def __init__(self, app, undock_action=None): gtk.VBox.__init__(self) self.set_border_width(SPACING) self.app = app self.settings = app.settings self.system = app.system Loggable.__init__(self) self.log("New PitiviViewer") self.pipeline = None self._tmp_pipeline = None # Used for displaying a preview when trimming self.sink = None self.docked = True # Only used for restoring the pipeline position after a live clip trim preview: self._oldTimelinePos = None self._haveUI = False self._createUi() self.target = self.internal self.undock_action = undock_action if undock_action: self.undock_action.connect("activate", self._toggleDocked) if not self.settings.viewerDocked: self.undock()
def __init__(self, options): Loggable.__init__(self) self.options = options self._start_time = 0 self.stats = {'timeout': 0, 'failures': 0, 'passed': 0, 'skipped': 0} self.results = []
def __init__(self, instance, hadj): Gtk.DrawingArea.__init__(self) Zoomable.__init__(self) Loggable.__init__(self) self.log("Creating new ScaleRuler") self.app = instance self._seeker = Seeker() self.hadj = hadj hadj.connect("value-changed", self._hadjValueChangedCb) self.add_events(Gdk.EventMask.POINTER_MOTION_MASK | Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK | Gdk.EventMask.SCROLL_MASK) self.pixbuf = None # all values are in pixels self.pixbuf_offset = 0 self.pixbuf_offset_painted = 0 # This is the number of width we allocate for the pixbuf self.pixbuf_multiples = 4 self.position = 0 # In nanoseconds self.pressed = False self.need_update = True self.min_frame_spacing = 5.0 self.frame_height = 5.0 self.frame_rate = Gst.Fraction(1 / 1) self.ns_per_frame = float(1 / self.frame_rate) * Gst.SECOND self.connect('draw', self.drawCb) self.connect('configure-event', self.configureEventCb) self.callback_id = None
def __init__(self, train_config, data_model_wrapper, language_config, output_dir, validation_model, plot_model, cont_model): Loggable.__init__(self) self.train_config = train_config self.langs = language_config.langs self.logger.info('Language order: {0}'.format([ (i, l) for i, l in enumerate(self.langs) ])) # Train setup self.do_train = strings.TRAIN in data_model_wrapper.data_models.keys() if self.do_train: self.output_dir = os.path.join(output_dir, strings.TRAIN_OUTPUT_FOLDER_NAME) self.dim = data_model_wrapper.dim # Word pairs self.train_data_model = data_model_wrapper.data_models[ strings.TRAIN] # Valid setup self.do_valid = validation_model is not None if self.do_valid: # Validation model self.validation_model = validation_model self.validation_model.set_datamodel( data_model_wrapper.data_models[strings.VALID]) else: self.logger.info( 'Validation will be skipped !!! - no validation process is required' ) self.plot_model = plot_model self.cont_model = cont_model
def __init__(self, name, test_manager, tests=[]): Loggable.__init__(self) self.name = name self.test_manager = test_manager self._tests = {} for test in tests: self._tests[test.classname] = test
def __init__(self): Loggable.__init__(self) self.undo_stacks = [] self.redo_stacks = [] self.stacks = [] self.running = False self._checkpoint = self._takeSnapshot()
def __init__(self, xml_path): Loggable.__init__(self) self._xml_path = xml_path self.media_xml = ET.parse(xml_path).getroot() # Sanity checks self.media_xml.attrib["duration"] self.media_xml.attrib["seekable"]
def __init__(self): Gtk.Button.__init__(self) Loggable.__init__(self) self.image = Gtk.Image() self.add(self.image) self.playing = False self.setPlay() self.connect('clicked', self._clickedCb)
def __new__(cls, *args, **kwargs): if not cls._instance: cls._instance = super(ScenarioManager, cls).__new__( cls, *args, **kwargs) cls._instance.config = None cls._instance.discovered = False Loggable.__init__(cls._instance) return cls._instance
def __init__(self): Loggable.__init__(self) self.options = None self.testers = [] self.tests = [] self.reporter = None self._list_testers() self.wanted_tests_patterns = []
def __init__(self, options): Loggable.__init__(self) self.options = options self._start_time = 0 self.stats = {'timeout': 0, 'failures': 0, 'passed': 0, 'skipped': 0 } self.results = []
def __init__(self): Loggable.__init__(self) self.tests = set([]) self.unwanted_tests = set([]) self.options = None self.args = None self.reporter = None self.wanted_tests_patterns = [] self.blacklisted_tests_patterns = []
def __init__(self, timeout=80): """ @param timeout (optional): the amount of miliseconds for a seek attempt """ Signallable.__init__(self) Loggable.__init__(self) self.timeout = timeout self.pending_seek_id = None self.position = None self.format = None self._time = None
def __init__(self, options): Loggable.__init__(self) self._current_test = None self.out = None self.options = options self.stats = {'timeout': 0, 'failures': 0, 'passed': 0, 'skipped': 0 } self.results = []
def __init__(self, pipeline, video_overlay): Loggable.__init__(self) Signallable.__init__(self) self._pipeline = pipeline self._bus = self._pipeline.get_bus() self._bus.add_signal_watch() self._bus.connect("message", self._busMessageCb) self._listening = False # for the position handler self._listeningInterval = 300 # default 300ms self._listeningSigId = 0 self._duration = Gst.CLOCK_TIME_NONE self.video_overlay = video_overlay
def __init__(self, settings=None): Gtk.DrawingArea.__init__(self) Loggable.__init__(self) self.seeker = Seeker() self.settings = settings self.box = None self.stored = False self.area = None self.zoom = 1.0 self.sink = None self.pixbuf = None self.pipeline = None self.transformation_properties = None
def __init__(self, data_wrapper_config, embedding_config, language_config): Loggable.__init__(self) self.data_models = dict() embedding_model_wrapper = EmbeddingModelWrapper( language_config=language_config, embedding_config=embedding_config) for (key, data_model_config) in data_wrapper_config.data_configs.items(): self.logger.info('Creating data model for {} ...'.format( key.upper())) self.data_models[key] = DataModel( language_config=language_config, data_model_config=data_model_config, embedding_model_wrapper=embedding_model_wrapper) self.dim = embedding_model_wrapper.get_dim()
def __init__(self, language_config, data_model_config, embedding_model_wrapper): Loggable.__init__(self) # Configs self.language_config = language_config self.data_model_config = data_model_config if self.data_model_config.emb is not None: own_embedding_model_wrapper = EmbeddingModelWrapper( language_config=language_config, embedding_config=self.data_model_config.embedding_config) self.embeddings = own_embedding_model_wrapper.embeddings else: self.embeddings = embedding_model_wrapper.embeddings # { (l1, l2) : [(w1, w2)] } self.word_pairs_dict = self._get_word_pairs_dict(self.embeddings)
def __init__(self, settings=None): gtk.DrawingArea.__init__(self) Loggable.__init__(self) self.seeker = Seeker() self.settings = settings self.box = None self.stored = False self.area = None self.zoom = 1.0 self.sink = None self.pixbuf = None self.pipeline = None self.transformation_properties = None for state in range(gtk.STATE_INSENSITIVE + 1): self.modify_bg(state, self.style.black)
def __init__(self, pipeline): Loggable.__init__(self) Signallable.__init__(self) self._pipeline = pipeline self._bus = self._pipeline.get_bus() self._bus.add_signal_watch() self._bus.connect("message", self._busMessageCb) # Initially, we set a synchronous bus message handler so that the xid # is known right away and we can set the viewer synchronously, avoiding # the creation of an external window. # Afterwards, the xid-message is handled async (to avoid deadlocks). self._bus.set_sync_handler(self._busSyncMessageHandler) self._has_sync_bus_handler = True self._listening = False # for the position handler self._listeningInterval = 300 # default 300ms self._listeningSigId = 0 self._duration = gst.CLOCK_TIME_NONE
def __init__(self, model_config, language_config, output_dir, type): Loggable.__init__(self) self.model_config = model_config self.langs = language_config.langs # Counters self.sim_lang_wise = dict() self.sim_cumm = [] self.precs_lang_wise = dict() # Output folder folder_name = '' if type == strings.VALID: folder_name = strings.VALID_OUTPUT_FOLDER_NAME elif type == strings.TEST: folder_name = strings.TEST_OUTPUT_FOLDER_NAME self.output_dir = os.path.join(output_dir, folder_name) os.makedirs(self.output_dir)
def __init__(self, **unused_kw): Loggable.__init__(self) self.videowidth = 720 self.videoheight = 576 self.render_scale = 100 self.videorate = gst.Fraction(25, 1) self.videopar = gst.Fraction(16, 15) self.audiochannels = 2 self.audiorate = 44100 self.audiodepth = 16 self.vencoder = None self.aencoder = None self.muxer = "oggmux" # A (muxer -> containersettings) map. self._containersettings_cache = {} # A (vencoder -> vcodecsettings) map. self._vcodecsettings_cache = {} # A (aencoder -> acodecsettings) map. self._acodecsettings_cache = {}
def __init__(self, application_name, classname, options, reporter, duration=0, timeout=DEFAULT_TIMEOUT, hard_timeout=None): """ @timeout: The timeout during which the value return by get_current_value keeps being exactly equal @hard_timeout: Max time the test can take in absolute """ Loggable.__init__(self) self.timeout = timeout self.hard_timeout = hard_timeout self.classname = classname self.options = options self.application = application_name self.command = "" self.reporter = reporter self.process = None self.duration = duration self.clean()
def __init__(self, classname, options, reporter, combination, uri, media_descriptor, timeout=DEFAULT_TIMEOUT, scenario=None): Loggable.__init__(self) file_dur = long(media_descriptor.get_duration()) / GST_SECOND try: timeout = G_V_PROTOCOL_TIMEOUTS[media_descriptor.get_protocol()] except KeyError: pass super(GstValidateTranscodingTest, self).__init__( GST_VALIDATE_TRANSCODING_COMMAND, classname, options, reporter, duration=file_dur, timeout=timeout, scenario=scenario) self.media_descriptor = media_descriptor self.uri = uri self.combination = combination self.dest_file = ""
def __init__(self, elementfactory, properties={}): Loggable.__init__(self) self.debug("factory:%s, properties:%s", elementfactory, properties) self.builder = gtk.Builder() self.builder.add_from_file(os.path.join(get_ui_dir(), "elementsettingsdialog.ui")) self.builder.connect_signals(self) self.ok_btn = self.builder.get_object("okbutton1") self.window = self.builder.get_object("dialog1") self.elementsettings = GstElementSettingsWidget() self.builder.get_object("viewport1").add(self.elementsettings) self.factory = elementfactory self.element = self.factory.create("elementsettings") if not self.element: self.warning("Couldn't create element from factory %s", self.factory) self.properties = properties self._fillWindow() # Try to avoid scrolling, whenever possible. screen_height = self.window.get_screen().get_height() contents_height = self.elementsettings.size_request()[1] maximum_contents_height = max(500, 0.7 * screen_height) if contents_height < maximum_contents_height: # The height of the content is small enough, disable the scrollbars. default_height = -1 scrolledwindow = self.builder.get_object("scrolledwindow1") scrolledwindow.set_policy(gtk.POLICY_NEVER, gtk.POLICY_NEVER) scrolledwindow.set_shadow_type(gtk.SHADOW_NONE) else: # If we need to scroll, set a reasonable height for the window. default_height = 600 self.window.set_default_size(300, default_height) self.window.show()
def __init__(self, app, layer, layer_type): Gtk.VBox.__init__(self, spacing=0) Loggable.__init__(self) self._app = app self.layer = layer self._selected = False context = self.get_style_context() # get the default color for the current theme self.UNSELECTED_COLOR = context.get_background_color(Gtk.StateFlags.NORMAL) # use base instead of bg colors so that we get the lighter color # that is used for list items in TreeView. self.SELECTED_COLOR = context.get_background_color(Gtk.StateFlags.SELECTED) table = Gtk.Table(rows=2, columns=2) table.set_border_width(2) table.set_row_spacings(3) table.set_col_spacings(3) self.eventbox = Gtk.EventBox() self.eventbox.add(table) self.eventbox.connect("button_press_event", self._buttonPressCb) self.pack_start(self.eventbox, True, True, 0) self.sep = SpacedSeparator() self.pack_start(self.sep, True, True, 0) icon_mapping = {GES.TrackType.AUDIO: "audio-x-generic", GES.TrackType.VIDEO: "video-x-generic"} # Folding button # TODO use images fold_button = TwoStateButton("▼", "▶") fold_button.set_relief(Gtk.ReliefStyle.NONE) fold_button.set_focus_on_click(False) fold_button.connect("changed-state", self._foldingChangedCb) table.attach(fold_button, 0, 1, 0, 1) # Name entry self.name_entry = Gtk.Entry() self.name_entry.set_tooltip_text(_("Set a personalized name for this layer")) self.name_entry.set_property("primary-icon-name", icon_mapping[layer_type]) self.name_entry.connect("focus-in-event", self._focusChangeCb, False) self.name_entry.connect("focus-out-event", self._focusChangeCb, True) self.name_entry.connect("button_press_event", self._buttonPressCb) # self.name_entry.drag_dest_unset() self.name_entry.set_sensitive(False) # 'Solo' toggle button self.solo_button = Gtk.ToggleButton() self.solo_button.set_tooltip_markup(_("<b>Solo mode</b>\n" "Other non-soloed layers will be disabled as long as " "this is enabled.")) solo_image = Gtk.Image() solo_image.set_from_icon_name("avatar-default-symbolic", Gtk.IconSize.MENU) self.solo_button.add(solo_image) self.solo_button.connect("toggled", self._soloToggledCb) self.solo_button.set_relief(Gtk.ReliefStyle.NONE) self.solo_button.set_sensitive(False) # CheckButton visible_option = Gtk.CheckButton() visible_option.connect("toggled", self._visibilityChangedCb) visible_option.set_active(True) visible_option.set_sensitive(False) visible_option.set_tooltip_markup(_("<b>Enable or disable this layer</b>\n" "Disabled layers will not play nor render.")) # Upper bar upper = Gtk.HBox() upper.pack_start(self.name_entry, True, True, 0) upper.pack_start(self.solo_button, False, False, 0) upper.pack_start(visible_option, False, False, 0) # Lower bar self.lower_hbox = Gtk.HBox() self.lower_hbox.set_sensitive(False) table.attach(upper, 1, 2, 0, 1) table.attach(self.lower_hbox, 1, 2, 1, 2) self.show_all() # Popup Menu self.popup = Gtk.Menu() layer_delete = Gtk.ImageMenuItem(_("_Delete layer")) layer_delete.connect("activate", self._deleteLayerCb) layer_delete.set_image(Gtk.Image.new_from_icon_name("edit-delete", Gtk.IconSize.MENU)) self.layer_up = Gtk.ImageMenuItem(_("Move layer up")) self.layer_up.connect("activate", self._moveLayerCb, -1) self.layer_up.set_image(Gtk.Image.new_from_icon_name("go-up", Gtk.IconSize.MENU)) self.layer_down = Gtk.ImageMenuItem(_("Move layer down")) self.layer_down.connect("activate", self._moveLayerCb, 1) self.layer_down.set_image(Gtk.Image.new_from_icon_name("go-down", Gtk.IconSize.MENU)) self.layer_first = Gtk.ImageMenuItem(_("Move layer to top")) self.layer_first.connect("activate", self._moveLayerCb, -2) self.layer_first.set_image(Gtk.Image.new_from_icon_name("go-top", Gtk.IconSize.MENU)) self.layer_last = Gtk.ImageMenuItem(_("Move layer to bottom")) self.layer_last.connect("activate", self._moveLayerCb, 2) self.layer_last.set_image(Gtk.Image.new_from_icon_name("go-bottom", Gtk.IconSize.MENU)) self.popup.append(self.layer_first) self.popup.append(self.layer_up) self.popup.append(self.layer_down) self.popup.append(self.layer_last) self.popup.append(Gtk.SeparatorMenuItem()) self.popup.append(layer_delete) for menu_item in self.popup: menu_item.set_use_underline(True) self.popup.show_all()
def __init__(self): Loggable.__init__(self)
def __init__(self): TestsManager.__init__(self) Loggable.__init__(self) self._uris = [] self._run_defaults = True
def __init__(self, instance): gtk.VBox.__init__(self) Loggable.__init__(self) self.log("Init PreviewWidget") self.connect('destroy', self._destroy_cb) self.settings = instance.settings self.preview_cache = {} self.preview_cache_errors = {} self.discoverer = gst.pbutils.Discoverer(gst.SECOND) #playbin for play pics self._unsurePlaybin() bus = self.player.get_bus() bus.add_signal_watch() bus.connect('message', self._bus_message_cb) bus.enable_sync_message_emission() bus.connect('sync-message::element', self._sync_message_cb) bus.connect('message::tag', self._tag_found_cb) self.__videosink = self.player.get_property("video-sink") self.__fakesink = gst.element_factory_make("fakesink", "fakesink") #some global variables for preview handling self.is_playing = False self.time_format = gst.Format(gst.FORMAT_TIME) self.original_dims = (PREVIEW_WIDTH, PREVIEW_HEIGHT) self.countinuous_seek = False self.current_selected_uri = "" self.current_preview_type = "" self.description = "" self.tags = {} # Play button self.bbox = gtk.HBox() self.play_button = gtk.ToolButton(gtk.STOCK_MEDIA_PLAY) self.play_button.connect("clicked", self._on_start_stop_clicked_cb) self.bbox.pack_start(self.play_button, expand=False) #Scale for position handling self.pos_adj = gtk.Adjustment() self.seeker = gtk.HScale(self.pos_adj) self.seeker.set_update_policy(gtk.UPDATE_DISCONTINUOUS) self.seeker.connect('button-press-event', self._on_seeker_press_cb) self.seeker.connect('button-release-event', self._on_seeker_press_cb) self.seeker.connect('motion-notify-event', self._on_motion_notify_cb) self.seeker.set_draw_value(False) self.seeker.show() self.bbox.pack_start(self.seeker) self.pack_start(self.bbox, expand=False, fill=False) self.preview_video = ViewerWidget() self.preview_image = gtk.Image() #Metadata self.l_tags = gtk.Label() #Error handling self.l_error = gtk.Label(_("KSE can not preview this file.")) self.b_details = gtk.Button(_("More info")) self.b_zoom_in = gtk.ToolButton(gtk.STOCK_ZOOM_IN) self.b_zoom_in.connect("clicked", self._on_zoom_clicked_cb, 1) self.b_zoom_out = gtk.ToolButton(gtk.STOCK_ZOOM_OUT) self.b_zoom_out.connect("clicked", self._on_zoom_clicked_cb, -1)
def __init__(self, instance): gtk.VBox.__init__(self) Loggable.__init__(self) self.log("Init PreviewWidget") self.connect('destroy', self._destroy_cb) self.settings = instance.settings self.preview_cache = {} self.preview_cache_errors = {} self.discoverer = gst.pbutils.Discoverer(gst.SECOND) #playbin for play pics self._unsurePlaybin() bus = self.player.get_bus() bus.add_signal_watch() bus.connect('message', self._bus_message_cb) bus.enable_sync_message_emission() bus.connect('sync-message::element', self._sync_message_cb) bus.connect('message::tag', self._tag_found_cb) self.__videosink = self.player.get_property("video-sink") self.__fakesink = gst.element_factory_make("fakesink", "fakesink") #some global variables for preview handling self.is_playing = False self.time_format = gst.Format(gst.FORMAT_TIME) self.original_dims = (PREVIEW_WIDTH, PREVIEW_HEIGHT) self.countinuous_seek = False self.current_selected_uri = "" self.current_preview_type = "" self.description = "" self.tags = {} # Gui elements: # Drawing area for video output self.preview_video = ViewerWidget() self.preview_video.modify_bg(gtk.STATE_NORMAL, self.preview_video.style.black) self.pack_start(self.preview_video, expand=False) # An image for images and audio self.preview_image = gtk.Image() self.preview_image.set_size_request(self.settings.FCpreviewWidth, self.settings.FCpreviewHeight) self.preview_image.show() self.pack_start(self.preview_image, expand=False) # Play button self.bbox = gtk.HBox() self.play_button = gtk.ToolButton(gtk.STOCK_MEDIA_PLAY) self.play_button.connect("clicked", self._on_start_stop_clicked_cb) self.bbox.pack_start(self.play_button, expand=False) #Scale for position handling self.pos_adj = gtk.Adjustment() self.seeker = gtk.HScale(self.pos_adj) self.seeker.set_update_policy(gtk.UPDATE_DISCONTINUOUS) self.seeker.connect('button-press-event', self._on_seeker_press_cb) self.seeker.connect('button-release-event', self._on_seeker_press_cb) self.seeker.connect('motion-notify-event', self._on_motion_notify_cb) self.seeker.set_draw_value(False) self.seeker.show() self.bbox.pack_start(self.seeker) # Zoom buttons self.b_zoom_in = gtk.ToolButton(gtk.STOCK_ZOOM_IN) self.b_zoom_in.connect("clicked", self._on_zoom_clicked_cb, 1) self.b_zoom_out = gtk.ToolButton(gtk.STOCK_ZOOM_OUT) self.b_zoom_out.connect("clicked", self._on_zoom_clicked_cb, -1) self.bbox.pack_start(self.b_zoom_in, expand=False) self.bbox.pack_start(self.b_zoom_out, expand=False) self.bbox.show_all() self.pack_start(self.bbox, expand=False, fill=False) # Label for metadata tags self.l_tags = gtk.Label() self.l_tags.set_justify(gtk.JUSTIFY_LEFT) self.l_tags.set_ellipsize(pango.ELLIPSIZE_END) self.l_tags.show() self.pack_start(self.l_tags, expand=False, fill=False) # Error handling vbox = gtk.VBox() vbox.set_spacing(SPACING) self.l_error = gtk.Label(_("PiTiVi can not preview this file.")) self.b_details = gtk.Button(_("More info")) self.b_details.connect('clicked', self._on_b_details_clicked_cb) vbox.pack_start(self.l_error) vbox.pack_start(self.b_details, expand=False, fill=False) vbox.show() self.pack_start(vbox, expand=False, fill=False)
def __init__(self, language_config, embedding_config): Loggable.__init__(self) self.language_config = language_config self.embedding_config = embedding_config self._get_sil2fb_map() self._read_embeddings()
def __init__(self): Loggable.__init__(self) self.syn0 = None self.index2word = None
def __init__(self): Loggable.__init__(self)
def __init__(self, input_dir): Loggable.__init__(self) self.input_dir = input_dir
def __init__(self, cfg): Loggable.__init__(self) self.config = cfg