From da91bb6d1ec2edda204eb50bb1ec6a0e00a4d557 Mon Sep 17 00:00:00 2001 From: NĂ©lio Laranjeiro Date: Fri, 6 Mar 2009 22:57:57 +0100 Subject: tools/trace: Ended the interpretor part of the trace tool. --- tools/trace/trace.py | 55 +++++++++++++++++++--------------------------------- 1 file changed, 20 insertions(+), 35 deletions(-) (limited to 'tools/trace/trace.py') diff --git a/tools/trace/trace.py b/tools/trace/trace.py index 86bffb35..6850a4cd 100644 --- a/tools/trace/trace.py +++ b/tools/trace/trace.py @@ -1,45 +1,30 @@ #!/bin/usr/env python +from optparse import OptionParser import sys +sys.path.append ('../../host/') from tcreator.tcreator import * from tinter.tinter import * -def create_parse_args(list = None): - infile = "" - outfile = "" - enum_name = "" - if list == None: - return None - else: - for i in range (0, len(list)): - if list[i] == "-e": - enum_name = list[i+1] - if list[i] == "-o": - outfile = list[i+1] - else: - infile = list[i] - return [infile, outfile, enum_name] +print "Trace System v1.0 by APBTeam\n" +parser = OptionParser() +parser.add_option("-e", "--enum-name", dest="enum_name", + help="provide the enumerator name", metavar="ENUM") +parser.add_option("-o", "--output", dest="outfile", + help="Store the eunerator on the output file") +parser.add_option("-i", "--infile", dest="infile", + help="Read the data from the file") +parser.add_option("-t", "--type", dest="type", + help="create to create the enumeration, inter to read the log from the flash.") -print "Trace System v1.0 by APBTeam\n" +[options, args] = parser.parse_args() -if len(sys.argv) > 1: - argc = len(sys.argv) - if sys.argv[1] == "create": - if (argc >= 2) and (argc <= 7): - data = create_parse_args(sys.argv) - cre = TCreator (data[0], data[1], data[2]) - cre.create () - else: - raise Exception ("Not enough arguments") - if sys.argv[1] == "inter": - if argc >= 2: - inter = TInter (sys.argv[2]) - if argc == 2: - inter.trace_print(None) - else: - inter.trace_print(sys.argv[3]) - else: - raise Exception ("Not enough arguments") +if options.type == 'create': + cre = TCreator (options.infile, options.outfile, options.enum_name) + cre.create () +elif options.type == "inter": + inter = TInter (options.infile, options.outfile) + inter.trace_print() else: - raise Exception ("Not enough arguments") + print "see the help\n python trace --help" -- cgit v1.2.3