memberPlumbing/common.py

27 lines
924 B
Python
Raw Permalink Normal View History

2019-12-20 18:42:06 -05:00
from ruamel.yaml import YAML
2018-08-13 15:46:00 -04:00
import os
from lib.hid.DoorController import DoorController
from lib.MembershipWorks import MembershipWorks
from passwords import DOOR_USERNAME, DOOR_PASSWORD
from passwords import MEMBERSHIPWORKS_USERNAME, MEMBERSHIPWORKS_PASSWORD
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)
2018-08-16 14:01:42 -04:00
doors = {doorName: DoorController(doorData['ip'],
DOOR_USERNAME, DOOR_PASSWORD,
name=doorName, access=doorData['access'])
for doorName, doorData in config["doors"].items()}
2019-12-20 18:42:06 -05:00
memberLevels = config['memberLevels']
doorSpecificSchedules = config['doorSpecificSchedules']
membershipworks = MembershipWorks()
membershipworks.login(MEMBERSHIPWORKS_USERNAME, MEMBERSHIPWORKS_PASSWORD)