Home | Trees | Index | Help |
|
---|
Package cheesecake :: Module util |
|
Utility functions for Cheesecake project.
Classes | |
---|---|
StdoutRedirector |
Redirect stdout to a temporary file. |
Function Summary | |
---|---|
Returns True if command exited normally, False otherwise. | |
Make directory with parent directories as needed. | |
Pad value with spaces at left up to given length. | |
Return line consisting of 'char' characters. | |
Pad message with dots and pad value with spaces. | |
Pad value with spaces at left up to given length. | |
Pad text with dots up to given length. | |
Run command and return its return code and its output. | |
Measure function execution time. | |
Unpack given egg to the destination directory. | |
Untar given package to the destination directory. | |
Unzip given package to the destination directory. |
Variable Summary | |
---|---|
int |
PAD_TEXT = 40 |
int |
PAD_VALUE = 4 |
Function Details |
---|
command_successful(cmd)Returns True if command exited normally, False otherwise. >>> command_successful('/bin/true') True >>> command_successful('this-command-doesnt-exist') False |
mkdirs(dir)Make directory with parent directories as needed. Don't throw an exception if directory exists. |
pad_left_spaces(value, length=4)Pad value with spaces at left up to given length. >>> pad_left_spaces(15, 4) ' 15' >>> pad_left_spaces(123456, 2) '123456' >>> len(pad_left_spaces("")) == PAD_VALUE True |
pad_line(char='=', length=45)Return line consisting of 'char' characters. >>> pad_line('*', 3) '***' >>> pad_line(length=10) '==========' |
pad_msg(msg, value, msg_length=40, value_length=4)Pad message with dots and pad value with spaces. >>> pad_msg("123456", 77, msg_length=10, value_length=4) '123456 ... 77' >>> pad_msg("123", u"45", msg_length=5, value_length=3) u'123 . 45' |
pad_right_spaces(value, length=4)Pad value with spaces at left up to given length. >>> pad_right_spaces(123, 5) '123 ' >>> pad_right_spaces(12.1, 5) '12.1 ' |
pad_with_dots(msg, length=40)Pad text with dots up to given length. >>> pad_with_dots("Hello world", 20) 'Hello world ........' >>> pad_with_dots("Exceeding length", 10) 'Exceeding length' |
run_cmd(cmd, env=None, max_timeout=None)Run command and return its return code and its output. >>> run_cmd('/bin/true') (0, '') >>> run_cmd('/bin/cat', max_timeout=0.2) (1, 'Time exceeded') |
time_function(function)Measure function execution time. Return (return value, time taken) tuple. >>> def fun(x): ... return x*2 >>> ret, time_taken = time_function(lambda: fun(5)) >>> ret 10 |
unegg_package(package, destination)Unpack given egg to the Return name of unpacked directory or None on error. |
untar_package(package, destination)Untar given Return name of unpacked directory or None on error. |
unzip_package(package, destination)Unzip given Return name of unpacked directory or None on error. |
Variable Details |
---|
PAD_TEXT
|
PAD_VALUE
|
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Fri Feb 9 02:15:12 2007 | http://epydoc.sf.net |