1
- import ugfx , badge , network , gc , time , urequests , appglue
1
+ import ugfx , badge , network , gc , time , urequests , appglue , sys
2
2
3
3
# SHA2017 Badge installer
4
4
# V2 Thomas Roos
@@ -71,10 +71,19 @@ def list_apps(slug):
71
71
ugfx .flush (ugfx .LUT_FULL )
72
72
73
73
try :
74
- f = urequests .get ("https://badge.sha2017.org/eggs/category/%s/json" % slug )
75
- packages = f .json ()
76
- finally :
77
- f .close ()
74
+ f = urequests .get ("https://badge.sha2017.org/eggs/category/%s/json" % slug , timeout = 30 )
75
+ try :
76
+ packages = f .json ()
77
+ finally :
78
+ f .close ()
79
+ except BaseException as e :
80
+ print ("[Installer] Failed to download list of eggs:" )
81
+ sys .print_exception (e )
82
+ text .text ("Download failed" )
83
+ ugfx .flush (ugfx .LUT_FULL )
84
+ list_categories ()
85
+ gc .collect ()
86
+ return
78
87
79
88
for package in packages :
80
89
options .add_item ("%s rev. %s" % (package ["name" ], package ["revision" ]))
@@ -87,6 +96,7 @@ def list_apps(slug):
87
96
ugfx .input_attach (ugfx .BTN_START , lambda pushed : appglue .start_app ('' ) if pushed else False )
88
97
89
98
show_description (True )
99
+ ugfx .flush (ugfx .LUT_FULL )
90
100
gc .collect ()
91
101
92
102
def start_categories (pushed ):
@@ -145,7 +155,7 @@ def list_categories():
145
155
ugfx .input_init ()
146
156
draw_msg ('Getting categories' )
147
157
try :
148
- f = urequests .get ("https://badge.sha2017.org/eggs/categories/json" )
158
+ f = urequests .get ("https://badge.sha2017.org/eggs/categories/json" , timeout = 30 )
149
159
categories = f .json ()
150
160
except :
151
161
draw_msg ('Failed!' )
0 commit comments