import os
import re
import platform
-import logging
import glob
+
from portage.output import bold, red, blue, yellow, green, nocolor
from stuff import scan
return broken_pathes
-def analyse(settings=None, logger=None, libraries=None, la_libraries=None,
+def analyse(settings, logger, libraries=None, la_libraries=None,
libraries_links=None, binaries=None, _libs_to_check=set()):
"""Main program body. It will collect all info and determine the
pkgs needing rebuilding.
binaries = collect_binaries_from_dir(bin_dirs, masked_dirs, logger)
if settings['USE_TMP_FILES']:
- save_cache(to_save={'libraries':libraries, 'la_libraries':la_libraries, 'libraries_links':libraries_links, 'binaries':binaries})
+ save_cache(logger=logger,
+ to_save={'libraries':libraries, 'la_libraries':la_libraries,
+ 'libraries_links':libraries_links, 'binaries':binaries
+ },
+ temp_path=settings['DEFAULT_TMP_DIR']
+ )
logger.debug('Found '+ str(len(libraries)) + ' libraries (+' + str(len(libraries_links)) + ' symlinks) and ' + str(len(binaries)) + ' binaries')
import os
import time
-import logging
+
from portage.output import red
from settings import DEFAULTS
return (ret['libraries'], ret['la_libraries'], ret['libraries_links'], ret['binaries'])
-def save_cache(logger=logging, to_save={}, temp_path=DEFAULTS['DEFAULT_TMP_DIR']):
+def save_cache(logger, to_save={}, temp_path=DEFAULTS['DEFAULT_TMP_DIR']):
''' Tries to store caching information.
@param logger
@param to_save have to be dict with keys: libraries, la_libraries, libraries_links and binaries
print 'Preparing cache ... '
from collect import *
+ import logging
bin_dirs, lib_dirs = prepare_search_dirs()
bin_dirs = bin_dirs.union(ld)
masked_dirs = masked_dirs.union(set(['/lib/modules', '/lib32/modules', '/lib64/modules',]))
- libraries, la_libraries, libraries_links, symlink_pairs = collect_libraries_from_dir(lib_dirs, masked_dirs)
- binaries = collect_binaries_from_dir(bin_dirs, masked_dirs)
+ libraries, la_libraries, libraries_links, symlink_pairs = collect_libraries_from_dir(lib_dirs, masked_dirs, logging)
+ binaries = collect_binaries_from_dir(bin_dirs, masked_dirs, logging)
- save_cache(to_save={'libraries':libraries, 'la_libraries':la_libraries, 'libraries_links':libraries_links, 'binaries':binaries})
+ save_cache(logger=logging,
+ to_save={'libraries':libraries, 'la_libraries':la_libraries,
+ 'libraries_links':libraries_links, 'binaries':binaries}
+ )
print 'Done.'
import os
import glob
import stat
-import logging
+
import portage
from portage.output import bold, red, blue, yellow, green, nocolor
return (found_files, found_la_files, found_symlinks, symlink_pairs)
-def collect_binaries_from_dir(dirs, mask, logger=logging):
+def collect_binaries_from_dir(dirs, mask, logger):
''' Collects all binaries from specified list of directories.
mask is list of pathes, that are ommited in scanning, can be eighter single file or entire directory
Returns list of binaries
if __name__ == '__main__':
+ import logging
bin_dirs, lib_dirs = prepare_search_dirs(logging)
masked_dirs, masked_files, ld = parse_revdep_config()
# Runs from here
-def main(settings=None):
+def main(settings=None, logger=None):
if settings is None:
print("NO Input settings, using defaults...")
settings = DEFAULTS.copy()
- logger = init_logger(settings)
+ if logger is None:
+ logger = init_logger(settings)
_libs_to_check = settings['library']
settings['PRETEND'] = True
analyze_cache = {}
- if settings['USE_TMP_FILES'] and check_temp_files():
- libraries, la_libraries, libraries_links, binaries = read_cache()
- assigned = analyse(libraries=libraries, la_libraries=la_libraries,
+ if settings['USE_TMP_FILES'] \
+ and check_temp_files(settings['DEFAULT_TMP_DIR']):
+ libraries, la_libraries, libraries_links, binaries = read_cache(
+ settings['DEFAULT_TMP_DIR'])
+ assigned = analyse(
+ settings=settings,
+ logger=logger,
+ libraries=libraries,
+ la_libraries=la_libraries,
libraries_links=libraries_links,
binaries=binaries,
_libs_to_check=_libs_to_check)