prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Service "s3" not yet available, retrying...
  Hello there
  
  After installing localstack and trying to start several services on my machine, s3 always failed to start
  The command I am using to start them up is
  
  `SERVICES=sqs,sns,s3,lambda DEBUG=1 localstack start`
  (With `DEBUG=1` in place already for debugging)
  
  First few lines of the output are:
  
  ```
  2018-06-19T10:05:57:WARNING:infra.py: Service "s3" not yet available, retrying...
  2018-06-19T10:06:00:WARNING:infra.py: Service "s3" not yet available, retrying...
  2018-06-19T10:06:05:WARNING:infra.py: Service "s3" not yet available, retrying...
  2018-06-19T10:06:08:WARNING:infra.py: Service "s3" not yet available, retrying...
  2018-06-19T10:06:12:WARNING:infra.py: Service "s3" not yet available, retrying...
  2018-06-19T10:06:15:WARNING:infra.py: Service "s3" not yet available, retrying...
  2018-06-19T10:06:19:WARNING:infra.py: Service "s3" not yet available, retrying...
  2018-06-19T10:06:22:ERROR:localstack.services.s3.s3_starter: S3 health check failed: An error occurred (ExpiredToken) when calling the AssumeRole operation: The security token included in the request is expired Traceback (most recent call last):
    File "/usr/local/lib/python3.6/site-packages/localstack/services/infra.py", line 344, in check_infra
      raise e
    File "/usr/local/lib/python3.6/site-packages/localstack/services/infra.py", line 341, in check_infra
      plugin.check(expect_shutdown=expect_shutdown, print_error=print_error)
    File "/usr/local/lib/python3.6/site-packages/localstack/services/infra.py", line 80, in check
      return self.check_function(expect_shutdown=expect_shutdown, print_error=print_error)
    File "/usr/local/lib/python3.6/site-packages/localstack/services/s3/s3_starter.py", line 23, in check_s3
      assert isinstance(out['Buckets'], list)
  TypeError: 'NoneType' object is not subscriptable
  
  During handling of the above exception, another exception occurred:
  ...
  ```
  
  I have been trying to tackle this problem for a few hours already, without any success, I tried the latest verion of localstack as well as 0.8.6.1 which works on another machine
  
  I am installing it trough pip (`pip install localstack`)
  
  Thanks for any help in advance!
  
  
  
  ┆Issue is synchronized with this [Jira Bug](https://localstack.atlassian.net/browse/LOC-309) by [Unito](https://www.unito.io/learn-more)
  
  
  </issue>
  <code>
  [start of localstack/services/s3/s3_starter.py]
  1 import sys
  2 import logging
  3 import traceback
  4 from moto.s3 import models as s3_models
  5 from moto.server import main as moto_main
  6 from localstack import config
  7 from localstack.constants import DEFAULT_PORT_S3_BACKEND
  8 from localstack.utils.aws import aws_stack
  9 from localstack.utils.common import wait_for_port_open
  10 from localstack.services.infra import (
  11     get_service_protocol, start_proxy_for_service, do_run, setup_logging)
  12 
  13 LOGGER = logging.getLogger(__name__)
  14 
  15 # max file size for S3 objects (in MB)
  16 S3_MAX_FILE_SIZE_MB = 128
  17 
  18 
  19 def check_s3(expect_shutdown=False, print_error=False):
  20     out = None
  21     try:
  22         # wait for port to be opened
  23         wait_for_port_open(DEFAULT_PORT_S3_BACKEND)
  24         # check S3
  25         out = aws_stack.connect_to_service(service_name='s3').list_buckets()
  26     except Exception as e:
  27         if print_error:
  28             LOGGER.error('S3 health check failed: %s %s' % (e, traceback.format_exc()))
  29     if expect_shutdown:
  30         assert out is None
  31     else:
  32         assert isinstance(out['Buckets'], list)
  33 
  34 
  35 def start_s3(port=None, backend_port=None, asynchronous=None, update_listener=None):
  36     port = port or config.PORT_S3
  37     backend_port = DEFAULT_PORT_S3_BACKEND
  38     cmd = 'python "%s" s3 -p %s -H 0.0.0.0' % (__file__, backend_port)
  39     print('Starting mock S3 (%s port %s)...' % (get_service_protocol(), port))
  40     start_proxy_for_service('s3', port, backend_port, update_listener)
  41     env_vars = {'PYTHONPATH': ':'.join(sys.path)}
  42     return do_run(cmd, asynchronous, env_vars=env_vars)
  43 
  44 
  45 def apply_patches():
  46     s3_models.DEFAULT_KEY_BUFFER_SIZE = S3_MAX_FILE_SIZE_MB * 1024 * 1024
  47 
  48     def init(self, name, value, storage='STANDARD', etag=None, is_versioned=False, version_id=0, max_buffer_size=None):
  49         return original_init(self, name, value, storage=storage, etag=etag, is_versioned=is_versioned,
  50             version_id=version_id, max_buffer_size=s3_models.DEFAULT_KEY_BUFFER_SIZE)
  51 
  52     original_init = s3_models.FakeKey.__init__
  53     s3_models.FakeKey.__init__ = init
  54 
  55 
  56 def main():
  57     setup_logging()
  58     # patch moto implementation
  59     apply_patches()
  60     # start API
  61     sys.exit(moto_main())
  62 
  63 
  64 if __name__ == '__main__':
  65     main()
  66
  [end of localstack/services/s3/s3_starter.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/localstack/services/s3/s3_starter.py b/localstack/services/s3/s3_starter.py
  --- a/localstack/services/s3/s3_starter.py
  +++ b/localstack/services/s3/s3_starter.py
  @@ -35,7 +35,7 @@
   def start_s3(port=None, backend_port=None, asynchronous=None, update_listener=None):
       port = port or config.PORT_S3
       backend_port = DEFAULT_PORT_S3_BACKEND
  -    cmd = 'python "%s" s3 -p %s -H 0.0.0.0' % (__file__, backend_port)
  +    cmd = '%s "%s" s3 -p %s -H 0.0.0.0' % (sys.executable, __file__, backend_port)
       print('Starting mock S3 (%s port %s)...' % (get_service_protocol(), port))
       start_proxy_for_service('s3', port, backend_port, update_listener)
       env_vars = {'PYTHONPATH': ':'.join(sys.path)}
  
verification_info: {"golden_diff": "diff --git a/localstack/services/s3/s3_starter.py b/localstack/services/s3/s3_starter.py\n--- a/localstack/services/s3/s3_starter.py\n+++ b/localstack/services/s3/s3_starter.py\n@@ -35,7 +35,7 @@\n def start_s3(port=None, backend_port=None, asynchronous=None, update_listener=None):\n     port = port or config.PORT_S3\n     backend_port = DEFAULT_PORT_S3_BACKEND\n-    cmd = 'python \"%s\" s3 -p %s -H 0.0.0.0' % (__file__, backend_port)\n+    cmd = '%s \"%s\" s3 -p %s -H 0.0.0.0' % (sys.executable, __file__, backend_port)\n     print('Starting mock S3 (%s port %s)...' % (get_service_protocol(), port))\n     start_proxy_for_service('s3', port, backend_port, update_listener)\n     env_vars = {'PYTHONPATH': ':'.join(sys.path)}\n", "issue": "Service \"s3\" not yet available, retrying...\nHello there\n\nAfter installing localstack and trying to start several services on my machine, s3 always failed to start\nThe command I am using to start them up is\n\n`SERVICES=sqs,sns,s3,lambda DEBUG=1 localstack start`\n(With `DEBUG=1` in place already for debugging)\n\nFirst few lines of the output are:\n\n```\n2018-06-19T10:05:57:WARNING:infra.py: Service \"s3\" not yet available, retrying...\n2018-06-19T10:06:00:WARNING:infra.py: Service \"s3\" not yet available, retrying...\n2018-06-19T10:06:05:WARNING:infra.py: Service \"s3\" not yet available, retrying...\n2018-06-19T10:06:08:WARNING:infra.py: Service \"s3\" not yet available, retrying...\n2018-06-19T10:06:12:WARNING:infra.py: Service \"s3\" not yet available, retrying...\n2018-06-19T10:06:15:WARNING:infra.py: Service \"s3\" not yet available, retrying...\n2018-06-19T10:06:19:WARNING:infra.py: Service \"s3\" not yet available, retrying...\n2018-06-19T10:06:22:ERROR:localstack.services.s3.s3_starter: S3 health check failed: An error occurred (ExpiredToken) when calling the AssumeRole operation: The security token included in the request is expired Traceback (most recent call last):\n  File \"/usr/local/lib/python3.6/site-packages/localstack/services/infra.py\", line 344, in check_infra\n    raise e\n  File \"/usr/local/lib/python3.6/site-packages/localstack/services/infra.py\", line 341, in check_infra\n    plugin.check(expect_shutdown=expect_shutdown, print_error=print_error)\n  File \"/usr/local/lib/python3.6/site-packages/localstack/services/infra.py\", line 80, in check\n    return self.check_function(expect_shutdown=expect_shutdown, print_error=print_error)\n  File \"/usr/local/lib/python3.6/site-packages/localstack/services/s3/s3_starter.py\", line 23, in check_s3\n    assert isinstance(out['Buckets'], list)\nTypeError: 'NoneType' object is not subscriptable\n\nDuring handling of the above exception, another exception occurred:\n...\n```\n\nI have been trying to tackle this problem for a few hours already, without any success, I tried the latest verion of localstack as well as 0.8.6.1 which works on another machine\n\nI am installing it trough pip (`pip install localstack`)\n\nThanks for any help in advance!\n\n\n\n\u2506Issue is synchronized with this [Jira Bug](https://localstack.atlassian.net/browse/LOC-309) by [Unito](https://www.unito.io/learn-more)\n\n", "before_files": [{"content": "import sys\nimport logging\nimport traceback\nfrom moto.s3 import models as s3_models\nfrom moto.server import main as moto_main\nfrom localstack import config\nfrom localstack.constants import DEFAULT_PORT_S3_BACKEND\nfrom localstack.utils.aws import aws_stack\nfrom localstack.utils.common import wait_for_port_open\nfrom localstack.services.infra import (\n    get_service_protocol, start_proxy_for_service, do_run, setup_logging)\n\nLOGGER = logging.getLogger(__name__)\n\n# max file size for S3 objects (in MB)\nS3_MAX_FILE_SIZE_MB = 128\n\n\ndef check_s3(expect_shutdown=False, print_error=False):\n    out = None\n    try:\n        # wait for port to be opened\n        wait_for_port_open(DEFAULT_PORT_S3_BACKEND)\n        # check S3\n        out = aws_stack.connect_to_service(service_name='s3').list_buckets()\n    except Exception as e:\n        if print_error:\n            LOGGER.error('S3 health check failed: %s %s' % (e, traceback.format_exc()))\n    if expect_shutdown:\n        assert out is None\n    else:\n        assert isinstance(out['Buckets'], list)\n\n\ndef start_s3(port=None, backend_port=None, asynchronous=None, update_listener=None):\n    port = port or config.PORT_S3\n    backend_port = DEFAULT_PORT_S3_BACKEND\n    cmd = 'python \"%s\" s3 -p %s -H 0.0.0.0' % (__file__, backend_port)\n    print('Starting mock S3 (%s port %s)...' % (get_service_protocol(), port))\n    start_proxy_for_service('s3', port, backend_port, update_listener)\n    env_vars = {'PYTHONPATH': ':'.join(sys.path)}\n    return do_run(cmd, asynchronous, env_vars=env_vars)\n\n\ndef apply_patches():\n    s3_models.DEFAULT_KEY_BUFFER_SIZE = S3_MAX_FILE_SIZE_MB * 1024 * 1024\n\n    def init(self, name, value, storage='STANDARD', etag=None, is_versioned=False, version_id=0, max_buffer_size=None):\n        return original_init(self, name, value, storage=storage, etag=etag, is_versioned=is_versioned,\n            version_id=version_id, max_buffer_size=s3_models.DEFAULT_KEY_BUFFER_SIZE)\n\n    original_init = s3_models.FakeKey.__init__\n    s3_models.FakeKey.__init__ = init\n\n\ndef main():\n    setup_logging()\n    # patch moto implementation\n    apply_patches()\n    # start API\n    sys.exit(moto_main())\n\n\nif __name__ == '__main__':\n    main()\n", "path": "localstack/services/s3/s3_starter.py"}]}