Giter Club home page Giter Club logo

Comments (13)

daltonmatos avatar daltonmatos commented on August 26, 2024

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.

daltonmatos avatar daltonmatos commented on August 26, 2024

I just updated the code and now can reproduce the problem. I will take a look.

from plugnplay.

daltonmatos avatar daltonmatos commented on August 26, 2024

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.

hugosenari avatar hugosenari commented on August 26, 2024

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.

hugosenari avatar hugosenari commented on August 26, 2024

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.

daltonmatos avatar daltonmatos commented on August 26, 2024

Yes. I thought about this else too. I also think the problem is there. Thanks.

from plugnplay.

hugosenari avatar hugosenari commented on August 26, 2024

More changes required :/

from plugnplay.

daltonmatos avatar daltonmatos commented on August 26, 2024

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.

daltonmatos avatar daltonmatos commented on August 26, 2024

The test that fails is from the fix for issue #6.

from plugnplay.

daltonmatos avatar daltonmatos commented on August 26, 2024

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.

daltonmatos avatar daltonmatos commented on August 26, 2024

Hello @hugosenari, I just made a small fix. Could you please re-run your tests? Thanks!

from plugnplay.

hugosenari avatar hugosenari commented on August 26, 2024

This pass on my tests :)
Thanks again

from plugnplay.

daltonmatos avatar daltonmatos commented on August 26, 2024

This is great! I'm closing this issue, then. Thanks a lot!

from plugnplay.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.