How to use the asciinema.config 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 / __main__.py View on Github external
def main():
    if locale.nl_langinfo(locale.CODESET).upper() not in ['US-ASCII', 'UTF-8']:
        print("asciinema needs an ASCII or UTF-8 character encoding to run. Check the output of `locale` command.")
        sys.exit(1)

    try:
        cfg = config.load()
    except config.ConfigError as e:
        sys.stderr.write(str(e) + '\n')
        sys.exit(1)

    # create the top-level parser
    parser = argparse.ArgumentParser(
        description="Record and share your terminal sessions, the right way.",
        epilog="""example usage:
  Record terminal and upload it to asciinema.org:
    \x1b[1masciinema rec\x1b[0m
  Record terminal to local file:
    \x1b[1masciinema rec demo.cast\x1b[0m
  Record terminal and upload it to asciinema.org, specifying title:
    \x1b[1masciinema rec -t "My git tutorial"\x1b[0m
  Record terminal to local file, limiting idle time to max 2.5 sec:
    \x1b[1masciinema rec -i 2.5 demo.cast\x1b[0m
github timhsutw / honeyterm / honeyterm_asciinema / asciinema / asciinema / __main__.py View on Github external
def main():
    if locale.nl_langinfo(locale.CODESET).upper() != 'UTF-8':
        print("asciinema needs a UTF-8 native locale to run. Check the output of `locale` command.")
        sys.exit(1)

    cfg = config.load()

    # create the top-level parser
    parser = argparse.ArgumentParser(
        description="Record and share your terminal sessions, the right way.",
        epilog="""example usage:
  Record terminal and upload it to asciinema.org:
    \x1b[1masciinema rec\x1b[0m
  Record terminal to local file:
    \x1b[1masciinema rec demo.json\x1b[0m
  Record terminal and upload it to asciinema.org, specifying title:
    \x1b[1masciinema rec -t "My git tutorial"\x1b[0m
  Record terminal to local file, "trimming" longer pauses to max 2.5 sec:
    \x1b[1masciinema rec -w 2.5 demo.json\x1b[0m
  Replay terminal recording from local file:
    \x1b[1masciinema play demo.json\x1b[0m
  Replay terminal recording hosted on asciinema.org:
github vsoch / helpme / helpme / action / submit.py View on Github external
"""
    if os.path.exists(filename):

        try:
            from asciinema.commands.upload import UploadCommand
            import asciinema.config as aconfig
            from asciinema.api import Api
        except:
            bot.exit(
                "The asciinema module is required to submit "
                "an asciinema recording. Try pip install helpme[asciinema]"
            )

        # Load the API class

        cfg = aconfig.load()
        api = Api(cfg.api_url, os.environ.get("USER"), cfg.install_id)

        # Perform the upload, return the url

        uploader = UploadCommand(api, filename)

        try:
            url, warn = uploader.api.upload_asciicast(filename)
            if warn:
                uploader.print_warning(warn)

            # Extract just the url, if provided (always is https)
            if url:
                match = re.search("https://.+", url)
                if match:
                    url = match.group()
github vsoch / helpme / helpme / action / record.py View on Github external
def record_asciinema():
    """a wrapper around generation of an asciinema.api.Api and a custom 
       recorder to pull out the input arguments to the Record from argparse.
       The function generates a filename in advance and a return code
       so we can check the final status. 
    """

    import asciinema.config as aconfig
    from asciinema.api import Api

    # Load the API class

    cfg = aconfig.load()
    api = Api(cfg.api_url, os.environ.get("USER"), cfg.install_id)

    # Create dummy class to pass in as args
    recorder = HelpMeRecord(api)
    code = recorder.execute()

    if code == 0 and os.path.exists(recorder.filename):
        return recorder.filename
    print("Problem generating %s, return code %s" % (recorder.filename, code))