subduino 0.2.1 → 0.2.2

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.
Files changed (267) hide show
  1. data/VERSION +1 -1
  2. data/bin/subduino +18 -5
  3. data/duino/Makefile +2 -3
  4. data/duino/duino.pde +97 -66
  5. data/lib/subduino/ard_io.rb +33 -14
  6. data/lib/subduino/ard_ps.rb +47 -24
  7. data/lib/subduino/os.rb +49 -0
  8. data/lib/subduino/parse/bool.rb +1 -1
  9. data/lib/subduino/parse/energy.rb +18 -0
  10. data/lib/subduino/parse/flow.rb +13 -0
  11. data/lib/subduino/parse/lux.rb +1 -1
  12. data/lib/subduino/parse/presence.rb +9 -0
  13. data/lib/subduino/parse/pressure.rb +13 -0
  14. data/lib/subduino/parse/temp.rb +1 -1
  15. data/lib/subduino/parse.rb +3 -3
  16. data/lib/subduino/scaffold/Makefile +72 -73
  17. data/lib/subduino/scaffold/scaffold.pde +77 -0
  18. data/lib/subduino/store.rb +1 -1
  19. data/spec/subduino/parse_spec.rb +1 -1
  20. data/subduino.gemspec +8 -249
  21. metadata +8 -249
  22. data/webapp/Gemfile +0 -8
  23. data/webapp/Gemfile.lock +0 -14
  24. data/webapp/Rakefile +0 -49
  25. data/webapp/Readme.textile +0 -45
  26. data/webapp/VERSION +0 -1
  27. data/webapp/config.yml +0 -20
  28. data/webapp/lib/app.rb +0 -103
  29. data/webapp/lib/duino.rb +0 -206
  30. data/webapp/lib/environment.rb +0 -36
  31. data/webapp/lib/messenger.rb +0 -16
  32. data/webapp/public/app.css +0 -119
  33. data/webapp/public/app.js +0 -34
  34. data/webapp/public/custom.js +0 -187
  35. data/webapp/public/date_input.css +0 -149
  36. data/webapp/public/facebox.css +0 -83
  37. data/webapp/public/facebox.js +0 -319
  38. data/webapp/public/favicon.ico +0 -0
  39. data/webapp/public/faye.js +0 -1
  40. data/webapp/public/icons/alarm-clock-blue.png +0 -0
  41. data/webapp/public/icons/alarm-clock.png +0 -0
  42. data/webapp/public/icons/balloon-left.png +0 -0
  43. data/webapp/public/icons/bandaid.png +0 -0
  44. data/webapp/public/icons/bell-disable.png +0 -0
  45. data/webapp/public/icons/bell.png +0 -0
  46. data/webapp/public/icons/big_icon.png +0 -0
  47. data/webapp/public/icons/bomb.png +0 -0
  48. data/webapp/public/icons/bookmark.png +0 -0
  49. data/webapp/public/icons/box-label.png +0 -0
  50. data/webapp/public/icons/brightness-control-up.png +0 -0
  51. data/webapp/public/icons/brightness-control.png +0 -0
  52. data/webapp/public/icons/brightness-small.png +0 -0
  53. data/webapp/public/icons/broom.png +0 -0
  54. data/webapp/public/icons/bug.png +0 -0
  55. data/webapp/public/icons/calculator.png +0 -0
  56. data/webapp/public/icons/calendar-day.png +0 -0
  57. data/webapp/public/icons/camera.png +0 -0
  58. data/webapp/public/icons/cards-address.png +0 -0
  59. data/webapp/public/icons/chart.png +0 -0
  60. data/webapp/public/icons/clock-select.png +0 -0
  61. data/webapp/public/icons/color.png +0 -0
  62. data/webapp/public/icons/compass.png +0 -0
  63. data/webapp/public/icons/control-power-small.png +0 -0
  64. data/webapp/public/icons/control-power.png +0 -0
  65. data/webapp/public/icons/control-record-small.png +0 -0
  66. data/webapp/public/icons/cpus.png +0 -0
  67. data/webapp/public/icons/credit-card.png +0 -0
  68. data/webapp/public/icons/cross-small.png +0 -0
  69. data/webapp/public/icons/current.png +0 -0
  70. data/webapp/public/icons/dashboard.png +0 -0
  71. data/webapp/public/icons/database.png +0 -0
  72. data/webapp/public/icons/databases.png +0 -0
  73. data/webapp/public/icons/day.png +0 -0
  74. data/webapp/public/icons/door-big.png +0 -0
  75. data/webapp/public/icons/door-open-in.png +0 -0
  76. data/webapp/public/icons/door-open-out.png +0 -0
  77. data/webapp/public/icons/door-open.png +0 -0
  78. data/webapp/public/icons/door.png +0 -0
  79. data/webapp/public/icons/drive-globe.png +0 -0
  80. data/webapp/public/icons/equalizer.png +0 -0
  81. data/webapp/public/icons/exclamation-diamond.png +0 -0
  82. data/webapp/public/icons/exclamation.png +0 -0
  83. data/webapp/public/icons/eye-disable.png +0 -0
  84. data/webapp/public/icons/eye.png +0 -0
  85. data/webapp/public/icons/false.png +0 -0
  86. data/webapp/public/icons/favicon.png +0 -0
  87. data/webapp/public/icons/gear-small.png +0 -0
  88. data/webapp/public/icons/gear.png +0 -0
  89. data/webapp/public/icons/groups.png +0 -0
  90. data/webapp/public/icons/heart.png +0 -0
  91. data/webapp/public/icons/heart_empty.png +0 -0
  92. data/webapp/public/icons/info.png +0 -0
  93. data/webapp/public/icons/irrigation.png +0 -0
  94. data/webapp/public/icons/key.png +0 -0
  95. data/webapp/public/icons/lamp-big.png +0 -0
  96. data/webapp/public/icons/lightbulb.png +0 -0
  97. data/webapp/public/icons/lightbulb_off.png +0 -0
  98. data/webapp/public/icons/lightning-disable.png +0 -0
  99. data/webapp/public/icons/lightning-small.png +0 -0
  100. data/webapp/public/icons/lightning.png +0 -0
  101. data/webapp/public/icons/lock-unlock.png +0 -0
  102. data/webapp/public/icons/lock.png +0 -0
  103. data/webapp/public/icons/locked.png +0 -0
  104. data/webapp/public/icons/lux.png +0 -0
  105. data/webapp/public/icons/marker.png +0 -0
  106. data/webapp/public/icons/media-player-phone.png +0 -0
  107. data/webapp/public/icons/megaphone.png +0 -0
  108. data/webapp/public/icons/mem.png +0 -0
  109. data/webapp/public/icons/microphone.png +0 -0
  110. data/webapp/public/icons/monitor.png +0 -0
  111. data/webapp/public/icons/navigation.png +0 -0
  112. data/webapp/public/icons/night.png +0 -0
  113. data/webapp/public/icons/noise.png +0 -0
  114. data/webapp/public/icons/off.png +0 -0
  115. data/webapp/public/icons/on.png +0 -0
  116. data/webapp/public/icons/onoff.png +0 -0
  117. data/webapp/public/icons/pin.png +0 -0
  118. data/webapp/public/icons/plug--exclamation.png +0 -0
  119. data/webapp/public/icons/plug-disable.png +0 -0
  120. data/webapp/public/icons/plug.png +0 -0
  121. data/webapp/public/icons/rain.png +0 -0
  122. data/webapp/public/icons/refrigeration.png +0 -0
  123. data/webapp/public/icons/restart.png +0 -0
  124. data/webapp/public/icons/ruby.png +0 -0
  125. data/webapp/public/icons/server.png +0 -0
  126. data/webapp/public/icons/shield-disable.png +0 -0
  127. data/webapp/public/icons/shield.png +0 -0
  128. data/webapp/public/icons/socket--exclamation.png +0 -0
  129. data/webapp/public/icons/socket-disable.png +0 -0
  130. data/webapp/public/icons/socket.png +0 -0
  131. data/webapp/public/icons/start.png +0 -0
  132. data/webapp/public/icons/stop.png +0 -0
  133. data/webapp/public/icons/switch--exclamation.png +0 -0
  134. data/webapp/public/icons/switch-disable.png +0 -0
  135. data/webapp/public/icons/switch-small.png +0 -0
  136. data/webapp/public/icons/switch.png +0 -0
  137. data/webapp/public/icons/target.png +0 -0
  138. data/webapp/public/icons/television-off.png +0 -0
  139. data/webapp/public/icons/television.png +0 -0
  140. data/webapp/public/icons/temp.png +0 -0
  141. data/webapp/public/icons/terminal.png +0 -0
  142. data/webapp/public/icons/tick-small.png +0 -0
  143. data/webapp/public/icons/traffic-light-off.png +0 -0
  144. data/webapp/public/icons/traffic-light.png +0 -0
  145. data/webapp/public/icons/traffic.png +0 -0
  146. data/webapp/public/icons/true.png +0 -0
  147. data/webapp/public/icons/umbrella.png +0 -0
  148. data/webapp/public/icons/unlocked.png +0 -0
  149. data/webapp/public/icons/unmonitor.png +0 -0
  150. data/webapp/public/icons/unmonitored.png +0 -0
  151. data/webapp/public/icons/users.png +0 -0
  152. data/webapp/public/icons/vcard.png +0 -0
  153. data/webapp/public/icons/wall.png +0 -0
  154. data/webapp/public/icons/wall_brick.png +0 -0
  155. data/webapp/public/icons/wall_disable.png +0 -0
  156. data/webapp/public/icons/wand-disable.png +0 -0
  157. data/webapp/public/icons/wand.png +0 -0
  158. data/webapp/public/icons/warn.png +0 -0
  159. data/webapp/public/icons/weather_clouds.png +0 -0
  160. data/webapp/public/icons/weather_cloudy.png +0 -0
  161. data/webapp/public/icons/weather_lightning.png +0 -0
  162. data/webapp/public/icons/weather_rain.png +0 -0
  163. data/webapp/public/icons/weather_snow.png +0 -0
  164. data/webapp/public/icons/weather_sun.png +0 -0
  165. data/webapp/public/icons/wrench-screwdriver.png +0 -0
  166. data/webapp/public/icons/wrench.png +0 -0
  167. data/webapp/public/images/ajax-loader.gif +0 -0
  168. data/webapp/public/images/b.png +0 -0
  169. data/webapp/public/images/bendl.gif +0 -0
  170. data/webapp/public/images/bendr.gif +0 -0
  171. data/webapp/public/images/bendsb.gif +0 -0
  172. data/webapp/public/images/bg.jpg +0 -0
  173. data/webapp/public/images/bhead.gif +0 -0
  174. data/webapp/public/images/bheadl.gif +0 -0
  175. data/webapp/public/images/bheadr.gif +0 -0
  176. data/webapp/public/images/bl.png +0 -0
  177. data/webapp/public/images/bnd.gif +0 -0
  178. data/webapp/public/images/br.png +0 -0
  179. data/webapp/public/images/bread.gif +0 -0
  180. data/webapp/public/images/btnb.gif +0 -0
  181. data/webapp/public/images/btnb_.gif +0 -0
  182. data/webapp/public/images/btnm.gif +0 -0
  183. data/webapp/public/images/btnm_.gif +0 -0
  184. data/webapp/public/images/btns.gif +0 -0
  185. data/webapp/public/images/btns_.gif +0 -0
  186. data/webapp/public/images/cal.jpg +0 -0
  187. data/webapp/public/images/close.png +0 -0
  188. data/webapp/public/images/closelabel.gif +0 -0
  189. data/webapp/public/images/error.gif +0 -0
  190. data/webapp/public/images/ft.gif +0 -0
  191. data/webapp/public/images/hdr.gif +0 -0
  192. data/webapp/public/images/hdrl.gif +0 -0
  193. data/webapp/public/images/hdrr.gif +0 -0
  194. data/webapp/public/images/hld.jpg +0 -0
  195. data/webapp/public/images/imgb.gif +0 -0
  196. data/webapp/public/images/imgo.gif +0 -0
  197. data/webapp/public/images/imgt.gif +0 -0
  198. data/webapp/public/images/info.gif +0 -0
  199. data/webapp/public/images/jquery.wysiwyg.gif +0 -0
  200. data/webapp/public/images/li.gif +0 -0
  201. data/webapp/public/images/mbg.png +0 -0
  202. data/webapp/public/images/nsp.gif +0 -0
  203. data/webapp/public/images/phs.gif +0 -0
  204. data/webapp/public/images/sdd.jpg +0 -0
  205. data/webapp/public/images/sdd_.jpg +0 -0
  206. data/webapp/public/images/sidebar.gif +0 -0
  207. data/webapp/public/images/sorta.gif +0 -0
  208. data/webapp/public/images/sortd.gif +0 -0
  209. data/webapp/public/images/srch.gif +0 -0
  210. data/webapp/public/images/srch_.gif +0 -0
  211. data/webapp/public/images/success.gif +0 -0
  212. data/webapp/public/images/thumb1.jpg +0 -0
  213. data/webapp/public/images/thumb2.jpg +0 -0
  214. data/webapp/public/images/thumb3.jpg +0 -0
  215. data/webapp/public/images/tiny.gif +0 -0
  216. data/webapp/public/images/tiny_.gif +0 -0
  217. data/webapp/public/images/tl.png +0 -0
  218. data/webapp/public/images/tr.png +0 -0
  219. data/webapp/public/images/upload.gif +0 -0
  220. data/webapp/public/images/warning.gif +0 -0
  221. data/webapp/public/iui/backButton.png +0 -0
  222. data/webapp/public/iui/blueButton.png +0 -0
  223. data/webapp/public/iui/cancel.png +0 -0
  224. data/webapp/public/iui/grayButton.png +0 -0
  225. data/webapp/public/iui/greenButton.png +0 -0
  226. data/webapp/public/iui/iui-logo-touch-icon.png +0 -0
  227. data/webapp/public/iui/iui.css +0 -396
  228. data/webapp/public/iui/iui.js +0 -511
  229. data/webapp/public/iui/iuix.css +0 -1
  230. data/webapp/public/iui/iuix.js +0 -1
  231. data/webapp/public/iui/listArrow.png +0 -0
  232. data/webapp/public/iui/listArrowSel.png +0 -0
  233. data/webapp/public/iui/listGroup.png +0 -0
  234. data/webapp/public/iui/loading.gif +0 -0
  235. data/webapp/public/iui/pinstripes.png +0 -0
  236. data/webapp/public/iui/redButton.png +0 -0
  237. data/webapp/public/iui/selection.png +0 -0
  238. data/webapp/public/iui/thumb.png +0 -0
  239. data/webapp/public/iui/toggle.png +0 -0
  240. data/webapp/public/iui/toggleOn.png +0 -0
  241. data/webapp/public/iui/toolButton.png +0 -0
  242. data/webapp/public/iui/toolbar.png +0 -0
  243. data/webapp/public/iui/whiteButton.png +0 -0
  244. data/webapp/public/iui/yellowButton.png +0 -0
  245. data/webapp/public/jquery.img.preload.js +0 -152
  246. data/webapp/public/jquery.js +0 -154
  247. data/webapp/public/jquery.sparkline.js +0 -85
  248. data/webapp/public/jquery.tablesorter.min.js +0 -2
  249. data/webapp/public/jquery.visualize.js +0 -452
  250. data/webapp/public/jquery.wysiwyg.css +0 -56
  251. data/webapp/public/layout.css +0 -33
  252. data/webapp/public/right.js +0 -9
  253. data/webapp/public/rt.js +0 -7
  254. data/webapp/public/sparkline.js +0 -85
  255. data/webapp/public/style.css +0 -881
  256. data/webapp/public/visualize.css +0 -32
  257. data/webapp/spec/duino_spec.rb +0 -8
  258. data/webapp/spec/spec_helper.rb +0 -10
  259. data/webapp/views/command.haml +0 -4
  260. data/webapp/views/icon.haml +0 -6
  261. data/webapp/views/index.haml +0 -367
  262. data/webapp/views/layout.haml +0 -88
  263. data/webapp/views/mobile.haml +0 -21
  264. data/webapp/views/switch.haml +0 -56
  265. data/webapp/views/template.haml +0 -676
  266. data/webapp/views/top.haml +0 -4
  267. data/webapp/views/watch.haml +0 -26
