From 372b6cfc13494b95028d4ec531b842685ecf370a Mon Sep 17 00:00:00 2001
From: "Kali Kaneko (leap communications)" <kali@leap.se>
Date: Thu, 29 Sep 2016 12:24:49 -0400
Subject: [bug] remove destructor, pass combined_ca_bundle as optional param

this brings back a couple of commits by pixelated that were missed in my
keymanager merge.

https://github.com/leapcode/keymanager/commit/354ad5a12e90463f9952fe056f191c6d4cdadf40
https://github.com/leapcode/keymanager/commit/dd7ba606df2909c76b20b1d4bb0134302f94b3d0

basically it removes the destructor (there's no guarantee that it gets
executed!) and it addds the combined ca bundle as an optional parameter
to keymanager initialization
---
 src/leap/bitmask/keymanager/__init__.py | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)

(limited to 'src')

diff --git a/src/leap/bitmask/keymanager/__init__.py b/src/leap/bitmask/keymanager/__init__.py
index c3ece05..146bcd2 100644
--- a/src/leap/bitmask/keymanager/__init__.py
+++ b/src/leap/bitmask/keymanager/__init__.py
@@ -65,7 +65,7 @@ class KeyManager(object):
 
     def __init__(self, address, nickserver_uri, soledad, token=None,
                  ca_cert_path=None, api_uri=None, api_version=None, uid=None,
-                 gpgbinary=None):
+                 gpgbinary=None, combined_ca_bundle=None):
         """
         Initialize a Key Manager for user's C{address} with provider's
         nickserver reachable in C{nickserver_uri}.
@@ -98,23 +98,10 @@ class KeyManager(object):
         self.api_version = api_version
         self.uid = uid
         self._openpgp = OpenPGPScheme(soledad, gpgbinary=gpgbinary)
-        self._combined_ca_bundle = self._create_combined_bundle_file()
+        self._combined_ca_bundle = combined_ca_bundle or self._create_combined_bundle_file()
         self._async_client = HTTPClient(self._combined_ca_bundle)
         self._async_client_pinned = HTTPClient(self._ca_cert_path)
 
-    #
-    # destructor
-    #
-
-    def __del__(self):
-        try:
-            created_tmp_combined_ca_bundle = self._combined_ca_bundle not in \
-                [ca_bundle.where(), self._ca_cert_path]
-            if created_tmp_combined_ca_bundle:
-                os.remove(self._combined_ca_bundle)
-        except OSError:
-            pass
-
     #
     # utilities
     #
-- 
cgit v1.2.3