是否可以将使用Subprocess.popen下载的文件重定向到另一个目录?

问题描述 投票:0回答:1

我正在尝试设置一个AWS Lambda函数,该函数使用python使用jar文件进行API调用。代码如下所示:

command_line = ('java -jar Reporter.jar p=Reporter.properties Sales.getReport' + " " + arg1 + ", " + arg2 + ", " + arg3 + ", " + arg4 + ", " + arg5 + ", " + arg6)
args = shlex.split(command_line)
print(args)
p = subprocess.Popen(args)
p.wait()

此文件(一个以gzip格式压缩的文本文件)被下载到与在我的本地计算机上保存jar文件和属性文件的目录相同的目录中。在AWS Lambda上,该相同的代码段成功执行,但给出了错误:Cannot save file. Make sure you have enough space and have write access to the current directory.这是因为AWS Lambda除了/tmp文件夹之外,不授予对下载文件的访问权限?

为了将文件下载到AWS Lambda /tmp文件夹而不是保存jar文件的文件夹,我可以对代码进行哪些更改?

我已经尝试使用os.chdir将目录更改为保存jar文件的目录,并在处理subprocess命令后返回到父目录,但是它将文件下载到与保存jar文件的目录相同的目录中。>

我正在尝试设置一个AWS Lambda函数,该函数使用python使用jar文件进行API调用。代码如下所示:command_line =('java -jar Reporter.jar p = Reporter.properties Sales ....

python-3.x amazon-web-services lambda subprocess popen
1个回答
0
投票

我对json和xlsx文件做了类似的操作。

© www.soinside.com 2019 - 2024. All rights reserved.