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


Python Git.pull方法代码示例

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


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

示例1: on_message

# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import pull [as 别名]
async def on_message(message):
	if client.sleeping:
		if message.content == '!wake':
			client.sleeping = False
			await client.send_message(message.channel, 'SolBot online!')
	else:
		if message.content == '!sleep':
			client.sleeping = True
			await client.send_message(message.channel, 'Going to sleep...')
		elif message.content == '!update':
			g = Git(os.path.dirname(os.path.abspath(__file__)))
			tmp = await client.send_message(message.channel, 'Pulling new code...')
			g.pull()
			await client.edit_message(tmp, 'Code pulled. Restarting...')
			client.logout()
			os.execv(sys.executable, ['python3.5'] + sys.argv)
		elif message.content == '!gitstatus':
			g = Git(os.path.dirname(os.path.abspath(__file__)))
			tmp = await client.send_message(message.channel, 'Checking status...')
			g.fetch()
			p = re.compile('Your branch is.*by (\d+) commits.*')
			m = p.match(g.status())
			if m:
				await client.edit_message(tmp, 'I am behind by {} commits'.format(m.group(1)))
			else:
				await client.edit_message(tmp, 'I am up to date!')
开发者ID:flip40,项目名称:SolBot,代码行数:28,代码来源:solbot.py

示例2: sched_builder

# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import pull [as 别名]
    def sched_builder(self):
        for project in sorted(Project.get_all(), key=lambda p: p.name):
            if (project.name == ""):
                continue
            try:
                log.msg("checking project: %s" % project.name)
                if project.is_building():
                    log.msg("project %s still building, skip" % project.name)
                    continue

                branch = "master"
                git = Git(project)
                if os.path.isdir(git.workdir):
                    git.checkout_branch(branch)
                    git.pull()
                else:
                    git.clone(branch)

                if not os.path.isdir(git.workdir):
                    continue

                for remote_branch in git.branches(remote=True):
                    git.checkout_remote_branch(remote_branch.replace('origin/', ''))

                for release in ('stable', 'testing', 'unstable'):
                    if project.last_tag(release) != git.last_tag(release):
                        try:
                            _, version = git.last_tag(release).split('_')
                            log.msg("new %s tag, building version: %s" % (release, version))
                            d = threads.deferToThread(self.send_job, project.name, branch, release, version)
                        except Exception, e:
                            log.msg("tag not parsed: %s:%s" % (project.name, git.last_tag(release)))

            except Exception, e:
                log.err(e)
开发者ID:andrerocker,项目名称:bricklayer,代码行数:37,代码来源:service.py

示例3: pull

# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import pull [as 别名]
def pull(ctx):
    """Pull dotfile changes from GitHub"""

    VerboseLog('Running pull()', ctx)
    check_init(ctx)

    if not os.path.exists(trackfile_path()):
        click.secho('Pssst...you aren\'t tracking any files.\nTry running `dot track [filename]`\n.', fg='yellow', bold=True)
        ctx.abort()

    with open(trackfile_path(), 'r') as trf:
        for line in trf:
            line = line.rstrip()
            VerboseLog('Copying ' + dot_dir_path() + '/' + line + ' to ' + home() + '/' + line, ctx)
            if os.path.exists(dot_dir_path() + '/' + line):
                shutil.copyfile(dot_dir_path() + '/' + line, home() + '/' + line)

    VerboseLog('Creating Git class object, running git.pull()', ctx)
    git = Git(home(), Conf('options', 'gitname'), Conf('options', 'reponame'))
    return_code = git.pull()

    VerboseLog('git.pull() return code was ' + str(return_code), ctx)

    if return_code == 0:
        click.secho('\ndotfiles pulled.\n', fg='green')
    else:
        click.secho('\nThere was an error pulling the dotfiles.\n', fg='red')
开发者ID:kylefrost,项目名称:dot-cli,代码行数:29,代码来源:cli.py

示例4: addSuperModuleCommit

# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import pull [as 别名]
	def addSuperModuleCommit(self, id, hash, url, who, branch, project):	
		self.log.debug("branch: " + branch + ", project:" + project)
		
		hasSuperModule = False
		isSuperModuleBr = False
		self.log.debug("Project names: " + str(self.config.projects))
		
		projectNames = self.config.projects.keys()
		for proj in projectNames:
				self.log.debug("project: " + project + " proj: " + proj)
				if project.lower() == proj:
					hasSuperModule = True
					break
	
		for br in self.config.branches:
			if branch == br:
				isSuperModuleBr = True
				break

		self.log.debug("isSuperModuleBr: " + str(isSuperModuleBr) + " hasSuperModule: " + str(hasSuperModule))	
		if isSuperModuleBr and hasSuperModule:
			self.log.debug("Git Profile Path: " + str(self.config.profile))
			git = Git(self.config.profile)
			self.checkoutTrackingBranch(git, branch)
			git.pull()
			git.submodule("update","--init")
			gitSubmoduleProfile = {'git':self.config.superRepoPath + self.config.projects[project.lower()]}
			gitSubmodule = Git(gitSubmoduleProfile)
			self.log.debug("checking out hash: " + hash)
			gitSubmodule.fetch()
	
			if self.isOptOut(gitSubmodule, hash):
				return	
	
			gitSubmodule.checkout(hash, True)
			git.add(".")
			commitMsg = "Auto checkin: " + self.getCommitMessage(gitSubmodule, hash) + "\nuser:" + who + "\nhash:" + hash + "\nproject: " + project
			self.log.debug("commiting in super module: " +  commitMsg)
			git.commit(commitMsg)
			self.log.debug("pushing super module to branch: " + branch)
			git.push(branch)
		else:
			self.log.debug("No super module commit is required.")
开发者ID:ralberts,项目名称:Gerrit-Submodule-Hooks,代码行数:45,代码来源:supermodulecommit.py

示例5: update

# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import pull [as 别名]
def update():
    try:
        print _("Attempting to update..")

        import pip

        try:
            from git import Git
        except ImportError:
            pip.main(["install", "gitpython==0.1.7", "gitdb", "async"])
            from git import Git

        g = Git(".")
        g.pull()

        import packages
        packages.setup(True)

        print _("Done!")
    except Exception as e:
        print _("Error updating: %s") % e
        raise e

    exit(0)
开发者ID:NotAFile,项目名称:Ultros,代码行数:26,代码来源:run.py

示例6: tag

# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import pull [as 别名]
def tag():
    """tag a new version of this distribution"""
    git = Git('.')
    git.pull('origin', 'master')
    git.tag(tag_name)
开发者ID:dinoboff,项目名称:paver-templates,代码行数:7,代码来源:pavement.py

示例7: AutoUpdater

# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import pull [as 别名]
class AutoUpdater():
    def __init__(self, name, repo, cwd='.', branch='master'):
        self.name = name
        self.repo = repo
        self.cwd = cwd
        self.git = Git(repo, cwd, branch)
        self.docker = DockerCompose(cwd)

        self.container = None
        self.upgrade_script = None
        self.init_script = None

        if not exists(cwd):
            logger.info('<%s> creating missing directory %s', self.name, cwd)
            makedirs(cwd)
            self.git.clone_if_necessary()
            try:
                self.first_startup()
            except DockerComposeError as e:
                logger.error('<%s> could not start docker-compose: %s',
                             self.name, e.errors)

    def add_scripts(self, container='web', init_cmd='', upgrade_cmd=''):
        self.container = container
        self.init_script = init_cmd
        self.upgrade_script = upgrade_cmd

    def first_startup(self):
        self.docker.update()
        if self.init_script:
            try:
                res = self.docker.exec(self.container, self.upgrade_script)
                logger.info('<%s> initialized with %s', self.name, res)
            except DockerComposeError as e:
                logger.warning('%s: %s', e.message, e.errors)
        self.upgrade()

    def start(self):
        try:
            self.docker.start()
        except DockerComposeError as e:
            logger.warning('<%s> start threw an error: %s', self.name,
                           e.errors)

    def update(self):
        if self.git.changed_files() > 0:
            running_commit_date = self.git.last_commit_date()
            self.git.pull()
            latest_commit_date = self.git.last_commit_date()
            self.docker.update()
            logger.info('<%s> update finished, %s to %s', self.name,
                        running_commit_date, latest_commit_date)
        else:
            logger.info('<%s> no update needed', self.name)

    def upgrade(self):
        if self.upgrade_script:
            try:
                res = self.docker.exec(self.container, self.upgrade_script)
                logger.info('<%s> upgraded with %s', self.name, res)
            except DockerComposeError as e:
                logger.warning('%s: %s', e.message, e.errors)
开发者ID:fossasia,项目名称:open-event-orga-server,代码行数:64,代码来源:auto_updater.py

示例8: Metadata

# 需要导入模块: from git import Git [as 别名]
# 或者: from git.Git import pull [as 别名]
class Metadata(Operations, LoggingMixIn):
   def __init__(self, local_storage_path):

      self.fd = 0
      self.xmlpath = local_storage_path + "/metadata/metadata.xml"

      if not(access(local_storage_path + "/metadata", F_OK)):
         self.git = Git(local_storage_path, True)
      else:
         self.git = Git(local_storage_path, False)

      self.files = dict()
      self.files['/'] = dict(st_mode=(S_IFDIR | 0755), st_ctime=0,
         st_mtime=0, st_atime=0)

      self.node = config.node
   
   def __call__(self, op, path, *args):
        return LoggingMixIn.__call__(self, op, path, *args)

   
   def push(self, upstream):
      self.git.push(upstream)

   def pull(self, upstream):
      self.git.pull(upstream)

   def getattr(self, path, fh=None):
      """ 
         return a dict containing file information of remote metadata
         raise an exception if the item is not found
      """
      dom = parse(self.xmlpath)
      node = get_file_node(dom, path)
      file = dict()
      for key in file_attributes:
         if node.hasAttribute(key):
            file[key] = int(node.getAttribute(key))
         else:
            file[key] = file_defaults[key]
      return file

   def readdir(self, path, fh=None):
      dom = parse(self.xmlpath)
      files = ['.', '..'] 
      dir = get_file_node(dom, path)
      for child in dir.childNodes :
         if child.nodeType == child.ELEMENT_NODE:
            files.append(child.getAttribute("d_name"))
       
      return files

   def create(self, path, mode):    
      # prepare File element to be put in metadata
      dom = parse(self.xmlpath)
      root = dom.getElementsByTagName("files")[0]

      dir, fname = split_path(path)

      dir_node = get_file_node(dom, dir)
      direntry_node = dom.createElement("Direntry")
      direntry_node.setAttribute("d_name", fname)
      dir_node.appendChild(direntry_node)

      now = str(int(time()))

      new_element = dom.createElement("File")
      new_element.setAttribute("path", path)
      new_element.setAttribute("st_ctime", now)
      new_element.setAttribute("st_atime", now)
      new_element.setAttribute("st_mtime", now)
      new_element.setAttribute("st_mode", str(mode))
      new_element.setAttribute("home", self.node)

      root.appendChild(new_element)

      self.writexml(dom)

      self.fd += 1
      return self.fd

   def mkdir(self, path, mode):
      self.create(path, mode | S_IFDIR)
      return 0

   def rmdir(self, path):
      dom = parse(self.xmlpath)
      if not isDir(dom, path):
         raise OSError(ENOTDIR)
      if path == "/" or not isDirEmpty(dom, path):
         raise OSError(ENOTEMPTY)

      return self.unlink(path)

   def unlink(self, path):
      dir, fname = split_path(path)
      dom = parse(self.xmlpath)
      node = get_file_node(dom, path)
      dirnode = get_file_node(dom, dir)

#.........这里部分代码省略.........
开发者ID:carriercomm,项目名称:clyde,代码行数:103,代码来源:metadata.py


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