Skip to content

Commit

Permalink
put DEVNULL into compat.py (#432)
Browse files Browse the repository at this point in the history
  • Loading branch information
bearney74 committed Feb 26, 2017
1 parent ff82fe8 commit ec57a19
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 42 deletions.
6 changes: 1 addition & 5 deletions moviepy/audio/io/ffmpeg_audiowriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@
import numpy as np
import subprocess as sp

from moviepy.compat import PY3
from moviepy.compat import PY3, DEVNULL

import os
if PY3:
from subprocess import DEVNULL # py3k
else:
DEVNULL = open(os.devnull, 'wb')

from tqdm import tqdm
from moviepy.config import get_setting
Expand Down
6 changes: 1 addition & 5 deletions moviepy/audio/io/readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@

from moviepy.video.io.ffmpeg_reader import ffmpeg_parse_infos
from moviepy.config import get_setting
from moviepy.compat import PY3
from moviepy.compat import PY3, DEVNULL
import os
if PY3:
from subprocess import DEVNULL # py3k
else:
DEVNULL = open(os.devnull, 'wb')


class FFMPEG_AudioReader:
Expand Down
6 changes: 6 additions & 0 deletions moviepy/compat.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
import os
import sys
PY3=sys.version_info.major >= 3

if PY3:
from subprocess import DEVNULL # py3k
else:
DEVNULL = open(os.devnull, 'wb')
7 changes: 1 addition & 6 deletions moviepy/config.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import os
import subprocess as sp
try:
from subprocess import DEVNULL # py3k
except ImportError:
DEVNULL = open(os.devnull, 'wb')
from .compat import DEVNULL

if os.name == 'nt':
try:
Expand Down Expand Up @@ -103,5 +100,3 @@ def change_settings(new_settings={}, file=None):
print( "MoviePy : ImageMagick successfully found." )
else:
print( "MoviePy : can't find or access ImageMagick." )


7 changes: 2 additions & 5 deletions moviepy/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
import re

import os
try:
from subprocess import DEVNULL # py3k
except ImportError:
DEVNULL = open(os.devnull, 'wb')
from .compat import DEVNULL


def sys_write_flush(s):
Expand Down Expand Up @@ -156,4 +153,4 @@ def find_extension(codec):
for ext,infos in extensions_dict.items():
if ('codec' in infos) and codec in infos['codec']:
return ext
raise ValueError
raise ValueError
6 changes: 1 addition & 5 deletions moviepy/video/VideoClip.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@
convert_masks_to_RGB,
use_clip_fps_by_default)

from ..compat import PY3
try:
from subprocess import DEVNULL # py3k
except ImportError:
DEVNULL = open(os.devnull, 'wb')
from ..compat import PY3, DEVNULL


class VideoClip(Clip):
Expand Down
6 changes: 1 addition & 5 deletions moviepy/video/io/ffmpeg_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,9 @@
import numpy as np
from moviepy.config import get_setting # ffmpeg, ffmpeg.exe, etc...
from moviepy.tools import cvsecs
from moviepy.compat import PY3
from moviepy.compat import PY3, DEVNULL

import os
if PY3:
from subprocess import DEVNULL # py3k
else:
DEVNULL = open(os.devnull, 'wb')


class FFMPEG_VideoReader:
Expand Down
8 changes: 1 addition & 7 deletions moviepy/video/io/ffmpeg_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,7 @@
import os
import numpy as np

from moviepy.compat import PY3

if PY3:
from subprocess import DEVNULL # py3k
else:
DEVNULL = open(os.devnull, 'wb')

from moviepy.compat import PY3, DEVNULL
from moviepy.config import get_setting
from moviepy.tools import verbose_print

Expand Down
5 changes: 1 addition & 4 deletions moviepy/video/io/gif_writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
from moviepy.tools import verbose_print, subprocess_call
import numpy as np

try:
from subprocess import DEVNULL # py3k
except ImportError:
DEVNULL = open(os.devnull, 'wb')
from moviepy.compat import DEVNULL

try:
import imageio
Expand Down

0 comments on commit ec57a19

Please sign in to comment.