annotate orpg/dirpath/dirpath_tools.py @ 162:e3714f232f2f beta

Traipse Beta 'OpenRPG' {091128-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 (Beta) New Features: Added Bookmarks Added 'boot' command to remote admin Added confirmation window for sent nodes Minor changes to allow for portability to an OpenSUSE linux OS Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG Zoom Mouse plugin added Images added to Plugin UI Switching to Element Tree Map efficiency, from FlexiRPG Added Status Bar to Update Manager New TrueDebug Class in orpg_log (See documentation for usage) Portable Mercurial Tip of the Day added, from Core and community New Reference Syntax added for custom PC sheets New Child Reference for gametree New Gametree Recursion method, mapping, context sensitivity, and effeciency.. New Features node with bonus nodes and Node Referencing help added Fixes: Fix to Text based Server Fix to Remote Admin Commands Fix to Pretty Print, from Core Fix to Splitter Nodes not being created Fix to massive amounts of images loading, from Core Fix to Map from gametree not showing to all clients Fix to gametree about menus Fix to Password Manager check on startup Fix to PC Sheets from tool nodes. They now use the tabber_panel Fixed Whiteboard ID to prevent random line or text deleting. Modified ID's to prevent non updated clients from ruining the fix. *Whiteboard from Core not showing* default_manifest.xml renamed to default_upmana.xml Fix to Update Manager; cleaner clode for saved repositories
author sirebral
date Sat, 28 Nov 2009 01:25:58 -0600
parents 3b6888bb53b5
children 1df5912db00c
rev   line source
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
1 import sys
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
2 import os
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
3 import errno
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
4 from orpg.orpg_wx import *
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
5
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
6 if WXLOADED:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
7 class tmpApp(wx.App):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
8 def OnInit(self):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
9 return True
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
10
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
11 #-------------------------------------------------------
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
12 # void load_paths( dir_struct_reference )
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
13 # moved structure loading from dirpath.py by Snowdog 3-8-05
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
14 #-------------------------------------------------------
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
15 def load_paths(dir_struct, root_dir):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
16 dir_struct["home"] = root_dir + os.sep
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
17 dir_struct["core"] = dir_struct["home"] + "orpg"+ os.sep
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
18 dir_struct["data"] = dir_struct["home"] + "data"+ os.sep
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
19 dir_struct["d20"] = dir_struct["data"] + "d20" + os.sep
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
20 dir_struct["dnd3e"] = dir_struct["data"] + "dnd3e" + os.sep
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
21 dir_struct["dnd35"] = dir_struct["data"] + "dnd35" + os.sep
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
22 dir_struct["SWd20"] = dir_struct["data"] + "SWd20" + os.sep
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
23 dir_struct["icon"] = dir_struct["home"] + "images" + os.sep
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
24 dir_struct["template"] = dir_struct["core"] + "templates" + os.sep
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
25 dir_struct["plugins"] = dir_struct["home"] + "plugins" + os.sep
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
26 dir_struct["nodes"] = dir_struct["template"] + "nodes" + os.sep
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
27 dir_struct["rollers"] = dir_struct["core"] + "dieroller" + os.sep + "rollers" + os.sep
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
28
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
29 _userbase_dir = dir_struct["home"]
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
30 _user_dir = dir_struct["home"] + "myfiles" + os.sep
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
31
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
32 try:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
33 os.makedirs(_user_dir)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
34 os.makedirs(_user_dir + "runlogs" + os.sep);
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
35 os.makedirs(_user_dir + "logs" + os.sep);
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
36 os.makedirs(_user_dir + "webfiles" + os.sep);
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
37 except OSError, e:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
38 if e.errno != errno.EEXIST: raise
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
39
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
40 dir_struct["user"] = _user_dir
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
41 dir_struct["logs"] = dir_struct["user"] + "logs" + os.sep
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
42
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
43 #-------------------------------------------------------
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
44 # int verify_home_path( directory_name )
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
45 # added by Snowdog 3-8-05
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
46 # updated with bailout code. Snowdog 7-25-05
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
47 #-------------------------------------------------------
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
48 def verify_home_path( path ):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
49 """checks for key ORPG files in the openrpg tree
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
50 and askes for user intervention if their is a problem"""
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
51 try:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
52 #verify that the root dir (as supplied) exists
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
53 if not verify_file(path): return 0
65
4840657c23c5 Traipse Dev 'OpenRPG' {090817-02}
sirebral
parents: 14
diff changeset
54
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
55 #These checks require that 'path' have a separator at the end.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
56 #Check and temporarily add one if needed
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
57 if (path[(len(path)-len(os.sep)):] != os.sep):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
58 path = path + os.sep
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
59 # These files should always exist at the root orpg dir
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
60 check_files = ["orpg","data","images"]
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
61 for n in range(len(check_files)):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
62 if not verify_file(path + check_files[n]): return 0
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
63 except:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
64 # an error occured while verifying the directory structure
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
65 # bail out with error signal
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
66 return 0
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
67
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
68 #all files and directories exist.
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
69 return 1
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
70
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
71 #-------------------------------------------------------
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
72 # int verify_file( absolute_path )
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
73 # added by Snowdog 3-8-05
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
74 #-------------------------------------------------------
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
75 def verify_file(abs_path):
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
76 """Returns True if file or directory exists"""
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
77 try:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
78 os.stat(abs_path)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
79 return 1
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
80 except OSError:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
81 #this exception signifies the file or dir doesn't exist
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
82 return 0
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
83
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
84
65
4840657c23c5 Traipse Dev 'OpenRPG' {090817-02}
sirebral
parents: 14
diff changeset
85 #-------------------------------------------------------
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
86 # pathname get_user_help()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
87 # added by Snowdog 3-8-05
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
88 # bug fix (SF #1242456) and updated with bailout code. Snowdog 7-25-05
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
89 #-------------------------------------------------------
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
90 ## This can be removed in the future. TaS '09
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
91 def get_user_located_root():
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
92 """Notify the user of directory problems
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
93 and show directory selection dialog """
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
94
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
95 if WXLOADED:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
96 app = tmpApp(0)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
97 app.MainLoop()
65
4840657c23c5 Traipse Dev 'OpenRPG' {090817-02}
sirebral
parents: 14
diff changeset
98
156
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
99 dir = None
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
100 try:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
101 msg = "OpenRPG cannot locate critical files.\nPlease locate the /System/ directory in the following window"
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
102 alert= wx.MessageDialog(None,msg,"Warning",wx.OK|wx.ICON_ERROR)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
103 alert.Show()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
104 if alert.ShowModal() == wx.OK:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
105 alert.Destroy()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
106 dlg = wx.DirDialog(None, "Locate the System directory:",style=wx.DD_DEFAULT_STYLE)
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
107 if dlg.ShowModal() == wx.ID_OK:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
108 dir = dlg.GetPath()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
109 dlg.Destroy()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
110 app.Destroy()
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
111 return dir
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
112 except Exception, e:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
113 print e
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
114 print "OpenRPG encountered a problem while attempting to load file dialog to locate the OpenRPG root directory."
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
115 print "please delete the files ./openrpg/orpg/dirpath/aproot.py and ./openrpg/orpg/dirpath/aproot.pyc and try again."
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
116 else:
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
117 dir = raw_input("Enter the full path to your openrpg folder: ")
3b6888bb53b5 Traipse Beta 'OpenRPG' {091125-02}
sirebral
parents: 65
diff changeset
118 return dir
14
0b8b7e3ed78d Adding fixes from OpenRPG 1.8.0
sirebral
parents: 0
diff changeset
119