Skip to content

Commit

Permalink
Renamed quiet option to headless
Browse files Browse the repository at this point in the history
  • Loading branch information
fernando79513 committed Aug 28, 2024
1 parent 5c3c49a commit 39cca8e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
20 changes: 10 additions & 10 deletions providers/base/bin/camera_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def __init__(self, **kwargs):
self._height = 480
self._devices = []
self.device = kwargs.get("device", "/dev/video0")
self.quiet = kwargs.get("quiet", False)
self.headless = kwargs.get("headless", False)
self.output = kwargs.get("output", "")
self.log_level = kwargs.get("log_level", logging.INFO)

Expand Down Expand Up @@ -346,7 +346,7 @@ def video(self):
Displays the preview window for a video stream
"""
# Don't display the video, just run the camera
if self.quiet:
if self.headless:
self.main_loop = self.GLib.MainLoop()
self.GLib.timeout_add_seconds(4, self._stop_pipeline)
self._setup_video_gstreamer("fakesink")
Expand Down Expand Up @@ -446,7 +446,7 @@ def _still_image_helper(self, filename, width, height, pixelformat):
if use_gstreamer:
self._capture_image_gstreamer(filename, width, height, pixelformat)
print("Image saved to %s" % filename)
if not self.quiet:
if not self.headless:
self._display_image(filename, width, height)

def _capture_image_fswebcam(self, filename, width, height, pixelformat):
Expand Down Expand Up @@ -611,7 +611,7 @@ def resolutions(self):
take multiple images using the first format returned by the driver,
and see if they are valid
"""
self.quiet = True
self.headless = True

format = self._get_default_format()
print(
Expand Down Expand Up @@ -910,10 +910,10 @@ def add_device_parameter(parser):
# Video subparser
video_parser = subparsers.add_parser("video")
add_device_parameter(video_parser)
# add a quiet option false by default
# add a headless option, false by default
video_parser.add_argument(
"-q",
"--quiet",
"-hl",
"--headless",
action="store_true",
help=("Don't display video, just run the camera"),
)
Expand All @@ -928,8 +928,8 @@ def add_device_parameter(parser):
help="Output directory to store the image",
)
image_parser.add_argument(
"-q",
"--quiet",
"-hl",
"--headless",
action="store_true",
help=("Don't display picture, just write the picture to a file"),
)
Expand Down Expand Up @@ -977,7 +977,7 @@ def get_video_devices():
camera.init_gstreamer()

# Import Gtk only for the test cases that will need it
if args["test"] in ["video", "image"] and not args["quiet"]:
if args["test"] in ["video", "image"] and not args["headless"]:
camera.init_gtk()

sys.exit(getattr(camera, args["test"])())
20 changes: 10 additions & 10 deletions providers/base/tests/test_camera_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ class CameraTestTests(unittest.TestCase):
def test_init(self):
mock_camera = CameraTest(
device="/dev/video1",
quiet=True,
headless=True,
output="/tmp",
log_level=logging.DEBUG,
)
self.assertEqual(mock_camera.device, "/dev/video1")
self.assertEqual(mock_camera.quiet, True)
self.assertEqual(mock_camera.headless, True)
self.assertEqual(mock_camera.output, "/tmp")
self.assertEqual(mock_camera.log_level, logging.DEBUG)

Expand Down Expand Up @@ -268,14 +268,14 @@ def test_led(self):

def test_video(self):
mock_camera = MagicMock()
mock_camera.quiet = False
mock_camera.headless = False
CameraTest.video(mock_camera)
self.assertEqual(mock_camera.GLib.timeout_add_seconds.call_count, 1)
self.assertEqual(mock_camera._setup_video_gstreamer.call_count, 1)

def test_video_quiet(self):
def test_video_headless(self):
mock_camera = MagicMock()
mock_camera.quiet = True
mock_camera.headless = True
CameraTest.video(mock_camera)
self.assertEqual(mock_camera.GLib.timeout_add_seconds.call_count, 1)
self.assertEqual(mock_camera._setup_video_gstreamer.call_count, 1)
Expand Down Expand Up @@ -372,17 +372,17 @@ def test_still_image_helper(self):
mock_camera = MagicMock()
mock_camera._capture_image_fswebcam.return_value = True
mock_camera._display_image.return_value = True
mock_camera.quiet = False
mock_camera.headless = False
CameraTest._still_image_helper(
mock_camera, "/tmp/test.jpg", 640, 480, "YUYV"
)
self.assertEqual(mock_camera._capture_image_fswebcam.call_count, 1)
self.assertEqual(mock_camera._display_image.call_count, 1)

def test_still_image_quiet(self):
def test_still_image_headless(self):
mock_camera = MagicMock()
mock_camera._capture_image_fswebcam.return_value = True
mock_camera.quiet = True
mock_camera.headless = True
CameraTest._still_image_helper(
mock_camera, "/tmp/test.jpg", 640, 480, "YUYV"
)
Expand Down Expand Up @@ -793,12 +793,12 @@ def test_image_subparser(self):
"/dev/video2",
"-o",
"/tmp/test.jpg",
"-q",
"-hl",
]
args = parse_arguments(argv)
self.assertEqual(args["device"], "/dev/video2")
self.assertEqual(args["output"], "/tmp/test.jpg")
self.assertEqual(args["quiet"], True)
self.assertEqual(args["headless"], True)

def test_debug_flag(self):
argv = ["detect"]
Expand Down

0 comments on commit 39cca8e

Please sign in to comment.