source: cows_wps/trunk/process_modules/ncdump_it.py @ 7014

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/cows_wps/trunk/process_modules/ncdump_it.py@7014
Revision 7014, 1.8 KB checked in by astephen, 10 years ago (diff)

renamed ddp_process_support to process_support

Line 
1"""
2ncdump_it.py
3============
4
5"""
6
7import os, stat, time
8
9from cows_wps.process_handler.fileset import FileSet, FLAG
10import cows_wps.process_handler.process_support as process_support
11from cows_wps.process_handler.context.process_status import STATUS
12
13class NCDumpIt(object):
14
15    def __call__(self, context):
16       
17        startTime = time.time()
18        jobId = os.path.basename(context.processDir)
19
20        # Parse the inputs
21        nc_file = context.inputs['FilePath']
22       
23        context.setStatus(STATUS.STARTED, 'Job is now running', 0)
24
25        # Always need a FileSet, even if empty
26        fileSet = context.outputs['FileSet'] = FileSet()
27
28        #MyOutput = "MY OUTPUT IS GREAT"
29        #context.outputs['ProcessSpecificContent'] = {"MyOutput": MyOutput}
30
31        ncdump_file = 'output-ncdump.txt'
32        ncdump_path = context.processDir + '/outputs/' + ncdump_file
33
34#        nc_file = "/disks/droplet1/hadrm3/data/HadRM3_PPE/nc/afixq/ape/afixqa.peo2sep.nc"
35#        eg_path = "/disks/droplet1/hadrm3/data/HadRM3_PPE/nc/afixq/ape/afixqa.peo2oct.nc"
36
37        if not os.path.isfile(nc_file):
38            raise Exception("The file path provided is not valid: %s" % nc_file)
39
40        os.system("/usr/local/bin/ncdump -h %s > %s" % (nc_file, ncdump_path))
41                   
42        context.log.info('Written output file: %s' % ncdump_path)
43        filesize = os.stat(ncdump_path)[stat.ST_SIZE]
44
45        fileSet = context.outputs['FileSet'] = FileSet()
46        fileSet.contents.append(FileSet(FLAG.DATA, ncdump_file, filesize, 'The only output'))
47
48        context.setStatus(STATUS.COMPLETED, 'The End', 100)
49       
50        completionTime = time.time()
51        process_support.updateJobDetailsAfterCompletion(context, startTime, completionTime)
52
53
54    def dryRun(self, context):
55
56        # Not implemented for sync jobs
57        pass
Note: See TracBrowser for help on using the repository browser.