post-processing script not receiving args?

Come up with a useful post-processing script? Share it here!
Post Reply
zoul
Newbie
Newbie
Posts: 4
Joined: November 21st, 2009, 1:25 pm

post-processing script not receiving args?

Post by zoul »

I'm attempting to write my first post-processing script.  I'm writing it in Python, on a windows machine ... according to the sabnzbd history the script is executing and the output is being dumped to the log file.  However, none of the arguments that sabnzbd says it will pass are being passed over ... the only argument found in sys.argv is the path of the script itself.

Am I missing something here?

Code: Select all

import sys

def main():
  print 'Executing ...'
  print sys.argv
  if len(sys.argv) > 1:
    print 'Parameters passed.'
    for p in sys.argv:
      print "Argument: " + p
  print 'Exitting ...'
  sys.exit(0)

main()
This scripts log output simply shows:

Code: Select all

    Executing ...
['path/to/myscript.py']
Exitting ...
I've tested this script from the command line using: "python myscript.py a b c d e f" and it works just fine ...

Are there any 'hello world' style script examples that show the bare basics, or some sort of script template ... or other form of requirement that I am missing?  The docs basically just say that the specified number of parameters are passed, some may be empty values ... and then explains what each parameter is, but I can't seem to find anything more in-depth.
zoul
Newbie
Newbie
Posts: 4
Joined: November 21st, 2009, 1:25 pm

Re: post-processing script not receiving args?

Post by zoul »

as a sidenote, in the sabnzbd.log ... it shows that it's running the external script with the parameters ...

Code: Select all

2009-11-22 13:26:24,403::INFO::[newsunpack] Running external script h:\htpc\downloads\sabnzbd\scripts\myepisodes.py(H:\htpc\videos\unsorted\TV\Cops\Season 22, msgid_5225615 Cops - 22x10 - Slacker Crimes Special Edition.nzb, Cops - 22x10 - Slacker Crimes Special Edition, 5225615, tv, alt.binaries.multimedia)
update:

I attempted to use the prowl python script, to see if maybe my script was just not working properly or not ... and found that the prowl python script also does not function properly, it errors with the following stack trace:

Code: Select all

    Traceback (most recent call last):
  File "H:\htpc\downloads\sabnzbd\scripts\prowl.py", line 4, in <module>
    job_name = sys.argv[3]
IndexError: list index out of range
So, I'm beginning to wonder whether or not python scripts are supported properly on the windows platform.  If it makes a difference, I am running Windows Server 2008 64-bit, and my python installation on this machine is 2.5.2 (although this should not matter since sabnzbd is running in it's own contained python interpreter ... most likely built using py2exe or whatever it's called ... so, external script execution should be performed ... I would think, with that, no?)

I created another script, called 'test.bat' that contains:

Code: Select all

echo %1
echo %2
echo %3
echo %4
echo %5
echo %6
and it outputs the parameters properly ... so, now I'm completely baffled and clueless.


I believe I have solved this problem by creating a .bat file that calls my python script for me and passes the information along, it also allows me to setup sabnzbd to execute multiple post-processing scripts - such as the Prowl script to notify my iPhone of the completed download, so I know what I can watch ... as well as executing my python script for updating myepisodes.com to flag an item as 'acquired' (this script is still in testing, and needs quite a bit of work ... but since I couldn't find one already written, I started writing it ... and will post it when it's ready for general consumption)
Last edited by zoul on November 23rd, 2009, 1:57 pm, edited 1 time in total.
rollingeyeball
Release Testers
Release Testers
Posts: 181
Joined: January 30th, 2009, 12:26 pm

Re: post-processing script not receiving args?

Post by rollingeyeball »

I wasn't able to interpret the documentation any better so I just took your second approach first and since it worked I never even tried to run the py file directly.
Seems like I made the right move :D


This myepisodes script- if it works in the slightest will be AWESOME.
I'm certainly looking forward to that post!

Have a good one,
Rolling
JohnSCS
Newbie
Newbie
Posts: 42
Joined: August 17th, 2009, 12:23 am

Re: post-processing script not receiving args?

Post by JohnSCS »

Zoul,

Install Python 2.6.4 from http://www.python.org/download/releases/2.6.4/ - which is the version I use. 2.5 is old and lacks some features, and 3.0+ has changed too many libraries.

The python interpreter in SAB (I believe) is not available for scripts outside of SAB.
Post Reply