Skip to content

Commit

Permalink
Fix python semgrep warning
Browse files Browse the repository at this point in the history
  • Loading branch information
praveen-ramamoorthi committed Jun 17, 2024
1 parent 052f3c5 commit b48781d
Showing 1 changed file with 17 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,53 +96,38 @@ def get_cpld_reg_value(self, getreg_path, register):
def ipmi_raw(cmd):
status = True
result = ""
try:
cmd = "ipmitool raw {}".format(str(cmd))
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
raw_data, err = p.communicate()
if err.decode("utf-8") == "":
result = raw_data.decode("utf-8").strip()
else:
status = False
except Exception:
cmd = "ipmitool raw {}".format(str(cmd))
ret, raw_data = subprocess.getstatusoutput(cmd)
if ret != 0:
status = False
else:
result = raw_data
return status, result

@staticmethod
def ipmi_fru_id(key_id, key=None):
status = True
result = ""
try:
cmd = "ipmitool fru print {}".format(str(
key_id)) if not key else "ipmitool fru print {0} | grep '{1}' ".format(str(key_id), str(key))

p = subprocess.Popen(
cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
raw_data, err = p.communicate()
if err == '':
result = raw_data.strip()
else:
status = False
except Exception:
cmd = "ipmitool fru print {}".format(str(
key_id)) if not key else "ipmitool fru print {0} | grep '{1}' ".format(str(key_id), str(key))
ret, data = subprocess.getstatusoutput(cmd)
if ret != 0:
status = False
else:
result = data
return status, result

@staticmethod
def ipmi_set_ss_thres(id, threshold_key, value):
status = True
result = ""
try:
cmd = "ipmitool sensor thresh '{}' {} {}".format(
str(id), str(threshold_key), str(value))
p = subprocess.Popen(
cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
raw_data, err = p.communicate()
if err == '':
result = raw_data.strip()
else:
status = False
except Exception:
cmd = "ipmitool sensor thresh '{}' {} {}".format(
str(id), str(threshold_key), str(value))
ret, data = subprocess.getstatusoutput(cmd)
if ret != 0:
status = False
else:
result = data
return status, result

@staticmethod
Expand Down

0 comments on commit b48781d

Please sign in to comment.