memberPlumbing/common.py

30 lines
1.0 KiB
Python
Raw Normal View History

2019-12-20 18:42:06 -05:00
from ruamel.yaml import YAML
import urllib3
2018-08-13 15:46:00 -04:00
import os
2018-08-16 14:01:42 -04:00
from hid.DoorController import DoorController
from passwords import DOOR_USERNAME, DOOR_PASSWORD
from passwords import MEMBERSHIPWORKS_USERNAME, MEMBERSHIPWORKS_PASSWORD
from MembershipWorks import MembershipWorks
# it's fine, ssl certs are for losers anyway
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
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)