• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python util.shellquote函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: filter

    def filter(self, filter, node, changelog, patchfile):
        """arbitrarily rewrite changeset before applying it"""

        self.ui.status(_("filtering %s\n") % patchfile)
        user, date, msg = (changelog[1], changelog[2], changelog[4])
        fd, headerfile = tempfile.mkstemp(prefix="hg-transplant-")
        fp = os.fdopen(fd, "w")
        fp.write("# HG changeset patch\n")
        fp.write("# User %s\n" % user)
        fp.write("# Date %d %d\n" % date)
        fp.write(msg + "\n")
        fp.close()

        try:
            util.system(
                "%s %s %s" % (filter, util.shellquote(headerfile), util.shellquote(patchfile)),
                environ={"HGUSER": changelog[1], "HGREVISION": revlog.hex(node)},
                onerr=util.Abort,
                errprefix=_("filter failed"),
                out=self.ui.fout,
            )
            user, date, msg = self.parselog(file(headerfile))[1:4]
        finally:
            os.unlink(headerfile)

        return (user, date, msg)
开发者ID:influencia0406,项目名称:intellij-community,代码行数:26,代码来源:transplant.py


示例2: filter

    def filter(self, filter, node, changelog, patchfile):
        '''arbitrarily rewrite changeset before applying it'''

        self.ui.status(_('filtering %s\n') % patchfile)
        user, date, msg = (changelog[1], changelog[2], changelog[4])
        fd, headerfile = tempfile.mkstemp(prefix='hg-transplant-')
        fp = os.fdopen(fd, 'w')
        fp.write("# HG changeset patch\n")
        fp.write("# User %s\n" % user)
        fp.write("# Date %d %d\n" % date)
        fp.write(msg + '\n')
        fp.close()

        try:
            util.system('%s %s %s' % (filter, util.shellquote(headerfile),
                                   util.shellquote(patchfile)),
                        environ={'HGUSER': changelog[1],
                                 'HGREVISION': revlog.hex(node),
                                 },
                        onerr=util.Abort, errprefix=_('filter failed'),
                        out=self.ui.fout)
            user, date, msg = self.parselog(file(headerfile))[1:4]
        finally:
            os.unlink(headerfile)

        return (user, date, msg)
开发者ID:spraints,项目名称:for-example,代码行数:26,代码来源:transplant.py


示例3: uisetup

def uisetup(ui):
    for cmd, path in ui.configitems('extdiff'):
        path = util.expandpath(path)
        if cmd.startswith('cmd.'):
            cmd = cmd[4:]
            if not path:
                path = util.findexe(cmd)
                if path is None:
                    path = filemerge.findexternaltool(ui, cmd) or cmd
            diffopts = ui.config('extdiff', 'opts.' + cmd, '')
            cmdline = util.shellquote(path)
            if diffopts:
                cmdline += ' ' + diffopts
        elif cmd.startswith('opts.'):
            continue
        else:
            if path:
                # case "cmd = path opts"
                cmdline = path
                diffopts = len(shlex.split(cmdline)) > 1
            else:
                # case "cmd ="
                path = util.findexe(cmd)
                if path is None:
                    path = filemerge.findexternaltool(ui, cmd) or cmd
                cmdline = util.shellquote(path)
                diffopts = False
        # look for diff arguments in [diff-tools] then [merge-tools]
        if not diffopts:
            args = ui.config('diff-tools', cmd+'.diffargs') or \
                   ui.config('merge-tools', cmd+'.diffargs')
            if args:
                cmdline += ' ' + args
        command(cmd, extdiffopts[:], _('hg %s [OPTION]... [FILE]...') % cmd,
                inferrepo=True)(savedcmd(path, cmdline))
开发者ID:motlin,项目名称:cyg,代码行数:35,代码来源:extdiff.py


示例4: get_filelogs_at_cl

def get_filelogs_at_cl(client, clnum):
    cmd = 'p4 --client %s -G fstat -T ' \
         '"depotFile,headAction,headType,headRev" ' \
         '"//%s/..."@%d' % (
         util.shellquote(client),
         util.shellquote(client),
         clnum
         )
    stdout = util.popen(cmd, mode='rb')
    try:
        result = []
        for d in loaditer(stdout):
            if d.get('depotFile'):
                headaction = d['headAction']
                if headaction in ACTION_ARCHIVE or headaction in ACTION_DELETE:
                    continue
                depotfile = d['depotFile']
                filelog = {}
                filelog[clnum] = {
                    'action': d['headAction'],
                    'type': d['headType'],
                }
                result.append(P4Filelog(depotfile, filelog))
        return result
    except Exception:
        raise P4Exception(stdout)
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:26,代码来源:p4.py


示例5: createtask

def createtask(ui, repo, defaultdesc):
    """FBONLY: create task for source control oncall"""
    prompt = '''Title: [hg rage] %s on %s by %s

Description:
%s

HG: Edit task title and description. Lines beginning with 'HG:' are removed."
HG: First line is the title followed by the description.
HG: Feel free to add relevant information.
''' % (repo.root, socket.gethostname(), encoding.environ.get('LOGNAME'),
       defaultdesc)

    text = re.sub("(?m)^HG:.*(\n|$)", "", ui.edit(prompt, ui.username()))
    lines = text.splitlines()
    title = re.sub("(?m)^Title:\s+", "", lines[0])
    desc = re.sub("(?m)^Description:\s+", "", '\n'.join(lines[1:]))
    tag = 'hg rage'
    oncall = 'source_control'
    taskid = shcmd(' '.join([
        'tasks',
        'create',
        '--title=' + util.shellquote(title),
        '--pri=low',
        '--assign=' + util.shellquote(oncall),
        '--sub=' + util.shellquote(oncall),
        '--tag=' + util.shellquote(tag),
        '--desc=' + util.shellquote(desc),
        ])
    )
    tasknum = shcmd('tasks view ' + taskid).splitlines()[0].split()[0]
    ui.write(
        _('Task created: https://our.intern.facebook.com/intern/tasks/?t=%s\n')
        % tasknum)
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:34,代码来源:rage.py


示例6: parse_filelist_at_cl

def parse_filelist_at_cl(client, cl=None):
    cmd = 'p4 --client %s -G files //%s/[email protected]%d' %(
            util.shellquote(client),
            util.shellquote(client),
            cl
            )
    stdout = util.popen(cmd, mode='rb')
    for d in loaditer(stdout):
        c = d.get('depotFile', None)
        if c:
            yield d
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:11,代码来源:p4.py


示例7: parse_filelist

def parse_filelist(client, startcl=None, endcl=None):
    if startcl is None:
        startcl = 0

    cmd = 'p4 --client %s -G files -a //%s/...%s' % (
            util.shellquote(client),
            util.shellquote(client),
            revrange(startcl, endcl))
    stdout = util.popen(cmd, mode='rb')
    for d in loaditer(stdout):
        c = d.get('depotFile', None)
        if c:
            yield d
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:13,代码来源:p4.py


示例8: parse_where

def parse_where(client, depotname):
    # TODO: investigate if we replace this with exactly one call to
    # where //clientame/...
    cmd = 'p4 --client %s -G where %s' % (
            util.shellquote(client),
            util.shellquote(depotname))
    try:
        stdout = ''
        @retry(num=3, sleeps=0.3)
        def helper():
            global stdout
            stdout = util.popen(cmd, mode='rb')
            return marshal.load(stdout)
        return helper()
    except Exception:
        raise P4Exception(stdout)
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:16,代码来源:p4.py


示例9: lsfiles

