Create a data collection script using Python for Windows. The Python script will execute the DOS shell command, “netsh wlan show all” and parse the output to get all visible wifi SSIDs, MAC addresses, and signal strengths. Insert statements will need to be constructed to insert this information to two tables in a database.

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

import os
import re
import sys
import logging
import optparse
import MySQLdb
import subprocess

"""Script default configuration
DB_HOST = ''
DB_PORT = '3306'
DB_USER = 'wlanuser'
DB_PASS = 'wlanpass'
DB_NAME = 'wlandb'

class DB:
    """MySQL wrapper class
    def __init__(self, ahost = DB_HOST, aport = DB_PORT, auser = DB_USER, apasswd = DB_PASS, adb = DB_NAME):
       """Initialize database configuration
       self.conn = None = ahost
       self.port = aport
       self.user = auser
       self.passwd = apasswd
       self.db = adb

    def connect(self):
       """Connect to database
       self.conn = MySQLdb.connect(,port=int(self.port),user=self.user,passwd=self.passwd,db=self.db,use_unicode=True, charset="utf8")
    def cursor(self):
       """Get current cursor of database
            return self.conn.cursor()
       except (AttributeError, MySQLdb.OperationalError):
            return self.conn.cursor()

    def escape(self, str):
       """Returns escaped string
       if self.conn == None:
       return self.conn.escape_string(str)
    def query(self, sql):
       """Query database with SQL statement
            cursor = self.conn.cursor()
       except (AttributeError, MySQLdb.OperationalError):
            cursor = self.conn.cursor()
       return cursor

    def close(self):
       """Close connection
       if self.conn != None:

    def commit(self):
       """Manual commit database operation
def parse_command_line(argv):
    """Command line options parser for the script
    usage = "usage: %prog [options]"...
$63.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Python Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats