Ejemplo n.º 1
0
'''
try:
    jsFile = open('phase3.html','w+')
except IOError as e:
        print "I/O error({0}): {1}".format(e.errno, e.strerror)
except ValueError:
        print "Could not convert data to an integer."
except:
        print "Unexpected error:", sys.exc_info()[0]
        raise
'''
print("Content-Type: text/html")
print ""
#print(""" """)
genJS.genOpenTag()
genJS.javaScriptType("jquery/jquery.js", "", "")
countRows = executeQuery(sql[1])
countRows = map(int, countRows)
colList = executeQuery(sql[0])
#print colList
colListStr = ','.join(colList)
emptyLst = []
for i in range(countRows[0]):
    emptyLst.append("")
print("<script type=\"text/javascript\">\n")
print("var count = %d;var table = %s;function getValues(event, n) {if(event.which == \"9\") {var focusedElement = $(\":focus\");var ele = Number(focusedElement.attr(\"id\").slice(4));var val = focusedElement.attr(\"value\");var temp = ele/n;var tempDiff = temp%%1;temp = temp - tempDiff;var temp1 = ele%%n;table[temp][temp1] = val;}else if(event.which == \"13\") {var value = \"\";var i;var rowEntry = [];for(i = (count * n); i < ((count + 1) * n); i++) {var temp;temp = document.getElementById(\"attr\" + i);if(temp != null) {value = temp.value;if(value == \'\') {alert(\"enter attribute \" + (i + 1));break;}else {rowEntry.push(value);}}}table.push(rowEntry);count++;var newTableRow = $(document.createElement(\'tr\')).attr(\"id\", \'TableRow\' + count);newTableRow.after().html("%(int(countRows[0]), str(emptyLst)))
genJS.genColumnTag(int(countRows[0]), len(colList))
print(");newTableRow.appendTo(\"#idTable\");document.getElementById(\"attr\" + (count * n)).focus();}else if(event.which == \"37\") {var focusedElement = $(\":focus\");var ele = Number(focusedElement.attr(\"id\").slice(4));if(ele > 0) {var input = document.getElementById(\"attr\" + (ele - 1));input.focus();var val = input.value;input.value = \'\';input.value = val;}else {var input = document.getElementById(\"attr\" + ele);input.focus();var val = input.value;input.value = \'\';input.value = val;}}else if(event.which == \"38\") {var focusedElement = $(\":focus\");var ele = Number(focusedElement.attr(\"id\").slice(4));if(ele >= n) {var input = document.getElementById(\"attr\" + (ele - n));input.focus();var val = input.value;input.value = \'\';input.value = val;}}else if(event.which == \"39\") {var focusedElement = $(\":focus\");var ele = Number(focusedElement.attr(\"id\").slice(4));if(ele < (count * n) + %d) {var input = document.getElementById(\"attr\" + (ele + 1));input.focus();var val = input.value;input.value = \'\';input.value = val;}}else if(event.which == \"40\") {var focusedElement = $(\":focus\");var ele = Number(focusedElement.attr(\"id\").slice(4));if(ele < (count * n)) {var input = document.getElementById(\"attr\" + (ele + n));input.focus();var val = input.value;input.value = \'\';input.value = val;}}}function submitTable(n) {var i;var rowEntry = [];for(i = 0; i < n; i++)rowEntry.push(document.getElementById(\"attr\" + ((count * n) + i)).value);console.log(count);table.push(rowEntry);for(i = 0; i <= count; i++)console.log(table[i]);}</script>"%(len(colList)-1))

print("\n<body>\n<table id=\"idTable\" border=\"1\" style=\"width:100%\">\n<tr id=\"tableHead\">\n")
genJS.genAttrNames(colList)
Ejemplo n.º 2
0
    except:
        print "Error: unable to fecth data"
    db.close()


try:
    jsFile = open('phase3.html', 'w+')
except IOError as e:
    print "I/O error({0}): {1}".format(e.errno, e.strerror)
except ValueError:
    print "Could not convert data to an integer."
except:
    print "Unexpected error:", sys.exc_info()[0]
    raise
genJS.genOpenTag(jsFile)
genJS.javaScriptType(jsFile, "js/jquery-1.11.3.js", "", "")
countRows = executeQuery(sql[1])
countRows = map(int, countRows)
colList = executeQuery(sql[0])
colListStr = ','.join(colList)
emptyLst = []
for i in range(countRows[0]):
    emptyLst.append("")
