__raw_msg__ -> raw_msg

This commit is contained in:
Alexandre Aubin 2018-12-14 14:17:20 +00:00
parent 46972788b2
commit 7e3a90232f
3 changed files with 12 additions and 12 deletions

View file

@ -183,7 +183,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 YunohostError("Error while writing appslist %s: %s" % (name, str(e)), __raw_msg__=True) raise YunohostError("Error while writing appslist %s: %s" % (name, str(e)), raw_msg=True)
now = int(time.time()) now = int(time.time())
appslists[name]["lastUpdate"] = now appslists[name]["lastUpdate"] = now
@ -840,9 +840,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 YunohostError(msg, __raw_msg__=True) raise YunohostError(msg, raw_msg=True)
msg = error_msg msg = error_msg
raise YunohostError(msg, __raw_msg__=True) raise YunohostError(msg, raw_msg=True)
# Clean hooks and add new ones # Clean hooks and add new ones
hook_remove(app_instance_name) hook_remove(app_instance_name)
@ -1472,7 +1472,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 YunohostError("action '%s' not available for app '%s', available actions are: %s" % (action, app, ", ".join(actions.keys())), __raw_msg__=True) raise YunohostError("action '%s' not available for app '%s', available actions are: %s" % (action, app, ", ".join(actions.keys())), raw_msg=True)
action_declaration = actions[action] action_declaration = actions[action]
@ -1510,7 +1510,7 @@ def app_action_run(app, action, args=None):
) )
if retcode not in action_declaration.get("accepted_return_codes", [0]): if retcode not in action_declaration.get("accepted_return_codes", [0]):
raise YunohostError("Error while executing action '%s' of app '%s': return code %s" % (action, app, retcode), __raw_msg__=True) raise YunohostError("Error while executing action '%s' of app '%s': return code %s" % (action, app, retcode), raw_msg=True)
os.remove(path) os.remove(path)
@ -2431,7 +2431,7 @@ def _write_appslist_list(appslist_lists):
json.dump(appslist_lists, f) json.dump(appslist_lists, f)
except Exception as e: except Exception as e:
raise YunohostError("Error while writing list of appslist %s: %s" % raise YunohostError("Error while writing list of appslist %s: %s" %
(APPSLISTS_JSON, str(e)), __raw_msg__=True) (APPSLISTS_JSON, str(e)), raw_msg=True)
def _register_new_appslist(url, name): def _register_new_appslist(url, name):

View file

@ -29,10 +29,10 @@ class YunohostError(MoulinetteError):
The (only?) main difference with MoulinetteError being that keys The (only?) main difference with MoulinetteError being that keys
are translated via m18n.n (namespace) instead of m18n.g (global?) are translated via m18n.n (namespace) instead of m18n.g (global?)
""" """
def __init__(self, key, __raw_msg__=False, *args, **kwargs): def __init__(self, key, raw_msg=False, *args, **kwargs):
if __raw_msg__: if raw_msg:
msg = key msg = key
else: else:
msg = m18n.n(key, *args, **kwargs) msg = m18n.n(key, *args, **kwargs)
super(YunohostError, self).__init__(msg, __raw_msg__=True) super(YunohostError, self).__init__(msg, raw_msg=True)

View file

@ -12,14 +12,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 YunohostError("Something wrong happened while trying to paste data on paste.yunohost.org : %s" % str(e), __raw_msg__=True) raise YunohostError("Something wrong happened while trying to paste data on paste.yunohost.org : %s" % str(e), raw_msg=True)
if r.status_code != 200: if r.status_code != 200:
raise YunohostError("Something wrong happened while trying to paste data on paste.yunohost.org : %s, %s" % (r.status_code, r.text), __raw_msg__=True) raise YunohostError("Something wrong happened while trying to paste data on paste.yunohost.org : %s, %s" % (r.status_code, r.text), raw_msg=True)
try: try:
url = json.loads(r.text)["key"] url = json.loads(r.text)["key"]
except: except:
raise YunohostError("Uhoh, couldn't parse the answer from paste.yunohost.org : %s" % r.text, __raw_msg__=True) raise YunohostError("Uhoh, couldn't parse the answer from paste.yunohost.org : %s" % r.text, raw_msg=True)
return "%s/raw/%s" % (paste_server, url) return "%s/raw/%s" % (paste_server, url)