summaryrefslogtreecommitdiff
path: root/src/leap/util
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2013-03-13 09:43:13 -0300
committerTomás Touceda <chiiph@leap.se>2013-03-13 09:43:13 -0300
commit70c402fe170ca4e01159b03739b7cacda7b0dfd0 (patch)
treef4e552d59a2e8b651ae754e80c308c4c12984857 /src/leap/util
parenta3d01f3285c7432675649e26aa95e31a64b73cbf (diff)
Add mtime check for existing json definitions before download
Also, wait for threads to finish when quitting
Diffstat (limited to 'src/leap/util')
-rw-r--r--src/leap/util/checkerthread.py1
-rw-r--r--src/leap/util/files.py18
2 files changed, 18 insertions, 1 deletions
diff --git a/src/leap/util/checkerthread.py b/src/leap/util/checkerthread.py
index 681c33e1..3430a450 100644
--- a/src/leap/util/checkerthread.py
+++ b/src/leap/util/checkerthread.py
@@ -64,7 +64,6 @@ class CheckerThread(QtCore.QThread):
"""
QtCore.QMutexLocker(self._should_quit_lock)
self._should_quit = True
- self.wait()
def start(self):
"""
diff --git a/src/leap/util/files.py b/src/leap/util/files.py
index f7fda39e..8c7a5af3 100644
--- a/src/leap/util/files.py
+++ b/src/leap/util/files.py
@@ -1,6 +1,7 @@
import os
import stat
import logging
+import time
logger = logging.getLogger(__name__)
@@ -25,3 +26,20 @@ def check_and_fix_urw_only(cert):
logger.error('Error while trying to chmod 600 %s' %
cert)
raise
+
+
+def get_mtime(filename):
+ """
+ Returns the modified time or None if the file doesn't exist
+
+ @param filename: path to check
+ @type filename: str
+
+ @rtype: str
+ """
+ try:
+ _mtime = os.stat(filename)[8]
+ mtime = time.strftime("%c GMT", time.gmtime(_mtime))
+ return mtime
+ except OSError:
+ return None