[mod] pep8 on tools.py

This commit is contained in:
Laurent Peuch 2017-08-20 21:18:25 +02:00
parent 66524213cd
commit 40ea2f9477

View file

@ -52,7 +52,7 @@ from yunohost.monitor import monitor_disk, monitor_system
from yunohost.utils.packages import ynh_packages_version from yunohost.utils.packages import ynh_packages_version
# FIXME this is a duplicate from apps.py # FIXME this is a duplicate from apps.py
APPS_SETTING_PATH= '/etc/yunohost/apps/' APPS_SETTING_PATH = '/etc/yunohost/apps/'
MIGRATIONS_STATE_PATH = "/etc/yunohost/migrations_state.json" MIGRATIONS_STATE_PATH = "/etc/yunohost/migrations_state.json"
logger = getActionLogger('yunohost.tools') logger = getActionLogger('yunohost.tools')
@ -69,7 +69,7 @@ def tools_ldapinit():
auth = init_authenticator(('ldap', 'default'), auth = init_authenticator(('ldap', 'default'),
{'uri': "ldap://localhost:389", {'uri': "ldap://localhost:389",
'base_dn': "dc=yunohost,dc=org", 'base_dn': "dc=yunohost,dc=org",
'user_rdn': "cn=admin" }) 'user_rdn': "cn=admin"})
auth.authenticate('yunohost') auth.authenticate('yunohost')
with open('/usr/share/yunohost/yunohost-config/moulinette/ldap_scheme.yml') as f: with open('/usr/share/yunohost/yunohost-config/moulinette/ldap_scheme.yml') as f:
@ -114,6 +114,7 @@ def tools_ldapinit():
logger.success(m18n.n('ldap_initialized')) logger.success(m18n.n('ldap_initialized'))
return auth return auth
def tools_adminpw(auth, new_password): def tools_adminpw(auth, new_password):
""" """
Change admin password Change admin password
@ -319,7 +320,7 @@ def tools_postinstall(domain, password, ignore_dyndns=False):
if 'redirected_urls' not in ssowat_conf: if 'redirected_urls' not in ssowat_conf:
ssowat_conf['redirected_urls'] = {} ssowat_conf['redirected_urls'] = {}
ssowat_conf['redirected_urls']['/'] = domain +'/yunohost/admin' ssowat_conf['redirected_urls']['/'] = domain + '/yunohost/admin'
try: try:
with open('/etc/ssowat/conf.json.persistent', 'w+') as f: with open('/etc/ssowat/conf.json.persistent', 'w+') as f:
@ -328,7 +329,6 @@ def tools_postinstall(domain, password, ignore_dyndns=False):
raise MoulinetteError(errno.EPERM, raise MoulinetteError(errno.EPERM,
m18n.n('ssowat_persistent_conf_write_error', error=e.strerror)) m18n.n('ssowat_persistent_conf_write_error', error=e.strerror))
os.system('chmod 644 /etc/ssowat/conf.json.persistent') os.system('chmod 644 /etc/ssowat/conf.json.persistent')
# Create SSL CA # Create SSL CA
@ -526,7 +526,7 @@ def tools_diagnosis(auth, private=False):
Return global info about current yunohost instance to help debugging Return global info about current yunohost instance to help debugging
""" """
diagnosis = OrderedDict(); diagnosis = OrderedDict()
# Debian release # Debian release
try: try:
@ -567,15 +567,14 @@ def tools_diagnosis(auth, private=False):
disks[disk]['avail'] disks[disk]['avail']
) )
try: try:
system = monitor_system(units=['cpu', 'memory'], human_readable=True) system = monitor_system(units=['cpu', 'memory'], human_readable=True)
except MoulinetteError as e: except MoulinetteError as e:
logger.warning(m18n.n('diagnosis_monitor_system_error', error=format(e)), exc_info=1) logger.warning(m18n.n('diagnosis_monitor_system_error', error=format(e)), exc_info=1)
else: else:
diagnosis['system']['memory'] = { diagnosis['system']['memory'] = {
'ram' : '%s (%s free)' % (system['memory']['ram']['total'], system['memory']['ram']['free']), 'ram': '%s (%s free)' % (system['memory']['ram']['total'], system['memory']['ram']['free']),
'swap' : '%s (%s free)' % (system['memory']['swap']['total'], system['memory']['swap']['free']), 'swap': '%s (%s free)' % (system['memory']['swap']['total'], system['memory']['swap']['free']),
} }
# Services status # Services status
@ -867,6 +866,7 @@ def _get_migrations_list():
class Migration(object): class Migration(object):
def migrate(self): def migrate(self):
self.forward() self.forward()