change, profit, investor.balance, )) investment.success = profit > 0 investment.profit = profit investment.done = True sess.commit() if top_networth < investor.balance: top_networth = investor.balance logging.info("New Top networth: %d", top_networth) # Measure how long processing took duration = stopwatch.measure() logging.info(" -- processed in %.2fs", duration) # Report the Reddit API call stats rem = int(reddit.auth.limits["remaining"]) res = int(reddit.auth.limits["reset_timestamp"] - time.time()) logging.info(" -- API calls remaining: %s, resetting in %.2fs", rem, res) sess.close() if __name__ == "__main__": utils.keep_up(main)
continue duration = stopwatch.measure() logging.info("New submission: %s", submission) logging.info(" -- retrieved in %ss", duration) c = conn.cursor() c.execute("SELECT * FROM posts WHERE id=?", (submission.id,)) if c.fetchone(): logging.info("Already processed") continue post_telegram(conn, submission, tbot) bot_reply = post_reply(submission) # Measure how long processing took duration = stopwatch.measure() logging.info(" -- processed in %.2fs", duration) # Create Buyable if bot_reply: sess.add( Buyable(post=submission.id, name=submission.author.name, response=bot_reply.id) ) sess.commit() if __name__ == "__main__": keep_up(main)