Exemple #1
0
    def _download_config(self):
        """
        Download the Soledad config for the given provider
        """
        leap_assert(self._provider_config, "We need a provider configuration!")
        logger.debug("Downloading Soledad config for %s" %
                     (self._provider_config.get_domain(), ))

        self._soledad_config = SoledadConfig()
        download_service_config(self._provider_config, self._soledad_config,
                                self._session, self._download_if_needed)
    def _pick_server(self, uuid):
        """
        Choose a soledad server to sync against.

        :param uuid: the uuid for the user.
        :type uuid: unicode
        :returns: the server url
        :rtype: unicode
        """
        if not self._soledad_config:
            self._soledad_config = SoledadConfig()

        # TODO: Select server based on timezone (issue #3308)
        server_dict = self._soledad_config.get_hosts()

        if not server_dict.keys():
            # XXX raise more specific exception, and catch it properly!
            raise Exception("No soledad server found")

        selected_server = server_dict[first(server_dict.keys())]
        server_url = "https://%s:%s/user-%s" % (selected_server["hostname"],
                                                selected_server["port"], uuid)
        logger.debug("Using soledad server url: %s" % (server_url, ))
        return server_url