more cleanup of importing logging. Use the one defined or passed in to in main().
authordol-sen <brian.dolbec@gmail.com>
Mon, 25 Apr 2011 07:03:20 +0000 (00:03 -0700)
committerPaul Varner <fuzzyray@gentoo.org>
Tue, 12 Jul 2011 21:29:01 +0000 (16:29 -0500)
pym/gentoolkit/revdep_rebuild/analyse.py
pym/gentoolkit/revdep_rebuild/cache.py
pym/gentoolkit/revdep_rebuild/collect.py
pym/gentoolkit/revdep_rebuild/rebuild.py

index 5ee0c7beff228c677a89faab57b7575b75846077..521d8b9e5a22509a81a67f8ea93b48f693b76f06 100644 (file)
@@ -3,8 +3,8 @@
 import os
 import re
 import platform
-import logging
 import glob
+
 from portage.output import bold, red, blue, yellow, green, nocolor
 
 from stuff import scan
@@ -114,7 +114,7 @@ def main_checks(found_libs, broken, dependencies, logger):
        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.
@@ -143,7 +143,12 @@ def analyse(settings=None, logger=None, libraries=None, la_libraries=None,
                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')
index e1a8e11458c57f4a28722b57378b34ce5b1c3622..8b1a8ed77e536d20c333deada1738d944e4cf40c 100644 (file)
@@ -2,7 +2,7 @@
 
 import os
 import time
-import logging
+
 from portage.output import red
 from settings import DEFAULTS
 
@@ -29,7 +29,7 @@ def read_cache(temp_path=DEFAULTS['DEFAULT_TMP_DIR']):
        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
@@ -87,6 +87,7 @@ if __name__ == '__main__':
        print 'Preparing cache ... '
 
        from collect import *
+       import logging
 
        bin_dirs, lib_dirs = prepare_search_dirs()
 
@@ -95,9 +96,12 @@ if __name__ == '__main__':
        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.'
index 735857b16ff93d8a251619da59ee4fb79523094f..b408edc103d8fa65d16d11a355e537287903ddd3 100644 (file)
@@ -4,7 +4,7 @@ import re
 import os
 import glob
 import stat
-import logging
+
 import portage
 from portage.output import bold, red, blue, yellow, green, nocolor
 
@@ -185,7 +185,7 @@ def collect_libraries_from_dir(dirs, mask, logger):
        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
@@ -229,6 +229,7 @@ def collect_binaries_from_dir(dirs, mask, logger=logging):
 
 
 if __name__ == '__main__':
+       import logging
        bin_dirs, lib_dirs = prepare_search_dirs(logging)
 
        masked_dirs, masked_files, ld = parse_revdep_config()
index 6185e0c7a87b9f39fd61fa1468a36dd9f45871da..6c08f5beef34c62913e81dffd70bccc6d8ae97bc 100644 (file)
@@ -169,13 +169,14 @@ def rebuild(logger, assigned, settings):
 
 
 # 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']
 
@@ -199,9 +200,15 @@ def main(settings=None):
                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)