Skip to content

Commit

Permalink
Use humanizer to show seconds.
Browse files Browse the repository at this point in the history
  • Loading branch information
claunia committed Sep 26, 2023
1 parent d44b32a commit 25c5cba
Show file tree
Hide file tree
Showing 22 changed files with 5,227 additions and 2,172 deletions.
50 changes: 29 additions & 21 deletions Aaru.Core/Devices/Dumping/ATA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
using Aaru.Decoders.PCMCIA;
using Humanizer;
using Humanizer.Bytes;
using Humanizer.Localisation;
using Identify = Aaru.CommonTypes.Structs.Devices.ATA.Identify;
using Tuple = Aaru.Decoders.PCMCIA.Tuple;
using Version = Aaru.CommonTypes.Interop.Version;
Expand Down Expand Up @@ -381,17 +382,19 @@ void Ata()
ibgLog.Close(_dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024,
blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), _devicePath);

UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0_seconds,
(end - start).TotalSeconds));
UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second)));

UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).
Per(totalDuration.Milliseconds())));

UpdateStatus?.Invoke(string.Format(Localization.Core.Average_write_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).Per(imageWriteDuration.Seconds())));
ByteSize.FromBytes(blockSize * (blocks + 1)).
Per(imageWriteDuration.Seconds())));

_dumpLog.WriteLine(Localization.Core.Dump_finished_in_0_seconds, (end - start).TotalSeconds);
_dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second)));

_dumpLog.WriteLine(Localization.Core.Average_dump_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalDuration.Milliseconds()));
Expand Down Expand Up @@ -443,11 +446,11 @@ void Ata()
EndProgress?.Invoke();
end = DateTime.UtcNow;

UpdateStatus?.Invoke(string.Format(Localization.Core.Trimming_finished_in_0_seconds,
(end - start).TotalSeconds));
UpdateStatus?.Invoke(string.Format(Localization.Core.Trimming_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second)));

_dumpLog.WriteLine(Localization.Core.Trimming_finished_in_0_seconds,
(end - start).TotalSeconds);
_dumpLog.WriteLine(string.Format(Localization.Core.Trimming_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second)));
}
#endregion Trimming

Expand Down Expand Up @@ -650,8 +653,8 @@ void Ata()
ibgLog.Close(_dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024,
blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), _devicePath);

UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0_seconds,
(end - start).TotalSeconds));
UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second)));

UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).
Expand All @@ -661,7 +664,8 @@ void Ata()
ByteSize.FromBytes(blockSize * (blocks + 1)).
Per(imageWriteDuration.Seconds())));

_dumpLog.WriteLine(Localization.Core.Dump_finished_in_0_seconds, (end - start).TotalSeconds);
_dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second)));

_dumpLog.WriteLine(Localization.Core.Average_dump_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalDuration.Milliseconds()));
Expand Down Expand Up @@ -695,10 +699,11 @@ void Ata()
outputFormat.Close();
DateTime closeEnd = DateTime.Now;

UpdateStatus?.Invoke(string.Format(Localization.Core.Closed_in_0_seconds,
(closeEnd - closeStart).TotalSeconds));
UpdateStatus?.Invoke(string.Format(Localization.Core.Closed_in_0,
(closeEnd - closeStart).Humanize(minUnit: TimeUnit.Second)));

_dumpLog.WriteLine(Localization.Core.Closed_in_0_seconds, (closeEnd - closeStart).TotalSeconds);
_dumpLog.WriteLine(Localization.Core.Closed_in_0,
(closeEnd - closeStart).Humanize(minUnit: TimeUnit.Second));

if(_aborted)
{
Expand Down Expand Up @@ -850,15 +855,15 @@ void Ata()

totalChkDuration = (chkEnd - chkStart).TotalMilliseconds;

UpdateStatus?.Invoke(string.Format(Localization.Core.Sidecar_created_in_0_seconds,
(chkEnd - chkStart).TotalSeconds));
UpdateStatus?.Invoke(string.Format(Localization.Core.Sidecar_created_in_0,
(chkEnd - chkStart).Humanize(minUnit: TimeUnit.Second)));

UpdateStatus?.Invoke(string.Format(Localization.Core.Average_checksum_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).
Per(totalChkDuration.Milliseconds())));

_dumpLog.WriteLine(Localization.Core.Sidecar_created_in_0_seconds,
(chkEnd - chkStart).TotalSeconds);
_dumpLog.WriteLine(Localization.Core.Sidecar_created_in_0,
(chkEnd - chkStart).Humanize(minUnit: TimeUnit.Second));

_dumpLog.WriteLine(Localization.Core.Average_checksum_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalChkDuration.Milliseconds()));
Expand Down Expand Up @@ -926,9 +931,12 @@ from fileSystem in partition.FileSystems
UpdateStatus?.Invoke("");

UpdateStatus?.
Invoke(string.Format(Localization.Core.Took_a_total_of_0_seconds_1_processing_commands_2_checksumming_3_writing_4_closing,
(end - start).TotalSeconds, totalDuration / 1000, totalChkDuration / 1000,
imageWriteDuration, (closeEnd - closeStart).TotalSeconds));
Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing,
(end - start).Humanize(minUnit: TimeUnit.Second),
totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second),
(closeEnd - closeStart).Humanize(minUnit: TimeUnit.Second)));

UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).
Expand Down
20 changes: 13 additions & 7 deletions Aaru.Core/Devices/Dumping/CompactDisc/Dump.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
using Aaru.Devices;
using Humanizer;
using Humanizer.Bytes;
using Humanizer.Localisation;
using Track = Aaru.CommonTypes.Structs.Track;
using TrackType = Aaru.CommonTypes.Enums.TrackType;
using Version = Aaru.CommonTypes.Interop.Version;
Expand Down Expand Up @@ -1294,7 +1295,8 @@ void CompactDisc()
ibgLog.Close(_dev, blocks, blockSize, (end - start).TotalSeconds, currentSpeed * 1024,
blockSize * (double)(blocks + 1) / 1024 / (totalDuration / 1000), _devicePath);

UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0_seconds, (end - start).TotalSeconds));
UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second)));

UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).
Expand All @@ -1304,7 +1306,8 @@ void CompactDisc()
ByteSize.FromBytes(blockSize * (blocks + 1)).
Per(imageWriteDuration.Seconds())));

_dumpLog.WriteLine(Localization.Core.Dump_finished_in_0_seconds, (end - start).TotalSeconds);
_dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second)));

_dumpLog.WriteLine(string.Format(Localization.Core.Average_dump_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).
Expand Down Expand Up @@ -1440,8 +1443,8 @@ void CompactDisc()
outputOptical.Close();
DateTime closeEnd = DateTime.Now;

UpdateStatus?.Invoke(string.Format(Localization.Core.Closed_in_0_seconds,
(closeEnd - closeStart).TotalSeconds));
UpdateStatus?.Invoke(string.Format(Localization.Core.Closed_in_0,
(closeEnd - closeStart).Humanize(minUnit: TimeUnit.Second)));

subLog?.Close();

Expand All @@ -1462,9 +1465,12 @@ void CompactDisc()
UpdateStatus?.Invoke("");

UpdateStatus?.
Invoke(string.Format(Localization.Core.Took_a_total_of_0_seconds_1_processing_commands_2_checksumming_3_writing_4_closing,
(end - dumpStart).TotalSeconds, totalDuration / 1000, totalChkDuration / 1000,
imageWriteDuration, (closeEnd - closeStart).TotalSeconds));
Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing,
(end - start).Humanize(minUnit: TimeUnit.Second),
totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second),
(closeEnd - closeStart).Humanize(minUnit: TimeUnit.Second)));

UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).
Expand Down
9 changes: 6 additions & 3 deletions Aaru.Core/Devices/Dumping/CompactDisc/Trim.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
using Aaru.Decoders.CD;
using Aaru.Decoders.SCSI;
using Aaru.Devices;
using Humanizer;
using Humanizer.Localisation;
using Track = Aaru.CommonTypes.Structs.Track;

namespace Aaru.Core.Devices.Dumping;
Expand Down Expand Up @@ -293,9 +295,10 @@ void TrimCdUserData(ExtentsULong audioExtents, uint blockSize, DumpHardware curr
EndProgress?.Invoke();
end = DateTime.UtcNow;

UpdateStatus?.Invoke(string.Format(Localization.Core.Trimming_finished_in_0_seconds,
(end - start).TotalSeconds));
UpdateStatus?.Invoke(string.Format(Localization.Core.Trimming_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second)));

