Пример #1
0
def deploy():
    used = set()
    try:
        triggers = [app.DEPLOY, app.POPULATE]
        if application_mode() == APP_NORMAL: triggers.append(app.NORMAL)
        elif application_mode() == APP_DEVEL: triggers.append(app.DEVEL)

        for call, name, trigger in support.eventsFor(*triggers):
            trigger = (trigger,)
            if app.DEPLOY.isTriggered(trigger):
                log.debug('Executing event call \'%s\'', name)
                call()
            elif app.POPULATE.isTriggered(trigger):
                used.add(name)
                executed = markers().get(name)
                if app.DEVEL.isTriggered(trigger): executed = None  # If in devel then we execute regardless
                if executed is None:
                    executed = call()
                    log.debug('Executed populate event call \'%s\' for the first time and got %s', name, executed)
                elif not executed:
                    executed = call()
                    log.debug('Executed populate event call \'%s\' again and got %s', name, executed)
                else:
                    log.debug('No need to execute populate event call \'%s\'', name)
                markers()[name] = executed

            elif app.NORMAL.isTriggered(trigger):
                log.debug('Executing normal only deploy event call \'%s\'', name)
                call()
            elif app.DEVEL.isTriggered(trigger):
                log.debug('Executing development only deploy event call \'%s\'', name)
                call()
    finally: persistMarkers(used)
Пример #2
0
def repair():
    openPlugins()

    used = set()
    try:
        for call, name, trigger in support.eventsFor(event.REPAIR, app.POPULATE):
            trigger = (trigger,)
            if app.POPULATE.isTriggered(trigger):
                used.add(name)
                executed = markers().get(name)
                if app.DEVEL.isTriggered(trigger) or app.REPAIR.isTriggered(trigger): executed = None  # If in devel then we execute regardless
                if executed is None:
                    executed = call()
                    log.info('Executed populate event call \'%s\' for the first time and got %s', name, executed)
                elif not executed:
                    executed = call()
                    log.info('Executed populate event call \'%s\' again and got %s', name, executed)
                else:
                    log.info('No need to execute populate event call \'%s\'', name)
                markers()[name] = executed

            elif app.REPAIR.isTriggered(trigger):
                log.info('Executing plugins repair event call \'%s\'', name)
                call()
    finally:
        persistMarkers(used)
        context.deactivate()
Пример #3
0
def triggerEvents(*triggers, always=(app.DEPLOY,), regardless=(app.DEVEL,), otherwise=(app.NORMAL, app.DEVEL)):
    '''
    Triggers the event for the provided triggers in accordance with the plugin distribution.
    The defaults of this function are for normal application execution.
    
    @param triggers: arguments[object]
        The triggers to perform the events for.
    @param always: tuple(ITrigger)
        The triggers that if present should always be executed.
    @param regardless: tuple(ITrigger)
        The triggers that if present with POPULATE should always be executed.
    @param otherwise: tuple(ITrigger)
        The triggers that if no POPULATE is present should otherwise be executed.
    '''
    assert triggers, 'At least one trigger is required'
    assert isinstance(always, tuple), 'Invalid always triggers %s' % always
    assert isinstance(regardless, tuple), 'Invalid regardless triggers %s' % regardless
    assert isinstance(otherwise, tuple), 'Invalid otherwise triggers %s' % otherwise
    if __debug__:
        for trigger in always: assert isinstance(trigger, ITrigger), 'Invalid always trigger %s' % trigger
        for trigger in regardless: assert isinstance(trigger, ITrigger), 'Invalid regardless trigger %s' % trigger
        for trigger in otherwise: assert isinstance(trigger, ITrigger), 'Invalid otherwise trigger %s' % trigger
    
    for call, name, ctriggers in support.eventsFor(*triggers):
        if app.DEVEL.isTriggered(ctriggers) and application_mode() != APP_DEVEL: continue
        if app.NORMAL.isTriggered(ctriggers) and application_mode() != APP_NORMAL: continue
        
        if any(trigger.isTriggered(ctriggers) for trigger in always):
            log.debug('Executing always event call \'%s\'', name)
            call()
        elif app.POPULATE.isTriggered(ctriggers):
            used().add(name)
            executed = markers().get(name)
            if any(trigger.isTriggered(ctriggers) for trigger in regardless): executed = None
            if executed is None:
                executed = call()
                log.debug('Executed populate event call \'%s\' for the first time and got %s', name, executed)
            elif not executed:
                executed = call()
                log.debug('Executed populate event call \'%s\' again and got %s', name, executed)
            else:
                log.debug('No need to execute populate event call \'%s\'', name)
            markers()[name] = executed

        elif any(trigger.isTriggered(ctriggers) for trigger in otherwise):
            log.debug('Executing otherwise event call \'%s\'', name)
            call()
Пример #4
0
def deploy():
    used = set()
    try:
        triggers = [app.DEPLOY, app.POPULATE]
        if application_mode() == APP_NORMAL: triggers.append(app.NORMAL)
        elif application_mode() == APP_DEVEL: triggers.append(app.DEVEL)

        for call, name, trigger in support.eventsFor(*triggers):
            trigger = (trigger, )
            if app.DEPLOY.isTriggered(trigger):
                log.debug('Executing event call \'%s\'', name)
                call()
            elif app.POPULATE.isTriggered(trigger):
                used.add(name)
                executed = markers().get(name)
                if app.DEVEL.isTriggered(trigger):
                    executed = None  # If in devel then we execute regardless
                if executed is None:
                    executed = call()
                    log.debug(
                        'Executed populate event call \'%s\' for the first time and got %s',
                        name, executed)
                elif not executed:
                    executed = call()
                    log.debug(
                        'Executed populate event call \'%s\' again and got %s',
                        name, executed)
                else:
                    log.debug('No need to execute populate event call \'%s\'',
                              name)
                markers()[name] = executed

            elif app.NORMAL.isTriggered(trigger):
                log.debug('Executing normal only deploy event call \'%s\'',
                          name)
                call()
            elif app.DEVEL.isTriggered(trigger):
                log.debug(
                    'Executing development only deploy event call \'%s\'',
                    name)
                call()
    finally:
        persistMarkers(used)
Пример #5
0
def repair():
    assert isinstance(application.options, OptionsCore), 'Invalid application options %s' % application.options
    if not application.options.repair: return
    try:
        openSetups()
        for call, name, _trigger in support.eventsFor(event.REPAIR):
            log.info('Executing repair event call \'%s\'', name)
            call()
            
    except SystemExit: raise
    except (SetupError, ConfigError):
        print('-' * 150, file=sys.stderr)
        print('A setup or configuration error occurred while deploying, try to rebuild the application properties by '
              'running the the application with "-dump" options', file=sys.stderr)
        traceback.print_exc(file=sys.stderr)
        print('-' * 150, file=sys.stderr)
    except:
        print('-' * 150, file=sys.stderr)
        print('A problem occurred while repairing', file=sys.stderr)
        traceback.print_exc(file=sys.stderr)
        print('-' * 150, file=sys.stderr)
    finally: context.deactivate()
Пример #6
0
def triggerEvents(*triggers,
                  always=(app.DEPLOY, ),
                  regardless=(app.DEVEL, ),
                  otherwise=(app.NORMAL, app.DEVEL)):
    '''
    Triggers the event for the provided triggers in accordance with the plugin distribution.
    The defaults of this function are for normal application execution.
    
    @param triggers: arguments[object]
        The triggers to perform the events for.
    @param always: tuple(ITrigger)
        The triggers that if present should always be executed.
    @param regardless: tuple(ITrigger)
        The triggers that if present with POPULATE should always be executed.
    @param otherwise: tuple(ITrigger)
        The triggers that if no POPULATE is present should otherwise be executed.
    '''
    assert triggers, 'At least one trigger is required'
    assert isinstance(always, tuple), 'Invalid always triggers %s' % always
    assert isinstance(regardless,
                      tuple), 'Invalid regardless triggers %s' % regardless
    assert isinstance(otherwise,
                      tuple), 'Invalid otherwise triggers %s' % otherwise
    if __debug__:
        for trigger in always:
            assert isinstance(trigger,
                              ITrigger), 'Invalid always trigger %s' % trigger
        for trigger in regardless:
            assert isinstance(
                trigger, ITrigger), 'Invalid regardless trigger %s' % trigger
        for trigger in otherwise:
            assert isinstance(
                trigger, ITrigger), 'Invalid otherwise trigger %s' % trigger

    for call, name, ctriggers in support.eventsFor(*triggers):
        if app.DEVEL.isTriggered(
                ctriggers) and application_mode() != APP_DEVEL:
            continue
        if app.NORMAL.isTriggered(
                ctriggers) and application_mode() != APP_NORMAL:
            continue

        if any(trigger.isTriggered(ctriggers) for trigger in always):
            log.debug('Executing always event call \'%s\'', name)
            call()
        elif app.POPULATE.isTriggered(ctriggers):
            used().add(name)
            executed = markers().get(name)
            if any(trigger.isTriggered(ctriggers) for trigger in regardless):
                executed = None
            if executed is None:
                executed = call()
                log.debug(
                    'Executed populate event call \'%s\' for the first time and got %s',
                    name, executed)
            elif not executed:
                executed = call()
                log.debug(
                    'Executed populate event call \'%s\' again and got %s',
                    name, executed)
            else:
                log.debug('No need to execute populate event call \'%s\'',
                          name)
            markers()[name] = executed

        elif any(trigger.isTriggered(ctriggers) for trigger in otherwise):
            log.debug('Executing otherwise event call \'%s\'', name)
            call()