• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python sh.cd函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: compile

    def compile( self, source_dir, build_dir, install_dir ):
        package_source_dir = os.path.join( source_dir, self.dirname )
        assert( os.path.exists( package_source_dir ) )
        package_build_dir = os.path.join( build_dir, self.dirname )

        sh.cd( os.path.join( package_source_dir, 'scripts/Resources' ) )
        sh.sh( './copyresources.sh' )
        # the install target doesn't copy the stuff that copyresources.sh puts in place
        sh.cp( '-v', os.path.join( package_source_dir, 'bin/Release/Readme.txt' ), os.path.join( install_dir, 'Readme.meshy.txt' ) )
        sh.cp( '-v', '-r', os.path.join( package_source_dir, 'bin/Release_Linux/Resources/' ), install_dir )

        sh.mkdir( '-p', package_build_dir )
        sh.cd( package_build_dir )
        if ( platform.system() == 'Darwin' ):
            sh.cmake(
                '-G', 'Xcode',
                '-D', 'CMAKE_INSTALL_PREFIX=%s' % install_dir,
                '-D', 'CMAKE_MODULE_PATH=%s' % os.path.join( install_dir, 'CMake' ),
                package_source_dir,
                _out = sys.stdout )
            sh.xcodebuild( '-configuration', 'Release', _out = sys.stdout )
        else:
            sh.cmake(
                '-D', 'CMAKE_INSTALL_PREFIX=%s' % install_dir,
                '-D', 'CMAKE_MODULE_PATH=%s' % os.path.join( install_dir, 'lib/OGRE/cmake' ),
                package_source_dir,
                _out = sys.stdout )
            sh.make( '-j4', 'VERBOSE=1', _out = sys.stdout )
            sh.make.install( _out = sys.stdout )
开发者ID:TTimo,项目名称:es_build,代码行数:29,代码来源:20_ogremeshy.py


示例2: __exit__

 def __exit__(self, type, value, traceback):
     """Reseting the current working directory,
         and run synchronization if enabled.
     """
     sh.cd(self.old_cwd)
     logger.info("Back to %s", self.old_cwd)
     shutil.rmtree(self.tmpd)
开发者ID:wvuu,项目名称:yunbk,代码行数:7,代码来源:yunbk.py


示例3: check_repositories

def check_repositories(config):
    cwd = os.getcwd()
    config.checkout_dir.makedirs(0o755, exist_ok=True)
    for repo in  config.repositories :
        if repo.private : config.pvt_pkgs.add(repo.name)
        repo.build_dist_for()
    cd(cwd)
开发者ID:dnene,项目名称:nestegg,代码行数:7,代码来源:main.py


示例4: testCamlistoreFileWriteAndCamputCompatibility

    def testCamlistoreFileWriteAndCamputCompatibility(self):
        # Create a 1MB random file
        test_file = tempfile.NamedTemporaryFile()
        test_file.write(os.urandom(int(1.5 * (1024 << 10))))
        test_file.seek(0)

        log.debug('Random file generated')

        log.info('Putting file with camput file:')
        old_pwd = os.getcwd()
        sh.cd(CAMLIPY_CAMLISTORE_PATH)
        camput_blobref = sh.devcam('put', 'file', test_file.name)
        sh.cd(old_pwd)
        log.info('Camput blobRef: {0}'.format(camput_blobref))

        file_writer = FileWriter(self.server, fileobj=test_file)
        file_writer.chunk()
        camplipy_blobref = file_writer.bytes_writer()

        log.info('Camlipy blobRef: {0}'.format(camplipy_blobref))

        log.info('FileWriter cnt={0}'.format(file_writer.cnt))

        # Check that no data blob has been uploaded,
        # since we just uploaded the same file with camput file.

        # "<= 1" since sometimes, camlipy make a slightly bigger end blob.
        self.assertTrue(file_writer.cnt['uploaded'] <= 1)
开发者ID:eric011,项目名称:camlipy,代码行数:28,代码来源:test_camput_and_camget_compatibility.py


示例5: gitrepo

def gitrepo(root):
    '''Construct a dictionary holding all the Git data that can be found.'''
    oldpwd = sh.pwd().strip()
    sh.cd(root)
    gitlog = sh.git('--no-pager', 'log', '-1',
                    pretty="format:%s" % FORMAT).split('\n', 7)
    branch = (os.environ.get('CIRCLE_BRANCH') or
              os.environ.get('TRAVIS_BRANCH',
                             sh.git('rev-parse',
                                    '--abbrev-ref', 'HEAD').strip()))
    remotes = [x.split() for x in sh.git.remote('-v').strip().splitlines()
               if x.endswith('(fetch)')]
    sh.cd(oldpwd)
    return {
        "head": {
            "id": gitlog[0],
            "author_name": gitlog[1],
            "author_email": gitlog[2],
            "author_timestamp": gitlog[3],
            "committer_name": gitlog[4],
            "committer_email": gitlog[5],
            "committer_timestamp": gitlog[6],
            "message": gitlog[7].strip(),
        },
        "branch": branch,
        "remotes": [{'name': r[0], 'url': r[1]} for r in remotes]
    }
开发者ID:abstrus,项目名称:xenon,代码行数:27,代码来源:repository.py


示例6: new_travis_template

def new_travis_template(repo, template, write_template=False):
    """
    compute (and optionally write) .travis.yml based on the template and current metadata.yaml 
    """
    template_written = False
    
    sh.cd(os.path.join(GITENBERG_DIR, repo))

    metadata_path = os.path.join(GITENBERG_DIR, repo, "metadata.yaml")
    travis_path = os.path.join(GITENBERG_DIR, repo, ".travis.yml")
    travis_api_key_path = os.path.join(GITENBERG_DIR, repo, ".travis.deploy.api_key.txt") 
    
    md = metadata.pandata.Pandata(metadata_path)
    epub_title = slugify(md.metadata.get("title"))
    encrypted_key = open(travis_api_key_path).read().strip()
    repo_name = md.metadata.get("_repo")
    
    template_vars =  {
        'epub_title': epub_title,
        'encrypted_key': encrypted_key,
        'repo_name': repo_name,
        'repo_owner': 'GITenberg'
    }
    
    template_result = template.render(**template_vars)
    
    if write_template:
        with open(travis_path, "w") as f:
            f.write(template_result)
        template_written = True
    
    return (template_result, template_written)
开发者ID:rdhyee,项目名称:nypl50,代码行数:32,代码来源:second_folio.py


示例7: main

def main():
    if len(sys.argv) == 2:
        sh.cd(sys.argv[1])
        print(sh.git("status"))
        print("(Y/n): Are you sure you want to reset this directory?")
        temp = str(input("Local changes will be deleted: "))
        if temp=="y" or temp =="Y":
            print(sh.git.reset("--hard", "HEAD"))
            print(sh.git.clean("-f"))
            print(sh.git.pull)
            print(sh.git("status"))
        else:
            sys.exit(0)

    else:
        print(sh.git("status"))
        print("(Y/n): Are you sure you want to reset this directory?")
        temp = str(input("Local changes will be deleted: "))
        if temp=="y" or temp =="Y":
            print(sh.git.reset("--hard", "HEAD"))
            print(sh.git.clean("-f"))
            print(sh.git.pull)
            print(sh.git("status"))
        else:
            sys.exit(0)
开发者ID:michaelrinos,项目名称:Python-Personal,代码行数:25,代码来源:BashScript.py


示例8: ensure_syncer_dir

def ensure_syncer_dir():
    if path.isdir(syncer_dir):
        return

    username = input('GitHub username: ')
    password = getpass.getpass('GitHub password: ')
    repo_exists = github.check_repo_exists(username, SYNCER_REPO_NAME)

    if not repo_exists:
        print("Creating new repo in GitHub")
        github.create_public_repo(username, password, SYNCER_REPO_NAME)

    print("Cloning GitHub repo.")
    sh.git('clone', 'https://%s:%[email protected]/%s/%s.git' % (username, password, username, SYNCER_REPO_NAME), syncer_dir)

    needs_commit = False
    sh.cd(syncer_dir)
    if not path.isfile(path('manifest.json')):
        sh.touch('manifest.json')
    
    if not path.isdir(path('content')):
        sh.mkdir('content')

    if not path.isdir(path('backup')):
        sh.mkdir('backup')

    if not path.isfile(path('.gitignore')):
        needs_commit = True
        with open('.gitignore', 'w') as gitignore_file:
            gitignore_file.write('backup')

    if needs_commit:
        sh.git('add', '-A')
        sh.git('commit', '-m', 'Setting up scaffolding.')
开发者ID:cerivera,项目名称:syncer,代码行数:34,代码来源:main.py


示例9: test_push_conflict_default

def test_push_conflict_default(git_dir, hg_repo):
    git_repo = clone_repo(git_dir, hg_repo)
    sh.cd(hg_repo)
    make_hg_commit("b")
    sh.cd(git_repo)
    make_git_commit("c")
    assert sh.git.push(_ok_code=1).stderr.find("master -> master (non-fast-forward)") > 0
开发者ID:alexsydell,项目名称:gitifyhg,代码行数:7,代码来源:test_push.py


