HCE Project Python language Distributed Tasks Manager Application, Distributed Crawler Application and client API bindings.  2.0.0-chaika
Hierarchical Cluster Engine Python language binding
ftest_ContentEvaluator.py
Go to the documentation of this file.
1 #!/usr/bin/python
2 # coding: utf-8
3 
4 import os
5 import sys
6 import logging
7 import logging.config
8 import ConfigParser
9 from sys import stdout
10 from sys import stderr
11 from app.Utils import varDump
12 
13 import dc_crawler.DBTasksWrapper as DBTasksWrapper
14 from app.ContentEvaluator import ContentEvaluator
15 
16 def getLogger():
17  # create logger
18  logger = logging.getLogger('hce')
19  logger.setLevel(logging.DEBUG)
20 
21  # create console handler and set level to debug
22  ch = logging.StreamHandler()
23  ch.setLevel(logging.DEBUG)
24 
25  # create formatter
26  formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
27 
28  # add formatter to ch
29  ch.setFormatter(formatter)
30 
31  # add ch to logger
32  logger.addHandler(ch)
33 
34  return logger
35 
36 
38  CONFIG_NAME = "../../ini/db-task.ini"
39  cfgParser = ConfigParser.ConfigParser()
40  cfgParser.read(CONFIG_NAME)
41  return DBTasksWrapper.DBTasksWrapper(cfgParser)
42 
43 
44 
45 logger = getLogger()
46 dbWrapper = getDBWrapper()
47 
48 contentData = '****************<!--TEST-->*****************'
49 
50 json = "[{\"WHERE\":\"RAW\", \"WHAT\":\"<!--(.*)-->\", \"WITH\":\" \", \"CONDITION\":\"ContentType='text/html'\"}]"
51 
52 sqlExpression = "ContentType='text/html'"
53 siteId = '40d202ab0424bd4ff6768171befd98e4'
54 # siteId = '0'
55 
56 # res = ContentEvaluator.executeSqlExpression(dbWrapper, siteId, sqlExpression)
57 # logger.debug('res:' + str(res))
58 # logger.debug("\n\n")
59 
60 logger.debug("contentData: %s", varDump(contentData))
61 contentData = ContentEvaluator.executeReplace(dbWrapper, siteId, json, contentData)
62 logger.debug("")
63 logger.debug("contentData: %s", varDump(contentData))
64 
def varDump(obj, stringify=True, strTypeMaxLen=256, strTypeCutSuffix='...', stringifyType=1, ignoreErrors=False, objectsHash=None, depth=0, indent=2, ensure_ascii=False, maxDepth=10)
Definition: Utils.py:410