- Timestamp:
- Oct 2, 2017 3:01:00 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
install/bootstrap.py
r3025 r3107 5 5 6 6 g2home = 'https://subversion.xray.aps.anl.gov/pyGSAS/' 7 path2GSAS2 = os.path.dirname(os.path.abspath(os.path.expanduser(__file__))) 8 print('Running bootstrap from {}'.format(path2GSAS2)) 7 9 ################################################################################ 8 10 ################################################################################ … … 161 163 print traceback.format_exc() 162 164 sys.exit() 163 # path to where this script is located164 gsaspath = os.path.split(sys.argv[0])[0]165 if not gsaspath: gsaspath = os.path.curdir166 gsaspath = os.path.abspath(os.path.expanduser(gsaspath))167 165 168 166 print '\nChecking for subversion...', … … 180 178 print 'done.' 181 179 182 print 'Ready to bootstrap GSAS-II from repository\n\t',g2home,'\nto '+ gsaspath180 print 'Ready to bootstrap GSAS-II from repository\n\t',g2home,'\nto '+path2GSAS2 183 181 proxycmds = [] 184 proxyinfo = os.path.join( gsaspath,"proxyinfo.txt")182 proxyinfo = os.path.join(path2GSAS2,"proxyinfo.txt") 185 183 host = None 186 184 port = '8080' … … 228 226 if '2frame' in res: 229 227 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, 231 229 '--non-interactive','--trust-server-cert', 232 230 '--accept','theirs-conflict','--force','--ignore-ancestry'] … … 239 237 print(res) 240 238 241 cmd = [svn, 'co', g2home+ 'trunk/', gsaspath, '--non-interactive', '--trust-server-cert']239 cmd = [svn, 'co', g2home+ 'trunk/', path2GSAS2, '--non-interactive', '--trust-server-cert'] 242 240 if proxycmds: cmd += proxycmds 243 241 msg = 'Now preparing to install GSAS-II' … … 253 251 print('subversion returned an error:') 254 252 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] 257 258 if proxycmds: cmd += proxycmds 258 259 for item in cmd: print item, … … 263 264 print('subversion returned an error:') 264 265 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') 266 268 print(' *** problem, most commonly because you need to use a network proxy. Please') 267 269 print(' *** check with a network administrator or use http://www.whatismyproxy.com/\n') … … 309 311 """ 310 312 p = subprocess.Popen([sys.executable,'-c',script],stdout=subprocess.PIPE,stderr=subprocess.PIPE, 311 cwd= gsaspath)313 cwd=path2GSAS2) 312 314 res,err = p.communicate() 313 315 if '==OK==' not in res or p.returncode != 0: … … 335 337 print 'Byte-compiling all .py files...', 336 338 import compileall 337 compileall.compile_dir( gsaspath,quiet=True)339 compileall.compile_dir(path2GSAS2,quiet=True) 338 340 print 'done' 339 341 #=========================================================================== … … 342 344 # on Windows, make a batch file with Python and GSAS-II location hard-coded 343 345 if 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")) 346 348 #=========================================================================== 347 349 # on a Mac, make an applescript 348 350 elif 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")] 351 353 print(u'running '+sys.argv[0]) 352 354 execfile(sys.argv[0]) … … 356 358 desktop_template = """ 357 359 [Desktop Entry] 358 Encoding=UTF-8359 360 Version=1.0 360 361 Type=Application 361 362 Terminal=false 362 Exec=xterm -hold -e %s363 Exec=xterm -hold -e bash -c "{} {}" 363 364 Name=GSAS-II 364 Icon=%s 365 Icon={} 366 Categories=Science; 365 367 """ 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') 371 378 os.chmod(script, # make the .py file executable and readable 372 379 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)) 375 382 os.chmod( 376 383 dfile, 377 384 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.