cli: Show progress during polling for async jobs If asyncblock is set to true, prints dots as polling requests are made. When result is obtained, dots are wiped and result is printed.
Signed-off-by: Rohit Yadav <bhais...@apache.org> Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/c7563cb7 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/c7563cb7 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/c7563cb7 Branch: refs/heads/ui-quick-view-v2 Commit: c7563cb7bd5f813332cfe7bbdf96bc235d56c1ff Parents: 9a66beb Author: Rohit Yadav <bhais...@apache.org> Authored: Fri Jan 4 15:15:21 2013 -0800 Committer: Rohit Yadav <bhais...@apache.org> Committed: Fri Jan 4 15:17:06 2013 -0800 ---------------------------------------------------------------------- tools/cli/cloudmonkey/cloudmonkey.py | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/c7563cb7/tools/cli/cloudmonkey/cloudmonkey.py ---------------------------------------------------------------------- diff --git a/tools/cli/cloudmonkey/cloudmonkey.py b/tools/cli/cloudmonkey/cloudmonkey.py index e1fc63e..3bc8716 100644 --- a/tools/cli/cloudmonkey/cloudmonkey.py +++ b/tools/cli/cloudmonkey/cloudmonkey.py @@ -266,7 +266,11 @@ class CloudMonkeyShell(cmd.Cmd, object): command = "queryAsyncJobResult" requests = {'jobid': jobId} timeout = int(self.timeout) + pollperiod = 3 while timeout > 0: + progress = int((int(self.timeout) - timeout) / pollperiod ) + 1 + print '\r' + '.' * progress, + sys.stdout.flush() response = process_json(conn.make_request_with_auth(command, requests)) responsekeys = filter(lambda x: 'response' in x, @@ -282,9 +286,10 @@ class CloudMonkeyShell(cmd.Cmd, object): jobresult["errortext"]) return elif jobstatus == 1: + print '\r', return response - time.sleep(4) - timeout = timeout - 4 + time.sleep(pollperiod) + timeout = timeout - pollperiod logger.debug("job: %s to timeout in %ds" % (jobId, timeout)) self.print_shell("Error:", "Async query timeout for jobid=", jobId)