except: #hmm. can't even check status. weird. print "okay weird error" traceback.print_exc(file=sys.stdout) continue #set post checked_at time refreshedpost["checked_at"] = nowdatetime # print "* refrehsedpost = " ,refreshedpost if ("error_code" in refreshedpost): #the post has been DELETED #let's flag, add to checklog print " >> POST DELETED: " + refreshedpost["error_message"] weibo_module.checklog_insert(refreshedpost) else: #post EXISTS print "* post alive: new/old repost count (" + str( refreshedpost["post_repost_count"]) + " / " + str( this_post_oldest["post_repost_count"]) + ") " # print "* elapsed time = " , weibo_module.total_seconds(elapsedtime) # print "* our timeout is = " , weibo_module.track_posts_timeout # print "* so has more time passed? " , (weibo_module.total_seconds(elapsedtime) > weibo_module.track_posts_timeout) if (weibo_module.total_seconds(elapsedtime) > weibo_settings.track_posts_timeout):
imgpath = weibo_settings.imgdir + str(thispost["post_id"])+ splitext(thispost["post_original_pic"])[1] print "Storing postID -- tracking post #" , (num_currently_tracking + newpostcount) print "Storing postID " + str(thispost["post_id"] + " image to file") #DOWNLOAD IMAGE """ req = urllib2.Request(thispost["post_original_pic"]) response = urllib2.urlopen(req) output = open(l'wb') output.write(response.read()) output.close()""" urlretrieve(thispost["post_original_pic"], imgpath) print "Storing postID " + str(thispost["post_id"] + " to database") weibo_module.checklog_insert(thispost) else: print "post " + str(thispost["post_id"]) + " already exists" if (loop == False): break statuspage += 1 print str(newpostcount) + " posts added, for a total of " + str(num_currently_tracking + newpostcount) + " posts"
if weibo_module.postexists(thispost["post_id"]) == False: # POST IS NEW - let's save it newpostcount += 1 imgpath = weibo_settings.imgdir + str(thispost["post_id"]) + splitext(thispost["post_original_pic"])[1] print "Storing postID -- tracking post #", (num_currently_tracking + newpostcount) print "Storing postID " + str(thispost["post_id"] + " image to file") # DOWNLOAD IMAGE """ req = urllib2.Request(thispost["post_original_pic"]) response = urllib2.urlopen(req) output = open(l'wb') output.write(response.read()) output.close()""" urlretrieve(thispost["post_original_pic"], imgpath) print "Storing postID " + str(thispost["post_id"] + " to database") weibo_module.checklog_insert(thispost) else: print "post " + str(thispost["post_id"]) + " already exists" if loop == False: break statuspage += 1 print str(newpostcount) + " posts added, for a total of " + str(num_currently_tracking + newpostcount) + " posts"
except: # hmm. can't even check status. weird. print "okay weird error" traceback.print_exc(file=sys.stdout) continue # set post checked_at time refreshedpost["checked_at"] = nowdatetime # print "* refrehsedpost = " ,refreshedpost if "error_code" in refreshedpost: # the post has been DELETED # let's flag, add to checklog print " >> POST DELETED: " + refreshedpost["error_message"] weibo_module.checklog_insert(refreshedpost) else: # post EXISTS print "* post alive: new/old repost count (" + str(refreshedpost["post_repost_count"]) + " / " + str( this_post_oldest["post_repost_count"] ) + ") " # print "* elapsed time = " , weibo_module.total_seconds(elapsedtime) # print "* our timeout is = " , weibo_module.track_posts_timeout # print "* so has more time passed? " , (weibo_module.total_seconds(elapsedtime) > weibo_module.track_posts_timeout) if weibo_module.total_seconds(elapsedtime) > weibo_settings.track_posts_timeout: # TOO MUCH TIME HAS PASSED - let's retire this