python类ErrorReturnCode_1()的实例源码

recipe.py 文件源码 项目:lbry-android 作者: lbryio 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def build_cython_components(self, arch):
        info('Cythonizing anything necessary in {}'.format(self.name))

        env = self.get_recipe_env(arch)

        if self.ctx.python_recipe.from_crystax:
            command = sh.Command('python{}'.format(self.ctx.python_recipe.version))
            site_packages_dirs = command(
                '-c', 'import site; print("\\n".join(site.getsitepackages()))')
            site_packages_dirs = site_packages_dirs.stdout.decode('utf-8').split('\n')
            if 'PYTHONPATH' in env:
                env['PYTHONPATH'] = env['PYTHONPATH'] + ':{}'.format(':'.join(site_packages_dirs))
            else:
                env['PYTHONPATH'] = ':'.join(site_packages_dirs)

        with current_directory(self.get_build_dir(arch.arch)):
            hostpython = sh.Command(self.ctx.hostpython)
            shprint(hostpython, '-c', 'import sys; print(sys.path)', _env=env)
            print('cwd is', realpath(curdir))
            info('Trying first build of {} to get cython files: this is '
                 'expected to fail'.format(self.name))

            manually_cythonise = False
            try:
                shprint(hostpython, 'setup.py', 'build_ext', '-v', _env=env,
                        *self.setup_extra_args)
            except sh.ErrorReturnCode_1:
                print()
                info('{} first build failed (as expected)'.format(self.name))
                manually_cythonise = True

            if manually_cythonise:
                self.cythonize_build(env=env)
                shprint(hostpython, 'setup.py', 'build_ext', '-v', _env=env,
                        _tail=20, _critical=True, *self.setup_extra_args)
            else:
                info('First build appeared to complete correctly, skipping manual'
                     'cythonising.')

            if 'python2' in self.ctx.recipe_build_order:
                info('Stripping object files')
                build_lib = glob.glob('./build/lib*')
                shprint(sh.find, build_lib[0], '-name', '*.o', '-exec',
                        env['STRIP'], '{}', ';', _env=env)

            if 'python3crystax' in self.ctx.recipe_build_order:
                info('Stripping object files')
                shprint(sh.find, '.', '-iname', '*.so', '-exec',
                        '/usr/bin/echo', '{}', ';', _env=env)
                shprint(sh.find, '.', '-iname', '*.so', '-exec',
                        env['STRIP'].split(' ')[0], '--strip-unneeded',
                        # '/usr/bin/strip', '--strip-unneeded',
                        '{}', ';', _env=env)
repo.py 文件源码 项目:ipbb 作者: ipbus 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def srcstat(env):

    if not env.workPath:
        secho  ( 'ERROR: No ipbb work area detected', fg='red' )
        return

    secho ( "Packages", fg='blue' )
    lSrcs = env.getSources()
    if not lSrcs:
        return

    lSrcTable = Texttable(max_width=0)
    lSrcTable.set_deco(Texttable.HEADER | Texttable.BORDER)
    lSrcTable.set_chars(['-', '|', '+', '-'])
    lSrcTable.header(['name', 'kind', 'version'])
    for lSrc in lSrcs:
        lSrcDir = join(env.src, lSrc)

        lKind, lBranch = "unknown", None

        # Check if a git repository
        if exists(join( lSrcDir, '.git')):
            with DirSentry(lSrcDir) as _:
                lKind = 'git'

                try:
                    # lBranch = sh.git('symbolic-ref','--short', 'HEAD').strip()
                    lBranch = sh.git('symbolic-ref', 'HEAD').split('/')[-1].strip()
                except sh.ErrorReturnCode_128:
                    lBranch = sh.git('rev-parse', '--short', 'HEAD').strip()+'...'

                try:
                    sh.git('diff', '--no-ext-diff', '--quiet').strip()
                except sh.ErrorReturnCode_1:
                    lBranch += '*'

                try:
                    sh.git('diff', '--no-ext-diff', '--cached', '--quiet').strip()
                except sh.ErrorReturnCode_1:
                    lBranch += '+'
        elif exists(join( lSrcDir, '.svn')):
            with DirSentry(lSrcDir) as _:
                lKind = 'svn'

                lSVNInfoRaw = sh.svn('info')

                lSVNInfo = { lEntry[0]:lEntry[1].strip() for lEntry in ( lLine.split(':',1) for lLine in lSVNInfoRaw.split('\n') if lLine )}

                lBranch = lSVNInfo['URL'].replace( lSVNInfo['Repository Root']+'/', '' )

                lSVNStatus = sh.svn('status','-q')
                if len(lSVNStatus):
                    lBranch += '*'

        lSrcTable.add_row([lSrc, lKind, lBranch])
    echo  ( lSrcTable.draw() )

# ------------------------------------------------------------------------------


问题


面经


文章

微信
公众号

扫码关注公众号