Skip to content

Commit

Permalink
[sonic_pcie][sonic_ssd] Make Python 3-compliant (sonic-net#150)
Browse files Browse the repository at this point in the history
Changes to make sonic_pcie and sonic_ssd packages Python 3-compliant.

Also remove unnecessary imports and remove executable permissions from files which should not be exectuable.
  • Loading branch information
jleveque authored Nov 25, 2020
1 parent 362afc2 commit ed6392d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
Empty file modified sonic_platform_base/sonic_pcie/__init__.py
100755 → 100644
Empty file.
Empty file modified sonic_platform_base/sonic_pcie/pcie_base.py
100755 → 100644
Empty file.
8 changes: 4 additions & 4 deletions sonic_platform_base/sonic_pcie/pcie_common.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def load_config_file(self):
with open(config_file) as conf_file:
self.confInfo = yaml.load(conf_file)
except IOError as e:
print "Error: {}".format(str(e))
print "Not found config file, please add a config file manually, or generate it by running [pcieutil pcie_generate]"
print("Error: {}".format(str(e)))
print("Not found config file, please add a config file manually, or generate it by running [pcieutil pcie_generate]")
sys.exit()

# load current PCIe device
Expand All @@ -40,11 +40,11 @@ def get_pcie_device(self):
command1 = "sudo lspci"
command2 = "sudo lspci -n"
# run command 1
proc1 = subprocess.Popen(command1, shell=True, stdout=subprocess.PIPE)
proc1 = subprocess.Popen(command1, shell=True, universal_newlines=True, stdout=subprocess.PIPE)
output1 = proc1.stdout.readlines()
(out, err) = proc1.communicate()
# run command 2
proc2 = subprocess.Popen(command2, shell=True, stdout=subprocess.PIPE)
proc2 = subprocess.Popen(command2, shell=True, universal_newlines=True, stdout=subprocess.PIPE)
output2 = proc2.stdout.readlines()
(out, err) = proc2.communicate()

Expand Down
8 changes: 2 additions & 6 deletions sonic_platform_base/sonic_ssd/ssd_generic.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
# - StorFly
# - Virtium

try:
import exceptions # Python 2
except ImportError:
import builtins as exceptions # Python 3
try:
import re
import subprocess
Expand Down Expand Up @@ -54,7 +50,7 @@ def __init__(self, diskdev):
# Known vendor part
if self.model:
model_short = self.model.split()[0]
if self.vendor_ssd_utility.has_key(model_short):
if model_short in self.vendor_ssd_utility:
self.fetch_vendor_ssd_info(diskdev, model_short)
self.parse_vendor_ssd_info(model_short)
else:
Expand All @@ -65,7 +61,7 @@ def __init__(self, diskdev):
self.model = "Unknown"

def _execute_shell(self, cmd):
process = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE)
process = subprocess.Popen(cmd.split(), universal_newlines=True, stdout=subprocess.PIPE)
output, error = process.communicate()
return output

Expand Down

0 comments on commit ed6392d

Please sign in to comment.