mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Set remote statistics.
This commit is contained in:
@@ -42,52 +42,61 @@ namespace DiscImageChef.Commands
|
||||
{
|
||||
internal class MediaScanCommand : Command
|
||||
{
|
||||
private string devicePath;
|
||||
private string ibgLogPath;
|
||||
private string mhddLogPath;
|
||||
private bool showHelp;
|
||||
string devicePath;
|
||||
string ibgLogPath;
|
||||
string mhddLogPath;
|
||||
bool showHelp;
|
||||
|
||||
public MediaScanCommand() : base("media-scan", "Scans the media inserted on a device.")
|
||||
{
|
||||
public MediaScanCommand() : base("media-scan", "Scans the media inserted on a device.") =>
|
||||
Options = new OptionSet
|
||||
{
|
||||
$"{MainClass.AssemblyTitle} {MainClass.AssemblyVersion?.InformationalVersion}",
|
||||
$"{MainClass.AssemblyCopyright}",
|
||||
"",
|
||||
$"usage: DiscImageChef {Name} [OPTIONS] devicepath",
|
||||
"",
|
||||
$"{MainClass.AssemblyCopyright}", "", $"usage: DiscImageChef {Name} [OPTIONS] devicepath", "",
|
||||
Help,
|
||||
{"mhdd-log|mw=", "Write a log of the scan in the format used by MHDD.", s => mhddLogPath = s},
|
||||
{"ibg-log|b=", "Write a log of the scan in the format used by ImgBurn.", s => ibgLogPath = s},
|
||||
{"help|h|?", "Show this message and exit.", v => showHelp = v != null}
|
||||
{
|
||||
"mhdd-log|mw=", "Write a log of the scan in the format used by MHDD.", s => mhddLogPath = s
|
||||
},
|
||||
{
|
||||
"ibg-log|b=", "Write a log of the scan in the format used by ImgBurn.", s => ibgLogPath = s
|
||||
},
|
||||
{
|
||||
"help|h|?", "Show this message and exit.", v => showHelp = v != null
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public override int Invoke(IEnumerable<string> arguments)
|
||||
{
|
||||
var extra = Options.Parse(arguments);
|
||||
List<string> extra = Options.Parse(arguments);
|
||||
|
||||
if (showHelp)
|
||||
if(showHelp)
|
||||
{
|
||||
Options.WriteOptionDescriptions(CommandSet.Out);
|
||||
return (int) ErrorNumber.HelpRequested;
|
||||
|
||||
return(int)ErrorNumber.HelpRequested;
|
||||
}
|
||||
|
||||
MainClass.PrintCopyright();
|
||||
if (MainClass.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
|
||||
if (MainClass.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
|
||||
|
||||
if(MainClass.Debug)
|
||||
DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
|
||||
|
||||
if(MainClass.Verbose)
|
||||
DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
|
||||
|
||||
Statistics.AddCommand("media-scan");
|
||||
|
||||
if (extra.Count > 1)
|
||||
if(extra.Count > 1)
|
||||
{
|
||||
DicConsole.ErrorWriteLine("Too many arguments.");
|
||||
return (int) ErrorNumber.UnexpectedArgumentCount;
|
||||
|
||||
return(int)ErrorNumber.UnexpectedArgumentCount;
|
||||
}
|
||||
|
||||
if (extra.Count == 0)
|
||||
if(extra.Count == 0)
|
||||
{
|
||||
DicConsole.ErrorWriteLine("Missing device path.");
|
||||
return (int) ErrorNumber.MissingArgument;
|
||||
|
||||
return(int)ErrorNumber.MissingArgument;
|
||||
}
|
||||
|
||||
devicePath = extra[0];
|
||||
@@ -98,44 +107,57 @@ namespace DiscImageChef.Commands
|
||||
DicConsole.DebugWriteLine("Media-Scan command", "--mhdd-log={0}", mhddLogPath);
|
||||
DicConsole.DebugWriteLine("Media-Scan command", "--verbose={0}", MainClass.Verbose);
|
||||
|
||||
if (devicePath.Length == 2 && devicePath[1] == ':' && devicePath[0] != '/' && char.IsLetter(devicePath[0]))
|
||||
if(devicePath.Length == 2 &&
|
||||
devicePath[1] == ':' &&
|
||||
devicePath[0] != '/' &&
|
||||
char.IsLetter(devicePath[0]))
|
||||
devicePath = "\\\\.\\" + char.ToUpper(devicePath[0]) + ':';
|
||||
|
||||
Device dev;
|
||||
|
||||
try
|
||||
{
|
||||
dev = new Device(devicePath);
|
||||
|
||||
if (dev.Error)
|
||||
if(dev.IsRemote)
|
||||
Statistics.AddRemote(dev.RemoteApplication, dev.RemoteVersion, dev.RemoteOperatingSystem,
|
||||
dev.RemoteOperatingSystemVersion, dev.RemoteArchitecture);
|
||||
|
||||
if(dev.Error)
|
||||
{
|
||||
DicConsole.ErrorWriteLine(Error.Print(dev.LastError));
|
||||
return (int) ErrorNumber.CannotOpenDevice;
|
||||
|
||||
return(int)ErrorNumber.CannotOpenDevice;
|
||||
}
|
||||
}
|
||||
catch (DeviceException e)
|
||||
catch(DeviceException e)
|
||||
{
|
||||
DicConsole.ErrorWriteLine(e.Message ?? Error.Print(e.LastError));
|
||||
return (int) ErrorNumber.CannotOpenDevice;
|
||||
|
||||
return(int)ErrorNumber.CannotOpenDevice;
|
||||
}
|
||||
|
||||
Statistics.AddDevice(dev);
|
||||
|
||||
var scanner = new MediaScan(mhddLogPath, ibgLogPath, devicePath, dev);
|
||||
scanner.UpdateStatus += Progress.UpdateStatus;
|
||||
scanner.UpdateStatus += Progress.UpdateStatus;
|
||||
scanner.StoppingErrorMessage += Progress.ErrorMessage;
|
||||
scanner.UpdateProgress += Progress.UpdateProgress;
|
||||
scanner.PulseProgress += Progress.PulseProgress;
|
||||
scanner.InitProgress += Progress.InitProgress;
|
||||
scanner.EndProgress += Progress.EndProgress;
|
||||
scanner.UpdateProgress += Progress.UpdateProgress;
|
||||
scanner.PulseProgress += Progress.PulseProgress;
|
||||
scanner.InitProgress += Progress.InitProgress;
|
||||
scanner.EndProgress += Progress.EndProgress;
|
||||
|
||||
System.Console.CancelKeyPress += (sender, e) =>
|
||||
{
|
||||
e.Cancel = true;
|
||||
scanner.Abort();
|
||||
};
|
||||
var results = scanner.Scan();
|
||||
|
||||
ScanResults results = scanner.Scan();
|
||||
|
||||
DicConsole.WriteLine("Took a total of {0} seconds ({1} processing commands).", results.TotalTime,
|
||||
results.ProcessingTime);
|
||||
results.ProcessingTime);
|
||||
|
||||
DicConsole.WriteLine("Average speed: {0:F3} MiB/sec.", results.AvgSpeed);
|
||||
DicConsole.WriteLine("Fastest speed burst: {0:F3} MiB/sec.", results.MaxSpeed);
|
||||
DicConsole.WriteLine("Slowest speed burst: {0:F3} MiB/sec.", results.MinSpeed);
|
||||
@@ -146,23 +168,25 @@ namespace DiscImageChef.Commands
|
||||
DicConsole.WriteLine("{0} sectors took less than 150 ms but more than 50 ms.", results.D);
|
||||
DicConsole.WriteLine("{0} sectors took less than 500 ms but more than 150 ms.", results.E);
|
||||
DicConsole.WriteLine("{0} sectors took more than 500 ms.", results.F);
|
||||
DicConsole.WriteLine("{0} sectors could not be read.",
|
||||
results.UnreadableSectors.Count);
|
||||
if (results.UnreadableSectors.Count > 0)
|
||||
foreach (var bad in results.UnreadableSectors)
|
||||
DicConsole.WriteLine("{0} sectors could not be read.", results.UnreadableSectors.Count);
|
||||
|
||||
if(results.UnreadableSectors.Count > 0)
|
||||
foreach(ulong bad in results.UnreadableSectors)
|
||||
DicConsole.WriteLine("Sector {0} could not be read", bad);
|
||||
|
||||
DicConsole.WriteLine();
|
||||
|
||||
#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator
|
||||
if (results.SeekTotal != 0 || results.SeekMin != double.MaxValue || results.SeekMax != double.MinValue)
|
||||
#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator
|
||||
DicConsole.WriteLine(
|
||||
"Testing {0} seeks, longest seek took {1:F3} ms, fastest one took {2:F3} ms. ({3:F3} ms average)",
|
||||
results.SeekTimes, results.SeekMax, results.SeekMin, results.SeekTotal / 1000);
|
||||
#pragma warning disable RECS0018 // Comparison of floating point numbers with equality operator
|
||||
if(results.SeekTotal != 0 ||
|
||||
results.SeekMin != double.MaxValue ||
|
||||
results.SeekMax != double.MinValue)
|
||||
#pragma warning restore RECS0018 // Comparison of floating point numbers with equality operator
|
||||
DicConsole.WriteLine("Testing {0} seeks, longest seek took {1:F3} ms, fastest one took {2:F3} ms. ({3:F3} ms average)",
|
||||
results.SeekTimes, results.SeekMax, results.SeekMin, results.SeekTotal / 1000);
|
||||
|
||||
dev.Close();
|
||||
return (int) ErrorNumber.NoError;
|
||||
|
||||
return(int)ErrorNumber.NoError;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user