pyats.log.commands package

Submodules

class pyats.log.commands.archive.Archive(archive, unzip_dir=None)

Bases: pyats.log.commands.archive.FileHandler

async extract_archive()
async listdir(folder=None, _depth=0, _parent_id=0)
async parse_archive(**kwargs)
async read_bytes(logfile, log_start=0, log_size=- 1, offset=0, limit=0)

return the logs for a secton/step, paginated according to offset/limit. log_start: start bytes of section in the log file. log_size: bytes size of section. offset: (Optional) start point for current trunk. bytes offset

inside the log section.

limit: (Optional) size of current trunk.

async read_file(filename, read_lines=False)
async read_lines(logfile, offset=None, limit=None, log_start=0, log_size=- 1)

return a list of file content, seperated by lines. return the whole file when passing no parameter. log_start: start btyes of section in the log file. log_size: bytes size of section. offset: start line # in the section. limit: # of lines to read

class pyats.log.commands.archive.FileHandler(_dir)

Bases: object

async listdir(folder=None, _depth=0, _parent_id=0)
async read_bytes(logfile, log_start=0, log_size=- 1, offset=0, limit=0)

return the logs for a secton/step, paginated according to offset/limit. log_start: start bytes of section in the log file. log_size: bytes size of section. offset: (Optional) start point for current trunk. bytes offset

inside the log section.

limit: (Optional) size of current trunk.

async read_file(filename, read_lines=False)
async read_lines(logfile, offset=None, limit=None, log_start=0, log_size=- 1)

return a list of file content, seperated by lines. return the whole file when passing no parameter. log_start: start btyes of section in the log file. log_size: bytes size of section. offset: start line # in the section. limit: # of lines to read

class pyats.log.commands.archive.RunInfoFileHandler(runinfo_dir)

Bases: pyats.log.commands.archive.FileHandler

async get_tail_start(filename, start_bytes=0, line_offset=20)

reads file by line and gets line and bytes number of where to start tailing line_offset is the number of previous lines to show from tailing

tailing_file(filename, start_bytes=0)

tailing_file function tail file in separated process in non blocking fashion

pyats.log.commands.archive.file_flag(flag_name)

Creates temp file within cache to indicate active parsing

class pyats.log.commands.logs.ListSubcommand(parent)

Bases: pyats.cli.base.Subcommand

description = '\nlist all archives stored in standard known archive locations.\n    '
help = 'list all log archives'
name = 'list'
run(args)

runs this subcommand

class pyats.log.commands.logs.LogsCommand(*args, **kwargs)

Bases: pyats.cli.base.CommandWithSubcommands

SUBCMDS_ENTRYPOINT = ''
SUBCOMMANDS = [<class 'pyats.log.commands.logs.ViewSubcommand'>, <class 'pyats.log.commands.logs.ListSubcommand'>, <class 'pyats.cisco.commands.upload.UploadSubcommand'>]
help = 'command enabling log archive viewing in local browser'
name = 'logs'
class pyats.log.commands.logs.ViewSubcommand(*args, **kwargs)

Bases: pyats.cli.base.Subcommand

description = '\nOpens pyATS generated archive zip files and host them through HTTP server.\n\nBehavior:\n    - List all archives stored in standard known archive locations in reverse \n      order on webpage.\n    - Click to view detail results of an archive.\n    - set environment variable $BROWSER to your browser executable to force using\n      your provided browser\n    - if liveview is enabled, opens the lastest running job.\n\nExamples:\n    # opens the archive list page\n    $ pyats logs view\n\n    # opens the last generated archive file\n    $ pyats logs view --latest\n\n    # open a specific archive file\n    $ pyats logs view /path/to/archive.zip\n    '
help = 'open and view log archives in browser'
name = 'view'
run(args)

runs this subcommand

usage = '{prog} [archive] [options]'
class pyats.log.commands.server.LogViewerServer(archive=None, fread_size=20480, fread_line=100, latest=False, **kwargs)

Bases: aiohttp.web_app.Application

keep_alive: if True, when liveview job finishes,

keep serving the logviewer

async commands(request)
configure_routes(url_prefix='/private/v1/standalone')
async download_archive(request)
async download_file(request)
async error_middleware(request, handler)
async filebytes(request)
async filelines(request)
async files(request)
async htmlviewer(request)
async index(request)

serve index page

async log_save(request)
async logfile_cmd(request)
async logfile_sec(request)
async redirect(request)
async results(request)
async results_list(request)

list all results data with pagination URL: /results

async sections(request)
serve(*args, **kwargs)

serve this single-app web server

setup_swagger_docs()
async static(request)
pyats.log.commands.server.validate_uuid(func)