예제 #1
0
    def post_submit_profile(self, db):
        """ This will post the user's profile to the recommender server
            and also generate the UUID for the user if that is not
            there yet
        """
        recommender_uuid = self.recommender_uuid
        if not recommender_uuid:
            # generate a new uuid, but do not save it yet, this will
            # be done later in _on_submit_profile_data
            recommender_uuid = get_recommender_uuid()
        installed_pkglist = [app.pkgname
                             for app in get_installed_apps_list(db)]
        profile = self._generate_submit_profile_data(recommender_uuid,
                                                     installed_pkglist)

        # compare profiles to see if there has been a change, and if there
        # has, do the profile update
        current_recommender_profile_id = self._calc_profile_id(profile)
        if current_recommender_profile_id != self.recommender_profile_id:
            LOG.info("Submitting recommendations profile to the server")
            self._set_recommender_profile_id(current_recommender_profile_id)
            # build the command and upload the profile
            spawner = SpawnHelper()
            spawner.parent_xid = self.xid
            spawner.needs_auth = True
            spawner.connect("data-available", self._on_submit_profile_data,
                            recommender_uuid)
            spawner.connect(
                "error", lambda spawner, err: self.emit("error", err))
            spawner.run_generic_piston_helper(
                "SoftwareCenterRecommenderAPI",
                "submit_profile",
                data=profile)
 def test_utils_get_installed_apps_list(self):
     db = get_test_db()
     # installed pkgs
     installed_pkgs = get_installed_package_list()
     # the installed apps
     installed_apps = get_installed_apps_list(db)
     self.assertTrue(len(installed_apps) > 0)
     self.assertTrue(len(installed_pkgs) > len(installed_apps))
 def test_utils_get_installed_apps_list(self):
     db = get_test_db()
     # installed pkgs
     installed_pkgs = get_installed_package_list()
     # the installed apps
     installed_apps = get_installed_apps_list(db)
     self.assertTrue(len(installed_apps) > 0)
     self.assertTrue(len(installed_pkgs) > len(installed_apps))
예제 #4
0
    def test_utils_get_installed_apps_list(self):
        from softwarecenter.db.utils import get_installed_package_list, get_installed_apps_list

        db = get_test_db()
        # installed pkgs
        installed_pkgs = get_installed_package_list()
        # the installed apps
        installed_apps = get_installed_apps_list(db)
        self.assertTrue(len(installed_apps) > 0)
        self.assertTrue(len(installed_pkgs) > len(installed_apps))
 def test_utils_get_installed_apps_list(self):
     from softwarecenter.db.utils import (get_installed_package_list,
                                          get_installed_apps_list)
     db = get_test_db()
     # installed pkgs
     installed_pkgs = get_installed_package_list()
     # the installed apps
     installed_apps = get_installed_apps_list(db)
     self.assertTrue(len(installed_apps) > 0)
     self.assertTrue(len(installed_pkgs) > len(installed_apps))
예제 #6
0
 def post_submit_profile(self, db):
     """ This will post the users profile to the recommender server
         and also generate the UUID for the user if that is not 
         there yet
     """
     # if we have not already set a recommender UUID, now is the time
     # to do it
     if not self.recommender_uuid:
         self.recommender_uuid = get_uuid()
     installed_pkglist = [app.pkgname for app in get_installed_apps_list(db)]
     data = self._generate_submit_profile_data(self.recommender_uuid, installed_pkglist)
     # build the command
     spawner = SpawnHelper()
     spawner.parent_xid = self.xid
     spawner.needs_auth = True
     spawner.connect("data-available", self._on_submit_profile_data)
     spawner.connect("error", lambda spawner, err: self.emit("error", err))
     spawner.run_generic_piston_helper("SoftwareCenterRecommenderAPI", "submit_profile", data=data)