示例10: test_git_dir_from_subdir

    def test_git_dir_from_subdir(self):
        sh.git('init')
        sh.mkdir('foo')
        expected = os.path.join(os.getcwd(), '.git')

        sh.cd('foo')
        self.assertEqual(expected, git_dir())
开发者ID:themalkolm,项目名称:git-boots,代码行数:7,代码来源:test_git_dir.py


示例11: getfiles

def getfiles(userpath):
	filepath=[]
	userpath = os.path.abspath(userpath)
	contents=os.walk(userpath)
	temp = contents
	temp_list=list(temp)
	if len(temp_list)==0:	#This means that either the path points to a single file or a non-existent file/folder.
		try:
			with open(userpath) as f:	
				pass	
			return userpath.split()	#Applied split function to convert the string to a list.
		except IOError:
			print 'Invalid path.'
			sys.exit()

	contents=os.walk(userpath)
	raw_files = contents.next()
	files = sh.ls(str(raw_files[0]), '-R')
	files = str(files).split()
	ff = []
	for i in xrange(len(files)):
		if files[i][-1] == ':':
			folder = files[i][:-1]
			continue
		try:
			sh.cd(folder + '/' + files[i])
			continue
		except OSError:
			ff.append(folder + '/' + files[i])
	return ff
开发者ID:ritratt,项目名称:craesy,代码行数:30,代码来源:GetFiles.py


示例12: give_user_ztanesh

def give_user_ztanesh(unix_user):
    """
    Make sure our UNIX user runs ZtaneSH shell it is more productive to work with Plone sites.

    https://github.com/miohtama/ztanesh
    """
    from sh import git
    from sh import chsh

    home = get_unix_user_home(unix_user)

    # Install ZtaneSH
    if not os.path.exists("%s/tools" % home):

        print "Installing ZtaneSH for user %s" % unix_user

        with sudo(i=True, u=unix_user, _with=True):
            cd(home)
            git("clone", "git://github.com/miohtama/ztanesh.git", "tools")
            setup = "%s/tools/zsh-scripts/setup.zsh" % home
            run = Command(setup)
            run()

    # Set user default shell
    with sudo:
        chsh("-s", "/bin/zsh", unix_user)
开发者ID:miohtama,项目名称:senorita.plonetool,代码行数:26,代码来源:main.py


示例13: setUp

 def setUp(self):
     super(TestServerOk, self).setUp()
     self.dir = tempfile.mkdtemp()
     sh.cd(self.dir)
     sh.git.init()
     sh.git('config', 'user.name', '"Guido"')
     sh.git('config', 'user.email', '"[email protected]"')
     sh.touch('README')
     sh.git.add('.')
     sh.git.commit('-am', 'first commit')
     sh.git.tag('-a', 'jenkins-release-1', '-m', 'Release 1')
     sh.touch('file1')
     sh.git.add('.')
     sh.git.commit('-am', 'second commit #777 #123')
     sh.git.tag('-a', 'jenkins-release-2', '-m', 'Release 2', _env={"GIT_COMMITTER_DATE": "2006-04-07T22:13:13"})
     sh.touch('file2')
     sh.git.add('.')
     sh.git.commit('-am', '#67 third commit')
     sh.git.tag('-a', 'jenkins-release-3', '-m', 'Release 3')
     self.prepare_client()
     self.valid_data = {
         'build_number': '42',
         'build_tag': 'jenkins-release-2',
         'previous_tag': 'jenkins-release-1',
         'job_url': 'http://jenkins_url/jobs/2/',
         'repo': self.dir,
         'instance': 'TestServer',
     }
开发者ID:futurecolors,项目名称:redmine-releasedate,代码行数:28,代码来源:test_releasedate.py


示例14: setUp

    def setUp(self):
        self.dir = tempfile.mkdtemp()

        sh.cd(self.dir)
        with open('.coveralls.mock', 'w+') as fp:
            fp.write('repo_token: xxx\n')
            fp.write('service_name: jenkins\n')
开发者ID:coagulant,项目名称:coveralls-python,代码行数:7,代码来源:configuration_test.py


示例15: test_run

def test_run(tmp_path):
    dotenv_file = tmp_path / '.env'
    dotenv_file.touch()
    sh.cd(str(tmp_path))
    dotenv.set_key(str(dotenv_file), 'FOO', 'BAR')
    result = sh.dotenv('run', 'printenv', 'FOO').strip()
    assert result == 'BAR'
开发者ID:theskumar,项目名称:python-dotenv,代码行数:7,代码来源:test_cli.py


示例16: generate_template

