Restructure to a more normal module-like structure
This commit is contained in:
parent
7981a05a46
commit
b509495c5f
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,2 +1,4 @@
|
|||||||
__pycache__/
|
__pycache__/
|
||||||
/passwords.py
|
/passwords.py
|
||||||
|
/passwords.yaml
|
||||||
|
/venv/
|
||||||
|
5
bin/doorUpdater
Executable file
5
bin/doorUpdater
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
from memberPlumbing import doorUpdater
|
||||||
|
|
||||||
|
doorUpdater.main()
|
5
bin/events
Executable file
5
bin/events
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
from memberPlumbing import events
|
||||||
|
|
||||||
|
events.main()
|
5
bin/sqlExport
Executable file
5
bin/sqlExport
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
from memberPlumbing import sqlExport
|
||||||
|
|
||||||
|
sqlExport.main()
|
5
bin/ucsAccounts
Executable file
5
bin/ucsAccounts
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
from memberPlumbing import ucsAccounts
|
||||||
|
|
||||||
|
ucsAccounts.main()
|
0
memberPlumbing/__init__.py
Normal file
0
memberPlumbing/__init__.py
Normal file
@ -1,22 +1,19 @@
|
|||||||
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"]
|
||||||
config = YAML().load(f)
|
|
||||||
|
MEMBERSHIPWORKS_USERNAME = passwords["MEMBERSHIPWORKS_USERNAME"]
|
||||||
|
MEMBERSHIPWORKS_PASSWORD = passwords["MEMBERSHIPWORKS_PASSWORD"]
|
||||||
|
|
||||||
|
with open("config.yaml") as f:
|
||||||
|
config = YAML().load(f)
|
||||||
|
|
||||||
doors = {
|
doors = {
|
||||||
doorName: DoorController(
|
doorName: DoorController(
|
@ -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:
|
@ -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):
|
0
memberPlumbing/hid/__init__.py
Normal file
0
memberPlumbing/hid/__init__.py
Normal 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()
|
@ -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"
|
@ -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>"]
|
||||||
|
@ -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
12
systemd/hidEvents.service
Normal 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
9
systemd/hidEvents.timer
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Hourly door controller events sync
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnCalendar=hourly
|
||||||
|
Persistent=true
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=timers.target
|
@ -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
|
||||||
|
Reference in New Issue
Block a user