1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
import RobotRaconteur as RR
from .ServiceTest import testroot_impl
from .ServiceTest2 import testroot3_impl
from .ServiceTest3 import asynctestroot_impl
import os
try:
raw_input # type: ignore
except NameError:
raw_input = input
def main():
robdef_path = os.path.abspath(os.path.dirname(
os.path.abspath(__file__)) + "/../../robdef")
os.environ["ROBOTRACONTEUR_ROBDEF_PATH"] = robdef_path
node = RR.RobotRaconteurNode()
node.Init()
node.RegisterServiceTypesFromFiles(["com.robotraconteur.testing.TestService2", "com.robotraconteur.testing.TestService1",
"com.robotraconteur.testing.TestService3", "com.robotraconteur.testing.TestService4", "com.robotraconteur.testing.TestService5"])
with RR.ServerNodeSetup("py_testprog", 22223, node=node) as node_setup:
t = node_setup.tcp_transport
t2 = testroot_impl(t)
ctx = node.RegisterService("RobotRaconteurTestService",
"com.robotraconteur.testing.TestService1.testroot", t2)
ctx.LogCandidateConnectionURLs()
t3 = testroot_impl(t)
authdata = "testuser1 0b91dec4fe98266a03b136b59219d0d6 objectlock\ntestuser2 841c4221c2e7e0cefbc0392a35222512 objectlock\ntestsuperuser 503ed776c50169f681ad7bbc14198b68 objectlock,objectlockoverride"
p = RR.PasswordFileUserAuthenticator(authdata)
policies = {"requirevaliduser": "true", "allowobjectlock": "true"}
s = RR.ServiceSecurityPolicy(p, policies)
node.RegisterService("RobotRaconteurTestService_auth",
"com.robotraconteur.testing.TestService1.testroot", t3, s)
t4 = testroot3_impl()
c = node.RegisterService("RobotRaconteurTestService2",
"com.robotraconteur.testing.TestService3.testroot3", t4)
c.RequestObjectLock("RobotRaconteurTestService2.nolock_test", "server")
t3 = asynctestroot_impl()
c = node.RegisterService("RobotRaconteurTestService3",
"com.robotraconteur.testing.TestService5.asynctestroot", t3)
print("Server ready")
raw_input("Press enter to quit")
if __name__ == "__main__":
main()
|