4 HCE project, Python bindings, Distributed Tasks Manager application. 5 Base template class from cement application for easy implementation derived classes. 7 @package: dc_postprocessor 8 @file PostProcessingApplicationClass.py 9 @author Alexander Vybornyh <alexander.hce.cluster@gmail.com> 10 @link: http://hierarchical-cluster-engine.com/ 11 @copyright: Copyright © 2013-2017 IOIX Ukraine 12 @license: http://hierarchical-cluster-engine.com/license/ 17 import cPickle
as pickle
24 from cement.core
import foundation
29 POST_PROCESSING_APPLICATION_NAME =
'PostProcessingApplicationClass' 34 MSG_ERROR_EMPTY_CONFIG_FILE_NAME =
"Config file name is empty." 35 MSG_ERROR_WRONG_CONFIG_FILE_NAME =
"Config file name is wrong" 36 MSG_ERROR_LOAD_APP_CONFIG =
"Error loading application config file." 37 MSG_ERROR_READ_LOG_CONFIG =
"Error read log config file." 38 MSG_ERROR_MISSED_SECTION =
"Missed mandatory section '%s'" 41 MSG_DEBUG_INPUT_PICKLE =
"Input pickle: " 42 MSG_DEBUG_INPUT_BATCH =
"Input batch: " 43 MSG_DEBUG_OUTPUT_BATCH =
"Output batch: " 44 MSG_DEBUG_OUTPUT_PICKLE =
"Output pickle: " 45 MSG_DEBUG_SEND_PICKLE =
"Send pickle. Done." 49 CONFIG_OPTION_LOG =
"log" 53 label = POST_PROCESSING_APPLICATION_NAME
62 foundation.CementApp.__init__(self)
73 foundation.CementApp.setup(self)
82 foundation.CementApp.run(self)
94 if not isinstance(configName, str)
or len(configName) == 0:
97 logging.config.fileConfig(configName)
102 except Exception, err:
114 config = ConfigParser.ConfigParser()
115 config.optionxform = str
117 readOk = config.read(configName)
122 if not config.has_section(APP_CONSTS.CONFIG_APPLICATION_SECTION_NAME):
128 configParser = config
129 except Exception, err:
140 if self.pargs.config:
144 if self.pargs.inputFile:
145 self.
inputFile = str(self.pargs.inputFile)
157 inputPickle = sys.stdin.read()
160 inputPickle = f.read() 171 inputBatch = pickle.loads(inputPickle)
183 outputPickle = pickle.dumps(outputBatch)
194 sys.stdout.write(outputPickle)
225 except Exception, err:
226 raise Exception(str(err))
def __sendPickle(self, outputPickle)
string MSG_ERROR_WRONG_CONFIG_FILE_NAME
def __getInputPickle(self)
def __loadLogConfig(self, configName)
string MSG_ERROR_MISSED_SECTION
string MSG_ERROR_EMPTY_CONFIG_FILE_NAME
def getConfigOption(self, sectionName, optionName, defaultValue=None)
def __unpickleInput(self, inputPickle)
string MSG_ERROR_READ_LOG_CONFIG
string MSG_ERROR_LOAD_APP_CONFIG
def __createOutputPickle(self, outputBatch)
def __loadAppConfig(self, configName)