source: cows_wps/trunk/process_modules/extract_uk_station_data.py @ 6116

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/cows_wps/trunk/process_modules/extract_uk_station_data.py@6116
Revision 6116, 1.9 KB checked in by astephen, 11 years ago (diff)

more fixes and improvements

Line 
1"""
2extract_uk_station_data.py
3===================
4
5Process extract_uk_station_data that holds the ExtractUKStationData class.
6
7"""
8
9import os, stat, time
10
11from cows_wps.process_handler.fileset import FileSet, FLAG
12import cows_wps.process_handler.ddp_process_support as ddp_process_support
13from cows_wps.process_handler.context.process_status import STATUS
14
15# Import local modules
16sys.path.append("/home/badc/software/datasets/ukmo-midas/scripts/extract")
17# MIDAS Station search code
18import midasSubsetter
19
20# Set up logger
21log = logging.getLogger(__name__)
22log.setLevel(logging.DEBUG)
23
24
25
26class ExtractUKStationData(object):
27    def __call__(self, context):
28       
29        startTime = time.time()
30        jobId = os.path.basename(context.processDir)
31
32        # Parse the inputs
33        ci = context.inputs
34        Username = ci['Username']
35        StationIDs = ci.get("StationIDs", []) 
36        Counties
37       
38        context.setStatus(STATUS.STARTED, 'Job is now running', 0)
39
40        # Always need a FileSet, even if empty
41        fileSet = context.outputs['FileSet'] = FileSet()
42
43        context.outputs['ProcessSpecificContent'] = {} 
44        MyFile = "uk_station_data.txt"
45        MyFilePath = context.processDir + '/outputs/' + MyFile
46
47        # Get station IDs if not provided
48        if StationIDs == []:
49            # Try counties next
50           
51
52        context.log.info('Written output file: %s' % MyFile)
53        filesize = os.stat(MyFilePath)[stat.ST_SIZE]
54
55        fileSet = context.outputs['FileSet'] = FileSet()
56        fileSet.contents.append(FileSet(FLAG.DATA, MyFile, filesize, 'The only output'))
57
58        context.setStatus(STATUS.COMPLETED, 'The End', 100)
59       
60        completionTime = time.time()
61        ddp_process_support.updateJobDetailsAfterCompletion(context, startTime, completionTime)
62
63   
64
65    def dryRun(self, context):
66
67        # Not implemented for sync jobs
68        pass
Note: See TracBrowser for help on using the repository browser.