def test_login(self): response = self.login.api.login("13800000002", "123456") jsonDate = response.json() logging.info("登陆成功返回的数据:{}", format(jsonDate)) assert_common(self, response, 200, True, 10000, "操作成功") token = jsonDate.get("date") app.HEADERS["Autherization"] = "Bearer" + token logging.info("保存的令牌时:{}".format(app.HEADERS))
def test01_login_success(self): response = self.login_api.login("13800000002", "123456") jsonData = response.json() logging.info("登录成功返回数据 : {}".format(jsonData)) # 断言 # self.assertEqual(200, response.status_code) # self.assertEqual(True, jsonData.get("success")) # self.assertEqual(10000, jsonData.get("code")) # self.assertIn("操作成功", jsonData.get("message")) assert_common(self, response, 200, True, 10000, "操作成功")
def run(self): try: with PiCamera() as capture: capture.resolution = self._target_resolution capture.framerate = self._target_fps raw_capture = PiRGBArray(capture, size=self._target_resolution) for frame in capture.capture_continuous(raw_capture, format="bgr", use_video_port=True): if not self._stop_queue.empty(): logging.info("The stop queue is not empty. Stop acquiring frames") self._stop_queue.get() self._stop_queue.task_done() logging.info("Stop Task Done") break raw_capture.truncate(0) # out = np.copy(frame.array) out = cv2.cvtColor(frame.array,cv2.COLOR_BGR2GRAY) self._queue.put(out) finally: self._stop_queue.close() self._queue.close() logging.info("Camera Frame grabber stopped acquisition cleanly")
def __init__(self, target_fps=10, target_resolution=(960, 720), *args, **kwargs): logging.info("Initialising camera") w, h = target_resolution if not isinstance(target_fps, int): raise EthoscopeException("FPS must be an integer number") self._queue = multiprocessing.Queue(maxsize=2) self._stop_queue = multiprocessing.JoinableQueue(maxsize=1) self._p = PiFrameGrabber(target_fps, target_resolution, self._queue, self._stop_queue) self._p.daemon = True self._p.start() im = self._queue.get(timeout=5) self._frame = cv2.cvtColor(im, cv2.COLOR_GRAY2BGR) if len(im.shape) < 2: raise EthoscopeException( "The camera image is corrupted (less that 2 dimensions)") self._resolution = (im.shape[1], im.shape[0]) if self._resolution != target_resolution: if w > 0 and h > 0: logging.warning( 'Target resolution "%s" could NOT be achieved. Effective resolution is "%s"' % (target_resolution, self._resolution)) else: logging.info('Maximal effective resolution is "%s"' % str(self._resolution)) super(OurPiCameraAsync, self).__init__(*args, **kwargs) self._start_time = time.time() logging.info("Camera initialised")
def create_pool(loop, **kw): logging.info('create database connection pool^')
def _close(self): logging.info("Requesting grabbing process to stop!") self._stop_queue.put(None) while not self._queue.empty(): self._queue.get() logging.info("Joining stop queue") self._stop_queue.cancel_join_thread() self._queue.cancel_join_thread() logging.info("Stopping stop queue") self._stop_queue.close() logging.info("Stopping queue") self._queue.close() logging.info("Joining process") self._p.join() logging.info("All joined ok")