def on_get(self, req, resp, tid): user_id = req.context['user'] logger.debug('Authorize user {id}'.format(id=user_id)) try: context = {'user_id': user_id} task = metadata.get_task(tid, context) except metadata.DoesNotExist: logger.debug('Task {id} does not exist'.format(id=id)) raise falcon.HTTPNotFound( title="Task not found", description="Task metadata does not exist") if 'result' not in task.history: raise falcon.HTTPNotFound(title='Task is not completed', description='Task is not completed') temp_id = task.history['result'] temp_path = storage.get_dataset_path(temp_id, prefix='tmp') resp.status = falcon.HTTP_200 resp.content_type = 'application/octet-stream' resp.stream_len = os.path.getsize(temp_path) resp.stream = open(temp_path, 'rb')
def on_get(self, req, resp, tid): user_id = req.context['user'] logger.debug('Authorize user {id}'.format(id=user_id)) try: context = {'user_id': user_id} task = metadata.get_task(tid, context) except metadata.DoesNotExist: logger.debug('Task {id} does not exist'.format(id=id)) raise falcon.HTTPNotFound( title="Task not found", description="Task metadata does not exist") resp.status = falcon.HTTP_200 resp.media = {'id': tid, 'config': task.config}
def on_get(self, req, resp, tid): user_id = req.context['user'] logger.debug('Authorize user {id}'.format(id=user_id)) try: context = {'user_id': user_id} task = metadata.get_task(tid, context) except metadata.DoesNotExist: logger.debug('Task {id} does not exist'.format(id=id)) raise falcon.HTTPNotFound( title="Task not found", description="Task metadata does not exist") if task.status in (metadata.task.SUCCESS, metadata.task.FAILURE): resp.status = falcon.HTTP_201 else: resp.status = falcon.HTTP_200 resp.media = task.history
def on_get(self, req, resp, id): user_id = req.context['user'] logger.debug('Authorize user {id}'.format(id=user_id)) try: context = {'user_id': user_id} task = metadata.get_task(id, context) except metadata.DoesNotExist: logger.debug('Task {id} does not exist'.format(id=id)) task = None if task: resp.status = falcon.HTTP_200 task_dict = task.to_dict() result_keys = ['id', 'status', 'command', 'date', 'config'] resp.media = { key: task_dict[key] for key in result_keys if key in task_dict } else: raise falcon.HTTPNotFound( title="Task not found", description="Task metadata does not exist")