def test_uuidparse(self): self.assertEqual( uuidparse('4a6e4a20-fd8f-4e2a-9808-4ed612b1f0d0.mov'), '4a6e4a20-fd8f-4e2a-9808-4ed612b1f0d0') self.assertEqual( uuidparse('not a uuid'), '')
def post(self, request): if 'title' not in request.POST: transaction.commit() return HttpResponse("expecting a title") title = request.POST.get('title', 'no title') ouuid = uuidparse(title) r = Operation.objects.filter(uuid=ouuid) if r.count() != 1: transaction.commit() return HttpResponse("could not find an operation with that UUID") statsd.incr('main.done') operations = [] params = dict() try: operation = r[0] operation.status = "complete" operation.save() operation.log(info="PCP completed") cunix_path = request.POST.get('movie_destination_path', '') make_cunix_file(operation, cunix_path) (operations, params) = handle_mediathread_submit(operation) except: statsd.incr('main.upload.failure') transaction.rollback() raise finally: transaction.commit() for o in operations: tasks.process_operation.delay(o, params) return HttpResponse("ok")
def handle(self, *args, **options): file_list = args[0] for line in open(file_list, "r"): filename = line.strip() try: uuid = uuidparse(filename) operation = Operation.objects.get(uuid=uuid) destination = operation.video.cuit_file().filename print "mv %s %s" % (destination, os.path.join(TMP_DIR, filename)) print "mv %s %s" % (os.path.join(HELIX_DIR, filename), destination) except Exception, e: print str(e)
def post(self, request): if 'title' not in request.POST: return HttpResponse("expecting a title") statsd.incr('main.received') title = request.POST.get('title', 'no title') ruuid = uuidparse(title) r = Operation.objects.filter(uuid=ruuid) if r.count() == 1: operation = r[0] if operation.video.is_mediathread_submit(): send_mediathread_received_mail(operation.video.title, operation.owner.username) else: statsd.incr('main.received_failure') return HttpResponse("ok")
def post(self, request): if 'title' not in request.POST: return HttpResponse("expecting a title") title = request.POST.get('title', 'no title') uuid = uuidparse(title) r = Operation.objects.filter(uuid=uuid) if r.count() == 1: statsd.incr('main.posterdone') operation = r[0] cunix_path = request.POST.get('image_destination_path', '') poster_url = cunix_path.replace( settings.CUNIX_BROADCAST_DIRECTORY, settings.CUNIX_BROADCAST_URL) File.objects.create(video=operation.video, label="CUIT thumbnail image", url=poster_url, location_type='cuitthumb') return HttpResponse("ok")