check if gradebook/submissions dir exists and has files to inspect

This commit is contained in:
2023-03-16 20:40:20 +00:00
parent 80aaf3ee5d
commit 9520e39590
2 changed files with 10 additions and 2 deletions

View File

@@ -3,9 +3,13 @@ from utils.inspector import generate_hashes_gradebook, generate_duplicate_hashes
def main():
gradebook_dir_name = ' '.join(sys.argv[1:]) if len(sys.argv) > 1 else exit(f'\nNo gradebook dir name given. Provide the name as an argument.\n\nUsage: python {sys.argv[0]} [gradebook dir name]\nExample: python {sys.argv[0]} AssignmentX\n')
gradebook_dir_name = ' '.join(sys.argv[1:]) if len(sys.argv) > 1 else exit(f'\nNo gradebook directory name given. Provide the name as an argument.\n\nUsage: python {sys.argv[0]} [gradebook dir name]\nExample: python {sys.argv[0]} AssignmentX\n')
gradebook_dir_path = os.path.join('BB_gradebooks', gradebook_dir_name)
if not os.path.exists(gradebook_dir_path):
exit('[Info] Gradebook directory does not exist - nothing to inspect')
if not os.listdir(gradebook_dir_path): # if no files in gradebook dir
exit(f'[Info] No files found in this gradebook - nothing to inspect')
# generate CSV file with hashes for all files in gradebook & return path to CSV file for finding duplicate hashes
hashes_csv_file_path = generate_hashes_gradebook(gradebook_dir_path)
# generate CSV file with files having duplicate hashes

View File

@@ -3,9 +3,13 @@ from utils.inspector import generate_hashes_submissions, generate_duplicate_hash
def main():
submissions_dir_name = ' '.join(sys.argv[1:]) if len(sys.argv) > 1 else exit(f'\nNo submissions dir name given. Provide the name as an argument.\n\nUsage: python {sys.argv[0]} [submissions dir name]\nExample: python {sys.argv[0]} AssignmentX\n')
submissions_dir_name = ' '.join(sys.argv[1:]) if len(sys.argv) > 1 else exit(f'\nNo submissions directory name given. Provide the name as an argument.\n\nUsage: python {sys.argv[0]} [submissions dir name]\nExample: python {sys.argv[0]} AssignmentX\n')
submissions_dir_path = os.path.join('BB_submissions', submissions_dir_name)
if not os.path.exists(submissions_dir_path):
exit('[Info] Directory does not exist - nothing to inspect')
if not os.listdir(submissions_dir_path): # if no files in dir
exit(f'[Info] No files found in this submissions directory - nothing to inspect')
# generate CSV file with hashes for all files in submissions (except for any 'excluded') & return path to CSV file for finding duplicate hashes
hashes_csv_file_path = generate_hashes_submissions(submissions_dir_path)
# generate CSV file with files having duplicate hashes