def initializeEnvironment(cls, path): """ CREATE MISSING FILES AND FOLDERS Due to the limited file creation privileges while running NGinx as a normal user, certain files and folders must exist prior to starting the server. """ for folderParts in cls._NGINX_FOLDERS: p = FileUtils.createPath(path, *folderParts, isDir=True) if not os.path.exists(p): os.makedirs(p) for fileParts in cls._NGINX_FILES: p = FileUtils.createPath(path, *fileParts, isFile=True) if not os.path.exists(p): f = open(p, 'w+') f.close() #------------------------------------------------------------------------------------------- # COPY CONF FILES # NGinx requires a number of conf files to be present and comes with a default set of # files, which must be cloned to the target location if they do not already exist. nginxExeConfFolder = FileUtils.createPath(NGinxSetupOps.getExePath(), 'conf', isDir=True) for item in os.listdir(nginxExeConfFolder): itemPath = FileUtils.createPath(nginxExeConfFolder, item) if not os.path.isfile(itemPath): continue targetPath = FileUtils.createPath(path, 'conf', item, isFile=True) if os.path.exists(targetPath): continue shutil.copy(itemPath, targetPath)
def __init__(self, parent, **kwargs): """Creates a new instance of NwmHomeWidget.""" super(NwmHomeWidget, self).__init__(parent, widgetFile=False, id='home', **kwargs) mainLayout = self._getLayout(self, QtGui.QVBoxLayout) mainLayout.setContentsMargins(6, 6, 6, 6) rootPath = self.mainWindow.appConfig.get(AppConfigEnum.ROOT_PATH, NGinxSetupOps.getExePath()) label = QtGui.QLabel(self) label.setText(u'Server Container Path:') label.setStyleSheet(self._HEADER_STYLE) mainLayout.addWidget(label) label = QtGui.QLabel(self) label.setText( u'The absolute path the location NGinx will use as its root source' ) label.setStyleSheet(self._INFO_STYLE) mainLayout.addWidget(label) mainLayout.addSpacing(3) textWidget, textLayout = self._createWidget(self, QtGui.QHBoxLayout, True) text = QtGui.QLineEdit(textWidget) text.setText(rootPath) textLayout.addWidget(text) self._pathLineEdit = text recent = PyGlassPushButton(textWidget, icon=IconSheetMap.DOWN, size=SizeEnum.SMALL) recent.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Preferred) recent.clicked.connect(self._handleRecentLocations) textLayout.addWidget(recent) self._recentBtn = recent browse = PyGlassPushButton(textWidget, icon=IconSheetMap.FOLDER, size=SizeEnum.SMALL) browse.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Preferred) browse.clicked.connect(self._handleLocatePath) textLayout.addWidget(browse) self._browseBtn = browse mainLayout.addSpacing(20) label = QtGui.QLabel(self) label.setText(u'Server Management:') label.setStyleSheet(self._HEADER_STYLE) mainLayout.addWidget(label) label = QtGui.QLabel(self) label.setText(u'Modify the state of your NGinx server') label.setStyleSheet(self._INFO_STYLE) mainLayout.addWidget(label) mainLayout.addSpacing(3) buttonBox, boxLayout = self._createWidget(self, QtGui.QHBoxLayout, True) btn = PyGlassPushButton(buttonBox, text='Start', icon=IconSheetMap.FORWARD) btn.clicked.connect(self._handleStartServer) boxLayout.addWidget(btn) self._startBtn = btn btn = PyGlassPushButton(buttonBox, text='Stop', icon=IconSheetMap.X) btn.clicked.connect(self._handleStopServer) boxLayout.addWidget(btn) self._stopBtn = btn btn = PyGlassPushButton(buttonBox, text='Reload', icon=IconSheetMap.ROTATE) btn.clicked.connect(self._handleReloadServer) boxLayout.addWidget(btn) self._reloadBtn = btn boxLayout.addStretch() mainLayout.addStretch() self._updateDisplay()
def rootPath(self): path = self._pathLineEdit.text() if path: return path return NGinxSetupOps.getExePath()
def __init__(self, parent, **kwargs): super(NGinxRemoteThread, self).__init__(parent, **kwargs) self._path = ArgsUtils.get('rootPath', None, kwargs) if not self._path: self._path = NGinxSetupOps.getExePath()
def __init__(self, parent, **kwargs): """Creates a new instance of NwmHomeWidget.""" super(NwmHomeWidget, self).__init__(parent, widgetFile=False, id='home', **kwargs) mainLayout = self._getLayout(self, QtGui.QVBoxLayout) mainLayout.setContentsMargins(6, 6, 6, 6) rootPath = self.mainWindow.appConfig.get( AppConfigEnum.ROOT_PATH, NGinxSetupOps.getExePath() ) label = QtGui.QLabel(self) label.setText(u'Server Container Path:') label.setStyleSheet(self._HEADER_STYLE) mainLayout.addWidget(label) label = QtGui.QLabel(self) label.setText(u'The absolute path the location NGinx will use as its root source') label.setStyleSheet(self._INFO_STYLE) mainLayout.addWidget(label) mainLayout.addSpacing(3) textWidget, textLayout = self._createWidget(self, QtGui.QHBoxLayout, True) text = QtGui.QLineEdit(textWidget) text.setText(rootPath) textLayout.addWidget(text) self._pathLineEdit = text recent = PyGlassPushButton(textWidget, icon=IconSheetMap.DOWN, size=SizeEnum.SMALL) recent.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Preferred) recent.clicked.connect(self._handleRecentLocations) textLayout.addWidget(recent) self._recentBtn = recent browse = PyGlassPushButton(textWidget, icon=IconSheetMap.FOLDER, size=SizeEnum.SMALL) browse.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Preferred) browse.clicked.connect(self._handleLocatePath) textLayout.addWidget(browse) self._browseBtn = browse mainLayout.addSpacing(20) label = QtGui.QLabel(self) label.setText(u'Server Management:') label.setStyleSheet(self._HEADER_STYLE) mainLayout.addWidget(label) label = QtGui.QLabel(self) label.setText(u'Modify the state of your NGinx server') label.setStyleSheet(self._INFO_STYLE) mainLayout.addWidget(label) mainLayout.addSpacing(3) buttonBox, boxLayout = self._createWidget(self, QtGui.QHBoxLayout, True) btn = PyGlassPushButton(buttonBox, text='Start', icon=IconSheetMap.FORWARD) btn.clicked.connect(self._handleStartServer) boxLayout.addWidget(btn) self._startBtn = btn btn = PyGlassPushButton(buttonBox, text='Stop', icon=IconSheetMap.X) btn.clicked.connect(self._handleStopServer) boxLayout.addWidget(btn) self._stopBtn = btn btn = PyGlassPushButton(buttonBox, text='Reload', icon=IconSheetMap.ROTATE) btn.clicked.connect(self._handleReloadServer) boxLayout.addWidget(btn) self._reloadBtn = btn boxLayout.addStretch() mainLayout.addStretch() self._updateDisplay()