36
|
1 from __future__ import with_statement
|
28
|
2 import wx, sys, os #just .sep maybe
|
|
3 from manifest import manifest
|
14
|
4 import shutil
|
18
|
5
|
|
6 from orpg.orpgCore import component
|
28
|
7 from orpg.dirpath import dir_struct
|
18
|
8 from orpg.tools.orpg_log import logger, crash
|
28
|
9 from upmana.validate import validate
|
|
10 from orpg.dirpath import dir_struct
|
17
|
11 from mercurial import ui, hg, commands, repo, revlog, cmdutil, util
|
14
|
12
|
28
|
13 class Term2Win(object):
|
|
14 # A stdout redirector. Allows the messages from Mercurial to be seen in the Install Window
|
|
15 def write(self, text):
|
31
|
16 self.closed = sys.__stdout__.closed
|
|
17 self.flush = sys.__stdout__.flush
|
|
18 statbar.SetStatusText(text.replace('\n', ''))
|
28
|
19 sys.__stdout__.write(text)
|
14
|
20
|
|
21 class Updater(wx.Panel):
|
28
|
22 def __init__(self, parent, component):
|
14
|
23 wx.Panel.__init__(self, parent)
|
28
|
24 ### Status Bar ###
|
|
25 #statbar.SetStatusText('Select a Package and Update')
|
31
|
26 #statbar.SetStatusText('New Status Bar')
|
|
27
|
|
28 self.timer = wx.Timer(self, 1)
|
|
29 self.count = 0
|
14
|
30
|
|
31 ### Update Manager
|
|
32 self.ui = ui.ui()
|
|
33 self.repo = hg.repository(self.ui, ".")
|
|
34 self.c = self.repo.changectx('tip')
|
18
|
35 self.parent = parent
|
28
|
36 self.SetBackgroundColour(wx.WHITE)
|
14
|
37 self.sizer = wx.GridBagSizer(hgap=1, vgap=1)
|
28
|
38 self.changelog = wx.TextCtrl(self, wx.ID_ANY, size=(300, -1),
|
|
39 style=wx.TE_MULTILINE | wx.TE_READONLY)
|
|
40 self.filelist = wx.TextCtrl(self, wx.ID_ANY, size=(275, 300),
|
|
41 style=wx.TE_MULTILINE | wx.TE_READONLY)
|
|
42 self.buttons = {}
|
|
43 self.buttons['progress_bar'] = wx.Gauge(self, wx.ID_ANY, 100)
|
|
44 self.buttons['auto_text'] = wx.StaticText(self, wx.ID_ANY, "Auto Update")
|
14
|
45 self.buttons['auto_check'] = wx.CheckBox(self, wx.ID_ANY)
|
28
|
46 self.buttons['no_text'] = wx.StaticText(self, wx.ID_ANY, "No Update")
|
14
|
47 self.buttons['no_check'] = wx.CheckBox(self, wx.ID_ANY)
|
28
|
48 self.buttons['advanced'] = wx.Button(self, wx.ID_ANY, "Package Select")
|
|
49 self.buttons['update'] = wx.Button(self, wx.ID_ANY, "Update Now")
|
14
|
50 self.buttons['finish'] = wx.Button(self, wx.ID_ANY, "Finish")
|
|
51
|
31
|
52 self.sizer.Add(self.changelog, (0,0), span=(5,1), flag=wx.EXPAND)
|
14
|
53 self.sizer.Add(self.filelist, (0,1), span=(1,3), flag=wx.EXPAND)
|
28
|
54
|
14
|
55 self.sizer.Add(self.buttons['progress_bar'], (1,1), span=(1,3), flag=wx.EXPAND)
|
28
|
56 self.sizer.Add(self.buttons['auto_text'], (2,1))
|
14
|
57 self.sizer.Add(self.buttons['auto_check'], (2,2), flag=wx.EXPAND)
|
28
|
58 self.sizer.Add(self.buttons['no_text'], (3,1))
|
14
|
59 self.sizer.Add(self.buttons['no_check'], (3,2), flag=wx.EXPAND)
|
28
|
60 self.sizer.Add(self.buttons['advanced'], (2,3), flag=wx.EXPAND)
|
|
61 self.sizer.Add(self.buttons['update'], (3,3), flag=wx.EXPAND)
|
14
|
62 self.sizer.Add(self.buttons['finish'], (4,3), flag=wx.EXPAND)
|
31
|
63 self.buttons['progress_bar'].SetValue(100)
|
28
|
64 self.sizer.AddGrowableCol(0)
|
|
65 self.sizer.AddGrowableRow(0)
|
|
66 self.SetSizer(self.sizer)
|
14
|
67 self.SetAutoLayout(True)
|
|
68 self.get_package
|
|
69
|
|
70 self.current = self.repo.dirstate.branch()
|
|
71 self.BranchInfo(self.current)
|
|
72
|
28
|
73 if manifest.GetString("updatemana", "no_update", "") == 'on': self.buttons['no_check'].SetValue(True)
|
|
74 else: self.buttons['no_check'].SetValue(False)
|
|
75 if manifest.GetString("updatemana", "auto_update", "") == 'on': self.buttons['auto_check'].SetValue(True)
|
|
76 else: self.buttons['auto_check'].SetValue(False)
|
|
77
|
|
78 ## Event Handlers
|
|
79 self.Bind(wx.EVT_BUTTON, self.Update, self.buttons['update'])
|
|
80 self.Bind(wx.EVT_BUTTON, self.Finish, self.buttons['finish'])
|
|
81 self.Bind(wx.EVT_BUTTON, self.ChooseBranch, self.buttons['advanced'])
|
14
|
82 self.Bind(wx.EVT_CHECKBOX, self.ToggleAutoUpdate, self.buttons['auto_check'])
|
|
83 self.Bind(wx.EVT_CHECKBOX, self.ToggleNoUpdate, self.buttons['no_check'])
|
31
|
84 self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer)
|
|
85
|
|
86 def OnTimer(self, event):
|
|
87 statbar.SetStatusText('Checking For Updates')
|
|
88 self.count = self.count + 1
|
|
89 self.buttons['progress_bar'].SetValue(self.count)
|
|
90 if self.count == 100:
|
|
91 self.timer.Stop()
|
|
92 statbar.SetStatusText('No Updates Available')
|
|
93
|
|
94 def UpdateCheck(self):
|
|
95 self.timer.Start(100)
|
|
96 self.count = 3
|
|
97 self.buttons['progress_bar'].SetValue(3)
|
|
98 try:
|
|
99 doUpdate = commands.incoming(self.ui, self.repo,
|
|
100 manifest.GetString('default', 'repo', ''),
|
|
101 force=True, bundle=False)
|
|
102 if doUpdate:
|
|
103 statbar.SetStatusText('No Updates Available')
|
|
104 self.buttons['progress_bar'].SetValue(100)
|
|
105 self.timer.Stop()
|
|
106 else:
|
|
107 statbar.SetStatusText('Refresh Repo For Updated Source')
|
|
108 self.buttons['progress_bar'].SetValue(100)
|
|
109 self.timer.Stop()
|
|
110 except:
|
|
111 statbar.SetStatusText('No Connection Found')
|
|
112 self.buttons['progress_bar'].SetValue(100)
|
|
113 self.timer.Stop()
|
|
114
|
14
|
115
|
28
|
116 def ToggleAutoUpdate(self, event):
|
14
|
117 if self.buttons['auto_check'].GetValue() == True:
|
|
118 if self.buttons['no_check'].GetValue() == True:
|
|
119 self.buttons['no_check'].SetValue(False)
|
28
|
120 manifest.SetString("updatemana", "no_update", "off")
|
|
121 manifest.SetString("updatemana", "auto_update", "on")
|
|
122 else: manifest.SetString("updatemana", "auto_update", "off")
|
14
|
123
|
28
|
124 def ToggleNoUpdate(self, event):
|
14
|
125 if self.buttons['no_check'].GetValue() == True:
|
|
126 if self.buttons['auto_check'].GetValue() == True:
|
|
127 self.buttons['auto_check'].SetValue(False)
|
28
|
128 manifest.SetString("updatemana", "auto_update", "off")
|
|
129 manifest.SetString("updatemana", "no_update", "on")
|
|
130 else: manifest.SetString("updatemana", "no_update", "off")
|
|
131
|
14
|
132 def Update(self, evt=None):
|
37
|
133 with open(sys.path[1]+os.sep+'location.py', 'rb') as f: old_location = f.read()
|
36
|
134 ## This new location file update allows for a more portable way to start Traipse. It's aimed at Linux users.
|
|
135 new_location = """import sys
|
|
136 import os
|
|
137
|
|
138 dyn_dir = 'System'
|
|
139 _home = sys.path[0]
|
|
140 _userbase_dir = _home + os.sep + dyn_dir
|
|
141 sys.path.append(_userbase_dir)
|
|
142 try: os.chdir(_userbase_dir)
|
|
143 except: print 'Failed to find ' + _userbase_dir + '\\nHopefuly you are running setup.py which would make this error normal.'"""
|
|
144
|
|
145 if new_location != old_location:
|
37
|
146 with open(sys.path[1]+os.sep+'location.py', 'w') as f: f.write(new_location)
|
36
|
147
|
14
|
148 self.ui = ui.ui()
|
|
149 self.repo = hg.repository(self.ui, ".")
|
|
150 self.c = self.repo.changectx('tip')
|
|
151 filename = 'ignorelist.txt'
|
18
|
152 self.filename = dir_struct["home"] + 'upmana' + os.sep + filename
|
|
153 component.get('validate').config_file(filename, "default_ignorelist.txt")
|
14
|
154 self.mana = self.LoadDoc()
|
18
|
155 temp = dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep
|
14
|
156 for ignore in self.ignorelist:
|
28
|
157 if len(ignore.split('/')) > 1:
|
|
158 gets = 0; dir1 = ''
|
|
159 while gets != len(ignore.split('/'))-1:
|
|
160 dir1 += ignore.split('/')[gets] + os.sep
|
|
161 gets += 1
|
|
162 os.makedirs(temp+dir1)
|
|
163 shutil.copy(ignore, temp + dir1 + ignore.split('/')[len(ignore.split('/')) - 1])
|
14
|
164 hg.clean(self.repo, self.current)
|
|
165 for ignore in self.ignorelist:
|
18
|
166 shutil.copyfile(temp + ignore.split('/')[len(ignore.split('/')) - 1], ignore)
|
|
167 os.remove(temp + ignore.split('/')[len(ignore.split('/')) - 1])
|
28
|
168 if len(ignore.split('/')) > 1:
|
|
169 gets = 0; dir1 = ''
|
|
170 while gets != len(ignore.split('/'))-1:
|
|
171 dir1 += ignore.split('/')[gets] + os.sep
|
|
172 gets += 1
|
|
173 os.removedirs(temp+dir1)
|
14
|
174
|
|
175 def LoadDoc(self):
|
31
|
176 manifest = open(self.filename)
|
14
|
177 self.ignorelist = []
|
31
|
178 ignore = manifest.readlines()
|
36
|
179 for i in ignore: self.ignorelist.append(str(i[:len(i)-1]))
|
31
|
180 manifest.close()
|
28
|
181
|
|
182 def Finish(self, evt=None):
|
|
183 component.get('upmana-win').OnClose(None)
|
|
184
|
14
|
185 def ChooseBranch(self, evt=None):
|
28
|
186 dlg = wx.Dialog(self, wx.ID_ANY, "Package Selector", style=wx.DEFAULT_DIALOG_STYLE)
|
|
187 if wx.Platform == '__WXMSW__': icon = wx.Icon(dir_struct["icon"]+'d20.ico', wx.BITMAP_TYPE_ICO)
|
|
188 else: icon = wx.Icon(dir_struct["icon"]+"d20.xpm", wx.BITMAP_TYPE_XPM )
|
14
|
189 dlg.SetIcon(icon)
|
|
190
|
|
191 self.ui = ui.ui()
|
|
192 self.repo = hg.repository(self.ui, ".")
|
28
|
193 self.c = self.repo.changectx('tip')
|
|
194
|
14
|
195 dlgsizer = wx.GridBagSizer(hgap=1, vgap=1)
|
28
|
196 Yes = wx.Button( dlg, wx.ID_OK, "Ok" )
|
|
197 Yes.SetDefault()
|
|
198 rgroup = wx.RadioButton(dlg, wx.ID_ANY, "group_start", style=wx.RB_GROUP)
|
|
199 rgroup.Hide()
|
|
200
|
14
|
201 self.get_packages()
|
|
202 if self.package_list == None: return
|
28
|
203 types = self.package_list
|
|
204 row=0; col=0
|
14
|
205 self.current = self.repo.dirstate.branch()
|
|
206 self.package_type = self.current
|
|
207 self.btnlist = {}; self.btn = {}
|
|
208 self.id = 1
|
|
209
|
28
|
210 for t in types:
|
|
211 self.btnName = str(t)
|
|
212 self.btn[self.id] = wx.RadioButton(dlg, wx.ID_ANY, str(t), name=self.btnName)
|
36
|
213 if self.btnName == self.current: self.btn[self.id].SetValue(True); self.current_id = self.id
|
14
|
214 self.btnlist[self.id] = self.btnName
|
28
|
215 dlgsizer.Add(self.btn[self.id], (row, col))
|
14
|
216 col += 1; self.id += 1
|
|
217 if col == 3: row += 1; col = 0
|
28
|
218
|
14
|
219 dlgsizer.Add(Yes, (row+1,col/2))
|
|
220 dlgsizer.AddGrowableCol(0)
|
|
221 dlgsizer.AddGrowableRow(0)
|
28
|
222 dlg.SetAutoLayout( True )
|
14
|
223 dlg.SetSizer( dlgsizer )
|
28
|
224 dlgsizer.Fit( dlg )
|
|
225 dlg.Centre()
|
|
226 dlg.Bind(wx.EVT_RADIOBUTTON, self.PackageSet)
|
|
227 if dlg.ShowModal(): dlg.Destroy()
|
|
228
|
14
|
229 def PackageSet(self, event):
|
|
230 for btn in self.btn:
|
36
|
231 if self.btn[btn].GetValue() == True:
|
|
232 if self.btnlist[btn] == 'pious-paladin':
|
|
233 try: from PyQt4 import QtCore
|
|
234 except:
|
|
235 error = "'Pious Paladin' requires PyQt 4.6. For stability you will not be able to update."
|
|
236 dlg = wx.MessageDialog(None, error, 'Failed PyQt Test', wx.OK | wx.ICON_ERROR)
|
|
237 dlg.ShowModal()
|
|
238 self.btn[self.current_id].SetValue(True)
|
|
239 self.current = self.btnlist[self.current_id]
|
|
240 else: self.current = self.btnlist[btn]
|
14
|
241
|
|
242 branches = self.repo.branchtags()
|
|
243 heads = dict.fromkeys(self.repo.heads(), 1)
|
|
244 l = [((n in heads), self.repo.changelog.rev(n), n, t) for t, n in branches.items()]
|
|
245
|
|
246 if self.current != type:
|
|
247 heads = dict.fromkeys(self.repo.heads(), self.repo.branchtags())
|
|
248 branches = dict.copy(self.repo.branchtags())
|
|
249 self.BranchInfo(self.current)
|
|
250
|
|
251 def BranchInfo(self, branch):
|
17
|
252 cs = self.repo.changectx( self.current ).changeset()
|
14
|
253 self.changelog.SetValue('')
|
17
|
254 changelog = cs[4]
|
14
|
255 self.changelog.AppendText(changelog + '\n')
|
17
|
256 self.filelist.SetValue('')
|
18
|
257 self.filelist.AppendText("Currently selected branch: " + branch + "\n\nAuthor: "+cs[1]+"\n\n")
|
|
258 self.filelist.AppendText("Files Modified (in update): \n")
|
17
|
259 for f in cs[3]: self.filelist.AppendText(f+"\n")
|
28
|
260
|
14
|
261 def get_packages(self, type=None):
|
|
262 #Fixed and ready for Test. Can be cleaner
|
|
263 self.package_list = []
|
|
264 b = self.repo.branchtags()
|
17
|
265 heads = dict.fromkeys(self.repo.heads(), 1) #The code below looks superfluous but there is good info inside
|
14
|
266 l = [((n in heads), self.repo.changelog.rev(n), n, t) for t, n in b.items()]
|
|
267 l.sort()
|
|
268 l.reverse()
|
|
269 for ishead, r, n, t in l: self.package_list.append(t)
|
28
|
270
|
14
|
271 def get_package(self):
|
28
|
272 self.get_packages()
|
14
|
273 if self.package_list == None: return None
|
28
|
274 return None
|
14
|
275
|
|
276 class Repos(wx.Panel):
|
28
|
277 def __init__(self, parent, openrpg):
|
14
|
278 wx.Panel.__init__(self, parent)
|
28
|
279 ### Status Bar ###
|
|
280 #statbar.SetStatusText('Add, Delete, or Refresh your source Tracs')
|
|
281 statbar.SetStatusText('New Status Bar')
|
14
|
282 ### Update Manager
|
|
283 self.ui = ui.ui()
|
|
284 self.r = hg.repository(self.ui, ".")
|
|
285 self.c = self.r.changectx('tip')
|
|
286
|
|
287 #mainpanel = self
|
|
288 self.openrpg = openrpg
|
|
289 self.buttons = {}
|
|
290 self.texts = {}
|
|
291
|
|
292 ## Section Sizers (with frame edges and text captions)
|
|
293 self.box_sizers = {}
|
|
294 self.box_sizers["newbutton"] = wx.StaticBox(self, -1)
|
|
295
|
|
296 ## Layout Sizers
|
|
297 self.sizers = {}
|
|
298 self.sizers["main"] = wx.GridBagSizer(hgap=2, vgap=2)
|
|
299 self.sizers["button"] = wx.GridBagSizer(hgap=2, vgap=2)
|
|
300
|
|
301 #Button Layout
|
|
302 self.sizers["newbutton"] = wx.StaticBoxSizer(self.box_sizers["newbutton"], wx.VERTICAL)
|
|
303 self.sizers["newrepo_layout"] = wx.FlexGridSizer(rows=1, cols=2, hgap=2, vgap=5)
|
|
304 empty = wx.StaticText(self, -1, "")
|
|
305 reponame = wx.StaticText(self, -1, "Name:")
|
|
306 self.texts["reponame"] = wx.TextCtrl(self, -1, '')
|
|
307 self.buttons['addrepo'] = wx.Button(self, wx.ID_NEW)
|
|
308
|
|
309 ##Build Button
|
|
310 self.sizers["newrepo_layout"].Add(self.buttons['addrepo'], -1, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL)
|
|
311 self.sizers["newrepo_layout"].Add(empty, -1)
|
|
312 self.sizers["newrepo_layout"].Add(reponame, -1, wx.ALIGN_CENTER|wx.ALIGN_CENTER_VERTICAL|wx.ALL)
|
|
313 self.sizers["newrepo_layout"].Add(self.texts["reponame"], -1, wx.EXPAND)
|
|
314 self.sizers["newrepo_layout"].AddGrowableCol(1)
|
|
315 self.sizers["newbutton"].Add(self.sizers["newrepo_layout"], -1, wx.EXPAND)
|
17
|
316
|
14
|
317 #Repo List Panel
|
|
318 self.repopanel = wx.ScrolledWindow(self)
|
|
319 self.repopanel.SetScrollbars(20,20,55,40)
|
|
320 self.repopanel.Scroll(50,10)
|
|
321 self.box_sizers["repolist"] = wx.StaticBox(self.repopanel, -1, "Current Repo List")
|
|
322 self.sizers["repolist"] = wx.StaticBoxSizer(self.box_sizers["repolist"], wx.VERTICAL)
|
|
323 self.sizers["repo"] = wx.GridBagSizer(hgap=2, vgap=2)
|
|
324 self.sizers["repolist_layout"] = wx.FlexGridSizer(rows=1, cols=1, hgap=2, vgap=5)
|
|
325
|
|
326 self.NewRepoList(None)
|
|
327 self.BuildRepoList(None)
|
|
328
|
|
329 self.sizers["repolist_layout"].AddGrowableCol(0)
|
|
330 self.sizers["repolist"].Add(self.sizers["repolist_layout"], -1, wx.EXPAND)
|
|
331 self.sizers["repo"].Add(self.sizers["repolist"], (0,0), flag=wx.EXPAND)
|
|
332 self.sizers["repo"].AddGrowableCol(0)
|
|
333 self.sizers['repo'].AddGrowableRow(0)
|
|
334 self.sizers['repo'].AddGrowableRow(1)
|
|
335 self.repopanel.SetSizer(self.sizers['repo'])
|
|
336 self.repopanel.SetAutoLayout(True)
|
|
337
|
|
338 #Build Main Sizer
|
|
339 self.sizers["main"].Add(self.sizers["newbutton"], (0,0), flag=wx.EXPAND)
|
|
340 self.sizers["main"].Add(self.repopanel, (1,0), flag=wx.EXPAND)
|
|
341 self.sizers["main"].AddGrowableCol(0)
|
|
342 self.sizers["main"].AddGrowableCol(1)
|
|
343 self.sizers["main"].AddGrowableRow(1)
|
|
344 self.SetSizer(self.sizers["main"])
|
|
345 self.SetAutoLayout(True)
|
28
|
346 #self.Fit()
|
14
|
347 self.Bind(wx.EVT_BUTTON, self.AddRepo, self.buttons['addrepo'])
|
|
348
|
|
349 def NewRepoList(self, event):
|
28
|
350 self.id = -1
|
|
351 self.box = {}; self.box_name= {}; self.main = {}; self.container = {}; self.layout = {}
|
14
|
352 self.name = {}; self.url = {}; self.url_list = {}; self.pull = {}; self.uri = {}; self.delete = {}
|
|
353 self.defaultcheck = {}; self.default = {}; self.repotrac = {}
|
28
|
354 self.pull_list = {}; self.delete_list = {}; self.defchecklist = {}; self.repolist = []
|
14
|
355
|
|
356 def BuildRepoList(self, event):
|
28
|
357 repolist = manifest.PluginChildren('updaterepo')
|
|
358 appendlist = []
|
|
359 for repo in repolist:
|
|
360 if repo not in self.repolist: appendlist.append(repo)
|
|
361 self.repolist = repolist
|
14
|
362
|
28
|
363 for repo in appendlist:
|
14
|
364 self.id += 1
|
|
365 #Build Constructs
|
|
366 self.box[self.id] = wx.StaticBox(self.repopanel, -1, str(repo))
|
|
367 self.main[self.id] = wx.GridBagSizer(hgap=2, vgap=2)
|
|
368 self.container[self.id] = wx.StaticBoxSizer(self.box[self.id], wx.VERTICAL)
|
|
369 self.layout[self.id] = wx.FlexGridSizer(rows=1, cols=4, hgap=2, vgap=5)
|
|
370 self.name[self.id] = wx.StaticText(self.repopanel, -1, 'URL')
|
28
|
371 self.uri[self.id] = manifest.GetString('updaterepo', repo, '')
|
|
372 #except: self.uri[self.id] = ''
|
14
|
373 self.url[self.id] = wx.TextCtrl(self.repopanel, -1, self.uri[self.id])
|
|
374 self.pull[self.id] = wx.Button(self.repopanel, wx.ID_REFRESH)
|
|
375 self.delete[self.id] = wx.Button(self.repopanel, wx.ID_DELETE)
|
|
376 self.delete_list[self.delete[self.id]] = self.id
|
|
377 self.defaultcheck[self.id] = wx.CheckBox(self.repopanel, -1)
|
|
378 self.default[self.id] = wx.StaticText(self.repopanel, -1, 'Default')
|
|
379 #Build Retraceables
|
|
380 self.box_name[self.id] = str(repo)
|
|
381 self.pull_list[self.pull[self.id]] = self.id
|
|
382 self.defchecklist[self.defaultcheck[self.id]] = self.id
|
|
383 #Build Layout
|
28
|
384 self.layout[self.id].Add(self.name[self.id],
|
|
385 -1, wx.ALIGN_LEFT|wx.ALIGN_CENTER_VERTICAL|wx.ALL)
|
|
386 self.layout[self.id].Add(self.url[self.id],
|
|
387 -1, wx.EXPAND)
|
|
388 self.layout[self.id].Add(self.pull[self.id],
|
|
389 -1, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL|wx.ALL)
|
14
|
390 self.layout[self.id].Add(self.delete[self.id], -1, wx.EXPAND)
|
28
|
391 self.layout[self.id].Add(self.defaultcheck[self.id],
|
|
392 -1, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL|wx.ALL)
|
14
|
393 self.layout[self.id].Add(self.default[self.id], -1, wx.EXPAND)
|
|
394 self.layout[self.id].AddGrowableCol(1)
|
|
395 self.container[self.id].Add(self.layout[self.id], -1, wx.EXPAND)
|
|
396 #Button Events
|
|
397 self.Bind(wx.EVT_BUTTON, self.RefreshRepo, self.pull[self.id])
|
|
398 self.Bind(wx.EVT_BUTTON, self.DelRepo, self.delete[self.id])
|
|
399 self.Bind(wx.EVT_CHECKBOX, self.SetDefault, self.defaultcheck[self.id])
|
|
400 self.sizers["repolist_layout"].Insert(0, self.container[self.id], -1, wx.EXPAND)
|
|
401 self.sizers['repolist_layout'].Layout()
|
28
|
402 self.Layout()
|
14
|
403
|
|
404 #Set Default Repo Button
|
28
|
405 capture = manifest.GetString('default', 'repo', '')
|
14
|
406 if capture != '':
|
|
407 for caught in self.uri:
|
|
408 if capture == self.uri[caught]: self.id = caught; pass
|
|
409 else: continue
|
|
410 self.defaultcheck[self.id].SetValue(True)
|
|
411
|
|
412 def AddRepo(self, event):
|
|
413 repo = self.texts['reponame'].GetValue(); repo = repo.replace(' ', '_'); repo = 'repo-' + repo
|
28
|
414 manifest.SetString('updaterepo', repo, '')
|
14
|
415 self.BuildRepoList(None)
|
|
416
|
|
417 def DelRepo(self, event):
|
|
418 self.id = self.delete_list[event.GetEventObject()]
|
|
419 self.sizers["repolist_layout"].Hide(self.container[self.id])
|
28
|
420 manifest.DelString('updaterepo', self.box_name[self.id])
|
14
|
421 try: del self.box_name[self.id]
|
|
422 except: pass
|
|
423 self.sizers['repolist_layout'].Layout()
|
28
|
424 self.repolist = manifest.PluginChildren('updaterepo')
|
14
|
425
|
|
426 def RefreshRepo(self, event):
|
|
427 self.id = self.pull_list[event.GetEventObject()]
|
28
|
428 manifest.SetString('updaterepo', str(self.box_name[self.id]), self.url[self.id].GetValue())
|
14
|
429 try: commands.pull(self.ui, self.r, self.url[self.id].GetValue(), rev='', update=False, force=True)
|
|
430 except: pass
|
|
431
|
|
432 def SetDefault(self, event):
|
|
433 self.id = self.defchecklist[event.GetEventObject()]
|
28
|
434 manifest.SetString('default', 'repo', self.uri[self.id])
|
14
|
435 for all in self.defaultcheck:
|
|
436 self.defaultcheck[all].SetValue(False)
|
|
437 self.defaultcheck[self.id].SetValue(True)
|
|
438
|
|
439 class Manifest(wx.Panel):
|
|
440 def __init__(self, parent):
|
|
441 wx.Panel.__init__(self, parent)
|
28
|
442 ### Status Bar ###
|
|
443 #statbar.SetStatusText('Create an Ignore List')
|
|
444 statbar.SetStatusText('New Status Bar')
|
14
|
445 self.ui = ui.ui()
|
|
446 self.repo = hg.repository(self.ui, ".")
|
|
447 self.c = self.repo.changectx('tip')
|
|
448 self.manifestlist = []
|
|
449 self.manifestlist = self.c.manifest().keys()
|
|
450 for mana in self.manifestlist: mana = os.sep + 'orpg' + os.sep + mana
|
|
451 self.manifestlist.sort()
|
28
|
452 self.SetBackgroundColour(wx.WHITE)
|
14
|
453 self.sizer = wx.GridBagSizer(hgap=1, vgap=1)
|
18
|
454 self.manifestlog = wx.CheckListBox( self, -1, wx.DefaultPosition, wx.DefaultSize,
|
|
455 self.manifestlist, wx.LC_REPORT|wx.SUNKEN_BORDER|wx.EXPAND|wx.LC_HRULES)
|
14
|
456 filename = 'ignorelist.txt'
|
18
|
457 self.filename = dir_struct["home"] + 'upmana' + os.sep + filename
|
|
458 component.get('validate').config_file(filename, "default_ignorelist.txt")
|
14
|
459 self.mana = self.LoadDoc()
|
|
460 self.manifestlog.Bind(wx.EVT_CHECKLISTBOX, self.GetChecked)
|
|
461 self.sizer.Add(self.manifestlog, (0,0), flag=wx.EXPAND)
|
28
|
462 self.sizer.AddGrowableCol(0)
|
14
|
463 self.sizer.AddGrowableRow(0)
|
28
|
464 self.SetSizer(self.sizer)
|
14
|
465 self.SetAutoLayout(True)
|
|
466
|
|
467 def GetChecked(self, event):
|
|
468 self.mana = []
|
|
469 for manifest in self.manifestlog.GetChecked(): self.mana.append(self.manifestlist[manifest])
|
|
470 self.SaveDoc()
|
|
471
|
|
472 def SaveDoc(self):
|
|
473 f = open(self.filename, "w")
|
|
474 for mana in self.mana: f.write(mana+'\n')
|
|
475 f.close()
|
|
476
|
|
477 def LoadDoc(self):
|
|
478 ignore = open(self.filename)
|
|
479 ignorelist = []
|
|
480 for i in ignore: ignorelist.append(str(i [:len(i)-1]))
|
|
481 for i in ignorelist: #Adds previously ignored files to manifestlistlog if they are not in changesets.
|
|
482 if self.c.manifest().has_key(i): continue
|
|
483 else: self.manifestlist.append(i); self.manifestlist.sort()
|
17
|
484 self.manifestlog = wx.CheckListBox( self, -1, wx.DefaultPosition, wx.DefaultSize, self.manifestlist,
|
|
485 wx.LC_REPORT|wx.SUNKEN_BORDER|wx.EXPAND|wx.LC_HRULES)
|
14
|
486 self.manifestlog.SetCheckedStrings(ignorelist)
|
|
487 manifest = ignore.readlines()
|
|
488 ignore.close()
|
|
489
|
|
490 class Control(wx.Panel):
|
|
491 def __init__(self, parent):
|
|
492 wx.Panel.__init__(self, parent)
|
28
|
493 ### Status Bar ###
|
|
494 #statbar.SetStatusText('Advanced Controls & Rollback')
|
|
495 statbar.SetStatusText('New Status Bar')
|
18
|
496 ### Control Panel
|
|
497 self.ui = ui.ui()
|
|
498 self.repo = hg.repository(self.ui, ".")
|
|
499 self.c = self.repo.changectx('tip')
|
28
|
500 self.parent = parent
|
18
|
501 #logger.debug("Enter updaterFrame") #Need to set logging level
|
|
502
|
|
503 self.get_packages()
|
28
|
504 self.SetBackgroundColour(wx.WHITE)
|
18
|
505 self.sizer = wx.GridBagSizer(hgap=1, vgap=1)
|
|
506 self.buttons = {}
|
28
|
507
|
18
|
508 ## Changelog / File List
|
|
509 changelogcp = wx.Panel(self)
|
|
510 self.changelogcp = wx.GridBagSizer(hgap=1, vgap=1)
|
|
511 self.changelog = wx.TextCtrl(changelogcp, wx.ID_ANY, size=wx.DefaultSize, style=wx.TE_MULTILINE | wx.TE_READONLY)
|
|
512 self.filelist = wx.TextCtrl(changelogcp, wx.ID_ANY, size=wx.DefaultSize, style=wx.TE_MULTILINE | wx.TE_READONLY)
|
|
513 self.changelogcp.Add(self.changelog, (0,0), flag=wx.EXPAND)
|
|
514 self.changelogcp.Add(self.filelist, (1,0), flag=wx.EXPAND)
|
|
515 changelogcp.SetSizer(self.changelogcp)
|
|
516 self.changelogcp.AddGrowableCol(0)
|
|
517 self.changelogcp.AddGrowableRow(0)
|
|
518 self.changelogcp.AddGrowableRow(1)
|
|
519 changelogcp.SetAutoLayout(True)
|
|
520
|
|
521 ## Branches / Revisions
|
|
522 branchcp = wx.Panel(self)
|
27
|
523 self.current = self.repo.dirstate.branch()
|
18
|
524 self.branchcp = wx.GridBagSizer(hgap=1, vgap=1)
|
|
525 self.branches = wx.Choice(branchcp, wx.ID_ANY, choices=self.package_list)
|
27
|
526 self.branches.SetSelection(self.package_list.index(self.current))
|
18
|
527 self.branch_txt = wx.StaticText(branchcp, wx.ID_ANY, "Branches")
|
|
528 self.branchcp.Add(self.branches, (0,0))
|
|
529 self.branchcp.Add(self.branch_txt, (0,1), flag=wx.ALIGN_CENTER_VERTICAL)
|
|
530 branchcp.SetSizer(self.branchcp)
|
|
531 branchcp.SetAutoLayout(True)
|
|
532
|
|
533 revlistcp = wx.Panel(self)
|
|
534 self.revlistcp = wx.GridBagSizer(hgap=2, vgap=2)
|
|
535 self.revlist = wx.ListCtrl(revlistcp, -1, wx.DefaultPosition, size=wx.DefaultSize,
|
|
536 style=wx.LC_REPORT|wx.SUNKEN_BORDER|wx.LC_HRULES)
|
|
537 self.revlist.InsertColumn(0, 'Revs')
|
|
538 self.revlist.InsertColumn(1, 'Changeset')
|
|
539 self.revlist.SetColumnWidth(0, -1)
|
|
540 self.revlist.SetColumnWidth(1, -1)
|
|
541 self.revlist.Refresh()
|
|
542 self.revlistcp.Add(self.revlist, (0,0), flag=wx.EXPAND)
|
|
543 revlistcp.SetSizer(self.revlistcp)
|
|
544 self.revlistcp.AddGrowableCol(0)
|
|
545 self.revlistcp.AddGrowableRow(0)
|
|
546 self.revlistcp.AddGrowableRow(1)
|
|
547 revlistcp.SetAutoLayout(True)
|
|
548
|
|
549 ## Control Panel
|
|
550 cp = wx.Panel(self)
|
|
551 self.cp = wx.GridBagSizer(hgap=1, vgap=1)
|
|
552 self.buttons['update'] = wx.Button(cp, wx.ID_ANY, "Revision Update")
|
|
553 self.buttons['delete'] = wx.Button(cp, wx.ID_ANY, "Delete Branch")
|
28
|
554 self.cp.Add(self.buttons['update'], (0,0))
|
18
|
555 self.cp.Add(self.buttons['delete'], (0,1))
|
|
556 cp.SetSizer(self.cp)
|
|
557 cp.SetAutoLayout(True)
|
28
|
558
|
18
|
559 self.sizer.Add(changelogcp, (0,0), span=(3,1), flag=wx.EXPAND)
|
|
560 self.sizer.Add(branchcp, (0,1), span=(1,1))
|
|
561 self.sizer.Add(revlistcp, (2,1), span=(1,1), flag=wx.EXPAND)
|
28
|
562 self.sizer.Add(cp, (1,1), span=(1,1))
|
18
|
563
|
28
|
564 self.buttons['delete'].Disable()
|
18
|
565 self.sizer.AddGrowableCol(0)
|
28
|
566 self.sizer.AddGrowableCol(1)
|
|
567 self.sizer.AddGrowableRow(2)
|
|
568 self.SetSizer(self.sizer)
|
18
|
569 self.SetAutoLayout(True)
|
|
570
|
|
571 self.currev = self.repo.changelog.rev(self.repo.branchtags()[self.current])
|
|
572 self.RevInfo(self.currev)
|
|
573 self.revlist.Select(self.revlist.FindItem(0, str(self.currev), 1))
|
|
574 self.BranchInfo(self.current)
|
|
575 self.Bind(wx.EVT_CHOICE, self.PackageSet)
|
|
576 self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.RevSet)
|
|
577 self.Bind(wx.EVT_BUTTON, self.RevUpdate, self.buttons['update'])
|
28
|
578
|
|
579
|
18
|
580 def PackageSet(self, event):
|
|
581 self.current = self.branches.GetStringSelection()
|
|
582 branches = self.repo.branchtags()
|
|
583 heads = dict.fromkeys(self.repo.heads(), 1)
|
|
584 l = [((n in heads), self.repo.changelog.rev(n), n, t) for t, n in branches.items()]
|
|
585 if self.current != type:
|
|
586 heads = dict.fromkeys(self.repo.heads(), self.repo.branchtags())
|
|
587 branches = dict.copy(self.repo.branchtags())
|
|
588 self.BranchInfo(self.current)
|
|
589 self.RevInfo(self.current)
|
|
590
|
|
591 def RevSet(self, event):
|
|
592 self.currev = self.revlist.GetItemText( self.revlist.GetFirstSelected() )
|
|
593 i = event.GetIndex()
|
|
594 self.revlist.Select(i, True)
|
|
595 self.revlist.Focus(i)
|
22
|
596 self.BranchInfo(self.current)
|
18
|
597 if self.currev != self.revlist.GetItemText( self.revlist.GetFirstSelected() ):
|
|
598 self.RevInfo(self.currev)
|
|
599
|
|
600 def RevInfo(self, rev):
|
|
601 self.revlist.DeleteAllItems()
|
|
602 self.revlist_a = []; self.revlist_b = {}
|
|
603 for heads in self.repo.changelog.reachable(self.repo.branchtags()[self.current]):
|
|
604 self.revlist_a.append(str(self.repo.changelog.rev(heads)))
|
|
605 self.revlist_b[str(self.repo.changelog.rev(heads))] = str(self.repo.changectx(heads))
|
|
606 self.revlist_a.sort()
|
|
607 for i in self.revlist_a:
|
|
608 self.revlist.InsertStringItem(0, str(i), 0 )
|
|
609 self.revlist.SetStringItem(0, 1, self.revlist_b[i])
|
|
610 self.revlist.SetColumnWidth(0, -1)
|
|
611 self.revlist.SetColumnWidth(1, -1)
|
|
612 self.revlist.Refresh()
|
|
613 self.BranchInfo(self.current)
|
|
614
|
|
615 def BranchInfo(self, branch):
|
|
616 rs = self.repo.changectx( self.currev ).changeset()
|
|
617 self.changelog.SetValue('')
|
|
618 changelog = rs[4]
|
|
619 self.changelog.AppendText(changelog + '\n')
|
|
620 self.filelist.SetValue('')
|
|
621 self.filelist.AppendText("Currently selected branch: " + branch + "\n\nAuthor: "+rs[1]+"\n\n")
|
|
622 self.filelist.AppendText("Files Modified (in update): \n")
|
|
623 for f in rs[3]: self.filelist.AppendText(f+"\n")
|
|
624
|
|
625 def DelBranch(self, event):
|
|
626 pass
|
|
627
|
|
628 def RevUpdate(self, event):
|
27
|
629 dlg = wx.MessageDialog(None, 'Revision Updates are recommended for Developers only.\n\nAre you sure to preform a Revision Update?\n\nNewer builds tend to have less bugs while older revisions may no longer function properly.', 'Expert Feature', wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION)
|
|
630 if dlg.ShowModal() == wx.ID_YES:
|
|
631 dlg.Destroy()
|
|
632 filename = 'ignorelist.txt'
|
|
633 self.filename = dir_struct["home"] + 'upmana' + os.sep + filename
|
|
634 component.get('validate').config_file(filename, "default_ignorelist.txt")
|
|
635 self.mana = self.LoadDoc()
|
|
636 temp = dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep
|
|
637 for ignore in self.ignorelist:
|
|
638 shutil.copy(ignore, temp + ignore.split('/')[len(ignore.split('/')) - 1])
|
|
639 hg.clean(self.repo, self.currev)
|
|
640 for ignore in self.ignorelist:
|
|
641 shutil.copyfile(temp + ignore.split('/')[len(ignore.split('/')) - 1], ignore)
|
|
642 os.remove(temp + ignore.split('/')[len(ignore.split('/')) - 1])
|
|
643 else:
|
|
644 dlg.Destroy(); pass
|
18
|
645
|
|
646 def LoadDoc(self):
|
31
|
647 manifest = open(self.filename)
|
18
|
648 self.ignorelist = []
|
31
|
649 ignore = manifest.readlines()
|
36
|
650 for i in ignore: self.ignorelist.append(str(i[:len(i)-1]))
|
31
|
651 manifest.close()
|
18
|
652
|
|
653 def get_packages(self, type=None):
|
28
|
654 #Can be cleaner
|
18
|
655 self.package_list = []
|
|
656 b = self.repo.branchtags()
|
|
657 heads = dict.fromkeys(self.repo.heads(), 1) #The code below looks superfluous but there is good info inside
|
|
658 l = [((n in heads), self.repo.changelog.rev(n), n, t) for t, n in b.items()]
|
|
659 l.sort()
|
|
660 l.reverse()
|
|
661 for ishead, r, n, t in l: self.package_list.append(t)
|
28
|
662
|
18
|
663 def get_package(self):
|
28
|
664 self.get_packages()
|
18
|
665 if self.package_list == None: return None
|
28
|
666 return None
|
|
667
|
|
668 class Help(wx.Panel):
|
|
669 def __init__(self, parent):
|
|
670 wx.Panel.__init__(self, parent)
|
|
671 sizer = wx.BoxSizer(wx.VERTICAL)
|
|
672 self.help = wx.TextCtrl(self, wx.ID_ANY, size=(-1, -1),
|
|
673 style=wx.TE_MULTILINE | wx.TE_READONLY)
|
|
674 sizer.Add(self.help, 1, wx.EXPAND)
|
|
675 self.build_help()
|
|
676 self.SetSizer(sizer)
|
|
677 self.Layout()
|
|
678
|
|
679 def build_help(self):
|
|
680 help = """'Traipse' OpenRPG Update Manager Help:
|
|
681 The Traipse Update Manager can be confusing at first glance. There is alot involved in the new addition so it is easy to by pass the finer details. This small page will help a new user understand how to use the new Update Manager to it's full capability.\n\n"""
|
|
682 self.help.AppendText(help)
|
|
683 help = """The Different Tabs: There are 5 different tabs available to users, and each tab has a different purpose. These five tabs are: Updater, Repos, Manifest, Control and Help.
|
|
684 ---
|
|
685
|
|
686 The Updater Tab:
|
|
687 The Updater tab is divided into three sections. The left section shows a description of the your current or selected version. The right top section shows the files that have been updated in your current or selected version. Underneath is a selection of buttons and check boxes.
|
|
688
|
|
689 Package Select:
|
|
690 When you press this button a small window pops up showing you the available packages to update too. You can select a package and the Updater's detail sections will reflect the change.
|
|
691
|
|
692 Update Now:
|
|
693 Press this button when you want to update to the selected package
|
|
694
|
|
695 Auto Update:
|
|
696 Check this if want to update when you start the software. You need to have a default Repository checked in the Repo tab.
|
|
697
|
|
698 No Update:
|
|
699 Check this if you do not want to see the Update Manager when you start the software.
|
|
700 ---\n\n"""
|
|
701 self.help.AppendText(help)
|
|
702 help = """The Repos Tab:
|
|
703 The Repos tab has two parts to it. The top most part is a section is where you name and create repositories. The second part shows you a list of all your available repositories.
|
|
704
|
|
705 What is a repostiory?
|
|
706 1: a place, room, or container where something is deposited or stored (Merriam-Webster). A repository, or repo for short, is a place to hold source code so others can download it.
|
|
707
|
|
708 Creating new Repos:
|
|
709 Creating a new repos is really easy. First you need to give your repo a name, any name will work, then press the New button. You will see that your named repo shows up in your list immediately.
|
|
710
|
|
711 You will then need to connect the named repo to a URL so you can download source code. Enter a URL (http://hg.assembla.com/traipse) into the new entry and press the Refresh button. This downloads the new source code to your computer only. Refreshing a repo does not update your software.
|
|
712
|
|
713 Default:
|
|
714 You can set any repo as your default repository. This is the repo the software will update from if you Auto Update.
|
|
715 ---\n\n"""
|
|
716 self.help.AppendText(help)
|
|
717 help = """The Manifest Tab:
|
|
718 The Manifest Tab is really easy to understand, it's just named differently. The manifest shows a list of all the files that are being tracked by your current package. Checking files in the list will place them into a list that prevents these files from being changed when you update to a new package.
|
|
719
|
|
720 The manifest can cause problems with compatibility if the newer source does not understand the unchanged files, so it would be smart to test out a new package in a different folder.
|
|
721 ---\n\n"""
|
|
722 self.help.AppendText(help)
|
|
723 help = """The Control Tab:
|
|
724 The control tab is recommended for developers only. The control tab contains the two details elements from the Updater tab and a new section that contains all of the revisions for your selected package.
|
|
725
|
|
726 You can select any of the available packages from the drop down and the list of revisions will change. You can also select any of the revisions in the list and the details on the left side will change to reflect the details of that revision.
|
|
727
|
|
728 You are also allowed to update to any of the selected revisions. Older revisions often times contain bugs and newer methods of coding, so revision updates commonly cause problems with software.
|
|
729
|
|
730 What is the Control Tab for?
|
|
731 The control tab is for developers who want to see how the source code has changed from revision to revision. When a user downloads the software they also download all past revisions made to that software. This tab allows users to roll back if a problem has been created with new source, or for developers they can watch the software evolve.
|
|
732 ---"""
|
|
733 self.help.AppendText(help)
|
|
734
|
|
735 class updaterFrame(wx.Frame):
|
14
|
736 def __init__(self, parent, title, openrpg, manifest, main):
|
17
|
737
|
28
|
738 wx.Frame.__init__(self, None, wx.ID_ANY, title, size=(600,500), style=wx.DEFAULT_FRAME_STYLE)
|
|
739 if wx.Platform == '__WXMSW__': icon = wx.Icon(dir_struct["icon"]+'d20.ico', wx.BITMAP_TYPE_ICO)
|
18
|
740 else: icon = wx.Icon(dir_struct["icon"]+"d20.xpm", wx.BITMAP_TYPE_XPM )
|
|
741
|
17
|
742 self.SetIcon(icon)
|
14
|
743 self.main = main
|
|
744 ####### Panel Stuff ######
|
|
745 p = wx.Panel(self)
|
|
746 nb = wx.Notebook(p)
|
|
747
|
28
|
748 global statbar
|
|
749 statbar = self.CreateStatusBar()
|
31
|
750 sys.stdout = Term2Win()
|
28
|
751 self.Centre()
|
|
752
|
14
|
753 # create the page windows as children of the notebook
|
31
|
754 self.page1 = Updater(nb, openrpg)
|
28
|
755 page2 = Repos(nb, openrpg)
|
14
|
756 page3 = Manifest(nb)
|
|
757 page4 = Control(nb)
|
28
|
758 page5 = Help(nb)
|
14
|
759
|
|
760 # add the pages to the notebook with the label to show on the tab
|
31
|
761 nb.AddPage(self.page1, "Updater")
|
14
|
762 nb.AddPage(page2, "Repos")
|
|
763 nb.AddPage(page3, "Manifest")
|
|
764 nb.AddPage(page4, "Control")
|
28
|
765 nb.AddPage(page5, 'Help')
|
14
|
766
|
|
767 # finally, put the notebook in a sizer for the panel to manage
|
|
768 # the layout
|
|
769 sizer = wx.BoxSizer()
|
|
770 sizer.Add(nb, 1, wx.EXPAND)
|
|
771 p.SetSizer(sizer)
|
28
|
772 p.Layout()
|
|
773 self.Refresh()
|
14
|
774 self.Bind(wx.EVT_CLOSE, self.OnClose)
|
28
|
775 component.add('upmana-win', self)
|
14
|
776
|
|
777 def OnClose(self, event):
|
|
778 if self.main == False: self.Destroy()
|
17
|
779 if self.main == True: self.Hide()
|
28
|
780
|
14
|
781 class updateApp(wx.App):
|
|
782 def OnInit(self):
|
31
|
783 self.main = False; self.autoUpdate = False; self.noUpdate = False
|
28
|
784 logger._set_log_to_console(False)
|
|
785 logger.note("Updater Start")
|
|
786 component.add('validate', validate)
|
31
|
787 self.updater = updaterFrame(self, "OpenRPG Update Manager 1.2",
|
28
|
788 component, manifest, self.main)
|
|
789 if manifest.GetString("updatemana", "auto_update", "") == 'on' and self.main == False:
|
31
|
790 self.AutoUpdate(); self.OnExit(); self.autoUpdate = True
|
14
|
791 else: pass
|
28
|
792 if manifest.GetString('updatemana', 'no_update', '') == 'on' and self.main == False:
|
31
|
793 self.OnExit(); self.noUpdate = True
|
14
|
794 else: pass
|
31
|
795 if not (self.autoUpdate or self.noUpdate):
|
|
796 try:
|
|
797 self.updater.Show()
|
|
798 self.updater.Fit()
|
|
799 if not self.main: self.updater.page1.UpdateCheck()
|
|
800 except: pass
|
14
|
801 return True
|
|
802
|
|
803 def AutoUpdate(self):
|
|
804 self.ui = ui.ui()
|
|
805 self.repo = hg.repository(self.ui, ".")
|
|
806 self.c = self.repo.changectx('tip')
|
|
807 self.current = self.repo.dirstate.branch()
|
|
808
|
31
|
809 capture = manifest.GetString('default', 'repo', '')
|
14
|
810 if capture != '':
|
31
|
811 try: commands.pull(self.ui, self.repo, capture, rev='', update=False, force=True)
|
|
812 except:
|
|
813 wx.MessageBox('No Connection Found. Skipping Auto Update!', 'Info')
|
|
814 return
|
14
|
815 filename = 'ignorelist.txt'
|
18
|
816 self.filename = dir_struct["home"] + 'upmana' + os.sep + filename
|
|
817 component.get('validate').config_file(filename, "default_ignorelist.txt")
|
31
|
818 self.mana = self.LoadDoc(); ignored = []
|
18
|
819 temp = dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep
|
16
|
820 for ignore in self.ignorelist:
|
28
|
821 if len(ignore.split('/')) > 1:
|
|
822 gets = 0; dir1 = ''
|
|
823 while gets != len(ignore.split('/'))-1:
|
|
824 dir1 += ignore.split('/')[gets] + os.sep
|
|
825 gets += 1
|
|
826 os.makedirs(temp+dir1)
|
31
|
827 ignoredfile = temp + dir1 + ignore.split('/')[len(ignore.split('/')) - 1]
|
|
828 ignored.append(ignoredfile)
|
|
829 shutil.copy(ignore, ignoredfile)
|
14
|
830 hg.clean(self.repo, self.current)
|
|
831 for ignore in self.ignorelist:
|
31
|
832 shutil.copyfile(ignored.index(ignore), ignore)
|
|
833 os.remove(ignored.index(ignore))
|
28
|
834 if len(ignore.split('/')) > 1:
|
|
835 gets = 0; dir1 = ''
|
|
836 while gets != len(ignore.split('/'))-1:
|
|
837 dir1 += ignore.split('/')[gets] + os.sep
|
|
838 gets += 1
|
|
839 os.removedirs(temp+dir1)
|
31
|
840 else: wx.MessageBox('Default Repo Not Found. Skipping Auto Update!', 'Info')
|
14
|
841
|
|
842 def LoadDoc(self):
|
31
|
843 manifest = open(self.filename)
|
14
|
844 self.ignorelist = []
|
31
|
845 ignore = manifest.readlines()
|
36
|
846 for i in ignore: self.ignorelist.append(str(i[:len(i)-1]))
|
31
|
847 manifest.close()
|
28
|
848
|
14
|
849 def OnExit(self):
|
18
|
850 imported = ['manifest', 'orpg.dirpath', 'orpg.orpgCore', 'orpg.orpg_version',
|
|
851 'orpg.tools.orpg_log', 'orpg.tools.orpg_log', 'orpg.orpg_xml', 'orpg.dirpath',
|
|
852 'orpg.dirpath', 'upmana.validate', 'mercurial.ui', 'mercurial.hg',
|
28
|
853 'mercurial.commands', 'mercurial.repo', 'mercurial.revlog', 'mercurial.cmdutil', 'shutil']
|
|
854 for name in imported:
|
14
|
855 if name in sys.modules: del sys.modules[name]
|
|
856
|
|
857 try: self.updater.Destroy()
|
|
858 except: pass
|