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


Python Repo.clone_from方法代码示例

本文整理汇总了Python中git.Repo.clone_from方法的典型用法代码示例。如果您正苦于以下问题:Python Repo.clone_from方法的具体用法?Python Repo.clone_from怎么用?Python Repo.clone_from使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在git.Repo的用法示例。


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

示例1: clone_new_repo

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import clone_from [as 别名]
    def clone_new_repo(self, path, url):
        if any(p for p, url in self.saved_repos if p == path):
            print 'You already cloned %s' % (path)
            return

        worktree_path = os.path.join(self.worktree_root, path)
        git_dir = os.path.join(self.repo_root, path)

        worktree_parent, tail = os.path.split(worktree_path)
        if not self.check_dir_structure(worktree_parent, self.worktree_root):
            return

        git_dir_parent, tail = os.path.split(git_dir)
        if not self.check_dir_structure(git_dir_parent, self.repo_root):
            return

        if os.path.exists(worktree_path):
            print '%s is already exist' % (worktree_path)
            return

        if os.path.exists(git_dir):
            print '%s is already exist' % (git_dir)
            return

        if not os.path.exists(worktree_parent):
            os.makedirs(worktree_parent)
        
        if not os.path.exists(git_dir_parent):
            os.makedirs(git_dir_parent)

        print 'clone %s to %s' % (url, path)
        kargs = {'separate-git-dir' : git_dir}
        Repo.clone_from(url, worktree_path, None, **kargs)

        self.save_repo(url, path)
开发者ID:niyaton,项目名称:git-tools,代码行数:37,代码来源:manager.py

示例2: main

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import clone_from [as 别名]
def main(argv):
    StartDirectory = 'C:\\Projekte\\windekis_src\\'
    if len(argv) > 0:
       StartDirectory = argv[0]
       
    print(config_root) 

    if os.path.exists(os.path.join(config_root,'.git')):
        print('Update repo git_templates_cim')    
        repo = Repo(config_root)   
        o = repo.remotes.origin
        o.pull('--rebase')
    else:
        print('Clone repo git_templates_cim')
        os.makedirs(config_root)        
        Repo.clone_from('[email protected]:git_templates_cim', config_root)
    
    template_dir = os.getenv('GIT_TEMPLATE_DIR', 'EMPTY')
    if template_dir != config_root:
        print('Temporarily set environment variable GIT_TEMPLATE_DIR to',config_root)
        os.environ['GIT_TEMPLATE_DIR'] = config_root   
    
    for dirname, dirnames, filenames in os.walk(StartDirectory):  
       # print path to all filenames.
       for dir in dirnames:
          if dir == 'hooks':
              parent_dir = os.path.abspath(os.path.join(dirname, dir, os.pardir))
              if os.path.split(parent_dir)[1] == '.git':
                  hook_dir = os.path.join(dirname, 'hooks')
                  hook_bak = add_unique_postfix(hook_dir + '_bak')
                  print('Backup hooks')
                  shutil.move(hook_dir,hook_bak)
                  repo_dir = os.path.abspath(os.path.join(dirname, os.pardir))
                  print('Reset hooks in repo: ', repo_dir)
                  Repo.init(repo_dir)
开发者ID:mbisch,项目名称:ScriptCollection,代码行数:37,代码来源:GitHookInit.py

示例3: test_clone_from_pathlib

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import clone_from [as 别名]
    def test_clone_from_pathlib(self, rw_dir):
        if pathlib is None:  # pythons bellow 3.4 don't have pathlib
            raise SkipTest("pathlib was introduced in 3.4")

        original_repo = Repo.init(osp.join(rw_dir, "repo"))

        Repo.clone_from(original_repo.git_dir, pathlib.Path(rw_dir) / "clone_pathlib")
开发者ID:gitpython-developers,项目名称:GitPython,代码行数:9,代码来源:test_repo.py

