def __init__(self, parent=None, completionMode=QCompleter.PopupCompletion, showHidden=False): """ Constructor @param parent parent widget of the completer (QWidget) @keyparam completionMode completion mode of the completer (QCompleter.CompletionMode) @keyparam showHidden flag indicating to show hidden entries as well (boolean) """ super(E5DirCompleter, self).__init__(parent) self.__model = QFileSystemModel(self) if showHidden: self.__model.setFilter( QDir.Filters(QDir.Drives | QDir.AllDirs | QDir.Hidden)) else: self.__model.setFilter( QDir.Filters(QDir.Drives | QDir.AllDirs)) self.setModel(self.__model) self.setCompletionMode(completionMode) if isWindowsPlatform(): self.setCaseSensitivity(Qt.CaseInsensitive) if parent: parent.setCompleter(self)
def __init__(self, parent = None, completionMode = QCompleter.PopupCompletion, showHidden = False): """ Constructor @param parent parent widget of the completer (QWidget) @keyparam completionMode completion mode of the completer (QCompleter.CompletionMode) @keyparam showHidden flag indicating to show hidden entries as well (boolean) """ QCompleter.__init__(self, parent) self.__model = QFileSystemModel(self) if showHidden: self.__model.setFilter(\ QDir.Filters(QDir.Drives | QDir.AllDirs | QDir.Hidden)) else: self.__model.setFilter(\ QDir.Filters(QDir.Drives | QDir.AllDirs)) self.setModel(self.__model) self.setCompletionMode(completionMode) if isWindowsPlatform(): self.setCaseSensitivity(Qt.CaseInsensitive) if parent: parent.setCompleter(self)
def getPythonLibPath(): """ Function to determine the path to Python's library. @return path to the Python library (string) """ pyFullVers = sys.version.split()[0] vl = re.findall("[0-9.]*", pyFullVers)[0].split(".") major = vl[0] minor = vl[1] pyVers = major + "." + minor pyVersNr = int(major) * 10 + int(minor) if isWindowsPlatform(): libDir = sys.prefix + "\\Lib" else: try: syslib = sys.lib except AttributeError: syslib = "lib" libDir = sys.prefix + "/" + syslib + "/python" + pyVers return libDir
def __writeScriptFile(self): """ Private method to write a script file to the virtualenv directory. """ if self.__pyvenv: basename = "create_pyvenv" else: basename = "create_virtualenv" if isWindowsPlatform(): script = os.path.join(self.__targetDir, basename + ".bat") txt = self.__cmd else: script = os.path.join(self.__targetDir, basename + ".sh") txt = "#!/usr/bin/env sh\n\n" + self.__cmd self.__logOutput( self.tr("\nWriting script file '{0}'.\n").format(script)) try: f = open(script, "w", encoding="utf-8") f.write(txt) f.close() except (IOError, OSError) as err: self.__logError( self.tr("""The script file '{0}' could not be written.\n""" """Reason: {1}\n""").format(script, str(err))) self.__logOutput(self.tr("Done.\n"))
def __init__(self, ui): """ Constructor @param ui reference to the user interface object (UI.UserInterface) """ QObject.__init__(self, ui) self.__ui = ui self.__initialize() self.__defaults = { "VirtualEnvironmentPy2": "", "VirtualEnvironmentPy3": "", "UsePlainPythonPy2": False, "UsePlainPythonPy3": False, "ServerAddress": "", "RecentNumberApps": 10, "UseIPv6": False, "TranslationsEditor": "", "UseExternalBrowser": False, "CheckDeployMode": False, } if isWindowsPlatform(): self.__defaults["ConsoleCommandNoClose"] = "cmd.exe /k" self.__defaults["ConsoleCommand"] = "cmd.exe /c" elif isMacPlatform(): self.__defaults["ConsoleCommandNoClose"] = "xterm -hold -e" self.__defaults["ConsoleCommand"] = "xterm -e" else: self.__defaults["ConsoleCommandNoClose"] = "konsole --noclose -e" self.__defaults["ConsoleCommand"] = "konsole -e" self.__translator = None self.__loadTranslator()
def checkBlacklistedVersions(): """ Module functions to check for blacklisted versions of the prerequisites. @return flag indicating good versions were found (boolean) """ from install import BlackLists, PlatformsBlackLists # determine the platform dependent black list if isWindowsPlatform(): PlatformBlackLists = PlatformsBlackLists["windows"] elif isLinuxPlatform(): PlatformBlackLists = PlatformsBlackLists["linux"] else: PlatformBlackLists = PlatformsBlackLists["mac"] # check version of sip try: import sipconfig sipVersion = sipconfig.Configuration().sip_version_str # always assume, that snapshots are good if "snapshot" not in sipVersion: # check for blacklisted versions for vers in BlackLists["sip"] + PlatformBlackLists["sip"]: if vers == sipVersion: print 'Sorry, sip version %s is not compatible with eric4.' % vers print 'Please install another version.' return False except ImportError: pass # check version of PyQt from PyQt4.QtCore import PYQT_VERSION_STR pyqtVersion = PYQT_VERSION_STR # always assume, that snapshots are good if "snapshot" not in pyqtVersion: # check for blacklisted versions for vers in BlackLists["PyQt4"] + PlatformBlackLists["PyQt4"]: if vers == pyqtVersion: print 'Sorry, PyQt4 version %s is not compatible with eric4.' % vers print 'Please install another version.' return False # check version of QScintilla from PyQt4.Qsci import QSCINTILLA_VERSION_STR scintillaVersion = QSCINTILLA_VERSION_STR # always assume, that snapshots are new enough if "snapshot" not in scintillaVersion: # check for blacklisted versions for vers in BlackLists["QScintilla2"] + PlatformBlackLists["QScintilla2"]: if vers == scintillaVersion: print 'Sorry, QScintilla2 version %s is not compatible with eric4.' % vers print 'Please install another version.' return False return True
def getUserName(): """ Function to get the user name. @return user name (string) """ if isWindowsPlatform(): return win32_GetUserName() else: return posix_GetUserName()
def hasEnvironmentEntry(key): """ Module function to check, if the environment contains an entry. @param key key of the requested environment entry (string) @return flag indicating the presence of the requested entry (boolean) """ filter = QRegExp("^%s[ \t]*=" % key) if isWindowsPlatform(): filter.setCaseSensitivity(Qt.CaseInsensitive) entries = QProcess.systemEnvironment().filter(filter) return entries.count() > 0
def __init__(self, text, fixed=False, linewrap=True, msgSuccess=None, msgError=None, saveFilters=None, parent=None): """ Constructor @param text text to be shown by the label (string) @keyparam fixed flag indicating a fixed font should be used (boolean) @keyparam linewrap flag indicating to wrap long lines (boolean) @keyparam msgSuccess optional string to show upon successful execution (string) @keyparam msgError optional string to show upon unsuccessful execution (string) @keyparam saveFilters filename filter string (string) @keyparam parent parent widget (QWidget) """ super(DjangoDialog, self).__init__(parent) self.setupUi(self) self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) self.buttonBox.button(QDialogButtonBox.Save).setEnabled(False) if saveFilters is None: self.buttonBox.button(QDialogButtonBox.Save).setHidden(True) self.ioEncoding = Preferences.getSystem("IOEncoding") self.proc = None self.argsLists = [] self.workingDir = None self.mergedOutput = False self.msgSuccess = msgSuccess self.msgError = msgError self.fileFilters = saveFilters self.outputGroup.setTitle(text) if fixed: if isWindowsPlatform(): self.resultbox.setFontFamily("Lucida Console") else: self.resultbox.setFontFamily("Monospace") if not linewrap: self.resultbox.setLineWrapMode(QTextEdit.NoWrap)
def generatePySideToolPath(toolname): """ Module function to generate the executable path for a PySide tool. @param toolname base name of the tool (string or QString) @return the PySide tool path with extension (string) """ if isWindowsPlatform(): if toolname == "pyside-uic": return os.path.join(sys.prefix, "Scripts", toolname + '.exe') else: return os.path.join(sys.prefix, "Lib", "site-packages", "PySide", toolname + ".exe") else: return toolname
def getConfigDir(): """ Module function to get the name of the directory storing the config data. @return directory name of the config dir (string) """ if configDir is not None and os.path.exists(configDir): hp = configDir else: if isWindowsPlatform(): cdn = "_eric4" else: cdn = ".eric4" hp = QDir.homePath() dn = QDir(hp) dn.mkdir(cdn) hp.append("/").append(cdn) return unicode(toNativeSeparators(hp))
def getEnvironmentEntry(key, default = None): """ Module function to get an environment entry. @param key key of the requested environment entry (string) @param default value to be returned, if the environment doesn't contain the requested entry (string) @return the requested entry or the default value, if the entry wasn't found (string or None) """ filter = QRegExp("^%s[ \t]*=" % key) if isWindowsPlatform(): filter.setCaseSensitivity(Qt.CaseInsensitive) entries = QProcess.systemEnvironment().filter(filter) if entries.count() == 0: return default # if there are multiple entries, just consider the first one ename, val = unicode(entries[0]).split("=", 1) return val.strip()
def __init__(self, plugin): """ Constructor @param plugin reference to the plugin object """ super(DjangoPage, self).__init__() self.setupUi(self) self.setObjectName("DjangoPage") self.virtualEnvPy3Button.setIcon(UI.PixmapCache.getIcon("open.png")) self.virtualEnvPy2Button.setIcon(UI.PixmapCache.getIcon("open.png")) self.translationsButton.setIcon(UI.PixmapCache.getIcon("open.png")) self.__virtualEnvPy3Completer = E5DirCompleter(self.virtualEnvPy3Edit) self.__virtualEnvPy2Completer = E5DirCompleter(self.virtualEnvPy2Edit) self.__translationsCompleter = E5FileCompleter(self.translationsEdit) self.__plugin = plugin consoleList = [] if isWindowsPlatform(): consoleList.append("cmd.exe /c") elif isMacPlatform(): consoleList.append("xterm -e") consoleList.append("/opt/X11/bin/xterm -e") else: consoleList.append("@konsole --workdir . -e") # KDE4/5 konsole spawns consoleList.append("gnome-terminal -e") consoleList.append("mate-terminal -e") consoleList.append("xfce4-terminal -e") consoleList.append("xterm -e") consoleNoCloseList = [] if isWindowsPlatform(): consoleNoCloseList.append("cmd.exe /k") elif isMacPlatform(): consoleNoCloseList.append("xterm -hold -e") consoleNoCloseList.append("/opt/X11/bin/xterm -hold -e") else: consoleNoCloseList.append("@konsole --noclose --workdir . -e") # KDE4/5 konsole spawns consoleNoCloseList.append("gnome-terminal --profile=<noclose> -e") consoleNoCloseList.append("mate-terminal --profile=<noclose> -e") consoleNoCloseList.append("xfce4-terminal --hold -e") consoleNoCloseList.append("xterm -hold -e") self.consoleCommandCombo.addItems(consoleList) self.consoleCommandNoCloseCombo.addItems(consoleNoCloseList) # set initial values self.consoleCommandCombo.setEditText( self.__plugin.getPreferences("ConsoleCommand")) self.consoleCommandNoCloseCombo.setEditText( self.__plugin.getPreferences("ConsoleCommandNoClose")) self.serverAddressEdit.setText( self.__plugin.getPreferences("ServerAddress")) self.ipv6CheckBox.setChecked(self.__plugin.getPreferences("UseIPv6")) self.externalBrowserCheckBox.setChecked( self.__plugin.getPreferences("UseExternalBrowser")) self.appsRecentSpinBox.setValue( self.__plugin.getPreferences("RecentNumberApps")) self.virtualEnvPy2Edit.setText( self.__plugin.getPreferences("VirtualEnvironmentPy2")) self.plainPython2CheckBox.setChecked( self.__plugin.getPreferences("UsePlainPythonPy2")) self.virtualEnvPy3Edit.setText( self.__plugin.getPreferences("VirtualEnvironmentPy3")) self.plainPython3CheckBox.setChecked( self.__plugin.getPreferences("UsePlainPythonPy3")) self.translationsEdit.setText( self.__plugin.getPreferences("TranslationsEditor"))