Skip to content

Commit

Permalink
Don't pass script path arg to main
Browse files Browse the repository at this point in the history
  • Loading branch information
jashandeep-sohi authored and asvetlov committed Mar 22, 2016
1 parent a39bb38 commit 128e345
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGES
=======

0.21.5 (04-22-2016)
-------------------

- Fix command line arg parsing #797

0.21.4 (03-12-2016)
-------------------

Expand Down
6 changes: 3 additions & 3 deletions aiohttp/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def main(argv):
type=int,
default="8080"
)
args, extra_args = arg_parser.parse_known_args(argv)
args, extra_argv = arg_parser.parse_known_args(argv)

# Import logic
mod_str, _, func_str = args.entry_func.partition(":")
Expand All @@ -368,9 +368,9 @@ def main(argv):
except AttributeError:
arg_parser.error("module %r has no attribute %r" % (mod_str, func_str))

app = func(extra_args)
app = func(extra_argv)
run_app(app, host=args.hostname, port=args.port)
arg_parser.exit(message="Stopped\n")

if __name__ == "__main__":
main(sys.argv)
main(sys.argv[1:])
2 changes: 1 addition & 1 deletion docs/web.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Command Line Interface (CLI)
accepts a list of any non-parsed command-line arguments and returns an
:class:`Application` instance after setting it up::

def init_function(args):
def init_function(argv):
app = web.Application()
app.router.add_route("GET", "/", index_handler)
return app
Expand Down
6 changes: 3 additions & 3 deletions examples/web_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def display_message(req):
return Response(text=text)


def init(args):
def init(argv):
arg_parser = ArgumentParser(
prog="aiohttp.web ...", description="Application CLI", add_help=False
)
Expand All @@ -45,10 +45,10 @@ def init(args):
help="show this message and exit", action="help"
)

parsed_args = arg_parser.parse_args(args)
args = arg_parser.parse_args(argv)

app = Application()
app["args"] = parsed_args
app["args"] = args
app.router.add_route('GET', '/', display_message)

return app

0 comments on commit 128e345

Please sign in to comment.