(task, assets, custom_assets)
| 10 | |
| 11 | |
| 12 | def get_resources(task, assets, custom_assets): |
| 13 | if assets not in ["all", "backup", "custom"]: |
| 14 | raise exceptions.ValidationError({"assets": "Invalid"}) |
| 15 | if assets == "custom": |
| 16 | INCLUDE_ALWAYS = ["cameras.json", "shots.geojson", "ground_control_points.geojson"] |
| 17 | if not isinstance(custom_assets, list): |
| 18 | raise exceptions.ValidationError({"customAssets": "Invalid"}) |
| 19 | |
| 20 | if len(custom_assets) > 0: |
| 21 | custom_assets = list(set(custom_assets) | set(INCLUDE_ALWAYS)) |
| 22 | else: |
| 23 | custom_assets = [] |
| 24 | |
| 25 | resources = [] |
| 26 | base_path = task.assets_path() |
| 27 | |
| 28 | if assets == "all": |
| 29 | resources.append(base_path) |
| 30 | elif assets == "backup": |
| 31 | base_path = task.task_path() |
| 32 | resources.append(base_path) |
| 33 | elif assets == "custom": |
| 34 | for asset in custom_assets: |
| 35 | try: |
| 36 | file = task.get_asset_download_path(asset) |
| 37 | except FileNotFoundError: |
| 38 | raise exceptions.ValidationError({"customAssets": "Invalid"}) |
| 39 | |
| 40 | if os.path.isfile(file): |
| 41 | resources.append(file) |
| 42 | |
| 43 | # Include EPT folder if available |
| 44 | if asset == "georeferenced_model.laz": |
| 45 | ept_dir = task.assets_path("entwine_pointcloud") |
| 46 | if os.path.isdir(ept_dir): |
| 47 | resources.append(ept_dir) |
| 48 | |
| 49 | # Include entire texturing folder (GLB + OBJ) |
| 50 | if asset == "textured_model.zip": |
| 51 | tex_dir = task.assets_path("odm_texturing") |
| 52 | if os.path.isdir(tex_dir): |
| 53 | resources.append(tex_dir) |
| 54 | |
| 55 | return resources, base_path |
| 56 | |
| 57 | def get_size_bytes(resources): |
| 58 | total_bytes = 0 |
no test coverage detected