Possible to run EE functions from another Python script?

I’d like to run EE CLI functions through another Python script. I’m currently accomplishing this with Pexpect.

However, considering that EE is written in Python I should think this is only necessary at this point due to my lack of knowledge and level of skill in Python - because it seems a rather silly way to do it!

It looks like the way to create sites would be through ee.cli.plugins.site_functions.py. I’ll first try to port to my script the way ee.cli.plugins.site.py utilizes the site_functions.py. I’m not sure what the best methods will be or how to pass the data in a way that it will work. For that matter, I’m not entirely sure how to import the EE functions into my script… but I suppose that’s what StackOverflow is for. :wink:

Any thoughts or pointers would be very helpful!

Also, just noticed EE is on Python 3, whereas I’m developing in Python2.

I’m guessing EE isn’t Python 2.7 compatible, and I should write my code for Python 3?

Update: Code rewritten for Python 3. Unsure of how to utilize the EE functions, now, though.


You can use EasyEngine functions in your python3 code. :slight_smile:

Note that: Some EasyEngine functions requires object of Cement App, as all EasyEngine sub commands are written as Cement plugins.

You can use http://builtoncement.com/2.4/ this cement doc for reference.

Thanks! But that doc link just brings me to the main page of the Cement docs - which I’ve already been to many a time. Is there a specific page that references what I’m trying to accomplish?

I’ve been through the EE code a bit and I can see where everything happens, but I’m not sure how to properly call or initialize things since it goes through cement.

Hello, You can start with http://builtoncement.com/2.4/dev/quickstart.html docs. Where you will get creation of cement app object. Using that app object you can use any EE function inside your Python code.

I’m still having a bit of a hard time wrapping my head around how to pass the arguments along to to it - like running ee site create domain.com --wp (which would require me to use the EESiteCreateController).

Hi @timworx

It’s been a long time, and we haven’t heard from you. It looks like your issue is resolved.

I am closing this support topic for now. Feel free to create a new support topic if you have any queries further. :slight_smile: