示例#1
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 = softwarecenter.distro.get_distro()
        self._history = None
        # import here (instead of global) to avoid dbus dependency
        # in update-software-center (that imports application, but
        # never uses AppDetails) LP: #620011
        from softwarecenter.backend.installbackend 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), "")

        # substitute 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)
示例#2
0
    def test_add_license_key_backend(self):
        self._finished = False
        # add repo
        deb_line = "deb https://mvo:[email protected]/canonical-isd-hackers/internal-qa/ubuntu oneiric main"
        signing_key_id = "F5410BE0"
        app = Application("Test app1", self.PKGNAME)
        # install only when runnig as root, as we require polkit promtps
        # otherwise
        # FIXME: provide InstallBackendSimulate()
        if os.getuid() == 0:
            backend = get_install_backend()
            backend.ui = Mock()
            backend.connect("transaction-finished",
                            self._on_transaction_finished)
            # simulate repos becomes available for the public 20 s later
            GLib.timeout_add_seconds(20, self._add_pw_to_commercial_repo)
            # run it
            backend.add_repo_add_key_and_install_app(deb_line,
                                                     signing_key_id,
                                                     app,
                                                     "icon",
                                                     self.LICENSE_KEY)
            # wait until the pkg is installed
            while not self._finished:
                do_events_with_sleep()

        if os.getuid() == 0:
            self.assertTrue(os.path.exists(self.LICENSE_KEY_PATH))
            self.assertEqual(open(self.LICENSE_KEY_PATH).read(), self.LICENSE_KEY)
示例#3
0
 def test_memleak_backend_finished(self):
     backend = get_install_backend()
     backend.emit("transaction-finished", Mock())
     do_events_with_sleep()
     with TraceMemoryUsage("backend.emit('transaction-finished')"):
         for i in range(self.ITERATIONS):
             backend.emit("transaction-finished", Mock())
             do_events_with_sleep()
示例#4
0
 def test_memleak_backend_finished(self):
     backend = get_install_backend()
     backend.emit("transaction-finished", Mock())
     do_events_with_sleep()
     with TraceMemoryUsage("backend.emit('transaction-finished')"):
         for i in range(self.ITERATIONS):
             backend.emit("transaction-finished", Mock())
             do_events_with_sleep()
示例#5
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 = softwarecenter.distro.get_distro()
        self._history = None
        # import here (instead of global) to avoid dbus dependency
        # in update-software-center (that imports application, but
        # never uses AppDetails) LP: #620011
        from softwarecenter.backend.installbackend 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), "")

        # substitute 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)
示例#6
0
    def __init__(self, view_manager, db, cache, icons):
        # boring stuff
        self.view_manager = view_manager

        def on_view_changed(widget, view_id):
            self.view_buttons[view_id].set_active(True)
        self.view_manager.connect('view-changed', on_view_changed)
        self.channel_manager = get_channels_manager(db)

        # backend sig handlers ...
        self.backend = get_install_backend()
        self.backend.connect("transactions-changed",
                             self.on_transaction_changed)
        self.backend.connect("transaction-finished",
                             self.on_transaction_finished)
        self.backend.connect("channels-changed",
                             self.on_channels_changed)

        # widgetry
        Gtk.Box.__init__(self)
        self.set_orientation(Gtk.Orientation.HORIZONTAL)

        # Gui stuff
        self.view_buttons = {}
        self.selectors = {}
        self._prev_view = None  # track the previous active section
        self._prev_item = None  # track the previous active menu-item
        self._handlers = []

        # order is important here!
        # first, the availablepane items
        icon = SymbolicIcon("available")
        self.append_section_with_channel_sel(
                                ViewPages.AVAILABLE,
                                _("All Software"),
                                icon,
                                self.on_get_available_channels)

        # the installedpane items
        icon = SymbolicIcon("installed")
        self.append_section_with_channel_sel(
                                ViewPages.INSTALLED,
                                _("Installed"),
                                icon,
                                self.on_get_installed_channels)

        # the historypane item
        icon = SymbolicIcon("history")
        self.append_section(ViewPages.HISTORY, _("History"), icon)

        # the pendingpane
        icon = PendingSymbolicIcon("pending")
        self.append_section(ViewPages.PENDING, _("Progress"), icon)

        # set sensible atk name
        atk_desc = self.get_accessible()
        atk_desc.set_name(_("Software sources"))
示例#7
0
 def __init__(self):
     FramedHeaderBox.__init__(self)
     self.recommender_agent = RecommenderAgent()
     # keep track of applications that have been viewed via a
     # recommendation so that we can detect when a recommended app
     # has been installed
     self.recommended_apps_viewed = set()
     self.backend = get_install_backend()
     self.backend.connect("transaction-started", self._on_transaction_started)
     self.backend.connect("transaction-finished", self._on_transaction_finished)
示例#8
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
示例#9
0
    def __init__(self, view_manager, db, cache, icons):
        # boring stuff
        self.view_manager = view_manager

        def on_view_changed(widget, view_id):
            self.view_buttons[view_id].set_active(True)

        self.view_manager.connect('view-changed', on_view_changed)
        self.channel_manager = get_channels_manager(db)

        # backend sig handlers ...
        self.backend = get_install_backend()
        self.backend.connect("transactions-changed",
                             self.on_transaction_changed)
        self.backend.connect("transaction-finished",
                             self.on_transaction_finished)
        self.backend.connect("channels-changed", self.on_channels_changed)

        # widgetry
        Gtk.Box.__init__(self)
        self.set_orientation(Gtk.Orientation.HORIZONTAL)

        # Gui stuff
        self.view_buttons = {}
        self.selectors = {}
        self._prev_view = None  # track the previous active section
        self._prev_item = None  # track the previous active menu-item
        self._handlers = []

        # order is important here!
        # first, the availablepane items
        icon = SymbolicIcon("available")
        self.append_section_with_channel_sel(ViewPages.AVAILABLE,
                                             _("All Software"), icon,
                                             self.on_get_available_channels)

        # the installedpane items
        icon = SymbolicIcon("installed")
        self.append_section_with_channel_sel(ViewPages.INSTALLED,
                                             _("Installed"), icon,
                                             self.on_get_installed_channels)

        # the historypane item
        icon = SymbolicIcon("history")
        self.append_section(ViewPages.HISTORY, _("History"), icon)

        # the pendingpane
        icon = PendingSymbolicIcon("pending")
        self.append_section(ViewPages.PENDING, _("Progress"), icon)

        # set sensible atk name
        atk_desc = self.get_accessible()
        atk_desc.set_name(_("Software sources"))
示例#10
0
 def __init__(self):
     FramedHeaderBox.__init__(self)
     self.recommender_agent = RecommenderAgent()
     # keep track of applications that have been viewed via a
     # recommendation so that we can detect when a recommended app
     # has been installed
     self.recommended_apps_viewed = set()
     self.backend = get_install_backend()
     self.backend.connect("transaction-started",
                          self._on_transaction_started)
     self.backend.connect("transaction-finished",
                          self._on_transaction_finished)
示例#11
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
示例#12
0
 def _process_json(self, json_string):
     try:
         LOG.debug("server returned: '%s'" % json_string)
         res = json.loads(json_string)
         # print res
     except:
         LOG.debug("error processing json: '%s'" % json_string)
         return
     if res["successful"] is False:
         if (
             res.get("user_canceled", False)
             or
             # note the different spelling
             res.get("user_cancelled", False)
             or
             # COMPAT with older clients that do not send the user
             #        canceled property (LP: #696861), this msg appears
             #        to be not translated
             "CANCELLED" in res.get("failures", "")
         ):
             self.emit("purchase-cancelled-by-user")
             self._block_wk_handlers()
             return
         # this is what the agent implements
         elif "failures" in res:
             LOG.error("the server returned a error: '%s'" % res["failures"])
         # show a generic error, the "failures" string we get from the
         # server is way too technical to show, but we do log it
         self.emit("purchase-failed")
         self._block_wk_handlers()
         return
     else:
         self.emit("purchase-succeeded")
         self._block_wk_handlers()
         # gather data from response
         deb_line = res["deb_line"]
         signing_key_id = res["signing_key_id"]
         license_key = res.get("license_key")
         license_key_path = res.get("license_key_path")
         # add repo and key
         backend = get_install_backend()
         backend.add_repo_add_key_and_install_app(
             deb_line,
             signing_key_id,
             self.app,
             self.iconname,
             license_key,
             license_key_path,
             json.dumps(self._oauth_token),
         )
示例#13
0
    def __init__(self, cache, db, distro, icons, show_ratings=True):

        Gtk.VBox.__init__(self)
        BasePane.__init__(self)

        # other classes we need
        self.enquirer = AppEnquire(cache, db)
        self._query_complete_handler = self.enquirer.connect(
            "query-complete", self.on_query_complete)

        self.cache = cache
        self.db = db
        self.distro = distro
        self.icons = icons
        self.show_ratings = show_ratings
        self.backend = get_install_backend()
        self.nonapps_visible = NonAppVisibility.MAYBE_VISIBLE
        # refreshes can happen out-of-bound so we need to be sure
        # that we only set the new model (when its available) if
        # the refresh_seq_nr of the ready model matches that of the
        # request (e.g. people click on ubuntu channel, get impatient, click
        # on partner channel)
        self.refresh_seq_nr = 0
        # this should be initialized
        self.apps_search_term = ""
        # Create the basic frame for the common view
        self.state = DisplayState()
        vm = get_viewmanager()
        self.searchentry = vm.get_global_searchentry()
        self.back_forward = vm.get_global_backforward()
        # a notebook below
        self.notebook = Gtk.Notebook()
        if not SOFTWARE_CENTER_DEBUG_TABS:
            self.notebook.set_show_tabs(False)
        self.notebook.set_show_border(False)
        # make a spinner view to display while the applist is loading
        self.spinner_notebook = SpinnerNotebook(self.notebook)
        self.pack_start(self.spinner_notebook, True, True, 0)

        # add a bar at the bottom (hidden by default) for contextual actions
        self.action_bar = ActionBar()
        self.pack_start(self.action_bar, False, True, 0)

        # cursor
        self.busy_cursor = Gdk.Cursor.new(Gdk.CursorType.WATCH)

        # views to be created in init_view
        self.app_view = None
        self.app_details_view = None
示例#14
0
    def __init__(self, cache, db, distro, icons, show_ratings=True):

        Gtk.VBox.__init__(self)
        BasePane.__init__(self)

        # other classes we need
        self.enquirer = AppEnquire(cache, db)
        self._query_complete_handler = self.enquirer.connect(
                            "query-complete", self.on_query_complete)

        self.cache = cache
        self.db = db
        self.distro = distro
        self.icons = icons
        self.show_ratings = show_ratings
        self.backend = get_install_backend()
        self.nonapps_visible = NonAppVisibility.MAYBE_VISIBLE
        # refreshes can happen out-of-bound so we need to be sure
        # that we only set the new model (when its available) if
        # the refresh_seq_nr of the ready model matches that of the
        # request (e.g. people click on ubuntu channel, get impatient, click
        # on partner channel)
        self.refresh_seq_nr = 0
        # this should be initialized
        self.apps_search_term = ""
        # Create the basic frame for the common view
        self.state = DisplayState()
        vm = get_viewmanager()
        self.searchentry = vm.get_global_searchentry()
        self.back_forward = vm.get_global_backforward()
        # a notebook below
        self.notebook = Gtk.Notebook()
        if not SOFTWARE_CENTER_DEBUG_TABS:
            self.notebook.set_show_tabs(False)
        self.notebook.set_show_border(False)
        # make a spinner view to display while the applist is loading
        self.spinner_notebook = SpinnerNotebook(self.notebook)
        self.pack_start(self.spinner_notebook, True, True, 0)

        # add a bar at the bottom (hidden by default) for contextual actions
        self.action_bar = ActionBar()
        self.pack_start(self.action_bar, False, True, 0)

        # cursor
        self.busy_cursor = Gdk.Cursor.new(Gdk.CursorType.WATCH)

        # views to be created in init_view
        self.app_view = None
        self.app_details_view = None
