Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I wrote the following command in Geoserver rest-api using curl:

cmd=curl -v -u admin:geoserver -XGET -H "Accept: text/xml" http://localhost:8080/geoserver/rest/workspaces/myworkspace/datastores/mydatastore/featuretypes?list=available   

I want to execute this command through python like os.system(cmd).
Now How can I get the list in python itself.
I tried as follow:

import subprocess
import os
from subprocess import Popen,PIPE,STDOUT,call
cmd=r"""curl -v -u admin:geoserver -XGET -H "Accept: text/xml" http://localhost:8080/geoserver/rest/workspaces/myworkspace/datastores/mydatastore/featuretypes?list=available"""  
print output
share|improve this question

2 Answers 2

up vote 1 down vote accepted

I would advice using a library for using REST from python, eg requests http://docs.python-requests.org/en/latest/index.html

r = requests.get('http://localhost:8080/geoserver/rest/workspaces/myworkspace/datastores/mydatastore/featuretypes?list=available', auth=('admin', 'geoserver'))

then use r.text or r.json

share|improve this answer

it is recommended to use subprocess.call()

cmd must be a list, so you should write it like :

cmdlist= ["curl", "-v", "-u", "admin:geoserver", "-XGET" ,"-H", "Accept: text/xml", "http//jdkjdf"]   

note that you can use .split(" ") to create the list based on your variable cmd

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.