X-Git-Url: http://git.tremily.us/?a=blobdiff_plain;f=pysawsim%2Fsawsim.py;h=0f85869dd634111a0ce0f64d65a9700895f6d8f1;hb=00c8d2959942fc1459069e2cc0c090765a78c55e;hp=ccac6f3308da100724ed7d97e0dd1eb7529f33ea;hpb=7e07146e0f970b782e92d26a5d2424502131f209;p=sawsim.git diff --git a/pysawsim/sawsim.py b/pysawsim/sawsim.py index ccac6f3..0f85869 100644 --- a/pysawsim/sawsim.py +++ b/pysawsim/sawsim.py @@ -27,6 +27,7 @@ try: from collections import namedtuple except ImportError: # work around Python < 2.6 from ._collections import namedtuple +from distutils.spawn import find_executable import hashlib from optparse import Option import os @@ -43,7 +44,10 @@ _multiprocess_can_split_ = True """Allow nosetests to split tests between processes. """ -SAWSIM = 'sawsim' # os.path.expand(os.path.join('~', 'bin', 'sawsim')) +SAWSIM = find_executable('sawsim') +if SAWSIM == None: + SAWSIM = os.path.join('bin', 'sawsim') + CACHE_DIR = os.path.expanduser(os.path.join('~', '.sawsim-cache')) DEFAULT_PARAM_STRING = ( '-s cantilever,hooke,0.05 -N1 ' @@ -61,9 +65,8 @@ Event = namedtuple( class SawsimRunner (object): """ - >>> from .manager.thread import ThreadManager - >>> m = ThreadManager() - >>> sr = SawsimRunner(sawsim='bin/sawsim', manager=m) + >>> m = get_manager()() + >>> sr = SawsimRunner(manager=m) >>> for run in sr(param_string=DEFAULT_PARAM_STRING, N=2): ... print 'New run' ... for i,event in enumerate(run): @@ -104,9 +107,9 @@ class SawsimRunner (object): default=400), Option('-m', '--manager', dest='manager', metavar='STRING', - help='Job manager name (one of %s) (%%default).' + help='Job manager name (one of %s) (default: auto-select).' % (', '.join(MANAGERS)), - default=MANAGERS[0]), + default=None), Option('-C','--use-cache', dest='use_cache', help='Use cached simulations if they exist (vs. running new simulations) (%default)', default=False, action='store_true'), @@ -273,11 +276,11 @@ def main(argv=None): Options: -h, --help show this help message and exit -s PATH, --sawsim=PATH - Set sawsim binary (sawsim). + Set sawsim binary (...sawsim). ... >>> print e 0 - >>> main(['--sawsim', 'bin/sawsim', '-N', '2']) + >>> main(['-N', '2']) ... # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE #Force (N) Initial state Final state ... folded unfolded