Exemplo n.º 1
0
def do_build():
	"""Runs build phase, building any modules that we've determined
	need building.
	"""
	shutit = shutit_global.shutit
	cfg = shutit.cfg
	shutit.log('PHASE: build, repository work', level=logging.DEBUG)
	module_id_list = shutit_util.module_ids()
	if shutit.build['deps_only']:
		module_id_list_build_only = filter(lambda x: cfg[x]['shutit.core.module.build'], module_id_list)
	for module_id in module_id_list:
		module = shutit.shutit_map[module_id]
		shutit.log('Considering whether to build: ' + module.module_id, level=logging.INFO)
		if cfg[module.module_id]['shutit.core.module.build']:
			if shutit.build['delivery'] not in module.ok_delivery_methods:
				shutit.fail('Module: ' + module.module_id + ' can only be built with one of these --delivery methods: ' + str(module.ok_delivery_methods) + '\nSee shutit build -h for more info, or try adding: --delivery <method> to your shutit invocation')
			if shutit_util.is_installed(module):
				shutit.build['report'] = (shutit.build['report'] + '\nBuilt already: ' + module.module_id + ' with run order: ' + str(module.run_order))
			else:
				# We move to the module directory to perform the build, returning immediately afterwards.
				if shutit.build['deps_only'] and module_id == module_id_list_build_only[-1]:
					# If this is the last module, and we are only building deps, stop here.
					shutit.build['report'] = (shutit.build['report'] + '\nSkipping: ' + module.module_id + ' with run order: ' + str(module.run_order) + '\n\tas this is the final module and we are building dependencies only')
				else:
					revert_dir = os.getcwd()
					shutit_global.shutit.get_current_shutit_pexpect_session_environment().module_root_dir = os.path.dirname(module.__module_file)
					shutit.chdir(shutit_global.shutit.get_current_shutit_pexpect_session_environment().module_root_dir)
					shutit.login(prompt_prefix=module_id,command='bash')
					build_module(module)
					shutit.logout()
					shutit.chdir(revert_dir)
		if shutit_util.is_installed(module):
			shutit.log('Starting module',level=logging.DEBUG)
			if not module.start(shutit):
				shutit.fail(module.module_id + ' failed on start', shutit_pexpect_child=shutit.get_shutit_pexpect_session_from_id('target_child').pexpect_child)
Exemplo n.º 2
0
def do_finalize():
    """Runs finalize phase; run after all builds are complete and all modules
	have been stopped.
	"""
    shutit = shutit_global.shutit
    # Stop all the modules
    if shutit.build['interactive'] >= 3:
        print('\nStopping all modules before finalize phase' +
              shutit_util.colourise('32', '\n\n[Hit return to continue]\n'))
        shutit_util.util_raw_input()
    stop_all()
    # Finalize in reverse order
    shutit.log('PHASE: finalize', level=logging.DEBUG)
    if shutit.build['interactive'] >= 3:
        print('\nNow doing finalize phase, which we do when all builds are ' +
              'complete and modules are stopped' +
              shutit_util.colourise('32', '\n\n[Hit return to continue]\n'))
        shutit_util.util_raw_input()
    # Login at least once to get the exports.
    for module_id in shutit_util.module_ids(rev=True):
        # Only finalize if it's thought to be installed.
        if shutit_util.is_installed(shutit.shutit_map[module_id]):
            shutit.login(prompt_prefix=module_id, command='bash')
            if not shutit.shutit_map[module_id].finalize(shutit):
                shutit.fail(module_id + ' failed on finalize',
                            shutit_pexpect_child=shutit.
                            get_shutit_pexpect_session_from_id(
                                'target_child').pexpect_child)
            shutit.logout()
Exemplo n.º 3
0
def do_test(shutit):
	"""Runs test phase, erroring if any return false.
	"""
	cfg = shutit.cfg
	if not cfg['build']['dotest']:
		shutit.log('Tests configured off, not running')
		return
	# Test in reverse order
	shutit.log('PHASE: test', code='32')
	if cfg['build']['interactive'] >= 3:
		print '\nNow doing test phase' + shutit_util.colour('32',
			'\n\n[Hit return to continue]\n')
		shutit_util.util_raw_input(shutit=shutit)
	stop_all(shutit)
	start_all(shutit)
	for module_id in shutit_util.module_ids(shutit, rev=True):
		module = shutit.shutit_map[module_id]
		# Only test if it's installed.
		if shutit_util.is_installed(shutit, shutit.shutit_map[module_id]):
			shutit.log('RUNNING TEST ON: ' + module_id, code='32')
			shutit.login(prompt_prefix=module_id,command='bash')
			if not shutit.shutit_map[module_id].test(shutit):
				shutit.fail(module_id + ' failed on test',
				child=shutit.pexpect_children['target_child'])
			shutit.logout()
Exemplo n.º 4
0
def do_test():
    """Runs test phase, erroring if any return false.
	"""
    shutit = shutit_global.shutit
    if not shutit.build['dotest']:
        shutit.log('Tests configured off, not running', level=logging.DEBUG)
        return
    # Test in reverse order
    shutit.log('PHASE: test', level=logging.DEBUG)
    if shutit.build['interactive'] >= 3:
        print '\nNow doing test phase' + shutit_util.colourise(
            '32', '\n\n[Hit return to continue]\n')
        shutit_util.util_raw_input()
    stop_all()
    start_all()
    for module_id in shutit_util.module_ids(rev=True):
        # Only test if it's installed.
        if shutit_util.is_installed(shutit.shutit_map[module_id]):
            shutit.log('RUNNING TEST ON: ' + module_id, level=logging.DEBUG)
            shutit.login(prompt_prefix=module_id, command='bash')
            if not shutit.shutit_map[module_id].test(shutit):
                shutit.fail(module_id + ' failed on test',
                            shutit_pexpect_child=shutit.
                            get_shutit_pexpect_session_from_id(
                                'target_child').pexpect_child)
            shutit.logout()
Exemplo n.º 5
0
def do_finalize(shutit):
	"""Runs finalize phase; run after all builds are complete and all modules
	have been stopped.
	"""
	cfg = shutit.cfg
	# Stop all the modules
	if cfg['build']['interactive'] >= 3:
		print('\nStopping all modules before finalize phase' + shutit_util.colour('32',
		      '\n\n[Hit return to continue]\n'))
		shutit_util.util_raw_input(shutit=shutit)
	stop_all(shutit)
	# Finalize in reverse order
	shutit.log('PHASE: finalize', code='32')
	if cfg['build']['interactive'] >= 3:
		print('\nNow doing finalize phase, which we do when all builds are ' +
		      'complete and modules are stopped' +
		      shutit_util.colour('32', '\n\n[Hit return to continue]\n'))
		shutit_util.util_raw_input(shutit=shutit)
	# Login at least once to get the exports.
	for module_id in shutit_util.module_ids(shutit, rev=True):
		# Only finalize if it's thought to be installed.
		if shutit_util.is_installed(shutit, shutit.shutit_map[module_id]):
			shutit.login(prompt_prefix=module_id,command='bash')
			if not shutit.shutit_map[module_id].finalize(shutit):
				shutit.fail(module_id + ' failed on finalize',
			                child=shutit.pexpect_children['target_child'])
			shutit.logout()
