added safe_mode to prevent processing ALL downloads.

This commit is contained in:
clinton-hall 2014-05-27 15:48:52 +09:30
commit 07719e79b6
4 changed files with 35 additions and 3 deletions

View file

@ -109,6 +109,12 @@ def processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID,
logger.info("Output directory set to: %s" % (outputDestination))
if nzbtomedia.SAFE_MODE and outputDestination == nzbtomedia.TORRENT_DEFAULTDIR:
logger.error(
'The output directory:[%s] is the Download Directory. Edit outputDirectory in autoProcessMedia.cfg. Exiting' % (
inputDirectory))
return -1
if not "NONE" in nzbtomedia.USER_SCRIPT_CATEGORIES: # if None, we only process the 5 listed.
if "ALL" in nzbtomedia.USER_SCRIPT_CATEGORIES: # All defined categories
processOnly = nzbtomedia.CATEGORIES

View file

@ -24,6 +24,11 @@
# Enable/Disable media file checking using ffprobe.
#check_media=1
# Safe Mode protection of DestDir (0, 1).
#
# Enable/Disable a safety check to ensure we don't process all downloads in the default_downloadDirectory by mistake.
#safe_mode=1
## CouchPotato
# CouchPotato script category.
@ -309,6 +314,12 @@ from nzbtomedia import logger, nzbToMediaDB
# post-processing
def process(inputDirectory, inputName=None, status=0, clientAgent='manual', download_id=None, inputCategory=None):
if nzbtomedia.SAFE_MODE and inputDirectory == nzbtomedia.NZB_DEFAULTDIR:
logger.error(
'The input directory:[%s] is the Default Download Directory. Please configure category directories to prevent processing of other media.' % (
inputDirectory))
return -1
if clientAgent != 'manual' and not nzbtomedia.DOWNLOADINFO:
logger.debug('Adding NZB download info for directory %s to database' % (inputDirectory))

View file

@ -75,11 +75,13 @@ GIT_USER = None
GIT_BRANCH = None
GIT_REPO = None
FORCE_CLEAN = None
SAFE_MODE = None
NZB_CLIENTAGENT = None
SABNZBDHOST = None
SABNZBDPORT = None
SABNZBDAPIKEY = None
NZB_DEFAULTDIR = None
TORRENT_CLIENTAGENT = None
TORRENT_CLASS = None
@ -87,6 +89,7 @@ USELINK = None
OUTPUTDIRECTORY = None
NOFLATTEN = []
DELETE_ORIGINAL = None
TORRENT_DEFAULTDIR = None
UTORRENTWEBUI = None
UTORRENTUSR = None
@ -158,7 +161,8 @@ def initialize(section=None):
OUTPUTVIDEOBITRATE, OUTPUTAUDIOCODEC, OUTPUTAUDIOBITRATE, OUTPUTSUBTITLECODEC, OUTPUTFASTSTART, OUTPUTQUALITYPERCENT, \
NICENESS, LOG_DEBUG, FORCE_CLEAN, FFMPEG_PATH, FFMPEG, FFPROBE, AUDIOCONTAINER, EXTCONTAINER, TORRENT_CLASS, \
DELETE_ORIGINAL, PASSWORDSFILE, USER_DELAY, USER_SCRIPT, USER_SCRIPT_CLEAN, USER_SCRIPT_MEDIAEXTENSIONS, \
USER_SCRIPT_PARAM, USER_SCRIPT_RUNONCE, USER_SCRIPT_SUCCESSCODES, DOWNLOADINFO, EXT_REPLACE, CHECK_MEDIA
USER_SCRIPT_PARAM, USER_SCRIPT_RUNONCE, USER_SCRIPT_SUCCESSCODES, DOWNLOADINFO, EXT_REPLACE, CHECK_MEDIA, SAFE_MODE, \
TORRENT_DEFAULTDIR, NZB_DEFAULTDIR
if __INITIALIZED__:
return False
@ -228,6 +232,7 @@ def initialize(section=None):
FORCE_CLEAN = CFG["General"]["force_clean"]
FFMPEG_PATH = CFG["General"]["ffmpeg_path"]
CHECK_MEDIA = int(CFG["General"]["check_media"])
SAFE_MODE = int(CFG["General"]["safe_mode"])
# Check for updates via GitHUB
if versionCheck.CheckVersion().check_for_new_version():
@ -251,10 +256,12 @@ def initialize(section=None):
SABNZBDHOST = CFG["Nzb"]["sabnzbd_host"]
SABNZBDPORT = int(CFG["Nzb"]["sabnzbd_port"])
SABNZBDAPIKEY = CFG["Nzb"]["sabnzbd_apikey"]
NZB_DEFAULTDIR = int(CFG["Nzb"]["default_downloadDirectory"])
TORRENT_CLIENTAGENT = CFG["Torrent"]["clientAgent"] # utorrent | deluge | transmission | rtorrent | other
USELINK = CFG["Torrent"]["useLink"] # no | hard | sym
OUTPUTDIRECTORY = CFG["Torrent"]["outputDirectory"] # /abs/path/to/complete/
NZB_DEFAULTDIR = int(CFG["Torrent"]["default_downloadDirectory"])
CATEGORIES = (CFG["Torrent"]["categories"]) # music,music_videos,pictures,software
NOFLATTEN = (CFG["Torrent"]["noFlatten"])
if isinstance(NOFLATTEN, str): NOFLATTEN = NOFLATTEN.split(',')

View file

@ -229,10 +229,18 @@ class ConfigObj(configobj.ConfigObj, Section):
# load configs into memory
CFG_NEW = config()
try:
section = "Nzb"
key = 'NZBOP_DESTDIR'
if os.environ.has_key(key):
option = default_downloadDirectory
value = os.environ[key]
CFG_NEW[section][option] = value
try:
section = "General"
envKeys = ['AUTO_UPDATE', 'CHECK_MEDIA']
cfgKeys = ['auto_update', 'check_media']
envKeys = ['AUTO_UPDATE', 'CHECK_MEDIA', 'SAFE_MODE']
cfgKeys = ['auto_update', 'check_media', 'safe_mode']
for index in range(len(envKeys)):
key = 'NZBPO_' + envKeys[index]
if os.environ.has_key(key):