示例4: build

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import clone_from [as 别名]
def build(branch, username, email, repository):
    app.logger.info('Building %s, %s %s on branch %s', repository, username, email, branch)
    workspace = build_workspace(repository)
    app.logger.info('on workspace %s', workspace)
    if os.path.exists(workspace):
        app.logger.info('Fetch project')
        repo = Repo(workspace)
        origin = repo.remotes['origin']
        origin.pull('refs/heads/{0}:refs/heads/origin'.format(branch))
    else:
        app.logger.info('Clone project')
        Repo.clone_from(rebuild_repository(repository), workspace, branch=branch)

    doc_path = os.path.join(workspace, 'doc')
    if os.path.exists(doc_path):
        app.logger.info('enter doc path %s', doc_path)
        with lcd(doc_path):
            try:
                local('make html')
                group, project_slug = parse_group_project(repository)
                versions = [find_version(os.path.join(doc_path, 'conf.py')), 'latest']
                for version in versions:
                    nginx_doc_path = os.path.join(app.config['DOC_HOME'], group.lower(), project_slug.lower(), version)
                    if os.path.isdir(nginx_doc_path):
                        shutil.rmtree(nginx_doc_path)
                    ensure_parent_dir(nginx_doc_path)
                    shutil.copytree(os.path.join(doc_path, '_build', 'html'), nginx_doc_path)
                with app.app_context():
                    DataAccess.add_project(group, project_slug, versions[0])
            except Exception as e:
                # TODO(benjamin): send notice send to user_name with user_email
                app.logger.exception(e)
                raise e
开发者ID:by46,项目名称:archives,代码行数:35,代码来源:task.py

示例5: Pull_git

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import clone_from [as 别名]
def Pull_git():
    try:
        logging.info( 'Trying to initialize btcnet_info repo')
        repo = Repo("btcnet_info")
        try:
            logging.info('Checking if it has been cloned properly')
            repo = repo.clone_from("git://github.com/c00w/btcnet_info.git", 'btcnet_info')
        except git.exc.GitCommandError:
            logging.info('It has been cloned properly')
            
    except git.exc.GitCommandError:
        logging.info( 'Making new btcnet_info repo')
        repo = Repo.init("btcnet_info")
        logging.info('Cloning into it')
        repo = repo.clone_from("git://github.com/c00w/btcnet_info.git", 'btcnet_info')
        try:
            logging.info('Checking if we need to add the origin')
            origin = repo.create_remote('origin', 'git://github.com/c00w/btcnet_info.git')
        except git.exc.GitCommandError:
            logging.info('We do not need to add the origin')
        
    logging.info( 'Updating btcnet_info')
    origin = repo.remotes.origin
    origin.fetch()
    origin.pull('master')
    logging.info( 'Done')
开发者ID:callmeivan,项目名称:bitHopper,代码行数:28,代码来源:btcnet_wrapper.py

示例6: build

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import clone_from [as 别名]
    def build(self,url,repo_name,tag=None,vnc):
        # for i,ports in enumerate(args.port):
        #     args.port[i] = tuple(ports.split('/'))
        # if not tag:
        #     tag = user+"/"+p_type+":"+str(version) # make_tag()

        # dockerfile = _create_dockerfile(url,p_type,user)
        if tag is None:
            tag = "latest"
        dockerfile_dir = join(GIT_DIR,repo_name)
        Repo.clone_from(url,dockerfile_dir,branch="master")

        temp_id = "djoiadsdaasasdass"
        Image.objects.create(img_id=temp_id,repo=repo_name,tag=tag,github_url=url,
          dockerfile=open(join(dockerfile_dir,"Dockerfile")).read())

        for line in self.client.build(path=dockerfile_dir, rm=True, tag=repo_name):
            print line
        Image.objects.filter(repo=repo_name).update(
          img_id=self.images(repo_name)[0].get("Id")[0:12])

        #Something others to do
        if vnc:
            dockerfile = self.make_dockerfile(base_image=repo_name,vnc=vnc)
            self.git_init(repo_name,dockerfile)
            Image.objects.create(img_id=temp_id,repo=repo_name,tag=tag,github_url=url,
                dockerfile=open(join(dockerfile_dir,"Dockerfile")).read())

            for line in self.client.build(path=dockerfile_dir, rm=True, tag=repo_name):
                print line
            Image.objects.filter(repo=repo_name).update(
              img_id=self.images(repo_name)[0].get("Id")[0:12])
开发者ID:rogeryu27,项目名称:myphp,代码行数:34,代码来源:images.py

示例7: build_ior

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import clone_from [as 别名]
def build_ior(basepath):
    from git import Repo
    """ Pulls the DAOS branch of IOR and builds it """

    home = os.path.expanduser("~")
    repo = os.path.abspath(home + "/ior-hpc")

    # check if there is pre-existing ior repo.
    if os.path.isdir(repo):
        shutil.rmtree(repo)

    with open(os.path.join(basepath, ".build_vars.json")) as afile:
        build_paths = json.load(afile)
    daos_dir = build_paths['PREFIX']

    try:
        # pulling daos branch of IOR
        Repo.clone_from("https://github.com/daos-stack/ior-hpc.git", repo,
                        branch='daos')

        cd_cmd = 'cd ' + repo
        bootstrap_cmd = cd_cmd + ' && ./bootstrap '
        configure_cmd = (
            cd_cmd +
            ' && ./configure --prefix={0} --with-daos={0}'.format(daos_dir))
        make_cmd = cd_cmd + ' &&  make install'

        # building ior
        subprocess.check_call(bootstrap_cmd, shell=True)
        subprocess.check_call(configure_cmd, shell=True)
        subprocess.check_call(make_cmd, shell=True)

    except subprocess.CalledProcessError as error:
        print("<IorBuildFailed> Exception occurred: {0}".format(str(error)))
        raise IorFailed("IOR Build process Failed")
开发者ID:daos-stack,项目名称:daos,代码行数:37,代码来源:ior_utils.py

示例8: install

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import clone_from [as 别名]
def install(services_dir: str, package: str, name: str):
    """Install a specific service by cloning a repo"""
    from os.path import isdir
    from urllib.parse import urlparse

    url = '{}/services-{}.git'.format(__github_url__, package)
    if urlparse(package).scheme != '':
        url = package

    path = '{}/{}'.format(services_dir, name)
    try:
        _check_repo_exists(url)

        if isdir(path):
            msg = 'Package "{}" is already installed, updating'.format(package)
            update_package(path)
            return True, msg

        Repo.clone_from(url, path)

        return True, None
    except HTTPError as error:
        return False, "Can't add package: {}".format(str(error))
    except ImportError:
        return False, 'Make sure git is installed'
    except exc.GitCommandError as error:
        return False, "Couldn't clone {} ({})".format(url, error)
开发者ID:inetprocess,项目名称:docker-lamp,代码行数:29,代码来源:services.py

示例9: __init__

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import clone_from [as 别名]
    def __init__(self, *args, **kwargs):
        # unittest.TestCase.__init__(self, name)
        import os
        import tempfile
        from git import Repo

        # The constructor is called multiple times by the unit testing framework.
        # Hence, we keep track of the first call to avoid multiple temporary directories.
        if self.__class__.needs_initial:
            self._repDir = tempfile.mkdtemp(prefix="tmp-BuildingsPy" + "-testing-")
            print("************************** {}".format(self._repDir))

            self.__class__.needs_initial = False
            self.__class__.repDir = self._repDir

            # Clone the libraries
            print("Cloning Buildings repository. This may take a while.")
            print("Dir is {}".format(self._repDir))
            Repo.clone_from("https://github.com/lbl-srg/modelica-buildings",
                            os.path.join(self._repDir, "modelica-buildings"), depth=5)
            print("Cloning IBPSA repository. This may take a while.")
            Repo.clone_from("https://github.com/ibpsa/modelica-ibpsa",
                            os.path.join(self._repDir, "modelica"), depth=5)
            print("Finished cloning.")

        else:
            self._repDir = self.__class__.repDir

        self._ibpsa_dir = os.path.join(self._repDir, "modelica", "IBPSA")
        self._dest_dir = os.path.join(self._repDir, "modelica-buildings", "Buildings")

        # Call constructor of parent class
        super(Test_development_merger_IBPSA, self).__init__(*args, **kwargs)
开发者ID:lbl-srg,项目名称:BuildingsPy,代码行数:35,代码来源:test_development_merger.py

示例10: setUp

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import clone_from [as 别名]
    def setUp(self):
        """ Ensure that environment variables that are needed to run
            the tests are set
        """
        from git import Repo
        import tempfile
        import os
        import shutil

        self.env = EnvironmentVarGuard()

        self._temDir = tempfile.mkdtemp(prefix='tmp-BuildingsPy-Modelica-Lib-')
        self._buiDir = os.path.join(os.getcwd(), "Buildings")

        clo_dir = os.path.join(os.getcwd(), "tmp")

        if os.path.exists(clo_dir):
            shutil.rmtree(clo_dir)

        Repo.clone_from("https://github.com/lbl-srg/modelica-buildings.git",
                        clo_dir, depth=1)

        if os.path.exists(os.path.join(os.getcwd(), "Buildings")):
            shutil.rmtree(os.path.join(os.getcwd(), "Buildings"))
        shutil.move(os.path.join(os.getcwd(), "tmp", "Buildings"),
                    self._buiDir)
        shutil.rmtree(clo_dir)
开发者ID:lbl-srg,项目名称:BuildingsPy,代码行数:29,代码来源:test_examples_dymola.py

示例11: setUp

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import clone_from [as 别名]
    def setUp(self):
        """ Ensure that environment variables that are needed to run
            the tests are set
        """
        # Set MODELICALIBRARY which is required to run
        # runSimulationTranslated.py
        from git import Repo
        import tempfile
        import os
        import shutil

        self.env = EnvironmentVarGuard()

        self._temDir = tempfile.mkdtemp(prefix='tmp-BuildingsPy-Modelica-Lib-')

        if not os.path.exists(os.path.join(os.getcwd(), "tmp")):
            clo_dir = os.path.join(os.getcwd(), "tmp")
            if os.path.exists(clo_dir):
                shutil.rmtree(clo_dir)
            Repo.clone_from("https://github.com/lbl-srg/modelica-buildings.git",
                            clo_dir, depth=1)

            if os.path.exists(os.path.join(os.getcwd(), "Buildings")):
                shutil.rmtree(os.path.join(os.getcwd(), "Buildings"))
            shutil.move(os.path.join(os.getcwd(), "tmp", "Buildings"),
                        os.path.join(os.getcwd()))
开发者ID:Mathadon,项目名称:BuildingsPy,代码行数:28,代码来源:test_examples_dymola.py

