- Timestamp:
- Oct 8, 2018, 3:49:02 PM (5 years ago)
- Branches:
- master, ctbto, dev
- Children:
- 0a06607
- Parents:
- 0e576fc
- Location:
- source
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
source/python/_config.py
r295ff45 r0aaeb04 34 34 FILE_MARS_REQUESTS = 'mars_requests.csv' 35 35 FORTRAN_EXECUTABLE = 'CONVERT2' 36 TEMPFILE_USER_ENVVARS = 'ECMWF_ENV.template' 36 37 FILE_USER_ENVVARS = 'ECMWF_ENV' 37 TEMPFILE_INSTALL_COMPILEJOB = 'compilejob.temp '38 TEMPFILE_INSTALL_COMPILEJOB = 'compilejob.template' 38 39 FILE_INSTALL_COMPILEJOB = 'compilejob.ksh' 39 40 TEMPFILE_INSTALL_JOB = 'job.temp.o' -
source/python/install.py
r27fe969 r0aaeb04 320 320 Creates a file named ECMWF_ENV which contains the 321 321 necessary environmental variables at ECMWF servers. 322 It is based on the template ECMWF_ENV.template. 322 323 323 324 @Input: … … 338 339 <nothing> 339 340 ''' 340 341 with open(_config.PATH_REL_ECMWF_ENV, 'w') as fo: 342 fo.write('ECUID ' + ecuid + '\n') 343 fo.write('ECGID ' + ecgid + '\n') 344 fo.write('GATEWAY ' + gateway + '\n') 345 fo.write('DESTINATION ' + destination + '\n') 341 from genshi.template.text import NewTextTemplate 342 from genshi.template import TemplateLoader 343 344 loader = TemplateLoader(_config.PATH_TEMPLATES, auto_reload=False) 345 ecmwfvars_template = loader.load(_config.TEMPFILE_USER_ENVVARS, 346 cls=NewTextTemplate) 347 348 stream = ecmwfvars_template.generate(user_name = ecuid, 349 user_group = ecgid, 350 gateway_name = gateway, 351 destination_name = destination 352 ) 353 354 with open(_config.PATH_ECMWF_ENV, 'w') as f: 355 f.write(stream.render('text')) 346 356 347 357 return … … 375 385 <nothing> 376 386 ''' 377 378 template = os.path.join(_config.PATH_REL_TEMPLATES, 379 _config.TEMPFILE_INSTALL_COMPILEJOB) 380 with open(template) as f: 381 fdata = f.read().split('\n') 382 383 compilejob = os.path.join(_config.PATH_REL_JOBSCRIPTS, 387 from genshi.template.text import NewTextTemplate 388 from genshi.template import TemplateLoader 389 390 loader = TemplateLoader(_config.PATH_TEMPLATES, auto_reload=False) 391 compile_template = loader.load(_config.TEMPFILE_INSTALL_COMPILEJOB, 392 cls=NewTextTemplate) 393 394 if fp_root == '../': 395 fp_root = '$HOME' 396 397 stream = compile_template.generate( 398 username = ecuid, 399 usergroup = ecgid, 400 version_number = _config._VERSION_STR, 401 fp_root_scripts = fp_root, 402 makefile = makefile, 403 fortran_program = _config.FORTRAN_EXECUTABLE 404 ) 405 406 compilejob = os.path.join(_config.PATH_JOBSCRIPTS, 384 407 _config.FILE_INSTALL_COMPILEJOB) 385 with open(compilejob, 'w') as fo: 386 for data in fdata: 387 if 'MAKEFILE=' in data: 388 data = 'export MAKEFILE=' + makefile 389 elif 'FLEXPART_ROOT_SCRIPTS=' in data: 390 if fp_root != '../': 391 data = 'export FLEXPART_ROOT_SCRIPTS=' + fp_root 392 else: 393 data = 'export FLEXPART_ROOT_SCRIPTS=$HOME' 394 elif target.lower() != 'local': 395 if '--workdir' in data: 396 data = '#SBATCH --workdir=/scratch/ms/' + \ 397 ecgid + '/' + ecuid 398 elif '##PBS -o' in data: 399 data = '##PBS -o /scratch/ms/' + ecgid + '/' + ecuid + \ 400 'flex_ecmwf.$Jobname.$Job_ID.out' 401 elif 'FLEXPART_ROOT_SCRIPTS=' in data: 402 if fp_root != '../': 403 data = 'export FLEXPART_ROOT_SCRIPTS=' + fp_root 404 else: 405 data = 'export FLEXPART_ROOT_SCRIPTS=$HOME' 406 fo.write(data + '\n') 408 409 with open(compilejob, 'w') as f: 410 f.write(stream.render('text')) 411 412 413 # template = os.path.join(_config.PATH_REL_TEMPLATES, 414 # _config.TEMPFILE_INSTALL_COMPILEJOB) 415 # with open(template) as f: 416 # fdata = f.read().split('\n') 417 418 419 # with open(compilejob, 'w') as fo: 420 # for data in fdata: 421 # if 'MAKEFILE=' in data: 422 # data = 'export MAKEFILE=' + makefile 423 # elif 'FLEXPART_ROOT_SCRIPTS=' in data: 424 # if fp_root != '../': 425 # data = 'export FLEXPART_ROOT_SCRIPTS=' + fp_root 426 # else: 427 # data = 'export FLEXPART_ROOT_SCRIPTS=$HOME' 428 # elif target.lower() != 'local': 429 # if '--workdir' in data: 430 # data = '#SBATCH --workdir=/scratch/ms/' + \ 431 # ecgid + '/' + ecuid 432 # elif '##PBS -o' in data: 433 # data = '##PBS -o /scratch/ms/' + ecgid + '/' + ecuid + \ 434 # 'flex_ecmwf.$Jobname.$Job_ID.out' 435 # elif 'FLEXPART_ROOT_SCRIPTS=' in data: 436 # if fp_root != '../': 437 # data = 'export FLEXPART_ROOT_SCRIPTS=' + fp_root 438 # else: 439 # data = 'export FLEXPART_ROOT_SCRIPTS=$HOME' 440 # fo.write(data + '\n') 407 441 408 442 return -
source/pythontest/TestInstall.py
r25b14be r0aaeb04 11 11 import _config 12 12 import install 13 from mods.tools import make_dir 13 from mods.tools import make_dir, silent_remove 14 14 15 15 … … 24 24 #! - mk_tarball 25 25 #! - un_tarball 26 # - mk_env_vars26 #! - mk_env_vars 27 27 # - mk_compilejob 28 28 # - mk_job_template … … 116 116 # clean up temp test dir 117 117 shutil.rmtree(test_dir) 118 119 def test_mk_env_vars(self): 120 import filecmp 121 122 # comparison file 123 testfile = os.path.join(_config.PATH_TEST_DIR,'TestData', 124 'ECMWF_ENV.test') 125 126 # create test ECMWF_ENV file 127 install.mk_env_vars('testuser', 128 'testgroup', 129 'gateway.test.ac.at', 130 'user@destination') 131 132 assert filecmp.cmp(testfile, _config.PATH_ECMWF_ENV, shallow=False) 133 134 # delte test file 135 silent_remove(_config.PATH_ECMWF_ENV) 136 137 def test_mk_compilejob(self): 138 import filecmp 139 140 # comparison file 141 testfile = os.path.join(_config.PATH_TEST_DIR,'TestData', 142 'compilejob.test') 143 144 # create 145 install.mk_compilejob('Makefile.TEST', 146 '', 147 'testuser', 148 'testgroup', 149 'fp_root_test_path') 150 151 finalfile = os.path.join(_config.PATH_JOBSCRIPTS, 152 _config.FILE_INSTALL_COMPILEJOB) 153 assert filecmp.cmp(testfile, finalfile, shallow=False) 154 155 # delete test file 156 silent_remove(finalfile)
Note: See TracChangeset
for help on using the changeset viewer.