示例#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)
示例#2
0
 def test_get_recommender_uuid(self):
     uuid = get_recommender_uuid()
     self.assertTrue("-" not in uuid and len(uuid) > 0)
示例#3
0
 def test_get_recommender_uuid(self):
     uuid = get_recommender_uuid()
     self.assertTrue("-" not in uuid and len(uuid) > 0)