Moved config migration code into our config class, makes more sense.

Added more detailed log messages for get_dirnames function.
This commit is contained in:
echel0n 2014-04-05 21:28:12 -07:00
commit 0ce4bb601d
10 changed files with 269 additions and 270 deletions

View file

@ -17,7 +17,6 @@ from nzbtomedia.autoProcess.autoProcessMovie import autoProcessMovie
from nzbtomedia.autoProcess.autoProcessMusic import autoProcessMusic
from nzbtomedia.autoProcess.autoProcessTV import autoProcessTV
from nzbtomedia.extractor import extractor
from nzbtomedia.migratecfg import migratecfg
from nzbtomedia.nzbToMediaAutoFork import autoFork
from nzbtomedia.nzbToMediaConfig import config
from nzbtomedia.nzbToMediaUtil import category_search, safeName, is_sample, copy_link, WakeUp, parse_args, flatten, \
@ -393,7 +392,7 @@ def external_script(outputDestination,torrentName,torrentLabel):
if __name__ == "__main__":
# run migrate to convert old cfg to new style cfg plus fix any cfg missing values/options.
if migratecfg().migrate():
if config.migrate():
nzbtomedia_configure_logging(config.LOG_FILE)
Logger = logging.getLogger(__name__)
Logger.info("====================") # Seperate old from new log

View file

@ -129,15 +129,14 @@ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'lib'
import logging
from nzbtomedia.autoProcess.autoProcessMovie import autoProcessMovie
from nzbtomedia.migratecfg import migratecfg
from nzbtomedia.nzbToMediaConfig import config
from nzbtomedia.nzbToMediaUtil import nzbtomedia_configure_logging, WakeUp, get_dirnames
# run migrate to convert old cfg to new style cfg plus fix any cfg missing values/options.
if migratecfg().migrate():
if config.migrate():
# check to write settings from nzbGet UI to autoProcessMedia.cfg.
if os.environ.has_key('NZBOP_SCRIPTDIR'):
migratecfg().addnzbget()
config.addnzbget()
nzbtomedia_configure_logging(config.LOG_FILE)
Logger = logging.getLogger(__name__)

View file

@ -64,15 +64,14 @@ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'lib'
##############################################################################
import logging
from nzbtomedia.autoProcess.autoProcessGames import autoProcessGames
from nzbtomedia.migratecfg import migratecfg
from nzbtomedia.nzbToMediaConfig import config
from nzbtomedia.nzbToMediaUtil import WakeUp, nzbtomedia_configure_logging, get_dirnames
# run migrate to convert old cfg to new style cfg plus fix any cfg missing values/options.
if migratecfg().migrate():
if config.migrate():
# check to write settings from nzbGet UI to autoProcessMedia.cfg.
if os.environ.has_key('NZBOP_SCRIPTDIR'):
migratecfg().addnzbget()
config.addnzbget()
nzbtomedia_configure_logging(config.LOG_FILE)
Logger = logging.getLogger(__name__)

View file

@ -77,15 +77,14 @@ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'lib'
# Exit codes used by NZBGet
import logging
from nzbtomedia.autoProcess.autoProcessMusic import autoProcessMusic
from nzbtomedia.migratecfg import migratecfg
from nzbtomedia.nzbToMediaConfig import config
from nzbtomedia.nzbToMediaUtil import get_dirnames, WakeUp, nzbtomedia_configure_logging
# run migrate to convert old cfg to new style cfg plus fix any cfg missing values/options.
if migratecfg().migrate():
if config.migrate():
# check to write settings from nzbGet UI to autoProcessMedia.cfg.
if os.environ.has_key('NZBOP_SCRIPTDIR'):
migratecfg().addnzbget()
config.addnzbget()
nzbtomedia_configure_logging(config.LOG_FILE)
Logger = logging.getLogger(__name__)

View file

