Skip to content

Commit 19ec96f

Browse files
author
David Norman
committed
Pause squeezed until the network is up.
Note: this should be done in the same way that sshd is done - using if-up.d and calling init.d restart when the wlan or eth interfaces come up. this is definitely a TODO Also do some web page neatening
1 parent 0bd0b76 commit 19ec96f

File tree

5 files changed

+30
-6
lines changed

5 files changed

+30
-6
lines changed

controller/src/squeezed

+10-1
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ import cherrypy
55
import json
66
import socket
77
import sys
8+
import syslog
9+
import time
810

911
squeeze_player = ""
1012

1113
def get_ip_address():
1214
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
13-
s.connect(('192.168.0.101', 0)) # connecting to a UDP address doesn't send packets
15+
while s.connect_ex(('192.168.0.101', 0)) != 0:
16+
time.sleep(1)
1417
return s.getsockname()[0]
1518

1619
def squeeze_request(params):
@@ -45,13 +48,18 @@ if __name__ == '__main__':
4548
}
4649
}
4750

51+
syslog.syslog("squeezed: starting")
52+
4853
# Get our IP address as seen by the squeeze server
4954
ip = get_ip_address()
5055

56+
syslog.syslog("squeezed: ip address " + ip)
57+
5158
# Establish our player id
5259
r = squeeze_request(["players"])
5360
player_count = r["count"]
5461
if player_count == 0:
62+
syslog.syslog("squeezed: no squeezebox players")
5563
sys.exit(0)
5664

5765
r = squeeze_request(["players",0,player_count])
@@ -60,6 +68,7 @@ if __name__ == '__main__':
6068
squeeze_player = p["playerid"]
6169

6270
if squeeze_player == "":
71+
syslog.syslog("squeezed: no squeezebox player id")
6372
sys.exit(0)
6473

6574
cherrypy.server.socket_host = "0.0.0.0"

web/src/css/piradio.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
span.bigicon {
22
padding: 2px;
3-
font-size: 4em;
3+
font-size: 3em;
44
}

web/src/html/playlist.html

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<div ng-init="init()">
22

3-
<p>Player: {{data.player_name}} @ {{data.player_ip}}
3+
<p>Player: {{data.player_name}} @ {{data.player_ip}}</p>
4+
5+
<p>
46

57
<table class="table table-striped">
68
<thead>
@@ -14,7 +16,7 @@
1416
</thead>
1517
<tbody>
1618
<tr ng-class="($index==data.playlist_cur_index)?'success':''" ng-repeat="r in data.playlist_loop">
17-
<td></td>
19+
<td><a href="javascript:;" ng-click="playlist_remove(r.id)"><span class="glyphicon glyphicon-remove-circle"></span></a></td>
1820
<td>{{r.tracknum}}</td>
1921
<td><a href="#/local/track/{{r.id}}">{{r.title}}</a></td>
2022
<td><a href="#/local/album/{{r.album_id}}">{{r.album}}</a></td>

web/src/js/playlist.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
function PlaylistController($scope, slimClient) {
1+
function PlaylistController($scope, $location, slimClient) {
2+
3+
$scope.playlist_remove = function(id) {
4+
slimClient.playlist_remove(id).
5+
success(function(result) {
6+
location.reload();
7+
});
8+
};
29

310
$scope.init = function() {
411
slimClient.player_status().

web/src/js/slim-client.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ function SlimClient($http, $location, serverStatus) {
5151
return slimRequest(data);
5252
};
5353

54+
this.playlist_remove = function(track_id) {
55+
data = ["playlistcontrol", "cmd:delete", "track_id:"+track_id];
56+
return slimRequest(data);
57+
};
58+
5459
this.ctrl_fb = function() {
5560
data = ["playlist", "index", "-1"];
5661
return slimRequest(data);
@@ -74,6 +79,7 @@ function SlimClient($http, $location, serverStatus) {
7479
this.player_status = function() {
7580
data = ["status", 0, 100, "tags:adelsty"];
7681
return slimRequest(data);
77-
}
82+
};
83+
7884
};
7985

0 commit comments

Comments
 (0)