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

Side by Side Diff: adb/contrib/adb_commands_safe.py

Issue 2633463003: python-adb: Fix KillADB logging. (Closed)
Patch Set: Created 3 years, 11 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 Google Inc. All rights reserved. 1 # Copyright 2015 Google Inc. All rights reserved.
2 # 2 #
3 # Licensed under the Apache License, Version 2.0 (the "License"); 3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License. 4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at 5 # You may obtain a copy of the License at
6 # 6 #
7 # http://www.apache.org/licenses/LICENSE-2.0 7 # http://www.apache.org/licenses/LICENSE-2.0
8 # 8 #
9 # Unless required by applicable law or agreed to in writing, software 9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, 10 # distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 time.sleep(0.001) 70 time.sleep(0.001)
71 71
72 try: 72 try:
73 processes = subprocess.check_output(['ps', 'aux']).splitlines() 73 processes = subprocess.check_output(['ps', 'aux']).splitlines()
74 except subprocess.CalledProcessError: 74 except subprocess.CalledProcessError:
75 _LOG.error('KillADB(): unable to scan process list.') 75 _LOG.error('KillADB(): unable to scan process list.')
76 processes = [] 76 processes = []
77 77
78 culprits = '\n'.join(p for p in processes if 'adb' in p) 78 culprits = '\n'.join(p for p in processes if 'adb' in p)
79 _LOG.error( 79 _LOG.error(
80 'KillADB() failed after %d attempts. Potential culprits: %s' % culprits) 80 'KillADB() failed after %d attempts. Potential culprits: %s',
81 attempts, culprits)
81 82
82 83
83 class AdbCommandsSafe(object): 84 class AdbCommandsSafe(object):
84 """Wraps an AdbCommands to make it exception safe. 85 """Wraps an AdbCommands to make it exception safe.
85 86
86 The fact that exceptions can be thrown any time makes the client code really 87 The fact that exceptions can be thrown any time makes the client code really
87 hard to write safely. Convert USBError* to None return value. 88 hard to write safely. Convert USBError* to None return value.
88 89
89 Only contains the low level commands. High level operations are built upon the 90 Only contains the low level commands. High level operations are built upon the
90 low level functionality provided by this class. 91 low level functionality provided by this class.
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 self.Close() 905 self.Close()
905 if not self._WaitUntilFound(use_serial=use_serial, timeout=timeout): 906 if not self._WaitUntilFound(use_serial=use_serial, timeout=timeout):
906 return False 907 return False
907 if not self._OpenHandle(): 908 if not self._OpenHandle():
908 return False 909 return False
909 return self._Connect(use_serial=use_serial) 910 return self._Connect(use_serial=use_serial)
910 911
911 def __repr__(self): 912 def __repr__(self):
912 return '<Device %s %s>' % ( 913 return '<Device %s %s>' % (
913 self.port_path, self.serial if self.is_valid else '(broken)') 914 self.port_path, self.serial if self.is_valid else '(broken)')
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698