【发布时间】:2017-10-21 13:25:45
【问题描述】:
我正在尝试制作我的第一个程序,我正在使用 GUI 输入自动执行 git push / clone 进程。
"""GUI GIT Program"""
#Import Statements
from tkinter import *
from tkinter import simpledialog
from tkinter import messagebox
import subprocess
from time import sleep
# set up the GUI
root = Tk()
w = Label(root, text="Git Handler")
w.pack()
# Welcome the User
messagebox.showinfo("Welcome","This is a program to automate your Git stuff!")
# solicit input
user_name = simpledialog.askstring("Username:","What is your username?")
password = simpledialog.askstring("Password","What is your password?",show="*")
message_for_push = simpledialog.askstring("Push Message","What's your push message?")
# do stuff with the data
# call(["git","push"])
# sleep (2)
# call([user_name])
# sleep (2)
# call([password])
commands = '''
git push'''
user_name
password
process = subprocess.Popen('/bin/bash', stdin=subprocess.PIPE, stdout=subprocess.PIPE)
out, err = process.communicate(commands.encode('utf-8'))
print(out.decode('utf-8'))
我遇到的问题是 git push 命令执行了,但下一步输入用户名没有,所有后续命令也是如此......有什么想法吗?
【问题讨论】:
标签: python terminal subprocess