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
Boxiang Sun
slapos.toolbox
Commits
f2ded72b
Commit
f2ded72b
authored
Aug 07, 2012
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for multiple notification servers
parent
7e87bf53
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
18 deletions
+17
-18
slapos/pubsub/notifier.py
slapos/pubsub/notifier.py
+17
-18
No files found.
slapos/pubsub/notifier.py
View file @
f2ded72b
...
@@ -24,15 +24,15 @@ def main():
...
@@ -24,15 +24,15 @@ def main():
parser
.
add_argument
(
'-f'
,
'--feed'
,
nargs
=
1
,
required
=
True
,
parser
.
add_argument
(
'-f'
,
'--feed'
,
nargs
=
1
,
required
=
True
,
dest
=
'feed_url'
,
help
=
"Url of the feed."
)
dest
=
'feed_url'
,
help
=
"Url of the feed."
)
parser
.
add_argument
(
'--notification-url'
,
dest
=
'notification_url'
,
parser
.
add_argument
(
'--notification-url'
,
dest
=
'notification_url'
,
nargs
=
1
,
required
=
True
,
nargs
=
'*'
,
required
=
True
,
help
=
"Notification url"
)
help
=
"Notification url"
)
parser
.
add_argument
(
'
executable'
,
nargs
=
1
,
parser
.
add_argument
(
'
--executable'
,
nargs
=
1
,
dest
=
'executable'
,
help
=
"Executable to wrap"
)
help
=
"Executable to wrap"
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
with
open
(
os
.
devnull
)
as
devnull
:
with
open
(
os
.
devnull
)
as
devnull
:
command
=
subprocess
.
Popen
(
args
.
executable
,
command
=
subprocess
.
Popen
(
args
.
executable
[
0
]
,
stdin
=
subprocess
.
PIPE
,
stdin
=
subprocess
.
PIPE
,
stdout
=
devnull
,
stdout
=
devnull
,
stderr
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
...
@@ -61,8 +61,8 @@ def main():
...
@@ -61,8 +61,8 @@ def main():
])
])
feed
=
urllib2
.
urlopen
(
args
.
feed_url
[
0
])
feed
=
urllib2
.
urlopen
(
args
.
feed_url
[
0
])
for
notif_url
in
args
.
notification_url
:
notification_url
=
urlparse
(
args
.
notification_url
[
0
]
)
notification_url
=
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
)
...
@@ -73,12 +73,11 @@ def main():
...
@@ -73,12 +73,11 @@ def main():
notification
.
request
(
'POST'
,
notification_url
.
path
,
feed
.
read
(),
headers
)
notification
.
request
(
'POST'
,
notification_url
.
path
,
feed
.
read
(),
headers
)
response
=
notification
.
getresponse
()
response
=
notification
.
getresponse
()
if
200
<=
response
.
status
<
300
:
if
not
(
200
<=
response
.
status
<
300
):
return
0
else
:
print
>>
sys
.
stderr
,
"The remote server didn't send a successfull reponse."
print
>>
sys
.
stderr
,
"The remote server didn't send a successfull reponse."
print
>>
sys
.
stderr
,
"It's response was %r"
%
response
.
reason
print
>>
sys
.
stderr
,
"It's response was %r"
%
response
.
reason
return
1
return
1
return
0
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