From f79633b942f2ae5ee844cc4f2e17c0f338e4ba3c Mon Sep 17 00:00:00 2001 From: kali Date: Wed, 17 Jul 2013 06:01:03 +0900 Subject: fix locking for raising window --- src/leap/util/__init__.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'src/leap/util/__init__.py') diff --git a/src/leap/util/__init__.py b/src/leap/util/__init__.py index 5ceaede5..93eb714d 100644 --- a/src/leap/util/__init__.py +++ b/src/leap/util/__init__.py @@ -15,8 +15,10 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . """ -Initializes version and app info +Initializes version and app info, plus some small and handy functions. """ +import datetime +import os __version__ = "unknown" try: @@ -47,3 +49,29 @@ def first(things): return things[0] except TypeError: return None + + +def get_modification_ts(path): + """ + Gets modification time of a file. + + :param path: the path to get ts from + :type path: str + :returns: modification time + :rtype: datetime object + """ + ts = os.path.getmtime(path) + return datetime.datetime.fromtimestamp(ts) + + +def update_modification_ts(path): + """ + Sets modification time of a file to current time. + + :param path: the path to set ts to. + :type path: str + :returns: modification time + :rtype: datetime object + """ + os.utime(path, None) + return get_modification_ts(path) -- cgit v1.2.3