Add qubes.utils.random_string()

This commit is contained in:
Bahtiar `kalkin-` Gadimov 2016-07-12 18:42:06 +02:00
parent c559ffdeab
commit f90d86fe13
No known key found for this signature in database
GPG Key ID: 96ED3C3BA19C3DEE

View File

@ -25,6 +25,8 @@
# #
import hashlib import hashlib
import random
import string
import os import os
import re import re
import subprocess import subprocess
@ -158,3 +160,9 @@ def get_entry_point_one(group, name):
', '.join('{}.{}'.format(ep.module_name, '.'.join(ep.attrs)) ', '.join('{}.{}'.format(ep.module_name, '.'.join(ep.attrs))
for ep in epoints))) for ep in epoints)))
return epoints[0].load() return epoints[0].load()
def random_string(length=5):
''' Return random string consisting of ascii_leters and digits '''
return ''.join(random.choice(string.ascii_letters + string.digits)
for _ in range(length))