prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  `deis run` generates 500 error
  [Integration tests](http://ci.deis.io/view/example-apps/job/test-integration-clojure-ring/47/console) against master found an error in `deis run`:
  
  ```
  === appssample Domains
  No domains
  
  
  ok
  /home/jenkins/workspace/test-integration-clojure-ring/src/github.com/deis/deis/tests/example-clojure-ring
  apps:run echo hello
  
  500 INTERNAL SERVER ERROR
  <h1>Server Error (500)</h1>
  
  error at command wait
  --- FAIL: TestApps (76.15 seconds)
      itutils.go:199: Failed:
          exit status 1
  FAIL
  exit status 1
  ```
  
  
  </issue>
  <code>
  [start of controller/api/tasks.py]
  1 """
  2 Long-running tasks for the Deis Controller API
  3 
  4 This module orchestrates the real "heavy lifting" of Deis, and as such these
  5 functions are decorated to run as asynchronous celery tasks.
  6 """
  7 
  8 from __future__ import unicode_literals
  9 
  10 import requests
  11 import threading
  12 
  13 from celery import task
  14 from django.conf import settings
  15 
  16 
  17 @task
  18 def create_cluster(cluster):
  19     cluster._scheduler.setUp()
  20 
  21 
  22 @task
  23 def destroy_cluster(cluster):
  24     for app in cluster.app_set.all():
  25         app.destroy()
  26     cluster._scheduler.tearDown()
  27 
  28 
  29 @task
  30 def deploy_release(app, release):
  31     containers = app.container_set.all()
  32     threads = []
  33     for c in containers:
  34         threads.append(threading.Thread(target=c.deploy, args=(release,)))
  35     [t.start() for t in threads]
  36     [t.join() for t in threads]
  37 
  38 
  39 @task
  40 def import_repository(source, target_repository):
  41     """Imports an image from a remote registry into our own private registry"""
  42     data = {
  43         'src': source,
  44     }
  45     requests.post(
  46         '{}/v1/repositories/{}/tags'.format(settings.REGISTRY_URL,
  47                                             target_repository),
  48         data=data,
  49     )
  50 
  51 
  52 @task
  53 def start_containers(containers):
  54     create_threads = []
  55     start_threads = []
  56     for c in containers:
  57         create_threads.append(threading.Thread(target=c.create))
  58         start_threads.append(threading.Thread(target=c.start))
  59     [t.start() for t in create_threads]
  60     [t.join() for t in create_threads]
  61     [t.start() for t in start_threads]
  62     [t.join() for t in start_threads]
  63 
  64 
  65 @task
  66 def stop_containers(containers):
  67     destroy_threads = []
  68     delete_threads = []
  69     for c in containers:
  70         destroy_threads.append(threading.Thread(target=c.destroy))
  71         delete_threads.append(threading.Thread(target=c.delete))
  72     [t.start() for t in destroy_threads]
  73     [t.join() for t in destroy_threads]
  74     [t.start() for t in delete_threads]
  75     [t.join() for t in delete_threads]
  76 
  77 
  78 @task
  79 def run_command(c, command):
  80     release = c.release
  81     version = release.version
  82     image = release.image
  83     try:
  84         # pull the image first
  85         rc, pull_output = c.run("docker pull {image}".format(**locals()))
  86         if rc != 0:
  87             raise EnvironmentError('Could not pull image: {pull_image}'.format(**locals()))
  88         # run the command
  89         docker_args = ' '.join(['--entrypoint=/bin/sh',
  90                                 '-a', 'stdout', '-a', 'stderr', '--rm', image])
  91         escaped_command = command.replace("'", "'\\''")
  92         command = r"docker run {docker_args} -c \'{escaped_command}\'".format(**locals())
  93         return c.run(command)
  94     finally:
  95         c.delete()
  96
  [end of controller/api/tasks.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/controller/api/tasks.py b/controller/api/tasks.py
  --- a/controller/api/tasks.py
  +++ b/controller/api/tasks.py
  @@ -79,12 +79,14 @@
   def run_command(c, command):
       release = c.release
       version = release.version
  -    image = release.image
  +    image = '{}:{}/{}'.format(settings.REGISTRY_HOST,
  +                              settings.REGISTRY_PORT,
  +                              release.image)
       try:
           # pull the image first
           rc, pull_output = c.run("docker pull {image}".format(**locals()))
           if rc != 0:
  -            raise EnvironmentError('Could not pull image: {pull_image}'.format(**locals()))
  +            raise EnvironmentError('Could not pull image: {image}'.format(**locals()))
           # run the command
           docker_args = ' '.join(['--entrypoint=/bin/sh',
                                   '-a', 'stdout', '-a', 'stderr', '--rm', image])
  
verification_info: {"golden_diff": "diff --git a/controller/api/tasks.py b/controller/api/tasks.py\n--- a/controller/api/tasks.py\n+++ b/controller/api/tasks.py\n@@ -79,12 +79,14 @@\n def run_command(c, command):\n     release = c.release\n     version = release.version\n-    image = release.image\n+    image = '{}:{}/{}'.format(settings.REGISTRY_HOST,\n+                              settings.REGISTRY_PORT,\n+                              release.image)\n     try:\n         # pull the image first\n         rc, pull_output = c.run(\"docker pull {image}\".format(**locals()))\n         if rc != 0:\n-            raise EnvironmentError('Could not pull image: {pull_image}'.format(**locals()))\n+            raise EnvironmentError('Could not pull image: {image}'.format(**locals()))\n         # run the command\n         docker_args = ' '.join(['--entrypoint=/bin/sh',\n                                 '-a', 'stdout', '-a', 'stderr', '--rm', image])\n", "issue": "`deis run` generates 500 error\n[Integration tests](http://ci.deis.io/view/example-apps/job/test-integration-clojure-ring/47/console) against master found an error in `deis run`:\n\n```\n=== appssample Domains\nNo domains\n\n\nok\n/home/jenkins/workspace/test-integration-clojure-ring/src/github.com/deis/deis/tests/example-clojure-ring\napps:run echo hello\n\n500 INTERNAL SERVER ERROR\n<h1>Server Error (500)</h1>\n\nerror at command wait\n--- FAIL: TestApps (76.15 seconds)\n    itutils.go:199: Failed:\n        exit status 1\nFAIL\nexit status 1\n```\n\n", "before_files": [{"content": "\"\"\"\nLong-running tasks for the Deis Controller API\n\nThis module orchestrates the real \"heavy lifting\" of Deis, and as such these\nfunctions are decorated to run as asynchronous celery tasks.\n\"\"\"\n\nfrom __future__ import unicode_literals\n\nimport requests\nimport threading\n\nfrom celery import task\nfrom django.conf import settings\n\n\n@task\ndef create_cluster(cluster):\n    cluster._scheduler.setUp()\n\n\n@task\ndef destroy_cluster(cluster):\n    for app in cluster.app_set.all():\n        app.destroy()\n    cluster._scheduler.tearDown()\n\n\n@task\ndef deploy_release(app, release):\n    containers = app.container_set.all()\n    threads = []\n    for c in containers:\n        threads.append(threading.Thread(target=c.deploy, args=(release,)))\n    [t.start() for t in threads]\n    [t.join() for t in threads]\n\n\n@task\ndef import_repository(source, target_repository):\n    \"\"\"Imports an image from a remote registry into our own private registry\"\"\"\n    data = {\n        'src': source,\n    }\n    requests.post(\n        '{}/v1/repositories/{}/tags'.format(settings.REGISTRY_URL,\n                                            target_repository),\n        data=data,\n    )\n\n\n@task\ndef start_containers(containers):\n    create_threads = []\n    start_threads = []\n    for c in containers:\n        create_threads.append(threading.Thread(target=c.create))\n        start_threads.append(threading.Thread(target=c.start))\n    [t.start() for t in create_threads]\n    [t.join() for t in create_threads]\n    [t.start() for t in start_threads]\n    [t.join() for t in start_threads]\n\n\n@task\ndef stop_containers(containers):\n    destroy_threads = []\n    delete_threads = []\n    for c in containers:\n        destroy_threads.append(threading.Thread(target=c.destroy))\n        delete_threads.append(threading.Thread(target=c.delete))\n    [t.start() for t in destroy_threads]\n    [t.join() for t in destroy_threads]\n    [t.start() for t in delete_threads]\n    [t.join() for t in delete_threads]\n\n\n@task\ndef run_command(c, command):\n    release = c.release\n    version = release.version\n    image = release.image\n    try:\n        # pull the image first\n        rc, pull_output = c.run(\"docker pull {image}\".format(**locals()))\n        if rc != 0:\n            raise EnvironmentError('Could not pull image: {pull_image}'.format(**locals()))\n        # run the command\n        docker_args = ' '.join(['--entrypoint=/bin/sh',\n                                '-a', 'stdout', '-a', 'stderr', '--rm', image])\n        escaped_command = command.replace(\"'\", \"'\\\\''\")\n        command = r\"docker run {docker_args} -c \\'{escaped_command}\\'\".format(**locals())\n        return c.run(command)\n    finally:\n        c.delete()\n", "path": "controller/api/tasks.py"}]}