author | Andrey Skvortsov <andrej.skvortzov@gmail.com> |
Tue, 28 Mar 2017 19:48:51 +0300 | |
changeset 1670 | cd03b8432541 |
parent 1666 | d3603b5a1cbc |
child 1680 | 6db967480b7d |
permissions | -rwxr-xr-x |
1663
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/env python |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
2 |
# -*- coding: utf-8 -*- |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
3 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
4 |
# This file is part of Beremiz, a Integrated Development Environment for |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
5 |
# programming IEC 61131-3 automates supporting plcopen standard and CanFestival. |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
6 |
# |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
7 |
# Copyright (C) 2016 - 2017: Andrey Skvortsov <andrej.skvortzov@gmail.com> |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
8 |
# |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
9 |
# See COPYING file for copyrights details. |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
10 |
# |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
11 |
# This program is free software; you can redistribute it and/or |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
12 |
# modify it under the terms of the GNU General Public License |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
13 |
# as published by the Free Software Foundation; either version 2 |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
14 |
# of the License, or (at your option) any later version. |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
15 |
# |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
16 |
# This program is distributed in the hope that it will be useful, |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
17 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
18 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
19 |
# GNU General Public License for more details. |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
20 |
# |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
21 |
# You should have received a copy of the GNU General Public License |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
22 |
# along with this program; if not, write to the Free Software |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
23 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
24 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
25 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
26 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
27 |
import os, sys, getopt |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
28 |
import time |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
29 |
import __builtin__ |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
30 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
31 |
class BeremizIDELauncher: |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
32 |
def __init__(self): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
33 |
self.updateinfo_url = None |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
34 |
self.extensions = [] |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
35 |
self.app_dir = os.path.dirname(os.path.realpath(__file__)) |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
36 |
self.projectOpen = None |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
37 |
self.buildpath = None |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
38 |
self.splash = None |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
39 |
self.splashPath = self.Bpath("images", "splash.png") |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
40 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
41 |
def Bpath(self, *args): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
42 |
return os.path.join(self.app_dir,*args) |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
43 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
44 |
def ShowSplashScreen(self): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
45 |
from wx.lib.agw.advancedsplash import AdvancedSplash |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
46 |
bmp = wx.Image(self.splashPath).ConvertToBitmap() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
47 |
self.splash = AdvancedSplash(None, bitmap=bmp) |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
48 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
49 |
# process all events |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
50 |
# even the events generated by splash themself during showing |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
51 |
if wx.Platform == '__WXMSW__': |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
52 |
self.splash.Show() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
53 |
self.splash.ProcessEvent(wx.PaintEvent()) |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
54 |
else: |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
55 |
for i in range(0,30): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
56 |
wx.Yield() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
57 |
time.sleep(0.01); |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
58 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
59 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
60 |
def Usage(self): |
1666
d3603b5a1cbc
make command line help message for Beremiz more verbose
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1663
diff
changeset
|
61 |
print "Usage:" |
d3603b5a1cbc
make command line help message for Beremiz more verbose
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1663
diff
changeset
|
62 |
print "%s [Options] [Projectpath] [Buildpath]"%sys.argv[0] |
d3603b5a1cbc
make command line help message for Beremiz more verbose
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1663
diff
changeset
|
63 |
print "" |
d3603b5a1cbc
make command line help message for Beremiz more verbose
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1663
diff
changeset
|
64 |
print "Supported options:" |
d3603b5a1cbc
make command line help message for Beremiz more verbose
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1663
diff
changeset
|
65 |
print "-h --help Print this help" |
d3603b5a1cbc
make command line help message for Beremiz more verbose
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1663
diff
changeset
|
66 |
print "-u --updatecheck URL Retrieve update information by checking URL" |
d3603b5a1cbc
make command line help message for Beremiz more verbose
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1663
diff
changeset
|
67 |
print "-e --extend PathToExtension Extend IDE functionality by loading at start additional extensions" |
d3603b5a1cbc
make command line help message for Beremiz more verbose
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1663
diff
changeset
|
68 |
print "" |
d3603b5a1cbc
make command line help message for Beremiz more verbose
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1663
diff
changeset
|
69 |
print "" |
1663
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
70 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
71 |
def SetCmdOptions(self): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
72 |
self.shortCmdOpts = "hu:e:" |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
73 |
self.longCmdOpts = ["help", "updatecheck=", "extend="] |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
74 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
75 |
def ProcessOption(self, o, a): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
76 |
if o in ("-h", "--help"): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
77 |
self.Usage() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
78 |
sys.exit() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
79 |
if o in ("-u", "--updatecheck"): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
80 |
self.updateinfo_url = a |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
81 |
if o in ("-e", "--extend"): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
82 |
self.extensions.append(a) |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
83 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
84 |
def ProcessCommandLineArgs(self): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
85 |
self.SetCmdOptions() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
86 |
try: |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
87 |
opts, args = getopt.getopt(sys.argv[1:], self.shortCmdOpts, self.longCmdOpts) |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
88 |
except getopt.GetoptError: |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
89 |
# print help information and exit: |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
90 |
self.Usage() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
91 |
sys.exit(2) |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
92 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
93 |
for o, a in opts: |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
94 |
self.ProcessOption(o, a) |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
95 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
96 |
if len(args) > 2: |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
97 |
self.Usage() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
98 |
sys.exit() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
99 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
100 |
elif len(args) == 1: |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
101 |
self.projectOpen = args[0] |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
102 |
self.buildpath = None |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
103 |
elif len(args) == 2: |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
104 |
self.projectOpen = args[0] |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
105 |
self.buildpath = args[1] |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
106 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
107 |
def CreateApplication(self): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
108 |
if os.path.exists("BEREMIZ_DEBUG"): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
109 |
__builtin__.__dict__["BMZ_DBG"] = True |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
110 |
else : |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
111 |
__builtin__.__dict__["BMZ_DBG"] = False |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
112 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
113 |
global wxversion, wx |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
114 |
import wxversion |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
115 |
wxversion.select(['2.8', '3.0']) |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
116 |
import wx |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
117 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
118 |
if wx.VERSION >= (3, 0, 0): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
119 |
self.app = wx.App(redirect=BMZ_DBG) |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
120 |
else: |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
121 |
self.app = wx.PySimpleApp(redirect=BMZ_DBG) |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
122 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
123 |
self.app.SetAppName('beremiz') |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
124 |
if wx.VERSION < (3, 0, 0): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
125 |
wx.InitAllImageHandlers() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
126 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
127 |
self.ShowSplashScreen() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
128 |
self.BackgroundInitialization() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
129 |
self.app.MainLoop() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
130 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
131 |
def BackgroundInitialization(self): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
132 |
self.InitI18n() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
133 |
self.CheckUpdates() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
134 |
self.LoadExtensions() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
135 |
self.ImportModules() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
136 |
self.InstallExceptionHandler() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
137 |
self.ShowUI() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
138 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
139 |
def InitI18n(self): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
140 |
from util.misc import InstallLocalRessources |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
141 |
InstallLocalRessources(self.app_dir) |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
142 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
143 |
def LoadExtensions(self): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
144 |
for extfilename in self.extensions: |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
145 |
from util.TranslationCatalogs import AddCatalog |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
146 |
from util.BitmapLibrary import AddBitmapFolder |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
147 |
extension_folder = os.path.split(os.path.realpath(extfilename))[0] |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
148 |
sys.path.append(extension_folder) |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
149 |
AddCatalog(os.path.join(extension_folder, "locale")) |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
150 |
AddBitmapFolder(os.path.join(extension_folder, "images")) |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
151 |
execfile(extfilename, locals()) |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
152 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
153 |
def CheckUpdates(self): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
154 |
if self.updateinfo_url is not None: |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
155 |
updateinfo = _("Fetching %s") % self.updateinfo_url |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
156 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
157 |
def updateinfoproc(): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
158 |
global updateinfo |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
159 |
try : |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
160 |
import urllib2 |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
161 |
updateinfo = urllib2.urlopen(self.updateinfo_url,None).read() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
162 |
except : |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
163 |
updateinfo = _("update info unavailable.") |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
164 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
165 |
from threading import Thread |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
166 |
self.splash.SetText(text=updateinfo) |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
167 |
updateinfoThread = Thread(target=updateinfoproc) |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
168 |
updateinfoThread.start() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
169 |
updateinfoThread.join(2) |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
170 |
self.splash.SetText(text=updateinfo) |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
171 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
172 |
def ImportModules(self): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
173 |
global BeremizIDE |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
174 |
import BeremizIDE |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
175 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
176 |
def InstallExceptionHandler(self): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
177 |
import version |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
178 |
import tempfile |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
179 |
logpath = tempfile.gettempdir()+os.sep+'Beremiz' |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
180 |
BeremizIDE.AddExceptHook(logpath,version.app_version) |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
181 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
182 |
def ShowUI(self): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
183 |
self.frame = BeremizIDE.Beremiz(None, self.projectOpen, self.buildpath) |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
184 |
if self.splash: |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
185 |
self.splash.Close() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
186 |
self.frame.Show() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
187 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
188 |
def Start(self): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
189 |
self.ProcessCommandLineArgs() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
190 |
self.CreateApplication() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
191 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
192 |
if __name__ == '__main__': |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
193 |
beremiz = BeremizIDELauncher() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
194 |
beremiz.Start() |