Changeset 3646 for lliurex-store/trunk/fuentes/python3-lliurex-store.install/usr/share/lliurexstore/storeManager.py
- Timestamp:
- Feb 15, 2017, 6:27:03 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lliurex-store/trunk/fuentes/python3-lliurex-store.install/usr/share/lliurexstore/storeManager.py
r3615 r3646 27 27 } 28 28 self.dbg=0 29 if args: 30 self.dbg=args 29 31 self.threads={} #Dict that stores the functions that must execute each action 30 32 self.threadsProgress={} #"" "" "" the progress for each launched thread 31 33 self.threadsRunning={} #"" "" "" the running threads 32 self._define_functions_for_threads() #Function that loads the dictionary self.threads33 34 self.registeredPlugins={} #Dict that have the relation between plugins and actions 34 35 self.registerProcessProgress={} #Dict that stores the progress for each function/parentAction pair 35 self.__init_plugins__() #Function that loads the plugins36 36 self.progressActions={} #Progress of global actions based on average progress of individual processes 37 37 self.result={} #Result of the actions 38 self.execute_action('load') #Function that launches the actions39 38 self.lock=threading.Lock() #locker for functions related to threads (get_progress, is_action_running...) 40 # self.log 39 self.main() 41 40 #def __init__ 41 42 def main(self): 43 self._define_functions_for_threads() #Function that loads the dictionary self.threads 44 self.__init_plugins__() #Function that loads the plugins 45 self.execute_action('load') #Initial load of the store 46 #def main 42 47 43 48 #### … … 148 153 if action in self.registeredPlugins: 149 154 self._debug("Plugin for "+action+": "+self.registeredPlugins[action][parms]) 150 # exeFunction=eval(self.pluginMod+'.'+self.registeredPlugins[action][parms]+"()")151 155 exeFunction=eval(self.registeredPlugins[action][parms]+"()") 156 if self.dbg: 157 exeFunction.set_debug(1) 152 158 self._registerProcessProgress(action,exeFunction,launchedby) 153 159 else: … … 211 217 def _registerProcessProgress(self,action,function,parentAction=None): 212 218 if action in self.registerProcessProgress.keys(): 213 self._debug("Appended process for action :"+action +" and function: "+str(function))219 self._debug("Appended process for action: "+action +" and function: "+str(function)) 214 220 self.registerProcessProgress[action].append(function) 215 221 else: 216 self._debug("Registered process for action :"+action+" and function: "+str(function))222 self._debug("Registered process for action: "+action+" and function: "+str(function)) 217 223 self.registerProcessProgress[action]=[function] 218 224 if parentAction: … … 370 376 if action=='list_sections': 371 377 searchItem='' 372 if (searchItem in self.registeredPlugins[action]):373 self._debug("Plugin for search "+ searchItem +": "+self.registeredPlugins[action][searchItem])374 finder=self.registeredPlugins[action][searchItem]375 else:376 self._debug("Plugin for generic search: "+self.registeredPlugins[action]['*'])377 finder=self.registeredPlugins[action][('*')]378 searchFunction=eval(finder+"()")379 378 if not launchedby: 380 379 launchedby=action 381 self._registerProcessProgress(action,searchFunction,launchedby) 380 381 searchFunction=self._execute_class_method(action,'*',launchedby) 382 382 aux_applist=searchFunction.execute_action(self.store,action,searchItem) 383 #1.- Get appstream metadata (faster) 384 partialAction='info' 385 applist=self._get_App_Info(aux_applist,launchedby) 386 self._debug("Add result for "+partialAction) 387 self.result[partialAction]=applist 388 #2.- Get rest of metadata (slower) 389 partialAction='pkginfo' 390 applist=self._get_Extended_App_Info(applist,launchedby,fullsearch) 391 realAction=action 392 if launchedby: 393 realAction=launchedby 394 self._debug("Assigned results of "+action+" to "+realAction) 395 if (len(applist)): 396 self.result[realAction]=applist 397 return_msg=True 398 else: 399 notfound='' 400 for item in searchItem: 401 notfound=' '.join(searchItem) 402 self.result[realAction]=[{notfound:" not found"}] 383 if len(aux_applist): 384 #1.- Get appstream metadata (faster) 385 partialAction='info' 386 applist=self._get_App_Info(aux_applist,launchedby) 387 self._debug("Add result for "+partialAction) 388 self.result[partialAction]=applist 389 #2.- Get rest of metadata (slower) 390 partialAction='pkginfo' 391 applist=self._get_Extended_App_Info(applist,launchedby,fullsearch) 392 realAction=action 393 if launchedby: 394 realAction=launchedby 395 self._debug("Assigned results of "+action+" to "+realAction) 396 if (len(applist)): 397 self.result[realAction]=applist 398 return_msg=True 399 else: 400 notfound='' 401 self.result[realAction]=[{searchItem:2}] 402 return_msg=False 403 else: 404 self.result[launchedby]=[{searchItem:1}] 403 405 return_msg=False 404 406 return(return_msg) … … 424 426 if (action=='install' and appInfo['status']=='installed') or (action=='remove' and appInfo['status']=='available'): 425 427 if action=='remove': 426 self.result[action]=[{appInfo['package']: "Package not installed"}]428 self.result[action]=[{appInfo['package']:3}] 427 429 else: 428 self.result[action]=[{appInfo['package']: "Package already installed"}]430 self.result[action]=[{appInfo['package']:4}] 429 431 return_msg=False 430 432 typeDict={}
Note: See TracChangeset
for help on using the changeset viewer.