Skip to content

Commit dc7209f

Browse files
committed
hostname: python fallback
1 parent 2be1ff1 commit dc7209f

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

+stdlib/hostname.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010
if stdlib.has_dotnet()
1111
n = System.Environment.MachineName;
1212
% https://learn.microsoft.com/en-us/dotnet/api/system.environment.machinename
13+
elseif stdlib.has_java()
14+
n = javaMethod("getLocalHost", "java.net.InetAddress").getHostName();
15+
elseif stdlib.has_python()
16+
n = py_hostname();
1317
elseif stdlib.isoctave()
1418
n = gethostname();
15-
elseif stdlib.has_java()
16-
n = java.net.InetAddress.getLocalHost().getHostName();
1719
end
1820

1921
try %#ok<*TRYNC>

+stdlib/private/py_hostname.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function n = py_hostname()
2+
3+
n = py.socket.gethostname();
4+
5+
end

0 commit comments

Comments
 (0)