Module pywander.common
common module
Functions
def beep(a, b)
-
make a sound ref: http://stackoverflow.com/questions/16573051/python-sound-alarm-when-code-finishes you need install
apt-get install sox
:param a: frenquency :param b: duration
create a background thread,so this function does not block the main program
def humanize_bytes(n, precision=1)
-
based on Author: Doug Latornell's work
# Licence: MIT # URL: <http://code.activestate.com/recipes/577081/> Return a humanized string representation of a number of bytes.
>>> humanize_bytes(1) '1 B' >>> humanize_bytes(1024) '1.0 KiB' >>> humanize_bytes(1024 * 123) '123.0 KiB' >>> humanize_bytes(1024 * 12342) '12.1 MiB' >>> humanize_bytes(1024 * 12342, 2) '12.05 MiB' >>> humanize_bytes(1024 * 1234, 2) '1.21 MiB' >>> humanize_bytes(1024 * 1234 * 1111, 2) '1.31 GiB' >>> humanize_bytes(1024 * 1234 * 1111 * 1024) '1.3 TiB' >>>
def str2num(val)
-
str to int or float or raise a Exception. in some case maybe you just want to do some number type transform.
def str2pyobj(val)
-
basestring to python obj or not changed :param val: :return: