We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Better logging
Using the built-in python logging module I've made various log levels possible and made the creation of a log file a matter of changing the configuration in debug.py. The python logging module is thread-safe so we can safely replace all `print` calls with calls to `logger`. I only replaced some of them mainly to test the configuration (and there are a lot of `print` calls)

There are some commits in my merge that mention translation files, I'm working on that but didn't mean to include them in this merge. I deleted them but the commit history is already there.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `checkdeps.py`
Content:
```
1 #!/usr/bin/env python2
2 """
3 Check dependendies and give recommendations about how to satisfy them
4 
5 Limitations:
6 
7     * Does not detect whether packages are already installed. Solving this requires writing more of a configuration
8     management system. Or we could switch to an existing one.
9     * Not fully PEP508 compliant. Not slightly. It makes bold assumptions about the simplicity of the contents of
10     EXTRAS_REQUIRE. This is fine because most developers do, too.
11 """
12 
13 import os
14 import sys
15 from distutils.errors import CompileError
16 try:
17     from setuptools.dist import Distribution
18     from setuptools.extension import Extension
19     from setuptools.command.build_ext import build_ext
20     HAVE_SETUPTOOLS = True
21     # another import from setuptools is in setup.py
22     from setup import EXTRAS_REQUIRE
23 except ImportError:
24     HAVE_SETUPTOOLS = False
25     EXTRAS_REQUIRE = []
26 
27 from importlib import import_module
28 
29 from src.depends import detectOS, PACKAGES, PACKAGE_MANAGER
30 
31 
32 COMPILING = {
33     "Debian": "build-essential libssl-dev",
34     "Ubuntu": "build-essential libssl-dev",
35     "Fedora": "gcc-c++ redhat-rpm-config python-devel openssl-devel",
36     "openSUSE": "gcc-c++ libopenssl-devel python-devel",
37     "optional": False,
38 }
39 
40 # OS-specific dependencies for optional components listed in EXTRAS_REQUIRE
41 EXTRAS_REQUIRE_DEPS = {
42     # The values from setup.EXTRAS_REQUIRE
43     'python_prctl': {
44         # The packages needed for this requirement, by OS
45         "OpenBSD": [""],
46         "FreeBSD": [""],
47         "Debian": ["libcap-dev python-prctl"],
48         "Ubuntu": ["libcap-dev python-prctl"],
49         "Ubuntu 12": ["libcap-dev python-prctl"],
50         "openSUSE": [""],
51         "Fedora": ["prctl"],
52         "Guix": [""],
53         "Gentoo": ["dev-python/python-prctl"],
54     },
55 }
56 
57 
58 def detectPrereqs(missing=True):
59     available = []
60     for module in PACKAGES:
61         try:
62             import_module(module)
63             if not missing:
64                 available.append(module)
65         except ImportError:
66             if missing:
67                 available.append(module)
68     return available
69 
70 
71 def prereqToPackages():
72     if not detectPrereqs():
73         return
74     print("%s %s" % (
75         PACKAGE_MANAGER[detectOS()], " ".join(
76             PACKAGES[x][detectOS()] for x in detectPrereqs())))
77 
78 
79 def compilerToPackages():
80     if not detectOS() in COMPILING:
81         return
82     print("%s %s" % (
83         PACKAGE_MANAGER[detectOS.result], COMPILING[detectOS.result]))
84 
85 
86 def testCompiler():
87     if not HAVE_SETUPTOOLS:
88         # silent, we can't test without setuptools
89         return True
90 
91     bitmsghash = Extension(
92         'bitmsghash',
93         sources=['src/bitmsghash/bitmsghash.cpp'],
94         libraries=['pthread', 'crypto'],
95     )
96 
97     dist = Distribution()
98     dist.ext_modules = [bitmsghash]
99     cmd = build_ext(dist)
100     cmd.initialize_options()
101     cmd.finalize_options()
102     cmd.force = True
103     try:
104         cmd.run()
105     except CompileError:
106         return False
107     else:
108         fullPath = os.path.join(cmd.build_lib, cmd.get_ext_filename("bitmsghash"))
109         return os.path.isfile(fullPath)
110 
111 
112 prereqs = detectPrereqs()
113 compiler = testCompiler()
114 
115 if (not compiler or prereqs) and detectOS() in PACKAGE_MANAGER:
116     print(
117         "It looks like you're using %s. "
118         "It is highly recommended to use the package manager\n"
119         "to install the missing dependencies." % detectOS.result)
120 
121 if not compiler:
122     print(
123         "Building the bitmsghash module failed.\n"
124         "You may be missing a C++ compiler and/or the OpenSSL headers.")
125 
126 if prereqs:
127     mandatory = [x for x in prereqs if not PACKAGES[x].get("optional")]
128     optional = [x for x in prereqs if PACKAGES[x].get("optional")]
129     if mandatory:
130         print("Missing mandatory dependencies: %s" % " ".join(mandatory))
131     if optional:
132         print("Missing optional dependencies: %s" % " ".join(optional))
133         for package in optional:
134             print(PACKAGES[package].get('description'))
135 
136 # Install the system dependencies of optional extras_require components
137 OPSYS = detectOS()
138 CMD = PACKAGE_MANAGER[OPSYS] if OPSYS in PACKAGE_MANAGER else 'UNKNOWN_INSTALLER'
139 for lhs, rhs in EXTRAS_REQUIRE.items():
140     if OPSYS is None:
141         break
142     if rhs and any([
143         EXTRAS_REQUIRE_DEPS[x][OPSYS]
144         for x in rhs
145         if x in EXTRAS_REQUIRE_DEPS
146     ]):
147         rhs_cmd = ''.join([
148             CMD,
149             ' ',
150             ' '.join([
151                 ''. join([
152                     xx for xx in EXTRAS_REQUIRE_DEPS[x][OPSYS]
153                 ])
154                 for x in rhs
155                 if x in EXTRAS_REQUIRE_DEPS
156             ]),
157         ])
158         print(
159             "Optional dependency `pip install .[{}]` would require `{}`"
160             " to be run as root".format(lhs, rhs_cmd))
161 
162 if (not compiler or prereqs) and OPSYS in PACKAGE_MANAGER:
163     print("You can install the missing dependencies by running, as root:")
164     if not compiler:
165         compilerToPackages()
166     prereqToPackages()
167     if mandatory:
168         sys.exit(1)
169 else:
170     print("All the dependencies satisfied, you can install PyBitmessage")
171
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/checkdeps.py b/checkdeps.py
--- a/checkdeps.py
+++ b/checkdeps.py
@@ -22,7 +22,7 @@
     from setup import EXTRAS_REQUIRE
 except ImportError:
     HAVE_SETUPTOOLS = False
-    EXTRAS_REQUIRE = []
+    EXTRAS_REQUIRE = {}
 
 from importlib import import_module

{"golden_diff": "diff --git a/checkdeps.py b/checkdeps.py\n--- a/checkdeps.py\n+++ b/checkdeps.py\n@@ -22,7 +22,7 @@\n     from setup import EXTRAS_REQUIRE\n except ImportError:\n     HAVE_SETUPTOOLS = False\n-    EXTRAS_REQUIRE = []\n+    EXTRAS_REQUIRE = {}\n \n from importlib import import_module\n", "issue": "Better logging\nUsing the built-in python logging module I've made various log levels possible and made the creation of a log file a matter of changing the configuration in debug.py. The python logging module is thread-safe so we can safely replace all `print` calls with calls to `logger`. I only replaced some of them mainly to test the configuration (and there are a lot of `print` calls)\n\nThere are some commits in my merge that mention translation files, I'm working on that but didn't mean to include them in this merge. I deleted them but the commit history is already there.\n\n", "before_files": [{"content": "#!/usr/bin/env python2\n\"\"\"\nCheck dependendies and give recommendations about how to satisfy them\n\nLimitations:\n\n    * Does not detect whether packages are already installed. Solving this requires writing more of a configuration\n    management system. Or we could switch to an existing one.\n    * Not fully PEP508 compliant. Not slightly. It makes bold assumptions about the simplicity of the contents of\n    EXTRAS_REQUIRE. This is fine because most developers do, too.\n\"\"\"\n\nimport os\nimport sys\nfrom distutils.errors import CompileError\ntry:\n    from setuptools.dist import Distribution\n    from setuptools.extension import Extension\n    from setuptools.command.build_ext import build_ext\n    HAVE_SETUPTOOLS = True\n    # another import from setuptools is in setup.py\n    from setup import EXTRAS_REQUIRE\nexcept ImportError:\n    HAVE_SETUPTOOLS = False\n    EXTRAS_REQUIRE = []\n\nfrom importlib import import_module\n\nfrom src.depends import detectOS, PACKAGES, PACKAGE_MANAGER\n\n\nCOMPILING = {\n    \"Debian\": \"build-essential libssl-dev\",\n    \"Ubuntu\": \"build-essential libssl-dev\",\n    \"Fedora\": \"gcc-c++ redhat-rpm-config python-devel openssl-devel\",\n    \"openSUSE\": \"gcc-c++ libopenssl-devel python-devel\",\n    \"optional\": False,\n}\n\n# OS-specific dependencies for optional components listed in EXTRAS_REQUIRE\nEXTRAS_REQUIRE_DEPS = {\n    # The values from setup.EXTRAS_REQUIRE\n    'python_prctl': {\n        # The packages needed for this requirement, by OS\n        \"OpenBSD\": [\"\"],\n        \"FreeBSD\": [\"\"],\n        \"Debian\": [\"libcap-dev python-prctl\"],\n        \"Ubuntu\": [\"libcap-dev python-prctl\"],\n        \"Ubuntu 12\": [\"libcap-dev python-prctl\"],\n        \"openSUSE\": [\"\"],\n        \"Fedora\": [\"prctl\"],\n        \"Guix\": [\"\"],\n        \"Gentoo\": [\"dev-python/python-prctl\"],\n    },\n}\n\n\ndef detectPrereqs(missing=True):\n    available = []\n    for module in PACKAGES:\n        try:\n            import_module(module)\n            if not missing:\n                available.append(module)\n        except ImportError:\n            if missing:\n                available.append(module)\n    return available\n\n\ndef prereqToPackages():\n    if not detectPrereqs():\n        return\n    print(\"%s %s\" % (\n        PACKAGE_MANAGER[detectOS()], \" \".join(\n            PACKAGES[x][detectOS()] for x in detectPrereqs())))\n\n\ndef compilerToPackages():\n    if not detectOS() in COMPILING:\n        return\n    print(\"%s %s\" % (\n        PACKAGE_MANAGER[detectOS.result], COMPILING[detectOS.result]))\n\n\ndef testCompiler():\n    if not HAVE_SETUPTOOLS:\n        # silent, we can't test without setuptools\n        return True\n\n    bitmsghash = Extension(\n        'bitmsghash',\n        sources=['src/bitmsghash/bitmsghash.cpp'],\n        libraries=['pthread', 'crypto'],\n    )\n\n    dist = Distribution()\n    dist.ext_modules = [bitmsghash]\n    cmd = build_ext(dist)\n    cmd.initialize_options()\n    cmd.finalize_options()\n    cmd.force = True\n    try:\n        cmd.run()\n    except CompileError:\n        return False\n    else:\n        fullPath = os.path.join(cmd.build_lib, cmd.get_ext_filename(\"bitmsghash\"))\n        return os.path.isfile(fullPath)\n\n\nprereqs = detectPrereqs()\ncompiler = testCompiler()\n\nif (not compiler or prereqs) and detectOS() in PACKAGE_MANAGER:\n    print(\n        \"It looks like you're using %s. \"\n        \"It is highly recommended to use the package manager\\n\"\n        \"to install the missing dependencies.\" % detectOS.result)\n\nif not compiler:\n    print(\n        \"Building the bitmsghash module failed.\\n\"\n        \"You may be missing a C++ compiler and/or the OpenSSL headers.\")\n\nif prereqs:\n    mandatory = [x for x in prereqs if not PACKAGES[x].get(\"optional\")]\n    optional = [x for x in prereqs if PACKAGES[x].get(\"optional\")]\n    if mandatory:\n        print(\"Missing mandatory dependencies: %s\" % \" \".join(mandatory))\n    if optional:\n        print(\"Missing optional dependencies: %s\" % \" \".join(optional))\n        for package in optional:\n            print(PACKAGES[package].get('description'))\n\n# Install the system dependencies of optional extras_require components\nOPSYS = detectOS()\nCMD = PACKAGE_MANAGER[OPSYS] if OPSYS in PACKAGE_MANAGER else 'UNKNOWN_INSTALLER'\nfor lhs, rhs in EXTRAS_REQUIRE.items():\n    if OPSYS is None:\n        break\n    if rhs and any([\n        EXTRAS_REQUIRE_DEPS[x][OPSYS]\n        for x in rhs\n        if x in EXTRAS_REQUIRE_DEPS\n    ]):\n        rhs_cmd = ''.join([\n            CMD,\n            ' ',\n            ' '.join([\n                ''. join([\n                    xx for xx in EXTRAS_REQUIRE_DEPS[x][OPSYS]\n                ])\n                for x in rhs\n                if x in EXTRAS_REQUIRE_DEPS\n            ]),\n        ])\n        print(\n            \"Optional dependency `pip install .[{}]` would require `{}`\"\n            \" to be run as root\".format(lhs, rhs_cmd))\n\nif (not compiler or prereqs) and OPSYS in PACKAGE_MANAGER:\n    print(\"You can install the missing dependencies by running, as root:\")\n    if not compiler:\n        compilerToPackages()\n    prereqToPackages()\n    if mandatory:\n        sys.exit(1)\nelse:\n    print(\"All the dependencies satisfied, you can install PyBitmessage\")\n", "path": "checkdeps.py"}], "after_files": [{"content": "#!/usr/bin/env python2\n\"\"\"\nCheck dependendies and give recommendations about how to satisfy them\n\nLimitations:\n\n    * Does not detect whether packages are already installed. Solving this requires writing more of a configuration\n    management system. Or we could switch to an existing one.\n    * Not fully PEP508 compliant. Not slightly. It makes bold assumptions about the simplicity of the contents of\n    EXTRAS_REQUIRE. This is fine because most developers do, too.\n\"\"\"\n\nimport os\nimport sys\nfrom distutils.errors import CompileError\ntry:\n    from setuptools.dist import Distribution\n    from setuptools.extension import Extension\n    from setuptools.command.build_ext import build_ext\n    HAVE_SETUPTOOLS = True\n    # another import from setuptools is in setup.py\n    from setup import EXTRAS_REQUIRE\nexcept ImportError:\n    HAVE_SETUPTOOLS = False\n    EXTRAS_REQUIRE = {}\n\nfrom importlib import import_module\n\nfrom src.depends import detectOS, PACKAGES, PACKAGE_MANAGER\n\n\nCOMPILING = {\n    \"Debian\": \"build-essential libssl-dev\",\n    \"Ubuntu\": \"build-essential libssl-dev\",\n    \"Fedora\": \"gcc-c++ redhat-rpm-config python-devel openssl-devel\",\n    \"openSUSE\": \"gcc-c++ libopenssl-devel python-devel\",\n    \"optional\": False,\n}\n\n# OS-specific dependencies for optional components listed in EXTRAS_REQUIRE\nEXTRAS_REQUIRE_DEPS = {\n    # The values from setup.EXTRAS_REQUIRE\n    'python_prctl': {\n        # The packages needed for this requirement, by OS\n        \"OpenBSD\": [\"\"],\n        \"FreeBSD\": [\"\"],\n        \"Debian\": [\"libcap-dev python-prctl\"],\n        \"Ubuntu\": [\"libcap-dev python-prctl\"],\n        \"Ubuntu 12\": [\"libcap-dev python-prctl\"],\n        \"openSUSE\": [\"\"],\n        \"Fedora\": [\"prctl\"],\n        \"Guix\": [\"\"],\n        \"Gentoo\": [\"dev-python/python-prctl\"],\n    },\n}\n\n\ndef detectPrereqs(missing=True):\n    available = []\n    for module in PACKAGES:\n        try:\n            import_module(module)\n            if not missing:\n                available.append(module)\n        except ImportError:\n            if missing:\n                available.append(module)\n    return available\n\n\ndef prereqToPackages():\n    if not detectPrereqs():\n        return\n    print(\"%s %s\" % (\n        PACKAGE_MANAGER[detectOS()], \" \".join(\n            PACKAGES[x][detectOS()] for x in detectPrereqs())))\n\n\ndef compilerToPackages():\n    if not detectOS() in COMPILING:\n        return\n    print(\"%s %s\" % (\n        PACKAGE_MANAGER[detectOS.result], COMPILING[detectOS.result]))\n\n\ndef testCompiler():\n    if not HAVE_SETUPTOOLS:\n        # silent, we can't test without setuptools\n        return True\n\n    bitmsghash = Extension(\n        'bitmsghash',\n        sources=['src/bitmsghash/bitmsghash.cpp'],\n        libraries=['pthread', 'crypto'],\n    )\n\n    dist = Distribution()\n    dist.ext_modules = [bitmsghash]\n    cmd = build_ext(dist)\n    cmd.initialize_options()\n    cmd.finalize_options()\n    cmd.force = True\n    try:\n        cmd.run()\n    except CompileError:\n        return False\n    else:\n        fullPath = os.path.join(cmd.build_lib, cmd.get_ext_filename(\"bitmsghash\"))\n        return os.path.isfile(fullPath)\n\n\nprereqs = detectPrereqs()\ncompiler = testCompiler()\n\nif (not compiler or prereqs) and detectOS() in PACKAGE_MANAGER:\n    print(\n        \"It looks like you're using %s. \"\n        \"It is highly recommended to use the package manager\\n\"\n        \"to install the missing dependencies.\" % detectOS.result)\n\nif not compiler:\n    print(\n        \"Building the bitmsghash module failed.\\n\"\n        \"You may be missing a C++ compiler and/or the OpenSSL headers.\")\n\nif prereqs:\n    mandatory = [x for x in prereqs if not PACKAGES[x].get(\"optional\")]\n    optional = [x for x in prereqs if PACKAGES[x].get(\"optional\")]\n    if mandatory:\n        print(\"Missing mandatory dependencies: %s\" % \" \".join(mandatory))\n    if optional:\n        print(\"Missing optional dependencies: %s\" % \" \".join(optional))\n        for package in optional:\n            print(PACKAGES[package].get('description'))\n\n# Install the system dependencies of optional extras_require components\nOPSYS = detectOS()\nCMD = PACKAGE_MANAGER[OPSYS] if OPSYS in PACKAGE_MANAGER else 'UNKNOWN_INSTALLER'\nfor lhs, rhs in EXTRAS_REQUIRE.items():\n    if OPSYS is None:\n        break\n    if rhs and any([\n        EXTRAS_REQUIRE_DEPS[x][OPSYS]\n        for x in rhs\n        if x in EXTRAS_REQUIRE_DEPS\n    ]):\n        rhs_cmd = ''.join([\n            CMD,\n            ' ',\n            ' '.join([\n                ''. join([\n                    xx for xx in EXTRAS_REQUIRE_DEPS[x][OPSYS]\n                ])\n                for x in rhs\n                if x in EXTRAS_REQUIRE_DEPS\n            ]),\n        ])\n        print(\n            \"Optional dependency `pip install .[{}]` would require `{}`\"\n            \" to be run as root\".format(lhs, rhs_cmd))\n\nif (not compiler or prereqs) and OPSYS in PACKAGE_MANAGER:\n    print(\"You can install the missing dependencies by running, as root:\")\n    if not compiler:\n        compilerToPackages()\n    prereqToPackages()\n    if mandatory:\n        sys.exit(1)\nelse:\n    print(\"All the dependencies satisfied, you can install PyBitmessage\")\n", "path": "checkdeps.py"}]}