def gen(): content = request.form['config'] pdef = json.loads(content) pdef['project']['group'] = 'qdingweb' pdef['dbinfo']['host'] = db_host pdef['dbinfo']['port'] = db_port pdef['dbinfo']['username'] = db_user pdef['dbinfo']['password'] = db_passwd manager = Manager() manager.set_pdef(pdef) manager.create_zip() zip_dir(manager.project.targetfolder,os.path.join(manager.project.targetfolder,manager.project.folder_name+".zip")) try: db = DButils() sql = "insert into codeg.gen_log(pdef_content,filename,uuid) values (%s,%s,%s)" db.execute(sql,(content.encode("utf-8"),manager.project.folder_name,manager.project.uuid_name)) finally: db.close_db() return redirect("/list")
def downloader(id): dirname = "" filename = "" try: db = DButils() sql = "select * from codeg.gen_log where id = " + id r = db.fetchone(sql) dirname = os.path.join("target", r[4]) filename = r[3] + ".zip" finally: db.close_db() print dirname, filename return send_from_directory(dirname, filename, as_attachment=True)
def downloader(id): dirname = "" filename = "" try: db = DButils() sql = "select * from codeg.gen_log where id = " + id r = db.fetchone(sql) dirname = os.path.join("target",r[4]) filename = r[3] +".zip" finally: db.close_db() print dirname,filename return send_from_directory(dirname,filename,as_attachment=True)
def list(): field_dict = {} projects = [] try: db = DButils() sql = "select * from codeg.gen_log order by create_at desc limit 20" results = db.fetchmany(sql) for r in results: projects.append({ "id": r[0], "create_at": r[1], "config": r[2], "name": r[3] }) finally: db.close_db() return render_template("list.html", projects=projects)
def gen(): content = request.form['config'] pdef = json.loads(content) pdef['project']['group'] = 'qdingweb-pro' #pdef['dbinfo']['host'] = db_host #pdef['dbinfo']['port'] = db_port #pdef['dbinfo']['username'] = db_user #pdef['dbinfo']['password'] = db_passwd manager = Manager() manager.set_pdef(pdef) manager.create_zip() zip_dir( manager.project.targetfolder, os.path.join(manager.project.targetfolder, manager.project.folder_name + ".zip")) try: db = DButils() sql = "insert into codeg.gen_log(pdef_content,filename,uuid) values (%s,%s,%s)" db.execute(sql, (content.encode("utf-8"), manager.project.folder_name, manager.project.uuid_name)) finally: db.close_db() return redirect("/list")
def list(): field_dict = {} projects = [] try: db = DButils() sql = "select * from codeg.gen_log order by create_at desc limit 20" results = db.fetchmany(sql) for r in results: projects.append( { "id":r[0], "create_at":r[1], "config":r[2], "name":r[3] } ) finally: db.close_db() return render_template("list.html",projects = projects)