jsFile.write("<script type=\"text/javascript\">\n")
jsFile.write(
    "var count = %d;var table = %s;function getValues(event, n) {if(event.which == \"9\") {var focusedElement = $(\":focus\");var ele = Number(focusedElement.attr(\"id\").slice(4));var val = focusedElement.attr(\"value\");var temp = ele/n;var tempDiff = temp%%1;temp = temp - tempDiff;var temp1 = ele%%n;table[temp][temp1] = val;}else if(event.which == \"13\") {var value = \"\";var i;var rowEntry = [];for(i = (count * n); i < ((count + 1) * n); i++) {var temp;temp = document.getElementById(\"attr\" + i);if(temp != null) {value = temp.value;if(value == \'\') {alert(\"enter attribute \" + (i + 1));break;}else {rowEntry.push(value);}}}table.push(rowEntry);count++;var newTableRow = $(document.createElement(\'tr\')).attr(\"id\", \'TableRow\' + count);newTableRow.after().html("
    % (int(countRows[0]), str(emptyLst)))
genJS.genColumnTag(jsFile, int(countRows[0]), len(colList))
jsFile.write(
    ");newTableRow.appendTo(\"#idTable\");document.getElementById(\"attr\" + (count * n)).focus();}else if(event.which == \"37\") {var focusedElement = $(\":focus\");var ele = Number(focusedElement.attr(\"id\").slice(4));if(ele > 0) {var input = document.getElementById(\"attr\" + (ele - 1));input.focus();var val = input.value;input.value = \'\';input.value = val;}else {var input = document.getElementById(\"attr\" + ele);input.focus();var val = input.value;input.value = \'\';input.value = val;}}else if(event.which == \"38\") {var focusedElement = $(\":focus\");var ele = Number(focusedElement.attr(\"id\").slice(4));if(ele >= n) {var input = document.getElementById(\"attr\" + (ele - n));input.focus();var val = input.value;input.value = \'\';input.value = val;}}else if(event.which == \"39\") {var focusedElement = $(\":focus\");var ele = Number(focusedElement.attr(\"id\").slice(4));if(ele < (count * n) + %d) {var input = document.getElementById(\"attr\" + (ele + 1));input.focus();var val = input.value;input.value = \'\';input.value = val;}}else if(event.which == \"40\") {var focusedElement = $(\":focus\");var ele = Number(focusedElement.attr(\"id\").slice(4));if(ele < (count * n)) {var input = document.getElementById(\"attr\" + (ele + n));input.focus();var val = input.value;input.value = \'\';input.value = val;}}}function submitTable(n) {var i;var rowEntry = [];for(i = 0; i < n; i++)rowEntry.push(document.getElementById(\"attr\" + ((count * n) + i)).value);console.log(count);table.push(rowEntry);for(i = 0; i <= count; i++)console.log(table[i]);}</script>"
    % (len(colList) - 1))
        return resList
    except:
        print "Error: unable to fecth data"
    db.close()

try:
    jsFile = open('genTable.html','w+')
except IOError as e:
        print "I/O error({0}): {1}".format(e.errno, e.strerror)
except ValueError:
        print "Could not convert data to an integer."
except:
        print "Unexpected error:", sys.exc_info()[0]
        raise
genJS.genOpenTag(jsFile)
genJS.javaScriptType(jsFile, "js/jquery-1.11.3.js", "", "")
countRows = executeQuery(sql[1])
countRows = map(int, countRows)
colList = executeQuery(sql[0])
colListStr = ','.join(colList)
emptyLst = []
for i in range(countRows[0]):
    emptyLst.append("")
jsFile.write("<script type=\"text/javascript\">\n")
jsFile.write("var count = %d;var table = %s;function getValues(event, n) {if(event.which == \"9\") {var focusedElement = $(\":focus\");var ele = Number(focusedElement.attr(\"id\").slice(4));var val = focusedElement.attr(\"value\");var temp = ele/n;var tempDiff = temp%%1;temp = temp - tempDiff;var temp1 = ele%%n;table[temp][temp1] = val;}else if(event.which == \"13\") {var value = \"\";var i;var rowEntry = [];for(i = (count * n); i < ((count + 1) * n); i++) {var temp;temp = document.getElementById(\"attr\" + i);if(temp != null) {value = temp.value;if(value == \'\') {alert(\"enter attribute \" + (i + 1));break;}else {rowEntry.push(value);}}}table.push(rowEntry);count++;var newTableRow = $(document.createElement(\'tr\')).attr(\"id\", \'TableRow\' + count);newTableRow.after().html("%(int(countRows[0]), str(emptyLst)))
genJS.genColumnTag(jsFile, int(countRows[0]), len(colList))
jsFile.write(");newTableRow.appendTo(\"#idTable\");document.getElementById(\"attr\" + (count * n)).focus();}else if(event.which == \"37\") {var focusedElement = $(\":focus\");var ele = Number(focusedElement.attr(\"id\").slice(4));if(ele > 0) {var input = document.getElementById(\"attr\" + (ele - 1));input.focus();var val = input.value;input.value = \'\';input.value = val;}else {var input = document.getElementById(\"attr\" + ele);input.focus();var val = input.value;input.value = \'\';input.value = val;}}else if(event.which == \"38\") {var focusedElement = $(\":focus\");var ele = Number(focusedElement.attr(\"id\").slice(4));if(ele >= n) {var input = document.getElementById(\"attr\" + (ele - n));input.focus();var val = input.value;input.value = \'\';input.value = val;}}else if(event.which == \"39\") {var focusedElement = $(\":focus\");var ele = Number(focusedElement.attr(\"id\").slice(4));if(ele < (count * n) + %d) {var input = document.getElementById(\"attr\" + (ele + 1));input.focus();var val = input.value;input.value = \'\';input.value = val;}}else if(event.which == \"40\") {var focusedElement = $(\":focus\");var ele = Number(focusedElement.attr(\"id\").slice(4));if(ele < (count * n)) {var input = document.getElementById(\"attr\" + (ele + n));input.focus();var val = input.value;input.value = \'\';input.value = val;}}}function submitTable(n) {var i;var rowEntry = [];for(i = 0; i < n; i++)rowEntry.push(document.getElementById(\"attr\" + ((count * n) + i)).value);console.log(count);table.push(rowEntry);for(i = 0; i <= count; i++)console.log(table[i]);}</script>"%(len(colList)-1))