示例#15
0
    def __init__(self, icons):
        # icon, status, progress
        Gtk.ListStore.__init__(self)
        self.set_column_types(self.column_types)

        self._transactions_watcher = get_transactions_watcher()
        self._transactions_watcher.connect("lowlevel-transactions-changed",
            self._on_lowlevel_transactions_changed)
        # data
        self.icons = icons
        # the apt-daemon stuff
        self.backend = get_install_backend()
        self._signals = []
        # let the pulse helper run
        GLib.timeout_add(500, self._pulse_purchase_helper)
示例#16
0
    def __init__(self, icons):
        # icon, status, progress
        Gtk.ListStore.__init__(self)
        self.set_column_types(self.column_types)

        self._transactions_watcher = get_transactions_watcher()
        self._transactions_watcher.connect(
            "lowlevel-transactions-changed",
            self._on_lowlevel_transactions_changed)
        # data
        self.icons = icons
        # the apt-daemon stuff
        self.backend = get_install_backend()
        self._signals = []
        # let the pulse helper run
        GLib.timeout_add(500, self._pulse_purchase_helper)
示例#17
0
 def __init__(self, parent=None):
     super(PkgListModel, self).__init__()
     self._docs = []
     roles = dict(enumerate(PkgListModel.COLUMNS))
     self.setRoleNames(roles)
     self._query = ""
     self._category = ""
     pathname = os.path.join(XAPIAN_BASE_PATH, "xapian")
     self.cache = get_pkg_info()
     self.db = StoreDatabase(pathname, self.cache)
     self.db.open(use_axi=False)
     self.backend = get_install_backend()
     self.backend.connect("transaction-progress-changed",
                          self._on_backend_transaction_progress_changed)
     self.reviews = get_review_loader(self.cache)
     # FIXME: get this from a parent
     self._catparser = CategoriesParser(self.db)
     self._categories = self._catparser.parse_applications_menu(
         '/usr/share/app-install')
示例#18
0
 def _process_json(self, json_string):
     try:
         LOG.debug("server returned: '%s'" % json_string)
         res = json.loads(json_string)
         #print res
     except:
         LOG.debug("error processing json: '%s'" % json_string)
         return
     if res["successful"] is False:
         if (res.get("user_canceled", False) or
                 # note the different spelling
                 res.get("user_cancelled", False) or
                 # COMPAT with older clients that do not send the user
                 #        canceled property (LP: #696861), this msg appears
                 #        to be not translated
                 "CANCELLED" in res.get("failures", "")):
             self.emit("purchase-cancelled-by-user")
             self._block_wk_handlers()
             return
         # this is what the agent implements
         elif "failures" in res:
             LOG.error("the server returned a error: '%s'" %
                       res["failures"])
         # show a generic error, the "failures" string we get from the
         # server is way too technical to show, but we do log it
         self.emit("purchase-failed")
         self._block_wk_handlers()
         return
     else:
         self.emit("purchase-succeeded")
         self._block_wk_handlers()
         # gather data from response
         deb_line = res["deb_line"]
         signing_key_id = res["signing_key_id"]
         license_key = res.get("license_key")
         license_key_path = res.get("license_key_path")
         # add repo and key
         backend = get_install_backend()
         backend.add_repo_add_key_and_install_app(
             deb_line, signing_key_id, self.app, self.iconname, license_key,
             license_key_path, json.dumps(self._oauth_token))
