11 import sys |
11 import sys |
12 import shutil |
12 import shutil |
13 import zipfile |
13 import zipfile |
14 import compileall |
14 import compileall |
15 import urllib.parse |
15 import urllib.parse |
|
16 import glob |
16 |
17 |
17 from PyQt4.QtCore import pyqtSlot, Qt, QDir, QFileInfo |
18 from PyQt4.QtCore import pyqtSlot, Qt, QDir, QFileInfo |
18 from PyQt4.QtGui import QWidget, QDialogButtonBox, QAbstractButton, QApplication, \ |
19 from PyQt4.QtGui import QWidget, QDialogButtonBox, QAbstractButton, QApplication, \ |
19 QDialog, QVBoxLayout |
20 QDialog, QVBoxLayout |
20 |
21 |
292 pluginSource = Utilities.decode(zip.read(pluginFileName))[0] |
293 pluginSource = Utilities.decode(zip.read(pluginFileName))[0] |
293 packageName = "" |
294 packageName = "" |
294 internalPackages = [] |
295 internalPackages = [] |
295 needsRestart = False |
296 needsRestart = False |
296 pyqtApi = 0 |
297 pyqtApi = 0 |
|
298 doCompile = True |
297 for line in pluginSource.splitlines(): |
299 for line in pluginSource.splitlines(): |
298 if line.startswith("packageName"): |
300 if line.startswith("packageName"): |
299 tokens = line.split("=") |
301 tokens = line.split("=") |
300 if tokens[0].strip() == "packageName" and \ |
302 if tokens[0].strip() == "packageName" and \ |
301 tokens[1].strip()[1:-1] != "__core__": |
303 tokens[1].strip()[1:-1] != "__core__": |
432 return False, \ |
438 return False, \ |
433 self.trUtf8("Unspecific exception installing plugin."), \ |
439 self.trUtf8("Unspecific exception installing plugin."), \ |
434 False |
440 False |
435 |
441 |
436 # now compile the plugins |
442 # now compile the plugins |
437 compileall.compile_dir(destination, quiet=True) |
443 if doCompile: |
|
444 compileall.compile_dir(destination, quiet=True) |
438 |
445 |
439 if not self.__external: |
446 if not self.__external: |
440 # now load and activate the plugin |
447 # now load and activate the plugin |
441 self.__pluginManager.loadPlugin(installedPluginName, destination, reload_) |
448 self.__pluginManager.loadPlugin(installedPluginName, destination, reload_) |
442 if activatePlugin: |
449 if activatePlugin: |
500 |
507 |
501 fnamec = "{0}c".format(pluginFile) |
508 fnamec = "{0}c".format(pluginFile) |
502 if os.path.exists(fnamec): |
509 if os.path.exists(fnamec): |
503 os.remove(fnamec) |
510 os.remove(fnamec) |
504 |
511 |
|
512 pluginDirCache = os.path.join(os.path.dirname(pluginFile), "__pycache__") |
|
513 if os.path.exists(pluginDirCache): |
|
514 pluginFileName = os.path.splitext(os.path.basename(pluginFile))[0] |
|
515 for fnameo in glob.glob( |
|
516 os.path.join(pluginDirCache, "{0}*.pyo".format(pluginFileName))): |
|
517 os.remove(fnameo) |
|
518 for fnamec in glob.glob( |
|
519 os.path.join(pluginDirCache, "{0}*.pyc".format(pluginFileName))): |
|
520 os.remove(fnamec) |
|
521 |
505 os.remove(pluginFile) |
522 os.remove(pluginFile) |
506 except (IOError, OSError, os.error): |
523 except (IOError, OSError, os.error): |
507 # ignore some exceptions |
524 # ignore some exceptions |
508 pass |
525 pass |
509 |
526 |