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