Fixed issue with getDirs function

This commit is contained in:
echel0n 2014-04-25 02:46:04 -07:00
commit 5bd3a6ac9d
3 changed files with 16 additions and 17 deletions

View file

@ -312,10 +312,10 @@ def main(args):
# Perform Manual Post-Processing # Perform Manual Post-Processing
logger.warning("Invalid number of arguments received from client, Switching to manual run mode ...") logger.warning("Invalid number of arguments received from client, Switching to manual run mode ...")
for section, subsection in nzbtomedia.SECTIONS.items(): for section, subsections in nzbtomedia.SECTIONS.items():
for category in subsection: for subsection in subsections:
for dirName in nzbtomedia.getDirs(subsection[category]): for dirName in nzbtomedia.getDirs(section,subsection):
logger.info("Starting manual run for %s:%s - Folder:%s" % (section, category, dirName)) logger.info("Starting manual run for %s:%s - Folder:%s" % (section, subsection, dirName))
logger.info("Checking database for download info for %s ..." % (os.path.basename(dirName))) logger.info("Checking database for download info for %s ..." % (os.path.basename(dirName)))
downloadInfo = nzbtomedia.get_downloadInfo(os.path.basename(dirName), 0) downloadInfo = nzbtomedia.get_downloadInfo(os.path.basename(dirName), 0)
@ -344,11 +344,11 @@ def main(args):
if not clientAgent.lower() in (nzbtomedia.TORRENT_CLIENTS,'manual'): if not clientAgent.lower() in (nzbtomedia.TORRENT_CLIENTS,'manual'):
continue continue
results = processTorrent(dirName, os.path.basename(dirName), category, inputHash, inputID, results = processTorrent(dirName, os.path.basename(dirName), subsection, inputHash, inputID,
clientAgent) clientAgent)
if results != 0: if results != 0:
logger.error("A problem was reported when trying to perform a manual run for %s:%s." % ( logger.error("A problem was reported when trying to perform a manual run for %s:%s." % (
section, category)) section, subsection))
result = results result = results
if result == 0: if result == 0:

View file

@ -460,10 +460,10 @@ def main(args, section=None):
# Perform Manual Post-Processing # Perform Manual Post-Processing
logger.warning("Invalid number of arguments received from client, Switching to manual run mode ...") logger.warning("Invalid number of arguments received from client, Switching to manual run mode ...")
for section, subsection in nzbtomedia.SECTIONS.items(): for section, subsections in nzbtomedia.SECTIONS.items():
for category in subsection: for subsection in subsections:
for dirName in getDirs(subsection[category]): for dirName in getDirs(section, subsection):
logger.info("Starting manual run for %s:%s - Folder:%s" % (section, category, dirName)) logger.info("Starting manual run for %s:%s - Folder:%s" % (section, subsection, dirName))
logger.info("Checking database for download info for %s ..." % (os.path.basename(dirName))) logger.info("Checking database for download info for %s ..." % (os.path.basename(dirName)))
downloadInfo = get_downloadInfo(os.path.basename(dirName), 0) downloadInfo = get_downloadInfo(os.path.basename(dirName), 0)
@ -489,10 +489,10 @@ def main(args, section=None):
continue continue
results = process(dirName, os.path.basename(dirName), 0, clientAgent=clientAgent, results = process(dirName, os.path.basename(dirName), 0, clientAgent=clientAgent,
download_id=download_id, inputCategory=category) download_id=download_id, inputCategory=subsection)
if results != 0: if results != 0:
logger.error("A problem was reported when trying to perform a manual run for %s:%s." % ( logger.error("A problem was reported when trying to perform a manual run for %s:%s." % (
section, category)) section, subsection))
result = results result = results
if result == 0: if result == 0:

View file

@ -383,8 +383,7 @@ def parse_args(clientAgent, args):
return None, None, None, None, None return None, None, None, None, None
def getDirs(subsection): def getDirs(section, subsection):
subsectionName = subsection.keys()[0]
to_return = [] to_return = []
def processDir(path): def processDir(path):
@ -437,16 +436,16 @@ def getDirs(subsection):
os.path.isdir(os.path.join(path, o))]) os.path.isdir(os.path.join(path, o))])
return folders return folders
watch_dir = subsection["watch_dir"] watch_dir = nzbtomedia.CFG[section][subsection]["watch_dir"]
if os.path.exists(watch_dir): if os.path.exists(watch_dir):
to_return.extend(processDir(watch_dir)) to_return.extend(processDir(watch_dir))
outputDirectory = os.path.join(nzbtomedia.OUTPUTDIRECTORY, subsectionName) outputDirectory = os.path.join(nzbtomedia.OUTPUTDIRECTORY, subsection)
if os.path.exists(outputDirectory): if os.path.exists(outputDirectory):
to_return.extend(processDir(outputDirectory)) to_return.extend(processDir(outputDirectory))
if not to_return: if not to_return:
logger.debug("No directories identified in %s for post-processing" % (subsectionName)) logger.debug("No directories identified in %s:%s for post-processing" % (section,subsection))
return list(set(to_return)) return list(set(to_return))