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


Python utils.getProcessOutput函数代码示例

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


在下文中一共展示了getProcessOutput函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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