changeset 47:52f6a38f8885 traipse_dev

Update Manager 0.6.7 (Initial Release). Getting ready to implement it now. Default Check on repos does *NOT* work. Manifest works, Repos work. Main does not show panel or menu item, so if Auto or No are check, user will *NOT* see the Update Manager unless they edit their manifest.xml
author sirebral
date Thu, 06 Aug 2009 03:31:21 -0500
parents 599f727e3833
children 0aeee1992423
files orpg/orpg_version.py orpg/templates/default.hgignore upmana/ReadMe.txt upmana/default_ignorelist.txt upmana/default_manifest.xml upmana/manifest.py upmana/updatemana.py upmana/validate.py
diffstat 6 files changed, 139 insertions(+), 67 deletions(-) [+]
line wrap: on
line diff
--- a/orpg/orpg_version.py	Wed Aug 05 19:52:56 2009 -0500
+++ b/orpg/orpg_version.py	Thu Aug 06 03:31:21 2009 -0500
@@ -4,7 +4,7 @@
 #BUILD NUMBER FORMAT: "YYMMDD-##" where ## is the incremental daily build index (if needed)
 DISTRO = "Traipse Dev"
 DIS_VER = "Grumpy Goblin"
-BUILD = "090805-09"
+BUILD = "090806-00"
 
 # This version is for network capability.
 PROTOCOL_VERSION = "1.2"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/upmana/ReadMe.txt	Thu Aug 06 03:31:21 2009 -0500
@@ -0,0 +1,18 @@
+Welcome to Update Manager 0.6.7!!!
+
+This is the first isntallment of Update Manager for the OpenRPG Virtual Game Table.  The package includes several files that allow users to install Update Manager as a package into other softwares that use Mercurial.  The package itself includes
+
+updatemana.py ## The Update Manager
+manfiest.py ## A clone of the Plugin Database file (plugindb.py) from the OpenRPG Project
+validate.py ## Currently unused but it is here for future packaging, from the OpenRPG Project
+xmltramp.py  ## From the OpenRPG Project
+__init__.py ## So you can copy the upmana folder and import updatemana.py anywhere
+tmp folder ## Used to protect files during a repository update
+default_ignorelist.txt ## An empty txt, needed in case users cannot create their own ignorelist.txt
+default_manifest.xml ## A nearly empty XML file.  Used to hold Update Manager information.
+
+The code is incomplete in this version, but the pieces that are missing have notes in remarks on how to complete them.
+
+So what can you do with Update Manager? If you have a project that you want to serve to users and user Mercurial as a way to deliver updates, Update Manager allows you to deliver those updates without the fear of creating a problem with user sentiment.  Users will be able to (when completed) access their Control tab and update to any revision or any branch that has been served via a repoistory.  Users also have the option to protect files from being overwritten during updates, or not update at all!
+
+If you have a development team you can use Update Manager as a speedy way to surf through your branches and revisions.  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/upmana/default_manifest.xml	Thu Aug 06 03:31:21 2009 -0500
@@ -0,0 +1,1 @@
+<manifest></manifest>
--- a/upmana/manifest.py	Wed Aug 05 19:52:56 2009 -0500
+++ b/upmana/manifest.py	Thu Aug 06 03:31:21 2009 -0500
@@ -1,12 +1,13 @@
 import xmltramp
 import orpg.dirpath
 import orpg.tools.validate
+from os import sep
 from types import *
 
 class ManifestChanges:
     def __init__(self, filename="updatemana.xml"):
-        self.filename = orpg.dirpath.dir_struct["user"] + filename
-        orpg.tools.validate.Validate().config_file(filename,"default_manifest.xml")
+        self.filename = orpg.dirpath.dir_struct["home"] + 'upmana' + sep + filename
+        orpg.tools.validate.Validate(orpg.dirpath.dir_struct["home"] + 'upmana' + sep).config_file(filename,"default_manifest.xml")
         self.xml_dom = self.LoadDoc()
 
     def GetString(self, plugname, strname, defaultval, verbose=0):
--- a/upmana/updatemana.py	Wed Aug 05 19:52:56 2009 -0500
+++ b/upmana/updatemana.py	Thu Aug 06 03:31:21 2009 -0500
@@ -7,6 +7,8 @@
 import orpg.orpg_xml
 import orpg.dirpath
 import orpg.tools.validate
+import tempfile
+import shutil
 from mercurial import ui, hg, commands, repo, revlog, cmdutil
 
 
@@ -19,7 +21,6 @@
         self.repo = hg.repository(self.ui, ".")
         self.c = self.repo.changectx('tip')
         self.manifest = manifest
-
         self.xml = open_rpg.get_component('xml')
         self.dir_struct = open_rpg.get_component("dir_struct")
         self.parent = parent
@@ -58,7 +59,6 @@
 
         self.current = self.c.branch()
         self.BranchInfo(self.current)
-        #if self.autoupdate == "On": self.buttons['auto_check'].SetValue(True)
 
         ## Event Handlers
         self.Bind(wx.EVT_BUTTON, self.Update, self.buttons['update'])
@@ -72,32 +72,44 @@
             if self.buttons['no_check'].GetValue(): 
                 self.buttons['no_check'].SetValue(False)
                 self.manifest.SetString("updatemana", "no_update", "off")
-            self.autoupdate = "On"
             self.manifest.SetString("updatemana", "auto_update", "on")
-        else:
-            self.autoupdate = "Off"
-            self.manifest.SetString("updatemana", "auto_update", "off")
+        else: self.manifest.SetString("updatemana", "auto_update", "off")
 
     def ToggleNoUpdate(self, event):
         if self.buttons['no_check'].GetValue():
             if self.buttons['auto_check'].GetValue(): 
                 self.buttons['auto_check'].SetValue(False)
                 self.manifest.SetString("updatemana", "auto_update", "off")
-            self.autoupdate = "On"
             self.manifest.SetString("updatemana", "no_update", "on")
-        else:
-            self.autoupdate = "Off"
-            self.manifest.SetString("updatemana", "no_update", "off")
+        else: self.manifest.SetString("updatemana", "no_update", "off")
 
     def Update(self, evt=None):
-        hg.clean(self.repo, self.current)
+        self.ui = ui.ui()
+        self.repo = hg.repository(self.ui, ".")
+        self.c = self.repo.changectx('tip')
+
+        filename = '.ignorelist.txt'
+        self.filename = orpg.dirpath.dir_struct["home"] + 'upmana' + os.sep + filename
+        orpg.tools.validate.Validate(orpg.dirpath.dir_struct["home"] + 'upmana' + os.sep).config_file(filename, "default_ignorelist.txt")
+        self.mana = self.LoadDoc()
+        for ignore in self.ignorelist:
+            shutil.copy(ignore, orpg.dirpath.dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep)
+        #hg.clean(self.repo, self.current)
+        for ignore in self.ignorelist:
+            shutil.copyfile(orpg.dirpath.dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep + ignore.split('/')[len(ignore.split('/')) - 1], ignore)
+            os.remove(orpg.dirpath.dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep + ignore.split('/')[len(ignore.split('/')) - 1])
+
+    def LoadDoc(self):
+        ignore = open(self.filename)
+        self.ignorelist = []
+        for i in ignore: self.ignorelist.append(str(i [:len(i)-1]))
+        manifest = ignore.readlines()
+        ignore.close()
 
     def Finish(self, evt=None):
-        self.Finished = True
-        self.Destroy() #destroys tab, pretty useless.
+        exit()
 
     def ChooseBranch(self, evt=None):
-
         dlg = wx.Dialog(self, wx.ID_ANY, "Package Selector", style=wx.DEFAULT_DIALOG_STYLE)
         if wx.Platform == '__WXMSW__': icon = wx.Icon(self.dir_struct["icon"]+'d20.ico', wx.BITMAP_TYPE_ICO)
         else: icon = wx.Icon(self.dir_struct["icon"]+"d20.xpm", wx.BITMAP_TYPE_XPM )
@@ -121,21 +133,21 @@
         for t in types:
             self.btnName = str(t)
             self.btn[self.id] = wx.RadioButton(dlg, wx.ID_ANY, str(t), name=self.btnName)
