Esempio n. 1
0
def start():
    if not options.isFlag(FLAG_START): return
    if not os.path.isfile(options.configuration):
        log.warn(
            'The configuration file "%s" doesn\'t exist, create one by running the the application '
            'with "-dump" option', options.configuration)
    context.processStart()
Esempio n. 2
0
def start():
    if not os.path.isfile(path_configuration()):
        log.warn('The configuration file \'%s\' does not exist, create one by running the the application '
                 'with "-dump" option', path_configuration())
    with activate(plugins(), 'start'):
        context.configurationsLoad(configurations())
        triggerEvents(app.SETUP)
        context.processStart()
Esempio n. 3
0
def start():
    if not os.path.isfile(path_configuration()):
        log.warn(
            'The configuration file \'%s\' does not exist, create one by running the the application '
            'with "-dump" option', path_configuration())
    with activate(plugins(), 'start'):
        context.configurationsLoad(configurations())
        triggerEvents(app.SETUP)
        context.processStart()
Esempio n. 4
0
def __deploy__():
    # Deploy the application
    try:
        import package_extender
        package_extender.PACKAGE_EXTENDER.addFreezedPackage('__deploy__.')
        from ally.container import aop, context
    except ImportError:
        print(
            'Corrupted or missing ally component, make sure that this component is not missing from python path '
            'or components eggs',
            file=sys.stderr)
        sys.exit(1)

    application = sys.modules['application'] = ModuleType('application')
    try:
        # We create the parser to be prepared.
        application.parser = argparse.ArgumentParser(
            description='The ally distribution application deployer.')
        application.Options = object  # Prepare the option class

        # In the first stage we prepare the application deployment.
        context.open(aop.modulesIn('__deploy__.*.prepare'))
        try:
            context.processStart()
        finally:
            context.deactivate()

        # In the second stage we parse the application arguments.
        application.options = application.parser.parse_args(
            namespace=application.Options())

        # In the final stage we deploy the application.
        context.open(aop.modulesIn('__deploy__.*.deploy'))
        try:
            context.processStart()
        finally:
            context.deactivate()

    except SystemExit:
        raise
    except:
        print('-' * 150, file=sys.stderr)
        print('A problem occurred while deploying', file=sys.stderr)
        traceback.print_exc()
        print('-' * 150, file=sys.stderr)
        sys.exit(1)
Esempio n. 5
0
def deploy():
    loadPlugins()
    if not os.path.isfile(configurations_file_path()):
        print('The configuration file "%s" does not exist, create one by running the the application '
              'with "-dump" option' % configurations_file_path())
        sys.exit(1)
    with open(configurations_file_path(), 'r') as f: config = load(f)

    PACKAGE_EXTENDER.addFreezedPackage('__plugin__.')
    pluginModules = aop.modulesIn('__plugin__.**')
    for module in pluginModules.load().asList():
        if not isPackage(module) and re.match('__plugin__\\.[^\\.]+$', module.__name__):
            raise SetupError('The plugin setup module \'%s\' is not allowed directly in the __plugin__ package it needs '
                             'to be in a sub package' % module.__name__)

    context.open(pluginModules, config=config, included=True)
    try: context.processStart()
    finally: context.deactivate()
Esempio n. 6
0
def deploy():
    assert isinstance(application.options, OptionsCore), 'Invalid application options %s' % application.options
    if not application.options.start: return
    try:
        openSetups()
        context.processStart()
        if log_file(): logging.getLogger().addHandler(FileHandler(log_file()))

    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" option', 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 deploying', file=sys.stderr)
        traceback.print_exc(file=sys.stderr)
        print('-' * 150, file=sys.stderr)
    finally: context.deactivate()
Esempio n. 7
0
def __deploy__():
    # Deploy the application
    try:
        import package_extender
        package_extender.PACKAGE_EXTENDER.addFreezedPackage('__deploy__.')
        from ally.container import aop, context
    except ImportError:
        print('Corrupted or missing ally component, make sure that this component is not missing from python path '
              'or components eggs', file=sys.stderr)
        sys.exit(1)

    application = sys.modules['application'] = ModuleType('application')
    try:
        # We create the parser to be prepared.
        application.parser = argparse.ArgumentParser(description='The ally distribution application deployer.')
        application.Options = object  # Prepare the option class

        # In the first stage we prepare the application deployment.
        context.open(aop.modulesIn('__deploy__.*.prepare'))
        try: context.processStart()
        finally: context.deactivate()

        # In the second stage we parse the application arguments.
        application.options = application.parser.parse_args(namespace=application.Options())

        # In the final stage we deploy the application.
        context.open(aop.modulesIn('__deploy__.*.deploy'))
        try: context.processStart()
        finally: context.deactivate()

    except SystemExit: raise
    except:
        print('-' * 150, file=sys.stderr)
        print('A problem occurred while deploying', file=sys.stderr)
        traceback.print_exc()
        print('-' * 150, file=sys.stderr)
        sys.exit(1)
Esempio n. 8
0
def deploy():
    assert isinstance(application.options, OptionsCore), 'Invalid application options %s' % application.options
    if not application.options.start: return
    try:
        if not os.path.isfile(application.options.configurationPath):
            print('The configuration file "%s" doesn\'t exist, create one by running the the application '
                  'with "-dump" option' % application.options.configurationPath, file=sys.stderr)
            sys.exit(1)
        with open(application.options.configurationPath, 'r') as f: config = load(f)

        context.open(aop.modulesIn('__setup__.ally_utilities.**'), config=config)

        import logging
        logging.basicConfig(format=format())
        if log_file(): logging.getLogger().addHandler(FileHandler(log_file()))
        for name in warning_for(): logging.getLogger(name).setLevel(logging.WARN)
        for name in info_for(): logging.getLogger(name).setLevel(logging.INFO)
        for name in debug_for(): logging.getLogger(name).setLevel(logging.DEBUG)

        context.deactivate()

        context.open(aop.modulesIn('__setup__.**'), config=config)
        try: context.processStart()
        finally: context.deactivate()
    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 "configure components" 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 deploying', file=sys.stderr)
        traceback.print_exc(file=sys.stderr)
        print('-' * 150, file=sys.stderr)
Esempio n. 9
0
def document():
    if not options.isFlag(FLAG_DOCUMENT): return
    with activate(plugins(), 'document'):
        context.processStart()
        createDocumentation()
Esempio n. 10
0
def document():
    if not options.isFlag(FLAG_DOCUMENT): return
    with activate(plugins(), 'document'):
        context.processStart()
        createDocumentation()
Esempio n. 11
0
def deploy():
    openPlugins()

    try: context.processStart()
    finally: context.deactivate()
Esempio n. 12
0
def start():
    if not options.isFlag(FLAG_START): return
    if not os.path.isfile(options.configuration):
        log.warn('The configuration file "%s" doesn\'t exist, create one by running the the application '
                 'with "-dump" option', options.configuration)
    context.processStart()