def get_maintenance_status(self, cache, appname, pkgname, component,
                               channelname):
        # try to figure out the support dates of the release and make
        # sure to look only for stuff in "Ubuntu" and "distro_codename"
        # (to exclude stuff in ubuntu-updates for the support time
        # calculation because the "Release" file time for that gets
        # updated regularly)
        if not hasattr(cache, '_cache') or not pkgname:
            return
        releasef = get_release_filename_for_pkg(cache._cache, pkgname,
                                                "Ubuntu", self.get_codename())
        time_t = get_release_date_from_release_file(releasef)
        # check the release date and show support information
        # based on this
        if time_t:
            release_date = datetime.datetime.fromtimestamp(time_t)
            #print "release_date: ", release_date
            now = datetime.datetime.now()
            #release_age = (now - release_date).days
            #print "release age: ", release_age

            # init with the default time
            support_month = 18

            # see if we have a "Supported" entry in the pkg record
            if (pkgname in cache and cache[pkgname].candidate):
                support_time = cache._cache[pkgname].candidate.record.get(
                    "Supported")
                if support_time:
                    if support_time.endswith("y"):
                        support_month = 12 * int(support_time.strip("y"))
                    elif support_time.endswith("m"):
                        support_month = int(support_time.strip("m"))
                    else:
                        LOG.warning("unsupported 'Supported' string '%s'" %
                                    support_time)

            # mvo: we do not define the end date very precisely
            #      currently this is why it will just display a end
            #      range
            # print release_date, support_month
            (support_end_year, support_end_month) = get_maintenance_end_date(
                release_date, support_month)
            support_end_month_str = locale.nl_langinfo(
                getattr(locale, "MON_%d" % support_end_month))
            # check if the support has ended
            support_ended = (now.year >= support_end_year
                             and now.month > support_end_month)
            if component == "main":
                if support_ended:
                    return _("Canonical does no longer provide "
                             "updates for %s in Ubuntu %s. "
                             "Updates may be available in a newer version of "
                             "elementary OS.") % (appname,
                                                  self.get_distro_release())
                else:
                    return _("Canonical provides critical updates for "
                             "%(appname)s until %(support_end_month_str)s "
                             "%(support_end_year)s.") % {
                                 'appname': appname,
                                 'support_end_month_str':
                                 support_end_month_str,
                                 'support_end_year': support_end_year
                             }
            elif component == "restricted":
                if support_ended:
                    return _("Canonical does no longer provide "
                             "updates for %s in Ubuntu %s. "
                             "Updates may be available in a newer version of "
                             "elementary OS.") % (appname,
                                                  self.get_distro_release())
                else:
                    return _("Canonical provides critical updates supplied "
                             "by the developers of %(appname)s until "
                             "%(support_end_month_str)s "
                             "%(support_end_year)s.") % {
                                 'appname': appname,
                                 'support_end_month_str':
                                 support_end_month_str,
                                 'support_end_year': support_end_year,
                             }

        # if we couldn't determine a support date, use a generic maintenance
        # string without the date
        if (channelname
                or component in ("partner", "independent", "commercial")):
            return _("Provided by the vendor.")
        elif component == "main":
            return _("Canonical provides critical updates for %s.") % appname
        elif component == "restricted":
            return _("Canonical provides critical updates supplied by the "
                     "developers of %s.") % appname
        elif component == "universe" or component == "multiverse":
            return _("Canonical does not provide updates for %s. "
                     "Some updates may be provided by the "
                     "elementary OS community.") % appname
Пример #2
0
    def get_maintenance_status(self, cache, appname, pkgname, component,
        channelname):
        # try to figure out the support dates of the release and make
        # sure to look only for stuff in "Ubuntu" and "distro_codename"
        # (to exclude stuff in ubuntu-updates for the support time
        # calculation because the "Release" file time for that gets
        # updated regularly)
        if not hasattr(cache, '_cache') or not pkgname:
            return
        releasef = get_release_filename_for_pkg(cache._cache, pkgname,
                                                "Ubuntu",
                                                self.get_codename())
        time_t = get_release_date_from_release_file(releasef)
        # check the release date and show support information
        # based on this
        if time_t:
            release_date = datetime.datetime.fromtimestamp(time_t)
            #print "release_date: ", release_date
            now = datetime.datetime.now()
            #release_age = (now - release_date).days
            #print "release age: ", release_age

            # init with the default time
            support_month = 18

            # see if we have a "Supported" entry in the pkg record
            if (pkgname in cache and
                cache[pkgname].candidate):
                support_time = cache._cache[pkgname].candidate.record.get(
                    "Supported")
                if support_time:
                    if support_time.endswith("y"):
                        support_month = 12 * int(support_time.strip("y"))
                    elif support_time.endswith("m"):
                        support_month = int(support_time.strip("m"))
                    else:
                        LOG.warning("unsupported 'Supported' string '%s'" %
                            support_time)

            # mvo: we do not define the end date very precisely
            #      currently this is why it will just display a end
            #      range
            # print release_date, support_month
            (support_end_year, support_end_month) = get_maintenance_end_date(
                release_date, support_month)
            support_end_month_str = locale.nl_langinfo(
                getattr(locale, "MON_%d" % support_end_month))
             # check if the support has ended
            support_ended = (now.year >= support_end_year and
                             now.month > support_end_month)
            if component == "main":
                if support_ended:
                    return _("Canonical does no longer provide "
                             "updates for %s in Ubuntu %s. "
                             "Updates may be available in a newer version of "
                             "Ubuntu.") % (appname, self.get_distro_release())
                else:
                    return _("Canonical provides critical updates for "
                             "%(appname)s until %(support_end_month_str)s "
                             "%(support_end_year)s.") % {
                                'appname': appname,
                                'support_end_month_str': support_end_month_str,
                                'support_end_year': support_end_year}
            elif component == "restricted":
                if support_ended:
                    return _("Canonical does no longer provide "
                             "updates for %s in Ubuntu %s. "
                             "Updates may be available in a newer version of "
                             "Ubuntu.") % (appname, self.get_distro_release())
                else:
                    return _("Canonical provides critical updates supplied "
                             "by the developers of %(appname)s until "
                             "%(support_end_month_str)s "
                             "%(support_end_year)s.") % {
                                'appname': appname,
                                'support_end_month_str': support_end_month_str,
                                'support_end_year': support_end_year,
                            }

        # if we couldn't determine a support date, use a generic maintenance
        # string without the date
        if (channelname or
            component in ("partner", "independent", "commercial")):
            return _("Provided by the vendor.")
        elif component == "main":
            return _("Canonical provides critical updates for %s.") % appname
        elif component == "restricted":
            return _("Canonical provides critical updates supplied by the "
                     "developers of %s.") % appname
        elif component == "universe" or component == "multiverse":
            return _("Canonical does not provide updates for %s. "
                     "Some updates may be provided by the "
                     "Ubuntu community.") % appname
Пример #3
0
 def test_get_release_date_from_release_file(self):
     path = os.path.join(os.path.dirname(__file__), "data", "misc",
                         "foo_Release")
     t = get_release_date_from_release_file(path)
     self.assertEqual(str(datetime.datetime.utcfromtimestamp(t)),
                      "2012-04-25 22:49:23")
Пример #4
0
 def test_get_release_date_from_release_file(self):
     path = os.path.join(os.path.dirname(__file__), 
                         "data", "misc", "foo_Release")
     t = get_release_date_from_release_file(path)
     self.assertEqual(str(datetime.datetime.utcfromtimestamp(t)),
                      "2012-04-25 22:49:23")