示例#1
0
# -*- encoding: utf-8 -*-
# File: test_rpc.py
# Date: 20111210
# Author: notedit

import time
import rpc

@rpc.remote()
def now():
    return time.strftime('%Y-%m-%d %H:%M:%S')

@rpc.remote()
def add(x,y):
    return x+y

@rpc.remote()
def inc2(x):
    return x+2

@rpc.remote()
def raiseerror():
    raise rpc.BackendError('dfdfdf','dfdfdfdfdfdfdf')


if __name__ == '__main__':
    rpc.start(port=27019)
示例#2
0
 def start(self ):
     self.rpc_server = rpc.start(self.address, self.scheduler, self.debug)
     logging.notice( "distrubuted scheduler started" )
     self.scheduler.start()
示例#3
0
            }
        else:
            status["timestamps"] = {
                "end":
                int(time.time()) - int(cmus_dict["position"]) +
                int(cmus_dict["duration"])
            }

    elif cmus_dict["status"] == "playing" or cmus_dict["status"] == "paused":
        filename = re.match(".*\/([^\.]+)\..", cmus_dict["file"]).group(
            1)  # regex by @LiquidFenrir :)
        status["details"] = "{0}".format(filename)
    return status


client_id = "409516139404853248"
rpc = rpc.DiscordRPC(client_id)
rpc.start()
print("RPC init finished")
cmus = remote.PyCmus()
print("cmus connection opened")

signal.signal(signal.SIGINT, signal_handler)

config = config_loader()

while True:
    status = cmus.get_status_dict()
    rpc.send_rich_presence(parse(status))
    time.sleep(15)
示例#4
0
import rpc


class NoopModelWrapper(rpc.ModelWrapperBase):
    def __init__(self):
        print("NoopModelWrapper init code running")

    def predict_ints(self, inputs):
        print("predicting %d integer inputs" % len(inputs))
        return np.arange(1, len(inputs) + 1).astype('float64')

    def predict_floats(self, inputs):
        print("predicting %d float inputs" % len(inputs))
        return np.arange(1, len(inputs) + 1).astype('float64')

    def predict_bytes(self, inputs):
        print("predicting %d byte inputs" % len(inputs))
        return np.arange(1, len(inputs) + 1).astype('float64')

    def predict_strings(self, inputs):
        print("predicting %d string inputs" % len(inputs))
        for item in inputs:
            print(item)
        return np.arange(1, len(inputs) + 1).astype('float64')


if __name__ == '__main__':
    model = NoopModelWrapper()
    rpc.start(model, "127.0.0.1", 6001)