示例12: CommitAndPushFiles

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import clone_from [as 别名]
def CommitAndPushFiles( aRepo, aFileList, aCommitMessage, aDryRun, aBranch=None ):
    from git import Repo
    clonePath = tempfile.mkdtemp()
    if aBranch is not None and len(aBranch) > 0:
        Info( "Locally clone %s (%s) to %s" % ( aRepo, aBranch, clonePath ) )
        localRepo = Repo.clone_from( aRepo, clonePath, branch=aBranch )
    else:
        Info( "Locally clone %s to %s" % ( aRepo, clonePath ) )
        localRepo = Repo.clone_from( aRepo, clonePath )

    repoName = os.path.basename( aRepo ).split('.')[0]
    for file in aFileList:
        # copy locally changed files to clone
        parentDir = os.path.abspath(os.path.join(file, os.pardir))
        fileDir = os.path.basename( parentDir )
        if fileDir == repoName:
            fileDir = ""
        relPath = os.path.join( fileDir, os.path.basename( file ) )
        fullPath = os.path.join( clonePath, relPath )
        Info( "Copy %s to %s " % ( file, fullPath ) )
        shutil.copy2( file, fullPath )
        localRepo.index.add( [relPath] )  # add changes

    if localRepo.is_dirty():  # check if any changes to commit
        Info( "Committing changed files..." )
        Info( "%s" % localRepo.git.status() )
        if not aDryRun:
            localRepo.index.commit( "%s" % aCommitMessage )  # commit changes
        Info( "Pushing changes to %s" % aRepo )
        if not aDryRun:
            localRepo.git.push()
    else:
        Info( "No changed files to commit!" )

    shutil.rmtree( clonePath )  # remove temp clone
开发者ID:openhome,项目名称:ohdevtools,代码行数:37,代码来源:Common.py

示例13: install

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import clone_from [as 别名]
 def install(self):
     try:
         Repo.clone_from(self.url, self.app.config['SKILL_FOLDER'] + self.name)
         json.path = self.app.config['SKILL_FOLDER'] + self.name + "/package.json"
         data = json.decode_path()
         self.install_dep(data)
         self.install_pip(data)
         skill = get_skill_function(self.app.config['SKILL_FOLDER'], self.name)
         if (hasattr(skill, 'create_skill') and callable(skill.create_skill)):
             Module = skill.create_skill()
             if (hasattr(Module, 'install') and callable(Module.install)):
                 try:
                     Module.install()
                 except Exception as e:
                     logger.error('Install Skill error for ' + self.name + ' : ' + str(e))
             if (hasattr(Module, 'get_blueprint') and callable(Module.get_blueprint)):
                 self.app.register_blueprint(Module.get_blueprint())
         if data['navbar'] == 'True':
             navbar.folder = self.name
             navbar.set_plugin_navbar()
         os.system('cd ' + self.app.config['SKILL_FOLDER'] + self.name + ' && make compilelang')
         bot = kernel.set()
         kernel.train(bot)
         logger.info('Installation done with success')
         return json.encode({"status":"success"})
     except Exception as e:
         logger.error('Installation error : ' + str(e))
         return json.encode({"status":"error"})
开发者ID:OnyxProject,项目名称:Onyx,代码行数:30,代码来源:__init__.py

示例14: load_game_data

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import clone_from [as 别名]
    def load_game_data(self):
        with open("games/gamelist.json") as gamelist_data:
            games = json.load(gamelist_data)

        for game_json in games:
            start_directory = None
            if 'start_directory' in game_json:
                start_directory = game_json['start_directory']

            game = Game(game_json['url'], game_json['start_file'], start_directory)
            self.games.append(game)
            print(game.local_repo)
            try:
                if not self.stopp:
                    repo = Repo(game.local_repo)
                    try:
                        repo.remotes.origin.pull()
                    except AssertionError:
                        print("Ooops ... something wen't wrong while pulling")
                    print("Done ... PULL")
            except NoSuchPathError:
                Repo.clone_from(game.url, game.local_repo)
                print("Done ... CHECKOUT")
            except GitCommandError:
                print("No Network connection :-/")
        self.games_loaded = True
开发者ID:HackerspaceBremen,项目名称:pixels_menu,代码行数:28,代码来源:gameloader.py

示例15: clone_repo

# 需要导入模块: from git import Repo [as 别名]
# 或者: from git.Repo import clone_from [as 别名]
def clone_repo(url, target):
    repo_name = os.path.split(url)
    try:
        print("Cloning " + repo_name[1])
        Repo.clone_from(url, target)
    except GitCommandError:
        print("Repository " + repo_name[1] + " already cloned")
开发者ID:Shoeboxam,项目名称:Texture_Synthesis,代码行数:9,代码来源:web.py


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