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

Unified Diff: tools/linux-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 | « no previous file | tools/tickprocessor.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/linux-tick-processor.py
diff --git a/tools/linux-tick-processor.py b/tools/linux-tick-processor.py
index e529e0a50d102565630e92c8177693ab141790d2..67c3b95525941ed5d2ba542a74185531e78c31a1 100755
--- a/tools/linux-tick-processor.py
+++ b/tools/linux-tick-processor.py
@@ -30,7 +30,7 @@
# Usage: process-ticks.py <logfile>
# Where <logfile> is the log file name (eg, v8.log).
-import subprocess, re, sys, tickprocessor, getopt
+import subprocess, re, sys, tickprocessor
class LinuxTickProcessor(tickprocessor.TickProcessor):
@@ -54,36 +54,25 @@ class LinuxTickProcessor(tickprocessor.TickProcessor):
pipe.close()
-def Usage():
- print("Usage: linux-tick-processor.py --{js,gc,compiler,other} logfile-name");
- sys.exit(2)
+class LinuxCmdLineProcessor(tickprocessor.CmdLineProcessor):
+
+ def GetRequiredArgsNames(self):
+ return 'log_file'
+
+ def ProcessRequiredArgs(self, args):
+ if len(args) != 1:
+ self.PrintUsageAndExit()
+ else:
+ self.log_file = args[0]
+
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) != 1:
- Usage();
+ cmdline_processor = LinuxCmdLineProcessor()
+ cmdline_processor.ProcessArguments()
tick_processor = LinuxTickProcessor()
- tick_processor.ProcessLogfile(args[0], state, ignore_unknown)
+ cmdline_processor.RunLogfileProcessing(tick_processor)
tick_processor.PrintResults()
+
if __name__ == '__main__':
Main()
« no previous file with comments | « no previous file | tools/tickprocessor.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698