*** empty log message ***

svn path=/trunk/boinc/; revision=1737
This commit is contained in:
Karl Chen 2003-07-18 22:41:11 +00:00
parent 1b2113e71a
commit a48da07dfd
1 changed files with 124 additions and 63 deletions

View File

@ -3,16 +3,17 @@
# $Id$ # $Id$
# Creates a new BOINC project. # Creates a new BOINC project.
import sys, os, getopt import sys, os, getopt, re
sys.path.append('../py') sys.path.append('../py')
from version import * from version import *
from boinc import * from boinc import *
argv0 = sys.argv[0] argv0 = sys.argv[0]
HOME = os.path.expanduser('~') HOME = os.path.expanduser('~')
USER = os.environ['USER']
HELP = """ HELP = """
syntax: %(argv0)s [options] project-dir-name 'Project Long Name'] syntax: %(argv0)s [options] project-dir-name 'Project Long Name' app-exe 'App Name'
Creates a new project with given name with everything running on a single Creates a new project with given name with everything running on a single
server. server.
@ -21,6 +22,7 @@ Misc options:
--verbose={0,1,2} default: 1 --verbose={0,1,2} default: 1
-v alias for --verbose=2 -v alias for --verbose=2
--no_query accept all directories without querying --no_query accept all directories without querying
--user_name default: $USER (%(USER)s)
Dir-options: Dir-options:
--base default: $HOME (%(HOME)s) --base default: $HOME (%(HOME)s)
@ -32,17 +34,6 @@ Dir-options:
--html_ops_url default: URL_BASE/PROJECT_ops/ --html_ops_url default: URL_BASE/PROJECT_ops/
--cgi_url default: URL_BASE/PROJECT_cgi/ --cgi_url default: URL_BASE/PROJECT_cgi/
Project-specific directory structure that you probably don't need to change:
--bin_dir default: PROJECT_ROOT/bin
--cgi_bin_dir default: PROJECT_ROOT/cgi-bin
--html_user_dir default: PROJECT_ROOT/html_user
--html_ops_dir default: PROJECT_ROOT/html_ops
--download_dir default: PROJECT_ROOT/download
--upload_dir default: PROJECT_ROOT/upload
--log_dir default: PROJECT_ROOT/log
--pid_dir default: PROJECT_ROOT/pid
E.g. if you run make_project --base $HOME/boinc --url_base http://boink/ yah 'YETI @ Home' E.g. if you run make_project --base $HOME/boinc --url_base http://boink/ yah 'YETI @ Home'
Then upload_dir = $HOME/boinc/projects/yah/upload Then upload_dir = $HOME/boinc/projects/yah/upload
@ -52,8 +43,19 @@ By default, directory options will be queried if they do not exist yet.
""" %locals() """ %locals()
def syntax_error(): # Project-specific directory structure that you probably don't need to change:
raise SystemExit('See "%s --help" for help\n' % sys.argv[0])
# --bin_dir default: PROJECT_ROOT/bin
# --cgi_bin_dir default: PROJECT_ROOT/cgi-bin
# --html_user_dir default: PROJECT_ROOT/html_user
# --html_ops_dir default: PROJECT_ROOT/html_ops
# --download_dir default: PROJECT_ROOT/download
# --upload_dir default: PROJECT_ROOT/upload
# --log_dir default: PROJECT_ROOT/log
# --pid_dir default: PROJECT_ROOT/pid
def syntax_error(str):
raise SystemExit('%s; See "%s --help" for help\n' % (str,sys.argv[0]))
def usage(): def usage():
print HELP print HELP
@ -65,6 +67,7 @@ try:
[ 'help', [ 'help',
'verbose=', 'verbose=',
'no_query', 'no_query',
'user_name=',
'base=', 'base=',
'key_dir=', 'key_dir=',
'project_root=', 'project_root=',
@ -72,74 +75,132 @@ try:
'html_user_url=', 'html_user_url=',
'html_ops_url=', 'html_ops_url=',
'cgi_url=', 'cgi_url=',
'bin_dir=', # 'bin_dir=',
'cgi_bin_dir=', # 'cgi_bin_dir=',
'html_user_dir=', # 'html_user_dir=',
'html_ops_dir=', # 'html_ops_dir=',
'download_dir=', # 'download_dir=',
'upload_dir=', # 'upload_dir=',
'log_dir=', # 'log_dir=',
'pid_dir=' ]) # 'pid_dir='
except getopt.GetoptError: ])
syntax_error() except getopt.GetoptError, e:
syntax_error(e)
options.url_base = None options.url_base = None
options.no_query = False
for o,a in opts: for o,a in opts:
if o == '-h' or o == '--help': usage() if o == '-h' or o == '--help': usage()
elif o == 'v': options.echo_verbose = 2 elif o == '-v': options.echo_verbose = 2
elif o == 'verbose': options.echo_verbose = int(a) elif o == '--verbose': options.echo_verbose = int(a)
elif o == 'no_query': options.no_query = True elif o == '--no_query': options.no_query = True
elif o == 'base': options.base = a elif o == '--user_name': options.user_name = a
elif o == 'key_dir': options.key_dir = a elif o == '--base': options.base = a
elif o == 'project_root': options.project_root = a elif o == '--key_dir': options.key_dir = a
elif o == 'url_base': options.url_base = a elif o == '--project_root': options.project_root = a
elif o == 'html_user_url': options.html_user_url = a elif o == '--url_base': options.url_base = a
elif o == 'html_ops_url': options.html_ops_url = a elif o == '--html_user_url': options.html_user_url = a
elif o == 'cgi_url': options.cgi_url = a elif o == '--html_ops_url': options.html_ops_url = a
elif o == 'bin_dir': options.bin_dir = a elif o == '--cgi_url': options.cgi_url = a
elif o == 'cgi_bin_dir': options.cgi_bin_dir = a # elif o == '--bin_dir': options.bin_dir = a
elif o == 'html_user_dir': options.html_user_dir = a # elif o == '--cgi_bin_dir': options.cgi_bin_dir = a
elif o == 'html_ops_dir': options.html_ops_dir = a # elif o == '--html_user_dir': options.html_user_dir = a
elif o == 'download_dir': options.download_dir = a # elif o == '--html_ops_dir': options.html_ops_dir = a
elif o == 'upload_dir': options.upload_dir = a # elif o == '--download_dir': options.download_dir = a
elif o == 'log_dir': options.log_dir = a # elif o == '--upload_dir': options.upload_dir = a
elif o == 'pid_dir': options.pid_dir = a # elif o == '--log_dir': options.log_dir = a
# elif o == '--pid_dir': options.pid_dir = a
else: else:
raise SystemExit('internal error') raise SystemExit('internal error o=%s'%o)
if len(args) != 2 or not options.url_base: if len(args) != 4:
syntax_error() syntax_error('Need four arguments')
(project_shortname, project_longname) = args (project_shortname, project_longname, app_exe, app_name) = args
if not options.url_base:
syntax_error('Need --url_base')
if not options.url_base.startswith('http://'):
syntax_error('url_base needs to be an URL')
options.url_base = os.path.join(options.url_base, '')
opt_repls = {'PROJECT':project_shortname, 'URL_BASE':options.url_base}
def replopt(str):
for key in opt_repls:
str = re.compile('\\b'+key+'\\b').sub(os.path.join(opt_repls[key],'')[:-1], str)
return str
def add_slash(str, action=True):
if action:
return os.path.join(str,'')
else:
return str
def defopt(name, v, isdir=True):
options.__dict__[name] = opt_repls[name.upper()] = add_slash(replopt(options.__dict__.get(name) or v), isdir)
# if BLAH: defopt('user_name', USER, isdir=False)
# print """I created the directories BLAH and BLAH. You need to add this (or similar) to your Apache config.httpd: defopt('base', HOME)
defopt('key_dir', 'BASE/keys')
defopt('project_root', 'BASE/projects/PROJECT')
# Alias /%(project)s %(BOINC_HTML_USER_DIR)s defopt('html_user_url', 'URL_BASE/PROJECT')
# ScriptAlias /%(project)s_cgi %(BOINC_CGI_BIN_DIR)s defopt('html_ops_url', 'URL_BASE/PROJECT_ops')
defopt('cgi_url', 'URL_BASE/PROJECT_cgi')
print "Creating project '%s' (short name '%s'):" %(project_longname, project_shortname)
for k in ['base',
'key_dir',
'project_root',
'url_base',
'html_user_url',
'html_ops_url',
'cgi_url' ]:
print k.upper().rjust(15), "=", options.__dict__[k]
project_root_parent = os.path.realpath(os.path.join(options.project_root,'..'))
if not os.path.exists(project_root_parent):
os.makedirs(project_root_parent)
# # Note: projects/*/keys/ should NOT be readable! if not options.no_query:
if not query_yesno("Continue?"):
raise SystemExit('Aborted')
# <Directory "/disks/koloth/a/inet_services/boinc_www/share/projects/*/html_user"> Options Indexes FollowSymlinks MultiViews app = App(app_name)
# AllowOverride None app_version = AppVersion(app, exec_names=[app_exe])
# Order allow,deny
# Allow from all
# </Directory>
# <Directory "/disks/koloth/a/inet_services/boinc_www/share/projects/*/html_ops"> options.install_method = 'copy'
# Options FollowSymLinks init()
# AllowOverride AuthConfig project = Project(project_shortname, project_longname,
# Order allow,deny project_dir = options.project_root,
# Allow from all master_url = options.url_base,
# </Directory> cgi_url = options.cgi_url,
apps=[app], app_versions=[app_version],
)
project.install_project()
print '''You need to manually edit your Apache config.httpd to add these lines:
Alias /%(project)s %(options.project_root)s/html_user
Alias /%(project)s_ops %(options.project_root)s/html_ops
ScriptAlias /%(project)s_cgi %(options.project_root)s/cgi-bin
# Note: projects/*/keys/ should NOT be readable!
<Directory "/disks/koloth/a/inet_services/boinc_www/share/projects/*/html_user"> Options Indexes FollowSymlinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<Directory "/disks/koloth/a/inet_services/boinc_www/share/projects/*/html_ops">
Options FollowSymLinks
AllowOverride AuthConfig
Order allow,deny
Allow from all
</Directory>
'''%locals()
## TODO: first time: by default query all options with raw_input() ; use --no-query to use only environ vars ## TODO: first time: by default query all options with raw_input() ; use --no-query to use only environ vars