aboutsummaryrefslogtreecommitdiff
path: root/src/toolkit
diff options
context:
space:
mode:
authortassaron2017-08-10 16:04:41 -0400
committertassaron2017-08-10 16:04:41 -0400
commit1c4afc96d69789f16284c067ffd7098dc7b2ca70 (patch)
treef04e4117c133a539a87ffcae00d0cd66fa1517f4 /src/toolkit
parent8baa24e87847a0c7c530cbb55196103ce9cc511c (diff)
using the builtin logging module
Diffstat (limited to 'src/toolkit')
-rw-r--r--src/toolkit/ffmpeg.py19
-rw-r--r--src/toolkit/frame.py6
2 files changed, 18 insertions, 7 deletions
diff --git a/src/toolkit/ffmpeg.py b/src/toolkit/ffmpeg.py
index 3421049..6ab445c 100644
--- a/src/toolkit/ffmpeg.py
+++ b/src/toolkit/ffmpeg.py
@@ -8,12 +8,16 @@ import subprocess
import threading
import signal
from queue import PriorityQueue
+import logging
import core
from toolkit.common import checkOutput, pipeWrapper
from component import ComponentError
+log = logging.getLogger('AVP.Toolkit.Ffmpeg')
+
+
class FfmpegVideo:
'''Opens a pipe to ffmpeg and stores a buffer of raw video frames.'''
@@ -88,13 +92,14 @@ class FfmpegVideo:
def fillBuffer(self):
logFilename = os.path.join(
- core.Core.dataDir, 'extra_%s.log' % str(self.component.compPos))
- with open(logFilename, 'w') as log:
- log.write(" ".join(self.command) + '\n\n')
- with open(logFilename, 'a') as log:
+ core.Core.logDir, 'render_%s.log' % str(self.component.compPos))
+ log.debug('Creating ffmpeg process (log at %s)' % logFilename)
+ with open(logFilename, 'w') as logf:
+ logf.write(" ".join(self.command) + '\n\n')
+ with open(logFilename, 'a') as logf:
self.pipe = openPipe(
self.command, stdin=subprocess.DEVNULL, stdout=subprocess.PIPE,
- stderr=log, bufsize=10**8
+ stderr=logf, bufsize=10**8
)
while True:
if self.parent.canceled:
@@ -375,7 +380,7 @@ def getAudioDuration(filename):
try:
info = fileInfo.decode("utf-8").split('\n')
except UnicodeDecodeError as e:
- print('Unicode error:', str(e))
+ log.error('Unicode error:', str(e))
return False
for line in info:
@@ -398,7 +403,7 @@ def readAudioFile(filename, videoWorker):
'''
duration = getAudioDuration(filename)
if not duration:
- print('Audio file doesn\'t exist or unreadable.')
+ log.error('Audio file doesn\'t exist or unreadable.')
return
command = [
diff --git a/src/toolkit/frame.py b/src/toolkit/frame.py
index 7e83d58..02f9229 100644
--- a/src/toolkit/frame.py
+++ b/src/toolkit/frame.py
@@ -7,10 +7,14 @@ from PIL.ImageQt import ImageQt
import sys
import os
import math
+import logging
import core
+log = logging.getLogger('AVP.Toolkit.Frame')
+
+
class FramePainter(QtGui.QPainter):
'''
A QPainter for a blank frame, which can be converted into a
@@ -79,6 +83,7 @@ def FloodFrame(width, height, RgbaTuple):
@defaultSize
def BlankFrame(width, height):
'''The base frame used by each component to start drawing.'''
+ log.debug('Creating new %s*%s blank frame' % (width, height))
return FloodFrame(width, height, (0, 0, 0, 0))
@@ -88,6 +93,7 @@ def Checkerboard(width, height):
A checkerboard to represent transparency to the user.
TODO: Would be cool to generate this image with numpy instead.
'''
+ log.debug('Creating new %s*%s checkerboard' % (width, height))
image = FloodFrame(1920, 1080, (0, 0, 0, 0))
image.paste(Image.open(
os.path.join(core.Core.wd, "background.png")),