Exemplo n.º 1
0
 def connect(self, tiger_id, private_key):
     sign = sign_with_rsa(private_key, tiger_id, 'utf-8')
     self.stomp_connection = stomp.Connection10(host_and_ports=[(self.host, self.port), ], use_ssl=self.use_ssl,
                                                keepalive=True)
     # self.stomp_connection.set_listener('stats', stomp.StatsListener())
     self.stomp_connection.set_listener('push', self)
     self.stomp_connection.start()
     self.stomp_connection.connect(tiger_id, sign, wait=True)
Exemplo n.º 2
0
    def __prepare_request(self, request):
        THREAD_LOCAL.logger = self.__logger
        params = request.get_params()
        params[P_TIMESTAMP] = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
        common_params = self.__get_common_params(params)
        all_params = dict()
        all_params.update(params)
        all_params.update(common_params)
        sign_content = get_sign_content(all_params)
        try:
            sign = sign_with_rsa(self.__config.private_key, sign_content, self.__config.charset)
        except Exception as e:
            raise RequestException('[' + THREAD_LOCAL.uuid + ']request sign failed. ' + str(e))
        all_params[P_SIGN] = sign

        log_url = self.__config.server_url + '?' + sign_content + "&sign=" + sign
        if THREAD_LOCAL.logger:
            THREAD_LOCAL.logger.debug('[' + THREAD_LOCAL.uuid + ']request:' + log_url)

        return all_params
Exemplo n.º 3
0
 def connect(self, tiger_id, private_key):
     self._tiger_id = tiger_id
     self._private_key = private_key
     self._sign = sign_with_rsa(self._private_key, self._tiger_id, 'utf-8')
     self._connect()