def lsfiles(ui, repo, *args, **kwargs):
    cmdoptions = [
        ('c', 'cached', None, ''),
        ('d', 'deleted', None, ''),
        ('m', 'modified', None, ''),
        ('o', 'others', None, ''),
        ('i', 'ignored', None, ''),
        ('s', 'stage', None, ''),
        ('z', '_zero', None, ''),
    ]
    args, opts = parseoptions(ui, cmdoptions, args)

    if (opts.get('modified') or opts.get('deleted')
        or opts.get('others') or opts.get('ignored')):
        cmd = Command('status')
        if opts.get('deleted'):
            cmd['-d'] = None
        if opts.get('modified'):
            cmd['-m'] = None
        if opts.get('others'):
            cmd['-o'] = None
        if opts.get('ignored'):
            cmd['-i'] = None
    else:
        cmd = Command('files')
    if opts.get('stage'):
        ui.status(_("note: Mercurial doesn't have a staging area, ignoring "
                  "--stage\n"))
    if opts.get('_zero'):
        cmd['-0'] = None
    cmd.append('.')
    for include in args:
        cmd['-I'] = util.shellquote(include)

    ui.status((str(cmd)), "\n")
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:35,代码来源:githelp.py


示例10: content

 def content(self, rev):
     text = None
     if os.path.isfile(self.rcspath):
         cmd = 'co -kk -q -p1.%d %s' % (rev, util.shellquote(self.rcspath))
         with util.popen(cmd, mode='rb') as fp:
             text = fp.read()
     return text
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:7,代码来源:importer.py


示例11: _findeditor

def _findeditor(repo, files):
    '''returns tuple of editor name and editor path.

    tools matched by pattern are returned as (name, toolpath)
    tools detected by search are returned as (name, toolpath)
    tortoisehg.editor is returned as         (None, tortoisehg.editor)
    HGEDITOR or ui.editor are returned as    (None, ui.editor)

    So first return value is an [editor-tool] name or None and
    second return value is a toolpath or user configured command line
    '''
    ui = repo.ui

    # first check for tool specified by file patterns.  The first file pattern
    # which matches one of the files being edited selects the editor
    for pat, tool in ui.configitems("editor-patterns"):
        mf = match.match(repo.root, '', [pat])
        toolpath = _findtool(ui, tool)
        if mf(files[0]) and toolpath:
            return (tool, util.shellquote(toolpath))

    # then editor-tools
    tools = {}
    for k, v in ui.configitems("editor-tools"):
        t = k.split('.')[0]
        if t not in tools:
            try:
                priority = int(_toolstr(ui, t, "priority", "0"))
            except ValueError, e:
                priority = -100
            tools[t] = priority
开发者ID:seewindcn,项目名称:tortoisehg,代码行数:31,代码来源:editor.py


示例12: launchtool

def launchtool(cmd, opts, replace, block):
    def quote(match):
        key = match.group()[1:]
        return util.shellquote(replace[key])
    if isinstance(cmd, unicode):
        cmd = hglib.fromunicode(cmd)
    lopts = []
    for opt in opts:
        if isinstance(opt, unicode):
            lopts.append(hglib.fromunicode(opt))
        else:
            lopts.append(opt)
    args = ' '.join(lopts)
    args = re.sub(_regex, quote, args)
    cmdline = util.shellquote(cmd) + ' ' + args
    cmdline = util.quotecommand(cmdline)
    try:
        proc = subprocess.Popen(cmdline, shell=True,
                                creationflags=qtlib.openflags,
                                stderr=subprocess.PIPE,
                                stdout=subprocess.PIPE,
                                stdin=subprocess.PIPE)
        if block:
            proc.communicate()
    except (OSError, EnvironmentError), e:
        QMessageBox.warning(None,
                _('Tool launch failure'),
                _('%s : %s') % (cmd, str(e)))
开发者ID:seewindcn,项目名称:tortoisehg,代码行数:28,代码来源:visdiff.py


示例13: _execute

 def _execute(self, cmd, *args, **kwargs):
     cmdline = [self.execmd, cmd]
     cmdline += args
     cmdline = [util.shellquote(arg) for arg in cmdline]
     cmdline += ['>', os.devnull, '2>', os.devnull]
     cmdline = util.quotecommand(' '.join(cmdline))
     self.ui.debug(cmdline, '\n')
     return os.system(cmdline)
开发者ID:raymundviloria,项目名称:android-app,代码行数:8,代码来源:gnuarch.py


示例14: _parse_view

 def _parse_view(self, path):
     "Read changes affecting the path"
     cmd = 'p4 -G changes -s submitted %s' % util.shellquote(path)
     stdout = util.popen(cmd, mode='rb')
     for d in loaditer(stdout):
         c = d.get("change", None)
         if c:
             self.p4changes[c] = True
