home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / bin / gdebi-gtk < prev    next >
Encoding:
Text File  |  2009-04-01  |  2.6 KB  |  87 lines

  1. #!/usr/bin/python
  2. #
  3. # Copyright (c) 2005-2009 Canonical Ltd
  4. #
  5. # AUTHOR:
  6. # Michael Vogt <mvo@ubuntu.com>
  7. #
  8. # This file is part of GDebi
  9. #
  10. # GDebi is free software; you can redistribute it and/or
  11. # modify it under the terms of the GNU General Public License as published
  12. # by the Free Software Foundation; either version 2 of the License, or (at
  13. # your option) any later version.
  14. #
  15. # GDebi is distributed in the hope that it will be useful,
  16. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  18. # General Public License for more details.
  19. #
  20. # You should have received a copy of the GNU General Public License
  21. # along with GDebi; if not, write to the Free Software
  22. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  23. #
  24.  
  25. import sys
  26. import apt
  27. import os.path
  28.  
  29.  
  30. from optparse import OptionParser
  31. from GDebi.GDebi import GDebi
  32.  
  33. from gettext import gettext as _
  34. import gettext
  35.  
  36. import pygtk
  37. pygtk.require("2.0")
  38. import gtk
  39.  
  40.  
  41. if __name__ == "__main__":
  42.     data="/usr/share/gdebi"
  43.  
  44.     localesApp="gdebi"
  45.     localesDir="/usr/share/locale"
  46.     gettext.bindtextdomain(localesApp, localesDir)
  47.     gettext.textdomain(localesApp)
  48.  
  49.     parser = OptionParser()
  50.     parser.add_option("-n", "--non-interactive",
  51.                       action="store_true", dest="non_interactive",
  52.                       default=False,
  53.                       help=_("Run non-interactive (dangerous!)"))
  54.     (options, args) = parser.parse_args()
  55.  
  56.     try:
  57.         gtk.init_check()
  58.     except RuntimeError, e:
  59.         sys.stderr.write("Can not start %s: %s. Exiting\n" % (sys.argv[0], e))
  60.         sys.exit(1)
  61.  
  62.     afile = ""
  63.     if len(args) >= 1:
  64.         afile = args[0]
  65.         
  66.     try:
  67.         app = GDebi(datadir=data,options=options,file=afile)
  68.     except SystemError, e:
  69.         err_header = _("Software index is broken")
  70.         err_body = _("This is a major failure of your software " 
  71.                     "management system. Please check for broken packages "
  72.                     "with synaptic, check the file permissions and "
  73.                     "correctness of the file '/etc/apt/sources.list' and "
  74.                     "reload the software information with: "
  75.                     "'sudo apt-get update' and 'sudo apt-get install -f'."
  76.                     )
  77.         dia = gtk.MessageDialog(None, 0, gtk.MESSAGE_ERROR,
  78.                                 gtk.BUTTONS_OK, "")
  79.         dia.set_markup("<b><big>%s</big></b>" % err_header)
  80.         dia.format_secondary_text(err_body)
  81.         dia.run()
  82.         sys.exit(1)
  83.         
  84.     if options.non_interactive == True:
  85.         app.on_button_install_clicked(None)
  86.     app.run()
  87.