forked from CMS/memberPlumbing
Switch config file from JSON to YAML
This commit is contained in:
parent
d248e41fdb
commit
d5be64c37d
20
common.py
20
common.py
@ -1,5 +1,5 @@
|
|||||||
import csv
|
import csv
|
||||||
import json
|
from ruamel.yaml import YAML
|
||||||
import urllib3
|
import urllib3
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
@ -7,29 +7,25 @@ from io import StringIO
|
|||||||
import requests
|
import requests
|
||||||
from hid.DoorController import DoorController
|
from hid.DoorController import DoorController
|
||||||
|
|
||||||
from passwords import *
|
from passwords import (DOOR_USERNAME, DOOR_PASSWORD,
|
||||||
|
MEMBERSHIPWORKS_USERNAME, MEMBERSHIPWORKS_PASSWORD)
|
||||||
|
|
||||||
# it's fine, ssl certs are for losers anyway
|
# it's fine, ssl certs are for losers anyway
|
||||||
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
config = json.load(
|
with open(os.path.dirname(os.path.abspath(__file__)) + "/config.yaml") as f:
|
||||||
open(os.path.dirname(os.path.abspath(__file__)) + "/config.json"))
|
config = YAML().load(f)
|
||||||
except NameError:
|
except NameError:
|
||||||
config = json.load(open("config.json"))
|
with open("config.yaml") as f:
|
||||||
|
config = YAML().load(f)
|
||||||
|
|
||||||
doors = {doorName: DoorController(doorData['ip'],
|
doors = {doorName: DoorController(doorData['ip'],
|
||||||
DOOR_USERNAME, DOOR_PASSWORD,
|
DOOR_USERNAME, DOOR_PASSWORD,
|
||||||
name=doorName, access=doorData['access'])
|
name=doorName, access=doorData['access'])
|
||||||
for doorName, doorData in config["doors"].items()}
|
for doorName, doorData in config["doors"].items()}
|
||||||
|
|
||||||
# mapping of member levels to schedules
|
memberLevels = config['memberLevels']
|
||||||
memberLevels = {"CMS Staff": "7x24",
|
|
||||||
"CMS Weekends Only": "Weekends Only",
|
|
||||||
"CMS Weekdays Only": "Weekdays Only",
|
|
||||||
"CMS Unlimited": "Unlimited",
|
|
||||||
"CMS Nights & Weekends": "Nights and Weekends",
|
|
||||||
"CMS Day Pass": "Unlimited"}
|
|
||||||
|
|
||||||
def getMembershipworksData(folders, columns):
|
def getMembershipworksData(folders, columns):
|
||||||
""" Pull the members csv from the membershipworks api
|
""" Pull the members csv from the membershipworks api
|
||||||
|
10
config.json
10
config.json
@ -1,10 +0,0 @@
|
|||||||
{
|
|
||||||
"doors": {
|
|
||||||
"Studio Space": {"ip": "172.18.51.11", "access": "Studio Space"},
|
|
||||||
"Front Door": {"ip": "172.18.51.12", "access": "Front Door"},
|
|
||||||
"Metal Shop": {"ip": "172.18.51.13", "access": "Metal Shop"},
|
|
||||||
"Wood Shop": {"ip": "172.18.51.14", "access": "Wood Shop"},
|
|
||||||
"Wood Shop Rear": {"ip": "172.18.51.15", "access": "Wood Shop"},
|
|
||||||
"Storage Closet": {"ip": "172.18.51.16", "access": "Storage Closet"}
|
|
||||||
}
|
|
||||||
}
|
|
16
config.yaml
Normal file
16
config.yaml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
doors:
|
||||||
|
Studio Space: {ip: 172.18.51.11, access: Studio Space}
|
||||||
|
Front Door: {ip: 172.18.51.12, access: Front Door}
|
||||||
|
Metal Shop: {ip: 172.18.51.13, access: Metal Shop}
|
||||||
|
Wood Shop: {ip: 172.18.51.14, access: Wood Shop}
|
||||||
|
Wood Shop Rear: {ip: 172.18.51.15, access: Wood Shop}
|
||||||
|
Storage Closet: {ip: 172.18.51.16, access: Storage Closet}
|
||||||
|
|
||||||
|
# {member type: door schedule}
|
||||||
|
memberLevels:
|
||||||
|
CMS Staff: 7x24
|
||||||
|
CMS Weekends Only: Weekends Only
|
||||||
|
CMS Weekdays Only: Weekdays Only
|
||||||
|
CMS Unlimited: Unlimited
|
||||||
|
CMS Nights & Weekends: Nights and Weekends
|
||||||
|
CMS Day Pass: Unlimited
|
Loading…
Reference in New Issue
Block a user