提交 89d4978b 编写于 作者: L Lucas Meneghel Rodrigues 提交者: Lucas Meneghel Rodrigues

Merge pull request #171 from lmr/trivial-fixes-sprint12

Trivial fixes sprint12
...@@ -45,5 +45,5 @@ build-rpm-all: source ...@@ -45,5 +45,5 @@ build-rpm-all: source
clean: clean:
$(PYTHON) setup.py clean $(PYTHON) setup.py clean
$(MAKE) -f $(CURDIR)/debian/rules clean || true $(MAKE) -f $(CURDIR)/debian/rules clean || true
rm -rf build/ MANIFEST BUILD BUILDROOT SPECS RPMS SRPMS rm -rf build/ MANIFEST BUILD BUILDROOT SPECS RPMS SRPMS SOURCES
find . -name '*.pyc' -delete find . -name '*.pyc' -delete
...@@ -45,17 +45,41 @@ class ProgressStreamHandler(logging.StreamHandler): ...@@ -45,17 +45,41 @@ class ProgressStreamHandler(logging.StreamHandler):
self.handleError(record) self.handleError(record)
class Paginator(object):
"""
Paginator that uses less to display contents on the terminal.
Contains cleanup handling for when user presses 'q' (to quit less).
"""
def __init__(self):
less_cmd = process.find_command('less')
self.pipe = os.popen('%s -FRSX' % less_cmd, 'w')
def __del__(self):
try:
self.pipe.close()
except IOError:
pass
def write(self, msg):
try:
self.pipe.write(msg)
except IOError:
pass
def get_paginator(): def get_paginator():
""" """
Get a pipe. If we can't do that, return stdout. Get a paginator. If we can't do that, return stdout.
The paginator is 'less'. The paginator is a useful feature inspired in The paginator is 'less'. The paginator is a useful feature inspired in
programs such as git, since it lets you scroll up and down large buffers programs such as git, since it lets you scroll up and down large buffers
of text, increasing the program's usability. of text, increasing the program's usability.
""" """
try: try:
less_cmd = process.find_command('less') return Paginator()
return os.popen('%s -FRSX' % less_cmd, 'w')
except process.CmdNotFoundError: except process.CmdNotFoundError:
return sys.stdout return sys.stdout
...@@ -238,7 +262,7 @@ class OutputManager(object): ...@@ -238,7 +262,7 @@ class OutputManager(object):
else: else:
self.log_partial(self.THROBBER_MOVES[self.throbber_pos], True) self.log_partial(self.THROBBER_MOVES[self.throbber_pos], True)
if self.throbber_pos == (len(self.THROBBER_MOVES)-1): if self.throbber_pos == (len(self.THROBBER_MOVES) - 1):
self.throbber_pos = 0 self.throbber_pos = 0
else: else:
self.throbber_pos += 1 self.throbber_pos += 1
......
...@@ -113,7 +113,7 @@ class TreeNode(object): ...@@ -113,7 +113,7 @@ class TreeNode(object):
def get_environment(self): def get_environment(self):
def update_or_extend(target, source): def update_or_extend(target, source):
for k, v in source.items(): for k, _ in source.items():
if target.has_key(k) and isinstance(target[k], list): if target.has_key(k) and isinstance(target[k], list):
target[k].extend(source[k]) target[k].extend(source[k])
else: else:
...@@ -148,7 +148,7 @@ class TreeNode(object): ...@@ -148,7 +148,7 @@ class TreeNode(object):
return list(self.iter_leaves()) return list(self.iter_leaves())
def get_ascii(self, show_internal=True, compact=False, attributes=None): def get_ascii(self, show_internal=True, compact=False, attributes=None):
(lines, mid) = self._ascii_art(show_internal=show_internal, (lines, _) = self._ascii_art(show_internal=show_internal,
compact=compact, attributes=attributes) compact=compact, attributes=attributes)
return '\n' + '\n'.join(lines) return '\n' + '\n'.join(lines)
...@@ -218,10 +218,6 @@ def create_from_ordered_data(data, tree=None, root=None, name='/root'): ...@@ -218,10 +218,6 @@ def create_from_ordered_data(data, tree=None, root=None, name='/root'):
if isinstance(data, dict): if isinstance(data, dict):
for key, value in data.items(): for key, value in data.items():
if isinstance(value, dict): if isinstance(value, dict):
leaf = True
for k, v in value.items():
if isinstance(v, dict):
leaf = False
node = TreeNode(key) node = TreeNode(key)
tree.add_child(node) tree.add_child(node)
create_from_ordered_data(value, node, root) create_from_ordered_data(value, node, root)
......
...@@ -414,7 +414,6 @@ class Job(object): ...@@ -414,7 +414,6 @@ class Job(object):
params_list = [] params_list = []
if urls is not None: if urls is not None:
for url in urls: for url in urls:
test_module = os.path.basename(url).split('.')[0]
try: try:
variants = multiplexer.create_variants_from_yaml(open(multiplex_file)) variants = multiplexer.create_variants_from_yaml(open(multiplex_file))
except SyntaxError: except SyntaxError:
......
...@@ -68,15 +68,19 @@ class Multiplexer(plugin.Plugin): ...@@ -68,15 +68,19 @@ class Multiplexer(plugin.Plugin):
data = tree.read_ordered_yaml(open(multiplex_file)) data = tree.read_ordered_yaml(open(multiplex_file))
t = tree.create_from_ordered_data(data) t = tree.create_from_ordered_data(data)
pipe.write(t.get_ascii()) pipe.write(t.get_ascii())
sys.exit(0) sys.exit(error_codes.numeric_status['AVOCADO_ALL_OK'])
variants = multiplexer.create_variants_from_yaml(open(multiplex_file)) variants = multiplexer.create_variants_from_yaml(open(multiplex_file))
pipe.write(bcolors.header_str('Variants generated:')) pipe.write(bcolors.header_str('Variants generated:'))
pipe.write('\n') pipe.write('\n')
for (index, dct) in enumerate(variants): for (index, tpl) in enumerate(variants):
pipe.write(' Variant %s: %s\n' % (index+1, [str(x) for x in dct])) pipe.write('Variant %s: %s\n' % (index+1, [str(x) for x in tpl]))
if args.contents: if args.contents:
for key in sorted(dct.keys()): env = {}
pipe.write(' %s = %s\n' % (key, dct.get(key))) for node in tpl:
env.update(node.environment)
for k in sorted(env.keys()):
pipe.write(' %s: %s\n' % (k, env[k]))
sys.exit(error_codes.numeric_status['AVOCADO_ALL_OK']) sys.exit(error_codes.numeric_status['AVOCADO_ALL_OK'])
sync_tarball: synctest.tar.bz2 sync_tarball: synctest.tar.bz2
short: loop:
short:
sync_loop: 10 sync_loop: 10
sync_length: 100 medium:
medium:
sync_loop: 50 sync_loop: 50
sync_length: 500 long:
long:
sync_loop: 100 sync_loop: 100
length:
short:
sync_length: 100
medium:
sync_length: 500
long:
sync_length: 1000 sync_length: 1000
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册