I'm trying to uncompress a tar file with .gz extension
status = subprocess.call('tar -zvxf %s -C %s 2> /dev/null' % (zipped_tar_file,data_path), shell=True)
Shortly after this statement, I have another call-
status = subprocess.call('psql -q -v PATH=%s -f %s -h %s -p %d %s' %(some params)
The second statement tells postgres to use some files extracted by the first command. I get a file not exists error in postgres.
It looks like the tar command is still running while the second statement has started and postgres can't find the required files which are yet to be extracted.
ERROR: could not open file "path/filename.csv" for reading: No such file or directory
filename.csv
is one of the files to be extracted from the tarball.
The files are a bit heavy (few hundered of megabytes)
Is this the correct way to use subprocess.call
?