How to use the asciinema.config.ConfigError 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
  Replay terminal recording from local file:
github asciinema / asciinema / asciinema / config.py View on Github external
def upgrade(self):
        try:
            self.install_id
        except ConfigError:
            id = self.__api_token() or self.__user_token() or self.__gen_install_id()
            self.__save_install_id(id)

            items = {name: dict(section) for (name, section) in self.config.items()}
            if items == {'DEFAULT': {}, 'api': {'token': id}} or items == {'DEFAULT': {}, 'user': {'token': id}}:
                os.remove(self.config_file_path)

        if self.env.get('ASCIINEMA_API_TOKEN'):
            raise ConfigError('ASCIINEMA_API_TOKEN variable is no longer supported, please use ASCIINEMA_INSTALL_ID instead')
github asciinema / asciinema / asciinema / config.py View on Github external
def install_id(self):
        id = self.env.get('ASCIINEMA_INSTALL_ID') or self.__read_install_id()

        if id:
            return id
        else:
            raise ConfigError('no install ID found')
github asciinema / asciinema / asciinema / config.py View on Github external
def upgrade(self):
        try:
            self.install_id
        except ConfigError:
            id = self.__api_token() or self.__user_token() or self.__gen_install_id()
            self.__save_install_id(id)

            items = {name: dict(section) for (name, section) in self.config.items()}
            if items == {'DEFAULT': {}, 'api': {'token': id}} or items == {'DEFAULT': {}, 'user': {'token': id}}:
                os.remove(self.config_file_path)

        if self.env.get('ASCIINEMA_API_TOKEN'):
            raise ConfigError('ASCIINEMA_API_TOKEN variable is no longer supported, please use ASCIINEMA_INSTALL_ID instead')