--- a/Beremiz.py Thu Mar 09 18:03:57 2017 +0300
+++ b/Beremiz.py Fri Mar 10 17:09:48 2017 +0300
@@ -5,6 +5,7 @@
# programming IEC 61131-3 automates supporting plcopen standard and CanFestival.
#
# Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD
+# Copyright (C) 2016: Andrey Skvortsov <andrej.skvortzov@gmail.com>
#
# See COPYING file for copyrights details.
#
@@ -22,10 +23,8 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-updateinfo_url = None
-
-import os, sys, getopt
-import __builtin__
+
+import os, sys
import tempfile
import shutil
import random
@@ -35,114 +34,9 @@
beremiz_dir = os.path.dirname(os.path.realpath(__file__))
-if __name__ == '__main__':
- import wxversion
- wxversion.select(['2.8', '3.0'])
- import wx
-
-from wx.lib.agw.advancedsplash import AdvancedSplash
-
def Bpath(*args):
return os.path.join(beremiz_dir,*args)
-def ShowSplashScreen():
- bmp = wx.Image(Bpath("images", "splash.png")).ConvertToBitmap()
- #splash=AdvancedSplash(None, bitmap=bmp, style=wx.SPLASH_CENTRE_ON_SCREEN, timeout=4000)
- splash = AdvancedSplash(None, bitmap=bmp)
-
- # process all events
- # even the events generated by splash themself during showing
- for i in range(0,30):
- wx.Yield()
- time.sleep(0.01);
- return splash
-
-if __name__ == '__main__':
- def usage():
- print "\nUsage of Beremiz.py :"
- print "\n %s [Projectpath] [Buildpath]\n"%sys.argv[0]
-
- try:
- opts, args = getopt.getopt(sys.argv[1:], "hu:e:", ["help", "updatecheck=", "extend="])
- except getopt.GetoptError:
- # print help information and exit:
- usage()
- sys.exit(2)
-
- extensions=[]
-
- for o, a in opts:
- if o in ("-h", "--help"):
- usage()
- sys.exit()
- if o in ("-u", "--updatecheck"):
- updateinfo_url = a
- if o in ("-e", "--extend"):
- extensions.append(a)
-
- if len(args) > 2:
- usage()
- sys.exit()
- elif len(args) == 1:
- projectOpen = args[0]
- buildpath = None
- elif len(args) == 2:
- projectOpen = args[0]
- buildpath = args[1]
- else:
- projectOpen = None
- buildpath = None
-
- if os.path.exists("BEREMIZ_DEBUG"):
- __builtin__.__dict__["BMZ_DBG"] = True
- else :
- __builtin__.__dict__["BMZ_DBG"] = False
-
- if wx.VERSION >= (3, 0, 0):
- app = wx.App(redirect=BMZ_DBG)
- else:
- app = wx.PySimpleApp(redirect=BMZ_DBG)
-
- app.SetAppName('beremiz')
- if wx.VERSION < (3, 0, 0):
- wx.InitAllImageHandlers()
-
- # popup splash
- splash = ShowSplashScreen()
-
- # load internatialization files
- from util.misc import InstallLocalRessources
- InstallLocalRessources(beremiz_dir)
-
- if updateinfo_url is not None:
- updateinfo = _("Fetching %s") % updateinfo_url
- # warn for possible updates
- def updateinfoproc():
- global updateinfo
- try :
- import urllib2
- updateinfo = urllib2.urlopen(updateinfo_url,None).read()
- except :
- updateinfo = _("update info unavailable.")
-
- from threading import Thread
- splash.SetText(text=updateinfo)
- wx.Yield()
- updateinfoThread = Thread(target=updateinfoproc)
- updateinfoThread.start()
- updateinfoThread.join(2)
- splash.SetText(text=updateinfo)
- wx.Yield()
-
- # Load extensions
- for extfilename in extensions:
- from util.TranslationCatalogs import AddCatalog
- from util.BitmapLibrary import AddBitmapFolder
- extension_folder = os.path.split(os.path.realpath(extfilename))[0]
- sys.path.append(extension_folder)
- AddCatalog(os.path.join(extension_folder, "locale"))
- AddBitmapFolder(os.path.join(extension_folder, "images"))
- execfile(extfilename, locals())
import wx.lib.buttons, wx.lib.statbmp, wx.stc
@@ -1281,14 +1175,3 @@
sys.excepthook(*sys.exc_info())
self.run = run_with_except_hook
threading.Thread.__init__ = init
-
-if __name__ == '__main__':
- # Install a exception handle for bug reports
- logpath = tempfile.gettempdir()+os.sep+'Beremiz'
- AddExceptHook(logpath ,version.app_version)
-
- frame = Beremiz(None, projectOpen, buildpath)
- if splash:
- splash.Close()
- frame.Show()
- app.MainLoop()