前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >OSError: [Errno 2] No such file or directory

OSError: [Errno 2] No such file or directory

作者头像
党志强
发布2020-02-11 11:44:28
2.3K0
发布2020-02-11 11:44:28
举报
文章被收录于专栏:敏而好学敏而好学

执行Python脚本时,报如下错误:

['mkdir -p /tmp/gluster_volume_files.can.not.delete']

[E 150529 11:36:14 web:1030] Uncaught exception GET /api/v1/volume/df/tank (10.58.164.150)

    HTTPRequest(protocol='http', host='10.160.140.23:8000', method='GET', uri='/api/v1/volume/df/tank', version='HTTP/1.1', remote_ip='10.58.164.150', body='', headers={'Connection': 'keep-alive', 'Accept-Language': 'zh-CN,zh;q=0.8', 'Accept-Encoding': 'gzip, deflate, sdch', 'Cache-Control': 'max-age=0', 'Host': '10.160.140.23:8000', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,p_w_picpath/webp,*/*;q=0.8', 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.93 Safari/537.36'})

    Traceback (most recent call last):

      File "/usr/lib/python2.6/site-packages/tornado/web.py", line 987, in _execute

        getattr(self, self.request.method.lower())(*args, **kwargs)

      File "/root/dzq/workspace/tools/glusterfs-rest/glusterrest/restapi.py", line 214, in get

        self.write(volume_df(vol))

      File "/root/dzq/workspace/tools/glusterfs-rest/glusterrest/restapi.py", line 90, in volume_df

        return run_and_response(volume.df, [vol])

      File "/root/dzq/workspace/tools/glusterfs-rest/glusterrest/restapi.py", line 44, in run_and_response

        return resp_success(func(*args))

      File "/root/dzq/workspace/tools/glusterfs-rest/glusterrest/cli/volume.py", line 399, in df

        utils.checkstatuszero(cmd1)

      File "/root/dzq/workspace/tools/glusterfs-rest/glusterrest/utils.py", line 29, in checkstatuszero

        rc, out, err = execute(cmd)

      File "/root/dzq/workspace/tools/glusterfs-rest/glusterrest/utils.py", line 21, in execute

        close_fds=close_fds)

      File "/usr/lib64/python2.6/subprocess.py", line 642, in __init__

        errread, errwrite)

      File "/usr/lib64/python2.6/subprocess.py", line 1234, in _execute_child

        raise child_exception

    OSError: [Errno 2] No such file or directory

解决方案:

方案1:Popen中加shell=true选项。

方案2:将命令更为如下形式传入:cmd = ['mkdir'] + ['-p'] + ['/tmp/gluster_volume_files.can.not.delete']

参考:http://stackoverflow.com/questions/901982/python-oserror-errno-2

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2015-05-29 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档