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

Side by Side Diff: build/android/pylib/android_commands.py

Issue 26402002: [Android] Some clean up in pylib. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove shebang lines Created 7 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 | Annotate | Revision Log
« no previous file with comments | « build/android/device_stats_monitor.py ('k') | build/android/pylib/device_stats_monitor.html » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Provides an interface to communicate with the device via the adb command. 5 """Provides an interface to communicate with the device via the adb command.
6 6
7 Assumes adb binary is currently on system path. 7 Assumes adb binary is currently on system path.
8 """ 8 """
9 9
10 import collections 10 import collections
11 import datetime 11 import datetime
12 import logging 12 import logging
13 import os 13 import os
14 import re 14 import re
15 import shlex 15 import shlex
16 import subprocess 16 import subprocess
17 import sys 17 import sys
18 import tempfile 18 import tempfile
19 import time 19 import time
20 20
21 import cmd_helper 21 import cmd_helper
22 import constants 22 import constants
23 import io_stats_parser
24 try: 23 try:
25 from pylib import pexpect 24 from pylib import pexpect
26 except: 25 except:
27 pexpect = None 26 pexpect = None
28 27
29 sys.path.append(os.path.join( 28 sys.path.append(os.path.join(
30 constants.DIR_SOURCE_ROOT, 'third_party', 'android_testrunner')) 29 constants.DIR_SOURCE_ROOT, 'third_party', 'android_testrunner'))
31 import adb_interface 30 import adb_interface
32 import am_instrument_parser 31 import am_instrument_parser
33 import errors 32 import errors
(...skipping 1327 matching lines...) Expand 10 before | Expand all | Expand 10 after
1361 pass 1360 pass
1362 return pids 1361 return pids
1363 1362
1364 def GetIoStats(self): 1363 def GetIoStats(self):
1365 """Gets cumulative disk IO stats since boot (for all processes). 1364 """Gets cumulative disk IO stats since boot (for all processes).
1366 1365
1367 Returns: 1366 Returns:
1368 Dict of {num_reads, num_writes, read_ms, write_ms} or None if there 1367 Dict of {num_reads, num_writes, read_ms, write_ms} or None if there
1369 was an error. 1368 was an error.
1370 """ 1369 """
1370 IoStats = collections.namedtuple(
1371 'IoStats',
1372 ['device',
1373 'num_reads_issued',
1374 'num_reads_merged',
1375 'num_sectors_read',
1376 'ms_spent_reading',
1377 'num_writes_completed',
1378 'num_writes_merged',
1379 'num_sectors_written',
1380 'ms_spent_writing',
1381 'num_ios_in_progress',
1382 'ms_spent_doing_io',
1383 'ms_spent_doing_io_weighted',
1384 ])
1385
1371 for line in self.GetFileContents('/proc/diskstats', log_result=False): 1386 for line in self.GetFileContents('/proc/diskstats', log_result=False):
1372 stats = io_stats_parser.ParseIoStatsLine(line) 1387 fields = line.split()
1388 stats = IoStats._make([fields[2]] + [int(f) for f in fields[3:]])
1373 if stats.device == 'mmcblk0': 1389 if stats.device == 'mmcblk0':
1374 return { 1390 return {
1375 'num_reads': stats.num_reads_issued, 1391 'num_reads': stats.num_reads_issued,
1376 'num_writes': stats.num_writes_completed, 1392 'num_writes': stats.num_writes_completed,
1377 'read_ms': stats.ms_spent_reading, 1393 'read_ms': stats.ms_spent_reading,
1378 'write_ms': stats.ms_spent_writing, 1394 'write_ms': stats.ms_spent_writing,
1379 } 1395 }
1380 logging.warning('Could not find disk IO stats.') 1396 logging.warning('Could not find disk IO stats.')
1381 return None 1397 return None
1382 1398
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
1625 """ 1641 """
1626 def __init__(self, output): 1642 def __init__(self, output):
1627 self._output = output 1643 self._output = output
1628 1644
1629 def write(self, data): 1645 def write(self, data):
1630 data = data.replace('\r\r\n', '\n') 1646 data = data.replace('\r\r\n', '\n')
1631 self._output.write(data) 1647 self._output.write(data)
1632 1648
1633 def flush(self): 1649 def flush(self):
1634 self._output.flush() 1650 self._output.flush()
OLDNEW
« no previous file with comments | « build/android/device_stats_monitor.py ('k') | build/android/pylib/device_stats_monitor.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698