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


Python ExternalCommand.execute方法代码示例

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


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

示例1: _tag

# 需要导入模块: from vcpx.shwrap import ExternalCommand [as 别名]
# 或者: from vcpx.shwrap.ExternalCommand import execute [as 别名]
    def _tag(self, tagname, date, author):
        """
        Apply a tag.
        """

        # Sanitize tagnames for CVS: start with [a-zA-z], only include letters,
        # numbers, '-' and '_'.
        # str.isalpha et al are locale-dependent
        def iscvsalpha(chr):
            return (chr >= 'a' and chr <= 'z') or (chr >= 'A' and chr <= 'Z')
        def iscvsdigit(chr):
            return chr >= '0' and chr <= '9'
        def iscvschar(chr):
            return iscvsalpha(chr) or iscvsdigit(chr) or chr == '-' or chr == '_'
        def cvstagify(chr):
            if iscvschar(chr):
                return chr
            else:
                return '_'

        tagname = ''.join([cvstagify(chr) for chr in tagname])
        if not iscvsalpha(tagname[0]):
            tagname = 'tag-' + tagname

        cmd = self.repository.command("-f", "tag")
        c = ExternalCommand(cwd=self.repository.basedir, command=cmd)
        c.execute(tagname)
        if c.exit_status:
            raise ChangesetApplicationFailure("%s returned status %d" %
                                              (str(c), c.exit_status))
开发者ID:c0ns0le,项目名称:cygwin,代码行数:32,代码来源:cvsps.py

示例2: _commit

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

        from vcpx.shwrap import ReopenableNamedTemporaryFile

        encode = self.repository.encode

        logmessage = []
        if patchname:
            logmessage.append(patchname)
        if changelog:
            logmessage.append(changelog)
        logmessage.append('')
        logmessage.append('Original author: %s' % author)
        logmessage.append('Date: %s' % date)

        rontf = ReopenableNamedTemporaryFile('cvs', 'tailor')
        log = open(rontf.name, "w")
        log.write(encode('\n'.join(logmessage)))
        log.close()

        cmd = self.repository.command("-f", "-q", "ci", "-F", rontf.name)
        if not entries:
            entries = ['.']

        c = ExternalCommand(cwd=self.repository.basedir, command=cmd)
        c.execute(entries)

        if c.exit_status:
            raise ChangesetApplicationFailure("%s returned status %d" %
                                              (str(c), c.exit_status))
开发者ID:c0ns0le,项目名称:cygwin,代码行数:36,代码来源:cvsps.py

示例3: _prepareWorkingDirectory

# 需要导入模块: from vcpx.shwrap import ExternalCommand [as 别名]
# 或者: from vcpx.shwrap.ExternalCommand import execute [as 别名]
    def _prepareWorkingDirectory(self, source_repo):
        """
        Checkout a working copy of the target SVN repository.
        """

        from os.path import join, exists
        from vcpx.dualwd import IGNORED_METADIRS

        if not self.repository.repository or exists(join(self.repository.basedir, self.repository.METADIR)):
            return

        cmd = self.repository.command("co", "--quiet")
        if self.repository.ignore_externals:
            cmd.append("--ignore-externals")

        svnco = ExternalCommand(command=cmd)
        svnco.execute("%s%s" % (self.repository.repository,
                                self.repository.module), self.repository.basedir)

        ignore = [md for md in IGNORED_METADIRS]

        if self.logfile.startswith(self.repository.basedir):
            ignore.append(self.logfile[len(self.repository.basedir)+1:])
        if self.state_file.filename.startswith(self.repository.basedir):
            sfrelname = self.state_file.filename[len(self.repository.basedir)+1:]
            ignore.append(sfrelname)
            ignore.append(sfrelname+'.old')
            ignore.append(sfrelname+'.journal')

        cmd = self.repository.command("propset", "%(propname)s", "--quiet")
        pset = ExternalCommand(cwd=self.repository.basedir, command=cmd)
        pset.execute('\n'.join(ignore), '.', propname='svn:ignore')
