From 744b1c083ebe412e92daa1de459d807db226f6fc Mon Sep 17 00:00:00 2001 From: "Kali Kaneko (leap communications)" Date: Fri, 7 Oct 2016 10:21:50 -0400 Subject: [style] pep8 --- src/leap/bitmask/bonafide/_protocol.py | 2 +- src/leap/bitmask/cli/bitmask_cli.py | 1 - src/leap/bitmask/cli/logs.py | 4 ++-- src/leap/bitmask/core/dispatcher.py | 2 +- src/leap/bitmask/core/mail_services.py | 17 ++++++++++++----- src/leap/bitmask/hooks.py | 5 +++-- src/leap/bitmask/keymanager/__init__.py | 3 ++- src/leap/bitmask/mail/adaptors/soledad.py | 9 +++++---- src/leap/bitmask/mail/outgoing/service.py | 3 ++- src/leap/bitmask/mail/rfc3156.py | 1 + 10 files changed, 29 insertions(+), 18 deletions(-) diff --git a/src/leap/bitmask/bonafide/_protocol.py b/src/leap/bitmask/bonafide/_protocol.py index 622086f5..047ad842 100644 --- a/src/leap/bitmask/bonafide/_protocol.py +++ b/src/leap/bitmask/bonafide/_protocol.py @@ -1,4 +1,4 @@ - # -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- # _protocol.py # Copyright (C) 2014-2015 LEAP # diff --git a/src/leap/bitmask/cli/bitmask_cli.py b/src/leap/bitmask/cli/bitmask_cli.py index ab3c2069..c27cabfc 100755 --- a/src/leap/bitmask/cli/bitmask_cli.py +++ b/src/leap/bitmask/cli/bitmask_cli.py @@ -136,7 +136,6 @@ def _null_printer(*args): pass - def main(): def signal_handler(signal, frame): if reactor.running: diff --git a/src/leap/bitmask/cli/logs.py b/src/leap/bitmask/cli/logs.py index 0976ebc9..ae7acaec 100644 --- a/src/leap/bitmask/cli/logs.py +++ b/src/leap/bitmask/cli/logs.py @@ -56,7 +56,7 @@ SUBCOMMANDS: def watch(self, raw_args): def tail(_file): - _file.seek(0,2) # Go to the end of the file + _file.seek(0, 2) # Go to the end of the file while True: line = _file.readline() if not line: @@ -66,7 +66,7 @@ SUBCOMMANDS: _file = open(_log_path, 'r') print (Fore.GREEN + '[bitmask] ' + - Fore.RESET + 'Watching log file %s' % _log_path ) + Fore.RESET + 'Watching log file %s' % _log_path) for line in _file.readlines(): print line, for line in tail(_file): diff --git a/src/leap/bitmask/core/dispatcher.py b/src/leap/bitmask/core/dispatcher.py index 783094ad..2d22b57e 100644 --- a/src/leap/bitmask/core/dispatcher.py +++ b/src/leap/bitmask/core/dispatcher.py @@ -472,7 +472,7 @@ def _format_error(failure): # If a exception declares the 'expected' attribute as True, # we will not print a full traceback - expected = getattr(failure.value, 'expected', False) + expected = getattr(failure.value, 'expected', False) if not expected: logger.failure('[DISPATCHER] Unexpected error:') diff --git a/src/leap/bitmask/core/mail_services.py b/src/leap/bitmask/core/mail_services.py index 564f4325..a82659a9 100644 --- a/src/leap/bitmask/core/mail_services.py +++ b/src/leap/bitmask/core/mail_services.py @@ -184,7 +184,8 @@ class SoledadService(HookableService): password = kw.get('password') uuid = kw.get('uuid') container = self._container - logger.debug("on_passphrase_entry: New Soledad Instance: %s" % userid) + logger.debug("on_passphrase_entry: " + "New Soledad Instance: %s" % userid) if not container.get_instance(userid): container.add_instance(userid, password, uuid=uuid, token=None) else: @@ -271,7 +272,9 @@ class KeymanagerContainer(Container): logger.info("key generated for %s" % userid) if not keymanager.token: - logger.debug("token not available, scheduling new send attempt...") + logger.debug( + "token not available, scheduling " + "a new key sending attempt...") return task.deferLater(reactor, 5, _send_key, None) logger.info("sending public key to server") @@ -384,7 +387,9 @@ class KeymanagerService(HookableService): container = self._container if container.get_instance(userid): - logger.debug('Passing a new SRP Token to Keymanager: %s' % userid) + logger.debug( + 'passing a new SRP Token ' + 'to Keymanager: %s' % userid) container.set_remote_auth_token(userid, token) else: logger.debug('storing the keymanager token... %s ' % token) @@ -533,7 +538,9 @@ class StandardMailService(service.MultiService, HookableService): username = kw['username'] multiservice = self.getServiceNamed('incoming_mail') incoming = multiservice.getServiceNamed(username) - logger.debug('looking for incoming mail service for logout: %s' % username) + logger.debug( + 'looking for incoming mail service ' + 'for logout: %s' % username) if incoming: incoming.stopService() @@ -565,7 +572,7 @@ class StandardMailService(service.MultiService, HookableService): shutil.rmtree(tokens_folder) except OSError as e: logger.warning("Can't remove tokens folder %s: %s" - % (tokens_folder, e)) + % (tokens_folder, e)) return os.mkdir(tokens_folder, 0700) diff --git a/src/leap/bitmask/hooks.py b/src/leap/bitmask/hooks.py index 7d9825e2..79edf6c6 100644 --- a/src/leap/bitmask/hooks.py +++ b/src/leap/bitmask/hooks.py @@ -54,8 +54,9 @@ class HookableService(Service): getattr(listener, 'hook_' + name)(**kw) except AttributeError as exc: raise RuntimeError( - "Tried to notify a hook, but the listener service class %s " - "has not defined the proper method %s" % + "Tried to notify a hook, but the listener " + "service class %s has not defined the " + "proper method %s" % (listener.__class__, 'hook_' + name)) if not hasattr(self, 'event_listeners'): diff --git a/src/leap/bitmask/keymanager/__init__.py b/src/leap/bitmask/keymanager/__init__.py index aafb9ce0..be3730a7 100644 --- a/src/leap/bitmask/keymanager/__init__.py +++ b/src/leap/bitmask/keymanager/__init__.py @@ -97,7 +97,8 @@ class KeyManager(object): self.api_version = api_version self.uid = uid self._openpgp = OpenPGPScheme(soledad, gpgbinary=gpgbinary) - self._combined_ca_bundle = combined_ca_bundle or self._create_combined_bundle_file() + create = self._create_combined_bundle_file + self._combined_ca_bundle = combined_ca_bundle or create() self._async_client = HTTPClient(self._combined_ca_bundle) self._async_client_pinned = HTTPClient(self._ca_cert_path) diff --git a/src/leap/bitmask/mail/adaptors/soledad.py b/src/leap/bitmask/mail/adaptors/soledad.py index b8153e56..74f346bd 100644 --- a/src/leap/bitmask/mail/adaptors/soledad.py +++ b/src/leap/bitmask/mail/adaptors/soledad.py @@ -945,11 +945,12 @@ class SoledadMailAdaptor(SoledadIndexMixin): # See https://leap.se/code/issues/7495. # This avoids blocks, but the real cause still needs to be # isolated (0.9.0rc3) -- kali - logger.debug("BUG ---------------------------------------------------") - logger.debug("BUG: Error while retrieving part docs for mdoc id %s" % - mdoc_id) + logger.debug("BUG ------------------------------------------") + logger.debug( + "BUG: Error while retrieving part docs for mdoc id %s" % + mdoc_id) logger.error(failure) - logger.debug("BUG (please report above info) ------------------------") + logger.debug("BUG (please report above info) ---------------") return [] def _err_log_cannot_find_msg(failure): diff --git a/src/leap/bitmask/mail/outgoing/service.py b/src/leap/bitmask/mail/outgoing/service.py index f483763a..accb9e5d 100644 --- a/src/leap/bitmask/mail/outgoing/service.py +++ b/src/leap/bitmask/mail/outgoing/service.py @@ -208,7 +208,8 @@ class OutgoingMail(object): :type encrypt_and_sign_result: tuple """ message, recipient = encrypt_and_sign_result - logger.info("Connecting to SMTP server %s:%s" % (self._host, self._port)) + logger.info( + 'Connecting to SMTP server %s:%s' % (self._host, self._port)) msg = message.as_string(False) # we construct a defer to pass to the ESMTPSenderFactory diff --git a/src/leap/bitmask/mail/rfc3156.py b/src/leap/bitmask/mail/rfc3156.py index 1ab631f8..e602b6b6 100644 --- a/src/leap/bitmask/mail/rfc3156.py +++ b/src/leap/bitmask/mail/rfc3156.py @@ -40,6 +40,7 @@ logger = Logger() # A generator that solves http://bugs.python.org/issue14983 # + class RFC3156CompliantGenerator(Generator): """ An email generator that addresses Python's issue #14983 for multipart -- cgit v1.2.3