We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Vispy Linux Error ( division by zero)
When I try to tun the vispy on linux I get the following error:

```
from vispy.plot import Fig
f = Fig()

/lib/python2.7/site-packages/vispy/util/dpi/_linux.pyc in <lambda>(x_px, y_px, x_mm, y_mm)
     49     from_xrandr = _get_dpi_from(
     50         'xrandr', r'(\d+)x(\d+).*?(\d+)mm x (\d+)mm',
---> 51         lambda x_px, y_px, x_mm, y_mm: 25.4 * (x_px / x_mm + y_px / y_mm) / 2)
     52     if from_xrandr is not None:
     53         return from_xrandr
```

ZeroDivisionError: float division by zero


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `vispy/util/dpi/_linux.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 # -----------------------------------------------------------------------------
3 # Copyright (c) Vispy Development Team. All Rights Reserved.
4 # Distributed under the (new) BSD License. See LICENSE.txt for more info.
5 # -----------------------------------------------------------------------------
6 
7 import os
8 import re
9 from subprocess import CalledProcessError
10 
11 from ..logs import logger
12 from ..wrappers import run_subprocess
13 
14 
15 def _get_dpi_from(cmd, pattern, func):
16     """Match pattern against the output of func, passing the results as
17     floats to func.  If anything fails, return None.
18     """
19     try:
20         out, _ = run_subprocess([cmd])
21     except (OSError, CalledProcessError):
22         pass
23     else:
24         match = re.search(pattern, out)
25         if match:
26             return func(*map(float, match.groups()))
27 
28 
29 def get_dpi(raise_error=True):
30     """Get screen DPI from the OS
31 
32     Parameters
33     ----------
34     raise_error : bool
35         If True, raise an error if DPI could not be determined.
36 
37     Returns
38     -------
39     dpi : float
40         Dots per inch of the primary screen.
41     """
42     # If we are running without an X server (e.g. OSMesa), use a fixed DPI
43     if 'DISPLAY' not in os.environ:
44         return 96.
45 
46     from_xdpyinfo = _get_dpi_from(
47         'xdpyinfo', r'(\d+)x(\d+) dots per inch',
48         lambda x_dpi, y_dpi: (x_dpi + y_dpi) / 2)
49     if from_xdpyinfo is not None:
50         return from_xdpyinfo
51 
52     from_xrandr = _get_dpi_from(
53         'xrandr', r'(\d+)x(\d+).*?(\d+)mm x (\d+)mm',
54         lambda x_px, y_px, x_mm, y_mm: 25.4 * (x_px / x_mm + y_px / y_mm) / 2)
55     if from_xrandr is not None:
56         return from_xrandr
57     if raise_error:
58         raise RuntimeError('could not determine DPI')
59     else:
60         logger.warning('could not determine DPI')
61     return 96
62
```
--- 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/vispy/util/dpi/_linux.py b/vispy/util/dpi/_linux.py
--- a/vispy/util/dpi/_linux.py
+++ b/vispy/util/dpi/_linux.py
@@ -26,6 +26,14 @@
             return func(*map(float, match.groups()))
 
 
+def _xrandr_calc(x_px, y_px, x_mm, y_mm):
+    if x_mm == 0 or y_mm == 0:
+        logger.warning("'xrandr' output has screen dimension of 0mm, " +
+                       "can't compute proper DPI")
+        return 96.
+    return 25.4 * (x_px / x_mm + y_px / y_mm) / 2
+
+
 def get_dpi(raise_error=True):
     """Get screen DPI from the OS
 
@@ -51,7 +59,7 @@
 
     from_xrandr = _get_dpi_from(
         'xrandr', r'(\d+)x(\d+).*?(\d+)mm x (\d+)mm',
-        lambda x_px, y_px, x_mm, y_mm: 25.4 * (x_px / x_mm + y_px / y_mm) / 2)
+        _xrandr_calc)
     if from_xrandr is not None:
         return from_xrandr
     if raise_error:

{"golden_diff": "diff --git a/vispy/util/dpi/_linux.py b/vispy/util/dpi/_linux.py\n--- a/vispy/util/dpi/_linux.py\n+++ b/vispy/util/dpi/_linux.py\n@@ -26,6 +26,14 @@\n             return func(*map(float, match.groups()))\n \n \n+def _xrandr_calc(x_px, y_px, x_mm, y_mm):\n+    if x_mm == 0 or y_mm == 0:\n+        logger.warning(\"'xrandr' output has screen dimension of 0mm, \" +\n+                       \"can't compute proper DPI\")\n+        return 96.\n+    return 25.4 * (x_px / x_mm + y_px / y_mm) / 2\n+\n+\n def get_dpi(raise_error=True):\n     \"\"\"Get screen DPI from the OS\n \n@@ -51,7 +59,7 @@\n \n     from_xrandr = _get_dpi_from(\n         'xrandr', r'(\\d+)x(\\d+).*?(\\d+)mm x (\\d+)mm',\n-        lambda x_px, y_px, x_mm, y_mm: 25.4 * (x_px / x_mm + y_px / y_mm) / 2)\n+        _xrandr_calc)\n     if from_xrandr is not None:\n         return from_xrandr\n     if raise_error:\n", "issue": "Vispy Linux Error ( division by zero)\nWhen I try to tun the vispy on linux I get the following error:\n\n```\nfrom vispy.plot import Fig\nf = Fig()\n\n/lib/python2.7/site-packages/vispy/util/dpi/_linux.pyc in <lambda>(x_px, y_px, x_mm, y_mm)\n     49     from_xrandr = _get_dpi_from(\n     50         'xrandr', r'(\\d+)x(\\d+).*?(\\d+)mm x (\\d+)mm',\n---> 51         lambda x_px, y_px, x_mm, y_mm: 25.4 * (x_px / x_mm + y_px / y_mm) / 2)\n     52     if from_xrandr is not None:\n     53         return from_xrandr\n```\n\nZeroDivisionError: float division by zero\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n# -----------------------------------------------------------------------------\n# Copyright (c) Vispy Development Team. All Rights Reserved.\n# Distributed under the (new) BSD License. See LICENSE.txt for more info.\n# -----------------------------------------------------------------------------\n\nimport os\nimport re\nfrom subprocess import CalledProcessError\n\nfrom ..logs import logger\nfrom ..wrappers import run_subprocess\n\n\ndef _get_dpi_from(cmd, pattern, func):\n    \"\"\"Match pattern against the output of func, passing the results as\n    floats to func.  If anything fails, return None.\n    \"\"\"\n    try:\n        out, _ = run_subprocess([cmd])\n    except (OSError, CalledProcessError):\n        pass\n    else:\n        match = re.search(pattern, out)\n        if match:\n            return func(*map(float, match.groups()))\n\n\ndef get_dpi(raise_error=True):\n    \"\"\"Get screen DPI from the OS\n\n    Parameters\n    ----------\n    raise_error : bool\n        If True, raise an error if DPI could not be determined.\n\n    Returns\n    -------\n    dpi : float\n        Dots per inch of the primary screen.\n    \"\"\"\n    # If we are running without an X server (e.g. OSMesa), use a fixed DPI\n    if 'DISPLAY' not in os.environ:\n        return 96.\n\n    from_xdpyinfo = _get_dpi_from(\n        'xdpyinfo', r'(\\d+)x(\\d+) dots per inch',\n        lambda x_dpi, y_dpi: (x_dpi + y_dpi) / 2)\n    if from_xdpyinfo is not None:\n        return from_xdpyinfo\n\n    from_xrandr = _get_dpi_from(\n        'xrandr', r'(\\d+)x(\\d+).*?(\\d+)mm x (\\d+)mm',\n        lambda x_px, y_px, x_mm, y_mm: 25.4 * (x_px / x_mm + y_px / y_mm) / 2)\n    if from_xrandr is not None:\n        return from_xrandr\n    if raise_error:\n        raise RuntimeError('could not determine DPI')\n    else:\n        logger.warning('could not determine DPI')\n    return 96\n", "path": "vispy/util/dpi/_linux.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n# -----------------------------------------------------------------------------\n# Copyright (c) Vispy Development Team. All Rights Reserved.\n# Distributed under the (new) BSD License. See LICENSE.txt for more info.\n# -----------------------------------------------------------------------------\n\nimport os\nimport re\nfrom subprocess import CalledProcessError\n\nfrom ..logs import logger\nfrom ..wrappers import run_subprocess\n\n\ndef _get_dpi_from(cmd, pattern, func):\n    \"\"\"Match pattern against the output of func, passing the results as\n    floats to func.  If anything fails, return None.\n    \"\"\"\n    try:\n        out, _ = run_subprocess([cmd])\n    except (OSError, CalledProcessError):\n        pass\n    else:\n        match = re.search(pattern, out)\n        if match:\n            return func(*map(float, match.groups()))\n\n\ndef _xrandr_calc(x_px, y_px, x_mm, y_mm):\n    if x_mm == 0 or y_mm == 0:\n        logger.warning(\"'xrandr' output has screen dimension of 0mm, \" +\n                       \"can't compute proper DPI\")\n        return 96.\n    return 25.4 * (x_px / x_mm + y_px / y_mm) / 2\n\n\ndef get_dpi(raise_error=True):\n    \"\"\"Get screen DPI from the OS\n\n    Parameters\n    ----------\n    raise_error : bool\n        If True, raise an error if DPI could not be determined.\n\n    Returns\n    -------\n    dpi : float\n        Dots per inch of the primary screen.\n    \"\"\"\n    # If we are running without an X server (e.g. OSMesa), use a fixed DPI\n    if 'DISPLAY' not in os.environ:\n        return 96.\n\n    from_xdpyinfo = _get_dpi_from(\n        'xdpyinfo', r'(\\d+)x(\\d+) dots per inch',\n        lambda x_dpi, y_dpi: (x_dpi + y_dpi) / 2)\n    if from_xdpyinfo is not None:\n        return from_xdpyinfo\n\n    from_xrandr = _get_dpi_from(\n        'xrandr', r'(\\d+)x(\\d+).*?(\\d+)mm x (\\d+)mm',\n        _xrandr_calc)\n    if from_xrandr is not None:\n        return from_xrandr\n    if raise_error:\n        raise RuntimeError('could not determine DPI')\n    else:\n        logger.warning('could not determine DPI')\n    return 96\n", "path": "vispy/util/dpi/_linux.py"}]}