mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-03-11 09:04:54 +00:00
backups: Remove unnecessary context manager for paramiko SFTPClient
Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
This commit is contained in:
parent
9f71c5867e
commit
795ed9d735
@ -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'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user