Changeset 2734 for lliurex-up/trunk/fuentes/LliurexUpCore.py
- Timestamp:
- Oct 31, 2016, 6:30:30 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lliurex-up/trunk/fuentes/LliurexUpCore.py
r2712 r2734 3 3 import shutil 4 4 import subprocess 5 import socket 5 6 6 7 class LliurexUpCore(object): … … 49 50 def checkLliurexUpIsUpdated(self): 50 51 sourceslistDefaultPath = os.path.join(self.processSourceslist,'default') 51 options = "-o Dir::Etc::sourcelist={sourceslistOnlyLliurex} -o Dir::Etc::sourceparts=/dev/null".format(sourceslistOnlyLliurex=sourceslistDefaultPath) 52 options = "" 53 if self.canConnectToLliurexNet(): 54 options = "-o Dir::Etc::sourcelist={sourceslistOnlyLliurex} -o Dir::Etc::sourceparts=/dev/null".format(sourceslistOnlyLliurex=sourceslistDefaultPath) 52 55 command = "LANG=C apt-get update {options}".format(options=options) 53 56 subprocess.Popen(command,shell=True).communicate() 54 57 result = self.getPackageVersionAvailable('lliurex-up',options) 58 55 59 if result['installed'] != result['candidate']: 56 command = "LANG=C apt-get install lliurex-up {options}".format(options=options) 57 p = subprocess.Popen(command,shell=True,stdout=subprocess.PIPE) 58 p.communicate() 59 return "reboot" 60 return "install" 60 61 return "nothing" 61 62 63 def installLliurexUp(self): 64 command = "LANG=C apt-get install lliurex-up {options}".format(options=options) 65 p = subprocess.Popen(command,shell=True,stdout=subprocess.PIPE) 66 p.communicate() 62 67 63 68 def lliurexMirrorIsUpdated(self): … … 94 99 if targetMetapackage != '': 95 100 return targetMetapackage 101 102 def canConnectToLliurexNet(self): 103 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 104 host = socket.gethostbyname('lliurex.net') 105 result = s.connect_ex((host, 80)) 106 s.close() 107 if result: 108 return False 109 return True 110 111 def getLliurexVersion(self): 112 sourceslistDefaultPath = os.path.join(self.processSourceslist,'default') 113 options = "" 114 if self.canConnectToLliurexNet(): 115 options = "-o Dir::Etc::sourcelist={sourceslistOnlyLliurex} -o Dir::Etc::sourceparts=/dev/null".format(sourceslistOnlyLliurex=sourceslistDefaultPath) 116 command = "LANG=C apt-get update {options}".format(options=options) 117 subprocess.Popen(command,shell=True).communicate() 118 return self.getPackageVersionAvailable('lliurex-version-stamp',options) 119 120 def getPackagesToUpdate(self): 121 packageInfo = {} 122 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 if x.startswith('Inst') ] 126 r = [ w.replace('Inst ','') for w in y ] 127 for allinfo in r : 128 packageInfo[allinfo.split(' ')[0]] = ' '.join(allinfo.split(' ')[1:]) 129 130 131
Note: See TracChangeset
for help on using the changeset viewer.