Merge branch 'stretch-unstable' into new-diagnosis-system

This commit is contained in:
Alexandre Aubin 2019-11-06 18:58:50 +01:00
commit ab1f42cad1
2 changed files with 25 additions and 5 deletions

View file

@ -48,7 +48,6 @@ from yunohost.app import (
from yunohost.hook import (
hook_list, hook_info, hook_callback, hook_exec, CUSTOM_HOOK_FOLDER
)
from yunohost.monitor import binary_to_human
from yunohost.tools import tools_postinstall
from yunohost.regenconf import regen_conf
from yunohost.log import OperationLogger
@ -2492,3 +2491,23 @@ def disk_usage(path):
du_output = subprocess.check_output(['du', '-sb', path])
return int(du_output.split()[0].decode('utf-8'))
def binary_to_human(n, customary=False):
"""
Convert bytes or bits into human readable format with binary prefix
Keyword argument:
n -- Number to convert
customary -- Use customary symbol instead of IEC standard
"""
symbols = ('Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi', 'Yi')
if customary:
symbols = ('K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y')
prefix = {}
for i, s in enumerate(symbols):
prefix[s] = 1 << (i + 1) * 10
for s in reversed(symbols):
if n >= prefix[s]:
value = float(n) / prefix[s]
return '%.1f%s' % (value, s)
return "%s" % n

View file

@ -7,7 +7,7 @@ from moulinette.utils.log import getActionLogger
from moulinette.utils.filesystem import read_yaml
from yunohost.tools import Migration
from yunohost.user import user_group_create, user_group_update
from yunohost.user import user_list, user_group_create, user_group_update
from yunohost.app import app_setting, app_list
from yunohost.regenconf import regen_conf, BACKUP_CONF_DIR
from yunohost.permission import permission_create, user_permission_update, permission_sync_to_user
@ -109,10 +109,11 @@ class MyMigration(Migration):
url = "/" if domain and path else None
if permission:
allowed_groups = permission.split(',')
known_users = user_list()["users"].keys()
allowed = [user for user in permission.split(',') if user in known_users]
else:
allowed_groups = ["all_users"]
permission_create(app+".main", url=url, allowed=allowed_groups, sync_perm=False)
allowed = ["all_users"]
permission_create(app+".main", url=url, allowed=allowed, sync_perm=False)
app_setting(app, 'allowed_users', delete=True)