prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Cowrie not set up for py.test framework
  So I tried running the test in both python2 and python3. For python2 all the tests were passing but for python3 there was some error.
  
  ```
   py.test --cov=cowrie                     
  ===================================================================================== test session starts =====================================================================================
  platform linux -- Python 3.7.2, pytest-4.2.0, py-1.7.0, pluggy-0.8.1
  rootdir: /home/mzfr/dev/cowrie, inifile:
  plugins: cov-2.6.1
  collected 3 items / 3 errors                                                                                                                                                                  
  
  =========================================================================================== ERRORS ============================================================================================
  ___________________________________________________________________ ERROR collecting src/cowrie/test/test_base_commands.py ____________________________________________________________________
  ../shell/fs.py:26: in <module>
      PICKLE = pickle.load(open(CONFIG.get('shell', 'filesystem'), 'rb'))
  ../core/config.py:29: in get
      return super(EnvironmentConfigParser, self).get(section, option, **kwargs)
  /usr/lib/python3.7/configparser.py:780: in get
      d = self._unify_values(section, vars)
  /usr/lib/python3.7/configparser.py:1146: in _unify_values
      raise NoSectionError(section) from None
  E   configparser.NoSectionError: No section: 'shell'
  
  During handling of the above exception, another exception occurred:
  test_base_commands.py:12: in <module>
      from cowrie.shell import protocol
  ../shell/protocol.py:21: in <module>
      from cowrie.shell import command
  ../shell/command.py:20: in <module>
      from cowrie.shell import fs
  ../shell/fs.py:29: in <module>
      exit(2)
  /usr/lib/python3.7/_sitebuiltins.py:26: in __call__
      raise SystemExit(code)
  E   SystemExit: 2
  --------------------------------------------------------------------------------------- Captured stdout ---------------------------------------------------------------------------------------
  ERROR: Config file not found: etc/cowrie.cfg.dist
  ________________________________________________________________________ ERROR collecting src/cowrie/test/test_echo.py ________________________________________________________________________
  ../shell/fs.py:26: in <module>
      PICKLE = pickle.load(open(CONFIG.get('shell', 'filesystem'), 'rb'))
  ../core/config.py:29: in get
      return super(EnvironmentConfigParser, self).get(section, option, **kwargs)
  /usr/lib/python3.7/configparser.py:780: in get
      d = self._unify_values(section, vars)
  /usr/lib/python3.7/configparser.py:1146: in _unify_values
      raise NoSectionError(section) from None
  E   configparser.NoSectionError: No section: 'shell'
  
  During handling of the above exception, another exception occurred:
  test_echo.py:16: in <module>
      from cowrie.shell import protocol
  ../shell/protocol.py:21: in <module>
      from cowrie.shell import command
  ../shell/command.py:20: in <module>
      from cowrie.shell import fs
  ../shell/fs.py:29: in <module>
      exit(2)
  /usr/lib/python3.7/_sitebuiltins.py:26: in __call__
      raise SystemExit(code)
  E   SystemExit: 2
  --------------------------------------------------------------------------------------- Captured stdout ---------------------------------------------------------------------------------------
  ERROR: Config file not found: etc/cowrie.cfg.dist
  ________________________________________________________________________ ERROR collecting src/cowrie/test/test_tftp.py ________________________________________________________________________
  ../shell/fs.py:26: in <module>
      PICKLE = pickle.load(open(CONFIG.get('shell', 'filesystem'), 'rb'))
  ../core/config.py:29: in get
      return super(EnvironmentConfigParser, self).get(section, option, **kwargs)
  /usr/lib/python3.7/configparser.py:780: in get
      d = self._unify_values(section, vars)
  /usr/lib/python3.7/configparser.py:1146: in _unify_values
      raise NoSectionError(section) from None
  E   configparser.NoSectionError: No section: 'shell'
  
  During handling of the above exception, another exception occurred:
  test_tftp.py:16: in <module>
      from cowrie.shell import protocol
  ../shell/protocol.py:21: in <module>
      from cowrie.shell import command
  ../shell/command.py:20: in <module>
      from cowrie.shell import fs
  ../shell/fs.py:29: in <module>
      exit(2)
  /usr/lib/python3.7/_sitebuiltins.py:26: in __call__
      raise SystemExit(code)
  E   SystemExit: 2
  --------------------------------------------------------------------------------------- Captured stdout ---------------------------------------------------------------------------------------
  ERROR: Config file not found: etc/cowrie.cfg.dist
  ```
  
  </issue>
  <code>
  [start of src/cowrie/core/config.py]
  1 # Copyright (c) 2009-2014 Upi Tamminen <desaster@gmail.com>
  2 # See the COPYRIGHT file for more information
  3 
  4 """
  5 This module contains ...
  6 """
  7 
  8 from __future__ import absolute_import, division
  9 
  10 import configparser
  11 import os
  12 
  13 
  14 def to_environ_key(key):
  15     return key.upper()
  16 
  17 
  18 class EnvironmentConfigParser(configparser.ConfigParser):
  19 
  20     def has_option(self, section, option):
  21         if to_environ_key('_'.join((section, option))) in os.environ:
  22             return True
  23         return super(EnvironmentConfigParser, self).has_option(section, option)
  24 
  25     def get(self, section, option, **kwargs):
  26         key = to_environ_key('_'.join((section, option)))
  27         if key in os.environ:
  28             return os.environ[key]
  29         return super(EnvironmentConfigParser, self).get(section, option, **kwargs)
  30 
  31 
  32 def readConfigFile(cfgfile):
  33     """
  34     Read config files and return ConfigParser object
  35 
  36     @param cfgfile: filename or array of filenames
  37     @return: ConfigParser object
  38     """
  39     parser = EnvironmentConfigParser(interpolation=configparser.ExtendedInterpolation())
  40     parser.read(cfgfile)
  41     return parser
  42 
  43 
  44 CONFIG = readConfigFile(("etc/cowrie.cfg.dist", "/etc/cowrie/cowrie.cfg", "etc/cowrie.cfg", "cowrie.cfg"))
  45
  [end of src/cowrie/core/config.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/src/cowrie/core/config.py b/src/cowrie/core/config.py
  --- a/src/cowrie/core/config.py
  +++ b/src/cowrie/core/config.py
  @@ -8,7 +8,8 @@
   from __future__ import absolute_import, division
   
   import configparser
  -import os
  +from os import environ
  +from os.path import abspath, dirname, exists, join
   
   
   def to_environ_key(key):
  @@ -18,15 +19,16 @@
   class EnvironmentConfigParser(configparser.ConfigParser):
   
       def has_option(self, section, option):
  -        if to_environ_key('_'.join((section, option))) in os.environ:
  +        if to_environ_key('_'.join((section, option))) in environ:
               return True
           return super(EnvironmentConfigParser, self).has_option(section, option)
   
       def get(self, section, option, **kwargs):
           key = to_environ_key('_'.join((section, option)))
  -        if key in os.environ:
  -            return os.environ[key]
  -        return super(EnvironmentConfigParser, self).get(section, option, **kwargs)
  +        if key in environ:
  +            return environ[key]
  +        return super(EnvironmentConfigParser, self).get(
  +            section, option, **kwargs)
   
   
   def readConfigFile(cfgfile):
  @@ -36,9 +38,26 @@
       @param cfgfile: filename or array of filenames
       @return: ConfigParser object
       """
  -    parser = EnvironmentConfigParser(interpolation=configparser.ExtendedInterpolation())
  +    parser = EnvironmentConfigParser(
  +        interpolation=configparser.ExtendedInterpolation())
       parser.read(cfgfile)
       return parser
   
   
  -CONFIG = readConfigFile(("etc/cowrie.cfg.dist", "/etc/cowrie/cowrie.cfg", "etc/cowrie.cfg", "cowrie.cfg"))
  +def get_config_path():
  +    """Get absolute path to the config file
  +    """
  +    config_files = ["etc/cowrie/cowrie.cfg", "etc/cowrie.cfg",
  +                    "cowrie.cfg", "etc/cowrie.cfg.dist"]
  +    current_path = abspath(dirname(__file__))
  +    root = "/".join(current_path.split("/")[:-3])
  +
  +    for file in config_files:
  +        absolute_path = join(root, file)
  +        if exists(absolute_path):
  +            return absolute_path
  +
  +    print("Config file not found")
  +
  +
  +CONFIG = readConfigFile(get_config_path())
  
verification_info: {"golden_diff": "diff --git a/src/cowrie/core/config.py b/src/cowrie/core/config.py\n--- a/src/cowrie/core/config.py\n+++ b/src/cowrie/core/config.py\n@@ -8,7 +8,8 @@\n from __future__ import absolute_import, division\n \n import configparser\n-import os\n+from os import environ\n+from os.path import abspath, dirname, exists, join\n \n \n def to_environ_key(key):\n@@ -18,15 +19,16 @@\n class EnvironmentConfigParser(configparser.ConfigParser):\n \n     def has_option(self, section, option):\n-        if to_environ_key('_'.join((section, option))) in os.environ:\n+        if to_environ_key('_'.join((section, option))) in environ:\n             return True\n         return super(EnvironmentConfigParser, self).has_option(section, option)\n \n     def get(self, section, option, **kwargs):\n         key = to_environ_key('_'.join((section, option)))\n-        if key in os.environ:\n-            return os.environ[key]\n-        return super(EnvironmentConfigParser, self).get(section, option, **kwargs)\n+        if key in environ:\n+            return environ[key]\n+        return super(EnvironmentConfigParser, self).get(\n+            section, option, **kwargs)\n \n \n def readConfigFile(cfgfile):\n@@ -36,9 +38,26 @@\n     @param cfgfile: filename or array of filenames\n     @return: ConfigParser object\n     \"\"\"\n-    parser = EnvironmentConfigParser(interpolation=configparser.ExtendedInterpolation())\n+    parser = EnvironmentConfigParser(\n+        interpolation=configparser.ExtendedInterpolation())\n     parser.read(cfgfile)\n     return parser\n \n \n-CONFIG = readConfigFile((\"etc/cowrie.cfg.dist\", \"/etc/cowrie/cowrie.cfg\", \"etc/cowrie.cfg\", \"cowrie.cfg\"))\n+def get_config_path():\n+    \"\"\"Get absolute path to the config file\n+    \"\"\"\n+    config_files = [\"etc/cowrie/cowrie.cfg\", \"etc/cowrie.cfg\",\n+                    \"cowrie.cfg\", \"etc/cowrie.cfg.dist\"]\n+    current_path = abspath(dirname(__file__))\n+    root = \"/\".join(current_path.split(\"/\")[:-3])\n+\n+    for file in config_files:\n+        absolute_path = join(root, file)\n+        if exists(absolute_path):\n+            return absolute_path\n+\n+    print(\"Config file not found\")\n+\n+\n+CONFIG = readConfigFile(get_config_path())\n", "issue": "Cowrie not set up for py.test framework\nSo I tried running the test in both python2 and python3. For python2 all the tests were passing but for python3 there was some error.\r\n\r\n```\r\n py.test --cov=cowrie                     \r\n===================================================================================== test session starts =====================================================================================\r\nplatform linux -- Python 3.7.2, pytest-4.2.0, py-1.7.0, pluggy-0.8.1\r\nrootdir: /home/mzfr/dev/cowrie, inifile:\r\nplugins: cov-2.6.1\r\ncollected 3 items / 3 errors                                                                                                                                                                  \r\n\r\n=========================================================================================== ERRORS ============================================================================================\r\n___________________________________________________________________ ERROR collecting src/cowrie/test/test_base_commands.py ____________________________________________________________________\r\n../shell/fs.py:26: in <module>\r\n    PICKLE = pickle.load(open(CONFIG.get('shell', 'filesystem'), 'rb'))\r\n../core/config.py:29: in get\r\n    return super(EnvironmentConfigParser, self).get(section, option, **kwargs)\r\n/usr/lib/python3.7/configparser.py:780: in get\r\n    d = self._unify_values(section, vars)\r\n/usr/lib/python3.7/configparser.py:1146: in _unify_values\r\n    raise NoSectionError(section) from None\r\nE   configparser.NoSectionError: No section: 'shell'\r\n\r\nDuring handling of the above exception, another exception occurred:\r\ntest_base_commands.py:12: in <module>\r\n    from cowrie.shell import protocol\r\n../shell/protocol.py:21: in <module>\r\n    from cowrie.shell import command\r\n../shell/command.py:20: in <module>\r\n    from cowrie.shell import fs\r\n../shell/fs.py:29: in <module>\r\n    exit(2)\r\n/usr/lib/python3.7/_sitebuiltins.py:26: in __call__\r\n    raise SystemExit(code)\r\nE   SystemExit: 2\r\n--------------------------------------------------------------------------------------- Captured stdout ---------------------------------------------------------------------------------------\r\nERROR: Config file not found: etc/cowrie.cfg.dist\r\n________________________________________________________________________ ERROR collecting src/cowrie/test/test_echo.py ________________________________________________________________________\r\n../shell/fs.py:26: in <module>\r\n    PICKLE = pickle.load(open(CONFIG.get('shell', 'filesystem'), 'rb'))\r\n../core/config.py:29: in get\r\n    return super(EnvironmentConfigParser, self).get(section, option, **kwargs)\r\n/usr/lib/python3.7/configparser.py:780: in get\r\n    d = self._unify_values(section, vars)\r\n/usr/lib/python3.7/configparser.py:1146: in _unify_values\r\n    raise NoSectionError(section) from None\r\nE   configparser.NoSectionError: No section: 'shell'\r\n\r\nDuring handling of the above exception, another exception occurred:\r\ntest_echo.py:16: in <module>\r\n    from cowrie.shell import protocol\r\n../shell/protocol.py:21: in <module>\r\n    from cowrie.shell import command\r\n../shell/command.py:20: in <module>\r\n    from cowrie.shell import fs\r\n../shell/fs.py:29: in <module>\r\n    exit(2)\r\n/usr/lib/python3.7/_sitebuiltins.py:26: in __call__\r\n    raise SystemExit(code)\r\nE   SystemExit: 2\r\n--------------------------------------------------------------------------------------- Captured stdout ---------------------------------------------------------------------------------------\r\nERROR: Config file not found: etc/cowrie.cfg.dist\r\n________________________________________________________________________ ERROR collecting src/cowrie/test/test_tftp.py ________________________________________________________________________\r\n../shell/fs.py:26: in <module>\r\n    PICKLE = pickle.load(open(CONFIG.get('shell', 'filesystem'), 'rb'))\r\n../core/config.py:29: in get\r\n    return super(EnvironmentConfigParser, self).get(section, option, **kwargs)\r\n/usr/lib/python3.7/configparser.py:780: in get\r\n    d = self._unify_values(section, vars)\r\n/usr/lib/python3.7/configparser.py:1146: in _unify_values\r\n    raise NoSectionError(section) from None\r\nE   configparser.NoSectionError: No section: 'shell'\r\n\r\nDuring handling of the above exception, another exception occurred:\r\ntest_tftp.py:16: in <module>\r\n    from cowrie.shell import protocol\r\n../shell/protocol.py:21: in <module>\r\n    from cowrie.shell import command\r\n../shell/command.py:20: in <module>\r\n    from cowrie.shell import fs\r\n../shell/fs.py:29: in <module>\r\n    exit(2)\r\n/usr/lib/python3.7/_sitebuiltins.py:26: in __call__\r\n    raise SystemExit(code)\r\nE   SystemExit: 2\r\n--------------------------------------------------------------------------------------- Captured stdout ---------------------------------------------------------------------------------------\r\nERROR: Config file not found: etc/cowrie.cfg.dist\r\n```\n", "before_files": [{"content": "# Copyright (c) 2009-2014 Upi Tamminen <desaster@gmail.com>\n# See the COPYRIGHT file for more information\n\n\"\"\"\nThis module contains ...\n\"\"\"\n\nfrom __future__ import absolute_import, division\n\nimport configparser\nimport os\n\n\ndef to_environ_key(key):\n    return key.upper()\n\n\nclass EnvironmentConfigParser(configparser.ConfigParser):\n\n    def has_option(self, section, option):\n        if to_environ_key('_'.join((section, option))) in os.environ:\n            return True\n        return super(EnvironmentConfigParser, self).has_option(section, option)\n\n    def get(self, section, option, **kwargs):\n        key = to_environ_key('_'.join((section, option)))\n        if key in os.environ:\n            return os.environ[key]\n        return super(EnvironmentConfigParser, self).get(section, option, **kwargs)\n\n\ndef readConfigFile(cfgfile):\n    \"\"\"\n    Read config files and return ConfigParser object\n\n    @param cfgfile: filename or array of filenames\n    @return: ConfigParser object\n    \"\"\"\n    parser = EnvironmentConfigParser(interpolation=configparser.ExtendedInterpolation())\n    parser.read(cfgfile)\n    return parser\n\n\nCONFIG = readConfigFile((\"etc/cowrie.cfg.dist\", \"/etc/cowrie/cowrie.cfg\", \"etc/cowrie.cfg\", \"cowrie.cfg\"))\n", "path": "src/cowrie/core/config.py"}]}