home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / pyshared / AppInstall / distros / Default.py < prev    next >
Encoding:
Python Source  |  2009-03-31  |  3.4 KB  |  90 lines

  1. from AppInstall.Menu import SHOW_ALL, SHOW_ONLY_SUPPORTED, SHOW_ONLY_FREE, SHOW_ONLY_MAIN, SHOW_ONLY_PROPRIETARY, SHOW_ONLY_THIRD_PARTY, SHOW_ONLY_INSTALLED
  2.  
  3. from gettext import gettext as _
  4. import subprocess
  5.  
  6. class Distribution(object):
  7.     def __init__(self):
  8.         # Dictonary of all available filters with corresponding choser name
  9.         # and tooltip
  10.         # The installed filter will be automatically added in non-installer mode
  11.         # The primary and secondary filters are separated
  12.         self.filters_primary = {
  13.             SHOW_ALL : (_("All available applications"),
  14.                         _("Show all applications including ones which are "
  15.                           "unsupported and possibly restricted by law or "
  16.                           "copyright"))
  17.             }
  18.         self.filters_secondary = {}
  19.         # List of components whose applications should not be installed
  20.         # before asking for a confirmation
  21.         self.components_ask = []
  22.         # Dictonary that provides dialog messages that are shown,
  23.         # before a component gets activated or when it requires to be confirmed
  24.         self.components_activation = {
  25.             None : [_("Enable the installation of software from the %s "
  26.                       "component of Ubuntu?"),
  27.                     _("%s is not officially supported with security "
  28.                       "updates.")],
  29.               }
  30.         self.dependencies_map = []
  31.         self.comp_depend_map = {}
  32.  
  33.     def get_components_ask(self):
  34.         """
  35.         Returns a list of components whose applications should not be installed
  36.         before asking for a confirmation
  37.         """
  38.         return self.components_ask
  39.  
  40.     def get_codec_information_link(self):
  41.         """
  42.         Returns a link and a description to additional codec releated
  43.         information or possibilities, e.g. a link to a petition against
  44.         software patents or a shop to purchase codecs, just as the distro
  45.         pleases
  46.         """
  47.         return (None, None)
  48.  
  49.     def get_components_ask_msgs(self):
  50.         """
  51.         Returns a dictonary that provides dialog messages that are shown,
  52.         before a component gets activated or when it requires to be confirmed
  53.         """ 
  54.         return self.components_activation
  55.  
  56.     def get_codename(self):
  57.         """
  58.         Return the distribution codename of the current running distro
  59.         as returned by lsb_release
  60.         """
  61.         if not hasattr(self ,"codename"):
  62.             self.codename = subprocess.Popen(["lsb_release","-c","-s"],stdout=subprocess.PIPE).communicate()[0].strip()
  63.         return self.codename
  64.  
  65.     def get_distro_release(self):
  66.         """
  67.         Return the distribution release of the current running distro
  68.         as returned by lsb_release
  69.         """
  70.         if not hasattr(self ,"distro_release"):
  71.             self.distro_release = subprocess.Popen(["lsb_release","-r","-s"],stdout=subprocess.PIPE).communicate()[0].strip()
  72.         return self.distro_release
  73.  
  74.     def get_maintaince_status(self, app, cache):
  75.         """ 
  76.         return a string that gives information about the mainainance
  77.         status of the the given app
  78.         """
  79.         return ""
  80.  
  81.     def get_comp_dependencies(self, comp):
  82.         if self.comp_depend_map.has_key(comp):
  83.             return self.comp_depend_map[comp]
  84.         else:
  85.             return []
  86.  
  87. if __name__ == "__main__":
  88.     d = Distribution()
  89.     print "code: '%s'" % d.get_codename()
  90.