Changeset 7329


Ignore:
Timestamp:
16/08/10 14:35:38 (9 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.

Location:
cows_wps/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • cows_wps/trunk/cows_wps/templates/ui_template.html

    r7118 r7329  
    119119                (Administrator) 
    120120        </py:if> 
    121         ] 
     121       <py:if test="logged_in"> 
     122              ] 
     123        </py:if> 
    122124                 
    123125 
  • cows_wps/trunk/create_process.sh

    r6105 r7329  
    55mod_name=$1 
    66class_name=$2 
     7 
     8if [ ! $mod_name ]; then 
     9        echo "Please provide module name as first argument." 
     10        exit 
     11fi 
     12 
     13if [ ! $class_name ]; then 
     14        echo "Please provide class name as second argument." 
     15        exit 
     16fi  
    717 
    818new_module=process_modules/${mod_name}.py 
  • 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]) 
  • cows_wps/trunk/process_modules/subset_pp_file.py

    r7328 r7329  
    1616import process_modules.process_base 
    1717 
     18import process_modules.lib_subset_pp_file.utils as ppf_utils 
     19 
    1820# Import process-specific modules 
    19 sys.path.append("/usr/local/cwps/swarv/lib/python") 
    20 import pypp.pp_file 
     21#sys.path.append("/usr/local/cwps/swarv/lib/python") 
     22#import pypp.pp_file 
    2123 
    2224 
     
    6769            # Really generate output 
    6870            outputStashCodes = a["StashCodes"] 
     71            """ 
    6972            ppf = pypp.pp_file.PP_File(a["FilePath"]) 
    7073            fieldsToKeep = [] 
     
    7780                    fieldsToKeep.appends(h.stashcode) 
    7881                     
     82            """ 
    7983 
    80             size = os.path.getsize(outputFilePath) 
     84            nFields = ppf_utils.subsetPPFile(a["FilePath"], outputFilePath, a["StashCodes"]) 
    8185 
    8286            # Add the output list to the XML output section: ProcessSpecificContent 
    83             context.outputs['ProcessSpecificContent'] = {"PPFields": " ".join([str(f) for f in fieldsToKeep])} 
    84  
    85             fout = open(outputFilePath, "w") 
    86             fout.write("\n".join([str(i) for i in outputStashCodes])) 
    87             fout.close() 
     87            context.outputs['ProcessSpecificContent'] = {"NumberOfPPRecordMatches": nFields} 
    8888 
    8989            size = os.path.getsize(outputFilePath) 
Note: See TracChangeset for help on using the changeset viewer.