From db9b8cdbd7662d564cffccffdb4ec845e9924c11 Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@cd1c1023-2f26-0410-ae45-c471fc1f0318> Date: Tue, 1 Jan 2008 14:34:24 +0000 Subject: [PATCH] - misc bug fixes - moving askquestion to EquoInterface (that is gonna be renamed to EntropyInterface when done) git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@973 cd1c1023-2f26-0410-ae45-c471fc1f0318 --- TODO | 1 + client/confTools.py | 5 +- client/equo | 5 +- client/equoTools.py | 60 ++++++++----- client/queryTools.py | 49 +++++------ client/repositoriesTools.py | 22 +++-- client/rescueTools.py | 32 ++++--- client/uiTools.py | 18 ++-- libraries/activatorTools.py | 88 +++++++++---------- libraries/databaseTools.py | 165 ++++++++++++++++++------------------ libraries/entropyTools.py | 19 ----- libraries/outputTools.py | 57 ++++++++++--- libraries/reagentTools.py | 76 ++++++++--------- libraries/remoteTools.py | 10 +-- libraries/smartTools.py | 86 +++++++++---------- 15 files changed, 344 insertions(+), 349 deletions(-) diff --git a/TODO b/TODO index 8b22e7976..1e32ddaed 100644 --- a/TODO +++ b/TODO @@ -6,6 +6,7 @@ TODO list: - equo world: removal packages, first ask all, then do - separate packages for license restrictions - add a check when installing a package from a different arch + - convert all print_* into TextInterface::updateProgress notice this: >> ## Ebuild: pkg_prerm() diff --git a/client/confTools.py b/client/confTools.py index 7370a3cd7..23add291d 100644 --- a/client/confTools.py +++ b/client/confTools.py @@ -61,6 +61,7 @@ def configurator(options): ''' def update(): cache_status = False + Text = TextInterface() while 1: scandata = scanfs(dcache = cache_status) if (cache_status): @@ -93,7 +94,7 @@ def update(): continue print_info(darkred("Configuration file: ")+darkgreen(etpConst['systemroot']+scandata[key]['destination'])) if cmd == -3: - rc = entropyTools.askquestion(">> Overwrite ?") + rc = Text.askQuestion(">> Overwrite ?") if rc == "No": continue print_info(darkred("Moving ")+darkgreen(etpConst['systemroot']+scandata[key]['source'])+darkred(" to ")+brown(etpConst['systemroot']+scandata[key]['destination'])) @@ -120,7 +121,7 @@ def update(): continue print_info(darkred("Configuration file: ")+darkgreen(etpConst['systemroot']+scandata[key]['destination'])) if cmd == -7: - rc = entropyTools.askquestion(">> Discard ?") + rc = Text.askQuestion(">> Discard ?") if rc == "No": continue print_info(darkred("Discarding ")+darkgreen(etpConst['systemroot']+scandata[key]['source'])) diff --git a/client/equo b/client/equo index 6e8bfc399..741d4f8da 100644 --- a/client/equo +++ b/client/equo @@ -315,8 +315,9 @@ except KeyboardInterrupt: #except Timeout: # pass except Exception: - from entropyTools import askquestion, printException + from entropyTools import printException from remoteTools import getOnlineContent, reportApplicationError + Text = TextInterface() print_error(darkred("Hi. My name is Bug Reporter. I am sorry to inform you that Equo crashed. Well, you know, shit happens.")) print_error(darkred("But there's something you could do to help Equo to be a better application.")) print_error(darkred("-- EVEN IF I DON'T WANT YOU TO SUBMIT THE SAME REPORT MULTIPLE TIMES --")) @@ -352,7 +353,7 @@ except Exception: conntest = getOnlineContent("http://svn.sabayonlinux.org") if (conntest != False): print_error(darkgreen("Of course you are on the Internet...")) - rc = askquestion(" Erm... Can I send the error to my creators so they can fix me?") + rc = Text.askQuestion(" Erm... Can I send the error to my creators so they can fix me?") if rc == "No": print_error(darkgreen("Ok, ok ok ok... Sorry!")) loadconfcache() diff --git a/client/equoTools.py b/client/equoTools.py index b6ffa3126..5597a21e0 100644 --- a/client/equoTools.py +++ b/client/equoTools.py @@ -29,7 +29,7 @@ from clientConstants import * from outputTools import * import remoteTools import exceptionTools -from entropyTools import compareMd5, bytesIntoHuman, askquestion, getRandomNumber, dep_getkey, uncompressTarBz2, extractXpak, applicationLockCheck, countdown, isRoot, spliturl, remove_tag, dep_striptag, md5sum, allocateMaskedFile, istextfile, isnumber, extractEdb, unpackXpak, lifobuffer, ebeep, parallelStep +from entropyTools import compareMd5, bytesIntoHuman, getRandomNumber, dep_getkey, uncompressTarBz2, extractXpak, applicationLockCheck, countdown, isRoot, spliturl, remove_tag, dep_striptag, md5sum, allocateMaskedFile, istextfile, isnumber, extractEdb, unpackXpak, lifobuffer, ebeep, parallelStep from databaseTools import openRepositoryDatabase, openClientDatabase import confTools import dumpTools @@ -50,7 +50,7 @@ class EquoInterface(TextInterface): @input noclientdb(bool): if enabled, client database non-existance will be ignored @input xcache(bool): enable/disable database caching ''' - def __init__(self, indexing = True, noclientdb = False, xcache = True): + def __init__(self, indexing = True, noclientdb = False, xcache = True, server = False, server_readonly = True, server_noupload = True): import dumpTools self.dumpTools = dumpTools @@ -63,7 +63,12 @@ class EquoInterface(TextInterface): self.indexing = indexing self.noclientdb = noclientdb self.xcache = xcache - self.openClientDatatabase() + if server: + self.server_readonly = server_readonly + self.server_noupload = server_noupload + self.openServerDatabase() + else: + self.openClientDatabase() self.repoDbCache = {} # Packages installation stuff self.transaction_ready = False @@ -84,18 +89,29 @@ class EquoInterface(TextInterface): self.clientDbconn.closeDB() self.openClientDatatabase() + def reopenServerDbconn(self, readonly = True, noupload = True): + self.serverDbconn.closeDB() + self.server_readonly = readonly + self.server_noupload = noupload + self.openServerDatabase() + def closeAllRepositoryDatabases(self): for item in self.repoDbCache: self.repoDbCache[item].closeDB() del self.repoDbCache[item] self.repoDbCache.clear() - def openClientDatatabase(self): + def openClientDatabase(self): self.clientDbconn = self.databaseTools.openClientDatabase(indexing = self.indexing, generate = self.noclientdb, xcache = self.xcache ) + def openServerDatabase(self): + self.serverDbconn = self.databaseTools.openServerDatabase(readOnly = self.server_readonly, + noUpload = self.server_noupload + ) + def openRepositoryDatabase(self, repoid): if not self.repoDbCache.has_key((repoid,etpConst['systemroot'])): dbconn = self.databaseTools.openRepositoryDatabase(repoid, xcache = self.xcache, indexing = self.indexing) @@ -113,6 +129,7 @@ class EquoInterface(TextInterface): indexing = self.indexing, readOnly = readOnly ) + return dbconn def listAllAvailableBranches(self): branches = set() @@ -832,7 +849,7 @@ class EquoInterface(TextInterface): monotree = set(idpackages) # monodimensional tree # check if dependstable is sane before beginning - rx = self.clientDbconn.retrieveDepends(idpackages[0]) + self.clientDbconn.retrieveDepends(idpackages[0]) while (not dependsOk): treedepth += 1 @@ -1015,13 +1032,14 @@ class EquoInterface(TextInterface): # filter out packages that are in actionQueue comparing key + slot if install and removal: myremmatch = {} - [myremmatch.update({(self.entropyTools.dep_getkey(self.clientDbconn.retrieveAtom(x)),self.clientDbconn.retrieveSlot(x)): x}) for x in removal] + for x in removal: + myremmatch.update({(self.entropyTools.dep_getkey(self.clientDbconn.retrieveAtom(x)),self.clientDbconn.retrieveSlot(x)): x}) for packageInfo in install: dbconn = self.openRepositoryDatabase(packageInfo[1]) testtuple = (self.entropyTools.dep_getkey(dbconn.retrieveAtom(packageInfo[0])),dbconn.retrieveSlot(packageInfo[0])) if testtuple in myremmatch: # remove from removalQueue - if myremmatch[testtuple] in removalQueue: + if myremmatch[testtuple] in removal: removal.remove(myremmatch[testtuple]) del testtuple del myremmatch @@ -1169,7 +1187,7 @@ def fetchFile(url, digest = None): filename = os.path.basename(url) filepath = etpConst['packagesbindir']+"/"+etpConst['branch']+"/"+filename if os.path.exists(filepath): - os.remove(filepath) + os.remove(filepath) # load class fetchConn = remoteTools.urlFetcher(url, filepath) @@ -1179,21 +1197,20 @@ def fetchFile(url, digest = None): fetchChecksum = fetchConn.download() data_transfer = fetchConn.datatransfer except KeyboardInterrupt: - return -4, data_transfer + return -4, data_transfer except: - return -1, data_transfer + return -1, data_transfer if fetchChecksum == "-3": - return -3, data_transfer - if (digest): - #print digest+" <--> "+fetchChecksum - if (fetchChecksum != digest): - # not properly downloaded - del fetchConn - return -2, data_transfer - else: - del fetchConn - return 0, data_transfer + return -3, data_transfer + del fetchConn + if (digest): + #print digest+" <--> "+fetchChecksum + if (fetchChecksum != digest): + # not properly downloaded + return -2, data_transfer + else: + return 0, data_transfer return 0, data_transfer def matchChecksum(infoDict): @@ -1365,7 +1382,6 @@ def removePackage(infoDict): ''' def unpackPackage(infoDict): - package = infoDict['download'] equoLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"Unpacking package: "+str(infoDict['atom'])) if os.path.isdir(infoDict['unpackdir']): @@ -1978,7 +1994,7 @@ def stepExecutor(step, infoDict, loopString = None): elif step == "cleanup": print_info(red(" ## ")+blue("Cleaning temporary files for: ")+red(os.path.basename(infoDict['atom']))) xtermTitle(loopString+' Cleaning temporary files for: '+os.path.basename(infoDict['atom'])) - parallelClean = parallelStep(cleanupPackage,infoDict) + parallelStep(cleanupPackage,infoDict) # we don't care if cleanupPackage fails since it's not critical ''' output = cleanupPackage(infoDict) diff --git a/client/queryTools.py b/client/queryTools.py index c10ff9846..a487c8fe1 100644 --- a/client/queryTools.py +++ b/client/queryTools.py @@ -112,8 +112,6 @@ def searchInstalledPackages(packages, idreturn = False, dbconn = None): if (result): for pkg in result: idpackage = pkg[1] - atom = pkg[0] - branch = clientDbconn.retrieveBranch(idpackage) if (idreturn): dataInfo.add(idpackage) else: @@ -141,24 +139,22 @@ def searchBelongs(files, idreturn = False, dbconn = None): dataInfo = set() # when idreturn is True results = {} flatresults = {} - for file in files: + for xfile in files: like = False - if file.find("*") != -1: - import re - out = re.subn("\*","%",file) - file = out[0] + if xfile.find("*") != -1: + xfile.replace("*","%") like = True - results[file] = set() - idpackages = clientDbconn.searchBelongs(file, like) + results[xfile] = set() + idpackages = clientDbconn.searchBelongs(xfile, like) for idpackage in idpackages: if not flatresults.get(idpackage): - results[file].add(idpackage) + results[xfile].add(idpackage) flatresults[idpackage] = True if (results): for result in results: # print info - file = result + xfile = result result = results[result] for idpackage in result: if (idreturn): @@ -168,7 +164,7 @@ def searchBelongs(files, idreturn = False, dbconn = None): else: printPackageInfo(idpackage, clientDbconn, clientSearch = True) if (not idreturn) and (not etpUi['quiet']): - print_info(blue(" Keyword: ")+bold("\t"+file)) + print_info(blue(" Keyword: ")+bold("\t"+xfile)) print_info(blue(" Found: ")+bold("\t"+str(len(result)))+red(" entries")) if (idreturn): @@ -191,9 +187,9 @@ def searchDepends(atoms, idreturn = False, dbconn = None): for atom in atoms: result = clientDbconn.atomMatch(atom) matchInRepo = False - if (result[0] == -1) and dbclose: + if (result[0] == -1): matchInRepo = True - result = atomMatch(atom) + result = Equo.atomMatch(atom) if (result[0] != -1): if (matchInRepo): dbconn = Equo.openRepositoryDatabase(result[1]) @@ -316,11 +312,11 @@ def searchFiles(atoms, idreturn = False, dbconn = None): dataInfo.add((result,files)) else: if etpUi['quiet']: - for file in files: - print file + for xfile in files: + print xfile else: - for file in files: - print_info(blue(" ### ")+red(file)) + for xfile in files: + print_info(blue(" ### ")+red(xfile)) if (not idreturn) and (not etpUi['quiet']): print_info(blue(" Package: ")+bold("\t"+atom)) print_info(blue(" Found: ")+bold("\t"+str(len(files)))+red(" files")) @@ -341,10 +337,9 @@ def searchOrphans(): # start to list all files on the system: dirs = etpConst['filesystemdirs'] foundFiles = set() - for dir in dirs: - for currentdir,subdirs,files in os.walk(dir): + for xdir in dirs: + for currentdir,subdirs,files in os.walk(xdir): for filename in files: - file = currentdir+"/"+filename # filter python compiled objects? if filename.endswith(".pyo") or filename.startswith(".pyc") or filename == '.keep': continue @@ -466,7 +461,7 @@ def searchInstalled(idreturn = False): installedPackages = clientDbconn.listAllPackages() installedPackages.sort() - if (not idreturn): + if not idreturn: if (not etpUi['quiet']): print_info(red(" @@ ")+blue("These are the installed packages:")) for package in installedPackages: @@ -485,7 +480,7 @@ def searchInstalled(idreturn = False): else: idpackages = set() for x in installedPackages: - idpackages.add(package[1]) + idpackages.add(x[1]) return list(idpackages) @@ -498,7 +493,6 @@ def searchPackage(packages, idreturn = False): print_info(darkred(" @@ ")+darkgreen("Searching...")) # search inside each available database repoNumber = 0 - searchError = False for repo in etpRepositories: foundPackages[repo] = {} repoNumber += 1 @@ -522,8 +516,6 @@ def searchPackage(packages, idreturn = False): # print info for pkg in foundPackages[repo][package]: idpackage = pkg[1] - atom = pkg[0] - branch = dbconn.retrieveBranch(idpackage) if (idreturn): dataInfo.add((idpackage,repo)) else: @@ -634,7 +626,7 @@ def searchDescription(descriptions, idreturn = False): Internal functions ''' def __searchDescriptions(descriptions, dbconn, idreturn = False): - dataInfo = [] # when idreturn is True + dataInfo = set() # when idreturn is True mydescdata = {} for desc in descriptions: @@ -643,9 +635,8 @@ def __searchDescriptions(descriptions, dbconn, idreturn = False): mydescdata[desc] = result for pkg in mydescdata[desc]: idpackage = pkg[1] - atom = pkg[0] if (idreturn): - dataInfo.append([idpackage,repo]) + dataInfo.add(idpackage) elif (etpUi['quiet']): print dbconn.retrieveAtom(idpackage) else: diff --git a/client/repositoriesTools.py b/client/repositoriesTools.py index 3a1c9ed8e..91d9625aa 100644 --- a/client/repositoriesTools.py +++ b/client/repositoriesTools.py @@ -28,7 +28,6 @@ from entropyConstants import * from clientConstants import * from outputTools import * -import entropyTools import exceptionTools def repositories(options): @@ -224,12 +223,12 @@ def syncRepositories(reponames = [], forceUpdate = False): import cacheTools cacheTools.generateCache(depcache = True, configcache = False) - if repoConn.syncErrors: + syncErrors = repoConn.syncErrors + del repoConn + if syncErrors: if (not etpUi['quiet']): print_warning(darkred(" @@ ")+red("Something bad happened. Please have a look.")) - del repoConn return 128 - del repoConn rc = False try: @@ -259,11 +258,13 @@ class repositoryController(TextInterface): import remoteTools import dumpTools + import entropyTools self.remoteTools = remoteTools self.dumpTools = dumpTools + self.entropyTools = entropyTools # check if I am root - if (not entropyTools.isRoot()): + if (not self.entropyTools.isRoot()): raise exceptionTools.PermissionDenied("PermissionDenied: not allowed as user.") # check etpRepositories @@ -371,10 +372,9 @@ class repositoryController(TextInterface): fetchConn = self.remoteTools.urlFetcher(url, filepath) rc = fetchConn.download() - if rc in ("-1","-2","-3"): - del fetchConn - return False del fetchConn + if rc in ("-1","-2","-3"): + return False return True def removeRepositoryFiles(self, repo, dbfilenameid): @@ -392,15 +392,13 @@ class repositoryController(TextInterface): self.validateRepositoryId(repo) - import entropyTools - path = eval("entropyTools."+cmethod[1])(etpRepositories[repo]['dbpath']+"/"+etpConst[cmethod[2]]) + path = eval("self.entropyTools."+cmethod[1])(etpRepositories[repo]['dbpath']+"/"+etpConst[cmethod[2]]) return path def verifyDatabaseChecksum(self, repo): self.validateRepositoryId(repo) - import entropyTools try: f = open(etpRepositories[repo]['dbpath']+"/"+etpConst['etpdatabasehashfile'],"r") md5hash = f.readline().strip() @@ -408,7 +406,7 @@ class repositoryController(TextInterface): f.close() except: return -1 - rc = entropyTools.compareMd5(etpRepositories[repo]['dbpath']+"/"+etpConst['etpdatabasefile'],md5hash) + rc = self.entropyTools.compareMd5(etpRepositories[repo]['dbpath']+"/"+etpConst['etpdatabasefile'],md5hash) return rc def closeTransactions(self): diff --git a/client/rescueTools.py b/client/rescueTools.py index 67a4a7d7e..45aa63a47 100644 --- a/client/rescueTools.py +++ b/client/rescueTools.py @@ -31,19 +31,17 @@ from outputTools import * from databaseTools import backupClientDatabase import entropyTools import equoTools -import exceptionTools +Equo = equoTools.EquoInterface(noclientdb = True) def database(options): if len(options) < 1: - return -10 + return -10 # check if I am root if (not entropyTools.isRoot()): print_error(red("You are not ")+bold("root")+red(".")) - return 1 - - Equo = equoTools.EquoInterface(noclientdb = True) + return 1 if (options[0] == "generate"): @@ -57,13 +55,13 @@ def database(options): print_warning(bold("ATTENTION: ")+red("The installed package database will be generated again using Gentoo one.")) print_warning(red("If you dont know what you're doing just, don't do this. Really. I'm not joking.")) - rc = entropyTools.askquestion(" Understood?") + rc = Equo.askQuestion(" Understood?") if rc == "No": return 0 - rc = entropyTools.askquestion(" Really?") + rc = Equo.askQuestion(" Really?") if rc == "No": return 0 - rc = entropyTools.askquestion(" This is your last chance. Ok?") + rc = Equo.askQuestion(" This is your last chance. Ok?") if rc == "No": return 0 @@ -156,13 +154,13 @@ def database(options): print_warning(bold("####### ATTENTION -> ")+red("The installed package database will be resurrected, this will take a LOT of time.")) print_warning(bold("####### ATTENTION -> ")+red("Please use this function ONLY if you are using an Entropy-enabled Sabayon distribution.")) - rc = entropyTools.askquestion(" Can I continue ?") + rc = Equo.askQuestion(" Can I continue ?") if rc == "No": return 0 - rc = entropyTools.askquestion(" Are you REALLY sure ?") + rc = Equo.askQuestion(" Are you REALLY sure ?") if rc == "No": return 0 - rc = entropyTools.askquestion(" Do you even know what you're doing ?") + rc = Equo.askQuestion(" Do you even know what you're doing ?") if rc == "No": return 0 @@ -309,7 +307,7 @@ def database(options): if x[0] not in installedCounters: # check if the package is in toBeAdded if (toBeAdded): - atomkey = entropyTools.dep_getkey(clientDbconn.retrieveAtom(x[1])) + atomkey = entropyTools.dep_getkey(Equo.clientDbconn.retrieveAtom(x[1])) atomslot = Equo.clientDbconn.retrieveSlot(x[1]) add = True for pkgdata in toBeAdded: @@ -339,7 +337,7 @@ def database(options): atom = Equo.clientDbconn.retrieveAtom(x) print_info(brown(" # ")+red(atom)) rc = "Yes" - if etpUi['ask']: rc = entropyTools.askquestion(">> Continue with removal?") + if etpUi['ask']: rc = Equo.askQuestion(">> Continue with removal?") if rc == "Yes": queue = 0 totalqueue = str(len(toBeRemoved)) @@ -355,7 +353,7 @@ def database(options): for x in toBeAdded: print_info(darkgreen(" # ")+red(x[0])) rc = "Yes" - if etpUi['ask']: rc = entropyTools.askquestion(">> Continue with adding?") + if etpUi['ask']: rc = Equo.askQuestion(">> Continue with adding?") if rc == "No": return 0 # now analyze @@ -532,9 +530,9 @@ def getinfo(dict = False): info['Installed database'] = conn if (conn): # print db info - info['Removal internal protected directories'] = clientDbconn.listConfigProtectDirectories() - info['Removal internal protected directory masks'] = clientDbconn.listConfigProtectDirectories(mask = True) - info['Total installed packages'] = len(clientDbconn.listAllIdpackages()) + info['Removal internal protected directories'] = Equo.clientDbconn.listConfigProtectDirectories() + info['Removal internal protected directory masks'] = Equo.clientDbconn.listConfigProtectDirectories(mask = True) + info['Total installed packages'] = len(Equo.clientDbconn.listAllIdpackages()) # repository databases info (if found on the system) info['Repository databases'] = {} diff --git a/client/uiTools.py b/client/uiTools.py index 6d0f9b120..96581edd4 100644 --- a/client/uiTools.py +++ b/client/uiTools.py @@ -221,7 +221,7 @@ def worldUpdate(onlyfetch = False, replay = False, upgradeTo = None, resume = Fa if (not etpUi['pretend']): if human: - rc = Equo.entropyTools.askquestion(" Would you like to query them ?") + rc = Equo.askQuestion(" Would you like to query them ?") if rc == "No": return 0,0 @@ -376,7 +376,7 @@ def installPackages(packages = [], atomsdata = [], deps = True, emptydeps = Fals if (deps): if (etpUi['ask']): - rc = Equo.entropyTools.askquestion(" Would you like to continue with dependencies calculation ?") + rc = Equo.askQuestion(" Would you like to continue with dependencies calculation ?") if rc == "No": dirscleanup() return 0,0 @@ -423,14 +423,12 @@ def installPackages(packages = [], atomsdata = [], deps = True, emptydeps = Fals pkgsToReinstall = 0 pkgsToDowngrade = 0 pkgsToRemove = len(removalQueue) - actionQueue = {} if (runQueue): if (etpUi['ask'] or etpUi['pretend']): if not (etpUi['quiet']): print_info(red(" @@ ")+blue("These are the packages that would be ")+bold("merged:")) count = 0 - atomlen = len(runQueue) for packageInfo in runQueue: count += 1 @@ -525,7 +523,7 @@ def installPackages(packages = [], atomsdata = [], deps = True, emptydeps = Fals print_info(red(" @@ ")+blue("Freed disk space:\t\t")+bold(str(Equo.entropyTools.bytesIntoHuman(abs(deltaSize))))) if (etpUi['ask']): - rc = Equo.entropyTools.askquestion(" Would you like to run the queue ?") + rc = Equo.askQuestion(" Would you like to run the queue ?") if rc == "No": dirscleanup() return 0,0 @@ -855,7 +853,7 @@ def removePackages(packages = [], atomsdata = [], deps = True, deep = False, sys lookForOrphanedPackages = False if (etpUi['ask']): - rc = Equo.entropyTools.askquestion(question) + rc = Equo.askQuestion(question) if rc == "No": lookForOrphanedPackages = False if (not deps): @@ -902,7 +900,7 @@ def removePackages(packages = [], atomsdata = [], deps = True, deep = False, sys question = " Would you like to proceed?" if human: question = " Would you like to proceed with a selective removal ?" - rc = Equo.entropyTools.askquestion(question) + rc = Equo.askQuestion(question) if rc == "No": return 0,0 elif (deps): @@ -979,7 +977,7 @@ def removePackages(packages = [], atomsdata = [], deps = True, deep = False, sys # if human if not (etpUi['quiet']): print_info(red(" -- ")+bold("(")+blue(str(currentqueue))+"/"+red(totalqueue)+bold(") ")+">>> "+darkgreen(infoDict['removeatom'])) if human: - rc = Equo.entropyTools.askquestion(" Remove this one ?") + rc = Equo.askQuestion(" Remove this one ?") if rc == "No": # update resume cache resume_cache['removalQueue'].remove(idpackage) @@ -1074,7 +1072,7 @@ def dependenciesTest(clientDbconn = None, reagent = False): if (packagesNeeded) and (not etpUi['quiet']) and (not reagent): if (etpUi['ask']): - rc = Equo.entropyTools.askquestion(" Would you like to install the available packages?") + rc = Equo.askQuestion(" Would you like to install the available packages?") if rc == "No": return 0,packagesNeeded else: @@ -1229,7 +1227,7 @@ def librariesTest(clientDbconn = None, reagent = False, listfiles = False): if (atomsdata) and (not reagent): if (etpUi['ask']): - rc = Equo.entropyTools.askquestion(" Would you like to install them?") + rc = Equo.askQuestion(" Would you like to install them?") if rc == "No": return 0,atomsdata else: diff --git a/libraries/activatorTools.py b/libraries/activatorTools.py index 09fef5b8a..c25f40fa4 100644 --- a/libraries/activatorTools.py +++ b/libraries/activatorTools.py @@ -20,9 +20,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ''' -# Never do "import portage" here, please use entropyTools binding -# EXIT STATUSES: 400-499 - +import os +import time +import shutil from entropyConstants import * from serverConstants import * from entropyTools import * @@ -30,14 +30,9 @@ from outputTools import * import mirrorTools import dumpTools import exceptionTools +import databaseTools import remoteTools - -import os -import commands -import string -import time -import shutil - +Text = TextInterface() # Logging initialization import logTools @@ -79,7 +74,7 @@ def sync(options, justTidy = False): database(["sync"]) if (not activatorRequestNoAsk): # ask question - rc = askquestion(" Should I continue with the tidy procedure ?") + rc = Text.askQuestion(" Should I continue with the tidy procedure ?") if rc == "No": sys.exit(0) @@ -92,7 +87,6 @@ def sync(options, justTidy = False): # now it's time to do some tidy # collect all the binaries in the database - import databaseTools dbconn = databaseTools.openServerDatabase(readOnly = True, noUpload = True) dbBinaries = dbconn.listBranchPackagesTbz2(mybranch) dbconn.closeDB() @@ -129,12 +123,12 @@ def sync(options, justTidy = False): continue print_info(green(" * ")+red("This is the list of files that would be removed from the mirrors: ")) - for file in removeList: - print_info(green("\t* ")+brown(file)) + for xfile in removeList: + print_info(green("\t* ")+brown(xfile)) # ask question if (not activatorRequestNoAsk): - rc = askquestion(" Would you like to continue ?") + rc = Text.askQuestion(" Would you like to continue ?") if rc == "No": sys.exit(0) @@ -145,38 +139,38 @@ def sync(options, justTidy = False): print_info(green(" * ")+red("Connecting to: ")+bold(extractFTPHostFromUri(uri))) ftp = mirrorTools.handlerFTP(uri) ftp.setCWD(etpConst['binaryurirelativepath']+"/"+mybranch) - for file in removeList: + for xfile in removeList: - activatorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"sync: removing (remote) file "+file) - print_info(green(" * ")+red("Removing file: ")+bold(file), back = True) + activatorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"sync: removing (remote) file "+xfile) + print_info(green(" * ")+red("Removing file: ")+bold(xfile), back = True) # remove remotely - if (ftp.isFileAvailable(file)): - rc = ftp.deleteFile(file) + if (ftp.isFileAvailable(xfile)): + rc = ftp.deleteFile(xfile) if (rc): - print_info(green(" * ")+red("Package file: ")+bold(file)+red(" removed successfully from ")+bold(extractFTPHostFromUri(uri))) + print_info(green(" * ")+red("Package file: ")+bold(xfile)+red(" removed successfully from ")+bold(extractFTPHostFromUri(uri))) else: - print_warning(brown(" * ")+red("ATTENTION: remote file ")+bold(file)+red(" cannot be removed.")) + print_warning(brown(" * ")+red("ATTENTION: remote file ")+bold(xfile)+red(" cannot be removed.")) # checksum - if (ftp.isFileAvailable(file+etpConst['packageshashfileext'])): - rc = ftp.deleteFile(file+etpConst['packageshashfileext']) + if (ftp.isFileAvailable(xfile+etpConst['packageshashfileext'])): + rc = ftp.deleteFile(xfile+etpConst['packageshashfileext']) if (rc): - print_info(green(" * ")+red("Checksum file: ")+bold(file+etpConst['packageshashfileext'])+red(" removed successfully from ")+bold(extractFTPHostFromUri(uri))) + print_info(green(" * ")+red("Checksum file: ")+bold(xfile+etpConst['packageshashfileext'])+red(" removed successfully from ")+bold(extractFTPHostFromUri(uri))) else: - print_warning(brown(" * ")+red("ATTENTION: remote checksum file ")+bold(file)+red(" cannot be removed.")) + print_warning(brown(" * ")+red("ATTENTION: remote checksum file ")+bold(xfile)+red(" cannot be removed.")) # remove locally - if os.path.isfile(etpConst['packagesbindir']+"/"+mybranch+"/"+file): - activatorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"sync: removing (local) file "+file) - print_info(green(" * ")+red("Package file: ")+bold(file)+red(" removed successfully from ")+bold(etpConst['packagesbindir']+"/"+mybranch)) - os.remove(etpConst['packagesbindir']+"/"+mybranch+"/"+file) + if os.path.isfile(etpConst['packagesbindir']+"/"+mybranch+"/"+xfile): + activatorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"sync: removing (local) file "+xfile) + print_info(green(" * ")+red("Package file: ")+bold(xfile)+red(" removed successfully from ")+bold(etpConst['packagesbindir']+"/"+mybranch)) + os.remove(etpConst['packagesbindir']+"/"+mybranch+"/"+xfile) try: - os.remove(etpConst['packagesbindir']+"/"+mybranch+"/"+file+etpConst['packagesexpirationfileext']) + os.remove(etpConst['packagesbindir']+"/"+mybranch+"/"+xfile+etpConst['packagesexpirationfileext']) except OSError: pass # checksum - if os.path.isfile(etpConst['packagesbindir']+"/"+mybranch+"/"+file+etpConst['packageshashfileext']): - activatorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"sync: removing (local) file "+file+etpConst['packageshashfileext']) - print_info(green(" * ")+red("Checksum file: ")+bold(file+etpConst['packageshashfileext'])+red(" removed successfully from ")+bold(etpConst['packagesbindir']+"/"+mybranch)) - os.remove(etpConst['packagesbindir']+"/"+mybranch+"/"+file+etpConst['packageshashfileext']) + if os.path.isfile(etpConst['packagesbindir']+"/"+mybranch+"/"+xfile+etpConst['packageshashfileext']): + activatorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"sync: removing (local) file "+xfile+etpConst['packageshashfileext']) + print_info(green(" * ")+red("Checksum file: ")+bold(xfile+etpConst['packageshashfileext'])+red(" removed successfully from ")+bold(etpConst['packagesbindir']+"/"+mybranch)) + os.remove(etpConst['packagesbindir']+"/"+mybranch+"/"+xfile+etpConst['packageshashfileext']) ftp.closeConnection() print_info(green(" * ")+red("Syncronization across mirrors completed.")) @@ -316,9 +310,9 @@ def packages(options): # it's already on the mirror, but... is its size correct?? localSize = int(os.stat(etpConst['packagesbindir']+"/"+mybranch+"/"+localPackage)[6]) remoteSize = 0 - for file in remotePackagesInfo: - if file.split()[8] == localPackage: - remoteSize = int(file.split()[4]) + for xfile in remotePackagesInfo: + if xfile.split()[8] == localPackage: + remoteSize = int(xfile.split()[4]) if (localSize != remoteSize) and (localSize != 0): # size does not match, adding to the upload queue if localPackage not in finePackages: @@ -334,9 +328,9 @@ def packages(options): # it's already on the mirror, but... is its size correct?? localSize = int(os.stat(etpConst['packagesbindir']+"/"+mybranch+"/"+remotePackage)[6]) remoteSize = 0 - for file in remotePackagesInfo: - if file.split()[8] == remotePackage: - remoteSize = int(file.split()[4]) + for xfile in remotePackagesInfo: + if xfile.split()[8] == remotePackage: + remoteSize = int(xfile.split()[4]) if (localSize != remoteSize) and (localSize != 0): # size does not match, remove first #print "removal of "+localPackage+" because its size differ" @@ -465,7 +459,7 @@ def packages(options): if (etpUi['pretend']): continue if (etpUi['ask']): - rc = askquestion("\n Would you like to run the steps above ?") + rc = Text.askQuestion("\n Would you like to run the steps above ?") if rc == "No": print "\n" continue @@ -701,12 +695,12 @@ def packages(options): pkgbranches = [x for x in pkgbranches if os.path.isdir(etpConst['packagessuploaddir']+"/"+x)] for branch in pkgbranches: branchcontent = os.listdir(etpConst['packagessuploaddir']+"/"+branch) - for file in branchcontent: - source = etpConst['packagessuploaddir']+"/"+branch+"/"+file + for xfile in branchcontent: + source = etpConst['packagessuploaddir']+"/"+branch+"/"+xfile destdir = etpConst['packagesbindir']+"/"+branch if not os.path.isdir(destdir): os.makedirs(destdir) - dest = destdir+"/"+file + dest = destdir+"/"+xfile shutil.move(source,dest) if os.path.isfile(dest+etpConst['packagesexpirationfileext']): # clear expiration file os.remove(dest+etpConst['packagesexpirationfileext']) @@ -980,8 +974,8 @@ def syncRemoteDatabases(noUpload = False, justStats = False): print_info(green(" * ")+red("Starting to update the needed mirrors ...")) _uploadList = [] for uri in etpConst['activatoruploaduris']: - for list in uploadList: - if list[0].startswith(uri): + for xlist in uploadList: + if xlist[0].startswith(uri): _uploadList.append(uri) break diff --git a/libraries/databaseTools.py b/libraries/databaseTools.py index 613c07b43..1406298f0 100644 --- a/libraries/databaseTools.py +++ b/libraries/databaseTools.py @@ -30,6 +30,7 @@ except ImportError: # fallback to embedded pysqlite from pysqlite2 import dbapi2 import dumpTools import exceptionTools +Text = TextInterface() # Logging initialization # FIXME: remove database logging @@ -137,77 +138,6 @@ def backupClientDatabase(): return dest return "" -def doServerDatabaseSyncLock(noUpload): - - import mirrorTools - import activatorTools - - # check if the database is locked locally - if os.path.isfile(etpConst['etpdatabasedir']+"/"+etpConst['etpdatabaselockfile']): - self.updateProgress(red("Entropy database is already locked by you :-)"), importance = 1, type = "info", header = red(" * ")) - else: - # check if the database is locked REMOTELY - self.updateProgress(red("Locking and Syncing Entropy database..."), importance = 1, type = "info", header = red(" * "), back = True) - for uri in etpConst['activatoruploaduris']: - ftp = mirrorTools.handlerFTP(uri) - try: - ftp.setCWD(etpConst['etpurirelativepath']) - except: - bdir = "" - for mydir in etpConst['etpurirelativepath'].split("/"): - bdir += "/"+mydir - if (not ftp.isFileAvailable(bdir)): - try: - ftp.mkdir(bdir) - except Exception, e: - if str(e).find("550") != -1: - pass - raise - ftp.setCWD(etpConst['etpurirelativepath']) - if (ftp.isFileAvailable(etpConst['etpdatabaselockfile'])) and (not os.path.isfile(etpConst['etpdatabasedir']+"/"+etpConst['etpdatabaselockfile'])): - import time - self.updateProgress(bold("WARNING")+red(": online database is already locked. Waiting up to 2 minutes..."), importance = 1, type = "info", header = red(" * "), back = True) - unlocked = False - count = 120 - while count: - time.sleep(1) - count -= 1 - if (not ftp.isFileAvailable(etpConst['etpdatabaselockfile'])): - self.updateProgress(bold("HOORAY")+red(": online database has been unlocked. Locking back and syncing..."), importance = 1, type = "info", header = red(" * ")) - unlocked = True - break - if (unlocked): - break - - self.updateProgress(darkgreen("Mirrors status table:"), importance = 1, type = "info", header = brown(" * ")) - dbstatus = activatorTools.getMirrorsLock() - for db in dbstatus: - - db[1] = green("Unlocked") - if (db[1]): - db[1] = red("Locked") - db[2] = green("Unlocked") - if (db[2]): - db[2] = red("Locked") - - p_uri = entropyTools.extractFTPHostFromUri(db[0]) - self.updateProgress( - bold("%s: ")+red("[")+brown("DATABASE: %s")+red("] [")+brown("DOWNLOAD: %s")+red("]") % (p_uri,db[1],db[2],), - importance = 1, - type = "info", - header = "\t" - ) - del p_uri - - ftp.closeConnection() - raise exceptionTools.OnlineMirrorError("OnlineMirrorError: cannot lock mirror "+entropyTools.extractFTPHostFromUri(uri)) - - # if we arrive here, it is because all the mirrors are unlocked so... damn, LOCK! - activatorTools.lockDatabases(True) - - # ok done... now sync the new db, if needed - activatorTools.syncRemoteDatabases(noUpload) - class etpDatabase(TextInterface): def __init__(self, readOnly = False, noUpload = False, dbFile = etpConst['etpdatabasefilepath'], clientDatabase = False, xcache = False, dbname = 'etpdb', indexing = True): @@ -234,8 +164,78 @@ class etpDatabase(TextInterface): if not ((self.clientDatabase) or (self.readOnly)): # server side is calling # lock mirror remotely and ensure to have latest database revision - doServerDatabaseSyncLock(self.noUpload) + self.doServerDatabaseSyncLock(self.noUpload) + def doServerDatabaseSyncLock(self, noUpload): + + import mirrorTools + import activatorTools + + # check if the database is locked locally + if os.path.isfile(etpConst['etpdatabasedir']+"/"+etpConst['etpdatabaselockfile']): + self.updateProgress(red("Entropy database is already locked by you :-)"), importance = 1, type = "info", header = red(" * ")) + else: + # check if the database is locked REMOTELY + self.updateProgress(red("Locking and Syncing Entropy database..."), importance = 1, type = "info", header = red(" * "), back = True) + for uri in etpConst['activatoruploaduris']: + ftp = mirrorTools.handlerFTP(uri) + try: + ftp.setCWD(etpConst['etpurirelativepath']) + except: + bdir = "" + for mydir in etpConst['etpurirelativepath'].split("/"): + bdir += "/"+mydir + if (not ftp.isFileAvailable(bdir)): + try: + ftp.mkdir(bdir) + except Exception, e: + if str(e).find("550") != -1: + pass + raise + ftp.setCWD(etpConst['etpurirelativepath']) + if (ftp.isFileAvailable(etpConst['etpdatabaselockfile'])) and (not os.path.isfile(etpConst['etpdatabasedir']+"/"+etpConst['etpdatabaselockfile'])): + import time + self.updateProgress(bold("WARNING")+red(": online database is already locked. Waiting up to 2 minutes..."), importance = 1, type = "info", header = red(" * "), back = True) + unlocked = False + count = 120 + while count: + time.sleep(1) + count -= 1 + if (not ftp.isFileAvailable(etpConst['etpdatabaselockfile'])): + self.updateProgress(bold("HOORAY")+red(": online database has been unlocked. Locking back and syncing..."), importance = 1, type = "info", header = red(" * ")) + unlocked = True + break + if (unlocked): + break + + self.updateProgress(darkgreen("Mirrors status table:"), importance = 1, type = "info", header = brown(" * ")) + dbstatus = activatorTools.getMirrorsLock() + for db in dbstatus: + + db[1] = green("Unlocked") + if (db[1]): + db[1] = red("Locked") + db[2] = green("Unlocked") + if (db[2]): + db[2] = red("Locked") + + p_uri = entropyTools.extractFTPHostFromUri(db[0]) + self.updateProgress( + bold("%s: ")+red("[")+brown("DATABASE: %s")+red("] [")+brown("DOWNLOAD: %s")+red("]") % (p_uri,db[1],db[2],), + importance = 1, + type = "info", + header = "\t" + ) + del p_uri + + ftp.closeConnection() + raise exceptionTools.OnlineMirrorError("OnlineMirrorError: cannot lock mirror "+entropyTools.extractFTPHostFromUri(uri)) + + # if we arrive here, it is because all the mirrors are unlocked so... damn, LOCK! + activatorTools.lockDatabases(True) + + # ok done... now sync the new db, if needed + activatorTools.syncRemoteDatabases(noUpload) def closeDB(self): @@ -420,7 +420,7 @@ class etpDatabase(TextInterface): header = brown(" * ") ) # lock database - doServerDatabaseSyncLock(self.noUpload) + self.doServerDatabaseSyncLock(self.noUpload) # now run queue self.runTreeUpdatesActions(update_actions) @@ -696,7 +696,7 @@ class etpDatabase(TextInterface): reagent_cmds += atoms # ask branch question - rc = entropyTools.askquestion(" Would you like to continue with the default branch \"%s\" ?" % (etpConst['branch'],)) + rc = self.askQuestion(" Would you like to continue with the default branch \"%s\" ?" % (etpConst['branch'],)) if rc == "No": # ask which mybranch = etpConst['branch'] @@ -711,7 +711,7 @@ class etpDatabase(TextInterface): ) continue # ask to confirm - rc = entropyTools.askquestion(" Confirm %s ?" % (mybranch,)) + rc = self.askQuestion(" Confirm %s ?" % (mybranch,)) if rc == "Yes": break reagent_cmds.append("--branch=%s" % (mybranch,)) @@ -799,7 +799,7 @@ class etpDatabase(TextInterface): versiontag = '#'+etpData['versiontag'] foundid = self.isPackageAvailable(etpData['category']+"/"+etpData['name']+"-"+etpData['version']+versiontag) - if (foundid < 0): # same atom doesn't exist + if (foundid < 0): # same atom doesn't exist in any branch idpk, revision, etpDataUpdated, accepted = self.addPackage(etpData, revision = forcedRevision) else: idpk, revision, etpDataUpdated, accepted = self.updatePackage(etpData, forcedRevision) # only when the same atom exists @@ -2562,9 +2562,6 @@ class etpDatabase(TextInterface): def retrieveDepends(self, idpackage): - #cache = self.fetchInfoCache(idpackage,'retrieveDepends') - #if cache != None: return cache - # sanity check on the table sanity = self.isDependsTableSane() if not sanity: # is empty, need generation @@ -2573,14 +2570,14 @@ class etpDatabase(TextInterface): self.cursor.execute('SELECT dependencies.idpackage FROM dependstable,dependencies WHERE dependstable.idpackage = (?) and dependstable.iddependency = dependencies.iddependency', (idpackage,)) result = self.fetchall2set(self.cursor.fetchall()) - #self.storeInfoCache(idpackage,'retrieveDepends',result) return result # You must provide the full atom to this function - # WARNING: this function does not support branches !!! - def isPackageAvailable(self,pkgkey): - pkgkey = entropyTools.removePackageOperators(pkgkey) - self.cursor.execute('SELECT idpackage FROM baseinfo WHERE atom = "'+pkgkey+'"') + # WARNING: this function does not support branches + # NOTE: server side uses this regardless branch specification because it already handles it in updatePackage() + def isPackageAvailable(self,pkgatom): + pkgatom = entropyTools.removePackageOperators(pkgatom) + self.cursor.execute('SELECT idpackage FROM baseinfo WHERE atom = (?)', (pkgatom,)) result = self.cursor.fetchone() if result: return result[0] diff --git a/libraries/entropyTools.py b/libraries/entropyTools.py index e1305e341..8b3f204c6 100644 --- a/libraries/entropyTools.py +++ b/libraries/entropyTools.py @@ -1368,25 +1368,6 @@ def umountProc(): else: return True -def askquestion(prompt): - xtermTitle("Entropy got a question for you") - responses, colours = ["Yes", "No"], [green, red] - print darkgreen(prompt), - try: - while True: - response=raw_input("["+"/".join([colours[i](responses[i]) for i in range(len(responses))])+"] ") - for key in responses: - # An empty response will match the first value in responses. - if response.upper()==key[:len(response)].upper(): - xtermTitleReset() - return key - print "I cannot understand '%s'" % response, - except (EOFError, KeyboardInterrupt): - print "Interrupted." - xtermTitleReset() - sys.exit(100) - xtermTitleReset() - class lifobuffer: def __init__(self): diff --git a/libraries/outputTools.py b/libraries/outputTools.py index db0ac3ffe..4a8e91c0d 100644 --- a/libraries/outputTools.py +++ b/libraries/outputTools.py @@ -22,10 +22,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ''' -__docformat__ = "epytext" - -from sys import stderr, stdout, modules -from os import environ, getenv +import sys, os import curses import readline from entropyConstants import etpUi @@ -162,33 +159,33 @@ codes["UNMERGE_WARN"] = codes["red"] codes["MERGE_LIST_PROGRESS"] = codes["yellow"] def xtermTitle(mystr, raw=False): - if dotitles and "TERM" in environ and stderr.isatty(): - myt=environ["TERM"] + if dotitles and "TERM" in os.environ and sys.stderr.isatty(): + myt=os.environ["TERM"] legal_terms = ["xterm","Eterm","aterm","rxvt","screen","kterm","rxvt-unicode","gnome"] if myt in legal_terms: if not raw: mystr = "\x1b]0;%s\x07" % mystr - stderr.write(mystr) - stderr.flush() + sys.stderr.write(mystr) + sys.stderr.flush() default_xterm_title = None def xtermTitleReset(): global default_xterm_title if default_xterm_title is None: - prompt_command = getenv('PROMPT_COMMAND') + prompt_command = os.getenv('PROMPT_COMMAND') if prompt_command == "": default_xterm_title = "" elif prompt_command is not None: import commands default_xterm_title = commands.getoutput(prompt_command) else: - pwd = getenv('PWD','') - home = getenv('HOME', '') + pwd = os.getenv('PWD','') + home = os.getenv('HOME', '') if home != '' and pwd.startswith(home): pwd = '~' + pwd[len(home):] default_xterm_title = '\x1b]0;%s@%s:%s\x07' % ( - getenv('LOGNAME', ''), getenv('HOSTNAME', '').split('.', 1)[0], pwd) + os.getenv('LOGNAME', ''), os.getenv('HOSTNAME', '').split('.', 1)[0], pwd) xtermTitle(default_xterm_title, raw=True) def notitles(): @@ -225,7 +222,7 @@ def create_color_func(color_key): return derived_func for c in compat_functions_colors: - setattr(modules[__name__], c, create_color_func(c)) + setattr(sys.modules[__name__], c, create_color_func(c)) def enlightenatom(atom): out = atom.split("/") @@ -269,7 +266,7 @@ def print_generic(msg): # here we'll wrap any nice formatting def writechar(char): if etpUi['mute']: return - stdout.write(char); stdout.flush() + sys.stdout.write(char); sys.stdout.flush() def readtext(request): xtermTitle("Entropy needs your attention") @@ -308,6 +305,38 @@ class TextInterface: elif importance in (2,3): eval("print_"+type)(header+count_str+text, back = back) + # @input question: question to do + # + # @input importance: + # values: 0,1,2 (latter is a blocker - popup menu on a GUI env) + # used to specify information importance, 0 len(colours): + import exceptionTools + raise exceptionTools.IncorrectParameter("IncorrectParameter: maximum responses length = %s" % (len(colours),)) + print darkgreen(question), + try: + while True: + xtermTitle("Entropy got a question for you") + response = raw_input("["+"/".join([colours[i](responses[i]) for i in range(len(responses))])+"] ") + for key in responses: + # An empty response will match the first value in responses. + if response.upper()==key[:len(response)].upper(): + xtermTitleReset() + return key + print "I cannot understand '%s'" % response, + except (EOFError, KeyboardInterrupt): + print "Interrupted." + xtermTitleReset() + sys.exit(100) + xtermTitleReset() + def nocolor(self): nocolor() diff --git a/libraries/reagentTools.py b/libraries/reagentTools.py index e791054af..7c353e5a6 100644 --- a/libraries/reagentTools.py +++ b/libraries/reagentTools.py @@ -19,25 +19,19 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ''' - -# Never do "import portage" here, please use entropyTools binding - -# EXIT STATUSES: 500-599 - +import os +import shutil from entropyConstants import * from serverConstants import * from entropyTools import * import exceptionTools -import os -import shutil import databaseTools +Text = TextInterface() # Logging initialization import logTools reagentLog = logTools.LogFile(level=etpConst['reagentloglevel'],filename = etpConst['reagentlogfile'], header = "[Reagent]") -# reagentLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"testFunction: example. ") - def generator(package, dbconnection = None, enzymeRequestBranch = etpConst['branch'], inject = False): reagentLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"generator: called -> Package: "+str(package)+" | dbconnection: "+str(dbconnection)) @@ -45,49 +39,47 @@ def generator(package, dbconnection = None, enzymeRequestBranch = etpConst['bran # check if the package provided is valid validFile = False if os.path.isfile(package) and package.endswith(".tbz2"): - validFile = True + validFile = True if (not validFile): - print_warning(package+" does not exist !") + print_warning(package+" does not exist !") packagename = os.path.basename(package) print_info(brown(" * ")+red("Processing: ")+bold(packagename)+red(", please wait...")) mydata = extractPkgData(package, enzymeRequestBranch, inject = inject) - + if dbconnection is None: - dbconn = databaseTools.openServerDatabase(readOnly = False, noUpload = True) + dbconn = databaseTools.openServerDatabase(readOnly = False, noUpload = True) else: - dbconn = dbconnection - + dbconn = dbconnection + idpk, revision, etpDataUpdated, accepted = dbconn.handlePackage(mydata) - + # add package info to our official repository etpConst['officialrepositoryname'] if (accepted): dbconn.removePackageFromInstalledTable(idpk) - dbconn.addPackageToInstalledTable(idpk,etpConst['officialrepositoryname']) - + dbconn.addPackageToInstalledTable(idpk,etpConst['officialrepositoryname']) + if dbconnection is None: - dbconn.commitChanges() - dbconn.closeDB() + dbconn.commitChanges() + dbconn.closeDB() packagename = packagename[:-5]+"~"+str(revision)+".tbz2" if (accepted) and (revision != 0): - reagentLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"generator: entry for "+str(os.path.basename(etpDataUpdated['download']))+" has been updated to revision: "+str(revision)) - print_info(green(" * ")+red("Package ")+bold(os.path.basename(etpDataUpdated['download']))+red(" entry has been updated. Revision: ")+bold(str(revision))) - return True, idpk + reagentLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"generator: entry for "+str(os.path.basename(etpDataUpdated['download']))+" has been updated to revision: "+str(revision)) + print_info(green(" * ")+red("Package ")+bold(os.path.basename(etpDataUpdated['download']))+red(" entry has been updated. Revision: ")+bold(str(revision))) + return True, idpk elif (accepted) and (revision == 0): - reagentLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"generator: entry for "+str(os.path.basename(etpDataUpdated['download']))+" newly created or version bumped.") - print_info(green(" * ")+red("Package ")+bold(os.path.basename(etpDataUpdated['download']))+red(" entry newly created.")) - return True, idpk + reagentLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"generator: entry for "+str(os.path.basename(etpDataUpdated['download']))+" newly created or version bumped.") + print_info(green(" * ")+red("Package ")+bold(os.path.basename(etpDataUpdated['download']))+red(" entry newly created.")) + return True, idpk else: - reagentLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"generator: entry for "+str(os.path.basename(etpDataUpdated['download']))+" kept intact, no updates needed.") - print_info(green(" * ")+red("Package ")+bold(os.path.basename(etpDataUpdated['download']))+red(" does not need to be updated. Current revision: ")+bold(str(revision))) - return False, idpk - - + reagentLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"generator: entry for "+str(os.path.basename(etpDataUpdated['download']))+" kept intact, no updates needed.") + print_info(green(" * ")+red("Package ")+bold(os.path.basename(etpDataUpdated['download']))+red(" does not need to be updated. Current revision: ")+bold(str(revision))) + return False, idpk def inject(options): - + requestedBranch = etpConst['branch'] mytbz2s = [] for opt in options: @@ -204,7 +196,7 @@ def update(options): atom = dbconn.retrieveAtom(x) print_info(brown(" # ")+red(atom)) if reagentRequestAsk: - rc = askquestion(">> Would you like to remove them now ?") + rc = Text.askQuestion(">> Would you like to remove them now ?") else: rc = "Yes" if rc == "Yes": @@ -221,7 +213,7 @@ def update(options): for x in toBeAdded: print_info(brown(" # ")+red(x[0])) if reagentRequestAsk: - rc = askquestion(">> Would you like to package them now ?") + rc = Text.askQuestion(">> Would you like to package them now ?") if rc == "No": return 0 @@ -437,7 +429,7 @@ def database(options): pass dbconn.closeDB() print_info(red(" * ")+bold("WARNING")+red(": database file already exists. Overwriting.")) - rc = askquestion("\n Do you want to continue ?") + rc = Text.askQuestion("\n Do you want to continue ?") if rc == "No": return 0 os.remove(etpConst['etpdatabasefilepath']) @@ -462,7 +454,7 @@ def database(options): f.flush() f.close() - rc = askquestion(" Would you like to sync packages first (important if you don't have them synced) ?") + rc = Text.askQuestion(" Would you like to sync packages first (important if you don't have them synced) ?") if rc == "Yes": activatorTools.packages(["sync","--ask"]) @@ -561,7 +553,7 @@ def database(options): print_error(green(" * ")+red("Supplied directory does not exist.")) return 5 print_info(green(" * ")+red("Initializing an empty database file with Entropy structure ..."),back = True) - connection = databaseTools.sqlite.connect(mypath[0]) + connection = databaseTools.dbapi2.connect(mypath[0]) cursor = connection.cursor() for sql in etpSQLInitDestroyAll.split(";"): if sql: @@ -617,7 +609,7 @@ def database(options): atom = dbconn.retrieveAtom(pkg) print_info(red(" (*) ")+bold(atom)) - rc = askquestion(" Would you like to continue ?") + rc = Text.askQuestion(" Would you like to continue ?") if rc == "No": return 9 @@ -723,7 +715,7 @@ def database(options): print_info(red("\t (*) ")+bold(pkgatom)+blue(" [")+red(branch)+blue("]")) # ask to continue - rc = askquestion(" Would you like to continue ?") + rc = Text.askQuestion(" Would you like to continue ?") if rc == "No": return 0 @@ -785,7 +777,7 @@ def database(options): print_info(darkred(" (*) ")+blue("[")+red(branch)+blue("] ")+brown(pkgatom)) # ask to continue - rc = askquestion(" Would you like to continue ?") + rc = Text.askQuestion(" Would you like to continue ?") if rc == "No": return 0 @@ -867,7 +859,7 @@ def database(options): toBeDownloaded.append([idpackage,pkgfile,pkgbranch]) if (not databaseRequestNoAsk): - rc = askquestion(" Would you like to continue ?") + rc = Text.askQuestion(" Would you like to continue ?") if rc == "No": return 0 @@ -984,7 +976,7 @@ def database(options): print_info(green(" - ")+red(pkgatom)+" -> "+bold(str(pkgbranch)+"/"+pkgfile)) if (not databaseRequestNoAsk): - rc = askquestion(" Would you like to continue ?") + rc = Text.askQuestion(" Would you like to continue ?") if rc == "No": return 0 diff --git a/libraries/remoteTools.py b/libraries/remoteTools.py index 72777391f..7b04f25cc 100644 --- a/libraries/remoteTools.py +++ b/libraries/remoteTools.py @@ -111,8 +111,8 @@ def reportApplicationError(errorstring): proxy_support = urllib2.ProxyHandler(etpConst['proxy']) opener = urllib2.build_opener(proxy_support) urllib2.install_opener(opener) - file = urllib2.urlopen(url) - result = file.readlines() + xfile = urllib2.urlopen(url) + result = xfile.readlines() socket.setdefaulttimeout(2) return result except: @@ -125,7 +125,7 @@ def reportApplicationError(errorstring): # ATTENTION: this functions fills global variable etpFileTransferMetadata !! # take care of that -class urlFetcher(TextInterface): +class urlFetcher: def __init__(self, url, pathToSave, checksum = True, showSpeed = True): @@ -177,8 +177,8 @@ class urlFetcher(TextInterface): self.remotefile = urllib2.urlopen(self.url) except KeyboardInterrupt: self.close() - raise KeyboardInterrupt - except Exception, e: + raise + except: self.close() self.status = "-3" return self.status diff --git a/libraries/smartTools.py b/libraries/smartTools.py index 78ef86a87..73b33fbfc 100644 --- a/libraries/smartTools.py +++ b/libraries/smartTools.py @@ -24,14 +24,12 @@ import shutil from entropyConstants import * from clientConstants import * from outputTools import * -import equoTools import uiTools -Equo = equoTools.EquoInterface() def smart(options): # check if I am root - if (not Equo.entropyTools.isRoot()): + if (not uiTools.Equo.entropyTools.isRoot()): print_error(red("You are not ")+bold("root")+red(".")) return 1 @@ -85,12 +83,12 @@ def QuickpkgHandler(mypackages, savedir = None): packages = [] for opt in mypackages: - match = Equo.clientDbconn.atomMatch(opt) + match = uiTools.Equo.clientDbconn.atomMatch(opt) if match[0] != -1: packages.append(match) else: if not etpUi['quiet']: print_warning(darkred(" * ")+red("Cannot find: ")+bold(opt)) - packages = Equo.entropyTools.filterDuplicatedEntries(packages) + packages = uiTools.Equo.entropyTools.filterDuplicatedEntries(packages) if (not packages): print_error(darkred(" * ")+red("No valid packages specified.")) return 2 @@ -100,19 +98,19 @@ def QuickpkgHandler(mypackages, savedir = None): pkgInfo = {} pkgData = {} for pkg in packages: - atom = Equo.clientDbconn.retrieveAtom(pkg[0]) + atom = uiTools.Equo.clientDbconn.retrieveAtom(pkg[0]) pkgInfo[pkg] = atom - pkgData[pkg] = Equo.clientDbconn.getPackageData(pkg[0]) + pkgData[pkg] = uiTools.Equo.clientDbconn.getPackageData(pkg[0]) print_info(brown("\t[")+red("from:")+bold("installed")+brown("]")+" - "+atom) if (not etpUi['quiet']) or (etpUi['ask']): - rc = Equo.entropyTools.askquestion(">> Would you like to recompose the selected packages ?") + rc = uiTools.Equo.askQuestion(">> Would you like to recompose the selected packages ?") if rc == "No": return 0 for pkg in packages: if not etpUi['quiet']: print_info(brown(" * ")+red("Compressing: ")+darkgreen(pkgInfo[pkg])) - resultfile = Equo.entropyTools.quickpkg(pkgdata = pkgData[pkg], dirpath = savedir) + resultfile = uiTools.Equo.entropyTools.quickpkg(pkgdata = pkgData[pkg], dirpath = savedir) if resultfile == None: if not etpUi['quiet']: print_error(darkred(" * ")+red("Error creating package for: ")+bold(pkgInfo[pkg])+darkred(". Cannot continue.")) return 3 @@ -141,7 +139,7 @@ def CommonFlate(mytbz2s, action, savedir = None): for tbz2 in mytbz2s: #print_info(brown(" * ")+darkred("Analyzing: ")+tbz2) - if not (os.path.isfile(tbz2) and tbz2.endswith(".tbz2") and Equo.entropyTools.isEntropyTbz2(tbz2)): + if not (os.path.isfile(tbz2) and tbz2.endswith(".tbz2") and uiTools.Equo.entropyTools.isEntropyTbz2(tbz2)): print_error(darkred(" * ")+bold(tbz2)+red(" is not a valid tbz2")) return 1 @@ -166,19 +164,19 @@ def InflateHandler(mytbz2s, savedir): etptbz2path = savedir+"/"+os.path.basename(tbz2) if os.path.realpath(tbz2) != os.path.realpath(etptbz2path): # can convert a file without copying shutil.copy2(tbz2,etptbz2path) - mydata = Equo.entropyTools.extractPkgData(etptbz2path) + mydata = uiTools.Equo.entropyTools.extractPkgData(etptbz2path) # append arbitrary revision mydata['revision'] = 9999 # create temp database - dbpath = etpConst['packagestmpdir']+"/"+str(Equo.entropyTools.getRandomNumber()) + dbpath = etpConst['packagestmpdir']+"/"+str(uiTools.Equo.entropyTools.getRandomNumber()) while os.path.isfile(dbpath): - dbpath = etpConst['packagestmpdir']+"/"+str(Equo.entropyTools.getRandomNumber()) + dbpath = etpConst['packagestmpdir']+"/"+str(uiTools.Equo.entropyTools.getRandomNumber()) # create - mydbconn = Equo.openGenericDatabase(dbpath) + mydbconn = uiTools.Equo.openGenericDatabase(dbpath) mydbconn.initializeDatabase() mydbconn.addPackage(mydata, revision = mydata['revision']) mydbconn.closeDB() - Equo.entropyTools.aggregateEdb(tbz2file = etptbz2path, dbfile = dbpath) + uiTools.Equo.entropyTools.aggregateEdb(tbz2file = etptbz2path, dbfile = dbpath) os.remove(dbpath) print_info(darkgreen(" * ")+darkred("Inflated package: ")+etptbz2path) @@ -189,9 +187,9 @@ def DeflateHandler(mytbz2s, savedir): # analyze files for tbz2 in mytbz2s: print_info(darkgreen(" * ")+darkred("Deflating: ")+tbz2, back = True) - mytbz2 = Equo.entropyTools.removeEdb(tbz2,savedir) + mytbz2 = uiTools.Equo.entropyTools.removeEdb(tbz2,savedir) tbz2name = os.path.basename(mytbz2)[:-5] # remove .tbz2 - tbz2name = Equo.entropyTools.remove_tag(tbz2name)+".tbz2" + tbz2name = uiTools.Equo.entropyTools.remove_tag(tbz2name)+".tbz2" newtbz2 = os.path.dirname(mytbz2)+"/"+tbz2name print_info(darkgreen(" * ")+darkred("Deflated package: ")+newtbz2) @@ -206,7 +204,7 @@ def ExtractHandler(mytbz2s, savedir): if os.path.isfile(dbpath): os.remove(dbpath) # extract - out = Equo.entropyTools.extractEdb(tbz2,dbpath = dbpath) + out = uiTools.Equo.entropyTools.extractEdb(tbz2,dbpath = dbpath) print_info(darkgreen(" * ")+darkred("Extracted Entropy metadata from: ")+out) return 0 @@ -219,12 +217,12 @@ def smartPackagesHandler(mypackages): packages = [] for opt in mypackages: - match = Equo.atomMatch(opt) + match = uiTools.Equo.atomMatch(opt) if match[0] != -1: packages.append(match) else: print_warning(darkred(" * ")+red("Cannot find: ")+bold(opt)) - packages = Equo.entropyTools.filterDuplicatedEntries(packages) + packages = uiTools.Equo.entropyTools.filterDuplicatedEntries(packages) if (not packages): print_error(darkred(" * ")+red("No valid packages specified.")) return 2 @@ -233,12 +231,12 @@ def smartPackagesHandler(mypackages): print_info(darkgreen(" * ")+red("This is the list of the packages that would be merged into a single one:")) pkgInfo = {} for pkg in packages: - dbconn = Equo.openRepositoryDatabase(pkg[1]) + dbconn = uiTools.Equo.openRepositoryDatabase(pkg[1]) atom = dbconn.retrieveAtom(pkg[0]) pkgInfo[pkg] = atom print_info(brown("\t[")+red("from:")+pkg[1]+brown("]")+" - "+atom) - rc = Equo.entropyTools.askquestion(">> Would you like to create the packages above ?") + rc = uiTools.Equo.askQuestion(">> Would you like to create the packages above ?") if rc == "No": return 0 @@ -256,7 +254,7 @@ def smartpackagegenerator(matchedPackages): fetchdata = [] matchedAtoms = {} for x in matchedPackages: - xdbconn = Equo.openRepositoryDatabase(x[1]) + xdbconn = uiTools.Equo.openRepositoryDatabase(x[1]) matchedAtoms[x] = {} xatom = xdbconn.retrieveAtom(x[0]) xdownload = xdbconn.retrieveDownloadURL(x[0]) @@ -271,9 +269,9 @@ def smartpackagegenerator(matchedPackages): return rc[0] # create unpack dir and unpack all packages - unpackdir = etpConst['entropyunpackdir']+"/smartpackage-"+str(Equo.entropyTools.getRandomNumber()) + unpackdir = etpConst['entropyunpackdir']+"/smartpackage-"+str(uiTools.Equo.entropyTools.getRandomNumber()) while os.path.isdir(unpackdir): - unpackdir = etpConst['entropyunpackdir']+"/smartpackage-"+str(Equo.entropyTools.getRandomNumber()) + unpackdir = etpConst['entropyunpackdir']+"/smartpackage-"+str(uiTools.Equo.entropyTools.getRandomNumber()) if os.path.isdir(unpackdir): shutil.rmtree(unpackdir) os.makedirs(unpackdir) @@ -281,22 +279,22 @@ def smartpackagegenerator(matchedPackages): os.mkdir(unpackdir+"/db") # create master database dbfile = unpackdir+"/db/merged.db" - mergeDbconn = Equo.openGenericDatabase(dbfile, dbname = "client") + mergeDbconn = uiTools.Equo.openGenericDatabase(dbfile, dbname = "client") mergeDbconn.initializeDatabase() mergeDbconn.createXpakTable() tmpdbfile = dbfile+"--readingdata" for package in matchedPackages: print_info(darkgreen(" * ")+brown(matchedAtoms[package]['atom'])+": "+red("collecting Entropy metadata")) - Equo.entropyTools.extractEdb(etpConst['entropyworkdir']+"/"+matchedAtoms[package]['download'],tmpdbfile) + uiTools.Equo.entropyTools.extractEdb(etpConst['entropyworkdir']+"/"+matchedAtoms[package]['download'],tmpdbfile) # read db and add data to mergeDbconn - mydbconn = Equo.openGenericDatabase(tmpdbfile) + mydbconn = uiTools.Equo.openGenericDatabase(tmpdbfile) idpackages = mydbconn.listAllIdpackages() for myidpackage in idpackages: data = mydbconn.getPackageData(myidpackage) if len(idpackages) == 1: # just a plain package that would like to become smart - xpakdata = Equo.entropyTools.readXpak(etpConst['entropyworkdir']+"/"+matchedAtoms[package]['download']) + xpakdata = uiTools.Equo.entropyTools.readXpak(etpConst['entropyworkdir']+"/"+matchedAtoms[package]['download']) else: xpakdata = mydbconn.retrieveXpakMetadata(myidpackage) # already a smart package # add @@ -312,7 +310,7 @@ def smartpackagegenerator(matchedPackages): # merge packages for package in matchedPackages: print_info(darkgreen(" * ")+brown(matchedAtoms[package]['atom'])+": "+red("unpacking content")) - rc = Equo.entropyTools.uncompressTarBz2(etpConst['entropyworkdir']+"/"+matchedAtoms[x]['download'], extractPath = unpackdir+"/content") + rc = uiTools.Equo.entropyTools.uncompressTarBz2(etpConst['entropyworkdir']+"/"+matchedAtoms[x]['download'], extractPath = unpackdir+"/content") if rc != 0: print_error(darkred(" * ")+red("Unpack failed due to unknown reasons.")) return rc @@ -324,7 +322,7 @@ def smartpackagegenerator(matchedPackages): for x in matchedAtoms: atoms.append(matchedAtoms[x]['atom'].split("/")[1]) atoms = '+'.join(atoms) - rc = Equo.entropyTools.compressTarBz2(etpConst['smartpackagesdir']+"/"+atoms+".tbz2",unpackdir+"/content") + rc = uiTools.Equo.entropyTools.compressTarBz2(etpConst['smartpackagesdir']+"/"+atoms+".tbz2",unpackdir+"/content") if rc != 0: print_error(darkred(" * ")+red("Compress failed due to unknown reasons.")) return rc @@ -333,7 +331,7 @@ def smartpackagegenerator(matchedPackages): print_error(darkred(" * ")+red("Compressed file does not exist.")) return 1 - Equo.entropyTools.aggregateEdb(etpConst['smartpackagesdir']+"/"+atoms+".tbz2",dbfile) + uiTools.Equo.entropyTools.aggregateEdb(etpConst['smartpackagesdir']+"/"+atoms+".tbz2",dbfile) print_info("\t"+etpConst['smartpackagesdir']+"/"+atoms+".tbz2") shutil.rmtree(unpackdir,True) return 0 @@ -352,7 +350,7 @@ def smartappsHandler(mypackages, emptydeps = False): packages = set() for opt in mypackages: - match = Equo.atomMatch(opt) + match = uiTools.Equo.atomMatch(opt) if match[0] != -1: packages.add(match) else: @@ -366,12 +364,12 @@ def smartappsHandler(mypackages, emptydeps = False): print_info(darkgreen(" * ")+red("This is the list of the packages that would be worked out:")) pkgInfo = {} for pkg in packages: - dbconn = Equo.openRepositoryDatabase(pkg[1]) + dbconn = uiTools.Equo.openRepositoryDatabase(pkg[1]) atom = dbconn.retrieveAtom(pkg[0]) pkgInfo[pkg] = atom print_info(brown("\t[")+red("from:")+pkg[1]+red("|SMART")+brown("]")+" - "+atom) - rc = Equo.entropyTools.askquestion(">> Would you like to create the packages above ?") + rc = uiTools.Equo.askQuestion(">> Would you like to create the packages above ?") if rc == "No": return 0 @@ -386,7 +384,7 @@ def smartappsHandler(mypackages, emptydeps = False): # tool that generates .tar.bz2 packages with all the binary dependencies included def smartgenerator(atomInfo, emptydeps = False): - dbconn = Equo.openRepositoryDatabase(atomInfo[1]) + dbconn = uiTools.Equo.openRepositoryDatabase(atomInfo[1]) idpackage = atomInfo[0] atom = dbconn.retrieveAtom(idpackage) @@ -397,7 +395,7 @@ def smartgenerator(atomInfo, emptydeps = False): pkgfilename = os.path.basename(pkgfilepath) pkgname = pkgfilename.split(".tbz2")[0] - pkgdependencies, removal, result = Equo.retrieveInstallQueue([atomInfo], empty_deps = emptydeps) + pkgdependencies, removal, result = uiTools.Equo.retrieveInstallQueue([atomInfo], empty_deps = emptydeps) # flatten them pkgs = [] if (result == 0): @@ -415,14 +413,14 @@ def smartgenerator(atomInfo, emptydeps = False): if pkgs: print_info(darkgreen(" * ")+red("This is the list of the dependencies that would be included:")) for i in pkgs: - mydbconn = Equo.openRepositoryDatabase(i[1]) + mydbconn = uiTools.Equo.openRepositoryDatabase(i[1]) atom = mydbconn.retrieveAtom(i[0]) print_info(darkgreen(" (x) ")+red(atom)) fetchdata = [] fetchdata.append([atom,atomInfo]) for x in pkgs: - xdbconn = Equo.openRepositoryDatabase(x[1]) + xdbconn = uiTools.Equo.openRepositoryDatabase(x[1]) xatom = xdbconn.retrieveAtom(x[0]) fetchdata.append([xatom,x]) # run installPackages with onlyfetch @@ -438,7 +436,7 @@ def smartgenerator(atomInfo, emptydeps = False): os.makedirs(pkgtmpdir) mainBinaryPath = etpConst['packagesbindir']+"/"+pkgbranch+"/"+pkgfilename print_info(darkgreen(" * ")+red("Unpacking main package ")+bold(str(pkgfilename))) - Equo.entropyTools.uncompressTarBz2(mainBinaryPath,pkgtmpdir) # first unpack + uiTools.Equo.entropyTools.uncompressTarBz2(mainBinaryPath,pkgtmpdir) # first unpack binaryExecs = [] for item in pkgcontent: @@ -454,13 +452,13 @@ def smartgenerator(atomInfo, emptydeps = False): # now uncompress all the rest for dep in pkgs: - mydbconn = Equo.openRepositoryDatabase(dep[1]) + mydbconn = uiTools.Equo.openRepositoryDatabase(dep[1]) download = os.path.basename(mydbconn.retrieveDownloadURL(dep[0])) depbranch = mydbconn.retrieveBranch(dep[0]) depatom = mydbconn.retrieveAtom(dep[0]) print_info(darkgreen(" * ")+red("Unpacking dependency package ")+bold(depatom)) deppath = etpConst['packagesbindir']+"/"+depbranch+"/"+download - Equo.entropyTools.uncompressTarBz2(deppath,pkgtmpdir) # first unpack + uiTools.Equo.entropyTools.uncompressTarBz2(deppath,pkgtmpdir) # first unpack # remove unwanted files (header files) @@ -552,13 +550,13 @@ def smartgenerator(atomInfo, emptydeps = False): f.flush() f.close() # now compile - Equo.entropyTools.spawnCommand("cd "+pkgtmpdir+"/ ; g++ -Wall "+item+".cc -o "+item+".exe") + uiTools.Equo.entropyTools.spawnCommand("cd "+pkgtmpdir+"/ ; g++ -Wall "+item+".cc -o "+item+".exe") os.remove(pkgtmpdir+"/"+item+".cc") smartpath = etpConst['smartappsdir']+"/"+pkgname+"-"+etpConst['currentarch']+".tbz2" print_info(darkgreen(" * ")+red("Compressing smart application: ")+bold(atom)) print_info("\t"+smartpath) - Equo.entropyTools.compressTarBz2(smartpath,pkgtmpdir+"/") + uiTools.Equo.entropyTools.compressTarBz2(smartpath,pkgtmpdir+"/") shutil.rmtree(pkgtmpdir,True) return 0 \ No newline at end of file