Commit 5eaf6615 authored by Marco Mariani's avatar Marco Mariani

fix for multiple notifications

parent 8f16692d
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import math
import subprocess
import os
import uuid
import argparse
import csv
import time
import urllib2
from urlparse import urlparse
import httplib
import math
import os
import socket
import subprocess
import sys
import argparse
import time
import urllib2
import urlparse
import uuid
def main():
parser = argparse.ArgumentParser()
......@@ -61,8 +62,11 @@ def main():
])
feed = urllib2.urlopen(args.feed_url[0])
body = feed.read()
failed = False
for notif_url in args.notification_url:
notification_url = urlparse(notif_url)
notification_url = urlparse.urlparse(notif_url)
notification_port = notification_url.port
if notification_port is None:
notification_port = socket.getservbyname(notification_url.scheme)
......@@ -70,14 +74,17 @@ def main():
headers = {'Content-Type': feed.info().getheader('Content-Type')}
notification = httplib.HTTPConnection(notification_url.hostname,
notification_port)
notification.request('POST', notification_url.path, feed.read(), headers)
notification.request('POST', notification_url.path, body, headers)
response = notification.getresponse()
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
sys.stderr.write("The remote server at %s didn't send a successful reponse.\n" % notif_url)
sys.stderr.write("Its response was %r\n" % response.reason)
failed = True
if failed:
sys.exit(1)
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