eric6, PluginManager: added the '--disable-plugin=' option to disable plug-ins via the command line.

Sun, 22 Apr 2018 19:21:44 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 22 Apr 2018 19:21:44 +0200
changeset 6267
350655a6c85f
parent 6266
c7bc0e516cd6
child 6268
eb6e49388114

eric6, PluginManager: added the '--disable-plugin=' option to disable plug-ins via the command line.

APIs/Python3/eric6.api file | annotate | diff | comparison | revisions
Documentation/Help/source.qch file | annotate | diff | comparison | revisions
Documentation/Source/eric6.PluginManager.PluginManager.html file | annotate | diff | comparison | revisions
Documentation/Source/eric6.UI.UserInterface.html file | annotate | diff | comparison | revisions
PluginManager/PluginManager.py file | annotate | diff | comparison | revisions
UI/UserInterface.py file | annotate | diff | comparison | revisions
changelog file | annotate | diff | comparison | revisions
eric6.py file | annotate | diff | comparison | revisions
--- a/APIs/Python3/eric6.api	Sun Apr 22 14:01:39 2018 +0200
+++ b/APIs/Python3/eric6.api	Sun Apr 22 19:21:44 2018 +0200
@@ -3907,7 +3907,7 @@
 eric6.PluginManager.PluginManager.PluginManager.removePluginFromSysModules?4(pluginName, package, internalPackages)
 eric6.PluginManager.PluginManager.PluginManager.shutdown?7
 eric6.PluginManager.PluginManager.PluginManager.unloadPlugin?4(name)
-eric6.PluginManager.PluginManager.PluginManager?1(parent=None, doLoadPlugins=True, develPlugin=None)
+eric6.PluginManager.PluginManager.PluginManager?1(parent=None, disabledPlugins=None, doLoadPlugins=True, develPlugin=None)
 eric6.PluginManager.PluginRepositoryDialog.PluginRepositoryDialog.getDownloadedPlugins?4()
 eric6.PluginManager.PluginRepositoryDialog.PluginRepositoryDialog?1(parent=None)
 eric6.PluginManager.PluginRepositoryDialog.PluginRepositoryDownloadCleanup?4(quiet=False)
@@ -9928,7 +9928,7 @@
 eric6.UI.UserInterface.UserInterface.showReplaceFilesDialog?4(txt="", searchDir="", openFiles=False)
 eric6.UI.UserInterface.UserInterface.unregisterToolbar?4(name)
 eric6.UI.UserInterface.UserInterface.versionIsNewer?4(required, snapshot=None)
-eric6.UI.UserInterface.UserInterface?1(app, locale, splash, plugin, noOpenAtStartup, noCrashOpenAtStartup, disableCrashSession, restartArguments)
+eric6.UI.UserInterface.UserInterface?1(app, locale, splash, plugin, disabledPlugins, noOpenAtStartup, noCrashOpenAtStartup, disableCrashSession, restartArguments)
 eric6.Utilities.AutoSaver.AutoSaver.AUTOSAVE_IN?7
 eric6.Utilities.AutoSaver.AutoSaver.MAXWAIT?7
 eric6.Utilities.AutoSaver.AutoSaver.changeOccurred?4()
Binary file Documentation/Help/source.qch has changed
--- a/Documentation/Source/eric6.PluginManager.PluginManager.html	Sun Apr 22 14:01:39 2018 +0200
+++ b/Documentation/Source/eric6.PluginManager.PluginManager.html	Sun Apr 22 19:21:44 2018 +0200
@@ -219,7 +219,7 @@
 </table>
 <a NAME="PluginManager.__init__" ID="PluginManager.__init__"></a>
 <h4>PluginManager (Constructor)</h4>
-<b>PluginManager</b>(<i>parent=None, doLoadPlugins=True, develPlugin=None</i>)
+<b>PluginManager</b>(<i>parent=None, disabledPlugins=None, doLoadPlugins=True, develPlugin=None</i>)
 <p>
         Constructor
 </p><p>
@@ -230,17 +230,21 @@
         is the user plugin directory located inside the .eric6 directory
         of the users home directory.
 </p><dl>
-<dt><i>parent</i></dt>
+<dt><i>parent</i> (QObject)</dt>
 <dd>
-reference to the parent object (QObject)
-</dd><dt><i>doLoadPlugins=</i></dt>
+reference to the parent object
+</dd><dt><i>disabledPlugins</i> (list of str)</dt>
 <dd>
-flag indicating, that plugins should
-            be loaded (boolean)
-</dd><dt><i>develPlugin=</i></dt>
+list of plug-ins that have been disabled via
+            the command line parameters '--disable-plugin='
+</dd><dt><i>doLoadPlugins</i> (bool)</dt>
 <dd>
-filename of a plugin to be loaded for
-            development (string)
+flag indicating, that plug-ins should
+            be loaded
+</dd><dt><i>develPlugin</i> (str)</dt>
+<dd>
+filename of a plug-in to be loaded for
+            development
 </dd>
 </dl><dl>
 <dt>Raises <b>PluginModulesError</b>:</dt>
--- a/Documentation/Source/eric6.UI.UserInterface.html	Sun Apr 22 14:01:39 2018 +0200
+++ b/Documentation/Source/eric6.UI.UserInterface.html	Sun Apr 22 19:21:44 2018 +0200
@@ -829,40 +829,43 @@
 </table>
 <a NAME="UserInterface.__init__" ID="UserInterface.__init__"></a>
 <h4>UserInterface (Constructor)</h4>
-<b>UserInterface</b>(<i>app, locale, splash, plugin, noOpenAtStartup, noCrashOpenAtStartup, disableCrashSession, restartArguments</i>)
+<b>UserInterface</b>(<i>app, locale, splash, plugin, disabledPlugins, noOpenAtStartup, noCrashOpenAtStartup, disableCrashSession, restartArguments</i>)
 <p>
         Constructor
 </p><dl>
-<dt><i>app</i></dt>
+<dt><i>app</i> (E5Application)</dt>
 <dd>
-reference to the application object (E5Application)
-</dd><dt><i>locale</i></dt>
+reference to the application object
+</dd><dt><i>locale</i> (str)</dt>
 <dd>
-locale to be used by the UI (string)
-</dd><dt><i>splash</i></dt>
+locale to be used by the UI
+</dd><dt><i>splash</i> (UI.SplashScreen.SplashScreen)</dt>
 <dd>
 reference to the splashscreen
-            (UI.SplashScreen.SplashScreen)
-</dd><dt><i>plugin</i></dt>
+</dd><dt><i>plugin</i> (str)</dt>
 <dd>
-filename of a plugin to be loaded (used for plugin
+filename of a plug-in to be loaded (used for plugin
             development)
-</dd><dt><i>noOpenAtStartup</i></dt>
+</dd><dt><i>disabledPlugins</i> (list of str)</dt>
+<dd>
+list of plug-ins that have been disabled via
+            the command line parameters '--disable-plugin='
+</dd><dt><i>noOpenAtStartup</i> (bool)</dt>
 <dd>
 flag indicating that the open at startup option
-            should not be executed (boolean)
-</dd><dt><i>noCrashOpenAtStartup</i></dt>
+            should not be executed
+</dd><dt><i>noCrashOpenAtStartup</i> (bool)</dt>
 <dd>
 flag indicating to ignore any crash session
-            file found at statup (boolean)
-</dd><dt><i>disableCrashSession</i></dt>
+            file found at statup
+</dd><dt><i>disableCrashSession</i> (bool)</dt>
 <dd>
 flag indicating to disable the crash session
-            support (boolean)
-</dd><dt><i>restartArguments</i></dt>
+            support
+</dd><dt><i>restartArguments</i> (list of str)</dt>
 <dd>
 list of command line parameters to be used for
-            a restart (list of strings)
+            a restart
 </dd>
 </dl><a NAME="UserInterface.__TBMenuTriggered" ID="UserInterface.__TBMenuTriggered"></a>
 <h4>UserInterface.__TBMenuTriggered</h4>
--- a/PluginManager/PluginManager.py	Sun Apr 22 14:01:39 2018 +0200
+++ b/PluginManager/PluginManager.py	Sun Apr 22 19:21:44 2018 +0200
@@ -65,7 +65,8 @@
     pluginAboutToBeDeactivated = pyqtSignal(str, object)
     pluginDeactivated = pyqtSignal(str, object)
     
-    def __init__(self, parent=None, doLoadPlugins=True, develPlugin=None):
+    def __init__(self, parent=None, disabledPlugins=None, doLoadPlugins=True,
+                 develPlugin=None):
         """
         Constructor
         
@@ -76,11 +77,17 @@
         is the user plugin directory located inside the .eric6 directory
         of the users home directory.
         
-        @param parent reference to the parent object (QObject)
-        @keyparam doLoadPlugins flag indicating, that plugins should
-            be loaded (boolean)
-        @keyparam develPlugin filename of a plugin to be loaded for
-            development (string)
+        @param parent reference to the parent object
+        @type QObject
+        @param disabledPlugins list of plug-ins that have been disabled via
+            the command line parameters '--disable-plugin='
+        @type list of str
+        @param doLoadPlugins flag indicating, that plug-ins should
+            be loaded
+        @type bool
+        @param develPlugin filename of a plug-in to be loaded for
+            development
+        @type str
         @exception PluginPathError raised to indicate an invalid plug-in path
         @exception PluginModulesError raised to indicate the absence of
             plug-in modules
@@ -90,6 +97,10 @@
         self.__ui = parent
         self.__develPluginFile = develPlugin
         self.__develPluginName = None
+        if disabledPlugins is not None:
+            self.__disabledPlugins = disabledPlugins[:]
+        else:
+            self.__disabledPlugins = []
         
         self.__inactivePluginsKey = "PluginManager/InactivePlugins"
         
@@ -531,13 +542,16 @@
         """
         savedInactiveList = Preferences.Prefs.settings.value(
             self.__inactivePluginsKey)
+        inactiveList = self.__disabledPlugins[:]
+        if savedInactiveList is not None:
+            inactiveList += [p for p in savedInactiveList
+                             if p not in self.__disabledPlugins]
         if self.__develPluginName is not None and \
-           savedInactiveList is not None and \
-           self.__develPluginName in savedInactiveList:
-            savedInactiveList.remove(self.__develPluginName)
+           self.__develPluginName in inactiveList:
+            inactiveList.remove(self.__develPluginName)
         names = sorted(self.__inactiveModules.keys())
         for name in names:
-            if savedInactiveList is None or name not in savedInactiveList:
+            if name not in inactiveList:
                 self.activatePlugin(name)
         self.allPlugginsActivated.emit()
     
--- a/UI/UserInterface.py	Sun Apr 22 14:01:39 2018 +0200
+++ b/UI/UserInterface.py	Sun Apr 22 19:21:44 2018 +0200
@@ -164,25 +164,36 @@
     
     ErrorLogFileName = "eric6_error.log"
     
-    def __init__(self, app, locale, splash, plugin, noOpenAtStartup,
-                 noCrashOpenAtStartup, disableCrashSession, restartArguments):
+    def __init__(self, app, locale, splash, plugin, disabledPlugins,
+                 noOpenAtStartup, noCrashOpenAtStartup, disableCrashSession,
+                 restartArguments):
         """
         Constructor
         
-        @param app reference to the application object (E5Application)
-        @param locale locale to be used by the UI (string)
+        @param app reference to the application object
+        @type E5Application
+        @param locale locale to be used by the UI
+        @type str
         @param splash reference to the splashscreen
-            (UI.SplashScreen.SplashScreen)
-        @param plugin filename of a plugin to be loaded (used for plugin
+        @type UI.SplashScreen.SplashScreen
+        @param plugin filename of a plug-in to be loaded (used for plugin
             development)
+        @type str
+        @param disabledPlugins list of plug-ins that have been disabled via
+            the command line parameters '--disable-plugin='
+        @type list of str
         @param noOpenAtStartup flag indicating that the open at startup option
-            should not be executed (boolean)
+            should not be executed
+        @type bool
         @param noCrashOpenAtStartup flag indicating to ignore any crash session
-            file found at statup (boolean)
+            file found at statup
+        @type bool
         @param disableCrashSession flag indicating to disable the crash session
-            support (boolean)
+            support
+        @type bool
         @param restartArguments list of command line parameters to be used for
-            a restart (list of strings)
+            a restart
+        @type list of str
         """
         super(UserInterface, self).__init__()
         
@@ -196,6 +207,7 @@
         self.__noOpenAtStartup = noOpenAtStartup
         self.__noCrashOpenAtStartup = noCrashOpenAtStartup
         self.__disableCrashSession = disableCrashSession
+        self.__disabledPlugins = disabledPlugins[:]
         
         self.layoutType, self.embeddedShell, self.embeddedFileBrowser = \
             Preferences.getUILayout()
@@ -245,7 +257,8 @@
         
         # Initialize the Plugin Manager (Plugins are initialized later
         from PluginManager.PluginManager import PluginManager
-        self.pluginManager = PluginManager(self, develPlugin=plugin)
+        self.pluginManager = PluginManager(self, self.__disabledPlugins,
+                                           develPlugin=plugin)
         
         splash.showMessage(self.tr("Generating Main User Interface..."))
         
--- a/changelog	Sun Apr 22 14:01:39 2018 +0200
+++ b/changelog	Sun Apr 22 19:21:44 2018 +0200
@@ -2,6 +2,9 @@
 ----------
 Version 18.05:
 - bug fixes
+- General
+  -- added the '--disable-plugin=' option to disable plug-ins via the command
+     line
 - Code Style Checker
   -- added support for '# noqa' and '# NOQA' comments to suppress warnings
   -- extended the dialog to be able to define the number of blank lines
--- a/eric6.py	Sun Apr 22 14:01:39 2018 +0200
+++ b/eric6.py	Sun Apr 22 19:21:44 2018 +0200
@@ -17,7 +17,8 @@
 
 # generate list of arguments to be remembered for a restart
 restartArgsList = ["--no-splash", "--plugin", "--debug", "--config",
-                   "--pyqt4", "--settings", "--disable-crash"]
+                   "--pyqt4", "--settings", "--disable-crash",
+                   "--disable-plugin"]
 restartArgs = [arg for arg in sys.argv[1:]
                if arg.split("=", 1)[0] in restartArgsList]
 
@@ -114,20 +115,38 @@
     if res > 0:
         if "--no-splash" in sys.argv and \
                 sys.argv.index("--no-splash") < ddindex:
-            del sys.argv[sys.argv.index("--no-splash")]
+            sys.argv.remove("--no-splash")
+            ddindex -= 1
         if "--no-open" in sys.argv and sys.argv.index("--no-open") < ddindex:
-            del sys.argv[sys.argv.index("--no-open")]
+            sys.argv.remove("--no-open")
+            ddindex -= 1
         if "--no-crash" in sys.argv and sys.argv.index("--no-crash") < ddindex:
-            del sys.argv[sys.argv.index("--no-crash")]
+            sys.argv.remove("--no-crash")
         if "--disable-crash" in sys.argv and \
                 sys.argv.index("--disable-crash") < ddindex:
-            del sys.argv[sys.argv.index("--disable-crash")]
+            sys.argv.remove("--disable-crash")
+            ddindex -= 1
         if "--debug" in sys.argv and sys.argv.index("--debug") < ddindex:
-            del sys.argv[sys.argv.index("--debug")]
+            sys.argv.remove("--debug")
+            ddindex -= 1
+        for arg in sys.argv:
+            if arg.startswith("--config=") and \
+               sys.argv.index(arg) < ddindex:
+                sys.argv.remove(arg)
+                ddindex -= 1
+                break
         for arg in sys.argv:
-            if arg.startswith("--config="):
+            if arg.startswith("--plugin=") and \
+               sys.argv.index(arg) < ddindex:
                 sys.argv.remove(arg)
+                ddindex -= 1
                 break
+        for arg in sys.argv[:]:
+            if arg.startswith("--disable-plugin=") and \
+               sys.argv.index(arg) < ddindex:
+                sys.argv.remove(arg)
+                ddindex -= 1
+        
         if len(sys.argv) > 1:
             client.processArgs(sys.argv[1:])
         sys.exit(0)
@@ -247,6 +266,8 @@
          "don't open anything at startup except that given in command"),
         ("--no-crash", "don't check for a crash session file on startup"),
         ("--disable-crash", "disable the support for crash sessions"),
+        ("--disable-plugin=<plug-in name>",
+         "disable the given plug-in (may be repeated)"),
         ("--plugin=plugin-file",
          "load the given plugin file (plugin development)"),
         ("--pyqt4",
@@ -286,11 +307,12 @@
     
     # set the search path for icons
     Startup.initializeResourceSearchPath()
-
+    
     # generate and show a splash window, if not suppressed
     from UI.SplashScreen import SplashScreen, NoneSplashScreen
     if "--no-splash" in sys.argv and sys.argv.index("--no-splash") < ddindex:
-        del sys.argv[sys.argv.index("--no-splash")]
+        sys.argv.remove("--no-splash")
+        ddindex -= 1
         splash = NoneSplashScreen()
     elif not Preferences.getUI("ShowSplash"):
         splash = NoneSplashScreen()
@@ -313,22 +335,35 @@
     noopen = False
     nocrash = False
     disablecrash = False
+    disabledPlugins = []
     if "--no-open" in sys.argv and sys.argv.index("--no-open") < ddindex:
-        del sys.argv[sys.argv.index("--no-open")]
+        sys.argv.remove("--no-open")
+        ddindex -= 1
         noopen = True
     if "--no-crash" in sys.argv and sys.argv.index("--no-crash") < ddindex:
-        del sys.argv[sys.argv.index("--no-crash")]
+        sys.argv.remove("--no-crash")
+        ddindex -= 1
         nocrash = True
     if "--disable-crash" in sys.argv and \
             sys.argv.index("--disable-crash") < ddindex:
-        del sys.argv[sys.argv.index("--disable-crash")]
+        sys.argv.remove("--disable-crash")
+        ddindex -= 1
         disablecrash = True
+    for arg in sys.argv[:]:
+        if arg.startswith("--disable-plugin=") and \
+           sys.argv.index(arg) < ddindex:
+            # extract the plug-in name
+            pluginName = arg.replace("--disable-plugin=", "")
+            sys.argv.remove(arg)
+            ddindex -= 1
+            disabledPlugins.append(pluginName)
     for arg in sys.argv:
         if arg.startswith("--plugin=") and sys.argv.index(arg) < ddindex:
             import Utilities
             # extract the plugin development option
             pluginFile = arg.replace("--plugin=", "").replace('"', "")
             sys.argv.remove(arg)
+            ddindex -= 1
             pluginFile = os.path.expanduser(pluginFile)
             pluginFile = Utilities.normabspath(pluginFile)
             break
@@ -357,8 +392,8 @@
 
     splash.showMessage(
         QCoreApplication.translate("eric6", "Generating Main Window..."))
-    mainWindow = UserInterface(app, loc, splash, pluginFile, noopen, nocrash,
-                               disablecrash, restartArgs)
+    mainWindow = UserInterface(app, loc, splash, pluginFile, disabledPlugins,
+                               noopen, nocrash, disablecrash, restartArgs)
     app.lastWindowClosed.connect(app.quit)
     mainWindow.show()
     

eric ide

mercurial