avoid distutils, no longer in python 3.12
This commit is contained in:
parent
301babd1dd
commit
171059cf45
1 changed files with 16 additions and 3 deletions
19
ox/file.py
19
ox/file.py
|
@ -2,7 +2,6 @@
|
|||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
# GPL 2008
|
||||
from __future__ import division, print_function
|
||||
from distutils.spawn import find_executable
|
||||
from glob import glob
|
||||
import hashlib
|
||||
import os
|
||||
|
@ -39,6 +38,21 @@ EXTENSIONS = {
|
|||
],
|
||||
}
|
||||
|
||||
def is_exe(fpath):
|
||||
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
|
||||
|
||||
def which(program):
|
||||
fpath, fname = os.path.split(program)
|
||||
if fpath:
|
||||
if is_exe(program):
|
||||
return program
|
||||
else:
|
||||
for path in os.environ.get("PATH", "").split(os.pathsep):
|
||||
exe_file = os.path.join(path, program)
|
||||
if is_exe(exe_file):
|
||||
return exe_file
|
||||
return None
|
||||
|
||||
def cmd(program):
|
||||
local = os.path.expanduser('~/.ox/bin/%s' % program)
|
||||
if os.path.exists(local):
|
||||
|
@ -160,12 +174,11 @@ def avinfo(filename, cached=True):
|
|||
if cached:
|
||||
return cache(filename, 'info')
|
||||
if os.path.getsize(filename):
|
||||
if find_executable('ffprobe'):
|
||||
if which('ffprobe'):
|
||||
return ffprobe(filename)
|
||||
raise EnvironmentError('could to find ffprobe. please install ffmpeg')
|
||||
return {'path': filename, 'size': 0}
|
||||
|
||||
|
||||
def ffprobe(filename):
|
||||
p = subprocess.Popen([
|
||||
cmd('ffprobe'),
|
||||
|
|
Loading…
Reference in a new issue