Beremiz.py
changeset 588 aa5a08d20ba1
parent 571 427bf9130d12
child 589 22e83880cdd9
equal deleted inserted replaced
587:c6354f7fe26e 588:aa5a08d20ba1
    20 #
    20 #
    21 #You should have received a copy of the GNU General Public
    21 #You should have received a copy of the GNU General Public
    22 #License along with this library; if not, write to the Free Software
    22 #License along with this library; if not, write to the Free Software
    23 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    23 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    24 
    24 
    25 __version__ = "$Revision$"
    25 
       
    26 updateinfo_url = None
    26 
    27 
    27 import os, sys, getopt, wx
    28 import os, sys, getopt, wx
       
    29 from wx.lib.agw.advancedsplash import AdvancedSplash
    28 import tempfile
    30 import tempfile
    29 import shutil
    31 import shutil
    30 import random
    32 import random
    31 import time
    33 import time
    32 
    34 
    39     def usage():
    41     def usage():
    40         print "\nUsage of Beremiz.py :"
    42         print "\nUsage of Beremiz.py :"
    41         print "\n   %s [Projectpath] [Buildpath]\n"%sys.argv[0]
    43         print "\n   %s [Projectpath] [Buildpath]\n"%sys.argv[0]
    42     
    44     
    43     try:
    45     try:
    44         opts, args = getopt.getopt(sys.argv[1:], "h", ["help"])
    46         opts, args = getopt.getopt(sys.argv[1:], "hu:", ["help", "updatecheck="])
    45     except getopt.GetoptError:
    47     except getopt.GetoptError:
    46         # print help information and exit:
    48         # print help information and exit:
    47         usage()
    49         usage()
    48         sys.exit(2)
    50         sys.exit(2)
    49     
    51     
    50     for o, a in opts:
    52     for o, a in opts:
    51         if o in ("-h", "--help"):
    53         if o in ("-h", "--help"):
    52             usage()
    54             usage()
    53             sys.exit()
    55             sys.exit()
       
    56         if o in ("-u", "--updatecheck"):
       
    57             updateinfo_url = a
    54     
    58     
    55     if len(args) > 2:
    59     if len(args) > 2:
    56         usage()
    60         usage()
    57         sys.exit()
    61         sys.exit()
    58     elif len(args) == 1:
    62     elif len(args) == 1:
    72 
    76 
    73     app = wx.PySimpleApp(redirect=BMZ_DBG)
    77     app = wx.PySimpleApp(redirect=BMZ_DBG)
    74     app.SetAppName('beremiz')
    78     app.SetAppName('beremiz')
    75     wx.InitAllImageHandlers()
    79     wx.InitAllImageHandlers()
    76     
    80     
       
    81     # popup splash
    77     bmp = wx.Image(Bpath("images","splash.png")).ConvertToBitmap()
    82     bmp = wx.Image(Bpath("images","splash.png")).ConvertToBitmap()
    78     splash=wx.SplashScreen(bmp,wx.SPLASH_CENTRE_ON_SCREEN, 1000, None)
    83     #splash=AdvancedSplash(None, bitmap=bmp, style=wx.SPLASH_CENTRE_ON_SCREEN, timeout=4000)
       
    84     splash=AdvancedSplash(None, bitmap=bmp)
    79     wx.Yield()
    85     wx.Yield()
       
    86 
       
    87     if updateinfo_url is not None:
       
    88         updateinfo = "Fetching %s" % updateinfo_url
       
    89         # warn for possible updates
       
    90         def updateinfoproc():
       
    91             global updateinfo
       
    92             try :
       
    93                 import urllib2
       
    94                 updateinfo = urllib2.urlopen(updateinfo_url,None).read()
       
    95             except :
       
    96                 updateinfo = "update info unavailable." 
       
    97                 
       
    98         from threading import Thread
       
    99         splash.SetText(text=updateinfo)
       
   100         wx.Yield()
       
   101         updateinfoThread = Thread(target=updateinfoproc)
       
   102         updateinfoThread.start()
       
   103         updateinfoThread.join(2)
       
   104         splash.SetText(text=updateinfo)
       
   105         wx.Yield()
    80 
   106 
    81 # Import module for internationalization
   107 # Import module for internationalization
    82 import gettext
   108 import gettext
    83 import __builtin__
   109 import __builtin__
    84 
   110 
  1578     #sys.excepthook = lambda *args: wx.CallAfter(handle_exception, *args)
  1604     #sys.excepthook = lambda *args: wx.CallAfter(handle_exception, *args)
  1579     sys.excepthook = handle_exception
  1605     sys.excepthook = handle_exception
  1580 
  1606 
  1581 if __name__ == '__main__':
  1607 if __name__ == '__main__':
  1582     # Install a exception handle for bug reports
  1608     # Install a exception handle for bug reports
  1583     AddExceptHook(os.getcwd(),__version__)
  1609     AddExceptHook(os.getcwd(),updateinfo_url)
  1584     
  1610     
  1585     frame = Beremiz(None, projectOpen, buildpath)
  1611     frame = Beremiz(None, projectOpen, buildpath)
  1586     frame.Show()
  1612     frame.Show()
  1587     splash.Close()
  1613     splash.Close()
  1588     app.MainLoop()
  1614     app.MainLoop()