completed the Entropy database search function

git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@211 cd1c1023-2f26-0410-ae45-c471fc1f0318
This commit is contained in:
lxnay
2007-03-29 09:08:59 +00:00
parent d8ce309573
commit dfda10a22a
6 changed files with 81 additions and 22 deletions
+4 -4
View File
@@ -43,13 +43,13 @@ def print_help():
entropyTools.print_info(" --version\t\tprint version")
entropyTools.print_info(" --nocolor\t\tdisable colorized output")
entropyTools.print_info(entropyTools.blue("Tools available: "))
entropyTools.print_info(" \t"+entropyTools.green("generator")+entropyTools.yellow("\t to create .etp file from a specified .tbz2 file"))
entropyTools.print_info(" \t\t"+entropyTools.red("--force-bump")+"\t\t force the revision bumping of the .etp files")
entropyTools.print_info(" \t"+entropyTools.green("generator")+entropyTools.yellow("\t to add the package to the database, revision bump if needed"))
entropyTools.print_info(" \t\t"+entropyTools.red("--force-bump")+"\t\t to force the revision bumping of the package entry")
entropyTools.print_info(" \t"+entropyTools.green("digest")+entropyTools.yellow("\t\t to digest a specified directory"))
entropyTools.print_info(" \t"+entropyTools.green("enzyme")+entropyTools.yellow("\t\t to analyze enzyme store directory"))
entropyTools.print_info(" \t\t"+entropyTools.red("--force-bump")+"\t\t force the revision bumping of the .etp files")
entropyTools.print_info(" \t\t"+entropyTools.red("--force-bump")+"\t\t to force the revision bumping of the package entries")
entropyTools.print_info(" \t"+entropyTools.green(entropyTools.bold("database"))+entropyTools.yellow("\t Entropy database tool manager."))
entropyTools.print_info(" \t\t"+entropyTools.red("--initialize")+"\t\t (Re)Initialize the Entropy packages database")
entropyTools.print_info(" \t\t"+entropyTools.red("--initialize")+"\t\t (Re)Initialize the Entropy packages database [DO NOT USE THIS]")
entropyTools.print_info(" \t\t"+entropyTools.green("search")+"\t\t\t Search a package inside the Entropy packages database")
entropyTools.print_info(" \t"+entropyTools.green(entropyTools.bold("cleanup"))+entropyTools.yellow("\t\t to clean temporary files"))
+2 -1
View File
@@ -21,6 +21,7 @@
'''
# Never do "import portage" here, please use entropyTools binding
# EXIT STATUSES: 400-499
from entropyConstants import *
from entropyTools import *
@@ -352,4 +353,4 @@ def database(options):
else:
print_error(green(" * ")+green("No valid tool specified."))
sys.exit(100)
sys.exit(400)
+60 -4
View File
@@ -21,6 +21,7 @@
'''
# Never do "import portage" here, please use entropyTools binding
# EXIT STATUSES: 300-399
from entropyConstants import *
from entropyTools import *
@@ -33,15 +34,15 @@ import sys
def database(options):
if len(options) == 0:
print "not enough options"
sys.exit(1)
print_error(yellow(" * ")+red("Not enough parameters"))
sys.exit(301)
if (options[0] == "--initialize"):
# initialize the database
print_info(green(" * ")+red("Initializing Entropy database..."), back = True)
# database file: etpConst['etpdatabasefile']
if os.path.isfile(etpConst['etpdatabasefile']):
print_info(red(" * ")+bold("WARNING")+red(": database file already exists."))
print_info(red(" * ")+bold("WARNING")+red(": database file already exists. Overwriting."))
rc = askquestion("\n Do you want to continue ?")
if rc == "No":
sys.exit(0)
@@ -54,8 +55,63 @@ def database(options):
print_info(green(" * ")+red("Entropy database initialized."))
elif (options[0] == "search"):
mykeywords = options[1:]
if (len(mykeywords) == 0):
print_error(yellow(" * ")+red("Not enough parameters"))
sys.exit(302)
# search tool
print "search"
print_info(green(" * ")+red("Searching inside the Entropy database..."))
dbconn = etpDatabase()
for mykeyword in mykeywords:
results = dbconn.searchPackages(mykeyword)
for result in results:
print
print_info(green(" * ")+bold(result[0])) # package atom
print_info(red("\t Name: ")+blue(result[1]))
print_info(red("\t Installed version: ")+blue(result[2]))
if (result[3]):
print_info(red("\t Description: ")+result[3])
print_info(red("\t CHOST: ")+blue(result[5]))
print_info(red("\t CFLAGS: ")+darkred(result[6]))
print_info(red("\t CXXFLAGS: ")+darkred(result[7]))
if (result[8]):
print_info(red("\t Website: ")+result[8])
print_info(red("\t USE Flags: ")+blue(result[9]))
print_info(red("\t License: ")+bold(result[10]))
print_info(red("\t Source keywords: ")+darkblue(result[11]))
print_info(red("\t Binary keywords: ")+green(result[12]))
print_info(red("\t Package path: ")+result[13])
print_info(red("\t Download relative URL: ")+result[14])
print_info(red("\t Package Checksum: ")+green(result[15]))
if (result[16]):
print_info(red("\t Sources"))
sources = result[16].split()
for source in sources:
print_info(darkred("\t # Source package: ")+yellow(source))
if (result[17]):
print_info(red("\t Slot: ")+yellow(result[17]))
#print_info(red("\t Blah: ")+result[18]) # I don't need to print mirrorlinks
if (result[19]):
deps = result[19].split()
print_info(red("\t Dependencies"))
for dep in deps:
print_info(darkred("\t # Depends on: ")+dep)
#print_info(red("\t Blah: ")+result[20]) --> it's a dup of [21]
if (result[21]):
rundeps = result[21].split()
print_info(red("\t Built with runtime dependencies"))
for rundep in rundeps:
print_info(darkred("\t # Dependency: ")+rundep)
if (result[22]):
print_info(red("\t Conflicts with"))
conflicts = result[22].split()
for conflict in conflicts:
print_info(darkred("\t # Conflict: ")+conflict)
print_info(red("\t Entry API: ")+green(result[23]))
print_info(red("\t Entry revision: ")+str(result[24]))
#print result
print
dbconn.closeDB()
############
+4 -2
View File
@@ -49,6 +49,8 @@ import sys
import random
import commands
# EXIT STATUSES: 100-199
def getArchFromChost(chost):
# when we'll add new archs, we'll have to add a testcase here
if chost.startswith("x86_64"):
@@ -154,7 +156,7 @@ def calculateFullAtomsDependencies(atoms, deep = False, extraopts = ""):
return deplist, blocklist
else:
rc = os.system(cmd)
sys.exit(1)
sys.exit(100)
def calculateAtomUSEFlags(atom):
try:
@@ -1642,7 +1644,7 @@ def askquestion(prompt):
print "I cannot understand '%s'" % response,
except (EOFError, KeyboardInterrupt):
print "Interrupted."
sys.exit(1)
sys.exit(100)
def print_error(msg):
print red(">>")+" "+msg
+10 -10
View File
@@ -31,7 +31,7 @@ import commands
import string
# Stolen from Porthole 0.5.0 - thanks for your help :-)
# EXIT STATUSES: 200-299
def getSyncTime():
"""gets and returns the timestamp info saved during
@@ -72,7 +72,7 @@ def sync(options):
rsync = commands.getoutput("which rsync")
if (not rsync.startswith("/")):
print_error(red(bold("net-misc/rsync is not installed. Please install.")))
sys.exit(100)
sys.exit(200)
for i in myopts:
if ( i == "--verbose" ) or ( i == "-v" ):
@@ -89,7 +89,7 @@ def sync(options):
rc = spawnCommand(vdbPORTDIR+"="+etpConst['portagetreedir']+" "+cdbEMERGE+" --sync ", redirect = syncMiscRedirect) # redirect = "/dev/null"
if (rc != 0):
print_error(red("an error occoured while syncing the Portage tree. Are you sure that your Internet connection works?"))
sys.exit(101)
sys.exit(201)
if (not enzymeNoOverlaySync):
# syncing overlays
rc = overlay(['overlay','sync'])
@@ -128,7 +128,7 @@ def sync(options):
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):
print_error(red("an error occoured while syncing back the official Portage Tree."))
sys.exit(101)
sys.exit(201)
def build(atoms):
@@ -186,7 +186,7 @@ def build(atoms):
if validAtoms == []:
print_error(red(bold("no valid package names specified.")))
sys.exit(102)
sys.exit(202)
# resolve atom name with the best package available
_validAtoms = []
@@ -251,7 +251,7 @@ def build(atoms):
print_warning(red(" *")+bold(" [CONFL] ")+i)
if (not enzymeRequestIgnoreConflicts):
print_error(red(" ***")+" Sorry, I can't continue. To force this, add --ignore-conflicts at your own risk.")
sys.exit(1)
sys.exit(101)
else:
import time
print_warning((" ***")+" You are using --ignore-conflicts at your own risk.")
@@ -572,7 +572,7 @@ def world(options):
print_info(green(" * ")+red("Starting to build binaries..."))
else:
print_error(red(" * ")+red("No detected packages??? Are you serious?"))
sys.exit(301)
sys.exit(231)
localcount = 0
for pkg in installedPackages:
@@ -583,7 +583,7 @@ def world(options):
if (rc is None):
print_warning(red(" * ")+yellow(" quickpkg problem for ")+red(pkg))
# FIXME: remove sys.exit then...
sys.exit(302)
sys.exit(232)
writechar("\n")
print_info(green(" * ")+red("All packages have been generates successfully"))
return 0
@@ -598,7 +598,7 @@ def world(options):
if blocklist != []:
print blocklist
print "error there is something that is blocking all this shit"
sys.exit(303)
sys.exit(233)
if (enzymeRequestSkipfirst):
deplist = deplist[1:]
@@ -772,7 +772,7 @@ def uninstall(options):
if validAtoms == []:
print_error(red(bold("no valid package names specified.")))
sys.exit(102)
sys.exit(232)
if (not enzymeRequestPrune):
uninstallText += bold("unmerge ")
+1 -1
View File
@@ -202,7 +202,7 @@ def extractPkgData(package):
print_info(yellow(" * ")+red("Getting package location path..."),back = True)
# local path to the file
etpData['packagepath'] = etpConst['packagesbindir']+"/"+pkgname+"-"+pkgver+".tbz2"
etpData['packagepath'] = etpConst['binaryurirelativepath']+"/"+pkgname+"-"+pkgver+".tbz2"
print_info(yellow(" * ")+red("Getting package description..."),back = True)
# Fill description