Fixed missing imports

This commit is contained in:
echel0n 2014-04-03 23:14:35 -07:00
parent 2c4b260440
commit 8c430908b4
9 changed files with 34 additions and 51 deletions

View file

@ -1,6 +1,10 @@
#!/usr/bin/env python #!/usr/bin/env python
# adds lib directory to system path # adds lib directory to system path
import os
import sys
from nzbtomedia.nzbToMediaConfig import config
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'lib'))) sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'lib')))
# #
@ -33,14 +37,6 @@ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'lib'
### NZBGET POST-PROCESSING SCRIPT ### ### NZBGET POST-PROCESSING SCRIPT ###
############################################################################## ##############################################################################
import os
import sys
# NZBGet argv: all passed as environment variables.
# Exit codes used by NZBGet
POSTPROCESS_SUCCESS=93
POSTPROCESS_ERROR=94
POSTPROCESS_NONE=95
def is_sample(filePath, inputName, maxSampleSize, SampleIDs): def is_sample(filePath, inputName, maxSampleSize, SampleIDs):
# 200 MB in bytes # 200 MB in bytes
@ -66,13 +62,13 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5
if os.environ['NZBOP_UNPACK'] != 'yes': if os.environ['NZBOP_UNPACK'] != 'yes':
print "Please enable option \"Unpack\" in nzbget configuration file, exiting." print "Please enable option \"Unpack\" in nzbget configuration file, exiting."
sys.exit(POSTPROCESS_ERROR) sys.exit(config().POSTPROCESS_ERROR)
# Check par status # Check par status
if os.environ['NZBPP_PARSTATUS'] == '3': if os.environ['NZBPP_PARSTATUS'] == '3':
print "Par-check successful, but Par-repair disabled, exiting." print "Par-check successful, but Par-repair disabled, exiting."
print "Please check your Par-repair settings for future downloads." print "Please check your Par-repair settings for future downloads."
sys.exit(POSTPROCESS_NONE) sys.exit(config().POSTPROCESS_NONE)
if os.environ['NZBPP_PARSTATUS'] == '1' or os.environ['NZBPP_PARSTATUS'] == '4': if os.environ['NZBPP_PARSTATUS'] == '1' or os.environ['NZBPP_PARSTATUS'] == '4':
print "Par-repair failed, setting status \"failed\"." print "Par-repair failed, setting status \"failed\"."
@ -103,7 +99,7 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5
# All checks done, now launching the script. # All checks done, now launching the script.
if status == 1: if status == 1:
sys.exit(POSTPROCESS_NONE) sys.exit(config().POSTPROCESS_NONE)
mediaContainer = os.environ['NZBPO_MEDIAEXTENSIONS'].split(',') mediaContainer = os.environ['NZBPO_MEDIAEXTENSIONS'].split(',')
SampleIDs = os.environ['NZBPO_SAMPLEIDS'].split(',') SampleIDs = os.environ['NZBPO_SAMPLEIDS'].split(',')
@ -120,8 +116,8 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5
os.unlink(filePath) os.unlink(filePath)
except: except:
print "Error: unable to delete file", filePath print "Error: unable to delete file", filePath
sys.exit(POSTPROCESS_ERROR) sys.exit(config().POSTPROCESS_ERROR)
sys.exit(POSTPROCESS_SUCCESS) sys.exit(config().POSTPROCESS_SUCCESS)
else: else:
print "This script can only be called from NZBGet (11.0 or later)." print "This script can only be called from NZBGet (11.0 or later)."

View file

