edq .cli .http .send-exchange
Send an HTTP exchange to the target server.
usage: python3 -m edq.cli.http.send-exchange [-h] SERVER PATH
Send an HTTP exchange to the target server.
positional arguments:
SERVER Server to send the exahnge to.
PATH Path to the exchange file.
options:
-h, --help show this help message and exit
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.net.exchange 12import edq.net.request 13 14def run_cli(args: argparse.Namespace) -> int: 15 """ Run the CLI. """ 16 17 exchange = edq.net.exchange.HTTPExchange.from_path(args.path) 18 _, body = edq.net.request.make_with_exchange(exchange, args.server) 19 20 print(body) 21 22 return 0 23 24def main() -> int: 25 """ Get a parser, parse the args, and call run. """ 26 return run_cli(_get_parser().parse_args()) 27 28def _get_parser() -> argparse.ArgumentParser: 29 """ Get the parser. """ 30 31 parser = edq.core.argparser.get_default_parser(__doc__.strip(), 32 include_net = True, 33 ) 34 35 parser.add_argument('server', metavar = 'SERVER', 36 action = 'store', type = str, 37 help = 'Server to send the exahnge to.') 38 39 parser.add_argument('path', metavar = 'PATH', 40 action = 'store', type = str, 41 help = 'Path to the exchange file.') 42 43 return parser 44 45if (__name__ == '__main__'): 46 sys.exit(main())
def
run_cli(args: argparse.Namespace) -> int:
15def run_cli(args: argparse.Namespace) -> int: 16 """ Run the CLI. """ 17 18 exchange = edq.net.exchange.HTTPExchange.from_path(args.path) 19 _, body = edq.net.request.make_with_exchange(exchange, args.server) 20 21 print(body) 22 23 return 0
Run the CLI.
def
main() -> int:
25def main() -> int: 26 """ Get a parser, parse the args, and call run. """ 27 return run_cli(_get_parser().parse_args())
Get a parser, parse the args, and call run.