Pexpect孩子没有阅读配置文件

时间:2013-03-09 12:24:31

标签: python linux raspberry-pi pexpect pandora

我正在尝试使用pexpect打开pianobar(Pandora在线广播的客户端)。

如果我只是从命令行(而不是我的Python程序)启动pianobar,它会使用配置文件中的信息(电子邮件,密码,TLS_fingerprint)自动登录。

如果我在IDLE中运行我的脚本,它也可以。但是,如果我从命令提示符运行它,它就像它没有看到配置文件,并询问我的电子邮件和密码。

我可以通过电子邮件和密码提供,但我不知道如何使用TLS_fingerprint, 最终“TLS握手失败”

我是一个全新的,在我脑海中,但如果我能让它上班,那就太棒了。 我在Raspberry Pi上使用Raspian Wheezy Linux发行版进行此操作。

由于 ZYGO

Here is the relevant code:
from pexpect import spawn

child = spawn('/usr/bin/pianobar')  
#starts pianobar which then should log me on automatically with info from its config file

print channel
child.expect('station:')    #looks for prompt from pianobar for ‘station:'
print child.before
child.sendline('35')       #tells pianobar I’d like it to play station 35

使用下拉菜单中的运行从空闲窗口正常工作, 但如果我从'sudo python'的bash提示开始 它启动过程然后挂起。

我从错误消息中发现,当从bash提示符运行时它没有自动登录(从空闲状态可以做到这一点)。
它正在停止并询问“Email:?”,因此它永远不会到达“station:”

我能够通过在我的脚本中添加'child.expect'和'child.sendline'语句来输入电子邮件和密码,但之后因为“TLS握手失败”而停止

由于电子邮件,密码和TLS信息都是配置文件,我认为由于某种原因它没有访问配置文件。

感谢您花时间看看这个, ZYGO

0 个答案:

没有答案
相关问题