Changeset 3105 for lliurex-store/trunk
- Timestamp:
- Dec 19, 2016, 2:49:33 PM (4 years ago)
- Location:
- lliurex-store/trunk/fuentes/lliurex-appstore.install/usr/bin
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
lliurex-store/trunk/fuentes/lliurex-appstore.install/usr/bin/plugins/debManager.py
r3099 r3105 1 import syslog 1 2 import gi 2 3 gi.require_version('PackageKitGlib', '1.0') … … 25 26 #def debug 26 27 28 def _log(self,msg=None): 29 if msg: 30 syslog.openlog('lliurex-store') 31 syslog.syslog(msg) 32 27 33 def register(self): 28 34 return(self.pluginInfo) … … 39 45 self._install_App(app) 40 46 if action=='remove': 47 self._log("Removing "+appInfo['package']) 48 self._get_App_Dependencies(appInfo,app) 49 self._log("Dependencies to remove"+str(appInfo['depends'])) 41 50 self._remove_App(app) 42 if action=='pkginfo' and self.count==1: 51 # if action=='pkginfo' and self.count==1: 52 if action=='pkginfo': 43 53 self._get_App_Dependencies(appInfo,app) 44 54 # if action=='pkginfo': … … 72 82 def _remove_App(self,app): 73 83 try: 74 self.installer.remove_packages(False,[app.get_id(),],True, True,None,self._callback,None)84 self.installer.remove_packages(False,[app.get_id(),],True,False,None,self._callback,None) 75 85 self.result.append({app.get_id():" removed succesfully"}) 76 86 except Exception as e: -
lliurex-store/trunk/fuentes/lliurex-appstore.install/usr/bin/plugins/loadStore.py
r3099 r3105 27 27 #def register 28 28 29 def execute_action(self,action,store): 29 def execute_action(self,action): 30 self.store=appstream.Store() 30 31 if action=='load': 31 self.load_store(s tore)32 self.load_store(self.store) 32 33 self.progress=100 33 34 return (self.store) -
lliurex-store/trunk/fuentes/lliurex-appstore.install/usr/bin/storeManager.py
r3099 r3105 1 #!/usr/bin/python3 1 2 import sys 2 import gi3 import locale4 3 import os 5 import time6 gi.require_version('AppStreamGlib', '1.0')7 from gi.repository import AppStreamGlib as appstream8 from gi.repository import Gio9 4 import threading 10 import plugins 11 5 import syslog 6 #Load the plugin dir 7 pluginDir=os.getcwd()+'/plugins' #Path to the dir that stores the plugins 8 oldpwd=os.getcwd() 9 os.chdir(pluginDir) 10 exec ('import ' + os.path.basename(pluginDir)) #DON'T CHANGE!!! 11 os.chdir(oldpwd) 12 del (oldpwd) 13 del (pluginDir) 12 14 ###### 13 15 #Ver. 1.0 of storeManager.py … … 20 22 class StoreManager: 21 23 def __init__(self,args=()): 22 self.store=appstream.Store() 24 # self.store=appstream.Store() 25 self.store=None 23 26 self.relatedActions={ 24 27 'load':['load'], … … 29 32 'remove':['search','info','pkginfo','remove'] 30 33 } 31 if locale.getdefaultlocale()[0]=="es_ES": 32 self.locale=['es_ES','es','ca@valencia','ca','ca_ES','C'] 33 else: 34 self.locale=[locale.getlocale()[0],'ca@valencia','ca','es','es_ES','C'] 35 self.dbg=1 34 self.dbg=0 36 35 self.threads={} #Dict that stores the functions that must execute each action 37 36 self.threadsProgress={} #"" "" "" the progress for each launched thread 38 37 self.threadsRunning={} #"" "" "" the running threads 39 38 self._define_functions_for_threads() #Function that loads the dictionary self.threads 40 self.pluginDir=os.getcwd()+'/plugins' 39 self.pluginDir=os.getcwd()+'/plugins' #Path to the dir that stores the plugins 41 40 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)46 41 self.registeredPlugins={} #Dict that have the relation between plugins and actions 47 42 self.registerProcessProgress={} #Dict that stores the progress for each function/parentAction pair … … 51 46 self.execute_action('load') #Function that launches the actions 52 47 self.lock=threading.Lock() #locker for functions related to threads (get_progress, is_action_running...) 48 # self.log 53 49 #def __init__ 54 50 … … 59 55 os.chdir(self.pluginDir) 60 56 for mod in os.listdir(): 61 if not 57 if not mod.startswith('_'): 62 58 modName=mod.split('.')[0] 63 59 strImport='from plugins.'+modName+' import *' … … 96 92 #def _debug 97 93 94 def _log(self,msg=None): 95 if msg: 96 syslog.openlog('lliurex-store') 97 syslog.syslog(msg) 98 98 #### 99 99 #dict of actions/related functions for threading … … 121 121 self._join_action('load') 122 122 if action in self.threads.keys(): 123 # self.action=action124 123 if self.is_action_running(action): 125 124 #join thread if we're performing the same action … … 154 153 parms="*" 155 154 self._debug("Plugin for "+action+": "+self.registeredPlugins[action][parms]) 156 # exeFunction=eval(self.pluginDir+'.'+self.registeredPlugins[action][parms]+"()")157 155 exeFunction=eval(self.pluginMod+'.'+self.registeredPlugins[action][parms]+"()") 158 # exeFunction=exec(self.pluginMod+'.'+self.registeredPlugins[action][parms]+"()")159 156 self._registerProcessProgress(action,exeFunction,launchedby) 160 157 return (exeFunction) … … 221 218 self.registerProcessProgress[action]=[function] 222 219 if parentAction: 223 self._debug("Registered process for Parent Action :"+action+"-"+parentAction+" and function: "+str(function))220 self._debug("Registered process for Parent Action: "+action+"-"+parentAction+" and function: "+str(function)) 224 221 if parentAction in self.threadsProgress.keys(): 225 222 self.threadsProgress[parentAction].update({action:function}) … … 227 224 self.threadsProgress[parentAction]={action:function} 228 225 #def _registerProcessProgress 229 230 226 231 227 #### … … 300 296 action='load' 301 297 loadFunction=self._execute_class_method(action) 302 self.store=loadFunction.execute_action(action ,self.store)298 self.store=loadFunction.execute_action(action) 303 299 #def _load_Store 304 300 … … 426 422 def _install_remove_App(self,appName,action='install',launchedby=None): 427 423 self._debug("Attempting to "+action +" "+appName) 424 self._log("Attempting to "+action +" "+appName) 428 425 result={} 429 426 return_msg=False … … 456 453 return_msg=True 457 454 455 self._log("Result "+action +": "+str(self.result[action])) 458 456 return(return_msg) 459 457 #def install_App … … 462 460 #Check the package type 463 461 #Input: 464 # - AppInfo dict (element of list returned by _get_app_info)462 # - AppInfo dict (element of the list returned by _get_app_info) 465 463 #Output: 466 464 # - String with the type (deb, sh, zmd...)
Note: See TracChangeset
for help on using the changeset viewer.