def _start_from_binary(self): assets_target_path = self.context.get_microservice_target_path(self.service_name) assets_path = self.context.application.workspace + self.service_data["location"] force_chdir(assets_path) remove_if_exists("RUNNING_FROM") force_chdir(assets_target_path) if not self.context.offline: nexus = SmNexus(self.context, self.service_name) if self.version: versions = [ self.version ] elif self.context.assets_versions: versions = self.context.assets_versions self.log("Starting assets versions: %s" % (", ".join(versions))) else: versions = nexus.get_all_versions(self.run_from) for version in versions: nexus.download_jar_if_necessary(self.run_from, version) self._unzip_assets(versions) cmd_with_params = self.service_data["binary"]["cmd"] makedirs_if_not_exists("logs") with open("logs/stdout.txt", "wb") as out, open("logs/stderr.txt", "wb") as err: return subprocess.Popen(cmd_with_params[0].split(), shell=False, env=os.environ.copy(), stdout=out, stderr=err, close_fds=True).pid
def download_jar_if_necessary(self, run_from, version): artifact = self.context.service_data(self.service_name)["binary"]["artifact"] groupId = self.context.service_data(self.service_name)["binary"]["groupId"] repo_mappings = self.context.config_value("bintray")["repoMappings"] repositoryId = repo_mappings[run_from] if not version: version = self.find_latest_version(run_from, artifact, groupId) if version: localFilename = artifact + ".tgz" bintrayFilename = artifact + "-" + str(version) + ".tgz" bintrayFilePath = groupId + artifact + "/" + str(version) + "/" + bintrayFilename bintrayMD5FilePath = bintrayFilePath + ".md5" microservice_target_path = self.context.get_microservice_target_path(self.service_name) downloaded_artifact_path = microservice_target_path + localFilename downloaded_md5_path = microservice_target_path + localFilename + ".md5" # first download the md5 file in order to determine if new artifact download is required self._download_from_bintray(bintrayMD5FilePath, downloaded_md5_path, repositoryId, False) bintray_md5 = open(downloaded_md5_path, 'r').read() local_md5 = SmNexus._md5_if_exists(downloaded_artifact_path) if local_md5 != bintray_md5: remove_if_exists(downloaded_artifact_path) self.context.log("Downloading Bintray binary for '" + self.service_name + "': " + bintrayFilename) self._download_from_bintray(bintrayFilePath, downloaded_artifact_path, repositoryId, self.context.show_progress) os.remove(downloaded_md5_path) else: print b.warning + "WARNING: Due to lack of version data from Bintray you may not have an up to date version..." + b.endc
def download_jar_if_necessary(self, run_from, version): binary = self.context.service_data(self.service_name)["binary"] nexus_host = self.context.application.nexus_repo_host artifact = binary["artifact"] group_id = binary["groupId"] filename = self.context.get_jar_filename(self.service_name, run_from) microservice_target_path = self.context.get_microservice_target_path( self.service_name) repo_mappings = self.context.config_value("nexus")["repoMappings"] if run_from == "RELEASE": url_type_repository = repo_mappings["RELEASE"] else: url_type_repository = repo_mappings["SNAPSHOT"] if not version: version = self.find_latest_version(run_from, artifact, group_id) if version: nexus_extension = self._create_nexus_extension() nexus_filename = artifact + "-" + version + nexus_extension md5_filename = nexus_filename + ".md5" nexus_url = (nexus_host + binary["nexus"] + url_type_repository + "/" + group_id + artifact + "/" + version + "/") # first download the md5 file in order to determine if new artifact download is required self._download_from_nexus(nexus_url + md5_filename, microservice_target_path + md5_filename, False) if self.service_type == "assets": if (self._md5_if_exists(microservice_target_path + nexus_filename) != open(microservice_target_path + md5_filename, "r").read()): remove_if_exists(microservice_target_path + filename) self.context.log("Downloading Nexus binary for '" + self.service_name + "': " + nexus_filename) self._download_from_nexus( nexus_url + nexus_filename, nexus_filename, self.context.show_progress, ) else: if (self._md5_if_exists(microservice_target_path + filename) != open(microservice_target_path + md5_filename, "r").read()): remove_if_exists(microservice_target_path + filename) self.context.log("Downloading Nexus binary for '" + self.service_name + "': " + nexus_filename) self._download_from_nexus(nexus_url + nexus_filename, filename, self.context.show_progress) os.remove(microservice_target_path + md5_filename) else: print( b.warning + "WARNING: Due to lack of version data from nexus you may not have an up to date version..." + b.endc)
def _start_from_binary(self): assets_target_path = self.context.get_microservice_target_path( self.service_name) assets_path = self.context.application.workspace + self.service_data[ "location"] force_chdir(assets_path) remove_if_exists("RUNNING_FROM") force_chdir(assets_target_path) if not self.context.offline: nexus = SmNexus(self.context, self.service_name) versions = nexus.get_all_versions(self.version, self.run_from) for version in versions: nexus.download_jar_if_necessary(self.run_from, version) self._unzip_assets(versions) cmd_with_params = self.service_data["binary"]["cmd"] makedirs_if_not_exists("logs") with open("logs/stdout.txt", "wb") as out, open("logs/stderr.txt", "wb") as err: return subprocess.Popen(cmd_with_params[0].split(), shell=False, env=os.environ.copy(), stdout=out, stderr=err, close_fds=True).pid
def download_jar_if_necessary(self, run_from, version): binary_config = self.context.service_data(self.service_name)["binary"] artifact = binary_config["artifact"] groupId = binary_config["groupId"] repo_mappings = self.context.config_value( "artifactory")["repoMappings"] repositoryId = repo_mappings[run_from] if not version: version = self.find_latest_version(run_from, artifact, groupId) if version: extension = "." + binary_config.get("ext", "tgz") localFilename = artifact + extension if self.service_type == "assets": localFilename = artifact + "-" + str(version) + extension artifactoryFilename = artifact + "-" + str(version) + extension artifactoryFilePath = groupId + artifact + "/" + str( version) + "/" + artifactoryFilename artifactoryMD5FilePath = artifactoryFilePath + ".md5" microservice_target_path = self.context.get_microservice_target_path( self.service_name) downloaded_artifact_path = microservice_target_path + localFilename downloaded_md5_path = microservice_target_path + localFilename + ".md5" # first download the md5 file in order to determine if new artifact download is required self._download_from_artifactory(artifactoryMD5FilePath, downloaded_md5_path, repositoryId, False) artifactory_md5 = open(downloaded_md5_path, 'r').read() local_md5 = SmNexus._md5_if_exists(downloaded_artifact_path) if local_md5 != artifactory_md5: remove_if_exists(downloaded_artifact_path) self.context.log( "Downloading Artifactory binary for '" + self.service_name + "': " + artifactoryFilename, True) self._download_from_artifactory(artifactoryFilePath, downloaded_artifact_path, repositoryId, self.context.show_progress) else: self.context.log( "Skipped download of %s. The local copy matches the one on Artifactory" % artifactoryFilename, True) os.remove(downloaded_md5_path) return artifactoryFilename else: print b.warning + "WARNING: Due to lack of version data from Artifactory you may not have an up to date version..." + b.endc
def _start_from_binary(self): assets_target_path = self.context.get_microservice_target_path( self.service_name) assets_path = self.context.application.workspace + self.service_data[ "location"] force_chdir(assets_path) remove_if_exists("RUNNING_FROM") force_chdir(assets_target_path) if not self.context.offline: artifactory = SmArtifactory(self.context, self.service_name) if self.version: versions = [self.version] elif self.context.assets_versions: versions = self.context.assets_versions self.log( "Starting assets versions: %s" % (", ".join(versions)), True) else: versions = artifactory.find_all_versions(self.run_from) self.log( "Starting assets versions: %s" % (", ".join(versions)), True) for version in versions: self.context.log("\nStarting assets version: %s" % version) artifactory.download_jar_if_necessary(self.run_from, version) self._unzip_assets(versions) cmd_with_params = self.service_data["binary"]["cmd"] if _is_python_3(): py3cmd = self.service_data["binary"].get("py3_cmd") if py3cmd is not None: cmd_with_params = py3cmd self.log("starting %s..." % cmd_with_params) makedirs_if_not_exists("logs") with open("logs/stdout.txt", "wb") as out, open("logs/stderr.txt", "wb") as err: return subprocess.Popen( cmd_with_params[0].split(), shell=False, env=os.environ.copy(), stdout=out, stderr=err, close_fds=True, universal_newlines=True, ).pid
def download_jar_if_necessary(self, run_from, version): binary_config = self.context.service_data(self.service_name)["binary"] artifact = binary_config["artifact"] groupId = binary_config["groupId"] repo_mappings = self.context.config_value("artifactory")["repoMappings"] repositoryId = repo_mappings[run_from] if not version: version = self.find_latest_version(run_from, artifact, groupId) if version: extension = "." + binary_config.get("ext", "tgz") localFilename = artifact + extension if self.service_type == "assets": localFilename = artifact + "-" + str(version) + extension artifactoryFilename = artifact + "-" + str(version) + extension artifactoryFilePath = groupId + artifact + "/" + str(version) + "/" + artifactoryFilename artifactoryMD5FilePath = artifactoryFilePath + ".md5" microservice_target_path = self.context.get_microservice_target_path(self.service_name) downloaded_artifact_path = microservice_target_path + localFilename downloaded_md5_path = microservice_target_path + localFilename + ".md5" # first download the md5 file in order to determine if new artifact download is required self._download_from_artifactory(artifactoryMD5FilePath, downloaded_md5_path, repositoryId, False) artifactory_md5 = open(downloaded_md5_path, 'r').read() local_md5 = SmNexus._md5_if_exists(downloaded_artifact_path) if local_md5 != artifactory_md5: remove_if_exists(downloaded_artifact_path) self.context.log("Downloading Artifactory binary for '" + self.service_name + "': " + artifactoryFilename, True) self._download_from_artifactory(artifactoryFilePath, downloaded_artifact_path, repositoryId, self.context.show_progress) else: self.context.log("Skipped download of %s. The local copy matches the one on Artifactory" % artifactoryFilename, True) os.remove(downloaded_md5_path) return artifactoryFilename else: print b.warning + "WARNING: Due to lack of version data from Artifactory you may not have an up to date version..." + b.endc
def download_jar_if_necessary(self, run_from, version): binary = self.context.service_data(self.service_name)["binary"] nexus_host = self.context.application.nexus_repo_host artifact = binary["artifact"] group_id = binary["groupId"] filename = self.context.get_jar_filename(self.service_name, run_from) microservice_target_path = self.context.get_microservice_target_path(self.service_name) repo_mappings = self.context.config_value("nexus")["repoMappings"] if run_from == "RELEASE": url_type_repository = repo_mappings["RELEASE"] else: url_type_repository = repo_mappings["SNAPSHOT"] if not version: version = self.find_latest_version(run_from, artifact, group_id) if version: nexus_extension = self._create_nexus_extension() nexus_filename = artifact + "-" + version + nexus_extension md5_filename = nexus_filename + ".md5" nexus_url = nexus_host + binary["nexus"] + url_type_repository + "/" + group_id + artifact + "/" + version + "/" # first download the md5 file in order to determine if new artifact download is required self._download_from_nexus(nexus_url + md5_filename, microservice_target_path + md5_filename, False) if self.service_type == "assets": if self._md5_if_exists(microservice_target_path + nexus_filename) != open(microservice_target_path + md5_filename, 'r').read(): remove_if_exists(microservice_target_path + filename) self.context.log("Downloading Nexus binary for '" + self.service_name + "': " + nexus_filename) self._download_from_nexus(nexus_url + nexus_filename, nexus_filename, self.context.show_progress) else: if self._md5_if_exists(microservice_target_path + filename) != open(microservice_target_path + md5_filename, 'r').read(): remove_if_exists(microservice_target_path + filename) self.context.log("Downloading Nexus binary for '" + self.service_name + "': " + nexus_filename) self._download_from_nexus(nexus_url + nexus_filename, filename, self.context.show_progress) os.remove(microservice_target_path + md5_filename) else: print b.warning + "WARNING: Due to lack of version data from nexus you may not have an up to date version..." + b.endc