annotate upmana/updatemana.py @ 18:97265586402b ornery-orc

Traipse 'OpenRPG' {090827-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: Update Manager is now in version 0.8. While not every button works, users can now browse the different revisions and their different changesets. The code has been refined some with feature from Core added to it. A Crash report is now created if the users software crashes. Update Manager has been moved to the Traipse Suite menu item, and a Debug Console as been added as well.
author sirebral
date Thu, 27 Aug 2009 01:04:43 -0500
parents 265b987cce4f
children 8b168989c344
rev   line source
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
1 import wx
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
2 import sys
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
3 import os #just .sep maybe
14
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
4 import manifest
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
5 import shutil
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
6
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
7 from orpg.orpgCore import component
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
8 from orpg.dirpath import dir_struct
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
9 from orpg.tools.orpg_log import logger, crash
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
10 from orpg.tools.decorators import debugging
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
11 from upmana.validate import validate
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
12 from orpg.dirpath import dir_struct
17
265b987cce4f Traipse 'OpenRPG' {090813-00}
sirebral
parents: 16
diff changeset
13 from mercurial import ui, hg, commands, repo, revlog, cmdutil, util
14
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
14
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
15
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
16 class Updater(wx.Panel):
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
17 @debugging
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
18 def __init__(self, parent, component, manifest):
14
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
19 wx.Panel.__init__(self, parent)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
20
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
21 ### Update Manager
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
22 self.ui = ui.ui()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
23 self.repo = hg.repository(self.ui, ".")
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
24 self.c = self.repo.changectx('tip')
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
25 self.manifest = manifest
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
26 self.parent = parent
14
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
27 self.SetBackgroundColour(wx.WHITE)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
28 self.sizer = wx.GridBagSizer(hgap=1, vgap=1)
17
265b987cce4f Traipse 'OpenRPG' {090813-00}
sirebral
parents: 16
diff changeset
29 self.changelog = wx.TextCtrl(self, wx.ID_ANY, size=(325, -1), style=wx.TE_MULTILINE | wx.TE_READONLY)
265b987cce4f Traipse 'OpenRPG' {090813-00}
sirebral
parents: 16
diff changeset
30 self.filelist = wx.TextCtrl(self, wx.ID_ANY, size=(275, 300), style=wx.TE_MULTILINE | wx.TE_READONLY)
14
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
31 self.buttons = {}
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
32 self.buttons['progress_bar'] = wx.Gauge(self, wx.ID_ANY, 100)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
33 self.buttons['auto_text'] = wx.StaticText(self, wx.ID_ANY, "Auto Update")
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
34 self.buttons['auto_check'] = wx.CheckBox(self, wx.ID_ANY)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
35 self.buttons['no_text'] = wx.StaticText(self, wx.ID_ANY, "No Update")
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
36 self.buttons['no_check'] = wx.CheckBox(self, wx.ID_ANY)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
37 self.buttons['advanced'] = wx.Button(self, wx.ID_ANY, "Package Select")
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
38 self.buttons['update'] = wx.Button(self, wx.ID_ANY, "Update Now")
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
39 self.buttons['finish'] = wx.Button(self, wx.ID_ANY, "Finish")
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
40
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
41 self.sizer.Add(self.changelog, (0,0), span=(4,1), flag=wx.EXPAND)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
42 self.sizer.Add(self.filelist, (0,1), span=(1,3), flag=wx.EXPAND)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
43
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
44 self.sizer.Add(self.buttons['progress_bar'], (1,1), span=(1,3), flag=wx.EXPAND)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
45 self.sizer.Add(self.buttons['auto_text'], (2,1))
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
46 self.sizer.Add(self.buttons['auto_check'], (2,2), flag=wx.EXPAND)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
47 self.sizer.Add(self.buttons['no_text'], (3,1))
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
48 self.sizer.Add(self.buttons['no_check'], (3,2), flag=wx.EXPAND)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
49 self.sizer.Add(self.buttons['advanced'], (2,3), flag=wx.EXPAND)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
50 self.sizer.Add(self.buttons['update'], (3,3), flag=wx.EXPAND)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
51 self.sizer.Add(self.buttons['finish'], (4,3), flag=wx.EXPAND)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
52 self.buttons['finish'].Disable()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
53 self.sizer.AddGrowableCol(0)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
54 self.sizer.AddGrowableRow(0)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
55 self.SetSizer(self.sizer)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
56 self.SetAutoLayout(True)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
57 self.get_package
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
58
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
59 self.current = self.repo.dirstate.branch()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
60 self.BranchInfo(self.current)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
61
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
62 if self.manifest.GetString("updatemana", "no_update", "") == 'on': self.buttons['no_check'].SetValue(True)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
63 else: self.buttons['no_check'].SetValue(False)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
64 if self.manifest.GetString("updatemana", "auto_update", "") == 'on': self.buttons['auto_check'].SetValue(True)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
65 else: self.buttons['auto_check'].SetValue(False)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
66
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
67 ## Event Handlers
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
68 self.Bind(wx.EVT_BUTTON, self.Update, self.buttons['update'])
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
69 self.Bind(wx.EVT_BUTTON, self.Finish, self.buttons['finish'])
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
70 self.Bind(wx.EVT_BUTTON, self.ChooseBranch, self.buttons['advanced'])
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
71 self.Bind(wx.EVT_CHECKBOX, self.ToggleAutoUpdate, self.buttons['auto_check'])
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
72 self.Bind(wx.EVT_CHECKBOX, self.ToggleNoUpdate, self.buttons['no_check'])
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
73
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
74 def ToggleAutoUpdate(self, event):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
75 if self.buttons['auto_check'].GetValue() == True:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
76 if self.buttons['no_check'].GetValue() == True:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
77 self.buttons['no_check'].SetValue(False)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
78 self.manifest.SetString("updatemana", "no_update", "off")
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
79 self.manifest.SetString("updatemana", "auto_update", "on")
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
80 else: self.manifest.SetString("updatemana", "auto_update", "off")
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
81
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
82 def ToggleNoUpdate(self, event):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
83 if self.buttons['no_check'].GetValue() == True:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
84 if self.buttons['auto_check'].GetValue() == True:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
85 self.buttons['auto_check'].SetValue(False)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
86 self.manifest.SetString("updatemana", "auto_update", "off")
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
87 self.manifest.SetString("updatemana", "no_update", "on")
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
88 else: self.manifest.SetString("updatemana", "no_update", "off")
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
89
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
90 def Update(self, evt=None):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
91 self.ui = ui.ui()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
92 self.repo = hg.repository(self.ui, ".")
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
93 self.c = self.repo.changectx('tip')
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
94 filename = 'ignorelist.txt'
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
95 self.filename = dir_struct["home"] + 'upmana' + os.sep + filename
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
96 component.get('validate').config_file(filename, "default_ignorelist.txt")
14
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
97 self.mana = self.LoadDoc()
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
98 temp = dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep
14
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
99 for ignore in self.ignorelist:
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
100 shutil.copy(ignore, temp + ignore.split('/')[len(ignore.split('/')) - 1])
14
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
101 hg.clean(self.repo, self.current)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
102 for ignore in self.ignorelist:
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
103 shutil.copyfile(temp + ignore.split('/')[len(ignore.split('/')) - 1], ignore)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
104 os.remove(temp + ignore.split('/')[len(ignore.split('/')) - 1])
14
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
105
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
106 def LoadDoc(self):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
107 ignore = open(self.filename)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
108 self.ignorelist = []
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
109 for i in ignore: self.ignorelist.append(str(i [:len(i)-1]))
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
110 manifest = ignore.readlines()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
111 ignore.close()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
112
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
113 def Finish(self, evt=None):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
114 try: self.parent.Destroy()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
115 except:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
116 print 'Fail'; exit()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
117
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
118 def ChooseBranch(self, evt=None):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
119 dlg = wx.Dialog(self, wx.ID_ANY, "Package Selector", style=wx.DEFAULT_DIALOG_STYLE)
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
120 if wx.Platform == '__WXMSW__': icon = wx.Icon(dir_struct["icon"]+'d20.ico', wx.BITMAP_TYPE_ICO)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
121 else: icon = wx.Icon(dir_struct["icon"]+"d20.xpm", wx.BITMAP_TYPE_XPM )
14
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
122 dlg.SetIcon(icon)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
123
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
124 self.ui = ui.ui()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
125 self.repo = hg.repository(self.ui, ".")
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
126 self.c = self.repo.changectx('tip')
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
127
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
128 dlgsizer = wx.GridBagSizer(hgap=1, vgap=1)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
129 Yes = wx.Button( dlg, wx.ID_OK, "Ok" )
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
130 Yes.SetDefault()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
131 rgroup = wx.RadioButton(dlg, wx.ID_ANY, "group_start", style=wx.RB_GROUP)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
132 rgroup.Hide()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
133
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
134 self.get_packages()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
135 if self.package_list == None: return
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
136 types = self.package_list
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
137 row=0; col=0
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
138 self.current = self.repo.dirstate.branch()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
139 self.package_type = self.current
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
140 self.btnlist = {}; self.btn = {}
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
141 self.id = 1
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
142
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
143 for t in types:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
144 self.btnName = str(t)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
145 self.btn[self.id] = wx.RadioButton(dlg, wx.ID_ANY, str(t), name=self.btnName)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
146 if self.btnName == self.current: self.btn[self.id].SetValue(True)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
147 self.btnlist[self.id] = self.btnName
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
148 dlgsizer.Add(self.btn[self.id], (row, col))
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
149 col += 1; self.id += 1
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
150 if col == 3: row += 1; col = 0
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
151
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
152 dlgsizer.Add(Yes, (row+1,col/2))
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
153 dlgsizer.AddGrowableCol(0)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
154 dlgsizer.AddGrowableRow(0)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
155 dlg.SetAutoLayout( True )
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
156 dlg.SetSizer( dlgsizer )
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
157 dlgsizer.Fit( dlg )
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
158 dlg.Centre()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
159 dlg.Bind(wx.EVT_RADIOBUTTON, self.PackageSet)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
160 if dlg.ShowModal(): dlg.Destroy()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
161
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
162 def PackageSet(self, event):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
163 for btn in self.btn:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
164 if self.btn[btn].GetValue() == True: self.current = self.btnlist[btn]
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
165
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
166 branches = self.repo.branchtags()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
167 heads = dict.fromkeys(self.repo.heads(), 1)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
168 l = [((n in heads), self.repo.changelog.rev(n), n, t) for t, n in branches.items()]
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
169
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
170 if self.current != type:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
171 heads = dict.fromkeys(self.repo.heads(), self.repo.branchtags())
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
172 branches = dict.copy(self.repo.branchtags())
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
173 self.BranchInfo(self.current)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
174
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
175 def BranchInfo(self, branch):
17
265b987cce4f Traipse 'OpenRPG' {090813-00}
sirebral
parents: 16
diff changeset
176 cs = self.repo.changectx( self.current ).changeset()
14
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
177 self.changelog.SetValue('')
17
265b987cce4f Traipse 'OpenRPG' {090813-00}
sirebral
parents: 16
diff changeset
178 changelog = cs[4]
14
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
179 self.changelog.AppendText(changelog + '\n')
17
265b987cce4f Traipse 'OpenRPG' {090813-00}
sirebral
parents: 16
diff changeset
180 self.filelist.SetValue('')
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
181 self.filelist.AppendText("Currently selected branch: " + branch + "\n\nAuthor: "+cs[1]+"\n\n")
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
182 self.filelist.AppendText("Files Modified (in update): \n")
17
265b987cce4f Traipse 'OpenRPG' {090813-00}
sirebral
parents: 16
diff changeset
183 for f in cs[3]: self.filelist.AppendText(f+"\n")
14
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
184
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
185 def get_packages(self, type=None):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
186 #Fixed and ready for Test. Can be cleaner
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
187 self.package_list = []
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
188 b = self.repo.branchtags()
17
265b987cce4f Traipse 'OpenRPG' {090813-00}
sirebral
parents: 16
diff changeset
189 heads = dict.fromkeys(self.repo.heads(), 1) #The code below looks superfluous but there is good info inside
14
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
190 l = [((n in heads), self.repo.changelog.rev(n), n, t) for t, n in b.items()]
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
191 l.sort()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
192 l.reverse()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
193 for ishead, r, n, t in l: self.package_list.append(t)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
194
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
195 def get_package(self):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
196 self.get_packages()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
197 if self.package_list == None: return None
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
198 return None
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
199
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
200 class Repos(wx.Panel):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
201 def __init__(self, parent, openrpg, manifest):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
202 wx.Panel.__init__(self, parent)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
203
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
204 ### Update Manager
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
205 self.ui = ui.ui()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
206 self.r = hg.repository(self.ui, ".")
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
207 self.c = self.r.changectx('tip')
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
208
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
209 #mainpanel = self
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
210 self.openrpg = openrpg
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
211 self.manifest = manifest
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
212 self.buttons = {}
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
213 self.texts = {}
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
214
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
215 ## Section Sizers (with frame edges and text captions)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
216 self.box_sizers = {}
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
217 self.box_sizers["newbutton"] = wx.StaticBox(self, -1)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
218
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
219 ## Layout Sizers
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
220 self.sizers = {}
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
221 self.sizers["main"] = wx.GridBagSizer(hgap=2, vgap=2)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
222 self.sizers["button"] = wx.GridBagSizer(hgap=2, vgap=2)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
223
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
224 #Button Layout
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
225 self.sizers["newbutton"] = wx.StaticBoxSizer(self.box_sizers["newbutton"], wx.VERTICAL)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
226 self.sizers["newrepo_layout"] = wx.FlexGridSizer(rows=1, cols=2, hgap=2, vgap=5)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
227 empty = wx.StaticText(self, -1, "")
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
228 reponame = wx.StaticText(self, -1, "Name:")
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
229 self.texts["reponame"] = wx.TextCtrl(self, -1, '')
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
230 self.buttons['addrepo'] = wx.Button(self, wx.ID_NEW)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
231
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
232 ##Build Button
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
233 self.sizers["newrepo_layout"].Add(self.buttons['addrepo'], -1, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
234 self.sizers["newrepo_layout"].Add(empty, -1)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
235 self.sizers["newrepo_layout"].Add(reponame, -1, wx.ALIGN_CENTER|wx.ALIGN_CENTER_VERTICAL|wx.ALL)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
236 self.sizers["newrepo_layout"].Add(self.texts["reponame"], -1, wx.EXPAND)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
237 self.sizers["newrepo_layout"].AddGrowableCol(1)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
238 self.sizers["newbutton"].Add(self.sizers["newrepo_layout"], -1, wx.EXPAND)
17
265b987cce4f Traipse 'OpenRPG' {090813-00}
sirebral
parents: 16
diff changeset
239
14
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
240 #Repo List Panel
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
241 self.repopanel = wx.ScrolledWindow(self)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
242 self.repopanel.SetScrollbars(20,20,55,40)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
243 self.repopanel.Scroll(50,10)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
244 self.box_sizers["repolist"] = wx.StaticBox(self.repopanel, -1, "Current Repo List")
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
245 self.sizers["repolist"] = wx.StaticBoxSizer(self.box_sizers["repolist"], wx.VERTICAL)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
246 self.sizers["repo"] = wx.GridBagSizer(hgap=2, vgap=2)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
247 self.sizers["repolist_layout"] = wx.FlexGridSizer(rows=1, cols=1, hgap=2, vgap=5)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
248 self.manifest = manifest
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
249
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
250 self.NewRepoList(None)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
251 self.BuildRepoList(None)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
252
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
253 self.sizers["repolist_layout"].AddGrowableCol(0)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
254 self.sizers["repolist"].Add(self.sizers["repolist_layout"], -1, wx.EXPAND)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
255 self.sizers["repo"].Add(self.sizers["repolist"], (0,0), flag=wx.EXPAND)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
256 self.sizers["repo"].AddGrowableCol(0)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
257 self.sizers['repo'].AddGrowableRow(0)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
258 self.sizers['repo'].AddGrowableRow(1)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
259 self.repopanel.SetSizer(self.sizers['repo'])
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
260 self.repopanel.SetAutoLayout(True)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
261
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
262 #Build Main Sizer
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
263 self.sizers["main"].Add(self.sizers["newbutton"], (0,0), flag=wx.EXPAND)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
264 self.sizers["main"].Add(self.repopanel, (1,0), flag=wx.EXPAND)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
265 self.sizers["main"].AddGrowableCol(0)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
266 self.sizers["main"].AddGrowableCol(1)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
267 self.sizers["main"].AddGrowableRow(1)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
268 self.SetSizer(self.sizers["main"])
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
269 self.SetAutoLayout(True)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
270 self.Fit()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
271 self.Bind(wx.EVT_BUTTON, self.AddRepo, self.buttons['addrepo'])
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
272
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
273 def NewRepoList(self, event):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
274 self.id = -1; self.box = {}; self.box_name= {}; self.main = {}; self.container = {}; self.layout = {}
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
275 self.name = {}; self.url = {}; self.url_list = {}; self.pull = {}; self.uri = {}; self.delete = {}
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
276 self.defaultcheck = {}; self.default = {}; self.repotrac = {}
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
277 self.pull_list = {}; self.delete_list = {}; self.defchecklist = {}
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
278
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
279 def BuildRepoList(self, event):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
280 self.repolist = self.manifest.GetList('UpdateManifest', 'repolist', '')
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
281 try: self.repolist = self.repo
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
282 except: pass
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
283
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
284 #wx.Yeild() For future refrence.
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
285
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
286 for repo in self.repolist:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
287 self.id += 1
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
288 #Build Constructs
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
289 self.box[self.id] = wx.StaticBox(self.repopanel, -1, str(repo))
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
290 self.main[self.id] = wx.GridBagSizer(hgap=2, vgap=2)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
291 self.container[self.id] = wx.StaticBoxSizer(self.box[self.id], wx.VERTICAL)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
292 self.layout[self.id] = wx.FlexGridSizer(rows=1, cols=4, hgap=2, vgap=5)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
293 self.name[self.id] = wx.StaticText(self.repopanel, -1, 'URL')
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
294 self.uri[self.id] = self.manifest.GetString('updaterepo', repo, '')
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
295 self.url[self.id] = wx.TextCtrl(self.repopanel, -1, self.uri[self.id])
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
296 self.pull[self.id] = wx.Button(self.repopanel, wx.ID_REFRESH)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
297 self.delete[self.id] = wx.Button(self.repopanel, wx.ID_DELETE)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
298 self.delete_list[self.delete[self.id]] = self.id
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
299 self.defaultcheck[self.id] = wx.CheckBox(self.repopanel, -1)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
300 self.default[self.id] = wx.StaticText(self.repopanel, -1, 'Default')
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
301 #Build Retraceables
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
302 self.box_name[self.id] = str(repo)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
303 self.pull_list[self.pull[self.id]] = self.id
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
304 self.defchecklist[self.defaultcheck[self.id]] = self.id
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
305 #Build Layout
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
306 self.layout[self.id].Add(self.name[self.id], -1, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
307 self.layout[self.id].Add(self.url[self.id], -1, wx.EXPAND)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
308 self.layout[self.id].Add(self.pull[self.id], -1, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL|wx.ALL)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
309 self.layout[self.id].Add(self.delete[self.id], -1, wx.EXPAND)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
310 self.layout[self.id].Add(self.defaultcheck[self.id], -1, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL|wx.ALL)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
311 self.layout[self.id].Add(self.default[self.id], -1, wx.EXPAND)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
312 self.layout[self.id].AddGrowableCol(1)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
313 self.container[self.id].Add(self.layout[self.id], -1, wx.EXPAND)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
314 #Button Events
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
315 self.Bind(wx.EVT_BUTTON, self.RefreshRepo, self.pull[self.id])
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
316 self.Bind(wx.EVT_BUTTON, self.DelRepo, self.delete[self.id])
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
317 self.Bind(wx.EVT_CHECKBOX, self.SetDefault, self.defaultcheck[self.id])
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
318 self.sizers["repolist_layout"].Insert(0, self.container[self.id], -1, wx.EXPAND)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
319 self.sizers['repolist_layout'].Layout()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
320
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
321 #Set Default Repo Button
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
322 capture = self.manifest.GetString('updaterepo', 'default', '')
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
323 if capture != '':
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
324 for caught in self.uri:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
325 if capture == self.uri[caught]: self.id = caught; pass
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
326 else: continue
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
327 self.defaultcheck[self.id].SetValue(True)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
328
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
329 def AddRepo(self, event):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
330 repo = self.texts['reponame'].GetValue(); repo = repo.replace(' ', '_'); repo = 'repo-' + repo
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
331 self.manifest.SetString('updaterepo', repo, ''); self.repo = repo.split(',')
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
332 repolist = self.manifest.GetList('UpdateManifest', 'repolist', '')
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
333 if repolist == '': pass
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
334 else: repolist = repolist + self.repo
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
335 self.manifest.SetList('UpdateManifest', 'repolist', repolist)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
336 self.BuildRepoList(None)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
337
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
338 def DelRepo(self, event):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
339 self.id = self.delete_list[event.GetEventObject()]
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
340 self.sizers["repolist_layout"].Hide(self.container[self.id])
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
341 try: del self.box_name[self.id]
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
342 except: pass
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
343 self.manifest.SetList('UpdateManifest', 'repolist', list(self.box_name.values()))
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
344 self.sizers['repolist_layout'].Layout()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
345
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
346 def RefreshRepo(self, event):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
347 self.id = self.pull_list[event.GetEventObject()]
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
348 self.manifest.SetString('updaterepo', str(self.box_name[self.id]), self.url[self.id].GetValue())
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
349 try: commands.pull(self.ui, self.r, self.url[self.id].GetValue(), rev='', update=False, force=True)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
350 except: pass
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
351
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
352 def SetDefault(self, event):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
353 self.id = self.defchecklist[event.GetEventObject()]
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
354 self.manifest.SetString('updaterepo', 'default', self.uri[self.id])
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
355 for all in self.defaultcheck:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
356 self.defaultcheck[all].SetValue(False)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
357 self.defaultcheck[self.id].SetValue(True)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
358
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
359 class Manifest(wx.Panel):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
360 def __init__(self, parent):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
361 wx.Panel.__init__(self, parent)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
362 self.ui = ui.ui()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
363 self.repo = hg.repository(self.ui, ".")
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
364 self.c = self.repo.changectx('tip')
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
365 self.manifestlist = []
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
366 self.manifestlist = self.c.manifest().keys()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
367 for mana in self.manifestlist: mana = os.sep + 'orpg' + os.sep + mana
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
368 self.manifestlist.sort()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
369 self.SetBackgroundColour(wx.WHITE)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
370 self.sizer = wx.GridBagSizer(hgap=1, vgap=1)
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
371 self.manifestlog = wx.CheckListBox( self, -1, wx.DefaultPosition, wx.DefaultSize,
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
372 self.manifestlist, wx.LC_REPORT|wx.SUNKEN_BORDER|wx.EXPAND|wx.LC_HRULES)
14
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
373 filename = 'ignorelist.txt'
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
374 self.filename = dir_struct["home"] + 'upmana' + os.sep + filename
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
375 component.get('validate').config_file(filename, "default_ignorelist.txt")
14
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
376 self.mana = self.LoadDoc()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
377 self.manifestlog.Bind(wx.EVT_CHECKLISTBOX, self.GetChecked)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
378 self.sizer.Add(self.manifestlog, (0,0), flag=wx.EXPAND)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
379 self.sizer.AddGrowableCol(0)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
380 self.sizer.AddGrowableRow(0)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
381 self.SetSizer(self.sizer)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
382 self.SetAutoLayout(True)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
383
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
384 def GetChecked(self, event):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
385 self.mana = []
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
386 for manifest in self.manifestlog.GetChecked(): self.mana.append(self.manifestlist[manifest])
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
387 self.SaveDoc()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
388
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
389 def SaveDoc(self):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
390 f = open(self.filename, "w")
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
391 for mana in self.mana: f.write(mana+'\n')
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
392 f.close()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
393
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
394 def LoadDoc(self):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
395 ignore = open(self.filename)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
396 ignorelist = []
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
397 for i in ignore: ignorelist.append(str(i [:len(i)-1]))
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
398 for i in ignorelist: #Adds previously ignored files to manifestlistlog if they are not in changesets.
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
399 if self.c.manifest().has_key(i): continue
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
400 else: self.manifestlist.append(i); self.manifestlist.sort()
17
265b987cce4f Traipse 'OpenRPG' {090813-00}
sirebral
parents: 16
diff changeset
401 self.manifestlog = wx.CheckListBox( self, -1, wx.DefaultPosition, wx.DefaultSize, self.manifestlist,
265b987cce4f Traipse 'OpenRPG' {090813-00}
sirebral
parents: 16
diff changeset
402 wx.LC_REPORT|wx.SUNKEN_BORDER|wx.EXPAND|wx.LC_HRULES)
14
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
403 self.manifestlog.SetCheckedStrings(ignorelist)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
404 manifest = ignore.readlines()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
405 ignore.close()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
406
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
407 class Control(wx.Panel):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
408 def __init__(self, parent):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
409 wx.Panel.__init__(self, parent)
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
410
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
411 ### Control Panel
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
412 self.ui = ui.ui()
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
413 self.repo = hg.repository(self.ui, ".")
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
414 self.c = self.repo.changectx('tip')
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
415 self.manifest = manifest
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
416 self.parent = parent
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
417 #logger.debug("Enter updaterFrame") #Need to set logging level
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
418
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
419 self.get_packages()
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
420 self.SetBackgroundColour(wx.WHITE)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
421 self.sizer = wx.GridBagSizer(hgap=1, vgap=1)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
422 self.buttons = {}
14
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
423
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
424 ## Changelog / File List
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
425 changelogcp = wx.Panel(self)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
426 self.changelogcp = wx.GridBagSizer(hgap=1, vgap=1)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
427 self.changelog = wx.TextCtrl(changelogcp, wx.ID_ANY, size=wx.DefaultSize, style=wx.TE_MULTILINE | wx.TE_READONLY)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
428 self.filelist = wx.TextCtrl(changelogcp, wx.ID_ANY, size=wx.DefaultSize, style=wx.TE_MULTILINE | wx.TE_READONLY)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
429 self.changelogcp.Add(self.changelog, (0,0), flag=wx.EXPAND)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
430 self.changelogcp.Add(self.filelist, (1,0), flag=wx.EXPAND)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
431 changelogcp.SetSizer(self.changelogcp)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
432 self.changelogcp.AddGrowableCol(0)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
433 self.changelogcp.AddGrowableRow(0)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
434 self.changelogcp.AddGrowableRow(1)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
435 changelogcp.SetAutoLayout(True)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
436
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
437 ## Branches / Revisions
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
438 branchcp = wx.Panel(self)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
439 self.branchcp = wx.GridBagSizer(hgap=1, vgap=1)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
440 self.branches = wx.Choice(branchcp, wx.ID_ANY, choices=self.package_list)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
441 self.branch_txt = wx.StaticText(branchcp, wx.ID_ANY, "Branches")
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
442 self.branchcp.Add(self.branches, (0,0))
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
443 self.branchcp.Add(self.branch_txt, (0,1), flag=wx.ALIGN_CENTER_VERTICAL)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
444 branchcp.SetSizer(self.branchcp)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
445 branchcp.SetAutoLayout(True)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
446
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
447 revlistcp = wx.Panel(self)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
448 self.revlistcp = wx.GridBagSizer(hgap=2, vgap=2)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
449 self.revlist = wx.ListCtrl(revlistcp, -1, wx.DefaultPosition, size=wx.DefaultSize,
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
450 style=wx.LC_REPORT|wx.SUNKEN_BORDER|wx.LC_HRULES)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
451 self.revlist.InsertColumn(0, 'Revs')
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
452 self.revlist.InsertColumn(1, 'Changeset')
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
453 self.revlist.SetColumnWidth(0, -1)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
454 self.revlist.SetColumnWidth(1, -1)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
455 self.revlist.Refresh()
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
456 self.revlistcp.Add(self.revlist, (0,0), flag=wx.EXPAND)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
457 revlistcp.SetSizer(self.revlistcp)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
458 self.revlistcp.AddGrowableCol(0)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
459 self.revlistcp.AddGrowableRow(0)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
460 self.revlistcp.AddGrowableRow(1)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
461 revlistcp.SetAutoLayout(True)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
462
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
463 ## Control Panel
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
464 cp = wx.Panel(self)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
465 self.cp = wx.GridBagSizer(hgap=1, vgap=1)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
466 self.buttons['update'] = wx.Button(cp, wx.ID_ANY, "Revision Update")
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
467 self.buttons['delete'] = wx.Button(cp, wx.ID_ANY, "Delete Branch")
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
468 self.cp.Add(self.buttons['update'], (0,0))
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
469 self.cp.Add(self.buttons['delete'], (0,1))
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
470 cp.SetSizer(self.cp)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
471 cp.SetAutoLayout(True)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
472
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
473 self.sizer.Add(changelogcp, (0,0), span=(3,1), flag=wx.EXPAND)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
474 self.sizer.Add(branchcp, (0,1), span=(1,1))
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
475 self.sizer.Add(revlistcp, (2,1), span=(1,1), flag=wx.EXPAND)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
476 self.sizer.Add(cp, (1,1), span=(1,1))
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
477
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
478 self.buttons['delete'].Disable()
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
479 self.sizer.AddGrowableCol(0)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
480 self.sizer.AddGrowableCol(1)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
481 self.sizer.AddGrowableRow(2)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
482 self.SetSizer(self.sizer)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
483 self.SetAutoLayout(True)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
484
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
485 self.current = self.repo.dirstate.branch()
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
486 self.currev = self.repo.changelog.rev(self.repo.branchtags()[self.current])
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
487 self.RevInfo(self.currev)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
488 self.revlist.Select(self.revlist.FindItem(0, str(self.currev), 1))
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
489 self.BranchInfo(self.current)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
490 self.Bind(wx.EVT_CHOICE, self.PackageSet)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
491 self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.RevSet)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
492 self.Bind(wx.EVT_BUTTON, self.RevUpdate, self.buttons['update'])
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
493
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
494
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
495 def PackageSet(self, event):
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
496 self.current = self.branches.GetStringSelection()
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
497 branches = self.repo.branchtags()
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
498 heads = dict.fromkeys(self.repo.heads(), 1)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
499 l = [((n in heads), self.repo.changelog.rev(n), n, t) for t, n in branches.items()]
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
500 if self.current != type:
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
501 heads = dict.fromkeys(self.repo.heads(), self.repo.branchtags())
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
502 branches = dict.copy(self.repo.branchtags())
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
503 self.BranchInfo(self.current)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
504 self.RevInfo(self.current)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
505
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
506 def RevSet(self, event):
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
507 self.currev = self.revlist.GetItemText( self.revlist.GetFirstSelected() )
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
508 i = event.GetIndex()
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
509 self.revlist.Select(i, True)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
510 self.revlist.Focus(i)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
511 if self.currev != self.revlist.GetItemText( self.revlist.GetFirstSelected() ):
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
512 self.RevInfo(self.currev)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
513
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
514 def RevInfo(self, rev):
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
515 self.revlist.DeleteAllItems()
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
516 self.revlist_a = []; self.revlist_b = {}
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
517 for heads in self.repo.changelog.reachable(self.repo.branchtags()[self.current]):
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
518 self.revlist_a.append(str(self.repo.changelog.rev(heads)))
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
519 self.revlist_b[str(self.repo.changelog.rev(heads))] = str(self.repo.changectx(heads))
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
520 self.revlist_a.sort()
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
521 for i in self.revlist_a:
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
522 self.revlist.InsertStringItem(0, str(i), 0 )
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
523 self.revlist.SetStringItem(0, 1, self.revlist_b[i])
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
524 self.revlist.SetColumnWidth(0, -1)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
525 self.revlist.SetColumnWidth(1, -1)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
526 self.revlist.Refresh()
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
527 self.BranchInfo(self.current)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
528
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
529 def BranchInfo(self, branch):
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
530 rs = self.repo.changectx( self.currev ).changeset()
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
531 self.changelog.SetValue('')
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
532 changelog = rs[4]
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
533 self.changelog.AppendText(changelog + '\n')
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
534 self.filelist.SetValue('')
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
535 self.filelist.AppendText("Currently selected branch: " + branch + "\n\nAuthor: "+rs[1]+"\n\n")
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
536 self.filelist.AppendText("Files Modified (in update): \n")
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
537 for f in rs[3]: self.filelist.AppendText(f+"\n")
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
538
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
539 def DelBranch(self, event):
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
540 pass
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
541
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
542 def RevUpdate(self, event):
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
543 filename = 'ignorelist.txt'
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
544 self.filename = dir_struct["home"] + 'upmana' + os.sep + filename
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
545 component.get('validate').config_file(filename, "default_ignorelist.txt")
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
546 self.mana = self.LoadDoc()
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
547 temp = dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
548 for ignore in self.ignorelist:
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
549 shutil.copy(ignore, temp + ignore.split('/')[len(ignore.split('/')) - 1])
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
550 hg.clean(self.repo, self.currev)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
551 for ignore in self.ignorelist:
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
552 shutil.copyfile(temp + ignore.split('/')[len(ignore.split('/')) - 1], ignore)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
553 os.remove(temp + ignore.split('/')[len(ignore.split('/')) - 1])
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
554 pass
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
555
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
556 def LoadDoc(self):
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
557 ignore = open(self.filename)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
558 self.ignorelist = []
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
559 for i in ignore: self.ignorelist.append(str(i [:len(i)-1]))
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
560 manifest = ignore.readlines()
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
561 ignore.close()
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
562
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
563 def get_packages(self, type=None):
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
564 #Fixed and ready for Test. Can be cleaner
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
565 self.package_list = []
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
566 b = self.repo.branchtags()
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
567 heads = dict.fromkeys(self.repo.heads(), 1) #The code below looks superfluous but there is good info inside
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
568 l = [((n in heads), self.repo.changelog.rev(n), n, t) for t, n in b.items()]
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
569 l.sort()
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
570 l.reverse()
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
571 for ishead, r, n, t in l: self.package_list.append(t)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
572
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
573 def get_package(self):
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
574 self.get_packages()
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
575 if self.package_list == None: return None
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
576 return None
14
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
577
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
578 class updaterFrame(wx.Frame):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
579 def __init__(self, parent, title, openrpg, manifest, main):
17
265b987cce4f Traipse 'OpenRPG' {090813-00}
sirebral
parents: 16
diff changeset
580
265b987cce4f Traipse 'OpenRPG' {090813-00}
sirebral
parents: 16
diff changeset
581 wx.Frame.__init__(self, None, wx.ID_ANY, title, size=(600,480), style=wx.DEFAULT_FRAME_STYLE)
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
582 if wx.Platform == '__WXMSW__': icon = wx.Icon(dir_struct["icon"]+'d20.ico', wx.BITMAP_TYPE_ICO)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
583 else: icon = wx.Icon(dir_struct["icon"]+"d20.xpm", wx.BITMAP_TYPE_XPM )
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
584
17
265b987cce4f Traipse 'OpenRPG' {090813-00}
sirebral
parents: 16
diff changeset
585 self.SetIcon(icon)
14
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
586 self.CenterOnScreen()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
587 self.main = main
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
588 ####### Panel Stuff ######
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
589 p = wx.Panel(self)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
590 nb = wx.Notebook(p)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
591
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
592 # create the page windows as children of the notebook
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
593 page1 = Updater(nb, openrpg, manifest)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
594 page2 = Repos(nb, openrpg, manifest)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
595 page3 = Manifest(nb)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
596 page4 = Control(nb)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
597
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
598 # add the pages to the notebook with the label to show on the tab
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
599 nb.AddPage(page1, "Updater")
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
600 nb.AddPage(page2, "Repos")
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
601 nb.AddPage(page3, "Manifest")
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
602 nb.AddPage(page4, "Control")
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
603
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
604 # finally, put the notebook in a sizer for the panel to manage
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
605 # the layout
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
606 sizer = wx.BoxSizer()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
607 sizer.Add(nb, 1, wx.EXPAND)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
608 p.SetSizer(sizer)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
609 self.Bind(wx.EVT_CLOSE, self.OnClose)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
610
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
611 def OnClose(self, event):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
612 if self.main == False: self.Destroy()
17
265b987cce4f Traipse 'OpenRPG' {090813-00}
sirebral
parents: 16
diff changeset
613 if self.main == True: self.Hide()
14
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
614
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
615 class updateApp(wx.App):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
616 def OnInit(self):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
617 self.main = False
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
618 logger._set_log_to_console(False)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
619 logger.note("Updater Start")
14
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
620 self.manifest = manifest.ManifestChanges()
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
621 component.add('validate', validate)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
622 self.updater = updaterFrame(self, "OpenRPG Update Manager 0.8 (open beta)",
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
623 component, self.manifest, self.main)
14
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
624 if self.manifest.GetString("updatemana", "auto_update", "") == 'on' and self.main == False:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
625 self.AutoUpdate(); self.OnExit()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
626 else: pass
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
627 if self.manifest.GetString('updatemana', 'no_update', '') == 'on' and self.main == False:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
628 self.OnExit()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
629 else: pass
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
630 try:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
631 self.updater.Show()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
632 self.updater.Fit()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
633 except: pass
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
634 return True
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
635
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
636 def AutoUpdate(self):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
637 self.ui = ui.ui()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
638 self.repo = hg.repository(self.ui, ".")
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
639 self.c = self.repo.changectx('tip')
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
640 self.current = self.repo.dirstate.branch()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
641
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
642 capture = self.manifest.GetString('updaterepo', 'default', '')
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
643 if capture != '':
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
644 commands.pull(self.ui, self.repo, capture, rev='', update=False, force=True)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
645 filename = 'ignorelist.txt'
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
646 self.filename = dir_struct["home"] + 'upmana' + os.sep + filename
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
647 component.get('validate').config_file(filename, "default_ignorelist.txt")
14
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
648 self.mana = self.LoadDoc()
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
649 temp = dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep
16
281ca8daa911 Traipse 'OpenRPG' {090808-00}
sirebral
parents: 14
diff changeset
650 for ignore in self.ignorelist:
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
651 shutil.copy(ignore, temp + ignore.split('/')[len(ignore.split('/')) - 1])
14
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
652 hg.clean(self.repo, self.current)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
653 for ignore in self.ignorelist:
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
654 shutil.copyfile(temp + ignore.split('/')[len(ignore.split('/')) - 1], ignore)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
655 os.remove(temp + ignore.split('/')[len(ignore.split('/')) - 1])
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
656 else: wx.MessageBox('No default Rpository set. Skipping Auto Update!', 'Info')
14
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
657
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
658 def LoadDoc(self):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
659 ignore = open(self.filename)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
660 self.ignorelist = []
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
661 for i in ignore: self.ignorelist.append(str(i [:len(i)-1]))
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
662 manifest = ignore.readlines()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
663 ignore.close()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
664
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
665 def OnExit(self):
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
666 imported = ['manifest', 'orpg.dirpath', 'orpg.orpgCore', 'orpg.orpg_version',
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
667 'orpg.tools.orpg_log', 'orpg.tools.orpg_log', 'orpg.orpg_xml', 'orpg.dirpath',
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
668 'orpg.dirpath', 'upmana.validate', 'mercurial.ui', 'mercurial.hg',
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
669 'mercurial.commands', 'mercurial.repo', 'mercurial.revlog', 'mercurial.cmdutil', 'shutil']
14
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
670 for name in imported:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
671 if name in sys.modules: del sys.modules[name]
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
672
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
673 try: self.updater.Destroy()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
674 except: pass