def update_pigrow_click(self, e):
#reads button lable for check if update or install is required
if self.update_pigrow_btn.GetLabel() == "update pigrow":
do_upgrade = True
#checks to determine best git merge stratergy
if self.update_type == "clean":
git_command = "git -C ~/Pigrow/ pull"
elif self.update_type == "merge":
print("WARNING WARNING _ THIS CODE IS VERY MUCH IN THE TESTING PHASE")
print("if you're doing odd things it's very likely to mess up!")
#this can cause odd confusions which requires use of 'git rebase'
#reokace command line question with dialog box
question = raw_input("merge using default, ours or theirs?")
if question == "ours":
git_command = "git -C ~/Pigrow/ pull --strategy=ours" #if we've changed a file it ignores the remote updated one
elif question == "theirs":
#often needs to commit or stash changes before working
git_command = "git -C ~/Pigrow/ pull -s recursive -X theirs" #removes any changes made locally and replaces file with remote updated one
elif question == "default":
git_command = "git -C ~/Pigrow/ pull"
else:
print("not an option, calling the whole thing off...")
do_upgrade = False
#runs the git pull command using the selected stratergy
if do_upgrade == True:
dbox = wx.MessageDialog(self, "Are you sure you want to upgrade this pigrow?", "update pigrow?", wx.OK | wx.CANCEL | wx.ICON_QUESTION)
answer = dbox.ShowModal()
dbox.Destroy()
#if user said ok then upload file to pi
if (answer == wx.ID_OK):
try:
stdin, stdout, stderr = ssh.exec_command(git_command)
responce = stdout.read().strip()
error = stderr.read()
print responce
if len(error) > 0:
print 'error:' + str(error)
system_info_pnl.sys_pigrow_update.SetLabel("--UPDATED--")
except Exception as e:
print("ooops! " + str(e))
system_info_pnl.sys_pigrow_update.SetLabel("--UPDATE ERROR--")
elif self.update_pigrow_btn.GetLabel() == "install pigrow":
print("Downloading Pigrow code onto Pi")
out, error = MainApp.localfiles_ctrl_pannel.run_on_pi("git clone https://github.com/Pragmatismo/Pigrow ~/Pigrow/")
print out, error
system_info_pnl.sys_pigrow_update.SetLabel("--NEW INSTALL--")
print(" -- Installing software on pigrow ")
out, error = MainApp.localfiles_ctrl_pannel.run_on_pi("~/Pigrow/scripts/config/install.py")
print out, error
评论列表
文章目录