Comment 0 for bug 1650480

Revision history for this message
seahawk1986 (seahawk1986-hotmail) wrote :

When opening the serial connection using pyserial 3.x in plotter.py fails ( https://bazaar.launchpad.net/~inkscape.dev/inkscape/trunk/view/head:/share/extensions/plotter.py#L196 ), the script looks at the wrong element of the exception (which results in raising another Exception like in this post: https://forum.ubuntuusers.de/post/8682508/ ):

Traceback (most recent call last):
  File "plotter.py", line 227, in <module>
    e.affect()
  File "/usr/share/inkscape/extensions/inkex.py", line 268, in affect
    self.effect()
  File "plotter.py", line 96, in effect
    self.sendHpglToSerial()
  File "plotter.py", line 162, in sendHpglToSerial
    if 'ould not open port' in inst.args[0]:
TypeError: argument of type 'int' is not iterable

Minimal example in the python interpreter:
>>> import serial
>>> mySerial = serial.Serial()
>>> mySerial.port = '/dev/ttyS0'
>>> try:
... mySerial.open()
... except Exception as inst:
... inst[0]
... inst.strerror
...
13
"could not open port /dev/ttyS0: [Errno 13] Keine Berechtigung: '/dev/ttyS0'"

It should be more reliable to use the inst.strerror Attribute of the Exception or str(inst) instead of an index-Based value in the Exception.