port update-motd.d/40-updates to python3

jessie and trusty install python3-apt by default,
xenial no longer installes python-apt.
This commit is contained in:
j 2016-05-15 14:11:34 +02:00
parent 04845ffdf7
commit 700d109af6

View File

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
#
# 40-updates - create the list of packages for update with caching
# Copyright (c) 2015 Igor Pecovnik
@ -59,7 +59,7 @@ def refreshdata ():
# open the apt cache
try:
cache = apt_pkg.Cache(OpNullProgress())
except SystemError, e:
except SystemError as e:
sys.stderr.write("Error: Opening the cache (%s)" % e)
sys.exit(-1)
@ -87,7 +87,7 @@ def refreshdata ():
# then a standard upgrade
depcache.upgrade()
except SystemError, e:
except SystemError as e:
sys.stderr.write("Error: Couldn't mark the upgrade (%s)" % e)
sys.exit(-1)
@ -146,7 +146,7 @@ else:
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("[ \033[92m%d updates to install\033[0m: apt-get upgrade ]\n" % (updates))