Changeset 2902
- Timestamp:
- Nov 17, 2016, 3:00:24 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lliurex-up/trunk/fuentes/LliurexUpCore.py
r2734 r2902 22 22 23 23 def prepareEnvironment(self): 24 ''' 25 This funcion delete all environment and rebuild environment 26 ''' 24 27 if os.path.exists(self.processPath): 25 28 shutil.rmtree(os.path.join(self.processPath)) … … 36 39 37 40 def getPackageVersionAvailable(self,package,options=""): 41 ''' 42 Args : 43 package String 44 options String 45 46 return dictionary => result 47 result : {'installed':String,'candidate':String} 48 49 Options are Apt options 50 ''' 38 51 command = "LANG=C apt-cache policy {package} {options}".format(package=package,options=options) 39 52 p = subprocess.Popen(command,shell=True,stdout=subprocess.PIPE) … … 48 61 return {"installed":installed,"candidate":candidate} 49 62 50 def checkLliurexUpIsUpdated(self): 63 def isLliurexUpIsUpdated(self): 64 ''' 65 return Boolean 66 ''' 51 67 sourceslistDefaultPath = os.path.join(self.processSourceslist,'default') 52 68 options = "" … … 58 74 59 75 if result['installed'] != result['candidate']: 60 return "install" 61 return "nothing" 62 63 def installLliurexUp(self): 76 return False 77 return True 78 79 def installLliurexUp(self,options=""): 80 ''' 81 Args : 82 options String 83 return dictionary => result 84 result : {'returncode':Int,'stdout':String,'stderr':String} 85 86 options are Apt options 87 88 89 This function install lliurex-up 90 ''' 64 91 command = "LANG=C apt-get install lliurex-up {options}".format(options=options) 65 92 p = subprocess.Popen(command,shell=True,stdout=subprocess.PIPE) 66 p.communicate() 93 poutput,perror = p.communicate() 94 return {'returncode':p.returncode,'stdout':poutput,'stderrs':perror} 67 95 68 96 def lliurexMirrorIsUpdated(self): 97 ''' 98 return None | dictionary => result 99 result : {'status':Boolean,'msg':String,'action':String} 100 result.msg : message of status 101 result.action : Action to launch 102 ''' 69 103 if self.haveLliurexMirror and 'server' in self.flavours : 70 104 result = self.n4d.is_update_available('','MirrorManager',self.defaultMirror) … … 73 107 74 108 def lliurexMirrorIsRunning(self): 109 ''' 110 return Boolean 111 ''' 75 112 if self.haveLliurexMirror and 'server' in self.flavours : 76 113 result = self.n4d.is_alive('','MirrorManager') … … 79 116 80 117 def getPercentageLliurexMirror(self): 118 ''' 119 return int | None 120 ''' 81 121 if self.haveLliurexMirror and 'server' in self.flavours: 82 122 result = self.n4d.get_percentage('','MirrorManager',self.defaultMirror) … … 86 126 87 127 def checkFlavour(self): 128 ''' 129 return None|String 130 If metapackages has been uninstalled, this function return 131 package to must install. If return None, you are ok and don't need 132 install anything. 133 ''' 88 134 targetMetapackage = None 89 135 if 'None' in self.flavours: … … 101 147 102 148 def canConnectToLliurexNet(self): 149 ''' 150 return Boolean 151 ''' 103 152 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 104 153 host = socket.gethostbyname('lliurex.net') … … 110 159 111 160 def getLliurexVersion(self): 161 ''' 162 return dictionary => result 163 result : {'installed':String,'candidate':String} 164 ''' 112 165 sourceslistDefaultPath = os.path.join(self.processSourceslist,'default') 113 166 options = "" … … 119 172 120 173 def getPackagesToUpdate(self): 174 ''' 175 packageInfo definition 176 { 177 'PACKAGENAME' : { 178 'install' : 'INSTALLEDVERSION', 179 'candidate' : 'CANDIDATEVERSION', 180 'icon' : 'ICONNAME', 181 'changelog' : 'CHANGELOGTEXT' 182 } 183 } 184 ''' 121 185 packageInfo = {} 122 186 subprocess.Popen("LANG=C apt-get update",shell=True).communicate() 123 p = subprocess.Popen('LANG=C apt-get dist-upgrade -sV',shell=True,stdout=subprocess.PIPE)124 z = p.stdout.readlines()125 y = [ x.strip() for x in z ifx.startswith('Inst') ]126 r = [ w.replace('Inst ','') for w in y]187 psimulate = subprocess.Popen('LANG=C apt-get dist-upgrade -sV',shell=True,stdout=subprocess.PIPE) 188 rawoutputpsimulate = psimulate.stdout.readlines() 189 rawpackagestoinstall = [ aux.strip() for aux in rawoutputpsimulate if aux.startswith('Inst') ] 190 r = [ aux.replace('Inst ','') for aux in rawpackagestoinstall ] 127 191 for allinfo in r : 128 packageInfo[allinfo.split(' ')[0]] = ' '.join(allinfo.split(' ')[1:]) 129 130 131 192 packageInfo[allinfo.split(' ')[0]] = {} 193 packageInfo[allinfo.split(' ')[0]]['raw'] = ' '.join(allinfo.split(' ')[1:]) 194 195 for package in packageInfo: 196 raw = packageInfo[package]['raw'].split(' ') 197 if raw[0].startswith('['): 198 packageInfo[package]['install'] = raw[0][1:-1] 199 packageInfo[package]['candidate'] = raw[1][1:] 200 elif raw[0].startswith('('): 201 packageInfo[package]['install'] = None 202 packageInfo[package]['candidate'] = raw[0][1:] 203 packageInfo[package].pop('raw')
Note: See TracChangeset
for help on using the changeset viewer.