Verified Commit b412585e authored by Jakob Moser's avatar Jakob Moser
Browse files

Don't use the vault anymore

parent 140acbba
Loading
Loading
Loading
Loading
+8 −24
Original line number Diff line number Diff line
@@ -11,7 +11,6 @@ from poolpay.director.Director import Director
from poolpay.display.PygameDisplay import PygameDisplay
from poolpay.touch.EvdevTouchScreen import EvdevTouchScreen
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

@@ -21,7 +20,6 @@ logging.basicConfig(

logging.info("Starting PoolPay")
logging.info("Creating Vault, Display and Director")
vault = Vault(paths.vault_file, paths.instance_dir)
display = PygameDisplay(Path("/dev/fb1"), width=480, height=320)
touch_screen = EvdevTouchScreen(Path("/dev/input/event0"))
director = Director(play, display)
@@ -59,21 +57,14 @@ def _initialize_card_reader_and_run_with_crash() -> None:
            exit(42)


def launch_application(password: str | None) -> None:
def launch_application() -> None:
    if director.started:
        logging.warning(
            "Application is already launched, don't launch it a second time"
        )
        return

    open_vault = vault
    if password:
        logging.info("Opening vault")
        open_vault = vault.open(password)
    else:
        logging.info("No password to open vault was given, so assuming it was already open")

    with open_vault, touch_screen:
    with touch_screen:
        try:
            logging.info("Opening database")
            db.open(paths.db_file)
@@ -92,10 +83,10 @@ def launch_application(password: str | None) -> None:
            server.stop()


def launch_application_as_daemon(password: str | None) -> None:
def launch_application_as_daemon() -> None:
    logging.info("Launching main application as daemon thread")
    Thread(
        target=launch_application, args=(password,), daemon=True
        target=launch_application, daemon=True
    ).start()


@@ -104,9 +95,7 @@ server = Server(paths.socket_path)


def on_message_received(message: Message) -> None:
    if message.get("action") == "unlock" and message.get("password"):
        logging.info("Unlock message received via wire")
        launch_application_as_daemon(message["password"])
    logging.debug(f"Received message {message}, will do nothing.")


server.on_receive(on_message_received)
@@ -123,12 +112,7 @@ logging.info("Registering SIGINT and SIGTERM handlers")
signal.signal(signal.SIGINT, handle_signal)  # for keyboard interrupt
signal.signal(signal.SIGTERM, handle_signal)  # for systemd interrupt

if vault.is_open:
    # The vault has already been opened, so we don't need to wait for a password to start
    launch_application_as_daemon(None)
    # We will still launch the server, in case I ever get around to implementing more commands
else:
    logging.info("Waiting for vault unlock password via wire server")

# As documented above, we launch the server in any case
# The application is the main thing of interest. The server currently has no purpose at all (it once took care
# of unlocking the vault), but maybe it will have a purpose in the future.
launch_application_as_daemon()
server.start()