def _bundle_images(images_directory, zip_file): """Bundle the images directory :param images_directory: path to the images directory :type images_directory: str :param zip_file: zip file object :type zip_file: zipfile.ZipFile :rtype: None """ for filename in sorted(os.listdir(images_directory)): fullpath = os.path.join(images_directory, filename) if (filename == 'icon-small.png' or filename == 'icon-medium.png' or filename == 'icon-large.png'): util.validate_png(fullpath) zip_file.write(fullpath, arcname='images/{}'.format(filename)) elif filename == 'screenshots' and os.path.isdir(fullpath): _bundle_screenshots(fullpath, zip_file) else: # anything else is an error raise DCOSException( ('Error bundling package. Extra file in package ' 'directory [{}]').format(fullpath))
def _bundle_screenshots(screenshot_directory, zip_file): """Bundle the screenshots directory :param screenshot_directory: path to the screenshots directory :type screenshot_directory: str :param zip_file: zip file object :type zip_file: zipfile.ZipFile :rtype: None """ for filename in sorted(os.listdir(screenshot_directory)): fullpath = os.path.join(screenshot_directory, filename) util.validate_png(fullpath) zip_file.write(fullpath, arcname='images/screenshots/{}'.format(filename))
def _bundle_screenshots(screenshot_directory, zip_file): """Bundle the screenshots directory :param screenshot_directory: path to the screenshots directory :type screenshot_directory: str :param zip_file: zip file object :type zip_file: zipfile.ZipFile :rtype: None """ for filename in sorted(os.listdir(screenshot_directory)): fullpath = os.path.join(screenshot_directory, filename) util.validate_png(fullpath) zip_file.write( fullpath, arcname='images/screenshots/{}'.format(filename))