prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Importing of JSON timelines creates duplicate timelines with same name.
  Steps to reproduce
  1) command line:
  echo '[
    {
      "datetime": "2012-04-12T17:24:38-08:00",
      "timestamp_desc": "Test",
      "timestamp": 1334251478000000,
      "message": "Test message"
    }
  ]' > test_dupe.json  
  tsctl json2ts --name test_dupe --file test_dupe.json
  tsctl json2ts --name test_dupe --file test_dupe.json
  
  2) Create new sketch
  3) Notice duplicate "test_dupe" timelines on list to select from.
  4) Add both
  5) Explore, using "*" as filter.
  6) notice duplicate results.
  
  
  </issue>
  <code>
  [start of wsgi.py]
  1 #!/usr/bin/env python
  2 # Copyright 2015 Google Inc. All rights reserved.
  3 #
  4 # Licensed under the Apache License, Version 2.0 (the "License");
  5 # you may not use this file except in compliance with the License.
  6 # You may obtain a copy of the License at
  7 #
  8 #     http://www.apache.org/licenses/LICENSE-2.0
  9 #
  10 # Unless required by applicable law or agreed to in writing, software
  11 # distributed under the License is distributed on an "AS IS" BASIS,
  12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 # See the License for the specific language governing permissions and
  14 # limitations under the License.
  15 """This module is for creating the app for a WSGI server.
  16 
  17 Example with Gunicorn:
  18 $ gunicorn -b 127.0.0.1:4000 --log-file - wsgi:application
  19 
  20 Example configuration for Apache with mod_wsgi (a2enmod mod_wsgi):
  21 <VirtualHost *:443>
  22         ServerAdmin root@localhost
  23         SSLEngine On
  24         SSLCertificateFile    /etc/apache2/cert.crt
  25         SSLCertificateKeyFile /etc/apache2/cert.key
  26         WSGIScriptAlias / /path/to/this/file/wsgi.py
  27 </VirtualHost>
  28 """
  29 
  30 # If you installed Timesketch in a virtualenv you need to activate it.
  31 # This needs to be before any imports in order to import from the virtualenv.
  32 #activate_virtualenv = '/path/to/your/virtualenv/bin/activate_this.py'
  33 #execfile(activate_virtualenv, dict(__file__=activate_virtualenv))
  34 
  35 from timesketch import create_app
  36 from timesketch.models import db_session
  37 
  38 application = create_app()
  39 
  40 # Remove the session after every request or app shutdown.
  41 @application.teardown_appcontext
  42 def shutdown_session(exception=None):
  43     db_session.remove()
  44
  [end of wsgi.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/wsgi.py b/wsgi.py
  --- a/wsgi.py
  +++ b/wsgi.py
  @@ -37,7 +37,8 @@
   
   application = create_app()
   
  -# Remove the session after every request or app shutdown.
  +# pylint: disable=unused-argument
   @application.teardown_appcontext
   def shutdown_session(exception=None):
  +    """Remove the database session after every request or app shutdown."""
       db_session.remove()
  
verification_info: {"golden_diff": "diff --git a/wsgi.py b/wsgi.py\n--- a/wsgi.py\n+++ b/wsgi.py\n@@ -37,7 +37,8 @@\n \n application = create_app()\n \n-# Remove the session after every request or app shutdown.\n+# pylint: disable=unused-argument\n @application.teardown_appcontext\n def shutdown_session(exception=None):\n+    \"\"\"Remove the database session after every request or app shutdown.\"\"\"\n     db_session.remove()\n", "issue": "Importing of JSON timelines creates duplicate timelines with same name.\nSteps to reproduce\n1) command line:\necho '[\n  {\n    \"datetime\": \"2012-04-12T17:24:38-08:00\",\n    \"timestamp_desc\": \"Test\",\n    \"timestamp\": 1334251478000000,\n    \"message\": \"Test message\"\n  }\n]' > test_dupe.json  \ntsctl json2ts --name test_dupe --file test_dupe.json\ntsctl json2ts --name test_dupe --file test_dupe.json\n\n2) Create new sketch\n3) Notice duplicate \"test_dupe\" timelines on list to select from.\n4) Add both\n5) Explore, using \"*\" as filter.\n6) notice duplicate results.\n\n", "before_files": [{"content": "#!/usr/bin/env python\n# Copyright 2015 Google Inc. All rights reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\"\"\"This module is for creating the app for a WSGI server.\n\nExample with Gunicorn:\n$ gunicorn -b 127.0.0.1:4000 --log-file - wsgi:application\n\nExample configuration for Apache with mod_wsgi (a2enmod mod_wsgi):\n<VirtualHost *:443>\n        ServerAdmin root@localhost\n        SSLEngine On\n        SSLCertificateFile    /etc/apache2/cert.crt\n        SSLCertificateKeyFile /etc/apache2/cert.key\n        WSGIScriptAlias / /path/to/this/file/wsgi.py\n</VirtualHost>\n\"\"\"\n\n# If you installed Timesketch in a virtualenv you need to activate it.\n# This needs to be before any imports in order to import from the virtualenv.\n#activate_virtualenv = '/path/to/your/virtualenv/bin/activate_this.py'\n#execfile(activate_virtualenv, dict(__file__=activate_virtualenv))\n\nfrom timesketch import create_app\nfrom timesketch.models import db_session\n\napplication = create_app()\n\n# Remove the session after every request or app shutdown.\n@application.teardown_appcontext\ndef shutdown_session(exception=None):\n    db_session.remove()\n", "path": "wsgi.py"}]}