From dff192a21bace37d76dfd0fd52c681affb2146ba Mon Sep 17 00:00:00 2001 From: mmanguno Date: Mon, 12 Sep 2016 12:27:21 -0400 Subject: [PATCH] Add timout to ARC16 scrape. See issue #57. --- .../air/transmitter_log_entries_controller.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/controllers/air/transmitter_log_entries_controller.rb b/app/controllers/air/transmitter_log_entries_controller.rb index 90c023b..daff84c 100644 --- a/app/controllers/air/transmitter_log_entries_controller.rb +++ b/app/controllers/air/transmitter_log_entries_controller.rb @@ -8,10 +8,12 @@ def index # scrape the power readings page begin - doc = Nokogiri::XML(open('http://opdesk.wrek.org/engineering/arc16xml.php')) - @plate_current = doc.at_css('Channel[name="PLTCUR"]')[:value] - @plate_voltage = doc.at_css('Channel[name="PLTVLT"]')[:value] - @power_out = doc.at_css('Channel[name="PWROUT"]')[:value] + timout(5) do + doc = Nokogiri::XML(open('http://opdesk.wrek.org/engineering/arc16xml.php')) + @plate_current = doc.at_css('Channel[name="PLTCUR"]')[:value] + @plate_voltage = doc.at_css('Channel[name="PLTVLT"]')[:value] + @power_out = doc.at_css('Channel[name="PWROUT"]')[:value] + end rescue @plate_current = "?" @plate_voltage = "?" @@ -63,4 +65,4 @@ def transmitter_log_entry_params params.require(:transmitter_log_entry).permit(:sign_in, :automation_in, :automation_out, :sign_out) end -end \ No newline at end of file +end