Use of Subprocess.py in macro

MagicDraw OpenAPI, scripting related questions and discussions

Moderator: Moderators

Use of Subprocess.py in macro

Postby alban.cotton@se.com » Fri Jul 23, 2021 7:16 am

Hello,
I'm trying to use the Subprocess.py lib in a macro but it's not working.

here is an exemple of the code:
Code: Select all

import subprocess

subprocess.run(['print("hello")'],shell=True)             
     

I got this message:
MagicDraw cannot execute the Jython macro, please make sure that the md:\\_19_0_2_e670268_1627040463662_130879_79761 is correct. null java.lang.IncompatibleClassChangeError: java.lang.IncompatibleClassChangeError: Found class com.kenai.jffi.InvocationBuffer, but interface was expected in md:\\_19_0_2_e670268_1627040463662_130879_79761 at line number 2

I tried it on a pyhton IDE it's working
Does anyone know why?

Thank you by advance,
Alban
alban.cotton@se.com
Forum Newbie
Forum Newbie
 
Posts: 4
Posts Rating:0
Joined: Mon Jun 21, 2021 3:17 am

Re: Use of Subprocess.py in macro

Postby charlenecart12@gmail.com » Thu Jul 29, 2021 12:49 am

The subprocess module present in Python(both 2. x and 3. x) is used to run new applications or programs through Python code by creating new processes. It also helps to obtain the input/output/error pipes as well as the exit codes of various commands.
Lowes Life
charlenecart12@gmail.com
Forum Newbie
Forum Newbie
 
Posts: 1
Posts Rating:0
Joined: Thu Jul 29, 2021 12:46 am

Re: Use of Subprocess.py in macro

Postby alban.cotton@se.com » Mon Aug 09, 2021 12:36 am

Ok thank you for the precision.
Do you know if there is a way to use it within Cameo ?
alban.cotton@se.com
Forum Newbie
Forum Newbie
 
Posts: 4
Posts Rating:0
Joined: Mon Jun 21, 2021 3:17 am

Re: Use of Subprocess.py in macro

Postby psemenov313@gmail.com » Tue Sep 07, 2021 5:09 am

This works really well for us, thank you!

aces etm
psemenov313@gmail.com
Forum Newbie
Forum Newbie
 
Posts: 1
Posts Rating:0
Joined: Tue Sep 07, 2021 5:07 am


Return to Programmatic Extendibility

Who is online

Users browsing this forum: No registered users and 0 guests