コード例 #1
0
ファイル: __init__.py プロジェクト: agriffis/StrangeCase
        def wrapper():
            project_path = get_test_file(project_name)
            deploy_path = join(project_path, 'public')
            config_file_path = join(project_path, 'config.yaml')

            if os.path.exists(deploy_path):
                shutil.rmtree(deploy_path)
            config = CONFIG.copy(all=True)

            config['project_path'] = project_path
            config['site_path'] = join(project_path, 'site')
            config['deploy_path'] = join(project_path, 'public')

            if os.path.exists(config_file_path):
                with open(config_file_path, 'r') as config_file:
                    yaml_config = yaml.load(config_file)
                    config.update(yaml_config)

            old_path = os.getcwd()
            try:
                os.chdir(project_path)
                ret = fn(config)
            except Exception:
                tree(config['site_path'], config['project_path'])
                tree(config['deploy_path'], config['project_path'])
                raise
            finally:
                os.chdir(old_path)
            shutil.rmtree(deploy_path)
            return ret
コード例 #2
0
ファイル: __init__.py プロジェクト: colinta/StrangeCase
        def wrapper(**ignore):
            project_path = get_test_file(project_name)
            deploy_path = join(project_path, 'public')
            config_file_path = join(project_path, 'config.yaml')

            if os.path.exists(deploy_path):
                shutil.rmtree(deploy_path)
            config = CONFIG.copy(all=True)

            config['project_path'] = project_path
            config['site_path'] = join(project_path, 'site')
            config['deploy_path'] = join(project_path, 'public')

            if os.path.exists(config_file_path):
                with open(config_file_path, 'r') as config_file:
                    yaml_config = yaml.load(config_file, Loader=yaml.FullLoader)
                    config.update(yaml_config)

            old_path = os.getcwd()
            try:
                os.chdir(project_path)
                ret = fn(config)
            except Exception:
                tree(config['site_path'], config['project_path'])
                tree(config['deploy_path'], config['project_path'])
                raise
            finally:
                os.chdir(old_path)
            shutil.rmtree(deploy_path)
            return ret