Ejemplo n.º 1
0
def dump(config, savedir, symlink=False):
    if 'active' in config and config['active'] in ('false', 'off', '0'):
        return

    if 'src' in config:
        src = config['src']
    else:
        src = config['dir']

    if 'ignore' in config:
        ignore = ignore_patterns(
            *[p.strip() for p in config['ignore'].split(',')])
    else:
        ignore = None

    run_hook('pre-create-code', [config['project'], src],
             logger=logger,
             exit_on_error=True)

    makedirs_silent(savedir)
    dest = os.path.join(savedir, config['project'])
    if symlink:
        logger.info("symlink '%(src)s' to '%(dest)s'" % {
            'src': src,
            'dest': dest
        })
        symlink_silent(src, dest)
    else:
        logger.info("copy '%(src)s' to '%(dest)s'" % {
            'src': src,
            'dest': dest
        })
        copytree(src, dest, symlinks=True, ignore=ignore)

    run_hook('post-create-code', [config['project'], src], logger=logger)
Ejemplo n.º 2
0
def restore(config, srcdir):
    if 'dest' in config:
        dest = config['dest']
    else:
        dest = config['dir']

    srcdir = os.path.join(srcdir, config['project'])
    if os.path.exists(srcdir):
        run_hook('pre-restore-code', [config['project'], dest], logger=logger)

        logger.info("deleting '%(dest)s'" % {'dest': dest})
        rmtree_silent(dest)
        os.makedirs(dest)

        logger.info("copying '%(src)s' to '%(dest)s'" % {
            'src': srcdir,
            'dest': dest
        })
        copytree(srcdir, dest, symlinks=True, keepdst=True)

        run_hook('post-restore-code', [config['project'], dest], logger=logger)

        return dest
    else:
        logger.debug("'%(srcdir)s' don't exists, no code to restore" %
                     {'srcdir': srcdir})
        return None
Ejemplo n.º 3
0
def dump(config, savedir, symlink=False):
    if 'active' in config and config['active'] in ('false', 'off', '0'):
        return

    if 'src' in config:
        src = config['src']
    else:
        src = config['dir']

    if 'ignore' in config:
        ignore = ignore_patterns(*[p.strip() for p in config['ignore'].split(',')])
    else:
        ignore = None

    run_hook('pre-create-code', [config['project'], src], logger=logger, exit_on_error=True)

    makedirs_silent(savedir)
    dest = os.path.join(savedir, config['project'])
    if symlink:
        logger.info("symlink '%(src)s' to '%(dest)s'" % {'src': src, 'dest': dest})
        symlink_silent(src, dest)
    else:
        logger.info("copy '%(src)s' to '%(dest)s'" % {'src': src, 'dest': dest})
        copytree(src, dest, symlinks=True, ignore=ignore)

    run_hook('post-create-code', [config['project'], src], logger=logger)
Ejemplo n.º 4
0
def dump(config, savedir, symlink=False):
    if 'active' in config and config['active'] in ('false', 'off', '0'):
        return

    dirs = get_dirs(config['dirs'])

    if 'ignore' in config:
        ignore = ignore_patterns(*[p.strip() for p in config['ignore'].split(',')])
    else:
        ignore = None

    for src in dirs:
        if src.startswith('/'):
            dest = os.path.join(savedir, src[1:])
            if src.endswith('/'):
                dest = dest[:-1]
        else:
            logger.error("'%s' is not an absolute path" % src)
            sys.exit(1)

        if symlink:
            makedirs_silent(os.path.dirname(dest))
            logger.info("symlink '%(src)s' to '%(dest)s'" % {'src': src, 'dest': dest})
            symlink_silent(src, dest)
        else:
            logger.info("copying '%(src)s' to '%(dest)s'" % {'src': src, 'dest': dest})
            copytree(src, dest, symlinks=True, ignore=ignore, update_rights=True)
Ejemplo n.º 5
0
def restore(config, srcdir):
    if not os.path.exists(srcdir):
        logger.debug("'%(srcdir)s' don't exists, no files to restore" % {'srcdir': srcdir})
        return

    run_hook('pre-restore-files', logger=logger)

    for dest in get_dirs(config['dirs']):
        logger.info("deleting '%(dest)s'" % {'dest': dest})
        rmtree_silent(dest)

        # first '/' removed in second arg
        src = os.path.join(srcdir, dest[1:])

        logger.info("copying '%(src)s' to '%(dest)s'" % {'src': src, 'dest': dest})
        copytree(src, dest, symlinks=True)

    run_hook('post-restore-files', logger=logger)
Ejemplo n.º 6
0
def restore(config, srcdir):
    if 'dest' in config:
        dest = config['dest']
    else:
        dest = config['dir']

    srcdir = os.path.join(srcdir, config['project'])
    if os.path.exists(srcdir):
        run_hook('pre-restore-code', [config['project'], dest], logger=logger)

        logger.info("deleting '%(dest)s'" % {'dest': dest})
        rmtree_silent(dest)
        os.makedirs(dest)

        logger.info("copying '%(src)s' to '%(dest)s'" % {'src': srcdir, 'dest': dest})
        copytree(srcdir, dest, symlinks=True, keepdst=True)

        run_hook('post-restore-code', [config['project'], dest], logger=logger)

        return dest
    else:
        logger.debug("'%(srcdir)s' don't exists, no code to restore" % {'srcdir': srcdir})
        return None
Ejemplo n.º 7
0
def copy_hooks(hooks, dest):
    logger.debug("copy hooks from '%(hooks)s' to '%(dest)s'" % {'hooks': hooks, 'dest': dest})
    copytree(hooks, os.path.join(dest, basename(hooks)), ignore=ignore_patterns('.svn'))
Ejemplo n.º 8
0
def copy_hooks(hooks, dest):
    logger.debug("copy hooks from '%(hooks)s' to '%(dest)s'" % {"hooks": hooks, "dest": dest})
    copytree(hooks, os.path.join(dest, basename(hooks)), ignore=ignore_patterns(".svn"))