~ubuntu-branches/ubuntu/quantal/apport/quantal-proposed

« back to all changes in this revision

Viewing changes to apport/crashdb_impl/launchpad.py

  • Committer: Package Import Robot
  • Author(s): Brian Murray
  • Date: 2012-10-16 13:31:24 UTC
  • mfrom: (341.1.8 quantal)
  • Revision ID: package-import@ubuntu.com-20121016133124-7e200k8c8vt1zo38
Tags: 2.6.1-0ubuntu4
apport/ui.py: create a MarkForUpload field and set that to false for
binaries that changed since the crash happened thereby preventing uploads
to the crash database (LP: #1039220)

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
    from httplib import HTTPSConnection
20
20
    from urllib import urlencode, urlopen
21
21
    (HTTPSHandler, Request, build_opener, HTTPSConnection, urlencode, urlopen)  # pyflakes
 
22
    _python2 = True
22
23
else:
23
24
    from urllib.request import HTTPSHandler, Request, build_opener, urlopen
24
25
    from urllib.parse import urlencode
25
26
    from http.client import HTTPSConnection
 
27
    _python2 = False
26
28
 
27
29
try:
28
30
    from launchpadlib.errors import HTTPError
376
378
            x.append('apport-collected')
377
379
            # add any tags (like the release) to the bug
378
380
            if 'Tags' in report:
379
 
                x += report['Tags'].lower().split()
 
381
                x += self._filter_tag_names(report['Tags']).split()
380
382
            bug.tags = x
381
383
            bug.lp_save()
382
384
            bug = self.launchpad.bugs[id]  # fresh bug object, LP#336866 workaround
722
724
            tags_to_copy = ['bugpattern-needed', 'running-unity']
723
725
            for series in self.lp_distro.series:
724
726
                if series.status not in ['Active Development',
725
 
                                         'Current Stable Release', 'Supported']:
 
727
                                         'Current Stable Release',
 
728
                                         'Supported', 'Pre-release Freeze']:
726
729
                    continue
727
730
                tags_to_copy.append(series.name)
728
731
            # copy tags over from the duplicate bug to the master bug
909
912
        if a:
910
913
            hdr['Tags'] += ' ' + a
911
914
        if 'Tags' in report:
912
 
            hdr['Tags'] += ' ' + report['Tags'].lower()
 
915
            hdr['Tags'] += ' ' + self._filter_tag_names(report['Tags'])
913
916
 
914
917
        # privacy/retracing for distro reports
915
918
        # FIXME: ugly hack until LP has a real crash db
942
945
 
943
946
        return mime
944
947
 
 
948
    @classmethod
 
949
    def _filter_tag_names(klass, tags):
 
950
        '''Replace characters from tags which are not palatable to Launchpad'''
 
951
 
 
952
        res = ''
 
953
        for ch in tags.lower().encode('ASCII', errors='ignore'):
 
954
            if ch in b'abcdefghijklmnopqrstuvwxyz0123456789 ' or (len(res) > 0 and ch in b'+-.'):
 
955
                if _python2:
 
956
                    res += ch
 
957
                else:
 
958
                    res += chr(ch)
 
959
            else:
 
960
                res += '.'
 
961
 
 
962
        return res
 
963
 
945
964
#
946
965
# Launchpad storeblob API (should go into launchpadlib, see LP #315358)
947
966
#
1691
1710
            # create the bug from header and description data
1692
1711
            bug = self.crashdb.launchpad.bugs.createBug(
1693
1712
                description=description,
1694
 
                private=(header['Private'] == 'yes'),
 
1713
                # temporarily disabled to work around SSLHandshakeError on
 
1714
                # private attachments
 
1715
                #private=(header['Private'] == 'yes'),
1695
1716
                tags=header['Tags'].split(),
1696
1717
                target=bug_target,
1697
1718
                title=report.get('Title', report.standard_title()))