Exemplo n.º 1
0
 def prepare_command(self,
                     response,
                     status,
                     action,
                     parameters={},
                     get_page=None,
                     error=None):
     """Prepare a L{Command} for testing."""
     self.url = None
     self.method = None
     self.error = error
     self.response = response
     self.status = status
     self.output = StringIO()
     self.query = None
     if get_page is None:
         get_page = self.get_page
     self.get_page_function = get_page
     self.command = Command("key", "secret", "endpoint", action, parameters,
                            self.output, self.query_factory)
Exemplo n.º 2
0
def get_command(arguments, output=None):
    """Parse C{arguments} and configure a L{Command} instance.

    An access key, secret key, endpoint and action are required.  Additional
    parameters included with the request are passed as parameters to the
    method call.  For example, the following command will create a L{Command}
    object that can invoke the C{DescribeRegions} method with the optional
    C{RegionName.0} parameter included in the request::

      txaws-discover --key KEY --secret SECRET --endpoint URL \
                     --action DescribeRegions --RegionName.0 us-west-1

    @param arguments: The command-line arguments to parse.
    @raises OptionError: Raised if C{arguments} can't be used to create a
        L{Command} object.
    @return: A L{Command} instance configured to make an EC2 API method call.
    """
    options = parse_options(arguments)
    key = options.pop("key")
    secret = options.pop("secret")
    endpoint = options.pop("endpoint")
    action = options.pop("action")
    return Command(key, secret, endpoint, action, options, output)