def OnOrder(self, evt=None): otype = evt.GetColumn() if otype == 5 or otype == 6: try: if not self.WBS.bTmExit: wx.MessageBox(Eng2Zh("获取微博信息还没有结束,不能进行排序。请稍等或主动停止获取开始排序!")) return False except Exception, e: print "order error:", e return False if otype == 5: intype = "comment" elif otype == 6: intype = "rt" sina_sql = sina_sdk.Sina_Sqlite() data = sina_sql.order(intype) if data <> False: self.WeiboListCtrl.DeleteAllItems() self.WriteWBData(data) # add facebook twitter if self.fbk: fbsql = facebook.Facebook_Sql() fb = fbsql.get_status(0) self.WriteWBData(fb) if self.twr: twsql = twitter.Twitter_Sql() tw = twsql.get_status(self.weibokey, 0) self.WriteWBData(tw)
def OnWeiboSearch(self, evt): global timeoutval, threadcnt, pagecntval, pagetmval #检查网络 #if not self.OnTimer(): # return False #添加数据源菜单失效 self.menu.facebook.Enable(False) self.menu.twitter.Enable(False) self.menu.testnet.Enable(False) self.menu.order_by_comment.Enable(False) self.menu.order_by_rt.Enable(False) #self.menu.analysis.Enable(False) self.weibokey = self.WeiKeyVal.GetValue() self.weibokey = self.weibokey.encode('utf8') #print self.weibokey if self.weibokey == "": wx.MessageBox(Eng2Zh("请输入微博关键字")) return key = self.weibokey pages = pagecntval #need weibo pages tdnum = threadcnt #the thread number of getting weibo sinasql = sqlite_op.sqlite_op() twsql = twitter.Twitter_Sql() fbk_sql = facebook.Facebook_Sql() #clear sqlite try: sinasql.delete_all("status") print "delete all sina status " except Exception, e: print "delete all sina status error:", e
def GetFBKWB(self): fbk_sql = facebook.Facebook_Sql() index = 0 while not self.FBS.bTmExit: try: data = fbk_sql.get_status(index) if data == []: continue index += len(data) self.WriteWBData(data) except Exception, e: print "Get Facebook error:", e
def delete_all_sql(): print "*** start clear sqlite3" sinasql = sqlite_op.sqlite_op() rensql = sql_renren.renren_sql() twsql = twitter.Twitter_Sql() fbsql = facebook.Facebook_Sql() try: sinasql.delete_all() except: print "sina,No table" try: twsql.clear_all() print "clear twitter sql" except Exception, e: print "twitter,No table", e
def FacebookGet(self): fbsql = facebook.Facebook_Sql() index = 0 while (threading.currentThread().isAlive()): if self.isEnd: break try: data = fbsql.get_users(self.key, index) if (data == None or len(data) == 0): continue index += len(data) #print "facebook write","data",len(data),Eng2Zh("第"),index self.ForWriteData(data) except: time.sleep(0.1) print "facebook exit write" while 1: try: data = fbsql.get_users(self.key, index) self.ForWriteData(data) break except Exception, e: print "facebook write error:", e