Exemplo n.º 6
0
def do_build(shutit):
	"""Runs build phase, building any modules that we've determined
	need building.
	"""
	cfg = shutit.cfg
	shutit.log('PHASE: build, repository work', code='32')
	shutit.log(shutit_util.print_config(cfg))
	if cfg['build']['interactive'] >= 3:
		print ('\nNow building any modules that need building' +
	 	       shutit_util.colour('32', '\n\n[Hit return to continue]\n'))
		shutit_util.util_raw_input(shutit=shutit)
	module_id_list = shutit_util.module_ids(shutit)
	if cfg['build']['deps_only']:
		module_id_list_build_only = filter(lambda x: cfg[x]['shutit.core.module.build'], module_id_list)
	for module_id in module_id_list:
		module = shutit.shutit_map[module_id]
		shutit.log('considering whether to build: ' + module.module_id,
		           code='32')
		if cfg[module.module_id]['shutit.core.module.build']:
			if cfg['build']['delivery'] not in module.ok_delivery_methods:
				shutit.fail('Module: ' + module.module_id + ' can only be built with one of these --delivery methods: ' + str(module.ok_delivery_methods) + '\nSee shutit build -h for more info, or try adding: --delivery <method> to your shutit invocation')
			if shutit_util.is_installed(shutit,module):
				cfg['build']['report'] = (cfg['build']['report'] +
				    '\nBuilt already: ' + module.module_id +
				    ' with run order: ' + str(module.run_order))
			else:
				# We move to the module directory to perform the build, returning immediately afterwards.
				if cfg['build']['deps_only'] and module_id == module_id_list_build_only[-1]:
					# If this is the last module, and we are only building deps, stop here.
					cfg['build']['report'] = (cfg['build']['report'] + '\nSkipping: ' +
					    module.module_id + ' with run order: ' + str(module.run_order) +
					    '\n\tas this is the final module and we are building dependencies only')
				else:
					revert_dir = os.getcwd()
					cfg['environment'][cfg['build']['current_environment_id']]['module_root_dir'] = os.path.dirname(module.__module_file)
					shutit.chdir(cfg['environment'][cfg['build']['current_environment_id']]['module_root_dir'])
					shutit.login(prompt_prefix=module_id,command='bash')
					build_module(shutit, module)
					shutit.logout()
					shutit.chdir(revert_dir)
		if shutit_util.is_installed(shutit, module):
			shutit.log('Starting module')
			if not module.start(shutit):
				shutit.fail(module.module_id + ' failed on start',
				    child=shutit.pexpect_children['target_child'])
Exemplo n.º 7
0
def stop_all(run_order=-1):
	"""Runs stop method on all modules less than the passed-in run_order.
	Used when target is exporting itself mid-build, so we clean up state
	before committing run files etc.
	"""
	shutit = shutit_global.shutit
	# sort them so they're stopped in reverse order
	for module_id in shutit_util.module_ids(rev=True):
		shutit_module_obj = shutit.shutit_map[module_id]
		if run_order == -1 or shutit_module_obj.run_order <= run_order:
			if shutit_util.is_installed(shutit_module_obj):
				if not shutit_module_obj.stop(shutit):
					shutit.fail('failed to stop: ' + module_id, shutit_pexpect_child=shutit.get_shutit_pexpect_session_from_id('target_child').shutit_pexpect_child)
Exemplo n.º 8
0
def start_all(run_order=-1):
	"""Runs start method on all modules less than the passed-in run_order.
	Used when target is exporting itself mid-build, so we can export a clean
	target and still depended-on modules running if necessary.
	"""
	shutit = shutit_global.shutit
	# sort them so they're started in order
	for module_id in shutit_util.module_ids():
		shutit_module_obj = shutit.shutit_map[module_id]
		if run_order == -1 or shutit_module_obj.run_order <= run_order:
			if shutit_util.is_installed(shutit_module_obj):
				if not shutit_module_obj.start(shutit):
					shutit.fail('failed to start: ' + module_id, shutit_pexpect_child=shutit.get_shutit_pexpect_session_from_id('target_child').shutit_pexpect_child)
Exemplo n.º 9
0
def start_all(run_order=-1):
	"""Runs start method on all modules less than the passed-in run_order.
	Used when target is exporting itself mid-build, so we can export a clean
	target and still depended-on modules running if necessary.
	"""
	shutit = shutit_global.shutit
	if shutit.build['interactive'] >= 3:
		print('\nRunning start on all modules' + shutit_util.colourise('32', '\n\n[Hit return to continue]\n'))
		shutit_util.util_raw_input()
	# sort them so they're started in order
	for module_id in shutit_util.module_ids():
		shutit_module_obj = shutit.shutit_map[module_id]
		if run_order == -1 or shutit_module_obj.run_order <= run_order:
			if shutit_util.is_installed(shutit_module_obj):
				if not shutit_module_obj.start(shutit):
					shutit.fail('failed to start: ' + module_id, shutit_pexpect_child=shutit.get_shutit_pexpect_session_from_id('target_child').shutit_pexpect_child)
Exemplo n.º 10
0
def stop_all(run_order=-1):
	"""Runs stop method on all modules less than the passed-in run_order.
	Used when target is exporting itself mid-build, so we clean up state
	before committing run files etc.
	"""
	shutit = shutit_global.shutit
	if shutit.build['interactive'] >= 3:
		print('\nRunning stop on all modules' + shutit_util.colourise('32', '\n\n[Hit return to continue]'))
		shutit_util.util_raw_input()
	# sort them so they're stopped in reverse order
	for module_id in shutit_util.module_ids(rev=True):
		shutit_module_obj = shutit.shutit_map[module_id]
		if run_order == -1 or shutit_module_obj.run_order <= run_order:
			if shutit_util.is_installed(shutit_module_obj):
				if not shutit_module_obj.stop(shutit):
					shutit.fail('failed to stop: ' + module_id, shutit_pexpect_child=shutit.get_shutit_pexpect_session_from_id('target_child').shutit_pexpect_child)
Exemplo n.º 11
0
def start_all(shutit, run_order=-1):
    """Runs start method on all modules less than the passed-in run_order.
	Used when target is exporting itself mid-build, so we can export a clean
	target and still depended-on modules running if necessary.
	"""
    # sort them so they're started in order
    for module_id in shutit_util.module_ids(shutit):
        shutit_module_obj = shutit.shutit_map[module_id]
        if run_order == -1 or shutit_module_obj.run_order <= run_order:
            if shutit_util.is_installed(shutit, shutit_module_obj):
                if not shutit_module_obj.start(shutit):
                    shutit.fail(
                        'failed to start: ' + module_id,
                        shutit_pexpect_child=shutit.
                        get_shutit_pexpect_session_from_id('target_child').
                        shutit_pexpect_child)  # pragma: no cover
Exemplo n.º 12
0
def stop_all(shutit, run_order=-1):
    """Runs stop method on all modules less than the passed-in run_order.
	Used when target is exporting itself mid-build, so we clean up state
	before committing run files etc.
	"""
    # sort them so they're stopped in reverse order
    for module_id in shutit_util.module_ids(shutit, rev=True):
        shutit_module_obj = shutit.shutit_map[module_id]
        if run_order == -1 or shutit_module_obj.run_order <= run_order:
            if shutit_util.is_installed(shutit, shutit_module_obj):
                if not shutit_module_obj.stop(shutit):
                    shutit.fail(
                        'failed to stop: ' + module_id,
                        shutit_pexpect_child=shutit.
                        get_shutit_pexpect_session_from_id('target_child').
                        shutit_pexpect_child)  # pragma: no cover
Exemplo n.º 13
0
def do_finalize():
	"""Runs finalize phase; run after all builds are complete and all modules
	have been stopped.
	"""
	shutit = shutit_global.shutit
	# Stop all the modules
	stop_all()
	# Finalize in reverse order
	shutit.log('PHASE: finalize', level=logging.DEBUG)
	# Login at least once to get the exports.
	for module_id in shutit_util.module_ids(rev=True):
		# Only finalize if it's thought to be installed.
		if shutit_util.is_installed(shutit.shutit_map[module_id]):
			shutit.login(prompt_prefix=module_id,command='bash')
			if not shutit.shutit_map[module_id].finalize(shutit):
				shutit.fail(module_id + ' failed on finalize', shutit_pexpect_child=shutit.get_shutit_pexpect_session_from_id('target_child').pexpect_child)
			shutit.logout()
Exemplo n.º 14
0
def stop_all(shutit, run_order=-1):
	"""Runs stop method on all modules less than the passed-in run_order.
	Used when target is exporting itself mid-build, so we clean up state
	before committing run files etc.
	"""
	cfg = shutit.cfg
	if cfg['build']['interactive'] >= 3:
		print('\nRunning stop on all modules' + \
			shutit_util.colour('32', '\n\n[Hit return to continue]'))
		shutit_util.util_raw_input(shutit=shutit)
	# sort them so they're stopped in reverse order
	for module_id in shutit_util.module_ids(shutit, rev=True):
		shutit_module_obj = shutit.shutit_map[module_id]
		if run_order == -1 or shutit_module_obj.run_order <= run_order:
			if shutit_util.is_installed(shutit, shutit_module_obj):
				if not shutit_module_obj.stop(shutit):
					shutit.fail('failed to stop: ' + \
						module_id, child=shutit.pexpect_children['target_child'])
Exemplo n.º 15
0
def check_ready(throw_error=True):
    """Check that all modules are ready to be built, calling check_ready on
	each of those configured to be built and not already installed
	(see shutit_util.is_installed).
	"""
    shutit = shutit_global.shutit
    cfg = shutit.cfg
    shutit.log('PHASE: check_ready', level=logging.DEBUG)
    errs = []
    shutit.pause_point(
        '\nNow checking whether we are ready to build modules configured to be built',
        print_input=False,
        level=3)
    # Find out who we are to see whether we need to log in and out or not.
    for module_id in shutit_util.module_ids():
        module = shutit.shutit_map[module_id]
        shutit.log('considering check_ready (is it ready to be built?): ' +
                   module_id,
                   level=logging.DEBUG)
        if cfg[module_id][
                'shutit.core.module.build'] and module.module_id not in shutit_global.shutit.get_current_shutit_pexpect_session_environment(
                ).modules_ready and not shutit_util.is_installed(module):
            shutit.log('checking whether module is ready to build: ' +
                       module_id,
                       level=logging.DEBUG)
            shutit.login(prompt_prefix=module_id,
                         command='bash --noprofile --norc',
                         echo=False)
            # Move to the correct directory (eg for checking for the existence of files needed for build)
            revert_dir = os.getcwd()
            shutit_global.shutit.get_current_shutit_pexpect_session_environment(
            ).module_root_dir = os.path.dirname(module.__module_file)
            shutit.chdir(shutit_global.
                         shutit.get_current_shutit_pexpect_session_environment(
                         ).module_root_dir)
            if not is_ready(module) and throw_error:
                errs.append((
                    module_id +
                    ' not ready to install.\nRead the check_ready function in the module,\nor log messages above to determine the issue.\n\n',
                    shutit.get_shutit_pexpect_session_from_id('target_child')))
            shutit.logout(echo=False)
            shutit.chdir(revert_dir)
    return errs
Exemplo n.º 16
0
def do_test():
	"""Runs test phase, erroring if any return false.
	"""
	shutit = shutit_global.shutit
	if not shutit.build['dotest']:
		shutit.log('Tests configured off, not running',level=logging.DEBUG)
		return
	# Test in reverse order
	shutit.log('PHASE: test', level=logging.DEBUG)
	stop_all()
	start_all()
	for module_id in shutit_util.module_ids(rev=True):
		# Only test if it's installed.
		if shutit_util.is_installed(shutit.shutit_map[module_id]):
			shutit.log('RUNNING TEST ON: ' + module_id, level=logging.DEBUG)
			shutit.login(prompt_prefix=module_id,command='bash')
			if not shutit.shutit_map[module_id].test(shutit):
				shutit.fail(module_id + ' failed on test', shutit_pexpect_child=shutit.get_shutit_pexpect_session_from_id('target_child').pexpect_child)
			shutit.logout()
Exemplo n.º 17
0
 def _finalize(shutit):
     # Stop all the modules
     stop_all(shutit)
     # Finalize in reverse order
     shutit.log('PHASE: finalizing object ' + str(shutit),
                level=logging.DEBUG)
     # Login at least once to get the exports.
     for module_id in shutit_util.module_ids(shutit, rev=True):
         # Only finalize if it's thought to be installed.
         if shutit_util.is_installed(shutit, shutit.shutit_map[module_id]):
             shutit.login(prompt_prefix=module_id,
                          command='bash --noprofile --norc',
                          echo=False)
             if not shutit.shutit_map[module_id].finalize(shutit):
                 shutit.fail(
                     module_id + ' failed on finalize',
                     shutit_pexpect_child=shutit.
                     get_shutit_pexpect_session_from_id(
                         'target_child').pexpect_child)  # pragma: no cover
             shutit.logout(echo=False)
Exemplo n.º 18
0
def stop_all(run_order=-1):
    """Runs stop method on all modules less than the passed-in run_order.
	Used when target is exporting itself mid-build, so we clean up state
	before committing run files etc.
	"""
    shutit = shutit_global.shutit
    if shutit.build['interactive'] >= 3:
        print('\nRunning stop on all modules' +
              shutit_util.colourise('32', '\n\n[Hit return to continue]'))
        shutit_util.util_raw_input()
    # sort them so they're stopped in reverse order
    for module_id in shutit_util.module_ids(rev=True):
        shutit_module_obj = shutit.shutit_map[module_id]
        if run_order == -1 or shutit_module_obj.run_order <= run_order:
            if shutit_util.is_installed(shutit_module_obj):
                if not shutit_module_obj.stop(shutit):
                    shutit.fail('failed to stop: ' + module_id,
                                shutit_pexpect_child=shutit.
                                get_shutit_pexpect_session_from_id(
                                    'target_child').shutit_pexpect_child)
Exemplo n.º 19
0
def start_all(run_order=-1):
    """Runs start method on all modules less than the passed-in run_order.
	Used when target is exporting itself mid-build, so we can export a clean
	target and still depended-on modules running if necessary.
	"""
    shutit = shutit_global.shutit
    if shutit.build['interactive'] >= 3:
        print('\nRunning start on all modules' +
              shutit_util.colourise('32', '\n\n[Hit return to continue]\n'))
        shutit_util.util_raw_input()
    # sort them so they're started in order
    for module_id in shutit_util.module_ids():
        shutit_module_obj = shutit.shutit_map[module_id]
        if run_order == -1 or shutit_module_obj.run_order <= run_order:
            if shutit_util.is_installed(shutit_module_obj):
                if not shutit_module_obj.start(shutit):
                    shutit.fail('failed to start: ' + module_id,
                                shutit_pexpect_child=shutit.
                                get_shutit_pexpect_session_from_id(
                                    'target_child').shutit_pexpect_child)
Exemplo n.º 20
0
def do_finalize():
    """Runs finalize phase; run after all builds are complete and all modules
	have been stopped.
	"""
    shutit = shutit_global.shutit
    # Stop all the modules
    stop_all()
    # Finalize in reverse order
    shutit.log('PHASE: finalize', level=logging.DEBUG)
    # Login at least once to get the exports.
    for module_id in shutit_util.module_ids(rev=True):
        # Only finalize if it's thought to be installed.
        if shutit_util.is_installed(shutit.shutit_map[module_id]):
            shutit.login(prompt_prefix=module_id,
                         command='bash --noprofile --norc',
                         echo=False)
            if not shutit.shutit_map[module_id].finalize(shutit):
                shutit.fail(module_id + ' failed on finalize',
                            shutit_pexpect_child=shutit.
                            get_shutit_pexpect_session_from_id(
                                'target_child').pexpect_child)
            shutit.logout(echo=False)
Exemplo n.º 21
0
def do_finalize():
	"""Runs finalize phase; run after all builds are complete and all modules
	have been stopped.
	"""
	shutit = shutit_global.shutit
	# Stop all the modules
	if shutit.build['interactive'] >= 3:
		print('\nStopping all modules before finalize phase' + shutit_util.colourise('32', '\n\n[Hit return to continue]\n'))
		shutit_util.util_raw_input()
	stop_all()
	# Finalize in reverse order
	shutit.log('PHASE: finalize', level=logging.DEBUG)
	if shutit.build['interactive'] >= 3:
		print('\nNow doing finalize phase, which we do when all builds are ' + 'complete and modules are stopped' + shutit_util.colourise('32', '\n\n[Hit return to continue]\n'))
		shutit_util.util_raw_input()
	# Login at least once to get the exports.
	for module_id in shutit_util.module_ids(rev=True):
		# Only finalize if it's thought to be installed.
		if shutit_util.is_installed(shutit.shutit_map[module_id]):
			shutit.login(prompt_prefix=module_id,command='bash')
			if not shutit.shutit_map[module_id].finalize(shutit):
				shutit.fail(module_id + ' failed on finalize', shutit_pexpect_child=shutit.get_shutit_pexpect_session_from_id('target_child').pexpect_child)
			shutit.logout()
Exemplo n.º 22
0
def do_test(shutit):
    """Runs test phase, erroring if any return false.
	"""
    if not shutit.build['dotest']:
        shutit.log('Tests configured off, not running', level=logging.DEBUG)
        return
    # Test in reverse order
    shutit.log('PHASE: test', level=logging.DEBUG)
    stop_all(shutit)
    start_all(shutit)
    for module_id in shutit_util.module_ids(shutit, rev=True):
        # Only test if it's installed.
        if shutit_util.is_installed(shutit, shutit.shutit_map[module_id]):
            shutit.log('RUNNING TEST ON: ' + module_id, level=logging.DEBUG)
            shutit.login(prompt_prefix=module_id,
                         command='bash --noprofile --norc',
                         echo=False)
            if not shutit.shutit_map[module_id].test(shutit):
                shutit.fail(
                    module_id + ' failed on test',
                    shutit_pexpect_child=shutit.
                    get_shutit_pexpect_session_from_id(
                        'target_child').pexpect_child)  # pragma: no cover
            shutit.logout(echo=False)
Exemplo n.º 23
0
def check_ready(throw_error=True):
	"""Check that all modules are ready to be built, calling check_ready on
	each of those configured to be built and not already installed
	(see shutit_util.is_installed).
	"""
	shutit = shutit_global.shutit
	cfg = shutit.cfg
	shutit.log('PHASE: check_ready', level=logging.DEBUG)
	errs = []
	shutit.pause_point('\nNow checking whether we are ready to build modules configured to be built', print_input=False, level=3)
	# Find out who we are to see whether we need to log in and out or not.
	for module_id in shutit_util.module_ids():
		module = shutit.shutit_map[module_id]
		shutit.log('considering check_ready (is it ready to be built?): ' + module_id, level=logging.DEBUG)
		if cfg[module_id]['shutit.core.module.build'] and module.module_id not in shutit_global.shutit.get_current_shutit_pexpect_session_environment().modules_ready and not shutit_util.is_installed(module):
			shutit.log('checking whether module is ready to build: ' + module_id, level=logging.DEBUG)
			shutit.login(prompt_prefix=module_id,command='bash')
			# Move to the correct directory (eg for checking for the existence of files needed for build)
			revert_dir = os.getcwd()
			shutit_global.shutit.get_current_shutit_pexpect_session_environment().module_root_dir = os.path.dirname(module.__module_file)
			shutit.chdir(shutit_global.shutit.get_current_shutit_pexpect_session_environment().module_root_dir)
			if not is_ready(module) and throw_error:
				errs.append((module_id + ' not ready to install.\nRead the check_ready function in the module,\nor log messages above to determine the issue.\n\n', shutit.get_shutit_pexpect_session_from_id('target_child')))
			shutit.logout()
			shutit.chdir(revert_dir)
	return errs
