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

View File

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

View File

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

View File

View File

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

View File

@ -4,7 +4,7 @@ import re
import string import string
import subprocess import subprocess
from common import membershipworks from .common import membershipworks
LDAP_BASE = "cn=users,dc=sawtooth,dc=claremontmakerspace,dc=org" LDAP_BASE = "cn=users,dc=sawtooth,dc=claremontmakerspace,dc=org"
GROUP_BASE = "cn=groups,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] [tool.poetry]
name = "memberPlumbing" name = "memberPlumbing"
packages = [{ include = "memberPlumbing" }]
version = "0.1.0" version = "0.1.0"
description = "" description = ""
authors = ["Adam Goldsmith <adam@adamgoldsmith.name>"] authors = ["Adam Goldsmith <adam@adamgoldsmith.name>"]

View File

@ -7,4 +7,4 @@ User=adam
Type=oneshot Type=oneshot
TimeoutStartSec=600 TimeoutStartSec=600
WorkingDirectory=/home/adam/memberPlumbing/ 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 Type=oneshot
TimeoutStartSec=600 TimeoutStartSec=600
WorkingDirectory=/home/adam/memberPlumbing/ 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