Question: Given that, when run, the console prints There has been an exception, identify the lines of code by line numbers and/or including the section of

  1. Given that, when run, the console prints There has been an exception, identify the lines of code by line numbers and/or including the section of code that could cause problems and what problems those could be.

This code cannot and will not actually run so you will have to analyze this file by sight

  1. Continuing to consider the code what steps would you take to determine which line (or lines) are causing the problem. Note that this flawed design was chosen for some reason, so you should both consider wholesale redesigns as well as ways to debug it while keeping the general structure as is. Descriptions of your solutions are sufficient but be sure that the description is detailed enough that I understand what your solutions are. Given that, when run, the console prints There has been an

# Code takes configuration input from a file, user input through the UI, and # live sensor data through a network socket connection. This input is then # combined via a forumla noted within the in-line comments and then written # to a persistent database. assume that any variables used are appropriately scoped and # initialized. def process_datapoint(): try: connectString = # I) Open, read the database connect string from, and close setup.cfg configFile = open("setup.cfg", "r") if configFile.mode == 'r': lineNo = 0 contents = configfile.readlines) while len(connectString) == 0: if configFile[lineNo][0, len(connectstring=")] "connectstring": connectString = configFile[lineNo][len("connectstring=")] configfile.close() # II) Read from the three sensor reading count textboxes sensor1Count = int(sensor1 CountBox.getText() sensor2 Count = int(sensor2 CountBox.getText() sensor 3Count = int(sensor 3CountBox.getText() # III) Grab the next datapoint from the sensor socket representing # the sum of sensor readings since the last readings S = socket.socket() s.connect((sensorAddress, port)) sumOf SensorReadings = int(s.recv(1024)) s.close() # IV) Calculate average of sensor sum over the three sensor reading # counts average = sumOf SensorReadings/(sensorCount + sensor 2 Count + sensor 3Count) # V) Connect to the database specified from the connect string conn = pyodbc.connect(connectString) # VI) Run the sensor data update stored procedure with all data cursor = conn.cursor() cursor.callproc('spUpdateSensorData' (sensor1 Count, sensor2 Count, sensor 3Count, sumOfSensorReadings, average)) # VII) Close the database connection cursor.close() connection.close() except: print("There has been an exception")

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!