From 9aecb6103b9c1f96bf424598f5bfe9eccbb645c8 Mon Sep 17 00:00:00 2001 From: Harald Hope Date: Tue, 20 Mar 2018 22:07:39 -0700 Subject: [PATCH] First small patch fix, corrected a few issues, one for apt deb822 output formatting, and a small bug for blank files there. Second, made the --output error message more clear for bad file structure now lists the 3 requirements: must be full path, must be writeable directory, and must have a file in it. Third, another subtle thing, after a lot of research, am trying the MiB GiB format because it's technically more accurate and less ambiguous than GB, which is used either to refer to 1000 bite blocks OR to 1024 blocks, depending on the platform etc. So rather than hope people get it, trying that slightly more wordy format, and maybe if people wonder what it is. --- inxi | 53 +++++++++++++++++++++++++++----------------------- inxi.changelog | 16 +++++++++++++-- 2 files changed, 43 insertions(+), 26 deletions(-) diff --git a/inxi b/inxi index 20af30c..0a57b1b 100755 --- a/inxi +++ b/inxi @@ -37,7 +37,7 @@ use POSIX qw(uname strftime ttyname); ## INXI INFO ## my $self_name='inxi'; -my $self_version='2.9.01'; +my $self_version='2.9.02'; my $self_date='2018-03-20'; my $self_patch='00'; ## END INXI INFO ## @@ -2124,7 +2124,7 @@ sub error_handler { elsif ( $err eq 'open-dir' ) { $errno=46; "Error opening directory: $one \nError: $two" } elsif ( $err eq 'output-file-bad' ) { - $errno=47; "The output directory path is not writable, or no file name was included:\nPath given: $two" } + $errno=47; "Value for --output-file must be full path, a writable directory, \nand include file name. Path: $two" } elsif ( $err eq 'not-writable' ) { $errno=48; "The file: $one is not writable!" } elsif ( $err eq 'open-dir-failed' ) { @@ -4506,27 +4506,27 @@ sub get_size { } elsif ($size > 1024**5){ $data[0] = sprintf("%.2f",$size/1024**5); - $data[1] = 'EB'; + $data[1] = 'EiB'; } elsif ($size > 1024**4){ $data[0] = sprintf("%.2f",$size/1024**4); - $data[1] = 'PB'; + $data[1] = 'PiB'; } elsif ($size > 1024**3){ $data[0] = sprintf("%.2f",$size/1024**3); - $data[1] = 'TB'; + $data[1] = 'TiB'; } elsif ($size > 1024**2){ $data[0] = sprintf("%.2f",$size/1024**2); - $data[1] = 'GB'; + $data[1] = 'GiB'; } elsif ($size > 1024){ $data[0] = sprintf("%.1f",$size/1024); - $data[1] = 'MB'; + $data[1] = 'MiB'; } else { $data[0] = sprintf("%.0f",$size); - $data[1] = 'KB'; + $data[1] = 'KiB'; } return @data; } @@ -4622,25 +4622,27 @@ sub row_defaults { return $unfound{$type}; } # convert string passed to KB, based on GB/MB/TB id +# NOTE: K 1024 KB 1000 sub translate_size { my ($working) = @_; my $size = 0; #print ":$working:\n"; return if ! defined $working; + my $math = ( $working =~ /B$/) ? 1000: 1024; if ( $working =~ /^([0-9\.]+)M[B]?$/i){ - $size = $1 * 1024; + $size = $1 * $math; } elsif ( $working =~ /^([0-9\.]+)G[B]?$/i){ - $size = $1 * 1024**2; + $size = $1 * $math**2; } elsif ( $working =~ /^([0-9\.]+)T[B]?$/i){ - $size = $1 * 1024**3; + $size = $1 * $math**3; } elsif ( $working =~ /^([0-9\.]+)P[B]?$/i){ - $size = $1 * 1024**4; + $size = $1 * $math**4; } elsif ( $working =~ /^([0-9\.]+)E[B]?$/i){ - $size = $1 * 1024**5; + $size = $1 * $math**5; } elsif ( $working =~ /^([0-9\.]+)K[B]?$/i){ $size = $1; @@ -4659,7 +4661,7 @@ sub check_output_path { $dir = $path; $dir =~ s/([^\/])+$//; $file = $1; - $b_good = 1 if (-d $dir && -w $dir && $file); + $b_good = 1 if (-d $dir && -w $dir && $file && $dir !~ /^\//); return $b_good; } @@ -9836,7 +9838,7 @@ sub cpu_processes { $b[2] <=> $a[2] } @ps_aux; # if there's a count limit, for irc, etc, only use that much of the data @rows = splice @rows,0,$count; - $cpu_mem = ' - Memory: MB / % used' if $extra > 0; + $cpu_mem = ' - Memory: MiB / % used' if $extra > 0; $j = scalar @rows; my $throttled = throttled($ps_count,$count,$j); my @data = ( @@ -9863,7 +9865,7 @@ sub cpu_processes { $processes[$j]{$num++ . "#pid"} = $row[1]; if ($extra > 0){ my $decimals = ($row[5]/1024 > 10 ) ? 1 : 2; - $mem = (defined $row[5]) ? sprintf( "%.${decimals}f", $row[5]/1024 ) . 'MB' : 'N/A'; + $mem = (defined $row[5]) ? sprintf( "%.${decimals}f", $row[5]/1024 ) . 'MiB' : 'N/A'; $mem .= ' (' . $row[3] . '%)'; $processes[$j]{$num++ . "#mem"} = $mem; } @@ -9887,7 +9889,7 @@ sub mem_processes { $j = scalar @rows; my $throttled = throttled($ps_count,$count,$j); @data = ( - {$num++ . "#Memory MB/% used - Command - pid$cpu_mem - top" => "$count$throttled",}, + {$num++ . "#Memory MiB/% used - Command - pid$cpu_mem - top" => "$count$throttled",}, ); @processes = (@processes,@data); my $i = 1; @@ -9896,7 +9898,7 @@ sub mem_processes { $j = scalar @processes; my @row = split /\s+/, $_; my $decimals = ($row[5]/1024 > 10 ) ? 1 : 2; - $mem = ($row[5]) ? sprintf( "%.${decimals}f", $row[5]/1024 ) . ' MB' : 'N/A'; + $mem = ($row[5]) ? sprintf( "%.${decimals}f", $row[5]/1024 ) . ' MiB' : 'N/A'; my @command = process_starter(scalar @row, $row[10],$row[11]); if ($extra > 0){ $mem .= " (" . $row[2] . "%)"; @@ -11049,7 +11051,7 @@ sub get_repos_linux { # apt repos here as well if (-f $apt || -d "$apt.d"){ my ($apt_arch,$apt_comp,$apt_suites,$apt_types,@apt_urls,@apt_working, - $b_apt_enabled,$file); + $b_apt_enabled,$file,$string); my $counter = 0; @files = main::globber('/etc/apt/sources.list.d/*.list'); push @files, $apt; @@ -11081,10 +11083,12 @@ sub get_repos_linux { if ($b_apt_enabled){ #print "1: url builder\n"; foreach $repo (@apt_working){ - my $string = $apt_types . ' ' . $repo; + $string = $apt_types; + $string .= ' [arch=' . $apt_arch . ']' if $apt_arch; + $string .= ' ' . $repo; $string .= ' ' . $apt_suites if $apt_suites ; $string .= ' ' . $apt_comp if $apt_comp; - $string .= ' ' . $apt_arch if $apt_arch; + #print "s1:$string\n"; push @data3, $string; } @@ -11124,10 +11128,11 @@ sub get_repos_linux { #print "2: url builder\n"; if ($b_apt_enabled){ foreach $repo (@apt_working){ - my $string = $apt_types . ' ' . $repo; + my $string = $apt_types; + $string .= ' [arch=' . $apt_arch . ']' if $apt_arch; + $string .= ' ' . $repo; $string .= ' ' . $apt_suites if $apt_suites ; $string .= ' ' . $apt_comp if $apt_comp; - $string .= ' ' . $apt_arch if $apt_arch; #print "s2:$string\n"; push @data3, $string; } @@ -11147,7 +11152,7 @@ sub get_repos_linux { @apt_urls = url_cleaner(@apt_urls); } else { - $key = repo_builder('active','apt'); + $key = repo_builder('missing','apt'); } @data = ( {$num++ . "#$key" => $file}, diff --git a/inxi.changelog b/inxi.changelog index f048058..a394ecc 100644 --- a/inxi.changelog +++ b/inxi.changelog @@ -1,14 +1,26 @@ ===================================================================================== -Version: 2.9.01; +Version: 2.9.02; Patch Version: 00; Script Date: 2018-03-20; ----------------------------------- Changes: ----------------------------------- +First small patch fix, corrected a few issues, one for apt deb822 output formatting, +and a small bug for blank files there. +Second, made the --output error message more clear for bad file structure now lists +the 3 requirements: must be full path, must be writeable directory, and must have +a file in it. + +Third, another subtle thing, after a lot of research, am trying the MiB GiB format +because it's technically more accurate and less ambiguous than GB, which is used +either to refer to 1000 bite blocks OR to 1024 blocks, depending on the platform etc. + +So rather than hope people get it, trying that slightly more wordy format, and maybe +if people wonder what it is. ----------------------------------- --- Harald Hope - Tue, 20 Mar 2018 15:07:40 -0700 +-- Harald Hope - Tue, 20 Mar 2018 22:02:39 -0700 ===================================================================================== Version: 2.9.01;