Changeset 6693
- Timestamp:
- Jan 25, 2018, 4:47:53 PM (3 years ago)
- Location:
- lliurex-store/trunk/fuentes/python3-lliurex-store.install/usr/share/lliurexstore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
lliurex-store/trunk/fuentes/python3-lliurex-store.install/usr/share/lliurexstore/plugins/appImageManager.py
r6645 r6693 20 20 self.progress=0 21 21 self.partial_progress=0 22 #This dict defines wich package_type relies on what action23 #action=example24 #package='*' (in this case all packages)25 22 self.plugin_actions={'install':'appimage','remove':'appimage','pkginfo':'appimage','load':'appimage'} 26 23 self.result={} … … 89 86 #def _set_status 90 87 91 def _callback(self,partial Size=0,totalSize=0):88 def _callback(self,partial_size=0,total_size=0): 92 89 limit=99 93 if partial Size!=0 and totalSize!=0:94 inc=round(partial Size/totalSize,2)*10090 if partial_size!=0 and total_size!=0: 91 inc=round(partial_size/total_size,2)*100 95 92 self.progress=inc 96 93 else: -
lliurex-store/trunk/fuentes/python3-lliurex-store.install/usr/share/lliurexstore/plugins/debManager.py
r6645 r6693 7 7 self.installer='' 8 8 self.dbg=False 9 self.pkgList=[]10 9 self.result=[] 11 10 self.progress=0 … … 38 37 39 38 def execute_action(self,action,applist): 40 self._debug("Applist: "+str(applist))41 39 self.progress=0 42 40 self.installer=packagekit.Client() -
lliurex-store/trunk/fuentes/python3-lliurex-store.install/usr/share/lliurexstore/plugins/infoManager.py
r6645 r6693 3 3 class infomanager: 4 4 def __init__(self): 5 self.dbg=True 6 self.pluginInfo={'get_info':'*'} 7 # self.pluginInfo={'info':'*','get_info':'*'} 5 self.dbg=False 6 self.plugin_actions={'get_info':'*'} 8 7 self.result={} 9 8 self.result['status']={'status':-1,'msg':''} … … 25 24 26 25 def register(self): 27 return(self.plugin Info)26 return(self.plugin_actions) 28 27 #def register 29 28 … … 103 102 break 104 103 else: 105 #If there's no icon set empty icon path 106 appInfo['icon']="" 107 # if app.get_icon_default(): 108 # appInfo['icon']=appInfo['icon']+'/'+app.get_icon_default().get_name() 104 appInfo['icon']='' 109 105 110 106 if app.get_screenshots(): … … 153 149 if 'embed' not in appInfo['video']: 154 150 appInfo['video']=appInfo['video'].replace('watch?v=','embed/') 155 #F***g appstream returns unknown for all the possible types151 #F***g appstream returns unknown for all the possible kinds 156 152 # if app.get_bundle_default(): 157 153 # appInfo['bundle']=app.get_bundle_default().get_kind() 158 #Fix F***g appstream returns unknown for all the possible types154 #Fix F***g appstream returns unknown for all the possible kinds 159 155 #ID must contain bundle type as last field 160 156 for bundle in app.get_bundles(): -
lliurex-store/trunk/fuentes/python3-lliurex-store.install/usr/share/lliurexstore/plugins/loadStore.py
r6645 r6693 52 52 if action=='load_bundles': 53 53 self._load_store(self.store,loadBundles=True) 54 # self.progress=10055 54 self.result['data']=self.store 56 55 self.progress=100 57 56 return(self.result) 58 # return (self.store)59 57 #def execute_action 60 58 … … 91 89 if target_file.endswith('appdata.xml'): 92 90 store_file=Gio.File.new_for_path(target_dir+'/'+target_file) 93 self._debug("Adding file "+target_dir+'/'+target_file)91 self._debug("Adding file %s/%s"%(target_dir,target_file)) 94 92 try: 95 93 store.from_file(store_file,icon_dir,None) 96 94 except Exception as e: 97 self._debug("Couldn't add file "+target_file+" to store")98 self._debug("Reason: "+str(e))95 self._debug("Couldn't add file %s to store"%target_file) 96 self._debug("Reason: %s"%e) 99 97 return(store) 100 98 … … 111 109 a.remove_veto(veto) 112 110 store.add_app(a) 113 self._debug("Adding app from desktop "+desktop_file)111 self._debug("Adding app from desktop %s"%desktop_file) 114 112 except: 115 113 pass … … 125 123 #Zomandos get max priority 126 124 if app.has_category('Zomando'): 127 self._debug("Prioritize zmd "+str(app.get_id()))125 self._debug("Prioritize zmd %s"%app.get_id()) 128 126 app.set_priority(400) 129 127 lliurex_apps.update({app.get_id_filename():app}) … … 132 130 #Prioritize Lliurex apps 133 131 elif app.has_category('Lliurex'): 134 self._debug("Prioritize app "+str(app.get_id()))132 self._debug("Prioritize app %s"%app.get_id()) 135 133 app.set_priority(200) 136 134 lliurex_apps.update({app.get_id_filename():app}) 137 135 elif str(app.get_origin()).find('lliurex')>=0: 138 self._debug("Prioritize app "+app.get_id())136 self._debug("Prioritize app %s"%app.get_id()) 139 137 app.set_priority(100) 140 138 lliurex_apps.update({app.get_id_filename():app}) … … 142 140 app.set_priority(0) 143 141 if app.get_id_filename() in lliurex_apps.keys(): 144 self._debug("Mergin app "+str(app.get_id())+" as is in Lliurex")142 self._debug("Mergin app %s as is in LliureX"%app.get_id()) 145 143 lliurex_apps[app.get_id_filename()].subsume_full(app,appstream.AppSubsumeFlags.BOTH_WAYS) 146 144 store.remove_app(app) … … 150 148 #Remove add-on apps (as are included in the main packages) 151 149 if app.get_kind()==appstream.AppKind.ADDON: 152 self._debug("Removed addon "+str(app.get_pkgnames()))150 self._debug("Removed addon %s"%app.get_pkgnames()) 153 151 store.remove_app(app) 154 152 #Remove duplicated apps … … 157 155 if pkg in tmp_store_apps.keys(): 158 156 fn=app.get_id_no_prefix() 159 self._debug("Comparing "+fn+" with "+tmp_store_apps[pkg]['fn'])157 self._debug("Comparing %s with %s"%(fn,tmp_store_apps[pkg]['fn'])) 160 158 if fn != tmp_store_apps[pkg]['fn']: 161 159 if fn != pkg and ".desktop" not in fn: 162 self._debug("Removed duplicated "+app.get_id())160 self._debug("Removed duplicated %s"%app.get_id()) 163 161 store.remove_app(app) 164 162 else: 165 self._debug("Removed duplicated "+tmp_store_apps[pkg]['app'].get_id())163 self._debug("Removed duplicated %s"%tmp_store_apps[pkg]['app'].get_id()) 166 164 store.remove_app(tmp_store_apps[pkg]['app']) 167 165 tmp_store_apps.update({pkg:{'fn':app.get_id_no_prefix(),'app':app}}) … … 178 176 def _purge_zomandos(self,zmd_apps,store): 179 177 for zmd_id in zmd_apps: 180 self._debug("Searching debs related to "+zmd_id)178 self._debug("Searching debs related to %s"%zmd_id) 181 179 purge_list=store.get_apps_by_id(zmd_id) 182 180 purge_list.extend(store.get_apps_by_id(zmd_id+".desktop")) … … 184 182 if purge_app: 185 183 if not purge_app.has_category('Zomando'): 186 self._debug("Removed related zomando app "+str(purge_app.get_id()))184 self._debug("Removed related zomando app %s"%purge_app.get_id()) 187 185 store.remove_app(purge_app) 188 186 return(store) … … 222 220 store.remove_app(app) 223 221 else: 224 self._debug("App "+blacklist_app+" from blacklist not found in store. Assigned to RE blacklist")222 self._debug("App %s from blacklist not found in store. Assigned to RE blacklist"%blacklist_app) 225 223 blacklist_re.append("("+blacklist_app+")") 226 224 if blacklist_re: … … 231 229 if re_result: 232 230 store.remove_app(app) 233 self._debug("Removed "+str(app.get_id()) +" as matches with "+blacklist_app)231 self._debug("Removed %s as matches with %s"%(app.get_id(),blacklist_app)) 234 232 else: 235 233 self._debug('No blacklist to check') 236 234 except Exception as e: 237 self._debug("Error processing blacklist: "+str(e))235 self._debug("Error processing blacklist: %s"%e) 238 236 finally: 239 237 return(store) -
lliurex-store/trunk/fuentes/python3-lliurex-store.install/usr/share/lliurexstore/plugins/searchManager.py
r6645 r6693 21 21 return (self.applist) 22 22 23 def set_debug(self,dbg ):23 def set_debug(self,dbg=True): 24 24 self.dbg=dbg 25 25 self._debug ("Debug enabled") … … 35 35 36 36 def execute_action(self,appstreamStore,action,tokens,exact_match_for_search=False,max_results=0): 37 self._debug("Executing action %s"%action) 38 self._debug("Tokens: %s"%tokens) 37 39 self.progress=0 38 if not type(tokens) is str: 40 if type(tokens)==type([]): 41 tokens=' '.join(tokens) 42 if type(tokens) is str: 43 tokens=tokens.lower() 44 else: 39 45 tokens='' 40 else:41 tokens=tokens.lower()42 46 if len(tokens.split(' '))>1: 43 47 if action=='search': … … 75 79 applist=[] 76 80 app=None 77 if len(tokens)==1: 81 # if len(tokens)==1: 82 if exact_match: 78 83 app=self._app_exists(tokens[0]) 79 84 if app: … … 149 154 applist_2.append(app) 150 155 else: 151 print("*************")152 156 print("Removing %s"%app.get_pkgname()) 153 print("*************")154 157 applist=applist_2 155 158 # for app in applist: … … 202 205 score=app.search_matches(token) 203 206 if score>=self.precision: 204 if "appimage" in app.get_id().lower():205 score=1207 # if "appimage" in app.get_id().lower(): 208 # score=1 206 209 if score in tmp_app_dict: 207 210 tmp_app_dict[score].append(app) 208 211 else: 209 212 tmp_app_dict[score]=[app] 210 for match in sorted(tmp_app_dict): 213 fake_app=[] 214 for match in sorted(tmp_app_dict.keys()): 211 215 for app in tmp_app_dict[match]: 212 216 if app not in applist: 213 217 self._debug("Adding app "+app.get_id() + " with score: "+str(match)) 214 applist.insert( 1,app)218 applist.insert(0,app) 215 219 return(applist) 216 220 -
lliurex-store/trunk/fuentes/python3-lliurex-store.install/usr/share/lliurexstore/plugins/shManager.py
r6645 r6693 21 21 #def __init__ 22 22 23 def set_debug(self,dbg ):23 def set_debug(self,dbg=True): 24 24 self.dbg=dbg 25 25 self._debug ("Debug enabled") -
lliurex-store/trunk/fuentes/python3-lliurex-store.install/usr/share/lliurexstore/plugins/snapManager.py
r6645 r6693 101 101 102 102 def _load_snap_store(self,store): 103 try: 104 for pkg in self._search_snap("*"): 105 store.add_app(self._generate_appstream_app(pkg)) 106 except: 107 self._set_status(1) 103 pkgs=[] 104 if self.cli_mode: 105 pkgs=self._search_snap("*") 106 else: 107 pkgs=self._search_snap_async("*") 108 self._set_status(1) 109 for pkg in pkgs: 110 store.add_app(self._generate_appstream_app(pkg)) 108 111 return(store) 109 112 … … 148 151 None, 149 152 self._search_cb,(None,),None) 150 time.sleep(0.5) 153 while 'Snapd' not in str(type(wrap)): 154 time.sleep(0.1) 151 155 snaps=self.snap_client.find_finish(wrap) 152 156 if type(snaps)!=type([]): … … 154 158 else: 155 159 pkgs=snaps 156 return(pkgs) 160 stable_pkgs=[] 161 for pkg in pkgs: 162 if pkg.get_channel()=='stable': 163 stable_pkgs.append(pkg) 164 return(stable_pkgs) 157 165 158 166 def _search_snap(self,tokens): … … 160 168 pkg=None 161 169 try: 162 pkg =self.snap_client.find_sync(Snapd.FindFlags.MATCH_NAME,tokens,None,None)170 pkgs=self.snap_client.find_sync(Snapd.FindFlags.MATCH_NAME,tokens,None,None) 163 171 except Exception as e: 164 172 print(e) 165 173 self._set_status(1) 174 stable_pkgs=[] 175 for pkg in pkgs: 176 if pkg.get_channel()=='stable': 177 stable_pkgs.append(pkg) 166 178 self._debug("Done") 167 return( pkg)179 return(stable_pkgs) 168 180 #def _search_snap 169 181 … … 193 205 def _get_info(self,app_info): 194 206 #switch to launch async method when running under a gui 195 #For an unknown re quest will block when sync mode under a gui207 #For an unknown reason request will block when sync mode under a gui and async blocks when on cli (really funny) 196 208 if self.cli_mode: 197 209 pkgs=self._search_snap(app_info['name']) … … 223 235 screenshot_list.append(screen.get_url()) 224 236 app_info["screenshots"]=screenshot_list 225 print (pkg.get_channel())226 237 #Method not working in xenial, license default type assigned in infoManager 227 238 # if pkg.get_license(): -
lliurex-store/trunk/fuentes/python3-lliurex-store.install/usr/share/lliurexstore/plugins/zmdManager.py
r6645 r6693 73 73 def _set_status(self,status,msg=''): 74 74 self.result['status']={'status':status,'msg':msg} 75 # dataList['status']={'status':status,'msg':msg}76 75 77 76 def _callback(self,zmd_launcher): … … 96 95 err=0 97 96 try: 98 # zmd_sudo=['gksudo',zmd]99 97 zmd_sudo=['pe',zmd] 100 98 self._debug("executing "+str(zmd_sudo)) … … 202 200 except Exception as e: 203 201 self._set_status(10) 204 # self.result['data'].append(app_info)205 # self.result.append(app_info)206 202 return(app_info) 207 203 #def _get_Zmd_Info -
lliurex-store/trunk/fuentes/python3-lliurex-store.install/usr/share/lliurexstore/storeManager.py
r6645 r6693 16 16 17 17 class StoreManager(): 18 # def __init__(self,snap=False,appimage=False,dbg=False): 19 def __init__(self,**kwargs): 18 def __init__(self,*args,**kwargs): 20 19 self.dbg=False 21 20 if 'dbg' in kwargs.keys(): … … 33 32 } 34 33 self.cli_mode=[] #List that controls cli_mode for plugins 35 self.threads={} #Dict that storesthe functions that must execute each action34 self.threads={} #Dict with the functions that must execute each action 36 35 self.threads_progress={} #"" "" "" the progress for each launched thread 37 36 self.running_threads={} #"" "" "" the running threads 38 self.plugins_registered={} #Dict that havethe relation between plugins and actions39 self.register_action_progress={} #Dict that storesthe progress for each function/parent_action pair37 self.plugins_registered={} #Dict with the relation between plugins and actions 38 self.register_action_progress={} #Dict with the progress for each function/parent_action pair 40 39 self.action_progress={} #Progress of global actions based on average progress of individual processes 41 self.extra_actions={} #Dict that havethe actions managed by plugins and no defined on the main class as related_actions40 self.extra_actions={} #Dict with the actions managed by plugins and no defined on the main class as related_actions 42 41 self.result={} #Result of the actions 43 42 self.lock=threading.Lock() #locker for functions related to threads (get_progress, is_action_running...) 44 self.main( kwargs)43 self.main(**kwargs) 45 44 #def __init__ 46 45 47 def main(self, args={}):46 def main(self,**kwargs): 48 47 self._define_functions_for_threads() #Function that loads the dictionary self.threads 49 self.__init_plugins__( args) #Function that loads the plugins48 self.__init_plugins__(**kwargs) #Function that loads the plugins 50 49 self.execute_action('load') #Initial load of the store 51 50 #def main … … 54 53 #Load and register the plugins from plugin dir 55 54 #### 56 def __init_plugins__(self, args={}):55 def __init_plugins__(self,**kwargs): 57 56 package=plugins 58 57 for importer, mod, ispkg in pkgutil.walk_packages(path=package.__path__, prefix=package.__name__+'.',onerror=lambda x: None): 59 import_mod='from '+mod+' import *'58 import_mod='from %s import *'%mod 60 59 try: 61 self._debug("Importing "+str(mod))60 self._debug("Importing %s"%mod) 62 61 exec (import_mod) 63 62 except Exception as e: 64 print(str(e)) 63 print("Import failed for %s"%mod) 64 print("Reason; %s"%e) 65 65 66 66 for mod in (sys.modules.keys()): … … 69 69 plugin_name_up=mod.split('.')[-1] 70 70 plugin_name=plugin_name_up.lower() 71 self._debug("Initializing "+str(plugin_name))71 self._debug("Initializing %s"%plugin_name) 72 72 sw_cli_mode=False 73 73 try: … … 83 83 val=value 84 84 break 85 if val in args.keys():86 if args[val]==True:85 if val in kwargs.keys(): 86 if kwargs[val]==True: 87 87 if target_class.disabled: 88 88 self._debug("Disabling plugin %s"%plugin_name) … … 95 95 continue 96 96 if 'cli_mode' in target_class.__dict__.keys(): 97 if 'cli' in args.keys():97 if 'cli' in kwargs.keys(): 98 98 sw_cli_mode=True 99 99 self._debug("Enabling cli mode for %s"%plugin_name) 100 100 except Exception as e: 101 print ("Can't initialize "+str(mod)+' '+str(target_class))102 print ("Reason: "+str(e))101 print ("Can't initialize %s %s"%(mod,target_class)) 102 print ("Reason: %s"%e) 103 103 pass 104 104 … … 121 121 def _debug(self,msg=''): 122 122 if self.dbg==1: 123 print ('DEBUG Store: '+msg)123 print ('DEBUG Store: %s'%msg) 124 124 #def _debug 125 125 … … 134 134 def _define_functions_for_threads(self): 135 135 self.threads['load']="threading.Thread(target=self._load_Store)" 136 # self.threads['load_bundles']="threading.Thread(target=self._load_Store)" 137 self.threads['get_info']="threading.Thread(target=self._get_App_Info,args=[args])" 138 self.threads['pkginfo']="threading.Thread(target=self._get_Extended_App_Info,args=[args])" 139 self.threads['search']='threading.Thread(target=self._search_Store,args=[args,action])' 140 self.threads['list']='threading.Thread(target=self._search_Store,args=[args,action])' 141 self.threads['info']='threading.Thread(target=self._search_Store,args=[args,action])' 142 self.threads['install']='threading.Thread(target=self._install_remove_App,args=[args,action])' 143 self.threads['remove']='threading.Thread(target=self._install_remove_App,args=[args,action])' 144 self.threads['list_sections']='threading.Thread(target=self._list_sections,args=[args,action])' 136 self.threads['get_info']="threading.Thread(target=self._get_App_Info,args=args,kwargs=kwargs)" 137 self.threads['pkginfo']="threading.Thread(target=self._get_Extended_App_Info,args=args,kwargs=kwargs)" 138 self.threads['search']='threading.Thread(target=self._search_Store,args=args,kwargs=kwargs)' 139 self.threads['list']='threading.Thread(target=self._search_Store,args=args,kwargs=kwargs)' 140 self.threads['info']='threading.Thread(target=self._search_Store,args=args,kwargs=kwargs)' 141 self.threads['install']='threading.Thread(target=self._install_remove_App,args=args,kwargs=kwargs)' 142 self.threads['remove']='threading.Thread(target=self._install_remove_App,args=args,kwargs=kwargs)' 143 self.threads['list_sections']='threading.Thread(target=self._list_sections,args=args,kwargs=kwargs)' 145 144 #def _define_functions_for_threads 146 145 … … 151 150 # - parms for the action 152 151 #### 153 def execute_action(self,action,args=None): 154 self._debug("Launching action: "+action+" and args "+str(args)) 152 def execute_action(self,action,*args,**kwargs): 153 #Action must be a kwarg but for retrocompatibility reasons we keep it as an arg 154 kwargs.update({"action":action}) 155 self._debug("Launching action: %s with args %s and kwargs %s"%(action,args,kwargs)) 155 156 if self.is_action_running('load'): 156 157 self._join_action('load') … … 159 160 if action not in self.threads.keys(): 160 161 #Attempt to add a new action managed by a plugin 161 self._debug("Attempting to find a plugin for action "+action)162 self._debug("Attempting to find a plugin for action %s"%action) 162 163 if action in self.plugins_registered.keys(): 163 164 for package_type,plugin in self.plugins_registered[action].items(): 164 165 self.action_progress[action]=0 165 self.threads[action]='threading.Thread(target=self._execute_class_method(action,package_type,action).execute_action,args=[action] )'166 self.threads[action]='threading.Thread(target=self._execute_class_method(action,package_type,action).execute_action,args=[action],kwargs={kwargs})' 166 167 break 167 self._debug('Plugin for '+action+' found: '+str(self.plugins_registered[action]))168 self._debug('Plugin for %s found: %s'%(action,self.plugins_registered[action])) 168 169 self.related_actions.update({action:[action]}) 169 170 sw_track_status=True … … 171 172 if self.is_action_running(action): 172 173 #join thread if we're performing the same action 173 self._debug("Waiting for current action "+action+" to end")174 self._debug("Waiting for current action %s to end"%s) 174 175 self.running_threads[action].join() 175 176 try: … … 184 185 else: 185 186 self.result[action]['status']={'status':-1,'msg':''} 186 self._debug("Thread "+str(self.running_threads[action])+" for action "+action+" launched")187 self._debug("Thread %s for action %s launched"%(self.running_threads[action],action)) 187 188 188 189 except Exception as e: 189 self._debug("Can't launch thread for action: "+action)190 self._debug("Reason: "+str(e))190 self._debug("Can't launch thread for action: %s"%action) 191 self._debug("Reason: %s"%e) 191 192 pass 192 193 else: 193 self._debug("No function associated with action "+action)194 self._debug("No function associated with action %s"%action) 194 195 #def execute_action 195 196 … … 203 204 # - The class method to execute 204 205 #### 205 def _execute_class_method(self,action,pa rms=None,launchedby=None):206 def _execute_class_method(self,action,package_type,*args,launchedby=None,**kwargs): 206 207 exe_function=None 207 if not pa rms:208 pa rms="*"208 if not package_type: 209 package_type="*" 209 210 if action in self.plugins_registered: 210 self._debug("Plugin for "+action+": "+self.plugins_registered[action][parms])211 exe_function=eval(self.plugins_registered[action][pa rms]+"()")211 self._debug("Plugin for %s: %s"%(action,self.plugins_registered[action][package_type])) 212 exe_function=eval(self.plugins_registered[action][package_type]+"("+','.join(args)+")") 212 213 if self._propagate_dbg: 213 214 exe_function.set_debug() 214 if self.plugins_registered[action][pa rms] in self.cli_mode:215 if self.plugins_registered[action][package_type] in self.cli_mode: 215 216 exe_function.cli_mode=True 216 217 self._register_action_progress(action,exe_function,launchedby) 217 218 else: 218 self._debug("No plugin for action: "+action) 219 219 self._debug("No plugin for action: %s"%action) 220 if kwargs: 221 self._debug("Parms: %s"%kwargs) 220 222 return (exe_function) 221 223 #def _execute_class_method … … 257 259 #### 258 260 def _join_action(self,action): 259 self._debug("Joining action: "+action)261 self._debug("Joining action: %s"%action) 260 262 try: 261 263 self.running_threads[action].join() 262 264 except Exception as e: 263 self._debug("Unable to join thread for: "+action)264 self._debug("Reason: "+ str(e))265 self._debug("Unable to join thread for: %s"%action) 266 self._debug("Reason: %s"%e) 265 267 finally: 266 268 if action in self.running_threads.keys(): … … 277 279 def _register_action_progress(self,action,function,parent_action=None): 278 280 if action in self.register_action_progress.keys(): 279 self._debug("Appended process for action: "+action +" and function: "+str(function))281 self._debug("Appended process for action: %s and function: %s"%(action,function)) 280 282 self.register_action_progress[action].append(function) 281 283 else: 282 self._debug("Registered process for action: "+action+" and function: "+str(function))284 self._debug("Registered process for action: %s and function %s"%(action,function)) 283 285 self.register_action_progress[action]=[function] 284 286 if parent_action: 285 self._debug("Registered process for Parent Action: "+action+"-"+parent_action+" and function: "+str(function))287 self._debug("Registered process for Parent Action: %s-%s and function: %s"%(action,parent_action,function)) 286 288 if parent_action in self.threads_progress.keys(): 287 289 self.threads_progress[parent_action].update({action:function}) … … 300 302 progress={'search':0,'list':0,'install':0,'remove':0,'load':0,'list_sections':0} 301 303 action_list=[] 302 if action and action in self.register_action_progress:304 if action in self.register_action_progress.keys(): 303 305 action_list=[action] 304 306 else: … … 342 344 result[res]=[] 343 345 else: 344 self._debug("Checking result for action "+action)346 self._debug("Checking result for action %s"%action) 345 347 if self.is_action_running(action): 346 348 self._join_action(action) … … 366 368 def get_status(self,action=None): 367 369 self.lock.acquire() 368 self._debug("Checking status for action "+str(action))370 self._debug("Checking status for action %s"%action) 369 371 result={} 370 372 if action in self.result: … … 390 392 action='load' 391 393 for package_type in self.plugins_registered[action]: 392 load_function=self._execute_class_method(action,package_type, None)394 load_function=self._execute_class_method(action,package_type,launchedby=None) 393 395 self.store=load_function.execute_action(action=action,store=self.store)['data'] 394 396 #def _load_Store … … 403 405 def _get_App_Info(self,applist,launchedby=None): 404 406 action='get_info' 405 info_function=self._execute_class_method(action,None,launchedby )407 info_function=self._execute_class_method(action,None,launchedby=launchedby) 406 408 info_applist=info_function.execute_action(self.store,action,applist) 407 409 return(info_applist) … … 423 425 result['status']={'status':0,'msg':''} 424 426 for app_info in info_applist: 425 # result['data'].append(app_info)426 427 package_type=self._check_package_type(app_info) 427 428 if package_type in types_dict: … … 430 431 types_dict[package_type]=[app_info] 431 432 for package_type in types_dict: 432 self._debug("Checking plugin for "+action+ " "+package_type)433 self._debug("Checking plugin for %s %s"%(action,package_type)) 433 434 if package_type in self.plugins_registered[action]: 434 # result['data']=[]435 435 #Only search full info if it's required 436 436 if (fullsearch==False and package_type=='deb'): 437 437 result['data'].extend(types_dict[package_type]) 438 438 continue 439 self._debug("Retrieving info for "+str(types_dict[package_type])) 440 info_function=self._execute_class_method(action,package_type,launchedby) 441 # result.update(info_function.execute_action(action,types_dict[package_type])) 439 self._debug("Retrieving info for %s"%types_dict[package_type]) 440 info_function=self._execute_class_method(action,package_type,launchedby=launchedby) 442 441 result['data'].extend(info_function.execute_action(action,types_dict[package_type])['data']) 443 # result['status']=info_function.execute_action(action,types_dict[package_type])['status']444 # result=info_function.execute_action(action,types_dict[package_type])445 442 else: 446 443 result['data'].append(app_info) … … 454 451 status={} 455 452 if action in self.plugins_registered.keys(): 456 self._debug("Plugin for generic search: "+self.plugins_registered[action]['*'])453 self._debug("Plugin for generic search: %s"%self.plugins_registered[action]['*']) 457 454 finder=self.plugins_registered[action][('*')] 458 455 search_function=eval(finder+"()") … … 461 458 data=result['data'] 462 459 else: 463 print("No plugin for action "+action)460 print("No plugin for action %s"%action) 464 461 self.result[action]['data']=data 465 462 self.result[action]['status']=status 466 self._debug("Sections: "+str(self.result[action]['data']))467 self._debug("Status: "+str(self.result[action]['status']))463 self._debug("Sections: %s"%self.result[action]['data']) 464 self._debug("Status: %s"%self.result[action]['status']) 468 465 469 466 #### … … 474 471 # - List of dicts with all the info 475 472 #### 476 def _search_Store(self,search_item='',action='search',fullsearch=False,launchedby=None,max_results=0): 477 if type(search_item[-1])==type(1): 478 max_results=search_item[-1] 479 search_item=search_item[:-1] 480 applist={} 473 def _search_Store(self,*args,**kwargs): 474 search_item=args[0] 475 action='search' 476 if 'action' in kwargs.keys(): 477 action=kwargs['action'] 478 launchedby=None 479 if 'launchedby' in kwargs.keys(): 480 launchedby=kwargs['launchedby'] 481 max_results=0 482 if 'max_results' in kwargs.keys(): 483 max_results=kwargs['max_results'] 484 fullsearch=False 485 if 'fullsearch' in kwargs.keys(): 486 fullsearch=kwargs['fullsearch'] 481 487 result={} 482 aux_applist=[] 483 if action=='list': 484 try: 485 search_item=' '.join(search_item) 486 except: 487 search_item='' 488 elif action=='list_sections': 488 tmp_applist=[] 489 if action=='list_sections': 489 490 search_item='' 490 491 elif action=='info': … … 497 498 exact_match=False 498 499 for package_type in self.plugins_registered[action]: 499 search_function=self._execute_class_method(action,'*',launchedby )500 search_function=self._execute_class_method(action,'*',launchedby=launchedby) 500 501 result.update(search_function.execute_action(self.store,action,search_item,exact_match,max_results)) 501 aux_applist=result['data']502 tmp_applist=result['data'] 502 503 status=result['status'] 503 504 realAction=action … … 506 507 subordinate_action='get_info' 507 508 self.result[subordinate_action]={} 508 result=self._get_App_Info( aux_applist,launchedby)509 self._debug("Add result for "+subordinate_action)509 result=self._get_App_Info(tmp_applist,launchedby) 510 self._debug("Add result for %s"%subordinate_action) 510 511 self.result[subordinate_action]=result 511 512 #2.- Get rest of metadata (slower) … … 514 515 if launchedby: 515 516 realAction=launchedby 516 self._debug("Assigned results of "+action+" to "+realAction)517 self._debug("Assigned results of %s to %s"%(action,realAction)) 517 518 if (result['status']['status']==0) or (result['status']['status']==9): 518 519 return_msg=True … … 535 536 # - Result of the operation 536 537 #### 537 def _install_remove_App(self,appName,action='install',launchedby=None): 538 self._log("Attempting to "+action +" "+appName) 538 def _install_remove_App(self,*args,**kwargs): 539 appName=args[0] 540 if 'action' in kwargs.keys(): 541 action=kwargs['action'] 542 self._log("Attempting to %s %s"%(action,appName)) 539 543 result={} 540 544 return_msg=False 541 if (self._search_Store(appName, 'search',True,action)):545 if (self._search_Store(appName,action='search',fullsearch=True,launchedby=action)): 542 546 info_applist=self.result[action]['data'] 543 547 types_dict={} 544 548 #Check if package is installed if we want to remove it or vice versa 545 549 for app_info in info_applist: 546 #Appstream doesn't get the right status in all cases so we rely on the mechanisms given by the different plugins.550 #Appstream doesn't get the right status in all cases so we rely on the mechanisms given by the different plugins. 547 551 if (action=='install' and app_info['state']=='installed') or (action=='remove' and app_info['state']=='available'): 548 552 if (action=='remove' and app_info['state']=='available'): … … 564 568 565 569 for package_type in types_dict: 566 self._debug("Checking plugin for "+action+ " "+package_type)570 self._debug("Checking plugin for %s %s"%(action,package_type)) 567 571 if package_type in self.plugins_registered[action]: 568 install_function=self._execute_class_method(action,package_type, action)572 install_function=self._execute_class_method(action,package_type,launchedby=action) 569 573 if package_type=='zmd': 570 574 #If it's a zmd the zomando must be present in the system … … 572 576 for zmd_bundle in types_dict[package_type]: 573 577 zmdInfo={} 574 self._debug("Cheking presence of zmd "+zmd_bundle['package'])578 self._debug("Cheking presence of zmd %s"%zmd_bundle['package']) 575 579 zmd='/usr/share/zero-center/zmds/'+app_info['package']+'.zmd' 576 580 if not os.path.exists(zmd): … … 579 583 if zmd_info: 580 584 self._debug("Installing needed packages") 581 install_depends_function=self._execute_class_method(action,"deb", action)585 install_depends_function=self._execute_class_method(action,"deb",launchedby=action) 582 586 result=install_depends_function.execute_action(action,zmd_info) 583 587 … … 594 598 self._debug("App state changed to available") 595 599 return_msg=True 596 self._log("Result "+action +": "+str(self.result[action]))600 self._log("Result %s: %s"%(action,self.result[action])) 597 601 return(return_msg) 598 602 #def install_App … … 613 617 else: 614 618 #Standalone installers must have an installerUrl field loaded from a bundle type=script description 615 if app_info['installerUrl']!='': 619 if app_info['bundle']!='': 620 return_msg=app_info['bundle'] 621 elif app_info['installerUrl']!='': 616 622 return_msg="sh" 617 elif app_info['bundle']!='':618 return_msg=app_info['bundle']619 623 else: 620 624 return_msg="deb"
Note: See TracChangeset
for help on using the changeset viewer.