PluginManager/PluginInstallDialog.py

changeset 5588
6ba512d9f46a
parent 5389
9b1c800daff3
child 6048
82ad8ec9548c
equal deleted inserted replaced
5587:ea526b78ee6c 5588:6ba512d9f46a
289 self.tr( 289 self.tr(
290 """<p>The destination directory <b>{0}</b> is not """ 290 """<p>The destination directory <b>{0}</b> is not """
291 """writeable. Aborting...</p>""").format(destination), \ 291 """writeable. Aborting...</p>""").format(destination), \
292 False 292 False
293 293
294 zip = zipfile.ZipFile(archive, "r") 294 zipFile = zipfile.ZipFile(archive, "r")
295 295
296 # check, if the archive contains a valid plugin 296 # check, if the archive contains a valid plugin
297 pluginFound = False 297 pluginFound = False
298 pluginFileName = "" 298 pluginFileName = ""
299 for name in zip.namelist(): 299 for name in zipFile.namelist():
300 if self.__pluginManager.isValidPluginName(name): 300 if self.__pluginManager.isValidPluginName(name):
301 installedPluginName = name[:-3] 301 installedPluginName = name[:-3]
302 pluginFound = True 302 pluginFound = True
303 pluginFileName = name 303 pluginFileName = name
304 break 304 break
309 """<p>The file <b>{0}</b> is not a valid plugin """ 309 """<p>The file <b>{0}</b> is not a valid plugin """
310 """ZIP-archive. Aborting...</p>""").format(archive), \ 310 """ZIP-archive. Aborting...</p>""").format(archive), \
311 False 311 False
312 312
313 # parse the plugin module's plugin header 313 # parse the plugin module's plugin header
314 pluginSource = Utilities.decode(zip.read(pluginFileName))[0] 314 pluginSource = Utilities.decode(zipFile.read(pluginFileName))[0]
315 packageName = "" 315 packageName = ""
316 internalPackages = [] 316 internalPackages = []
317 needsRestart = False 317 needsRestart = False
318 pyqtApi = 0 318 pyqtApi = 0
319 doCompile = True 319 doCompile = True
409 # now do the installation 409 # now do the installation
410 self.__installedDirs = [] 410 self.__installedDirs = []
411 self.__installedFiles = [] 411 self.__installedFiles = []
412 try: 412 try:
413 if packageName != "None": 413 if packageName != "None":
414 namelist = sorted(zip.namelist()) 414 namelist = sorted(zipFile.namelist())
415 tot = len(namelist) 415 tot = len(namelist)
416 prog = 0 416 prog = 0
417 self.progress.setMaximum(tot) 417 self.progress.setMaximum(tot)
418 QApplication.processEvents() 418 QApplication.processEvents()
419 for name in namelist: 419 for name in namelist:
434 # it is a file 434 # it is a file
435 d = os.path.dirname(outname) 435 d = os.path.dirname(outname)
436 if not os.path.exists(d): 436 if not os.path.exists(d):
437 self.__makedirs(d) 437 self.__makedirs(d)
438 f = open(outname, "wb") 438 f = open(outname, "wb")
439 f.write(zip.read(name)) 439 f.write(zipFile.read(name))
440 f.close() 440 f.close()
441 self.__installedFiles.append(outname) 441 self.__installedFiles.append(outname)
442 self.progress.setValue(tot) 442 self.progress.setValue(tot)
443 # now compile user interface files 443 # now compile user interface files
444 compileUiFiles(os.path.join(destination, packageName), True) 444 compileUiFiles(os.path.join(destination, packageName), True)
473 self.tr("Unspecific exception installing plugin."), \ 473 self.tr("Unspecific exception installing plugin."), \
474 False 474 False
475 475
476 # now compile the plugins 476 # now compile the plugins
477 if doCompile: 477 if doCompile:
478 dir = os.path.join(destination, packageName) 478 dirName = os.path.join(destination, packageName)
479 files = os.path.join(destination, pluginFileName) 479 files = os.path.join(destination, pluginFileName)
480 if sys.version_info[0] == 2: 480 if sys.version_info[0] == 2:
481 dir = dir.encode(sys.getfilesystemencoding()) 481 dirName = dirName.encode(sys.getfilesystemencoding())
482 files = files.encode(sys.getfilesystemencoding()) 482 files = files.encode(sys.getfilesystemencoding())
483 os.path.join_unicode = False 483 os.path.join_unicode = False
484 compileall.compile_dir(dir, quiet=True) 484 compileall.compile_dir(dirName, quiet=True)
485 compileall.compile_file(files, quiet=True) 485 compileall.compile_file(files, quiet=True)
486 os.path.join_unicode = True 486 os.path.join_unicode = True
487 487
488 if not self.__external: 488 if not self.__external:
489 # now load and activate the plugin 489 # now load and activate the plugin

eric ide

mercurial