From 7844d35dfbe671f697b697c6e6c19452fa6e4f94 Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@cd1c1023-2f26-0410-ae45-c471fc1f0318> Date: Thu, 17 Jan 2008 19:06:32 +0000 Subject: [PATCH] fix text_query calls with reagent database search git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@1062 cd1c1023-2f26-0410-ae45-c471fc1f0318 --- libraries/reagentTools.py | 105 ++++++++++++++++++++------------------ server/reagent | 12 ++--- 2 files changed, 61 insertions(+), 56 deletions(-) diff --git a/libraries/reagentTools.py b/libraries/reagentTools.py index 6942bdfd4..89030e0b6 100644 --- a/libraries/reagentTools.py +++ b/libraries/reagentTools.py @@ -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"): diff --git a/server/reagent b/server/reagent index 040320938..325062454 100644 --- a/server/reagent +++ b/server/reagent @@ -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=")+"\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=")+"\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