--- /dev/null
+import docopt
+
+import teuthology.config
+import teuthology.tree
+
+doc = """
+usage:
+ teuthology-tree -h
+ teuthology-tree [-p <prefixes>] [--] <suite_dir>
+
+Describe the contents of a qa suite by extracting comments
+starting with particular prefixes from files in the suite.
+
+positional arguments:
+ <suite_dir> path under which to archive results
+
+optional arguments:
+ -h, --help Show this help message and exit
+ -p <prefixes>, --prefix <prefixes> Comma-separated list of prefixes
+ [default: desc]
+""".format(archive_base=teuthology.config.config.archive_base)
+
+
+def main():
+ args = docopt.docopt(doc)
+ teuthology.tree.main(args)
'teuthology-kill = scripts.kill:main',
'teuthology-queue = scripts.queue:main',
'teuthology-prune-logs = scripts.prune_logs:main',
+ 'teuthology-tree = scripts.tree:main',
],
},
--- /dev/null
+# -*- coding: utf-8 -*-
+import os
+
+def main(args):
+ suite_dir = os.path.abspath(args["<suite_dir>"])
+ filters = args["--prefix"].split(',')
+ print suite_dir
+ return tree(suite_dir, filters, '')
+
+def extract_info(file_name, filters):
+ result = []
+ if os.path.isdir(file_name):
+ return result
+ with file(file_name, 'r') as f:
+ for line in f:
+ for filt in filters:
+ prefix = '# ' + filt + ':'
+ if line.startswith(prefix):
+ result.append(line[len(prefix):].rstrip('\n'))
+ return result
+
+def tree(cur_dir, filters, prefix):
+ files = sorted(os.listdir(cur_dir))
+ for i, f in enumerate(files):
+ path = os.path.join(cur_dir, f)
+ if i == len(files) - 1:
+ file_pad = '└── '
+ dir_pad = ' '
+ else:
+ file_pad = '├── '
+ dir_pad = '│ '
+ info = extract_info(path, filters)
+ print prefix + file_pad + f + ' ' + ' | '.join(info)
+ if os.path.isdir(path):
+ tree(path, filters, prefix + dir_pad)