-
Notifications
You must be signed in to change notification settings - Fork 0
/
fakerpi
executable file
·50 lines (39 loc) · 1.27 KB
/
fakerpi
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
#!/usr/bin/env python
# -*- mode: python -*-
import sys
from application import PagerPI
class Shutdown(BaseException):
pass
class StdinPager(object):
is_open = True
def readline(self):
try:
return raw_input("pager line: ")
except (EOFError, KeyboardInterrupt):
raise Shutdown()
def close(self):
pass
class StdoutPushover(object):
def send_message(self, message, title="Message", profile="Default"):
sys.stdout.write("Pushover: %r [%s]" % (title, profile))
sys.stdout.write(message)
sys.stdout.write("\n")
def main():
override_config = {}
if "--local" in sys.argv:
override_config['pager_log_host'] = 'http://localhost:8080/'
pagerpi = PagerPI(pager=StdinPager(), override_config=override_config)
if "--real-pushover" not in sys.argv:
pagerpi.pushover = StdoutPushover()
pagerpi.public_pushover = StdoutPushover()
pagerpi.debug = True
pagerpi.verbose = True
pagerpi.send_addresses = lambda: None
print "Example alert message:"
print "x x @@ALERT F0 x G&SC1 message SVC 1729 B11 (31415) LAT/LON:-37.777, 144.444 v w x y z [resource]"
try:
pagerpi.main()
except Shutdown:
print
if __name__ == '__main__':
main()