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

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

renamed ddp_process_support to process_support

Line 
1"""
2cf_check.py
3===================
4
5Process cf_check that holds the CFCheck class.
6
7"""
8
9# Standard library imports
10import os, stat, time, sys
11
12# WPS imports
13from cows_wps.process_handler.fileset import FileSet, FLAG
14import cows_wps.process_handler.process_support as process_support
15from cows_wps.process_handler.context.process_status import STATUS
16
17# Import process-specific modules
18
19# NOTE ABOUT LOGGING:
20# You can log with the context.log object
21
22
23class CFCheck(object):
24    def __call__(self, context):
25       
26        startTime = time.time()
27        jobId = os.path.basename(context.processDir)
28
29        # Parse the inputs
30        MyInput = context.inputs['MyInput']
31       
32        context.setStatus(STATUS.STARTED, 'Job is now running', 0)
33
34        # Always need a FileSet, even if empty
35        fileSet = context.outputs['FileSet'] = FileSet()
36
37        MyOutput = "MY OUTPUT IS GREAT"
38        context.outputs['ProcessSpecificContent'] = {"MyOutput": MyOutput, "TryAnArray": [1, 3, 567]} 
39
40        MyFile = 'MyFile.txt'
41        MyFilePath = context.processDir + '/outputs/' + MyFile
42
43        fh = open(MyFilePath, 'w')
44        fh.write('You can write the input here if you like: %s.' % MyInput)
45        fh.close()
46
47        context.log.info('Written output file: %s' % MyFile)
48        filesize = os.stat(MyFilePath)[stat.ST_SIZE]
49
50        fileSet = context.outputs['FileSet'] = FileSet()
51        fileSet.contents.append(FileSet(FLAG.DATA, MyFile, filesize, 'The only output'))
52
53        context.setStatus(STATUS.COMPLETED, 'The End', 100)
54       
55        completionTime = time.time()
56        process_support.updateJobDetailsAfterCompletion(context, startTime, completionTime)
57
58
59    def dryRun(self, context):
60
61        # Not implemented for sync jobs
62        pass
Note: See TracBrowser for help on using the repository browser.