Skip to content

Commit 543b1a7

Browse files
committed
test types
1 parent 0d106c8 commit 543b1a7

File tree

12 files changed

+59
-32
lines changed

12 files changed

+59
-32
lines changed

+stdlib/+dotnet/os_version.m

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
function [os, version] = os_version()
22

3-
v = System.Environment.OSVersion.VersionString;
4-
% https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.versionstring
5-
vs = split(string(v), ' ');
3+
try
4+
v = System.Environment.OSVersion.VersionString;
5+
% https://learn.microsoft.com/en-us/dotnet/api/system.operatingsystem.versionstring
6+
vs = split(string(v), ' ');
67

7-
version = char(vs(end));
8-
os = char(join(vs(1:end-1)));
8+
version = char(vs(end));
9+
os = char(join(vs(1:end-1)));
10+
catch e
11+
dotnetException(e)
12+
os = '';
13+
version = '';
14+
end
915

1016
end

+stdlib/+java/hard_link_count.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
function i = hard_link_count(file)
22

3-
opt = java.nio.file.LinkOption.values();
43
try
5-
i = java.nio.file.Files.getAttribute(javaAbsolutePath(file), "unix:nlink", opt);
4+
i = java.nio.file.Files.getAttribute(javaAbsolutePath(file), "unix:nlink", java.nio.file.LinkOption.values());
65
catch e
76
javaException(e)
87
i = [];

+stdlib/+java/os_version.m

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
function [os, version] = os_version()
22

3-
os = char(java.lang.System.getProperty('os.name'));
4-
version = char(java.lang.System.getProperty('os.version'));
3+
try
4+
os = char(java.lang.System.getProperty('os.name'));
5+
version = char(java.lang.System.getProperty('os.version'));
6+
catch e
7+
javaException(e)
8+
os = '';
9+
version = '';
10+
end
511

612
end

+stdlib/+python/get_uid.m

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
function u = get_uid()
22

3+
u = [];
4+
35
if isunix()
4-
u = double(py.os.geteuid());
5-
else
6-
u = [];
6+
try
7+
u = double(py.os.geteuid());
8+
catch e
9+
pythonException(e)
10+
end
711
end
812

913
end

+stdlib/+python/is_mount.m

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,18 @@
66

77
y = logical.empty;
88

9-
p = py.pathlib.Path(filepath);
10-
if ~p.exists(), return, end
11-
12-
% some Python on CI needs this. Didn't replicate on local Windows PC.
13-
if ispc() && strcmp(filepath, string(p.drive)) && ~endsWith(filepath, "/" | filesep)
14-
y = false;
15-
return
16-
end
179

1810
try %#ok<TRYNC>
11+
12+
p = py.pathlib.Path(filepath);
13+
if ~p.exists(), return, end
14+
15+
% some Python on CI needs this. Didn't replicate on local Windows PC.
16+
if ispc() && strcmp(filepath, string(p.drive)) && ~endsWith(filepath, "/" | filesep)
17+
y = false;
18+
return
19+
end
20+
1921
y = py.os.path.ismount(p);
2022
end
2123

+stdlib/+python/is_symlink.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88
try
99
y = py.pathlib.Path(file).is_symlink();
10-
catch
10+
catch e
11+
pythonException(e)
1112
y = logical.empty;
1213
end
1314

+stdlib/+python/os_version.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
os = char(py.platform.system());
55
version = char(py.platform.version());
66
catch e
7-
warning(e.identifier, 'Failed to get OS version using Python: %s', e.message)
7+
pythonException(e)
88
os = '';
99
version = '';
1010
end

+stdlib/+python/ram_free.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
try
44
vm = py.psutil.virtual_memory();
55
n = vm.available;
6-
catch
6+
catch e
7+
pythonException(e)
78
n = [];
89
end
910

+stdlib/+python/ram_total.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
try
44
vm = py.psutil.virtual_memory();
55
n = vm.total;
6-
catch
6+
catch e
7+
pythonException(e)
78
n = [];
89
end
910

+stdlib/+python/read_symlink.m

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@
22

33
r = string.empty;
44

5-
p = py.pathlib.Path(file);
6-
if ~p.is_symlink()
7-
return
8-
end
5+
try
6+
p = py.pathlib.Path(file);
7+
if ~p.is_symlink()
8+
return
9+
end
910

1011
% https://docs.python.org/3/library/pathlib.html#pathlib.Path.readlink
11-
try
12+
1213
r = string(py.str(p.readlink()));
1314
if ispc() && startsWith(r, '\\?\')
1415
r = extractAfter(r, '\\?\');
1516
end
1617
catch e
17-
warning(e.identifier, "read_symlink(%s) failed: %s", file, e.message);
18+
pythonException(e)
1819
end
1920

2021
end

0 commit comments

Comments
 (0)