diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index 6fa8a24..71077f2 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs | |||
@@ -91,8 +91,23 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
91 | m_log.Info("[MRM] Starting MRM"); | 91 | m_log.Info("[MRM] Starting MRM"); |
92 | mmb.Start(); | 92 | mmb.Start(); |
93 | } | 93 | } |
94 | catch (UnauthorizedAccessException e) | ||
95 | { | ||
96 | m_log.Error("[MRM] UAE " + e.Message); | ||
97 | m_log.Error("[MRM] " + e.StackTrace); | ||
98 | |||
99 | if (e.InnerException != null) | ||
100 | m_log.Error("[MRM] " + e.InnerException); | ||
101 | |||
102 | m_scene.Broadcast(delegate(IClientAPI user) | ||
103 | { | ||
104 | user.SendAlertMessage( | ||
105 | "MRM UnAuthorizedAccess: " + e); | ||
106 | }); | ||
107 | } | ||
94 | catch (Exception e) | 108 | catch (Exception e) |
95 | { | 109 | { |
110 | m_log.Info("[MRM] Error: " + e); | ||
96 | m_scene.Broadcast(delegate(IClientAPI user) | 111 | m_scene.Broadcast(delegate(IClientAPI user) |
97 | { | 112 | { |
98 | user.SendAlertMessage( | 113 | user.SendAlertMessage( |
@@ -133,13 +148,15 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
133 | /// <returns></returns> | 148 | /// <returns></returns> |
134 | internal string CompileFromDotNetText(string Script, string uuid) | 149 | internal string CompileFromDotNetText(string Script, string uuid) |
135 | { | 150 | { |
151 | m_log.Info("MRM 1"); | ||
136 | const string ext = ".cs"; | 152 | const string ext = ".cs"; |
137 | const string FilePrefix = "MiniModule"; | 153 | const string FilePrefix = "MiniModule"; |
138 | 154 | ||
139 | // Output assembly name | 155 | // Output assembly name |
140 | string OutFile = Path.Combine("MiniModules", Path.Combine( | 156 | string OutFile = Path.Combine("MiniModules", Path.Combine( |
141 | m_scene.RegionInfo.RegionID.ToString(), | 157 | m_scene.RegionInfo.RegionID.ToString(), |
142 | FilePrefix + "_compiled_" + uuid + ".dll")); | 158 | FilePrefix + "_compiled_" + uuid + "_" + |
159 | Util.RandomClass.Next(9000) + ".dll")); | ||
143 | 160 | ||
144 | // Create Directories for Assemblies | 161 | // Create Directories for Assemblies |
145 | if (!Directory.Exists("MiniModules")) | 162 | if (!Directory.Exists("MiniModules")) |
@@ -148,10 +165,19 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
148 | if (!Directory.Exists(tmp)) | 165 | if (!Directory.Exists(tmp)) |
149 | Directory.CreateDirectory(tmp); | 166 | Directory.CreateDirectory(tmp); |
150 | 167 | ||
168 | |||
169 | m_log.Info("MRM 2"); | ||
170 | |||
151 | try | 171 | try |
152 | { | 172 | { |
153 | File.Delete(OutFile); | 173 | File.Delete(OutFile); |
154 | } | 174 | } |
175 | catch (UnauthorizedAccessException e) | ||
176 | { | ||
177 | throw new Exception("Unable to delete old existing " + | ||
178 | "script-file before writing new. Compile aborted: " + | ||
179 | e); | ||
180 | } | ||
155 | catch (IOException e) | 181 | catch (IOException e) |
156 | { | 182 | { |
157 | throw new Exception("Unable to delete old existing " + | 183 | throw new Exception("Unable to delete old existing " + |
@@ -159,6 +185,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
159 | e); | 185 | e); |
160 | } | 186 | } |
161 | 187 | ||
188 | m_log.Info("MRM 3"); | ||
189 | |||
162 | // DEBUG - write source to disk | 190 | // DEBUG - write source to disk |
163 | string srcFileName = FilePrefix + "_source_" + | 191 | string srcFileName = FilePrefix + "_source_" + |
164 | Path.GetFileNameWithoutExtension(OutFile) + ext; | 192 | Path.GetFileNameWithoutExtension(OutFile) + ext; |
@@ -176,6 +204,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
176 | srcFileName + "\": " + ex.ToString()); | 204 | srcFileName + "\": " + ex.ToString()); |
177 | } | 205 | } |
178 | 206 | ||
207 | m_log.Info("MRM 4"); | ||
208 | |||
179 | // Do actual compile | 209 | // Do actual compile |
180 | CompilerParameters parameters = new CompilerParameters(); | 210 | CompilerParameters parameters = new CompilerParameters(); |
181 | 211 | ||
@@ -196,9 +226,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
196 | parameters.IncludeDebugInformation = true; | 226 | parameters.IncludeDebugInformation = true; |
197 | parameters.TreatWarningsAsErrors = false; | 227 | parameters.TreatWarningsAsErrors = false; |
198 | 228 | ||
229 | m_log.Info("MRM 5"); | ||
230 | |||
199 | CompilerResults results = CScodeProvider.CompileAssemblyFromSource( | 231 | CompilerResults results = CScodeProvider.CompileAssemblyFromSource( |
200 | parameters, Script); | 232 | parameters, Script); |
201 | 233 | ||
234 | m_log.Info("MRM 6"); | ||
235 | |||
202 | int display = 5; | 236 | int display = 5; |
203 | if (results.Errors.Count > 0) | 237 | if (results.Errors.Count > 0) |
204 | { | 238 | { |
@@ -232,6 +266,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
232 | } | 266 | } |
233 | } | 267 | } |
234 | 268 | ||
269 | m_log.Info("MRM 7"); | ||
270 | |||
235 | if (!File.Exists(OutFile)) | 271 | if (!File.Exists(OutFile)) |
236 | { | 272 | { |
237 | string errtext = String.Empty; | 273 | string errtext = String.Empty; |
@@ -256,6 +292,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
256 | throw new Exception(errtext); | 292 | throw new Exception(errtext); |
257 | } | 293 | } |
258 | 294 | ||
295 | m_log.Info("MRM 8"); | ||
296 | |||
259 | // Convert to base64 | 297 | // Convert to base64 |
260 | // | 298 | // |
261 | string filetext = Convert.ToBase64String(data); | 299 | string filetext = Convert.ToBase64String(data); |
@@ -264,10 +302,14 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
264 | 302 | ||
265 | Byte[] buf = enc.GetBytes(filetext); | 303 | Byte[] buf = enc.GetBytes(filetext); |
266 | 304 | ||
305 | m_log.Info("MRM 9"); | ||
306 | |||
267 | FileStream sfs = File.Create(OutFile + ".cil.b64"); | 307 | FileStream sfs = File.Create(OutFile + ".cil.b64"); |
268 | sfs.Write(buf, 0, buf.Length); | 308 | sfs.Write(buf, 0, buf.Length); |
269 | sfs.Close(); | 309 | sfs.Close(); |
270 | 310 | ||
311 | m_log.Info("MRM 10"); | ||
312 | |||
271 | return OutFile; | 313 | return OutFile; |
272 | } | 314 | } |
273 | } | 315 | } |