Get buildId from CDash at submit time
Pass extra data when submitting to CDash. If CDash responds with a buildId, construct and display helpful URL that links to the uploaded report.
This commit is contained in:
parent
738d2bd77a
commit
aed9a532c6
@ -63,6 +63,7 @@ def __init__(self, args):
|
|||||||
buildstamp_format = "%Y%m%d-%H%M-{0}".format(args.cdash_track)
|
buildstamp_format = "%Y%m%d-%H%M-{0}".format(args.cdash_track)
|
||||||
self.buildstamp = time.strftime(buildstamp_format,
|
self.buildstamp = time.strftime(buildstamp_format,
|
||||||
time.localtime(self.starttime))
|
time.localtime(self.starttime))
|
||||||
|
self.buildId = None
|
||||||
|
|
||||||
def build_report(self, filename, report_data):
|
def build_report(self, filename, report_data):
|
||||||
self.initialize_report(filename, report_data)
|
self.initialize_report(filename, report_data)
|
||||||
@ -159,6 +160,7 @@ def clean_log_event(event):
|
|||||||
t = env.get_template(phase_template)
|
t = env.get_template(phase_template)
|
||||||
f.write(t.render(report_data))
|
f.write(t.render(report_data))
|
||||||
self.upload(phase_report)
|
self.upload(phase_report)
|
||||||
|
self.print_cdash_link()
|
||||||
|
|
||||||
def concretization_report(self, filename, msg):
|
def concretization_report(self, filename, msg):
|
||||||
report_data = {}
|
report_data = {}
|
||||||
@ -174,6 +176,7 @@ def concretization_report(self, filename, msg):
|
|||||||
with open(output_filename, 'w') as f:
|
with open(output_filename, 'w') as f:
|
||||||
f.write(t.render(report_data))
|
f.write(t.render(report_data))
|
||||||
self.upload(output_filename)
|
self.upload(output_filename)
|
||||||
|
self.print_cdash_link()
|
||||||
|
|
||||||
def initialize_report(self, filename, report_data):
|
def initialize_report(self, filename, report_data):
|
||||||
if not os.path.exists(filename):
|
if not os.path.exists(filename):
|
||||||
@ -191,13 +194,29 @@ def upload(self, filename):
|
|||||||
# Compute md5 checksum for the contents of this file.
|
# Compute md5 checksum for the contents of this file.
|
||||||
md5sum = checksum(hashlib.md5, filename, block_size=8192)
|
md5sum = checksum(hashlib.md5, filename, block_size=8192)
|
||||||
|
|
||||||
|
buildid_regexp = re.compile("<buildId>([0-9]+)</buildId>")
|
||||||
opener = build_opener(HTTPHandler)
|
opener = build_opener(HTTPHandler)
|
||||||
with open(filename, 'rb') as f:
|
with open(filename, 'rb') as f:
|
||||||
url = "{0}&MD5={1}".format(self.cdash_upload_url, md5sum)
|
url = "{0}&build={1}&site={2}&stamp={3}&MD5={4}".format(
|
||||||
|
self.cdash_upload_url, self.buildname, self.site,
|
||||||
|
self.buildstamp, md5sum)
|
||||||
request = Request(url, data=f)
|
request = Request(url, data=f)
|
||||||
request.add_header('Content-Type', 'text/xml')
|
request.add_header('Content-Type', 'text/xml')
|
||||||
request.add_header('Content-Length', os.path.getsize(filename))
|
request.add_header('Content-Length', os.path.getsize(filename))
|
||||||
# By default, urllib2 only support GET and POST.
|
# By default, urllib2 only support GET and POST.
|
||||||
# CDash needs expects this file to be uploaded via PUT.
|
# CDash needs expects this file to be uploaded via PUT.
|
||||||
request.get_method = lambda: 'PUT'
|
request.get_method = lambda: 'PUT'
|
||||||
url = opener.open(request)
|
response = opener.open(request)
|
||||||
|
if not self.buildId:
|
||||||
|
match = buildid_regexp.search(response.read())
|
||||||
|
if match:
|
||||||
|
self.buildId = match.group(1)
|
||||||
|
|
||||||
|
def print_cdash_link(self):
|
||||||
|
if self.buildId:
|
||||||
|
# Construct and display a helpful link if CDash responded with
|
||||||
|
# a buildId.
|
||||||
|
build_url = self.cdash_upload_url
|
||||||
|
build_url = build_url[0:build_url.find("submit.php")]
|
||||||
|
build_url += "buildSummary.php?buildid={0}".format(self.buildId)
|
||||||
|
print("View your build results here:\n {0}\n".format(build_url))
|
||||||
|
Loading…
Reference in New Issue
Block a user