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)
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
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()
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)
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()
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)
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)
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)
def repairEvents(): with activate(plugins(), 'repair'): triggerEvents(app.REPAIR)
def startEvents(): with activate(plugins(), 'events'): triggerEvents(app.DEPLOY, app.POPULATE)
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
def dumpPlugins(): if not options.isFlag(FLAG_DUMP): return with activate(plugins(), 'events'): context.configurationsLoad(configurations()) support.performEventsFor(app.DUMP) saveConfigurations(context.configurationsExtract())
def document(): if not options.isFlag(FLAG_DOCUMENT): return with activate(plugins(), 'document'): context.processStart() createDocumentation()