diff --git a/actions/letsencrypt b/actions/letsencrypt index d7da00e42..5e55598f9 100755 --- a/actions/letsencrypt +++ b/actions/letsencrypt @@ -23,11 +23,12 @@ Configuration helper for Let's Encrypt. import argparse import json import os +import shutil import subprocess import sys import re + import configobj -import shutil from plinth import action_utils from plinth.modules.config import config @@ -141,7 +142,7 @@ def get_validity_status(domain): output = subprocess.check_output(['certbot', 'certificates', '-d', domain]) output = output.decode(sys.stdout.encoding) - match = re.search('INVALID: (.*)\)', output) + match = re.search(r'INVALID: (.*)\)', output) if match is not None: validity = match.group(1).lower() elif re.search('VALID', output) is not None: @@ -194,7 +195,7 @@ def subcommand_revoke(arguments): process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - stdout, stderr = process.communicate() + _, stderr = process.communicate() if process.returncode: print(stderr.decode(), file=sys.stderr) sys.exit(1) @@ -216,7 +217,7 @@ def subcommand_obtain(arguments): process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - stdin, stderr = process.communicate() + _, stderr = process.communicate() if process.returncode: print(stderr.decode(), file=sys.stderr) sys.exit(1) @@ -390,7 +391,7 @@ def subcommand_delete(arguments): command = ['certbot', 'delete', '--cert-name', domain] process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - stdout, stderr = process.communicate() + _, stderr = process.communicate() if process.returncode: print(stderr.decode(), file=sys.stderr) sys.exit(1) diff --git a/plinth/modules/letsencrypt/templates/letsencrypt.html b/plinth/modules/letsencrypt/templates/letsencrypt.html index 6d5da3d79..47c37b772 100644 --- a/plinth/modules/letsencrypt/templates/letsencrypt.html +++ b/plinth/modules/letsencrypt/templates/letsencrypt.html @@ -160,11 +160,11 @@ {% if status.current_domain.name %} {% blocktrans with current_domain=status.current_domain.name %} Let Plinth manage certificate renewal of - {{ current_domain }} (recommmended) + {{ current_domain }} (recommended) {% endblocktrans %} {% else %} {% blocktrans with current_domain=status.current_domain.name %} - Let Plinth manage certificate renewal of the current domain (recommmended) + Let Plinth manage certificate renewal of the current domain (recommended) {% endblocktrans %} {% endif %} diff --git a/plinth/modules/letsencrypt/views.py b/plinth/modules/letsencrypt/views.py index e86826178..a3b1ea7b5 100644 --- a/plinth/modules/letsencrypt/views.py +++ b/plinth/modules/letsencrypt/views.py @@ -19,14 +19,15 @@ Plinth module for using Let's Encrypt. """ +import json +import logging + from django.contrib import messages from django.shortcuts import redirect from django.template.response import TemplateResponse from django.urls import reverse_lazy from django.utils.translation import ugettext as _ from django.views.decorators.http import require_POST -import json -import logging from plinth import actions from plinth.errors import ActionError @@ -138,10 +139,12 @@ def get_status(): status = actions.superuser_run('letsencrypt', ['get-status']) status = json.loads(status) curr_dom = config.get_domainname() - current_domain = {'name': curr_dom, - 'has_cert': curr_dom in status['domains'] and - status['domains'][curr_dom]['certificate_available'], - 'manage_hooks_enabled': _hooks_manage_enabled()} + current_domain = { + 'name': curr_dom, + 'has_cert': (curr_dom in status['domains'] and + status['domains'][curr_dom]['certificate_available']), + 'manage_hooks_enabled': _hooks_manage_enabled() + } status['current_domain'] = current_domain for domain_type, domains in names.domains.items(): @@ -156,10 +159,10 @@ def get_status(): def _hooks_manage_enabled(): - """Return status of hook management for current domain.""" - try: - output = actions.superuser_run('letsencrypt', - ['manage_hooks', 'status']) - except ActionError: - return False - return output.strip() == 'enabled' + """Return status of hook management for current domain.""" + try: + output = actions.superuser_run('letsencrypt', + ['manage_hooks', 'status']) + except ActionError: + return False + return output.strip() == 'enabled'