def cached_du(**json): q = du_impl(**json) with connect(url=app.config["DATABASE"]) as conn: r = conn.execute(q).fetchone() return { "size": float(r.size) if r.size is not None else 0.0, "inodes": r.inodes, }
def find(): json = request.get_json() print(app.config["API_KEY"]) if json is None or json.pop("api_key", None) != app.config["API_KEY"]: abort(401) try: validate(json, schema=find_schema) except: abort(400) q = find_impl(**json) with connect(url=app.config["DATABASE"]) as conn: return jsonify([row.path for row in conn.execute(q)])
def du(): json = request.get_json() if json is None or json.pop("api_key", None) != app.config["API_KEY"]: abort(401) try: validate(json, schema=find_schema) except: abort(400) q = du_impl(**json) with connect(url=app.config["DATABASE"]) as conn: r = conn.execute(q).fetchone() return { "size": float(r.size) if r.size is not None else 0.0, "inodes": r.inodes, }
def db_(): logging.basicConfig() logging.getLogger("sqlalchemy.engine").setLevel(logging.INFO) with db.connect() as c: yield c
paths = group["path"] messages.append({ "to": f"{fullname} <{username}@nci.org.au>", "subject": f"CLEX storage at NCI for {username}", "message": j_template.render( username=p.pw_name, fullname=p.pw_gecos, count=paths.size, paths=paths, ), }) print(messages[-1]["message"]) with open(f"/g/data/hh5/tmp/dusql/users/{username}.txt", "w") as f: for path in paths: f.write(path + "\n") json.dump(messages, sys.stdout, indent=4) if __name__ == "__main__": from grafanadb import db with db.connect() as conn: unreadable_report(conn)
def db_(): logging.basicConfig() logging.getLogger("sqlalchemy.engine").setLevel(logging.INFO) with db.connect(url=os.environ.get('TEST_DB', db.default_url)) as c: yield c