From f1f89196852ce4ad220c8e608e3e79e9308e24a9 Mon Sep 17 00:00:00 2001 From: Ellen Zhong Date: Fri, 20 Jun 2014 09:04:17 -0400 Subject: [PATCH] added verbosity flag to convert --- testing/UnitTest.py | 6 +++--- testing/convert.py | 10 ++++++---- testing/gromacs_driver.py | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/testing/UnitTest.py b/testing/UnitTest.py index c7637f71..dfb3456f 100644 --- a/testing/UnitTest.py +++ b/testing/UnitTest.py @@ -108,7 +108,7 @@ def test_desmond(args): h1, h2 = add_handler(odir) flags = ['--des_in', f, '--desmond', '--gromacs', '--lammps', '--odir', odir] flags = add_flags(args, flags) - logger.info('Converting %s with command:\n python convert.py %s' % (f,' '.join(flags))) + logger.info('Converting %s with command:\n python convert.py %s\n' % (f,' '.join(flags))) try: diff = convert.main(flags) # reuses code from convert.py assert(len(diff) == N_FORMATS) @@ -138,7 +138,7 @@ def test_gromacs(args): h1, h2 = add_handler(odir) flags = ['--gro_in', g, t, '--desmond', '--gromacs', '--lammps', '--odir', odir] flags = add_flags(args, flags) - logger.info('Converting %s, %s with command:\n python convert.py %s' + logger.info('Converting %s, %s with command:\n python convert.py %s\n' % (g, t,' '.join(flags))) try: diff = convert.main(flags) # reuses code from convert.py @@ -167,7 +167,7 @@ def test_lammps(args): h1, h2 = add_handler(odir) flags = ['--lmp_in', f, '--desmond', '--gromacs', '--lammps', '--odir', odir] flags = add_flags(args, flags) - logger.info('Converting %s with command:\n python convert.py %s' % (f,' '.join(flags))) + logger.info('Converting %s with command:\n python convert.py %s\n' % (f,' '.join(flags))) try: diff = convert.main(flags) # reuses code from convert.py assert(len(diff) == N_FORMATS) diff --git a/testing/convert.py b/testing/convert.py index bfda17ae..79d02c52 100644 --- a/testing/convert.py +++ b/testing/convert.py @@ -21,9 +21,9 @@ # Make a global logging object. if __name__ == '__main__': logger = logging.getLogger('InterMolLog') - logger.setLevel(logging.INFO) # specifies lowest severity log messages to handle (DEBUG will be ignored) + logger.setLevel(logging.DEBUG) # specifies lowest severity log messages to handle h = logging.StreamHandler() - #f = logging.Formatter("%(levelname)s %(asctime)s %(funcName)s %(lineno)d %(message)s") + h.setLevel(logging.INFO) # ignores DEBUG level for now f = logging.Formatter("%(levelname)s %(asctime)s %(message)s", "%Y-%m-%d %H:%M:%S") h.setFormatter(f) logger.addHandler(h) @@ -71,7 +71,7 @@ def get_parser(): metavar='path', default='lmp_openmpi', help='path for LAMMPS binary, needed for energy evaluation') group_misc.add_argument('-v', '--verbose', dest='verbose', action='store_true', - help='verbosity') + help='high verbosity, includes DEBUG level output') # prints help if no arguments given if len(sys.argv)==1: @@ -88,6 +88,8 @@ def main(args=''): args = parser.parse_args(args) logger = logging.getLogger('InterMolLog') + if args.verbose: + h.setLevel(logging.DEBUG) System._sys = System('InterMol') # --------------- PROCESS INPUTS ----------------- # @@ -210,7 +212,7 @@ def main(args=''): e_outfile.append(-1) # display energy comparison results - out = [''] + out = ['InterMol Conversion Energy Comparison Results',''] out.append('{0} input energy file: {1}'.format(input_type, e_infile)) for type, file in zip(output_type, e_outfile): out.append('{0} output energy file: {1}'.format(type, file)) diff --git a/testing/gromacs_driver.py b/testing/gromacs_driver.py index c731a27f..d7a3328b 100644 --- a/testing/gromacs_driver.py +++ b/testing/gromacs_driver.py @@ -83,7 +83,7 @@ def gromacs_energies(top=None, gro=None, mdp=None, gropath='',grosuff='', grompp select = " ".join(map(str, range(1, 20))) + " 0 " cmd = 'echo {select} | {genergy_bin} -f {ener} -o {ener_xvg} -dp'.format( select=select, genergy_bin=genergy_bin, ener=ener, ener_xvg=ener_xvg) - logger.debug('Running GROMACS with command:\n %s' % ' '.join(cmd)) + logger.debug('Running GROMACS with command:\n %s' % cmd) with open(stdout, 'wa') as out, open(stderr, 'wa') as err: exit = subprocess.call(cmd, stdout=out, stderr=err, shell=True) if exit: