Exemple #1
0
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
# 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:
        refreshedpost = weibo_module.refreshpost(this_post_id)
# 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:
        refreshedpost = weibo_module.refreshpost(this_post_id)
    except: