Giter VIP home page Giter VIP logo

dubbo-telnet-py's Introduction

Dubbo Telnet Client of python

通过telnet调用Dubbo接口, 可用来做Dubbo的自动化测试。

兼容性测试

  • Python 2.6.6
  • Python 2.7.10
  • Python 3.4.3

安装

  • easyinstall安装
easy_install dubbo_telnet
  • pip安装
pip install --upgrade dubbo_telnet
  • git安装
pip install --upgrade git+https://github.com/WALL-E/dubbo-telnet-py.git

Example

    import dubbo_telnet

    Host = '192.168.1.203'  # Doubble服务器IP
    Port = 28008  # Doubble服务端口

    # 初始化dubbo对象
    conn = dubbo_telnet.connect(Host, Port)

    # 设置telnet连接超时时间
    conn.set_connect_timeout(10)

    # 设置dubbo服务返回响应的编码
    conn.set_encoding('gbk')

    interface = 'com.zrj.pay.trade.api.QueryTradeService'
    method = 'tradeDetailQuery'
    param = '{"id": 1}'
    print conn.invoke(interface, method, param)

    command = 'invoke com.zrj.pay.trade.api.QueryTradeService.tradeDetailQuery({"id":1})'
    print conn.do(command)

Dubbo Telnet命令

Dubbo2.0.5以上版本服务提供端口支持telnet命令,使用如下

telnet localhost 20880

或者

echo status | nc -i 1 localhost 20880

详见Dubbo官方文档Telnet命令参考手册

Todo

  • 使用pexpect替换telnetlib

dubbo-telnet-py's People

Contributors

wall-e avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

dubbo-telnet-py's Issues

TypeError: 'in <string>' requires string as left operand, not bytes

Traceback (most recent call last):
File "<pyshell#1>", line 1, in
print(conn.invoke(interface, method, param.encode('ascii')))
File "D:\Program Files\Python36\lib\site-packages\dubbo_telnet-1.0.1b3-py3.6.egg\dubbo_telnet_init_.py", line 84, in invoke
return self.do(cmd)
File "D:\Program Files\Python36\lib\site-packages\dubbo_telnet-1.0.1b3-py3.6.egg\dubbo_telnet_init_.py", line 65, in do
tn.write('\n')
File "D:\Program Files\Python36\lib\telnetlib.py", line 287, in write
if IAC in buffer:
TypeError: 'in ' requires string as left operand, not bytes

那个好像是因为python版本不对 可是我改了2.7版本 服务端java接收不到参数怎么办、用的你们的example

-- coding: utf-8 --

代码、、java端没有参数接收到
import dubbo_telnet

if name == 'main':
Host = '127.0.0.1' # Doubble服务器IP
Port = 30885 # Doubble服务端口

# 初始化dubbo对象
conn = dubbo_telnet.connect(Host, Port)

# 设置telnet连接超时时间
conn.set_connect_timeout(10)

# 设置dubbo服务返回响应的编码
conn.set_encoding('gbk')

# interface = 'com.hqjl.scheduler.classcard.IScheduleClassCardService'
# method = 'getTeachingClassStudent',
# param = '{"schoolID": "1153"}'
# print (conn.invoke(interface, method, param))

command = 'invoke com.hqjl.scheduler.classcard.IScheduleClassCardService.getTeachingClassStudent({"schoolID":1153})'
print (conn.do(command))

Python 3.7 安装编码问题

Python 3.7 安装时出现
File "C:\Users\huangpo\AppData\Local\Temp\pycharm-packaging\dubbo-telnet\setup.py", line 24, in
long_description=open("README.PYPI").read(),
UnicodeDecodeError: 'gbk' codec can't decode byte 0xaf in position 163: illegal multibyte sequence

##############################################################################
修改 setup.py 为
long_description=open("README.PYPI", encoding='utf-8').read()
后可以正常安装. 随后使用 Python 2.7 未出现此问题, 建议加入版本判断或统一使用 utf-8 编码.

你好有个问题请教一下

我是用python调用java的dubbo服务 把你的文件复制到我的site-package下,调用时出现如下问题
Traceback (most recent call last):
File "D:/classadmin/生涯探索/careerserv/example/tests.py", line 19, in
print (conn.invoke(interface, method, param))
File "D:\python\venv\lib\site-packages\dubbo_telnet_init_.py", line 84, in invoke
return self.do(cmd)
File "D:\python\venv\lib\site-packages\dubbo_telnet_init_.py", line 65, in do
tn.write('\n')
File "C:\Users\asdf\AppData\Local\Programs\Python\Python36\Lib\telnetlib.py", line 287, in write
if IAC in buffer:
TypeError: 'in ' requires string as left operand, not bytes
我的代码
import dubbo_telnet

if name == 'main':
Host = '127.0.0.1' # Doubble服务器IP
Port = 30885 # Doubble服务端口

# 初始化dubbo对象
conn = dubbo_telnet.connect(Host, Port)

# 设置telnet连接超时时间
conn.set_connect_timeout(10)

# 设置dubbo服务返回响应的编码
conn.set_encoding('utf-8')

interface = 'com.hqjl.scheduler.classcard.IScheduleClassCardService'
method = 'getAdminClasses',
param = '{"schoolID": "1153"}'
print (conn.invoke(interface, method, param))

# command = 'invoke com.zrj.pay.trade.api.QueryTradeService.tradeDetailQuery({"id":"nimeide"})'
# print (conn.do(command))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.