*** empty log message ***

svn path=/trunk/boinc/; revision=2259
This commit is contained in:
Karl Chen 2003-09-04 08:09:11 +00:00
parent 9596e8e9ff
commit 4dced6f768
3 changed files with 33 additions and 20 deletions

View File

@ -150,7 +150,7 @@ usage such as custom SQL queries (anything is possible :) see the pydoc.
<pre>
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)
</pre>

View File

@ -304,14 +304,16 @@ class DatabaseObject:
if key == 'id':
# self.id = value
continue
if not key in columns:
raise ValueError("database '%s' object doesn't take argument '%s'"%(
self._table.table, key))
elif key.endswith('id'):
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))
def do_init(self, kwargs):
try:

View File

@ -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,7 +67,7 @@ class XAppVersion(database.AppVersion):
xml_doc += ('<app_version>\n'+
' <app_name>%s</app_name>\n'+
' <version_num>%d</version_num>\n') %(
self.name, self.version_num)
kwargs['app'].name, int(kwargs['version_num']))
first = True
for exec_file in exec_files:
@ -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)