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

Add a check_compatibility method to PluginMixin #4641

Closed
goanpeca opened this issue Jun 23, 2017 · 11 comments
Closed

Add a check_compatibility method to PluginMixin #4641

goanpeca opened this issue Jun 23, 2017 · 11 comments
Assignees
Milestone

Comments

@goanpeca
Copy link
Member

goanpeca commented Jun 23, 2017

On 3.x

https://github.com/spyder-ide/spyder/blob/master/spyder/api/plugins.py

Create a new method for class SpyderPluginWidget(PluginWidget):

# For instance Qt4 can be checked here or other things...

    def check_compatibility(self):
        """
        This method can be implemented to check compatibility of plugin on a given os.

        `message` should give information in case of non compatibility:
        For example: 'This plugin does not work with Qt4'
        """
        message = ''
        valid = True
        return valid, message

On top of this we need to change the loading of plugins to load it only if compatible

@ccordoba12, @andfoy, @rlaverde comments, ideas?

@goanpeca goanpeca added this to the v3.2 milestone Jun 23, 2017
@andfoy
Copy link
Member

andfoy commented Jun 23, 2017

I was thinking that in some cases, this function might be not called at all, for example, on Spyder Terminal we don't even expose the Plugin at all if the current Qt backend if different from PyQt5 (spyder_terminal/init.py)

@goanpeca
Copy link
Member Author

in that case maybe we dont need such method ?

@andfoy
Copy link
Member

andfoy commented Jun 23, 2017

Maybe, it should be defined on each plugin's __init__.py

@goanpeca
Copy link
Member Author

goanpeca commented Jun 23, 2017

What I don't like here, is that we have an orphan PLUGIN_CLASS, I would make it None at least

from qtpy import PYQT5

PLUGIN_CLASS = None
if PYQT5:
    from .terminalplugin import TerminalPlugin as PLUGIN_CLASS

@andfoy
Copy link
Member

andfoy commented Jun 23, 2017

What I don't like here, is that we have an orphan PLUGIN_CLASS, I would make it None at least

To be changed on 3.1.2!

@ccordoba12
Copy link
Member

@andfoy, the idea is to make changes in spyder-terminal so that is a message is shown when people try to run it with PyQt4.

So its compatibility is to depend on PyQt5.

@goanpeca
Copy link
Member Author

PLUGIN_COMPATIBLE = (True, '') then? and check that in spyder

In the case of spyder-terminal check for Qt4 and build a message accordingly

@andfoy
Copy link
Member

andfoy commented Jun 23, 2017

So should we remove that try... except block instead?

@goanpeca
Copy link
Member Author

So should we remove that try... except block instead?

Probably

@ccordoba12
Copy link
Member

Yes, that's the idea, and use check_compatibility instead.

But @goanpeca, then check_compatibility should be the first thing to run in register_plugin, right? That way, if compatibility is not satisfied, the plugin would not continue the registering process, and will show a (non-modal) QMessageBox instead.

@ccordoba12
Copy link
Member

Sorry, check_compatibility has to be called in the __init__ method of SpyderPluginWidget:

https://github.com/spyder-ide/spyder/blob/3.x/spyder/plugins/__init__.py#L539

That way it will be run every time a plugin is created.

@dalthviz, please add the check_compatibility method to SpyderPluginWidget with @goanpeca suggestion, then call it in its __init__ method.

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

No branches or pull requests

4 participants