예제 #1
0
파일: test.py 프로젝트: ajiexw/zarkpy
def emptyTestFileDir():
    for k in TEST_PATH:
        v = sh.config[k]
        assert v.endswith('-testing/'), u'你使用正式文件数据来测试?'
        sh.autoMkdir(v)
        # 递归删除v中的所有文件,但保留空文件夹,以免下次测试时再创建
        os.system('find "%s" -type f | xargs rm -rf' % v)
예제 #2
0
파일: test.py 프로젝트: shaqhuang/zarkpy
def emptyTestFileDir():
    for k in TEST_PATH:
        v = sh.config[k]
        assert v.endswith('-testing/'), u'你使用正式文件数据来测试?'
        sh.autoMkdir(v)
        # 递归删除v中的所有文件,但保留空文件夹,以免下次测试时再创建
        os.system('find "%s" -type f | xargs rm -rf' % v)
예제 #3
0
파일: app.py 프로젝트: duoduo369/zarkpy
def initRender():
    import datetime
    from tool import subpage_data
    # 模版文件中可以直接访问的变量
    temp_func = {
        'eval':         eval,
        'str':          str,
        'int':          int,
        'len':          len,
        'type':         type,
        'map':          map,
        'all':          all,
        'any':          any,
        'hasattr':      hasattr,
        'getattr':      getattr,
        'input':        web.input,
        'sh':           sh,
        'datetime':     datetime.datetime,
        'subpage_data': subpage_data,
    }

    render = web.template.render

    subpage_path = sh.config.APP_ROOT_PATH + 'web/cgi/subpage'
    sh.autoMkdir(subpage_path)
    temp_func['subpage'] = render(loc=subpage_path, globals=temp_func)
    # 为了能在subpage中使用subpage, 所以这里又render了一次
    temp_func['subpage'] = render(loc=subpage_path, globals=temp_func)
    sh.subpage = temp_func['subpage']

    page_render_path = sh.config.APP_ROOT_PATH + 'web/cgi/page'
    sh.autoMkdir(page_render_path)
    sh.page = render(loc=page_render_path, base='Base', globals=temp_func)
    sh.page_nobase = render(loc=page_render_path, globals=temp_func)

    editor_render_path = sh.config.APP_ROOT_PATH + 'web/cgi/editor'
    sh.autoMkdir(editor_render_path)
    sh.editor = render(loc=editor_render_path, base='Base', globals=temp_func)
    sh.editor_nobase = render(loc=editor_render_path, globals=temp_func)
예제 #4
0
def initRender():
    import datetime
    from tool import subpage_data
    # 模版文件中可以直接访问的变量
    temp_func = {
        'str': str,
        'int': int,
        'len': len,
        'type': type,
        'map': map,
        'all': all,
        'any': any,
        'hasattr': hasattr,
        'getattr': getattr,
        'input': web.input,
        'sh': sh,
        'datetime': datetime.datetime,
        'subpage_data': subpage_data,
    }

    render = web.template.render

    subpage_path = sh.config.APP_ROOT_PATH + 'web/cgi/subpage'
    sh.autoMkdir(subpage_path)
    temp_func['subpage'] = render(loc=subpage_path, globals=temp_func)
    # 为了能在subpage中使用subpage, 所以这里又render了一次
    temp_func['subpage'] = render(loc=subpage_path, globals=temp_func)
    sh.subpage = temp_func['subpage']

    page_render_path = sh.config.APP_ROOT_PATH + 'web/cgi/page'
    sh.autoMkdir(page_render_path)
    sh.page = render(loc=page_render_path, base='Base', globals=temp_func)
    sh.page_nobase = render(loc=page_render_path, globals=temp_func)

    editor_render_path = sh.config.APP_ROOT_PATH + 'web/cgi/editor'
    sh.autoMkdir(editor_render_path)
    sh.editor = render(loc=editor_render_path, base='Base', globals=temp_func)
    sh.editor_nobase = render(loc=editor_render_path, globals=temp_func)
예제 #5
0
파일: app.py 프로젝트: alliadt/zarkpy
sh.session = web.session.Session(app, web.session.DiskStore(sh.config.SESSION_PATH), initializer={})

# 模版文件中可以直接访问的变量
template_enabled = {
    'str':          str,
    'int':          int,
    'len':          len,
    'type':         type,
    'dir':          dir,
    'map':          map,
    'hasattr':      hasattr,
    'getattr':      getattr,
    'web_ctx':      web.ctx,
    'input':        web.input,
    'sh':           sh,
    'session':      sh.session,
    'config':       sh.config,
    'ipToStr':      sh.ipToStr,
    'getUrlParams': sh.getUrlParams,
    'datetime':     datetime.datetime,
}

page_render_path = sh.config.APP_ROOT_PATH + 'web/cgi/page'
sh.autoMkdir(page_render_path)
sh.page_render = web.template.render(loc=page_render_path, base='Base', globals=template_enabled)
sh.page_render_nobase = web.template.render(loc=page_render_path, globals=template_enabled)

if __name__ == "__main__":
    app.run()
예제 #6
0
파일: app.py 프로젝트: yanwen/zarkpy
# 模版文件中可以直接访问的变量
template_enabled = {
    'str': str,
    'int': int,
    'len': len,
    'type': type,
    'dir': dir,
    'map': map,
    'hasattr': hasattr,
    'getattr': getattr,
    'web_ctx': web.ctx,
    'input': web.input,
    'sh': sh,
    'session': sh.session,
    'config': sh.config,
    'ipToStr': sh.ipToStr,
    'getUrlParams': sh.getUrlParams,
    'datetime': datetime.datetime,
}

page_render_path = sh.config.APP_ROOT_PATH + 'web/cgi/page'
sh.autoMkdir(page_render_path)
sh.page_render = web.template.render(loc=page_render_path,
                                     base='Base',
                                     globals=template_enabled)
sh.page_render_nobase = web.template.render(loc=page_render_path,
                                            globals=template_enabled)

if __name__ == "__main__":
    app.run()
예제 #7
0
파일: Image.py 프로젝트: ajiexw/note
 def _saveImage(self, file_path, image_value):
     sh.autoMkdir(file_path)
     assert(not os.path.exists(file_path))
     with open(file_path, 'w') as f:
         f.write(image_value)
예제 #8
0
 def _saveImage(self, file_path, image_value):
     sh.autoMkdir(file_path)
     assert not os.path.exists(file_path), file_path
     with open(file_path, 'w') as f:
         f.write(image_value)