Changeset 8749


Ignore:
Timestamp:
18 Jun 2012, 10:14:32 (13 years ago)
Author:
uli
Message:

Reorganize.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.stress/trunk/src/waeup/stress/run.py

    r8674 r8749  
    55from optparse import OptionParser
    66from ConfigParser import SafeConfigParser
     7
     8VALID_MODES = ('paster', 'kofactl', 'zeo', 'profile')
    79
    810def configure_options():
     
    5557        print name, value
    5658        params.update(dict({name: value}))
    57     if params['instance_mode'] not in ('paster', 'kofactl', 'zeo'):
     59    if params['instance_mode'] not in VALID_MODES:
    5860        print "Warning: invalid instance_mode in config.cfg, picking 'paster'."
     61        print "  valid would be: %s" % VALID_MODES
    5962        params['instance_mode'] = 'paster'
    6063    params['start_instance'] = config.getboolean(
     
    6265    return params
    6366
    64 def main():
    65     # late import as this scripts mangles sys.argv
    66     from multimechanize.utilities import run
     67def configure():
    6768    cmd_opts, args = configure_options()
    6869    project_name = args[0]
    6970    path = os.path.abspath(os.path.join(cmd_opts.projects_dir, project_name))
    7071    cfg_opts = configure_project(project_name, path)
     72    return path, project_name, cmd_opts, cfg_opts
     73
     74def main():
     75    path, project_name, cmd_opts, cfg_opts = configure()
    7176    pre_run_path = os.path.join(path, 'pre_run.py')
    7277    post_run_path = os.path.join(path, 'post_run.py')
     78    sys.path.append(path) # make project scripts available for import
    7379    if os.path.exists(pre_run_path):
    7480        print "WAEUP.STRESS.RUN: running pre_run %s" % pre_run_path
    7581        execfile(pre_run_path)
     82    # late import as this scripts mangles sys.argv
     83    from multimechanize.utilities import run
    7684    run.main()
    7785    if os.path.exists(post_run_path):
Note: See TracChangeset for help on using the changeset viewer.