Question

How can I upload zipped-up file geodatabase to FME Server and kick off a workspace using Python?

  • 25 February 2016
  • 4 replies
  • 20 views

I have workspaces published in FME Server and have created a web form where users can upload zipped-up file geodatabases which get processed and loaded into a master database. Now some users want to automate that process using Python so they don't have to use the web form but can have a Python script that can be set to run automatically once a month and upload the data. I have seen bits and pieces of code and functionality which are tantalizingly close to what I want to do but not quite. Has anyone out there ever done this?


4 replies

Userlevel 5
Badge +25

You can create a notification that's triggered by a file upload, using the Directory Watcher publication. That bypasses the web form alltogether. There doesn't seem to be a recent tutorial on that though.

Alternatively... you could schedule the Python upload every month and then create a 2nd monthly schedule in FME Server that kicks off your workspace a little while after the upload, bypassing the notification system entirely.

Userlevel 4
Badge +13

Here is a script for running a job on FME Server using Python:

 

http://playground.fmeserver.com/other-languages/py...

This shows how to interact with FME Server in python. You can modify this script to upload files to the Resource area using REST calls. Screenshot:

https://www.dropbox.com/s/lbqupzhnqigwmk1/Screensh...

---

I also like the suggestion from @redgeographics about using the Directory Watch publication as well. There is a tutorial for that available at:

https://knowledge.safe.com/articles/1401/directory...

---

Alternatively, a scheduled job could be setup on FME Server to search specific directories and process the data as well. This assumes that FME Server can see the directories where users place the files.

Here is a script for running a job on FME Server using Python:

 

http://playground.fmeserver.com/other-languages/py...

This shows how to interact with FME Server in python. You can modify this script to upload files to the Resource area using REST calls. Screenshot:

https://www.dropbox.com/s/lbqupzhnqigwmk1/Screensh...

---

I also like the suggestion from @redgeographics about using the Directory Watch publication as well. There is a tutorial for that available at:

https://knowledge.safe.com/articles/1401/directory...

---

Alternatively, a scheduled job could be setup on FME Server to search specific directories and process the data as well. This assumes that FME Server can see the directories where users place the files.

Thanks to all for the suggestions. I took @aaronkoning's advice and was able to create a Python script that uploads a zipped up FGDB to the shared resources directory and kicks off a workspace successfully. Unfortunately, it can't get to the FGDB inside the ZIP file. I get the following: Unable to connect to the File Geodatabase at 'C:'. I have tried setting the opt_extractarchive parameter to true but this had no effect. Is there a way to upload a ZIP file to the shared resources directory and have it unzip?

Badge

Here is a script for running a job on FME Server using Python:

 

http://playground.fmeserver.com/other-languages/py...

This shows how to interact with FME Server in python. You can modify this script to upload files to the Resource area using REST calls. Screenshot:

https://www.dropbox.com/s/lbqupzhnqigwmk1/Screensh...

---

I also like the suggestion from @redgeographics about using the Directory Watch publication as well. There is a tutorial for that available at:

https://knowledge.safe.com/articles/1401/directory...

---

Alternatively, a scheduled job could be setup on FME Server to search specific directories and process the data as well. This assumes that FME Server can see the directories where users place the files.

Is your reader a generic format reader or a filegeodatabase reader? I experienced some issues woth generic readers an zip files, but i'm not 100% sure if this is a gerneral problem, or if i just used it the wrong way.

 

Reply