mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[mod] imports at the beginning of the file
This commit is contained in:
parent
f0dfb3c960
commit
49155ec8c3
1 changed files with 10 additions and 26 deletions
|
@ -29,6 +29,8 @@ import shutil
|
||||||
import yaml
|
import yaml
|
||||||
import time
|
import time
|
||||||
import re
|
import re
|
||||||
|
import string
|
||||||
|
import random
|
||||||
import socket
|
import socket
|
||||||
import urlparse
|
import urlparse
|
||||||
import errno
|
import errno
|
||||||
|
@ -40,6 +42,10 @@ from moulinette.utils.log import getActionLogger
|
||||||
|
|
||||||
from yunohost.service import service_log
|
from yunohost.service import service_log
|
||||||
from yunohost.utils import packages
|
from yunohost.utils import packages
|
||||||
|
from yunohost.hook import hook_add, hook_remove, hook_exec, hook_callback
|
||||||
|
from yunohost.user import user_list, user_info
|
||||||
|
from yunohost.domain import domain_list
|
||||||
|
|
||||||
|
|
||||||
logger = getActionLogger('yunohost.app')
|
logger = getActionLogger('yunohost.app')
|
||||||
|
|
||||||
|
@ -331,8 +337,6 @@ def app_upgrade(auth, app=[], url=None, file=None):
|
||||||
url -- Git url to fetch for upgrade
|
url -- Git url to fetch for upgrade
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from yunohost.hook import hook_add, hook_remove, hook_exec
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
app_list()
|
app_list()
|
||||||
except MoulinetteError:
|
except MoulinetteError:
|
||||||
|
@ -443,8 +447,6 @@ def app_install(auth, app, label=None, args=None):
|
||||||
args -- Serialize arguments for app installation
|
args -- Serialize arguments for app installation
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from yunohost.hook import hook_add, hook_remove, hook_exec
|
|
||||||
|
|
||||||
# Fetch or extract sources
|
# Fetch or extract sources
|
||||||
try: os.listdir(install_tmp)
|
try: os.listdir(install_tmp)
|
||||||
except OSError: os.makedirs(install_tmp)
|
except OSError: os.makedirs(install_tmp)
|
||||||
|
@ -586,8 +588,6 @@ def app_remove(auth, app):
|
||||||
app -- App(s) to delete
|
app -- App(s) to delete
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from yunohost.hook import hook_exec, hook_remove
|
|
||||||
|
|
||||||
if not _is_installed(app):
|
if not _is_installed(app):
|
||||||
raise MoulinetteError(errno.EINVAL,
|
raise MoulinetteError(errno.EINVAL,
|
||||||
m18n.n('app_not_installed', app=app))
|
m18n.n('app_not_installed', app=app))
|
||||||
|
@ -629,9 +629,6 @@ def app_addaccess(auth, apps, users=[]):
|
||||||
apps
|
apps
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from yunohost.user import user_list, user_info
|
|
||||||
from yunohost.hook import hook_callback
|
|
||||||
|
|
||||||
result = {}
|
result = {}
|
||||||
|
|
||||||
if not users:
|
if not users:
|
||||||
|
@ -684,9 +681,6 @@ def app_removeaccess(auth, apps, users=[]):
|
||||||
apps
|
apps
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from yunohost.user import user_list
|
|
||||||
from yunohost.hook import hook_callback
|
|
||||||
|
|
||||||
result = {}
|
result = {}
|
||||||
|
|
||||||
remove_all = False
|
remove_all = False
|
||||||
|
@ -734,8 +728,6 @@ def app_clearaccess(auth, apps):
|
||||||
apps
|
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:
|
for app in apps:
|
||||||
|
@ -786,8 +778,6 @@ def app_makedefault(auth, app, domain=None):
|
||||||
domain
|
domain
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from yunohost.domain import domain_list
|
|
||||||
|
|
||||||
app_settings = _get_app_settings(app)
|
app_settings = _get_app_settings(app)
|
||||||
app_domain = app_settings['domain']
|
app_domain = app_settings['domain']
|
||||||
app_path = app_settings['path']
|
app_path = app_settings['path']
|
||||||
|
@ -879,8 +869,6 @@ def app_checkurl(auth, url, app=None):
|
||||||
app -- Write domain & path to app settings for further checks
|
app -- Write domain & path to app settings for further checks
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from yunohost.domain import domain_list
|
|
||||||
|
|
||||||
if "https://" == url[:8]:
|
if "https://" == url[:8]:
|
||||||
url = url[8:]
|
url = url[8:]
|
||||||
elif "http://" == url[:7]:
|
elif "http://" == url[:7]:
|
||||||
|
@ -963,9 +951,6 @@ def app_ssowatconf(auth):
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from yunohost.domain import domain_list
|
|
||||||
from yunohost.user import user_list
|
|
||||||
|
|
||||||
with open('/etc/yunohost/current_host', 'r') as f:
|
with open('/etc/yunohost/current_host', 'r') as f:
|
||||||
main_domain = f.readline().rstrip()
|
main_domain = f.readline().rstrip()
|
||||||
|
|
||||||
|
@ -1464,6 +1449,7 @@ def _check_manifest_requirements(manifest):
|
||||||
pkgname=pkgname, version=version,
|
pkgname=pkgname, version=version,
|
||||||
spec=spec))
|
spec=spec))
|
||||||
|
|
||||||
|
|
||||||
def _parse_args_from_manifest(manifest, action, args={}, auth=None):
|
def _parse_args_from_manifest(manifest, action, args={}, auth=None):
|
||||||
"""Parse arguments needed for an action from the manifest
|
"""Parse arguments needed for an action from the manifest
|
||||||
|
|
||||||
|
@ -1478,9 +1464,6 @@ def _parse_args_from_manifest(manifest, action, args={}, auth=None):
|
||||||
args -- A dictionnary of arguments to parse
|
args -- A dictionnary of arguments to parse
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from yunohost.domain import domain_list
|
|
||||||
from yunohost.user import user_info
|
|
||||||
|
|
||||||
args_list = OrderedDict()
|
args_list = OrderedDict()
|
||||||
try:
|
try:
|
||||||
action_args = manifest['arguments'][action]
|
action_args = manifest['arguments'][action]
|
||||||
|
@ -1575,6 +1558,7 @@ def _parse_args_from_manifest(manifest, action, args={}, auth=None):
|
||||||
args_list[arg_name] = arg_value
|
args_list[arg_name] = arg_value
|
||||||
return args_list
|
return args_list
|
||||||
|
|
||||||
|
|
||||||
def _make_environment_dict(args_dict):
|
def _make_environment_dict(args_dict):
|
||||||
"""
|
"""
|
||||||
Convert a dictionnary containing manifest arguments
|
Convert a dictionnary containing manifest arguments
|
||||||
|
@ -1589,6 +1573,7 @@ def _make_environment_dict(args_dict):
|
||||||
env_dict[ "YNH_APP_ARG_%s" % arg_name.upper() ] = arg_value
|
env_dict[ "YNH_APP_ARG_%s" % arg_name.upper() ] = arg_value
|
||||||
return env_dict
|
return env_dict
|
||||||
|
|
||||||
|
|
||||||
def _parse_app_instance_name(app_instance_name):
|
def _parse_app_instance_name(app_instance_name):
|
||||||
"""
|
"""
|
||||||
Parse a Yunohost app instance name and extracts the original appid
|
Parse a Yunohost app instance name and extracts the original appid
|
||||||
|
@ -1616,6 +1601,7 @@ def _parse_app_instance_name(app_instance_name):
|
||||||
app_instance_nb = int(match.groupdict().get('appinstancenb')) if match.groupdict().get('appinstancenb') is not None else 1
|
app_instance_nb = int(match.groupdict().get('appinstancenb')) if match.groupdict().get('appinstancenb') is not None else 1
|
||||||
return (appid, app_instance_nb)
|
return (appid, app_instance_nb)
|
||||||
|
|
||||||
|
|
||||||
def is_true(arg):
|
def is_true(arg):
|
||||||
"""
|
"""
|
||||||
Convert a string into a boolean
|
Convert a string into a boolean
|
||||||
|
@ -1648,7 +1634,5 @@ def random_password(length=8):
|
||||||
length -- The string length to generate
|
length -- The string length to generate
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import string, random
|
|
||||||
|
|
||||||
char_set = string.ascii_uppercase + string.digits + string.ascii_lowercase
|
char_set = string.ascii_uppercase + string.digits + string.ascii_lowercase
|
||||||
return ''.join(random.sample(char_set, length))
|
return ''.join(random.sample(char_set, length))
|
||||||
|
|
Loading…
Add table
Reference in a new issue