client.py

来自「MANTIS是由科罗拉多大学开发的传感器网络嵌入式操作系统。 这是mantis」· Python 代码 · 共 31 行

PY
31
字号
# This file is part of MANTIS OS, Operating System# See http://mantis.cs.colorado.edu/## Copyright (C) 2003-2005 University of Colorado, Boulder## This program is free software; you can redistribute it and/or# modify it under the terms of the mos license (see file LICENSE)import sysfrom twisted.spread import pbfrom twisted.internet import reactorfrom twisted.python import util# Connect to the serverfactory = pb.PBClientFactory()reactor.connectTCP("localhost", 1529, factory)# Get our node idnode_id = sys.argv[1]# Since it could take a while to connect and get the object, getRootObject# returns a deferred object.  This is an object we can attach callbacks to# so that when a connection is eventually made it will be handled.  In the# meantime we don't have to block, we just start running.d = factory.getRootObject()d.addCallback(lambda object: object.callRemote("register", node_id))d.addErrback(lambda reason: 'error: '+str(reason.value))d.addCallback(util.println)d.addCallback(lambda _: reactor.stop())reactor.run()

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?