def ingestFolder(request): from celery.canvas import chain from vsi.tools.dir_util import mkdtemp import voxel_globe.ingest.tasks uploadSession_id = request.POST['uploadSession'] #directories = models.Directory.objects.filter(uploadSession_id = uploadSession_id) #Code not quite done, using failsafe for now. uploadSession = models.UploadSession.objects.get(id=uploadSession_id) sessionDir = os.path.join(os.environ['VIP_TEMP_DIR'], 'ingest', str(uploadSession.id)) #imageDir = os.path.join(os.environ['VIP_IMAGE_SERVER_ROOT'], str(uploadSession.id)) #if os.path.exists(imageDir): imageDir = mkdtemp(dir=os.environ['VIP_IMAGE_SERVER_ROOT'], prefix='img') task0 = voxel_globe.ingest.tasks.move_data.si(sessionDir, imageDir) task1 = PAYLOAD_TYPES[uploadSession.payload_type].ingest.si( uploadSession_id, imageDir) task2 = METADATA_TYPES[uploadSession.metadata_type].ingest.s( uploadSession_id, imageDir) task3 = voxel_globe.ingest.tasks.cleanup.si(uploadSession_id) tasks = task0 | task1 | task2 | task3 #create chain result = tasks.apply_async() return render(request, 'ingest/html/ingest_started.html', {'task_id': result.task_id})
def ingestFolder(request): from celery.canvas import chain from vsi.tools.dir_util import mkdtemp import voxel_globe.ingest.tasks uploadSession_id = request.POST['uploadSession'] #directories = models.Directory.objects.filter(uploadSession_id = uploadSession_id) #Code not quite done, using failsafe for now. uploadSession = models.UploadSession.objects.get(id=uploadSession_id); sessionDir = os.path.join(os.environ['VIP_TEMP_DIR'], 'ingest', str(uploadSession.id)) #imageDir = os.path.join(os.environ['VIP_IMAGE_SERVER_ROOT'], str(uploadSession.id)) #if os.path.exists(imageDir): imageDir = mkdtemp(dir=os.environ['VIP_IMAGE_SERVER_ROOT'], prefix='img'); task0 = voxel_globe.ingest.tasks.move_data.si(sessionDir, imageDir) task1 = PAYLOAD_TYPES[uploadSession.payload_type].ingest.si(uploadSession_id, imageDir) task2 = METADATA_TYPES[uploadSession.metadata_type].ingest.s(uploadSession_id, imageDir) task3 = voxel_globe.ingest.tasks.cleanup.si(uploadSession_id) tasks = task0 | task1 | task2 | task3 #create chain result = tasks.apply_async() return render(request, 'ingest/html/ingest_started.html', {'task_id':result.task_id})
def ingestFolderControlpoint(request): import json from celery.canvas import chain from vsi.tools.dir_util import mkdtemp import voxel_globe.ingest.tasks from .controlpoint.tasks import ControlPointTypes uploadSession_id = request.POST['uploadSession'] #directories = models.Directory.objects.filter(uploadSession_id = uploadSession_id) #Code not quite done, using failsafe for now. uploadSession = models.UploadSession.objects.get(id=uploadSession_id) upload_types = json.loads(uploadSession.upload_types) controlpoint_type = upload_types['controlpoint_type'] sessionDir = os.path.join(os.environ['VIP_TEMP_DIR'], 'ingest_controlpoint', str(uploadSession.id)) with voxel_globe.tools.storage_dir('ingest_control_points') as data_dir: distutils.dir_util.copy_tree(sessionDir, data_dir) distutils.dir_util.remove_tree(sessionDir) task1 = ControlPointTypes[controlpoint_type].ingest.si(uploadSession_id, data_dir) task3 = voxel_globe.ingest.tasks.cleanup.si(uploadSession_id) tasks = task1 | task3 #create chain result = tasks.apply_async(user=request.user) return redirect('/')
def ingestFolder(request): import json from celery.canvas import chain from vsi.tools.dir_util import mkdtemp import voxel_globe.ingest.tasks uploadSession_id = request.POST['uploadSession'] #directories = models.Directory.objects.filter(uploadSession_id = uploadSession_id) #Code not quite done, using failsafe for now. uploadSession = models.UploadSession.objects.get(id=uploadSession_id) upload_types = json.loads(uploadSession.upload_types) controlpoint_type = upload_types['controlpoint_type'] sessionDir = os.path.join(os.environ['VIP_TEMP_DIR'], 'ingest_controlpoint', str(uploadSession.id)) task1 = CONTROLPOINT_TYPES[controlpoint_type].ingest.si( uploadSession_id, sessionDir) task3 = voxel_globe.ingest.tasks.cleanup.si(uploadSession_id) tasks = task1 | task3 #create chain result = tasks.apply_async() return render(request, 'ingest_controlpoint/html/ingest_started.html', {'task_id': result.task_id})
def ingestFolderControlpoint(request): import json from celery.canvas import chain from vsi.tools.dir_util import mkdtemp import voxel_globe.ingest.tasks from .controlpoint.tasks import ControlPointTypes uploadSession_id = request.POST['uploadSession'] #directories = models.Directory.objects.filter(uploadSession_id = uploadSession_id) #Code not quite done, using failsafe for now. uploadSession = models.UploadSession.objects.get(id=uploadSession_id) upload_types = json.loads(uploadSession.upload_types) controlpoint_type = upload_types['controlpoint_type'] sessionDir = os.path.join(os.environ['VIP_TEMP_DIR'], 'ingest_controlpoint', str(uploadSession.id)) with voxel_globe.tools.storage_dir('ingest_control_points') as data_dir: distutils.dir_util.copy_tree(sessionDir, data_dir) distutils.dir_util.remove_tree(sessionDir) task1 = ControlPointTypes[controlpoint_type].ingest.si( uploadSession_id, data_dir) task3 = voxel_globe.ingest.tasks.cleanup.si(uploadSession_id) tasks = task1 | task3 #create chain result = tasks.apply_async(user=request.user) return redirect('/')
def ingestFolderImage(request): from celery.canvas import chain from vsi.tools.dir_util import mkdtemp import voxel_globe.ingest.tasks import voxel_globe.tools import distutils.dir_util from .metadata.tasks import MetadataTypes from .payload.tasks import PayloadTypes uploadSession_id = request.POST['uploadSession'] #directories = models.Directory.objects.filter(uploadSession_id = uploadSession_id) #Code not quite done, using failsafe for now. uploadSession = models.UploadSession.objects.get(id=uploadSession_id) # print 'Upload session id: ' # print os.path.join(os.environ['VIP_TEMP_DIR'], 'ingest', str(uploadSession.id)) sessionDir = os.path.join(os.environ['VIP_TEMP_DIR'], 'ingest', str(uploadSession.id)) with voxel_globe.tools.storage_dir('ingest') as imageDir: #task0 = voxel_globe.ingest.tasks.move_data.si(sessionDir, imageDir) distutils.dir_util.copy_tree(sessionDir, imageDir) distutils.dir_util.remove_tree(sessionDir) # for dirpath, subdirs, files in os.walk(imageDir): # for f in files: # print f task1 = PayloadTypes[uploadSession.payload_type].ingest.si( uploadSession_id, imageDir) task2 = MetadataTypes[uploadSession.metadata_type].ingest.s( uploadSession_id, imageDir) task3 = voxel_globe.ingest.tasks.cleanup.si(uploadSession_id) tasks = task1 | task2 | task3 #create chain result = tasks.apply_async(user=request.user) return redirect('/')
def ingestFolderImage(request): from celery.canvas import chain from vsi.tools.dir_util import mkdtemp import voxel_globe.ingest.tasks import voxel_globe.tools import distutils.dir_util from .metadata.tasks import MetadataTypes from .payload.tasks import PayloadTypes uploadSession_id = request.POST['uploadSession'] #directories = models.Directory.objects.filter(uploadSession_id = uploadSession_id) #Code not quite done, using failsafe for now. uploadSession = models.UploadSession.objects.get(id=uploadSession_id) # print 'Upload session id: ' # print os.path.join(os.environ['VIP_TEMP_DIR'], 'ingest', str(uploadSession.id)) sessionDir = os.path.join(os.environ['VIP_TEMP_DIR'], 'ingest', str(uploadSession.id)) with voxel_globe.tools.storage_dir('ingest') as imageDir: #task0 = voxel_globe.ingest.tasks.move_data.si(sessionDir, imageDir) distutils.dir_util.copy_tree(sessionDir, imageDir) distutils.dir_util.remove_tree(sessionDir) # for dirpath, subdirs, files in os.walk(imageDir): # for f in files: # print f task1 = PayloadTypes[uploadSession.payload_type].ingest.si(uploadSession_id, imageDir) task2 = MetadataTypes[uploadSession.metadata_type].ingest.s(uploadSession_id, imageDir) task3 = voxel_globe.ingest.tasks.cleanup.si(uploadSession_id) tasks = task1 | task2 | task3 #create chain result = tasks.apply_async(user=request.user) return redirect('/')