Beispiel #1
0
 def post(self,project,filename):
     try:
         self.set_header('Content-Type','application/json')
         installm=installpmodel(self.get_secure_cookie("crtcluster"))
         packegpathm=packagepathmodel(self.get_secure_cookie("crtcluster"))
         showpath=[]
         #read the install project
         chooseinstall=installm.installproject
         packetsp=packegpathm.packagepath
         #upload file
         if filename =="uploadfile":                
             if self.request.files.get('uploadfile',None):
                 uploadpath=packetsp[chooseinstall[-1]][project].split(',')[-1]+'/'+self.request.files['uploadfile'][0]['filename']
                 uploadfile=self.request.files['uploadfile'][0]
                 with open(uploadpath,'w') as f:
                     f.write(uploadfile['body'])
             self.redirect('/CustomConfigure')
         #save the xml file
         else:    
             confpath=packetsp[chooseinstall[-1]][project].split(',')[-1]+'/'+filename.split('?')[0]
             if filename.split('?')[0].split('.')[-1] == 'xml':
                 data=json.loads(self.request.body)
                 con=HadoopConf(confpath)
                 con.setdt2(data) 
             else:
                 with open(confpath,'w') as f:
                     f.write(self.request.body)
             self.set_header("Content-Type","application/text")
             self.set_status(201)
             self.write("保存成功!")
     except Exception ,e:
         logging.error(e)
         self.set_header("Content-Type","application/text")
         self.set_status(500)
         self.write(e)
Beispiel #2
0
 def post(self,filename):
     try:
         paths='static/configure/'+filename.split('?')[0]
         con=HadoopConf(paths)
         con.setdt2(data) 
         self.set_header("Content-Type","application/text")
         self.set_status(201)
         self.write("保存成功!")
     except Exception, e:
         logging.error(e)
         self.set_header("Content-Type","application/text")
         self.set_status(201)
         self.write(e)