Wed, 21 Aug 2013 19:49:48 +0200
Fixed an issue uninstalling a plug-in leaving residual files.
(grafted from 2de1955c6391292dde405e13ad41f2a0669fc4af)
PluginManager/PluginInstallDialog.py | file | annotate | diff | comparison | revisions | |
PluginManager/PluginUninstallDialog.py | file | annotate | diff | comparison | revisions |
--- a/PluginManager/PluginInstallDialog.py Mon Aug 19 11:12:21 2013 +0200 +++ b/PluginManager/PluginInstallDialog.py Wed Aug 21 19:49:48 2013 +0200 @@ -13,6 +13,7 @@ import zipfile import compileall import urllib.parse +import glob from PyQt4.QtCore import pyqtSlot, Qt, QDir, QFileInfo from PyQt4.QtGui import QWidget, QDialogButtonBox, QAbstractButton, QApplication, \ @@ -294,6 +295,7 @@ internalPackages = [] needsRestart = False pyqtApi = 0 + doCompile = True for line in pluginSource.splitlines(): if line.startswith("packageName"): tokens = line.split("=") @@ -317,6 +319,10 @@ pyqtApi = int(tokens[1].strip()) except ValueError: pass + elif line.startswith("doNotCompile"): + tokens = line.split("=") + if tokens[1].strip() == "True": + doCompile = False elif line.startswith("# End-Of-Header"): break @@ -434,7 +440,8 @@ False # now compile the plugins - compileall.compile_dir(destination, quiet=True) + if doCompile: + compileall.compile_dir(destination, quiet=True) if not self.__external: # now load and activate the plugin @@ -502,6 +509,16 @@ if os.path.exists(fnamec): os.remove(fnamec) + pluginDirCache = os.path.join(os.path.dirname(pluginFile), "__pycache__") + if os.path.exists(pluginDirCache): + pluginFileName = os.path.splitext(os.path.basename(pluginFile))[0] + for fnameo in glob.glob( + os.path.join(pluginDirCache, "{0}*.pyo".format(pluginFileName))): + os.remove(fnameo) + for fnamec in glob.glob( + os.path.join(pluginDirCache, "{0}*.pyc".format(pluginFileName))): + os.remove(fnamec) + os.remove(pluginFile) except (IOError, OSError, os.error): # ignore some exceptions
--- a/PluginManager/PluginUninstallDialog.py Mon Aug 19 11:12:21 2013 +0200 +++ b/PluginManager/PluginUninstallDialog.py Wed Aug 21 19:49:48 2013 +0200 @@ -11,6 +11,7 @@ import os import imp import shutil +import glob from PyQt4.QtCore import pyqtSlot, pyqtSignal from PyQt4.QtGui import QWidget, QDialog, QDialogButtonBox, QVBoxLayout @@ -143,6 +144,16 @@ if os.path.exists(fnamec): os.remove(fnamec) + pluginDirCache = os.path.join(os.path.dirname(pluginFile), "__pycache__") + if os.path.exists(pluginDirCache): + pluginFileName = os.path.splitext(os.path.basename(pluginFile))[0] + for fnameo in glob.glob( + os.path.join(pluginDirCache, "{0}*.pyo".format(pluginFileName))): + os.remove(fnameo) + for fnamec in glob.glob( + os.path.join(pluginDirCache, "{0}*.pyc".format(pluginFileName))): + os.remove(fnamec) + os.remove(pluginFile) except OSError as err: E5MessageBox.critical(self,