コード例 #1
0
def CreateIndex(buildName, targetDir):
    """Generates a <buildName>_index.html page from the hint files that hardhat creates
    which contain the actual distro filenames"""

    html = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">\n'
    html += '<html><head>\n'
    html += '<link rel="Stylesheet" href="http://builds.osafoundation.org/tinderbox/OSAF.css" type="text/css" charset="iso-8859-1">\n'
    html += '<title>Downloads for Chandler Build: ' + buildName + '</title>\n'
    html += '</head><body<img src="http://builds.osafoundation.org/tinderbox/OSAFLogo.gif" alt="[OSAF Logo]">\n'
    html += '<h2>Chandler Build: ' + buildName + '</h2>\n'
    files = os.listdir(os.path.join("/home/builder/snapshots", targetDir))
    for thisFile in files:
        fileName = os.path.join("/home/builder/snapshots", targetDir, thisFile)
        urlPath = os.path.join("/chandler/snapshots", targetDir, thisFile)
        if fileName.find("_src_") > 0:
            print "Generating data for ", thisFile
            html += '<strong style="font-size: larger;">'
            html += '<a href="' + thisFile + '">' + thisFile + '</a>'
            html += ' (' + hardhatutil.fileSize(fileName) + ')</strong>\n'
            html += '<p>Source code.</p>'
            html += ' MD5 checksum: ' + hardhatutil.MD5sum(fileName) + '<br>'
            html += ' SHA checksum: ' + hardhatutil.SHAsum(fileName) + '<br>'
            html += '\n<hr>\n'
        elif fileName.find("Chan") > 0:
            print "Generating data for ", thisFile
            html += '<strong style="font-size: larger;">'
            html += '<a href="' + thisFile + '">' + thisFile + '</a>'
            html += ' (' + hardhatutil.fileSize(fileName) + ')</strong>\n'
            if fileName.find("_debug_") > 0:
                html += '<p>' + _descriptions['developer'][1] + '</p>'
            else:
                html += '<p>' + _descriptions['enduser'][1] + '</p>'
            html += ' MD5 checksum: ' + hardhatutil.MD5sum(fileName) + '<br>'
            html += ' SHA checksum: ' + hardhatutil.SHAsum(fileName) + '<br>'
            html += '\n<hr>\n'
        else:
            print "skipping ", thisFile

    html += '</body></html>\n'

    fileOut = file(buildName + "_index.html", "w")
    fileOut.write(html)
    fileOut.close()

    shutil.move(fileOut.name, os.path.join("snapshots", targetDir,
                                           fileOut.name))
コード例 #2
0
ファイル: distIndex.py プロジェクト: HackLinux/chandler-1
def CreateIndex(buildName, targetDir):
    """Generates a <buildName>_index.html page from the hint files that hardhat creates
    which contain the actual distro filenames"""

    html =  '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">\n'
    html += '<html><head>\n'
    html += '<link rel="Stylesheet" href="http://builds.osafoundation.org/tinderbox/OSAF.css" type="text/css" charset="iso-8859-1">\n'
    html += '<title>Downloads for Chandler Build: ' + buildName + '</title>\n'
    html += '</head><body<img src="http://builds.osafoundation.org/tinderbox/OSAFLogo.gif" alt="[OSAF Logo]">\n'
    html += '<h2>Chandler Build: ' + buildName + '</h2>\n'
    files = os.listdir(os.path.join("/home/builder/snapshots", targetDir))
    for thisFile in files:
        fileName = os.path.join("/home/builder/snapshots", targetDir, thisFile)
        urlPath = os.path.join("/chandler/snapshots", targetDir, thisFile)
        if fileName.find("_src_") > 0:
            print "Generating data for ", thisFile
            html += '<strong style="font-size: larger;">'
            html += '<a href="' + thisFile + '">' + thisFile + '</a>'
            html += ' (' + hardhatutil.fileSize(fileName) + ')</strong>\n'
            html += '<p>Source code.</p>'
            html += ' MD5 checksum: ' + hardhatutil.MD5sum(fileName) + '<br>'
            html += ' SHA checksum: ' + hardhatutil.SHAsum(fileName) + '<br>'
            html += '\n<hr>\n'
        elif fileName.find("Chan") > 0:
            print "Generating data for ", thisFile
            html += '<strong style="font-size: larger;">'            
            html += '<a href="' + thisFile + '">' + thisFile + '</a>'
            html += ' (' + hardhatutil.fileSize(fileName) + ')</strong>\n'
            if fileName.find("_debug_") > 0:
                html += '<p>' + _descriptions['developer'][1] + '</p>'
            else:
                html += '<p>' + _descriptions['enduser'][1] + '</p>'
            html += ' MD5 checksum: ' + hardhatutil.MD5sum(fileName) + '<br>'
            html += ' SHA checksum: ' + hardhatutil.SHAsum(fileName) + '<br>'
            html += '\n<hr>\n'
        else:
            print "skipping ", thisFile

    html += '</body></html>\n'
    
    fileOut = file(buildName+"_index.html", "w")    
    fileOut.write(html)
    fileOut.close()

    shutil.move(fileOut.name, os.path.join("snapshots", targetDir, fileOut.name))
