FSM structure
diff --git a/py/util.py b/py/util.py
index a1e7716876..203e6f5e0a 100644
--- a/py/util.py
+++ b/py/util.py
@@ -4,3 +4,8 @@ def list2dict(list):
dict = {}
for k in list: dict[k] = None
return dict
+
+def sorted_keys(dict):
+ k = dict.keys()
+ k.sort()
+ return k
diff --git a/tools/add b/tools/add
new file mode 100755
index 0000000000..60b3477740
--- /dev/null
+++ b/tools/add
@@ -0,0 +1,497 @@
+#!/usr/bin/env python
+
+# The contents of this file are subject to the BOINC Public License
+# Version 1.0 (the "License"); you may not use this file except in
+# compliance with the License. You may obtain a copy of the License at
+# http://boinc.berkeley.edu/license_1.0.txt
+#
+# Software distributed under the License is distributed on an "AS IS"
+# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+# License for the specific language governing rights and limitations
+# under the License.
+#
+# The Original Code is the Berkeley Open Infrastructure for Network Computing.
+#
+# The Initial Developer of the Original Code is the SETI@home project.
+# Portions created by the SETI@home project are Copyright (C) 2002
+# University of California at Berkeley. All Rights Reserved.
+#
+# Contributor(s):
+#
+
+# add - add items to the DB
+#
+# usages:
+# add project -project_short_name x -project_long_name x
+# add project
+# add app -app_name x
+# add application
+# create DB record
+# add platform -platform_name x -user_friendly_name y
+# create DB record
+# add app_version
+# -app_name x -platform_name y -version a
+# -download_dir d -download_url e
+# -exec_dir b
+# [ -exec_files file1 file2 ... ]
+# [ -signed_exec_files file1 sign1 file2 sign2 ... ]
+# create DB record
+# copy exec to data directory
+# add user -email_addr x -name y -authenticator a
+# [ -global_prefs_file y ]
+
+# int version, retval, nexec_files;
+# double nbytes;
+# bool signed_exec_files;
+# char buf[256], md5_cksum[64];
+# char *db_name=0, *db_passwd=0, *app_name=0, *platform_name=0;
+# char *project_short_name=0, *project_long_name=0;
+# char* user_friendly_name=0;
+# char* exec_dir=0, *exec_files[10], *signature_files[10];
+# char *email_addr=0, *user_name=0, *authenticator=0;
+# char *global_prefs_file=0, *download_dir, *download_url;
+# char* code_sign_keyfile=0;
+# char *message=0, *message_priority=0;
+
+import sys
+sys.path.append('../py/')
+import database, db_mid
+from util import *
+
+list_objects_to_add = [
+ [ database.Project, 'short_name', 'long_name' ],
+ [ database.App, 'name' ],
+ [ database.AppVersion, 'appname' ],
+ [ database.Platform, 'name', 'user_friendly_name' ],
+ [ database.User, 'name', 'email_addr', 'authenticator' ],
+ [ database.Workunit, 'zzzz' ],
+ ]
+
+def ambiguous_lookup(string, dict):
+ results = []
+ string = string.replace('_','')
+ for key in dict:
+ k = key.replace('_','')
+ if k == string:
+ return [k]
+ if k.startswith(string):
+ results.append(dict[key])
+ return results
+
+def parse_global_options(args):
+ # raise SystemExit('todo')
+ pass
+
+def add_object(object, args):
+ raise SystemExit('TODO: add object %s with args %s'%(object,args))
+
+class Dict:
+ pass
+
+objects_to_add = {}
+for o in list_objects_to_add:
+ object = Dict()
+ object.DatabaseObject = o[0]
+ object.name = object.DatabaseObject._table.table
+ object.args = o[1:]
+ objects_to_add[object.name] = object
+
+if len(sys.argv) < 2:
+ print >>sys.stderr, """Syntax: add
+
+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:
+ --db_name Database name
+ --db_password Database password [optional]
+ --db_user Database user [optional]
+
+For command-line help on a particular object, use add