@@ -502,34 +502,40 @@ def get_device_status(self) -> tuple[str | None, str, str, str, str]:
502502 tuple: Beta status, old_update_engine, current version, version_id, backup version (in that order)
503503 """
504504 old_update_engine = True
505+ version_id = ""
506+ beta_contents = ""
505507
506508 if self .client :
507509 self .logger .debug ("Connecting to FTP" )
508510 ftp = self .client .open_sftp ()
509511 self .logger .debug ("Connected" )
510512
511513 xochitl_version , old_update_engine = self ._read_version_from_path (ftp )
514+ def exists (path :str ) -> bool :
515+ try :
516+ _ = ftp .stat (path )
517+ return True
518+ except (FileNotFoundError , IOError ):
519+ return False
512520
513- with ftp .file ("/etc/version" ) as file :
514- version_id = file .read ().decode ("utf-8" ).strip ("\n " )
521+ if exists ("/etc/version" ):
522+ with ftp .file ("/etc/version" ) as file :
523+ version_id = file .read ().decode ("utf-8" ).strip ("\n " )
515524
516- with ftp .file ("/home/root/.config/remarkable/xochitl.conf" ) as file :
517- beta_contents = file .read ().decode ("utf-8" )
525+ if exists ("/home/root/.config/remarkable/xochitl.conf" ):
526+ with ftp .file ("/home/root/.config/remarkable/xochitl.conf" ) as file :
527+ beta_contents = file .read ().decode ("utf-8" )
518528
519529 else :
520530 xochitl_version , old_update_engine = self ._read_version_from_path ()
521531
522532 if os .path .exists ("/etc/version" ):
523533 with open ("/etc/version" , encoding = "utf-8" ) as file :
524534 version_id = file .read ().rstrip ()
525- else :
526- version_id = ""
527535
528536 if os .path .exists ("/home/root/.config/remarkable/xochitl.conf" ):
529537 with open ("/home/root/.config/remarkable/xochitl.conf" , encoding = "utf-8" ) as file :
530538 beta_contents = file .read ().rstrip ()
531- else :
532- beta_contents = ""
533539
534540 beta_possible = re .search ("(?<=GROUP=).*" , beta_contents )
535541 beta = "Release"
0 commit comments