Skip to content

Commit

Permalink
Add verification and skip non-java files
Browse files Browse the repository at this point in the history
  • Loading branch information
mistzzt committed Nov 2, 2017
1 parent 4f555fc commit 5a3eaae
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions palint.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
TURN_IN_PROMPT = 'Do you want to turn in assignment now?'

TURN_IN_COMMAND = 'cse11turnin {}'
VERIFY_COMMAND = 'cse11verify {}'

EXIT_SUCCESS = 0
EXIT_FAILURE = 1
Expand Down Expand Up @@ -142,6 +143,12 @@ def process_project():
print('\n')
print('Start turning in assignment...')
turnin()

print('\n')
print('Start verifying assignment...')
verify()

print('\n')
print('Completed!')


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

result = subprocess.check_output(cmd.format(class_path, ' '.join(files)), shell=True)
java_list = filter(lambda x: str(x).endswith('.java'), files)
optional_list = filter(lambda x: str(x).endswith('.java'), optionals)

result = subprocess.check_output(cmd.format(class_path, ' '.join(java_list)), shell=True)
if len(result) != 0:
error('Your source codes cannot be compiled; see {} for details.'.format(COMPILE_ERROR_FILE_NAME))
has_error = True

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


def verify():
""" Verify assignment. """
os.system(VERIFY_COMMAND.format(project))


def error(msg):
""" Show error message to user. """
sys.stderr.write('> \033[93m{} \033[0m\n'.format(msg))
Expand Down

0 comments on commit 5a3eaae

Please sign in to comment.