def set_log_file(self, filename): if self.log_file is not None: for feature in self.features: feature.handle_detach_log_file(self, self.log_file) if filename is None: if self.dispatcher is not None: self.dispatcher.cancel() self.dispatcher = None self.log_file = None self.tmpfile = None self.actions.groups["RowActions"].props.sensitive = False else: if self.tmpfile and filename != self.tmpfile.name: self.tmpfile = tempfile.NamedTemporaryFile() shutil.copyfile(filename, self.tmpfile.name) filename = self.tmpfile.name self.logger.debug("setting log file %r", filename) try: self.setup_model(LazyLogModel()) self.dispatcher = Common.Data.GSourceDispatcher() self.log_file = Data.LogFile(filename, self.dispatcher) except EnvironmentError as exc: try: file_size = os.path.getsize(filename) except EnvironmentError: pass else: if file_size == 0: # Trying to mmap an empty file results in an invalid # argument error. self.show_error(_("Could not open file"), _("The selected file is empty")) return self.handle_environment_error(exc, filename) return basename = os.path.basename(filename) self.gtk_window.props.title = _("%s - GStreamer Debug Viewer") % ( basename, ) self.log_file.consumers.append(self) self.log_file.start_loading()
def __init__(self, filename): self.main_loop = gobject.MainLoop() self.log_file = Data.LogFile(filename, Common.Data.DefaultDispatcher()) self.log_file.consumers.append(self)