예제 #1
0
def identify_packages(files):
    """Organizes the files, using the distribution's package manager.
    """
    distribution = platform.linux_distribution()[0].lower()
    if distribution == 'ubuntu':
        manager = DpkgManager()
    elif distribution == 'debian':
        manager = DpkgManager()
    else:
        return files, []

    for f in files:
        manager.search_for_file(f)

    return manager.unknown_files, listvalues(manager.packages)
예제 #2
0
def identify_packages(files):
    """Organizes the files, using the distribution's package manager.
    """
    distribution = platform.linux_distribution()[0].lower()
    if distribution == "ubuntu":
        manager = DpkgManager()
    elif distribution == "debian":
        manager = DpkgManager()
    else:
        return files, []

    begin = time.time()
    manager.search_for_files(files)
    logging.debug("Assigning files to packages took %f seconds", (time.time() - begin))

    return manager.unknown_files, listvalues(manager.packages)
예제 #3
0
def identify_packages(files):
    """Organizes the files, using the distribution's package manager.
    """
    distribution = platform.linux_distribution()[0].lower()
    if distribution == 'ubuntu':
        manager = DpkgManager()
    elif distribution == 'debian':
        manager = DpkgManager()
    else:
        return files, []

    begin = time.time()
    manager.search_for_files(files)
    logging.debug("Assigning files to packages took %f seconds",
                  (time.time() - begin))

    return manager.unknown_files, listvalues(manager.packages)
예제 #4
0
def identify_packages(files):
    """Organizes the files, using the distribution's package manager.
    """
    distribution = platform.linux_distribution()[0].lower()
    if distribution in ('debian', 'ubuntu'):
        logging.info("Identifying Debian packages...")
        manager = DpkgManager()
    elif (distribution in ('centos', 'centos linux',
                           'fedora', 'scientific linux') or
            distribution.startswith('red hat')):
        logging.info("Identifying RPM packages...")
        manager = RpmManager()
    else:
        return files, []

    begin = time.time()
    manager.search_for_files(files)
    logging.debug("Assigning files to packages took %f seconds",
                  (time.time() - begin))

    return manager.unknown_files, listvalues(manager.packages)
예제 #5
0
def identify_packages(files):
    """Organizes the files, using the distribution's package manager.
    """
    distribution = platform.linux_distribution()[0].lower()
    if distribution in ('debian', 'ubuntu'):
        logging.info("Identifying Debian packages for %d files...", len(files))
        manager = DpkgManager()
    elif (distribution
          in ('centos', 'centos linux', 'fedora', 'scientific linux')
          or distribution.startswith('red hat')):
        logging.info("Identifying RPM packages for %d files...", len(files))
        manager = RpmManager()
    else:
        logging.info("Unknown distribution, can't identify packages")
        return files, []

    begin = time.time()
    manager.search_for_files(files)
    logging.debug("Assigning files to packages took %f seconds",
                  (time.time() - begin))

    return manager.unknown_files, listvalues(manager.packages)
예제 #6
0
def combine_files(newfiles, newpackages, oldfiles, oldpackages):
    """Merges two sets of packages and files.
    """
    files = set(oldfiles)
    files.update(newfiles)

    packages = dict((pkg.name, pkg) for pkg in newpackages)
    for oldpkg in oldpackages:
        if oldpkg.name in packages:
            pkg = packages[oldpkg.name]
            # Here we build TracedFiles from the Files so that the comment
            # (size, etc) gets set
            s = set(TracedFile(fi.path) for fi in oldpkg.files)
            s.update(pkg.files)
            oldpkg.files = list(s)
            packages[oldpkg.name] = oldpkg
        else:
            oldpkg.files = [TracedFile(fi.path) for fi in oldpkg.files]
            packages[oldpkg.name] = oldpkg
    packages = listvalues(packages)

    return files, packages
예제 #7
0
def merge_files(newfiles, newpackages, oldfiles, oldpackages):
    """Merges two sets of packages and files.
    """
    files = set(oldfiles)
    files.update(newfiles)

    packages = dict((pkg.name, pkg) for pkg in newpackages)
    for oldpkg in oldpackages:
        if oldpkg.name in packages:
            pkg = packages[oldpkg.name]
            # Here we build TracedFiles from the Files so that the comment
            # (size, etc) gets set
            s = set(TracedFile(fi.path) for fi in oldpkg.files)
            s.update(pkg.files)
            oldpkg.files = list(s)
            packages[oldpkg.name] = oldpkg
        else:
            oldpkg.files = [TracedFile(fi.path) for fi in oldpkg.files]
            packages[oldpkg.name] = oldpkg
    packages = listvalues(packages)

    return files, packages