Caught exceptions in some console commands

From: Arthur Rodrigo S Valadares <arthursv@linux.vnet.ibm.com>
0.6.2-post-fixes
Sean Dague 2009-01-12 15:34:05 +00:00
parent d770bea291
commit 77f0df6394
1 changed files with 53 additions and 26 deletions

View File

@ -46,7 +46,7 @@ using Timer=System.Timers.Timer;
namespace OpenSim namespace OpenSim
{ {
/// <summary> /// <summary>
/// Interactive OpenSim region server /// Interactive OpenSim region server
/// </summary> /// </summary>
public class OpenSim : OpenSimBase, conscmd_callback public class OpenSim : OpenSimBase, conscmd_callback
@ -137,7 +137,7 @@ namespace OpenSim
} }
base.ShutdownSpecific(); base.ShutdownSpecific();
} }
private void RunAutoTimerScript(object sender, EventArgs e) private void RunAutoTimerScript(object sender, EventArgs e)
{ {
if (m_timedScript != "disabled") if (m_timedScript != "disabled")
@ -188,11 +188,11 @@ namespace OpenSim
/// </summary> /// </summary>
/// <param name="fileName"></param> /// <param name="fileName"></param>
private void RunCommandScript(string fileName) private void RunCommandScript(string fileName)
{ {
if (File.Exists(fileName)) if (File.Exists(fileName))
{ {
m_log.Info("[COMMANDFILE]: Running " + fileName); m_log.Info("[COMMANDFILE]: Running " + fileName);
StreamReader readFile = File.OpenText(fileName); StreamReader readFile = File.OpenText(fileName);
string currentCommand; string currentCommand;
while ((currentCommand = readFile.ReadLine()) != null) while ((currentCommand = readFile.ReadLine()) != null)
@ -335,6 +335,12 @@ namespace OpenSim
m_log.Info("[ Login ] Login are enabled"); m_log.Info("[ Login ] Login are enabled");
break; break;
case "create-region": case "create-region":
if (cmdparams.Length < 2)
{
m_console.Error("Usage: create-region <region name> <region_file.xml>");
break;
}
string regionsDir = ConfigSource.Source.Configs["Startup"].GetString("regionload_regionsdir", "Regions").Trim(); string regionsDir = ConfigSource.Source.Configs["Startup"].GetString("regionload_regionsdir", "Regions").Trim();
string regionFile = String.Format("{0}/{1}", regionsDir, cmdparams[1]); string regionFile = String.Format("{0}/{1}", regionsDir, cmdparams[1]);
// Allow absolute and relative specifiers // Allow absolute and relative specifiers
@ -422,7 +428,7 @@ namespace OpenSim
} }
else else
{ {
IConfig c = m_config.Source.Configs[cmdparams[1]]; // DefaultConfig().Configs[cmdparams[1]]; IConfig c = m_config.Source.Configs[cmdparams[1]]; // DefaultConfig().Configs[cmdparams[1]];
if (c == null) if (c == null)
{ {
m_console.Notice(n, "Section \"" + cmdparams[1] + "\" does not exist."); m_console.Notice(n, "Section \"" + cmdparams[1] + "\" does not exist.");
@ -490,10 +496,10 @@ namespace OpenSim
m_commsManager.AddInventoryService(cmdparams[0]); m_commsManager.AddInventoryService(cmdparams[0]);
} }
break; break;
case "reset": case "reset":
Reset(cmdparams); Reset(cmdparams);
break; break;
default: default:
string[] tmpPluginArgs = new string[cmdparams.Length + 1]; string[] tmpPluginArgs = new string[cmdparams.Length + 1];
@ -551,7 +557,7 @@ namespace OpenSim
break; break;
} }
} }
/// <summary> /// <summary>
/// Execute switch for some of the reset commands /// Execute switch for some of the reset commands
/// </summary> /// </summary>
@ -564,7 +570,7 @@ namespace OpenSim
switch (args[0]) switch (args[0])
{ {
case "user": case "user":
switch (args[1]) switch (args[1])
{ {
case "password": case "password":
@ -578,10 +584,10 @@ namespace OpenSim
} }
break; break;
} }
break; break;
} }
} }
/// <summary> /// <summary>
/// Turn on some debugging values for OpenSim. /// Turn on some debugging values for OpenSim.
@ -708,7 +714,7 @@ namespace OpenSim
case "assets": case "assets":
m_assetCache.ShowState(); m_assetCache.ShowState();
break; break;
case "users": case "users":
IList agents; IList agents;
if (showParams.Length > 1 && showParams[1] == "full") if (showParams.Length > 1 && showParams[1] == "full")
@ -860,7 +866,7 @@ namespace OpenSim
m_log.ErrorFormat("[CONSOLE]: A user with the name {0} {1} already exists!", firstName, lastName); m_log.ErrorFormat("[CONSOLE]: A user with the name {0} {1} already exists!", firstName, lastName);
} }
} }
/// <summary> /// <summary>
/// Reset a user password. /// Reset a user password.
/// </summary> /// </summary>
@ -870,7 +876,7 @@ namespace OpenSim
string firstName; string firstName;
string lastName; string lastName;
string newPassword; string newPassword;
if (cmdparams.Length < 3) if (cmdparams.Length < 3)
firstName = MainConsole.Instance.CmdPrompt("First name"); firstName = MainConsole.Instance.CmdPrompt("First name");
else firstName = cmdparams[2]; else firstName = cmdparams[2];
@ -882,9 +888,9 @@ namespace OpenSim
if ( cmdparams.Length < 5 ) if ( cmdparams.Length < 5 )
newPassword = MainConsole.Instance.PasswdPrompt("New password"); newPassword = MainConsole.Instance.PasswdPrompt("New password");
else newPassword = cmdparams[4]; else newPassword = cmdparams[4];
m_commsManager.UserAdminService.ResetUserPassword(firstName, lastName, newPassword); m_commsManager.UserAdminService.ResetUserPassword(firstName, lastName, newPassword);
} }
protected void SaveXml(string[] cmdparams) protected void SaveXml(string[] cmdparams)
{ {
@ -933,7 +939,14 @@ namespace OpenSim
} }
else else
{ {
m_sceneManager.LoadCurrentSceneFromXml(DEFAULT_PRIM_BACKUP_FILENAME, false, loadOffset); try
{
m_sceneManager.LoadCurrentSceneFromXml(DEFAULT_PRIM_BACKUP_FILENAME, false, loadOffset);
}
catch
{
m_console.Error("Default xml not found. Usage: load-xml <filename>");
}
} }
} }
@ -957,7 +970,14 @@ namespace OpenSim
} }
else else
{ {
m_sceneManager.LoadCurrentSceneFromXml2(DEFAULT_PRIM_BACKUP_FILENAME); try
{
m_sceneManager.LoadCurrentSceneFromXml2(DEFAULT_PRIM_BACKUP_FILENAME);
}
catch
{
m_console.Error("Default xml not found. Usage: load-xml2 <filename>");
}
} }
} }
@ -973,7 +993,14 @@ namespace OpenSim
} }
else else
{ {
m_sceneManager.LoadArchiveToCurrentScene(DEFAULT_OAR_BACKUP_FILENAME); try
{
m_sceneManager.LoadArchiveToCurrentScene(DEFAULT_OAR_BACKUP_FILENAME);
}
catch
{
m_console.Error("Default oar not found. Usage: load-oar <filename>");
}
} }
} }
@ -992,7 +1019,7 @@ namespace OpenSim
m_sceneManager.SaveCurrentSceneToArchive(DEFAULT_OAR_BACKUP_FILENAME); m_sceneManager.SaveCurrentSceneToArchive(DEFAULT_OAR_BACKUP_FILENAME);
} }
} }
/// <summary> /// <summary>
/// Load inventory from an inventory file archive /// Load inventory from an inventory file archive
/// </summary> /// </summary>
@ -1005,16 +1032,16 @@ namespace OpenSim
m_log.Error("[CONSOLE]: usage is load-inv <first name> <last name> <inventory path> [<load file path>]"); m_log.Error("[CONSOLE]: usage is load-inv <first name> <last name> <inventory path> [<load file path>]");
return; return;
} }
string firstName = cmdparams[0]; string firstName = cmdparams[0];
string lastName = cmdparams[1]; string lastName = cmdparams[1];
string invPath = cmdparams[2]; string invPath = cmdparams[2];
string loadPath = (cmdparams.Length > 3 ? cmdparams[3] : DEFAULT_INV_BACKUP_FILENAME); string loadPath = (cmdparams.Length > 3 ? cmdparams[3] : DEFAULT_INV_BACKUP_FILENAME);
new InventoryArchiveReadRequest( new InventoryArchiveReadRequest(
m_sceneManager.CurrentOrFirstScene, m_commsManager).execute( m_sceneManager.CurrentOrFirstScene, m_commsManager).execute(
firstName, lastName, invPath, loadPath); firstName, lastName, invPath, loadPath);
} }
/// <summary> /// <summary>
/// Save inventory to a file archive /// Save inventory to a file archive
@ -1028,17 +1055,17 @@ namespace OpenSim
m_log.Error("[CONSOLE]: usage is save-inv <first name> <last name> <inventory path> [<save file path>]"); m_log.Error("[CONSOLE]: usage is save-inv <first name> <last name> <inventory path> [<save file path>]");
return; return;
} }
string firstName = cmdparams[0]; string firstName = cmdparams[0];
string lastName = cmdparams[1]; string lastName = cmdparams[1];
string invPath = cmdparams[2]; string invPath = cmdparams[2];
string savePath = (cmdparams.Length > 3 ? cmdparams[3] : DEFAULT_INV_BACKUP_FILENAME); string savePath = (cmdparams.Length > 3 ? cmdparams[3] : DEFAULT_INV_BACKUP_FILENAME);
new InventoryArchiveWriteRequest( new InventoryArchiveWriteRequest(
m_sceneManager.CurrentOrFirstScene,m_commsManager).execute( m_sceneManager.CurrentOrFirstScene,m_commsManager).execute(
firstName, lastName, invPath, savePath); firstName, lastName, invPath, savePath);
} }
private static string CombineParams(string[] commandParams, int pos) private static string CombineParams(string[] commandParams, int pos)
{ {
string result = String.Empty; string result = String.Empty;