From 67cf68343b3056304b7dd0111da50ef23f52811e Mon Sep 17 00:00:00 2001 From: Kloadut Date: Tue, 12 Feb 2013 13:52:11 +0100 Subject: [PATCH] App system enhancement --- action_map.yml | 2 ++ parse_args | 10 +++++----- yunohost_app.py | 21 ++++++++++++++++++--- yunohost_domain.py | 4 ++-- 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/action_map.yml b/action_map.yml index 1c22a771..8a68a6a5 100644 --- a/action_map.yml +++ b/action_map.yml @@ -29,6 +29,8 @@ # ########################################################################## +# TODO: Add patern for all this + ############################# # General args # ############################# diff --git a/parse_args b/parse_args index c7f0a199..c1701740 100755 --- a/parse_args +++ b/parse_args @@ -190,11 +190,11 @@ def main(): result = args.func(**args_dict) else: result = args.func(**args_dict) - except TypeError, error: - if not __debug__ : - traceback.print_exc() - print(_("Not (yet) implemented function")) - return 1 + #except TypeError, error: + #if not __debug__ : + #traceback.print_exc() + #print(_("Not (yet) implemented function")) + #return 1 except YunoHostError, error: display_error(error) return error.code diff --git a/yunohost_app.py b/yunohost_app.py index ad0dc6b9..adb21e52 100644 --- a/yunohost_app.py +++ b/yunohost_app.py @@ -5,6 +5,7 @@ import sys import json from urllib import urlopen, urlretrieve from yunohost import YunoHostError, YunoHostLDAP, win_msg +from yunohost_domain import domain_list, domain_add def app_updatelist(url=None): """ @@ -25,6 +26,8 @@ def app_updatelist(url=None): if not url: url = 'http://fapp.yunohost.org/app/list/raw' + # TODO: Add multiple list support + # Get list try: fetch = urlopen(url) except IOError: fetch = False @@ -32,6 +35,8 @@ def app_updatelist(url=None): if fetch and (fetch.code == 200): urlretrieve(url, app_path + 'list.json') else: raise YunoHostError(1, _("List server connection failed")) + # TODO: Use system wget in order to have a status bar + win_msg(_("List updated successfully")) @@ -95,6 +100,8 @@ def app_install(app, domain=None, path=None, label=None, public=False, protected # TODO: Check if the app is already installed + # Fetch | Extract sources + install_tmp = '/tmp/yunohost/install' try: os.listdir(install_tmp) except OSError: os.makedirs(install_tmp) @@ -114,6 +121,9 @@ def app_install(app, domain=None, path=None, label=None, public=False, protected if extract_result != 0: raise YunoHostError(22, _("Invalid install file")) + with open(app_tmp_folder + '/manifest.webapp') as json_manifest: + manifest = json.loads(str(json_manifest.read())) + else: install_from_file = False app_tmp_folder = install_tmp +'/'+ app @@ -122,6 +132,7 @@ def app_install(app, domain=None, path=None, label=None, public=False, protected if app in app_dict: app_info = app_dict[app] + manifest = app_info['manifest'] else: raise YunoHostError(22, _("App doesn't exists")) @@ -131,12 +142,16 @@ def app_install(app, domain=None, path=None, label=None, public=False, protected if not git_result == git_result_2 == 0: raise YunoHostError(22, _("Sources fetching failed")) - - # TODO: Check if exists another instance - + # TODO: Create domain + try: + domain_list(filter="virtualdomain="+ domain) + except YunoHostError: + domain_add(domain=[domain]) + + # TODO: Install dependencies # TODO: Exec install script diff --git a/yunohost_domain.py b/yunohost_domain.py index 929d31a3..8954c790 100644 --- a/yunohost_domain.py +++ b/yunohost_domain.py @@ -32,8 +32,8 @@ def domain_list(filter=None, limit=None, offset=None): if result and len(result) > (0 + offset) and limit > 0: i = 0 + offset for domain in result[i:]: - if i < limit: - result_dict[str(i)] = domain['virtualdomain'] + if i <= limit: + result_dict[str(i)] = domain['virtualdomain'][0] i += 1 else: raise YunoHostError(167, _("No domain found"))