_dumpLog.WriteLine(Localization.Core.Trimming_finished_in_0_seconds, (end - start).TotalSeconds);
_dumpLog.WriteLine(string.Format(Localization.Core.Trimming_finished_in_0,
(end - start).Humanize(minUnit: TimeUnit.Second)));
}
}
16 changes: 10 additions & 6 deletions Aaru.Core/Devices/Dumping/LinearMemory/Retrode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
using Aaru.Core.Graphics;
using Humanizer;
using Humanizer.Bytes;
using Humanizer.Localisation;
using Version = Aaru.CommonTypes.Interop.Version;

namespace Aaru.Core.Devices.Dumping;
Expand Down Expand Up @@ -403,7 +404,7 @@ void Retrode()
DateTime end = DateTime.UtcNow;
EndProgress?.Invoke();

UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0_seconds, (end - start).TotalSeconds));
UpdateStatus?.Invoke(string.Format(Localization.Core.Dump_finished_in_0, (end - start).Humanize(minUnit: TimeUnit.Second)));

UpdateStatus?.Invoke(string.Format(Localization.Core.Average_dump_speed_0,
ByteSize.FromBytes(512 * (romSectors + 1)).
Expand All @@ -413,7 +414,7 @@ void Retrode()
ByteSize.FromBytes(512 * (romSectors + 1)).
Per(imageWriteDuration.Seconds())));

_dumpLog.WriteLine(Localization.Core.Dump_finished_in_0_seconds, (end - start).TotalSeconds);
_dumpLog.WriteLine(string.Format(Localization.Core.Dump_finished_in_0, (end - start).Humanize(minUnit: TimeUnit.Second)));

_dumpLog.WriteLine(string.Format(Localization.Core.Average_dump_speed_0,
ByteSize.FromBytes(512 * (romSectors + 1)).Per(totalDuration.Milliseconds())));
Expand Down Expand Up @@ -442,7 +443,7 @@ void Retrode()
DateTime closeStart = DateTime.Now;
outputBai.Close();
DateTime closeEnd = DateTime.Now;
_dumpLog.WriteLine(Localization.Core.Closed_in_0_seconds, (closeEnd - closeStart).TotalSeconds);
_dumpLog.WriteLine(Localization.Core.Closed_in_0, (closeEnd - closeStart).Humanize(minUnit: TimeUnit.Second));

if(_aborted)
{
Expand All @@ -461,9 +462,12 @@ void Retrode()
UpdateStatus?.Invoke("");

UpdateStatus?.
Invoke(string.Format(Localization.Core.Took_a_total_of_0_seconds_1_processing_commands_2_checksumming_3_writing_4_closing,
(end - start).TotalSeconds, totalDuration / 1000, totalChkDuration / 1000,
imageWriteDuration, (closeEnd - closeStart).TotalSeconds));
Invoke(string.Format(Localization.Core.Took_a_total_of_0_1_processing_commands_2_checksumming_3_writing_4_closing,
(end - start).Humanize(minUnit: TimeUnit.Second),
totalDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
totalChkDuration.Milliseconds().Humanize(minUnit: TimeUnit.Second),
imageWriteDuration.Seconds().Humanize(minUnit: TimeUnit.Second),
(closeEnd - closeStart).Humanize(minUnit: TimeUnit.Second)));

UpdateStatus?.Invoke(string.Format(Localization.Core.Average_speed_0,
ByteSize.FromBytes(512 * (romSectors + 1)).
Expand Down
3 changes: 2 additions & 1 deletion Aaru.Core/Devices/Dumping/Metadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
using Aaru.CommonTypes.Interfaces;
using Humanizer;
using Humanizer.Bytes;
using Humanizer.Localisation;

namespace Aaru.Core.Devices.Dumping;

Expand Down Expand Up @@ -98,7 +99,7 @@ void WriteOpticalSidecar(uint blockSize, ulong blocks, MediaType mediaType, Laye
return;

totalChkDuration = (end - chkStart).TotalMilliseconds;
_dumpLog.WriteLine(Localization.Core.Sidecar_created_in_0_seconds, (end - chkStart).TotalSeconds);
_dumpLog.WriteLine(Localization.Core.Sidecar_created_in_0, (end - chkStart).Humanize(minUnit: TimeUnit.Second));

_dumpLog.WriteLine(Localization.Core.Average_checksum_speed_0,
ByteSize.FromBytes(blockSize * (blocks + 1)).Per(totalChkDuration.Milliseconds()));
Expand Down
Loading

0 comments on commit 25c5cba

Please sign in to comment.