Paramiko's SFTPClient apparently does not have an exists
method. This is my current implementation:
def rexists(sftp, path):
"""os.path.exists for paramiko's SCP object
"""
try:
sftp.stat(path)
except IOError, e:
if 'No such file' in str(e):
return False
raise
else:
return True
Is there a better way to do this? Checking for substring in Exception messages is pretty ugly and can be unreliable.