开发者ID:GymWenFLL,项目名称:tpp_libs,代码行数:34,代码来源:svn.py

示例4: setupTagsDirectory

# 需要导入模块: from vcpx.shwrap import ExternalCommand [as 别名]
# 或者: from vcpx.shwrap.ExternalCommand import execute [as 别名]
    def setupTagsDirectory(self):
        if self._setupTagsDirectory == None:
            self._setupTagsDirectory = False
            if self.module and self.module <> '/':

                # Check the existing tags directory
                cmd = self.command("ls")
                svnls = ExternalCommand(command=cmd)
                svnls.execute(self.repository + self.tags_path)
                if svnls.exit_status:
                    # create it, if not exist
                    cmd = self.command("mkdir", "-m",
                                       "This directory will host the tags")
                    svnmkdir = ExternalCommand(command=cmd)
                    svnmkdir.execute(self.repository + self.tags_path)
                    if svnmkdir.exit_status:
                        raise TargetInitializationFailure(
                                    "Was not able to create tags directory '%s'"
                                    % self.tags_path)
                else:
                    self.log.debug("Directory '%s' already exists"
                                   % self.tags_path)
                self._setupTagsDirectory = True
            else:
                self.log.debug("Tags needs module setup other than '/'")

        return self._setupTagsDirectory
开发者ID:c0ns0le,项目名称:cygwin,代码行数:29,代码来源:svn.py

示例5: _commit

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

        encode = self.repository.encode

        logmessage = []
        if patchname:
            logmessage.append(patchname)
        if changelog:
            logmessage.append(changelog.replace('%', '%%'))

        cmd = self.repository.command("-u", encode(author), "commit",
                                      "-m", encode('\n'.join(logmessage)),
                                      "-D", date.astimezone(UTC).strftime('%Y/%m/%d %H:%M:%S UTC'))

        if not entries:
            entries = ['...']

        c = ExternalCommand(cwd=self.repository.basedir, command=cmd)
        c.execute(entries)

        if c.exit_status:
            raise ChangesetApplicationFailure("%s returned status %d" %
                                              (str(c), c.exit_status))
开发者ID:GymWenFLL,项目名称:tpp_libs,代码行数:29,代码来源:cdv.py

示例6: _commit

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

        logmessage = []

        logmessage.append(date.astimezone(UTC).strftime('%Y/%m/%d %H:%M:%S UTC'))
        logmessage.append(author)
        if patchname:
            logmessage.append(patchname)
        if changelog:
            logmessage.append(changelog)
        if not patchname and not changelog:
            logmessage.append('Unnamed patch')

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

        record = ExternalCommand(cwd=self.repository.basedir, command=cmd)
        record.execute(input=self.repository.encode('\n'.join(logmessage)))

        if record.exit_status:
            raise ChangesetApplicationFailure(
                "%s returned status %d" % (str(record), record.exit_status))
开发者ID:c0ns0le,项目名称:cygwin,代码行数:29,代码来源:target.py

示例7: _commit

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

        from os import environ

        encode = self.repository.encode

        logmessage = []
        if patchname:
            logmessage.append(patchname)
        if changelog:
            logmessage.append(changelog)

        env = {}
        env.update(environ)

        (name, email) = self.__parse_author(author)
        if name:
            env['GIT_AUTHOR_NAME'] = encode(name)
        if email:
            env['GIT_AUTHOR_EMAIL']=email
        if date:
            env['GIT_AUTHOR_DATE']=date.strftime('%Y-%m-%d %H:%M:%S %z')
        # '-f' flag means we can get empty commits, which
        # shouldn't be a problem.
        cmd = self.repository.command("commit", "-f")
        c = ExternalCommand(cwd=self.repository.basedir, command=cmd)

        c.execute(env=env, input=encode('\n'.join(logmessage)))
        if c.exit_status:
            raise ChangesetApplicationFailure("%s returned status %d" %
                                              (str(c), c.exit_status))
