Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sbws
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
juga
sbws
Commits
61f2ba84
Commit
61f2ba84
authored
6 years ago
by
juga
Browse files
Options
Downloads
Patches
Plain Diff
v3bwfile: include destinations' country in headers
Closes: #29299.
parent
fe281909
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
sbws/core/generate.py
+4
-1
4 additions, 1 deletion
sbws/core/generate.py
sbws/lib/v3bwfile.py
+9
-4
9 additions, 4 deletions
sbws/lib/v3bwfile.py
tests/unit/lib/test_v3bwfile.py
+6
-1
6 additions, 1 deletion
tests/unit/lib/test_v3bwfile.py
with
19 additions
and
6 deletions
sbws/core/generate.py
+
4
−
1
View file @
61f2ba84
...
...
@@ -9,6 +9,7 @@ from argparse import ArgumentDefaultsHelpFormatter
import
os
import
logging
from
sbws.util.timestamp
import
now_fname
from
sbws.lib
import
destination
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -106,7 +107,9 @@ def main(args, conf):
"
cached-consensus
"
)
# Accept None as scanner_country to be compatible with older versions.
scanner_country
=
conf
[
'
scanner
'
].
get
(
'
country
'
)
bw_file
=
V3BWFile
.
from_results
(
results
,
scanner_country
,
state_fpath
,
destinations_countries
=
destination
.
parse_destinations_countries
(
conf
)
bw_file
=
V3BWFile
.
from_results
(
results
,
scanner_country
,
destinations_countries
,
state_fpath
,
args
.
scale_constant
,
scaling_method
,
torflow_cap
=
args
.
torflow_bw_margin
,
round_digs
=
args
.
round_digs
,
...
...
This diff is collapsed.
Click to expand it.
sbws/lib/v3bwfile.py
+
9
−
4
View file @
61f2ba84
...
...
@@ -29,7 +29,7 @@ KEYVALUE_SEP_V2 = ' '
# List of the extra KeyValues accepted by the class
EXTRA_ARG_KEYVALUES
=
[
'
software
'
,
'
software_version
'
,
'
file_created
'
,
'
earliest_bandwidth
'
,
'
generator_started
'
,
'
scanner_country
'
]
'
scanner_country
'
,
'
destinations_countries
'
]
STATS_KEYVALUES
=
[
'
number_eligible_relays
'
,
'
minimum_number_eligible_relays
'
,
'
number_consensus_relays
'
,
'
percent_eligible_relays
'
,
'
minimum_percent_eligible_relays
'
]
...
...
@@ -141,7 +141,8 @@ class V3BWHeader(object):
return
self
.
strv2
@classmethod
def
from_results
(
cls
,
results
,
scanner_country
=
None
,
state_fpath
=
''
):
def
from_results
(
cls
,
results
,
scanner_country
=
None
,
destinations_countries
=
None
,
state_fpath
=
''
):
kwargs
=
dict
()
latest_bandwidth
=
cls
.
latest_bandwidth_from_results
(
results
)
earliest_bandwidth
=
cls
.
earliest_bandwidth_from_results
(
results
)
...
...
@@ -154,6 +155,8 @@ class V3BWHeader(object):
# To be compatible with older bandwidth files, do not require it.
if
scanner_country
is
not
None
:
kwargs
[
'
scanner_country
'
]
=
scanner_country
if
destinations_countries
is
not
None
:
kwargs
[
'
destinations_countries
'
]
=
destinations_countries
h
=
cls
(
timestamp
,
**
kwargs
)
return
h
...
...
@@ -528,7 +531,8 @@ class V3BWFile(object):
for
bw_line
in
self
.
bw_lines
])
@classmethod
def
from_results
(
cls
,
results
,
scanner_country
=
None
,
state_fpath
=
''
,
def
from_results
(
cls
,
results
,
scanner_country
=
None
,
destinations_countries
=
None
,
state_fpath
=
''
,
scale_constant
=
SBWS_SCALE_CONSTANT
,
scaling_method
=
TORFLOW_SCALING
,
torflow_obs
=
TORFLOW_OBS_LAST
,
...
...
@@ -555,7 +559,8 @@ class V3BWFile(object):
"""
log
.
info
(
'
Processing results to generate a bandwidth list file.
'
)
header
=
V3BWHeader
.
from_results
(
results
,
scanner_country
,
state_fpath
)
header
=
V3BWHeader
.
from_results
(
results
,
scanner_country
,
destinations_countries
,
state_fpath
)
bw_lines_raw
=
[]
number_consensus_relays
=
cls
.
read_number_consensus_relays
(
consensus_path
)
...
...
This diff is collapsed.
Click to expand it.
tests/unit/lib/test_v3bwfile.py
+
6
−
1
View file @
61f2ba84
...
...
@@ -18,6 +18,9 @@ timestamp_l = str(timestamp)
version_l
=
KEYVALUE_SEP_V1
.
join
([
'
version
'
,
SPEC_VERSION
])
scanner_country
=
'
US
'
scanner_country_l
=
KEYVALUE_SEP_V1
.
join
([
'
scanner_country
'
,
scanner_country
])
destinations_countries
=
'
00,DE
'
destinations_countries_l
=
KEYVALUE_SEP_V1
.
join
([
'
destinations_countries
'
,
destinations_countries
])
software_l
=
KEYVALUE_SEP_V1
.
join
([
'
software
'
,
'
sbws
'
])
software_version_l
=
KEYVALUE_SEP_V1
.
join
([
'
software_version
'
,
version
])
file_created
=
'
2018-04-25T13:10:57
'
...
...
@@ -25,7 +28,8 @@ file_created_l = KEYVALUE_SEP_V1.join(['file_created', file_created])
latest_bandwidth
=
'
2018-04-17T14:09:07
'
latest_bandwidth_l
=
KEYVALUE_SEP_V1
.
join
([
'
latest_bandwidth
'
,
latest_bandwidth
])
header_ls
=
[
timestamp_l
,
version_l
,
file_created_l
,
latest_bandwidth_l
,
header_ls
=
[
timestamp_l
,
version_l
,
destinations_countries_l
,
file_created_l
,
latest_bandwidth_l
,
scanner_country_l
,
software_l
,
software_version_l
,
TERMINATOR
]
header_str
=
LINE_SEP
.
join
(
header_ls
)
+
LINE_SEP
earliest_bandwidth
=
'
2018-04-16T14:09:07
'
...
...
@@ -56,6 +60,7 @@ v3bw_str = header_extra_str + raw_bwl_str
def
test_v3bwheader_str
():
"""
Test header str
"""
header
=
V3BWHeader
(
timestamp_l
,
scanner_country
=
scanner_country
,
destinations_countries
=
destinations_countries
,
file_created
=
file_created
)
assert
header_str
==
str
(
header
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment