mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 21:32:15 +01:00
Fix - import pysftp only when necessary
Blender 2.93 has issue with conflicting libraries, pysftp is actually not needed in provider running in a host, do not import it or explode when its not necessary
This commit is contained in:
parent
bd020bb606
commit
c014b698a6
1 changed files with 21 additions and 7 deletions
|
|
@ -11,11 +11,15 @@ from openpype.api import get_system_settings
|
|||
from .abstract_provider import AbstractProvider
|
||||
log = Logger().get_logger("SyncServer")
|
||||
|
||||
pysftp = None
|
||||
try:
|
||||
import pysftp
|
||||
import pysftp as _pysftp
|
||||
|
||||
pysftp = _pysftp
|
||||
except (ImportError, SyntaxError):
|
||||
if six.PY3:
|
||||
six.reraise(*sys.exc_info())
|
||||
pass
|
||||
# if six.PY3:
|
||||
# six.reraise(*sys.exc_info())
|
||||
|
||||
# handle imports from Python 2 hosts - in those only basic methods are used
|
||||
log.warning("Import failed, imported from Python 2, operations will fail.")
|
||||
|
|
@ -41,7 +45,7 @@ class SFTPHandler(AbstractProvider):
|
|||
self.project_name = project_name
|
||||
self.site_name = site_name
|
||||
self.root = None
|
||||
self.conn = None
|
||||
self._conn = None
|
||||
|
||||
self.presets = presets
|
||||
if not self.presets:
|
||||
|
|
@ -63,11 +67,17 @@ class SFTPHandler(AbstractProvider):
|
|||
self.sftp_key = provider_presets["sftp_key"]
|
||||
self.sftp_key_pass = provider_presets["sftp_key_pass"]
|
||||
|
||||
self.conn = self._get_conn()
|
||||
|
||||
self._tree = None
|
||||
self.active = True
|
||||
|
||||
@property
|
||||
def conn(self):
|
||||
"""SFTP connection, cannot be used in all places though."""
|
||||
if not self._conn:
|
||||
self._conn = self._get_conn()
|
||||
|
||||
return self._conn
|
||||
|
||||
def is_active(self):
|
||||
"""
|
||||
Returns True if provider is activated, eg. has working credentials.
|
||||
|
|
@ -321,7 +331,8 @@ class SFTPHandler(AbstractProvider):
|
|||
if not self.file_path_exists(path):
|
||||
raise FileNotFoundError("File {} to be deleted doesn't exist."
|
||||
.format(path))
|
||||
self.conn.remove(path)
|
||||
conn = self._get_conn()
|
||||
conn.remove(path)
|
||||
|
||||
def list_folder(self, folder_path):
|
||||
"""
|
||||
|
|
@ -394,6 +405,9 @@ class SFTPHandler(AbstractProvider):
|
|||
Returns:
|
||||
pysftp.Connection
|
||||
"""
|
||||
if not pysftp:
|
||||
raise ImportError
|
||||
|
||||
cnopts = pysftp.CnOpts()
|
||||
cnopts.hostkeys = None
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue