Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
apachedex
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
apachedex
Commits
33679833
Commit
33679833
authored
Apr 08, 2013
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for naming bases.
parent
55dd1135
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
12 deletions
+35
-12
apachedex/__init__.py
apachedex/__init__.py
+35
-12
No files found.
apachedex/__init__.py
View file @
33679833
...
@@ -664,14 +664,31 @@ class AggregateSiteUrl(argparse.Action):
...
@@ -664,14 +664,31 @@ class AggregateSiteUrl(argparse.Action):
}
}
def
__call__
(
self
,
parser
,
namespace
,
values
,
option_string
=
None
):
def
__call__
(
self
,
parser
,
namespace
,
values
,
option_string
=
None
):
action
=
base_action
=
self
.
__argument_to_aggregator
[
option_string
]
action
=
base_action
=
self
.
__argument_to_aggregator
[
option_string
]
dest
=
getattr
(
namespace
,
self
.
dest
)
site_list
,
site_caption_dict
=
getattr
(
namespace
,
self
.
dest
)
for
value
in
values
:
next_value
=
iter
(
values
).
next
while
True
:
try
:
value
=
next_value
()
except
StopIteration
:
break
if
value
in
site_caption_dict
:
raise
ValueError
(
'Duplicate base: %r'
%
value
)
if
action
is
not
None
and
value
[
0
]
==
'+'
:
caption
=
value
[
1
:]
try
:
value
=
next_value
()
except
StopIteration
:
raise
ValueError
(
'No base follows caption %r'
%
value
)
else
:
caption
=
value
site_caption_dict
[
value
]
=
caption
caption
=
None
match
=
re
.
compile
(
value
).
match
match
=
re
.
compile
(
value
).
match
if
base_action
is
not
None
:
if
base_action
is
not
None
:
match_suffix
=
re
.
compile
(
value
+
'(?P<suffix>.*)'
).
match
match_suffix
=
re
.
compile
(
value
+
'(?P<suffix>.*)'
).
match
action
=
partial
(
base_action
,
action
=
partial
(
base_action
,
suffix
=
lambda
x
:
match_suffix
(
x
).
group
(
'suffix'
))
suffix
=
lambda
x
:
match_suffix
(
x
).
group
(
'suffix'
))
de
st
.
append
((
value
,
match
,
action
))
site_li
st
.
append
((
value
,
match
,
action
))
def
_asMonthString
(
timestamp
):
def
_asMonthString
(
timestamp
):
dt
,
_
=
timestamp
.
split
(
' '
)
dt
,
_
=
timestamp
.
split
(
' '
)
...
@@ -778,7 +795,7 @@ period_parser = {
...
@@ -778,7 +795,7 @@ period_parser = {
unquoteToHtml
=
lambda
x
,
encoding
:
escape
(
unquote
(
x
).
decode
(
encoding
))
unquoteToHtml
=
lambda
x
,
encoding
:
escape
(
unquote
(
x
).
decode
(
encoding
))
def
asHTML
(
out
,
encoding
,
per_site
,
args
,
default_site
,
period_parameter_dict
,
def
asHTML
(
out
,
encoding
,
per_site
,
args
,
default_site
,
period_parameter_dict
,
stats
):
stats
,
site_caption_dict
):
period
=
period_parameter_dict
[
'period'
]
period
=
period_parameter_dict
[
'period'
]
decimator
=
period_parameter_dict
[
'decimator'
]
decimator
=
period_parameter_dict
[
'decimator'
]
date_format
=
period_parameter_dict
[
'date_format'
]
date_format
=
period_parameter_dict
[
'date_format'
]
...
@@ -821,10 +838,9 @@ def asHTML(out, encoding, per_site, args, default_site, period_parameter_dict,
...
@@ -821,10 +838,9 @@ def asHTML(out, encoding, per_site, args, default_site, period_parameter_dict,
for
date
,
hit
in
sorted
(
hit_per_day
.
iteritems
(),
key
=
ITEMGETTER0
):
for
date
,
hit
in
sorted
(
hit_per_day
.
iteritems
(),
key
=
ITEMGETTER0
):
out
.
write
(
'<tr><td>%s</td><td>%s</td></tr>'
%
(
date
,
hit
))
out
.
write
(
'<tr><td>%s</td><td>%s</td></tr>'
%
(
date
,
hit
))
out
.
write
(
'</table>'
)
out
.
write
(
'</table>'
)
for
site_id
,
data
in
per_site
.
iteritems
():
for
site_id
,
data
in
sorted
(
per_site
.
iteritems
(),
key
=
ITEMGETTER0
):
if
site_id
is
None
:
out
.
write
(
'<h1>Site: %s</h1>'
%
unquoteToHtml
(
site_caption_dict
.
get
(
site_id
=
default_site
site_id
,
site_id
),
encoding
))
out
.
write
(
'<h1>Site: %s</h1>'
%
unquoteToHtml
(
site_id
,
encoding
))
apdex_data
=
data
.
getApdexData
()
apdex_data
=
data
.
getApdexData
()
if
apdex_data
:
if
apdex_data
:
out
.
write
(
out
.
write
(
...
@@ -942,10 +958,14 @@ def main():
...
@@ -942,10 +958,14 @@ def main():
'Arguments (except for -d/--default) are interpreted as Python regexes. '
'Arguments (except for -d/--default) are interpreted as Python regexes. '
'Literal values are expected urlencoded. For example: '
'Literal values are expected urlencoded. For example: '
'--base "/%E6%96%87%E5%AD%97%E5%8C%96%E3%81%91(/|$|
\
\
?)" matches '
'--base "/%E6%96%87%E5%AD%97%E5%8C%96%E3%81%91(/|$|
\
\
?)" matches '
'"/
\
xe6
\
x96
\
x87
\
xe5
\
xad
\
x97
\
xe5
\
x8c
\
x96
\
xe3
\
x81
\
x91
" ("mojibake").'
)
'"/
\
xe6
\
x96
\
x87
\
xe5
\
xad
\
x97
\
xe5
\
x8c
\
x96
\
xe3
\
x81
\
x91
" ("mojibake").'
'You can name matched entries by providing a name before the regex,'
'prefixed by "+". For example: --base +foo "/foo(/|$|
\
\
?)" '
'"/bar(/|$|
\
\
?)" "+baz boo" "/baz(/|$|
\
\
?)" will defines 3 bases, named'
'"foo", "/bar(/|$|
\
\
?)" and "baz boo" respectively.'
)
group
.
add_argument
(
'-d'
,
'--default'
,
group
.
add_argument
(
'-d'
,
'--default'
,
help
=
'Caption for lines matching no prefix, or skip them if not provided.'
)
help
=
'Caption for lines matching no prefix, or skip them if not provided.'
)
group
.
add_argument
(
'--base'
,
dest
=
'path'
,
default
=
[]
,
nargs
=
'+'
,
group
.
add_argument
(
'--base'
,
dest
=
'path'
,
default
=
([],
{})
,
nargs
=
'+'
,
action
=
AggregateSiteUrl
,
action
=
AggregateSiteUrl
,
help
=
'Absolute base url(s) of some part of a site.'
)
help
=
'Absolute base url(s) of some part of a site.'
)
group
.
add_argument
(
'--erp5-base'
,
dest
=
'path'
,
nargs
=
'+'
,
group
.
add_argument
(
'--erp5-base'
,
dest
=
'path'
,
nargs
=
'+'
,
...
@@ -1014,7 +1034,7 @@ def main():
...
@@ -1014,7 +1034,7 @@ def main():
period
=
args
.
period
period
=
args
.
period
asDate
,
decimator
,
graph_period
,
date_format
,
placeholder_delta
,
\
asDate
,
decimator
,
graph_period
,
date_format
,
placeholder_delta
,
\
round_date
=
period_parser
[
period
]
round_date
=
period_parser
[
period
]
site_list
=
args
.
path
site_list
,
site_caption_dict
=
args
.
path
default_site
=
args
.
default
default_site
=
args
.
default
if
default_site
is
None
:
if
default_site
is
None
:
default_action
=
None
default_action
=
None
...
@@ -1024,6 +1044,7 @@ def main():
...
@@ -1024,6 +1044,7 @@ def main():
sys
.
exit
(
1
)
sys
.
exit
(
1
)
else
:
else
:
default_action
=
partial
(
GenericSiteStats
,
suffix
=
lambda
x
:
x
)
default_action
=
partial
(
GenericSiteStats
,
suffix
=
lambda
x
:
x
)
site_caption_dict
[
None
]
=
default_site
infile_list
=
args
.
logfile
infile_list
=
args
.
logfile
quiet
=
args
.
quiet
quiet
=
args
.
quiet
threshold
=
args
.
apdex
threshold
=
args
.
apdex
...
@@ -1168,7 +1189,9 @@ def main():
...
@@ -1168,7 +1189,9 @@ def main():
'no_url_lines'
:
no_url_lines
,
'no_url_lines'
:
no_url_lines
,
'skipped_lines'
:
skipped_lines
,
'skipped_lines'
:
skipped_lines
,
'skipped_user_agent'
:
skipped_user_agent
,
'skipped_user_agent'
:
skipped_user_agent
,
})
},
site_caption_dict
,
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
main
()
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