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
88a6c3d83a
commit
3235f5f3fe
1 changed files with 77 additions and 64 deletions
|
@ -397,8 +397,8 @@ def app_map(app=None, raw=False, user=None):
|
|||
if 'domain' not in app_settings:
|
||||
continue
|
||||
if user is not None:
|
||||
if ('mode' not in app_settings \
|
||||
or ('mode' in app_settings \
|
||||
if ('mode' not in app_settings
|
||||
or ('mode' in app_settings
|
||||
and app_settings['mode'] == 'private')) \
|
||||
and 'allowed_users' in app_settings \
|
||||
and user not in app_settings['allowed_users'].split(','):
|
||||
|
@ -632,6 +632,7 @@ def app_upgrade(auth, app=[], url=None, file=None):
|
|||
|
||||
logger.success(m18n.n('upgrade_complete'))
|
||||
|
||||
|
||||
def app_install(auth, app, label=None, args=None, no_remove_on_failure=False):
|
||||
"""
|
||||
Install apps
|
||||
|
@ -646,8 +647,10 @@ def app_install(auth, app, label=None, args=None, no_remove_on_failure=False):
|
|||
from yunohost.hook import hook_add, hook_remove, hook_exec
|
||||
|
||||
# Fetch or extract sources
|
||||
try: os.listdir(INSTALL_TMP)
|
||||
except OSError: os.makedirs(INSTALL_TMP)
|
||||
try:
|
||||
os.listdir(INSTALL_TMP)
|
||||
except OSError:
|
||||
os.makedirs(INSTALL_TMP)
|
||||
|
||||
status = {
|
||||
'installed_at': int(time.time()),
|
||||
|
@ -800,7 +803,8 @@ def app_remove(auth, app):
|
|||
# TODO: display fail messages from script
|
||||
try:
|
||||
shutil.rmtree('/tmp/yunohost_remove')
|
||||
except: pass
|
||||
except:
|
||||
pass
|
||||
|
||||
os.system('cp -a %s /tmp/yunohost_remove && chown -hR admin: /tmp/yunohost_remove' % app_setting_path)
|
||||
os.system('chown -R admin: /tmp/yunohost_remove')
|
||||
|
@ -817,7 +821,8 @@ def app_remove(auth, app):
|
|||
if hook_exec('/tmp/yunohost_remove/scripts/remove', args=args_list, env=env_dict, user="root") == 0:
|
||||
logger.success(m18n.n('app_removed', app=app))
|
||||
|
||||
if os.path.exists(app_setting_path): shutil.rmtree(app_setting_path)
|
||||
if os.path.exists(app_setting_path):
|
||||
shutil.rmtree(app_setting_path)
|
||||
shutil.rmtree('/tmp/yunohost_remove')
|
||||
hook_remove(app)
|
||||
app_ssowatconf(auth)
|
||||
|
@ -939,7 +944,8 @@ def app_clearaccess(auth, apps):
|
|||
"""
|
||||
from yunohost.hook import hook_callback
|
||||
|
||||
if not isinstance(apps, list): apps = [apps]
|
||||
if not isinstance(apps, list):
|
||||
apps = [apps]
|
||||
|
||||
for app in apps:
|
||||
app_settings = _get_app_settings(app)
|
||||
|
@ -1025,7 +1031,6 @@ def app_makedefault(auth, app, domain=None):
|
|||
raise MoulinetteError(errno.EPERM,
|
||||
m18n.n('ssowat_persistent_conf_write_error', error=e.strerror))
|
||||
|
||||
|
||||
os.system('chmod 644 /etc/ssowat/conf.json.persistent')
|
||||
|
||||
logger.success(m18n.n('ssowat_conf_updated'))
|
||||
|
@ -1384,17 +1389,20 @@ def _extract_app_from_file(path, remove=False):
|
|||
"""
|
||||
logger.info(m18n.n('extracting'))
|
||||
|
||||
if os.path.exists(APP_TMP_FOLDER): shutil.rmtree(APP_TMP_FOLDER)
|
||||
if os.path.exists(APP_TMP_FOLDER):
|
||||
shutil.rmtree(APP_TMP_FOLDER)
|
||||
os.makedirs(APP_TMP_FOLDER)
|
||||
|
||||
path = os.path.abspath(path)
|
||||
|
||||
if ".zip" in path:
|
||||
extract_result = os.system('unzip %s -d %s > /dev/null 2>&1' % (path, APP_TMP_FOLDER))
|
||||
if remove: os.remove(path)
|
||||
if remove:
|
||||
os.remove(path)
|
||||
elif ".tar" in path:
|
||||
extract_result = os.system('tar -xf %s -C %s > /dev/null 2>&1' % (path, APP_TMP_FOLDER))
|
||||
if remove: os.remove(path)
|
||||
if remove:
|
||||
os.remove(path)
|
||||
elif os.path.isdir(path):
|
||||
shutil.rmtree(APP_TMP_FOLDER)
|
||||
if path[len(path) - 1:] != '/':
|
||||
|
@ -1519,7 +1527,8 @@ def _fetch_app_from_git(app):
|
|||
manifest['remote'] = {'type': 'git', 'url': url, 'branch': branch}
|
||||
try:
|
||||
revision = _get_git_last_commit_hash(url, branch)
|
||||
except: pass
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
manifest['remote']['revision'] = revision
|
||||
else:
|
||||
|
@ -1712,6 +1721,7 @@ def _check_manifest_requirements(manifest):
|
|||
pkgname=pkgname, version=version,
|
||||
spec=spec))
|
||||
|
||||
|
||||
def _parse_args_from_manifest(manifest, action, args={}, auth=None):
|
||||
"""Parse arguments needed for an action from the manifest
|
||||
|
||||
|
@ -1861,6 +1871,7 @@ def _parse_args_from_manifest(manifest, action, args={}, auth=None):
|
|||
|
||||
return args_dict
|
||||
|
||||
|
||||
def _make_environment_dict(args_dict):
|
||||
"""
|
||||
Convert a dictionnary containing manifest arguments
|
||||
|
@ -1875,6 +1886,7 @@ def _make_environment_dict(args_dict):
|
|||
env_dict["YNH_APP_ARG_%s" % arg_name.upper()] = arg_value
|
||||
return env_dict
|
||||
|
||||
|
||||
def _parse_app_instance_name(app_instance_name):
|
||||
"""
|
||||
Parse a Yunohost app instance name and extracts the original appid
|
||||
|
@ -2086,7 +2098,8 @@ def random_password(length=8):
|
|||
length -- The string length to generate
|
||||
|
||||
"""
|
||||
import string, random
|
||||
import string
|
||||
import random
|
||||
|
||||
char_set = string.ascii_uppercase + string.digits + string.ascii_lowercase
|
||||
return ''.join(random.sample(char_set, length))
|
||||
|
|
Loading…
Add table
Reference in a new issue