2013-07-07 90 views
0

在Linux上我已經叫visca.py以下Python源文件:蟒蛇subprocess.call參數

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

我在外殼和進口VISCA打開Python解釋器,那麼我visca.recall類型(0),並得到

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 

但是,如果我在Python Shell直接鍵入

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

它的工作原理。有什麼問題?

+0

對不起,我的壞。我做了重新編譯模塊並在每次對源文件進行編輯之後將其導入,但沒有意識到解釋器仍然有我的文件的第一個版本的參數不正確。在我重新開放解釋器之後,代碼正在工作 – hooch

回答

0

它告訴你bufsize must be an integer。我會猜測,在腳本中爲preset設置的值不是整數(請記住,0.0是一個浮點數,而不是整數)。通過在函數中打印出來,快速檢查你的論點。