Merge remote-tracking branch 'NovaXeros/patch-1' into develop

Conflicts:
	headphones/notifiers.py
This commit is contained in:
rembo10
2014-04-17 17:17:25 -07:00
2 changed files with 7 additions and 12 deletions
+2 -2
View File
@@ -678,9 +678,9 @@
</div> </div>
</fieldset> </fieldset>
<fieldset> <fieldset>
<h3>LMS</h3> <h3>Logitech Media Server</h3>
<div class="checkbox row"> <div class="checkbox row">
<input type="checkbox" name="lms_enabled" id="lms" value="1" ${config['lms_enabled']} /><label>Enable Squeezebox Updates</label> <input type="checkbox" name="lms_enabled" id="lms" value="1" ${config['lms_enabled']} /><label>Enable LMS Updates</label>
</div> </div>
<div id="lmsoptions"> <div id="lmsoptions">
<div class="row"> <div class="row">
+5 -10
View File
@@ -249,10 +249,10 @@ class LMS:
self.hosts = headphones.LMS_HOST self.hosts = headphones.LMS_HOST
def _sendjson(self, host): def _sendjson(self, host):
data = {'id': 1, 'method': 'slim.request', 'params': ["",["rescan"]]} #Had a lot of trouble with simplejson, but this works. data = {'id': 1, 'method': 'slim.request', 'params': ["",["rescan"]]}
data = simplejson.JSONEncoder().encode(data) data = simplejson.JSONEncoder().encode(data)
content = {'Content-Type': 'application/json', 'Content-Length': len(data)} content = {'Content-Type': 'application/json'}
req = urllib2.Request(host+'/jsonrpc.js', data, content) req = urllib2.Request(host+'/jsonrpc.js', data, content)
@@ -263,20 +263,15 @@ class LMS:
return return
response = simplejson.JSONDecoder().decode(handle.read()) response = simplejson.JSONDecoder().decode(handle.read())
server_result = simplejson.dumps(response)
try: try:
return response[0]['result'] return response['result']
except: except:
logger.warn('LMS returned error: %s' % response[0]['error']) logger.warn('LMS returned error: %s' % response['error'])
return return
def update(self): def update(self):
#Send the ["rescan"] command to an LMS server.
#Note that the command must be prefixed with the 'player' that the command is aimed at,
#But with this being a request for the server to update its library, the player is blank, so ""
hosts = [x.strip() for x in self.hosts.split(',')] hosts = [x.strip() for x in self.hosts.split(',')]
for host in hosts: for host in hosts:
@@ -780,4 +775,4 @@ class BOXCAR:
except urllib2.URLError, e: except urllib2.URLError, e:
logger.warn('Error sending Boxcar2 Notification: %s' % e) logger.warn('Error sending Boxcar2 Notification: %s' % e)
return False return False