开发者ID:GymWenFLL,项目名称:tpp_libs,代码行数:37,代码来源:cg.py

示例8: _handleConflict

# 需要导入模块: from vcpx.shwrap import ExternalCommand [as 别名]
# 或者: from vcpx.shwrap.ExternalCommand import execute [as 别名]
    def _handleConflict(self, changeset, conflicts, conflict):
        """
        Handle the conflict raised by the application of the upstream changeset.

        Override parent behaviour: with darcs, we need to execute a revert
        on the conflicted files, **trashing** local changes, but there should
        be none of them in tailor context.
        """

        from os import walk, unlink
        from os.path import join
        from re import compile

        self.log.info("Reverting changes to %s, to solve the conflict",
                      ' '.join(conflict))
        cmd = self.repository.command("revert", "--all")
        revert = ExternalCommand(cwd=self.repository.basedir, command=cmd)
        revert.execute(conflict, input="\n")

        # Remove also the backups made by darcs
        bckre = compile('-darcs-backup[0-9]+$')
        for root, dirs, files in walk(self.repository.basedir):
            backups = [f for f in files if bckre.search(f)]
            for bck in backups:
                self.log.debug("Removing backup file %r in %r", bck, root)
                unlink(join(root, bck))
开发者ID:GymWenFLL,项目名称:tpp_libs,代码行数:28,代码来源:source.py

示例9: _prepareWorkingDirectory

# 需要导入模块: from vcpx.shwrap import ExternalCommand [as 别名]
# 或者: from vcpx.shwrap.ExternalCommand import execute [as 别名]
    def _prepareWorkingDirectory(self, source_repo):
        """
        Possibly checkout a working copy of the target VC, that will host the
        upstream source tree, when overriden by subclasses.
        """

        from re import escape

        if not self.repository.repository or exists(join(self.repository.basedir, '_MTN')):
            return

        if not self.repository.module:
            raise TargetInitializationFailure("Monotone needs a module "
                                              "defined (to be used as "
                                              "commit branch)")


        cmd = self.repository.command("setup",
                                      "--db", self.repository.repository,
                                      "--branch", self.repository.module)

        if self.repository.keygenid:
           self.repository.keyid = self.repository.keygenid
        if self.repository.keyid:
            cmd.extend( ("--key", self.repository.keyid) )

        setup = ExternalCommand(command=cmd)
        setup.execute(self.repository.basedir, stdout=PIPE, stderr=PIPE)

        if self.repository.passphrase or self.repository.custom_lua:
            monotonerc = open(join(self.repository.basedir, '_MTN', 'monotonerc'), 'w')
            if self.repository.passphrase:
                monotonerc.write(MONOTONERC % self.repository.passphrase)
            else:
                raise TargetInitializationFailure("The passphrase must be specified")
            if self.repository.custom_lua:
                self.log.info("Adding custom lua script")
                monotonerc.write(self.repository.custom_lua)
            monotonerc.close()

        # Add the tailor log file and state file to _MTN's list of
        # ignored files
        ignored = []
        logfile = self.repository.projectref().logfile
        if logfile.startswith(self.repository.basedir):
            ignored.append('^%s$' %
                           escape(logfile[len(self.repository.basedir)+1:]))

        sfname = self.repository.projectref().state_file.filename
        if sfname.startswith(self.repository.basedir):
            sfrelname = sfname[len(self.repository.basedir)+1:]
            ignored.append('^%s$' % escape(sfrelname))
            ignored.append('^%s$' % escape(sfrelname + '.old'))
            ignored.append('^%s$' % escape(sfrelname + '.journal'))

        if len(ignored) > 0:
            mt_ignored = open(join(self.repository.basedir, '.mtn-ignore'), 'a')
            mt_ignored.write('\n'.join(ignored))
            mt_ignored.close()
