comparison upmana/updatemana.py @ 49:b41ea7d28a9e traipse_dev

Final testing! Moving to a WinXP platform for final testing before stable.
author sirebral
date Thu, 06 Aug 2009 09:26:31 -0500
parents 0aeee1992423
children 14d4270d5e5d
comparison
equal deleted inserted replaced
48:0aeee1992423 49:b41ea7d28a9e
49 self.sizer.Add(self.buttons['no_text'], (3,1)) 49 self.sizer.Add(self.buttons['no_text'], (3,1))
50 self.sizer.Add(self.buttons['no_check'], (3,2), flag=wx.EXPAND) 50 self.sizer.Add(self.buttons['no_check'], (3,2), flag=wx.EXPAND)
51 self.sizer.Add(self.buttons['advanced'], (2,3), flag=wx.EXPAND) 51 self.sizer.Add(self.buttons['advanced'], (2,3), flag=wx.EXPAND)
52 self.sizer.Add(self.buttons['update'], (3,3), flag=wx.EXPAND) 52 self.sizer.Add(self.buttons['update'], (3,3), flag=wx.EXPAND)
53 self.sizer.Add(self.buttons['finish'], (4,3), flag=wx.EXPAND) 53 self.sizer.Add(self.buttons['finish'], (4,3), flag=wx.EXPAND)
54 self.buttons['finish'].Disable()
54 self.sizer.AddGrowableCol(0) 55 self.sizer.AddGrowableCol(0)
55 self.sizer.AddGrowableRow(0) 56 self.sizer.AddGrowableRow(0)
56 self.SetSizer(self.sizer) 57 self.SetSizer(self.sizer)
57 self.SetAutoLayout(True) 58 self.SetAutoLayout(True)
58 self.get_package 59 self.get_package
59 60
60 self.current = self.repo.dirstate.branch() 61 self.current = self.repo.dirstate.branch()
61 self.BranchInfo(self.current) 62 self.BranchInfo(self.current)
63
64 if self.manifest.GetString("updatemana", "no_update", "") == 'on': self.buttons['no_check'].SetValue(True)
65 else: self.buttons['no_check'].SetValue(False)
66 if self.manifest.GetString("updatemana", "auto_update", "") == 'on': self.buttons['auto_check'].SetValue(True)
67 else: self.buttons['auto_check'].SetValue(False)
62 68
63 ## Event Handlers 69 ## Event Handlers
64 self.Bind(wx.EVT_BUTTON, self.Update, self.buttons['update']) 70 self.Bind(wx.EVT_BUTTON, self.Update, self.buttons['update'])
65 self.Bind(wx.EVT_BUTTON, self.Finish, self.buttons['finish']) 71 self.Bind(wx.EVT_BUTTON, self.Finish, self.buttons['finish'])
66 self.Bind(wx.EVT_BUTTON, self.ChooseBranch, self.buttons['advanced']) 72 self.Bind(wx.EVT_BUTTON, self.ChooseBranch, self.buttons['advanced'])
67 self.Bind(wx.EVT_CHECKBOX, self.ToggleAutoUpdate, self.buttons['auto_check']) 73 self.Bind(wx.EVT_CHECKBOX, self.ToggleAutoUpdate, self.buttons['auto_check'])
68 self.Bind(wx.EVT_CHECKBOX, self.ToggleNoUpdate, self.buttons['no_check']) 74 self.Bind(wx.EVT_CHECKBOX, self.ToggleNoUpdate, self.buttons['no_check'])
69 75
70 def ToggleAutoUpdate(self, event): 76 def ToggleAutoUpdate(self, event):
71 if self.buttons['auto_check'].GetValue(): 77 if self.buttons['auto_check'].GetValue() == True:
72 if self.buttons['no_check'].GetValue(): 78 if self.buttons['no_check'].GetValue() == True:
73 self.buttons['no_check'].SetValue(False) 79 self.buttons['no_check'].SetValue(False)
74 self.manifest.SetString("updatemana", "no_update", "off") 80 self.manifest.SetString("updatemana", "no_update", "off")
75 self.manifest.SetString("updatemana", "auto_update", "on") 81 self.manifest.SetString("updatemana", "auto_update", "on")
76 else: self.manifest.SetString("updatemana", "auto_update", "off") 82 else: self.manifest.SetString("updatemana", "auto_update", "off")
77 83
78 def ToggleNoUpdate(self, event): 84 def ToggleNoUpdate(self, event):
79 if self.buttons['no_check'].GetValue(): 85 if self.buttons['no_check'].GetValue() == True:
80 if self.buttons['auto_check'].GetValue(): 86 if self.buttons['auto_check'].GetValue() == True:
81 self.buttons['auto_check'].SetValue(False) 87 self.buttons['auto_check'].SetValue(False)
82 self.manifest.SetString("updatemana", "auto_update", "off") 88 self.manifest.SetString("updatemana", "auto_update", "off")
83 self.manifest.SetString("updatemana", "no_update", "on") 89 self.manifest.SetString("updatemana", "no_update", "on")
84 else: self.manifest.SetString("updatemana", "no_update", "off") 90 else: self.manifest.SetString("updatemana", "no_update", "off")
85 91
105 for i in ignore: self.ignorelist.append(str(i [:len(i)-1])) 111 for i in ignore: self.ignorelist.append(str(i [:len(i)-1]))
106 manifest = ignore.readlines() 112 manifest = ignore.readlines()
107 ignore.close() 113 ignore.close()
108 114
109 def Finish(self, evt=None): 115 def Finish(self, evt=None):
110 exit() 116 try: self.parent.Destroy()
117 except:
118 print 'Fail'; exit()
111 119
112 def ChooseBranch(self, evt=None): 120 def ChooseBranch(self, evt=None):
113 dlg = wx.Dialog(self, wx.ID_ANY, "Package Selector", style=wx.DEFAULT_DIALOG_STYLE) 121 dlg = wx.Dialog(self, wx.ID_ANY, "Package Selector", style=wx.DEFAULT_DIALOG_STYLE)
114 if wx.Platform == '__WXMSW__': icon = wx.Icon(self.dir_struct["icon"]+'d20.ico', wx.BITMAP_TYPE_ICO) 122 if wx.Platform == '__WXMSW__': icon = wx.Icon(self.dir_struct["icon"]+'d20.ico', wx.BITMAP_TYPE_ICO)
115 else: icon = wx.Icon(self.dir_struct["icon"]+"d20.xpm", wx.BITMAP_TYPE_XPM ) 123 else: icon = wx.Icon(self.dir_struct["icon"]+"d20.xpm", wx.BITMAP_TYPE_XPM )
391 399
392 def LoadDoc(self): 400 def LoadDoc(self):
393 ignore = open(self.filename) 401 ignore = open(self.filename)
394 ignorelist = [] 402 ignorelist = []
395 for i in ignore: ignorelist.append(str(i [:len(i)-1])) 403 for i in ignore: ignorelist.append(str(i [:len(i)-1]))
404 for i in ignorelist:
405 if self.c.manifest().has_key(i): pass
406 else: self.manifestlist.append(i); self.manifestlist.sort()
396 self.manifestlog.SetCheckedStrings(ignorelist) 407 self.manifestlog.SetCheckedStrings(ignorelist)
397 manifest = ignore.readlines() 408 manifest = ignore.readlines()
398 ignore.close() 409 ignore.close()
399 410
400 class Control(wx.Panel): 411 class Control(wx.Panel):
401 def __init__(self, parent): 412 def __init__(self, parent):
402 wx.Panel.__init__(self, parent) 413 wx.Panel.__init__(self, parent)
403 414
404 415
405 class updaterFrame(wx.Frame): 416 class updaterFrame(wx.Frame):
406 def __init__(self, parent, title, openrpg, manifest): 417 def __init__(self, parent, title, openrpg, manifest, main):
407 wx.Frame.__init__(self, None, wx.ID_ANY, title, size=(700,480), 418 wx.Frame.__init__(self, None, wx.ID_ANY, title, size=(700,480),
408 style=wx.FRAME_NO_TASKBAR | wx.STAY_ON_TOP | wx.DEFAULT_FRAME_STYLE) 419 style=wx.FRAME_NO_TASKBAR | wx.STAY_ON_TOP | wx.DEFAULT_FRAME_STYLE)
409 self.CenterOnScreen() 420 self.CenterOnScreen()
410 421
422 self.main = main
411 ####### Panel Stuff ###### 423 ####### Panel Stuff ######
412 p = wx.Panel(self) 424 p = wx.Panel(self)
413 nb = wx.Notebook(p) 425 nb = wx.Notebook(p)
414 426
415 # create the page windows as children of the notebook 427 # create the page windows as children of the notebook
427 # finally, put the notebook in a sizer for the panel to manage 439 # finally, put the notebook in a sizer for the panel to manage
428 # the layout 440 # the layout
429 sizer = wx.BoxSizer() 441 sizer = wx.BoxSizer()
430 sizer.Add(nb, 1, wx.EXPAND) 442 sizer.Add(nb, 1, wx.EXPAND)
431 p.SetSizer(sizer) 443 p.SetSizer(sizer)
444 self.Bind(wx.EVT_CLOSE, self.OnClose)
445
446 def OnClose(self, event):
447 if self.main == False: self.Destroy()
448 if self.main == True: self.Hide() #self.Hide()
449 #continue
432 450
433 class updateApp(wx.App): 451 class updateApp(wx.App):
434 def OnInit(self): 452 def OnInit(self):
435 self.open_rpg = open_rpg 453 self.open_rpg = open_rpg
454 self.main = False
436 self.log = orpg.tools.orpg_log.orpgLog(orpg.dirpath.dir_struct["user"] + "runlogs/") 455 self.log = orpg.tools.orpg_log.orpgLog(orpg.dirpath.dir_struct["user"] + "runlogs/")
437 self.log.setLogToConsol(False) 456 self.log.setLogToConsol(False)
438 self.log.log("Updater Start", ORPG_NOTE) 457 self.log.log("Updater Start", ORPG_NOTE)
439 self.manifest = manifest.ManifestChanges() 458 self.manifest = manifest.ManifestChanges()
440 self.open_rpg.add_component("log", self.log) 459 self.open_rpg.add_component("log", self.log)
441 self.open_rpg.add_component("xml", orpg.orpg_xml) 460 self.open_rpg.add_component("xml", orpg.orpg_xml)
442 self.open_rpg.add_component("dir_struct", orpg.dirpath.dir_struct) 461 self.open_rpg.add_component("dir_struct", orpg.dirpath.dir_struct)
443 self.validate = orpg.tools.validate.Validate() 462 self.validate = orpg.tools.validate.Validate()
444 self.open_rpg.add_component("validate", self.validate) 463 self.open_rpg.add_component("validate", self.validate)
445 self.updater = updaterFrame(self, "OpenRPG Update Manager Beta 0.6.7", self.open_rpg, self.manifest) 464 self.updater = updaterFrame(self, "OpenRPG Update Manager Beta 0.6.7", self.open_rpg, self.manifest, self.main)
446 if self.manifest.GetString("updatemana", "auto_update", "") == 'on': 465 if self.manifest.GetString("updatemana", "auto_update", "") == 'on' and self.main == False:
447 self.AutoUpdate(); self.OnExit() 466 self.AutoUpdate(); self.OnExit()
448 if self.manifest.GetString('updatemana', 'no_update', '') == 'on': self.OnExit() 467 else: pass
468 if self.manifest.GetString('updatemana', 'no_update', '') == 'on' and self.main == False:
469 print 'no udpate'; self.OnExit()
470 else: pass
449 try: 471 try:
450 self.updater.Show() 472 self.updater.Show()
451 self.SetTopWindow(self.updater) 473 #self.SetTopWindow(self.updater)
452 self.updater.Fit() 474 self.updater.Fit()
453 except: pass 475 except: pass
454 return True 476 return True
455 477
456 def AutoUpdate(self): 478 def AutoUpdate(self):
477 499
478 def OnExit(self): 500 def OnExit(self):
479 imported = ['manifest', 'orpg.dirpath', 'orpg.orpgCore', 'orpg.orpg_version', 'orpg.tools.orpg_log', 'orpg.tools.orpg_log', 'orpg.orpg_xml', 'orpg.dirpath', 'orpg.dirpath', 'orpg.tools.validate', 'mercurial.ui', 'mercurial.hg', 'mercurial.commands', 'mercurial.repo', 'mercurial.revlog', 'mercurial.cmdutil', 'shutil'] 501 imported = ['manifest', 'orpg.dirpath', 'orpg.orpgCore', 'orpg.orpg_version', 'orpg.tools.orpg_log', 'orpg.tools.orpg_log', 'orpg.orpg_xml', 'orpg.dirpath', 'orpg.dirpath', 'orpg.tools.validate', 'mercurial.ui', 'mercurial.hg', 'mercurial.commands', 'mercurial.repo', 'mercurial.revlog', 'mercurial.cmdutil', 'shutil']
480 for name in imported: 502 for name in imported:
481 if name in sys.modules: del sys.modules[name] 503 if name in sys.modules: del sys.modules[name]
504
482 try: self.updater.Destroy() 505 try: self.updater.Destroy()
483 except: pass 506 except: pass