25 lines
490 B
Python
25 lines
490 B
Python
import subprocess
|
|
import tempfile
|
|
|
|
from shutil import which
|
|
|
|
DEPENDENCIES = ('pdftoppm',)
|
|
IMAGE_OPENER = 'ristretto'
|
|
|
|
|
|
def ensure_dependencies():
|
|
for s in DEPENDENCIES:
|
|
if which(s) is None:
|
|
return RuntimeError(f'required dependency not found: {s}')
|
|
|
|
|
|
def randomtempname(suffix=None):
|
|
name = next(tempfile._get_candidate_names())
|
|
if suffix is not None:
|
|
name += suffix
|
|
return name
|
|
|
|
|
|
def desktop_open_image(f):
|
|
subprocess.run([IMAGE_OPENER, f])
|