예제 #1
0
    def show(self, name, contract=None, start=None, end=None, account=None,
            management=None, support_level="", support_type="",
            virt_only=None, products=[], highlight=None):
        """
        Show subscription details.

        Start and end should be formatted strings, not actual date objects.
        Products is a list of tuples in the format (name, id)
        """
        # set a new buffer to clear out all the old tag information
        self.subscription_text.set_buffer(gtk.TextBuffer())
        self._set(self.subscription_text, name)
        buf = self.subscription_text.get_buffer()
        tag = buf.create_tag("highlight-tag", weight=pango.WEIGHT_BOLD)

        for index in utils.find_text(name, highlight):
            buf.apply_tag(tag, buf.get_iter_at_offset(index),
                    buf.get_iter_at_offset(index + len(highlight)))

        self._set(self.support_level_text, support_level)
        self._set(self.support_type_text, support_type)

        if self.show_contract:
            self._set(self.contract_number_text, contract)
            self._set(self.start_end_date_text, "%s - %s" % (
                      managerlib.formatDate(start), managerlib.formatDate(end)))
            self._set(self.account_text, account)
            self._set(self.provides_management_text, management)
            self._set(self.virt_only_text, virt_only)

        self.bundled_products.clear()
        for product in products:
            self.bundled_products.add_product(utils.apply_highlight(product[0],
                highlight), product[1])
예제 #2
0
    def _show_other_details(self, name, contract=None, start=None, end=None, account=None,
                           management=None, support_level="", support_type="",
                           virt_only=None, products=[], highlight=None, sku=None):
        self.start_end_date_text.modify_base(gtk.STATE_NORMAL,
                self._get_date_bg(end))

        self._set(self.contract_number_text, contract)
        self._set(self.start_end_date_text, "%s - %s" % (
                    managerlib.formatDate(start), managerlib.formatDate(end)))
        self._set(self.account_text, account)
        self._set(self.provides_management_text, management)
        self._set(self.virt_only_text, virt_only)
예제 #3
0
    def _show_other_details(self, name, contract=None, start=None, end=None, account=None,
                           management=None, support_level="", support_type="",
                           virt_only=None, products=[], highlight=None, sku=None):

        # Save the original background color for the
        # start_end_date_text widget so we can restore it in the
        # clear() function.
        self.original_bg = self.start_end_date_text.rc_get_style().base[gtk.STATE_NORMAL]

        self.start_end_date_text.modify_base(gtk.STATE_NORMAL,
                self._get_date_bg(end))

        self._set(self.contract_number_text, contract)
        self._set(self.start_end_date_text, "%s - %s" % (
                    managerlib.formatDate(start), managerlib.formatDate(end)))
        self._set(self.account_text, account)
        self._set(self.provides_management_text, management)
        self._set(self.virt_only_text, virt_only)
예제 #4
0
    def _set_validity_status(self):
        """ Updates the entitlement validity status portion of the UI. """

        if ClassicCheck().is_registered_with_classic():
            self._set_status_icons(VALID)
            self.subscription_status_label.set_text(
                get_branding().RHSMD_REGISTERED_TO_OTHER)
            return

        is_registered = self.consumer.is_valid()
        self.set_registered(is_registered)

        # Look for products which have invalid entitlements
        sorter = CertSorter(self.product_dir, self.entitlement_dir,
                            self.facts.get_facts())

        warn_count = len(sorter.expired_products) + \
                len(sorter.unentitled_products)

        partial_count = len(sorter.partially_valid_products)

        if warn_count > 0:
            self._set_status_icons(INVALID)
            # Change wording slightly for just one product
            if warn_count > 1:
                self.subscription_status_label.set_markup(
                    _("%s installed products do not have valid subscriptions.")
                    % warn_count)
            else:
                self.subscription_status_label.set_markup(
                    _("1 installed product does not have a valid subscription."
                      ))

        elif partial_count > 0:
            self._set_status_icons(PARTIAL)
            self.subscription_status_label.set_markup(
                _("This system does not match subscription limits."))

        else:
            first_invalid = find_first_invalid_date(self.entitlement_dir,
                                                    self.product_dir,
                                                    self.facts.get_facts())
            self._set_status_icons(VALID)
            if first_invalid:
                self.subscription_status_label.set_markup(
                        _("System is properly subscribed through %s.") % \
                            managerlib.formatDate(first_invalid))
            else:
                # No product certs installed, no first invalid date, and
                # the subscription assistant can't do anything, so we'll disable
                # the button to launch it:
                self.subscription_status_label.set_text(
                    _("No installed products detected."))

        if not is_registered:
            self.subscription_status_label.set_text(
                _("Keep your system up to date by registering."))
