1
0
mirror of https://github.com/rzzzwilson/pymlac.git synced 2025-06-10 09:32:41 +00:00
rzzzwilson.pymlac/pymlac/test_Trace.py
2018-07-28 19:55:49 +07:00

66 lines
1.4 KiB
Python
Executable File

"""
Test the pymlac Trace code.
Usage: test_Trace.py [-h]
"""
import Trace
# if we don't have log.py, don't crash
try:
import log
log = log.Log('test.log', log.Log.DEBUG)
except ImportError:
def log(*args, **kwargs):
pass
def test():
for inst in (' NOP', ' LAW 0'):
Trace.start()
Trace.itrace(inst)
Trace.dtrace(inst)
Trace.end()
################################################################################
if __name__ == '__main__':
import sys
import getopt
import traceback
# print some usage information
def usage(msg=None):
if msg:
print(msg+'\n')
print(__doc__) # module docstring used
# our own handler for uncaught exceptions
def excepthook(type, value, tb):
msg = '\n' + '=' * 80
msg += '\nUncaught exception:\n'
msg += ''.join(traceback.format_exception(type, value, tb))
msg += '=' * 80 + '\n'
print(msg)
sys.exit(1)
# plug our handler into the python system
sys.excepthook = excepthook
# decide which tiles to use, default is GMT
argv = sys.argv[1:]
try:
(opts, args) = getopt.getopt(argv, 'h', ['help'])
except getopt.error:
usage()
sys.exit(1)
for (opt, param) in opts:
if opt in ['-h', '--help']:
usage()
sys.exit(0)
test()