diff options
author | Kali Kaneko (leap communications) <kali@leap.se> | 2016-10-27 00:48:54 +0200 |
---|---|---|
committer | Kali Kaneko (leap communications) <kali@leap.se> | 2016-11-03 14:28:04 +0100 |
commit | 3d2d564a966679086156c844d8c58b11751163a3 (patch) | |
tree | 15c6b2cbd4541335c94a7808e0acb19d443b2232 /src/leap/bitmask/core | |
parent | 12bbdc84a744aaa2af4130539a2a7188996c7659 (diff) |
[style] pep8 fixes
Diffstat (limited to 'src/leap/bitmask/core')
-rw-r--r-- | src/leap/bitmask/core/__init__.py | 21 | ||||
-rw-r--r-- | src/leap/bitmask/core/launcher.py | 1 | ||||
-rw-r--r-- | src/leap/bitmask/core/uuid_map.py | 21 |
3 files changed, 25 insertions, 18 deletions
diff --git a/src/leap/bitmask/core/__init__.py b/src/leap/bitmask/core/__init__.py index 55672e4e..5af0f38f 100644 --- a/src/leap/bitmask/core/__init__.py +++ b/src/leap/bitmask/core/__init__.py @@ -1,15 +1,20 @@ import platform +# FIXME some temporary imports to make the modules +# appear in the coverage report. Remove the imports when +# test code cover them. + + +def dummy_imports(): + import service + import uuid_map + import mail_services + import dispatcher + APPNAME = "bitmask.core" -if platform.system() =='Windows': +if platform.system() == 'Windows': ENDPOINT = "tcp://127.0.0.1:5001" else: ENDPOINT = "ipc:///tmp/%s.sock" % APPNAME -# FIXME some temporary imports to make the modules -# appear in the coverage report. Remove the imports when -# test code cover them. -import service -import uuid_map -import mail_services -import dispatcher +dummy_imports() diff --git a/src/leap/bitmask/core/launcher.py b/src/leap/bitmask/core/launcher.py index 62e8575d..c6a2ab4a 100644 --- a/src/leap/bitmask/core/launcher.py +++ b/src/leap/bitmask/core/launcher.py @@ -32,6 +32,7 @@ pid = abspath(join(get_path_prefix(), 'leap', 'bitmaskd.pid')) STANDALONE = getattr(sys, 'frozen', False) + def here(module=None): if STANDALONE: # we are running in a |PyInstaller| bundle diff --git a/src/leap/bitmask/core/uuid_map.py b/src/leap/bitmask/core/uuid_map.py index b7041aa7..9c13fc57 100644 --- a/src/leap/bitmask/core/uuid_map.py +++ b/src/leap/bitmask/core/uuid_map.py @@ -33,7 +33,8 @@ if IS_WIN: import socket from cryptography.fernet import Fernet from cryptography.hazmat.backends.multibackend import MultiBackend - from cryptography.hazmat.backends.openssl.backend import Backend as OpenSSLBackend + from cryptography.hazmat.backends.openssl.backend \ + import Backend as OpenSSLBackend crypto_backend = MultiBackend([OpenSSLBackend()]) @@ -114,9 +115,9 @@ def _encode_uuid_map(userid, uuid, passwd): # TODO review usage of the raw passwd here if IS_WIN: key = scrypt.hash(passwd, socket.gethostname()) - key = base64.urlsafe_b64encode(key[:32]) - f = Fernet(key, backend=crypto_backend) - encrypted = f.encrypt(data) + key = base64.urlsafe_b64encode(key[:32]) + f = Fernet(key, backend=crypto_backend) + encrypted = f.encrypt(data) else: encrypted = scrypt.encrypt(data, passwd, maxtime=0.05) return base64.urlsafe_b64encode(encrypted) @@ -126,12 +127,12 @@ def _decode_uuid_line(line, passwd): decoded = base64.urlsafe_b64decode(line) if IS_WIN: key = scrypt.hash(passwd, socket.gethostname()) - key = base64.urlsafe_b64encode(key[:32]) - try: - f = Fernet(key, backend=crypto_backend) - maybe_decrypted = f.decrypt(key) - except Exception: - return None + key = base64.urlsafe_b64encode(key[:32]) + try: + f = Fernet(key, backend=crypto_backend) + maybe_decrypted = f.decrypt(key) + except Exception: + return None else: try: maybe_decrypted = scrypt.decrypt(decoded, passwd, maxtime=0.1) |