From c199e681fd9caca516c3d8120e4bfdf69e77120e Mon Sep 17 00:00:00 2001 From: zamentur Date: Sun, 14 Feb 2016 01:03:16 +0100 Subject: [PATCH 1/2] [fix] Error "seems to be not correctly installed" on app install --- src/yunohost/app.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/yunohost/app.py b/src/yunohost/app.py index 6b40b3b55..e739e1225 100644 --- a/src/yunohost/app.py +++ b/src/yunohost/app.py @@ -475,7 +475,10 @@ def app_install(auth, app, label=None, args=None): hook_add(app_id, app_tmp_folder +'/hooks/'+ file) now = int(time.time()) - app_setting(app_id, 'id', app_id) + + # We can't use app_setting cause it creates an 'app_not_correctly_installed' + # message. See https://dev.yunohost.org/issues/206#note-3 + _set_app_settings(app, {'id':app_id}) # TODO: Move install_time away from app_setting app_setting(app_id, 'install_time', now) status['installed_at'] = now @@ -796,9 +799,7 @@ def app_setting(app, key, value=None, delete=False): value=yaml.load(value) app_settings[key] = value - with open(os.path.join( - apps_setting_path, app, 'settings.yml'), 'w') as f: - yaml.safe_dump(app_settings, f, default_flow_style=False) + _set_app_settings(app, app_settings) def app_checkport(port): @@ -1019,6 +1020,18 @@ def _get_app_settings(app_id): app=app_id)) return {} +def _set_app_settings(app_id, app_settings): + """ + Set settings of an app + + Keyword arguments: + app_id -- The app id + app_settings -- A dictionary of app settings + + """ + with open(os.path.join( + apps_setting_path, app_id, 'settings.yml'), 'w') as f: + yaml.safe_dump(app_settings, f, default_flow_style=False) def _get_app_status(app_id, format_date=False): """ From cdaceb52b8530cbcfaa9857cc2d2f328ab1c5e10 Mon Sep 17 00:00:00 2001 From: zamentur Date: Sun, 14 Feb 2016 03:26:12 +0100 Subject: [PATCH 2/2] [enh] Display friom which store come an app --- src/yunohost/app.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/yunohost/app.py b/src/yunohost/app.py index e739e1225..4bc800168 100644 --- a/src/yunohost/app.py +++ b/src/yunohost/app.py @@ -148,8 +148,12 @@ def app_list(offset=None, limit=None, filter=None, raw=False): for applist in applists: if '.json' in applist: + list_name=applist.split('.json', 1)[0] with open(repo_path +'/'+ applist) as json_list: - app_dict.update(json.loads(str(json_list.read()))) + list_content=json.loads(str(json_list.read())) + for k in list_content.keys(): + list_content[k]['store']=list_name + app_dict.update(list_content) for app in os.listdir(apps_setting_path): if app not in app_dict: @@ -1026,7 +1030,7 @@ def _set_app_settings(app_id, app_settings): Keyword arguments: app_id -- The app id - app_settings -- A dictionary of app settings + app_settings -- A dictionary of app settings """ with open(os.path.join(