Failure of some Python4Capella scripts

Testing some of the sample scripts provided with Python4Capella, I noted that some of them have bugs ?!?.

In the error dump log in the console, there is always the same kind of error, coming from the “capella.py” and “JAVA_API.py” modules as indicated below for the test of “Export_SF_and_FE_to_xlsx.py”

////////////// error log ///////////////////////////////////////////////////////////////////////////////////////////////
starting export of model In-Flight Entertainment System
org.eclipse.ease.ScriptExecutionException: Traceback (most recent call last):
File “workspace://sample_scripts/Export_SF_and_FE_to_xlsx.py”, line 81, in
set_types=set):
File “workspace://Python4Capella/simplified_api/capella.py”, line 239, in get_all_contents_by_type
self.except_data = except_data
File “workspace://Python4Capella/java_api/Java_API.py”, line 35, in next
try:
File “workspace://Python4Capella/java_api/Java_API.py”, line 27, in next
from py4j.java_collections import ListConverter as _pyease_ListConverter
File “workspace://Python4Capella/simplified_api/capella.py”, line 164, in get_class
‘’’
AttributeError: module ‘main’ has no attribute ‘Attribute’
/////////////////////////////////////////////////////////////////////////////////////////////////////////

This is a bug that have been fixed:

You can check the linked discussion or the commit to patch EObject.get_class() in your capella.py file.

I have read the discussion … but it is not clear that the bug has been solved ?!?

I am using :

  • Capella 6.0.0
  • Python4Capella 1.1.0
  • Requirement VP 0.13.0
  • PVMT 60.6.0
  • DiagramStyler 60.3.1
  • System to subsystem 1.6.0
  • Capella Filtering 1.6.0
  • HTLM generation 6.0.0

I have the bug for (non exhaustive list) :

  • Export_capabilities_and_owned_scenarios_to_xlsx.py
  • Export_description_of_elements _with_html format_and_as_plain text_to_xlsx.py
  • Export_SF_and_FE_to_xlsx.py
  • Export_traceability_matrix_SF_LF_to_xlsx.py
  • Function_allocation_completeness_check.py

Are OK (non exhaustive list) :

  • List_logical_components_in_console.py
  • Export_the_list_of_physical_components_to_xlsx.py

It should be fixed in the 1.1.0… I just checked the update site on the release page for version 1.1.0 and line 164 of capella.py is:

            res = getattr(sys.modules["__main__"], "Attribute")

Did you reimporte the Python4Capella project after updating ? This is needed to have the last version of Python scripts. You can download the update site from the release page if needed. You can also patch the line but other fixes will be missing…

EDIT: I might have respined this release shortly after the initial release. That might explain the difference in your version.

I have re dowloaded

org.eclipse.python4capella.update.zip
57.8 MB
Sep 26, 2022

followed all steps as described here : GitHub - labs4capella/python4capella: Python for Capella

and in capella.py, i have on line 164

res = getattr(sys.modules["__main__"], "Attribute")

but I still get the same errors … some scripts are correct but the others not

OK… The bug is still here somehow. You add an import to the module declaring Attribute:

# include needed for the requirement API
include('workspace://Python4Capella/simplified_api/requirement.py')
if False:
    from simplified_api.requirement import *