mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[fix] Move imports at the top in backup.py
This commit is contained in:
parent
8a44179d00
commit
704151f5eb
1 changed files with 7 additions and 14 deletions
|
@ -39,6 +39,13 @@ from moulinette.core import MoulinetteError
|
||||||
from moulinette.utils import filesystem
|
from moulinette.utils import filesystem
|
||||||
from moulinette.utils.log import getActionLogger
|
from moulinette.utils.log import getActionLogger
|
||||||
|
|
||||||
|
from yunohost.app import app_info, app_ssowatconf, _is_installed,
|
||||||
|
from yunohost.hook import (
|
||||||
|
hook_info, hook_callback, hook_exec, custom_hook_folder
|
||||||
|
)
|
||||||
|
from yunohost.monitor import binary_to_human
|
||||||
|
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
|
||||||
|
|
||||||
|
@ -63,8 +70,6 @@ def backup_create(name=None, description=None, output_directory=None,
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# TODO: Add a 'clean' argument to clean output directory
|
# TODO: Add a 'clean' argument to clean output directory
|
||||||
from yunohost.hook import hook_info, hook_callback, hook_exec
|
|
||||||
|
|
||||||
tmp_dir = None
|
tmp_dir = None
|
||||||
|
|
||||||
# Validate what to backup
|
# Validate what to backup
|
||||||
|
@ -167,8 +172,6 @@ def backup_create(name=None, description=None, output_directory=None,
|
||||||
|
|
||||||
# Backup apps
|
# Backup apps
|
||||||
if not ignore_apps:
|
if not ignore_apps:
|
||||||
from yunohost.app import app_info
|
|
||||||
|
|
||||||
# Filter applications to backup
|
# Filter applications to backup
|
||||||
apps_list = set(os.listdir('/etc/yunohost/apps'))
|
apps_list = set(os.listdir('/etc/yunohost/apps'))
|
||||||
apps_filtered = set()
|
apps_filtered = set()
|
||||||
|
@ -293,9 +296,6 @@ def backup_restore(auth, name, hooks=[], ignore_hooks=False,
|
||||||
force -- Force restauration on an already installed system
|
force -- Force restauration on an already installed system
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from yunohost.hook import hook_info, hook_callback, hook_exec
|
|
||||||
from yunohost.hook import custom_hook_folder
|
|
||||||
|
|
||||||
# Validate what to restore
|
# Validate what to restore
|
||||||
if ignore_hooks and ignore_apps:
|
if ignore_hooks and ignore_apps:
|
||||||
raise MoulinetteError(errno.EINVAL,
|
raise MoulinetteError(errno.EINVAL,
|
||||||
|
@ -373,8 +373,6 @@ def backup_restore(auth, name, hooks=[], ignore_hooks=False,
|
||||||
_clean_tmp_dir()
|
_clean_tmp_dir()
|
||||||
raise MoulinetteError(errno.EEXIST, m18n.n('restore_failed'))
|
raise MoulinetteError(errno.EEXIST, m18n.n('restore_failed'))
|
||||||
else:
|
else:
|
||||||
from yunohost.tools import tools_postinstall
|
|
||||||
|
|
||||||
# Retrieve the domain from the backup
|
# Retrieve the domain from the backup
|
||||||
try:
|
try:
|
||||||
with open("%s/yunohost/current_host" % tmp_dir, 'r') as f:
|
with open("%s/yunohost/current_host" % tmp_dir, 'r') as f:
|
||||||
|
@ -430,8 +428,6 @@ def backup_restore(auth, name, hooks=[], ignore_hooks=False,
|
||||||
|
|
||||||
# Add apps restore hook
|
# Add apps restore hook
|
||||||
if not ignore_apps:
|
if not ignore_apps:
|
||||||
from yunohost.app import _is_installed, app_ssowatconf
|
|
||||||
|
|
||||||
# Filter applications to restore
|
# Filter applications to restore
|
||||||
apps_list = set(info['apps'].keys())
|
apps_list = set(info['apps'].keys())
|
||||||
apps_filtered = set()
|
apps_filtered = set()
|
||||||
|
@ -540,8 +536,6 @@ 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
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from yunohost.monitor import binary_to_human
|
|
||||||
|
|
||||||
archive_file = '%s/%s.tar.gz' % (archives_path, name)
|
archive_file = '%s/%s.tar.gz' % (archives_path, name)
|
||||||
if not os.path.isfile(archive_file):
|
if not os.path.isfile(archive_file):
|
||||||
raise MoulinetteError(errno.EIO,
|
raise MoulinetteError(errno.EIO,
|
||||||
|
@ -589,7 +583,6 @@ def backup_delete(name):
|
||||||
name -- Name of the local backup archive
|
name -- Name of the local backup archive
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from yunohost.hook import hook_callback
|
|
||||||
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)
|
||||||
|
|
Loading…
Add table
Reference in a new issue