Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
envsetup
Manage
Activity
Members
Plan
Redmine
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mediaserver
envsetup
Commits
85fceb71
"roles/mediaserver/git@git.ubicast.net:sys/ansible-public.git" did not exist on "2c52e03bbf5a63793195790fa995f75f468ca422"
Commit
85fceb71
authored
8 years ago
by
Stéphane Diemer
Browse files
Options
Downloads
Patches
Plain Diff
Changed output management (refs
#19907
).
parent
e20c512d
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
4.Postfix/0_setup.py
+1
-2
1 addition, 2 deletions
4.Postfix/0_setup.py
tester.py
+8
-3
8 additions, 3 deletions
tester.py
utils.py
+16
-13
16 additions, 13 deletions
utils.py
with
25 additions
and
18 deletions
4.Postfix/0_setup.py
+
1
−
2
View file @
85fceb71
...
@@ -6,9 +6,8 @@ import utils
...
@@ -6,9 +6,8 @@ import utils
def
setup
(
interactive
=
True
):
def
setup
(
interactive
=
True
):
# Get hostname
# Get hostname
utils
.
log
(
'
Getting system hostname.
'
)
utils
.
log
(
'
Getting system hostname.
'
)
code
,
out
=
utils
.
exec_cmd
(
[
'
hostname
'
]
)
code
,
hostname
=
utils
.
exec_cmd
(
'
hostname
'
)
if
code
==
0
:
if
code
==
0
:
hostname
=
out
utils
.
log
(
'
Hostname is %s.
'
%
hostname
)
utils
.
log
(
'
Hostname is %s.
'
%
hostname
)
else
:
else
:
raise
Exception
(
'
Failed to get hostname.
'
)
raise
Exception
(
'
Failed to get hostname.
'
)
...
...
This diff is collapsed.
Click to expand it.
tester.py
+
8
−
3
View file @
85fceb71
...
@@ -118,9 +118,14 @@ class Tester():
...
@@ -118,9 +118,14 @@ class Tester():
description
=
self
.
get_file_description
(
test_path
)
description
=
self
.
get_file_description
(
test_path
)
# Run test
# Run test
try
:
try
:
code
,
out
=
utils
.
exec_cmd
(
test_path
)
p
=
subprocess
.
Popen
([
test_path
],
stdin
=
sys
.
stdin
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
if
code
!=
0
:
out
,
err
=
p
.
communicate
()
raise
Exception
(
'
Command exited with code %s.
'
%
code
)
if
out
:
log
(
out
.
decode
(
'
utf-8
'
).
strip
())
if
err
:
log
(
err
.
decode
(
'
utf-8
'
).
strip
())
if
p
.
returncode
!=
0
:
raise
Exception
(
'
Command exited with code %s.
'
%
p
.
returncode
)
except
Exception
as
e
:
except
Exception
as
e
:
exit_code
=
1
exit_code
=
1
log
(
e
)
log
(
e
)
...
...
This diff is collapsed.
Click to expand it.
utils.py
+
16
−
13
View file @
85fceb71
...
@@ -21,23 +21,26 @@ def get_dir(file_path):
...
@@ -21,23 +21,26 @@ def get_dir(file_path):
return
os
.
path
.
dirname
(
os
.
path
.
abspath
(
os
.
path
.
expanduser
(
file_path
)))
return
os
.
path
.
dirname
(
os
.
path
.
abspath
(
os
.
path
.
expanduser
(
file_path
)))
def
exec_cmd
(
cmd
,
log_output
=
True
):
def
exec_cmd
(
cmd
,
log_output
=
True
,
get_output
=
True
):
shell
=
not
isinstance
(
cmd
,
(
tuple
,
list
))
shell
=
not
isinstance
(
cmd
,
(
tuple
,
list
))
p
=
subprocess
.
Popen
(
cmd
,
stdin
=
sys
.
stdin
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
shell
=
shell
)
stdout
=
subprocess
.
PIPE
if
get_output
or
not
log_output
else
sys
.
stdout
stderr
=
subprocess
.
PIPE
if
get_output
or
not
log_output
else
sys
.
stderr
p
=
subprocess
.
Popen
(
cmd
,
stdin
=
sys
.
stdin
,
stdout
=
stdout
,
stderr
=
stderr
,
shell
=
shell
)
out
,
err
=
p
.
communicate
()
out
,
err
=
p
.
communicate
()
out
=
out
.
decode
(
'
utf-8
'
).
strip
()
if
out
else
''
if
get_output
:
if
err
:
out
=
out
.
decode
(
'
utf-8
'
).
strip
()
if
out
else
''
if
out
:
if
err
:
out
+=
'
\n
'
if
out
:
out
+=
err
.
decode
(
'
utf-8
'
).
strip
()
out
+=
'
\n
'
out
=
out
.
strip
()
out
+=
err
.
decode
(
'
utf-8
'
).
strip
()
if
log_output
:
out
=
out
.
strip
()
log
(
out
)
if
log_output
:
log
(
out
)
return
p
.
returncode
,
out
return
p
.
returncode
,
out
def
check_cmd
(
cmd
):
def
check_cmd
(
cmd
,
log_output
=
False
):
code
,
out
=
exec_cmd
(
cmd
,
log_output
=
False
)
code
,
out
=
exec_cmd
(
cmd
,
log_output
,
False
)
return
code
return
code
...
@@ -136,7 +139,7 @@ def run_commands(cmds):
...
@@ -136,7 +139,7 @@ def run_commands(cmds):
log
(
'
A backup file already exist for:
\n
%s
'
%
cmd
[
'
target
'
])
log
(
'
A backup file already exist for:
\n
%s
'
%
cmd
[
'
target
'
])
else
:
else
:
log
(
'
>>>
'
+
cmd
[
'
line
'
])
log
(
'
>>>
'
+
cmd
[
'
line
'
])
code
=
check_cmd
(
cmd
[
'
line
'
])
code
=
check_cmd
(
cmd
[
'
line
'
]
,
log_output
=
True
)
if
code
!=
0
:
if
code
!=
0
:
raise
Exception
(
'
Command exited with code %s.
'
%
code
)
raise
Exception
(
'
Command exited with code %s.
'
%
code
)
except
Exception
as
e
:
except
Exception
as
e
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment