def update(self): index = ExtensionIndex() updateList = [] for name in self.installedExtensions: extension = index.getByName(name) if extension != None: if( self.installedExtensions[name].getVersion() < extension.getVersion()): updateList.append(extension) self.display([], updateList, []) if(len(updateList) > 0): display("Updating extensions:") for ex in range(len(updateList)): updateList[ex].update()
def install(self, extensionNames): index = ExtensionIndex() installList = [] updateList = [] newest = [] for ex in range(len(extensionNames)): # get extension info rex = index.getByName(extensionNames[ex]) if(rex == None): error("Error: Extension '"+extensionNames[ex]+"' not found!") #check if extensions is already installed if(rex.isInstalled()): currVersion = self.installedExtensions[extensionNames[ex]].getVersion() remVersion = rex.getVersion() #check if currunt extension is older version if (currVersion < remVersion): updateList.append(rex) else: newest.append(rex.getName()+" is already the newest version.") else: installList.append(rex) #print out extensions that already is installed with newest version for ex in range(len(newest)): display(newest[ex]) self.display(installList, updateList, []) if(len(updateList) > 0): display("Updating extensions:") for ex in range(len(updateList)): updateList[ex].install() if(len(installList) > 0 ): display("Installing extensions:") for ex in range(len(installList)): installList[ex].install()
def remove(self, extensionNames): index = ExtensionIndex() removeList = [] notInstalled= [] for ex in range( len(extensionNames) ): rex = index.getByName(extensionNames[ex]) if(rex == None): error("Error: Extension '"+extensionNames[ex]+"' not found!") if(rex.isInstalled()): removeList.append(rex) else: notInstalled.append(rex) for ex in range(len(notInstalled)): display(notInstalled[ex].getName()+" is not installed") self.display([],[],removeList) if(len(removeList) > 0 ): display("Removing extensions:") for ex in range(len(removeList)): removeList[ex].remove()