-            if self.btnName == self.current:
-                self.btn[self.id].SetValue(True)
+            if self.btnName == self.current: self.btn[self.id].SetValue(True)
             self.btnlist[self.id] = self.btnName
             dlgsizer.Add(self.btn[self.id], (row, col))
-            row += 1; self.id += 1
+            col += 1; self.id += 1
+            if col == 3: row += 1; col = 0
 
-        dlgsizer.Add(Yes, (row+1,0))
+        dlgsizer.Add(Yes, (row+1,col/2))
+        dlgsizer.AddGrowableCol(0)
+        dlgsizer.AddGrowableRow(0)
         dlg.SetAutoLayout( True )
-        dlg.SetSizer( dlgsizer )
+        dlg.SetSizer( dlgsizer )
         dlgsizer.Fit( dlg )
         dlg.Centre()
         dlg.Bind(wx.EVT_RADIOBUTTON, self.PackageSet)
-
-        if dlg.ShowModal():
-            dlg.Destroy()
+        if dlg.ShowModal(): dlg.Destroy()
 
     def PackageSet(self, event):
         for btn in self.btn:
@@ -171,16 +183,14 @@
         self.filelist.SetValue('')
         self.filelist.AppendText("Files that will change\n\n")
         self.changelog.SetValue('')
-        changelog = "Traipse 'OpenRPG' Update Manager.\n\nThis is Dev Build 0.6.5 of the Update Manager. It has limited functionality.\n\nThe full release will search your Revision log and show the contents here.\n\nMajor changes in this version are ... Manifest is now in a CheckListBox, very nice, Repos now allow for scrolling, New button works. Checks Box on the Updater tab work.  Settings file is created and data is saved to it."
+        changelog = "Traipse 'OpenRPG' Update Manager.\n\nThis is Dev Build 0.6.7 of the Update Manager. This version is nearly 100% functional. Users can now add repositories of OpenRPG, choose from different branches available from those repositories, and add files to an ignore list.\n\nThe Update Manager is divided into tabs, Updater, Repos, Manifest, and Control. The Updater says it all, choose a branch and update to that branch. Repos is a new feature that I hope users take advantage of. Clone the repo, build your own, and then share it with your friends! The Manifest is the ignore list. Want to make sure a test run doesn't delete important files ... then add them to the Manifest'. Control is not functional yet, but when it is users will be able to update to specific revision dates and delete branches.\n\nThis is a good start. Enjoy the freedom!!"
         self.changelog.AppendText(changelog + '\n')
-        self.filelist.AppendText("Update to " + branch + "\n\n The full release will show the files to be changed here.")
+        self.filelist.AppendText("Update to " + branch + "\n\nWhen Update Manager is fully functional this area will show the files that will be affected by the yoru branch selection.")
 
         #### Files works but not fully without the change log information, pulled for Dev 0.1
         #for f in files:
         #    fc = c[f]
         #    self.filelist.AppendText(str(f + '\n'))
-
-    
 
     def get_packages(self, type=None):
         #Fixed and ready for Test. Can be cleaner
@@ -321,10 +331,8 @@
         repo = self.texts['reponame'].GetValue(); repo = repo.replace(' ', '_'); repo = 'repo-' + repo
         self.manifest.SetString('updaterepo', repo, ''); self.repo = repo.split(',')
         repolist = self.manifest.GetList('UpdateManifest', 'repolist', '')
-        if repolist == '':
-            pass
-        else:
-            repolist = repolist + self.repo
+        if repolist == '': pass
+        else: repolist = repolist + self.repo
         self.manifest.SetList('UpdateManifest', 'repolist', repolist)
         self.BuildRepoList(None)
 
@@ -339,10 +347,8 @@
     def RefreshRepo(self, event):
         self.id = self.pull_list[event.GetEventObject()]
         self.manifest.SetString('updaterepo', str(self.box_name[self.id]), self.url[self.id].GetValue())
