diff options
| author | tassaron | 2017-07-13 17:03:25 -0400 |
|---|---|---|
| committer | tassaron | 2017-07-13 17:03:25 -0400 |
| commit | 06c27a48bc3f52e15c15445d822e8a6f523ab98f (patch) | |
| tree | d238a05980dddef9c76786a755de04c33028088c /src | |
| parent | b7931572a73d408dceecc4b17b784a0338e0e35b (diff) | |
more error messages for blank components
Diffstat (limited to 'src')
| -rw-r--r-- | src/components/image.py | 7 | ||||
| -rw-r--r-- | src/components/sound.py | 11 | ||||
| -rw-r--r-- | src/components/text.py | 8 | ||||
| -rw-r--r-- | src/components/video.py | 13 | ||||
| -rw-r--r-- | src/video_thread.py | 28 |
5 files changed, 53 insertions, 14 deletions
diff --git a/src/components/image.py b/src/components/image.py index 6465bc9..6a70424 100644 --- a/src/components/image.py +++ b/src/components/image.py @@ -48,14 +48,15 @@ class Component(Component): def properties(self): props = ['static'] - if self.imagePath and not os.path.exists(self.imagePath): + if not os.path.exists(self.imagePath): props.append('error') return props def error(self): + if not self.imagePath: + return "There is no image selected." if not os.path.exists(self.imagePath): - return "The image selected on " \ - "layer %s does not exist!" % str(self.compPos) + return "The image selected does not exist!" def frameRender(self, layerNo, frameNo): width = int(self.settings.value('outputWidth')) diff --git a/src/components/sound.py b/src/components/sound.py index 9c114a8..2ffb682 100644 --- a/src/components/sound.py +++ b/src/components/sound.py @@ -34,7 +34,16 @@ class Component(Component): pass def properties(self): - return ['static', 'audio'] + props = ['static', 'audio'] + if not os.path.exists(self.sound): + props.append('error') + return props + + def error(self): + if not self.sound: + return "No audio file selected." + if not os.path.exists(self.sound): + return "The audio file selected no longer exists!" def audio(self): return (self.sound, {}) diff --git a/src/components/text.py b/src/components/text.py index 4435b80..c52bdc5 100644 --- a/src/components/text.py +++ b/src/components/text.py @@ -121,7 +121,13 @@ class Component(Component): return self.addText(width, height) def properties(self): - return ['static'] + props = ['static'] + if not self.title: + props.append('error') + return props + + def error(self): + return "No text provided." def frameRender(self, layerNo, frameNo): width = int(self.settings.value('outputWidth')) diff --git a/src/components/video.py b/src/components/video.py index 53487b1..8861d70 100644 --- a/src/components/video.py +++ b/src/components/video.py @@ -115,6 +115,7 @@ class Component(Component): self.settings = parent.settings page = self.loadUi('video.ui') self.videoPath = '' + self.badVideo = False self.x = 0 self.y = 0 self.loopVideo = False @@ -156,14 +157,18 @@ class Component(Component): props = [] if self.useAudio: props.append('audio') - if self.videoPath and not os.path.exists(self.videoPath): + if not self.videoPath or self.badVideo \ + or not os.path.exists(self.videoPath): props.append('error') return props def error(self): + if not self.videoPath: + return "There is no video selected." if not os.path.exists(self.videoPath): - return "The video selected on " \ - "layer %s does not exist!" % str(self.compPos) + return "The video selected does not exist!" + if self.badVideo: + return "The video selected is corrupt!" def audio(self): return (self.videoPath, {'map': '-v'}) @@ -300,6 +305,7 @@ def finalizeFrame(self, imageData, width, height): '### BAD VIDEO SELECTED ###\n' 'Video will not export with these settings' ) + self.badVideo = True return BlankFrame(width, height) if self.scale != 100 \ @@ -308,4 +314,5 @@ def finalizeFrame(self, imageData, width, height): frame.paste(image, box=(self.xPosition, self.yPosition)) else: frame = image + self.badVideo = False return frame diff --git a/src/video_thread.py b/src/video_thread.py index bfb0cc4..9ce9cc8 100644 --- a/src/video_thread.py +++ b/src/video_thread.py @@ -141,7 +141,7 @@ class Worker(QtCore.QObject): ])) self.staticComponents = {} numComps = len(self.components) - for compNo, comp in enumerate(self.components): + for compNo, comp in enumerate(reversed(self.components)): comp.preFrameRender( worker=self, completeAudioArray=self.completeAudioArray, @@ -151,26 +151,41 @@ class Worker(QtCore.QObject): ) if 'error' in comp.properties(): + self.cancel() self.canceled = True errMsg = "Component #%s encountered an error!" % compNo \ - if comp.error() is None else comp.error() + if comp.error() is None else 'Component #%s (%s): %s' % ( + str(compNo), + str(comp), + comp.error() + ) self.parent.showMessage( msg=errMsg, icon='Warning', parent=None # MainWindow is in a different thread ) + break if 'static' in comp.properties(): self.staticComponents[compNo] = \ comp.frameRender(compNo, 0).copy() + if self.canceled: + print('Export cancelled by component #%s (%s): %s' % ( + compNo, str(comp), comp.error() + )) + self.progressBarSetText.emit('Export Canceled') + self.encoding.emit(False) + self.videoCreated.emit() + return + # Merge consecutive static component frames together - for compNo in range(len(self.components), 0, -1): + for compNo in range(len(self.components)): if compNo not in self.staticComponents \ - or compNo - 1 not in self.staticComponents: + or compNo + 1 not in self.staticComponents: continue - self.staticComponents[compNo - 1] = Image.alpha_composite( + self.staticComponents[compNo + 1] = Image.alpha_composite( self.staticComponents.pop(compNo), - self.staticComponents[compNo - 1] + self.staticComponents[compNo + 1] ) self.staticComponents[compNo] = None @@ -278,6 +293,7 @@ class Worker(QtCore.QObject): def cancel(self): self.canceled = True + self.stopped = True self.core.cancel() for comp in self.components: |
