diff options
author | Tomás Touceda <chiiph@leap.se> | 2013-03-13 09:43:13 -0300 |
---|---|---|
committer | Tomás Touceda <chiiph@leap.se> | 2013-03-13 09:43:13 -0300 |
commit | 70c402fe170ca4e01159b03739b7cacda7b0dfd0 (patch) | |
tree | f4e552d59a2e8b651ae754e80c308c4c12984857 /src/leap/util/files.py | |
parent | a3d01f3285c7432675649e26aa95e31a64b73cbf (diff) |
Add mtime check for existing json definitions before download
Also, wait for threads to finish when quitting
Diffstat (limited to 'src/leap/util/files.py')
-rw-r--r-- | src/leap/util/files.py | 18 |
1 files changed, 18 insertions, 0 deletions
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 |