def build(): emojize = bootstrap() clean_up(('build', 'dist')) success = execute_command('pipenv lock') if success: LOGGER.info('Successfully created lock file %s %s', emojize(':white_heavy_check_mark:'), emojize(':thumbs_up:')) else: LOGGER.error('%s Errors creating lock file! %s', emojize(':cross_mark:'), emojize(':crying_face:')) raise SystemExit(1) save_requirements() for file in BUILD_REQUIRED_FILES: shutil.copy(file, os.path.join(f'{PROJECT_SLUG}', file)) success = execute_command('python setup.py sdist bdist_egg') if success: LOGGER.info('%s Successfully built artifact %s', emojize(':white_heavy_check_mark:'), emojize(':thumbs_up:')) else: LOGGER.error('%s Errors building artifact! %s', emojize(':cross_mark:'), emojize(':crying_face:')) clean_up([ os.path.join(f'{PROJECT_SLUG}', file) for file in BUILD_REQUIRED_FILES ]) return emojize if success else None
def test(): emojize = bootstrap() clean_up('test-output') os.mkdir('test-output') # exit_code = execute_command('pipenv lock') # success = not exit_code # if success: # LOGGER.info('Successfully created lock file %s', # emojize(':white_heavy_check_mark:'), # emojize(':thumbs_up:')) # else: # LOGGER.error('%s Errors creating lock file! %s', # emojize(':cross_mark:'), # emojize(':crying_face:')) # raise SystemExit(1) save_requirements() exit_code = execute_command('tox') success = not exit_code if success: open_file(os.path.join('test-output', 'coverage', 'index.html')) sleep(0.5) open_file(os.path.join('test-output', 'nosetests.html')) LOGGER.info('%s No testing errors found! %s', emojize(':white_heavy_check_mark:'), emojize(':thumbs_up:')) else: LOGGER.error('%s Testing errors found! %s', emojize(':cross_mark:'), emojize(':crying_face:')) raise SystemExit(exit_code)
def build(): emojize = bootstrap() clean_up(('build', 'dist')) # exit_code = execute_command('pipenv lock') # success = not exit_code # if success: # LOGGER.info('Successfully created lock file %s', # emojize(':white_heavy_check_mark:'), # emojize(':thumbs_up:')) # else: # LOGGER.error('%s Errors creating lock file! %s', # emojize(':cross_mark:'), # emojize(':crying_face:')) # raise SystemExit(1) save_requirements() for file in BUILD_REQUIRED_FILES: shutil.copy(file, os.path.join('{{cookiecutter.project_slug}}', file)) exit_code = execute_command('python setup.py sdist bdist_egg') success = not exit_code if success: LOGGER.info('%s Successfully built artifact %s', emojize(':white_heavy_check_mark:'), emojize(':thumbs_up:')) else: LOGGER.error('%s Errors building artifact! %s', emojize(':cross_mark:'), emojize(':crying_face:')) clean_up([ os.path.join('pythonlibproject', file) for file in BUILD_REQUIRED_FILES ]) return emojize if success else None
def reset(environment_variables): pipfile_path = environment_variables.get('PIPENV_PIPFILE', 'Pipfile') venv = os.path.join(get_project_root_path(), os.path.dirname(pipfile_path), '.venv') try: clean_up(venv) print(f'Successfully removed venv {venv}') except Exception as e: print(e) print(f'Unable to remove venv, make sure {venv} exists.')
def apply_patches(patches, project): for diff_patch in patches: print( f'Interpolating project name "{project.name}" in patch {diff_patch}' ) patch_file = get_interpolated_temp_patch_file(diff_patch, project.name) success = apply_patch(patch_file, project.parent_directory_full_path) print(f'Removing temporary file "{patch_file}"') clean_up(patch_file) if success: print(f'Successfully applied patch {diff_patch}') else: print(f'Failed applying patch {diff_patch}') raise PatchFailure(diff_patch)
def document(): emojize = bootstrap() clean_up( ('_build', os.path.join('docs', '_build'), os.path.join('docs', 'test_docs.rst'), os.path.join('docs', 'modules.rst'))) exit_code = execute_command('make -C docs html') success = not exit_code if success: shutil.move(os.path.join('docs', '_build'), '_build') path = os.path.join('_build', 'html', 'index.html') open_file(path) LOGGER.info('%s Successfully built documentation %s', emojize(':white_heavy_check_mark:'), emojize(':thumbs_up:')) else: LOGGER.error('%s Documentation creation errors found! %s', emojize(':cross_mark:'), emojize(':crying_face:')) raise SystemExit(exit_code)
def test(): bootstrap() clean_up('test-output') os.mkdir('test-output') save_requirements() success = execute_command('tox') try: open_file(os.path.join('test-output', 'coverage', 'index.html')) sleep(0.5) open_file(os.path.join('test-output', 'nosetests.html')) except Exception: LOGGER.warning('Could not execute UI portion. Maybe running headless?') if success: LOGGER.info('%s No testing errors found! %s', emojize(':white_heavy_check_mark:'), emojize(':thumbs_up:')) else: LOGGER.error('%s Testing errors found! %s', emojize(':cross_mark:'), emojize(':crying_face:')) raise SystemExit(0 if success else 1)
def document(): emojize = bootstrap() clean_up(('_build', os.path.join('docs', '_build'), os.path.join('docs', 'test_docs.rst'), os.path.join('docs', 'modules.rst'))) success = execute_command('make -C docs html') if success: shutil.move(os.path.join('docs', '_build'), '_build') try: open_file(os.path.join('_build', 'html', 'index.html')) except Exception: LOGGER.warning('Could not execute UI portion. Maybe running headless?') LOGGER.info('%s Successfully built documentation %s', emojize(':white_heavy_check_mark:'), emojize(':thumbs_up:')) else: LOGGER.error('%s Documentation creation errors found! %s', emojize(':cross_mark:'), emojize(':crying_face:')) raise SystemExit(0 if success else 1)
def reset(environment_variables): pipfile_path = environment_variables.get('PIPENV_PIPFILE', 'Pipfile') venv = os.path.join(get_project_root_path(), os.path.dirname(pipfile_path), '.venv') clean_up(venv)