prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Traceback appears in Status Bar, when trying to replay live flow
  ##### Steps to reproduce the problem:
  
  1. Run **pathod** : `pathod -a "/=200:p0,10"`
  2. Run mitmproxy.
  3. Send _get request_ to pathod through mitmproxy using **pathoc**: 
  `pathoc -c localhost:9999 localhost:8080 'get:/'`
  4. Try to replay the corresponding live flow in mitmproxy by pressing `r`.
  
  I am seeing:
  ![screenshot from 2018-01-06 13-40-01](https://user-images.githubusercontent.com/20267977/34639350-30f9aed6-f2e7-11e7-8920-44979218178e.png)
  
  
  ##### Any other comments? What have you tried so far?
  This issue is relevant for the situations, when server didn't have time to send a response yet, but a user tries to replay the corresponding flow.
  I also faced this issue, when trying to replay `mitm.it` flow from onboardingapp.
  
  
  ##### System information
  
  Mitmproxy: 3.0.0.dev1101 (commit d9d4d15) binary
  Python: 3.5.2
  OpenSSL: OpenSSL 1.1.0g 2 Nov 2017
  Platform: Linux-4.4.0-104-generic-x86_64-with-debian-stretch-sid
  
    
  
  </issue>
  <code>
  [start of mitmproxy/addons/clientplayback.py]
  1 from mitmproxy import exceptions
  2 from mitmproxy import ctx
  3 from mitmproxy import io
  4 from mitmproxy import flow
  5 from mitmproxy import command
  6 import mitmproxy.types
  7 
  8 import typing
  9 
  10 
  11 class ClientPlayback:
  12     def __init__(self):
  13         self.flows = []  # type: typing.List[flow.Flow]
  14         self.current_thread = None
  15         self.configured = False
  16 
  17     def count(self) -> int:
  18         if self.current_thread:
  19             current = 1
  20         else:
  21             current = 0
  22         return current + len(self.flows)
  23 
  24     @command.command("replay.client.stop")
  25     def stop_replay(self) -> None:
  26         """
  27             Stop client replay.
  28         """
  29         self.flows = []
  30         ctx.log.alert("Client replay stopped.")
  31         ctx.master.addons.trigger("update", [])
  32 
  33     @command.command("replay.client")
  34     def start_replay(self, flows: typing.Sequence[flow.Flow]) -> None:
  35         """
  36             Replay requests from flows.
  37         """
  38         self.flows = list(flows)
  39         ctx.log.alert("Replaying %s flows." % len(self.flows))
  40         ctx.master.addons.trigger("update", [])
  41 
  42     @command.command("replay.client.file")
  43     def load_file(self, path: mitmproxy.types.Path) -> None:
  44         try:
  45             flows = io.read_flows_from_paths([path])
  46         except exceptions.FlowReadException as e:
  47             raise exceptions.CommandError(str(e))
  48         ctx.log.alert("Replaying %s flows." % len(self.flows))
  49         self.flows = flows
  50         ctx.master.addons.trigger("update", [])
  51 
  52     def configure(self, updated):
  53         if not self.configured and ctx.options.client_replay:
  54             self.configured = True
  55             ctx.log.info("Client Replay: {}".format(ctx.options.client_replay))
  56             try:
  57                 flows = io.read_flows_from_paths(ctx.options.client_replay)
  58             except exceptions.FlowReadException as e:
  59                 raise exceptions.OptionsError(str(e))
  60             self.start_replay(flows)
  61 
  62     def tick(self):
  63         current_is_done = self.current_thread and not self.current_thread.is_alive()
  64         can_start_new = not self.current_thread or current_is_done
  65         will_start_new = can_start_new and self.flows
  66 
  67         if current_is_done:
  68             self.current_thread = None
  69             ctx.master.addons.trigger("update", [])
  70         if will_start_new:
  71             f = self.flows.pop(0)
  72             self.current_thread = ctx.master.replay_request(f)
  73             ctx.master.addons.trigger("update", [f])
  74         if current_is_done and not will_start_new:
  75             ctx.master.addons.trigger("processing_complete")
  76
  [end of mitmproxy/addons/clientplayback.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/mitmproxy/addons/clientplayback.py b/mitmproxy/addons/clientplayback.py
  --- a/mitmproxy/addons/clientplayback.py
  +++ b/mitmproxy/addons/clientplayback.py
  @@ -35,6 +35,9 @@
           """
               Replay requests from flows.
           """
  +        for f in flows:
  +            if f.live:
  +                raise exceptions.CommandError("Can't replay live flow.")
           self.flows = list(flows)
           ctx.log.alert("Replaying %s flows." % len(self.flows))
           ctx.master.addons.trigger("update", [])
  
verification_info: {"golden_diff": "diff --git a/mitmproxy/addons/clientplayback.py b/mitmproxy/addons/clientplayback.py\n--- a/mitmproxy/addons/clientplayback.py\n+++ b/mitmproxy/addons/clientplayback.py\n@@ -35,6 +35,9 @@\n         \"\"\"\n             Replay requests from flows.\n         \"\"\"\n+        for f in flows:\n+            if f.live:\n+                raise exceptions.CommandError(\"Can't replay live flow.\")\n         self.flows = list(flows)\n         ctx.log.alert(\"Replaying %s flows.\" % len(self.flows))\n         ctx.master.addons.trigger(\"update\", [])\n", "issue": "Traceback appears in Status Bar, when trying to replay live flow\n##### Steps to reproduce the problem:\r\n\r\n1. Run **pathod** : `pathod -a \"/=200:p0,10\"`\r\n2. Run mitmproxy.\r\n3. Send _get request_ to pathod through mitmproxy using **pathoc**: \r\n`pathoc -c localhost:9999 localhost:8080 'get:/'`\r\n4. Try to replay the corresponding live flow in mitmproxy by pressing `r`.\r\n\r\nI am seeing:\r\n![screenshot from 2018-01-06 13-40-01](https://user-images.githubusercontent.com/20267977/34639350-30f9aed6-f2e7-11e7-8920-44979218178e.png)\r\n\r\n\r\n##### Any other comments? What have you tried so far?\r\nThis issue is relevant for the situations, when server didn't have time to send a response yet, but a user tries to replay the corresponding flow.\r\nI also faced this issue, when trying to replay `mitm.it` flow from onboardingapp.\r\n\r\n\r\n##### System information\r\n\r\nMitmproxy: 3.0.0.dev1101 (commit d9d4d15) binary\r\nPython: 3.5.2\r\nOpenSSL: OpenSSL 1.1.0g 2 Nov 2017\r\nPlatform: Linux-4.4.0-104-generic-x86_64-with-debian-stretch-sid\r\n\r\n  \n", "before_files": [{"content": "from mitmproxy import exceptions\nfrom mitmproxy import ctx\nfrom mitmproxy import io\nfrom mitmproxy import flow\nfrom mitmproxy import command\nimport mitmproxy.types\n\nimport typing\n\n\nclass ClientPlayback:\n    def __init__(self):\n        self.flows = []  # type: typing.List[flow.Flow]\n        self.current_thread = None\n        self.configured = False\n\n    def count(self) -> int:\n        if self.current_thread:\n            current = 1\n        else:\n            current = 0\n        return current + len(self.flows)\n\n    @command.command(\"replay.client.stop\")\n    def stop_replay(self) -> None:\n        \"\"\"\n            Stop client replay.\n        \"\"\"\n        self.flows = []\n        ctx.log.alert(\"Client replay stopped.\")\n        ctx.master.addons.trigger(\"update\", [])\n\n    @command.command(\"replay.client\")\n    def start_replay(self, flows: typing.Sequence[flow.Flow]) -> None:\n        \"\"\"\n            Replay requests from flows.\n        \"\"\"\n        self.flows = list(flows)\n        ctx.log.alert(\"Replaying %s flows.\" % len(self.flows))\n        ctx.master.addons.trigger(\"update\", [])\n\n    @command.command(\"replay.client.file\")\n    def load_file(self, path: mitmproxy.types.Path) -> None:\n        try:\n            flows = io.read_flows_from_paths([path])\n        except exceptions.FlowReadException as e:\n            raise exceptions.CommandError(str(e))\n        ctx.log.alert(\"Replaying %s flows.\" % len(self.flows))\n        self.flows = flows\n        ctx.master.addons.trigger(\"update\", [])\n\n    def configure(self, updated):\n        if not self.configured and ctx.options.client_replay:\n            self.configured = True\n            ctx.log.info(\"Client Replay: {}\".format(ctx.options.client_replay))\n            try:\n                flows = io.read_flows_from_paths(ctx.options.client_replay)\n            except exceptions.FlowReadException as e:\n                raise exceptions.OptionsError(str(e))\n            self.start_replay(flows)\n\n    def tick(self):\n        current_is_done = self.current_thread and not self.current_thread.is_alive()\n        can_start_new = not self.current_thread or current_is_done\n        will_start_new = can_start_new and self.flows\n\n        if current_is_done:\n            self.current_thread = None\n            ctx.master.addons.trigger(\"update\", [])\n        if will_start_new:\n            f = self.flows.pop(0)\n            self.current_thread = ctx.master.replay_request(f)\n            ctx.master.addons.trigger(\"update\", [f])\n        if current_is_done and not will_start_new:\n            ctx.master.addons.trigger(\"processing_complete\")\n", "path": "mitmproxy/addons/clientplayback.py"}]}