/
gertrude.pyw
executable file
·81 lines (68 loc) · 2.6 KB
/
gertrude.pyw
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
# This file is part of Gertrude.
#
# Gertrude 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 2 of the License, or
# (at your option) any later version.
#
# Gertrude 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 Gertrude; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
from __future__ import unicode_literals
from __future__ import print_function
import codecs
import os
import sys
import wx
if sys.executable.endswith("pythonw.exe"):
logfile = open("gertrude.log", "a")
sys.stdout = codecs.getwriter('utf8')(logfile)
sys.stderr = codecs.getwriter('utf8')(logfile)
elif sys.platform != "win32":
from config import GERTRUDE_DIRECTORY
if not os.path.exists(GERTRUDE_DIRECTORY):
os.mkdir(GERTRUDE_DIRECTORY)
try:
print("Démarrage de Gertrude ...")
except:
sys.stdout = codecs.open(GERTRUDE_DIRECTORY + "/gertrude.log", "a", "utf-8")
bin_path = os.path.dirname(os.path.realpath(__file__))
cacert_path = os.path.join(bin_path, "cacert.pem")
if os.path.exists(cacert_path):
os.environ["REQUESTS_CA_BUNDLE"] = cacert_path
from startdialog import StartDialog
class GertrudeApp(wx.App):
def OnInit(self):
self.SetAssertMode(wx.PYAPP_ASSERT_SUPPRESS)
self.locale = wx.Locale(wx.LANGUAGE_DEFAULT)
print("TODO tester readonly")
# __builtin__.readonly = False
self.instance = wx.SingleInstanceChecker("Gertrude")
if self.instance.IsAnotherRunning():
dlg = wx.MessageDialog(
None,
"Gertrude est déjà lancée. Les données seront accessibles en lecture seule !",
"Confirmation",
wx.OK | wx.ICON_WARNING | wx.CANCEL
)
response = dlg.ShowModal()
dlg.Destroy()
if response == wx.ID_OK:
pass
print("TODO tester readonly")
# __builtin__.readonly = True
else:
return False
dialog = StartDialog()
dialog.Show(True)
return True
if __name__ == '__main__':
app = GertrudeApp(False)
app.MainLoop()