运行 aria2 官方的 xmlrpc 实例报错。 - V2EX
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
toaoman

运行 aria2 官方的 xmlrpc 实例报错。

  •  
  •   toaoman Jan 26, 2015 5179 views
    This topic created in 4124 days ago, the information mentioned may be changed or developed.
    刚刚开始接触python,对于通过xml-rpc远程过程调用来控制aria2下载文件很感兴趣。刚好看到aria2的网络手册上有这么一段程序的实例,就在python2.7中运行了一下。(aria2的启动参数为: aria2c --enable-rpc --rpc-listen-all=true --rpc-allow-origin-all -c )

    http://img.bbs.csdn.net/upload/201501/26/1422260883_325696.jpg

    import xmlrpclib
    s = xmlrpclib.ServerProxy('http://localhost:6800/rpc')
    s.aria2.addTorrent(xmlrpclib.Binary(open('file.torrent').read()))

    程序运行后报错信息如下:
    http://img.bbs.csdn.net/upload/201501/26/1422261594_631892.jpg

    Traceback (most recent call last):
    File "C:\test.py", line 3, in <module>
    s.aria2.addTorrent(xmlrpclib.Binary(open('file.torrent').read()))
    File "C:\Python27\lib\xmlrpclib.py", line 1224, in __call__
    return self.__send(self.__name, args)
    File "C:\Python27\lib\xmlrpclib.py", line 1570, in __request
    verbose=self.__verbose
    File "C:\Python27\lib\xmlrpclib.py", line 1264, in request
    return self.single_request(host, handler, request_body, verbose)
    File "C:\Python27\lib\xmlrpclib.py", line 1297, in single_request
    return self.parse_response(response)
    File "C:\Python27\lib\xmlrpclib.py", line 1468, in parse_response
    return u.close()
    File "C:\Python27\lib\xmlrpclib.py", line 793, in close
    raise Fault(**self._stack[0])
    Fault: <Fault 1: 'Bencode decoding failed: Expected 16860 bytes of data, but only 39 read.'>

    看起来是编码的原因造成的,但是改了好久都搞不定,请python的高手们多指点迷津。

    后台运行的aria2c.下载地址。
    http://sourceforge.jp/projects/sfnet_aria2rpcmanager/downloads/win-releases/Aria2RPCManagerv1.0.zip/

    另外运行官方手册中的那个json-rpc的实例也会报错。
    报错信息为:
    Traceback (most recent call last):
    File "C:\test.py", line 5, in <module>
    c = urllib2.urlopen('http://localhost:6800/jsonrpc', jsonreq)
    File "C:\Python27\lib\urllib2.py", line 126, in urlopen
    return _opener.open(url, data, timeout)
    File "C:\Python27\lib\urllib2.py", line 397, in open
    respOnse= meth(req, response)
    File "C:\Python27\lib\urllib2.py", line 510, in http_response
    'http', request, response, code, msg, hdrs)
    File "C:\Python27\lib\urllib2.py", line 435, in error
    return self._call_chain(*args)
    File "C:\Python27\lib\urllib2.py", line 369, in _call_chain
    result = func(*args)
    File "C:\Python27\lib\urllib2.py", line 518, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
    HTTPError: HTTP Error 500: Internal Server Error

    我在ipython中一行一行运行,看起来原因也是编码出现了问题。
    1 replies
    toaoman
        1
    toaoman  
    OP
       Jan 27, 2015
    已自行解决,请管理员删除该主题。
    About     Help     Advertise     Blog     API     FAQ     Solana     5694 Online   Highest 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 42ms UTC 03:32 PVG 11:32 LAX 20:32 JFK 23:32
    Do have fait in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86