OSDN Git Service

simpleperf: fix scripts based on test on darwin/windows.
authorYabin Cui <yabinc@google.com>
Mon, 21 Aug 2017 20:14:49 +0000 (13:14 -0700)
committerYabin Cui <yabinc@google.com>
Mon, 21 Aug 2017 20:15:46 +0000 (13:15 -0700)
1. fix inferno.bat to correctly pass arguments.
2. type `inferno.bat` instead of `./inferno.bat`.
3. call `inferno.bat` in python should use shell=True.
4. fix the way to open browser on darwin/windows.

Bug: http://b/64035530
Test: run test.py on all platforms.

Change-Id: I5e22907d0c25186b129bf82e0f83d3b71e28ffb2

simpleperf/doc/README.md
simpleperf/doc/inferno.md
simpleperf/scripts/inferno.bat
simpleperf/scripts/inferno/inferno.py
simpleperf/scripts/test.py

index 2e33a1e..db58485 100644 (file)
@@ -764,7 +764,7 @@ On non-Windows platforms:
 
 On Windows platform:
 
-    $ ./inferno.bat -sc --symfs binary_cache
+    $ inferno.bat -sc --symfs binary_cache
 
 Remove `--symfs binary_cache` if you selected not to collect binaries when
 using `app_profiler.py`.
index 2f33e8d..bfe280a 100644 (file)
@@ -52,7 +52,7 @@ visualize in which part of an app the CPU cycles are spent.
 Open a terminal and from `simpleperf/scripts` directory type:
 ```
 ./inferno.sh  (on Linux/Mac)
-./inferno.bat (on Windows)
+inferno.bat (on Windows)
 ```
 
 Inferno will collect data, process them and automatically open your web browser
index 3021d50..a2d18a7 100644 (file)
@@ -1 +1 @@
-python -m inferno.inferno %
+python -m inferno.inferno %*
index 15d7776..b4fd97a 100644 (file)
@@ -214,13 +214,17 @@ def collect_machine_info(process):
 
 
 def open_report_in_browser(report_path):
-    # Try to open the report with Chrome
-    browser_key = ""
-    for key, value in webbrowser._browsers.items():
-        if key.find("chrome") != -1:
-            browser_key = key
-    browser = webbrowser.get(browser_key)
-    browser.open(report_path, new=0, autoraise=True)
+    try:
+        # Try to open the report with Chrome
+        browser_key = ""
+        for key, value in webbrowser._browsers.items():
+            if key.find("chrome") != -1:
+                browser_key = key
+        browser = webbrowser.get(browser_key)
+        browser.open(report_path, new=0, autoraise=True)
+    except:
+        # webbrowser.get() doesn't work well on darwin/windows.
+        webbrowser.open_new_tab(report_path)
 
 
 def main():
index aa9763f..ea66fee 100644 (file)
@@ -92,11 +92,12 @@ class TestBase(unittest.TestCase):
     def run_cmd(self, args, return_output=False):
         if args[0].endswith('.py'):
             args = [sys.executable] + args
+        use_shell = args[0].endswith('.bat')
         try:
             if not return_output:
-                returncode = subprocess.call(args)
+                returncode = subprocess.call(args, shell=use_shell)
             else:
-                subproc = subprocess.Popen(args, stdout=subprocess.PIPE)
+                subproc = subprocess.Popen(args, stdout=subprocess.PIPE, shell=use_shell)
                 (output_data, _) = subproc.communicate()
                 returncode = subproc.returncode
         except: