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

Python shlex.split函数代码示例

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

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



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

示例1: _getini

 def _getini(self, name):
     try:
         description, type, default = self._parser._inidict[name]
     except KeyError:
         raise ValueError("unknown configuration value: %r" %(name,))
     try:
         value = self.inicfg[name]
     except KeyError:
         if default is not None:
             return default
         if type is None:
             return ''
         return []
     if type == "pathlist":
         dp = py.path.local(self.inicfg.config.path).dirpath()
         l = []
         for relpath in shlex.split(value):
             l.append(dp.join(relpath, abs=True))
         return l
     elif type == "args":
         return shlex.split(value)
     elif type == "linelist":
         return [t for t in map(lambda x: x.strip(), value.split("\n")) if t]
     elif type == "bool":
         return bool(_strtobool(value.strip()))
     else:
         assert type is None
         return value
开发者ID:Bachmann1234,项目名称:pytest,代码行数:28,代码来源:config.py


示例2: replace_line_in_file

def replace_line_in_file(fname, startswith, replacement):
    """Will overwrite tempfile.txt."""
    subprocess.call(shlex.split("cp %s tempfile.txt" % fname))
    infile = open('tempfile.txt')
    outfile = open(fname, 'w')
    i = 0
    for line in infile:
        i += 1
        written = False
        for entry, repl in zip(startswith, replacement):
            if isinstance(entry, int):
                if i == entry:
                    outfile.write(repl)
                    written = True
                    break
            elif isinstance(entry, str):
                if line.startswith(entry):
                    outfile.write(repl)
                    written = True
                    break
        if not written:
            outfile.write(line)
    subprocess.call(shlex.split("rm tempfile.txt"))
    infile.close()
    outfile.close()
开发者ID:eirikgje,项目名称:misc_python,代码行数:25,代码来源:gen_utils.py


示例3: run_checks

def run_checks(hooks_all, hooks_modified, modified, path):
    """ Run selected checks on the current git index """
    retcode = 0
    for command in hooks_all:
        if not isinstance(command, list):
            command = shlex.split(command)
        retcode |= subprocess.call(command, env={'PATH': path})

    for pattern, command in hooks_modified:
        if not isinstance(command, list):
            command = shlex.split(command)
        for filename in modified:
            if not fnmatch.fnmatch(filename, pattern):
                continue
            printed_filename = False
            proc = subprocess.Popen(command + [filename],
                                    env={'PATH': path},
                                    stdout=subprocess.PIPE,
                                    stderr=subprocess.STDOUT)
            output, _ = proc.communicate()
            if proc.returncode != 0:
                if not printed_filename:
                    print(filename)
                    print('=' * len(filename))
                    printed_filename = True
                print(command[0])
                print('-' * len(command[0]))
                print(output)
                retcode |= proc.returncode

    return retcode
开发者ID:stevearc,项目名称:ozzy,代码行数:31,代码来源:hook.py


示例4: launch_workers

    def launch_workers(self):
        absenv, addenv = self.get_env()
        p = sb.Popen(
            shlex.split('ssh {sshname} cd {workdir}; sh -c "cat > job.sh"'.format(**self.params)), stdin=sb.PIPE
        )
        p.stdin.write("#!/bin/sh\n")

        if self.params["type"] == "PBS":
            spec = "ssh {sshname} cd {workdir}; qsub -N dmon -o logs/logs -t 1-{cores} -j oe job.sh"
        else:
            p.stdin.write("source ENV/bin/activate\n")
            spec = "ssh {sshname} cd {workdir}; qsub -q normal.q -N dmon -e logs -o logs -t 1:{cores} -j y job.sh"

        p.stdin.write("\n".join(("export {0}={1}".format(x, y) for x, y in absenv.iteritems())))
        p.stdin.write("\n")
        p.stdin.write("\n".join(("export {0}=${0}:{1}".format(x, y) for x, y in addenv.iteritems())))
        p.stdin.write("\ncd {workdir}\n".format(**self.params))
        p.stdin.write("\n{pythonloc} -m jobmon.mon\n".format(**self.params))
        p.stdin.close()
        p.wait()

        p = sb.Popen(shlex.split(spec.format(**self.params)))
        ret = p.wait()
        if ret != "0":
            print("Success!")
        else:
            raise Exception("Error launching monitor daemons with return code %s" % str(ret))
开发者ID:binarybana,项目名称:jobmon,代码行数:27,代码来源:config.py


示例5: shlex_split

def shlex_split(string, env_replace=True, envs=None):
    """
    Split the string, applying environment variable substitutions

    Python2's shlex doesn't like unicode, so we have to convert the string
    into bytes, run shlex.split() and convert it back to unicode.

    This applies environment variable substitutions on the string when
    quoting allows, and splits it into tokens at whitespace
    delimiters.

    Environment variable substitution is applied to the entire string,
    even the part before any '=', which is not technically correct but
    will only fail for invalid Dockerfile content.

    :param string: str, string to split
    :param env_replace: bool, whether to perform substitution
    :param envs: dict, environment variables for substitution

    """
    if env_replace:
        string = EnvSubst(string, envs or {}).substitute()

    if PY2 and isinstance(string, unicode):
        string = u2b(string)
        # this takes care of quotes
        splits = shlex.split(string)
        return map(b2u, splits)
    else:
        return shlex.split(string)
开发者ID:jpopelka,项目名称:dockerfile-parse,代码行数:30,代码来源:util.py


示例6: post

    def post(self, request):
        try:
            data = received_json_data=json.loads(request.body)
        except Exception as e:
            return JsonResponse(BAD_JSON_RESPONSE, status=400)

        if 'cmd' not in data:
            return JsonResponse(NO_CMD_RESPONSE, status=400)

        cmd = data['cmd']
        # Random key for the output
        outputKey = generate_key()
        outfile = open('/tmp/' + outputKey + '.out','w')
        errfile = open('/tmp/' + outputKey + '.err','w')
        try:
            if '|' in cmd:
                cmd_parts = cmd.split('|')
                # Run the first part of the pipe
                p = psutil.Popen(shlex.split(cmd_parts[0]),stdin=None, stdout=PIPE, stderr=errfile)
                # Do the rest in background
                t = threading.Thread(target=runPipe, args=(cmd_parts[1:], p, outfile, errfile))
                t.start()
            else:
                # Run the command
                p = psutil.Popen(shlex.split(cmd), stdout=outfile, stderr=errfile)
                # Wait in background
                t = threading.Thread(target=runCmd, args=(p, outfile, errfile))
                t.start()
        except OSError as e:
            outfile.close()
            errfile.close()
            return JsonResponse(BAD_CMD_RESPONSE, status=400)
        return JsonResponse({'result': 'ok', 'process': p.pid, 'output': outputKey })
开发者ID:donnanicolas,项目名称:monitoreo,代码行数:33,代码来源:views.py


示例7: RunTiming

  def RunTiming(self, options):
    Log.Info("Perform ALLKNN.", self.verbose)

    # If the dataset contains two files then the second file is the query file.
    # In this case we add this to the command line.
    if len(self.dataset) == 2:
      cmd = shlex.split(self.path + "mlpack_allknn -r " + self.dataset[0] +
          " -q " + self.dataset[1] + " -v -n neighbors.csv -d distances.csv " +
          options)
    else:
      cmd = shlex.split(self.path + "mlpack_allknn -r " + self.dataset +
          " -v -n neighbors.csv -d distances.csv " + options)

    # Run command with the nessecary arguments and return its output as a byte
    # string. We have untrusted input so we disable all shell based features.
    try:
      s = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=False,
          timeout=self.timeout)
    except subprocess.TimeoutExpired as e:
      Log.Warn(str(e))
      return -2
    except Exception as e:
      Log.Fatal("Could not execute command: " + str(cmd))
      return -1

    # Return the elapsed time.
    timer = self.parseTimer(s)
    if not timer:
      Log.Fatal("Can't parse the timer")
      return -1
    else:
      time = self.GetTime(timer)
      Log.Info(("total time: %fs" % (time)), self.verbose)

      return time
开发者ID:Saurabh7,项目名称:benchmarks,代码行数:35,代码来源:allknn.py


示例8: start_server

def start_server(socketname, compid, side, container, command, copyfrom, copyto):
    comparison_home = "comparisons/{}".format(compid)
    donefile = "{}/{}.done".format(comparison_home, side)
    if os.path.exists(donefile):
        return

    context = zmq.Context()
    socket = context.socket(zmq.PUSH)
    socket.connect(socketname)

    cmd, cidfile = docker_command(container, command)
    time.sleep(2)

    logfile = "{}/{}.log".format(comparison_home, side)
    msgstub = {"to": "update_logs", "compid": compid, "side": side}
    start_docker(cmd, cidfile, socket, logfile=logfile, msgstub=msgstub)
    open(donefile, "a").close()

    print "docker done... copying result"
    container_id = open(cidfile).read()
    cmd = "docker cp {}:{} {}/{}.{}".format(container_id, copyfrom, comparison_home, side, copyto)
    subprocess.call(shlex.split(cmd))

    cmd = "docker rm {}".format(container_id)
    subprocess.call(shlex.split(cmd))
    print "exit, runserver"
开发者ID:lukasheinrich,项目名称:atl-cutcompare,代码行数:26,代码来源:runserver.py


示例9: run_command

def run_command(command):
    if "|" in command:
        command_parts = command.split('|')
    elif ">" in command or ">>" in command or "<" in command or "<<" in command:
        p = subprocess.Popen(command,stdin=None, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
        return ''.join(list(iter(p.stdout.readline, b'')))
    else:
        command_parts = []
        command_parts.append(command)
    i = 0
    p = {}
    for command_part in command_parts:
        command_part = command_part.strip()
        if i == 0:
            p[i]=subprocess.Popen(shlex.split(command_part),stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        else:
            p[i]=subprocess.Popen(shlex.split(command_part),stdin=p[i-1].stdout, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        i = i +1
    (output, err) = p[i-1].communicate()
    exit_code = p[0].wait()
    if exit_code != 0:
        errorStr =  "Shell Output: " + str(output) + '\n'
        errorStr += "Shell Error: " + str(err) + '\n'
        return errorStr
    else:
        return str(output)
开发者ID:n0clues,项目名称:Empire,代码行数:26,代码来源:agent.py


示例10: main

def main():

    # Path to this script
    my_path = os.path.dirname(os.path.realpath(__file__))

    parser = argparse.ArgumentParser()
    parser.add_argument("exe", help="""Path the MOM executable.""")
    parser.add_argument("--git_repo", default=my_path, help="""
                        The path to the git repo.""")
    parser.add_argument("--verbose", default=False, action='store_true',
                        help="""Verbose output, will print the hashes.""")
    args = parser.parse_args()

    readelf_out = sp.check_output(shlex.split('readelf -p .rodata {}'.format(args.exe)))
    m = re.search('MOM_VERSION=(\w{40})', readelf_out)
    exe_hash = m.group(1)

    if args.verbose:
        print('Exe hash {}'.format(exe_hash), file=sys.stderr)

    curr_dir = os.getcwd()
    os.chdir(args.git_repo)
    git_out = sp.check_output(shlex.split('git rev-parse HEAD'))
    os.chdir(curr_dir)

    if args.verbose:
        print('Repo hash {}'.format(git_out.strip()), file=sys.stderr)

    if exe_hash == git_out.strip():
        return 0
    else:
        return 1
开发者ID:BreakawayLabs,项目名称:mom,代码行数:32,代码来源:check_exe_version.py


示例11: setup_module

def setup_module(module):
    print ("")
    print ("start applications backend")

    global pid
    global backend_address

    if backend_address == "http://127.0.0.1:5000/":
        # Set test mode for applications backend
        os.environ['TEST_ALIGNAK_BACKEND'] = '1'
        os.environ['TEST_ALIGNAK_BACKEND_DB'] = 'test_alignak_webui-datatable'

        # Delete used mongo DBs
        exit_code = subprocess.call(
            shlex.split('mongo %s --eval "db.dropDatabase()"' % os.environ['TEST_ALIGNAK_BACKEND_DB'])
        )
        assert exit_code == 0

        # No console output for the applications backend ...
        FNULL = open(os.devnull, 'w')
        pid = subprocess.Popen(
            shlex.split('alignak_backend --hostname 127.0.0.1 --port 5000'), stdout=FNULL, stderr=FNULL
        )
        print ("PID: %s" % pid)
        time.sleep(1)
开发者ID:algorys,项目名称:alignak-webui,代码行数:25,代码来源:test_datatable.py


示例12: run_tool

def run_tool(path):
    if os.path.getsize(path) < 100:
       print("pcap file too small, not splitting")
       return

    # need to make directories to store results from pcapsplitter
    base_dir = path.rsplit('/', 1)[0]
    timestamp = ""
    try:
        timestamp = '-'.join(str(datetime.datetime.now()).split(' ')) + '-UTC'
        timestamp = timestamp.replace(':', '_')
    except Exception as e:  # pragma: no cover
        print("couldn't create output directory with unique timestamp")
    # make directory for tool name recognition of piping to other tools
    output_dir = os.path.join(base_dir, 'pcap-node-splitter' + '-' + timestamp)
    try:
        os.mkdir(output_dir)
        os.mkdir(output_dir + '/clients')
        os.mkdir(output_dir + '/servers')
    except OSError:  # pragma: no cover
        print("couldn't make directories for output of this tool")
    try:
        subprocess.check_call(shlex.split("./PcapSplitter -f " +
                                          path + " -o " + output_dir + '/clients' + " -m client-ip"))

        subprocess.check_call(shlex.split("./PcapSplitter -f " +
                                          path + " -o " + output_dir + '/servers' + " -m server-ip"))
    except Exception as e:
        print(str(e))
开发者ID:CyberReboot,项目名称:vent-plugins,代码行数:29,代码来源:pcap_to_node_pcap.py


示例13: startPacketCaptureReader

    def startPacketCaptureReader(self, source_node_name):
        """
        Starts the packet capture reader.
        """

        if not os.path.isfile(self._capture_file_path):
            raise FileNotFoundError("the {} capture file does not exist on this host".format(self._capture_file_path))

        if self._tail_process and self._tail_process.poll() is None:
            self._tail_process.kill()
            self._tail_process = None
        if self._capture_reader_process and self._capture_reader_process.poll() is None:
            self._capture_reader_process.kill()
            self._capture_reader_process = None

        command = self._settings["packet_capture_reader_command"]

        # PCAP capture file path
        command = command.replace("%c", '"' + self._capture_file_path + '"')

        # Add description
        description = "{} {} to {} {}".format(source_node_name, self.name(),
                                              self.destinationNode().name(), self.destinationPort().name())
        command = command.replace("%d", description)

        if "|" in command:
            # live traffic capture (using tail)
            command1, command2 = command.split("|", 1)
            info = None
            if sys.platform.startswith("win"):
                # hide tail window on Windows
                info = subprocess.STARTUPINFO()
                info.dwFlags |= subprocess.STARTF_USESHOWWINDOW
                info.wShowWindow = subprocess.SW_HIDE
                if hasattr(sys, "frozen"):
                    tail_path = os.path.dirname(os.path.abspath(sys.executable))  # for Popen to find tail.exe
                else:
                    # We suppose a developer will have tail the standard GNS3 location
                    tail_path = "C:\\Program Files\\GNS3"
                command1 = command1.replace("tail.exe", os.path.join(tail_path, "tail.exe"))
                command1 = command1.strip()
                command2 = command2.strip()
            else:
                try:
                    command1 = shlex.split(command1)
                    command2 = shlex.split(command2)
                except ValueError as e:
                    msg = "Invalid packet capture command {}: {}".format(command, str(e))
                    print(msg)
                    log.error(msg)
                    return

            self._tail_process = subprocess.Popen(command1, startupinfo=info, stdout=subprocess.PIPE)
            self._capture_reader_process = subprocess.Popen(command2, stdin=self._tail_process.stdout, stdout=subprocess.PIPE)
            self._tail_process.stdout.close()
        else:
            # normal traffic capture
            if not sys.platform.startswith("win"):
                command = shlex.split(command)
            self._capture_reader_process = subprocess.Popen(command)
开发者ID:GMarciales,项目名称:gns3-gui,代码行数:60,代码来源:port.py


示例14: main

def main():
  parser = argparse.ArgumentParser(description="decrypt bzipped tarred sets",
                                   formatter_class=argparse.ArgumentDefaultsHelpFormatter)
  parser.add_argument("--rootdir", "-r", help="directory where sets are")
  parser.add_argument("--keys", "-k", nargs='+', default=[], help="decrypt keys")
  parser.add_argument("--sets", "-s", nargs='+', default=[], help="decrypt sets")
  parser.add_argument("--template", default=".tar.bz2.openssl", help="suffix of input files")
  parser.add_argument("--opensslargstr", default="enc -d -aes-256-cbc -salt", help="openssl options")
  parser.add_argument("--tarargstr", default="-jxf", help="tar options")



  try:
    args = parser.parse_args()
  except IOError as msg:
    parser.error(str(msg))

  if len(args.keys) != len(args.sets):
    sys.stderr.write("Must have same number of keys as sets\n")
    sys.exit(1)
  for k, s in zip(args.keys, args.sets):
    infile = os.path.join(args.rootdir, "%s%s" % (s, args.template))
    opensslcmd = "openssl %s -k %s" % (args.opensslargstr, k)
    tarcmd = "tar -C %s %s -" % (args.rootdir, args.tarargstr)
    op = subprocess.Popen(shlex.split(opensslcmd), stdin=open(infile, 'r'), stdout=subprocess.PIPE)
    tp = subprocess.check_call(shlex.split(tarcmd), stdin=op.stdout)
开发者ID:panx27,项目名称:elisatools,代码行数:26,代码来源:decrypt_sets.py


示例15: run

    def run(self):
        if platform.mac_ver()[0] < '10.7.':
            cc = [get_config_var('CC')]
            env = dict(os.environ)
            env['MACOSX_DEPLOYMENT_TARGET'] = get_config_var('MACOSX_DEPLOYMENT_TARGET')
        else:
            cc = ['xcrun', 'clang']
            env = dict(os.environ)
            env['MACOSX_DEPLOYMENT_TARGET'] = get_config_var('MACOSX_DEPLOYMENT_TARGET')


        if not os.path.exists('lib'):
            os.mkdir('lib')
        cflags = get_config_var('CFLAGS')
        arch_flags = sum([shlex.split(x) for x in re.findall('-arch\s+\S+', cflags)], [])
        root_flags = sum([shlex.split(x) for x in re.findall('-isysroot\s+\S+', cflags)], [])

        cmd = cc + arch_flags + root_flags + ['-dynamiclib', '-o', os.path.abspath('lib/libshared.1.dylib'), 'src/sharedlib.c']
        subprocess.check_call(cmd, env=env)
        if os.path.exists('lib/libshared.dylib'):
            os.unlink('lib/libshared.dylib')
        os.symlink('libshared.1.dylib', 'lib/libshared.dylib')

        if not os.path.exists('lib/stash'):
            os.makedirs('lib/stash')

        if os.path.exists('lib/libhalf.dylib'):
            os.unlink('lib/libhalf.dylib')

        cmd = cc + arch_flags + root_flags + ['-dynamiclib', '-o', os.path.abspath('lib/libhalf.dylib'), 'src/sharedlib.c']
        subprocess.check_call(cmd, env=env)

        os.rename('lib/libhalf.dylib', 'lib/stash/libhalf.dylib')
        os.symlink('stash/libhalf.dylib', 'lib/libhalf.dylib')
开发者ID:MerouaneBen,项目名称:py2app,代码行数:34,代码来源:setup.py


示例16: start

    def start(self):
        sys.stderr.flush()
        call(['toilet', '-f', 'smbraille', 'Starting QEMU'])
        sys.stdout.flush()
        self.log.info("Starting VM, ssh port redirected to localhost:%s (inside docker, not exposed by default)", self.ssh_port)
        if self.is_running():
            raise VMError("VM is running, shutdown first")
        if self._interactive:
            self.qemu_process = Popen(shlex.split(QEMU_RUN_INTERACTIVE.format(ssh_port=self.ssh_port, ram=self.ram)))
            return
        else:
            self.log.info("Starting in non-interactive mode. Terminal output is disabled.")
            self.qemu_process = Popen(shlex.split(QEMU_RUN.format(ssh_port=self.ssh_port, ram=self.ram)), stdout=DEVNULL, stdin=DEVNULL, stderr=PIPE)
        def keep_waiting():
            return self.is_running()

        logging.info("waiting for ssh to be open in the VM (timeout {}s)".format(self.timeout_s))
        ssh_working = wait_ssh_open('127.0.0.1', self.ssh_port, keep_waiting, self.timeout_s)

        if not self.is_running():
            (_, stderr) = self.qemu_process.communicate()
            raise VMError("VM failed to start, retcode: {}, stderr: {}".format( self.retcode(), stderr.decode()))

        if not ssh_working:
            if self.is_running():
                self.log.error("VM running but SSH is not working")
            self.terminate()
            raise VMError("SSH is not working after {} seconds".format(self.timeout_s))
        self.log.info("VM is online and SSH is up")
开发者ID:dmlc,项目名称:mxnet,代码行数:29,代码来源:vmcontrol.py


示例17: exec_command

    def exec_command(self, cmd, args=None, printflag=True):
        if printflag:
            if args:
                LOG.debug('cmd: %(cmd)s, args: %(args)s' %
                          {'cmd': cmd, 'args': args})
            else:
                LOG.debug('cmd: %s' % cmd)

        cmd = [cmd]

        if args:
            if isinstance(args, six.text_type):
                cmd += shlex.split(args.encode())
            else:
                cmd += shlex.split(args)

        try:
            stdout, stderr = utils.execute(*cmd, run_as_root=True)
            ret = 0
        except putils.ProcessExecutionError as e:
            ret = e.exit_code
            stdout = e.stdout
            stderr = e.stderr

            LOG.debug('cmd: %s' % six.text_type(cmd))
            LOG.debug('from: %s' % six.text_type(inspect.stack()[2]))
            LOG.debug('ret: %d' % ret)
            LOG.debug('stdout: %s' % stdout.replace(os.linesep, ' '))
            LOG.debug('stderr: %s' % stderr.replace(os.linesep, ' '))

        return ret, stdout, stderr
开发者ID:NicolasT,项目名称:cinder,代码行数:31,代码来源:hbsd_basiclib.py


示例18: __init__

    def __init__(self, config, file_name, file_path, info, stop_event, exceptions):
        threading.Thread.__init__(self)
        self.config = config
        self.seconds = int(info['duration'])

        self.title = ''
        self.author = ''
        self.album = ''
        self.track = ''
        self.genre = ''
        self.comment = 'Made by RadioCo www.RadioCo.org'
        if 'title' in info and info['title']:
            self.title = unicode(info['title'])
        if 'author' in info and info['author']:
            self.author = unicode(info['author'])
        if 'album' in info and info['album']:
            self.album = unicode(info['album'])
        if 'track' in info and info['track']:
            self.track = str(info['track'])
        if 'genre' in info and info['genre']:
            self.genre = unicode(info['genre'])

        self.file_name = file_name
        self.file_path = file_path
        self.stop_event = stop_event
        self.exceptions = exceptions
        self.command_1 = []
        for row in shlex.split(str(config.get('SETTINGS', 'recorder_command'))):
            self.command_1.append(self.replace(row))

        self.command_2 = []
        for row in shlex.split(str(config.get('SETTINGS', 'recorder_command_2'))):
            self.command_2.append(self.replace(row))
开发者ID:cybord,项目名称:django-radio-recorder,代码行数:33,代码来源:recorder.py


示例19: writeArgs

def writeArgs(game, args):
    cfile = Variables.playonlinux_rep+"shortcuts/"+game
    fichier = open(cfile,"r").readlines()
    i = 0
    line = []

    while(i < len(fichier)): # On retire l'eventuel
        fichier[i] = fichier[i].replace("\n","")
        if("POL_Wine " not in fichier[i]):
            line.append(fichier[i])
        else:
            try:
                old_string = shlex.split(fichier[i])
                new_string = shlex.split(str(args))
                new_string = old_string[0:2] + new_string
                new_string = " ".join([ pipes.quote(x) for x in new_string])

                new_string = new_string+' "[email protected]"'
                line.append(new_string)
            except:
                line.append(fichier[i])
        i += 1

    fichier_write = open(cfile,"w")
    i = 0
    while(i < len(line)): # On ecrit
        fichier_write.write(line[i]+"\n")
        i+=1
开发者ID:PlayOnLinux,项目名称:POL-POM-4,代码行数:28,代码来源:playonlinux.py


示例20: reposync

	def reposync(self, repoid, repoconfig, newest, urlonly, quiet):
		cmd = 'reposync --norepopath -r %s -p %s' % (repoid, repoid)

		if repoconfig:
			cmd += ' -c %s' % repoconfig

		if self.str2bool(newest) is True:
			cmd += ' -n'

		if self.str2bool(urlonly) is True:
			cmd += ' -u'
			proc = subprocess.Popen(shlex.split(cmd), stdin=None,
				stdout=subprocess.PIPE, stderr=subprocess.PIPE)
			o, e = proc.communicate()
			return o, e

		if self.str2bool(quiet) is False:
			proc = subprocess.Popen(shlex.split(cmd), stdin=None,
				stdout=None, stderr=subprocess.PIPE)
			o, e = proc.communicate()
		else:
			proc = subprocess.Popen(shlex.split(cmd), stdin=None,
				stdout=subprocess.PIPE, stderr=subprocess.PIPE)
			o, e = proc.communicate()

		if repoid and (self.str2bool(urlonly) is False):
			cwd = os.getcwd()
			os.chdir(repoid)
			# Check if RPMS dir already exists
			if not os.path.lexists('RPMS'):
				os.symlink('.', 'RPMS')
			os.chdir(cwd)
开发者ID:StackIQ,项目名称:stacki,代码行数:32,代码来源:__init__.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python shlib.rm函数代码示例发布时间:2022-05-27
下一篇:
Python shlex.shsplit函数代码示例发布时间: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