In detail, ERRORS as below are generated by using import to introduce module to codegen template code. Thnaks
2020-08-13 10:42:50,436 ERROR [component_loader] Failed to load 'AddcontentFunctionComponent = fn_add_content.components.addContent:FunctionComponent' from 'fn-add-content 1.0.0'
2020-08-13 10:42:50,437 DEBUG [filelock] Attempting to release lock 139854496915536 on /home/integration/.resilient/resilient_circuits_lockfile
2020-08-13 10:42:50,437 INFO [filelock] Lock 139854496915536 released on /home/integration/.resilient/resilient_circuits_lockfile
Traceback (most recent call last):
File "/home/integration/resilient/bin/resilient-circuits", line 10, in <module>
sys.exit(main())
File "/home/integration/resilient/lib/python2.7/site-packages/resilient_circuits/bin/resilient_circuits_cmd.py", line 674, in main
config_file=args.config_file)
File "/home/integration/resilient/lib/python2.7/site-packages/resilient_circuits/bin/resilient_circuits_cmd.py", line 90, in run
app.run(**kwargs)
File "/home/integration/resilient/lib/python2.7/site-packages/resilient_circuits/app.py", line 341, in run
application = App(*args, **kwargs)
File "/home/integration/resilient/lib/python2.7/site-packages/resilient_circuits/app.py", line 189, in __init__
self.do_initialization()
File "/home/integration/resilient/lib/python2.7/site-packages/resilient_circuits/app.py", line 224, in do_initialization
self.component_loader = ComponentLoader(self.opts)
File "/home/integration/resilient/lib/python2.7/site-packages/resilient_circuits/component_loader.py", line 64, in __init__
installed_components = self.discover_installed_components()
File "/home/integration/resilient/lib/python2.7/site-packages/resilient_circuits/component_loader.py", line 90, in discover_installed_components
return [ep.load() for ep in entry_points if ep.name not in self.noload]
File "/home/integration/resilient/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2443, in load
return self.resolve()
File "/home/integration/resilient/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2453, in resolve
raise ImportError(str(exc))
ImportError: 'module' object has no attribute 'FunctionComponent'
------------------------------
Ivan To
------------------------------
Original Message:
Sent: Wed August 12, 2020 10:46 PM
From: Ivan To
Subject: ImportError: 'module' object has no attribute 'FunctionComponent'
thanks for your advice. However, the issues is not able to resolve even giving a different way of calling the import. Is there the other way to resolve this issue. Thanks
from fn_add_content.components.addContent import fnAddContent (As you could review in Part I, it failed to run during resilient-circuits run )
Part I
Failed to load 'AddcontentFunctionCompent =
ImportError: 'module' object has no attribute 'FunctionComponent'
Part II (unit testing) but could not be execute during resilient-circuits run.
For Unit Testing of different way to import the modules, it could be run during unit testing )
from fn_add_content.components.addContent import fnAddContent
#from fn_add_content.components.addContent import fnAddContent
#from components.addContent import fnAddContent
#from components.addContent import fnAddContent
#from addContent import fnAddContent
testing = fnAddContent("Testing the way of import fnAddContent v43")
print(testing)
------------------------------
Ivan To
Original Message:
Sent: Wed August 12, 2020 02:11 PM
From: Liam Mahoney
Subject: ImportError: 'module' object has no attribute 'FunctionComponent'
Ivan,
Try using 'from fn_add_content.components.addContent import fnAddContent' as your import statement in funct_f_add_content.py.
------------------------------
Liam Mahoney
Original Message:
Sent: Wed August 12, 2020 12:33 PM
From: Ivan To
Subject: ImportError: 'module' object has no attribute 'FunctionComponent'
Question: How am I supposed to proper import function from one module to the resilient-circuits codegen template code. In more specific, how to import successfully addContent module on funct_f_add_content module, as shown in figure 1.
addContent.py ( trying to import on funct_f_add_content module)
Funct_f_add_content.py (How come the program can not be executed even with valid import python syntax)
# Method 3: assign value via function from other module 'addContent' on variable 'addingContent3'
from addContent import fnAddContent
addingContent3 = fnAddContent("Ivan Testing 3")
# #yield StatusMessage("fn_add_content '{0}'".format(a))
results = {
"content": addingContent3
}
By using method 3, with import other module, to make a simple add content on a note program and demonstrate how to import a self-custom module (addContent.py) with a function (fnAddContent(tmp_content)) on a template code (funct_f_add_content.py) generated by resilient-circuits codegen. However, the program cannot be executed to assign value by a function in different module (method 3). Once resilient-circuits run is executed it prompt out error messages as below:
Failed to load 'AddcontentFunctionComponent = fn_add_content.components.addContent:FunctionComponent' from 'fn-add-content
1.0.0'
...
ImportError: 'module' object has no attribute 'FunctionComponent'
------------------------------
Ivan To
------------------------------