def printException(self, v, exc, msg=None): res = error.getExceptionMessage(exc) if msg: res = '{}: {}'.format(msg, res) self.println(v, '[!] ' + res.replace('\n', '\n[-] ')) if isinstance(exc, error.Error): for key, val in exc.fields.items(): self.println(v + 1, '[-] {}: {}'.format(key, val))
def loadFiles(self, paths, types=None): items = [] errors = [] for path in paths: try: items.append(InputItem(path=path, types=types)) except Exception as err: errors.append('# {}'.format(path)) errors.append(error.getExceptionMessage(err)) errors.append(error.getExceptionDetails()) errors.append('\n') return items, errors
def loadFile(path, skipMissing): try: item = type(path=path) if item.hasMatchingStream(): items.append(item) elif not skipMissing: errors.append((path, _('There are no usable streams'))) except Exception as err: if not skipMissing or error.getExceptionField( err, 'averror') != 'AVERROR_INVALIDDATA': msg = error.getExceptionMessage( err) + '\n' + error.getExceptionDetails() errors.append((path, msg))
def showExceptionDlg(parent=None, excInfo=None, msg=None): def showDlg(msg, details): with ErrorWin(parent, msg) as dlg: dlg.addDetails(details) dlg.ShowModal() if not msg: msg = error.getExceptionMessage(excInfo and excInfo[1]) details = error.getExceptionDetails(excInfo) if wx.IsMainThread(): showDlg(msg, details) else: wx.CallAfter(showDlg, msg, details)
def synchronize(self, task): sync = Synchronizer(task.sub, task.ref) try: sync.onError = self.onError sync.init() sync.start() effort = -1 while sync.isRunning() and effort < settings().minEffort: status = sync.getStatus() effort = status.effort self.printStats(status) sleep(1) sync.stop() status = sync.getStatus() if status and status.subReady: self.printStats(status, endline=True) path = task.getOutputPath() pr.println(1, '[+] saving to {}'.format(path)) try: npath = sync.getSynchronizedSubtitles().save( path=path, encoding=task.getOutputEnc(), fps=task.out.fps, overwrite=settings().overwrite) if path != npath: pr.println( 1, '[+] file exists, saving to {}'.format(npath)) pr.println(1, '[+] done') except error.Error as e: pr.println(0, '[!] {}'.format(error.getExceptionMessage(e))) else: pr.println(0, '[-] couldn\'t synchronize!') finally: sync.destroy()
def downloadAsset(self, asset): name = asset.getPrettyName() updater = asset.getUpdater() updater.start() while updater.isRunning(): self.printDownloadStats(name, updater.getStatus()) sleep(1) status = updater.getStatus() if status.state == 'done' and status.detail == 'success': self.printDownloadStats(name, status, endline=True) return True else: pr.println(0, '[!] FAILED') if status.error: pr.println( 1, '[!] {}'.format( error.getExceptionMessage(status.error[1]))) pr.println(2, error.getExceptionDetails(status.error)) return False
def showDlg(msg): if not msg: msg = error.getExceptionMessage(exc) with ErrorWin(parent, msg) as dlg: dlg.addDetails(*traceback.format_exception(type, exc, tb)) dlg.ShowModal()