[mod] autopep8

This commit is contained in:
Laurent Peuch 2016-05-13 04:34:31 +02:00
parent bb87c41bc0
commit 8694cde7ab

View file

@ -44,7 +44,7 @@ from yunohost.service import service_status, service_regen_conf, service_log
from yunohost.monitor import monitor_disk, monitor_system from yunohost.monitor import monitor_disk, monitor_system
from yunohost.utils.packages import ynh_packages_version from yunohost.utils.packages import ynh_packages_version
apps_setting_path= '/etc/yunohost/apps/' apps_setting_path = '/etc/yunohost/apps/'
logger = getActionLogger('yunohost.tools') logger = getActionLogger('yunohost.tools')
@ -59,12 +59,16 @@ def tools_ldapinit(auth):
ldap_map = yaml.load(f) ldap_map = yaml.load(f)
for rdn, attr_dict in ldap_map['parents'].items(): for rdn, attr_dict in ldap_map['parents'].items():
try: auth.add(rdn, attr_dict) try:
except: pass auth.add(rdn, attr_dict)
except:
pass
for rdn, attr_dict in ldap_map['children'].items(): for rdn, attr_dict in ldap_map['children'].items():
try: auth.add(rdn, attr_dict) try:
except: pass auth.add(rdn, attr_dict)
except:
pass
admin_dict = { admin_dict = {
'cn': 'admin', 'cn': 'admin',
@ -115,7 +119,7 @@ def tools_maindomain(auth, old_domain=None, new_domain=None, dyndns=False):
old_domain = f.readline().rstrip() old_domain = f.readline().rstrip()
if not new_domain: if not new_domain:
return { 'current_main_domain': old_domain } return {'current_main_domain': old_domain}
if not new_domain: if not new_domain:
raise MoulinetteError(errno.EINVAL, m18n.n('new_domain_required')) raise MoulinetteError(errno.EINVAL, m18n.n('new_domain_required'))
@ -150,7 +154,8 @@ def tools_maindomain(auth, old_domain=None, new_domain=None, dyndns=False):
try: try:
with open('/etc/yunohost/installed', 'r') as f: with open('/etc/yunohost/installed', 'r') as f:
service_regen_conf() service_regen_conf()
except IOError: pass except IOError:
pass
logger.success(m18n.n('maindomain_changed')) logger.success(m18n.n('maindomain_changed'))
@ -192,7 +197,7 @@ def tools_postinstall(domain, password, ignore_dyndns=False):
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')
# Initialize LDAP for YunoHost # Initialize LDAP for YunoHost
@ -209,8 +214,10 @@ def tools_postinstall(domain, password, ignore_dyndns=False):
] ]
for folder in folders_to_create: for folder in folders_to_create:
try: os.listdir(folder) try:
except OSError: os.makedirs(folder) os.listdir(folder)
except OSError:
os.makedirs(folder)
# Change folders permissions # Change folders permissions
os.system('chmod 755 /home/yunohost.app') os.system('chmod 755 /home/yunohost.app')
@ -229,7 +236,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'
with open('/etc/ssowat/conf.json.persistent', 'w+') as f: with open('/etc/ssowat/conf.json.persistent', 'w+') as f:
json.dump(ssowat_conf, f, sort_keys=True, indent=4) json.dump(ssowat_conf, f, sort_keys=True, indent=4)
@ -341,7 +348,7 @@ def tools_update(ignore_apps=False, ignore_packages=False):
if len(apps) == 0 and len(packages) == 0: if len(apps) == 0 and len(packages) == 0:
logger.info(m18n.n('packages_no_upgrade')) logger.info(m18n.n('packages_no_upgrade'))
return { 'packages': packages, 'apps': apps } return {'packages': packages, 'apps': apps}
def tools_upgrade(auth, ignore_apps=False, ignore_packages=False): def tools_upgrade(auth, ignore_apps=False, ignore_packages=False):
@ -410,7 +417,7 @@ def tools_upgrade(auth, ignore_apps=False, ignore_packages=False):
# Return API logs if it is an API call # Return API logs if it is an API call
if is_api: if is_api:
return { "log": service_log('yunohost-api', number="100").values()[0] } return {"log": service_log('yunohost-api', number="100").values()[0]}
def tools_diagnosis(auth, private=False): def tools_diagnosis(auth, private=False):
@ -418,7 +425,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:
@ -462,8 +469,8 @@ def tools_diagnosis(auth, private=False):
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