当前位置: 首页>>代码示例>>Python>>正文


Python websocket.enableTrace方法代码示例

本文整理汇总了Python中websocket.enableTrace方法的典型用法代码示例。如果您正苦于以下问题:Python websocket.enableTrace方法的具体用法?Python websocket.enableTrace怎么用?Python websocket.enableTrace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在websocket的用法示例。


在下文中一共展示了websocket.enableTrace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: connect

# 需要导入模块: import websocket [as 别名]
# 或者: from websocket import enableTrace [as 别名]
def connect(self, apiKey, secretKey, trace=False):
        self.host = OKEX_USD_CONTRACT
        self.apiKey = apiKey
        self.secretKey = secretKey
        self.trace = trace

        websocket.enableTrace(trace)

        self.ws = websocket.WebSocketApp(self.host,
                                         on_message=self.onMessage,
                                         on_error=self.onError,
                                         on_close=self.onClose,
                                         on_open=self.onOpen)

        self.thread = Thread(target=self.ws.run_forever, args=(None, None, 60, 30))
        self.thread.start()

    # ---------------------------------------------------------------------- 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:20,代码来源:vnokex.py

示例2: run_subscription_batch_jobs

# 需要导入模块: import websocket [as 别名]
# 或者: from websocket import enableTrace [as 别名]
def run_subscription_batch_jobs(self):
        """
        请求 KLine 实时数据
        """
        websocket.enableTrace(False)
        self.__ws = websocket.WebSocketApp(
            self.HUOBIPRO_WEBSOCKET_URL,
            on_message=self.on_message,
            on_open=self.on_open,
            on_error=self.on_error,
            on_close=self.on_close
        )
        self.__locked = True

        # 如果意外退出,等待10秒重新运行
        while (True):
            self.__ws.run_forever()
            QA_util_log_expection("FTW! it quit! Retry 10 seconds later...")
            time.sleep(10) 
开发者ID:QUANTAXIS,项目名称:QUANTAXIS,代码行数:21,代码来源:QAhuobi_realtime.py

示例3: connect_Subpot

# 需要导入模块: import websocket [as 别名]
# 或者: from websocket import enableTrace [as 别名]
def connect_Subpot(self, apiKey , secretKey , trace = False):
        self.host = GATEIO_SOCKET_URL
        self.apiKey = apiKey
        self.secretKey = secretKey
        self.trace = trace

        websocket.enableTrace(trace)

        self.ws = websocket.WebSocketApp(self.host, 
                                             on_message=self.onMessage,
                                             on_error=self.onError,
                                             on_close=self.onClose,
                                             on_open=self.onOpen)        
            
        self.thread = Thread(target = self.ws.run_forever , args = (None , None , 60, 30))
        # self.thread_heart = Thread(target = self.run_forever_heart)

        self.thread.start()
        # self.thread_heart.start()

    #---------------------------------------------------------------------- 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:23,代码来源:vngateio_ws.py

示例4: _websocketThread

# 需要导入模块: import websocket [as 别名]
# 或者: from websocket import enableTrace [as 别名]
def _websocketThread(self, evtThreadEnded):
        try:
            websocket.enableTrace(False)
            self._ws = websocket.WebSocketApp(self._REST_URLS['websocket'] + self.access_token,
                                              on_open=self._on_open,
                                              on_message=self._on_message,
                                              on_close=self._on_close,
                                              on_error=self._on_error)

            # ping_timeout is for no blocking call
            self._ws.run_forever(ping_interval=self.ping_timeout/2, ping_timeout=self.ping_timeout)

        except AttributeError:
            self._on_error(websocket, 'No internet connection!')
        except Exception as ex:
            self._on_error(websocket, ex)
        finally:
            evtThreadEnded.set() 
开发者ID:elbowz,项目名称:xbmc.service.pushbullet,代码行数:20,代码来源:pushbullet.py

示例5: connect

# 需要导入模块: import websocket [as 别名]
# 或者: from websocket import enableTrace [as 别名]
def connect(self, host, apiKey, secretKey, trace=False):
        """连接服务器"""
        self.host = host
        self.apiKey = apiKey
        self.secretKey = secretKey
        
        if self.host == OKCOIN_CNY:
            self.currency = CURRENCY_CNY
        else:
            self.currency = CURRENCY_USD
            
        websocket.enableTrace(trace)
        
        self.ws = websocket.WebSocketApp(host, 
                                         on_message=self.onMessage,
                                         on_error=self.onError,
                                         on_close=self.onClose,
                                         on_open=self.onOpen)        
        
        self.thread = Thread(target=self.ws.run_forever)
        self.thread.start()
        
    #---------------------------------------------------------------------- 
开发者ID:sunshinelover,项目名称:chanlun,代码行数:25,代码来源:vnokcoin.py

示例6: connect

# 需要导入模块: import websocket [as 别名]
# 或者: from websocket import enableTrace [as 别名]
def connect(self):
        self.logger.info("connect ws")
        websocket.enableTrace(True)
        self.ws = websocket.WebSocketApp("wss://www.deribit.com/ws/api/v1/",
                                  on_message = lambda ws,msg: self.on_message(ws, msg),
                                  on_error   = lambda ws,msg: self.on_error(ws, msg),
                                  on_open    = lambda ws:  self.on_open(ws),
                                  #on_open = self.on_open,                                  
                                  on_close = self.on_close)
        ssl_defaults = ssl.get_default_verify_paths()
        sslopt_ca_certs = {'ca_certs': ssl_defaults.cafile}
        self.wst = threading.Thread(target=lambda: self.ws.run_forever(sslopt=sslopt_ca_certs))
        self.wst.daemon = True
        self.wst.start()
        self.logger.info("Started thread")
        #TOOD subscribe later
        #self.ws.run_forever() 
开发者ID:economicnetwork,项目名称:archon,代码行数:19,代码来源:deribit_ws.py

示例7: main

# 需要导入模块: import websocket [as 别名]
# 或者: from websocket import enableTrace [as 别名]
def main():
    # Connect to websocket interfaces
    headers = {}
    userpass = ":".join(get_auth())
    headers["Authorization"] = "Basic " + base64.b64encode(
        userpass.encode()).decode()
    url = get_url()

    # If you really want to see everything going across the wire,
    # uncomment this. However realize the trace is going to also do
    # things like dump the binary sound packets in text in the
    # console.
    #
    # websocket.enableTrace(True)
    ws = websocket.WebSocketApp(url,
                                header=headers,
                                on_message=on_message,
                                on_error=on_error,
                                on_close=on_close)
    ws.on_open = on_open
    ws.args = parse_args()
    # This gives control over the WebSocketApp. This is a blocking
    # call, so it won't return until the ws.close() gets called (after
    # 6 seconds in the dedicated thread).
    ws.run_forever() 
开发者ID:IBM,项目名称:watson-streaming-stt,代码行数:27,代码来源:transcribe.py

示例8: _init_publisher_ws

# 需要导入模块: import websocket [as 别名]
# 或者: from websocket import enableTrace [as 别名]
def _init_publisher_ws(self):
        """
        Create a new web socket connection with proper headers.
        """
        logging.debug("Initializing new web socket connection.")

        url = ('wss://%s/v1/stream/messages/' % self.eventhub_client.host)

        headers = self._generate_publish_headers()

        logging.debug("URL=" + str(url))
        logging.debug("HEADERS=" + str(headers))

        websocket.enableTrace(False)
        self._ws = websocket.WebSocketApp(url,
                                          header=headers,
                                          on_message=self._on_ws_message,
                                          on_open=self._on_ws_open,
                                          on_close=self._on_ws_close)
        self._ws_thread = threading.Thread(target=self._ws.run_forever, kwargs={'ping_interval': 30})
        self._ws_thread.daemon = True
        self._ws_thread.start()
        time.sleep(1) 
开发者ID:PredixDev,项目名称:predixpy,代码行数:25,代码来源:publisher.py

示例9: __init__

# 需要导入模块: import websocket [as 别名]
# 或者: from websocket import enableTrace [as 别名]
def __init__(self, url, password):
        super().__init__()

        self._url = url
        self._password = password

        import websocket

        websocket.enableTrace(True)
        self._ws = websocket.WebSocket(skip_utf8_validation=True)
        self._ws.settimeout(10)
        self._ws.connect(self._url, timeout=5)
        prompt = self._ws.recv()
        if prompt != "Password: ":
            raise RuntimeError("Expected password prompt, got %r" % prompt)
        self._ws.send(self._password + "\r\n")

        self._reading_thread = threading.Thread(target=self._keep_reading, daemon=True)
        self._reading_thread.start() 
开发者ID:thonny,项目名称:thonny,代码行数:21,代码来源:webrepl_connection.py

示例10: receiveMsg_Start_Websocket

# 需要导入模块: import websocket [as 别名]
# 或者: from websocket import enableTrace [as 别名]
def receiveMsg_Start_Websocket(self, m, sender):
        if self.started: # already started
            return
        self.config = m
        self.started = True
        self.running = True

        # open the connection
        websocket.enableTrace(False)
        self.ws = websocket.create_connection(m.ws_addr)
        log.info("Websocket Connected")

        # set up the socket monitoring
        self.epoll = select.epoll()
        mask = select.EPOLLIN | select.EPOLLHUP | select.EPOLLERR
        self.epoll.register(self.ws.sock.fileno(), mask)

        # subscribe to the feed
        self.ws.send(m.start_msg)

        # start checking for data
        self.send(self.myAddress, WakeupMessage(None)) 
开发者ID:thespianpy,项目名称:Thespian,代码行数:24,代码来源:websocket.py

示例11: __init__

