def test_fs_partial_content(self): fpath = os.path.join(xconfig.DATA_DIR, "test.txt") xutils.writefile(fpath, "test") response = app.request("/data/test.txt", headers=dict(RANGE="bytes=1-100")) self.assertEqual("206 Partial Content", response.status) self.assertEqual("bytes", response.headers["Accept-Ranges"]) self.assertEqual(True, "Content-Range" in response.headers)
def handle(self, input): self.title = '通过模板创建命令扩展' self.description = '''请输入命令扩展名称''' self.btn_text = '创建' self.rows = 1 self.editable = False if input != '': name = os.path.join(xconfig.COMMANDS_DIR, input) if not name.endswith(".py"): name += ".py" if os.path.exists(name): return u("文件[%s]已经存在!") % u(name) user_name = xauth.get_current_name() code = xconfig.get("NEW_COMMAND_TEMPLATE", DEFAULT_COMMAND_TEMPLATE) code = code.replace("$since", xutils.format_datetime()) code = code.replace("$author", user_name) xutils.writefile(name, code) raise web.seeother('/code/edit?path=%s' % name)
def handle(self, input): self.description = '''请输入插件名称''' self.title = '通过模板创建插件' self.btn_text = '创建' self.rows = 1 if input != '': name = os.path.join(xconfig.PLUGINS_DIR, input) if not name.endswith(".py"): name += ".py" if os.path.exists(name): return u("文件[%s]已经存在!") % u(name) user_name = xauth.get_current_name() code = xconfig.get("NEW_PLUGIN_TEMPLATE", DEFAULT_PLUGIN_TEMPLATE) code = code.replace("$since", xutils.format_datetime()) code = code.replace("$author", user_name) xutils.writefile(name, code) log_plugin_visit(os.path.basename(name)) raise web.seeother('/code/edit?path=%s' % name)
def create_file(self, path): user_name = xauth.current_name() code = self.get_plugin_template() code = code.replace("$since", xutils.format_datetime()) code = code.replace("$author", user_name) xutils.writefile(path, code)
def create_file(self, path): user_name = xauth.current_name() code = xconfig.PLUGIN_TEMPLATE code = code.replace("$since", xutils.format_datetime()) code = code.replace("$author", user_name) xutils.writefile(path, code)