开发者ID:c0ns0le,项目名称:cygwin,代码行数:61,代码来源:monotone.py

示例10: _renamePathname

# 需要导入模块: from vcpx.shwrap import ExternalCommand [as 别名]
# 或者: from vcpx.shwrap.ExternalCommand import execute [as 别名]
    def _renamePathname(self, oldname, newname):
        """
        Rename a filesystem object.
        """

        cmd = self.repository.command("copy")
        rename = ExternalCommand(cwd=self.repository.basedir, command=cmd)
        rename.execute(oldname, newname)
开发者ID:GymWenFLL,项目名称:tpp_libs,代码行数:10,代码来源:arx.py

示例11: _removePathnames

# 需要导入模块: from vcpx.shwrap import ExternalCommand [as 别名]
# 或者: from vcpx.shwrap.ExternalCommand import execute [as 别名]
    def _removePathnames(self, names):
        """
        Remove some filesystem objects.
        """

        cmd = self.repository.command("remove", "--quiet", "--force")
        remove = ExternalCommand(cwd=self.repository.basedir, command=cmd)
        remove.execute(names)
开发者ID:c0ns0le,项目名称:cygwin,代码行数:10,代码来源:svn.py

示例12: _renamePathname

# 需要导入模块: from vcpx.shwrap import ExternalCommand [as 别名]
# 或者: from vcpx.shwrap.ExternalCommand import execute [as 别名]
 def _renamePathname(self, oldname, newname):
     """
     Rename a filesystem object.
     """
     cmd = self.repository.command("rename", "--")
     rename = ExternalCommand(cwd=self.repository.basedir, command=cmd)
     rename.execute(oldname, newname, stdout=PIPE, stderr=PIPE)
     if rename.exit_status:
         raise ChangesetApplicationFailure(
                  "%s returned status %s" % (str(rename),rename.exit_status))
开发者ID:c0ns0le,项目名称:cygwin,代码行数:12,代码来源:monotone.py

示例13: _addSubtree

# 需要导入模块: from vcpx.shwrap import ExternalCommand [as 别名]
# 或者: from vcpx.shwrap.ExternalCommand import execute [as 别名]
 def _addSubtree(self, subdir):
     """
     Add a whole subtree (recursively)
     """
     cmd = self.repository.command("add", "--recursive", "--")
     add = ExternalCommand(cwd=self.repository.basedir, command=cmd)
     add.execute(subdir, stdout=PIPE, stderr=PIPE)
     if add.exit_status:
         raise ChangesetApplicationFailure("%s returned status %s" %
                                           (str(add),add.exit_status))
开发者ID:c0ns0le,项目名称:cygwin,代码行数:12,代码来源:monotone.py

示例14: testExitStatusForFalse

# 需要导入模块: from vcpx.shwrap import ExternalCommand [as 别名]
# 或者: from vcpx.shwrap.ExternalCommand import execute [as 别名]
    def testExitStatusForFalse(self):
        """Verify ExternalCommand exit_status of ``false``.
        """

        if platform != 'win32':
            c = ExternalCommand(['false'])
        else:
            c = ExternalCommand(['cmd','/c exit 1'])
        c.execute()
        self.assertNotEqual(c.exit_status, 0)
开发者ID:lelit,项目名称:tailor,代码行数:12,代码来源:shwrap.py

示例15: testExitStatusForTrue

# 需要导入模块: from vcpx.shwrap import ExternalCommand [as 别名]
# 或者: from vcpx.shwrap.ExternalCommand import execute [as 别名]
    def testExitStatusForTrue(self):
        """Verify ExternalCommand exit_status of ``true``.
        """

        if platform != 'win32':
            c = ExternalCommand(['true'])
        else:
            c = ExternalCommand(['cmd','/c exit 0'])
        c.execute()
        self.assertEqual(c.exit_status, 0)
开发者ID:lelit,项目名称:tailor,代码行数:12,代码来源:shwrap.py


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