def do_confirm_invitations(client, email, oid, aclargs): orga = aclargs["orga"] try: L.info(f"Confirming {email} to {orga.name}/{orga.id}") ret = client.confirm_invitation(aclargs["orga"], email) return {(email, oid): ret} except Exception as exc: trace = traceback.format_exc() L.error(f"Error while confirming {email}\n{orga.name}\n{trace}") DONE["errors"][(email, oid)] = (exc, trace)
def add_to_orga(client, email, oid, aclargs): orga = aclargs["orga"] try: L.info(f"Adding {email} to orga: {orga.name}/{orga.id}") ret = client.set_organization_access(email, aclargs["orga"], **aclargs["payload"]) return {(email, oid): ret} except Exception as exc: trace = traceback.format_exc() L.error(f"Error while creating {email}\n{orga.name}\n{trace}") DONE["errors"][(email, oid)] = (exc, trace)
def record(client, email, secretd, constructed): try: return client.delete_user(email) except bwclient.UserNotFoundError: pass except Exception as exc: trace = traceback.format_exc() print(trace) sid = email L.error(f"Error while creating {sid}\n{trace}") DONE["errors"][sid] = exc
def add_to_collection(client, email, cid, aclargs): collection = aclargs["collection"] try: L.info( f"Adding {email} to collection: {collection.name}/{collection.id}") ret = client.set_collection_access(email, aclargs["collection"], **aclargs["payload"]) return {(email, cid): ret} except Exception as exc: trace = traceback.format_exc() L.error(f"Error while creating {email}\n{collection.name}\n{trace}") DONE["errors"][(email, cid)] = (exc, trace)
def record(client, email, secretd, constructed): try: user = client.get_user(email=email) if not user.emailVerified: user = client.validate(email) return user, secretd["password"] except bwclient.UserNotFoundError: pass try: return client.create_user(email, name=email.split("@")[0], password=secretd["password"]) except Exception as exc: trace = traceback.format_exc() print(trace) sid = email L.error(f"Error while creating {sid}\n{trace}") DONE["errors"][sid] = exc
def record(client, cipherd): try: secret = cipherd["secret"] cipherd = assemble(cipherd) bw = cipherd["bw"] for action in cipherd["actions"]: if action in ["create", "edit"]: bw = getattr(client, action)(**cipherd["patch"]) break # attachments if "attach" in cipherd["actions"]: filename = secret["blob_meta"]["filename"] filepath = f'{EXPORT_DIR}/{secret["id"]}/{filename}' client.attach(bw, filepath) return bw except Exception as exc: trace = traceback.format_exc() sid = cipherd["secret"]["id"] L.error(f"Error while creating {sid}\n{trace}") DONE["errors"][sid] = exc