mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[mod] rename all global variables to uppercase
This commit is contained in:
parent
3804f33b2f
commit
f6c7702dfa
7 changed files with 115 additions and 114 deletions
|
@ -44,11 +44,11 @@ from yunohost.utils import packages
|
||||||
|
|
||||||
logger = getActionLogger('yunohost.app')
|
logger = getActionLogger('yunohost.app')
|
||||||
|
|
||||||
repo_path = '/var/cache/yunohost/repo'
|
REPO_PATH = '/var/cache/yunohost/repo'
|
||||||
apps_path = '/usr/share/yunohost/apps'
|
APPS_PATH = '/usr/share/yunohost/apps'
|
||||||
apps_setting_path= '/etc/yunohost/apps/'
|
APPS_SETTING_PATH= '/etc/yunohost/apps/'
|
||||||
install_tmp = '/var/cache/yunohost'
|
INSTALL_TMP = '/var/cache/yunohost'
|
||||||
app_tmp_folder = install_tmp + '/from_file'
|
APP_TMP_FOLDER = INSTALL_TMP + '/from_file'
|
||||||
|
|
||||||
re_github_repo = re.compile(
|
re_github_repo = re.compile(
|
||||||
r'^(http[s]?://|git@)github.com[/:]'
|
r'^(http[s]?://|git@)github.com[/:]'
|
||||||
|
@ -69,7 +69,7 @@ def app_listlists():
|
||||||
"""
|
"""
|
||||||
list_list = []
|
list_list = []
|
||||||
try:
|
try:
|
||||||
for filename in os.listdir(repo_path):
|
for filename in os.listdir(REPO_PATH):
|
||||||
if '.json' in filename:
|
if '.json' in filename:
|
||||||
list_list.append(filename[:len(filename)-5])
|
list_list.append(filename[:len(filename)-5])
|
||||||
except OSError:
|
except OSError:
|
||||||
|
@ -88,8 +88,8 @@ def app_fetchlist(url=None, name=None):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# Create app path if not exists
|
# Create app path if not exists
|
||||||
if not os.path.exists(repo_path):
|
if not os.path.exists(REPO_PATH):
|
||||||
os.makedirs(repo_path)
|
os.makedirs(REPO_PATH)
|
||||||
|
|
||||||
if url is None:
|
if url is None:
|
||||||
url = 'https://app.yunohost.org/official.json'
|
url = 'https://app.yunohost.org/official.json'
|
||||||
|
@ -117,7 +117,7 @@ def app_fetchlist(url=None, name=None):
|
||||||
raise MoulinetteError(errno.EBADR, m18n.n('appslist_retrieve_bad_format'))
|
raise MoulinetteError(errno.EBADR, m18n.n('appslist_retrieve_bad_format'))
|
||||||
|
|
||||||
# Write app list to file
|
# Write app list to file
|
||||||
list_file = '%s/%s.json' % (repo_path, name)
|
list_file = '%s/%s.json' % (REPO_PATH, name)
|
||||||
with open(list_file, "w") as f:
|
with open(list_file, "w") as f:
|
||||||
f.write(applist)
|
f.write(applist)
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ def app_removelist(name):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
os.remove('%s/%s.json' % (repo_path, name))
|
os.remove('%s/%s.json' % (REPO_PATH, name))
|
||||||
os.remove("/etc/cron.d/yunohost-applist-%s" % name)
|
os.remove("/etc/cron.d/yunohost-applist-%s" % name)
|
||||||
except OSError:
|
except OSError:
|
||||||
raise MoulinetteError(errno.ENOENT, m18n.n('appslist_unknown'))
|
raise MoulinetteError(errno.ENOENT, m18n.n('appslist_unknown'))
|
||||||
|
@ -177,13 +177,13 @@ def app_list(offset=None, limit=None, filter=None, raw=False, installed=False, w
|
||||||
applists = app_listlists()['lists']
|
applists = app_listlists()['lists']
|
||||||
|
|
||||||
for applist in applists:
|
for applist in applists:
|
||||||
with open(os.path.join(repo_path, applist + '.json')) as json_list:
|
with open(os.path.join(REPO_PATH, applist + '.json')) as json_list:
|
||||||
for app, info in json.loads(str(json_list.read())).items():
|
for app, info in json.loads(str(json_list.read())).items():
|
||||||
if app not in app_dict:
|
if app not in app_dict:
|
||||||
info['repository'] = applist
|
info['repository'] = applist
|
||||||
app_dict[app] = info
|
app_dict[app] = info
|
||||||
|
|
||||||
for app in os.listdir(apps_setting_path):
|
for app in os.listdir(APPS_SETTING_PATH):
|
||||||
if app not in app_dict:
|
if app not in app_dict:
|
||||||
# Look for forks
|
# Look for forks
|
||||||
if '__' in app:
|
if '__' in app:
|
||||||
|
@ -191,7 +191,7 @@ def app_list(offset=None, limit=None, filter=None, raw=False, installed=False, w
|
||||||
if original_app in app_dict:
|
if original_app in app_dict:
|
||||||
app_dict[app] = app_dict[original_app]
|
app_dict[app] = app_dict[original_app]
|
||||||
continue
|
continue
|
||||||
with open( apps_setting_path + app +'/manifest.json') as json_manifest:
|
with open( APPS_SETTING_PATH + app +'/manifest.json') as json_manifest:
|
||||||
app_dict[app] = {"manifest":json.loads(str(json_manifest.read()))}
|
app_dict[app] = {"manifest":json.loads(str(json_manifest.read()))}
|
||||||
app_dict[app]['repository'] = None
|
app_dict[app]['repository'] = None
|
||||||
|
|
||||||
|
@ -212,8 +212,8 @@ def app_list(offset=None, limit=None, filter=None, raw=False, installed=False, w
|
||||||
|
|
||||||
# Filter only apps with backup and restore scripts
|
# Filter only apps with backup and restore scripts
|
||||||
if with_backup and (
|
if with_backup and (
|
||||||
not os.path.isfile(apps_setting_path + app_id + '/scripts/backup') or
|
not os.path.isfile(APPS_SETTING_PATH + app_id + '/scripts/backup') or
|
||||||
not os.path.isfile(apps_setting_path + app_id + '/scripts/restore')
|
not os.path.isfile(APPS_SETTING_PATH + app_id + '/scripts/restore')
|
||||||
):
|
):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -269,7 +269,7 @@ def app_info(app, show_status=False, raw=False):
|
||||||
ret['settings'] = _get_app_settings(app)
|
ret['settings'] = _get_app_settings(app)
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
app_setting_path = apps_setting_path + app
|
app_setting_path = APPS_SETTING_PATH + app
|
||||||
|
|
||||||
# Retrieve manifest and status
|
# Retrieve manifest and status
|
||||||
with open(app_setting_path + '/manifest.json') as f:
|
with open(app_setting_path + '/manifest.json') as f:
|
||||||
|
@ -309,7 +309,7 @@ def app_map(app=None, raw=False, user=None):
|
||||||
m18n.n('app_not_installed', app=app))
|
m18n.n('app_not_installed', app=app))
|
||||||
apps = [app,]
|
apps = [app,]
|
||||||
else:
|
else:
|
||||||
apps = os.listdir(apps_setting_path)
|
apps = os.listdir(APPS_SETTING_PATH)
|
||||||
|
|
||||||
for app_id in apps:
|
for app_id in apps:
|
||||||
app_settings = _get_app_settings(app_id)
|
app_settings = _get_app_settings(app_id)
|
||||||
|
@ -363,7 +363,7 @@ def app_upgrade(auth, app=[], url=None, file=None):
|
||||||
# If no app is specified, upgrade all apps
|
# If no app is specified, upgrade all apps
|
||||||
if not app:
|
if not app:
|
||||||
if (not url and not file):
|
if (not url and not file):
|
||||||
app = os.listdir(apps_setting_path)
|
app = os.listdir(APPS_SETTING_PATH)
|
||||||
elif not isinstance(app, list):
|
elif not isinstance(app, list):
|
||||||
app = [ app ]
|
app = [ app ]
|
||||||
|
|
||||||
|
@ -398,7 +398,7 @@ def app_upgrade(auth, app=[], url=None, file=None):
|
||||||
# Check requirements
|
# Check requirements
|
||||||
_check_manifest_requirements(manifest)
|
_check_manifest_requirements(manifest)
|
||||||
|
|
||||||
app_setting_path = apps_setting_path +'/'+ app_instance_name
|
app_setting_path = APPS_SETTING_PATH +'/'+ app_instance_name
|
||||||
|
|
||||||
# Retrieve current app status
|
# Retrieve current app status
|
||||||
status = _get_app_status(app_instance_name)
|
status = _get_app_status(app_instance_name)
|
||||||
|
@ -418,7 +418,7 @@ def app_upgrade(auth, app=[], url=None, file=None):
|
||||||
env_dict["YNH_APP_INSTANCE_NUMBER"] = str(app_instance_nb)
|
env_dict["YNH_APP_INSTANCE_NUMBER"] = str(app_instance_nb)
|
||||||
|
|
||||||
# Execute App upgrade script
|
# Execute App upgrade script
|
||||||
os.system('chown -hR admin: %s' % install_tmp)
|
os.system('chown -hR admin: %s' % INSTALL_TMP)
|
||||||
if hook_exec(extracted_app_folder +'/scripts/upgrade', args=args_list, env=env_dict) != 0:
|
if hook_exec(extracted_app_folder +'/scripts/upgrade', args=args_list, env=env_dict) != 0:
|
||||||
logger.error(m18n.n('app_upgrade_failed', app=app_instance_name))
|
logger.error(m18n.n('app_upgrade_failed', app=app_instance_name))
|
||||||
else:
|
else:
|
||||||
|
@ -467,8 +467,8 @@ def app_install(auth, app, label=None, args=None, no_remove_on_failure=False):
|
||||||
from yunohost.hook import hook_add, hook_remove, hook_exec
|
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)
|
||||||
|
|
||||||
status = {
|
status = {
|
||||||
'installed_at': int(time.time()),
|
'installed_at': int(time.time()),
|
||||||
|
@ -521,7 +521,7 @@ def app_install(auth, app, label=None, args=None, no_remove_on_failure=False):
|
||||||
env_dict["YNH_APP_INSTANCE_NUMBER"] = str(instance_number)
|
env_dict["YNH_APP_INSTANCE_NUMBER"] = str(instance_number)
|
||||||
|
|
||||||
# Create app directory
|
# Create app directory
|
||||||
app_setting_path = os.path.join(apps_setting_path, app_instance_name)
|
app_setting_path = os.path.join(APPS_SETTING_PATH, app_instance_name)
|
||||||
if os.path.exists(app_setting_path):
|
if os.path.exists(app_setting_path):
|
||||||
shutil.rmtree(app_setting_path)
|
shutil.rmtree(app_setting_path)
|
||||||
os.makedirs(app_setting_path)
|
os.makedirs(app_setting_path)
|
||||||
|
@ -538,7 +538,7 @@ def app_install(auth, app, label=None, args=None, no_remove_on_failure=False):
|
||||||
os.system('chown -R admin: '+ extracted_app_folder)
|
os.system('chown -R admin: '+ extracted_app_folder)
|
||||||
|
|
||||||
# Execute App install script
|
# Execute App install script
|
||||||
os.system('chown -hR admin: %s' % install_tmp)
|
os.system('chown -hR admin: %s' % INSTALL_TMP)
|
||||||
# Move scripts and manifest to the right place
|
# Move scripts and manifest to the right place
|
||||||
os.system('cp %s/manifest.json %s' % (extracted_app_folder, app_setting_path))
|
os.system('cp %s/manifest.json %s' % (extracted_app_folder, app_setting_path))
|
||||||
os.system('cp -R %s/scripts %s' % (extracted_app_folder, app_setting_path))
|
os.system('cp -R %s/scripts %s' % (extracted_app_folder, app_setting_path))
|
||||||
|
@ -614,7 +614,7 @@ def app_remove(auth, app):
|
||||||
raise MoulinetteError(errno.EINVAL,
|
raise MoulinetteError(errno.EINVAL,
|
||||||
m18n.n('app_not_installed', app=app))
|
m18n.n('app_not_installed', app=app))
|
||||||
|
|
||||||
app_setting_path = apps_setting_path + app
|
app_setting_path = APPS_SETTING_PATH + app
|
||||||
|
|
||||||
#TODO: display fail messages from script
|
#TODO: display fail messages from script
|
||||||
try:
|
try:
|
||||||
|
@ -783,7 +783,7 @@ def app_debug(app):
|
||||||
Keyword argument:
|
Keyword argument:
|
||||||
app
|
app
|
||||||
"""
|
"""
|
||||||
with open(apps_setting_path + app + '/manifest.json') as f:
|
with open(APPS_SETTING_PATH + app + '/manifest.json') as f:
|
||||||
manifest = json.loads(f.read())
|
manifest = json.loads(f.read())
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -1021,7 +1021,7 @@ def app_ssowatconf(auth):
|
||||||
|
|
||||||
for app in apps_list:
|
for app in apps_list:
|
||||||
if _is_installed(app['id']):
|
if _is_installed(app['id']):
|
||||||
with open(apps_setting_path + app['id'] +'/settings.yml') as f:
|
with open(APPS_SETTING_PATH + app['id'] +'/settings.yml') as f:
|
||||||
app_settings = yaml.load(f)
|
app_settings = yaml.load(f)
|
||||||
for item in _get_setting(app_settings, 'skipped_uris'):
|
for item in _get_setting(app_settings, 'skipped_uris'):
|
||||||
if item[-1:] == '/':
|
if item[-1:] == '/':
|
||||||
|
@ -1092,7 +1092,7 @@ def _get_app_settings(app_id):
|
||||||
m18n.n('app_not_installed', app=app_id))
|
m18n.n('app_not_installed', app=app_id))
|
||||||
try:
|
try:
|
||||||
with open(os.path.join(
|
with open(os.path.join(
|
||||||
apps_setting_path, app_id, 'settings.yml')) as f:
|
APPS_SETTING_PATH, app_id, 'settings.yml')) as f:
|
||||||
settings = yaml.load(f)
|
settings = yaml.load(f)
|
||||||
if app_id == settings['id']:
|
if app_id == settings['id']:
|
||||||
return settings
|
return settings
|
||||||
|
@ -1112,7 +1112,7 @@ def _set_app_settings(app_id, settings):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
with open(os.path.join(
|
with open(os.path.join(
|
||||||
apps_setting_path, app_id, 'settings.yml'), 'w') as f:
|
APPS_SETTING_PATH, app_id, 'settings.yml'), 'w') as f:
|
||||||
yaml.safe_dump(settings, f, default_flow_style=False)
|
yaml.safe_dump(settings, f, default_flow_style=False)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1125,7 +1125,7 @@ def _get_app_status(app_id, format_date=False):
|
||||||
format_date -- Format date fields
|
format_date -- Format date fields
|
||||||
|
|
||||||
"""
|
"""
|
||||||
app_setting_path = apps_setting_path + app_id
|
app_setting_path = APPS_SETTING_PATH + app_id
|
||||||
if not os.path.isdir(app_setting_path):
|
if not os.path.isdir(app_setting_path):
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n('app_unknown'))
|
raise MoulinetteError(errno.EINVAL, m18n.n('app_unknown'))
|
||||||
status = {}
|
status = {}
|
||||||
|
@ -1170,22 +1170,22 @@ def _extract_app_from_file(path, remove=False):
|
||||||
"""
|
"""
|
||||||
logger.info(m18n.n('extracting'))
|
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)
|
os.makedirs(APP_TMP_FOLDER)
|
||||||
|
|
||||||
path = os.path.abspath(path)
|
path = os.path.abspath(path)
|
||||||
|
|
||||||
if ".zip" in path:
|
if ".zip" in path:
|
||||||
extract_result = os.system('unzip %s -d %s > /dev/null 2>&1' % (path, app_tmp_folder))
|
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:
|
elif ".tar" in path:
|
||||||
extract_result = os.system('tar -xf %s -C %s > /dev/null 2>&1' % (path, app_tmp_folder))
|
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):
|
elif os.path.isdir(path):
|
||||||
shutil.rmtree(app_tmp_folder)
|
shutil.rmtree(APP_TMP_FOLDER)
|
||||||
if path[len(path)-1:] != '/':
|
if path[len(path)-1:] != '/':
|
||||||
path = path + '/'
|
path = path + '/'
|
||||||
extract_result = os.system('cp -a "%s" %s' % (path, app_tmp_folder))
|
extract_result = os.system('cp -a "%s" %s' % (path, APP_TMP_FOLDER))
|
||||||
else:
|
else:
|
||||||
extract_result = 1
|
extract_result = 1
|
||||||
|
|
||||||
|
@ -1193,7 +1193,7 @@ def _extract_app_from_file(path, remove=False):
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n('app_extraction_failed'))
|
raise MoulinetteError(errno.EINVAL, m18n.n('app_extraction_failed'))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
extracted_app_folder = app_tmp_folder
|
extracted_app_folder = APP_TMP_FOLDER
|
||||||
if len(os.listdir(extracted_app_folder)) == 1:
|
if len(os.listdir(extracted_app_folder)) == 1:
|
||||||
for folder in os.listdir(extracted_app_folder):
|
for folder in os.listdir(extracted_app_folder):
|
||||||
extracted_app_folder = extracted_app_folder +'/'+ folder
|
extracted_app_folder = extracted_app_folder +'/'+ folder
|
||||||
|
@ -1240,7 +1240,7 @@ def _fetch_app_from_git(app):
|
||||||
Dict manifest
|
Dict manifest
|
||||||
|
|
||||||
"""
|
"""
|
||||||
extracted_app_folder = app_tmp_folder
|
extracted_app_folder = APP_TMP_FOLDER
|
||||||
|
|
||||||
app_tmp_archive = '{0}.zip'.format(extracted_app_folder)
|
app_tmp_archive = '{0}.zip'.format(extracted_app_folder)
|
||||||
if os.path.exists(extracted_app_folder):
|
if os.path.exists(extracted_app_folder):
|
||||||
|
@ -1383,9 +1383,9 @@ def _installed_instance_number(app, last=False):
|
||||||
if last:
|
if last:
|
||||||
number = 0
|
number = 0
|
||||||
try:
|
try:
|
||||||
installed_apps = os.listdir(apps_setting_path)
|
installed_apps = os.listdir(APPS_SETTING_PATH)
|
||||||
except OSError:
|
except OSError:
|
||||||
os.makedirs(apps_setting_path)
|
os.makedirs(APPS_SETTING_PATH)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
for installed_app in installed_apps:
|
for installed_app in installed_apps:
|
||||||
|
@ -1419,7 +1419,7 @@ def _is_installed(app):
|
||||||
Boolean
|
Boolean
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return os.path.isdir(apps_setting_path + app)
|
return os.path.isdir(APPS_SETTING_PATH + app)
|
||||||
|
|
||||||
|
|
||||||
def _value_for_locale(values):
|
def _value_for_locale(values):
|
||||||
|
|
|
@ -42,13 +42,13 @@ from yunohost.app import (
|
||||||
app_info, app_ssowatconf, _is_installed, _parse_app_instance_name
|
app_info, app_ssowatconf, _is_installed, _parse_app_instance_name
|
||||||
)
|
)
|
||||||
from yunohost.hook import (
|
from yunohost.hook import (
|
||||||
hook_info, hook_callback, hook_exec, custom_hook_folder
|
hook_info, hook_callback, hook_exec, CUSTOM_HOOK_FOLDER
|
||||||
)
|
)
|
||||||
from yunohost.monitor import binary_to_human
|
from yunohost.monitor import binary_to_human
|
||||||
from yunohost.tools import tools_postinstall
|
from yunohost.tools import tools_postinstall
|
||||||
|
|
||||||
backup_path = '/home/yunohost.backup'
|
BACKUP_PATH = '/home/yunohost.backup'
|
||||||
archives_path = '%s/archives' % backup_path
|
ARCHIVES_PATH = '%s/archives' % BACKUP_PATH
|
||||||
|
|
||||||
logger = getActionLogger('yunohost.backup')
|
logger = getActionLogger('yunohost.backup')
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ def backup_create(name=None, description=None, output_directory=None,
|
||||||
output_directory = os.path.abspath(output_directory)
|
output_directory = os.path.abspath(output_directory)
|
||||||
|
|
||||||
# Check for forbidden folders
|
# Check for forbidden folders
|
||||||
if output_directory.startswith(archives_path) or \
|
if output_directory.startswith(ARCHIVES_PATH) or \
|
||||||
re.match(r'^/(|(bin|boot|dev|etc|lib|root|run|sbin|sys|usr|var)(|/.*))$',
|
re.match(r'^/(|(bin|boot|dev|etc|lib|root|run|sbin|sys|usr|var)(|/.*))$',
|
||||||
output_directory):
|
output_directory):
|
||||||
raise MoulinetteError(errno.EINVAL,
|
raise MoulinetteError(errno.EINVAL,
|
||||||
|
@ -118,11 +118,11 @@ def backup_create(name=None, description=None, output_directory=None,
|
||||||
tmp_dir = output_directory
|
tmp_dir = output_directory
|
||||||
env_var['CAN_BIND'] = 0
|
env_var['CAN_BIND'] = 0
|
||||||
else:
|
else:
|
||||||
output_directory = archives_path
|
output_directory = ARCHIVES_PATH
|
||||||
|
|
||||||
# Create archives directory if it does not exists
|
# Create archives directory if it does not exists
|
||||||
if not os.path.isdir(archives_path):
|
if not os.path.isdir(ARCHIVES_PATH):
|
||||||
os.mkdir(archives_path, 0750)
|
os.mkdir(ARCHIVES_PATH, 0750)
|
||||||
|
|
||||||
def _clean_tmp_dir(retcode=0):
|
def _clean_tmp_dir(retcode=0):
|
||||||
ret = hook_callback('post_backup_create', args=[tmp_dir, retcode])
|
ret = hook_callback('post_backup_create', args=[tmp_dir, retcode])
|
||||||
|
@ -135,7 +135,7 @@ def backup_create(name=None, description=None, output_directory=None,
|
||||||
|
|
||||||
# Create temporary directory
|
# Create temporary directory
|
||||||
if not tmp_dir:
|
if not tmp_dir:
|
||||||
tmp_dir = "%s/tmp/%s" % (backup_path, name)
|
tmp_dir = "%s/tmp/%s" % (BACKUP_PATH, name)
|
||||||
if os.path.isdir(tmp_dir):
|
if os.path.isdir(tmp_dir):
|
||||||
logger.debug("temporary directory for backup '%s' already exists",
|
logger.debug("temporary directory for backup '%s' already exists",
|
||||||
tmp_dir)
|
tmp_dir)
|
||||||
|
@ -305,12 +305,12 @@ def backup_create(name=None, description=None, output_directory=None,
|
||||||
|
|
||||||
# Move info file
|
# Move info file
|
||||||
shutil.move(tmp_dir + '/info.json',
|
shutil.move(tmp_dir + '/info.json',
|
||||||
'{:s}/{:s}.info.json'.format(archives_path, name))
|
'{:s}/{:s}.info.json'.format(ARCHIVES_PATH, name))
|
||||||
|
|
||||||
# If backuped to a non-default location, keep a symlink of the archive
|
# If backuped to a non-default location, keep a symlink of the archive
|
||||||
# to that location
|
# to that location
|
||||||
if output_directory != archives_path:
|
if output_directory != ARCHIVES_PATH:
|
||||||
link = "%s/%s.tar.gz" % (archives_path, name)
|
link = "%s/%s.tar.gz" % (ARCHIVES_PATH, name)
|
||||||
os.symlink(archive_file, link)
|
os.symlink(archive_file, link)
|
||||||
|
|
||||||
# Clean temporary directory
|
# Clean temporary directory
|
||||||
|
@ -354,19 +354,19 @@ def backup_restore(auth, name, hooks=[], ignore_hooks=False,
|
||||||
raise MoulinetteError(errno.EIO, m18n.n('backup_archive_open_failed'))
|
raise MoulinetteError(errno.EIO, m18n.n('backup_archive_open_failed'))
|
||||||
|
|
||||||
# Check temporary directory
|
# Check temporary directory
|
||||||
tmp_dir = "%s/tmp/%s" % (backup_path, name)
|
tmp_dir = "%s/tmp/%s" % (BACKUP_PATH, name)
|
||||||
if os.path.isdir(tmp_dir):
|
if os.path.isdir(tmp_dir):
|
||||||
logger.debug("temporary directory for restoration '%s' already exists",
|
logger.debug("temporary directory for restoration '%s' already exists",
|
||||||
tmp_dir)
|
tmp_dir)
|
||||||
os.system('rm -rf %s' % tmp_dir)
|
os.system('rm -rf %s' % tmp_dir)
|
||||||
|
|
||||||
# Check available disk space
|
# Check available disk space
|
||||||
statvfs = os.statvfs(backup_path)
|
statvfs = os.statvfs(BACKUP_PATH)
|
||||||
free_space = statvfs.f_frsize * statvfs.f_bavail
|
free_space = statvfs.f_frsize * statvfs.f_bavail
|
||||||
if free_space < info['size']:
|
if free_space < info['size']:
|
||||||
logger.debug("%dB left but %dB is needed", free_space, info['size'])
|
logger.debug("%dB left but %dB is needed", free_space, info['size'])
|
||||||
raise MoulinetteError(
|
raise MoulinetteError(
|
||||||
errno.EIO, m18n.n('not_enough_disk_space', path=backup_path))
|
errno.EIO, m18n.n('not_enough_disk_space', path=BACKUP_PATH))
|
||||||
|
|
||||||
def _clean_tmp_dir(retcode=0):
|
def _clean_tmp_dir(retcode=0):
|
||||||
ret = hook_callback('post_backup_restore', args=[tmp_dir, retcode])
|
ret = hook_callback('post_backup_restore', args=[tmp_dir, retcode])
|
||||||
|
@ -455,7 +455,7 @@ def backup_restore(auth, name, hooks=[], ignore_hooks=False,
|
||||||
continue
|
continue
|
||||||
# Add restoration hook from the backup to the system
|
# Add restoration hook from the backup to the system
|
||||||
# FIXME: Refactor hook_add and use it instead
|
# FIXME: Refactor hook_add and use it instead
|
||||||
restore_hook_folder = custom_hook_folder + 'restore'
|
restore_hook_folder = CUSTOM_HOOK_FOLDER + 'restore'
|
||||||
filesystem.mkdir(restore_hook_folder, 755, True)
|
filesystem.mkdir(restore_hook_folder, 755, True)
|
||||||
for f in tmp_hooks:
|
for f in tmp_hooks:
|
||||||
logger.debug("adding restoration hook '%s' to the system "
|
logger.debug("adding restoration hook '%s' to the system "
|
||||||
|
@ -580,7 +580,7 @@ def backup_list(with_info=False, human_readable=False):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Retrieve local archives
|
# Retrieve local archives
|
||||||
archives = os.listdir(archives_path)
|
archives = os.listdir(ARCHIVES_PATH)
|
||||||
except OSError:
|
except OSError:
|
||||||
logger.debug("unable to iterate over local archives", exc_info=1)
|
logger.debug("unable to iterate over local archives", exc_info=1)
|
||||||
else:
|
else:
|
||||||
|
@ -612,7 +612,7 @@ def backup_info(name, with_details=False, human_readable=False):
|
||||||
human_readable -- Print sizes in human readable format
|
human_readable -- Print sizes in human readable format
|
||||||
|
|
||||||
"""
|
"""
|
||||||
archive_file = '%s/%s.tar.gz' % (archives_path, name)
|
archive_file = '%s/%s.tar.gz' % (ARCHIVES_PATH, name)
|
||||||
|
|
||||||
# Check file exist (even if it's a broken symlink)
|
# Check file exist (even if it's a broken symlink)
|
||||||
if not os.path.lexists(archive_file):
|
if not os.path.lexists(archive_file):
|
||||||
|
@ -628,7 +628,7 @@ def backup_info(name, with_details=False, human_readable=False):
|
||||||
raise MoulinetteError(errno.EIO,
|
raise MoulinetteError(errno.EIO,
|
||||||
m18n.n('backup_archive_broken_link', path=archive_file))
|
m18n.n('backup_archive_broken_link', path=archive_file))
|
||||||
|
|
||||||
info_file = "%s/%s.info.json" % (archives_path, name)
|
info_file = "%s/%s.info.json" % (ARCHIVES_PATH, name)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(info_file) as f:
|
with open(info_file) as f:
|
||||||
|
@ -673,9 +673,9 @@ def backup_delete(name):
|
||||||
"""
|
"""
|
||||||
hook_callback('pre_backup_delete', args=[name])
|
hook_callback('pre_backup_delete', args=[name])
|
||||||
|
|
||||||
archive_file = '%s/%s.tar.gz' % (archives_path, name)
|
archive_file = '%s/%s.tar.gz' % (ARCHIVES_PATH, name)
|
||||||
|
|
||||||
info_file = "%s/%s.info.json" % (archives_path, name)
|
info_file = "%s/%s.info.json" % (ARCHIVES_PATH, name)
|
||||||
for backup_file in [archive_file, info_file]:
|
for backup_file in [archive_file, info_file]:
|
||||||
if not os.path.isfile(backup_file):
|
if not os.path.isfile(backup_file):
|
||||||
raise MoulinetteError(errno.EIO,
|
raise MoulinetteError(errno.EIO,
|
||||||
|
|
|
@ -38,8 +38,8 @@ from moulinette.utils import process
|
||||||
from moulinette.utils.log import getActionLogger
|
from moulinette.utils.log import getActionLogger
|
||||||
from moulinette.utils.text import prependlines
|
from moulinette.utils.text import prependlines
|
||||||
|
|
||||||
firewall_file = '/etc/yunohost/firewall.yml'
|
FIREWALL_FILE = '/etc/yunohost/firewall.yml'
|
||||||
upnp_cron_job = '/etc/cron.d/yunohost-firewall-upnp'
|
UPNP_CRON_JOB = '/etc/cron.d/yunohost-firewall-upnp'
|
||||||
|
|
||||||
logger = getActionLogger('yunohost.firewall')
|
logger = getActionLogger('yunohost.firewall')
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ def firewall_list(raw=False, by_ip_version=False, list_forwarded=False):
|
||||||
list_forwarded -- List forwarded ports with UPnP
|
list_forwarded -- List forwarded ports with UPnP
|
||||||
|
|
||||||
"""
|
"""
|
||||||
with open(firewall_file) as f:
|
with open(FIREWALL_FILE) as f:
|
||||||
firewall = yaml.load(f)
|
firewall = yaml.load(f)
|
||||||
if raw:
|
if raw:
|
||||||
return firewall
|
return firewall
|
||||||
|
@ -318,7 +318,7 @@ def firewall_upnp(action='status', no_refresh=False):
|
||||||
return {'enabled': enabled}
|
return {'enabled': enabled}
|
||||||
elif action == 'enable' or (enabled and action == 'status'):
|
elif action == 'enable' or (enabled and action == 'status'):
|
||||||
# Add cron job
|
# Add cron job
|
||||||
with open(upnp_cron_job, 'w+') as f:
|
with open(UPNP_CRON_JOB, 'w+') as f:
|
||||||
f.write('*/50 * * * * root '
|
f.write('*/50 * * * * root '
|
||||||
'/usr/bin/yunohost firewall upnp status >>/dev/null\n')
|
'/usr/bin/yunohost firewall upnp status >>/dev/null\n')
|
||||||
# Open port 1900 to receive discovery message
|
# Open port 1900 to receive discovery message
|
||||||
|
@ -330,7 +330,7 @@ def firewall_upnp(action='status', no_refresh=False):
|
||||||
elif action == 'disable' or (not enabled and action == 'status'):
|
elif action == 'disable' or (not enabled and action == 'status'):
|
||||||
try:
|
try:
|
||||||
# Remove cron job
|
# Remove cron job
|
||||||
os.remove(upnp_cron_job)
|
os.remove(UPNP_CRON_JOB)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
enabled = False
|
enabled = False
|
||||||
|
@ -384,8 +384,8 @@ def firewall_upnp(action='status', no_refresh=False):
|
||||||
firewall['uPnP']['enabled'] = enabled
|
firewall['uPnP']['enabled'] = enabled
|
||||||
|
|
||||||
# Make a backup and update firewall file
|
# Make a backup and update firewall file
|
||||||
os.system("cp {0} {0}.old".format(firewall_file))
|
os.system("cp {0} {0}.old".format(FIREWALL_FILE))
|
||||||
with open(firewall_file, 'w') as f:
|
with open(FIREWALL_FILE, 'w') as f:
|
||||||
yaml.safe_dump(firewall, f, default_flow_style=False)
|
yaml.safe_dump(firewall, f, default_flow_style=False)
|
||||||
|
|
||||||
if not no_refresh:
|
if not no_refresh:
|
||||||
|
@ -427,7 +427,7 @@ def firewall_stop():
|
||||||
os.system("ip6tables -F")
|
os.system("ip6tables -F")
|
||||||
os.system("ip6tables -X")
|
os.system("ip6tables -X")
|
||||||
|
|
||||||
if os.path.exists(upnp_cron_job):
|
if os.path.exists(UPNP_CRON_JOB):
|
||||||
firewall_upnp('disable')
|
firewall_upnp('disable')
|
||||||
|
|
||||||
|
|
||||||
|
@ -450,8 +450,8 @@ def _get_ssh_port(default=22):
|
||||||
|
|
||||||
def _update_firewall_file(rules):
|
def _update_firewall_file(rules):
|
||||||
"""Make a backup and write new rules to firewall file"""
|
"""Make a backup and write new rules to firewall file"""
|
||||||
os.system("cp {0} {0}.old".format(firewall_file))
|
os.system("cp {0} {0}.old".format(FIREWALL_FILE))
|
||||||
with open(firewall_file, 'w') as f:
|
with open(FIREWALL_FILE, 'w') as f:
|
||||||
yaml.safe_dump(rules, f, default_flow_style=False)
|
yaml.safe_dump(rules, f, default_flow_style=False)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,8 @@ from glob import iglob
|
||||||
from moulinette.core import MoulinetteError
|
from moulinette.core import MoulinetteError
|
||||||
from moulinette.utils import log
|
from moulinette.utils import log
|
||||||
|
|
||||||
hook_folder = '/usr/share/yunohost/hooks/'
|
HOOK_FOLDER = '/usr/share/yunohost/hooks/'
|
||||||
custom_hook_folder = '/etc/yunohost/hooks.d/'
|
CUSTOM_HOOK_FOLDER = '/etc/yunohost/hooks.d/'
|
||||||
|
|
||||||
logger = log.getActionLogger('yunohost.hook')
|
logger = log.getActionLogger('yunohost.hook')
|
||||||
|
|
||||||
|
@ -49,12 +49,12 @@ def hook_add(app, file):
|
||||||
path, filename = os.path.split(file)
|
path, filename = os.path.split(file)
|
||||||
priority, action = _extract_filename_parts(filename)
|
priority, action = _extract_filename_parts(filename)
|
||||||
|
|
||||||
try: os.listdir(custom_hook_folder + action)
|
try: os.listdir(CUSTOM_HOOK_FOLDER + action)
|
||||||
except OSError: os.makedirs(custom_hook_folder + action)
|
except OSError: os.makedirs(CUSTOM_HOOK_FOLDER + action)
|
||||||
|
|
||||||
finalpath = custom_hook_folder + action +'/'+ priority +'-'+ app
|
finalpath = CUSTOM_HOOK_FOLDER + action +'/'+ priority +'-'+ app
|
||||||
os.system('cp %s %s' % (file, finalpath))
|
os.system('cp %s %s' % (file, finalpath))
|
||||||
os.system('chown -hR admin: %s' % hook_folder)
|
os.system('chown -hR admin: %s' % HOOK_FOLDER)
|
||||||
|
|
||||||
return { 'hook': finalpath }
|
return { 'hook': finalpath }
|
||||||
|
|
||||||
|
@ -68,10 +68,10 @@ def hook_remove(app):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
for action in os.listdir(custom_hook_folder):
|
for action in os.listdir(CUSTOM_HOOK_FOLDER):
|
||||||
for script in os.listdir(custom_hook_folder + action):
|
for script in os.listdir(CUSTOM_HOOK_FOLDER + action):
|
||||||
if script.endswith(app):
|
if script.endswith(app):
|
||||||
os.remove(custom_hook_folder + action +'/'+ script)
|
os.remove(CUSTOM_HOOK_FOLDER + action +'/'+ script)
|
||||||
except OSError: pass
|
except OSError: pass
|
||||||
|
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ def hook_info(action, name):
|
||||||
|
|
||||||
# Search in custom folder first
|
# Search in custom folder first
|
||||||
for h in iglob('{:s}{:s}/*-{:s}'.format(
|
for h in iglob('{:s}{:s}/*-{:s}'.format(
|
||||||
custom_hook_folder, action, name)):
|
CUSTOM_HOOK_FOLDER, action, name)):
|
||||||
priority, _ = _extract_filename_parts(os.path.basename(h))
|
priority, _ = _extract_filename_parts(os.path.basename(h))
|
||||||
priorities.add(priority)
|
priorities.add(priority)
|
||||||
hooks.append({
|
hooks.append({
|
||||||
|
@ -98,7 +98,7 @@ def hook_info(action, name):
|
||||||
})
|
})
|
||||||
# Append non-overwritten system hooks
|
# Append non-overwritten system hooks
|
||||||
for h in iglob('{:s}{:s}/*-{:s}'.format(
|
for h in iglob('{:s}{:s}/*-{:s}'.format(
|
||||||
hook_folder, action, name)):
|
HOOK_FOLDER, action, name)):
|
||||||
priority, _ = _extract_filename_parts(os.path.basename(h))
|
priority, _ = _extract_filename_parts(os.path.basename(h))
|
||||||
if priority not in priorities:
|
if priority not in priorities:
|
||||||
hooks.append({
|
hooks.append({
|
||||||
|
@ -183,23 +183,23 @@ def hook_list(action, list_by='name', show_info=False):
|
||||||
# Append system hooks first
|
# Append system hooks first
|
||||||
if list_by == 'folder':
|
if list_by == 'folder':
|
||||||
result['system'] = dict() if show_info else set()
|
result['system'] = dict() if show_info else set()
|
||||||
_append_folder(result['system'], hook_folder)
|
_append_folder(result['system'], HOOK_FOLDER)
|
||||||
else:
|
else:
|
||||||
_append_folder(result, hook_folder)
|
_append_folder(result, HOOK_FOLDER)
|
||||||
except OSError:
|
except OSError:
|
||||||
logger.debug("system hook folder not found for action '%s' in %s",
|
logger.debug("system hook folder not found for action '%s' in %s",
|
||||||
action, hook_folder)
|
action, HOOK_FOLDER)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Append custom hooks
|
# Append custom hooks
|
||||||
if list_by == 'folder':
|
if list_by == 'folder':
|
||||||
result['custom'] = dict() if show_info else set()
|
result['custom'] = dict() if show_info else set()
|
||||||
_append_folder(result['custom'], custom_hook_folder)
|
_append_folder(result['custom'], CUSTOM_HOOK_FOLDER)
|
||||||
else:
|
else:
|
||||||
_append_folder(result, custom_hook_folder)
|
_append_folder(result, CUSTOM_HOOK_FOLDER)
|
||||||
except OSError:
|
except OSError:
|
||||||
logger.debug("custom hook folder not found for action '%s' in %s",
|
logger.debug("custom hook folder not found for action '%s' in %s",
|
||||||
action, custom_hook_folder)
|
action, CUSTOM_HOOK_FOLDER)
|
||||||
|
|
||||||
return { 'hooks': result }
|
return { 'hooks': result }
|
||||||
|
|
||||||
|
|
|
@ -44,9 +44,9 @@ from yunohost.domain import get_public_ip
|
||||||
|
|
||||||
logger = getActionLogger('yunohost.monitor')
|
logger = getActionLogger('yunohost.monitor')
|
||||||
|
|
||||||
glances_uri = 'http://127.0.0.1:61209'
|
GLANCES_URI = 'http://127.0.0.1:61209'
|
||||||
stats_path = '/var/lib/yunohost/stats'
|
STATS_PATH = '/var/lib/yunohost/stats'
|
||||||
crontab_path = '/etc/cron.d/yunohost-monitor'
|
CRONTAB_PATH = '/etc/cron.d/yunohost-monitor'
|
||||||
|
|
||||||
|
|
||||||
def monitor_disk(units=None, mountpoint=None, human_readable=False):
|
def monitor_disk(units=None, mountpoint=None, human_readable=False):
|
||||||
|
@ -422,7 +422,7 @@ def monitor_enable(with_stats=False):
|
||||||
'3 * * * * root {cmd} week >> /dev/null\n'
|
'3 * * * * root {cmd} week >> /dev/null\n'
|
||||||
'6 */4 * * * root {cmd} month >> /dev/null').format(
|
'6 */4 * * * root {cmd} month >> /dev/null').format(
|
||||||
cmd='/usr/bin/yunohost --quiet monitor update-stats')
|
cmd='/usr/bin/yunohost --quiet monitor update-stats')
|
||||||
with open(crontab_path, 'w') as f:
|
with open(CRONTAB_PATH, 'w') as f:
|
||||||
f.write(rules)
|
f.write(rules)
|
||||||
|
|
||||||
logger.success(m18n.n('monitor_enabled'))
|
logger.success(m18n.n('monitor_enabled'))
|
||||||
|
@ -447,7 +447,7 @@ def monitor_disable():
|
||||||
|
|
||||||
# Remove crontab
|
# Remove crontab
|
||||||
try:
|
try:
|
||||||
os.remove(crontab_path)
|
os.remove(CRONTAB_PATH)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -460,7 +460,7 @@ def _get_glances_api():
|
||||||
|
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
p = xmlrpclib.ServerProxy(glances_uri)
|
p = xmlrpclib.ServerProxy(GLANCES_URI)
|
||||||
p.system.methodHelp('getAll')
|
p.system.methodHelp('getAll')
|
||||||
except (xmlrpclib.ProtocolError, IOError):
|
except (xmlrpclib.ProtocolError, IOError):
|
||||||
pass
|
pass
|
||||||
|
@ -552,9 +552,9 @@ def _retrieve_stats(period, date=None):
|
||||||
# Retrieve pickle file
|
# Retrieve pickle file
|
||||||
if date is not None:
|
if date is not None:
|
||||||
timestamp = calendar.timegm(date)
|
timestamp = calendar.timegm(date)
|
||||||
pkl_file = '%s/%d_%s.pkl' % (stats_path, timestamp, period)
|
pkl_file = '%s/%d_%s.pkl' % (STATS_PATH, timestamp, period)
|
||||||
else:
|
else:
|
||||||
pkl_file = '%s/%s.pkl' % (stats_path, period)
|
pkl_file = '%s/%s.pkl' % (STATS_PATH, period)
|
||||||
if not os.path.isfile(pkl_file):
|
if not os.path.isfile(pkl_file):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -581,11 +581,11 @@ def _save_stats(stats, period, date=None):
|
||||||
# Set pickle file name
|
# Set pickle file name
|
||||||
if date is not None:
|
if date is not None:
|
||||||
timestamp = calendar.timegm(date)
|
timestamp = calendar.timegm(date)
|
||||||
pkl_file = '%s/%d_%s.pkl' % (stats_path, timestamp, period)
|
pkl_file = '%s/%d_%s.pkl' % (STATS_PATH, timestamp, period)
|
||||||
else:
|
else:
|
||||||
pkl_file = '%s/%s.pkl' % (stats_path, period)
|
pkl_file = '%s/%s.pkl' % (STATS_PATH, period)
|
||||||
if not os.path.isdir(stats_path):
|
if not os.path.isdir(STATS_PATH):
|
||||||
os.makedirs(stats_path)
|
os.makedirs(STATS_PATH)
|
||||||
|
|
||||||
# Limit stats
|
# Limit stats
|
||||||
if date is None:
|
if date is None:
|
||||||
|
|
|
@ -39,9 +39,9 @@ from moulinette.utils import log, filesystem
|
||||||
from yunohost.hook import hook_callback
|
from yunohost.hook import hook_callback
|
||||||
|
|
||||||
|
|
||||||
base_conf_path = '/home/yunohost.conf'
|
BASE_CONF_PATH = '/home/yunohost.conf'
|
||||||
backup_conf_dir = os.path.join(base_conf_path, 'backup')
|
BACKUP_CONF_DIR = os.path.join(BASE_CONF_PATH, 'backup')
|
||||||
pending_conf_dir = os.path.join(base_conf_path, 'pending')
|
PENDING_CONF_DIR = os.path.join(BASE_CONF_PATH, 'pending')
|
||||||
|
|
||||||
logger = log.getActionLogger('yunohost.service')
|
logger = log.getActionLogger('yunohost.service')
|
||||||
|
|
||||||
|
@ -300,15 +300,15 @@ def service_regen_conf(names=[], with_diff=False, force=False, dry_run=False,
|
||||||
return pending_conf
|
return pending_conf
|
||||||
|
|
||||||
# Clean pending conf directory
|
# Clean pending conf directory
|
||||||
if os.path.isdir(pending_conf_dir):
|
if os.path.isdir(PENDING_CONF_DIR):
|
||||||
if not names:
|
if not names:
|
||||||
shutil.rmtree(pending_conf_dir, ignore_errors=True)
|
shutil.rmtree(PENDING_CONF_DIR, ignore_errors=True)
|
||||||
else:
|
else:
|
||||||
for name in names:
|
for name in names:
|
||||||
shutil.rmtree(os.path.join(pending_conf_dir, name),
|
shutil.rmtree(os.path.join(PENDING_CONF_DIR, name),
|
||||||
ignore_errors=True)
|
ignore_errors=True)
|
||||||
else:
|
else:
|
||||||
filesystem.mkdir(pending_conf_dir, 0755, True)
|
filesystem.mkdir(PENDING_CONF_DIR, 0755, True)
|
||||||
|
|
||||||
# Format common hooks arguments
|
# Format common hooks arguments
|
||||||
common_args = [1 if force else 0, 1 if dry_run else 0]
|
common_args = [1 if force else 0, 1 if dry_run else 0]
|
||||||
|
@ -318,7 +318,7 @@ def service_regen_conf(names=[], with_diff=False, force=False, dry_run=False,
|
||||||
|
|
||||||
def _pre_call(name, priority, path, args):
|
def _pre_call(name, priority, path, args):
|
||||||
# create the pending conf directory for the service
|
# create the pending conf directory for the service
|
||||||
service_pending_path = os.path.join(pending_conf_dir, name)
|
service_pending_path = os.path.join(PENDING_CONF_DIR, name)
|
||||||
filesystem.mkdir(service_pending_path, 0755, True, uid='admin')
|
filesystem.mkdir(service_pending_path, 0755, True, uid='admin')
|
||||||
# return the arguments to pass to the script
|
# return the arguments to pass to the script
|
||||||
return pre_args + [service_pending_path, ]
|
return pre_args + [service_pending_path, ]
|
||||||
|
@ -615,12 +615,12 @@ def _get_pending_conf(services=[]):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
result = {}
|
result = {}
|
||||||
if not os.path.isdir(pending_conf_dir):
|
if not os.path.isdir(PENDING_CONF_DIR):
|
||||||
return result
|
return result
|
||||||
if not services:
|
if not services:
|
||||||
services = os.listdir(pending_conf_dir)
|
services = os.listdir(PENDING_CONF_DIR)
|
||||||
for name in services:
|
for name in services:
|
||||||
service_pending_path = os.path.join(pending_conf_dir, name)
|
service_pending_path = os.path.join(PENDING_CONF_DIR, name)
|
||||||
if not os.path.isdir(service_pending_path):
|
if not os.path.isdir(service_pending_path):
|
||||||
continue
|
continue
|
||||||
path_index = len(service_pending_path)
|
path_index = len(service_pending_path)
|
||||||
|
@ -672,7 +672,7 @@ def _process_regen_conf(system_conf, new_conf=None, save=True):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if save:
|
if save:
|
||||||
backup_path = os.path.join(backup_conf_dir, '{0}-{1}'.format(
|
backup_path = os.path.join(BACKUP_CONF_DIR, '{0}-{1}'.format(
|
||||||
system_conf.lstrip('/'), time.strftime("%Y%m%d.%H%M%S")))
|
system_conf.lstrip('/'), time.strftime("%Y%m%d.%H%M%S")))
|
||||||
backup_dir = os.path.dirname(backup_path)
|
backup_dir = os.path.dirname(backup_path)
|
||||||
if not os.path.isdir(backup_dir):
|
if not os.path.isdir(backup_dir):
|
||||||
|
|
|
@ -46,7 +46,8 @@ 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/'
|
# FIXME this is a duplicate from apps.py
|
||||||
|
APPS_SETTING_PATH= '/etc/yunohost/apps/'
|
||||||
|
|
||||||
logger = getActionLogger('yunohost.tools')
|
logger = getActionLogger('yunohost.tools')
|
||||||
|
|
||||||
|
@ -341,7 +342,7 @@ def tools_update(ignore_apps=False, ignore_packages=False):
|
||||||
app_fetchlist()
|
app_fetchlist()
|
||||||
except MoulinetteError:
|
except MoulinetteError:
|
||||||
pass
|
pass
|
||||||
app_list = os.listdir(apps_setting_path)
|
app_list = os.listdir(APPS_SETTING_PATH)
|
||||||
if len(app_list) > 0:
|
if len(app_list) > 0:
|
||||||
for app_id in app_list:
|
for app_id in app_list:
|
||||||
if '__' in app_id:
|
if '__' in app_id:
|
||||||
|
|
Loading…
Add table
Reference in a new issue