Пример #1
0
def test_cbm():
    try:
        service_client = RpcClient(CbmService, port=PORT2)
        service_client.start()

        goto_quit = False
        while True:
            cmd = raw_input('请输入命令:')
            if cmd == 'q' or cmd == 'Q':
                goto_quit = True
                break
            elif cmd == 'c' or cmd == 'C':
                break
            if cmd in all_cmds:
                all_cmds[cmd](service_client.get())
                print '\n'
            else:
                print '命令%s未实现!!!' % cmd
        service_client.close()

        if goto_quit:
            # 关闭rpc服务器
            QuitServer()

    except Thrift.TException, tx:
        print '%s' % (tx.message)
Пример #2
0
def test_cbm():
  try:  
    service_client = RpcClient(CbmService, port=PORT2)
    service_client.start()

    goto_quit = False
    while True:
      cmd = raw_input('请输入命令:')
      if cmd == 'q' or cmd == 'Q':
        goto_quit = True
        break
      elif cmd == 'c' or cmd == 'C':
        break
      if cmd in all_cmds:
        all_cmds[cmd](service_client.get())
        print '\n'
      else:
        print '命令%s未实现!!!' % cmd
    service_client.close()

    if goto_quit:
      # 关闭rpc服务器
      QuitServer()

  except Thrift.TException, tx:
    print '%s' % (tx.message)
#
# SPDX-License-Identifier: Unlicense
"""
Home Assistant Remote Procedure Call for MacroPad.
"""
import time
import displayio
import terminalio
from adafruit_display_shapes.rect import Rect
from rpc import RpcClient, RpcError
from adafruit_display_text import label
from adafruit_macropad import MacroPad
from secrets import secrets

macropad = MacroPad()
rpc = RpcClient()

COMMAND_TOPIC = "macropad/peripheral"
SUBSCRIBE_TOPICS = ("stat/demoswitch/POWER", "stat/office-light/POWER")
ENCODER_ITEM = 0
KEY_LABELS = ("Demo", "Office")
UPDATE_DELAY = 0.25
NEOPIXEL_COLORS = {
    "OFF": 0xff0000,
    "ON": 0x00ff00,
}


class MqttError(Exception):
    """For MQTT Specific Errors"""
    pass
Пример #4
0
import os
import sys
lib_path = os.path.abspath(os.path.join(__file__, '..', '..'))
sys.path.append(lib_path)

from rpc import RpcClient

rpc_client = RpcClient()
rpc_client.call('add', data={'a': 3, 'b': 4})

response = rpc_client.call_and_wait('add', data={'a': 1, 'b': 1})
print(response.data)
Пример #5
0
# ----------------------------------------------------------------------------
# Copyright 2015 Nervana Systems Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------
from rpc import RpcClient
import sys

if len(sys.argv) != 2:
    print "Usage: python rpc_client <rpc_queue_name>"
    sys.exit(1)

# declare an rpc client listening on queue specified by first arg
neon_rpc = RpcClient(sys.argv[1])

arg = int(raw_input("Give an integer to pow: "))

print " [x] Making request"
response = neon_rpc.call(arg)
print " [.] Got %r" % (response,)
Пример #6
0
from rpc import RpcClient

with RpcClient('http://localhost:8000') as client:
    print("3 is even: {}".format(client.is_even(3)))
    print("100 is even: {}".format(client.is_even(100)))