From 1a0fbf8fdb819ec7be1f2820ddcfe06638097861 Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Mon, 18 Aug 2025 14:22:40 +0100 Subject: [PATCH] Move markup to resources in media scan command. --- Aaru.Core/Devices/Scanning/ATA.cs | 42 ++++++++--------- Aaru.Core/Devices/Scanning/SCSI.cs | 48 +++++++++----------- Aaru.Core/Devices/Scanning/SecureDigital.cs | 30 ++++++------- Aaru.Localization/Core.resx | 50 ++++++++++----------- Aaru/Commands/Media/Scan.cs | 49 ++++++++++---------- 5 files changed, 103 insertions(+), 116 deletions(-) diff --git a/Aaru.Core/Devices/Scanning/ATA.cs b/Aaru.Core/Devices/Scanning/ATA.cs index 149fa976f..6a09c8b60 100644 --- a/Aaru.Core/Devices/Scanning/ATA.cs +++ b/Aaru.Core/Devices/Scanning/ATA.cs @@ -120,8 +120,7 @@ public sealed partial class MediaScan if(ataReader.IsLba) { - UpdateStatus?.Invoke(string.Format($"[slateblue1]{Localization.Core.Reading_0_sectors_at_a_time}[/]", - $"[violet]{blocksToRead}[/]")); + UpdateStatus?.Invoke(string.Format(Localization.Core.Reading_0_sectors_at_a_time, blocksToRead)); InitBlockMap?.Invoke(results.Blocks, blockSize, blocksToRead, ataProfile); mhddLog = new MhddLog(_mhddLogPath, _dev, results.Blocks, blockSize, blocksToRead, false); @@ -142,12 +141,12 @@ public sealed partial class MediaScan if(currentSpeed < results.MinSpeed && currentSpeed > 0) results.MinSpeed = currentSpeed; - UpdateProgress?.Invoke(string.Format($"[slateblue1]{Localization.Core.Reading_sector_0_of_1_2}[/]", - $"[lime]{i}[/]", - $"[violet]{results.Blocks}[/]", - $"[aqua]{ByteSize.FromMegabytes(currentSpeed) - .Per(_oneSecond) - .Humanize()}[/]"), + UpdateProgress?.Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, + i, + results.Blocks, + ByteSize.FromMegabytes(currentSpeed) + .Per(_oneSecond) + .Humanize()), (long)i, (long)results.Blocks); @@ -234,8 +233,7 @@ public sealed partial class MediaScan uint seekPos = (uint)rnd.Next((int)results.Blocks); - PulseProgress?.Invoke(string.Format($"[slateblue1]{Localization.Core.Seeking_to_sector_0}[/]", - $"[lime]{seekPos}[/]")); + PulseProgress?.Invoke(string.Format(Localization.Core.Seeking_to_sector_0, seekPos)); ataReader.Seek(seekPos, out seekCur); @@ -275,14 +273,13 @@ public sealed partial class MediaScan if(currentSpeed < results.MinSpeed && currentSpeed > 0) results.MinSpeed = currentSpeed; - PulseProgress - ?.Invoke(string.Format($"[slateblue1]{Localization.Core.Reading_cylinder_0_head_1_sector_2_3}[/]", - $"[lime]{cy}[/]", - $"[lime]{hd}[/]", - $"[lime]{sc}[/]", - $"[aqua]{ByteSize.FromMegabytes(currentSpeed) - .Per(_oneSecond) - .Humanize()}[/]")); + PulseProgress?.Invoke(string.Format(Localization.Core.Reading_cylinder_0_head_1_sector_2_3, + cy, + hd, + sc, + ByteSize.FromMegabytes(currentSpeed) + .Per(_oneSecond) + .Humanize())); bool error = ataReader.ReadChs(out cmdBuf, cy, hd, sc, out duration, out _); @@ -370,11 +367,10 @@ public sealed partial class MediaScan byte seekHd = (byte)rnd.Next(heads); byte seekSc = (byte)rnd.Next(sectors); - PulseProgress - ?.Invoke(string.Format($"[slateblue1]{Localization.Core.Seeking_to_cylinder_0_head_1_sector_2}[/]", - $"[lime]{seekCy}[/]", - $"[lime]{seekHd}[/]", - $"[lime]{seekSc}[/]")); + PulseProgress?.Invoke(string.Format(Localization.Core.Seeking_to_cylinder_0_head_1_sector_2, + seekCy, + seekHd, + seekSc)); ataReader.SeekChs(seekCy, seekHd, seekSc, out seekCur); diff --git a/Aaru.Core/Devices/Scanning/SCSI.cs b/Aaru.Core/Devices/Scanning/SCSI.cs index 53d95f977..a265bc0a7 100644 --- a/Aaru.Core/Devices/Scanning/SCSI.cs +++ b/Aaru.Core/Devices/Scanning/SCSI.cs @@ -80,8 +80,7 @@ public sealed partial class MediaScan while(leftRetries > 0) { - PulseProgress - ?.Invoke($"[olive]{Localization.Core.Waiting_for_drive_to_become_ready}[/]"); + PulseProgress?.Invoke(Localization.Core.Waiting_for_drive_to_become_ready); Thread.Sleep(2000); sense = _dev.ScsiTestUnitReady(out senseBuf, _dev.Timeout, out _); @@ -106,8 +105,7 @@ public sealed partial class MediaScan while(leftRetries > 0) { - PulseProgress - ?.Invoke($"[olive]{Localization.Core.Waiting_for_drive_to_become_ready}[/]"); + PulseProgress?.Invoke(Localization.Core.Waiting_for_drive_to_become_ready); Thread.Sleep(2000); sense = _dev.ScsiTestUnitReady(out senseBuf, _dev.Timeout, out _); @@ -136,8 +134,7 @@ public sealed partial class MediaScan while(leftRetries > 0) { - PulseProgress - ?.Invoke($"[olive]{Localization.Core.Waiting_for_drive_to_become_ready}[/]"); + PulseProgress?.Invoke(Localization.Core.Waiting_for_drive_to_become_ready); Thread.Sleep(2000); sense = _dev.ScsiTestUnitReady(out senseBuf, _dev.Timeout, out _); @@ -203,12 +200,12 @@ public sealed partial class MediaScan { results.Blocks++; - UpdateStatus?.Invoke(string.Format($"[slateblue1]{Localization.Core - .Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2}[/]", - $"[violet]{results.Blocks}[/]", - $"[lime]{blockSize}[/]", - $"[lime]{ByteSize.FromBytes(results.Blocks * blockSize) - .ToString("0.000")}[/]")); + UpdateStatus?.Invoke(string.Format(Localization.Core + .Media_has_0_blocks_of_1_bytes_each_for_a_total_of_2, + results.Blocks, + blockSize, + ByteSize.FromBytes(results.Blocks * blockSize) + .ToString("0.000"))); } break; @@ -320,7 +317,7 @@ public sealed partial class MediaScan out _); if(readcd) - UpdateStatus?.Invoke($"[slateblue1]{Localization.Core.Using_MMC_READ_CD_command}[/]"); + UpdateStatus?.Invoke(Localization.Core.Using_MMC_READ_CD_command); else if(!foundReadCommand) { StoppingErrorMessage?.Invoke(Localization.Core.Unable_to_read_medium); @@ -366,8 +363,7 @@ public sealed partial class MediaScan return results; } - UpdateStatus?.Invoke(string.Format($"[slateblue1]{Localization.Core.Reading_0_sectors_at_a_time}[/]", - $"[violet]{blocksToRead}[/]")); + UpdateStatus?.Invoke(string.Format(Localization.Core.Reading_0_sectors_at_a_time, blocksToRead)); InitBlockMap?.Invoke(results.Blocks, blockSize, blocksToRead, currentProfile); mhddLog = new MhddLog(_mhddLogPath, _dev, results.Blocks, blockSize, blocksToRead, false); @@ -389,10 +385,10 @@ public sealed partial class MediaScan if(currentSpeed < results.MinSpeed && currentSpeed > 0) results.MinSpeed = currentSpeed; - UpdateProgress?.Invoke(string.Format($"[slateblue1]{Localization.Core.Reading_sector_0_of_1_2}[/]", - $"[lime]{i}[/]", - $"[violet]{results.Blocks}[/]", - $"[aqua]{ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()}[/]"), + UpdateProgress?.Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, + i, + results.Blocks, + ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), (long)i, (long)results.Blocks); @@ -539,8 +535,7 @@ public sealed partial class MediaScan { _scanStopwatch.Restart(); - UpdateStatus?.Invoke(string.Format($"[slateblue1]{Localization.Core.Reading_0_sectors_at_a_time}[/]", - $"[violet]{scsiReader.BlocksToRead}[/]")); + UpdateStatus?.Invoke(string.Format(Localization.Core.Reading_0_sectors_at_a_time, scsiReader.BlocksToRead)); InitBlockMap?.Invoke(results.Blocks, blockSize, scsiReader.BlocksToRead, currentProfile); mhddLog = new MhddLog(_mhddLogPath, _dev, results.Blocks, blockSize, scsiReader.BlocksToRead, false); @@ -562,10 +557,10 @@ public sealed partial class MediaScan if(currentSpeed < results.MinSpeed && currentSpeed > 0) results.MinSpeed = currentSpeed; - UpdateProgress?.Invoke(string.Format($"[slateblue1]{Localization.Core.Reading_sector_0_of_1_2}[/]", - $"[lime]{i}[/]", - $"[violet]{results.Blocks}[/]", - $"[aqua]{ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()}[/]"), + UpdateProgress?.Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, + i, + results.Blocks, + ByteSize.FromMegabytes(currentSpeed).Per(_oneSecond).Humanize()), (long)i, (long)results.Blocks); @@ -660,8 +655,7 @@ public sealed partial class MediaScan uint seekPos = (uint)rnd.Next((int)results.Blocks); - PulseProgress?.Invoke(string.Format($"[slateblue1]{Localization.Core.Seeking_to_sector_0}[/]", - $"[lime]{seekPos}[/]")); + PulseProgress?.Invoke(string.Format(Localization.Core.Seeking_to_sector_0, seekPos)); double seekCur; diff --git a/Aaru.Core/Devices/Scanning/SecureDigital.cs b/Aaru.Core/Devices/Scanning/SecureDigital.cs index 739c0aabd..3fcbffa9d 100644 --- a/Aaru.Core/Devices/Scanning/SecureDigital.cs +++ b/Aaru.Core/Devices/Scanning/SecureDigital.cs @@ -149,8 +149,8 @@ public sealed partial class MediaScan if(sense || _dev.Error) { - UpdateStatus?.Invoke($"[slateblue1]{Localization.Core - .Environment_does_not_support_setting_block_count_downgrading_to_OS_reading}[/]"); + UpdateStatus?.Invoke(Localization.Core + .Environment_does_not_support_setting_block_count_downgrading_to_OS_reading); supportsCmd23 = false; } @@ -214,19 +214,18 @@ public sealed partial class MediaScan var rnd = new Random(); if(supportsCmd23 || blocksToRead == 1) - UpdateStatus?.Invoke(string.Format($"[slateblue1]{Localization.Core.Reading_0_sectors_at_a_time}[/]", - $"[violet]{blocksToRead}[/]")); + { + UpdateStatus?.Invoke(string.Format(Localization.Core.Reading_0_sectors_at_a_time, blocksToRead)); + } else if(_useBufferedReads) { - UpdateStatus - ?.Invoke(string.Format($"[slateblue1]{Localization.Core.Reading_0_sectors_at_a_time_using_OS_buffered_reads}[/]", - $"[violet]{blocksToRead}[/]")); + UpdateStatus?.Invoke(string.Format(Localization.Core.Reading_0_sectors_at_a_time_using_OS_buffered_reads, + blocksToRead)); } else { - UpdateStatus - ?.Invoke(string.Format($"[slateblue1]{Localization.Core.Reading_0_sectors_using_sequential_single_commands}[/]", - $"[violet]{blocksToRead}[/]")); + UpdateStatus?.Invoke(string.Format(Localization.Core.Reading_0_sectors_using_sequential_single_commands, + blocksToRead)); } InitBlockMap?.Invoke(results.Blocks, blockSize, blocksToRead, sdProfile); @@ -248,10 +247,10 @@ public sealed partial class MediaScan if(currentSpeed < results.MinSpeed && currentSpeed > 0) results.MinSpeed = currentSpeed; - UpdateProgress?.Invoke(string.Format($"[slateblue1]{Localization.Core.Reading_sector_0_of_1_2}[/]", - $"[lime]{i}[/]", - $"[violet]{results.Blocks}[/]", - $"[aqua]{ByteSize.FromBytes(currentSpeed).Per(_oneSecond).Humanize()}[/]"), + UpdateProgress?.Invoke(string.Format(Localization.Core.Reading_sector_0_of_1_2, + i, + results.Blocks, + ByteSize.FromBytes(currentSpeed).Per(_oneSecond).Humanize()), (long)i, (long)results.Blocks); @@ -371,8 +370,7 @@ public sealed partial class MediaScan uint seekPos = (uint)rnd.Next((int)results.Blocks); - PulseProgress?.Invoke(string.Format($"[slateblue1]{Localization.Core.Seeking_to_sector_0}[/]", - $"[lime]{seekPos}[/]")); + PulseProgress?.Invoke(string.Format(Localization.Core.Seeking_to_sector_0, seekPos)); _dev.ReadSingleBlock(out cmdBuf, out _, seekPos, blockSize, byteAddressed, timeout, out double seekCur); diff --git a/Aaru.Localization/Core.resx b/Aaru.Localization/Core.resx index fbbb6e8f8..e4dd262ce 100644 --- a/Aaru.Localization/Core.resx +++ b/Aaru.Localization/Core.resx @@ -39,7 +39,7 @@ Querying ATAPI IDENTIFY... - Waiting for drive to become ready + [olive]Waiting for drive to become ready[/] Device not ready. Sense {0} ASC {1:X2}h ASCQ {2:X2}h @@ -288,7 +288,7 @@ Stack trace: {0} - Media has {0} blocks of {1} bytes/each. (for a total of {2}) + [slateblue1]Media has [violet]{0}[/] blocks of [lime]{1}[/] bytes/each. (for a total of [lime]{2}[/])[/] Xbox DMI @@ -399,43 +399,43 @@ Combined offset is {0} bytes ({1} samples). - Took a total of {0} ({1} processing commands). + [slateblue1]Took a total of [teal]{0}[/] ([teal]{1}[/] processing commands).[/] - Average speed: {0} + [slateblue1]Average speed: [aqua]{0}[/].[/] - Fastest speed burst: {0}. + [slateblue1]Fastest speed burst: [aqua]{0}[/].[/] - Slowest speed burst: {0}. + [slateblue1]Slowest speed burst: [aqua]{0}[/].[/] - Summary + [bold][blue]Summary[/][/] - {0} sectors took less than 3 ms. + [lime]{0} sectors took less than 3 ms.[/] - {0} sectors took less than 10 ms but more than 3 ms. + [green]{0} sectors took less than 10 ms but more than 3 ms.[/] - {0} sectors took less than 50 ms but more than 10 ms. + [darkorange]{0} sectors took less than 50 ms but more than 10 ms.[/] - {0} sectors took less than 150 ms but more than 50 ms. + [olive]{0} sectors took less than 150 ms but more than 50 ms.[/] - {0} sectors took less than 500 ms but more than 150 ms. + [orange3]{0} sectors took less than 500 ms but more than 150 ms.[/] - {0} sectors took more than 500 ms. + [red]{0} sectors took more than 500 ms.[/] - {0} sectors could not be read. + [maroon]{0} sectors could not be read.[/] - Testing {0} seeks, longest seek took {1:F3} ms, fastest one took {2:F3} ms. ({3:F3} ms average) + [slateblue1]Testing [teal]{0}[/] seeks, longest seek took [aqua]{1:F3}[/] ms, fastest one took [aqua]{2:F3}[/] ms. ([aqua]{3:F3}[/] ms average)[/] Whole device @@ -648,7 +648,7 @@ Aborted! - Reading sector {0} of {1} ({2}) + [slateblue1]Reading sector [lime]{0}[/] of [violet]{1}[/] ([aqua]{2}[/])[/] Adding CD-i Ready hole from LBA {0} to {1} inclusive. @@ -818,7 +818,7 @@ Device error {0} trying to guess ideal transfer length. - Reading {0} sectors at a time. + [slateblue1]Reading [violet]{0}[/] sectors at a time.[/] Device reports {0} blocks ({1} bytes). @@ -909,7 +909,7 @@ Cannot write tag {0}. - Sector {0} could not be read. + [red]Sector [teal]{0}[/] could not be read.[/] Setting ISRC for track {0} to {1} @@ -1372,7 +1372,7 @@ Output format does not support ATA IDENTIFY. - Reading cylinder {0} head {1} sector {2} ({3}) + [slateblue1]Reading cylinder [lime]{0}[/] head [lime]{1}[/] sector [lime]{2}[/] ([aqua]{3}[/]) Error reading cylinder {0} head {1} sector {2}. @@ -2309,10 +2309,10 @@ Do you want to proceed? (Y/N): Querying SCSI REPORT DENSITY SUPPORT for medium types for current media... - Seeking to sector {0}... + [slateblue1]Seeking to sector [lime]{0}[/]...[/] - Seeking to cylinder {0}, head {1}, sector {2}... + [slateblue1]Seeking to cylinder [lime]{0}[/], head [lime]{1}[/], sector [lime]{2}[/]...[/] Scanning will never be supported on SCSI Streaming Devices. @@ -2322,20 +2322,20 @@ It has no sense to do it, and it will put too much strain on the tape. Error trying to decode TOC... - Using [fuchsia]MMC READ CD[/] command. + [slateblue1]Using [fuchsia]MMC READ CD[/] command.[/] READ CD error: {0} - Environment does not support setting block count, downgrading to OS reading. + [slateblue1]Environment does not support setting block count, downgrading to OS reading.[/] - Reading {0} sectors at a time using OS buffered reads. + [slateblue1]Reading [violet]{0}[/] sectors at a time using OS buffered reads.[/] - Reading {0} sectors using sequential single commands. + [slateblue1]Reading [violet]{0}[/] sectors using sequential single commands.[/] Unknown device type {0}. diff --git a/Aaru/Commands/Media/Scan.cs b/Aaru/Commands/Media/Scan.cs index 6285b6a0b..73c0fc3b2 100644 --- a/Aaru/Commands/Media/Scan.cs +++ b/Aaru/Commands/Media/Scan.cs @@ -151,50 +151,49 @@ sealed class MediaScanCommand : Command results = scanner.Scan(); }); - AaruLogging.WriteLine($"[slateblue1]{Localization.Core.Took_a_total_of_0_1_processing_commands}[/]", - $"[teal]{results.TotalTime.Seconds().Humanize(minUnit: TimeUnit.Second)}[/]", - $"[teal]{results.ProcessingTime.Seconds().Humanize(minUnit: TimeUnit.Second)}[/]"); + AaruLogging.WriteLine(Localization.Core.Took_a_total_of_0_1_processing_commands, + results.TotalTime.Seconds().Humanize(minUnit: TimeUnit.Second), + results.ProcessingTime.Seconds().Humanize(minUnit: TimeUnit.Second)); - AaruLogging.WriteLine($"[slateblue1]{Localization.Core.Average_speed_0}[/]", - $"[aqua]{ByteSize.FromMegabytes(results.AvgSpeed).Per(1.Seconds()).Humanize()}[/]"); + AaruLogging.WriteLine(Localization.Core.Average_speed_0, + ByteSize.FromMegabytes(results.AvgSpeed).Per(1.Seconds()).Humanize()); - AaruLogging.WriteLine($"[slateblue1]{Localization.Core.Fastest_speed_burst_0}[/]", - $"[aqua]{ByteSize.FromMegabytes(results.MaxSpeed).Per(1.Seconds()).Humanize()}[/]"); + AaruLogging.WriteLine(Localization.Core.Fastest_speed_burst_0, + ByteSize.FromMegabytes(results.MaxSpeed).Per(1.Seconds()).Humanize()); - AaruLogging.WriteLine($"[slateblue1]{Localization.Core.Slowest_speed_burst_0}[/]", - $"[aqua]{ByteSize.FromMegabytes(results.MinSpeed).Per(1.Seconds()).Humanize()}[/]"); + AaruLogging.WriteLine(Localization.Core.Slowest_speed_burst_0, + ByteSize.FromMegabytes(results.MinSpeed).Per(1.Seconds()).Humanize()); AaruLogging.WriteLine(); - AaruLogging.WriteLine($"[bold]{Localization.Core.Summary}:[/]"); - AaruLogging.WriteLine($"[lime]{string.Format(Localization.Core._0_sectors_took_less_than_3_ms, results.A)}[/]"); + AaruLogging.WriteLine(Localization.Core.Summary); + AaruLogging.WriteLine(Localization.Core._0_sectors_took_less_than_3_ms, results.A); - AaruLogging.WriteLine($"[green]{string.Format(Localization.Core._0_sectors_took_less_than_10_ms_but_more_than_3_ms, results.B)}[/]"); + AaruLogging.WriteLine(Localization.Core._0_sectors_took_less_than_10_ms_but_more_than_3_ms, results.B); - AaruLogging.WriteLine($"[darkorange]{string.Format(Localization.Core._0_sectors_took_less_than_50_ms_but_more_than_10_ms, results.C)}[/]"); + AaruLogging.WriteLine(Localization.Core._0_sectors_took_less_than_50_ms_but_more_than_10_ms, results.C); - AaruLogging.WriteLine($"[olive]{string.Format(Localization.Core._0_sectors_took_less_than_150_ms_but_more_than_50_ms, results.D)}[/]"); + AaruLogging.WriteLine(Localization.Core._0_sectors_took_less_than_150_ms_but_more_than_50_ms, results.D); - AaruLogging.WriteLine($"[orange3]{string.Format(Localization.Core._0_sectors_took_less_than_500_ms_but_more_than_150_ms, results.E)}[/]"); + AaruLogging.WriteLine(Localization.Core._0_sectors_took_less_than_500_ms_but_more_than_150_ms, results.E); - AaruLogging.WriteLine($"[red]{string.Format(Localization.Core._0_sectors_took_more_than_500_ms, results.F)}[/]"); + AaruLogging.WriteLine(Localization.Core._0_sectors_took_more_than_500_ms, results.F); - AaruLogging.WriteLine($"[maroon]{string.Format(Localization.Core._0_sectors_could_not_be_read, - results.UnreadableSectors.Count)}[/]"); + AaruLogging.WriteLine(Localization.Core._0_sectors_could_not_be_read, results.UnreadableSectors.Count); foreach(ulong bad in results.UnreadableSectors) - AaruLogging.WriteLine($"[red]{Localization.Core.Sector_0_could_not_be_read}[/]", $"[teal]{bad}[/]"); + AaruLogging.WriteLine(Localization.Core.Sector_0_could_not_be_read, bad); AaruLogging.WriteLine(); if(results.SeekTotal > 0 || results.SeekMin < double.MaxValue || results.SeekMax > double.MinValue) { - AaruLogging.WriteLine($"[slateblue1]{Localization.Core - .Testing_0_seeks_longest_seek_took_1_ms_fastest_one_took_2_ms_3_ms_average}[/]", - $"[aqua]{results.SeekTimes}[/]", - $"[aqua]{results.SeekMax}[/]", - $"[aqua]{results.SeekMin}[/]", - $"[aqua]{results.SeekTotal / 1000}[/]"); + AaruLogging.WriteLine(Localization.Core + .Testing_0_seeks_longest_seek_took_1_ms_fastest_one_took_2_ms_3_ms_average, + results.SeekTimes, + results.SeekMax, + results.SeekMin, + results.SeekTotal / 1000); } dev.Close();