1 __all__=["writepid","removepid","daemonize"]
6 def diff_time(timestamp, abstime=True):
11 diff = now - timestamp
14 # return the number of seconds as a difference from current time.
16 if diff < 60: # sec in min.
18 t_str = "%s sec ago" % int(math.ceil(t))
19 elif diff < 60*60: # sec in hour
21 t_str = "%s min ago" % int(math.ceil(t))
22 elif diff < 60*60*24: # sec in day
24 t_str = "%s hrs ago" % int(math.ceil(t))
25 elif diff < 60*60*24*14: # sec in week
27 t_str = "%s days ago" % int(math.ceil(t))
28 elif diff <= 60*60*24*30: # approx sec in month
29 t = diff / (60*60*24*7)
30 t_str = "%s wks ago" % int(math.ceil(t))
31 elif diff > 60*60*24*30: # approx sec in month
32 t = diff / (60*60*24*30)
33 t_str = "%s mnths ago" % int(t)