Changeset ff99eae in flex_extract.git for python/install.py
- Timestamp:
- Jun 1, 2018, 8:34:59 PM (6 years ago)
- Branches:
- master, ctbto, dev
- Children:
- e1228f3
- Parents:
- ccab809
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/install.py
r991df6a rff99eae 2 2 # -*- coding: utf-8 -*- 3 3 #************************************************************************ 4 # TODO AP 5 # - localpythonpath should not be set in module load section! 4 # ToDo AP 6 5 # - create a class Installation and divide installation in 3 subdefs for 7 6 # ecgate, local and cca seperatly … … 18 17 # - applied PEP8 style guide 19 18 # - added documentation 19 # - moved install_args_and_control in here 20 20 # 21 21 # @License: … … 45 45 # MODULES 46 46 # ------------------------------------------------------------------------------ 47 import datetime48 47 import os 49 48 import sys … … 51 50 import subprocess 52 51 import inspect 53 from argparse import ArgumentParser,ArgumentDefaultsHelpFormatter 54 55 # add path to pythonpath so that python finds its buddies 56 localpythonpath = os.path.dirname(os.path.abspath( 57 inspect.getfile(inspect.currentframe()))) 58 if localpythonpath not in sys.path: 59 sys.path.append(localpythonpath) 52 from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter 60 53 61 54 # software specific classes and modules from flex_extract 62 55 from ControlFile import ControlFile 56 57 # add path to pythonpath so that python finds its buddies 58 LOCAL_PYTHON_PATH = os.path.dirname(os.path.abspath( 59 inspect.getfile(inspect.currentframe()))) 60 if LOCAL_PYTHON_PATH not in sys.path: 61 sys.path.append(LOCAL_PYTHON_PATH) 63 62 64 63 # ------------------------------------------------------------------------------ … … 78 77 ''' 79 78 80 os.chdir( localpythonpath)79 os.chdir(LOCAL_PYTHON_PATH) 81 80 args, c = install_args_and_control() 82 81 … … 84 83 install_via_gateway(c, args.install_target) 85 84 else: 86 print ('Please specify installation target (local|ecgate|cca)')87 print ('use -h or --help for help')85 print 'Please specify installation target (local|ecgate|cca)' 86 print 'use -h or --help for help' 88 87 89 88 sys.exit() … … 152 151 try: 153 152 c = ControlFile(args.controlfile) 154 except :155 print ('Could not read CONTROL file "' + args.controlfile + '"')156 print ('Either it does not exist or its syntax is wrong.')157 print ('Try "' + sys.argv[0].split('/')[-1] +158 ' -h" to print usage information' )153 except IOError: 154 print 'Could not read CONTROL file "' + args.controlfile + '"' 155 print 'Either it does not exist or its syntax is wrong.' 156 print 'Try "' + sys.argv[0].split('/')[-1] + \ 157 ' -h" to print usage information' 159 158 exit(1) 160 159 161 160 if args.install_target != 'local': 162 if (args.ecgid is None or args.ecuid is None or args.gateway is None163 or args.destination is None):164 print ('Please enter your ECMWF user id and group id as well as \161 if args.ecgid is None or args.ecuid is None or args.gateway is None \ 162 or args.destination is None: 163 print 'Please enter your ECMWF user id and group id as well as \ 165 164 the \nname of the local gateway and the ectrans \ 166 destination ' )167 print ('with command line options --ecuid --ecgid \168 --gateway --destination' )169 print ('Try "' + sys.argv[0].split('/')[-1] +170 ' -h" to print usage information' )171 print ('Please consult ecaccess documentation or ECMWF user support \172 for further details' )165 destination ' 166 print 'with command line options --ecuid --ecgid \ 167 --gateway --destination' 168 print 'Try "' + sys.argv[0].split('/')[-1] + \ 169 ' -h" to print usage information' 170 print 'Please consult ecaccess documentation or ECMWF user support \ 171 for further details' 173 172 sys.exit(1) 174 173 else: … … 178 177 c.destination = args.destination 179 178 180 try:179 if args.makefile: 181 180 c.makefile = args.makefile 182 except:183 pass184 181 185 182 if args.install_target == 'local': … … 240 237 c.flexpart_root_scripts 241 238 else: 242 data ='export FLEXPART_ROOT_SCRIPTS=$HOME'239 data = 'export FLEXPART_ROOT_SCRIPTS=$HOME' 243 240 if target.lower() != 'local': 244 241 if '--workdir' in data: … … 292 289 fo.close() 293 290 294 295 296 291 if target.lower() == 'local': 297 292 # compile CONVERT2 298 293 if c.flexpart_root_scripts is None or c.flexpart_root_scripts == '../': 299 print ('Warning: FLEXPART_ROOT_SCRIPTS has not been specified')300 print ('Only CONVERT2 will be compiled in ' + ecd + '/../src')294 print 'Warning: FLEXPART_ROOT_SCRIPTS has not been specified' 295 print 'Only CONVERT2 will be compiled in ' + ecd + '/../src' 301 296 else: 302 297 c.flexpart_root_scripts = os.path.expandvars(os.path.expanduser( 303 298 c.flexpart_root_scripts)) 304 299 if os.path.abspath(ecd) != os.path.abspath(c.flexpart_root_scripts): 305 300 os.chdir('/') … … 311 306 try: 312 307 os.makedirs(c.flexpart_root_scripts + '/ECMWFDATA7.1') 313 except:308 finally: 314 309 pass 315 310 os.chdir(c.flexpart_root_scripts + '/ECMWFDATA7.1') … … 329 324 p = subprocess.check_call(['rm'] + flist) 330 325 try: 331 print (('Using makefile: ' + makefile))326 print 'Using makefile: ' + makefile 332 327 p = subprocess.check_call(['make', '-f', makefile]) 333 p = subprocess.check_call(['ls', '-l','CONVERT2']) 334 except: 335 print('compile failed - please edit ' + makefile + 336 ' or try another Makefile in the src directory.') 337 print('most likely GRIB_API_INCLUDE_DIR, GRIB_API_LIB ' 338 'and EMOSLIB must be adapted.') 339 print('Available Makefiles:') 340 print(glob.glob('Makefile*')) 341 328 p = subprocess.check_call(['ls', '-l', 'CONVERT2']) 329 except subprocess.CalledProcessError as e: 330 print 'compile failed with the following error:' 331 print e.output 332 print 'please edit ' + makefile + \ 333 ' or try another Makefile in the src directory.' 334 print 'most likely GRIB_API_INCLUDE_DIR, GRIB_API_LIB \ 335 and EMOSLIB must be adapted.' 336 print 'Available Makefiles:' 337 print glob.glob('Makefile*') 342 338 elif target.lower() == 'ecgate': 343 339 os.chdir('/') … … 352 348 'ecgate:/home/ms/' + c.ecgid + '/' + 353 349 c.ecuid + '/ECMWFDATA7.1.tar']) 354 except: 355 print('ecaccess-file-put failed! Probably the eccert key has expired.') 350 except subprocess.CalledProcessError as e: 351 print 'ecaccess-file-put failed! \ 352 Probably the eccert key has expired.' 356 353 exit(1) 357 p = subprocess.check_call(['ecaccess-job-submit', 358 '-queueName', 359 target, 360 ecd + 'python/compilejob.ksh']) 361 print('compilejob.ksh has been submitted to ecgate for ' 362 'installation in ' + c.ec_flexpart_root_scripts + 363 '/ECMWFDATA7.1') 364 print('You should get an email with subject flexcompile within ' 365 'the next few minutes') 354 355 try: 356 p = subprocess.check_call(['ecaccess-job-submit', 357 '-queueName', 358 target, 359 ecd + 'python/compilejob.ksh']) 360 print 'compilejob.ksh has been submitted to ecgate for \ 361 installation in ' + c.ec_flexpart_root_scripts + \ 362 '/ECMWFDATA7.1' 363 print 'You should get an email with subject flexcompile within \ 364 the next few minutes' 365 except subprocess.CalledProcessError as e: 366 print 'ecaccess-job-submit failed!' 367 exit(1) 366 368 367 369 elif target.lower() == 'cca': … … 377 379 'cca:/home/ms/' + c.ecgid + '/' + 378 380 c.ecuid + '/ECMWFDATA7.1.tar']) 379 except :380 print ('ecaccess-file-put failed! '381 'Probably the eccert key has expired.')381 except subprocess.CalledProcessError as e: 382 print 'ecaccess-file-put failed! \ 383 Probably the eccert key has expired.' 382 384 exit(1) 383 385 384 p=subprocess.check_call(['ecaccess-job-submit', 385 '-queueName', 386 target, 387 ecd + 'python/compilejob.ksh']) 388 print('compilejob.ksh has been submitted to cca for installation in ' + 389 c.ec_flexpart_root_scripts + '/ECMWFDATA7.1') 390 print('You should get an email with subject flexcompile ' 391 'within the next few minutes') 386 try: 387 p = subprocess.check_call(['ecaccess-job-submit', 388 '-queueName', 389 target, 390 ecd + 'python/compilejob.ksh']) 391 print 'compilejob.ksh has been submitted to cca for installation in ' +\ 392 c.ec_flexpart_root_scripts + '/ECMWFDATA7.1' 393 print 'You should get an email with subject flexcompile \ 394 within the next few minutes' 395 except subprocess.CalledProcessError as e: 396 print 'ecaccess-job-submit failed!' 397 exit(1) 392 398 393 399 else: 394 print ('ERROR: unknown installation target ', target)395 print ('Valid targets: ecgate, cca, local')400 print 'ERROR: unknown installation target ', target 401 print 'Valid targets: ecgate, cca, local' 396 402 397 403 return
Note: See TracChangeset
for help on using the changeset viewer.