-        try:
-            commands.pull(self.ui, self.r, self.url[self.id].GetValue(), rev='', update=False, force=True)
-        except:
-            pass
+        try: commands.pull(self.ui, self.r, self.url[self.id].GetValue(), rev='', update=False, force=True)
+        except: pass
 
 class Manifest(wx.Panel):
     def __init__(self, parent):
@@ -353,6 +359,7 @@
 
         self.manifestlist = []
         self.manifestlist = self.c.manifest().keys()
+        for mana in self.manifestlist: mana = os.sep + 'orpg' + os.sep + mana
         self.manifestlist.sort()
 
         self.SetBackgroundColour(wx.WHITE)
@@ -361,9 +368,9 @@
         self.manifestlog = wx.CheckListBox( self, -1, wx.DefaultPosition, wx.DefaultSize, self.manifestlist, 
             wx.LC_REPORT|wx.SUNKEN_BORDER|wx.EXPAND|wx.LC_HRULES)
 
-        filename = '.hgignore'
-        self.filename = orpg.dirpath.dir_struct["home"] + filename
-        orpg.tools.validate.Validate(orpg.dirpath.dir_struct["home"]).config_file(filename, "default.hgignore")
+        filename = 'ignorelist.txt'
+        self.filename = orpg.dirpath.dir_struct["home"] + 'upmana' + os.sep + filename
+        orpg.tools.validate.Validate(orpg.dirpath.dir_struct["home"] + 'upmana' + os.sep).config_file(filename, "default_ignorelist.txt")
         self.mana = self.LoadDoc()
 
         self.manifestlog.Bind(wx.EVT_CHECKLISTBOX, self.GetChecked)
@@ -375,24 +382,20 @@
 
     def GetChecked(self, event):
         self.mana = []
-        for manifest in self.manifestlog.GetChecked():
-            self.mana.append(self.manifestlist[manifest])
+        for manifest in self.manifestlog.GetChecked(): self.mana.append(self.manifestlist[manifest])
         self.SaveDoc()
 
     def SaveDoc(self):
         f = open(self.filename, "w")
-        for mana in self.mana:
-            f.write(mana+'\n')
-            #f.write('\n')
+        for mana in self.mana: f.write(mana+'\n')
         f.close()
 
     def LoadDoc(self):
         ignore = open(self.filename)
         ignorelist = []
-        for i in ignore:
-            ignorelist.append(str(i [:len(i)-1]))
+        for i in ignore: ignorelist.append(str(i [:len(i)-1]))
         self.manifestlog.SetCheckedStrings(ignorelist)
-        manifest = ignore.read()
+        manifest = ignore.readlines()
         ignore.close()
 
 class Control(wx.Panel):
@@ -402,9 +405,8 @@
 
 class updaterFrame(wx.Frame):
     def __init__(self, parent, title, openrpg, manifest):
