#!/usr/bin/env python3

import os
import n4d.client
from pathlib import Path 

config_path = Path("/etc/free-classroom.conf")
if config_path.exists():
    with config_path.open() as f:
        for line in f:
            if line.lower().startswith("enabled"):
                enabled = line.split("=")[1].strip().lower() == "true"
                if not enabled:
                    print("Free classroom is disabled in the configuration.")
                    exit(0)

user=os.environ["USER"]
n=n4d.client.Client("https://localhost:9779",user=user,password="")
ret=n.create_ticket()
cred=ret.credential
c=n4d.client.Client("https://localhost:9779",credential=ret.credential)
c.ClassroomManager.free_classroom()
