我编写了一个可以在我的笔记本电脑上运行的程序(Ubuntu 14.1 和 Python 2.7.6),但不能在树莓派上运行(Wheezy w/ Python 2.7.3)。我收到一个索引:在笔记本电脑上运行时没有出现的 Pi 上的超出范围错误。
闪存.py
def bang(self, dev):
self.makers = g.get_csv_values()
self.ma =()
self.ma = g.id_hub(self.makers)
#print self.ma
self.make = self.ma[0]
self.dex = self.ma[1]
self.dfu = g.get_dfu(self.make, self.dex) //Here's the call
self.hub_name = g.get_product_name(self.make, self.dex)
if self.hub_name is None:
self.mod.text = 'No hub found'
self.prm.text = 'Reconnect hub'
Clock.schedule_interval(self.detect, 1)
else:
self.mod.text = self.hub_name + ' hub found'
self.prm.text = 'Testing...'
self.err_comp = g.flash_hub(self.dfu)
if self.err_comp == 'Error':
self.prm.text = 'Error: Reflash'
#Clock.schedule_interval(self.detach, 1)
if self.err_comp == 'Completed':
self.prm.text = 'Flashing Done!'
time.sleep(3)
Clock.schedule_interval(self.detach, 2)
吸气剂.py
def id_hub(args):
hub = subprocess.check_output('sudo lsusb | grep 2996', shell=True)
vends = []
vends = [hub[28:32], hub[63:67], hub[98:102]]
for i in vends:
a = '0x' + i
if a in args[0]['Hub_idProduct']:
gm = args[0], args[0]['Hub_idProduct'].index(a)
return gm
elif a in args[1]['Hub_idProduct']:
ford = args[1], args[1]['Hub_idProduct'].index(a)
return ford
elif a in args[2]['Hub_idProduct']:
chrysler = args[2], args[2]['Hub_idProduct'].index(a)
return chrysler
def get_dfu(make, dex):
#print make
#print dex
return make['dfu'][dex] //Here is the line indicated in the error
我正在测试的 2 个案例中的self.ma