How to use the asciinema.asciicast.v2 function in asciinema

To help you get started, we’ve selected a few asciinema examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github asciinema / asciinema / asciinema / commands / record.py View on Github external
vars = filter(None, map((lambda var: var.strip()), self.env_whitelist.split(',')))

        try:
            recorder.record(
                self.filename,
                command=self.command,
                append=append,
                title=self.title,
                idle_time_limit=self.idle_time_limit,
                command_env=self.env,
                capture_env=vars,
                rec_stdin=self.rec_stdin,
                writer=self.writer
            )
        except v2.LoadError:
            self.print_error("can only append to asciicast v2 format recordings")
            return 1

        self.print_info("recording finished")

        if upload:
            if not self.assume_yes:
                self.print_info("press  to upload to %s,  to save locally"
                                % self.api.hostname())
                try:
                    sys.stdin.readline()
                except KeyboardInterrupt:
                    self.print("\r", end="")
                    self.print_info("asciicast saved to %s" % self.filename)
                    return 0
github asciinema / asciinema / asciinema / recorder.py View on Github external
def record(path, command=None, append=False, idle_time_limit=None,
           rec_stdin=False, title=None, metadata=None, command_env=None,
           capture_env=None, writer=v2.writer, record=pty.record):
    if command is None:
        command = os.environ.get('SHELL') or 'sh'

    if command_env is None:
        command_env = os.environ.copy()
        command_env['ASCIINEMA_REC'] = '1'

    if capture_env is None:
        capture_env = ['SHELL', 'TERM']

    w, h = term.get_size()

    full_metadata = {
        'width': w,
        'height': h,
        'timestamp': int(time.time())
github asciinema / asciinema / asciinema / asciicast / __init__.py View on Github external
def __enter__(self):
        try:
            self.file = open_url(self.url)
            first_line = self.file.readline()

            try:  # try v2 first
                self.context = v2.open_from_file(first_line, self.file)
                return self.context.__enter__()
            except v2.LoadError:
                try:  # try v1 next
                    self.context = v1.open_from_file(first_line, self.file)
                    return self.context.__enter__()
                except v1.LoadError:
                    raise LoadError(self.FORMAT_ERROR)

        except (OSError, urllib.error.HTTPError) as e:
            raise LoadError(str(e))
github asciinema / asciinema / asciinema / recorder.py View on Github external
full_metadata.update(metadata or {})

    if idle_time_limit is not None:
        full_metadata['idle_time_limit'] = idle_time_limit

    if capture_env:
        full_metadata['env'] = {var: command_env.get(var) for var in capture_env}

    if title:
        full_metadata['title'] = title

    time_offset = 0

    if append and os.stat(path).st_size > 0:
        time_offset = v2.get_duration(path)

    with async_writer(writer, path, full_metadata, append) as w:
        with async_notifier() as n:
            record(
                ['sh', '-c', command],
                w,
                command_env,
                rec_stdin,
                time_offset,
                n
            )
github vsoch / helpme / helpme / action / record.py View on Github external
if filename is None:
            filename = self.generate_temporary_file()

        Command.__init__(self, quiet=quiet)
        self.api = api
        self.filename = filename
        self.rec_stdin = record_stdin
        self.command = command or os.environ["SHELL"]
        self.env_whitelist = ""
        self.title = title
        self.assume_yes = quiet
        self.idle_time_limit = 10
        self.append = append
        self.overwrite = overwrite
        self.raw = record_raw
        self.recorder = raw.Recorder() if record_raw else v2.Recorder()
        self.env = env if env is not None else os.environ
github asciinema / asciinema / asciinema / commands / record.py View on Github external
def __init__(self, args, config, env):
        Command.__init__(self, args, config, env)
        self.quiet = args.quiet
        self.filename = args.filename
        self.rec_stdin = args.stdin
        self.command = args.command
        self.env_whitelist = args.env
        self.title = args.title
        self.assume_yes = args.yes or args.quiet
        self.idle_time_limit = args.idle_time_limit
        self.append = args.append
        self.overwrite = args.overwrite
        self.raw = args.raw
        self.writer = raw.writer if args.raw else v2.writer
        self.env = env
github asciinema / asciinema / asciinema / asciicast / __init__.py View on Github external
def __enter__(self):
        try:
            self.file = open_url(self.url)
            first_line = self.file.readline()

            try:  # try v2 first
                self.context = v2.open_from_file(first_line, self.file)
                return self.context.__enter__()
            except v2.LoadError:
                try:  # try v1 next
                    self.context = v1.open_from_file(first_line, self.file)
                    return self.context.__enter__()
                except v1.LoadError:
                    raise LoadError(self.FORMAT_ERROR)

        except (OSError, urllib.error.HTTPError) as e:
            raise LoadError(str(e))