It's very difficult to provide an exact answer without knowing a lot more details, but I'll comment on both the Delete tool and using it inside a GP Service.
- The Delete tool returns true when it does what you've asked of it. So if you pass it a folder that doesn't exist, it gives True as a result. If it deletes the folder, it says True. You only get False if after the tool runs, the item is still there.
eg.
arcpy.management.Delete("c:\\I_DONT_EXIST")
<Result 'true'>
There is generally zero need to use Delete in a geoprocessing service. Delete is a mechanism to "clean up". Each and every GP Service execution runs in a it's own space. At the end of execution, after a set amount of time, the GP Framework cleans up everything that happens in that space. All your temporary files AND your output are simply cleaned up (deleted). Because of this, I don't recommend putting the Delete tool into your workflow. This adds execution time that the user needs to wait on. And for what? To have files removed on the server? Don't put this cost/time on the user.
(This is what I think you're doing based on your comment). It sounds like you're passing a "folder" or "path" argument to the GP Service and hoping it'll delete said folder. First, the GP Service is executing on a remote server; not your desktop. As such, it can only delete items (files, folders, etc) that are either on that server, or the service has access too from that server itself. So if you've passed it c:\temp
and that directory does not exist on the server, it can't reach back to YOUR CLIENT machine and delete it. You're accessing the service over web calls. It simply can't do this level of operations to your local machine. Beyond the GP Service on the Server accessing only items LOCAL to the service, it needs proper permissions to delete (or modify) files on that disk. Generally, ArcGIS Server is installed using a local user account (although it can be installed using a domain account). That user account generally does not have broad access to the Server box (think security concerns). The account has access to the Server install directory and the well defined $\arcgisserver\*
directories where execution takes place. You'd need to give the account running Server explicit folder access to where you're trying to access.
Take the last point, and assume you've given the ArcGIS Server user account all access to the Server machine and you publish a GP Service with the delete tool (or os.remove
or shutil.rmtree
). Then, as a user I send in the path c:\windows
to your service. Oooops!
newfolder
variable?