backups: Remove unnecessary context manager for paramiko SFTPClient

Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
This commit is contained in:
Joseph Nuthalapati 2019-06-14 21:13:27 +05:30
parent 9f71c5867e
commit 795ed9d735
No known key found for this signature in database
GPG Key ID: 5398F00A2FA43C35

View File

@ -410,7 +410,7 @@ def _validate_remote_repository(path, credentials, uuid=None):
password = credentials['ssh_password']
repository = None
with _ssh_connection(hostname, username, password) as ssh_client:
with _sftp_client(ssh_client) as sftp_client:
with ssh_client.open_sftp() as sftp_client:
dir_contents = None
try:
dir_contents = sftp_client.listdir(dir_path)
@ -454,16 +454,6 @@ def _ssh_connection(hostname, username, password):
ssh_client.close()
@contextmanager
def _sftp_client(ssh_client):
"""Context manager to create and close an SFTP client."""
sftp_client = ssh_client.open_sftp()
try:
yield sftp_client
finally:
sftp_client.close()
class RemoveRepositoryView(SuccessMessageMixin, TemplateView):
"""View to delete a repository."""
template_name = 'backups_repository_remove.html'