Added customizable interfaces option to config

This commit is contained in:
Remy
2011-08-09 17:43:36 -07:00
parent 36a2967354
commit ff5776659f
3 changed files with 35 additions and 6 deletions

View File

@@ -1,4 +1,8 @@
<%inherit file="base.html"/>
<%!
import headphones
%>
<%def name="headerIncludes()">
<div id="subhead_container">
<ul id="subhead_menu">
@@ -234,8 +238,20 @@
<td>
<h2>Miscellaneous:</h2>
<br>
<h3><input type="checkbox" name="include_extras" value="1" ${config['include_extras']} />Automatically Include Extras When Adding an Artist</h3><br />
<i class="smalltext">Extras includes: EPs, Compilations, Live Albums, Remix Albums and Singles</i>
<h3><input type="checkbox" name="include_extras" value="1" ${config['include_extras']} />Automatically Include Extras When Adding an Artist</h3>
<i class="smalltext">(EPs, Compilations, Live Albums, Remix Albums and Singles)</i>
<br><br>
<h3>Interface: <select name="interface"><h3>
%for interface in config['interface_list']:
<%
if interface == headphones.INTERFACE:
selected = 'selected="selected"'
else:
selected = ''
%>
<option value="${interface}" ${selected}>${interface}</option>
%endfor
</select>
<br><br>
<h3>Log Directory:</h3><input type="text" name="log_dir" value="${config['log_dir']}" size="50">
</td>

View File

@@ -104,6 +104,8 @@ LASTFM_USERNAME = None
MEDIA_FORMATS = ["mp3", "flac", "aac", "ogg", "ape", "m4a"]
INTERFACE = None
def CheckSection(sec):
""" Check if INI section exists, if not create it """
try:
@@ -161,7 +163,7 @@ def initialize():
ADD_ALBUM_ART, EMBED_ALBUM_ART, DOWNLOAD_DIR, BLACKHOLE, BLACKHOLE_DIR, USENET_RETENTION, NZB_SEARCH_INTERVAL, \
LIBRARYSCAN_INTERVAL, DOWNLOAD_SCAN_INTERVAL, SAB_HOST, SAB_USERNAME, SAB_PASSWORD, SAB_APIKEY, SAB_CATEGORY, \
NZBMATRIX, NZBMATRIX_USERNAME, NZBMATRIX_APIKEY, NEWZNAB, NEWZNAB_HOST, NEWZNAB_APIKEY, \
NZBSORG, NZBSORG_UID, NZBSORG_HASH, NEWZBIN, NEWZBIN_UID, NEWZBIN_PASSWORD, LASTFM_USERNAME
NZBSORG, NZBSORG_UID, NZBSORG_HASH, NEWZBIN, NEWZBIN_UID, NEWZBIN_PASSWORD, LASTFM_USERNAME, INTERFACE
if __INITIALIZED__:
return False
@@ -237,6 +239,8 @@ def initialize():
NEWZBIN_PASSWORD = check_setting_str(CFG, 'Newzbin', 'newzbin_password', '')
LASTFM_USERNAME = check_setting_str(CFG, 'General', 'lastfm_username', '')
INTERFACE = check_setting_str(CFG, 'General', 'interface', 'default')
if not LOG_DIR:
LOG_DIR = os.path.join(DATA_DIR, 'logs')
@@ -403,6 +407,7 @@ def config_write():
new_config['Newzbin']['newzbin_password'] = NEWZBIN_PASSWORD
new_config['General']['lastfm_username'] = LASTFM_USERNAME
new_config['General']['interface'] = INTERFACE
new_config.write()

View File

@@ -17,7 +17,9 @@ from headphones.helpers import checked, radio
def serve_template(templatename, **kwargs):
template_dir = os.path.join(str(headphones.PROG_DIR), 'data/interfaces/default/')
interface_dir = os.path.join(str(headphones.PROG_DIR), 'data/interfaces/')
template_dir = os.path.join(str(interface_dir), headphones.INTERFACE)
_hplookup = TemplateLookup(directories=[template_dir])
try:
@@ -246,6 +248,10 @@ class WebInterface(object):
clearhistory.exposed = True
def config(self):
interface_dir = os.path.join(headphones.PROG_DIR, 'data/interfaces/')
interface_list = [ name for name in os.listdir(interface_dir) if os.path.isdir(os.path.join(interface_dir, name)) ]
config = {
"http_host" : headphones.HTTP_HOST,
"http_user" : headphones.HTTP_USERNAME,
@@ -289,7 +295,8 @@ class WebInterface(object):
"folder_format" : headphones.FOLDER_FORMAT,
"file_format" : headphones.FILE_FORMAT,
"include_extras" : checked(headphones.INCLUDE_EXTRAS),
"log_dir" : headphones.LOG_DIR
"log_dir" : headphones.LOG_DIR,
"interface_list" : interface_list
}
return serve_template(templatename="config.html", title="Settings", config=config)
config.exposed = True
@@ -299,7 +306,7 @@ class WebInterface(object):
sab_host=None, sab_username=None, sab_apikey=None, sab_password=None, sab_category=None, download_dir=None, blackhole=0, blackhole_dir=None,
usenet_retention=None, nzbmatrix=0, nzbmatrix_username=None, nzbmatrix_apikey=None, newznab=0, newznab_host=None, newznab_apikey=None,
nzbsorg=0, nzbsorg_uid=None, nzbsorg_hash=None, newzbin=0, newzbin_uid=None, newzbin_password=None, preferred_quality=0, preferred_bitrate=None, detect_bitrate=0, move_files=0,
rename_files=0, correct_metadata=0, cleanup_files=0, add_album_art=0, embed_album_art=0, destination_dir=None, folder_format=None, file_format=None, include_extras=0, log_dir=None):
rename_files=0, correct_metadata=0, cleanup_files=0, add_album_art=0, embed_album_art=0, destination_dir=None, folder_format=None, file_format=None, include_extras=0, interface=None, log_dir=None):
headphones.HTTP_HOST = http_host
headphones.HTTP_PORT = http_port
@@ -340,6 +347,7 @@ class WebInterface(object):
headphones.FOLDER_FORMAT = folder_format
headphones.FILE_FORMAT = file_format
headphones.INCLUDE_EXTRAS = include_extras
headphones.INTERFACE = interface
headphones.LOG_DIR = log_dir
headphones.config_write()