1

I have a command that uses Popen from Python's subprocess module to call the raster2pgsql command for postgis. Here is what I've got:

curl_url = "https://....."
command = """raster2pgsql -F -I -C -s 26916 -t auto -R "/vsicurl/{}" table_name | database credentials...""".format(curl_url)

p1 = subprocess.Popen(command, shell=False, stdin=PIPE, stdout=PIPE, stderr=PIPE)
out, err = p1.communicate(b'...(This part is supposed to be the password for my database)', timeout=20)
print("out: {}, err: {}".format(out.decode('utf-8'), err))

The error I keep getting is

out: , err: b'ERROR: Unable to read raster file: table_name\r\n'

This shows that Popen is completely skipping my "/vsicurl/url...." block and is trying to open my table_name as the raster file.

When I make changes to the raster curl_url (ex. to /url... or just /vsicurl/, both of which are obviously syntactically incorrect), the error returns back to normal and says

out: , err: b'ERROR: Unable to read raster file: /url...'

Does anyone know why this is happening and how to fix it?

huski1018
  • 11
  • 2

0 Answers0