本文整理汇总了Python中twisted.internet.utils.getProcessOutput函数的典型用法代码示例。如果您正苦于以下问题:Python getProcessOutput函数的具体用法?Python getProcessOutput怎么用?Python getProcessOutput使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getProcessOutput函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: run_journald_script
def run_journald_script(self, script):
"""
Run a script that logs messages to journald and uses
``FlockerScriptRunner``.
:param ICommandLineScript: Script to run. Must be class in this module.
:return: ``Deferred`` that fires with decoded JSON messages from the
journal for the process.
"""
name = random_name(self).encode("utf-8")
code = _SCRIPT_CODE.format(script.__name__, script.__name__)
d = getProcessOutput(
b"systemd-run", [b"--unit=" + name, b"--description=testing",
sys.executable, b"-u", b"-c", code,
b"--journald"],
env=os.environ, errortoo=True,
)
d.addCallback(lambda result: msg("systemd-run output: " + result))
# systemd-run doesn't wait for process to exit, so we need to ask
# systemd when it's done:
d.addCallback(lambda _: loop_until(lambda: Popen(
[b"systemctl", b"-q", b"is-active", name]).wait() != 0))
d.addCallback(lambda _: getProcessOutput(
b"journalctl", [b"-u", name, b"-o", b"cat"]))
d.addCallback(lambda data: (msg(b"script output: " + data), data)[1])
d.addCallback(lambda data: [
loads(l) for l in data.splitlines() if l.startswith(b"{")])
return d
开发者ID:gitstorage,项目名称:flocker,代码行数:29,代码来源:test_script.py
示例2: refresh
def refresh(self):
cmd = ("ps -xc | grep -sq Chrome && osascript" +
" -e 'tell app \"Google Chrome\"'" +
" -e 'set winref to a reference to (first window)'" +
" -e 'reload active tab of winref'" +
" -e 'end tell'")
utils.getProcessOutput('bash', ['-c', cmd])
开发者ID:emiraga,项目名称:dotfiles,代码行数:7,代码来源:main.py
示例3: start
def start(service):
args = ['-chrome', 'http://127.0.0.1:%d' % ws._port.getHost().port]
if firefoxArgs:
args.extend(firefoxArgs)
if os.name == 'nt':
executable = 'C:/Program Files/Mozilla Firefox/firefox.exe'
else:
executable = '/usr/bin/firefox'
utils.getProcessOutput(executable, args, os.environ)
开发者ID:BackupTheBerlios,项目名称:nufox-svn,代码行数:9,代码来源:deploy.py
示例4: call
def call(executable, args=None, path=None):
"""call an external process in a separate thread, when the process
returns, print the exit-code
returns the deferred"""
print 'Calling', executable, args
if args:
args = shlex.split(str(args))
d = utils.getProcessOutput(executable, args=args, env=os.environ, path=path, errortoo=True)
else:
d = utils.getProcessOutput(executable, env=os.environ, path=path, errortoo=True)
d.addCallback(print_exit_code)
return d
开发者ID:ronaldevers,项目名称:twister,代码行数:15,代码来源:utils.py
示例5: get_file_contents
def get_file_contents(poller, branch, file_path):
"""Returns a Deferred to returns the file's content."""
return utils.getProcessOutput(
poller.gitbin,
['show', 'origin/%s:%s' % (branch, file_path)],
path=poller.workdir,
)
开发者ID:alexmos17,项目名称:build_internal,代码行数:7,代码来源:cros_try_job_git.py
示例6: get_max_channels_in_raw
def get_max_channels_in_raw(self):
"""
Calls deferred with an int as argument
@rtype: Deferred
"""
def _cb(text, deferred):
ret = None
for i in text.splitlines():
if "raw supports up to " in i:
ret = int(i.split()[-2])
if ret is None:
log.error("Could not figure out how many channels in raw are supported.")
ret = 8
deferred.callback(ret)
def _eb(reason, deferred):
deferred.errback(reason)
print("Error getting max channels: %s" % (reason))
command_name = "milhouse"
args = ['--max-channels']
try:
executable = procutils.which(command_name)[0] # gets the executable
except IndexError:
return defer.fail(RuntimeError("Could not find command %s" % (command_name)))
deferred = defer.Deferred()
d = utils.getProcessOutput(executable, args=args, env=os.environ, errortoo=True) # errortoo puts stderr in output
d.addCallback(_cb, deferred)
d.addErrback(_eb, deferred)
return deferred
开发者ID:alg-a,项目名称:scenic,代码行数:30,代码来源:streamer.py
示例7: jackd_get_infos
def jackd_get_infos():
"""
Calls jack-info to retrieve info about jackd servers.
Returns a Deferred whose result is list of dict:
[{
'period': 1024,
'rate': 44100,
'latency': 32
}]
@rtype: Deferred
"""
def _cb(text, deferred):
#print text
ret = _parse_jack_info(text)
deferred.callback(ret)
def _eb(reason, deferred):
deferred.errback(reason)
print("Error listing jackd servers: %s" % (reason))
command_name = "jack-info"
args = []
try:
executable = procutils.which(command_name)[0] # gets the executable
except IndexError:
return defer.fail(RuntimeError("Could not find command %s" % (command_name)))
deferred = defer.Deferred()
d = utils.getProcessOutput(executable, args=args, env=os.environ, errortoo=True) # errortoo puts stderr in output
d.addCallback(_cb, deferred)
d.addErrback(_eb, deferred)
return deferred
开发者ID:alg-a,项目名称:scenic,代码行数:32,代码来源:jackd.py
示例8: list_cameras
def list_cameras():
"""
Calls the Deferred with the dict of devices as argument.
@rtype: Deferred
"""
def _cb(text, deferred):
#print text
ret = _parse_milhouse_list_cameras(text)
deferred.callback(ret)
def _eb(reason, deferred):
deferred.errback(reason)
print("Error listing cameras: %s" % (reason))
command_name = "milhouse"
args = ['--list-v4l2']
try:
executable = procutils.which(command_name)[0] # gets the executable
except IndexError:
return defer.fail(RuntimeError("Could not find command %s" % (command_name)))
deferred = defer.Deferred()
d = utils.getProcessOutput(executable, args=args, env=os.environ, errortoo=True) # errortoo puts stderr in output
d.addCallback(_cb, deferred)
d.addErrback(_eb, deferred)
return deferred
开发者ID:alg-a,项目名称:scenic,代码行数:26,代码来源:cameras.py
示例9: _scp_furl
def _scp_furl(self, hostname):
scp_cmd = "scp ~/.ipython/security/ipcontroller-engine.furl %s:.ipython/security/" % (hostname)
cmd_list = scp_cmd.split()
cmd_list[1] = os.path.expanduser(cmd_list[1])
log.msg('Copying furl file: %s' % scp_cmd)
d = getProcessOutput(cmd_list[0], cmd_list[1:], env=os.environ)
return d
开发者ID:FrankBian,项目名称:kuma,代码行数:7,代码来源:ipcluster.py
示例10: method
def method(testcase):
testcase.expectCommands(Expect("command"))
testcase.addGetProcessOutputExpectEnv({'key': 'value'})
d = utils.getProcessOutput("command", (), env={'key': 'value'})
d.addCallback(self.assertEqual, '')
d.addCallback(lambda _: testcase.assertAllCommandsRan())
return d
开发者ID:MPanH,项目名称:buildbot,代码行数:7,代码来源:test_test_util_gpo.py
示例11: list_midi_devices
def list_midi_devices():
"""
Twisted wrapper for _list_x11_displays.
Result is a dict with keys "input" and "output". The value are dict with ID and name for each device.
@rtype: Deferred
"""
deferred = defer.Deferred()
def _cb(text, deferred):
#print text
ret = _parse_miditream_list_devices(text)
deferred.callback(ret)
def _eb(reason, deferred):
deferred.errback(reason)
log.error("Error listing MIDI devices: %s" % (reason))
command_name = "midistream"
args = ['--list-devices']
try:
executable = procutils.which(command_name)[0] # gets the executable
except IndexError:
return defer.fail(RuntimeError("Could not find command %s" % (command_name)))
log.debug("$ %s %s" % (executable, args))
d = utils.getProcessOutput(executable, args=args, env=os.environ, errortoo=True) # errortoo puts stderr in output
d.addCallback(_cb, deferred)
d.addErrback(_eb, deferred)
return deferred
开发者ID:alg-a,项目名称:scenic,代码行数:27,代码来源:midi.py
示例12: insert
def insert(self, url, afterid, metadata, checked=False):
if 'youtube' in url and not checked:
# eclipse workaround !!!
y = os.environ
y.update({'PYTHONPATH': '/usr/bin/python'}) # / eclipse workaround
d = utils.getProcessOutput(
'/usr/bin/youtube-dl',
['-g', '-f', 'bestaudio', url],
env=y,
reactor=reactor)
d.addCallback(
lambda u: self.insert(
u.split('\n')[0], afterid, metadata, True))
return d
# log.err('playlist length:%s' % len(self._playlist))
self.maxsongid += 1
if len(self._playlist) == 0:
self._playlist.append([self.maxsongid, url, metadata])
else:
if afterid == '0':
self._playlist.insert(0, [self.maxsongid, url, metadata])
else:
self._playlist.insert(
self.playlist[self.playlist.index(int(afterid))],
[self.maxsongid, url, metadata])
# log.err('real playlist: %s' % self._playlist)
self.playlist = [i[0] for i in self._playlist]
# log.err('new playlist: %s' % self.playlist)
# log.err('metadata dic: %s' % metadata)
self.oh_playlist = [str(i) for i in self.playlist]
self.idArray = id_array(self.playlist)
self.changed_tracks()
if self.songid == 0:
self.update_metadata({'songid': 1})
return defer.succeed(self.maxsongid)
开发者ID:lazytech-org,项目名称:onDemand,代码行数:35,代码来源:omxclient.py
示例13: render_GET
def render_GET (self, request):
if self._script_id in _running_scripts:
return "This script is already running"
def done (result):
print "Process complete"
print result
_running_scripts.discard(self._script_id)
print "Running Script: %s" % self._script_path
d = utils.getProcessOutput(self._script_path, reactor = reactor)
d.addBoth(done)
_running_scripts.add(self._script_id)
url = "/experiments/"
return """
<!DOCTYPE html>
<html>
<head>
<meta http-equiv=\"refresh\" content=\"10;URL=%(url)s\">
</head>
<body bgcolor=\"#FFFFFF\" text=\"#000000\">
Starting Experiment. Will redirect to the experiment list in 10s.<br>
Or you can <a href=\"%(url)s\">go to the experiment list now.</a>
</body>
</html>""" % { "url": url }
开发者ID:rasata,项目名称:octopus,代码行数:29,代码来源:server.py
示例14: process_genome
def process_genome(form_data):
print form_data
out_string = 'description;organism;defaultPos;genome;scientificName;sourceName;taxId\n{};'.format(form_data[
'description'])
genome = form_data['genome'].split()
normalized_genome = '{}. {}'.format(
genome[0][0].upper(), genome[1].lower())
print normalized_genome
out_string += '{};{};{};{};{};{}'.format(form_data['organism'], form_data['defaultPos'], normalized_genome, form_data[
'scientificName'], form_data['sourceName'], str(form_data['taxId']))
with open('naming.csv', 'w') as f:
f.write(out_string)
print out_string
transactions = build_new_database.generate_sql_dict_from_csv(
'naming.csv')
result = build_new_database.execute_sql_queries(transactions)
print result
if result == 1045:
return {'toast': 'The database is improperly configured :('}
splitName = form_data['organism'].split()
genomes = map(lambda x: {'name': x.name, 'abbrev': x.genome}, self.db.query(
self.Genome).all())
print genomes
name = splitName[0][
:3].lower() + splitName[1][0].upper() + splitName[1][1:3].lower()
prior_versions = filter(lambda x: not x.startswith(name), map(lambda x: x['name'], genomes))
all = string.maketrans('', '')
nodigs = all.translate(all, string.digits)
if name in prior_versions:
name += str(max(map(lambda x: int(x.translate(all, nodigs)), prior_versions)) + 1)
else:
name += '0'
return utils.getProcessOutput('/bin/sh', ('-c', 'fa_to_agp.sh {} {}'.format(form_data['filename'], name)))
开发者ID:H-Plus-Time,项目名称:healthhack2015_genome_browser,代码行数:34,代码来源:app.py
示例15: executeReducedPowerMode
def executeReducedPowerMode(self):
NodeB.serverState = ServerState.SHUTDOWN_IN_PROGRESS
cmd = 'singleservermode'
location = '/usr/sbin/'
d = utils.getProcessOutput("%s%s" % (location, cmd))
return d
开发者ID:gepolquevedo,项目名称:T3Management,代码行数:7,代码来源:PowerManager.py
示例16: test_generateTestScript
def test_generateTestScript(self):
"""
Test for L{generateTestScript}
"""
fname = self._outputToTempFile(
dedent(
'''
// import ConsoleJSTestFoo.Bar
// import ConsoleJSTestFoo.Baz
print("hello from the test module");
'''))
deps = getDependencies(
fname,
ignore=(),
bootstrap=(),
packages=self._getPackages())
script = generateTestScript(
fname,
dependencies=deps)
scriptfname = self._outputToTempFile(script)
def gotResult(s):
self.assertEqual(s.split('\n'),
['hello from ConsoleJSTestFoo',
'hello from ConsoleJSTestFoo.Bar',
'hello from ConsoleJSTestFoo.Baz',
'hello from the test module',
''])
result = getProcessOutput(self.javascriptInterpreter, ('-f', scriptfname))
result.addCallback(gotResult)
return result
开发者ID:StetHD,项目名称:nevow,代码行数:35,代码来源:test_consolejstest.py
示例17: GetCommitFiles
def GetCommitFiles(self, project, rev):
args = ['log', rev, '--name-only', '--no-walk', '--format=%n']
d = utils.getProcessOutput(self.git_bin, args,
path=os.path.join(self.workdir, project),
env=os.environ, errortoo=False)
d.addCallback(lambda git_output: [x for x in git_output.splitlines() if x])
return d
开发者ID:alexmos17,项目名称:build_internal,代码行数:7,代码来源:repo_poller.py
示例18: collect
def collect(self):
return getProcessOutput(
b"chroot", [b"/host", b"flocker-diagnostics", b"--version"],
env=environ,
).addCallback(
lambda version: version.strip()
)
开发者ID:ClusterHQ,项目名称:volume-hub-catalog-agents,代码行数:7,代码来源:node_agent.py
示例19: insert
def insert(self, url, afterid, metadata, checked=False):
def inserted(res, md):
# log.err('%s %s' % (res, md))
# reactor.callLater(2, # @UndefinedVariable
# self.insert_metadata,
# md)
return res['Id']
if 'youtube' in url and not checked:
# eclipse workaround !!!
y = os.environ
y.update({'PYTHONPATH': '/usr/bin/python'})
# / eclipse workaround
d = utils.getProcessOutput(
'/usr/bin/youtube-dl',
['-g', '-f', 'bestaudio', url],
env=y,
reactor=reactor)
d.addCallback(
lambda u: self.insert(
u.split('\n')[0], afterid, metadata, True))
return d
if len(self.playlist) == 0:
d = self.mpd.call('addid', url)
elif int(afterid) == 0:
d = self.mpd.call('addid', url + ' 0')
else:
d = self.mpd.call(
'addid',
' '.join((url, str(self.playlist.index(int(afterid))+1))))
d.addCallback(inserted, metadata)
return d
开发者ID:bverdu,项目名称:onDemand,代码行数:34,代码来源:mpdclient.py
示例20: setUp
def setUp(self):
from twisted.internet import reactor
self.reactor = reactor
self.keydir = self.tmpdir.join('key').strpath
yield getProcessOutput('curvecpmakekey', [self.keydir], env=os.environ)
with open(os.path.join(self.keydir, 'publickey')) as infile:
self.key = infile.read().encode('hex')
开发者ID:habnabit,项目名称:spiral,代码行数:7,代码来源:test_acceptance.py
注:本文中的twisted.internet.utils.getProcessOutput函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论