edq.cli.http.send-exchange

Send an HTTP exchange to the target server.

 1# pylint: disable=invalid-name
 2
 3"""
 4Send an HTTP exchange to the target server.
 5"""
 6
 7import argparse
 8import sys
 9
10import edq.core.argparser
11import edq.util.net
12
13def run_cli(args: argparse.Namespace) -> int:
14    """ Run the CLI. """
15
16    exchange = edq.util.net.HTTPExchange.from_path(args.path)
17    _, body = exchange.make_request(args.server)
18
19    print(body)
20
21    return 0
22
23def main() -> int:
24    """ Get a parser, parse the args, and call run. """
25    return run_cli(_get_parser().parse_args())
26
27def _get_parser() -> argparse.ArgumentParser:
28    """ Get the parser. """
29
30    parser = edq.core.argparser.get_default_parser(__doc__.strip(),
31            include_net = True,
32    )
33
34    parser.add_argument('server', metavar = 'SERVER',
35        action = 'store', type = str,
36        help = 'Server to send the exahnge to.')
37
38    parser.add_argument('path', metavar = 'PATH',
39        action = 'store', type = str,
40        help = 'Path to the exchange file.')
41
42    return parser
43
44if (__name__ == '__main__'):
45    sys.exit(main())
def run_cli(args: argparse.Namespace) -> int:
14def run_cli(args: argparse.Namespace) -> int:
15    """ Run the CLI. """
16
17    exchange = edq.util.net.HTTPExchange.from_path(args.path)
18    _, body = exchange.make_request(args.server)
19
20    print(body)
21
22    return 0

Run the CLI.

def main() -> int:
24def main() -> int:
25    """ Get a parser, parse the args, and call run. """
26    return run_cli(_get_parser().parse_args())

Get a parser, parse the args, and call run.