def generate_template():
    template_file = ""
    if not isdir(build_dir):
        mkdir(build_dir)
    if isdir(build_dir):
        template_file = build_dir + "/dekko.dekkoproject.pot"
        print("TemplateFile: " + template_file)
        cd(build_dir)
        print("Running cmake to generate updated template")
        cmake('..')
        print("Running make")
        make("-j2")
    if isfile(template_file):
        if isdir(po_dir):
            print("Moving template to po dir: " + po_dir)
            mv(template_file, po_dir)
        else:
            print("Couldn't find po dir: " + po_dir)
            cleanup()
            return
    else:
        cleanup()
        print("No template found for: " + template_file)
        return
    print("Cleaning up")
    cleanup()
    print("YeeHaa!")
    print("All done, you need to commit & push this to bitbucket now :-)")
    print("NOTE: this would also be a good time to sync with launchpad, run")
    print("  $ python3 launchpad_sync.py")
开发者ID:ubuntu-touch-apps,项目名称:dekko,代码行数:30,代码来源:update_translations.py


示例17: setUp

    def setUp(self):
        self.powerline = mock.MagicMock()
        git.Color = mock.MagicMock()

        self.dirname = tempfile.mkdtemp()
        sh.cd(self.dirname)
        sh.git("init", ".")
开发者ID:Bragaman,项目名称:powerline-shell,代码行数:7,代码来源:git_test.py


示例18: repo_version

def repo_version(repo, version_type='patch', write_version=False):
    
    assert version_type in ('patch', 'minor', 'major')
    
    metadata_updated = False
    
    sh.cd(os.path.join(GITENBERG_DIR, repo))
    metadata_path = os.path.join(GITENBERG_DIR, repo, "metadata.yaml")
    
    if os.path.exists(metadata_path):
        md = metadata.pandata.Pandata(metadata_path)
        _version = md.metadata.get("_version")
        next_func = getattr(semantic_version.Version(_version), "next_{}".format(version_type))
        _next_version = unicode(next_func())
        
        if write_version:
            md.metadata["_version"] =  _next_version
            with open(metadata_path, 'w') as f:
                f.write(yaml.safe_dump(md.metadata,default_flow_style=False,allow_unicode=True))
            metadata_updated = True
        
        return (_version, _next_version, metadata_updated)
    
    else:
        
        return (None, None, False)
开发者ID:rdhyee,项目名称:nypl50,代码行数:26,代码来源:second_folio.py


示例19: build_opencv

def build_opencv():
    sh.pip.install("numpy")
    clone_if_not_exists("opencv", "https://github.com/PolarNick239/opencv.git", branch="stable_3.0.0)
    clone_if_not_exists("opencv_contrib", "https://github.com/PolarNick239/opencv_contrib.git", branch="stable_3.0.0")
    sh.rm("-rf", "build")
    sh.mkdir("build")
    sh.cd("build")
    python_path = pathlib.Path(sh.pyenv.which("python").stdout.decode()).parent.parent
    version = "{}.{}".format(sys.version_info.major, sys.version_info.minor)
    sh.cmake(
        "..",
        "-DCMAKE_BUILD_TYPE=RELEASE",
        "-DCMAKE_INSTALL_PREFIX={}/usr/local".format(python_path),
        "-DWITH_CUDA=OFF",
        "-DWITH_FFMPEG=OFF",
        "-DINSTALL_C_EXAMPLES=OFF",
        "-DBUILD_opencv_legacy=OFF",
        "-DBUILD_NEW_PYTHON_SUPPORT=ON",
        "-DBUILD_opencv_python3=ON",
        "-DOPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.4.1/modules",
        "-DBUILD_EXAMPLES=ON",
        "-DPYTHON_EXECUTABLE={}/bin/python".format(python_path),
        "-DPYTHON3_LIBRARY={}/lib/libpython{}m.so".format(python_path, version),
        "-DPYTHON3_PACKAGES_PATH={}/lib/python{}/site-packages/".format(python_path, version),
        "-DPYTHON3_NUMPY_INCLUDE_DIRS={}/lib/python{}/site-packages/numpy/core/include".format(python_path, version),
        "-DPYTHON_INCLUDE_DIR={}/include/python{}m".format(python_path, version),
        _out=sys.stdout,
    )
    sh.make("-j4", _out=sys.stdout)
    sh.make.install(_out=sys.stdout)
开发者ID:hephaex,项目名称:toolchain,代码行数:30,代码来源:build_opencv.py


示例20: get_new_files

def get_new_files(input):
    sh.cd(input)
    git = sh.git
    return [
        x[3:].rstrip('\n') for x in git.status('--porcelain')
            if x.startswith('?? ')
    ]
开发者ID:gisce,项目名称:atr,代码行数:7,代码来源:tasks.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python sh.cp函数代码示例发布时间:2022-05-27
下一篇:
Python sh.cat函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap