def setUp(self): self.host = "0.0.0.0" self.cam_port = 8888 self.pipeline_port = 8889 self.cam_proxy_port = 8898 self.pipeline_proxy_port = 8899 for port in self.cam_port, self.pipeline_port, self.cam_proxy_port, self.pipeline_proxy_port: print("Port ", port, "avilable: ", is_port_available(port)) test_base_dir = os.path.split(os.path.abspath(__file__))[0] self.cam_config_folder = os.path.join(test_base_dir, "camera_config/") self.pipeline_config_folder = os.path.join(test_base_dir, "pipeline_config/") self.background_config_folder = os.path.join(test_base_dir, "background_config/") self.user_scripts_folder = os.path.join(test_base_dir, "user_scripts/") require_folder(self.background_config_folder) require_folder(self.user_scripts_folder) cam_server_address = "http://%s:%s" % (self.host, self.cam_port) pipeline_server_address = "http://%s:%s" % (self.host, self.pipeline_port) cam_server_proxy_address = "http://%s:%s" % (self.host, self.cam_proxy_port) pipeline_server_proxy_address = "http://%s:%s" % ( self.host, self.pipeline_proxy_port) self.cam_process = Process(target=start_camera_server, args=(self.host, self.cam_port, self.cam_config_folder, self.user_scripts_folder)) self.cam_process.start() self.cam_proxy_process = Process(target=start_camera_proxy, args=(self.host, self.cam_proxy_port, cam_server_address, self.cam_config_folder)) self.cam_proxy_process.start() self.pipeline_process = Process( target=start_pipeline_server, args=(self.host, self.pipeline_port, self.pipeline_config_folder, self.background_config_folder, self.user_scripts_folder, cam_server_proxy_address)) self.pipeline_process.start() self.pipeline_proxy_process = Process( target=start_pipeline_proxy, args=(self.host, self.pipeline_proxy_port, pipeline_server_address, self.pipeline_config_folder, self.background_config_folder, self.user_scripts_folder, cam_server_proxy_address)) self.pipeline_proxy_process.start() self.cam_client = CamClient(cam_server_proxy_address) self.pipeline_client = PipelineClient(pipeline_server_proxy_address) # Give it some time to start. sleep(1.0) # Give it some time to start.
def test_scripts_manager(self): require_folder("user_scripts/") scripts_manager = UserScriptsManager("user_scripts/") script_name = "Test.py" script_content = "print('Hello world')" scripts_manager.save_script(script_name, script_content) try: scripts = scripts_manager.get_scripts() self.assertIn(script_name, scripts) ret = scripts_manager.get_script(script_name) self.assertEqual(ret, script_content) finally: os.remove(os.path.join(scripts_manager.scripts_folder, "Test.py"), )
def setUp(self): self.host = "0.0.0.0" self.port = 8888 test_base_dir = os.path.split(os.path.abspath(__file__))[0] self.config_folder = os.path.join(test_base_dir, "camera_config/") self.background_folder = os.path.join(test_base_dir, "background_config/") self.user_scripts_folder = os.path.join(test_base_dir, "user_scripts/") require_folder(self.background_folder) self.process = Process(target=start_camera_server, args=(self.host, self.port, self.config_folder, self.user_scripts_folder)) self.process.start() # Give it some time to start. sleep(0.5) server_address = "http://%s:%s" % (self.host, self.port) self.client = CamClient(server_address)
def setUp(self): self.host = "localhost" self.cam_port = 8888 self.pipeline_port = 8889 test_base_dir = os.path.split(os.path.abspath(__file__))[0] self.cam_config_folder = os.path.join(test_base_dir, "camera_config/") self.pipeline_config_folder = os.path.join(test_base_dir, "pipeline_config/") self.background_config_folder = os.path.join(test_base_dir, "background_config/") self.user_scripts_folder = os.path.join(test_base_dir, "user_scripts/") require_folder(self.background_config_folder) require_folder(self.user_scripts_folder) cam_server_address = "http://%s:%s" % (self.host, self.cam_port) pipeline_server_address = "http://%s:%s" % (self.host, self.pipeline_port) self.cam_process = Process(target=start_camera_server, args=(self.host, self.cam_port, self.cam_config_folder, None)) self.cam_process.start() self.pipeline_process = Process( target=start_pipeline_server, args=(self.host, self.pipeline_port, self.pipeline_config_folder, self.background_config_folder, self.user_scripts_folder, cam_server_address)) self.pipeline_process.start() # Give it some time to start. sleep(1) self.cam_client = CamClient(cam_server_address) self.pipeline_client = PipelineClient(pipeline_server_address)
def setUp(self): test_base_dir = os.path.split(os.path.abspath(__file__))[0] self.cam_config_folder = os.path.join(test_base_dir, "camera_config/") self.pipeline_config_folder = os.path.join(test_base_dir, "pipeline_config/") self.background_config_folder = os.path.join(test_base_dir, "background_config/") self.user_scripts_folder = os.path.join(test_base_dir, "user_scripts/") self.temp_folder = os.path.join(test_base_dir, "temp/") require_folder(self.background_config_folder) require_folder(self.user_scripts_folder) require_folder(self.temp_folder) self.host = "localhost" self.cam_server_ports = [8880, 8881] self.cam_manager_port = 8888 self.pipeline_server_ports = [8890, 8891] self.pipeline_manager_port = 8889 self.cam_server_address = [] self.process_camserver = [] port_range = config.CAMERA_STREAM_PORT_RANGE for p in self.cam_server_ports: port_range = [port_range[0] + 10000, port_range[1] + 10000] self.cam_server_address.append("http://%s:%s" % (self.host, p)) process = Process(target=start_camera_worker, args=(self.host, p, self.user_scripts_folder, None, port_range)) self.process_camserver.append(process) process.start() self.cam_proxy_host = "0.0.0.0" self.process_camproxy = Process( target=start_camera_manager, args=(self.host, self.cam_manager_port, ",".join(self.cam_server_address), self.cam_config_folder, self.user_scripts_folder)) self.process_camproxy.start() cam_server_proxy_address = "http://%s:%s" % (self.host, self.cam_manager_port) pipeline_server_proxy_address = "http://%s:%s" % ( self.host, self.pipeline_manager_port) self.pipeline_server_address = [] self.process_pipelineserver = [] port_range = config.PIPELINE_STREAM_PORT_RANGE for p in self.pipeline_server_ports: port_range = [port_range[0] + 10000, port_range[1] + 10000] self.pipeline_server_address.append("http://%s:%s" % (self.host, p)) process = Process(target=start_pipeline_worker, args=(self.host, p, self.temp_folder, self.temp_folder, cam_server_proxy_address, None, port_range)) self.process_pipelineserver.append(process) process.start() cfg = """{ "http://localhost:8890": { "expanding": true }, "http://localhost:8891": { "cameras": [ "simulation3" ], "expanding": false, "instances": [ "simulation_sp:10123" ] } }""" self.pipeline_proxy_process = Process( target=start_pipeline_manager, args=(self.host, self.pipeline_manager_port, cfg, self.pipeline_config_folder, self.background_config_folder, config.DEFAULT_BACKGROUND_FILES_DAYS_TO_LIVE, self.user_scripts_folder, cam_server_proxy_address)) self.pipeline_proxy_process.start() sleep(1.0) # Give it some time to start. cam_server_address = "http://%s:%s" % (self.host, self.cam_manager_port) self.cam_client = CamClient(cam_server_address) pipeline_server_address = "http://%s:%s" % (self.host, self.pipeline_manager_port) self.pipeline_client = PipelineClient(pipeline_server_address) self.cam_proxy_client = ProxyClient(cam_server_address) self.pipeline_proxy_client = ProxyClient(pipeline_server_address)