mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
The rest
The ones that sed didn't find. Modified by hand.
This commit is contained in:
parent
0468d6b900
commit
fab662f4ef
11 changed files with 36 additions and 88 deletions
|
@ -184,9 +184,7 @@ def app_fetchlist(url=None, name=None):
|
||||||
with open(list_file, "w") as f:
|
with open(list_file, "w") as f:
|
||||||
f.write(appslist)
|
f.write(appslist)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise MoulinetteError(errno.EIO,
|
raise MoulinetteError("Error while writing appslist %s: %s" % (name, str(e)))
|
||||||
"Error while writing appslist %s: %s" %
|
|
||||||
(name, str(e)))
|
|
||||||
|
|
||||||
now = int(time.time())
|
now = int(time.time())
|
||||||
appslists[name]["lastUpdate"] = now
|
appslists[name]["lastUpdate"] = now
|
||||||
|
@ -843,9 +841,9 @@ def app_install(operation_logger, auth, app, label=None, args=None, no_remove_on
|
||||||
|
|
||||||
if install_retcode == -1:
|
if install_retcode == -1:
|
||||||
msg = m18n.n('operation_interrupted') + " " + error_msg
|
msg = m18n.n('operation_interrupted') + " " + error_msg
|
||||||
raise MoulinetteError(errno.EINTR, msg)
|
raise MoulinetteError(msg)
|
||||||
msg = error_msg
|
msg = error_msg
|
||||||
raise MoulinetteError(errno.EIO, msg)
|
raise MoulinetteError(msg)
|
||||||
|
|
||||||
# Clean hooks and add new ones
|
# Clean hooks and add new ones
|
||||||
hook_remove(app_instance_name)
|
hook_remove(app_instance_name)
|
||||||
|
@ -1135,10 +1133,7 @@ def app_makedefault(operation_logger, auth, app, domain=None):
|
||||||
|
|
||||||
operation_logger.start()
|
operation_logger.start()
|
||||||
if '/' in app_map(raw=True)[domain]:
|
if '/' in app_map(raw=True)[domain]:
|
||||||
raise MoulinetteError(errno.EEXIST,
|
raise MoulinetteError('app_make_default_location_already_used', app=app, domain=app_domain, other_app=app_map(raw=True)[domain]["/"]["id"])
|
||||||
m18n.n('app_make_default_location_already_used',
|
|
||||||
app=app, domain=app_domain,
|
|
||||||
other_app=app_map(raw=True)[domain]["/"]["id"]))
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open('/etc/ssowat/conf.json.persistent') as json_conf:
|
with open('/etc/ssowat/conf.json.persistent') as json_conf:
|
||||||
|
@ -1298,14 +1293,10 @@ def app_checkurl(auth, url, app=None):
|
||||||
installed = True
|
installed = True
|
||||||
continue
|
continue
|
||||||
if path == p:
|
if path == p:
|
||||||
raise MoulinetteError(errno.EINVAL,
|
raise MoulinetteError('app_location_already_used', app=a["id"], path=path)
|
||||||
m18n.n('app_location_already_used',
|
|
||||||
app=a["id"], path=path))
|
|
||||||
# can't install "/a/b/" if "/a/" exists
|
# can't install "/a/b/" if "/a/" exists
|
||||||
elif path.startswith(p) or p.startswith(path):
|
elif path.startswith(p) or p.startswith(path):
|
||||||
raise MoulinetteError(errno.EPERM,
|
raise MoulinetteError('app_location_install_failed', other_path=p, other_app=a['id'))
|
||||||
m18n.n('app_location_install_failed',
|
|
||||||
other_path=p, other_app=a['id']))
|
|
||||||
|
|
||||||
if app is not None and not installed:
|
if app is not None and not installed:
|
||||||
app_setting(app, 'domain', value=domain)
|
app_setting(app, 'domain', value=domain)
|
||||||
|
@ -1482,7 +1473,7 @@ def app_action_run(app, action, args=None):
|
||||||
actions = {x["id"]: x for x in actions}
|
actions = {x["id"]: x for x in actions}
|
||||||
|
|
||||||
if action not in actions:
|
if action not in actions:
|
||||||
raise MoulinetteError(errno.EINVAL, "action '%s' not available for app '%s', available actions are: %s" % (action, app, ", ".join(actions.keys())))
|
raise MoulinetteError("action '%s' not available for app '%s', available actions are: %s" % (action, app, ", ".join(actions.keys())))
|
||||||
|
|
||||||
action_declaration = actions[action]
|
action_declaration = actions[action]
|
||||||
|
|
||||||
|
@ -2066,7 +2057,7 @@ def _check_manifest_requirements(manifest, app_instance_name):
|
||||||
yunohost_req = requirements.get('yunohost', None)
|
yunohost_req = requirements.get('yunohost', None)
|
||||||
if (not yunohost_req or
|
if (not yunohost_req or
|
||||||
not packages.SpecifierSet(yunohost_req) & '>= 2.3.6'):
|
not packages.SpecifierSet(yunohost_req) & '>= 2.3.6'):
|
||||||
raise MoulinetteError(errno.EINVAL, '{0}{1}'.format(
|
raise MoulinetteError('{0}{1}'.format(
|
||||||
m18n.g('colon', m18n.n('app_incompatible'), app=app_instance_name),
|
m18n.g('colon', m18n.n('app_incompatible'), app=app_instance_name),
|
||||||
m18n.n('app_package_need_update', app=app_instance_name)))
|
m18n.n('app_package_need_update', app=app_instance_name)))
|
||||||
elif not requirements:
|
elif not requirements:
|
||||||
|
@ -2079,9 +2070,7 @@ def _check_manifest_requirements(manifest, app_instance_name):
|
||||||
versions = packages.get_installed_version(
|
versions = packages.get_installed_version(
|
||||||
*requirements.keys(), strict=True, as_dict=True)
|
*requirements.keys(), strict=True, as_dict=True)
|
||||||
except packages.PackageException as e:
|
except packages.PackageException as e:
|
||||||
raise MoulinetteError(errno.EINVAL,
|
raise MoulinetteError('app_requirements_failed', error=str(e), app=app_instance_name)
|
||||||
m18n.n('app_requirements_failed',
|
|
||||||
error=str(e), app=app_instance_name))
|
|
||||||
|
|
||||||
# Iterate over requirements
|
# Iterate over requirements
|
||||||
for pkgname, spec in requirements.items():
|
for pkgname, spec in requirements.items():
|
||||||
|
@ -2221,28 +2210,20 @@ def _parse_action_args_in_yunohost_format(args, action_args, auth=None):
|
||||||
|
|
||||||
# Validate argument choice
|
# Validate argument choice
|
||||||
if arg_choices and arg_value not in arg_choices:
|
if arg_choices and arg_value not in arg_choices:
|
||||||
raise MoulinetteError(errno.EINVAL,
|
raise MoulinetteError('app_argument_choice_invalid', name=arg_name, choices=', '.join(arg_choices))
|
||||||
m18n.n('app_argument_choice_invalid',
|
|
||||||
name=arg_name, choices=', '.join(arg_choices)))
|
|
||||||
|
|
||||||
# Validate argument type
|
# Validate argument type
|
||||||
if arg_type == 'domain':
|
if arg_type == 'domain':
|
||||||
if arg_value not in domain_list(auth)['domains']:
|
if arg_value not in domain_list(auth)['domains']:
|
||||||
raise MoulinetteError(errno.EINVAL,
|
raise MoulinetteError('app_argument_invalid', name=arg_name, error=m18n.n('domain_unknown'))
|
||||||
m18n.n('app_argument_invalid',
|
|
||||||
name=arg_name, error=m18n.n('domain_unknown')))
|
|
||||||
elif arg_type == 'user':
|
elif arg_type == 'user':
|
||||||
try:
|
try:
|
||||||
user_info(auth, arg_value)
|
user_info(auth, arg_value)
|
||||||
except MoulinetteError as e:
|
except MoulinetteError as e:
|
||||||
raise MoulinetteError(errno.EINVAL,
|
raise MoulinetteError('app_argument_invalid', name=arg_name, error=e.strerror)
|
||||||
m18n.n('app_argument_invalid',
|
|
||||||
name=arg_name, error=e.strerror))
|
|
||||||
elif arg_type == 'app':
|
elif arg_type == 'app':
|
||||||
if not _is_installed(arg_value):
|
if not _is_installed(arg_value):
|
||||||
raise MoulinetteError(errno.EINVAL,
|
raise MoulinetteError('app_argument_invalid', name=arg_name, error=m18n.n('app_unknown'))
|
||||||
m18n.n('app_argument_invalid',
|
|
||||||
name=arg_name, error=m18n.n('app_unknown')))
|
|
||||||
elif arg_type == 'boolean':
|
elif arg_type == 'boolean':
|
||||||
if isinstance(arg_value, bool):
|
if isinstance(arg_value, bool):
|
||||||
arg_value = 1 if arg_value else 0
|
arg_value = 1 if arg_value else 0
|
||||||
|
@ -2252,9 +2233,7 @@ def _parse_action_args_in_yunohost_format(args, action_args, auth=None):
|
||||||
elif str(arg_value).lower() in ["0", "no", "n"]:
|
elif str(arg_value).lower() in ["0", "no", "n"]:
|
||||||
arg_value = 0
|
arg_value = 0
|
||||||
else:
|
else:
|
||||||
raise MoulinetteError(errno.EINVAL,
|
raise MoulinetteError('app_argument_choice_invalid', name=arg_name, choices='yes, no, y, n, 1, 0')
|
||||||
m18n.n('app_argument_choice_invalid',
|
|
||||||
name=arg_name, choices='yes, no, y, n, 1, 0'))
|
|
||||||
elif arg_type == 'password':
|
elif arg_type == 'password':
|
||||||
from yunohost.utils.password import assert_password_is_strong_enough
|
from yunohost.utils.password import assert_password_is_strong_enough
|
||||||
assert_password_is_strong_enough('user', arg_value)
|
assert_password_is_strong_enough('user', arg_value)
|
||||||
|
@ -2453,8 +2432,7 @@ def _write_appslist_list(appslist_lists):
|
||||||
with open(APPSLISTS_JSON, "w") as f:
|
with open(APPSLISTS_JSON, "w") as f:
|
||||||
json.dump(appslist_lists, f)
|
json.dump(appslist_lists, f)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise MoulinetteError(errno.EIO,
|
raise MoulinetteError("Error while writing list of appslist %s: %s" %
|
||||||
"Error while writing list of appslist %s: %s" %
|
|
||||||
(APPSLISTS_JSON, str(e)))
|
(APPSLISTS_JSON, str(e)))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2295,9 +2295,7 @@ def _create_archive_dir():
|
||||||
""" Create the YunoHost archives directory if doesn't exist """
|
""" Create the YunoHost archives directory if doesn't exist """
|
||||||
if not os.path.isdir(ARCHIVES_PATH):
|
if not os.path.isdir(ARCHIVES_PATH):
|
||||||
if os.path.lexists(ARCHIVES_PATH):
|
if os.path.lexists(ARCHIVES_PATH):
|
||||||
raise MoulinetteError(errno.EINVAL,
|
raise MoulinetteError('backup_output_symlink_dir_broken', path=ARCHIVES_PATH)
|
||||||
m18n.n('backup_output_symlink_dir_broken',
|
|
||||||
path=ARCHIVES_PATH))
|
|
||||||
|
|
||||||
os.mkdir(ARCHIVES_PATH, 0750)
|
os.mkdir(ARCHIVES_PATH, 0750)
|
||||||
|
|
||||||
|
|
|
@ -106,8 +106,7 @@ def certificate_status(auth, domain_list, full=False):
|
||||||
for domain in domain_list:
|
for domain in domain_list:
|
||||||
# Is it in Yunohost domain list?
|
# Is it in Yunohost domain list?
|
||||||
if domain not in yunohost_domains_list:
|
if domain not in yunohost_domains_list:
|
||||||
raise MoulinetteError(errno.EINVAL, m18n.n(
|
raise MoulinetteError('certmanager_domain_unknown', domain=domain)
|
||||||
'certmanager_domain_unknown', domain=domain))
|
|
||||||
|
|
||||||
certificates = {}
|
certificates = {}
|
||||||
|
|
||||||
|
|
|
@ -87,16 +87,14 @@ def domain_add(operation_logger, auth, domain, dyndns=False):
|
||||||
|
|
||||||
# Do not allow to subscribe to multiple dyndns domains...
|
# Do not allow to subscribe to multiple dyndns domains...
|
||||||
if os.path.exists('/etc/cron.d/yunohost-dyndns'):
|
if os.path.exists('/etc/cron.d/yunohost-dyndns'):
|
||||||
raise MoulinetteError(errno.EPERM,
|
raise MoulinetteError('domain_dyndns_already_subscribed')
|
||||||
m18n.n('domain_dyndns_already_subscribed'))
|
|
||||||
|
|
||||||
from yunohost.dyndns import dyndns_subscribe, _dyndns_provides
|
from yunohost.dyndns import dyndns_subscribe, _dyndns_provides
|
||||||
|
|
||||||
# Check that this domain can effectively be provided by
|
# Check that this domain can effectively be provided by
|
||||||
# dyndns.yunohost.org. (i.e. is it a nohost.me / noho.st)
|
# dyndns.yunohost.org. (i.e. is it a nohost.me / noho.st)
|
||||||
if not _dyndns_provides("dyndns.yunohost.org", domain):
|
if not _dyndns_provides("dyndns.yunohost.org", domain):
|
||||||
raise MoulinetteError(errno.EINVAL,
|
raise MoulinetteError('domain_dyndns_root_unknown')
|
||||||
m18n.n('domain_dyndns_root_unknown'))
|
|
||||||
|
|
||||||
# Actually subscribe
|
# Actually subscribe
|
||||||
dyndns_subscribe(domain=domain)
|
dyndns_subscribe(domain=domain)
|
||||||
|
|
|
@ -77,9 +77,7 @@ def _dyndns_provides(provider, domain):
|
||||||
dyndomains = download_json('https://%s/domains' % provider, timeout=30)
|
dyndomains = download_json('https://%s/domains' % provider, timeout=30)
|
||||||
except MoulinetteError as e:
|
except MoulinetteError as e:
|
||||||
logger.error(str(e))
|
logger.error(str(e))
|
||||||
raise MoulinetteError(errno.EIO,
|
raise MoulinetteError('dyndns_could_not_check_provide', domain=domain, provider=provider)
|
||||||
m18n.n('dyndns_could_not_check_provide',
|
|
||||||
domain=domain, provider=provider))
|
|
||||||
|
|
||||||
# Extract 'dyndomain' from 'domain', e.g. 'nohost.me' from 'foo.nohost.me'
|
# Extract 'dyndomain' from 'domain', e.g. 'nohost.me' from 'foo.nohost.me'
|
||||||
dyndomain = '.'.join(domain.split('.')[1:])
|
dyndomain = '.'.join(domain.split('.')[1:])
|
||||||
|
|
|
@ -318,7 +318,7 @@ def hook_exec(path, args=None, raise_on_error=False, no_trace=False,
|
||||||
if path[0] != '/':
|
if path[0] != '/':
|
||||||
path = os.path.realpath(path)
|
path = os.path.realpath(path)
|
||||||
if not os.path.isfile(path):
|
if not os.path.isfile(path):
|
||||||
raise MoulinetteError(errno.EIO, m18n.g('file_not_exist', path=path))
|
raise MoulinetteError('file_not_exist', path=path)
|
||||||
|
|
||||||
# Construct command variables
|
# Construct command variables
|
||||||
cmd_args = ''
|
cmd_args = ''
|
||||||
|
|
|
@ -188,7 +188,7 @@ def log_display(path, number=50, share=False):
|
||||||
if os.path.exists(log_path):
|
if os.path.exists(log_path):
|
||||||
logger.warning(error)
|
logger.warning(error)
|
||||||
else:
|
else:
|
||||||
raise MoulinetteError(errno.EINVAL, error)
|
raise MoulinetteError(error)
|
||||||
|
|
||||||
# Display logs if exist
|
# Display logs if exist
|
||||||
if os.path.exists(log_path):
|
if os.path.exists(log_path):
|
||||||
|
|
|
@ -130,10 +130,7 @@ def service_start(names):
|
||||||
logger.success(m18n.n('service_started', service=name))
|
logger.success(m18n.n('service_started', service=name))
|
||||||
else:
|
else:
|
||||||
if service_status(name)['status'] != 'running':
|
if service_status(name)['status'] != 'running':
|
||||||
raise MoulinetteError(errno.EPERM,
|
raise MoulinetteError('service_start_failed', service=name, logs=_get_journalctl_logs(name))
|
||||||
m18n.n('service_start_failed',
|
|
||||||
service=name,
|
|
||||||
logs=_get_journalctl_logs(name)))
|
|
||||||
logger.debug(m18n.n('service_already_started', service=name))
|
logger.debug(m18n.n('service_already_started', service=name))
|
||||||
|
|
||||||
|
|
||||||
|
@ -152,10 +149,7 @@ def service_stop(names):
|
||||||
logger.success(m18n.n('service_stopped', service=name))
|
logger.success(m18n.n('service_stopped', service=name))
|
||||||
else:
|
else:
|
||||||
if service_status(name)['status'] != 'inactive':
|
if service_status(name)['status'] != 'inactive':
|
||||||
raise MoulinetteError(errno.EPERM,
|
raise MoulinetteError('service_stop_failed', service=name, logs=_get_journalctl_logs(name))
|
||||||
m18n.n('service_stop_failed',
|
|
||||||
service=name,
|
|
||||||
logs=_get_journalctl_logs(name)))
|
|
||||||
logger.debug(m18n.n('service_already_stopped', service=name))
|
logger.debug(m18n.n('service_already_stopped', service=name))
|
||||||
|
|
||||||
@is_unit_operation()
|
@is_unit_operation()
|
||||||
|
@ -174,10 +168,7 @@ def service_enable(operation_logger, names):
|
||||||
if _run_service_command('enable', name):
|
if _run_service_command('enable', name):
|
||||||
logger.success(m18n.n('service_enabled', service=name))
|
logger.success(m18n.n('service_enabled', service=name))
|
||||||
else:
|
else:
|
||||||
raise MoulinetteError(errno.EPERM,
|
raise MoulinetteError('service_enable_failed', service=name, logs=_get_journalctl_logs(name))
|
||||||
m18n.n('service_enable_failed',
|
|
||||||
service=name,
|
|
||||||
logs=_get_journalctl_logs(name)))
|
|
||||||
|
|
||||||
|
|
||||||
def service_disable(names):
|
def service_disable(names):
|
||||||
|
@ -194,10 +185,7 @@ def service_disable(names):
|
||||||
if _run_service_command('disable', name):
|
if _run_service_command('disable', name):
|
||||||
logger.success(m18n.n('service_disabled', service=name))
|
logger.success(m18n.n('service_disabled', service=name))
|
||||||
else:
|
else:
|
||||||
raise MoulinetteError(errno.EPERM,
|
raise MoulinetteError('service_disable_failed', service=name, logs=_get_journalctl_logs(name))
|
||||||
m18n.n('service_disable_failed',
|
|
||||||
service=name,
|
|
||||||
logs=_get_journalctl_logs(name)))
|
|
||||||
|
|
||||||
|
|
||||||
def service_status(names=[]):
|
def service_status(names=[]):
|
||||||
|
@ -220,8 +208,7 @@ def service_status(names=[]):
|
||||||
|
|
||||||
for name in names:
|
for name in names:
|
||||||
if check_names and name not in services.keys():
|
if check_names and name not in services.keys():
|
||||||
raise MoulinetteError(errno.EINVAL,
|
raise MoulinetteError('service_unknown', service=name)
|
||||||
m18n.n('service_unknown', service=name))
|
|
||||||
|
|
||||||
# this "service" isn't a service actually so we skip it
|
# this "service" isn't a service actually so we skip it
|
||||||
#
|
#
|
||||||
|
|
|
@ -139,8 +139,7 @@ def tools_adminpw(auth, new_password, check_strength=True):
|
||||||
auth.update("cn=admin", { "userPassword": new_hash, })
|
auth.update("cn=admin", { "userPassword": new_hash, })
|
||||||
except:
|
except:
|
||||||
logger.exception('unable to change admin password')
|
logger.exception('unable to change admin password')
|
||||||
raise MoulinetteError(errno.EPERM,
|
raise MoulinetteError('admin_password_change_failed')
|
||||||
m18n.n('admin_password_change_failed'))
|
|
||||||
else:
|
else:
|
||||||
# Write as root password
|
# Write as root password
|
||||||
try:
|
try:
|
||||||
|
@ -289,8 +288,7 @@ def tools_postinstall(operation_logger, domain, password, ignore_dyndns=False,
|
||||||
|
|
||||||
# Do some checks at first
|
# Do some checks at first
|
||||||
if os.path.isfile('/etc/yunohost/installed'):
|
if os.path.isfile('/etc/yunohost/installed'):
|
||||||
raise MoulinetteError(errno.EPERM,
|
raise MoulinetteError('yunohost_already_installed')
|
||||||
m18n.n('yunohost_already_installed'))
|
|
||||||
|
|
||||||
# Check password
|
# Check password
|
||||||
if not force_password:
|
if not force_password:
|
||||||
|
@ -319,9 +317,7 @@ def tools_postinstall(operation_logger, domain, password, ignore_dyndns=False,
|
||||||
dyndns = True
|
dyndns = True
|
||||||
# If not, abort the postinstall
|
# If not, abort the postinstall
|
||||||
else:
|
else:
|
||||||
raise MoulinetteError(errno.EEXIST,
|
raise MoulinetteError('dyndns_unavailable', domain=domain)
|
||||||
m18n.n('dyndns_unavailable',
|
|
||||||
domain=domain))
|
|
||||||
else:
|
else:
|
||||||
dyndns = False
|
dyndns = False
|
||||||
else:
|
else:
|
||||||
|
@ -364,8 +360,7 @@ def tools_postinstall(operation_logger, domain, password, ignore_dyndns=False,
|
||||||
with open('/etc/ssowat/conf.json.persistent') as json_conf:
|
with open('/etc/ssowat/conf.json.persistent') as json_conf:
|
||||||
ssowat_conf = json.loads(str(json_conf.read()))
|
ssowat_conf = json.loads(str(json_conf.read()))
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
raise MoulinetteError(errno.EINVAL,
|
raise MoulinetteError('ssowat_persistent_conf_read_error', error=str(e))
|
||||||
m18n.n('ssowat_persistent_conf_read_error', error=str(e)))
|
|
||||||
except IOError:
|
except IOError:
|
||||||
ssowat_conf = {}
|
ssowat_conf = {}
|
||||||
|
|
||||||
|
@ -378,8 +373,7 @@ def tools_postinstall(operation_logger, domain, password, ignore_dyndns=False,
|
||||||
with open('/etc/ssowat/conf.json.persistent', 'w+') as f:
|
with open('/etc/ssowat/conf.json.persistent', 'w+') as f:
|
||||||
json.dump(ssowat_conf, f, sort_keys=True, indent=4)
|
json.dump(ssowat_conf, f, sort_keys=True, indent=4)
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
raise MoulinetteError(errno.EPERM,
|
raise MoulinetteError('ssowat_persistent_conf_write_error', error=str(e))
|
||||||
m18n.n('ssowat_persistent_conf_write_error', error=str(e)))
|
|
||||||
|
|
||||||
os.system('chmod 644 /etc/ssowat/conf.json.persistent')
|
os.system('chmod 644 /etc/ssowat/conf.json.persistent')
|
||||||
|
|
||||||
|
|
|
@ -71,8 +71,7 @@ def user_list(auth, fields=None):
|
||||||
if attr in keys:
|
if attr in keys:
|
||||||
attrs.append(attr)
|
attrs.append(attr)
|
||||||
else:
|
else:
|
||||||
raise MoulinetteError(errno.EINVAL,
|
raise MoulinetteError('field_invalid', attrz1)
|
||||||
m18n.n('field_invalid', attr))
|
|
||||||
else:
|
else:
|
||||||
attrs = ['uid', 'cn', 'mail', 'mailuserquota', 'loginShell']
|
attrs = ['uid', 'cn', 'mail', 'mailuserquota', 'loginShell']
|
||||||
|
|
||||||
|
|
|
@ -13,17 +13,14 @@ def yunopaste(data):
|
||||||
try:
|
try:
|
||||||
r = requests.post("%s/documents" % paste_server, data=data, timeout=30)
|
r = requests.post("%s/documents" % paste_server, data=data, timeout=30)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise MoulinetteError(errno.EIO,
|
raise MoulinetteError("Something wrong happened while trying to paste data on paste.yunohost.org : %s" % str(e))
|
||||||
"Something wrong happened while trying to paste data on paste.yunohost.org : %s" % str(e))
|
|
||||||
|
|
||||||
if r.status_code != 200:
|
if r.status_code != 200:
|
||||||
raise MoulinetteError(errno.EIO,
|
raise MoulinetteError("Something wrong happened while trying to paste data on paste.yunohost.org : %s, %s" % (r.status_code, r.text))
|
||||||
"Something wrong happened while trying to paste data on paste.yunohost.org : %s, %s" % (r.status_code, r.text))
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
url = json.loads(r.text)["key"]
|
url = json.loads(r.text)["key"]
|
||||||
except:
|
except:
|
||||||
raise MoulinetteError(errno.EIO,
|
raise MoulinetteError("Uhoh, couldn't parse the answer from paste.yunohost.org : %s" % r.text)
|
||||||
"Uhoh, couldn't parse the answer from paste.yunohost.org : %s" % r.text)
|
|
||||||
|
|
||||||
return "%s/raw/%s" % (paste_server, url)
|
return "%s/raw/%s" % (paste_server, url)
|
||||||
|
|
Loading…
Add table
Reference in a new issue