Author Topic: Running a JScript EA Script from Python via Win32 API: Is it possible?  (Read 3334 times)

JanKowal

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
We have got a script written in JScript that utilizies the EA's API like Repository.GetPackageByGuid() etc. What we want to do is to execute the script from an external application that is written in Python that uses Win32 API to communicate with EA. We can not rewrite the primary script to work in Python. Is it possible? We are fine tho to execute the script not necessarily from Python but PowerShell or Java instead.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Running a JScript EA Script from Python via Win32 API: Is it possible?
« Reply #1 on: September 16, 2023, 01:24:42 am »
Yes, I do that all time.

 
Code: [Select]
eaApp = win32com.client.Dispatch("EA.App")
eaRep = eaApp.Repository

q.

JanKowal

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Running a JScript EA Script from Python via Win32 API: Is it possible?
« Reply #2 on: September 18, 2023, 04:04:11 pm »
Yes, I do that all time.

 
Code: [Select]
eaApp = win32com.client.Dispatch("EA.App")
eaRep = eaApp.Repository

q.
Yes, we got the same code, but what is the exact function call for script execution? I could not find any documentation on this matter.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Running a JScript EA Script from Python via Win32 API: Is it possible?
« Reply #3 on: September 18, 2023, 07:12:04 pm »
I run Python scripts usually from Wingware. From inside EA you can't. Except you find a way to issue system calls from VB os tha J-stuff.

q.

JanKowal

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Running a JScript EA Script from Python via Win32 API: Is it possible?
« Reply #4 on: September 18, 2023, 07:34:06 pm »
I am not looking for a way to execute a Python script, but for a Python function that allows me to execute an existing script. So perfect situation would be something like
Code: [Select]
eaRep.ExecuteScript("scriptName") after dispatching EA.App and fetching Repository object.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Running a JScript EA Script from Python via Win32 API: Is it possible?
« Reply #5 on: September 18, 2023, 07:43:14 pm »
I am not looking for a way to execute a Python script, but for a Python function that allows me to execute an existing script. So perfect situation would be something like
Code: [Select]
eaRep.ExecuteScript("scriptName") after dispatching EA.App and fetching Repository object.

EA doesn't expose scripts in the API at all.
Although it is possible to run EA scripts without the help of EA, it's not a simple task at all.
I had to write quite a bit of code to pull that of in EA-Matic.

I guess you could do the same in Python, but it will probably take more time than rewriting the scripts in Python directly.

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Running a JScript EA Script from Python via Win32 API: Is it possible?
« Reply #6 on: September 18, 2023, 08:13:05 pm »
Well, yes. With an add-in it's easy. I did that to call external Python scripts. Worked nicely.

q.