forked from CenterForOpenScience/osf-sync
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.py
55 lines (39 loc) · 1.15 KB
/
start.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import sys
from PyQt5.QtWidgets import QApplication, QMessageBox, QSystemTrayIcon
from osfoffline import utils
from osfoffline.application.main import OSFApp
from osfoffline.database_manager.db import drop_db
def running_warning():
warn_app = QApplication(sys.argv)
QMessageBox.information(
None,
"Systray",
"OSF-Offline is already running. Check out the system tray."
)
warn_app.quit()
sys.exit(0)
def start():
# Start logging all events
if '--drop' in sys.argv:
drop_db()
utils.start_app_logging()
if sys.platform == 'win32':
from server import SingleInstance
single_app = SingleInstance()
if single_app.already_running():
running_warning()
app = QApplication(sys.argv)
if not QSystemTrayIcon.isSystemTrayAvailable():
QMessageBox.critical(
None,
"Systray",
"Could not detect a system tray on this system"
)
sys.exit(1)
QApplication.setQuitOnLastWindowClosed(False)
osf = OSFApp()
osf.start()
osf.hide()
sys.exit(app.exec_())
if __name__ == "__main__":
start()