Exemple #1
0
 def fetch(self):
     try:
         if not self.uid:
             self.uid = get_uid()
         for main_run in Run.objects.filter(Q(hwaddr=self.hwaddr, rerun=True) | Q(hwaddr=None)):
             #syslog.syslog(syslog.LOG_DEBUG, 'main: ' + str(main_run))
             i = 0
             task = main_run.task
             main_run_id = main_run.pk
             my_previous_runs = Run.objects.filter(hwaddr=self.hwaddr, task=task, rerun=False)
             #syslog.syslog(syslog.LOG_DEBUG, 'prev: ' + str(my_previous_runs))
             if (not main_run.hwaddr and my_previous_runs) or (main_run.hwaddr and my_previous_runs and any(map(lambda prev: prev.id > main_run.id, my_previous_runs))):
                 continue
             my_run = Run(task_id=main_run.task.pk, hwaddr=self.hwaddr, ip=self.ip, uid=self.uid, start=datetime.now(tz(config.path.time_difference)).replace(tzinfo=None))
             my_run.save()
             _id = "%s_%04d_%s" % (task.name, my_run.pk, self.ip)
             _cmd = ['python2.7', config.path.pybot, '--critical', 'critical', '--pythonpath', "%s:%s" % (config.path.listener_path, config.path.suits_path), '--listener',
                     "%(module)s:%(run_id)s:%(uid)s" % {'module': config.path.listener, 'run_id': my_run.pk, 'uid': self.uid}]
             _suites = set()
             for test in task.tests.all():
                 _cmd += ['--test', test.name]
                 _suites.add(test.suite.path)
             _outputdir = my_run.path_to_results
             _cmd += ['--outputdir', _outputdir]
             _cmd += _suites
             if not os.path.isdir(_outputdir):
                 os.mkdir(_outputdir)
             Task(self, my_run.pk, on_exit, (_cmd, 0, None, None, subprocess.PIPE, subprocess.PIPE))
     except Exception, e:
         syslog.syslog(syslog.LOG_DEBUG, "Cannot fetch tasks: %s, %s" % (e.message, e.args))
Exemple #2
0
def start_tasks(request, selected):
    dajax = Dajax()
    main_runs = Run.objects.filter(task__in=map(int, selected), hwaddr=None).delete()
    runs = Run.objects.filter(task__in=map(int, selected)).update(rerun=True)
    for task_id in map(int, selected):
        new_run = Run(start=datetime.now(), task=Task.objects.get(id=task_id), hwaddr=None)
        new_run.save()
    dajax.redirect('/tasks/')
    return dajax.json()
Exemple #3
0
 def fetch(self):
     try:
         if not self.uid:
             self.uid = get_uid()
         for main_run in Run.objects.filter(
                 Q(hwaddr=self.hwaddr, rerun=True) | Q(hwaddr=None)):
             #syslog.syslog(syslog.LOG_DEBUG, 'main: ' + str(main_run))
             i = 0
             task = main_run.task
             main_run_id = main_run.pk
             my_previous_runs = Run.objects.filter(hwaddr=self.hwaddr,
                                                   task=task,
                                                   rerun=False)
             #syslog.syslog(syslog.LOG_DEBUG, 'prev: ' + str(my_previous_runs))
             if (not main_run.hwaddr and my_previous_runs) or (
                     main_run.hwaddr and my_previous_runs and any(
                         map(lambda prev: prev.id > main_run.id,
                             my_previous_runs))):
                 continue
             my_run = Run(
                 task_id=main_run.task.pk,
                 hwaddr=self.hwaddr,
                 ip=self.ip,
                 uid=self.uid,
                 start=datetime.now(tz(
                     config.path.time_difference)).replace(tzinfo=None))
             my_run.save()
             _id = "%s_%04d_%s" % (task.name, my_run.pk, self.ip)
             _cmd = [
                 'python2.7', config.path.pybot, '--critical', 'critical',
                 '--pythonpath',
                 "%s:%s" %
                 (config.path.listener_path, config.path.suits_path),
                 '--listener',
                 "%(module)s:%(run_id)s:%(uid)s" % {
                     'module': config.path.listener,
                     'run_id': my_run.pk,
                     'uid': self.uid
                 }
             ]
             _suites = set()
             for test in task.tests.all():
                 _cmd += ['--test', test.name]
                 _suites.add(test.suite.path)
             _outputdir = my_run.path_to_results
             _cmd += ['--outputdir', _outputdir]
             _cmd += _suites
             if not os.path.isdir(_outputdir):
                 os.mkdir(_outputdir)
             Task(self, my_run.pk, on_exit,
                  (_cmd, 0, None, None, subprocess.PIPE, subprocess.PIPE))
     except Exception, e:
         syslog.syslog(syslog.LOG_DEBUG,
                       "Cannot fetch tasks: %s, %s" % (e.message, e.args))
Exemple #4
0
def start_tasks(request, selected):
    dajax = Dajax()
    main_runs = Run.objects.filter(task__in=map(int, selected),
                                   hwaddr=None).delete()
    runs = Run.objects.filter(task__in=map(int, selected)).update(rerun=True)
    for task_id in map(int, selected):
        new_run = Run(start=datetime.now(),
                      task=Task.objects.get(id=task_id),
                      hwaddr=None)
        new_run.save()
    dajax.redirect('/tasks/')
    return dajax.json()
Exemple #5
0
def create_task(request, name, suite_id, test_ids, comment, run):
    if not suite_id:
        return
    dajax = Dajax()
    test_ids = filter(lambda x: bool(x) == True, test_ids.split(','))
    task = Task(suite=Suite.objects.get(id__exact=(int(suite_id))), name=name, comment=comment)
    task.save()
    task.tests.add(*Test.objects.filter(id__in=test_ids))
    task.save()
    _xml = ""
    for test in test_ids:
        _xml += "<test name='%s' />\n" % test
    dajax.assign('#preview', 'rows', len(_xml.split('/')) + 1)
    dajax.assign('#preview', 'cols', max(map(len, _xml.split('/'))) + 1)
    dajax.assign('#preview', 'innerText', _xml)
    if run:
        run = Run(start=datetime.now(), task=task, hwaddr=None)
        run.save()
    return dajax.json()
Exemple #6
0
def create_task(request, name, suite_id, test_ids, comment, run):
    if not suite_id:
        return
    dajax = Dajax()
    test_ids = filter(lambda x: bool(x) == True, test_ids.split(','))
    task = Task(suite=Suite.objects.get(id__exact=(int(suite_id))),
                name=name,
                comment=comment)
    task.save()
    task.tests.add(*Test.objects.filter(id__in=test_ids))
    task.save()
    _xml = ""
    for test in test_ids:
        _xml += "<test name='%s' />\n" % test
    dajax.assign('#preview', 'rows', len(_xml.split('/')) + 1)
    dajax.assign('#preview', 'cols', max(map(len, _xml.split('/'))) + 1)
    dajax.assign('#preview', 'innerText', _xml)
    if run:
        run = Run(start=datetime.now(), task=task, hwaddr=None)
        run.save()
    return dajax.json()