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
dc_db.AttrFetchTask.AttrFetchTask Class Reference
Inheritance diagram for dc_db.AttrFetchTask.AttrFetchTask:
Collaboration diagram for dc_db.AttrFetchTask.AttrFetchTask:

Public Member Functions

def __init__ (self)
 
def process (self, attrFetches, queryCallback)
 
- Public Member Functions inherited from dc_db.BaseTask.BaseTask
def isSiteExist (self, siteId, queryCallback, userId=None)
 
def generateCriterionSQL (self, criterions, additionWhere=None, siteId=None)
 
def fetchByCriterions (self, criterions, queryCallback)
 
def dbLock (self, mutexName, queryCallback, sleepTime=1, mutexLockTTL=Constants.DEFAULT_LOCK_TTL)
 
def dbUnlock (self, mutexName, queryCallback)
 
def createUrlsInsertQuery (self, siteId, localKeys, localValues)
 
def copyUrlsToDcUrls (self, siteId, queryCallback)
 
def statisticLogUpdate (self, localObj, urlMd5, siteId, status, queryCallback, isInsert=False)
 
def calculateMd5FormUrl (self, url, urlType, useNormilize=False)
 

Static Public Member Functions

def fetchUrlsAttributes (siteId, urlMd5, queryCallback)
 
def fetchUrlsAttributesByNames (siteId, urlMd5, queryCallback, attributeNames)
 
- Static Public Member Functions inherited from dc_db.BaseTask.BaseTask
def readValueFromSiteProp (siteId, propName, queryCallback, urlMd5=None)
 

Static Public Attributes

string ATTR_FETCH_TEMPLATE = "SELECT * FROM `%s` "
 

Detailed Description

Definition at line 20 of file AttrFetchTask.py.

Constructor & Destructor Documentation

◆ __init__()

def dc_db.AttrFetchTask.AttrFetchTask.__init__ (   self)

Definition at line 26 of file AttrFetchTask.py.

26  def __init__(self):
27  super(AttrFetchTask, self).__init__()
28 
29 
def __init__(self)
constructor
Definition: UIDGenerator.py:19

Member Function Documentation

◆ fetchUrlsAttributes()

def dc_db.AttrFetchTask.AttrFetchTask.fetchUrlsAttributes (   siteId,
  urlMd5,
  queryCallback 
)
static

Definition at line 69 of file AttrFetchTask.py.

69  def fetchUrlsAttributes(siteId, urlMd5, queryCallback):
70  attrFetchTask = AttrFetchTask()
71  attrFetches = [dc.EventObjects.AttributeFetch(siteId, None, {"WHERE": ("`URLMd5` = '%s'" % urlMd5)})]
72  return attrFetchTask.process(attrFetches, queryCallback)
73 
74 

◆ fetchUrlsAttributesByNames()

def dc_db.AttrFetchTask.AttrFetchTask.fetchUrlsAttributesByNames (   siteId,
  urlMd5,
  queryCallback,
  attributeNames 
)
static

Definition at line 83 of file AttrFetchTask.py.

83  def fetchUrlsAttributesByNames(siteId, urlMd5, queryCallback, attributeNames):
84  # variable for result
85  ret = []
86  # get full attributes list
87  attributes = AttrFetchTask.fetchUrlsAttributes(siteId, urlMd5, queryCallback)
88  if isinstance(attributeNames, list):
89  # default behavior (return all attributes)
90  if '*' in attributeNames:
91  ret = attributes
92  # search name form list
93  else:
94  localAttributes = []
95  for attribute in attributes:
96  if attribute.name in attributeNames:
97  localAttributes.append(attribute)
98  # save attributes list
99  ret = localAttributes
100 
101  return ret
102 

◆ process()

def dc_db.AttrFetchTask.AttrFetchTask.process (   self,
  attrFetches,
  queryCallback 
)

Definition at line 35 of file AttrFetchTask.py.

35  def process(self, attrFetches, queryCallback):
36  ret = []
37  for attrFetch in attrFetches:
38  if self.isSiteExist(attrFetch.siteId, queryCallback):
39  try:
40  additionWhere = None
41  if attrFetch.name is None:
42  additionWhere = self.generateCriterionSQL(attrFetch.criterions)
43  else:
44  additionWhere = ("WHERE `Name` = '%s'" % attrFetch.name)
45  logger.debug(">>> additionWhere = " + str(additionWhere))
46  if additionWhere is not None and len(additionWhere) > 0:
47  query = AttrFetchTask.ATTR_FETCH_TEMPLATE % (Constants.DC_ATT_TABLE_NAME_TEMPLATE % attrFetch.siteId)
48  res = queryCallback(query + additionWhere, Constants.ATT_DB_ID, Constants.EXEC_NAME)
49  if res is not None and len(res) > 0:
50  for elem in res:
51  attribute = dc.EventObjects.Attribute(attrFetch.siteId, elem["Name"])
52  attribute.urlMd5 = elem["URLMd5"]
53  attribute.value = elem["Value"]
54  attribute.cDate = elem["CDate"]
55  ret.append(attribute)
56  except Exception as excp:
57  logger.debug(">>> [AttributeFetch] Some Exception = " + str(type(excp)) + " " + str(excp))
58 
59  return ret
60 
61 
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ ATTR_FETCH_TEMPLATE

string dc_db.AttrFetchTask.AttrFetchTask.ATTR_FETCH_TEMPLATE = "SELECT * FROM `%s` "
static

Definition at line 22 of file AttrFetchTask.py.


The documentation for this class was generated from the following file: