labs4capella / python4capella

Python for Capella
Eclipse Public License 2.0
52 stars 10 forks source link

Unable to run script from the command line #172

Closed Ghipag closed 1 year ago

Ghipag commented 1 year ago

Hi all, I am trying to run a script directly from the command line using the following command:

C:/path/to/capellac.exe -nosplash -consolelog -application org.polarsys.capella.core.commandline.core -appid org.eclipse.python4capella.commandline -data ./workspace workspace:/Python_Script_Tools/scripts/myscript.py

However this fails, seemingly unable to find the script I am asking it to execute and the following is returned:

WARNING: A terminally deprecated method in java.lang.System has been called
WARNING: System::setSecurityManager has been called by org.eclipse.osgi.internal.framework.SystemBundleActivator (file:/c:/Users/lt17550/capella/capella/plugins/org.eclipse.osgi_3.16.300.v20210525-1715.jar)
WARNING: Please consider reporting this to the maintainers of org.eclipse.osgi.internal.framework.SystemBundleActivator
WARNING: System::setSecurityManager will be removed in a future release
!SESSION 2023-04-25 16:48:34.127 -----------------------------------------------
eclipse.buildId=unknown
java.version=17.0.4
java.vendor=Eclipse Adoptium
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_GB
Framework arguments:  -application org.polarsys.capella.core.commandline.core -appid org.eclipse.python4capella.commandline workspace:/Python_Script_Tools/scripts/myscript.py
Command-line arguments:  -os win32 -ws win32 -arch x86_64 -consolelog -application org.polarsys.capella.core.commandline.core -appid org.eclipse.python4capella.commandline -data .\workspace workspace:/Python_Script_Tools/scripts/myscript.py

!ENTRY org.eclipse.core.resources 2 10035 2023-04-25 16:48:34.943
!MESSAGE The workspace exited with unsaved changes in the previous session; refreshing workspace to recover changes.
log4j:WARN No appenders could be found for logger (org.polarsys.capella.common.mdsofa.common.helper).
log4j:WARN Please initialize the log4j system properly.
Executing workspace:/Python_Script_Tools/scripts/myscript.py with arguments: []
C:\Users\lt17550\capella\capella\plugins\org.eclipse.ease.lang.python.py4j_0.8.0.I202104091518\pysrc\ease_py4j_main.py:414: DeprecationWarning: setDaemon() is deprecated, set the daemon attribute 
instead
  thread.setDaemon(True)
java.io.IOException: org.eclipse.core.internal.resources.ResourceException: Resource '/Python_Script_Tools/scripts/myscript.py' does not exist.
        at org.eclipse.ease.urlhandler.WorkspaceURLConnection.getInputStream(WorkspaceURLConnection.java:42)
        at java.base/java.net.URL.openStream(URL.java:1161)
        at org.eclipse.ease.adapters.ScriptableAdapter.lambda$3(ScriptableAdapter.java:41)
        at org.eclipse.ease.Script.getCode(Script.java:128)
        at org.eclipse.ease.AbstractScriptEngine.inject(AbstractScriptEngine.java:169)
        at org.eclipse.ease.AbstractScriptEngine.run(AbstractScriptEngine.java:242)
        at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: org.eclipse.core.internal.resources.ResourceException: Resource '/Python_Script_Tools/scripts/myscript.py' does not exist.
        at org.eclipse.core.internal.resources.Resource.checkExists(Resource.java:330)
        at org.eclipse.core.internal.resources.Resource.checkAccessible(Resource.java:204)
        at org.eclipse.core.internal.resources.File.getContents(File.java:273)
        at org.eclipse.core.internal.resources.File.getContents(File.java:266)
        at org.eclipse.ease.urlhandler.WorkspaceURLConnection.getInputStream(WorkspaceURLConnection.java:40)
        ... 6 more
Caused by: java.lang.Exception: Resource '/Python_Script_Tools/scripts/myscript.py' does not exist.
        at org.eclipse.core.internal.resources.ResourceException.provideStackTrace(ResourceException.java:42)
        at org.eclipse.core.internal.resources.ResourceException.<init>(ResourceException.java:38)
        ... 11 more

!ENTRY org.eclipse.osgi 4 0 2023-04-25 16:48:35.615
!MESSAGE Application error
!STACK 1
java.lang.NullPointerException: Cannot invoke "org.eclipse.python4capella.commandline.Python4CapellaCommandLinePlugin$Implementation.log(Object)" because the return value of "org.eclipse.python4capella.commandline.Python4CapellaCommandLinePlugin.getPlugin()" is null
        at org.eclipse.python4capella.commandline.Python4CapellaCommandLine.runScript(Python4CapellaCommandLine.java:110)
        at org.eclipse.python4capella.commandline.Python4CapellaCommandLine.execute(Python4CapellaCommandLine.java:54)
        at org.polarsys.capella.core.commandline.core.CommandLineApp.launchApp(CommandLineApp.java:138)
        at org.polarsys.capella.core.commandline.core.CommandLineApp.start(CommandLineApp.java:72)
        at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:401)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:654)
        at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
        at org.eclipse.equinox.launcher.Main.run(Main.java:1462)

I am running this with Capella 6.0 and the script runs fine when run from within Capella. Thanks for any help

ylussaud commented 1 year ago

EASE doesn't find your script in your workspace. Do you have a workspace in the workspace directory in you courant directory ? And does it contains the Python_Script_Tools project with the scripts/myscript.py file ?

Maybe you need to change the workspace directory: -data C:/path/to/workspace

Ghipag commented 1 year ago

Ahh yep, that's it Thanks very much, all working now