-1
我已經編寫了下面的代碼來安裝一些包。我不希望腳本在輸出中顯示安裝過程消息。當完成一個包的安裝時,我只需要在輸出中打印一條提示。我如何重寫下面的代碼來完成這項任務。通過Python安裝Ubuntu包代碼
def package_installation(self):
self.apt = "apt install -y "
self.packages = "python-pip python-sqlalchemy mongodb python-bson python-dpkt python-jinja2 python-magic python-gridfs python-libvirt python-bottle python-pefile python-chardet git build-essential autoconf automake libtool dh-autoreconf libcurl4-gnutls-dev libmagic-dev python-dev tcpdump libcap2-bin virtualbox dkms python-pyrex"
self.color.print_green("[+] Phase 2 : Installation of the ubuntu packages is starting:")
for self.items in self.packages.split():
self.command = str(self.apt) + str(self.items)
subprocess.run(self.command.split())
self.color.print_blue("\t[+] Package [{}] Installed".format(str(self.items)))
self.color.print_green("[+] Phase 2 Accomplished. ")