bandshell 0.8 → 0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 76e1e5551356ead78b079d5f4dbafa43f432af3d
4
- data.tar.gz: 58f5320c083a5dbb6c586e018100d666bbe9e24f
3
+ metadata.gz: 50f3b9aa759cbb5ce8623ab42424d1772e8ec3a9
4
+ data.tar.gz: 32f5b633dd51276279e09c33010a3013e1a4cfcf
5
5
  SHA512:
6
- metadata.gz: 44769d0e908c6b2284a84e665bc7c4086bd270202ad620124aaf22a237232eb9d0b7b6a5958b034ca1daf3d34521697a4d2f2b68f47f277756e34ad7120c0eff
7
- data.tar.gz: d51445442008e2ca35af39677bf1c4c6de4e2189b1c123c6e8e699317edeb0cd2938d3e0a22bcbe8bee444f03dd17e7c9bfe94dad33c21d0c23473b4a51cd562
6
+ metadata.gz: 5827d9317a00e3a141e19687e35d3fe15762d8723c1c570683f913b5d9d0d2119e5c0fa5fb8b076e8a165a4ae13705f352781da23073557f83a30b31f8da69d5
7
+ data.tar.gz: 1e3244f4c1b9da340d18811f130d188b3c51c55eedfc8b66d3ae722b78482f3e643656d19f9983e0354e1a1a1a29d796113702bbc89409aad09edcf2ce8aaf64
@@ -18,6 +18,6 @@ timer_argv = ARGV.dup
18
18
  timer_argv << "--" unless timer_argv.include? "--"
19
19
  timer_argv << bandshell_url
20
20
 
21
- Daemons.run("bin/bandshell-timer.rb",
21
+ Daemons.run(File.join(File.dirname(__FILE__), "bandshell-timer.rb"),
22
22
  :log_output=>true, :dir_mode => dir_mode,
23
23
  :ARGV => timer_argv)
@@ -391,7 +391,8 @@ class ConcertoConfigServer < Sinatra::Base
391
391
  # to execute system maintenance functions such as updating configs
392
392
  # from Concerto, and performing screen on/off control.
393
393
  get '/background-job' do
394
- if update_player_info
394
+ force = params.has_key? "force"
395
+ if update_player_info(force)
395
396
  "Update executed"
396
397
  else
397
398
  "update_player_info failed."
@@ -401,7 +402,7 @@ class ConcertoConfigServer < Sinatra::Base
401
402
  # TODO: Refactor player settings management into a separate class
402
403
 
403
404
  @@player_data_updated=Time.new(0)
404
- @@screen_on_off=[{:action=>"on"}] # default to always-on
405
+ @@screen_on_off=[{"action"=>"on"}] # default to always-on
405
406
 
406
407
  # Fetches the latest player settings from Concerto if the current
407
408
  # settings are too old or an update is forced (force=true).
@@ -429,6 +430,7 @@ class ConcertoConfigServer < Sinatra::Base
429
430
  end
430
431
  end
431
432
 
433
+ # TODO: more validation before accepting.
432
434
  def parse_screen_on_off(data)
433
435
  begin
434
436
  rules = JSON.parse(data)
@@ -446,8 +448,56 @@ class ConcertoConfigServer < Sinatra::Base
446
448
 
447
449
  # Returns true if the screen should be turned on right now,
448
450
  # according to the latest data recieved from concerto-hardware.
451
+ # Assumes @@screen_on_off is either nil or a valid ruleset.
452
+ # TODO: Evaluate effects of timezones
449
453
  def screen_scheduled_on?
450
- raise 'screen_scheduled_on?: TODO'
454
+ return true if @@screen_on_off.nil?
455
+
456
+ results = []
457
+ t = Time.now
458
+ @@screen_on_off.each do |rule|
459
+ rule_active = true
460
+ rule.each do |key, value|
461
+ case key
462
+ when "wkday"
463
+ rule_active = false unless value.include? t.wday.to_s
464
+ when "time_after"
465
+ rule_secs = seconds_since_midnight(Time.parse(value))
466
+ curr_secs = seconds_since_midnight(t)
467
+ rule_active = false unless curr_secs > rule_secs
468
+ when "time_before"
469
+ rule_secs = seconds_since_midnight(Time.parse(value))
470
+ curr_secs = seconds_since_midnight(t)
471
+ rule_active = false unless curr_secs < rule_secs
472
+ when "date"
473
+ day = Time.parse(value)
474
+ rule_active = false unless t.year==day.year and t.yday==day.yday
475
+ when "action"
476
+ # Do nothing.
477
+ else
478
+ # Do nothing.
479
+ # Err on the side of being on too long.
480
+ end # case key
481
+ end
482
+ if rule_active and rule.has_key? "action"
483
+ results << rule["action"]
484
+ end
485
+ end # each rule
486
+
487
+ if results.include? "force_on"
488
+ return true
489
+ elsif results.include? "off"
490
+ return false
491
+ elsif results.include? "on"
492
+ return true
493
+ else # All rules failed
494
+ return false
495
+ end
496
+ end #screen_scheduled_on?
497
+
498
+ # For a given time object, gives a numeric representation of the
499
+ # time of day on the day it represents.
500
+ def seconds_since_midnight(time)
501
+ time.sec + (time.min * 60) + (time.hour * 3600)
451
502
  end
452
-
453
503
  end
@@ -26,17 +26,17 @@
26
26
  <div class="default-padding">
27
27
 
28
28
  <div class="row-fluid">
29
- <div class="span3">
29
+ <div class="span2">
30
30
  &nbsp;
31
31
  </div>
32
- <div class="span6">
32
+ <div class="span8">
33
33
 
34
34
  <br />
35
35
  <%= yield %>
36
36
  <br />
37
37
 
38
38
  </div>
39
- <div class="span3">
39
+ <div class="span2">
40
40
  &nbsp;
41
41
  </div>
42
42
  </div>
@@ -14,3 +14,7 @@
14
14
  <pre>
15
15
  <%= JSON.pretty_generate(@on_off_rules) %>
16
16
  </pre>
17
+ <p>
18
+ Screen status: Scheduled
19
+ <%= screen_scheduled_on? ? "On" : "Off" %>
20
+ </p>
@@ -118,7 +118,12 @@ module Bandshell
118
118
 
119
119
  data=JSON.parse(response.body)
120
120
  if data.has_key? 'screen_temp_token'
121
- ConfigStore.write_config('auth_temp_token',data['screen_temp_token'])
121
+ # We modify the token by appending an "s".
122
+ # Concerto allows this and concerto-hardware will use it to
123
+ # recognize that the user is setting up a managed player in
124
+ # addition to a simple screen.
125
+ token = data['screen_temp_token'] + 's'
126
+ ConfigStore.write_config('auth_temp_token',token)
122
127
  return true
123
128
  end
124
129
  return false
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bandshell
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.8'
4
+ version: '0.9'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Concerto Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-22 00:00:00.000000000 Z
11
+ date: 2014-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: haml
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - '>='
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - '>='
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: sys-uptime
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -147,19 +133,12 @@ files:
147
133
  - lib/bandshell/application/public/stylesheets/sass/views/users.scss
148
134
  - lib/bandshell/application/public/trollface.png
149
135
  - lib/bandshell/application/views/authenticate.erb
150
- - lib/bandshell/application/views/authenticate.haml
151
136
  - lib/bandshell/application/views/main.erb
152
- - lib/bandshell/application/views/main.haml
153
137
  - lib/bandshell/application/views/netsettings.erb
154
- - lib/bandshell/application/views/netsettings.haml
155
138
  - lib/bandshell/application/views/password.erb
156
- - lib/bandshell/application/views/password.haml
157
139
  - lib/bandshell/application/views/player_status.erb
158
- - lib/bandshell/application/views/player_status.haml
159
140
  - lib/bandshell/application/views/problem.erb
160
- - lib/bandshell/application/views/problem.haml
161
141
  - lib/bandshell/application/views/setup.erb
162
- - lib/bandshell/application/views/setup.haml
163
142
  - lib/bandshell/config_store.rb
164
143
  - lib/bandshell/hardware_api.rb
165
144
  - lib/bandshell/live_image.rb
@@ -186,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
165
  version: '0'
187
166
  requirements: []
188
167
  rubyforge_project:
189
- rubygems_version: 2.0.3
168
+ rubygems_version: 2.0.14
190
169
  signing_key:
191
170
  specification_version: 4
192
171
  summary: Concerto Client Tools
@@ -1,15 +0,0 @@
1
- %script{:src=>"authenticate.js"}
2
-
3
- %h1 Concerto Player Authentication
4
-
5
- #no-js
6
- It looks like Javascript is disabled. The Concerto Display will not work.
7
-
8
- - unless @display_temp_token.nil?
9
- #instructions
10
- Please enter the following token when setting up the screen in the
11
- Concerto Panel:
12
- = @display_temp_token
13
-
14
- #status
15
- Waiting for first update...
@@ -1,7 +0,0 @@
1
- !!! 5
2
- %html
3
- %head
4
- %title="Concerto Player Network Configuration"
5
- %script{:src=>"https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.js"}
6
- %link{:rel=>"stylesheet", :type=>"text/css", :href=>"/stylesheets/concerto-styles.css"}
7
- %body=yield
@@ -1,64 +0,0 @@
1
- %script{:src=>"/javascripts/network.js"}
2
- %a{:href=>"/setup"}="Back to setup"
3
- %h1="Concerto Player Network Configuration"
4
- %form{:method=>"post"}
5
- %h2="Connection Type"
6
- %select#connection_type{:name=>"connection_type"}
7
- / list out our available connection methods as options
8
- / set the html selected flag on the one that is currently
9
- / selected in the config
10
- - CONNECTION_METHODS.each do |cm|
11
- %option{:value=>cm.basename,
12
- :selected=>(cm==connection_method.class)}=cm.description
13
- #connection
14
- #WiredConnection
15
- %h3="Wired Connection Settings"
16
- %p
17
- %label{:for=>"WiredConnection_interface_name"}="Interface Name"
18
- %select#interface_name{:name=>"WiredConnection/interface_name"}
19
- %option{:value=>""}="Auto Select"
20
- / list out available interfaces and their MAC addresses
21
- / preselect one if there was one chosen in config
22
- - Bandshell::WiredConnection.interfaces.each do |iface|
23
- %option{:value=>iface.name, :selected=>value_from(connection_method, :interface_name)==iface.name}="#{iface.name} - #{iface.mac}"
24
- #WirelessConnection
25
- %h3="Wireless Connection Settings (no encryption)"
26
- %p
27
- %label{:for=>"WirelessConnection_interface_name"}="Interface Name"
28
- %select#interface_name{:name=>"WirelessConnection/interface_name"}
29
- %option{:value=>""}="Auto Select"
30
- / same as above but with the wireless interfaces
31
- - Bandshell::WirelessConnection.interfaces.each do |iface|
32
- %option{:value=>iface.name, :selected=>value_from(connection_method, :interface_name) == iface.name}="#{iface.name} - #{iface.mac}"
33
- %p
34
- %label{:for=>"WirelessConnection_ssid"}="SSID"
35
- %input{:type=>"text", :name=>"WirelessConnection/ssid",
36
- :value=>value_from(connection_method, :ssid)}
37
- %h2="IP Address"
38
- %select#addressing_type{:name=>"addressing_type"}
39
- - ADDRESSING_METHODS.each do |am|
40
- %option{:value=>am.basename,
41
- :selected=>(am==addressing_method.class)}=am.description
42
- #address
43
- #DHCPAddressing
44
- #StaticAddressing
45
- %h3="Static Address Settings"
46
- %p
47
- %label{:for=>"StaticAddressing_address"}="Address"
48
- %input{:type=>"text", :name=>"StaticAddressing/address",
49
- :value=>value_from(addressing_method, :address)}
50
- %p
51
- %label{:for=>"StaticAddressing_netmask"}="Netmask"
52
- %input{:type=>"text", :name=>"StaticAddressing/netmask",
53
- :value=>value_from(addressing_method, :netmask)}
54
- %p
55
- %label{:for=>"StaticAddressing_gateway"}="Gateway"
56
- %input{:type=>"text", :name=>"StaticAddressing/gateway",
57
- :value=>value_from(addressing_method, :gateway)}
58
- %p
59
- %label{:for=>"StaticAddressing_address"}="Nameservers (separate with commas or spaces)"
60
- %input{:type=>"text", :name=>"StaticAddressing/nameservers_flat",
61
- :value=>value_from(addressing_method, :nameservers_flat)}
62
-
63
- %input{:type=>"submit"}
64
-
@@ -1,9 +0,0 @@
1
- %form{:method=>'post'}
2
- %p
3
- %label{:for=>'newpass'} New Password
4
- %input{:type=>'password', :name=>'newpass'}
5
- %p
6
- %label{:for=>'newpass_confirm'} Confirm Password
7
- %input{:type=>'password', :name=>'newpass_confirm'}
8
- %p
9
- %input{:type=>'submit', :value=>'Change Password'}
@@ -1,11 +0,0 @@
1
- %p System Uptime: #{Uptime.uptime}
2
-
3
- %p System Processes:
4
- %ul
5
- - for p in @proctable
6
- %li
7
- %b= p.comm
8
- (PID #{p.pid.to_s})
9
-
10
- %p Screen on/off rules:
11
- %pre= JSON.pretty_generate(@on_off_rules)
@@ -1,15 +0,0 @@
1
- %script{:src=>"problem.js"}
2
- .error
3
- %p
4
- %img{:src=>"trollface.png"}
5
-
6
- %h1 Problem?
7
- %p
8
- Due to technical difficulties, this Concerto screen is currently not
9
- operational. Please check again soon.
10
- %p
11
- ==The Concerto installation at #{concerto_url} could not be reached.
12
- %p
13
- If the URL needs to be changed, go back to
14
- %a{:href=>"/setup"}
15
- Player Configuration
@@ -1,30 +0,0 @@
1
- %h1 Welcome to Concerto Player
2
- %p
3
- You're seeing this because your Concerto player has not yet been configured.
4
- We need the URL of your Concerto instance before we can get up and running.
5
-
6
- - unless @errors.nil?
7
- - @errors.each do |error|
8
- %p{:style=>'color:red'}= error
9
-
10
-
11
- %form{:method=>'post'}
12
- %p
13
- %label{:for=>'url'} URL
14
- %input{:type=>'text', :name=>'url', :value=>@url}
15
- %input{:type=>'submit', :value=>'Here it is!'}
16
-
17
- %p
18
- The IPv4 address of this screen appears to be:
19
- =my_ip
20
- %p
21
- ==This page can be accessed remotely via http://#{my_ip}:#{my_port}/setup
22
- %p
23
- Username is root, default password is 'default'.
24
- %p
25
- Also, you may want to
26
- %a{:href=>'/netconfig'} change network settings
27
- or
28
- %a{:href=>'/password'} change the configuration password.
29
-
30
-