From d1ea27be17cb8c16be5273ccb053249e0ae0732a Mon Sep 17 00:00:00 2001 From: Tomi Date: Thu, 27 May 2021 22:58:40 +0200 Subject: [PATCH] Added small changes to handle path encoding in some client and dccplugin functions --- artella/core/client.py | 3 ++- artella/core/dccplugin.py | 2 ++ artella/core/utils.py | 5 +++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/artella/core/client.py b/artella/core/client.py index 40b0af5..5c29222 100644 --- a/artella/core/client.py +++ b/artella/core/client.py @@ -732,7 +732,8 @@ def status(self, file_paths, include_remote=False): file_path = file_path.decode('latin-1') uri_path = path_to_uri(file_path) if not is_uri_path(file_path) else file_path uri_parts = urlparse(uri_path) - params = urlencode({'handle': uri_parts.path, 'include-remote': str(bool(include_remote)).lower()}) + uri_handle = utils.clean_path(uri_parts.path) + params = urlencode({'handle': uri_handle, 'include-remote': str(bool(include_remote)).lower()}) req = Request('http://{}:{}/v2/localserve/fileinfo?{}'.format( self._host, self._port, params)) rsp = self._communicate(req) diff --git a/artella/core/dccplugin.py b/artella/core/dccplugin.py index 0a950c6..7a9544d 100644 --- a/artella/core/dccplugin.py +++ b/artella/core/dccplugin.py @@ -610,6 +610,8 @@ def make_new_version(self, file_path=None, comment=None, do_lock=False): logger.warning(msg) return False + file_path = utils.clean_path(file_path) + can_lock = artella_drive_client.can_lock_file(file_path=file_path) if not can_lock: msg = 'Unable to lock file to make new version. File is already locked by other user.' diff --git a/artella/core/utils.py b/artella/core/utils.py index 6fbb04d..b941e35 100644 --- a/artella/core/utils.py +++ b/artella/core/utils.py @@ -18,6 +18,7 @@ import importlib import subprocess from functools import wraps + try: from importlib.machinery import SourceFileLoader except ImportError: @@ -91,9 +92,9 @@ def clean_path(path): path = os.path.expanduser(path) else: try: - path = os.path.expanduser(str(path.encode('latin1'))) - except Exception: path = os.path.expanduser(str(path.encode('utf-8'))) + except Exception: + path = os.path.expanduser(str(path.encode('latin1'))) path = str(path.replace('\\', '/').replace('//', '/').rstrip('/').strip()) # Fix server paths