diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html
index 97aacb60..beb3697a 100644
--- a/data/interfaces/default/config.html
+++ b/data/interfaces/default/config.html
@@ -50,13 +50,13 @@
HTTP Username
-
+
Enabled
@@ -667,15 +667,15 @@
Path to Encoder
-
+
@@ -1367,7 +1367,7 @@
Muscbrainz Mirror
- %for mirror in config['mirror_list']:
+ %for mirror in config['mirrorlist']:
<%
if mirror == headphones.CONFIG.MIRROR:
selected = 'selected="selected"'
diff --git a/headphones/__init__.py b/headphones/__init__.py
index 959707f6..a9a1e6bb 100644
--- a/headphones/__init__.py
+++ b/headphones/__init__.py
@@ -51,6 +51,7 @@ POSSIBLE_EXTRAS = [
]
PROG_DIR = None
+FULL_PATH = None
ARGS = None
SIGNAL = None
@@ -67,7 +68,7 @@ PIDFILE = None
SCHED = BackgroundScheduler()
INIT_LOCK = threading.Lock()
-__INITIALIZED__ = False
+_INITIALIZED = False
started = False
DATA_DIR = None
@@ -97,15 +98,16 @@ def initialize(config_file):
with INIT_LOCK:
global CONFIG
- global __INITIALIZED__
- global EXTRA_NEWZNABS
+ global _INITIALIZED
+ global CURRENT_VERSION
global LATEST_VERSION
+ global UMASK
CONFIG = headphones.config.Config(config_file)
assert CONFIG is not None
- if __INITIALIZED__:
+ if _INITIALIZED:
return False
if CONFIG.HTTP_PORT < 21 or CONFIG.HTTP_PORT > 65535:
@@ -172,7 +174,7 @@ def initialize(config_file):
UMASK = os.umask(0)
os.umask(UMASK)
- __INITIALIZED__ = True
+ _INITIALIZED = True
return True
@@ -246,9 +248,9 @@ def launch_browser(host, port, root):
def start():
- global __INITIALIZED__, started
+ global started
- if __INITIALIZED__:
+ if _INITIALIZED:
# Start our scheduled background tasks
from headphones import updater, searcher, librarysync, postprocessor, torrentfinished
@@ -499,8 +501,8 @@ def dbcheck():
c.execute('ALTER TABLE artists ADD COLUMN Extras TEXT DEFAULT NULL')
# Need to update some stuff when people are upgrading and have 'include
# extras' set globally/for an artist
- if INCLUDE_EXTRAS:
- EXTRAS = "1,2,3,4,5,6,7,8"
+ if CONFIG.INCLUDE_EXTRAS:
+ CONFIG.EXTRAS = "1,2,3,4,5,6,7,8"
logger.info("Copying over current artist IncludeExtras information")
artists = c.execute(
'SELECT ArtistID, IncludeExtras from artists').fetchall()
diff --git a/headphones/config.py b/headphones/config.py
index 0fad26b9..58e895c9 100644
--- a/headphones/config.py
+++ b/headphones/config.py
@@ -14,11 +14,13 @@ def bool_int(value):
value = 0
return int(bool(value))
-_config_definitions = {
+_CONFIG_DEFINITIONS = {
'ADD_ALBUM_ART': (int, 'General', 0),
'ADVANCEDENCODER': (str, 'General', ''),
'ALBUM_ART_FORMAT': (str, 'General', 'folder'),
- 'ALBUM_COMPLETION_PCT': (int, 'Advanced', 80), # This is used in importer.py to determine how complete an album needs to be - to be considered "downloaded". Percentage from 0-100
+ # This is used in importer.py to determine how complete an album needs to
+ # be - to be considered "downloaded". Percentage from 0-100
+ 'ALBUM_COMPLETION_PCT': (int, 'Advanced', 80),
'API_ENABLED': (int, 'General', 0),
'API_KEY': (str, 'General', ''),
'AUTOWANT_ALL': (int, 'General', 0),
@@ -239,7 +241,7 @@ class Config(object):
""" Initialize the config with values from a file """
self._config_file = config_file
self._config = ConfigObj(self._config_file, encoding='utf-8')
- for key in _config_definitions.keys():
+ for key in _CONFIG_DEFINITIONS.keys():
self.check_setting(key)
self.ENCODER_MULTICORE_COUNT = max(0, self.ENCODER_MULTICORE_COUNT)
self._upgrade()
@@ -247,7 +249,7 @@ class Config(object):
def _define(self, name):
key = name.upper()
ini_key = name.lower()
- definition = _config_definitions[key]
+ definition = _CONFIG_DEFINITIONS[key]
if len(definition) == 3:
definition_type, section, default = definition
else:
@@ -278,8 +280,8 @@ class Config(object):
new_config = ConfigObj(encoding="UTF-8")
new_config.filename = self._config_file
- # first copy over everything from the old config, even if it is not correctly
- # defined to keep from losing data
+ # first copy over everything from the old config, even if it is not
+ # correctly defined to keep from losing data
for key, subkeys in self._config.items():
if key not in new_config:
new_config[key] = {}
@@ -287,7 +289,7 @@ class Config(object):
new_config[key][subkey] = value
# next make sure that everything we expect to have defined is so
- for key in _config_definitions.keys():
+ for key in _CONFIG_DEFINITIONS.keys():
key, definition_type, section, ini_key, default = self._define(key)
self.check_setting(key)
if section not in new_config:
diff --git a/headphones/request.py b/headphones/request.py
index 3367428e..d52e1b39 100644
--- a/headphones/request.py
+++ b/headphones/request.py
@@ -48,7 +48,7 @@ def request_response(url, method="get", auto_raise=True,
# Disable verification of SSL certificates if requested. Note: this could
# pose a security issue!
- kwargs["verify"] = headphones.CONFIG.VERIFY_SSL_CERT
+ kwargs["verify"] = bool(headphones.CONFIG.VERIFY_SSL_CERT)
# Map method to the request.XXX method. This is a simple hack, but it allows
# requests to apply more magic per method. See lib/requests/api.py.
diff --git a/headphones/webserve.py b/headphones/webserve.py
index 1ae53c06..af153edd 100644
--- a/headphones/webserve.py
+++ b/headphones/webserve.py
@@ -658,7 +658,7 @@ class WebInterface(object):
def importLastFM(self, username):
headphones.CONFIG.LASTFM_USERNAME = username
- headphones.config_write()
+ headphones.CONFIG.write()
threading.Thread(target=lastfm.getArtists).start()
raise cherrypy.HTTPRedirect("home")
importLastFM.exposed = True
@@ -670,7 +670,7 @@ class WebInterface(object):
def importItunes(self, path):
headphones.CONFIG.PATH_TO_XML = path
- headphones.config_write()
+ headphones.CONFIG.write()
threading.Thread(target=importer.itunesImport, args=[path]).start()
time.sleep(10)
raise cherrypy.HTTPRedirect("home")
@@ -680,7 +680,7 @@ class WebInterface(object):
headphones.CONFIG.LIBRARYSCAN = libraryscan
headphones.CONFIG.AUTO_ADD_ARTISTS = autoadd
headphones.CONFIG.MUSIC_DIR = path
- headphones.config_write()
+ headphones.CONFIG.write()
if scan:
try:
threading.Thread(target=librarysync.libraryScan).start()
@@ -933,9 +933,9 @@ class WebInterface(object):
config = {
"http_host": headphones.CONFIG.HTTP_HOST,
- "http_user": headphones.CONFIG.HTTP_USERNAME,
+ "http_username": headphones.CONFIG.HTTP_USERNAME,
"http_port": headphones.CONFIG.HTTP_PORT,
- "http_pass": headphones.CONFIG.HTTP_PASSWORD,
+ "http_password": headphones.CONFIG.HTTP_PASSWORD,
"launch_browser": checked(headphones.CONFIG.LAUNCH_BROWSER),
"enable_https": checked(headphones.CONFIG.ENABLE_HTTPS),
"https_cert": headphones.CONFIG.HTTPS_CERT,
@@ -948,21 +948,21 @@ class WebInterface(object):
"search_interval": headphones.CONFIG.SEARCH_INTERVAL,
"libraryscan_interval": headphones.CONFIG.LIBRARYSCAN_INTERVAL,
"sab_host": headphones.CONFIG.SAB_HOST,
- "sab_user": headphones.CONFIG.SAB_USERNAME,
- "sab_api": headphones.CONFIG.SAB_APIKEY,
- "sab_pass": headphones.CONFIG.SAB_PASSWORD,
- "sab_cat": headphones.CONFIG.SAB_CATEGORY,
+ "sab_username": headphones.CONFIG.SAB_USERNAME,
+ "sab_apikey": headphones.CONFIG.SAB_APIKEY,
+ "sab_password": headphones.CONFIG.SAB_PASSWORD,
+ "sab_category": headphones.CONFIG.SAB_CATEGORY,
"nzbget_host": headphones.CONFIG.NZBGET_HOST,
- "nzbget_user": headphones.CONFIG.NZBGET_USERNAME,
- "nzbget_pass": headphones.CONFIG.NZBGET_PASSWORD,
- "nzbget_cat": headphones.CONFIG.NZBGET_CATEGORY,
+ "nzbget_username": headphones.CONFIG.NZBGET_USERNAME,
+ "nzbget_password": headphones.CONFIG.NZBGET_PASSWORD,
+ "nzbget_category": headphones.CONFIG.NZBGET_CATEGORY,
"nzbget_priority": headphones.CONFIG.NZBGET_PRIORITY,
"transmission_host": headphones.CONFIG.TRANSMISSION_HOST,
- "transmission_user": headphones.CONFIG.TRANSMISSION_USERNAME,
- "transmission_pass": headphones.CONFIG.TRANSMISSION_PASSWORD,
+ "transmission_username": headphones.CONFIG.TRANSMISSION_USERNAME,
+ "transmission_password": headphones.CONFIG.TRANSMISSION_PASSWORD,
"utorrent_host": headphones.CONFIG.UTORRENT_HOST,
- "utorrent_user": headphones.CONFIG.UTORRENT_USERNAME,
- "utorrent_pass": headphones.CONFIG.UTORRENT_PASSWORD,
+ "utorrent_username": headphones.CONFIG.UTORRENT_USERNAME,
+ "utorrent_password": headphones.CONFIG.UTORRENT_PASSWORD,
"utorrent_label": headphones.CONFIG.UTORRENT_LABEL,
"nzb_downloader_sabnzbd": radio(headphones.CONFIG.NZB_DOWNLOADER, 0),
"nzb_downloader_nzbget": radio(headphones.CONFIG.NZB_DOWNLOADER, 1),
@@ -977,7 +977,7 @@ class WebInterface(object):
"headphones_indexer": checked(headphones.CONFIG.HEADPHONES_INDEXER),
"use_newznab": checked(headphones.CONFIG.NEWZNAB),
"newznab_host": headphones.CONFIG.NEWZNAB_HOST,
- "newznab_api": headphones.CONFIG.NEWZNAB_APIKEY,
+ "newznab_apikey": headphones.CONFIG.NEWZNAB_APIKEY,
"newznab_enabled": checked(headphones.CONFIG.NEWZNAB_ENABLED),
"extra_newznabs": headphones.CONFIG.get_extra_newznabs(),
"use_nzbsorg": checked(headphones.CONFIG.NZBSORG),
@@ -1016,10 +1016,10 @@ class WebInterface(object):
"pref_qual_1": radio(headphones.CONFIG.PREFERRED_QUALITY, 1),
"pref_qual_2": radio(headphones.CONFIG.PREFERRED_QUALITY, 2),
"pref_qual_3": radio(headphones.CONFIG.PREFERRED_QUALITY, 3),
- "pref_bitrate": headphones.CONFIG.PREFERRED_BITRATE,
- "pref_bitrate_high": headphones.CONFIG.PREFERRED_BITRATE_HIGH_BUFFER,
- "pref_bitrate_low": headphones.CONFIG.PREFERRED_BITRATE_LOW_BUFFER,
- "pref_bitrate_allow_lossless": checked(headphones.CONFIG.PREFERRED_BITRATE_ALLOW_LOSSLESS),
+ "preferred_bitrate": headphones.CONFIG.PREFERRED_BITRATE,
+ "preferred_bitrate_high": headphones.CONFIG.PREFERRED_BITRATE_HIGH_BUFFER,
+ "preferred_bitrate_low": headphones.CONFIG.PREFERRED_BITRATE_LOW_BUFFER,
+ "preferred_bitrate_allow_lossless": checked(headphones.CONFIG.PREFERRED_BITRATE_ALLOW_LOSSLESS),
"detect_bitrate": checked(headphones.CONFIG.DETECT_BITRATE),
"lossless_bitrate_from": headphones.CONFIG.LOSSLESS_BITRATE_FROM,
"lossless_bitrate_to": headphones.CONFIG.LOSSLESS_BITRATE_TO,
@@ -1034,8 +1034,8 @@ class WebInterface(object):
"embed_album_art": checked(headphones.CONFIG.EMBED_ALBUM_ART),
"embed_lyrics": checked(headphones.CONFIG.EMBED_LYRICS),
"replace_existing_folders": checked(headphones.CONFIG.REPLACE_EXISTING_FOLDERS),
- "dest_dir": headphones.CONFIG.DESTINATION_DIR,
- "lossless_dest_dir": headphones.CONFIG.LOSSLESS_DESTINATION_DIR,
+ "destination_dir": headphones.CONFIG.DESTINATION_DIR,
+ "lossless_destination_dir": headphones.CONFIG.LOSSLESS_DESTINATION_DIR,
"folder_format": headphones.CONFIG.FOLDER_FORMAT,
"file_format": headphones.CONFIG.FILE_FORMAT,
"file_underscores": checked(headphones.CONFIG.FILE_UNDERSCORES),
@@ -1057,7 +1057,7 @@ class WebInterface(object):
"encoder": headphones.CONFIG.ENCODER,
"xldprofile": headphones.CONFIG.XLDPROFILE,
"bitrate": int(headphones.CONFIG.BITRATE),
- "encoderfolder": headphones.CONFIG.ENCODER_PATH,
+ "encoder_path": headphones.CONFIG.ENCODER_PATH,
"advancedencoder": headphones.CONFIG.ADVANCEDENCODER,
"encoderoutputformat": headphones.CONFIG.ENCODEROUTPUTFORMAT,
"samplingfrequency": headphones.CONFIG.SAMPLINGFREQUENCY,
@@ -1119,7 +1119,7 @@ class WebInterface(object):
"boxcar_enabled": checked(headphones.CONFIG.BOXCAR_ENABLED),
"boxcar_onsnatch": checked(headphones.CONFIG.BOXCAR_ONSNATCH),
"boxcar_token": headphones.CONFIG.BOXCAR_TOKEN,
- "mirror_list": headphones.MIRRORLIST,
+ "mirrorlist": headphones.MIRRORLIST,
"mirror": headphones.CONFIG.MIRROR,
"customhost": headphones.CONFIG.CUSTOMHOST,
"customport": headphones.CONFIG.CUSTOMPORT,
@@ -1136,7 +1136,8 @@ class WebInterface(object):
"mpc_enabled": checked(headphones.CONFIG.MPC_ENABLED)
}
- # Need to convert EXTRAS to a dictionary we can pass to the config: it'll come in as a string like 2,5,6,8 (append new extras to the end)
+ # Need to convert EXTRAS to a dictionary we can pass to the config:
+ # it'll come in as a string like 2,5,6,8
extra_munges = {
"dj-mix": "dj_mix",
"mixtape/street": "mixtape_street"