@@ -153,14 +153,32 @@ def __init__(self, oeMain):
153153 'InfoText' : 715 ,
154154 'order' : 2 ,
155155 },
156- 'CheckUpdate ' : {
157- 'name' : 32362 ,
156+ 'Channel ' : {
157+ 'name' : 32015 ,
158158 'value' : '' ,
159- 'action' : 'manual_check_update' ,
160- 'type' : 'button' ,
161- 'InfoText' : 716 ,
159+ 'action' : 'set_channel' ,
160+ 'type' : 'multivalue' ,
161+ 'parent' : {
162+ 'entry' : 'AutoUpdate' ,
163+ 'value' : ['manual' ],
164+ },
165+ 'values' : [],
166+ 'InfoText' : 760 ,
162167 'order' : 3 ,
163168 },
169+ 'Build' : {
170+ 'name' : 32020 ,
171+ 'value' : '' ,
172+ 'action' : 'do_manual_update' ,
173+ 'type' : 'multivalue' ,
174+ 'parent' : {
175+ 'entry' : 'AutoUpdate' ,
176+ 'value' : ['manual' ],
177+ },
178+ 'values' : [],
179+ 'InfoText' : 761 ,
180+ 'order' : 4 ,
181+ },
164182 },
165183 },
166184 'backup' : {
@@ -316,6 +334,16 @@ def load_values(self):
316334 if os .path .isfile ('%s/SYSTEM' % self .LOCAL_UPDATE_DIR ):
317335 self .update_in_progress = True
318336
337+ # Manual Update
338+
339+ value = self .oe .read_setting ('system' , 'Channel' )
340+ if not value is None :
341+ self .struct ['update' ]['settings' ]['Channel' ]['value' ] = value
342+
343+ self .update_json = self .get_json ()
344+ self .struct ['update' ]['settings' ]['Channel' ]['values' ] = self .get_channels ()
345+ self .struct ['update' ]['settings' ]['Build' ]['values' ] = self .get_available_builds ()
346+
319347 # AutoUpdate = manual by environment var.
320348
321349 if os .path .exists ('/dev/.update_disabled' ):
@@ -425,14 +453,6 @@ def set_hostname(self, listItem=None):
425453 self .oe .set_busy (0 )
426454 self .oe .dbg_log ('system::set_hostname' , 'ERROR: (' + repr (e ) + ')' )
427455
428- def manual_check_update (self , listItem = None ):
429- try :
430- self .oe .dbg_log ('system::manual_check_update' , 'enter_function' , 0 )
431- self .check_updates_v2 (True )
432- self .oe .dbg_log ('system::manual_check_update' , 'exit_function' , 0 )
433- except Exception , e :
434- self .oe .dbg_log ('system::manual_check_update' , 'ERROR: (' + repr (e ) + ')' )
435-
436456 def set_auto_update (self , listItem = None ):
437457 try :
438458 self .oe .dbg_log ('system::set_auto_update' , 'enter_function' , 0 )
@@ -506,7 +526,7 @@ def get_keyboard_layouts(self):
506526 arrTypes = None
507527 else :
508528 self .oe .dbg_log ('system::get_keyboard_layouts' , 'exit_function (no keyboard layouts found)' , 0 )
509- return (None , None )
529+ return (None , None , None )
510530 self .oe .dbg_log ('system::get_keyboard_layouts' , 'exit_function' , 0 )
511531 return (
512532 arrLayouts ,
@@ -516,6 +536,73 @@ def get_keyboard_layouts(self):
516536 except Exception , e :
517537 self .oe .dbg_log ('system::get_keyboard_layouts' , 'ERROR: (' + repr (e ) + ')' )
518538
539+ def set_channel (self , listItem = None ):
540+ try :
541+ self .oe .dbg_log ('system::set_channel' , 'enter_function' , 0 )
542+ if not listItem == None :
543+ self .set_value (listItem )
544+ self .struct ['update' ]['settings' ]['Build' ]['values' ] = self .get_available_builds ()
545+ self .oe .dbg_log ('system::set_channel' , 'exit_function' , 0 )
546+ except Exception , e :
547+ self .oe .dbg_log ('system::set_channel' , 'ERROR: (' + repr (e ) + ')' )
548+
549+ def get_channels (self ):
550+ try :
551+ self .oe .dbg_log ('system::get_channels' , 'enter_function' , 0 )
552+ channels = []
553+ for channel in self .update_json :
554+ channels .append (channel )
555+ return channels
556+ self .oe .dbg_log ('system::get_channels' , 'exit_function' , 0 )
557+ except Exception , e :
558+ self .oe .dbg_log ('system::get_channels' , 'ERROR: (' + repr (e ) + ')' )
559+
560+ def do_manual_update (self , listItem = None ):
561+ try :
562+ self .oe .dbg_log ('system::do_manual_update' , 'enter_function' , 0 )
563+ if not listItem == None :
564+ self .struct ['update' ]['settings' ]['Build' ]['value' ] = listItem .getProperty ('value' )
565+ if self .struct ['update' ]['settings' ]['Build' ]['value' ] != '' :
566+ self .update_file = self .UPDATE_DOWNLOAD_URL % ('releases' , self .struct ['update' ]['settings' ]['Build' ]['value' ])
567+ xbmcDialog = xbmcgui .Dialog ()
568+ answer = xbmcDialog .yesno ('LibreELEC Update' , self .oe ._ (32188 ).encode ('utf-8' ) + ': ' + self .oe .VERSION ,
569+ self .oe ._ (32187 ).encode ('utf-8' ) + ': ' + self .struct ['update' ]['settings' ]['Build' ]['value' ].split ('-'
570+ )[- 1 ].replace ('.tar' , '' ).encode ('utf-8' ), self .oe ._ (32180 ).encode ('utf-8' ))
571+ xbmcDialog = None
572+ del xbmcDialog
573+ if answer :
574+ self .update_in_progress = True
575+ self .do_autoupdate ()
576+ self .struct ['update' ]['settings' ]['Build' ]['value' ] = ''
577+ self .oe .dbg_log ('system::do_manual_update' , 'exit_function' , 0 )
578+ except Exception , e :
579+ self .oe .dbg_log ('system::do_manual_update' , 'ERROR: (' + repr (e ) + ')' )
580+
581+ def get_json (self ):
582+ try :
583+ self .oe .dbg_log ('system::get_json' , 'enter_function' , 0 )
584+ url = self .UPDATE_DOWNLOAD_URL % ('releases' , 'releases.json' )
585+ update_json = json .loads (self .oe .load_url (url ))
586+ return update_json
587+ self .oe .dbg_log ('system::get_json' , 'exit_function' , 0 )
588+ except Exception , e :
589+ self .oe .dbg_log ('system::get_json' , 'ERROR: (' + repr (e ) + ')' )
590+
591+ def get_available_builds (self ):
592+ try :
593+ self .oe .dbg_log ('system::get_available_builds' , 'enter_function' , 0 )
594+ channel = self .struct ['update' ]['settings' ]['Channel' ]['value' ]
595+ update_files = []
596+ if channel != '' :
597+ if channel in self .update_json :
598+ for i in self .update_json [channel ]['project' ][self .oe .ARCHITECTURE ]['releases' ]:
599+ update_files .append (self .update_json [channel ]['project' ][self .oe .ARCHITECTURE ]['releases' ][i ]['file' ]['name' ])
600+
601+ return update_files
602+ self .oe .dbg_log ('system::get_available_builds' , 'exit_function' , 0 )
603+ except Exception , e :
604+ self .oe .dbg_log ('system::get_available_builds' , 'ERROR: (' + repr (e ) + ')' )
605+
519606 def check_updates_v2 (self , force = False ):
520607 try :
521608 self .oe .dbg_log ('system::check_updates_v2' , 'enter_function' , 0 )
@@ -536,23 +623,10 @@ def check_updates_v2(self, force=False):
536623 if update_json != '' :
537624 update_json = json .loads (update_json )
538625 self .last_update_check = time .time ()
539- silent = True
540- answer = 0
541626 if 'update' in update_json ['data' ] and 'folder' in update_json ['data' ]:
542627 self .update_file = self .UPDATE_DOWNLOAD_URL % (update_json ['data' ]['folder' ], update_json ['data' ]['update' ])
543628 if self .struct ['update' ]['settings' ]['UpdateNotify' ]['value' ] == '1' :
544629 self .oe .notify (self .oe ._ (32363 ).encode ('utf-8' ), self .oe ._ (32364 ).encode ('utf-8' ))
545- if self .struct ['update' ]['settings' ]['AutoUpdate' ]['value' ] == 'manual' and force == True :
546- silent = False
547- xbmcDialog = xbmcgui .Dialog ()
548- answer = xbmcDialog .yesno ('LibreELEC Update' , self .oe ._ (32188 ).encode ('utf-8' ) + ': ' + self .oe .VERSION ,
549- self .oe ._ (32187 ).encode ('utf-8' ) + ': ' + update_json ['data' ]['update' ].split ('-'
550- )[- 1 ].replace ('.tar' , '' ).encode ('utf-8' ), self .oe ._ (32180 ).encode ('utf-8' ))
551- xbmcDialog = None
552- del xbmcDialog
553- if answer == 1 :
554- self .update_in_progress = True
555- self .do_autoupdate ()
556630 if self .struct ['update' ]['settings' ]['AutoUpdate' ]['value' ] == 'auto' and force == False :
557631 self .update_in_progress = True
558632 self .do_autoupdate (None , True )
0 commit comments