prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  widget.CheckUpdates on Fedora: show the correct number of updates
  widget.CheckUpdates on Fedora shows -2 updates when no updates found.
  
  Excerpt from my config.py:
  ```
  widget.CheckUpdates(
                       distro='Fedora',
                       display_format='  {updates} updates',
                       colour_have_updates=colors[3],
                       no_update_string='  no update',
                       update_interval=1800,
                       colour_no_updates=colors[5],
                       background=colors[8],
                       ),
  ```
  # Qtile version
  0.17.1dev
  # distro
  Fedora 34
  
  </issue>
  <code>
  [start of libqtile/widget/check_updates.py]
  1 # Copyright (c) 2015 Ali Mousavi
  2 #
  3 # Permission is hereby granted, free of charge, to any person obtaining a copy
  4 # of this software and associated documentation files (the "Software"), to deal
  5 # in the Software without restriction, including without limitation the rights
  6 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7 # copies of the Software, and to permit persons to whom the Software is
  8 # furnished to do so, subject to the following conditions:
  9 #
  10 # The above copyright notice and this permission notice shall be included in
  11 # all copies or substantial portions of the Software.
  12 #
  13 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  19 # SOFTWARE.
  20 
  21 import os
  22 from subprocess import CalledProcessError, Popen
  23 
  24 from libqtile.log_utils import logger
  25 from libqtile.widget import base
  26 
  27 
  28 class CheckUpdates(base.ThreadPoolText):
  29     """Shows number of pending updates in different unix systems"""
  30     orientations = base.ORIENTATION_HORIZONTAL
  31     defaults = [
  32         ("distro", "Arch", "Name of your distribution"),
  33         ("custom_command", None, "Custom shell command for checking updates (counts the lines of the output)"),
  34         ("custom_command_modify", (lambda x: x), "Lambda function to modify line count from custom_command"),
  35         ("update_interval", 60, "Update interval in seconds."),
  36         ('execute', None, 'Command to execute on click'),
  37         ("display_format", "Updates: {updates}", "Display format if updates available"),
  38         ("colour_no_updates", "ffffff", "Colour when there's no updates."),
  39         ("colour_have_updates", "ffffff", "Colour when there are updates."),
  40         ("restart_indicator", "", "Indicator to represent reboot is required. (Ubuntu only)"),
  41         ("no_update_string", "", "String to display if no updates available")
  42     ]
  43 
  44     def __init__(self, **config):
  45         base.ThreadPoolText.__init__(self, "", **config)
  46         self.add_defaults(CheckUpdates.defaults)
  47 
  48         # Helpful to have this as a variable as we can shorten it for testing
  49         self.execute_polling_interval = 1
  50 
  51         # format: "Distro": ("cmd", "number of lines to subtract from output")
  52         self.cmd_dict = {"Arch": ("pacman -Qu", 0),
  53                          "Arch_checkupdates": ("checkupdates", 0),
  54                          "Arch_Sup": ("pacman -Sup", 1),
  55                          "Arch_yay": ("yay -Qu", 0),
  56                          "Debian": ("apt-show-versions -u -b", 0),
  57                          "Ubuntu": ("aptitude search ~U", 0),
  58                          "Fedora": ("dnf list updates", 3),
  59                          "FreeBSD": ("pkg_version -I -l '<'", 0),
  60                          "Mandriva": ("urpmq --auto-select", 0)
  61                          }
  62 
  63         if self.custom_command:
  64             # Use custom_command
  65             self.cmd = self.custom_command
  66 
  67         else:
  68             # Check if distro name is valid.
  69             try:
  70                 self.cmd = self.cmd_dict[self.distro][0]
  71                 self.custom_command_modify = (lambda x: x - self.cmd_dict[self.distro][1])
  72             except KeyError:
  73                 distros = sorted(self.cmd_dict.keys())
  74                 logger.error(self.distro + ' is not a valid distro name. ' +
  75                              'Use one of the list: ' + str(distros) + '.')
  76                 self.cmd = None
  77 
  78         if self.execute:
  79             self.add_callbacks({'Button1': self.do_execute})
  80 
  81     def _check_updates(self):
  82         # type: () -> str
  83         try:
  84             updates = self.call_process(self.cmd, shell=True)
  85         except CalledProcessError:
  86             updates = ""
  87         num_updates = self.custom_command_modify(len(updates.splitlines()))
  88 
  89         if num_updates == 0:
  90             self.layout.colour = self.colour_no_updates
  91             return self.no_update_string
  92         num_updates = str(num_updates)
  93 
  94         if self.restart_indicator and os.path.exists('/var/run/reboot-required'):
  95             num_updates += self.restart_indicator
  96 
  97         self.layout.colour = self.colour_have_updates
  98         return self.display_format.format(**{"updates": num_updates})
  99 
  100     def poll(self):
  101         # type: () -> str
  102         if not self.cmd:
  103             return "N/A"
  104         return self._check_updates()
  105 
  106     def do_execute(self):
  107         self._process = Popen(self.execute, shell=True)
  108         self.timeout_add(self.execute_polling_interval, self._refresh_count)
  109 
  110     def _refresh_count(self):
  111         if self._process.poll() is None:
  112             self.timeout_add(self.execute_polling_interval, self._refresh_count)
  113 
  114         else:
  115             self.timer_setup()
  116
  [end of libqtile/widget/check_updates.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/libqtile/widget/check_updates.py b/libqtile/widget/check_updates.py
  --- a/libqtile/widget/check_updates.py
  +++ b/libqtile/widget/check_updates.py
  @@ -55,7 +55,7 @@
                            "Arch_yay": ("yay -Qu", 0),
                            "Debian": ("apt-show-versions -u -b", 0),
                            "Ubuntu": ("aptitude search ~U", 0),
  -                         "Fedora": ("dnf list updates", 3),
  +                         "Fedora": ("dnf list updates -q", 1),
                            "FreeBSD": ("pkg_version -I -l '<'", 0),
                            "Mandriva": ("urpmq --auto-select", 0)
                            }
  @@ -86,6 +86,8 @@
               updates = ""
           num_updates = self.custom_command_modify(len(updates.splitlines()))
   
  +        if num_updates < 0:
  +            num_updates = 0
           if num_updates == 0:
               self.layout.colour = self.colour_no_updates
               return self.no_update_string
  
verification_info: {"golden_diff": "diff --git a/libqtile/widget/check_updates.py b/libqtile/widget/check_updates.py\n--- a/libqtile/widget/check_updates.py\n+++ b/libqtile/widget/check_updates.py\n@@ -55,7 +55,7 @@\n                          \"Arch_yay\": (\"yay -Qu\", 0),\n                          \"Debian\": (\"apt-show-versions -u -b\", 0),\n                          \"Ubuntu\": (\"aptitude search ~U\", 0),\n-                         \"Fedora\": (\"dnf list updates\", 3),\n+                         \"Fedora\": (\"dnf list updates -q\", 1),\n                          \"FreeBSD\": (\"pkg_version -I -l '<'\", 0),\n                          \"Mandriva\": (\"urpmq --auto-select\", 0)\n                          }\n@@ -86,6 +86,8 @@\n             updates = \"\"\n         num_updates = self.custom_command_modify(len(updates.splitlines()))\n \n+        if num_updates < 0:\n+            num_updates = 0\n         if num_updates == 0:\n             self.layout.colour = self.colour_no_updates\n             return self.no_update_string\n", "issue": "widget.CheckUpdates on Fedora: show the correct number of updates\nwidget.CheckUpdates on Fedora shows -2 updates when no updates found.\r\n\r\nExcerpt from my config.py:\r\n```\r\nwidget.CheckUpdates(\r\n                     distro='Fedora',\r\n                     display_format='  {updates} updates',\r\n                     colour_have_updates=colors[3],\r\n                     no_update_string='  no update',\r\n                     update_interval=1800,\r\n                     colour_no_updates=colors[5],\r\n                     background=colors[8],\r\n                     ),\r\n```\r\n# Qtile version\r\n0.17.1dev\r\n# distro\r\nFedora 34\n", "before_files": [{"content": "# Copyright (c) 2015 Ali Mousavi\n#\n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n#\n# The above copyright notice and this permission notice shall be included in\n# all copies or substantial portions of the Software.\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\nimport os\nfrom subprocess import CalledProcessError, Popen\n\nfrom libqtile.log_utils import logger\nfrom libqtile.widget import base\n\n\nclass CheckUpdates(base.ThreadPoolText):\n    \"\"\"Shows number of pending updates in different unix systems\"\"\"\n    orientations = base.ORIENTATION_HORIZONTAL\n    defaults = [\n        (\"distro\", \"Arch\", \"Name of your distribution\"),\n        (\"custom_command\", None, \"Custom shell command for checking updates (counts the lines of the output)\"),\n        (\"custom_command_modify\", (lambda x: x), \"Lambda function to modify line count from custom_command\"),\n        (\"update_interval\", 60, \"Update interval in seconds.\"),\n        ('execute', None, 'Command to execute on click'),\n        (\"display_format\", \"Updates: {updates}\", \"Display format if updates available\"),\n        (\"colour_no_updates\", \"ffffff\", \"Colour when there's no updates.\"),\n        (\"colour_have_updates\", \"ffffff\", \"Colour when there are updates.\"),\n        (\"restart_indicator\", \"\", \"Indicator to represent reboot is required. (Ubuntu only)\"),\n        (\"no_update_string\", \"\", \"String to display if no updates available\")\n    ]\n\n    def __init__(self, **config):\n        base.ThreadPoolText.__init__(self, \"\", **config)\n        self.add_defaults(CheckUpdates.defaults)\n\n        # Helpful to have this as a variable as we can shorten it for testing\n        self.execute_polling_interval = 1\n\n        # format: \"Distro\": (\"cmd\", \"number of lines to subtract from output\")\n        self.cmd_dict = {\"Arch\": (\"pacman -Qu\", 0),\n                         \"Arch_checkupdates\": (\"checkupdates\", 0),\n                         \"Arch_Sup\": (\"pacman -Sup\", 1),\n                         \"Arch_yay\": (\"yay -Qu\", 0),\n                         \"Debian\": (\"apt-show-versions -u -b\", 0),\n                         \"Ubuntu\": (\"aptitude search ~U\", 0),\n                         \"Fedora\": (\"dnf list updates\", 3),\n                         \"FreeBSD\": (\"pkg_version -I -l '<'\", 0),\n                         \"Mandriva\": (\"urpmq --auto-select\", 0)\n                         }\n\n        if self.custom_command:\n            # Use custom_command\n            self.cmd = self.custom_command\n\n        else:\n            # Check if distro name is valid.\n            try:\n                self.cmd = self.cmd_dict[self.distro][0]\n                self.custom_command_modify = (lambda x: x - self.cmd_dict[self.distro][1])\n            except KeyError:\n                distros = sorted(self.cmd_dict.keys())\n                logger.error(self.distro + ' is not a valid distro name. ' +\n                             'Use one of the list: ' + str(distros) + '.')\n                self.cmd = None\n\n        if self.execute:\n            self.add_callbacks({'Button1': self.do_execute})\n\n    def _check_updates(self):\n        # type: () -> str\n        try:\n            updates = self.call_process(self.cmd, shell=True)\n        except CalledProcessError:\n            updates = \"\"\n        num_updates = self.custom_command_modify(len(updates.splitlines()))\n\n        if num_updates == 0:\n            self.layout.colour = self.colour_no_updates\n            return self.no_update_string\n        num_updates = str(num_updates)\n\n        if self.restart_indicator and os.path.exists('/var/run/reboot-required'):\n            num_updates += self.restart_indicator\n\n        self.layout.colour = self.colour_have_updates\n        return self.display_format.format(**{\"updates\": num_updates})\n\n    def poll(self):\n        # type: () -> str\n        if not self.cmd:\n            return \"N/A\"\n        return self._check_updates()\n\n    def do_execute(self):\n        self._process = Popen(self.execute, shell=True)\n        self.timeout_add(self.execute_polling_interval, self._refresh_count)\n\n    def _refresh_count(self):\n        if self._process.poll() is None:\n            self.timeout_add(self.execute_polling_interval, self._refresh_count)\n\n        else:\n            self.timer_setup()\n", "path": "libqtile/widget/check_updates.py"}]}