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
5
Merge Requests
5
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
slapos.toolbox
Commits
55b013d0
Commit
55b013d0
authored
May 29, 2017
by
Hardik Juneja
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Apachedex script (To be used by stack/erp5)
parent
d1ed4bf0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
184 additions
and
0 deletions
+184
-0
setup.py
setup.py
+1
-0
slapos/runapachedex.py
slapos/runapachedex.py
+108
-0
slapos/test/test_runApacheDex.py
slapos/test/test_runApacheDex.py
+75
-0
No files found.
setup.py
View file @
55b013d0
...
...
@@ -95,6 +95,7 @@ setup(name=name,
'monitor.configwrite = slapos.monitor.monitor_config_write:main'
,
'runResiliencyUnitTestTestNode = slapos.resiliencytest:runUnitTest'
,
'runResiliencyScalabilityTestNode = slapos.resiliencytest:runResiliencyTest'
,
'runApacheDex = slapos.runapachedex:main'
,
'lampconfigure = slapos.lamp:run [lampconfigure]'
,
'onetimedownload = slapos.onetimedownload:main'
,
'onetimeupload = slapos.onetimeupload:main'
,
...
...
slapos/runapachedex.py
0 → 100644
View file @
55b013d0
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
import
os
,
errno
import
subprocess
import
argparse
from
datetime
import
date
# run_apachedex.py <apachedex_executable> /srv/etc/output_folder script_name
def
build_command
(
apachedex_executable
,
output_folder
,
default
,
apache_log_list
=
None
,
base_list
=
None
,
skip_base_list
=
None
,
erp5_base_list
=
None
):
if
not
len
(
apache_log_list
):
return
1
if
not
os
.
path
.
exists
(
output_folder
)
or
not
os
.
path
.
isdir
(
output_folder
):
print
"ERROR: Output folder is not a directory. Exiting..."
return
1
apachedex
=
apachedex_executable
today
=
date
.
today
().
strftime
(
"%Y-%m-%d"
)
output_file
=
os
.
path
.
join
(
output_folder
,
'ApacheDex-%s.html'
%
today
)
argument_list
=
[
apachedex
,
'--js-embed'
,
'--out'
,
output_file
]
if
default
:
argument_list
+=
[
'--default'
,
default
]
log_list
=
[]
for
logfile
in
apache_log_list
:
if
not
logfile
:
continue
# Automaticaly replace variable 'date'.
apache_log
=
logfile
.
strip
()
%
{
'date'
:
date
.
today
().
strftime
(
"%Y%m%d"
)}
if
not
os
.
path
.
exists
(
apache_log
):
print
"WARNING: File %s not found..."
%
apache_log
continue
log_list
.
append
(
apache_log
)
if
not
log_list
:
print
"WARNING: Log file list to analyse is empty or not provided. Exiting..."
return
1
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
)
argument_list
.
append
(
'--error-detail'
)
argument_list
+=
log_list
return
argument_list
def
_get_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
(
"-apache_log_list"
,
nargs
=
'*'
)
parser
.
add_argument
(
"-base_list"
)
parser
.
add_argument
(
"-skip_base_list"
)
parser
.
add_argument
(
"-erp5_base_list"
)
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
)
argument_list
=
build_command
(
args
.
apachedex_executable
.
strip
(),
args
.
output_folder
.
strip
(),
args
.
default
.
strip
(),
args
.
apache_log_list
,
base_list
,
skip_base_list
,
erp5_base_list
)
if
argument_list
is
1
:
return
1
subprocess
.
check_call
(
argument_list
)
with
open
(
output_file
,
'r'
)
as
f
:
print
f
.
read
()
return
0
if
__name__
==
"__main__"
:
sys
.
exit
(
main
())
slapos/test/test_runApacheDex.py
0 → 100644
View file @
55b013d0
##############################################################################
#
# Copyright (c) 2017 Vifib SARL and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import
unittest
import
os.path
import
tempfile
import
shutil
from
datetime
import
date
from
slapos.runapachedex
import
build_command
class
TestGenerateFeed
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
output_folder
=
tempfile
.
mkdtemp
(
dir
=
'.'
)
self
.
apachedex
=
"/bin/apachedex"
self
.
today
=
date
.
today
().
strftime
(
"%Y-%m-%d"
)
_
,
self
.
acesslog1
=
tempfile
.
mkstemp
()
_
,
self
.
acesslog2
=
tempfile
.
mkstemp
()
def
tearDown
(
self
):
shutil
.
rmtree
(
self
.
output_folder
)
def
test_simpleCommand
(
self
):
command
=
build_command
(
self
.
apachedex
,
self
.
output_folder
,
"foo"
,
[
self
.
acesslog1
,
self
.
acesslog2
])
output_file
=
os
.
path
.
join
(
self
.
output_folder
,
'ApacheDex-%s.html'
%
self
.
today
)
self
.
assertEqual
(
command
,
[
'/bin/apachedex'
,
'--js-embed'
,
'--out'
,
output_file
,
'--default'
,
'foo'
,
'--error-detail'
,
self
.
acesslog1
,
self
.
acesslog2
])
def
test_complexCommand
(
self
):
command
=
build_command
(
self
.
apachedex
,
self
.
output_folder
,
'default1'
,
[
self
.
acesslog1
,
self
.
acesslog2
],
[
'bar'
,
'foo'
])
output_file
=
os
.
path
.
join
(
self
.
output_folder
,
'ApacheDex-%s.html'
%
self
.
today
)
self
.
assertEqual
(
command
,
[
'/bin/apachedex'
,
'--js-embed'
,
'--out'
,
output_file
,
'--default'
,
'default1'
,
'--base'
,
'bar'
,
'foo'
,
'--error-detail'
,
self
.
acesslog1
,
self
.
acesslog2
])
if
__name__
==
'__main__'
:
unittest
.
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