~nilsschlupp/auto-ndiswrapper/rewrite

« back to all changes in this revision

Viewing changes to main/auto-ndis.py

  • Committer: Gabriel Joel
  • Date: 2007-12-13 23:30:07 UTC
  • Revision ID: gabrieljoel@gmail.com-20071213233007-zk3bua2b5vd6h7i4
initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
# Auto-NDISwrapper
 
3
#
 
4
# This program is free software; you can redistribute it and/or
 
5
# modify it under the terms of the GNU General Public License
 
6
# as published by the Free Software Foundation; Version 2
 
7
# of the License.
 
8
 
 
9
import os
 
10
import commands
 
11
import sys
 
12
import string
 
13
import re
 
14
 
 
15
 
 
16
print "Auto-NDISwrapper 0.1"
 
17
 
 
18
#Gets the id of all the pci devices
 
19
outtext = commands.getoutput("lspci -n")
 
20
 
 
21
#Stores the pci ids in a list
 
22
L = outtext.split()
 
23
 
 
24
#Stores the ids of all the supported cards in a dictionary with the website where the driver is found
 
25
#Later on we will need something better than this as we will need to assoaciate also the preffered driver
 
26
D = {'14e4:4324':'http://www.actiontecsupport.com/files/Prism80211b2KXPDrivers.exe','0000:0000':'http://www.yahoo.com/'}
 
27
 
 
28
def searchcard(L,D):
 
29
        
 
30
        card = -1       
 
31
        #Looks if card is in the list of supported cards
 
32
        for item in L:
 
33
                if item in D:
 
34
                        card = item
 
35
                        return card
 
36
 
 
37
card = searchcard(L,D)
 
38
 
 
39
#This is thanks to mintwifi.py, GPL by the way
 
40
if card == -1:
 
41
        os.system("lspci | grep \"Network controller\" > /tmp/detected_wireless_devices")
 
42
        devices_file = open("/tmp/detected_wireless_devices")
 
43
        for device_item in devices_file.readlines():
 
44
                deviceArray = device_item.split()
 
45
                device = ' '.join(deviceArray[3:])
 
46
                pci_id_line = commands.getoutput("lspci -n | grep " + deviceArray[0]) 
 
47
                pci_id_array = pci_id_line.split()
 
48
                pci_id = ' '.join(pci_id_array[2:])     
 
49
                print "Sorry, card not yet supported by Auto-NDISwrapper but most likely there are other solutions"
 
50
                print "Save this output as it will help other people give you support"
 
51
                print "  -- " + device 
 
52
                print "      ==> PCI ID = " + pci_id
 
53
 
 
54
else:
 
55
        print "Card Supported"
 
56
        print "Fetching driver for card with pci id", card
 
57
        URL = D[card]
 
58
        os.system(string.join(("wget ",URL)))   
 
59
        Files = URL.split("/")
 
60
        #Will we need a elif for every compression format?
 
61
        if ".exe" in URL:
 
62
                os.system(string.join(("unzip",Files[-1])))
 
63
                Inf = os.system("ls -t")
 
64
                #This is a really ugly solution does anyone know of anything better
 
65
                if ".inf" in Inf
 
66
                        for item in Inf
 
67
                                if ".inf" in item
 
68
                                        os.system(string.join(("sudo ndiswrapper -i ",item)))
 
69
                                        os.system("ndiswrapper -l")
 
70
                                        os.system("sudo modeprobe ndiswrapper")         
 
71
                                        os.system("sudo ndiswrapper -m")