def create_root_vdn_dataset(s3export, server, headers, name, description): new_dataset = { 'root': True, 'aws_requester_pays': True, 'aws_region': s3export.region, 'aws_bucket': s3export.bucket, 'aws_key': s3export.key, 'name': name, 'description': description } server_url = server.url if not server_url.endswith('/'): server_url += '/' r = requests.post("{}api/datasets/".format(server_url), data=new_dataset, headers=headers) if r.status_code == 201: vdn_dataset = VDNDataset() vdn_dataset.url = r.json()['url'] vdn_dataset.root = True vdn_dataset.response = r.text vdn_dataset.server = server vdn_dataset.save() s3export.video.vdn_dataset = vdn_dataset return vdn_dataset else: raise ValueError, "Could not crated dataset"
def create_child_vdn_dataset(parent_video, server, headers): server_url = server.url if not server_url.endswith('/'): server_url += '/' new_dataset = { 'root': False, 'parent_url': parent_video.vdn_dataset.url, 'description': 'automatically created child' } r = requests.post("{}api/datasets/".format(server_url), data=new_dataset, headers=headers) if r.status_code == 201: vdn_dataset = VDNDataset() vdn_dataset.url = r.json()['url'] vdn_dataset.root = False vdn_dataset.response = r.text vdn_dataset.server = server vdn_dataset.parent_local = parent_video.vdn_dataset vdn_dataset.save() return vdn_dataset else: raise ValueError, "{} {} {} {}".format( "{}api/datasets/".format(server_url), headers, r.status_code, new_dataset)
def create_dataset(d, server): dataset = VDNDataset() dataset.server = server dataset.name = d['name'] dataset.description = d['description'] dataset.download_url = d['download_url'] dataset.url = d['url'] dataset.aws_bucket = d['aws_bucket'] dataset.aws_key = d['aws_key'] dataset.aws_region = d['aws_region'] dataset.aws_requester_pays = d['aws_requester_pays'] dataset.organization_url = d['organization']['url'] dataset.response = json.dumps(d) dataset.save() return dataset
def create_child_vdn_dataset(parent_video, server, headers): server_url = server.url if not server_url.endswith('/'): server_url += '/' new_dataset = {'root': False, 'parent_url': parent_video.vdn_dataset.url, 'description': 'automatically created child'} r = requests.post("{}api/datasets/".format(server_url), data=new_dataset, headers=headers) if r.status_code == 201: vdn_dataset = VDNDataset() vdn_dataset.url = r.json()['url'] vdn_dataset.root = False vdn_dataset.response = r.text vdn_dataset.server = server vdn_dataset.parent_local = parent_video.vdn_dataset vdn_dataset.save() return vdn_dataset else: raise ValueError, "{} {} {} {}".format("{}api/datasets/".format(server_url), headers, r.status_code, new_dataset)
def create_root_vdn_dataset(s3export, server, headers, name, description): new_dataset = {'root': True, 'aws_requester_pays': True, 'aws_region': s3export.region, 'aws_bucket': s3export.bucket, 'aws_key': s3export.key, 'name': name, 'description': description } server_url = server.url if not server_url.endswith('/'): server_url += '/' r = requests.post("{}api/datasets/".format(server_url), data=new_dataset, headers=headers) if r.status_code == 201: vdn_dataset = VDNDataset() vdn_dataset.url = r.json()['url'] vdn_dataset.root = True vdn_dataset.response = r.text vdn_dataset.server = server vdn_dataset.save() s3export.video.vdn_dataset = vdn_dataset return vdn_dataset else: raise ValueError, "Could not crated dataset"