mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
moulinette MoulinetteError multilignes"
sed -i "N; s@MoulinetteError(.*m18n\.n(\n* *\(.*\)))@MoulinetteError(\1)@g" <fichiers>
This commit is contained in:
parent
f2e184d8b2
commit
4bc3427e3e
12 changed files with 89 additions and 172 deletions
|
@ -125,14 +125,12 @@ def app_fetchlist(url=None, name=None):
|
|||
appslists_to_be_fetched = [name]
|
||||
operation_logger.success()
|
||||
else:
|
||||
raise MoulinetteError(errno.EINVAL,
|
||||
m18n.n('custom_appslist_name_required'))
|
||||
raise MoulinetteError('custom_appslist_name_required')
|
||||
|
||||
# If a name is given, look for an appslist with that name and fetch it
|
||||
elif name is not None:
|
||||
if name not in appslists.keys():
|
||||
raise MoulinetteError(errno.EINVAL,
|
||||
m18n.n('appslist_unknown', appslist=name))
|
||||
raise MoulinetteError('appslist_unknown', appslist=name)
|
||||
else:
|
||||
appslists_to_be_fetched = [name]
|
||||
|
||||
|
@ -343,8 +341,7 @@ def app_info(app, show_status=False, raw=False):
|
|||
|
||||
"""
|
||||
if not _is_installed(app):
|
||||
raise MoulinetteError(errno.EINVAL,
|
||||
m18n.n('app_not_installed', app=app))
|
||||
raise MoulinetteError('app_not_installed', app=app)
|
||||
|
||||
app_setting_path = APPS_SETTING_PATH + app
|
||||
|
||||
|
@ -402,8 +399,7 @@ def app_map(app=None, raw=False, user=None):
|
|||
|
||||
if app is not None:
|
||||
if not _is_installed(app):
|
||||
raise MoulinetteError(errno.EINVAL,
|
||||
m18n.n('app_not_installed', app=app))
|
||||
raise MoulinetteError('app_not_installed', app=app)
|
||||
apps = [app, ]
|
||||
else:
|
||||
apps = os.listdir(APPS_SETTING_PATH)
|
||||
|
@ -455,8 +451,7 @@ def app_change_url(operation_logger, auth, app, domain, path):
|
|||
|
||||
installed = _is_installed(app)
|
||||
if not installed:
|
||||
raise MoulinetteError(errno.ENOPKG,
|
||||
m18n.n('app_not_installed', app=app))
|
||||
raise MoulinetteError('app_not_installed', app=app)
|
||||
|
||||
if not os.path.exists(os.path.join(APPS_SETTING_PATH, app, "scripts", "change_url")):
|
||||
raise MoulinetteError("app_change_no_change_url_script", app_name=app)
|
||||
|
@ -593,8 +588,7 @@ def app_upgrade(auth, app=[], url=None, file=None):
|
|||
logger.info(m18n.n('app_upgrade_app_name', app=app_instance_name))
|
||||
installed = _is_installed(app_instance_name)
|
||||
if not installed:
|
||||
raise MoulinetteError(errno.ENOPKG,
|
||||
m18n.n('app_not_installed', app=app_instance_name))
|
||||
raise MoulinetteError('app_not_installed', app=app_instance_name)
|
||||
|
||||
if app_instance_name in upgraded_apps:
|
||||
continue
|
||||
|
@ -746,8 +740,7 @@ def app_install(operation_logger, auth, app, label=None, args=None, no_remove_on
|
|||
instance_number = _installed_instance_number(app_id, last=True) + 1
|
||||
if instance_number > 1:
|
||||
if 'multi_instance' not in manifest or not is_true(manifest['multi_instance']):
|
||||
raise MoulinetteError(errno.EEXIST,
|
||||
m18n.n('app_already_installed', app=app_id))
|
||||
raise MoulinetteError('app_already_installed', app=app_id)
|
||||
|
||||
# Change app_id to the forked app id
|
||||
app_instance_name = app_id + '__' + str(instance_number)
|
||||
|
@ -888,8 +881,7 @@ def app_remove(operation_logger, auth, app):
|
|||
"""
|
||||
from yunohost.hook import hook_exec, hook_remove, hook_callback
|
||||
if not _is_installed(app):
|
||||
raise MoulinetteError(errno.EINVAL,
|
||||
m18n.n('app_not_installed', app=app))
|
||||
raise MoulinetteError('app_not_installed', app=app)
|
||||
|
||||
operation_logger.start()
|
||||
|
||||
|
@ -1152,8 +1144,7 @@ def app_makedefault(operation_logger, auth, app, domain=None):
|
|||
with open('/etc/ssowat/conf.json.persistent') as json_conf:
|
||||
ssowat_conf = json.loads(str(json_conf.read()))
|
||||
except ValueError as e:
|
||||
raise MoulinetteError(errno.EINVAL,
|
||||
m18n.n('ssowat_persistent_conf_read_error', error=e.strerror))
|
||||
raise MoulinetteError('ssowat_persistent_conf_read_error', error=e.strerror)
|
||||
except IOError:
|
||||
ssowat_conf = {}
|
||||
|
||||
|
@ -1166,8 +1157,7 @@ def app_makedefault(operation_logger, auth, app, domain=None):
|
|||
with open('/etc/ssowat/conf.json.persistent', 'w+') as f:
|
||||
json.dump(ssowat_conf, f, sort_keys=True, indent=4)
|
||||
except IOError as e:
|
||||
raise MoulinetteError(errno.EPERM,
|
||||
m18n.n('ssowat_persistent_conf_write_error', error=e.strerror))
|
||||
raise MoulinetteError('ssowat_persistent_conf_write_error', error=e.strerror)
|
||||
|
||||
os.system('chmod 644 /etc/ssowat/conf.json.persistent')
|
||||
|
||||
|
@ -1219,8 +1209,7 @@ def app_checkport(port):
|
|||
if tools_port_available(port):
|
||||
logger.success(m18n.n('port_available', port=int(port)))
|
||||
else:
|
||||
raise MoulinetteError(errno.EINVAL,
|
||||
m18n.n('port_unavailable', port=int(port)))
|
||||
raise MoulinetteError('port_unavailable', port=int(port))
|
||||
|
||||
|
||||
def app_register_url(auth, app, domain, path):
|
||||
|
@ -1247,8 +1236,7 @@ def app_register_url(auth, app, domain, path):
|
|||
if installed:
|
||||
settings = _get_app_settings(app)
|
||||
if "path" in settings.keys() and "domain" in settings.keys():
|
||||
raise MoulinetteError(errno.EINVAL,
|
||||
m18n.n('app_already_installed_cant_change_url'))
|
||||
raise MoulinetteError('app_already_installed_cant_change_url')
|
||||
|
||||
# Check the url is available
|
||||
conflicts = _get_conflicting_apps(auth, domain, path)
|
||||
|
@ -1458,8 +1446,7 @@ def app_ssowatconf(auth):
|
|||
def app_change_label(auth, app, new_label):
|
||||
installed = _is_installed(app)
|
||||
if not installed:
|
||||
raise MoulinetteError(errno.ENOPKG,
|
||||
m18n.n('app_not_installed', app=app))
|
||||
raise MoulinetteError('app_not_installed', app=app)
|
||||
|
||||
app_setting(app, "label", value=new_label)
|
||||
|
||||
|
@ -1640,8 +1627,7 @@ def app_config_apply(app, args):
|
|||
|
||||
installed = _is_installed(app)
|
||||
if not installed:
|
||||
raise MoulinetteError(errno.ENOPKG,
|
||||
m18n.n('app_not_installed', app=app))
|
||||
raise MoulinetteError('app_not_installed', app=app_id)
|
||||
|
||||
config_panel = os.path.join(APPS_SETTING_PATH, app, 'config_panel.json')
|
||||
config_script = os.path.join(APPS_SETTING_PATH, app, 'scripts', 'config')
|
||||
|
@ -1699,8 +1685,7 @@ def _get_app_settings(app_id):
|
|||
|
||||
"""
|
||||
if not _is_installed(app_id):
|
||||
raise MoulinetteError(errno.EINVAL,
|
||||
m18n.n('app_not_installed', app=app_id))
|
||||
raise MoulinetteError('app_not_installed', app=app_id)
|
||||
try:
|
||||
with open(os.path.join(
|
||||
APPS_SETTING_PATH, app_id, 'settings.yml')) as f:
|
||||
|
@ -1816,8 +1801,7 @@ def _extract_app_from_file(path, remove=False):
|
|||
except IOError:
|
||||
raise MoulinetteError('app_install_files_invalid')
|
||||
except ValueError as e:
|
||||
raise MoulinetteError(errno.EINVAL,
|
||||
m18n.n('app_manifest_invalid', error=e.strerror))
|
||||
raise MoulinetteError('app_manifest_invalid', error=e.strerror)
|
||||
|
||||
logger.debug(m18n.n('done'))
|
||||
|
||||
|
@ -1885,8 +1869,7 @@ def _fetch_app_from_git(app):
|
|||
'wget', '-qO', app_tmp_archive, tarball_url])
|
||||
except subprocess.CalledProcessError:
|
||||
logger.exception('unable to download %s', tarball_url)
|
||||
raise MoulinetteError(errno.EIO,
|
||||
m18n.n('app_sources_fetch_failed'))
|
||||
raise MoulinetteError('app_sources_fetch_failed')
|
||||
else:
|
||||
manifest, extracted_app_folder = _extract_app_from_file(
|
||||
app_tmp_archive, remove=True)
|
||||
|
@ -1909,11 +1892,9 @@ def _fetch_app_from_git(app):
|
|||
with open(extracted_app_folder + '/manifest.json') as f:
|
||||
manifest = json.loads(str(f.read()))
|
||||
except subprocess.CalledProcessError:
|
||||
raise MoulinetteError(errno.EIO,
|
||||
m18n.n('app_sources_fetch_failed'))
|
||||
raise MoulinetteError('app_sources_fetch_failed')
|
||||
except ValueError as e:
|
||||
raise MoulinetteError(errno.EIO,
|
||||
m18n.n('app_manifest_invalid', error=e.strerror))
|
||||
raise MoulinetteError('app_manifest_invalid', error=e.strerror)
|
||||
else:
|
||||
logger.debug(m18n.n('done'))
|
||||
|
||||
|
@ -1936,8 +1917,7 @@ def _fetch_app_from_git(app):
|
|||
raise MoulinetteError('app_unknown')
|
||||
|
||||
if 'git' not in app_info:
|
||||
raise MoulinetteError(errno.EINVAL,
|
||||
m18n.n('app_unsupported_remote_type'))
|
||||
raise MoulinetteError('app_unsupported_remote_type')
|
||||
url = app_info['git']['url']
|
||||
|
||||
if 'github.com' in url:
|
||||
|
@ -1949,8 +1929,7 @@ def _fetch_app_from_git(app):
|
|||
'wget', '-qO', app_tmp_archive, tarball_url])
|
||||
except subprocess.CalledProcessError:
|
||||
logger.exception('unable to download %s', tarball_url)
|
||||
raise MoulinetteError(errno.EIO,
|
||||
m18n.n('app_sources_fetch_failed'))
|
||||
raise MoulinetteError('app_sources_fetch_failed')
|
||||
else:
|
||||
manifest, extracted_app_folder = _extract_app_from_file(
|
||||
app_tmp_archive, remove=True)
|
||||
|
@ -1966,11 +1945,9 @@ def _fetch_app_from_git(app):
|
|||
with open(extracted_app_folder + '/manifest.json') as f:
|
||||
manifest = json.loads(str(f.read()))
|
||||
except subprocess.CalledProcessError:
|
||||
raise MoulinetteError(errno.EIO,
|
||||
m18n.n('app_sources_fetch_failed'))
|
||||
raise MoulinetteError('app_sources_fetch_failed')
|
||||
except ValueError as e:
|
||||
raise MoulinetteError(errno.EIO,
|
||||
m18n.n('app_manifest_invalid', error=e.strerror))
|
||||
raise MoulinetteError('app_manifest_invalid', error=e.strerror)
|
||||
else:
|
||||
logger.debug(m18n.n('done'))
|
||||
|
||||
|
@ -2237,8 +2214,7 @@ def _parse_action_args_in_yunohost_format(args, action_args, auth=None):
|
|||
# Validate argument value
|
||||
if (arg_value is None or arg_value == '') \
|
||||
and not arg.get('optional', False):
|
||||
raise MoulinetteError(errno.EINVAL,
|
||||
m18n.n('app_argument_required', name=arg_name))
|
||||
raise MoulinetteError('app_argument_required', name=arg_name)
|
||||
elif arg_value is None:
|
||||
args_dict[arg_name] = ''
|
||||
continue
|
||||
|
@ -2462,8 +2438,7 @@ def _read_appslist_list():
|
|||
try:
|
||||
appslists = json.loads(appslists_json)
|
||||
except ValueError:
|
||||
raise MoulinetteError(errno.EBADR,
|
||||
m18n.n('appslist_corrupted_json', filename=APPSLISTS_JSON))
|
||||
raise MoulinetteError('appslist_corrupted_json', filename=APPSLISTS_JSON)
|
||||
|
||||
return appslists
|
||||
|
||||
|
@ -2493,15 +2468,13 @@ def _register_new_appslist(url, name):
|
|||
|
||||
# Check if name conflicts with an existing list
|
||||
if name in appslist_list:
|
||||
raise MoulinetteError(errno.EEXIST,
|
||||
m18n.n('appslist_name_already_tracked', name=name))
|
||||
raise MoulinetteError('appslist_name_already_tracked', name=name)
|
||||
|
||||
# Check if url conflicts with an existing list
|
||||
known_appslist_urls = [appslist["url"] for _, appslist in appslist_list.items()]
|
||||
|
||||
if url in known_appslist_urls:
|
||||
raise MoulinetteError(errno.EEXIST,
|
||||
m18n.n('appslist_url_already_tracked', url=url))
|
||||
raise MoulinetteError('appslist_url_already_tracked', url=url)
|
||||
|
||||
logger.debug("Registering new appslist %s at %s" % (name, url))
|
||||
|
||||
|
|
|
@ -327,8 +327,7 @@ class BackupManager():
|
|||
logger.debug("temporary directory for backup '%s' already exists",
|
||||
self.work_dir)
|
||||
# FIXME May be we should clean the workdir here
|
||||
raise MoulinetteError(
|
||||
errno.EIO, m18n.n('backup_output_directory_not_empty'))
|
||||
raise MoulinetteError('backup_output_directory_not_empty')
|
||||
|
||||
###########################################################################
|
||||
# Backup target management #
|
||||
|
@ -880,8 +879,7 @@ class RestoreManager():
|
|||
logger.debug("unable to retrieve current_host from the backup",
|
||||
exc_info=1)
|
||||
# FIXME include the current_host by default ?
|
||||
raise MoulinetteError(errno.EIO,
|
||||
m18n.n('backup_invalid_archive'))
|
||||
raise MoulinetteError('backup_invalid_archive')
|
||||
|
||||
logger.debug("executing the post-install...")
|
||||
tools_postinstall(domain, 'yunohost', True)
|
||||
|
@ -1010,8 +1008,7 @@ class RestoreManager():
|
|||
subprocess.call(['rmdir', self.work_dir])
|
||||
logger.debug("Unmount dir: {}".format(self.work_dir))
|
||||
else:
|
||||
raise MoulinetteError(errno.EIO,
|
||||
m18n.n('restore_removing_tmp_dir_failed'))
|
||||
raise MoulinetteError('restore_removing_tmp_dir_failed')
|
||||
elif os.path.isdir(self.work_dir):
|
||||
logger.debug("temporary restore directory '%s' already exists",
|
||||
self.work_dir)
|
||||
|
@ -1019,8 +1016,7 @@ class RestoreManager():
|
|||
if ret == 0:
|
||||
logger.debug("Delete dir: {}".format(self.work_dir))
|
||||
else:
|
||||
raise MoulinetteError(errno.EIO,
|
||||
m18n.n('restore_removing_tmp_dir_failed'))
|
||||
raise MoulinetteError('restore_removing_tmp_dir_failed')
|
||||
|
||||
filesystem.mkdir(self.work_dir, parents=True)
|
||||
|
||||
|
@ -1524,8 +1520,7 @@ class BackupMethod(object):
|
|||
"""
|
||||
if self.need_mount():
|
||||
if self._recursive_umount(self.work_dir) > 0:
|
||||
raise MoulinetteError(errno.EINVAL,
|
||||
m18n.n('backup_cleaning_failed'))
|
||||
raise MoulinetteError('backup_cleaning_failed')
|
||||
|
||||
if self.manager.is_tmp_work_dir:
|
||||
filesystem.rm(self.work_dir, True, True)
|
||||
|
@ -1567,8 +1562,7 @@ class BackupMethod(object):
|
|||
if free_space < backup_size:
|
||||
logger.debug('Not enough space at %s (free: %s / needed: %d)',
|
||||
self.repo, free_space, backup_size)
|
||||
raise MoulinetteError(errno.EIO, m18n.n(
|
||||
'not_enough_disk_space', path=self.repo))
|
||||
raise MoulinetteError('not_enough_disk_space', path=self.repo)
|
||||
|
||||
def _organize_files(self):
|
||||
"""
|
||||
|
@ -1656,12 +1650,10 @@ class BackupMethod(object):
|
|||
i = msignals.prompt(m18n.n('backup_ask_for_copying_if_needed',
|
||||
answers='y/N', size=str(size)))
|
||||
except NotImplemented:
|
||||
raise MoulinetteError(errno.EIO,
|
||||
m18n.n('backup_unable_to_organize_files'))
|
||||
raise MoulinetteError('backup_unable_to_organize_files')
|
||||
else:
|
||||
if i != 'y' and i != 'Y':
|
||||
raise MoulinetteError(errno.EIO,
|
||||
m18n.n('backup_unable_to_organize_files'))
|
||||
raise MoulinetteError('backup_unable_to_organize_files')
|
||||
|
||||
# Copy unbinded path
|
||||
logger.debug(m18n.n('backup_copying_to_organize_the_archive',
|
||||
|
@ -1751,8 +1743,7 @@ class CopyBackupMethod(BackupMethod):
|
|||
super(CopyBackupMethod, self).mount()
|
||||
|
||||
if not os.path.isdir(self.repo):
|
||||
raise MoulinetteError(errno.EIO,
|
||||
m18n.n('backup_no_uncompress_archive_dir'))
|
||||
raise MoulinetteError('backup_no_uncompress_archive_dir')
|
||||
|
||||
filesystem.mkdir(self.work_dir, parent=True)
|
||||
ret = subprocess.call(["mount", "-r", "--rbind", self.repo,
|
||||
|
@ -1763,8 +1754,7 @@ class CopyBackupMethod(BackupMethod):
|
|||
logger.warning(m18n.n("bind_mouting_disable"))
|
||||
subprocess.call(["mountpoint", "-q", dest,
|
||||
"&&", "umount", "-R", dest])
|
||||
raise MoulinetteError(errno.EIO,
|
||||
m18n.n('backup_cant_mount_uncompress_archive'))
|
||||
raise MoulinetteError('backup_cant_mount_uncompress_archive')
|
||||
|
||||
|
||||
class TarBackupMethod(BackupMethod):
|
||||
|
@ -1809,8 +1799,7 @@ class TarBackupMethod(BackupMethod):
|
|||
except:
|
||||
logger.debug("unable to open '%s' for writing",
|
||||
self._archive_file, exc_info=1)
|
||||
raise MoulinetteError(errno.EIO,
|
||||
m18n.n('backup_archive_open_failed'))
|
||||
raise MoulinetteError('backup_archive_open_failed')
|
||||
|
||||
# Add files to the archive
|
||||
try:
|
||||
|
@ -1821,8 +1810,7 @@ class TarBackupMethod(BackupMethod):
|
|||
tar.close()
|
||||
except IOError:
|
||||
logger.error(m18n.n('backup_archive_writing_error'), exc_info=1)
|
||||
raise MoulinetteError(errno.EIO,
|
||||
m18n.n('backup_creation_failed'))
|
||||
raise MoulinetteError('backup_creation_failed')
|
||||
|
||||
# Move info file
|
||||
shutil.copy(os.path.join(self.work_dir, 'info.json'),
|
||||
|
@ -1850,8 +1838,7 @@ class TarBackupMethod(BackupMethod):
|
|||
except:
|
||||
logger.debug("cannot open backup archive '%s'",
|
||||
self._archive_file, exc_info=1)
|
||||
raise MoulinetteError(errno.EIO,
|
||||
m18n.n('backup_archive_open_failed'))
|
||||
raise MoulinetteError('backup_archive_open_failed')
|
||||
tar.close()
|
||||
|
||||
# Mount the tarball
|
||||
|
@ -1912,12 +1899,10 @@ class BorgBackupMethod(BackupMethod):
|
|||
super(CopyBackupMethod, self).backup()
|
||||
|
||||
# TODO run borg create command
|
||||
raise MoulinetteError(
|
||||
errno.EIO, m18n.n('backup_borg_not_implemented'))
|
||||
raise MoulinetteError('backup_borg_not_implemented')
|
||||
|
||||
def mount(self, mnt_path):
|
||||
raise MoulinetteError(
|
||||
errno.EIO, m18n.n('backup_borg_not_implemented'))
|
||||
raise MoulinetteError('backup_borg_not_implemented')
|
||||
|
||||
|
||||
class CustomBackupMethod(BackupMethod):
|
||||
|
@ -1963,8 +1948,7 @@ class CustomBackupMethod(BackupMethod):
|
|||
ret = hook_callback('backup_method', [self.method],
|
||||
args=self._get_args('backup'))
|
||||
if ret['failed']:
|
||||
raise MoulinetteError(errno.EIO,
|
||||
m18n.n('backup_custom_backup_error'))
|
||||
raise MoulinetteError('backup_custom_backup_error')
|
||||
|
||||
def mount(self, restore_manager):
|
||||
"""
|
||||
|
@ -1977,8 +1961,7 @@ class CustomBackupMethod(BackupMethod):
|
|||
ret = hook_callback('backup_method', [self.method],
|
||||
args=self._get_args('mount'))
|
||||
if ret['failed']:
|
||||
raise MoulinetteError(errno.EIO,
|
||||
m18n.n('backup_custom_mount_error'))
|
||||
raise MoulinetteError('backup_custom_mount_error')
|
||||
|
||||
def _get_args(self, action):
|
||||
"""Return the arguments to give to the custom script"""
|
||||
|
@ -2014,8 +1997,7 @@ def backup_create(name=None, description=None, methods=[],
|
|||
|
||||
# Validate there is no archive with the same name
|
||||
if name and name in backup_list()['archives']:
|
||||
raise MoulinetteError(errno.EINVAL,
|
||||
m18n.n('backup_archive_name_exists'))
|
||||
raise MoulinetteError('backup_archive_name_exists')
|
||||
|
||||
# Validate output_directory option
|
||||
if output_directory:
|
||||
|
@ -2025,17 +2007,14 @@ def backup_create(name=None, description=None, methods=[],
|
|||
if output_directory.startswith(ARCHIVES_PATH) or \
|
||||
re.match(r'^/(|(bin|boot|dev|etc|lib|root|run|sbin|sys|usr|var)(|/.*))$',
|
||||
output_directory):
|
||||
raise MoulinetteError(errno.EINVAL,
|
||||
m18n.n('backup_output_directory_forbidden'))
|
||||
raise MoulinetteError('backup_output_directory_forbidden')
|
||||
|
||||
# Check that output directory is empty
|
||||
if os.path.isdir(output_directory) and no_compress and \
|
||||
os.listdir(output_directory):
|
||||
raise MoulinetteError(errno.EIO,
|
||||
m18n.n('backup_output_directory_not_empty'))
|
||||
raise MoulinetteError('backup_output_directory_not_empty')
|
||||
elif no_compress:
|
||||
raise MoulinetteError(errno.EINVAL,
|
||||
m18n.n('backup_output_directory_required'))
|
||||
raise MoulinetteError('backup_output_directory_required')
|
||||
|
||||
# Define methods (retro-compat)
|
||||
if not methods:
|
||||
|
@ -2217,8 +2196,7 @@ def backup_info(name, with_details=False, human_readable=False):
|
|||
|
||||
# Check file exist (even if it's a broken symlink)
|
||||
if not os.path.lexists(archive_file):
|
||||
raise MoulinetteError(errno.EIO,
|
||||
m18n.n('backup_archive_name_unknown', name=name))
|
||||
raise MoulinetteError('backup_archive_name_unknown', name=name)
|
||||
|
||||
# If symlink, retrieve the real path
|
||||
if os.path.islink(archive_file):
|
||||
|
@ -2292,8 +2270,8 @@ def backup_delete(name):
|
|||
|
||||
"""
|
||||
if name not in backup_list()["archives"]:
|
||||
raise MoulinetteError(errno.EIO, m18n.n('backup_archive_name_unknown',
|
||||
name=name))
|
||||
raise MoulinetteError('backup_archive_name_unknown',
|
||||
name=name)
|
||||
|
||||
hook_callback('pre_backup_delete', args=[name])
|
||||
|
||||
|
|
|
@ -172,8 +172,7 @@ def _certificate_install_selfsigned(domain_list, force=False):
|
|||
status = _get_status(domain)
|
||||
|
||||
if status["summary"]["code"] in ('good', 'great'):
|
||||
raise MoulinetteError(errno.EINVAL, m18n.n(
|
||||
'certmanager_attempt_to_replace_valid_cert', domain=domain))
|
||||
raise MoulinetteError('certmanager_attempt_to_replace_valid_cert', domain=domain)
|
||||
|
||||
operation_logger.start()
|
||||
|
||||
|
@ -203,8 +202,7 @@ def _certificate_install_selfsigned(domain_list, force=False):
|
|||
|
||||
if p.returncode != 0:
|
||||
logger.warning(out)
|
||||
raise MoulinetteError(
|
||||
errno.EIO, m18n.n('domain_cert_gen_failed'))
|
||||
raise MoulinetteError('domain_cert_gen_failed')
|
||||
else:
|
||||
logger.debug(out)
|
||||
|
||||
|
@ -262,14 +260,12 @@ def _certificate_install_letsencrypt(auth, domain_list, force=False, no_checks=F
|
|||
for domain in domain_list:
|
||||
yunohost_domains_list = yunohost.domain.domain_list(auth)['domains']
|
||||
if domain not in yunohost_domains_list:
|
||||
raise MoulinetteError(errno.EINVAL, m18n.n(
|
||||
'certmanager_domain_unknown', domain=domain))
|
||||
raise MoulinetteError('certmanager_domain_unknown', domain=domain)
|
||||
|
||||
# Is it self-signed?
|
||||
status = _get_status(domain)
|
||||
if not force and status["CA_type"]["code"] != "self-signed":
|
||||
raise MoulinetteError(errno.EINVAL, m18n.n(
|
||||
'certmanager_domain_cert_not_selfsigned', domain=domain))
|
||||
raise MoulinetteError('certmanager_domain_cert_not_selfsigned', domain=domain)
|
||||
|
||||
if staging:
|
||||
logger.warning(
|
||||
|
@ -349,25 +345,21 @@ def certificate_renew(auth, domain_list, force=False, no_checks=False, email=Fal
|
|||
|
||||
# Is it in Yunohost dmomain list?
|
||||
if domain not in yunohost.domain.domain_list(auth)['domains']:
|
||||
raise MoulinetteError(errno.EINVAL, m18n.n(
|
||||
'certmanager_domain_unknown', domain=domain))
|
||||
raise MoulinetteError('certmanager_domain_unknown', domain=domain)
|
||||
|
||||
status = _get_status(domain)
|
||||
|
||||
# Does it expire soon?
|
||||
if status["validity"] > VALIDITY_LIMIT and not force:
|
||||
raise MoulinetteError(errno.EINVAL, m18n.n(
|
||||
'certmanager_attempt_to_renew_valid_cert', domain=domain))
|
||||
raise MoulinetteError('certmanager_attempt_to_renew_valid_cert', domain=domain)
|
||||
|
||||
# Does it have a Let's Encrypt cert?
|
||||
if status["CA_type"]["code"] != "lets-encrypt":
|
||||
raise MoulinetteError(errno.EINVAL, m18n.n(
|
||||
'certmanager_attempt_to_renew_nonLE_cert', domain=domain))
|
||||
raise MoulinetteError('certmanager_attempt_to_renew_nonLE_cert', domain=domain)
|
||||
|
||||
# Check ACME challenge configured for given domain
|
||||
if not _check_acme_challenge_configuration(domain):
|
||||
raise MoulinetteError(errno.EINVAL, m18n.n(
|
||||
'certmanager_acme_not_configured_for_domain', domain=domain))
|
||||
raise MoulinetteError('certmanager_acme_not_configured_for_domain', domain=domain)
|
||||
|
||||
if staging:
|
||||
logger.warning(
|
||||
|
@ -563,19 +555,16 @@ def _fetch_and_enable_new_certificate(domain, staging=False, no_checks=False):
|
|||
CA=certification_authority)
|
||||
except ValueError as e:
|
||||
if "urn:acme:error:rateLimited" in str(e):
|
||||
raise MoulinetteError(errno.EINVAL, m18n.n(
|
||||
'certmanager_hit_rate_limit', domain=domain))
|
||||
raise MoulinetteError('certmanager_hit_rate_limit', domain=domain)
|
||||
else:
|
||||
logger.error(str(e))
|
||||
_display_debug_information(domain)
|
||||
raise MoulinetteError(errno.EINVAL, m18n.n(
|
||||
'certmanager_cert_signing_failed'))
|
||||
raise MoulinetteError('certmanager_cert_signing_failed')
|
||||
|
||||
except Exception as e:
|
||||
logger.error(str(e))
|
||||
|
||||
raise MoulinetteError(errno.EINVAL, m18n.n(
|
||||
'certmanager_cert_signing_failed'))
|
||||
raise MoulinetteError('certmanager_cert_signing_failed')
|
||||
|
||||
import requests # lazy loading this module for performance reasons
|
||||
try:
|
||||
|
@ -624,8 +613,7 @@ def _fetch_and_enable_new_certificate(domain, staging=False, no_checks=False):
|
|||
status_summary = _get_status(domain)["summary"]
|
||||
|
||||
if status_summary["code"] != "great":
|
||||
raise MoulinetteError(errno.EINVAL, m18n.n(
|
||||
'certmanager_certificate_fetching_or_enabling_failed', domain=domain))
|
||||
raise MoulinetteError('certmanager_certificate_fetching_or_enabling_failed', domain=domain)
|
||||
|
||||
|
||||
def _prepare_certificate_signing_request(domain, key_file, output_folder):
|
||||
|
@ -658,8 +646,7 @@ def _get_status(domain):
|
|||
cert_file = os.path.join(CERT_FOLDER, domain, "crt.pem")
|
||||
|
||||
if not os.path.isfile(cert_file):
|
||||
raise MoulinetteError(errno.EINVAL, m18n.n(
|
||||
'certmanager_no_cert_file', domain=domain, file=cert_file))
|
||||
raise MoulinetteError('certmanager_no_cert_file', domain=domain, file=cert_file)
|
||||
|
||||
from OpenSSL import crypto # lazy loading this module for performance reasons
|
||||
try:
|
||||
|
@ -668,8 +655,7 @@ def _get_status(domain):
|
|||
except Exception as exception:
|
||||
import traceback
|
||||
traceback.print_exc(file=sys.stdout)
|
||||
raise MoulinetteError(errno.EINVAL, m18n.n(
|
||||
'certmanager_cannot_read_cert', domain=domain, file=cert_file, reason=exception))
|
||||
raise MoulinetteError('certmanager_cannot_read_cert', domain=domain, file=cert_file, reason=exception)
|
||||
|
||||
cert_subject = cert.get_subject().CN
|
||||
cert_issuer = cert.get_issuer().CN
|
||||
|
@ -830,13 +816,11 @@ def _check_domain_is_ready_for_ACME(domain):
|
|||
|
||||
# Check if IP from DNS matches public IP
|
||||
if not _dns_ip_match_public_ip(public_ip, domain):
|
||||
raise MoulinetteError(errno.EINVAL, m18n.n(
|
||||
'certmanager_domain_dns_ip_differs_from_public_ip', domain=domain))
|
||||
raise MoulinetteError('certmanager_domain_dns_ip_differs_from_public_ip', domain=domain)
|
||||
|
||||
# Check if domain seems to be accessible through HTTP?
|
||||
if not _domain_is_accessible_through_HTTP(public_ip, domain):
|
||||
raise MoulinetteError(errno.EINVAL, m18n.n(
|
||||
'certmanager_domain_http_not_working', domain=domain))
|
||||
raise MoulinetteError('certmanager_domain_http_not_working', domain=domain)
|
||||
|
||||
|
||||
def _get_dns_ip(domain):
|
||||
|
@ -845,8 +829,7 @@ def _get_dns_ip(domain):
|
|||
resolver.nameservers = DNS_RESOLVERS
|
||||
answers = resolver.query(domain, "A")
|
||||
except (dns.resolver.NoAnswer, dns.resolver.NXDOMAIN):
|
||||
raise MoulinetteError(errno.EINVAL, m18n.n(
|
||||
'certmanager_error_no_A_record', domain=domain))
|
||||
raise MoulinetteError('certmanager_error_no_A_record', domain=domain)
|
||||
|
||||
return str(answers[0])
|
||||
|
||||
|
|
|
@ -70,8 +70,8 @@ class MyMigration(Migration):
|
|||
# Migration didn't succeed, so we rollback and raise an exception
|
||||
os.system("mv /etc/yunohost/dyndns/*+165* /tmp")
|
||||
|
||||
raise MoulinetteError(m18n.n('migrate_tsig_failed', domain=domain,
|
||||
error_code=str(r.status_code), error=error))
|
||||
raise MoulinetteError('migrate_tsig_failed', domain=domain,
|
||||
error_code=str(r.status_code), error=error)
|
||||
|
||||
# remove old certificates
|
||||
os.system("mv /etc/yunohost/dyndns/*+157* /tmp")
|
||||
|
|
|
@ -162,8 +162,7 @@ def domain_remove(operation_logger, auth, domain, force=False):
|
|||
continue
|
||||
else:
|
||||
if app_domain == domain:
|
||||
raise MoulinetteError(errno.EPERM,
|
||||
m18n.n('domain_uninstall_app_first'))
|
||||
raise MoulinetteError('domain_uninstall_app_first')
|
||||
|
||||
operation_logger.start()
|
||||
if auth.remove('virtualdomain=' + domain + ',ou=domains') or force:
|
||||
|
|
|
@ -136,8 +136,7 @@ def dyndns_subscribe(operation_logger, subscribe_host="dyndns.yunohost.org", dom
|
|||
|
||||
# Verify if domain is available
|
||||
if not _dyndns_available(subscribe_host, domain):
|
||||
raise MoulinetteError(errno.ENOENT,
|
||||
m18n.n('dyndns_unavailable', domain=domain))
|
||||
raise MoulinetteError('dyndns_unavailable', domain=domain)
|
||||
|
||||
operation_logger.start()
|
||||
|
||||
|
@ -167,8 +166,7 @@ def dyndns_subscribe(operation_logger, subscribe_host="dyndns.yunohost.org", dom
|
|||
error = json.loads(r.text)['error']
|
||||
except:
|
||||
error = "Server error, code: %s. (Message: \"%s\")" % (r.status_code, r.text)
|
||||
raise MoulinetteError(errno.EPERM,
|
||||
m18n.n('dyndns_registration_failed', error=error))
|
||||
raise MoulinetteError('dyndns_registration_failed', error=error)
|
||||
|
||||
logger.success(m18n.n('dyndns_registered'))
|
||||
|
||||
|
@ -302,8 +300,7 @@ def dyndns_update(operation_logger, dyn_host="dyndns.yunohost.org", domain=None,
|
|||
command = ["/usr/bin/nsupdate", "-k", key, DYNDNS_ZONE]
|
||||
subprocess.check_call(command)
|
||||
except subprocess.CalledProcessError:
|
||||
raise MoulinetteError(errno.EPERM,
|
||||
m18n.n('dyndns_ip_update_failed'))
|
||||
raise MoulinetteError('dyndns_ip_update_failed')
|
||||
|
||||
logger.success(m18n.n('dyndns_ip_updated'))
|
||||
|
||||
|
@ -359,5 +356,4 @@ def _guess_current_dyndns_domain(dyn_host):
|
|||
else:
|
||||
return (_domain, path)
|
||||
|
||||
raise MoulinetteError(errno.EINVAL,
|
||||
m18n.n('dyndns_no_domain_registered'))
|
||||
raise MoulinetteError('dyndns_no_domain_registered')
|
||||
|
|
|
@ -384,14 +384,12 @@ def hook_exec(path, args=None, raise_on_error=False, no_trace=False,
|
|||
# Check and return process' return code
|
||||
if returncode is None:
|
||||
if raise_on_error:
|
||||
raise MoulinetteError(
|
||||
errno.EIO, m18n.n('hook_exec_not_terminated', path=path))
|
||||
raise MoulinetteError('hook_exec_not_terminated', path=path)
|
||||
else:
|
||||
logger.error(m18n.n('hook_exec_not_terminated', path=path))
|
||||
return 1
|
||||
elif raise_on_error and returncode != 0:
|
||||
raise MoulinetteError(
|
||||
errno.EIO, m18n.n('hook_exec_failed', path=path))
|
||||
raise MoulinetteError('hook_exec_failed', path=path)
|
||||
return returncode
|
||||
|
||||
|
||||
|
|
|
@ -148,8 +148,7 @@ def log_display(path, number=50, share=False):
|
|||
log_path = base_path + LOG_FILE_EXT
|
||||
|
||||
if not os.path.exists(md_path) and not os.path.exists(log_path):
|
||||
raise MoulinetteError(errno.EINVAL,
|
||||
m18n.n('log_does_exists', log=path))
|
||||
raise MoulinetteError('log_does_exists', log=path)
|
||||
|
||||
infos = {}
|
||||
|
||||
|
|
|
@ -390,11 +390,9 @@ def monitor_show_stats(period, date=None):
|
|||
|
||||
result = _retrieve_stats(period, date)
|
||||
if result is False:
|
||||
raise MoulinetteError(errno.ENOENT,
|
||||
m18n.n('monitor_stats_file_not_found'))
|
||||
raise MoulinetteError('monitor_stats_file_not_found')
|
||||
elif result is None:
|
||||
raise MoulinetteError(errno.EINVAL,
|
||||
m18n.n('monitor_stats_period_unavailable'))
|
||||
raise MoulinetteError('monitor_stats_period_unavailable')
|
||||
return result
|
||||
|
||||
|
||||
|
|
|
@ -83,8 +83,7 @@ def settings_set(key, value):
|
|||
settings = _get_settings()
|
||||
|
||||
if key not in settings:
|
||||
raise MoulinetteError(errno.EINVAL, m18n.n(
|
||||
'global_settings_key_doesnt_exists', settings_key=key))
|
||||
raise MoulinetteError('global_settings_key_doesnt_exists', settings_key=key)
|
||||
|
||||
key_type = settings[key]["type"]
|
||||
|
||||
|
@ -138,8 +137,7 @@ def settings_reset(key):
|
|||
settings = _get_settings()
|
||||
|
||||
if key not in settings:
|
||||
raise MoulinetteError(errno.EINVAL, m18n.n(
|
||||
'global_settings_key_doesnt_exists', settings_key=key))
|
||||
raise MoulinetteError('global_settings_key_doesnt_exists', settings_key=key)
|
||||
|
||||
settings[key]["value"] = settings[key]["default"]
|
||||
_save_settings(settings)
|
||||
|
|
|
@ -406,8 +406,7 @@ def tools_postinstall(operation_logger, domain, password, ignore_dyndns=False,
|
|||
|
||||
if p.returncode != 0:
|
||||
logger.warning(out)
|
||||
raise MoulinetteError(errno.EPERM,
|
||||
m18n.n('yunohost_ca_creation_failed'))
|
||||
raise MoulinetteError('yunohost_ca_creation_failed')
|
||||
else:
|
||||
logger.debug(out)
|
||||
|
||||
|
@ -1070,8 +1069,8 @@ def _load_migration(migration_file):
|
|||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
raise MoulinetteError(errno.EINVAL, m18n.n('migrations_error_failed_to_load_migration',
|
||||
number=number, name=name))
|
||||
raise MoulinetteError('migrations_error_failed_to_load_migration',
|
||||
number=number, name=name)
|
||||
|
||||
def _skip_all_migrations():
|
||||
"""
|
||||
|
|
|
@ -188,8 +188,7 @@ def user_create(operation_logger, auth, username, firstname, lastname, mail, pas
|
|||
with open('/etc/ssowat/conf.json.persistent') as json_conf:
|
||||
ssowat_conf = json.loads(str(json_conf.read()))
|
||||
except ValueError as e:
|
||||
raise MoulinetteError(errno.EINVAL,
|
||||
m18n.n('ssowat_persistent_conf_read_error', error=e.strerror))
|
||||
raise MoulinetteError('ssowat_persistent_conf_read_error', error=e.strerror)
|
||||
except IOError:
|
||||
ssowat_conf = {}
|
||||
|
||||
|
@ -199,8 +198,7 @@ def user_create(operation_logger, auth, username, firstname, lastname, mail, pas
|
|||
with open('/etc/ssowat/conf.json.persistent', 'w+') as f:
|
||||
json.dump(ssowat_conf, f, sort_keys=True, indent=4)
|
||||
except IOError as e:
|
||||
raise MoulinetteError(errno.EPERM,
|
||||
m18n.n('ssowat_persistent_conf_write_error', error=e.strerror))
|
||||
raise MoulinetteError('ssowat_persistent_conf_write_error', error=e.strerror)
|
||||
|
||||
if auth.add('uid=%s,ou=users' % username, attr_dict):
|
||||
# Invalidate passwd to take user creation into account
|
||||
|
@ -355,8 +353,7 @@ def user_update(operation_logger, auth, username, firstname=None, lastname=None,
|
|||
if len(user['mail']) > 1 and mail in user['mail'][1:]:
|
||||
user['mail'].remove(mail)
|
||||
else:
|
||||
raise MoulinetteError(errno.EINVAL,
|
||||
m18n.n('mail_alias_remove_failed', mail=mail))
|
||||
raise MoulinetteError('mail_alias_remove_failed', mail=mail)
|
||||
new_attr_dict['mail'] = user['mail']
|
||||
|
||||
if add_mailforward:
|
||||
|
@ -375,8 +372,7 @@ def user_update(operation_logger, auth, username, firstname=None, lastname=None,
|
|||
if len(user['maildrop']) > 1 and mail in user['maildrop'][1:]:
|
||||
user['maildrop'].remove(mail)
|
||||
else:
|
||||
raise MoulinetteError(errno.EINVAL,
|
||||
m18n.n('mail_forward_remove_failed', mail=mail))
|
||||
raise MoulinetteError('mail_forward_remove_failed', mail=mail)
|
||||
new_attr_dict['maildrop'] = user['maildrop']
|
||||
|
||||
if mailbox_quota is not None:
|
||||
|
|
Loading…
Add table
Reference in a new issue