@@ -1,45 +0,0 @@
1
- h2. Description
2
-
3
- Friendly web "Arduino":http://arduino.cc
4
-
5
- h2. Screenshots
6
-
7
-
8
- h3. Requirements
9
-
10
- * "Sinatra":http://sinatrarb.com/
11
-
12
- h3. Install
13
-
14
-
15
- gem install duino
16
-
17
- h2. Usage
18
-
19
- username: foo
20
- </pre>
21
-
22
- h2. Contributing
23
-
24
- duino uses "ditz":http://ditz.rubyforge.org for issue tracking. Fork
25
- duino, clone your copy and then run:
26
-
27
- @ditz todo@
28
-
29
- For more details on a specific issue:
30
-
31
- @ditz show duino-1@
32
-
33
- Make your changes that fix a bug, then resolve it.
34
-
35
- @ditz close duino-1@
36
-
37
- Commit, push your changes to GitHub, then send a pull request!
38
-
39
- h3. Author
40
-
41
- nofxx
42
-
43
- h3. License
44
-
45
- "WTFPL":http://sam.zoy.org/wtfpl/
data/webapp/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.1.0
data/webapp/config.yml DELETED
@@ -1,20 +0,0 @@
1
- ---
2
- log_interval: 60
3
- inputs:
4
- i1:
5
- type: Temp
6
- name: Cafofo temp
7
- i2:
8
- type: Temp
9
- name: Out temp
10
- i3:
11
- type: Lux
12
- name: Cafofo light
13
- # i2:
14
- # i3:
15
- # i4:
16
- # i5:
17
- outputs:
18
- d2:
19
- type: door
20
- name: Cafofo door
data/webapp/lib/app.rb DELETED
@@ -1,103 +0,0 @@
1
-
2
- helpers do
3
-
4
- def get_layout
5
- return false if request.env['HTTP_XHR']
6
- case request.env['HTTP_USER_AGENT']
7
- when /iPhone|iPod/ then :mobile
8
- when /Android|Nokia/ then :mobile
9
- else true
10
- end
11
- end
12
-
13
- end # helpers
14
-
15
- before do
16
- unless (DUINO_CONFIG['username'].nil? && DUINO_CONFIG['password'].nil?) || self.request.path_info == '/heartbeat'
17
- use Rack::Auth::Basic do |user, pass|
18
- [user, pass] == [DUINO_CONFIG['username'], DUINO_CONFIG['password']]
19
- end
20
- end
21
- # DUINO.ping
22
- end
23
-
24
-
25
-
26
- set :haml, {:format => :html5 }
27
-
28
-
29
-
30
-
31
- get '/' do
32
- @statuses = DUINO.status
33
- @watches = []
34
- # @statuses.each do |watch, status|
35
- # @watches << watch.to_s
36
- # end
37
- # @watches = @watches.group_by { |w| @statuses[w][:state].to_s }
38
- @sensors = DUINO.sensors || []
39
- @host = `hostname`
40
- @stats = Duino.cpu_status
41
- @footer = "Subduino www v0.0.1 - #{@host}"
42
- show(:index, @host)
43
- end
44
-
45
-
46
- get '/o' do
47
- @commands = %w{ false false }
48
- @watch = :all
49
- show(:switch, "Pins Switch")
50
- end
51
-
52
- get '/i' do
53
- @text = `hostname`
54
- show(:icon)
55
- end
56
-
57
- get '/t' do
58
- @text = `top -Hibn 1`.gsub("top - ", "")
59
- show(:top)
60
- end
61
-
62
- get '/heartbeat' do
63
- @statuses = DUINO.status
64
- 'OK'
65
- end
66
-
67
- get '/w/:watch' do
68
- @watch = params["watch"]
69
- @status = DUINO.status[@watch][:state]
70
- @commands = Duino.possible_statuses(@status)
71
- @log = DUINO.last_log(@watch)
72
- show(:switch, @watch)
73
- end
74
-
75
- get '/w/:watch/:command' do
76
- @watch = params["watch"]
77
- @command = params["command"]
78
- @success = DUINO.switch(@watch, @command)
79
- # @success = false if @success == []
80
- @log = DUINO.last_log(@watch)
81
- show(:command, "#{@command}ing #{@watch}")
82
- end
83
-
84
- get '/g/:sensor' do
85
- @watch = params["sensor"]
86
- @name, @sensor = *DUINO.sensors(@watch).to_a[0]
87
- @name = @name.capitalize
88
- @log = DUINO.log @watch
89
- # @child = DUINO.status.keys.each.select { |k| DUINO.status[k][:sensor] == @sensor } #.select { |w| w["sensor"] = @sensor }
90
- # @child.map!{ |c| [c, DUINO.status[c][:state]]}
91
- # @status = nil
92
- # @commands = Duino.possible_statuses(@status)
93
- show(:watch, "#{@name} #{@sensor} [sensor]")
94
- end
95
-
96
-
97
- private
98
-
99
- def show(template, title = 'Duino')
100
- @title = title
101
- request.env['HTTP_XHR']
102
- haml(template, :layout => get_layout)
103
- end
data/webapp/lib/duino.rb DELETED
@@ -1,206 +0,0 @@
1
-
2
- class Duino
3
-
4
- Config = YAML.load(File.read("config.yml"))
5
-
6
- def initialize(config)
7
- @config = config
8
- @redis = Redis.new(:timeout => 0)
9
- end
10
-
11
- def sensors(one=nil)
12
- sensors = Config["inputs"]
13
- # s = one ? Sensors.select { |k,v| k.to_s == one.to_s } : Sensors
14
- sensors.map do |s|
15
- p s
16
- val = @redis.get(s[0]) #rescue nil
17
- next unless val
18
- Subduino::Parse.work(s[1]["type"], val, s[1]["name"])
19
- end.reject(&:nil?)
20
- end
21
-
22
- def switch(pins, comm)
23
- comm = Message.new(comm =~ /start/).txt
24
- puts "[OUT] #{pins} #{comm}"
25
- command(comm)
26
- end
27
-
28
- def log(n)
29
- key = n + "_log"
30
- size = @redis.llen key
31
- @redis.lrange key, size - 100, size
32
- end
33
-
34
- # ping server to ensure that it is responsive
35
- def ping
36
- tries = 3
37
- begin
38
- # @server.ping
39
- rescue Exception => e
40
- retry if (tries -= 1) > 1
41
- raise e, "The server is not available (or you do not have permissions to access it)"
42
- end
43
- end
44
-
45
- def last_log(watch)
46
- format_log(log_command(watch, true))
47
- end
48
-
49
- def self.possible_statuses(status)
50
- # need to check, but god doesn't have a monitored and offline state...
51
- case status
52
- when :up then [true, true] #%w{start monitor}
53
- when :unmonitored then [false, false] #%w{start monitor}
54
- else [] # nil #[false, false] #%w{start stop restart}
55
- end
56
- end
57
-
58
- def self.ram_status
59
- mem = `free -mo`.split(" ")
60
- used, free, cached, swap = mem[8], mem[9], mem[12], mem[15]
61
- end
62
-
63
- def self.cpu_status
64
- #stat = `cat /proc/stat`.split(" ")
65
- # top = `top -bn 1`
66
- # info, tasks, cpus, mem, swap, *rest = *top
67
- # # Use array to keep order (ruby < 1.9)
68
- # [[:info, info.gsub(/top - |\d{2}:\d{2}(:\d{2})?(\s|,)|\saverage/, "")],
69
- # [:cpus, cpus.gsub("Cpu\(s\): ", "").split(", ")[0..4].join(", ")],
70
- # [:mem, mem.gsub("Mem: ", "").gsub(/(\d*k)/) { ($1.to_i / 1000).to_s }]]
71
- []
72
- end
73
- def status
74
- status_command
75
- end
76
-
77
- private
78
-
79
- def command(line)
80
- @redis.publish('subduin', line) unless line.empty?
81
- end
82
-
83
-
84
- # def method_missing(meth,*args)
85
- # if %w{groups status log quit terminate}.include?(meth.to_s)
86
- # ping
87
- # send("#{meth}_command")
88
- # # elsif %w{start stop restart unmonitor monitor}.include?(meth.to_s)
89
- # # ping
90
- # # lifecycle_command(args.first, meth.to_s)
91
- # else
92
- # raise NoMethodError, meth
93
- # end
94
- # end
95
-
96
- def groups_command
97
- groups = []
98
- @server.groups.each do |key, value|
99
- groups << key
100
- end
101
- groups.sort
102
- end
103
-
104
- def status_command
105
- # @server.status
106
- end
107
-
108
- #
109
- # To make it look good (no horiz scrollbars) in the iphone
110
- #
111
- def format_log(raw)
112
- return "..." unless raw
113
- raw.split("\n").map do |l|
114
- # clean stuff we don't need
115
- l.gsub!(/I\s+|\(\w*\)|within bounds/, "") # gsub(/\(\w*\)/, """)
116
- # if ok, span is green
117
- ok = l =~ /\[ok\]/
118
- if l =~ /\[\w*\]/
119
- # get some data we want...
120
- l.gsub(/\[\S*\s(\S*)\]\W+INFO: (\w*-?\w*|.*)?\s\[(\w*)?\]/, "<span class='gray'>\\1</span> | <span class='#{ok ? 'green' : 'red'}'>\\3</span> |").
121
- # take only the integer from cpu
122
- gsub(/cpu/, "cpu %").gsub(/(\d{1,3})\.\d*%/, "\\1").
123
- # show mem usage in mb
124
- gsub(/memory/, "mem mb").gsub(/(\d*kb)/) { ($1.to_i / 1000).to_s }
125
- else
126
- l.gsub(/\[\S*\s(\S*)\]\W+INFO: \w*\s(\w*)/, "<span class='gray'>\\1</span> | <span class='act'>act</span> | \\2")
127
- end
128
-
129
- end.reverse.join("</br>")
130
- end
131
-
132
- #TODO
133
- def log_command(name, sample=false)
134
- # begin
135
- # Signal.trap('INT') { exit }
136
- # # name = @args[1]
137
-
138
- # unless name
139
- # puts "You must specify a Task or Group name"
140
- # exit!
141
- # end
142
-
143
- # t = Time.at(0)
144
- # if sample
145
- # @server.running_log(name, t)
146
- # else
147
- # loop do
148
- # @server.running_log(name, t)
149
- # t = Time.now
150
- # sleep 1
151
- # end
152
- # end
153
- # rescue God::NoSuchWatchError
154
- # puts "No such watch"
155
- # rescue DRb::DRbConnError
156
- # puts "The server went away"
157
- # end
158
- end
159
-
160
- def quit_command
161
- begin
162
- @server.terminate
163
- return false
164
- rescue DRb::DRbConnError
165
- return true
166
- end
167
- end
168
-
169
- def terminate_command
170
- stopped_all = false
171
- if @server.stop_all
172
- stopped_all = true
173
- end
174
-
175
- begin
176
- @server.terminate
177
- return false
178
- rescue DRb::DRbConnError
179
- return stopped_all
180
- end
181
- end
182
-
183
-
184
- def lifecycle_command(*args)
185
- # get the name of the watch/group
186
- name = args.first
187
- command = args.last
188
-
189
- # send @command
190
- watches = @server.control(name, command)
191
-
192
- watches.empty? ? [] : watches
193
- end
194
-
195
- end
196
-
197
-
198
- # def halt!
199
- # puts "Closing server"
200
- # @redis.quit
201
- # puts "..."
202
- # exit
203
- # end
204
-
205
- # trap(:TERM) { halt! }
206
- # trap(:INT) { halt! }
@@ -1,36 +0,0 @@
1
- #!/usr/bin/env ruby
2
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__)))
3
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', '..', 'lib'))
4
-
5
- require 'rubygems'
6
- require 'sinatra'
7
- require 'eventmachine'
8
- require 'readline'
9
- require 'redis'
10
- require 'stringio'
11
- require 'yaml'
12
- require 'haml'
13
- require 'optparse'
14
- require 'duino'
15
- require 'subduino/parse'
16
-
17
- config = {
18
- 'username' => nil,
19
- 'password' => nil
20
- }
21
-
22
- begin
23
- config.merge!(YAML.load(File.read(ARGV[0])))
24
- DUINO_CONFIG = config
25
- rescue
26
- DUINO_CONFIG = config
27
- end
28
- DUINO = Duino.new(config)
29
-
30
- # Require app
31
- require "messenger"
32
- include Messenger
33
- require "app"
34
-
35
- Sinatra::Application.public = File.dirname(__FILE__) + "/../public"
36
- Sinatra::Application.views = File.dirname(__FILE__) + "/../views"
@@ -1,16 +0,0 @@
1
- module Messenger
2
- class Message
3
- PINS = (0..12).to_a
4
- LOW = 0
5
- HIGH = 250
6
-
7
- def initialize(txt=nil)
8
- @txt = PINS.map { |p| txt ? HIGH : LOW }.join(" ")
9
- end
10
-
11
- def txt
12
- @txt
13
- end
14
- end
15
-
16
- end
@@ -1,119 +0,0 @@
1
- body {
2
- color: #222;
3
- }
4
-
5
- .home_icon_div {
6
- padding-top: 80px;
7
- background: transparent url(../icons/big_icon.png) no-repeat scroll center center;
8
- height: 300px;
9
- }
10
-
11
- .home_icon_txt {
12
- font-size: 4em;
13
- font-weight: bold;
14
- color: #2f6a9f;
15
- text-shadow: rgba(255, 255, 255, 0.75) 2px 2px 0;
16
- margin-bottom: 50px
17
- }
18
-
19
- .home_icon_info {
20
- position: absolute
21
- top: -100px
22
- font-size: 1em;
23
- margin-bottom: 100px;
24
- font-weight: bold;
25
- color: #eee
26
- }
27
-
28
- fieldset > ul {
29
- padding: 0px 10px;
30
- }
31
-
32
- fieldset > ul > li {
33
- text-align: left;
34
- background:#FFFFFF none repeat scroll 0 0;
35
- position: relative;
36
- margin: 0;
37
- border-bottom: 1px solid #E0E0E0;
38
- padding: 8px 0 8px 0px;
39
- font-size: 20px;
40
- font-weight: bold;
41
- list-style: none;
42
- }
43
-
44
- fieldset > ul > li > a {
45
- display: block;
46
- margin: -8px 0 -8px -10px;
47
- padding: 8px 32px 8px 10px;
48
- text-decoration: none;
49
- color: inherit;
50
- background: url(iui/listArrow.png) no-repeat right center;
51
- }
52
-
53
- li img {
54
- border:medium none;
55
- float:left;
56
- margin:4px 8px 0px 0px;
57
- }
58
-
59
- .pico {font-size: 0.6em; }
60
- .tiny {font-size: 0.8em; }
61
- li.tiny img { margin-top: 0px; }
62
-
63
- .gray { color: #aaa; }
64
-
65
- .green {
66
- color: #00aa00;
67
- font-weight: bold;
68
- }
69
- .red {
70
- color: #aa0000;
71
- font-weight: bold;
72
- }
73
- .act {
74
- color: #999900;
75
- font-weight: bold;
76
- }
77
-
78
- .yellowButton,
79
- .greenButton {
80
- display: block;
81
- border-width: 0 12px;
82
- padding: 10px;
83
- text-align: center;
84
- font-size: 20px;
85
- font-weight: bold;
86
- text-decoration: inherit;
87
- color: inherit;
88
- }
89
-
90
- .greenButton {
91
- -webkit-border-image: url(../iui/greenButton.png) 0 12 0 12;
92
- color:#fff;
93
- text-shadow: #007a00 0 -1px 0;
94
- }
95
-
96
- .yellowButton {
97
- -webkit-border-image: url(../iui/yellowButton.png) 0 12 0 12;
98
- color:#fff;
99
- text-shadow: #007a7a 0 -1px 0;
100
- }
101
-
102
- .code {
103
- font-size: 14px;
104
- font-family: Courier;
105
- color: #33EE33;
106
- background-color: #222;
107
- padding-left: 15px;
108
- white-space: nowrap;
109
- overflow: auto;
110
- padding-top: 8px;
111
- }
112
-
113
-
114
- /* PC */
115
-
116
- .right {
117
- width: 50%;
118
- float: right;
119
- }
data/webapp/public/app.js DELETED
@@ -1,34 +0,0 @@
1
- //FIXME: grr... bug if you run once, cancel, and try to run on another watch (hate js..)
2
- function submitCommand(action, watch) {
3
- var comm;
4
- var act;
5
- var s;
6
-
7
- if (document.getElementById("toggle_" + action)) {
8
- act = document.getElementById("toggle_" + action);
9
- s = act.getAttribute("toggled");
10
-
11
- if(action == "power") {
12
- comm = (s == "true") ? "start" : "stop";
13
- } else {
14
- comm = (s == "true") ? "monitor" : "unmonitor";
15
- }
16
- } else {
17
- comm = action;
18
- }
19
-
20
- // if (confirm("God will " + comm + " " + watch + "..")) {
21
- //var results = document.getElementById("results");
22
- var divTag = document.createElement("div");
23
- divTag.id = "cresult";
24
- document.body.appendChild(divTag);
25
- var res = document.getElementById("cresult");
26
-
27
- // res.innerHTML = "";
28
- iui.showPageByHref("/w/" + watch + "/" + comm, null, null, res, null);
29
- // } else {
30
- //act.setAttribute("toggled", (s == "true") ? "false" : "true");
31
- // }
32
- return false;
33
- }
34
-