Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Network Health
sbws
Commits
589da111
Commit
589da111
authored
May 23, 2018
by
juga
Committed by
Matt Traudt
Jun 05, 2018
Browse files
Fix mispelled latest
parent
aa1dd5ad
Changes
2
Hide whitespace changes
Inline
Side-by-side
sbws/lib/v3bwfile.py
View file @
589da111
...
...
@@ -18,7 +18,7 @@ KEYVALUE_SEP_V200 = ' '
EXTRA_ARG_KEYVALUES
=
[
'software'
,
'software_version'
,
'file_created'
,
'earliest_bandwidth'
,
'generator_started'
]
# List of all unordered KeyValues currently being used to generate the file
UNORDERED_KEYVALUES
=
EXTRA_ARG_KEYVALUES
+
[
'la
s
test_bandwidth'
]
UNORDERED_KEYVALUES
=
EXTRA_ARG_KEYVALUES
+
[
'latest_bandwidth'
]
# List of all the KeyValues currently being used to generate the file
ALL_KEYVALUES
=
[
'version'
]
+
UNORDERED_KEYVALUES
TERMINATOR
=
'===='
...
...
@@ -71,9 +71,9 @@ class V3BwHeader(object):
self
.
software
=
kwargs
.
get
(
'software'
,
'sbws'
)
self
.
software_version
=
kwargs
.
get
(
'software_version'
,
__version__
)
self
.
file_created
=
kwargs
.
get
(
'file_created'
,
now_isodt_str
())
# la
s
test_bandwidth should not be in kwargs, since it MUST be the
# latest_bandwidth should not be in kwargs, since it MUST be the
# same as timestamp
self
.
la
s
test_bandwidth
=
unixts_to_isodt_str
(
timestamp
)
self
.
latest_bandwidth
=
unixts_to_isodt_str
(
timestamp
)
[
setattr
(
self
,
k
,
v
)
for
k
,
v
in
kwargs
.
items
()
if
k
in
EXTRA_ARG_KEYVALUES
]
...
...
@@ -167,7 +167,7 @@ class V3BwHeader(object):
return
read_started_ts
(
conf
)
@
staticmethod
def
la
s
test_bandwidth_from_results
(
results
):
def
latest_bandwidth_from_results
(
results
):
return
round
(
max
([
r
.
time
for
fp
in
results
for
r
in
results
[
fp
]]))
@
staticmethod
...
...
@@ -177,11 +177,11 @@ class V3BwHeader(object):
@
classmethod
def
from_results
(
cls
,
conf
,
results
):
kwargs
=
dict
()
la
s
test_bandwidth
=
cls
.
la
s
test_bandwidth_from_results
(
results
)
earliest_bandwidth
=
cls
.
la
s
test_bandwidth_from_results
(
results
)
latest_bandwidth
=
cls
.
latest_bandwidth_from_results
(
results
)
earliest_bandwidth
=
cls
.
latest_bandwidth_from_results
(
results
)
generator_started
=
cls
.
generator_started_from_file
(
conf
)
timestamp
=
str
(
la
s
test_bandwidth
)
kwargs
[
'la
s
test_bandwidth'
]
=
unixts_to_isodt_str
(
la
s
test_bandwidth
)
timestamp
=
str
(
latest_bandwidth
)
kwargs
[
'latest_bandwidth'
]
=
unixts_to_isodt_str
(
latest_bandwidth
)
kwargs
[
'earliest_bandwidth'
]
=
unixts_to_isodt_str
(
earliest_bandwidth
)
kwargs
[
'generator_started'
]
=
generator_started
h
=
cls
(
timestamp
,
**
kwargs
)
...
...
tests/unit/lib/test_v3bwfile.py
View file @
589da111
...
...
@@ -11,10 +11,10 @@ software_l = KEYVALUE_SEP_V110.join(['software', 'sbws'])
software_version_l
=
KEYVALUE_SEP_V110
.
join
([
'software_version'
,
version
])
file_created
=
'2018-04-25T13:10:57'
file_created_l
=
KEYVALUE_SEP_V110
.
join
([
'file_created'
,
file_created
])
la
s
test_bandwidth
=
'2018-04-17T14:09:07'
la
s
test_bandwidth_l
=
KEYVALUE_SEP_V110
.
join
([
'la
s
test_bandwidth'
,
la
s
test_bandwidth
])
header_ls
=
[
timestamp_l
,
version_l
,
file_created_l
,
la
s
test_bandwidth_l
,
latest_bandwidth
=
'2018-04-17T14:09:07'
latest_bandwidth_l
=
KEYVALUE_SEP_V110
.
join
([
'latest_bandwidth'
,
latest_bandwidth
])
header_ls
=
[
timestamp_l
,
version_l
,
file_created_l
,
latest_bandwidth_l
,
software_l
,
software_version_l
,
TERMINATOR
]
header_str
=
LINE_SEP
.
join
(
header_ls
)
+
LINE_SEP
earliest_bandwidth
=
'2018-04-16T14:09:07'
...
...
@@ -25,7 +25,7 @@ generator_started_l = KEYVALUE_SEP_V110.join(['generator_started',
generator_started
])
header_extra_ls
=
[
timestamp_l
,
version_l
,
earliest_bandwidth_l
,
file_created_l
,
generator_started_l
,
la
s
test_bandwidth_l
,
latest_bandwidth_l
,
software_l
,
software_version_l
,
TERMINATOR
]
header_extra_str
=
LINE_SEP
.
join
(
header_extra_ls
)
+
LINE_SEP
...
...
Write
Preview
Supports
Markdown
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