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


Python sh.cd函数代码示例

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


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


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