| | |
| | | def _on_sys_command(self, req: pb.RequestCommand, resp: pb.ResponseCommand): |
| | | if pb.SubCommand.POWER_ON_SUB_COMMAND == req.sub_command: |
| | | print('power on message received') |
| | | self._device_manager.get_device(req.device_id) |
| | | self._device_manager.get_device(req.device_id,save_folder) |
| | | elif pb.SubCommand.POWER_OFF_SUB_COMMAND == req.sub_command: |
| | | device = self._device_manager.get_device(req.device_id) |
| | | device = self._device_manager.get_device(req.device_id,save_folder) |
| | | device['power_on'] = False |
| | | print('power off message received') |
| | | return |
| | |
| | | |
| | | |
| | | if __name__ == "__main__": |
| | | def help(): |
| | | print("Usage: Server.py [MQhost] [MQuser] [MQpassword] [QUEUEname] [WEBport] [SAVEfolder]") |
| | | print("EXAMPLE: Server.py localhost chai password123 aerial_rpc 5000 ./Images") |
| | | exit(1) |
| | | |
| | | if len(sys.argv) != 7: |
| | | help() |
| | | try: |
| | | MQhost = str(sys.argv[1]) |
| | | MQuser = str(sys.argv[2]) |
| | | MQpassword = str(sys.argv[3]) |
| | | QUEUEname = str(sys.argv[4]) |
| | | WEBport = int(sys.argv[5]) |
| | | SAVEfolder = str(sys.argv[6]) |
| | | global save_folder |
| | | save_folder = SAVEfolder |
| | | |
| | | except Exception as e: |
| | | print(e) |
| | | help() |
| | | server = MyServer(host="localhost", user='chai', password='password123', queue='aerial_rpc', port=5000) |
| | | server.run_all() |