예제 #1
0
파일: deploy.py 프로젝트: gizm0bill/Ally-Py
def dump():
    assert isinstance(application.options, OptionsCore), 'Invalid application options %s' % application.options
    if not application.options.writeConfigurations: return
    if not __debug__:
        print('Cannot dump configuration file if python is run with "-O" or "-OO" option', file=sys.stderr)
        sys.exit(1)
    try:
        context.activate(dumpAssembly())
        try: 
            loadPlugins()
            configFile = configurations_file_path()
        
            if os.path.isfile(configFile):
                with open(configFile, 'r') as f: config = load(f)
            else: config = {}
            
            context.open(aop.modulesIn('__plugin__.**'), config=config, included=True)
            try:
                if os.path.isfile(configFile): os.rename(configFile, configFile + '.bak')
                with open(configFile, 'w') as f: save(context.configurations(force=True), f)
                print('Created "%s" configuration file' % configFile)
            finally: context.deactivate()
        finally: context.deactivate()
    
    except SystemExit: raise
    except:
        print('-' * 150, file=sys.stderr)
        print('A problem occurred while dumping configurations', file=sys.stderr)
        traceback.print_exc(file=sys.stderr)
        print('-' * 150, file=sys.stderr)
예제 #2
0
def preparePreferences():

    application.parser = parser.add_argument_group(
        'ally-py application plugins options.')
    with activate(plugins(), 'deploy'):
        support.performEventsFor(deploy.APP_PREPARE)
    application.parser = parser
예제 #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()
예제 #4
0
def __distribution__():
    # In the first stage we prepare the application deployment.
    with context.activate(context.open(aop.modulesIn('__distribution__.**')), 'deploy'):
        support.performEventsFor(APP_PREPARE)
        # In the second stage we parse the application arguments.
        parser.parse_args(namespace=options)
    
        support.performEventsFor(APP_START)
예제 #5
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()
예제 #6
0
def __deploy__():
    # Deploy the application
    with context.activate(context.open(aop.modulesIn('__setup__.**')),
                          'deploy'):
        support.performEventsFor(APP_PREPARE)
        # In the second stage we parse the application arguments.
        parser.parse_args(namespace=options)

        support.performEventsFor(APP_START)
예제 #7
0
def dump():
    assert isinstance(
        application.options,
        OptionsCore), 'Invalid application options %s' % application.options
    if not application.options.writeConfigurations: return
    if not __debug__:
        print(
            'Cannot dump configuration file if python is run with "-O" or "-OO" option',
            file=sys.stderr)
        sys.exit(1)
    try:
        context.activate(dumpAssembly())
        try:
            loadPlugins()
            configFile = configurations_file_path()

            if os.path.isfile(configFile):
                with open(configFile, 'r') as f:
                    config = load(f)
            else:
                config = {}

            context.open(aop.modulesIn('__plugin__.**'),
                         config=config,
                         included=True)
            try:
                if os.path.isfile(configFile):
                    os.rename(configFile, configFile + '.bak')
                with open(configFile, 'w') as f:
                    save(context.configurations(force=True), f)
                print('Created "%s" configuration file' % configFile)
            finally:
                context.deactivate()
        finally:
            context.deactivate()

    except SystemExit:
        raise
    except:
        print('-' * 150, file=sys.stderr)
        print('A problem occurred while dumping configurations',
              file=sys.stderr)
        traceback.print_exc(file=sys.stderr)
        print('-' * 150, file=sys.stderr)
예제 #8
0
파일: deploy.py 프로젝트: gizm0bill/Ally-Py
def dump():
    assert isinstance(application.options, OptionsCore), 'Invalid application options %s' % application.options
    if not application.options.writeConfigurations: return
    if not __debug__:
        print('Cannot dump configuration file if python is run with "-O" or "-OO" option', file=sys.stderr)
        sys.exit(1)
    assembly, configFile = dumpAssembly(), application.options.configurationPath
    try:
        context.activate(assembly)
        try:
            if os.path.isfile(configFile): os.rename(configFile, configFile + '.bak')
            for config in assembly.configurations:
                try: assembly.processForName(config)
                except ConfigError as e: print('Failed to fetch a value for configuration \'%s\': %s' % (config, e))
            # Forcing the processing of all configurations
            with open(configFile, 'w') as f: save(assembly.trimmedConfigurations(), f)
            print('Created "%s" configuration file' % configFile)
        finally: context.deactivate()
    except SystemExit: raise
    except:
        print('-' * 150, file=sys.stderr)
        print('A problem occurred while dumping configurations', file=sys.stderr)
        traceback.print_exc(file=sys.stderr)
        print('-' * 150, file=sys.stderr)
예제 #9
0
def repairEvents():
    with activate(plugins(), 'repair'): triggerEvents(app.REPAIR)
예제 #10
0
def startEvents():
    with activate(plugins(), 'events'): triggerEvents(app.DEPLOY, app.POPULATE)
예제 #11
0
def repairEvents():
    with activate(plugins(), 'repair'):
        triggerEvents(app.REPAIR)
예제 #12
0
def preparePreferences():
    
    application.parser = parser.add_argument_group('ally-py application plugins options.')
    with activate(plugins(), 'deploy'): support.performEventsFor(deploy.APP_PREPARE)
    application.parser = parser
예제 #13
0
def startEvents():
    with activate(plugins(), 'events'):
        triggerEvents(app.DEPLOY, app.POPULATE)
예제 #14
0
def dumpPlugins():
    if not options.isFlag(FLAG_DUMP): return
    with activate(plugins(), 'events'):
        context.configurationsLoad(configurations())
        support.performEventsFor(app.DUMP)
        saveConfigurations(context.configurationsExtract())
예제 #15
0
def document():
    if not options.isFlag(FLAG_DOCUMENT): return
    with activate(plugins(), 'document'):
        context.processStart()
        createDocumentation()
예제 #16
0
def document():
    if not options.isFlag(FLAG_DOCUMENT): return
    with activate(plugins(), 'document'):
        context.processStart()
        createDocumentation()
예제 #17
0
def dumpPlugins():
    if not options.isFlag(FLAG_DUMP): return
    with activate(plugins(), 'events'):
        context.configurationsLoad(configurations())
        support.performEventsFor(app.DUMP)
        saveConfigurations(context.configurationsExtract())