|
|
@ -2974,14 +2974,19 @@ def get_file_content(path, default=None, strip=True):
|
|
|
|
data = default
|
|
|
|
data = default
|
|
|
|
if os.path.exists(path) and os.access(path, os.R_OK):
|
|
|
|
if os.path.exists(path) and os.access(path, os.R_OK):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
datafile = open(path)
|
|
|
|
try:
|
|
|
|
data = datafile.read()
|
|
|
|
datafile = open(path)
|
|
|
|
if strip:
|
|
|
|
data = datafile.read()
|
|
|
|
data = data.strip()
|
|
|
|
if strip:
|
|
|
|
if len(data) == 0:
|
|
|
|
data = data.strip()
|
|
|
|
data = default
|
|
|
|
if len(data) == 0:
|
|
|
|
finally:
|
|
|
|
data = default
|
|
|
|
datafile.close()
|
|
|
|
finally:
|
|
|
|
|
|
|
|
datafile.close()
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
|
|
|
# ignore errors as some jails/containers might have readable permissions but not allow reads to proc
|
|
|
|
|
|
|
|
# done in 2 blocks for 2.4 compat
|
|
|
|
|
|
|
|
pass
|
|
|
|
return data
|
|
|
|
return data
|
|
|
|
|
|
|
|
|
|
|
|
def get_file_lines(path):
|
|
|
|
def get_file_lines(path):
|
|
|
|