Monitor IOU nvram for change

With the save as you go we need to save the startup config
when a change appear instead of the old commit system.
This commit is contained in:
Julien Duponchelle committed 2016-06-10 18:26:01 +02:00
1 parent 182a979e71
commit 69334665d2
4 files changed
+28 -26

No files matched your search

+5 -5
View File
@@ -23,6 +23,7 @@ class FileWatcher:
"""
Watch for file change and call the callback when something happen
"""
def __init__(self, path, callback, delay=1):
if not isinstance(path, str):
path = str(path)
@@ -32,7 +33,7 @@ class FileWatcher:
self._closed = False
try:
self._mtime = os.stat(path).st_mtime
self._mtime = os.stat(path).st_mtime_ns
except OSError:
self._mtime = None
asyncio.get_event_loop().call_later(self._delay, self._check_config_file_change)
@@ -48,9 +49,10 @@ class FileWatcher:
return
changed = False
try:
if os.stat(self._path).st_mtime != self._mtime:
mtime = os.stat(self._path).st_mtime_ns
if mtime != self._mtime:
changed = True
self._mtime = os.stat(self._path).st_mtime
self._mtime = mtime
except OSError:
self._mtime = None
if changed:
@@ -64,5 +66,3 @@ class FileWatcher:
@callback.setter
def callback(self, val):
self._callback = val