subprocess.Popen需要哪些权限? [英] What permissions are required for subprocess.Popen?

查看:570
本文介绍了subprocess.Popen需要哪些权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码:

gb = self.request.form['groupby']
typ = self.request.form['type']
tbl = self.request.form['table']

primary = self.request.form.get('primary', None)

if primary is not None:
    create = False
else:
create = True

mdb = tempfile.NamedTemporaryFile()
mdb.write(self.request.form['mdb'].read())
mdb.seek(0)

csv = tempfile.TemporaryFile()
conversion = subprocess.Popen(("/Users/jondoe/development/mdb-export", mdb.name, tbl,),stdout=csv)

在OS X中调用最后一行(即转换=")时,会导致此错误.

Causes the this error when calling the last line i.e. 'conversion =' in OS X.

Traceback (innermost last):
  Module ZPublisher.Publish, line 119, in publish
  Module ZPublisher.mapply, line 88, in mapply
  Module ZPublisher.Publish, line 42, in call_object
  Module circulartriangle.mdbtoat.mdb, line 62, in __call__
  Module subprocess, line 543, in __init__
  Module subprocess, line 975, in _execute_child
OSError: [Errno 13] Permission denied

我已经尝试过chmod 777 /Users/jondoe/development/mdb-export-可能还需要什么?

I've tried chmod 777 /Users/jondoe/development/mdb-export - what else might be required?

推荐答案

似乎权限被拒绝错误"最初来自Popen,试图从错误的位置执行mdb-export(并使用错误的权限执行复合操作) ).

It seems the 'Permissions denied error' was orginally coming from Popen trying to execute mdb-export from the wrong location (and to compound things, with the wrong permissions).

如果安装了mdbtools,则以下命令可以正常工作,并且继承了正确的权限,而无需sudo等.

If mdbtools is installed, the following works fine and inherits the correct permissions without the need for sudo etc.

subprocess.Popen(("mdb-export", mdb.name, tbl,),stdout=csv)

(值得一提的是,我忘了Popen用于打开可执行文件,而不是打开文件夹或文件夹中的不可执行文件,这让我陷入了混乱之中)

(Worth noting, I got myself into a muddle for a while, having forgotten that Popen is for opening executables, not folders or non-exectable files in folders)

感谢您的所有回复,无论:)

Thanks for all your responses, they all made for interesting reading regardless :)

这篇关于subprocess.Popen需要哪些权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