Mercurial > traipse_dev
comparison upmana/updatemana.py @ 66:c54768cffbd4 ornery-dev
Traipse Dev 'OpenRPG' {090818-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:
*Unstable*
This is the first wave of Code Refinement updates. Includes new material from Core Beta; new debugger material (partially implemented), beginnings of switch to etree, TerminalWriter, and a little more. open_rpg has been renamed to component; functioning now as component.get(), component.add(), component.delete(). This version has known bugs, specifically with the gametree and nodes. I think the XML files where not removed during testing of Core and switching back.
author | sirebral |
---|---|
date | Tue, 18 Aug 2009 06:33:37 -0500 |
parents | e8029caed892 |
children | 52a5fa913008 |
comparison
equal
deleted
inserted
replaced
65:4840657c23c5 | 66:c54768cffbd4 |
---|---|
1 import wx | 1 import wx |
2 import manifest | 2 import manifest |
3 import orpg.dirpath | 3 from orpg.dirpath import dir_struct |
4 from orpg.orpgCore import * | 4 from orpg.orpgCore import * |
5 import orpg.orpg_version | 5 import orpg.orpg_version |
6 import orpg.tools.orpg_log | 6 import orpg.tools.orpg_log |
7 import orpg.orpg_xml | 7 import orpg.orpg_xml |
8 import orpg.dirpath | 8 from orpg.dirpath import dir_struct |
9 import upmana.validate | 9 import upmana.validate |
10 import tempfile | 10 import tempfile |
11 import shutil | 11 import shutil |
12 from mercurial import ui, hg, commands, repo, revlog, cmdutil, util | 12 from mercurial import ui, hg, commands, repo, revlog, cmdutil, util |
13 | 13 |
14 | 14 |
15 class Updater(wx.Panel): | 15 class Updater(wx.Panel): |
16 def __init__(self, parent, open_rpg, manifest): | 16 def __init__(self, parent, component, manifest): |
17 wx.Panel.__init__(self, parent) | 17 wx.Panel.__init__(self, parent) |
18 | 18 |
19 ### Update Manager | 19 ### Update Manager |
20 self.ui = ui.ui() | 20 self.ui = ui.ui() |
21 self.repo = hg.repository(self.ui, ".") | 21 self.repo = hg.repository(self.ui, ".") |
22 self.c = self.repo.changectx('tip') | 22 self.c = self.repo.changectx('tip') |
23 self.manifest = manifest | 23 self.manifest = manifest |
24 self.xml = open_rpg.get_component('xml') | 24 self.xml = component.get('xml') |
25 self.dir_struct = open_rpg.get_component("dir_struct") | |
26 self.parent = parent | 25 self.parent = parent |
27 self.log = open_rpg.get_component("log") | 26 self.log = component.get("log") |
28 self.log.log("Enter updaterFrame", ORPG_DEBUG) | 27 self.log.log("Enter updaterFrame", ORPG_DEBUG) |
29 self.SetBackgroundColour(wx.WHITE) | 28 self.SetBackgroundColour(wx.WHITE) |
30 self.sizer = wx.GridBagSizer(hgap=1, vgap=1) | 29 self.sizer = wx.GridBagSizer(hgap=1, vgap=1) |
31 self.changelog = wx.TextCtrl(self, wx.ID_ANY, size=(325, -1), style=wx.TE_MULTILINE | wx.TE_READONLY) | 30 self.changelog = wx.TextCtrl(self, wx.ID_ANY, size=(325, -1), style=wx.TE_MULTILINE | wx.TE_READONLY) |
32 self.filelist = wx.TextCtrl(self, wx.ID_ANY, size=(275, 300), style=wx.TE_MULTILINE | wx.TE_READONLY) | 31 self.filelist = wx.TextCtrl(self, wx.ID_ANY, size=(275, 300), style=wx.TE_MULTILINE | wx.TE_READONLY) |
93 self.ui = ui.ui() | 92 self.ui = ui.ui() |
94 self.repo = hg.repository(self.ui, ".") | 93 self.repo = hg.repository(self.ui, ".") |
95 self.c = self.repo.changectx('tip') | 94 self.c = self.repo.changectx('tip') |
96 | 95 |
97 filename = 'ignorelist.txt' | 96 filename = 'ignorelist.txt' |
98 self.filename = orpg.dirpath.dir_struct["home"] + 'upmana' + os.sep + filename | 97 self.filename = dir_struct["home"] + 'upmana' + os.sep + filename |
99 upmana.validate.Validate(orpg.dirpath.dir_struct["home"] + 'upmana' + os.sep).config_file(filename, "default_ignorelist.txt") | 98 upmana.validate.Validate(dir_struct["home"] + 'upmana' + os.sep).config_file(filename, "default_ignorelist.txt") |
100 self.mana = self.LoadDoc() | 99 self.mana = self.LoadDoc() |
101 for ignore in self.ignorelist: | 100 for ignore in self.ignorelist: |
102 shutil.copy(ignore, orpg.dirpath.dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep +ignore.split('/')[len(ignore.split('/')) - 1]) | 101 shutil.copy(ignore, dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep +ignore.split('/')[len(ignore.split('/')) - 1]) |
103 hg.clean(self.repo, self.current) | 102 hg.clean(self.repo, self.current) |
104 for ignore in self.ignorelist: | 103 for ignore in self.ignorelist: |
105 shutil.copyfile(orpg.dirpath.dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep + ignore.split('/')[len(ignore.split('/')) - 1], ignore) | 104 shutil.copyfile(dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep + ignore.split('/')[len(ignore.split('/')) - 1], ignore) |
106 os.remove(orpg.dirpath.dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep + ignore.split('/')[len(ignore.split('/')) - 1]) | 105 os.remove(dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep + ignore.split('/')[len(ignore.split('/')) - 1]) |
107 | 106 |
108 def LoadDoc(self): | 107 def LoadDoc(self): |
109 ignore = open(self.filename) | 108 ignore = open(self.filename) |
110 self.ignorelist = [] | 109 self.ignorelist = [] |
111 for i in ignore: self.ignorelist.append(str(i [:len(i)-1])) | 110 for i in ignore: self.ignorelist.append(str(i [:len(i)-1])) |
117 except: | 116 except: |
118 print 'Fail'; exit() | 117 print 'Fail'; exit() |
119 | 118 |
120 def ChooseBranch(self, evt=None): | 119 def ChooseBranch(self, evt=None): |
121 dlg = wx.Dialog(self, wx.ID_ANY, "Package Selector", style=wx.DEFAULT_DIALOG_STYLE) | 120 dlg = wx.Dialog(self, wx.ID_ANY, "Package Selector", style=wx.DEFAULT_DIALOG_STYLE) |
122 if wx.Platform == '__WXMSW__': icon = wx.Icon(self.dir_struct["icon"]+'d20.ico', wx.BITMAP_TYPE_ICO) | 121 if wx.Platform == '__WXMSW__': icon = wx.Icon(dir_struct["icon"]+'d20.ico', wx.BITMAP_TYPE_ICO) |
123 else: icon = wx.Icon(self.dir_struct["icon"]+"d20.xpm", wx.BITMAP_TYPE_XPM ) | 122 else: icon = wx.Icon(dir_struct["icon"]+"d20.xpm", wx.BITMAP_TYPE_XPM ) |
124 dlg.SetIcon(icon) | 123 dlg.SetIcon(icon) |
125 | 124 |
126 self.ui = ui.ui() | 125 self.ui = ui.ui() |
127 self.repo = hg.repository(self.ui, ".") | 126 self.repo = hg.repository(self.ui, ".") |
128 self.c = self.repo.changectx('tip') | 127 self.c = self.repo.changectx('tip') |
371 self.SetBackgroundColour(wx.WHITE) | 370 self.SetBackgroundColour(wx.WHITE) |
372 self.sizer = wx.GridBagSizer(hgap=1, vgap=1) | 371 self.sizer = wx.GridBagSizer(hgap=1, vgap=1) |
373 self.manifestlog = wx.CheckListBox( self, -1, wx.DefaultPosition, wx.DefaultSize, self.manifestlist, | 372 self.manifestlog = wx.CheckListBox( self, -1, wx.DefaultPosition, wx.DefaultSize, self.manifestlist, |
374 wx.LC_REPORT|wx.SUNKEN_BORDER|wx.EXPAND|wx.LC_HRULES) | 373 wx.LC_REPORT|wx.SUNKEN_BORDER|wx.EXPAND|wx.LC_HRULES) |
375 filename = 'ignorelist.txt' | 374 filename = 'ignorelist.txt' |
376 self.filename = orpg.dirpath.dir_struct["home"] + 'upmana' + os.sep + filename | 375 self.filename = dir_struct["home"] + 'upmana' + os.sep + filename |
377 upmana.validate.Validate(orpg.dirpath.dir_struct["home"] + 'upmana' + os.sep).config_file(filename, "default_ignorelist.txt") | 376 upmana.validate.Validate(dir_struct["home"] + 'upmana' + os.sep).config_file(filename, "default_ignorelist.txt") |
378 self.mana = self.LoadDoc() | 377 self.mana = self.LoadDoc() |
379 self.manifestlog.Bind(wx.EVT_CHECKLISTBOX, self.GetChecked) | 378 self.manifestlog.Bind(wx.EVT_CHECKLISTBOX, self.GetChecked) |
380 self.sizer.Add(self.manifestlog, (0,0), flag=wx.EXPAND) | 379 self.sizer.Add(self.manifestlog, (0,0), flag=wx.EXPAND) |
381 self.sizer.AddGrowableCol(0) | 380 self.sizer.AddGrowableCol(0) |
382 self.sizer.AddGrowableRow(0) | 381 self.sizer.AddGrowableRow(0) |
411 wx.Panel.__init__(self, parent) | 410 wx.Panel.__init__(self, parent) |
412 | 411 |
413 | 412 |
414 class updaterFrame(wx.Frame): | 413 class updaterFrame(wx.Frame): |
415 def __init__(self, parent, title, openrpg, manifest, main): | 414 def __init__(self, parent, title, openrpg, manifest, main): |
416 self.dir_struct = open_rpg.get_component("dir_struct") | 415 dir_struct = component.get("dir_struct") |
417 | 416 |
418 wx.Frame.__init__(self, None, wx.ID_ANY, title, size=(600,480), style=wx.DEFAULT_FRAME_STYLE) | 417 wx.Frame.__init__(self, None, wx.ID_ANY, title, size=(600,480), style=wx.DEFAULT_FRAME_STYLE) |
419 if wx.Platform == '__WXMSW__': icon = wx.Icon(self.dir_struct["icon"]+'d20.ico', wx.BITMAP_TYPE_ICO) | 418 if wx.Platform == '__WXMSW__': icon = wx.Icon(dir_struct["icon"]+'d20.ico', wx.BITMAP_TYPE_ICO) |
420 else: icon = wx.Icon(self.dir_struct["icon"]+"d20.xpm", wx.BITMAP_TYPE_XPM ) | 419 else: icon = wx.Icon(dir_struct["icon"]+"d20.xpm", wx.BITMAP_TYPE_XPM ) |
421 self.SetIcon(icon) | 420 self.SetIcon(icon) |
422 | 421 |
423 self.CenterOnScreen() | 422 self.CenterOnScreen() |
424 self.main = main | 423 self.main = main |
425 ####### Panel Stuff ###### | 424 ####### Panel Stuff ###### |
449 if self.main == False: self.Destroy() | 448 if self.main == False: self.Destroy() |
450 if self.main == True: self.Hide() | 449 if self.main == True: self.Hide() |
451 | 450 |
452 class updateApp(wx.App): | 451 class updateApp(wx.App): |
453 def OnInit(self): | 452 def OnInit(self): |
454 self.open_rpg = open_rpg | 453 self.component = component |
455 self.main = False | 454 self.main = False |
456 self.log = orpg.tools.orpg_log.orpgLog(orpg.dirpath.dir_struct["user"] + "runlogs/") | 455 self.log = orpg.tools.orpg_log.orpgLog(dir_struct["user"] + "runlogs/") |
457 self.log.setLogToConsol(False) | 456 self.log.setLogToConsol(False) |
458 self.log.log("Updater Start", ORPG_NOTE) | 457 self.log.log("Updater Start", ORPG_NOTE) |
459 self.manifest = manifest.ManifestChanges() | 458 self.manifest = manifest.ManifestChanges() |
460 self.open_rpg.add_component("log", self.log) | 459 self.component.add("log", self.log) |
461 self.open_rpg.add_component("xml", orpg.orpg_xml) | 460 self.component.add("xml", orpg.orpg_xml) |
462 self.open_rpg.add_component("dir_struct", orpg.dirpath.dir_struct) | 461 self.component.add("dir_struct", dir_struct) |
463 self.validate = upmana.validate.Validate() | 462 self.validate = upmana.validate.Validate() |
464 self.open_rpg.add_component("validate", self.validate) | 463 self.component.add("validate", self.validate) |
465 self.updater = updaterFrame(self, "OpenRPG Update Manager 0.7.2 (open beta)", self.open_rpg, self.manifest, self.main) | 464 self.updater = updaterFrame(self, "OpenRPG Update Manager 0.7.2 (open beta)", self.component, self.manifest, self.main) |
466 if self.manifest.GetString("updatemana", "auto_update", "") == 'on' and self.main == False: | 465 if self.manifest.GetString("updatemana", "auto_update", "") == 'on' and self.main == False: |
467 self.AutoUpdate(); self.OnExit() | 466 self.AutoUpdate(); self.OnExit() |
468 else: pass | 467 else: pass |
469 if self.manifest.GetString('updatemana', 'no_update', '') == 'on' and self.main == False: | 468 if self.manifest.GetString('updatemana', 'no_update', '') == 'on' and self.main == False: |
470 self.OnExit() | 469 self.OnExit() |
483 | 482 |
484 capture = self.manifest.GetString('updaterepo', 'default', '') | 483 capture = self.manifest.GetString('updaterepo', 'default', '') |
485 if capture != '': | 484 if capture != '': |
486 commands.pull(self.ui, self.repo, capture, rev='', update=False, force=True) | 485 commands.pull(self.ui, self.repo, capture, rev='', update=False, force=True) |
487 filename = 'ignorelist.txt' | 486 filename = 'ignorelist.txt' |
488 self.filename = orpg.dirpath.dir_struct["home"] + 'upmana' + os.sep + filename | 487 self.filename = dir_struct["home"] + 'upmana' + os.sep + filename |
489 upmana.validate.Validate(orpg.dirpath.dir_struct["home"] + 'upmana' + os.sep).config_file(filename, "default_ignorelist.txt") | 488 upmana.validate.Validate(dir_struct["home"] + 'upmana' + os.sep).config_file(filename, "default_ignorelist.txt") |
490 self.mana = self.LoadDoc() | 489 self.mana = self.LoadDoc() |
491 for ignore in self.ignorelist: | 490 for ignore in self.ignorelist: |
492 shutil.copy(ignore, orpg.dirpath.dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep +ignore.split('/')[len(ignore.split('/')) - 1]) | 491 shutil.copy(ignore, dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep +ignore.split('/')[len(ignore.split('/')) - 1]) |
493 hg.clean(self.repo, self.current) | 492 hg.clean(self.repo, self.current) |
494 for ignore in self.ignorelist: | 493 for ignore in self.ignorelist: |
495 print ignore.split('/')[len(ignore.split('/')) - 1] | 494 print ignore.split('/')[len(ignore.split('/')) - 1] |
496 shutil.copyfile(orpg.dirpath.dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep + ignore.split('/')[len(ignore.split('/')) - 1], ignore) | 495 shutil.copyfile(dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep + ignore.split('/')[len(ignore.split('/')) - 1], ignore) |
497 os.remove(orpg.dirpath.dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep + ignore.split('/')[len(ignore.split('/')) - 1]) | 496 os.remove(dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep + ignore.split('/')[len(ignore.split('/')) - 1]) |
498 else: print 'No default repository set, skipping Auto Update!' | 497 else: print 'No default repository set, skipping Auto Update!' |
499 | 498 |
500 def LoadDoc(self): | 499 def LoadDoc(self): |
501 ignore = open(self.filename) | 500 ignore = open(self.filename) |
502 self.ignorelist = [] | 501 self.ignorelist = [] |