Esempio n. 1
0
    def __init__(self):
        ManagerUI.__init__(self, 3)

        self.menu = Gtk.Menu()
        self.fill_menu()
        builder = Gtk.Builder()
        builder.add_from_file(get_ui_path('listing.glade'))
        release = builder.get_object("release_label")
        release.set_label(get_footer())

        self.gui = builder

        self.box = builder.get_object("listingbox")
        self.vista = builder.get_object("vista")
        self.scroll = builder.get_object("scrolledw")
        self.vista.get_selection().set_mode(Gtk.SelectionMode.SINGLE) # could SELECTION_MULTIPLE

        old_style = context.get_conf().get_color_style()
        self.color = context.get_conf().get_palette(old_style)

        builder.connect_signals(self)
        self.dispatcher.connect_ui("action-mm-refresh-row", self.refresh_row_from_mp)
        self.dispatcher.connect_ui("operation-started", self.refresh_operation)
        self.dispatcher.connect_ui("operation-stopped", self.refresh_operation)
        self.dispatcher.connect_ui("view-changed", self.event_change_mode)

        self.populate_treeview(list(self.repository.list().values()))
        self.box.pack_start(self.strip,False,False,0)
        self.box.reorder_child(self.strip,0)
        self.box.show()
        self.pack_start(self.box,True,True,0)
Esempio n. 2
0
 def test_context(self):
     self.assertNotEqual(type(context.get_conf()), galicaster.core.conf)
     self.assertEqual(type(context.get_conf()), galicaster.core.conf.Conf)
     self.assertEqual(type(context.get_dispatcher()),
                      galicaster.core.dispatcher.Dispatcher)
     self.assertEqual(type(context.get_repository()),
                      galicaster.mediapackage.repository.Repository)
Esempio n. 3
0
    def __init__(self):
        ManagerUI.__init__(self, 3)

	builder = gtk.Builder()
	builder.add_from_file(get_ui_path('listing.glade'))
	self.gui = builder

	self.box = builder.get_object("listingbox")
	self.vista = builder.get_object("vista")		
	self.scroll = builder.get_object("scrolledw")
	self.vista.get_selection().set_mode(gtk.SELECTION_SINGLE) # could SELECTION_MULTIPLE

	old_style = context.get_conf().get_color_style()
	self.color = context.get_conf().get_palette(old_style)
	
	builder.connect_signals(self)
	self.dispatcher.connect("refresh-row", self.refresh_row_from_mp)
	self.dispatcher.connect("start-operation", self.refresh_operation)
	self.dispatcher.connect("stop-operation", self.refresh_operation)
	self.dispatcher.connect("galicaster-status", self.event_change_mode)
		
	self.populate_treeview(self.repository.list().values())
	self.box.pack_start(self.strip,False,False,0)
	self.box.reorder_child(self.strip,0)
	self.box.show()
	self.pack_start(self.box,True,True,0)
    def __init__(self):
        ManagerUI.__init__(self, 3)

        self.menu = Gtk.Menu()
        self.fill_menu()
        builder = Gtk.Builder()
        builder.add_from_file(get_ui_path('listing.glade'))
        release = builder.get_object("release_label")
        release.set_label(get_footer())

        self.gui = builder

        self.box = builder.get_object("listingbox")
        self.vista = builder.get_object("vista")
        self.scroll = builder.get_object("scrolledw")
        self.vista.get_selection().set_mode(Gtk.SelectionMode.SINGLE) # could SELECTION_MULTIPLE

        old_style = context.get_conf().get_color_style()
        self.color = context.get_conf().get_palette(old_style)

        builder.connect_signals(self)
        self.dispatcher.connect_ui("action-mm-refresh-row", self.refresh_row_from_mp)
        self.dispatcher.connect_ui("operation-started", self.refresh_operation)
        self.dispatcher.connect_ui("operation-stopped", self.refresh_operation)
        self.dispatcher.connect_ui("view-changed", self.event_change_mode)

        self.populate_treeview(self.repository.list().values())
        self.box.pack_start(self.strip,False,False,0)
        self.box.reorder_child(self.strip,0)
        self.box.show()
        self.pack_start(self.box,True,True,0)
Esempio n. 5
0
    def __init__(self):
        ManagerUI.__init__(self, 3)

        builder = gtk.Builder()
        builder.add_from_file(get_ui_path('listing.glade'))
        self.gui = builder

        self.box = builder.get_object("listingbox")
        self.vista = builder.get_object("vista")
        self.scroll = builder.get_object("scrolledw")
        self.vista.get_selection().set_mode(
            gtk.SELECTION_SINGLE)  # could SELECTION_MULTIPLE

        old_style = context.get_conf().get_color_style()
        self.color = context.get_conf().get_palette(old_style)

        builder.connect_signals(self)
        self.dispatcher.connect("refresh-row", self.refresh_row_from_mp)
        self.dispatcher.connect("start-operation", self.refresh_operation)
        self.dispatcher.connect("stop-operation", self.refresh_operation)
        self.dispatcher.connect("galicaster-status", self.event_change_mode)

        self.populate_treeview(self.repository.list().values())
        self.box.pack_start(self.strip, False, False, 0)
        self.box.reorder_child(self.strip, 0)
        self.box.show()
        self.pack_start(self.box, True, True, 0)
Esempio n. 6
0
    def change_selected_profile(self, button):
        model, iterator = self.view.get_selection().get_selected()
        if type(iterator) is Gtk.TreeIter:
            profile = model.get_value(iterator, 0)
            context.get_conf().change_current_profile(profile.name)

        context.get_dispatcher().emit("action-reload-profile")
        self.close()
    def change_selected_profile(self, button):
        model,iterator=self.view.get_selection().get_selected()
        if type(iterator) is Gtk.TreeIter:
            profile=model.get_value(iterator,0)
            context.get_conf().change_current_profile(profile.name)

        context.get_dispatcher().emit("action-reload-profile")
        self.close()
Esempio n. 8
0
 def close(self):
     """Handles UI closure, destroying tabs and updating changes"""
     if self.profile:
         self.profile.destroy()
     if self.track:
         self.track.destroy()
     context.get_conf().update()
     context.get_dispatcher().emit("reload-profile")
     self.destroy()          
Esempio n. 9
0
    def change_selected_profile(self, button):

        model,iterator=self.view.get_selection().get_selected()
        if type(iterator) is gtk.TreeIter:
            profile=model.get_value(iterator,0)
            
            context.get_conf().change_current_profile(profile.name)
        #self.refresh()
        self.close()
Esempio n. 10
0
 def close(self):
     """Handles UI closure, destroying tabs and updating changes"""
     if self.profile:
         self.profile.destroy()
     if self.track:
         self.track.destroy()
     context.get_conf().update()
     context.get_dispatcher().emit("reload-profile")
     self.destroy()          
Esempio n. 11
0
    def change_selected_profile(self, button):

        model,iterator=self.view.get_selection().get_selected()
        if type(iterator) is gtk.TreeIter:
            profile=model.get_value(iterator,0)
            
            context.get_conf().change_current_profile(profile.name)
        #self.refresh()
        self.close()
Esempio n. 12
0
def state():
    response.content_type = 'application/json'
    #TODO: Complete!
    return json.dumps({"is-recording" : context.get_recorder().is_recording(),
                       "hostname" : context.get_conf().get_hostname(),
                       "net" : context.get_ocservice().net if context.get_ocservice() else None,
                       "recorder-status" : str(context.get_recorder().status),
                       "current-profile" : context.get_conf().get_current_profile().name,
                       "current-mediapackage" : context.get_recorder().current_mediapackage.getIdentifier() if context.get_recorder().current_mediapackage else None
})
Esempio n. 13
0
 def operation_readable(self, column, cell, model, iterator, operation):
     """Sets text equivalent for numeric operation status of mediapackages."""
     mp = self.repository.get((model[iterator])[0])
     status = mp.getOpStatus(operation)
     out = mediapackage.op_status[status]
     cell.set_property('text', out)
     old_style = context.get_conf().get_color_style()
     if old_style:
         color = model[iterator][8]
     else:
         palette = context.get_conf().get_palette()
         color = palette[status]
     cell.set_property('background', color)
Esempio n. 14
0
 def save_profile(self, origin):
     """Saves to memory the modification of a profile"""
     old_key=self.profile.name
     self.profile.name = self.profile_name.get_text()        
         
     if not context.get_conf().get_profiles().has_key(self.profile.name):
         CONF= context.get_conf()
         CONF.add_profile(self.profile,old_key)
         if self.profile == CONF.get_current_profile():
             CONF.force_set_current_profile(self.profile.name)
         
     self.close()   
     return self.profile
Esempio n. 15
0
 def operation_readable(self,column,cell,model,iterator,operation):
     """Sets text equivalent for numeric operation status of mediapackages."""	
     mp=self.repository.get((model[iterator])[0])
     status=mp.getOpStatus(operation)
     out = mediapackage.op_status[status]
     cell.set_property('text', out)
     old_style = context.get_conf().get_color_style()
     if old_style:
         color = model[iterator][8]
     else:
         palette = context.get_conf().get_palette()
         color = palette[status]
     cell.set_property('background', color)
Esempio n. 16
0
 def save_profile(self, origin):
     """Saves to memory the modification of a profile"""
     old_key=self.profile.name
     self.profile.name = self.profile_name.get_text()        
         
     if not context.get_conf().get_profiles().has_key(self.profile.name):
         CONF= context.get_conf()
         CONF.add_profile(self.profile,old_key)
         if self.profile == CONF.get_current_profile():
             CONF.force_set_current_profile(self.profile.name)
         
     self.close()   
     return self.profile
Esempio n. 17
0
    def duplicate_profile(self, origin):
        model, iterator = self.view.get_selection().get_selected()
        if type(iterator) is not gtk.TreeIter:
            return

        profile = model.get_value(iterator, 0)

        new_profile = conf.Profile(profile.name + " copy",
                                   context.get_conf().get_free_profile())

        for track in profile.tracks:
            new_profile.add_track(track)
        context.get_conf().add_profile(new_profile)
        self.refresh()
Esempio n. 18
0
    def delete_profile(self, origin):
        model,iterator = self.view.get_selection().get_selected()
        if type(iterator) is not gtk.TreeIter:
            return

        profile = model.get_value(iterator,0)
        if profile.name == "Default":
            return

        if profile == context.get_conf().get_current_profile():
            context.get_conf().set_default_profile_as_current()            
            
        profile.to_delete = True
        model.remove(iterator)
        self.refresh()
Esempio n. 19
0
    def delete_profile(self, origin):
        model,iterator = self.view.get_selection().get_selected()
        if type(iterator) is not gtk.TreeIter:
            return

        profile = model.get_value(iterator,0)
        if profile.name == "Default":
            return

        if profile == context.get_conf().get_current_profile():
            context.get_conf().set_default_profile_as_current()            
            
        profile.to_delete = True
        model.remove(iterator)
        self.refresh()
def init():
    global conf, logger, recorder, dispatcher
    dispatcher = context.get_dispatcher()
    logger = context.get_logger()
    conf = context.get_conf()
    recorder = context.get_recorder()
    dispatcher.connect('init', manage_button)
Esempio n. 21
0
    def __init__(self):  
        gtk.Box.__init__(self)
        dbuilder= gtk.Builder()
        dbuilder.add_from_file(get_ui_path('distrib.glade'))
        self.builder = dbuilder
        dbox = dbuilder.get_object("distbox")
        release = dbuilder.get_object("release_label")
        release.set_label("Galicaster "+__version__)

        recorder = dbuilder.get_object("button1")        
        manager = dbuilder.get_object("button2")
        quit_button =  dbuilder.get_object("button3")
        shutdown_button =  dbuilder.get_object("button4")

        profile_button = dbuilder.get_object("profile_button")
        self.selected = dbuilder.get_object("selected_profile")
        self.update_selected_profile()
        
        #Connect signals
        dispatcher = context.get_dispatcher()
        dispatcher.connect("reload-profile", self.update_selected_profile)
        recorder.connect("clicked", self.emit_signal, "change_mode", 0)
        manager.connect("clicked", self.emit_signal, "change_mode", 1)
        quit_button.connect("clicked", self.emit_signal, "galicaster-quit")
        shutdown_button.connect("clicked", self.emit_signal, "galicaster-shutdown")
        profile_button.connect("clicked", self.on_profile_button)
        
        about = dbuilder.get_object("aboutevent")
        about.connect("button-press-event", self.show_about_dialog)

        conf = context.get_conf()
        quit_button.set_visible(conf.get_boolean("basic", "quit"))
        shutdown_button.set_visible(conf.get_boolean("basic", "shutdown"))
        self.pack_start(dbox, True, True, 0)
    def test_cleanstale_plugin(self):
        dispatcher = context.get_dispatcher()
        repo = context.get_repository()
        conf = context.get_conf()
        now = datetime.datetime.utcnow()

        mp = mediapackage.Mediapackage(identifier="1", title='MP#1', date=(now - datetime.timedelta(days=1)))
        repo.add(mp)
        mp = mediapackage.Mediapackage(identifier="2", title='MP#2', date=(now - datetime.timedelta(days=30)))
        repo.add(mp)
        mp = mediapackage.Mediapackage(identifier="3", title='MP#3', date=(now - datetime.timedelta(days=60)))
        repo.add(mp)
        mp = mediapackage.Mediapackage(identifier="4", title='MP#4', date=(now + datetime.timedelta(days=1)))
        repo.add(mp)
        mp = mediapackage.Mediapackage(identifier="5", title='MP#5', date=(now + datetime.timedelta(days=30)))
        repo.add(mp)


        conf.set('cleanstale','maxarchivaldays', '70')
        cleanstale.init()
        self.assertEqual(len(repo), 5)

        conf.set('cleanstale','maxarchivaldays', '50')
        cleanstale.init()
        dispatcher.emit('timer-nightly')
        self.assertEqual(len(repo), 4)
        conf.set('cleanstale','maxarchivaldays', '20')
        cleanstale.init()
        dispatcher.emit('timer-nightly')
        self.assertEqual(len(repo), 3)
Esempio n. 23
0
def init():
    conf = context.get_conf()
    host = conf.get('rest', 'host')
    port = conf.get_int('rest', 'port')
    restp = threading.Thread(target=run,kwargs={'host': host, 'port': port, 'quiet': True})
    restp.setDaemon(True)
    restp.start()
Esempio n. 24
0
def init():
    global conf, logger
    dispatcher = context.get_dispatcher()
    logger = context.get_logger()
    conf = context.get_conf()
    dispatcher.connect('init', show_msg)
    dispatcher.connect('record-finished', show_msg)
Esempio n. 25
0
    def __init__(self,package = None, parent = None):
        self.gui = gtk.Builder()
        self.gui.add_from_file(get_ui_path('conf.glade'))

        self.conf=context.get_conf()
        
        dialog = self.gui.get_object("confdialog")
        if parent != None:
            dialog.set_transient_for(parent.get_toplevel())
        self.shifter1 = self.gui.get_object('playershift') 
        self.shifter2 = self.gui.get_object('recordshift') 
        self.shifter1.add_events(gtk.gdk.BUTTON_PRESS_MASK)
        self.shifter1.connect("button-press-event",self.on_toggle) # CHANGE method name
        self.shifter2.add_events(gtk.gdk.BUTTON_PRESS_MASK)
        self.shifter2.connect("button-press-event",self.on_toggle) # CHANGE method name
        if self.conf.get("screen","player") == "presentation":
            self.on_toggle(self.shifter1, None)
        if self.conf.get("screen","recorder") == "presentation":
            self.on_toggle(self.shifter2, None)
 
        self.populate_conf()
        response = dialog.run()        
        if response > 1: # FIXME, need a main
            print "Galicaster Configuration Update"
            self.update_conf()
        elif response == 1:
            print "Galicaster Configuration Update"# FIXME just apply changes dont close
            self.update_conf()
        else:       
            print "Cancel Configuration"
        dialog.destroy()
Esempio n. 26
0
    def __init__(self, options):
        self.logger = logger
        # Init gc_parameters add Base and Object class
        self.gc_parameters = self.get_gc_parameters()

        current_profile_path = context.get_conf().get_current_profile().path
        # Check the profile parameters (*.ini)
        # for k in options:
        #     if k not in self.gc_parameters and k not in ['device', 'active', 'path']:
        #         logger.warning('Does not exit the parameter "{0}". Please check the file {1}'.format(
        #                 k, current_profile_path))



        # Init options with default gc_parameters values and options
        self.options = dict([(k,v['default']) for k,v in self.gc_parameters.iteritems()])
        # TODO parsear
        self.options.update(options)

        # Validate option values
        try:
            validator.validate_track(self.options)
        except Exception as exc:
            error_msg = 'Profile error in {0}, track {1}. {2}'.format(
                current_profile_path, self.options['name'], exc)

            logger.error(error_msg)
            raise SystemError(error_msg)        

        # Sanitaze values
        self.options["name"] = re.sub(r'\W+', '', self.options["name"])
Esempio n. 27
0
def post_init(source=None):
    conf = context.get_conf()
    recorder_ui = context.get_mainwindow().nbox.get_nth_page(0).gui
    data_panel = recorder_ui.get_object('data_panel')

    # Customize tabs in the recorder UI
    try: 
        tabs_to_hide = set( x for x in set(conf.get('hidetabs', 'hide').split()) if x in ALL_TABS )
        if tabs_to_hide:
            for tab, obj_name in ALL_TABS.iteritems():
                page = recorder_ui.get_object(obj_name)
                if tab in tabs_to_hide:
                    page.hide()

    except AttributeError:
        # The conf parameter isn't defined. Ignore
        print "Attribute error"

    default_tab = conf.get('hidetabs', 'default') or None
    try:
        page = recorder_ui.get_object(ALL_TABS[default_tab])
        data_panel.set_current_page(data_panel.page_num(page))
    except KeyError:
        # The conf parameter isn't defined. Ignore
        pass
Esempio n. 28
0
    def test_validate_flavor(self):
        track = {'device': 'videotest'}
        error, valid_track = validator.validate_track(track)
        self.assertEqual(error, None)

        # Valid
        track['flavor'] = 'presentation'
        error, valid_track = validator.validate_track(track)
        self.assertEqual(error, None)
        self.assertEqual(valid_track['flavor'], 'presentation')

        # Invalid
        track['flavor'] = 'noflavor'
        error, valid_track = validator.validate_track(track)
        self.assertNotEqual(error, None)
        self.assertEqual(valid_track['flavor'], 'presenter')

        # Valid (Test custom flavors)
        from galicaster.core import context as gc_context
        gc_conf = gc_context.get_conf()
        gc_conf.set('basic', 'custom_flavors',
                    'myflavor')  # Add myflavor to list of valid flavors

        track['flavor'] = 'myflavor'
        error, valid_track = validator.validate_track(track)
        self.assertEqual(error, None)
        self.assertEqual(valid_track['flavor'], 'myflavor')
Esempio n. 29
0
def init():
    global minfree, logger, repo, ocservice, dispatcher

    conf = context.get_conf()
    dispatcher = context.get_dispatcher()
    repo = context.get_repository()
    logger = context.get_logger()
    ocservice = context.get_ocservice()

    minfree = None
    try:
        minfree = int(conf.get('checkspace', 'minfreespace'))
    except Exception as exc:
        raise Exception("Wrong parameter minfreespace: {}".format(exc))

    if minfree:
        logger.info("Parameter 'minfreespace' set to {} GB".format(minfree))
        dispatcher.connect('timer-nightly', check_space)
        dispatcher.connect('recorder-status', check_space_status)

        oninit = conf.get('checkspace', 'checkoninit')
        if oninit in ["True", "true"]:
            check_space(None)
    else:
        raise Exception("Parameter minfreespace not configured")
Esempio n. 30
0
 def show_current_image(self, column, cell, model, iterator, data=None):
     profile = model[iterator][0]
     if profile == context.get_conf().get_current_profile():
         cell.set_property("stock-id", gtk.STOCK_YES)
     else:
         cell.set_property("stock-id", 0)
     return None
Esempio n. 31
0
    def create_series(self, ev=None):
        conf = context.get_conf()

        self.__logger.info("Creating series")

        if self.user_button is not None:
            self.user_button.set_sensitive(False)  # disabled

        for element in self.result.get_children():
            self.result.remove(element)

        loading_box = Gtk.Box(spacing=10)
        loading_box.set_name("grd_result_loading")

        label = Gtk.Label("")
        loading_box.pack_start(label, expand=False, fill=False, padding=0)

        spinner = Gtk.Spinner()
        spinner.start()
        loading_box.pack_start(spinner, expand=False, fill=False, padding=0)

        label = Gtk.Label(" Creating user profile... ")
        loading_box.pack_start(label, expand=False, fill=False, padding=0)

        label = Gtk.Label("")
        loading_box.pack_start(label, expand=False, fill=False, padding=0)

        self.result.pack_start(loading_box,
                               expand=False,
                               fill=False,
                               padding=0)
        self.result.show_all()

        self.set_series_close_modal(self.call_create_series(self.details))
Esempio n. 32
0
    def test_cleanstale_plugin(self):
        dispatcher = context.get_dispatcher()
        repo = context.get_repository()
        conf = context.get_conf()
        now = datetime.datetime.utcnow()

        mp = mediapackage.Mediapackage(identifier="1", title='MP#1', date=(now - datetime.timedelta(days=1)))
        repo.add(mp)
        mp = mediapackage.Mediapackage(identifier="2", title='MP#2', date=(now - datetime.timedelta(days=30)))
        repo.add(mp)
        mp = mediapackage.Mediapackage(identifier="3", title='MP#3', date=(now - datetime.timedelta(days=60)))
        repo.add(mp)
        mp = mediapackage.Mediapackage(identifier="4", title='MP#4', date=(now + datetime.timedelta(days=1)))
        repo.add(mp)
        mp = mediapackage.Mediapackage(identifier="5", title='MP#5', date=(now + datetime.timedelta(days=30)))
        repo.add(mp)

        
        cleanstale.init()
        
        self.assertEqual(len(repo), 5)
        conf.set('cleanstale','maxarchivaldays', '50')
        dispatcher.emit('galicaster-notify-nightly')
        self.assertEqual(len(repo), 4)
        conf.set('cleanstale','maxarchivaldays', '20')
        dispatcher.emit('galicaster-notify-nightly')
        self.assertEqual(len(repo), 3)
Esempio n. 33
0
def post_init(source=None):

    global recorder_ui
    global rec_button
    global metadata

    metadata = {}
    
    # Get a shallow copy of the plugin configuration
    config = context.get_conf().get_section('setuprecording') or {}

    # Get the metadata to setup the mediapackage defaults
    for key, value in config.iteritems():
        final_key = EQUIV.get(key) or key
        if final_key in DCTERMS:
            try:
                metadata[final_key] = value.format(**MAPPINGS)
            except KeyError:
                metadata[final_key] = value

    # Check the special case that series is specified using 'series' rather than 'isPartOf'
    if 'series' in config:
        metadata['isPartOf'] = config['series']

    recorder_ui = context.get_mainwindow().nbox.get_nth_page(0)

    rec_button = recorder_ui.gui.get_object('recbutton')

    rec_button.connect('clicked', on_rec)
    rec_button.handler_block_by_func(recorder_ui.on_rec)
Esempio n. 34
0
 def show_current_image(self, column, cell, model, iterator, data=None):
     profile = model[iterator][0]
     if profile == context.get_conf().get_current_profile():
         cell.set_property("stock-id", gtk.STOCK_YES)
     else:
         cell.set_property("stock-id", 0)
     return None
Esempio n. 35
0
def init():
    global recorder, dispatcher, logger, config, repo

    config = context.get_conf().get_section(CONFIG_SECTION) or {}
    dispatcher = context.get_dispatcher()
    repo = context.get_repository()
    logger = context.get_logger()

    backend = config.get(BACKEND)

    if backend == "onvif":
        global cam
        import galicaster.utils.camctrl_onvif_interface as camera
        # connect to the camera
        cam = camera.AXIS_V5915()
        cam.connect(config.get(IPADDRESS), config.get(PORT, DEFAULT_PORT),
                    config.get(USERNAME), config.get(PASSWORD))
        # initiate the onvif user interface
        dispatcher.connect("init", init_onvif_ui)

    elif backend == "visca":
        global pysca
        import galicaster.utils.pysca as pysca
        # If port is not defined, a None value will make this method fail
        pysca.connect(config.get(PORT_KEY))
        # initiate the visca user interface
        dispatcher.connect("init", init_visca_ui)
    else:
        logger.warn(
            "You have to choose a backend in the config file before starting Galicaster, otherwise the cameracontrol plugin does not work."
        )
        raise RuntimeError("No backend for the cameracontrol plugin defined.")
    logger.info("Camera connected.")
    def test_validate_flavor(self):
        track = {'device': 'videotest'}
        error, valid_track = validator.validate_track(track)
        self.assertEqual(error, None)

        # Valid
        track['flavor'] = 'presentation'
        error, valid_track = validator.validate_track(track)
        self.assertEqual(error, None)
        self.assertEqual(valid_track['flavor'], 'presentation')

        # Invalid
        track['flavor'] = 'noflavor'
        error, valid_track = validator.validate_track(track)
        self.assertNotEqual(error, None)
        self.assertEqual(valid_track['flavor'], 'presenter')

        # Valid (Test custom flavors)
        from galicaster.core import context as gc_context
        gc_conf = gc_context.get_conf()
        gc_conf.set('basic', 'custom_flavors', 'myflavor') # Add myflavor to list of valid flavors

        track['flavor'] = 'myflavor'
        error, valid_track = validator.validate_track(track)
        self.assertEqual(error, None)
        self.assertEqual(valid_track['flavor'], 'myflavor')
def init():
    global conf, logger, event_handler, jobs, cam_ctrl
    dispatcher = context.get_dispatcher()
    conf = context.get_conf()
    logger = context.get_logger()
    camera = conf.get('cameracontrol', 'camera')

    cam = __import__(camera, globals())
    cam_ctrl = cam.Controls()

    icons = [
        "left", "right", "up1", "down1", "up_right", "up_left", "down_left",
        "down_right", "plus", "minus"
    ]
    icontheme = Gtk.IconTheme()
    for name in icons:
        pixbuf = GdkPixbuf.Pixbuf.new_from_file(get_image_path(name + ".svg"))
        icontheme.add_builtin_icon(name, 20, pixbuf)

    dispatcher.connect('init', load_ui)
    dispatcher.connect("action-key-press", on_key_press)
    dispatcher.connect("action-key-release", on_key_release)

    event_handler = Handler()
    jobs = Queue.Queue()
    t = T(jobs)
    t.setDaemon(True)
    t.start()
Esempio n. 38
0
    def duplicate_profile(self, origin):
        model,iterator = self.view.get_selection().get_selected()
        if type(iterator) is not gtk.TreeIter:
            return

        profile = model.get_value(iterator,0)
        
        new_profile = conf.Profile (                                    
            profile.name+" copy",
            context.get_conf().get_free_profile()
            )
        
        for track in profile.tracks:
            new_profile.add_track(track)
        context.get_conf().add_profile(new_profile)
        self.refresh()
Esempio n. 39
0
 def crash_file_creator(self):
     from galicaster.core import context
     if context.get_conf().get_boolean("plugins", "notifycrash"):
         filename = os.path.join(self.get_rectemp_path(), ".recording_crash")
         file = open(filename, 'w')
         file.close()
     return
Esempio n. 40
0
def init():
    try:
        global device
        global MAX_AMPLITUDE
        global audio_track
        dispatcher = context.get_dispatcher()
        device = context.get_conf().get('failovermic', 'device')
        MAX_AMPLITUDE = context.get_conf().get('failovermic', 'failover_threshold')
        audio_track = context.get_conf().get('failovermic', 'audio_track')
        dispatcher.connect('update-rec-vumeter', check_pipeline_amp)
        dispatcher.connect('recorder-closed', failover_audio)
        dispatcher.connect('starting-record', record)
        dispatcher.connect('restart-preview', stop)
        set_pipeline()
    except ValueError:
        pass
Esempio n. 41
0
def init():
    global conf, logger, recorder, dispatcher
    dispatcher = context.get_dispatcher()
    logger = context.get_logger()
    conf = context.get_conf()
    recorder = context.get_recorder()
    dispatcher.connect('init', manage_button)
Esempio n. 42
0
def init():
    global loaded
    conf = context.get_conf()

    list_plugins = conf.get_section('plugins')
    for plugin, v in list(list_plugins.items()):
        if v.lower() == 'true':
            for prefix in prefixes:
                plugin_type = prefixes[prefix]
                try:
                    name = prefix + plugin
                    __import__(name)
                    sys.modules[name].init()
                    logger.info('{} plugin {} started'.format(plugin_type,
                                                              plugin))
                    loaded.append(name)
                    break
                except Exception as e:
                    if e.msg == 'No module named {}'.format(plugin):
                        logger.warning('{} plugin {} not found'
                                       .format(plugin_type, plugin))
                    else:
                        logger.error('Exception thrown starting plugin {}:'
                                     .format(plugin), exc_info=True)
            else:
                logger.error('Error starting plugin {}'.format(plugin))
        else:
            logger.info('Plugin {0} not enabled in conf'.format(plugin))
Esempio n. 43
0
    def add_after_rec(self, mp, bins, duration, add_catalogs=True, remove_tmp_files=True, ignore_capture_devices=False):
        """Adds information to the mediapackage when a recording ends and adds it to the repository.
        Args:
            mp (Mediapackage): the mediapackage whose recordings are going to be updated.
            bins (Dict{str,str}): the information about mediapackage recordings.
            duration (str): duration of the mediapackage.
            add_catalogs (bool): true if the mediapackage belongs to a catalog, false otherwise.
            remove_tmp_files (bool): true if the temporary file are going to be removed.
        Returns:
            Str: the URI of the mediapackage
        """
        if not self.has(mp):
            if not mp.getURI():
                mp.setURI(self.__get_folder_name(mp))
                os.mkdir(mp.getURI())

        for bin in bins:
            # TODO rec all and ingest
            capture_dev_names = mp.getOCCaptureAgentProperty('capture.device.names')
            if mp.manual or not capture_dev_names or len(capture_dev_names) == 0 or capture_dev_names == 'defaults' or bin['name'].lower() in capture_dev_names or ignore_capture_devices:
                filename = os.path.join(bin['path'], bin['file'])
                dest = os.path.join(mp.getURI(), os.path.basename(filename))
                os.rename(filename, dest)

                etype   = bin['mimetype']
                if not '/' in bin['flavor']:
                    flavour = bin['flavor'] + '/source'
                else:
                    flavour = bin['flavor']

                tags = []
                if 'tags' in bin:
                    tags = bin['tags']

                mp.add(dest, mediapackage.TYPE_TRACK, flavour, etype, duration, tags=tags) # FIXME MIMETYPE
            else:
                self.logger and self.logger.info("Not adding {} to MP {}".format(bin['file'],mp.getIdentifier()))

        if mp.manual and not mp.getSeriesIdentifier():
            conf = context.get_conf()
            if conf.get('series','default'):
                series.setSeriebyId(mp, conf.get('series','default'))

        mp.forceDuration(duration)


        if add_catalogs:
            if not mp.getElementByBasename('episode.xml'):
                mp.add(os.path.join(mp.getURI(), 'episode.xml'), mediapackage.TYPE_CATALOG, 'dublincore/episode', 'text/xml')
            if mp.getSeriesIdentifier():
                if not mp.getElementByBasename('series.xml'):
                    mp.add(os.path.join(mp.getURI(), 'series.xml'), mediapackage.TYPE_CATALOG, 'dublincore/series', 'text/xml')

        # ADD MP to repo
        self.__add(mp)

        # Remove temporary files
        self._manage_tmp_files(remove_tmp_files, mp.getURI())

        return mp.getURI()
Esempio n. 44
0
def post_init(source=None):
    conf = context.get_conf()
    recorder_ui = context.get_mainwindow().nbox.get_nth_page(0).gui
    data_panel = recorder_ui.get_object('data_panel')

    # Customize tabs in the recorder UI
    try:
        tabs_to_hide = set(x
                           for x in set(conf.get('hidetabs', 'hide').split())
                           if x in ALL_TABS)
        if tabs_to_hide:
            for tab, obj_name in ALL_TABS.iteritems():
                page = recorder_ui.get_object(obj_name)
                if tab in tabs_to_hide:
                    page.hide()

    except AttributeError:
        # The conf parameter isn't defined. Ignore
        print "Attribute error"

    default_tab = conf.get('hidetabs', 'default') or None
    try:
        page = recorder_ui.get_object(ALL_TABS[default_tab])
        data_panel.set_current_page(data_panel.page_num(page))
    except KeyError:
        # The conf parameter isn't defined. Ignore
        pass
Esempio n. 45
0
def send_to_moniviestin(mediapackage, dispatcher, logger, worker):
    sbs_layout = "sbs"

    from galicaster.core import context
    url = context.get_conf().get("moniviestin", "url")

    dispatcher.emit(
        'start-operation',
        'send-moniviestin',
        mediapackage
    )

    logger.info("Starting to send moniviestin")
    #create side-by-side video
    export_path = worker.export_path

    logger.info(
        'Executing SideBySide for MP {0}'.format(mediapackage.getIdentifier())
    )

    name = datetime.now().replace(microsecond=0).isoformat()
    sbs_location = os.path.join(export_path, name + '.mp4')
    logger.info("SBS_location: %s" % sbs_location)
    try:
        create_sbs_video(sbs_location, sbs_layout, mediapackage)
    except Exception, e:
        logger.exception("Failed to sbs", e)
        logger.info(
            "Failed to create sbs video, stopping send to moniviestin"
        )
        return
Esempio n. 46
0
    def __init__(self, options):
        self.logger = logger
        # Init gc_parameters add Base and Object class
        self.gc_parameters = self.get_gc_parameters()
        path = 'Unknown'
        current_profile = context.get_conf().get_current_profile()
        if current_profile:
            path = current_profile.path
        # Check the profile parameters (*.ini)
        for k in options:
            if k not in self.gc_parameters and k not in ['device', 'active', 'path']:
                logger.warning('The profile parameter "{0}" does not exist. Please check the file {1}'.format(
                        k, path))



        # Init options with default gc_parameters values and options
        self.options = dict([(k,v['default']) for k,v in self.gc_parameters.iteritems()])
        # TODO parsear

        # Validate option values
        for k, v in options.iteritems():
            gc_parameter = None
            if self.gc_parameters.has_key(k):
                gc_parameter = self.gc_parameters[k]
            if v is not None:
                error, self.options[k] = validator.parse_validate(k, v, gc_parameter)
                if error:
                    self.logger.error(error)

        # Sanitaze values
        self.options["name"] = re.sub(r'\W+', '', self.options["name"])
