Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Hardik Juneja
slapos.toolbox
Commits
5eaf6615
Commit
5eaf6615
authored
Nov 07, 2012
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix for multiple notifications
parent
8f16692d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
14 deletions
+21
-14
slapos/pubsub/notifier.py
slapos/pubsub/notifier.py
+21
-14
No files found.
slapos/pubsub/notifier.py
View file @
5eaf6615
#!/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
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment