当前位置: 首页>>代码示例>>Python>>正文


Python util.get_workspace_dir函数代码示例

本文整理汇总了Python中mod.util.get_workspace_dir函数的典型用法代码示例。如果您正苦于以下问题:Python get_workspace_dir函数的具体用法?Python get_workspace_dir怎么用?Python get_workspace_dir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_workspace_dir函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: deploy_webpage

def deploy_webpage(fips_dir, proj_dir, webpage_dir) :
    """builds the final webpage under under fips-deploy/oryol-webpage"""
    ws_dir = util.get_workspace_dir(fips_dir)
    deploy_dir = '{}/fips-deploy/yakc/yakc-emsc-make-release/'.format(ws_dir)

    # webpage files
    copy_tree(proj_dir+'/web/_site', webpage_dir)

    # copy the application files
    for name in ['yakcapp.js'] :
        log.info('> copy file: {}'.format(name))
        shutil.copy(deploy_dir + name, webpage_dir + '/' + name)

    # copy kcc and tap files
    for fname in glob.glob(proj_dir + '/files/*') :
        log.info('> copy file: {}'.format(fname))
        shutil.copy(fname, webpage_dir + '/' + os.path.basename(fname))

    # if the virtualkc directory exists, copy everything there
    # so that a simple git push is enough to upload
    # the webpage
    vkc_dir = '{}/virtualkc'.format(ws_dir)
    if os.path.isdir(vkc_dir) :
        log.info(">>> updating virtualkc repository")
        copy_tree(webpage_dir, vkc_dir)
开发者ID:RobertoMalatesta,项目名称:yakc,代码行数:25,代码来源:web.py

示例2: _rec_update_imports

def _rec_update_imports(fips_dir, proj_dir, handled) :
    """same as _rec_fetch_imports() but for updating the imported projects
    """
    ws_dir = util.get_workspace_dir(fips_dir)
    proj_name = util.get_project_name_from_dir(proj_dir)
    if proj_name not in handled :
        handled.append(proj_name)
        imports = get_imports(fips_dir, proj_dir)
        for dep in imports:
            dep_proj_name = dep
            if dep not in handled:
                dep_proj_dir = util.get_project_dir(fips_dir, dep_proj_name)
                log.colored(log.YELLOW, "=== dependency: '{}':".format(dep_proj_name))
                dep_ok = False
                if os.path.isdir(dep_proj_dir) :
                    # directory did not exist, do a fresh git clone
                    dep = imports[dep_proj_name]
                    git_commit = None if 'rev' not in dep else dep['rev']
                    if git.has_local_changes(dep_proj_dir) :
                        log.warn("  '{}' has local changes, skipping...".format(dep_proj_dir))
                    else :
                        log.colored(log.BLUE, "  updating '{}'...".format(dep_proj_dir))
                        git.update(dep_proj_dir)
                        if git_commit:
                            log.colored(log.YELLOW, "=== revision: '{}':".format(git_commit))
                            dep_ok = git.checkout(dep_proj_dir, git_commit)
                        else:
                            dep_ok = True
                else :
                    log.warn("  '{}' does not exist, please run 'fips fetch'".format(dep_proj_dir))
                # recuse
                if dep_ok :
                    handled = _rec_update_imports(fips_dir, dep_proj_dir, handled)
    # done, return the new handled array
    return handled
开发者ID:floooh,项目名称:fips,代码行数:35,代码来源:dep.py

示例3: serve_webpage

def serve_webpage(fips_dir, proj_dir) :
    ws_dir = util.get_workspace_dir(fips_dir)
    webpage_dir = '{}/fips-deploy/oryol-webpage'.format(ws_dir)
    p = util.get_host_platform()
    if p == 'osx' :
        try :
            subprocess.call(
                'open http://localhost:8000 ; python {}/mod/httpserver.py'.format(fips_dir),
                cwd = webpage_dir, shell=True)
        except KeyboardInterrupt :
            pass
    elif p == 'win':
        try:
            subprocess.call(
                'cmd /c start http://localhost:8000 && python {}/mod/httpserver.py'.format(fips_dir),
                cwd = webpage_dir, shell=True)
        except KeyboardInterrupt:
            pass
    elif p == 'linux':
        try:
            subprocess.call(
                'xdg-open http://localhost:8000; python {}/mod/httpserver.py'.format(fips_dir),
                cwd = webpage_dir, shell=True)
        except KeyboardInterrupt:
            pass
开发者ID:UIKit0,项目名称:oryol,代码行数:25,代码来源:webpage.py

示例4: build_deploy_webpage

def build_deploy_webpage(fips_dir, proj_dir) :
    # if webpage dir exists, clear it first
    ws_dir = util.get_workspace_dir(fips_dir)
    webpage_dir = '{}/fips-deploy/oryol-webpage'.format(ws_dir)
    if os.path.isdir(webpage_dir) :
        shutil.rmtree(webpage_dir)
    os.makedirs(webpage_dir)

    # compile emscripten, pnacl and android samples
    if BuildEmscripten and emscripten.check_exists(fips_dir) :
        project.gen(fips_dir, proj_dir, 'emsc-ninja-release')
        project.build(fips_dir, proj_dir, 'emsc-ninja-release')
    if BuildWasm and emscripten.check_exists(fips_dir) :
        project.gen(fips_dir, proj_dir, 'wasm-ninja-release')
        project.build(fips_dir, proj_dir, 'wasm-ninja-release')
    if BuildPNaCl and nacl.check_exists(fips_dir) :
        project.gen(fips_dir, proj_dir, 'pnacl-ninja-release')
        project.build(fips_dir, proj_dir, 'pnacl-ninja-release')
    
    # export sample assets
    export_assets(fips_dir, proj_dir, webpage_dir)

    # deploy the webpage
    deploy_webpage(fips_dir, proj_dir, webpage_dir)

    log.colored(log.GREEN, 'Generated Samples web page under {}.'.format(webpage_dir))
开发者ID:UIKit0,项目名称:oryol,代码行数:26,代码来源:webpage.py

示例5: copy_build_files

def copy_build_files(fips_dir, proj_dir, webpage_dir) :
    # copy all files from the deploy dir to the webpage_dir
    ws_dir = util.get_workspace_dir(fips_dir)
    src_dir = '{}/fips-deploy/oryol-samples/wasmasmjs-make-release'.format(ws_dir)
    dst_dir = webpage_dir
    copy_tree(src_dir, dst_dir)
    shutil.copy('{}/web/wasmsuite-readme.md'.format(proj_dir), '{}/README.md'.format(dst_dir))
    shutil.copy('{}/LICENSE'.format(proj_dir), '{}/LICENSE'.format(dst_dir))
开发者ID:floooh,项目名称:oryol-samples,代码行数:8,代码来源:wasmtest.py

示例6: _rec_get_all_imports_exports

def _rec_get_all_imports_exports(fips_dir, proj_dir, result) :
    """recursively get all imported projects, their exported and
    imported modules in a dictionary object:
        
        project-1:
            url:    git-url (not valid for first, top-level project)
            exports:
                header-dirs: [ ]
                lib-dirs: [ ]
                defines: 
                    def-key: def-val
                    ...
                modules :
                    mod: dir
                    mod: dir
                ...
            imports:
                name:
                    git:    [git-url]
                    branch: [optional: branch or tag]
                    cond:   [optional: cmake-if condition string conditionally including the dependency]
                name:
                    ...
                ...
        ...

    :param fips_dir:    absolute fips directory
    :param proj_dir:    absolute project directory
    :param result:      in/out current result
    :returns:           bool success, and modified result dictionary
    """
    success = True
    ws_dir = util.get_workspace_dir(fips_dir)
    proj_name = util.get_project_name_from_dir(proj_dir)
    if proj_name not in result :
        imports = get_imports(fips_dir, proj_dir)
        exports = get_exports(proj_dir)
        for dep_proj_name in imports :
            if dep_proj_name not in result :
                dep_proj_dir = util.get_project_dir(fips_dir, dep_proj_name)
                dep_url = imports[dep_proj_name]['git']
                success, result = _rec_get_all_imports_exports(fips_dir, dep_proj_dir, result)
                # break recursion on error
                if not success :
                    return success, result

        result[proj_name] = {}
        result[proj_name]['proj_dir'] = proj_dir
        result[proj_name]['imports'] = imports 
        result[proj_name]['exports'] = exports 

    # done
    return success, result
开发者ID:floooh,项目名称:fips,代码行数:53,代码来源:dep.py

示例7: view

def view(fips_dir, proj_dir):
    proj_name = util.get_project_name_from_dir(proj_dir)
    out_dir = util.get_workspace_dir(fips_dir)+'/fips-deploy/'+proj_name+'-markdeep'
    if os.path.isfile(out_dir+'/index.html'):
        p = util.get_host_platform()
        if p == 'osx':
            subprocess.call('open index.html', cwd=out_dir, shell=True)
        elif p == 'win':
            subprocess.call('start index.html', cwd=out_dir, shell=True)
        elif p == 'linux':
            subprocess.call('xdg-open index.html', cwd=out_dir, shell=True)
    else:
        log.error('no generated index.html found: {}'.format(out_dir+'/index.html'))
开发者ID:floooh,项目名称:fips,代码行数:13,代码来源:markdeep.py

示例8: _rec_fetch_imports

def _rec_fetch_imports(fips_dir, proj_dir, handled) :
    """internal recursive function to fetch project imports,
    keeps an array of already handled dirs to break cyclic dependencies

    :param proj_dir:    current project directory
    :param handled:     array of already handled dirs
    :returns:           updated array of handled dirs
    """
    ws_dir = util.get_workspace_dir(fips_dir)
    proj_name = util.get_project_name_from_dir(proj_dir)
    if proj_name not in handled :
        handled.append(proj_name)

        imports = get_imports(fips_dir, proj_dir)
        for dep in imports:
            dep_proj_name = dep
            if dep not in handled:
                dep_proj_dir = util.get_project_dir(fips_dir, dep_proj_name)
                log.colored(log.YELLOW, "=== dependency: '{}':".format(dep_proj_name))
                dep_ok = False
                if not os.path.isdir(dep_proj_dir) :
                    # directory did not exist, do a fresh git clone
                    dep = imports[dep_proj_name]
                    git_commit = None if 'rev' not in dep else dep['rev']
                    if git_commit :
                        if 'depth' in dep :
                            # when using rev, we may not want depth because the revision may not be reachable
                            log.colored(log.YELLOW, "=== 'depth' was ignored because parameter 'rev' is specified.")
                        dep['depth'] = None
                    git_depth = git.clone_depth if not git_commit and 'depth' not in dep else dep['depth']
                    git_url = dep['git']
                    git_branch = dep['branch']
                    if git.clone(git_url, git_branch, git_depth, dep_proj_name, ws_dir) :
                        if git_commit :
                            log.colored(log.YELLOW, "=== revision: '{}':".format(git_commit))
                            dep_ok = git.checkout(dep_proj_dir, git_commit)
                        else :
                            dep_ok = True
                    else :
                        log.error('failed to git clone {} into {}'.format(git_url, dep_proj_dir))
                else :
                    # directory already exists
                    log.info("dir '{}' exists".format(dep_proj_dir))
                    dep_ok = True

                # recuse
                if dep_ok :
                    handled = _rec_fetch_imports(fips_dir, dep_proj_dir, handled)

    # done, return the new handled array
    return handled
开发者ID:XoDeR,项目名称:Amstel,代码行数:51,代码来源:dep.py

示例9: build_deploy_webpage

