Ejemplo n.º 1
0
def create_directory_structure(expand, remove=None, create=None,copy=None,link=None, dry_run=False):
    """Creates a subdirectory structure, and copies, moves, and links in files
    
    Arguments:
        expand  -- a single-argument function to perform any string substitutions on any of the input arguments
        create  -- a list of subdirectories to create if they don't already exists
        remove  -- a list of file patterns to remove
        copy    -- a list of file patterns to copy
        link    -- a list of file patterns to link
        dry_run -- log rather than execute commands 

    """        
    # pass initial time as an argument, to leave a one-argument function which will expand strings

    logger = loghelper.get(LOGGER)
    if create:
        for d in create:
            subdir = expand(d)
            shared.create(subdir, dry_run=dry_run)

    if remove:
        for pattern in remove:
            shared.remove(expand(pattern), dry_run=dry_run)

    if copy:
        for pattern in copy:
            shared.copy(expand(pattern), dry_run=dry_run)
            
    if link:
        for pattern in link:
            shared.link(expand(pattern), dry_run=dry_run)
Ejemplo n.º 2
0
def main():
    # merge command-line and file-specified arguments
    config = conf.config(__doc__, sys.argv[1:])
    logger = loghelper.create(LOGGER,
                              log_level=config.get('log.level'),
                              log_fmt=config.get('log.format'),
                              log_file=config.get('log.file'))

    base_dir = config['base_dir']
    wrftools_dir = config['wrftools_dir']
    dry_run = config.get('dry_run')
    jobs = config.get('jobs')
    create = config.get('initialise.create')
    remove = config.get('initialise.remove')
    copy = config.get('initialise.copy')
    link = config.get('initialise.link')

    if create:
        for d in create:
            shared.create(d, dry_run=dry_run)

    if remove:
        for pattern in remove:
            shared.remove(pattern, dry_run=dry_run)

    if copy:
        for pattern in copy:
            shared.copy(pattern, dry_run=dry_run)

    if link:
        for pattern in link:
            shared.link(pattern, dry_run=dry_run)

    logger.debug("init.py done")
    print("\n\n")
    print("************************************************")
    print(NEXT_STEPS % (base_dir, base_dir))
    print("************************************************")
Ejemplo n.º 3
0
def main():
    # merge command-line and file-specified arguments
    config = conf.config(__doc__, sys.argv[1:])
    logger = loghelper.create(LOGGER, log_level=config.get('log.level'), log_fmt=config.get('log.format'), log_file=config.get('log.file'))
    
    
    base_dir = config['base_dir']
    wrftools_dir = config['wrftools_dir']
    dry_run = config.get('dry_run')
    jobs = config.get('jobs')
    create = config.get('initialise.create')
    remove = config.get('initialise.remove')
    copy = config.get('initialise.copy')
    link = config.get('initialise.link')
    
    if create:
        for d in create:
            shared.create(d, dry_run=dry_run)

    if remove:
        for pattern in remove:
            shared.remove(pattern, dry_run=dry_run)

    if copy:
        for pattern in copy:
            shared.copy(pattern, dry_run=dry_run)
            
    if link:
        for pattern in link:
            shared.link(pattern, dry_run=dry_run)

    logger.debug("init.py done")
    print("\n\n")
    print("************************************************")
    print(NEXT_STEPS % (base_dir,base_dir))
    print("************************************************")