logging implementation almost complete

git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@309 cd1c1023-2f26-0410-ae45-c471fc1f0318
This commit is contained in:
lxnay
2007-06-07 09:52:02 +00:00
parent 768f38abe2
commit e5e212a7b4
9 changed files with 338 additions and 288 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
TODO list (for developers only):
- implement logTools inside handlers
- enzymeTools
- reagent: complete smartapps section
- handle errors with the exception framework
- move all os.system to spawnCommand()
- enzyme, reagent: test kernel dependent packages
- enzyme, build(): add an option to force the continuation of the emerge queue even if a package fails
- enzyme, add a module that integrates revdep-rebuild
+37 -37
View File
@@ -36,11 +36,11 @@ import time
# Logging initialization
import logTools
activatorLog = logTools.LogFile(level=etpConst['activatorloglevel'],filename = etpConst['activatorlogfile'], header = "[Activator]")
# example: activatorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"testFuncton: called.")
# example: activatorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"testFuncton: called.")
def sync(options, justTidy = False):
activatorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"sync: called with justTidy -> "+str(justTidy))
activatorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"sync: called with justTidy -> "+str(justTidy))
print_info(green(" * ")+red("Starting to sync data across mirrors (packages/database) ..."))
@@ -88,7 +88,7 @@ def sync(options, justTidy = False):
removeList.append(repoBin)
if (removeList == []):
activatorLog.log(ETP_LOG_INFO,ETP_LOG_NORMAL,"sync: no packages to remove from the lirrors.")
activatorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"sync: no packages to remove from the lirrors.")
print_info(green(" * ")+red("No packages to remove from the mirrors."))
print_info(green(" * ")+red("Syncronization across mirrors completed."))
return
@@ -103,14 +103,14 @@ def sync(options, justTidy = False):
sys.exit(0)
# remove them!
activatorLog.log(ETP_LOG_INFO,ETP_LOG_NORMAL,"sync: starting to remove packages from mirrors.")
activatorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"sync: starting to remove packages from mirrors.")
for uri in etpConst['activatoruploaduris']:
activatorLog.log(ETP_LOG_INFO,ETP_LOG_NORMAL,"sync: connecting to mirror "+extractFTPHostFromUri(uri))
activatorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"sync: connecting to mirror "+extractFTPHostFromUri(uri))
print_info(green(" * ")+red("Connecting to: ")+bold(extractFTPHostFromUri(uri)))
ftp = mirrorTools.handlerFTP(uri)
ftp.setCWD(etpConst['binaryurirelativepath'])
for file in removeList:
activatorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"sync: removing (remote) file "+file)
activatorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"sync: removing (remote) file "+file)
print_info(green(" * ")+red("Removing file: ")+bold(file), back = True)
# remove remotely
if (ftp.isFileAvailable(file)):
@@ -121,7 +121,7 @@ def sync(options, justTidy = False):
print_warning(yellow(" * ")+red("ATTENTION: remote file ")+bold(file)+red(" cannot be removed."))
# remove locally
if os.path.isfile(etpConst['packagesbindir']+"/"+file):
activatorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"sync: removing (local) file "+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']))
os.remove(etpConst['packagesbindir']+"/"+file)
ftp.closeFTPConnection()
@@ -131,7 +131,7 @@ def sync(options, justTidy = False):
def packages(options):
activatorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"packages: called with options -> "+str(options))
activatorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"packages: called with options -> "+str(options))
# Options available for all the packages submodules
myopts = options[1:]
@@ -154,7 +154,7 @@ def packages(options):
currentUri = 0
totalSuccessfulUri = 0
activatorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"packages: called sync.")
activatorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"packages: called sync.")
for uri in etpConst['activatoruploaduris']:
@@ -172,7 +172,7 @@ def packages(options):
if tbz2.endswith(".tbz2"):
uploadCounter += 1
activatorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"packages: upload directory stats -> files: "+str(uploadCounter)+" | upload packages list: "+str(toBeUploaded))
activatorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"packages: upload directory stats -> files: "+str(uploadCounter)+" | upload packages list: "+str(toBeUploaded))
print_info(green(" * ")+red("Upload directory:\t\t")+bold(str(uploadCounter))+red(" files ready."))
localPackagesRepository = [] # parse etpConst['packagesbindir']
@@ -184,7 +184,7 @@ def packages(options):
if tbz2.endswith(".tbz2"):
packageCounter += 1
activatorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"packages: packages directory stats -> files: "+str(packageCounter)+" | download packages list (including md5): "+str(localPackagesRepository))
activatorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"packages: packages directory stats -> files: "+str(packageCounter)+" | download packages list (including md5): "+str(localPackagesRepository))
print_info(green(" * ")+red("Packages directory:\t")+bold(str(packageCounter))+red(" files ready."))
@@ -201,7 +201,7 @@ def packages(options):
if tbz2.endswith(".tbz2"):
remoteCounter += 1
activatorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"packages: remote packages stats -> files: "+str(remoteCounter))
activatorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"packages: remote packages stats -> files: "+str(remoteCounter))
print_info(green(" * ")+red("Remote packages:\t\t")+bold(str(remoteCounter))+red(" files stored."))
@@ -210,7 +210,7 @@ def packages(options):
downloadQueue = []
removalQueue = []
activatorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"packages: starting packages calculation...")
activatorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"packages: starting packages calculation...")
# if a package is in the packages directory but not online, we have to upload it
# we have localPackagesRepository and remotePackages
@@ -369,9 +369,9 @@ def packages(options):
_downloadQueue.append(p)
downloadQueue = _downloadQueue
activatorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"packages: removal queue -> "+str(removalQueue))
activatorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"packages: download queue -> "+str(downloadQueue))
activatorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"packages: upload queue -> "+str(uploadQueue))
activatorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"packages: removal queue -> "+str(removalQueue))
activatorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"packages: download queue -> "+str(downloadQueue))
activatorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"packages: upload queue -> "+str(uploadQueue))
if (len(uploadQueue) == 0) and (len(downloadQueue) == 0) and (len(removalQueue) == 0):
print_info(green(" * ")+red("Nothing to syncronize for ")+bold(extractFTPHostFromUri(uri)+red(". Queue empty.")))
@@ -448,10 +448,10 @@ def packages(options):
uploadCounter = "0"
downloadCounter = "0"
activatorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"packages: detailed removal queue -> "+str(detailedRemovalQueue))
activatorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"packages: detailed simple copy queue -> "+str(simpleCopyQueue))
activatorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"packages: detailed download queue -> "+str(detailedDownloadQueue))
activatorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"packages: detailed upload queue -> "+str(detailedUploadQueue))
activatorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"packages: detailed removal queue -> "+str(detailedRemovalQueue))
activatorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"packages: detailed simple copy queue -> "+str(simpleCopyQueue))
activatorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"packages: detailed download queue -> "+str(detailedDownloadQueue))
activatorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"packages: detailed upload queue -> "+str(detailedUploadQueue))
# removal queue
@@ -535,7 +535,7 @@ def packages(options):
# trap exceptions, failed to upload/download someting?
except:
activatorLog.log(ETP_LOG_WARNING,ETP_LOG_NORMAL,"packages: cannot properly syncronize "+extractFTPHostFromUri(uri)+". Trying to continue if possible.")
activatorLog.log(ETP_LOGPRI_WARNING,ETP_LOGLEVEL_NORMAL,"packages: cannot properly syncronize "+extractFTPHostFromUri(uri)+". Trying to continue if possible.")
# print warning cannot sync uri
print_warning(yellow(" * ")+red("ATTENTION: cannot properly syncronize ")+bold(extractFTPHostFromUri(uri))+red(". Continuing if possible..."))
@@ -543,7 +543,7 @@ def packages(options):
# decide what to do
if (totalSuccessfulUri > 0) or (activatorRequestPretend):
# we're safe
activatorLog.log(ETP_LOG_WARNING,ETP_LOG_NORMAL,"packages: at least one mirror has been synced properly. I'm fine.")
activatorLog.log(ETP_LOGPRI_WARNING,ETP_LOGLEVEL_NORMAL,"packages: at least one mirror has been synced properly. I'm fine.")
print_info(green(" * ")+red("At least one mirror has been synced properly. I'm fine."))
continue
else:
@@ -553,7 +553,7 @@ def packages(options):
else:
# no mirrors were synced properly
# show error and return, do not move files from the upload dir
activatorLog.log(ETP_LOG_ERROR,ETP_LOG_NORMAL,"packages: no mirrors have been properly syncronized. Check network status and retry. Cannot continue.")
activatorLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_NORMAL,"packages: no mirrors have been properly syncronized. Check network status and retry. Cannot continue.")
print_error(yellow(" * ")+red("ERROR: no mirrors have been properly syncronized. Check network status and retry. Cannot continue."))
return False
@@ -561,7 +561,7 @@ def packages(options):
# if at least one server has been synced successfully, move files
if (totalSuccessfulUri > 0) and (not activatorRequestPretend):
# now we can store the files in upload/%ARCH% in packages/%ARCH%
activatorLog.log(ETP_LOG_INFO,ETP_LOG_NORMAL,"packages: all done. Now it's time to move packages to "+etpConst['packagesbindir'])
activatorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"packages: all done. Now it's time to move packages to "+etpConst['packagesbindir'])
os.system("mv -f "+etpConst['packagessuploaddir']+"/* "+etpConst['packagesbindir']+"/ &> /dev/null")
return True
else:
@@ -575,17 +575,17 @@ def packages(options):
def database(options):
activatorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"database: called with -> "+str(options))
activatorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"database: called with -> "+str(options))
# lock tool
if (options[0] == "lock"):
print_info(green(" * ")+green("Starting to lock mirrors' databases..."))
rc = lockDatabases(lock = True)
if (rc):
activatorLog.log(ETP_LOG_ERROR,ETP_LOG_NORMAL,"database: (lock) A problem occured on at least one mirror !")
activatorLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_NORMAL,"database: (lock) A problem occured on at least one mirror !")
print_info(green(" * ")+red("A problem occured on at least one mirror !"))
else:
activatorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"database: Databases lock complete.")
activatorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"database: Databases lock complete.")
print_info(green(" * ")+green("Databases lock complete"))
# unlock tool
@@ -593,10 +593,10 @@ def database(options):
print_info(green(" * ")+green("Starting to unlock mirrors' databases..."))
rc = lockDatabases(lock = False)
if (rc):
activatorLog.log(ETP_LOG_ERROR,ETP_LOG_NORMAL,"database: (unlock) A problem occured on at least one mirror !")
activatorLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_NORMAL,"database: (unlock) A problem occured on at least one mirror !")
print_info(green(" * ")+green("A problem occured on at least one mirror !"))
else:
activatorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"database: Databases lock complete.")
activatorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"database: Databases lock complete.")
print_info(green(" * ")+green("Databases unlock complete"))
# download lock tool
@@ -604,10 +604,10 @@ def database(options):
print_info(green(" * ")+green("Starting to lock download mirrors' databases..."))
rc = downloadLockDatabases(lock = True)
if (rc):
activatorLog.log(ETP_LOG_ERROR,ETP_LOG_NORMAL,"database: (download-lock) A problem occured on at least one mirror !")
activatorLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_NORMAL,"database: (download-lock) A problem occured on at least one mirror !")
print_info(green(" * ")+green("A problem occured on at least one mirror !"))
else:
activatorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"database: Download mirrors lock complete.")
activatorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"database: Download mirrors lock complete.")
print_info(green(" * ")+green("Download mirrors lock complete"))
# download unlock tool
@@ -615,10 +615,10 @@ def database(options):
print_info(green(" * ")+green("Starting to unlock download mirrors' databases..."))
rc = downloadLockDatabases(lock = False)
if (rc):
activatorLog.log(ETP_LOG_ERROR,ETP_LOG_NORMAL,"database: (download-unlock) A problem occured on at least one mirror !")
activatorLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_NORMAL,"database: (download-unlock) A problem occured on at least one mirror !")
print_info(green(" * ")+green("A problem occured on at least one mirror..."))
else:
activatorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"database: Download mirrors unlock complete.")
activatorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"database: Download mirrors unlock complete.")
print_info(green(" * ")+green("Download mirrors unlock complete"))
# lock status tool
@@ -639,7 +639,7 @@ def database(options):
# database sync tool
elif (options[0] == "sync"):
activatorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"database: database sync called.")
activatorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"database: database sync called.")
print_info(green(" * ")+red("Checking database status ..."), back = True)
@@ -673,17 +673,17 @@ def database(options):
os.remove(etpConst['etpdatabasedir']+"/"+etpConst['etpdatabasetaintfile'])
else:
print
activatorLog.log(ETP_LOG_ERROR,ETP_LOG_NORMAL,"database (sync inside activatorTools): At the moment, mirrors are locked, someone is working on their databases, try again later...")
activatorLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_NORMAL,"database (sync inside activatorTools): At the moment, mirrors are locked, someone is working on their databases, try again later...")
print_error(green(" * ")+red("At the moment, mirrors are locked, someone is working on their databases, try again later..."))
sys.exit(422)
else:
if (dbLockFile):
activatorLog.log(ETP_LOG_ERROR,ETP_LOG_NORMAL,"database (sync inside activatorTools): Mirrors are not locked remotely but the local database is. It is a non-sense. Please remove the lock file "+etpConst['etpdatabasedir']+"/"+etpConst['etpdatabaselockfile'])
activatorLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_NORMAL,"database (sync inside activatorTools): Mirrors are not locked remotely but the local database is. It is a non-sense. Please remove the lock file "+etpConst['etpdatabasedir']+"/"+etpConst['etpdatabaselockfile'])
print_info(green(" * ")+red("Mirrors are not locked remotely but the local database is. It is a non-sense. Please remove the lock file "+etpConst['etpdatabasedir']+"/"+etpConst['etpdatabaselockfile']))
sys.exit(423)
else:
activatorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"database (sync inside activatorTools): Mirrors are not locked. Fetching data...")
activatorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"database (sync inside activatorTools): Mirrors are not locked. Fetching data...")
print_info(green(" * ")+red("Mirrors are not locked. Fetching data..."))
syncRemoteDatabases()
+73 -73
View File
@@ -704,7 +704,7 @@ class databaseStatus:
def __init__(self):
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"DatabaseStatus.__init__ called.")
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"DatabaseStatus.__init__ called.")
self.databaseBumped = False
self.databaseInfoCached = False
@@ -714,103 +714,103 @@ class databaseStatus:
self.databaseAlreadyTainted = False
if os.path.isfile(etpConst['etpdatabasedir']+"/"+etpConst['etpdatabasetaintfile']):
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"DatabaseStatus: database tainted.")
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"DatabaseStatus: database tainted.")
self.databaseAlreadyTainted = True
def isDatabaseAlreadyBumped(self):
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"DatabaseStatus: already bumped? "+str(self.databaseBumped))
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"DatabaseStatus: already bumped? "+str(self.databaseBumped))
return self.databaseBumped
def isDatabaseAlreadyTainted(self):
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"DatabaseStatus: tainted? "+str(self.databaseAlreadyTainted))
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"DatabaseStatus: tainted? "+str(self.databaseAlreadyTainted))
return self.databaseAlreadyTainted
def setDatabaseTaint(self,bool):
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"DatabaseStatus: setting database taint to: "+str(bool))
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"DatabaseStatus: setting database taint to: "+str(bool))
self.databaseAlreadyTainted = bool
def setDatabaseBump(self,bool):
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"DatabaseStatus: setting database bump to: "+str(bool))
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"DatabaseStatus: setting database bump to: "+str(bool))
self.databaseBumped = bool
def setDatabaseLock(self):
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"DatabaseStatus: Locking database (upload)")
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"DatabaseStatus: Locking database (upload)")
self.databaseLock = True
def unsetDatabaseLock(self):
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"DatabaseStatus: Unlocking database (upload)")
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"DatabaseStatus: Unlocking database (upload)")
self.databaseLock = False
def getDatabaseLock(self):
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"DatabaseStatus: getting database lock info (upload), status: "+str(self.databaseLock))
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"DatabaseStatus: getting database lock info (upload), status: "+str(self.databaseLock))
return self.databaseLock
def setDatabaseDownloadLock(self):
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"DatabaseStatus: Locking database (download)")
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"DatabaseStatus: Locking database (download)")
self.databaseDownloadLock = True
def unsetDatabaseDownloadLock(self):
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"DatabaseStatus: Unlocking database (download)")
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"DatabaseStatus: Unlocking database (download)")
self.databaseDownloadLock = False
def getDatabaseDownloadLock(self):
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"DatabaseStatus: getting database lock info (download), status: "+str(self.databaseDownloadLock))
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"DatabaseStatus: getting database lock info (download), status: "+str(self.databaseDownloadLock))
return self.databaseDownloadLock
class etpDatabase:
def __init__(self, readOnly = False, noUpload = False):
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"etpDatabase.__init__ called.")
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"etpDatabase.__init__ called.")
self.readOnly = readOnly
self.noUpload = noUpload
if (self.readOnly):
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"etpDatabase: database opened readonly")
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"etpDatabase: database opened readonly")
# if the database is opened readonly, we don't need to lock the online status
self.connection = sqlite.connect(etpConst['etpdatabasefilepath'])
self.cursor = self.connection.cursor()
# set the table read only
return
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"etpDatabase: database opened in read/write mode")
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"etpDatabase: database opened in read/write mode")
# check if the database is locked locally
if os.path.isfile(etpConst['etpdatabasedir']+"/"+etpConst['etpdatabaselockfile']):
dbLog.log(ETP_LOG_WARNING,ETP_LOG_NORMAL,"etpDatabase: database already locked")
dbLog.log(ETP_LOGPRI_WARNING,ETP_LOGLEVEL_NORMAL,"etpDatabase: database already locked")
print_info(red(" * ")+red(" Entropy database is already locked by you :-)"))
else:
# check if the database is locked REMOTELY
dbLog.log(ETP_LOG_INFO,ETP_LOG_NORMAL,"etpDatabase: starting to lock and sync database")
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"etpDatabase: starting to lock and sync database")
print_info(red(" * ")+red(" Locking and Syncing Entropy database ..."), back = True)
for uri in etpConst['activatoruploaduris']:
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"etpDatabase: connecting to "+uri)
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"etpDatabase: connecting to "+uri)
ftp = mirrorTools.handlerFTP(uri)
ftp.setCWD(etpConst['etpurirelativepath'])
if (ftp.isFileAvailable(etpConst['etpdatabaselockfile'])) and (not os.path.isfile(etpConst['etpdatabasedir']+"/"+etpConst['etpdatabaselockfile'])):
import time
print_info(red(" * ")+bold("WARNING")+red(": online database is already locked. Waiting up to 2 minutes..."), back = True)
dbLog.log(ETP_LOG_WARNING,ETP_LOG_NORMAL,"etpDatabase: online database already locked. Waiting 2 minutes")
dbLog.log(ETP_LOGPRI_WARNING,ETP_LOGLEVEL_NORMAL,"etpDatabase: online database already locked. Waiting 2 minutes")
unlocked = False
for x in range(120):
time.sleep(1)
if (not ftp.isFileAvailable(etpConst['etpdatabaselockfile'])):
dbLog.log(ETP_LOG_INFO,ETP_LOG_NORMAL,"etpDatabase: online database has been unlocked !")
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"etpDatabase: online database has been unlocked !")
print_info(red(" * ")+bold("HOORAY")+red(": online database has been unlocked. Locking back and syncing..."))
unlocked = True
break
if (unlocked):
break
dbLog.log(ETP_LOG_ERROR,ETP_LOG_NORMAL,"etpDatabase: online database has not been unlocked in time. Giving up.")
dbLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_NORMAL,"etpDatabase: online database has not been unlocked in time. Giving up.")
# time over
print_info(red(" * ")+bold("ERROR")+red(": online database has not been unlocked. Giving up. Who the hell is working on it? Damn, it's so frustrating for me. I'm a piece of python code with a soul dude!"))
# FIXME show the lock status
print_info(yellow(" * ")+green("Mirrors status table:"))
dbstatus = entropyTools.getMirrorsLock()
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"etpDatabase: showing mirrors status table:")
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"etpDatabase: showing mirrors status table:")
for db in dbstatus:
if (db[1]):
db[1] = red("Locked")
@@ -820,7 +820,7 @@ class etpDatabase:
db[2] = red("Locked")
else:
db[2] = green("Unlocked")
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE," "+entropyTools.extractFTPHostFromUri(db[0])+": DATABASE: "+db[1]+" | DOWNLOAD: "+db[2])
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE," "+entropyTools.extractFTPHostFromUri(db[0])+": DATABASE: "+db[1]+" | DOWNLOAD: "+db[2])
print_info(bold("\t"+entropyTools.extractFTPHostFromUri(db[0])+": ")+red("[")+yellow("DATABASE: ")+db[1]+red("] [")+yellow("DOWNLOAD: ")+db[2]+red("]"))
ftp.closeFTPConnection()
@@ -840,13 +840,13 @@ class etpDatabase:
# if the class is opened readOnly, close and forget
if (self.readOnly):
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"closeDB: closing database opened in readonly.")
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"closeDB: closing database opened in readonly.")
#self.connection.rollback()
self.cursor.close()
self.connection.close()
return
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"closeDB: closing database opened in read/write.")
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"closeDB: closing database opened in read/write.")
# FIXME verify all this shit, for now it works...
if (entropyTools.dbStatus.isDatabaseAlreadyTainted()) and (not entropyTools.dbStatus.isDatabaseAlreadyBumped()):
@@ -865,15 +865,15 @@ class etpDatabase:
def commitChanges(self):
if (not self.readOnly):
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"commitChanges: writing changes to database.")
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"commitChanges: writing changes to database.")
self.connection.commit()
self.taintDatabase()
else:
dbLog.log(ETP_LOG_WARNING,ETP_LOG_VERBOSE,"commitChanges: discarding changes to database (opened readonly).")
dbLog.log(ETP_LOGPRI_WARNING,ETP_LOGLEVEL_VERBOSE,"commitChanges: discarding changes to database (opened readonly).")
self.discardChanges() # is it ok?
def taintDatabase(self):
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"taintDatabase: called.")
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"taintDatabase: called.")
# taint the database status
f = open(etpConst['etpdatabasedir']+"/"+etpConst['etpdatabasetaintfile'],"w")
f.write(etpConst['currentarch']+" database tainted\n")
@@ -882,13 +882,13 @@ class etpDatabase:
entropyTools.dbStatus.setDatabaseTaint(True)
def untaintDatabase(self):
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"untaintDatabase: called.")
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"untaintDatabase: called.")
entropyTools.dbStatus.setDatabaseTaint(False)
# untaint the database status
os.system("rm -f "+etpConst['etpdatabasedir']+"/"+etpConst['etpdatabasetaintfile'])
def revisionBump(self):
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"revisionBump: called.")
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"revisionBump: called.")
if (not os.path.isfile(etpConst['etpdatabasedir']+"/"+etpConst['etpdatabaserevisionfile'])):
revision = 0
else:
@@ -902,18 +902,18 @@ class etpDatabase:
f.close()
def isDatabaseTainted(self):
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"isDatabaseTainted: called.")
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"isDatabaseTainted: called.")
if os.path.isfile(etpConst['etpdatabasedir']+"/"+etpConst['etpdatabasetaintfile']):
return True
return False
def discardChanges(self):
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"discardChanges: called.")
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"discardChanges: called.")
self.connection.rollback()
# never use this unless you know what you're doing
def initializeDatabase(self):
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"initializeDatabase: called.")
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"initializeDatabase: called.")
self.cursor.execute(etpSQLInitDestroyAll)
self.cursor.execute(etpSQLInit)
self.commitChanges()
@@ -922,7 +922,7 @@ class etpDatabase:
# if it does not exist, it fires up addPackage
# otherwise it fires up updatePackage
def handlePackage(self, etpData, forceBump = False):
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"handlePackage: called.")
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"handlePackage: called.")
if (not self.isPackageAvailable(etpData['category']+"/"+etpData['name']+"-"+etpData['version'])):
update, revision, etpDataUpdated = self.addPackage(etpData)
else:
@@ -932,7 +932,7 @@ class etpDatabase:
# default add an unstable package
def addPackage(self, etpData, revision = 0, wantedBranch = "unstable"):
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"addPackage: called.")
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"addPackage: called.")
# Handle package name
etpData['download'] = etpData['download'].split(".tbz2")[0]
@@ -941,7 +941,7 @@ class etpDatabase:
# if a similar package, in the same branch exists, mark for removal
searchsimilar = self.searchSimilarPackages(etpData['category']+"/"+etpData['name'], branch = wantedBranch)
dbLog.log(ETP_LOG_INFO,ETP_LOG_NORMAL,"addPackage: here is the list of similar packages (that will be removed) found for "+etpData['category']+"/"+etpData['name']+": "+str(searchsimilar))
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"addPackage: here is the list of similar packages (that will be removed) found for "+etpData['category']+"/"+etpData['name']+": "+str(searchsimilar))
removelist = []
for oldpkg in searchsimilar:
# get the package slot
@@ -953,9 +953,9 @@ class etpDatabase:
for pkg in removelist:
self.removePackage(pkg)
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"addPackage: inserting: ")
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"addPackage: inserting: ")
for ln in etpData:
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"\t "+ln+": "+str(etpData[ln]))
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"\t "+ln+": "+str(etpData[ln]))
# wantedBranch = etpData['branch']
self.cursor.execute(
'INSERT into etpData VALUES '
@@ -998,11 +998,11 @@ class etpDatabase:
# returns False,revision if not
def updatePackage(self, etpData, forceBump = False):
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"updatePackage: called.")
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"updatePackage: called.")
# are there any stable packages?
searchsimilarStable = self.searchSimilarPackages(etpData['category']+"/"+etpData['name'], branch = "stable")
dbLog.log(ETP_LOG_INFO,ETP_LOG_NORMAL,"updatePackage: here is the list of similar stable packages found for "+etpData['category']+"/"+etpData['name']+": "+str(searchsimilarStable))
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"updatePackage: here is the list of similar stable packages found for "+etpData['category']+"/"+etpData['name']+": "+str(searchsimilarStable))
# filter the one with the same version
stableFound = False
for pkg in searchsimilarStable:
@@ -1016,7 +1016,7 @@ class etpDatabase:
if (stableFound):
dbLog.log(ETP_LOG_INFO,ETP_LOG_NORMAL,"updatePackage: found an old stable package, if etpData['neededlibs'] is equal, mark the branch of this updated package, stable too")
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"updatePackage: found an old stable package, if etpData['neededlibs'] is equal, mark the branch of this updated package, stable too")
# in this case, we should compare etpData['neededlibs'] with the db entry to see if there has been a API breakage
dbStoredNeededLibs = self.retrievePackageVar(etpData['category'] + "/" + etpData['name'] + "-" + etpData['version'], "neededlibs", "stable")
@@ -1026,7 +1026,7 @@ class etpDatabase:
# - same libraries requirements
# setup etpData['branch'] accordingly
etpData['branch'] = "stable"
dbLog.log(ETP_LOG_INFO,ETP_LOG_NORMAL,"updatePackage: yes, their etpData['neededlibs'] match, marking the new package stable.")
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"updatePackage: yes, their etpData['neededlibs'] match, marking the new package stable.")
# get selected package revision
@@ -1049,17 +1049,17 @@ class etpDatabase:
# bump revision nevertheless
curRevision += 1
dbLog.log(ETP_LOG_INFO,ETP_LOG_NORMAL,"updatePackage: current revision set to "+str(curRevision))
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"updatePackage: current revision set to "+str(curRevision))
# add the new one
dbLog.log(ETP_LOG_INFO,ETP_LOG_NORMAL,"updatePackage: complete. Now spawning addPackage.")
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"updatePackage: complete. Now spawning addPackage.")
self.addPackage(etpData,curRevision,etpData['branch'])
# You must provide the full atom to this function
# FIXME: this must be fixed to work with branches
def removePackage(self,key, branch = "unstable"):
dbLog.log(ETP_LOG_INFO,ETP_LOG_NORMAL,"removePackage: trying to remove (if exists) -> "+str(key)+" | branch: "+branch)
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"removePackage: trying to remove (if exists) -> "+str(key)+" | branch: "+branch)
key = entropyTools.removePackageOperators(key)
self.cursor.execute('DELETE FROM etpData WHERE atom = "'+key+'" AND branch = "'+branch+'"')
self.commitChanges()
@@ -1080,20 +1080,20 @@ class etpDatabase:
for i in myEtpData:
myEtpData[i] = self.retrievePackageVar(dbPkgInfo,i,dbPkgBranch)
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"comparePackagesData: called for "+str(etpData['name'])+" and "+str(myEtpData['name'])+" | branch: "+dbPkgBranch)
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"comparePackagesData: called for "+str(etpData['name'])+" and "+str(myEtpData['name'])+" | branch: "+dbPkgBranch)
for i in etpData:
if etpData[i] != myEtpData[i]:
dbLog.log(ETP_LOG_WARNING,ETP_LOG_VERBOSE,"comparePackagesData: they don't match")
dbLog.log(ETP_LOGPRI_WARNING,ETP_LOGLEVEL_VERBOSE,"comparePackagesData: they don't match")
return False
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"comparePackagesData: they match")
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"comparePackagesData: they match")
return True
# You must provide the full atom to this function
def retrievePackageInfo(self,pkgkey, branch = "unstable"):
pkgkey = entropyTools.removePackageOperators(pkgkey)
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"retrievePackageInfo: retrieving package info for "+pkgkey+" | branch: "+branch)
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"retrievePackageInfo: retrieving package info for "+pkgkey+" | branch: "+branch)
result = []
self.cursor.execute('SELECT * FROM etpData WHERE atom = "'+pkgkey+'" AND branch = "'+branch+'"')
for row in self.cursor:
@@ -1103,7 +1103,7 @@ class etpDatabase:
# You must provide the full atom to this function
def retrievePackageVar(self,pkgkey,pkgvar, branch = "unstable"):
pkgkey = entropyTools.removePackageOperators(pkgkey)
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"retrievePackageVar: retrieving package variable "+pkgvar+" for "+pkgkey+" | branch: "+branch)
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"retrievePackageVar: retrieving package variable "+pkgvar+" for "+pkgkey+" | branch: "+branch)
result = []
self.cursor.execute('SELECT "'+pkgvar+'" FROM etpData WHERE atom = "'+pkgkey+'" AND branch = "'+branch+'"')
for row in self.cursor:
@@ -1117,7 +1117,7 @@ class etpDatabase:
# package associated to a certain binary package file (.tbz2)
def retrievePackageVarFromBinaryPackage(self,binaryPkgName,pkgvar):
# search binary package
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"retrievePackageVarFromBinaryPackage: retrieving package variable "+pkgvar+" for "+binaryPkgName)
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"retrievePackageVarFromBinaryPackage: retrieving package variable "+pkgvar+" for "+binaryPkgName)
result = []
self.cursor.execute('SELECT "'+pkgvar+'" FROM etpData WHERE download = "'+etpConst['binaryurirelativepath']+binaryPkgName+'"')
for row in self.cursor:
@@ -1130,34 +1130,34 @@ class etpDatabase:
# You must provide the full atom to this function
# WARNING: this function does not support branches !!!
def isPackageAvailable(self,pkgkey):
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"isPackageAvailable: called.")
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"isPackageAvailable: called.")
pkgkey = entropyTools.removePackageOperators(pkgkey)
result = []
self.cursor.execute('SELECT * FROM etpData WHERE atom = "'+pkgkey+'"')
for row in self.cursor:
result.append(row)
if result == []:
dbLog.log(ETP_LOG_WARNING,ETP_LOG_NORMAL,"isPackageAvailable: "+pkgkey+" not available.")
dbLog.log(ETP_LOGPRI_WARNING,ETP_LOGLEVEL_NORMAL,"isPackageAvailable: "+pkgkey+" not available.")
return False
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"isPackageAvailable: "+pkgkey+" available.")
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"isPackageAvailable: "+pkgkey+" available.")
return True
# This version is more specific and supports branches
def isSpecificPackageAvailable(self,pkgkey, branch):
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"isSpecificPackageAvailable: called.")
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"isSpecificPackageAvailable: called.")
pkgkey = entropyTools.removePackageOperators(pkgkey)
result = []
self.cursor.execute('SELECT atom FROM etpData WHERE atom LIKE "'+pkgkey+'" AND branch = "'+branch+'"')
for row in self.cursor:
result.append(row[0])
if result == []:
dbLog.log(ETP_LOG_WARNING,ETP_LOG_NORMAL,"isSpecificPackageAvailable: "+pkgkey+" | branch: "+branch+" -> not found.")
dbLog.log(ETP_LOGPRI_WARNING,ETP_LOGLEVEL_NORMAL,"isSpecificPackageAvailable: "+pkgkey+" | branch: "+branch+" -> not found.")
return False
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"isSpecificPackageAvailable: "+pkgkey+" | branch: "+branch+" -> found !")
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"isSpecificPackageAvailable: "+pkgkey+" | branch: "+branch+" -> found !")
return True
def searchPackages(self,keyword):
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"searchPackages: called for "+keyword)
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"searchPackages: called for "+keyword)
result = []
self.cursor.execute('SELECT atom FROM etpData WHERE atom LIKE "%'+keyword+'%"')
for row in self.cursor:
@@ -1165,7 +1165,7 @@ class etpDatabase:
return result
def searchPackagesInBranch(self,keyword,branch):
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"searchPackagesInBranch: called.")
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"searchPackagesInBranch: called.")
result = []
self.cursor.execute('SELECT atom FROM etpData WHERE atom LIKE "%'+keyword+'%" AND branch = "'+branch+'"')
for row in self.cursor:
@@ -1176,7 +1176,7 @@ class etpDatabase:
# you must provide something like: media-sound/amarok
# optionally, you can add version too.
def searchSimilarPackages(self,atom, branch = "unstable"):
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"searchSimilarPackages: called for "+atom+" | branch: "+branch)
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"searchSimilarPackages: called for "+atom+" | branch: "+branch)
category = atom.split("/")[0]
name = atom.split("/")[1]
result = []
@@ -1188,7 +1188,7 @@ class etpDatabase:
# NOTE: unstable and stable packages are pulled in
# so, there might be duplicates! that's normal
def listAllPackages(self):
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"listAllPackages: called. ")
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"listAllPackages: called. ")
result = []
self.cursor.execute('SELECT atom FROM etpData')
for row in self.cursor:
@@ -1196,7 +1196,7 @@ class etpDatabase:
return result
def listAllPackagesTbz2(self):
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"listAllPackagesTbz2: called. ")
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"listAllPackagesTbz2: called. ")
result = []
pkglist = self.listAllPackages()
for pkg in pkglist:
@@ -1213,7 +1213,7 @@ class etpDatabase:
return result
def listStablePackages(self):
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"listStablePackages: called. ")
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"listStablePackages: called. ")
result = []
self.cursor.execute('SELECT atom FROM etpData WHERE branch = "stable"')
for row in self.cursor:
@@ -1221,7 +1221,7 @@ class etpDatabase:
return result
def listUnstablePackages(self):
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"listUnstablePackages: called. ")
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"listUnstablePackages: called. ")
result = []
self.cursor.execute('SELECT atom FROM etpData WHERE branch = "unstable"')
for row in self.cursor:
@@ -1229,7 +1229,7 @@ class etpDatabase:
return result
def searchStablePackages(self,atom):
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"searchStablePackages: called for "+atom)
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"searchStablePackages: called for "+atom)
category = atom.split("/")[0]
name = atom.split("/")[1]
result = []
@@ -1239,7 +1239,7 @@ class etpDatabase:
return result
def searchUnstablePackages(self,atom):
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"searchUnstablePackages: called for "+atom)
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"searchUnstablePackages: called for "+atom)
category = atom.split("/")[0]
name = atom.split("/")[1]
result = []
@@ -1251,12 +1251,12 @@ class etpDatabase:
# useful to quickly retrieve (and trash) all the data
# and look for problems.
def noopCycle(self):
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"noopCycle: called. ")
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"noopCycle: called. ")
self.cursor.execute('SELECT * FROM etpData')
def stabilizePackage(self,atom,stable = True):
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"stabilizePackage: called for "+atom+" | branch stable? -> "+str(stable))
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"stabilizePackage: called for "+atom+" | branch stable? -> "+str(stable))
action = "unstable"
removeaction = "stable"
@@ -1264,10 +1264,10 @@ class etpDatabase:
action = "stable"
removeaction = "unstable"
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"stabilizePackage: add action: "+action+" | remove action: "+removeaction)
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"stabilizePackage: add action: "+action+" | remove action: "+removeaction)
if (self.isSpecificPackageAvailable(atom, removeaction)):
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"stabilizePackage: there's something old that needs to be removed.")
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"stabilizePackage: there's something old that needs to be removed.")
# ! Get rid of old entries with the same slot, pkgcat/name that
# were already marked "stable"
# get its pkgname
@@ -1285,10 +1285,10 @@ class etpDatabase:
myslot = self.retrievePackageVar(result,"slot", branch = action)
if (myslot == slot):
removelist.append(result)
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"stabilizePackage: removelist: "+str(removelist))
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"stabilizePackage: removelist: "+str(removelist))
for pkg in removelist:
self.removePackage(pkg, branch = action)
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"stabilizePackage: updating "+atom+" setting branch: "+action)
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"stabilizePackage: updating "+atom+" setting branch: "+action)
self.cursor.execute('UPDATE etpData SET branch = "'+action+'" WHERE atom = "'+atom+'" AND branch = "'+removeaction+'"')
self.commitChanges()
@@ -1296,7 +1296,7 @@ class etpDatabase:
return False,action
def writePackageParameter(self,atom,field,what,branch):
dbLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"writePackageParameter: writing '"+what+"' into field '"+field+"' for '"+atom+"' | branch: "+branch)
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"writePackageParameter: writing '"+what+"' into field '"+field+"' for '"+atom+"' | branch: "+branch)
self.cursor.execute('UPDATE etpData SET '+field+' = "'+what+'" WHERE atom = "'+atom+'" AND branch = "'+branch+'"')
self.commitChanges()
+16 -13
View File
@@ -124,11 +124,13 @@ ETP_SMARTAPPSDIR = "/smartapps/"+ETP_ARCH_CONST
ETP_CONF_DIR = "/etc/entropy"
ETP_ROOT_DIR = "/"
ETP_LOG_DIR = ETP_DIR+"/"+"logs"
ETP_LOG_NORMAL = 1
ETP_LOG_VERBOSE = 2
ETP_LOG_INFO = "[ INFO ]"
ETP_LOG_WARNING = "[ WARNING ]"
ETP_LOG_ERROR = "[ ERROR ]"
ETP_SYSLOG_DIR = "/var/log/entropy/"
ETP_LOGLEVEL_NORMAL = 1
ETP_LOGLEVEL_VERBOSE = 2
ETP_LOGPRI_INFO = "[ INFO ]"
ETP_LOGPRI_WARNING = "[ WARNING ]"
ETP_LOGPRI_ERROR = "[ ERROR ]"
# NEVER APPEND another \n to this file because it will break the md5 check of reagent
ETP_HEADER_TEXT = "# Sabayon Linux (C - 2007) - Entropy Package Specifications (GPLv2)\n"
MAX_ETP_REVISION_COUNT = 99999
@@ -176,16 +178,17 @@ etpConst = {
'reagentloglevel': 1 , # Reagent log level (default: 1 - see reagent.conf for more info)
'activatorloglevel': 1, # # Activator log level (default: 1 - see activator.conf for more info)
'entropyloglevel': 1, # # Entropy log level (default: 1 - see entropy.conf for more info)
'spmbackendloglevel': 1, # # Source Package Manager backend log level (default: 1 - see entropy.conf for more info)
'logdir': ETP_LOG_DIR , # Log dir where ebuilds store their shit
'mirrorslogfile': ETP_LOG_DIR+"/mirrors.log", # Mirrors operations log file
'spmbackendlogfile': ETP_LOG_DIR+"/spmbackend.log", # Source Package Manager backend configuration log file
'databaselogfile': ETP_LOG_DIR+"/database.log", # Database operations log file
'enzymelogfile': ETP_LOG_DIR+"/enzyme.log", # Enzyme operations log file
'reagentlogfile': ETP_LOG_DIR+"/reagent.log", # Reagent operations log file
'activatorlogfile': ETP_LOG_DIR+"/activator.log", # Activator operations log file
'entropylogfile': ETP_LOG_DIR+"/entropy.log", # Activator operations log file
'syslogdir': ETP_SYSLOG_DIR, # Entropy system tools log directory
'mirrorslogfile': ETP_SYSLOG_DIR+"/mirrors.log", # Mirrors operations log file
'spmbackendlogfile': ETP_SYSLOG_DIR+"/spmbackend.log", # Source Package Manager backend configuration log file
'databaselogfile': ETP_SYSLOG_DIR+"/database.log", # Database operations log file
'enzymelogfile': ETP_SYSLOG_DIR+"/enzyme.log", # Enzyme operations log file
'reagentlogfile': ETP_SYSLOG_DIR+"/reagent.log", # Reagent operations log file
'activatorlogfile': ETP_SYSLOG_DIR+"/activator.log", # Activator operations log file
'entropylogfile': ETP_SYSLOG_DIR+"/entropy.log", # Activator operations log file
'distcc-status': False, # used by Enzyme, if True distcc is enabled
+60 -60
View File
@@ -37,7 +37,7 @@ dbStatus = databaseTools.databaseStatus()
# Logging initialization
import logTools
entropyLog = logTools.LogFile(level=etpConst['entropyloglevel'],filename = etpConst['entropylogfile'], header = "[Entropy]")
# example: entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"testFuncton: called.")
# example: entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"testFuncton: called.")
# EXIT STATUSES: 100-199
@@ -87,7 +87,7 @@ def md5sum(filepath):
# @returns the complete hash file path
# FIXME: add more hashes, SHA1 for example
def createHashFile(tbz2filepath):
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"createHashFile: for "+tbz2filepath)
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"createHashFile: for "+tbz2filepath)
md5hash = md5sum(tbz2filepath)
hashfile = tbz2filepath+etpConst['packageshashfileext']
f = open(hashfile,"w")
@@ -98,14 +98,14 @@ def createHashFile(tbz2filepath):
return hashfile
def compareMd5(filepath,checksum):
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"compareMd5: called. ")
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"compareMd5: called. ")
checksum = str(checksum)
result = md5sum(filepath)
result = str(result)
if checksum == result:
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"compareMd5: match. ")
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"compareMd5: match. ")
return True
entropyLog.log(ETP_LOG_WARNING,ETP_LOG_VERBOSE,"compareMd5: no match. ")
entropyLog.log(ETP_LOGPRI_WARNING,ETP_LOGLEVEL_VERBOSE,"compareMd5: no match. ")
return False
def md5string(string):
@@ -278,7 +278,7 @@ def filterDuplicatedEntries(nameslist):
# Tool to run commands
def spawnCommand(command, redirect = None):
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"spawnCommand: called for: "+command)
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"spawnCommand: called for: "+command)
if redirect is not None:
command += " "+redirect
rc = os.system(command)
@@ -294,7 +294,7 @@ def extractFTPHostFromUri(uri):
# This function check the Entropy online database status
def getEtpRemoteDatabaseStatus():
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"getEtpRemoteDatabaseStatus: called.")
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"getEtpRemoteDatabaseStatus: called.")
uriDbInfo = []
for uri in etpConst['activatoruploaduris']:
@@ -320,13 +320,13 @@ def getEtpRemoteDatabaseStatus():
uriDbInfo.append(info)
ftp.closeFTPConnection()
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"getEtpRemoteDatabaseStatus: dump -> "+str(uriDbInfo))
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"getEtpRemoteDatabaseStatus: dump -> "+str(uriDbInfo))
return uriDbInfo
def syncRemoteDatabases(noUpload = False, justStats = False):
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"syncRemoteDatabases: called.")
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"syncRemoteDatabases: called.")
remoteDbsStatus = getEtpRemoteDatabaseStatus()
print_info(green(" * ")+red("Remote Entropy Database Repository Status:"))
@@ -439,13 +439,13 @@ def syncRemoteDatabases(noUpload = False, justStats = False):
uploadList.append(dbstat)
if (downloadLatest == []) and (not uploadLatest):
entropyLog.log(ETP_LOG_INFO,ETP_LOG_NORMAL,"syncRemoteDatabases: online database does not need to be updated.")
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"syncRemoteDatabases: online database does not need to be updated.")
print_info(green(" * ")+red("Online database does not need to be updated."))
return
# now run the selected task!
if (downloadLatest != []):
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"syncRemoteDatabases: download latest database needed.")
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"syncRemoteDatabases: download latest database needed.")
# match the proper URI
for uri in etpConst['activatoruploaduris']:
if downloadLatest[0].startswith(uri):
@@ -453,7 +453,7 @@ def syncRemoteDatabases(noUpload = False, justStats = False):
downloadDatabase(downloadLatest[0])
if (uploadLatest) and (not noUpload):
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"syncRemoteDatabases: some mirrors don't have the latest database.")
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"syncRemoteDatabases: some mirrors don't have the latest database.")
print_info(green(" * ")+red("Starting to update the needed mirrors ..."))
_uploadList = []
for uri in etpConst['activatoruploaduris']:
@@ -474,7 +474,7 @@ def syncRemoteDatabases(noUpload = False, justStats = False):
def uploadDatabase(uris):
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"uploadDatabase: called.")
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"uploadDatabase: called.")
# our fancy compressor :-)
import gzip
@@ -482,7 +482,7 @@ def uploadDatabase(uris):
for uri in uris:
downloadLockDatabases(True,[uri])
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"uploadDatabase: uploading data to: "+extractFTPHostFromUri(uri))
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"uploadDatabase: uploading data to: "+extractFTPHostFromUri(uri))
print_info(green(" * ")+red("Uploading database to ")+bold(extractFTPHostFromUri(uri))+red(" ..."))
print_info(green(" * ")+red("Connecting to ")+bold(extractFTPHostFromUri(uri))+red(" ..."), back = True)
@@ -531,10 +531,10 @@ def uploadDatabase(uris):
print_info(green(" * ")+red("Uploading file ")+bold(etpConst['etpdatabasedir'] + "/" + etpConst['etpdatabasehashfile'])+red(" ..."), back = True)
rc = ftp.uploadFile(etpConst['etpdatabasedir'] + "/" + etpConst['etpdatabasehashfile'],True)
if (rc == True):
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"uploadDatabase: uploading to: "+extractFTPHostFromUri(uri)+" successfull.")
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"uploadDatabase: uploading to: "+extractFTPHostFromUri(uri)+" successfull.")
print_info(green(" * ")+red("Upload of ")+bold(etpConst['etpdatabasedir'] + "/" + etpConst['etpdatabasehashfile'])+red(" completed. Disconnecting."))
else:
entropyLog.log(ETP_LOG_ERROR,ETP_LOG_VERBOSE,"uploadDatabase: uploading to: "+extractFTPHostFromUri(uri)+" UNSUCCESSFUL! ERROR!.")
entropyLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_VERBOSE,"uploadDatabase: uploading to: "+extractFTPHostFromUri(uri)+" UNSUCCESSFUL! ERROR!.")
print_warning(yellow(" * ")+red("Cannot properly upload to ")+bold(extractFTPHostFromUri(uri))+red(". Please check."))
# close connection
@@ -545,11 +545,11 @@ def uploadDatabase(uris):
def downloadDatabase(uri):
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"downloadDatabase: called.")
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"downloadDatabase: called.")
import gzip
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"downloadDatabase: downloading from -> "+extractFTPHostFromUri(uri))
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"downloadDatabase: downloading from -> "+extractFTPHostFromUri(uri))
print_info(green(" * ")+red("Downloading database from ")+bold(extractFTPHostFromUri(uri))+red(" ..."))
print_info(green(" * ")+red("Connecting to ")+bold(extractFTPHostFromUri(uri))+red(" ..."), back = True)
@@ -579,7 +579,7 @@ def downloadDatabase(uri):
print_info(green(" * ")+red("Decompression of ")+bold(etpConst['etpdatabasefilegzip'])+red(" completed."))
# downloading revision file
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"downloadDatabase: downloading revision file for "+extractFTPHostFromUri(uri))
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"downloadDatabase: downloading revision file for "+extractFTPHostFromUri(uri))
print_info(green(" * ")+red("Downloading file to ")+bold(etpConst['etpdatabaserevisionfile'])+red(" ..."), back = True)
rc = ftp.downloadFile(etpConst['etpdatabaserevisionfile'],os.path.dirname(etpConst['etpdatabasefilepath']),True)
if (rc == True):
@@ -587,17 +587,17 @@ def downloadDatabase(uri):
else:
print_warning(yellow(" * ")+red("Cannot properly download to ")+bold(extractFTPHostFromUri(uri))+red(". Please check."))
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"downloadDatabase: downloading digest file for "+extractFTPHostFromUri(uri))
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"downloadDatabase: downloading digest file for "+extractFTPHostFromUri(uri))
# downlading digest
print_info(green(" * ")+red("Downloading file to ")+bold(etpConst['etpdatabasehashfile'])+red(" ..."), back = True)
rc = ftp.downloadFile(etpConst['etpdatabasehashfile'],os.path.dirname(etpConst['etpdatabasefilepath']),True)
if (rc == True):
print_info(green(" * ")+red("Download of ")+bold(etpConst['etpdatabasehashfile'])+red(" completed. Disconnecting."))
else:
entropyLog.log(ETP_LOG_WARNING,ETP_LOG_VERBOSE,"downloadDatabase: Cannot properly download from "+extractFTPHostFromUri(uri)+". Please check.")
entropyLog.log(ETP_LOGPRI_WARNING,ETP_LOGLEVEL_VERBOSE,"downloadDatabase: Cannot properly download from "+extractFTPHostFromUri(uri)+". Please check.")
print_warning(yellow(" * ")+red("Cannot properly download from ")+bold(extractFTPHostFromUri(uri))+red(". Please check."))
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"downloadDatabase: do some tidy.")
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"downloadDatabase: do some tidy.")
os.system("rm -f " + etpConst['etpdatabasedir'] + "/" + etpConst['etpdatabasefilegzip']+" &> /dev/null")
# close connection
ftp.closeFTPConnection()
@@ -607,7 +607,7 @@ def downloadDatabase(uri):
# @ the second parameter is referred to upload locks, while the second to download ones
def getMirrorsLock():
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"getMirrorsLock: called.")
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"getMirrorsLock: called.")
# parse etpConst['activatoruploaduris']
dbstatus = []
@@ -628,13 +628,13 @@ def getMirrorsLock():
def downloadPackageFromMirror(uri,pkgfile):
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"downloadPackageFromMirror: called for "+extractFTPHostFromUri(uri)+" and file -> "+pkgfile)
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"downloadPackageFromMirror: called for "+extractFTPHostFromUri(uri)+" and file -> "+pkgfile)
tries = 0
maxtries = 5
for i in range(maxtries):
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"downloadPackageFromMirror: ("+tries+"/"+maxtries+") downloading -> "+pkgfile)
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"downloadPackageFromMirror: ("+tries+"/"+maxtries+") downloading -> "+pkgfile)
pkgfilename = pkgfile.split("/")[len(pkgfile.split("/"))-1]
print_info(red(" * Connecting to ")+bold(extractFTPHostFromUri(uri)), back = True)
@@ -645,12 +645,12 @@ def downloadPackageFromMirror(uri,pkgfile):
print_info(red(" * Downloading ")+yellow(pkgfilename)+red(" from ")+bold(extractFTPHostFromUri(uri)))
rc = ftp.downloadFile(pkgfilename,etpConst['packagesbindir'])
if (rc is None):
entropyLog.log(ETP_LOG_ERROR,ETP_LOG_VERBOSE,"downloadPackageFromMirror: ("+tries+"/"+maxtries+") Error. File not found. -> "+pkgfile)
entropyLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_VERBOSE,"downloadPackageFromMirror: ("+tries+"/"+maxtries+") Error. File not found. -> "+pkgfile)
# file does not exist
print_warning(red(" * File ")+yellow(pkgfilename)+red(" does not exist remotely on ")+bold(extractFTPHostFromUri(uri)))
ftp.closeFTPConnection()
return None
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"downloadPackageFromMirror: ("+tries+"/"+maxtries+") checking md5 for -> "+pkgfile)
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"downloadPackageFromMirror: ("+tries+"/"+maxtries+") checking md5 for -> "+pkgfile)
# check md5
dbconn = databaseTools.etpDatabase(readOnly = True)
storedmd5 = dbconn.retrievePackageVarFromBinaryPackage(pkgfilename,"digest")
@@ -662,11 +662,11 @@ def downloadPackageFromMirror(uri,pkgfile):
return True
else:
if (tries == maxtries):
entropyLog.log(ETP_LOG_ERROR,ETP_LOG_VERBOSE,"downloadPackageFromMirror: Max tries limit reached. Checksum does not match. Please consider to download or repackage again. Giving up.")
entropyLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_VERBOSE,"downloadPackageFromMirror: Max tries limit reached. Checksum does not match. Please consider to download or repackage again. Giving up.")
print_warning(red(" * Package ")+yellow(pkgfilename)+red(" checksum does not match. Please consider to download or repackage again. Giving up."))
return False
else:
entropyLog.log(ETP_LOG_ERROR,ETP_LOG_VERBOSE,"downloadPackageFromMirror: Checksum does not match. Trying to download it again...")
entropyLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_VERBOSE,"downloadPackageFromMirror: Checksum does not match. Trying to download it again...")
print_warning(red(" * Package ")+yellow(pkgfilename)+red(" checksum does not match. Trying to download it again..."))
tries += 1
if os.path.isfile(etpConst['packagesbindir']+"/"+pkgfilename):
@@ -685,7 +685,7 @@ def compressTarBz2(storepath,pathtocompress):
# tar.bz2 uncompress function...
def uncompressTarBz2(filepath, extractPath = None):
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"uncompressTarBz2: called. ")
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"uncompressTarBz2: called. ")
if extractPath is None:
extractPath = os.path.dirname(filepath)
cmd = "tar xjf "+filepath+" -C "+extractPath
@@ -705,7 +705,7 @@ def bytesIntoHuman(bytes):
# hide password from full ftp URI
def hideFTPpassword(uri):
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"hideFTPpassword: called. ")
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"hideFTPpassword: called. ")
ftppassword = uri.split("@")[:len(uri.split("@"))-1]
if len(ftppassword) > 1:
import string
@@ -724,14 +724,14 @@ def hideFTPpassword(uri):
def lockDatabases(lock = True, mirrorList = []):
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"lockDatabases: called. ")
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"lockDatabases: called. ")
outstat = False
if (mirrorList == []):
mirrorList = etpConst['activatoruploaduris']
for uri in mirrorList:
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"lockDatabases: locking? "+str(lock)+" for: "+extractFTPHostFromUri(uri))
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"lockDatabases: locking? "+str(lock)+" for: "+extractFTPHostFromUri(uri))
if (lock):
print_info(yellow(" * ")+red("Locking ")+bold(extractFTPHostFromUri(uri))+red(" mirror..."),back = True)
@@ -743,13 +743,13 @@ def lockDatabases(lock = True, mirrorList = []):
# check if the lock is already there
if (lock):
if (ftp.isFileAvailable(etpConst['etpdatabaselockfile'])):
entropyLog.log(ETP_LOG_WARNING,ETP_LOG_VERBOSE,"lockDatabases: mirror "+extractFTPHostFromUri(uri)+" already locked.")
entropyLog.log(ETP_LOGPRI_WARNING,ETP_LOGLEVEL_VERBOSE,"lockDatabases: mirror "+extractFTPHostFromUri(uri)+" already locked.")
print_info(green(" * ")+red("Mirror database at ")+bold(extractFTPHostFromUri(uri))+red(" already locked."))
ftp.closeFTPConnection()
continue
else:
if (not ftp.isFileAvailable(etpConst['etpdatabaselockfile'])):
entropyLog.log(ETP_LOG_WARNING,ETP_LOG_VERBOSE,"lockDatabases: mirror "+extractFTPHostFromUri(uri)+" already unlocked.")
entropyLog.log(ETP_LOGPRI_WARNING,ETP_LOGLEVEL_VERBOSE,"lockDatabases: mirror "+extractFTPHostFromUri(uri)+" already unlocked.")
print_info(green(" * ")+red("Mirror database at ")+bold(extractFTPHostFromUri(uri))+red(" already unlocked."))
ftp.closeFTPConnection()
continue
@@ -760,24 +760,24 @@ def lockDatabases(lock = True, mirrorList = []):
f.close()
rc = ftp.uploadFile(etpConst['etpdatabasedir']+"/"+etpConst['etpdatabaselockfile'],ascii= True)
if (rc == True):
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"lockDatabases: mirror "+extractFTPHostFromUri(uri)+" successfully locked.")
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"lockDatabases: mirror "+extractFTPHostFromUri(uri)+" successfully locked.")
print_info(green(" * ")+red("Succesfully locked ")+bold(extractFTPHostFromUri(uri))+red(" mirror."))
else:
outstat = True
print "\n"
entropyLog.log(ETP_LOG_ERROR,ETP_LOG_VERBOSE,"lockDatabases: mirror "+extractFTPHostFromUri(uri)+" had an unknown issue while locking.")
entropyLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_VERBOSE,"lockDatabases: mirror "+extractFTPHostFromUri(uri)+" had an unknown issue while locking.")
print_warning(red(" * ")+red("A problem occured while locking ")+bold(extractFTPHostFromUri(uri))+red(" mirror. Please have a look."))
if os.path.isfile(etpConst['etpdatabasedir']+"/"+etpConst['etpdatabaselockfile']):
os.remove(etpConst['etpdatabasedir']+"/"+etpConst['etpdatabaselockfile'])
else:
rc = ftp.deleteFile(etpConst['etpdatabaselockfile'])
if (rc):
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"lockDatabases: mirror "+extractFTPHostFromUri(uri)+" successfully unlocked.")
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"lockDatabases: mirror "+extractFTPHostFromUri(uri)+" successfully unlocked.")
print_info(green(" * ")+red("Succesfully unlocked ")+bold(extractFTPHostFromUri(uri))+red(" mirror."))
if os.path.isfile(etpConst['etpdatabasedir']+"/"+etpConst['etpdatabaselockfile']):
os.remove(etpConst['etpdatabasedir']+"/"+etpConst['etpdatabaselockfile'])
else:
entropyLog.log(ETP_LOG_ERROR,ETP_LOG_VERBOSE,"lockDatabases: mirror "+extractFTPHostFromUri(uri)+" had an unknown issue while unlocking.")
entropyLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_VERBOSE,"lockDatabases: mirror "+extractFTPHostFromUri(uri)+" had an unknown issue while unlocking.")
outstat = True
print "\n"
print_warning(red(" * ")+red("A problem occured while unlocking ")+bold(extractFTPHostFromUri(uri))+red(" mirror. Please have a look."))
@@ -786,17 +786,17 @@ def lockDatabases(lock = True, mirrorList = []):
def downloadLockDatabases(lock = True, mirrorList = []):
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"downloadLockDatabases: called. ")
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"downloadLockDatabases: called. ")
outstat = False
if (mirrorList == []):
mirrorList = etpConst['activatoruploaduris']
for uri in mirrorList:
if (lock):
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"downloadLockDatabases: download locking -> "+extractFTPHostFromUri(uri))
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"downloadLockDatabases: download locking -> "+extractFTPHostFromUri(uri))
print_info(yellow(" * ")+red("Locking ")+bold(extractFTPHostFromUri(uri))+red(" download mirror..."),back = True)
else:
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"downloadLockDatabases: download unlocking -> "+extractFTPHostFromUri(uri))
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"downloadLockDatabases: download unlocking -> "+extractFTPHostFromUri(uri))
print_info(yellow(" * ")+red("Unlocking ")+bold(extractFTPHostFromUri(uri))+red(" download mirror..."),back = True)
ftp = mirrorTools.handlerFTP(uri)
# upload the lock file to database/%ARCH% directory
@@ -809,7 +809,7 @@ def downloadLockDatabases(lock = True, mirrorList = []):
continue
else:
if (not ftp.isFileAvailable(etpConst['etpdatabasedownloadlockfile'])):
entropyLog.log(ETP_LOG_WARNING,ETP_LOG_VERBOSE,"downloadLockDatabases: already unlocked -> "+extractFTPHostFromUri(uri))
entropyLog.log(ETP_LOGPRI_WARNING,ETP_LOGLEVEL_VERBOSE,"downloadLockDatabases: already unlocked -> "+extractFTPHostFromUri(uri))
print_info(green(" * ")+red("Download mirror at ")+bold(extractFTPHostFromUri(uri))+red(" already unlocked."))
ftp.closeFTPConnection()
continue
@@ -820,20 +820,20 @@ def downloadLockDatabases(lock = True, mirrorList = []):
f.close()
rc = ftp.uploadFile(etpConst['packagestmpdir']+"/"+etpConst['etpdatabasedownloadlockfile'],ascii= True)
if (rc == True):
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"downloadLockDatabases: successfully locked -> "+extractFTPHostFromUri(uri))
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"downloadLockDatabases: successfully locked -> "+extractFTPHostFromUri(uri))
print_info(green(" * ")+red("Succesfully locked ")+bold(extractFTPHostFromUri(uri))+red(" download mirror."))
else:
entropyLog.log(ETP_LOG_ERROR,ETP_LOG_VERBOSE,"downloadLockDatabases: a problem occured while trying to download lock -> "+extractFTPHostFromUri(uri))
entropyLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_VERBOSE,"downloadLockDatabases: a problem occured while trying to download lock -> "+extractFTPHostFromUri(uri))
outstat = True
print "\n"
print_warning(red(" * ")+red("A problem occured while locking ")+bold(extractFTPHostFromUri(uri))+red(" download mirror. Please have a look."))
else:
rc = ftp.deleteFile(etpConst['etpdatabasedownloadlockfile'])
if (rc):
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"downloadLockDatabases: successfully unlocked -> "+extractFTPHostFromUri(uri))
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"downloadLockDatabases: successfully unlocked -> "+extractFTPHostFromUri(uri))
print_info(green(" * ")+red("Succesfully unlocked ")+bold(extractFTPHostFromUri(uri))+red(" download mirror."))
else:
entropyLog.log(ETP_LOG_ERROR,ETP_LOG_VERBOSE,"downloadLockDatabases: a problem occured while trying to download unlock -> "+extractFTPHostFromUri(uri))
entropyLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_VERBOSE,"downloadLockDatabases: a problem occured while trying to download unlock -> "+extractFTPHostFromUri(uri))
outstat = True
print "\n"
print_warning(red(" * ")+red("A problem occured while unlocking ")+bold(extractFTPHostFromUri(uri))+red(" download mirror. Please have a look."))
@@ -841,7 +841,7 @@ def downloadLockDatabases(lock = True, mirrorList = []):
return outstat
def getLocalDatabaseRevision():
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"getLocalDatabaseRevision: called. ")
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"getLocalDatabaseRevision: called. ")
if os.path.isfile(etpConst['etpdatabasedir']+"/"+etpConst['etpdatabaserevisionfile']):
f = open(etpConst['etpdatabasedir']+"/"+etpConst['etpdatabaserevisionfile'])
rev = f.readline().strip()
@@ -854,7 +854,7 @@ def getLocalDatabaseRevision():
# parse a dumped .etp file and returns etpData
def parseEtpDump(file):
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"parseEtpDump: called. ")
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"parseEtpDump: called. ")
myEtpData = etpData.copy()
# reset
@@ -873,7 +873,7 @@ def parseEtpDump(file):
# Distcc check status function
def setDistCC(status = True):
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"setDistCC: called. ")
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"setDistCC: called. ")
f = open(etpConst['enzymeconf'],"r")
enzymeconf = f.readlines()
@@ -894,7 +894,7 @@ def setDistCC(status = True):
def getDistCCHosts():
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"getDistCCHosts: called.")
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"getDistCCHosts: called.")
f = open(etpConst['enzymeconf'],"r")
enzymeconf = f.readlines()
@@ -905,15 +905,15 @@ def getDistCCHosts():
line = line.strip().split("|")[1].split()
for host in line:
hostslist.append(host)
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"getDistCCHosts: hosts list dump -> "+str(hostslist))
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"getDistCCHosts: hosts list dump -> "+str(hostslist))
return hostslist
entropyLog.log(ETP_LOG_WARNING,ETP_LOG_VERBOSE,"getDistCCHosts: hosts list EMPTY.")
entropyLog.log(ETP_LOGPRI_WARNING,ETP_LOGLEVEL_VERBOSE,"getDistCCHosts: hosts list EMPTY.")
return []
# @returns True if validIP (type: string) is a valid IP
# @param validIP: IP string
def isValidIP(validIP):
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"getDistCCHosts: called. ")
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"getDistCCHosts: called. ")
validIPExpr = re.compile('(([0-9]|[01]?[0-9]{2}|2([0-4][0-9]|5[0-5]))\.){3}([0-9]|[01]?[0-9]{2}|2([0-4][0-9]|5[0-5]))$')
result = validIPExpr.match(validIP)
@@ -924,7 +924,7 @@ def isValidIP(validIP):
# you must provide a list
def addDistCCHosts(hosts):
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"addDistCCHosts: called.")
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"addDistCCHosts: called.")
hostslist = getDistCCHosts()
for host in hosts:
@@ -933,7 +933,7 @@ def addDistCCHosts(hosts):
# filter dupies
hostslist = list(set(hostslist))
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"addDistCCHosts: hostslist dump -> "+str(hostslist))
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"addDistCCHosts: hostslist dump -> "+str(hostslist))
# write back to file
f = open(etpConst['enzymeconf'],"r")
@@ -969,7 +969,7 @@ def addDistCCHosts(hosts):
# you must provide a list
def removeDistCCHosts(hosts):
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"removeDistCCHosts: called. ")
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"removeDistCCHosts: called. ")
hostslist = getDistCCHosts()
cleanedhosts = []
@@ -986,7 +986,7 @@ def removeDistCCHosts(hosts):
# filter dupies
cleanedhosts = list(set(cleanedhosts))
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"removeDistCCHosts: cleanedhosts dump: "+cleanedhosts)
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"removeDistCCHosts: cleanedhosts dump: "+cleanedhosts)
# write back to file
f = open(etpConst['enzymeconf'],"r")
@@ -1024,7 +1024,7 @@ def getDistCCStatus():
def isIPAvailable(ip):
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"isIPAvailable: called. ")
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"isIPAvailable: called. ")
rc = os.system("ping -c 1 "+ip+" &> /dev/null")
if (rc):
@@ -1088,7 +1088,7 @@ def alphaSorter(seq):
# Temporary files cleaner
def cleanup(options):
entropyLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"cleanup: with options: "+str(options))
entropyLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"cleanup: with options: "+str(options))
toCleanDirs = [ etpConst['packagestmpdir'], etpConst['logdir'] ]
counter = 0
+59 -12
View File
@@ -33,12 +33,16 @@ import string
# Logging initialization
import logTools
enzymeLog = logTools.LogFile(level=etpConst['enzymeloglevel'],filename = etpConst['enzymelogfile'], header = "[Enzyme]")
# example: enzymeLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"testFuncton: called.")
# EXIT STATUSES: 200-299
def getSyncTime():
"""gets and returns the timestamp info saved during
the last portage tree sync"""
enzymeLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"getSyncTime: called.")
lastSync = None
try:
f = open(etpConst['portagetreedir'] + "/metadata/timestamp")
@@ -57,14 +61,20 @@ def getSyncTime():
except:
print_warning("getSyncTime(): empty Portage tree (first run?) or no timestamp to read")
# NOTE: this function does not directly check if
# layman is installed !!!!
def listOverlays():
# NOTE: this function does not directly check if
# layman is installed !!!!
enzymeLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"listOverlays: called.")
lst = etpConst['overlays'].split()
return lst
# fetch the latest updates from Gentoo rsync mirrors
def sync(options):
enzymeLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"sync: called with options -> "+str(options))
myopts = options[1:]
enzymeNoSyncBack = True
enzymeOnlySyncBack = False
@@ -74,6 +84,7 @@ def sync(options):
# check if rsync is installed
rsync = commands.getoutput("which rsync")
if (not rsync.startswith("/")):
enzymeLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_NORMAL,"sync: rsync not found.")
print_error(red(bold("net-misc/rsync is not installed. Please install.")))
sys.exit(200)
@@ -91,18 +102,21 @@ def sync(options):
print_info(green("Syncing Entropy Portage Tree at: "+etpConst['portagetreedir']))
rc = spawnCommand(vdbPORTDIR+"="+etpConst['portagetreedir']+" "+cdbEMERGE+" --sync ", redirect = syncMiscRedirect) # redirect = "/dev/null"
if (rc != 0):
enzymeLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_NORMAL,"sync: an error occoured while syncing the Portage tree. Are you sure that your Internet connection works?")
print_error(red("an error occoured while syncing the Portage tree. Are you sure that your Internet connection works?"))
sys.exit(201)
if (not enzymeNoOverlaySync):
# syncing overlays
rc = overlay(['overlay','sync'])
if (not rc):
enzymeLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_NORMAL,"sync: an error occoured while syncing the overlays. Please check if it's all fine.")
print_warning(red("an error occoured while syncing the overlays. Please check if it's all fine."))
else:
print_info(green("Not syncing Entropy Portage Tree at: "+etpConst['portagetreedir']))
if (not enzymeNoSyncBack):
enzymeLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"sync: Syncing back Entropy Portage Tree at: "+etpConst['portagetreedir']+" to the official Portage Tree.")
print_info(green("Syncing back Entropy Portage Tree at: ")+bold(etpConst['portagetreedir'])+green(" to the official Portage Tree"))
# sync back to /usr/portage, but firstly, get user's PORTDIR
if os.path.isfile("/etc/make.conf"):
@@ -128,14 +142,19 @@ def sync(options):
officialPortageTreeDir = officialPortageTreeDir[:len(officialPortageTreeDir)-1]
# sync back
# FIXME: anything better?
enzymeLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"sync: spawning rsync...")
rc = spawnCommand("rsync --recursive --links --safe-links --perms --times --force --whole-file --delete --delete-after --exclude=/distfiles --exclude=/packages "+etpConst['portagetreedir']+" "+officialPortageTreeDir, redirect = syncMiscRedirect)
if (rc != 0):
enzymeLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_NORMAL,"sync: an error occoured while syncing back the official Portage Tree.")
print_error(red("an error occoured while syncing back the official Portage Tree."))
sys.exit(201)
def build(atoms):
enzymeLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"build: called with parameters -> "+str(atoms))
enzymeRequestVerbose = False
enzymeRequestForceRepackage = False
enzymeRequestForceRebuild = False
@@ -193,9 +212,11 @@ def build(atoms):
if (checkAtom(i)):
validAtoms.append(i)
else:
enzymeLog.log(ETP_LOGPRI_WARNING,ETP_LOGLEVEL_NORMAL,"build: "+str(i)+" -> is not a valid atom, it's masked or its name conflicts with something else.")
print_warning(red("* >>> ")+yellow(i)+" is not a valid atom, it's masked or its name conflicts with something else.")
if getBestAtom(i) == "!!conflicts":
# it conflicts with something
enzymeLog.log(ETP_LOGPRI_WARNING,ETP_LOGLEVEL_NORMAL,"build: "+str(i)+" -> Ambiguous package name. Please add category.")
print_warning(red("* ^^^ ")+"Ambiguous package name. Please add category.")
if validAtoms == []:
@@ -532,6 +553,7 @@ def build(atoms):
if (rc is not None):
packagesPaths.append(rc)
else:
enzymeLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_NORMAL,"build: (PackagesQuickpkg) "+str(dep)+" -> quickpkg error. Cannot continue.")
print_error(red(" *")+" quickpkg error for "+red(dep))
print_error(red(" ***")+" Fatal error, cannot continue")
sys.exit(251)
@@ -572,6 +594,7 @@ def build(atoms):
if (rc is not None):
packagesPaths.append(rc)
else:
enzymeLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_NORMAL,"build: (runtimeDepsQuickpkg) "+str(dep)+" -> quickpkg error. Cannot continue.")
print_error(red(" *")+" quickpkg error for "+red(atom))
print_error(red(" ***")+" Fatal error, cannot continue")
sys.exit(251)
@@ -591,6 +614,8 @@ def world(options):
myopts = options[1:]
enzymeLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"world: called with options -> "+str(options))
# FIXME: are --pretend and --ask useful here?
enzymeRequestDeep = False
enzymeRequestVerbose = False
@@ -624,6 +649,7 @@ def world(options):
enzymeRequestDeep = True
else:
print red(" ***")+" Wrong parameters specified."
enzymeLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_NORMAL,"world: Wrong parameters specified.")
sys.exit(201)
if (enzymeRequestJustRepackageWorld):
@@ -635,17 +661,17 @@ def world(options):
print_info(green(" * ")+red("Starting to build binaries..."))
else:
print_error(red(" * ")+red("No detected packages??? Are you serious?"))
enzymeLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_NORMAL,"world: No detected packages??? Are you serious? Are you sure that you are running a Gentoo based distribution?")
sys.exit(231)
localcount = 0
for pkg in installedPackages:
localcount += 1
print_info(" "+red("(")+green(str(localcount))+yellow("/")+blue(str(pkgsnumber))+red(")")+red(" Compressing... ")+bold(pkg),back = True)
# FIXME: Check if the package is already available in the Store dir before building it again?
rc = quickpkg(pkg,etpConst['packagesstoredir'])
if (rc is None):
print_warning(red(" * ")+yellow(" quickpkg problem for ")+red(pkg))
# FIXME: remove sys.exit then...
enzymeLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_NORMAL,"world: (installedPackages) quickpkg problem for"+str(pkg))
sys.exit(232)
writechar("\n")
print_info(green(" * ")+red("All packages have been generates successfully"))
@@ -661,7 +687,8 @@ def world(options):
if blocklist != []:
# FIXME: this part needs some polishing
print blocklist
print "error there is something that is blocking all this shit"
enzymeLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_NORMAL,"world: error there is something that is blocking all this shit "+str(blocklist))
print_error(red(" * ")+" Error there is something that is blocking all this shit")
sys.exit(233)
if (enzymeRequestSkipfirst):
@@ -682,19 +709,20 @@ def world(options):
build(atoms)
def overlay(options):
#FIXME: add sync-back to the official Portage Tree?
# etpConst['overlaysconffile'] --> layman.cfg
enzymeLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"overlay: called with options -> "+str(options))
# check if the portage tree is configured
if (not os.path.isfile(etpConst['portagetreedir']+"/metadata/timestamp")):
enzymeLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_NORMAL,"overlay: Entropy Portage tree is not yet prepared. Use the 'sync' tool first.")
print_error(red(bold("Entropy Portage tree is not yet prepared. Use the 'sync' tool first.")))
return False
# check if layman is installed
layman = commands.getoutput("which layman")
if (not layman.startswith("/")):
print_error(red(bold("app-portage/layman is not installed. Please install.")))
enzymeLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_NORMAL,"overlay: app-portage/layman is not installed. Please install.")
print_error(red(" * app-portage/layman is not installed. Please install."))
return False
myopts = options[1:]
@@ -725,6 +753,7 @@ def overlay(options):
print_info(green("adding overlay: ")+bold(i))
rc = spawnCommand(layman+" --config="+etpConst['overlaysconffile']+" -f -a "+i, redirect = verbosity)
if (rc != 0):
enzymeLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_NORMAL,"overlay: a problem occoured adding "+i+" overlay.")
print_warning(red(bold("a problem occoured adding "+i+" overlay.")))
elif (myopts[0] == "remove"):
# remove overlay
@@ -733,6 +762,7 @@ def overlay(options):
print_info(green("removing overlay: ")+bold(i))
rc = spawnCommand(layman+" --config="+etpConst['overlaysconffile']+" -d "+i, redirect = verbosity)
if (rc != 0):
enzymeLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_NORMAL,"overlay: a problem occoured removing "+i+" overlay.")
print_warning(red(bold("a problem occoured removing "+i+" overlay.")))
return True
elif (myopts[0] == "sync"):
@@ -743,6 +773,7 @@ def overlay(options):
print_info(green("syncing all the overlays"))
rc = spawnCommand(layman+" --config="+etpConst['overlaysconffile']+" -S ", redirect = verbosity)
if (rc != 0):
enzymeLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_NORMAL,"overlay: a problem occoured syncing all the overlays.")
print_warning(red(bold("a problem occoured syncing all the overlays.")))
else:
print_info(green("sync completed."))
@@ -752,6 +783,7 @@ def overlay(options):
print_info(green("syncing overlay: ")+bold(i),back = True)
rc = spawnCommand(layman+" --config="+etpConst['overlaysconffile']+" -s "+i, redirect = verbosity)
if (rc != 0):
enzymeLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_NORMAL,"overlay: a problem occoured syncing "+i+" overlay.")
print_warning(red(bold("a problem occoured syncing "+i+" overlay.")))
else:
print_info(green("synced overlay: ")+bold(i))
@@ -765,7 +797,7 @@ def overlay(options):
for i in listing:
print_info(green(i)+" overlay is added.")
else:
# error !
enzymeLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_NORMAL,"overlay: wrong synthax.")
print_error(red(bold("wrong synthax.")))
return False
@@ -773,6 +805,8 @@ def overlay(options):
def uninstall(options):
enzymeLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_NORMAL,"uninstall: called with options -> "+str(options))
# Filter extra commands
enzymeRequestVerbose = False
enzymeUninstallRedirect = "&>/dev/null"
@@ -830,6 +864,7 @@ def uninstall(options):
uninstallText = yellow(" * ")+"Doing "
if validAtoms == []:
enzymeLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_NORMAL,"uninstall: no valid package names specified.")
print_error(red(bold("no valid package names specified.")))
sys.exit(232)
@@ -892,6 +927,7 @@ def uninstall(options):
# now run the command
rc = spawnCommand(portageCmd+"'"+atom+"'",enzymeUninstallRedirect)
if (rc):
enzymeLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_NORMAL,"uninstall: Something weird happened while running the action on "+str(atom))
print_warning(yellow(" *** ")+red("Something weird happened while running the action on ")+bold(atom))
if (not enzymeRequestVerbose):
print_warning(yellow(" *** ")+red("Please use --verbose and retry to see what was wrong. Continuing..."))
@@ -904,6 +940,8 @@ def uninstall(options):
def search(atoms):
enzymeLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"search: called with -> "+str(atoms))
# filter any --starting package
_atoms = []
for atom in atoms:
@@ -942,6 +980,8 @@ def search(atoms):
def distcc(options):
enzymeLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"distcc: called with options -> "+str(options))
# Filter
if options == []:
print_error(yellow(" * ")+red("Not enough parameters."))
@@ -950,6 +990,7 @@ def distcc(options):
# Firstly check if distcc is available
distccAvail = os.system("which distcc &> /dev/null")
if (distccAvail):
enzymeLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_NORMAL,"distcc: distcc is not installed. Cannot continue.")
print_error(yellow(" *** ")+red("distcc is not installed. Cannot continue."))
sys.exit(201)
@@ -962,6 +1003,7 @@ def distcc(options):
print_info(yellow(" * ")+red("Starting distccd..."))
rc = os.system(cdbStartDistcc+" &> /dev/null")
if (rc):
enzymeLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_NORMAL,"distcc: A problem occured while starting distcc. Please check.")
print_error(yellow(" *** ")+red(" A problem occured while starting distcc. Please check."))
sys.exit(202)
@@ -978,6 +1020,7 @@ def distcc(options):
print_info(yellow(" * ")+red("Stopping distccd..."))
rc = os.system(cdbStopDistcc+" &> /dev/null")
if (rc):
enzymeLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_NORMAL,"distcc: A problem occured while stopping distcc. Please check.")
print_error(yellow(" *** ")+red(" A problem occured while stopping distcc. Please check."))
sys.exit(203)
# now configure distcc properly in enzyme.conf
@@ -990,6 +1033,7 @@ def distcc(options):
print_warning(yellow(" * ")+red("Attention: distcc is not enabled."))
myhosts = options[1:]
if len(myhosts) == 0:
enzymeLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_NORMAL,"distcc: (--add-host) No hosts specified.")
print_error(yellow(" * ")+red("No hosts specified."))
sys.exit(204)
print_info(green(" * ")+red("Adding specified hosts..."), back = True)
@@ -999,9 +1043,11 @@ def distcc(options):
elif (options[0] == "--remove-host"):
if (not getDistCCStatus()):
enzymeLog.log(ETP_LOGPRI_WARNING,ETP_LOGLEVEL_NORMAL,"distcc: Attention: distcc is not enabled.")
print_warning(yellow(" * ")+red("Attention: distcc is not enabled."))
myhosts = options[1:]
if len(myhosts) == 0:
enzymeLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_NORMAL,"distcc: (--remove-host) No hosts specified.")
print_error(yellow(" * ")+red("No hosts specified."))
sys.exit(204)
print_info(green(" * ")+red("Removing specified hosts..."), back = True)
@@ -1014,7 +1060,8 @@ def distcc(options):
print_warning(yellow(" * ")+red("Attention: distcc is not enabled."))
hosts = getDistCCHosts()
if len(hosts) == 0:
print_warning(yellow(" * ")+red("Attention: no hosts selected."))
enzymeLog.log(ETP_LOGPRI_WARNING,ETP_LOGLEVEL_NORMAL,"distcc: (--show-hosts) Error: no hosts selected.")
print_error(yellow(" * ")+red("Error: no hosts selected."))
sys.exit(205)
print_info(green(" * ")+red("Showing DistCC hosts table:"))
for host in hosts:
@@ -1023,4 +1070,4 @@ def distcc(options):
availability = green("running")
else:
availability = green("not running")
print_info(green(" * ")+yellow("\tHost:\t")+blue(host)+red(" :: ")+availability)
print_info(green(" * ")+yellow("\tHost:\t")+blue(host)+red(" :: ")+availability)
+37 -37
View File
@@ -32,7 +32,7 @@ import os
# Logging initialization
import logTools
mirrorLog = logTools.LogFile(level=etpConst['mirrorsloglevel'],filename = etpConst['mirrorslogfile'], header = "[Mirrors]")
# example: mirrorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"testFuncton: called.")
# example: mirrorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"testFuncton: called.")
class handlerFTP:
@@ -41,7 +41,7 @@ class handlerFTP:
# this must be run before calling the other functions
def __init__(self, ftpuri):
mirrorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"handlerFTP.__init__: called.")
mirrorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"handlerFTP.__init__: called.")
from ftplib import FTP
@@ -89,52 +89,52 @@ class handlerFTP:
# this can be used in case of exceptions
def reconnectHost(self):
mirrorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"handlerFTP.reconnectHost: called.")
mirrorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"handlerFTP.reconnectHost: called.")
self.ftpconn = FTP(self.ftphost)
self.ftpconn.login(self.ftpuser,self.ftppassword)
self.ftpconn.cwd(self.currentdir)
def getFTPHost(self):
mirrorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"handlerFTP.getFTPHost: called -> "+self.ftphost)
mirrorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"handlerFTP.getFTPHost: called -> "+self.ftphost)
return self.ftphost
def getFTPPort(self):
mirrorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"handlerFTP.getFTPPort: called -> "+self.ftpport)
mirrorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"handlerFTP.getFTPPort: called -> "+self.ftpport)
return self.ftpport
def getFTPDir(self):
mirrorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"handlerFTP.getFTPPort: called -> "+self.ftpdir)
mirrorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"handlerFTP.getFTPPort: called -> "+self.ftpdir)
return self.ftpdir
def getCWD(self):
pwd = self.ftpconn.pwd()
mirrorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"handlerFTP.getCWD: called -> "+pwd)
mirrorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"handlerFTP.getCWD: called -> "+pwd)
return pwd
def setCWD(self,dir):
mirrorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"handlerFTP.setCWD: called -> "+dir)
mirrorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"handlerFTP.setCWD: called -> "+dir)
self.ftpconn.cwd(dir)
self.currentdir = dir
def setPASV(self,bool):
mirrorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"handlerFTP.setPASV: called -> "+str(bool))
mirrorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"handlerFTP.setPASV: called -> "+str(bool))
self.ftpconn.set_pasv(bool)
def getFileMtime(self,path):
mirrorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"handlerFTP.getFileMtime: called for -> "+path)
mirrorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"handlerFTP.getFileMtime: called for -> "+path)
rc = self.ftpconn.sendcmd("mdtm "+path)
return rc.split()[len(rc.split())-1]
def spawnFTPCommand(self,cmd):
mirrorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"handlerFTP.spawnFTPCommand: called, command -> "+cmd)
mirrorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"handlerFTP.spawnFTPCommand: called, command -> "+cmd)
rc = self.ftpconn.sendcmd(cmd)
mirrorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"handlerFTP.spawnFTPCommand: called, rc -> "+str(rc))
mirrorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"handlerFTP.spawnFTPCommand: called, rc -> "+str(rc))
return rc
# list files and directory of a FTP
# @returns a list
def listFTPdir(self):
mirrorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"handlerFTP.listFTPdir: called.")
mirrorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"handlerFTP.listFTPdir: called.")
# directory is: self.ftpdir
try:
rc = self.ftpconn.nlst()
@@ -149,7 +149,7 @@ class handlerFTP:
# list if the file is available
# @returns True or False
def isFileAvailable(self,filename):
mirrorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"handlerFTP.isFileAvailable: called for -> "+filename)
mirrorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"handlerFTP.isFileAvailable: called for -> "+filename)
# directory is: self.ftpdir
try:
rc = self.ftpconn.nlst()
@@ -159,31 +159,31 @@ class handlerFTP:
rc = _rc
for i in rc:
if i == filename:
mirrorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"handlerFTP.isFileAvailable: result -> True")
mirrorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"handlerFTP.isFileAvailable: result -> True")
return True
mirrorLog.log(ETP_LOG_INFO,ETP_LOG_WARNING,"handlerFTP.isFileAvailable: result -> False (no exception)")
mirrorLog.log(ETP_LOGPRI_INFO,ETP_LOGPRI_WARNING,"handlerFTP.isFileAvailable: result -> False (no exception)")
return False
except:
mirrorLog.log(ETP_LOG_INFO,ETP_LOG_ERROR,"handlerFTP.isFileAvailable: result -> False (exception occured!!!)")
mirrorLog.log(ETP_LOGPRI_INFO,ETP_LOGPRI_ERROR,"handlerFTP.isFileAvailable: result -> False (exception occured!!!)")
return False
def deleteFile(self,file):
mirrorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"handlerFTP.deleteFile: called for -> "+str(file))
mirrorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"handlerFTP.deleteFile: called for -> "+str(file))
try:
rc = self.ftpconn.delete(file)
if rc.startswith("250"):
mirrorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"handlerFTP.deleteFile: result -> True")
mirrorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"handlerFTP.deleteFile: result -> True")
return True
else:
mirrorLog.log(ETP_LOG_WARNING,ETP_LOG_VERBOSE,"handlerFTP.deleteFile: result -> False (no exception)")
mirrorLog.log(ETP_LOGPRI_WARNING,ETP_LOGLEVEL_VERBOSE,"handlerFTP.deleteFile: result -> False (no exception)")
return False
except:
mirrorLog.log(ETP_LOG_ERROR,ETP_LOG_VERBOSE,"handlerFTP.deleteFile: result -> False (exception occured!!!)")
mirrorLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_VERBOSE,"handlerFTP.deleteFile: result -> False (exception occured!!!)")
return False
# this function also supports callback, because storbinary doesn't
def advancedStorBinary(self, cmd, fp, callback=None, blocksize=8192):
mirrorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"handlerFTP.advancedStorBinary: called with -> "+str(cmd))
mirrorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"handlerFTP.advancedStorBinary: called with -> "+str(cmd))
''' Store a file in binary mode. Our version supports a callback function'''
self.ftpconn.voidcmd('TYPE I')
conn = self.ftpconn.transfercmd(cmd)
@@ -207,11 +207,11 @@ class handlerFTP:
# print !
print_info(currentText,back = True)
mirrorLog.log(ETP_LOG_INFO,ETP_LOG_NORMAL,"handlerFTP.uploadFile: called for -> "+str(file)+" mode, ascii?: "+str(ascii))
mirrorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"handlerFTP.uploadFile: called for -> "+str(file)+" mode, ascii?: "+str(ascii))
for i in range(10): # ten tries
mirrorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"handlerFTP.uploadFile: try #"+str(i))
mirrorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"handlerFTP.uploadFile: try #"+str(i))
f = open(file)
filename = file.split("/")[len(file.split("/"))-1]
@@ -231,13 +231,13 @@ class handlerFTP:
self.renameFile(filename+".tmp",filename)
f.close()
if rc.find("226") != -1: # upload complete
mirrorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"handlerFTP.uploadFile: upload complete.")
mirrorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"handlerFTP.uploadFile: upload complete.")
return True
else:
mirrorLog.log(ETP_LOG_ERROR,ETP_LOG_NORMAL,"handlerFTP.uploadFile: upload failed !!.")
mirrorLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_NORMAL,"handlerFTP.uploadFile: upload failed !!.")
return False
except: # connection reset by peer
mirrorLog.log(ETP_LOG_WARNING,ETP_LOG_NORMAL,"handlerFTP.uploadFile: upload issues, retrying...")
mirrorLog.log(ETP_LOGPRI_WARNING,ETP_LOGLEVEL_NORMAL,"handlerFTP.uploadFile: upload issues, retrying...")
print_info(red("Upload issue, retrying..."))
self.reconnectHost() # reconnect
if self.isFileAvailable(filename):
@@ -259,7 +259,7 @@ class handlerFTP:
# print !
print_info(currentText,back = True)
mirrorLog.log(ETP_LOG_INFO,ETP_LOG_NORMAL,"handlerFTP.downloadFile: called for -> "+str(filepath)+" | download directory: "+str(downloaddir)+" | ascii? "+str(ascii))
mirrorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_NORMAL,"handlerFTP.downloadFile: called for -> "+str(filepath)+" | download directory: "+str(downloaddir)+" | ascii? "+str(ascii))
file = filepath.split("/")[len(filepath.split("/"))-1]
# look if the file exist
@@ -282,28 +282,28 @@ class handlerFTP:
f.flush()
f.close()
if rc.find("226") != -1: # upload complete
mirrorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"handlerFTP.downloadFile: download success.")
mirrorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"handlerFTP.downloadFile: download success.")
return True
else:
mirrorLog.log(ETP_LOG_ERROR,ETP_LOG_NORMAL,"handlerFTP.downloadFile: download issues !!.")
mirrorLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_NORMAL,"handlerFTP.downloadFile: download issues !!.")
return False
else:
mirrorLog.log(ETP_LOG_ERROR,ETP_LOG_NORMAL,"handlerFTP.downloadFile: file '"+file+"' not available !!.")
mirrorLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_NORMAL,"handlerFTP.downloadFile: file '"+file+"' not available !!.")
return None
# also used to move files
def renameFile(self,fromfile,tofile):
mirrorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"handlerFTP.renameFile: rename file from '"+fromfile+"' to '"+tofile+"'.")
mirrorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"handlerFTP.renameFile: rename file from '"+fromfile+"' to '"+tofile+"'.")
rc = self.ftpconn.rename(fromfile,tofile)
mirrorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"handlerFTP.renameFile: return output: '"+rc+"'")
mirrorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"handlerFTP.renameFile: return output: '"+rc+"'")
# not supported by dreamhost.com
def getFileSize(self,file):
mirrorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"handlerFTP.getFileSize: called for -> "+file)
mirrorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"handlerFTP.getFileSize: called for -> "+file)
return self.ftpconn.size(file)
def getFileSizeCompat(self,file):
mirrorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"handlerFTP.getFileSizeCompat: called for -> "+file)
mirrorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"handlerFTP.getFileSizeCompat: called for -> "+file)
list = self.getRoughList()
for item in list:
if item.find(file) != -1:
@@ -315,11 +315,11 @@ class handlerFTP:
self.FTPbuffer.append(buf)
def getRoughList(self):
mirrorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"handlerFTP.getRoughList: called.")
mirrorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"handlerFTP.getRoughList: called.")
self.FTPbuffer = []
self.ftpconn.dir(self.bufferizer)
return self.FTPbuffer
def closeFTPConnection(self):
mirrorLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"handlerFTP.closeFTPConnection: called.")
mirrorLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"handlerFTP.closeFTPConnection: called.")
self.ftpconn.quit()
+45 -45
View File
@@ -61,7 +61,7 @@ import entropyTools
# Logging initialization
import logTools
portageLog = logTools.LogFile(level=etpConst['spmbackendloglevel'],filename = etpConst['spmbackendlogfile'], header = "[Portage]")
# portageLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"testFunction: example. ")
# portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"testFunction: example. ")
############
# Functions and Classes
@@ -71,41 +71,41 @@ def getThirdPartyMirrors(mirrorname):
return portage.thirdpartymirrors[mirrorname]
def getPortageEnv(var):
portageLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"getPortageEnv: called. ")
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"getPortageEnv: called. ")
try:
rc = portage.config(clone=portage.settings).environ()[var]
portageLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"getPortageEnv: variable available -> "+str(var))
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"getPortageEnv: variable available -> "+str(var))
return rc
except KeyError:
portageLog.log(ETP_LOG_WARNING,ETP_LOG_VERBOSE,"getPortageEnv: variable not available -> "+str(var))
portageLog.log(ETP_LOGPRI_WARNING,ETP_LOGLEVEL_VERBOSE,"getPortageEnv: variable not available -> "+str(var))
return None
# resolve atoms automagically (best, not current!)
# sys-libs/application --> sys-libs/application-1.2.3-r1
def getBestAtom(atom):
portageLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"getBestAtom: called -> "+str(atom))
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"getBestAtom: called -> "+str(atom))
try:
rc = portage.portdb.xmatch("bestmatch-visible",str(atom))
portageLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"getBestAtom: result -> "+str(rc))
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"getBestAtom: result -> "+str(rc))
return rc
except ValueError:
portageLog.log(ETP_LOG_WARNING,ETP_LOG_VERBOSE,"getBestAtom: conflict found. ")
portageLog.log(ETP_LOGPRI_WARNING,ETP_LOGLEVEL_VERBOSE,"getBestAtom: conflict found. ")
return "!!conflicts"
# same as above but includes masked ebuilds
def getBestMaskedAtom(atom):
portageLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"getBestAtom: called. ")
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"getBestAtom: called. ")
atoms = portage.portdb.xmatch("match-all",str(atom))
# find the best
from portage_versions import best
rc = best(atoms)
portageLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"getBestAtom: result -> "+str(rc))
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"getBestAtom: result -> "+str(rc))
return rc
# I need a valid complete atom...
def calculateFullAtomsDependencies(atoms, deep = False, extraopts = ""):
portageLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"calculateFullAtomsDependencies: called -> "+str(atoms)+" | extra options: "+extraopts)
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"calculateFullAtomsDependencies: called -> "+str(atoms)+" | extra options: "+extraopts)
# in order... thanks emerge :-)
deepOpt = ""
@@ -141,17 +141,17 @@ def calculateFullAtomsDependencies(atoms, deep = False, extraopts = ""):
blocklist = _blocklist
if deplist != []:
portageLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"calculateFullAtomsDependencies: deplist -> "+len(deplist)+" | blocklist -> "+len(blocklist))
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"calculateFullAtomsDependencies: deplist -> "+len(deplist)+" | blocklist -> "+len(blocklist))
return deplist, blocklist
else:
portageLog.log(ETP_LOG_ERROR,ETP_LOG_VERBOSE,"calculateFullAtomsDependencies: deplist empty. Giving up.")
portageLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_VERBOSE,"calculateFullAtomsDependencies: deplist empty. Giving up.")
rc = os.system(cmd)
sys.exit(100)
def calculateAtomUSEFlags(atom):
portageLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"calculateAtomUSEFlags: called -> "+str(atom))
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"calculateAtomUSEFlags: called -> "+str(atom))
try:
useflags = "USE='"+os.environ['USE']+"' "
@@ -166,7 +166,7 @@ def calculateAtomUSEFlags(atom):
useparm = useparm.split()
_useparm = []
portageLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"calculateAtomUSEFlags: USE flags -> "+str(useparm))
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"calculateAtomUSEFlags: USE flags -> "+str(useparm))
for use in useparm:
# -cups
@@ -190,12 +190,12 @@ def calculateAtomUSEFlags(atom):
# should be only used when a pkgcat/pkgname <-- is not specified (example: db, amarok, AND NOT media-sound/amarok)
def getAtomCategory(atom):
portageLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"getAtomCategory: called. ")
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"getAtomCategory: called. ")
try:
rc = portage.portdb.xmatch("match-all",str(atom))[0].split("/")[0]
return rc
except:
portageLog.log(ETP_LOG_ERROR,ETP_LOG_VERBOSE,"getAtomCategory: error, can't extract category !")
portageLog.log(ETP_LOGPRI_ERROR,ETP_LOGLEVEL_VERBOSE,"getAtomCategory: error, can't extract category !")
return None
# This function compare the version number of two atoms
@@ -204,7 +204,7 @@ def getAtomCategory(atom):
# if atom1 > atom2 --> returns a POSITIVE number
# if atom1 == atom2 --> returns 0
def compareAtoms(atom1,atom2):
portageLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"compareAtoms: called -> "+atom1+" && "+atom2)
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"compareAtoms: called -> "+atom1+" && "+atom2)
# filter pkgver
x, atom1 = extractPkgNameVer(atom1)
x, atom2 = extractPkgNameVer(atom2)
@@ -213,7 +213,7 @@ def compareAtoms(atom1,atom2):
# please always force =pkgcat/pkgname-ver if possible
def getInstalledAtom(atom):
portageLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"getInstalledAtom: called -> "+str(atom))
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"getInstalledAtom: called -> "+str(atom))
rc = portage.db['/']['vartree'].dep_match(str(atom))
if (rc != []):
if (len(rc) == 1):
@@ -224,20 +224,20 @@ def getInstalledAtom(atom):
return None
def getPackageSlot(atom):
portageLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"getPackageSlot: called. ")
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"getPackageSlot: called. ")
if atom.startswith("="):
atom = atom[1:]
rc = portage.db['/']['vartree'].getslot(atom)
if rc != "":
portageLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"getPackageSlot: slot found -> "+str(atom)+" -> "+str(rc))
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"getPackageSlot: slot found -> "+str(atom)+" -> "+str(rc))
return rc
else:
portageLog.log(ETP_LOG_WARNING,ETP_LOG_VERBOSE,"getPackageSlot: slot not found -> "+str(atom))
portageLog.log(ETP_LOGPRI_WARNING,ETP_LOGLEVEL_VERBOSE,"getPackageSlot: slot not found -> "+str(atom))
return None
# you must provide a complete atom
def collectBinaryFilesForInstalledPackage(atom):
portageLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"collectBinaryFilesForInstalledPackage: called. ")
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"collectBinaryFilesForInstalledPackage: called. ")
if atom.startswith("="):
atom = atom[1:]
pkgcat = atom.split("/")[0]
@@ -258,11 +258,11 @@ def collectBinaryFilesForInstalledPackage(atom):
return binarylibs
def getEbuildDbPath(atom):
portageLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"getEbuildDbPath: called -> "+atom)
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"getEbuildDbPath: called -> "+atom)
return portage.db['/']['vartree'].getebuildpath(atom)
def getEbuildTreePath(atom):
portageLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"getEbuildTreePath: called -> "+atom)
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"getEbuildTreePath: called -> "+atom)
if atom.startswith("="):
atom = atom[1:]
rc = portage.portdb.findname(atom)
@@ -272,7 +272,7 @@ def getEbuildTreePath(atom):
return None
def getPackageDownloadSize(atom):
portageLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"getPackageDownloadSize: called -> "+atom)
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"getPackageDownloadSize: called -> "+atom)
if atom.startswith("="):
atom = atom[1:]
@@ -298,7 +298,7 @@ def getPackageDownloadSize(atom):
return "N/A"
def getInstalledAtoms(atom):
portageLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"getInstalledAtoms: called -> "+atom)
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"getInstalledAtoms: called -> "+atom)
rc = portage.db['/']['vartree'].dep_match(str(atom))
if (rc != []):
return rc
@@ -309,7 +309,7 @@ def getInstalledAtoms(atom):
# YOU MUST PROVIDE A COMPLETE ATOM with a pkgcat !
def unmerge(atom):
portageLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"umerge: called -> "+atom)
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"umerge: called -> "+atom)
if isjustname(atom) or (not isvalidatom(atom)) or (atom.find("/") == -1):
return 1
else:
@@ -323,7 +323,7 @@ def unmerge(atom):
# TO THIS FUNCTION:
# must be provided a valid and complete atom
def extractPkgNameVer(atom):
portageLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"extractPkgNameVer: called -> "+atom)
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"extractPkgNameVer: called -> "+atom)
package = dep_getcpv(atom)
package = atom.split("/")[len(atom.split("/"))-1]
package = package.split("-")
@@ -343,7 +343,7 @@ def extractPkgNameVer(atom):
return pkgname,pkgver
def emerge(atom, options, outfile = None, redirect = "&>", simulate = False):
portageLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"emerge: called -> "+atom+" | options: "+str(options)+" | redirect: "+str(redirect)+" | outfile: "+str(outfile)+" | simulate: "+str(simulate))
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"emerge: called -> "+atom+" | options: "+str(options)+" | redirect: "+str(redirect)+" | outfile: "+str(outfile)+" | simulate: "+str(simulate))
if (simulate):
return 0,"" # simulation enabled
if (outfile is None) and (redirect == "&>"):
@@ -381,7 +381,7 @@ def emerge(atom, options, outfile = None, redirect = "&>", simulate = False):
except:
ldflags = " "
portageLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"emerge: USE: "+useflags+" | CFLAGS: "+cflags+" | MAKEOPTS: "+makeopts+" | LDFLAGS: "+ldflags)
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"emerge: USE: "+useflags+" | CFLAGS: "+cflags+" | MAKEOPTS: "+makeopts+" | LDFLAGS: "+ldflags)
# elog configuration
elogopts = dbPORTAGE_ELOG_OPTS+" "
@@ -405,7 +405,7 @@ def emerge(atom, options, outfile = None, redirect = "&>", simulate = False):
def parseElogFile(atom):
portageLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"parseElogFile: called. ")
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"parseElogFile: called. ")
if atom.startswith("="):
atom = atom[1:]
@@ -445,7 +445,7 @@ def parseElogFile(atom):
def compareLibraryLists(pkgBinaryFiles,newPkgBinaryFiles):
portageLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"compareLibraryLists: called. ")
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"compareLibraryLists: called. ")
brokenBinariesList = []
# check if there has been a API breakage
@@ -488,7 +488,7 @@ def compareLibraryLists(pkgBinaryFiles,newPkgBinaryFiles):
# create a .tbz2 file in the specified path
def quickpkg(atom,dirpath):
portageLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"quickpkg: called -> "+atom+" | dirpath: "+dirpath)
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"quickpkg: called -> "+atom+" | dirpath: "+dirpath)
# getting package info
pkgname = atom.split("/")[1]
@@ -534,7 +534,7 @@ def quickpkg(atom,dirpath):
def unpackTbz2(tbz2File,tmpdir = None):
portageLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"unpackTbz2: called -> "+tbz2File)
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"unpackTbz2: called -> "+tbz2File)
import xpak
if tmpdir is None:
@@ -550,7 +550,7 @@ def unpackTbz2(tbz2File,tmpdir = None):
# NOTE: atom must be a COMPLETE atom, with version!
def isTbz2PackageAvailable(atom, verbose = False):
portageLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"isTbz2PackageAvailable: called -> "+atom)
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"isTbz2PackageAvailable: called -> "+atom)
# check if the package have been already merged
atomName = atom.split("/")[len(atom.split("/"))-1]
@@ -571,12 +571,12 @@ def isTbz2PackageAvailable(atom, verbose = False):
tbz2Available = uploadPath
if (verbose): print_info("found here: "+str(tbz2Available))
portageLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"isTbz2PackageAvailable: result -> "+str(tbz2Available))
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"isTbz2PackageAvailable: result -> "+str(tbz2Available))
return tbz2Available
def checkAtom(atom):
portageLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"checkAtom: called -> "+str(atom))
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"checkAtom: called -> "+str(atom))
bestAtom = getBestAtom(atom)
if bestAtom == "!!conflicts":
bestAtom = ""
@@ -586,7 +586,7 @@ def checkAtom(atom):
def getPackageDependencyList(atom):
portageLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"getPackageDependencyList: called -> "+str(atom))
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"getPackageDependencyList: called -> "+str(atom))
pkgSplittedDeps = []
tmp = portage.portdb.aux_get(atom, ["DEPEND"])[0].split()
for i in tmp:
@@ -603,7 +603,7 @@ def getPackageDependencyList(atom):
# this file is contained in the .tbz2->.xpak file
def getPackageRuntimeDependencies(NEEDED):
portageLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"getPackageRuntimeDependencies: called. ")
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"getPackageRuntimeDependencies: called. ")
if not os.path.isfile(NEEDED):
return [],[],[] # all empty
@@ -653,16 +653,16 @@ def getPackageRuntimeDependencies(NEEDED):
return runtimeNeededPackages, runtimeNeededPackagesXT, neededLibraries
def getUSEFlags():
portageLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"getUSEFlags: called. ")
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"getUSEFlags: called. ")
return getPortageEnv('USE')
# you must provide a complete atom
def getPackageIUSE(atom):
portageLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"getPackageIUSE: called. ")
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"getPackageIUSE: called. ")
return getPackageVar(atom,"IUSE")
def getPackageVar(atom,var):
portageLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"getPackageVar: called -> "+atom+" | var: "+var)
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"getPackageVar: called -> "+atom+" | var: "+var)
if atom.startswith("="):
atom = atom[1:]
# can't check - return error
@@ -671,7 +671,7 @@ def getPackageVar(atom,var):
return portage.portdb.aux_get(atom,[var])[0]
def synthetizeRoughDependencies(roughDependencies, useflags = None):
portageLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"synthetizeRoughDependencies: called. ")
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"synthetizeRoughDependencies: called. ")
if useflags is None:
useflags = getUSEFlags()
# returns dependencies, conflicts
@@ -761,7 +761,7 @@ def getPortageAppDbPath():
# Collect installed packages
def getInstalledPackages():
portageLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"getInstalledPackages: called. ")
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"getInstalledPackages: called. ")
import os
appDbDir = getPortageAppDbPath()
dbDirs = os.listdir(appDbDir)
@@ -777,7 +777,7 @@ def getInstalledPackages():
def packageSearch(keyword):
portageLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"packageSearch: called. ")
portageLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"packageSearch: called. ")
SearchDirs = []
# search in etpConst['portagetreedir']
+9 -9
View File
@@ -37,11 +37,11 @@ from portageTools import unpackTbz2, synthetizeRoughDependencies, getPackageRunt
import logTools
reagentLog = logTools.LogFile(level=etpConst['reagentloglevel'],filename = etpConst['reagentlogfile'], header = "[Reagent]")
# reagentLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"testFunction: example. ")
# reagentLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"testFunction: example. ")
def generator(package, enzymeRequestBump = False, dbconnection = None):
reagentLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"generator: called -> Package: "+str(package)+" | enzymeRequestBump: "+str(enzymeRequestBump)+" | dbconnection: "+str(dbconnection))
reagentLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"generator: called -> Package: "+str(package)+" | enzymeRequestBump: "+str(enzymeRequestBump)+" | dbconnection: "+str(dbconnection))
# check if the package provided is valid
validFile = False
@@ -70,15 +70,15 @@ def generator(package, enzymeRequestBump = False, dbconnection = None):
dbconn.closeDB()
if (updated) and (revision != 0):
reagentLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"generator: entry for "+str(packagename)+" has been updated to revision: "+str(revision))
reagentLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"generator: entry for "+str(packagename)+" has been updated to revision: "+str(revision))
print_info(green(" * ")+red("Package ")+bold(packagename)+red(" entry has been updated. Revision: ")+bold(str(revision)))
return True, newFileName
elif (updated) and (revision == 0):
reagentLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"generator: entry for "+str(packagename)+" newly created.")
reagentLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"generator: entry for "+str(packagename)+" newly created.")
print_info(green(" * ")+red("Package ")+bold(packagename)+red(" entry newly created."))
return True, newFileName
else:
reagentLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"generator: entry for "+str(packagename)+" kept intact, no updates needed.")
reagentLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"generator: entry for "+str(packagename)+" kept intact, no updates needed.")
print_info(green(" * ")+red("Package ")+bold(packagename)+red(" does not need to be updated. Current revision: ")+bold(str(revision)))
return False, newFileName
@@ -86,7 +86,7 @@ def generator(package, enzymeRequestBump = False, dbconnection = None):
# This tool is used by Entropy after enzyme, it simply parses the content of etpConst['packagesstoredir']
def enzyme(options):
reagentLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"enzyme: called -> options: "+str(options))
reagentLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"enzyme: called -> options: "+str(options))
enzymeRequestBump = False
#_atoms = []
@@ -135,7 +135,7 @@ def enzyme(options):
# This function extracts all the info from a .tbz2 file and returns them
def extractPkgData(package):
reagentLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"extractPkgData: called -> package: "+str(package))
reagentLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"extractPkgData: called -> package: "+str(package))
# Clean the variables
for i in etpData:
@@ -447,7 +447,7 @@ def extractPkgData(package):
def smartapps(options):
reagentLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"smartapps: called -> options: "+str(options))
reagentLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"smartapps: called -> options: "+str(options))
if (len(options) == 0):
print_error(yellow(" * ")+red("No valid tool specified."))
@@ -497,7 +497,7 @@ def smartapps(options):
# NOTE: this section is highly portage dependent
def smartgenerator(atom):
reagentLog.log(ETP_LOG_INFO,ETP_LOG_VERBOSE,"smartgenerator: called -> package: "+str(atom))
reagentLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"smartgenerator: called -> package: "+str(atom))
dbconn = databaseTools.etpDatabase(readOnly = True)