本文整理汇总了Python中subprocess.list2cmdline函数的典型用法代码示例。如果您正苦于以下问题:Python list2cmdline函数的具体用法?Python list2cmdline怎么用?Python list2cmdline使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了list2cmdline函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get_disabled
def get_disabled():
'''
Return the disabled services
CLI Example:
.. code-block:: bash
salt '*' service.get_disabled
'''
if has_powershell():
cmd = 'Get-WmiObject win32_service | where {$_.startmode -ne "Auto"} | select-object name'
lines = __salt__['cmd.run'](cmd, shell='POWERSHELL').splitlines()
return sorted([line.strip() for line in lines[3:]])
else:
ret = set()
services = []
cmd = list2cmdline(['sc', 'query', 'type=', 'service', 'state=', 'all', 'bufsize=', str(BUFFSIZE)])
lines = __salt__['cmd.run'](cmd).splitlines()
for line in lines:
if 'SERVICE_NAME:' in line:
comps = line.split(':', 1)
if not len(comps) > 1:
continue
services.append(comps[1].strip())
for service in services:
cmd2 = list2cmdline(['sc', 'qc', service])
lines = __salt__['cmd.run'](cmd2).splitlines()
for line in lines:
if 'DEMAND_START' in line:
ret.add(service)
elif 'DISABLED' in line:
ret.add(service)
return sorted(ret)
开发者ID:DavideyLee,项目名称:salt,代码行数:34,代码来源:win_service.py
示例2: backup
def backup(self):
if self.dry_run:
return
if not os.path.exists(self.config['tar']['directory']) \
or not os.path.isdir(self.config['tar']['directory']):
raise BackupError('{0} is not a directory!'.format(self.config['tar']['directory']))
out_name = "{0}.tar".format(
self.config['tar']['directory'].lstrip('/').replace('/', '_'))
outfile = os.path.join(self.target_directory, out_name)
args = ['tar', 'c', self.config['tar']['directory']]
errlog = TemporaryFile()
stream = self._open_stream(outfile, 'w')
LOG.info("Executing: %s", list2cmdline(args))
pid = Popen(
args,
stdout=stream.fileno(),
stderr=errlog.fileno(),
close_fds=True)
status = pid.wait()
try:
errlog.flush()
errlog.seek(0)
for line in errlog:
LOG.error("%s[%d]: %s", list2cmdline(args), pid.pid, line.rstrip())
finally:
errlog.close()
if status != 0:
raise BackupError('tar failed (status={0})'.format(status))
开发者ID:abg,项目名称:holland,代码行数:29,代码来源:tar.py
示例3: run_tophat2_paired
def run_tophat2_paired(project_dir, sample, index_basename, fastq_r1, fastq_r2, logger):
'''Run tophat2 in paired-end mode for fastq files.
'''
logger.info('***Running tophat2 on paired-end reads; aligned to ref %s' % index_basename)
filepath = os.path.join(project_dir, sample)
args = [
'/Applications/tophat-2.1.0.OSX_x86_64/tophat2', #temp path for testing
#'/home/seqproc/tophat2/'
'--num-threads','10',
'--mate-inner-dist','200',
'--max-multihits' ,'1',
'--splice-mismatches', '1',
index_basename,
os.path.join(filepath, fastq_r1),
os.path.join(filepath, fastq_r2)
]
print subprocess.list2cmdline(args)
top2_process = subprocess.call(args)
if not top2_process: #return code of 0 is success
logger.info(
'***Bowtie2 alignment completed successfully for %s' % filepath
)
else:
logger.info(
'***Error in bowtie2 alignment. Return code: %d' % top2_process
)
开发者ID:mchimenti,项目名称:automated-alignment-fastq,代码行数:29,代码来源:align_fastq.py
示例4: run_task
def run_task(task_name, task, config):
if task is None:
return
target = task["target"]
positional_args = parse_list_arg(
task.get("args", {}).get("positional", []),
config,
config.get("mipmip.arg_policy." + task_name, {}).get("positional", {}),
False,
)
joined_named_args = parse_dict_arg(
task.get("args", {}).get("named", {}),
config,
config.get("mipmip.arg_policy." + task_name, {}).get("named", {}),
False,
)
stdout_pipe = None
for artifact_name, artifact in task.get("artifacts", {}).viewitems():
if artifact["type"] == "stdout":
stdout_pipe = subprocess.PIPE
args = [target] + positional_args + joined_named_args
print subprocess.list2cmdline(args)
p = subprocess.Popen(args, stdout=stdout_pipe)
returncode = p.wait()
if returncode == 0:
for artifact_name, artifact in task.get("artifacts", {}).viewitems():
if artifact["type"] == "stdout":
config["mipmip.artifacts." + task_name + "." + artifact_name] = p.stdout.read()
return p.returncode
开发者ID:legion0,项目名称:yac,代码行数:29,代码来源:mipmip.py
示例5: run_pgdump
def run_pgdump(dbname, output_stream, connection_params, format='custom', env=None):
"""Run pg_dump for the given database and write to the specified output
stream.
:param db: database name
:type db: str
:param output_stream: a file-like object - must have a fileno attribute
that is a real, open file descriptor
"""
args = [ 'pg_dump' ] + connection_params + [
'--format', format,
dbname
]
LOG.info('%s > %s', subprocess.list2cmdline(args),
output_stream.name)
stderr = tempfile.TemporaryFile()
returncode = subprocess.call(args,
stdout=output_stream,
stderr=stderr,
env=env,
close_fds=True)
stderr.flush()
stderr.seek(0)
for line in stderr:
LOG.error('%s', line.rstrip())
stderr.close()
if returncode != 0:
raise OSError("%s failed." %
subprocess.list2cmdline(args))
开发者ID:dcmorton,项目名称:holland,代码行数:32,代码来源:base.py
示例6: Config_and_build_own
def Config_and_build_own(self):
'''
Build all the own libraries that are used for SaRoMaN
'''
#digi_ND
#run configure and autogen in that context.
command = self.exec_base+'/digi_ND/autogen.sh'
print command
subprocess.call('bash %s' %command, shell=True, cwd = self.exec_base+'/digi_ND')
subprocess.call('bash %s' %command, shell=True, cwd = self.exec_base+'/digi_ND')
command = self.exec_base+'/digi_ND/configure'
print command
subprocess.call('bash %s' %command, shell=True, cwd = self.exec_base+'/digi_ND')
subprocess.call('make', shell=True, cwd = self.exec_base+'/digi_ND')
#mind_rec
#run configure and autogen in that context.
command = self.exec_base+'/mind_rec/autogen.sh'
print command
subprocess.call('bash %s' %command, shell=True, cwd = self.exec_base+'/mind_rec')
subprocess.call('bash %s' %command, shell=True, cwd = self.exec_base+'/mind_rec')
command = self.exec_base+'/mind_rec/configure'
print command
subprocess.call('bash %s' %command, shell=True, cwd = self.exec_base+'/mind_rec')
subprocess.call('make', shell=True, cwd = self.exec_base+'/mind_rec')
#sciNDG4
command = [self.third_party_support+'/bin/scons']
print subprocess.list2cmdline(command)
subprocess.call(command, cwd = self.exec_base+'/sciNDG4', env=os.environ)
开发者ID:rbayes,项目名称:SaRoMaN,代码行数:31,代码来源:saroman.py
示例7: matlab_despike_command
def matlab_despike_command(func):
import os
import subprocess
# make sure your nifti is unzipped
cur_dir = os.getcwd()
matlab_command = ['matlab',
'-nodesktop' ,
'-nosplash',
'-r "WaveletDespike(\'%s\',\'%s/rest_dn\', \'wavelet\', \'d4\', \'LimitRAM\', 17) ; quit;"' %(func, cur_dir)]
print ''
print 'Running matlab through python...........Bitch Please....'
print ''
print subprocess.list2cmdline(matlab_command)
print ''
subprocess.call(matlab_command)
spike_percent = [os.path.join(cur_dir,i) for i in os.listdir(cur_dir) if 'SP' in i][0]
noise_img = [os.path.join(cur_dir,i) for i in os.listdir(cur_dir) if 'noise' in i][0]
despiked_img = [os.path.join(cur_dir,i) for i in os.listdir(cur_dir) if 'wds' in i][0]
return despiked_img, noise_img, spike_percent
开发者ID:amadeuskanaan,项目名称:GluREST,代码行数:26,代码来源:wavelets.py
示例8: main
def main():
if (len(sys.argv) != 2):
print "Usage: ./submit_problem.py problem_file"
exit(1)
if (str.find(sys.argv[1], '-') == -1):
print "Solution file format: id-infostring.txt"
exit(1)
solution_file = sys.argv[1]
if (str.find(solution_file, '/') != -1):
id_start_idx = len(solution_file) - 1 - str.index(solution_file[::-1], '/')
else:
id_start_idx = 0
id_end_idx = str.index(solution_file, '-')
problem_id = solution_file[id_start_idx+1:id_end_idx]
cmd_list = [
"curl",
"--compressed",
"-L",
"-H", "Expect:",
"-H", "X-API-Key: " + API_KEY,
"-F", "problem_id=" + problem_id,
"-F", "[email protected]" + solution_file,
SUBMIT_ENDPOINT
]
print subprocess.list2cmdline(cmd_list)
out_json = subprocess.check_output(cmd_list)
print out_json
开发者ID:kratzercanby,项目名称:icfp_2016,代码行数:30,代码来源:submit_problem.py
示例9: run
def run(cls, cmd, *args, **argd):
extraflags = argd.get('extraflags', [])
if type(extraflags) not in (list, tuple):
extraflags = [extraflags]
cmd = [g_drive_bin] + [cmd] + list(extraflags) + list(args)
#print '$',
if argd.get('input') is not None:
if re.match(r'^[\x32-\x79\n]+$', argd.get('input')):
print 'echo "%s" |' % argd.get('input'),
else:
print 'echo ... |',
print subprocess.list2cmdline(cmd)
try:
cwd = os.getcwd()
os.chdir(g_testdir)
if argd.get('input') is None:
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
else:
p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
finally:
os.chdir(cwd)
out, err = p.communicate(argd.get('input'))
return p.returncode, out, err
开发者ID:AshutoshKumarAnand,项目名称:drive,代码行数:27,代码来源:drive_test.py
示例10: _exec_wrapper
def _exec_wrapper(self, type, args, root=None, arch=None,
outputlogger=None, timeout=None, ignoreerrors=False,
interactive=False, quiet=False, ignorestderr=False,
remount=False):
assert not (interactive and outputlogger)
basecmd = self.jurtrootcmd[:]
basecmd.extend(("--type", type))
basecmd.extend(("--target", self.targetname))
if timeout is not None:
basecmd.extend(("--timeout", str(timeout)))
if root is not None:
basecmd.extend(("--root", root))
if remount:
basecmd.append("--remount")
if arch is not None:
basecmd.extend(("--arch", arch))
if ignoreerrors:
basecmd.append("--ignore-errors")
if quiet:
basecmd.append("--quiet")
if ignorestderr:
basecmd.append("--ignore-stderr")
basecmd.extend(args)
if interactive:
fullcmd = self.sucmd[:]
fullcmd.extend(basecmd)
cmdline = subprocess.list2cmdline(fullcmd)
proc = subprocess.Popen(args=fullcmd, shell=False, bufsize=-1)
proc.wait()
returncode = proc.returncode
output = "(interactive command, no output)"
else:
cmdline = subprocess.list2cmdline(basecmd)
if outputlogger and not quiet:
outputlogger.write(">>>> running privilleged agent: %s\n" % (cmdline))
outputlogger.flush()
if not self.agentrunning:
self.start()
logger.debug("sending command to agent: %s", cmdline)
self.agentproc.stdin.write(cmdline + "\n")
self.agentproc.stdin.flush()
if outputlogger:
targetfile = outputlogger
else:
targetfile = StringIO()
returncode = self._collect_from_agent(targetfile, outputlogger)
if outputlogger:
output = "(error in log available in log files)"
else:
output = targetfile.getvalue()
# check for error:
if returncode != 0:
if timeout is not None and returncode == 124:
# command timeout
raise CommandTimeout, ("command timed out:\n%s\n" %
(cmdline))
raise CommandError(returncode, cmdline, output)
return output
开发者ID:AlexandreProenca,项目名称:jurt,代码行数:60,代码来源:su.py
示例11: main
def main(sys_args):
sys_args, jython_opts = decode_args(sys_args)
args, jython_args = parse_launcher_args(sys_args)
jython_command = JythonCommand(args, jython_opts + jython_args)
command = jython_command.command
if args.profile and not args.help:
try:
os.unlink("profile.txt")
except OSError:
pass
if args.print_requested and not args.help:
if jython_command.uname == "windows":
print subprocess.list2cmdline(jython_command.command)
else:
print " ".join(pipes.quote(arg) for arg in jython_command.command)
else:
if not (is_windows or not hasattr(os, "execvp") or args.help or jython_command.uname == "cygwin"):
# Replace this process with the java process.
#
# NB such replacements actually do not work under Windows,
# but if tried, they also fail very badly by hanging.
# So don't even try!
os.execvp(command[0], command[1:])
else:
result = 1
try:
result = subprocess.call(command)
if args.help:
print_help()
except KeyboardInterrupt:
pass
sys.exit(result)
开发者ID:Raja1992,项目名称:jython,代码行数:33,代码来源:jython.py
示例12: _exec_command_line
def _exec_command_line( command, prefix ):
"""
Executes a command (from a string), allowing all output to pass to STDOUT.
"""
# split the arguments
arguments = shlex.split( command )
# attempt to detect generic commands (not a relative command)
proc = arguments[ 0 ]
# this is probably a generic/system command
if proc[ 0 ] != '.':
check = _which( proc )
if check is None:
raise RuntimeError(
'Unable to locate "{}" in path.'.format( proc )
)
arguments[ 0 ] = check
# this needs to be executed relative to the prefix
else:
arguments[ 0 ] = prefix + arguments[ 1 : ]
# print the statement we're about to execute
print subprocess.list2cmdline( arguments )
# attempt to execute the requested command
result = subprocess.call( arguments )
# return the result of the command
return result
开发者ID:zhester,项目名称:hzpy,代码行数:32,代码来源:user.py
示例13: lvsnapshot
def lvsnapshot(orig_lv_path, snapshot_name, snapshot_extents, chunksize=None):
"""Create a snapshot of an existing logical volume
:param snapshot_lv_name: name of the snapshot
:param orig_lv_path: path to the logical volume being snapshotted
:param snapshot_extents: size to allocate to snapshot volume in extents
:param chunksize: (optional) chunksize of the snapshot volume
"""
lvcreate_args = [
"lvcreate",
"--snapshot",
"--name",
snapshot_name,
"--extents",
"%d" % snapshot_extents,
orig_lv_path,
]
if chunksize:
lvcreate_args.insert(-1, "--chunksize")
lvcreate_args.insert(-1, chunksize)
LOG.debug("%s", list2cmdline(lvcreate_args))
process = Popen(lvcreate_args, stdout=PIPE, stderr=PIPE, preexec_fn=os.setsid, close_fds=True)
stdout, stderr = process.communicate()
for line in stdout.splitlines():
if not line:
continue
LOG.debug("lvcreate: %s", line)
if process.returncode != 0:
raise LVMCommandError(list2cmdline(lvcreate_args), process.returncode, str(stderr).strip())
开发者ID:AlexLSB,项目名称:zendesk_holland,代码行数:34,代码来源:raw.py
示例14: cmd
def cmd( cmd, args = [], raw = False, show = False ):
""" executes a command returning the output as a string """
# prepend the base command
args.insert( 0, cmd )
# check for a raw command (no interpreted arguments)
if raw == True:
cmd_args = ' '.join( args )
if show == True:
print cmd_args
# normal command (list of arguments)
else:
cmd_args = args
if show == True:
print subprocess.list2cmdline( cmd_args )
# call the command expecting to see string output
output = subprocess.check_output( cmd_args,
stderr = subprocess.STDOUT,
shell = True,
universal_newlines = True )
# return the output of the command
return output.strip()
开发者ID:zhester,项目名称:hzpy,代码行数:26,代码来源:chpy.py
示例15: enable
def enable(self):
proxies = ('%s=%s' % (_, self.__get_proxy(_))
for _ in self.__env_names)
print(list2cmdline(['export'] + list(proxies)))
aliases = ('%s=%s' % (_, self.__get_proxy('GIT_SSH'))
for _ in self.__ssh_aliases)
print(list2cmdline(['alias'] + list(aliases)))
开发者ID:septs,项目名称:dotfiles,代码行数:7,代码来源:proxy-control.py
示例16: DamnSpawner
def DamnSpawner(cmd, shell=False, stderr=None, stdout=None, stdin=None, cwd=None, bufsize=0):
if cwd is None:
cwd = DV.curdir
cwd = DamnUnicode(cwd)
if type(cmd) in (type(''), type(u'')):
cmd = DamnUnicode(cmd)
else:
for i in range(len(cmd)):
cmd[i] = DamnUnicode(cmd[i])
if DV.os == 'nt':
import win32process
if type(cmd) in (type([]), type(())):
tempcmd = []
for i in cmd:
tempcmd.append(DamnUnicode(i).encode('windows-1252'))
Damnlog('Spawning subprocess on NT:', tempcmd)
Damnlog('Actual command:', subprocess.list2cmdline(tempcmd))
return subprocess.Popen(tempcmd, shell=shell, creationflags=win32process.CREATE_NO_WINDOW, stderr=subprocess.PIPE, stdout=subprocess.PIPE, stdin=subprocess.PIPE, cwd=cwd.encode('windows-1252'), executable=None, bufsize=bufsize) # Yes, ALL std's must be PIPEd, otherwise it doesn't work on win32 (see http://www.py2exe.org/index.cgi/Py2ExeSubprocessInteractions)
else:
Damnlog('Spawning subprocess on NT:', cmd)
Damnlog('Actual command:', subprocess.list2cmdline(cmd))
return subprocess.Popen(cmd.encode('windows-1252'), shell=shell, creationflags=win32process.CREATE_NO_WINDOW, stderr=subprocess.PIPE, stdout=subprocess.PIPE, stdin=subprocess.PIPE, cwd=cwd.encode('windows-1252'), executable=None, bufsize=bufsize)
else:
Damnlog('Spawning subprocess on UNIX:', cmd)
Damnlog('Actual command:', subprocess.list2cmdline(cmd))
return subprocess.Popen(cmd, shell=shell, stderr=stderr, stdout=stdout, stdin=stdin, cwd=cwd, executable=None, bufsize=bufsize)
开发者ID:EtiennePerot,项目名称:damnvid,代码行数:26,代码来源:dSpawn.py
示例17: dryrun
def dryrun(self, binary_xtrabackup):
"""Perform test backup"""
from subprocess import Popen, list2cmdline, PIPE, STDOUT
xb_cfg = self.config["xtrabackup"]
args = util.build_xb_args(
xb_cfg, self.target_directory, self.defaults_path, binary_xtrabackup
)
LOG.info("* xtrabackup command: %s", list2cmdline(args))
args = ["xtrabackup", "--defaults-file=" + self.defaults_path, "--help"]
cmdline = list2cmdline(args)
LOG.info("* Verifying generated config '%s'", self.defaults_path)
LOG.debug("* Verifying via command: %s", cmdline)
try:
process = Popen(args, stdout=PIPE, stderr=STDOUT, close_fds=True)
except OSError:
raise BackupError("Failed to find xtrabackup binary")
stdout = process.stdout.read()
process.wait()
# Note: xtrabackup --help will exit with 1 usually
if process.returncode != 1:
LOG.error("! %s failed. Output follows below.", cmdline)
for line in stdout.splitlines():
LOG.error("! %s", line)
raise BackupError("%s exited with failure status [%d]" % (cmdline, process.returncode))
开发者ID:holland-backup,项目名称:holland,代码行数:25,代码来源:plugin.py
示例18: spawnProcess
def spawnProcess(self, cmdList):
if not self.dryRun:
self.makeGroupNote('Spawning a process with command ' + subprocess.list2cmdline(cmdList) + ' at ' + os.getcwd())
return subprocess.Popen(cmdList)
else:
self.makeGroupNote('Doing a dry run. Would spawn a process with command ' + subprocess.list2cmdline(cmdList) + ' at ' + os.getcwd())
return None
开发者ID:abernatskiy,项目名称:evscripts,代码行数:7,代码来源:worker.py
示例19: ffmpeg_encode
def ffmpeg_encode(threads=1):
cmd = ['ffmpeg', '-y', '-vcodec', 'ppm','-r','23.97', '-f', 'image2pipe','-i', '-']
cmd.extend(['-vcodec', 'libx264','-pix_fmt','yuv420p', '-profile', 'baseline','-vb','15M','-crf', '16'])
cmd.extend([os.path.expanduser('~/out.mov')])
print subprocess.list2cmdline(cmd)
p = None
pool = Pool(threads)
#with ThreadPoolExecutor(max_workers=threads) as e:
for result in pool.imap(rotate,xrange(360)):
if p is None:
p = subprocess.Popen(cmd,stdin=subprocess.PIPE)
p.stdin.write(result)
p.stdin.flush()
p.stdin.close()
p.wait()
pool.close()
pool.join()
开发者ID:markreidvfx,项目名称:cythonmagick,代码行数:28,代码来源:ffmpeg_encode.py
示例20: run_pgdump
def run_pgdump(dbname, output_stream, connection_params, out_format="custom", env=None):
"""Run pg_dump for the given database and write to the specified output
stream.
:param db: database name
:type db: str
:param output_stream: a file-like object - must have a fileno attribute
that is a real, open file descriptor
"""
args = ["pg_dump"] + connection_params + ["--format", out_format, dbname]
LOG.info("%s > %s", subprocess.list2cmdline(args), output_stream.name)
stderr = tempfile.TemporaryFile()
try:
try:
returncode = subprocess.call(
args, stdout=output_stream, stderr=stderr, env=env, close_fds=True
)
except OSError as exc:
raise PgError("Failed to execute '%s': [%d] %s" % (args[0], exc.errno, exc.strerror))
stderr.flush()
stderr.seek(0)
for line in stderr:
LOG.error("%s", line.rstrip())
finally:
stderr.close()
if returncode != 0:
raise PgError("%s failed." % subprocess.list2cmdline(args))
开发者ID:holland-backup,项目名称:holland,代码行数:31,代码来源:base.py
注:本文中的subprocess.list2cmdline函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论