def list_live_posts(): tracking_post_ids = weibo_module.get_tracking_postids() print "########## POSTS TRACKING ##########" print "# of posts we're tracking: ", len(tracking_post_ids) if (len(tracking_post_ids) > 0): for this_post_id in tracking_post_ids: print "Checking post #" + this_post_id + ":", this_post_new = weibo_module.get_most_recent_live_post( this_post_id) this_post_old = weibo_module.get_oldest_post(this_post_id) print "alive: new/old repost count (", this_post_new[ "post_repost_count"], " / ", this_post_old[ "post_repost_count"], ") " # print "* this_post_new = " , this_post_new elapsedtime = nowdatetime - weibo_module.set_timezone_to_china( this_post_new["started_tracking_at"]) print "elapsed time = ", elapsedtime
def list_live_posts(): tracking_post_ids = weibo_module.get_tracking_postids() print "########## POSTS TRACKING ##########" print "# of posts we're tracking: " , len(tracking_post_ids) if (len(tracking_post_ids) > 0): for this_post_id in tracking_post_ids: print "Checking post #" + this_post_id + ":", this_post_new = weibo_module.get_most_recent_live_post(this_post_id) this_post_old = weibo_module.get_oldest_post(this_post_id) print "alive: new/old repost count (" , this_post_new["post_repost_count"] , " / " , this_post_old["post_repost_count"] , ") " # print "* this_post_new = " , this_post_new elapsedtime = nowdatetime - weibo_module.set_timezone_to_china(this_post_new["started_tracking_at"]) print "elapsed time = " , elapsedtime
def list_retired_posts(): retired_post_ids = weibo_module.get_retired_postids() print "" print "########## RETIRED POSTS ##########" num_retired_posts = len(retired_post_ids) print "# of retired posts we've tracked: " + str(num_retired_posts) if (num_retired_posts > 0): retired_post_ids = [] for this_post_id in retired_post_ids: print "Checking post # " + this_post_id , # get the post info from postids_live collection, # since if the post was retired we wouldn't have any of that info anymore this_post_new = weibo_module.get_most_recent_live_post(this_post_id) this_post_old = weibo_module.get_oldest_post(this_post_id) print "alive: new/old repost count (" , this_post_new["post_repost_count"] , " / " , this_post_old["post_repost_count"] , ") "
def list_retired_posts(): retired_post_ids = weibo_module.get_retired_postids() print "" print "########## RETIRED POSTS ##########" num_retired_posts = len(retired_post_ids) print "# of retired posts we've tracked: " + str(num_retired_posts) if (num_retired_posts > 0): retired_post_ids = [] for this_post_id in retired_post_ids: print "Checking post # " + this_post_id, # get the post info from postids_live collection, # since if the post was retired we wouldn't have any of that info anymore this_post_new = weibo_module.get_most_recent_live_post( this_post_id) this_post_old = weibo_module.get_oldest_post(this_post_id) print "alive: new/old repost count (", this_post_new[ "post_repost_count"], " / ", this_post_old[ "post_repost_count"], ") "
# pseudocode # does it exist? NO --- it was deleted! turn the flag on, log in checklog # does it exist? YES! -- too old? NO: log in checklog # does it exist? YES! -- too old? YES: turn flag on, log in checklog checkpostcount = 0 for this_post_id in tracking_post_ids: checkpostcount += 1 print "==========================" print "CHECK", checkpostcount, ":: checking post # " + this_post_id thispost_is_alive = True this_post_newest = weibo_module.get_most_recent_live_post(this_post_id) this_post_oldest = weibo_module.get_oldest_post(this_post_id) thispost_created_at = weibo_module.set_timezone_to_china( this_post_newest['post_created_at']) elapsedtime = nowdatetime - thispost_created_at # print "now is = " , nowdatetime # print "newest sez created at = " , this_post_newest["post_created_at"] # print "oldt commitest sez created at = " , this_post_oldest["post_created_at"] print "* time elapsed = ", elapsedtime, " and in seconds", weibo_module.total_seconds( elapsedtime) # so - we look for the post # if we have an error, assemble a skeletal post consisting of post id, is_deleted, error message, error code, checekd_at, and then put it in checklog. # whic means that we should check first for the existenc of an error # refreshpost will give us back the error, otherwise returns a dict
tracking_post_ids = weibo_module.get_tracking_postids() num_currently_tracking = len(tracking_post_ids) num_posts_to_track = weibo_module.num_posts_to_track() num_trackmore = num_posts_to_track - num_currently_tracking nowdatetime = weibo_module.get_current_chinatime() print "The DATE/TIME IS ", nowdatetime # if we're tracking more than we need, exit. if num_trackmore <= 0: print "Currently tracking all " + str(num_currently_tracking) + " posts:" print "After all, we can only track a max of " + str(weibo_module.num_posts_to_track()) + " posts" counter = 1 for thispostid in tracking_post_ids: thispost = weibo_module.get_most_recent_live_post(thispostid) print "post #", counter, ":" + thispost["post_id"] + ", started tracking at", thispost["started_tracking_at"] print "was created at ", thispost["post_created_at"] counter += 1 sys.exit(0) # sys.exit("Currently tracking all " + str(num_currently_tracking) + " posts.") print "Currently tracking " + str(num_currently_tracking) + " posts" print "Attempting to find " + str(num_trackmore) + " more posts to track" print " -- for a total of " + str(num_posts_to_track) + " tracked posts" print weibo_module.post_alert() ########################################## ## GET DATA ##########################################
tracking_post_ids = weibo_module.get_tracking_postids() num_currently_tracking = len(tracking_post_ids) num_posts_to_track = weibo_module.num_posts_to_track() num_trackmore = num_posts_to_track - num_currently_tracking nowdatetime = weibo_module.get_current_chinatime() print "The DATE/TIME IS " , nowdatetime # if we're tracking more than we need, exit. if (num_trackmore <= 0): print "Currently tracking all " + str(num_currently_tracking) + " posts:" print "After all, we can only track a max of " + str(weibo_module.num_posts_to_track()) + " posts" counter = 1 for thispostid in tracking_post_ids: thispost = weibo_module.get_most_recent_live_post(thispostid) print "post #" , counter ,":" + thispost["post_id"] + ", started tracking at" , thispost["started_tracking_at"] print "was created at " , thispost["post_created_at"] counter += 1 sys.exit(0) # sys.exit("Currently tracking all " + str(num_currently_tracking) + " posts.") print "Currently tracking " + str(num_currently_tracking) + " posts" print "Attempting to find " + str(num_trackmore) + " more posts to track" print " -- for a total of " + str(num_posts_to_track) + " tracked posts" print weibo_module.post_alert() ########################################## ## GET DATA ##########################################
# pseudocode # does it exist? NO --- it was deleted! turn the flag on, log in checklog # does it exist? YES! -- too old? NO: log in checklog # does it exist? YES! -- too old? YES: turn flag on, log in checklog checkpostcount = 0 for this_post_id in tracking_post_ids: checkpostcount += 1 print "==========================" print "CHECK", checkpostcount, ":: checking post # " + this_post_id thispost_is_alive = True this_post_newest = weibo_module.get_most_recent_live_post(this_post_id) this_post_oldest = weibo_module.get_oldest_post(this_post_id) thispost_created_at = weibo_module.set_timezone_to_china(this_post_newest["post_created_at"]) elapsedtime = nowdatetime - thispost_created_at # print "now is = " , nowdatetime # print "newest sez created at = " , this_post_newest["post_created_at"] # print "oldt commitest sez created at = " , this_post_oldest["post_created_at"] print "* time elapsed = ", elapsedtime, " and in seconds", weibo_module.total_seconds(elapsedtime) # so - we look for the post # if we have an error, assemble a skeletal post consisting of post id, is_deleted, error message, error code, checekd_at, and then put it in checklog. # whic means that we should check first for the existenc of an error # refreshpost will give us back the error, otherwise returns a dict try: