def restore_cfg(self, cfgFile=None): CfgPath = "/tmp/cfgfile" lcHDRS = {} for key, val in cherrypy.request.headers.iteritems(): lcHDRS[key.lower()] = val formFields = myFieldStorage(fp=cherrypy.request.rfile, headers=lcHDRS, environ={'REQUEST_METHOD':'POST'}, keep_blank_values=True) cfgFile = formFields['cfgFile'] os.link(cfgFile.file.name, CfgPath) ret = xte_administration.importing(CfgPath, str(cherrypy.request.login)) login_name = cherrypy.session.get("LoginName") administration_jcfg = xte_administration.get() for dirPath, dirNames, fileNames in os.walk(controller.acc_online_dir): accName = fileNames tmp = controller.lookup.get_template("administration.mako") self.msg = [] if ret[0]: self.addMsg(_("Restore Configuration successfully")) return tmp.render(administration_args = administration_jcfg[1], acc_list = accName, user_name = login_name, msg_list = self.msg) else: self.addMsg(lang.change_error_msg(ret[1])) return tmp.render(administration_args = administration_jcfg[1], acc_list = accName, user_name = login_name, msg_list = self.msg)
def edit_account(self, name, password, group): ret = xte_administration.change_password(str(name), str(password), str(cherrypy.request.login)) if ret[0] and xte_administration.get()[1][name]["g"] != group: ret = xte_administration.change_group(str(name), str(group), str(cherrypy.request.login)) cherrypy.response.headers['Content-Type'] = 'application/json' return json.dumps(ret)
def firmware_update(self, fwupfile=None): global firmware_updatekey CfgPath = "/tmp/updatefile" lcHDRS = {} for key, val in cherrypy.request.headers.iteritems(): lcHDRS[key.lower()] = val formFields = myFieldStorage(fp=cherrypy.request.rfile, headers=lcHDRS, environ={'REQUEST_METHOD':'POST'}, keep_blank_values=True) fwupfile = formFields['fwupfile'] os.link(fwupfile.file.name, CfgPath) ret = xte_administration.firmware_update(firmware_updatekey, CfgPath) login_name = cherrypy.session.get("LoginName") administration_jcfg = xte_administration.get() for dirPath, dirNames, fileNames in os.walk(controller.acc_online_dir): accName = fileNames tmp = controller.lookup.get_template("administration.mako") self.msg = [] if ret[0]: self.addMsg(_("Firmware update successfully, system rebooting...")) return tmp.render(administration_args = administration_jcfg[1], acc_list = accName, user_name = login_name, msg_list = self.msg) else: self.addMsg(lang.change_error_msg(ret[1])) return tmp.render(administration_args = administration_jcfg[1], acc_list = accName, user_name = login_name, msg_list = self.msg)
def index(self): self.msg = [] try: login_name = cherrypy.session.get("LoginName") administration_jcfg = xte_administration.get() for dirPath, dirNames, fileNames in os.walk(controller.acc_online_dir): accName = fileNames tmp = controller.lookup.get_template("administration.mako") if administration_jcfg[0]: # load successfully return tmp.render(administration_args = administration_jcfg[1], acc_list = accName, user_name = login_name, msg_list = self.msg) else: self.addMsg(str(administration_jcfg[1])) return tmp.render(administration_args = {}, acc_list = accName, user_name = login_name, msg_list = self.msg) return tmp.render() except: exceptions.html_error_template().render()