[molecule.utils] add get_random_str()

This commit is contained in:
Fabio Erculiani
2010-08-08 17:42:04 +02:00
parent c75dd2f43d
commit ea2edc7297
+10
View File
@@ -142,6 +142,16 @@ def get_random_number():
"""
return random.randint(0, 99999)
def get_random_str(str_len):
"""
Return a random string of length str_len. It uses os.urandom()
@param str_len: byte length
@type str_len: int
@return: random string
@rtype: str
"""
return os.urandom(str_len)
def md5sum(filepath):
"""
Calcuate md5 hash of given file path.