-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathiarnrod.py
executable file
·49 lines (41 loc) · 1.86 KB
/
iarnrod.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/python3
#
# Copyright: Conor O'Callghan 2016
# Version: v1.1.3
#
# Please feel free to fork this project, modify the code and improve
# it on the github repo https://github.com/brioscaibriste/iarnrod
#
# Powered by TfL Open Data
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import coire
# Iarnrod Tuning options
Throttling = "True" # Limit the burden on the API, throttle the connections
PollIntervalMinutes = 5 # This is the status polling interval in minutes
StatusOutput = "small" # You can set this to small or large and it will change the output format
TFileName = '/tmp/iarn-i3-temp' # Where to store the timestamp file for poll throttling
SFileName = '/tmp/iarn-i3-stat' # Where to store the cache of the line status
# Parse the command line arguments
Line = coire.ParseArgs()
# Throttling
Run = coire.Throttle(PollIntervalMinutes,Throttling,TFileName)
# Gather the line status data
LineStatusData = coire.RetrieveTFLData(Line,Run,SFileName)
# Generate the status output and print
if (StatusOutput == "small") and (LineStatusData == "Good Service"):
print ("TFL " + Line[0] + Line[1] + Line[2] + " OK")
elif StatusOutput == "small":
print ("TFL " + Line[0] + Line[1] + Line[2] + " " + LineStatusData)
else:
print ("TFL " + Line + " line has " + LineStatusData)