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

Python utils.getProcessValue函数代码示例

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

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



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

示例1: cb_start_server_button_clicked

 def cb_start_server_button_clicked(self, *args):
     if hasattr(sys, "frozen"):
         # TODO Find the absolute path.
         def1 = utils.getProcessValue("slugathon.exe", ["server", "-n"],
                                      env=os.environ)
     else:
         def1 = utils.getProcessValue(sys.executable,
                                      ["-m", "slugathon.net.Server", "-n"],
                                      env=os.environ)
     def1.addCallback(self.server_exited)
     def1.addErrback(self.server_failed)
开发者ID:dripton,项目名称:Slugathon,代码行数:11,代码来源:Connect.py


示例2: cb_start_server_button_clicked

 def cb_start_server_button_clicked(self, *args):
     self.status_textview.modify_style(self.status_text_norm)
     self.status_textview.get_buffer().set_text("Starting server")
     if hasattr(sys, "frozen"):
         # TODO Find the absolute path.
         def1 = utils.getProcessValue("slugathon.exe", ["server", "-n"],
                                      env=os.environ)
     else:
         def1 = utils.getProcessValue(sys.executable,
                                      ["-m", "slugathon.net.Server", "-n"],
                                      env=os.environ)
     # no errback called, irrespective of process return value
     def1.addCallback(self.server_exited)
开发者ID:orbisvicis,项目名称:Slugathon,代码行数:13,代码来源:Connect.py


示例3: jack_disconnect

def jack_disconnect(source, sink):
    """
    Calls jack_disconnect with the given arguments.
    Returns a Deferred
    """
    deferred = defer.Deferred()
    def _cb(result):
        if type(result) != int:
            lor.error("The result of calling jack_disconnect should be an int.")
        log.info("jack_disconnect result: " + str(result))
        if result == 0:
            deferred.callback(True)
        else:
            deferred.callback(False)
    
    exec_name = "jack_disconnect"
    try:
        executable = procutils.which(exec_name)[0]
    except IndexError:
        log.error("Could not find executable %s" % (exec_name))
        return defer.succeed(False)
    else:
        args = [source, sink]
        log.info("$ %s %s" % (executable, " ".join(list(args))))
        d = utils.getProcessValue(executable, args, os.environ, '.', reactor)
        d.addCallback(_cb)
        return deferred
开发者ID:aalex,项目名称:ubuntu-spinic,代码行数:27,代码来源:plumberjack.py


示例4: _prepare_base_image

    def _prepare_base_image(self):
        """
        I am a private method for creating (possibly cheap) copies of a
        base_image for start_instance to boot.
        """
        if not self.base_image:
            return defer.succeed(True)

        if self.cheap_copy:
            clone_cmd = "qemu-img"
            clone_args = "create -b %(base)s -f qcow2 %(image)s"
        else:
            clone_cmd = "cp"
            clone_args = "%(base)s %(image)s"

        clone_args = clone_args % {
            "base": self.base_image,
            "image": self.image,
        }

        log.msg("Cloning base image: %s %s'" % (clone_cmd, clone_args))

        d = utils.getProcessValue(clone_cmd, clone_args.split())

        def _log_result(res):
            log.msg("Cloning exit code was: %d" % res)
            return res

        def _log_error(err):
            log.err("Cloning failed: %s" % err)
            return err

        d.addCallbacks(_log_result, _log_error)

        return d
开发者ID:iskradelta,项目名称:buildbot,代码行数:35,代码来源:libvirt.py


示例5: test_is_mamba_package_for_egg_file

    def test_is_mamba_package_for_egg_file(self):

        result = yield utils.getProcessValue('mamba-admin', [], os.environ)
        if result == 1:
            raise unittest.SkipTest('mamba framework is not installed yet')

        with self._generate_docs():
            self.config.parseOptions()
            self.config['name'] = 'mamba-dummy'
            self.packer.pack_application(
                'bdist_egg', self.config,
                config.Application('config/application.json')
            )
            major, minor = sys.version_info[:2]
            self.assertTrue(os.path.exists(
                'mamba_dummy-0.1.2-py{}.{}.egg'.format(major, minor))
            )
            path = filepath.FilePath(
                'mamba_dummy-0.1.2-py{}.{}.egg'.format(major, minor)
            )
            is_mamba_package = self.packer.is_mamba_package(path)
            self.assertTrue(is_mamba_package)
            self.packer.do(
                ['rm', 'mamba_dummy-0.1.2-py{}.{}.egg'.format(major, minor)]
            )
开发者ID:saoili,项目名称:mamba-framework,代码行数:25,代码来源:test_mamba_admin.py


示例6: stop

 def stop(self, name):
     """ Stop the container.
         
         @param name:        Name of the container which should be stopped.
         @type  name:        str
         
         @param command:     Deferred whose callback is triggered on success
                             or whose errback is triggered on failure with
                             an error message.
         @type  command:     twisted::Deferred
     """
     log.msg("Stop container '{0}'".format(name))
     deferred = Deferred()
     
     try:
         dfrd = getProcessValue('/usr/bin/lxc-stop', ('-n', name),
                                env=os.environ, reactor=self._reactor)
         
         def cb(retVal):
             if retVal == 0:
                 deferred.callback('Container successfully stopped.')
             else:
                 e = ContainerError('Container could not be stopped: '
                                    'Received exit code {0} from '
                                    'lxc-stop.'.format(retVal))
                 deferred.errback(Failure(e))
         
         dfrd.addCallback(cb)
     except OSError:
         e = ContainerError('Insufficient system resources to stop a '
                            'process.')
         deferred.errback(Failure(e))
     
     return deferred
开发者ID:dreamfrog,项目名称:rce,代码行数:34,代码来源:container.py


示例7: run

 def run(self, type, text):
     d = getProcessValue(
         "zenity",
         args=(type, "--text", text),
         env=os.environ
     )
     return d
开发者ID:dpnova,项目名称:devdaemon,代码行数:7,代码来源:alerts.py


示例8: _doWork

        def _doWork():

            # only one 'word' can be in the command.
            # everything else gets split up and put in the args array
            command = "pwd"
            args = []

            # i can't think of a better example that will definitely run... but here's a beefier hypothetical example
            # to run the command: ./myProg input.txt output.txt --num_cats 5
            # it would look like:
            # command = "./myProg"
            # args = ["input.txt", "output.txt", "--num_cats", "5"]
            # or maybe this would also work
            # args = ["input.txt", "output.txt", "--num_cats 5"]

            # run another command with getProcessOutput [to capture the stdout output]
            # or with getProcessValue [to just capture the exit code of the command]
            out = yield utils.getProcessOutput(command, args)
            val = yield utils.getProcessValue(command, args)

            # printing is the same as logging
            print "getProcessOutput:", out
            print "getProcessValue:", val

            # here's how you get stuff to display back in the web browser
            request.write("getProcessOutput: %s" % out)

            # you can do as many request.writes as you like, whenever/whereever
            request.write("<br />getProcessValue: %d" % val)

            # finish the request so the browser doesn't expect more
            request.finish()

            # how you finish up a method that has the @defer.inlineCallbacks decorator
            defer.returnValue(None)
开发者ID:ktuite,项目名称:twisted-server-cpp-worker,代码行数:35,代码来源:commandLauncherServer.py


