mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
moulinette MoulinetteError oneline
This commit is contained in:
parent
0179bf2005
commit
f2e184d8b2
15 changed files with 80 additions and 80 deletions
|
@ -212,7 +212,7 @@ def app_removelist(operation_logger, name):
|
||||||
|
|
||||||
# Make sure we know this appslist
|
# Make sure we know this appslist
|
||||||
if name not in appslists.keys():
|
if name not in appslists.keys():
|
||||||
raise MoulinetteError(errno.ENOENT, m18n.n('appslist_unknown', appslist=name))
|
raise MoulinetteError('appslist_unknown', appslist=name)
|
||||||
|
|
||||||
operation_logger.start()
|
operation_logger.start()
|
||||||
|
|
||||||
|
@ -459,7 +459,7 @@ def app_change_url(operation_logger, auth, app, domain, path):
|
||||||
m18n.n('app_not_installed', app=app))
|
m18n.n('app_not_installed', app=app))
|
||||||
|
|
||||||
if not os.path.exists(os.path.join(APPS_SETTING_PATH, app, "scripts", "change_url")):
|
if not os.path.exists(os.path.join(APPS_SETTING_PATH, app, "scripts", "change_url")):
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n("app_change_no_change_url_script", app_name=app))
|
raise MoulinetteError("app_change_no_change_url_script", app_name=app)
|
||||||
|
|
||||||
old_domain = app_setting(app, "domain")
|
old_domain = app_setting(app, "domain")
|
||||||
old_path = app_setting(app, "path")
|
old_path = app_setting(app, "path")
|
||||||
|
@ -471,7 +471,7 @@ def app_change_url(operation_logger, auth, app, domain, path):
|
||||||
path = normalize_url_path(path)
|
path = normalize_url_path(path)
|
||||||
|
|
||||||
if (domain, path) == (old_domain, old_path):
|
if (domain, path) == (old_domain, old_path):
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n("app_change_url_identical_domains", domain=domain, path=path))
|
raise MoulinetteError("app_change_url_identical_domains", domain=domain, path=path)
|
||||||
|
|
||||||
# WARNING / FIXME : checkurl will modify the settings
|
# WARNING / FIXME : checkurl will modify the settings
|
||||||
# (this is a non intuitive behavior that should be changed)
|
# (this is a non intuitive behavior that should be changed)
|
||||||
|
@ -547,7 +547,7 @@ def app_change_url(operation_logger, auth, app, domain, path):
|
||||||
stderr=subprocess.STDOUT,
|
stderr=subprocess.STDOUT,
|
||||||
shell=True).rstrip()
|
shell=True).rstrip()
|
||||||
|
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n("app_change_url_failed_nginx_reload", nginx_errors=nginx_errors))
|
raise MoulinetteError("app_change_url_failed_nginx_reload", nginx_errors=nginx_errors)
|
||||||
|
|
||||||
logger.success(m18n.n("app_change_url_success",
|
logger.success(m18n.n("app_change_url_success",
|
||||||
app=app, domain=domain, path=path))
|
app=app, domain=domain, path=path))
|
||||||
|
@ -573,7 +573,7 @@ def app_upgrade(auth, app=[], url=None, file=None):
|
||||||
try:
|
try:
|
||||||
app_list()
|
app_list()
|
||||||
except MoulinetteError:
|
except MoulinetteError:
|
||||||
raise MoulinetteError(errno.ENODATA, m18n.n('app_no_upgrade'))
|
raise MoulinetteError('app_no_upgrade')
|
||||||
|
|
||||||
upgraded_apps = []
|
upgraded_apps = []
|
||||||
|
|
||||||
|
@ -684,7 +684,7 @@ def app_upgrade(auth, app=[], url=None, file=None):
|
||||||
operation_logger.success()
|
operation_logger.success()
|
||||||
|
|
||||||
if not upgraded_apps:
|
if not upgraded_apps:
|
||||||
raise MoulinetteError(errno.ENODATA, m18n.n('app_no_upgrade'))
|
raise MoulinetteError('app_no_upgrade')
|
||||||
|
|
||||||
app_ssowatconf(auth)
|
app_ssowatconf(auth)
|
||||||
|
|
||||||
|
@ -730,12 +730,12 @@ def app_install(operation_logger, auth, app, label=None, args=None, no_remove_on
|
||||||
elif os.path.exists(app):
|
elif os.path.exists(app):
|
||||||
manifest, extracted_app_folder = _extract_app_from_file(app)
|
manifest, extracted_app_folder = _extract_app_from_file(app)
|
||||||
else:
|
else:
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n('app_unknown'))
|
raise MoulinetteError('app_unknown')
|
||||||
status['remote'] = manifest.get('remote', {})
|
status['remote'] = manifest.get('remote', {})
|
||||||
|
|
||||||
# Check ID
|
# Check ID
|
||||||
if 'id' not in manifest or '__' in manifest['id']:
|
if 'id' not in manifest or '__' in manifest['id']:
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n('app_id_invalid'))
|
raise MoulinetteError('app_id_invalid')
|
||||||
|
|
||||||
app_id = manifest['id']
|
app_id = manifest['id']
|
||||||
|
|
||||||
|
@ -1139,7 +1139,7 @@ def app_makedefault(operation_logger, auth, app, domain=None):
|
||||||
domain = app_domain
|
domain = app_domain
|
||||||
operation_logger.related_to.append(('domain',domain))
|
operation_logger.related_to.append(('domain',domain))
|
||||||
elif domain not in domain_list(auth)['domains']:
|
elif domain not in domain_list(auth)['domains']:
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n('domain_unknown'))
|
raise MoulinetteError('domain_unknown')
|
||||||
|
|
||||||
operation_logger.start()
|
operation_logger.start()
|
||||||
if '/' in app_map(raw=True)[domain]:
|
if '/' in app_map(raw=True)[domain]:
|
||||||
|
@ -1262,7 +1262,7 @@ def app_register_url(auth, app, domain, path):
|
||||||
app_label=app_label,
|
app_label=app_label,
|
||||||
))
|
))
|
||||||
|
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n('app_location_unavailable', apps="\n".join(apps)))
|
raise MoulinetteError('app_location_unavailable', apps="\n".join(apps))
|
||||||
|
|
||||||
app_setting(app, 'domain', value=domain)
|
app_setting(app, 'domain', value=domain)
|
||||||
app_setting(app, 'path', value=path)
|
app_setting(app, 'path', value=path)
|
||||||
|
@ -1300,7 +1300,7 @@ def app_checkurl(auth, url, app=None):
|
||||||
apps_map = app_map(raw=True)
|
apps_map = app_map(raw=True)
|
||||||
|
|
||||||
if domain not in domain_list(auth)['domains']:
|
if domain not in domain_list(auth)['domains']:
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n('domain_unknown'))
|
raise MoulinetteError('domain_unknown')
|
||||||
|
|
||||||
if domain in apps_map:
|
if domain in apps_map:
|
||||||
# Loop through apps
|
# Loop through apps
|
||||||
|
@ -1349,10 +1349,10 @@ def app_initdb(user, password=None, db=None, sql=None):
|
||||||
mysql_root_pwd = open('/etc/yunohost/mysql').read().rstrip()
|
mysql_root_pwd = open('/etc/yunohost/mysql').read().rstrip()
|
||||||
mysql_command = 'mysql -u root -p%s -e "CREATE DATABASE %s ; GRANT ALL PRIVILEGES ON %s.* TO \'%s\'@localhost IDENTIFIED BY \'%s\';"' % (mysql_root_pwd, db, db, user, password)
|
mysql_command = 'mysql -u root -p%s -e "CREATE DATABASE %s ; GRANT ALL PRIVILEGES ON %s.* TO \'%s\'@localhost IDENTIFIED BY \'%s\';"' % (mysql_root_pwd, db, db, user, password)
|
||||||
if os.system(mysql_command) != 0:
|
if os.system(mysql_command) != 0:
|
||||||
raise MoulinetteError(errno.EIO, m18n.n('mysql_db_creation_failed'))
|
raise MoulinetteError('mysql_db_creation_failed')
|
||||||
if sql is not None:
|
if sql is not None:
|
||||||
if os.system('mysql -u %s -p%s %s < %s' % (user, password, db, sql)) != 0:
|
if os.system('mysql -u %s -p%s %s < %s' % (user, password, db, sql)) != 0:
|
||||||
raise MoulinetteError(errno.EIO, m18n.n('mysql_db_init_failed'))
|
raise MoulinetteError('mysql_db_init_failed')
|
||||||
|
|
||||||
if return_pwd:
|
if return_pwd:
|
||||||
return password
|
return password
|
||||||
|
@ -1738,7 +1738,7 @@ def _get_app_status(app_id, format_date=False):
|
||||||
"""
|
"""
|
||||||
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('app_unknown')
|
||||||
status = {}
|
status = {}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -1803,7 +1803,7 @@ def _extract_app_from_file(path, remove=False):
|
||||||
extract_result = 1
|
extract_result = 1
|
||||||
|
|
||||||
if extract_result != 0:
|
if extract_result != 0:
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n('app_extraction_failed'))
|
raise MoulinetteError('app_extraction_failed')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
extracted_app_folder = APP_TMP_FOLDER
|
extracted_app_folder = APP_TMP_FOLDER
|
||||||
|
@ -1814,7 +1814,7 @@ def _extract_app_from_file(path, remove=False):
|
||||||
manifest = json.loads(str(json_manifest.read()))
|
manifest = json.loads(str(json_manifest.read()))
|
||||||
manifest['lastUpdate'] = int(time.time())
|
manifest['lastUpdate'] = int(time.time())
|
||||||
except IOError:
|
except IOError:
|
||||||
raise MoulinetteError(errno.EIO, m18n.n('app_install_files_invalid'))
|
raise MoulinetteError('app_install_files_invalid')
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
raise MoulinetteError(errno.EINVAL,
|
raise MoulinetteError(errno.EINVAL,
|
||||||
m18n.n('app_manifest_invalid', error=e.strerror))
|
m18n.n('app_manifest_invalid', error=e.strerror))
|
||||||
|
@ -1933,7 +1933,7 @@ def _fetch_app_from_git(app):
|
||||||
app_info['manifest']['lastUpdate'] = app_info['lastUpdate']
|
app_info['manifest']['lastUpdate'] = app_info['lastUpdate']
|
||||||
manifest = app_info['manifest']
|
manifest = app_info['manifest']
|
||||||
else:
|
else:
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n('app_unknown'))
|
raise MoulinetteError('app_unknown')
|
||||||
|
|
||||||
if 'git' not in app_info:
|
if 'git' not in app_info:
|
||||||
raise MoulinetteError(errno.EINVAL,
|
raise MoulinetteError(errno.EINVAL,
|
||||||
|
@ -2312,7 +2312,7 @@ def _parse_action_args_in_yunohost_format(args, action_args, auth=None):
|
||||||
app_label=app_label,
|
app_label=app_label,
|
||||||
))
|
))
|
||||||
|
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n('app_location_unavailable', apps="\n".join(apps)))
|
raise MoulinetteError('app_location_unavailable', apps="\n".join(apps))
|
||||||
|
|
||||||
# (We save this normalized path so that the install script have a
|
# (We save this normalized path so that the install script have a
|
||||||
# standard path format to deal with no matter what the user inputted)
|
# standard path format to deal with no matter what the user inputted)
|
||||||
|
|
|
@ -507,7 +507,7 @@ class BackupManager():
|
||||||
|
|
||||||
if not successfull_apps and not successfull_system:
|
if not successfull_apps and not successfull_system:
|
||||||
filesystem.rm(self.work_dir, True, True)
|
filesystem.rm(self.work_dir, True, True)
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n('backup_nothings_done'))
|
raise MoulinetteError('backup_nothings_done')
|
||||||
|
|
||||||
# Add unlisted files from backup tmp dir
|
# Add unlisted files from backup tmp dir
|
||||||
self._add_to_list_to_backup('backup.csv')
|
self._add_to_list_to_backup('backup.csv')
|
||||||
|
@ -857,7 +857,7 @@ class RestoreManager():
|
||||||
self.info["system"] = self.info["hooks"]
|
self.info["system"] = self.info["hooks"]
|
||||||
except IOError:
|
except IOError:
|
||||||
logger.debug("unable to load '%s'", info_file, exc_info=1)
|
logger.debug("unable to load '%s'", info_file, exc_info=1)
|
||||||
raise MoulinetteError(errno.EIO, m18n.n('backup_invalid_archive'))
|
raise MoulinetteError('backup_invalid_archive')
|
||||||
else:
|
else:
|
||||||
logger.debug("restoring from backup '%s' created on %s", self.name,
|
logger.debug("restoring from backup '%s' created on %s", self.name,
|
||||||
datetime.utcfromtimestamp(self.info['created_at']))
|
datetime.utcfromtimestamp(self.info['created_at']))
|
||||||
|
@ -1442,7 +1442,7 @@ class BackupMethod(object):
|
||||||
@property
|
@property
|
||||||
def method_name(self):
|
def method_name(self):
|
||||||
"""Return the string name of a BackupMethod (eg "tar" or "copy")"""
|
"""Return the string name of a BackupMethod (eg "tar" or "copy")"""
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n('backup_abstract_method'))
|
raise MoulinetteError('backup_abstract_method')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
|
@ -2132,7 +2132,7 @@ def backup_restore(auth, name, system=[], apps=[], force=False):
|
||||||
if i == 'y' or i == 'Y':
|
if i == 'y' or i == 'Y':
|
||||||
force = True
|
force = True
|
||||||
if not force:
|
if not force:
|
||||||
raise MoulinetteError(errno.EEXIST, m18n.n('restore_failed'))
|
raise MoulinetteError('restore_failed')
|
||||||
|
|
||||||
# TODO Partial app restore could not work if ldap is not restored before
|
# TODO Partial app restore could not work if ldap is not restored before
|
||||||
# TODO repair mysql if broken and it's a complete restore
|
# TODO repair mysql if broken and it's a complete restore
|
||||||
|
@ -2159,7 +2159,7 @@ def backup_restore(auth, name, system=[], apps=[], force=False):
|
||||||
if restore_manager.success:
|
if restore_manager.success:
|
||||||
logger.success(m18n.n('restore_complete'))
|
logger.success(m18n.n('restore_complete'))
|
||||||
else:
|
else:
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n('restore_nothings_done'))
|
raise MoulinetteError('restore_nothings_done')
|
||||||
|
|
||||||
return restore_manager.targets.results
|
return restore_manager.targets.results
|
||||||
|
|
||||||
|
@ -2240,7 +2240,7 @@ def backup_info(name, with_details=False, human_readable=False):
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.debug("unable to retrieve '%s' inside the archive",
|
logger.debug("unable to retrieve '%s' inside the archive",
|
||||||
info_file, exc_info=1)
|
info_file, exc_info=1)
|
||||||
raise MoulinetteError(errno.EIO, m18n.n('backup_invalid_archive'))
|
raise MoulinetteError('backup_invalid_archive')
|
||||||
else:
|
else:
|
||||||
shutil.move(os.path.join(info_dir, 'info.json'), info_file)
|
shutil.move(os.path.join(info_dir, 'info.json'), info_file)
|
||||||
finally:
|
finally:
|
||||||
|
@ -2253,7 +2253,7 @@ def backup_info(name, with_details=False, human_readable=False):
|
||||||
info = json.load(f)
|
info = json.load(f)
|
||||||
except:
|
except:
|
||||||
logger.debug("unable to load '%s'", info_file, exc_info=1)
|
logger.debug("unable to load '%s'", info_file, exc_info=1)
|
||||||
raise MoulinetteError(errno.EIO, m18n.n('backup_invalid_archive'))
|
raise MoulinetteError('backup_invalid_archive')
|
||||||
|
|
||||||
# Retrieve backup size
|
# Retrieve backup size
|
||||||
size = info.get('size', 0)
|
size = info.get('size', 0)
|
||||||
|
|
|
@ -581,7 +581,7 @@ def _fetch_and_enable_new_certificate(domain, staging=False, no_checks=False):
|
||||||
try:
|
try:
|
||||||
intermediate_certificate = requests.get(INTERMEDIATE_CERTIFICATE_URL, timeout=30).text
|
intermediate_certificate = requests.get(INTERMEDIATE_CERTIFICATE_URL, timeout=30).text
|
||||||
except requests.exceptions.Timeout as e:
|
except requests.exceptions.Timeout as e:
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n('certmanager_couldnt_fetch_intermediate_cert'))
|
raise MoulinetteError('certmanager_couldnt_fetch_intermediate_cert')
|
||||||
|
|
||||||
# Now save the key and signed certificate
|
# Now save the key and signed certificate
|
||||||
logger.debug("Saving the key and signed certificate...")
|
logger.debug("Saving the key and signed certificate...")
|
||||||
|
|
|
@ -52,7 +52,7 @@ class MyMigration(Migration):
|
||||||
'public_key_sha512': base64.b64encode(public_key_sha512),
|
'public_key_sha512': base64.b64encode(public_key_sha512),
|
||||||
}, timeout=30)
|
}, timeout=30)
|
||||||
except requests.ConnectionError:
|
except requests.ConnectionError:
|
||||||
raise MoulinetteError(errno.ENETUNREACH, m18n.n('no_internet_connection'))
|
raise MoulinetteError('no_internet_connection')
|
||||||
|
|
||||||
if r.status_code != 201:
|
if r.status_code != 201:
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -30,7 +30,7 @@ class MyMigration(Migration):
|
||||||
|
|
||||||
def backward(self):
|
def backward(self):
|
||||||
|
|
||||||
raise MoulinetteError(m18n.n("migration_0003_backward_impossible"))
|
raise MoulinetteError("migration_0003_backward_impossible")
|
||||||
|
|
||||||
def migrate(self):
|
def migrate(self):
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ class MyMigration(Migration):
|
||||||
self.apt_dist_upgrade(conf_flags=["old", "miss", "def"])
|
self.apt_dist_upgrade(conf_flags=["old", "miss", "def"])
|
||||||
_run_service_command("start", "mysql")
|
_run_service_command("start", "mysql")
|
||||||
if self.debian_major_version() == 8:
|
if self.debian_major_version() == 8:
|
||||||
raise MoulinetteError(m18n.n("migration_0003_still_on_jessie_after_main_upgrade", log=self.logfile))
|
raise MoulinetteError("migration_0003_still_on_jessie_after_main_upgrade", log=self.logfile)
|
||||||
|
|
||||||
# Specific upgrade for fail2ban...
|
# Specific upgrade for fail2ban...
|
||||||
logger.info(m18n.n("migration_0003_fail2ban_upgrade"))
|
logger.info(m18n.n("migration_0003_fail2ban_upgrade"))
|
||||||
|
@ -107,11 +107,11 @@ class MyMigration(Migration):
|
||||||
# would still be in 2.x...
|
# would still be in 2.x...
|
||||||
if not self.debian_major_version() == 8 \
|
if not self.debian_major_version() == 8 \
|
||||||
and not self.yunohost_major_version() == 2:
|
and not self.yunohost_major_version() == 2:
|
||||||
raise MoulinetteError(m18n.n("migration_0003_not_jessie"))
|
raise MoulinetteError("migration_0003_not_jessie")
|
||||||
|
|
||||||
# Have > 1 Go free space on /var/ ?
|
# Have > 1 Go free space on /var/ ?
|
||||||
if free_space_in_directory("/var/") / (1024**3) < 1.0:
|
if free_space_in_directory("/var/") / (1024**3) < 1.0:
|
||||||
raise MoulinetteError(m18n.n("migration_0003_not_enough_free_space"))
|
raise MoulinetteError("migration_0003_not_enough_free_space")
|
||||||
|
|
||||||
# Check system is up to date
|
# Check system is up to date
|
||||||
# (but we don't if 'stretch' is already in the sources.list ...
|
# (but we don't if 'stretch' is already in the sources.list ...
|
||||||
|
@ -120,7 +120,7 @@ class MyMigration(Migration):
|
||||||
self.apt_update()
|
self.apt_update()
|
||||||
apt_list_upgradable = check_output("apt list --upgradable -a")
|
apt_list_upgradable = check_output("apt list --upgradable -a")
|
||||||
if "upgradable" in apt_list_upgradable:
|
if "upgradable" in apt_list_upgradable:
|
||||||
raise MoulinetteError(m18n.n("migration_0003_system_not_fully_up_to_date"))
|
raise MoulinetteError("migration_0003_system_not_fully_up_to_date")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def disclaimer(self):
|
def disclaimer(self):
|
||||||
|
|
|
@ -20,10 +20,10 @@ class MyMigration(Migration):
|
||||||
return
|
return
|
||||||
|
|
||||||
if not self.package_is_installed("postgresql-9.6"):
|
if not self.package_is_installed("postgresql-9.6"):
|
||||||
raise MoulinetteError(m18n.n("migration_0005_postgresql_96_not_installed"))
|
raise MoulinetteError("migration_0005_postgresql_96_not_installed")
|
||||||
|
|
||||||
if not space_used_by_directory("/var/lib/postgresql/9.4") > free_space_in_directory("/var/lib/postgresql"):
|
if not space_used_by_directory("/var/lib/postgresql/9.4") > free_space_in_directory("/var/lib/postgresql"):
|
||||||
raise MoulinetteError(m18n.n("migration_0005_not_enough_space", path="/var/lib/postgresql/"))
|
raise MoulinetteError("migration_0005_not_enough_space", path="/var/lib/postgresql/")
|
||||||
|
|
||||||
subprocess.check_call("service postgresql stop", shell=True)
|
subprocess.check_call("service postgresql stop", shell=True)
|
||||||
subprocess.check_call("pg_dropcluster --stop 9.6 main", shell=True)
|
subprocess.check_call("pg_dropcluster --stop 9.6 main", shell=True)
|
||||||
|
|
|
@ -78,7 +78,7 @@ def domain_add(operation_logger, auth, domain, dyndns=False):
|
||||||
try:
|
try:
|
||||||
auth.validate_uniqueness({'virtualdomain': domain})
|
auth.validate_uniqueness({'virtualdomain': domain})
|
||||||
except MoulinetteError:
|
except MoulinetteError:
|
||||||
raise MoulinetteError(errno.EEXIST, m18n.n('domain_exists'))
|
raise MoulinetteError('domain_exists')
|
||||||
|
|
||||||
operation_logger.start()
|
operation_logger.start()
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ def domain_add(operation_logger, auth, domain, dyndns=False):
|
||||||
}
|
}
|
||||||
|
|
||||||
if not auth.add('virtualdomain=%s,ou=domains' % domain, attr_dict):
|
if not auth.add('virtualdomain=%s,ou=domains' % domain, attr_dict):
|
||||||
raise MoulinetteError(errno.EIO, m18n.n('domain_creation_failed'))
|
raise MoulinetteError('domain_creation_failed')
|
||||||
|
|
||||||
# Don't regen these conf if we're still in postinstall
|
# Don't regen these conf if we're still in postinstall
|
||||||
if os.path.exists('/etc/yunohost/installed'):
|
if os.path.exists('/etc/yunohost/installed'):
|
||||||
|
@ -147,11 +147,11 @@ def domain_remove(operation_logger, auth, domain, force=False):
|
||||||
from yunohost.app import app_ssowatconf
|
from yunohost.app import app_ssowatconf
|
||||||
|
|
||||||
if not force and domain not in domain_list(auth)['domains']:
|
if not force and domain not in domain_list(auth)['domains']:
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n('domain_unknown'))
|
raise MoulinetteError('domain_unknown')
|
||||||
|
|
||||||
# Check domain is not the main domain
|
# Check domain is not the main domain
|
||||||
if domain == _get_maindomain():
|
if domain == _get_maindomain():
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n('domain_cannot_remove_main'))
|
raise MoulinetteError('domain_cannot_remove_main')
|
||||||
|
|
||||||
# Check if apps are installed on the domain
|
# Check if apps are installed on the domain
|
||||||
for app in os.listdir('/etc/yunohost/apps/'):
|
for app in os.listdir('/etc/yunohost/apps/'):
|
||||||
|
@ -169,7 +169,7 @@ def domain_remove(operation_logger, auth, domain, force=False):
|
||||||
if auth.remove('virtualdomain=' + domain + ',ou=domains') or force:
|
if auth.remove('virtualdomain=' + domain + ',ou=domains') or force:
|
||||||
os.system('rm -rf /etc/yunohost/certs/%s' % domain)
|
os.system('rm -rf /etc/yunohost/certs/%s' % domain)
|
||||||
else:
|
else:
|
||||||
raise MoulinetteError(errno.EIO, m18n.n('domain_deletion_failed'))
|
raise MoulinetteError('domain_deletion_failed')
|
||||||
|
|
||||||
service_regen_conf(names=['nginx', 'metronome', 'dnsmasq', 'postfix'])
|
service_regen_conf(names=['nginx', 'metronome', 'dnsmasq', 'postfix'])
|
||||||
app_ssowatconf(auth)
|
app_ssowatconf(auth)
|
||||||
|
@ -246,7 +246,7 @@ def _get_conflicting_apps(auth, domain, path):
|
||||||
|
|
||||||
# Abort if domain is unknown
|
# Abort if domain is unknown
|
||||||
if domain not in domain_list(auth)['domains']:
|
if domain not in domain_list(auth)['domains']:
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n('domain_unknown'))
|
raise MoulinetteError('domain_unknown')
|
||||||
|
|
||||||
# This import cannot be put on top of file because it would create a
|
# This import cannot be put on top of file because it would create a
|
||||||
# recursive import...
|
# recursive import...
|
||||||
|
|
|
@ -161,7 +161,7 @@ def dyndns_subscribe(operation_logger, subscribe_host="dyndns.yunohost.org", dom
|
||||||
try:
|
try:
|
||||||
r = requests.post('https://%s/key/%s?key_algo=hmac-sha512' % (subscribe_host, base64.b64encode(key)), data={'subdomain': domain}, timeout=30)
|
r = requests.post('https://%s/key/%s?key_algo=hmac-sha512' % (subscribe_host, base64.b64encode(key)), data={'subdomain': domain}, timeout=30)
|
||||||
except requests.ConnectionError:
|
except requests.ConnectionError:
|
||||||
raise MoulinetteError(errno.ENETUNREACH, m18n.n('no_internet_connection'))
|
raise MoulinetteError('no_internet_connection')
|
||||||
if r.status_code != 201:
|
if r.status_code != 201:
|
||||||
try:
|
try:
|
||||||
error = json.loads(r.text)['error']
|
error = json.loads(r.text)['error']
|
||||||
|
@ -202,7 +202,7 @@ def dyndns_update(operation_logger, dyn_host="dyndns.yunohost.org", domain=None,
|
||||||
keys = glob.glob('/etc/yunohost/dyndns/K{0}.+*.private'.format(domain))
|
keys = glob.glob('/etc/yunohost/dyndns/K{0}.+*.private'.format(domain))
|
||||||
|
|
||||||
if not keys:
|
if not keys:
|
||||||
raise MoulinetteError(errno.EIO, m18n.n('dyndns_key_not_found'))
|
raise MoulinetteError('dyndns_key_not_found')
|
||||||
|
|
||||||
key = keys[0]
|
key = keys[0]
|
||||||
|
|
||||||
|
@ -329,7 +329,7 @@ def dyndns_removecron():
|
||||||
try:
|
try:
|
||||||
os.remove("/etc/cron.d/yunohost-dyndns")
|
os.remove("/etc/cron.d/yunohost-dyndns")
|
||||||
except:
|
except:
|
||||||
raise MoulinetteError(errno.EIO, m18n.n('dyndns_cron_remove_failed'))
|
raise MoulinetteError('dyndns_cron_remove_failed')
|
||||||
|
|
||||||
logger.success(m18n.n('dyndns_cron_removed'))
|
logger.success(m18n.n('dyndns_cron_removed'))
|
||||||
|
|
||||||
|
|
|
@ -268,7 +268,7 @@ def firewall_reload(skip_upnp=False):
|
||||||
reloaded = True
|
reloaded = True
|
||||||
|
|
||||||
if not reloaded:
|
if not reloaded:
|
||||||
raise MoulinetteError(errno.ESRCH, m18n.n('firewall_reload_failed'))
|
raise MoulinetteError('firewall_reload_failed')
|
||||||
|
|
||||||
hook_callback('post_iptable_rules',
|
hook_callback('post_iptable_rules',
|
||||||
args=[upnp, os.path.exists("/proc/net/if_inet6")])
|
args=[upnp, os.path.exists("/proc/net/if_inet6")])
|
||||||
|
@ -338,7 +338,7 @@ def firewall_upnp(action='status', no_refresh=False):
|
||||||
if action == 'status':
|
if action == 'status':
|
||||||
no_refresh = True
|
no_refresh = True
|
||||||
else:
|
else:
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n('action_invalid', action=action))
|
raise MoulinetteError('action_invalid', action=action)
|
||||||
|
|
||||||
# Refresh port mapping using UPnP
|
# Refresh port mapping using UPnP
|
||||||
if not no_refresh:
|
if not no_refresh:
|
||||||
|
@ -407,7 +407,7 @@ def firewall_upnp(action='status', no_refresh=False):
|
||||||
firewall_reload(skip_upnp=True)
|
firewall_reload(skip_upnp=True)
|
||||||
|
|
||||||
if action == 'enable' and not enabled:
|
if action == 'enable' and not enabled:
|
||||||
raise MoulinetteError(errno.ENXIO, m18n.n('upnp_port_open_failed'))
|
raise MoulinetteError('upnp_port_open_failed')
|
||||||
return {'enabled': enabled}
|
return {'enabled': enabled}
|
||||||
|
|
||||||
|
|
||||||
|
@ -419,7 +419,7 @@ def firewall_stop():
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if os.system("iptables -w -P INPUT ACCEPT") != 0:
|
if os.system("iptables -w -P INPUT ACCEPT") != 0:
|
||||||
raise MoulinetteError(errno.ESRCH, m18n.n('iptables_unavailable'))
|
raise MoulinetteError('iptables_unavailable')
|
||||||
|
|
||||||
os.system("iptables -w -F")
|
os.system("iptables -w -F")
|
||||||
os.system("iptables -w -X")
|
os.system("iptables -w -X")
|
||||||
|
|
|
@ -112,7 +112,7 @@ def hook_info(action, name):
|
||||||
})
|
})
|
||||||
|
|
||||||
if not hooks:
|
if not hooks:
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n('hook_name_unknown', name=name))
|
raise MoulinetteError('hook_name_unknown', name=name)
|
||||||
return {
|
return {
|
||||||
'action': action,
|
'action': action,
|
||||||
'name': name,
|
'name': name,
|
||||||
|
@ -174,7 +174,7 @@ def hook_list(action, list_by='name', show_info=False):
|
||||||
# Add only the name
|
# Add only the name
|
||||||
d.add(name)
|
d.add(name)
|
||||||
else:
|
else:
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n('hook_list_by_invalid'))
|
raise MoulinetteError('hook_list_by_invalid')
|
||||||
|
|
||||||
def _append_folder(d, folder):
|
def _append_folder(d, folder):
|
||||||
# Iterate over and add hook from a folder
|
# Iterate over and add hook from a folder
|
||||||
|
|
|
@ -83,7 +83,7 @@ def monitor_disk(units=None, mountpoint=None, human_readable=False):
|
||||||
result_dname = dn
|
result_dname = dn
|
||||||
if len(devices) == 0:
|
if len(devices) == 0:
|
||||||
if mountpoint is not None:
|
if mountpoint is not None:
|
||||||
raise MoulinetteError(errno.ENODEV, m18n.n('mountpoint_unknown'))
|
raise MoulinetteError('mountpoint_unknown')
|
||||||
return result
|
return result
|
||||||
|
|
||||||
# Retrieve monitoring for unit(s)
|
# Retrieve monitoring for unit(s)
|
||||||
|
@ -141,7 +141,7 @@ def monitor_disk(units=None, mountpoint=None, human_readable=False):
|
||||||
for dname in devices_names:
|
for dname in devices_names:
|
||||||
_set(dname, 'not-available')
|
_set(dname, 'not-available')
|
||||||
else:
|
else:
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n('unit_unknown', unit=u))
|
raise MoulinetteError('unit_unknown', unit=u)
|
||||||
|
|
||||||
if result_dname is not None:
|
if result_dname is not None:
|
||||||
return result[result_dname]
|
return result[result_dname]
|
||||||
|
@ -237,7 +237,7 @@ def monitor_network(units=None, human_readable=False):
|
||||||
'gateway': gateway,
|
'gateway': gateway,
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n('unit_unknown', unit=u))
|
raise MoulinetteError('unit_unknown', unit=u)
|
||||||
|
|
||||||
if len(units) == 1:
|
if len(units) == 1:
|
||||||
return result[units[0]]
|
return result[units[0]]
|
||||||
|
@ -287,7 +287,7 @@ def monitor_system(units=None, human_readable=False):
|
||||||
elif u == 'infos':
|
elif u == 'infos':
|
||||||
result[u] = json.loads(glances.getSystem())
|
result[u] = json.loads(glances.getSystem())
|
||||||
else:
|
else:
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n('unit_unknown', unit=u))
|
raise MoulinetteError('unit_unknown', unit=u)
|
||||||
|
|
||||||
if len(units) == 1 and type(result[units[0]]) is not str:
|
if len(units) == 1 and type(result[units[0]]) is not str:
|
||||||
return result[units[0]]
|
return result[units[0]]
|
||||||
|
@ -303,7 +303,7 @@ def monitor_update_stats(period):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if period not in ['day', 'week', 'month']:
|
if period not in ['day', 'week', 'month']:
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n('monitor_period_invalid'))
|
raise MoulinetteError('monitor_period_invalid')
|
||||||
|
|
||||||
stats = _retrieve_stats(period)
|
stats = _retrieve_stats(period)
|
||||||
if not stats:
|
if not stats:
|
||||||
|
@ -321,7 +321,7 @@ def monitor_update_stats(period):
|
||||||
else:
|
else:
|
||||||
monitor = _monitor_all(p, 0)
|
monitor = _monitor_all(p, 0)
|
||||||
if not monitor:
|
if not monitor:
|
||||||
raise MoulinetteError(errno.ENODATA, m18n.n('monitor_stats_no_update'))
|
raise MoulinetteError('monitor_stats_no_update')
|
||||||
|
|
||||||
stats['timestamp'].append(time.time())
|
stats['timestamp'].append(time.time())
|
||||||
|
|
||||||
|
@ -386,7 +386,7 @@ def monitor_show_stats(period, date=None):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if period not in ['day', 'week', 'month']:
|
if period not in ['day', 'week', 'month']:
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n('monitor_period_invalid'))
|
raise MoulinetteError('monitor_period_invalid')
|
||||||
|
|
||||||
result = _retrieve_stats(period, date)
|
result = _retrieve_stats(period, date)
|
||||||
if result is False:
|
if result is False:
|
||||||
|
@ -470,8 +470,8 @@ def _get_glances_api():
|
||||||
from yunohost.service import service_status
|
from yunohost.service import service_status
|
||||||
|
|
||||||
if service_status('glances')['status'] != 'running':
|
if service_status('glances')['status'] != 'running':
|
||||||
raise MoulinetteError(errno.EPERM, m18n.n('monitor_not_enabled'))
|
raise MoulinetteError('monitor_not_enabled')
|
||||||
raise MoulinetteError(errno.EIO, m18n.n('monitor_glances_con_failed'))
|
raise MoulinetteError('monitor_glances_con_failed')
|
||||||
|
|
||||||
|
|
||||||
def _extract_inet(string, skip_netmask=False, skip_loopback=True):
|
def _extract_inet(string, skip_netmask=False, skip_loopback=True):
|
||||||
|
|
|
@ -85,7 +85,7 @@ def service_add(name, status=None, log=None, runlevel=None, need_lock=False, des
|
||||||
_save_services(services)
|
_save_services(services)
|
||||||
except:
|
except:
|
||||||
# we'll get a logger.warning with more details in _save_services
|
# we'll get a logger.warning with more details in _save_services
|
||||||
raise MoulinetteError(errno.EIO, m18n.n('service_add_failed', service=name))
|
raise MoulinetteError('service_add_failed', service=name)
|
||||||
|
|
||||||
logger.success(m18n.n('service_added', service=name))
|
logger.success(m18n.n('service_added', service=name))
|
||||||
|
|
||||||
|
@ -103,13 +103,13 @@ def service_remove(name):
|
||||||
try:
|
try:
|
||||||
del services[name]
|
del services[name]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n('service_unknown', service=name))
|
raise MoulinetteError('service_unknown', service=name)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
_save_services(services)
|
_save_services(services)
|
||||||
except:
|
except:
|
||||||
# we'll get a logger.warning with more details in _save_services
|
# we'll get a logger.warning with more details in _save_services
|
||||||
raise MoulinetteError(errno.EIO, m18n.n('service_remove_failed', service=name))
|
raise MoulinetteError('service_remove_failed', service=name)
|
||||||
|
|
||||||
logger.success(m18n.n('service_removed', service=name))
|
logger.success(m18n.n('service_removed', service=name))
|
||||||
|
|
||||||
|
@ -320,10 +320,10 @@ def service_log(name, number=50):
|
||||||
services = _get_services()
|
services = _get_services()
|
||||||
|
|
||||||
if name not in services.keys():
|
if name not in services.keys():
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n('service_unknown', service=name))
|
raise MoulinetteError('service_unknown', service=name)
|
||||||
|
|
||||||
if 'log' not in services[name]:
|
if 'log' not in services[name]:
|
||||||
raise MoulinetteError(errno.EPERM, m18n.n('service_no_log', service=name))
|
raise MoulinetteError('service_no_log', service=name)
|
||||||
|
|
||||||
log_list = services[name]['log']
|
log_list = services[name]['log']
|
||||||
|
|
||||||
|
@ -609,7 +609,7 @@ def _run_service_command(action, service):
|
||||||
"""
|
"""
|
||||||
services = _get_services()
|
services = _get_services()
|
||||||
if service not in services.keys():
|
if service not in services.keys():
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n('service_unknown', service=service))
|
raise MoulinetteError('service_unknown', service=service)
|
||||||
|
|
||||||
possible_actions = ['start', 'stop', 'restart', 'reload', 'enable', 'disable']
|
possible_actions = ['start', 'stop', 'restart', 'reload', 'enable', 'disable']
|
||||||
if action not in possible_actions:
|
if action not in possible_actions:
|
||||||
|
|
|
@ -23,7 +23,7 @@ def user_ssh_allow(auth, username):
|
||||||
# TODO it would be good to support different kind of shells
|
# TODO it would be good to support different kind of shells
|
||||||
|
|
||||||
if not _get_user_for_ssh(auth, username):
|
if not _get_user_for_ssh(auth, username):
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n('user_unknown', user=username))
|
raise MoulinetteError('user_unknown', user=username)
|
||||||
|
|
||||||
auth.update('uid=%s,ou=users' % username, {'loginShell': '/bin/bash'})
|
auth.update('uid=%s,ou=users' % username, {'loginShell': '/bin/bash'})
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ def user_ssh_disallow(auth, username):
|
||||||
# TODO it would be good to support different kind of shells
|
# TODO it would be good to support different kind of shells
|
||||||
|
|
||||||
if not _get_user_for_ssh(auth, username):
|
if not _get_user_for_ssh(auth, username):
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n('user_unknown', user=username))
|
raise MoulinetteError('user_unknown', user=username)
|
||||||
|
|
||||||
auth.update('uid=%s,ou=users' % username, {'loginShell': '/bin/false'})
|
auth.update('uid=%s,ou=users' % username, {'loginShell': '/bin/false'})
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,7 @@ def tools_ldapinit():
|
||||||
pwd.getpwnam("admin")
|
pwd.getpwnam("admin")
|
||||||
except KeyError:
|
except KeyError:
|
||||||
logger.error(m18n.n('ldap_init_failed_to_create_admin'))
|
logger.error(m18n.n('ldap_init_failed_to_create_admin'))
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n('installation_failed'))
|
raise MoulinetteError('installation_failed')
|
||||||
|
|
||||||
logger.success(m18n.n('ldap_initialized'))
|
logger.success(m18n.n('ldap_initialized'))
|
||||||
return auth
|
return auth
|
||||||
|
@ -176,7 +176,7 @@ def tools_maindomain(operation_logger, auth, new_domain=None):
|
||||||
|
|
||||||
# Check domain exists
|
# Check domain exists
|
||||||
if new_domain not in domain_list(auth)['domains']:
|
if new_domain not in domain_list(auth)['domains']:
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n('domain_unknown'))
|
raise MoulinetteError('domain_unknown')
|
||||||
|
|
||||||
operation_logger.related_to.append(('domain', new_domain))
|
operation_logger.related_to.append(('domain', new_domain))
|
||||||
operation_logger.start()
|
operation_logger.start()
|
||||||
|
@ -199,7 +199,7 @@ def tools_maindomain(operation_logger, auth, new_domain=None):
|
||||||
_set_maindomain(new_domain)
|
_set_maindomain(new_domain)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning("%s" % e, exc_info=1)
|
logger.warning("%s" % e, exc_info=1)
|
||||||
raise MoulinetteError(errno.EPERM, m18n.n('maindomain_change_failed'))
|
raise MoulinetteError('maindomain_change_failed')
|
||||||
|
|
||||||
_set_hostname(new_domain)
|
_set_hostname(new_domain)
|
||||||
|
|
||||||
|
@ -248,7 +248,7 @@ def _set_hostname(hostname, pretty_hostname=None):
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
logger.warning(command)
|
logger.warning(command)
|
||||||
logger.warning(out)
|
logger.warning(out)
|
||||||
raise MoulinetteError(errno.EIO, m18n.n('domain_hostname_failed'))
|
raise MoulinetteError('domain_hostname_failed')
|
||||||
else:
|
else:
|
||||||
logger.debug(out)
|
logger.debug(out)
|
||||||
|
|
||||||
|
@ -483,7 +483,7 @@ def tools_update(ignore_apps=False, ignore_packages=False):
|
||||||
# Update APT cache
|
# Update APT cache
|
||||||
logger.debug(m18n.n('updating_apt_cache'))
|
logger.debug(m18n.n('updating_apt_cache'))
|
||||||
if not cache.update():
|
if not cache.update():
|
||||||
raise MoulinetteError(errno.EPERM, m18n.n('update_cache_failed'))
|
raise MoulinetteError('update_cache_failed')
|
||||||
|
|
||||||
cache.open(None)
|
cache.open(None)
|
||||||
cache.upgrade(True)
|
cache.upgrade(True)
|
||||||
|
@ -807,7 +807,7 @@ def tools_migrations_list(pending=False, done=False):
|
||||||
|
|
||||||
# Check for option conflict
|
# Check for option conflict
|
||||||
if pending and done:
|
if pending and done:
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n("migrations_list_conflict_pending_done"))
|
raise MoulinetteError("migrations_list_conflict_pending_done")
|
||||||
|
|
||||||
# Get all migrations
|
# Get all migrations
|
||||||
migrations = _get_migrations_list()
|
migrations = _get_migrations_list()
|
||||||
|
@ -864,7 +864,7 @@ def tools_migrations_migrate(target=None, skip=False, auto=False, accept_disclai
|
||||||
|
|
||||||
# validate input, target must be "0" or a valid number
|
# validate input, target must be "0" or a valid number
|
||||||
elif target != 0 and target not in all_migration_numbers:
|
elif target != 0 and target not in all_migration_numbers:
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n('migrations_bad_value_for_target', ", ".join(map(str, all_migration_numbers))))
|
raise MoulinetteError('migrations_bad_value_for_target', ", ".join(map(str, all_migration_numbers)))
|
||||||
|
|
||||||
logger.debug(m18n.n('migrations_current_target', target))
|
logger.debug(m18n.n('migrations_current_target', target))
|
||||||
|
|
||||||
|
|
|
@ -130,7 +130,7 @@ def user_create(operation_logger, auth, username, firstname, lastname, mail, pas
|
||||||
# Validate uniqueness of username in system users
|
# Validate uniqueness of username in system users
|
||||||
all_existing_usernames = {x.pw_name for x in pwd.getpwall()}
|
all_existing_usernames = {x.pw_name for x in pwd.getpwall()}
|
||||||
if username in all_existing_usernames:
|
if username in all_existing_usernames:
|
||||||
raise MoulinetteError(errno.EEXIST, m18n.n('system_username_exists'))
|
raise MoulinetteError('system_username_exists')
|
||||||
|
|
||||||
main_domain = _get_maindomain()
|
main_domain = _get_maindomain()
|
||||||
aliases = [
|
aliases = [
|
||||||
|
@ -226,7 +226,7 @@ def user_create(operation_logger, auth, username, firstname, lastname, mail, pas
|
||||||
|
|
||||||
return {'fullname': fullname, 'username': username, 'mail': mail}
|
return {'fullname': fullname, 'username': username, 'mail': mail}
|
||||||
|
|
||||||
raise MoulinetteError(169, m18n.n('user_creation_failed'))
|
raise MoulinetteError('user_creation_failed')
|
||||||
|
|
||||||
|
|
||||||
@is_unit_operation([('username', 'user')])
|
@is_unit_operation([('username', 'user')])
|
||||||
|
@ -257,7 +257,7 @@ def user_delete(operation_logger, auth, username, purge=False):
|
||||||
if purge:
|
if purge:
|
||||||
subprocess.call(['rm', '-rf', '/home/{0}'.format(username)])
|
subprocess.call(['rm', '-rf', '/home/{0}'.format(username)])
|
||||||
else:
|
else:
|
||||||
raise MoulinetteError(169, m18n.n('user_deletion_failed'))
|
raise MoulinetteError('user_deletion_failed')
|
||||||
|
|
||||||
app_ssowatconf(auth)
|
app_ssowatconf(auth)
|
||||||
|
|
||||||
|
@ -296,7 +296,7 @@ def user_update(operation_logger, auth, username, firstname=None, lastname=None,
|
||||||
# Populate user informations
|
# Populate user informations
|
||||||
result = auth.search(base='ou=users,dc=yunohost,dc=org', filter='uid=' + username, attrs=attrs_to_fetch)
|
result = auth.search(base='ou=users,dc=yunohost,dc=org', filter='uid=' + username, attrs=attrs_to_fetch)
|
||||||
if not result:
|
if not result:
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n('user_unknown', user=username))
|
raise MoulinetteError('user_unknown', user=username)
|
||||||
user = result[0]
|
user = result[0]
|
||||||
|
|
||||||
# Get modifications from arguments
|
# Get modifications from arguments
|
||||||
|
@ -389,7 +389,7 @@ def user_update(operation_logger, auth, username, firstname=None, lastname=None,
|
||||||
app_ssowatconf(auth)
|
app_ssowatconf(auth)
|
||||||
return user_info(auth, username)
|
return user_info(auth, username)
|
||||||
else:
|
else:
|
||||||
raise MoulinetteError(169, m18n.n('user_update_failed'))
|
raise MoulinetteError('user_update_failed')
|
||||||
|
|
||||||
|
|
||||||
def user_info(auth, username):
|
def user_info(auth, username):
|
||||||
|
@ -414,7 +414,7 @@ def user_info(auth, username):
|
||||||
if result:
|
if result:
|
||||||
user = result[0]
|
user = result[0]
|
||||||
else:
|
else:
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n('user_unknown', user=username))
|
raise MoulinetteError('user_unknown', user=username)
|
||||||
|
|
||||||
result_dict = {
|
result_dict = {
|
||||||
'username': user['uid'][0],
|
'username': user['uid'][0],
|
||||||
|
@ -470,7 +470,7 @@ def user_info(auth, username):
|
||||||
if result:
|
if result:
|
||||||
return result_dict
|
return result_dict
|
||||||
else:
|
else:
|
||||||
raise MoulinetteError(167, m18n.n('user_info_failed'))
|
raise MoulinetteError('user_info_failed')
|
||||||
|
|
||||||
#
|
#
|
||||||
# SSH subcategory
|
# SSH subcategory
|
||||||
|
|
Loading…
Add table
Reference in a new issue