Example #1
0
 def param_comparison_uses_config(self):
     conf = Config(overrides={"user": "******"})
     c = Connection(
         user="******", host="myhost", port=123, config=conf
     )
     template = "<Connection host=myhost port=123>"
     assert repr(c) == template
Example #2
0
 def accepts_configuration_value(self):
     gw = Connection("jumpbox")
     config = Config(overrides={"gateway": gw})
     # TODO: the fact that they will be eq, but _not_ necessarily be
     # the same object, could be problematic in some cases...
     cxn = Connection("host", config=config)
     assert cxn.gateway == gw
Example #3
0
 def kwarg_wins_over_config(self):
     # TODO: should this be more of a merge-down?
     c = Config(overrides={"connect_kwargs": {"origin": "config"}})
     cxn = Connection("host",
                      connect_kwargs={"origin": "kwarg"},
                      config=c)
     assert cxn.connect_kwargs == {"origin": "kwarg"}
Example #4
0
 def can_be_specified(self):
     c = Config(overrides={"user": "******", "custom": "option"})
     config = Connection("host", config=c).config
     assert c is config
     assert config["user"] == "me"
     assert config["custom"] == "option"
Example #5
0
 def kwarg_wins_over_config(self):
     config = Config(overrides={"timeouts": {"connect": 20}})
     cxn = Connection("host", connect_timeout=100, config=config)
     assert cxn.connect_timeout == 100
Example #6
0
 def accepts_configuration_value(self):
     config = Config(overrides={"timeouts": {"connect": 10}})
     assert Connection("host", config=config).connect_timeout == 10
Example #7
0
 def kwarg_wins_over_config(self):
     config = Config(overrides={"forward_agent": True})
     cxn = Connection("host", forward_agent=False, config=config)
     assert cxn.forward_agent is False
Example #8
0
 def accepts_configuration_value(self):
     config = Config(overrides={"forward_agent": True})
     assert Connection("host", config=config).forward_agent is True
Example #9
0
        metavar="JSON",
        default=os.path.join(os.path.dirname(__file__), "config.json"),
    )
    args = parser.parse_args()

    video = _cv.VideoCapture("target_p04_diff.mp4")
    diff_frames: _np.ndarray = _get_frames(video, grayscale=True)
    fps = video.get(_cv.CAP_PROP_FPS)
    width = int(video.get(_cv.CAP_PROP_FRAME_WIDTH))
    height = int(video.get(_cv.CAP_PROP_FRAME_HEIGHT))
    video.release()
    del video

    codec = _cv.VideoWriter_fourcc(*"mp4v")

    cfg = Config(args.config)
    displaymanager = _DisplayManager(diff_frames, cfg)
    displaymanager.topmost = args.topmost

    if not args.adjust and not args.adjust_separate:
        print("Detecting LEDs...")
        output = _cv.VideoWriter("target_p05_detect.mp4", codec, fps,
                                 (width, height))

        displaymanager.display_contours = True
        displaymanager.display_hulls = True
        displaymanager.display_rectangles = True
        displaymanager.show = False
        for i in range(displaymanager.frames.shape[0]):
            displaymanager.frame_number = i
            output.write(displaymanager.update_image())
Example #10
0
 def kwarg_wins_over_config(self):
     config = Config(overrides={"port": 2222})
     cxn = Connection("host", port=123, config=config)
     assert cxn.port == 123
Example #11
0
 def accepts_configuration_port(self):
     config = Config(overrides={"port": 2222})
     assert Connection("host", config=config).port == 2222
Example #12
0
 def shorthand_wins_over_config(self):
     config = Config(overrides={"user": "******"})
     cxn = Connection("somebody@host", config=config)
     assert cxn.user == "somebody"
Example #13
0
 def kwarg_wins_over_config(self):
     config = Config(overrides={"user": "******"})
     cxn = Connection("host", user="******", config=config)
     assert cxn.user == "somebody"
Example #14
0
 def accepts_config_user_option(self):
     config = Config(overrides={"user": "******"})
     assert Connection("host", config=config).user == "nobody"
Example #15
0
 def may_be_configured(self):
     c = Config(overrides={"connect_kwargs": {"origin": "config"}})
     cxn = Connection("host", config=c)
     assert cxn.connect_kwargs == {"origin": "config"}
Example #16
0
 def shorthand_wins_over_config(self):
     config = Config(overrides={"port": 2222})
     cxn = Connection("host:123", config=config)
     assert cxn.port == 123
Example #17
0
 def defaults_to_config_value(self):
     assert Connection("host").inline_ssh_env is False
     config = Config({"inline_ssh_env": True})
     assert Connection("host", config=config).inline_ssh_env is True