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
b94f7ae0
Commit
b94f7ae0
authored
Jun 14, 2018
by
juga
Browse files
Generate v3bw files in a dir and named with timestamp
parent
c8009072
Changes
5
Hide whitespace changes
Inline
Side-by-side
sbws/config.default.ini
View file @
b94f7ae0
[paths]
datadir
=
${sbws_home}/datadir
v3bw_fname
=
${sbws_home}/v3bw.txt
v3bw_dname
=
${sbws_home}/v3bw
v3bw_fname
=
${v3bw_dname}/{}.v3bw
started_filepath
=
${sbws_home}/started_at
log_filepath
=
${sbws_home}/sbws.log
...
...
sbws/core/generate.py
View file @
b94f7ae0
...
...
@@ -35,6 +35,8 @@ def main(args, conf):
if
not
is_initted
(
args
.
directory
):
fail_hard
(
'Sbws isn
\'
t initialized. Try sbws init'
)
os
.
makedirs
(
conf
[
'paths'
][
'v3bw_dname'
],
exist_ok
=
True
)
datadir
=
conf
[
'paths'
][
'datadir'
]
if
not
os
.
path
.
isdir
(
datadir
):
fail_hard
(
'%s does not exist'
,
datadir
)
...
...
sbws/lib/v3bwfile.py
View file @
b94f7ae0
...
...
@@ -9,7 +9,7 @@ from sbws import __version__
from
sbws.globals
import
SPEC_VERSION
,
BW_LINE_SIZE
from
sbws.lib.resultdump
import
ResultSuccess
,
_ResultType
from
sbws.util.filelock
import
FileLock
from
sbws.util.timestamp
import
now_isodt_str
,
unixts_to_isodt_str
from
sbws.util.timestamp
import
now_isodt_str
,
unixts_to_isodt_str
,
now_fname
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -395,7 +395,7 @@ class V3BwFile(object):
bw_lines
=
scale_lines
(
bw_lines
,
args
.
scale_constant
)
header
=
V3BwHeader
.
from_results
(
conf
,
results
)
f
=
cls
(
header
,
bw_lines
)
output
=
args
.
output
or
conf
[
'paths'
][
'v3bw_fname'
]
output
=
args
.
output
or
conf
[
'paths'
][
'v3bw_fname'
]
.
format
(
now_fname
())
f
.
write
(
output
)
return
f
...
...
sbws/util/config.py
View file @
b94f7ae0
...
...
@@ -149,7 +149,7 @@ def _validate_paths(conf):
sec
=
'paths'
err_tmpl
=
Template
(
'$sec/$key ($val): $e'
)
unvalidated_keys
=
[
'datadir'
,
'sbws_home'
,
'v3bw_fname'
,
'datadir'
,
'sbws_home'
,
'v3bw_fname'
,
'v3bw_dname'
,
'started_filepath'
,
'log_filepath'
]
all_valid_keys
=
unvalidated_keys
allow_missing
=
[
'sbws_home'
]
...
...
sbws/util/timestamp.py
View file @
b94f7ae0
...
...
@@ -47,6 +47,16 @@ def now_isodt_str():
return
dt_obj_to_isodt_str
(
datetime
.
utcnow
())
def
now_fname
():
"""
Return now timestamp in UTC formatted as %Y%m%d_%H%M%S string for file
names.
:returns: now timestamp in UTC formatted as %Y%m%d_%H%M%S string
"""
return
datetime
.
utcnow
().
strftime
(
"%Y%m%d_%H%M%S"
)
def
unixts_to_str
(
unixts
):
"""Convert unix timestamp integer or float to string"""
# even if it is only converting to str, ensure that input is nothing else
...
...
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