Commit dc54d5c5 authored by Nikos Skalkotos's avatar Nikos Skalkotos

Remove new_line parameter from most output methods

This is only needed for the info method. There is no reason to pollute
the rest of the methods with this.
parent 788ea15b
# -*- coding: utf-8 -*-
#
# Copyright (C) 2011-2014 GRNET S.A.
# Copyright (C) 2011-2015 GRNET S.A.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -24,15 +24,15 @@ of the various parts of the image-creator package.
class Output(object):
"""A class for printing program output"""
def error(self, msg, new_line=True):
def error(self, msg):
"""Print an error"""
pass
def warn(self, msg, new_line=True):
def warn(self, msg):
"""Print a warning"""
pass
def success(self, msg, new_line=True):
def success(self, msg):
"""Print msg after an action is completed"""
pass
......@@ -40,7 +40,7 @@ class Output(object):
"""Print normal program output"""
pass
def result(self, msg='', new_line=True):
def result(self, msg=''):
"""Print a result"""
pass
......
# -*- coding: utf-8 -*-
#
# Copyright (C) 2011-2014 GRNET S.A.
# Copyright (C) 2011-2015 GRNET S.A.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -39,14 +39,14 @@ class SilentOutput(Output):
self.stdout = kwargs['stdout'] if 'stdout' in kwargs else sys.stdout
self.stderr = kwargs['stderr'] if 'stderr' in kwargs else sys.stderr
def result(self, msg, new_line=True):
def result(self, msg):
"""Print a result"""
write(msg, new_line, lambda x: x, self.stdout)
write(msg, True, lambda x: x, self.stdout)
def error(self, msg, new_line=True):
def error(self, msg):
"""Print an error"""
color = red if self.colored else lambda x: x
write("Error: %s" % msg, new_line, color, self.stderr)
write("Error: %s" % msg, True, color, self.stderr)
class SimpleOutput(SilentOutput):
......@@ -54,15 +54,15 @@ class SimpleOutput(SilentOutput):
output messages. The user gets informed when the action begins and when it
ends, but no progress is shown in between."""
def warn(self, msg, new_line=True):
def warn(self, msg):
"""Print a warning"""
color = yellow if self.colored else lambda x: x
write("Warning: %s" % msg, new_line, color, self.stderr)
write("Warning: %s" % msg, True, color, self.stderr)
def success(self, msg, new_line=True):
def success(self, msg):
"""Print msg after an action is completed"""
color = green if self.colored else lambda x: x
write(msg, new_line, color, self.stderr)
write(msg, True, color, self.stderr)
def info(self, msg='', new_line=True):
"""Print msg as normal program output"""
......
# -*- coding: utf-8 -*-
#
# Copyright (C) 2011-2014 GRNET S.A.
# Copyright (C) 2011-2015 GRNET S.A.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -36,30 +36,30 @@ class CompositeOutput(Output, list):
if outputs is not None:
self.extend(outputs)
def error(self, msg, new_line=True):
def error(self, msg):
"""Call the error method of each of the output instances"""
for out in self:
out.error(msg, new_line)
out.error(msg)
def warn(self, msg, new_line=True):
def warn(self, msg):
"""Call the warn method of each of the output instances"""
for out in self:
out.warn(msg, new_line)
out.warn(msg)
def success(self, msg, new_line=True):
def success(self, msg):
"""Call the success method of each of the output instances"""
for out in self:
out.success(msg, new_line)
out.success(msg)
def info(self, msg='', new_line=True):
"""Call the output method of each of the output instances"""
for out in self:
out.info(msg, new_line)
def result(self, msg='', new_line=True):
def result(self, msg=''):
"""Call the output method of each of the output instances"""
for out in self:
out.result(msg, new_line)
out.result(msg)
def cleanup(self):
"""Call the cleanup method of each of the output instances"""
......
# -*- coding: utf-8 -*-
#
# Copyright (C) 2011-2014 GRNET S.A.
# Copyright (C) 2011-2015 GRNET S.A.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -48,24 +48,24 @@ class GaugeOutput(Output):
self.d.gauge_update(self.percent, self.msg, update_text=True)
time.sleep(0.4)
def result(self, msg='', new_line=True):
def result(self, msg=''):
"""Print a result"""
self.info(msg, new_line)
self.info(msg)
def success(self, result, new_line=True):
def success(self, result):
"""Print result after a successful action"""
self.percent = 100
self.d.gauge_update(self.percent, "%s %s" % (self.msg, result),
update_text=True)
time.sleep(0.4)
def warn(self, msg, new_line=True):
def warn(self, msg):
"""Print a warning"""
self.d.gauge_update(self.percent, "%s Warning: %s" % (self.msg, msg),
update_text=True)
time.sleep(0.4)
def error(self, msg, new_line=True):
def error(self, msg):
"""Print an error"""
self.d.gauge_update(self.percent, "%s Error: %s" % (self.msg, msg),
update_text=True)
......@@ -130,21 +130,21 @@ class InfoBoxOutput(Output):
self.d.infobox(display, title=self.title, height=self.height,
width=self.width)
def result(self, msg='', new_line=True):
def result(self, msg=''):
"""Print a result"""
self.info(msg, new_line)
self.info(msg)
def success(self, result, new_line=True):
def success(self, result):
"""Print result after an action is completed successfully"""
self.info(result, new_line)
self.info(result)
def warn(self, msg, new_line=True):
def warn(self, msg):
"""Print a warning message"""
self.info("Warning: %s" % msg, new_line)
self.info("Warning: %s" % msg)
def error(self, msg, new_line=True):
def error(self, msg):
"""Print an error message"""
self.info("Error: %s" % msg, new_line)
self.info("Error: %s" % msg)
def finalize(self):
"""Finalize the output. After this is called, the InfoboxOutput
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment