OSError: [Errno 2] No such file or directory
2015-05-29 14:42
609 查看
执行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,image/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
['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,image/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
相关文章推荐
- Python动态类型的学习---引用的理解
- Python3写爬虫(四)多线程实现数据爬取
- 垃圾邮件过滤器 python简单实现
- 下载并遍历 names.txt 文件,输出长度最长的回文人名。
- install and upgrade scrapy
- Scrapy的架构介绍
- Centos6 编译安装Python
- 使用Python生成Excel格式的图片
- 让Python文件也可以当bat文件运行
- [Python]推算数独
- Python中zip()函数用法举例
- Python中map()函数浅析
- Python在CAM软件Genesis2000中的应用
- 使用Shiboken为C++和Qt库创建Python绑定
- FREEBASIC 编译可被python调用的dll函数示例
- Python 七步捉虫法
- Python实现的基于ADB的Android远程工具