From 808c7e4aec95786c798f4202f7209eb7c399f737 Mon Sep 17 00:00:00 2001 From: Abhinav Singh <126065+abhinavsingh@users.noreply.github.com> Date: Sat, 11 Dec 2021 17:44:41 +0530 Subject: [PATCH] Process `--enable-*` flags before loading plugins (#860) * Process `--enable-*` flags before loading plugins * Fix spelling * Ignore RST299 and RST499 --- .flake8 | 2 ++ proxy/common/flag.py | 39 +++++++++++++++++++++++++-------------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/.flake8 b/.flake8 index 1bffdb4268..b18b1a582e 100644 --- a/.flake8 +++ b/.flake8 @@ -73,7 +73,9 @@ extend-ignore = Q003 # FIXME: avoid escaping in-string quotes RST201 # FIXME: missing trailing blank line in docstring RST203 # FIXME: no trailing blank line in docstring + RST299 # FIXME: Cannot extract compound bibliographic field "copyright" RST301 # FIXME: unexpected indent in docstring + RST499 # FIXME: Missing matching underline for section title overline S101 # FIXME: assertions are thrown away in optimized mode, needs audit S104 # FIXME: bind-all interface listen S105 # FIXME: hardcoded password? diff --git a/proxy/common/flag.py b/proxy/common/flag.py index d4b7da733d..2e3f4a9536 100644 --- a/proxy/common/flag.py +++ b/proxy/common/flag.py @@ -156,6 +156,30 @@ def initialize( # unless user overrides the default auth plugin. auth_plugins.append(auth_plugin) + # --enable flags must be parsed before loading plugins + # otherwise we will miss the plugins passed via constructor + args.enable_web_server = cast( + bool, + opts.get( + 'enable_web_server', + args.enable_web_server, + ), + ) + args.enable_static_server = cast( + bool, + opts.get( + 'enable_static_server', + args.enable_static_server, + ), + ) + args.enable_events = cast( + bool, + opts.get( + 'enable_events', + args.enable_events, + ), + ) + # Load default plugins along with user provided --plugins default_plugins = [ bytes_(p) @@ -290,6 +314,7 @@ def initialize( args.num_acceptors = cast( int, num_acceptors if num_acceptors > 0 else multiprocessing.cpu_count(), ) + args.static_server_dir = cast( str, opts.get( @@ -297,13 +322,6 @@ def initialize( args.static_server_dir, ), ) - args.enable_static_server = cast( - bool, - opts.get( - 'enable_static_server', - args.enable_static_server, - ), - ) args.min_compression_limit = cast( bool, opts.get( @@ -324,13 +342,6 @@ def initialize( args.timeout = cast(int, opts.get('timeout', args.timeout)) args.threadless = cast(bool, opts.get('threadless', args.threadless)) args.threaded = cast(bool, opts.get('threaded', args.threaded)) - args.enable_events = cast( - bool, - opts.get( - 'enable_events', - args.enable_events, - ), - ) args.pid_file = cast( Optional[str], opts.get( 'pid_file',