def pytest_runtest_setup(item): global recorder if vid_options and vid_options['enabled']: vid_log_path = log_path.join(vid_options['dir']) vid_dir, vid_name = get_path_and_file_name(item) full_vid_path = vid_log_path.join(vid_dir) try: os.makedirs(full_vid_path.strpath) except OSError: pass vid_name = vid_name + ".ogv" recorder = Recorder(full_vid_path.join(vid_name).strpath) recorder.start() yield
def start_test(self, artifact_path, test_name, test_location, slaveid): test_ident = "{}/{}".format(test_location, test_name) if test_ident in self.tests: if self.tests[test_ident].in_progress: print("Test already running, can't start another") return None else: self.tests[test_ident] = self.Test(test_ident) self.tests[test_ident].in_progress = True artifacts = [] os_filename = self.ident + ".ogv" os_filename = os.path.join(artifact_path, os_filename) if os.path.isfile(os_filename): os.remove(os_filename) artifacts.append(os_filename) try: self.tests[test_ident].recorder = Recorder(os_filename, display=self.display, quality=self.quality) self.tests[test_ident].recorder.start() except Exception as e: print(e) self.tests[test_ident].in_progress = True for filename in artifacts: self.fire_hook('filedump', test_location=test_location, test_name=test_name, description="Video recording", file_type="video", contents="", display_glyph="camera", dont_write=True, os_filename=filename, group_id="misc-artifacts", slaveid=slaveid)
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """Video recording script. Use when you want to record something separately """ import time from argparse import ArgumentParser, RawDescriptionHelpFormatter from cfme.utils.video import Recorder parser = ArgumentParser( epilog=__doc__, formatter_class=RawDescriptionHelpFormatter ) parser.add_argument("filename", help="File name to save the recording in") parser.add_argument("--display", default=None, type=str, help="Display to record") parser.add_argument("--quality", default=None, type=int, help="Recording quality") args = parser.parse_args() with Recorder(args.filename, args.display, args.quality): alive = True while alive: try: time.sleep(1) except KeyboardInterrupt: alive = False except Exception: pass