Add "dump object uuid" console command. This allows any object in the scene to be serialized and dumped to XML for debug purposes.

integration
Justin Clark-Casey (justincc) 2012-10-24 02:05:28 +01:00
parent 326f1507fa
commit 73db057fa1
2 changed files with 168 additions and 91 deletions

View File

@ -32,6 +32,8 @@ using System.Reflection;
using log4net; using log4net;
using OpenMetaverse; using OpenMetaverse;
namespace OpenSim.Framework.Console
{
public class ConsoleUtil public class ConsoleUtil
{ {
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@ -59,6 +61,27 @@ delete object pos ,,-~ to ,,30";
public const string VectorSeparator = ","; public const string VectorSeparator = ",";
public static char[] VectorSeparatorChars = VectorSeparator.ToCharArray(); public static char[] VectorSeparatorChars = VectorSeparator.ToCharArray();
/// <summary>
/// Try to parse a console UUID from the console.
/// </summary>
/// <remarks>
/// Will complain to the console if parsing fails.
/// </remarks>
/// <returns></returns>
/// <param name='console'></param>
/// <param name='rawUuid'></param>
/// <param name='uuid'></param>
public static bool TryParseConsoleUuid(ICommandConsole console, string rawUuid, out UUID uuid)
{
if (!UUID.TryParse(rawUuid, out uuid))
{
console.OutputFormat("{0} is not a valid uuid", rawUuid);
return false;
}
return true;
}
/// <summary> /// <summary>
/// Convert a minimum vector input from the console to an OpenMetaverse.Vector3 /// Convert a minimum vector input from the console to an OpenMetaverse.Vector3
/// </summary> /// </summary>
@ -129,3 +152,4 @@ delete object pos ,,-~ to ,,30";
return Vector3.TryParse(semiDigestedConsoleVector, out vector); return Vector3.TryParse(semiDigestedConsoleVector, out vector);
} }
} }
}

View File

@ -27,10 +27,12 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Xml;
using log4net; using log4net;
using Mono.Addins; using Mono.Addins;
using NDesk.Options; using NDesk.Options;
@ -41,6 +43,7 @@ using OpenSim.Framework.Console;
using OpenSim.Framework.Monitoring; using OpenSim.Framework.Monitoring;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Scenes.Serialization;
namespace OpenSim.Region.CoreModules.World.Objects.Commands namespace OpenSim.Region.CoreModules.World.Objects.Commands
{ {
@ -181,6 +184,16 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
"Show details of scene object parts within the given area.", "Show details of scene object parts within the given area.",
ConsoleUtil.CoordHelp, ConsoleUtil.CoordHelp,
HandleShowPartByPos); HandleShowPartByPos);
m_console.Commands.AddCommand(
"Objects",
false,
"dump object uuid",
"dump object uuid <UUID>",
"Dump the formatted serialization of the given object to the file <UUID>.xml",
"e.g. dump object uuid c1ed6809-cc24-4061-a4c2-93082a2d1f1d will dump serialization to c1ed6809-cc24-4061-a4c2-93082a2d1f1d.xml\n"
+ "To locate the UUID in the first place, you need to use the other show object commands",
HandleDumpObjectByUuid);
} }
public void RemoveRegion(Scene scene) public void RemoveRegion(Scene scene)
@ -447,6 +460,46 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
OutputSopsToConsole(searchPredicate, true); OutputSopsToConsole(searchPredicate, true);
} }
private void HandleDumpObjectByUuid(string module, string[] cmdparams)
{
if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene))
return;
if (cmdparams.Length < 4)
{
m_console.OutputFormat("Usage: dump object uuid <uuid>");
return;
}
UUID objectUuid;
if (!ConsoleUtil.TryParseConsoleUuid(m_console, cmdparams[3], out objectUuid))
return;
SceneObjectGroup so = m_scene.GetSceneObjectGroup(objectUuid);
if (so == null)
{
// m_console.OutputFormat("No part found with uuid {0}", objectUuid);
return;
}
string fileName = string.Format("{0}.xml", objectUuid);
if (File.Exists(fileName))
{
m_console.OutputFormat("File {0} already exists. Please move or remove it.", fileName);
return;
}
using (XmlTextWriter xtw = new XmlTextWriter(fileName, Encoding.UTF8))
{
xtw.Formatting = Formatting.Indented;
SceneObjectSerializer.ToOriginalXmlFormat(so, xtw, true);
}
m_console.OutputFormat("Object dumped to file {0}", fileName);
}
/// <summary> /// <summary>
/// Append a scene object report to an input StringBuilder /// Append a scene object report to an input StringBuilder
/// </summary> /// </summary>