From 6011453a14d3035a72d8fb7afa055a6b5ec2f24c Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Tue, 18 Nov 2014 17:01:31 -0800 Subject: [PATCH 1/2] Replaced tabs with spaces and removed usage of several deprecated features: * dict.has_key -> `in` operator * backticks -> repr Also removed trailing newlines from a few files. flake8 --select='W' no longer reports any issues --- letsencrypt/client/CONFIG.py | 4 ++-- letsencrypt/client/acme.py | 4 ++-- letsencrypt/client/challenge.py | 1 - letsencrypt/client/client.py | 2 +- letsencrypt/client/configurator.py | 4 ++-- letsencrypt/client/logger.py | 5 ----- letsencrypt/client/payment_challenge.py | 1 - 7 files changed, 7 insertions(+), 14 deletions(-) diff --git a/letsencrypt/client/CONFIG.py b/letsencrypt/client/CONFIG.py index 832b5b4ce..8c7c4b6d4 100644 --- a/letsencrypt/client/CONFIG.py +++ b/letsencrypt/client/CONFIG.py @@ -40,13 +40,13 @@ NONCE_SIZE = 16 RSA_KEY_SIZE = 2048 # bits of hashcash to generate -difficulty = 23 +difficulty = 23 # Let's Encrypt cert and chain files CERT_PATH = CERT_DIR + "cert-letsencrypt.pem" CHAIN_PATH = CERT_DIR + "chain-letsencrypt.pem" -#Invalid Extension +#Invalid Extension INVALID_EXT = ".acme.invalid" # Challenge Preferences Dict for currently supported challenges diff --git a/letsencrypt/client/acme.py b/letsencrypt/client/acme.py index 306ee9171..70a5982ad 100755 --- a/letsencrypt/client/acme.py +++ b/letsencrypt/client/acme.py @@ -19,9 +19,9 @@ def acme_object_validate(j): j = json.loads(j) if not isinstance(j, dict): raise jsonschema.ValidationError("this is not a dictionary object") - if not j.has_key("type"): + if "type" not in j: raise jsonschema.ValidationError("missing type field") - if not schemata.has_key(j["type"]): + if j["type"] not in schemata: raise jsonschema.ValidationError("unknown type %s" % j["type"]) jsonschema.validate(j, schemata[j["type"]]) diff --git a/letsencrypt/client/challenge.py b/letsencrypt/client/challenge.py index a25e60be0..2ccf9406f 100644 --- a/letsencrypt/client/challenge.py +++ b/letsencrypt/client/challenge.py @@ -10,4 +10,3 @@ class Challenge(object): logger.error("Error - base class challenge.generate_response()") def clean(self): logger.error("Error - base class challenge.clean()") - diff --git a/letsencrypt/client/client.py b/letsencrypt/client/client.py index 0f625804d..198c4139c 100755 --- a/letsencrypt/client/client.py +++ b/letsencrypt/client/client.py @@ -688,7 +688,7 @@ class Client(object): def sanity_check_names(self, names): for name in names: if not self.is_hostname_sane(name): - logger.fatal(`name` + " is an impossible hostname") + logger.fatal(repr(name) + " is an impossible hostname") sys.exit(81) def is_hostname_sane(self, hostname): diff --git a/letsencrypt/client/configurator.py b/letsencrypt/client/configurator.py index 6f5aabf58..c5b0e1f92 100644 --- a/letsencrypt/client/configurator.py +++ b/letsencrypt/client/configurator.py @@ -907,12 +907,12 @@ LogLevel warn \n\ Enables mod_ssl """ try: - # Use check_output so the command will finish before reloading + # Use check_output so the command will finish before reloading subprocess.check_call(["sudo", "a2enmod", mod_name], stdout=open("/dev/null", 'w'), stderr=open("/dev/null", 'w')) # Hopefully this waits for output subprocess.check_call(["sudo", "/etc/init.d/apache2", "restart"], stdout=open("/dev/null", 'w'), stderr=open("/dev/null", 'w')) except: - logger.error("Error enabling mod_" + mod_name) + logger.error("Error enabling mod_" + mod_name) sys.exit(1) def fnmatch_to_re(self, cleanFNmatch): diff --git a/letsencrypt/client/logger.py b/letsencrypt/client/logger.py index b285c2359..86a8da846 100644 --- a/letsencrypt/client/logger.py +++ b/letsencrypt/client/logger.py @@ -168,8 +168,3 @@ if __name__ == "__main__": logger.error("errrrr") logger.trace("some trace data: %d - %f - %s" % (5, 8.3, 'cows')) - - - - - diff --git a/letsencrypt/client/payment_challenge.py b/letsencrypt/client/payment_challenge.py index 773975d68..e3c4494d5 100644 --- a/letsencrypt/client/payment_challenge.py +++ b/letsencrypt/client/payment_challenge.py @@ -43,4 +43,3 @@ class Payment_Challenge(Challenge): def formatted_reasons(self): return "\n\t* %s\n" % self.reason - From 08e07e67a64660e6e035e415bcf345d422343cde Mon Sep 17 00:00:00 2001 From: James Kasten Date: Tue, 18 Nov 2014 18:00:30 -0800 Subject: [PATCH 2/2] small cleanup --- letsencrypt.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/letsencrypt.py b/letsencrypt.py index da302af2b..b680ab0f9 100755 --- a/letsencrypt.py +++ b/letsencrypt.py @@ -82,10 +82,10 @@ def main(): display.setDisplay(display.NcursesDisplay()) else: display.setDisplay(display.FileDisplay(sys.stdout)) - + if not server: server = ACME_SERVER - + c = client.Client(server, csr, privkey, curses) if flag_revoke: c.list_certs_keys() @@ -108,7 +108,7 @@ def print_options(): "view-checkpoints (Used to view available checkpoints and " + "see what configuration changes have been made)", "rollback=X (Revert the configuration X number of checkpoints)", - "redirect (Automatically redirect all HTTP traffic to " + + "redirect (Automatically redirect all HTTP traffic to " + "HTTPS for the newly authenticated vhost)", "no-redirect (Skip the HTTPS redirect question, " + "allowing both HTTP and HTTPS)",