Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(542)

Unified Diff: tools/windows-tick-processor.py

Issue 20452: Refactored command-line options handling in tick processor scripts (Closed)
Patch Set: Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/tickprocessor.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/windows-tick-processor.py
diff --git a/tools/windows-tick-processor.py b/tools/windows-tick-processor.py
index dc2578184554835b3dd66519efc00c12b4b7a352..ade2bf27e17f860f213adccfe9312feaa9e49652 100755
--- a/tools/windows-tick-processor.py
+++ b/tools/windows-tick-processor.py
@@ -38,7 +38,7 @@
# only works for statically linked executables - no information about
# shared libraries is logged from v8 on Windows.
-import os, re, sys, tickprocessor, getopt
+import os, re, sys, tickprocessor
class WindowsTickProcessor(tickprocessor.TickProcessor):
@@ -107,36 +107,30 @@ class WindowsTickProcessor(tickprocessor.TickProcessor):
finally:
map_file.close()
-def Usage():
- print("Usage: windows-tick-processor.py binary logfile-name");
- sys.exit(2)
+
+class WindowsCmdLineProcessor(tickprocessor.CmdLineProcessor):
+
+ def __init__(self):
+ super(WindowsCmdLineProcessor, self).__init__()
+ self.binary_file = None
+
+ def GetRequiredArgsNames(self):
+ return 'binary log_file'
+
+ def ProcessRequiredArgs(self, args):
+ if len(args) != 2:
+ self.PrintUsageAndExit()
+ else:
+ self.binary_file = args[0]
+ self.log_file = args[1]
+
def Main():
- # parse command line options
- ignore_unknown = False
- state = None;
- try:
- opts, args = getopt.getopt(sys.argv[1:], "jgco", ["js", "gc", "compiler", "other", "ignore-unknown"])
- except getopt.GetoptError:
- usage()
- # process options.
- for key, value in opts:
- if key in ("-j", "--js"):
- state = 0
- if key in ("-g", "--gc"):
- state = 1
- if key in ("-c", "--compiler"):
- state = 2
- if key in ("-o", "--other"):
- state = 3
- if key in ("--ignore-unknown"):
- ignore_unknown = True
- # do the processing.
- if len(args) != 2:
- Usage();
+ cmdline_processor = WindowsCmdLineProcessor()
+ cmdline_processor.ProcessArguments()
tickprocessor = WindowsTickProcessor()
- tickprocessor.ParseMapFile(args[0])
- tickprocessor.ProcessLogfile(args[1], state, ignore_unknown)
+ tickprocessor.ParseMapFile(cmdline_processor.binary_file)
+ cmdline_processor.RunLogfileProcessing(tickprocessor)
tickprocessor.PrintResults()
if __name__ == '__main__':
« no previous file with comments | « tools/tickprocessor.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698