Change 40-updates logic regarding last upgrade date
This commit is contained in:
parent
b8671309e7
commit
3c147016ee
@ -27,7 +27,7 @@ import time
|
||||
import os
|
||||
import os.path as path
|
||||
|
||||
def refreshdata ():
|
||||
def refreshdata():
|
||||
# update procedure
|
||||
DISTRO = subprocess.Popen(["lsb_release", "-c", "-s"],
|
||||
stdout=subprocess.PIPE).communicate()[0].strip()
|
||||
@ -131,18 +131,17 @@ def refreshdata ():
|
||||
myfile = "/var/cache/apt/archives/updates.number"
|
||||
now = time.time()
|
||||
twodays_ago = now - 60*60*24*2 # Number of seconds in two days
|
||||
lastupgrade = os.stat('/var/cache/apt/archives').st_mtime
|
||||
lastupgrade = path.getmtime('/var/lib/dpkg/status')
|
||||
|
||||
if os.path.isfile(myfile):
|
||||
if path.isfile(myfile):
|
||||
fileCreation = path.getmtime(myfile)
|
||||
if (fileCreation < twodays_ago or lastupgrade != fileCreation):
|
||||
refreshdata ()
|
||||
if (fileCreation < twodays_ago or lastupgrade > fileCreation):
|
||||
refreshdata()
|
||||
else:
|
||||
refreshdata ()
|
||||
refreshdata()
|
||||
|
||||
# display if there are some upgrades
|
||||
|
||||
file = open(myfile, 'r+')
|
||||
updates = int(file.read())
|
||||
if updates > 0:
|
||||
print("[ \033[92m%d updates to install\033[0m: apt-get upgrade ]\n" % (updates))
|
||||
print("\n[ \033[92m%d updates to install\033[0m: apt-get upgrade ]\n" % (updates))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user