mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-06-07 14:43:16 +03:00
Do not manually remove temporary files on Unix
This commit is contained in:
parent
7f8df9d712
commit
e19447cbbb
|
@ -126,16 +126,6 @@ class Viewer:
|
||||||
os.system(self.get_command(path, **options))
|
os.system(self.get_command(path, **options))
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
def _remove_path_after_delay(self, path):
|
|
||||||
subprocess.Popen(
|
|
||||||
[
|
|
||||||
sys.executable,
|
|
||||||
"-c",
|
|
||||||
"import os, sys, time; time.sleep(20); os.remove(sys.argv[1])",
|
|
||||||
path,
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -190,7 +180,14 @@ class MacViewer(Viewer):
|
||||||
else:
|
else:
|
||||||
raise TypeError("Missing required argument: 'path'")
|
raise TypeError("Missing required argument: 'path'")
|
||||||
subprocess.call(["open", "-a", "Preview.app", path])
|
subprocess.call(["open", "-a", "Preview.app", path])
|
||||||
self._remove_path_after_delay(path)
|
subprocess.Popen(
|
||||||
|
[
|
||||||
|
sys.executable,
|
||||||
|
"-c",
|
||||||
|
"import os, sys, time; time.sleep(20); os.remove(sys.argv[1])",
|
||||||
|
path,
|
||||||
|
]
|
||||||
|
)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
||||||
|
@ -235,7 +232,6 @@ class XDGViewer(UnixViewer):
|
||||||
else:
|
else:
|
||||||
raise TypeError("Missing required argument: 'path'")
|
raise TypeError("Missing required argument: 'path'")
|
||||||
subprocess.Popen(["xdg-open", path])
|
subprocess.Popen(["xdg-open", path])
|
||||||
self._remove_path_after_delay(path)
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
||||||
|
@ -274,7 +270,6 @@ class DisplayViewer(UnixViewer):
|
||||||
args.append(path)
|
args.append(path)
|
||||||
|
|
||||||
subprocess.Popen(args)
|
subprocess.Popen(args)
|
||||||
os.remove(path)
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
||||||
|
@ -304,7 +299,6 @@ class GmDisplayViewer(UnixViewer):
|
||||||
else:
|
else:
|
||||||
raise TypeError("Missing required argument: 'path'")
|
raise TypeError("Missing required argument: 'path'")
|
||||||
subprocess.Popen(["gm", "display", path])
|
subprocess.Popen(["gm", "display", path])
|
||||||
os.remove(path)
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
||||||
|
@ -334,7 +328,6 @@ class EogViewer(UnixViewer):
|
||||||
else:
|
else:
|
||||||
raise TypeError("Missing required argument: 'path'")
|
raise TypeError("Missing required argument: 'path'")
|
||||||
subprocess.Popen(["eog", "-n", path])
|
subprocess.Popen(["eog", "-n", path])
|
||||||
os.remove(path)
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
||||||
|
@ -375,7 +368,6 @@ class XVViewer(UnixViewer):
|
||||||
args.append(path)
|
args.append(path)
|
||||||
|
|
||||||
subprocess.Popen(args)
|
subprocess.Popen(args)
|
||||||
os.remove(path)
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user