def main():
	# Get the CGI information for the source
	# Exit the script if that information is not good. 
	form = cgi.FieldStorage()
	src = urllib.unquote(form.getvalue('source'))
	if src is None:
		raise Exception

	# Get the source list data from the database
	rows = cdblib.getSourceConnectionList(src)
	if rows is None:
		raise Exception

	# transpose the data
	rdict = [dict(label = cdblib.makeCableLabel(row, "A"),
				  type = row[7],
				  longType = row[16],
				  use = row[8],
				  sourceconn = row[3],
				  destconn = row[5],
				  wiring = row[11])
			 for row in rows]

	# Setup the renderer to make the html list
	renderer = pystache.Renderer()
	
	footer = time.asctime(time.localtime())
	title = 'Source Connection List for {0}'.format(src)
	
	data = renderer.render_path('getSourceList.mustache', 
						        {'source' : src,
								 'footer' : footer,
								 'title'  : title,
				 				 'sourceList' : rdict})	
	print data
示例#2
0
def doLabels(data, type):
	print 'Content-Type: application/csv; name="labels.csv"'
	print 'Content-Disposition: attachment; filename="labels.csv"'
	print
	if type == 'all':
		for row in data:
			print cdblib.makeCableLabel(row, "A") + "," + cdblib.makeCableLabel(row, "B")
	elif type == 'A':
		for row in data:
			print cdblib.makeCableLabel(row, "A")
	elif type == 'B':
		for row in data:
			print cdblib.makeCableLabel(row, "B")
示例#3
0
def doLabels(data, type):
    print 'Content-Type: application/csv; name="labels.csv"'
    print 'Content-Disposition: attachment; filename="labels.csv"'
    print
    if type == 'all':
        for row in data:
            print cdblib.makeCableLabel(
                row, "A") + "," + cdblib.makeCableLabel(row, "B")
    elif type == 'A':
        for row in data:
            print cdblib.makeCableLabel(row, "A")
    elif type == 'B':
        for row in data:
            print cdblib.makeCableLabel(row, "B")
示例#4
0
def printTableData(keys):
	rows = cdblib.doCableSearch(keys)
	rdict = [dict(label = cdblib.makeCableLabel(row,'{A/B}'),
				  type = row[7],
				  longType = row[16],
				  use = row[8],
				  source = row[9],
				  destination = row[10],
				  path = row[12],
				  wiring = row[11],
				  installed = row[13])
				  for row in rows]


	# Setup the renderer to make the html list
	renderer = pystache.Renderer()
	data = renderer.render_path('tableData.mustache', {'footer' : time.asctime(time.localtime()),
													   'title'  : 'Cable Data',
													   'sourceList' : rdict,
													   'idlist' : ",".join(["{0}".format(row[0]) for row in rows])})
	print data
示例#5
0
def main():
    # Get the CGI information for the source
    # Exit the script if that information is not good.
    form = cgi.FieldStorage()
    src = urllib.unquote(form.getvalue('source'))
    if src is None:
        raise Exception

    # Get the source list data from the database
    rows = cdblib.getSourceConnectionList(src)
    if rows is None:
        raise Exception

    # transpose the data
    rdict = [
        dict(label=cdblib.makeCableLabel(row, "A"),
             type=row[7],
             longType=row[16],
             use=row[8],
             sourceconn=row[3],
             destconn=row[5],
             wiring=row[11]) for row in rows
    ]

    # Setup the renderer to make the html list
    renderer = pystache.Renderer()

    footer = time.asctime(time.localtime())
    title = 'Source Connection List for {0}'.format(src)

    data = renderer.render_path('getSourceList.mustache', {
        'source': src,
        'footer': footer,
        'title': title,
        'sourceList': rdict
    })
    print data