Changeset 4239


Ignore:
Timestamp:
Jan 9, 2020 2:29:00 PM (22 months ago)
Author:
toby
Message:

fix multi-image use in scripts; work on 32-bit windows build

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • install/bootstrap.py

    r3910 r4239  
    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
     
    213231        missing.append(pkg)
    214232
    215 if missing:
     233if missing and not skipInstallSteps:
    216234    msg = """Sorry, this version of Python cannot be used
    217235for GSAS-II. It is missing the following package(s):
    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',]:
    224         exec('import '+pkg)
    225     sys.exit()
    226 # try:
    227 #     import OpenGL
    228 #     install_with_easyinstall = None
    229 # except:
    230 #     try:               
    231 #           from setuptools.command import easy_install                 
    232 #     except ImportError:
    233 #         print('You are missing the OpenGL Python package. This can be ')
    234 #         print('installed by this script if the setuptools package is installed')
    235 #         print('Please install either OpenGL (pyopengl) or setuptools')
    236 #         print("package and try running this again.")
    237 #         sys.exit()
    238 #     print("Missing the OpenGL Python package. Will attempt to install this later.")
    239 #     def install_with_easyinstall(package):             
    240 #         try:                   
    241 #             print("trying system-wide ")               
    242 #             easy_install.main(['-f',os.path.split(__file__)[0],package])               
    243 #             return             
    244 #         except:               
    245 #             pass               
    246 #         try:                   
    247 #             print("trying user level ")               
    248 #             easy_install.main(['-f',os.path.split(__file__)[0],'--user',package])             
    249 #             return             
    250 #         except:               
    251 #             print("\nInstall of "+package+" failed. Error traceback follows:")
    252 #             import traceback                   
    253 #             print(traceback.format_exc())
    254 #             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)
    255243
    256244if not skipDownloadSteps:
     
    260248    svn = whichsvn() # resets host & port if proxyinfo.txt is found
    261249    if not svn:
    262         print("Sorry, subversion (svn) could not be found on your system.")
    263         print("Please install this or place in path and rerun this.")
    264         #raise Exception('Subversion (svn) not found')
    265         sys.exit()
    266     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)
    267255
    268256#if install_with_easyinstall:           
     
    297285            key = i
    298286            break
     287val = ''
    299288if key:
    300289    val = os.environ[key].strip()
     290if val:
    301291    if val[-1] == '/':
    302292        val = val[:-1]
     
    381371            cmd = [svn, 'cleanup', path2GSAS2]
    382372            s = subprocess.Popen(cmd,stderr=subprocess.PIPE)
    383             out,err = s.communicate()   
     373            out,err = MakeByte2str(s.communicate())
    384374            if err:
    385375                print('subversion returned an error:')
     
    393383        s = subprocess.Popen(cmd,stderr=subprocess.PIPE)
    394384        print('\nsubversion output:')
    395         out,err = s.communicate()
     385        out,err = MakeByte2str(s.communicate())
    396386        if err:
    397387            print('subversion returned an error:')
     
    408398        print(msg)
    409399        s = subprocess.Popen(cmd,stderr=subprocess.PIPE)
    410         out,err = s.communicate()
     400        out,err = MakeByte2str(s.communicate())
    411401        if err:
    412             print('subversion returned an error:')
    413             print(err)
    414             print('  *** GSAS-II failed to be installed. A likely reason is a network access')
    415             print('  *** problem, most commonly because you need to use a network proxy. Please')
    416             print('  *** check with a network administrator or use http://www.whatismyproxy.com/\n')
    417             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)
    418414    print('\n'+75*'*')
    419415
     
    422418    print('import of GSASIIpath completed')
    423419except Exception as err:
    424     print('\n'+75*'=')
    425     print('Failed with import of GSASIIpath. This is unexpected.')
    426     print('GSAS-II will not run without correcting this. Contact toby@anl.gov')
    427     print(err)
    428     print(75*'=')
    429     sys.exit()
    430 
    431 if allBinaries and skipDownloadSteps:
     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)
     423
     424if allBinaries and not skipDownloadSteps:
    432425    print('Loading all binaries with command...')
    433426    if not GSASIIpath.svnSwitchDir('AllBinaries','',g2home+ 'Binaries/',None,True):
    434         print('Binary load failed')
    435         sys.exit()
     427        msg = 'Binary load failed'
     428        BailOut(msg)
    436429else:
    437430    GSASIIpath.DownloadG2Binaries(g2home)
     
    457450p = subprocess.Popen([sys.executable,'-c',script],stdout=subprocess.PIPE,stderr=subprocess.PIPE,
    458451                     cwd=path2GSAS2)
    459 res,err = p.communicate()
     452res,err = MakeByte2str(p.communicate())
    460453if '==OK==' not in str(res) or p.returncode != 0:
    461     print('\n'+75*'=')
    462     print('Failed when testing the GSAS-II compiled files. GSAS-II will not run')
    463     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'
    464457    if res:
    465         print(res.decode())
     458        msg += res.decode()
     459        msg += '\n'
    466460    if err:
    467         print(err.decode())
     461        msg += err.decode()
    468462    #print('\nAttempting to open a web page on compiling GSAS-II...')
    469     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)
    470465    #import webbrowser
    471466    #webbrowser.open_new('https://subversion.xray.aps.anl.gov/trac/pyGSAS/wiki/CompileGSASII')
    472     print(75*'=')
     467    #print(75*'=')
    473468#    if '86' in platform.machine() and (sys.platform.startswith('linux')
    474469#                                        or sys.platform == "darwin"
     
    477472#    else:
    478473#        print('Platform '+sys.platform+' with processor type '+platform.machine()+' not is supported')
    479     sys.exit()
    480474else:
    481475    print('Successfully tested compiled routines')
  • install/g2complete/src/bootstrap.py

    r4238 r4239  
    404404            if os.path.exists(os.path.join(path2GSAS2,"makeBat.py")):
    405405                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'
     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'
    408408                msg += '\ncheck with a network administrator or use http://www.whatismyproxy.com/'
    409409            else:               
  • install/setversion.py

    r3912 r4239  
     1import sys
     2import platform
    13import subprocess
    24
     
    3941    fp = open(fil+'.template','r')
    4042    out = fp.read().replace('**Version**',version)
     43    if sys.platform == "win32" and platform.architecture()[0] != '64bit':
     44        print('changing for 32-bit windows'
     45        out = out.replace('win-64','win-32')
    4146    fp.close()
    4247    print('Creating',fil)
  • trunk/GSASIIscriptable.py

    r4211 r4239  
    17641764    formatName = Controls.get('formatName','')
    17651765    imagefile = ImgObj.data['data'][1]
    1766     ImageTag = None # fix this for multiimage files
     1766    if isinstance(imagefile, tuple) or isinstance(imagefile, list):
     1767        imagefile, ImageTag =  imagefile # fix for multiimage files
     1768    else:
     1769        ImageTag = None # single-image file
    17671770    sumImg = G2fil.RereadImageData(ImageReaderlist,imagefile,ImageTag=ImageTag,FormatName=formatName)
    17681771    if sumImg is None:
Note: See TracChangeset for help on using the changeset viewer.