@ -1,8 +1,12 @@
#!/usr/bin/env python #!/usr/bin/env python
# adds lib directory to system path # adds lib directory to system path
import os
import sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'lib'))) sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'lib')))
from nzbtomedia.nzbToMediaConfig import config
# #
############################################################################## ##############################################################################
### NZBGET POST-PROCESSING SCRIPT ### ### NZBGET POST-PROCESSING SCRIPT ###
@ -17,17 +21,6 @@ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'lib'
### NZBGET POST-PROCESSING SCRIPT ### ### NZBGET POST-PROCESSING SCRIPT ###
############################################################################## ##############################################################################
# NZBGet V11+
# Check if the script is called from nzbget 11.0 or later
import os
import sys
# NZBGet argv: all passed as environment variables.
# Exit codes used by NZBGet
POSTPROCESS_SUCCESS=93
POSTPROCESS_ERROR=94
POSTPROCESS_NONE=95
if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5] < '11.0': if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5] < '11.0':
print "Script triggered from NZBGet (11.0 or later)." print "Script triggered from NZBGet (11.0 or later)."
@ -36,13 +29,13 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5
if os.environ['NZBOP_UNPACK'] != 'yes': if os.environ['NZBOP_UNPACK'] != 'yes':
print "Please enable option \"Unpack\" in nzbget configuration file, exiting." print "Please enable option \"Unpack\" in nzbget configuration file, exiting."
sys.exit(POSTPROCESS_ERROR) sys.exit(config().POSTPROCESS_ERROR)
# Check par status # Check par status
if os.environ['NZBPP_PARSTATUS'] == '3': if os.environ['NZBPP_PARSTATUS'] == '3':
print "Par-check successful, but Par-repair disabled, exiting." print "Par-check successful, but Par-repair disabled, exiting."
print "Please check your Par-repair settings for future downloads." print "Please check your Par-repair settings for future downloads."
sys.exit(POSTPROCESS_NONE) sys.exit(config().POSTPROCESS_NONE)
if os.environ['NZBPP_PARSTATUS'] == '1' or os.environ['NZBPP_PARSTATUS'] == '4': if os.environ['NZBPP_PARSTATUS'] == '1' or os.environ['NZBPP_PARSTATUS'] == '4':
print "Par-repair failed, setting status \"failed\"." print "Par-repair failed, setting status \"failed\"."
@ -73,7 +66,7 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5
# All checks done, now launching the script. # All checks done, now launching the script.
if status == 1: if status == 1:
sys.exit(POSTPROCESS_NONE) sys.exit(config().POSTPROCESS_NONE)
directory = os.path.normpath(os.environ['NZBPP_DIRECTORY']) directory = os.path.normpath(os.environ['NZBPP_DIRECTORY'])
for dirpath, dirnames, filenames in os.walk(directory): for dirpath, dirnames, filenames in os.walk(directory):
@ -85,8 +78,8 @@ if os.environ.has_key('NZBOP_SCRIPTDIR') and not os.environ['NZBOP_VERSION'][0:5
continue continue
except: except:
print "Error: unable to reset time for file", file print "Error: unable to reset time for file", file
sys.exit(POSTPROCESS_ERROR) sys.exit(config().POSTPROCESS_ERROR)
sys.exit(POSTPROCESS_SUCCESS) sys.exit(config().POSTPROCESS_SUCCESS)
else: else:
print "This script can only be called from NZBGet (11.0 or later)." print "This script can only be called from NZBGet (11.0 or later)."

View file

@ -1,14 +1,13 @@
#!/usr/bin/env python #!/usr/bin/env python
# adds lib directory to system path # adds lib directory to system path
import os
import sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'lib'))) sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'lib')))
import datetime import datetime
import time import time
import logging import logging
import os
import re import re
import sys
import shutil import shutil
from subprocess import Popen from subprocess import Popen
from nzbtomedia.autoProcess.autoProcessComics import autoProcessComics from nzbtomedia.autoProcess.autoProcessComics import autoProcessComics
@ -26,7 +25,6 @@ from nzbtomedia.synchronousdeluge.client import DelugeClient
from nzbtomedia.utorrent.client import UTorrentClient from nzbtomedia.utorrent.client import UTorrentClient
from nzbtomedia.transmissionrpc.client import Client as TransmissionClient from nzbtomedia.transmissionrpc.client import Client as TransmissionClient
def main(inputDirectory, inputName, inputCategory, inputHash, inputID): def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
status = int(1) # 1 = failed | 0 = success status = int(1) # 1 = failed | 0 = success
@ -145,7 +143,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
Logger.debug("MAIN: Scanning files in directory: %s", inputDirectory) Logger.debug("MAIN: Scanning files in directory: %s", inputDirectory)
noFlatten.extend(hpCategory) # Make sure we preserve folder structure for HeadPhones. noFlatten.extend(hpCategory) # Make sure we preserve folder structure for HeadPhones.
outputDestinationMaster = outputDestination # Save the original, so we can change this within the loop below, and reset afterwards. outputDestinationMaster = outputDestination # Save the original, so we can change this within the loop below, and reset afterwards.
now = datetime.datetime.now() now = datetime.datetime.now()
for dirpath, dirnames, filenames in os.walk(inputDirectory): for dirpath, dirnames, filenames in os.walk(inputDirectory):
@ -236,7 +234,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
flatten(outputDestination) flatten(outputDestination)
# Now check if movie files exist in destination: # Now check if movie files exist in destination:
if inputCategory in cpsCategory + sbCategory: if inputCategory in cpsCategory + sbCategory:
for dirpath, dirnames, filenames in os.walk(outputDestination): for dirpath, dirnames, filenames in os.walk(outputDestination):
for file in filenames: for file in filenames:
filePath = os.path.join(dirpath, file) filePath = os.path.join(dirpath, file)

