How to use the asciinema.api.Api 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 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()
            return url
github asciinema / asciinema / asciinema / commands / command.py View on Github external
def __init__(self, args, config, env):
        self.quiet = False
        self.api = Api(config.api_url, env.get("USER"), config.install_id)
github timhsutw / honeyterm / honeyterm_asciinema / asciinema / asciinema / __main__.py View on Github external
def upload_command(args, config):
    api = Api(config.api_url, os.environ.get("USER"), config.api_token)
    return UploadCommand(api, args.filename)
github timhsutw / honeyterm / honeyterm_asciinema / asciinema / asciinema / __main__.py View on Github external
def rec_command(args, config):
    api = Api(config.api_url, os.environ.get("USER"), config.api_token)
    return RecordCommand(api, args.filename, args.command, args.title, args.yes, args.quiet, args.max_wait)
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))