mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
app_list()
This commit is contained in:
parent
fed9e529fd
commit
d26c545293
1 changed files with 20 additions and 10 deletions
|
@ -4,7 +4,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import json
|
import json
|
||||||
from urllib import urlopen, urlretrieve
|
from urllib import urlopen, urlretrieve
|
||||||
from yunohost import YunoHostError, YunoHostLDAP
|
from yunohost import YunoHostError, YunoHostLDAP, win_msg
|
||||||
|
|
||||||
def app_updatelist(url=None):
|
def app_updatelist(url=None):
|
||||||
"""
|
"""
|
||||||
|
@ -23,19 +23,29 @@ def app_updatelist(url=None):
|
||||||
try: os.listdir(app_path)
|
try: os.listdir(app_path)
|
||||||
except OSError: os.makedirs(app_path)
|
except OSError: os.makedirs(app_path)
|
||||||
|
|
||||||
if url: list_url = url
|
if not url: url = 'http://fapp.yunohost.org/app/list/raw'
|
||||||
else: list_url = 'http://fapp.yunohost.org/app/list/raw'
|
|
||||||
|
|
||||||
# Get list
|
# Get list
|
||||||
try: info_fetch = urlopen(list_url)
|
try: fetch = urlopen(url)
|
||||||
except IOError: info_fetch = False
|
except IOError: fetch = False
|
||||||
finally:
|
finally:
|
||||||
if info_fetch and (info_fetch.code == 200): urlretrieve(list_url, app_path + str(infos['lastUpdate']) + '.json')
|
if fetch and (fetch.code == 200): urlretrieve(url, app_path + 'list.json')
|
||||||
else: raise YunoHostError(1, _("List server connection failed"))
|
else: raise YunoHostError(1, _("List server connection failed"))
|
||||||
|
|
||||||
return True
|
win_msg(_("List updated successfully"))
|
||||||
|
|
||||||
|
|
||||||
def app_list(args):
|
def app_list(filter=None, fields=None, offset=None, limit=None):
|
||||||
info_dict = json.loads(str(info_fetch.read()))
|
with open('/var/cache/yunohost/apps/list.json') as json_list:
|
||||||
pass
|
app_dict = json.loads(str(json_list.read()))
|
||||||
|
|
||||||
|
list_dict = {}
|
||||||
|
|
||||||
|
for app_id, app_info in app_dict.items():
|
||||||
|
list_dict[app_id] = {
|
||||||
|
'Name': app_info['manifest']['name'],
|
||||||
|
'Version': app_info['manifest']['version'],
|
||||||
|
'Description': app_info['manifest']['description']
|
||||||
|
}
|
||||||
|
|
||||||
|
return list_dict
|
||||||
|
|
Loading…
Add table
Reference in a new issue