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

Public Member Functions

def __init__ (self)
 
def process (self, proxies, queryCallback)
 
def insertProxy (self, proxy, 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 lookProxyInDB (proxy, queryCallback)
 
- Static Public Member Functions inherited from dc_db.BaseTask.BaseTask
def readValueFromSiteProp (siteId, propName, queryCallback, urlMd5=None)
 

Detailed Description

Definition at line 20 of file ProxyNewTask.py.

Constructor & Destructor Documentation

◆ __init__()

def dc_db.ProxyNewTask.ProxyNewTask.__init__ (   self)

Definition at line 25 of file ProxyNewTask.py.

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

Member Function Documentation

◆ insertProxy()

def dc_db.ProxyNewTask.ProxyNewTask.insertProxy (   self,
  proxy,
  queryCallback 
)

Definition at line 69 of file ProxyNewTask.py.

69  def insertProxy(self, proxy, queryCallback):
70  ret = False
71  fields, values = Constants.getFieldsValuesTuple(proxy, Constants.ProxyTableDict)
72  fieldValueString = Constants.createFieldsValuesString(fields, values)
73  if fieldValueString is not None and fieldValueString != "":
74  query = Constants.INSERT_COMMON_TEMPLATE % ("sites_proxy", fieldValueString)
75  queryCallback(query, Constants.PRIMARY_DB_ID)
76  ret = True
77  return ret
78 
Here is the caller graph for this function:

◆ lookProxyInDB()

def dc_db.ProxyNewTask.ProxyNewTask.lookProxyInDB (   proxy,
  queryCallback 
)
static

Definition at line 35 of file ProxyNewTask.py.

35  def lookProxyInDB(proxy, queryCallback):
36  ret = False
37  FETCH_PROXY_SQL = "SELECT * FROM `sites_proxy` WHERE `Site_Id` = '%s' AND `Host` = '%s'"
38  query = FETCH_PROXY_SQL % (proxy.siteId, proxy.host)
39  res = queryCallback(query, Constants.PRIMARY_DB_ID)
40  if hasattr(res, '__iter__') and len(res) > 0 and res[0] is not None:
41  ret = True
42  return ret
43 
44 

◆ process()

def dc_db.ProxyNewTask.ProxyNewTask.process (   self,
  proxies,
  queryCallback 
)

Definition at line 50 of file ProxyNewTask.py.

50  def process(self, proxies, queryCallback):
51  ret = GeneralResponse()
52  for proxy in proxies:
53  if not ProxyNewTask.lookProxyInDB(proxy, queryCallback):
54  if self.insertProxy(proxy, queryCallback):
55  status = 0
56  else:
57  status = 1
58  else:
59  status = 2
60  ret.statuses.append(status)
61  return ret
62 
63 
Here is the call graph for this function:
Here is the caller graph for this function:

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