import logging
import logging.handlers
-import sys
+import sys as _sys
+import os as _os
_multiprocess_shared_ = True
__version__ = '0.10' # match sawsim version
+PYSAWSIM_LOG_LEVEL_MSG = """
+You can control the log verbosity with the `PYSAWSIM_LOG_LEVEL`
+environmental variable. Set it to one of the level names in Python's
+`logging` module (e.g. `DEBUG`).
+"""
+
def log():
return logging.getLogger('pysawsim')
-def add_stderr_log_handler(level=logging.DEBUG):
+def add_stderr_log_handler(level=None):
+ if level == None:
+ level_string = _os.environ.get('PYSAWSIM_LOG_LEVEL', 'WARNING')
+ try:
+ level = getattr(logging, level_string)
+ except AttributeError:
+ _sys.stderr.write(
+ 'unrecognized PYSAWSIM_LOG_LEVEL: %s\n' % level_string)
+ raise
_log = log()
_log.setLevel(level)
console = logging.StreamHandler()
console.setFormatter(formatter)
_log.addHandler(console)
-add_stderr_log_handler(logging.WARNING)
+add_stderr_log_handler()
import numpy
+from . import PYSAWSIM_LOG_LEVEL_MSG as _PYSAWSIM_LOG_LEVEL_MSG
from .histogram import Histogram
from .parameter_scan import (
EXAMPLE_HISTOGRAM_FILE_CONTENTS, HistogramMatcher,
'`<bin_edge>` should mark the left-hand side of the bin, and',
'all bins should be of equal width (so we know where the last',
'one ends).',
+ _PYSAWSIM_LOG_LEVEL_MSG,
])
parser = OptionParser(usage, epilog=epilog)
parser.format_epilog = lambda formatter: epilog+'\n'
import pylab
from . import log
+from . import PYSAWSIM_LOG_LEVEL_MSG as _PYSAWSIM_LOG_LEVEL_MSG
from .histogram import Histogram
from .sawsim_histogram import sawsim_histogram
from .sawsim import SawsimRunner
'`<bin_edge>` should mark the left-hand side of the bin, and',
'all bins should be of equal width (so we know where the last',
'one ends).',
+ PYSAWSIM_LOG_LEVEL_MSG,
])
parser = OptionParser(usage, epilog=epilog)
parser.format_epilog = lambda formatter: epilog+'\n'
from uuid import uuid4
from . import __version__
+from . import PYSAWSIM_LOG_LEVEL_MSG as _PYSAWSIM_LOG_LEVEL_MSG
from .manager import MANAGERS, get_manager, InvokeJob
epilog = '\n'.join([
'Python wrapper around `sawsim`. Distribute `N` runs using',
'one of the possible job "managers". Also supports caching',
- 'results to speed future runs.'
+ 'results to speed future runs.',
+ _PYSAWSIM_LOG_LEVEL_MSG,
])
parser = OptionParser(usage, epilog=epilog)
+ parser.format_epilog = lambda formatter: epilog+'\n'
for option in sr.optparse_options:
parser.add_option(option)
import numpy
+from . import PYSAWSIM_LOG_LEVEL_MSG as _PYSAWSIM_LOG_LEVEL_MSG
from .histogram import Histogram
from .manager import MANAGERS, get_manager
from .sawsim import SawsimRunner
epilog = '\n'.join([
'Generate an unfolding force histogram from a series of `sawsim`',
'runs.',
- ])
+ _PYSAWSIM_LOG_LEVEL_MSG,
+ ])
parser = OptionParser(usage, epilog=epilog)
+ parser.format_epilog = lambda formatter: epilog+'\n'
for option in sr.optparse_options:
parser.add_option(option)
parser.add_option('-w', '--bin-width', dest='bin_width',