View file

@ -1,6 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python
# adds lib directory to system path # adds lib directory to system path
import os
import sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'lib'))) sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'lib')))
# #
@ -126,8 +128,6 @@ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'lib'
############################################################################## ##############################################################################
import logging import logging
import os
import sys
from nzbtomedia.autoProcess.autoProcessMovie import autoProcessMovie from nzbtomedia.autoProcess.autoProcessMovie import autoProcessMovie
from nzbtomedia.migratecfg import migratecfg from nzbtomedia.migratecfg import migratecfg
from nzbtomedia.nzbToMediaConfig import config from nzbtomedia.nzbToMediaConfig import config

View file

@ -1,6 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python
# adds lib directory to system path # adds lib directory to system path
import os
import sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'lib'))) sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'lib')))
# #
@ -60,12 +62,7 @@ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'lib'
### NZBGET POST-PROCESSING SCRIPT ### ### NZBGET POST-PROCESSING SCRIPT ###
############################################################################## ##############################################################################
# Exit codes used by NZBGet
import logging import logging
import os
import sys
from nzbtomedia.autoProcess.autoProcessGames import autoProcessGames from nzbtomedia.autoProcess.autoProcessGames import autoProcessGames
from nzbtomedia.migratecfg import migratecfg from nzbtomedia.migratecfg import migratecfg
from nzbtomedia.nzbToMediaConfig import config from nzbtomedia.nzbToMediaConfig import config

View file

@ -1,6 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python
# adds lib directory to system path # adds lib directory to system path
import os
import sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'lib'))) sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'lib')))
# #
@ -73,8 +75,6 @@ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'lib'
# NZBGet argv: all passed as environment variables. # NZBGet argv: all passed as environment variables.
# Exit codes used by NZBGet # Exit codes used by NZBGet
import os
import sys
import logging import logging
from nzbtomedia.autoProcess.autoProcessMusic import autoProcessMusic from nzbtomedia.autoProcess.autoProcessMusic import autoProcessMusic
from nzbtomedia.migratecfg import migratecfg from nzbtomedia.migratecfg import migratecfg

View file

@ -1,6 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python
# adds lib directory to system path # adds lib directory to system path
import os
import sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'lib'))) sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'lib')))
# #
@ -274,9 +276,6 @@ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'lib'
### NZBGET POST-PROCESSING SCRIPT ### ### NZBGET POST-PROCESSING SCRIPT ###
############################################################################## ##############################################################################
import os
import sys
import logging import logging
from nzbtomedia.autoProcess.autoProcessComics import autoProcessComics from nzbtomedia.autoProcess.autoProcessComics import autoProcessComics
from nzbtomedia.autoProcess.autoProcessGames import autoProcessGames from nzbtomedia.autoProcess.autoProcessGames import autoProcessGames

View file

@ -1,6 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python
# adds lib directory to system path # adds lib directory to system path
import os
import sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'lib'))) sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'lib')))
# #
@ -66,8 +68,6 @@ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'lib'
# Exit codes used by NZBGet # Exit codes used by NZBGet
import logging import logging
import os
import sys
from nzbtomedia.autoProcess.autoProcessComics import autoProcessComics from nzbtomedia.autoProcess.autoProcessComics import autoProcessComics
from nzbtomedia.migratecfg import migratecfg from nzbtomedia.migratecfg import migratecfg
from nzbtomedia.nzbToMediaConfig import config from nzbtomedia.nzbToMediaConfig import config

View file

@ -1,6 +1,8 @@
#!/usr/bin/env python #!/usr/bin/env python
# adds lib directory to system path # adds lib directory to system path
import os
import sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'lib'))) sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'lib')))
# #
@ -127,8 +129,6 @@ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'lib'
### NZBGET POST-PROCESSING SCRIPT ### ### NZBGET POST-PROCESSING SCRIPT ###
############################################################################## ##############################################################################
import os
import sys
import logging import logging
from nzbtomedia.autoProcess.autoProcessTV import autoProcessTV from nzbtomedia.autoProcess.autoProcessTV import autoProcessTV
from nzbtomedia.migratecfg import migratecfg from nzbtomedia.migratecfg import migratecfg