From 2e990342d647a3d2349eeebac0ba5927c5e0c2af Mon Sep 17 00:00:00 2001 From: Andy Kipp Date: Mon, 7 Oct 2013 22:44:35 -0400 Subject: [PATCH] Display task description and status --- R/lucid.R | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/R/lucid.R b/R/lucid.R index 787852a..443af24 100644 --- a/R/lucid.R +++ b/R/lucid.R @@ -57,28 +57,30 @@ lucidClient <- function(authInfo) { waitForTaskCompletion = function(taskId, quiet = FALSE) { path <- paste("/tasks/", taskId, sep="") - + + cat("Waiting for task: ", taskId, "\n", sep="") + lastStatus <- NULL while(TRUE) { # check status status <- handleResponse(GET(authInfo, path)) + # display status to the user if it changed + if (!identical(lastStatus, status$description)) { + if (!quiet) + cat(" ", status$status, ": ", status$description, "\n", sep="") + lastStatus <- status$description + } + # are we finished? (note: this codepath is the only way to exit # this function) - if (status$finished) { + else if (status$finished) { if (identical(status$status, "complete")) return (NULL) else stop(status$error, call. = FALSE) } - # display status to the user if it changed - else if (!identical(lastStatus, status$status)) { - if (!quiet) - cat(" ", status$status, "\n", sep="") - lastStatus <- status$status - } - # wait for 1 second before polling again Sys.sleep(1) }