~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/devscripts/ec2test/remote.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2010-08-24 21:34:50 UTC
  • mfrom: (11407.2.1 subject-and-attachment)
  • Revision ID: launchpad@pqm.canonical.com-20100824213450-qgo4ifgfaqhxpsah
[r=gmb][ui=none][no-qa] Change the subject and attachment of EC2 test
        mails.

Show diffs side-by-side

added added

removed removed

Lines of Context:
314
314
        conn = bzrlib.smtp_connection.SMTPConnection(self._bzr_config)
315
315
        conn.send_email(message)
316
316
 
317
 
    def get_trunk_details(self):
 
317
    def get_target_details(self):
318
318
        """Return (branch_url, revno) for trunk."""
319
319
        branch = bzrlib.branch.Branch.open(self._local_branch_path)
320
320
        return branch.get_parent().encode('utf-8'), branch.revno()
321
321
 
322
 
    def get_branch_details(self):
 
322
    def get_source_details(self):
323
323
        """Return (branch_url, revno) for the branch we're merging in.
324
324
 
325
325
        If we're not merging in a branch, but instead just testing a trunk,
337
337
 
338
338
    def get_nick(self):
339
339
        """Get the nick of the branch we are testing."""
340
 
        details = self.get_branch_details()
 
340
        details = self.get_source_details()
341
341
        if not details:
342
 
            details = self.get_trunk_details()
 
342
            details = self.get_target_details()
343
343
        url, revno = details
344
344
        return self._last_segment(url)
345
345
 
 
346
    def get_revno(self):
 
347
        """Get the revno of the branch we are testing."""
 
348
        if self._revno is not None:
 
349
            return self._revno
 
350
        return bzrlib.branch.Branch.open(self._local_branch_path).revno()
 
351
 
346
352
    def get_merge_description(self):
347
353
        """Get a description of the merge request.
348
354
 
353
359
        # XXX: JonathanLange 2010-08-17: Not actually used yet. I think it
354
360
        # would be a great thing to have in the subject of the emails we
355
361
        # receive.
356
 
        source = self.get_branch_details()
 
362
        source = self.get_source_details()
357
363
        if not source:
358
 
            return self.get_nick()
359
 
        target = self.get_trunk_details()
 
364
            return '%s r%s' % (self.get_nick(), self.get_revno())
 
365
        target = self.get_target_details()
360
366
        return '%s => %s' % (
361
367
            self._last_segment(source[0]), self._last_segment(target[0]))
362
368
 
391
397
            status = 'SUCCESS'
392
398
        else:
393
399
            status = 'FAILURE'
394
 
        subject = 'Test results: %s' % (status,)
 
400
        subject = 'Test results: %s: %s' % (
 
401
            self.get_merge_description(), status)
395
402
        message['Subject'] = subject
396
403
 
397
404
        # Make the body.
403
410
        zipped_log = MIMEApplication(full_log_gz, 'x-gzip')
404
411
        zipped_log.add_header(
405
412
            'Content-Disposition', 'attachment',
406
 
            filename='%s.log.gz' % self.get_nick())
 
413
            filename='%s-r%s.subunit.gz' % (
 
414
                self.get_nick(), self.get_revno()))
407
415
        message.attach(zipped_log)
408
416
        return message
409
417
 
609
617
            ''')
610
618
 
611
619
        # Describe the trunk branch.
612
 
        trunk, trunk_revno = self._request.get_trunk_details()
 
620
        trunk, trunk_revno = self._request.get_target_details()
613
621
        msg = '%s, revision %d\n' % (trunk, trunk_revno)
614
622
        add_to_html('''\
615
623
            <p><strong>%s</strong></p>
616
624
            ''' % (escape(msg),))
617
625
        log(msg)
618
626
 
619
 
        branch_details = self._request.get_branch_details()
 
627
        branch_details = self._request.get_source_details()
620
628
        if not branch_details:
621
629
            add_to_html('<p>(no merged branch)</p>\n')
622
630
            log('(no merged branch)')