fix text_query calls with reagent database search

git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@1062 cd1c1023-2f26-0410-ae45-c471fc1f0318
This commit is contained in:
(no author)
2008-01-17 19:06:32 +00:00
parent 12847f8c29
commit 7844d35dfb
2 changed files with 61 additions and 56 deletions

View File

@@ -114,7 +114,7 @@ def update(options):
# differential checking
# collect differences between the packages in the database and the ones on the system
reagentRequestSeekStore = False
reagentRequestRepackage = False
reagentRequestAsk = True
@@ -512,59 +512,64 @@ def database(options):
# used by reagent
elif (options[0] == "search"):
mykeywords = options[1:]
if (len(mykeywords) == 0):
print_error(brown(" * ")+red("Not enough parameters"))
return 2
if (not os.path.isfile(etpConst['etpdatabasefilepath'])):
print_error(brown(" * ")+red("Entropy Datbase does not exist"))
return 3
# search tool
print_info(green(" * ")+red("Searching ..."))
# open read only
dbconn = Entropy.databaseTools.openServerDatabase(readOnly = True, noUpload = True)
from text_query import printPackageInfo
foundCounter = 0
for mykeyword in mykeywords:
results = dbconn.searchPackages(mykeyword)
for result in results:
foundCounter += 1
print
printPackageInfo(result[1],dbconn, clientSearch = True, extended = True)
dbconn.closeDB()
if (foundCounter == 0):
print_warning(red(" * ")+red("Nothing found."))
else:
print
# so text_query works fine
global Equo
Equo = Entropy
mykeywords = options[1:]
if (len(mykeywords) == 0):
print_error(brown(" * ")+red("Not enough parameters"))
return 2
if (not os.path.isfile(etpConst['etpdatabasefilepath'])):
print_error(brown(" * ")+red("Entropy Datbase does not exist"))
return 3
# search tool
print_info(green(" * ")+red("Searching ..."))
# open read only
dbconn = Entropy.databaseTools.openServerDatabase(readOnly = True, noUpload = True)
from text_query import printPackageInfo
foundCounter = 0
for mykeyword in mykeywords:
results = dbconn.searchPackages(mykeyword)
for result in results:
foundCounter += 1
print
printPackageInfo(result[1],dbconn, clientSearch = True, extended = True)
dbconn.closeDB()
if (foundCounter == 0):
print_warning(red(" * ")+red("Nothing found."))
else:
print
return 0
elif (options[0] == "create-empty-database"):
mypath = options[1:]
if len(mypath) == 0:
print_error(brown(" * ")+red("Not enough parameters"))
return 4
if (os.path.dirname(mypath[0]) != '') and (not os.path.isdir(os.path.dirname(mypath[0]))):
print_error(green(" * ")+red("Supplied directory does not exist."))
return 5
print_info(green(" * ")+red("Initializing an empty database file with Entropy structure ..."),back = True)
connection = Entropy.databaseTools.dbapi2.connect(mypath[0])
cursor = connection.cursor()
for sql in etpSQLInitDestroyAll.split(";"):
if sql:
cursor.execute(sql+";")
del sql
for sql in etpSQLInit.split(";"):
if sql:
cursor.execute(sql+";")
connection.commit()
cursor.close()
connection.close()
print_info(green(" * ")+red("Entropy database file ")+bold(mypath[0])+red(" successfully initialized."))
if len(mypath) == 0:
print_error(brown(" * ")+red("Not enough parameters"))
return 4
if (os.path.dirname(mypath[0]) != '') and (not os.path.isdir(os.path.dirname(mypath[0]))):
print_error(green(" * ")+red("Supplied directory does not exist."))
return 5
print_info(green(" * ")+red("Initializing an empty database file with Entropy structure ..."),back = True)
connection = Entropy.databaseTools.dbapi2.connect(mypath[0])
cursor = connection.cursor()
for sql in etpSQLInitDestroyAll.split(";"):
if sql:
cursor.execute(sql+";")
del sql
for sql in etpSQLInit.split(";"):
if sql:
cursor.execute(sql+";")
connection.commit()
cursor.close()
connection.close()
print_info(green(" * ")+red("Entropy database file ")+bold(mypath[0])+red(" successfully initialized."))
return 0
elif (options[0] == "switchbranch"):

View File

@@ -42,16 +42,16 @@ def print_help():
print_info(" --version\t\tprint version")
print_info(" --nocolor\t\tdisable colorized output")
print_info(blue("Tools available: "))
print_info(" \t"+green("update")+brown("\t\t Update Entropy Database analyzing the system for new installed packages"))
print_info(" \t\t"+red("--branch=<branch name>")+"\t\t Choose which branch assign to the packages")
print_info(" \t\t"+red("--seekstore")+"\t\t\t Skip differential COUNTERS scanning and analyze STORE directory")
print_info(" \t\t"+red("--repackage")+"\t\t\t Repackage specified atoms")
print_info(" \t\t"+red("--noask")+"\t\t\t\t Automatically handle things without questioning")
print_info(" \t"+green("inject")+brown("\t\t Inject .tbz2s into database without removing others in the scope (multipackage)"))
print_info(" \t\t"+red("--branch=<branch name>")+"\t\t Choose which branch assign to the packages")
print_info(" \t"+green("database")+brown("\t Entropy database tool manager"))
print_info(" \t\t"+red("--initialize")+"\t\t\t (Re)Initialize the Entropy packages database [DO NOT USE THIS]")
print_info(" \t\t"+green("search")+"\t\t\t\t Search a package inside the Entropy packages database")
@@ -73,7 +73,7 @@ def print_help():
print_info(" \t\t"+green("switchbranch")+"\t\t\t Switch to the specified branch, a package, a list of packages, world")
print_info(" \t\t"+green("md5check")+"\t\t\t Check digest of a package, a list of packages, world")
print_info(" \t\t"+green("md5remote")+"\t\t\t Compare digest of a package between database and mirrors")
print_info(" \t"+green("deptest")+brown("\t\t Look for unsatisfied dependencies inside database"))
print_info(" \t"+green("depends")+brown("\t\t Regenerate depends table (plus database lock and bump)"))
print_info(" \t\t"+red("--quiet")+"\t\t\t\t just print the dependencies list")
@@ -104,9 +104,9 @@ import databaseTools
_options = []
for opt in options:
if (opt == "--nocolor"):
nocolor()
nocolor()
elif (opt == "--debug"):
entropyTools.enableDebug()
entropyTools.enableDebug()
else:
if (opt == "--quiet"):
etpUi['quiet'] = True