comparison orpg/dirpath/dirpath_tools.py @ 23:57106cf03b14 grumpy-goblin

Traipse 'OpenRPG' {090830-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. 'Grumpy-Goblin' was designed to stablize the software and make it easy for users to install and run. Update Summary: Update dirpath_tools to remove the dependency of the OPENRPG_BASE system key. The new file is compatible with older location.py files and with the new location.py file.
author sirebral
date Sun, 30 Aug 2009 17:58:31 -0500
parents 5df1340bda13
children ff154cf3350c
comparison
equal deleted inserted replaced
16:281ca8daa911 23:57106cf03b14
5 5
6 if WXLOADED: 6 if WXLOADED:
7 class tmpApp(wx.App): 7 class tmpApp(wx.App):
8 def OnInit(self): 8 def OnInit(self):
9 return True 9 return True
10
11 10
12 #------------------------------------------------------- 11 #-------------------------------------------------------
13 # void load_paths( dir_struct_reference ) 12 # void load_paths( dir_struct_reference )
14 # moved structure loading from dirpath.py by Snowdog 3-8-05 13 # moved structure loading from dirpath.py by Snowdog 3-8-05
15 #------------------------------------------------------- 14 #-------------------------------------------------------
25 dir_struct["template"] = dir_struct["core"] + "templates" + os.sep 24 dir_struct["template"] = dir_struct["core"] + "templates" + os.sep
26 dir_struct["plugins"] = dir_struct["home"] + "plugins" + os.sep 25 dir_struct["plugins"] = dir_struct["home"] + "plugins" + os.sep
27 dir_struct["nodes"] = dir_struct["template"] + "nodes" + os.sep 26 dir_struct["nodes"] = dir_struct["template"] + "nodes" + os.sep
28 dir_struct["rollers"] = dir_struct["core"] + "dieroller" + os.sep + "rollers" + os.sep 27 dir_struct["rollers"] = dir_struct["core"] + "dieroller" + os.sep + "rollers" + os.sep
29 28
30 29 _userbase_dir = dir_struct["home"]
31 _userbase_dir = _userbase_dir = os.environ['OPENRPG_BASE'] 30 _user_dir = dir_struct["home"] + "myfiles" + os.sep
32 _user_dir = _userbase_dir + os.sep + "myfiles" + os.sep
33
34 31
35 try: 32 try:
36 os.makedirs(_user_dir) 33 os.makedirs(_user_dir)
37 os.makedirs(_user_dir + "runlogs" + os.sep); 34 os.makedirs(_user_dir + "runlogs" + os.sep);
38 os.makedirs(_user_dir + "logs" + os.sep); 35 os.makedirs(_user_dir + "logs" + os.sep);
39 os.makedirs(_user_dir + "webfiles" + os.sep); 36 os.makedirs(_user_dir + "webfiles" + os.sep);
40 except OSError, e: 37 except OSError, e:
41 if e.errno != errno.EEXIST: 38 if e.errno != errno.EEXIST: raise
42 raise
43 39
44 dir_struct["user"] = _user_dir 40 dir_struct["user"] = _user_dir
45
46 dir_struct["logs"] = dir_struct["user"] + "logs" + os.sep 41 dir_struct["logs"] = dir_struct["user"] + "logs" + os.sep
47
48
49 42
50 #------------------------------------------------------- 43 #-------------------------------------------------------
51 # int verify_home_path( directory_name ) 44 # int verify_home_path( directory_name )
52 # added by Snowdog 3-8-05 45 # added by Snowdog 3-8-05
53 # updated with bailout code. Snowdog 7-25-05 46 # updated with bailout code. Snowdog 7-25-05
54 #------------------------------------------------------- 47 #-------------------------------------------------------
55 def verify_home_path( path ): 48 def verify_home_path( path ):
56 """checks for key ORPG files in the openrpg tree 49 """checks for key ORPG files in the openrpg tree
57 and askes for user intervention if their is a problem""" 50 and askes for user intervention if their is a problem"""
58
59 try: 51 try:
60 #verify that the root dir (as supplied) exists 52 #verify that the root dir (as supplied) exists
61 if not verify_file(path): return 0 53 if not verify_file(path): return 0
62 54
63 #These checks require that 'path' have a separator at the end. 55 #These checks require that 'path' have a separator at the end.
64 #Check and temporarily add one if needed 56 #Check and temporarily add one if needed
65 if (path[(len(path)-len(os.sep)):] != os.sep): 57 if (path[(len(path)-len(os.sep)):] != os.sep):
66 path = path + os.sep 58 path = path + os.sep
67
68 # These files should always exist at the root orpg dir 59 # These files should always exist at the root orpg dir
69 check_files = ["orpg","data","images"] 60 check_files = ["orpg","data","images"]
70 for n in range(len(check_files)): 61 for n in range(len(check_files)):
71 if not verify_file(path + check_files[n]): return 0 62 if not verify_file(path + check_files[n]): return 0
72
73 except: 63 except:
74 # an error occured while verifying the directory structure 64 # an error occured while verifying the directory structure
75 # bail out with error signal 65 # bail out with error signal
76 return 0 66 return 0
77 67
78 #all files and directories exist. 68 #all files and directories exist.
79 return 1 69 return 1
80
81
82 70
83 #------------------------------------------------------- 71 #-------------------------------------------------------
84 # int verify_file( absolute_path ) 72 # int verify_file( absolute_path )
85 # added by Snowdog 3-8-05 73 # added by Snowdog 3-8-05
86 #------------------------------------------------------- 74 #-------------------------------------------------------
97 #------------------------------------------------------- 85 #-------------------------------------------------------
98 # pathname get_user_help() 86 # pathname get_user_help()
99 # added by Snowdog 3-8-05 87 # added by Snowdog 3-8-05
100 # bug fix (SF #1242456) and updated with bailout code. Snowdog 7-25-05 88 # bug fix (SF #1242456) and updated with bailout code. Snowdog 7-25-05
101 #------------------------------------------------------- 89 #-------------------------------------------------------
90 ## This can be removed in the future. TaS '09
102 def get_user_located_root(): 91 def get_user_located_root():
103 """Notify the user of directory problems 92 """Notify the user of directory problems
104 and show directory selection dialog """ 93 and show directory selection dialog """
105 94
106 if WXLOADED: 95 if WXLOADED:
107 app = tmpApp(0) 96 app = tmpApp(0)
108 app.MainLoop() 97 app.MainLoop()
109 98
110 dir = None 99 dir = None
111
112 try: 100 try:
113 msg = "OpenRPG cannot locate critical files.\nPlease locate the /System/ directory in the following window" 101 msg = "OpenRPG cannot locate critical files.\nPlease locate the /System/ directory in the following window"
114 alert= wx.MessageDialog(None,msg,"Warning",wx.OK|wx.ICON_ERROR) 102 alert= wx.MessageDialog(None,msg,"Warning",wx.OK|wx.ICON_ERROR)
115 alert.Show() 103 alert.Show()
116 if alert.ShowModal() == wx.OK: 104 if alert.ShowModal() == wx.OK:
117 alert.Destroy() 105 alert.Destroy()
118 dlg = wx.DirDialog(None, "Locate the openrpg1 directory:",style=wx.DD_DEFAULT_STYLE) 106 dlg = wx.DirDialog(None, "Locate the System directory:",style=wx.DD_DEFAULT_STYLE)
119 if dlg.ShowModal() == wx.ID_OK: 107 if dlg.ShowModal() == wx.ID_OK:
120 dir = dlg.GetPath() 108 dir = dlg.GetPath()
121 dlg.Destroy() 109 dlg.Destroy()
122 app.Destroy() 110 app.Destroy()
123 return dir 111 return dir