~launchpad-pqm/launchpad/devel

« back to all changes in this revision

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

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-12-22 04:18:30 UTC
  • mfrom: (14564.3.2 megalint-6)
  • Revision ID: launchpad@pqm.canonical.com-20111222041830-444w19r626s6qkzj
[r=jtv][no-qa] Lint.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
__metaclass__ = type
7
7
__all__ = []
8
8
 
9
 
from datetime import datetime, timedelta
 
9
from datetime import (
 
10
    datetime,
 
11
    timedelta,
 
12
    )
10
13
import os
11
14
import pdb
12
15
import socket
23
26
    ListOption,
24
27
    Option,
25
28
    )
 
29
from bzrlib.trace import is_verbose
26
30
from bzrlib.transport import get_transport
27
 
from bzrlib.trace import is_verbose
28
 
from pytz import UTC
29
 
import simplejson
30
 
 
31
31
from devscripts import get_launchpad_root
32
32
from devscripts.ec2test.account import VALID_AMI_OWNERS
33
33
from devscripts.ec2test.credentials import EC2Credentials
42
42
    EC2TestRunner,
43
43
    TRUNK_BRANCH,
44
44
    )
 
45
from pytz import UTC
 
46
import simplejson
45
47
 
46
48
# Options accepted by more than one command.
47
49
 
620
622
        instance.check_bundling_prerequisites(ami_name)
621
623
        instance.set_up_and_run(
622
624
            postmortem, True, self.update_image, instance,
623
 
            extra_update_image_command, ami_name, instance._credentials, public)
 
625
            extra_update_image_command, ami_name, instance._credentials,
 
626
            public)
624
627
 
625
628
    def update_image(self, instance, extra_update_image_command, ami_name,
626
629
                     credentials, public):
792
795
                    current_status = '[FAILED]'
793
796
                else:
794
797
                    current_status = '[OK]    '
795
 
        output = '%-40s  %-10s (up for %s) %10s' % (description, current_status, uptime,
796
 
            instance.id)
 
798
        output = (
 
799
            '%-40s  %-10s (up for %s) %10s'
 
800
            % (description, current_status, uptime, instance.id))
797
801
        if verbose:
798
802
            url = self.get_http_url(instance)
799
803
            if url is None:
800
804
                url = "No web service"
801
805
            output += '\n  %s' % (url,)
802
806
            if instance.state_reason:
803
 
                output += '\n  transition reason: %s' % instance.state_reason.get(
804
 
                    'message', '')
 
807
                output += (
 
808
                    '\n  transition reason: %s'
 
809
                    % instance.state_reason.get('message', ''))
805
810
        return output
806
811
 
807
812
    def format_summary(self, by_state):
824
829
            data = self.get_ec2test_info(instance)
825
830
            if data is None and not all:
826
831
                continue
827
 
            print self.format_instance(instance, data, verbose=(show_urls or is_verbose()))
 
832
            print self.format_instance(
 
833
                instance, data, verbose=(show_urls or is_verbose()))
828
834
        print 'Summary: %s' % (self.format_summary(by_state),)
829
835
 
830
836