Skip to content

Commit

Permalink
setup signal handlers for SIGINT/TERM exit
Browse files Browse the repository at this point in the history
fixes #36
  • Loading branch information
heartsucker committed Oct 18, 2018
1 parent f12019a commit 7769807
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion securedrop_client/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
import logging
import pathlib
import os
import signal
import sys
from sqlalchemy.orm import sessionmaker
from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import Qt
from PyQt5.QtCore import Qt, QTimer
from logging.handlers import TimedRotatingFileHandler
from securedrop_client import __version__
from securedrop_client.logic import Client
Expand Down Expand Up @@ -91,11 +92,24 @@ def run():
app.setDesktopFileName('org.freedomofthepress.securedrop.client')
app.setApplicationVersion(__version__)
app.setAttribute(Qt.AA_UseHighDpiPixmaps)

gui = Window()
app.setWindowIcon(load_icon(gui.icon))
app.setStyleSheet(load_css('sdclient.css'))

Session = sessionmaker(bind=engine)
session = Session()

client = Client("http://localhost:8081/", gui, session)
client.setup()

def signal_handler(*nargs) -> None:
app.quit()

for sig in [signal.SIGINT, signal.SIGTERM]:
signal.signal(sig, signal_handler)
timer = QTimer()
timer.start(500)
timer.timeout.connect(lambda: None)

sys.exit(app.exec_())

0 comments on commit 7769807

Please sign in to comment.