Exemplo n.º 1
0
 def get_bugs(self, **kwargs):
     """
     Do the actual work of getting bugs from the BZ API
     :return: set
     """
     bugs = {}
     try:
         args = self._get_bz_args()
         args = dict((k.encode('utf-8'), v) for k, v in
                     args.iterlists())
         bzkwargs = {}
         if 'bug_id' in args:
             bzkwargs['ids'] = [int(bid) for bid in
                                args['bug_id'][0].split(',')]
         else:
             for item in ['product', 'component']:
                 items = args.get(item)
                 if items:
                     bzkwargs[item] = items
         if bzkwargs:
             bzkwargs.update(kwargs)
             bugs = bugzilla.get_bugs(**bzkwargs)
             bugs['date_received'] = now()
     except Exception:
         log.exception('Problem fetching bugs from %s', self.url)
         raise BZError("Couldn't retrieve bugs from Bugzilla")
     if self.id and not self.one_time:
         self.date_synced = now()
         self.save()
     return set(store_bugs(bugs))
Exemplo n.º 2
0
 def get_bugs(self, **kwargs):
     """
     Do the actual work of getting bugs from the BZ API
     :return: set
     """
     bugs = {}
     try:
         args = self._get_bz_args()
         args = dict((k.encode('utf-8'), v) for k, v in args.iterlists())
         bzkwargs = {}
         if 'bug_id' in args:
             bzkwargs['ids'] = [
                 int(bid) for bid in args['bug_id'][0].split(',')
             ]
         else:
             for item in ['product', 'component']:
                 items = args.get(item)
                 if items:
                     bzkwargs[item] = items
         if bzkwargs:
             bzkwargs.update(kwargs)
             bugs = bugzilla.get_bugs(**bzkwargs)
             bugs['date_received'] = now()
     except Exception:
         log.exception('Problem fetching bugs from %s', self.url)
         raise BZError("Couldn't retrieve bugs from Bugzilla")
     if self.id and not self.one_time:
         self.date_synced = now()
         self.save()
     return set(store_bugs(bugs))
Exemplo n.º 3
0
def update_bugs(bug_ids):
    bugs = bugzilla.get_bugs(ids=bug_ids, scrum_only=False)
    for fault in bugs['faults']:
        if fault['faultCode'] == 102:  # unauthorized
            try:
                Bug.objects.get(id=fault['id']).delete()
                log.warning("DELETED unauthorized bug #%d", fault['id'])
            except Bug.DoesNotExist:
                pass
    store_bugs(bugs)
Exemplo n.º 4
0
def update_bugs(bug_ids):
    bugs = bugzilla.get_bugs(ids=bug_ids, scrum_only=False)
    for fault in bugs['faults']:
        if fault['faultCode'] == 102:  # unauthorized
            try:
                Bug.objects.get(id=fault['id']).delete()
                log.warning("DELETED unauthorized bug #%d", fault['id'])
            except Bug.DoesNotExist:
                pass
    store_bugs(bugs)
Exemplo n.º 5
0
    def get_object(self, queryset=None):
        """Return the bug object.

        Return None if the bug isn't in the DB
        Return False if we're also unable to retrieve it from BZ
        """
        obj = None
        refresh = self.request.META.get('HTTP_CACHE_CONTROL') == 'no-cache'
        try:
            obj = super(BugView, self).get_object(queryset)
        except Http404:
            if refresh:
                pk = self.kwargs['pk']
                bug_data = bugzilla.get_bugs(ids=[pk], scrum_only=False)
                if bug_data['bugs']:
                    obj = store_bugs(bug_data)[0]
                else:
                    obj = False
        else:
            if refresh:
                obj.refresh_from_bugzilla()
                obj.save()

        return obj
Exemplo n.º 6
0
    def get_object(self, queryset=None):
        """Return the bug object.

        Return None if the bug isn't in the DB
        Return False if we're also unable to retrieve it from BZ
        """
        obj = None
        refresh = self.request.META.get('HTTP_CACHE_CONTROL') == 'no-cache'
        try:
            obj = super(BugView, self).get_object(queryset)
        except Http404:
            if refresh:
                pk = self.kwargs['pk']
                bug_data = bugzilla.get_bugs(ids=[pk], scrum_only=False)
                if bug_data['bugs']:
                    obj = store_bugs(bug_data)[0]
                else:
                    obj = False
        else:
            if refresh:
                obj.refresh_from_bugzilla()
                obj.save()

        return obj
Exemplo n.º 7
0
 def refresh_from_bugzilla(self):
     data = bugzilla.get_bugs(ids=[self.id]).get('bugs')
     self.fill_from_data(data[0])
Exemplo n.º 8
0
 def refresh_from_bugzilla(self):
     data = bugzilla.get_bugs(ids=[self.id]).get('bugs')
     self.fill_from_data(data[0])