prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  [cliquet] Add a way to change the port used when using kinto start.
  original: https://github.com/mozilla-services/cliquet/issues/686
  
  All in title
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `kinto/__main__.py`
  Content:
  ```
  1 from __future__ import print_function
  2 import argparse
  3 import os
  4 import sys
  5 
  6 from six.moves import input
  7 from kinto.core import scripts
  8 from pyramid.scripts import pserve
  9 from pyramid.paster import bootstrap
  10 from kinto import __version__
  11 from kinto.config import init
  12 
  13 CONFIG_FILE = 'config/kinto.ini'
  14 
  15 
  16 def main(args=None):
  17     """The main routine."""
  18     if args is None:
  19         args = sys.argv[1:]
  20 
  21     parser = argparse.ArgumentParser(description="Kinto commands")
  22     parser.add_argument('--ini',
  23                         help='Application configuration file',
  24                         dest='ini_file',
  25                         required=False,
  26                         default=CONFIG_FILE)
  27     parser.add_argument('--backend',
  28                         help='Specify backend',
  29                         dest='backend',
  30                         required=False,
  31                         default=None)
  32 
  33     parser.add_argument('-v', '--version',
  34                         action='version', version=__version__,
  35                         help='Print the Kinto version and exit.')
  36 
  37     subparsers = parser.add_subparsers(title='subcommands',
  38                                        description='valid subcommands',
  39                                        dest='subcommand',
  40                                        help='init/start/migrate')
  41     subparsers.required = True
  42 
  43     parser_init = subparsers.add_parser('init')
  44     parser_init.set_defaults(which='init')
  45 
  46     parser_migrate = subparsers.add_parser('migrate')
  47     parser_migrate.set_defaults(which='migrate')
  48 
  49     parser_start = subparsers.add_parser('start')
  50     parser_start.add_argument('--reload',
  51                               action='store_true',
  52                               help='Restart when code or config changes',
  53                               required=False,
  54                               default=False)
  55     parser_start.set_defaults(which='start')
  56 
  57     parsed_args = vars(parser.parse_args(args))
  58 
  59     config_file = parsed_args['ini_file']
  60 
  61     if parsed_args['which'] == 'init':
  62         if os.path.exists(config_file):
  63             print("%s already exists." % config_file, file=sys.stderr)
  64             return 1
  65 
  66         backend = parsed_args['backend']
  67         if not backend:
  68             while True:
  69                 prompt = ("Select the backend you would like to use: "
  70                           "(1 - postgresql, 2 - redis, default - memory) ")
  71                 answer = input(prompt).strip()
  72                 try:
  73                     backends = {"1": "postgresql", "2": "redis", "": "memory"}
  74                     backend = backends[answer]
  75                     break
  76                 except KeyError:
  77                     pass
  78 
  79         init(config_file, backend)
  80 
  81         # Install postgresql libraries if necessary
  82         if backend == "postgresql":
  83             try:
  84                 import psycopg2  # NOQA
  85             except ImportError:
  86                 import pip
  87                 pip.main(['install', "kinto[postgresql]"])
  88 
  89     elif parsed_args['which'] == 'migrate':
  90         env = bootstrap(config_file)
  91         scripts.migrate(env)
  92 
  93     elif parsed_args['which'] == 'start':
  94         pserve_argv = ['pserve', config_file]
  95         if parsed_args['reload']:
  96             pserve_argv.append('--reload')
  97         pserve.main(pserve_argv)
  98 
  99     return 0
  100
  ```
  --- 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()
  
  ```
  
golden_diff: diff --git a/kinto/__main__.py b/kinto/__main__.py
  --- a/kinto/__main__.py
  +++ b/kinto/__main__.py
  @@ -52,6 +52,11 @@
                                 help='Restart when code or config changes',
                                 required=False,
                                 default=False)
  +    parser_start.add_argument('--port',
  +                              type=int,
  +                              help='Listening port number',
  +                              required=False,
  +                              default=8888)
       parser_start.set_defaults(which='start')
   
       parsed_args = vars(parser.parse_args(args))
  @@ -94,6 +99,7 @@
           pserve_argv = ['pserve', config_file]
           if parsed_args['reload']:
               pserve_argv.append('--reload')
  +        pserve_argv.append('http_port=%s' % parsed_args['port'])
           pserve.main(pserve_argv)
   
       return 0
  
verification_info: {"golden_diff": "diff --git a/kinto/__main__.py b/kinto/__main__.py\n--- a/kinto/__main__.py\n+++ b/kinto/__main__.py\n@@ -52,6 +52,11 @@\n                               help='Restart when code or config changes',\n                               required=False,\n                               default=False)\n+    parser_start.add_argument('--port',\n+                              type=int,\n+                              help='Listening port number',\n+                              required=False,\n+                              default=8888)\n     parser_start.set_defaults(which='start')\n \n     parsed_args = vars(parser.parse_args(args))\n@@ -94,6 +99,7 @@\n         pserve_argv = ['pserve', config_file]\n         if parsed_args['reload']:\n             pserve_argv.append('--reload')\n+        pserve_argv.append('http_port=%s' % parsed_args['port'])\n         pserve.main(pserve_argv)\n \n     return 0\n", "issue": "[cliquet] Add a way to change the port used when using kinto start.\noriginal: https://github.com/mozilla-services/cliquet/issues/686\n\nAll in title\n\n", "before_files": [{"content": "from __future__ import print_function\nimport argparse\nimport os\nimport sys\n\nfrom six.moves import input\nfrom kinto.core import scripts\nfrom pyramid.scripts import pserve\nfrom pyramid.paster import bootstrap\nfrom kinto import __version__\nfrom kinto.config import init\n\nCONFIG_FILE = 'config/kinto.ini'\n\n\ndef main(args=None):\n    \"\"\"The main routine.\"\"\"\n    if args is None:\n        args = sys.argv[1:]\n\n    parser = argparse.ArgumentParser(description=\"Kinto commands\")\n    parser.add_argument('--ini',\n                        help='Application configuration file',\n                        dest='ini_file',\n                        required=False,\n                        default=CONFIG_FILE)\n    parser.add_argument('--backend',\n                        help='Specify backend',\n                        dest='backend',\n                        required=False,\n                        default=None)\n\n    parser.add_argument('-v', '--version',\n                        action='version', version=__version__,\n                        help='Print the Kinto version and exit.')\n\n    subparsers = parser.add_subparsers(title='subcommands',\n                                       description='valid subcommands',\n                                       dest='subcommand',\n                                       help='init/start/migrate')\n    subparsers.required = True\n\n    parser_init = subparsers.add_parser('init')\n    parser_init.set_defaults(which='init')\n\n    parser_migrate = subparsers.add_parser('migrate')\n    parser_migrate.set_defaults(which='migrate')\n\n    parser_start = subparsers.add_parser('start')\n    parser_start.add_argument('--reload',\n                              action='store_true',\n                              help='Restart when code or config changes',\n                              required=False,\n                              default=False)\n    parser_start.set_defaults(which='start')\n\n    parsed_args = vars(parser.parse_args(args))\n\n    config_file = parsed_args['ini_file']\n\n    if parsed_args['which'] == 'init':\n        if os.path.exists(config_file):\n            print(\"%s already exists.\" % config_file, file=sys.stderr)\n            return 1\n\n        backend = parsed_args['backend']\n        if not backend:\n            while True:\n                prompt = (\"Select the backend you would like to use: \"\n                          \"(1 - postgresql, 2 - redis, default - memory) \")\n                answer = input(prompt).strip()\n                try:\n                    backends = {\"1\": \"postgresql\", \"2\": \"redis\", \"\": \"memory\"}\n                    backend = backends[answer]\n                    break\n                except KeyError:\n                    pass\n\n        init(config_file, backend)\n\n        # Install postgresql libraries if necessary\n        if backend == \"postgresql\":\n            try:\n                import psycopg2  # NOQA\n            except ImportError:\n                import pip\n                pip.main(['install', \"kinto[postgresql]\"])\n\n    elif parsed_args['which'] == 'migrate':\n        env = bootstrap(config_file)\n        scripts.migrate(env)\n\n    elif parsed_args['which'] == 'start':\n        pserve_argv = ['pserve', config_file]\n        if parsed_args['reload']:\n            pserve_argv.append('--reload')\n        pserve.main(pserve_argv)\n\n    return 0\n", "path": "kinto/__main__.py"}], "after_files": [{"content": "from __future__ import print_function\nimport argparse\nimport os\nimport sys\n\nfrom six.moves import input\nfrom kinto.core import scripts\nfrom pyramid.scripts import pserve\nfrom pyramid.paster import bootstrap\nfrom kinto import __version__\nfrom kinto.config import init\n\nCONFIG_FILE = 'config/kinto.ini'\n\n\ndef main(args=None):\n    \"\"\"The main routine.\"\"\"\n    if args is None:\n        args = sys.argv[1:]\n\n    parser = argparse.ArgumentParser(description=\"Kinto commands\")\n    parser.add_argument('--ini',\n                        help='Application configuration file',\n                        dest='ini_file',\n                        required=False,\n                        default=CONFIG_FILE)\n    parser.add_argument('--backend',\n                        help='Specify backend',\n                        dest='backend',\n                        required=False,\n                        default=None)\n\n    parser.add_argument('-v', '--version',\n                        action='version', version=__version__,\n                        help='Print the Kinto version and exit.')\n\n    subparsers = parser.add_subparsers(title='subcommands',\n                                       description='valid subcommands',\n                                       dest='subcommand',\n                                       help='init/start/migrate')\n    subparsers.required = True\n\n    parser_init = subparsers.add_parser('init')\n    parser_init.set_defaults(which='init')\n\n    parser_migrate = subparsers.add_parser('migrate')\n    parser_migrate.set_defaults(which='migrate')\n\n    parser_start = subparsers.add_parser('start')\n    parser_start.add_argument('--reload',\n                              action='store_true',\n                              help='Restart when code or config changes',\n                              required=False,\n                              default=False)\n    parser_start.add_argument('--port',\n                              type=int,\n                              help='Listening port number',\n                              required=False,\n                              default=8888)\n    parser_start.set_defaults(which='start')\n\n    parsed_args = vars(parser.parse_args(args))\n\n    config_file = parsed_args['ini_file']\n\n    if parsed_args['which'] == 'init':\n        if os.path.exists(config_file):\n            print(\"%s already exists.\" % config_file, file=sys.stderr)\n            return 1\n\n        backend = parsed_args['backend']\n        if not backend:\n            while True:\n                prompt = (\"Select the backend you would like to use: \"\n                          \"(1 - postgresql, 2 - redis, default - memory) \")\n                answer = input(prompt).strip()\n                try:\n                    backends = {\"1\": \"postgresql\", \"2\": \"redis\", \"\": \"memory\"}\n                    backend = backends[answer]\n                    break\n                except KeyError:\n                    pass\n\n        init(config_file, backend)\n\n        # Install postgresql libraries if necessary\n        if backend == \"postgresql\":\n            try:\n                import psycopg2  # NOQA\n            except ImportError:\n                import pip\n                pip.main(['install', \"kinto[postgresql]\"])\n\n    elif parsed_args['which'] == 'migrate':\n        env = bootstrap(config_file)\n        scripts.migrate(env)\n\n    elif parsed_args['which'] == 'start':\n        pserve_argv = ['pserve', config_file]\n        if parsed_args['reload']:\n            pserve_argv.append('--reload')\n        pserve_argv.append('http_port=%s' % parsed_args['port'])\n        pserve.main(pserve_argv)\n\n    return 0\n", "path": "kinto/__main__.py"}]}