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
Lu Xu
slapos.toolbox
Commits
faaf0cd0
Commit
faaf0cd0
authored
Nov 11, 2020
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Plain Diff
Fix apachedex wrapper
See merge request
nexedi/slapos.toolbox!86
parents
840e40bb
0a1fd4b6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
19 deletions
+23
-19
slapos/apachedex.py
slapos/apachedex.py
+10
-19
slapos/test/test_apachedex.py
slapos/test/test_apachedex.py
+13
-0
No files found.
slapos/apachedex.py
View file @
faaf0cd0
...
...
@@ -32,7 +32,7 @@ from __future__ import print_function
import
os
,
errno
import
subprocess
import
argparse
import
time
import
shlex
from
datetime
import
date
# run_apachedex.py <apachedex_executable> /srv/etc/output_folder script_name
...
...
@@ -61,8 +61,7 @@ def build_command(apachedex_executable, output_file,
raise
ValueError
(
"log_list: no log files to analyse were provided"
)
if
config
:
config
=
filter
(
None
,
[
x
.
strip
()
for
x
in
config
.
split
(
' '
)])
argument_list
+=
config
argument_list
.
extend
(
shlex
.
split
(
config
))
argument_list
.
append
(
'--error-detail'
)
argument_list
+=
log_list
...
...
@@ -74,8 +73,8 @@ def main():
parser
.
add_argument
(
"apachedex_executable"
,
metavar
=
"APACHEDEX_EXECUTABLE"
)
parser
.
add_argument
(
"output_folder"
,
metavar
=
"OUTPUT_FOLDER"
)
parser
.
add_argument
(
"base_url"
,
metavar
=
"BASE_URL"
)
parser
.
add_argument
(
"--apache-log-list"
,
dest
=
"apache_log_list"
,
nargs
=
'*'
)
parser
.
add_argument
(
"--configuration"
,
dest
=
"configuration"
)
parser
.
add_argument
(
"--apache-log-list"
,
nargs
=
'*'
)
parser
.
add_argument
(
"--configuration"
)
args
=
parser
.
parse_args
()
config
=
args
.
configuration
...
...
@@ -97,16 +96,11 @@ def main():
except
ValueError
as
e
:
print
(
e
)
return
1
process_handler
=
subprocess
.
Popen
(
argument_list
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
universal_newlines
=
True
,
)
stdout
,
stderr
=
process_handler
.
communicate
()
if
process_handler
.
returncode
!=
0
:
if
stderr
:
print
(
stderr
)
try
:
subprocess
.
check_output
(
argument_list
,
stderr
=
subprocess
.
STDOUT
)
except
subprocess
.
CalledProcessError
as
e
:
print
(
"Error running apachedex"
,
e
.
output
)
return
1
# Check that output_file is a readable file.
...
...
@@ -114,6 +108,3 @@ def main():
print
(
base_url
+
'/ApacheDex-%s.html'
%
today
)
return
0
if
__name__
==
"__main__"
:
sys
.
exit
(
main
())
slapos/test/test_apachedex.py
View file @
faaf0cd0
...
...
@@ -64,6 +64,19 @@ class TestApachedexCommand(unittest.TestCase):
'--base'
,
'bar'
,
'foo'
,
'--default'
,
'foo'
,
'--error-detail'
,
self
.
acesslog1
,
self
.
acesslog2
])
def
test_complexCommandEscape
(
self
):
command
=
build_command
(
self
.
apachedex
,
'bar.html'
,
[
self
.
acesslog1
,
self
.
acesslog2
],
'--base "foo bar"'
)
self
.
assertEqual
(
command
,
[
'/bin/apachedex'
,
'--js-embed'
,
'--out'
,
'bar.html'
,
'--base'
,
'foo bar'
,
'--error-detail'
,
self
.
acesslog1
,
self
.
acesslog2
])
def
test_raiseErro
(
self
):
self
.
assertRaises
(
ValueError
,
build_command
,
self
.
apachedex
,
'foo.html'
,
[])
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