Ignore:
Timestamp:
16/08/10 14:35:38 (10 years ago)
Author:
astephen
Message:

Created new process that subsets pp files. Needs time and level and
forecast time added to the filtering. Then it also needs a clever way of
using the outputs of one process to populate the UI contents for another
process.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cows_wps/trunk/process_modules/lib_subset_pp_file/utils.py

    r7328 r7329  
    1 #!/usr/bin/env python 
     1""" 
     2utils.py 
     3======== 
    24 
    3 import sys 
    4 import getopt 
    5 import os 
     5Utilities for subset_pp_file.py module and SubsetPPFile class. 
     6 
     7""" 
     8import os, stat, time, sys 
     9import urllib 
     10 
     11from cows_wps.process_handler.context.process_status import STATUS 
     12from cows_wps.utils.duration_splitter import * 
     13 
     14# Import local modules 
     15sys.path.append("/usr/local/cwps/python-um-file") 
    616 
    717import umfile 
     
    919 
    1020import logging 
     21logging.basicConfig() 
    1122log = logging.getLogger(__name__) 
    1223 
     
    1627    Subsets the contents of ``inputFilePath`` into ``outputFilePath`` based on  
    1728    the filtering criteria set. 
     29 
     30    Returns the number of records that matched the filtering criteria set. 
    1831    """ 
    1932    log.warn("Doing autodetection of file type") 
     
    4659                recsOut.append(rec) 
    4760 
    48     fh = umfile.OutputUMFile(outputFilePath, **kwargs) 
    49     fh.writeFile(hdr, recsOut) 
    50     fh.close() 
     61    nFields = len(recsOut) 
     62 
     63    if nFields > 0: 
     64        fh = umfile.OutputUMFile(outputFilePath, **kwargs) 
     65        fh.writeFile(hdr, recsOut) 
     66        fh.close() 
     67    else: 
     68        raise Exception("No records found that match your filter criteria.") 
    5169 
    5270    log.info("Filtered PP-file into new file: %s" % outputFilePath) 
    53     return  
     71    return nFields 
    5472 
    55  
    56 if __name__ == "__main__": 
    57  
    58     subsetPPFile("/disks/kona1/cwps-test-data/africa-lam/prods_op_afr_20100813_18.006pp", "out.pp",  
    59                  stashCodes = [4202, 16202]) 
Note: See TracChangeset for help on using the changeset viewer.