Add support for multiple notification servers

parent 7e87bf53
......@@ -24,15 +24,15 @@ def main():
parser.add_argument('-f', '--feed', nargs=1, required=True,
dest='feed_url', help="Url of the feed.")
parser.add_argument('--notification-url', dest='notification_url',
nargs=1, required=True,
nargs='*', required=True,
help="Notification url")
parser.add_argument('executable', nargs=1,
parser.add_argument('--executable', nargs=1, dest='executable',
help="Executable to wrap")
args = parser.parse_args()
with open(os.devnull) as devnull:
command = subprocess.Popen(args.executable,
command = subprocess.Popen(args.executable[0],
stdin=subprocess.PIPE,
stdout=devnull,
stderr=subprocess.PIPE,
......@@ -61,8 +61,8 @@ def main():
])
feed = urllib2.urlopen(args.feed_url[0])
notification_url = urlparse(args.notification_url[0])
for notif_url in args.notification_url:
notification_url = urlparse(notif_url)
notification_port = notification_url.port
if notification_port is None:
notification_port = socket.getservbyname(notification_url.scheme)
......@@ -73,12 +73,11 @@ def main():
notification.request('POST', notification_url.path, feed.read(), headers)
response = notification.getresponse()
if 200 <= response.status < 300:
return 0
else:
if not (200 <= response.status < 300):
print >> sys.stderr, "The remote server didn't send a successfull reponse."
print >> sys.stderr, "It's response was %r" % response.reason
return 1
return 0
if __name__ == '__main__':
main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment