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'm building the curl command in a python script, but when I run the script I get this error:

* Connected to localhost (127.0.0.1) port 8081
* Server auth using Basic with user 'admin'
> PUT /geoserver/rest/workspaces/csEvo/datastores/ABSM/file.shp HTTP/1.1
> Authorization: Basic YWRtaW46Y3NlbWVyZ2Vuc3lz
> User-Agent: curl/7.15.1 (i386-pc-win32) libcurl/7.15.1 OpenSSL/1.0.1c zlib/1.2.3
> Host: localhost:8081
> Accept: */*
> Content-type: application/zip
> Content-Length: 16302
> Expect: 100-continue
>
< HTTP/1.1 100 Continue
HTTP/1.1 500 Internal Server Error
< Content-Type: text/plain
< Transfer-Encoding: chunked
< Server: Jetty(6.1.8)
Error occured unzipping file:error in opening zip file* Connection #0 to host localhost left intact
* Closing connection #0

but if I run the same built curl command directly in the cmd line it works.

My py script is as follows (zips the shapefile and uploads it into geoserver) and I'm running it from inside the OSGEO4W shell in order to inherit environment settings:

#!/usr/bin/env python
import os
import zipfile
from subprocess import call
# Geoserver Variables
gshost = "http://localhost:8081"
gsuser = "admin"
gspassw = "geoserver"
gsworkspace = "csEvo"
gsstore = "teste"
AB_shpfile = "C:/data/theshpfile.shp"
#zip file for Geoserver upload
thezipfile = zipfile.ZipFile(AB_shpfile.replace('.','').replace('shp', '.zip'), "w")
for filenametozip in [ABSM_shpfile, ABSM_shpfile.replace('.shp', '.dbf'), AB_shpfile.replace('.shp', '.shx'), ABSM_shpfile.replace('.shp', '.prj')]: 
       arcname=os.path.basename(filenametozip.replace('.',''))
       arcname=str(arcname).replace(str(arcname)[-3:], '.' + str(arcname)[-3:])
       thezipfile.write(filenametozip, arcname)
# Send to Geoserver
thefileforgs = AB_shpfile.replace('.','').replace('shp', '.zip')
call("curl -u "+gsuser+":"+gspassw+" -v -XPUT -H " + '"Content-type: application/zip"' + " --data-binary @"+'"'+str(thefileforgs)+'"' + ' ' + gshost +"/geoserver/rest/workspaces/"+gsworkspace+"/datastores/"+gsstore+"/file.shp", shell=True)

What on earth am I missing?

Cheers

share|improve this question
    
Have you checked if your resulting path is the correct path? –  R.K. Dec 4 '12 at 11:08

1 Answer 1

If you want to do it with Python, you're better off using gsconfig as opposed to system calls using the subprocess module. It's a Python library for manipulating a GeoServer instance via the GeoServer RESTConfig API. You can check the documentation for more information.

share|improve this answer
    
but thats far more complex, isn't it? –  vascobnunes Dec 4 '12 at 10:48
1  
The fewer additional components I need to install, the better. Is gsconfig on the OSGEO4W package? –  vascobnunes Dec 4 '12 at 10:55

Your Answer

 
discard

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.