Question: I need help resolving this error: execute ( [ ' KITH - 2 0 1 7 ' , ' - - test' ] ) did

I need help resolving this error:
execute(['KITH-2017','--test']) did not print out an error message
35. Implement execute
The main application function is execute. It takes the command line arguments and decides whether to call discover_violations or tests.test_all(). If the user provides a data file, the function runs discover_violations. If the user provides the argument --test it runs the main test function.
You have already seen an example of something similar in the course videos. The application to_celsius contains a function execute that can either be used to test the function or run the temperature application. This code is available in the samples folder under unit3. Take a look at this sample code now and use it to complete your execute function.
When you have finished this function, run the test script. Better yet, try to run the tests directly from the application as follows:
codio@mike-panther:~/workspace$ python auditor --test
Testing module utils
...
def execute(args):
"""
Executes the application or prints an error message if executed incorrectly.
The arguments to the application (EXCLUDING the application name) are provided to
the list args. This list should contain either 1 or 2 elements. If there is one
element, it should be the name of the data set folder or the value '--test'. If
there are two elements, the first should be the data set folder and the second
should be the name of a CSV file (for output of the results).
If the user calls this script incorrectly (with the wrong number of arguments), this
function prints:
Usage: python auditor dataset [output.csv]
This function does not do much error checking beyond counting the number of arguments.
Parameter args: The command line arguments for the application (minus the application name)
Precondition: args is a list of strings
"""
# Total arguments
n = len(args)
# Print an error if the number of arguments is incorrect
if n <1 or n >2:
print('Usage: python auditor dataset [output.csv]')
return
if n ==1:
if args[0]=='--test':
# Call the test procedure header
print("Running test procedure...")
else:
print("Folder name:", args[0])
else:
folder_name = args[0]
csv_file_name = args[1]
# Check if the second argument is '--test' or a valid CSV file name
if csv_file_name !='--test' and not csv_file_name.endswith('.csv'):
print('Invalid second argument. Should be "--test" or a valid CSV file name.')
return
print("Folder name:", folder_name)
print("Csv file name:", csv_file_name)

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!