예제 #1
0
파일: watch.py 프로젝트: JohanAberg/plow
    def addJob(self, job):
        if self.__jobs.has_key(job.id):
            return False

        item = QtGui.QTreeWidgetItem([
            job.name,
            "",
            "%02d" % job.totals.running,
            "%02d" % job.totals.waiting,
            "%02d" % job.minCores,
            formatMaxValue(job.maxCores),
            formatDuration(job.startTime, job.stopTime)
        ])

        self.__jobs[job.id] = item

        item.setToolTip(6, "Started: %s\nStopped:%s" % 
            (formatDateTime(job.startTime), formatDateTime(job.stopTime)))

        item.setData(0, JOBID_ROLE, job.id)
        item.setData(0, JOB_ROLE, job)

        self.__tree.addTopLevelItem(item)

        progress = JobProgressBar(job.totals, self.__tree)
        self.__tree.setItemWidget(item, len(self.Header)-1, progress);

        self.__setJobStateAndColor(item)

        return True
예제 #2
0
    def addJob(self, job):
        if self.__jobs.has_key(job.id):
            return False

        item = QtGui.QTreeWidgetItem([
            job.name, "",
            "%02d" % job.totals.running,
            "%02d" % job.totals.waiting,
            "%02d" % job.minCores,
            formatMaxValue(job.maxCores),
            formatDuration(job.startTime, job.stopTime)
        ])

        self.__jobs[job.id] = item

        item.setToolTip(
            6, "Started: %s\nStopped:%s" %
            (formatDateTime(job.startTime), formatDateTime(job.stopTime)))

        item.setData(0, JOBID_ROLE, job.id)
        item.setData(0, JOB_ROLE, job)

        self.__tree.addTopLevelItem(item)

        progress = JobProgressBar(job.totals, self.__tree)
        self.__tree.setItemWidget(item,
                                  len(self.Header) - 1, progress)

        self.__setJobStateAndColor(item)

        return True
예제 #3
0
파일: watch.py 프로젝트: JohanAberg/plow
    def updateJob(self, job):
        item = self.__jobs[job.id]
        item.setData(0, JOB_ROLE, job)

        item.setText(2, "%02d" % job.totals.running)
        item.setText(3, "%02d" % job.totals.waiting)
        item.setText(4, "%02d" % job.minCores)
        item.setText(5, formatMaxValue(job.maxCores))
        item.setText(6, formatDuration(job.startTime, job.stopTime))

        item.setToolTip(6, "Started: %s\nStopped:%s" % 
            (formatDateTime(job.startTime), formatDateTime(job.stopTime)))

        self.__tree.itemWidget(item, len(self.Header)-1).setTotals(job.totals)
        self.__setJobStateAndColor(item)
예제 #4
0
    def data(self, column, role=QtCore.Qt.DisplayRole):
        job = self.ref 

        DISP = QtCore.Qt.DisplayRole
        TOOL = QtCore.Qt.ToolTipRole
        BG = QtCore.Qt.BackgroundRole
        FG = QtCore.Qt.ForegroundRole

        if role == QtCore.Qt.TextAlignmentRole:
            if column > 0:
                return QtCore.Qt.AlignCenter

        # State
        if column == 2:
            if role == DISP or role == BG or role == FG:
                totals = job.totals
                color = QtCore.Qt.black 
                bgcolor = constants.COLOR_JOB_STATE[job.state]
                text = constants.JOB_STATES[job.state]

                if job.paused:
                    bgcolor = constants.BLUE
                    color = QtCore.Qt.white

                elif totals.dead:
                    bgcolor = constants.COLOR_TASK_STATE[TaskState.DEAD]
                    color = QtCore.Qt.white

                if role == BG:
                    return QtGui.QBrush(bgcolor)
               
                elif role == FG:
                    return QtGui.QBrush(color)
               
                else:
                    return text

        # Start time
        elif column == 4:
            if role == DISP:
                return formatDuration(job.startTime, job.stopTime)
            elif role == TOOL:
                return "Started: {0}\nStopped:{1}".format(
                            formatDateTime(job.startTime), 
                            formatDateTime(job.stopTime) )

        return super(JobNode, self).data(column, role)
예제 #5
0
    def updateJob(self, job):
        item = self.__jobs[job.id]
        item.setData(0, JOB_ROLE, job)

        item.setText(2, "%02d" % job.totals.running)
        item.setText(3, "%02d" % job.totals.waiting)
        item.setText(4, "%02d" % job.minCores)
        item.setText(5, formatMaxValue(job.maxCores))
        item.setText(6, formatDuration(job.startTime, job.stopTime))

        item.setToolTip(
            6, "Started: %s\nStopped:%s" %
            (formatDateTime(job.startTime), formatDateTime(job.stopTime)))

        self.__tree.itemWidget(item,
                               len(self.Header) - 1).setTotals(job.totals)
        self.__setJobStateAndColor(item)
예제 #6
0
파일: wrangle.py 프로젝트: Br3nda/plow
    def data(self, column, role=QtCore.Qt.DisplayRole):
        job = self.ref 

        DISP = QtCore.Qt.DisplayRole
        TOOL = QtCore.Qt.ToolTipRole
        BG = QtCore.Qt.BackgroundRole
        FG = QtCore.Qt.ForegroundRole

        # State
        if column == 6:
            if role == DISP or role == BG or role == FG:
                totals = job.totals
                color = QtCore.Qt.black 
                bgcolor = constants.COLOR_JOB_STATE[job.state]
                text = constants.JOB_STATES[job.state]

                if job.paused:
                    bgcolor = constants.BLUE
                    color = QtCore.Qt.white

                elif totals.dead:
                    bgcolor = constants.COLOR_TASK_STATE[TaskState.DEAD]
                    color = QtCore.Qt.white

                if role == BG:
                    return QtGui.QBrush(bgcolor)
               
                elif role == FG:
                    return QtGui.QBrush(color)
               
                else:
                    return text

        # Start time
        elif column == 8 and role == TOOL:
            start = formatDateTime(job.startTime)
            stop = formatDateTime(job.stopTime)
            return "Started: {0}\nStopped:{1}".format(start, stop)

        return super(JobNode, self).data(column, role)
