Permalink
Browse files

update check function

  • Loading branch information...
sdpython committed Jan 10, 2018
1 parent 4128f1c commit 1c2f811b05b4f9389aa63b96a9f58933d15fa920
View
@@ -16,6 +16,7 @@ script:
- { CMD: "python -u setup.py unittests -e \".*noenv3.*\"", NAME: "UT_NOENV3" }
- { CMD: "python -u setup.py unittests -e \".*noenv4.*\"", NAME: "UT_NOENV4" }
- { CMD: "python -u setup.py unittests -e \".*noenv5.*\"", NAME: "UT_NOENV5" }
- { CMD: "python -u setup.py unittests -e \".*noenv6.*\"", NAME: "UT_NOENV6" }
- { CMD: "python -X faulthandler -X showrefcount -u setup.py unittests_LONG", NAME: "UT_LONG" }
- { CMD: "python -X faulthandler -X showrefcount -u setup.py unittests_SKIP", NAME: "UT_SKIP" }
after_script:
@@ -49,7 +49,7 @@ def test_check(self):
self._testMethodName,
OutputPrint=__name__ == "__main__")
check(kind="video")
check(kind="video", fLOG=fLOG)
if __name__ == "__main__":
@@ -52,13 +52,14 @@ def _setup_hook(add_print=False, unit_test=False):
print("Success: _setup_hook")
def check(log=False, kind=None):
def check(log=False, kind=None, fLOG=None):
"""
Checks the library is working.
It raises an exception.
@param log if True, display information, otherwise
@param kind None or ``'scratch'`` or ``'video'``
@param fLOG logging function
@return 0 or exception
"""
r = True
@@ -67,7 +68,7 @@ def check(log=False, kind=None):
r &= check()
if kind is None or kind == "video":
from .faq.faq_video import check
r &= check()
r &= check(fLOG=fLOG)
return r
@@ -9,6 +9,7 @@
import sys
import numpy
import tempfile
import time
from pytube import YouTube
from imageio import imsave
import moviepy.audio.fx.all as afx
@@ -32,16 +33,34 @@ class FontError(Exception):
pass
def check():
def check(fLOG=None):
"""
Checks a couple of functionality works.
The test takes 5-6 seconds to download,
4-5 seconds to process the video.
@param logging function
"""
t1 = time.clock()
with tempfile.TemporaryDirectory() as temp:
vid = download_youtube_video("4o5baMYWdtQ", temp)
if fLOG:
fLOG('[check] download_youtube_video')
vid = download_youtube_video("4o5baMYWdtQ", temp, res=None)
vid = os.path.join(temp, vid)
t2 = time.clock()
if fLOG:
fLOG('[check] video_compose')
ext = video_compose(vid, vid, t2=2, place="h2")
dest = os.path.join(temp, "res.mp4")
video_save(exp, dest)
return os.path.exists(dest)
if fLOG:
fLOG('[check] video_save')
video_save(ext, dest)
res = os.path.exists(dest)
delta1 = time.clock() - t1
delta2 = time.clock() - t2
if fLOG:
fLOG("[check] video time={0} - video={1}".format(delta1, delta2))
return res
##########
@@ -59,7 +78,7 @@ def download_youtube_video(tag, output_path=None, res='720p', mime_type="video/m
@param mime_type see :epkg:`youtube`
@param res see :epkg:`youtube`
@param kwargs see :epkg:`youtube`
@return filename
@return filename (relative to *output_path*)
.. faqref::
:title: Télécharger une vidéo sur YouTube

0 comments on commit 1c2f811

Please sign in to comment.