src/eric7/SystemUtilities/FileSystemUtilities.py

branch
eric7
changeset 10397
f60464a5f7ea
parent 10396
2f72e9330af2
child 10439
21c28b0f9e41
--- a/src/eric7/SystemUtilities/FileSystemUtilities.py	Sun Dec 10 17:06:00 2023 +0100
+++ b/src/eric7/SystemUtilities/FileSystemUtilities.py	Sun Dec 10 17:49:42 2023 +0100
@@ -740,18 +740,19 @@
     """
     filePath = str(filePath)
 
-    if OSUtilities.isWindowsPlatform():
-        return os.startfile(filePath)  # secok
-
-    elif OSUtilities.isMacPlatform():
-        return subprocess.call(("open", filePath))  # secok
+    with contextlib.suppress(OSError):
+        if OSUtilities.isWindowsPlatform():
+            os.startfile(filePath)  # secok
+            return True
 
-    elif OSUtilities.isLinuxPlatform() or OSUtilities.isFreeBsdPlatform():
-        return subprocess.call(("xdg-open", filePath))  # secok
+        elif OSUtilities.isMacPlatform():
+            return subprocess.call(("open", filePath)) == 0  # secok
 
-    else:
-        # unsupported platform
-        return False
+        elif OSUtilities.isLinuxPlatform() or OSUtilities.isFreeBsdPlatform():
+            return subprocess.call(("xdg-open", filePath)) == 0  # secok
+
+    # unsupported platform or OSError
+    return False
 
 
 ################################################################################

eric ide

mercurial