diff options
Diffstat (limited to 'tools/glusterfind/src/utils.py')
| -rw-r--r-- | tools/glusterfind/src/utils.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/tools/glusterfind/src/utils.py b/tools/glusterfind/src/utils.py index c24258e6ef8..906ebd8f252 100644 --- a/tools/glusterfind/src/utils.py +++ b/tools/glusterfind/src/utils.py @@ -36,10 +36,10 @@ class RecordType(object): def cache_output(func): def wrapper(*args, **kwargs): global cache_data - if cache_data.get(func.func_name, None) is None: - cache_data[func.func_name] = func(*args, **kwargs) + if cache_data.get(func.__name__, None) is None: + cache_data[func.__name__] = func(*args, **kwargs) - return cache_data[func.func_name] + return cache_data[func.__name__] return wrapper @@ -58,12 +58,13 @@ def find(path, callback_func=lambda x: True, filter_func=lambda x: True, # Capture filter_func output and pass it to callback function filter_result = filter_func(path) if filter_result is not None: - callback_func(path, filter_result) + callback_func(path, filter_result, os.path.isdir(path)) for p in os.listdir(path): full_path = os.path.join(path, p) - if os.path.isdir(full_path): + is_dir = os.path.isdir(full_path) + if is_dir: if subdirs_crawl: find(full_path, callback_func, filter_func, ignore_dirs) else: @@ -73,7 +74,7 @@ def find(path, callback_func=lambda x: True, filter_func=lambda x: True, else: filter_result = filter_func(full_path) if filter_result is not None: - callback_func(full_path, filter_result) + callback_func(full_path, filter_result, is_dir) def output_write(f, path, prefix=".", encode=False, tag="", @@ -229,7 +230,11 @@ def get_changelog_rollover_time(volumename): try: tree = etree.fromstring(out) - return int(tree.find('volGetopts/Opt/Value').text) + val = tree.find('volGetopts/Opt/Value').text + if val is not None: + # Filter the value by split, as it may be 'X (DEFAULT)' + # and we only need 'X' + return int(val.split(' ', 1)[0]) except ParseError: return DEFAULT_CHANGELOG_INTERVAL |
