More string fixes

This commit is contained in:
Joshua Harlow 2012-03-29 13:23:58 -07:00
parent 79104bc3a8
commit 63e0384de5
2 changed files with 7 additions and 6 deletions

View File

@ -30,18 +30,19 @@ def set(key, value):
# See: from http://docs.python.org/library/os.html
# Calling putenv() directly does not change os.environ, so it's better to modify os.environ.
if key is not None:
LOG.audit("Setting environment key [%s] to value [%s]" % (key, value))
LOG.audit("Setting environment key %r to value %r" % (str(key), str(value)))
os.environ[str(key)] = str(value)
def get_key(key, default_value=None):
if not key:
return default_value
LOG.debug("Looking up environment variable [%s]" % (key))
key = str(key)
LOG.debug("Looking up environment variable %r" % (key))
value = get().get(key)
if value is None:
LOG.debug("Could not find anything in environment variable [%s]" % (key))
LOG.debug("Could not find anything in environment variable %r" % (key))
value = default_value
else:
LOG.audit("Found [%s] in environment variable [%s]" % (value, key))
LOG.audit("Found %r in environment variable %r" % (value, key))
return value

View File

@ -272,12 +272,12 @@ class RcReader(object):
def extract(self, fn):
extracted_vars = dict()
contents = ''
LOG.audit("Loading rc file [%s]" % (fn))
LOG.audit("Loading rc file %r" % (fn))
try:
with open(fn, 'r') as fh:
contents = fh.read()
except IOError as e:
LOG.warn("Failed extracting rc file [%s] due to [%s]" % (fn, e))
LOG.warn("Failed extracting rc file %r due to %s" % (fn, e))
return extracted_vars
for line in contents.splitlines():
if self._is_comment(line):