【发布时间】:2018-02-07 23:04:50
【问题描述】:
我正在尝试解压缩扩展名为 .gz 的 tar 文件
status = subprocess.call('tar -zvxf %s -C %s 2> /dev/null' % (zipped_tar_file,data_path), shell=True)
在此声明之后不久,我有另一个电话-
status = subprocess.call('psql -q -v PATH=%s -f %s -h %s -p %d %s' %(some params)
第二个语句告诉 postgres 使用第一个命令提取的一些文件。我在 postgres 中收到文件不存在错误。
看起来 tar 命令仍在运行,而第二个语句已启动,并且 postgres 找不到尚未提取的所需文件。
ERROR: could not open file "path/filename.csv" for reading: No such file or directory
filename.csv 是要从 tarball 中提取的文件之一。
文件有点重(几百兆)
这是使用subprocess.call的正确方法吗?
【问题讨论】:
标签: python python-2.7 postgresql subprocess