mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Remove 'auto' option, essentially irrelevant if we want to properly manage errors
This commit is contained in:
parent
5e99db7c63
commit
77b7f96b33
9 changed files with 27 additions and 31 deletions
|
@ -191,7 +191,7 @@ def app_fetchlist(url=None, name=None):
|
|||
_write_appslist_list(appslists)
|
||||
|
||||
|
||||
@is_unit_operation(auto=False)
|
||||
@is_unit_operation()
|
||||
def app_removelist(uo, name):
|
||||
"""
|
||||
Remove list from the repositories
|
||||
|
@ -429,7 +429,7 @@ def app_map(app=None, raw=False, user=None):
|
|||
return result
|
||||
|
||||
|
||||
@is_unit_operation(auto=False)
|
||||
@is_unit_operation()
|
||||
def app_change_url(uo, auth, app, domain, path):
|
||||
"""
|
||||
Modify the URL at which an application is installed.
|
||||
|
@ -681,7 +681,7 @@ def app_upgrade(auth, app=[], url=None, file=None):
|
|||
return {"log": service_log('yunohost-api', number="100").values()[0]}
|
||||
|
||||
|
||||
@is_unit_operation(auto=False)
|
||||
@is_unit_operation()
|
||||
def app_install(uo, auth, app, label=None, args=None, no_remove_on_failure=False):
|
||||
"""
|
||||
Install apps
|
||||
|
@ -862,7 +862,7 @@ def app_install(uo, auth, app, label=None, args=None, no_remove_on_failure=False
|
|||
hook_callback('post_app_install', args=args_list, env=env_dict)
|
||||
|
||||
|
||||
@is_unit_operation(auto=False)
|
||||
@is_unit_operation()
|
||||
def app_remove(uo, auth, app):
|
||||
"""
|
||||
Remove app
|
||||
|
@ -1103,7 +1103,7 @@ def app_debug(app):
|
|||
}
|
||||
|
||||
|
||||
@is_unit_operation(auto=False)
|
||||
@is_unit_operation()
|
||||
def app_makedefault(uo, auth, app, domain=None):
|
||||
"""
|
||||
Redirect domain root to an app
|
||||
|
|
|
@ -51,7 +51,7 @@ from yunohost.hook import (
|
|||
from yunohost.monitor import binary_to_human
|
||||
from yunohost.tools import tools_postinstall
|
||||
from yunohost.service import service_regen_conf
|
||||
from yunohost.log import UnitOperation, is_unit_operation
|
||||
from yunohost.log import UnitOperation
|
||||
|
||||
BACKUP_PATH = '/home/yunohost.backup'
|
||||
ARCHIVES_PATH = '%s/archives' % BACKUP_PATH
|
||||
|
|
|
@ -47,7 +47,7 @@ from yunohost.utils.errors import YunoHostError
|
|||
from moulinette import m18n
|
||||
from yunohost.app import app_ssowatconf
|
||||
from yunohost.service import _run_service_command, service_regen_conf
|
||||
from yunohost.log import is_unit_operation, UnitOperation
|
||||
from yunohost.log import UnitOperation
|
||||
|
||||
logger = getActionLogger('yunohost.certmanager')
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ def domain_list(auth):
|
|||
return {'domains': result_list}
|
||||
|
||||
|
||||
@is_unit_operation(auto=False)
|
||||
@is_unit_operation()
|
||||
def domain_add(uo, auth, domain, dyndns=False):
|
||||
"""
|
||||
Create a custom domain
|
||||
|
@ -133,7 +133,7 @@ def domain_add(uo, auth, domain, dyndns=False):
|
|||
logger.success(m18n.n('domain_created'))
|
||||
|
||||
|
||||
@is_unit_operation(auto=False)
|
||||
@is_unit_operation()
|
||||
def domain_remove(uo, auth, domain, force=False):
|
||||
"""
|
||||
Delete domains
|
||||
|
|
|
@ -113,7 +113,7 @@ def _dyndns_available(provider, domain):
|
|||
return r == u"Domain %s is available" % domain
|
||||
|
||||
|
||||
@is_unit_operation(auto=False)
|
||||
@is_unit_operation()
|
||||
def dyndns_subscribe(uo, subscribe_host="dyndns.yunohost.org", domain=None, key=None):
|
||||
"""
|
||||
Subscribe to a DynDNS service
|
||||
|
@ -175,7 +175,7 @@ def dyndns_subscribe(uo, subscribe_host="dyndns.yunohost.org", domain=None, key=
|
|||
dyndns_installcron()
|
||||
|
||||
|
||||
@is_unit_operation(auto=False)
|
||||
@is_unit_operation()
|
||||
def dyndns_update(uo, dyn_host="dyndns.yunohost.org", domain=None, key=None,
|
||||
ipv4=None, ipv6=None):
|
||||
"""
|
||||
|
|
|
@ -197,7 +197,7 @@ def log_display(path, number=50, share=False):
|
|||
|
||||
return infos
|
||||
|
||||
def is_unit_operation(entities='app,domain,service,user', exclude='auth,password', operation_key=None, auto=True):
|
||||
def is_unit_operation(entities='app,domain,service,user', exclude='auth,password', operation_key=None):
|
||||
"""
|
||||
Configure quickly a unit operation
|
||||
|
||||
|
@ -218,9 +218,6 @@ def is_unit_operation(entities='app,domain,service,user', exclude='auth,password
|
|||
well formed description you should add a translation key like this
|
||||
"log_" + operation_key in locales files.
|
||||
|
||||
auto If true, start the recording. If False, the unit operation object
|
||||
created is given to the decorated function as the first argument and you can
|
||||
start recording at the good time.
|
||||
"""
|
||||
def decorate(func):
|
||||
def func_wrapper(*args, **kwargs):
|
||||
|
@ -266,13 +263,10 @@ def is_unit_operation(entities='app,domain,service,user', exclude='auth,password
|
|||
context.pop(field, None)
|
||||
uo = UnitOperation(op_key, related_to, args=context)
|
||||
|
||||
# Start to record or give the unit operation in argument to let the
|
||||
# developper start the record itself
|
||||
if auto:
|
||||
uo.start()
|
||||
try:
|
||||
if not auto:
|
||||
args = (uo,) + args
|
||||
# Start the actual function, and give the unit operation
|
||||
# in argument to let the developper start the record itself
|
||||
args = (uo,) + args
|
||||
result = func(*args, **kwargs)
|
||||
except Exception as e:
|
||||
uo.error(e)
|
||||
|
|
|
@ -152,7 +152,7 @@ def service_stop(names):
|
|||
logger.debug(m18n.n('service_already_stopped', service=name))
|
||||
|
||||
@is_unit_operation()
|
||||
def service_enable(names):
|
||||
def service_enable(uo, names):
|
||||
"""
|
||||
Enable one or more services
|
||||
|
||||
|
@ -160,6 +160,7 @@ def service_enable(names):
|
|||
names -- Services name to enable
|
||||
|
||||
"""
|
||||
uo.start()
|
||||
if isinstance(names, str):
|
||||
names = [names]
|
||||
for name in names:
|
||||
|
@ -344,7 +345,7 @@ def service_log(name, number=50):
|
|||
return result
|
||||
|
||||
|
||||
@is_unit_operation('names:service', auto=False)
|
||||
@is_unit_operation('names:service')
|
||||
def service_regen_conf(uo, names=[], with_diff=False, force=False, dry_run=False,
|
||||
list_pending=False):
|
||||
"""
|
||||
|
|
|
@ -139,7 +139,7 @@ def tools_adminpw(auth, new_password):
|
|||
logger.success(m18n.n('admin_password_changed'))
|
||||
|
||||
|
||||
@is_unit_operation(auto=False)
|
||||
@is_unit_operation()
|
||||
def tools_maindomain(uo, auth, new_domain=None):
|
||||
"""
|
||||
Check the current main domain, or change it
|
||||
|
@ -249,7 +249,7 @@ def _is_inside_container():
|
|||
return out.split()[1] != "(1,"
|
||||
|
||||
|
||||
@is_unit_operation(auto=False)
|
||||
@is_unit_operation()
|
||||
def tools_postinstall(uo, domain, password, ignore_dyndns=False):
|
||||
"""
|
||||
YunoHost post-install
|
||||
|
@ -473,7 +473,7 @@ def tools_update(ignore_apps=False, ignore_packages=False):
|
|||
return {'packages': packages, 'apps': apps}
|
||||
|
||||
|
||||
@is_unit_operation(auto=False)
|
||||
@is_unit_operation()
|
||||
def tools_upgrade(uo, auth, ignore_apps=False, ignore_packages=False):
|
||||
"""
|
||||
Update apps & package cache, then display changelog
|
||||
|
@ -713,7 +713,7 @@ def tools_port_available(port):
|
|||
return False
|
||||
|
||||
|
||||
@is_unit_operation(auto=False)
|
||||
@is_unit_operation()
|
||||
def tools_shutdown(uo, force=False):
|
||||
shutdown = force
|
||||
if not shutdown:
|
||||
|
@ -732,7 +732,7 @@ def tools_shutdown(uo, force=False):
|
|||
subprocess.check_call(['systemctl', 'poweroff'])
|
||||
|
||||
|
||||
@is_unit_operation(auto=False)
|
||||
@is_unit_operation()
|
||||
def tools_reboot(uo, force=False):
|
||||
reboot = force
|
||||
if not reboot:
|
||||
|
|
|
@ -99,7 +99,7 @@ def user_list(auth, fields=None):
|
|||
return {'users': users}
|
||||
|
||||
|
||||
@is_unit_operation('username:user', auto=False)
|
||||
@is_unit_operation('username:user')
|
||||
def user_create(uo, auth, username, firstname, lastname, mail, password,
|
||||
mailbox_quota="0"):
|
||||
"""
|
||||
|
@ -224,7 +224,7 @@ def user_create(uo, auth, username, firstname, lastname, mail, password,
|
|||
|
||||
|
||||
@is_unit_operation('username:user')
|
||||
def user_delete(auth, username, purge=False):
|
||||
def user_delete(uo, auth, username, purge=False):
|
||||
"""
|
||||
Delete user
|
||||
|
||||
|
@ -236,6 +236,7 @@ def user_delete(auth, username, purge=False):
|
|||
from yunohost.app import app_ssowatconf
|
||||
from yunohost.hook import hook_callback
|
||||
|
||||
uo.start()
|
||||
if auth.remove('uid=%s,ou=users' % username):
|
||||
# Invalidate passwd to take user deletion into account
|
||||
subprocess.call(['nscd', '-i', 'passwd'])
|
||||
|
@ -259,7 +260,7 @@ def user_delete(auth, username, purge=False):
|
|||
logger.success(m18n.n('user_deleted'))
|
||||
|
||||
|
||||
@is_unit_operation('username:user', exclude='auth,change_password', auto=False)
|
||||
@is_unit_operation('username:user', exclude='auth,change_password')
|
||||
def user_update(uo, auth, username, firstname=None, lastname=None, mail=None,
|
||||
change_password=None, add_mailforward=None, remove_mailforward=None,
|
||||
add_mailalias=None, remove_mailalias=None, mailbox_quota=None):
|
||||
|
|
Loading…
Add table
Reference in a new issue