@@ -50,8 +50,8 @@ def wrapper(*args):
5050_ = gettext .gettext
5151
5252# Constants
53- ICE_DIR = os .path .expanduser ("~/.local/share /ice" )
54- APPS_DIR = os .path .expanduser ("~/.local/share /applications" )
53+ ICE_DIR = os .path .expanduser ("/home/jannik/Programmieren/Python/LinuxMint/Local_Files /ice" )
54+ APPS_DIR = os .path .expanduser ("/home/jannik/Programmieren/Python/LinuxMint/Local_Files /applications" )
5555PROFILES_DIR = os .path .join (ICE_DIR , "profiles" )
5656FIREFOX_PROFILES_DIR = os .path .join (ICE_DIR , "firefox" )
5757FIREFOX_FLATPAK_PROFILES_DIR = os .path .expanduser ("~/.var/app/org.mozilla.firefox/data/ice/firefox" )
@@ -561,7 +561,7 @@ def export_webapps(callback, path):
561561 print (e )
562562 result = "error"
563563
564- callback ( result , "export" , path )
564+ GLib . idle_add ( callback , result , "export" , path )
565565
566566@_async
567567def import_webapps (callback , path ):
@@ -576,12 +576,15 @@ def import_webapps(callback, path):
576576 if file .startswith ("applications/" ):
577577 # Rewrite the "Exec" section. It will apply the new paths and will search for browsers
578578 path = os .path .join (base_dir , file )
579- update_imported_desktop (path )
579+ result = update_imported_desktop (path )
580+ if result == "error" :
581+ tar .close ()
582+ break
580583 except Exception as e :
581584 print (e )
582585 result = "error"
583586
584- callback ( result , "import" , path )
587+ GLib . idle_add ( callback , result , "import" , path )
585588
586589
587590def get_all_desktop_files ():
@@ -601,35 +604,39 @@ def get_codename(path):
601604 return codename
602605
603606def update_imported_desktop (path ):
604- webapp = WebAppLauncher (path , get_codename (path ))
605- if "/" in webapp .icon :
606- # Update Icon Path
607- iconpath = os .path .join (ICONS_DIR , os .path .basename (webapp .icon ))
608- else :
609- iconpath = webapp .icon
610-
611- # Check if the browser is installed
612- browsers = WebAppManager .get_supported_browsers ()
613- configured_browser = next ((browser for browser in browsers if browser .name == webapp .web_browser ), None )
614- if os .path .exists (configured_browser .test_path ) == False :
615- # If the browser is not installed, search another browser.
616- # 1. Sort browsers by same browser type
617- # 2. Sort the browsers by similarity of the name of the missing browser
618- similar_browsers = browsers
619- similar_browsers .sort (key = lambda browser : (
620- browser .browser_type == configured_browser .browser_type ,
621- configured_browser .name .split (" " )[0 ].lower () not in browser .name .lower ()
622- ))
623- configured_browser = None
624- for browser in similar_browsers :
625- if os .path .exists (browser .test_path ):
626- configured_browser = browser
627- break
628-
629- print (webapp .web_browser , "-Browser not installed" )
630-
631- WebAppManager .edit_webapp (WebAppManager , path , webapp .name , configured_browser , webapp .url , iconpath , webapp .category ,
632- webapp .custom_parameters , webapp .codename , webapp .isolate_profile , webapp .navbar , webapp .privatewindow )
607+ try :
608+ webapp = WebAppLauncher (path , get_codename (path ))
609+ if "/" in webapp .icon :
610+ # Update Icon Path
611+ iconpath = os .path .join (ICONS_DIR , os .path .basename (webapp .icon ))
612+ else :
613+ iconpath = webapp .icon
614+
615+ # Check if the browser is installed
616+ browsers = WebAppManager .get_supported_browsers ()
617+ configured_browser = next ((browser for browser in browsers if browser .name == webapp .web_browser ), None )
618+ if os .path .exists (configured_browser .test_path ) == False :
619+ # If the browser is not installed, search another browser.
620+ # 1. Sort browsers by same browser type
621+ # 2. Sort the browsers by similarity of the name of the missing browser
622+ similar_browsers = browsers
623+ similar_browsers .sort (key = lambda browser : (
624+ browser .browser_type == configured_browser .browser_type ,
625+ configured_browser .name .split (" " )[0 ].lower () not in browser .name .lower ()
626+ ))
627+ configured_browser = None
628+ for browser in similar_browsers :
629+ if os .path .exists (browser .test_path ):
630+ configured_browser = browser
631+ break
632+
633+ print (webapp .web_browser , "-Browser not installed" )
634+
635+ WebAppManager .edit_webapp (WebAppManager , path , webapp .name , configured_browser , webapp .url , iconpath , webapp .category ,
636+ webapp .custom_parameters , webapp .codename , webapp .isolate_profile , webapp .navbar , webapp .privatewindow )
637+ return "ok"
638+ except :
639+ return "error"
633640
634641if __name__ == "__main__" :
635642 download_favicon (sys .argv [1 ])
0 commit comments