-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgetting_data.py
More file actions
executable file
·56 lines (41 loc) · 1.55 KB
/
getting_data.py
File metadata and controls
executable file
·56 lines (41 loc) · 1.55 KB
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
50
51
52
53
54
55
56
#!/usr/bin/env python
#
# Prints faction of escalators outage in the New York city subway system with reason repair.
#
# Thomas Schmitt thms.schmitt@gmail.com
#
from __future__ import print_function
import sys
import getopt
from schmitt.session2 import loadEscalatorOutage
from schmitt.session2 import countEscalatorOutageReason
def main(options,argv):
"""Prints faction of escalators outage in the New York city subway system with reason repair."""
try:
esculatorOutage = loadEscalatorOutage()
except Exception as e:
print("Unable to load escalators outage status.",file=sys.stderr)
print(e,file=sys.stderr)
exit(-1)
try:
repair,total = countEscalatorOutageReason(esculatorOutage)
except Exception as e:
print("Invalid outage status.",file=sys.stderr)
print(e,file=sys.stderr)
exit(-1)
print('Total outages: %d, outages with reason "Repair": %d, fraction: %f' %(total,repair,float(repair)/total))
def _printHelpAndExit():
print("USAGE: %s" % (sys.argv[0]),file=sys.stderr)
print("Prints the faction of outages of escalators in the NYC subway system caused by repairs.\n",file=sys.stderr)
print(" -h or --help",file=sys.stderr)
print(" shows this help text",file=sys.stderr)
exit(-1)
if __name__ == "__main__":
try:
options,argv = getopt.getopt(sys.argv[1:],"h",["help"])
options = dict(options)
except:
_printHelpAndExit()
if "-h" in options:
_printHelpAndExit()
main(options,argv)