").replace("
[^";]+)'), dkim_content, re.M | re.S
+ '[^"]*"v=(?P [^";]+)'), dkim_content, re.M | re.S
)
else:
dkim = re.match((
r'^(?P [^";]+)'), dkim_content, re.M | re.S
+ '[^"]*"v=(?P [^";]+)'), dkim_content, re.M | re.S
)
if not dkim:
diff --git a/src/yunohost/hook.py b/src/yunohost/hook.py
index b57300f54..f939f2c99 100644
--- a/src/yunohost/hook.py
+++ b/src/yunohost/hook.py
@@ -270,9 +270,9 @@ def hook_callback(action, hooks=[], args=None, no_trace=False, chdir=None,
# Validate callbacks
if not callable(pre_callback):
- pre_callback = lambda name, priority, path, args: args
+ def pre_callback(name, priority, path, args): return args
if not callable(post_callback):
- post_callback = lambda name, priority, path, succeed: None
+ def post_callback(name, priority, path, succeed): return None
# Iterate over hooks and execute them
for priority in sorted(hooks_dict):
@@ -283,7 +283,7 @@ def hook_callback(action, hooks=[], args=None, no_trace=False, chdir=None,
hook_args = pre_callback(name=name, priority=priority,
path=path, args=args)
hook_return = hook_exec(path, args=hook_args, chdir=chdir, env=env,
- no_trace=no_trace, raise_on_error=True)[1]
+ no_trace=no_trace, raise_on_error=True)[1]
except YunohostError as e:
state = 'failed'
hook_return = {}
@@ -293,9 +293,9 @@ def hook_callback(action, hooks=[], args=None, no_trace=False, chdir=None,
else:
post_callback(name=name, priority=priority, path=path,
succeed=True)
- if not name in result:
+ if name not in result:
result[name] = {}
- result[name][path] = {'state' : state, 'stdreturn' : hook_return }
+ result[name][path] = {'state': state, 'stdreturn': hook_return}
return result
@@ -446,17 +446,17 @@ def _hook_exec_python(path, args, env, loggers):
dir_ = os.path.dirname(path)
name = os.path.splitext(os.path.basename(path))[0]
- if not dir_ in sys.path:
+ if dir_ not in sys.path:
sys.path = [dir_] + sys.path
module = import_module(name)
ret = module.main(args, env, loggers)
# # Assert that the return is a (int, dict) tuple
assert isinstance(ret, tuple) \
- and len(ret) == 2 \
- and isinstance(ret[0],int) \
- and isinstance(ret[1],dict), \
- "Module %s did not return a (int, dict) tuple !" % module
+ and len(ret) == 2 \
+ and isinstance(ret[0], int) \
+ and isinstance(ret[1], dict), \
+ "Module %s did not return a (int, dict) tuple !" % module
return ret
diff --git a/src/yunohost/log.py b/src/yunohost/log.py
index 892105c6b..88da1ebf0 100644
--- a/src/yunohost/log.py
+++ b/src/yunohost/log.py
@@ -270,7 +270,7 @@ def log_display(path, number=None, share=False, filter_irrelevant=False, with_su
if os.path.exists(log_path):
from yunohost.service import _tail
if number and filters:
- logs = _tail(log_path, int(number*4))
+ logs = _tail(log_path, int(number * 4))
elif number:
logs = _tail(log_path, int(number))
else:
diff --git a/src/yunohost/regenconf.py b/src/yunohost/regenconf.py
index 7f4f73247..6b369fc8c 100644
--- a/src/yunohost/regenconf.py
+++ b/src/yunohost/regenconf.py
@@ -47,7 +47,7 @@ logger = log.getActionLogger('yunohost.regenconf')
# FIXME : check for all reference of 'service' close to operation_logger stuff
@is_unit_operation([('names', 'configuration')])
def regen_conf(operation_logger, names=[], with_diff=False, force=False, dry_run=False,
- list_pending=False):
+ list_pending=False):
"""
Regenerate the configuration file(s)
diff --git a/src/yunohost/service.py b/src/yunohost/service.py
index 522395718..084df471d 100644
--- a/src/yunohost/service.py
+++ b/src/yunohost/service.py
@@ -654,7 +654,6 @@ def _tail(file, n):
avg_line_length = 74
to_read = n
-
try:
if file.endswith(".gz"):
import gzip
diff --git a/src/yunohost/settings.py b/src/yunohost/settings.py
index 9b8589d35..0f8860529 100644
--- a/src/yunohost/settings.py
+++ b/src/yunohost/settings.py
@@ -15,6 +15,7 @@ logger = getActionLogger('yunohost.settings')
SETTINGS_PATH = "/etc/yunohost/settings.json"
SETTINGS_PATH_OTHER_LOCATION = "/etc/yunohost/settings-%s.json"
+
def is_boolean(value):
"""
Ensure a string value is intended as a boolean
@@ -60,11 +61,11 @@ DEFAULTS = OrderedDict([
("service.ssh.allow_deprecated_dsa_hostkey", {"type": "bool", "default": False}),
("security.ssh.compatibility", {"type": "enum", "default": "modern",
- "choices": ["intermediate", "modern"]}),
+ "choices": ["intermediate", "modern"]}),
("security.nginx.compatibility", {"type": "enum", "default": "intermediate",
- "choices": ["intermediate", "modern"]}),
+ "choices": ["intermediate", "modern"]}),
("security.postfix.compatibility", {"type": "enum", "default": "intermediate",
- "choices": ["intermediate", "modern"]}),
+ "choices": ["intermediate", "modern"]}),
("pop3.enabled", {"type": "bool", "default": False}),
("smtp.allow_ipv6", {"type": "bool", "default": True}),
@@ -321,17 +322,20 @@ def reconfigure_nginx(setting_name, old_value, new_value):
if old_value != new_value:
service_regen_conf(names=['nginx'])
+
@post_change_hook("security.ssh.compatibility")
def reconfigure_ssh(setting_name, old_value, new_value):
if old_value != new_value:
service_regen_conf(names=['ssh'])
+
@post_change_hook("smtp.allow_ipv6")
@post_change_hook("security.postfix.compatibility")
def reconfigure_postfix(setting_name, old_value, new_value):
if old_value != new_value:
service_regen_conf(names=['postfix'])
+
@post_change_hook("pop3.enabled")
def reconfigure_dovecot(setting_name, old_value, new_value):
dovecot_package = 'dovecot-pop3d'
diff --git a/src/yunohost/tools.py b/src/yunohost/tools.py
index 2e90b38ee..fcc2810d6 100644
--- a/src/yunohost/tools.py
+++ b/src/yunohost/tools.py
@@ -51,9 +51,11 @@ MIGRATIONS_STATE_PATH = "/etc/yunohost/migrations.yaml"
logger = getActionLogger('yunohost.tools')
+
def tools_versions():
return ynh_packages_version()
+
def tools_ldapinit():
"""
YunoHost LDAP initialization
@@ -146,7 +148,7 @@ def tools_adminpw(new_password, check_strength=True):
ldap = _get_ldap_interface()
try:
- ldap.update("cn=admin", {"userPassword": [ new_hash ], })
+ ldap.update("cn=admin", {"userPassword": [new_hash], })
except:
logger.exception('unable to change admin password')
raise YunohostError('admin_password_change_failed')
@@ -599,7 +601,6 @@ def tools_upgrade(operation_logger, apps=None, system=False, allow_yunohost_upgr
logger.debug("Running apt command :\n{}".format(dist_upgrade))
-
def is_relevant(l):
irrelevants = [
"service sudo-ldap already provided",
@@ -936,7 +937,7 @@ def _migrate_legacy_migration_json():
# Extract the list of migration ids
from . import data_migrations
migrations_path = data_migrations.__path__[0]
- migration_files = filter(lambda x: re.match("^\d+_[a-zA-Z0-9_]+\.py$", x), os.listdir(migrations_path))
+ migration_files = filter(lambda x: re.match(r"^\d+_[a-zA-Z0-9_]+\.py$", x), os.listdir(migrations_path))
# (here we remove the .py extension and make sure the ids are sorted)
migration_ids = sorted([f.rsplit(".", 1)[0] for f in migration_files])
@@ -985,7 +986,7 @@ def _get_migrations_list():
# (in particular, pending migrations / not already ran are not listed
states = tools_migrations_state()["migrations"]
- for migration_file in filter(lambda x: re.match("^\d+_[a-zA-Z0-9_]+\.py$", x), os.listdir(migrations_path)):
+ for migration_file in filter(lambda x: re.match(r"^\d+_[a-zA-Z0-9_]+\.py$", x), os.listdir(migrations_path)):
m = _load_migration(migration_file)
m.state = states.get(m.id, "pending")
migrations.append(m)
@@ -1004,7 +1005,7 @@ def _get_migration_by_name(migration_name):
raise AssertionError("Unable to find migration with name %s" % migration_name)
migrations_path = data_migrations.__path__[0]
- migrations_found = filter(lambda x: re.match("^\d+_%s\.py$" % migration_name, x), os.listdir(migrations_path))
+ migrations_found = filter(lambda x: re.match(r"^\d+_%s\.py$" % migration_name, x), os.listdir(migrations_path))
assert len(migrations_found) == 1, "Unable to find migration with name %s" % migration_name
@@ -1048,7 +1049,7 @@ class Migration(object):
# Those are to be implemented by daughter classes
mode = "auto"
- dependencies = [] # List of migration ids required before running this migration
+ dependencies = [] # List of migration ids required before running this migration
@property
def disclaimer(self):