We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
management script utilities is broken in 0.10
In 46ff5e9, the `run_simple` function in `werkzeug/serving.py` adds a new parameter `reloader_type`, which breaks management script utilities. 

```
Traceback (most recent call last):
  File "manage.py", line 27, in <module>
    manager.run()
  File "/Users/leemars/.virtualenvs/meiping/lib/python2.7/site-packages/flaskext/actions/__init__.py", line 58, in run
    script.run(self._actions, '')
  File "/Users/leemars/.virtualenvs/meiping/lib/python2.7/site-packages/werkzeug/script.py", line 177, in run
    return func(**arguments)
  File "/Users/leemars/.virtualenvs/meiping/lib/python2.7/site-packages/werkzeug/script.py", line 314, in action
    static_files=static_files, ssl_context=ssl_context)
  File "/Users/leemars/.virtualenvs/meiping/lib/python2.7/site-packages/werkzeug/serving.py", line 622, in run_simple
    reloader_type)
  File "/Users/leemars/.virtualenvs/meiping/lib/python2.7/site-packages/werkzeug/_reloader.py", line 262, in run_with_reloader
    reloader = reloader_loops[reloader_type](extra_files, interval)
KeyError: True
```

I found that in `werkzeug/script.py`, when calling the `run_simple` function, it didn't use named parameters.