示例#19
0
    def __init__(self, db, cache, icons, icon_size, global_icon_cache):
        AppPropertiesHelper.__init__(self, db, cache, icons, icon_size,
                                     global_icon_cache)

        # backend stuff
        self.backend = get_install_backend()
        self.backend.connect("transaction-progress-changed",
            self._on_transaction_progress_changed)
        self.backend.connect("transaction-started",
            self._on_transaction_started)
        self.backend.connect("transaction-finished",
            self._on_transaction_finished)

        # keep track of paths for transactions in progress
        self.transaction_path_map = {}

        # active row path
        self.active_row = None

        self._in_progress = False
        self._break = False

        # other stuff
        self.active = False
示例#20
0
    def __init__(self, db, cache, icons, icon_size, global_icon_cache):
        AppPropertiesHelper.__init__(self, db, cache, icons, icon_size,
                                     global_icon_cache)

        # backend stuff
        self.backend = get_install_backend()
        self.backend.connect("transaction-progress-changed",
                             self._on_transaction_progress_changed)
        self.backend.connect("transaction-started",
                             self._on_transaction_started)
        self.backend.connect("transaction-finished",
                             self._on_transaction_finished)

        # keep track of paths for transactions in progress
        self.transaction_path_map = {}

        # active row path
        self.active_row = None

        self._in_progress = False
        self._break = False

        # other stuff
        self.active = False
示例#21
0
        res = "ok"
        res = error(parent=parent,
                    primary=primary,
                    secondary=secondary,
                    details=details,
                    alternative_action=alternative_action)
        if res == Gtk.ResponseType.YES:
            res = "yes"
        return res


if __name__ == "__main__":
    from softwarecenter.backend.installbackend import get_install_backend
    from mock import Mock

    aptd = get_install_backend()
    aptd.ui = InstallBackendUI()
    # test config file prompt
    trans = Mock()
    res = aptd._config_file_conflict(trans, "/etc/group", "/etc/group-")
    print(res)

    # test medium required
    trans = Mock()
    res = aptd._medium_required(trans, "medium", "drive")
    print(res)

    # test error dialog
    trans = Mock()
    trans.error_code = 102
    trans.error_details = "details"
示例#22
0
文件: utils.py 项目: sti-lyneos/shop
def get_test_install_backend():
    backend = get_install_backend()
    return backend
