def load_keyfiles(): s = Settings() raw_k = s.get('keyfiles', {}) keyfiles = [] for name in raw_k: try: k = Keyfile.load(raw_k[name]) k.name = name keyfiles.append(k) except: pass return keyfiles
def create(name, keyfile_path=None, database_path=None, length=Keyfile.LENGTH, characters=Keyfile.CHARACTERS): try: if keyfile_path is None: keyfile_path = '%s.pkf' % name if database_path is None: database_path = '%s.pdb' % name keyfile = Keyfile.create( keyfile_path, database_path, length=length, characters=characters) Database.create(keyfile) s = Settings() keyfiles = s.get('keyfiles', {}) keyfiles[name] = keyfile.path s.set(keyfiles=keyfiles) notify('Created the keyfile', 'and initialised a database') except: notify('Error', 'Could not create the keyfile')