equal
deleted
inserted
replaced
21 # You should have received a copy of the GNU General Public License |
21 # You should have received a copy of the GNU General Public License |
22 # along with this program; if not, write to the Free Software |
22 # along with this program; if not, write to the Free Software |
23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
24 |
24 |
25 |
25 |
26 |
26 import os |
27 import os, sys, getopt |
27 import sys |
|
28 import getopt |
28 import time |
29 import time |
29 import __builtin__ |
30 import __builtin__ |
30 import util.paths as paths |
31 import util.paths as paths |
|
32 |
31 |
33 |
32 class BeremizIDELauncher: |
34 class BeremizIDELauncher: |
33 def __init__(self): |
35 def __init__(self): |
34 self.updateinfo_url = None |
36 self.updateinfo_url = None |
35 self.extensions = [] |
37 self.extensions = [] |
38 self.buildpath = None |
40 self.buildpath = None |
39 self.splash = None |
41 self.splash = None |
40 self.splashPath = self.Bpath("images", "splash.png") |
42 self.splashPath = self.Bpath("images", "splash.png") |
41 |
43 |
42 def Bpath(self, *args): |
44 def Bpath(self, *args): |
43 return os.path.join(self.app_dir,*args) |
45 return os.path.join(self.app_dir, *args) |
44 |
46 |
45 def ShowSplashScreen(self): |
47 def ShowSplashScreen(self): |
46 from wx.lib.agw.advancedsplash import AdvancedSplash |
48 from wx.lib.agw.advancedsplash import AdvancedSplash |
47 bmp = wx.Image(self.splashPath).ConvertToBitmap() |
49 bmp = wx.Image(self.splashPath).ConvertToBitmap() |
48 self.splash = AdvancedSplash(None, bitmap=bmp) |
50 self.splash = AdvancedSplash(None, bitmap=bmp) |
51 # even the events generated by splash themself during showing |
53 # even the events generated by splash themself during showing |
52 if wx.Platform == '__WXMSW__': |
54 if wx.Platform == '__WXMSW__': |
53 self.splash.Show() |
55 self.splash.Show() |
54 self.splash.ProcessEvent(wx.PaintEvent()) |
56 self.splash.ProcessEvent(wx.PaintEvent()) |
55 else: |
57 else: |
56 for i in range(0,30): |
58 for i in range(0, 30): |
57 wx.Yield() |
59 wx.Yield() |
58 time.sleep(0.01); |
60 time.sleep(0.01) |
59 |
|
60 |
61 |
61 def Usage(self): |
62 def Usage(self): |
62 print "Usage:" |
63 print "Usage:" |
63 print "%s [Options] [Projectpath] [Buildpath]"%sys.argv[0] |
64 print "%s [Options] [Projectpath] [Buildpath]" % sys.argv[0] |
64 print "" |
65 print "" |
65 print "Supported options:" |
66 print "Supported options:" |
66 print "-h --help Print this help" |
67 print "-h --help Print this help" |
67 print "-u --updatecheck URL Retrieve update information by checking URL" |
68 print "-u --updatecheck URL Retrieve update information by checking URL" |
68 print "-e --extend PathToExtension Extend IDE functionality by loading at start additional extensions" |
69 print "-e --extend PathToExtension Extend IDE functionality by loading at start additional extensions" |
69 print "" |
70 print "" |
70 print "" |
71 print "" |
71 |
72 |
72 def SetCmdOptions(self): |
73 def SetCmdOptions(self): |
73 self.shortCmdOpts = "hu:e:" |
74 self.shortCmdOpts = "hu:e:" |
74 self.longCmdOpts = ["help", "updatecheck=", "extend="] |
75 self.longCmdOpts = ["help", "updatecheck=", "extend="] |
75 |
76 |
106 self.buildpath = args[1] |
107 self.buildpath = args[1] |
107 |
108 |
108 def CreateApplication(self): |
109 def CreateApplication(self): |
109 if os.path.exists("BEREMIZ_DEBUG"): |
110 if os.path.exists("BEREMIZ_DEBUG"): |
110 __builtin__.__dict__["BMZ_DBG"] = True |
111 __builtin__.__dict__["BMZ_DBG"] = True |
111 else : |
112 else: |
112 __builtin__.__dict__["BMZ_DBG"] = False |
113 __builtin__.__dict__["BMZ_DBG"] = False |
113 |
114 |
114 global wxversion, wx |
115 global wxversion, wx |
115 import wxversion |
116 import wxversion |
116 wxversion.select(['2.8', '3.0']) |
117 wxversion.select(['2.8', '3.0']) |
155 if self.updateinfo_url is not None: |
156 if self.updateinfo_url is not None: |
156 updateinfo = _("Fetching %s") % self.updateinfo_url |
157 updateinfo = _("Fetching %s") % self.updateinfo_url |
157 |
158 |
158 def updateinfoproc(): |
159 def updateinfoproc(): |
159 global updateinfo |
160 global updateinfo |
160 try : |
161 try: |
161 import urllib2 |
162 import urllib2 |
162 updateinfo = urllib2.urlopen(self.updateinfo_url,None).read() |
163 updateinfo = urllib2.urlopen(self.updateinfo_url, None).read() |
163 except : |
164 except Exception: |
164 updateinfo = _("update info unavailable.") |
165 updateinfo = _("update info unavailable.") |
165 |
166 |
166 from threading import Thread |
167 from threading import Thread |
167 self.splash.SetText(text=updateinfo) |
168 self.splash.SetText(text=updateinfo) |
168 updateinfoThread = Thread(target=updateinfoproc) |
169 updateinfoThread = Thread(target=updateinfoproc) |
176 |
177 |
177 def InstallExceptionHandler(self): |
178 def InstallExceptionHandler(self): |
178 import version |
179 import version |
179 import tempfile |
180 import tempfile |
180 logpath = tempfile.gettempdir()+os.sep+'Beremiz' |
181 logpath = tempfile.gettempdir()+os.sep+'Beremiz' |
181 BeremizIDE.AddExceptHook(logpath,version.app_version) |
182 BeremizIDE.AddExceptHook(logpath, version.app_version) |
182 |
183 |
183 def ShowUI(self): |
184 def ShowUI(self): |
184 self.frame = BeremizIDE.Beremiz(None, self.projectOpen, self.buildpath) |
185 self.frame = BeremizIDE.Beremiz(None, self.projectOpen, self.buildpath) |
185 if self.splash: |
186 if self.splash: |
186 self.splash.Close() |
187 self.splash.Close() |
188 |
189 |
189 def Start(self): |
190 def Start(self): |
190 self.ProcessCommandLineArgs() |
191 self.ProcessCommandLineArgs() |
191 self.CreateApplication() |
192 self.CreateApplication() |
192 |
193 |
|
194 |
193 if __name__ == '__main__': |
195 if __name__ == '__main__': |
194 beremiz = BeremizIDELauncher() |
196 beremiz = BeremizIDELauncher() |
195 beremiz.Start() |
197 beremiz.Start() |