2003-08-23 01:26:06 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2005-10-12 18:40:53 +00:00
|
|
|
print "add is deprecated. Use xadd instead.\n"
|
|
|
|
raise SystemExit
|
|
|
|
|
2003-09-03 07:47:59 +00:00
|
|
|
# $Id$
|
|
|
|
|
2003-10-03 05:53:28 +00:00
|
|
|
|
|
|
|
#XXX TODO: add app should modify config.xml to add application-specific daemons
|
|
|
|
|
2003-09-03 08:02:12 +00:00
|
|
|
'''
|
2004-01-13 06:51:19 +00:00
|
|
|
add items to the BOINC database -- command-line interface. See also ``xadd``.
|
2003-09-03 08:02:12 +00:00
|
|
|
|
|
|
|
Usages:
|
|
|
|
|
2003-09-05 22:12:35 +00:00
|
|
|
add project --name=yah --long_name="YETI @ home"
|
2003-09-03 08:02:12 +00:00
|
|
|
|
2003-09-05 22:12:35 +00:00
|
|
|
add platform --name=c64 [ --user_friendly_name="Commodore 64" ]
|
2003-09-03 08:02:12 +00:00
|
|
|
|
2003-09-05 22:12:35 +00:00
|
|
|
add core_version --platform=c64 --version_num=717
|
2003-09-03 08:02:12 +00:00
|
|
|
--exec_file=/path/to/boinc_7.17_c64
|
|
|
|
[--message="Message"] [--message_priority="Priority"]
|
|
|
|
|
2003-09-05 22:12:35 +00:00
|
|
|
add app --name=YetiApp [--min_version=716]
|
2003-09-03 08:02:12 +00:00
|
|
|
|
2003-09-05 22:12:35 +00:00
|
|
|
add app_version --app=YetiApp --platform=c64 --version_num=717
|
2003-09-03 08:02:12 +00:00
|
|
|
--exec_file=/path/to/yeti_7.17_c64
|
|
|
|
[--signature_file=/path/to/sig_file]
|
|
|
|
[--exec_file=/path/to/more_bins
|
|
|
|
[--signature_file=/tmp/sig_file2]] ...
|
|
|
|
|
2003-09-05 22:12:35 +00:00
|
|
|
add user --name="Carl Sagan" --email_addr="carl.sagan@example.com"
|
2003-09-03 08:02:12 +00:00
|
|
|
--authenticator="deadbeef"
|
|
|
|
[--country=Estonia --postal_code=94703
|
|
|
|
--global_prefs_file=/path/to/prefs.xml]
|
|
|
|
|
2003-10-27 06:30:14 +00:00
|
|
|
add work --name="/path/ap_20031026.23987.28452.wu"
|
|
|
|
--wu_template=/path/wu_template.xml
|
|
|
|
--result_template=/path/result_template.xml
|
|
|
|
[--rsc_fpops_est=3000000] [--rsc_fpops_bound=5000000]
|
|
|
|
[--rsc_memory_bound=20000000] [--rsc_disk_bound=10000000]
|
|
|
|
[--delay_bound=14days | --delay_bound=1209600]
|
|
|
|
[--min_quorum=3]
|
|
|
|
[--target_nresults=10]
|
|
|
|
[--max_error_results=5]
|
|
|
|
[--max_total_results=20]
|
|
|
|
[--max_success_results=10]
|
|
|
|
[--sequence 4] (unimplemented)
|
|
|
|
infile1 [infile2] ...
|
|
|
|
|
2003-09-05 22:12:35 +00:00
|
|
|
add workunit (TODO)
|
2003-09-03 08:02:12 +00:00
|
|
|
|
2003-09-05 22:12:35 +00:00
|
|
|
add result (TODO) '''
|
2003-08-23 01:26:06 +00:00
|
|
|
|
2003-09-04 05:07:17 +00:00
|
|
|
import boinc_path_config
|
2004-01-13 06:51:19 +00:00
|
|
|
from Boinc import database, db_mid, configxml
|
2003-09-04 08:09:11 +00:00
|
|
|
from Boinc.util import *
|
2004-01-13 06:51:19 +00:00
|
|
|
from Boinc.add_util import *
|
|
|
|
import sys, os, getopt
|
2003-08-26 21:52:43 +00:00
|
|
|
|
2003-08-23 01:26:06 +00:00
|
|
|
def ambiguous_lookup(string, dict):
|
|
|
|
results = []
|
|
|
|
string = string.replace('_','')
|
|
|
|
for key in dict:
|
|
|
|
k = key.replace('_','')
|
|
|
|
if k == string:
|
2003-09-03 08:17:11 +00:00
|
|
|
return [dict[key]]
|
2003-08-23 01:26:06 +00:00
|
|
|
if k.startswith(string):
|
|
|
|
results.append(dict[key])
|
|
|
|
return results
|
|
|
|
|
2004-01-13 06:51:19 +00:00
|
|
|
def lookup_object_to_add(name_of_object_to_add):
|
|
|
|
name_of_object_to_add = name_of_object_to_add.strip().lower()
|
|
|
|
possible_objects = ambiguous_lookup(name_of_object_to_add, add_objects)
|
|
|
|
if len(possible_objects) == 0:
|
|
|
|
raise SystemExit("No such object '%s' to add"%name_of_object_to_add)
|
|
|
|
if len(possible_objects) > 1:
|
|
|
|
print >>sys.stderr, "Object name '%s' matches multiple objects:"%name_of_object_to_add
|
|
|
|
for object in possible_objects:
|
|
|
|
print " ", object.name
|
|
|
|
raise SystemExit(1)
|
|
|
|
return possible_objects[0]
|
2003-09-03 09:07:16 +00:00
|
|
|
|
2003-08-23 01:26:06 +00:00
|
|
|
def parse_global_options(args):
|
|
|
|
# raise SystemExit('todo')
|
|
|
|
pass
|
|
|
|
|
2003-08-26 19:45:57 +00:00
|
|
|
def dv(object,arg):
|
2003-09-03 08:17:11 +00:00
|
|
|
if arg in object.default_values:
|
|
|
|
return ' --%s [%s]' %(arg, object.default_values[arg])
|
2003-08-26 19:45:57 +00:00
|
|
|
else:
|
|
|
|
return ' --%s' %arg
|
|
|
|
|
|
|
|
def help_object(object, msg=None):
|
|
|
|
if msg:
|
2003-09-03 08:17:11 +00:00
|
|
|
print >>sys.stderr, "add:", msg
|
2003-08-26 19:45:57 +00:00
|
|
|
print
|
2003-09-05 22:12:35 +00:00
|
|
|
print >>sys.stderr, "Syntax: add %s"%object.name
|
2003-08-26 19:45:57 +00:00
|
|
|
for arg in object.args:
|
|
|
|
print >>sys.stderr, dv(object,arg)
|
|
|
|
print >>sys.stderr, " Optional:"
|
|
|
|
for arg in object.optional_args:
|
|
|
|
print >>sys.stderr, dv(object,arg)
|
|
|
|
raise SystemExit
|
|
|
|
|
2004-01-13 06:51:19 +00:00
|
|
|
def commandline_add_object(add_object, args):
|
2003-08-26 19:45:57 +00:00
|
|
|
try:
|
2003-08-26 21:52:43 +00:00
|
|
|
parsed_opts, placement_args = \
|
|
|
|
getopt.getopt(args, '',
|
|
|
|
map(lambda s: s+'=',
|
2004-01-13 06:51:19 +00:00
|
|
|
add_object.args + add_object.optional_args))
|
2003-08-26 21:52:43 +00:00
|
|
|
if placement_args:
|
2003-09-03 08:17:11 +00:00
|
|
|
raise getopt.GetoptError('Unknown args '+' '.join(placement_args))
|
|
|
|
except getopt.GetoptError, e:
|
2004-01-13 06:51:19 +00:00
|
|
|
help_object(add_object, e)
|
|
|
|
untranslated_args_dict = {}
|
2003-08-26 19:45:57 +00:00
|
|
|
for arg,value in parsed_opts:
|
|
|
|
if not arg.startswith('--'):
|
|
|
|
raise Exception('internal error: arg should start with "--"')
|
2004-01-13 06:51:19 +00:00
|
|
|
untranslated_args_dict[arg[2:]] = value
|
|
|
|
try:
|
|
|
|
do_add_object(add_object, untranslated_args_dict)
|
|
|
|
except AddObjectException, e:
|
|
|
|
help_object(add_object, e)
|
2003-08-23 01:26:06 +00:00
|
|
|
|
|
|
|
if len(sys.argv) < 2:
|
2003-09-05 22:12:35 +00:00
|
|
|
print >>sys.stderr, """Syntax: add <object_to_add> <options...>
|
2003-08-23 01:26:06 +00:00
|
|
|
|
|
|
|
Adds an object to the BOINC database.
|
|
|
|
|
|
|
|
Objects to add:"""
|
|
|
|
for object in sorted_keys(objects_to_add):
|
|
|
|
print >>sys.stderr, " ", object
|
|
|
|
print >>sys.stderr, """
|
|
|
|
Global options:
|
2003-09-03 08:17:11 +00:00
|
|
|
--config=config.xml Path to configuration file.
|
2004-01-13 06:51:19 +00:00
|
|
|
--skip_old Ignore database objects that already exist
|
2003-09-03 08:17:11 +00:00
|
|
|
|
|
|
|
These override config.xml:
|
2003-08-23 01:26:06 +00:00
|
|
|
--db_name Database name
|
2003-09-03 08:17:11 +00:00
|
|
|
--db_password Database password
|
|
|
|
--db_user Database user
|
2003-08-23 01:26:06 +00:00
|
|
|
|
|
|
|
For command-line help on a particular object, use add <object> without further
|
|
|
|
arguments.
|
|
|
|
"""
|
|
|
|
|
|
|
|
raise SystemExit(1)
|
|
|
|
|
2004-01-13 06:51:19 +00:00
|
|
|
add_object = lookup_object_to_add(sys.argv[1])
|
2003-08-23 01:26:06 +00:00
|
|
|
|
|
|
|
args = sys.argv[2:]
|
|
|
|
parse_global_options(args)
|
2003-09-04 08:09:11 +00:00
|
|
|
|
|
|
|
config = configxml.default_config()
|
|
|
|
database.connect(config.config)
|
|
|
|
|
2004-01-13 06:51:19 +00:00
|
|
|
commandline_add_object(add_object, args)
|