New version, new tarball, new man page. Deprecated xiin uploader, which completes the deprecation

of the xiin.py tool, which is going to become obsolete when python 3 fully replaces python 2.

Since the odds of perl being around and stable are far higher than the odds of xiin.py
even working on python 3, I'm getting ahead of the race. Plus Perl is nicer to work with.

And Perl is a lot faster. I mean, a lot. Not slightly.

And it also works on much older systems, and does not have that Python version < 2.6
failure due to changing Python syntax even between sub versions. xiin.py never ran on
Python 2.5 even when it was relatively recent, which is one reason I'm removing all Python
from inxi.

Basically xiin.py worked only on Python 2.6 or 2.7, period.

Oh, and also handled issue #115 by not making -B show -M data.
This commit is contained in:
Harald Hope 2017-08-23 16:14:47 -07:00
parent 29fd891c63
commit c3ba00e5a8
3 changed files with 126 additions and 38 deletions

126
inxi
View file

@ -2,8 +2,8 @@
######################################################################## ########################################################################
SELF_NAME='inxi' SELF_NAME='inxi'
# don't quote the following, parsers grab these too # don't quote the following, parsers grab these too
SELF_VERSION=2.3.36 SELF_VERSION=2.3.37
SELF_DATE=2017-08-16 SELF_DATE=2017-08-23
SELF_PATCH=00 SELF_PATCH=00
######################################################################## ########################################################################
#### SPECIAL THANKS #### SPECIAL THANKS
@ -52,7 +52,6 @@ SELF_PATCH=00
#### If you don't understand what Free Software is, please read (or reread) #### If you don't understand what Free Software is, please read (or reread)
#### this page: http://www.gnu.org/philosophy/free-sw.html #### this page: http://www.gnu.org/philosophy/free-sw.html
######################################################################## ########################################################################
#### ####
#### PACKAGE NAME NOTES #### PACKAGE NAME NOTES
#### * Package names in (...) are the Debian Squeeze package name. Check your #### * Package names in (...) are the Debian Squeeze package name. Check your
@ -1323,7 +1322,7 @@ select_default_color_scheme()
;; ;;
esac esac
set_color_scheme $i set_color_scheme $i
print_screen_output "$irc_clear $i)$spacer${C1}Card:${C2} nVidia G86 [GeForce 8400 GS] ${C1}X.Org${C2} 1.7.7" print_screen_output "$irc_clear $i)$spacer${C1}Card:${C2} nVidia G86 [GeForce 8400 GS] ${C1}Display Server${C2} x11 (X.Org 1.7.7)"
done done
set_color_scheme 0 set_color_scheme 0
@ -1764,12 +1763,12 @@ set_man_location()
# args: $1 - debug data type: sys|xorg|disk # args: $1 - debug data type: sys|xorg|disk
debug_data_collector() debug_data_collector()
{ {
local xiin_app='' xiin_data_file='' error='' b_run_xiin='false' b_xiin_downloaded='false' local xiin_app='' sys_data_file='' error='' b_run_xiin='false' b_xiin_downloaded='false'
local Debug_Data_Dir='' bsd_string='' xorg_d_files='' xorg_file='' a_distro_ids='' local Debug_Data_Dir='' bsd_string='' xorg_d_files='' xorg_file='' a_distro_ids=''
local completed_gz_file='' Xiin_File='xiin.py' ftp_upload='ftp.techpatterns.com/incoming' local completed_gz_file='' Xiin_File='xiin.py' ftp_upload='ftp.techpatterns.com/incoming'
local Line='-------------------------' local Line='-------------------------'
local start_directory=$( pwd ) local start_directory=$( pwd )
local host='' debug_i='' root_string='' local host='' debug_i='' root_string='' b_perl_worked='false' b_uploaded='false'
if (( "$BASH" >= 4 ));then if (( "$BASH" >= 4 ));then
host="${HOSTNAME,,}" host="${HOSTNAME,,}"
@ -1802,7 +1801,7 @@ debug_data_collector()
echo "Starting debugging data collection type: $1" echo "Starting debugging data collection type: $1"
cd $SELF_DATA_DIR cd $SELF_DATA_DIR
if [[ -d $SELF_DATA_DIR/$Debug_Data_Dir ]];then if [[ -d $SELF_DATA_DIR/$Debug_Data_Dir ]];then
echo 'Deleting previous xiin data directory...' echo "Deleting previous $SELF_NAME debugger data directory..."
rm -rf $SELF_DATA_DIR/$Debug_Data_Dir rm -rf $SELF_DATA_DIR/$Debug_Data_Dir
fi fi
mkdir $SELF_DATA_DIR/$Debug_Data_Dir mkdir $SELF_DATA_DIR/$Debug_Data_Dir
@ -1891,6 +1890,7 @@ debug_data_collector()
ps aux &> $Debug_Data_Dir/ps-aux.txt ps aux &> $Debug_Data_Dir/ps-aux.txt
ps -e &> $Debug_Data_Dir/ps-e.txt ps -e &> $Debug_Data_Dir/ps-e.txt
ps -p 1 &> $Debug_Data_Dir/ps-p-1.txt ps -p 1 &> $Debug_Data_Dir/ps-p-1.txt
echo "Collecting init data..."
cat /proc/1/comm &> $Debug_Data_Dir/proc-1-comm.txt cat /proc/1/comm &> $Debug_Data_Dir/proc-1-comm.txt
runlevel &> $Debug_Data_Dir/runlevel.txt runlevel &> $Debug_Data_Dir/runlevel.txt
if type -p rc-status &>/dev/null;then if type -p rc-status &>/dev/null;then
@ -1961,7 +1961,11 @@ debug_data_collector()
else else
touch $Debug_Data_Dir/systemd-detect-virt-absent touch $Debug_Data_Dir/systemd-detect-virt-absent
fi fi
if type -p perl &>/dev/null;then
perl -MFile::Find=find -MFile::Spec::Functions -Tlwe 'find { wanted => sub { print canonpath $_ if /\.pm\z/ }, no_chdir => 1 }, @INC' &> $Debug_Data_Dir/perl-modules.txt
else
touch $Debug_Data_Dir/perl-missing.txt
fi
cat /etc/src.conf &> $Debug_Data_Dir/bsd-etc-src-conf.txt cat /etc/src.conf &> $Debug_Data_Dir/bsd-etc-src-conf.txt
cat /etc/make.conf &> $Debug_Data_Dir/bsd-etc-make-conf.txt cat /etc/make.conf &> $Debug_Data_Dir/bsd-etc-make-conf.txt
cat /etc/issue &> $Debug_Data_Dir/etc-issue.txt cat /etc/issue &> $Debug_Data_Dir/etc-issue.txt
@ -2163,19 +2167,19 @@ debug_data_collector()
ifconfig &> $Debug_Data_Dir/ifconfig.txt ifconfig &> $Debug_Data_Dir/ifconfig.txt
ip addr &> $Debug_Data_Dir/ip-addr.txt ip addr &> $Debug_Data_Dir/ip-addr.txt
fi fi
# first download and verify xiin # create the error file in case it's needed
if [[ $B_UPLOAD_DEBUG_DATA == 'true' || $1 == 'disk' || $1 == 'sys' || $1 == 'all' ]];then if [[ $B_UPLOAD_DEBUG_DATA == 'true' || $1 == 'disk' || $1 == 'sys' || $1 == 'all' ]];then
touch $SELF_DATA_DIR/$Debug_Data_Dir/xiin-error.txt touch $SELF_DATA_DIR/$Debug_Data_Dir/xiin-error.txt
fi fi
# note, only bash 4> supports ;;& for case, so using if/then here # note, only bash 4> supports ;;& for case, so using if/then here
if [[ -z $BSD_TYPE ]] && [[ $1 == 'disk' || $1 == 'sys' || $1 == 'all' ]];then if [[ -z $BSD_TYPE ]] && [[ $1 == 'disk' || $1 == 'sys' || $1 == 'all' ]];then
echo $Line echo $Line
xiin_data_file=$SELF_DATA_DIR/$Debug_Data_Dir/xiin-sys.txt sys_data_file=$SELF_DATA_DIR/$Debug_Data_Dir/xiin-sys.txt
touch $xiin_data_file touch $sys_data_file
if type -p perl &>/dev/null;then if type -p perl &>/dev/null;then
echo "Collecting data from /sys..." echo "Collecting data from /sys..."
echo -n "Using Perl: " && perl --version | grep -oE 'v[0-9.]+' echo -n "Using Perl: " && perl --version | grep -oE 'v[0-9.]+'
xiin_data="$( perl -e ' sys_traverse_data="$( perl -e '
use File::Find; use File::Find;
use strict; use strict;
# use warnings; # use warnings;
@ -2222,17 +2226,18 @@ debug_data_collector()
# print scalar @content . "\n"; # print scalar @content . "\n";
print "$result"; print "$result";
} ' )" } ' )"
if [[ -z "$xiin_data" ]];then if [[ -z "$sys_traverse_data" ]];then
echo -e "ERROR: failed to generate /sys data - removing data file.\nContinuing with incomplete data collection." echo -e "ERROR: failed to generate /sys data - removing data file.\nContinuing with incomplete data collection."
echo "Continuing with incomplete data collection." echo "Continuing with incomplete data collection."
rm -f $xiin_data_file rm -f $sys_data_file
echo "/sys data generation failed. No data collected." >> $Debug_Data_Dir/xiin-error.txt echo "/sys data generation failed. No data collected." >> $Debug_Data_Dir/xiin-error.txt
else else
b_perl_worked='true'
echo 'Completed /sys data collection.' echo 'Completed /sys data collection.'
echo -n "$xiin_data" > $xiin_data_file echo -n "$sys_traverse_data" > $sys_data_file
fi fi
fi fi
if [[ -z "$xiin_data" ]];then if [[ -z "$sys_traverse_data" ]];then
download_xiin 'sys' download_xiin 'sys'
if [[ $? -eq 0 ]];then if [[ $? -eq 0 ]];then
b_run_xiin='true' b_run_xiin='true'
@ -2240,11 +2245,11 @@ debug_data_collector()
echo "Running $Xiin_File tool now on /sys..." echo "Running $Xiin_File tool now on /sys..."
echo -n "Using " && python --version echo -n "Using " && python --version
python --version &> $Debug_Data_Dir/python-version.txt python --version &> $Debug_Data_Dir/python-version.txt
python ./$Xiin_File -d /sys -f $xiin_data_file python ./$Xiin_File -d /sys -f $sys_data_file
if [[ $? -ne 0 ]];then if [[ $? -ne 0 ]];then
error=$? error=$?
echo -e "ERROR: $Xiin_File exited with error $error - removing data file.\nContinuing with incomplete data collection." echo -e "ERROR: $Xiin_File exited with error $error - removing data file.\nContinuing with incomplete data collection."
rm -f $xiin_data_file rm -f $sys_data_file
echo "$Xiin_File data generation failed with python error $error" >> $Debug_Data_Dir/xiin-error.txt echo "$Xiin_File data generation failed with python error $error" >> $Debug_Data_Dir/xiin-error.txt
fi fi
fi fi
@ -2253,7 +2258,7 @@ debug_data_collector()
fi fi
# has to be before gz cleanup # has to be before gz cleanup
if [[ $B_UPLOAD_DEBUG_DATA == 'true' ]];then if [[ $B_UPLOAD_DEBUG_DATA == 'true' ]];then
if [[ $b_xiin_downloaded == 'false' ]];then if [[ $b_xiin_downloaded == 'false' && $b_perl_worked == 'false' ]];then
echo $Line echo $Line
download_xiin 'upload' download_xiin 'upload'
if [[ $? -eq 0 ]];then if [[ $? -eq 0 ]];then
@ -2290,18 +2295,30 @@ debug_data_collector()
echo $completed_gz_file echo $completed_gz_file
if [[ $B_UPLOAD_DEBUG_DATA == 'true' ]];then if [[ $B_UPLOAD_DEBUG_DATA == 'true' ]];then
echo $Line echo $Line
if [[ $b_run_xiin == 'true' ]];then if [[ $b_perl_worked == 'true' ]];then
echo "Running automatic upload of data to remote server $ftp_upload now..." upload_debugger_data "$completed_gz_file"
python ./$Xiin_File --version
python ./$Xiin_File -u $completed_gz_file $ftp_upload
if [[ $? -gt 0 ]];then if [[ $? -gt 0 ]];then
echo $Line echo "Error: looks like the Perl ftp upload failed. Error number: $?"
echo "Error: looks like the ftp upload failed. Error number: $?" else
# echo "The ftp upload failed. Error number: $?" >> $Debug_Data_Dir/xiin-error.txt b_uploaded='true'
echo "Hurray! Looks like the Perl ftp upload worked!"
fi
fi
if [[ $b_uploaded == 'false' ]];then
if [[ $b_run_xiin == 'true' ]];then
echo "Running automatic upload of data to remote server $ftp_upload now..."
python ./$Xiin_File --version
python ./$Xiin_File -u $completed_gz_file $ftp_upload
if [[ $? -gt 0 ]];then
echo $Line
echo "Error: looks like the Python ftp upload failed. Error number: $?"
# echo "The ftp upload failed. Error number: $?" >> $Debug_Data_Dir/xiin-error.txt
fi
else
echo 'Unable to run the automatic ftp upload because no uploaders appear to be working or available.'
# that has been removed at this point, so no more logging
# echo "Unable to run the automoatic ftp upload because of an error with the xiin download" >> $Debug_Data_Dir/xiin-error.txt
fi fi
else
echo 'Unable to run the automatic ftp upload because of an error with the xiin download.'
# echo "Unable to run the automoatic ftp upload because of an error with the xiin download" >> $Debug_Data_Dir/xiin-error.txt
fi fi
else else
echo 'You can upload this here using most file managers: ftp.techpatterns.com/incoming' echo 'You can upload this here using most file managers: ftp.techpatterns.com/incoming'
@ -2313,6 +2330,50 @@ debug_data_collector()
fi fi
exit 0 exit 0
} }
## args: $1 - debugger file name
upload_debugger_data()
{
local result='' debugger_file=$1
if ! type -p perl &>/dev/null;then
echo "Perl is not installed!"
return 2
elif ! perl -MNet::FTP -e 1 &>/dev/null;then
echo "Required Perl module Net::FTP not installed."
return 3
fi
export debugger_file
echo "Starting Perl Uploader..."
result="$( perl -e '
use strict;
use warnings;
use Net::FTP;
my ($ftp, $host, $user, $pass, $dir, $fpath, $error);
$host = "ftp.techpatterns.com";
$user = "anonymous";
$pass = "anonymous\@techpatterns.com";
$dir = "incoming";
$fpath = $ENV{debugger_file};
$ftp = Net::FTP->new($host, Debug => 0);
$ftp->login($user, $pass) || die $ftp->message;
$ftp->binary();
$ftp->cwd($dir);
print "Connected to FTP server.\n";
$ftp->put($fpath) || die $ftp->message;
$ftp->quit;
print "Uploaded file.\n";
print $ftp->message;
' )"
echo "$result"
if [[ "$result" == *Goodbye* ]];then
return 0
else
return 1
fi
}
# $1 - download type [sys|upload] # $1 - download type [sys|upload]
download_xiin() download_xiin()
{ {
@ -2417,7 +2478,7 @@ check_recommends_user_output()
echo "Gawk version: $gawk_version" echo "Gawk version: $gawk_version"
echo "Sed version: $sed_version" echo "Sed version: $sed_version"
echo "Sudo version: $sudo_version" echo "Sudo version: $sudo_version"
echo "Python version: $python_version" echo "Python version: $python_version (deprecated)"
echo "Perl version: $perl_versio" echo "Perl version: $perl_versio"
echo $Line echo $Line
@ -2889,7 +2950,6 @@ get_parameters()
use_short='false' use_short='false'
;; ;;
M) B_SHOW_MACHINE='true' M) B_SHOW_MACHINE='true'
B_SHOW_BATTERY='true'
use_short='false' use_short='false'
;; ;;
n) B_SHOW_ADVANCED_NETWORK='true' n) B_SHOW_ADVANCED_NETWORK='true'
@ -3333,9 +3393,9 @@ show_options()
print_lines_basic "2" "10" "Color logging." print_lines_basic "2" "10" "Color logging."
print_lines_basic "1" "" "The following create a tar.gz file of system data, plus collecting the inxi output to file. To automatically upload debugger data tar.gz file to ftp.techpatterns.com: inxi^-xx@^<11-14>" print_lines_basic "1" "" "The following create a tar.gz file of system data, plus collecting the inxi output to file. To automatically upload debugger data tar.gz file to ftp.techpatterns.com: inxi^-xx@^<11-14>"
print_lines_basic "1" "" "For alternate ftp upload locations: Example:^inxi^-!^ftp.yourserver.com/incoming^-xx@^14" print_lines_basic "1" "" "For alternate ftp upload locations: Example:^inxi^-!^ftp.yourserver.com/incoming^-xx@^14"
print_lines_basic "2" "11" "With data file of xiin read of /sys." print_lines_basic "2" "11" "With data file of tree traverse read of /sys."
print_lines_basic "2" "12" "With xorg conf and log data, xrandr, xprop, xdpyinfo, glxinfo etc." print_lines_basic "2" "12" "With xorg conf and log data, xrandr, xprop, xdpyinfo, glxinfo etc."
print_lines_basic "2" "13" "With data from dev, disks, ${partition_string}s, etc., plus xiin data file." print_lines_basic "2" "13" "With data from dev, disks, ${partition_string}s, etc., plus /sys tree traverse data file."
print_lines_basic "2" "14" "Everything, full data collection." print_lines_basic "2" "14" "Everything, full data collection."
print_screen_output " " print_screen_output " "
print_screen_output "Advanced Options:" print_screen_output "Advanced Options:"

