Beispiel #1
0
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))
Beispiel #2
0
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))
Beispiel #3
0
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))
Beispiel #4
0
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))