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
Gabriel Monnerat
slapos.toolbox
Commits
5698a3fb
Commit
5698a3fb
authored
Oct 26, 2016
by
Nicolas Wavrant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
notifier.py: new argument allowing to run the executable several times in case of failure
parent
cc34cbb2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
21 deletions
+31
-21
slapos/pubsub/notifier.py
slapos/pubsub/notifier.py
+31
-21
No files found.
slapos/pubsub/notifier.py
View file @
5698a3fb
...
...
@@ -48,6 +48,9 @@ def main():
parser
.
add_argument
(
'--transaction-id'
,
nargs
=
1
,
dest
=
'transaction_id'
,
type
=
int
,
required
=
False
,
help
=
"Additional parameter for notification-url"
)
parser
.
add_argument
(
'--max-run'
,
dest
=
'max_run'
,
type
=
int
,
default
=
1
,
required
=
False
,
help
=
"Run executable until it ends correctly, in a limit of max-run times"
)
# Verbose mode
parser
.
add_argument
(
'--instance-root-name'
,
dest
=
'instance_root_name'
,
...
...
@@ -74,28 +77,35 @@ def main():
saveStatus
(
'STARTED'
)
try
:
content
=
subprocess
.
check_output
(
args
.
executable
[
0
],
stderr
=
subprocess
.
STDOUT
)
exit_code
=
0
content
=
(
"OK</br><p>%s ran successfully</p>"
"<p>Output is: </p><pre>%s</pre>"
%
(
args
.
executable
[
0
],
content
.
replace
(
'&'
,
'&'
).
replace
(
'<'
,
'<'
).
replace
(
'>'
,
'>'
)
))
saveStatus
(
'FINISHED'
)
except
subprocess
.
CalledProcessError
as
e
:
saveStatus
(
'ERROR'
)
content
=
e
.
output
exit_code
=
e
.
returncode
content
=
(
"FAILURE</br><p>%s Failed with returncode <em>%d</em>.</p>"
"<p>Output is: </p><pre>%s</pre>"
%
(
if
args
.
max_run
<=
0
:
print
"--max-run argument takes a strictely positive number as argument"
sys
.
exit
(
-
1
)
while
args
.
max_run
>
0
:
try
:
content
=
subprocess
.
check_output
(
args
.
executable
[
0
],
exit_code
,
content
.
replace
(
'&'
,
'&'
).
replace
(
'<'
,
'<'
).
replace
(
'>'
,
'>'
)
))
stderr
=
subprocess
.
STDOUT
)
exit_code
=
0
content
=
(
"OK</br><p>%s ran successfully</p>"
"<p>Output is: </p><pre>%s</pre>"
%
(
args
.
executable
[
0
],
content
.
replace
(
'&'
,
'&'
).
replace
(
'<'
,
'<'
).
replace
(
'>'
,
'>'
)
))
saveStatus
(
'FINISHED'
)
break
except
subprocess
.
CalledProcessError
as
e
:
args
.
max_run
-=
1
saveStatus
(
'ERROR'
)
content
=
e
.
output
exit_code
=
e
.
returncode
content
=
(
"FAILURE</br><p>%s Failed with returncode <em>%d</em>.</p>"
"<p>Output is: </p><pre>%s</pre>"
%
(
args
.
executable
[
0
],
exit_code
,
content
.
replace
(
'&'
,
'&'
).
replace
(
'<'
,
'<'
).
replace
(
'>'
,
'>'
)
))
print
content
...
...
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