Skip to content
GitLab
Next
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Commits on Source (2)
OPen all files with "b" flag. For Python 3 compatibility
· 950d1fd9
Gary E. Miller
authored
Sep 10, 2016
Per the "Practical Python Porting"
950d1fd9
Run ntpviz past 2to3. Few changes.
· 9206f420
Gary E. Miller
authored
Sep 10, 2016
9206f420
Hide whitespace changes
Inline
Side-by-side
ntpstats/ntpviz
View file @
9206f420
...
...
@@ -66,7 +66,7 @@ def gnuplot(template, outfile=None):
if
outfile
is
None:
out =
None
else:
out =
open(outfile,
"
w
")
out =
open(outfile,
"
w
b
")
#
shell=
True
is
a
security
hazard
proc =
subprocess.Popen("gnuplot",
shell=
False,
bufsize=
4096,
...
...
@@ -210,7 +210,7 @@ plot \\
unit =
"ppb"
rnd =
0
percs.update
({
k:
round
(
v
*
multiplier
,
rnd
)
for
k
,
v
in
percs.items
()})
percs.update
({
k:
round
(
v
*
multiplier
,
rnd
)
for
k
,
v
in
list
(
percs.items
()
)
})
ninetynine =
percs[99]
ninetyfive =
percs[95]
five =
percs[5]
...
...
@@ -274,7 +274,7 @@ plot \
else:
unit =
"ns"
percs.update
({
k:
round
(
v
*
multiplier
,
rnd
)
for
k
,
v
in
percs.items
()})
percs.update
({
k:
round
(
v
*
multiplier
,
rnd
)
for
k
,
v
in
list
(
percs.items
()
)
})
ninetynine =
percs[99]
ninetyfive =
percs[95]
five =
percs[5]
...
...
@@ -364,7 +364,7 @@ plot \
multiplier =
1e9
rnd =
3
percs.update
({
k:
round
(
v*multiplier
,
rnd
)
for
k
,
v
in
percs.items
()})
percs.update
({
k:
round
(
v*multiplier
,
rnd
)
for
k
,
v
in
list
(
percs.items
()
)
})
ninetynine =
percs[99]
ninetyfive =
percs[95]
fifty =
percs[50]
...
...
@@ -455,7 +455,7 @@ plot \
rnd1 =
9
#
round
to
1
ns
boxes
boxwidth =
1e-9
percs.update
({
k:
round
(
v*multiplier
,
rnd
)
for
k
,
v
in
percs.items
()})
percs.update
({
k:
round
(
v*multiplier
,
rnd
)
for
k
,
v
in
list
(
percs.items
()
)
})
ninetynine =
percs[99]
ninetyfive =
percs[95]
five =
percs[5]
...
...
@@ -783,13 +783,13 @@ if __name__ == '__main__':
# if no ntpsec favicon.ico, write one.
ico_filename = os.path.join(outdir, "favicon.ico")
if not os.path.lexists( ico_filename ):
with open( ico_filename, "w" ) as wp:
with open( ico_filename, "w
b
" ) as wp:
wp.write(binascii.a2b_base64(ntpsec_ico))
# if no ntpsec logo, write one.
logo_filename = os.path.join(outdir, "ntpsec-logo.png")
if not os.path.lexists( logo_filename ):
with open( logo_filename, "w" ) as wp:
with open( logo_filename, "w
b
" ) as wp:
wp.write(binascii.a2b_base64(ntpsec_logo))
explanations = {
...
...
@@ -882,7 +882,7 @@ at 0s. Typical 90% ranges may be: local serial GPS 200 ms; local LAN peer
title = 'ntpviz'
if os.path.isfile(title_f):
try:
title_file = open( title_f, 'r')
title_file = open( title_f, 'r
b
')
title = title_file.read()
except IOError:
pass
...
...
@@ -1012,7 +1012,7 @@ ntpviz</a>, part of the <a href="https://www.ntpsec.org/">NTPsec project</a>
header = os.path.join(outdir, "header")
if os.path.isfile(header):
try:
header_file = open( header, 'r')
header_file = open( header, 'r
b
')
header_txt = header_file.read()
index_buffer += '
<br>
\n' + header_txt + '\n'
except IOError:
...
...
@@ -1031,7 +1031,7 @@ ntpviz</a>, part of the <a href="https://www.ntpsec.org/">NTPsec project</a>
("peer-offsets", stats.peer_offsets_gnuplot()),
]
peerlist = stats.peersplit().keys()
peerlist =
list(
stats.peersplit().keys()
)
# sort for output order stability
peerlist = sorted( peerlist )
for key in peerlist:
...
...
@@ -1066,7 +1066,7 @@ ntpviz</a>, part of the <a href="https://www.ntpsec.org/">NTPsec project</a>
footer = os.path.join(outdir, "footer")
if os.path.isfile(footer):
try:
footer_file = open( footer, 'r')
footer_file = open( footer, 'r
b
')
footer_txt = footer_file.read()
index_buffer += '
<br>
\n' + footer_txt + '\n'
except IOError:
...
...
@@ -1074,7 +1074,7 @@ ntpviz</a>, part of the <a href="https://www.ntpsec.org/">NTPsec project</a>
index_buffer += index_trailer
# and send the file buffer
with open(os.path.join(outdir, "index.html"), "w") as ifile:
with open(os.path.join(outdir, "index.html"), "w
b
") as ifile:
ifile.write(index_buffer)
ifile.close()
...
...