11#########################################################################################################
22# #
33# Buildstatus for openATV is a multiplatform tool (runs on Enigma2 & Windows and probably many others) #
4- # Coded by Mr.Servo @ openATV (c) 2023 #
4+ # Coded by Mr.Servo @ openATV (c) 2023-2025 #
55# Learn more about the tool by running it in the shell: "python Buildstatus.py -h" #
66# -----------------------------------------------------------------------------------------------------#
77# This plugin is licensed under the GNU version 3.0 <https://www.gnu.org/licenses/gpl-3.0.en.html>. #
@@ -38,7 +38,7 @@ def start(self): # loads json-platformdata from build server
3838 response = get ("http://api.mynonpublic.com/content.json" , timeout = (3.05 , 6 ))
3939 response .raise_for_status ()
4040 except exceptions .RequestException as err :
41- self .error = "[%s ] ERROR in module 'start': '%s" % ( MODULE_NAME , str (err ))
41+ self .error = f"[ { MODULE_NAME } ] ERROR in module 'start': '{ str (err )} "
4242 return {}
4343 try :
4444 dictdata = loads (response .text )
@@ -49,15 +49,15 @@ def start(self): # loads json-platformdata from build server
4949 archlist = []
5050 for arch in helplist : # separate dupes in platforms in "latest" and "oldest"
5151 if helplist .count (arch ) > 1 :
52- release = "oldest" if "%s_latest" % arch in archlist else "latest"
52+ release = "oldest" if f" { arch } _latest" in archlist else "latest"
5353 else :
5454 release = "latest"
55- archlist .append ("%s_%s" % ( arch .lower (), release ) )
55+ archlist .append (f" { arch .lower ()} _ { release } " )
5656 self .archlist = sorted (set (archlist ))
5757 return dictdata
58- self .error = "[%s ] ERROR in module 'start': server access failed." % MODULE_NAME
58+ self .error = f"[ { MODULE_NAME } ] ERROR in module 'start': server access failed."
5959 except Exception as err :
60- self .error = "[%s ] ERROR in module 'start': invalid json data from server. %s" % ( MODULE_NAME , str (err ))
60+ self .error = f"[ { MODULE_NAME } ] ERROR in module 'start': invalid json data from server. { str (err )} "
6161 return {}
6262
6363 def stop (self ):
@@ -68,22 +68,22 @@ def getpage(self): # loads html-imagedata from build server
6868 self .error = None
6969 if self .url :
7070 if self .callback :
71- print ("[%s ] accessing buildservers for data..." % MODULE_NAME )
71+ print (f"[ { MODULE_NAME } ] accessing buildservers for data..." )
7272 try :
7373 response = get (self .url , timeout = (3.05 , 6 ))
7474 response .raise_for_status ()
7575 except exceptions .RequestException as err :
76- self .error = "[%s ] ERROR in module 'getpage': '%s" % ( MODULE_NAME , str (err ))
76+ self .error = f"[ { MODULE_NAME } ] ERROR in module 'getpage': '{ str (err )} "
7777 return
7878 try :
7979 htmldata = response .text
8080 if htmldata :
8181 return htmldata
82- self .error = "[%s ] ERROR in module 'getpage': server access failed." % MODULE_NAME
82+ self .error = f"[ { MODULE_NAME } ] ERROR in module 'getpage': server access failed."
8383 except Exception as err :
84- self .error = "[%s ] ERROR in module 'getpage': invalid data from server %s" % ( MODULE_NAME , str (err ))
84+ self .error = f"[ { MODULE_NAME } ] ERROR in module 'getpage': invalid data from server { str (err )} "
8585 else :
86- self .error = "[%s ] ERROR in module 'getpage': missing url" % MODULE_NAME
86+ self .error = f"[ { MODULE_NAME } ] ERROR in module 'getpage': missing url"
8787
8888 def getbuildinfos (self , platform , callback = None ): # loads imagesdata from build server
8989 self .callback = callback
@@ -92,7 +92,7 @@ def getbuildinfos(self, platform, callback=None): # loads imagesdata from build
9292 self .url = self .platdict ["versionurls" ][platform ]["url" ]
9393 else :
9494 self .url = None
95- self .error = "[%s ] ERROR in module 'getbuildinfos': '%s" % ( MODULE_NAME , " invalid platform '%s'" % platform )
95+ self .error = f"[ { MODULE_NAME } ] ERROR in module 'getbuildinfos': invalid platform: { platform } )"
9696 return {}
9797 if callback :
9898 callInThread (self .createdict , callback )
@@ -119,10 +119,10 @@ def createdict(self, callback=None): # coordinates 'get html-imagesdata & creat
119119 self .htmldict = self .htmlparse (htmldata ) # complete dict of all platform boxes
120120 else :
121121 self .htmldict = None
122- self .error = "[%s ] ERROR in module 'createdict': htmldata is None." % MODULE_NAME
122+ self .error = f"[ { MODULE_NAME } ] ERROR in module 'createdict': htmldata is None."
123123 if callback :
124124 if not self .error :
125- print ("[%s ] buildservers successfully accessed..." % MODULE_NAME )
125+ print (f"[ { MODULE_NAME } ] buildservers successfully accessed..." )
126126 callback (None if self .error else self .htmldict )
127127 return None if self .error else self .htmldict
128128
@@ -162,7 +162,7 @@ def htmlparse(self, htmldata): # parse html-imagesdata & create imagesdict
162162
163163 def findbuildbox (self ): # find boxname current image is build for
164164 if self .htmldict is None :
165- self .error = "[%s ] ERROR in module 'findbuildbox': '%s" % ( MODULE_NAME , " self.htmldict is None")
165+ self .error = f"[ { MODULE_NAME } ] ERROR in module 'findbuildbox': self.htmldict is None"
166166 return
167167 hit = None
168168 boxinfo = self .htmldict ["boxinfo" ]
@@ -174,7 +174,7 @@ def findbuildbox(self): # find boxname current image is build for
174174
175175 def evaluate (self , box = None ): # evaluate box data
176176 if self .htmldict is None :
177- self .error = "[%s ] ERROR in module 'evaluate': '%s" % ( MODULE_NAME , " self.htmldict is None")
177+ self .error = f"[ { MODULE_NAME } ] ERROR in module 'evaluate': self.htmldict is None"
178178 return None , 0 , None , 0 , 0
179179 buildbox = self .findbuildbox ()
180180 boxinfo = self .htmldict ["boxinfo" ]
@@ -209,7 +209,7 @@ def evaluate(self, box=None): # evaluate box data
209209 failed += 1
210210 boxcounter += 1
211211 if box is not None and not foundbox :
212- self .error = "[%s ] WARNING in module 'evaluate': '%s'" % ( MODULE_NAME , " Box not found in this platform. Try another platform.")
212+ self .error = f"[ { MODULE_NAME } ] WARNING in module 'evaluate': Box not found in this platform. Try another platform."
213213 return timedelta (), 0 , cycletime , boxcounter , failed
214214 return nextbuild , boxesahead - 1 , cycletime , boxcounter , failed
215215
@@ -222,29 +222,20 @@ def strf_delta(self, td): # converts deltatime-format in hours (e.g. '2 days, 0
222222
223223def main (argv ): # shell interface
224224 mainfmt = "[__main__]"
225- buildbox = False
226- cycle = False
227- evaluate = False
228- verbose = False
229- architecture = False
230- supported = False
231- usable = False
232- filename = None
233- boxname = None
234- cycletime = None
225+ buildbox , cycle , evaluate , verbose , architecture , supported , usable = False , False , False , False , False , False , False
226+ filename , boxname , cycletime = None , None , None
235227 currarch = "arm_latest"
236228 currplat = ""
237- counter = 0
238- failed = 0
229+ counter , failed = 0 , 0
239230 helpstring = "Buildstatus v1.3: try 'python Buildstatus.py -h' for more information"
240231 BS = Buildstatus ()
241232 if BS .error :
242- print ("Error: %s" % BS .error .replace (mainfmt , "" ).strip ())
233+ print (f "Error: { BS .error .replace (mainfmt , '' ).strip ()} " )
243234 exit ()
244235 try :
245236 opts , args = getopt (argv , "a:p:j:e:bcvsuh" , ["architecture =" , "platform=" , "json =" , "evaluate =" , "buildbox" , "cycle" , "verbose" , "supported" , "usable" , "help" ])
246237 except GetoptError as error :
247- print ("Error: %s \n %s" % ( error , helpstring ) )
238+ print (f "Error: { error } \n { helpstring } " )
248239 exit (2 )
249240 if not opts :
250241 verbose = True
@@ -289,55 +280,55 @@ def main(argv): # shell interface
289280 if not currplat :
290281 currplat = BS .getplatform (currarch )
291282 if BS .error :
292- print ("Error: %s" % BS .error .replace (mainfmt , "" ).strip ())
283+ print (f "Error: { BS .error .replace (mainfmt , '' ).strip ()} " )
293284 exit ()
294285 if currarch not in archlist :
295- print ("Unknown architecture '%s '. Supported is: %s" % ( currarch , ", " .join (x .split (" " )[0 ] for x in archlist )) )
286+ print (f "Unknown architecture '{ currarch } '. Supported is: { ', ' .join (x .split (' ' )[0 ] for x in archlist )} " )
296287 exit ()
297288 if currplat :
298289 currplat = currplat .replace ("_" , " " )
299290 if currplat and currplat not in platlist :
300- print ("Unknown platform '%s'. Supported is: %s" % ( currplat .replace (" " , "_" ).lower (), ", " .join (x .replace (' ' , '_' ).lower () for x in platlist )) )
291+ print (f "Unknown platform '{ currplat .replace (' ' , '_' ).lower ()} '. Supported is: { ', ' .join (x .replace (' ' , '_' ).lower () for x in platlist )} " )
301292 exit ()
302293 BS .getbuildinfos (currplat )
303294 if BS .error :
304- print ("Error: %s" % BS .error .replace (mainfmt , "" ).strip ())
295+ print (f "Error: { BS .error .replace (mainfmt , '' ).strip ()} " )
305296 exit ()
306297 if BS .htmldict and verbose :
307298 separator = "+-----+--------------------+--------------------+--------------+----------------------+----------------------+----------------------+-----------+------------+"
308- row = "| {0 :<3} | {1 :<18} | {2 :<18} | {3 :<12} | {4 :<20} | {5 :<20} | {6 :<20} | {7 :<9} | {8 :<10} |"
309- print ("%s%s%s" % ( "+" , "-" * 156 , "+" ) )
310- print ("| {0:<155}|" . format ( BS .htmldict [" title" ]) )
299+ row = "| {:<3} | {:<18} | {:<18} | {:<12} | {:<20} | {:<20} | {:<20} | {:<9} | {:<10} |"
300+ print (f"+ { '-' * 156 } +" )
301+ print (f "| { BS .htmldict [' title' ]:<155 } |" )
311302 print (separator )
312303 print (row .format (* BS .htmldict ["headline" ].split (", " )))
313304 print (separator )
314305 for counter , box in enumerate (BS .htmldict ["boxinfo" ]):
315306 bi = BS .htmldict ["boxinfo" ][box ]
316307 print (row .format (bi ["No" ].rjust (3 ), box , bi ["OemName" ], bi ["BuildStatus" ].rjust (12 ), bi ["StartBuild" ], bi ["StartFeedSync" ], bi ["EndBuild" ], bi ["SyncTime" ].rjust (9 ), bi ["BuildTime" ].rjust (10 )))
317308 print (separator )
318- print ("| {0 :<50}{1 :<48}{2 :<57}|" .format ("current platform: %s" % currplat .upper (), "boxes found: %s" % counter , "building errors found: %s" % str (failed ).rjust (3 )))
319- print ("%s%s%s" % ( "+" , "-" * 156 , "+" ) )
309+ print ("| {:<50}{:<48}{:<57}|" .format (f "current platform: { currplat .upper ()} " , f "boxes found: { counter } " , f "building errors found: { str (failed ).rjust (3 )} " ))
310+ print (f"+ { '-' * 156 } +" )
320311 if BS .htmldict and filename :
321312 with open (filename , "w" ) as f :
322313 dump (BS .htmldict , f )
323- print ("File '%s ' was successfully created." % filename )
314+ print (f "File '{ filename } ' was successfully created." )
324315 if buildbox :
325316 buildboxname = BS .findbuildbox ()
326317 if BS .error :
327- print ("Error: %s" % BS .error .replace (mainfmt , "" ).strip ())
318+ print (f "Error: { BS .error .replace (mainfmt , '' ).strip ()} " )
328319 exit ()
329320 if buildboxname :
330- print ("Currently the image is built for: '%s'" % buildboxname )
321+ print (f "Currently the image is built for: '{ buildboxname } '" )
331322 else :
332323 print ("At the moment no image is built on the platform!" )
333324 if evaluate :
334325 if boxname :
335326 nextbuild , boxesahead , cycletime , counter , failed = BS .evaluate (boxname )
336327 if BS .error :
337- print ("Error: %s" % BS .error .replace (mainfmt , "" ).strip ())
328+ print (f "Error: { BS .error .replace (mainfmt , '' ).strip ()} " )
338329 exit ()
339330 if nextbuild :
340- print ("Estimated duration for next image for '%s ' in %sh at %s (%s boxes ahead) " % ( boxname , BS .strf_delta (nextbuild ), (datetime .now () + nextbuild ).strftime (" %Y/%m/%d, %H:%M:%S" ), boxesahead ) )
331+ print (f "Estimated duration for next image for '{ boxname } ' in { BS .strf_delta (nextbuild )} h at { (datetime .now () + nextbuild ).strftime (' %Y/%m/%d, %H:%M:%S' ) } ( { boxesahead } boxes ahead) " )
341332 else :
342333 print ("Server paused, unclear how many boxes are ahead!" )
343334 else :
@@ -347,17 +338,17 @@ def main(argv): # shell interface
347338 if not cycletime :
348339 nextbuild , boxesahead , cycletime , counter , failed = BS .evaluate ()
349340 if BS .error :
350- print ("Error: %s" % BS .error .replace (mainfmt , "" ).strip ())
341+ print (f "Error: { BS .error .replace (mainfmt , '' ).strip ()} " )
351342 exit ()
352- print ("Estimated durance of complete cycle (%s ): %s h" % ( currplat , BS .strf_delta (cycletime )) )
343+ print (f "Estimated durance of complete cycle ({ currplat } ): { BS .strf_delta (cycletime )} h" )
353344 if supported :
354345 if not architecture and archlist :
355- print ("Available architectures: %s" % ", " .join (x for x in archlist ))
346+ print (f "Available architectures: { ', ' .join (x for x in archlist )} " )
356347 else :
357348 print ("No architectures found" )
358349 if usable :
359350 if platlist :
360- print ("Available platforms: %s" % ", " .join (x . lower (). replace ( " " , "_" ) for x in platlist ) )
351+ print (f "Available architectures: { ', ' .join (x for x in archlist ) } " )
361352 else :
362353 print ("No platforms found" )
363354
0 commit comments