Comments (13)
Hello @hugosenari I tried to reproduce the problem but all worked well, look:
(pig)daltonmatos@jetta dtc % PYTHONPATH=../pig:. python -m dtc master [+0] [959a312] untracked
** (process:10785): WARNING **: Trying to register gtype 'GMountMountFlags' as enum when in fact it is of type 'GFlags'
** (process:10785): WARNING **: Trying to register gtype 'GDriveStartFlags' as enum when in fact it is of type 'GFlags'
** (process:10785): WARNING **: Trying to register gtype 'GSocketMsgFlags' as enum when in fact it is of type 'GFlags'
^CTraceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/home/daltonmatos/projetos/contrib/dtc/dtc/__main__.py", line 19, in <module>
__main__()
File "/home/daltonmatos/projetos/contrib/dtc/dtc/__main__.py", line 16, in __main__
loop.run();
KeyboardInterrupt
(pig)daltonmatos@jetta dtc %
The PYTHONPATH=../pig:.
was needed because I didn't have pig
installed. Despite the ^C
I had to press, no exception were raised.
p.s. I had to comment some code inside pig
. Something about pynotify
and and inexistant appindicator
module.
Here is the sys.path
:
['', '/home/daltonmatos/.virtualenvs/pig/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg',
'/home/daltonmatos/.virtualenvs/pig/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg',
'/home/daltonmatos/projetos/contrib/pig', '/home/daltonmatos/projetos/contrib/dtc',
'/home/daltonmatos/.virtualenvs/pig/lib/python27.zip', '/home/daltonmatos/.virtualenvs/pig/lib/python2.7',
'/home/daltonmatos/.virtualenvs/pig/lib/python2.7/plat-linux2', '/home/daltonmatos/.virtualenvs/pig/lib/python2.7/lib-tk',
'/home/daltonmatos/.virtualenvs/pig/lib/python2.7/lib-old', '/home/daltonmatos/.virtualenvs/pig/lib/python2.7/lib-dynload',
'/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk',
'/home/daltonmatos/.virtualenvs/pig/lib/python2.7/site-packages', '/usr/lib/python2.7/site-packages/Genshi-0.6-py2.7.egg',
'/usr/lib/python2.7/site-packages/Trac-0.11.6-py2.7.egg', '/usr/lib/python2.7/site-packages/wsgid-v0.6.0-py2.7.egg',
'/usr/lib/python2.7/site-packages/clint-0.3.1-py2.7.egg', '/usr/lib/python2.7/site-packages/simplejson-2.4.0-py2.7-linux-
x86_64.egg', '/usr/lib/python2.7/site-packages/requests-0.10.8-py2.7.egg', '/usr/lib/python2.7/site-packages/BeautifulSoup-
3.2.1-py2.7.egg', '/usr/lib/python2.7/site-packages/Django-1.3-py2.7.egg', '/usr/lib/python2.7/site-packages/pyzmq-2.1.11-
py2.7-linux-x86_64.egg', '/usr/lib/python2.7/site-packages/chardet-1.0.1-py2.7.egg', '/usr/lib/python2.7/site-packages/certifi-
0.0.8-py2.7.egg', '/usr/lib/python2.7/site-packages', '/usr/lib/python2.7/site-packages/PIL', '/usr/lib/python2.7/site-
packages/gst-0.10', '/usr/lib/python2.7/site-packages/gtk-2.0', '/usr/lib/python2.7/site-packages']
Maybe you have just a misconfigured PYTHONPATH
?
from plugnplay.
I just updated the code and now can reproduce the problem. I will take a look.
from plugnplay.
Interesting: Running the __main__.py
as a python script it works!
daltonmatos@jetta dtc % PYTHONPATH=. python dtc/__main__.py master [+0] [80af5e3] untracked
DEBUG:root:no mainloop found
DEBUG:root:importing gobject
DEBUG:root:add dir: /home/daltonmatos/projetos/contrib/dtc/dtc/core/interfaces to path
DEBUG:root:add dir: /home/daltonmatos/projetos/contrib/dtc/dtc/modules to path
DEBUG:root:Set up plugnplay
deu zebra?
['/home/daltonmatos/projetos/contrib/dtc/dtc', '/home/daltonmatos/projetos/contrib/dtc/dtc/core', '/home/daltonmatos/projetos/contrib/dtc/dtc', '/usr/lib/python2.7/site-packages/Genshi-0.6-py2.7.egg', '/usr/lib/python2.7/site-packages/Trac-0.11.6-py2.7.egg', '/usr/lib/python2.7/site-packages/wsgid-v0.6.0-py2.7.egg', '/usr/lib/python2.7/site-packages/clint-0.3.1-py2.7.egg', '/usr/lib/python2.7/site-packages/simplejson-2.4.0-py2.7-linux-x86_64.egg', '/usr/lib/python2.7/site-packages/requests-0.10.8-py2.7.egg', '/usr/lib/python2.7/site-packages/BeautifulSoup-3.2.1-py2.7.egg', '/usr/lib/python2.7/site-packages/Django-1.3-py2.7.egg', '/usr/lib/python2.7/site-packages/pyzmq-2.1.11-py2.7-linux-x86_64.egg', '/usr/lib/python2.7/site-packages/chardet-1.0.1-py2.7.egg', '/usr/lib/python2.7/site-packages/certifi-0.0.8-py2.7.egg', '/home/daltonmatos/projetos/contrib/dtc', '/usr/lib/python27.zip', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/lib/python2.7/site-packages', '/usr/lib/python2.7/site-packages/PIL', '/usr/lib/python2.7/site-packages/gst-0.10', '/usr/lib/python2.7/site-packages/gtk-2.0', '/usr/lib/python2.7/site-packages', '/usr/lib/portage/pym']
deu zebra?
DEBUG:root:execute modules
but running with python -m
does not:
DEBUG:root:no mainloop found
DEBUG:root:importing gobject
DEBUG:root:add dir: dtc/core/interfaces to path
DEBUG:root:add dir: dtc/modules to path
DEBUG:root:Set up plugnplay
deu zebra?
['dtc', 'dtc/core', '', '/usr/lib/python2.7/site-packages/Genshi-0.6-py2.7.egg', '/usr/lib/python2.7/site-packages/Trac-0.11.6-py2.7.egg', '/usr/lib/python2.7/site-packages/wsgid-v0.6.0-py2.7.egg', '/usr/lib/python2.7/site-packages/clint-0.3.1-py2.7.egg', '/usr/lib/python2.7/site-packages/simplejson-2.4.0-py2.7-linux-x86_64.egg', '/usr/lib/python2.7/site-packages/requests-0.10.8-py2.7.egg', '/usr/lib/python2.7/site-packages/BeautifulSoup-3.2.1-py2.7.egg', '/usr/lib/python2.7/site-packages/Django-1.3-py2.7.egg', '/usr/lib/python2.7/site-packages/pyzmq-2.1.11-py2.7-linux-x86_64.egg', '/usr/lib/python2.7/site-packages/chardet-1.0.1-py2.7.egg', '/usr/lib/python2.7/site-packages/certifi-0.0.8-py2.7.egg', '/home/daltonmatos/projetos/contrib/dtc', '/usr/lib/python27.zip', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/lib/python2.7/site-packages', '/usr/lib/python2.7/site-packages/PIL', '/usr/lib/python2.7/site-packages/gst-0.10', '/usr/lib/python2.7/site-packages/gtk-2.0', '/usr/lib/python2.7/site-packages', '/usr/lib/portage/pym']
DEBUG:root:Error loading plugin: logger
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/plugnplay/__init__.py", line 116, in _import_module
imported_module = _import_from_python_package(_mod_name, mod_name)
File "/usr/lib/python2.7/site-packages/plugnplay/__init__.py", line 100, in _import_from_python_package
locals=locals(), fromlist=[module])
File "dtc/modules/logger.py", line 15, in <module>
from dtc.core.interfaces import loggable
ImportError: cannot import name loggable
DEBUG:root:execute modules
from plugnplay.
Testing here 4.0 works:
['',
'/usr/local/lib/python2.7/dist-packages/plugnplay-0.4-py2.7.egg',
'dtc/core/interfaces',
'dtc/core/interfaces/gui',
'dtc/modules']
4.0.1 don't work:
['dtc',
'dtc/core/interfaces',
'dtc/core',
'',
'/usr/local/lib/python2.7/dist-packages/plugnplay-0.4.1-py2.7.egg']
Error:
DEBUG:root:Error loading plugin: logger
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/plugnplay-0.4.1-py2.7.egg/plugnplay/__init__.py",
line 116, in _import_module
imported_module = _import_from_python_package(_mod_name, mod_name)
File "/usr/local/lib/python2.7/dist-packages/plugnplay-0.4.1-py2.7.egg/plugnplay/__init__.py",
line 100, in _import_from_python_package
locals=locals(), fromlist=[module])
File "dtc/modules/logger.py", line 15, in <module>
from dtc.core.interfaces import loggable
ImportError: cannot import name loggable
from plugnplay.
To be more especific:
from 4.0 (work)
sys.path.append(d)
to 4.0.1 (don't work)
if not _is_python_package(d):
sys.path.insert(0, d)
else:
sys.path.insert(0, dirname(d))
And also this (work):
sys.path.insert(0, d)
Probably "else" are problem:
sys.path.insert(0, dirname(d))
from plugnplay.
Yes. I thought about this else too. I also think the problem is there. Thanks.
from plugnplay.
More changes required :/
from plugnplay.
One test fails with this patch, I will take a look:
(plugnplay)daltonmatos@jetta plugnplay % py.test tests/*.py hugo/issue14 [c925eb4] [+1]
================================================================= test session starts =================================================================
platform linux2 -- Python 2.7.3 -- pytest-2.2.3
collected 22 items
tests/calling.py .
tests/common.py ..
tests/loading.py ......F...
tests/manager.py .....
tests/plugin-metaclass.py ....
====================================================================== FAILURES =======================================================================
_________________________________________________ LoadingTest.test_load_plugins_from_a_python_package _________________________________________________
self = <loading.LoadingTest testMethod=test_load_plugins_from_a_python_package>
def test_load_plugins_from_a_python_package(self):
"""
See github issue #6.
"""
from allinone.interface import AllInOne
import allinone
from allinone import interface
all_in_one_dir = join(self.basepath, 'allinone')
plugnplay.set_plugin_dirs(all_in_one_dir)
logger = Mock()
plugnplay.load_plugins(logger)
# Check that we did not try to load a plugin named __init__.
# See Github issue #9
self.assertEquals(0, logger.debug.call_count)
self.assertTrue(dirname(all_in_one_dir) in sys.path, "sys.path not modified correctly")
> self.assertEquals(len(AllInOne.implementors()), 1)
E AssertionError: 0 != 1
tests/loading.py:112: AssertionError
========================================================= 1 failed, 21 passed in 0.10 seconds =========================================================
(plugnplay)daltonmatos@jetta plugnplay % hugo/issue14 [c925eb4] [+1]
from plugnplay.
The test that fails is from the fix for issue #6.
from plugnplay.
Some interesting points:
dtc/Dtc.py
imports manually dtc.core.interfaces.module
this makes the from dtc.core.interfaces import module
that comes form dtc/modules/logger.py
work.
When we add from dtc.core.interfaces import loggable
inside dtc/Dtc.py
the load process of dtc/modules/logger.py
works perfectly.
And another detail: Inside logger.py
if we make from dtc.core.interfaces.loggable import Loggable
it works!!
Importing the package does not work, but importing the final Class works.
from plugnplay.
Hello @hugosenari, I just made a small fix. Could you please re-run your tests? Thanks!
from plugnplay.
This pass on my tests :)
Thanks again
from plugnplay.
This is great! I'm closing this issue, then. Thanks a lot!
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
- 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
- modules from different dirs but with same file name HOT 8
- 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.