Exemplo n.º 24
0
def do_build():
    """Runs build phase, building any modules that we've determined
	need building.
	"""
    shutit = shutit_global.shutit
    cfg = shutit.cfg
    shutit.log('PHASE: build, repository work', level=logging.DEBUG)
    if shutit.build['interactive'] >= 3:
        print('\nNow building any modules that need building' +
              shutit_util.colourise('32', '\n\n[Hit return to continue]\n'))
        shutit_util.util_raw_input()
    module_id_list = shutit_util.module_ids()
    if shutit.build['deps_only']:
        module_id_list_build_only = filter(
            lambda x: cfg[x]['shutit.core.module.build'], module_id_list)
    for module_id in module_id_list:
        module = shutit.shutit_map[module_id]
        shutit.log('Considering whether to build: ' + module.module_id,
                   level=logging.INFO)
        if cfg[module.module_id]['shutit.core.module.build']:
            if shutit.build['delivery'] not in module.ok_delivery_methods:
                shutit.fail(
                    'Module: ' + module.module_id +
                    ' can only be built with one of these --delivery methods: '
                    + str(module.ok_delivery_methods) +
                    '\nSee shutit build -h for more info, or try adding: --delivery <method> to your shutit invocation'
                )
            if shutit_util.is_installed(module):
                shutit.build['report'] = (shutit.build['report'] +
                                          '\nBuilt already: ' +
                                          module.module_id +
                                          ' with run order: ' +
                                          str(module.run_order))
            else:
                # We move to the module directory to perform the build, returning immediately afterwards.
                if shutit.build[
                        'deps_only'] and module_id == module_id_list_build_only[
                            -1]:
                    # If this is the last module, and we are only building deps, stop here.
                    shutit.build['report'] = (
                        shutit.build['report'] + '\nSkipping: ' +
                        module.module_id + ' with run order: ' +
                        str(module.run_order) +
                        '\n\tas this is the final module and we are building dependencies only'
                    )
                else:
                    revert_dir = os.getcwd()
                    shutit_global.shutit.get_current_shutit_pexpect_session_environment(
                    ).module_root_dir = os.path.dirname(module.__module_file)
                    shutit.chdir(
                        shutit_global.
                        shutit.get_current_shutit_pexpect_session_environment(
                        ).module_root_dir)
                    shutit.login(prompt_prefix=module_id, command='bash')
                    build_module(module)
                    shutit.logout()
                    shutit.chdir(revert_dir)
        if shutit_util.is_installed(module):
            shutit.log('Starting module', level=logging.DEBUG)
            if not module.start(shutit):
                shutit.fail(module.module_id + ' failed on start',
                            shutit_pexpect_child=shutit.
                            get_shutit_pexpect_session_from_id(
                                'target_child').pexpect_child)
Exemplo n.º 25
0
def check_ready(shutit, throw_error=True):
	"""Check that all modules are ready to be built, calling check_ready on
	each of those configured to be built and not already installed
	(see shutit_util.is_installed).
	"""
	cfg = shutit.cfg
	shutit.log('PHASE: check_ready', code='32')
	errs = []
	shutit.pause_point('\nNow checking whether we are ready to build modules' + 
	                   ' configured to be built',
	                   print_input=False, level=3)
	# Find out who we are to see whether we need to log in and out or not. 
	for module_id in shutit_util.module_ids(shutit):
		module = shutit.shutit_map[module_id]
		shutit.log('considering check_ready (is it ready to be built?): ' +
		           module_id, code='32')
		if cfg[module_id]['shutit.core.module.build'] and module.module_id not in cfg['environment'][cfg['build']['current_environment_id']]['modules_ready'] and not shutit_util.is_installed(shutit,module):
			shutit.log('checking whether module is ready to build: ' + module_id,
			           code='32')
			shutit.login(prompt_prefix=module_id,command='bash')
			# Move to the directory so context is correct (eg for checking for
			# the existence of files needed for build)
			revert_dir = os.getcwd()
			cfg['environment'][cfg['build']['current_environment_id']]['module_root_dir'] = os.path.dirname(module.__module_file)
			shutit.chdir(cfg['environment'][cfg['build']['current_environment_id']]['module_root_dir'])
			if not is_ready(shutit, module) and throw_error:
				errs.append((module_id + ' not ready to install.\nRead the ' +
				            'check_ready function in the module,\nor log ' + 
				            'messages above to determine the issue.\n\n',
				            shutit.pexpect_children['target_child']))
			shutit.logout()
			shutit.chdir(revert_dir)
	return errs