diff options
author | Yabin Cui <yabinc@google.com> | 2017-08-21 21:40:16 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-08-21 21:40:16 +0000 |
commit | cc4690506e58bea6cda6f513d41040ed3aa4ad4f (patch) | |
tree | 71b7c85631fb87ed9789c09a4dd9bc88ee8ec442 | |
parent | 04938917b539e94a7151dbf985299ba09b1b72a2 (diff) | |
parent | b137bb2c74275a606150a9429982a1f55803895a (diff) | |
download | extras-cc4690506e58bea6cda6f513d41040ed3aa4ad4f.tar.gz |
Merge "simpleperf: fix scripts based on test on darwin/windows."
am: b137bb2c74
Change-Id: I330a053333edb0d2b686d6dd1a63147951d614cf
-rw-r--r-- | simpleperf/doc/README.md | 2 | ||||
-rw-r--r-- | simpleperf/doc/inferno.md | 2 | ||||
-rw-r--r-- | simpleperf/scripts/inferno.bat | 2 | ||||
-rw-r--r-- | simpleperf/scripts/inferno/inferno.py | 18 | ||||
-rw-r--r-- | simpleperf/scripts/test.py | 5 |
5 files changed, 17 insertions, 12 deletions
diff --git a/simpleperf/doc/README.md b/simpleperf/doc/README.md index 2e33a1e6..db584857 100644 --- a/simpleperf/doc/README.md +++ b/simpleperf/doc/README.md @@ -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`. diff --git a/simpleperf/doc/inferno.md b/simpleperf/doc/inferno.md index 2f33e8dc..bfe280a3 100644 --- a/simpleperf/doc/inferno.md +++ b/simpleperf/doc/inferno.md @@ -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 diff --git a/simpleperf/scripts/inferno.bat b/simpleperf/scripts/inferno.bat index 3021d50a..a2d18a7b 100644 --- a/simpleperf/scripts/inferno.bat +++ b/simpleperf/scripts/inferno.bat @@ -1 +1 @@ -python -m inferno.inferno % +python -m inferno.inferno %* diff --git a/simpleperf/scripts/inferno/inferno.py b/simpleperf/scripts/inferno/inferno.py index 15d7776a..b4fd97ad 100644 --- a/simpleperf/scripts/inferno/inferno.py +++ b/simpleperf/scripts/inferno/inferno.py @@ -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(): diff --git a/simpleperf/scripts/test.py b/simpleperf/scripts/test.py index aa9763f7..ea66fee2 100644 --- a/simpleperf/scripts/test.py +++ b/simpleperf/scripts/test.py @@ -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: |