コード例 #1
0
ファイル: qmis_html.py プロジェクト: modgethanc/qmis
def html_one(datafile, itemID):
    unit = []

    item = core.get_by_id(datafile, itemID)[itemID]
    links = item.get("links")

    subclass = item.get("subcat")
    if subclass == "35mm":
        subclass = "thirtyfive"

    unit.append("<div class=\"item\"><div class=\""+subclass+"\"><a name=\""+itemID+"\"></a>")
    unit.append("\n\t<p><b>"+core.display_name(item)+"</b></p>") 

    unit.append("\n\t<p><small><i>"+core.display_cat(item)+"</i></small></p>")

    if links:
        linktext = "\n\t<p>bundled with: "
        if item.get("cat") == core.categories[9]:
            linktext = "\n\t<p>kit contents: "
        #unit.append("\n\t<p>bundled with: ")
        unit.append(linktext)
        for x in links:
            unit.append("<a href=\"#"+x+"\">"+core.display_name(core.get_by_id(datafile, x)[x])+"</a> ")
        unit.append("</p>")

    unit.append("\n\t<p align=\"right\"><small>"+colored_status(item)+"</small></p>")
    unit.append("\n\t<div class=\"meta\"><p><small>"+itemID+" "+str(item)+"</small></p></div>")

    unit.append("\n</div></div>\n")

    return "".join(unit)
コード例 #2
0
def html_one(datafile, itemID):
    unit = []

    item = core.get_by_id(datafile, itemID)[itemID]
    links = item.get("links")

    subclass = item.get("subcat")
    if subclass == "35mm":
        subclass = "thirtyfive"

    unit.append("<div class=\"item\"><div class=\"" + subclass +
                "\"><a name=\"" + itemID + "\"></a>")
    unit.append("\n\t<p><b>" + core.display_name(item) + "</b></p>")

    unit.append("\n\t<p><small><i>" + core.display_cat(item) +
                "</i></small></p>")

    if links:
        linktext = "\n\t<p>bundled with: "
        if item.get("cat") == core.categories[9]:
            linktext = "\n\t<p>kit contents: "
        #unit.append("\n\t<p>bundled with: ")
        unit.append(linktext)
        for x in links:
            unit.append("<a href=\"#" + x + "\">" +
                        core.display_name(core.get_by_id(datafile, x)[x]) +
                        "</a> ")
        unit.append("</p>")

    unit.append("\n\t<p align=\"right\"><small>" + colored_status(item) +
                "</small></p>")
    unit.append("\n\t<div class=\"meta\"><p><small>" + itemID + " " +
                str(item) + "</small></p></div>")

    unit.append("\n</div></div>\n")

    return "".join(unit)
コード例 #3
0
def sortable(datafile):
    outfile = open(BASEDIR + "/www/inventory.html", "w+")
    done = 0
    total = 0

    outfile.write(
        "<html><head>\n<title>QMIS OUTPUT TEST</title>\n<script src=\"sorttable.js\"></script>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\" /></link>\n</head>\n<body>"
    )
    outfile.write(
        "<p>this file is automatically generated from QMIS. do not take it too seriously right now.</p>\n\n"
    )
    outfile.write("<p><i>last updated:<br>" + time.strftime("%d %b %Y, %H%M") +
                  "</i></p>\n")
    outfile.write("<div class=\"dataset\">\n<table class=\"sortable\">")
    outfile.write(
        "<th>Name</th><th>Make</th><th>Model</th><th>Category</th><th>S/N</th><th>CMU ID</th><th>Links</th><th>Last Updated</th><th>ID</th>\n"
    )

    for itemID in datafile:
        total += 1
        item = core.get_by_id(datafile, itemID)[itemID]

        outfile.write("<tr style=\"color:" + status_color(item) + "\"><td>")
        outfile.write(core.display_name(item) + "</td><td>")
        #outfile.write(str(item.get("name"))+"</td><td>")
        outfile.write(str(item.get("make")) + "</td><td>")
        outfile.write(str(item.get("model")) + "</td><td>")
        outfile.write(core.display_cat(item) + "</td><td>")
        #outfile.write(str(item.get("cat"))+"</td><td>")
        #outfile.write(str(item.get("subcat"))+"</td><td>")
        outfile.write(str(item.get("serial")) + "</td><td>")
        outfile.write(str(item.get("cmu")) + "</td><td>")

        links = item.get("links")
        if links:
            for ID in links:
                outfile.write(
                    "<a href=\"#" + ID + "\">" +
                    core.display_name(core.get_by_id(datafile, ID)[ID]) +
                    "</a> ")
        else:
            outfile.write(" ")
        outfile.write("</td><td>")
        timestamp = item.get("last updated")
        color = "<font color=red>"
        if isinstance(timestamp, float):
            ## set this for closing mode
            if timestamp > 1494350400:
                color = "<font color=green>"
                #if item.get("status") not in nocount:
                if item.get("status") in closing:
                    done += 1
            #timestamp = time.strftime("%Y-%m-%d:%H%M", time.localtime(timestamp))

        # comment this for closing check
        color = ""
        #

        if item.get("status") not in closing:
            #if item.get("status") in nocount:
            total -= 1
        outfile.write(color + str(timestamp) + "</font></td><td>")
        outfile.write("<font color=black>" + str(itemID) +
                      "</font><a name=\"" + itemID + "\"></a></td>")
        outfile.write("</tr>\n")

    outfile.write("</table>")

    completion = int(100 * float(done) / float(total))
    # (for closing check only
    #outfile.write("<div style=\"float:right; position:absolute;top:0em; right:.5em;\"><p>"+str(done)+"/"+str(total)+" ("+str(completion)+"%)</div>")
    outfile.write("<p> </p>")
    outfile.write("<p> </p>")
    outfile.write("<p> </p>")
    outfile.write("<p> </p>")
    outfile.write("<p> </p>")
    outfile.write("<p> </p>")
    outfile.write("<p> </p>")
    outfile.write("<p> </p>")
    outfile.write("<p> </p>")
    outfile.write("<p> </p>")
    outfile.write("<p> </p>")
    outfile.write("<p> </p>")
    outfile.write("<p> </p>")
    outfile.write("<p> </p>")
    outfile.write("<p> </p>")
    outfile.write("<p> </p>")
    outfile.write("<p> </p>")
    outfile.write("</body></html>")
    outfile.close()

    print_status(done, total, completion)
