Changeset 3107 for install


Ignore:
Timestamp:
Oct 2, 2017 3:01:00 PM (6 years ago)
Author:
toby
Message:

more diagnostics; start improvements on Linux shortcut

File:
1 edited

Legend:

Unmodified
Added
Removed
  • install/bootstrap.py

    r3025 r3107  
    55
    66g2home = 'https://subversion.xray.aps.anl.gov/pyGSAS/'
     7path2GSAS2 = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
     8print('Running bootstrap from {}'.format(path2GSAS2))
    79################################################################################
    810################################################################################
     
    161163            print traceback.format_exc()                 
    162164            sys.exit()
    163 # path to where this script is located
    164 gsaspath = os.path.split(sys.argv[0])[0]
    165 if not gsaspath: gsaspath = os.path.curdir
    166 gsaspath = os.path.abspath(os.path.expanduser(gsaspath))
    167165
    168166print '\nChecking for subversion...',
     
    180178    print 'done.'
    181179   
    182 print 'Ready to bootstrap GSAS-II from repository\n\t',g2home,'\nto '+gsaspath
     180print 'Ready to bootstrap GSAS-II from repository\n\t',g2home,'\nto '+path2GSAS2
    183181proxycmds = []
    184 proxyinfo = os.path.join(gsaspath,"proxyinfo.txt")
     182proxyinfo = os.path.join(path2GSAS2,"proxyinfo.txt")
    185183host = None
    186184port = '8080'
     
    228226if '2frame' in res:
    229227    print('Switching previous 2frame install to trunk\n\thttps://subversion.xray.aps.anl.gov/pyGSAS')
    230     cmd = [svn, 'switch',g2home + '/trunk',gsaspath,
     228    cmd = [svn, 'switch',g2home + '/trunk',path2GSAS2,
    231229           '--non-interactive','--trust-server-cert',
    232230           '--accept','theirs-conflict','--force','--ignore-ancestry']
     
    239237        print(res)
    240238
    241 cmd = [svn, 'co', g2home+ 'trunk/', gsaspath, '--non-interactive', '--trust-server-cert']
     239cmd = [svn, 'co', g2home+ 'trunk/', path2GSAS2, '--non-interactive', '--trust-server-cert']
    242240if proxycmds: cmd += proxycmds
    243241msg = 'Now preparing to install GSAS-II'
     
    253251    print('subversion returned an error:')
    254252    print(err)
    255     print('Retrying with command for older svn version...')
    256     cmd = [svn, 'co', g2home+ 'trunk/', gsaspath]
     253    print('Retrying with a cleanup and a command for older svn version...')
     254    cmd = [svn, 'cleanup', path2GSAS2]
     255    s = subprocess.Popen(cmd,stderr=subprocess.PIPE)
     256    out,err = s.communicate()   
     257    cmd = [svn, 'co', g2home+ 'trunk/', path2GSAS2]
    257258    if proxycmds: cmd += proxycmds
    258259    for item in cmd: print item,
     
    263264        print('subversion returned an error:')
    264265        print(err)
    265         print('  *** GSAS-II failed to be installed: you likely have a network access')
     266        print('  *** GSAS-II failed to be installed. In case the cleanup worked, try running this again')
     267        print('  *** If this installation continues to fail, a likely reason is a network access')
    266268        print('  *** problem, most commonly because you need to use a network proxy. Please')
    267269        print('  *** check with a network administrator or use http://www.whatismyproxy.com/\n')
     
    309311"""
    310312p = subprocess.Popen([sys.executable,'-c',script],stdout=subprocess.PIPE,stderr=subprocess.PIPE,
    311                      cwd=gsaspath)
     313                     cwd=path2GSAS2)
    312314res,err = p.communicate()
    313315if '==OK==' not in res or p.returncode != 0:
     
    335337print 'Byte-compiling all .py files...',
    336338import compileall
    337 compileall.compile_dir(gsaspath,quiet=True)
     339compileall.compile_dir(path2GSAS2,quiet=True)
    338340print 'done'
    339341#===========================================================================
     
    342344# on Windows, make a batch file with Python and GSAS-II location hard-coded
    343345if sys.platform.startswith('win') and os.path.exists(
    344     os.path.join(gsaspath,"makeBat.py")):
    345     execfile(os.path.join(gsaspath,"makeBat.py"))
     346    os.path.join(path2GSAS2,"makeBat.py")):
     347    execfile(os.path.join(path2GSAS2,"makeBat.py"))
    346348#===========================================================================
    347349# on a Mac, make an applescript
    348350elif sys.platform.startswith('darwin') and os.path.exists(
    349     os.path.join(gsaspath,"makeMacApp.py")):
    350     sys.argv = [os.path.join(gsaspath,"makeMacApp.py")]
     351    os.path.join(path2GSAS2,"makeMacApp.py")):
     352    sys.argv = [os.path.join(path2GSAS2,"makeMacApp.py")]
    351353    print(u'running '+sys.argv[0])
    352354    execfile(sys.argv[0])
     
    356358    desktop_template = """
    357359[Desktop Entry]
    358 Encoding=UTF-8
    359360Version=1.0
    360361Type=Application
    361362Terminal=false
    362 Exec=xterm -hold -e %s
     363Exec=xterm -hold -e bash -c "{} {}"
    363364Name=GSAS-II
    364 Icon=%s
     365Icon={}
     366Categories=Science;
    365367"""
    366     loc = '~/Desktop/'
    367     eloc = os.path.expanduser(loc)
    368     dfile = os.path.join(eloc,'GSASII.desktop')
    369     icon = os.path.join(gsaspath, 'gsas2.png')
    370     script = os.path.join(gsaspath, 'GSASII.py')
     368    loc = os.path.expanduser('~/Desktop/')
     369    if "XDG_DATA_HOME" in os.environ and os.path.exists(os.path.join(os.environ.get("XDG_DATA_HOME"),"applications")):
     370        loc = os.path.join(os.environ.get("XDG_DATA_HOME"),"applications")
     371    elif "HOME" in os.environ and os.path.exists(os.path.join(os.environ.get("HOME"),".local/share/applications")):
     372        loc = os.path.join(os.environ.get("HOME"),".local/share/applications")
     373    elif not os.path.exists(loc):
     374        loc = os.path.expanduser('~/')
     375    dfile = os.path.join(loc,'GSASII.desktop')
     376    icon = os.path.join(path2GSAS2, 'gsas2.png')
     377    script = os.path.join(path2GSAS2, 'GSASII.py')
    371378    os.chmod(script, # make the .py file executable and readable
    372379             stat.S_IXUSR | stat.S_IRUSR | stat.S_IRGRP | stat.S_IXGRP | stat.S_IXOTH)
    373     if os.path.exists(eloc):
    374         open(dfile,'w').write(desktop_template % (script,icon))
     380    try:
     381        open(dfile,'w').write(desktop_template.format(sys.executable,script,icon))
    375382        os.chmod(
    376383            dfile,
    377384            stat.S_IWUSR | stat.S_IXUSR | stat.S_IRUSR | stat.S_IRGRP | stat.S_IXGRP | stat.S_IXOTH)
    378         print("created GNOME desktop shortcut "+dfile)
    379 
     385        print("created GNOME/KDE desktop shortcut "+dfile)
     386    except:
     387        print("creation of file failed: "+dfile)
     388
Note: See TracChangeset for help on using the changeset viewer.