ctrl-c ends commandline mode properly
This commit is contained in:
parent
ad6dd9f532
commit
8411857030
2
setup.py
2
setup.py
|
@ -2,7 +2,7 @@ from setuptools import setup
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
__version__ = '2.0.0.rc4'
|
__version__ = '2.0.0rc5'
|
||||||
|
|
||||||
|
|
||||||
def package_files(directory):
|
def package_files(directory):
|
||||||
|
|
|
@ -8,6 +8,7 @@ import argparse
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
import signal
|
||||||
|
|
||||||
from core import Core
|
from core import Core
|
||||||
|
|
||||||
|
@ -91,6 +92,9 @@ class Command(QtCore.QObject):
|
||||||
for arg in args:
|
for arg in args:
|
||||||
self.core.selectedComponents[i].command(arg)
|
self.core.selectedComponents[i].command(arg)
|
||||||
|
|
||||||
|
# ctrl-c stops the export thread
|
||||||
|
signal.signal(signal.SIGINT, self.stopVideo)
|
||||||
|
|
||||||
if self.args.export and self.args.projpath:
|
if self.args.export and self.args.projpath:
|
||||||
errcode, data = self.core.parseAvFile(projPath)
|
errcode, data = self.core.parseAvFile(projPath)
|
||||||
for key, value in data['WindowFields']:
|
for key, value in data['WindowFields']:
|
||||||
|
@ -124,6 +128,11 @@ class Command(QtCore.QObject):
|
||||||
self.worker.progressBarSetText.connect(self.progressBarSetText)
|
self.worker.progressBarSetText.connect(self.progressBarSetText)
|
||||||
self.createVideo.emit()
|
self.createVideo.emit()
|
||||||
|
|
||||||
|
def stopVideo(self, *args):
|
||||||
|
self.worker.error = True
|
||||||
|
self.worker.cancelExport()
|
||||||
|
self.worker.cancel()
|
||||||
|
|
||||||
@QtCore.pyqtSlot(str)
|
@QtCore.pyqtSlot(str)
|
||||||
def progressBarSetText(self, value):
|
def progressBarSetText(self, value):
|
||||||
if 'Export ' in value:
|
if 'Export ' in value:
|
||||||
|
|
|
@ -98,7 +98,8 @@ class Component(Component):
|
||||||
|
|
||||||
def preFrameRender(self, **kwargs):
|
def preFrameRender(self, **kwargs):
|
||||||
super().preFrameRender(**kwargs)
|
super().preFrameRender(**kwargs)
|
||||||
self.previewPipe.wait()
|
if self.previewPipe is not None:
|
||||||
|
self.previewPipe.wait()
|
||||||
self.updateChunksize()
|
self.updateChunksize()
|
||||||
w, h = scale(self.scale, self.width, self.height, str)
|
w, h = scale(self.scale, self.width, self.height, str)
|
||||||
self.video = FfmpegVideo(
|
self.video = FfmpegVideo(
|
||||||
|
|
10
src/core.py
10
src/core.py
|
@ -13,8 +13,8 @@ import toolkit
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger('AVP.Core')
|
log = logging.getLogger('AVP.Core')
|
||||||
STDOUT_LOGLVL = logging.INFO
|
STDOUT_LOGLVL = logging.WARNING
|
||||||
FILE_LOGLVL = logging.VERBOSE
|
FILE_LOGLVL = None
|
||||||
|
|
||||||
|
|
||||||
class Core:
|
class Core:
|
||||||
|
@ -77,8 +77,7 @@ class Core:
|
||||||
if compPos < 0 or compPos > len(self.selectedComponents):
|
if compPos < 0 or compPos > len(self.selectedComponents):
|
||||||
compPos = len(self.selectedComponents)
|
compPos = len(self.selectedComponents)
|
||||||
if len(self.selectedComponents) > 50:
|
if len(self.selectedComponents) > 50:
|
||||||
return None
|
return -1
|
||||||
|
|
||||||
if type(component) is int:
|
if type(component) is int:
|
||||||
# create component using module index in self.modules
|
# create component using module index in self.modules
|
||||||
moduleIndex = int(component)
|
moduleIndex = int(component)
|
||||||
|
@ -188,7 +187,6 @@ class Core:
|
||||||
|
|
||||||
for key, value in data['Settings']:
|
for key, value in data['Settings']:
|
||||||
Core.settings.setValue(key, value)
|
Core.settings.setValue(key, value)
|
||||||
|
|
||||||
for tup in data['Components']:
|
for tup in data['Components']:
|
||||||
name, vers, preset = tup
|
name, vers, preset = tup
|
||||||
clearThis = False
|
clearThis = False
|
||||||
|
@ -213,7 +211,7 @@ class Core:
|
||||||
self.moduleIndexFor(name),
|
self.moduleIndexFor(name),
|
||||||
loader
|
loader
|
||||||
)
|
)
|
||||||
if i is None:
|
if i == -1:
|
||||||
loader.showMessage(msg="Too many components!")
|
loader.showMessage(msg="Too many components!")
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ class FramePainter(QtGui.QPainter):
|
||||||
super().setPen(penStyle)
|
super().setPen(penStyle)
|
||||||
|
|
||||||
def finalize(self):
|
def finalize(self):
|
||||||
|
log.verbose("Finalizing FramePainter")
|
||||||
imBytes = self.image.bits().asstring(self.image.byteCount())
|
imBytes = self.image.bits().asstring(self.image.byteCount())
|
||||||
frame = Image.frombytes(
|
frame = Image.frombytes(
|
||||||
'RGBA', (self.image.width(), self.image.height()), imBytes
|
'RGBA', (self.image.width(), self.image.height()), imBytes
|
||||||
|
|
|
@ -252,9 +252,14 @@ class Worker(QtCore.QObject):
|
||||||
print('############################')
|
print('############################')
|
||||||
log.info('Opening pipe to ffmpeg')
|
log.info('Opening pipe to ffmpeg')
|
||||||
log.info(cmd)
|
log.info(cmd)
|
||||||
self.out_pipe = openPipe(
|
try:
|
||||||
ffmpegCommand, stdin=sp.PIPE, stdout=sys.stdout, stderr=sys.stdout
|
self.out_pipe = openPipe(
|
||||||
)
|
ffmpegCommand,
|
||||||
|
stdin=sp.PIPE, stdout=sys.stdout, stderr=sys.stdout
|
||||||
|
)
|
||||||
|
except sp.CalledProcessError:
|
||||||
|
log.critical('Ffmpeg pipe couldn\'t be created!')
|
||||||
|
raise
|
||||||
|
|
||||||
# =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~==~=~=~=~=~=~=~=~=~=~=~=~=~=~
|
# =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~==~=~=~=~=~=~=~=~=~=~=~=~=~=~
|
||||||
# START CREATING THE VIDEO
|
# START CREATING THE VIDEO
|
||||||
|
|
Reference in New Issue