Issue #27 resolved

TypeError: write() got multiple values for keyword argument 'timeout'

Anonymous created an issue

Running galileo with no arguments gives me the following error:

Traceback (most recent call last):
  File "./galileo.py", line 786, in <module>
    main()
  File "./galileo.py", line 778, in main
    total, success, skipped = syncAllTrackers(include, exclude, cmdlineargs.force, cmdlineargs.dump, cmdlineargs.upload)
  File "./galileo.py", line 604, in syncAllTrackers
    fitbit.disconnect()
  File "./galileo.py", line 330, in disconnect
    self.dongle.ctrl_write([2, 2])
  File "./galileo.py", line 206, in ctrl_write
    l = self.dev.write(0x02, data, self.CtrlIF.bInterfaceNumber, timeout=timeout)
TypeError: write() got multiple values for keyword argument 'timeout'

I have pyusb version 1.0.0b1 if that makes a difference.

Comments (12)

  1. Benoît Allard repo owner

    Looks like it's a legitimate error as the timeout is supposed to be the third parameter, and as we supply it as extra keyword parameter. You are probably using a special version of Python that can't cope with that (an older maybe ? 2.6 ?).

    You can confirm my assumption by putting the timeout in third position, and removing the "timeout=" in the call to self.dev

    Thanks for reporting !

  2. Benoît Allard repo owner

    Been reading the doc too quickly, and mixing two write methods (from usb.core.Device and usb.core.Endpoint). So my suggestion was wrong.

    I just added more detailled information to the --version parameter (and when shamefully exiting like in your case). Would you mind updating your version with the new tip, and pasting the new error message there ?

  3. Alan Berndt
    # A serious error happened, which is probably due to a
    # programming error. Please open a new issue with the following
    # information on the galileo bug tracker:
    #    https://bitbucket.org/benallard/galileo/issues/new
    # Python: 2.7.6 (default, Nov 26 2013, 12:52:49) [GCC 4.8.2]
    # Platform: Linux gandalf.eab.local 3.12.9-2-ARCH #1 SMP PREEMPT Fri Jan 31 10:22:54 CET 2014 x86_64 
    # pyusb: 1.0.0b1
    # requests: 2.2.1
    # ./run: 0.4dev
    Traceback (most recent call last):
      File "./run", line 5, in <module>
        main()
      File "/home/alan/source/galileo/galileo/main.py", line 296, in main
        total, success, skipped = syncAllTrackers(config)
      File "/home/alan/source/galileo/galileo/main.py", line 37, in syncAllTrackers
        fitbit.disconnect()
      File "/home/alan/source/galileo/galileo/tracker.py", line 47, in disconnect
        self.dongle.ctrl_write([2, 2])
      File "/home/alan/source/galileo/galileo/dongle.py", line 112, in ctrl_write
        l = self.dev.write(0x02, data, self.CtrlIF.bInterfaceNumber, timeout=timeout)
    TypeError: write() got multiple values for keyword argument 'timeout'
    
  4. Benoît Allard repo owner

    I'm rather clueless on this one ... Maybe we should escalate this to the pyusb guys, as the trouble is happening when calling one of their function ... I really can't figure out which write function is being talked to, as there is only one that take this amount of argument, and then, the timeout parameter is the last one ...

    Can you still try a few more things ?

    • name all the parameters in the offending line (File "/home/alan/source/galileo/galileo/dongle.py", line 112), replace it with:
        l = self.dev.write(endpoint=0x02, data=data, interface=self.CtrlIF.bInterfaceNumber, timeout=timeout)
    
    • Or remove the timeout= from this line (don't name any parameter).
  5. Benoît Allard repo owner

    Looks like we have an hypothesis here ... Could it be that you are using the development version of pyusb ? (Not 1.0.0b1 from the released tar ball ?)

    It would namely explain the issue ...

    I need to think a bit on how to support both older and newer versions ...

  6. Alan Berndt

    I tried using the .zip from sourceforge and I get the same error.

    As per your earlier request, I tried naming all the parameters to write and got this:

    # A serious error happened, which is probably due to a
    # programming error. Please open a new issue with the following
    # information on the galileo bug tracker:
    #    https://bitbucket.org/benallard/galileo/issues/new
    # Python: 2.7.6 (default, Nov 26 2013, 12:52:49) [GCC 4.8.2]
    # Platform: Linux gandalf.eab.local 3.12.9-2-ARCH #1 SMP PREEMPT Fri Jan 31 10:22:54 CET 2014 x86_64 
    # pyusb: 1.0.0b1
    # requests: 2.2.1
    # ./run: 0.4dev
    Traceback (most recent call last):
      File "./run", line 5, in <module>
        main()
      File "/home/alan/source/galileo/galileo/main.py", line 296, in main
        total, success, skipped = syncAllTrackers(config)
      File "/home/alan/source/galileo/galileo/main.py", line 37, in syncAllTrackers
        fitbit.disconnect()
      File "/home/alan/source/galileo/galileo/tracker.py", line 47, in disconnect
        self.dongle.ctrl_write([2, 2])
      File "/home/alan/source/galileo/galileo/dongle.py", line 112, in ctrl_write
        l = self.dev.write(endpoint=0x02, data=data, interface=self.CtrlIF.bInterfaceNumber, timeout=timeout)
    TypeError: write() got an unexpected keyword argument 'interface'
    

    I also tried with no parameters named and curiously got this:

    # A serious error happened, which is probably due to a
    # programming error. Please open a new issue with the following
    # information on the galileo bug tracker:
    #    https://bitbucket.org/benallard/galileo/issues/new
    # Python: 2.7.6 (default, Nov 26 2013, 12:52:49) [GCC 4.8.2]
    # Platform: Linux gandalf.eab.local 3.12.9-2-ARCH #1 SMP PREEMPT Fri Jan 31 10:22:54 CET 2014 x86_64 
    # pyusb: 1.0.0b1
    # requests: 2.2.1
    # ./run: 0.4dev
    Traceback (most recent call last):
      File "./run", line 5, in <module>
        main()
      File "/home/alan/source/galileo/galileo/main.py", line 296, in main
        total, success, skipped = syncAllTrackers(config)
      File "/home/alan/source/galileo/galileo/main.py", line 37, in syncAllTrackers
        fitbit.disconnect()
      File "/home/alan/source/galileo/galileo/tracker.py", line 47, in disconnect
        self.dongle.ctrl_write([2, 2])
      File "/home/alan/source/galileo/galileo/dongle.py", line 112, in ctrl_write
        l = self.dev.write(0x02, data, self.CtrlIF.bInterfaceNumber, timeout)
    TypeError: write() takes at most 4 arguments (5 given)
    

    At this point I checked the pyusb source and found that timeout is apparently the third parameter and the interface parameter is no longer used. After removing that parameter from all the read and write calls, the software seems to run correctly, but now I am having some unrelated issues with my fitbit one.

  7. Benoît Allard repo owner

    I think you're having a conflict between the dev version you previously installed and the one you downloaded from sourceforge.

    Indeed, in the repository from github, the interface parameter has been removed (https://github.com/walac/pyusb/blob/master/usb/core.py#L628), but this happened after 1.0.0b1. In the tar ball I downloaded from sourceforge, the parameter is still there (https://github.com/walac/pyusb/blob/0546cad8980783c39f96db717005a550059b730f/usb/core.py#L598).

    I'd rather wait for the next pyusb release before looking at this change, as there might be a few more to come ... Non stable API are not ideal, but no one said the pyusb API was supposed to be stable ... (especially that it's still in beta version ...)

  8. Alan Berndt

    That could be although I tried to ensure I removed the dev build. In any case, the software is working for me now so I don't see any reason for this to stay open.

    I don't know if I am able to close this issue as I wasn't logged in when I created it.

  9. Log in to comment