我正在尝试制作一个带有按钮的 PyGtk Gui。当用户按下此按钮时,gnome-terminal
提示用户输入密码。
然后它将为JQuery 片段克隆这个Git 存储库。gedit
然后,它将js.xml
文件复制到/usr/share/gedit/plugins/snippets/js.xml
最后,它强行删除了 Git 存储库。
命令:
gnome-terminal -x sudo git clone git://github.com/pererinha/gedit-snippet-jquery.git && sudo cp -f gedit-snippet-jquery/js.xml /usr/share/gedit/plugins/snippets/js.xml && sudo rm -rf gedit-snippet-jquery
它在我的终端上运行良好。
但是,通过它刚刚打开的 GUI,我添加了我的密码,按 Enter,然后它再次关闭。
我只想将命令运行到第一个&&
这是我的 Python 函数(带有命令):
def on_install_jquery_code_snippet_for_gedit_activate(self, widget):
""" Install Jquery code snippet for Gedit. """
cmd="gnome-terminal -x sudo git clone git://github.com/pererinha/gedit-snippet-jquery.git && sudo cp -f gedit-snippet-jquery/js.xml /usr/share/gedit/plugins/snippets/js.xml && sudo rm -rf gedit-snippet-jquery"
p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT,
close_fds=False)
self.status.set_text(p.stdout.read()) #show response in 'status