Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
improved callback info (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
pacogomez committed Feb 15, 2018
1 parent 600da49 commit afdd658
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions AUTHORS
@@ -1,2 +1,3 @@
Paco Gómez <contact@pacogomez.com>
Paco Gómez <pacogomez@users.noreply.github.com>
VMware GitHub Bot <fincht@vmware.com>
7 changes: 7 additions & 0 deletions ChangeLog
@@ -1,6 +1,13 @@
CHANGES
=======

0.0.5
-----

* changelog
* Improved exception handling (#1)
* Improved exception handling
* Update README.md

0.0.4
-----
Expand Down
16 changes: 10 additions & 6 deletions vsphere_guest_run/vsphere.py
Expand Up @@ -85,7 +85,8 @@ def execute_program_in_guest(self,
try:
processes = pm.ListProcessesInGuest(vm, creds, [pid])
if len(processes) == 0:
raise Exception('process not found (pid=%s)' % pid)
raise Exception('process not found (pid=%s) (vm=%s)' %
(pid, vm))
if processes[0].exitCode is not None:
result = [processes[0].exitCode]
if get_output:
Expand All @@ -106,20 +107,23 @@ def execute_program_in_guest(self,
else:
print(str(e))
if callback is not None:
callback('process %s finished, exit code: %s' %
(result, processes[0].exitCode))
callback(
'process %s on vm %s finished, exit code: %s' %
(result, vm, processes[0].exitCode))
return result
else:
if callback is not None:
n += 1
callback('waiting for process %s to finish (%s)' %
(pid, n))
callback(
'waiting for process %s on vm %s to finish (%s)' %
(pid, vm, n))
time.sleep(wait_time)
except Exception as e:
if str(e).startswith('process not found ('):
raise e
if callback is not None:
callback('exception, will retry in a few seconds', e)
callback('exception, will retry in a few seconds, vm %s' %
vm, e)
else:
print(str(e))
print('will retry again in a few seconds')
Expand Down

0 comments on commit afdd658

Please sign in to comment.