-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRunCheck.py
More file actions
64 lines (49 loc) · 2.54 KB
/
RunCheck.py
File metadata and controls
64 lines (49 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import os
from shutil import copyfile
import RunJavaUtils
from collections import defaultdict
import argparse
import ExcelWriter
#
def Create_File_List(sourceDir):
dirs = os.listdir(sourceDir)
files = []
for file in dirs:
if (".java" == file[(len(file) - len(".java")):]):
files.append(file)
return files
def Parse_Args():
parser = argparse.ArgumentParser()
parser.add_argument('-student_dir', type=str, required=True, help="path to where the student copies of the java source resides")
parser.add_argument('-xlsx', type=str, required=True, help="name of the .xlsx file where the results should be stored")
parser.add_argument('-output', dest='output', action='store_true', help='append the output from running the file into the .csv')
parser.add_argument('-no_output', dest='output', action='store_false', help='do not append the output from running the file into the .csv')
parser.add_argument('-file', dest='file', action='store_true', help='append the original student source into the .csv')
parser.add_argument('-no_file', dest='file', action='store_false', help='do not append the original student source into the .csv')
parser.add_argument("-golden_source", help='if you want to compare the output of a golden source to the student sources specify a file with this option')
parser.set_defaults(output=True)
parser.set_defaults(file=True)
args = parser.parse_args()
parsed = True
if (args.student_dir == None or args.output == None):
print("Missing required argument (they're all required)")
parser.print_help()
parsed = False
return (parsed, args.student_dir, args.xlsx, args.output, args.file, args.golden_source)
def main():
(parsed, studentDir, csv, addOutput, addFile, golden_source) = Parse_Args()
if (parsed):
tempPath = RunJavaUtils.Create_Temp_Dir()
goldenLines = []
if (golden_source != None):
(success, _, _, _, goldenLines) = RunJavaUtils.Copy_And_Run_Java_File(tempPath, golden_source, None)
if (success == False):
print("Build failure for golden source")
return
writer = ExcelWriter.ExcelWriter(csv)
files = Create_File_List(studentDir)
RunJavaUtils.Copy_And_Run_Files(studentDir, files, tempPath, writer, addOutput, addFile, goldenLines)
writer.Create_Excel_File()
RunJavaUtils.Clean_And_Remove_Temp_Dir(tempPath)
if __name__ == '__main__':
main()