author | Andrey Skvortsov <andrej.skvortzov@gmail.com> |
Fri, 18 Aug 2017 20:14:38 +0300 | |
changeset 1768 | 691083b5682a |
parent 1752 | d14ff9d7eb76 |
child 1780 | c52d1460cea8 |
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 |
|
1732
94ffe74e6895
clean-up: fix PEP8 E401 multiple imports on one line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
26 |
import os |
94ffe74e6895
clean-up: fix PEP8 E401 multiple imports on one line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
27 |
import sys |
94ffe74e6895
clean-up: fix PEP8 E401 multiple imports on one line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
28 |
import getopt |
1663
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
29 |
import time |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
30 |
import __builtin__ |
1680
6db967480b7d
make run Beremiz and PLCOpen Editor, if full path contain non-lating
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1666
diff
changeset
|
31 |
import util.paths as paths |
1663
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
32 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
33 |
|
1663
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
34 |
class BeremizIDELauncher: |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
35 |
def __init__(self): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
36 |
self.updateinfo_url = None |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
37 |
self.extensions = [] |
1680
6db967480b7d
make run Beremiz and PLCOpen Editor, if full path contain non-lating
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1666
diff
changeset
|
38 |
self.app_dir = paths.AbsDir(__file__) |
1663
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
39 |
self.projectOpen = None |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
40 |
self.buildpath = None |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
41 |
self.splash = None |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
42 |
self.splashPath = self.Bpath("images", "splash.png") |
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 Bpath(self, *args): |
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
45 |
return os.path.join(self.app_dir, *args) |
1663
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
46 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
47 |
def ShowSplashScreen(self): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
48 |
from wx.lib.agw.advancedsplash import AdvancedSplash |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
49 |
bmp = wx.Image(self.splashPath).ConvertToBitmap() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
50 |
self.splash = AdvancedSplash(None, bitmap=bmp) |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
51 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
52 |
# process all events |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
53 |
# 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
|
54 |
if wx.Platform == '__WXMSW__': |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
55 |
self.splash.Show() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
56 |
self.splash.ProcessEvent(wx.PaintEvent()) |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
57 |
else: |
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
58 |
for i in range(0, 30): |
1663
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
59 |
wx.Yield() |
1752
d14ff9d7eb76
clean-up: fix PEP8 E703 statement ends with a semicolon
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1749
diff
changeset
|
60 |
time.sleep(0.01) |
1663
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
61 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
62 |
def Usage(self): |
1666
d3603b5a1cbc
make command line help message for Beremiz more verbose
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1663
diff
changeset
|
63 |
print "Usage:" |
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1732
diff
changeset
|
64 |
print "%s [Options] [Projectpath] [Buildpath]" % sys.argv[0] |
1666
d3603b5a1cbc
make command line help message for Beremiz more verbose
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1663
diff
changeset
|
65 |
print "" |
d3603b5a1cbc
make command line help message for Beremiz more verbose
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1663
diff
changeset
|
66 |
print "Supported options:" |
d3603b5a1cbc
make command line help message for Beremiz more verbose
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1663
diff
changeset
|
67 |
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
|
68 |
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
|
69 |
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
|
70 |
print "" |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1680
diff
changeset
|
71 |
print "" |
1663
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
72 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
73 |
def SetCmdOptions(self): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
74 |
self.shortCmdOpts = "hu:e:" |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
75 |
self.longCmdOpts = ["help", "updatecheck=", "extend="] |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
76 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
77 |
def ProcessOption(self, o, a): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
78 |
if o in ("-h", "--help"): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
79 |
self.Usage() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
80 |
sys.exit() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
81 |
if o in ("-u", "--updatecheck"): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
82 |
self.updateinfo_url = a |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
83 |
if o in ("-e", "--extend"): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
84 |
self.extensions.append(a) |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
85 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
86 |
def ProcessCommandLineArgs(self): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
87 |
self.SetCmdOptions() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
88 |
try: |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
89 |
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
|
90 |
except getopt.GetoptError: |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
91 |
# print help information and exit: |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
92 |
self.Usage() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
93 |
sys.exit(2) |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
94 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
95 |
for o, a in opts: |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
96 |
self.ProcessOption(o, a) |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
97 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
98 |
if len(args) > 2: |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
99 |
self.Usage() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
100 |
sys.exit() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
101 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
102 |
elif len(args) == 1: |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
103 |
self.projectOpen = args[0] |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
104 |
self.buildpath = None |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
105 |
elif len(args) == 2: |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
106 |
self.projectOpen = args[0] |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
107 |
self.buildpath = args[1] |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
108 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
109 |
def CreateApplication(self): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
110 |
if os.path.exists("BEREMIZ_DEBUG"): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
111 |
__builtin__.__dict__["BMZ_DBG"] = True |
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1736
diff
changeset
|
112 |
else: |
1663
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
113 |
__builtin__.__dict__["BMZ_DBG"] = False |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
114 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
115 |
global wxversion, wx |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
116 |
import wxversion |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
117 |
wxversion.select(['2.8', '3.0']) |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
118 |
import wx |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
119 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
120 |
if wx.VERSION >= (3, 0, 0): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
121 |
self.app = wx.App(redirect=BMZ_DBG) |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
122 |
else: |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
123 |
self.app = wx.PySimpleApp(redirect=BMZ_DBG) |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
124 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
125 |
self.app.SetAppName('beremiz') |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
126 |
if wx.VERSION < (3, 0, 0): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
127 |
wx.InitAllImageHandlers() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
128 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
129 |
self.ShowSplashScreen() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
130 |
self.BackgroundInitialization() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
131 |
self.app.MainLoop() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
132 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
133 |
def BackgroundInitialization(self): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
134 |
self.InitI18n() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
135 |
self.CheckUpdates() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
136 |
self.LoadExtensions() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
137 |
self.ImportModules() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
138 |
self.InstallExceptionHandler() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
139 |
self.ShowUI() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
140 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
141 |
def InitI18n(self): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
142 |
from util.misc import InstallLocalRessources |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
143 |
InstallLocalRessources(self.app_dir) |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
144 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
145 |
def LoadExtensions(self): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
146 |
for extfilename in self.extensions: |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
147 |
from util.TranslationCatalogs import AddCatalog |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
148 |
from util.BitmapLibrary import AddBitmapFolder |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
149 |
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
|
150 |
sys.path.append(extension_folder) |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
151 |
AddCatalog(os.path.join(extension_folder, "locale")) |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
152 |
AddBitmapFolder(os.path.join(extension_folder, "images")) |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
153 |
execfile(extfilename, locals()) |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
154 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
155 |
def CheckUpdates(self): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
156 |
if self.updateinfo_url is not None: |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
157 |
updateinfo = _("Fetching %s") % self.updateinfo_url |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
158 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
159 |
def updateinfoproc(): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
160 |
global updateinfo |
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1736
diff
changeset
|
161 |
try: |
1663
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
162 |
import urllib2 |
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
163 |
updateinfo = urllib2.urlopen(self.updateinfo_url, None).read() |
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1736
diff
changeset
|
164 |
except: |
1663
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
165 |
updateinfo = _("update info unavailable.") |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
166 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
167 |
from threading import Thread |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
168 |
self.splash.SetText(text=updateinfo) |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
169 |
updateinfoThread = Thread(target=updateinfoproc) |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
170 |
updateinfoThread.start() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
171 |
updateinfoThread.join(2) |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
172 |
self.splash.SetText(text=updateinfo) |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
173 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
174 |
def ImportModules(self): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
175 |
global BeremizIDE |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
176 |
import BeremizIDE |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
177 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
178 |
def InstallExceptionHandler(self): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
179 |
import version |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
180 |
import tempfile |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
181 |
logpath = tempfile.gettempdir()+os.sep+'Beremiz' |
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
182 |
BeremizIDE.AddExceptHook(logpath, version.app_version) |
1663
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
183 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
184 |
def ShowUI(self): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
185 |
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
|
186 |
if self.splash: |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
187 |
self.splash.Close() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
188 |
self.frame.Show() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
189 |
|
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
190 |
def Start(self): |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
191 |
self.ProcessCommandLineArgs() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
192 |
self.CreateApplication() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
193 |
|
1749
d73b64672238
clean-up: fix PEP8 E305 expected 2 blank lines after class or function definition
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1741
diff
changeset
|
194 |
|
1663
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
195 |
if __name__ == '__main__': |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
196 |
beremiz = BeremizIDELauncher() |
81f6781f7fec
rename BeremizIDELauncher.py to Beremiz.py
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
diff
changeset
|
197 |
beremiz.Start() |