コード例 #1
0
ファイル: queue.py プロジェクト: netravnen/indico-plugins
    def create(cls, changes, ref, excluded_categories=set()):
        """Create a new change in all queues.

        :param changes: the change types, an iterable containing
                        :class:`ChangeType`
        :param ref: the object reference (returned by `obj_ref`)
                        of the changed object
        :param excluded_categories: set of categories (IDs) whose items
                                    will not be tracked
        """
        ref = dict(ref)
        obj = obj_deref(ref)

        if isinstance(obj, Category):
            if any(c.id in excluded_categories for c in obj.chain_query):
                return
        else:
            event = obj if isinstance(obj, Event) else obj.event
            if excluded_categories & set(event.category_chain):
                return

        for change in changes:
            for agent in LiveSyncAgent.find():
                entry = cls(agent=agent, change=change, **ref)
                db.session.add(entry)

        db.session.flush()
コード例 #2
0
def agents():
    """Lists the currently active agents"""
    print 'The following LiveSync agents are active:'
    agent_list = LiveSyncAgent.find().order_by(
        LiveSyncAgent.backend_name, db.func.lower(LiveSyncAgent.name)).all()
    table_data = [['ID', 'Name', 'Backend', 'Initial Export', 'Queue']]
    for agent in agent_list:
        initial = (cformat('%{green!}done%{reset}')
                   if agent.initial_data_exported else
                   cformat('%{yellow!}pending%{reset}'))
        if agent.backend is None:
            backend_title = cformat(
                '%{red!}invalid backend ({})%{reset}').format(
                    agent.backend_name)
        else:
            backend_title = agent.backend.title
        table_data.append([
            unicode(agent.id), agent.name, backend_title, initial,
            unicode(agent.queue.filter_by(processed=False).count())
        ])
    table = AsciiTable(table_data)
    table.justify_columns[4] = 'right'
    print table.table
    if not all(a.initial_data_exported for a in agent_list):
        print
        print "You need to perform the initial data export for some agents."
        print cformat(
            "To do so, run "
            "%{yellow!}indico livesync initial_export %{reset}%{yellow}<agent_id>%{reset} for those agents."
        )
コード例 #3
0
ファイル: queue.py プロジェクト: florv/indico-plugins
    def create(cls, changes, ref):
        """Creates a new change in all queues

        :param changes: the change types, an iterable containing
                        :class:`ChangeType`
        :param ref: the object reference (returned by `obj_ref`)
                        of the changed object
        """
        ref = dict(ref)
        for agent in LiveSyncAgent.find():
            for change in changes:
                entry = cls(agent=agent, change=change, **ref)
                db.session.add(entry)
        db.session.flush()
コード例 #4
0
ファイル: cli.py プロジェクト: indico/indico-plugins
def agents():
    """Lists the currently active agents"""
    print 'The following LiveSync agents are active:'
    agent_list = LiveSyncAgent.find().order_by(LiveSyncAgent.backend_name, db.func.lower(LiveSyncAgent.name)).all()
    table_data = [['ID', 'Name', 'Backend', 'Initial Export', 'Queue']]
    for agent in agent_list:
        initial = (cformat('%{green!}done%{reset}') if agent.initial_data_exported else
                   cformat('%{yellow!}pending%{reset}'))
        if agent.backend is None:
            backend_title = cformat('%{red!}invalid backend ({})%{reset}').format(agent.backend_name)
        else:
            backend_title = agent.backend.title
        table_data.append([unicode(agent.id), agent.name, backend_title, initial,
                           unicode(agent.queue.filter_by(processed=False).count())])
    table = AsciiTable(table_data)
    table.justify_columns[4] = 'right'
    print table.table
    if not all(a.initial_data_exported for a in agent_list):
        print
        print "You need to perform the initial data export for some agents."
        print cformat("To do so, run "
                      "%{yellow!}indico livesync initial_export %{reset}%{yellow}<agent_id>%{reset} for those agents.")
コード例 #5
0
def extend_plugin_details():
    agents = LiveSyncAgent.find().order_by(LiveSyncAgent.name,
                                           LiveSyncAgent.id).all()
    return render_plugin_template('plugin_details_extra.html',
                                  agents=agents,
                                  backends=current_plugin.backend_classes)
コード例 #6
0
 def has_data(self):
     return LiveSyncAgent.find().count()
コード例 #7
0
ファイル: zodbimport.py プロジェクト: florv/indico-plugins
 def has_data(self):
     return LiveSyncAgent.find().count()
コード例 #8
0
ファイル: controllers.py プロジェクト: florv/indico-plugins
def extend_plugin_details():
    agents = LiveSyncAgent.find().order_by(LiveSyncAgent.name, LiveSyncAgent.id).all()
    return render_plugin_template('plugin_details_extra.html', agents=agents, backends=current_plugin.backend_classes)