comparison upmana/updatemana.py @ 227:81d0bfd5e800 alpha

Traipse Alpha 'OpenRPG' {100612-00} Traipse is a distribution of OpenRPG that is designed to be easy to setup and go. Traipse also makes it easy for developers to work on code without fear of sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds fixes to the code. 'Ornery-Orc's main goal is to offer more advanced features and enhance the productivity of the user. Update Summary (Preparing to close updates) New Features: New to Map, can re-order Grid, Miniatures, and Whiteboard layer draw order Fixes: Fix to InterParse that was causing an Infernal Loop with Namespace Internal Fix to XML data, removed old Minidom and switched to Element Tree Fix to Server that was causing eternal attempt to find a Server ID, in Register Rooms thread Fix to metaservers.xml file not being created
author sirebral
date Sat, 12 Jun 2010 03:50:37 -0500
parents fa18af3e04b9
children
comparison
equal deleted inserted replaced
182:4b2884f29a72 227:81d0bfd5e800
10 from mercurial import ui, hg, commands, repo, revlog, cmdutil, util 10 from mercurial import ui, hg, commands, repo, revlog, cmdutil, util
11 11
12 class Term2Win(object): 12 class Term2Win(object):
13 # A stdout redirector. Allows the messages from Mercurial to be seen in the Install Window 13 # A stdout redirector. Allows the messages from Mercurial to be seen in the Install Window
14 def write(self, text): 14 def write(self, text):
15 statbar.SetStatusText(text) 15 self.closed = sys.__stdout__.closed
16 wx.Yield() 16 self.flush = sys.__stdout__.flush
17 statbar.SetStatusText(text.replace('\n', ''))
17 sys.__stdout__.write(text) 18 sys.__stdout__.write(text)
18 19
19 class Updater(wx.Panel): 20 class Updater(wx.Panel):
20 def __init__(self, parent, component): 21 def __init__(self, parent, component):
21 wx.Panel.__init__(self, parent) 22 wx.Panel.__init__(self, parent)
22 ### Status Bar ### 23 ### Status Bar ###
23 #statbar.SetStatusText('Select a Package and Update') 24 #statbar.SetStatusText('Select a Package and Update')
24 statbar.SetStatusText('New Status Bar') 25 #statbar.SetStatusText('New Status Bar')
26
27 self.timer = wx.Timer(self, 1)
28 self.count = 0
25 29
26 ### Update Manager 30 ### Update Manager
27 self.ui = ui.ui() 31 self.ui = ui.ui()
28 self.repo = hg.repository(self.ui, ".") 32 self.repo = hg.repository(self.ui, ".")
29 self.c = self.repo.changectx('tip') 33 self.c = self.repo.changectx('tip')
42 self.buttons['no_check'] = wx.CheckBox(self, wx.ID_ANY) 46 self.buttons['no_check'] = wx.CheckBox(self, wx.ID_ANY)
43 self.buttons['advanced'] = wx.Button(self, wx.ID_ANY, "Package Select") 47 self.buttons['advanced'] = wx.Button(self, wx.ID_ANY, "Package Select")
44 self.buttons['update'] = wx.Button(self, wx.ID_ANY, "Update Now") 48 self.buttons['update'] = wx.Button(self, wx.ID_ANY, "Update Now")
45 self.buttons['finish'] = wx.Button(self, wx.ID_ANY, "Finish") 49 self.buttons['finish'] = wx.Button(self, wx.ID_ANY, "Finish")
46 50
47 self.sizer.Add(self.changelog, (0,0), span=(4,1), flag=wx.EXPAND) 51 self.sizer.Add(self.changelog, (0,0), span=(5,1), flag=wx.EXPAND)
48 self.sizer.Add(self.filelist, (0,1), span=(1,3), flag=wx.EXPAND) 52 self.sizer.Add(self.filelist, (0,1), span=(1,3), flag=wx.EXPAND)
49 53
50 self.sizer.Add(self.buttons['progress_bar'], (1,1), span=(1,3), flag=wx.EXPAND) 54 self.sizer.Add(self.buttons['progress_bar'], (1,1), span=(1,3), flag=wx.EXPAND)
51 self.sizer.Add(self.buttons['auto_text'], (2,1)) 55 self.sizer.Add(self.buttons['auto_text'], (2,1))
52 self.sizer.Add(self.buttons['auto_check'], (2,2), flag=wx.EXPAND) 56 self.sizer.Add(self.buttons['auto_check'], (2,2), flag=wx.EXPAND)
53 self.sizer.Add(self.buttons['no_text'], (3,1)) 57 self.sizer.Add(self.buttons['no_text'], (3,1))
54 self.sizer.Add(self.buttons['no_check'], (3,2), flag=wx.EXPAND) 58 self.sizer.Add(self.buttons['no_check'], (3,2), flag=wx.EXPAND)
55 self.sizer.Add(self.buttons['advanced'], (2,3), flag=wx.EXPAND) 59 self.sizer.Add(self.buttons['advanced'], (2,3), flag=wx.EXPAND)
56 self.sizer.Add(self.buttons['update'], (3,3), flag=wx.EXPAND) 60 self.sizer.Add(self.buttons['update'], (3,3), flag=wx.EXPAND)
57 self.sizer.Add(self.buttons['finish'], (4,3), flag=wx.EXPAND) 61 self.sizer.Add(self.buttons['finish'], (4,3), flag=wx.EXPAND)
58 #self.buttons['finish'].Disable() 62 self.buttons['progress_bar'].SetValue(100)
59 self.sizer.AddGrowableCol(0) 63 self.sizer.AddGrowableCol(0)
60 self.sizer.AddGrowableRow(0) 64 self.sizer.AddGrowableRow(0)
61 self.SetSizer(self.sizer) 65 self.SetSizer(self.sizer)
62 self.SetAutoLayout(True) 66 self.SetAutoLayout(True)
63 self.get_package 67 self.get_package
74 self.Bind(wx.EVT_BUTTON, self.Update, self.buttons['update']) 78 self.Bind(wx.EVT_BUTTON, self.Update, self.buttons['update'])
75 self.Bind(wx.EVT_BUTTON, self.Finish, self.buttons['finish']) 79 self.Bind(wx.EVT_BUTTON, self.Finish, self.buttons['finish'])
76 self.Bind(wx.EVT_BUTTON, self.ChooseBranch, self.buttons['advanced']) 80 self.Bind(wx.EVT_BUTTON, self.ChooseBranch, self.buttons['advanced'])
77 self.Bind(wx.EVT_CHECKBOX, self.ToggleAutoUpdate, self.buttons['auto_check']) 81 self.Bind(wx.EVT_CHECKBOX, self.ToggleAutoUpdate, self.buttons['auto_check'])
78 self.Bind(wx.EVT_CHECKBOX, self.ToggleNoUpdate, self.buttons['no_check']) 82 self.Bind(wx.EVT_CHECKBOX, self.ToggleNoUpdate, self.buttons['no_check'])
83 self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer)
84
85 def OnTimer(self, event):
86 statbar.SetStatusText('Checking For Updates')
87 self.count = self.count + 1
88 self.buttons['progress_bar'].SetValue(self.count)
89 if self.count == 100:
90 self.timer.Stop()
91 statbar.SetStatusText('No Updates Available')
92
93 def UpdateCheck(self):
94 self.timer.Start(100)
95 self.count = 3
96 self.buttons['progress_bar'].SetValue(3)
97 try:
98 doUpdate = commands.incoming(self.ui, self.repo,
99 manifest.GetString('default', 'repo', ''),
100 force=True, bundle=False)
101 if doUpdate:
102 statbar.SetStatusText('No Updates Available')
103 self.buttons['progress_bar'].SetValue(100)
104 self.timer.Stop()
105 else:
106 statbar.SetStatusText('Refresh Repo For Updated Source')
107 self.buttons['progress_bar'].SetValue(100)
108 self.timer.Stop()
109 except:
110 statbar.SetStatusText('No Connection Found')
111 self.buttons['progress_bar'].SetValue(100)
112 self.timer.Stop()
113
79 114
80 def ToggleAutoUpdate(self, event): 115 def ToggleAutoUpdate(self, event):
81 if self.buttons['auto_check'].GetValue() == True: 116 if self.buttons['auto_check'].GetValue() == True:
82 if self.buttons['no_check'].GetValue() == True: 117 if self.buttons['no_check'].GetValue() == True:
83 self.buttons['no_check'].SetValue(False) 118 self.buttons['no_check'].SetValue(False)
120 dir1 += ignore.split('/')[gets] + os.sep 155 dir1 += ignore.split('/')[gets] + os.sep
121 gets += 1 156 gets += 1
122 os.removedirs(temp+dir1) 157 os.removedirs(temp+dir1)
123 158
124 def LoadDoc(self): 159 def LoadDoc(self):
125 ignore = open(self.filename) 160 manifest = open(self.filename)
126 self.ignorelist = [] 161 self.ignorelist = []
127 for i in ignore: self.ignorelist.append(str(i [:len(i)-1])) 162 ignore = manifest.readlines()
128 manifest = ignore.readlines() 163 for i in ignore: print i; self.ignorelist.append(str(i[:len(i)-1]))
129 ignore.close() 164 manifest.close()
130 165
131 def Finish(self, evt=None): 166 def Finish(self, evt=None):
132 try: component.get('upmana-win').OnClose(None) 167 component.get('upmana-win').OnClose(None)
133 except Exception, e:
134 print 'Fail', e; exit()
135 168
136 def ChooseBranch(self, evt=None): 169 def ChooseBranch(self, evt=None):
137 dlg = wx.Dialog(self, wx.ID_ANY, "Package Selector", style=wx.DEFAULT_DIALOG_STYLE) 170 dlg = wx.Dialog(self, wx.ID_ANY, "Package Selector", style=wx.DEFAULT_DIALOG_STYLE)
138 if wx.Platform == '__WXMSW__': icon = wx.Icon(dir_struct["icon"]+'d20.ico', wx.BITMAP_TYPE_ICO) 171 if wx.Platform == '__WXMSW__': icon = wx.Icon(dir_struct["icon"]+'d20.ico', wx.BITMAP_TYPE_ICO)
139 else: icon = wx.Icon(dir_struct["icon"]+"d20.xpm", wx.BITMAP_TYPE_XPM ) 172 else: icon = wx.Icon(dir_struct["icon"]+"d20.xpm", wx.BITMAP_TYPE_XPM )
584 os.remove(temp + ignore.split('/')[len(ignore.split('/')) - 1]) 617 os.remove(temp + ignore.split('/')[len(ignore.split('/')) - 1])
585 else: 618 else:
586 dlg.Destroy(); pass 619 dlg.Destroy(); pass
587 620
588 def LoadDoc(self): 621 def LoadDoc(self):
589 ignore = open(self.filename) 622 manifest = open(self.filename)
590 self.ignorelist = [] 623 self.ignorelist = []
591 for i in ignore: self.ignorelist.append(str(i [:len(i)-1])) 624 ignore = manifest.readlines()
592 manifest = ignore.readlines() 625 for i in ignore: print i; self.ignorelist.append(str(i[:len(i)-1]))
593 ignore.close() 626 manifest.close()
594 627
595 def get_packages(self, type=None): 628 def get_packages(self, type=None):
596 #Fixed and ready for Test. Can be cleaner 629 #Can be cleaner
597 self.package_list = [] 630 self.package_list = []
598 b = self.repo.branchtags() 631 b = self.repo.branchtags()
599 heads = dict.fromkeys(self.repo.heads(), 1) #The code below looks superfluous but there is good info inside 632 heads = dict.fromkeys(self.repo.heads(), 1) #The code below looks superfluous but there is good info inside
600 l = [((n in heads), self.repo.changelog.rev(n), n, t) for t, n in b.items()] 633 l = [((n in heads), self.repo.changelog.rev(n), n, t) for t, n in b.items()]
601 l.sort() 634 l.sort()
687 p = wx.Panel(self) 720 p = wx.Panel(self)
688 nb = wx.Notebook(p) 721 nb = wx.Notebook(p)
689 722
690 global statbar 723 global statbar
691 statbar = self.CreateStatusBar() 724 statbar = self.CreateStatusBar()
725 sys.stdout = Term2Win()
692 self.Centre() 726 self.Centre()
693 727
694 # create the page windows as children of the notebook 728 # create the page windows as children of the notebook
695 page1 = Updater(nb, openrpg) 729 self.page1 = Updater(nb, openrpg)
696 page2 = Repos(nb, openrpg) 730 page2 = Repos(nb, openrpg)
697 page3 = Manifest(nb) 731 page3 = Manifest(nb)
698 page4 = Control(nb) 732 page4 = Control(nb)
699 page5 = Help(nb) 733 page5 = Help(nb)
700 734
701 # add the pages to the notebook with the label to show on the tab 735 # add the pages to the notebook with the label to show on the tab
702 nb.AddPage(page1, "Updater") 736 nb.AddPage(self.page1, "Updater")
703 nb.AddPage(page2, "Repos") 737 nb.AddPage(page2, "Repos")
704 nb.AddPage(page3, "Manifest") 738 nb.AddPage(page3, "Manifest")
705 nb.AddPage(page4, "Control") 739 nb.AddPage(page4, "Control")
706 nb.AddPage(page5, 'Help') 740 nb.AddPage(page5, 'Help')
707 741
719 if self.main == False: self.Destroy() 753 if self.main == False: self.Destroy()
720 if self.main == True: self.Hide() 754 if self.main == True: self.Hide()
721 755
722 class updateApp(wx.App): 756 class updateApp(wx.App):
723 def OnInit(self): 757 def OnInit(self):
724 self.main = False 758 self.main = False; self.autoUpdate = False; self.noUpdate = False
725 sys.stdout = Term2Win()
726 logger._set_log_to_console(False) 759 logger._set_log_to_console(False)
727 logger.note("Updater Start") 760 logger.note("Updater Start")
728 component.add('validate', validate) 761 component.add('validate', validate)
729 self.updater = updaterFrame(self, "OpenRPG Update Manager 1.0", 762 self.updater = updaterFrame(self, "OpenRPG Update Manager 1.2",
730 component, manifest, self.main) 763 component, manifest, self.main)
731 if manifest.GetString("updatemana", "auto_update", "") == 'on' and self.main == False: 764 if manifest.GetString("updatemana", "auto_update", "") == 'on' and self.main == False:
732 self.AutoUpdate(); self.OnExit() 765 self.AutoUpdate(); self.OnExit(); self.autoUpdate = True
733 else: pass 766 else: pass
734 if manifest.GetString('updatemana', 'no_update', '') == 'on' and self.main == False: 767 if manifest.GetString('updatemana', 'no_update', '') == 'on' and self.main == False:
735 self.OnExit() 768 self.OnExit(); self.noUpdate = True
736 else: pass 769 else: pass
737 try: 770 if not (self.autoUpdate or self.noUpdate):
738 self.updater.Show() 771 try:
739 self.updater.Fit() 772 self.updater.Show()
740 except: pass 773 self.updater.Fit()
774 if not self.main: self.updater.page1.UpdateCheck()
775 except: pass
741 return True 776 return True
742 777
743 def AutoUpdate(self): 778 def AutoUpdate(self):
744 self.ui = ui.ui() 779 self.ui = ui.ui()
745 self.repo = hg.repository(self.ui, ".") 780 self.repo = hg.repository(self.ui, ".")
746 self.c = self.repo.changectx('tip') 781 self.c = self.repo.changectx('tip')
747 self.current = self.repo.dirstate.branch() 782 self.current = self.repo.dirstate.branch()
748 783
749 capture = manifest.GetString('updaterepo', 'default', '') 784 capture = manifest.GetString('default', 'repo', '')
750 if capture != '': 785 if capture != '':
751 commands.pull(self.ui, self.repo, capture, rev='', update=False, force=True) 786 try: commands.pull(self.ui, self.repo, capture, rev='', update=False, force=True)
787 except:
788 wx.MessageBox('No Connection Found. Skipping Auto Update!', 'Info')
789 return
752 filename = 'ignorelist.txt' 790 filename = 'ignorelist.txt'
753 self.filename = dir_struct["home"] + 'upmana' + os.sep + filename 791 self.filename = dir_struct["home"] + 'upmana' + os.sep + filename
754 component.get('validate').config_file(filename, "default_ignorelist.txt") 792 component.get('validate').config_file(filename, "default_ignorelist.txt")
755 self.mana = self.LoadDoc() 793 self.mana = self.LoadDoc(); ignored = []
756 temp = dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep 794 temp = dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep
757 for ignore in self.ignorelist: 795 for ignore in self.ignorelist:
758 if len(ignore.split('/')) > 1: 796 if len(ignore.split('/')) > 1:
759 gets = 0; dir1 = '' 797 gets = 0; dir1 = ''
760 while gets != len(ignore.split('/'))-1: 798 while gets != len(ignore.split('/'))-1:
761 dir1 += ignore.split('/')[gets] + os.sep 799 dir1 += ignore.split('/')[gets] + os.sep
762 gets += 1 800 gets += 1
763 os.makedirs(temp+dir1) 801 os.makedirs(temp+dir1)
764 shutil.copy(ignore, temp + dir1 + ignore.split('/')[len(ignore.split('/')) - 1]) 802 ignoredfile = temp + dir1 + ignore.split('/')[len(ignore.split('/')) - 1]
803 ignored.append(ignoredfile)
804 shutil.copy(ignore, ignoredfile)
765 hg.clean(self.repo, self.current) 805 hg.clean(self.repo, self.current)
766 for ignore in self.ignorelist: 806 for ignore in self.ignorelist:
767 shutil.copyfile(temp + ignore.split('/')[len(ignore.split('/')) - 1], ignore) 807 shutil.copyfile(ignored.index(ignore), ignore)
768 os.remove(temp + ignore.split('/')[len(ignore.split('/')) - 1]) 808 os.remove(ignored.index(ignore))
769 if len(ignore.split('/')) > 1: 809 if len(ignore.split('/')) > 1:
770 gets = 0; dir1 = '' 810 gets = 0; dir1 = ''
771 while gets != len(ignore.split('/'))-1: 811 while gets != len(ignore.split('/'))-1:
772 dir1 += ignore.split('/')[gets] + os.sep 812 dir1 += ignore.split('/')[gets] + os.sep
773 gets += 1 813 gets += 1
774 os.removedirs(temp+dir1) 814 os.removedirs(temp+dir1)
775 else: wx.MessageBox('No default Rpository set. Skipping Auto Update!', 'Info') 815 else: wx.MessageBox('Default Repo Not Found. Skipping Auto Update!', 'Info')
776 816
777 def LoadDoc(self): 817 def LoadDoc(self):
778 ignore = open(self.filename) 818 manifest = open(self.filename)
779 self.ignorelist = [] 819 self.ignorelist = []
780 for i in ignore: self.ignorelist.append(str(i [:len(i)-1])) 820 ignore = manifest.readlines()
781 manifest = ignore.readlines() 821 for i in ignore: print i; self.ignorelist.append(str(i[:len(i)-1]))
782 ignore.close() 822 manifest.close()
783 823
784 def OnExit(self): 824 def OnExit(self):
785 imported = ['manifest', 'orpg.dirpath', 'orpg.orpgCore', 'orpg.orpg_version', 825 imported = ['manifest', 'orpg.dirpath', 'orpg.orpgCore', 'orpg.orpg_version',
786 'orpg.tools.orpg_log', 'orpg.tools.orpg_log', 'orpg.orpg_xml', 'orpg.dirpath', 826 'orpg.tools.orpg_log', 'orpg.tools.orpg_log', 'orpg.orpg_xml', 'orpg.dirpath',
787 'orpg.dirpath', 'upmana.validate', 'mercurial.ui', 'mercurial.hg', 827 'orpg.dirpath', 'upmana.validate', 'mercurial.ui', 'mercurial.hg',