def iterRows(self, **kwargs: Any) -> Iterator[XMLContent]: suite: JUnitSuite = kwargs['suite'] casesByClass: DefaultDict[str, List[JUnitCase]] = defaultdict(list) for case in suite.testcase: casesByClass[case.classname].append(case) for classname, cases in casesByClass.items(): for idx, case in enumerate(cases): result = case.result row: List[XMLContent] = [] if idx == 0: row.append(cell(rowspan=len(cases))[classname]) row.append(case.name) row.append(f'{case.time:1.3f}') row.append(cell(class_=result)[resultMap[result]]) yield row
def presentTotals() -> Iterator[XMLContent]: yield xhtml.b['Total'] for tasks in tasksByDay: yield cell( class_='rightalign')[str(len(tasks)) if tasks else ''] yield '' yield ''
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]
def presentTaskRunner(resourceDB: ResourceDB, runnerId: str) -> XMLContent: content: XMLContent try: runner = resourceDB.getTaskRunner(runnerId) except KeyError: status = 'lost' content = runnerId else: status = getResourceStatus(runner) content = createTaskRunnerDetailsLink(runnerId) return cell(class_=status)[ content ]
def createCell(taskName: Optional[str], tasks: Optional[Sequence[Task]], beginTime: int, endTime: int) -> XMLContent: if tasks is None: return '' bar = createStatusBar(tasks, length=0) if taskName is None: return bar url = makeURL(taskName, beginTime, endTime) return cell(onclick=f"document.location='{url}'")[xhtml.a( href=url)[bar]]
def iterRows(self, **kwargs: object) -> Iterator[XMLContent]: taskSet = cast(TaskSetWithInputs, kwargs['taskSet']) grouped = taskSet.getInputsGrouped() localInputs = taskSet.hasLocalInputs() resourceDB: ResourceDB = getattr(kwargs['proc'], 'resourceDB') taskRunners = None for group, groupInputs in grouped: first: Optional[str] = None for inp in groupInputs: inputName = inp.getName() cells: List[XMLContent] = [inputName] prodType = inp.getType() local = inp.isLocal() locator = inp.getLocator() or '' if prodType is ProductType.TOKEN: if local: cells.append('token') else: # Global token: do not include this. continue else: cells.append( textInput(name='prod.' + inputName, value=locator, size=80)) if localInputs and first is None: if local: if taskRunners is None: taskRunners = sorted(runner.getId( ) for runner in resourceDB.iterTaskRunners( ) if self.filterTaskRunner( # TODO: Passing "inp" should not be needed, # but this requires non-trivial # changes in BatchExecute. runner, taskSet, group, inp)) cellData: XMLContent = dropDownList( name='local.' + inputName, selected=inp.getLocalAt() or '', required=True)[emptyOption( disabled=True)['(select Task Runner)'], taskRunners] else: cellData = '-' cells.append(cell(rowspan=len(groupInputs))[cellData]) if first is None: first = inputName elif local: cells[0] = (cells[0], hiddenInput(name='lref.' + inputName, value=first)) yield cells
def presentTaskRunners(resourceDB: ResourceDB, taskLabel: str, runnerIds: Collection[str] ) -> Iterator[XMLContent]: first = True for runner in sorted(runnerIds): if first: yield ( cell(rowspan = len(runnerIds))[ taskLabel ], presentTaskRunner(resourceDB, runner) ) first = False else: yield presentTaskRunner(resourceDB, runner),
def iterRows(self, **kwargs: object) -> Iterator[XMLContent]: proc = cast(ScheduleDetails_GET.Processor, kwargs['proc']) tagKey = proc.scheduled['tagKey'] tagValue = proc.scheduled['tagValue'] numMatches = len(proc.scheduled.getMatchingConfigIds(proc.configDB)) yield 'key:\u00A0', tagKey yield 'value:\u00A0', tagValue tagArgs = TagArgs(tagkey = tagKey, tagvalue = tagValue) yield cell(colspan = 2)[ pageLink('LoadExecute', tagArgs)[ 'view' ], ' or ', pageLink('FastExecute', tagArgs)[ 'execute' ], f' {numMatches:d} matching configurations', ],
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]
def iterRows(self, **kwargs: object) -> Iterator[XMLContent]: getValues = cast(Callable[[str], Sequence[str]], kwargs['getValues']) tagCache = self.getTagCache(**kwargs) tagKeys = tagCache.getKeys() for index, key in enumerate(tagKeys): indexStr = str(index) inputName = 'tagvalues.' + indexStr values = sorted(tagCache.getValues(key)) yield (preserveSpaces(key), (hiddenInput(name='tagkeys.' + indexStr, value=key), textInput(name=inputName, value=getValues(key), size=80)), cell(class_='taglist')[dropDownList( selected='', style='width: 100%', onchange="AddTagValue('" + inputName + "', event);")[chain([''], values)]] if values else cell)
def iterRows(self, **kwargs: Any) -> Iterator[XMLContent]: showChecks: bool = kwargs['showChecks'] suites: Iterable[JUnitSuite] = kwargs['suites'] for suite in suites: row: List[XMLContent] = [suite.name, f'{suite.time:1.3f}'] if showChecks: row.append(len(suite.testcase)) row.append(suite.tests) for count, result in zip( (suite.failures, suite.errors, suite.skipped), (ResultCode.WARNING, ResultCode.ERROR, ResultCode.CANCELLED)): style = None if count == 0 else result # The cast works around a regression in mypy/typeshed: # https://github.com/python/typeshed/issues/4226 row.append(cell(class_=style)[cast(int, count)]) yield row
def iterRows(self, **kwargs: object) -> Iterator[XMLContent]: proc = cast('ConfigDetails_GET.Processor', kwargs['proc']) tasksByName = sorted( ( task.getName(), task ) for task in proc.config.getTasks() ) for taskName, task in tasksByName: taskLink = createTaskDetailsLink(taskName) params = task.getVisibleParameters() first = True for key, value in sorted(params.items()): if first: yield cell(rowspan = len(params))[taskLink], key, value first = False else: yield key, value if first: yield taskLink, '-', '-'
def iterRows(self, **kwargs: object) -> Iterator[XMLContent]: proc = cast(Task_GET.Processor, kwargs['proc']) taskRunDB = proc.taskRunDB taskRun = proc.task.getLatestRun() taskRunId = taskRun.getId() taskName = taskRun.getName() for key in sorted(taskRunDB.getKeys(taskName)): values = [] for run, value in taskRunDB.getData(taskName, [taskRunId], key): assert run == taskRunId values.append(value) if len(values) == 0: value = '-' else: assert len(values) == 1 value = values[0] yield (createDataTrendsLink(taskName, [key])[key], cell(class_='rightalign')[value])
def iterCells( taskName: Optional[str], rowHeader: XMLContent, weekTasks: Iterable[Optional[Sequence[Task]]], totalTasks: Optional[Sequence[Task]]) -> Iterator[XMLContent]: # pylint: disable=stop-iteration-return # https://github.com/PyCQA/pylint/issues/2158 yield rowHeader dayStartGen = iterDays(beginWeek) todayStart = next(dayStartGen) for tasks in weekTasks: tomorrowStart = next(dayStartGen) yield createCell(taskName, tasks, todayStart, tomorrowStart) todayStart = tomorrowStart yield cell(class_='rightalign')[str(len(totalTasks) ) if totalTasks else ''] yield createCell(taskName, totalTasks, beginWeek, endWeek)
def iterRows(self, **kwargs: object) -> Iterator[XMLContent]: form = cast(_FormPresenter, kwargs['form']) active = self.getActive(**kwargs) first = True for key, cells in self.iterOptions(**kwargs): if first: focus = form.addControl(self.name, True) first = False else: focus = False boxCell: XMLContent = cell(class_='clickable', onclick='toggleRow(event)')[ xhtml.label[ xhtml.input( type = 'checkbox', tabindex = 1, name = self.name, value = key, checked = key in active, autofocus = focus ), ' ', cells[0] ] ] yield (boxCell,) + tuple(cells[1 : ])
def presentCell(self, record: ResourceBase, **kwargs: object) -> XMLContent: status = getResourceStatus(record) return cell(class_=status)[status]
def presentCell(self, record: Job, **kwargs: object) -> XMLContent: return cell(class_='strong')[createStatusBar(record.getTaskSequence())]
def iterRows(self, **kwargs: object) -> Iterator[XMLContent]: proc = cast(EditProcessorBase[ResTypeEditArgs, ResType], kwargs['proc']) yield 'Name', proc.args.id or '(unnamed)' yield 'Description', textInput(name='description', size=80) yield 'Exclusive', cell(class_='checkboxes')[ExclusiveWidget.instance]
def presentCell(self, record: Record, **kwargs: object) -> XMLContent: key = self.keyName assert key is not None return cell(class_='rightalign')[formatDuration( cast(Optional[int], record[key]))]
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