View difference between Paste ID: Ypq2DCd7 and pt4qM5aR
SHOW: | | - or go back to the newest paste.
1
# -*- coding: utf-8 -*-
2
import datetime
3
4
5
def last_update():
6
    """function to return time for last update"""
7
    last_update_time = datetime.datetime(2013, 1, 1, 0, 0)
8
    with open("/var/log/pacman.log", 'r') as logfile:
9
        for line in logfile:
10
            if (line.find("starting full system upgrade") > -1):
11
                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]))
12
    return last_update_time
13
14
15
def since_last_update(last_update_time):
16
    """function to return time since last update"""
17
    since_lu_time = datetime.datetime.now() - last_update_time
18
    formatline = u"%3i дней %2i часов %2i минут" %(since_lu_time.days, int(since_lu_time.seconds / 60 / 60), int(since_lu_time.seconds / 60) % 60)
19
    return formatline
20
21
22
if __name__ == "__main__":
23
      print since_last_update(last_update())