Ignore:
Timestamp:
Apr 6, 2020 6:05:40 PM (20 months ago)
Author:
toby
Message:

improve end-of-life message, add tools to run bash/bat scripts outside GSAS-II

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIdataGUI.py

    r4389 r4396  
    407407            dlg.Destroy()
    408408        sys.exit()
    409        
     409
    410410    if platform.python_version()[:3] == '2.7':
    411         dlg = wx.MessageDialog(None,
     411        msg = '''The end-of-life for python 2.7 was January 1, 2020.
     412We strongly recommend reinstalling GSAS-II from a new installation kit as we may not be able to offer support for operation of GSAS-II in python 2.7. See instructions for details.
    412413'''
    413 The end-of-life for python 2.7 was January 1, 2020.
    414 We strongly recommend reinstalling GSAS-II from a new installation kit as
    415 we may not be able to offer support for operation of GSAS-II in python 2.7.
    416 GSAS-II installation kits can be found at https://subversion.xray.aps.anl.gov/trac/pyGSAS
    417 which is easily found by searching the web for GSAS-II
    418 The kit will install python 3.7 and all current packages as well as the newest version of GSAS-II.''',
    419             'End-Of-Life warning for Python 2.7',wx.OK)
     414        download = ''
     415        cmds = []
     416        instructions = 'https://subversion.xray.aps.anl.gov/trac/pyGSAS'
     417        if sys.platform == "win32":
     418            download = 'https://subversion.xray.aps.anl.gov/admin_pyGSAS/downloads/gsas2full-Latest-Windows-x86_64.exe'
     419            instructions = 'https://subversion.xray.aps.anl.gov/trac/pyGSAS/wiki/SingleStepWindowsIllustrated'
     420        elif sys.platform == "darwin":
     421            cmds = ['echo starting download, please wait...',
     422                    '''echo 'curl "https://subversion.xray.aps.anl.gov/admin_pyGSAS/downloads/gsas2full-Latest-MacOSX-x86_64.sh" > /tmp/g2.sh; bash /tmp/g2.sh' ''',
     423                    'curl "https://subversion.xray.aps.anl.gov/admin_pyGSAS/downloads/gsas2full-Latest-MacOSX-x86_64.sh" > /tmp/g2.sh; bash /tmp/g2.sh'
     424                    ]
     425            instructions = 'https://subversion.xray.aps.anl.gov/trac/pyGSAS/wiki/MacSingleStepInstallerFigs'
     426        elif sys.platform.startswith("linux"):
     427            download = 'https://subversion.xray.aps.anl.gov/admin_pyGSAS/downloads/gsas2full-Latest-Linux-x86_64.sh'
     428            instructions = 'https://subversion.xray.aps.anl.gov/trac/pyGSAS/wiki/LinuxSingleStepInstaller'
     429        else:
     430            print(u'Unknown platform: '+sys.platform)
     431        if platform.architecture()[0] != '64bit' and sys.platform == "win32":
     432            msg += '''\nYou are currently using 32-bit Python. Please check if you are running 32-bit windows or 64-bit windows (use Start/Settings/System/About & look for "System type".
     433            We recommend using the 64-bit installer if you have 64-bit windows.'''
     434            download = ''
     435        elif platform.architecture()[0] != '64bit' and sys.platform.startswith("linux"):
     436            msg += '''\nYou are using 32-bit Python. We now only package for 64-bit linux.
     437            If you are running 32-bit linux you will need to install Python yourself.
     438            See instructions at https://subversion.xray.aps.anl.gov/trac/pyGSAS/wiki/InstallLinux'''
     439            instructions = 'https://subversion.xray.aps.anl.gov/trac/pyGSAS/wiki/InstallLinux'
     440        dlg = wx.Dialog(None,wx.ID_ANY,'End-Of-Life warning for Python 2.7',
     441            style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
     442        mainSizer = wx.BoxSizer(wx.VERTICAL)
     443        txt = wx.StaticText(dlg,wx.ID_ANY,G2G.StripIndents(msg))
     444        mainSizer.Add(txt)
     445        txt.Wrap(600)
     446        dlg.SetSizer(mainSizer)
     447        btnsizer = wx.BoxSizer(wx.HORIZONTAL)
     448        btnsizer.Add((1,1),1,wx.EXPAND,1)
     449        OKbtn = wx.Button(dlg, wx.ID_OK,'Continue')
     450        OKbtn.SetDefault()
     451        OKbtn.Bind(wx.EVT_BUTTON,lambda event: dlg.EndModal(wx.ID_OK))
     452        btnsizer.Add(OKbtn)
     453
     454        btn = wx.Button(dlg, wx.ID_ANY,'Show Instructions')
     455        def openInstructions(event):
     456            G2G.ShowWebPage(instructions,None)
     457        btn.Bind(wx.EVT_BUTTON, openInstructions)
     458        btnsizer.Add(btn)
     459        if download:
     460            btn = wx.Button(dlg, wx.ID_ANY,'Start Download')
     461            btn.Bind(wx.EVT_BUTTON,lambda event: dlg.EndModal(wx.ID_YES))
     462            btnsizer.Add(btn)
     463        elif cmds:
     464            btn = wx.Button(dlg, wx.ID_ANY,'Start Install')
     465            btn.Bind(wx.EVT_BUTTON,lambda event: dlg.EndModal(wx.ID_CANCEL))
     466            btnsizer.Add(btn)
     467
     468        #btn = wx.Button(dlg, wx.ID_CANCEL)
     469        #btnsizer.AddButton(btn)
     470        btnsizer.Add((1,1),1,wx.EXPAND,1)
     471        #btnsizer.Realize()
     472        mainSizer.Add((-1,5),1,wx.EXPAND,1)
     473        mainSizer.Add(btnsizer,0,wx.ALIGN_CENTER,0)
     474        mainSizer.Add((-1,10))
     475        res = 0
    420476        try:
    421             dlg.ShowModal()
     477            res = dlg.ShowModal()
    422478        finally:
    423479            dlg.Destroy()
    424            
     480        if res == wx.ID_YES:
     481            G2G.ShowWebPage(download,None)
     482            G2G.ShowWebPage(instructions,None)
     483            wx.Sleep(1)
     484            dlg = wx.MessageDialog(None,G2G.StripIndents(
     485                    '''Download has been started in your browser; installation instructions will also be shown in a web page\n\nPress OK to exit GSAS-II, Cancel to continue.'''),
     486                    'start install',wx.OK|wx.CANCEL)
     487            if dlg.ShowModal() == wx.ID_OK:
     488                sys.exit()
     489        elif res == wx.ID_CANCEL:
     490            dlg = wx.MessageDialog(None,G2G.StripIndents(
     491                    '''Press OK to continue. Instructions will be shown in a web page.
     492                    Download and installation will start in the terminal window after you press OK. Respond to questions there.'''),
     493                    'start install',wx.OK|wx.CANCEL)
     494            if dlg.ShowModal() == wx.ID_OK:
     495                G2G.ShowWebPage(instructions,None)
     496                GSASIIpath.runScript(cmds, wait=True)   
     497                sys.exit()
    425498    application.main = GSASII(None)  # application.main is the main wx.Frame (G2frame in most places)
    426499    application.SetTopWindow(application.main)
     
    490563        if GSASIIpath.GetConfigValue('debug'):
    491564            def OnIPython(event):
     565                G2frame = self
    492566                GSASIIpath.IPyBreak()
    493567            item = parent.Append(wx.ID_ANY,"IPython Console",'')
Note: See TracChangeset for help on using the changeset viewer.