prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Make serve recipe is failing
  Seems related to #1087
  ```
  gsurita-30820:kinto gsurita$ make serve 
  .venv/bin/kinto --ini config/kinto.ini init
  Select the backend you would like to use: (1 - postgresql, 2 - redis, default - memory) 
  INFO   Created config /Users/gsurita/kinto/config/kinto.ini
  .venv/bin/kinto --ini config/kinto.ini migrate
  /Users/gsurita/kinto/kinto/core/initialization.py:567: UserWarning: HTTPS is not enabled
    warnings.warn('HTTPS is not enabled')
  INFO   Running kinto 6.0.0.dev0. 
  echo '{"name":"kinto","version":"5.3.1-118-g5fc2dedf","source":"https://github.com/gabisurita/kinto/","commit":"5fc2dedfc0a75d9f337ccdbcc935fa051f377164"}' > version.json
  .venv/bin/kinto --ini config/kinto.ini start --reload
  usage: kinto [-h] [-n NAME] [-s SERVER_TYPE] [--server-name SECTION_NAME]
               [--reload] [--reload-interval RELOAD_INTERVAL] [-b] [-v] [-q]
               [config_uri] [config_vars [config_vars ...]]
  kinto: error: unrecognized arguments: http_port=8888
  make: *** [serve] Error 2
  ```
  
  --- 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 import argparse
  2 import os
  3 import sys
  4 import logging
  5 import logging.config
  6 
  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 DEFAULT_CONFIG_FILE = 'config/kinto.ini'
  14 DEFAULT_PORT = 8888
  15 DEFAULT_LOG_LEVEL = logging.INFO
  16 DEFAULT_LOG_FORMAT = "%(levelname)-5.5s  %(message)s"
  17 
  18 
  19 def main(args=None):
  20     """The main routine."""
  21     if args is None:
  22         args = sys.argv[1:]
  23 
  24     parser = argparse.ArgumentParser(description="Kinto Command-Line "
  25                                                  "Interface")
  26     # XXX: deprecate this option, unnatural as first argument.
  27     parser.add_argument('--ini',
  28                         help='Application configuration file',
  29                         dest='ini_file',
  30                         required=False,
  31                         default=DEFAULT_CONFIG_FILE)
  32 
  33     parser.add_argument('-q', '--quiet', action='store_const',
  34                         const=logging.CRITICAL, dest='verbosity',
  35                         help='Show only critical errors.')
  36 
  37     parser.add_argument('--debug', action='store_const',
  38                         const=logging.DEBUG, dest='verbosity',
  39                         help='Show all messages, including debug messages.')
  40 
  41     commands = ('init', 'start', 'migrate', 'delete-collection', 'version')
  42     subparsers = parser.add_subparsers(title='subcommands',
  43                                        description='Main Kinto CLI commands',
  44                                        dest='subcommand',
  45                                        help="Choose and run with --help")
  46     subparsers.required = True
  47 
  48     for command in commands:
  49         subparser = subparsers.add_parser(command)
  50         subparser.set_defaults(which=command)
  51 
  52         if command == 'init':
  53             subparser.add_argument('--backend',
  54                                    help='{memory,redis,postgresql}',
  55                                    dest='backend',
  56                                    required=False,
  57                                    default=None)
  58             subparser.add_argument('--host',
  59                                    help='Host to listen() on.',
  60                                    dest='host',
  61                                    required=False,
  62                                    default='127.0.0.1')
  63         elif command == 'migrate':
  64             subparser.add_argument('--dry-run',
  65                                    action='store_true',
  66                                    help='Simulate the migration operations '
  67                                         'and show information',
  68                                    dest='dry_run',
  69                                    required=False,
  70                                    default=False)
  71         elif command == 'delete-collection':
  72             subparser.add_argument('--bucket',
  73                                    help='The bucket where the collection '
  74                                         'belongs to.',
  75                                    required=True)
  76             subparser.add_argument('--collection',
  77                                    help='The collection to remove.',
  78                                    required=True)
  79 
  80         elif command == 'start':
  81             subparser.add_argument('--reload',
  82                                    action='store_true',
  83                                    help='Restart when code or config changes',
  84                                    required=False,
  85                                    default=False)
  86             subparser.add_argument('--port',
  87                                    type=int,
  88                                    help='Listening port number',
  89                                    required=False,
  90                                    default=DEFAULT_PORT)
  91 
  92     # Parse command-line arguments
  93     parsed_args = vars(parser.parse_args(args))
  94 
  95     config_file = parsed_args['ini_file']
  96     which_command = parsed_args['which']
  97 
  98     # Initialize logging from
  99     level = parsed_args.get('verbosity') or DEFAULT_LOG_LEVEL
  100     logging.basicConfig(level=level, format=DEFAULT_LOG_FORMAT)
  101 
  102     if which_command == 'init':
  103         if os.path.exists(config_file):
  104             print("{} already exists.".format(config_file), file=sys.stderr)
  105             return 1
  106 
  107         backend = parsed_args['backend']
  108         if not backend:
  109             while True:
  110                 prompt = ("Select the backend you would like to use: "
  111                           "(1 - postgresql, 2 - redis, default - memory) ")
  112                 answer = input(prompt).strip()
  113                 try:
  114                     backends = {"1": "postgresql", "2": "redis", "": "memory"}
  115                     backend = backends[answer]
  116                     break
  117                 except KeyError:
  118                     pass
  119 
  120         init(config_file, backend, parsed_args['host'])
  121 
  122         # Install postgresql libraries if necessary
  123         if backend == "postgresql":
  124             try:
  125                 import psycopg2  # NOQA
  126             except ImportError:
  127                 import pip
  128                 pip.main(['install', "kinto[postgresql]"])
  129         elif backend == "redis":
  130             try:
  131                 import kinto_redis  # NOQA
  132             except ImportError:
  133                 import pip
  134                 pip.main(['install', "kinto[redis]"])
  135 
  136     elif which_command == 'migrate':
  137         dry_run = parsed_args['dry_run']
  138         env = bootstrap(config_file)
  139         scripts.migrate(env, dry_run=dry_run)
  140 
  141     elif which_command == 'delete-collection':
  142         env = bootstrap(config_file)
  143         return scripts.delete_collection(env,
  144                                          parsed_args['bucket'],
  145                                          parsed_args['collection'])
  146 
  147     elif which_command == 'start':
  148         pserve_argv = ['pserve', config_file]
  149         if parsed_args['reload']:
  150             pserve_argv.append('--reload')
  151         pserve_argv.append('http_port={}'.format(parsed_args['port']))
  152         pserve.main(pserve_argv)
  153 
  154     else:
  155         print(__version__)
  156 
  157     return 0
  158
  ```
  --- 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
  @@ -23,21 +23,6 @@
   
       parser = argparse.ArgumentParser(description="Kinto Command-Line "
                                                    "Interface")
  -    # XXX: deprecate this option, unnatural as first argument.
  -    parser.add_argument('--ini',
  -                        help='Application configuration file',
  -                        dest='ini_file',
  -                        required=False,
  -                        default=DEFAULT_CONFIG_FILE)
  -
  -    parser.add_argument('-q', '--quiet', action='store_const',
  -                        const=logging.CRITICAL, dest='verbosity',
  -                        help='Show only critical errors.')
  -
  -    parser.add_argument('--debug', action='store_const',
  -                        const=logging.DEBUG, dest='verbosity',
  -                        help='Show all messages, including debug messages.')
  -
       commands = ('init', 'start', 'migrate', 'delete-collection', 'version')
       subparsers = parser.add_subparsers(title='subcommands',
                                          description='Main Kinto CLI commands',
  @@ -49,6 +34,20 @@
           subparser = subparsers.add_parser(command)
           subparser.set_defaults(which=command)
   
  +        subparser.add_argument('--ini',
  +                               help='Application configuration file',
  +                               dest='ini_file',
  +                               required=False,
  +                               default=DEFAULT_CONFIG_FILE)
  +
  +        subparser.add_argument('-q', '--quiet', action='store_const',
  +                               const=logging.CRITICAL, dest='verbosity',
  +                               help='Show only critical errors.')
  +
  +        subparser.add_argument('-v', '--debug', action='store_const',
  +                               const=logging.DEBUG, dest='verbosity',
  +                               help='Show all messages, including debug messages.')
  +
           if command == 'init':
               subparser.add_argument('--backend',
                                      help='{memory,redis,postgresql}',
  @@ -145,11 +144,20 @@
                                            parsed_args['collection'])
   
       elif which_command == 'start':
  -        pserve_argv = ['pserve', config_file]
  +        pserve_argv = ['pserve']
  +
           if parsed_args['reload']:
               pserve_argv.append('--reload')
  +
  +        if level == logging.DEBUG:
  +            pserve_argv.append('-v')
  +
  +        if level == logging.CRITICAL:
  +            pserve_argv.append('-q')
  +
  +        pserve_argv.append(config_file)
           pserve_argv.append('http_port={}'.format(parsed_args['port']))
  -        pserve.main(pserve_argv)
  +        pserve.main(argv=pserve_argv)
   
       else:
           print(__version__)
  
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@@ -23,21 +23,6 @@\n \n     parser = argparse.ArgumentParser(description=\"Kinto Command-Line \"\n                                                  \"Interface\")\n-    # XXX: deprecate this option, unnatural as first argument.\n-    parser.add_argument('--ini',\n-                        help='Application configuration file',\n-                        dest='ini_file',\n-                        required=False,\n-                        default=DEFAULT_CONFIG_FILE)\n-\n-    parser.add_argument('-q', '--quiet', action='store_const',\n-                        const=logging.CRITICAL, dest='verbosity',\n-                        help='Show only critical errors.')\n-\n-    parser.add_argument('--debug', action='store_const',\n-                        const=logging.DEBUG, dest='verbosity',\n-                        help='Show all messages, including debug messages.')\n-\n     commands = ('init', 'start', 'migrate', 'delete-collection', 'version')\n     subparsers = parser.add_subparsers(title='subcommands',\n                                        description='Main Kinto CLI commands',\n@@ -49,6 +34,20 @@\n         subparser = subparsers.add_parser(command)\n         subparser.set_defaults(which=command)\n \n+        subparser.add_argument('--ini',\n+                               help='Application configuration file',\n+                               dest='ini_file',\n+                               required=False,\n+                               default=DEFAULT_CONFIG_FILE)\n+\n+        subparser.add_argument('-q', '--quiet', action='store_const',\n+                               const=logging.CRITICAL, dest='verbosity',\n+                               help='Show only critical errors.')\n+\n+        subparser.add_argument('-v', '--debug', action='store_const',\n+                               const=logging.DEBUG, dest='verbosity',\n+                               help='Show all messages, including debug messages.')\n+\n         if command == 'init':\n             subparser.add_argument('--backend',\n                                    help='{memory,redis,postgresql}',\n@@ -145,11 +144,20 @@\n                                          parsed_args['collection'])\n \n     elif which_command == 'start':\n-        pserve_argv = ['pserve', config_file]\n+        pserve_argv = ['pserve']\n+\n         if parsed_args['reload']:\n             pserve_argv.append('--reload')\n+\n+        if level == logging.DEBUG:\n+            pserve_argv.append('-v')\n+\n+        if level == logging.CRITICAL:\n+            pserve_argv.append('-q')\n+\n+        pserve_argv.append(config_file)\n         pserve_argv.append('http_port={}'.format(parsed_args['port']))\n-        pserve.main(pserve_argv)\n+        pserve.main(argv=pserve_argv)\n \n     else:\n         print(__version__)\n", "issue": "Make serve recipe is failing\nSeems related to #1087\r\n```\r\ngsurita-30820:kinto gsurita$ make serve \r\n.venv/bin/kinto --ini config/kinto.ini init\r\nSelect the backend you would like to use: (1 - postgresql, 2 - redis, default - memory) \r\nINFO   Created config /Users/gsurita/kinto/config/kinto.ini\r\n.venv/bin/kinto --ini config/kinto.ini migrate\r\n/Users/gsurita/kinto/kinto/core/initialization.py:567: UserWarning: HTTPS is not enabled\r\n  warnings.warn('HTTPS is not enabled')\r\nINFO   Running kinto 6.0.0.dev0. \r\necho '{\"name\":\"kinto\",\"version\":\"5.3.1-118-g5fc2dedf\",\"source\":\"https://github.com/gabisurita/kinto/\",\"commit\":\"5fc2dedfc0a75d9f337ccdbcc935fa051f377164\"}' > version.json\r\n.venv/bin/kinto --ini config/kinto.ini start --reload\r\nusage: kinto [-h] [-n NAME] [-s SERVER_TYPE] [--server-name SECTION_NAME]\r\n             [--reload] [--reload-interval RELOAD_INTERVAL] [-b] [-v] [-q]\r\n             [config_uri] [config_vars [config_vars ...]]\r\nkinto: error: unrecognized arguments: http_port=8888\r\nmake: *** [serve] Error 2\r\n```\n", "before_files": [{"content": "import argparse\nimport os\nimport sys\nimport logging\nimport logging.config\n\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\nDEFAULT_CONFIG_FILE = 'config/kinto.ini'\nDEFAULT_PORT = 8888\nDEFAULT_LOG_LEVEL = logging.INFO\nDEFAULT_LOG_FORMAT = \"%(levelname)-5.5s  %(message)s\"\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 Command-Line \"\n                                                 \"Interface\")\n    # XXX: deprecate this option, unnatural as first argument.\n    parser.add_argument('--ini',\n                        help='Application configuration file',\n                        dest='ini_file',\n                        required=False,\n                        default=DEFAULT_CONFIG_FILE)\n\n    parser.add_argument('-q', '--quiet', action='store_const',\n                        const=logging.CRITICAL, dest='verbosity',\n                        help='Show only critical errors.')\n\n    parser.add_argument('--debug', action='store_const',\n                        const=logging.DEBUG, dest='verbosity',\n                        help='Show all messages, including debug messages.')\n\n    commands = ('init', 'start', 'migrate', 'delete-collection', 'version')\n    subparsers = parser.add_subparsers(title='subcommands',\n                                       description='Main Kinto CLI commands',\n                                       dest='subcommand',\n                                       help=\"Choose and run with --help\")\n    subparsers.required = True\n\n    for command in commands:\n        subparser = subparsers.add_parser(command)\n        subparser.set_defaults(which=command)\n\n        if command == 'init':\n            subparser.add_argument('--backend',\n                                   help='{memory,redis,postgresql}',\n                                   dest='backend',\n                                   required=False,\n                                   default=None)\n            subparser.add_argument('--host',\n                                   help='Host to listen() on.',\n                                   dest='host',\n                                   required=False,\n                                   default='127.0.0.1')\n        elif command == 'migrate':\n            subparser.add_argument('--dry-run',\n                                   action='store_true',\n                                   help='Simulate the migration operations '\n                                        'and show information',\n                                   dest='dry_run',\n                                   required=False,\n                                   default=False)\n        elif command == 'delete-collection':\n            subparser.add_argument('--bucket',\n                                   help='The bucket where the collection '\n                                        'belongs to.',\n                                   required=True)\n            subparser.add_argument('--collection',\n                                   help='The collection to remove.',\n                                   required=True)\n\n        elif command == 'start':\n            subparser.add_argument('--reload',\n                                   action='store_true',\n                                   help='Restart when code or config changes',\n                                   required=False,\n                                   default=False)\n            subparser.add_argument('--port',\n                                   type=int,\n                                   help='Listening port number',\n                                   required=False,\n                                   default=DEFAULT_PORT)\n\n    # Parse command-line arguments\n    parsed_args = vars(parser.parse_args(args))\n\n    config_file = parsed_args['ini_file']\n    which_command = parsed_args['which']\n\n    # Initialize logging from\n    level = parsed_args.get('verbosity') or DEFAULT_LOG_LEVEL\n    logging.basicConfig(level=level, format=DEFAULT_LOG_FORMAT)\n\n    if which_command == 'init':\n        if os.path.exists(config_file):\n            print(\"{} already exists.\".format(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, parsed_args['host'])\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        elif backend == \"redis\":\n            try:\n                import kinto_redis  # NOQA\n            except ImportError:\n                import pip\n                pip.main(['install', \"kinto[redis]\"])\n\n    elif which_command == 'migrate':\n        dry_run = parsed_args['dry_run']\n        env = bootstrap(config_file)\n        scripts.migrate(env, dry_run=dry_run)\n\n    elif which_command == 'delete-collection':\n        env = bootstrap(config_file)\n        return scripts.delete_collection(env,\n                                         parsed_args['bucket'],\n                                         parsed_args['collection'])\n\n    elif which_command == 'start':\n        pserve_argv = ['pserve', config_file]\n        if parsed_args['reload']:\n            pserve_argv.append('--reload')\n        pserve_argv.append('http_port={}'.format(parsed_args['port']))\n        pserve.main(pserve_argv)\n\n    else:\n        print(__version__)\n\n    return 0\n", "path": "kinto/__main__.py"}], "after_files": [{"content": "import argparse\nimport os\nimport sys\nimport logging\nimport logging.config\n\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\nDEFAULT_CONFIG_FILE = 'config/kinto.ini'\nDEFAULT_PORT = 8888\nDEFAULT_LOG_LEVEL = logging.INFO\nDEFAULT_LOG_FORMAT = \"%(levelname)-5.5s  %(message)s\"\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 Command-Line \"\n                                                 \"Interface\")\n    commands = ('init', 'start', 'migrate', 'delete-collection', 'version')\n    subparsers = parser.add_subparsers(title='subcommands',\n                                       description='Main Kinto CLI commands',\n                                       dest='subcommand',\n                                       help=\"Choose and run with --help\")\n    subparsers.required = True\n\n    for command in commands:\n        subparser = subparsers.add_parser(command)\n        subparser.set_defaults(which=command)\n\n        subparser.add_argument('--ini',\n                               help='Application configuration file',\n                               dest='ini_file',\n                               required=False,\n                               default=DEFAULT_CONFIG_FILE)\n\n        subparser.add_argument('-q', '--quiet', action='store_const',\n                               const=logging.CRITICAL, dest='verbosity',\n                               help='Show only critical errors.')\n\n        subparser.add_argument('-v', '--debug', action='store_const',\n                               const=logging.DEBUG, dest='verbosity',\n                               help='Show all messages, including debug messages.')\n\n        if command == 'init':\n            subparser.add_argument('--backend',\n                                   help='{memory,redis,postgresql}',\n                                   dest='backend',\n                                   required=False,\n                                   default=None)\n            subparser.add_argument('--host',\n                                   help='Host to listen() on.',\n                                   dest='host',\n                                   required=False,\n                                   default='127.0.0.1')\n        elif command == 'migrate':\n            subparser.add_argument('--dry-run',\n                                   action='store_true',\n                                   help='Simulate the migration operations '\n                                        'and show information',\n                                   dest='dry_run',\n                                   required=False,\n                                   default=False)\n        elif command == 'delete-collection':\n            subparser.add_argument('--bucket',\n                                   help='The bucket where the collection '\n                                        'belongs to.',\n                                   required=True)\n            subparser.add_argument('--collection',\n                                   help='The collection to remove.',\n                                   required=True)\n\n        elif command == 'start':\n            subparser.add_argument('--reload',\n                                   action='store_true',\n                                   help='Restart when code or config changes',\n                                   required=False,\n                                   default=False)\n            subparser.add_argument('--port',\n                                   type=int,\n                                   help='Listening port number',\n                                   required=False,\n                                   default=DEFAULT_PORT)\n\n    # Parse command-line arguments\n    parsed_args = vars(parser.parse_args(args))\n\n    config_file = parsed_args['ini_file']\n    which_command = parsed_args['which']\n\n    # Initialize logging from\n    level = parsed_args.get('verbosity') or DEFAULT_LOG_LEVEL\n    logging.basicConfig(level=level, format=DEFAULT_LOG_FORMAT)\n\n    if which_command == 'init':\n        if os.path.exists(config_file):\n            print(\"{} already exists.\".format(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, parsed_args['host'])\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        elif backend == \"redis\":\n            try:\n                import kinto_redis  # NOQA\n            except ImportError:\n                import pip\n                pip.main(['install', \"kinto[redis]\"])\n\n    elif which_command == 'migrate':\n        dry_run = parsed_args['dry_run']\n        env = bootstrap(config_file)\n        scripts.migrate(env, dry_run=dry_run)\n\n    elif which_command == 'delete-collection':\n        env = bootstrap(config_file)\n        return scripts.delete_collection(env,\n                                         parsed_args['bucket'],\n                                         parsed_args['collection'])\n\n    elif which_command == 'start':\n        pserve_argv = ['pserve']\n\n        if parsed_args['reload']:\n            pserve_argv.append('--reload')\n\n        if level == logging.DEBUG:\n            pserve_argv.append('-v')\n\n        if level == logging.CRITICAL:\n            pserve_argv.append('-q')\n\n        pserve_argv.append(config_file)\n        pserve_argv.append('http_port={}'.format(parsed_args['port']))\n        pserve.main(argv=pserve_argv)\n\n    else:\n        print(__version__)\n\n    return 0\n", "path": "kinto/__main__.py"}]}