Loading poolpay/__main__.py +21 −3 Original line number Diff line number Diff line from pathlib import Path from threading import Thread from poolpay import db, paths from poolpay.card.Pirc522CardReader import Pirc522CardReader Loading @@ -6,14 +7,16 @@ from poolpay.director.Director import Director from poolpay.display.PygameDisplay import PygameDisplay from poolpay.ui.pygame.play import play from poolpay.vault.Vault import Vault from poolpay.wire.Message import Message from poolpay.wire.Server import Server # TODO Show a message indicating the application is locked and a password is required? password = "hunter2" # TODO Prompt for this instead of hardcoding it into the file # Prepare basic resources vault = Vault(paths.vault_file, paths.instance_dir) display = PygameDisplay(Path("/dev/fb0"), width=480, height=320) director = Director(play, display) def launch_application(password: str) -> None: with vault.open(password), Pirc522CardReader() as card_reader: try: db.open(paths.db_file) Loading @@ -24,3 +27,18 @@ with vault.open(password), Pirc522CardReader() as card_reader: ) finally: db.close() server.stop() # Now start the wire server (over which the admin will pass us the password) server = Server(paths.socket_path) def on_message_received(message: Message) -> None: if message.get("action") == "unlock" and message.get("password"): Thread(target=launch_application, args=(message["password"],)).start() server.on_receive(on_message_received) # Wait indefinitely server.start() poolpay/paths.py +1 −0 Original line number Diff line number Diff line Loading @@ -4,5 +4,6 @@ proj_dir = Path(__file__).parent.parent.resolve() instance_dir = proj_dir / "instance" vault_file = proj_dir / "instance.img" db_file = instance_dir / "poolpay.db" socket_path = proj_dir / "wire.socket" __all__ = ["proj_dir", "instance_dir", "vault_file", "db_file"] Loading
poolpay/__main__.py +21 −3 Original line number Diff line number Diff line from pathlib import Path from threading import Thread from poolpay import db, paths from poolpay.card.Pirc522CardReader import Pirc522CardReader Loading @@ -6,14 +7,16 @@ from poolpay.director.Director import Director from poolpay.display.PygameDisplay import PygameDisplay from poolpay.ui.pygame.play import play from poolpay.vault.Vault import Vault from poolpay.wire.Message import Message from poolpay.wire.Server import Server # TODO Show a message indicating the application is locked and a password is required? password = "hunter2" # TODO Prompt for this instead of hardcoding it into the file # Prepare basic resources vault = Vault(paths.vault_file, paths.instance_dir) display = PygameDisplay(Path("/dev/fb0"), width=480, height=320) director = Director(play, display) def launch_application(password: str) -> None: with vault.open(password), Pirc522CardReader() as card_reader: try: db.open(paths.db_file) Loading @@ -24,3 +27,18 @@ with vault.open(password), Pirc522CardReader() as card_reader: ) finally: db.close() server.stop() # Now start the wire server (over which the admin will pass us the password) server = Server(paths.socket_path) def on_message_received(message: Message) -> None: if message.get("action") == "unlock" and message.get("password"): Thread(target=launch_application, args=(message["password"],)).start() server.on_receive(on_message_received) # Wait indefinitely server.start()
poolpay/paths.py +1 −0 Original line number Diff line number Diff line Loading @@ -4,5 +4,6 @@ proj_dir = Path(__file__).parent.parent.resolve() instance_dir = proj_dir / "instance" vault_file = proj_dir / "instance.img" db_file = instance_dir / "poolpay.db" socket_path = proj_dir / "wire.socket" __all__ = ["proj_dir", "instance_dir", "vault_file", "db_file"]