Commit cf51df57 authored by Tim Heap's avatar Tim Heap
Browse files

Move w.utils.ffmpeg_installed to w.ffmpeg.installed

parent c8f67197
......@@ -106,7 +106,7 @@ class TestVideoAddView(TestCase, WagtailTestUtils):
root_collection = Collection.get_first_root_node()
self.assertEqual(video.collection, root_collection)
@patch('wagtailvideos.models.ffmpeg_installed')
@patch('wagtailvideos.ffmpeg.installed')
def test_add_no_ffmpeg(self, ffmpeg_installed):
ffmpeg_installed.return_value = False
......
......@@ -3,12 +3,12 @@ from __future__ import absolute_import, print_function, unicode_literals
from django.apps import AppConfig
from django.core.checks import Warning, register
from wagtailvideos.utils import ffmpeg_installed
from wagtailvideos import ffmpeg
def ffmpeg_check(app_configs, **kwargs):
messages = []
if not ffmpeg_installed():
if not ffmpeg.installed():
messages.append(
Warning(
'ffmpeg could not be found on your system. Transcoding will be disabled',
......
from __future__ import absolute_import, print_function, unicode_literals
try:
from shutil import which
except ImportError:
from distutils.spawn import find_executable as which
def ffmpeg_installed(path=None):
def installed(path=None):
return which('ffmpeg', path=path) is not None
......@@ -29,7 +29,7 @@ from wagtail.wagtailcore.models import CollectionMember
from wagtail.wagtailsearch import index
from wagtail.wagtailsearch.queryset import SearchableQuerySetMixin
from wagtailvideos.utils import ffmpeg_installed
from wagtailvideos import ffmpeg
logger = logging.getLogger(__name__)
......@@ -356,6 +356,9 @@ def video_delete(sender, instance, **kwargs):
# Fields that need the actual video file to create
@receiver(post_save, sender=Video)
def video_saved(sender, instance, **kwargs):
if not ffmpeg.installed():
return
if hasattr(instance, '_from_signal'):
return
instance.thumbnail = instance.get_thumbnail()
......
......@@ -15,10 +15,10 @@ from wagtail.wagtailadmin.utils import (
from wagtail.wagtailcore.models import Collection
from wagtail.wagtailsearch.backends import get_search_backends
from wagtailvideos import ffmpeg
from wagtailvideos.forms import VideoTranscodeAdminForm, get_video_form
from wagtailvideos.models import Video
from wagtailvideos.permissions import permission_policy
from wagtailvideos.utils import ffmpeg_installed
permission_checker = PermissionPolicyChecker(permission_policy)
......@@ -120,7 +120,7 @@ def edit(request, video_id):
'video': video,
'form': form,
'filesize': video.get_file_size(),
'can_transcode': ffmpeg_installed(),
'can_transcode': ffmpeg.installed(),
'transcodes': video.transcodes.all(),
'transcode_form': VideoTranscodeAdminForm(video=video),
'user_can_delete': permission_policy.user_has_permission_for_instance(request.user, 'delete', video)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment