提交 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
clean:
$(PYTHON) setup.py clean
$(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
......@@ -45,17 +45,41 @@ class ProgressStreamHandler(logging.StreamHandler):
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():
"""
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
programs such as git, since it lets you scroll up and down large buffers
of text, increasing the program's usability.
"""
try:
less_cmd = process.find_command('less')
return os.popen('%s -FRSX' % less_cmd, 'w')
return Paginator()
except process.CmdNotFoundError:
return sys.stdout
......@@ -238,7 +262,7 @@ class OutputManager(object):
else:
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
else:
self.throbber_pos += 1
......
......@@ -113,7 +113,7 @@ class TreeNode(object):
def get_environment(self):
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):
target[k].extend(source[k])
else:
......@@ -148,8 +148,8 @@ class TreeNode(object):
return list(self.iter_leaves())
def get_ascii(self, show_internal=True, compact=False, attributes=None):
(lines, mid) = self._ascii_art(show_internal=show_internal,
compact=compact, attributes=attributes)
(lines, _) = self._ascii_art(show_internal=show_internal,
compact=compact, attributes=attributes)
return '\n' + '\n'.join(lines)
def _ascii_art(self, char1='-', show_internal=True, compact=False, attributes=None):
......@@ -218,10 +218,6 @@ def create_from_ordered_data(data, tree=None, root=None, name='/root'):
if isinstance(data, dict):
for key, value in data.items():
if isinstance(value, dict):
leaf = True
for k, v in value.items():
if isinstance(v, dict):
leaf = False
node = TreeNode(key)
tree.add_child(node)
create_from_ordered_data(value, node, root)
......
......@@ -414,7 +414,6 @@ class Job(object):
params_list = []
if urls is not None:
for url in urls:
test_module = os.path.basename(url).split('.')[0]
try:
variants = multiplexer.create_variants_from_yaml(open(multiplex_file))
except SyntaxError:
......
......@@ -68,15 +68,19 @@ class Multiplexer(plugin.Plugin):
data = tree.read_ordered_yaml(open(multiplex_file))
t = tree.create_from_ordered_data(data)
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))
pipe.write(bcolors.header_str('Variants generated:'))
pipe.write('\n')
for (index, dct) in enumerate(variants):
pipe.write(' Variant %s: %s\n' % (index+1, [str(x) for x in dct]))
for (index, tpl) in enumerate(variants):
pipe.write('Variant %s: %s\n' % (index+1, [str(x) for x in tpl]))
if args.contents:
for key in sorted(dct.keys()):
pipe.write(' %s = %s\n' % (key, dct.get(key)))
env = {}
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'])
sync_tarball: synctest.tar.bz2
short:
sync_loop: 10
sync_length: 100
medium:
sync_loop: 50
sync_length: 500
long:
sync_loop: 100
sync_length: 1000
loop:
short:
sync_loop: 10
medium:
sync_loop: 50
long:
sync_loop: 100
length:
short:
sync_length: 100
medium:
sync_length: 500
long:
sync_length: 1000
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册