Skip to content

Commit f9d2c1a

Browse files
move redirect inside _main (#401)
1 parent 83e0e1d commit f9d2c1a

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

openproblems/api/main.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,17 @@ def _main(args=None):
3232
if args.subcommand is None:
3333
argparser.print_help()
3434
elif args.subcommand in SUBCOMMANDS:
35-
return SUBCOMMANDS[args.subcommand].main(args)
35+
# Since printing the output to stdout is important here,
36+
# we redirect all other stdout to stderr.
37+
with utils.RedirectStdout():
38+
return SUBCOMMANDS[args.subcommand].main(args)
3639
else:
3740
raise NotImplementedError
3841

3942

4043
def main(args=None, do_print=True):
41-
"""Run the command-line interface.
42-
43-
Since printing the output to stdout is important here,
44-
we redirect all other stdout to stderr.
45-
"""
46-
with utils.RedirectStdout():
47-
output = _main(args)
44+
"""Run the command-line interface."""
45+
output = _main(args)
4846
if do_print:
4947
utils.print_output(output)
5048
return 0

0 commit comments

Comments
 (0)