11
inxi.1
View file

@ -1,4 +1,4 @@
.TH INXI 1 "2017\-07\-30" inxi "inxi manual" .TH INXI 1 "2017\-08\-23" inxi "inxi manual"
.SH NAME .SH NAME
inxi \- Command line system information script for console and IRC inxi \- Command line system information script for console and IRC
.SH SYNOPSIS .SH SYNOPSIS
@ -604,13 +604,13 @@ For alternate ftp upload locations: Example:
\fIftp.yourserver.com/incoming\fB \-xx@ 14\fR \fIftp.yourserver.com/incoming\fB \-xx@ 14\fR
.TP .TP
.B \-@ 11 .B \-@ 11
\- With data file of xiin read of \fB/sys \- With tree traversal data file read of \fB/sys\fR
.TP .TP
.B \-@ 12 .B \-@ 12
\- With xorg conf and log data, xrandr, xprop, xdpyinfo, glxinfo etc. \- With xorg conf and log data, xrandr, xprop, xdpyinfo, glxinfo etc.
.TP .TP
.B \-@ 13 .B \-@ 13
\- With data from dev, disks, partitions, etc., plus xiin data file. \- With data from dev, disks, partitions, etc., plus thes tree traversal data file read of \fB/sys\fR.
.TP .TP
.B \-@ 14 .B \-@ 14
\- Everything, full data collection. \- Everything, full data collection.
@ -719,8 +719,9 @@ Copyright (C) 2005\-2007 Michiel de Boer a.k.a. locsmif
inxi version: Copyright (C) 2008\-17 Harald Hope inxi version: Copyright (C) 2008\-17 Harald Hope
Initial CPU logic, konversation version logic, and occasional Initial CPU logic, konversation version logic, occasional maintenance fixes,
maintenance fixes: Scott Rogers and the initial xiin.py tool for /sys parsing (deprecated but still very much
appreciated for all the valuable debugger data it helped generate): Scott Rogers
Further fixes (listed as known): Further fixes (listed as known):

View file

@ -1,3 +1,30 @@
=====================================================================================
Version: 2.3.37
Patch Version: 00
Script Date: 2017-08-23
-----------------------------------
Changes:
-----------------------------------
New version, new tarball, new man page. Deprecated xiin uploader, which completes the deprecation
of the xiin.py tool, which is going to become obsolete when python 3 fully replaces python 2.
Since the odds of perl being around and stable are far higher than the odds of xiin.py
even working on python 3, I'm getting ahead of the race. Plus Perl is nicer to work with.
And Perl is a lot faster. I mean, a lot. Not slightly.
And it also works on much older systems, and does not have that Python version < 2.6
failure due to changing Python syntax even between sub versions. xiin.py never ran on
Python 2.5 even when it was relatively recent, which is one reason I'm removing all Python
from inxi.
Basically xiin.py worked only on Python 2.6 or 2.7, period.
Oh, and also handled issue #115 by not making -B show -M data.
-----------------------------------
-- Harald Hope - Wed, 23 Aug 2017 15:06:22 -0700
===================================================================================== =====================================================================================
Version: 2.3.36 Version: 2.3.36
Patch Version: 00 Patch Version: 00