gbdx_cloud_harness/services/account_storage_service.py
def download(self, local_port_path, key_names):  # pragma: no cover
        """
        download all files from a users account location
        :param local_port_path: the local path where the data is to download to
        :param key_name: can start with self.prefix or taken as relative to prefix.

        Example:
            local_port_path = /home/user/myworkflow/input_images/ (sync all data in this folder)
            s3_folder = myworkflow/input_images/ (location on s3 that will be synced to local path)
        """

        if not os.path.isdir(local_port_path):
            raise ValueError("Download path does not exist: %s" % local_port_path)

        if not isinstance(key_names, list):
            key_names = [key_names]

        for key_name in key_names:
            is_folder = key_name.endswith('/')

            # strip leading and trailing slashes
            key_name = key_name.lstrip('/').rstrip('/')
            key_parts = key_name.split('/')

            # Key names from the list function will include the account prefix
            # and any folder namespace.
            if key_parts[0] == self.prefix:
                path = os.path.join(local_port_path, *key_parts[1:])
                if not is_folder:
                    folder_path = os.path.join(local_port_path, *key_parts[1:-1])
                get_key_name = key_name
            else:
                path = os.path.join(local_port_path, *key_parts)
                if not is_folder:
                    folder_path = os.path.join(local_port_path, *key_parts[:-1])
                get_key_name = '%s/%s' % (self.prefix, key_name)

            if is_folder and not os.path.isdir(path):
                # A directory that doesn't exist
                os.makedirs(path)
            else:
                if not os.path.isdir(folder_path):
                    os.makedirs(folder_path)
                # Assume it is a file
                self.__download_file(path, get_key_name)
def download(self, local_port_path, key_names):  # pragma: no cover
        """
        download all files from a users account location
        :param local_port_path: the local path where the data is to download to
        :param key_name: can start with self.prefix or taken as relative to prefix.

        Example:
            local_port_path = /home/user/myworkflow/input_images/ (sync all data in this folder)
            s3_folder = myworkflow/input_images/ (location on s3 that will be synced to local path)
        """

        if not os.path.isdir(local_port_path):
            raise ValueError("Download path does not exist: %s" % local_port_path)

        if not isinstance(key_names, list):
            key_names = [key_names]

        for key_name in key_names:
            is_folder = key_name.endswith('/')

            # strip leading and trailing slashes
            key_name = key_name.lstrip('/').rstrip('/')
            key_parts = key_name.split('/')

            # Key names from the list function will include the account prefix
            # and any folder namespace.
            if key_parts[0] == self.prefix:
                path = os.path.join(local_port_path, *key_parts[1:])
                if not is_folder:
                    folder_path = os.path.join(local_port_path, *key_parts[1:-1])
                get_key_name = key_name
            else:
                path = os.path.join(local_port_path, *key_parts)
                if not is_folder:
                    folder_path = os.path.join(local_port_path, *key_parts[:-1])
                get_key_name = '%s/%s' % (self.prefix, key_name)

            if is_folder and not os.path.isdir(path):
                # A directory that doesn't exist
                os.makedirs(path)
            else:
                if not os.path.isdir(folder_path):
                    os.makedirs(folder_path)
                # Assume it is a file
                self.__download_file(path, get_key_name)
download all files from a users account location
        :param local_port_path: the local path where the data is to download to
        :param key_name: can start with self.prefix or taken as relative to prefix.

        Example:
            local_port_path = /home/user/myworkflow/input_images/ (sync all data in this folder)
            s3_folder = myworkflow/input_images/ (location on s3 that will be synced to local path)