[MIG] base_external_system: Migration to 15.0

This commit is contained in:
Cesar Andres Sanchez
2022-07-14 00:00:17 +02:00
committed by Pedro M. Baeza
parent 2f3f56d476
commit f46233eb16
5 changed files with 14 additions and 9 deletions

View File

@@ -23,7 +23,7 @@ class ExternalSystemOs(models.Model):
"""Return a usable client representing the remote system."""
super(ExternalSystemOs, self).external_get_client()
if self.system_id.remote_path:
self.previous_dir = os.getcwd()
ExternalSystemOs.previous_dir = os.getcwd()
os.chdir(self.system_id.remote_path)
return os
@@ -34,7 +34,8 @@ class ExternalSystemOs(models.Model):
client (mixed): The client that was returned by
``external_get_client``.
"""
super(ExternalSystemOs, self).external_destroy_client(client)
if self.previous_dir:
os.chdir(self.previous_dir)
self.previous_dir = None
result = super(ExternalSystemOs, self).external_destroy_client(client)
if ExternalSystemOs.previous_dir:
os.chdir(ExternalSystemOs.previous_dir)
ExternalSystemOs.previous_dir = None
return result