Пример #1
0
def main():
    """
	Main program 
	"""
    post_count = 0
    last_posted_ids = set([])
    while True:
        sys.stdout.flush()
        try:
            current_post_id = int(get_file_post())
            last_posted_ids.add(current_post_id)
        except ValueError:
            print "Error in .lastpost"
            sys.exit(1)
        last_post = grabber.get_last_post()
        if last_post == None:
            time.sleep(60)
            continue
        if last_post.get("id") in last_posted_ids:
            print "No new posts available"
            time.sleep(60)
            continue
        print "New post found, with id: %d [compared to previous id: %d]" % (last_post.get("id"), current_post_id)
        message = compose_message(last_post)
        result = post_message(message, last_post.get("title"))
        update_file_post(last_post)
        if result:
            print "%d posted successfully" % (last_post.get("id"))
Пример #2
0
def main():
        '''
        Main program
        '''
        post = grabber.get_last_post()
        if post == None:
                print("Error getting last post...")
                sys.exit(1)
	update_file(post)