#!/usr/bin/env python3 from subprocess import call, DEVNULL PACKAGES = [ "python3-defusedxml", "python3-openssl", "python3-psutil", "python3-requests", "python3-spf", ] def main(): for pkg in PACKAGES: if call( ["/usr/bin/dpkg", "-s", pkg], shell=False, stdout=DEVNULL, stderr=DEVNULL ): result = call( ["/usr/bin/apt", "install", pkg], shell=False, stdout=DEVNULL, stderr=DEVNULL, ) if not result: print("{} install succeeded".format(pkg)) else: print("{} install failed".format(pkg)) else: print("{} already installed".format(pkg)) if __name__ == "__main__": main()