开发者ID:MezzLabs,项目名称:mercurial,代码行数:8,代码来源:p4.py


示例15: get_latest_cl

def get_latest_cl(client):
    cmd = 'p4 --client %s -G changes -m 1 -s submitted' % (
            util.shellquote(client))
    stdout = util.popen(cmd, mode='rb')
    parsed = marshal.load(stdout)
    cl = parsed.get('change')
    if cl:
        return int(cl)
    return None
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:9,代码来源:p4.py


示例16: run_command

 def run_command(self, host, command, username=None, port=None):
     sshcmd = ui.config("ui", "ssh", "ssh")
     args = util.sshargs(sshcmd, host, username, port)
     cmd = '%s %s %s' % (sshcmd, args,
                         util.shellquote(''.join(command)))
     ui.debug('calling ssh: %s\n' % cmd)
     proc = subprocess.Popen(util.quotecommand(cmd), shell=True,
                             stdin=subprocess.PIPE,
                             stdout=subprocess.PIPE)
     return SubprocessWrapper(proc)
开发者ID:earies,项目名称:hg-git,代码行数:10,代码来源:_ssh.py


示例17: parse_changes

def parse_changes(client, startcl=None, endcl=None):
    "Read changes affecting the path"
    cmd = 'p4 --client %s -ztag -G changes -s submitted //%s/...%s' % (
        util.shellquote(client),
        util.shellquote(client),
        revrange(startcl, endcl))

    stdout = util.popen(cmd, mode='rb')
    cur_time = time.time()
    for d in loaditer(stdout):
        c = d.get("change", None)
        oc = d.get("oldChange", None)
        user = d.get("user", None)
        commit_time = d.get("time", None)
        time_diff = (cur_time - int(commit_time)) if commit_time else 0
        if oc:
            yield P4Changelist(int(oc), int(c), user, time_diff)
        elif c:
            yield P4Changelist(int(c), int(c), user, time_diff)
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:19,代码来源:p4.py


示例18: revisions

 def revisions(self):
     revs = set()
     if os.path.isfile(self.rcspath):
         stdout = util.popen('rlog %s 2>%s'
                             % (util.shellquote(self.rcspath), os.devnull),
                             mode='rb')
         for l in stdout.readlines():
             m = re.match('revision 1.(\d+)', l)
             if m:
                 revs.add(int(m.group(1)))
     return revs
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:11,代码来源:importer.py


示例19: parse_fstat

def parse_fstat(clnum, client, filter=None):
    cmd = 'p4 --client %s -G fstat -e %d -T ' \
          '"depotFile,headAction,headType,headRev" "//%s/..."' % (
            util.shellquote(client),
            clnum,
            util.shellquote(client))
    stdout = util.popen(cmd, mode='rb')
    try:
        result = []
        for d in loaditer(stdout):
            if d.get('depotFile') and (filter is None or filter(d)):
                if d['headAction'] in ACTION_ARCHIVE:
                    continue
                result.append({
                    'depotFile': d['depotFile'],
                    'action': d['headAction'],
                    'type': d['headType'],
                })
        return result
    except Exception:
        raise P4Exception(stdout)
开发者ID:davidshepherd7,项目名称:dotfiles,代码行数:21,代码来源:p4.py


示例20: get_ui

def get_ui():
    ui_ = ui.ui()
    ui_.fout = ui_.ferr
    ui_.setconfig('progress', 'disable', True)
    ui_.readconfig(os.path.join(git_dir, 'hgrc'))
    ssh = os.environ.get('GIT_SSH_COMMAND')
    if not ssh:
        ssh = os.environ.get('GIT_SSH')
        if ssh:
            ssh = util.shellquote(ssh)
    if ssh:
        ui_.setconfig('ui', 'ssh', ssh)
    return ui_
开发者ID:gasolin,项目名称:git-cinnabar,代码行数:13,代码来源:hg.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python util.unlinkpath函数代码示例发布时间:2022-05-27
下一篇:
Python util.sha1函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap