Skip to content

Commit

Permalink
Code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
micafer committed Jul 29, 2015
1 parent 1df7a48 commit 25db327
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions IM/VirtualMachine.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,9 +632,13 @@ def get_ctxt_log(self, remote_dir, delete = False):

# Remove problematic chars
conf_out = filter(lambda x: x in string.printable, conf_out).encode("ascii", "replace")
if delete:
ssh.sftp_remove(remote_dir + '/ctxt_agent.log')
except Exception:
try:
if delete:
ssh.sftp_remove(remote_dir + '/ctxt_agent.log')
except:
VirtualMachine.logger.exception("Error deleting remote contextualization process log")
pass
except:
VirtualMachine.logger.exception("Error getting contextualization process log")
self.configured = False
finally:
Expand All @@ -651,8 +655,12 @@ def get_ctxt_output(self, remote_dir, delete = False):
# Get the JSON output of the ctxt_agent
ssh.sftp_get(remote_dir + '/ctxt_agent.out', tmp_dir + '/ctxt_agent.out')
with open(tmp_dir + '/ctxt_agent.out') as f: ctxt_agent_out = json.load(f)
if delete:
ssh.sftp_remove(remote_dir + '/ctxt_agent.out')
try:
if delete:
ssh.sftp_remove(remote_dir + '/ctxt_agent.out')
except:
VirtualMachine.logger.exception("Error deleting remote contextualization process output")
pass
# And process it
self.process_ctxt_agent_out(ctxt_agent_out)
except Exception, ex:
Expand Down

0 comments on commit 25db327

Please sign in to comment.