[Mod] 将RestClient和WebClient移动到api文件夹中,并修改import方式

This commit is contained in:
nanoric 2018-10-11 22:51:31 -04:00
parent a396b55f8e
commit 6e0e1c116b
11 changed files with 12 additions and 12 deletions

View File

@ -1,8 +1,7 @@
import unittest
# noinspection PyUnresolvedReferences
from tests.network.RestfulClientTest import *
from tests.network.WebSocketClientTest import *
from api.base import *
if __name__ == "__main__":
unittest.main()

View File

@ -6,7 +6,7 @@ import unittest
from simplejson import JSONDecodeError
from Promise import Promise
from vnpy.network.RestClient import RestClient, Request
from vnpy.api.rest.RestClient import RestClient, Request
class FailedError(RuntimeError):

View File

@ -1,9 +1,8 @@
# encoding: UTF-8
import json
import unittest
from Promise import Promise
from vnpy.network.WebSocketClient import WebsocketClient
from vnpy.api.websocket import WebsocketClient
class TestWebsocketClient(WebsocketClient):

View File

@ -3,7 +3,7 @@ from enum import Enum
from typing import Any, Callable, List, Union
from vnpy.api.okexfuture.vnokexFuture import OkexFutureRestBase
from vnpy.network.RestClient import Request
from vnpy.api.rest import Request
########################################################################

View File

@ -4,7 +4,7 @@ import urllib
########################################################################
from vnpy.network.RestClient import RestClient, Request
from vnpy.api.rest import RestClient, Request
########################################################################

View File

@ -0,0 +1 @@
from .RestClient import Request, RequestStatus, RestClient, requestsSessionProvider

View File

@ -9,7 +9,7 @@ import time
from abc import abstractmethod
from threading import Thread, Lock
import websocket
import vnpy.api.websocket
class WebsocketClient(object):
@ -57,12 +57,12 @@ class WebsocketClient(object):
#----------------------------------------------------------------------
def sendReq(self, req): # type: (dict)->None
"""发出请求"""
return self._get_ws().send(json.dumps(req), opcode=websocket.ABNF.OPCODE_TEXT)
return self._get_ws().send(json.dumps(req), opcode=vnpy.api.websocket.ABNF.OPCODE_TEXT)
#----------------------------------------------------------------------
def sendText(self, text): # type: (str)->None
"""发出请求"""
return self._get_ws().send(text, opcode=websocket.ABNF.OPCODE_TEXT)
return self._get_ws().send(text, opcode=vnpy.api.websocket.ABNF.OPCODE_TEXT)
#----------------------------------------------------------------------
def sendData(self, data): # type: (bytes)->None
@ -78,7 +78,7 @@ class WebsocketClient(object):
#----------------------------------------------------------------------
def _connect(self):
""""""
self._ws = websocket.create_connection(self.host, sslopt={'cert_reqs': ssl.CERT_NONE})
self._ws = vnpy.api.websocket.create_connection(self.host, sslopt={'cert_reqs': ssl.CERT_NONE})
self.onConnect()
#----------------------------------------------------------------------
@ -125,7 +125,7 @@ class WebsocketClient(object):
#----------------------------------------------------------------------
def _ping(self):
return self._get_ws().send('ping', websocket.ABNF.OPCODE_PING)
return self._get_ws().send('ping', vnpy.api.websocket.ABNF.OPCODE_PING)
#----------------------------------------------------------------------
@abstractmethod

View File

@ -0,0 +1 @@
from .WebSocketClient import WebsocketClient