Example #1
0
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()
Example #2
0
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()