@@ -118,6 +118,8 @@ def show_file(self, path: str, **options: Any) -> int:
118118 """
119119 Display given file.
120120 """
121+ if not os .path .exists (path ):
122+ raise FileNotFoundError
121123 os .system (self .get_command (path , ** options )) # nosec
122124 return 1
123125
@@ -142,6 +144,8 @@ def show_file(self, path: str, **options: Any) -> int:
142144 """
143145 Display given file.
144146 """
147+ if not os .path .exists (path ):
148+ raise FileNotFoundError
145149 subprocess .Popen (
146150 self .get_command (path , ** options ),
147151 shell = True ,
@@ -171,6 +175,8 @@ def show_file(self, path: str, **options: Any) -> int:
171175 """
172176 Display given file.
173177 """
178+ if not os .path .exists (path ):
179+ raise FileNotFoundError
174180 subprocess .call (["open" , "-a" , "Preview.app" , path ])
175181 executable = sys .executable or shutil .which ("python3" )
176182 if executable :
@@ -215,6 +221,8 @@ def show_file(self, path: str, **options: Any) -> int:
215221 """
216222 Display given file.
217223 """
224+ if not os .path .exists (path ):
225+ raise FileNotFoundError
218226 subprocess .Popen (["xdg-open" , path ])
219227 return 1
220228
@@ -237,6 +245,8 @@ def show_file(self, path: str, **options: Any) -> int:
237245 """
238246 Display given file.
239247 """
248+ if not os .path .exists (path ):
249+ raise FileNotFoundError
240250 args = ["display" ]
241251 title = options .get ("title" )
242252 if title :
@@ -259,6 +269,8 @@ def show_file(self, path: str, **options: Any) -> int:
259269 """
260270 Display given file.
261271 """
272+ if not os .path .exists (path ):
273+ raise FileNotFoundError
262274 subprocess .Popen (["gm" , "display" , path ])
263275 return 1
264276
@@ -275,6 +287,8 @@ def show_file(self, path: str, **options: Any) -> int:
275287 """
276288 Display given file.
277289 """
290+ if not os .path .exists (path ):
291+ raise FileNotFoundError
278292 subprocess .Popen (["eog" , "-n" , path ])
279293 return 1
280294
@@ -299,6 +313,8 @@ def show_file(self, path: str, **options: Any) -> int:
299313 """
300314 Display given file.
301315 """
316+ if not os .path .exists (path ):
317+ raise FileNotFoundError
302318 args = ["xv" ]
303319 title = options .get ("title" )
304320 if title :
0 commit comments