예제 #7
0
    def addJob(self, job):
        if self.__jobs.has_key(job.id):
            return False

        item = QtGui.QTreeWidgetItem([
            job.name, "",
            "%02d" % job.totals.running,
            "%02d" % (job.totals.waiting + job.totals.depend),
            "%02d" % job.minCores,
            formatMaxValue(job.maxCores),
            formatMaxValue(job.stats.highRam),
            formatDuration(job.startTime, job.stopTime)
        ])

        center = QtCore.Qt.AlignCenter
        for i in xrange(2, item.columnCount()):
            item.setTextAlignment(i, center)

        self.__jobs[job.id] = item

        item.setToolTip(0, job.name)

        item.setToolTip(
            6, "Started: %s\nStopped:%s" %
            (formatDateTime(job.startTime), formatDateTime(job.stopTime)))

        item.setData(0, JOBID_ROLE, job.id)
        item.setData(0, JOB_ROLE, job)

        self.__tree.addTopLevelItem(item)

        progress = JobProgressBar(job.totals, self.__tree)
        self.__tree.setItemWidget(item,
                                  len(self.HEADER) - 1, progress)

        self.__setJobStateAndColor(item)

        return True
예제 #8
0
파일: watch.py 프로젝트: Br3nda/plow
    def addJob(self, job):
        if self.__jobs.has_key(job.id):
            return False

        item = QtGui.QTreeWidgetItem([
            job.name,
            "",
            "%02d" % job.totals.running,
            "%02d" % (job.totals.waiting + job.totals.depend),
            "%02d" % job.minCores,
            formatMaxValue(job.maxCores),
            formatMaxValue(job.stats.highRam),
            formatDuration(job.startTime, job.stopTime)
        ])

        center = QtCore.Qt.AlignCenter
        for i in xrange(2, item.columnCount()):
            item.setTextAlignment(i, center)

        self.__jobs[job.id] = item

        item.setToolTip(0, job.name)

        item.setToolTip(6, "Started: %s\nStopped:%s" % 
            (formatDateTime(job.startTime), formatDateTime(job.stopTime)))

        item.setData(0, JOBID_ROLE, job.id)
        item.setData(0, JOB_ROLE, job)

        self.__tree.addTopLevelItem(item)

        progress = JobProgressBar(job.totals, self.__tree)
        self.__tree.setItemWidget(item, len(self.HEADER)-1, progress);

        self.__setJobStateAndColor(item)

        return True
예제 #9
0
 def __init__(self, value, parent=None):
     FormWidget.__init__(self, parent)
     self.setWidget(QtGui.QLabel(formatDateTime(value), self))
예제 #10
0
class JobNode(PlowNode):

    TYPE = JOB_TYPE
    HEADERS = [
                "Name", "Running", "State", "Owner", 
                "Duration", "maxRam",
               ]

    HEADER_WIDTHS = (400,75,80,80,100,50)

    DISPLAY_CALLBACKS = [
        lambda j: j.name,
        lambda j: "{0} / {1}".format(j.totals.succeeded, j.totals.total),
        lambda j: "Paused" if j.paused else JOB_STATES.get(j.state, '').title(),
        lambda j: j.username,
        lambda j: formatDateTime(j.startTime),
        lambda j: j.stats.highRam,
    ]

    DATA_CALLBACKS = DISPLAY_CALLBACKS[:]
    DATA_CALLBACKS[2] = lambda j: (j.totals.succeeded / float(j.totals.total)) if j.totals.total else 0
    DATA_CALLBACKS[4] = lambda j: j.startTime

    def data(self, column, role=QtCore.Qt.DisplayRole):
        job = self.ref 

        DISP = QtCore.Qt.DisplayRole
        TOOL = QtCore.Qt.ToolTipRole
        BG = QtCore.Qt.BackgroundRole
        FG = QtCore.Qt.ForegroundRole

        if role == QtCore.Qt.TextAlignmentRole:
            if column > 0:
                return QtCore.Qt.AlignCenter

        # State
        if column == 2:
            if role == DISP or role == BG or role == FG:
                totals = job.totals
                color = QtCore.Qt.black 
                bgcolor = constants.COLOR_JOB_STATE[job.state]
                text = constants.JOB_STATES[job.state]

                if job.paused:
                    bgcolor = constants.BLUE
                    color = QtCore.Qt.white

                elif totals.dead:
                    bgcolor = constants.COLOR_TASK_STATE[TaskState.DEAD]
                    color = QtCore.Qt.white

                if role == BG:
                    return QtGui.QBrush(bgcolor)
               
                elif role == FG:
                    return QtGui.QBrush(color)
               
                else:
                    return text

        # Start time
        elif column == 4:
            if role == DISP:
                return formatDuration(job.startTime, job.stopTime)
            elif role == TOOL:
                return "Started: {0}\nStopped:{1}".format(
                            formatDateTime(job.startTime), 
                            formatDateTime(job.stopTime) )

        return super(JobNode, self).data(column, role)
예제 #11
0
파일: fwidgets.py 프로젝트: Br3nda/plow
 def __init__(self, value, parent=None):
     FormWidget.__init__(self, parent)
     self.setWidget(QtGui.QLabel(formatDateTime(value), self))