Changeset 4376
- Timestamp:
- Mar 19, 2020 4:27:06 PM (4 years ago)
- Location:
- install
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
install/bootstrap.py
r4242 r4376 18 18 if 'noinstall' in a.lower(): 19 19 skipInstallSteps = True 20 showWXerror = True20 if sys.platform.startswith('win'): showWXerror = True 21 21 elif 'nonet' in a.lower(): 22 22 skipDownloadSteps = True … … 55 55 def BailOut(msg): 56 56 '''Exit with an error message. Use a GUI to show the error when 57 showWXerror == True ( when --noinstall is specified)57 showWXerror == True (on windows when --noinstall is specified) 58 58 ''' 59 59 print(msg) … … 67 67 dlg.ShowModal() 68 68 dlg.Destroy() 69 else: 70 print("BOOTSTRAP WARNING: ",file=sys.stderr) 71 for line in msg.split('\n'): 72 print(line,file=sys.stderr) 73 print("Recreate this using command:") 74 print(" {} {} {}".format( 75 os.path.abspath(sys.executable), 76 os.path.abspath(os.path.expanduser(__file__)), 77 ' '.join(sys.argv[1:]), 78 ),file=sys.stderr) 69 79 sys.exit() 70 80 … … 102 112 '''Loads a proxy for subversion from the file created by bootstrap.py 103 113 ''' 104 proxyinfo = os.path.join(path2GSAS2,"proxyinfo.txt") 105 if os.path.exists(proxyinfo): 106 global proxycmds 107 global host,port # only in bootstrap.py 108 proxycmds = [] 109 fp = open(proxyinfo,'r') 114 global proxycmds 115 proxycmds = [] 116 proxyinfo = os.path.join(os.path.expanduser('~/.G2local/'),"proxyinfo.txt") 117 if not os.path.exists(proxyinfo): 118 proxyinfo = os.path.join(path2GSAS2,"proxyinfo.txt") 119 if not os.path.exists(proxyinfo): 120 return '','','' 121 fp = open(proxyinfo,'r') 122 host = fp.readline().strip() 123 # allow file to begin with comments 124 while host.startswith('#'): 110 125 host = fp.readline().strip() 111 port = fp.readline().strip() 112 fp.close() 113 setsvnProxy(host,port) 114 if not host.strip(): return '','' 115 return host,port 116 return '','' 117 118 def setsvnProxy(host,port): 126 port = fp.readline().strip() 127 etc = [] 128 line = fp.readline() 129 while line: 130 etc.append(line.strip()) 131 line = fp.readline() 132 fp.close() 133 setsvnProxy(host,port,etc) 134 return host,port,etc 135 136 def setsvnProxy(host,port,etc=[]): 119 137 '''Sets the svn commands needed to use a proxy 120 138 ''' … … 123 141 host = host.strip() 124 142 port = port.strip() 125 if not host.strip(): return 126 proxycmds.append('--config-option') 127 proxycmds.append('servers:global:http-proxy-host='+host) 128 if port.strip(): 143 if host: 129 144 proxycmds.append('--config-option') 130 proxycmds.append('servers:global:http-proxy-port='+port) 145 proxycmds.append('servers:global:http-proxy-host='+host) 146 if port: 147 proxycmds.append('--config-option') 148 proxycmds.append('servers:global:http-proxy-port='+port) 149 for item in etc: 150 proxycmds.append(item) 131 151 132 152 def whichsvn(): … … 145 165 svnprog = 'svn' 146 166 if sys.platform.startswith('win'): svnprog += '.exe' 147 host,port = getsvnProxy()167 host,port,etc = getsvnProxy() 148 168 if GetConfigValue('debug') and host: 149 169 print('DBG_Using proxy host {} port {}'.format(host,port)) … … 261 281 print('Ready to bootstrap GSAS-II from repository\n\t'+g2home+'\nto '+path2GSAS2) 262 282 proxycmds = [] 263 proxyinfo = os.path.join(path2GSAS2,"proxyinfo.txt") 264 if os.path.exists(proxyinfo): 265 fp = open(proxyinfo,'r') 266 host = fp.readline().strip() 267 port = fp.readline().strip() 268 fp.close() 269 os.remove(proxyinfo) 270 print(70*"=") 283 host,port,etc = getsvnProxy() 271 284 if sys.version_info[0] == 2: 272 285 getinput = raw_input … … 274 287 getinput = input 275 288 276 # get proxy from environment variable289 # get proxy setting from environment variable 277 290 key = None 278 291 for i in os.environ.keys(): … … 303 316 host = "" 304 317 elif host: 318 print('\n'+75*'*') 305 319 ans = getinput("Enter the proxy address (type none to remove) ["+host+"]: ").strip() 306 320 if ans.lower() == "none": host = "" … … 312 326 if ans == "": ans=port 313 327 port = ans 328 print('If your site needs additional svn commands (such as \n\t', 329 '--config-option servers:global:http-proxy-username=*account*','\n\t', 330 '--config-option servers:global:http-proxy-password=*password*', 331 '\nenter them now:') 332 if etc: 333 prevetc = ' '.join(etc) 334 print('\nDefault for next input is "{}"'.format(prevetc)) 335 prompt = "Enter additional svn options (if any) [use previous]: " 336 else: 337 prompt = "Enter additional svn options (if any) [none]: " 338 ans = 'start' 339 etcstr = '' 340 while ans: 341 ans = getinput(prompt).strip() 342 prompt = "more svn options (if any): " 343 if etcstr: etcstr += ' ' 344 etcstr += ans 345 if etcstr.strip(): 346 etc = etcstr.split() 314 347 except EOFError: 315 348 host = "" 316 349 port = "" 350 etc = [] 351 setsvnProxy(host,port,etc) 352 # delete old proxy files 353 localproxy = os.path.join(os.path.expanduser('~/.G2local/'),"proxyinfo.txt") 354 for proxyinfo in localproxy,os.path.join(path2GSAS2,"proxyinfo.txt"): 355 if os.path.exists(proxyinfo): 356 try: 357 os.remove(proxyinfo) 358 print('Deleted file {}'.format(proxyinfo)) 359 except: 360 pass 317 361 if host: 318 proxycmds.append('--config-option') 319 proxycmds.append('servers:global:http-proxy-host='+host.strip()) 320 if port: 321 proxycmds.append('--config-option') 322 proxycmds.append('servers:global:http-proxy-port='+port.strip()) 323 fp = open(proxyinfo,'w') 324 fp.write(host.strip()+'\n') 325 fp.write(port.strip()+'\n') 326 fp.close() 327 fp = open(os.path.join(path2GSAS2,'bootstrap.log'),'a') 328 fp.write('Proxy info written: {} port\n'.format(host,port)) 329 print('Proxy info written: {} port'.format(host,port)) 330 fp.close() 331 362 try: 363 fp = open(proxyinfo,'w') 364 except: 365 fp = open(localproxy,'w') 366 proxyinfo = localproxy 367 try: 368 fp.write(host.strip()+'\n') 369 fp.write(port.strip()+'\n') 370 for i in etc: 371 if i.strip(): 372 fp.write(i.strip()+'\n') 373 fp.close() 374 msg = 'Proxy info written: {} port {} etc {}\n'.format(host,port,etc) 375 print(msg) 376 fp = open(os.path.join(path2GSAS2,'bootstrap.log'),'a') 377 fp.write(msg) 378 fp.close() 379 except Exception as err: 380 print('Error writing file {}:\n{}'.format(proxyinfo,err)) 332 381 if not skipDownloadSteps: 333 382 # patch: switch GSAS-II location if linked to XOR server (relocated May/June 2017) … … 407 456 msg += '\nThe most common reason is you need to use a network proxy. Please' 408 457 msg += '\ncheck with a network administrator or use http://www.whatismyproxy.com/' 409 else: 458 else: 459 # this will happen only with initial installs where all files 460 # are to be downloaded (not gsas2full or updates) 410 461 msg += '\n\n *** GSAS-II failed to be installed. A likely reason is a network access' 411 462 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'463 msg += '\n *** check with a network administrator or use http://www.whatismyproxy.com/\n' 413 464 BailOut(msg) 414 465 print('\n'+75*'*') … … 425 476 print('Loading all binaries with command...') 426 477 if not GSASIIpath.svnSwitchDir('AllBinaries','',g2home+ 'Binaries/',None,True): 427 msg = 'Binary load failed '478 msg = 'Binary load failed. Subversion problem? Please seek help' 428 479 BailOut(msg) 429 480 else: … … 461 512 msg += err 462 513 #print('\nAttempting to open a web page on compiling GSAS-II...') 463 msg += '\n\nPlease see web page\nhttps://subversion.xray.aps.anl.gov/trac/pyGSAS/wiki/CompileGSASII '514 msg += '\n\nPlease see web page\nhttps://subversion.xray.aps.anl.gov/trac/pyGSAS/wiki/CompileGSASII if you wish to compile for yourself (usually not needed for windows and Mac, but sometimes required for Linux.)' 464 515 BailOut(msg) 465 516 #import webbrowser -
install/g2complete/src/bootstrap.py
- Property svn:keywords set to Date Author Revision URL Id
r4261 r4376 5 5 import os, stat, sys, platform, subprocess, datetime 6 6 7 version = "$Id : bootstrap.py 3515 2018-07-30 02:14:14Z toby$"7 version = "$Id$" 8 8 g2home = 'https://subversion.xray.aps.anl.gov/pyGSAS/' 9 9 path2GSAS2 = os.path.dirname(os.path.abspath(os.path.expanduser(__file__))) … … 69 69 else: 70 70 print("BOOTSTRAP WARNING: ",file=sys.stderr) 71 print(msg.replace('\n',' '),file=sys.stderr) 72 print(" Recreate this using command: {} {} {}".format( 71 for line in msg.split('\n'): 72 print(line,file=sys.stderr) 73 print("Recreate this using command:") 74 print(" {} {} {}".format( 73 75 os.path.abspath(sys.executable), 74 76 os.path.abspath(os.path.expanduser(__file__)), … … 110 112 '''Loads a proxy for subversion from the file created by bootstrap.py 111 113 ''' 112 proxyinfo = os.path.join(path2GSAS2,"proxyinfo.txt") 113 if os.path.exists(proxyinfo): 114 global proxycmds 115 global host,port # only in bootstrap.py 116 proxycmds = [] 117 fp = open(proxyinfo,'r') 114 global proxycmds 115 proxycmds = [] 116 proxyinfo = os.path.join(os.path.expanduser('~/.G2local/'),"proxyinfo.txt") 117 if not os.path.exists(proxyinfo): 118 proxyinfo = os.path.join(path2GSAS2,"proxyinfo.txt") 119 if not os.path.exists(proxyinfo): 120 return '','','' 121 fp = open(proxyinfo,'r') 122 host = fp.readline().strip() 123 # allow file to begin with comments 124 while host.startswith('#'): 118 125 host = fp.readline().strip() 119 port = fp.readline().strip() 120 fp.close() 121 setsvnProxy(host,port) 122 if not host.strip(): return '','' 123 return host,port 124 return '','' 125 126 def setsvnProxy(host,port): 126 port = fp.readline().strip() 127 etc = [] 128 line = fp.readline() 129 while line: 130 etc.append(line.strip()) 131 line = fp.readline() 132 fp.close() 133 setsvnProxy(host,port,etc) 134 return host,port,etc 135 136 def setsvnProxy(host,port,etc=[]): 127 137 '''Sets the svn commands needed to use a proxy 128 138 ''' … … 131 141 host = host.strip() 132 142 port = port.strip() 133 if not host.strip(): return 134 proxycmds.append('--config-option') 135 proxycmds.append('servers:global:http-proxy-host='+host) 136 if port.strip(): 143 if host: 137 144 proxycmds.append('--config-option') 138 proxycmds.append('servers:global:http-proxy-port='+port) 145 proxycmds.append('servers:global:http-proxy-host='+host) 146 if port: 147 proxycmds.append('--config-option') 148 proxycmds.append('servers:global:http-proxy-port='+port) 149 for item in etc: 150 proxycmds.append(item) 139 151 140 152 def whichsvn(): … … 153 165 svnprog = 'svn' 154 166 if sys.platform.startswith('win'): svnprog += '.exe' 155 host,port = getsvnProxy()167 host,port,etc = getsvnProxy() 156 168 if GetConfigValue('debug') and host: 157 169 print('DBG_Using proxy host {} port {}'.format(host,port)) … … 269 281 print('Ready to bootstrap GSAS-II from repository\n\t'+g2home+'\nto '+path2GSAS2) 270 282 proxycmds = [] 271 proxyinfo = os.path.join(path2GSAS2,"proxyinfo.txt") 272 if os.path.exists(proxyinfo): 273 fp = open(proxyinfo,'r') 274 host = fp.readline().strip() 275 port = fp.readline().strip() 276 fp.close() 277 os.remove(proxyinfo) 278 print(70*"=") 283 host,port,etc = getsvnProxy() 279 284 if sys.version_info[0] == 2: 280 285 getinput = raw_input … … 282 287 getinput = input 283 288 284 # get proxy from environment variable289 # get proxy setting from environment variable 285 290 key = None 286 291 for i in os.environ.keys(): … … 311 316 host = "" 312 317 elif host: 318 print('\n'+75*'*') 313 319 ans = getinput("Enter the proxy address (type none to remove) ["+host+"]: ").strip() 314 320 if ans.lower() == "none": host = "" … … 320 326 if ans == "": ans=port 321 327 port = ans 328 print('If your site needs additional svn commands (such as \n\t', 329 '--config-option servers:global:http-proxy-username=*account*','\n\t', 330 '--config-option servers:global:http-proxy-password=*password*', 331 '\nenter them now:') 332 if etc: 333 prevetc = ' '.join(etc) 334 print('\nDefault for next input is "{}"'.format(prevetc)) 335 prompt = "Enter additional svn options (if any) [use previous]: " 336 else: 337 prompt = "Enter additional svn options (if any) [none]: " 338 ans = 'start' 339 etcstr = '' 340 while ans: 341 ans = getinput(prompt).strip() 342 prompt = "more svn options (if any): " 343 if etcstr: etcstr += ' ' 344 etcstr += ans 345 if etcstr.strip(): 346 etc = etcstr.split() 322 347 except EOFError: 323 348 host = "" 324 349 port = "" 350 etc = [] 351 setsvnProxy(host,port,etc) 352 # delete old proxy files 353 localproxy = os.path.join(os.path.expanduser('~/.G2local/'),"proxyinfo.txt") 354 for proxyinfo in localproxy,os.path.join(path2GSAS2,"proxyinfo.txt"): 355 if os.path.exists(proxyinfo): 356 try: 357 os.remove(proxyinfo) 358 print('Deleted file {}'.format(proxyinfo)) 359 except: 360 pass 325 361 if host: 326 proxycmds.append('--config-option') 327 proxycmds.append('servers:global:http-proxy-host='+host.strip()) 328 if port: 329 proxycmds.append('--config-option') 330 proxycmds.append('servers:global:http-proxy-port='+port.strip()) 331 fp = open(proxyinfo,'w') 332 fp.write(host.strip()+'\n') 333 fp.write(port.strip()+'\n') 334 fp.close() 335 fp = open(os.path.join(path2GSAS2,'bootstrap.log'),'a') 336 fp.write('Proxy info written: {} port\n'.format(host,port)) 337 print('Proxy info written: {} port'.format(host,port)) 338 fp.close() 339 362 try: 363 fp = open(proxyinfo,'w') 364 except: 365 fp = open(localproxy,'w') 366 proxyinfo = localproxy 367 try: 368 fp.write(host.strip()+'\n') 369 fp.write(port.strip()+'\n') 370 for i in etc: 371 if i.strip(): 372 fp.write(i.strip()+'\n') 373 fp.close() 374 msg = 'Proxy info written: {} port {} etc {}\n'.format(host,port,etc) 375 print(msg) 376 fp = open(os.path.join(path2GSAS2,'bootstrap.log'),'a') 377 fp.write(msg) 378 fp.close() 379 except Exception as err: 380 print('Error writing file {}:\n{}'.format(proxyinfo,err)) 340 381 if not skipDownloadSteps: 341 382 # patch: switch GSAS-II location if linked to XOR server (relocated May/June 2017) … … 412 453 if os.path.exists(os.path.join(path2GSAS2,"makeBat.py")): 413 454 msg += '\n\nGSAS-II failed to be updated. A likely reason is a network access' 414 msg += '\nproblem. If your web browser works, but the update did not ,'415 msg += '\n the most common reason is you need to use a network proxy. Please'455 msg += '\nproblem. If your web browser works, but the update did not.' 456 msg += '\nThe most common reason is you need to use a network proxy. Please' 416 457 msg += '\ncheck with a network administrator or use http://www.whatismyproxy.com/' 417 458 else: … … 420 461 msg += '\n\n *** GSAS-II failed to be installed. A likely reason is a network access' 421 462 msg += '\n *** problem, most commonly because you need to use a network proxy. Please' 422 msg += ' *** check with a network administrator or use http://www.whatismyproxy.com/\n'463 msg += '\n *** check with a network administrator or use http://www.whatismyproxy.com/\n' 423 464 BailOut(msg) 424 465 print('\n'+75*'*')
Note: See TracChangeset
for help on using the changeset viewer.