~ubuntu-branches/ubuntu/utopic/apport/utopic

« back to all changes in this revision

Viewing changes to problem_report.py

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2012-07-09 08:14:30 UTC
  • mfrom: (148.1.66)
  • Revision ID: package-import@ubuntu.com-20120709081430-jim1xdcbior31pph
Tags: 2.3-0ubuntu1
* New upstream release:
  - launchpad.py: Rework test suite to not use Launchpad's +storeblob
    facility at all any more. It almost never works on staging and is
    horribly slow. Fake the bug creation from a blob by manually creating
    the comment and attachments ourselves, and just assume that storeblob
    works on production.  Also change the structure to allow running every
    test individually.
  - crash-digger: Add --crash-db option to specify a non-default crash
    database name. (LP: #1003506)
  - apport-gtk: Add --hanging option to specify the process ID of a hanging
    application. If the user chooses to report this error, apport will
    terminate the pid with SIGABRT, otherwise it will send SIGKILL. The
    normal core pipe handler will be used to process the resulting report
    file, with a .hanging file in /var/crash to separate these from regular
    crashes.
  - apport: Also treat a binary as modified if the /proc/pid/exe symlink
    does not point to an existing file any more. (LP: #984944)
  - Fix PEP-8 violations picked up by latest pep8 checker.
  - ui.py: Do not ignore certain exceptions during upload which are not
    likely to be a network error.
  - launchpad.py: Recongize Launchpad projects for bug query and marking
    operations. (LP: #1003506)
  - packaging-apt-dpkg.py: Fix get_source_tree() to work with apt sandboxes.
  - apport-retrace: Turn StacktraceSource generation back on, now that it
    works with the current sandboxing.
  - launchpad.py: Ensure that upload chunk size does not underrun.
    (LP: #1013334)
  - apport_python_hook: Fix UnicodeEncodeError crash with Python 2 for
    exceptions with non-ASCII characters. (LP: #972436)
  - test_ui_kde.py: Fix occasional test failure in test_1_crash_details if
    the application ends before the "is progress bar visible" check is done.

Show diffs side-by-side

added added

removed removed

Lines of Context:
99
99
        date is the desired date/time string; if None (default), the
100
100
        current local time is used.
101
101
        '''
102
 
        if date == None:
 
102
        if date is None:
103
103
            date = time.asctime()
104
104
        self.data = {'ProblemType': type, 'Date': date}
105
105
 
132
132
            if line.startswith(b' '):
133
133
                if b64_block and not binary:
134
134
                    continue
135
 
                assert (key != None and value != None)
 
135
                assert (key is not None and value is not None)
136
136
                if b64_block:
137
137
                    l = base64.b64decode(line)
138
138
                    if bd:
169
169
                    b64_block = False
170
170
                    bd = None
171
171
                if key:
172
 
                    assert value != None
 
172
                    assert value is not None
173
173
                    self.data[key] = self._try_unicode(value)
174
174
                (key, value) = line.split(b':', 1)
175
175
                if not _python2:
183
183
                        value = b''
184
184
                    b64_block = True
185
185
 
186
 
        if key != None:
 
186
        if key is not None:
187
187
            self.data[key] = self._try_unicode(value)
188
188
 
189
189
        self.old_keys = set(self.data.keys())
282
282
 
283
283
            # if it's a tuple, we have a file reference; read the contents
284
284
            if not hasattr(v, 'find'):
285
 
                if len(v) >= 3 and v[2] != None:
 
285
                if len(v) >= 3 and v[2] is not None:
286
286
                    limit = v[2]
287
287
                else:
288
288
                    limit = None
298
298
                if fail_on_empty and len(v) == 0:
299
299
                    raise IOError('did not get any data for field ' + k)
300
300
 
301
 
                if limit != None and len(v) > limit:
 
301
                if limit is not None and len(v) > limit:
302
302
                    del self.data[k]
303
303
                    continue
304
304
 
344
344
            crc = zlib.crc32(b'')
345
345
 
346
346
            bc = zlib.compressobj(9, zlib.DEFLATED, -zlib.MAX_WBITS,
347
 
                zlib.DEF_MEM_LEVEL, 0)
 
347
                                  zlib.DEF_MEM_LEVEL, 0)
348
348
            # direct value
349
349
            if hasattr(v, 'find'):
350
350
                size += len(v)
355
355
                    file.write(b'\n ')
356
356
            # file reference
357
357
            else:
358
 
                if len(v) >= 3 and v[2] != None:
 
358
                if len(v) >= 3 and v[2] is not None:
359
359
                    limit = v[2]
360
360
 
361
361
                if hasattr(v[0], 'read'):
366
366
                    block = f.read(1048576)
367
367
                    size += len(block)
368
368
                    crc = zlib.crc32(block, crc)
369
 
                    if limit != None:
 
369
                    if limit is not None:
370
370
                        if size > limit:
371
371
                            # roll back
372
372
                            file.seek(curr_pos)
418
418
            os.chmod(reportfile, st.st_mode)
419
419
 
420
420
    def write_mime(self, file, attach_treshold=5, extra_headers={},
421
 
        skip_keys=None, priority_fields=None):
 
421
                   skip_keys=None, priority_fields=None):
422
422
        '''Write MIME/Multipart RFC 2822 formatted data into file.
423
423
 
424
424
        file must be a file-like object, not a path.  It needs to be opened in
562
562
        # value must be a string or a CompressedValue or a file reference
563
563
        # (tuple (string|file [, bool]))
564
564
        assert (isinstance(v, CompressedValue) or hasattr(v, 'isalnum') or
565
 
            (hasattr(v, '__getitem__') and (
566
 
            len(v) == 1 or (len(v) >= 2 and v[1] in (True, False)))
567
 
            and (hasattr(v[0], 'isalnum') or hasattr(v[0], 'read'))))
 
565
                (hasattr(v, '__getitem__') and (
 
566
                    len(v) == 1 or (len(v) >= 2 and v[1] in (True, False)))
 
567
                    and (hasattr(v[0], 'isalnum') or hasattr(v[0], 'read'))))
568
568
 
569
569
        return self.data.__setitem__(k, v)
570
570