[Python Any reason for script not stopping?

Come up with a useful post-processing script? Share it here!
Post Reply
nock
Newbie
Newbie
Posts: 28
Joined: October 29th, 2014, 2:55 pm

[Python Any reason for script not stopping?

Post by nock »

Trying to learn some more Python. Does anyone see why this script is not exiting in SAB? It is running until i restart SAB manually. I did a equal script just with a lot of if, elif lines, that works.
Its a updating Plex script.

Code: Select all

#!/usr/bin/env python
 
import sys
import os
import urllib
 
try:
    (scriptname,directory,orgnzbname,jobname,reportnumber,category,group,postprocstatus,url) = sys.argv
except:
    try:
        # Category
        c = sys.argv[5]
    except:
        print"No commandline paramenter found"
        sys.exit(1)
#c = category
def update(x):
    ip = "IP:PORT"
    os.system("wget -q --delete-after http://%s/library/sections/%r/refresh > /dev/null" % (ip,x))  #for linux
    #urllib.urlopen("http://%s/library/sections/%r/refresh" % (ip,x)) # for windows
    sys.exit(0)
options = {
    'movieshd': 6,
    'comedy':5,
    'ufc':9,
    'documentary':7,
    'barnefilm':10,
    'skifilm':8,
}
holder = options[c]
update(holder)
User avatar
sander
Release Testers
Release Testers
Posts: 9062
Joined: January 22nd, 2008, 2:22 pm

Re: [Python Any reason for script not stopping?

Post by sander »

Run it from the command line, and show the full output here

Because this is what I get:

Code: Select all

$ python bla.py 1 2 3 4 5 6 7 8
Traceback (most recent call last):
  File "bla.py", line 35, in <module>
    holder = options[c]
NameError: name 'c' is not defined
So the script is not correct at all, and so little use to call it from SABnzbd.
nock
Newbie
Newbie
Posts: 28
Joined: October 29th, 2014, 2:55 pm

Re: [Python Any reason for script not stopping?

Post by nock »

I had to put c = "" on top of the script, and %s could not take in "ip:port" for some reason.. Had to use one variable for ip and one for port, and modify the os.system line: "%s:%s", and of course add at the end % (ip,port,x).
brightstar
Newbie
Newbie
Posts: 1
Joined: March 24th, 2015, 6:12 am

Re: [Python Any reason for script not stopping?

Post by brightstar »

I also agree with the "nock" that system line: "%s:%s", and of course add at the end % (ip,port,x). you should try it don't be ignore it best of luck....
Post Reply