forked from smathot/qnotero
-
Notifications
You must be signed in to change notification settings - Fork 1
/
qnotero
executable file
·66 lines (61 loc) · 2.18 KB
/
qnotero
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
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python3
# This file is part of Qnotero.
#
# Qnotero is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Qnotero is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Qnotero. If not, see <https://www.gnu.org/licenses/>.
# Copyright (c) 2019 E. Albiter
#
if __name__ == "__main__":
import sys
# Check if we're running a supported Python (>= 3.3)
if sys.version_info < (3,3,0):
raise Exception('Qnotero requires Python >= 3.3')
if '--version' in sys.argv:
from libqnotero.qnotero import Qnotero
print(Qnotero.version)
sys.exit()
print('Using Python %s' % sys.version)
# The listener will fail if another instance of Qnotero is already running.
# In that case we send an activate signal, to pop up the Qnotero window, and
# exit.
from libqnotero.listener import Listener
try:
if "--notray" not in sys.argv:
listener = Listener()
else:
listener = None
except:
from libqnotero.config import getConfig
import socket
print(u"qnotero: Qnotero already running, sending activate signal")
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.sendto(b"activate", (u"localhost", getConfig(u"listenerPort")) )
sys.exit()
# Enable CTRL+C.
import signal
signal.signal(signal.SIGINT, signal.SIG_DFL)
# Normal start of Qnotero
from libqnotero.qnotero import Qnotero
from libqnotero.qt.QtGui import QApplication
reset = "--reset" in sys.argv
systray = "--notray" not in sys.argv
app = QApplication(sys.argv)
app.setQuitOnLastWindowClosed(False)
qnotero = Qnotero(app, systray=systray, debug=True, reset=reset)
qnotero.listener = listener
if not systray:
qnotero.popUp()
if listener is not None:
listener.qnotero = qnotero
listener.start()
sys.exit(app.exec_())