jsFile.write("\n<body>\n<table id=\"idTable\" border=\"1\" style=\"width:100%\">\n<tr id=\"tableHead\">\n")
genJS.genAttrNames(jsFile, colList)
jsFile.write("</tr>")
Ejemplo n.º 4
0
db = MySQLdb.connect("localhost","root","mysql",sys.argv[1])

# prepare a cursor object using cursor() method
cursor = db.cursor()

# Prepare SQL query to INSERT a record into the database.
sql = "SELECT `COLUMN_NAME`  FROM `INFORMATION_SCHEMA`.`COLUMNS`  WHERE `TABLE_SCHEMA`='container'  AND `TABLE_NAME`='%s';"%(sys.argv[2])
colList = []
try:
       # Execute the SQL command
          cursor.execute(sql)
             # Fetch all the rows in a list of lists.
          results = cursor.fetchall()
          for row in results:
               colList.append(row[0])
               
          print "Columns\n",colList
except:
       print "Error: unable to fecth data"

       # disconnect from server
       db.close()
jsFile = open('genColList.html','w+')
jsFile.write("<html>\n<body>\n")
genJS.javaScriptType(jsFile, "js/jquery.min.js", "css/bootstrap.min.css", "stylesheet")
genJS.javaScriptType(jsFile, "js/bootstrap.min.js", "css/bootstrap-multiselect.css", "stylesheet")
genJS.javaScriptType(jsFile, "js/bootstrap-multiselect.js", "", "")
jsFile.write("<script type=\"text/javascript\">\n$(function () {\n$(\'#optionList\').multiselect({\nincludeSelectAllOption: true\n});\n$(\'#btnSelected\').click(function () {\nvar selected = $(\"#optionList option:selected\");\nvar message = \"\";\nselected.each(function () {\nmessage += $(this).text() + \" \" + $(this).val() + \"\";\n});\nalert(message);\n});\n});\n</script>\n")
genJS.genOptions(jsFile, colList)
jsFile.write("</body>\n</html>")
"""
try:
    jsFile = open('phase3.html','w+')
except IOError as e:
        print "I/O error({0}): {1}".format(e.errno, e.strerror)
except ValueError:
        print "Could not convert data to an integer."
except:
        print "Unexpected error:", sys.exc_info()[0]
        raise
"""
print ("Content-Type: text/html")
print ""
# print(""" """)
genJS.genOpenTag()
genJS.javaScriptType("jquery/jquery.js", "", "")
countRows = executeQuery(sql[1])
countRows = map(int, countRows)
colList = executeQuery(sql[0])
# print colList
colListStr = ",".join(colList)
emptyLst = []
for i in range(countRows[0]):
    emptyLst.append("")
print ('<script type="text/javascript">\n')
print (
    'var count = %d;var table = %s;function getValues(event, n) {if(event.which == "9") {var focusedElement = $(":focus");var ele = Number(focusedElement.attr("id").slice(4));var val = focusedElement.attr("value");var temp = ele/n;var tempDiff = temp%%1;temp = temp - tempDiff;var temp1 = ele%%n;table[temp][temp1] = val;}else if(event.which == "13") {var value = "";var i;var rowEntry = [];for(i = (count * n); i < ((count + 1) * n); i++) {var temp;temp = document.getElementById("attr" + i);if(temp != null) {value = temp.value;if(value == \'\') {alert("enter attribute " + (i + 1));break;}else {rowEntry.push(value);}}}table.push(rowEntry);count++;var newTableRow = $(document.createElement(\'tr\')).attr("id", \'TableRow\' + count);newTableRow.after().html('
    % (int(countRows[0]), str(emptyLst))
)
genJS.genColumnTag(int(countRows[0]), len(colList))
print (