예제 #5
0
    def do_set_property(self, prop, value):
        """
        called to set the date property for rendering in a cell.
        we convert to display in the user's locale, then pass on to the cell
        renderer.
        """

        if value:
            date = managerlib.formatDate(value)
        else:
            date = value

        gtk.CellRendererText.set_property(self, 'text', date)
예제 #6
0
    def do_set_property(self, prop, value):
        """
        called to set the date property for rendering in a cell.
        we convert to display in the user's locale, then pass on to the cell
        renderer.
        """

        if value:
            date = managerlib.formatDate(value)
        else:
            date = value

        gtk.CellRendererText.set_property(self, 'text', date)
예제 #7
0
    def _set_validity_status(self):
        """ Updates the entitlement validity status portion of the UI. """

        if ClassicCheck().is_registered_with_classic():
            self._set_status_icons(VALID)
            self.subscription_status_label.set_text(
                _("This system is registered to RHN Classic"))
            return

        is_registered = ConsumerIdentity.existsAndValid()
        self.set_registered(is_registered)

        # Look for products which have invalid entitlements
        sorter = CertSorter(self.product_dir, self.entitlement_dir,
                            self.facts.get_facts())

        warn_count = len(sorter.expired_products) + \
                len(sorter.unentitled_products)

        partial_count = len(sorter.partially_valid_products)

        if warn_count > 0:
            self._set_status_icons(INVALID)
            # Change wording slightly for just one product
            if warn_count > 1:
                self.subscription_status_label.set_markup(
                    _("You have <b>%s</b> products with <i>invalid</i> entitlement certificates."
                      ) % warn_count)
            else:
                self.subscription_status_label.set_markup(
                    _("You have <b>1</b> product with an <i>invalid</i> entitlement certificate."
                      ))

        elif partial_count > 0:
            self._set_status_icons(PARTIAL)
            # Change wording slightly for just one product
            if partial_count > 1:
                self.subscription_status_label.set_markup(
                    _("You have <b>%s</b> products in need of <i>additional</i> entitlement certificates."
                      ) % partial_count)
            else:
                self.subscription_status_label.set_markup(
                    _("You have <b>1</b> product in need of <i>additional</i> entitlement certificates."
                      ))

        else:
            first_invalid = find_first_invalid_date(self.entitlement_dir,
                                                    self.product_dir,
                                                    self.facts.get_facts())
            self._set_status_icons(VALID)
            if first_invalid:
                self.subscription_status_label.set_markup(
                        _("Product entitlement certificates <i>valid</i> until %s") % \
                            managerlib.formatDate(first_invalid))
            else:
                # No product certs installed, no first invalid date, and
                # the subscription assistant can't do anything, so we'll disable
                # the button to launch it:
                self.subscription_status_label.set_text(
                    _("No product certificates installed."))

        if not is_registered:
            self.subscription_status_label.set_text(
                _("You must register this system before subscribing."))
