Ignore:
Timestamp:
Jan 8, 2020 7:30:23 PM (3 years ago)
Author:
toby
Message:

more install fixes: add error message

File:
1 edited

Legend:

Unmodified
Added
Removed
  • install/g2complete/src/bootstrap.py

    r3934 r4238  
    1212skipDownloadSteps = False
    1313skipProxy = False
     14showWXerror = False
    1415help = False
    1516allBinaries = False
     
    1718    if 'noinstall' in a.lower():
    1819        skipInstallSteps = True
     20        showWXerror = True
    1921    elif 'nonet' in a.lower():
    2022        skipDownloadSteps = True
     
    5153################################################################################
    5254################################################################################
     55def BailOut(msg):
     56    '''Exit with an error message. Use a GUI to show the error when
     57    showWXerror == True (when --noinstall is specified)
     58    '''
     59    print(msg)
     60    if showWXerror:
     61        import wx
     62        app = wx.App()
     63        app.MainLoop()
     64        dlg = wx.MessageDialog(None,msg,'GSAS-II installation error',
     65                wx.OK | wx.ICON_ERROR | wx.STAY_ON_TOP)
     66        dlg.Raise()
     67        dlg.ShowModal()
     68        dlg.Destroy()
     69    sys.exit()
     70       
    5371def GetConfigValue(*args): return True
    5472# routines copied from GSASIIpath.py
     
    218236\t"""
    219237    for pkg in missing: msg += " "+pkg
    220     print(msg)
    221     print("\nPlease install these package(s) and try running this again.")
    222     print("Showing first error: ")
    223     for pkg in ['numpy','scipy','matplotlib','wx','OpenGL',]:
    224         exec('import '+pkg)
    225     sys.exit()
     238    msg += "\nPlease install these package(s) and try running bootstrap.py again."
     239    #print("Showing first error: ")
     240    #for pkg in ['numpy','scipy','matplotlib','wx','OpenGL',]:
     241    #    exec('import '+pkg)
     242    BailOut(msg)
    226243
    227244if not skipDownloadSteps:
     
    231248    svn = whichsvn() # resets host & port if proxyinfo.txt is found
    232249    if not svn:
    233         print("Sorry, subversion (svn) could not be found on your system.")
    234         print("Please install this or place in path and rerun this.")
    235         #raise Exception('Subversion (svn) not found')
    236         sys.exit()
    237     print(' found svn image: '+svn)
     250        msg ="Sorry, subversion (svn) could not be found on your system."
     251        msg += "\nPlease install this or place in path and rerun this."
     252        BailOut(msg)
     253    else:
     254        print(' found svn image: '+svn)
    238255
    239256#if install_with_easyinstall:           
     
    354371            cmd = [svn, 'cleanup', path2GSAS2]
    355372            s = subprocess.Popen(cmd,stderr=subprocess.PIPE)
    356             out,err = s.communicate()   
     373            out,err = MakeByte2str(s.communicate())
    357374            if err:
    358375                print('subversion returned an error:')
     
    366383        s = subprocess.Popen(cmd,stderr=subprocess.PIPE)
    367384        print('\nsubversion output:')
    368         out,err = s.communicate()
     385        out,err = MakeByte2str(s.communicate())
    369386        if err:
    370387            print('subversion returned an error:')
     
    381398        print(msg)
    382399        s = subprocess.Popen(cmd,stderr=subprocess.PIPE)
    383         out,err = s.communicate()
     400        out,err = MakeByte2str(s.communicate())
    384401        if err:
    385             print('subversion returned an error:')
    386             print(err)
    387             print('  *** GSAS-II failed to be installed. A likely reason is a network access')
    388             print('  *** problem, most commonly because you need to use a network proxy. Please')
    389             print('  *** check with a network administrator or use http://www.whatismyproxy.com/\n')
    390             sys.exit()
     402            msg = 'subversion returned an error:\n'
     403            msg += err
     404            if os.path.exists(os.path.join(path2GSAS2,"makeBat.py")):
     405                msg += '\n\nGSAS-II failed to be updated. A likely reason is a network access'
     406                msg += '\nproblem. If your web browser works, but the update did not'
     407                msg += '\nthe most common reason is you need to use a network proxy. Please'
     408                msg += '\ncheck with a network administrator or use http://www.whatismyproxy.com/'
     409            else:               
     410                msg += '\n\n  *** GSAS-II failed to be installed. A likely reason is a network access'
     411                msg += '\n  *** problem, most commonly because you need to use a network proxy. Please'
     412                msg += '  *** check with a network administrator or use http://www.whatismyproxy.com/\n'
     413            BailOut(msg)
    391414    print('\n'+75*'*')
    392415
     
    395418    print('import of GSASIIpath completed')
    396419except Exception as err:
    397     print('\n'+75*'=')
    398     print('Failed with import of GSASIIpath. This is unexpected.')
    399     print('GSAS-II will not run without correcting this. Contact toby@anl.gov')
    400     print(err)
    401     print(75*'=')
    402     sys.exit()
     420    msg = 'Failed with import of GSASIIpath. This is unexpected.'
     421    msg += '\nGSAS-II will not run without correcting this. Contact toby@anl.gov'
     422    BailOut(msg)
    403423
    404424if allBinaries and not skipDownloadSteps:
    405425    print('Loading all binaries with command...')
    406426    if not GSASIIpath.svnSwitchDir('AllBinaries','',g2home+ 'Binaries/',None,True):
    407         print('Binary load failed')
    408         sys.exit()
     427        msg = 'Binary load failed'
     428        BailOut(msg)
    409429else:
    410430    GSASIIpath.DownloadG2Binaries(g2home)
     
    430450p = subprocess.Popen([sys.executable,'-c',script],stdout=subprocess.PIPE,stderr=subprocess.PIPE,
    431451                     cwd=path2GSAS2)
    432 res,err = p.communicate()
     452res,err = MakeByte2str(p.communicate())
    433453if '==OK==' not in str(res) or p.returncode != 0:
    434     print('\n'+75*'=')
    435     print('Failed when testing the GSAS-II compiled files. GSAS-II will not run')
    436     print('without correcting this.\n\nError message:')
     454    #print('\n'+75*'=')
     455    msg = 'Failed when testing the GSAS-II compiled files. GSAS-II will not run'
     456    msg += ' without correcting this.\n\nError message:\n'
    437457    if res:
    438         print(res.decode())
     458        msg += res.decode()
     459        msg += '\n'
    439460    if err:
    440         print(err.decode())
     461        msg += err.decode()
    441462    #print('\nAttempting to open a web page on compiling GSAS-II...')
    442     print('Please see web page\nhttps://subversion.xray.aps.anl.gov/trac/pyGSAS/wiki/CompileGSASII')
     463    msg += '\n\nPlease see web page\nhttps://subversion.xray.aps.anl.gov/trac/pyGSAS/wiki/CompileGSASII'
     464    BailOut(msg)
    443465    #import webbrowser
    444466    #webbrowser.open_new('https://subversion.xray.aps.anl.gov/trac/pyGSAS/wiki/CompileGSASII')
    445     print(75*'=')
     467    #print(75*'=')
    446468#    if '86' in platform.machine() and (sys.platform.startswith('linux')
    447469#                                        or sys.platform == "darwin"
     
    450472#    else:
    451473#        print('Platform '+sys.platform+' with processor type '+platform.machine()+' not is supported')
    452     sys.exit()
    453474else:
    454475    print('Successfully tested compiled routines')
Note: See TracChangeset for help on using the changeset viewer.