122
122
##Stores the usb ids in a list
123
123
usb = self.process_pciids(outtext)
126
pcilist = usblist = None
128
# Try getting info from server
129
if opts.repo == 'auto' or opts.repo == 'remote':
131
pcilist = self.serverquery(pci)
132
usblist = self.serverquery(usb)
133
except ConnectionFailed:
134
logger.error('Failed to connect to server')
135
if opts.repo == 'auto':
136
logger.error('Trying local database')
138
# If we have nothing, either fail or try the local reposotory
139
if pcilist == None and usblist == None:
140
if opts.repo == 'remote':
141
raise ConnectionFailed('Unable to establish connection. Please either check your interent connection or download the local database from FIXME...')
143
pcilist = self.localquery(pci)
144
usblist = self.localquery(usb)
146
return pcilist, usblist
148
127
##Checks if the user has a pci card or a usb card, if he has both the program will ask card he wants to setup
149
128
##If he has neither the program will exit and tell him what pci card he has if he has one
150
129
#if pcicard != 'empty' and usbcard == 'empty':
172
151
#get_print_card_info()
154
def get_lists(self,pci,usb):
155
pcilist = usblist = None
157
# Try getting info from server
158
if opts.repo == 'auto' or opts.repo == 'remote':
160
pcilist = self.serverquery(pci)
161
usblist = self.serverquery(usb)
162
except ConnectionFailed:
163
logger.error('Failed to connect to server')
164
if opts.repo == 'auto':
165
logger.error('Trying local database')
167
# If we have nothing, either fail or try the local reposotory
168
if pcilist == None and usblist == None:
169
if opts.repo == 'remote':
170
raise ConnectionFailed('Unable to establish connection. Please either check your interent connection or download the local database from FIXME...')
173
pcilist = self.localquery(pci)
174
usblist = self.localquery(usb)
176
return pcilist, usblist
175
179
def process_pciids(self, output):
176
180
logger.debug('Starting process_pciids')
177
181
output = output.split("\n")
210
214
logger.debug('Done serverquery')
212
def localquery(self, devices_list,database):
216
def localquery(self, devices_list, database):
213
217
'''Looks if one of the ids in the devices list given as argument matches an entry in the database'''
215
219
logger.debug('Starting localquery')
223
line = line.split(';;;')
224
for pci in devices_list:
225
if line[0].strip() == pci[0]:
226
if line[1].strip() == pci[1]:
228
matches.insert(0,line)
238
logger.debug('Done localquery')
217
241
def selectdatabase(self, selection = None):
218
242
#find database file:
252
for i in inprogramdir:
255
databases.insert(0,os.path.split(os.path.abspath(sys.argv[0]))[0] + '/' + i)
257
databases.append(os.path.split(os.path.abspath(sys.argv[0]))[0] + '/' + i)
229
260
if 'database' in i:
230
databases.append(os.getcwd() + '/' + i)
232
for i in inprogramdir:
234
databases.append(os.path.split(os.path.abspath(sys.argv[0]))[0] + '/' + i)
262
databases.insert(0,os.getcwd() + '/' + i)
264
databases.append(os.getcwd() + '/' + i)
236
266
for i in intmpdir:
237
267
if 'database' in i:
238
databases.append(opts.tmp_dir + '/' + i)
269
databases.insert(0,opts.tmp_dir + '/' + i)
271
databases.append(opts.tmp_dir + '/' + i)
240
273
if len(databases) == 0:
241
274
raise DatabaseNotFound('No database found anywhere')
243
if selection != None:
244
return databases[selection]
246
276
if len(databases) > 1:
311
341
print '[*] Internet connection found, continuing installation'
314
343
def remove_old_drivers(self):
315
344
'''Removes existing wireless drivers.'''
316
345
print '[*] Removing Old Drivers:'
652
681
logger.addHandler(ch)
684
def grab_lists(pci,usb):
685
pcilist = usblist = None
687
# Try getting info from server
688
if opts.repo == 'auto' or opts.repo == 'remote':
690
pcilist = main.serverquery(pci)
691
usblist = main.serverquery(usb)
692
except ConnectionFailed:
693
logger.error('Failed to connect to server')
694
if opts.repo == 'auto':
695
logger.error('Trying local database')
697
# If we have nothing, either fail or try the local reposotory
698
if pcilist == None and usblist == None:
699
if opts.repo == 'remote':
700
logger.error('Unable to establish connection. Please either check your interent connection or download the local database from FIXME...')
706
database = main.selectdatabase(selection)
707
except DatabaseNotFound:
708
logger.error('No database found for local query. Please place a database file in either the current directory, the auto-ndis file directory or in ' + opts.tmp_dir)
710
if type(database) == type([]):
711
print 'Found these databases:'
712
for i,file in enumerate(database):
713
print ' [%s] %s' % (i+1,file)
716
selection = input('Please enter the number of the database to use\n')
719
if type(selection) == type(1) and selection <= len(database):
720
database = database[(selection-1)]
723
pcilist = main.localquery(pci,database)
724
usblist = main.localquery(usb,database)
728
return pcilist,usblist
656
730
if __name__ == '__main__':
657
731
print 'Welcome to auto-ndiswrapper %s' % (__version__, )
681
755
logger.error('Error occured, exiting')
758
pci, usb = main.get_card_id()
760
pcilist,usblist=grab_lists(pci,usb)
b'\\ No newline at end of file'