當前位置: 首頁>>代碼示例>>Python>>正文


Python RecommenderAgent.connect方法代碼示例

本文整理匯總了Python中softwarecenter.backend.recagent.RecommenderAgent.connect方法的典型用法代碼示例。如果您正苦於以下問題:Python RecommenderAgent.connect方法的具體用法?Python RecommenderAgent.connect怎麽用?Python RecommenderAgent.connect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在softwarecenter.backend.recagent.RecommenderAgent的用法示例。


在下文中一共展示了RecommenderAgent.connect方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: disabled_test_recagent_query_profile

# 需要導入模塊: from softwarecenter.backend.recagent import RecommenderAgent [as 別名]
# 或者: from softwarecenter.backend.recagent.RecommenderAgent import connect [as 別名]
 def disabled_test_recagent_query_profile(self):
     # NOTE: This requires a working recommender host that is reachable
     recommender_agent = RecommenderAgent()
     recommender_agent.connect("profile", self.on_query_done)
     recommender_agent.connect("error", self.on_query_error)
     recommender_agent.query_profile(pkgnames=["pitivi", "fretsonfire"])
     self.loop.run()
     self.assertFalse(self.error)
開發者ID:cs2c,項目名稱:AppStream,代碼行數:10,代碼來源:test_recagent.py

示例2: test_recagent_query_server_status

# 需要導入模塊: from softwarecenter.backend.recagent import RecommenderAgent [as 別名]
# 或者: from softwarecenter.backend.recagent.RecommenderAgent import connect [as 別名]
 def test_recagent_query_server_status(self):
     # NOTE: This requires a working recommender host that is reachable
     recommender_agent = RecommenderAgent()
     recommender_agent.connect("server-status", self.on_query_done)
     recommender_agent.connect("error", self.on_query_error)
     recommender_agent.query_server_status()
     self.loop.run()
     self.assertFalse(self.error)
開發者ID:cs2c,項目名稱:AppStream,代碼行數:10,代碼來源:test_recagent.py

示例3: test_recagent_query_recommend_app

# 需要導入模塊: from softwarecenter.backend.recagent import RecommenderAgent [as 別名]
# 或者: from softwarecenter.backend.recagent.RecommenderAgent import connect [as 別名]
 def test_recagent_query_recommend_app(self):
     # NOTE: This requires a working recommender host that is reachable
     recommender_agent = RecommenderAgent()
     recommender_agent.connect("recommend-app", self.on_query_done)
     recommender_agent.connect("error", self.on_query_error)
     recommender_agent.query_recommend_app("pitivi")
     self.loop.run()
     self.assertFalse(self.error)
開發者ID:cs2c,項目名稱:AppStream,代碼行數:10,代碼來源:test_recagent.py

示例4: disabled_test_recagent_post_submit_profile

# 需要導入模塊: from softwarecenter.backend.recagent import RecommenderAgent [as 別名]
# 或者: from softwarecenter.backend.recagent.RecommenderAgent import connect [as 別名]
 def disabled_test_recagent_post_submit_profile(self):
     # NOTE: This requires a working recommender host that is reachable
     recommender_agent = RecommenderAgent()
     recommender_agent.connect("submit-profile-finished", self.on_query_done)
     recommender_agent.connect("error", self.on_query_error)
     db = get_test_db()
     recommender_agent.post_submit_profile(db)
     self.loop.run()
     self.assertFalse(self.error)
開發者ID:cs2c,項目名稱:AppStream,代碼行數:11,代碼來源:test_recagent.py

示例5: RecommendedForYouCategory

# 需要導入模塊: from softwarecenter.backend.recagent import RecommenderAgent [as 別名]
# 或者: from softwarecenter.backend.recagent.RecommenderAgent import connect [as 別名]
class RecommendedForYouCategory(Category):

    __gsignals__ = {
        "needs-refresh": (GObject.SIGNAL_RUN_LAST,
                          GObject.TYPE_NONE,
                          (),
                          ),
        "recommender-agent-error": (GObject.SIGNAL_RUN_LAST,
                                    GObject.TYPE_NONE,
                                    (GObject.TYPE_STRING,),
                                    ),
    }

    def __init__(self, db, subcategory=None):
        self.db = db
        self.subcategory = subcategory
        if subcategory:
            # this is the set of recommendations for a given subcategory
            cat_title = u"Recommended For You in %s" % (
                subcategory.untranslated_name)
            tr_title = utf8(_("Recommended For You in %s")) % utf8(
                subcategory.name)
        else:
            # this is the full set of recommendations for e.g. the lobby view
            cat_title = u"Recommended For You"
            tr_title = _("Recommended For You")
        super(RecommendedForYouCategory, self).__init__(
                cat_title,
                tr_title,
                None,
                xapian.Query(),
                flags=['available-only', 'not-installed-only'],
                item_limit=60)
        self.recommender_agent = RecommenderAgent()
        self.recommender_agent.connect(
            "recommend-me", self._recommend_me_result)
        self.recommender_agent.connect(
            "error", self._recommender_agent_error)
        self.recommender_agent.query_recommend_me()

    def _recommend_me_result(self, recommender_agent, result_list):
        pkgs = []
        for item in result_list['data']:
            pkgs.append(item['package_name'])
        if self.subcategory:
            self.query = xapian.Query(xapian.Query.OP_AND,
                                  self.db.get_query_for_pkgnames(pkgs),
                                  self.subcategory.query)
        else:
            self.query = self.db.get_query_for_pkgnames(pkgs)
        self.emit("needs-refresh")

    def _recommender_agent_error(self, recommender_agent, msg):
        LOG.warn("Error while accessing the recommender service: %s"
                                                            % msg)
        self.emit("recommender-agent-error", msg)
開發者ID:pombredanne,項目名稱:shop,代碼行數:58,代碼來源:categories.py

示例6: test_recagent_query_error

# 需要導入模塊: from softwarecenter.backend.recagent import RecommenderAgent [as 別名]
# 或者: from softwarecenter.backend.recagent.RecommenderAgent import connect [as 別名]
 def test_recagent_query_error(self):
     # NOTE: This tests the error condition itself! it simply forces an error
     #       'cuz there definitely isn't a server here  :)
     os.environ["SOFTWARE_CENTER_RECOMMENDER_HOST"] = "https://test-no-server-here.staging.ubuntu.com"
     recommender_agent = RecommenderAgent()
     recommender_agent.connect("recommend-top", self.on_query_done)
     recommender_agent.connect("error", self.on_query_error)
     recommender_agent.query_recommend_top()
     self.loop.run()
     self.assertTrue(self.error)
開發者ID:cs2c,項目名稱:AppStream,代碼行數:12,代碼來源:test_recagent.py

示例7: test_mocked_recagent_post_submit_profile

# 需要導入模塊: from softwarecenter.backend.recagent import RecommenderAgent [as 別名]
# 或者: from softwarecenter.backend.recagent.RecommenderAgent import connect [as 別名]
 def test_mocked_recagent_post_submit_profile(self, mock_spawn_helper_run):
     def _patched_on_submit_profile_data(*args, **kwargs):
         piston_submit_profile = {}
         recommender_agent.emit("submit-profile-finished", 
                                piston_submit_profile)
     mock_spawn_helper_run.side_effect = _patched_on_submit_profile_data
     recommender_agent = RecommenderAgent()
     recommender_agent.connect("submit-profile-finished", self.on_query_done)
     recommender_agent.connect("error", self.on_query_error)
     recommender_agent._calc_profile_id = lambda profile: "i-am-random"
     db = get_test_db()
     recommender_agent.post_submit_profile(db)
     self.assertFalse(self.error)
     args, kwargs =  mock_spawn_helper_run.call_args
     self.assertNotEqual(kwargs['data'][0]['package_list'], [])
開發者ID:feiying,項目名稱:AppStream,代碼行數:17,代碼來源:test_recagent.py

示例8: AppRecommendationsCategory

# 需要導入模塊: from softwarecenter.backend.recagent import RecommenderAgent [as 別名]
# 或者: from softwarecenter.backend.recagent.RecommenderAgent import connect [as 別名]
class AppRecommendationsCategory(Category):

    __gsignals__ = {
        "needs-refresh": (GObject.SIGNAL_RUN_LAST,
                          GObject.TYPE_NONE,
                          (),
                          ),
        "recommender-agent-error": (GObject.SIGNAL_RUN_LAST,
                                    GObject.TYPE_NONE,
                                    (GObject.TYPE_STRING,),
                                    ),
    }

    def __init__(self, db, pkgname):
        super(AppRecommendationsCategory, self).__init__(
            u"People Also Installed",
            _(u"People Also Installed"),
            None,
            xapian.Query(),
            flags=['available-only', 'not-installed-only'],
            item_limit=4)
        self.db = db
        self.recommender_agent = RecommenderAgent()
        self.recommender_agent.connect(
            "recommend-app", self._recommend_app_result)
        self.recommender_agent.connect(
            "error", self._recommender_agent_error)
        self.recommender_agent.query_recommend_app(pkgname)

    def _recommend_app_result(self, recommender_agent, result_list):
        pkgs = []
        for item in result_list['data']:
            pkgs.append(item['package_name'])
        self.query = self.db.get_query_for_pkgnames(pkgs)
        self.emit("needs-refresh")

    def _recommender_agent_error(self, recommender_agent, msg):
        LOG.warn("Error while accessing the recommender service: %s"
                                                            % msg)
        self.emit("recommender-agent-error", msg)
開發者ID:pombredanne,項目名稱:shop,代碼行數:42,代碼來源:categories.py


注:本文中的softwarecenter.backend.recagent.RecommenderAgent.connect方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。