3
3
from time import sleep
4
4
from src .exercise_checker .checker import ExerciceFailed , ProtostarExerciseChecker
5
5
from src .file_watcher .watcher import FileWatcher
6
+ from src import prompt
6
7
from src .verify import ExerciseSeeker
7
8
from src .constants import exercise_files_architecture
8
9
@@ -12,20 +13,24 @@ def __init__(self, root_path: Path):
12
13
self ._file_watcher = FileWatcher (root_path )
13
14
self ._exercise_checker = ProtostarExerciseChecker (root_path )
14
15
self ._exercise_seeker = ExerciseSeeker (exercise_files_architecture , root_path )
16
+ prompt .on_watch_start (self ._exercise_seeker .find_next_exercise ())
15
17
16
18
def on_file_changed (self , _ ):
17
19
asyncio .run (self ._check_exercise ())
18
20
19
21
async def _check_exercise (self ):
20
22
next_exercise_path = self ._exercise_seeker .find_next_exercise ()
21
- print ( f"Checking exercise { next_exercise_path } ..." )
23
+ prompt . on_exercise_check ( next_exercise_path )
22
24
try :
23
- test_result = await self ._exercise_checker .run (str (next_exercise_path ))
24
- print ( test_result )
25
+ await self ._exercise_checker .run (str (next_exercise_path ))
26
+ prompt . on_exercise_success ( next_exercise_path )
25
27
except ExerciceFailed as error :
26
- print ( error .message )
28
+ prompt . on_exercise_failure ( next_exercise_path , error .message )
27
29
28
30
def run (self ):
29
- self ._file_watcher .start (self .on_file_changed )
30
- while True :
31
- sleep (5 )
31
+ try :
32
+ self ._file_watcher .start (self .on_file_changed )
33
+ while True :
34
+ sleep (5 )
35
+ except KeyboardInterrupt :
36
+ pass
0 commit comments