prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  features/steps/standby_cluster.py produces error under Windows
  Trying to execute:
  `>behave -i standby_cluster.feature`
  will produce error:
  ```
  2020-05-07 19:27:19,407 ERROR: Failed to execute ['c:userspashaappdatalocalprogramspythonpython37-32python.exe', 'features/callback.py', '5362', 'on_role_change', 'master', 'batman']
  Traceback (most recent call last):
    File "C:\Users\pasha\Code\zalando-patroni\patroni\postgresql\cancellable.py", line 28, in _start_process
      self._process = psutil.Popen(cmd, *args, **kwargs)
    File "c:\users\pasha\appdata\local\programs\python\python37-32\lib\site-packages\psutil\__init__.py", line 1431, in __init__
      self.__subproc = subprocess.Popen(*args, **kwargs)
    File "c:\users\pasha\appdata\local\programs\python\python37-32\lib\subprocess.py", line 775, in __init__
      restore_signals, start_new_session)
    File "c:\users\pasha\appdata\local\programs\python\python37-32\lib\subprocess.py", line 1178, in _execute_child
      startupinfo)
  FileNotFoundError: [WinError 2] The system cannot find the file specified
  ```
  
  This error produced by `postgresql/cancellable.py`: 
  ```
      def _start_process(self, cmd, *args, **kwargs):
          """This method must be executed only when the `_lock` is acquired"""
  
          try:
              self._process_children = []
              self._process_cmd = cmd
              self._process = psutil.Popen(cmd, *args, **kwargs)
                                     ^^^^^^^^^^^^^^^^^
          except Exception:
              return logger.exception('Failed to execute %s',  cmd)
          return True
  ```
  
  
  </issue>
  <code>
  [start of features/steps/standby_cluster.py]
  1 import os
  2 import sys
  3 import time
  4 
  5 from behave import step
  6 
  7 
  8 select_replication_query = """
  9 SELECT * FROM pg_catalog.pg_stat_replication
  10 WHERE application_name = '{0}'
  11 """
  12 
  13 callback = sys.executable + " features/callback2.py "
  14 
  15 
  16 @step('I start {name:w} with callback configured')
  17 def start_patroni_with_callbacks(context, name):
  18     return context.pctl.start(name, custom_config={
  19         "postgresql": {
  20             "callbacks": {
  21                 "on_role_change": sys.executable + " features/callback.py"
  22             }
  23         }
  24     })
  25 
  26 
  27 @step('I start {name:w} in a cluster {cluster_name:w}')
  28 def start_patroni(context, name, cluster_name):
  29     return context.pctl.start(name, custom_config={
  30         "scope": cluster_name,
  31         "postgresql": {
  32             "callbacks": {c: callback + name for c in ('on_start', 'on_stop', 'on_restart', 'on_role_change')},
  33             "backup_restore": {
  34                 "command": (sys.executable + " features/backup_restore.py --sourcedir=" +
  35                             os.path.join(context.pctl.patroni_path, 'data', 'basebackup'))}
  36         }
  37     })
  38 
  39 
  40 @step('I start {name:w} in a standby cluster {cluster_name:w} as a clone of {name2:w}')
  41 def start_patroni_standby_cluster(context, name, cluster_name, name2):
  42     # we need to remove patroni.dynamic.json in order to "bootstrap" standby cluster with existing PGDATA
  43     os.unlink(os.path.join(context.pctl._processes[name]._data_dir, 'patroni.dynamic.json'))
  44     port = context.pctl._processes[name2]._connkwargs.get('port')
  45     context.pctl._processes[name].update_config({
  46         "scope": cluster_name,
  47         "bootstrap": {
  48             "dcs": {
  49                 "ttl": 20,
  50                 "loop_wait": 2,
  51                 "retry_timeout": 5,
  52                 "standby_cluster": {
  53                     "host": "localhost",
  54                     "port": port,
  55                     "primary_slot_name": "pm_1",
  56                     "create_replica_methods": ["backup_restore", "basebackup"]
  57                 }
  58             }
  59         },
  60         "postgresql": {
  61             "callbacks": {c: callback + name for c in ('on_start', 'on_stop', 'on_restart', 'on_role_change')}
  62         }
  63     })
  64     return context.pctl.start(name)
  65 
  66 
  67 @step('{pg_name1:w} is replicating from {pg_name2:w} after {timeout:d} seconds')
  68 def check_replication_status(context, pg_name1, pg_name2, timeout):
  69     bound_time = time.time() + timeout
  70 
  71     while time.time() < bound_time:
  72         cur = context.pctl.query(
  73             pg_name2,
  74             select_replication_query.format(pg_name1),
  75             fail_ok=True
  76         )
  77 
  78         if cur and len(cur.fetchall()) != 0:
  79             break
  80 
  81         time.sleep(1)
  82     else:
  83         assert False, "{0} is not replicating from {1} after {2} seconds".format(pg_name1, pg_name2, timeout)
  84
  [end of features/steps/standby_cluster.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/features/steps/standby_cluster.py b/features/steps/standby_cluster.py
  --- a/features/steps/standby_cluster.py
  +++ b/features/steps/standby_cluster.py
  @@ -10,7 +10,8 @@
   WHERE application_name = '{0}'
   """
   
  -callback = sys.executable + " features/callback2.py "
  +executable = sys.executable if os.name != 'nt' else sys.executable.replace('\\', '/')
  +callback = executable + " features/callback2.py "
   
   
   @step('I start {name:w} with callback configured')
  @@ -18,7 +19,7 @@
       return context.pctl.start(name, custom_config={
           "postgresql": {
               "callbacks": {
  -                "on_role_change": sys.executable + " features/callback.py"
  +                "on_role_change": executable + " features/callback.py"
               }
           }
       })
  @@ -31,7 +32,7 @@
           "postgresql": {
               "callbacks": {c: callback + name for c in ('on_start', 'on_stop', 'on_restart', 'on_role_change')},
               "backup_restore": {
  -                "command": (sys.executable + " features/backup_restore.py --sourcedir=" +
  +                "command": (executable + " features/backup_restore.py --sourcedir=" +
                               os.path.join(context.pctl.patroni_path, 'data', 'basebackup'))}
           }
       })
  
verification_info: {"golden_diff": "diff --git a/features/steps/standby_cluster.py b/features/steps/standby_cluster.py\n--- a/features/steps/standby_cluster.py\n+++ b/features/steps/standby_cluster.py\n@@ -10,7 +10,8 @@\n WHERE application_name = '{0}'\n \"\"\"\n \n-callback = sys.executable + \" features/callback2.py \"\n+executable = sys.executable if os.name != 'nt' else sys.executable.replace('\\\\', '/')\n+callback = executable + \" features/callback2.py \"\n \n \n @step('I start {name:w} with callback configured')\n@@ -18,7 +19,7 @@\n     return context.pctl.start(name, custom_config={\n         \"postgresql\": {\n             \"callbacks\": {\n-                \"on_role_change\": sys.executable + \" features/callback.py\"\n+                \"on_role_change\": executable + \" features/callback.py\"\n             }\n         }\n     })\n@@ -31,7 +32,7 @@\n         \"postgresql\": {\n             \"callbacks\": {c: callback + name for c in ('on_start', 'on_stop', 'on_restart', 'on_role_change')},\n             \"backup_restore\": {\n-                \"command\": (sys.executable + \" features/backup_restore.py --sourcedir=\" +\n+                \"command\": (executable + \" features/backup_restore.py --sourcedir=\" +\n                             os.path.join(context.pctl.patroni_path, 'data', 'basebackup'))}\n         }\n     })\n", "issue": "features/steps/standby_cluster.py produces error under Windows\nTrying to execute:\r\n`>behave -i standby_cluster.feature`\r\nwill produce error:\r\n```\r\n2020-05-07 19:27:19,407 ERROR: Failed to execute ['c:userspashaappdatalocalprogramspythonpython37-32python.exe', 'features/callback.py', '5362', 'on_role_change', 'master', 'batman']\r\nTraceback (most recent call last):\r\n  File \"C:\\Users\\pasha\\Code\\zalando-patroni\\patroni\\postgresql\\cancellable.py\", line 28, in _start_process\r\n    self._process = psutil.Popen(cmd, *args, **kwargs)\r\n  File \"c:\\users\\pasha\\appdata\\local\\programs\\python\\python37-32\\lib\\site-packages\\psutil\\__init__.py\", line 1431, in __init__\r\n    self.__subproc = subprocess.Popen(*args, **kwargs)\r\n  File \"c:\\users\\pasha\\appdata\\local\\programs\\python\\python37-32\\lib\\subprocess.py\", line 775, in __init__\r\n    restore_signals, start_new_session)\r\n  File \"c:\\users\\pasha\\appdata\\local\\programs\\python\\python37-32\\lib\\subprocess.py\", line 1178, in _execute_child\r\n    startupinfo)\r\nFileNotFoundError: [WinError 2] The system cannot find the file specified\r\n```\r\n\r\nThis error produced by `postgresql/cancellable.py`: \r\n```\r\n    def _start_process(self, cmd, *args, **kwargs):\r\n        \"\"\"This method must be executed only when the `_lock` is acquired\"\"\"\r\n\r\n        try:\r\n            self._process_children = []\r\n            self._process_cmd = cmd\r\n            self._process = psutil.Popen(cmd, *args, **kwargs)\r\n                                   ^^^^^^^^^^^^^^^^^\r\n        except Exception:\r\n            return logger.exception('Failed to execute %s',  cmd)\r\n        return True\r\n```\r\n\n", "before_files": [{"content": "import os\nimport sys\nimport time\n\nfrom behave import step\n\n\nselect_replication_query = \"\"\"\nSELECT * FROM pg_catalog.pg_stat_replication\nWHERE application_name = '{0}'\n\"\"\"\n\ncallback = sys.executable + \" features/callback2.py \"\n\n\n@step('I start {name:w} with callback configured')\ndef start_patroni_with_callbacks(context, name):\n    return context.pctl.start(name, custom_config={\n        \"postgresql\": {\n            \"callbacks\": {\n                \"on_role_change\": sys.executable + \" features/callback.py\"\n            }\n        }\n    })\n\n\n@step('I start {name:w} in a cluster {cluster_name:w}')\ndef start_patroni(context, name, cluster_name):\n    return context.pctl.start(name, custom_config={\n        \"scope\": cluster_name,\n        \"postgresql\": {\n            \"callbacks\": {c: callback + name for c in ('on_start', 'on_stop', 'on_restart', 'on_role_change')},\n            \"backup_restore\": {\n                \"command\": (sys.executable + \" features/backup_restore.py --sourcedir=\" +\n                            os.path.join(context.pctl.patroni_path, 'data', 'basebackup'))}\n        }\n    })\n\n\n@step('I start {name:w} in a standby cluster {cluster_name:w} as a clone of {name2:w}')\ndef start_patroni_standby_cluster(context, name, cluster_name, name2):\n    # we need to remove patroni.dynamic.json in order to \"bootstrap\" standby cluster with existing PGDATA\n    os.unlink(os.path.join(context.pctl._processes[name]._data_dir, 'patroni.dynamic.json'))\n    port = context.pctl._processes[name2]._connkwargs.get('port')\n    context.pctl._processes[name].update_config({\n        \"scope\": cluster_name,\n        \"bootstrap\": {\n            \"dcs\": {\n                \"ttl\": 20,\n                \"loop_wait\": 2,\n                \"retry_timeout\": 5,\n                \"standby_cluster\": {\n                    \"host\": \"localhost\",\n                    \"port\": port,\n                    \"primary_slot_name\": \"pm_1\",\n                    \"create_replica_methods\": [\"backup_restore\", \"basebackup\"]\n                }\n            }\n        },\n        \"postgresql\": {\n            \"callbacks\": {c: callback + name for c in ('on_start', 'on_stop', 'on_restart', 'on_role_change')}\n        }\n    })\n    return context.pctl.start(name)\n\n\n@step('{pg_name1:w} is replicating from {pg_name2:w} after {timeout:d} seconds')\ndef check_replication_status(context, pg_name1, pg_name2, timeout):\n    bound_time = time.time() + timeout\n\n    while time.time() < bound_time:\n        cur = context.pctl.query(\n            pg_name2,\n            select_replication_query.format(pg_name1),\n            fail_ok=True\n        )\n\n        if cur and len(cur.fetchall()) != 0:\n            break\n\n        time.sleep(1)\n    else:\n        assert False, \"{0} is not replicating from {1} after {2} seconds\".format(pg_name1, pg_name2, timeout)\n", "path": "features/steps/standby_cluster.py"}]}