Restructure to a more normal module-like structure

This commit is contained in:
Adam Goldsmith 2020-03-30 21:43:05 -04:00
parent 7981a05a46
commit b509495c5f
21 changed files with 67 additions and 26 deletions

2
.gitignore vendored
View File

@ -1,2 +1,4 @@
__pycache__/
/passwords.py
/passwords.yaml
/venv/

5
bin/doorUpdater Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env python3
from memberPlumbing import doorUpdater
doorUpdater.main()

5
bin/events Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env python3
from memberPlumbing import events
events.main()

5
bin/sqlExport Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env python3
from memberPlumbing import sqlExport
sqlExport.main()

5
bin/ucsAccounts Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env python3
from memberPlumbing import ucsAccounts
ucsAccounts.main()

View File

View File

@ -1,22 +1,19 @@
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,
)
from .hid.DoorController import DoorController
from .MembershipWorks import MembershipWorks
try:
with open(os.path.dirname(os.path.abspath(__file__)) + "/config.yaml") as f:
config = YAML().load(f)
except NameError:
with open("config.yaml") as f:
config = YAML().load(f)
with open("passwords.yaml") as f:
passwords = YAML().load(f)
DOOR_USERNAME = passwords["DOOR_USERNAME"]
DOOR_PASSWORD = passwords["DOOR_PASSWORD"]
MEMBERSHIPWORKS_USERNAME = passwords["MEMBERSHIPWORKS_USERNAME"]
MEMBERSHIPWORKS_PASSWORD = passwords["MEMBERSHIPWORKS_PASSWORD"]
with open("config.yaml") as f:
config = YAML().load(f)
doors = {
doorName: DoorController(

View File

@ -2,9 +2,9 @@
import copy
from common import doors, doorSpecificSchedules, memberLevels, membershipworks
from lib.hid.Credential import Credential
from lib.hid.DoorController import ROOT, E
from .common import doors, doorSpecificSchedules, memberLevels, membershipworks
from .hid.Credential import Credential
from .hid.DoorController import ROOT, E
class Member:

View File

@ -5,8 +5,8 @@ import re
import requests
from lxml import etree
from common import doors
from lib.hid.DoorController import E, E_plain
from .common import doors
from .hid.DoorController import E, E_plain
def getStrings(door):

View File

View File

@ -2,8 +2,8 @@
from datetime import datetime
from common import membershipworks
from lib.mw_models import Label, Member, MemberLabel, Transaction, database
from .common import membershipworks
from .mw_models import Label, Member, MemberLabel, Transaction, database
@database.atomic()

View File

@ -4,7 +4,7 @@ import re
import string
import subprocess
from common import membershipworks
from .common import membershipworks
LDAP_BASE = "cn=users,dc=sawtooth,dc=claremontmakerspace,dc=org"
GROUP_BASE = "cn=groups,dc=sawtooth,dc=claremontmakerspace,dc=org"

View File

@ -9,6 +9,7 @@ line_length = 88
[tool.poetry]
name = "memberPlumbing"
packages = [{ include = "memberPlumbing" }]
version = "0.1.0"
description = ""
authors = ["Adam Goldsmith <adam@adamgoldsmith.name>"]

View File

@ -7,4 +7,4 @@ User=adam
Type=oneshot
TimeoutStartSec=600
WorkingDirectory=/home/adam/memberPlumbing/
ExecStart=/usr/bin/python3 -u /home/adam/memberPlumbing/doorUpdater.py
ExecStart=/usr/bin/python3 -u /home/adam/.poetry/bin/poetry run /home/adam/memberPlumbing/bin/doorUpdater

12
systemd/hidEvents.service Normal file
View File

@ -0,0 +1,12 @@
[Unit]
Description=Pull events from door controllers into local database
OnFailure=status-email-admin@%n.service
After=mariadb.service
Requires=mariadb.service
[Service]
User=adam
Type=oneshot
TimeoutStartSec=600
WorkingDirectory=/home/adam/memberPlumbing/
ExecStart=/usr/bin/python3 -u /home/adam/.poetry/bin/poetry run /home/adam/memberPlumbing/bin/hidEvents

9
systemd/hidEvents.timer Normal file
View File

@ -0,0 +1,9 @@
[Unit]
Description=Hourly door controller events sync
[Timer]
OnCalendar=hourly
Persistent=true
[Install]
WantedBy=timers.target

View File

@ -9,4 +9,4 @@ User=adam
Type=oneshot
TimeoutStartSec=600
WorkingDirectory=/home/adam/memberPlumbing/
ExecStart=/usr/bin/python3 -u /home/adam/memberPlumbing/sqlExport.py
ExecStart=/usr/bin/python3 -u /home/adam/.poetry/bin/poetry run /home/adam/memberPlumbing/bin/sqlExport