Permalink
Browse files

Make pylint happier.

  • Loading branch information...
1 parent 1686abd commit c06f98581beb679943ef4beec2339c3037f0d78c @vpelletier committed Aug 17, 2016
Showing with 18 additions and 15 deletions.
  1. +17 −14 examples/hotplug_advanced.py
  2. +1 −1 usb1.py
@@ -18,6 +18,7 @@
Advanced hotplug examples.
Presents ways of integrating hotplug into your userland USB driver.
"""
+from __future__ import print_function
import select
import sys
import usb1
@@ -29,11 +30,11 @@ class NoHotplugSupport(Exception):
pass
def onAwesomeDeviceLeft(awesome_device):
- print 'Device left:', str(awesome_device)
+ print('Device left:', str(awesome_device))
def onAwesomeDeviceArrived(awesome_device):
awesome_device.onClose = onAwesomeDeviceLeft
- print 'Device arrived:', str(awesome_device)
+ print('Device arrived:', str(awesome_device))
class SelectPoller(object):
"""
@@ -58,7 +59,7 @@ def poll(self, timeout=None):
select.select(*([[
fd
for fd, events in self._fd_dict.iteritems() if events & flag
- ] for flag in flag_list ] + [timeout])),
+ ] for flag in flag_list] + [timeout])),
flag_list,
):
result[fd] = result.get(fd, 0) | happened_flag
@@ -169,9 +170,9 @@ class AwesomeDeviceHoarderSimple(AwesomeDeviceHoarderBase):
"""
def run(self):
with self.context:
- print 'Registering hotplug callback...'
+ print('Registering hotplug callback...')
self._registerCallback()
- print 'Callback registered. Monitoring events, ^C to exit'
+ print('Callback registered. Monitoring events, ^C to exit')
while True:
self.context.handleEvents()
@@ -188,9 +189,9 @@ class AwesomeDeviceHoarderEventLoop(AwesomeDeviceHoarderBase):
"""
def __enter__(self):
self.context.open()
- print 'Registering hotplug callback...'
+ print('Registering hotplug callback...')
self._registerCallback()
- print 'Callback registered.'
+ print('Callback registered.')
return self
def __exit__(self, exc_type, exc_val, exc_tb):
@@ -203,7 +204,7 @@ def eventloop():
# to base_poller.
# The event loop would be something like:
poller = usb1.USBPoller(awesome_device_hoarder.context, base_poller)
- print 'Monitoring events, ^C to exit'
+ print('Monitoring events, ^C to exit')
while True:
poller.poll()
mode_dict['eventloop'] = eventloop
@@ -212,22 +213,24 @@ def main():
try:
mode = mode_dict[sys.argv[1]]
except (KeyError, IndexError):
- print 'Usage: %s [%s]' % (
+ print('Usage: %s [%s]' % (
sys.argv[0],
'|'.join(mode_dict),
- )
+ ))
sys.exit(1)
- print ('NOTE: this example needs sufficient permissions to be able to '
+ print(
+ 'NOTE: this example needs sufficient permissions to be able to '
'open USB devices to produce any interesting output. If you see '
'nothing below, check you have USB devices plugged *and* that you '
- 'have sufficient permissions to open them.')
+ 'have sufficient permissions to open them.'
+ )
try:
mode()
except NoHotplugSupport, exc:
- print exc.value
+ print(exc.value)
sys.exit(1)
except (KeyboardInterrupt, SystemExit):
- print 'Exiting'
+ print('Exiting')
if __name__ == '__main__':
main()
View
@@ -48,7 +48,7 @@
from __future__ import division
from ctypes import byref, create_string_buffer, c_int, sizeof, POINTER, \
cast, c_uint8, c_uint16, c_ubyte, string_at, c_void_p, cdll, addressof, \
- c_char, py_object
+ c_char
from ctypes.util import find_library
import sys
import threading

0 comments on commit c06f985

Please sign in to comment.