コード例 #3
0
def CreateIndex(treeName, outputDir, newDirName, nowString, buildName):
    """
    Generates HTML files that contain links and hash information
    for downloadable files.
    """

    newPrefix = outputDir + os.sep + newDirName + os.sep

    head1 = '<html>\n<head>\n' +\
            '<META HTTP-EQUIV="Pragma" CONTENT="no-cache">\n' +\
            '<title>Download %s %s %s </title>\n' % (treeName, buildName, newDirName) +\
            '<link rel="Stylesheet" ' +\
            'href="http://www.osafoundation.org/css/OSAF.css" ' +\
            'type="text/css" charset="iso-8859-1">\n'
    head2 = '</head>\n' +\
            '<body>\n' +\
            '<img src="http://www.osafoundation.org/images/OSAFLogo.gif" ' + 'alt="[OSAF Logo]">\n' +\
            '<h2>Chandler Build: ' + nowString + ' PDT (machine: ' + buildName + ')</h2>\n'
    cryptoblurb = '<p>This software is subject to the U.S. Export ' +\
                  'Administration Regulations and other U.S. law, and may ' +\
                  'not be exported or re-exported to certain countries ' +\
                  '(currently Cuba, Iran, Libya, North Korea, Sudan and ' +\
                  'Syria) or to persons or entities prohibited from ' +\
                  'receiving U.S. exports (including Denied Parties, ' +\
                  'Specially Designated Nationals, and entities on the ' +\
                  'Bureau of Industry and Security Entity List or involved ' +\
                  'with missile technology or nuclear, chemical or ' +\
                  'biological weapons).</p>\n'
    index = head1 + head2 + cryptoblurb

    userInstall = None
    userTarball = None
    devInstall  = None
    devTarball  = None

    for distro in ('enduser', 'developer'):
        distroFile = os.path.join(outputDir, newDirName, distro)
        if os.path.exists(distroFile):
            lines = _readFile(distroFile)

            for line in lines:
                actualDistroFile = line.strip()
                actualDistro     = os.path.join(outputDir, newDirName, actualDistroFile)

                distroExt = os.path.splitext(actualDistroFile)[1]

                if _instructions.has_key(distroExt):
                    distroType = _instructions[distroExt][0]
                else:
                    raise MissingFileError, ('Unknown distribution extension: %s' % distroExt)

                if distroType == 'tarball':
                    if distro == 'enduser':
                        userTarball = (actualDistroFile, actualDistro, _instructions[distroExt][1])
                    else:
                        devTarball  = (actualDistroFile, actualDistro, _instructions[distroExt][1])
                else:
                    if distro == 'developer':
                        devInstall  = (actualDistroFile, actualDistro, _instructions[distroExt][1])
                    else:
                        userInstall = (actualDistroFile, actualDistro, _instructions[distroExt][1])

    if userInstall:
        index += '<h3>End-User Installer</h3>\n' +\
                 '<p>If you just want to use Chandler, then this is the file to download.<br/>\n' +\
                 userInstall[2] + '</p>\n'

        index += '<p><a href="%s">%s</a> (%s)<br/>\n' % \
                    (userInstall[0], userInstall[0], hardhatutil.fileSize(userInstall[1]))
        index += 'MD5 checksum: %s<br/>\nSHA checksum: %s</p>\n' % \
                    (hardhatutil.MD5sum(userInstall[1]), hardhatutil.SHAsum(userInstall[1]))

    if devInstall:
        index += '<h3>Developer Installer</h3>\n' +\
                 "<p>If you're a developer and want to run Chandler in debugging mode, " +\
                 'this distribution contains debug versions of the binaries.  ' +\
                 'Assertions are active, the __debug__ global is set to True, ' +\
                 'and memory leaks are listed upon exit.  You can also use this ' +\
                 'distribution to develop your own parcels (See ' +\
                 '<a href="http://wiki.osafoundation.org/bin/view/Chandler/ParcelLoading">Parcel Loading</a> ' +\
                 'for details on loading your own parcels).<br/>\n' +\
                 devInstall[2] + '</p>\n'

        index += '<p><a href="%s">%s</a> (%s)<br/>\n' % \
                    (devInstall[0], devInstall[0], hardhatutil.fileSize(devInstall[1]))
        index += 'MD5 checksum: %s<br/>\nSHA checksum: %s</p>\n' % \
                    (hardhatutil.MD5sum(actualDistro), hardhatutil.SHAsum(devInstall[1]))

    if userTarball or devTarball:
        index += '<h3>Compressed Install Images</h3>\n' +\
                 '<p>The End-User and Developer compressed images contain a snapshot of Chandler.\n' +\
                 'Use these if you cannot or do not want to use the installers.</p>\n'

        if userTarball:
            index += '<p>End-Users: <a href="%s">%s</a> (%s): %s<br/>\n' % \
                        (userTarball[0], userTarball[0], hardhatutil.fileSize(userTarball[1]), userTarball[2])
            index += 'MD5 checksum: %s<br/>\nSHA checksum: %s</p>\n' % \
                        (hardhatutil.MD5sum(userTarball[1]), hardhatutil.SHAsum(userTarball[1]))

        if devTarball:
            index += '<p>Developers: <a href="%s">%s</a> (%s): %s<br/>\n' % \
                        (devTarball[0], devTarball[0], hardhatutil.fileSize(devTarball[1]), devTarball[2])
            index += 'MD5 checksum: %s<br/>\nSHA checksum: %s</p>\n' % \
                        (hardhatutil.MD5sum(devTarball[1]), hardhatutil.SHAsum(devTarball[1]))

    index += '</body></html>\n'

    fileOut = file(newPrefix + "index.html", "w")
    fileOut.write(index)
    fileOut.close()

    fileOut = file(outputDir + os.sep + "latest.html", "w")
    fileOut.write(head1 +\
                  '<meta http-equiv="refresh" content="0;URL=' + newDirName + '">\n' +\
                  head2 +\
                  '<h2>Latest Continuous ' + buildName + ' Build</h2>\n' +\
                  '<a href="' + newDirName + '">' + newDirName + '</a>\n' +\
                  '</body></html>\n')
    fileOut.close()

    # This file is used by:
    # - http://builds.osafoundation.org/index.html
    # - http://wiki.osafoundation.org/bin/view/Chandler/GettingChandler
    fileOut = file(outputDir+os.sep+"time.js", "w")
    fileOut.write("document.write('" + nowString + "');\n")
    fileOut.close()