mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
autopep8 --in-place -a -a -a --ignore E402,E501,E722 -r src/yunohost/{__init__.py,certificate.py,diagnosis.py,domain.py,dyndns.py,firewall.py,hook.py,log.py,regenconf.py,service.py,settings.py,ssh.py,tools.py}
This commit is contained in:
parent
ecbd63636b
commit
49f6394233
9 changed files with 40 additions and 35 deletions
|
@ -91,7 +91,7 @@ def init_logging(interface="cli",
|
|||
logfile = os.path.join(logdir, "yunohost-%s.log" % interface)
|
||||
|
||||
if not os.path.isdir(logdir):
|
||||
os.makedirs(logdir, 0750)
|
||||
os.makedirs(logdir, 0o750)
|
||||
|
||||
# ####################################################################### #
|
||||
# Logging configuration for CLI (or any other interface than api...) #
|
||||
|
|
|
@ -477,6 +477,7 @@ class Diagnoser():
|
|||
meta_data.update(item.get("data", {}))
|
||||
|
||||
html_tags = re.compile(r'<[^>]+>')
|
||||
|
||||
def m18n_(info):
|
||||
if not isinstance(info, tuple) and not isinstance(info, list):
|
||||
info = (info, {})
|
||||
|
|
|
@ -615,15 +615,15 @@ def _get_DKIM(domain):
|
|||
dkim = re.match((
|
||||
r'^(?P<host>[a-z_\-\.]+)[\s]+([0-9]+[\s]+)?IN[\s]+TXT[\s]+'
|
||||
'[^"]*"v=(?P<v>[^";]+);'
|
||||
'[\s"]*k=(?P<k>[^";]+);'
|
||||
r'[\s"]*k=(?P<k>[^";]+);'
|
||||
'[\s"]*p=(?P<p>[^";]+)'), dkim_content, re.M | re.S
|
||||
)
|
||||
else:
|
||||
dkim = re.match((
|
||||
r'^(?P<host>[a-z_\-\.]+)[\s]+([0-9]+[\s]+)?IN[\s]+TXT[\s]+'
|
||||
'[^"]*"v=(?P<v>[^";]+);'
|
||||
'[\s"]*h=(?P<h>[^";]+);'
|
||||
'[\s"]*k=(?P<k>[^";]+);'
|
||||
r'[\s"]*h=(?P<h>[^";]+);'
|
||||
r'[\s"]*k=(?P<k>[^";]+);'
|
||||
'[\s"]*p=(?P<p>[^";]+)'), dkim_content, re.M | re.S
|
||||
)
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
@ -293,7 +293,7 @@ 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}
|
||||
return result
|
||||
|
@ -446,7 +446,7 @@ 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)
|
||||
|
||||
|
|
|
@ -654,7 +654,6 @@ def _tail(file, n):
|
|||
avg_line_length = 74
|
||||
to_read = n
|
||||
|
||||
|
||||
try:
|
||||
if file.endswith(".gz"):
|
||||
import gzip
|
||||
|
|
|
@ -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
|
||||
|
@ -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'
|
||||
|
|
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue