+def process_keyring(fullpath, secret=False):
+ """Create empty keyring if necessary."""
+
+ if os.path.exists(fullpath):
+ return
+
+ keydir = os.path.dirname(fullpath)
+
+ if not os.path.isdir(keydir):
+ print "Creating %s ..." % (keydir)
+ os.makedirs(keydir)
+ if secret:
+ # Make sure secret keyring directories are 0700
+ os.chmod(keydir, 0o700)
+
+ # Touch the file
+ print "Creating %s ..." % (fullpath)
+ file(fullpath, 'w')
+ if secret:
+ os.chmod(fullpath, 0o600)
+ else:
+ os.chmod(fullpath, 0o644)
+