mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[mod] autopep8
This commit is contained in:
parent
bb87c41bc0
commit
8694cde7ab
1 changed files with 29 additions and 22 deletions
|
@ -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.utils.packages import ynh_packages_version
|
||||
|
||||
apps_setting_path= '/etc/yunohost/apps/'
|
||||
apps_setting_path = '/etc/yunohost/apps/'
|
||||
|
||||
logger = getActionLogger('yunohost.tools')
|
||||
|
||||
|
@ -59,12 +59,16 @@ def tools_ldapinit(auth):
|
|||
ldap_map = yaml.load(f)
|
||||
|
||||
for rdn, attr_dict in ldap_map['parents'].items():
|
||||
try: auth.add(rdn, attr_dict)
|
||||
except: pass
|
||||
try:
|
||||
auth.add(rdn, attr_dict)
|
||||
except:
|
||||
pass
|
||||
|
||||
for rdn, attr_dict in ldap_map['children'].items():
|
||||
try: auth.add(rdn, attr_dict)
|
||||
except: pass
|
||||
try:
|
||||
auth.add(rdn, attr_dict)
|
||||
except:
|
||||
pass
|
||||
|
||||
admin_dict = {
|
||||
'cn': 'admin',
|
||||
|
@ -115,7 +119,7 @@ def tools_maindomain(auth, old_domain=None, new_domain=None, dyndns=False):
|
|||
old_domain = f.readline().rstrip()
|
||||
|
||||
if not new_domain:
|
||||
return { 'current_main_domain': old_domain }
|
||||
return {'current_main_domain': old_domain}
|
||||
|
||||
if not new_domain:
|
||||
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:
|
||||
with open('/etc/yunohost/installed', 'r') as f:
|
||||
service_regen_conf()
|
||||
except IOError: pass
|
||||
except IOError:
|
||||
pass
|
||||
|
||||
logger.success(m18n.n('maindomain_changed'))
|
||||
|
||||
|
@ -192,7 +197,7 @@ def tools_postinstall(domain, password, ignore_dyndns=False):
|
|||
auth = init_authenticator(('ldap', 'default'),
|
||||
{'uri': "ldap://localhost:389",
|
||||
'base_dn': "dc=yunohost,dc=org",
|
||||
'user_rdn': "cn=admin" })
|
||||
'user_rdn': "cn=admin"})
|
||||
auth.authenticate('yunohost')
|
||||
|
||||
# Initialize LDAP for YunoHost
|
||||
|
@ -209,8 +214,10 @@ def tools_postinstall(domain, password, ignore_dyndns=False):
|
|||
]
|
||||
|
||||
for folder in folders_to_create:
|
||||
try: os.listdir(folder)
|
||||
except OSError: os.makedirs(folder)
|
||||
try:
|
||||
os.listdir(folder)
|
||||
except OSError:
|
||||
os.makedirs(folder)
|
||||
|
||||
# Change folders permissions
|
||||
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:
|
||||
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:
|
||||
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:
|
||||
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):
|
||||
|
@ -410,7 +417,7 @@ def tools_upgrade(auth, ignore_apps=False, ignore_packages=False):
|
|||
|
||||
# Return API logs if it is an API call
|
||||
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):
|
||||
|
@ -418,7 +425,7 @@ def tools_diagnosis(auth, private=False):
|
|||
Return global info about current yunohost instance to help debugging
|
||||
|
||||
"""
|
||||
diagnosis = OrderedDict();
|
||||
diagnosis = OrderedDict()
|
||||
|
||||
# Debian release
|
||||
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)
|
||||
else:
|
||||
diagnosis['system']['memory'] = {
|
||||
'ram' : '%s (%s free)' % (system['memory']['ram']['total'], system['memory']['ram']['free']),
|
||||
'swap' : '%s (%s free)' % (system['memory']['swap']['total'], system['memory']['swap']['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']),
|
||||
}
|
||||
|
||||
# Services status
|
||||
|
|
Loading…
Add table
Reference in a new issue