From 6604a0ffaa5e4f501bc4ad6d369e72580141cdbb Mon Sep 17 00:00:00 2001 From: Peter Eckersley Date: Tue, 16 Jun 2015 12:47:07 -0700 Subject: [PATCH 1/6] Prevent pylint from complaining about some silly things --- .pylintrc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.pylintrc b/.pylintrc index d954b2658..0e3405b1a 100644 --- a/.pylintrc +++ b/.pylintrc @@ -38,7 +38,7 @@ load-plugins=linter_plugin # --enable=similarities". If you want to run only the classes checker, but have # no Warning level messages displayed, use"--disable=all --enable=classes # --disable=W" -disable=fixme,locally-disabled,abstract-class-not-used +disable=fixme,locally-disabled,abstract-class-not-used,bad-continuation,too-few-public-methods # abstract-class-not-used cannot be disabled locally (at least in pylint 1.4.1) @@ -101,7 +101,7 @@ function-rgx=[a-z_][a-z0-9_]{2,40}$ function-name-hint=[a-z_][a-z0-9_]{2,40}$ # Regular expression matching correct variable names -variable-rgx=[a-z_][a-z0-9_]{2,30}$ +variable-rgx=[a-z_][a-z0-9_]{1,30}$ # Naming hint for variable names variable-name-hint=[a-z_][a-z0-9_]{2,30}$ @@ -228,7 +228,8 @@ max-module-lines=1250 indent-string=' ' # Number of spaces of indent required inside a hanging or continued line. -indent-after-paren=4 +# This does something silly/broken... +#indent-after-paren=4 [TYPECHECK] From fd3170e2e8323ba0870841165091026537cc50b0 Mon Sep 17 00:00:00 2001 From: Peter Eckersley Date: Fri, 28 Aug 2015 17:22:25 -0700 Subject: [PATCH 2/6] Disable another silly pylint warning --- .pylintrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pylintrc b/.pylintrc index 0e3405b1a..49277ea32 100644 --- a/.pylintrc +++ b/.pylintrc @@ -38,7 +38,7 @@ load-plugins=linter_plugin # --enable=similarities". If you want to run only the classes checker, but have # no Warning level messages displayed, use"--disable=all --enable=classes # --disable=W" -disable=fixme,locally-disabled,abstract-class-not-used,bad-continuation,too-few-public-methods +disable=fixme,locally-disabled,abstract-class-not-used,bad-continuation,too-few-public-methods,no-self-use # abstract-class-not-used cannot be disabled locally (at least in pylint 1.4.1) From 7325a3f28d964046df58f66281432a576b981459 Mon Sep 17 00:00:00 2001 From: Peter Eckersley Date: Fri, 28 Aug 2015 17:22:58 -0700 Subject: [PATCH 3/6] Make the "run" command the default --- letsencrypt/cli.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/letsencrypt/cli.py b/letsencrypt/cli.py index 066aa388d..1fd04ccbd 100644 --- a/letsencrypt/cli.py +++ b/letsencrypt/cli.py @@ -352,7 +352,7 @@ class HelpfulArgumentParser(object): """ def __init__(self, args, plugins): - self.args = args + print args plugin_names = [name for name, _p in plugins.iteritems()] self.help_topics = HELP_TOPICS + plugin_names + [None] self.parser = configargparse.ArgParser( @@ -365,6 +365,7 @@ class HelpfulArgumentParser(object): self.parser._add_config_file_help = False # pylint: disable=protected-access self.silent_parser = SilentParser(self.parser) + self.args = self.preprocess_args(args) help1 = self.prescan_for_flag("-h", self.help_topics) help2 = self.prescan_for_flag("--help", self.help_topics) assert max(True, "a") == "a", "Gravity changed direction" @@ -377,6 +378,17 @@ class HelpfulArgumentParser(object): #print self.visible_topics self.groups = {} # elements are added by .add_group() + def preprocess_args(self, args): + """Work around some limitations in argparse. + + Currently, add the default verb "run" as a default. + """ + + for token in args: + if token in VERBS: + return args + return ["run"] + args + def prescan_for_flag(self, flag, possible_arguments): """Checks cli input for flags. @@ -543,6 +555,11 @@ def create_parser(plugins, args): return helpful.parser +# For now unfortunately this constant just needs to match the code below; +# there isn't an elegant way to autogenerate it in time. +VERBS = ["run", "auth", "install", "revoke", "rollback", "config_changes",\ + "plugins"] + def _create_subparsers(helpful): subparsers = helpful.parser.add_subparsers(metavar="SUBCOMMAND") From 44d7ac2dce2691116da0ba4fa88d37d7fde89134 Mon Sep 17 00:00:00 2001 From: Peter Eckersley Date: Fri, 28 Aug 2015 17:31:57 -0700 Subject: [PATCH 4/6] Plumbing for tweaked args - to make "run" the default, we need to add it to the args - which means we need to pass that back up to the actual argparse call (This is ugly... probably HelpfulArgParser needs to actuall inherit from argparse...) --- letsencrypt/cli.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/letsencrypt/cli.py b/letsencrypt/cli.py index 1fd04ccbd..9dacf32c6 100644 --- a/letsencrypt/cli.py +++ b/letsencrypt/cli.py @@ -553,7 +553,7 @@ def create_parser(plugins, args): _create_subparsers(helpful) - return helpful.parser + return helpful.parser, helpful.args # For now unfortunately this constant just needs to match the code below; # there isn't an elegant way to autogenerate it in time. @@ -743,7 +743,8 @@ def main(cli_args=sys.argv[1:]): # note: arg parser internally handles --help (and exits afterwards) plugins = plugins_disco.PluginsRegistry.find_all() - args = create_parser(plugins, cli_args).parse_args(cli_args) + parser,tweaked_cli_args = create_parser(plugins, cli_args) + args = parser.parse_args(tweaked_cli_args) config = configuration.NamespaceConfig(args) # Setup logging ASAP, otherwise "No handlers could be found for From f09c8dd7405e4952733f794a87e5b4d90d061ace Mon Sep 17 00:00:00 2001 From: Peter Eckersley Date: Fri, 28 Aug 2015 17:47:37 -0700 Subject: [PATCH 5/6] Satisfy the pylint demon --- letsencrypt/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/letsencrypt/cli.py b/letsencrypt/cli.py index 9dacf32c6..42e501fdf 100644 --- a/letsencrypt/cli.py +++ b/letsencrypt/cli.py @@ -743,7 +743,7 @@ def main(cli_args=sys.argv[1:]): # note: arg parser internally handles --help (and exits afterwards) plugins = plugins_disco.PluginsRegistry.find_all() - parser,tweaked_cli_args = create_parser(plugins, cli_args) + parser, tweaked_cli_args = create_parser(plugins, cli_args) args = parser.parse_args(tweaked_cli_args) config = configuration.NamespaceConfig(args) From 11c6ef32a8c58a420e14b66c150e36adf5976edc Mon Sep 17 00:00:00 2001 From: Peter Eckersley Date: Tue, 15 Sep 2015 17:11:20 -0700 Subject: [PATCH 6/6] Remove stray debugging printf --- letsencrypt/cli.py | 1 - 1 file changed, 1 deletion(-) diff --git a/letsencrypt/cli.py b/letsencrypt/cli.py index 42e501fdf..600adba99 100644 --- a/letsencrypt/cli.py +++ b/letsencrypt/cli.py @@ -352,7 +352,6 @@ class HelpfulArgumentParser(object): """ def __init__(self, args, plugins): - print args plugin_names = [name for name, _p in plugins.iteritems()] self.help_topics = HELP_TOPICS + plugin_names + [None] self.parser = configargparse.ArgParser(