AnsweredAssumed Answered

10.2 GP service creates file - how to write it so I can actually retrieve it

Question asked by frank_mclean on May 29, 2014
Latest reply on May 29, 2014 by frank_mclean
Hi,

I am tearing out my hair (which I can ill afford to do) over being able to retrieve a file I create via a GP service.  Very simplified:-

1. Let's say I have a Python script which takes no input parameters.
2. It creates a file called 'HelloWorld.txt', which is empty.

That's it.  This runs fine on the desktop and I can retrieve HelloWorld.txt.  Yippee.

When I publish this, successfully, and run it, successfully, I cannot for the life of me get the file.  I've tried a lot of stuff:

1. Writing to 'nowhere', i.e. just HelloWorld.txt = written in job scratch area, result url goes to a scratch folder which gives an HTTP 400, Invalid URL.
2. Writing to 'scratch' via arcpy.env.scratchFolder = same as above
3. Writing to the 'current workspace' via arcpy.env.workspace = empty on server, same as above
4. Etc

What it _appears_ I need to do is to somehow write to the 'Output Directory' specified for the service, which has a nice accompanying 'Virtual Directory'.  Am I right?  How on earth do I get this location?  Would doing that even cause the url to be mapped to that location?  Why is this so hard?  :-)  You just publish a GP result, right?  Hooray!

Sorry.  You can probably tell this has my mind in knots.

Please, if someone could provide the Python snippet that will do this, I would be most grateful.  I might even make a T Shirt out of it, grow a beard and travel the world evangelizing about it, because this should be EASY, front and center whenever someone outputs a file as a script result and wants to publish it.  I'm asking for a Python snippet, rather than a URL to help docs, because "I've been everywhere, man!" and really doubt those will shed any light.  DO NOT let this put you off attempting to help, however. :-)  I'll be truly grateful for any crumbs.

I just wanted it to work like the print task works.  You get a nice URL that you download from and go on with your life.  This seemed like it must be a five minute job.  Tops.

Thanks for listening!

Frank

Outcomes