mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
App system enhancement
This commit is contained in:
parent
d902369b18
commit
67cf68343b
4 changed files with 27 additions and 10 deletions
|
@ -29,6 +29,8 @@
|
|||
#
|
||||
##########################################################################
|
||||
|
||||
# TODO: Add patern for all this
|
||||
|
||||
#############################
|
||||
# General args #
|
||||
#############################
|
||||
|
|
10
parse_args
10
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"))
|
||||
|
|
Loading…
Add table
Reference in a new issue