示例9: test_sql_create_live

    def test_sql_create_live(self):

        result = yield utils.getProcessValue('mamba-admin', [], os.environ)
        if result == 1:
            raise unittest.SkipTest('mamba framework is not installed yet')

        currdir = os.getcwd()
        os.chdir('../mamba/test/dummy_app/')

        cfg_file = filepath.FilePath('config/database.json')
        cfg_file_content = cfg_file.open('r').read()
        cfg_file_new = cfg_file_content.replace('dummy.db', 'dummy2.db')
        cfg_file.open('w').write(cfg_file_new)

        yield utils.getProcessOutput(
            'python', ['../../scripts/mamba_admin.py', 'sql', 'create', '-l'],
            os.environ
        )

        db_file = filepath.FilePath('db/dummy2.db')
        self.assertTrue(db_file.exists)
        db_file.remove()

        cfg_file.open('w').write(cfg_file_content)

        os.chdir(currdir)
开发者ID:cypreess,项目名称:mamba,代码行数:26,代码来源:test_mamba_admin.py


示例10: test_sql_reset

    def test_sql_reset(self):

        if skip_command_line_tests is True:
            raise unittest.SkipTest('skip_command_line_tests is set as True')

        result = yield utils.getProcessValue('mamba-admin', [], os.environ)
        if result == 1:
            raise unittest.SkipTest('mamba framework is not installed yet')

        currdir = os.getcwd()
        os.chdir('../mamba/test/dummy_app')
        db_file = filepath.FilePath('db/dummy.db')
        db_contents = db_file.open('rb').read()
        result = yield utils.getProcessOutput(
            'python',
            ['../../scripts/mamba_admin.py', 'sql', 'reset', '-n'],
            os.environ
        )

        self.assertEqual(
            result,
            'All the data in your database has been reset.\n')

        db_file.open('wb').write(db_contents)

        os.chdir(currdir)
开发者ID:cypreess,项目名称:mamba,代码行数:26,代码来源:test_mamba_admin.py


示例11: run_once

def run_once(executable, *args):
    """
    Runs a command, without looking at its output or return value.
    Returns a Deferred or None.
    """
    from twisted.internet import reactor
    global _original_environment_variables
    def _cb(result):
        #print(result)
        pass
    try:
        executable = procutils.which(executable)[0]
    except IndexError:
        log.error("Could not find executable %s" % (executable))
        return None
    else:
        env = _original_environment_variables
        for k in ["GTK2_RC_FILES", "GTK_RC_FILES"]:
            if env.has_key(k):
                log.info("%s=%s" % (k, env[k]))
        log.info("$ %s %s" % (executable, " ".join(list(args))))
        log.debug("ENV=%s" % (env))
        d = utils.getProcessValue(executable, args, env, '.', reactor)
        d.addCallback(_cb)
        return d
开发者ID:alg-a,项目名称:scenic,代码行数:25,代码来源:process.py


示例12: parallel

def parallel(count=None):
    coop = task.Cooperator()
    work = (getProcessValue(executable) for i in range(10))
    if count:
        return defer.DeferredList([coop.coiterate(work) for i in xrange(count)])
    else:
        return coop.coiterate(work)
开发者ID:812653525,项目名称:learntosolveit,代码行数:7,代码来源:networking_twisted_parallel2.py


示例13: _doWork

        def _doWork():

            # Answer Set Programming file details
            aspDir = "C:\Program Files\clingo-3.0.4-win32//"
            ruleSetDir = "C:\Program Files\clingo-3.0.4-win32//"
            aspFile = "ServerASPHelloWorld.lp"

            # only one 'word' can be in the command. 
            # everything else gets split up and put in the args array
            # if you were passing solver specific commands,
            # you could also pass to args something like "-n 4"
            # if you are in a unix-like environment, you will need to change 'clingo.exe' to just 'clingo'
            command = aspDir + "clingo.exe"
            args = [ruleSetDir + aspFile]
        
            # run another command with getProcessOutput [to capture the stdout output]
            # or with getProcessValue [to just capture the exit code of the command]
            out = yield utils.getProcessOutput(command, args)
            val = yield utils.getProcessValue(command, args)

            # printing is the same as logging
            print "getProcessOutput:", out
            print "getProcessValue:", val
        
            # here's how you get stuff to display back in the web browser
            request.write("getProcessOutput: %s" % out)

            # you can do as many request.writes as you like, whenever/whereever
            request.write("<br />getProcessValue: %d" % val)

            # finish the request so the browser doesn't expect more
            request.finish()
            
            # how you finish up a method that has the @defer.inlineCallbacks decorator
            defer.returnValue(None)
