def LongTask(self):
return_msg = None
return_code = None
reboot = False
# Checking if System is connected through VPN
if check_vpn and vpn_connected(arch=arch):
dlg_msg = _(u"WPKG-GP Client detected a active VPN Connection using Cisco Anyconnect.\n"
u"This could result in slow upgrade progress and updates for the AnyConnect\n"
u"Software will be blocked.\n"
u"Continue?")
dlg = wx.MessageDialog(self, dlg_msg, app_name, wx.YES_NO | wx.YES_DEFAULT | wx.ICON_INFORMATION)
if dlg.ShowModal() == wx.ID_NO:
# Canceled by user because of active VPN Connection
return_msg = 'WPKG process start canceled by user.' # Make translate able?
return 400, return_msg, None
# LONG TASK is the PipeConnection to the WPKG-GP Windows Service
self.running = True
msg = 'ExecuteNoReboot'
try:
pipeHandle = CreateFile("\\\\.\\pipe\\WPKG", GENERIC_READ|GENERIC_WRITE, 0, None, OPEN_EXISTING, 0, None)
except pywintypes.error, (n, f, e):
# print "Error when generating pipe handle: %s" % e
# Can't connect to pipe error, probably service not running
return_msg = u"Error: WPKG-GP Service not running"
return 208, return_msg, None
SetNamedPipeHandleState(pipeHandle, PIPE_READMODE_MESSAGE, None, None)
WriteFile(pipeHandle, msg)
while 1:
try:
(hr, readmsg) = ReadFile(pipeHandle, 512)
out = readmsg[4:].decode('utf-8') #Strip 3 digit status code, decode characters
status_code = int(readmsg[:3])
if status_code < 102:
# default status code for pipe updates
percentage = getPercentage(out)
wx.CallAfter(self.update_box.SetValue, out)
wx.CallAfter(self.gauge.SetValue, percentage)
elif status_code > 300:
# reboot necessary
reboot = True
elif status_code > 200:
# possible error
return_code = status_code
return_msg = out
except win32api.error as exc:
if exc.winerror == winerror.ERROR_PIPE_BUSY:
win32api.Sleep(5000)
print 'Pipe Busy Error'
continue
break
return return_code, return_msg, reboot
评论列表
文章目录