Skip to content

Commit

Permalink
Make pylint happier.
Browse files Browse the repository at this point in the history
  • Loading branch information
vpelletier committed Aug 17, 2016
1 parent 1686abd commit c06f985
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
31 changes: 17 additions & 14 deletions examples/hotplug_advanced.py
Expand Up @@ -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
Expand All @@ -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):
"""
Expand All @@ -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
Expand Down Expand Up @@ -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()

Expand All @@ -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):
Expand All @@ -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
Expand All @@ -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()
2 changes: 1 addition & 1 deletion usb1.py
Expand Up @@ -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
Expand Down

0 comments on commit c06f985

Please sign in to comment.