Changeset 2fb99de in flex_extract.git for python/MarsRetrieval.py
- Timestamp:
- Sep 20, 2018, 11:56:37 AM (6 years ago)
- Branches:
- master, ctbto, dev
- Children:
- 5d42acd
- Parents:
- 3232589
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/MarsRetrieval.py
r54a8a01 r2fb99de 65 65 import os 66 66 67 import _config 67 68 # ------------------------------------------------------------------------------ 68 69 # CLASS … … 310 311 ''' 311 312 @Description: 312 Prints all class attributes and their values. 313 Prints all class attributes and their values to the 314 standard output. 313 315 314 316 @Input: … … 328 330 pass 329 331 else: 330 print item[0] + ': ' + str(item[1]) 332 print(item[0] + ': ' + str(item[1])) 333 334 return 335 336 337 def print_info(self): 338 ''' 339 @Description: 340 Prints all mars requests to an extra file for debugging and 341 information. 342 343 @Input: 344 self: instance of MarsRetrieval 345 For description see class documentation. 346 347 @Return: 348 <nothing> 349 ''' 350 # Get all class attributes and their values as a dictionary 351 attrs = vars(self) 352 353 # open a file to store all requests to 354 with open(os.path.join(_config.PATH_RUN_DIR, 355 _config.FILE_MARS_REQUESTS), 'a') as f: 356 f.write('mars\n') 357 # iterate through all attributes and print them 358 # with their corresponding values 359 for item in attrs.items(): 360 if item[0] in 'server': 361 pass 362 else: 363 f.write(item[0] + ': ' + str(item[1]) + '\n') 364 f.write('\n\n') 331 365 332 366 return … … 371 405 self.server.execute(s, target) 372 406 except: 373 print 374 have you already registered at apps.ecmwf.int?'407 print('MARS Request failed, \ 408 have you already registered at apps.ecmwf.int?') 375 409 raise IOError 376 410 if os.stat(target).st_size == 0: 377 print 'MARS Request returned no data - please check request'411 print('MARS Request returned no data - please check request') 378 412 raise IOError 379 413 # MARS request via extra process in shell … … 384 418 stderr=subprocess.PIPE, bufsize=1) 385 419 pout = p.communicate(input=s)[0] 386 print pout.decode()420 print(pout.decode()) 387 421 388 422 if 'Some errors reported' in pout.decode(): 389 print 'MARS Request failed - please check request'423 print('MARS Request failed - please check request') 390 424 raise IOError 391 425 392 426 if os.stat(target).st_size == 0: 393 print 'MARS Request returned no data - please check request'427 print('MARS Request returned no data - please check request') 394 428 raise IOError 395 429
Note: See TracChangeset
for help on using the changeset viewer.