0

I'm trying to use pexpect to open pianobar (a client for Pandora online radio).

If I just start pianobar from the command line (not from my Python program), it logs in automatically using info from the config file (Email, Password, TLS_fingerprint).

If I run my script in IDLE, it also works. But if I run it from the command prompt, it acts like it doesn't see the config file, and asks me for my Email and Password.

I can feed it my Email and Password, but I have no idea what to do with the TLS_fingerprint, and end up with 'TLS handshake failed'

I am a total Newb, in over my head, but if I can get this to work it would be great. I am doing this on a Raspberry Pi, using the Raspian Wheezy Linux distro.

Thanks 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

Works fine from an idle window using run from the pull down menu, but if I start from a bash prompt with 'sudo python ' it starts the process and then hangs.

I figured out from the error message that it doesn't auto login when run from the bash prompt (it does this fine from idle).
It is stopping and asking "Email:?", and so it never gets to "station:"

I was able to get past this by adding 'child.expect' and 'child.sendline' statements to my script to enter the Email and Password, but then it stops because "TLS handshake failed"

Since the Email, Password, and TLS info are all the config file, I figure it isn't accessing the config file for some reason.

Thanks for taking the time to look at this, Zygo

  • Hi and welcome to stackoverflow. You need to provide a better description of your problem, and probably provide some code, just mentioning pexpect and pandora is not enough for us to understand what you what to do. – theAlse Mar 09 '13 at 14:43
  • Hi and thanks for your reply. I added more detail to the original post. I hope that makes it a bit clearer. – user2151423 Mar 09 '13 at 16:01
  • Maybe the difference is that here you run it with `sudo` --- so it runs as root and looks for config files in `/root`. – Armin Rigo Mar 09 '13 at 18:46
  • You nailed it! Thank you, thank you, thank you! The script is looking in the root directory and not finding the file. I moved the file to root/.config/pianobar/config and presto! – user2151423 Mar 09 '13 at 20:21

0 Answers0