Problem running a python script for postproc

Get help with all aspects of SABnzbd
Forum rules
Help us help you:
  • Are you using the latest stable version of SABnzbd? Downloads page.
  • Tell us what system you run SABnzbd on.
  • Adhere to the forum rules.
  • Do you experience problems during downloading?
    Check your connection in Status and Interface settings window.
    Use Test Server in Config > Servers.
    We will probably ask you to do a test using only basic settings.
  • Do you experience problems during repair or unpacking?
    Enable +Debug logging in the Status and Interface settings window and share the relevant parts of the log here using [ code ] sections.
rudyb
Newbie
Newbie
Posts: 28
Joined: December 8th, 2009, 11:46 pm

Problem running a python script for postproc

Post 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
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: Problem running a python script for postproc

Post 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.
rudyb
Newbie
Newbie
Posts: 28
Joined: December 8th, 2009, 11:46 pm

Re: Problem running a python script for postproc

Post 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!
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: Problem running a python script for postproc

Post 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.
rudyb
Newbie
Newbie
Posts: 28
Joined: December 8th, 2009, 11:46 pm

Re: Problem running a python script for postproc

Post 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.
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: Problem running a python script for postproc

Post by shypike »

OK, you'll need the wrapper then.
I'm still not sure why it goes wrong, i'll check that later.
rudyb
Newbie
Newbie
Posts: 28
Joined: December 8th, 2009, 11:46 pm

Re: Problem running a python script for postproc

Post 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!
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: Problem running a python script for postproc

Post 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?
rudyb
Newbie
Newbie
Posts: 28
Joined: December 8th, 2009, 11:46 pm

Re: Problem running a python script for postproc

Post 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.
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: Problem running a python script for postproc

Post 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.)
rudyb
Newbie
Newbie
Posts: 28
Joined: December 8th, 2009, 11:46 pm

Re: Problem running a python script for postproc

Post 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?)
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: Problem running a python script for postproc

Post by shypike »

It should not be necessary, but it's worth a try.
rudyb
Newbie
Newbie
Posts: 28
Joined: December 8th, 2009, 11:46 pm

Re: Problem running a python script for postproc

Post 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. 
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: Problem running a python script for postproc

Post by shypike »

OK, got a clue now where to look.
Thanks.
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: Problem running a python script for postproc

Post 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).
Post Reply