diff --git a/openhtf/core/station_api.py b/openhtf/core/station_api.py index 566b0b7e9..39bb06ae8 100644 --- a/openhtf/core/station_api.py +++ b/openhtf/core/station_api.py @@ -413,7 +413,7 @@ def wait_for_update(self, timeout_s=1): except xmlrpc.client.Fault as fault: # TODO(madsci): This is a super kludge, eventually implement the # ReraisingMixin for ServerProxy, but that's hard, so do this for now. - if 'openhtf.io.station_api.UpdateTimeout' in fault.faultString: + if 'openhtf.core.station_api.UpdateTimeout' in fault.faultString: return self.cached_state raise diff --git a/openhtf/plugs/usb/adb_device.py b/openhtf/plugs/usb/adb_device.py index 511ff7d64..54c280f6e 100644 --- a/openhtf/plugs/usb/adb_device.py +++ b/openhtf/plugs/usb/adb_device.py @@ -30,7 +30,6 @@ class, subclass, and protocol. """ -import io import logging import os.path @@ -47,6 +46,7 @@ from openhtf.plugs.usb import usb_exceptions from openhtf.util import timeouts +import six # USB interface class, subclass, and protocol for matching against. CLASS = 0xFF @@ -165,7 +165,7 @@ def pull(self, device_filename, dest_file=None, timeout_ms=None): if isinstance(dest_file, str): dest_file = open(dest_file, 'w') elif dest_file is None: - dest_file = io.StringIO() + dest_file = six.StringIO() self.filesync_service.recv(device_filename, dest_file, timeouts.PolledTimeout.from_millis(timeout_ms)) if should_return_data: diff --git a/openhtf/plugs/usb/fastboot_protocol.py b/openhtf/plugs/usb/fastboot_protocol.py index d8c81d3b7..b2d958678 100644 --- a/openhtf/plugs/usb/fastboot_protocol.py +++ b/openhtf/plugs/usb/fastboot_protocol.py @@ -17,7 +17,6 @@ import binascii import collections -import io import logging import os import struct @@ -71,7 +70,7 @@ def send_command(self, command, arg=None): """ if arg is not None: command = '%s:%s' % (command, arg) - self._write(io.StringIO(command), len(command)) + self._write(six.StringIO(command), len(command)) def handle_simple_responses( self, timeout_ms=None, info_cb=DEFAULT_MESSAGE_CALLBACK): @@ -260,14 +259,14 @@ def download(self, source_file, source_len=0, Returns: Response to a download request, normally nothing. """ - if isinstance(source_file, str): + if isinstance(source_file, six.string_types): source_len = os.stat(source_file).st_size source_file = open(source_file) if source_len == 0: # Fall back to storing it all in memory :( data = source_file.read() - source_file = io.StringIO(data) + source_file = six.StringIO(data) source_len = len(data) self._protocol.send_command('download', '%08x' % source_len) diff --git a/openhtf/plugs/usb/filesync_service.py b/openhtf/plugs/usb/filesync_service.py index bc8106d38..b3fd3ca96 100644 --- a/openhtf/plugs/usb/filesync_service.py +++ b/openhtf/plugs/usb/filesync_service.py @@ -112,6 +112,7 @@ import sys import time +from future.utils import raise_with_traceback from openhtf.plugs.usb import adb_message from openhtf.plugs.usb import usb_exceptions @@ -223,7 +224,7 @@ def _check_for_fail_message(self, transport, exc_info, timeout): # pylint: disa if sys.exc_info()[0] is usb_exceptions.AdbRemoteError: raise # Otherwise reraise the original exception. - raise exc_info[0](exc_info[1]).raise_with_traceback(exc_info[2]) + raise_with_traceback(exc_info[0](exc_info[1]), traceback=exc_info[2]) # pylint: disable=too-many-arguments def send(self, src_file, filename, st_mode=DEFAULT_PUSH_MODE, mtime=None, diff --git a/openhtf/plugs/usb/shell_service.py b/openhtf/plugs/usb/shell_service.py index 0a6e0bbc6..7806a0258 100644 --- a/openhtf/plugs/usb/shell_service.py +++ b/openhtf/plugs/usb/shell_service.py @@ -68,7 +68,6 @@ # output.getvalue() now contains the output of the arecord command. """ -import io import threading import time