Reputation: 75
I am writing a GUI in Linux using Kivy and Python. The program should detect a USB device and using the device to program an image to a target. Here are a snippet of my code:
These are the codes I am trying to detect USB device. This is on a file, let's call it A.py.
busses = usb.busses()
for bus in busses:
devices = bus.devices
for dev in devices:
if (dev.idVendor == vendor and dev.idProduct == product):
obj = ProgJTAG.ProgJTAG(bus.dirname,dev.filename, dev.idVendor, dev.idProduct, dev)
break
When I ran the program, assertion error occured in creating an instance of ProgJTAG. This is defined in a separate file ProgJTAG.py as follows:
class ProgJTAG(BoxLayout):
usb_bus = StringProperty('')
usb_dev = StringProperty('')
usb_vendor = StringProperty('')
usb_product = StringProperty('')
def __init__(self, _usb_bus, _usb_dev, _usb_vendor, _usb_product, dev):
super(ProgJTAG, self).__init__()
self.usb_bus = _usb_bus
self.usb_dev = _usb_dev
self.usb_vendor = str(_usb_vendor)
self.usb_product = str(_usb_product)
self.bind(usb_bus=self.usb_bus)
self.bind(usb_dev=self.usb_bus)
self.bind(usb_vendor=self.usb_bus)
self.bind(usb_product=self.usb_bus)
The error occur from the line self.bind(usb_bus=self.usb_bus). The error message is File "_event.pyx", kivy._event.EventDispatcher.bind(kivy/_event.c:5536) AssertionError: '' is not callable
Q1. Can anyone help what the assertion means?
Q2. I noticed that the _usb_bus and _usb_dev are empty string. Is this assertion caused by the fact that the _usb_bus and _usb_dev are empty string property hence not callable?
Upvotes: 0
Views: 1710
Reputation: 29488
Yes, when you bind you must pass a function because the binding will try to call it later.
Upvotes: 1