Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loadModule issue #24

Open
tlechien opened this issue Jun 15, 2021 · 2 comments
Open

loadModule issue #24

tlechien opened this issue Jun 15, 2021 · 2 comments

Comments

@tlechien
Copy link

Hello,

Great repo,

I encounter an issue when trying to load a module:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/dist-packages/mirage-1.1-py3.7.egg/mirage/libs/utils.py", line 230, in loadModule
    return app.App.Instance.loader.load(name)
AttributeError: 'NoneType' object has no attribute 'loader'

Following the breadcrumbs I found out that there is an issue in the loader:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'mirage.modules' has no attribute '__modules__'

Cordially,

tlechien

@RCayre
Copy link
Owner

RCayre commented Jun 15, 2021

Hi,
weird issue... can you provide me more details ? How are you running Mirage ? sudo ./mirage_launcher ? sudo mirage ? Are you trying to run a module directly from an external python script ?
Can you provide me a code snippet allowing to reproduce the issue ?
Thanks.

@tlechien
Copy link
Author

Hello,
I admit I could have been clearer.
I'm importing Mirage as a library. Tried both to call loadModule as a standalone function and in a new module. It seems there is sth going on with the loader and the paths ( generated in modules/init.py & libs/utils.py).
I modified init in mirage/core/loader.py with

                self.modulesList = {}
                modulesPath = next(iter(modules.__path__))
                mList = modules.generateModulesDictionary(modulesPath, modulesPath)
                for moduleName,module in mList.items():
                        current = module#__import__("modules."+module, fromlist=module)
                        moduleClass = getattr(current,moduleName)
                        self.modulesList[moduleName] = moduleClass

to fix it (and it works as long as i initialize app.App() beforehand) but it's more of a bandaid than an actual fix.

Cordially,

tlechien

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants