mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-14 18:47:09 -07:00
Fix bug in enabled check, changed code to return list and proper turn to string
This commit is contained in:
parent
c9898e0e87
commit
6820188605
6 changed files with 30 additions and 28 deletions
|
@ -15,8 +15,8 @@ class autoProcessComics:
|
|||
return 1 # failure
|
||||
|
||||
# auto-detect correct section
|
||||
section = config.issubsection(inputCategory, checkenabled=True)
|
||||
if len(section) == 0:
|
||||
section = config.issubsection(inputCategory, checkenabled=True)[0]
|
||||
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)
|
||||
return 1
|
||||
|
|
|
@ -14,8 +14,8 @@ class autoProcessGames:
|
|||
return 1 # failure
|
||||
|
||||
# auto-detect correct section
|
||||
section = config.issubsection(inputCategory, checkenabled=True)
|
||||
if len(section) == 0:
|
||||
section = config.issubsection(inputCategory, checkenabled=True)[0]
|
||||
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)
|
||||
return 1
|
||||
|
|
|
@ -166,8 +166,8 @@ class autoProcessMovie:
|
|||
return 1 # failure
|
||||
|
||||
# auto-detect correct section
|
||||
section = config.issubsection(inputCategory, checkenabled=True)
|
||||
if len(section) == 0:
|
||||
section = config.issubsection(inputCategory, checkenabled=True)[0]
|
||||
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)
|
||||
return 1
|
||||
|
|
|
@ -15,7 +15,7 @@ class autoProcessMusic:
|
|||
return 1 # failure
|
||||
|
||||
# auto-detect correct section
|
||||
section = config.issubsection(inputCategory,checkenabled=True)
|
||||
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)
|
||||
|
@ -44,6 +44,7 @@ class autoProcessMusic:
|
|||
TimePerGiB = int(config()[section][inputCategory]["TimePerGiB"])
|
||||
except:
|
||||
TimePerGiB = 60 # note, if using Network to transfer on 100Mbit LAN, expect ~ 600 MB/minute.
|
||||
|
||||
if ssl:
|
||||
protocol = "https://"
|
||||
else:
|
||||
|
|
|
@ -21,8 +21,8 @@ class autoProcessTV:
|
|||
return 1 # failure
|
||||
|
||||
# auto-detect correct section
|
||||
section = config.issubsection(inputCategory, checkenabled=True)
|
||||
if len(section) == 0:
|
||||
section = config.issubsection(inputCategory, checkenabled=True)[0]
|
||||
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)
|
||||
return 1
|
||||
|
|
|
@ -1,10 +1,19 @@
|
|||
import logging
|
||||
import os
|
||||
import shutil
|
||||
from lib import configobj
|
||||
import lib.configobj
|
||||
from lib.configobj import ConfigObj
|
||||
from itertools import chain
|
||||
|
||||
class config(object):
|
||||
original_ConfigObj = lib.configobj.ConfigObj
|
||||
class config(original_ConfigObj):
|
||||
def __init__(self, *args, **kw):
|
||||
if len(args) == 0:
|
||||
args = (self.CONFIG_FILE,)
|
||||
super(lib.configobj.ConfigObj, self).__init__(*args, **kw)
|
||||
|
||||
def __call__(self, *args, **kwargs):
|
||||
print()
|
||||
|
||||
# constants for nzbtomedia
|
||||
NZBTOMEDIA_VERSION = 'V9.3'
|
||||
NZBTOMEDIA_TIMEOUT = 60
|
||||
|
@ -40,15 +49,6 @@ class config(object):
|
|||
LOG_CONFIG = os.path.join(PROGRAM_DIR, "logging.cfg")
|
||||
SAMPLE_LOG_CONFIG = os.path.join(PROGRAM_DIR, "logging.cfg.sample")
|
||||
|
||||
def __new__(cls, *config_file):
|
||||
try:
|
||||
# load config
|
||||
if not config_file:
|
||||
return configobj.ConfigObj(cls.CONFIG_FILE, interpolation=False)
|
||||
else:
|
||||
return configobj.ConfigObj(*config_file, interpolation=False)
|
||||
except Exception, e:
|
||||
return
|
||||
|
||||
@staticmethod
|
||||
def issubsection(inputCategory, sections=None, checkenabled=False):
|
||||
|
@ -60,15 +60,15 @@ class config(object):
|
|||
if not isinstance(sections, list):
|
||||
sections = [sections]
|
||||
|
||||
results = set()
|
||||
results = []
|
||||
for section in sections:
|
||||
if config()[section].has_key(inputCategory):
|
||||
if checkenabled:
|
||||
if config.isenabled(section, inputCategory):
|
||||
results.add(section)
|
||||
results.append(section)
|
||||
else:
|
||||
results.add(section)
|
||||
return results if results.issubset(sections) else False
|
||||
results.append(section)
|
||||
return results if list(set(results).intersection(set(sections))) else False
|
||||
|
||||
@staticmethod
|
||||
def get_sections(subsections):
|
||||
|
@ -114,8 +114,7 @@ class config(object):
|
|||
if key in config()[section].keys():
|
||||
return config()[section][key]
|
||||
|
||||
@staticmethod
|
||||
def migrate():
|
||||
def migrate(self, *args, **kw):
|
||||
global config_new, config_old
|
||||
config_new = config_old = None
|
||||
|
||||
|
@ -354,4 +353,6 @@ class config(object):
|
|||
|
||||
# writing our configuration file to 'autoProcessMedia.cfg'
|
||||
with open(config.CONFIG_FILE, 'wb') as configFile:
|
||||
config_new.write(configFile)
|
||||
config_new.write(configFile)
|
||||
|
||||
lib.configobj.ConfigObj = config
|
Loading…
Add table
Add a link
Reference in a new issue