Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Commits on Source (2)
In Python, when interval added to peer listings.
· 6a8158de
Eric S. Raymond
authored
Oct 22, 2016
6a8158de
pynptq opeers display: behave more sanely on out-of-bounds dispersion.
· aa240f9b
Eric S. Raymond
authored
Oct 22, 2016
aa240f9b
Hide whitespace changes
Inline
Side-by-side
libntp/pymodule.c
View file @
aa240f9b
...
...
@@ -14,6 +14,7 @@
#include
"ntp_fp.h"
#include
"ntp_stdlib.h"
#include
"ntp_random.h"
#include
"timespecops.h"
#include
"ntp_config.h"
#include
"ntp_assert.h"
...
...
@@ -58,6 +59,24 @@ libntpc_prettydate(PyObject *self, PyObject *args)
}
}
static
PyObject
*
libntpc_lfptofloat
(
PyObject
*
self
,
PyObject
*
args
)
{
char
*
s
;
l_fp
ts
;
struct
timespec
tt
;
UNUSED_ARG
(
self
);
if
(
!
PyArg_ParseTuple
(
args
,
"s"
,
&
s
))
return
NULL
;
if
(
!
hextolfp
(
s
+
2
,
&
ts
))
{
PyErr_SetString
(
PyExc_ValueError
,
"ill-formed hex date"
);
return
NULL
;
}
tt
=
lfp_stamp_to_tspec
(
ts
,
NULL
);
return
Py_BuildValue
(
"d"
,
tt
.
tv_sec
+
tt
.
tv_nsec
*
1e-9
);
}
/* List of functions defined in the module */
static
PyMethodDef
libntpc_methods
[]
=
{
...
...
@@ -65,6 +84,8 @@ static PyMethodDef libntpc_methods[] = {
PyDoc_STR
(
"Status string display from peer status word."
)},
{
"prettydate"
,
libntpc_prettydate
,
METH_VARARGS
,
PyDoc_STR
(
"Status string display from peer status word."
)},
{
"lfptofloat"
,
libntpc_lfptofloat
,
METH_VARARGS
,
PyDoc_STR
(
"NTP l_fp to Python-style float time."
)},
{
NULL
,
NULL
,
0
,
NULL
}
/* sentinel */
};
...
...
ntpq/pyntpq
View file @
aa240f9b
...
...
@@ -217,8 +217,8 @@ usage: help [ command ]
# Unexposed helper tables and functions begin here
__common
=
"
st t when poll reach delay offset
"
__opeerheader
=
"
remote local
"
+
__common
+
"
disp
\n
"
__common
=
"
st t when poll reach delay offset
"
__opeerheader
=
"
remote local
"
+
__common
+
"
disp
\n
"
__peerheader
=
"
remote refid
"
+
__common
+
"
jitter
\n
"
__apeerheader
=
"
remote refid assid
"
+
__common
+
"
jitter
\n
"
...
...
@@ -468,15 +468,17 @@ usage: help [ command ]
else
:
sys
.
stdout
.
write
(
"
"
*
(
addrwidth
-
len
(
visible
)))
# The rest of the story
#prettyinterval(when(&ts, &rec, &reftime)),
last_sync
=
variables
.
get
(
"
rec
"
)
or
variables
.
get
(
"
reftime
"
)
jd
=
estjitter
if
have_jitter
else
estdisp
jd
=
"
-
"
if
jd
>=
999
else
(
"
%7.3f
"
%
jd
)
sys
.
stdout
.
write
(
"
%2ld %c %4.4s %4.4s %3lo %7.3f %8.3f %
7.3f
\n
"
%
\
"
%2ld %c %4.4s %4.4s %3lo %7.3f %8.3f %
s
\n
"
%
\
(
variables
.
get
(
"
stratum
"
,
0
),
ptype
,
Ntpq
.
prettyinterval
(
0
),
Ntpq
.
prettyinterval
(
now
if
last_sync
is
None
else
int
(
now
-
lfptofloat
(
last_sync
))
),
Ntpq
.
prettyinterval
(
poll_sec
),
reach
,
estdelay
,
estoffset
,
estjitter
if
have_jitter
else
estdisp
))
jd
))
return
True
else
:
return
True
...
...