diff --git a/frameioclient/lib/transfer.py b/frameioclient/lib/transfer.py index 422c5614..125e4403 100644 --- a/frameioclient/lib/transfer.py +++ b/frameioclient/lib/transfer.py @@ -58,7 +58,7 @@ def __init__( self.session = None self.filename = Utils.normalize_filename(asset["name"]) self.request_logs = list() - self.stats = True + self.stats = False self._evaluate_asset() self._get_path() @@ -411,17 +411,18 @@ def multi_thread_download(self): pprint(self.downloader) download_speed = round((self.downloader.filesize / download_time), 2) - if self.downloader.checksum_verification == True: - # Check for checksum, if not present throw error - if self.downloader._get_checksum() == None: - raise AssetChecksumNotPresent - - # Calculate the file hash - if ( - Utils.calculate_hash(self.destination) - != self.downloader.original_checksum - ): - raise AssetChecksumMismatch + # TODO: Ensure this works correctly on assets that are missing checksums/at all + # if self.downloader.checksum_verification == True: + # # Check for checksum, if not present throw error + # if self.downloader._get_checksum() == None: + # raise AssetChecksumNotPresent + + # # Calculate the file hash + # if ( + # Utils.calculate_hash(self.destination) + # != self.downloader.original_checksum + # ): + # raise AssetChecksumMismatch # Log completion event SDKLogger("downloads").info( diff --git a/frameioclient/lib/transport.py b/frameioclient/lib/transport.py index 6dda6e16..09ac0ce4 100644 --- a/frameioclient/lib/transport.py +++ b/frameioclient/lib/transport.py @@ -126,6 +126,10 @@ def _api_call( if r.status_code == 422 and "presentation" in endpoint: raise PresentationException + + if r.status_code == 500 and 'audit' in endpoint: + print(f"Hit a 500 on page: {r.headers.get('page-number')}, url: {r.url}") + return [] return r.raise_for_status() diff --git a/frameioclient/services/assets.py b/frameioclient/services/assets.py index 08a2ac08..3ce45c88 100644 --- a/frameioclient/services/assets.py +++ b/frameioclient/services/assets.py @@ -138,6 +138,7 @@ def create( "type": type, "filesize": filesize, "filetype": filetype, + "properties": {"reference_id": "7eaa2f13-1202-42b3-a360-9d21e9a9efa7"}, } endpoint = "/assets/{}/children".format(parent_asset_id) @@ -356,6 +357,10 @@ def upload( except Exception as e: print(e) + else: + with open(file_info["filepath"], "rb") as fp: + self._upload(asset, fp) + return asset def download( @@ -393,7 +398,7 @@ def upload_folder(self, source_path: str, destination_id: Union[str, UUID]): Example:: - client.assets.upload("./file.mov", "1231-12414-afasfaf-aklsajflaksjfla") + client.assets.upload("./file.mov", "1231-12414-afasfaf-aklsajflaksjfla") """ # Check if destination is a project or folder diff --git a/frameioclient/services/helpers.py b/frameioclient/services/helpers.py index 973397c3..75955403 100644 --- a/frameioclient/services/helpers.py +++ b/frameioclient/services/helpers.py @@ -40,7 +40,7 @@ def get_assets_recursively(self, asset_id, slim=True): assets = self.client.assets.get_children(asset_id, slim=slim) print("Number of assets at top level", len(assets)) - for asset in assets: + for index, asset in enumerate(assets): # try: print( f"Type: {asset['_type']}, Name: {asset['name']}, Children: {len(asset['children'])}" @@ -57,7 +57,7 @@ def get_assets_recursively(self, asset_id, slim=True): if asset["_type"] == "version_stack": print("Grabbing top item from version stack") versions = self.client.assets.get_children(asset["id"], slim=True) - asset = versions[0] # re-assign on purpose + assets[index]['children'] = versions # re-assign on purpose continue # We only get the first three items when we use "include=children" @@ -97,10 +97,8 @@ def download_project(self, project_id, destination): project = self.client.projects.get(project_id) initial_tree = self.get_assets_recursively(project["root_asset_id"]) self.recursive_downloader(destination, initial_tree) - # pprint(initial_tree) - # print(f"Downloading {Utils.format_bytes(total_bytes, type='size')}") - def recursive_downloader(self, directory, asset, count=0): + def recursive_downloader(self, directory, asset, manifest=[]): print(f"Directory {directory}") try: @@ -121,7 +119,7 @@ def recursive_downloader(self, directory, asset, count=0): try: if asset["_type"] == "folder": if len(asset["children"]) >= 0: - count += 1 + # count += 1 # Create the new folder that these items will go in before it's too late if not os.path.exists( os.path.join(target_directory, asset["name"]) @@ -139,17 +137,25 @@ def recursive_downloader(self, directory, asset, count=0): self.recursive_downloader( f"{directory}/{str(asset['name']).replace('/', '-')}", asset["children"], + manifest ) if asset["_type"] == "file": - count += 1 - return self.client.assets.download( + # count += 1 + fn = self.client.assets.download( asset, target_directory, multi_part=True ) + manifest.append({ + "asset_id": asset['id'], + "file_path": fn, + "directory": target_directory + }) + except Exception as e: print(e) + pprint(manifest) return True