开发者ID:adrianPerez,项目名称:twisted-server-cpp-worker,代码行数:35,代码来源:aspLauncherServer.py


示例14: _check

def _check(unit):
    command = _HOST_COMMAND + [b"/usr/bin/systemctl", b"status"] + [unit]
    Message.new(
        system="log-agent:os-detection:journald",
        unit=unit,
        command=command,
    ).write()
    return getProcessValue(command[0], command[1:], env=environ)
开发者ID:ClusterHQ,项目名称:volume-hub-catalog-agents,代码行数:8,代码来源:_journallogs.py


示例15: testLog

 def testLog(self):
     exes = which("buildbot")
     if not exes:
         raise unittest.SkipTest("Buildbot needs to be installed")
     self.buildbotexe = exes[0]
     d = getProcessValue(self.buildbotexe, ["create-master", "--log-size=1000", "--log-count=2", "master"])
     d.addCallback(self._master_created)
     return d
开发者ID:pythonologist,项目名称:buildbot,代码行数:8,代码来源:test_limitlogs.py


示例16: test_value

    def test_value(self):
        """
        The L{Deferred} returned by L{getProcessValue} is fired with the exit
        status of the child process.
        """
        scriptFile = self.makeSourceFile(["raise SystemExit(1)"])

        d = utils.getProcessValue(self.exe, ['-u', scriptFile])
        return d.addCallback(self.assertEqual, 1)
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:9,代码来源:test_iutils.py


示例17: _do_exec

	def _do_exec(self, cmd, args, filename):
		if self.blocking:
			retval = call([cmd]+ args)
			return self._handle_process_run(retval, filename, args)
		else:
			d = utils.getProcessValue(cmd, args)
			d.addCallback(self._handle_process_run, filename, args)
			d.addErrback(self._handle_failure)
			return d
开发者ID:BGCX261,项目名称:zoto-server-svn-to-git,代码行数:9,代码来源:imagemanip.py


示例18: done

 def done(self):
     self.publish("Compressing")
     try:
         code = yield getProcessValue("/bin/tar", ["-cf", safe_format("./tmp/{}.tar", self.url), "-C", "./tmp/", self.url], os.environ, ".")
     except:
         self.publish("Failed to compress archive", True)
         shutil.rmtree(self.folder)
     else:
         self.cleanup()
开发者ID:Fugiman,项目名称:Tumblr-Backup,代码行数:9,代码来源:server.py


示例19: _uncleanSocketTest

    def _uncleanSocketTest(self, callback):
        self.filename = self.mktemp()
        source = ("from twisted.internet import protocol, reactor\n"
                  "reactor.listenUNIX(%r, protocol.ServerFactory(), wantPID=True)\n") % (self.filename,)
        env = {'PYTHONPATH': os.pathsep.join(sys.path)}

        d = utils.getProcessValue(sys.executable, ("-u", "-c", source), env=env)
        d.addCallback(callback)
        return d
开发者ID:Almad,项目名称:twisted,代码行数:9,代码来源:test_unix.py


示例20: configure_iface

    def configure_iface(self, iface, ip='', action='up'):
        """See :meth:`wader.common.interfaces.IOSPlugin.configure_iface`"""
        assert action in ['up', 'down']
        if action == 'down':
            args = [iface, action]
        else:
            args = [iface, ip, 'netmask', '255.255.255.255', '-arp', action]

        return utils.getProcessValue('/sbin/ifconfig', args, reactor=reactor)
开发者ID:andrewbird,项目名称:wader,代码行数:9,代码来源:linux.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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