Skip to content
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.

Add timout to ARC16 scrape. #61

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions app/controllers/air/transmitter_log_entries_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "?"
Expand Down Expand Up @@ -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
end