mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-19 21:03:14 -07:00
Monkey Patched our config class.
Fixed code for enabled check. Tweaked a few things here and there.
This commit is contained in:
parent
cd0eb9a83a
commit
0ca0e43752
14 changed files with 72 additions and 82 deletions
|
@ -48,7 +48,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
|||
|
||||
Logger.debug("MAIN: Determined Directory: %s | Name: %s | Category: %s", inputDirectory, inputName, inputCategory)
|
||||
|
||||
if config.issubsection(inputCategory,["SickBeard","NzbDrone"]):
|
||||
if config().issubsection(inputCategory,["SickBeard","NzbDrone"]):
|
||||
Logger.info("MAIN: Calling autoProcessTV to post-process: %s",inputName)
|
||||
result = autoProcessTV().processEpisode(inputDirectory, inputName, 0, clientAgent=clientAgent, inputCategory=inputCategory)
|
||||
if result != 0:
|
||||
|
@ -128,8 +128,8 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
|||
|
||||
Logger.debug("MAIN: Scanning files in directory: %s", inputDirectory)
|
||||
|
||||
if config.issubsection(inputCategory, "HeadPhones"):
|
||||
noFlatten.extend(list(chain.from_iterable(config.get_subsections("HeadPhones")))) # Make sure we preserve folder structure for HeadPhones.
|
||||
if config().issubsection(inputCategory, "HeadPhones"):
|
||||
noFlatten.extend(list(chain.from_iterable(config().get_subsections("HeadPhones")))) # 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.
|
||||
now = datetime.datetime.now()
|
||||
|
@ -170,7 +170,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
|||
continue # This file has not been recently moved or created, skip it
|
||||
|
||||
if fileExtension in mediaContainer: # If the file is a video file
|
||||
if is_sample(filePath, inputName, minSampleSize, SampleIDs) and not config.issubsection(inputCategory, ["HeadPhones"]): # Ignore samples
|
||||
if is_sample(filePath, inputName, minSampleSize, SampleIDs) and not config().issubsection(inputCategory, ["HeadPhones"]): # Ignore samples
|
||||
Logger.info("MAIN: Ignoring sample file: %s ", filePath)
|
||||
continue
|
||||
else:
|
||||
|
@ -206,7 +206,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
|||
except:
|
||||
Logger.exception("MAIN: Extraction failed for: %s", file)
|
||||
continue
|
||||
elif not config.issubsection(inputCategory,['CouchPotato','SickBeard','NzbDrone']): #process all for non-video categories.
|
||||
elif not config().issubsection(inputCategory,['CouchPotato','SickBeard','NzbDrone']): #process all for non-video categories.
|
||||
Logger.info("MAIN: Found file %s for category %s", filePath, inputCategory)
|
||||
copy_link(filePath, targetDirectory, useLink, outputDestination)
|
||||
copy_list.append([filePath, os.path.join(outputDestination, file)])
|
||||
|
@ -220,7 +220,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
|||
flatten(outputDestination)
|
||||
|
||||
# Now check if video files exist in destination:
|
||||
if config.issubsection(inputCategory,["SickBeard","NzbDrone"]):
|
||||
if config().issubsection(inputCategory,["SickBeard","NzbDrone"]):
|
||||
for dirpath, dirnames, filenames in os.walk(outputDestination):
|
||||
for file in filenames:
|
||||
filePath = os.path.join(dirpath, file)
|
||||
|
@ -245,7 +245,7 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
|||
if (inputCategory in user_script_categories and not "NONE" in user_script_categories) or ("ALL" in user_script_categories and not inputCategory in processCategories):
|
||||
Logger.info("MAIN: Processing user script %s.", user_script)
|
||||
result = external_script(outputDestination,inputName,inputCategory)
|
||||
elif status == int(0) or (config.issubsection(inputCategory,['HeadPhones','Mylar','Gamez'])): # if movies linked/extracted or for other categories.
|
||||
elif status == int(0) or (config().issubsection(inputCategory,['HeadPhones','Mylar','Gamez'])): # if movies linked/extracted or for other categories.
|
||||
Logger.debug("MAIN: Calling autoProcess script for successful download.")
|
||||
status = int(0) # hp, my, gz don't support failed.
|
||||
else:
|
||||
|
@ -253,23 +253,23 @@ def main(inputDirectory, inputName, inputCategory, inputHash, inputID):
|
|||
sys.exit(-1)
|
||||
|
||||
result = 0
|
||||
if config.issubsection(inputCategory,['CouchPotato']):
|
||||
if config().issubsection(inputCategory,['CouchPotato']):
|
||||
Logger.info("MAIN: Calling CouchPotato:" + inputCategory + " to post-process: %s", inputName)
|
||||
download_id = inputHash
|
||||
result = autoProcessMovie().process(outputDestination, inputName, status, clientAgent, download_id, inputCategory)
|
||||
elif config.issubsection(inputCategory,['SickBeard']):
|
||||
elif config().issubsection(inputCategory,['SickBeard']):
|
||||
Logger.info("MAIN: Calling Sick-Beard:" + inputCategory + " to post-process: %s", inputName)
|
||||
result = autoProcessTV().processEpisode(outputDestination, inputName, status, clientAgent, inputCategory)
|
||||
elif config.issubsection(inputCategory,['NzbDrone']):
|
||||
elif config().issubsection(inputCategory,['NzbDrone']):
|
||||
Logger.info("MAIN: Calling NzbDrone:" + inputCategory + " to post-process: %s", inputName)
|
||||
result = autoProcessTV().processEpisode(outputDestination, inputName, status, clientAgent, inputCategory)
|
||||
elif config.issubsection(inputCategory,['HeadPhones']):
|
||||
elif config().issubsection(inputCategory,['HeadPhones']):
|
||||
Logger.info("MAIN: Calling HeadPhones:" + inputCategory + " to post-process: %s", inputName)
|
||||
result = autoProcessMusic().process(inputDirectory, inputName, status, clientAgent, inputCategory)
|
||||
elif config.issubsection(inputCategory,['Mylar']):
|
||||
elif config().issubsection(inputCategory,['Mylar']):
|
||||
Logger.info("MAIN: Calling Mylar:" + inputCategory + " to post-process: %s", inputName)
|
||||
result = autoProcessComics().processEpisode(outputDestination, inputName, status, clientAgent, inputCategory)
|
||||
elif config.issubsection(inputCategory,['Gamez']):
|
||||
elif config().issubsection(inputCategory,['Gamez']):
|
||||
Logger.info("MAIN: Calling Gamez:" + inputCategory + " to post-process: %s", inputName)
|
||||
result = autoProcessGames().process(outputDestination, inputName, status, clientAgent, inputCategory)
|
||||
|
||||
|
@ -393,7 +393,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 config.migrate():
|
||||
if config().migrate():
|
||||
nzbtomedia_configure_logging(config.LOG_FILE)
|
||||
Logger = logging.getLogger(__name__)
|
||||
Logger.info("====================") # Seperate old from new log
|
||||
|
@ -435,7 +435,7 @@ if __name__ == "__main__":
|
|||
minSampleSize = int(config()["Extensions"]["minSampleSize"]) # 200 (in MB)
|
||||
SampleIDs = (config()["Extensions"]["SampleIDs"]) # sample,-s.
|
||||
|
||||
subsections = config.get_subsections(["CouchPotato", "SickBeard", "NzbDrone", "HeadPhones", "Mylar", "Gamez"])
|
||||
subsections = config().get_subsections(["CouchPotato", "SickBeard", "NzbDrone", "HeadPhones", "Mylar", "Gamez"])
|
||||
categories += list(chain.from_iterable(subsections.values()))
|
||||
|
||||
user_script_categories = config()["UserScript"]["user_script_categories"] # NONE
|
||||
|
@ -465,7 +465,7 @@ if __name__ == "__main__":
|
|||
if inputDirectory is None:
|
||||
for section, subsection in subsections.iteritems():
|
||||
for category in subsection:
|
||||
if config.isenabled(section, category):
|
||||
if config().isenabled(section, category):
|
||||
dirNames = get_dirnames(section, category)
|
||||
Logger.info("MAIN: TorrentToMedia running %s:%s as a manual run...", section, category)
|
||||
for dirName in dirNames:
|
||||
|
|
|
@ -133,10 +133,10 @@ 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 config.migrate():
|
||||
if config().migrate():
|
||||
# check to write settings from nzbGet UI to autoProcessMedia.cfg.
|
||||
if os.environ.has_key('NZBOP_SCRIPTDIR'):
|
||||
config.addnzbget()
|
||||
config().addnzbget()
|
||||
|
||||
nzbtomedia_configure_logging(config.LOG_FILE)
|
||||
Logger = logging.getLogger(__name__)
|
||||
|
@ -233,12 +233,12 @@ else:
|
|||
result = 0
|
||||
|
||||
# init sub-sections
|
||||
subsections = config.get_subsections(["CouchPotato"])
|
||||
subsections = config().get_subsections(["CouchPotato"])
|
||||
|
||||
Logger.warn("MAIN: Invalid number of arguments received from client.")
|
||||
for section, subsection in subsections.items():
|
||||
for category in subsection:
|
||||
if config.isenabled(section, category):
|
||||
if config().isenabled(section, category):
|
||||
dirNames = get_dirnames(section, category)
|
||||
for dirName in dirNames:
|
||||
Logger.info("MAIN: nzbToCouchPotato running %s:%s as a manual run...", section, subsection)
|
||||
|
|
|
@ -68,10 +68,10 @@ 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 config.migrate():
|
||||
if config().migrate():
|
||||
# check to write settings from nzbGet UI to autoProcessMedia.cfg.
|
||||
if os.environ.has_key('NZBOP_SCRIPTDIR'):
|
||||
config.addnzbget()
|
||||
config().addnzbget()
|
||||
|
||||
nzbtomedia_configure_logging(config.LOG_FILE)
|
||||
Logger = logging.getLogger(__name__)
|
||||
|
@ -83,7 +83,7 @@ else:
|
|||
sys.exit(-1)
|
||||
|
||||
# gamez category
|
||||
sections = config.get_subsections(['Gamez'])
|
||||
sections = config().get_subsections(['Gamez'])
|
||||
|
||||
WakeUp()
|
||||
|
||||
|
@ -163,12 +163,12 @@ else:
|
|||
result = 0
|
||||
|
||||
# init sub-sections
|
||||
subsections = config.get_subsections(["Gamez"])
|
||||
subsections = config().get_subsections(["Gamez"])
|
||||
|
||||
Logger.warn("MAIN: Invalid number of arguments received from client.")
|
||||
for section, subsection in subsections.items():
|
||||
for category in subsection:
|
||||
if config.isenabled(section, category):
|
||||
if config().isenabled(section, category):
|
||||
dirNames = get_dirnames(section, category)
|
||||
for dirName in dirNames:
|
||||
Logger.info("MAIN: nzbToGamez running %s:%s as a manual run...", section, category)
|
||||
|
|
|
@ -81,10 +81,10 @@ 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 config.migrate():
|
||||
if config().migrate():
|
||||
# check to write settings from nzbGet UI to autoProcessMedia.cfg.
|
||||
if os.environ.has_key('NZBOP_SCRIPTDIR'):
|
||||
config.addnzbget()
|
||||
config().addnzbget()
|
||||
|
||||
nzbtomedia_configure_logging(config.LOG_FILE)
|
||||
Logger = logging.getLogger(__name__)
|
||||
|
@ -173,12 +173,12 @@ else:
|
|||
result = 0
|
||||
|
||||
# init sub-sections
|
||||
subsections = config.get_subsections(["HeadPhones"])
|
||||
subsections = config().get_subsections(["HeadPhones"])
|
||||
|
||||
Logger.warn("MAIN: Invalid number of arguments received from client.")
|
||||
for section, subsection in subsections.items():
|
||||
for category in subsection:
|
||||
if config.isenabled(section, category):
|
||||
if config().isenabled(section, category):
|
||||
dirNames = get_dirnames(section, category)
|
||||
for dirName in dirNames:
|
||||
Logger.info("MAIN: nzbToHeadPhones running %s:%s as a manual run...", section, category)
|
||||
|
|
|
@ -339,10 +339,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 config.migrate():
|
||||
if config().migrate():
|
||||
# check to write settings from nzbGet UI to autoProcessMedia.cfg.
|
||||
if os.environ.has_key('NZBOP_SCRIPTDIR'):
|
||||
config.addnzbget()
|
||||
config().addnzbget()
|
||||
|
||||
nzbtomedia_configure_logging(config.LOG_FILE)
|
||||
|
||||
|
@ -443,12 +443,12 @@ else:
|
|||
result = 0
|
||||
|
||||
# init sub-sections
|
||||
subsections = config.get_subsections(["CouchPotato", "SickBeard", "NzbDrone", "HeadPhones", "Mylar", "Gamez"])
|
||||
subsections = config().get_subsections(["CouchPotato", "SickBeard", "NzbDrone", "HeadPhones", "Mylar", "Gamez"])
|
||||
|
||||
Logger.warn("MAIN: Invalid number of arguments received from client.")
|
||||
for section, subsection in subsections.items():
|
||||
for category in subsection:
|
||||
if config.isenabled(section, category):
|
||||
if config().isenabled(section, category):
|
||||
dirNames = get_dirnames(section, category)
|
||||
for dirName in dirNames:
|
||||
Logger.info("MAIN: nzbToMedia running %s:%s as a manual run...", section, category)
|
||||
|
|
|
@ -73,10 +73,10 @@ 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 config.migrate():
|
||||
if config().migrate():
|
||||
# check to write settings from nzbGet UI to autoProcessMedia.cfg.
|
||||
if os.environ.has_key('NZBOP_SCRIPTDIR'):
|
||||
config.addnzbget()
|
||||
config().addnzbget()
|
||||
|
||||
nzbtomedia_configure_logging(config.LOG_FILE)
|
||||
Logger = logging.getLogger(__name__)
|
||||
|
@ -165,12 +165,12 @@ else:
|
|||
result = 0
|
||||
|
||||
# init sub-sections
|
||||
subsections = config.get_subsections(["Mylar"])
|
||||
subsections = config().get_subsections(["Mylar"])
|
||||
|
||||
Logger.warn("MAIN: Invalid number of arguments received from client.")
|
||||
for section, subsection in subsections.items():
|
||||
for category in subsection:
|
||||
if config.isenabled(section, category):
|
||||
if config().isenabled(section, category):
|
||||
dirNames = get_dirnames(section, category)
|
||||
for dirName in dirNames:
|
||||
Logger.info("MAIN: nzbToMylar running %s:%s as a manual run...", section, category)
|
||||
|
|
|
@ -102,10 +102,10 @@ 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 config.migrate():
|
||||
if config().migrate():
|
||||
# check to write settings from nzbGet UI to autoProcessMedia.cfg.
|
||||
if os.environ.has_key('NZBOP_SCRIPTDIR'):
|
||||
config.addnzbget()
|
||||
config().addnzbget()
|
||||
|
||||
nzbtomedia_configure_logging(config.LOG_FILE)
|
||||
Logger = logging.getLogger(__name__)
|
||||
|
@ -197,12 +197,12 @@ else:
|
|||
result = 0
|
||||
|
||||
# init sub-sections
|
||||
subsections = config.get_subsections(["NzbDrone"])
|
||||
subsections = config().get_subsections(["NzbDrone"])
|
||||
|
||||
Logger.warn("MAIN: Invalid number of arguments received from client.")
|
||||
for section, subsection in subsections.items():
|
||||
for category in subsection:
|
||||
if config.isenabled(section, category):
|
||||
if config().isenabled(section, category):
|
||||
dirNames = get_dirnames(section, category)
|
||||
for dirName in dirNames:
|
||||
Logger.info("MAIN: nzbToNzbDrone running %s:%s as a manual run...", section, category)
|
||||
|
|
|
@ -135,10 +135,10 @@ 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 config.migrate():
|
||||
if config().migrate():
|
||||
# check to write settings from nzbGet UI to autoProcessMedia.cfg.
|
||||
if os.environ.has_key('NZBOP_SCRIPTDIR'):
|
||||
config.addnzbget()
|
||||
config().addnzbget()
|
||||
|
||||
nzbtomedia_configure_logging(config.LOG_FILE)
|
||||
Logger = logging.getLogger(__name__)
|
||||
|
@ -230,12 +230,12 @@ else:
|
|||
result = 0
|
||||
|
||||
# init sub-sections
|
||||
subsections = config.get_subsections(["SickBeard"])
|
||||
subsections = config().get_subsections(["SickBeard"])
|
||||
|
||||
Logger.warn("MAIN: Invalid number of arguments received from client.")
|
||||
for section, subsection in subsections.items():
|
||||
for category in subsection:
|
||||
if config.isenabled(section,category):
|
||||
if config().isenabled(section,category):
|
||||
dirNames = get_dirnames(section, category)
|
||||
for dirName in dirNames:
|
||||
Logger.info("MAIN: nzbTo%s running %s:%s as a manual run...", section, section, category)
|
||||
|
|
|
@ -15,7 +15,7 @@ class autoProcessComics:
|
|||
return 1 # failure
|
||||
|
||||
# auto-detect correct section
|
||||
section = config.issubsection(inputCategory, checkenabled=True)[0]
|
||||
section = ''.join(map(str, config().issubsection(inputCategory, checkenabled=True)))
|
||||
if not section:
|
||||
Logger.error(
|
||||
"MAIN: We were unable to find a processor for category %s that was enabled, please check your autoProcessMedia.cfg file.", inputCategory)
|
||||
|
|
|
@ -14,7 +14,7 @@ class autoProcessGames:
|
|||
return 1 # failure
|
||||
|
||||
# auto-detect correct section
|
||||
section = config.issubsection(inputCategory, checkenabled=True)[0]
|
||||
section = ''.join(map(str, config().issubsection(inputCategory, checkenabled=True)))
|
||||
if not section:
|
||||
Logger.error(
|
||||
"MAIN: We were unable to find a processor for category %s that was enabled, please check your autoProcessMedia.cfg file.", inputCategory)
|
||||
|
|
|
@ -166,7 +166,7 @@ class autoProcessMovie:
|
|||
return 1 # failure
|
||||
|
||||
# auto-detect correct section
|
||||
section = config.issubsection(inputCategory, checkenabled=True)[0]
|
||||
section = ''.join(map(str, config().issubsection(inputCategory, checkenabled=True)))
|
||||
if not section:
|
||||
Logger.error(
|
||||
"MAIN: We were unable to find a processor for category %s that was enabled, please check your autoProcessMedia.cfg file.", inputCategory)
|
||||
|
|
|
@ -15,7 +15,7 @@ class autoProcessMusic:
|
|||
return 1 # failure
|
||||
|
||||
# auto-detect correct section
|
||||
section = config.issubsection(inputCategory,checkenabled=True)[0]
|
||||
section = config().issubsection(inputCategory,checkenabled=True)[0]
|
||||
if len(section) == 0:
|
||||
Logger.error(
|
||||
"MAIN: We were unable to find a processor for category %s that was enabled, please check your autoProcessMedia.cfg file.", inputCategory)
|
||||
|
|
|
@ -21,7 +21,7 @@ class autoProcessTV:
|
|||
return 1 # failure
|
||||
|
||||
# auto-detect correct section
|
||||
section = config.issubsection(inputCategory, checkenabled=True)[0]
|
||||
section = ''.join(map(str, config().issubsection(inputCategory, checkenabled=True)))
|
||||
if not section:
|
||||
Logger.error(
|
||||
"MAIN: We were unable to find a processor for category %s that was enabled, please check your autoProcessMedia.cfg file.", inputCategory)
|
||||
|
|
|
@ -12,9 +12,6 @@ class config(original_ConfigObj):
|
|||
super(lib.configobj.ConfigObj, self).__init__(*args, **kw)
|
||||
self.interpolation = False
|
||||
|
||||
def __call__(self, *args, **kwargs):
|
||||
print()
|
||||
|
||||
# constants for nzbtomedia
|
||||
NZBTOMEDIA_VERSION = 'V9.3'
|
||||
NZBTOMEDIA_TIMEOUT = 60
|
||||
|
@ -50,29 +47,26 @@ class config(original_ConfigObj):
|
|||
LOG_CONFIG = os.path.join(PROGRAM_DIR, "logging.cfg")
|
||||
SAMPLE_LOG_CONFIG = os.path.join(PROGRAM_DIR, "logging.cfg.sample")
|
||||
|
||||
|
||||
@staticmethod
|
||||
def issubsection(inputCategory, sections=None, checkenabled=False):
|
||||
def issubsection(self, inputCategory, sections=None, checkenabled=False):
|
||||
# checks if the inputCategory belongs to the section
|
||||
# or returns sections with subsections matching the inputCategoryu
|
||||
if not sections:
|
||||
sections = config.get_sections(inputCategory)
|
||||
sections = self.get_sections(inputCategory)
|
||||
|
||||
if not isinstance(sections, list):
|
||||
sections = [sections]
|
||||
|
||||
results = []
|
||||
for section in sections:
|
||||
if config()[section].has_key(inputCategory):
|
||||
if self[section].has_key(inputCategory):
|
||||
if checkenabled:
|
||||
if config.isenabled(section, inputCategory):
|
||||
if self.isenabled(section, inputCategory):
|
||||
results.append(section)
|
||||
else:
|
||||
results.append(section)
|
||||
return results if list(set(results).intersection(set(sections))) else False
|
||||
return results if list(set(results).intersection(set(sections))) else []
|
||||
|
||||
@staticmethod
|
||||
def get_sections(subsections):
|
||||
def get_sections(self, subsections):
|
||||
# finds all sections belonging to the subsection and returns them
|
||||
if not isinstance(subsections, list):
|
||||
subsections = [subsections]
|
||||
|
@ -80,51 +74,48 @@ class config(original_ConfigObj):
|
|||
to_return = []
|
||||
for subsection in subsections:
|
||||
for section in config().sections:
|
||||
if config()[section].has_key(subsection):
|
||||
if self[section].has_key(subsection):
|
||||
to_return.append(section)
|
||||
return to_return
|
||||
|
||||
@staticmethod
|
||||
def get_subsections(sections):
|
||||
def get_subsections(self, sections):
|
||||
# finds all subsections belonging to the section and returns them
|
||||
if not isinstance(sections, list):
|
||||
sections = [sections]
|
||||
|
||||
to_return = {}
|
||||
for section in sections:
|
||||
if section in config().sections:
|
||||
for subsection in config()[section].sections:
|
||||
if section in self.sections:
|
||||
for subsection in self[section].sections:
|
||||
if not isinstance(subsection, list):
|
||||
subsection = [subsection]
|
||||
to_return.update({section: subsection})
|
||||
return to_return
|
||||
|
||||
@staticmethod
|
||||
def isenabled(section, inputCategory):
|
||||
|
||||
def isenabled(self, section, inputCategory):
|
||||
# checks if the subsection is enabled/disabled
|
||||
if int(config()[section][inputCategory]['enabled']) == 1:
|
||||
if int(self[section][inputCategory]['enabled']) == 1:
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def search(key, section, subsection=None):
|
||||
def search(self, key, section, subsection=None):
|
||||
# searches for data in sections and subsections and returns it
|
||||
if subsection:
|
||||
if key in config()[section][subsection].keys():
|
||||
return config()[section][subsection][key]
|
||||
if key in self[section][subsection].keys():
|
||||
return self[section][subsection][key]
|
||||
else:
|
||||
if key in config()[section].keys():
|
||||
return config()[section][key]
|
||||
if key in self[section].keys():
|
||||
return self[section][key]
|
||||
|
||||
@staticmethod
|
||||
def migrate():
|
||||
def migrate(self):
|
||||
global config_new, config_old
|
||||
config_new = config_old = None
|
||||
|
||||
try:
|
||||
# check for autoProcessMedia.cfg and create if it does not exist
|
||||
if not config(config.CONFIG_FILE):
|
||||
if not config():
|
||||
shutil.copyfile(config.SAMPLE_CONFIG_FILE, config.CONFIG_FILE)
|
||||
config_old = config(config.CONFIG_FILE)
|
||||
config_old = config()
|
||||
except:
|
||||
pass
|
||||
|
||||
|
@ -243,8 +234,7 @@ class config(original_ConfigObj):
|
|||
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def addnzbget():
|
||||
def addnzbget(self):
|
||||
config_new = config()
|
||||
section = "CouchPotato"
|
||||
envCatKey = 'NZBPO_CPSCATEGORY'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue