memberPlumbing/common.py

37 lines
904 B
Python
Raw Normal View History

2018-08-13 15:46:00 -04:00
import os
from ruamel.yaml import YAML
from lib.hid.DoorController import DoorController
from lib.MembershipWorks import MembershipWorks
from passwords import (
DOOR_PASSWORD,
DOOR_USERNAME,
MEMBERSHIPWORKS_PASSWORD,
MEMBERSHIPWORKS_USERNAME,
)
2018-08-16 12:52:25 -04:00
try:
2019-12-20 18:42:06 -05:00
with open(os.path.dirname(os.path.abspath(__file__)) + "/config.yaml") as f:
config = YAML().load(f)
2018-08-16 12:52:25 -04:00
except NameError:
2019-12-20 18:42:06 -05:00
with open("config.yaml") as f:
config = YAML().load(f)
doors = {
doorName: DoorController(
doorData["ip"],
DOOR_USERNAME,
DOOR_PASSWORD,
name=doorName,
access=doorData["access"],
)
for doorName, doorData in config["doors"].items()
}
2018-08-16 14:01:42 -04:00
memberLevels = config["memberLevels"]
doorSpecificSchedules = config["doorSpecificSchedules"]
membershipworks = MembershipWorks()
membershipworks.login(MEMBERSHIPWORKS_USERNAME, MEMBERSHIPWORKS_PASSWORD)