annotate orpg/dirpath/dirpath_tools.py @ 28:ff154cf3350c ornery-orc

Traipse 'OpenRPG' {100203-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 (Stable) New Features: New Bookmarks Feature New 'boot' command to remote admin New confirmation window for sent nodes Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG New Zoom Mouse plugin added New Images added to Plugin UI Switching to Element Tree New Map efficiency, from FlexiRPG New Status Bar to Update Manager New TrueDebug Class in orpg_log (See documentation for usage) New Portable Mercurial New Tip of the Day, from Core and community New Reference Syntax added for custom PC sheets New Child Reference for gametree New Parent Reference for gametree New Gametree Recursion method, mapping, context sensitivity, and effeciency.. New Features node with bonus nodes and Node Referencing help added New Dieroller structure from Core New DieRoller portability for odd Dice New 7th Sea die roller; ie [7k3] = [7d10.takeHighest(3).open(10)] New 'Mythos' System die roller added New vs. die roller method for WoD; ie [3v3] = [3d10.vs(3)]. Included for Mythos roller also New Warhammer FRPG Die Roller (Special thanks to Puu-san for the support) New EZ_Tree Reference system. Push a button, Traipse the tree, get a reference (Beta!) New Grids act more like Spreadsheets in Use mode, with Auto Calc Fixes: Fix to allow for portability to an OpenSUSE linux OS Fix to mplay_client for Fedora and OpenSUSE 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 Fix to Whiteboard ID to prevent random line or text deleting. Fixes to Server, Remote Server, and Server GUI Fix to Update Manager; cleaner clode for saved repositories Fixes made to Settings Panel and now reactive settings when Ok is pressed Fixes to Alternity roller's attack roll. Uses a simple Tuple instead of a Splice Fix to Use panel of Forms and Tabbers. Now longer enters design mode Fix made Image Fetching. New fetching image and new failed image Fix to whiteboard ID's to prevent non updated clients from ruining the fix. default_manifest.xml renamed to default_upmana.xml
author sirebral
date Wed, 03 Feb 2010 22:16:49 -0600
parents 97265586402b
children d02e9197c066
rev   line source
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
1 import sys
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
2 import os
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
3 import errno
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
4 from orpg.orpg_wx import *
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
5
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
6 if WXLOADED:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
7 class tmpApp(wx.App):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
8 def OnInit(self):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
9 return True
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
10
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
11 #-------------------------------------------------------
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
12 # void load_paths( dir_struct_reference )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
13 # moved structure loading from dirpath.py by Snowdog 3-8-05
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
14 #-------------------------------------------------------
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
15 def load_paths(dir_struct, root_dir):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
16 dir_struct["home"] = root_dir + os.sep
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
17 dir_struct["core"] = dir_struct["home"] + "orpg"+ os.sep
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
18 dir_struct["data"] = dir_struct["home"] + "data"+ os.sep
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
19 dir_struct["d20"] = dir_struct["data"] + "d20" + os.sep
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
20 dir_struct["dnd3e"] = dir_struct["data"] + "dnd3e" + os.sep
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
21 dir_struct["dnd35"] = dir_struct["data"] + "dnd35" + os.sep
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
22 dir_struct["SWd20"] = dir_struct["data"] + "SWd20" + os.sep
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
23 dir_struct["icon"] = dir_struct["home"] + "images" + os.sep
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
24 dir_struct["template"] = dir_struct["core"] + "templates" + os.sep
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
25 dir_struct["plugins"] = dir_struct["home"] + "plugins" + os.sep
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
26 dir_struct["nodes"] = dir_struct["template"] + "nodes" + os.sep
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
27 dir_struct["rollers"] = dir_struct["core"] + "dieroller" + os.sep + "rollers" + os.sep
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
29 _userbase_dir = dir_struct["home"]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
30 _user_dir = dir_struct["home"] + "myfiles" + os.sep
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
31
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
32 try:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
33 os.makedirs(_user_dir)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
34 os.makedirs(_user_dir + "runlogs" + os.sep);
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
35 os.makedirs(_user_dir + "logs" + os.sep);
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
36 os.makedirs(_user_dir + "webfiles" + os.sep);
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
37 except OSError, e:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
38 if e.errno != errno.EEXIST: raise
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
39
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
40 dir_struct["user"] = _user_dir
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
41 dir_struct["logs"] = dir_struct["user"] + "logs" + os.sep
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
42
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
43 #-------------------------------------------------------
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
44 # int verify_home_path( directory_name )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
45 # added by Snowdog 3-8-05
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
46 # updated with bailout code. Snowdog 7-25-05
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
47 #-------------------------------------------------------
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
48 def verify_home_path( path ):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
49 """checks for key ORPG files in the openrpg tree
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
50 and askes for user intervention if their is a problem"""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
51 try:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
52 #verify that the root dir (as supplied) exists
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
53 if not verify_file(path): return 0
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 10
diff changeset
54
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
55 #These checks require that 'path' have a separator at the end.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
56 #Check and temporarily add one if needed
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
57 if (path[(len(path)-len(os.sep)):] != os.sep):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
58 path = path + os.sep
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
59 # These files should always exist at the root orpg dir
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
60 check_files = ["orpg","data","images"]
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
61 for n in range(len(check_files)):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
62 if not verify_file(path + check_files[n]): return 0
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
63 except:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
64 # an error occured while verifying the directory structure
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
65 # bail out with error signal
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
66 return 0
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
67
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
68 #all files and directories exist.
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
69 return 1
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
70
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
71 #-------------------------------------------------------
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
72 # int verify_file( absolute_path )
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
73 # added by Snowdog 3-8-05
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
74 #-------------------------------------------------------
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
75 def verify_file(abs_path):
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
76 """Returns True if file or directory exists"""
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
77 try:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
78 os.stat(abs_path)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
79 return 1
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
80 except OSError:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
81 #this exception signifies the file or dir doesn't exist
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
82 return 0
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
83
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
84
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 10
diff changeset
85 #-------------------------------------------------------
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
86 # pathname get_user_help()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
87 # added by Snowdog 3-8-05
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
88 # bug fix (SF #1242456) and updated with bailout code. Snowdog 7-25-05
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
89 #-------------------------------------------------------
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
90 ## This can be removed in the future. TaS '09
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
91 def get_user_located_root():
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
92 """Notify the user of directory problems
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
93 and show directory selection dialog """
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
94
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
95 if WXLOADED:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
96 app = tmpApp(0)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
97 app.MainLoop()
18
97265586402b Traipse 'OpenRPG' {090827-00}
sirebral
parents: 10
diff changeset
98
28
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
99 dir = None
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
100 try:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
101 msg = "OpenRPG cannot locate critical files.\nPlease locate the /System/ directory in the following window"
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
102 alert= wx.MessageDialog(None,msg,"Warning",wx.OK|wx.ICON_ERROR)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
103 alert.Show()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
104 if alert.ShowModal() == wx.OK:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
105 alert.Destroy()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
106 dlg = wx.DirDialog(None, "Locate the System directory:",style=wx.DD_DEFAULT_STYLE)
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
107 if dlg.ShowModal() == wx.ID_OK:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
108 dir = dlg.GetPath()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
109 dlg.Destroy()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
110 app.Destroy()
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
111 return dir
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
112 except Exception, e:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
113 print e
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
114 print "OpenRPG encountered a problem while attempting to load file dialog to locate the OpenRPG root directory."
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
115 print "please delete the files ./openrpg/orpg/dirpath/aproot.py and ./openrpg/orpg/dirpath/aproot.pyc and try again."
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
116 else:
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
117 dir = raw_input("Enter the full path to your openrpg folder: ")
ff154cf3350c Traipse 'OpenRPG' {100203-00}
sirebral
parents: 18
diff changeset
118 return dir
10
5df1340bda13 Big patch! Linux GUI, Fetching Dict., Init2, Streaming lining.
sirebral
parents: 0
diff changeset
119