Пример #1
0
 def _create_package(self, pkgname):
     p = subprocess.Popen([
         'dpkg-query', '--showformat=${Package}\t'
         '${Version}\t'
         '${Installed-Size}\n', '-W', pkgname
     ],
                          stdout=subprocess.PIPE)
     try:
         size = version = None
         for l in p.stdout:
             fields = l.split()
             # Removes :arch
             name = fields[0].decode('ascii').split(':', 1)[0]
             if name == pkgname:
                 version = fields[1].decode('ascii')
                 size = int(fields[2].decode('ascii')) * 1024  # kbytes
                 break
         for l in p.stdout:  # finish draining stdout
             pass
     finally:
         p.wait()
     if p.returncode == 0:
         pkg = Package(pkgname, version, size=size)
         logging.debug("Found package %s", pkg)
         return pkg
     else:
         return None
Пример #2
0
 def _create_package(self, pkgname):
     p = subprocess.Popen(
         ['rpm', '-q', pkgname, '--qf', '%{VERSION}-%{RELEASE} %{SIZE}'],
         stdout=subprocess.PIPE,
         stderr=subprocess.PIPE)
     out, err = p.communicate()
     if p.returncode == 0:
         version, size = out.strip().decode('iso-8859-1').rsplit(' ', 1)
         size = int(size)
         pkg = Package(pkgname, version, size=size)
         logging.debug("Found package %s", pkg)
         return pkg
     else:
         return None
Пример #3
0
 def _create_package(self, pkgname):
     p = subprocess.Popen([
         'dpkg-query', '--showformat=${Package}\t'
         '${Version}\t'
         '${Installed-Size}\n', '-W', pkgname
     ],
                          stdout=subprocess.PIPE)
     try:
         size = version = None
         for l in p.stdout:
             fields = l.split()
             # Removes :arch
             name = fields[0].decode('ascii').split(':', 1)[0]
             if name == pkgname:
                 version = fields[1].decode('ascii')
                 size = int(fields[2].decode('ascii')) * 1024  # kbytes
                 break
     finally:
         p.wait()
     assert p.returncode == 0
     return Package(pkgname, version, size=size)