- Timestamp:
- Apr 6, 2020 6:05:40 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIdataGUI.py
r4389 r4396 407 407 dlg.Destroy() 408 408 sys.exit() 409 409 410 410 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. 412 We 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. 412 413 ''' 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 420 476 try: 421 dlg.ShowModal()477 res = dlg.ShowModal() 422 478 finally: 423 479 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() 425 498 application.main = GSASII(None) # application.main is the main wx.Frame (G2frame in most places) 426 499 application.SetTopWindow(application.main) … … 490 563 if GSASIIpath.GetConfigValue('debug'): 491 564 def OnIPython(event): 565 G2frame = self 492 566 GSASIIpath.IPyBreak() 493 567 item = parent.Append(wx.ID_ANY,"IPython Console",'') -
trunk/GSASIIpath.py
r4352 r4396 507 507 version = str(version) 508 508 # start the upgrade in a separate interpreter (avoids loading .pyd files) 509 proc = subprocess.Popen([sys.executable,__file__,projectfile,version]) 509 ex = sys.executable 510 if sys.platform == "darwin": # mac requires pythonw which is not always reported as sys.executable 511 if os.path.exists(ex+'w'): ex += 'w' 512 proc = subprocess.Popen([ex,__file__,projectfile,version]) 510 513 if sys.platform != "win32": 511 514 proc.wait() … … 1032 1035 subprocess.Popen(["osascript","-e",script]) 1033 1036 1037 def findConda(): 1038 '''Determines if GSAS-II has been installed as g2conda or gsas2full 1039 with conda located relative to this file. 1040 We could also look for conda relative to the python (sys.executable) 1041 image, but I don't want to muck around with python that someone else 1042 installed. 1043 ''' 1044 parent = os.path.split(path2GSAS2)[0] 1045 if sys.platform != "win32": 1046 activate = os.path.join(parent,'bin','activate') 1047 conda = os.path.join(parent,'bin','conda') 1048 else: 1049 activate = os.path.join(parent,'Scripts','activate.bat') 1050 conda = os.path.join(parent,'condabin','conda.bat') 1051 if os.path.exists(activate) and os.path.exists(conda): 1052 return conda,activate 1053 else: 1054 return None 1055 1056 def runScript(cmds=[], wait=False, G2frame=None): 1057 '''run a shell script of commands in an external process 1058 1059 :param list cmds: a list of str's, each ietm containing a shell (cmd.exe 1060 or bash) command 1061 :param bool wait: if True indicates the commands should be run and then 1062 the script should return. If False, then the currently running Python 1063 will exit. Default is False 1064 :param wx.Frame G2frame: provides the location of the current .gpx file 1065 to be used to restart GSAS-II after running the commands, if wait 1066 is False. Default is None which prevents restarting GSAS-II regardless of 1067 the value of wait. 1068 ''' 1069 import tempfile 1070 if not cmds: #debug 1071 print('nothing to do in runScript') 1072 return 1073 if sys.platform != "win32": 1074 suffix = '.sh' 1075 else: 1076 suffix = '.bat' 1077 1078 fp = tempfile.NamedTemporaryFile(mode='w', suffix=suffix, delete=False) 1079 shellname = fp.name 1080 for line in cmds: 1081 fp.write(line) 1082 fp.write('\n') 1083 1084 if not wait: 1085 if G2frame: 1086 projectfile = '' 1087 if G2frame.GSASprojectfile: 1088 projectfile = os.path.realpath(G2frame.GSASprojectfile) 1089 main = os.path.join(path2GSAS2,'GSASII.py') 1090 ex = sys.executable 1091 if sys.platform == "darwin": # mac requires pythonw which is not always reported as sys.executable 1092 if os.path.exists(ex+'w'): ex += 'w' 1093 print ('restart using ',' '.join([ex,main,projectfile])) 1094 fp.write(' '.join([ex,main,projectfile])) 1095 fp.write('\n') 1096 fp.close() 1097 1098 # start the upgrade in a separate interpreter (avoids loading .pyd files) 1099 if sys.platform != "win32": 1100 proc = subprocess.Popen(['bash',shellname]) 1101 else: 1102 proc = subprocess.Popen([shellname],shell=True) 1103 if wait: 1104 proc.wait() 1105 else: 1106 if sys.platform != "win32": proc.wait() 1107 sys.exit() 1108 1034 1109 if __name__ == '__main__': 1035 1110 '''What follows is called to update (or downdate) GSAS-II in a separate process.
Note: See TracChangeset
for help on using the changeset viewer.