Changeset 1558
- Timestamp:
- Nov 2, 2014 10:11:53 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIpath.py
r1557 r1558 13 13 Other routines will update GSASII from the subversion server if svn can be 14 14 found. 15 16 Accesses configuration options, as defined in config.py 15 17 ''' 16 18 … … 307 309 sys.exit() 308 310 311 def IPyBreak(): 312 '''A routine that invokes an IPython session at the calling location 313 This routine is only used when debug=True is set in config.py 314 ''' 315 savehook = sys.excepthook # save the exception hook 316 from IPython.terminal.embed import InteractiveShellEmbed 317 import inspect 318 ipshell = InteractiveShellEmbed() 319 320 frame = inspect.currentframe().f_back 321 msg = 'Entering IPython console inside {0.f_code.co_filename} at line {0.f_lineno}'.format(frame) 322 ipshell(msg,stack_depth=2) # Go up one level, to see the calling routine 323 sys.excepthook = savehook # reset IPython's change to the exception hook 324 325 def exceptHook(*args): 326 '''A routine to be called when an exception occurs. It prints the traceback 327 with fancy formatting and then calls an IPython shell with the environment 328 of the exception location. 329 330 This routine is only used when debug=True is set in config.py 331 ''' 332 from IPython.core import ultratb 333 ultratb.FormattedTB(call_pdb=False,color_scheme='LightBG')(*args) 334 from IPython.terminal.embed import InteractiveShellEmbed 335 import inspect 336 frame = inspect.getinnerframes(args[2])[-1][0] 337 msg = 'Entering IPython console at {0.f_code.co_filename} at line {0.f_lineno}'.format(frame) 338 InteractiveShellEmbed(banner1=msg)(local_ns=frame.f_locals,global_ns=frame.f_globals) 339 340 def DoNothing(): 341 '''A routine that does nothing. This is called in place of IPyBreak and pdbBreak 342 except when the debug option is set True in config.py 343 ''' 344 pass 345 346 if GetConfigValue('debug'): 347 print 'Debug on: IPython: Exceptions and G2path.IPyBreak(); pdb: G2path.pdbBreak()' 348 sys.excepthook = exceptHook 349 import pdb 350 pdbBreak = pdb.set_trace 351 else: 352 IPyBreak = DoNothing 353 pdbBreak = DoNothing 354 309 355 if __name__ == '__main__': 310 356 import subprocess -
trunk/config_example.py
r1513 r1558 16 16 provide the default behavior if the file is not present or if any configuration 17 17 variable is not set, but please do place a docstring here for every used 18 config variable explaining what it does. 18 config variable explaining what it does. Access these variables using 19 :func:`GSASIIpath.GetConfigValue`. 20 ''' 21 22 debug = False 23 '''Set to True to turn on debugging mode. This enables use of IPython on 24 exceptions and on calls to :func:`GSASIIpath.IPyBreak`. Calls to 25 :func:`GSASIIpath.pdbBreak` will invoke pdb at that location. 26 If debug is false calls to :func:`GSASIIpath.IPyBreak` and 27 :func:`GSASIIpath.pdbBreak` are ignored. 19 28 ''' 20 29
Note: See TracChangeset
for help on using the changeset viewer.