moooooooooooooooooooooooooooooore speeed uppppppppp

git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@482 cd1c1023-2f26-0410-ae45-c471fc1f0318
This commit is contained in:
(no author)
2007-09-04 16:41:41 +00:00
parent 2f6720b587
commit c1fbf8bd7b
2 changed files with 77 additions and 38 deletions
+28 -11
View File
@@ -1387,22 +1387,29 @@ def fetchFileOnMirrors(repository, filename, digest = False):
uris = etpRepositories[repository]['packages'][::-1]
remaining = set(uris[:])
mirrorcount = 0
for uri in uris:
if len(remaining) == 0:
# tried all the mirrors, quitting for error
return -3
mirrorcount += 1
mirrorCountText = "( mirror #"+str(mirrorcount)+" ) "
# now fetch the new one
url = uri+"/"+filename
print_info(red(" ## ")+blue("Downloading from: ")+red(url))
print_info(red(" ## ")+mirrorCountText+blue("Downloading from: ")+red(url))
rc = fetchFile(url, digest)
if rc == 0:
print_info(red(" ## ")+blue("Successfully downloaded from: ")+red(url))
print_info(red(" ## ")+mirrorCountText+blue("Successfully downloaded from: ")+red(url))
return 0
else:
# something bad happened
print_info(red(" ## ")+blue("Error downloading from: ")+red(url)+" ["+str(rc)+"] | looking for another mirror...")
if rc == -1:
print_info(red(" ## ")+mirrorCountText+blue("Error downloading from: ")+red(url)+" - file not available on this mirror.")
elif rc == -2:
print_info(red(" ## ")+mirrorCountText+blue("Error downloading from: ")+red(url)+" - wrong checksum.")
else:
print_info(red(" ## ")+mirrorCountText+blue("Error downloading from: ")+red(url)+" - unknown reason.")
remaining.remove(uri)
'''
@@ -1713,10 +1720,24 @@ def installPackageIntoDatabase(idpackage, repository, clientDbconn = None):
clientDbconn.closeDB()
print "DEBUG!!! Package "+str(idpk)+" has not been inserted, status: "+str(status)
exitstatus = 1 # it hasn't been insterted ? why??
else:
else: # all fine
# add idpk to the installedtable
clientDbconn.removePackageFromInstalledTable(idpk)
clientDbconn.addPackageToInstalledTable(idpk,repository)
# update dependstable
try:
depends = clientDbconn.listIdpackageDependencies(idpk)
for depend in depends:
atom = depend[1]
iddep = depend[0]
match = atomMatchInRepository(atom,clientDbconn)
if (match[0] != -1):
clientDbconn.removeDependencyFromDependsTable(iddep)
clientDbconn.addDependRelationToDependsTable(iddep,match[0])
except:
print "DEBUG!!! dependstable not found"
regenerateDependsTable(clientDbconn)
if (closedb):
clientDbconn.closeDB()
@@ -1737,10 +1758,6 @@ def removePackageFromDatabase(idpackage, clientDbconn = None):
clientDbconn = openClientDatabase()
clientDbconn.removePackage(idpackage)
# also remove from dependstable
x = clientDbconn.removePackageFromDependsTable(idpackage)
if (x == 1): #`shit, needs regeneration
regenerateDependsTable(clientDbconn, output = False)
if (closedb):
clientDbconn.closeDB()
@@ -2828,8 +2845,8 @@ def installPackages(packages, ask = False, pretend = False, verbose = False, dep
return -1,rc
# regenerate depends table
print_info(red(" @@ ")+blue("Regenerating depends caching table..."), back = True)
regenerateDependsTable(clientDbconn, output = False)
#print_info(red(" @@ ")+blue("Regenerating depends caching table..."), back = True)
#regenerateDependsTable(clientDbconn, output = False)
print_info(red(" @@ ")+blue("Install Complete."))
clientDbconn.closeDB()
+49 -27
View File
@@ -761,12 +761,6 @@ class etpDatabase:
self.connection.close()
return
# Cleanups if at least one package has been removed
if (self.packagesRemoved):
self.cleanupUseflags()
self.cleanupSources()
self.cleanupDependencies()
# if it's equo that's calling the function, just save changes and quit
if (self.clientDatabase):
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"closeDB: closing database opened by Entropy Client.")
@@ -774,7 +768,14 @@ class etpDatabase:
self.cursor.close()
self.connection.close()
return
# Cleanups if at least one package has been removed
# Please NOTE: the client database does not need it
if (self.packagesRemoved):
self.cleanupUseflags()
self.cleanupSources()
self.cleanupDependencies()
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"closeDB: closing database opened in read/write.")
# FIXME verify all this shit, for now it works...
@@ -1261,8 +1262,10 @@ class etpDatabase:
except:
pass
# Remove from installedtable if exist
# Remove from installedtable if exists
self.removePackageFromInstalledTable(idpackage)
# Remove from dependstable if exists
self.removePackageFromDependsTable(idpackage)
# need a final cleanup
self.packagesRemoved = True
@@ -1387,12 +1390,11 @@ class etpDatabase:
def cleanupUseflags(self):
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"cleanupUseflags: called.")
self.cursor.execute('SELECT idflag FROM useflagsreference')
idflags = []
idflags = set([])
for row in self.cursor:
idflags.append(row[0])
idflags.add(row[0])
# now parse them into useflags table
idflags = list(set(idflags))
orphanedFlags = idflags[:]
orphanedFlags = idflags.copy()
for idflag in idflags:
self.cursor.execute('SELECT idflag FROM useflags WHERE idflag = '+str(idflag))
for row in self.cursor:
@@ -1401,18 +1403,17 @@ class etpDatabase:
# now we have orphans that can be removed safely
for idoflag in orphanedFlags:
self.cursor.execute('DELETE FROM useflagsreference WHERE idflag = '+str(idoflag))
for row in self.cursor:
x = row # really necessary ?
for row in self.cursor:
x = row # really necessary ?
def cleanupSources(self):
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"cleanupSources: called.")
self.cursor.execute('SELECT idsource FROM sourcesreference')
idsources = []
idsources = set([])
for row in self.cursor:
idsources.append(row[0])
idsources.add(row[0])
# now parse them into useflags table
idsources = list(set(idsources))
orphanedSources = idsources[:]
orphanedSources = idsources.copy()
for idsource in idsources:
self.cursor.execute('SELECT idsource FROM sources WHERE idsource = '+str(idsource))
for row in self.cursor:
@@ -1421,18 +1422,17 @@ class etpDatabase:
# now we have orphans that can be removed safely
for idosrc in orphanedSources:
self.cursor.execute('DELETE FROM sourcesreference WHERE idsource = '+str(idosrc))
for row in self.cursor:
x = row # really necessary ?
for row in self.cursor:
x = row # really necessary ?
def cleanupDependencies(self):
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"cleanupDependencies: called.")
self.cursor.execute('SELECT iddependency FROM dependenciesreference')
iddeps = []
iddeps = set([])
for row in self.cursor:
iddeps.append(row[0])
iddeps.add(row[0])
# now parse them into useflags table
iddeps = list(set(iddeps))
orphanedDeps = iddeps[:]
orphanedDeps = iddeps.copy()
for iddep in iddeps:
self.cursor.execute('SELECT iddependency FROM dependencies WHERE iddependency = '+str(iddep))
for row in self.cursor:
@@ -1441,8 +1441,8 @@ class etpDatabase:
# now we have orphans that can be removed safely
for idodep in orphanedDeps:
self.cursor.execute('DELETE FROM dependenciesreference WHERE iddependency = '+str(idodep))
for row in self.cursor:
x = row # really necessary ?
for row in self.cursor:
x = row # really necessary ?
# WARNING: this function must be kept in sync with Entropy database schema
# returns True if equal
@@ -2661,6 +2661,19 @@ class etpDatabase:
result.append(row)
return result
def listIdpackageDependencies(self, idpackage):
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"listIdpackageDependencies: called.")
self.cursor.execute('SELECT iddependency FROM dependencies where idpackage = "'+str(idpackage)+'"')
iddeps = []
for row in self.cursor:
iddeps.append(row[0])
result = []
for iddep in iddeps:
self.cursor.execute('SELECT iddependency,dependency FROM dependenciesreference where iddependency = "'+str(iddep)+'"')
for row in self.cursor:
result.append(row)
return result
def listAllPackagesTbz2(self):
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"listAllPackagesTbz2: called.")
result = []
@@ -2793,7 +2806,16 @@ class etpDatabase:
def removePackageFromDependsTable(self, idpackage):
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"removePackageFromDependsTable: called for "+str(idpackage))
try:
self.cursor.execute('DELETE FROM dependstable WHERE idpackage = '+idpackage)
self.cursor.execute('DELETE FROM dependstable WHERE idpackage = '+str(idpackage))
self.commitChanges()
return 0
except:
return 1 # need reinit
def removeDependencyFromDependsTable(self, iddependency):
dbLog.log(ETP_LOGPRI_INFO,ETP_LOGLEVEL_VERBOSE,"removeDependencyFromDependsTable: called for "+str(iddependency))
try:
self.cursor.execute('DELETE FROM dependstable WHERE iddependency = '+str(iddependency))
self.commitChanges()
return 0
except: