Skip to content

Commit

Permalink
Add 'sudo' to required calls (sonic-net#48)
Browse files Browse the repository at this point in the history
 - Run 'decode-syseeprom,' using sudo 'cat' and 'tail' commands using sudo
 - Small refactoring of 'show logging'
  • Loading branch information
jleveque authored May 10, 2017
1 parent ad735d1 commit 3378ef8
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions show/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def summary():
@platform.command()
def syseeprom():
"""Show system EEPROM information"""
run_command("decode-syseeprom")
run_command("sudo decode-syseeprom")


#
Expand All @@ -270,22 +270,25 @@ def syseeprom():
def logging():
pass

# Default 'lldp' command (called if no subcommands or their aliases were passed)
# Default 'logging' command (called if no subcommands or their aliases were passed)
@logging.command(default=True)
@click.argument('process', required=False)
@click.option('--tail', required=False, default=10)
@click.option('--follow', required=False)
def default(process, tail, follow):
@click.option('-l', '--lines')
@click.option('-f', '--follow', is_flag=True)
def default(process, lines, follow):
"""Show system log"""
if process is not None:
command = "grep {} /var/log/syslog".format(process)
if tail is not None:
command += "| tail -{}".format(tail)
elif follow is not None:
command += "| tail -f"
run_command(command)
if follow:
run_command("sudo tail -f /var/log/syslog")
else:
run_command("cat /var/log/syslog", pager=True)
command = "sudo cat /var/log/syslog"

if process is not None:
command += " | grep '{}'".format(process)

if lines is not None:
command += " | tail -{}".format(lines)

run_command(command, pager=True)


#
Expand Down

0 comments on commit 3378ef8

Please sign in to comment.