コード例 #4
0
ファイル: qmis_html.py プロジェクト: modgethanc/qmis
def sortable(datafile):
    outfile = open("/home/hvincent/projects/qmis/bin/www/test_sort.html", "w+")
    done = 0
    total = 0

    outfile.write("<html><head>\n<title>QMIS OUTPUT TEST</title>\n<script src=\"sorttable.js\"></script>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\" /></link>\n</head>\n<body>")
    outfile.write("<p>this file is automatically generated from QMIS. do not take it too seriously right now.</p>\n\n")
    outfile.write("<p><i>last updated:<br>"+time.strftime("%d %b %Y, %H%M")+"</i></p>\n")
    outfile.write("<div class=\"dataset\">\n<table class=\"sortable\">")
    outfile.write("<th>Name</th><th>Make</th><th>Model</th><th>Category</th><th>S/N</th><th>CMU ID</th><th>Links</th><th>Last Updated</th><th>ID</th>\n")

    for itemID in datafile:
        total += 1
        item = core.get_by_id(datafile, itemID)[itemID]

        outfile.write("<tr style=\"color:"+status_color(item)+"\"><td>")
        outfile.write(core.display_name(item)+"</td><td>")
        #outfile.write(str(item.get("name"))+"</td><td>")
        outfile.write(str(item.get("make"))+"</td><td>")
        outfile.write(str(item.get("model"))+"</td><td>")
        outfile.write(core.display_cat(item)+"</td><td>")
        #outfile.write(str(item.get("cat"))+"</td><td>")
        #outfile.write(str(item.get("subcat"))+"</td><td>")
        outfile.write(str(item.get("serial"))+"</td><td>")
        outfile.write(str(item.get("cmu"))+"</td><td>")

        links = item.get("links")
        if links:
            for ID in links:
                outfile.write("<a href=\"#"+ID+"\">"+core.display_name(core.get_by_id(datafile,ID)[ID])+"</a> ")
        else:
            outfile.write(" ")
        outfile.write("</td><td>")
        timestamp = item.get("last updated")
        color = "<font color=red>"
        if isinstance(timestamp, float):
            if timestamp > 1462398232:
                color = "<font color=green>"
                if item.get("status") not in nocount:
                    done += 1

        # comment this for closing check
        color = ""
        #

        if item.get("status") in nocount:
            total -= 1
        #outfile.write(color+core.display_last_checked(item)+"</font></td><td>")
        outfile.write(color+str(timestamp)+"</font></td><td>")
        #outfile.write(str(item.get("last updated"))+"</td><td>")
        outfile.write("<font color=black>"+str(itemID)+"</font><a name=\""+itemID+"\"></a></td>")
        outfile.write("</tr>\n")

    outfile.write("</table>")

    completion = int(100*float(done)/float(total))
    # (for closing check only
    # outfile.write("<div style=\"float:right; position:absolute;top:0em; right:.5em;\"><p>"+str(done)+"/"+str(total)+" ("+str(completion)+"%)</div>")
    outfile.write("<p> </p>")
    outfile.write("<p> </p>")
    outfile.write("<p> </p>")
    outfile.write("<p> </p>")
    outfile.write("<p> </p>")
    outfile.write("<p> </p>")
    outfile.write("<p> </p>")
    outfile.write("<p> </p>")
    outfile.write("<p> </p>")
    outfile.write("<p> </p>")
    outfile.write("<p> </p>")
    outfile.write("<p> </p>")
    outfile.write("<p> </p>")
    outfile.write("<p> </p>")
    outfile.write("<p> </p>")
    outfile.write("<p> </p>")
    outfile.write("<p> </p>")
    outfile.write("</body></html>")
    outfile.close()