Skip to content

Commit 5a3eaae

Browse files
committed
Add verification and skip non-java files
1 parent 4f555fc commit 5a3eaae

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

palint.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
TURN_IN_PROMPT = 'Do you want to turn in assignment now?'
2626

2727
TURN_IN_COMMAND = 'cse11turnin {}'
28+
VERIFY_COMMAND = 'cse11verify {}'
2829

2930
EXIT_SUCCESS = 0
3031
EXIT_FAILURE = 1
@@ -142,6 +143,12 @@ def process_project():
142143
print('\n')
143144
print('Start turning in assignment...')
144145
turnin()
146+
147+
print('\n')
148+
print('Start verifying assignment...')
149+
verify()
150+
151+
print('\n')
145152
print('Completed!')
146153

147154

@@ -178,13 +185,16 @@ def test_compile(files, optionals, libraries):
178185
class_path = ''.join(libs) + '.'
179186
cmd = 'javac -cp {} {}'
180187

181-
result = subprocess.check_output(cmd.format(class_path, ' '.join(files)), shell=True)
188+
java_list = filter(lambda x: str(x).endswith('.java'), files)
189+
optional_list = filter(lambda x: str(x).endswith('.java'), optionals)
190+
191+
result = subprocess.check_output(cmd.format(class_path, ' '.join(java_list)), shell=True)
182192
if len(result) != 0:
183193
error('Your source codes cannot be compiled; see {} for details.'.format(COMPILE_ERROR_FILE_NAME))
184194
has_error = True
185195

186196
if len(optionals) != 0:
187-
result = subprocess.check_output(cmd.format(class_path, ' '.join(optionals)), shell=True)
197+
result = subprocess.check_output(cmd.format(class_path, ' '.join(optional_list)), shell=True)
188198
if len(result) != 0:
189199
error('Your optional files cannot be compiled; see {} for details.'.format(COMPILE_ERROR_FILE_NAME))
190200
has_error = True
@@ -276,6 +286,11 @@ def turnin():
276286
p.wait()
277287

278288

289+
def verify():
290+
""" Verify assignment. """
291+
os.system(VERIFY_COMMAND.format(project))
292+
293+
279294
def error(msg):
280295
""" Show error message to user. """
281296
sys.stderr.write('> \033[93m{} \033[0m\n'.format(msg))

0 commit comments

Comments
 (0)