OLD | NEW |
1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 """Defines the client library.""" | 5 """Defines the client library.""" |
6 | 6 |
7 import argparse | 7 import argparse |
8 import datetime | 8 import datetime |
9 import logging | 9 import logging |
10 import os | 10 import os |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 ]) | 195 ]) |
196 | 196 |
197 self._ExecuteProcess(cmd) | 197 self._ExecuteProcess(cmd) |
198 | 198 |
199 def _ExecuteProcess(self, cmd): | 199 def _ExecuteProcess(self, cmd): |
200 """Executes a process, waits for it to complete, and checks for success.""" | 200 """Executes a process, waits for it to complete, and checks for success.""" |
201 logging.debug('Running %s', ' '.join(cmd)) | 201 logging.debug('Running %s', ' '.join(cmd)) |
202 p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | 202 p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
203 _, stderr = p.communicate() | 203 _, stderr = p.communicate() |
204 if p.returncode != 0: | 204 if p.returncode != 0: |
205 stderr.seek(0) | |
206 raise Error(stderr) | 205 raise Error(stderr) |
207 | 206 |
208 def OnConnect(self, ip_address): | 207 def OnConnect(self, ip_address): |
209 """Receives client ip address on connection.""" | 208 """Receives client ip address on connection.""" |
210 self._ip_address = ip_address | 209 self._ip_address = ip_address |
211 self._connected = True | 210 self._connected = True |
212 self._rpc = common_lib.ConnectToServer(self._ip_address) | 211 self._rpc = common_lib.ConnectToServer(self._ip_address) |
213 logging.info('%s connected from %s', self._name, ip_address) | 212 logging.info('%s connected from %s', self._name, ip_address) |
214 self._connect_event.set() | 213 self._connect_event.set() |
OLD | NEW |