def _execute_validation(self, working_dir): working_dir_path = str(working_dir.toAbsolutePath()) build_xml = self._project_validate_xml_template(working_dir_path) Files.write(working_dir.resolve("build.xml"), bytearray(str(build_xml))) process = Popen([self.ant_executable], stdout=PIPE, stderr=STDOUT, cwd=working_dir_path, env=self._get_env_properties(), universal_newlines=True) stdout_lines = iter(process.stdout.readline, "") for stdout_line in stdout_lines: yield stdout_line process.stdout.close() rc = process.wait() if rc != 0: raise CalledProcessError(rc, self.ant_executable)
def undeploy_package(self, zipped_package): working_dir, working_dir_path, undeploy_package_path = self._setup_working_dir() try: unzipped_package_path = Files.createDirectory(working_dir.resolve("undeploy_root")) self._extract_package(zipped_package, str(unzipped_package_path.toAbsolutePath())) package_xml_file = unzipped_package_path.resolve("package.xml") root = ET.parse(str(package_xml_file.toAbsolutePath())).getroot() ns = {'sf': 'http://soap.sforce.com/2006/04/metadata'} version = root.find('sf:version', ns).text Files.copy(package_xml_file, undeploy_package_path.resolve('destructiveChanges.xml')) Files.write(undeploy_package_path.resolve("package.xml"), bytearray(self.empty_package_template(version))) for output in self._execute(working_dir): print output finally: FileUtils.deleteDirectory(working_dir.toFile())
def write(filePath, vars, script): content = (vars + Strings.FileUtils_separator + script) Files.write(filePath, StringUtil.toBytes(content))