Pre processing trouble

Come up with a useful post-processing script? Share it here!
jowi
Newbie
Newbie
Posts: 19
Joined: August 9th, 2012, 6:16 am

Pre processing trouble

Post by jowi »

I'm experimenting with the pre-processing / pre-queue scripting, according to http://wiki.sabnzbd.org/user-pre-queue-script.
I've create a simple python script, just for testing purposes, the only thing it does is return '0' indicating sabnzbd should REFUSE the nzb.

I can see in sabnzbd's logging that it is actually called, and says it accepts the nzb, i dont know why, since i return 0 as in REFUSED?

Code: Select all

2012-08-10 14:59:15,592::INFO::[newsunpack:1417] Running pre-queue script ['/mnt/cache/Apps/sabnzbd/scripts/pre.py', 'Breaking.Bad.S05E02.Madrigal.HDTV.x264-FQM', '', 'tvseries', '', '-100', '330523175', 'alt.binaries.multimedia alt.binaries.teevee', '', '', '', '']
2012-08-10 14:59:15,595::INFO::[newsunpack:1439] Pre-Q accepts Breaking.Bad.S05E02.Madrigal.HDTV.x264-FQM
the script itself:

Code: Select all

#!/usr/bin/env python
import os
import sys

print "0"
sys.exit(0)
What am i missing here?
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: Pre processing trouble

Post by shypike »

Does the script run from the command line?
If SABnzbd detects any problems it will accept the NZB anyway.
Set logging to "Debug" in order to get more info logged.
jowi
Newbie
Newbie
Posts: 19
Joined: August 9th, 2012, 6:16 am

Re: Pre processing trouble

Post by jowi »

Yes, it runs from the command line. Debug logging is on, the logging in the first post is with debug logging.

I've also tried to let the script create a file on startup, just as 'proof' it has been executed. From the command line it works, from within sabnzb, it does not, even though the logging keeps showing the script has been executed.

I've also tried returning the extra 6 empty lines, so it totals the 7 lines. Did not help:

Code: Select all

#!/usr/bin/env python
import os
import sys

print "0"
print
print
print
print
print
print

sys.exit(0)
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: Pre processing trouble

Post by shypike »

Do you see "Pre-Q refuses name" or "Pre-Q accepts name" in the log?

To exclude Python problems, try something simpler first:

Code: Select all

#!/bin/sh
echo 0
jowi
Newbie
Newbie
Posts: 19
Joined: August 9th, 2012, 6:16 am

Re: Pre processing trouble

Post by jowi »

As you can see in the logging in the first post, sab says 'Pre-Q accepts <file>'...
The python enviroment works, i've build an extensive postprocessing using python, which is working nicely with sab & sickbeard.

How do i use your (bash?) sample? Does it needs some special extension, because i can only select .py files in sabnzb's pre-queue dropdown box...
*edit* nevermind, got it, had to chmod it a bit ;) now it shows up in the dropdown.
Last edited by jowi on August 9th, 2012, 9:56 am, edited 1 time in total.
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: Pre processing trouble

Post by shypike »

The essential bit is that you've done a "chmod +x" on your script.
No extension needed, any name will do.

Reviewing the code, I see a missed opportunity for better logging...
That's Murphy for you: the app is littered with logging, except in that one place
where you happen to need it :(
jowi
Newbie
Newbie
Posts: 19
Joined: August 9th, 2012, 6:16 am

Re: Pre processing trouble

Post by jowi »

;)

I tested the bash thingy, this time it crashes:

Code: Select all

2012-08-10 16:57:30,106::INFO::[newsunpack:1417] Running pre-queue script ['/mnt/cache/Apps/sabnzbd/scripts/pre2.sh', 'Breaking.Bad.S05E02.Madrigal.HDTV.x264-FQM', '', 'tvseries', '', '-100', '330523175', 'alt.binaries.multimedia alt.binaries.teevee', '', '', '', '']
2012-08-10 16:57:30,109::DEBUG::[newsunpack:1424] Failed script /mnt/cache/Apps/sabnzbd/scripts/pre2.sh, Traceback: 
Traceback (most recent call last):
  File "/mnt/cache/Apps/sabnzbd/sabnzbd/newsunpack.py", line 1422, in pre_queue
    startupinfo=stup, env=env, creationflags=creationflags)
  File "/usr/lib/python2.6/subprocess.py", line 623, in __init__
    errread, errwrite)
  File "/usr/lib/python2.6/subprocess.py", line 1141, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: Pre processing trouble

Post by shypike »

That may mean that the path /bin/sh is not correct.
Check what it is on your system.
jowi
Newbie
Newbie
Posts: 19
Joined: August 9th, 2012, 6:16 am

Re: Pre processing trouble

Post by jowi »

Will try to. I'm new at linux.
But the bash script does run from the command line...

*edit*

Code: Select all

root@Tower:/bin# ls -l sh
lrwxrwxrwx 1 root root 4 2012-06-21 00:54 sh -> bash
looks ok to me?
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: Pre processing trouble

Post by shypike »

It runs from the command prompt too?
jowi
Newbie
Newbie
Posts: 19
Joined: August 9th, 2012, 6:16 am

Re: Pre processing trouble

Post by jowi »

Yes it does.
jowi
Newbie
Newbie
Posts: 19
Joined: August 9th, 2012, 6:16 am

Re: Pre processing trouble

Post by jowi »

Anyone who knows what i'm doing wrong here?
Any tips or ideas? I'm running Sab 0.7.2 on an unRAID v5.0 server.
NoTolerance
Full Member
Full Member
Posts: 127
Joined: June 27th, 2012, 9:55 am

Re: Pre processing trouble

Post by NoTolerance »

Carriage returns maybe?

Run 'cat -vE pre.py' and look for '\r' in the output.
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: Pre processing trouble

Post by shypike »

Checked again on two Linux platforms: no issues.
It might be something in the Python implementation.
BTW: do you also use post-processing scripts and do they work?
jowi
Newbie
Newbie
Posts: 19
Joined: August 9th, 2012, 6:16 am

Re: Pre processing trouble

Post by jowi »

NoTolerance wrote:Carriage returns maybe?
Run 'cat -vE pre.py' and look for '\r' in the output.
Nope...

Code: Select all

#!/usr/bin/env python^M$
import sys^M$
print "0"^M$
exit(0)^M$
shypike wrote:BTW: do you also use post-processing scripts and do they work?
Yep... wrote them myself as well.
Post Reply