Skip to content

Instantly share code, notes, and snippets.

@mvandenburgh
Last active January 17, 2022 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mvandenburgh/6c9b284b6bf2b684b43236fe0da35a93 to your computer and use it in GitHub Desktop.
Save mvandenburgh/6c9b284b6bf2b684b43236fe0da35a93 to your computer and use it in GitHub Desktop.
from tempfile import TemporaryFile
from django.core.files import File
from django.db import transaction
from django.urls import reverse
import djclick as click
import requests
from rgd.models import ChecksumFile
from rgd_imagery.models import Image, ImageSet, Raster
from rgd_imagery.tasks import task_populate_raster
@click.command()
def reproduce_file_path_bug():
filename = 'buildings-to-dsm/buildings_to_dsm_CLS.tif'
resp = requests.get('https://data.kitware.com/api/v1/item/61e5c7ce4acac99f42575dc0/download')
with TemporaryFile() as fd:
fd.write(resp.content)
chksm_file = ChecksumFile.objects.create(name=filename, file=File(fd))
img = Image.objects.create(file=chksm_file)
img_set = ImageSet.objects.create(name=filename)
img_set.images.set([img])
Raster.objects.create(name=filename, image_set=img_set)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment