summaryrefslogtreecommitdiff
path: root/examples/python/nmex.py
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2018-06-15 08:36:22 +0200
committerLubomir Rintel <lkundrak@v3.sk>2018-06-15 08:36:22 +0200
commit9c0db9809496bad98d8d62e4f42a5643af9eccab (patch)
treedf9ccff7ea1d204218979187b25588a52e3c2e79 /examples/python/nmex.py
parent119e828dbeeeab134e83890b18d0b7a0c1838786 (diff)
downloadNetworkManager-9c0db9809496bad98d8d62e4f42a5643af9eccab.tar.gz
Revert "example/python: avoid falling back to CLOCK_MONOTONIC"
This breaks client tests on avery old kernel (2.6.32, RHEL 6). Traceback (most recent call last): File "./clients/tests/test-client.py", line 699, in setUp self.srv = NMStubServer(self._testMethodName) File "./clients/tests/test-client.py", line 309, in __init__ start = nmex.nm_boot_time_ns() File "/builddir/build/BUILD/NetworkManager-1.11.4/examples/python/nmex.py", line 54, in nm_boot_time_ns return sys_clock_gettime_ns(CLOCK_BOOTTIME) File "/builddir/build/BUILD/NetworkManager-1.11.4/examples/python/nmex.py", line 50, in sys_clock_gettime_ns return _sys_clock_gettime_ns(clock_id) File "/builddir/build/BUILD/NetworkManager-1.11.4/examples/python/nmex.py", line 39, in f raise OSError(errno_, os.strerror(errno_)) OSError: [Errno 22] Invalid argument This reverts commit 119e828dbeeeab134e83890b18d0b7a0c1838786.
Diffstat (limited to 'examples/python/nmex.py')
-rw-r--r--examples/python/nmex.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/examples/python/nmex.py b/examples/python/nmex.py
index 78489efeb3..a85eecaf87 100644
--- a/examples/python/nmex.py
+++ b/examples/python/nmex.py
@@ -50,8 +50,18 @@ def sys_clock_gettime_ns(clock_id):
return _sys_clock_gettime_ns(clock_id)
def nm_boot_time_ns():
- CLOCK_BOOTTIME = 7
- return sys_clock_gettime_ns(CLOCK_BOOTTIME)
+ # NetworkManager exposes some timestamps as CLOCK_BOOTTIME.
+ # Try that first (number 7).
+ try:
+ return sys_clock_gettime_ns(7)
+ except OSError as e:
+ # On systems, where this is not available, fallback to
+ # CLOCK_MONOTONIC (numeric 1).
+ # That is what NetworkManager does as well.
+ import errno
+ if e.errno == errno.EINVAL:
+ return sys_clock_gettime_ns(1)
+ raise
def nm_boot_time_us():
return nm_boot_time_ns() / 1000
def nm_boot_time_ms():