def installer_exists(self, platform): """ <Purpose> Checks if the given installer already exists. Returns True if it does, False otherwise. <Arguments> platform: A string representing the installer to check. For example, "linux". <Exceptions> None. <Side Effects> None. <Returns> A boolean value. """ validations.validate_platform(platform) installer_filename = os.path.join( settings.CUSTOM_INSTALLER_ROOT, self.build_id, constants.PLATFORM_BUNDLES[platform] ) if os.path.isfile(installer_filename): return True return False
def package(self, platform): """ <Purpose> Constructs an installer for the given platform, assuming a vesselinfo file already exists. <Arguments> None. <Exceptions> ValidationError if the vesselinfo file does not already exist. <Side Effects> The installer will be written to disk. <Returns> Nothing. """ # Validate the platform. validations.validate_platform(platform) # Get the name of our build directory, and select a temporary directory to # perform our work in. build_dir = self.get_build_directory() temp_dir = tempfile.mkdtemp() # Copy the existing vesselinfo file into place. source_vesselinfo_fn = os.path.join(build_dir, 'vesselinfo') destination_vesselinfo_fn = os.path.join(temp_dir, 'vesselinfo') if not os.path.isfile(source_vesselinfo_fn): raise validations.ValidationError( 'There is no vesselinfo file for the given build ID.') shutil.copy(source_vesselinfo_fn, destination_vesselinfo_fn) # Create packages for the requested installers. packager.package_installers(temp_dir, [platform]) # Move each file in the temporary directory to the destination directory. for file_to_move in os.listdir(temp_dir): source_filename = os.path.abspath( os.path.join(temp_dir, file_to_move)) destination_filename = os.path.abspath( os.path.join(build_dir, file_to_move)) shutil.move(source_filename, destination_filename) # Remove the temporary directory. shutil.rmtree(temp_dir)
def package(self, platform): """ <Purpose> Constructs an installer for the given platform, assuming a vesselinfo file already exists. <Arguments> None. <Exceptions> ValidationError if the vesselinfo file does not already exist. <Side Effects> The installer will be written to disk. <Returns> Nothing. """ # Validate the platform. validations.validate_platform(platform) # Get the name of our build directory, and select a temporary directory to # perform our work in. build_dir = self.get_build_directory() temp_dir = tempfile.mkdtemp() # Copy the existing vesselinfo file into place. source_vesselinfo_fn = os.path.join(build_dir, 'vesselinfo') destination_vesselinfo_fn = os.path.join(temp_dir, 'vesselinfo') if not os.path.isfile(source_vesselinfo_fn): raise validations.ValidationError('There is no vesselinfo file for the given build ID.') shutil.copy(source_vesselinfo_fn, destination_vesselinfo_fn) # Create packages for the requested installers. packager.package_installers(temp_dir, [platform]) # Move each file in the temporary directory to the destination directory. for file_to_move in os.listdir(temp_dir): source_filename = os.path.abspath(os.path.join(temp_dir, file_to_move)) destination_filename = os.path.abspath(os.path.join(build_dir, file_to_move)) shutil.move(source_filename, destination_filename) # Remove the temporary directory. shutil.rmtree(temp_dir)