Changeset 3099 for lliurex-store/trunk
- Timestamp:
- Dec 19, 2016, 1:00:49 PM (4 years ago)
- Location:
- lliurex-store/trunk/fuentes/lliurex-appstore.install/usr/bin
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
lliurex-store/trunk/fuentes/lliurex-appstore.install/usr/bin/plugins/__init__.py
r3060 r3099 1 from .loadStore import *2 from .zmdManager import *3 from .debManager import *4 from .shManager import *5 from .searchManager import *6 from .infoManager import * -
lliurex-store/trunk/fuentes/lliurex-appstore.install/usr/bin/plugins/debManager.py
r3093 r3099 11 11 self.partialProgress=0 12 12 #self.pluginInfo=['install','deb','remove','deb','pkginfo','deb','remove','zmd'] 13 self.pluginInfo= ['install','deb','remove','deb','pkginfo','deb']13 self.pluginInfo={'install':'deb','remove':'deb','pkginfo':'deb'} 14 14 self.count=0 15 15 #def __init__ -
lliurex-store/trunk/fuentes/lliurex-appstore.install/usr/bin/plugins/example.py
r3092 r3099 1 # Remember to include the plugin in the __ini__ file1 #The name of the main class must match the file name in lowercase 2 2 3 class exampleplugin: 3 4 class example: 4 5 def __init__(self): 5 6 self.example='This is an example plugin' 6 7 self.dbg=0 7 8 self.progress=0 8 self.pluginInfo=['example','*'] 9 #This dict defines wich package_type relies on what action 10 self.pluginInfo={'example':'*'} 9 11 #def __init__ 10 12 … … 20 22 21 23 def register(self): 22 return(self.pluginInfo) 24 #This function MUST return the dict with the action:package_type pair 25 #In this example it return nothing 26 #return(self.pluginInfo) 27 return({}) 23 28 24 29 def execute_action(self,action): -
lliurex-store/trunk/fuentes/lliurex-appstore.install/usr/bin/plugins/infoManager.py
r3092 r3099 4 4 def __init__(self): 5 5 self.dbg=1 6 self.pluginInfo= ['info','*']6 self.pluginInfo={'info':'*'} 7 7 self.applistInfo=[] 8 8 self.progress=0 -
lliurex-store/trunk/fuentes/lliurex-appstore.install/usr/bin/plugins/loadStore.py
r3078 r3099 8 8 def __init__(self): 9 9 self.dbg=0 10 self.pluginInfo= ['load','*']10 self.pluginInfo={'load':'*'} 11 11 self.store='' 12 12 self.progress=0 -
lliurex-store/trunk/fuentes/lliurex-appstore.install/usr/bin/plugins/searchManager.py
r3078 r3099 6 6 self.dbg=1 7 7 self.store='' 8 self.pluginInfo= ['search','*','list','*','list_sections','*']8 self.pluginInfo={'search':'*','list':'*','list_sections':'*'} 9 9 self.precision=50 10 10 self.applist=[] -
lliurex-store/trunk/fuentes/lliurex-appstore.install/usr/bin/plugins/shManager.py
r3060 r3099 9 9 self.locale=locale.getlocale()[0] 10 10 self.dbg=0 11 self.pluginInfo= ['install','sh']11 self.pluginInfo={'install':'sh'} 12 12 if action=='install': 13 13 self.install_App(app['installerUrl']) -
lliurex-store/trunk/fuentes/lliurex-appstore.install/usr/bin/plugins/zmdManager.py
r3093 r3099 14 14 self.dbg=1 15 15 self.zmdPath='/usr/share/zero-center/zmds' 16 self.pluginInfo= ['install','zmd','pkginfo','zmd','remove','zmd']16 self.pluginInfo={'install':'zmd','pkginfo':'zmd','remove':'zmd'} 17 17 self.progress=0 18 18 self.n4dclient='' -
lliurex-store/trunk/fuentes/lliurex-appstore.install/usr/bin/storeManager.py
r3093 r3099 38 38 self.threadsRunning={} #"" "" "" the running threads 39 39 self._define_functions_for_threads() #Function that loads the dictionary self.threads 40 self.pluginDir='plugins' #Dir that stores the plugins 40 self.pluginDir=os.getcwd()+'/plugins' #Path to the dir that stores the plugins 41 self.pluginMod=os.path.basename(self.pluginDir) #DON'T CHANGE!!! 42 oldpwd=os.getcwd() 43 os.chdir(self.pluginDir) 44 exec ('import ' + self.pluginMod) #DON'T CHANGE!!! 45 os.chdir(oldpwd) 41 46 self.registeredPlugins={} #Dict that have the relation between plugins and actions 42 47 self.registerProcessProgress={} #Dict that stores the progress for each function/parentAction pair … … 53 58 def __init_plugins__(self): 54 59 os.chdir(self.pluginDir) 55 self.registeredPlugin={} 56 pluginFile=open('__init__.py','r') 57 for line in pluginFile: 58 definedActions=[] 59 pluginName=line.split()[1].lower() 60 pluginName=pluginName[1:] 61 pluginClass=self.pluginDir+'.'+pluginName.lower() 62 try: 63 loadedClass=eval(pluginClass)() 64 definedActions=loadedClass.register() 65 except Exception as e: 66 print ("Can't initialize "+pluginClass) 67 print ("Reason: "+str(e)) 68 pass 69 70 while definedActions: 71 if definedActions[0] in self.registeredPlugins: 72 aux_actionDicc=self.registeredPlugins[definedActions[0]] 73 aux_actionDicc[definedActions[1]]=pluginName 74 self.registeredPlugins[definedActions[0]]=aux_actionDicc 75 else: 76 self.registeredPlugins[definedActions[0]]={definedActions[1]:pluginName} 77 definedActions.pop(0) 78 definedActions.pop(0) 60 for mod in os.listdir(): 61 if not mod.startswith('_'): 62 modName=mod.split('.')[0] 63 strImport='from plugins.'+modName+' import *' 64 try: 65 exec (strImport) 66 except Exception as e: 67 print(str(e)) 68 for mod in (sys.modules.keys()): 69 if 'plugins.' in mod: 70 definedActions={} 71 pluginNameUp=mod.split('.')[-1] 72 pluginName=pluginNameUp.lower() 73 try: 74 loadedClass=eval(mod+'.'+pluginName)() 75 definedActions=loadedClass.register() 76 except Exception as e: 77 print ("Can't initialize "+str(mod)+' '+str(loadedClass)) 78 print ("Reason: "+str(e)) 79 pass 80 81 for action in definedActions.keys(): 82 if action not in self.registeredPlugins: 83 self.registeredPlugins[action]={} 84 self.registeredPlugins[action].update({definedActions[action]:pluginNameUp+'.'+pluginName}) 79 85 self._debug(str(self.registeredPlugins)) 80 86 #def __init_plugins__ … … 148 154 parms="*" 149 155 self._debug("Plugin for "+action+": "+self.registeredPlugins[action][parms]) 150 exeFunction=eval(self.pluginDir+'.'+self.registeredPlugins[action][parms]+"()") 156 # exeFunction=eval(self.pluginDir+'.'+self.registeredPlugins[action][parms]+"()") 157 exeFunction=eval(self.pluginMod+'.'+self.registeredPlugins[action][parms]+"()") 158 # exeFunction=exec(self.pluginMod+'.'+self.registeredPlugins[action][parms]+"()") 151 159 self._registerProcessProgress(action,exeFunction,launchedby) 152 160 return (exeFunction) … … 343 351 self._debug("Plugin for generic search: "+self.registeredPlugins[action]['*']) 344 352 finder=self.registeredPlugins[action][('*')] 345 searchFunction=eval(self.plugin Dir+'.'+finder+"()")353 searchFunction=eval(self.pluginMod+'.'+finder+"()") 346 354 result=searchFunction.execute_action(self.store,action,searchItem) 347 355 else: … … 379 387 else: 380 388 searchItem=[searchItem] 381 searchFunction=eval(self.pluginDir+'.'+finder+"()") 389 # searchFunction=eval(finder+"()") 390 searchFunction=eval(self.pluginMod+'.'+finder+"()") 382 391 if not launchedby: 383 392 launchedby=action
Note: See TracChangeset
for help on using the changeset viewer.