@ -282,7 +282,6 @@ from nzbtomedia.autoProcess.autoProcessGames import autoProcessGames
from nzbtomedia.autoProcess.autoProcessMovie import autoProcessMovie
from nzbtomedia.autoProcess.autoProcessMusic import autoProcessMusic
from nzbtomedia.autoProcess.autoProcessTV import autoProcessTV
from nzbtomedia.migratecfg import migratecfg
from nzbtomedia.nzbToMediaConfig import config
from nzbtomedia.nzbToMediaUtil import nzbtomedia_configure_logging, WakeUp, get_dirnames
@ -345,10 +344,10 @@ def process(nzbDir, inputName=None, status=0, clientAgent='manual', download_id=
########################################################################################################################
# run migrate to convert old cfg to new style cfg plus fix any cfg missing values/options.
if migratecfg().migrate():
if config.migrate():
# check to write settings from nzbGet UI to autoProcessMedia.cfg.
if os.environ.has_key('NZBOP_SCRIPTDIR'):
migratecfg().addnzbget()
config.addnzbget()
nzbtomedia_configure_logging(config.LOG_FILE)

View file

@ -69,15 +69,14 @@ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'lib'
# Exit codes used by NZBGet
import logging
from nzbtomedia.autoProcess.autoProcessComics import autoProcessComics
from nzbtomedia.migratecfg import migratecfg
from nzbtomedia.nzbToMediaConfig import config
from nzbtomedia.nzbToMediaUtil import nzbtomedia_configure_logging, WakeUp, get_dirnames
# run migrate to convert old cfg to new style cfg plus fix any cfg missing values/options.
if migratecfg().migrate():
if config.migrate():
# check to write settings from nzbGet UI to autoProcessMedia.cfg.
if os.environ.has_key('NZBOP_SCRIPTDIR'):
migratecfg().addnzbget()
config.addnzbget()
nzbtomedia_configure_logging(config.LOG_FILE)
Logger = logging.getLogger(__name__)

View file

@ -131,15 +131,14 @@ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'lib'
##############################################################################
import logging
from nzbtomedia.autoProcess.autoProcessTV import autoProcessTV
from nzbtomedia.migratecfg import migratecfg
from nzbtomedia.nzbToMediaConfig import config
from nzbtomedia.nzbToMediaUtil import nzbtomedia_configure_logging, WakeUp, get_dirnames
# run migrate to convert old cfg to new style cfg plus fix any cfg missing values/options.
if migratecfg().migrate():
if config.migrate():
# check to write settings from nzbGet UI to autoProcessMedia.cfg.
if os.environ.has_key('NZBOP_SCRIPTDIR'):
migratecfg().addnzbget()
config.addnzbget()
nzbtomedia_configure_logging(config.LOG_FILE)
Logger = logging.getLogger(__name__)

View file

@ -1,241 +0,0 @@
import os
import shutil
from nzbtomedia.nzbToMediaConfig import config
from itertools import chain
class migratecfg:
def migrate(self):
categories = {}
confignew = None
configold = None
try:
# check for autoProcessMedia.cfg and create if it does not exist
if not config(config.CONFIG_FILE):
shutil.copyfile(config.SAMPLE_CONFIG_FILE, config.CONFIG_FILE)
configold = config(config.CONFIG_FILE)
except:pass
try:
# check for autoProcessMedia.cfg.sample and create if it does not exist
if not config(config.SAMPLE_CONFIG_FILE):
shutil.copyfile(config.CONFIG_FILE, config.SAMPLE_CONFIG_FILE)
confignew = config(config.SAMPLE_CONFIG_FILE)
except:pass
# check for autoProcessMedia.cfg and autoProcessMedia.cfg.sample and if they don't exist return and fail
if not config() and not config(config.SAMPLE_CONFIG_FILE) or not confignew or not configold:
return False
for section in configold.sections:
for option, value in configold[section].items():
if section == "CouchPotato":
if option == "category": # change this old format
option = "cpsCategory"
if section == "SickBeard":
if option == "category": # change this old format
option = "sbCategory"
if option in ["cpsCategory","sbCategory","hpCategory","mlCategory","gzCategory"]:
if not isinstance(value, list):
value = [value]
categories.update({section: value})
continue
try:
for section in configold.sections:
subsection = None
if section in list(chain.from_iterable(categories.values())):
subsection = section
section = ''.join([k for k, v in categories.iteritems() if subsection in v])
elif section in categories.keys():
subsection = categories[section][0]
# create subsection if it does not exist
if subsection and subsection not in confignew[section].sections:
confignew[section][subsection] = {}
for option, value in configold[section].items():
if section == "CouchPotato":
if option == "outputDirectory": # move this to new location format
value = os.path.split(os.path.normpath(value))[0]
confignew['Torrent'][option] = value
continue
if option in ["username", "password"]: # these are no-longer needed.
continue
if option in ["category","cpsCategory"]:
continue
if section == "SickBeard":
if option == "wait_for": # remove old format
continue
if option == "failed_fork": # change this old format
option = "fork"
value = "auto"
if option == "Torrent_ForceLink":
continue
if option == "outputDirectory": # move this to new location format
value = os.path.split(os.path.normpath(value))[0]
confignew['Torrent'][option] = value
continue
if option in ["category", "sbCategory"]:
continue
if section == "HeadPhones":
if option in ["username", "password" ]:
continue
if option == "hpCategory":
continue
if section == "Mylar":
if option in "mlCategory":
continue
if section == "Gamez":
if option in ["username", "password"]: # these are no-longer needed.
continue
if option == "gzCategory":
continue
if section == "Torrent":
if option in ["compressedExtensions", "mediaExtensions", "metaExtensions", "minSampleSize"]:
section = "Extensions" # these were moved
if option == "useLink": # Sym links supported now as well.
if isinstance(value, int):
num_value = int(value)
if num_value == 1:
value = "hard"
else:
value = "no"
if subsection:
confignew[section][subsection][option] = value
else:
confignew[section][option] = value
except:pass
# create a backup of our old config
if os.path.isfile(config.CONFIG_FILE):
cfgbak_name = config.CONFIG_FILE + ".old"
if os.path.isfile(cfgbak_name): # remove older backups
os.unlink(cfgbak_name)
os.rename(config.CONFIG_FILE, cfgbak_name)
# writing our configuration file to 'autoProcessMedia.cfg'
with open(config.CONFIG_FILE, 'wb') as configFile:
confignew.write(configFile)
return True
def addnzbget(self):
confignew = config()
section = "CouchPotato"
envCatKey = 'NZBPO_CPSCATEGORY'
envKeys = ['APIKEY', 'HOST', 'PORT', 'SSL', 'WEB_ROOT', 'DELAY', 'METHOD', 'DELETE_FAILED', 'REMOTECPS', 'WAIT_FOR', 'TIMEPERGIB']
cfgKeys = ['apikey', 'host', 'port', 'ssl', 'web_root', 'delay', 'method', 'delete_failed', 'remoteCPS', 'wait_for', 'TimePerGiB']
if os.environ.has_key(envCatKey):
for index in range(len(envKeys)):
key = 'NZBPO_CPS' + envKeys[index]
if os.environ.has_key(key):
option = cfgKeys[index]
value = os.environ[key]
if os.environ[envCatKey] not in confignew[section].sections:
confignew[section][os.environ[envCatKey]] = {}
confignew[section][os.environ[envCatKey]][option] = value
section = "SickBeard"
envCatKey = 'NZBPO_SBCATEGORY'
envKeys = ['HOST', 'PORT', 'USERNAME', 'PASSWORD', 'SSL', 'WEB_ROOT', 'WATCH_DIR', 'FORK', 'DELETE_FAILED', 'DELAY', 'TIMEPERGIB', 'PROCESS_METHOD']
cfgKeys = ['host', 'port', 'username', 'password', 'ssl', 'web_root', 'watch_dir', 'fork', 'delete_failed', 'delay', 'TimePerGiB', 'process_method']
if os.environ.has_key(envCatKey):
for index in range(len(envKeys)):
key = 'NZBPO_SB' + envKeys[index]
if os.environ.has_key(key):
option = cfgKeys[index]
value = os.environ[key]
if os.environ[envCatKey] not in confignew[section].sections:
confignew[section][os.environ[envCatKey]] = {}
confignew[section][os.environ[envCatKey]][option] = value
section = "HeadPhones"
envCatKey = 'NZBPO_HPCATEGORY'
envKeys = ['APIKEY', 'HOST', 'PORT', 'SSL', 'WEB_ROOT', 'DELAY', 'TIMEPERGIB']
cfgKeys = ['apikey', 'host', 'port', 'ssl', 'web_root', 'delay', 'TimePerGiB']
if os.environ.has_key(envCatKey):
for index in range(len(envKeys)):
key = 'NZBPO_HP' + envKeys[index]
if os.environ.has_key(key):
option = cfgKeys[index]
value = os.environ[key]
if os.environ[envCatKey] not in confignew[section].sections:
confignew[section][os.environ[envCatKey]] = {}
confignew[section][os.environ[envCatKey]][option] = value
section = "Mylar"
envCatKey = 'NZBPO_MYCATEGORY'
envKeys = ['HOST', 'PORT', 'USERNAME', 'PASSWORD', 'SSL', 'WEB_ROOT']
cfgKeys = ['host', 'port', 'username', 'password', 'ssl', 'web_root']
if os.environ.has_key(envCatKey):
for index in range(len(envKeys)):
key = 'NZBPO_MY' + envKeys[index]
if os.environ.has_key(key):
option = cfgKeys[index]
value = os.environ[key]
if os.environ[envCatKey] not in confignew[section].sections:
confignew[section][os.environ[envCatKey]] = {}
confignew[section][os.environ[envCatKey]][option] = value
section = "Gamez"
envCatKey = 'NZBPO_GZCATEGORY'
envKeys = ['APIKEY', 'HOST', 'PORT', 'SSL', 'WEB_ROOT']
cfgKeys = ['apikey', 'host', 'port', 'ssl', 'web_root']
if os.environ.has_key(envCatKey):
for index in range(len(envKeys)):
key = 'NZBPO_GZ' + envKeys[index]
if os.environ.has_key(key):
option = cfgKeys[index]
value = os.environ[key]
if os.environ[envCatKey] not in confignew[section].sections:
confignew[section][os.environ[envCatKey]] = {}
confignew[section][os.environ[envCatKey]][option] = value
section = "Extensions"
envKeys = ['COMPRESSEDEXTENSIONS', 'MEDIAEXTENSIONS', 'METAEXTENSIONS']
cfgKeys = ['compressedExtensions', 'mediaExtensions', 'metaExtensions']
for index in range(len(envKeys)):
key = 'NZBPO_' + envKeys[index]
if os.environ.has_key(key):
option = cfgKeys[index]
value = os.environ[key]
confignew[section][option] = value
section = "Transcoder"
envKeys = ['TRANSCODE', 'DUPLICATE', 'IGNOREEXTENSIONS', 'OUTPUTVIDEOEXTENSION', 'OUTPUTVIDEOCODEC', 'OUTPUTVIDEOPRESET', 'OUTPUTVIDEOFRAMERATE', 'OUTPUTVIDEOBITRATE', 'OUTPUTAUDIOCODEC', 'OUTPUTAUDIOBITRATE', 'OUTPUTSUBTITLECODEC']
cfgKeys = ['transcode', 'duplicate', 'ignoreExtensions', 'outputVideoExtension', 'outputVideoCodec', 'outputVideoPreset', 'outputVideoFramerate', 'outputVideoBitrate', 'outputAudioCodec', 'outputAudioBitrate', 'outputSubtitleCodec']
for index in range(len(envKeys)):
key = 'NZBPO_' + envKeys[index]
if os.environ.has_key(key):
option = cfgKeys[index]
value = os.environ[key]
confignew[section][option] = value
section = "WakeOnLan"
envKeys = ['WAKE', 'HOST', 'PORT', 'MAC']
cfgKeys = ['wake', 'host', 'port', 'mac']
for index in range(len(envKeys)):
key = 'NZBPO_WOL' + envKeys[index]
if os.environ.has_key(key):
option = cfgKeys[index]
value = os.environ[key]
confignew[section][option] = value
# create a backup of our old config
if os.path.isfile(config.CONFIG_FILE):
cfgbak_name = config.CONFIG_FILE + ".old"
if os.path.isfile(cfgbak_name): # remove older backups
os.unlink(cfgbak_name)
os.rename(config.CONFIG_FILE, cfgbak_name)
# writing our configuration file to 'autoProcessMedia.cfg'
with open(config.CONFIG_FILE, 'wb') as configFile:
confignew.write(configFile)

View file

@ -1,4 +1,6 @@
import os
import shutil
from itertools import chain
from lib import configobj
class config(object):
@ -57,4 +59,242 @@ class config(object):
for x in section:
if config().has_key(x):
sections.update({x: config()[x].sections})
return sections
return sections
@staticmethod
def migrate():
categories = {}
confignew = None
configold = None
try:
# check for autoProcessMedia.cfg and create if it does not exist
if not config(config.CONFIG_FILE):
shutil.copyfile(config.SAMPLE_CONFIG_FILE, config.CONFIG_FILE)
configold = config(config.CONFIG_FILE)
except:pass
try:
# check for autoProcessMedia.cfg.sample and create if it does not exist
if not config(config.SAMPLE_CONFIG_FILE):
shutil.copyfile(config.CONFIG_FILE, config.SAMPLE_CONFIG_FILE)
confignew = config(config.SAMPLE_CONFIG_FILE)
except:pass
# check for autoProcessMedia.cfg and autoProcessMedia.cfg.sample and if they don't exist return and fail
if not config() and not config(config.SAMPLE_CONFIG_FILE) or not confignew or not configold:
return False
for section in configold.sections:
for option, value in configold[section].items():
if section == "CouchPotato":
if option == "category": # change this old format
option = "cpsCategory"
if section == "SickBeard":
if option == "category": # change this old format
option = "sbCategory"
if option in ["cpsCategory","sbCategory","hpCategory","mlCategory","gzCategory"]:
if not isinstance(value, list):
value = [value]
categories.update({section: value})
continue
try:
for section in configold.sections:
subsection = None
if section in list(chain.from_iterable(categories.values())):
subsection = section
section = ''.join([k for k, v in categories.iteritems() if subsection in v])
elif section in categories.keys():
subsection = categories[section][0]
# create subsection if it does not exist
if subsection and subsection not in confignew[section].sections:
confignew[section][subsection] = {}
for option, value in configold[section].items():
if section == "CouchPotato":
if option == "outputDirectory": # move this to new location format
value = os.path.split(os.path.normpath(value))[0]
confignew['Torrent'][option] = value
continue
if option in ["username", "password"]: # these are no-longer needed.
continue
if option in ["category","cpsCategory"]:
continue
if section == "SickBeard":
if option == "wait_for": # remove old format
continue
if option == "failed_fork": # change this old format
option = "fork"
value = "auto"
if option == "Torrent_ForceLink":
continue
if option == "outputDirectory": # move this to new location format
value = os.path.split(os.path.normpath(value))[0]
confignew['Torrent'][option] = value
continue
if option in ["category", "sbCategory"]:
continue
if section == "HeadPhones":
if option in ["username", "password" ]:
continue
if option == "hpCategory":
continue
if section == "Mylar":
if option in "mlCategory":
continue
if section == "Gamez":
if option in ["username", "password"]: # these are no-longer needed.
continue
if option == "gzCategory":
continue
if section == "Torrent":
if option in ["compressedExtensions", "mediaExtensions", "metaExtensions", "minSampleSize"]:
section = "Extensions" # these were moved
if option == "useLink": # Sym links supported now as well.
if isinstance(value, int):
num_value = int(value)
if num_value == 1:
value = "hard"
else:
value = "no"
if subsection:
confignew[section][subsection][option] = value
else:
confignew[section][option] = value
except:pass
# create a backup of our old config
if os.path.isfile(config.CONFIG_FILE):
cfgbak_name = config.CONFIG_FILE + ".old"
if os.path.isfile(cfgbak_name): # remove older backups
os.unlink(cfgbak_name)
os.rename(config.CONFIG_FILE, cfgbak_name)
# writing our configuration file to 'autoProcessMedia.cfg'
with open(config.CONFIG_FILE, 'wb') as configFile:
confignew.write(configFile)
return True
@staticmethod
def addnzbget():
confignew = config()
section = "CouchPotato"
envCatKey = 'NZBPO_CPSCATEGORY'
envKeys = ['APIKEY', 'HOST', 'PORT', 'SSL', 'WEB_ROOT', 'DELAY', 'METHOD', 'DELETE_FAILED', 'REMOTECPS', 'WAIT_FOR', 'TIMEPERGIB']
cfgKeys = ['apikey', 'host', 'port', 'ssl', 'web_root', 'delay', 'method', 'delete_failed', 'remoteCPS', 'wait_for', 'TimePerGiB']
if os.environ.has_key(envCatKey):
for index in range(len(envKeys)):
key = 'NZBPO_CPS' + envKeys[index]
if os.environ.has_key(key):
option = cfgKeys[index]
value = os.environ[key]
if os.environ[envCatKey] not in confignew[section].sections:
confignew[section][os.environ[envCatKey]] = {}
confignew[section][os.environ[envCatKey]][option] = value
section = "SickBeard"
envCatKey = 'NZBPO_SBCATEGORY'
envKeys = ['HOST', 'PORT', 'USERNAME', 'PASSWORD', 'SSL', 'WEB_ROOT', 'WATCH_DIR', 'FORK', 'DELETE_FAILED', 'DELAY', 'TIMEPERGIB', 'PROCESS_METHOD']
cfgKeys = ['host', 'port', 'username', 'password', 'ssl', 'web_root', 'watch_dir', 'fork', 'delete_failed', 'delay', 'TimePerGiB', 'process_method']
if os.environ.has_key(envCatKey):
for index in range(len(envKeys)):
key = 'NZBPO_SB' + envKeys[index]
if os.environ.has_key(key):
option = cfgKeys[index]
value = os.environ[key]
if os.environ[envCatKey] not in confignew[section].sections:
confignew[section][os.environ[envCatKey]] = {}
confignew[section][os.environ[envCatKey]][option] = value
section = "HeadPhones"
envCatKey = 'NZBPO_HPCATEGORY'
envKeys = ['APIKEY', 'HOST', 'PORT', 'SSL', 'WEB_ROOT', 'DELAY', 'TIMEPERGIB']
cfgKeys = ['apikey', 'host', 'port', 'ssl', 'web_root', 'delay', 'TimePerGiB']
if os.environ.has_key(envCatKey):
for index in range(len(envKeys)):
key = 'NZBPO_HP' + envKeys[index]
if os.environ.has_key(key):
option = cfgKeys[index]
value = os.environ[key]
if os.environ[envCatKey] not in confignew[section].sections:
confignew[section][os.environ[envCatKey]] = {}
confignew[section][os.environ[envCatKey]][option] = value
section = "Mylar"
envCatKey = 'NZBPO_MYCATEGORY'
envKeys = ['HOST', 'PORT', 'USERNAME', 'PASSWORD', 'SSL', 'WEB_ROOT']
cfgKeys = ['host', 'port', 'username', 'password', 'ssl', 'web_root']
if os.environ.has_key(envCatKey):
for index in range(len(envKeys)):
key = 'NZBPO_MY' + envKeys[index]
if os.environ.has_key(key):
option = cfgKeys[index]
value = os.environ[key]
if os.environ[envCatKey] not in confignew[section].sections:
confignew[section][os.environ[envCatKey]] = {}
confignew[section][os.environ[envCatKey]][option] = value
section = "Gamez"
envCatKey = 'NZBPO_GZCATEGORY'
envKeys = ['APIKEY', 'HOST', 'PORT', 'SSL', 'WEB_ROOT']
cfgKeys = ['apikey', 'host', 'port', 'ssl', 'web_root']
if os.environ.has_key(envCatKey):
for index in range(len(envKeys)):
key = 'NZBPO_GZ' + envKeys[index]
if os.environ.has_key(key):
option = cfgKeys[index]
value = os.environ[key]
if os.environ[envCatKey] not in confignew[section].sections:
confignew[section][os.environ[envCatKey]] = {}
confignew[section][os.environ[envCatKey]][option] = value
section = "Extensions"
envKeys = ['COMPRESSEDEXTENSIONS', 'MEDIAEXTENSIONS', 'METAEXTENSIONS']
cfgKeys = ['compressedExtensions', 'mediaExtensions', 'metaExtensions']
for index in range(len(envKeys)):
key = 'NZBPO_' + envKeys[index]
if os.environ.has_key(key):
option = cfgKeys[index]
value = os.environ[key]
confignew[section][option] = value
section = "Transcoder"
envKeys = ['TRANSCODE', 'DUPLICATE', 'IGNOREEXTENSIONS', 'OUTPUTVIDEOEXTENSION', 'OUTPUTVIDEOCODEC', 'OUTPUTVIDEOPRESET', 'OUTPUTVIDEOFRAMERATE', 'OUTPUTVIDEOBITRATE', 'OUTPUTAUDIOCODEC', 'OUTPUTAUDIOBITRATE', 'OUTPUTSUBTITLECODEC']
cfgKeys = ['transcode', 'duplicate', 'ignoreExtensions', 'outputVideoExtension', 'outputVideoCodec', 'outputVideoPreset', 'outputVideoFramerate', 'outputVideoBitrate', 'outputAudioCodec', 'outputAudioBitrate', 'outputSubtitleCodec']
for index in range(len(envKeys)):
key = 'NZBPO_' + envKeys[index]
if os.environ.has_key(key):
option = cfgKeys[index]
value = os.environ[key]
confignew[section][option] = value
section = "WakeOnLan"
envKeys = ['WAKE', 'HOST', 'PORT', 'MAC']
cfgKeys = ['wake', 'host', 'port', 'mac']
for index in range(len(envKeys)):
key = 'NZBPO_WOL' + envKeys[index]
if os.environ.has_key(key):
option = cfgKeys[index]
value = os.environ[key]
confignew[section][option] = value
# create a backup of our old config
if os.path.isfile(config.CONFIG_FILE):
cfgbak_name = config.CONFIG_FILE + ".old"
if os.path.isfile(cfgbak_name): # remove older backups
os.unlink(cfgbak_name)
os.rename(config.CONFIG_FILE, cfgbak_name)
# writing our configuration file to 'autoProcessMedia.cfg'
with open(config.CONFIG_FILE, 'wb') as configFile:
confignew.write(configFile)

View file

@ -452,31 +452,38 @@ def parse_args(clientAgent):
return clients[clientAgent](sys.argv)
def get_dirnames(section, inputCategory):
dirNames = []
try:
watch_dir = config()[section][inputCategory]["watch_dir"]
if not os.path.exists(watch_dir):
watch_dir = ""
except:
watch_dir = ""
try:
outputDirectory = os.path.join(config()["Torrent"]["outputDirectory"], inputCategory)
if not os.path.exists(watch_dir):
outputDirectory = ""
except:
outputDirectory = ""
# set dirName
dirNames = []
if watch_dir != "":
if os.path.exists(watch_dir):
dirNames.extend([os.path.join(watch_dir, o) for o in os.listdir(watch_dir) if
os.path.isdir(os.path.join(watch_dir, o))])
dirNames.extend([os.path.join(watch_dir, o) for o in os.listdir(watch_dir) if
os.path.isdir(os.path.join(watch_dir, o))])
if not dirNames:
Logger.warn("No Directories identified to Scan inside " + watch_dir)
if outputDirectory != "":
if os.path.exists(outputDirectory):
dirNames.extend([os.path.join(outputDirectory, o) for o in os.listdir(outputDirectory) if
os.path.isdir(os.path.join(outputDirectory, o))])
dirNames.extend([os.path.join(outputDirectory, o) for o in os.listdir(outputDirectory) if
os.path.isdir(os.path.join(outputDirectory, o))])
if not dirNames:
Logger.warn("No Directories identified to Scan inside " + outputDirectory)
if watch_dir == "" and outputDirectory == "":
Logger.warn("No watch_dir or outputDirectory setup to be Scanned, go fix you autoProcessMedia.cfg file.")
return dirNames
def delete(dirName):