def build_deploy_webpage(fips_dir, proj_dir) :
    # if webpage dir exists, clear it first
    ws_dir = util.get_workspace_dir(fips_dir)
    webpage_dir = '{}/fips-deploy/oryol-wasm-buildsuite'.format(ws_dir)
    if not os.path.exists(webpage_dir) :
        os.makedirs(webpage_dir)
    config = 'wasmasmjs-make-release'
    project.clean(fips_dir, proj_dir, config) 
    project.gen(fips_dir, proj_dir, config)
    for target in Samples :
        project.build(fips_dir, proj_dir, config, target)
    
    copy_build_files(fips_dir, proj_dir, webpage_dir)
    if ExportAssets :
        export_assets(fips_dir, proj_dir, webpage_dir)

    log.colored(log.GREEN, 'Done. ({})'.format(webpage_dir))
开发者ID:floooh,项目名称:oryol-samples,代码行数:17,代码来源:wasmtest.py

示例10: build_deploy_webpage

def build_deploy_webpage(fips_dir, proj_dir) :
    # if webpage dir exists, clear it first
    ws_dir = util.get_workspace_dir(fips_dir)
    webpage_dir = '{}/fips-deploy/yakc-webpage/virtualkc'.format(ws_dir)
    if os.path.isdir(webpage_dir) :
        shutil.rmtree(webpage_dir)
    os.makedirs(webpage_dir)

    # compile emscripten, pnacl and android samples
    if emscripten.check_exists(fips_dir) :
        project.gen(fips_dir, proj_dir, 'yakc-emsc-make-release')
        project.build(fips_dir, proj_dir, 'yakc-emsc-make-release')
   
    # build the webpage via jekyll
    subprocess.call('jekyll build', cwd=proj_dir+'/web', shell=True)

    # deploy the webpage
    deploy_webpage(fips_dir, proj_dir, webpage_dir)

    log.colored(log.GREEN, 'Generated web page under {}.'.format(webpage_dir))
开发者ID:RobertoMalatesta,项目名称:yakc,代码行数:20,代码来源:web.py

示例11: build_deploy_webpage

def build_deploy_webpage(fips_dir, proj_dir) :
    # if webpage dir exists, clear it first
    ws_dir = util.get_workspace_dir(fips_dir)
    webpage_dir = '{}/fips-deploy/oryol-samples-webpage'.format(ws_dir)
    if os.path.isdir(webpage_dir) :
        shutil.rmtree(webpage_dir)
    os.makedirs(webpage_dir)

    if emscripten.check_exists(fips_dir) :
        project.gen(fips_dir, proj_dir, BuildConfig)
        project.build(fips_dir, proj_dir, BuildConfig)
    
    # export sample assets
    if ExportAssets :
        export_assets(fips_dir, proj_dir, webpage_dir)

    # deploy the webpage
    deploy_webpage(fips_dir, proj_dir, webpage_dir)

    log.colored(log.GREEN, 'Generated Samples web page under {}.'.format(webpage_dir))
开发者ID:floooh,项目名称:oryol-samples,代码行数:20,代码来源:webpage.py

示例12: init

def init(fips_dir, proj_name) :
    """initialize an existing project directory as a fips directory by
    copying essential files and creating or updating .gitignore

    :param fips_dir:    absolute path to fips
    :param proj_name:   project directory name (dir must exist)
    :returns:           True if the project was successfully initialized
    """
    ws_dir = util.get_workspace_dir(fips_dir)
    proj_dir = util.get_project_dir(fips_dir, proj_name)
    if os.path.isdir(proj_dir) :
        templ_values = {
            'project': proj_name
        }
        for f in ['CMakeLists.txt', 'fips', 'fips.cmd', 'fips.yml'] :
            template.copy_template_file(fips_dir, proj_dir, f, templ_values)
        os.chmod(proj_dir + '/fips', 0o744)
        gitignore_entries = ['.fips-*', '*.pyc']
        template.write_git_ignore(proj_dir, gitignore_entries)
    else :
        log.error("project dir '{}' does not exist".format(proj_dir))
        return False
开发者ID:RobertoMalatesta,项目名称:fips,代码行数:22,代码来源:project.py

示例13: _rec_fetch_imports

def _rec_fetch_imports(fips_dir, proj_dir, handled) :
    """internal recursive function to fetch project imports,
    keeps an array of already handled dirs to break cyclic dependencies

    :param proj_dir:    current project directory
    :param handled:     array of already handled dirs
    :returns:           updated array of handled dirs
    """
    ws_dir = util.get_workspace_dir(fips_dir)
    proj_name = util.get_project_name_from_dir(proj_dir)
    if proj_name not in handled :
        handled.append(proj_name)

        imports = get_imports(fips_dir, proj_dir)
        for dep in imports:
            dep_proj_name = dep
            if dep not in handled:
                dep_proj_dir = util.get_project_dir(fips_dir, dep_proj_name)
                log.colored(log.YELLOW, "=== dependency: '{}':".format(dep_proj_name))
                dep_ok = False
                if not os.path.isdir(dep_proj_dir) :
                    # directory did not exist, do a fresh git clone
                    git_url = imports[dep_proj_name]['git']
                    git_branch = imports[dep_proj_name]['branch']
                    if git.clone(git_url, git_branch, dep_proj_name, ws_dir) :
                        dep_ok = True
                    else :
                        log.error('failed to git clone {} into {}'.format(git_url, dep_proj_dir))
                else :
                    # directory already exists
                    log.info("dir '{}' exists".format(dep_proj_dir))
                    dep_ok = True

                # recuse
                if dep_ok :
                    handled = _rec_fetch_imports(fips_dir, dep_proj_dir, handled)

    # done, return the new handled array
    return handled
开发者ID:RobertoMalatesta,项目名称:fips,代码行数:39,代码来源:dep.py

示例14: clone

def clone(fips_dir, url) :
    """clone an existing fips project with git, do NOT fetch dependencies

    :param fips_dir:    absolute path to fips
    :param url:         git url to clone from (may contain branch name separated by '#')
    :return:            True if project was successfully cloned
    """
    ws_dir = util.get_workspace_dir(fips_dir)
    proj_name = util.get_project_name_from_url(url)
    proj_dir = util.get_project_dir(fips_dir, proj_name)
    if not os.path.isdir(proj_dir) :
        git_url = util.get_giturl_from_url(url)
        git_branch = util.get_gitbranch_from_url(url)
        if git.clone(git_url, git_branch, proj_name, ws_dir) :
            # fetch imports
            dep.fetch_imports(fips_dir, proj_dir)
            return True
        else :
            log.error("failed to 'git clone {}' into '{}'".format(url, proj_dir))
            return False
    else :
        log.error("project dir '{}' already exists".format(proj_dir))
        return False
开发者ID:RobertoMalatesta,项目名称:fips,代码行数:23,代码来源:project.py

示例15: deploy_webpage

def deploy_webpage(fips_dir, proj_dir, webpage_dir) :
    """builds the final webpage under under fips-deploy/voxel-test-webpage"""
    ws_dir = util.get_workspace_dir(fips_dir)

    # copy other required files
    for name in ['style.css', 'emsc.js', 'favicon.png'] :
        log.info('> copy file: {}'.format(name))
        shutil.copy(proj_dir + '/web/' + name, webpage_dir + '/' + name)

    # generate emscripten HTML page
    if emscripten.check_exists(fips_dir) :
        emsc_deploy_dir = '{}/fips-deploy/voxel-test/emsc-ninja-release'.format(ws_dir)
        name = 'VoxelTest'
        log.info('> generate emscripten HTML page: {}'.format(name))
        for ext in ['js', 'html.mem'] :
            src_path = '{}/{}.{}'.format(emsc_deploy_dir, name, ext)
            if os.path.isfile(src_path) :
                shutil.copy(src_path, webpage_dir)
        with open(proj_dir + '/web/emsc.html', 'r') as f :
            templ = Template(f.read())
        html = templ.safe_substitute(name=name)
        with open('{}/index.html'.format(webpage_dir), 'w') as f :
            f.write(html)
开发者ID:floooh,项目名称:voxel-test,代码行数:23,代码来源:web.py


注:本文中的mod.util.get_workspace_dir函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。