import time import Ice import sys import traceback import RecordVideo status = 0 ic = None try: # 初始化运行环境 ic = Ice.initialize(sys.argv) # 获取远程printer服务的代理 base = ic.stringToProxy("LoopRecordVideoServer:default -p 10010") # 请求服务端确认:”这是不是 Demo::Printer的代理接口?“ printer = RecordVideo.LoopRecorderPrx.checkedCast(base) if not printer: raise RuntimeError("Invalid proxy") str_json = "{\"rtsp\":\"rtsp://admin:a1234567@192.168.1.188:554/h264/ch1/main/av_stream\"," \ "\"path\":\"/home/bsk/test/2/" # 远程调用,看起来像本地的服务一样 # ti = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) # str1 = str_json + ti + ".mp4\"}" # print(str1) # printer.addCamera("2", "test") time.sleep(2) ti1 = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) str2 = str_json + ti1 + ".mp4\"}" print(str2) str_key = printer.addCamera("2", str2) print(str_key) # time.sleep(2) # ti1 = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) # str2 = str_json + ti1 + ".mp4\"}" # print(str2) # printer.addCamera("2", str2) # printer.addCamera("2", "test") # time.sleep(2) # ti3 = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) # str3 = str_json + ti3 + ".mp4\"}" # print(str2) # printer.addCamera("3", str3) # # printer.removeCamera("2") # # printer.removeCamera("2") while True: printer.feedDog("2") time.sleep(1) except: traceback.print_exc() status = 1 if ic: # Clean up try: ic.destroy() except: traceback.print_exc() status = 1 sys.exit(status)