Page 1 of 2

Problem running a python script for postproc

Posted: January 8th, 2010, 5:28 am
by rudyb
So, I searched my butt off, and didn't find an answer. Forgive me if I missed something.

I've got the python script provided in another thread for updating XBMC and sending an alert via Prowl. I don't have the link to the other thread off-hand. I'll track it down tomorrow.

Anyway, when I try selecting the script itself as my postproc script, I get the following error message:
Script
    Exit(1) operable program or batch file. (More)

More:

'C:\Program' is not recognized as an internal or external command,
operable program or batch file.

I have Python 2.6.4 installed. I have added C:\python26 to Windows' path.

I thought I'd try calling it from a batch file. I made a batch file with the following contents:

Code: Select all

python XBMCUpdate.py %1 %2 %3 %4 %5 %6
and got
C:\Program Files (x86)\SABnzbd>python XBMCUpdate.py "E:\Movies\The Osbournes\Season 4" "The Osbournes - 4x05 - 28 Days Later" "The Osbournes - 4x05 - 28 Days Later" 5259414 movies alt.binaries.multimedia.comedy
'python' is not recognized as an internal or external command,
operable program or batch file.
So I tried removing "python" from the bat file, and got:
C:\Program Files (x86)\SABnzbd>XBMCUpdate.py "E:\Movies\The Osbournes\Season 4" "The Osbournes - 4x05 - 28 Days Later" "The Osbournes - 4x05 - 28 Days Later" 5259414 movies alt.binaries.multimedia.comedy
'XBMCUpdate.py' is not recognized as an internal or external command,
operable program or batch file.


Soooo, I gots no clue. I can run the .py file or .bat file from the command line, no problem.

Actually, clue: I haven't rebooted since installing python or adding it to the windows path. Should that matter? I'll give it a try when I wake up. Bed now.

Thanks for any help!

Oh, running SABnzbd+ 0.5.0b5

Re: Problem running a python script for postproc

Posted: January 8th, 2010, 5:53 am
by shypike
Obviously Python should be in the Windows system path.
Otherwise you should use the full path, like
"c:\program files\Python\python.exe"

Also, the current directory is not the script folder!
If you use a wrapper it should be something like this.
"c:\program files\Python\python.exe" "c:\my\script\path\doit.py"

I think that after a reboot you should be able to run without a wrapper.
I'll check that remark for correctness later.

Re: Problem running a python script for postproc

Posted: January 8th, 2010, 10:19 am
by rudyb
Thanks for the reply.

Python is in the windows path. I'll reboot in a bit and give it a try. Should I need to call "python.exe scriptname.py" via a batch file? Is there a reason I can't just call the script directly when I can from the command line?

Thanks, again!

Re: Problem running a python script for postproc

Posted: January 8th, 2010, 11:34 am
by shypike
Only when you are able to run a PY file directly from the command line
it will work from SABnzbd also.
That's just the OS being critical.

Re: Problem running a python script for postproc

Posted: January 8th, 2010, 12:15 pm
by rudyb
Hmmm... Well, I *can* run it from the command line directly, but when I try in sab, I get this error that I mentioned in the first post:
Script
    Exit(1) operable program or batch file. (More)

More:

'C:\Program' is not recognized as an internal or external command,
operable program or batch file.

Re: Problem running a python script for postproc

Posted: January 8th, 2010, 12:46 pm
by shypike
OK, you'll need the wrapper then.
I'm still not sure why it goes wrong, i'll check that later.

Re: Problem running a python script for postproc

Posted: January 8th, 2010, 1:30 pm
by rudyb
Rebooted. Still getting this when I try running the python script directly:
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
Weird that it works fine from the command line, but not SAB.

I did manage to get it working with the following wrapper, like you suggested:
"c:\python26\python.exe" "C:\Program Files (x86)\SABnzbd\scripts\XBMCUpdate.py" %1 %2 %3 %4 %5 %6
If you come up with an idea as to why I can't point at the .py directly, let me know, and I'll test/fix what needs testing/fixing.

Thanks for your help!

Re: Problem running a python script for postproc

Posted: January 8th, 2010, 1:57 pm
by shypike
There must be something wrong with your Python installation.
I have no problems running a test.py script from SABnzbd.
Did you use the Python installer?

Re: Problem running a python script for postproc

Posted: January 8th, 2010, 2:21 pm
by rudyb
shypike wrote: There must be something wrong with your Python installation.
I have no problems running a test.py script from SABnzbd.
Did you use the Python installer?
I did, indeed. Default settings, even.

Any tips on what I can try to troubleshoot?

The fact that it's saying "'C:\Program' is not recognized..." sounds like it's having a problem with the space in the path to the scripts folder, but .bat files work just fine.

Re: Problem running a python script for postproc

Posted: January 8th, 2010, 3:06 pm
by shypike
Could indeed be the spaces in the path, I install Python in c:\bin\python.
I vaguely remember that Python isn't completely "space in path" compatible.
The trick is usually to put this in the path instead:
c:\progra~1\python26

(Note that you need c:\progra~2\python on 64 bit versions of Windows.)

Re: Problem running a python script for postproc

Posted: January 8th, 2010, 5:20 pm
by rudyb
Weird part is, I've got python installed in C:\python26

SABnzbd is in program files, as is my scripts folder, so maybe I need to move that (or change the way it's specified in the sabnzbd settings, maybe?)

Re: Problem running a python script for postproc

Posted: January 8th, 2010, 5:26 pm
by shypike
It should not be necessary, but it's worth a try.

Re: Problem running a python script for postproc

Posted: January 9th, 2010, 5:13 am
by rudyb
Changed my scripts folder location in sab's settings to "c:\progra~2\sabnzbd\scripts". I can now point sabnzbd directly at python scripts.

Bug?

Running Windows 7, SABnzbd+ 0.5.0 b5. Python 2.6.4, default installation, installed to c:\python26

If you think it's a sab bug, and need anything to help track it down, please let me know, and I'll be happy to assist. 

Re: Problem running a python script for postproc

Posted: January 9th, 2010, 8:50 am
by shypike
OK, got a clue now where to look.
Thanks.

Re: Problem running a python script for postproc

Posted: January 9th, 2010, 10:35 am
by shypike
It's caused by a bug in Python's system library (Python is the programming language we use).
I found a work-around. Will be fixed in next release (after Beta6).