def fetch_weibo_timeline(username): print "[%s]: single started" %formatDatetime(datetime.now()) access_token = Settings.settings().weibo_access_token if access_token: member = Member.getMemberByUsername(username) if member: if member.port == "weibo": content = weibo_api_request(weibo_user_timeline_url, "GET", access_token, uid=member.oauth_id) if content: save_weibo_content(member, content) print "[%s]: single finished" %formatDatetime(datetime.now())
def fetch_weibo_timelines(): print "[%s]: schedule tasks started" %formatDatetime(datetime.now()) access_token = Settings.settings().weibo_access_token if access_token: members = Member.get_enabled_tasks() for member in members: if member.port == "weibo": content = weibo_api_request(weibo_user_timeline_url, "GET", access_token, uid=member.oauth_id) if content: save_weibo_content(member, content) print "[%s]: schedule tasks finished" %formatDatetime(datetime.now())
def main(): """start engine""" define("port", default=9999, help="Server port", type=int) define("conf", default="app.conf", help="Config file path", type=str) define("status", default="dev", help="Server status use dev or live", type=str) tornado.options.parse_command_line() if os.path.exists(options.conf): print 'Loading', options.conf else: exit("No config file at %s" %options.conf) configs = get_config(options.conf) opts = getattr(configs, options.status) connect(opts.db_name, host=opts.db_host, username=opts.db_username, password=opts.db_password) profiles = Settings.settings() http_server = httpserver.HTTPServer(Engine(opts, profiles)) http_server.listen(options.port) tornado.locale.load_translations(os.path.join(os.path.dirname(__file__), "core/trans")) ioloop.IOLoop.instance().start()
def update_profiles(self): self.settings["profiles"] = Settings.settings()