wifixers team mailing list archive
-
wifixers team
-
Mailing list archive
-
Message #00020
[Merge] lp:~wifixers/wifix/kermiac-restructure into lp:wifix
Mitch Towner has proposed merging lp:~wifixers/wifix/kermiac-restructure into lp:wifix.
Requested reviews:
Mitch Towner (kermiac)
--
https://code.launchpad.net/~wifixers/wifix/kermiac-restructure/+merge/32659
Your team Wifixers is subscribed to branch lp:wifix.
=== added file 'README'
--- README 1970-01-01 00:00:00 +0000
+++ README 2010-08-14 10:39:40 +0000
@@ -0,0 +1,42 @@
+This file should replace "Tech Notes"
+
+=========
+How To Run Wifix
+=========
+
+From a terminal window, run the following command:
+
+python wifix.py
+
+
+=========
+Interface
+=========
+
+WiFix chooses from a number of available interfaces. The priority of
+UIs, from highest to lowest, is as follows:
+
+-GTK
+-Qt
+-text
+
+
+For help on invoking a specific mode, open a terminal window and run the following command:
+
+wifix.py --help
+
+
+
+========
+DB Query
+========
+
+The program connects to a database with device ID-to-driver mappings and
+driver-to-arguments mappings. The arguments consist of many parameters
+needed to install the driver, such as the URL to retrieve it from, the
+location of the INF file in the archive (where necessary), any special
+instructions needed to compile the driver (where necessary), etc.
+
+When an unknown device ID is entered into the database, it is logged.
+These IDs are then added to the database, along with the appropriate
+mappings, when the appropriate driver is found.
=== added file 'linux-install-wifi'
--- linux-install-wifi 1970-01-01 00:00:00 +0000
+++ linux-install-wifi 2010-08-14 10:39:40 +0000
@@ -0,0 +1,458 @@
+#!/bin/bash
+# Author: bmartin (blakecmartin@xxxxxxxxx)
+# Author: Buran Ayuthia (the.ayuthias@xxxxxxxxx)
+
+####################
+# This file is part of WiFix.
+#
+# WiFix is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# WiFix is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+####################
+
+# display a message to the user
+message() {
+ xmessage -center "$*"
+}
+
+# ensure this program is run as the superuser
+if [ $(id -u) -ne 0 ]; then
+ message "You must be root to run this program."
+ exit 0
+fi
+
+# add a command to be run at the end of the installation
+append-command() {
+ COMMANDS[$COMMAND_INDEX]="$*"
+ let "COMMAND_INDEX = $COMMAND_INDEX + 1"
+}
+
+# perform a normal make
+do-make() {
+ # use explicitly-specified working directory, if available
+ if [ "$DIR" ]; then
+ pushd $DIR > /dev/null
+ else
+ pushd "$1" > /dev/null
+ fi
+
+ [ "$FIRMWARE" ] && progress "firmware" "Installing firmware"
+ progress "make" "Compiling"
+ # strip debugging information, if desired
+ [ "$STRIP" ] && progress "strip -S *.ko" "Stripping debugging information from modules"
+ progress "make install" "Installing"
+ # this avoids module dependency and location problems
+ progress "depmod -ae" "Resolving module dependencies"
+ # insert the desired kernel modules
+ insert-modules
+
+ popd > /dev/null
+}
+
+# ensure the given program exists in the current path
+ensure-program() {
+ while [ ! "$*" = "" ]; do
+ if [ ! $(which $1) ]; then
+ message "$1, a necessary program to run this installer, was not found. Please install
+" "$1 and run the installer again.
+
+" "If $1 exists on your computer, you may have to modify the value of "'$PATH'"
+" "or create a symbolic link to $1 within "'$PATH'" on your computer."
+
+ exit 1
+ fi
+
+ shift
+ done
+}
+
+# copy firmware from make directory
+firmware() {
+ mkdir -p $FIRMWARE
+ cp *.bin $FIRMWARE
+}
+
+# retrieve a CAB file with InstallShield files in it
+get-cab() {
+ # handle CAB
+ progress-file "$1" "Retrieving file"
+ file=$(echo $1 | sed "s|.*/||g")
+ progress "cabextract $file" "Extracting files from CAB file"
+
+ inf
+}
+
+# retrieve a CAB file with InstallShield files in it
+get-cab-unsh() {
+ # handle CABs with InstallShield installers
+ progress-file "$1" "Retrieving file"
+ file=$(echo $1 | sed "s|.*/||g")
+ progress "cabextract $file" "Extracting files from CAB file"
+ progress "unshield x $(find . -name *.cab)" "Unshielding InstallShield files"
+
+ inf
+}
+
+# retrieve code from a CVS repository
+get-cvs() {
+ # handle CVS repositories
+ cvs -d:pserver:anonymous@$1 $2 $3
+
+ # compile the source code
+ pushd $3 > /dev/null
+ do-make
+ popd > /dev/null
+}
+
+# retrieve code from a GIT repository
+get-git() {
+ # handle GIT source trees
+ git-clone $1
+ echo $1
+}
+
+# retrieve code from a SVN repository
+get-svn() {
+ # handle subversion repositories
+ progress "svn co $1 $2" "Retrieving file"
+ do-make $2
+}
+
+# retrieve a tarball
+get-url() {
+ # handle normal installers (tarballs)
+ progress-file "$1" "Retrieving file"
+ progress "tar xvf $FILENAME" "Extracting archive contents"
+ dir="$(echo $FILENAME | sed "s|\.tar\..*||g")"
+ do-make "$dir"
+}
+
+# retrieve a file in ZIP archive format
+get-zip() {
+ # handle zip files
+ progress-file "$1" "Retrieving file"
+
+ # unzip only *.zip, if desired
+ if [ "$UNZIP" ]; then
+ progress "unzip -au $FLAT *.zip" "Extracting files"
+ # otherwise, unzip whatever file was downloaded
+ else
+ file=$(echo $1 | sed "s|.*/||g")
+ progress "unzip -au $FLAT $file" "Extracting files"
+ fi
+
+ inf
+}
+
+# retrieve a zip file, extract the extracted files, then unshield the CABs
+get-zip-cab-unsh() {
+ INF_TEMP="$INF"
+ INF=""
+ # get file and unzip
+ get-zip "$1"
+ # cabextract all files
+ progress "cabextract $(find . -name *.exe)" "Extracting CAB files"
+ # unshield CAB files
+ progress "unshield x $(find . -name *.cab)" "Unshielding InstallShield files"
+ # install driver
+ INF="$INF_TEMP"
+
+ inf
+}
+
+# unzip and unshield
+get-zip-unsh() {
+ INF_TEMP="$INF"
+ INF=""
+ # get file and unzip
+ get-zip "$1"
+ # unshield CAB files
+ progress "unshield x $(find . -name *.cab)" "Unshielding InstallShield files"
+ # install driver
+ INF="$INF_TEMP"
+
+ inf
+}
+
+# perform 2 unzips
+get-zipzip() {
+ FLAT_TEMP="$FLAT"
+ INF_TEMP="$INF"
+ UNZIP_TEMP="$UNZIP"
+
+ # unzip first file, but don't install the driver
+ INF=""
+ get-zip "$1"
+ INF="$INF_TEMP"
+
+ # unzip the newly-created zips
+ FLAT=""
+ UNZIP="yes"
+ get-zip "$1"
+ UNZIP="$UNZIP_TEMP"
+ FLAT="$FLAT_TEMP"
+}
+
+install-ndis(){
+ # see if the ndiswrapper utility exists
+ which ndiswrapper > /dev/null
+ NDIS_FOUND=$?
+
+ if [ $NDIS_FOUND -eq 0 ]; then
+ NDIS_INFO=$(ndiswrapper -v | grep "^version:" | grep -o "[.0-9]*$")
+ UPDATE=$(expr $NDIS_INFO '<' $CUR_VER)
+ # if the version is new enough, don't compile
+ [ $UPDATE -eq 0 ] && return
+ fi
+
+ # retrieve and unpack source
+ rm $DONE_MARKER
+ ARCH="ndiswrapper.tar.gz"
+ progress-file "http://prdownloads.sourceforge.net/ndiswrapper/ndiswrapper-${CUR_VER}.tar.gz" "Retrieving NDISwrapper source code" "$ARCH"
+ # unpackage-ndis ndiswrapper-*
+ progress "tar xvf $ARCH" "Extracting NDISwrapper source code"
+
+ # compile and install NDISwrapper
+ pushd ndiswrapper-* > /dev/null
+ progress "make uninstall" "Uninstalling old NDISwrapper files"
+ progress "make" "Compiling NDISwrapper"
+ progress "make install" "Installing NDISwrapper"
+ popd > /dev/null
+}
+
+# install driver using INF file
+inf() {
+ install-ndis
+ NDIS_DRIVER=$(echo $INF|sed "s|.*/||g")
+ NDIS_DRIVER="${NDIS_DRIVER%.inf}"
+
+ if [ "$INF" ]; then
+ progress "ndiswrapper -e" "$NDIS_DRIVER" "Removing old driver"
+ progress "ndiswrapper -i" "$INF" "Installing driver"
+ progress "ndiswrapper -ma" "Configuring NDISwrapper"
+ progress "modprobe ndiswrapper" "Inserting ndiswrapper module"
+ fi
+
+ # blacklist the necessary kernel modules
+ ndiswrapper -l | grep -o "alternate driver:.*$" | sed "s|^.* \(.*\))$|blacklist \1|g" > $BLACKLIST_FILE
+}
+
+# insert kernel modules
+insert-modules() {
+ # use explicitly-specified modules by default
+ if [ "$MODULES" ]; then
+ for module in "$MODULES"; do
+ progress "modprobe -v $module" "Inserting $module module"
+ done
+ # otherwise, insert whatever modules are available in $(pwd)
+ else
+ for module in $(ls *.ko); do
+ module="${module%.ko}"
+ progress "modprobe -v $module" "Inserting $module module"
+ done
+ fi
+}
+
+# show a progress monitor while performing a certain task
+progress() {
+ if [ "$3" ]; then
+ $1 "$2" | tee -a $LOG | zenity --progress --pulsate --auto-close --auto-kill --text="$3..."
+ else
+ $1 | tee -a $LOG | zenity --progress --pulsate --auto-close --auto-kill --text="$2..."
+ fi
+
+ if [ $PIPESTATUS -ne 0 ]; then
+ message "Installer failed at $2. See $LOG for more details."
+ exit 1
+ fi
+}
+
+# retrieve a file, showing a progress monitor
+progress-file() {
+ # figure out what the name of the downloaded file will be
+ if [ $3 ]; then
+ FILENAME="$3"
+ else
+ FILENAME="$(echo $1 | sed 's|.*/||g')"
+ fi
+
+ # if the file was already downloaded, don't get it again
+ if [ ! -f "$DONE_MARKER" ]; then
+ $WGET -O "$FILENAME" "$1" 2>&1 | sed -u 's|.*\ \([0-9]\+%\)\ \+\([0-9.]\+\ [KMB\/s]\+\)$|\1\n# Downloading \2|' | tee -a $LOG | zenity --progress --auto-close --auto-kill --text="$2..."
+ touch $DONE_MARKER
+ if [ $PIPESTATUS -ne 0 ]; then
+ message "Installer failed at $2. See $LOG for more details."
+ exit 1
+ fi
+ fi
+}
+
+#############################
+# BEGINNING OF MAIN PROGRAM #
+#############################
+
+ensure-program "xmessage" "zenity"
+
+BLACKLIST_FILE="/etc/modprobe.d/blacklist-wifix.conf"
+DATE_STR="$(date +%s-%F)"
+DONE_MARKER="./.done-downloading"
+LOG="/var/log/wifix-$DATE_STR"
+TEMP="/tmp/wifix/$DATE_STR"
+WGET="wget"
+
+# see if we're testing
+workdir="$(pwd)"
+if [ ! "${workdir%/tests}" = "$workdir" ]; then
+ TESTING="yes"
+ TEMP="/tmp/wifix/$(echo test$* | sed "s|[^a-zA-Z0-9]|-|g")"
+ echo "***TESTING MODE ENABLED***"
+ echo "***temporary directory: $TEMP"
+fi
+
+# process arguments
+while [ ! "$*" = "" ]; do
+ case "$1" in
+ ("-cab")
+ # retrieve source code from CAB file
+ ensure-program "cabextract"
+ append-command "get-cab $2"
+ shift
+ ;;
+ ("-cab-unsh")
+ # retrieve source code from CAB file and unshield as necessary
+ ensure-program "cabextract" "unshield"
+ append-command "get-cab-unsh $2"
+ shift
+ ;;
+ ("-cvs")
+ # retrieve source code using CVS program
+ ensure-program "cvs"
+ append-command "get-cvs $2 $3 $4"
+ shift 3
+ ;;
+ ("-dir")
+ # use alternate directory for building
+ DIR="$2"
+ shift
+ ;;
+ ("-firmware")
+ # copy firmware files from make directory
+ FIRMWARE="$2"
+ shift
+ ;;
+ ("-flat")
+ # don't recreate ZIP structure
+ FLAT="-j"
+ ;;
+ ("-git")
+ # retrieve source code using GIT program
+ ensure-program "git"
+ append-command "get-git $2"
+ shift
+ ;;
+
+ ("-inf")
+ # use the given INF file
+ ensure-program "gcc"
+ INF="$2"
+ shift
+ ;;
+ ("-module")
+ # specify kernel modules to be inserted
+ ensure-program "modprobe"
+ MODULES="$(echo $2 | sed 's|,| |g')"
+ shift
+ ;;
+ ("-ndis")
+ # sets the ndiswrapper version
+ CUR_VER="$2"
+ shift
+ ;;
+ ("-strip")
+ # strips debugging information from kernel modules
+ ensure-program "strip"
+ STRIP="yes"
+ ;;
+ ("-svn")
+ # retrieve source code using Subversion
+ ensure-program "svn"
+ append-command "get-svn $2 $3"
+ shift 2
+ ;;
+ ("-url")
+ # retrieve a compressed tarball
+ ensure-program "wget"
+ append-command "get-url $2"
+ shift
+ ;;
+ ("-unzip")
+ # force "unzip -a *.zip"
+ UNZIP="yes"
+ ;;
+ ("-zip")
+ # retrieve a zip file
+ ensure-program "unzip"
+ append-command "get-zip $2"
+ shift
+ ;;
+ ("-zip-cab-unsh")
+ # retrieve a zip file and uncab/unshield as necessary
+ ensure-program "cabextract" "unshield" "unzip"
+ append-command "get-zip-cab-unsh $2"
+ shift
+ ;;
+ ("-zip-unsh")
+ # retrieve a zip file and uncab/unshield as necessary
+ ensure-program "unshield" "unzip"
+ append-command "get-zip-unsh $2"
+ shift
+ ;;
+ ("-zipzip")
+ # retrieve a zip file
+ ensure-program "unzip"
+ append-command "get-zipzip $2"
+ shift
+ ;;
+ (*):
+ echo "Invalid argument: $1"
+ exit 1
+ esac
+
+ shift
+done
+
+if [ "$INF" ]; then
+ if [ ! "$CUR_VER" ]; then
+ message "NDISwrapper version not specified; cannot install driver."
+ exit 0
+ fi
+fi
+
+# create temporary directory and change into it
+mkdir -p $TEMP
+pushd $TEMP > /dev/null
+
+# execute all commands in the $COMMANDS array
+index=0
+if [ "$COMMAND_INDEX" ]; then
+ while [ "$index" -lt "$COMMAND_INDEX" ]; do
+ ${COMMANDS[$index]}
+ let "index = $index + 1"
+ done
+
+ message "Installation was successful!"
+else
+ message "Nothing to do; exiting."
+fi
+
+# return to previous directory
+popd > /dev/null
=== added directory 'messages'
=== added file 'messages.py'
--- messages.py 1970-01-01 00:00:00 +0000
+++ messages.py 2010-08-14 10:39:40 +0000
@@ -0,0 +1,36 @@
+#!/bin/python
+# Author: bmartin (blakecmartin@xxxxxxxxx)
+
+"""
+This file is part of WiFix.
+
+WiFix is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WiFix is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
+
+err_root = "Please run the installer without root priviledges."
+submitted = "Wifix was unable to match a wireless device on this computer with any currently in the Wifix communitys Driver Database.\n\nThe Wifix Driver Database is a work in progress being built with the help of feedback from people like you. To help improve the database for everyone, please copy and paste the following information into an e-mail to wifi.feedback@xxxxxxxxx:\n\n"
+no_driver = "No driver information found on database.\nGathering debugging info"
+usage = "USAGE:\twifix [ ARGS ]\n\nARGS:\n\t--help\tShow this usage\n\t--gtk\tUse GTK interface\n\t--qt\tUse QT interface\n\t--text\tUse text interface\n"
+
+def privacy():
+ return __read_file('./messages/privacy')
+
+def submission():
+ return __read_file('./messages/submission')
+
+def __read_file(file):
+ f = open(file, 'r')
+ contents = f.read()
+ f.close()
+ return contents
=== added file 'messages/privacy'
--- messages/privacy 1970-01-01 00:00:00 +0000
+++ messages/privacy 2010-08-14 10:39:40 +0000
@@ -0,0 +1,5 @@
+TERMS OF USE:
+
+The Wifix software queries the Wifix database to determine the appropriate driver(s) for your hardware. To do this vendor and device IDs from network devices on your system will be submitted to our database. No personally identifiable information is collected. We use this information in order to better serve you and everyone who runs Wifix in the future.
+
+By clicking Yes, you agree to these terms and conditions.
=== added file 'messages/submission'
--- messages/submission 1970-01-01 00:00:00 +0000
+++ messages/submission 2010-08-14 10:39:40 +0000
@@ -0,0 +1,5 @@
+Your wireless adaptor was detected, but we couldn't locate the appropriate driver in our database. We would like to add your adaptor information to our database so that we may locate the appropriate driver. When this is completed it will also enable all WiFix users with this same adaptor to install the appropriate driver.
+
+The only information that will be sent is the vendor id and device id of your wireless adaptor. No personal information will be taken or passed to any third party.
+
+If you would like to help us by submitting your adaptor's information, press the Submit button below. Otherwise, press Exit and no information will be sent.
=== added file 'platforms.py'
--- platforms.py 1970-01-01 00:00:00 +0000
+++ platforms.py 2010-08-14 10:39:40 +0000
@@ -0,0 +1,236 @@
+#!/usr/bin/python
+# Author: bmartin (blakecmartin@xxxxxxxxx)
+# Author: Buran Ayuthia (the.ayuthias@xxxxxxxxx)
+
+"""
+This file is part of WiFix.
+
+WiFix is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WiFix is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
+
+# The idea here is to polymorphically run commands depending on which operating
+# system is detected (e.g., BSD, Linux).
+
+import commands
+import httplib
+import os
+import string
+import sys
+import urllib
+import time
+
+import messages
+
+class __Platform:
+ """
+ Provides an interface for OS-dependent calls.
+ """
+
+ def execute(self, command):
+ """
+ Executes the given command within a terminal. All output resulting from
+ executing the given command should be displayed in the terminal.
+ """
+
+ raise NotImplementedError
+
+ def get_devices(self):
+ """
+ Retrieves a listing of all PCI IDs of network devices on the computer.
+ """
+
+ raise NotImplementedError
+
+ def get_installer_command(self, arguments):
+ """
+ Retrives the command to run the installer with the given arguments.
+ """
+
+ raise NotImplementedError
+
+ def has_display(self):
+ """
+ Returns True if a display is available; False otherwise.
+ """
+
+ raise NotImplementedError
+
+ def is_root(self):
+ """
+ Returns True if the current process is being executed with elevated
+ privileges, False otherwise.
+ """
+
+ raise NotImplementedError
+
+ def message(self, message):
+ """
+ Displays a message to the user.
+ """
+
+ raise NotImplementedError
+
+ def message_yesno(self, message):
+ """
+ Displays a yes/no message to the user.
+ """
+
+ raise NotImplementedError
+
+ def __get_pci_devices(self):
+ """
+ Retrieves a listing of PCI IDs of all PCI network devices on the
+ computer.
+ """
+
+ raise NotImplementedError
+
+ def __get_usb_devices(self):
+ """
+ Retrieves a listing of USB IDs of all USB network devices on the
+ computer.
+ """
+
+ raise NotImplementedError
+
+class PlatformLinux(__Platform):
+ """
+ OS-specific calls for the Linux implementation.
+ """
+ def get_debug_info (self, pm):
+ pci_devices = []
+ usb_devices = []
+ device_label = []
+
+ # retrieve PCI networking devices
+ pm.start("Gathering info", messages.no_driver)
+ for pci_device in self.__get_pci_devices():
+ device_label.append(commands.getoutput('lspci -nn | grep ' + pci_device + ' | sed "s|.*: ||g"'))
+
+ # retrieve USB devices
+ for usb_device in self.__get_usb_devices():
+ device_label.append(usb_device)
+
+ #build the timestamp (yyyymmddhhmmss)
+ y = str(time.localtime ()[0])
+ m = str(time.localtime ()[1]).zfill (2)
+ d = str(time.localtime ()[2]).zfill (2)
+ h = str(time.localtime ()[3]).zfill (2)
+ mi = str(time.localtime ()[4]).zfill (2)
+ s = str(time.localtime ()[5]).zfill (2)
+ timestamp = y + m + d + h + mi + s
+ pm.stop()
+
+ return timestamp + '\n' + string.join(device_label, '\n')
+
+ def get_devices(self, pm):
+ options_list = []
+ pci_devices = []
+ usb_devices = []
+ device_label = dict()
+
+ # retrieve PCI networking devices
+ pm.start("Gathering devices", "Searching for PCI adaptors")
+ for pci_device in self.__get_pci_devices():
+ pci_devices.append(pci_device + ".P")
+ device_label[pci_device] = commands.getoutput('lspci -nn | grep ' + pci_device + ' | sed "s|.*: ||g"')
+ pm.stop()
+
+ # retrieve USB networking devices
+ pm.start("Gathering devices", "Searching for USB adaptors")
+ for usb_device in self.__get_usb_devices():
+ usb_devices.append(usb_device + ".U")
+ device_label[usb_device] = commands.getoutput('lsusb | grep ' + usb_device + ' | sed "s|.*: ID ||g"')
+ pm.stop()
+
+ devices = string.join(pci_devices, ';') + ";" + string.join(usb_devices, ';')
+ params = urllib.urlencode({'cards': devices})
+ headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
+
+ # Call PHP page to retrieve available drivers
+ pm.start("Querying database", "Fetching driver information from database")
+ try:
+ die = False
+ conn = httplib.HTTPConnection("wifix.sourceforge.net:80")
+ conn.request("POST", "/get-driver.php", params, headers)
+ response = conn.getresponse()
+ data = response.read()
+ # TODO might want to do something with response.status, response.reason
+ except Error, description:
+ self.message("Unable to connect to database: " + description)
+ die = True
+ finally:
+ conn.close()
+ pm.stop()
+ if die:
+ sys.exit()
+
+ card = dict()
+
+ for line in data.split("<br>"):
+ # find the first "=" in the string
+ index = line.find("=")
+ if (index == -1):
+ # no "=" present; not driver info
+ if card.has_key('arguments'):
+ # add card info to list
+ if card['arguments'] != "":
+ card['label'] = device_label[card['id'][0:9]]
+ options_list.append(card)
+ card = dict()
+ else:
+ # add key:value pair
+ key=line[0:index]
+ value=line[index + 1:]
+ card[key] = value
+ return options_list
+
+ def get_installer_command(self, arguments):
+ args = arguments.split(';')
+ arguments = string.join(args, ' ')
+ return 'bash linux-install-wifi ' + arguments
+
+ def __get_pci_devices(self):
+ wifi_pci = commands.getoutput('d="[0-9a-f]" ; pci_id="$d$d$d$d":"$d$d$d$d" ; p="[0-9]" ; bus="$p$p:$p$p\.$p" ; pcis=$(lshw -C network | grep "bus info: pci@" | grep -o "$bus") ; lspci -nn | grep -F "$pcis" | grep -o "$pci_id"')
+ # skip line 0 (lshw su warning) to only return actual devices)
+ return wifi_pci.splitlines()[1:]
+
+ def __get_usb_devices(self):
+ wifi_usb = commands.getoutput('d="[0-9a-f]" ; pci_id="$d$d$d$d":"$d$d$d$d" ; lsusb | grep -o "${pci_id}" | grep -v "0000:0000"')
+ return wifi_usb.splitlines()
+
+ def is_root(self):
+ return not os.system('[ $(id -u) = 0 ]')
+
+ def message(self, message):
+ return os.system("zenity --info --text='" + message + "'")
+
+ def message_yesno(self, message):
+ return os.system("zenity --question --text='" + message + "'") == 0
+
+ def has_display(self):
+ if (commands.getoutput('echo $DISPLAY') != ""):
+ return True
+ else:
+ return False
+
+ def execute(self, command):
+ return os.system(command)
+
+class PlatformBSD(__Platform):
+ """
+ OS-specific calls for the BSD implementation.
+ """
+
+ pass
=== added file 'pm.py'
--- pm.py 1970-01-01 00:00:00 +0000
+++ pm.py 2010-08-14 10:39:40 +0000
@@ -0,0 +1,46 @@
+#!/usr/bin/python
+# Author: bmartin (blakecmartin@xxxxxxxxx)
+
+"""
+This file is part of WiFix.
+
+WiFix is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WiFix is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
+
+import os
+import subprocess
+
+class ProgressMonitor():
+ def start(self, title, message):
+ """
+ Causes the progress monitor to pulsate.
+ """
+
+ self.p1 = subprocess.Popen(["/bin/cat", "/dev/zero"], stdout=subprocess.PIPE)
+ self.p2 = subprocess.Popen(["zenity", "--progress", "--pulsate", "--text=" + message, "--title=" + title], stdin=self.p1.stdout, stdout=subprocess.PIPE)
+ self.pid1 = self.p1.pid
+ self.pid2 = self.p2.pid
+
+ def stop(self):
+ """
+ Causes the progress monitor to disappear.
+ """
+
+ # kill the thread that feeds the pipe into zenity
+ os.kill(self.pid1, 1)
+ # kill the zenity thread
+ os.kill(self.pid2, 1)
+ # wait for the threads to finish
+ self.p1.wait()
+ self.p2.wait()
=== removed directory 'src'
=== removed file 'src/linux-install-wifi'
--- src/linux-install-wifi 2010-08-09 21:53:11 +0000
+++ src/linux-install-wifi 1970-01-01 00:00:00 +0000
@@ -1,458 +0,0 @@
-#!/bin/bash
-# Author: bmartin (blakecmartin@xxxxxxxxx)
-# Author: Buran Ayuthia (the.ayuthias@xxxxxxxxx)
-
-####################
-# This file is part of WiFix.
-#
-# WiFix is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# WiFix is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-####################
-
-# display a message to the user
-message() {
- xmessage -center "$*"
-}
-
-# ensure this program is run as the superuser
-if [ $(id -u) -ne 0 ]; then
- message "You must be root to run this program."
- exit 0
-fi
-
-# add a command to be run at the end of the installation
-append-command() {
- COMMANDS[$COMMAND_INDEX]="$*"
- let "COMMAND_INDEX = $COMMAND_INDEX + 1"
-}
-
-# perform a normal make
-do-make() {
- # use explicitly-specified working directory, if available
- if [ "$DIR" ]; then
- pushd $DIR > /dev/null
- else
- pushd "$1" > /dev/null
- fi
-
- [ "$FIRMWARE" ] && progress "firmware" "Installing firmware"
- progress "make" "Compiling"
- # strip debugging information, if desired
- [ "$STRIP" ] && progress "strip -S *.ko" "Stripping debugging information from modules"
- progress "make install" "Installing"
- # this avoids module dependency and location problems
- progress "depmod -ae" "Resolving module dependencies"
- # insert the desired kernel modules
- insert-modules
-
- popd > /dev/null
-}
-
-# ensure the given program exists in the current path
-ensure-program() {
- while [ ! "$*" = "" ]; do
- if [ ! $(which $1) ]; then
- message "$1, a necessary program to run this installer, was not found. Please install
-" "$1 and run the installer again.
-
-" "If $1 exists on your computer, you may have to modify the value of "'$PATH'"
-" "or create a symbolic link to $1 within "'$PATH'" on your computer."
-
- exit 1
- fi
-
- shift
- done
-}
-
-# copy firmware from make directory
-firmware() {
- mkdir -p $FIRMWARE
- cp *.bin $FIRMWARE
-}
-
-# retrieve a CAB file with InstallShield files in it
-get-cab() {
- # handle CAB
- progress-file "$1" "Retrieving file"
- file=$(echo $1 | sed "s|.*/||g")
- progress "cabextract $file" "Extracting files from CAB file"
-
- inf
-}
-
-# retrieve a CAB file with InstallShield files in it
-get-cab-unsh() {
- # handle CABs with InstallShield installers
- progress-file "$1" "Retrieving file"
- file=$(echo $1 | sed "s|.*/||g")
- progress "cabextract $file" "Extracting files from CAB file"
- progress "unshield x $(find . -name *.cab)" "Unshielding InstallShield files"
-
- inf
-}
-
-# retrieve code from a CVS repository
-get-cvs() {
- # handle CVS repositories
- cvs -d:pserver:anonymous@$1 $2 $3
-
- # compile the source code
- pushd $3 > /dev/null
- do-make
- popd > /dev/null
-}
-
-# retrieve code from a GIT repository
-get-git() {
- # handle GIT source trees
- git-clone $1
- echo $1
-}
-
-# retrieve code from a SVN repository
-get-svn() {
- # handle subversion repositories
- progress "svn co $1 $2" "Retrieving file"
- do-make $2
-}
-
-# retrieve a tarball
-get-url() {
- # handle normal installers (tarballs)
- progress-file "$1" "Retrieving file"
- progress "tar xvf $FILENAME" "Extracting archive contents"
- dir="$(echo $FILENAME | sed "s|\.tar\..*||g")"
- do-make "$dir"
-}
-
-# retrieve a file in ZIP archive format
-get-zip() {
- # handle zip files
- progress-file "$1" "Retrieving file"
-
- # unzip only *.zip, if desired
- if [ "$UNZIP" ]; then
- progress "unzip -au $FLAT *.zip" "Extracting files"
- # otherwise, unzip whatever file was downloaded
- else
- file=$(echo $1 | sed "s|.*/||g")
- progress "unzip -au $FLAT $file" "Extracting files"
- fi
-
- inf
-}
-
-# retrieve a zip file, extract the extracted files, then unshield the CABs
-get-zip-cab-unsh() {
- INF_TEMP="$INF"
- INF=""
- # get file and unzip
- get-zip "$1"
- # cabextract all files
- progress "cabextract $(find . -name *.exe)" "Extracting CAB files"
- # unshield CAB files
- progress "unshield x $(find . -name *.cab)" "Unshielding InstallShield files"
- # install driver
- INF="$INF_TEMP"
-
- inf
-}
-
-# unzip and unshield
-get-zip-unsh() {
- INF_TEMP="$INF"
- INF=""
- # get file and unzip
- get-zip "$1"
- # unshield CAB files
- progress "unshield x $(find . -name *.cab)" "Unshielding InstallShield files"
- # install driver
- INF="$INF_TEMP"
-
- inf
-}
-
-# perform 2 unzips
-get-zipzip() {
- FLAT_TEMP="$FLAT"
- INF_TEMP="$INF"
- UNZIP_TEMP="$UNZIP"
-
- # unzip first file, but don't install the driver
- INF=""
- get-zip "$1"
- INF="$INF_TEMP"
-
- # unzip the newly-created zips
- FLAT=""
- UNZIP="yes"
- get-zip "$1"
- UNZIP="$UNZIP_TEMP"
- FLAT="$FLAT_TEMP"
-}
-
-install-ndis(){
- # see if the ndiswrapper utility exists
- which ndiswrapper > /dev/null
- NDIS_FOUND=$?
-
- if [ $NDIS_FOUND -eq 0 ]; then
- NDIS_INFO=$(ndiswrapper -v | grep "^version:" | grep -o "[.0-9]*$")
- UPDATE=$(expr $NDIS_INFO '<' $CUR_VER)
- # if the version is new enough, don't compile
- [ $UPDATE -eq 0 ] && return
- fi
-
- # retrieve and unpack source
- rm $DONE_MARKER
- ARCH="ndiswrapper.tar.gz"
- progress-file "http://prdownloads.sourceforge.net/ndiswrapper/ndiswrapper-${CUR_VER}.tar.gz" "Retrieving NDISwrapper source code" "$ARCH"
- # unpackage-ndis ndiswrapper-*
- progress "tar xvf $ARCH" "Extracting NDISwrapper source code"
-
- # compile and install NDISwrapper
- pushd ndiswrapper-* > /dev/null
- progress "make uninstall" "Uninstalling old NDISwrapper files"
- progress "make" "Compiling NDISwrapper"
- progress "make install" "Installing NDISwrapper"
- popd > /dev/null
-}
-
-# install driver using INF file
-inf() {
- install-ndis
- NDIS_DRIVER=$(echo $INF|sed "s|.*/||g")
- NDIS_DRIVER="${NDIS_DRIVER%.inf}"
-
- if [ "$INF" ]; then
- progress "ndiswrapper -e" "$NDIS_DRIVER" "Removing old driver"
- progress "ndiswrapper -i" "$INF" "Installing driver"
- progress "ndiswrapper -ma" "Configuring NDISwrapper"
- progress "modprobe ndiswrapper" "Inserting ndiswrapper module"
- fi
-
- # blacklist the necessary kernel modules
- ndiswrapper -l | grep -o "alternate driver:.*$" | sed "s|^.* \(.*\))$|blacklist \1|g" > $BLACKLIST_FILE
-}
-
-# insert kernel modules
-insert-modules() {
- # use explicitly-specified modules by default
- if [ "$MODULES" ]; then
- for module in "$MODULES"; do
- progress "modprobe -v $module" "Inserting $module module"
- done
- # otherwise, insert whatever modules are available in $(pwd)
- else
- for module in $(ls *.ko); do
- module="${module%.ko}"
- progress "modprobe -v $module" "Inserting $module module"
- done
- fi
-}
-
-# show a progress monitor while performing a certain task
-progress() {
- if [ "$3" ]; then
- $1 "$2" | tee -a $LOG | zenity --progress --pulsate --auto-close --auto-kill --text="$3..."
- else
- $1 | tee -a $LOG | zenity --progress --pulsate --auto-close --auto-kill --text="$2..."
- fi
-
- if [ $PIPESTATUS -ne 0 ]; then
- message "Installer failed at $2. See $LOG for more details."
- exit 1
- fi
-}
-
-# retrieve a file, showing a progress monitor
-progress-file() {
- # figure out what the name of the downloaded file will be
- if [ $3 ]; then
- FILENAME="$3"
- else
- FILENAME="$(echo $1 | sed 's|.*/||g')"
- fi
-
- # if the file was already downloaded, don't get it again
- if [ ! -f "$DONE_MARKER" ]; then
- $WGET -O "$FILENAME" "$1" 2>&1 | sed -u 's|.*\ \([0-9]\+%\)\ \+\([0-9.]\+\ [KMB\/s]\+\)$|\1\n# Downloading \2|' | tee -a $LOG | zenity --progress --auto-close --auto-kill --text="$2..."
- touch $DONE_MARKER
- if [ $PIPESTATUS -ne 0 ]; then
- message "Installer failed at $2. See $LOG for more details."
- exit 1
- fi
- fi
-}
-
-#############################
-# BEGINNING OF MAIN PROGRAM #
-#############################
-
-ensure-program "xmessage" "zenity"
-
-BLACKLIST_FILE="/etc/modprobe.d/blacklist-wifix.conf"
-DATE_STR="$(date +%s-%F)"
-DONE_MARKER="./.done-downloading"
-LOG="/var/log/wifix-$DATE_STR"
-TEMP="/tmp/wifix/$DATE_STR"
-WGET="wget"
-
-# see if we're testing
-workdir="$(pwd)"
-if [ ! "${workdir%/tests}" = "$workdir" ]; then
- TESTING="yes"
- TEMP="/tmp/wifix/$(echo test$* | sed "s|[^a-zA-Z0-9]|-|g")"
- echo "***TESTING MODE ENABLED***"
- echo "***temporary directory: $TEMP"
-fi
-
-# process arguments
-while [ ! "$*" = "" ]; do
- case "$1" in
- ("-cab")
- # retrieve source code from CAB file
- ensure-program "cabextract"
- append-command "get-cab $2"
- shift
- ;;
- ("-cab-unsh")
- # retrieve source code from CAB file and unshield as necessary
- ensure-program "cabextract" "unshield"
- append-command "get-cab-unsh $2"
- shift
- ;;
- ("-cvs")
- # retrieve source code using CVS program
- ensure-program "cvs"
- append-command "get-cvs $2 $3 $4"
- shift 3
- ;;
- ("-dir")
- # use alternate directory for building
- DIR="$2"
- shift
- ;;
- ("-firmware")
- # copy firmware files from make directory
- FIRMWARE="$2"
- shift
- ;;
- ("-flat")
- # don't recreate ZIP structure
- FLAT="-j"
- ;;
- ("-git")
- # retrieve source code using GIT program
- ensure-program "git"
- append-command "get-git $2"
- shift
- ;;
-
- ("-inf")
- # use the given INF file
- ensure-program "gcc"
- INF="$2"
- shift
- ;;
- ("-module")
- # specify kernel modules to be inserted
- ensure-program "modprobe"
- MODULES="$(echo $2 | sed 's|,| |g')"
- shift
- ;;
- ("-ndis")
- # sets the ndiswrapper version
- CUR_VER="$2"
- shift
- ;;
- ("-strip")
- # strips debugging information from kernel modules
- ensure-program "strip"
- STRIP="yes"
- ;;
- ("-svn")
- # retrieve source code using Subversion
- ensure-program "svn"
- append-command "get-svn $2 $3"
- shift 2
- ;;
- ("-url")
- # retrieve a compressed tarball
- ensure-program "wget"
- append-command "get-url $2"
- shift
- ;;
- ("-unzip")
- # force "unzip -a *.zip"
- UNZIP="yes"
- ;;
- ("-zip")
- # retrieve a zip file
- ensure-program "unzip"
- append-command "get-zip $2"
- shift
- ;;
- ("-zip-cab-unsh")
- # retrieve a zip file and uncab/unshield as necessary
- ensure-program "cabextract" "unshield" "unzip"
- append-command "get-zip-cab-unsh $2"
- shift
- ;;
- ("-zip-unsh")
- # retrieve a zip file and uncab/unshield as necessary
- ensure-program "unshield" "unzip"
- append-command "get-zip-unsh $2"
- shift
- ;;
- ("-zipzip")
- # retrieve a zip file
- ensure-program "unzip"
- append-command "get-zipzip $2"
- shift
- ;;
- (*):
- echo "Invalid argument: $1"
- exit 1
- esac
-
- shift
-done
-
-if [ "$INF" ]; then
- if [ ! "$CUR_VER" ]; then
- message "NDISwrapper version not specified; cannot install driver."
- exit 0
- fi
-fi
-
-# create temporary directory and change into it
-mkdir -p $TEMP
-pushd $TEMP > /dev/null
-
-# execute all commands in the $COMMANDS array
-index=0
-if [ "$COMMAND_INDEX" ]; then
- while [ "$index" -lt "$COMMAND_INDEX" ]; do
- ${COMMANDS[$index]}
- let "index = $index + 1"
- done
-
- message "Installation was successful!"
-else
- message "Nothing to do; exiting."
-fi
-
-# return to previous directory
-popd > /dev/null
=== removed directory 'src/messages'
=== removed file 'src/messages.py'
--- src/messages.py 2010-08-10 05:36:45 +0000
+++ src/messages.py 1970-01-01 00:00:00 +0000
@@ -1,36 +0,0 @@
-#!/bin/python
-# Author: bmartin (blakecmartin@xxxxxxxxx)
-
-"""
-This file is part of WiFix.
-
-WiFix is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-WiFix is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-"""
-
-err_root = "Please run the installer without root priviledges."
-submitted = "Wifix was unable to match a wireless device on this computer with any currently in the Wifix communitys Driver Database.\n\nThe Wifix Driver Database is a work in progress being built with the help of feedback from people like you. To help improve the database for everyone, please copy and paste the following information into an e-mail to wifi.feedback@xxxxxxxxx:\n\n"
-no_driver = "No driver information found on database.\nGathering debugging info"
-usage = "USAGE:\twifix [ ARGS ]\n\nARGS:\n\t--help\tShow this usage\n\t--gtk\tUse GTK interface\n\t--qt\tUse QT interface\n\t--text\tUse text interface\n"
-
-def privacy():
- return __read_file('./messages/privacy')
-
-def submission():
- return __read_file('./messages/submission')
-
-def __read_file(file):
- f = open(file, 'r')
- contents = f.read()
- f.close()
- return contents
=== removed file 'src/messages/privacy'
--- src/messages/privacy 2010-08-09 21:53:11 +0000
+++ src/messages/privacy 1970-01-01 00:00:00 +0000
@@ -1,5 +0,0 @@
-TERMS OF USE:
-
-The Wifix software queries the Wifix database to determine the appropriate driver(s) for your hardware. To do this vendor and device IDs from network devices on your system will be submitted to our database. No personally identifiable information is collected. We use this information in order to better serve you and everyone who runs Wifix in the future.
-
-By clicking Yes, you agree to these terms and conditions.
=== removed file 'src/messages/submission'
--- src/messages/submission 2010-08-09 21:14:11 +0000
+++ src/messages/submission 1970-01-01 00:00:00 +0000
@@ -1,5 +0,0 @@
-Your wireless adaptor was detected, but we couldn't locate the appropriate driver in our database. We would like to add your adaptor information to our database so that we may locate the appropriate driver. When this is completed it will also enable all WiFix users with this same adaptor to install the appropriate driver.
-
-The only information that will be sent is the vendor id and device id of your wireless adaptor. No personal information will be taken or passed to any third party.
-
-If you would like to help us by submitting your adaptor's information, press the Submit button below. Otherwise, press Exit and no information will be sent.
=== removed file 'src/platforms.py'
--- src/platforms.py 2010-08-07 02:49:54 +0000
+++ src/platforms.py 1970-01-01 00:00:00 +0000
@@ -1,236 +0,0 @@
-#!/usr/bin/python
-# Author: bmartin (blakecmartin@xxxxxxxxx)
-# Author: Buran Ayuthia (the.ayuthias@xxxxxxxxx)
-
-"""
-This file is part of WiFix.
-
-WiFix is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-WiFix is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-"""
-
-# The idea here is to polymorphically run commands depending on which operating
-# system is detected (e.g., BSD, Linux).
-
-import commands
-import httplib
-import os
-import string
-import sys
-import urllib
-import time
-
-import messages
-
-class __Platform:
- """
- Provides an interface for OS-dependent calls.
- """
-
- def execute(self, command):
- """
- Executes the given command within a terminal. All output resulting from
- executing the given command should be displayed in the terminal.
- """
-
- raise NotImplementedError
-
- def get_devices(self):
- """
- Retrieves a listing of all PCI IDs of network devices on the computer.
- """
-
- raise NotImplementedError
-
- def get_installer_command(self, arguments):
- """
- Retrives the command to run the installer with the given arguments.
- """
-
- raise NotImplementedError
-
- def has_display(self):
- """
- Returns True if a display is available; False otherwise.
- """
-
- raise NotImplementedError
-
- def is_root(self):
- """
- Returns True if the current process is being executed with elevated
- privileges, False otherwise.
- """
-
- raise NotImplementedError
-
- def message(self, message):
- """
- Displays a message to the user.
- """
-
- raise NotImplementedError
-
- def message_yesno(self, message):
- """
- Displays a yes/no message to the user.
- """
-
- raise NotImplementedError
-
- def __get_pci_devices(self):
- """
- Retrieves a listing of PCI IDs of all PCI network devices on the
- computer.
- """
-
- raise NotImplementedError
-
- def __get_usb_devices(self):
- """
- Retrieves a listing of USB IDs of all USB network devices on the
- computer.
- """
-
- raise NotImplementedError
-
-class PlatformLinux(__Platform):
- """
- OS-specific calls for the Linux implementation.
- """
- def get_debug_info (self, pm):
- pci_devices = []
- usb_devices = []
- device_label = []
-
- # retrieve PCI networking devices
- pm.start("Gathering info", messages.no_driver)
- for pci_device in self.__get_pci_devices():
- device_label.append(commands.getoutput('lspci -nn | grep ' + pci_device + ' | sed "s|.*: ||g"'))
-
- # retrieve USB devices
- for usb_device in self.__get_usb_devices():
- device_label.append(usb_device)
-
- #build the timestamp (yyyymmddhhmmss)
- y = str(time.localtime ()[0])
- m = str(time.localtime ()[1]).zfill (2)
- d = str(time.localtime ()[2]).zfill (2)
- h = str(time.localtime ()[3]).zfill (2)
- mi = str(time.localtime ()[4]).zfill (2)
- s = str(time.localtime ()[5]).zfill (2)
- timestamp = y + m + d + h + mi + s
- pm.stop()
-
- return timestamp + '\n' + string.join(device_label, '\n')
-
- def get_devices(self, pm):
- options_list = []
- pci_devices = []
- usb_devices = []
- device_label = dict()
-
- # retrieve PCI networking devices
- pm.start("Gathering devices", "Searching for PCI adaptors")
- for pci_device in self.__get_pci_devices():
- pci_devices.append(pci_device + ".P")
- device_label[pci_device] = commands.getoutput('lspci -nn | grep ' + pci_device + ' | sed "s|.*: ||g"')
- pm.stop()
-
- # retrieve USB networking devices
- pm.start("Gathering devices", "Searching for USB adaptors")
- for usb_device in self.__get_usb_devices():
- usb_devices.append(usb_device + ".U")
- device_label[usb_device] = commands.getoutput('lsusb | grep ' + usb_device + ' | sed "s|.*: ID ||g"')
- pm.stop()
-
- devices = string.join(pci_devices, ';') + ";" + string.join(usb_devices, ';')
- params = urllib.urlencode({'cards': devices})
- headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
-
- # Call PHP page to retrieve available drivers
- pm.start("Querying database", "Fetching driver information from database")
- try:
- die = False
- conn = httplib.HTTPConnection("wifix.sourceforge.net:80")
- conn.request("POST", "/get-driver.php", params, headers)
- response = conn.getresponse()
- data = response.read()
- # TODO might want to do something with response.status, response.reason
- except Error, description:
- self.message("Unable to connect to database: " + description)
- die = True
- finally:
- conn.close()
- pm.stop()
- if die:
- sys.exit()
-
- card = dict()
-
- for line in data.split("<br>"):
- # find the first "=" in the string
- index = line.find("=")
- if (index == -1):
- # no "=" present; not driver info
- if card.has_key('arguments'):
- # add card info to list
- if card['arguments'] != "":
- card['label'] = device_label[card['id'][0:9]]
- options_list.append(card)
- card = dict()
- else:
- # add key:value pair
- key=line[0:index]
- value=line[index + 1:]
- card[key] = value
- return options_list
-
- def get_installer_command(self, arguments):
- args = arguments.split(';')
- arguments = string.join(args, ' ')
- return 'bash linux-install-wifi ' + arguments
-
- def __get_pci_devices(self):
- wifi_pci = commands.getoutput('d="[0-9a-f]" ; pci_id="$d$d$d$d":"$d$d$d$d" ; p="[0-9]" ; bus="$p$p:$p$p\.$p" ; pcis=$(lshw -C network | grep "bus info: pci@" | grep -o "$bus") ; lspci -nn | grep -F "$pcis" | grep -o "$pci_id"')
- # skip line 0 (lshw su warning) to only return actual devices)
- return wifi_pci.splitlines()[1:]
-
- def __get_usb_devices(self):
- wifi_usb = commands.getoutput('d="[0-9a-f]" ; pci_id="$d$d$d$d":"$d$d$d$d" ; lsusb | grep -o "${pci_id}" | grep -v "0000:0000"')
- return wifi_usb.splitlines()
-
- def is_root(self):
- return not os.system('[ $(id -u) = 0 ]')
-
- def message(self, message):
- return os.system("zenity --info --text='" + message + "'")
-
- def message_yesno(self, message):
- return os.system("zenity --question --text='" + message + "'") == 0
-
- def has_display(self):
- if (commands.getoutput('echo $DISPLAY') != ""):
- return True
- else:
- return False
-
- def execute(self, command):
- return os.system(command)
-
-class PlatformBSD(__Platform):
- """
- OS-specific calls for the BSD implementation.
- """
-
- pass
=== removed file 'src/pm.py'
--- src/pm.py 2008-01-08 11:54:34 +0000
+++ src/pm.py 1970-01-01 00:00:00 +0000
@@ -1,46 +0,0 @@
-#!/usr/bin/python
-# Author: bmartin (blakecmartin@xxxxxxxxx)
-
-"""
-This file is part of WiFix.
-
-WiFix is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-WiFix is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-"""
-
-import os
-import subprocess
-
-class ProgressMonitor():
- def start(self, title, message):
- """
- Causes the progress monitor to pulsate.
- """
-
- self.p1 = subprocess.Popen(["/bin/cat", "/dev/zero"], stdout=subprocess.PIPE)
- self.p2 = subprocess.Popen(["zenity", "--progress", "--pulsate", "--text=" + message, "--title=" + title], stdin=self.p1.stdout, stdout=subprocess.PIPE)
- self.pid1 = self.p1.pid
- self.pid2 = self.p2.pid
-
- def stop(self):
- """
- Causes the progress monitor to disappear.
- """
-
- # kill the thread that feeds the pipe into zenity
- os.kill(self.pid1, 1)
- # kill the zenity thread
- os.kill(self.pid2, 1)
- # wait for the threads to finish
- self.p1.wait()
- self.p2.wait()
=== removed file 'src/wifix.py'
--- src/wifix.py 2010-08-10 05:36:45 +0000
+++ src/wifix.py 1970-01-01 00:00:00 +0000
@@ -1,135 +0,0 @@
-#!/usr/bin/python
-# Author: Buran Ayuthia (the.ayuthias@xxxxxxxxx)
-# Author: bmartin (blakecmartin@xxxxxxxxx)
-
-"""
-This file is part of WiFix.
-
-WiFix is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-WiFix is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-"""
-
-import sys
-
-import messages
-import platforms
-
-def show_usage():
- print messages.usage
- sys.exit()
-
-def check_sanity(platform, ui):
- # ensure the program isn't being run as root
- if platform.is_root():
- platform.message(messages.err_root)
- return False
- # ensure all necessary programs for the UI exist
- if not ui.check_programs():
- platform.message(messages.err_programs)
- return False
-
- return True
-
-def display_privacy_notice(platform):
- if not platform.message_yesno(messages.privacy()):
- sys.exit()
-
-def get_platform():
- if sys.platform.startswith("linux"):
- return platforms.PlatformLinux()
- else:
- print "The " + sys.platform + " platform is not supported by WiFix."
- sys.exit();
-
-def get_ui():
- try:
- import wifixui_gtk
- ui = wifixui_gtk.GraphicalUI(platform)
- # perform checks to ensure the program can work properly
- if check_sanity(platform, ui):
- return ui
- except Exception, detail:
- print "Unable to use GTK interface:", detail
-
- try:
- import wifixui_qt
- ui = wifixui_qt.GraphicalUI(platform)
- # perform checks to ensure the program can work properly
- if check_sanity(platform, ui):
- return ui
- except Exception, detail:
- print "Unable to use Qt interface:", detail
-
- try:
- import wifixui_text
- ui = wifixui_text.UI(platform)
- # perform checks to ensure the program can work properly
- if check_sanity(platform, ui):
- return ui
- except Exception, detail:
- print "Unable to use text interface:", detail
-
- raise Exception("No UI available.")
-
-# make sure we have an implementation for the given platform
-platform = get_platform()
-
-ui = None
-
-# process command-line parameters
-del sys.argv[0]
-
-while len(sys.argv) > 0:
- arg=sys.argv[0]
- del sys.argv[0]
- if arg == "--help":
- show_usage()
- elif arg == "--gtk":
- import wifixui_gtk
- ui = wifixui_gtk.GraphicalUI(platform)
- elif arg == "--qt":
- import wifixui_qt
- ui = wifixui_qt.GraphicalUI(platform)
- elif arg == "--text":
- import wifixui_text
- ui = wifixui_text.UI(platform)
- else:
- print "Invalid parameter:", arg
- show_usage()
-
-# figure out which UI we're going to use
-if not ui:
- ui = get_ui()
-else:
- if not check_sanity(platform, ui):
- raise Exception("Unable to use desired interface.")
-display_privacy_notice(platform)
-
-#######################################################################
-### now that the platform and UI have been determined, we can begin ###
-#######################################################################
-
-import commands
-import messages
-#import webbrowser
-
-# retrieve the driver information from the database
-options_list = platform.get_devices(ui.get_progress_meter())
-radio = ui.build_radio(options_list)
-
-if not radio:
- debug_info = platform.get_debug_info(ui.get_progress_meter())
- platform.message(messages.submitted + debug_info)
- sys.exit()
-
-ui.start(radio)
=== removed file 'src/wifixui.py'
--- src/wifixui.py 2008-01-08 11:53:41 +0000
+++ src/wifixui.py 1970-01-01 00:00:00 +0000
@@ -1,73 +0,0 @@
-#!/usr/bin/python
-# Author: bmartin (blakecmartin@xxxxxxxxx)
-
-"""
-This file is part of WiFix.
-
-WiFix is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-WiFix is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-"""
-
-import os
-
-class WifixUI():
- def check_dependencies(self):
- """
- Ensures that all dependent programs exist.
- """
-
- raise NotImplementedError
-
- def check_programs(self):
- """
- Returns True if all of the necessary programs are present, false
- otherwise.
- """
-
- raise NotImplementedError
-
- def get_dependencies(self):
- """
- Retrieves a list of programs that must exist in order to use this UI.
- """
-
- def get_progress_meter(self):
- """
- Retrieves a progress meter for the UI.
- """
-
- raise NotImplementedError
-
- def program_exists(self, program):
- """
- Returns True if the given program exists, false otherwise.
- """
-
- if os.system("which " + program + " > /dev/null"):
- raise Exception(program + ", a necessary program, was not found")
- return True
-
- def sudo(self, title, command):
- """
- Returns a command string that, if executed, will perform the given
- command with elevated provileges.
- """
-
- raise NotImplementedError
-
- def start(self, options_list):
- """
- Begins execution of the UI.
- """
-
- raise NotImplementedError
=== removed file 'src/wifixui_gtk.py'
--- src/wifixui_gtk.py 2008-01-31 23:01:38 +0000
+++ src/wifixui_gtk.py 1970-01-01 00:00:00 +0000
@@ -1,128 +0,0 @@
-#!/usr/bin/python
-# Author: Buran Ayuthia (the.ayuthias@xxxxxxxxx)
-# Author: bmartin (blakecmartin@xxxxxxxxx)
-
-"""
-This file is part of WiFix.
-
-WiFix is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-WiFix is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-"""
-
-import pm
-import wifixui
-
-import gtk
-
-class GraphicalUI(wifixui.WifixUI):
- def check_programs(self):
- return self.program_exists("echo") and self.program_exists("gksudo") and self.program_exists("grep") and self.program_exists("id") and self.program_exists("lshw") and self.program_exists("lspci") and self.program_exists("lsusb") and self.program_exists("sed") and self.program_exists("zenity")
-
- def run_installer(self, widget):
- self.platform.execute(self.perform)
- self.close_application(widget)
-
- def sudo(self, title, command):
- return "gksudo --message '" + title + "' '" + command + "'"
-
- def use_command(self, radiobutton, val):
- if radiobutton.get_active():
- self.perform = val
-
- def close_application(self, widget):
- gtk.main_quit()
-
- def build_radio(self, options_list):
- radio = []
- radio_anchor = gtk.RadioButton(None, "")
- for option in options_list:
- label = option['label']
- driver = option['driver']
- arguments = option['arguments']
- if arguments.find(' -inf ') != -1:
- driver_type='Windows/NDIS'
- else:
- driver_type='compiled from source'
- install_msg = label + '\nDriver: ' + driver + ' (' + driver_type + ')'
- radio_button = gtk.RadioButton(radio_anchor, install_msg)
- radio_button.connect("toggled", self.use_command, self.sudo("Run installer", self.platform.get_installer_command(arguments)))
- radio.append(radio_button)
- return radio
-
- def get_progress_meter(self):
- return pm.ProgressMonitor()
-
- def start(self, radio):
- for radio_button in radio:
- self.vbox.pack_start(radio_button, False, True, 0)
- radio_button.show()
-
- radio[0].set_active(True)
- self.textbuffer.set_text("Welcome to WiFix!!!!")
- separator = gtk.HSeparator()
- self.box1.pack_start(separator, False, True, 0)
- separator.show()
-
- self.box2 = gtk.VBox(False, 10)
- self.box2.set_border_width(10)
- self.box1.pack_start(self.box2, False, True, 0)
- self.box2.show()
-
- button = gtk.Button("Install")
- button.connect("clicked", self.run_installer)
- self.box2.pack_start(button, True, True, 0)
- button.set_flags(gtk.CAN_DEFAULT)
- button.grab_default()
- button.show()
- self.window.show()
- gtk.main()
-
- def __init__(self, platform):
- self.platform = platform
- self.device_info=''
- self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
- self.window.set_resizable(True)
- self.window.connect("destroy", self.close_application)
- self.window.set_title("WiFix Wireless Driver Installer")
- self.window.set_border_width(0)
-
- self.box1 = gtk.VBox(False, 0)
- self.window.add(self.box1)
- self.box1.show()
-
- self.box2 = gtk.VBox(False, 10)
- self.box2.set_border_width(10)
- self.box1.pack_start(self.box2, True, True, 0)
- self.box2.show()
-
- sw = gtk.ScrolledWindow()
- sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
- textview = gtk.TextView()
- textview.set_editable(False)
- textview.set_cursor_visible(False)
- textview.set_wrap_mode(gtk.WRAP_WORD)
-
- self.textbuffer = textview.get_buffer()
- sw.add(textview)
- sw.show()
- textview.show()
-
- self.box2.pack_start(sw)
-
- hbox = gtk.HButtonBox()
- self.box2.pack_start(hbox, False, False, 0)
- hbox.show()
-
- self.vbox = gtk.VBox()
- self.vbox.show()
- hbox.pack_start(self.vbox, False, False, 0)
=== removed file 'src/wifixui_qt.py'
--- src/wifixui_qt.py 2008-01-31 23:01:38 +0000
+++ src/wifixui_qt.py 1970-01-01 00:00:00 +0000
@@ -1,109 +0,0 @@
-#!/usr/bin/python
-# Author: Buran Ayuthia (the.ayuthias@xxxxxxxxx)
-# Author: bmartin (blakecmartin@xxxxxxxxx)
-
-"""
-This file is part of WiFix.
-
-WiFix is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-WiFix is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-"""
-
-from PyQt4.QtCore import SIGNAL, SLOT
-from PyQt4.QtGui import QApplication, QWidget, QTextEdit, QGridLayout, QPushButton, QRadioButton
-import wifixui
-
-import os
-import sys
-
-import messages
-import platforms
-import pm
-import threading
-import commands
-import webbrowser
-
-global app
-app = QApplication(sys.argv)
-
-class GraphicalUI(wifixui.WifixUI, QWidget):
- def build_radio(self, options_list):
- radio = []
-
- for option in options_list:
- label = option['label']
- driver = option['driver']
- arguments = option['arguments']
- driver_type='compiled from source'
- if arguments.find(' -inf ') != -1:
- driver_type='Windows/NDIS'
- install_msg = label + '\nDriver: ' + driver + ' (' + driver_type + ')'
- radio_button = QRadioButton(install_msg, self)
- self.arg_list = self.platform.get_installer_command(arguments)
-# self.arg_list.append(radio_button)
- radio_button.connect(radio_button, SIGNAL("toggled(bool)"), self.use_command)
- radio.append(radio_button)
-
- return radio
-
- def check_programs(self):
- return self.program_exists("echo") and self.program_exists("grep") and self.program_exists("id") and self.program_exists("kdesu") and self.program_exists("lshw") and self.program_exists("lspci") and self.program_exists("lsusb") and self.program_exists("sed") and self.program_exists("zenity")
-
- def close_application(self):
- self.close()
-
- def get_progress_meter(self):
- return pm.ProgressMonitor()
-
- def run_installer(self):
- self.platform.execute(self.perform)
- self.close_application()
-
- def start(self, radio):
- row = 0
- self.MainLayout.setSpacing(10)
- self.MainLayout.addWidget(self.TextMsg, row, 0)
- row += 1
- for radio_button in radio:
- self.MainLayout.addWidget(radio_button, row, 0)
- radio_button.show()
- row += 1
- radio[0].setChecked(True)
-
- self.Button = QPushButton("Install", self)
- self.Button.connect(self.Button, SIGNAL("clicked()"), self.run_installer)
- self.MainLayout.addWidget(self.Button, row, 0)
-
- self.show()
- sys.exit(app.exec_())
-
- def sudo(self, title, command):
- return "kdesu -c '" + command + "' --caption '" + title + "'"
-
- def use_command(self):
- val = self.arg_list
- self.perform = self.sudo("Run installer", val)
-
- def __init__(self, platform):
- self.platform = platform
- QWidget.__init__(self)
-
- self.device_info = ''
-
- self.setWindowTitle("WiFix Wireless Driver Installer")
-
- self.MainLayout = QGridLayout(self)
-
- self.TextMsg = QTextEdit(self)
- self.TextMsg.setReadOnly(True)
- self.TextMsg.setText("Welcome to WiFix!!!!")
=== removed file 'src/wifixui_text.py'
--- src/wifixui_text.py 2008-01-08 11:53:41 +0000
+++ src/wifixui_text.py 1970-01-01 00:00:00 +0000
@@ -1,41 +0,0 @@
-#!/usr/bin/python
-# Author: Buran Ayuthia (the.ayuthias@xxxxxxxxx)
-# Author: bmartin (blakecmartin@xxxxxxxxx)
-
-"""
-This file is part of WiFix.
-
-WiFix is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-WiFix is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see <http://www.gnu.org/licenses/>.
-"""
-
-import wifixui
-
-class TextUI(wifixui.WifixUI):
- def run_installer(self, widget):
- print "TODO implement wifixtext.run_installer"
-
- def use_command(self, radiobutton, val):
- print "TODO implement wifixtext.use_command"
-
- def close_application(self, widget):
- print "TODO implement wifixtext.close_application"
-
- def submit_card_data(self, data=None):
- print "TODO implement wifixtext.submit_card_data"
-
- def build_radio(self):
- print "TODO implement wifixtext.build_radio"
-
- def __init__(self):
- print "TODO work on text interface"
=== removed file 'wifix'
--- wifix 2007-09-30 11:38:31 +0000
+++ wifix 1970-01-01 00:00:00 +0000
@@ -1,22 +0,0 @@
-#!/bin/bash
-# Author: bmartin (blakecmartin@xxxxxxxxx)
-
-####################
-# This file is part of WiFix.
-#
-# WiFix is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# WiFix is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-####################
-
-cd src
-python wifix.py
=== added file 'wifix.py'
--- wifix.py 1970-01-01 00:00:00 +0000
+++ wifix.py 2010-08-14 10:39:40 +0000
@@ -0,0 +1,135 @@
+#!/usr/bin/python
+# Author: Buran Ayuthia (the.ayuthias@xxxxxxxxx)
+# Author: bmartin (blakecmartin@xxxxxxxxx)
+
+"""
+This file is part of WiFix.
+
+WiFix is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WiFix is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
+
+import sys
+
+import messages
+import platforms
+
+def show_usage():
+ print messages.usage
+ sys.exit()
+
+def check_sanity(platform, ui):
+ # ensure the program isn't being run as root
+ if platform.is_root():
+ platform.message(messages.err_root)
+ return False
+ # ensure all necessary programs for the UI exist
+ if not ui.check_programs():
+ platform.message(messages.err_programs)
+ return False
+
+ return True
+
+def display_privacy_notice(platform):
+ if not platform.message_yesno(messages.privacy()):
+ sys.exit()
+
+def get_platform():
+ if sys.platform.startswith("linux"):
+ return platforms.PlatformLinux()
+ else:
+ print "The " + sys.platform + " platform is not supported by WiFix."
+ sys.exit();
+
+def get_ui():
+ try:
+ import wifixui_gtk
+ ui = wifixui_gtk.GraphicalUI(platform)
+ # perform checks to ensure the program can work properly
+ if check_sanity(platform, ui):
+ return ui
+ except Exception, detail:
+ print "Unable to use GTK interface:", detail
+
+ try:
+ import wifixui_qt
+ ui = wifixui_qt.GraphicalUI(platform)
+ # perform checks to ensure the program can work properly
+ if check_sanity(platform, ui):
+ return ui
+ except Exception, detail:
+ print "Unable to use Qt interface:", detail
+
+ try:
+ import wifixui_text
+ ui = wifixui_text.UI(platform)
+ # perform checks to ensure the program can work properly
+ if check_sanity(platform, ui):
+ return ui
+ except Exception, detail:
+ print "Unable to use text interface:", detail
+
+ raise Exception("No UI available.")
+
+# make sure we have an implementation for the given platform
+platform = get_platform()
+
+ui = None
+
+# process command-line parameters
+del sys.argv[0]
+
+while len(sys.argv) > 0:
+ arg=sys.argv[0]
+ del sys.argv[0]
+ if arg == "--help":
+ show_usage()
+ elif arg == "--gtk":
+ import wifixui_gtk
+ ui = wifixui_gtk.GraphicalUI(platform)
+ elif arg == "--qt":
+ import wifixui_qt
+ ui = wifixui_qt.GraphicalUI(platform)
+ elif arg == "--text":
+ import wifixui_text
+ ui = wifixui_text.UI(platform)
+ else:
+ print "Invalid parameter:", arg
+ show_usage()
+
+# figure out which UI we're going to use
+if not ui:
+ ui = get_ui()
+else:
+ if not check_sanity(platform, ui):
+ raise Exception("Unable to use desired interface.")
+display_privacy_notice(platform)
+
+#######################################################################
+### now that the platform and UI have been determined, we can begin ###
+#######################################################################
+
+import commands
+import messages
+#import webbrowser
+
+# retrieve the driver information from the database
+options_list = platform.get_devices(ui.get_progress_meter())
+radio = ui.build_radio(options_list)
+
+if not radio:
+ debug_info = platform.get_debug_info(ui.get_progress_meter())
+ platform.message(messages.submitted + debug_info)
+ sys.exit()
+
+ui.start(radio)
=== added file 'wifixui.py'
--- wifixui.py 1970-01-01 00:00:00 +0000
+++ wifixui.py 2010-08-14 10:39:40 +0000
@@ -0,0 +1,73 @@
+#!/usr/bin/python
+# Author: bmartin (blakecmartin@xxxxxxxxx)
+
+"""
+This file is part of WiFix.
+
+WiFix is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WiFix is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
+
+import os
+
+class WifixUI():
+ def check_dependencies(self):
+ """
+ Ensures that all dependent programs exist.
+ """
+
+ raise NotImplementedError
+
+ def check_programs(self):
+ """
+ Returns True if all of the necessary programs are present, false
+ otherwise.
+ """
+
+ raise NotImplementedError
+
+ def get_dependencies(self):
+ """
+ Retrieves a list of programs that must exist in order to use this UI.
+ """
+
+ def get_progress_meter(self):
+ """
+ Retrieves a progress meter for the UI.
+ """
+
+ raise NotImplementedError
+
+ def program_exists(self, program):
+ """
+ Returns True if the given program exists, false otherwise.
+ """
+
+ if os.system("which " + program + " > /dev/null"):
+ raise Exception(program + ", a necessary program, was not found")
+ return True
+
+ def sudo(self, title, command):
+ """
+ Returns a command string that, if executed, will perform the given
+ command with elevated provileges.
+ """
+
+ raise NotImplementedError
+
+ def start(self, options_list):
+ """
+ Begins execution of the UI.
+ """
+
+ raise NotImplementedError
=== added file 'wifixui_gtk.py'
--- wifixui_gtk.py 1970-01-01 00:00:00 +0000
+++ wifixui_gtk.py 2010-08-14 10:39:40 +0000
@@ -0,0 +1,128 @@
+#!/usr/bin/python
+# Author: Buran Ayuthia (the.ayuthias@xxxxxxxxx)
+# Author: bmartin (blakecmartin@xxxxxxxxx)
+
+"""
+This file is part of WiFix.
+
+WiFix is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WiFix is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
+
+import pm
+import wifixui
+
+import gtk
+
+class GraphicalUI(wifixui.WifixUI):
+ def check_programs(self):
+ return self.program_exists("echo") and self.program_exists("gksudo") and self.program_exists("grep") and self.program_exists("id") and self.program_exists("lshw") and self.program_exists("lspci") and self.program_exists("lsusb") and self.program_exists("sed") and self.program_exists("zenity")
+
+ def run_installer(self, widget):
+ self.platform.execute(self.perform)
+ self.close_application(widget)
+
+ def sudo(self, title, command):
+ return "gksudo --message '" + title + "' '" + command + "'"
+
+ def use_command(self, radiobutton, val):
+ if radiobutton.get_active():
+ self.perform = val
+
+ def close_application(self, widget):
+ gtk.main_quit()
+
+ def build_radio(self, options_list):
+ radio = []
+ radio_anchor = gtk.RadioButton(None, "")
+ for option in options_list:
+ label = option['label']
+ driver = option['driver']
+ arguments = option['arguments']
+ if arguments.find(' -inf ') != -1:
+ driver_type='Windows/NDIS'
+ else:
+ driver_type='compiled from source'
+ install_msg = label + '\nDriver: ' + driver + ' (' + driver_type + ')'
+ radio_button = gtk.RadioButton(radio_anchor, install_msg)
+ radio_button.connect("toggled", self.use_command, self.sudo("Run installer", self.platform.get_installer_command(arguments)))
+ radio.append(radio_button)
+ return radio
+
+ def get_progress_meter(self):
+ return pm.ProgressMonitor()
+
+ def start(self, radio):
+ for radio_button in radio:
+ self.vbox.pack_start(radio_button, False, True, 0)
+ radio_button.show()
+
+ radio[0].set_active(True)
+ self.textbuffer.set_text("Welcome to WiFix!!!!")
+ separator = gtk.HSeparator()
+ self.box1.pack_start(separator, False, True, 0)
+ separator.show()
+
+ self.box2 = gtk.VBox(False, 10)
+ self.box2.set_border_width(10)
+ self.box1.pack_start(self.box2, False, True, 0)
+ self.box2.show()
+
+ button = gtk.Button("Install")
+ button.connect("clicked", self.run_installer)
+ self.box2.pack_start(button, True, True, 0)
+ button.set_flags(gtk.CAN_DEFAULT)
+ button.grab_default()
+ button.show()
+ self.window.show()
+ gtk.main()
+
+ def __init__(self, platform):
+ self.platform = platform
+ self.device_info=''
+ self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
+ self.window.set_resizable(True)
+ self.window.connect("destroy", self.close_application)
+ self.window.set_title("WiFix Wireless Driver Installer")
+ self.window.set_border_width(0)
+
+ self.box1 = gtk.VBox(False, 0)
+ self.window.add(self.box1)
+ self.box1.show()
+
+ self.box2 = gtk.VBox(False, 10)
+ self.box2.set_border_width(10)
+ self.box1.pack_start(self.box2, True, True, 0)
+ self.box2.show()
+
+ sw = gtk.ScrolledWindow()
+ sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+ textview = gtk.TextView()
+ textview.set_editable(False)
+ textview.set_cursor_visible(False)
+ textview.set_wrap_mode(gtk.WRAP_WORD)
+
+ self.textbuffer = textview.get_buffer()
+ sw.add(textview)
+ sw.show()
+ textview.show()
+
+ self.box2.pack_start(sw)
+
+ hbox = gtk.HButtonBox()
+ self.box2.pack_start(hbox, False, False, 0)
+ hbox.show()
+
+ self.vbox = gtk.VBox()
+ self.vbox.show()
+ hbox.pack_start(self.vbox, False, False, 0)
=== added file 'wifixui_qt.py'
--- wifixui_qt.py 1970-01-01 00:00:00 +0000
+++ wifixui_qt.py 2010-08-14 10:39:40 +0000
@@ -0,0 +1,109 @@
+#!/usr/bin/python
+# Author: Buran Ayuthia (the.ayuthias@xxxxxxxxx)
+# Author: bmartin (blakecmartin@xxxxxxxxx)
+
+"""
+This file is part of WiFix.
+
+WiFix is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WiFix is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
+
+from PyQt4.QtCore import SIGNAL, SLOT
+from PyQt4.QtGui import QApplication, QWidget, QTextEdit, QGridLayout, QPushButton, QRadioButton
+import wifixui
+
+import os
+import sys
+
+import messages
+import platforms
+import pm
+import threading
+import commands
+import webbrowser
+
+global app
+app = QApplication(sys.argv)
+
+class GraphicalUI(wifixui.WifixUI, QWidget):
+ def build_radio(self, options_list):
+ radio = []
+
+ for option in options_list:
+ label = option['label']
+ driver = option['driver']
+ arguments = option['arguments']
+ driver_type='compiled from source'
+ if arguments.find(' -inf ') != -1:
+ driver_type='Windows/NDIS'
+ install_msg = label + '\nDriver: ' + driver + ' (' + driver_type + ')'
+ radio_button = QRadioButton(install_msg, self)
+ self.arg_list = self.platform.get_installer_command(arguments)
+# self.arg_list.append(radio_button)
+ radio_button.connect(radio_button, SIGNAL("toggled(bool)"), self.use_command)
+ radio.append(radio_button)
+
+ return radio
+
+ def check_programs(self):
+ return self.program_exists("echo") and self.program_exists("grep") and self.program_exists("id") and self.program_exists("kdesu") and self.program_exists("lshw") and self.program_exists("lspci") and self.program_exists("lsusb") and self.program_exists("sed") and self.program_exists("zenity")
+
+ def close_application(self):
+ self.close()
+
+ def get_progress_meter(self):
+ return pm.ProgressMonitor()
+
+ def run_installer(self):
+ self.platform.execute(self.perform)
+ self.close_application()
+
+ def start(self, radio):
+ row = 0
+ self.MainLayout.setSpacing(10)
+ self.MainLayout.addWidget(self.TextMsg, row, 0)
+ row += 1
+ for radio_button in radio:
+ self.MainLayout.addWidget(radio_button, row, 0)
+ radio_button.show()
+ row += 1
+ radio[0].setChecked(True)
+
+ self.Button = QPushButton("Install", self)
+ self.Button.connect(self.Button, SIGNAL("clicked()"), self.run_installer)
+ self.MainLayout.addWidget(self.Button, row, 0)
+
+ self.show()
+ sys.exit(app.exec_())
+
+ def sudo(self, title, command):
+ return "kdesu -c '" + command + "' --caption '" + title + "'"
+
+ def use_command(self):
+ val = self.arg_list
+ self.perform = self.sudo("Run installer", val)
+
+ def __init__(self, platform):
+ self.platform = platform
+ QWidget.__init__(self)
+
+ self.device_info = ''
+
+ self.setWindowTitle("WiFix Wireless Driver Installer")
+
+ self.MainLayout = QGridLayout(self)
+
+ self.TextMsg = QTextEdit(self)
+ self.TextMsg.setReadOnly(True)
+ self.TextMsg.setText("Welcome to WiFix!!!!")
=== added file 'wifixui_text.py'
--- wifixui_text.py 1970-01-01 00:00:00 +0000
+++ wifixui_text.py 2010-08-14 10:39:40 +0000
@@ -0,0 +1,41 @@
+#!/usr/bin/python
+# Author: Buran Ayuthia (the.ayuthias@xxxxxxxxx)
+# Author: bmartin (blakecmartin@xxxxxxxxx)
+
+"""
+This file is part of WiFix.
+
+WiFix is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+WiFix is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
+
+import wifixui
+
+class TextUI(wifixui.WifixUI):
+ def run_installer(self, widget):
+ print "TODO implement wifixtext.run_installer"
+
+ def use_command(self, radiobutton, val):
+ print "TODO implement wifixtext.use_command"
+
+ def close_application(self, widget):
+ print "TODO implement wifixtext.close_application"
+
+ def submit_card_data(self, data=None):
+ print "TODO implement wifixtext.submit_card_data"
+
+ def build_radio(self):
+ print "TODO implement wifixtext.build_radio"
+
+ def __init__(self):
+ print "TODO work on text interface"
Follow ups