mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[enh] Add --installed and --with-backup to app_list action (wip #227)
This commit is contained in:
parent
4a7ff6a24f
commit
d07d8e835a
2 changed files with 28 additions and 6 deletions
|
@ -377,6 +377,14 @@ app:
|
||||||
full: --raw
|
full: --raw
|
||||||
help: Return the full app_dict
|
help: Return the full app_dict
|
||||||
action: store_true
|
action: store_true
|
||||||
|
-i:
|
||||||
|
full: --installed
|
||||||
|
help: Return only installed apps
|
||||||
|
action: store_true
|
||||||
|
-b:
|
||||||
|
full: --with-backup
|
||||||
|
help: Return only apps with backup feature (force --installed filter)
|
||||||
|
action: store_true
|
||||||
|
|
||||||
### app_info()
|
### app_info()
|
||||||
info:
|
info:
|
||||||
|
|
|
@ -126,7 +126,7 @@ def app_removelist(name):
|
||||||
logger.success(m18n.n('appslist_removed'))
|
logger.success(m18n.n('appslist_removed'))
|
||||||
|
|
||||||
|
|
||||||
def app_list(offset=None, limit=None, filter=None, raw=False):
|
def app_list(offset=None, limit=None, filter=None, raw=False, installed=False, with_backup=False):
|
||||||
"""
|
"""
|
||||||
List apps
|
List apps
|
||||||
|
|
||||||
|
@ -135,12 +135,15 @@ def app_list(offset=None, limit=None, filter=None, raw=False):
|
||||||
offset -- Starting number for app fetching
|
offset -- Starting number for app fetching
|
||||||
limit -- Maximum number of app fetched
|
limit -- Maximum number of app fetched
|
||||||
raw -- Return the full app_dict
|
raw -- Return the full app_dict
|
||||||
|
installed -- Return only installed apps
|
||||||
|
with_backup -- Return only apps with backup feature (force --installed filter)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if offset: offset = int(offset)
|
if offset: offset = int(offset)
|
||||||
else: offset = 0
|
else: offset = 0
|
||||||
if limit: limit = int(limit)
|
if limit: limit = int(limit)
|
||||||
else: limit = 1000
|
else: limit = 1000
|
||||||
|
installed = with_backup or installed
|
||||||
|
|
||||||
app_dict = {}
|
app_dict = {}
|
||||||
if raw:
|
if raw:
|
||||||
|
@ -183,16 +186,27 @@ def app_list(offset=None, limit=None, filter=None, raw=False):
|
||||||
for app_id, app_info_dict in sorted_app_dict.items():
|
for app_id, app_info_dict in sorted_app_dict.items():
|
||||||
if i < limit:
|
if i < limit:
|
||||||
if (filter and ((filter in app_id) or (filter in app_info_dict['manifest']['name']))) or not filter:
|
if (filter and ((filter in app_id) or (filter in app_info_dict['manifest']['name']))) or not filter:
|
||||||
installed = _is_installed(app_id)
|
app_installed = _is_installed(app_id)
|
||||||
|
|
||||||
|
# Only installed apps filter
|
||||||
|
if installed and not app_installed:
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Filter only apps with backup and restore scripts
|
||||||
|
if with_backup and (
|
||||||
|
not os.path.isfile(apps_setting_path + app_id + '/scripts/backup') or
|
||||||
|
not os.path.isfile(apps_setting_path + app_id + '/scripts/restore')
|
||||||
|
):
|
||||||
|
continue
|
||||||
|
|
||||||
if raw:
|
if raw:
|
||||||
app_info_dict['installed'] = installed
|
app_info_dict['installed'] = app_installed
|
||||||
if installed:
|
if app_installed:
|
||||||
app_info_dict['status'] = _get_app_status(app_id)
|
app_info_dict['status'] = _get_app_status(app_id)
|
||||||
list_dict[app_id] = app_info_dict
|
list_dict[app_id] = app_info_dict
|
||||||
else:
|
else:
|
||||||
label = None
|
label = None
|
||||||
if installed:
|
if app_installed:
|
||||||
app_info_dict_raw = app_info(app=app_id, raw=True)
|
app_info_dict_raw = app_info(app=app_id, raw=True)
|
||||||
label = app_info_dict_raw['settings']['label']
|
label = app_info_dict_raw['settings']['label']
|
||||||
list_dict.append({
|
list_dict.append({
|
||||||
|
@ -204,7 +218,7 @@ def app_list(offset=None, limit=None, filter=None, raw=False):
|
||||||
# FIXME: Temporarly allow undefined license
|
# FIXME: Temporarly allow undefined license
|
||||||
'license': app_info_dict['manifest'].get('license',
|
'license': app_info_dict['manifest'].get('license',
|
||||||
m18n.n('license_undefined')),
|
m18n.n('license_undefined')),
|
||||||
'installed': installed
|
'installed': app_installed
|
||||||
})
|
})
|
||||||
i += 1
|
i += 1
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Reference in a new issue