SensorStream 0.2.0 → 0.2.1

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 (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/SensorStream.rb +27 -12
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 969d6c982ad55343c56dbfb8192021e4649edba6
4
- data.tar.gz: 4f1a0a9f69fc0fa01695d86540340b87a08e6f03
3
+ metadata.gz: fb098ddfd37fabf24bf24a65d53d144d6a5449c7
4
+ data.tar.gz: bf9330e4121f5da1aa791875c69b1a1b000fef86
5
5
  SHA512:
6
- metadata.gz: 10fb9911ae273a696fd95f7529bb656bbba44540dc4a6508c38edc7fb611ece7ff076a4f9e438d66a6a2933e7722e1d23930982b35801927a2da25ddb4112431
7
- data.tar.gz: d3ec2fde6bd9a87b6c61362dca312f90e553c33c9307deba66e2919e579d13290856b095ad8fc1985f7c90ed1ea5c98303644b8cbb49a4719b4557926b30079c
6
+ metadata.gz: bb5ee40a24e7af1c5dd679125eb2dbbb107691496ab7bf3a5509fc5b9c24fb5d43c189eb8b2f59348db86e1221f61b38b57568a9563d82936d8009f5ecf75304
7
+ data.tar.gz: 2862a3e185201f18f813c7afbafeabd1ba8d6436d1842466d6337939aca92c0597028575ff57b8292a5d7256bb0d97b66e0d11ec59d485f32a97b7dbb0d90baf
data/lib/SensorStream.rb CHANGED
@@ -28,7 +28,7 @@ module SensorStream
28
28
 
29
29
  # Allows the SensorStream server to be overridden
30
30
  def self.set_default_server
31
- @host_name = "sensorstream.cloudapp.net"
31
+ @host_name = "sensorstream.coas.oregonstate.edu"
32
32
  @port_number = 80
33
33
  end
34
34
 
@@ -49,10 +49,16 @@ module SensorStream
49
49
 
50
50
  http = Net::HTTP.new(@host_name, @port_number);
51
51
  http.read_timeout = timeout; # 10 minute default timeout
52
- http.post(uri.request_uri, JSON.generate(body_dict), header_dict);
53
- # This is very important: we're making use of the implied return of ruby, here!!!
54
- end
55
-
52
+ retval = http.post(uri.request_uri, JSON.generate(body_dict), header_dict);
53
+
54
+ rescue Errno::ETIMEDOUT => e
55
+ puts "Timed out while waiting for SensorStream."
56
+ return nil
57
+ end
58
+
59
+ return retval
60
+ end
61
+
56
62
  # Internally used to wrap HTTP gets with the required headers
57
63
  def self.make_http_get(request = "", header_dict = {}, timeout = 600, debug = false)
58
64
  # Ensure that the hostname and port are set
@@ -67,8 +73,14 @@ module SensorStream
67
73
 
68
74
  http = Net::HTTP.new(@host_name, @port_number);
69
75
  http.read_timeout = 600; # 10 minute timeout
70
- http.get(uri.request_uri, header_dict);
71
- # This is very important: we're making use of the implied return of ruby, here!!!
76
+ retval = http.get(uri.request_uri, header_dict);
77
+
78
+ rescue Errno::ETIMEDOUT => e
79
+ puts "Timed out while waiting for SensorStream."
80
+ return nil
81
+ end
82
+
83
+ return retval
72
84
  end
73
85
 
74
86
  # create a new device on the server
@@ -125,12 +137,15 @@ module SensorStream
125
137
  return nil;
126
138
  else
127
139
  devices = [];
140
+
141
+ if (resp.body.empty?)
142
+ return nil
143
+ end
144
+
128
145
  JSON.parse(resp.body).each { |device|
129
- devices << SensorStream::Device.new(device["username"],
130
- device["devicename"],
131
- device["description"])
132
- #devices.last.get_streams
133
- }
146
+ devices << SensorStream::Device.new(device["username"],
147
+ device["devicename"],
148
+ device["description"]) }
134
149
  return devices;
135
150
  end
136
151
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: SensorStream
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Dillon