Example #1
0
    def __init__(self, repo):
        if repo:
            repo_id = repo.get_property('repo-id')
            if repo_id.endswith('-source'):
                repo_id = repo_id[:-len('-source')]
                self.component = 'source'
            elif repo_id.endswith('-debuginfo'):
                repo_id = repo_id[:-len('-debuginfo')]
                self.component = 'debuginfo'
            else:
                self.component = 'main'

            if repo_id == 'updates':
                self.origin = get_distro().get_distro_channel_name()
                self.archive = 'stable'
            elif repo_id == 'updates-testing':
                self.origin = get_distro().get_distro_channel_name()
                self.archive = 'testing'
            elif repo_id.endswith('-updates-testing'):
                self.origin = repo_id[:-len('-updates-testing')]
                self.archive = 'testing'
            else:
                self.origin = repo_id
                self.archive = 'stable'

            self.trusted = True
            self.label = repo.get_property('description')
        else:
            self.origin = 'unknown'
            self.archive = 'unknown'
            self.trusted = False
            self.label = _("Unknown repository")
            self.component = 'main'
        self.site = ''
Example #2
0
    def __init__(self, repo):
        if repo:
            repo_id = repo.get_property("repo-id")
            if repo_id.endswith("-source"):
                repo_id = repo_id[: -len("-source")]
                self.component = "source"
            elif repo_id.endswith("-debuginfo"):
                repo_id = repo_id[: -len("-debuginfo")]
                self.component = "debuginfo"
            else:
                self.component = "main"

            if repo_id == "updates":
                self.origin = get_distro().get_distro_channel_name()
                self.archive = "stable"
            elif repo_id == "updates-testing":
                self.origin = get_distro().get_distro_channel_name()
                self.archive = "testing"
            elif repo_id.endswith("-updates-testing"):
                self.origin = repo_id[: -len("-updates-testing")]
                self.archive = "testing"
            else:
                self.origin = repo_id
                self.archive = "stable"

            self.trusted = True
            self.label = repo.get_property("description")
        else:
            self.origin = "unknown"
            self.archive = "unknown"
            self.trusted = False
            self.label = _("Unknown repository")
            self.component = "main"
        self.site = ""
    def __init__(self, datadir, db, icons):
        gtk.TreeStore.__init__(self, AnimatedImage, str, int, gobject.TYPE_PYOBJECT)
        self.icons = icons
        self.datadir = datadir
        self.backend = get_install_backend()
        self.backend.connect("transactions-changed", self.on_transactions_changed)
        self.backend.connect("channels-changed", self.on_channels_changed)
        self.db = db
        self.distro = get_distro()
        # pending transactions
        self._pending = 0
        # setup the normal stuff
        available_icon = self._get_icon("softwarecenter")
        self.available_iter = self.append(None, [available_icon, _("Get Software"), self.ACTION_ITEM_AVAILABLE, None])

        # do initial channel list update
        self._update_channel_list()
        
        icon = AnimatedImage(self.icons.load_icon("computer", self.ICON_SIZE, 0))
        installed_iter = self.append(None, [icon, _("Installed Software"), self.ACTION_ITEM_INSTALLED, None])
        icon = AnimatedImage(None)
        self.append(None, [icon, "<span size='1'> </span>", self.ACTION_ITEM_SEPARATOR_1, None])
        
        # kick off a background check for changes that may have been made
        # in the channels list
        glib.timeout_add(300, lambda: self._check_for_channel_updates(self.channels))
Example #4
0
def test_ping(host=None):
    global NETWORK_STATE
    import subprocess

    # ping the screenshots provider
    from softwarecenter.distro import get_distro
    distro = get_distro()
    host = urlparse(distro.SCREENSHOT_LARGE_URL)[1]
    msg = ("Attempting one time ping of %s to test if internet "
           "connectivity exists." % host)
    logging.info(msg)

    ping = subprocess.Popen(["ping", "-c", "1", host],
                            stdout=subprocess.PIPE,
                            stderr=subprocess.PIPE)
    out, error = ping.communicate()
    res = ping.wait()

    if res != 0:
        NETWORK_STATE = NetState.NM_STATE_DISCONNECTED
        msg = "Could not detect an internet connection\n%s" % error
    else:
        NETWORK_STATE = NetState.NM_STATE_CONNECTED_GLOBAL
        msg = "Internet connection available!\n%s" % out

    __WATCHER__.emit("changed", NETWORK_STATE)
    logging.info("ping output: '%s'" % msg)
    return NETWORK_STATE
Example #5
0
 def __init__(self, channel_name, channel_origin, channel_component,
              source_entry=None, installed_only=False,
              channel_icon=None, channel_query=None,
              channel_sort_mode=SortMethods.BY_ALPHABET):
     """
     configure the software channel object based on channel name,
     origin, and component (the latter for detecting the partner
     channel)
     """
     self._channel_name = channel_name
     self._channel_origin = channel_origin
     self._channel_component = channel_component
     self._channel_color = None
     self._channel_view_id = None
     self.installed_only = installed_only
     self._channel_sort_mode = channel_sort_mode
     # distro specific stuff
     self.distro = get_distro()
     # configure the channel
     self._channel_display_name = self._get_display_name_for_channel(channel_name, channel_component)
     if channel_icon is None:
         self._channel_icon = self._get_icon_for_channel(channel_name, channel_origin, channel_component)
     else:
         self._channel_icon = channel_icon
     if channel_query is None:
         self._channel_query = self._get_channel_query_for_channel(channel_name, channel_origin, channel_component)
     else:
         self._channel_query = channel_query
     # a sources.list entry attached to the channel (this is currently
     # only used for not-yet-enabled channels)
     self._source_entry = source_entry
     # when the channel needs to be added to the systems sources.list
     self.needs_adding = False
Example #6
0
    def component(self):
        """
        get the component (main, universe, ..)

        this uses the data from apt, if there is none it uses the
        data from the app-install-data files
        """
        # try apt first
        if self._pkg:
            for origin in self._pkg.candidate.origins:
                if (origin.origin == get_distro().get_distro_channel_name() and
                    origin.trusted and origin.component):
                    return origin.component
        # then xapian
        elif self._doc:
            comp = self._doc.get_value(XapianValues.ARCHIVE_SECTION)
            return comp
        # then apturl requests
        else:
            section_matches = re.findall(r'section=([a-z]+)',
                self._app.request)
            if section_matches:
                valid_section_matches = []
                for section_match in section_matches:
                    if (self._unavailable_component(
                        component_to_check=section_match) and
                        valid_section_matches.count(section_match) == 0):
                        valid_section_matches.append(section_match)
                if valid_section_matches:
                    return ('&').join(valid_section_matches)
Example #7
0
    def test_new_no_sort_info_yet(self):
        # ensure that we don't show a empty "whats new" category
        # see LP: #865985
        from softwarecenter.testutils import get_test_db
        db = get_test_db()
        cache = db._aptcache
        # simulate a fresh install with no catalogedtime info
        del db._axi_values["catalogedtime"]

        from softwarecenter.testutils import get_test_gtk3_icon_cache
        icons = get_test_gtk3_icon_cache()

        from softwarecenter.db.appfilter import AppFilter
        apps_filter = AppFilter(db, cache)

        from softwarecenter.distro import get_distro
        from softwarecenter.ui.gtk3.views.catview_gtk import LobbyViewGtk
        view = LobbyViewGtk(softwarecenter.paths.datadir,
                            softwarecenter.paths.APP_INSTALL_PATH,
                            cache, db, icons, get_distro(), apps_filter)
        view.show()

        # gui
        win = Gtk.Window()
        self.addCleanup(win.destroy)
        win.set_size_request(800, 400)

        scroll = Gtk.ScrolledWindow()
        scroll.add(view)
        scroll.show()
        win.add(scroll)
        win.show()
        # test visibility
        do_events()
        self.assertFalse(view.whats_new_frame.get_property("visible"))
Example #8
0
    def __init__(self, db, doc=None, application=None):
        """ Create a new AppDetails object. It can be created from
            a xapian.Document or from a db.application.Application object
        """
        GObject.GObject.__init__(self)
        if not doc and not application:
            raise ValueError("Need either document or application")
        self._db = db
        self._db.connect("reopen", self._on_db_reopen)
        self._cache = self._db._aptcache
        self._distro = get_distro()
        self._history = None
        # import here (intead of global) to avoid dbus dependency
        # in update-software-center (that imports application, but
        # never uses AppDetails) LP: #620011
        from softwarecenter.backend import get_install_backend
        self._backend = get_install_backend()
        # FIXME: why two error states ?
        self._error = None
        self._error_not_found = None
        self._screenshot_list = None

        # load application
        self._app = application
        if doc:
            self._app = Application(self._db.get_appname(doc), 
                                    self._db.get_pkgname(doc), 
                                    "")

        # sustitute for apturl
        if self._app.request:
            self._app.request = self._app.request.replace(
                "$distro", self._distro.get_codename())

        # load pkg cache
        self._pkg = None
        if (self._app.pkgname in self._cache and 
            self._cache[self._app.pkgname].candidate):
            self._pkg = self._cache[self._app.pkgname]

        # load xapian document
        self._doc = doc
        if not self._doc:
            try:
                self._doc = self._db.get_xapian_document(
                    self._app.appname, self._app.pkgname)
            except IndexError:
                # if there is no document and no apturl request,
                # set error state
                debfile_matches = re.findall(r'/', self._app.request)
                channel_matches = re.findall(r'channel=[a-z,-]*', 
                                             self._app.request)
                section_matches = re.findall(r'section=[a-z]*', 
                                             self._app.request)
                if (not self._pkg and 
                    not debfile_matches and 
                    not channel_matches and 
                    not section_matches):
                    self._error = _("Not found")
                    self._error_not_found = utf8(_(u"There isn\u2019t a software package called \u201c%s\u201D in your current software sources.")) % utf8(self.pkgname)
Example #9
0
    def update_debline(cls, debline):
        # Be careful to handle deblines with pockets.
        source_entry = SourceEntry(debline)
        distro_pocket = source_entry.dist.split('-')
        distro_pocket[0] = get_distro().get_codename()
        source_entry.dist = "-".join(distro_pocket)

        return unicode(source_entry)
Example #10
0
 def test_distro_functions(self):
     distro = get_distro()
     codename = distro.get_codename()
     self.assertNotEqual(codename, None)
     myname = distro.get_app_name()
     self.assertTrue(len(myname) > 0)
     arch = distro.get_architecture()
     self.assertNotEqual(arch, None)
Example #11
0
 def __init__(self, db, backend, icons):
     GObject.GObject.__init__(self)
     self._globalise_instance()
     self.db = db
     self.backend = backend
     self.distro = get_distro()
     self.datadir = softwarecenter.paths.datadir
     self.icons = icons
 def __init__(self, db, cache):
     self.distro = get_distro()
     self.db = db
     self.cache = cache
     self.supported_only = False
     self.installed_only = False
     self.not_installed_only = False
     self.only_packages_without_applications = False
Example #13
0
 def __init__(self):
     super(PackagekitInfo, self).__init__()
     self.client = packagekit.Client()
     self.client.set_locale(make_locale_string())
     self._cache = {}  # temporary hack for decent testing
     self._notfound_cache = []
     self._repocache = {}
     self.distro = get_distro()
Example #14
0
    def index(self, document, pkg):
        """
        Update the document with the information from this data source.

        document  is the document to update
        pkg       is the python-apt Package object for this package
        """
        ver = pkg.candidate
        # if there is no version or the AppName custom key is not
        # found we can skip the pkg
        if ver is None or not CustomKeys.APPNAME in ver.record:
            return
        # we want to index the following custom fields:
        #   XB-AppName,
        #   XB-Icon,
        #   XB-Screenshot-Url,
        #   XB-Thumbnail-Url,
        #   XB-Category
        if CustomKeys.APPNAME in ver.record:
            name = ver.record[CustomKeys.APPNAME]
            self.indexer.set_document(document)
            # add s-c values/terms for the name
            document.add_term("AA"+name)
            document.add_value(XapianValues.APPNAME, name)
            for t in get_pkgname_terms(pkg.name):
                document.add_term(t)
            self.indexer.index_text_without_positions(
                name, WEIGHT_DESKTOP_NAME)
            # we pretend to be an application
            document.add_term("AT" + "application")
            # and we inject a custom component value to indicate "independent"
            document.add_value(XapianValues.ARCHIVE_SECTION, "independent")
        if CustomKeys.ICON in ver.record:
            icon = ver.record[CustomKeys.ICON]
            document.add_value(XapianValues.ICON, icon)
            # calculate the url and add it (but only if there actually is
            # a url)
            try:
                distro = get_distro()
                if distro:
                    base_uri = ver.uri
                    # new python-apt returns None instead of StopIteration
                    if base_uri:
                        url = distro.get_downloadable_icon_url(base_uri, icon)
                        document.add_value(XapianValues.ICON_URL, url)
            except StopIteration:
                pass
        if CustomKeys.SCREENSHOT_URLS in ver.record:
            screenshot_url = ver.record[CustomKeys.SCREENSHOT_URLS]
            document.add_value(XapianValues.SCREENSHOT_URLS, screenshot_url)
        if CustomKeys.THUMBNAIL_URL in ver.record:
            url = ver.record[CustomKeys.THUMBNAIL_URL]
            document.add_value(XapianValues.THUMBNAIL_URL, url)
        if CustomKeys.CATEGORY in ver.record:
            categories_str = ver.record[CustomKeys.CATEGORY]
            for cat in categories_str.split(";"):
                if cat:
                    document.add_term("AC" + cat.lower())
Example #15
0
    def setUp(self):
        from softwarecenter.backend import zeitgeist_logger
        if not zeitgeist_logger.HAVE_MODULE:
            self.skipTest("Zeitgeist module missing, impossible to test")

        from zeitgeist import datamodel
        self.distro = get_distro()
        self.logger = ZeitgeistLogger(self.distro)
        self.datamodel = datamodel
Example #16
0
 def test_regression_lp1041004(self):
     from softwarecenter.ui.gtk3.views import appdetailsview
     db = get_test_db()
     cache = get_test_pkg_info()
     icons = get_test_gtk3_icon_cache()
     distro = get_distro()
     view = appdetailsview.AppDetailsView(db, distro, icons, cache)
     cache.emit("query-total-size-on-install-done", "apt", 10, 10)
     do_events_with_sleep()
     self.assertEqual(view.totalsize_info.value_label.get_text(), "")
 def __init__(self, cache, db, distro, icons, datadir):
     # parent
     SoftwarePane.__init__(self, cache, db, distro, icons, datadir, show_ratings=False)
     self.channel = None
     self.apps_filter = None
     self.search_terms = ""
     self.current_appview_selection = None
     self.distro = get_distro()
     # UI
     self._build_ui()
Example #18
0
 def __init__(self, cache, db, distro, icons, datadir):
     # parent
     SoftwarePane.__init__(self, cache, db, distro, icons, datadir,
                           show_ratings=False)
     self.channel = None
     self.apps_filter = None
     self.apps_search_term = ""
     self.current_appview_selection = None
     self.distro = get_distro()
     self.pane_name = _("Software Channels")
Example #19
0
 def __init__(self, db, cache):
     xapian.MatchDecider.__init__(self)
     self.distro = get_distro()
     self.db = db
     self.cache = cache
     self.available_only = False
     self.supported_only = global_filter.supported_only
     self.installed_only = False
     self.not_installed_only = False
     self.restricted_list = False
Example #20
0
    def _apply_exceptions(self):
        # for items from the agent, we use the full-size screenshot for
        # the thumbnail and scale it for display, this is done because
        # we no longer keep thumbnail versions of screenshots on the server
        if (hasattr(self.sca_application, "screenshot_url") and
                not hasattr(self.sca_application, "thumbnail_url")):
            self.sca_application.thumbnail_url = \
                self.sca_application.screenshot_url
        if hasattr(self.sca_application, "description"):
            comment, desc = self.sca_application.description.split("\n", 1)
            self.sca_application.comment = comment.strip()
            self.sca_application.description = desc.strip()

        # debtags is send as a list, but we need it as a comma separated string
        debtags = getattr(self.sca_application, "debtags", [])
        self.sca_application.tags = ",".join(debtags)

        # we only support a single video currently :/
        urls = getattr(self.sca_application, "video_embedded_html_urls", None)
        if urls:
            self.sca_application.video_embedded_html_url = urls[0]
        else:
            self.sca_application.video_embedded_html_url = None

        # XXX 2012-01-16 bug=917109
        # We can remove these work-arounds once the above bug is fixed on
        # the server. Until then, we fake a channel here and empty category
        # to make the parser happy. Note: available_apps api call includes
        # these already, it's just the apps with subscriptions_for_me which
        # don't currently.
        self.sca_application.channel = \
            AVAILABLE_FOR_PURCHASE_MAGIC_CHANNEL_NAME
        if not hasattr(self.sca_application, 'categories'):
            self.sca_application.categories = ""

        # detect if its for the partner channel and set the channel
        # attribute appropriately so that the channel-adding magic works
        if hasattr(self.sca_application, "archive_root"):
            u = urlparse(self.sca_application.archive_root)
            if u.scheme == "http" and u.netloc == "archive.canonical.com":
                distroseries = get_distro().get_codename()
                self.sca_application.channel = "%s-partner" % distroseries
            if u.scheme == "http" and u.netloc == "extras.ubuntu.com":
                self.sca_application.channel = "ubuntu-extras"

        # support multiple screenshots
        if hasattr(self.sca_application, "screenshot_urls"):
            # ensure to html-quote "," as this is also our separator
            s = ",".join([url.replace(",", "%2C")
                          for url in self.sca_application.screenshot_urls])
            self.sca_application.screenshot_url = s

        keywords = getattr(self.sca_application, 'keywords', self.NOT_DEFINED)
        if keywords is self.NOT_DEFINED:
            self.sca_application.keywords = ''
Example #21
0
 def setUp(self):
     # get required test stuff
     self.db = get_test_db()
     self.backend = Mock()
     self.distro = get_distro()
     self.datadir = softwarecenter.paths.datadir
     self.icons = get_test_gtk3_icon_cache()
     # create it once, it becomes global instance
     if get_appmanager() is None:
         ApplicationManager(
             self.db, self.backend, self.icons)
Example #22
0
 def __init__(self):
     super(PackagekitInfo, self).__init__()
     self.pktask = packagekit.Task()
     self.pktask.set_locale(make_locale_string())
     self._cache_pkg_filter_none = {} # temporary hack for decent testing
     self._cache_pkg_filter_newest = {} # temporary hack for decent testing
     self._cache_details = {} # temporary hack for decent testing
     self._notfound_cache_pkg = []
     self._repocache = {}
     self._ready = False
     self.distro = get_distro()
     self._pkgs_cache = {}
 def test_channel_detection_partner(self, mock):
     # we need to patch os.path.exists as "AppDetails.channelname" will
     # check if there is a matching channel description file on disk
     os.path.exists.return_value = True
     # setup dict
     app_dict = make_software_center_agent_app_dict()
     app_dict["archive_root"] = "http://archive.canonical.com/"
     app_details = self._get_app_details_from_app_dict(app_dict)
     # ensure that archive.canonical.com archive roots are detected
     # as the partner channel
     dist = get_distro().get_codename()
     self.assertEqual(app_details.channelname, "%s-partner" % dist)
Example #24
0
 def __init__(self, ignore_cache=False, xid=None):
     GObject.GObject.__init__(self)
     self.distro = get_distro()
     self.ignore_cache = ignore_cache
     binary = os.path.join(
         softwarecenter.paths.datadir, PistonHelpers.SOFTWARE_CENTER_AGENT)
     self.HELPER_CMD = [binary]
     if self.ignore_cache:
         self.HELPER_CMD.append("--ignore-cache")
     if xid:
         self.HELPER_CMD.append("--parent-xid")
         self.HELPER_CMD.append(str(xid))
Example #25
0
 def __init__(self, db):
     self.db = db
     self.distro = get_distro()
     self.backend = get_install_backend()
     self.backend.connect("channels-changed",
                          self._remove_no_longer_needed_extra_channels)
     # kick off a background check for changes that may have been made
     # in the channels list
     GLib.timeout_add_seconds(60, self._check_for_channel_updates_timer)
     # extra channels from e.g. external sources
     self.extra_channels = []
     self._logger = LOG
Example #26
0
    def _update_appcount(self):
        enq = AppEnquire(self.cache, self.db)

        distro = get_distro()
        if get_global_filter().supported_only:
            query = distro.get_supported_query()
        else:
            query = xapian.Query('')

        length = enq.get_estimated_matches_count(query)
        text = gettext.ngettext("%(amount)s item", "%(amount)s items", length
                                ) % {'amount': length}
        self.appcount.set_text(text)
Example #27
0
    def _update_appcount(self):
        enq = AppEnquire(self.cache, self.db)

        distro = get_distro()
        if get_global_filter().supported_only:
            query = distro.get_supported_query()
        else:
            query = xapian.Query('')

        length = enq.get_estimated_matches_count(query)
        text = gettext.ngettext("%(amount)s item", "%(amount)s items", length
                                ) % {'amount': length}
        self.appcount.set_text(text)
    def _apply_exceptions(self):
        # for items from the agent, we use the full-size screenshot for
        # the thumbnail and scale it for display, this is done because
        # we no longer keep thumbnail versions of screenshots on the server
        if (hasattr(self.sca_application, "screenshot_url") and
            not hasattr(self.sca_application, "thumbnail_url")):
            self.sca_application.thumbnail_url = \
                self.sca_application.screenshot_url
        if hasattr(self.sca_application, "description"):
            comment = self.sca_application.description.split("\n")[0].strip()
            self.sca_application.Comment = comment
            self.sca_application.Description = "\n".join(
                self.sca_application.description.split("\n")[1:]).strip()

        # debtags is send as a list, but we need it as a comma seperated string
        self.sca_application.Tags = ",".join(getattr(self.sca_application,
            "debtags", []))

        # we only support a single video currently :/
        if hasattr(self.sca_application, "video_embedded_html_urls"):
            if self.sca_application.video_embedded_html_urls:
                video_url = self.sca_application.video_embedded_html_urls[0]
                self.sca_application.video_embedded_html_url = video_url

        # XXX 2012-01-16 bug=917109
        # We can remove these work-arounds once the above bug is fixed on
        # the server. Until then, we fake a channel here and empty category
        # to make the parser happy. Note: available_apps api call includes
        # these already, it's just the apps with subscriptions_for_me which
        # don't currently.
        self.sca_application.channel = \
            AVAILABLE_FOR_PURCHASE_MAGIC_CHANNEL_NAME
        if not hasattr(self.sca_application, 'categories'):
            self.sca_application.categories = ""

        # detect if its for the partner channel and set the channel
        # attribute appropriately so that the channel-adding magic works
        if hasattr(self.sca_application, "archive_root"):
            u = urlparse(self.sca_application.archive_root)
            if u.scheme == "http" and u.netloc == "archive.canonical.com":
                distroseries = get_distro().get_codename()
                self.sca_application.channel = "%s-partner" % distroseries
            if u.scheme == "http" and u.netloc == "extras.ubuntu.com":
                self.sca_application.channel = "ubuntu-extras"

        # support multiple screenshots
        if hasattr(self.sca_application, "screenshot_urls"):
            # ensure to html-quote "," as this is also our seperator
            s = ",".join([url.replace(",", "%2C")
                          for url in self.sca_application.screenshot_urls])
            self.sca_application.screenshot_url = s
Example #29
0
    def __init__(self, view_manager, datadir, db, cache, icons):
        Gtk.TreeStore.__init__(self)
        self.set_column_types((GObject.TYPE_PYOBJECT,  # COL_ICON
                               str,                    # COL_NAME
                               GObject.TYPE_PYOBJECT,  # COL_ACTION
                               GObject.TYPE_PYOBJECT,  # COL_CHANNEL
                               str,                    # COL_BUBBLE_TEXT
                               ))  # must match columns above
        self.view_manager = view_manager
        self.icons = icons
        self.datadir = datadir
        self.backend = get_install_backend()
        self.backend.connect("transactions-changed",
            self.on_transactions_changed)
        self.backend.connect("transaction-finished",
            self.on_transaction_finished)
        self.db = db
        self.cache = cache
        self.distro = get_distro()
        # pending transactions
        self._pending = 0
        # setup the normal stuff

        # first, the availablepane items
        available_icon = self._get_icon("softwarecenter")
        self.available_iter = self.append(None, [available_icon,
            _("Get Software"), ViewPages.AVAILABLE, None, None])

        # the installedpane items
        icon = self._get_icon("computer")
        self.installed_iter = self.append(None, [icon, _("Installed Software"),
            ViewPages.INSTALLED, None, None])

        # the channelpane
        self.channel_manager = ChannelsManager(db, icons)
        # do initial channel list update
        self._update_channel_list()

        # the historypane item
        icon = self._get_icon("document-open-recent")
        self.append(None, [icon, _("History"), ViewPages.HISTORY, None, None])
        icon = None
        self.append(None, [icon, "<span size='1'> </span>",
            ViewPages.SEPARATOR_1, None, None])

        # the progress pane is build on demand

        # emit a transactions-changed signal to ensure that we display any
        # pending transactions
        self.backend.emit("transactions-changed",
            self.backend.pending_transactions)
Example #30
0
def deauthorize_computer(parent, datadir, db, icons, account_name,
    purchased_packages):
    """ Display a dialog to deauthorize the current computer for purchases
    """
    cache = db._aptcache
    distro = get_distro()

    (primary, button_text) = distro.get_deauthorize_text(account_name,
                                                         purchased_packages)

    # build the dialog
    glade_dialog = SimpleGtkbuilderDialog(datadir, domain="software-center")
    dialog = glade_dialog.dialog_deauthorize
    dialog.set_resizable(True)
    dialog.set_transient_for(parent)
    dialog.set_default_size(360, -1)

    # use the icon for software-center in the dialog
    icon_name = "softwarecenter"
    if (icon_name is None or
        not icons.has_icon(icon_name)):
        icon_name = Icons.MISSING_APP
    glade_dialog.image_icon.set_from_icon_name(icon_name,
                                               Gtk.IconSize.DIALOG)

    # set the texts
    glade_dialog.label_deauthorize_primary.set_text(
        "<span font_weight=\"bold\" font_size=\"large\">%s</span>" % primary)
    glade_dialog.label_deauthorize_primary.set_use_markup(True)
    glade_dialog.button_deauthorize_do.set_label(button_text)

    # add the list of packages to remove, if there are any
    if len(purchased_packages) > 0:
        view = PackageNamesView(_("Deauthorize"), cache, purchased_packages,
            icons, ICON_SIZE, db)
        view.set_headers_visible(False)
        # FIXME: work out how not to select?/focus?/activate? first item
        glade_dialog.scrolledwindow_purchased_packages.add(view)
        glade_dialog.scrolledwindow_purchased_packages.show_all()
    else:
        glade_dialog.viewport_purchased_packages.hide()

    result = dialog.run()
    dialog.hide()
    if result == Gtk.ResponseType.ACCEPT:
        return True
    return False
Example #31
0
    def index(self, document, pkg):
        """
        Update the document with the information from this data source.

        document  is the document to update
        pkg       is the python-apt Package object for this package
        """
        ver = pkg.candidate
        # if there is no version or the AppName custom key is not
        # found we can skip the pkg
        if ver is None or not CustomKeys.APPNAME in ver.record:
            return
        # we want to index the following custom fields:
        #   XB-AppName,
        #   XB-Icon,
        #   XB-Screenshot-Url,
        #   XB-Thumbnail-Url,
        #   XB-Category
        if CustomKeys.APPNAME in ver.record:
            name = ver.record[CustomKeys.APPNAME]
            self.indexer.set_document(document)
            index_name(document, name, self.indexer)
            # we pretend to be an application
            document.add_term("AT" + "application")
            # and we inject a custom component value to indicate "independent"
            document.add_value(XapianValues.ARCHIVE_SECTION, "independent")
        if CustomKeys.ICON in ver.record:
            icon = ver.record[CustomKeys.ICON]
            document.add_value(XapianValues.ICON, icon)
            # calculate the url and add it (but only if there actually is
            # a url)
            try:
                url = get_distro().get_downloadable_icon_url(ver.uri, icon)
                document.add_value(XapianValues.ICON_URL, url)
            except StopIteration:
                pass
        if CustomKeys.SCREENSHOT_URL in ver.record:
            screenshot_url = ver.record[CustomKeys.SCREENSHOT_URL]
            document.add_value(XapianValues.SCREENSHOT_URL, screenshot_url)
        if CustomKeys.THUMBNAIL_URL in ver.record:
            url = ver.record[CustomKeys.THUMBNAIL_URL]
            document.add_value(XapianValues.THUMBNAIL_URL, url)
        if CustomKeys.CATEGORY in ver.record:
            categories_str = ver.record[CustomKeys.CATEGORY]
            for cat in categories_str.split(";"):
                if cat:
                    document.add_term("AC" + cat.lower())
def confirm_remove(parent, datadir, app, db, icons):
    """ Confirm removing of the given app """
    cache = db._aptcache
    distro = get_distro()
    appdetails = app.get_details(db)
    # FIXME: use 
    #  backend = get_install_backend()
    #  backend.simulate_remove(app.pkgname)
    # once it works
    if not appdetails.pkg:
        return True
    depends = cache.get_packages_removed_on_remove(appdetails.pkg)
    if not depends:
        return True
    (primary, button_text) = distro.get_removal_warning_text(
        db._aptcache, appdetails.pkg, app.name, depends)
    return _confirm_remove_internal(parent, datadir, app, db, icons, primary, button_text, depends, cache)
Example #33
0
def confirm_remove(parent, datadir, app, db, icons):
    """ Confirm removing of the given app """
    cache = db._aptcache
    distro = get_distro()
    appdetails = app.get_details(db)
    # FIXME: use 
    #  backend = get_install_backend()
    #  backend.simulate_remove(app.pkgname)
    # once it works
    if not appdetails.pkg:
        return True
    depends = cache.get_packages_removed_on_remove(appdetails.pkg)
    if not depends:
        return True
    (primary, button_text) = distro.get_removal_warning_text(
        db._aptcache, appdetails.pkg, app.name, depends)
    return _confirm_internal(parent, datadir, app, db, icons, primary, button_text, depends, cache)
 def query_multiple_screenshots(self):
     """ query if multiple screenshots for the given app are available
         and if so, emit "screenshots-available" signal
     """
     # check if we have it cached
     if self._screenshot_list:
         self.emit("screenshots-available", self._screenshot_list)
         return
     # download it
     distro = get_distro()
     url = distro.SCREENSHOT_JSON_URL % self._app.pkgname
     try:
         f = Gio.File.new_for_uri(url)
         f.load_contents_async(
             None, self._gio_screenshots_json_download_complete_cb, None)
     except:
         LOG.exception("failed to load content")
Example #35
0
def confirm_install(parent, datadir, app, db, icons):
    """Confirm install of the given app
       
       (currently only shows a dialog if a installed app needs to be removed
        in order to install the application)
    """
    cache = db._aptcache
    distro = get_distro()
    appdetails = app.get_details(db)

    if not appdetails.pkg:
        return True
    depends = cache.get_packages_removed_on_install(appdetails.pkg)
    if not depends:
        return True
    (primary, button_text) = distro.get_install_warning_text(cache, appdetails.pkg, app.name, depends)
    return _confirm_internal(parent, datadir, app, db, icons, primary, button_text, depends, cache)
Example #36
0
def deauthorize_computer(parent, datadir, db, icons, account_name,
                         purchased_packages):
    """ Display a dialog to deauthorize the current computer for purchases
    """
    cache = db._aptcache
    distro = get_distro()

    (primary,
     button_text) = distro.get_deauthorize_text(account_name,
                                                purchased_packages)

    # build the dialog
    glade_dialog = SimpleGtkbuilderDialog(datadir, domain="software-center")
    dialog = glade_dialog.dialog_deauthorize
    dialog.set_resizable(True)
    dialog.set_transient_for(parent)
    dialog.set_default_size(360, -1)

    # use the icon for software-center in the dialog
    icon_name = "softwarecenter"
    if (icon_name is None or not icons.has_icon(icon_name)):
        icon_name = Icons.MISSING_APP
    glade_dialog.image_icon.set_from_icon_name(icon_name, Gtk.IconSize.DIALOG)

    # set the texts
    glade_dialog.label_deauthorize_primary.set_text(
        "<span font_weight=\"bold\" font_size=\"large\">%s</span>" % primary)
    glade_dialog.label_deauthorize_primary.set_use_markup(True)
    glade_dialog.button_deauthorize_do.set_label(button_text)

    # add the list of packages to remove, if there are any
    if len(purchased_packages) > 0:
        view = PackageNamesView(_("Deauthorize"), cache, purchased_packages,
                                icons, ICON_SIZE, db)
        view.set_headers_visible(False)
        # FIXME: work out how not to select?/focus?/activate? first item
        glade_dialog.scrolledwindow_purchased_packages.add(view)
        glade_dialog.scrolledwindow_purchased_packages.show_all()
    else:
        glade_dialog.viewport_purchased_packages.hide()

    result = dialog.run()
    dialog.hide()
    if result == Gtk.ResponseType.ACCEPT:
        return True
    return False
 def __init__(self, icons, channel_name, channel_origin, channel_component, filter_required=False):
     """
     configure the software channel object based on channel name,
     origin, and component (the latter for detecting the partner
     channel)
     """
     self._channel_name = channel_name
     self._channel_origin = channel_origin
     self._channel_component = channel_component
     self.filter_required = filter_required
     self.icons = icons
     # distro specific stuff
     self.distro = get_distro()
     # configure the channel
     self._channel_display_name = self._get_display_name_for_channel(channel_name, channel_component)
     self._channel_icon = self._get_icon_for_channel(channel_name, channel_origin, channel_component)
     self._channel_query = self._get_channel_query_for_channel(channel_name, channel_component)
Example #38
0
    def _update_subcat_departments(self, category, num_items):
        self.departments.remove_all()

        # set the subcat header
        m = "<b><big>%s</big></b>"
        self.subcat_label.set_markup(m % GLib.markup_escape_text(self.header))

        # sort Category.name's alphabetically
        sorted_cats = categories_sorted_by_name(self.categories)
        enquire = xapian.Enquire(self.db.xapiandb)
        app_filter = AppFilter(self.db, self.cache)
        distro = get_distro()
        supported_only = get_global_filter().supported_only
        for cat in sorted_cats:
            # add the subcategory if and only if it is non-empty
            if supported_only:
                enquire.set_query(
                    xapian.Query(xapian.Query.OP_AND, cat.query,
                                 distro.get_supported_query()))
            else:
                enquire.set_query(cat.query)
            if len(enquire.get_mset(0, 1)):
                tile = CategoryTile(cat.name, cat.iconname)
                tile.connect('clicked', self.on_category_clicked, cat)
                self.departments.add_child(tile)

        # partially work around a (quite rare) corner case
        if num_items == 0:
            enquire.set_query(
                xapian.Query(xapian.Query.OP_AND, category.query,
                             xapian.Query("ATapplication")))
            # assuming that we only want apps is not always correct ^^^
            tmp_matches = enquire.get_mset(0, len(self.db), None, app_filter)
            num_items = tmp_matches.get_matches_estimated()

        # append an additional button to show all of the items in the category
        all_cat = Category("All", _("All"), "category-show-all",
                           category.query)
        name = GLib.markup_escape_text('%s %s' % (_("All"), num_items))
        tile = CategoryTile(name, "category-show-all")
        tile.connect('clicked', self.on_category_clicked, all_cat)
        self.departments.add_child(tile)
        self.departments.queue_draw()
        return num_items
Example #39
0
    def _update_appcount(self):
        enq = AppEnquire(self.cache, self.db)

        distro = get_distro()
        if get_global_filter().supported_only:
            query = distro.get_supported_query()
        else:
            query = xapian.Query('')

        enq.set_query(query,
                      limit=0,
                      nonapps_visible=NonAppVisibility.ALWAYS_VISIBLE,
                      nonblocking_load=True)

        length = len(enq.matches)
        text = gettext.ngettext("%(amount)s item", "%(amount)s items",
                                length) % {
                                    'amount': length,
                                }
        self.appcount.set_text(text)
Example #40
0
    def __init__(self, cache, db):
        """
        Init a AppEnquire object

        :Parameters:
        - `cache`: apt cache (for stuff like the overlay icon)
        - `db`: a xapian.Database that contains the applications
        """
        GObject.GObject.__init__(self)
        self.cache = cache
        self.db = db
        self.distro = get_distro()
        self.search_query = SearchQuery(None)
        self.nonblocking_load = True
        self.sortmode = SortMethods.UNSORTED
        self.nonapps_visible = NonAppVisibility.MAYBE_VISIBLE
        self.limit = DEFAULT_SEARCH_LIMIT
        self.filter = None
        self.exact = False
        self.nr_pkgs = 0
        self.nr_apps = 0
        self._matches = []
        self.match_docids = set()
    def test_subcatview_new_no_sort_info_yet(self):
        # ensure that we don't show a empty "whats new" category
        # see LP: #865985
        from softwarecenter.testutils import get_test_db
        db = get_test_db()
        cache = db._aptcache
        # simulate a fresh install with no catalogedtime info
        del db._axi_values["catalogedtime"]

        from softwarecenter.testutils import get_test_gtk3_icon_cache
        icons = get_test_gtk3_icon_cache()

        from softwarecenter.db.appfilter import AppFilter
        apps_filter = AppFilter(db, cache)

        from softwarecenter.distro import get_distro
        import softwarecenter.paths
        from softwarecenter.paths import APP_INSTALL_PATH
        from softwarecenter.ui.gtk3.views.catview_gtk import LobbyViewGtk
        view = LobbyViewGtk(softwarecenter.paths.datadir, APP_INSTALL_PATH,
                            cache, db, icons, get_distro(), apps_filter)
        view.show()

        # gui
        win = Gtk.Window()
        win.set_size_request(800, 400)

        scroll = Gtk.ScrolledWindow()
        scroll.add(view)
        scroll.show()
        win.add(scroll)
        win.show()
        # test visibility
        self._p()
        self.assertFalse(view.whats_new_frame.get_property("visible"))
        self._p()
        win.destroy()
def make_purchased_app_details(db=None, supported_series=None):
    """Return an AppDetail instance with the required attributes."""
    app = make_software_center_agent_app_dict()
    subscription = make_software_center_agent_subscription_dict(app)

    if supported_series != None:
        subscription['application']['series'] = supported_series
    else:
        # If no supportod_series kwarg was provided, we ensure the
        # current series/arch is supported.
        distro = get_distro()
        subscription['application']['series'] = {
            distro.get_codename(): [distro.get_architecture()]
        }

    item = PistonResponseObject.from_dict(subscription)
    parser = SCAPurchasedApplicationParser(item)

    if db is None:
        db = get_test_db()

    doc = make_doc_from_parser(parser, db._aptcache)
    app_details = AppDetails(db, doc)
    return app_details
Example #43
0
 def __init__(self, channel_name, channel_origin, channel_component,
              source_entry=None, installed_only=False,
              channel_icon=None, channel_query=None,
              channel_sort_mode=SortMethods.BY_ALPHABET):
     """
     configure the software channel object based on channel name,
     origin, and component (the latter for detecting the partner
     channel)
     """
     self._channel_name = channel_name
     self._channel_origin = channel_origin
     self._channel_component = channel_component
     self._channel_color = None
     self._channel_view_id = None
     self.installed_only = installed_only
     self._channel_sort_mode = channel_sort_mode
     # distro specific stuff
     self.distro = get_distro()
     # configure the channel
     self._channel_display_name = self._get_display_name_for_channel(
         channel_name, channel_origin, channel_component)
     if channel_icon is None:
         self._channel_icon = self._get_icon_for_channel(
             channel_name, channel_origin, channel_component)
     else:
         self._channel_icon = channel_icon
     if channel_query is None:
         self._channel_query = self._get_channel_query_for_channel(
             channel_name, channel_origin, channel_component)
     else:
         self._channel_query = channel_query
     # a sources.list entry attached to the channel (this is currently
     # only used for not-yet-enabled channels)
     self._source_entry = source_entry
     # when the channel needs to be added to the systems sources.list
     self.needs_adding = False
Example #44
0
 def __init__(self):
     LoginBackend.__init__(self)
     self.distro = get_distro()
     self.oauth_token = None
Example #45
0
 def __init__(self, ignore_cache=False, xid=None):
     GObject.GObject.__init__(self)
     self.distro = get_distro()
     self.ignore_cache = ignore_cache
     self.xid = xid
Example #46
0
    def _get_channels(self, installed_only=False):
        """
        (internal) implements 'channels()' and 'channels_installed_only()' properties
        """
        distro_channel_name = self.distro.get_distro_channel_name()

        # gather the set of software channels and order them
        other_channel_list = []
        cached_origins = []
        for channel_iter in self.db.xapiandb.allterms("XOL"):
            if len(channel_iter.term) == 3:
                continue
            channel_name = channel_iter.term[3:]
            channel_origin = ""

            # get origin information for this channel
            m = self.db.xapiandb.postlist_begin(channel_iter.term)
            doc = self.db.xapiandb.get_document(m.get_docid())
            for term_iter in doc.termlist():
                if term_iter.term.startswith("XOO") and len(
                        term_iter.term) > 3:
                    channel_origin = term_iter.term[3:]
                    break
            self._logger.debug("channel_name: %s" % channel_name)
            self._logger.debug("channel_origin: %s" % channel_origin)
            if channel_origin not in cached_origins:
                other_channel_list.append((channel_name, channel_origin))
                cached_origins.append(channel_origin)

        dist_channel = None
        partner_channel = None
        for_purchase_channel = None
        new_apps_channel = None
        ppa_channels = []
        other_channels = []
        unknown_channel = []
        local_channel = None

        for (channel_name, channel_origin) in other_channel_list:
            if not channel_name:
                unknown_channel.append(
                    SoftwareChannel(channel_name,
                                    channel_origin,
                                    None,
                                    installed_only=installed_only))
            elif channel_name == distro_channel_name:
                dist_channel = (SoftwareChannel(distro_channel_name,
                                                channel_origin,
                                                None,
                                                installed_only=installed_only))
            elif channel_name == "Partner archive":
                partner_channel = SoftwareChannel(
                    channel_name,
                    channel_origin,
                    "partner",
                    installed_only=installed_only)
            elif channel_name == "notdownloadable":
                if installed_only:
                    local_channel = SoftwareChannel(
                        channel_name,
                        None,
                        None,
                        installed_only=installed_only)
            elif (channel_origin and channel_origin.startswith(
                    "LP-PPA-commercial-ppa-uploaders")):
                # do not display commercial private PPAs, they will all be
                # displayed in the "for-purchase" node anyway
                pass
            elif channel_origin and channel_origin.startswith("LP-PPA"):
                if channel_origin == "LP-PPA-app-review-board":
                    new_apps_channel = SoftwareChannel(
                        channel_name,
                        channel_origin,
                        None,
                        installed_only=installed_only)
                else:
                    ppa_channels.append(
                        SoftwareChannel(channel_name,
                                        channel_origin,
                                        None,
                                        installed_only=installed_only))
            # TODO: detect generic repository source (e.g., Google, Inc.)
            else:
                other_channels.append(
                    SoftwareChannel(channel_name,
                                    channel_origin,
                                    None,
                                    installed_only=installed_only))

        # always display the partner channel, even if its source is not enabled
        if not partner_channel and distro_channel_name == "Ubuntu":
            partner_channel = SoftwareChannel("Partner archive",
                                              "Canonical",
                                              "partner",
                                              installed_only=installed_only)

        # create a "magic" channel to display items available for purchase
        for_purchase_query = xapian.Query(
            "AH" + AVAILABLE_FOR_PURCHASE_MAGIC_CHANNEL_NAME)
        for_purchase_channel = SoftwareChannel(
            "For Purchase",
            None,
            None,
            channel_icon=None,  # FIXME:  need an icon
            channel_query=for_purchase_query,
            installed_only=installed_only)

        # set them in order
        channels = []
        if dist_channel is not None:
            channels.append(dist_channel)
        if partner_channel is not None:
            channels.append(partner_channel)
        if get_distro().PURCHASE_APP_URL:
            channels.append(for_purchase_channel)
        if new_apps_channel is not None:
            channels.append(new_apps_channel)
        channels.extend(ppa_channels)
        channels.extend(other_channels)
        channels.extend(unknown_channel)
        channels.extend(self.extra_channels)
        if local_channel is not None:
            channels.append(local_channel)

        for channel in channels:
            if installed_only:
                channel._channel_view_id = ViewPages.INSTALLED
            else:
                channel._channel_view_id = ViewPages.AVAILABLE
        return channels
 def setUpClass(cls):
     # Set these as class attributes as we don't modify either
     # during the tests.
     cls.distro = get_distro()
     cls.db = get_test_db()
Example #48
0
 def __init__(self, db, **kwargs):
     self.distro = get_distro()
     self.db = db
Example #49
0
class AllInstalledChannel(AllChannel):

    def __init__(self):
        AllChannel.__init__(self, _("All Installed"), True)

# singleton
channels_manager = None
def get_channels_manager(db):
    global channels_manager
    if channels_manager is None:
        from softwarecenter.enums import USE_PACKAGEKIT_BACKEND
        if not USE_PACKAGEKIT_BACKEND:
            from softwarecenter.backend.channel_impl.aptchannels import AptChannelsManager
            channels_manager = AptChannelsManager(db)
        else:
            channels_manager = ChannelsManager(db)
    return channels_manager

def is_channel_available(channelname):
    from softwarecenter.backend.channel_impl.aptchannels import AptChannelsManager
    return AptChannelsManager.channel_available(channelname)

if __name__ == "__main__":
    distro = get_distro()
    channel = SoftwareChannel(distro.get_distro_channel_name(), 
                              None, None)
    print(channel)
    channel = SoftwareChannel(distro.get_distro_channel_name(), None, "partner")
    print(channel)

Example #50
0
    def __init__(self, db, doc=None, application=None):
        """ Create a new AppDetails object. It can be created from
            a xapian.Document or from a db.application.Application object
        """
        GObject.GObject.__init__(self)
        if not doc and not application:
            raise ValueError("Need either document or application")
        self._db = db
        self._db.connect("reopen", self._on_db_reopen)
        self._cache = self._db._aptcache
        self._distro = get_distro()
        self._history = None
        # import here (intead of global) to avoid dbus dependency
        # in update-software-center (that imports application, but
        # never uses AppDetails) LP: #620011
        from softwarecenter.backend import get_install_backend
        self._backend = get_install_backend()
        # FIXME: why two error states ?
        self._error = None
        self._error_not_found = None
        self._screenshot_list = []

        # load application
        self._app = application
        if doc:
            self._app = Application(self._db.get_appname(doc),
                                    self._db.get_pkgname(doc),
                                    "")

        # sustitute for apturl
        if self._app.request:
            self._app.request = self._app.request.replace(
                "$distro", self._distro.get_codename())

        # load pkg cache
        self._pkg = None
        if (self._app.pkgname in self._cache and
            self._cache[self._app.pkgname].candidate):
            self._pkg = self._cache[self._app.pkgname]

        # load xapian document
        self._doc = doc
        if not self._doc:
            try:
                self._doc = self._db.get_xapian_document(
                    self._app.appname, self._app.pkgname)
            except IndexError:
                # if there is no document and no apturl request,
                # set error state
                debfile_matches = re.findall(r'/', self._app.request)
                channel_matches = re.findall(r'channel=[a-z,-]*',
                                             self._app.request)
                section_matches = re.findall(r'section=[a-z]*',
                                             self._app.request)
                if (not self._pkg and
                    not debfile_matches and
                    not channel_matches and
                    not section_matches):
                    self._error = _("Not found")
                    self._error_not_found = utf8(
                        _(u"There isn\u2019t a "
                          u"software package called \u201c%s\u201D in your "
                          u"current software sources.")) % utf8(self.pkgname)
Example #51
0
 def test_application_details(self):
     db = xapian.WritableDatabase("./data/test.db", 
                                  xapian.DB_CREATE_OR_OVERWRITE)
     res = update_from_app_install_data(db, self.cache, datadir="./data/desktop")
     self.assertTrue(res)
     db = StoreDatabase("./data/test.db", self.cache)
     db.open(use_axi=False, use_agent=False)
     self.assertEqual(len(db), 5)
     # test details
     app = Application("Ubuntu Software Center Test", "software-center")
     details = app.get_details(db)
     self.assertNotEqual(details, None)
     self.assertEqual(details.component, "main")
     self.assertEqual(details.pkgname, "software-center")
     # get the first document
     for doc in db:
         if doc.get_data() == "Ubuntu Software Center Test":
             appdetails = AppDetails(db, doc=doc)
             break
     # test get_appname and get_pkgname
     self.assertEqual(db.get_appname(doc), "Ubuntu Software Center Test")
     self.assertEqual(db.get_pkgname(doc), "software-center")
     # test appdetails
     self.assertEqual(appdetails.name, "Ubuntu Software Center Test")
     self.assertEqual(appdetails.pkgname, "software-center")
     # FIXME: add a dekstop file with a real channel to test
     #        and monkey-patch/modify the APP_INSTALL_CHANNELS_PATH
     self.assertEqual(appdetails.channelname, None)
     self.assertEqual(appdetails.channelfile, None)
     self.assertEqual(appdetails.component, "main")
     self.assertNotEqual(appdetails.pkg, None)
     # from the fake test/data/appdetails/var/lib/dpkg/status
     self.assertEqual(appdetails.pkg.is_installed, True)
     self.assertEqual(appdetails.pkg_state, PkgStates.INSTALLED)
     # FIXME: test description for unavailable pkg
     self.assertTrue(
         appdetails.description.startswith("Ubuntu Software Center lets you"))
     # FIXME: test appdetails.website
     self.assertEqual(appdetails.icon, "softwarecenter")
     # crude, crude
     self.assertTrue(len(appdetails.version) > 2)
     # FIXME: screenshots will only work on ubuntu
     self.assertTrue(re.match(
             "http://screenshots.ubuntu.com/screenshot-with-version/software-center/[\d.]+", 
             appdetails.screenshot))
     self.assertTrue(re.match(
             "http://screenshots.ubuntu.com/thumbnail-with-version/software-center/[\d.]+",
             appdetails.thumbnail))
     # FIXME: add document that has a price
     self.assertEqual(appdetails.price, '')
     self.assertEqual(appdetails.license, "Open source")
     # test lazy history loading for installation date
     self.ensure_installation_date_and_lazy_history_loading(appdetails)
     # test apturl replacements
     # $kernel
     app = Application("", "linux-headers-$kernel", "channel=$distro-partner")
     self.assertEqual(app.pkgname, 'linux-headers-'+os.uname()[2])
     # $distro
     details = app.get_details(db)
     from softwarecenter.distro import get_distro
     distro = get_distro().get_codename()
     self.assertEqual(app.request, 'channel=' + distro + '-partner')
Example #52
0
 def test_get_distro(self):
     distro = get_distro()
     self.assertNotEqual(distro, None)
 def __init__(self):
     super(PackagekitInfo, self).__init__()
     self.client = packagekit.Client()
     self._cache = {}  # temporary hack for decent testing
     self._notfound_cache = []
     self.distro = get_distro()