How to use the kobo.hub.models.Task function in kobo

To help you get started, we’ve selected a few kobo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github release-engineering / kobo / tests / test_xmlrpc_worker.py View on Github external
def test_check_wait_without_subtasks(self):
        t = Task.objects.create(
            worker=self._worker,
            arch=self._arch,
            channel=self._channel,
            owner=self._user,
            state=TASK_STATES['FREE'],
        )

        req = _make_request(self._worker)
        finished, unfinished = worker.check_wait(req, t.id)
        self.assertEqual(len(finished), 0)
        self.assertEqual(len(unfinished), 0)
github release-engineering / kobo / tests / test_xmlrpc_client.py View on Github external
def test_cancel_task(self):
        task_id = Task.create_task(self._user.username, 'task', 'method')
        ret = client.cancel_task(_make_request(), task_id)
        self.assertIsNone(ret)

        t = Task.objects.get(id=task_id)
        self.assertEqual(t.state, TASK_STATES['CANCELED'])
github release-engineering / kobo / tests / test_forms.py View on Github external
def test_get_query_search_filter_authenticated(self):
        task = Task.objects.create(
            worker=self._worker,
            arch=self._arch,
            channel=self._channel,
            owner=self._user,
            method='TaskMethod',
            label='Task 1',
            state=TASK_STATES['FREE'],
        )

        Task.objects.create(
            worker=self._worker,
            arch=self._arch,
            channel=self._channel,
            owner=self._user,
            method='TaskMethod',
            label='Task 2',
github release-engineering / kobo / tests / test_models.py View on Github external
def test_time_task_not_started(self):
        t = Task(dt_started=None, dt_finished=None)
        self.assertIsNone(t.time)
github release-engineering / kobo / tests / test_models.py View on Github external
def _create_task(self, **kwargs):
        params = {
            'worker': self._worker,
            'arch': self._arch,
            'channel': self._channel,
            'owner': self._user,
            'method': 'DummyTask',
            'state': TASK_STATES['FREE'],
        }

        params.update(kwargs)

        return Task.objects.create(**params)
github release-engineering / kobo / tests / test_models.py View on Github external
def test_get_time_display_task_not_started(self):
        t = Task(dt_started=None, dt_finished=None)
        self.assertEquals(t.get_time_display(), '')
github release-engineering / kobo / kobo / hub / forms.py View on Github external
query = Q()

        if search:
            query |= Q(method__icontains=search)
            query |= Q(owner__username__icontains=search)
            query |= Q(label__icontains=search)

        if my and call_if_callable(request.user.is_authenticated):
            query &= Q(owner=request.user)

        if self.state is not None:
            query &= Q(state__in=self.state)
        #if self.kwargs:
        #    query &= Q(self.kwargs)
        return Task.objects.filter(parent__isnull=True).filter(query).order_by(*self.order_by).defer("result", "args").select_related("owner", "worker")
github release-engineering / kobo / kobo / hub / xmlrpc / client.py View on Github external
def shutdown_worker(request, worker_name, kill=False):
    """shutdown_worker(worker_name, kill): None

    Send shutdown request to a worker.
    If kill argument is set to True, kill worker immediately,
    otherwise wait until all tasks assigned to the are finished.
    """
    return models.Task.create_shutdown_task(request.user.username, worker_name, kill=kill)
github release-engineering / kobo / kobo / hub / models.py View on Github external
def __init__(self, *args, **kwargs):
        self.logs = TaskLogs(self)
        traceback = kwargs.pop("traceback", None)
        if traceback:
            self.logs["traceback.log"] = traceback

        stdout = kwargs.pop("stdout", None)
        if stdout:
            self.logs["stdout.log"] = stdout

        super(Task, self).__init__(*args, **kwargs)