def validateAssets(parent, tasks, updateAssets=True, askForLang=True): for task in tasks: sub = task.sub ref = task.ref if sub == None or sub.path == None or sub.no == None: raise raiseTaskError(task, _('Subtitles not set')) if ref == None or ref.path == None or ref.no == None: raise raiseTaskError(task, _('Reference file not set')) if sub.path == ref.path and sub.no == ref.no: raise raiseTaskError( task, _('Subtitles can\'t be the same as reference')) if ref.type == 'audio' and not ref.lang: raise raiseTaskError(task, _('Select reference language first')) if task.out and task.out.path: task.out.validateOutputPattern() if askForLang and settings().showLanguageNotSelectedPopup: if not askForLangSelection(parent, tasks): return False assetListNotReady = assetListUpdater.isRunning() needed = set() for task in tasks: needed |= assetManager.getAssetsForTask(task) missing = [asset for asset in needed if asset.isMissing()] if assetListNotReady and missing: with BusyDlg(self, _('Downloading assets list...')) as dlg: dlg.ShowModalWhile(assetListUpdater.isRunning) missing = [asset for asset in needed if asset.isMissing()] if missing: msg = [_('Following assets are missing on server:'), ''] msg += [' - ' + asset.getPrettyName() for asset in missing] raise Error('\n'.join(msg)) nonLocal = [asset for asset in needed if not asset.isLocal()] if nonLocal: if not askForDownloadAssets(parent, nonLocal): return False if updateAssets: update = [asset for asset in needed if asset.isUpgradable()] if update: askForUpdateAssets(parent, update) missing = [asset for asset in needed if not asset.isLocal()] if missing: msg = [_('Following assets are missing:')] msg += [' - ' + asset.getPrettyName() for asset in missing] raise Error('\n'.join(msg)) return True
def validateAssets(parent, tasks, updateAssets=True, askForLang=True): for task in tasks: sub = task.sub ref = task.ref if sub == None or sub.path == None or sub.no == None: raise raiseTaskError(task, _('Subtitles not set')) if ref == None or ref.path == None or ref.no == None: raise raiseTaskError(task, _('Reference file not set')) if sub.path == ref.path and sub.no == ref.no: raise raiseTaskError( task, _('Subtitles can\'t be the same as reference')) if ref.type == 'audio' and not ref.lang: raise raiseTaskError(task, _('Select reference language first')) if task.out and task.out.path: task.out.validateOutputPattern() if askForLang and settings().showLanguageNotSelectedPopup: if not askForLangSelection(parent, tasks): return False needed = set() for task in tasks: needed |= assetManager.getAssetsForTask(task) missing = [asset for asset in needed if asset.isMissing()] if missing and updateAssetList(parent): missing = [asset for asset in needed if asset.isMissing()] if missing: raiseNotSupportedAssets(missing) if not missing: nonLocal = [asset for asset in needed if not asset.isLocal()] if nonLocal: if not askForDownloadAssets(parent, nonLocal): return False missing = [asset for asset in needed if not asset.isLocal()] if missing: raiseMissingAssets(missing) if updateAssets: update = [asset for asset in needed if asset.isUpgradable()] if update: askForUpdateAssets(parent, update) return True
def getMissingAssets(self, task): needed = assetManager.getAssetsForTask(task) nonLocal = [asset for asset in needed if not asset.isLocal()] if nonLocal and not self.offline: self.downloadAssetList() missing = [asset for asset in nonLocal if asset.isMissing()] if missing: self.printMissingAssets(missing) return False for asset in nonLocal: if not self.downloadAsset(asset): return False missing = [asset for asset in needed if not asset.isLocal()] if missing: self.printMissingAssets(missing) return False return True