def copy_file(source, target): if sys.platform.startswith('win'): source = cp.winapi_path(source) target = cp.winapi_path(target) shutil.copy(source, target) else: shutil.copy(source, target)
def replace_file(source, destination): """Replace source file to the destination """ logger.info('Replacing files from:' + str(source) + " to: " + str(destination)) if sys.platform.startswith('win'): source = cp.winapi_path(source) destination = cp.winapi_path(destination) shutil.move(source, destination)
def copy_file(source, target): """Copy the source file to the target. """ if sys.platform.startswith('win'): source = cp.winapi_path(source) target = cp.winapi_path(target) shutil.copy(source, target) else: shutil.copy(source, target)
def copy_file(source, target): """Copy the source file to the target. """ try: if sys.platform.startswith('win'): source = cp.winapi_path(source) target = cp.winapi_path(target) if os.path.isdir(source): shutil.copytree(source, target, ignore=ignore_dirs((IGNORE_DIR_TYPES[product_id]))) else: shutil.copy(source, target) except OSError as e: print('Directory not copied. Error: %s' % e)
def get_product_name(): global product_name global product_zip_name dist_pom_path = Path(workspace + "/" + product_id + "/" + DIST_POM_PATH[product_id]) if sys.platform.startswith('win'): dist_pom_path = cp.winapi_path(dist_pom_path) ET.register_namespace('', NS['d']) artifact_tree = ET.parse(dist_pom_path) artifact_root = artifact_tree.getroot() parent = artifact_root.find('d:parent', NS) artifact_id = artifact_root.find('d:artifactId', NS) version = parent.find('d:version', NS) product_name = artifact_id.text + "-" + version.text product_zip_name = product_name + ".zip" return product_name
def get_dist_name(): """Get the product name by reading distribution pom. """ global dist_name global dist_zip_name global product_version dist_pom_path = Path(workspace + "/" + product_id + "/" + DIST_POM_PATH[product_id]) if sys.platform.startswith('win'): dist_pom_path = cp.winapi_path(dist_pom_path) ET.register_namespace('', NS['d']) artifact_tree = ET.parse(dist_pom_path) artifact_root = artifact_tree.getroot() parent = artifact_root.find('d:parent', NS) artifact_id = artifact_root.find('d:artifactId', NS).text product_version = parent.find('d:version', NS).text dist_name = artifact_id + "-" + product_version dist_zip_name = dist_name + ZIP_FILE_EXTENSION return dist_name