Пример #1
0
def theme_update(path=None, safe=False):
    conf.load(path)

    if safe:
        logger.info('saving current theme')
        assets_bak = "%s.bak" % pathes.theme_assets_installed()
        templates_bak = "%s.bak" % pathes.theme_templates_installed()
        try:
            for path in [templates_bak, assets_bak]:
                if os.path.isdir(path):
                    shutil.rmtree(path, ignore_errors=True)
            shutil.move(pathes.theme_assets_installed(), assets_bak)
            shutil.move(pathes.theme_templates_installed(), templates_bak)
        except Exception as e:
            logger.error('error saving existing theme files: ' + str(e))
            return

    logger.info('updating theme files')
    try:
        path = pathes.theme_assets_source()
        helpers.copydir(path, pathes.theme_assets_installed())
        path = pathes.theme_templates_source()
        helpers.copydir(path, pathes.theme_templates_installed())
    except Exception as e:
        logger.error('error updating theme: ' + str(e))
Пример #2
0
def init(path=None, force=False):
    """Create new website."""
    conf.generate(path, force)
    try:
        src = pathes.proto()
        existing = helpers.copydir(src, pathes.site(), force=force)
        if len(existing):
            message = "some existing files were overwritten" if force else \
                "some existing files were NOT overwritten (use --force " \
                "to overwrite)"
            logger.warn("%s\n- %s" % (message, '\n- '.join(existing)))
        logger.info('website created successfully, have fun!')
    except Exception as ex:
        logger.error('initialization failed: ' + str(ex))
        print(str(ex))