Skip to content
Snippets Groups Projects
Commit f942e555 authored by cmaffeo2's avatar cmaffeo2
Browse files

Added --debug option to mrdna script

parent 06033882
No related branches found
No related tags found
No related merge requests found
......@@ -23,6 +23,8 @@ parser.add_argument('--fine-steps', type=float, default=1e7,
help='Simulation steps for fine model (50 fs/step)')
parser.add_argument('--backbone-scale', type=float, default=1.0,
help='Factor to scale DNA backbone in atomic model; try 0.25 to avoid clashes for atomistic simulations')
parser.add_argument('--debug', action='store_true',
help='Run through the python debugger?')
parser.add_argument('--draw-cylinders', action='store_true',
help='Whether or not to draw the cylinders')
......@@ -37,8 +39,7 @@ parser.add_argument('input_file', type=str,
args = parser.parse_args()
if __name__ == '__main__':
def main():
infile = pathlib.Path(args.input_file)
try:
prefix = infile.stem
......@@ -100,3 +101,43 @@ if __name__ == '__main__':
simulate( **run_args )
if __name__ == '__main__':
if args.debug:
class Restart(Exception):
"""Causes a debugger to be restarted for the debugged python program."""
pass
import traceback
import sys
from pdb import Pdb
pdb = Pdb()
while True:
try:
# pdb._runscript(mainpyfile)
pdb.runcall(main)
if pdb._user_requested_quit:
break
print("The program finished and will be restarted")
except Restart:
print("Restarting...")
print("\t" + " ".join(args))
except SystemExit:
# In most cases SystemExit does not warrant a post-mortem session.
print("The program exited via sys.exit(). Exit status:", end=' ')
print(sys.exc_info()[1])
except SyntaxError:
traceback.print_exc()
sys.exit(1)
except:
traceback.print_exc()
print("Uncaught exception. Entering post mortem debugging")
print("Running 'cont' or 'step' will restart the program")
t = sys.exc_info()[2]
pdb.interaction(None, t)
print("Post mortem debugger finished. mrdna will be restarted")
else:
main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment