def showUserAndLogMessage(before, text="", level=QGis.Info, duration=3, onlyLog=False): ''' Show user & log info/warning/error messages ''' if not onlyLog: iface.messageBar().popWidget() iface.messageBar().pushMessage( before, text, level=level, duration=duration) if level == QGis.Info: log.info(text) elif level == QGis.Warning: log.warning(text) elif level == QGis.Critical: log.error(text) return
def parse_options(self, opt, twopass=None): """ Parse Options """ f = opt["format"] if f not in self.formats: log.error("Requested unknown format: " + str(f)) format_options = self.formats[f]().parse_options(opt) if format_options is None: log.error("Unknown container format error") """ audio options""" if "audio" not in opt or twopass == 1: opt_audio = {"codec": None} else: opt_audio = opt["audio"] if not isinstance(opt_audio, dict) or "codec" not in opt_audio: log.error("Invalid audio codec specification") c = opt_audio["codec"] if c not in self.audio_codecs: log.error("Requested unknown audio codec " + str(c)) audio_options = self.audio_codecs[c]().parse_options(opt_audio) if audio_options is None: log.error("Unknown audio codec error") """ video options""" if "video" not in opt: opt_video = {"codec": None} else: opt_video = opt["video"] if not isinstance(opt_video, dict) or "codec" not in opt_video: log.error("Invalid video codec specification") c = opt_video["codec"] if c not in self.video_codecs: log.error("Requested unknown video codec " + str(c)) video_options = self.video_codecs[c]().parse_options(opt_video) if video_options is None: log.error("Unknown video codec error") if "subtitle" not in opt: opt_subtitle = {"codec": None} else: opt_subtitle = opt["subtitle"] if not isinstance(opt_subtitle, dict) or "codec" not in opt_subtitle: log.error("Invalid subtitle codec specification") c = opt_subtitle["codec"] if c not in self.subtitle_codecs: log.error("Requested unknown subtitle codec " + str(c)) subtitle_options = self.subtitle_codecs[c]().parse_options( opt_subtitle) if subtitle_options is None: log.error("Unknown subtitle codec error") """ aggregate all options""" optlist = audio_options + video_options + subtitle_options + format_options if twopass == 1: optlist.extend(["-pass", "1"]) elif twopass == 2: optlist.extend(["-pass", "2"]) return optlist
def parse_options(self, opt, twopass=None): f = opt['format'] if f not in self.formats: log.error('Requested unknown format: ' + str(f)) format_options = self.formats[f]().parse_options(opt) if format_options is None: log.error('Unknown container format error') ''' audio options''' if 'audio' not in opt or twopass == 1: opt_audio = {'codec': None} else: opt_audio = opt['audio'] if not isinstance(opt_audio, dict) or 'codec' not in opt_audio: log.error('Invalid audio codec specification') c = opt_audio['codec'] if c not in self.audio_codecs: log.error('Requested unknown audio codec ' + str(c)) audio_options = self.audio_codecs[c]().parse_options(opt_audio) if audio_options is None: log.error('Unknown audio codec error') ''' video options''' if 'video' not in opt: opt_video = {'codec': None} else: opt_video = opt['video'] if not isinstance(opt_video, dict) or 'codec' not in opt_video: log.error('Invalid video codec specification') c = opt_video['codec'] if c not in self.video_codecs: log.error('Requested unknown video codec ' + str(c)) video_options = self.video_codecs[c]().parse_options(opt_video) if video_options is None: log.error('Unknown video codec error') if 'subtitle' not in opt: opt_subtitle = {'codec': None} else: opt_subtitle = opt['subtitle'] if not isinstance(opt_subtitle, dict) or 'codec' not in opt_subtitle: log.error('Invalid subtitle codec specification') c = opt_subtitle['codec'] if c not in self.subtitle_codecs: log.error('Requested unknown subtitle codec ' + str(c)) subtitle_options = self.subtitle_codecs[c]( ).parse_options(opt_subtitle) if subtitle_options is None: log.error('Unknown subtitle codec error') ''' aggregate all options''' optlist = audio_options + video_options + subtitle_options + format_options if twopass == 1: optlist.extend(['-pass', '1']) elif twopass == 2: optlist.extend(['-pass', '2']) return optlist