~apport-hackers/apport/trunk

« back to all changes in this revision

Viewing changes to backends/packaging-apt-dpkg.py

  • Committer: Martin Pitt
  • Date: 2012-04-11 16:09:08 UTC
  • Revision ID: martin.pitt@canonical.com-20120411160908-cypjfe8pkzqp5lbd
* Fix the whole code to be PEP-8 compatible, and enforce this in test/run by running the "pep8" tool.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
import apport
23
23
from apport.packaging import PackageInfo
24
24
 
 
25
 
25
26
class __AptDpkgPackageInfo(PackageInfo):
26
27
    '''Concrete apport.PackageInfo class implementation for python-apt and
27
28
    dpkg, as found on Debian and derivatives such as Ubuntu.'''
163
164
 
164
165
        origins = None
165
166
        origins = pkg.candidate.origins
166
 
        if origins: # might be None
 
167
        if origins:  # might be None
167
168
            for o in origins:
168
169
                if o.origin in native_origins:
169
170
                    return True
221
222
                    if '\0' in line:
222
223
                        apport.warning('%s contains NUL character, ignoring line', sumfile)
223
224
                        continue
224
 
                    words  = line.split()
 
225
                    words = line.split()
225
226
                    if not words:
226
227
                        apport.warning('%s contains empty line, ignoring line', sumfile)
227
228
                        continue
246
247
        official user-facing API for this, which will ask for confirmation and
247
248
        allows filtering.
248
249
        '''
249
 
        dpkg = subprocess.Popen(['dpkg-query','-W','--showformat=${Conffiles}',
 
250
        dpkg = subprocess.Popen(['dpkg-query', '-W', '--showformat=${Conffiles}',
250
251
            package], stdout=subprocess.PIPE, close_fds=True)
251
252
 
252
253
        out = dpkg.communicate()[0].decode()
253
254
        if dpkg.returncode != 0:
254
 
           return {}
 
255
            return {}
255
256
 
256
257
        modified = {}
257
258
        for line in out.splitlines():
285
286
 
286
287
        while not match and i < len(file_list):
287
288
            p = subprocess.Popen(['fgrep', '-lxm', '1', '--', pattern] +
288
 
                file_list[i:i+slice_size], stdin=subprocess.PIPE,
 
289
                file_list[i:(i + slice_size)], stdin=subprocess.PIPE,
289
290
                stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
290
291
            out = p.communicate()[0].decode('UTF-8')
291
292
            if p.returncode == 0:
442
443
        if debug_pkgname in c and c[debug_pkgname].isInstalled:
443
444
            #print('kernel ddeb already installed')
444
445
            return (installed, outdated)
445
 
        target_dir = apt_pkg.Config.FindDir('Dir::Cache::archives')+'/partial'
 
446
        target_dir = apt_pkg.Config.FindDir('Dir::Cache::archives') + '/partial'
446
447
        deb = '%s_%s_%s.ddeb' % (debug_pkgname, ver, arch)
447
448
        # FIXME: this package is currently not in Packages.gz
448
449
        url = 'http://ddebs.ubuntu.com/pool/main/l/linux/%s' % deb
452
453
        if u.getcode() > 400:
453
454
            return ('', 'linux')
454
455
        while True:
455
 
            block = u.read(8*1024)
 
456
            block = u.read(8 * 1024)
456
457
            if not block:
457
458
                break
458
459
            out.write(block)
569
570
            c.fetch_archives(fetcher=fetcher)
570
571
        except apt.cache.FetchFailedException as e:
571
572
            apport.error('Package download error, try again later: %s', str(e))
572
 
            sys.exit(99) # transient error
 
573
            sys.exit(99)  # transient error
573
574
 
574
575
        # unpack packages
575
576
        if verbose: