usb15: abort if permission denied

Don't ignore permission denied when looking for a suitable USB device.
Otherwise users don't notice what the problem is, stcgal will just
keep waiting on the prompt.
This commit is contained in:
Grigori Goronzy 2016-05-20 02:47:42 +02:00
parent f90fe4152b
commit 26ef34991b

View File

@ -21,7 +21,7 @@
#
import serial
import sys, os, time, struct, re
import sys, os, time, struct, re, errno
import argparse
import collections
from stcgal.models import MCUModelDatabase
@ -1528,7 +1528,11 @@ class StcUsb15Protocol(Stc15Protocol):
self.status_packet = None
raise StcFramingException
else: raise StcFramingException
except (StcFramingException, usb.core.USBError): time.sleep(0.5)
except StcFramingException:
time.sleep(0.5)
except usb.core.USBError as err:
if err.errno == errno.EACCES:
raise IOError(err.strerror)
self.initialize_model()
print("done")