def main(mode,novel): dbconf = gen_dbconf(mode) #conn = tornado.database.Connection(dbconf['host'],dbconf['db'],user=dbconf['user'],password=dbconf['passwd']) pool = DBPool(host=dbconf['host'],database=dbconf['db'],user=dbconf['user'],password=dbconf['passwd'],min_conn=2,max_conn=3) conn = pool.connect() if not novel: for key in books: if mode == 'pro' and books[key][3] == True: pass else: book_module = book_relative_import(books[key]) book = book_module() path = gen_content_path(mode,book.dir_name) if not os.path.exists(path): os.mkdir(path) os.chdir(path) book.process(conn) else: key = novel if mode == 'pro' and books[key][3] == True: pass else: book_module = book_relative_import(books[key]) book = book_module() path = gen_content_path(mode,book.dir_name) if not os.path.exists(path): os.mkdir(path) os.chdir(path) book.process(conn) conn.close() pool.close()
def __init__(self,mode): handlers = [ ('/',IndexHandler), ('/(\w+)$',MainHandler), ('/([^/]+?)/detail/(\S+)$',DetailHandler) ] settings = dict( template_path=os.path.join(os.path.dirname(__file__), "./template"), static_path=os.path.join(os.path.dirname(__file__), "./static"), debug=True, autoescape=None ) super(Application,self).__init__(handlers,**settings) self.mode = mode dbconf = gen_dbconf(self.mode) self.pool = DBPool(host=dbconf['host'],database=dbconf['db'],user=dbconf['user'],password=dbconf['passwd'],min_conn=4,max_conn=7) self.books = {} self.book_names = {} for key in books: book_module = book_relative_import(books[key]) book = book_module() self.books[key] = book self.book_names[key] = books[key][2] self.bookcontent_cache = KVCache(cap=200)
def __init__(self, mode): handlers = [("/", IndexHandler), ("/(\w+)$", MainHandler), ("/([^/]+?)/detail/(\S+)$", DetailHandler)] settings = dict( template_path=os.path.join(os.path.dirname(__file__), "./template"), static_path=os.path.join(os.path.dirname(__file__), "./static"), debug=True, autoescape=None, ) super(Application, self).__init__(handlers, **settings) self.mode = mode dbconf = gen_dbconf(self.mode) self.pool = DBPool( host=dbconf["host"], database=dbconf["db"], user=dbconf["user"], password=dbconf["passwd"], min_conn=4, max_conn=7, ) self.books = {} self.book_names = {} for key in books: book_module = book_relative_import(books[key]) book = book_module() self.books[key] = book self.book_names[key] = books[key][2] self.bookcontent_cache = KVCache(cap=200)
def main(mode, novel): dbconf = gen_dbconf(mode) #conn = tornado.database.Connection(dbconf['host'],dbconf['db'],user=dbconf['user'],password=dbconf['passwd']) pool = DBPool(host=dbconf['host'], database=dbconf['db'], user=dbconf['user'], password=dbconf['passwd'], min_conn=2, max_conn=3) conn = pool.connect() if not novel: for key in books: if mode == 'pro' and books[key][3] == True: pass else: book_module = book_relative_import(books[key]) book = book_module() path = gen_content_path(mode, book.dir_name) if not os.path.exists(path): os.mkdir(path) os.chdir(path) book.process(conn) else: key = novel if mode == 'pro' and books[key][3] == True: pass else: book_module = book_relative_import(books[key]) book = book_module() path = gen_content_path(mode, book.dir_name) if not os.path.exists(path): os.mkdir(path) os.chdir(path) book.process(conn) conn.close() pool.close()