def GenerateCode(self, user, pid, target): connect = MySQLdb.connect(db=config.DB_NAME, host=config.DB_HOST, port=config.DB_PORT, user=config.DB_USER, passwd=config.DB_PASSWD) project = loadProject(connect, user, pid) metamodel = loadMetaModel(connect, user, project['metamodel_id'], check=False) files = TemplateService.tree(project['metamodel_id'], connect) connect.close() for f in files: if f['path'] == target: self.templates[f['name']] = f['content'] self.input = self.input + '/t' + str(metamodel['id']) self.userpath = self.outpath + '/' + user['uname'] self.projectpath = self.userpath + '/p' + str(project['id']) if not os.path.exists(self.userpath): os.mkdir(self.userpath) #clear directory if os.path.exists(self.projectpath): shutil.rmtree(self.projectpath) if not os.path.exists(self.projectpath): os.mkdir(self.projectpath) # self.model = parseJSON(project['xml'], metamodel['xml']) global message message = '' global output_text output_text = '' wbconf = json.loads(metamodel['config']); for t in wbconf['targets']: if t['name'] == target: self.parseXML(t) return output_text
def temp_tree(): if 'user' in session: connect = MySQLdb.connect(db=config.DB_NAME, host=config.DB_HOST, port=config.DB_PORT, user=config.DB_USER, passwd=config.DB_PASSWD) result = TemplateService.tree(request.form['id'], connect) connect.close() # result = FileService.GetFileTree(session['user'], request.form['id']) return json.dumps(result)