| 1 |
ninoborges |
8 |
"""
|
| 2 |
|
|
|
| 3 |
|
|
MCP_Upgrade_Utility
|
| 4 |
|
|
|
| 5 |
|
|
Created by
|
| 6 |
|
|
Emanuel Borges
|
| 7 |
|
|
05.20.2011
|
| 8 |
|
|
|
| 9 |
|
|
This stand alone program will upgrade the MCP for that user when they execute it.
|
| 10 |
|
|
|
| 11 |
|
|
"""
|
| 12 |
|
|
|
| 13 |
|
|
import wx,os,shutil
|
| 14 |
|
|
|
| 15 |
|
|
class MyFrame(wx.Frame):
|
| 16 |
|
|
def __init__(self, parent, ID, title, pos=wx.DefaultPosition):
|
| 17 |
|
|
wx.Frame.__init__(self, parent, ID, title, pos, size =(550,580))
|
| 18 |
|
|
|
| 19 |
|
|
|
| 20 |
|
|
class Upgrade():
|
| 21 |
|
|
def __init__(self):
|
| 22 |
|
|
self.local_MCPPath = r'c:\program files\MCP'
|
| 23 |
|
|
self.remote_MCPPath = r'\\bstads01\app\manny\MCP\Prgs'
|
| 24 |
|
|
self.programList = ['distMCP_Case_Scan','MCP_AddCase_UI','MCP_CopyUp_Request_UI','MCP_ViewEdit_UI']
|
| 25 |
|
|
def DoUpgradeMCP(self):
|
| 26 |
|
|
pass_Fail_Status = True
|
| 27 |
|
|
if os.path.exists(self.local_MCPPath):
|
| 28 |
|
|
print "\nMCP: Preparing directories...\n"
|
| 29 |
|
|
for program in self.programList:
|
| 30 |
|
|
for file in os.listdir(os.path.join(self.local_MCPPath,program)):
|
| 31 |
|
|
if file == 'Settings.sys':
|
| 32 |
|
|
pass
|
| 33 |
|
|
else:
|
| 34 |
|
|
if os.path.isfile(os.path.join(os.path.join(self.local_MCPPath,program),file)):
|
| 35 |
|
|
os.remove(os.path.join(os.path.join(self.local_MCPPath,program),file))
|
| 36 |
|
|
elif file == 'support':
|
| 37 |
|
|
for genFile in os.listdir(os.path.join(os.path.join(os.path.join(self.local_MCPPath,program),file),'gen_py')):
|
| 38 |
|
|
os.remove(os.path.join(os.path.join(os.path.join(os.path.join(self.local_MCPPath,program),file),'gen_py'),genFile))
|
| 39 |
|
|
os.rmdir(os.path.join(os.path.join(os.path.join(self.local_MCPPath,program),file),'gen_py'))
|
| 40 |
|
|
os.rmdir(os.path.join(os.path.join(self.local_MCPPath,program),file))
|
| 41 |
|
|
else:
|
| 42 |
|
|
print "MCP: ERROR -- an error has occurred. Please call Manny"
|
| 43 |
|
|
pass_Fail_Status = False
|
| 44 |
|
|
else:
|
| 45 |
|
|
pass_Fail_Status = False
|
| 46 |
|
|
|
| 47 |
|
|
if pass_Fail_Status:
|
| 48 |
|
|
for program in self.programList:
|
| 49 |
|
|
print"MCP: Now upgrading %s..."% program
|
| 50 |
|
|
for file in os.listdir(os.path.join(self.remote_MCPPath, program)):
|
| 51 |
|
|
if os.path.isfile(os.path.join(os.path.join(self.remote_MCPPath, program),file)):
|
| 52 |
|
|
#print 'yep'
|
| 53 |
|
|
shutil.copy2(os.path.join(os.path.join(self.remote_MCPPath, program),file),os.path.join(self.local_MCPPath, program))
|
| 54 |
|
|
else:
|
| 55 |
|
|
shutil.copytree(os.path.join(os.path.join(self.remote_MCPPath, program),file),os.path.join(os.path.join(self.local_MCPPath, program),file))
|
| 56 |
|
|
#print 'nope'
|
| 57 |
|
|
print "MCP: %s upgraded.\n"% program
|
| 58 |
|
|
|
| 59 |
|
|
return pass_Fail_Status
|
| 60 |
|
|
|
| 61 |
|
|
|
| 62 |
|
|
|
| 63 |
|
|
|
| 64 |
|
|
|
| 65 |
|
|
class MyApp(wx.App):
|
| 66 |
|
|
def OnInit(self):
|
| 67 |
|
|
diag = wx.MessageDialog(None, "MCP: This program will update your version of the MCP to the latest version.", "MCP: Upgrade Utility v1.0",wx.OK|wx.CANCEL, wx.DefaultPosition)
|
| 68 |
|
|
#diag.ShowModal()
|
| 69 |
|
|
if diag.ShowModal() == wx.ID_OK:
|
| 70 |
|
|
diag.Destroy()
|
| 71 |
|
|
proc = Upgrade()
|
| 72 |
|
|
pass_Fail_Status = proc.DoUpgradeMCP()
|
| 73 |
|
|
if pass_Fail_Status:
|
| 74 |
|
|
finishedDiag = wx.MessageDialog(None, "MCP: Your install is now on the latest version.\n\nEND OF LINE.", "MCP: Upgrade Utility",wx.OK, wx.DefaultPosition)
|
| 75 |
|
|
else:
|
| 76 |
|
|
finishedDiag = wx.MessageDialog(None, "MCP: A error occurred durring your install. Please call Manny.\n\nEND OF LINE.", "MCP: Upgrade Utility",wx.OK, wx.DefaultPosition)
|
| 77 |
|
|
finishedDiag.ShowModal()
|
| 78 |
|
|
#self.frame = MyFrame(None, -1, "MCP Upgrade Utility")
|
| 79 |
|
|
#self.frame.Show(True)
|
| 80 |
|
|
#self.SetTopWindow(self.frame)
|
| 81 |
|
|
return True
|
| 82 |
|
|
else:
|
| 83 |
|
|
return False
|
| 84 |
|
|
|
| 85 |
|
|
|
| 86 |
|
|
|
| 87 |
|
|
if __name__ == '__main__':
|
| 88 |
|
|
app = MyApp(0)
|
| 89 |
|
|
app.MainLoop() |