def init():
    try:
        conf = context.get_conf()
        mode = conf.get('qrcode', 'pause_mode') or 'hold'  # or 'start_stop'
        symbols = {}
        symbols['start'] = conf.get('qrcode', 'start_code') or 'start'
        symbols['stop'] = conf.get('qrcode', 'stop_code') or 'stop'
        symbols['hold'] = conf.get('qrcode', 'hold_code') or 'hold'
        rescale = conf.get('qrcode', 'rescale') or 'source'
        drop_frames = conf.get_boolean('qrcode', 'drop_frames') or False
        buffers = conf.get_int('qrcode', 'buffers') or 200
        hold_timeout = conf.get_int('qrcode', 'hold_timeout') or 1  # secs
        ignore_bins = conf.get('qrcode', 'ignore_track_name') or None
        qr = QRCodeScanner(mode, symbols, hold_timeout, rescale, drop_frames,
                           buffers, ignore_bins, context.get_logger())

        dispatcher = context.get_dispatcher()
        dispatcher.connect('recorder-ready', qr.qrcode_add_pipeline)
        # only process sync-messages when recording to reduce overhead
        dispatcher.connect('recorder-started',
                           qr.qrcode_connect_to_sync_message)
        dispatcher.connect('recorder-stopped',
                           qr.qrcode_disconnect_to_sync_message)
        qr.set_add_edits(conf.get_boolean('qrcode', 'mp_add_edits') or False)
        qr.set_trimhold(
            conf.get_boolean('qrcode', 'mp_force_trimhold') or False)
        qr.set_add_smil(conf.get_boolean('qrcode', 'mp_add_smil') or False)
        dispatcher.connect('recorder-stopped', qr.qrcode_update_mediapackage)

    except ValueError:
        pass
Esempio n. 48
0
    def __init__(self, package=None, parent=None):
        self.gui = gtk.Builder()
        self.gui.add_from_file(get_ui_path('conf.glade'))

        self.conf = context.get_conf()

        dialog = self.gui.get_object("confdialog")
        if parent != None:
            dialog.set_transient_for(parent.get_toplevel())
        self.shifter1 = self.gui.get_object('playershift')
        self.shifter2 = self.gui.get_object('recordshift')
        self.shifter1.add_events(gtk.gdk.BUTTON_PRESS_MASK)
        self.shifter1.connect("button-press-event",
                              self.on_toggle)  # CHANGE method name
        self.shifter2.add_events(gtk.gdk.BUTTON_PRESS_MASK)
        self.shifter2.connect("button-press-event",
                              self.on_toggle)  # CHANGE method name
        if self.conf.get("screen", "player") == "presentation":
            self.on_toggle(self.shifter1, None)
        if self.conf.get("screen", "recorder") == "presentation":
            self.on_toggle(self.shifter2, None)

        self.populate_conf()
        response = dialog.run()
        if response > 1:  # FIXME, need a main
            print "Galicaster Configuration Update"
            self.update_conf()
        elif response == 1:
            print "Galicaster Configuration Update"  # FIXME just apply changes dont close
            self.update_conf()
        else:
            print "Cancel Configuration"
        dialog.destroy()
Esempio n. 49
0
    def __init__(self):
        Gtk.Table.__init__(self)
        self.resize(4,110)
        self.set_homogeneous(False)
        self.mute = False
        self.vumeter=Gtk.ProgressBar()
        self.rangeVum = 40
        conf = context.get_conf()
        self.minimum =  float(conf.get('audio','min') or -70)

	    #numbers
        label0 = Gtk.Label(label="0 dB")
        label1 = Gtk.Label(label="-3")
        label2 = Gtk.Label(label="-6")
        label3 = Gtk.Label(label="-12")
        label4 = Gtk.Label(label="-24")
        label5 = Gtk.Label(label="-40")	
	
        # set number's colour
	self.modify_widget_fgcolor (label0, Gdk.color_parse("#D9211D")) # Red
	self.modify_widget_fgcolor (label1, Gdk.color_parse("#D95E1D")) # Orange
	self.modify_widget_fgcolor (label2, Gdk.color_parse("#D95E1D")) # Orange
	self.modify_widget_fgcolor (label3, Gdk.color_parse("#068629")) # Green
	self.modify_widget_fgcolor (label4, Gdk.color_parse("#068629")) # Green
	self.modify_widget_fgcolor (label5, Gdk.color_parse("#068629")) # Green
    	
        labels= [label0,label1,label2,label3,label4,label5]
        for label in labels:
            label.set_justify(Gtk.Justification.CENTER)
            alist = Pango.AttrList()
            font=Pango.FontDescription("bold")
            #attr=Pango.AttrFontDesc(font,0,-1)
            #alist.insert(attr)
            #label.set_attributes(alist)

        # set number's position
        self.attach(label0,100,110,0,1,Gtk.AttachOptions.EXPAND|Gtk.AttachOptions.FILL,Gtk.AttachOptions.EXPAND|Gtk.AttachOptions.FILL,0,0)	#0
        self.attach(label1,92,102,0,1,Gtk.AttachOptions.EXPAND|Gtk.AttachOptions.FILL,Gtk.AttachOptions.EXPAND|Gtk.AttachOptions.FILL,0,0)	#-3
        self.attach(label2,85,95,0,1,Gtk.AttachOptions.EXPAND|Gtk.AttachOptions.FILL,Gtk.AttachOptions.EXPAND|Gtk.AttachOptions.FILL,0,0)	#-6
        self.attach(label3,70,80,0,1,Gtk.AttachOptions.EXPAND|Gtk.AttachOptions.FILL,Gtk.AttachOptions.EXPAND|Gtk.AttachOptions.FILL,0,0)	#-12
        self.attach(label4,40,50,0,1,Gtk.AttachOptions.EXPAND|Gtk.AttachOptions.FILL,Gtk.AttachOptions.EXPAND|Gtk.AttachOptions.FILL,0,0)	#-24
        self.attach(label5,0,10,0,1,Gtk.AttachOptions.EXPAND|Gtk.AttachOptions.FILL,Gtk.AttachOptions.EXPAND|Gtk.AttachOptions.FILL,0,0)	#-40

        #marks
        mark0=Gtk.VSeparator()
        mark1=Gtk.VSeparator()
        mark2=Gtk.VSeparator()
        mark3=Gtk.VSeparator()
        mark4=Gtk.VSeparator()
        mark5=Gtk.VSeparator()

        # attach marks to widget   
        self.attach(mark0,105,106,1,2,Gtk.AttachOptions.EXPAND|Gtk.AttachOptions.FILL,Gtk.AttachOptions.EXPAND|Gtk.AttachOptions.FILL,0,0)	#0dB
        self.attach(mark1,97,98,1,2,Gtk.AttachOptions.EXPAND|Gtk.AttachOptions.FILL,Gtk.AttachOptions.EXPAND|Gtk.AttachOptions.FILL,0,0)	#-3
        self.attach(mark2,90,91,1,2,Gtk.AttachOptions.EXPAND|Gtk.AttachOptions.FILL,Gtk.AttachOptions.EXPAND|Gtk.AttachOptions.FILL,0,0)	#-6
        self.attach(mark3,75,76,1,2,Gtk.AttachOptions.EXPAND|Gtk.AttachOptions.FILL,Gtk.AttachOptions.EXPAND|Gtk.AttachOptions.FILL,0,0)	#-12
        self.attach(mark4,45,46,1,2,Gtk.AttachOptions.EXPAND|Gtk.AttachOptions.FILL,Gtk.AttachOptions.EXPAND|Gtk.AttachOptions.FILL,0,0)	#-24
        self.attach(mark5,5,6,1,2,Gtk.AttachOptions.EXPAND|Gtk.AttachOptions.FILL,Gtk.AttachOptions.EXPAND|Gtk.AttachOptions.FILL,0,0)		#-40

        self.attach(self.vumeter,5,105,2,4,Gtk.AttachOptions.EXPAND|Gtk.AttachOptions.FILL,Gtk.AttachOptions.EXPAND|Gtk.AttachOptions.FILL,0,0)
Esempio n. 50
0
def init():
    global conf, logger, event_handler, jobs
    dispatcher = context.get_dispatcher()
    conf = context.get_conf()
    logger = context.get_logger()

    path = conf.get('cameracontrol', 'path')
    pysca.connect(path)
    pysca.set_zoom(1, 0)
    pysca.pan_tilt_home(1)
    dispatcher.connect('init', load_ui)
    pysca.osd_off(1)
    logger.info("Cam connected")

    icons = [
        "left", "right", "up1", "down1", "up_right", "up_left", "down_left",
        "down_right", "plus", "minus"
    ]
    icontheme = Gtk.IconTheme()
    for name in icons:
        pixbuf = GdkPixbuf.Pixbuf.new_from_file(get_image_path(name + ".svg"))
        icontheme.add_builtin_icon(name, 20, pixbuf)

    dispatcher.connect("action-key-press", on_key_press)
    dispatcher.connect("action-key-release", on_key_release)

    event_handler = Handler()
    jobs = Queue.Queue()
    t = T(jobs)
    t.setDaemon(True)
    t.start()
Esempio n. 51
0
def init():

    global recorder_ui
    global rec_button
    global metadata

    metadata = {}

    # Get a shallow copy of the plugin configuration
    config = context.get_conf().get_section('setuprecording') or {}

    # Get the metadata to setup the mediapackage defaults
    for key, value in config.iteritems():
        final_key = EQUIV.get(key) or key
        if final_key in DCTERMS:
            try:
                metadata[final_key] = value.format(**MAPPINGS)
            except KeyError:
                metadata[final_key] = value

    # Check the special case that series is specified using 'series' rather than 'isPartOf'
    if 'series' in config:
        metadata['isPartOf'] = config['series']

    recorder_ui = context.get_mainwindow().nbox.get_nth_page(0)

    rec_button = recorder_ui.gui.get_object('recbutton')

    rec_button.connect('clicked', on_rec)
    rec_button.handler_block_by_func(recorder_ui.on_rec)
Esempio n. 52
0
def monitor_timer_action(sender=None):

    global monitor_active

    conf = context.get_conf()

    # Is a recording currently active?
    logger.info("Short timer tick")

    now = datetime.datetime.now()
    # print now.year, now.month, now.day, now.hour, now.minute, now.second

    logger.info("Hour=%i minute=%i", now.hour, now.minute)

    # 8am - 5pm Mon-Fri
    if (now.minute % 2) == 1:
        # Check whether to start an ad-hoc recording: is there a recording active now?
        if recorder.is_recording() == False:
	    start_rapidrec_recording()
            monitor_active = True
        else:
            logger.info("Recording active - not starting rapidrec recording")

    if (now.minute %2) == 0:
        logger.info("Checking stop")
        # Check whether to stop an ad-hoc recording
        if recorder.is_recording() and monitor_active:
	    stop_rapidrec_recording()
            monitor_active = False
Esempio n. 53
0
 def show_current_image(self, column, cell, model, iterator, data=None):
     profile = model[iterator][0]
     if profile == context.get_conf().get_current_profile():
         cell.set_property("stock-id", Gtk.STOCK_YES)
         cell.set_property("stock-size", Gtk.IconSize.LARGE_TOOLBAR)
     else:
         cell.set_property("stock-id", "0")
     return None
Esempio n. 54
0
def init():
    dispatcher = context.get_dispatcher()
    inactivity = context.get_conf().get('screensaver', 'inactivity')
        
    dispatcher.connect('upcoming-recording', deactivate_screensaver)
    dispatcher.connect('starting-record', deactivate_screensaver)
    dispatcher.connect('restart-preview', activate_screensaver)
    activate_screensaver()
Esempio n. 55
0
 def new_profile(self, origin):
     new = conf.Profile("New Profile")
     new.path = context.get_conf().get_free_profile()
     ProfileBox(new,self.superior)
     self.superior.profile=ProfileBox(new,self.superior)
     tab2=gtk.Label(self.superior.get_title()+" > "+new.name)
     self.superior.append_tab(self.superior.profile,tab2)
     return new
Esempio n. 56
0
def init():
    global inactivity
    dispatcher = context.get_dispatcher()
    inactivity = context.get_conf().get('screensaver', 'inactivity')
    dispatcher.connect('upcoming-recording', deactivate_and_poke)
    dispatcher.connect('starting-record', deactivate_and_poke)
    dispatcher.connect('restart-preview', configure)
    dispatcher.connect('galicaster-notify-quit', configure_quit)
    configure()