def __init__(self, parent, client, **configs): QDialog.__init__(self, parent) DlgUtils.__init__(self, self.toolName) loadUi(self, 'tools/downtime.ui') self.sendBtn = self.buttonBox.addButton('&Send', QDialogButtonBox.AcceptRole) self.sendBtn.setIcon(QIcon(':/mail')) self.sendBtn.setDisabled(True) self.parentwindow = parent self.client = client if hasattr(parent, 'mainwindow'): self.mainwindow = parent.mainwindow self.log = NicosLogger(self.toolName) self.log.parent = self.mainwindow.log else: self.log = configs.get('log', None) self.sgroup = SettingGroup(self.toolName) self._sender = configs.get('sender', '*****@*****.**') self._receiver = configs.get('receiver', '*****@*****.**') self._mailserver = configs.get('mailserver', '') or \ self._getDeviceComponent('experiment', 'mailserver', 'smtp.frm2.tum.de') self._instrument = configs.get('instrument', '') or \ self._getDeviceComponent('instrument', 'instrument', 'DEMO') t = self.mailheaderText.text().replace('{{instrument}}', self._instrument) self.mailheaderText.setText(t) self.startDown.setDateTime(QDateTime.currentDateTime().addSecs(-3600)) self.endDown.setDateTime(QDateTime.currentDateTime()) self.errorText.setVisible(False) with self.sgroup as settings: self.loadSettings(settings) self.reasons.clearEditText()
def __init__(self, measmode, wavelength, header_labels, current_table, client, parent): QDialog.__init__(self, parent) loadUi(self, findResource('nicos_mlz/gui/tunewavetablepreviewdlg.ui')) self._client = client self._measmode = measmode self._wavelength = float(wavelength) self._header_labels = header_labels self._current_table = current_table self._shown_table = None self._history = {} # {datetime: table} self.measmodeLabel.setText(measmode) self.wavelengthLabel.setText(wavelength) self.timeline = TimelineWidget() self.horizontalLayout.insertWidget(0, self.timeline) self.tableWidget.setColumnCount(len(self._header_labels)) self.tableWidget.setHorizontalHeaderLabels(self._header_labels) self.fromDateTimeEdit.setDateTime( QDateTime.currentDateTime().addMonths(-1)) self.toDateTimeEdit.setDateTime(QDateTime.currentDateTime()) self.fromDateTimeEdit.dateTimeChanged.connect(self.update_timeline) self.toDateTimeEdit.dateTimeChanged.connect(self.update_timeline) self.timeline.timepointSelected.connect(self.update_table) self.diffNoneRadioButton.toggled.connect(self.update_table) self.diffCurrentRadioButton.toggled.connect(self.update_table) self.diffPreviousRadioButton.toggled.connect(self.update_table) self.update_timeline()
def setValue(self, new_data): w = self.currentWidget() if isinstance(w, TimeEditWidget): w.setValue(new_data) elif isinstance(w, QDateTimeEdit): dt = QDateTime() dt.setMSecsSinceEpoch(float(new_data) * 1000) w.setDateTime(dt) elif isinstance(w, QSpinBox): w.setValue(int(new_data)) self.current = new_data self.setEnabled(True)
def __init__(self, parent, client, options): Panel.__init__(self, parent, client, options) self._logPath = 'log' loadUi(self, 'panels/logviewer.ui') # initialize date/time range to display logs from yesterday # (same time) to now self.dateTimeEditFrom.setDateTime( QDateTime.currentDateTime().addDays(-1)) self.dateTimeEditTo.setDateTime(QDateTime.currentDateTime())
def __init__(self, parent, info=None, client=None): QDialog.__init__(self, parent) DlgUtils.__init__(self, 'History viewer') loadUi(self, 'panels/history_new.ui') self.client = client self.fromdate.setDateTime(QDateTime.currentDateTime()) self.todate.setDateTime(QDateTime.currentDateTime()) self.customY.toggled.connect(self.toggleCustomY) self.toggleCustomY(False) self.simpleTime.toggled.connect(self.toggleSimpleExt) self.extTime.toggled.connect(self.toggleSimpleExt) self.frombox.toggled.connect(self.toggleSimpleExt) self.tobox.toggled.connect(self.toggleSimpleExt) self.toggleSimpleExt(True) self.simpleTimeSpec.textChanged.connect(self.setIntervalFromSimple) self.helpButton.clicked.connect(self.showDeviceHelp) self.simpleHelpButton.clicked.connect(self.showSimpleHelp) self.devicesFrame.hide() self.deviceTree = None self.deviceTreeSel = OrderedDict() if not client: self.devicesExpandBtn.hide() else: devices = client.getDeviceList() devcompleter = QCompleter(devices, self) devcompleter.setCompletionMode(QCompleter.InlineCompletion) self.devices.setCompleter(devcompleter) if info is not None: self.devices.setText(info['devices']) self.namebox.setText(info['name']) self.simpleTime.setChecked(info['simpleTime']) self.simpleTimeSpec.setText(info['simpleTimeSpec']) self.slidingWindow.setChecked(info['slidingWindow']) self.extTime.setChecked(not info['simpleTime']) self.frombox.setChecked(info['frombox']) self.tobox.setChecked(info['tobox']) self.fromdate.setDateTime(QDateTime.fromTime_t(info['fromdate'])) self.todate.setDateTime(QDateTime.fromTime_t(info['todate'])) self.interval.setText(info['interval']) self.customY.setChecked(info['customY']) self.customYFrom.setText(info['customYFrom']) self.customYTo.setText(info['customYTo'])
def __init__(self, parent=None, init_widget_info=None, initState=None): QStackedWidget.__init__(self, parent) self.trueLive = TimeEditWidget(self) self.trueLive.setValue(1.0) self.clockTime = QDateTimeEdit(QDateTime.currentDateTime(), self) self.counts = QSpinBox(self) self.widget_types = { 'LiveTime': self.trueLive, 'TrueTime': self.trueLive, 'ClockTime': self.clockTime, 'counts': self.counts, } self.counts.setRange(0, 1000000000) self.counts.setSingleStep(50000) # config QDateTime: self.clockTime.setButtonSymbols(QAbstractSpinBox.NoButtons) # add widgets to Stack self.addWidget(self.trueLive) self.addWidget(self.clockTime) self.addWidget(self.counts) # Init given current widget with data (time.. etc) self.setCurrentWidget(self.widget_types[init_widget_info]) self.setValue(initState) self.trueLive.returnPressed.connect(self.on_returnPressed) self.clockTime.editingFinished.connect(self.on_dt_changed) self.counts.valueChanged[str].connect(self.on_cts_changed) self.setMinimumWidth(90)
def _getFilteredFileContent(self, path, fileDate, filters): # local vars for readability fromDateTime = filters['fromDateTime'] toDateTime = filters['toDateTime'] levels = filters['levels'] result = [] dateStr = fileDate.toString('yyyy-MM-dd ') with open(path, 'r') as f: # store if last line was added, # this is used to filter tracebacks etc properly lastLineAdded = False lastLevel = '' for line in f: # split line into: # time, level, service, msg parts = [part.strip() for part in line.split(' : ')] # append line continuations if len(parts) < 2: if lastLineAdded: result.append(self._colorizeLevel(line, lastLevel)) continue dateTime = QDateTime.fromString(parts[0], 'HH:mm:ss,zzz') dateTime.setDate(fileDate.date()) level = parts[1] # check time if fromDateTime.secsTo(dateTime) < 0 or toDateTime.secsTo( dateTime) > 0: lastLineAdded = False continue # check level if level not in levels: lastLineAdded = False continue # add current day to the line line = dateStr + line result.append(self._colorizeLevel(line, level)) lastLineAdded = True lastLevel = level result = reversed(result) return ''.join(result)
def setValue(self, new_data): self.state[0] = int(float(new_data[0])) self.state[1] = int(float(new_data[1])) dt = QDateTime() dt.setMSecsSinceEpoch(self.state[0] * 1000) self.date_widget.setDateTime(dt)
def set_QDateTimeEdit(self, ctl, val): ctl.setDateTime(QDateTime.fromString(val))