hi,
how can i get a list of upgrade packages available and write it to file using python?
when i run
"apt-get upgrade > output" it works in bash, I think i have to send the trap signal (ctrl-C) in python program
any suggestions? on how to achieve this...
-krisdigitx
i tried this on the code now,
#!/usr/bin/env python
import subprocess
apt = subprocess.Popen([r"apt-get", "-V", "upgrade", ">", "/usr/src/python/upgrade.log"], stdin=subprocess.PIPE)
apt_stdin = apt.communicate()[0]
but it exits and does not write to the file........
this works... but i am getting error when i port this to other debian systems
import apt
cache=apt.Cache()
cache.update()
cache.open(None)
cache.upgrade()
for pkg in cache.get_changes():
# print pkg.name, pkg.summary
fileHandle = open('/tmp/upgrade.log', 'a')
fileHandle.write(pkg.name + " - " + pkg.summary + "\n")
this is the error....
/usr/lib/python2.5/site-packages/apt/__init__.py:18: FutureWarning: apt API not stable yet
warnings.warn("apt API not stable yet", FutureWarning)
Traceback (most recent call last):
File "apt-notify.py", line 13, in <module>
for pkg in cache.get_changes():
AttributeError: 'Cache' object has no attribute 'get_changes'