Function - python subprocess.call arguments

De openkb
Aller à : Navigation, rechercher

Sommaire

Questions

on Linux I have the following python source file called visca.py:

from subprocess import call
def recall(preset):
    call(["visca-cli", "memory_recall", str(preset)])

I open python interpreter in shell and import visca, then i type visca.recall(0) and get

Traceback (most recent call last):   File "<stdin>", line 1, in <module>   File "visca.py", line 13, in recall
    subprocess.call(["visca-cli", "memory_recall", str(preset)])   File "/usr/lib/python2.7/subprocess.py", line 493, in call
    return Popen(*popenargs, **kwargs).wait()   File "/usr/lib/python2.7/subprocess.py", line 629, in __init__
    raise TypeError("bufsize must be an integer") TypeError: bufsize must be an integer

However, if I type directly in python shell

>>> from subprocess import call
>>> call(["visca-cli", "memory_recall", "0"])
10 OK - no return value
0

it works. What s the problem?

Answers

It s telling you that bufsize must be an integer. I am going to guess that whatever value you set for preset in the script is not an integer (keep in mind that 0.0 is a float, not an integer). Do a quick check for what your argument is by printing it out in the function.

Source

License : cc by-sa 3.0

http://stackoverflow.com/questions/17508414/python-subprocess-call-arguments

Related

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Outils