Пример #1
0
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,
        }
Пример #2
0
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)])
Пример #3
0
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,
        }
Пример #4
0
def db_():
    logging.basicConfig()
    logging.getLogger("sqlalchemy.engine").setLevel(logging.INFO)
    with db.connect() as c:
        yield c
Пример #5
0
        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)
Пример #6
0
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