Example #1
0
    def create_mark(self, report):
        if MarkUnknown.objects.filter(
                component=report.component,
                problem_pattern=self._args['problem']).count() > 0:
            raise BridgeException(
                _('Could not create a new mark since the similar mark exists already'
                  ))

        mark = MarkUnknown.objects.create(
            identifier=unique_id(),
            author=self._user,
            change_date=now(),
            format=report.root.job.format,
            job=report.root.job,
            description=str(self._args.get('description', '')),
            status=self._args['status'],
            is_modifiable=self._args['is_modifiable'],
            component=report.component,
            function=self._args['function'],
            problem_pattern=self._args['problem'],
            link=self._args['link'],
            is_regexp=self._args['is_regexp'])
        try:
            markversion = self.__create_version(mark)
            self.__create_attributes(markversion.id, report)
        except Exception:
            mark.delete()
            raise
        self.changes = ConnectMark(mark, prime_id=report.id).changes
        return mark
Example #2
0
    def upload_mark(self):
        if 'format' not in self._args:
            raise BridgeException(_('Safe mark format is required'))
        if isinstance(self._args.get('identifier'),
                      str) and 0 < len(self._args['identifier']) < 255:
            if MarkSafe.objects.filter(
                    identifier=self._args['identifier']).count() > 0:
                raise BridgeException(
                    _("The mark with identifier specified in the archive already exists"
                      ))
        else:
            self._args['identifier'] = unique_id()
        mark = MarkSafe.objects.create(
            identifier=self._args['identifier'],
            author=self._user,
            change_date=now(),
            format=self._args['format'],
            type=MARK_TYPE[2][0],
            status=self._args['status'],
            description=str(self._args.get('description', '')),
            is_modifiable=self._args['is_modifiable'],
            verdict=self._args['verdict'])

        try:
            markversion = self.__create_version(mark)
            self.__create_attributes(markversion.id)
        except Exception:
            mark.delete()
            raise
        return mark
Example #3
0
 def __add_password(self, user, password):
     self.__is_not_used()
     if isinstance(password, str):
         password = password.strip()
     if not isinstance(password, str) or len(password) == 0:
         password = unique_id()[:8]
     user.set_password(password)
     user.save()
     return password
Example #4
0
    def __save_data(self, user):
        try:
            cache = MarkAssociationsChanges.objects.get(user=user)
        except ObjectDoesNotExist:
            cache = MarkAssociationsChanges(user=user)
        cache.identifier = unique_id()

        cache.table_data = json.dumps({
            'href': reverse('marks:mark', args=[self.mark_type, self.mark.pk]),
            'values': self.values, 'attrs': self.attrs
        }, ensure_ascii=False, sort_keys=True, indent=2)
        cache.save()
        return cache.identifier
Example #5
0
    def __create_unsafe_reports(self, identifier):
        et_archs = {}
        for arch_name in self.data['error traces']:
            et_archs[arch_name] = self.archives[arch_name]
        res = CheckErrorTraces(et_archs, self.archives[self.data['sources']])

        source = ErrorTraceSource(root=self.root)
        source.add_sources(REPORT_ARCHIVE['sources'],
                           self.archives[self.data['sources']], True)

        cnt = 1
        unsafes = []
        for arch_name in self.data['error traces']:
            try:
                ReportUnsafe.objects.get(identifier=identifier +
                                         '/{0}'.format(cnt))
                raise ValueError(
                    'the report with specified identifier already exists')
            except ObjectDoesNotExist:
                if self.parent.cpu_time is None:
                    raise ValueError(
                        'unsafe parent need to be verification report and must have cpu_time'
                    )
                report = ReportUnsafe(identifier=identifier +
                                      '/{0}'.format(cnt),
                                      parent=self.parent,
                                      root=self.root,
                                      trace_id=unique_id(),
                                      source=source,
                                      cpu_time=self.parent.cpu_time,
                                      wall_time=self.parent.wall_time,
                                      memory=self.parent.memory)

            report.add_trace(REPORT_ARCHIVE['error trace'],
                             self.archives[arch_name], True)
            if not os.path.exists(
                    os.path.join(settings.MEDIA_ROOT,
                                 report.error_trace.name)):
                report.delete()
                raise CheckArchiveError(
                    'Report archive "error trace" was not saved')

            self.__create_leaf_attrs(report, res.add_attrs.get(arch_name))
            unsafes.append(report)
            cnt += 1
        self.__fill_unsafes_cache(unsafes)
Example #6
0
 def upload_mark(self):
     if 'component' not in self._args or len(self._args['component']) == 0:
         raise BridgeException(_("Component name is required"))
     if len(self._args['component']) > 15:
         raise BridgeException(_("Component name is too long"))
     component = Component.objects.get_or_create(
         name=self._args['component'])[0]
     if 'format' not in self._args:
         raise BridgeException(_('Unknown mark format is required'))
     if isinstance(self._args.get('identifier'),
                   str) and 0 < len(self._args['identifier']) < 255:
         if MarkUnknown.objects.filter(
                 identifier=self._args['identifier']).count() > 0:
             raise BridgeException(
                 _("The mark with identifier specified in the archive already exists"
                   ))
     else:
         self._args['identifier'] = unique_id()
     if MarkUnknown.objects.filter(
             component=component,
             problem_pattern=self._args['problem']).count() > 0:
         raise BridgeException(
             _('Could not upload the mark since it would be similar to the existing mark'
               ))
     mark = MarkUnknown.objects.create(
         identifier=self._args['identifier'],
         author=self._user,
         change_date=now(),
         description=str(self._args.get('description', '')),
         status=self._args['status'],
         is_modifiable=self._args['is_modifiable'],
         problem_pattern=self._args['problem'],
         function=self._args['function'],
         link=self._args['link'],
         component=component,
         format=self._args['format'],
         type=MARK_TYPE[2][0],
         is_regexp=self._args['is_regexp'])
     try:
         markversion = self.__create_version(mark)
         self.__create_attributes(markversion.id)
     except Exception:
         mark.delete()
         raise
     return mark
Example #7
0
    def create_mark(self, report):
        mark = MarkSafe.objects.create(
            identifier=unique_id(),
            author=self._user,
            change_date=now(),
            format=report.root.job.format,
            job=report.root.job,
            status=self._args['status'],
            description=str(self._args.get('description', '')),
            is_modifiable=self._args['is_modifiable'],
            verdict=self._args['verdict'])

        try:
            markversion = self.__create_version(mark)
            self.__create_attributes(markversion.id, report)
        except Exception:
            mark.delete()
            raise
        self.changes = ConnectMarks([mark], prime_id=report.id).changes.get(
            mark.id, {})
        self.__get_tags_changes(RecalculateTags(list(self.changes)).changes)
        update_confirmed_cache([report])
        return mark
Example #8
0
def add_unique_trace_id(apps, schema_editor):
    for unsafe in apps.get_model("reports", "ReportUnsafe").objects.all():
        unsafe.trace_id = unique_id()
        unsafe.save()
        time.sleep(0.1)