A Python program that reads scheduled tasks from a file and executes them at the right time. But this time, it's refactored in OOP.
Each line in schedule.txt follows this format:
HH:MM:SS command argument
Three supported commands:
| Command | Argument | Example |
|---|---|---|
print |
Message to print | 09:00:05 print Good morning! |
list_files |
Directory path | 09:00:10 list_files . |
create_file |
Filename | 09:00:15 create_file log.txt |
09:00:05 print Good morning!
09:00:10 create_file log.txt
09:00:15 list_files .
09:00:20 print All done!
- Create your
schedule.txtwith tasks set a few seconds from now - Run the scheduler:
python scheduler.py
- Press
Ctrl+Cto stop
Implement the scheduler just as the coursework from yesterday, but with OOP instead of procedural programming.
Complete the two classes and their relative methods.
Task— Represents a single scheduled taskScheduler— Manages loading and running scheduled tasks
- Create tests under the
testsfolder for theTaskclass - Create tests under the
testsfolder for theSchedulerclass