Exemplo n.º 1
0
 def iterRows(self, **kwargs: object) -> Iterator[XMLContent]:
     data = cast(TableData[Record], kwargs['data'])
     columns = data.columns
     for rowNr, record in enumerate(data.records):
         style = self.joinStyles(self.iterRowStyles(rowNr, record,
                                                    **kwargs))
         yield row(class_=style)[(column.presentCell(record, **kwargs)
                                  for column in columns)]
Exemplo n.º 2
0
 def iterRows(self, **kwargs: Any) -> Iterator[XMLContent]:
     job: Job = kwargs['job']
     for task in job.getTaskSequence():
         yield row(class_=task.result)[
             task.getName(),
             formatTime(task.startTime),
             cell(class_='rightalign')[formatDuration(task.getDuration())],
             taskSummary(task), task.result]
Exemplo n.º 3
0
 def iterRows(self, **kwargs: object) -> Iterator[XMLContent]:
     args = cast(CapFilterArgs, getattr(kwargs['proc'], 'args'))
     active = args.restype
     for value, name, desc in self.iterOptions(**kwargs):
         yield row(class_='match' if active == value else None)[
             pageLink('Capabilities', args.override(restype=value))[
                 name
                 ],
             desc
             ]
Exemplo n.º 4
0
 def iterRows(self, **kwargs: object) -> Iterator[XMLContent]:
     proc = cast(JobProcessor, kwargs['proc'])
     jobId = proc.args.jobId
     taskParams = cast(Mapping[str, Sequence[Tuple[bool, str, str]]],
                       kwargs['taskParams'])
     for name, params in taskParams.items():
         first = True
         for final, key, value in params:
             cells: List[XMLContent] = []
             if first:
                 cells.append(cell(rowspan=len(params))[
                     createTaskInfoLink(jobId, name)
                     ])
                 first = False
             cells += [key, value]
             yield row(class_='final' if final else None)[cells]
Exemplo n.º 5
0
 def iterRows(self, **kwargs: object) -> Iterator[XMLContent]:
     form = cast(_FormPresenter, kwargs['form'])
     formId = form.id
     name = self.name
     active = self.getActive(**kwargs)
     for index, item in enumerate(self.iterOptions(**kwargs)):
         focus = index == 0 and form.addControl(name, True)
         key = cast(str, item[0])
         box = xhtml.input(
             type = 'radio', tabindex = 1, name = name, value = key,
             checked = key == active, autofocus = focus
             )
         yield row(
             # Note: While clicking the label will activate the button,
             #       the JavaScript reacts to the entire row.
             onclick=f"document.forms.{formId}['{name}'][{index:d}]"
                                                         '.checked=true',
             class_='clickable'
             )[ self.formatOption(box, item[1:]) ]
Exemplo n.º 6
0
    def iterRows(self, **kwargs: object) -> Iterator[XMLContent]:
        data = cast(TableData[ResourceBase], kwargs['data'])
        recordsByType: DefaultDict[str, List[ResourceBase]] = \
                defaultdict(list)
        for record in data.records:
            recordsByType[record.typeName].append(record)

        proc = cast(ResourceIndex_GET.Processor, kwargs['proc'])
        columns = data.columns
        numColumns = sum(column.colSpan for column in columns)
        for resType in iterResourceTypes(proc.resTypeDB):
            resTypeName = resType.getId()
            if resTypeName in recordsByType:
                yield row[header(
                    colspan=numColumns,
                    class_='section')[presentResTypeName(resTypeName)]]
                for record in recordsByType[resTypeName]:
                    yield row(
                        class_=getResourceStatus(record))[(column.presentCell(
                            record, **kwargs) for column in columns)]
Exemplo n.º 7
0
    def iterRows(self, **kwargs: object) -> Iterator[XMLContent]:
        proc = cast(TaskRunnerDetails_GET.Processor, kwargs['proc'])
        runner = proc.taskRunner
        if runner is None:
            # Note: This is also reachable through auto-refresh of older
            #       renderings of the page.
            yield '-', ('Task Runner ', xhtml.b[proc.args.runnerId],
                        ' does not exist (anymore).')
            return

        yield 'Description', runner.description
        yield 'Version', runner['runnerVersion']
        yield 'Host', runner['host']
        yield 'Token ID', runner.token.getId()
        targets = proc.project.getTargets()
        yield 'Targets', presentCapabilities(runner.capabilities & targets,
                                             taskRunnerResourceTypeName)
        yield 'Other capabilities', presentCapabilities(
            runner.capabilities - targets, taskRunnerResourceTypeName)
        lastSync = cast(Optional[int], runner['lastSync'])
        yield 'Time since last sync', formatDuration(lastSync)
        run = runner.getRun()
        yield 'Current job', ('-' if run is None else createJobLink(
            cast(str, run['jobId'])))
        yield 'Current task', createTaskLink(runner)
        yield 'Duration', formatDuration(run.getDuration() if run else None)
        status = getResourceStatus(runner)
        yield row(class_=status)['Status', status]
        yield 'Exit when idle', 'yes' if runner.shouldExit() else 'no'
        yield 'Suspended', 'yes' if runner.isSuspended() else 'no'

        label = 'Last suspended' if runner.isSuspended() else 'Last resumed'
        changedTime = runner.getChangedTime()
        if changedTime:
            changeDesc = 'by %s at %s' % (runner.getChangedUser() or 'unknown',
                                          formatTime(changedTime))
        else:
            changeDesc = 'never'
        yield label, changeDesc
Exemplo n.º 8
0
 def iterRows(self, **kwargs: object) -> Iterator[XMLContent]:
     proc = cast(ScheduleDetails_GET.Processor, kwargs['proc'])
     scheduled = proc.scheduled
     configDB = proc.configDB
     configId = scheduled.configId
     if configId is None:
         yield 'Tag', TagsTable.instance.present(**kwargs)
     else:
         yield 'Configuration', (
             createConfigDetailsLink(configDB, configId, 'view'),
             ' or ',
             pageLink('FastExecute', ConfigIdArgs(configId = configId))[
                 'execute'
                 ],
             f' configuration "{configId}"'
             )
     yield 'Last run', createLastJobLink(scheduled)
     yield 'Next run', describeNextRun(scheduled)
     repeat = scheduled.repeat
     yield 'Repeat', repeat
     if repeat is ScheduleRepeat.WEEKLY:
         yield 'Days', ', '.join(stringToListDays(scheduled.dayFlags))
     elif repeat is ScheduleRepeat.CONTINUOUSLY:
         minDelay = scheduled.minDelay
         yield 'Minimum delay', \
             f"{minDelay:d} {pluralize('minute', minDelay)}"
     elif repeat is ScheduleRepeat.TRIGGERED:
         yield 'Triggered', 'yes' if scheduled['trigger'] else 'no'
         yield 'Triggers', xhtml.br.join(
             sorted(scheduled.tags.getTagValues('sf.trigger'))
             )
     if proc.userDB.showOwners:
         yield 'Owner', scheduled.owner or '-'
     yield 'Comment', xhtml.br.join(scheduled.comment.splitlines())
     yield row(class_ = getScheduleStatus(configDB, scheduled))[
         'Status', statusDescription(scheduled, configDB)
         ]
Exemplo n.º 9
0
    def iterRows(self, **kwargs: object) -> Iterator[XMLContent]:
        proc = cast(ProcT, kwargs['proc'])
        job = cast(JobProcessorMixin, proc).job
        jobId = job.getId()
        products = self.getProducts(proc)
        hasLocal = any(prod.isLocal() for prod in products)
        for product in products:
            productName = product.getName()
            potentialProducers = {
                task.getName()
                for task in job.getProducers(productName)
            }
            actualProducers = {
                taskName
                for taskName, locator_ in product.getProducers()
            }
            # For user inputs, actualProducers includes tasks that are not
            # in potentialProducers.
            producers = sorted(
                self.filterProducers(proc,
                                     potentialProducers | actualProducers))
            rowStyle = getProductStatus(job, productName) if self.showColors \
                                                          else None

            consumers = sorted(job.getConsumers(productName))

            first = True
            for taskName in producers:
                task = job.getTask(taskName)
                if task is None:
                    # No actual producer; this must be an input product.
                    producerStatus = 'ok'
                    finishedTask = True
                else:
                    producerStatus = getTaskStatus(task)
                    finishedTask = task.isExecutionFinished()

                cells = []
                if first:
                    cells.append(cell(rowspan=len(producers))[productName])
                if first and hasLocal:
                    cells.append(
                        cell(rowspan=len(producers))
                        [createTaskRunnerDetailsLink((
                            product.getLocalAt() or '?') if product.isLocal(
                            ) and not product.isBlocked() else None)])
                if self.showProducers:
                    cells.append(
                        cell(
                            class_=producerStatus if self.showColors else None)
                        ['(job input)' if task is None else createTaskInfoLink(
                            jobId, taskName)])
                if first and self.showConsumers:
                    cells.append(
                        cell(rowspan=len(producers))[xhtml.br.join(
                            createTaskInfoLink(jobId, consumer.getName())
                            for consumer in consumers)])
                locator = product.getLocator(taskName)
                if locator is None and not actualProducers:
                    # For old jobs, only one locator per product was stored.
                    locator = product.getLocator()
                if not self.showColors:
                    locatorStyle = None
                elif locator is None:
                    assert task is not None, \
                        f'input without locator: {taskName}'
                    if finishedTask:
                        locatorStyle = 'cancelled'
                    else:
                        locatorStyle = getTaskStatus(task)
                else:
                    locatorStyle = producerStatus
                cells.append(
                    cell(class_=locatorStyle)[formatLocator(
                        product, locator, finishedTask)])
                yield row(class_=rowStyle)[cells]
                first = False