3 @author Alexey <developers.hce@gmail.com> 4 @link http://hierarchical-cluster-engine.com/ 5 @copyright Copyright © 2013 IOIX Ukraine 6 @license http://hierarchical-cluster-engine.com/license/ 7 @package HCE project node API 18 from cement.core
import foundation
24 APP_NAME =
"ProcessorStoreContentKVDB" 26 MSG_ERROR_LOAD_CONFIG =
"Error loading config file. Exciting." 27 MSG_ERROR_LOAD_LOG_CONFIG_FILE =
"Error loading logging config file. Exiting." 28 MSG_ERROR_LOAD_EXTRACTORS =
"Error load extractors " 29 MSG_ERROR_TEMPLATE_EXTRACTION =
"Error template extraction " 30 MSG_ERROR_DYNAMIC_EXTRACTION =
"Error dynamic extraction " 31 MSG_ERROR_LOAD_DB_BACKEND =
"Error load db backend" 32 MSG_ERROR_LOAD_OPTIONS =
"Error load options" 33 MSG_INFO_PREPARE_CONTENT =
"Prepare content: " 34 MSG_ERROR_ADJUST_PR =
"Error adjust partial references. " 35 MSG_ERROR_PROCESS =
"Processor Storing Contents process batch error: " 56 foundation.CementApp.__init__(self)
69 foundation.CementApp.setup(self)
70 self.args.add_argument(
'-c',
'--config', action=
'store', metavar=
'config_file', help=
'config ini-file')
77 foundation.CementApp.run(self)
109 self.
logger.info(
"db_name: " + db_name)
113 connector = sqlite3.connect(db_name, timeout=self.
sqliteTimeout)
114 connector.text_factory = str
116 cur = connector.cursor()
117 query =
"CREATE TABLE IF NOT EXISTS \ 118 %s(id VARCHAR(32) PRIMARY KEY UNIQUE, data TEXT, CDate DATETIME DEFAULT CURRENT_TIMESTAMP)" \
121 cur.execute(
"INSERT OR REPLACE INTO raw_contents VALUES(?,?,datetime('now','localtime'))",
124 except Exception
as err:
128 ExceptionLog.handler(self.
logger, err,
'putContentToDB')
137 input_pickled_object = sys.stdin.read()
138 stored_in_data = pickle.loads(input_pickled_object)
146 except Exception
as err:
147 ExceptionLog.handler(self.
logger, err, MSG_ERROR_PROCESS, (err))
155 self.
config = ConfigParser.ConfigParser()
156 self.
config.optionxform = str
157 if self.pargs.config:
158 self.
config.read(self.pargs.config)
159 except Exception
as err:
160 print MSG_ERROR_LOAD_CONFIG + err.message
169 log_conf_file = self.
config.get(
"Application",
"log")
170 logging.config.fileConfig(log_conf_file)
172 except Exception
as err:
173 print MSG_ERROR_LOAD_LOG_CONFIG_FILE + err.message
185 except Exception
as err:
186 print MSG_ERROR_LOAD_OPTIONS + err.message
def loadLogConfigFile(self)