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
Thomas Leymonerie
slapos.toolbox
Commits
27d017eb
Commit
27d017eb
authored
Aug 14, 2017
by
Hardik Juneja
Committed by
Rafael Monnerat
Aug 14, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make apachedex report accept config as text instead of different parameters as done earlier
/reviewed-on
nexedi/slapos.toolbox!14
parent
3e92cce0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
44 deletions
+11
-44
slapos/apachedex.py
slapos/apachedex.py
+11
-44
No files found.
slapos/apachedex.py
View file @
27d017eb
...
...
@@ -34,11 +34,9 @@ import time
from
datetime
import
date
# run_apachedex.py <apachedex_executable> /srv/etc/output_folder script_name
def
build_command
(
apachedex_executable
,
output_file
,
default
,
def
build_command
(
apachedex_executable
,
output_file
,
apache_log_list
,
base_list
=
None
,
skip_base_list
=
None
,
erp5_base_list
=
None
):
config
=
None
):
if
not
len
(
apache_log_list
):
raise
ValueError
(
"apache_log_list is empty"
)
...
...
@@ -46,8 +44,6 @@ def build_command(apachedex_executable, output_file, default,
today
=
date
.
today
().
strftime
(
"%Y-%m-%d"
)
apachedex
=
apachedex_executable
argument_list
=
[
apachedex
,
'--js-embed'
,
'--out'
,
output_file
]
if
default
:
argument_list
+=
[
'--default'
,
default
]
log_list
=
[]
for
logfile
in
apache_log_list
:
...
...
@@ -62,52 +58,27 @@ def build_command(apachedex_executable, output_file, default,
if
not
log_list
:
raise
ValueError
(
"log_list: no log files to analyse were provided"
)
if
erp5_base_list
:
argument_list
.
append
(
'--erp5-base'
)
for
arg
in
erp5_base_list
:
argument_list
.
append
(
arg
)
if
base_list
:
argument_list
.
append
(
'--base'
)
for
arg
in
base_list
:
argument_list
.
append
(
arg
)
if
skip_base_list
:
argument_list
.
append
(
'--skip-base'
)
for
arg
in
skip_base_list
:
argument_list
.
append
(
arg
)
if
config
:
config
=
filter
(
None
,
[
x
.
strip
()
for
x
in
config
.
split
(
' '
)])
argument_list
+=
config
argument_list
.
append
(
'--error-detail'
)
argument_list
+=
log_list
return
argument_list
def
_extract_list
(
filename
):
final_list
=
None
if
os
.
path
.
exists
(
filename
):
with
open
(
filename
,
'r'
)
as
f
:
list
=
f
.
read
().
strip
();
final_list
=
[
base
.
strip
().
split
(
' '
)
for
base
in
list
.
split
(
' '
)
if
base
]
return
final_list
def
main
():
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"apachedex_executable"
,
metavar
=
"APACHEDEX_EXECUTABLE"
)
parser
.
add_argument
(
"output_folder"
,
metavar
=
"OUTPUT_FOLDER"
)
parser
.
add_argument
(
"
--default"
,
metavar
=
"DEFAULT_PARAMETER
"
)
parser
.
add_argument
(
"
base_url"
,
metavar
=
"BASE_URL
"
)
parser
.
add_argument
(
"--apache-log-list"
,
dest
=
"apache_log_list"
,
nargs
=
'*'
)
parser
.
add_argument
(
"--base-list"
,
dest
=
"base_list"
)
parser
.
add_argument
(
"--skip-base-list"
,
dest
=
"skip_base_list"
)
parser
.
add_argument
(
"--erp5-base-list"
,
dest
=
"erp5_base_list"
)
parser
.
add_argument
(
"--configuration"
,
dest
=
"configuration"
)
args
=
parser
.
parse_args
()
base_list
=
_extract_list
(
args
.
base_list
)
skip_base_list
=
_extract_list
(
args
.
skip_base_list
)
erp5_base_list
=
_extract_list
(
args
.
erp5_base_list
)
default
=
_extract_list
(
args
.
default
)
config
=
args
.
configuration
output_folder
=
args
.
output_folder
.
strip
()
base_url
=
args
.
base_url
.
strip
()
if
not
os
.
path
.
exists
(
output_folder
)
or
not
os
.
path
.
isdir
(
output_folder
):
print
"ERROR: Output folder is not a directory. Exiting..."
...
...
@@ -119,15 +90,11 @@ def main():
try
:
argument_list
=
build_command
(
args
.
apachedex_executable
.
strip
(),
output_file
,
args
.
default
.
strip
(),
args
.
apache_log_list
,
base_list
,
skip_base_list
,
erp5_base_list
)
config
)
except
ValueError
as
e
:
print
e
return
1
process_handler
=
subprocess
.
Popen
(
argument_list
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
...
...
@@ -140,7 +107,7 @@ def main():
return
1
with
open
(
output_file
,
'r'
)
as
f
:
print
f
.
read
()
print
base_url
+
'/ApacheDex-%s.html'
%
today
return
0
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