1# -*- coding: utf-8 -*- 2from __future__ import (absolute_import, division, print_function, 3 unicode_literals) 4from future.builtins import * # NOQA 5 6from datetime import datetime 7 8 9def asctime(): 10 """ 11 Returns the current time as a string hh:mm:ss 12 """ 13 a = str(datetime.utcnow()) 14 return a[11:19] 15 16 17def ascdate(): 18 """ 19 Returns the current date at yy/mm/dd 20 """ 21 a = str(datetime.utcnow()) 22 return a[2:10] 23 24 25def dsecs(dt): 26 """ 27 Given a timedelta object compute it as double seconds. 28 """ 29 d = dt.days * 86400. 30 d = d + dt.seconds 31 d = d + dt.microseconds / 1000000.0 32 return d 33 34 35def get_property(filename, key): 36 """ 37 Given a property filename get the value of the given key 38 """ 39 with open(filename, 'r') as fh: 40 lines = fh.readlines() 41 for line in lines: 42 line = line.strip() 43 if line.startswith(key): 44 ans = line[len(key) + 1:] 45 return ans 46 return "" 47