From 4dced6f7680b128e623a8820ea8d2d44565c52dd Mon Sep 17 00:00:00 2001 From: Karl Chen Date: Thu, 4 Sep 2003 08:09:11 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=2259 --- doc/python.php | 2 +- py/Boinc/database.py | 14 ++++++++------ tools/add.py | 37 ++++++++++++++++++++++++------------- 3 files changed, 33 insertions(+), 20 deletions(-) diff --git a/doc/python.php b/doc/python.php index 516ea6b64e..aeaa5f2594 100644 --- a/doc/python.php +++ b/doc/python.php @@ -150,7 +150,7 @@ usage such as custom SQL queries (anything is possible :) see the pydoc.
   all_apps = database.Apps.find()
   finished_yeti_wus = database.Workunits.find(
-      app = database.Apps.find(name='YETI@home')[0]
+      app = database.Apps.find(name='YETI@home')[0],
       assimilate_state = ASSIMILATE_DONE)
 
diff --git a/py/Boinc/database.py b/py/Boinc/database.py index 3166d23093..33dcb1be54 100644 --- a/py/Boinc/database.py +++ b/py/Boinc/database.py @@ -304,14 +304,16 @@ class DatabaseObject: if key == 'id': # self.id = value continue - if not key in columns: + if key or key+'id' in columns: + if key.endswith('id'): + xkey = key[:-2] + self.__dict__[xkey] = self.id_lookups[xkey]._table[value] + else: + self.__dict__[key] = value + else: + # print '### columns=%s'%columns raise ValueError("database '%s' object doesn't take argument '%s'"%( self._table.table, key)) - elif key.endswith('id'): - xkey = key[:-2] - self.__dict__[xkey] = self.id_lookups[xkey]._table[value] - else: - self.__dict__[key] = value def do_init(self, kwargs): try: diff --git a/tools/add.py b/tools/add.py index d24ef9b2cc..2c92edd1d8 100755 --- a/tools/add.py +++ b/tools/add.py @@ -33,10 +33,9 @@ add.py workunit (TODO) add.py result (TODO) ''' import boinc_path_config -from Boinc import database, db_mid, util -import sys, os, getopt, md5, time - -database.connect_default_config() +from Boinc import database, db_mid, configxml +from Boinc.util import * +import sys, os, getopt, md5, time, pprint, shutil CREATE_TIME = ['?create_time', int(time.time())] @@ -68,12 +67,12 @@ class XAppVersion(database.AppVersion): xml_doc += ('\n'+ ' %s\n'+ ' %d\n') %( - self.name, self.version_num) + kwargs['app'].name, int(kwargs['version_num'])) first = True for exec_file in exec_files: xml_doc += (' \n'+ - ' %s\n') %( + ' %s\n') %( os.path.basename(exec_file)) if first: xml_doc += ' \n' @@ -112,7 +111,7 @@ def translate_arg(object, arg, value, args_dict): '''Translate various arguments''' database_table = None try: - database_table = database.__dict__[arg.capitalize]._table + database_table = database.__dict__[arg.capitalize()]._table except: pass if database_table: @@ -148,9 +147,12 @@ def translate_database_arg(database_table, arg, value): except: results = database_table.find(name=value) if len(results) == 0: - raise SystemExit('No %s %s found' %(arg,value)) + raise SystemExit('No %s "%s" found' %(arg,value)) if len(results) > 1: - raise SystemExit('Too many %s match "%s"'%(arg,value)) + print >>sys.stderr, 'Too many %ss match "%s": '%(arg,value) + for result in results: + print >>sys.stderr, ' ', result.name + raise SystemExit return results[0] def ambiguous_lookup(string, dict): @@ -248,16 +250,21 @@ def add_object(object, args): if not arg in args_dict: help_object(object, 'required argument --%s not given'%arg) - print "## args_dict=",args_dict - object = apply(object.DatabaseObject, [], args_dict) object.commit() - print "Committed", object + print "Committed", object, "with args:" + pprint.pprint(object.__dict__) def sign_executable(executable_path): '''Returns signed text for executable''' print 'Signing', executable_path - return os.popen('sign_executable %s %s'%(executable_path,config.config.code_sign_key)).read() + code_sign_key = os.path.join(config.config.key_dir, 'code_sign_private') + sign_executable_path = os.path.join(boinc_path_config.TOP_BUILD_DIR, + 'tools','sign_executable') + if not os.path.exists(sign_executable_path): + raise SystemExit("tools/sign_executable not found! did you `make' it?") + return os.popen('%s %s %s'%(sign_executable_path, + executable_path,code_sign_key)).read() class Dict: pass @@ -325,4 +332,8 @@ if len(possible_objects) > 1: args = sys.argv[2:] parse_global_options(args) + +config = configxml.default_config() +database.connect(config.config) + add_object(possible_objects[0], args)