I have made a pull request to fix it.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `werkzeug/script.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 r'''
3     werkzeug.script
4     ~~~~~~~~~~~~~~~
5 
6     .. admonition:: Deprecated Functionality
7 
8        ``werkzeug.script`` is deprecated without replacement functionality.
9        Python's command line support improved greatly with :mod:`argparse`
10        and a bunch of alternative modules.
11 
12     Most of the time you have recurring tasks while writing an application
13     such as starting up an interactive python interpreter with some prefilled
14     imports, starting the development server, initializing the database or
15     something similar.
16 
17     For that purpose werkzeug provides the `werkzeug.script` module which
18     helps you writing such scripts.
19 
20 
21     Basic Usage
22     -----------
23 
24     The following snippet is roughly the same in every werkzeug script::
25 
26         #!/usr/bin/env python
27         # -*- coding: utf-8 -*-
28         from werkzeug import script
29 
30         # actions go here
31 
32         if __name__ == '__main__':
33             script.run()
34 
35     Starting this script now does nothing because no actions are defined.
36     An action is a function in the same module starting with ``"action_"``
37     which takes a number of arguments where every argument has a default.  The
38     type of the default value specifies the type of the argument.
39 
40     Arguments can then be passed by position or using ``--name=value`` from
41     the shell.
42 
43     Because a runserver and shell command is pretty common there are two
44     factory functions that create such commands::
45 
46         def make_app():
47             from yourapplication import YourApplication
48             return YourApplication(...)
49 
50         action_runserver = script.make_runserver(make_app, use_reloader=True)
51         action_shell = script.make_shell(lambda: {'app': make_app()})
52 
53 
54     Using The Scripts
55     -----------------
56 
57     The script from above can be used like this from the shell now:
58 
59     .. sourcecode:: text
60 
61         $ ./manage.py --help
62         $ ./manage.py runserver localhost 8080 --debugger --no-reloader
63         $ ./manage.py runserver -p 4000
64         $ ./manage.py shell
65 
66     As you can see it's possible to pass parameters as positional arguments
67     or as named parameters, pretty much like Python function calls.
68 
69 
70     :copyright: (c) 2014 by the Werkzeug Team, see AUTHORS for more details.
71     :license: BSD, see LICENSE for more details.
72 '''
73 from __future__ import print_function
74 
75 import sys
76 import inspect
77 import getopt
78 from os.path import basename
79 from werkzeug._compat import iteritems
80 
81 
82 argument_types = {
83     bool:       'boolean',
84     str:        'string',
85     int:        'integer',
86     float:      'float'
87 }
88 
89 
90 converters = {
91     'boolean':  lambda x: x.lower() in ('1', 'true', 'yes', 'on'),
92     'string':   str,
93     'integer':  int,
94     'float':    float
95 }
96 
97 
98 def run(namespace=None, action_prefix='action_', args=None):
99     """Run the script.  Participating actions are looked up in the caller's
100     namespace if no namespace is given, otherwise in the dict provided.
101     Only items that start with action_prefix are processed as actions.  If
102     you want to use all items in the namespace provided as actions set
103     action_prefix to an empty string.
104 
105     :param namespace: An optional dict where the functions are looked up in.
106                       By default the local namespace of the caller is used.
107     :param action_prefix: The prefix for the functions.  Everything else
108                           is ignored.
109     :param args: the arguments for the function.  If not specified
110                  :data:`sys.argv` without the first argument is used.
111     """
112     if namespace is None:
113         namespace = sys._getframe(1).f_locals
114     actions = find_actions(namespace, action_prefix)
115 
116     if args is None:
117         args = sys.argv[1:]
118     if not args or args[0] in ('-h', '--help'):
119         return print_usage(actions)
120     elif args[0] not in actions:
121         fail('Unknown action \'%s\'' % args[0])
122 
123     arguments = {}
124     types = {}
125     key_to_arg = {}
126     long_options = []
127     formatstring = ''
128     func, doc, arg_def = actions[args.pop(0)]
129     for idx, (arg, shortcut, default, option_type) in enumerate(arg_def):
130         real_arg = arg.replace('-', '_')
131         if shortcut:
132             formatstring += shortcut
133             if not isinstance(default, bool):
134                 formatstring += ':'
135             key_to_arg['-' + shortcut] = real_arg
136         long_options.append(isinstance(default, bool) and arg or arg + '=')
137         key_to_arg['--' + arg] = real_arg
138         key_to_arg[idx] = real_arg
139         types[real_arg] = option_type
140         arguments[real_arg] = default
141 
142     try:
143         optlist, posargs = getopt.gnu_getopt(args, formatstring, long_options)
144     except getopt.GetoptError as e:
145         fail(str(e))
146 
147     specified_arguments = set()
148     for key, value in enumerate(posargs):
149         try:
150             arg = key_to_arg[key]
151         except IndexError:
152             fail('Too many parameters')
153         specified_arguments.add(arg)
154         try:
155             arguments[arg] = converters[types[arg]](value)
156         except ValueError:
157             fail('Invalid value for argument %s (%s): %s' % (key, arg, value))
158 
159     for key, value in optlist:
160         arg = key_to_arg[key]
161         if arg in specified_arguments:
162             fail('Argument \'%s\' is specified twice' % arg)
163         if types[arg] == 'boolean':
164             if arg.startswith('no_'):
165                 value = 'no'
166             else:
167                 value = 'yes'
168         try:
169             arguments[arg] = converters[types[arg]](value)
170         except ValueError:
171             fail('Invalid value for \'%s\': %s' % (key, value))
172 
173     newargs = {}
174     for k, v in iteritems(arguments):
175         newargs[k.startswith('no_') and k[3:] or k] = v
176     arguments = newargs
177     return func(**arguments)
178 
179 
180 def fail(message, code=-1):
181     """Fail with an error."""
182     print('Error: %s' % message, file=sys.stderr)
183     sys.exit(code)
184 
185 
186 def find_actions(namespace, action_prefix):
187     """Find all the actions in the namespace."""
188     actions = {}
189     for key, value in iteritems(namespace):
190         if key.startswith(action_prefix):
191             actions[key[len(action_prefix):]] = analyse_action(value)
192     return actions
193 
194 
195 def print_usage(actions):
196     """Print the usage information.  (Help screen)"""
197     actions = sorted(iteritems(actions))
198     print('usage: %s <action> [<options>]' % basename(sys.argv[0]))
199     print('       %s --help' % basename(sys.argv[0]))
200     print()
201     print('actions:')
202     for name, (func, doc, arguments) in actions:
203         print('  %s:' % name)
204         for line in doc.splitlines():
205             print('    %s' % line)
206         if arguments:
207             print()
208         for arg, shortcut, default, argtype in arguments:
209             if isinstance(default, bool):
210                 print('    %s' % (
211                     (shortcut and '-%s, ' % shortcut or '') + '--' + arg
212                 ))
213             else:
214                 print('    %-30s%-10s%s' % (
215                     (shortcut and '-%s, ' % shortcut or '') + '--' + arg,
216                     argtype, default
217                 ))
218         print()
219 
220 
221 def analyse_action(func):
222     """Analyse a function."""
223     description = inspect.getdoc(func) or 'undocumented action'
224     arguments = []
225     args, varargs, kwargs, defaults = inspect.getargspec(func)
226     if varargs or kwargs:
227         raise TypeError('variable length arguments for action not allowed.')
228     if len(args) != len(defaults or ()):
229         raise TypeError('not all arguments have proper definitions')
230 
231     for idx, (arg, definition) in enumerate(zip(args, defaults or ())):
232         if arg.startswith('_'):
233             raise TypeError('arguments may not start with an underscore')
234         if not isinstance(definition, tuple):
235             shortcut = None
236             default = definition
237         else:
238             shortcut, default = definition
239         argument_type = argument_types[type(default)]
240         if isinstance(default, bool) and default is True:
241             arg = 'no-' + arg
242         arguments.append((arg.replace('_', '-'), shortcut,
243                           default, argument_type))
244     return func, description, arguments
245 
246 
247 def make_shell(init_func=None, banner=None, use_ipython=True):
248     """Returns an action callback that spawns a new interactive
249     python shell.
250 
251     :param init_func: an optional initialization function that is
252                       called before the shell is started.  The return
253                       value of this function is the initial namespace.
254     :param banner: the banner that is displayed before the shell.  If
255                    not specified a generic banner is used instead.
256     :param use_ipython: if set to `True` ipython is used if available.
257     """
258     if banner is None:
259         banner = 'Interactive Werkzeug Shell'
260     if init_func is None:
261         init_func = dict
262     def action(ipython=use_ipython):
263         """Start a new interactive python session."""
264         namespace = init_func()
265         if ipython:
266             try:
267                 try:
268                     from IPython.frontend.terminal.embed import InteractiveShellEmbed
269                     sh = InteractiveShellEmbed(banner1=banner)
270                 except ImportError:
271                     from IPython.Shell import IPShellEmbed
272                     sh = IPShellEmbed(banner=banner)
273             except ImportError:
274                 pass
275             else:
276                 sh(global_ns={}, local_ns=namespace)
277                 return
278         from code import interact
279         interact(banner, local=namespace)
280     return action
281 
282 
283 def make_runserver(app_factory, hostname='localhost', port=5000,
284                    use_reloader=False, use_debugger=False, use_evalex=True,
285                    threaded=False, processes=1, static_files=None,
286                    extra_files=None, ssl_context=None):
287     """Returns an action callback that spawns a new development server.
288 
289     .. versionadded:: 0.5
290        `static_files` and `extra_files` was added.
291 
292     ..versionadded:: 0.6.1
293        `ssl_context` was added.
294 
295     :param app_factory: a function that returns a new WSGI application.
296     :param hostname: the default hostname the server should listen on.
297     :param port: the default port of the server.
298     :param use_reloader: the default setting for the reloader.
299     :param use_evalex: the default setting for the evalex flag of the debugger.
300     :param threaded: the default threading setting.
301     :param processes: the default number of processes to start.
302     :param static_files: optional dict of static files.
303     :param extra_files: optional list of extra files to track for reloading.
304     :param ssl_context: optional SSL context for running server in HTTPS mode.
305     """
306     def action(hostname=('h', hostname), port=('p', port),
307                reloader=use_reloader, debugger=use_debugger,
308                evalex=use_evalex, threaded=threaded, processes=processes):
309         """Start a new development server."""
310         from werkzeug.serving import run_simple
311         app = app_factory()
312         run_simple(hostname, port, app, reloader, debugger, evalex,
313                    extra_files, 1, threaded, processes,
314                    static_files=static_files, ssl_context=ssl_context)
315     return action
316
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/werkzeug/script.py b/werkzeug/script.py
--- a/werkzeug/script.py
+++ b/werkzeug/script.py
@@ -309,7 +309,9 @@
         """Start a new development server."""
         from werkzeug.serving import run_simple
         app = app_factory()
-        run_simple(hostname, port, app, reloader, debugger, evalex,
-                   extra_files, 1, threaded, processes,
+        run_simple(hostname, port, app,
+                   use_reloader=reloader, use_debugger=debugger,
+                   use_evalex=evalex, extra_files=extra_files,
+                   reloader_interval=1, threaded=threaded, processes=processes,
                    static_files=static_files, ssl_context=ssl_context)
     return action

{"golden_diff": "diff --git a/werkzeug/script.py b/werkzeug/script.py\n--- a/werkzeug/script.py\n+++ b/werkzeug/script.py\n@@ -309,7 +309,9 @@\n         \"\"\"Start a new development server.\"\"\"\n         from werkzeug.serving import run_simple\n         app = app_factory()\n-        run_simple(hostname, port, app, reloader, debugger, evalex,\n-                   extra_files, 1, threaded, processes,\n+        run_simple(hostname, port, app,\n+                   use_reloader=reloader, use_debugger=debugger,\n+                   use_evalex=evalex, extra_files=extra_files,\n+                   reloader_interval=1, threaded=threaded, processes=processes,\n                    static_files=static_files, ssl_context=ssl_context)\n     return action\n", "issue": "management script utilities is broken in 0.10\nIn 46ff5e9, the `run_simple` function in `werkzeug/serving.py` adds a new parameter `reloader_type`, which breaks management script utilities. \n\n```\nTraceback (most recent call last):\n  File \"manage.py\", line 27, in <module>\n    manager.run()\n  File \"/Users/leemars/.virtualenvs/meiping/lib/python2.7/site-packages/flaskext/actions/__init__.py\", line 58, in run\n    script.run(self._actions, '')\n  File \"/Users/leemars/.virtualenvs/meiping/lib/python2.7/site-packages/werkzeug/script.py\", line 177, in run\n    return func(**arguments)\n  File \"/Users/leemars/.virtualenvs/meiping/lib/python2.7/site-packages/werkzeug/script.py\", line 314, in action\n    static_files=static_files, ssl_context=ssl_context)\n  File \"/Users/leemars/.virtualenvs/meiping/lib/python2.7/site-packages/werkzeug/serving.py\", line 622, in run_simple\n    reloader_type)\n  File \"/Users/leemars/.virtualenvs/meiping/lib/python2.7/site-packages/werkzeug/_reloader.py\", line 262, in run_with_reloader\n    reloader = reloader_loops[reloader_type](extra_files, interval)\nKeyError: True\n```\n\nI found that in `werkzeug/script.py`, when calling the `run_simple` function, it didn't use named parameters.\n\nI have made a pull request to fix it.\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\nr'''\n    werkzeug.script\n    ~~~~~~~~~~~~~~~\n\n    .. admonition:: Deprecated Functionality\n\n       ``werkzeug.script`` is deprecated without replacement functionality.\n       Python's command line support improved greatly with :mod:`argparse`\n       and a bunch of alternative modules.\n\n    Most of the time you have recurring tasks while writing an application\n    such as starting up an interactive python interpreter with some prefilled\n    imports, starting the development server, initializing the database or\n    something similar.\n\n    For that purpose werkzeug provides the `werkzeug.script` module which\n    helps you writing such scripts.\n\n\n    Basic Usage\n    -----------\n\n    The following snippet is roughly the same in every werkzeug script::\n\n        #!/usr/bin/env python\n        # -*- coding: utf-8 -*-\n        from werkzeug import script\n\n        # actions go here\n\n        if __name__ == '__main__':\n            script.run()\n\n    Starting this script now does nothing because no actions are defined.\n    An action is a function in the same module starting with ``\"action_\"``\n    which takes a number of arguments where every argument has a default.  The\n    type of the default value specifies the type of the argument.\n\n    Arguments can then be passed by position or using ``--name=value`` from\n    the shell.\n\n    Because a runserver and shell command is pretty common there are two\n    factory functions that create such commands::\n\n        def make_app():\n            from yourapplication import YourApplication\n            return YourApplication(...)\n\n        action_runserver = script.make_runserver(make_app, use_reloader=True)\n        action_shell = script.make_shell(lambda: {'app': make_app()})\n\n\n    Using The Scripts\n    -----------------\n\n    The script from above can be used like this from the shell now:\n\n    .. sourcecode:: text\n\n        $ ./manage.py --help\n        $ ./manage.py runserver localhost 8080 --debugger --no-reloader\n        $ ./manage.py runserver -p 4000\n        $ ./manage.py shell\n\n    As you can see it's possible to pass parameters as positional arguments\n    or as named parameters, pretty much like Python function calls.\n\n\n    :copyright: (c) 2014 by the Werkzeug Team, see AUTHORS for more details.\n    :license: BSD, see LICENSE for more details.\n'''\nfrom __future__ import print_function\n\nimport sys\nimport inspect\nimport getopt\nfrom os.path import basename\nfrom werkzeug._compat import iteritems\n\n\nargument_types = {\n    bool:       'boolean',\n    str:        'string',\n    int:        'integer',\n    float:      'float'\n}\n\n\nconverters = {\n    'boolean':  lambda x: x.lower() in ('1', 'true', 'yes', 'on'),\n    'string':   str,\n    'integer':  int,\n    'float':    float\n}\n\n\ndef run(namespace=None, action_prefix='action_', args=None):\n    \"\"\"Run the script.  Participating actions are looked up in the caller's\n    namespace if no namespace is given, otherwise in the dict provided.\n    Only items that start with action_prefix are processed as actions.  If\n    you want to use all items in the namespace provided as actions set\n    action_prefix to an empty string.\n\n    :param namespace: An optional dict where the functions are looked up in.\n                      By default the local namespace of the caller is used.\n    :param action_prefix: The prefix for the functions.  Everything else\n                          is ignored.\n    :param args: the arguments for the function.  If not specified\n                 :data:`sys.argv` without the first argument is used.\n    \"\"\"\n    if namespace is None:\n        namespace = sys._getframe(1).f_locals\n    actions = find_actions(namespace, action_prefix)\n\n    if args is None:\n        args = sys.argv[1:]\n    if not args or args[0] in ('-h', '--help'):\n        return print_usage(actions)\n    elif args[0] not in actions:\n        fail('Unknown action \\'%s\\'' % args[0])\n\n    arguments = {}\n    types = {}\n    key_to_arg = {}\n    long_options = []\n    formatstring = ''\n    func, doc, arg_def = actions[args.pop(0)]\n    for idx, (arg, shortcut, default, option_type) in enumerate(arg_def):\n        real_arg = arg.replace('-', '_')\n        if shortcut:\n            formatstring += shortcut\n            if not isinstance(default, bool):\n                formatstring += ':'\n            key_to_arg['-' + shortcut] = real_arg\n        long_options.append(isinstance(default, bool) and arg or arg + '=')\n        key_to_arg['--' + arg] = real_arg\n        key_to_arg[idx] = real_arg\n        types[real_arg] = option_type\n        arguments[real_arg] = default\n\n    try:\n        optlist, posargs = getopt.gnu_getopt(args, formatstring, long_options)\n    except getopt.GetoptError as e:\n        fail(str(e))\n\n    specified_arguments = set()\n    for key, value in enumerate(posargs):\n        try:\n            arg = key_to_arg[key]\n        except IndexError:\n            fail('Too many parameters')\n        specified_arguments.add(arg)\n        try:\n            arguments[arg] = converters[types[arg]](value)\n        except ValueError:\n            fail('Invalid value for argument %s (%s): %s' % (key, arg, value))\n\n    for key, value in optlist:\n        arg = key_to_arg[key]\n        if arg in specified_arguments:\n            fail('Argument \\'%s\\' is specified twice' % arg)\n        if types[arg] == 'boolean':\n            if arg.startswith('no_'):\n                value = 'no'\n            else:\n                value = 'yes'\n        try:\n            arguments[arg] = converters[types[arg]](value)\n        except ValueError:\n            fail('Invalid value for \\'%s\\': %s' % (key, value))\n\n    newargs = {}\n    for k, v in iteritems(arguments):\n        newargs[k.startswith('no_') and k[3:] or k] = v\n    arguments = newargs\n    return func(**arguments)\n\n\ndef fail(message, code=-1):\n    \"\"\"Fail with an error.\"\"\"\n    print('Error: %s' % message, file=sys.stderr)\n    sys.exit(code)\n\n\ndef find_actions(namespace, action_prefix):\n    \"\"\"Find all the actions in the namespace.\"\"\"\n    actions = {}\n    for key, value in iteritems(namespace):\n        if key.startswith(action_prefix):\n            actions[key[len(action_prefix):]] = analyse_action(value)\n    return actions\n\n\ndef print_usage(actions):\n    \"\"\"Print the usage information.  (Help screen)\"\"\"\n    actions = sorted(iteritems(actions))\n    print('usage: %s <action> [<options>]' % basename(sys.argv[0]))\n    print('       %s --help' % basename(sys.argv[0]))\n    print()\n    print('actions:')\n    for name, (func, doc, arguments) in actions:\n        print('  %s:' % name)\n        for line in doc.splitlines():\n            print('    %s' % line)\n        if arguments:\n            print()\n        for arg, shortcut, default, argtype in arguments:\n            if isinstance(default, bool):\n                print('    %s' % (\n                    (shortcut and '-%s, ' % shortcut or '') + '--' + arg\n                ))\n            else:\n                print('    %-30s%-10s%s' % (\n                    (shortcut and '-%s, ' % shortcut or '') + '--' + arg,\n                    argtype, default\n                ))\n        print()\n\n\ndef analyse_action(func):\n    \"\"\"Analyse a function.\"\"\"\n    description = inspect.getdoc(func) or 'undocumented action'\n    arguments = []\n    args, varargs, kwargs, defaults = inspect.getargspec(func)\n    if varargs or kwargs:\n        raise TypeError('variable length arguments for action not allowed.')\n    if len(args) != len(defaults or ()):\n        raise TypeError('not all arguments have proper definitions')\n\n    for idx, (arg, definition) in enumerate(zip(args, defaults or ())):\n        if arg.startswith('_'):\n            raise TypeError('arguments may not start with an underscore')\n        if not isinstance(definition, tuple):\n            shortcut = None\n            default = definition\n        else:\n            shortcut, default = definition\n        argument_type = argument_types[type(default)]\n        if isinstance(default, bool) and default is True:\n            arg = 'no-' + arg\n        arguments.append((arg.replace('_', '-'), shortcut,\n                          default, argument_type))\n    return func, description, arguments\n\n\ndef make_shell(init_func=None, banner=None, use_ipython=True):\n    \"\"\"Returns an action callback that spawns a new interactive\n    python shell.\n\n    :param init_func: an optional initialization function that is\n                      called before the shell is started.  The return\n                      value of this function is the initial namespace.\n    :param banner: the banner that is displayed before the shell.  If\n                   not specified a generic banner is used instead.\n    :param use_ipython: if set to `True` ipython is used if available.\n    \"\"\"\n    if banner is None:\n        banner = 'Interactive Werkzeug Shell'\n    if init_func is None:\n        init_func = dict\n    def action(ipython=use_ipython):\n        \"\"\"Start a new interactive python session.\"\"\"\n        namespace = init_func()\n        if ipython:\n            try:\n                try:\n                    from IPython.frontend.terminal.embed import InteractiveShellEmbed\n                    sh = InteractiveShellEmbed(banner1=banner)\n                except ImportError:\n                    from IPython.Shell import IPShellEmbed\n                    sh = IPShellEmbed(banner=banner)\n            except ImportError:\n                pass\n            else:\n                sh(global_ns={}, local_ns=namespace)\n                return\n        from code import interact\n        interact(banner, local=namespace)\n    return action\n\n\ndef make_runserver(app_factory, hostname='localhost', port=5000,\n                   use_reloader=False, use_debugger=False, use_evalex=True,\n                   threaded=False, processes=1, static_files=None,\n                   extra_files=None, ssl_context=None):\n    \"\"\"Returns an action callback that spawns a new development server.\n\n    .. versionadded:: 0.5\n       `static_files` and `extra_files` was added.\n\n    ..versionadded:: 0.6.1\n       `ssl_context` was added.\n\n    :param app_factory: a function that returns a new WSGI application.\n    :param hostname: the default hostname the server should listen on.\n    :param port: the default port of the server.\n    :param use_reloader: the default setting for the reloader.\n    :param use_evalex: the default setting for the evalex flag of the debugger.\n    :param threaded: the default threading setting.\n    :param processes: the default number of processes to start.\n    :param static_files: optional dict of static files.\n    :param extra_files: optional list of extra files to track for reloading.\n    :param ssl_context: optional SSL context for running server in HTTPS mode.\n    \"\"\"\n    def action(hostname=('h', hostname), port=('p', port),\n               reloader=use_reloader, debugger=use_debugger,\n               evalex=use_evalex, threaded=threaded, processes=processes):\n        \"\"\"Start a new development server.\"\"\"\n        from werkzeug.serving import run_simple\n        app = app_factory()\n        run_simple(hostname, port, app, reloader, debugger, evalex,\n                   extra_files, 1, threaded, processes,\n                   static_files=static_files, ssl_context=ssl_context)\n    return action\n", "path": "werkzeug/script.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\nr'''\n    werkzeug.script\n    ~~~~~~~~~~~~~~~\n\n    .. admonition:: Deprecated Functionality\n\n       ``werkzeug.script`` is deprecated without replacement functionality.\n       Python's command line support improved greatly with :mod:`argparse`\n       and a bunch of alternative modules.\n\n    Most of the time you have recurring tasks while writing an application\n    such as starting up an interactive python interpreter with some prefilled\n    imports, starting the development server, initializing the database or\n    something similar.\n\n    For that purpose werkzeug provides the `werkzeug.script` module which\n    helps you writing such scripts.\n\n\n    Basic Usage\n    -----------\n\n    The following snippet is roughly the same in every werkzeug script::\n\n        #!/usr/bin/env python\n        # -*- coding: utf-8 -*-\n        from werkzeug import script\n\n        # actions go here\n\n        if __name__ == '__main__':\n            script.run()\n\n    Starting this script now does nothing because no actions are defined.\n    An action is a function in the same module starting with ``\"action_\"``\n    which takes a number of arguments where every argument has a default.  The\n    type of the default value specifies the type of the argument.\n\n    Arguments can then be passed by position or using ``--name=value`` from\n    the shell.\n\n    Because a runserver and shell command is pretty common there are two\n    factory functions that create such commands::\n\n        def make_app():\n            from yourapplication import YourApplication\n            return YourApplication(...)\n\n        action_runserver = script.make_runserver(make_app, use_reloader=True)\n        action_shell = script.make_shell(lambda: {'app': make_app()})\n\n\n    Using The Scripts\n    -----------------\n\n    The script from above can be used like this from the shell now:\n\n    .. sourcecode:: text\n\n        $ ./manage.py --help\n        $ ./manage.py runserver localhost 8080 --debugger --no-reloader\n        $ ./manage.py runserver -p 4000\n        $ ./manage.py shell\n\n    As you can see it's possible to pass parameters as positional arguments\n    or as named parameters, pretty much like Python function calls.\n\n\n    :copyright: (c) 2014 by the Werkzeug Team, see AUTHORS for more details.\n    :license: BSD, see LICENSE for more details.\n'''\nfrom __future__ import print_function\n\nimport sys\nimport inspect\nimport getopt\nfrom os.path import basename\nfrom werkzeug._compat import iteritems\n\n\nargument_types = {\n    bool:       'boolean',\n    str:        'string',\n    int:        'integer',\n    float:      'float'\n}\n\n\nconverters = {\n    'boolean':  lambda x: x.lower() in ('1', 'true', 'yes', 'on'),\n    'string':   str,\n    'integer':  int,\n    'float':    float\n}\n\n\ndef run(namespace=None, action_prefix='action_', args=None):\n    \"\"\"Run the script.  Participating actions are looked up in the caller's\n    namespace if no namespace is given, otherwise in the dict provided.\n    Only items that start with action_prefix are processed as actions.  If\n    you want to use all items in the namespace provided as actions set\n    action_prefix to an empty string.\n\n    :param namespace: An optional dict where the functions are looked up in.\n                      By default the local namespace of the caller is used.\n    :param action_prefix: The prefix for the functions.  Everything else\n                          is ignored.\n    :param args: the arguments for the function.  If not specified\n                 :data:`sys.argv` without the first argument is used.\n    \"\"\"\n    if namespace is None:\n        namespace = sys._getframe(1).f_locals\n    actions = find_actions(namespace, action_prefix)\n\n    if args is None:\n        args = sys.argv[1:]\n    if not args or args[0] in ('-h', '--help'):\n        return print_usage(actions)\n    elif args[0] not in actions:\n        fail('Unknown action \\'%s\\'' % args[0])\n\n    arguments = {}\n    types = {}\n    key_to_arg = {}\n    long_options = []\n    formatstring = ''\n    func, doc, arg_def = actions[args.pop(0)]\n    for idx, (arg, shortcut, default, option_type) in enumerate(arg_def):\n        real_arg = arg.replace('-', '_')\n        if shortcut:\n            formatstring += shortcut\n            if not isinstance(default, bool):\n                formatstring += ':'\n            key_to_arg['-' + shortcut] = real_arg\n        long_options.append(isinstance(default, bool) and arg or arg + '=')\n        key_to_arg['--' + arg] = real_arg\n        key_to_arg[idx] = real_arg\n        types[real_arg] = option_type\n        arguments[real_arg] = default\n\n    try:\n        optlist, posargs = getopt.gnu_getopt(args, formatstring, long_options)\n    except getopt.GetoptError as e:\n        fail(str(e))\n\n    specified_arguments = set()\n    for key, value in enumerate(posargs):\n        try:\n            arg = key_to_arg[key]\n        except IndexError:\n            fail('Too many parameters')\n        specified_arguments.add(arg)\n        try:\n            arguments[arg] = converters[types[arg]](value)\n        except ValueError:\n            fail('Invalid value for argument %s (%s): %s' % (key, arg, value))\n\n    for key, value in optlist:\n        arg = key_to_arg[key]\n        if arg in specified_arguments:\n            fail('Argument \\'%s\\' is specified twice' % arg)\n        if types[arg] == 'boolean':\n            if arg.startswith('no_'):\n                value = 'no'\n            else:\n                value = 'yes'\n        try:\n            arguments[arg] = converters[types[arg]](value)\n        except ValueError:\n            fail('Invalid value for \\'%s\\': %s' % (key, value))\n\n    newargs = {}\n    for k, v in iteritems(arguments):\n        newargs[k.startswith('no_') and k[3:] or k] = v\n    arguments = newargs\n    return func(**arguments)\n\n\ndef fail(message, code=-1):\n    \"\"\"Fail with an error.\"\"\"\n    print('Error: %s' % message, file=sys.stderr)\n    sys.exit(code)\n\n\ndef find_actions(namespace, action_prefix):\n    \"\"\"Find all the actions in the namespace.\"\"\"\n    actions = {}\n    for key, value in iteritems(namespace):\n        if key.startswith(action_prefix):\n            actions[key[len(action_prefix):]] = analyse_action(value)\n    return actions\n\n\ndef print_usage(actions):\n    \"\"\"Print the usage information.  (Help screen)\"\"\"\n    actions = sorted(iteritems(actions))\n    print('usage: %s <action> [<options>]' % basename(sys.argv[0]))\n    print('       %s --help' % basename(sys.argv[0]))\n    print()\n    print('actions:')\n    for name, (func, doc, arguments) in actions:\n        print('  %s:' % name)\n        for line in doc.splitlines():\n            print('    %s' % line)\n        if arguments:\n            print()\n        for arg, shortcut, default, argtype in arguments:\n            if isinstance(default, bool):\n                print('    %s' % (\n                    (shortcut and '-%s, ' % shortcut or '') + '--' + arg\n                ))\n            else:\n                print('    %-30s%-10s%s' % (\n                    (shortcut and '-%s, ' % shortcut or '') + '--' + arg,\n                    argtype, default\n                ))\n        print()\n\n\ndef analyse_action(func):\n    \"\"\"Analyse a function.\"\"\"\n    description = inspect.getdoc(func) or 'undocumented action'\n    arguments = []\n    args, varargs, kwargs, defaults = inspect.getargspec(func)\n    if varargs or kwargs:\n        raise TypeError('variable length arguments for action not allowed.')\n    if len(args) != len(defaults or ()):\n        raise TypeError('not all arguments have proper definitions')\n\n    for idx, (arg, definition) in enumerate(zip(args, defaults or ())):\n        if arg.startswith('_'):\n            raise TypeError('arguments may not start with an underscore')\n        if not isinstance(definition, tuple):\n            shortcut = None\n            default = definition\n        else:\n            shortcut, default = definition\n        argument_type = argument_types[type(default)]\n        if isinstance(default, bool) and default is True:\n            arg = 'no-' + arg\n        arguments.append((arg.replace('_', '-'), shortcut,\n                          default, argument_type))\n    return func, description, arguments\n\n\ndef make_shell(init_func=None, banner=None, use_ipython=True):\n    \"\"\"Returns an action callback that spawns a new interactive\n    python shell.\n\n    :param init_func: an optional initialization function that is\n                      called before the shell is started.  The return\n                      value of this function is the initial namespace.\n    :param banner: the banner that is displayed before the shell.  If\n                   not specified a generic banner is used instead.\n    :param use_ipython: if set to `True` ipython is used if available.\n    \"\"\"\n    if banner is None:\n        banner = 'Interactive Werkzeug Shell'\n    if init_func is None:\n        init_func = dict\n    def action(ipython=use_ipython):\n        \"\"\"Start a new interactive python session.\"\"\"\n        namespace = init_func()\n        if ipython:\n            try:\n                try:\n                    from IPython.frontend.terminal.embed import InteractiveShellEmbed\n                    sh = InteractiveShellEmbed(banner1=banner)\n                except ImportError:\n                    from IPython.Shell import IPShellEmbed\n                    sh = IPShellEmbed(banner=banner)\n            except ImportError:\n                pass\n            else:\n                sh(global_ns={}, local_ns=namespace)\n                return\n        from code import interact\n        interact(banner, local=namespace)\n    return action\n\n\ndef make_runserver(app_factory, hostname='localhost', port=5000,\n                   use_reloader=False, use_debugger=False, use_evalex=True,\n                   threaded=False, processes=1, static_files=None,\n                   extra_files=None, ssl_context=None):\n    \"\"\"Returns an action callback that spawns a new development server.\n\n    .. versionadded:: 0.5\n       `static_files` and `extra_files` was added.\n\n    ..versionadded:: 0.6.1\n       `ssl_context` was added.\n\n    :param app_factory: a function that returns a new WSGI application.\n    :param hostname: the default hostname the server should listen on.\n    :param port: the default port of the server.\n    :param use_reloader: the default setting for the reloader.\n    :param use_evalex: the default setting for the evalex flag of the debugger.\n    :param threaded: the default threading setting.\n    :param processes: the default number of processes to start.\n    :param static_files: optional dict of static files.\n    :param extra_files: optional list of extra files to track for reloading.\n    :param ssl_context: optional SSL context for running server in HTTPS mode.\n    \"\"\"\n    def action(hostname=('h', hostname), port=('p', port),\n               reloader=use_reloader, debugger=use_debugger,\n               evalex=use_evalex, threaded=threaded, processes=processes):\n        \"\"\"Start a new development server.\"\"\"\n        from werkzeug.serving import run_simple\n        app = app_factory()\n        run_simple(hostname, port, app,\n                   use_reloader=reloader, use_debugger=debugger,\n                   use_evalex=evalex, extra_files=extra_files,\n                   reloader_interval=1, threaded=threaded, processes=processes,\n                   static_files=static_files, ssl_context=ssl_context)\n    return action\n", "path": "werkzeug/script.py"}]}