本文整理汇总了Python中DBManager.DBManager.close方法的典型用法代码示例。如果您正苦于以下问题:Python DBManager.close方法的具体用法?Python DBManager.close怎么用?Python DBManager.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBManager.DBManager
的用法示例。
在下文中一共展示了DBManager.close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: compressLocations
# 需要导入模块: from DBManager import DBManager [as 别名]
# 或者: from DBManager.DBManager import close [as 别名]
def compressLocations(self):
#get updated location data from this nodes session table
self.updateLocations()
#initialize list to hold location rows to delete lID's
#initialize Start and End
locToDel = list()
Start = 0
End = 0
#loop over every location
for index, location in enumerate(self.locations):
#skip the first iteration
if index == 0:
continue
lID = location['lID']
#if location is the same at self.locations[Start]
if self.sameLoc(location, self.locations[Start]):
locToDel.append(lID)
End = index
else:
if not Start == End:
locToDel.pop()
Start = index
End = index
#if there are locations to delete
if locToDel:
#open a connection to the DB
db = DBManager()
#delete the locations that were marked
db.deleteLocByLID(self.sessionTblName, locToDel)
#close the database connection
db.close()
示例2: namotoring_user_grab
# 需要导入模块: from DBManager import DBManager [as 别名]
# 或者: from DBManager.DBManager import close [as 别名]
def namotoring_user_grab(url, userdb = 'namotoring_users', debug = False):
bimm = namotoring()
main_page = xmlTree_w_login(url,'vb', 'somebody', 'anybody')
userdata = []
#pdb.set_trace()
if main_page:
if not debug:
udb = DBManager()
if len(main_page.xpath(bimm.location))>0:
#print bimm.get_location(main_page.xpath(bimm.location)[0].text_content().strip())
userdata.append(('Location',bimm.get_location(main_page.xpath(bimm.location)[0].text_content().strip())))
#if len(main_page.xpath(bimm.cars))>0:
# print main_page.xpath(bimm.cars)[0].text_content()
if len(main_page.xpath(bimm.interests))>0:
#print main_page.xpath(bimm.interests)[0].text_content()
userdata.append(('Interests',main_page.xpath(bimm.interests)))
if len(main_page.xpath(bimm.noposts))>0:
#print bimm.total_posts(main_page.xpath(bimm.noposts)[0].text_content())
userdata.append(('TotalPosts',bimm.total_posts(main_page.xpath(bimm.noposts)[0].text_content())[0]))
userdata.append(('PostsPerDay',bimm.total_posts(main_page.xpath(bimm.noposts)[0].text_content())[1]))
if len(main_page.xpath(bimm.lastac))>0:
#print bimm.last_activity(main_page.xpath(bimm.lastac)[0].text_content())
userdata.append(('LastActivity',bimm.convert_to_valid_date(bimm.last_activity(main_page.xpath(bimm.lastac)[0].text_content()))))
if len(main_page.xpath(bimm.joindate))>0:
#print bimm.join_date(main_page.xpath(bimm.joindate)[0].text_content())
userdata.append(('JoinDate',bimm.convert_to_valid_date(bimm.join_date(main_page.xpath(bimm.joindate)[0].text_content()))))
#if len(main_page.xpath(bimm.ppday))>0:
# print bimm.p_p_day(main_page.xpath(bimm.ppday)[0].text_content())
#if len(main_page.xpath(bimm.cars))>0:
# print bimm.get_cars(main_page.xpath(bimm.cars)[0])
if len(main_page.xpath(bimm.handle))>0:
#print main_page.xpath(bimm.handle)[0].text_content()
userdata.append(('Handle',main_page.xpath(bimm.handle)[0].text_content().strip()))
#if len(main_page.xpath(bimm.bio))>0:
# print main_page.xpath(bimm.bio)[0].text_content()
if len(main_page.xpath(bimm.occupation))>0:
#print main_page.xpath(bimm.occupation)[0].text_content()
try:
userdata.append(('Occupation',main_page.xpath(bimm.occupation)[0].text_content()))
except AttributeError:
userdata.append(('Occupation',main_page.xpath(bimm.occupation)[0]))
if len(main_page.xpath(bimm.ulink))>0:
#print main_page.xpath(bimm.ulink)[0].text_content()
userdata.append(('Link',main_page.xpath(bimm.ulink)[0].text_content()))
if len(main_page.xpath(bimm.name))>0:
#print bimm.get_name_email(main_page.xpath(bimm.name)[0])
userdata.append(('Name',bimm.get_name_email(main_page.xpath(bimm.name)[0])))
#print userdata
if len(main_page.xpath(bimm.plus_fb))>0:
userdata.append(('PositiveFeedback', main_page.xpath(bimm.plus_fb)[0].text_content().strip()))
if len(main_page.xpath(bimm.minus_fb))>0:
userdata.append(('NegativeFeedback', diff(main_page.xpath(bimm.minus_fb)[0].text_content().strip(),\
main_page.xpath(bimm.plus_fb)[0].text_content().strip())))
if not debug:
udb.insert_into_table(userdb, userdata)
udb.close()
else:
print userdata
else:
pass
示例3: validateLocations
# 需要导入模块: from DBManager import DBManager [as 别名]
# 或者: from DBManager.DBManager import close [as 别名]
def validateLocations(self):
#get updated location data from this nodes session table
self.updateLocations()
#initialize list to hold lID's of location rows to delete
locToDel = list()
#loop over every location
for location in self.locations:
lID = location['lID']
locTime = location['time']
locLat = location['lat']
locLon = location['lon']
# if the timestamp is invalid (in the future)
if not self.validTime(locTime):
locToDel.append(lID)
# o.w. if the location is invalid
elif not self.validLoc(locLat, locLon):
locToDel.append(lID)
#if there are locations to delete
if locToDel:
#open a connection to the DB
db = DBManager()
#delete the locations that were marked
db.deleteLocByLID(self.sessionTblName, locToDel)
#close the database connection
db.close()
示例4: audiworld_user_grab
# 需要导入模块: from DBManager import DBManager [as 别名]
# 或者: from DBManager.DBManager import close [as 别名]
def audiworld_user_grab(url, userdb = 'audiworld_users', debug = True):
bimm = audiworld()
main_page = xmlTree(url)
if main_page:
userdata = []
if not debug:
udb = DBManager()
if len(main_page.xpath(bimm.location))>0:
#print main_page.xpath(bimm.location)[0].text_content()
userdata.append(('Location',main_page.xpath(bimm.location)[0].text_content()))
#if len(main_page.xpath(bimm.cars))>0:
# print main_page.xpath(bimm.cars)[0].text_content()
if len(main_page.xpath(bimm.interests))>0:
#print main_page.xpath(bimm.interests)[0].text_content()
userdata.append(('Interests',main_page.xpath(bimm.interests)[0].text_content()))
if len(main_page.xpath(bimm.noposts))>0:
#print bimm.total_posts(main_page.xpath(bimm.noposts)[0].text_content())
userdata.append(('TotalPosts',bimm.total_posts(main_page.xpath(bimm.noposts)[0].text_content())))
if len(main_page.xpath(bimm.lastac))>0:
#print bimm.last_activity(main_page.xpath(bimm.lastac)[0].text_content())
userdata.append(('LastActivity',bimm.convert_to_valid_date(bimm.last_activity(main_page.xpath(bimm.lastac)[0].text_content()))))
if len(main_page.xpath(bimm.joindate))>0:
#print bimm.join_date(main_page.xpath(bimm.joindate)[0].text_content())
userdata.append(('JoinDate',bimm.convert_to_valid_date(bimm.join_date(main_page.xpath(bimm.joindate)[0].text_content()))))
if len(main_page.xpath(bimm.ppday))>0:
#print bimm.p_p_day(main_page.xpath(bimm.ppday)[0].text_content())
userdata.append(('PostsPerDay',bimm.p_p_day(main_page.xpath(bimm.ppday)[0].text_content())))
if len(main_page.xpath(bimm.cars))>0:
#print bimm.get_cars(main_page.xpath(bimm.cars)[0])
userdata.append(('Cars',bimm.get_cars(main_page.xpath(bimm.cars)[0])))
if len(main_page.xpath(bimm.handle))>0:
#print main_page.xpath(bimm.handle)[0].text_content().strip()
userdata.append(('Handle',main_page.xpath(bimm.handle)[0].text_content().strip()))
if len(main_page.xpath(bimm.bio))>0:
#print main_page.xpath(bimm.bio)[0].text_content()
userdata.append(('Biography',main_page.xpath(bimm.bio)[0].text_content()))
if len(main_page.xpath(bimm.occupation))>0:
#print main_page.xpath(bimm.occupation)[0].text_content()
userdata.append(('Occupation',main_page.xpath(bimm.occupation)[0].text_content()))
if len(main_page.xpath(bimm.ulink))>0:
#print main_page.xpath(bimm.ulink)[0].text_content()
userdata.append(('Link',main_page.xpath(bimm.ulink)[0].text_content()))
if not debug:
udb.insert_into_table(userdb, userdata)
udb.close() #@IndentOk
else:
print userdata
else:
pass
示例5: updateLocations
# 需要导入模块: from DBManager import DBManager [as 别名]
# 或者: from DBManager.DBManager import close [as 别名]
def updateLocations(self):
db = DBManager()
#get this nodes location data
self.locations = db.getLocations(self.sessionTblName, self.nID)
db.close()
#if this node has no locations or is not in a sessions, stop the housekeeping threads
if self.locations is None:
self.keepRunning = False
示例6: priuschat_user_grab
# 需要导入模块: from DBManager import DBManager [as 别名]
# 或者: from DBManager.DBManager import close [as 别名]
def priuschat_user_grab(url, userdb='priuschat_users', debug = False):
bimm = priuschat()
main_page = xmlTree(url)
userdata = []
#pdb.set_trace()
if main_page:
if not debug:
udb = DBManager()
if len(main_page.xpath(bimm.location))>0:
#print main_page.xpath(bimm.location)[0].text_content().strip()
userdata.append(('Location',main_page.xpath(bimm.location)[0].text_content().strip()))
#if len(main_page.xpath(bimm.cars))>0:
# print main_page.xpath(bimm.cars)[0].text_content()
if len(main_page.xpath(bimm.interests))>0:
#print main_page.xpath(bimm.interests)[0].text_content()
userdata.append(('Interests',main_page.xpath(bimm.interests)[0].text_content()))
if len(main_page.xpath(bimm.noposts))>0:
#print bimm.total_posts(main_page.xpath(bimm.noposts)[0].text_content())
userdata.append(('TotalPosts',bimm.total_posts(main_page.xpath(bimm.noposts)[0].text_content())))
if len(main_page.xpath(bimm.lastac))>0:
#print bimm.last_activity(main_page.xpath(bimm.lastac)[0].text_content())
userdata.append(('LastActivity',bimm.convert_to_valid_date(bimm.last_activity(main_page.xpath(bimm.lastac)[0].text_content()))))
if len(main_page.xpath(bimm.joindate))>0:
#print bimm.join_date(main_page.xpath(bimm.joindate)[0].text_content())
userdata.append(('JoinDate', bimm.convert_to_valid_date(bimm.join_date(main_page.xpath(bimm.joindate)[0].text_content()))))
if len(main_page.xpath(bimm.ppday))>0:
#print bimm.p_p_day(main_page.xpath(bimm.ppday)[0].text_content())
userdata.append(('PostsPerDay', bimm.p_p_day(main_page.xpath(bimm.ppday)[0].text_content())))
if len(main_page.xpath(bimm.cars))>0:
#print main_page.xpath(bimm.cars)[0].text_content()
userdata.append(('Cars',main_page.xpath(bimm.cars)[0].text_content()))
if len(main_page.xpath(bimm.handle))>0:
#print main_page.xpath(bimm.handle)[0].text_content()
userdata.append(('Handle',main_page.xpath(bimm.handle)[0].text_content()))
#if len(main_page.xpath(bimm.bio))>0:
# print main_page.xpath(bimm.bio)[0].text_content()
if len(main_page.xpath(bimm.occupation))>0:
#print main_page.xpath(bimm.occupation)[0].text_content()
userdata.append(('Occupation',main_page.xpath(bimm.occupation)[0].text_content()))
if len(main_page.xpath(bimm.ulink))>0:
#print main_page.xpath(bimm.ulink)[0].text_content()
userdata.append(('Link', main_page.xpath(bimm.ulink)[0].text_content()))
#if len(main_page.xpath(bimm.name))>0:
# print bimm.get_name_email(main_page.xpath(bimm.name)[0])
#print userdata
if not debug:
udb.insert_into_table(userdb, userdata)
udb.close()
else:
print userdata
else:
pass
示例7: createNodes
# 需要导入模块: from DBManager import DBManager [as 别名]
# 或者: from DBManager.DBManager import close [as 别名]
def createNodes(self):
#get data for nodes in the session
db = DBManager()
nodesData = db.getNodes(self.tblName)
db.close()
#create a new Node object for each nodeData row in nodesData
# if such an object does not already exist
for nodeData in nodesData:
if not nodeData['devID'] in self.nodesDict:
#add NodeHandler object to the list of nodes
self.nodes.append(NodeHandler(nodeData))
#add devID key to nodesDict and set to false(not started yet)
self.nodesDict[nodeData['devID']] = False
示例8: vwvortex_grab
# 需要导入模块: from DBManager import DBManager [as 别名]
# 或者: from DBManager.DBManager import close [as 别名]
def vwvortex_grab(threaddb = 'vwvortex_threads', debug = True):
# pdb.set_trace()
bmw = vwvortex()
main_page = xmlTree(bmw.domain)
lvl1 = main_page.xpath(bmw.linklist_lvl1)
if not debug:
udb = DBManager()
for lvl1_link in lvl1:
second_lvl_page = xmlTree(bmw.domain+lvl1_link)
lvl2 = second_lvl_page.xpath(bmw.linklist_lvl2)
for lvl2_link in lvl2:
next_page = xmlTree(bmw.domain+lvl2_link+alltime)
while True:
try:
next = next_page.xpath(bmw.next_link)[0]
except IndexError:
next = None
threads = next_page.xpath(bmw.threads_list)
tread_data = next_page.xpath(bmw.threaddata)
for j in tread_data:
#pass
if j.xpath(bmw.description):
threaddata = []
threaddata.append(('Description', j.xpath(bmw.description)[0].text_content().encode('utf-8')))
#print j.xpath(bmw.description)[0].text_content().encode('utf-8')
threaddata.append(('Replies', j.xpath(bmw.replies)[0].text_content()))
#print j.xpath(bmw.replies)[0].text_content()
threaddata.append(('Views', bmw.parse_views(j.xpath(bmw.views)[0].text_content())['Views']))
#print bmw.parse_views(j.xpath(bmw.views)[0].text_content())
threaddata.append(('Link', j.xpath(bmw.link)[0].encode('utf-8')))
#print j.xpath(bmw.link)[0].encode('utf-8')
#print bmw.thread_id(j.xpath(bmw.link)[0].encode('utf-8'))
vwvortex_thread_grab(bmw.domain+j.xpath(bmw.link)[0].encode('utf-8'))
if not debug:
udb.insert_into_table(threaddb, threaddata)
else:
print threaddata
#vwvortex_thread_grab()
# for k in threads:
# pass
# print k
if next:
next_page = xmlTree(bmw.domain+next)
elif not next:
break
if not debug:
udb.close()
示例9: audiworld_grab
# 需要导入模块: from DBManager import DBManager [as 别名]
# 或者: from DBManager.DBManager import close [as 别名]
def audiworld_grab(threaddb = 'audiworld_threads', debug = True):
bmw = audiworld()
main_page = xmlTree(bmw.domain)
lvl1 = main_page.xpath(bmw.linklist)
if not debug:
udb = DBManager()
for lvl1_link in lvl1:
# print lvl1_link
next_page = xmlTree(bmw.domain+lvl1_link+alltime)
#next_page = xmlTree(lvl1_link)
# print bmw.domain+lvl1_link
#next = next_page.xpath(bmw.next_link)[0]
while True:
try:
next = next_page.xpath(bmw.next_link)[0]
except IndexError:
next = None
threads = next_page.xpath(bmw.threads_list)
tread_data = next_page.xpath(bmw.threaddata)
for j in tread_data:
#pass
threaddata = []
if j.xpath(bmw.description):
threaddata.append(('Description',j.xpath(bmw.description)[0].text_content().encode('utf-8')))
#print j.xpath(bmw.description)[0].text_content().encode('utf-8')
threaddata.append(('Replies', j.xpath(bmw.replies)[0].text_content()))
#print j.xpath(bmw.replies)[0].text_content()
threaddata.append(('Views', j.xpath(bmw.views)[0].text_content()))
#print j.xpath(bmw.views)[0].text_content()
threaddata.append(('Link', j.xpath(bmw.link)[0]))
#print j.xpath(bmw.link)[0]
threaddata.append(('ThreadID', bmw.thread_id(j.xpath(bmw.link)[0]) ))
#print bmw.thread_id(j.xpath(bmw.link)[0])
audiworld_thread_grab(bmw.domain+j.xpath(bmw.link)[0])
if not debug:
udb.insert_into_table(threaddb, threaddata)
else:
print threaddata
for k in threads:
pass
print k
if next:
next_page = xmlTree(bmw.domain+next+alltime)
elif not next:
break
if not debug:
udb.close()
示例10: feoa_thread_grab
# 需要导入模块: from DBManager import DBManager [as 别名]
# 或者: from DBManager.DBManager import close [as 别名]
def feoa_thread_grab(url, postsdb = 'feoa_posts', debug = True):
bimm = feoa()
next_page = xmlTree(url)
#posts = main_page
if not debug:
udb = DBManager()
while True:
try:
next = next_page.xpath(bimm.next_link)[0]
#print next
except IndexError:
next = None
posts = next_page.xpath(bimm.postdata)
for t in posts:
if t.xpath(bimm.posterid):
threaddata = []
#print '**********************************************************************'
threaddata.append(('TimeOfPost',bimm.convert_to_valid_date(bimm.time_of_post(\
t.xpath(bimm.timeofpost)[0].text_content().strip()))))
#print t.xpath(bimm.timeofpost)[0].text_content().strip()
threaddata.append(('PosterID',bimm.poster_id(t.xpath(bimm.posterid)[0])))
#print bimm.poster_id(t.xpath(bimm.posterid)[0])#[0].text_content()
threaddata.append(('PostID',bimm.post_id(t.xpath(bimm.postid)[0])))
#print bimm.post_id(t.xpath(bimm.postid)[0])#[0].text_content()
threaddata.append(('ThreadID', bimm.thread_id(t.xpath(bimm.post_thread)[0])))
try:
threaddata.append(('PostCountInThread',t.xpath(bimm.postcount)[0].text_content()))
#print t.xpath(bimm.postcount)[0].text_content()
except AttributeError:
threaddata.append(('PostCountInThread',t.xpath(bimm.postcount)[0]))
#print t.xpath(bimm.postcount)[0]
except IndexError:
pass
threaddata.append(('Link',t.xpath(bimm.postlink)[0] ))
feoa_user_grab(bimm.domain+t.xpath(bimm.posterid)[0], 'feoa_users')
if not debug:
udb.insert_into_table(postsdb, threaddata)
else:
print threaddata
#print t.xpath(bimm.postlink)#[0].text_content()
#print '**********************************************************************'
if next:
#pdb.set_trace()
next_page = xmlTree(bimm.domain+next+alltime)
elif not next:
if not debug:
udb.close()
break
示例11: mazda3_grab
# 需要导入模块: from DBManager import DBManager [as 别名]
# 或者: from DBManager.DBManager import close [as 别名]
def mazda3_grab(threaddb = 'mazda3_threadas', debug =True):
#pdb.set_trace()
bmw = mazda3()
main_page = xmlTree(bmw.domain)
lvl1 = main_page.xpath(bmw.linklist)
if not debug:
udb = DBManager()
for lvl1_link in lvl1:
next_page = xmlTree(lvl1_link)
count = 0
pos = lvl1_link.find('board=') + len('board=')
part = lvl1_link[:pos]
fid = lvl1_link[pos:]
ifid = fid.split(r'.')
try:
lastpage = int(next_page.xpath(bmw.last_page_threads)[0].text_content())
except IndexError:
lastpage = 1
while count<lastpage:
#threads_list = next_page.xpath(bmw.threaddata)
threads = next_page.xpath(bmw.threads_list)
tread_data = next_page.xpath(bmw.threaddata)
for j in tread_data:
#pass
threaddata = []
if j.xpath(bmw.description):
threaddata.append(('Description',j.xpath(bmw.description)[0].text_content().encode('utf-8')))
#print j.xpath(bmw.description)[0].text_content().encode('utf-8')
threaddata.append(('Views', bmw.parse_stats(j.xpath(bmw.stats)[0].text_content())['Views']))
threaddata.append(('Views', bmw.parse_stats(j.xpath(bmw.stats)[0].text_content())['Replies']))
# print bmw.parse_stats(j.xpath(bmw.stats)[0].text_content())
#print j.xpath(bmw.views)[0].text_content()
threaddata.append(('Link', j.xpath(bmw.link)[0]))
# print j.xpath(bmw.link)[0]
mazda3_thread_grab(bmw.thread_id(j.xpath(bmw.link)[0]))
if not debug:
udb.insert_into_table(threaddb, threaddata)
#pass
else:
print threaddata
count += 1
print count
print part+addto(ifid,count)
next_page = xmlTree(part+addto(ifid,count))
if not debug:
udb.close()
示例12: priuschat_thread_grab
# 需要导入模块: from DBManager import DBManager [as 别名]
# 或者: from DBManager.DBManager import close [as 别名]
def priuschat_thread_grab(url, postsdb = 'priuschat_posts',debug = False):
bimm = priuschat()
next_page = xmlTree(url)
#posts = main_page
if not debug:
udb = DBManager()
while True:
try:
next = next_page.xpath(bimm.next_link)[0]
print next
except IndexError:
next = None
posts = next_page.xpath(bimm.postdata)
for t in posts:
if t.xpath(bimm.posterid):
threaddata = []
threaddata.append(('TimeOfPost',bimm.convert_to_valid_date(bimm.last_activity(t.xpath(bimm.timeofpost)[0]\
.text_content().strip()))))
#print t.xpath(bimm.timeofpost)[0].text_content().strip()
threaddata.append(('PosterID',bimm.poster_id(t.xpath(bimm.posterid)[0])))
#print bimm.poster_id(t.xpath(bimm.posterid)[0])#[0].text_content()
threaddata.append(('PostID',bimm.post_id(t.xpath(bimm.postid)[0])))
#print bimm.post_id(t.xpath(bimm.postid)[0])#[0].text_content()
try:
threaddata.append(('PostCountInThread',t.xpath(bimm.postcount)[0].text_content()))
#print t.xpath(bimm.postcount)[0].text_content()
except AttributeError:
threaddata.append(('PostCountInThread',t.xpath(bimm.postcount)[0]))
#print t.xpath(bimm.postcount)[0]
threaddata.append(('Link',t.xpath(bimm.postlink)[0]))
#print t.xpath(bimm.postlink)#[0].text_content()
priuschat_user_grab(t.xpath(bimm.posterid)[0],'priuschat_users')
if not debug:
udb.insert_into_table(postsdb, threaddata)
else:
print threaddata
if next:
#pdb.set_trace()
next_page = xmlTree(next)
elif not next:
if not debug:
udb.close()
break
示例13: mazda3_user_grab
# 需要导入模块: from DBManager import DBManager [as 别名]
# 或者: from DBManager.DBManager import close [as 别名]
def mazda3_user_grab(url, userdb = 'mazda3_users',debug = True):
bimm = mazda3()
main_page = xmlTree_w_login(url, 'mazda', 'somebodyis', 'anybodyanybody')
userdata = []
if main_page:
if not debug:
udb = DBManager()
#pdb.set_trace()
if len(main_page.xpath(bimm.location))>0:
#print main_page.xpath(bimm.location)[0].text_content().strip()
userdata.append(('Location', main_page.xpath(bimm.location)[0].text_content().strip()))
if len(main_page.xpath(bimm.car_make))>0:
#print main_page.xpath(bimm.cars)[0].text_content()
userdata.append(('Cars', main_page.xpath(bimm.car_make)[0].text_content()\
+main_page.xpath(bimm.car_year)[0].text_content()))
# if len(main_page.xpath(bimm.interests))>0:
# #print main_page.xpath(bimm.interests)[0].text_content()
# userdata.append(('Interests', main_page.xpath(bimm.interests)[0].text_content()))
if len(main_page.xpath(bimm.noposts))>0:
#print bimm.total_posts(main_page.xpath(bimm.noposts)[0].text_content())
userdata.append(('TotalPosts', bimm.total_posts(main_page.xpath(bimm.noposts)[0].text_content())))
if len(main_page.xpath(bimm.lastac))>0:
#print bimm.last_activity(main_page.xpath(bimm.lastac)[0].text_content())
userdata.append(('LastActivity', bimm.convert_to_valid_date(bimm.last_activity(main_page.xpath(bimm.lastac)[0].text_content()))))
if len(main_page.xpath(bimm.joindate))>0:
#print bimm.join_date(main_page.xpath(bimm.joindate)[0].text_content())
userdata.append(('JoinDate', bimm.convert_to_valid_date(bimm.join_date(main_page.xpath(bimm.joindate)[0].text_content()))))
#if len(main_page.xpath(bimm.ppday))>0:
# print bimm.p_p_day(main_page.xpath(bimm.ppday)[0].text_content())
#if len(main_page.xpath(bimm.cars))>0:
# print main_page.xpath(bimm.cars)[0].text_content()
if len(main_page.xpath(bimm.handle))>0:
#print bimm.get_handle(main_page.xpath(bimm.handle)[0].text_content())
userdata.append(('Handle', bimm.get_handle(main_page.xpath(bimm.handle)[0])))
if len(main_page.xpath(bimm.minus_fb))>0:
userdata.append(('NegativeFeedback', main_page.xpath(bimm.minus_fb)[0].text_content().strip()))
if len(main_page.xpath(bimm.plus_fb))>0:
userdata.append(('PositiveFeedback', main_page.xpath(bimm.plus_fb)[0].text_content().strip()))
if not debug:
udb.insert_into_table(userdb, userdata)
udb.close()
else:
print userdata
else:
pass
示例14: run
# 需要导入模块: from DBManager import DBManager [as 别名]
# 或者: from DBManager.DBManager import close [as 别名]
def run(self):
# run until forced to stop
while True:
# block until a new alert object appears on the queue
alert = self.queue.get()
# if alert.contactID exists
if alert.contactID is not None:
# try to find the contact information for the alert object's contactID
try:
db = DBManager()
contact = db.findContact(cID=alert.contactID)
db.close()
# send the alert using the provided communication types
self.sendAlert(contact, alert)
except ContactError as ce:
self.logger.info(
str(self.reporterID) + ": Contact with ID: %s was not found" % str(alert.contactID)
)
示例15: mazda3_thread_grab
# 需要导入模块: from DBManager import DBManager [as 别名]
# 或者: from DBManager.DBManager import close [as 别名]
def mazda3_thread_grab(url, postsdb = 'mazda3_posts', debug = True):
bimm = mazda3()
next_page = xmlTree(url)
lvl1 = next_page.xpath(bimm.postdata)
count = 0
pos = url.find('topic=') + len('topic=')
part = url[:pos]
fid = url[pos:]
ifid = fid.split(r'.')
if not debug:
udb = DBManager()
try:
lastpage = int(next_page.xpath(bimm.last_page_threads)[0].text_content())
except IndexError:
lastpage = 1
while count<lastpage:
posts = next_page.xpath(bimm.postdata)
for pst in posts:
threaddata = []
threaddata.append(('TimeOfPost',bimm.convert_to_valid_date(bimm.last_activity(bimm.time_of_post(pst.xpath(\
bimm.timeofpost)[0].text_content())))))
#print bimm.time_of_post(pst.xpath(bimm.timeofpost)[0].text_content())
threaddata.append(('PosterID',bimm.poster_id(pst.xpath(bimm.posterid)[0])))
#print pst.xpath(bimm.posterid)[0]
threaddata.append(('PostID',bimm.post_id(pst.xpath(bimm.postid)[0])))
#print pst.xpath(bimm.postid)[0]
threaddata.append(('Link',pst.xpath(bimm.postlink)[0]))
#print pst.xpath(bimm.postlink)[0]
threaddata.append(('PostCountInThread',bimm.post_count(pst.xpath(bimm.postcount)[0].text_content())))
threaddata.append(('ThreadID', bimm.thread_id(pst.xpath(bimm.post_thread)[0])))
#print bimm.post_count(pst.xpath(bimm.postcount)[0].text_content())
mazda3_user_grab(pst.xpath(bimm.posterid)[0],'mazda3_users')
if not debug:
udb.insert_into_table(postsdb, threaddata)
else:
print threaddata
count += 1
#print count
#print part+addto(ifid,count)
next_page = xmlTree(part+addto(ifid,count))
if not debug:
udb.close()