How to use default_or_flatten_and_uniq method in devtools-proxy

Best Python code snippet using devtools-proxy_python

proxy.py

Source:proxy.py Github

copy

Full Screen

...226 client_id = encoded_id >> (bits_available - bits_for_client_id)227 request_id = encoded_id & max_request_id228 return client_id, request_id229 return encode_id, decode_id, _max_clients230def default_or_flatten_and_uniq(arg, default):231 # Simple helper for parsing arguments with action='append' and default value232 if arg is None:233 return default234 else:235 return list(set(e for ee in arg for e in ee))236def main():237 parser = argparse.ArgumentParser(238 prog='devtools-proxy',239 description='DevTools Proxy'240 )241 default_host = ['127.0.0.1']242 parser.add_argument(243 '--host',244 type=str, nargs='+', action='append',245 help=f'Hosts to serve on (default: {default_host})',246 )247 default_port = [9222]248 parser.add_argument(249 '--port',250 type=int, nargs='+', action='append',251 help=f'Ports to serve on (default: {default_port})',252 )253 parser.add_argument(254 '--chrome-host',255 type=str, default='127.0.0.1',256 help=('Host on which Chrome is running, '257 'it corresponds with --remote-debugging-address Chrome argument (default: %(default)r)'),258 )259 parser.add_argument(260 '--chrome-port',261 type=int, default=12222,262 help=('Port which Chrome remote debugger is listening, '263 'it corresponds with --remote-debugging-port Chrome argument (default: %(default)r)'),264 )265 parser.add_argument(266 '--max-clients',267 type=int, default=8,268 help='Number of clients which proxy can handle during life cycle (default: %(default)r)',269 )270 parser.add_argument(271 '--log',272 default=sys.stdout, type=argparse.FileType('w'),273 help='Write logs to file',274 )275 parser.add_argument(276 '--version',277 action='version',278 version=VERSION,279 help='Print DevTools Proxy version',280 )281 parser.add_argument(282 '--debug',283 action='store_true', default=False,284 help='Turn on debug mode (default: %(default)r)',285 )286 args = parser.parse_args()287 encode_id, decode_id, max_clients = encode_decode_id(args.max_clients)288 args.port = default_or_flatten_and_uniq(args.port, default_port)289 args.host = default_or_flatten_and_uniq(args.host, default_host)290 arguments = {291 'f': {292 'encode_id': encode_id,293 'decode_id': decode_id,294 'print': lambda *a: args.log.write(' '.join(str(v) for v in a) + '\n'),295 'close_log': lambda: args.log.close(),296 },297 'max_clients': max_clients,298 'debug': args.debug,299 'proxy_hosts': args.host,300 'proxy_ports': args.port,301 'chrome_host': args.chrome_host,302 'chrome_port': args.chrome_port,303 'internal': {...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run devtools-proxy automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful