Sample program to generate a report and upload it to a web site.
#!/usr/bin/python # Filename : gentoo_report.py import os import sys import commands import subprocess import datetime def usage(): print \ "\n\tGentoo System Report\n" \ "\n" \ "\t", "To generate this report you will need:\n" \ "\t", "To be root!\n" \ "\t", "sys-apps/pciutils\n" \ "\t", "sys-apps/usbutils\n" def check_whoami(): if commands.getoutput( "whoami" ) != "root": sys.exit("\tSorry, You must be root!\n" ) def pn(): filename = "/tmp/report/gentoo_report.txt" fobj = open(filename, "a") newline = "\n" fobj.write(newline) fobj.close() def uname_report(): p = subprocess.Popen("uname -a > /tmp/report/gentoo_report.txt", shell=True, stdout=subprocess.PIPE) return p.stdout.readlines() def wm_version(): path = "/etc/X11/Sessions" lsdir = os.listdir(path) for fname in lsdir: if fname == "Gnome": p = subprocess.Popen("gnome-about --version | sed 's/gnome-about//' >> /tmp/report/gentoo_report.txt", shell=True, stdout=subprocess.PIPE) return p.stdout.readlines() elif fname == "kde-3.5": p = subprocess.Popen("kde-config --version >> /tmp/report/gentoo_report.txt", shell=True, stdout=subprocess.PIPE) return p.stdout.readlines() elif fname == "kde-4.1": p = subprocess.Popen("kde4-config --version >> /tmp/report/gentoo_report.txt", shell=True, stdout=subprocess.PIPE) return p.stdout.readlines() elif fname == "kde-4.2": p = subprocess.Popen("kde4-config --version >> /tmp/report/gentoo_report.txt", shell=True, stdout=subprocess.PIPE) return p.stdout.readlines() elif fname == "openbox": p = subprocess.Popen("openbox --version | sed '1!d' >> /tmp/report/gentoo_report.txt", shell=True, stdout=subprocess.PIPE) return p.stdout.readlines() elif fname == "fluxbox": p = subprocess.Popen("fluxbox --version >> /tmp/report/gentoo_report.txt", shell=True, stdout=subprocess.PIPE) return p.stdout.readlines() else: print "No Window Manager Found." def disk_report(): p = subprocess.Popen("df -h >> /tmp/report/gentoo_report.txt", shell=True, stdout=subprocess.PIPE) return p.stdout.readlines() def rcupdate_report(): p = subprocess.Popen("rc-update show >> /tmp/report/gentoo_report.txt", shell=True, stdout=subprocess.PIPE) return p.stdout.readlines() def cpuinfo_report(): p = subprocess.Popen("cat /proc/cpuinfo >> /tmp/report/gentoo_report.txt", shell=True, stdout=subprocess.PIPE) return p.stdout.readlines() def emerge_report(): p = subprocess.Popen("emerge --info >> /tmp/report/gentoo_report.txt", shell=True, stdout=subprocess.PIPE) return p.stdout.readlines() def lspci_report(): p = subprocess.Popen("lspci >> /tmp/report/gentoo_report.txt", shell=True, stdout=subprocess.PIPE) return p.stdout.readlines() def lsusb_report(): p = subprocess.Popen( "lsusb >> /tmp/report/gentoo_report.txt", shell=True, stdout=subprocess.PIPE) return p.stdout.readlines() def rcconf_report(): p = subprocess.Popen( "sed '/^[[:space:]]*\($\|#\)/d' /etc/rc.conf >> /tmp/report/gentoo_report.txt", shell=True, stdout=subprocess.PIPE) return p.stdout.readlines() def xorg_report(): p = subprocess.Popen( "sed '/^[[:space:]]*\($\|#\)/d' /etc/X11/xorg.conf >> /tmp/report/gentoo_report.txt", shell=True, stdout=subprocess.PIPE) return p.stdout.readlines() def create_date(): now = datetime.datetime.today() date = now.strftime("%h %d %Y %H:%M:%S") handle = open("/tmp/report/gentoo_report.txt","a") logline = [] logline.append(date) handle.write((" ".join(logline))+"\n") handle.close() def get_info(): nick = raw_input("Enter your nick on the Gentoo forum: ") dir = "/tmp/report/" if not os.path.exists(dir): os.makedirs(dir) make = raw_input("Enter the make of your computer: ") model = raw_input("Enter the model of your computer: ") filename = "/tmp/report/gentoo_report.txt" if os.path.exists(filename): print "Warning, file %s exists!" % filename cont = raw_input("Do you want to continue? [y/n] ") cont = cont.lower() if cont != "y" : sys.exit() try: fobj = open(filename, "w") except IOError, e: print "*** file open error:", e sys.exit() else: fobj.write(nick) fobj.write("\n") fobj.write(make) fobj.write("\n") fobj.write(model) fobj.write("\n") fobj.close() def sendfile(filename): curl = "curl" argv = "-T" fname= "/tmp/report/" + filename ftp = "ftp://dwabbott.com//var/www/localhost/htdocs/gentoo/" user = "--user" login = "user:passwd" subprocess.call([curl, argv, fname, ftp, user, login]) def sendall(files): for name in files: sendfile(name) def grabfiles(): files =['gentoo_report.txt'] sendall(files) def getdata(): usage() check_whoami() get_info() pn() uname_report() pn() disk_report() pn() wm_version() pn() rcupdate_report() pn() cpuinfo_report() pn() emerge_report() pn() lspci_report() pn() lsusb_report() pn() rcconf_report() pn() xorg_report() pn() create_date() pn() if __name__ == "__main__": getdata() grabfiles()
Linux opteron 2.6.28-gentoo-r1 #1 SMP Fri Jan 23 17:14:33 EST 2009 x86_64 Dual-Core AMD Opteron(tm) Processor 1220 SE AuthenticAMD GNU/Linux
Filesystem Size Used Avail Use% Mounted on
rootfs 229G 33G 185G 15% /
/dev/root 229G 33G 185G 15% /
rc-svcdir 1.0M 96K 928K 10% /lib64/rc/init.d
udev 10M 44K 10M 1% /dev
shm 2.0G 0 2.0G 0% /dev/shm
GNOME 2.24.3
keymaps | boot
mysql | default
bootmisc | boot
net.lo | boot
mtab | boot
savecache | shutdown
hald | default
fsck | boot
termencoding | boot
vixie-cron | default
consolefont | boot
alsasound | boot
sysctl | boot
sshd | default
acpid | default
net.eth0 | default
dmesg | sysinit
udev | sysinit
iptables | default
modules | boot
devfs | sysinit
urandom | boot
lm_sensors | default
dbus | default
xfs | default
swap | boot
nxserver | default
netmount | default
postgresql-8.3 | default
killprocs | shutdown
procfs | boot
hwclock | boot
localmount | boot
root | boot
syslog-ng | default
cupsd | default
ntp-client | default
ntop | default
hostname | boot
mount-ro | shutdown
local | nonetwork default
bluetooth | default
device-mapper | boot
ntpd | default
pulseaudio | default
processor : 0
vendor_id : AuthenticAMD
cpu family : 15
model : 67
model name : Dual-Core AMD Opteron(tm) Processor 1220 SE
stepping : 2
cpu MHz : 1000.000
cache size : 1024 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 2
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 1
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt rdtscp lm 3dnowext 3dnow rep_good pni cx16 lahf_lm cmp_legacy svm extapic cr8_legacy
bogomips : 2000.30
TLB size : 1024 4K pages
clflush size : 64
cache_alignment : 64
address sizes : 40 bits physical, 48 bits virtual
power management: ts fid vid ttp tm stc
processor : 1
vendor_id : AuthenticAMD
cpu family : 15
model : 67
model name : Dual-Core AMD Opteron(tm) Processor 1220 SE
stepping : 2
cpu MHz : 1000.000
cache size : 1024 KB
physical id : 0
siblings : 2
core id : 1
cpu cores : 2
apicid : 1
initial apicid : 1
fpu : yes
fpu_exception : yes
cpuid level : 1
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt rdtscp lm 3dnowext 3dnow rep_good pni cx16 lahf_lm cmp_legacy svm extapic cr8_legacy
bogomips : 2000.30
TLB size : 1024 4K pages
clflush size : 64
cache_alignment : 64
address sizes : 40 bits physical, 48 bits virtual
power management: ts fid vid ttp tm stc
Portage 2.1.6.7 (default/linux/amd64/2008.0/desktop, gcc-4.3.3, glibc-2.9_p20081201-r2, 2.6.28-gentoo-r1 x86_64)
=================================================================
System uname: Linux-2.6.28-gentoo-r1-x86_64-Dual-Core_AMD_Opteron-tm-_Processor_1220_SE-with-glibc2.2.5
Timestamp of tree: Sat, 07 Mar 2009 15:05:01 +0000
ccache version 2.4 [enabled]
app-shells/bash: 3.2_p48-r1
dev-java/java-config: 1.3.7-r1, 2.1.7
dev-lang/python: 2.4.4-r15, 2.5.4-r2
dev-python/pycrypto: 2.0.1-r6
dev-util/ccache: 2.4-r8
dev-util/cmake: 2.6.2
sys-apps/baselayout: 2.0.0
sys-apps/openrc: 0.4.3-r1
sys-apps/sandbox: 1.3.8
sys-devel/autoconf: 2.13, 2.63
sys-devel/automake: 1.5, 1.7.9-r1, 1.9.6-r2, 1.10.2
sys-devel/binutils: 2.19.1
sys-devel/gcc-config: 1.4.1
sys-devel/libtool: 2.2.6a
virtual/os-headers: 2.6.28-r1
ACCEPT_KEYWORDS="amd64 ~amd64"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=opteron -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/eselect/postgresql /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/udev/rules.d"
CXXFLAGS="-march=opteron -O2 -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="ccache distlocks fixpackages metadata-transfer parallel-fetch protect-owned sandbox sfperms strict unmerge-orphans userfetch"
GENTOO_MIRRORS="http://gentoo.osuosl.org/ ftp://ftp.gtlib.gatech.edu/pub/gentoo http://www.gtlib.gatech.edu/pub/gentoo http://open-systems.ufl.edu/mirrors/gentoo ftp://mirror.fslutd.org/linux/distributions/gentoo/ "
LDFLAGS="-Wl,-O1"
LINGUAS="en en_US"
MAKEOPTS="-j3"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="X aac acl acpi alsa amd64 apache2 automount avahi bash-completion berkdb bindist bluetooth branding bzip2 cairo ccache cdaudio cdda cddb cdparanoia cdr cdrom cleartype cli color-console colordiff cracklib crypt ctype cups curl dbus dri dvd dvdarchive dvdr dvdread emboss encode equalizer esd evo examples expat fam festival ffmpeg filter firefox3 flac fontconfig foomaticdb fortran ftp gconf gdbm gedit gif gimp git glib glitz gnome gnome-print gpm gsm gstreamer gtk gtkhtml gtkspell hal iconv ide imlib2 ipv6 isdnlog javascript jpeg lame ldap libnotify lm_sensors logrotate logviewer logwatch mad mailbox mbrola mdnsresponder-compat messages midi mikmod mjpeg mmx mp2 mp3 mp3rtp mp4 mp4live mpeg mpeg2 mplayer mudflap multilib mysql nautilus ncurses nls nptl nptlonly nsplugin ogg ogg123 opengl opengl-video opengl-xvmc openmp openssh pam pcre pdf perl php pidgin pixmaps png podcast policykit ppds pppd python quicktime readline reflection reiserfs rhythmbox rss sdl session slang sox spell spl sqlite sse sse2 ssl startup-notification status stream subversion svg svgz swig sysfs tcl tcpd theora threads threadsafe thunderbird tiff tk tokenizer truetype twolame type1 unicode unzip usb v4l v4l2 vhook video videos vim vim-pager vim-syntax vim-with-x vorbis wav weather wma wmp xcomposite xfs xml xmlrpc xorg xulrunner xv xvid zip zlib" ALSA_CARDS="emu10k1x" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic auth_digest authn_anon authn_dbd authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock dbd deflate dir disk_cache env expires ext_filter file_cache filter headers ident imagemap include info log_config logio mem_cache mime mime_magic negotiation proxy proxy_ajp proxy_balancer proxy_connect proxy_http rewrite setenvif so speling status unique_id userdir usertrack vhost_alias" ELIBC="glibc" INPUT_DEVICES="evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="en en_US" USERLAND="GNU" VIDEO_CARDS="vesa radeon radeonhd fglrx nv nvidia"
Unset: CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, LANG, LC_ALL, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, PORTDIR_OVERLAY
00:00.0 RAM memory: nVidia Corporation MCP55 Memory Controller (rev a2)
00:01.0 ISA bridge: nVidia Corporation MCP55 LPC Bridge (rev a3)
00:01.1 SMBus: nVidia Corporation MCP55 SMBus (rev a3)
00:02.0 USB Controller: nVidia Corporation MCP55 USB Controller (rev a1)
00:02.1 USB Controller: nVidia Corporation MCP55 USB Controller (rev a2)
00:04.0 IDE interface: nVidia Corporation MCP55 IDE (rev a1)
00:05.0 IDE interface: nVidia Corporation MCP55 SATA Controller (rev a3)
00:05.1 IDE interface: nVidia Corporation MCP55 SATA Controller (rev a3)
00:05.2 IDE interface: nVidia Corporation MCP55 SATA Controller (rev a3)
00:06.0 PCI bridge: nVidia Corporation MCP55 PCI bridge (rev a2)
00:08.0 Bridge: nVidia Corporation MCP55 Ethernet (rev a3)
00:09.0 Bridge: nVidia Corporation MCP55 Ethernet (rev a3)
00:0a.0 PCI bridge: nVidia Corporation MCP55 PCI Express bridge (rev a3)
00:0b.0 PCI bridge: nVidia Corporation MCP55 PCI Express bridge (rev a3)
00:0c.0 PCI bridge: nVidia Corporation MCP55 PCI Express bridge (rev a3)
00:0d.0 PCI bridge: nVidia Corporation MCP55 PCI Express bridge (rev a3)
00:0e.0 PCI bridge: nVidia Corporation MCP55 PCI Express bridge (rev a3)
00:0f.0 PCI bridge: nVidia Corporation MCP55 PCI Express bridge (rev a3)
00:18.0 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] HyperTransport Technology Configuration
00:18.1 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] Address Map
00:18.2 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] DRAM Controller
00:18.3 Host bridge: Advanced Micro Devices [AMD] K8 [Athlon64/Opteron] Miscellaneous Control
01:06.0 FireWire (IEEE 1394): VIA Technologies, Inc. VT6306 Fire II IEEE 1394 OHCI Link Layer Controller (rev c0)
01:07.0 Multimedia audio controller: Creative Labs [SB Live! Value] EMU10k1X
01:07.1 Input device controller: Creative Labs [SB Live! Value] Input device controller
07:00.0 VGA compatible controller: ATI Technologies Inc RV610 video device [Radeon HD 2400 PRO]
07:00.1 Audio device: ATI Technologies Inc RV610 audio device [Radeon HD 2400 PRO]
Bus 001 Device 001: ID 1d6b:0002
Bus 002 Device 003: ID 03f0:7204 Hewlett-Packard DeskJet 36xx
Bus 002 Device 002: ID 17a0:0001
Bus 002 Device 001: ID 1d6b:0001
rc_parallel="NO"
rc_interactive="YES"
rc_depend_strict="YES"
rc_logger="NO"
unicode="YES"
net_fs_list="afs cifs coda davfs fuse gfs ncpfs nfs nfs4 ocfs2 shfs smbfs"
rc_tty_number=12
Section "ServerLayout"
Identifier "X.org Configured"
Screen 0 "aticonfig-Screen[0]-0" 0 0
Screen "aticonfig-Screen[0]-1" LeftOf "aticonfig-Screen[0]-0"
Option "Dualhead" "true"
EndSection
Section "Files"
ModulePath "/usr/lib64/xorg/modules"
FontPath "built-ins"
FontPath "/usr/share/fonts/misc/"
FontPath "/usr/share/fonts/TTF/"
FontPath "/usr/share/fonts/OTF"
FontPath "/usr/share/fonts/Type1/"
FontPath "/usr/share/fonts/100dpi/"
FontPath "/usr/share/fonts/75dpi/"
FontPath "/usr/share/fonts/corefonts/"
FontPath "/usr/share/fonts/cyrillic/"
FontPath "/usr/share/fonts/default/"
FontPath "/usr/share/fonts/encodings/"
FontPath "/usr/share/fonts/freefonts/"
FontPath "/usr/share/fonts/prototype/"
FontPath "/usr/share/fonts/space_age/"
FontPath "/usr/share/fonts/terminus/"
FontPath "/usr/share/fonts/ttf-bitstream-vera/"
FontPath "/usr/share/fonts/util/"
FontPath "/usr/share/fonts/xawtv/"
EndSection
Section "Module"
Load "extmod"
Load "dbe"
Load "dri"
Load "record"
Load "glx"
Load "xtrap"
EndSection
Section "InputDevice"
Identifier "Keyboard0"
Driver "kbd"
EndSection
Section "InputDevice"
Identifier "Mouse0"
Driver "mouse"
Option "Protocol" "auto"
Option "Device" "/dev/input/mice"
Option "ZAxisMapping" "4 5"
EndSection
Section "Monitor"
Identifier "Monitor0"
VendorName "SAM"
ModelName "SyncMaster"
HorizSync 30.0 - 81.0
VertRefresh 56.0 - 75.0
Option "DPMS"
EndSection
Section "Monitor"
Identifier "aticonfig-Monitor[0]-0"
Option "VendorName" "ATI Proprietary Driver"
Option "ModelName" "Generic Autodetecting Monitor"
Option "DPMS" "true"
EndSection
Section "Monitor"
Identifier "aticonfig-Monitor[0]-1"
Option "VendorName" "ATI Proprietary Driver"
Option "ModelName" "Generic Autodetecting Monitor"
Option "DPMS" "true"
EndSection
Section "Device"
Identifier "Card0"
Driver "radeon"
VendorName "ATI Technologies Inc"
BoardName "RV610 video device [Radeon HD 2400 PRO]"
BusID "PCI:7:0:0"
EndSection
Section "Device"
Identifier "aticonfig-Device[0]-0"
Driver "fglrx"
BusID "PCI:7:0:0"
EndSection
Section "Device"
Identifier "aticonfig-Device[0]-1"
Driver "fglrx"
BusID "PCI:7:0:0"
Screen 1
EndSection
Section "Screen"
Identifier "Screen0"
Device "Card0"
Monitor "Monitor0"
SubSection "Display"
Viewport 0 0
Depth 24
EndSubSection
EndSection
Section "Screen"
Identifier "aticonfig-Screen[0]-0"
Device "aticonfig-Device[0]-0"
Monitor "aticonfig-Monitor[0]-0"
DefaultDepth 24
SubSection "Display"
Viewport 0 0
Depth 24
EndSubSection
EndSection
Section "Screen"
Identifier "aticonfig-Screen[0]-1"
Device "aticonfig-Device[0]-1"
Monitor "aticonfig-Monitor[0]-1"
DefaultDepth 24
SubSection "Display"
Viewport 0 0
Depth 24
EndSubSection
EndSection
Section "Extensions"
Option "Composite" "Enable"
EndSection
Mar 13 2009 13:02:38
#!/usr/bin/python # Filename : gentoo_report.py import os import sys import commands import subprocess import datetime from ftplib import FTP def usage(): print \ "\n\tGentoo System Report\n" \ "\n" \ "\t", "To generate this report you will need:\n" \ "\t", "To be root!\n" \ "\t", "sys-apps/pciutils\n" \ "\t", "sys-apps/usbutils\n" def check_whoami(): if commands.getoutput( "whoami" ) != "root": sys.exit("\tSorry, You must be root!\n" ) def pn(): filename = "/tmp/gentoo_report.txt" fobj = open(filename, "a") newline = "\n" fobj.write(newline) fobj.close() def uname_report(): p = subprocess.Popen("uname -a > /tmp/gentoo_report.txt", shell=True, stdout=subprocess.PIPE) return p.stdout.readlines() def wm_version(): path = "/etc/X11/Sessions" lsdir = os.listdir(path) for fname in lsdir: if fname == "Gnome": p = subprocess.Popen("gnome-about --version | sed 's/gnome-about//' >> /tmp/gentoo_report.txt", shell=True, stdout=subprocess.PIPE) return p.stdout.readlines() elif fname == "kde-3.5": p = subprocess.Popen("kde-config --version >> /tmp/gentoo_report.txt", shell=True, stdout=subprocess.PIPE) return p.stdout.readlines() elif fname == "kde-4.1": p = subprocess.Popen("kde4-config --version >> /tmp/gentoo_report.txt", shell=True, stdout=subprocess.PIPE) return p.stdout.readlines() elif fname == "kde-4.2": p = subprocess.Popen("kde4-config --version >> /tmp/gentoo_report.txt", shell=True, stdout=subprocess.PIPE) return p.stdout.readlines() elif fname == "openbox": p = subprocess.Popen("openbox --version | sed '1!d' >> /tmp/gentoo_report.txt", shell=True, stdout=subprocess.PIPE) return p.stdout.readlines() elif fname == "fluxbox": p = subprocess.Popen("fluxbox --version >> /tmp/gentoo_report.txt", shell=True, stdout=subprocess.PIPE) return p.stdout.readlines() else: print "No Window Manager Found." def disk_report(): p = subprocess.Popen("df -h >> /tmp/gentoo_report.txt", shell=True, stdout=subprocess.PIPE) return p.stdout.readlines() def rcupdate_report(): p = subprocess.Popen("rc-update show >> /tmp/gentoo_report.txt", shell=True, stdout=subprocess.PIPE) return p.stdout.readlines() def cpuinfo_report(): p = subprocess.Popen("cat /proc/cpuinfo >> /tmp/gentoo_report.txt", shell=True, stdout=subprocess.PIPE) return p.stdout.readlines() def emerge_report(): p = subprocess.Popen("emerge --info >> /tmp/gentoo_report.txt", shell=True, stdout=subprocess.PIPE) return p.stdout.readlines() def lspci_report(): p = subprocess.Popen("lspci >> /tmp/gentoo_report.txt", shell=True, stdout=subprocess.PIPE) return p.stdout.readlines() def lsusb_report(): p = subprocess.Popen( "lsusb >> /tmp/gentoo_report.txt", shell=True, stdout=subprocess.PIPE) return p.stdout.readlines() def rcconf_report(): p = subprocess.Popen( "sed '/^[[:space:]]*\($\|#\)/d' /etc/rc.conf >> /tmp/gentoo_report.txt", shell=True, stdout=subprocess.PIPE) return p.stdout.readlines() def xorg_report(): p = subprocess.Popen( "sed '/^[[:space:]]*\($\|#\)/d' /etc/X11/xorg.conf >> /tmp/gentoo_report.txt", shell=True, stdout=subprocess.PIPE) return p.stdout.readlines() def create_date(): now = datetime.datetime.today() date = now.strftime("%h %d %Y %H:%M:%S") handle = open("/tmp/gentoo_report.txt","a") logline = [] logline.append(date) handle.write((" ".join(logline))+"\n") handle.close() def sendfile(): ftp = FTP('wirelessfun.mobi') ftp.login('comprookie2000', 'passwd') print "Logging into server wirelessfun ... " ftp.mkd(nick) print "Created new directory", nick ftp.cwd(nick) fname = "/tmp/gentoo_report.txt" (head, tail) = os.path.split(fname) command = "STOR " + tail fd = open(fname, 'rb') temp = fd.read(2048) fd.seek(0, 0) if temp.find('\0') != -1: ftp.storbinary(command, fd) else: ftp.storlines(command, fd) ftp.close def getdata(): uname_report() pn() disk_report() pn() wm_version() pn() rcupdate_report() pn() cpuinfo_report() pn() emerge_report() pn() lspci_report() pn() lsusb_report() pn() rcconf_report() pn() xorg_report() pn() create_date() pn() if __name__ == "__main__": usage() check_whoami() nick = raw_input("Enter your nick on the Gentoo forum: ") directory = "/tmp/report/" if not os.path.exists(directory): os.makedirs(directory) make = raw_input("Enter the make of your computer: ") model = raw_input("Enter the model of your computer: ") filename = "/tmp/gentoo_report.txt" if os.path.exists(filename): print "Warning, file %s exists!" % filename cont = raw_input("Do you want to continue? [y/n] ") cont = cont.lower() if cont != "y" : sys.exit() try: fobj = open(filename, "w") except IOError, e: print "*** file open error:", e sys.exit() else: fobj.write(nick) fobj.write("\n") fobj.write(make) fobj.write("\n") fobj.write(model) fobj.write("\n") fobj.close() getdata() sendfile() print print "Your report has been uploaded to http://wirelessfun.mobi/%s" % nick + "/gentoo_report.txt" print