Class: IsaacToolbelt::Device
- Inherits:
-
Thor
- Object
- Thor
- IsaacToolbelt::Device
show all
- Includes:
- Helper
- Defined in:
- lib/isaac_toolbelt.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Helper
#check_file, #config_network, #host, #mkdir_if_not, #reboot, #ssh_run_command, #temp_path, #transfer_files, #upload_string_as_file, #waitfor, #waitfor_network
Class Method Details
.curl(url, save_dir) ⇒ Object
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
|
# File 'lib/isaac_toolbelt.rb', line 214
def self.curl(url, save_dir)
filename = url.split('/').last
filepath = File.join(save_dir, filename)
curl = Curl::Easy.new
curl.url = url
curl.follow_location = true
print "Downloads: '#{curl.url}'"
File.open(filepath, 'wb') do |f|
bar = ProgressBar.create(:title => filename, :starting_at => 0)
curl.on_progress do |dl_total, dl_now, ul_total, ul_now|
if dl_total > dl_now
bar.total = dl_total
bar.progress = dl_now
end
true
end
curl.on_body do |data|
f << data; data.size
end
curl.perform
puts "=> '#{filepath}'"
end
return filename
end
|
Instance Method Details
#_reboot ⇒ Object
351
352
353
|
# File 'lib/isaac_toolbelt.rb', line 351
def _reboot
reboot
end
|
#config_access_key(access_key) ⇒ Object
312
313
314
|
# File 'lib/isaac_toolbelt.rb', line 312
def config_access_key(access_key)
configure_access_key(access_key)
end
|
#config_wifi ⇒ Object
320
321
322
|
# File 'lib/isaac_toolbelt.rb', line 320
def config_wifi
configure_wifi(options[:ssid], options[:wpa])
end
|
#console ⇒ Object
326
327
328
|
# File 'lib/isaac_toolbelt.rb', line 326
def console
ssh_run_command('')
end
|
#info ⇒ Object
298
299
300
301
302
303
304
305
306
307
308
309
|
# File 'lib/isaac_toolbelt.rb', line 298
def info
uname = get_uname()
conf = get_conf()
rjust_count = 20
print "Operating System: ".rjust(rjust_count, ' ')
puts "#{uname}"
print "Access Key: ".rjust(rjust_count, ' ')
puts "#{conf['access_key']}"
end
|
#init ⇒ Object
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
|
# File 'lib/isaac_toolbelt.rb', line 243
def init
unless !!find_executable('dfu-util')
STDERR.puts 'dfu-util is not installed!'
STDERR.puts 'try: brew install dfu-util'
exit 1
end
= prepare_os_image()
flash_os_image()
waitfor
configure_wifi(options[:ssid], options[:wpa])
waitfor_network
SSHKit::Coordinator.new(host).each do
execute :pip, *%w(install --upgrade pip)
execute :pip, *%w(install --upgrade setuptools)
execute :rm, *%w(-rf /usr/lib/python2.7/site-packages/distribute*)
requirements = StringIO.new(REQUIREMENTS_TXT)
dst = '/tmp/requirements.txt'
upload! requirements, dst
execute :pip, *%w(install -r), dst
end
if options[:access_key]
set_conf({'access_key' => options[:access_key]})
SSHKit::Coordinator.new(host).each do
execute :systemctl, *%w(enable isaacd)
end
end
reboot
puts 'Your device is ready to develop!'
end
|
#logs ⇒ Object
331
332
333
|
# File 'lib/isaac_toolbelt.rb', line 331
def logs
ssh_run_command('journalctl -f')
end
|
#mode(state) ⇒ Object
336
337
338
339
340
341
342
343
344
345
346
347
348
|
# File 'lib/isaac_toolbelt.rb', line 336
def mode(state)
SSHKit::Coordinator.new(host).each do
if state == "development" then
execute :systemctl, *%w(stop isaacd)
execute :systemctl, *%w(disable isaacd)
elsif state == "production" then
execute :systemctl, *%w(enable isaacd)
execute :systemctl, *%w(start isaacd)
else
puts DEVICE_MODE
end
end
end
|