Beispiel #1
0
    def __init__(self, matcherObj=None, *args, **kwargs):
        super(MatcherItem, self).__init__(*args, **kwargs)

        if self.FIELDS_SORTED is None:
            self.FIELDS_SORTED = sorted(self.FIELDS, key=lambda k: self.FIELDS[k])

        if self.TYPES_SORTED is None:
            self.TYPES_SORTED = sorted(self.TYPES, key=lambda k: self.TYPES[k])

        self.__matcher = None
        self.setMinimumHeight(30)
        self.setMaximumHeight(50)

        self._field = field = QtGui.QComboBox(self)
        field.addItems(self.FIELDS_SORTED)
        field.setSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Preferred)

        self._type = typ = QtGui.QComboBox(self)
        typ.addItems(self.TYPES_SORTED)
        typ.setSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Preferred)

        self._value = value = QtGui.QLineEdit(self)
        value.setSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Preferred)

        layout = self._widgetLayout
        layout.setContentsMargins(8, 4, 8, 4)
        layout.addWidget(field)
        layout.addWidget(typ)
        layout.addWidget(value)

        if matcherObj:
            self.setMatcherObject(matcherObj)
Beispiel #2
0
    def __init__(self, job=None, task=None, attrs=None, parent=None):
        QtGui.QWidget.__init__(self, parent)

        self.__task = None 
        self.__log_file = QtCore.QFile()
        self.__log_stream = QtCore.QTextStream()

        openAction = QtGui.QAction("Open Log File", self)
        openAction.setShortcut(QtGui.QKeySequence.Open)
        self.addAction(openAction)

        self.__searchLine = QtGui.QLineEdit(self)
        self.__chk_tail = QtGui.QAction("Tail log", self)
        self.__chk_tail.setCheckable(True)

        prev = QtGui.QToolButton(self)
        prev.setIcon(QtGui.QIcon(":/images/left_arrow.png"))
        prev.setToolTip("Find Previous Match")
        prev.setFixedSize(20,20)

        nxt = QtGui.QToolButton(self)
        nxt.setToolTip("Find Next Match")
        nxt.setIcon(QtGui.QIcon(":/images/right_arrow.png"))
        nxt.setFixedSize(20,20)

        self.__logSelector = sel = QtGui.QComboBox(self)
        sel.setToolTip("Choose logs from previous retries")
        sel.setMaximumWidth(100)

        self.__jobNameLabel = label = QtGui.QLabel(self)
        label.setIndent(10)
        label.setWordWrap(True)
        # label.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse)
        label.hide()
        self.__jobNameSpacer = QtGui.QWidget(self)
        self.__jobNameSpacer.setFixedHeight(6)
        self.__jobNameSpacer.hide()

        def spacer(width):
            w = QtGui.QWidget()
            w.setFixedWidth(width)
            return w

        stretch = QtGui.QWidget()
        stretch.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred)

        self.__toolbar = tb = QtGui.QToolBar(self)
        tb.addWidget(spacer(4))
        tb.addWidget(QtGui.QLabel("Find: ", self))
        tb.addWidget(self.__searchLine)
        self.__findPrevBtn = tb.addWidget(prev)
        self.__findNextBtn = tb.addWidget(nxt)
        tb.addWidget(stretch)
        tb.addWidget(self.__logSelector)
        tb.addAction(self.__chk_tail)
        tb.addWidget(spacer(4))

        self.__view = view = QtGui.QPlainTextEdit(self)
        font = view.font()
        font.setPixelSize(DEFAULT_FONT_SIZE)
        view.setFont(font)
        view.setLineWrapMode(view.WidgetWidth)
        view.setReadOnly(True)
        view.setMaximumBlockCount(1000000)
        # self.__view.setFocusPolicy(QtCore.Qt.NoFocus)

        layout = QtGui.QVBoxLayout(self)
        layout.setSpacing(0)
        layout.setContentsMargins(0,0,0,0)
        layout.addWidget(self.__toolbar)
        layout.addWidget(self.__jobNameLabel)
        layout.addWidget(self.__jobNameSpacer)
        layout.addWidget(self.__view)

        self.__highlighter = TextHighlighter(view.document())
        self.__logWatcher = FileWatcher(self)

        # Connections
        self.__logWatcher.fileChanged.connect(self.__logUpdated)
        self.__chk_tail.toggled.connect(self.__logTailToggled)
        self.__searchLine.textChanged.connect(self.findText)
        self.__searchLine.returnPressed.connect(self.findNext)
        self.__findPrevBtn.triggered.connect(self.findPrev)
        self.__findNextBtn.triggered.connect(self.findNext)
        self.__logSelector.activated[int].connect(self.__logVersionChanged)
        openAction.triggered.connect(self.openLogFile)

        # Optional args
        if job:
            self.setJobName(job.name)

        if task:
            self.setCurrentTask(task)