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


Python ExternalCommand.exit_status方法代码示例

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


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

示例1: _commit

# 需要导入模块: from vcpx.shwrap import ExternalCommand [as 别名]
# 或者: from vcpx.shwrap.ExternalCommand import exit_status [as 别名]
    def _commit(self, date, author, patchname, changelog=None, entries=None,
                tags = [], isinitialcommit = False):
        """
        Commit the changeset.
        """

        from os import rename, unlink

        logmessage = []

        logmessage.append(date.astimezone(UTC).strftime('%Y/%m/%d %H:%M:%S UTC'))
        # Paranoid protection against newlines in author
        logmessage.append(''.join(author.split('\n')))
        # Patchname cannot start with a newline
        patchname = patchname.lstrip('\n')
        if patchname:
            logmessage.append(patchname)
        else:
            # This is possibile also when REMOVE_FIRST_LOG_LINE is in
            # effect and the changelog starts with newlines: discard
            # those, otherwise darcs will complain about invalid patch
            # name
            if changelog:
                while changelog.startswith('\n'):
                    changelog = changelog[1:]
            if not changelog:
                # No patch name and no changelog: force non empty one
                logmessage.append(' ')
        if changelog:
            logmessage.append(changelog)

        cmd = self.repository.command("record", "--all", "--pipe", "--ignore-times")
        if not entries:
            entries = ['.']

        record = ExternalCommand(cwd=self.repository.basedir, command=cmd)
        output = record.execute(input=self.repository.encode('\n'.join(logmessage)),
                                stdout=PIPE, stderr=STDOUT)[0]

        # Repair afterwards, for http://bugs.darcs.net/issue693
        #
        # Verified that this is still needed for darcs 2.1.2 (+ 343 patches)
        # using the config.tailor file that is attached to issue693 above.
        if record.exit_status == 2:
            self.log.debug("Trying to repair record failure...")
            cmd = self.repository.command("repair")
            repair = ExternalCommand(cwd=self.repository.basedir, command=cmd)
            repairoutput = repair.execute(stdout=PIPE, stderr=STDOUT)[0]
            if not repair.exit_status:
                record.exit_status = repair.exit_status
            else:
                self.log.warning("%s returned status %d, saying %s",
                                 str(repair), repair.exit_status,
                                 repairoutput.read())

        if record.exit_status:
            pending = join(self.repository.metadir, 'patches', 'pending')
            if exists(pending):
                wrongpending = pending + '.wrong'
                if exists(wrongpending):
                    unlink(wrongpending)
                rename(pending, wrongpending)
                self.log.debug("Pending file renamed to %s", wrongpending)
            raise ChangesetReplayFailure(
                "%s returned status %d, saying: %s" % (str(record),
                                                       record.exit_status,
                                                       output.read()))
开发者ID:lelit,项目名称:tailor,代码行数:69,代码来源:target.py


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