Skip to content

Commit cf6f9ec

Browse files
Merge pull request #642 from bartlettroscoe/etc-hostname
Return /etc/hostname when 'hostname' command does not exist
2 parents bef4ccf + e58119e commit cf6f9ec

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

tribits/ci_support/CheckinTest.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,19 @@ def getExtraCommandOutputFileName():
158158

159159

160160
def getHostname():
161-
return getCmndOutput("hostname", True)
161+
hostname = ""
162+
try:
163+
hostname = getCmndOutput("hostname", True)
164+
except Exception:
165+
pass
166+
if hostname == "":
167+
try:
168+
if os.path.exists("/etc/hostname"):
169+
with open("/etc/hostname", "r") as f:
170+
hostname = f.read().strip()
171+
except Exception:
172+
pass
173+
return hostname
162174

163175

164176
def getEmailAddressesSpaceString(emailAddressesCommasStr):

0 commit comments

Comments
 (0)