# 需要导入模块: import websocket [as 别名]
# 或者: from websocket import enableTrace [as 别名]
def __init__(self, logger, symbols, channels, URL, api_key, api_secret):
        self.logger = logger
        self.symbols = symbols
        self.channels = channels
        self.URL = URL
        if api_key is not None and api_secret is None:
            raise ValueError('Enter both public and secret keys')
        if api_key is None and api_secret is not None:
            raise ValueError('Enter both public and secret API keys')
        self.api_key = api_key
        self.api_secret = api_secret
        self.data = {}
        self.keys = {}
        # websocket.enableTrace(True)

        # Data table size - approcimate tick/min capacity per symbol.
        self.MAX_SIZE = 15000 * len(symbols)
        self.RECONNECT_TIMEOUT = 10

        self.connect() 
开发者ID:s-brez,项目名称:trading-server,代码行数:22,代码来源:bitmex_ws.py

示例12: __init__

# 需要导入模块: import websocket [as 别名]
# 或者: from websocket import enableTrace [as 别名]
def __init__(self, url, token, on_server_ws_msg):
        #websocket.enableTrace(True)

        def on_message(ws, msg):
            on_server_ws_msg(ws, msg)

        def on_error(ws, error):
            print(error)

        self.ws = websocket.WebSocketApp(url,
                                  on_message = on_message,
                                  on_error = on_error,
                                  header = ["Authorization: Bearer " + token],
                                  subprotocols=["binary", "base64"]) 
开发者ID:kennethjiang,项目名称:OctoPrint-Anywhere,代码行数:16,代码来源:server_ws.py

示例13: _listen

# 需要导入模块: import websocket [as 别名]
# 或者: from websocket import enableTrace [as 别名]
def _listen(self):
        self.sock.listen(100)
        index = 0
        basic_auth_string = self.create_basic_auth()
        while True:
            self.client, _address = self.sock.accept()
            self.client.settimeout(1800)
            host = 'wss://{}{}'.format(self.remote_addr, '.scm.azurewebsites.net/AppServiceTunnel/Tunnel.ashx')
            basic_auth_header = 'Authorization: Basic {}'.format(basic_auth_string)
            cli_logger = get_logger()  # get CLI logger which has the level set through command lines
            is_verbose = any(handler.level <= logs.INFO for handler in cli_logger.handlers)
            if is_verbose:
                logger.info('Websocket tracing enabled')
                websocket.enableTrace(True)
            else:
                logger.warning('Websocket tracing disabled, use --verbose flag to enable')
                websocket.enableTrace(False)
            self.ws = create_connection(host,
                                        sockopt=((socket.IPPROTO_TCP, socket.TCP_NODELAY, 1),),
                                        class_=TunnelWebSocket,
                                        header=[basic_auth_header],
                                        sslopt={'cert_reqs': ssl.CERT_NONE},
                                        enable_multithread=True)
            logger.info('Websocket, connected status: %s', self.ws.connected)
            index = index + 1
            logger.info('Got debugger connection... index: %s', index)
            debugger_thread = Thread(target=self._listen_to_client, args=(self.client, self.ws, index))
            web_socket_thread = Thread(target=self._listen_to_web_socket, args=(self.client, self.ws, index))
            debugger_thread.start()
            web_socket_thread.start()
            logger.info('Both debugger and websocket threads started...')
            logger.warning('Successfully connected to local server..')
            debugger_thread.join()
            web_socket_thread.join()
            logger.info('Both debugger and websocket threads stopped...')
            logger.warning('Stopped local server..') 
开发者ID:Azure,项目名称:azure-cli-extensions,代码行数:38,代码来源:tunnel.py

示例14: setUp

# 需要导入模块: import websocket [as 别名]
# 或者: from websocket import enableTrace [as 别名]
def setUp(self):
        ws.enableTrace(TRACEABLE) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:4,代码来源:test_websocket.py

示例15: __init__

# 需要导入模块: import websocket [as 别名]
# 或者: from websocket import enableTrace [as 别名]
def __init__(self, ip, password):

        ConBase.__init__(self)
        threading.Thread.__init__(self)

        self.daemon = True

        self.fifo = deque()
        self.fifo_lock = threading.Lock()

        # websocket.enableTrace(logging.root.getEffectiveLevel() < logging.INFO)
        self.ws = websocket.WebSocketApp(
            "ws://%s:8266" % ip,
            on_message=self.on_message,
            on_error=self.on_error,
            on_close=self.on_close,
        )

        self.start()

        self.timeout = 5.0

        if b"Password:" in self.read(10, blocking=False):
            self.ws.send(password + "\r")
            if b"WebREPL connected" not in self.read(25, blocking=False):
                raise ConError()
        else:
            raise ConError()

        self.timeout = 1.0

        logging.info("websocket connected to ws://%s:8266" % ip) 
开发者ID:wendlers,项目名称:mpfshell,代码行数:34,代码来源:conwebsock.py


注:本文中的websocket.enableTrace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。