Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- import datetime
- def last_update():
- """function to return time for last update"""
- last_update_time = datetime.datetime(2013, 1, 1, 0, 0)
- with open("/var/log/pacman.log", 'r') as logfile:
- for line in logfile:
- if (line.find("starting full system upgrade") > -1):
- last_update_time = datetime.datetime(int(line[1:5]), int(line[6:8]), int(line[9:11]), int(line[12:14]), int(line[15:17]))
- return last_update_time
- def since_last_update(last_update_time):
- """function to return time since last update"""
- since_lu_time = datetime.datetime.now() - last_update_time
- formatline = u"%3i дней %2i часов %2i минут" %(since_lu_time.days, int(since_lu_time.seconds / 60 / 60), int(since_lu_time.seconds / 60) % 60)
- return formatline
- if __name__ == "__main__":
- print since_last_update(last_update())
Advertisement
Add Comment
Please, Sign In to add comment