@@ -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" )
@@ -567,7 +567,7 @@ def export_webapps(callback, path):
567567 print (e )
568568 result = "error"
569569
570- callback ( result , "export" , path )
570+ GLib . idle_add ( callback , result , "export" , path )
571571
572572@_async
573573def import_webapps (callback , path ):
@@ -582,12 +582,15 @@ def import_webapps(callback, path):
582582 if file .startswith ("applications/" ):
583583 # Rewrite the "Exec" section. It will apply the new paths and will search for browsers
584584 path = os .path .join (base_dir , file )
585- update_imported_desktop (path )
585+ result = update_imported_desktop (path )
586+ if result == "error" :
587+ tar .close ()
588+ break
586589 except Exception as e :
587590 print (e )
588591 result = "error"
589592
590- callback ( result , "import" , path )
593+ GLib . idle_add ( callback , result , "import" , path )
591594
592595
593596def get_all_desktop_files ():
@@ -607,35 +610,39 @@ def get_codename(path):
607610 return codename
608611
609612def update_imported_desktop (path ):
610- webapp = WebAppLauncher (path , get_codename (path ))
611- if "/" in webapp .icon :
612- # Update Icon Path
613- iconpath = os .path .join (ICONS_DIR , os .path .basename (webapp .icon ))
614- else :
615- iconpath = webapp .icon
616-
617- # Check if the browser is installed
618- browsers = WebAppManager .get_supported_browsers ()
619- configured_browser = next ((browser for browser in browsers if browser .name == webapp .web_browser ), None )
620- if os .path .exists (configured_browser .test_path ) == False :
621- # If the browser is not installed, search another browser.
622- # 1. Sort browsers by same browser type
623- # 2. Sort the browsers by similarity of the name of the missing browser
624- similar_browsers = browsers
625- similar_browsers .sort (key = lambda browser : (
626- browser .browser_type == configured_browser .browser_type ,
627- configured_browser .name .split (" " )[0 ].lower () not in browser .name .lower ()
628- ))
629- configured_browser = None
630- for browser in similar_browsers :
631- if os .path .exists (browser .test_path ):
632- configured_browser = browser
633- break
634-
635- print (webapp .web_browser , "-Browser not installed" )
636-
637- WebAppManager .edit_webapp (WebAppManager , path , webapp .name , configured_browser , webapp .url , iconpath , webapp .category ,
638- webapp .custom_parameters , webapp .codename , webapp .isolate_profile , webapp .navbar , webapp .privatewindow )
613+ try :
614+ webapp = WebAppLauncher (path , get_codename (path ))
615+ if "/" in webapp .icon :
616+ # Update Icon Path
617+ iconpath = os .path .join (ICONS_DIR , os .path .basename (webapp .icon ))
618+ else :
619+ iconpath = webapp .icon
620+
621+ # Check if the browser is installed
622+ browsers = WebAppManager .get_supported_browsers ()
623+ configured_browser = next ((browser for browser in browsers if browser .name == webapp .web_browser ), None )
624+ if os .path .exists (configured_browser .test_path ) == False :
625+ # If the browser is not installed, search another browser.
626+ # 1. Sort browsers by same browser type
627+ # 2. Sort the browsers by similarity of the name of the missing browser
628+ similar_browsers = browsers
629+ similar_browsers .sort (key = lambda browser : (
630+ browser .browser_type == configured_browser .browser_type ,
631+ configured_browser .name .split (" " )[0 ].lower () not in browser .name .lower ()
632+ ))
633+ configured_browser = None
634+ for browser in similar_browsers :
635+ if os .path .exists (browser .test_path ):
636+ configured_browser = browser
637+ break
638+
639+ print (webapp .web_browser , "-Browser not installed" )
640+
641+ WebAppManager .edit_webapp (WebAppManager , path , webapp .name , configured_browser , webapp .url , iconpath , webapp .category ,
642+ webapp .custom_parameters , webapp .codename , webapp .isolate_profile , webapp .navbar , webapp .privatewindow )
643+ return "ok"
644+ except :
645+ return "error"
639646
640647if __name__ == "__main__" :
641648 download_favicon (sys .argv [1 ])
0 commit comments