cloudmesh-common.cloudmesh.common.console
¶
Printing messages in a console
Module Contents¶
Functions¶
|
indents the given text by the indent specified and wrapping to the given width |
-
cloudmesh-common.cloudmesh.common.console.
indent
(text, indent=2, width=128)¶ indents the given text by the indent specified and wrapping to the given width
- Parameters
text – the text to print
indent – indent characters
width – the width of the text
- Returns
-
class
cloudmesh-common.cloudmesh.common.console.
Console
¶ Bases:
object
A simple way to print in a console terminal in color. Instead of using simply the print statement you can use special methods to indicate warnings, errors, ok and regular messages.
Example Usage:
Console.warning("Warning") Console.error("Error") Console.info("Info") Console.msg("msg") Console.ok("Success")
One can switch the color mode off with:
Console.color = False Console.error("Error")
The color will be switched on by default.
-
color
= True¶
-
debug
= True¶
-
theme_color
¶
-
theme_bw
¶
-
theme
¶
-
red
(msg)¶
-
green
(msg)¶
-
blue
(msg)¶
-
static
init
()¶ initializes the Console
-
static
terminate
()¶ terminates the program
-
classmethod
set_debug
(cls, on=True)¶ sets debugging on or of
- Parameters
on – if on debugging is set
- Returns
-
static
set_theme
(color=True)¶ defines if the console messages are printed in color
- Parameters
color – if True its printed in color
- Returns
-
static
get
(name)¶ returns the default theme for printing console messages
- Parameters
name – the name of the theme
- Returns
-
static
txt_msg
(message, width=79)¶ prints a message to the screen
- Parameters
message – the message to print
width – teh width of the line
- Returns
-
static
msg
(*message)¶ prints a message
- Parameters
message – the message to print
- Returns
-
static
bullets
(elements)¶ prints elemnets of a list as bullet list
- Parameters
elements – the list
-
classmethod
error
(cls, message, prefix=True, traceflag=False)¶ prints an error message
- Parameters
message – the message
prefix – a prefix for the message
traceflag – if true the stack trace is retrieved and printed
- Returns
-
static
TODO
(message, prefix=True, traceflag=True)¶ prints an TODO message
- Parameters
message – the message
prefix – if set to true it prints TODO: as prefix
traceflag – if true the stack trace is retrieved and printed
- Returns
-
static
debug_msg
(message)¶ print a debug message
- Parameters
message – the message
- Returns
-
static
info
(message)¶ prints an informational message
- Parameters
message – the message
- Returns
-
static
warning
(message)¶ prints a warning
- Parameters
message – the message
- Returns
-
static
ok
(message)¶ prints an ok message
- Parameters
message – the message<
- Returns
-
static
cprint
(color='BLUE', prefix='', message='')¶ prints a message in a given color
- Parameters
color – the color as defined in the theme
prefix – the prefix (a string)
message – the message
- Returns
-
static
text
(color='RED', prefix=None, message=None)¶ returns a message in a given color
- Parameters
color – the color as defined in the theme
prefix – the prefix (a string)
message – the message
- Returns
-
-
cloudmesh-common.cloudmesh.common.console.
color
= False¶