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
juga
sbws
Commits
6573c754
Commit
6573c754
authored
Apr 25, 2018
by
juga
Browse files
Add class to generate bw file header
parent
2a09acf8
Changes
1
Show whitespace changes
Inline
Side-by-side
sbws/lib/v3bwfile.py
0 → 100644
View file @
6573c754
# -*- coding: utf-8 -*-
"""Classes and functions that create the bandwidth measurements document
(v3bw) used by bandwidth authorities."""
import
logging
from
sbws
import
version
from
sbws.globals
import
time_now
,
SPEC_VERSION
log
=
logging
.
getLogger
(
__name__
)
class
V3BwHeader
(
object
):
"""
Create a bandwidth measurements (V3bw) header
following bandwidth measurements document spec version 1.1.0.
:param int timestamp: timestamp in Unix Epoch seconds when the document
is created
:param str version: the spec version
:param str software: the name of the software that generates this
:param str software_version: the version of the software
"""
def
__init__
(
self
,
timestamp
=
None
,
version
=
SPEC_VERSION
,
software
=
'sbws'
,
software_version
=
version
):
self
.
timestamp
=
timestamp
or
int
(
time_now
())
self
.
version
=
version
self
.
software
=
software
self
.
software_version
=
software_version
def
__str__
(
self
):
"""Return header string following spec version 1.1.0."""
frmt
=
'{timestamp}
\n
version={version}
\n
software={software}
\n
'
\
'software_version={software_version}
\n
'
return
frmt
.
format
(
**
self
.
__dict__
)
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