示例#23
0
    def __init__(self, helper, doc, icon_size=48):
        TileButton.__init__(self)
        self._pressed = False

        label = helper.get_appname(doc)
        icon = helper.get_icon_at_size(doc, icon_size, icon_size)
        stats = helper.get_review_stats(doc)

        self.helper = helper
        helper.update_availability(doc)
        helper.connect("needs-refresh", self._on_needs_refresh, doc, icon_size)
        self.is_installed = helper.is_installed(doc)
        self._overlay = helper.icons.load_icon(Icons.INSTALLED_OVERLAY,
                                               self.INSTALLED_OVERLAY_SIZE,
                                               0)  # flags

        self.box.set_orientation(Gtk.Orientation.HORIZONTAL)
        self.box.set_spacing(StockEms.SMALL)

        self.content_left = Gtk.Box.new(Gtk.Orientation.VERTICAL,
            StockEms.MEDIUM)
        self.content_right = Gtk.Box.new(Gtk.Orientation.VERTICAL, 1)
        self.box.pack_start(self.content_left, False, False, 0)
        self.box.pack_start(self.content_right, False, False, 0)
        self.image = Gtk.Image()
        _update_icon(self.image, icon, icon_size)
        self.content_left.pack_start(self.image, False, False, 0)

        self.title = Gtk.Label.new(self._MARKUP %
            GLib.markup_escape_text(label))
        self.title.set_alignment(0.0, 0.5)
        self.title.set_use_markup(True)
        self.title.set_tooltip_text(label)
        self.title.set_ellipsize(Pango.EllipsizeMode.END)
        self.content_right.pack_start(self.title, False, False, 0)

        categories = helper.get_categories(doc)
        if categories is not None:
            self.category = Gtk.Label.new('<span font_desc="%i">%s</span>' %
                (em(0.6), GLib.markup_escape_text(categories)))
            self.category.set_use_markup(True)
            self.category.set_alignment(0.0, 0.5)
            self.category.set_ellipsize(Pango.EllipsizeMode.END)
            self.content_right.pack_start(self.category, False, False, 4)

        stats_a11y = None
        if stats is not None:
            self.stars = Star(size=StarSize.SMALL)
            self.stars.render_outline = True
            self.stars.set_rating(stats.ratings_average)
            self.rating_box = Gtk.Box.new(Gtk.Orientation.HORIZONTAL,
                StockEms.SMALL)
            self.rating_box.pack_start(self.stars, False, False, 0)
            self.n_ratings = Gtk.Label.new(
                '<span font_desc="%i"> (%i)</span>' % (
                    em(0.45), stats.ratings_total))
            self.n_ratings.set_use_markup(True)
            self.n_ratings.set_name("subtle-label")
            self.n_ratings.set_alignment(0.0, 0.5)
            self.rating_box.pack_start(self.n_ratings, False, False, 0)
            self.content_right.pack_start(self.rating_box, False, False, 0)
            # TRANSLATORS: this is an accessibility description for eg orca and
            # is not visible in the ui
            stats_a11y = _('%(stars)d stars - %(reviews)d reviews') % {
                'stars': stats.ratings_average, 'reviews': stats.ratings_total}

            # work out width tile needs to be to ensure ratings text is all
            # visible
            req_width = (self.stars.size_request().width +
                         self.image.size_request().width +
                         self.n_ratings.size_request().width +
                         StockEms.MEDIUM * 3
                         )
            global _global_featured_tile_width
            _global_featured_tile_width = max(_global_featured_tile_width,
                                              req_width)

        # TRANSLATORS: Free here means Gratis
        price = helper.get_display_price(doc)
        self.price = Gtk.Label.new(
            '<span font_desc="%i">%s</span>' % (em(0.6), price))
        self.price.set_use_markup(True)
        self.price.set_name("subtle-label")
        self.price.set_alignment(0.0, 0.5)
        self.content_right.pack_start(self.price, False, False, 0)

        self.set_name("featured-tile")

        a11y_name = '. '.join([t
            for t in [label, categories, stats_a11y, price] if t])
        self.get_accessible().set_name(a11y_name)

        self.backend = get_install_backend()
        self.backend.connect("transaction-finished",
                        self.on_transaction_finished,
                        helper, doc)
        self.connect("enter-notify-event", self.on_enter)
        self.connect("leave-notify-event", self.on_leave)
        self.connect("button-press-event", self.on_press)
        self.connect("button-release-event", self.on_release)
示例#24
0
def get_test_install_backend():
    from softwarecenter.backend.installbackend import get_install_backend
    backend = get_install_backend()
    return backend
示例#25
0
        from dialogs import error
        res = "ok"
        res = error(parent=parent,
                    primary=primary,
                    secondary=secondary,
                    details=details,
                    alternative_action=alternative_action)
        if res == Gtk.ResponseType.YES:
            res = "yes"
        return res

if __name__ == "__main__":
    from softwarecenter.backend.installbackend import get_install_backend
    from mock import Mock

    aptd = get_install_backend()
    aptd.ui = InstallBackendUI()
    # test config file prompt
    trans = Mock()
    res = aptd._config_file_conflict(trans, "/etc/group", "/etc/group-")
    print (res)

    # test medium required
    trans = Mock()
    res = aptd._medium_required(trans, "medium", "drive")
    print (res)

    # test error dialog
    trans = Mock()
    trans.error_code = 102
    trans.error_details = "details"
示例#26
0
文件: utils.py 项目: pombredanne/shop
def get_test_install_backend():
    backend = get_install_backend()
    return backend
def get_test_install_backend():
    from softwarecenter.backend.installbackend import get_install_backend
    backend = get_install_backend()
    return backend
示例#28
0
 def init_plugin(self):
     self.pkg_info = get_pkg_info()
     self.install_backend = get_install_backend()
     self.install_backend.connect("transaction-finished",
                                  self._on_transaction_finished)
示例#29
0
 def init_plugin(self):
     self.pkg_info = get_pkg_info()
     self.install_backend = get_install_backend()
     self.install_backend.connect(
         "transaction-finished", self._on_transaction_finished)
示例#30
0
    def __init__(self, app_view, db, icons, show_ratings, store=None):
        Gtk.TreeView.__init__(self)
        self._logger = logging.getLogger("softwarecenter.view.appview")

        self.app_view = app_view
        self.db = db

        self.pressed = False
        self.focal_btn = None
        self._action_block_list = []
        self._needs_collapse = []
        self.expanded_path = None
        self.selected_row_renderer = None

        # pixbuf for the icon that is displayed in the selected row
        self.selected_row_icon = None

        #~ # if this hacked mode is available everything will be fast
        #~ # and we can set fixed_height mode and still have growing rows
        #~ # (see upstream gnome #607447)
        try:
            self.set_property("ubuntu-almost-fixed-height-mode", True)
            self.set_fixed_height_mode(True)
        except:
            self._logger.warn(
                "ubuntu-almost-fixed-height-mode extension not available")

        self.set_headers_visible(False)

        # our custom renderer
        self._renderer = CellRendererAppView(icons,
                                 self.create_pango_layout(''),
                                 show_ratings,
                                 Icons.INSTALLED_OVERLAY)
        self._renderer.set_pixbuf_width(32)
        self._renderer.set_button_spacing(em(0.3))

        # create buttons and set initial strings
        info = CellButtonRenderer(self,
                                  name=CellButtonIDs.INFO)
        info.set_markup_variants(
                    {self.VARIANT_INFO: _('More Info')})

        action = CellButtonRenderer(self,
                                    name=CellButtonIDs.ACTION)

        action.set_markup_variants(
                {self.VARIANT_INSTALL: _('Install'),
                 self.VARIANT_REMOVE: _('Remove'),
                 self.VARIANT_PURCHASE: _(u'Buy\u2026')})

        self._renderer.button_pack_start(info)
        self._renderer.button_pack_end(action)

        self._column = Gtk.TreeViewColumn(
            "Applications", self._renderer,
            application=AppGenericStore.COL_ROW_DATA)
        self._column.set_cell_data_func(
            self._renderer, self._cell_data_func_cb)
        self._column.set_fixed_width(200)
        self._column.set_sizing(Gtk.TreeViewColumnSizing.FIXED)
        self.append_column(self._column)

        # network status watcher
        watcher = get_network_watcher()
        watcher.connect("changed", self._on_net_state_changed, self._renderer)

        # custom cursor
        self._cursor_hand = Gdk.Cursor.new(Gdk.CursorType.HAND2)

        self.connect("style-updated", self._on_style_updated, self._renderer)
        # workaround broken engines (LP: #1021308)
        self.emit("style-updated")
        # button and motion are "special"
        self.connect("button-press-event", self._on_button_press_event,
                     self._renderer)
        self.connect("button-release-event", self._on_button_release_event,
                     self._renderer)
        self.connect("key-press-event", self._on_key_press_event,
                     self._renderer)
        self.connect("key-release-event", self._on_key_release_event,
                     self._renderer)
        self.connect("motion-notify-event", self._on_motion, self._renderer)
        self.connect("cursor-changed", self._on_cursor_changed, self._renderer)
        # our own "activate" handler
        self.connect("row-activated", self._on_row_activated, self._renderer)

        self.backend = get_install_backend()
        self._transactions_connected = False
        self.connect('realize', self._on_realize, self._renderer)
示例#31
0
 def test_fake_aptd(self):
     from softwarecenter.backend.installbackend import get_install_backend
     backend = get_install_backend()
     backend.install(Application("2vcard", ""), iconname="")
     do_events_with_sleep()
示例#32
0
    def test_fake_aptd(self):
        from softwarecenter.backend.installbackend import get_install_backend

        backend = get_install_backend()
        backend.install(Application("2vcard", ""), iconname="")
        do_events_with_sleep()