2016-07-25 24 views
-1

いくつかのパッケージをインストールするために、次のコードを書いています。私はスクリプトが出力にインストールプロセスメッセージを表示しないようにします。パッケージのインストールが完了したら、出力にプロンプ​​トが表示されます。このタスクを実行するには、次のコードをどのように書き直すことができますか。固定UbuntuパッケージのインストールPythonコード

 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. ") 

答えて

0

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) 

     if (subprocess.run(self.command.split(), stdout=DEVNULL, stderr=DEVNULL)): 
      self.color.print_blue("\t[+] Package [{}] Installed".format(str(self.items))) 
     else: 
      self.color.print_red("\t[+] Package [{}] Don't Installed".format(str(self.items))) 

    self.color.print_red("[+] Phase 2 Accomplished.\n") 
関連する問題