我正在尝试编写我的第一个程序,使用GUI输入自动化git推送/克隆过程。
"""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'))im的问题是git push命令会执行,但下一步输入用户名不会,所有后续命令也会执行……有什么想法吗?
发布于 2017-05-22 10:14:51
我很久以前就遇到过类似的问题,并且能够使用下面的代码片段。
git-clone () {
print "Bitbucket checkout enter bitbucket user/pass."
echo -n "Bitbucket username:"
read bit_user
#echo "Bitbucket pass:"
read -s -p "Bitbucket Password:" bit_pass
su -c "cd /home/latlongo; git clone https://$bit_user:$bit_pass@bitbucket.org/xyz.git -b your_branch" -m $1
}https://stackoverflow.com/questions/44103517
复制相似问题