Repository: qtile/qtile

Issue:
widget.Pacman needs a non existing file:'checkupdates'
```
2020-03-30 07:09:12,582 ERROR libqtile base.py:worker():L478 problem polling to update widget pacman
Traceback (most recent call last):
  File "/home/parsrch/.local/lib/python3.8/site-packages/libqtile/widget/base.py", line 474, in worker
    text = self.poll()
  File "/home/parsrch/.local/lib/python3.8/site-packages/libqtile/widget/pacman.py", line 49, in poll
    pacman = self.call_process(['checkupdates'])
  File "/home/parsrch/.local/lib/python3.8/site-packages/libqtile/widget/base.py", line 266, in call_process
    output = subprocess.check_output(command, **kwargs)
  File "/usr/lib/python3.8/subprocess.py", line 411, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/lib/python3.8/subprocess.py", line 489, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/lib/python3.8/subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'checkupdates'
```


Discussion:
On Sun, Mar 29, 2020 at 07:42:13PM -0700, parsrch wrote:
> `2020-03-30 07:09:12,582 ERROR libqtile base.py:worker():L478 problem polling to update widget pacman
> Traceback (most recent call last):
>   File "/home/parsrch/.local/lib/python3.8/site-packages/libqtile/widget/base.py", line 474, in worker
>     text = self.poll()
>   File "/home/parsrch/.local/lib/python3.8/site-packages/libqtile/widget/pacman.py", line 49, in poll
>     pacman = self.call_process(['checkupdates'])
>   File "/home/parsrch/.local/lib/python3.8/site-packages/libqtile/widget/base.py", line 266, in call_process
>     output = subprocess.check_output(command, **kwargs)
>   File "/usr/lib/python3.8/subprocess.py", line 411, in check_output
>     return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
>   File "/usr/lib/python3.8/subprocess.py", line 489, in run
>     with Popen(*popenargs, **kwargs) as process:
>   File "/usr/lib/python3.8/subprocess.py", line 854, in __init__
>     self._execute_child(args, executable, preexec_fn, close_fds,
>   File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child
>     raise child_exception_type(errno_num, err_msg, err_filename)
> FileNotFoundError: [Errno 2] No such file or directory: 'checkupdates'`

This doesn't seem like a bug; if you're not on Arch, you won't have
this, so there's no reason to use Arch's package management widget.

> On Sun, Mar 29, 2020 at 07:42:13PM -0700, parsrch wrote: `2020-03-30 07:09:12,582 ERROR libqtile base.py:worker():L478 problem polling to update widget pacman Traceback (most recent call last): File "/home/parsrch/.local/lib/python3.8/site-packages/libqtile/widget/base.py", line 474, in worker text = self.poll() File "/home/parsrch/.local/lib/python3.8/site-packages/libqtile/widget/pacman.py", line 49, in poll pacman = self.call_process(['checkupdates']) File "/home/parsrch/.local/lib/python3.8/site-packages/libqtile/widget/base.py", line 266, in call_process output = subprocess.check_output(command, **kwargs) File "/usr/lib/python3.8/subprocess.py", line 411, in check_output return run(*popenargs, stdout=PIPE, timeout=timeout, check=True, File "/usr/lib/python3.8/subprocess.py", line 489, in run with Popen(*popenargs, **kwargs) as process: File "/usr/lib/python3.8/subprocess.py", line 854, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: 'checkupdates'`
> This doesn't seem like a bug; if you're not on Arch, you won't have this, so there's no reason to use Arch's package management widget.

1-I Use Arch BTW
2-its looking for filename checkupdates instead of check_updates.py which needs to be fixed
It uses `/usr/bin/checkupdates` which is provided by the `pacman-contrib` package. Do you have that installed?
IIRC widget.Pacman is deprecated in favor of widget.CheckUpdates.
Should the deprecation be made more clear? I just played around with the widget, but the documentation doesn't mention it at all. I only noticed it when looking at the code.
I guess we should just remove it, there is a deprecation warning in the code for quite some time now.

Resolving patch:
diff --git a/libqtile/widget/__init__.py b/libqtile/widget/__init__.py
--- a/libqtile/widget/__init__.py
+++ b/libqtile/widget/__init__.py
@@ -76,7 +76,6 @@ def safe_import(module_name, class_name):
 safe_import("clipboard", "Clipboard")
 safe_import("countdown", "Countdown")
 safe_import("tasklist", "TaskList")
-safe_import("pacman", "Pacman")
 safe_import("launchbar", "LaunchBar")
 safe_import("canto", "Canto")
 safe_import("mpriswidget", "Mpris")
diff --git a/libqtile/widget/pacman.py b/libqtile/widget/pacman.py
deleted file mode 100644
--- a/libqtile/widget/pacman.py
+++ /dev/null
@@ -1,56 +0,0 @@
-# -*- coding:utf-8 -*-
-#
-# Copyright (C) 2012, Maximilian Köhl <linuxmaxi@googlemail.com>
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-import subprocess
-
-from libqtile.log_utils import logger
-from libqtile.widget import base
-
-
-class Pacman(base.ThreadedPollText):
-    """Shows number of available updates
-
-    Needs the pacman package manager installed. So will only work in Arch Linux
-    installation.
-    """
-    orientations = base.ORIENTATION_HORIZONTAL
-    defaults = [
-        ('unavailable', 'ffffff', 'Unavailable Color - no updates.'),
-        ('execute', None, 'Command to execute on click'),
-        ('update_interval', 60, "The update interval."),
-    ]
-
-    def __init__(self, **config):
-        logger.warning("Pacman is deprecated, please use CheckUpdates")
-        base.ThreadedPollText.__init__(self, **config)
-        self.add_defaults(Pacman.defaults)
-
-    def draw(self):
-        if self.text == '0':
-            self.layout.colour = self.unavailable
-        else:
-            self.layout.colour = self.foreground
-        base.ThreadedPollText.draw(self)
-
-    def poll(self):
-        pacman = self.call_process(['checkupdates'])
-        return str(len(pacman.splitlines()))
-
-    def button_press(self, x, y, button):
-        base.ThreadedPollText.button_press(self, x, y, button)
-        if button == 1 and self.execute is not None:
-            subprocess.Popen([self.execute], shell=True)


Test patch: