Skip to content

Commit

Permalink
Fix the issue with path checking in dependency finding
Browse files Browse the repository at this point in the history
  • Loading branch information
BingLingGroup committed Apr 22, 2020
1 parent 00a528b commit 76d41a7
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 21 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,15 @@ Click up arrow to go back to TOC.
- Change all text file input decoding into "utf-8".
- Change the default style selection in subtitles translation.
- Change the loglevel in ffmpeg commands into `-loglevel error`.
- Change DEFAULT_MIN_REGION_SIZE to 0.5
- Change DEFAULT_MIN_REGION_SIZE to 0.5.

#### Fixed(Unreleased)

- Fix the size count bug when the last line been split in list_to_googletrans.
- Fix delete_chars issue when using `-of full-src`.
- Fix os.remove() PermissionError in api_xfyun.py.
- Fix DEFAULT_AUDIO_PRCS_CMDS and DEFAULT_CHECK_CMD.
- Fix the issue with path checking in dependency finding.

#### Removed(Unreleased)

Expand Down
46 changes: 26 additions & 20 deletions autosub/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,33 +394,39 @@ def which_exe(program_path):

def get_cmd(program_name):
"""
Return the executable name. "" returned when no executable exists.
Return the path for a given executable.
"" returned when no executable exists.
"""
command = which_exe(program_name)
if command:
return command

command = which_exe(program_name + ".exe")
if command:
return command
if not sys.platform.startswith('win'):
command = which_exe(program_name)
if command:
return command
else:
command = which_exe(program_name + ".exe")
if command:
return command

return ""


if 'FFMPEG_PATH' in os.environ:
FFMPEG_CMD = os.environ['FFMPEG_PATH']
else:
FFMPEG_CMD = get_cmd("ffmpeg")
def get_cmd_from_env(program_name, env_name):
"""
Return the path or the value of environment variable
for a given executable.
"""
if env_name in os.environ:
if is_exe(os.environ[env_name]):
return os.environ[env_name]
program_name = os.path.join(os.environ[env_name], program_name)
if is_exe(program_name):
return program_name
return program_name + ".exe"
return get_cmd(program_name)

if 'FFPROBE_PATH' in os.environ:
FFPROBE_CMD = os.environ['FFPROBE_PATH']
else:
FFPROBE_CMD = get_cmd("ffprobe")

if 'FFMPEG_NORMALIZE_PATH' in os.environ:
FFMPEG_NORMALIZE_CMD = os.environ['FFMPEG_NORMALIZE_PATH']
else:
FFMPEG_NORMALIZE_CMD = get_cmd("ffmpeg-normalize")
FFMPEG_CMD = get_cmd_from_env("ffmpeg", "FFMPEG_PATH")
FFPROBE_CMD = get_cmd_from_env("ffprobe", "FFPROBE_PATH")
FFMPEG_NORMALIZE_CMD = get_cmd_from_env("ffmpeg-normalize", "FFMPEG_NORMALIZE_PATH")

DEFAULT_AUDIO_PRCS_CMDS = [
FFMPEG_CMD + " -hide_banner -i \"{in_}\" -vn -af \"asplit[a],aphasemeter=video=0,\
Expand Down
1 change: 1 addition & 0 deletions docs/CHANGELOG.zh-Hans.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
- 修复delete_chars问题当使用`-of full-src`时。
- 修复api_xfyun.py中的os.remove()文件占用问题。
- 修复DEFAULT_AUDIO_PRCS_CMDS和DEFAULT_CHECK_CMD。
- 修复依赖查找中,路径检查的问题。

#### 删除(未发布)

Expand Down

0 comments on commit 76d41a7

Please sign in to comment.