New Upstream Release - ntplib
Ready changes
Summary
Merged new upstream version: 0.4.0 (was: 0.3.3).
Resulting package
Built on 2022-05-05T04:35 (took 5m42s)
The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:
apt install -t fresh-releases python3-ntplib
Lintian Result
Diff
diff --git a/CHANGELOG b/CHANGELOG
index 12d3994..9834bec 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,12 @@
+version 0.4.0 - 2021-05-28
+--------------------------
+- flake8 conformance
+- Add ROA Reference ID
+
+version 0.3.4 - 2020-04-28
+--------------------------
+- Re-release of 0.3.3 (0.3.3 was mistakenly deleted from PyPI)
+
version 0.3.3 - 2015-07-27
--------------------------
- Change to more permissive MIT license
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..e90fcc6
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,23 @@
+###############################################################################
+# The MIT License (MIT)
+#
+# Copyright (C) 2009-2015 Charles-Francois Natali <cf.natali@gmail.com>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+###############################################################################
\ No newline at end of file
diff --git a/MANIFEST b/MANIFEST
deleted file mode 100644
index 00bd904..0000000
--- a/MANIFEST
+++ /dev/null
@@ -1,8 +0,0 @@
-ntplib.py
-test_ntplib.py
-setup.py
-CHANGELOG
-COPYING
-COPYING.LESSER
-MANIFEST
-PKG-INFO
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..8eb28dd
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1,3 @@
+include LICENSE
+include README.md
+include CHANGELOG
\ No newline at end of file
diff --git a/PKG-INFO b/PKG-INFO
index 43f8776..d813204 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,8 +1,8 @@
Metadata-Version: 1.1
Name: ntplib
-Version: 0.3.3
+Version: 0.4.0
Summary: Python NTP library
-Home-page: http://code.google.com/p/ntplib/
+Home-page: https://github.com/cf-natali/ntplib
Author: Charles-Francois Natali
Author-email: cf.natali@gmail.com
License: MIT
@@ -55,3 +55,8 @@ Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Operating System :: OS Independent
Classifier: Topic :: System :: Networking :: Time Synchronization
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3.6
+Classifier: Programming Language :: Python :: 3.7
+Classifier: Programming Language :: Python :: 3.8
+Classifier: Programming Language :: Python :: 3.9
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..77acbbd
--- /dev/null
+++ b/README.md
@@ -0,0 +1,42 @@
+<h1 align="center">ntplib</h1>
+<div align="center">An NTP Client for Python</div>
+<br />
+
+[![PyPI Status](https://img.shields.io/pypi/v/ntplib.svg)](https://pypi.python.org/pypi/ntplib)
+[![Downloads](https://img.shields.io/pypi/dm/ntplib.svg)](https://pypi.python.org/pypi/ntplib)
+
+# Description
+
+This module offers a simple interface to query NTP servers from Python.
+
+It also provides utility functions to translate NTP fields values to text
+(mode, leap indicator…). Since it’s pure Python, and only depends on core
+modules, it should work on any platform with a Python implementation.
+
+
+# Example
+
+```
+>>> import ntplib
+>>> from time import ctime
+>>> c = ntplib.NTPClient()
+>>> response = c.request('europe.pool.ntp.org', version=3)
+>>> response.offset
+-0.143156766891
+>>> response.version
+3
+>>> ctime(response.tx_time)
+'Sun May 17 09:32:48 2009'
+>>> ntplib.leap_to_text(response.leap)
+'no warning'
+>>> response.root_delay
+0.0046844482421875
+>>> ntplib.ref_id_to_text(response.ref_id)
+193.190.230.66
+```
+
+# Installation
+
+```
+python setup.py install
+```
\ No newline at end of file
diff --git a/debian/changelog b/debian/changelog
index 4f4ef51..9172e96 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+ntplib (0.4.0-1) UNRELEASED; urgency=low
+
+ * New upstream release.
+
+ -- Debian Janitor <janitor@jelmer.uk> Thu, 05 May 2022 04:29:49 -0000
+
ntplib (0.3.3-3) unstable; urgency=medium
[ Ondřej Nový ]
diff --git a/ntplib.egg-info/PKG-INFO b/ntplib.egg-info/PKG-INFO
new file mode 100644
index 0000000..d813204
--- /dev/null
+++ b/ntplib.egg-info/PKG-INFO
@@ -0,0 +1,62 @@
+Metadata-Version: 1.1
+Name: ntplib
+Version: 0.4.0
+Summary: Python NTP library
+Home-page: https://github.com/cf-natali/ntplib
+Author: Charles-Francois Natali
+Author-email: cf.natali@gmail.com
+License: MIT
+Description:
+ ntplib - Python NTP library
+ ===========================
+
+ Description
+ -----------
+
+ This module offers a simple interface to query NTP servers from Python.
+
+ It also provides utility functions to translate NTP fields values to text (mode,
+ leap indicator...). Since it's pure Python, and only depends on core modules, it
+ should work on any platform with a Python implementation.
+
+ Example
+ -------
+
+ >>> import ntplib
+ >>> from time import ctime
+ >>> c = ntplib.NTPClient()
+ >>> response = c.request('europe.pool.ntp.org', version=3)
+ >>> response.offset
+ -0.143156766891
+ >>> response.version
+ 3
+ >>> ctime(response.tx_time)
+ 'Sun May 17 09:32:48 2009'
+ >>> ntplib.leap_to_text(response.leap)
+ 'no warning'
+ >>> response.root_delay
+ 0.0046844482421875
+ >>> ntplib.ref_id_to_text(response.ref_id)
+ 193.190.230.66
+
+
+ Installation
+ ------------
+
+ As root::
+
+ # python setup.py install
+
+ or just copy ntplib.py inside a directory in your sys.path, e.g.
+ `/usr/lib/python2.5/`.
+
+Platform: UNKNOWN
+Classifier: License :: OSI Approved :: MIT License
+Classifier: Programming Language :: Python
+Classifier: Operating System :: OS Independent
+Classifier: Topic :: System :: Networking :: Time Synchronization
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3.6
+Classifier: Programming Language :: Python :: 3.7
+Classifier: Programming Language :: Python :: 3.8
+Classifier: Programming Language :: Python :: 3.9
diff --git a/ntplib.egg-info/SOURCES.txt b/ntplib.egg-info/SOURCES.txt
new file mode 100644
index 0000000..7b07c81
--- /dev/null
+++ b/ntplib.egg-info/SOURCES.txt
@@ -0,0 +1,11 @@
+CHANGELOG
+LICENSE
+MANIFEST.in
+README.md
+ntplib.py
+setup.cfg
+setup.py
+ntplib.egg-info/PKG-INFO
+ntplib.egg-info/SOURCES.txt
+ntplib.egg-info/dependency_links.txt
+ntplib.egg-info/top_level.txt
\ No newline at end of file
diff --git a/ntplib.egg-info/dependency_links.txt b/ntplib.egg-info/dependency_links.txt
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/ntplib.egg-info/dependency_links.txt
@@ -0,0 +1 @@
+
diff --git a/ntplib.egg-info/top_level.txt b/ntplib.egg-info/top_level.txt
new file mode 100644
index 0000000..829af4d
--- /dev/null
+++ b/ntplib.egg-info/top_level.txt
@@ -0,0 +1 @@
+ntplib
diff --git a/ntplib.py b/ntplib.py
index e43b571..f5c5e96 100644
--- a/ntplib.py
+++ b/ntplib.py
@@ -81,6 +81,7 @@ class NTP:
"1PPS": "External 1 PPS input",
"FREE": "(Internal clock)",
"INIT": "(Initialization)",
+ "ROA\0": "Real Observatorio de la Armada",
"\0\0\0\0": "NULL",
}
"""reference identifier table"""
@@ -112,7 +113,7 @@ class NTP:
"""leap indicator table"""
-class NTPPacket:
+class NTPPacket(object):
"""NTP packet class.
This represents an NTP packet.
@@ -166,7 +167,8 @@ class NTPPacket:
NTPException -- in case of invalid field
"""
try:
- packed = struct.pack(NTPPacket._PACKET_FORMAT,
+ packed = struct.pack(
+ NTPPacket._PACKET_FORMAT,
(self.leap << 6 | self.version << 3 | self.mode),
self.stratum,
self.poll,
@@ -198,8 +200,10 @@ class NTPPacket:
NTPException -- in case of invalid packet format
"""
try:
- unpacked = struct.unpack(NTPPacket._PACKET_FORMAT,
- data[0:struct.calcsize(NTPPacket._PACKET_FORMAT)])
+ unpacked = struct.unpack(
+ NTPPacket._PACKET_FORMAT,
+ data[0:struct.calcsize(NTPPacket._PACKET_FORMAT)]
+ )
except struct.error:
raise NTPException("Invalid NTP packet.")
@@ -227,7 +231,7 @@ class NTPStats(NTPPacket):
def __init__(self):
"""Constructor."""
- NTPPacket.__init__(self)
+ super(NTPStats, self).__init__()
self.dest_timestamp = 0
"""destination timestamp"""
@@ -269,14 +273,14 @@ class NTPStats(NTPPacket):
return ntp_to_system_time(self.dest_timestamp)
-class NTPClient:
+class NTPClient(object):
"""NTP client session."""
def __init__(self):
"""Constructor."""
pass
- def request(self, host, version=2, port='ntp', timeout=5):
+ def request(self, host, version=2, port="ntp", timeout=5):
"""Query a NTP server.
Parameters:
@@ -299,8 +303,11 @@ class NTPClient:
s.settimeout(timeout)
# create the request packet - mode 3 is client
- query_packet = NTPPacket(mode=3, version=version,
- tx_timestamp=system_to_ntp_time(time.time()))
+ query_packet = NTPPacket(
+ mode=3,
+ version=version,
+ tx_timestamp=system_to_ntp_time(time.time())
+ )
# send the request
s.sendto(query_packet.to_data(), sockaddr)
@@ -437,11 +444,11 @@ def stratum_to_text(stratum):
NTPException -- in case of invalid stratum
"""
if stratum in NTP.STRATUM_TABLE:
- return NTP.STRATUM_TABLE[stratum] % (stratum)
+ return NTP.STRATUM_TABLE[stratum] % stratum
elif 1 < stratum < 16:
- return "secondary reference (%s)" % (stratum)
+ return "secondary reference (%s)" % stratum
elif stratum == 16:
- return "unsynchronized (%s)" % (stratum)
+ return "unsynchronized (%s)" % stratum
else:
raise NTPException("Invalid stratum or reserved.")
@@ -464,12 +471,12 @@ def ref_id_to_text(ref_id, stratum=2):
# return the result as a string or dot-formatted IP address
if 0 <= stratum <= 1:
- text = '%c%c%c%c' % fields
+ text = "%c%c%c%c" % fields
if text in NTP.REF_ID_TABLE:
return NTP.REF_ID_TABLE[text]
else:
- return "Unidentified reference source '%s'" % (text)
+ return "Unidentified reference source '%s'" % text
elif 2 <= stratum < 255:
- return '%d.%d.%d.%d' % fields
+ return "%d.%d.%d.%d" % fields
else:
raise NTPException("Invalid stratum.")
diff --git a/setup.cfg b/setup.cfg
new file mode 100644
index 0000000..aee541f
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,22 @@
+[bdist_wheel]
+universal = 1
+
+[flake8]
+max-line-length = 100
+inline-quotes = double
+
+[isort]
+balanced_wrapping = true
+line_length = 80
+lines_after_imports = 2
+multi_line_output = 3
+not_skip = __init__.py
+order_by_type = true
+
+[metadata]
+description-file = README.md
+
+[egg_info]
+tag_build =
+tag_date = 0
+
diff --git a/setup.py b/setup.py
index 6442f09..f6e9898 100644
--- a/setup.py
+++ b/setup.py
@@ -1,4 +1,4 @@
-from distutils.core import setup
+from setuptools import setup
long_description = """
@@ -47,19 +47,25 @@ or just copy ntplib.py inside a directory in your sys.path, e.g.
"""
-setup(name='ntplib',
- version='0.3.3',
- description='Python NTP library',
- author='Charles-Francois Natali',
- author_email='cf.natali@gmail.com',
- url='http://code.google.com/p/ntplib/',
- py_modules=['ntplib'],
- license='MIT',
- classifiers=[
- 'License :: OSI Approved :: MIT License',
- 'Programming Language :: Python',
- 'Operating System :: OS Independent',
- 'Topic :: System :: Networking :: Time Synchronization'
- ],
- long_description=long_description
- )
+setup(
+ name="ntplib",
+ version="0.4.0",
+ description="Python NTP library",
+ author="Charles-Francois Natali",
+ author_email="cf.natali@gmail.com",
+ url="https://github.com/cf-natali/ntplib",
+ py_modules=["ntplib"],
+ license="MIT",
+ classifiers=[
+ "License :: OSI Approved :: MIT License",
+ "Programming Language :: Python",
+ "Operating System :: OS Independent",
+ "Topic :: System :: Networking :: Time Synchronization",
+ "Programming Language :: Python :: 2.7",
+ "Programming Language :: Python :: 3.6",
+ "Programming Language :: Python :: 3.7",
+ "Programming Language :: Python :: 3.8",
+ "Programming Language :: Python :: 3.9",
+ ],
+ long_description=long_description
+)
diff --git a/test_ntplib.py b/test_ntplib.py
deleted file mode 100755
index 0a1e7cf..0000000
--- a/test_ntplib.py
+++ /dev/null
@@ -1,100 +0,0 @@
-"""Python NTP library tests."""
-
-
-import time
-import unittest
-
-import ntplib
-
-
-class TestNTPLib(unittest.TestCase):
-
- NTP_SERVER = "pool.ntp.org"
- """test NTP server"""
-
- POLL_DELAY = 1
- """delay between NTP polls, in seconds"""
-
- DELTA_TOLERANCE = 0.5
- """tolerance for offset/delay comparisons, in seconds"""
-
- def test_basic(self):
- """Basic tests."""
- self.assertTrue(issubclass(ntplib.NTPException, Exception))
-
- ntplib.NTPClient()
-
- def test_request(self):
- """Request tests."""
- client = ntplib.NTPClient()
-
- t1 = time.time()
- info = client.request(self.NTP_SERVER)
- t2 = time.time()
-
- # check response
- self.assertTrue(isinstance(info, ntplib.NTPStats))
- self.assertTrue(0 < info.version <= 4)
- self.assertTrue(isinstance(info.offset, float))
- self.assertTrue(0 <= info.stratum < 0xff)
- self.assertTrue(-0x7f <= info.precision < 0x7f)
- self.assertTrue(isinstance(info.root_delay, float))
- self.assertTrue(isinstance(info.root_dispersion, float))
- self.assertTrue(isinstance(info.delay, float))
- self.assertTrue(isinstance(info.leap, int))
- self.assertIn(info.leap, ntplib.NTP.LEAP_TABLE)
- self.assertTrue(0 <= info.poll < 0xfff)
- self.assertTrue(isinstance(info.mode, int))
- self.assertIn(info.mode, ntplib.NTP.MODE_TABLE)
- self.assertTrue(0 <= info.ref_id < 0xffffffff)
- self.assertTrue(isinstance(info.tx_time, float))
- self.assertTrue(isinstance(info.ref_time, float))
- self.assertTrue(isinstance(info.orig_time, float))
- self.assertTrue(isinstance(info.recv_time, float))
- self.assertTrue(isinstance(info.dest_time, float))
-
- time.sleep(self.POLL_DELAY)
-
- new_info = client.request(self.NTP_SERVER)
-
- # check timestamps
- self.assertTrue(t1 < info.orig_time < info.dest_time < t2)
- self.assertTrue(info.orig_time < new_info.orig_time)
- self.assertTrue(info.recv_time < new_info.recv_time)
- self.assertTrue(info.tx_time < new_info.tx_time)
- self.assertTrue(info.dest_time < new_info.dest_time)
-
- # check the offset and delay
- self.assertLess(abs(new_info.offset - info.offset),
- self.DELTA_TOLERANCE)
- self.assertLess(abs(new_info.delay - info.delay), self.DELTA_TOLERANCE)
-
- # try reaching a non existent server
- self.assertRaises(ntplib.NTPException,
- client.request, "localhost", port=42)
-
- # try reaching a non existent server with a custom timeout
- t = time.time()
- self.assertRaises(ntplib.NTPException,
- client.request, "localhost", port=42, timeout=1)
- self.assertTrue(0.7 < time.time() - t < 1.3)
-
- def test_helpers(self):
- """Helper methods tests."""
- client = ntplib.NTPClient()
-
- time.sleep(self.POLL_DELAY)
- info = client.request(self.NTP_SERVER)
-
- self.assertEqual(int(info.tx_time), ntplib.ntp_to_system_time(
- ntplib.system_to_ntp_time(int(info.tx_time))))
-
- self.assertTrue(isinstance(ntplib.leap_to_text(info.leap), str))
- self.assertTrue(isinstance(ntplib.mode_to_text(info.mode), str))
- self.assertTrue(isinstance(ntplib.stratum_to_text(info.stratum), str))
- self.assertTrue(isinstance(ntplib.ref_id_to_text(info.ref_id,
- info.stratum), str))
-
-
-if __name__ == '__main__':
- unittest.main()
Debdiff
[The following lists of changes regard files as different if they have different names, permissions or owners.]
Files in second set of .debs but not in first
-rw-r--r-- root/root /usr/lib/python3/dist-packages/ntplib-0.4.0.egg-info/PKG-INFO -rw-r--r-- root/root /usr/lib/python3/dist-packages/ntplib-0.4.0.egg-info/dependency_links.txt -rw-r--r-- root/root /usr/lib/python3/dist-packages/ntplib-0.4.0.egg-info/top_level.txt
Files in first set of .debs but not in second
-rw-r--r-- root/root /usr/lib/python3/dist-packages/ntplib-0.3.3.egg-info
No differences were encountered in the control files