示例#1
0
def setup_module_dir(variant, options):
    log = logging.getLogger('ksl.installer')

    variant_modules_dir = os.path.join(options.root_module_dir, variant.target_arch, variant.name)
    if not os.path.exists(variant_modules_dir):
        log.info("creating empty directory %s" % variant_modules_dir)
        os.makedirs(variant_modules_dir)

    module_name = variant.version+variant.tag
 
    if variant.tag == "":
        version_file = os.path.join(variant_modules_dir,'.version')
        if os.path.exists(version_file):
            if not options.force:
                print("Can I clobber module default version file %s? [y/n]: " % version_file)
                confirmation = getch()
                if confirmation != 'y':
                    raise Exception(
                        "unwilling to clobber version file %s" % version_file)
            log.info("deleting version file %s" % version_file)
            os.remove(version_file)

        log.info("setting default module version for %s on %s to %s " %
                 (variant.name, variant.target_arch, variant.version))
        file_handle = open(version_file, 'w')
        file_handle.write('#%%Module1.0\nset ModulesVersion "%s"\n' % variant.version)
        file_handle.close()
    else:
        log.info("installing non-default variant to module %s" % module_name)
        
    variant.module_file = os.path.join(variant_modules_dir, module_name)
示例#2
0
def clobber_dir(variant, clobber_dir, options):
    log = logging.getLogger('ksl.installer')
        
    if os.path.exists(clobber_dir):
        if not options.force:
            print("Can I clobber directory %s? [y/n]: " % clobber_dir)
            confirmation = getch()
            if confirmation != 'y':
                raise Exception(
                    "unwilling to clobber directory %s" % clobber_dir)
        log.info("clobbering directory %s" %  clobber_dir)
        shutil.rmtree(clobber_dir)

    log.info("creating empty directory %s" % clobber_dir)
    os.makedirs(clobber_dir)