def storeData(self): """ Public method to store the entered/modified data. """ self.project.debugProperties["INTERPRETER"] = \ self.interpreterPicker.text() if not self.project.debugProperties["INTERPRETER"]: if self.project.pdata["PROGLANGUAGE"][0] in \ ["Python", "Python2", "Python3"]: self.project.debugProperties["INTERPRETER"] = sys.executable elif self.project.pdata["PROGLANGUAGE"][0] == "Ruby": self.project.debugProperties["INTERPRETER"] = "/usr/bin/ruby" self.project.debugProperties["DEBUGCLIENT"] = \ self.debugClientPicker.text() if not self.project.debugProperties["DEBUGCLIENT"]: if self.project.pdata["PROGLANGUAGE"][0] in ["Python", "Python2"]: debugClient = os.path.join( getConfig('ericDir'), "DebugClients", "Python", "DebugClient.py") elif self.project.pdata["PROGLANGUAGE"][0] == "Python3": debugClient = os.path.join( getConfig('ericDir'), "DebugClients", "Python3", "DebugClient.py") elif self.project.pdata["PROGLANGUAGE"][0] == "Ruby": debugClient = os.path.join( getConfig('ericDir'), "DebugClients", "Ruby", "DebugClient.rb") else: debugClient = "" self.project.debugProperties["DEBUGCLIENT"] = debugClient self.project.debugProperties["ENVIRONMENTOVERRIDE"] = \ self.debugEnvironmentOverrideCheckBox.isChecked() self.project.debugProperties["ENVIRONMENTSTRING"] = \ self.debugEnvironmentEdit.text() self.project.debugProperties["REMOTEDEBUGGER"] = \ self.remoteDebuggerGroup.isChecked() self.project.debugProperties["REMOTEHOST"] = \ self.remoteHostEdit.text() self.project.debugProperties["REMOTECOMMAND"] = \ self.remoteCommandEdit.text() self.project.debugProperties["PATHTRANSLATION"] = \ self.pathTranslationGroup.isChecked() self.project.debugProperties["REMOTEPATH"] = \ self.translationRemoteEdit.text() self.project.debugProperties["LOCALPATH"] = \ self.translationLocalEdit.text() self.project.debugProperties["CONSOLEDEBUGGER"] = \ self.consoleDebuggerGroup.isChecked() self.project.debugProperties["CONSOLECOMMAND"] = \ self.consoleCommandEdit.text() self.project.debugProperties["REDIRECT"] = \ self.redirectCheckBox.isChecked() self.project.debugProperties["NOENCODING"] = \ self.noEncodingCheckBox.isChecked() self.project.debugPropertiesLoaded = True
def storeData(self): """ Public method to store the entered/modified data. """ self.project.debugProperties["INTERPRETER"] = \ self.interpreterEdit.text() if not self.project.debugProperties["INTERPRETER"]: if self.project.pdata["PROGLANGUAGE"][0] in \ ["Python", "Python2", "Python3"]: self.project.debugProperties["INTERPRETER"] = sys.executable elif self.project.pdata["PROGLANGUAGE"][0] == "Ruby": self.project.debugProperties["INTERPRETER"] = "/usr/bin/ruby" self.project.debugProperties["DEBUGCLIENT"] = \ self.debugClientEdit.text() if not self.project.debugProperties["DEBUGCLIENT"]: if self.project.pdata["PROGLANGUAGE"][0] in ["Python", "Python2"]: debugClient = os.path.join(getConfig('ericDir'), "DebugClients", "Python", "DebugClient.py") elif self.project.pdata["PROGLANGUAGE"][0] == "Python3": debugClient = os.path.join(getConfig('ericDir'), "DebugClients", "Python3", "DebugClient.py") elif self.project.pdata["PROGLANGUAGE"][0] == "Ruby": debugClient = os.path.join(getConfig('ericDir'), "DebugClients", "Ruby", "DebugClient.rb") else: debugClient = "" self.project.debugProperties["DEBUGCLIENT"] = debugClient self.project.debugProperties["ENVIRONMENTOVERRIDE"] = \ self.debugEnvironmentOverrideCheckBox.isChecked() self.project.debugProperties["ENVIRONMENTSTRING"] = \ self.debugEnvironmentEdit.text() self.project.debugProperties["REMOTEDEBUGGER"] = \ self.remoteDebuggerGroup.isChecked() self.project.debugProperties["REMOTEHOST"] = \ self.remoteHostEdit.text() self.project.debugProperties["REMOTECOMMAND"] = \ self.remoteCommandEdit.text() self.project.debugProperties["PATHTRANSLATION"] = \ self.pathTranslationGroup.isChecked() self.project.debugProperties["REMOTEPATH"] = \ self.translationRemoteEdit.text() self.project.debugProperties["LOCALPATH"] = \ self.translationLocalEdit.text() self.project.debugProperties["CONSOLEDEBUGGER"] = \ self.consoleDebuggerGroup.isChecked() self.project.debugProperties["CONSOLECOMMAND"] = \ self.consoleCommandEdit.text() self.project.debugProperties["REDIRECT"] = \ self.redirectCheckBox.isChecked() self.project.debugProperties["NOENCODING"] = \ self.noEncodingCheckBox.isChecked() self.project.debugPropertiesLoaded = True
def removePluginDirectories(): """ Remove the plug-in directories. """ pathsToRemove = [] globalPluginsDir = os.path.join(getConfig('mdir'), "eric6plugins") if os.path.exists(globalPluginsDir): pathsToRemove.append(globalPluginsDir) localPluginsDir = os.path.join(getConfigDir(), "eric6plugins") if os.path.exists(localPluginsDir): pathsToRemove.append(localPluginsDir) if pathsToRemove: print("Found these plug-in directories") for path in pathsToRemove: print(" - {0}".format(path)) answer = "c" while answer not in ["y", "Y", "n", "N", ""]: if sys.version_info[0] == 2: answer = raw_input( "Shall these directories be removed (y/N)? ") else: answer = input("Shall these directories be removed (y/N)? ") if answer in ["y", "Y"]: for path in pathsToRemove: shutil.rmtree(path)
def __installEric6Doc(self, engine): """ Private method to install/update the eric6 help documentation. @param engine reference to the help engine (QHelpEngineCore) @return flag indicating success (boolean) """ versionKey = "eric6_ide" info = engine.customValue(versionKey, "") lst = info.split('|') dt = QDateTime() if len(lst) and lst[0]: dt = QDateTime.fromString(lst[0], Qt.ISODate) qchFile = "" if len(lst) == 2: qchFile = lst[1] docsPath = QDir(getConfig("ericDocDir") + QDir.separator() + "Help") files = docsPath.entryList(["*.qch"]) if not files: engine.setCustomValue(versionKey, QDateTime().toString(Qt.ISODate) + '|') return False for f in files: if f == "source.qch": fi = QFileInfo(docsPath.absolutePath() + QDir.separator() + f) namespace = QHelpEngineCore.namespaceName( fi.absoluteFilePath()) if not namespace: continue if (dt.isValid() and namespace in engine.registeredDocumentations() and (fi.lastModified().toString(Qt.ISODate) == dt.toString(Qt.ISODate)) and qchFile == fi.absoluteFilePath()): return False if namespace in engine.registeredDocumentations(): engine.unregisterDocumentation(namespace) if not engine.registerDocumentation(fi.absoluteFilePath()): self.errorMessage.emit( self.tr( """<p>The file <b>{0}</b> could not be""" """ registered. <br/>Reason: {1}</p>""").format( fi.absoluteFilePath, engine.error())) return False engine.setCustomValue( versionKey, fi.lastModified().toString(Qt.ISODate) + '|' + fi.absoluteFilePath()) return True return False
def __startPluginInstall(self): """ Private slot to start the eric6 plugin installation dialog. """ proc = QProcess() applPath = os.path.join(getConfig("ericDir"), "eric6_plugininstall.py") args = [] args.append(applPath) args += self.cw.getDownloadedPlugins() if ( not os.path.isfile(applPath) or not proc.startDetached(sys.executable, args) ): E5MessageBox.critical( self, self.tr('Process Generation Error'), self.tr( '<p>Could not start the process.<br>' 'Ensure that it is available as <b>{0}</b>.</p>' ).format(applPath), self.tr('OK')) self.close()
def removePluginDirectories(): """ Remove the plug-in directories. """ pathsToRemove = [] globalPluginsDir = os.path.join(getConfig('mdir'), "eric6plugins") if os.path.exists(globalPluginsDir): pathsToRemove.append(globalPluginsDir) localPluginsDir = os.path.join(getConfigDir(), "eric6plugins") if os.path.exists(localPluginsDir): pathsToRemove.append(localPluginsDir) if pathsToRemove: print("Found these plug-in directories") for path in pathsToRemove: print(" - {0}".format(path)) answer = "c" while answer not in ["y", "Y", "n", "N", ""]: if sys.version_info[0] == 2: answer = raw_input( "Shall these directories be removed (y/N)? ") else: answer = input( "Shall these directories be removed (y/N)? ") if answer in ["y", "Y"]: for path in pathsToRemove: shutil.rmtree(path)
def __startProc(self, applName, *applArgs): """ Private method to start an eric6 application. @param applName name of the eric6 application script (string) @param *applArgs variable list of application arguments """ proc = QProcess() applPath = os.path.join(getConfig("ericDir"), applName) args = [] args.append(applPath) for arg in applArgs: args.append(arg) if not os.path.isfile(applPath) or \ not proc.startDetached(sys.executable, args): E5MessageBox.critical( self, self.tr('Process Generation Error'), self.tr( '<p>Could not start the process.<br>' 'Ensure that it is available as <b>{0}</b>.</p>' ).format(applPath), self.tr('OK'))
def __installEric6Doc(self, engine): """ Private method to install/update the eric6 help documentation. @param engine reference to the help engine (QHelpEngineCore) @return flag indicating success (boolean) """ versionKey = "eric6_ide" info = engine.customValue(versionKey, "") lst = info.split('|') dt = QDateTime() if len(lst) and lst[0]: dt = QDateTime.fromString(lst[0], Qt.ISODate) qchFile = "" if len(lst) == 2: qchFile = lst[1] docsPath = QDir(getConfig("ericDocDir") + QDir.separator() + "Help") files = docsPath.entryList(["*.qch"]) if not files: engine.setCustomValue( versionKey, QDateTime().toString(Qt.ISODate) + '|') return False for f in files: if f == "source.qch": fi = QFileInfo(docsPath.absolutePath() + QDir.separator() + f) if dt.isValid() and \ fi.lastModified().toString(Qt.ISODate) == \ dt.toString(Qt.ISODate) and \ qchFile == fi.absoluteFilePath(): return False namespace = QHelpEngineCore.namespaceName( fi.absoluteFilePath()) if not namespace: continue if namespace in engine.registeredDocumentations(): engine.unregisterDocumentation(namespace) if not engine.registerDocumentation(fi.absoluteFilePath()): self.errorMessage.emit( self.tr( """<p>The file <b>{0}</b> could not be""" """ registered. <br/>Reason: {1}</p>""") .format(fi.absoluteFilePath, engine.error()) ) return False engine.setCustomValue( versionKey, fi.lastModified().toString(Qt.ISODate) + '|' + fi.absoluteFilePath()) return True return False
def __startProc(self, applName, *applArgs): """ Private method to start an eric6 application. @param applName name of the eric6 application script (string) @param *applArgs variable list of application arguments """ proc = QProcess() applPath = os.path.join(getConfig("ericDir"), applName) args = [] args.append(applPath) args.append("--config={0}".format(Utilities.getConfigDir())) if self.settingsDir: args.append("--settings={0}".format(self.settingsDir)) for arg in applArgs: args.append(arg) if ( not os.path.isfile(applPath) or not proc.startDetached(sys.executable, args) ): E5MessageBox.critical( self, self.tr('Process Generation Error'), self.tr( '<p>Could not start the process.<br>' 'Ensure that it is available as <b>{0}</b>.</p>' ).format(applPath), self.tr('OK'))
def exeDisplayData(): """ Public method to support the display of some executable info. @return dictionary containing the data to query the presence of the executable """ exe = 'eric6_api' if Utilities.isWindowsPlatform(): exe = os.path.join(getConfig("bindir"), exe + '.bat') data = { "programEntry": True, "header": QCoreApplication.translate("EricapiPlugin", "Eric6 API File Generator"), "exe": exe, "versionCommand": '--version', "versionStartsWith": 'eric6_', "versionPosition": -3, "version": "", "versionCleanup": None, } return data
def initializeResourceSearchPath(): """ Module function to initialize the default mime source factory. """ import Preferences defaultIconPaths = [ os.path.join(getConfig('ericIconDir'), "default"), os.path.join(getConfig('ericIconDir'), "default", "languages"), ] iconPaths = Preferences.getIcons("Path") for iconPath in iconPaths: if iconPath: UI.PixmapCache.addSearchPath(iconPath) for defaultIconPath in defaultIconPaths: if defaultIconPath not in iconPaths: UI.PixmapCache.addSearchPath(defaultIconPath)
def exeDisplayDataList(): """ Public method to support the display of some executable info. @return dictionary containing the data to query the presence of the executable """ dataList = [] # 1. eric6_doc exe = 'eric6_doc' if Utilities.isWindowsPlatform(): exe = os.path.join(getConfig("bindir"), exe + '.bat') dataList.append({ "programEntry": True, "header": QCoreApplication.translate( "EricdocPlugin", "Eric6 Documentation Generator"), "exe": exe, "versionCommand": '--version', "versionStartsWith": 'eric6_', "versionPosition": -3, "version": "", "versionCleanup": None, }) # 2. Qt Help Generator exe = os.path.join(Utilities.getQtBinariesPath(), 'qhelpgenerator') if Utilities.isWindowsPlatform(): exe += '.exe' dataList.append({ "programEntry": True, "header": QCoreApplication.translate( "EricdocPlugin", "Qt Help Tools"), "exe": exe, "versionCommand": '-v', "versionStartsWith": 'Qt', "versionPosition": -1, "version": "", "versionCleanup": (0, -1), }) # 3. Qt Collection Generator exe = os.path.join(Utilities.getQtBinariesPath(), 'qcollectiongenerator') if Utilities.isWindowsPlatform(): exe += '.exe' dataList.append({ "programEntry": True, "header": QCoreApplication.translate( "EricdocPlugin", "Qt Help Tools"), "exe": exe, "versionCommand": '-v', "versionStartsWith": 'Qt', "versionPosition": -1, "version": "", "versionCleanup": (0, -1), }) return dataList
def __init__(self): """ Constructor """ ericPic = QPixmap(os.path.join(getConfig("ericPixDir"), "ericSplash.png")) self.labelAlignment = Qt.Alignment(Qt.AlignBottom | Qt.AlignRight | Qt.AlignAbsolute) super(SplashScreen, self).__init__(ericPic) self.show() QApplication.flush()
def uninstallMacAppBundle(): """ Uninstall the macOS application bundle. """ if os.path.exists("/Developer/Applications/Eric6"): shutil.rmtree("/Developer/Applications/Eric6") try: macAppBundlePath = getConfig("macAppBundlePath") macAppBundleName = getConfig("macAppBundleName") except AttributeError: macAppBundlePath = defaultMacAppBundlePath macAppBundleName = defaultMacAppBundleName for bundlePath in [os.path.join(defaultMacAppBundlePath, macAppBundleName), os.path.join(macAppBundlePath, macAppBundleName), ]: if os.path.exists(bundlePath): shutil.rmtree(bundlePath)
def __newUiForm(self, path): """ Private slot to handle the New Form menu action for Qt-related projects. @param path full directory path for the new form file (string) """ selectedForm, ok = QInputDialog.getItem(None, self.tr("New Form"), self.tr("Select a form type:"), self.templateTypes4, 0, False) if not ok or not selectedForm: # user pressed cancel return templateIndex = self.templateTypes4.index(selectedForm) templateFile = os.path.join(getConfig('ericTemplatesDir'), self.templates4[templateIndex]) fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( self, self.tr("New Form"), path, self.tr("Qt User-Interface Files (*.ui);;All Files (*)"), "", E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) if not fname: # user aborted or didn't enter a filename return ext = QFileInfo(fname).suffix() if not ext: ex = selectedFilter.split("(*")[1].split(")")[0] if ex: fname += ex if os.path.exists(fname): res = E5MessageBox.yesNo( self, self.tr("New Form"), self.tr("The file already exists! Overwrite it?"), icon=E5MessageBox.Warning) if not res: # user selected to not overwrite return try: shutil.copy(templateFile, fname) except IOError as e: E5MessageBox.critical( self, self.tr("New Form"), self.tr( "<p>The new form file <b>{0}</b> could not be created.<br>" "Problem: {1}</p>").format(fname, str(e))) return self.project.appendFile(fname) self.designerFile.emit(fname)
def __init__(self): """ Constructor """ ericPic = QPixmap( os.path.join(getConfig('ericPixDir'), 'ericSplash.png')) self.labelAlignment = Qt.Alignment(Qt.AlignBottom | Qt.AlignRight | Qt.AlignAbsolute) super(SplashScreen, self).__init__(ericPic) self.show() QApplication.flush()
def windowsDesktopEntries(): """ Function to generate data for the Windows Desktop links. @return list of tuples containing the desktop link name, the link target and the icon target @rtype list of tuples of (str, str, str) """ majorVersion, minorVersion = sys.version_info[:2] entriesTemplates = [ ("eric6 (Python {0}.{1}).lnk", os.path.join(getConfig("bindir"), "eric6.cmd"), os.path.join(getConfig("ericPixDir"), "eric6.ico")), ("eric6 Browser (Python {0}.{1}).lnk", os.path.join(getConfig("bindir"), "eric6_browser.cmd"), os.path.join(getConfig("ericPixDir"), "ericWeb48.ico")), ] return [(e[0].format(majorVersion, minorVersion), e[1], e[2]) for e in entriesTemplates]
def __loadStarted(self, browser): """ Private method to handle the loadStarted signal. @param browser reference to the web browser @type WebBrowserView """ index = self.indexOf(browser) anim = self.animationLabel( index, os.path.join(getConfig("ericPixDir"), "loading.gif"), 100) if not anim: loading = QIcon( os.path.join(getConfig("ericPixDir"), "loading.gif")) self.setTabIcon(index, loading) else: self.setTabIcon(index, QIcon()) self.setTabText(index, self.tr("Loading...")) self.setTabToolTip(index, self.tr("Loading...")) self.showMessage.emit(self.tr("Loading...")) self.__mainWindow.setLoadingActions(True)
def __loadStarted(self): """ Private method to handle the loadStarted signal. """ browser = self.sender() if browser is not None: index = self.indexOf(browser) anim = self.animationLabel( index, os.path.join(getConfig("ericPixDir"), "loading.gif"), 100) if not anim: loading = QIcon( os.path.join(getConfig("ericPixDir"), "loading.gif")) self.setTabIcon(index, loading) else: self.setTabIcon(index, QIcon()) self.setTabText(index, self.tr("Loading...")) self.setTabToolTip(index, self.tr("Loading...")) self.showMessage.emit(self.tr("Loading...")) self.__mainWindow.setLoadingActions(True)
def on_cssButton_clicked(self): """ Private slot to select a css style sheet. """ cssFile = E5FileDialog.getOpenFileName( self, self.tr("Select CSS style sheet"), getConfig('ericCSSDir'), self.tr("Style sheet (*.css);;All files (*)")) if cssFile: # make it relative, if it is in a subdirectory of the project path cf = Utilities.toNativeSeparators(cssFile) cf = self.project.getRelativePath(cf) self.cssEdit.setText(cf)
def __loadStarted(self): """ Private method to handle the loadStarted signal. """ browser = self.sender() if browser is not None: index = self.indexOf(browser) anim = self.animationLabel( index, os.path.join(getConfig("ericPixDir"), "loading.gif"), 100) if not anim: loading = QIcon(os.path.join(getConfig("ericPixDir"), "loading.gif")) self.setTabIcon(index, loading) else: self.setTabIcon(index, QIcon()) self.setTabText(index, self.tr("Loading...")) self.setTabToolTip(index, self.tr("Loading...")) self.showMessage.emit(self.tr("Loading...")) self.__mainWindow.setLoadingActions(True)
def storeData(self): """ Public method to store the entered/modified data. """ self.project.debugProperties["VIRTUALENV"] = ( self.venvComboBox.currentText()) self.project.debugProperties["DEBUGCLIENT"] = ( self.debugClientPicker.text(toNative=False)) if not self.project.debugProperties["DEBUGCLIENT"]: if self.project.pdata["PROGLANGUAGE"] in [ "Python", "Python2", "Python3" ]: debugClient = os.path.join(getConfig('ericDir'), "DebugClients", "Python", "DebugClient.py") else: debugClient = "" self.project.debugProperties["DEBUGCLIENT"] = debugClient self.project.debugProperties["ENVIRONMENTOVERRIDE"] = ( self.debugEnvironmentOverrideCheckBox.isChecked()) self.project.debugProperties["ENVIRONMENTSTRING"] = ( self.debugEnvironmentEdit.text()) self.project.debugProperties["REMOTEDEBUGGER"] = ( self.remoteDebuggerGroup.isChecked()) self.project.debugProperties["REMOTEHOST"] = ( self.remoteHostEdit.text()) self.project.debugProperties["REMOTECOMMAND"] = ( self.remoteCommandEdit.text()) self.project.debugProperties["PATHTRANSLATION"] = ( self.pathTranslationGroup.isChecked()) self.project.debugProperties["REMOTEPATH"] = ( self.translationRemoteEdit.text()) self.project.debugProperties["LOCALPATH"] = ( self.translationLocalEdit.text()) self.project.debugProperties["CONSOLEDEBUGGER"] = ( self.consoleDebuggerGroup.isChecked()) self.project.debugProperties["CONSOLECOMMAND"] = ( self.consoleCommandEdit.text()) self.project.debugProperties["REDIRECT"] = ( self.redirectCheckBox.isChecked()) self.project.debugProperties["NOENCODING"] = ( self.noEncodingCheckBox.isChecked()) self.project.debugPropertiesLoaded = True self.project.debugPropertiesChanged = True self.__saveHistories()
def getWebBrowserSupport(): """ Module function to determine the supported web browser variant. @return string indicating the supported web browser variant ("QtWebEngine", or "None") @rtype str """ from eric6config import getConfig scriptPath = os.path.join(getConfig("ericDir"), "Tools", "webBrowserSupport.py") proc = QProcess() proc.start(sys.executable, [scriptPath, qVersion()]) if proc.waitForFinished(10000): variant = str(proc.readAllStandardOutput(), "utf-8", 'replace').strip() else: variant = "None" return variant
def __init__(self): """ Constructor """ ericPic = QPixmap( os.path.join(getConfig('ericPixDir'), 'pymakrSplash.png')) self.labelAlignment = Qt.Alignment(Qt.AlignBottom | Qt.AlignRight | Qt.AlignAbsolute) super(SplashScreen, self).__init__(ericPic) lblVersion = QLabel(self) lblVersion.setText(UI.Info.Version) lblVersion.adjustSize() lblVersion.setStyleSheet("QLabel { color : white; }") lblVersion.setAttribute(Qt.WA_TranslucentBackground) lblVersion.move(425 - lblVersion.width(), 195) self.show() self.raise_() # needed for mac QApplication.flush()
def loadTranslators(qtTransDir, app, translationFiles=()): """ Module function to load all required translations. @param qtTransDir directory of the Qt translations files (string) @param app reference to the application object (QApplication) @param translationFiles tuple of additional translations to be loaded (tuple of strings) @return the requested locale (string) """ import Preferences global loaded_translators if qVersion() < "5.0.0": # set the default encoding for tr() QTextCodec.setCodecForTr(QTextCodec.codecForName("utf-8")) translations = ("qt", "eric6") + translationFiles loc = Preferences.getUILanguage() if loc is None: return if loc == "System": loc = QLocale.system().name() if loc != "C": dirs = [getConfig('ericTranslationsDir'), Globals.getConfigDir()] if qtTransDir is not None: dirs.append(qtTransDir) loca = loc for tf in ["{0}_{1}".format(tr, loc) for tr in translations]: translator, ok = loadTranslatorForLocale(dirs, tf) loaded_translators[tf] = translator if ok: app.installTranslator(translator) else: if tf.startswith("eric6"): loca = None loc = loca else: loc = None return loc
def __init__(self, ui): """ Constructor @param ui reference to the user interface object (UI.UserInterface) """ super(SyntaxCheckerPlugin, self).__init__(ui) self.__ui = ui self.__initialize() from Plugins.CheckerPlugins.SyntaxChecker.SyntaxCheckService import \ SyntaxCheckService self.syntaxCheckService = SyntaxCheckService() e5App().registerObject("SyntaxCheckService", self.syntaxCheckService) ericPath = getConfig('ericDir') path = os.path.join(ericPath, 'Plugins', 'CheckerPlugins', 'SyntaxChecker') self.syntaxCheckService.addLanguage( 'Python2', 'Python2', path, 'SyntaxCheck', self.__getPythonOptions, lambda: Preferences.getPython("PythonExtensions"), self.__translateSyntaxCheck, self.serviceErrorPy2) self.syntaxCheckService.addLanguage( 'Python3', 'Python3', path, 'SyntaxCheck', self.__getPythonOptions, lambda: Preferences.getPython("Python3Extensions"), self.__translateSyntaxCheck, self.serviceErrorPy3) # Jasy isn't yet compatible to Python2 self.syntaxCheckService.addLanguage( 'JavaScript', 'Python3', path, 'jsCheckSyntax', lambda: [], # No options lambda: ['.js'], lambda fn, problems: self.syntaxCheckService.syntaxChecked.emit(fn, problems), # __IGNORE_WARNING__ self.serviceErrorJavaScript)
def __startExternalClient(self, interpreter, port): """ Private method to start the background client as external process. @param interpreter path and name of the executable to start (string) @param port socket port to which the interpreter should connect (int) @return the process object (QProcess or None) """ if interpreter == "" or not Utilities.isinpath(interpreter): return None backgroundClient = os.path.join(getConfig('ericDir'), "Utilities", "BackgroundClient.py") proc = QProcess() proc.setProcessChannelMode(QProcess.ForwardedChannels) args = [backgroundClient, self.hostAddress, str(port)] proc.start(interpreter, args) if not proc.waitForStarted(10000): proc = None return proc
def installTranslations(): """ Install the translation files into the right place. """ global privateInstall, configDir if privateInstall: targetDir = configDir else: targetDir = getConfig('ericTranslationsDir') try: for fn in glob.glob(os.path.join('eric', 'i18n', '*.qm')): shutil.copy2(fn, targetDir) os.chmod(os.path.join(targetDir, os.path.basename(fn)), 0o644) except IOError as msg: sys.stderr.write( 'IOError: {0}\nTry install-i18n as root.\n'.format(msg)) except OSError as msg: sys.stderr.write( 'OSError: {0}\nTry install-i18n with admin rights.\n'.format(msg))
def __startExternalClient(self, interpreter, port): """ Private method to start the background client as external process. @param interpreter path and name of the executable to start (string) @param port socket port to which the interpreter should connect (int) @return the process object (QProcess or None) """ if interpreter == "" or not Utilities.isinpath(interpreter): return None backgroundClient = os.path.join( getConfig('ericDir'), "Utilities", "BackgroundClient.py") proc = QProcess() proc.setProcessChannelMode(QProcess.ForwardedChannels) args = [backgroundClient, self.hostAddress, str(port)] proc.start(interpreter, args) if not proc.waitForStarted(10000): proc = None return proc
def __exportStyles(self, lexers): """ Private method to export the styles of the given lexers. @param lexers list of lexer objects for which to export the styles """ from eric6config import getConfig stylesDir = getConfig("ericStylesDir") fn, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( self, self.tr("Export Highlighting Styles"), stylesDir, self.tr("Highlighting styles file (*.e6h)"), "", E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) if not fn: return ext = QFileInfo(fn).suffix() if not ext: ex = selectedFilter.split("(*")[1].split(")")[0] if ex: fn += ex f = QFile(fn) if f.open(QIODevice.WriteOnly): from E5XML.HighlightingStylesWriter import HighlightingStylesWriter HighlightingStylesWriter(f, lexers).writeXML() f.close() else: E5MessageBox.critical( self, self.tr("Export Highlighting Styles"), self.tr( """<p>The highlighting styles could not be exported""" """ to file <b>{0}</b>.</p><p>Reason: {1}</p>""") .format(fn, f.errorString()) )
def __populateLanguageCombo(self): """ Private method to initialize the language combobox of the Interface configuration page. """ self.languageComboBox.clear() fnlist = glob.glob("eric6_*.qm") + \ glob.glob(os.path.join( getConfig('ericTranslationsDir'), "eric6_*.qm")) + \ glob.glob(os.path.join(Utilities.getConfigDir(), "eric6_*.qm")) locales = {} for fn in fnlist: locale = os.path.basename(fn)[6:-3] if locale not in locales: translator = QTranslator() translator.load(fn) locales[locale] = translator.translate( "InterfacePage", "English", "Translate this with your language") + \ " ({0})".format(locale) localeList = sorted(list(locales.keys())) try: uiLanguage = Preferences.getUILanguage() if uiLanguage == "None" or uiLanguage is None: currentIndex = 0 elif uiLanguage == "System": currentIndex = 1 else: currentIndex = localeList.index(uiLanguage) + 2 except ValueError: currentIndex = 0 self.languageComboBox.clear() self.languageComboBox.addItem("English (default)", "None") self.languageComboBox.addItem(self.tr('System'), "System") for locale in localeList: self.languageComboBox.addItem(locales[locale], locale) self.languageComboBox.setCurrentIndex(currentIndex)
def __importStyles(self, lexers): """ Private method to import the styles of the given lexers. @param lexers dictionary of lexer objects for which to import the styles """ from eric6config import getConfig stylesDir = getConfig("ericStylesDir") fn = E5FileDialog.getOpenFileName( self, self.tr("Import Highlighting Styles"), stylesDir, self.tr("Highlighting styles file (*.e6h *.e4h)")) if not fn: return f = QFile(fn) if f.open(QIODevice.ReadOnly): from E5XML.HighlightingStylesReader import HighlightingStylesReader reader = HighlightingStylesReader(f, lexers) reader.readXML() f.close() else: E5MessageBox.critical( self, self.tr("Import Highlighting Styles"), self.tr( """<p>The highlighting styles could not be read""" """ from file <b>{0}</b>.</p><p>Reason: {1}</p>""") .format(fn, f.errorString()) ) return self.on_lexerLanguageComboBox_activated( self.lexerLanguageComboBox.currentText())
def __startPluginInstall(self): """ Private slot to start the eric6 plugin installation dialog. """ proc = QProcess() applPath = os.path.join(getConfig("ericDir"), "eric6_plugininstall.py") args = [] args.append(applPath) args += self.cw.getDownloadedPlugins() if not os.path.isfile(applPath) or \ not proc.startDetached(sys.executable, args): E5MessageBox.critical( self, self.tr('Process Generation Error'), self.tr( '<p>Could not start the process.<br>' 'Ensure that it is available as <b>{0}</b>.</p>' ).format(applPath), self.tr('OK')) self.close()
def exeDisplayData(): """ Public method to support the display of some executable info. @return dictionary containing the data to query the presence of the executable """ exe = 'eric6_api' if Utilities.isWindowsPlatform(): exe = os.path.join(getConfig("bindir"), exe + '.bat') data = { "programEntry": True, "header": QCoreApplication.translate( "EricapiPlugin", "Eric6 API File Generator"), "exe": exe, "versionCommand": '--version', "versionStartsWith": 'eric6_', "versionPosition": -3, "version": "", "versionCleanup": None, } return data
def __init__(self, project, parms=None, parent=None): """ Constructor @param project reference to the project object (Project.Project) @param parms parameters to set in the dialog @param parent parent widget of this dialog """ super(EricdocConfigDialog, self).__init__(parent) self.setupUi(self) self.outputDirPicker.setMode(E5PathPickerModes.DirectoryMode) self.outputDirPicker.setDefaultDirectory(project.getProjectPath()) self.ignoreDirPicker.setMode(E5PathPickerModes.DirectoryMode) self.ignoreDirPicker.setDefaultDirectory(project.getProjectPath()) self.cssPicker.setMode(E5PathPickerModes.OpenFileMode) self.cssPicker.setDefaultDirectory(getConfig('ericCSSDir')) self.cssPicker.setFilters(self.tr( "Style sheet (*.css);;All files (*)")) self.qtHelpDirPicker.setMode(E5PathPickerModes.DirectoryMode) self.qtHelpDirPicker.setDefaultDirectory(project.getProjectPath()) self.__okButton = self.buttonBox.button(QDialogButtonBox.Ok) self.__initializeDefaults() self.sampleText = self.tr( '''<?xml version="1.0" encoding="utf-8"?>''' '''<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"''' '''"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">''' '''<html><head>''' '''<title></title>''' '''</head>''' '''<body style="background-color:{BodyBgColor};''' '''color:{BodyColor}">''' '''<h1 style="background-color:{Level1HeaderBgColor};''' '''color:{Level1HeaderColor}">''' '''Level 1 Header</h1>''' '''<h3 style="background-color:{Level2HeaderBgColor};''' '''color:{Level2HeaderColor}">''' '''Level 2 Header</h3>''' '''<h2 style="background-color:{CFBgColor};color:{CFColor}">''' '''Class and Function Header</h2>''' '''Standard body text with ''' '''<a style="color:{LinkColor}">some links</a> embedded.''' '''</body></html>''' ) # get a copy of the defaults to store the user settings self.parameters = copy.deepcopy(self.defaults) self.colors = eric6docDefaultColors.copy() # combine it with the values of parms if parms is not None: for key, value in list(parms.items()): if key.endswith("Color"): self.colors[key] = parms[key] else: self.parameters[key] = parms[key] self.parameters['outputDirectory'] = \ Utilities.toNativeSeparators(self.parameters['outputDirectory']) self.parameters['qtHelpOutputDirectory'] = \ Utilities.toNativeSeparators( self.parameters['qtHelpOutputDirectory']) self.parameters['cssFile'] = \ Utilities.toNativeSeparators(self.parameters['cssFile']) if self.parameters['cssFile'].startswith("%PYTHON%"): self.parameters['cssFile'] = self.parameters['cssFile'].replace( "%PYTHON%", Utilities.getPythonModulesDirectory()) self.ppath = project.getProjectPath() self.project = project self.recursionCheckBox.setChecked(self.parameters['useRecursion']) self.noindexCheckBox.setChecked(self.parameters['noindex']) self.noemptyCheckBox.setChecked(self.parameters['noempty']) self.outputDirPicker.setText(self.parameters['outputDirectory']) self.ignoreDirsList.clear() for d in self.parameters['ignoreDirectories']: self.ignoreDirsList.addItem(d) self.cssPicker.setText(self.parameters['cssFile']) self.sourceExtEdit.setText( ", ".join(self.parameters['sourceExtensions'])) self.excludeFilesEdit.setText( ", ".join(self.parameters['ignoreFilePatterns'])) self.sample.setHtml(self.sampleText.format(**self.colors)) self.qtHelpGroup.setChecked(self.parameters['qtHelpEnabled']) self.qtHelpDirPicker.setText(self.parameters['qtHelpOutputDirectory']) self.qtHelpNamespaceEdit.setText(self.parameters['qtHelpNamespace']) self.qtHelpFolderEdit.setText(self.parameters['qtHelpVirtualFolder']) self.qtHelpFilterNameEdit.setText(self.parameters['qtHelpFilterName']) self.qtHelpFilterAttributesEdit.setText( self.parameters['qtHelpFilterAttributes']) self.qtHelpTitleEdit.setText(self.parameters['qtHelpTitle']) self.qtHelpGenerateCollectionCheckBox.setChecked( self.parameters['qtHelpCreateCollection'])
def __generatePythonCode(self): """ Private slot to generate Python code as requested by the user. """ # init some variables sourceImpl = [] appendAtIndex = -1 indentStr = " " slotsCode = [] if self.__module is None: # new file try: if self.project.getProjectLanguage() == "Python2": if self.project.getProjectType() == "PySide": tmplName = os.path.join( getConfig('ericCodeTemplatesDir'), "impl_pyside.py2.tmpl") elif self.project.getProjectType() == "PyQt5": tmplName = os.path.join( getConfig('ericCodeTemplatesDir'), "impl_pyqt5.py2.tmpl") else: tmplName = os.path.join( getConfig('ericCodeTemplatesDir'), "impl_pyqt.py2.tmpl") else: if self.project.getProjectType() == "PySide": tmplName = os.path.join( getConfig('ericCodeTemplatesDir'), "impl_pyside.py.tmpl") elif self.project.getProjectType() in [ "PyQt5", "E6Plugin"]: tmplName = os.path.join( getConfig('ericCodeTemplatesDir'), "impl_pyqt5.py.tmpl") else: tmplName = os.path.join( getConfig('ericCodeTemplatesDir'), "impl_pyqt.py.tmpl") tmplFile = open(tmplName, 'r', encoding="utf-8") template = tmplFile.read() tmplFile.close() except IOError as why: E5MessageBox.critical( self, self.tr("Code Generation"), self.tr( """<p>Could not open the code template file""" """ "{0}".</p><p>Reason: {1}</p>""") .format(tmplName, str(why))) return objName = self.__objectName() if objName: template = template\ .replace( "$FORMFILE$", os.path.splitext(os.path.basename(self.formFile))[0])\ .replace("$FORMCLASS$", objName)\ .replace("$CLASSNAME$", self.classNameCombo.currentText())\ .replace("$SUPERCLASS$", self.__className()) sourceImpl = template.splitlines(True) appendAtIndex = -1 # determine indent string for line in sourceImpl: if line.lstrip().startswith("def __init__"): indentStr = line.replace(line.lstrip(), "") break else: # extend existing file try: srcFile = open(self.srcFile, 'r', encoding="utf-8") sourceImpl = srcFile.readlines() srcFile.close() if not sourceImpl[-1].endswith("\n"): sourceImpl[-1] = "{0}{1}".format(sourceImpl[-1], "\n") except IOError as why: E5MessageBox.critical( self, self.tr("Code Generation"), self.tr( """<p>Could not open the source file "{0}".</p>""" """<p>Reason: {1}</p>""") .format(self.srcFile, str(why))) return cls = self.__module.classes[self.classNameCombo.currentText()] if cls.endlineno == len(sourceImpl) or cls.endlineno == -1: appendAtIndex = -1 # delete empty lines at end while not sourceImpl[-1].strip(): del sourceImpl[-1] else: appendAtIndex = cls.endlineno - 1 while not sourceImpl[appendAtIndex].strip(): appendAtIndex -= 1 appendAtIndex += 1 # determine indent string for line in sourceImpl[cls.lineno:cls.endlineno + 1]: if line.lstrip().startswith("def __init__"): indentStr = line.replace(line.lstrip(), "") break # do the coding stuff if self.project.getProjectLanguage() == "Python2": if self.project.getProjectType() == "PySide": pyqtSignatureFormat = '@Slot({0})' elif self.project.getProjectType() == "PyQt5": pyqtSignatureFormat = '@pyqtSlot({0})' else: pyqtSignatureFormat = '@pyqtSignature("{0}")' else: if self.project.getProjectType() == "PySide": pyqtSignatureFormat = '@Slot({0})' else: pyqtSignatureFormat = '@pyqtSlot({0})' for row in range(self.slotsModel.rowCount()): topItem = self.slotsModel.item(row) for childRow in range(topItem.rowCount()): child = topItem.child(childRow) if child.checkState() and \ child.flags() & Qt.ItemFlags(Qt.ItemIsUserCheckable): slotsCode.append('{0}\n'.format(indentStr)) slotsCode.append('{0}{1}\n'.format( indentStr, pyqtSignatureFormat.format( child.data(pyqtSignatureRole)))) slotsCode.append('{0}def {1}:\n'.format( indentStr, child.data(pythonSignatureRole))) indentStr2 = indentStr * 2 slotsCode.append('{0}"""\n'.format(indentStr2)) slotsCode.append( '{0}Slot documentation goes here.\n'.format( indentStr2)) if child.data(returnTypeRole) or \ child.data(parameterTypesListRole): slotsCode.append('{0}\n'.format(indentStr2)) if child.data(parameterTypesListRole): for name, type_ in zip( child.data(parameterNamesListRole), child.data(parameterTypesListRole)): slotsCode.append( '{0}@param {1} DESCRIPTION\n'.format( indentStr2, name)) slotsCode.append('{0}@type {1}\n'.format( indentStr2, type_)) if child.data(returnTypeRole): slotsCode.append( '{0}@returns DESCRIPTION\n'.format( indentStr2)) slotsCode.append('{0}@rtype {1}\n'.format( indentStr2, child.data(returnTypeRole))) slotsCode.append('{0}"""\n'.format(indentStr2)) slotsCode.append('{0}# {1}: not implemented yet\n'.format( indentStr2, "TODO")) slotsCode.append('{0}raise NotImplementedError\n'.format( indentStr2)) if appendAtIndex == -1: sourceImpl.extend(slotsCode) else: sourceImpl[appendAtIndex:appendAtIndex] = slotsCode # write the new code try: if self.project.useSystemEol(): newline = None else: newline = self.project.getEolString() srcFile = open(self.filenameEdit.text(), 'w', encoding="utf-8", newline=newline) srcFile.write("".join(sourceImpl)) srcFile.close() except IOError as why: E5MessageBox.critical( self, self.tr("Code Generation"), self.tr("""<p>Could not write the source file "{0}".</p>""" """<p>Reason: {1}</p>""") .format(self.filenameEdit.text(), str(why))) return self.project.appendFile(self.filenameEdit.text())
def uninstallEric(): """ Uninstall the eric files. """ global pyModDir # Remove the menu entry for Linux systems if sys.platform.startswith("linux") and os.getuid() == 0: if includePythonVariant: marker = PythonMarkers[sys.version_info.major] else: marker = "" for name in ["/usr/share/applications/eric6" + marker + ".desktop", "/usr/share/appdata/eric6" + marker + ".appdata.xml", "/usr/share/applications/eric6_webbrowser" + marker + ".desktop", "/usr/share/pixmaps/eric" + marker + ".png", "/usr/share/pixmaps/ericWeb" + marker + ".png"]: if os.path.exists(name): os.remove(name) # Remove the wrapper scripts rem_wnames = [ "eric6_api", "eric6_compare", "eric6_configure", "eric6_diff", "eric6_doc", "eric6_qregularexpression", "eric6_qregexp", "eric6_re", "eric6_trpreviewer", "eric6_uipreviewer", "eric6_unittest", "eric6", "eric6_tray", "eric6_editor", "eric6_plugininstall", "eric6_pluginuninstall", "eric6_pluginrepository", "eric6_sqlbrowser", "eric6_webbrowser", "eric6_iconeditor", "eric6_snap", ] if includePythonVariant: marker = PythonMarkers[sys.version_info.major] rem_wnames = [n + marker for n in rem_wnames] try: for rem_wname in rem_wnames: rwname = wrapperName(getConfig('bindir'), rem_wname) if os.path.exists(rwname): os.remove(rwname) # Cleanup our config file(s) for name in ['eric6config.py', 'eric6config.pyc', 'eric6.pth']: e5cfile = os.path.join(pyModDir, name) if os.path.exists(e5cfile): os.remove(e5cfile) e5cfile = os.path.join(pyModDir, "__pycache__", name) path, ext = os.path.splitext(e5cfile) for f in glob.glob("{0}.*{1}".format(path, ext)): os.remove(f) # Cleanup the install directories for name in ['ericExamplesDir', 'ericDocDir', 'ericDTDDir', 'ericCSSDir', 'ericIconDir', 'ericPixDir', 'ericTemplatesDir', 'ericCodeTemplatesDir', 'ericOthersDir', 'ericStylesDir', 'ericDir']: dirpath = getConfig(name) if os.path.exists(dirpath): shutil.rmtree(dirpath, True) # Cleanup translations for name in glob.glob( os.path.join(getConfig('ericTranslationsDir'), 'eric6_*.qm')): if os.path.exists(name): os.remove(name) # Cleanup API files apidir = getConfig('apidir') if apidir: for progLanguage in progLanguages: for name in getConfig('apis'): apiname = os.path.join(apidir, progLanguage.lower(), name) if os.path.exists(apiname): os.remove(apiname) for apiname in glob.glob( os.path.join(apidir, progLanguage.lower(), "*.bas")): if os.path.basename(apiname) != "eric6.bas": os.remove(apiname) if sys.platform == "darwin": # delete the Mac app bundle if os.path.exists("/Developer/Applications/Eric6"): shutil.rmtree("/Developer/Applications/Eric6") try: macAppBundlePath = getConfig("macAppBundlePath") macAppBundleName = getConfig("macAppBundleName") except AttributeError: macAppBundlePath = defaultMacAppBundlePath macAppBundleName = defaultMacAppBundleName for bundlePath in [os.path.join(defaultMacAppBundlePath, macAppBundleName), os.path.join(macAppBundlePath, macAppBundleName), ]: if os.path.exists(bundlePath): shutil.rmtree(bundlePath) # remove plug-in directories removePluginDirectories() # remove the eric data directory removeDataDirectory() # remove the eric configuration directory removeConfigurationData() print("\nUninstallation completed") except (IOError, OSError) as msg: sys.stderr.write( 'Error: {0}\nTry uninstall with admin rights.\n'.format(msg)) exit(7)
def __init__(self, vm): """ Constructor @param vm view manager widget (Tabview) """ super(TabWidget, self).__init__() self.__tabBar = TabBar(self) self.setTabBar(self.__tabBar) iconSize = self.__tabBar.iconSize() self.__tabBar.setIconSize( QSize(2 * iconSize.width(), iconSize.height())) self.setUsesScrollButtons(True) self.setElideMode(Qt.ElideNone) if isMacPlatform(): self.setDocumentMode(True) self.__tabBar.tabMoveRequested.connect(self.moveTab) self.__tabBar.tabRelocateRequested.connect(self.__relocateTab) self.__tabBar.tabCopyRequested[str, int, int].connect(self.__copyTabOther) self.__tabBar.tabCopyRequested[int, int].connect(self.__copyTab) self.vm = vm self.editors = [] self.indicator = E5Led(self) self.setCornerWidget(self.indicator, Qt.TopLeftCorner) self.rightCornerWidget = QWidget(self) self.rightCornerWidgetLayout = QHBoxLayout(self.rightCornerWidget) self.rightCornerWidgetLayout.setContentsMargins(0, 0, 0, 0) self.rightCornerWidgetLayout.setSpacing(0) self.__navigationMenu = QMenu(self) self.__navigationMenu.aboutToShow.connect(self.__showNavigationMenu) self.__navigationMenu.triggered.connect(self.__navigationMenuTriggered) self.navigationButton = QToolButton(self) if Preferences.getUI("SingleCloseButton") or \ not hasattr(self, 'setTabsClosable'): self.closeButton = QToolButton(self) self.closeButton.setIcon(UI.PixmapCache.getIcon("close.png")) self.closeButton.setToolTip(self.tr("Close the current editor")) self.closeButton.setEnabled(False) self.closeButton.clicked[bool].connect(self.__closeButtonClicked) self.rightCornerWidgetLayout.addWidget(self.closeButton) else: self.tabCloseRequested.connect(self.__closeRequested) self.closeButton = None self.setCornerWidget(self.rightCornerWidget, Qt.TopRightCorner) self.__initMenu() self.contextMenuEditor = None self.contextMenuIndex = -1 self.setTabContextMenuPolicy(Qt.CustomContextMenu) self.customTabContextMenuRequested.connect(self.__showContextMenu) ericPic = QPixmap( os.path.join(getConfig('ericPixDir'), 'pymakr_small.png')) self.emptyLabel = QLabel() self.emptyLabel.setPixmap(ericPic) self.emptyLabel.setAlignment(Qt.AlignVCenter | Qt.AlignHCenter) super(TabWidget, self).addTab(self.emptyLabel, UI.PixmapCache.getIcon("empty.png"), "")
def initializePage(self): """ Public method to initialize the page. """ self.syncErrorLabel.hide() forceUpload = self.field("ReencryptData") import Helpviewer.HelpWindow syncMgr = Helpviewer.HelpWindow.HelpWindow.syncManager() syncMgr.syncError.connect(self.__syncError) syncMgr.syncStatus.connect(self.__updateMessages) syncMgr.syncFinished.connect(self.__updateLabels) if Preferences.getHelp("SyncType") == SyncGlobals.SyncTypeFtp: self.handlerLabel.setText(self.tr("FTP")) self.infoLabel.setText(self.tr("Host:")) self.infoDataLabel.setText(Preferences.getHelp("SyncFtpServer")) elif Preferences.getHelp("SyncType") == SyncGlobals.SyncTypeDirectory: self.handlerLabel.setText(self.tr("Shared Directory")) self.infoLabel.setText(self.tr("Directory:")) self.infoDataLabel.setText( Preferences.getHelp("SyncDirectoryPath")) else: self.handlerLabel.setText(self.tr("No Synchronization")) self.hostLabel.setText("") self.bookmarkMsgLabel.setText("") self.historyMsgLabel.setText("") self.passwordsMsgLabel.setText("") self.userAgentsMsgLabel.setText("") self.speedDialMsgLabel.setText("") if not syncMgr.syncEnabled(): self.bookmarkLabel.setPixmap( UI.PixmapCache.getPixmap("syncNo.png")) self.historyLabel.setPixmap(UI.PixmapCache.getPixmap("syncNo.png")) self.passwordsLabel.setPixmap( UI.PixmapCache.getPixmap("syncNo.png")) self.userAgentsLabel.setPixmap( UI.PixmapCache.getPixmap("syncNo.png")) self.speedDialLabel.setPixmap( UI.PixmapCache.getPixmap("syncNo.png")) return animationFile = os.path.join(getConfig("ericPixDir"), "loading.gif") # bookmarks if Preferences.getHelp("SyncBookmarks"): self.__makeAnimatedLabel(animationFile, self.bookmarkLabel) else: self.bookmarkLabel.setPixmap( UI.PixmapCache.getPixmap("syncNo.png")) # history if Preferences.getHelp("SyncHistory"): self.__makeAnimatedLabel(animationFile, self.historyLabel) else: self.historyLabel.setPixmap(UI.PixmapCache.getPixmap("syncNo.png")) # Passwords if Preferences.getHelp("SyncPasswords"): self.__makeAnimatedLabel(animationFile, self.passwordsLabel) else: self.passwordsLabel.setPixmap( UI.PixmapCache.getPixmap("syncNo.png")) # user agent settings if Preferences.getHelp("SyncUserAgents"): self.__makeAnimatedLabel(animationFile, self.userAgentsLabel) else: self.userAgentsLabel.setPixmap( UI.PixmapCache.getPixmap("syncNo.png")) # speed dial settings if Preferences.getHelp("SyncSpeedDial"): self.__makeAnimatedLabel(animationFile, self.speedDialLabel) else: self.speedDialLabel.setPixmap( UI.PixmapCache.getPixmap("syncNo.png")) QTimer.singleShot( 0, lambda: syncMgr.loadSettings(forceUpload=forceUpload))
def uninstallEric(): """ Uninstall the eric files. """ global pyModDir # Remove the menu entry for Linux systems if sys.platform.startswith("linux") and os.getuid() == 0: if includePythonVariant: marker = PythonMarkers[sys.version_info.major] else: marker = "" for name in [ "/usr/share/applications/pymakr" + marker + ".desktop", "/usr/share/appdata/pymakr" + marker + ".appdata.xml", "/usr/share/applications/pymakr_webbrowser" + marker + ".desktop", "/usr/share/pixmaps/pymakr" + marker + ".png", "/usr/share/pixmaps/ericWeb" + marker + ".png" ]: if os.path.exists(name): os.remove(name) # Remove the wrapper scripts rem_wnames = [ "eric6_api", "eric6_compare", "eric6_configure", "eric6_diff", "eric6_doc", "eric6_qregularexpression", "eric6_qregexp", "eric6_re", "eric6_trpreviewer", "eric6_uipreviewer", "eric6_unittest", "eric6", "eric6_tray", "eric6_editor", "eric6_plugininstall", "eric6_pluginuninstall", "eric6_pluginrepository", "eric6_sqlbrowser", "pymakr_webbrowser", "eric6_iconeditor", "eric6_snap", ] if includePythonVariant: marker = PythonMarkers[sys.version_info.major] rem_wnames = [n + marker for n in rem_wnames] try: for rem_wname in rem_wnames: rwname = wrapperName(getConfig('bindir'), rem_wname) if os.path.exists(rwname): os.remove(rwname) # Cleanup our config file(s) for name in ['eric6config.py', 'eric6config.pyc', 'eric6.pth']: e5cfile = os.path.join(pyModDir, name) if os.path.exists(e5cfile): os.remove(e5cfile) e5cfile = os.path.join(pyModDir, "__pycache__", name) path, ext = os.path.splitext(e5cfile) for f in glob.glob("{0}.*{1}".format(path, ext)): os.remove(f) # Cleanup the install directories for name in [ 'ericExamplesDir', 'ericDocDir', 'ericDTDDir', 'ericCSSDir', 'ericIconDir', 'ericPixDir', 'ericTemplatesDir', 'ericCodeTemplatesDir', 'ericOthersDir', 'ericStylesDir', 'ericDir' ]: dirpath = getConfig(name) if os.path.exists(dirpath): shutil.rmtree(dirpath, True) # Cleanup translations for name in glob.glob( os.path.join(getConfig('ericTranslationsDir'), 'eric6_*.qm')): if os.path.exists(name): os.remove(name) # Cleanup API files apidir = getConfig('apidir') if apidir: for progLanguage in progLanguages: for name in getConfig('apis'): apiname = os.path.join(apidir, progLanguage.lower(), name) if os.path.exists(apiname): os.remove(apiname) for apiname in glob.glob( os.path.join(apidir, progLanguage.lower(), "*.bas")): if os.path.basename(apiname) != "eric6.bas": os.remove(apiname) if sys.platform == "darwin": # delete the Mac app bundle if os.path.exists("/Developer/Applications/pymakr"): shutil.rmtree("/Developer/Applications/pymakr") try: macAppBundlePath = getConfig("macAppBundlePath") macAppBundleName = getConfig("macAppBundleName") except AttributeError: macAppBundlePath = defaultMacAppBundlePath macAppBundleName = defaultMacAppBundleName for bundlePath in [ os.path.join(defaultMacAppBundlePath, macAppBundleName), os.path.join(macAppBundlePath, macAppBundleName), ]: if os.path.exists(bundlePath): shutil.rmtree(bundlePath) # remove plug-in directories removePluginDirectories() # remove the eric data directory removeDataDirectory() # remove the eric configuration directory removeConfigurationData() print("\nUninstallation completed") except (IOError, OSError) as msg: sys.stderr.write( 'Error: {0}\nTry uninstall with admin rights.\n'.format(msg)) exit(7)
def __init__(self, parent=None, doLoadPlugins=True, develPlugin=None): """ Constructor The Plugin Manager deals with three different plugin directories. The first is the one, that is part of eric6 (eric6/Plugins). The second one is the global plugin directory called 'eric6plugins', which is located inside the site-packages directory. The last one 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) @exception PluginPathError raised to indicate an invalid plug-in path """ super(PluginManager, self).__init__(parent) self.__ui = parent self.__develPluginFile = develPlugin self.__develPluginName = None self.__inactivePluginsKey = "PluginManager/InactivePlugins" self.pluginDirs = { "eric6": os.path.join(getConfig('ericDir'), "Plugins"), "global": os.path.join(Utilities.getPythonModulesDirectory(), "eric6plugins"), "user": os.path.join(Utilities.getConfigDir(), "eric6plugins"), } self.__priorityOrder = ["eric6", "global", "user"] self.__defaultDownloadDir = os.path.join( Utilities.getConfigDir(), "Downloads") self.__activePlugins = {} self.__inactivePlugins = {} self.__onDemandActivePlugins = {} self.__onDemandInactivePlugins = {} self.__activeModules = {} self.__inactiveModules = {} self.__onDemandActiveModules = {} self.__onDemandInactiveModules = {} self.__failedModules = {} self.__foundCoreModules = [] self.__foundGlobalModules = [] self.__foundUserModules = [] self.__modulesCount = 0 pdirsExist, msg = self.__pluginDirectoriesExist() if not pdirsExist: raise PluginPathError(msg) if doLoadPlugins: if not self.__pluginModulesExist(): raise PluginModulesError self.__insertPluginsPaths() self.__loadPlugins() self.__checkPluginsDownloadDirectory() self.pluginRepositoryFile = \ os.path.join(Utilities.getConfigDir(), "PluginRepository") # attributes for the network objects self.__networkManager = QNetworkAccessManager(self) self.__networkManager.proxyAuthenticationRequired.connect( proxyAuthenticationRequired) if SSL_AVAILABLE: self.__sslErrorHandler = E5SslErrorHandler(self) self.__networkManager.sslErrors.connect(self.__sslErrors) self.__replies = []
""" Module implementing a debugger stub for remote debugging. """ import os import sys import distutils.sysconfig from eric6config import getConfig debugger = None __scriptname = None modDir = distutils.sysconfig.get_python_lib(True) ericpath = os.getenv('ERICDIR', getConfig('ericDir')) if ericpath not in sys.path: sys.path.insert(-1, ericpath) def initDebugger(kind="standard"): """ Module function to initialize a debugger for remote debugging. @param kind type of debugger ("standard" or "threads") @return flag indicating success (boolean) @exception ValueError raised to indicate a wrong debugger kind """ global debugger res = True
def startRemote(self, port, runInConsole): """ Public method to start a remote Ruby interpreter. @param port portnumber the debug server is listening on (integer) @param runInConsole flag indicating to start the debugger in a console window (boolean) @return client process object (QProcess), a flag to indicate a network connection (boolean) and the name of the interpreter in case of a local execution (string) """ interpreter = Preferences.getDebugger("RubyInterpreter") if interpreter == "": E5MessageBox.critical( None, self.tr("Start Debugger"), self.tr("""<p>No Ruby interpreter configured.</p>""")) return None, False, "" debugClient = os.path.join( getConfig('ericDir'), "DebugClients", "Ruby", "DebugClient.rb") redirect = str(Preferences.getDebugger("RubyRedirect")) if Preferences.getDebugger("RemoteDbgEnabled"): ipaddr = self.debugServer.getHostAddress(False)[0] rexec = Preferences.getDebugger("RemoteExecution") rhost = Preferences.getDebugger("RemoteHost") if rhost == "": rhost = "localhost" if rexec: args = Utilities.parseOptionString(rexec) + \ [rhost, interpreter, os.path.abspath(debugClient), str(port), redirect, ipaddr] args[0] = Utilities.getExecutablePath(args[0]) process = self.__startProcess(args[0], args[1:]) if process is None: E5MessageBox.critical( None, self.tr("Start Debugger"), self.tr( """<p>The debugger backend could not be""" """ started.</p>""")) # set translation function if Preferences.getDebugger("PathTranslation"): self.translateRemote = \ Preferences.getDebugger("PathTranslationRemote") self.translateLocal = \ Preferences.getDebugger("PathTranslationLocal") self.translate = self.__remoteTranslation else: self.translate = self.__identityTranslation return process, self.__isNetworked, "" # set translation function self.translate = self.__identityTranslation # setup the environment for the debugger if Preferences.getDebugger("DebugEnvironmentReplace"): clientEnv = {} else: clientEnv = os.environ.copy() envlist = Utilities.parseEnvironmentString( Preferences.getDebugger("DebugEnvironment")) for el in envlist: try: key, value = el.split('=', 1) if value.startswith('"') or value.startswith("'"): value = value[1:-1] clientEnv[str(key)] = str(value) except ValueError: pass ipaddr = self.debugServer.getHostAddress(True) if runInConsole or Preferences.getDebugger("ConsoleDbgEnabled"): ccmd = Preferences.getDebugger("ConsoleDbgCommand") if ccmd: args = Utilities.parseOptionString(ccmd) + \ [interpreter, os.path.abspath(debugClient), str(port), '0', ipaddr] args[0] = Utilities.getExecutablePath(args[0]) process = self.__startProcess(args[0], args[1:], clientEnv) if process is None: E5MessageBox.critical( None, self.tr("Start Debugger"), self.tr( """<p>The debugger backend could not be""" """ started.</p>""")) return process, self.__isNetworked, interpreter process = self.__startProcess( interpreter, [debugClient, str(port), redirect, ipaddr], clientEnv) if process is None: E5MessageBox.critical( None, self.tr("Start Debugger"), self.tr( """<p>The debugger backend could not be started.</p>""")) return process, self.__isNetworked, interpreter
def __init__(self, project, parent=None, name=None): """ Constructor @param project reference to the project object @param parent parent widget of this dialog (QWidget) @param name name of this dialog (string) """ super(DebuggerPropertiesDialog, self).__init__(parent) if name: self.setObjectName(name) self.setupUi(self) self.debugClientPicker.setMode(E5PathPickerModes.OpenFileMode) self.interpreterPicker.setMode(E5PathPickerModes.OpenFileMode) self.translationLocalCompleter = E5DirCompleter( self.translationLocalEdit) self.project = project if self.project.debugProperties["INTERPRETER"]: self.interpreterPicker.setText( self.project.debugProperties["INTERPRETER"]) else: if self.project.pdata["PROGLANGUAGE"][0] in \ ["Python", "Python2", "Python3"]: self.interpreterPicker.setText(sys.executable) elif self.project.pdata["PROGLANGUAGE"][0] == "Ruby": self.interpreterPicker.setText("/usr/bin/ruby") if self.project.debugProperties["DEBUGCLIENT"]: self.debugClientPicker.setText( self.project.debugProperties["DEBUGCLIENT"]) else: if self.project.pdata["PROGLANGUAGE"][0] in ["Python", "Python2"]: debugClient = os.path.join( getConfig('ericDir'), "DebugClients", "Python", "DebugClient.py") elif self.project.pdata["PROGLANGUAGE"][0] == "Python3": debugClient = os.path.join( getConfig('ericDir'), "DebugClients", "Python3", "DebugClient.py") elif self.project.pdata["PROGLANGUAGE"][0] == "Ruby": debugClient = os.path.join( getConfig('ericDir'), "DebugClients", "Ruby", "DebugClient.rb") else: debugClient = "" self.debugClientPicker.setText(debugClient) self.debugEnvironmentOverrideCheckBox.setChecked( self.project.debugProperties["ENVIRONMENTOVERRIDE"]) self.debugEnvironmentEdit.setText( self.project.debugProperties["ENVIRONMENTSTRING"]) self.remoteDebuggerGroup.setChecked( self.project.debugProperties["REMOTEDEBUGGER"]) self.remoteHostEdit.setText( self.project.debugProperties["REMOTEHOST"]) self.remoteCommandEdit.setText( self.project.debugProperties["REMOTECOMMAND"]) self.pathTranslationGroup.setChecked( self.project.debugProperties["PATHTRANSLATION"]) self.translationRemoteEdit.setText( self.project.debugProperties["REMOTEPATH"]) self.translationLocalEdit.setText( self.project.debugProperties["LOCALPATH"]) self.consoleDebuggerGroup.setChecked( self.project.debugProperties["CONSOLEDEBUGGER"]) self.consoleCommandEdit.setText( self.project.debugProperties["CONSOLECOMMAND"]) self.redirectCheckBox.setChecked( self.project.debugProperties["REDIRECT"]) self.noEncodingCheckBox.setChecked( self.project.debugProperties["NOENCODING"]) msh = self.minimumSizeHint() self.resize(max(self.width(), msh.width()), msh.height())
def __setupUi(self): """ Private method to perform the general setup of the configuration widget. """ self.setObjectName("ConfigurationDialog") self.resize(900, 650) self.verticalLayout_2 = QVBoxLayout(self) self.verticalLayout_2.setSpacing(6) self.verticalLayout_2.setContentsMargins(6, 6, 6, 6) self.verticalLayout_2.setObjectName("verticalLayout_2") self.configSplitter = QSplitter(self) self.configSplitter.setOrientation(Qt.Horizontal) self.configSplitter.setObjectName("configSplitter") self.configListWidget = QWidget(self.configSplitter) self.leftVBoxLayout = QVBoxLayout(self.configListWidget) self.leftVBoxLayout.setContentsMargins(0, 0, 0, 0) self.leftVBoxLayout.setSpacing(0) self.leftVBoxLayout.setObjectName("leftVBoxLayout") self.configListSearch = E5ClearableLineEdit( self, self.tr("Enter search text...")) self.configListSearch.setObjectName("configListSearch") self.leftVBoxLayout.addWidget(self.configListSearch) self.configList = QTreeWidget() self.configList.setObjectName("configList") self.leftVBoxLayout.addWidget(self.configList) self.configListSearch.textChanged.connect(self.__searchTextChanged) self.scrollArea = QScrollArea(self.configSplitter) self.scrollArea.setFrameShape(QFrame.NoFrame) self.scrollArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self.scrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self.scrollArea.setWidgetResizable(False) self.scrollArea.setObjectName("scrollArea") self.configStack = QStackedWidget() self.configStack.setFrameShape(QFrame.Box) self.configStack.setFrameShadow(QFrame.Sunken) self.configStack.setObjectName("configStack") self.scrollArea.setWidget(self.configStack) self.emptyPage = QWidget() self.emptyPage.setGeometry(QRect(0, 0, 372, 591)) self.emptyPage.setObjectName("emptyPage") self.vboxlayout = QVBoxLayout(self.emptyPage) self.vboxlayout.setSpacing(6) self.vboxlayout.setContentsMargins(6, 6, 6, 6) self.vboxlayout.setObjectName("vboxlayout") spacerItem = QSpacerItem( 20, 20, QSizePolicy.Minimum, QSizePolicy.Expanding) self.vboxlayout.addItem(spacerItem) self.emptyPagePixmap = QLabel(self.emptyPage) self.emptyPagePixmap.setAlignment(Qt.AlignCenter) self.emptyPagePixmap.setObjectName("emptyPagePixmap") self.emptyPagePixmap.setPixmap( QPixmap(os.path.join(getConfig('ericPixDir'), 'eric.png'))) self.vboxlayout.addWidget(self.emptyPagePixmap) self.textLabel1 = QLabel(self.emptyPage) self.textLabel1.setAlignment(Qt.AlignCenter) self.textLabel1.setObjectName("textLabel1") self.vboxlayout.addWidget(self.textLabel1) spacerItem1 = QSpacerItem( 20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) self.vboxlayout.addItem(spacerItem1) self.configStack.addWidget(self.emptyPage) self.verticalLayout_2.addWidget(self.configSplitter) self.buttonBox = QDialogButtonBox(self) self.buttonBox.setOrientation(Qt.Horizontal) self.buttonBox.setStandardButtons( QDialogButtonBox.Apply | QDialogButtonBox.Cancel | QDialogButtonBox.Ok | QDialogButtonBox.Reset) self.buttonBox.setObjectName("buttonBox") if not self.fromEric and \ self.displayMode == ConfigurationWidget.DefaultMode: self.buttonBox.button(QDialogButtonBox.Apply).hide() self.buttonBox.button(QDialogButtonBox.Apply).setEnabled(False) self.buttonBox.button(QDialogButtonBox.Reset).setEnabled(False) self.verticalLayout_2.addWidget(self.buttonBox) self.setWindowTitle(self.tr("Preferences")) self.configList.header().hide() self.configList.header().setSortIndicator(0, Qt.AscendingOrder) self.configList.setSortingEnabled(True) self.textLabel1.setText( self.tr("Please select an entry of the list \n" "to display the configuration page.")) QMetaObject.connectSlotsByName(self) self.setTabOrder(self.configList, self.configStack) self.configStack.setCurrentWidget(self.emptyPage) self.configList.setFocus()
def generateParameters(self): """ Public method that generates the commandline parameters. It generates a list of strings to be used to set the QProcess arguments for the ericdoc call and a dictionary containing the non default parameters. This dictionary can be passed back upon object generation to overwrite the default settings. @return a tuple of the commandline parameters and non default parameters (list of strings, dictionary) """ parms = {} args = [] # 1. the program name args.append(sys.executable) args.append( Utilities.normabsjoinpath(getConfig('ericDir'), "eric6_doc.py")) # 2. the commandline options # 2a. general commandline options if self.parameters['outputDirectory'] != \ self.defaults['outputDirectory']: parms['outputDirectory'] = Utilities.fromNativeSeparators( self.project.getRelativePath( self.parameters['outputDirectory'])) args.append('-o') if os.path.isabs(self.parameters['outputDirectory']): args.append(self.parameters['outputDirectory']) else: args.append(os.path.join( self.ppath, self.parameters['outputDirectory'])) else: self.parameters['outputDirectory'] = \ self.defaults['outputDirectory'] if self.parameters['ignoreDirectories'] != \ self.defaults['ignoreDirectories']: parms['ignoreDirectories'] = \ self.parameters['ignoreDirectories'][:] for d in self.parameters['ignoreDirectories']: args.append('-x') args.append(d) if self.parameters['ignoreFilePatterns'] != \ self.defaults['ignoreFilePatterns']: parms['ignoreFilePatterns'] = \ self.parameters['ignoreFilePatterns'][:] for pattern in self.parameters['ignoreFilePatterns']: args.append("--exclude-file={0}".format(pattern)) if self.parameters['useRecursion'] != self.defaults['useRecursion']: parms['useRecursion'] = self.parameters['useRecursion'] args.append('-r') if self.parameters['noindex'] != self.defaults['noindex']: parms['noindex'] = self.parameters['noindex'] args.append('-i') if self.parameters['noempty'] != self.defaults['noempty']: parms['noempty'] = self.parameters['noempty'] args.append('-e') if self.parameters['sourceExtensions'] != \ self.defaults['sourceExtensions']: parms['sourceExtensions'] = self.parameters['sourceExtensions'][:] for ext in self.parameters['sourceExtensions']: args.append('-t') args.append(ext) # 2b. style commandline options if self.parameters['cssFile'] != self.defaults['cssFile']: cssFile = self.project.getRelativePath(self.parameters['cssFile']) if cssFile.startswith(Utilities.getPythonModulesDirectory()): cssFile = cssFile.replace( Utilities.getPythonModulesDirectory(), "%PYTHON%") parms['cssFile'] = Utilities.fromNativeSeparators(cssFile) args.append('-c') if os.path.isabs(self.parameters['cssFile']): args.append(self.parameters['cssFile']) else: args.append( os.path.join(self.ppath, self.parameters['cssFile'])) for key, value in list(self.colors.items()): if self.colors[key] != eric6docDefaultColors[key]: parms[key] = self.colors[key] args.append("--{0}={1}".format( eric6docColorParameterNames[key], self.colors[key])) # 2c. QtHelp commandline options parms['qtHelpEnabled'] = self.parameters['qtHelpEnabled'] if self.parameters['qtHelpEnabled']: args.append('--create-qhp') if self.parameters['qtHelpOutputDirectory'] != \ self.defaults['qtHelpOutputDirectory']: parms['qtHelpOutputDirectory'] = Utilities.fromNativeSeparators( self.project.getRelativePath( self.parameters['qtHelpOutputDirectory'])) if os.path.isabs(self.parameters['outputDirectory']): args.append("--qhp-outdir={0}".format( self.parameters['qtHelpOutputDirectory'])) else: args.append("--qhp-outdir={0}".format( os.path.join(self.ppath, self.parameters['qtHelpOutputDirectory']))) if self.parameters['qtHelpNamespace'] != \ self.defaults['qtHelpNamespace']: parms['qtHelpNamespace'] = self.parameters['qtHelpNamespace'] args.append("--qhp-namespace={0}".format( self.parameters['qtHelpNamespace'])) if self.parameters['qtHelpVirtualFolder'] != \ self.defaults['qtHelpVirtualFolder']: parms['qtHelpVirtualFolder'] = \ self.parameters['qtHelpVirtualFolder'] args.append("--qhp-virtualfolder={0}".format( self.parameters['qtHelpVirtualFolder'])) if self.parameters['qtHelpFilterName'] != \ self.defaults['qtHelpFilterName']: parms['qtHelpFilterName'] = self.parameters['qtHelpFilterName'] args.append("--qhp-filtername={0}".format( self.parameters['qtHelpFilterName'])) if self.parameters['qtHelpFilterAttributes'] != \ self.defaults['qtHelpFilterAttributes']: parms['qtHelpFilterAttributes'] = \ self.parameters['qtHelpFilterAttributes'] args.append("--qhp-filterattribs={0}".format( self.parameters['qtHelpFilterAttributes'])) if self.parameters['qtHelpTitle'] != self.defaults['qtHelpTitle']: parms['qtHelpTitle'] = self.parameters['qtHelpTitle'] args.append("--qhp-title={0}".format( self.parameters['qtHelpTitle'])) if self.parameters['qtHelpCreateCollection'] != \ self.defaults['qtHelpCreateCollection']: parms['qtHelpCreateCollection'] = \ self.parameters['qtHelpCreateCollection'] args.append('--create-qhc') return (args, parms)
def __init__(self, vm): """ Constructor @param vm view manager widget (Tabview) """ super(TabWidget, self).__init__() self.__tabBar = TabBar(self) self.setTabBar(self.__tabBar) iconSize = self.__tabBar.iconSize() self.__tabBar.setIconSize( QSize(2 * iconSize.width(), iconSize.height())) self.setUsesScrollButtons(True) self.setElideMode(Qt.ElideNone) if isMacPlatform(): self.setDocumentMode(True) self.__tabBar.tabMoveRequested.connect(self.moveTab) self.__tabBar.tabRelocateRequested.connect(self.__relocateTab) self.__tabBar.tabCopyRequested[str, int, int].connect( self.__copyTabOther) self.__tabBar.tabCopyRequested[int, int].connect(self.__copyTab) self.vm = vm self.editors = [] self.indicator = E5Led(self) self.setCornerWidget(self.indicator, Qt.TopLeftCorner) self.rightCornerWidget = QWidget(self) self.rightCornerWidgetLayout = QHBoxLayout(self.rightCornerWidget) self.rightCornerWidgetLayout.setContentsMargins(0, 0, 0, 0) self.rightCornerWidgetLayout.setSpacing(0) self.__navigationMenu = QMenu(self) self.__navigationMenu.aboutToShow.connect(self.__showNavigationMenu) self.__navigationMenu.triggered.connect(self.__navigationMenuTriggered) self.navigationButton = QToolButton(self) self.navigationButton.setIcon(UI.PixmapCache.getIcon("1downarrow.png")) self.navigationButton.setToolTip(self.tr("Show a navigation menu")) self.navigationButton.setPopupMode(QToolButton.InstantPopup) self.navigationButton.setMenu(self.__navigationMenu) self.navigationButton.setEnabled(False) self.rightCornerWidgetLayout.addWidget(self.navigationButton) if Preferences.getUI("SingleCloseButton") or \ not hasattr(self, 'setTabsClosable'): self.closeButton = QToolButton(self) self.closeButton.setIcon(UI.PixmapCache.getIcon("close.png")) self.closeButton.setToolTip( self.tr("Close the current editor")) self.closeButton.setEnabled(False) self.closeButton.clicked[bool].connect(self.__closeButtonClicked) self.rightCornerWidgetLayout.addWidget(self.closeButton) else: self.tabCloseRequested.connect(self.__closeRequested) self.closeButton = None self.setCornerWidget(self.rightCornerWidget, Qt.TopRightCorner) self.__initMenu() self.contextMenuEditor = None self.contextMenuIndex = -1 self.setTabContextMenuPolicy(Qt.CustomContextMenu) self.customTabContextMenuRequested.connect(self.__showContextMenu) ericPic = QPixmap( os.path.join(getConfig('ericPixDir'), 'eric_small.png')) self.emptyLabel = QLabel() self.emptyLabel.setPixmap(ericPic) self.emptyLabel.setAlignment(Qt.AlignVCenter | Qt.AlignHCenter) super(TabWidget, self).addTab( self.emptyLabel, UI.PixmapCache.getIcon("empty.png"), "")
# """ Module implementing a debugger stub for remote debugging. """ import os import sys import distutils.sysconfig from eric6config import getConfig debugger = None __scriptname = None modDir = distutils.sysconfig.get_python_lib(True) ericpath = os.getenv('ERICDIR', getConfig('ericDir')) if ericpath not in sys.path: sys.path.insert(-1, ericpath) def initDebugger(kind="standard"): """ Module function to initialize a debugger for remote debugging. @param kind type of debugger ("standard" or "threads") @return flag indicating success (boolean) @exception ValueError raised to indicate a wrong debugger kind """ global debugger res = True
def __newUiForm(self, path): """ Private slot to handle the New Form menu action for Qt-related projects. @param path full directory path for the new form file (string) """ selectedForm, ok = QInputDialog.getItem( None, self.tr("New Form"), self.tr("Select a form type:"), self.templateTypes4, 0, False) if not ok or not selectedForm: # user pressed cancel return templateIndex = self.templateTypes4.index(selectedForm) templateFile = os.path.join( getConfig('ericTemplatesDir'), self.templates4[templateIndex]) fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( self, self.tr("New Form"), path, self.tr("Qt User-Interface Files (*.ui);;All Files (*)"), "", E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) if not fname: # user aborted or didn't enter a filename return ext = QFileInfo(fname).suffix() if not ext: ex = selectedFilter.split("(*")[1].split(")")[0] if ex: fname += ex if os.path.exists(fname): res = E5MessageBox.yesNo( self, self.tr("New Form"), self.tr("The file already exists! Overwrite it?"), icon=E5MessageBox.Warning) if not res: # user selected to not overwrite return try: shutil.copy(templateFile, fname) except IOError as e: E5MessageBox.critical( self, self.tr("New Form"), self.tr( "<p>The new form file <b>{0}</b> could not be created.<br>" "Problem: {1}</p>").format(fname, str(e))) return self.project.appendFile(fname) self.designerFile.emit(fname)
""" Module implementing a debugger stub for remote debugging. """ import os import sys import distutils.sysconfig from eric6config import getConfig debugger = None __scriptname = None modDir = distutils.sysconfig.get_python_lib(True) ericpath = os.getenv("ERICDIR", getConfig("ericDir")) if ericpath not in sys.path: sys.path.insert(-1, ericpath) def initDebugger(kind="standard"): """ Module function to initialize a debugger for remote debugging. @param kind type of debugger ("standard" or "threads") @return flag indicating success (boolean) @exception ValueError raised to indicate a wrong debugger kind """ global debugger res = True
def generateParameters(self): """ Public method that generates the commandline parameters. It generates a list of strings to be used to set the QProcess arguments for the ericapi call and a dictionary containing the non default parameters. This dictionary can be passed back upon object generation to overwrite the default settings. @return a tuple of the commandline parameters and non default parameters (list of strings, dictionary) """ parms = {} args = [] # 1. the program name args.append(sys.executable) args.append( Utilities.normabsjoinpath(getConfig('ericDir'), "eric6_api.py")) # 2. the commandline options if self.parameters['outputFile'] != self.defaults['outputFile']: parms['outputFile'] = Utilities.fromNativeSeparators( self.project.getRelativePath(self.parameters['outputFile'])) args.append('-o') if os.path.isabs(self.parameters['outputFile']): args.append(self.parameters['outputFile']) else: args.append( os.path.join(self.ppath, self.parameters['outputFile'])) else: self.parameters['outputFile'] = self.defaults['outputFile'] if self.parameters['basePackage'] != self.defaults['basePackage']: parms['basePackage'] = self.parameters['basePackage'] args.append('-b') args.append(self.parameters['basePackage']) if self.parameters['ignoreDirectories'] != \ self.defaults['ignoreDirectories']: parms['ignoreDirectories'] = \ self.parameters['ignoreDirectories'][:] for d in self.parameters['ignoreDirectories']: args.append('-x') args.append(d) if self.parameters['ignoreFilePatterns'] != \ self.defaults['ignoreFilePatterns']: parms['ignoreFilePatterns'] = \ self.parameters['ignoreFilePatterns'][:] for pattern in self.parameters['ignoreFilePatterns']: args.append("--exclude-file={0}".format(pattern)) if self.parameters['useRecursion'] != self.defaults['useRecursion']: parms['useRecursion'] = self.parameters['useRecursion'] args.append('-r') if self.parameters['sourceExtensions'] != \ self.defaults['sourceExtensions']: parms['sourceExtensions'] = self.parameters['sourceExtensions'][:] for ext in self.parameters['sourceExtensions']: args.append('-t') args.append(ext) if self.parameters['includePrivate'] != \ self.defaults['includePrivate']: parms['includePrivate'] = self.parameters['includePrivate'] args.append('-p') parms['languages'] = self.parameters['languages'][:] for lang in self.parameters['languages']: args.append('--language={0}'.format(lang)) return (args, parms)