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