Example #1
0
    def hprose_client(self, ip, index, ty='open'):
        print("启动模拟器 IP  : " + ip + "  Index : " + str(index))
        client = hprose.HttpClient('http://' + ip + ':8181/')
        d = {'type': ty, 'data': index}
        data = json.dumps(d)

        return client.send_data(data)
Example #2
0
    def __init__(self, config=None):
        self.config = config or {}
        [config.setdefault(k, v) for k, v in default_config.items()]

        self.rpc_server = uri = config.get("rpc_server")
        self.client = hprose.HttpClient(uri)

        self.port = port = config.get("port")
        self.server = server = hprose.HttpServer(port=port)
        server.addFunctions([
            self.ping, self.notice, self.restart, self.discover, self.reset,
            self.onGPIO, self.progress
        ])

        self.simulator_stop = False
        self.pid = None

        self._simu_restarted_performed = False

        self.logfile = config.get("logfile")
        with open(self.logfile, "w") as f:
            print("", file=f)

        self.printl("[  SI-INFO  ] Simulator initialized : \n%s" %
                    json.dumps(self.config, indent=4))
Example #3
0
def ip_address():
	date = datetime.now()
	logs = open('calls.log', 'a')
	log_value =  ''+str(date)+ '-' + request.path +'\n'
	logs.write(log_value)
	
	client = hprose.HttpClient("http://127.0.0.1:8080/");
	
	return client.getIp()
Example #4
0
    def hprose_atx(self, ip, index):
        client = hprose.HttpClient('http://' + ip + ':8181/')

        la = random.randint(699999, 999990)

        ln = random.randint(390000, 599999)

        point = "126.%d,37.%d" % (la, ln)

        return client.run_atx(index, point)
Example #5
0
def main():
    client = hprose.HttpClient('http://127.0.0.1:8181/')
    client.filter = MyFilter()
    print(client.send_data({
        "Mon": 1,
        "Tue": 2,
        "Wed": {
            "i1": "Wed",
            "i2": 5
        }
    }))
Example #6
0
    def __init__(self, config=None):

        self.config = config = config or {}
        [config.setdefault(k, v) for k, v in default_config.items()]

        try:
            globals().update(
                importlib.import_module(config.get("environ")).__dict__)
        except:
            pass

        self.rpc_server = uri = config.get("rpc_server")
        self.client = hprose.HttpClient(uri)

        self.host = host = config.get("host")
        self.port = port = config.get("port")
        self.server = server = hprose.HttpServer(host=host, port=port)
        server.addFunctions([
            self.notice, self.update, self.isUpdating, self.cancelUpdate,
            self.isCancellingUpdate, self.readGPIO, self.listenGPIO,
            self.cancelListenGPIO, self.writeGPIO
        ])

        self.gpio = {}
        self.led_stop = False
        self.led_current_blink = ()
        self.monitor_stop = False
        self.ping_enabled = False
        self.master_pid = None

        self.tid = None
        self.update_progress = (0, "", 0)
        self.update_cancelling = False
        self.enable_report_update_progress = False

        # self.device_on_going = None
        self.mass_storage_usbdev_listerner = MassStorageUSBListerner()

        self.debug = config.get("debug")

        self.logfile = config.get("logfile")
        if self.logfile:
            with open(self.logfile, "w") as f:
                print("", file=f)

        atexit.register(self.atexit)

        self.discover_off()

        self.log("[  MO-INFO  ] Monitor initialized . Confirgurations: \n%s" %
                 json.dumps(self.config, indent=4))
Example #7
0
 def hprose_num(self, ip):
     client = hprose.HttpClient('http://' + ip + ':8181/')
     return client.get_running(11)
Example #8
0
 def hprose_isrunning(self, ip, index):
     client = hprose.HttpClient('http://' + ip + ':8181/')
     return client.is_running(index)
Example #9
0
def main():
    client = hprose.HttpClient('http://127.0.0.1:8181/')
    print(client.hello("World"))
def hprose_c():
    client = hprose.HttpClient('http://127.0.0.1:8080/')
    output = [{"node_server": {"server ip address": client.ping()}}]
    return jsonify(output)
Example #11
0
 def __connect_dispatcher(
         self, dispatcher: Dispatcher) -> hprose.HproseHttpClient:
     return hprose.HttpClient(uri=dispatcher.rpc())
Example #12
0
def main():
    client = hprose.HttpClient(
        'http://localhost/my/cxtx-web/web/test/api/hprose')
    print(client.hello('world'))
Example #13
0
def pingrpc():
    client = hprose.HttpClient('http://127.0.0.1:8080/')
    return client.ping("World")