-        wx.Frame.__init__(self, None, wx.ID_ANY, title, size=(640,480), 
+        wx.Frame.__init__(self, None, wx.ID_ANY, title, size=(700,480), 
             style=wx.FRAME_NO_TASKBAR | wx.STAY_ON_TOP | wx.DEFAULT_FRAME_STYLE)
-
         self.CenterOnScreen()
 
         ####### Panel Stuff ######
@@ -441,29 +443,42 @@
         self.open_rpg.add_component("dir_struct", orpg.dirpath.dir_struct)
         self.validate = orpg.tools.validate.Validate()
         self.open_rpg.add_component("validate", self.validate)
-        self.updater = updaterFrame(self, "OpenRPG Update Manager Beta 0.6.5", self.open_rpg, self.manifest)
-
+        self.updater = updaterFrame(self, "OpenRPG Update Manager Beta 0.6.7", self.open_rpg, self.manifest)
         if self.manifest.GetString("updatemana", "auto_update", "") == 'on':
-            print 'Auto Update not completed'
-            self.OnExit()
-
-        if self.manifest.GetString('updatemana', 'no_update', '') == 'on':
-            self.OnExit()
-
+            self.AutoUpdate(); self.OnExit()
+        if self.manifest.GetString('updatemana', 'no_update', '') == 'on': self.OnExit()
         try:
             self.updater.Show()
             self.SetTopWindow(self.updater)
             self.updater.Fit()
         except: pass
-
-        return True
+        return True
+
+    def AutoUpdate(self):
+        self.ui = ui.ui()
+        self.repo = hg.repository(self.ui, ".")
+        self.c = self.repo.changectx('tip')
+        filename = '.ignorelist.txt'
+        self.filename = orpg.dirpath.dir_struct["home"] + 'upmana' + os.sep + filename
+        orpg.tools.validate.Validate(orpg.dirpath.dir_struct["home"] + 'upmana' + os.sep).config_file(filename, "default_ignorelist.txt")
+        self.mana = self.LoadDoc()
+        for ignore in self.ignorelist:
+            shutil.copy(ignore, orpg.dirpath.dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep)
+        #hg.clean(self.repo, self.current)
+        for ignore in self.ignorelist:
+            shutil.copyfile(orpg.dirpath.dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep + ignore.split('/')[len(ignore.split('/')) - 1], ignore)
+            os.remove(orpg.dirpath.dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep + ignore.split('/')[len(ignore.split('/')) - 1])
+
+    def LoadDoc(self):
+        ignore = open(self.filename)
+        self.ignorelist = []
+        for i in ignore: self.ignorelist.append(str(i [:len(i)-1]))
+        manifest = ignore.readlines()
+        ignore.close()
 
     def OnExit(self):
-        imported = ['manifest', 'orpg.dirpath', 'orpg.orpgCore', 'orpg.orpg_version', 'orpg.tools.orpg_log', 'orpg.tools.orpg_log', 'orpg.orpg_xml', 'orpg.dirpath', 'orpg.dirpath', 'orpg.tools.validate', 'mercurial.ui', 'mercurial.hg', 'mercurial.commands', 'mercurial.repo', 'mercurial.revlog', 'mercurial.cmdutil']
-
+        imported = ['manifest', 'orpg.dirpath', 'orpg.orpgCore', 'orpg.orpg_version', 'orpg.tools.orpg_log', 'orpg.tools.orpg_log', 'orpg.orpg_xml', 'orpg.dirpath', 'orpg.dirpath', 'orpg.tools.validate', 'mercurial.ui', 'mercurial.hg', 'mercurial.commands', 'mercurial.repo', 'mercurial.revlog', 'mercurial.cmdutil', 'shutil']
         for name in imported:
-            if name in sys.modules:
-                #self.log.log("Unimported " + name, ORPG_DEBUG)
-                del sys.modules[name]
-        self.updater.Destroy()
-        #self.log.log("Updater Exit\n\n", ORPG_NOTE)
+            if name in sys.modules: del sys.modules[name]
+        try: self.updater.Destroy()
+        except: pass
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/upmana/validate.py	Thu Aug 06 03:31:21 2009 -0500
@@ -0,0 +1,37 @@
+# file: config_files.py
+#
+# Author: Todd Faris (Snowdog)
+# Date:   5/10/2005
+#
+# Misc. config file service methods
+#
+
+import orpg.dirpath
+import os
+
+class Validate:
+    def __init__(self, userpath=None):
+        if userpath is None:
+            userpath = orpg.dirpath.dir_struct["user"]
+        self.__loadUserPath = userpath
+
+    def config_file(self, user_file, template_file):
+        #STEP 1: verify the template exists
+        if (not os.path.exists(orpg.dirpath.dir_struct["template"] + template_file)):
+            return 0
+
+        #STEP 2: verify the user file exists. If it doesn't then create it from template
+        if (not os.path.exists(self.__loadUserPath + user_file)):
+            default = open(orpg.dirpath.dir_struct["template"] + template_file,"r")
+            file = default.read()
+            newfile = open(self.__loadUserPath + user_file,"w")
+            newfile.write(file)
+            default.close()
+            newfile.close()
+            return 2  #returning 2 (True) so calling method will know if file was created
+
+        #STEP 3: user file exists (is openable) return 1 indicating no-create operation required
+        else: return 1
+
+    def ini_entry(self, entry_name, ini_file):
+        pass