Snake YAML in Studio Scripting

81 views
Skip to first unread message

Lorenzo Gomez

unread,
Feb 12, 2021, 11:10:46 AM2/12/21
to yamcs
Hello everyone,

hope you are doing well.

In Studio's source code I see that SnakeYAML is listed as a dependency in the following file:

yamcs-studio/releng/org.yamcs.studio.platform/org.yamcs.studio.platform.target

However when I try to use it in my python script(which is attached to table widget), it cannot find the dependency and gives me the following error:

ImportError: No module named yaml

This is how I am doing it inside my script:

import org.yaml.snakeyaml


I'm sure this might be very simple, but I'm not that familiar with Maven.


Thanks in advance
Lorenzo


fabia...@spaceapplications.com

unread,
Feb 12, 2021, 11:52:38 AM2/12/21
to yamcs
Not everything from the platform is in the product.
This for example is not used by Yamcs Studio. Don't remember if it was at some point, but I think the line can be safely deleted now.

If you have a custom build of Yamcs Studio you should be able to add it to one of the product's feature modules.

Or convert your YAML to JSON before passing to studio.

Lorenzo Gomez

unread,
Feb 12, 2021, 1:42:50 PM2/12/21
to yamcs
Thanks a lot for the response!

I followed steps here as I'm trying to add the YAML capabilities to Studio, but I get the following error in eclipse when I click on "Synchronize":
!SESSION Fri Feb 12 18:30:59 GMT 2021 ------------------------------------------
!ENTRY org.eclipse.equinox.launcher 4 0 2021-02-12 18:30:59.253
!MESSAGE Exception launching the Eclipse Platform:
!STACK
java.lang.ClassNotFoundException: org.eclipse.core.runtime.adaptor.EclipseStarter
    at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:650)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:590)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1461)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1434)


The headless version of Studio built successfully before I attempted to set up my Eclipse Dev Environment. Here some more info that will hopefully help:

OS:Ubuntu 18.04.5 LTS
Eclipse:
Eclipse IDE for RCP and RAP Developers (includes Incubating components)
Version: 2020-12 (4.18.0)
Build id: 20201210-1552

mvn --version:
Apache Maven 3.6.0
Maven home: /usr/share/maven
Java version: 11.0.9.1, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.4.0-65-generic", arch: "amd64", family: "unix"

I should note that I set JAV_HOME like this in linux "export export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64/", which sets the variable only for that shell session.

Or is there a simpler way of doing this? All we'd like to do is have access to the SnakeYAML dependency in Studio OPI Scripts. Once we can add dependency to Maven, we should be able to access it from the Jython runtime, right?


I'm sorry about the lengthy message, just wanted to give enough info to debug the problem.

Thanks again for all of the help!
Lorenzo

Lorenzo Gomez

unread,
Feb 12, 2021, 1:59:14 PM2/12/21
to yamcs
I actually figured it out. This is a weird one. I had to go into yamcs-studio/releng/org.yamcs.studio.editor/plugin.xml and comment out the following line:
         <!--property
               name="preferenceCustomization">
         </property-->

Eclipse complained that the property was missing the "value" attribute, which makes sense because all of the other properties have a value attribute as well.

Thanks again
Lorenzo

Lorenzo Gomez

unread,
Feb 12, 2021, 3:09:01 PM2/12/21
to yamcs
I have Studio building from Eclipse and have a development environment. But I'm having issues adding SnakeYAML as a dependency to start using it in code. What are the steps in Eclipse GUI to add SnakeYAML as a Maven Dependency?

I have tried adding it everywhere and it still acts as if I never added the dependency.

I really don't know Maven well and really would appreciate the help.

Thank you
Lorenzo

fabia...@spaceapplications.com

unread,
Feb 13, 2021, 8:20:46 AM2/13/21
to yamcs
You should not add as a Maven dependency, but as an Eclipse dependency.

1/ Add to bundles/org.yamcs.studio.opibuilder.editor/plugin.xml
2/ Add to releng/org.yamcs.studio.editor.feature/feature.xml
3/ Rebuild
4/ Test:

importPackage(Packages.org.yaml.snakeyaml);
ConsoleUtil.writeInfo("got" + new Yaml());


This will break if and when we remove snakeyaml from our p2 website, but you can always find it from Orbit too: https://download.eclipse.org/tools/orbit/downloads/
Reply all
Reply to author
Forward
0 new messages