-
Notifications
You must be signed in to change notification settings - Fork 0
/
notify.py
38 lines (32 loc) · 878 Bytes
/
notify.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
#!/usr/bin/env python2.6
# -*- encoding: utf8 -*-
import sys
import optparse
import fileinput
import pycurl
import urllib
def main(args):
'''\
%prog [options]
'''
station = []
for line in fileinput.input():
station.append(line)
if len(station) > 0:
if u"GoStation Maintenance" in station[0]:
title = u"GoStation Maintenance"
else:
title = u"GoStation Update"
c = pycurl.Curl()
c.setopt(c.URL, 'PATH_TO_URL')
c.setopt(c.POSTFIELDS, 'title=%s&text=%s' % (urllib.quote(title), urllib.quote("".join(station))))
c.perform()
c.close()
return 0
if __name__ == '__main__':
parser = optparse.OptionParser(usage=main.__doc__)
options, args = parser.parse_args()
if len(args) != 0:
parser.print_help()
sys.exit(1)
sys.exit(main(args))