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

Side by Side Diff: tools/skpbench/_adb.py

Issue 2415033002: skpbench: suppot Nexus 6P (Closed)
Patch Set: skpbench: suppot Nexus 6P Created 4 years, 2 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 unified diff | Download patch
« no previous file with comments | « no previous file | tools/skpbench/_hardware_android.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2016 Google Inc. 1 # Copyright 2016 Google Inc.
2 # 2 #
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import re 6 import re
7 import subprocess 7 import subprocess
8 import sys
8 9
9 class Adb: 10 class Adb:
10 def __init__(self, device_serial=None): 11 def __init__(self, device_serial=None):
11 self.__invocation = ['adb'] 12 self.__invocation = ['adb']
12 if device_serial: 13 if device_serial:
13 self.__invocation.extend(['-s', device_serial]) 14 self.__invocation.extend(['-s', device_serial])
14 15
15 def shell(self, cmd): 16 def shell(self, cmd):
16 subprocess.call(self.__invocation + ['shell', cmd]) 17 subprocess.call(self.__invocation + ['shell', cmd], stdout=sys.stderr)
17 18
18 def check(self, cmd): 19 def check(self, cmd):
19 result = subprocess.check_output(self.__invocation + ['shell', cmd]) 20 result = subprocess.check_output(self.__invocation + ['shell', cmd])
20 return result.rstrip() 21 return result.rstrip()
21 22
22 def check_lines(self, cmd): 23 def check_lines(self, cmd):
23 result = self.check(cmd) 24 result = self.check(cmd)
24 return re.split('[\r\n]+', result) 25 return re.split('[\r\n]+', result)
25 26
26 def get_device_model(self): 27 def get_device_model(self):
27 result = self.check('getprop | grep ro.product.model') 28 result = self.check('getprop | grep ro.product.model')
28 result = re.match(r'\[ro.product.model\]:\s*\[(.*)\]', result) 29 result = re.match(r'\[ro.product.model\]:\s*\[(.*)\]', result)
29 return result.group(1) if result else 'unknown_product' 30 return result.group(1) if result else 'unknown_product'
30 31
31 def is_root(self): 32 def is_root(self):
32 return self.check('echo $USER') == 'root' 33 return self.check('whoami') == 'root'
33 34
34 def attempt_root(self): 35 def attempt_root(self):
35 if self.is_root(): 36 if self.is_root():
36 return True 37 return True
37 subprocess.call(self.__invocation + ['root']) 38 subprocess.call(self.__invocation + ['root'], stdout=sys.stderr)
38 return self.is_root() 39 return self.is_root()
39 40
40 def remount(self): 41 def remount(self):
41 subprocess.call(self.__invocation + ['remount']) 42 subprocess.call(self.__invocation + ['remount'], stdout=sys.stderr)
OLDNEW
« no previous file with comments | « no previous file | tools/skpbench/_hardware_android.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698