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
Kazuhiko Shiozaki
slapos.toolbox
Commits
5ecc34b2
Commit
5ecc34b2
authored
Nov 27, 2012
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bubble up errors from subprocesses
parent
d4c77c66
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
8 deletions
+15
-8
slapos/pubsub/notifier.py
slapos/pubsub/notifier.py
+15
-8
No files found.
slapos/pubsub/notifier.py
View file @
5ecc34b2
...
@@ -40,13 +40,16 @@ def main():
...
@@ -40,13 +40,16 @@ def main():
command
.
stdin
.
flush
()
command
.
stdin
.
flush
()
command
.
stdin
.
close
()
command
.
stdin
.
close
()
if
command
.
wait
()
!=
0
:
command_failed
=
(
command
.
wait
()
!=
0
)
command_stderr
=
command
.
stderr
.
read
()
if
command_failed
:
content
=
(
"<p>Failed with returncode <em>%d</em>.</p>"
content
=
(
"<p>Failed with returncode <em>%d</em>.</p>"
"<p>Standard error output is :</p><pre>%s</pre>"
)
%
(
"<p>Standard error output is :</p><pre>%s</pre>"
)
%
(
command
.
poll
(),
command
.
poll
(),
command
.
stderr
.
read
()
.
replace
(
'&'
,
'&'
)
\
command
_stderr
.
replace
(
'&'
,
'&'
)
\
.
replace
(
'<'
,
'<'
)
\
.
replace
(
'<'
,
'<'
)
\
.
replace
(
'>'
,
'>'
),
.
replace
(
'>'
,
'>'
),
)
)
else
:
else
:
content
=
"<p>Everything went well.</p>"
content
=
"<p>Everything went well.</p>"
...
@@ -60,10 +63,14 @@ def main():
...
@@ -60,10 +63,14 @@ def main():
'slapos:%s'
%
uuid
.
uuid4
(),
'slapos:%s'
%
uuid
.
uuid4
(),
])
])
if
command_failed
:
sys
.
stderr
.
write
(
'%s
\
n
'
%
command_stderr
)
sys
.
exit
(
1
)
feed
=
urllib2
.
urlopen
(
args
.
feed_url
[
0
])
feed
=
urllib2
.
urlopen
(
args
.
feed_url
[
0
])
body
=
feed
.
read
()
body
=
feed
.
read
()
failed
=
False
some_notification_
failed
=
False
for
notif_url
in
args
.
notification_url
:
for
notif_url
in
args
.
notification_url
:
notification_url
=
urlparse
.
urlparse
(
notif_url
)
notification_url
=
urlparse
.
urlparse
(
notif_url
)
notification_port
=
notification_url
.
port
notification_port
=
notification_url
.
port
...
@@ -72,16 +79,16 @@ def main():
...
@@ -72,16 +79,16 @@ 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
,
body
,
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
):
sys
.
stderr
.
write
(
"The remote server at %s didn't send a successful reponse.
\
n
"
%
notif_url
)
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
)
sys
.
stderr
.
write
(
"Its response was %r
\
n
"
%
response
.
reason
)
failed
=
True
some_notification_
failed
=
True
if
failed
:
if
some_notification_
failed
:
sys
.
exit
(
1
)
sys
.
exit
(
1
)
if
__name__
==
'__main__'
:
if
__name__
==
'__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