20 # |
21 # |
21 # You should have received a copy of the GNU General Public License |
22 # You should have received a copy of the GNU General Public License |
22 # along with this program; if not, write to the Free Software |
23 # along with this program; if not, write to the Free Software |
23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
24 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
24 |
25 |
25 updateinfo_url = None |
26 |
26 |
27 import os, sys |
27 import os, sys, getopt |
|
28 import __builtin__ |
|
29 import tempfile |
28 import tempfile |
30 import shutil |
29 import shutil |
31 import random |
30 import random |
32 import time |
31 import time |
33 import version |
32 import version |
34 from types import ListType |
33 from types import ListType |
35 |
34 |
36 beremiz_dir = os.path.dirname(os.path.realpath(__file__)) |
35 beremiz_dir = os.path.dirname(os.path.realpath(__file__)) |
37 |
36 |
38 if __name__ == '__main__': |
|
39 import wxversion |
|
40 wxversion.select(['2.8', '3.0']) |
|
41 import wx |
|
42 |
|
43 from wx.lib.agw.advancedsplash import AdvancedSplash |
|
44 |
|
45 def Bpath(*args): |
37 def Bpath(*args): |
46 return os.path.join(beremiz_dir,*args) |
38 return os.path.join(beremiz_dir,*args) |
47 |
39 |
48 def ShowSplashScreen(): |
|
49 bmp = wx.Image(Bpath("images", "splash.png")).ConvertToBitmap() |
|
50 #splash=AdvancedSplash(None, bitmap=bmp, style=wx.SPLASH_CENTRE_ON_SCREEN, timeout=4000) |
|
51 splash = AdvancedSplash(None, bitmap=bmp) |
|
52 |
|
53 # process all events |
|
54 # even the events generated by splash themself during showing |
|
55 for i in range(0,30): |
|
56 wx.Yield() |
|
57 time.sleep(0.01); |
|
58 return splash |
|
59 |
|
60 if __name__ == '__main__': |
|
61 def usage(): |
|
62 print "\nUsage of Beremiz.py :" |
|
63 print "\n %s [Projectpath] [Buildpath]\n"%sys.argv[0] |
|
64 |
|
65 try: |
|
66 opts, args = getopt.getopt(sys.argv[1:], "hu:e:", ["help", "updatecheck=", "extend="]) |
|
67 except getopt.GetoptError: |
|
68 # print help information and exit: |
|
69 usage() |
|
70 sys.exit(2) |
|
71 |
|
72 extensions=[] |
|
73 |
|
74 for o, a in opts: |
|
75 if o in ("-h", "--help"): |
|
76 usage() |
|
77 sys.exit() |
|
78 if o in ("-u", "--updatecheck"): |
|
79 updateinfo_url = a |
|
80 if o in ("-e", "--extend"): |
|
81 extensions.append(a) |
|
82 |
|
83 if len(args) > 2: |
|
84 usage() |
|
85 sys.exit() |
|
86 elif len(args) == 1: |
|
87 projectOpen = args[0] |
|
88 buildpath = None |
|
89 elif len(args) == 2: |
|
90 projectOpen = args[0] |
|
91 buildpath = args[1] |
|
92 else: |
|
93 projectOpen = None |
|
94 buildpath = None |
|
95 |
|
96 if os.path.exists("BEREMIZ_DEBUG"): |
|
97 __builtin__.__dict__["BMZ_DBG"] = True |
|
98 else : |
|
99 __builtin__.__dict__["BMZ_DBG"] = False |
|
100 |
|
101 if wx.VERSION >= (3, 0, 0): |
|
102 app = wx.App(redirect=BMZ_DBG) |
|
103 else: |
|
104 app = wx.PySimpleApp(redirect=BMZ_DBG) |
|
105 |
|
106 app.SetAppName('beremiz') |
|
107 if wx.VERSION < (3, 0, 0): |
|
108 wx.InitAllImageHandlers() |
|
109 |
|
110 # popup splash |
|
111 splash = ShowSplashScreen() |
|
112 |
|
113 # load internatialization files |
|
114 from util.misc import InstallLocalRessources |
|
115 InstallLocalRessources(beremiz_dir) |
|
116 |
|
117 if updateinfo_url is not None: |
|
118 updateinfo = _("Fetching %s") % updateinfo_url |
|
119 # warn for possible updates |
|
120 def updateinfoproc(): |
|
121 global updateinfo |
|
122 try : |
|
123 import urllib2 |
|
124 updateinfo = urllib2.urlopen(updateinfo_url,None).read() |
|
125 except : |
|
126 updateinfo = _("update info unavailable.") |
|
127 |
|
128 from threading import Thread |
|
129 splash.SetText(text=updateinfo) |
|
130 wx.Yield() |
|
131 updateinfoThread = Thread(target=updateinfoproc) |
|
132 updateinfoThread.start() |
|
133 updateinfoThread.join(2) |
|
134 splash.SetText(text=updateinfo) |
|
135 wx.Yield() |
|
136 |
|
137 # Load extensions |
|
138 for extfilename in extensions: |
|
139 from util.TranslationCatalogs import AddCatalog |
|
140 from util.BitmapLibrary import AddBitmapFolder |
|
141 extension_folder = os.path.split(os.path.realpath(extfilename))[0] |
|
142 sys.path.append(extension_folder) |
|
143 AddCatalog(os.path.join(extension_folder, "locale")) |
|
144 AddBitmapFolder(os.path.join(extension_folder, "images")) |
|
145 execfile(extfilename, locals()) |
|
146 |
40 |
147 |
41 |
148 import wx.lib.buttons, wx.lib.statbmp, wx.stc |
42 import wx.lib.buttons, wx.lib.statbmp, wx.stc |
149 import cPickle |
43 import cPickle |
150 import types, time, re, platform, time, traceback, commands |
44 import types, time, re, platform, time, traceback, commands |