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

  1.  
  2. import Default
  3.  
  4. 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
  5. from AppInstall.Util import *
  6.  
  7. import datetime
  8. import locale
  9.  
  10. from gettext import gettext as _
  11.  
  12. class Distribution(Default.Distribution):
  13.  
  14.     def __init__(self):
  15.         Default.Distribution.__init__(self)
  16.         # Dictonary of all available filters with corresponding choser name
  17.         # and tooltip
  18.         # The installed filter will be automatically added in non-installer mode
  19.         # The primary and secondary filters are separated
  20.         self.filters_primary = {
  21.             SHOW_ALL : (_("All available applications"), ""),
  22.             SHOW_ONLY_FREE : (_("All Open Source applications"), ""),
  23.             }
  24.         self.filters_secondary = {
  25.             SHOW_ONLY_SUPPORTED : (_("Canonical-maintained applications"), ""),
  26.             SHOW_ONLY_THIRD_PARTY :(_("Third party applications"), ""),
  27.             }
  28.         # List of components whose applications should not be installed
  29.         # before asking for a confirmation
  30.         self.components_ask = ["universe", "multiverse"]
  31.         # Dictonary that provides dialog messages that are shown,
  32.         # before a component gets activated or when it requires to be confirmed
  33.         self.components_activation = {
  34.             # Fallback
  35.             None : [_("Enable the installation of software from the %s "
  36.                       "component of Ubuntu?"),
  37.                     # %s is the name of the component
  38.                     _("%s is not officially supported with security "
  39.                       "updates.")],
  40.             "main" : [_("Enable the installaion of officially "
  41.                         "supported Ubuntu software?"),
  42.                       # %s is the name of the application
  43.                       _("%s is part of the Ubuntu main distribution. "
  44.                         "Canonical Ltd. provides support and security "
  45.                         "updates, which will be enabled too.")],
  46.             "universe" : [_("Enable the installation of community maintained "
  47.                             "software?"),
  48.                           # %s is the name of the application
  49.                           _("%s is maintained by the Ubuntu community. "
  50.                             "The Ubuntu community provides support and "
  51.                             "security updates, which will be enabled too.")],
  52.             "multiverse" : [_("Enable the installation of unsupported and "
  53.                               "restricted software?"),
  54.                             # %s is the name of the application
  55.                             _("The use, modification and distribution of %s "
  56.                               "is restricted by copyright or by legal terms in "
  57.                               "some countries.")]
  58.               }
  59.  
  60.         self.dependencies_map = [
  61.             # KDE
  62.             (("kdelibs5","python-kde4","libqtgui4"),
  63.             # %s is the name of an application
  64.              None,
  65.              "application-kde"),
  66.             # GNOME
  67.             (("libgnome2-0","python-gnome2","libgtk2.0-0","python-gtk2"),
  68.             # %s is the name of an application
  69.              None, 
  70.              "application-gnome"),
  71.             # XUBUNTU
  72.             # FIXME: get an icon from xubuntu
  73.             (("libxfce4util4",),
  74.             # %s is the name of an application
  75.              None,
  76.              None)]
  77.  
  78.         self.comp_depend_map = { "universe":["main"],
  79.                                  "multiverse":["main", "universe"]}
  80.  
  81.     def get_app_emblems(self, app, cache):
  82.         # A short statement about the freedom, legal status and level of
  83.         # support of the application
  84.         emblems = []
  85.         icon_name = None
  86.         tooltip = None
  87.         if app.channel.endswith("-partner") and app.supported:
  88.             tooltip = _("%s is provided by a third party vendor "
  89.                         "from the Canonical partner repository.") % app.name
  90.             icon_name = "application-partner"
  91.             emblems.append((icon_name, tooltip))
  92.         elif app.component == "main" or app.supported:
  93.             tooltip = _("Canonical Ltd. provides technical support and "
  94.                         "security updates for %s") % app.name
  95.             icon_name = "application-supported"
  96.             emblems.append((icon_name, tooltip))
  97.         elif app.thirdparty or app.channel:
  98.             tooltip = ("%s is provided by a third party vendor "
  99.                        "and is therefore not an official part "
  100.                        "of Ubuntu. The third party vendor is "
  101.                        "responsible for support and security "
  102.                        "updates.") % app.name
  103.             icon_name = "application-proprietary"
  104.             emblems.append((icon_name, tooltip))
  105.         if app.component == "universe":
  106.             tooltip =_("This application is provided by the "
  107.                        "Ubuntu community.")
  108.             icon_name = "application-community"
  109.             emblems.append((icon_name, tooltip))
  110.         if app.component == "multiverse" or app.thirdparty:
  111.             tooltip = _("The use, modification and distribution "
  112.                         "of %s is restricted by copyright or by "
  113.                         "legal terms in some countries.") % app.name
  114.             icon_name = "application-proprietary"
  115.             emblems.append((icon_name, tooltip))
  116.  
  117.         # Add an emblem corresponding to the dependencies of the app
  118.         if cache.has_key(app.pkgname):
  119.             for (deps, tooltip, icon_name) in self.dependencies_map:
  120.                 for dep in deps:
  121.                     if cache.pkgDependsOn(app.pkgname, dep):
  122.                         if type(tooltip) == str:
  123.                             tooltip = tooltip % app.name
  124.                         emblems.append((icon_name, tooltip))
  125.                         break
  126.         return emblems
  127.  
  128.     def get_codec_information_link(self):
  129.         url = "https://codecs.canonical.com"
  130.         label = _("Buy Licensed Plug-ins...")
  131.         return (label, url)
  132.  
  133.     def get_maintenance_status(self, app, cache):
  134.  
  135.         # try to figure out the support dates of the release and make
  136.         # sure to look only for stuff in "Ubuntu" and "distro_codename"
  137.         # (to exclude stuff in ubuntu-updates for the support time 
  138.         # calculation because the "Release" file time for that gets
  139.         # updated regularly)
  140.         releasef = get_release_filename_for_pkg(cache, app.pkgname, 
  141.                                                 "Ubuntu", self.get_codename())
  142.         time_t = get_release_date_from_release_file(releasef)
  143.         # check the release date and show support information
  144.         # based on this
  145.         if time_t:
  146.             release_date = datetime.datetime.fromtimestamp(time_t)
  147.             #print "release_date: ", release_date
  148.             now = datetime.datetime.now()
  149.             release_age = (now - release_date).days
  150.             #print "release age: ", release_age
  151.  
  152.             # mvo: we do not define the end date very precisely
  153.             #      currently this is why it will just display a end
  154.             #      range
  155.             (support_end_year, support_end_month) = get_maintenance_end_date(release_date, 18)
  156.             support_end_month_str = locale.nl_langinfo(getattr(locale,"MON_%d" % support_end_month))
  157.              # check if the support has ended
  158.             support_ended = (now.year >= support_end_year and 
  159.                              now.month > support_end_month)
  160.             if app.component == "main":
  161.                 if support_ended:
  162.                     return _("Canonical does no longer provide "
  163.                              "updates for %s in Ubuntu %s. "
  164.                              "Updates may be available in a newer version of "
  165.                              "Ubuntu.") % (app.name, self.get_distro_release())
  166.                 else:
  167.                     return _("Canonical provides critical updates for "
  168.                              "%(appname)s until %(support_end_month_str)s "
  169.                              "%(support_end_year)s.") % {'appname' : app.name,
  170.                                                          'support_end_month_str' : support_end_month_str,
  171.                                                          'support_end_year' : support_end_year}
  172.             elif app.component == "restricted":
  173.                 if support_ended:
  174.                     return _("Canonical does no longer provide "
  175.                              "updates for %s in Ubuntu %s. "
  176.                              "Updates may be available in a newer version of "
  177.                              "Ubuntu.") % (app.name, self.get_distro_release())
  178.                 else:
  179.                     return _("Canonical provides critical updates supplied "
  180.                              "by the developers of %(appname)s until "
  181.                              "%(support_end_month_str)s "
  182.                              "%(support_end_year)s.") % {'appname' : app.name,
  183.                                                          'support_end_month_str' : support_end_month_str,
  184.                                                          'support_end_year' : support_end_year}
  185.                
  186.         # if we couldn't fiure a support date, use a generic maintenance
  187.         # string without the date
  188.         if app.thirdparty or app.channel:
  189.             return _("Canonical does not provide updates for %s. "
  190.                      "Some updates may be provided by the third party "
  191.                      "vendor.") % app.name
  192.         elif app.component == "main":
  193.             return _("Canonical provides critical updates for %s.") % app.name
  194.         elif app.component == "restricted":
  195.             return _("Canonical provides critical updates supplied by the "
  196.                      "developers of %s.") % app.name
  197.         elif app.component == "universe" or app.component == "multiverse":
  198.             return _("Canonical does not provide updates for %s. "
  199.                      "Some updates may be provided by the "
  200.                      "Ubuntu community.") % app.name
  201.         return _("Application %s has a unkown maintenance status.") % app.name
  202.         
  203.