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
Klaus Wölfel
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
Show 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
...
@@ -34,11 +34,9 @@ import time
from
datetime
import
date
from
datetime
import
date
# run_apachedex.py <apachedex_executable> /srv/etc/output_folder script_name
# 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
,
apache_log_list
,
base_list
=
None
,
config
=
None
):
skip_base_list
=
None
,
erp5_base_list
=
None
):
if
not
len
(
apache_log_list
):
if
not
len
(
apache_log_list
):
raise
ValueError
(
"apache_log_list is empty"
)
raise
ValueError
(
"apache_log_list is empty"
)
...
@@ -46,8 +44,6 @@ def build_command(apachedex_executable, output_file, default,
...
@@ -46,8 +44,6 @@ def build_command(apachedex_executable, output_file, default,
today
=
date
.
today
().
strftime
(
"%Y-%m-%d"
)
today
=
date
.
today
().
strftime
(
"%Y-%m-%d"
)
apachedex
=
apachedex_executable
apachedex
=
apachedex_executable
argument_list
=
[
apachedex
,
'--js-embed'
,
'--out'
,
output_file
]
argument_list
=
[
apachedex
,
'--js-embed'
,
'--out'
,
output_file
]
if
default
:
argument_list
+=
[
'--default'
,
default
]
log_list
=
[]
log_list
=
[]
for
logfile
in
apache_log_list
:
for
logfile
in
apache_log_list
:
...
@@ -62,52 +58,27 @@ def build_command(apachedex_executable, output_file, default,
...
@@ -62,52 +58,27 @@ def build_command(apachedex_executable, output_file, default,
if
not
log_list
:
if
not
log_list
:
raise
ValueError
(
"log_list: no log files to analyse were provided"
)
raise
ValueError
(
"log_list: no log files to analyse were provided"
)
if
erp5_base_list
:
if
config
:
argument_list
.
append
(
'--erp5-base'
)
config
=
filter
(
None
,
[
x
.
strip
()
for
x
in
config
.
split
(
' '
)])
for
arg
in
erp5_base_list
:
argument_list
+=
config
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
)
argument_list
.
append
(
'--error-detail'
)
argument_list
.
append
(
'--error-detail'
)
argument_list
+=
log_list
argument_list
+=
log_list
return
argument_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
():
def
main
():
parser
=
argparse
.
ArgumentParser
()
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"apachedex_executable"
,
metavar
=
"APACHEDEX_EXECUTABLE"
)
parser
.
add_argument
(
"apachedex_executable"
,
metavar
=
"APACHEDEX_EXECUTABLE"
)
parser
.
add_argument
(
"output_folder"
,
metavar
=
"OUTPUT_FOLDER"
)
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
(
"--apache-log-list"
,
dest
=
"apache_log_list"
,
nargs
=
'*'
)
parser
.
add_argument
(
"--configuration"
,
dest
=
"configuration"
)
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"
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
base_list
=
_extract_list
(
args
.
base_list
)
config
=
args
.
configuration
skip_base_list
=
_extract_list
(
args
.
skip_base_list
)
erp5_base_list
=
_extract_list
(
args
.
erp5_base_list
)
default
=
_extract_list
(
args
.
default
)
output_folder
=
args
.
output_folder
.
strip
()
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
):
if
not
os
.
path
.
exists
(
output_folder
)
or
not
os
.
path
.
isdir
(
output_folder
):
print
"ERROR: Output folder is not a directory. Exiting..."
print
"ERROR: Output folder is not a directory. Exiting..."
...
@@ -119,15 +90,11 @@ def main():
...
@@ -119,15 +90,11 @@ def main():
try
:
try
:
argument_list
=
build_command
(
args
.
apachedex_executable
.
strip
(),
argument_list
=
build_command
(
args
.
apachedex_executable
.
strip
(),
output_file
,
output_file
,
args
.
default
.
strip
(),
args
.
apache_log_list
,
args
.
apache_log_list
,
base_list
,
config
)
skip_base_list
,
erp5_base_list
)
except
ValueError
as
e
:
except
ValueError
as
e
:
print
e
print
e
return
1
return
1
process_handler
=
subprocess
.
Popen
(
argument_list
,
process_handler
=
subprocess
.
Popen
(
argument_list
,
stdout
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
...
@@ -140,7 +107,7 @@ def main():
...
@@ -140,7 +107,7 @@ def main():
return
1
return
1
with
open
(
output_file
,
'r'
)
as
f
:
with
open
(
output_file
,
'r'
)
as
f
:
print
f
.
read
()
print
base_url
+
'/ApacheDex-%s.html'
%
today
return
0
return
0
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