ARM-software / gator

Sources for Arm Streamline's gator daemon, part of Arm Mobile Studio suite of performance analysis tools
https://www.arm.com/products/development-tools/graphics/arm-mobile-studio
133 stars 70 forks source link

gator: Fix script exception on non-English devices #21

Closed FrankNine closed 4 years ago

FrankNine commented 4 years ago

ADB may return non-ASCII character on non-English devices Which would cause 'UnicodeDecodeError' while running gator_me.py Forcing Subprocesses running with "utf-8" encoding can solve this issue

Signed-off-by: Chun-Fu Chao aaefiikmnnnr@gmail.com

Error message I encountered:

Searching for a Mali GPU:
Exception in thread Thread-11:
Traceback (most recent call last):
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python38-32\lib\threading.py", line 932, in _bootstrap_inner
    self.run()
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python38-32\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 1366, in _readerthread
    buffer.append(fh.read())
UnicodeDecodeError: 'cp950' codec can't decode byte 0x9d in position 5412: illegal multibyte sequence
Traceback (most recent call last):
  File ".\gator_me.py", line 878, in <module>
    sys.exit(main())
  File ".\gator_me.py", line 847, in main
    get_gpu_name(device)
  File ".\gator_me.py", line 429, in get_gpu_name
    logFile = device.adb("shell", "dumpsys", "SurfaceFlinger")
  File ".\gator_me.py", line 244, in adb
    rep = sp.run(commands, check=True, shell=shell, stdout=sp.PIPE,
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 491, in run
    stdout, stderr = process.communicate(input, timeout=timeout)
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 1024, in communicate
    stdout, stderr = self._communicate(input, endtime, timeout)
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 1416, in _communicate
    stdout = stdout[0]
IndexError: list index out of range
bengaineyarm commented 4 years ago

:+1: Thanks