home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / lib / python2.4 / site-packages / GDebi / GDebiCli.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2006-08-31  |  2.8 KB  |  89 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.4)
  3.  
  4. import sys
  5. import time
  6. import thread
  7. import os
  8. import fcntl
  9. import string
  10. import apt
  11. import apt_pkg
  12. from gettext import gettext as _
  13. from DebPackage import DebPackage, MyCache
  14.  
  15. class GDebiCli(object):
  16.     
  17.     def __init__(self):
  18.         tp = apt.progress.OpTextProgress()
  19.         self._cache = MyCache(tp)
  20.  
  21.     
  22.     def open(self, file):
  23.         
  24.         try:
  25.             self._deb = DebPackage(self._cache, file)
  26.         except (IOError, SystemError):
  27.             e = None
  28.             print _('Failed to open the software package'), _('The package might be corrupted or you are not allowed to open the file. Check the permissions of the file.')
  29.             sys.exit(1)
  30.  
  31.         print self._deb.pkgName
  32.         
  33.         try:
  34.             print self._deb['Description']
  35.         except KeyError:
  36.             print _('No description is available')
  37.  
  38.         if not self._deb.checkDeb():
  39.             print _('This package is uninstallable')
  40.             print self._deb._failureString
  41.             return False
  42.         
  43.         (install, remove, unauthenticated) = self._deb.requiredChanges
  44.         if len(unauthenticated) > 0:
  45.             print _('The following packages are UNAUTHENTICATED: ')
  46.             for pkgname in unauthenticated:
  47.                 print pkgname + ' ',
  48.             
  49.         
  50.         if len(remove) > 0:
  51.             print _('Requires the REMOVAL of the following packages: ')
  52.             for pkgname in remove:
  53.                 print pkgname + ' ',
  54.             
  55.         
  56.         print 
  57.         if len(install) > 0:
  58.             print _('Requires the installation of the following packages: ')
  59.             for pkgname in install:
  60.                 print pkgname + ' ',
  61.             
  62.         
  63.         print 
  64.         return True
  65.  
  66.     
  67.     def install(self):
  68.         (install, remove, unauthenticated) = self._deb.requiredChanges
  69.         if len(install) > 0 or len(remove) > 0:
  70.             fprogress = apt.progress.TextFetchProgress()
  71.             iprogress = apt.progress.InstallProgress()
  72.             res = self._cache.commit(fprogress, iprogress)
  73.         
  74.         os.system('dpkg -i %s' % self._deb.file)
  75.  
  76.  
  77. if __name__ == '__main__':
  78.     app = GDebiCli()
  79.     if not app.open(sys.argv[1]):
  80.         sys.exit(1)
  81.     
  82.     print _('Do you want to install the software package? [y/N]:'),
  83.     sys.stdout.flush()
  84.     res = sys.stdin.readline()
  85.     if res.startswith('y') or res.startswith('Y'):
  86.         app.install()
  87.     
  88.  
  89.