免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3156 | 回复: 6
打印 上一主题 下一主题

python 程序报错,请教 [复制链接]

招聘 : IT系统运维工
论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-03-22 01:15 |只看该作者 |倒序浏览
本帖最后由 yumany 于 2013-03-22 01:16 编辑

大家帮忙看看,下面的错误是怎么回事呢?
Python 3.1.1
Traceback (most recent call last):
  File "/opt/python/linux64/ix86/python_3.1.1/lib/python3.1/urllib/request.py", line 1054, in do_open
    h.request(req.get_method(), req.selector, req.data, headers)
  File "/opt/python/linux64/ix86/python_3.1.1/lib/python3.1/http/client.py", line 918, in request
    self._send_request(method, url, body, headers)
  File "/opt/python/linux64/ix86/python_3.1.1/lib/python3.1/http/client.py", line 956, in _send_request
    self.endheaders(body)
  File "/opt/python/linux64/ix86/python_3.1.1/lib/python3.1/http/client.py", line 914, in endheaders
    self._send_output(message_body)
  File "/opt/python/linux64/ix86/python_3.1.1/lib/python3.1/http/client.py", line 768, in _send_output
    self.send(msg)
  File "/opt/python/linux64/ix86/python_3.1.1/lib/python3.1/http/client.py", line 716, in send
    self.connect()
  File "/opt/python/linux64/ix86/python_3.1.1/lib/python3.1/http/client.py", line 1041, in connect
    self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file)
  File "/opt/python/linux64/ix86/python_3.1.1/lib/python3.1/ssl.py", line 381, in wrap_socket
    suppress_ragged_eofs=suppress_ragged_eofs)
  File "/opt/python/linux64/ix86/python_3.1.1/lib/python3.1/ssl.py", line 135, in __init__
    raise x
  File "/opt/python/linux64/ix86/python_3.1.1/lib/python3.1/ssl.py", line 131, in __init__
    self.do_handshake()
  File "/opt/python/linux64/ix86/python_3.1.1/lib/python3.1/ssl.py", line 327, in do_handshake
    self._sslobj.do_handshake()
socket.error: [Errno 104] Connection reset by peer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./count.py", line 246, in <module>
    stats = get_stats(product, current_FB_entry)
  File "./count.py", line 128, in get_stats
    build_info = get_api_result(build['url'])
  File "./count.py", line 54, in get_api_result
    return eval(urllib.request.urlopen(url + 'api/python').read())
  File "/opt/python/linux64/ix86/python_3.1.1/lib/python3.1/urllib/request.py", line 119, in urlopen
    return _opener.open(url, data, timeout)
  File "/opt/python/linux64/ix86/python_3.1.1/lib/python3.1/urllib/request.py", line 347, in open
    response = self._open(req, data)
  File "/opt/python/linux64/ix86/python_3.1.1/lib/python3.1/urllib/request.py", line 365, in _open
    '_open', req)
  File "/opt/python/linux64/ix86/python_3.1.1/lib/python3.1/urllib/request.py", line 325, in _call_chain
    result = func(*args)
  File "/opt/python/linux64/ix86/python_3.1.1/lib/python3.1/urllib/request.py", line 1080, in https_open
    return self.do_open(http.client.HTTPSConnection, req)
  File "/opt/python/linux64/ix86/python_3.1.1/lib/python3.1/urllib/request.py", line 1057, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 104] Connection reset by peer>
Build step 'Execute shell' marked build as failure

论坛徽章:
1
15-16赛季CBA联赛之新疆
日期:2017-03-09 12:33:45
2 [报告]
发表于 2013-03-22 07:33 |只看该作者
回复 1# yumany


    这个是你的服务端出了问题。
    你要检查一下你的服务端。

论坛徽章:
13
双鱼座
日期:2013-10-23 09:30:05数据库技术版块每日发帖之星
日期:2016-04-20 06:20:00程序设计版块每日发帖之星
日期:2016-03-09 06:20:002015亚冠之塔什干火车头
日期:2015-11-02 10:07:452015亚冠之德黑兰石油
日期:2015-08-30 10:07:07数据库技术版块每日发帖之星
日期:2015-08-28 06:20:00数据库技术版块每日发帖之星
日期:2015-08-05 06:20:002015年迎新春徽章
日期:2015-03-04 09:57:09辰龙
日期:2014-12-03 14:45:52酉鸡
日期:2014-07-23 09:46:23亥猪
日期:2014-03-13 08:46:22金牛座
日期:2014-02-11 09:36:21
3 [报告]
发表于 2013-03-22 09:00 |只看该作者
urllib.error.URLError: <urlopen error [Errno 104] Connection reset by peer>
这就是主要原因

招聘 : IT系统运维工
论坛徽章:
0
4 [报告]
发表于 2013-03-22 09:13 |只看该作者
谢谢两位,下面是我的源代码,我们现在是想urllib.request.urlopen去得到jenkins指定的页面内容,我也知道主要问题出在urllib.error.URLError: <urlopen error [Errno 104] Connection reset by peer>,服务器端大概会是什么问题呢?google很多没有找出有用的信息。

jenkins = 'http://belinb.china****.net:8080/'

import chameleon
import os
import urllib.request
import sys
import datetime
import subprocess
os.system('python -V')
print 'url'
def get_api_result(url):
    """Gets the dictionary returned by Jenkins' Pyfthon API.

    @type url: str
    @param utl: URL of the job/build.

    @rtype: dict
    @return: Contains information from Jenkins Python API for the requested build/job.

    """
    return eval(urllib.request.urlopen(url + 'api/python').read())


论坛徽章:
1
15-16赛季CBA联赛之新疆
日期:2017-03-09 12:33:45
5 [报告]
发表于 2013-03-22 11:12 |只看该作者
回复 4# yumany


    最简单,你用WEB BROWSER连上你所的URL,看是什么结果,这个就明白了。

招聘 : IT系统运维工
论坛徽章:
0
6 [报告]
发表于 2013-03-23 21:11 |只看该作者
本帖最后由 yumany 于 2013-03-23 21:11 编辑

现在有个问题是url这个值是在哪里定义,在脚本里没有单独定义这个变量,因为是别人写的,
如果单独在浏览器里 http://belinb.china****.net:8080/api/python,可以下载到网站内容。

def get_api_result(url):
    """Gets the dictionary returned by Jenkins' Pyfthon API.

    @type url: str
    @param utl: URL of the job/build.

    @rtype: dict
    @return: Contains information from Jenkins Python API for the requested build/job.

    """
    return eval(urllib.request.urlopen(url + 'api/python').read())

招聘 : IT系统运维工
论坛徽章:
0
7 [报告]
发表于 2013-03-23 21:32 |只看该作者
我试了一下简单的这样的脚本是没有问题
#!/usr/bin/env python3
import urllib.request
with urllib.request.urlopen('http://belinb.china****.net:8080/') as f:
      content = f.read()
print(content)

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP