Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[show][barefoot] replace shell=True #2699

Merged
merged 4 commits into from
Apr 20, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions show/plugins/barefoot.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import json
import subprocess
from sonic_py_common import device_info
from sonic_py_common.general import getstatusoutput_noshell_pipe, check_output_pipe

@click.group()
def barefoot():
Expand All @@ -25,8 +26,9 @@ def profile():

# Print current profile
click.echo('Current profile: ', nl=False)
subprocess.run('docker exec -it syncd readlink /opt/bfn/install | sed '
r's/install_\\\(.\*\\\)_profile/\\1/', check=True, shell=True)
cmd0 = ['docker', 'exec', '-it', 'syncd', 'readlink', '/opt/bfn/install']
cmd1 = ['sed', r's/install_\\\(.\*\\\)_profile/\\1/']
check_output_pipe(cmd0, cmd1)

# Exclude current and unsupported profiles
opts = ''
Expand All @@ -37,9 +39,10 @@ def profile():

# Print profile list
click.echo('Available profile(s):')
subprocess.run('docker exec -it syncd find /opt/bfn -mindepth 1 '
r'-maxdepth 1 -type d -name install_\*_profile ' + opts + '| sed '
r's%/opt/bfn/install_\\\(.\*\\\)_profile%\\1%', shell=True)
cmd0 = ['docker', 'exec', '-it', 'syncd', 'find', '/opt/bfn', '-mindepth', '1',\
r'-maxdepth', '1', r'-type', 'd', r'-name', r'install_\*_profile', opts]
Copy link
Contributor

@qiluo-msft qiluo-msft Feb 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r

This r is not needed. #Closed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r

the same

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r

the same

cmd1 = ["sed", r's%/opt/bfn/install_\\\(.\*\\\)_profile%\\1%']
getstatusoutput_noshell_pipe(cmd0, cmd1)

def register(cli):
version_info = device_info.get_sonic_version_info()
Expand Down