annotate upmana/updatemana.py @ 27:51428d30c59e ornery-orc

Traipse 'OpenRPG' {091003-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: Adds menu changes to draw attention to important updates, errors, or other events. Traipse URL is now included in the repos tab and is set as default. Fixes Copy for Windows and Linux (finally!!) users. Fixes incomplete update to Grid and List nodes. Fixes incomplete update to Chat Commands. Fixes problems with Remote Image Upload. Fixes Drop and Drag of Minis to Map. CherryPy can now use any image in the webfiles/ folder and sub-folders. CherryPy can now Drop and Drag Minis to the Map. Minor changes to Update Manager's GUI. Expert recommendation warning added to Revision Update. Step down compatibility with open_rpg & component added to orpgCore. Fixes CherryPit misspelling. Makes Traipse Suite 'Attention' item portable, and executes it on 'Critical' debug notices. Adds incomplete Shift + Enter to Text Entry, currently creates a 'Critical' warning. New default Lobby Map, designed for Traipse. Feel free to change it. Updates to Server GUI: * Admin can Ban from Backend. * Admin can Modify Ban List and Un Ban users. * Server GUI finds your Lobby Name * New users default as Lurker unless a Role is set Cleaner TraipseSuiteAttention portability and clean up in Main. Die Roll Commands addition from Core code allowing Math Ordering with ()'s New About Dialog. A more uniform About Dialog. Corrects image loading of duplicate images.
author sirebral
date Sat, 03 Oct 2009 18:49:37 -0500
parents 8b168989c344
children ff154cf3350c
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)
27
51428d30c59e Traipse 'OpenRPG' {091003-00}
sirebral
parents: 22
diff changeset
29 self.changelog = wx.TextCtrl(self, wx.ID_ANY, size=(300, -1), style=wx.TE_MULTILINE | wx.TE_READONLY)
17
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)
27
51428d30c59e Traipse 'OpenRPG' {091003-00}
sirebral
parents: 22
diff changeset
439 self.current = self.repo.dirstate.branch()
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
440 self.branchcp = wx.GridBagSizer(hgap=1, vgap=1)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
441 self.branches = wx.Choice(branchcp, wx.ID_ANY, choices=self.package_list)
27
51428d30c59e Traipse 'OpenRPG' {091003-00}
sirebral
parents: 22
diff changeset
442 self.branches.SetSelection(self.package_list.index(self.current))
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
443 self.branch_txt = wx.StaticText(branchcp, wx.ID_ANY, "Branches")
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
444 self.branchcp.Add(self.branches, (0,0))
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
445 self.branchcp.Add(self.branch_txt, (0,1), flag=wx.ALIGN_CENTER_VERTICAL)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
446 branchcp.SetSizer(self.branchcp)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
447 branchcp.SetAutoLayout(True)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
448
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
449 revlistcp = wx.Panel(self)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
450 self.revlistcp = wx.GridBagSizer(hgap=2, vgap=2)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
451 self.revlist = wx.ListCtrl(revlistcp, -1, wx.DefaultPosition, size=wx.DefaultSize,
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
452 style=wx.LC_REPORT|wx.SUNKEN_BORDER|wx.LC_HRULES)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
453 self.revlist.InsertColumn(0, 'Revs')
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
454 self.revlist.InsertColumn(1, 'Changeset')
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
455 self.revlist.SetColumnWidth(0, -1)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
456 self.revlist.SetColumnWidth(1, -1)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
457 self.revlist.Refresh()
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
458 self.revlistcp.Add(self.revlist, (0,0), flag=wx.EXPAND)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
459 revlistcp.SetSizer(self.revlistcp)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
460 self.revlistcp.AddGrowableCol(0)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
461 self.revlistcp.AddGrowableRow(0)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
462 self.revlistcp.AddGrowableRow(1)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
463 revlistcp.SetAutoLayout(True)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
464
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
465 ## Control Panel
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
466 cp = wx.Panel(self)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
467 self.cp = wx.GridBagSizer(hgap=1, vgap=1)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
468 self.buttons['update'] = wx.Button(cp, wx.ID_ANY, "Revision Update")
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
469 self.buttons['delete'] = wx.Button(cp, wx.ID_ANY, "Delete Branch")
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
470 self.cp.Add(self.buttons['update'], (0,0))
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
471 self.cp.Add(self.buttons['delete'], (0,1))
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
472 cp.SetSizer(self.cp)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
473 cp.SetAutoLayout(True)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
474
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
475 self.sizer.Add(changelogcp, (0,0), span=(3,1), flag=wx.EXPAND)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
476 self.sizer.Add(branchcp, (0,1), span=(1,1))
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
477 self.sizer.Add(revlistcp, (2,1), span=(1,1), flag=wx.EXPAND)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
478 self.sizer.Add(cp, (1,1), span=(1,1))
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
479
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
480 self.buttons['delete'].Disable()
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
481 self.sizer.AddGrowableCol(0)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
482 self.sizer.AddGrowableCol(1)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
483 self.sizer.AddGrowableRow(2)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
484 self.SetSizer(self.sizer)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
485 self.SetAutoLayout(True)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
486
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
487 self.currev = self.repo.changelog.rev(self.repo.branchtags()[self.current])
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
488 self.RevInfo(self.currev)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
489 self.revlist.Select(self.revlist.FindItem(0, str(self.currev), 1))
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
490 self.BranchInfo(self.current)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
491 self.Bind(wx.EVT_CHOICE, self.PackageSet)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
492 self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.RevSet)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
493 self.Bind(wx.EVT_BUTTON, self.RevUpdate, self.buttons['update'])
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
494
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
495
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
496 def PackageSet(self, event):
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
497 self.current = self.branches.GetStringSelection()
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
498 branches = self.repo.branchtags()
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
499 heads = dict.fromkeys(self.repo.heads(), 1)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
500 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
501 if self.current != type:
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
502 heads = dict.fromkeys(self.repo.heads(), self.repo.branchtags())
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
503 branches = dict.copy(self.repo.branchtags())
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
504 self.BranchInfo(self.current)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
505 self.RevInfo(self.current)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
506
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
507 def RevSet(self, event):
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
508 self.currev = self.revlist.GetItemText( self.revlist.GetFirstSelected() )
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
509 i = event.GetIndex()
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
510 self.revlist.Select(i, True)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
511 self.revlist.Focus(i)
22
8b168989c344 Traipse 'OpenRPG' {090827-04}
sirebral
parents: 18
diff changeset
512 self.BranchInfo(self.current)
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
513 if self.currev != self.revlist.GetItemText( self.revlist.GetFirstSelected() ):
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
514 self.RevInfo(self.currev)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
515
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
516 def RevInfo(self, rev):
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
517 self.revlist.DeleteAllItems()
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
518 self.revlist_a = []; self.revlist_b = {}
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
519 for heads in self.repo.changelog.reachable(self.repo.branchtags()[self.current]):
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
520 self.revlist_a.append(str(self.repo.changelog.rev(heads)))
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
521 self.revlist_b[str(self.repo.changelog.rev(heads))] = str(self.repo.changectx(heads))
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
522 self.revlist_a.sort()
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
523 for i in self.revlist_a:
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
524 self.revlist.InsertStringItem(0, str(i), 0 )
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
525 self.revlist.SetStringItem(0, 1, self.revlist_b[i])
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
526 self.revlist.SetColumnWidth(0, -1)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
527 self.revlist.SetColumnWidth(1, -1)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
528 self.revlist.Refresh()
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
529 self.BranchInfo(self.current)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
530
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
531 def BranchInfo(self, branch):
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
532 rs = self.repo.changectx( self.currev ).changeset()
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
533 self.changelog.SetValue('')
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
534 changelog = rs[4]
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
535 self.changelog.AppendText(changelog + '\n')
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
536 self.filelist.SetValue('')
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
537 self.filelist.AppendText("Currently selected branch: " + branch + "\n\nAuthor: "+rs[1]+"\n\n")
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
538 self.filelist.AppendText("Files Modified (in update): \n")
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
539 for f in rs[3]: self.filelist.AppendText(f+"\n")
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
540
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
541 def DelBranch(self, event):
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
542 pass
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
543
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
544 def RevUpdate(self, event):
27
51428d30c59e Traipse 'OpenRPG' {091003-00}
sirebral
parents: 22
diff changeset
545 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)
51428d30c59e Traipse 'OpenRPG' {091003-00}
sirebral
parents: 22
diff changeset
546 if dlg.ShowModal() == wx.ID_YES:
51428d30c59e Traipse 'OpenRPG' {091003-00}
sirebral
parents: 22
diff changeset
547 dlg.Destroy()
51428d30c59e Traipse 'OpenRPG' {091003-00}
sirebral
parents: 22
diff changeset
548 filename = 'ignorelist.txt'
51428d30c59e Traipse 'OpenRPG' {091003-00}
sirebral
parents: 22
diff changeset
549 self.filename = dir_struct["home"] + 'upmana' + os.sep + filename
51428d30c59e Traipse 'OpenRPG' {091003-00}
sirebral
parents: 22
diff changeset
550 component.get('validate').config_file(filename, "default_ignorelist.txt")
51428d30c59e Traipse 'OpenRPG' {091003-00}
sirebral
parents: 22
diff changeset
551 self.mana = self.LoadDoc()
51428d30c59e Traipse 'OpenRPG' {091003-00}
sirebral
parents: 22
diff changeset
552 temp = dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep
51428d30c59e Traipse 'OpenRPG' {091003-00}
sirebral
parents: 22
diff changeset
553 for ignore in self.ignorelist:
51428d30c59e Traipse 'OpenRPG' {091003-00}
sirebral
parents: 22
diff changeset
554 shutil.copy(ignore, temp + ignore.split('/')[len(ignore.split('/')) - 1])
51428d30c59e Traipse 'OpenRPG' {091003-00}
sirebral
parents: 22
diff changeset
555 hg.clean(self.repo, self.currev)
51428d30c59e Traipse 'OpenRPG' {091003-00}
sirebral
parents: 22
diff changeset
556 for ignore in self.ignorelist:
51428d30c59e Traipse 'OpenRPG' {091003-00}
sirebral
parents: 22
diff changeset
557 shutil.copyfile(temp + ignore.split('/')[len(ignore.split('/')) - 1], ignore)
51428d30c59e Traipse 'OpenRPG' {091003-00}
sirebral
parents: 22
diff changeset
558 os.remove(temp + ignore.split('/')[len(ignore.split('/')) - 1])
51428d30c59e Traipse 'OpenRPG' {091003-00}
sirebral
parents: 22
diff changeset
559 else:
51428d30c59e Traipse 'OpenRPG' {091003-00}
sirebral
parents: 22
diff changeset
560 dlg.Destroy(); pass
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
561
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
562 def LoadDoc(self):
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
563 ignore = open(self.filename)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
564 self.ignorelist = []
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
565 for i in ignore: self.ignorelist.append(str(i [:len(i)-1]))
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
566 manifest = ignore.readlines()
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
567 ignore.close()
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
568
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
569 def get_packages(self, type=None):
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
570 #Fixed and ready for Test. Can be cleaner
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
571 self.package_list = []
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
572 b = self.repo.branchtags()
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
573 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
574 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
575 l.sort()
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
576 l.reverse()
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
577 for ishead, r, n, t in l: self.package_list.append(t)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
578
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
579 def get_package(self):
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
580 self.get_packages()
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
581 if self.package_list == None: return None
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
582 return None
14
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
583
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
584 class updaterFrame(wx.Frame):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
585 def __init__(self, parent, title, openrpg, manifest, main):
17
265b987cce4f Traipse 'OpenRPG' {090813-00}
sirebral
parents: 16
diff changeset
586
265b987cce4f Traipse 'OpenRPG' {090813-00}
sirebral
parents: 16
diff changeset
587 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
588 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
589 else: icon = wx.Icon(dir_struct["icon"]+"d20.xpm", wx.BITMAP_TYPE_XPM )
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
590
17
265b987cce4f Traipse 'OpenRPG' {090813-00}
sirebral
parents: 16
diff changeset
591 self.SetIcon(icon)
14
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
592 self.CenterOnScreen()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
593 self.main = main
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
594 ####### Panel Stuff ######
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
595 p = wx.Panel(self)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
596 nb = wx.Notebook(p)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
597
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
598 # create the page windows as children of the notebook
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
599 page1 = Updater(nb, openrpg, manifest)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
600 page2 = Repos(nb, openrpg, manifest)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
601 page3 = Manifest(nb)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
602 page4 = Control(nb)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
603
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
604 # add the pages to the notebook with the label to show on the tab
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
605 nb.AddPage(page1, "Updater")
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
606 nb.AddPage(page2, "Repos")
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
607 nb.AddPage(page3, "Manifest")
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
608 nb.AddPage(page4, "Control")
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
609
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
610 # finally, put the notebook in a sizer for the panel to manage
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
611 # the layout
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
612 sizer = wx.BoxSizer()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
613 sizer.Add(nb, 1, wx.EXPAND)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
614 p.SetSizer(sizer)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
615 self.Bind(wx.EVT_CLOSE, self.OnClose)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
616
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
617 def OnClose(self, event):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
618 if self.main == False: self.Destroy()
17
265b987cce4f Traipse 'OpenRPG' {090813-00}
sirebral
parents: 16
diff changeset
619 if self.main == True: self.Hide()
14
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
620
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
621 class updateApp(wx.App):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
622 def OnInit(self):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
623 self.main = False
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
624 logger._set_log_to_console(False)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
625 logger.note("Updater Start")
14
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
626 self.manifest = manifest.ManifestChanges()
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
627 component.add('validate', validate)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
628 self.updater = updaterFrame(self, "OpenRPG Update Manager 0.8 (open beta)",
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
629 component, self.manifest, self.main)
14
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
630 if self.manifest.GetString("updatemana", "auto_update", "") == 'on' and self.main == False:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
631 self.AutoUpdate(); self.OnExit()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
632 else: pass
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
633 if self.manifest.GetString('updatemana', 'no_update', '') == 'on' and self.main == False:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
634 self.OnExit()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
635 else: pass
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
636 try:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
637 self.updater.Show()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
638 self.updater.Fit()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
639 except: pass
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
640 return True
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
641
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
642 def AutoUpdate(self):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
643 self.ui = ui.ui()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
644 self.repo = hg.repository(self.ui, ".")
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
645 self.c = self.repo.changectx('tip')
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
646 self.current = self.repo.dirstate.branch()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
647
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
648 capture = self.manifest.GetString('updaterepo', 'default', '')
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
649 if capture != '':
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
650 commands.pull(self.ui, self.repo, capture, rev='', update=False, force=True)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
651 filename = 'ignorelist.txt'
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
652 self.filename = dir_struct["home"] + 'upmana' + os.sep + filename
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
653 component.get('validate').config_file(filename, "default_ignorelist.txt")
14
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
654 self.mana = self.LoadDoc()
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
655 temp = dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep
16
281ca8daa911 Traipse 'OpenRPG' {090808-00}
sirebral
parents: 14
diff changeset
656 for ignore in self.ignorelist:
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
657 shutil.copy(ignore, temp + ignore.split('/')[len(ignore.split('/')) - 1])
14
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
658 hg.clean(self.repo, self.current)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
659 for ignore in self.ignorelist:
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
660 shutil.copyfile(temp + ignore.split('/')[len(ignore.split('/')) - 1], ignore)
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
661 os.remove(temp + ignore.split('/')[len(ignore.split('/')) - 1])
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
662 else: wx.MessageBox('No default Rpository set. Skipping Auto Update!', 'Info')
14
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
663
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
664 def LoadDoc(self):
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
665 ignore = open(self.filename)
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
666 self.ignorelist = []
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
667 for i in ignore: self.ignorelist.append(str(i [:len(i)-1]))
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
668 manifest = ignore.readlines()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
669 ignore.close()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
670
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
671 def OnExit(self):
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
672 imported = ['manifest', 'orpg.dirpath', 'orpg.orpgCore', 'orpg.orpg_version',
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
673 'orpg.tools.orpg_log', 'orpg.tools.orpg_log', 'orpg.orpg_xml', 'orpg.dirpath',
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
674 'orpg.dirpath', 'upmana.validate', 'mercurial.ui', 'mercurial.hg',
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 17
diff changeset
675 'mercurial.commands', 'mercurial.repo', 'mercurial.revlog', 'mercurial.cmdutil', 'shutil']
14
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
676 for name in imported:
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
677 if name in sys.modules: del sys.modules[name]
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
678
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
679 try: self.updater.Destroy()
e8260c6cb309 Traipse 'OpenRPG' {090806-00}
sirebral
parents:
diff changeset
680 except: pass