@contextmanager<EOL>def open_remote_file(hostname, filename, mode='<STR_LIT:r>', bufsize=-<NUM_LIT:1>, username=None, password=None):
with get_ssh_client(hostname, username=username, password=password) as ssh:<EOL><INDENT>sftp = None<EOL>f = None<EOL>try:<EOL><INDENT>sftp = ssh.open_sftp()<EOL>f = sftp.open(filename, mode, bufsize)<EOL>yield f<EOL><DEDENT>finally:<EOL><INDENT>if f is not None:<EOL><INDENT>f.close()<EOL><DEDENT>if sftp is not None:<EOL><INDENT>sftp.close()<EOL><DEDENT><DEDENT><DEDENT>
:param hostname:
:param filename:
:return: