Skip to content

Commit

Permalink
use os.path instaed of string formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
charless-splunk committed Jun 19, 2017
1 parent c33e603 commit bb8fc14
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/signalfx_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
DOGSTATSD_INSTANCE = collectd_dogstatsd.DogstatsDCollectD(collectd)
PERCORECPUUTIL = False
OVERALLCPUUTIL = True
ETC_PATH = "/etc"
ETC_PATH = "{0}etc".format(os.sep)


class mdict(dict):
Expand Down Expand Up @@ -848,7 +848,7 @@ def plugin_config(conf):
psutil.PROCFS_PATH = kv.values[0]
debug("Setting proc path to %s for psutil" % psutil.PROCFS_PATH)
elif kv.key == 'EtcPath':
ETC_PATH = kv.values[0].rstrip("/")
ETC_PATH = kv.values[0].rstrip(os.pathsep).rstrip(os.sep)
debug("Setting etc path to %s for os release detection"
% ETC_PATH)

Expand Down Expand Up @@ -1157,7 +1157,7 @@ def get_collectd_version():


def getLsbRelease():
path = ("{0}/lsb-release").format(ETC_PATH)
path = os.path.join(ETC_PATH, "lsb-release")
if os.path.isfile(path):
with open(path) as f:
for line in f.readlines():
Expand All @@ -1167,7 +1167,7 @@ def getLsbRelease():


def getOsRelease():
path = ("{0}/os-release").format(ETC_PATH)
path = os.path.join(ETC_PATH, "os-release")
if os.path.isfile(path):
with open(path) as f:
for line in f.readlines():
Expand All @@ -1177,9 +1177,9 @@ def getOsRelease():


def getCentos():
for file in ["{0}/centos-release".format(ETC_PATH),
"{0}/redhat-release".format(ETC_PATH),
"{0}/system-release".format(ETC_PATH)]:
for file in [os.path.join(ETC_PATH, "centos-release"),
os.path.join(ETC_PATH, "redhat-release"),
os.path.join(ETC_PATH, "system-release")]:
if os.path.isfile(file):
with open(file) as f:
line = f.read()
Expand Down

0 comments on commit bb8fc14

Please sign in to comment.