- tagfile = apt_pkg.ParseTagFile(open(STATE_FILE))
- outfile = open(STATE_FILE+".tmp","w")
- while tagfile.Step():
- pkgname = tagfile.Section.get("Package")
- autoInst = tagfile.Section.get("Auto-Installed")
+ try:
+ tagfile = apt_pkg.TagFile(open(STATE_FILE))
+ outfile = open(STATE_FILE+".tmp","w")
+ except IOError, msg:
+ print "%s, are you root?" % (msg)
+ sys.exit(1)
+ for section in tagfile:
+ pkgname = section.get("Package")
+ autoInst = section.get("Auto-Installed")