import urllib
import time
import logging
+import random
+import string
import wizard
f.close() # just to be safe
return ret
-def assert_all_writable(dir="."):
- """
- Recursively checks if all directories are writable and all files are
- readable. Raises :exc:`PermissionsError` if this is not true.
- """
- for dirpath, dirname, filenames in os.walk(dir):
- if not os.access(dirpath, os.R_OK):
- logging.warning("Could not write %s", dirpath)
- raise PermissionsError
- for filename in filenames:
- path = os.path.join(dirpath, filename)
- if os.path.islink(path):
- # assume it's ok
- continue
- if not os.access(path, os.R_OK):
- logging.warning("Could not read %s", path)
- raise PermissionsError
+def random_key(length=30):
+ """Generates a random alphanumeric key of ``length`` size."""
+ return ''.join(random.choice(string.letters + string.digits) for i in xrange(length))
class NoOperatorInfo(wizard.Error):
"""No information could be found about the operator from Kerberos."""