home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / bin / software-properties < prev    next >
Encoding:
Text File  |  2006-08-24  |  3.2 KB  |  94 lines

  1. #!/usr/bin/python
  2. # update-manager.in - easy updating application
  3. #  
  4. #  Copyright (c) 2004,2005 Canonical
  5. #                2004,2005 Michiel Sikkes
  6. #  
  7. #  Author: Michiel Sikkes <michiel@eyesopened.nl>
  8. #          Michael Vogt <mvo@debian.org>
  9. #  This program is free software; you can redistribute it and/or 
  10. #  modify it under the terms of the GNU General Public License as 
  11. #  published by the Free Software Foundation; either version 2 of the
  12. #  License, or (at your option) any later version.
  13. #  This program is distributed in the hope that it will be useful,
  14. #  but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. #  GNU General Public License for more details.
  17. #  You should have received a copy of the GNU General Public License
  18. #  along with this program; if not, write to the Free Software
  19. #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  20. #  USA
  21.  
  22. import pygtk
  23. pygtk.require('2.0')
  24. import gtk
  25. import gtk.gdk
  26. import gtk.glade
  27. import gobject
  28. import gettext
  29. import os
  30. import sys
  31.  
  32. from optparse import OptionParser
  33.  
  34. import UpdateManager.Common.aptsources as aptsources
  35.  
  36. #sys.path.append("@prefix@/share/update-manager/python")
  37.  
  38. from SoftwareProperties import SoftwareProperties
  39.  
  40. if __name__ == "__main__":
  41.   _ = gettext.gettext
  42.  
  43.   # Begin parsing of options
  44.   parser = OptionParser()
  45.   parser.add_option ("-n", "--no-update", action="store_true",
  46.                      dest="no_update", default=False,
  47.                      help="No update on repository change (usefull if called "\
  48.                      "from a external program).")
  49.   parser.add_option("-t", "--toplevel", 
  50.                     action="store", type="string", dest="toplevel",
  51.                     help="Set x-window-id of the toplevel parent for the "\
  52.                     "dialog (usefull for embedding)")
  53.   parser.add_option("-e", "--enable-component", 
  54.                     action="store", type="string", dest="enable_component",
  55.                     help="Enable the specified component of the distro's "\
  56.                     "repositories")
  57.                    
  58.  
  59.   (options, args) = parser.parse_args()
  60.   # Check for root permissions
  61.   if os.geteuid() != 0:
  62.     dialog = gtk.MessageDialog(None, 0, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, 
  63.                                _("You need to be root to run this program") )
  64.     dialog.set_default_response(gtk.RESPONSE_CLOSE)
  65.     dialog.run()
  66.     dialog.destroy()
  67.     sys.exit(1)
  68.                      
  69.   localesApp="update-manager"
  70.   localesDir="/usr/share/locale"
  71.   gettext.bindtextdomain(localesApp, localesDir)
  72.   gettext.textdomain(localesApp)
  73.   gtk.glade.bindtextdomain(localesApp, localesDir)
  74.   gtk.glade.textdomain(localesApp)
  75.  
  76.   data_dir="/usr/share/update-manager/"
  77.   #data_dir="/tmp/xxx/share/update-manager/"
  78.   file = None
  79.   if len(args) > 0:
  80.     file = args[0]
  81.   if options.enable_component:
  82.     sourceslist = aptsources.SourcesList()
  83.     distro = aptsources.Distribution()
  84.     distro.get_sources(sourceslist)
  85.     distro.enable_component(sourceslist, options.enable_component)
  86.     sourceslist.save()
  87.   else:
  88.     app = SoftwareProperties.SoftwareProperties(data_dir, options, file)
  89.     app.run()
  90.     sys.exit(app.modified)
  91.