zoukankan      html  css  js  c++  java
  • Python3调用hessian

    领导派了个任务,实现服务器日志文件调用hessian接口保存到数据库

    研究了半天python调用hessian的办法

    首先使用hessian for python的链接:

    http://hessian.caucho.com/#Python

    引入进来后各种报错,各种崩溃啊

    hessianlib.py在官网上还是2007的版本,估计不支持python3??

    然后寻找python3调用hessian的资料,关于python2转换成3的语法,使用:

    2to3.py在python目录:C:PythonToolsScripts2to3.py

    python 2to3.py -w hessianlib.py

    运行后,转换部分不成功,后来还是放弃了这个想法

    后来上谷歌一直寻找方案,最终在不断地研究下找到了突破口,原来关于hessian的python实现,已经转交给mustaine项目来处理,并且给出了google code地址:http://code.google.com/p/mustaine/

    接下来安装pyhessian和six

    pyhessian下载:http://code.google.com/p/mustaine/

    six下载:https://pypi.python.org/pypi/six

    下载后使用命令安装:

    python C:UsersAdminDesktoppython-hessian-mastersetup.py install

    python C:UsersAdminDesktopsix-1.9.0setup.py install

    安装后six没问题了,可pyhessian还需要把目录python-hessian-masterpyhessian复制到C:PythonLibsite-packagespyhessian

    引用pyhessian:

    from pyhessian.client import HessianProxy

    测试pyhessian成功:

    params = {"p1":"101", "p2":"102"}

    service = HessianProxy("http://192.168.1.1:8080/test/services/test.hessian")

    result = service.test(params)

    print(result.value)

  • 相关阅读:
    python3.x 基础五:模块
    python3.x 基础四:目录获取及目录规范
    python3.x 基础四:json与pickple
    python3.x 基础四:生成器与迭代器
    python3.x 基础三:装饰器
    python3.x 基础三:函数
    [leetcode]Anagrams
    [leetcode]Text Justification
    [leetcode]Single Number
    [leetcode]Longest Palindromic Substring
  • 原文地址:https://www.cnblogs.com/java-stack/p/11952664.html
Copyright © 2011-2022 走看看