File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -749,6 +749,14 @@ fn run() -> Result<()> {
749749 . context ( "Failed to submit" ) ?;
750750
751751 print_result_as_json ( & new_submission) ?;
752+ } else if let Some ( matches) = matches. subcommand_matches ( "wait-for-submission" ) {
753+ let submission_url = matches. value_of ( "submission-url" ) . unwrap ( ) ;
754+ let submission_finished = core
755+ . wait_for_submission ( submission_url)
756+ . context ( "Failed while waiting for submissions" ) ?;
757+ let submission_finished = serde_json:: to_string ( & submission_finished)
758+ . context ( "Failed to serialize submission results" ) ?;
759+ println ! ( "{}" , submission_finished) ;
752760 } else if let Some ( _matches) = matches. subcommand_matches ( "get-exercise-updates" ) {
753761 let course_id = matches. value_of ( "course-id" ) . unwrap ( ) ;
754762 let course_id = into_usize ( course_id) ?;
Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ use std::collections::HashMap;
1616use std:: io:: Write ;
1717use std:: path:: Path ;
1818use std:: path:: PathBuf ;
19+ use std:: thread;
20+ use std:: time:: Duration ;
1921use tempfile:: NamedTempFile ;
2022use tmc_langs_util:: task_executor;
2123
@@ -387,6 +389,18 @@ impl TmcCore {
387389 result
388390 }
389391
392+ pub fn wait_for_submission ( & self , submission_url : & str ) -> Result < SubmissionFinished > {
393+ loop {
394+ match self . check_submission ( submission_url) ? {
395+ SubmissionProcessingStatus :: Finished ( f) => return Ok ( * f) ,
396+ SubmissionProcessingStatus :: Processing ( _p) => {
397+ // todo: report status
398+ thread:: sleep ( Duration :: from_secs ( 1 ) ) ;
399+ }
400+ }
401+ }
402+ }
403+
390404 /// Fetches the course's exercises from the server,
391405 /// and finds new or updated exercises.
392406 /// If an exercise's id is not found in the checksum map, it is considered new.
You can’t perform that action at this time.
0 commit comments