Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def testInstaller( self, inst, platform ):
for vm in self._vms:
if vm.ostype() != platform:
continue
for case in self._testcases:
if not case.supportsPlatform( platform ):
continue
res = result.Result()
try:
try:
res.setInstaller( inst )
res.setTestCase( case )
res.setVirtualMachine( vm )
res.testStarted()
self.run_test( inst.path, vm, case, res )
res.testFinished()
inst.markAsTested()
except KeyboardInterrupt:
raise
except:
res.addException()
finally:
self._reporter.reportResult( res )
tests = Test.objects.filter(testsuite = testsuite)
evaluation = self.create(
testsuite = testsuite,
last_updated = generate_timestamp(),
percent_complete = 0.00,
reading_system = reading_system
)
evaluation.save()
total_score = Score(category = None, evaluation = evaluation)
total_score.save()
# create results for this evaluation
for t in tests:
result = Result(test = t, evaluation = evaluation, result = RESULT_NOT_ANSWERED)
result.save()
# update the score once results have been created
total_score.update(evaluation.get_all_results())
# create category score entries for this evaluation
categories = Category.objects.filter(testsuite = evaluation.testsuite)
for cat in categories:
score = Score(
category = cat,
evaluation = evaluation
)
score.update(evaluation.get_category_results(cat))
score.save()
return evaluation
try:
try:
conn = httplib.HTTPConnection( self._host )
conn.request( "POST", "{0}/submit.php?project={1}".format( self._location, self._project ), f )
response = conn.getresponse()
print response.status, response.reason
#TODO check result
finally:
if conn:
conn.close()
except:
#TODO: if submitting to cdash fails, try to notify the admin (mail?)
raise
if __name__ == "__main__":
r = result.Result()
r.testStarted()
r.addCheckerResult( result.CheckerResult( "test1", result.CheckerResult.Passed, "" ) )
r.addCheckerResult( result.CheckerResult( "test2", result.CheckerResult.Failed, "Something went wrong, dude!" ) )
time.sleep( 1 )
r.testFinished()
cr = CDashReporter( "http://localhost", "/CDash", "test1" )
cr.reportResult( r )
def select(self, query, on_progress=None, **opts):
import re
from json import loads
from result import Result
if re.search('[)\s]FORMAT\s', query, re.IGNORECASE):
raise Exception('Formatting is not available')
query += ' FORMAT JSONCompact'
url = self._build_url(opts)
data = self._fetch(url, query, on_progress or self.on_progress)
try:
return Result(**loads(data))
except BaseException:
raise_exception(data)
def stat_for_proc(proc: ProcessedTrace, metric: RunMetric) -> FailableValue:
res = (
_RUN_METRIC_GETTERS[metric](proc)
if isinstance(metric, NamedRunMetric)
else _value_for_score_metric(proc, metric)
)
# Type system not always reliable, so use this to report a bad metric
assert isinstance(res, Result) and (
res.is_err() or any(isinstance(res.unwrap(), t) for t in (bool, int, float))
), f"Getter for metric {metric} returned a {type(res)}"
return res
@property
def out_mb(self) -> float:
return bytes_to_mb(self.out_bytes)
@property
def budget(self) -> int:
return self._g.Budget
@with_slots
@dataclass(frozen=True)
class ProcessedHeap:
gc: "ProcessedGC"
index: int
per_heap_history: Result[str, AbstractGCPerHeapHistory]
# Missing for BGCs (don't know why...)
server_gc_history: Result[str, AbstractServerGcHistory]
## Index is a member of MarkRootType enum
_mark_times: Failable[Sequence[float]]
_mark_promoted: Failable[Sequence[float]]
join_info: Result[str, AbstractJoinInfoForHeap]
@property
def clr(self) -> Clr:
return self.gc.clr
def metric(self, metric: SingleHeapMetric) -> FailableValue:
# pylint:disable=import-outside-toplevel
from .single_heap_metrics import get_single_heap_stat
return get_single_heap_stat(self, metric)
return unicode(self.title)
class Message(models.Model):
text = models.TextField(_('Message'), max_length=1024, null=False, blank=False)
type = models.ForeignKey(MessageType)
def interpret(self, ctx):
ResultMessage.objects.create(result=ctx.result, message=self)
class Meta:
verbose_name = _('Message')
verbose_name_plural = _('Messages')
class ResultMessage(models.Model):
message = models.ForeignKey(Message, null=False, blank=False)
result = models.ForeignKey(Result, related_name='messages',
null=False, blank=False)
class Meta:
verbose_name = _('Result message')
verbose_name_plural = _('Result messages')