Skip to content

Commit

Permalink
added verbosity flag to UnitTest
Browse files Browse the repository at this point in the history
  • Loading branch information
Ellen Zhong committed Jun 20, 2014
1 parent 62054dd commit d0ef6b8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
9 changes: 5 additions & 4 deletions testing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ $ python convert.py -h
usage: convert.py [-h] [--des_in file] [--gro_in file file] [--lmp_in file]
[--desmond] [--gromacs] [--lammps] [--odir directory]
[--oname prefix] [-e] [--efile EFILE] [-d path] [-g path]
[-l path] [-v] [-f]
[-l path] [-v]
Perform a file conversion
Expand Down Expand Up @@ -41,8 +41,7 @@ Other optional arguments:
path for GROMACS binary, needed for energy evaluation
-l path, --lmppath path
path for LAMMPS binary, needed for energy evaluation
-v, --verbose verbosity
-f, --force ignore warnings
-v, --verbose high verbosity, includes DEBUG level output
````

UnitTest.py
Expand All @@ -51,7 +50,7 @@ UnitTest.py
````
$ python UnitTest.py -h
usage: PROG [-h] [--desmond] [--gromacs] [--lammps] [-e] [-d path] [-g path]
[-l path]
[-l path] [-v]
InterMol Unit Testing Script
--------------------------------
Expand Down Expand Up @@ -81,4 +80,6 @@ Other optional arguments:
path for GROMACS binary, needed for energy evaluation
-l path, --lmppath path
path for LAMMPS binary, needed for energy evaluation
-v, --verbose print conversion output to console, -v for INFO level,
-vv for DEBUG level
````
12 changes: 12 additions & 0 deletions testing/UnitTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ def parse_args():
group_misc.add_argument('-l', '--lmppath', dest='lmppath',
metavar='path', default='lmp_openmpi',
help='path for LAMMPS binary, needed for energy evaluation')
group_misc.add_argument('-v', '--verbose', dest='verbose', action='count',
help='print conversion output to console, -v for INFO level, -vv for DEBUG level')
if len(sys.argv)==1:
parser.print_help()
sys.exit(1)
Expand Down Expand Up @@ -217,6 +219,16 @@ def summarize_results(input_type, files, results):
def main():
args = parse_args()

if args.verbose:
h = logging.StreamHandler()
if args.verbose == 2:
h.setLevel(logging.DEBUG) # more verbosity
else: # == 1
h.setLevel(logging.INFO)
f = logging.Formatter("%(levelname)s %(asctime)s %(message)s", "%Y-%m-%d %H:%M:%S")
h.setFormatter(f)
logger.addHandler(h)

if not os.path.isdir(OUTPUT_DIR):
os.mkdir(OUTPUT_DIR)

Expand Down

0 comments on commit d0ef6b8

Please sign in to comment.