From 9d743344abde641d99f9db0b06e8450310b2ce26 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Thu, 6 Feb 2020 17:54:33 -0500 Subject: [PATCH] Move hid/*.py and MembershipWorks.py to lib folder --- common.py | 9 +++------ doorUpdater.py | 4 ++-- doorUtil.py | 10 ---------- MembershipWorks.py => lib/MembershipWorks.py | 0 {hid => lib/hid}/Credential.py | 0 {hid => lib/hid}/DoorController.py | 5 +++++ 6 files changed, 10 insertions(+), 18 deletions(-) delete mode 100644 doorUtil.py rename MembershipWorks.py => lib/MembershipWorks.py (100%) rename {hid => lib/hid}/Credential.py (100%) rename {hid => lib/hid}/DoorController.py (97%) diff --git a/common.py b/common.py index 307ad6b..6c593f0 100644 --- a/common.py +++ b/common.py @@ -1,15 +1,12 @@ from ruamel.yaml import YAML -import urllib3 import os -from hid.DoorController import DoorController + +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 -from MembershipWorks import MembershipWorks -# it's fine, ssl certs are for losers anyway -urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) - try: with open(os.path.dirname(os.path.abspath(__file__)) + "/config.yaml") as f: config = YAML().load(f) diff --git a/doorUpdater.py b/doorUpdater.py index 8bba418..17e3ce3 100755 --- a/doorUpdater.py +++ b/doorUpdater.py @@ -1,8 +1,8 @@ #!/usr/bin/env python3 from common import doors, membershipworks, memberLevels, doorSpecificSchedules -from hid.Credential import Credential -from hid.DoorController import ROOT, E +from lib.hid.Credential import Credential +from lib.hid.DoorController import ROOT, E class Member(): def __init__(self, forename="", surname="", membershipWorksID="", diff --git a/doorUtil.py b/doorUtil.py deleted file mode 100644 index 00b04ee..0000000 --- a/doorUtil.py +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env python3 -from common import doors - -def forEachDoor(fxn): - for door in doors.values(): - print(door.name) - fxn(door) - -#forEachDoor(lambda door: door.sendCardFormat("A901146A-244", 1, 244)) -#forEachDoor(lambda door: door.sendSchedules()) diff --git a/MembershipWorks.py b/lib/MembershipWorks.py similarity index 100% rename from MembershipWorks.py rename to lib/MembershipWorks.py diff --git a/hid/Credential.py b/lib/hid/Credential.py similarity index 100% rename from hid/Credential.py rename to lib/hid/Credential.py diff --git a/hid/DoorController.py b/lib/hid/DoorController.py similarity index 97% rename from hid/DoorController.py rename to lib/hid/DoorController.py index d7d1e85..f62395e 100644 --- a/hid/DoorController.py +++ b/lib/hid/DoorController.py @@ -1,5 +1,6 @@ import csv from io import StringIO +import urllib3 import requests from lxml import etree @@ -14,6 +15,10 @@ ROOT = E_plain.VertXMessage fieldnames = "CardNumber,CardFormat,PinRequired,PinCode,ExtendedAccess,ExpiryDate,Forename,Initial,Surname,Email,Phone,Custom1,Custom2,Schedule1,Schedule2,Schedule3,Schedule4,Schedule5,Schedule6,Schedule7,Schedule8".split(",") +# TODO: where should this live? +# it's fine, ssl certs are for losers anyway +urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) + class RemoteError(Exception): def __init__(self, r): super().__init__(