Created
November 6, 2020 02:18
-
-
Save mertyildiran/fd3c69a59172acd3a50436b8380386f7 to your computer and use it in GitHub Desktop.
Homework iterator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/python3 | |
import glob | |
import subprocess | |
import psutil | |
def kill(proc_pid): | |
process = psutil.Process(proc_pid) | |
for proc in process.children(recursive=True): | |
proc.kill() | |
process.kill() | |
files = glob.glob("*/*", recursive = True) | |
files.sort() | |
with open("grades.txt", "a") as grades: | |
for filepath in files: | |
folder = filepath.split('/')[0] | |
student_name = folder.split('_')[0] | |
process = subprocess.Popen(["libreoffice", "--calc", "--norestore", filepath], shell=False) | |
grade = input("Enter the grade for student %s: " % student_name) | |
grades.write("{: >20} {: >20}\n".format(student_name, grade)) | |
kill(process.pid) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment