Comments (8)
Could you create a branch or publish this code somewhere? I would like to take a look. Thanks.
from plugnplay.
https://github.com/hugosenari/pig
download pig rename pig/modules/maemo/notify_maemo.NotifyMaemo to pig/modules/maemo/notify.Notify
To run program (require linux)
python pig/__init__.py
This app, isn't done ;)
from plugnplay.
Sure I will do! And thanks for using plugnplay in one of your projects!
from plugnplay.
The problem here is that the python interpreter does not import two modules of the same name, twice.
My debug session told me that before importing any modules from pig.core.modules.maemo
all modules from pig.core.modules
are imported. So when comes the time to import pig.core.modules.maemo.notify
there is already a notify
entry in sys.modules['notify']
and this points to the previuos imported module, see:
ipdb> sys.modules['notify']
<module 'notify' from './pig/modules/notify.py'>
When this code runs:
> /usr/lib/python2.7/site-packages/plugnplay-0.3-py2.7.egg/plugnplay/__init__.py(64)load_plugins()
63 for mod_name in modules:
---> 64 try:
65 imported_module = __import__(mod_name, globals=globals(), \
ipdb> mod_name
'notify'
The value of the imported_module
variable does not change, that is, __import__
does not import the notify
module (from modules.maemo
) again.
Here is the value of the variables at the time of the second import:
ipdb> mod_name
'notify'
ipdb> print d
./pig/modules/maemo
ipdb> print imported_module
<module 'notify' from './pig/modules/notify.py'>
ipdb>
So even trying to import pig.core.modules.maemo.notify
it will not be imported because pig.core.modules.notify
already has its place on sys.modules
and __import__
knows about this.
In fact, I don't know if there is anything plugnplay can do to fix this, since it depends on the python loader __import__
.
from plugnplay.
maybe you can try (I don't know if is possible) import using "as dirName_Module"
Something like this:
https://github.com/hugosenari/plugnplay/commit/78dcd0f448e481def8e6184c38eb1f69a7856d7a
from plugnplay.
Yeah! Based on your commit I had an idea. The problem is that plugnplay imports using only the module name, this makes the python interpreter look for an entry in sys.modules
with this name. Since the two (or more) modules share the same name, the interpreter does not perform the second import.
The idea is to save the imported module under a unique sys.modules
key. For example:
If we need to import pig.core.modules.notify
and pig.core.modules.maemo.notify
plugnplay will save them on different places inside sys.modules
. Currently both are saved on sys.modules['notify']
and that's why the second module is never imported. I will try to chage plugnplay to save these two modules, respectivelly, in sys.modules['pig.core.modules.notify']
and sys.modules['pig.core.modules.maemo.notify']
.
I think this will do the trick. Let's see.
from plugnplay.
It's done @hugosenari. If you can, please take a look and check if this solves the problems you were having. Thanks.
from plugnplay.
"Worked"
But to me (at windows :( ):
Program send key error when remove _ init _
Solved adding one checker:
if mod_name in sys.modules:
del sys.modules[mod_name]
from plugnplay.
Related Issues (18)
- Implement external python files loading HOT 1
- Broken egg: README.rst missing HOT 2
- Add the ability to filter which implementors of an Interface will be returned HOT 8
- Choose the order which Interface implementors will be executed HOT 2
- __init__ of a direct plugnplay.Plugin descending is called upon loading
- My plugin can't import interface HOT 13
- Modules from dirs with same name HOT 6
- [Python 3.2] Unable to install 0.5.1 via pip or setup.py HOT 5
- Use logging.getLogger() of no logger is passed
- Incompatibility with py3k filter() function
- PnP does not run plugins that inherit a plugin without set implements again HOT 3
- Do not abort on loading error
- New way to call Interface implementors HOT 5
- Standardize Plugin Load/Execution order HOT 5
- plugnplay can't find implementors using different imports HOT 20
- Feature Request: recursive version of set_plugin_dirs HOT 4
- Do not import plugins that start with "__" HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from plugnplay.