18
18
# Check if 'serial' module is installed
19
19
try :
20
20
from serial import Serial
21
- except ImportError , e :
22
- print "Error: Can't import 'serial' module: %s" % e
21
+ except ImportError as e :
22
+ print ( "Error: Can't import 'serial' module: %s" % e )
23
23
exit (- 1 )
24
24
25
25
import os
29
29
from time import sleep , time
30
30
from optparse import OptionParser
31
31
32
- import host_tests_plugins
32
+ from . import host_tests_plugins
33
33
34
34
# This is a little tricky. We need to add upper directory to path so
35
35
# we can find packages we want from the same level as other files do
39
39
from tools .test_api import get_module_avail
40
40
41
41
42
- class Mbed :
42
+ class Mbed ( object ) :
43
43
""" Base class for a host driven test
44
44
"""
45
45
def __init__ (self ):
@@ -117,7 +117,7 @@ def __init__(self):
117
117
self .serial_timeout = 1
118
118
119
119
self .timeout = self .DEFAULT_TOUT if self .options .timeout is None else self .options .timeout
120
- print 'MBED: Instrumentation: "%s" and disk: "%s"' % (self .port , self .disk )
120
+ print ( 'MBED: Instrumentation: "%s" and disk: "%s"' % (self .port , self .disk ) )
121
121
122
122
def init_serial_params (self , serial_baud = 9600 , serial_timeout = 1 ):
123
123
""" Initialize port parameters.
@@ -183,11 +183,11 @@ def pool_for_serial_init(self, serial_baud, serial_timeout, pooling_loops=40, in
183
183
stdout .write ('.' )
184
184
stdout .flush ()
185
185
else :
186
- print "...port ready!"
186
+ print ( "...port ready!" )
187
187
result = True
188
188
break
189
189
if not result and last_error :
190
- print last_error
190
+ print ( last_error )
191
191
return result
192
192
193
193
def set_serial_timeout (self , timeout ):
@@ -221,7 +221,7 @@ def serial_readline(self, timeout=5):
221
221
c = self .serial .read (1 )
222
222
result += c
223
223
except Exception as e :
224
- print "MBED: %s" % str (e )
224
+ print ( "MBED: %s" % str (e ) )
225
225
result = None
226
226
break
227
227
if c == '\n ' :
@@ -298,7 +298,7 @@ def flush(self):
298
298
return result
299
299
300
300
301
- class HostTestResults :
301
+ class HostTestResults ( object ) :
302
302
""" Test results set by host tests
303
303
"""
304
304
def __init__ (self ):
@@ -389,8 +389,8 @@ def run(self):
389
389
self .print_result (result )
390
390
else :
391
391
self .notify ("HOST: Passive mode..." )
392
- except Exception , e :
393
- print str (e )
392
+ except Exception as e :
393
+ print ( str (e ) )
394
394
self .print_result (self .RESULT_ERROR )
395
395
396
396
def setup (self ):
@@ -406,7 +406,7 @@ def setup(self):
406
406
def notify (self , message ):
407
407
""" On screen notification function
408
408
"""
409
- print message
409
+ print ( message )
410
410
stdout .flush ()
411
411
412
412
def print_result (self , result ):
0 commit comments