receiver: clean up receiver creation
This commit is contained in:
parent
141721bc37
commit
e301551dde
|
@ -48,14 +48,12 @@ class Receiver:
|
||||||
number = 0xFF
|
number = 0xFF
|
||||||
kind = None
|
kind = None
|
||||||
|
|
||||||
def __init__(self, handle, device_info):
|
def __init__(self, handle, path, product_id):
|
||||||
assert handle
|
assert handle
|
||||||
self.handle = handle
|
|
||||||
assert device_info
|
|
||||||
self.path = device_info.path
|
|
||||||
self.isDevice = False # some devices act as receiver so we need a property to distinguish them
|
self.isDevice = False # some devices act as receiver so we need a property to distinguish them
|
||||||
# USB product id, used for some Nano receivers
|
self.handle = handle
|
||||||
self.product_id = device_info.product_id
|
self.path = path
|
||||||
|
self.product_id = product_id
|
||||||
product_info = _product_information(self.product_id)
|
product_info = _product_information(self.product_id)
|
||||||
if not product_info:
|
if not product_info:
|
||||||
_log.warning('Unknown receiver type: %s', self.product_id)
|
_log.warning('Unknown receiver type: %s', self.product_id)
|
||||||
|
@ -386,7 +384,7 @@ class Receiver:
|
||||||
try:
|
try:
|
||||||
handle = _base.open_path(device_info.path)
|
handle = _base.open_path(device_info.path)
|
||||||
if handle:
|
if handle:
|
||||||
return Receiver(handle, device_info)
|
return Receiver(handle, device_info.path, device_info.product_id)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
_log.exception('open %s', device_info)
|
_log.exception('open %s', device_info)
|
||||||
if e.errno == _errno.EACCES:
|
if e.errno == _errno.EACCES:
|
||||||
|
|
Loading…
Reference in New Issue