예제 #8
0
    def update_products(self):
        self.store.clear()
        self.cs = cert_sorter.CertSorter(self.product_dir,
                                         self.entitlement_dir,
                                         self.facts.get_facts())
        for product_cert in self.product_dir.list():
            for product in product_cert.getProducts():
                product_id = product.getHash()
                status = self.cs.get_status(product_id)

                entry = {}
                entry['product'] = product.getName()
                entry['version'] = product.getVersion()
                entry['arch'] = product.getArch()
                entry['product_id'] = product_id
                # Common properties
                entry['align'] = 0.5

                # TODO:  Pull this date logic out into a separate lib!
                #        This is also used in mysubstab...
                if status != NOT_SUBSCRIBED:

                    range_calculator = ValidProductDateRangeCalculator(self.cs)
                    compliant_range = range_calculator.calculate(
                        product.getHash())
                    start = ''
                    end = ''
                    if compliant_range:
                        start = compliant_range.begin()
                        end = compliant_range.end()

                    contract_ids, sub_names = self._calc_subs_providing(
                        product_id, compliant_range)
                    name = ", ".join(sub_names)
                    contract = ", ".join(contract_ids)

                    entry['subscription'] = name

                    entry['start_date'] = start
                    entry['expiration_date'] = end

                    if status == FUTURE_SUBSCRIBED:
                        entry['image'] = self._render_icon('red')
                        entry['status'] = _('Future Subscription')
                        entry['validity_note'] = _("Future Subscribed")
                    elif status == EXPIRED:
                        entry['image'] = self._render_icon('red')
                        entry['status'] = _('Expired')
                        sub_numbers = set([])
                        for ent_cert in self.cs.get_entitlements_for_product(
                                product_id):
                            order = ent_cert.getOrder()
                            # FIXME:  getSubscription() seems to always be None...?
                            if order.getSubscription():
                                sub_numbers.add(order.getSubscription())
                        subs_str = ', '.join(sub_numbers)

                        entry['validity_note'] = \
                             _('Subscription %s is expired') % subs_str
                    elif status == PARTIALLY_SUBSCRIBED:
                        entry['image'] = self._render_icon('yellow')
                        entry['status'] = _('Partially Subscribed')
                        entry['validity_note'] = _("Partially Subscribed")
                    else:
                        entry['image'] = self._render_icon('green')
                        entry['status'] = _('Subscribed')
                        entry['validity_note'] = \
                            _('Covered by contract(s) %s through %s') % \
                            (contract,
                             managerlib.formatDate(entry['expiration_date']))
                else:
                    entry['image'] = self._render_icon('red')
                    entry['status'] = _('Not Subscribed')
                    entry['validity_note'] = _("Not Subscribed")

                self.store.add_map(entry)
        # 811340: Select the first product in My Installed Software
        # table by default.
        selection = self.top_view.get_selection()
        selection.select_path(0)
예제 #9
0
    def _set_validity_status(self):
        """ Updates the entitlement validity status portion of the UI. """

        if ClassicCheck().is_registered_with_classic():
            self._set_status_icons(VALID)
            self.subscription_status_label.set_text(
                _("This system is registered to RHN Classic"))
            return

        is_registered = ConsumerIdentity.existsAndValid()
        self.set_registered(is_registered)

        # Look for products which have invalid entitlements
        sorter = CertSorter(self.product_dir, self.entitlement_dir,
                self.facts.get_facts())

        warn_count = len(sorter.expired_products) + \
                len(sorter.unentitled_products)

        partial_count = len(sorter.partially_valid_products)

        if warn_count > 0:
            self._set_status_icons(INVALID)
            # Change wording slightly for just one product
            if warn_count > 1:
                self.subscription_status_label.set_markup(
                        _("You have <b>%s</b> products with <i>invalid</i> entitlement certificates.")
                        % warn_count)
            else:
                self.subscription_status_label.set_markup(
                        _("You have <b>1</b> product with an <i>invalid</i> entitlement certificate."))

        elif partial_count > 0:
            self._set_status_icons(PARTIAL)
            # Change wording slightly for just one product
            if partial_count > 1:
                self.subscription_status_label.set_markup(
                        _("You have <b>%s</b> products in need of <i>additional</i> entitlement certificates.")
                        % partial_count)
            else:
                self.subscription_status_label.set_markup(
                        _("You have <b>1</b> product in need of <i>additional</i> entitlement certificates."))

        else:
            first_invalid = find_first_invalid_date(self.entitlement_dir,
                    self.product_dir, self.facts.get_facts())
            self._set_status_icons(VALID)
            if first_invalid:
                self.subscription_status_label.set_markup(
                        _("Product entitlement certificates <i>valid</i> until %s") % \
                            managerlib.formatDate(first_invalid))
            else:
                # No product certs installed, no first invalid date, and
                # the subscription assistant can't do anything, so we'll disable
                # the button to launch it:
                self.subscription_status_label.set_text(
                        _("No product certificates installed."))

        if not is_registered:
            self.subscription_status_label.set_text(
                _("You must register this system before subscribing."))
예제 #10
0
    def update_products(self):
        self.store.clear()
        self.cs = cert_sorter.CertSorter(self.product_dir,
                self.entitlement_dir, self.facts.get_facts())
        for product_cert in self.product_dir.list():
            for product in product_cert.getProducts():
                product_id = product.getHash()
                status = self.cs.get_status(product_id)

                entry = {}
                entry['product'] = product.getName()
                entry['version'] = product.getVersion()
                entry['arch'] = product.getArch()
                entry['product_id'] = product_id
                # Common properties
                entry['align'] = 0.5

                # TODO:  Pull this date logic out into a separate lib!
                #        This is also used in mysubstab...
                if status != NOT_SUBSCRIBED:

                    range_calculator = ValidProductDateRangeCalculator(self.cs)
                    compliant_range = range_calculator.calculate(product.getHash())
                    start = ''
                    end = ''
                    if compliant_range:
                        start = compliant_range.begin()
                        end = compliant_range.end()

                    contract_ids, sub_names = self._calc_subs_providing(
                            product_id, compliant_range)
                    name = ", ".join(sub_names)
                    contract = ", ".join(contract_ids)

                    entry['subscription'] = name

                    entry['start_date'] = start
                    entry['expiration_date'] = end

                    if status == FUTURE_SUBSCRIBED:
                        entry['image'] = self._render_icon('red')
                        entry['status'] = _('Future Subscription')
                        entry['validity_note'] = _("Future Subscribed")
                    elif status == EXPIRED:
                        entry['image'] = self._render_icon('red')
                        entry['status'] = _('Expired')
                        sub_numbers = set([])
                        for ent_cert in self.cs.get_entitlements_for_product(product_id):
                            order = ent_cert.getOrder()
                            # FIXME:  getSubscription() seems to always be None...?
                            if order.getSubscription():
                                sub_numbers.add(order.getSubscription())
                        subs_str = ', '.join(sub_numbers)

                        entry['validity_note'] = \
                             _('Subscription %s is expired') % subs_str
                    elif status == PARTIALLY_SUBSCRIBED:
                        entry['image'] = self._render_icon('yellow')
                        entry['status'] = _('Partially Subscribed')
                        entry['validity_note'] = _("Partially Subscribed")
                    else:
                        entry['image'] = self._render_icon('green')
                        entry['status'] = _('Subscribed')
                        entry['validity_note'] = \
                            _('Covered by contract(s) %s through %s') % \
                            (contract,
                             managerlib.formatDate(entry['expiration_date']))
                else:
                    entry['image'] = self._render_icon('red')
                    entry['status'] = _('Not Subscribed')
                    entry['validity_note'] = _("Not Subscribed")

                self.store.add_map(entry)
        # 811340: Select the first product in My Installed Software
        # table by default.
        selection = self.top_view.get_selection()
        selection.select_path(0)