mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-20 05:13:16 -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
|
return 1 # failure
|
||||||
|
|
||||||
# auto-detect correct section
|
# auto-detect correct section
|
||||||
section = config.issubsection(inputCategory, checkenabled=True)
|
section = config.issubsection(inputCategory, checkenabled=True)[0]
|
||||||
if len(section) == 0:
|
if not section:
|
||||||
Logger.error(
|
Logger.error(
|
||||||
"MAIN: We were unable to find a processor for category %s that was enabled, please check your autoProcessMedia.cfg file.", inputCategory)
|
"MAIN: We were unable to find a processor for category %s that was enabled, please check your autoProcessMedia.cfg file.", inputCategory)
|
||||||
return 1
|
return 1
|
||||||
|
|
|
@ -14,8 +14,8 @@ class autoProcessGames:
|
||||||
return 1 # failure
|
return 1 # failure
|
||||||
|
|
||||||
# auto-detect correct section
|
# auto-detect correct section
|
||||||
section = config.issubsection(inputCategory, checkenabled=True)
|
section = config.issubsection(inputCategory, checkenabled=True)[0]
|
||||||
if len(section) == 0:
|
if not section:
|
||||||
Logger.error(
|
Logger.error(
|
||||||
"MAIN: We were unable to find a processor for category %s that was enabled, please check your autoProcessMedia.cfg file.", inputCategory)
|
"MAIN: We were unable to find a processor for category %s that was enabled, please check your autoProcessMedia.cfg file.", inputCategory)
|
||||||
return 1
|
return 1
|
||||||
|
|
|
@ -166,8 +166,8 @@ class autoProcessMovie:
|
||||||
return 1 # failure
|
return 1 # failure
|
||||||
|
|
||||||
# auto-detect correct section
|
# auto-detect correct section
|
||||||
section = config.issubsection(inputCategory, checkenabled=True)
|
section = config.issubsection(inputCategory, checkenabled=True)[0]
|
||||||
if len(section) == 0:
|
if not section:
|
||||||
Logger.error(
|
Logger.error(
|
||||||
"MAIN: We were unable to find a processor for category %s that was enabled, please check your autoProcessMedia.cfg file.", inputCategory)
|
"MAIN: We were unable to find a processor for category %s that was enabled, please check your autoProcessMedia.cfg file.", inputCategory)
|
||||||
return 1
|
return 1
|
||||||
|
|
|
@ -15,7 +15,7 @@ class autoProcessMusic:
|
||||||
return 1 # failure
|
return 1 # failure
|
||||||
|
|
||||||
# auto-detect correct section
|
# auto-detect correct section
|
||||||
section = config.issubsection(inputCategory,checkenabled=True)
|
section = config.issubsection(inputCategory,checkenabled=True)[0]
|
||||||
if len(section) == 0:
|
if len(section) == 0:
|
||||||
Logger.error(
|
Logger.error(
|
||||||
"MAIN: We were unable to find a processor for category %s that was enabled, please check your autoProcessMedia.cfg file.", inputCategory)
|
"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"])
|
TimePerGiB = int(config()[section][inputCategory]["TimePerGiB"])
|
||||||
except:
|
except:
|
||||||
TimePerGiB = 60 # note, if using Network to transfer on 100Mbit LAN, expect ~ 600 MB/minute.
|
TimePerGiB = 60 # note, if using Network to transfer on 100Mbit LAN, expect ~ 600 MB/minute.
|
||||||
|
|
||||||
if ssl:
|
if ssl:
|
||||||
protocol = "https://"
|
protocol = "https://"
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -21,8 +21,8 @@ class autoProcessTV:
|
||||||
return 1 # failure
|
return 1 # failure
|
||||||
|
|
||||||
# auto-detect correct section
|
# auto-detect correct section
|
||||||
section = config.issubsection(inputCategory, checkenabled=True)
|
section = config.issubsection(inputCategory, checkenabled=True)[0]
|
||||||
if len(section) == 0:
|
if not section:
|
||||||
Logger.error(
|
Logger.error(
|
||||||
"MAIN: We were unable to find a processor for category %s that was enabled, please check your autoProcessMedia.cfg file.", inputCategory)
|
"MAIN: We were unable to find a processor for category %s that was enabled, please check your autoProcessMedia.cfg file.", inputCategory)
|
||||||
return 1
|
return 1
|
||||||
|
|
|
@ -1,10 +1,19 @@
|
||||||
import logging
|
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
from lib import configobj
|
import lib.configobj
|
||||||
|
from lib.configobj import ConfigObj
|
||||||
from itertools import chain
|
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
|
# constants for nzbtomedia
|
||||||
NZBTOMEDIA_VERSION = 'V9.3'
|
NZBTOMEDIA_VERSION = 'V9.3'
|
||||||
NZBTOMEDIA_TIMEOUT = 60
|
NZBTOMEDIA_TIMEOUT = 60
|
||||||
|
@ -40,15 +49,6 @@ class config(object):
|
||||||
LOG_CONFIG = os.path.join(PROGRAM_DIR, "logging.cfg")
|
LOG_CONFIG = os.path.join(PROGRAM_DIR, "logging.cfg")
|
||||||
SAMPLE_LOG_CONFIG = os.path.join(PROGRAM_DIR, "logging.cfg.sample")
|
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
|
@staticmethod
|
||||||
def issubsection(inputCategory, sections=None, checkenabled=False):
|
def issubsection(inputCategory, sections=None, checkenabled=False):
|
||||||
|
@ -60,15 +60,15 @@ class config(object):
|
||||||
if not isinstance(sections, list):
|
if not isinstance(sections, list):
|
||||||
sections = [sections]
|
sections = [sections]
|
||||||
|
|
||||||
results = set()
|
results = []
|
||||||
for section in sections:
|
for section in sections:
|
||||||
if config()[section].has_key(inputCategory):
|
if config()[section].has_key(inputCategory):
|
||||||
if checkenabled:
|
if checkenabled:
|
||||||
if config.isenabled(section, inputCategory):
|
if config.isenabled(section, inputCategory):
|
||||||
results.add(section)
|
results.append(section)
|
||||||
else:
|
else:
|
||||||
results.add(section)
|
results.append(section)
|
||||||
return results if results.issubset(sections) else False
|
return results if list(set(results).intersection(set(sections))) else False
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_sections(subsections):
|
def get_sections(subsections):
|
||||||
|
@ -114,8 +114,7 @@ class config(object):
|
||||||
if key in config()[section].keys():
|
if key in config()[section].keys():
|
||||||
return config()[section][key]
|
return config()[section][key]
|
||||||
|
|
||||||
@staticmethod
|
def migrate(self, *args, **kw):
|
||||||
def migrate():
|
|
||||||
global config_new, config_old
|
global config_new, config_old
|
||||||
config_new = config_old = None
|
config_new = config_old = None
|
||||||
|
|
||||||
|
@ -354,4 +353,6 @@ class config(object):
|
||||||
|
|
||||||
# writing our configuration file to 'autoProcessMedia.cfg'
|
# writing our configuration file to 'autoProcessMedia.cfg'
|
||||||
with open(config.CONFIG_FILE, 'wb') as configFile:
|
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