From bfc003a953a3ce509fe0851fa589c31fbc2ba57e Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Wed, 24 Aug 2011 11:32:02 -0700 Subject: Updating printdb to print hotseat items as well. Change-Id: I807a6fd040b4095fc670b7d513f1e5e13412d169 --- print_db.py | 107 +++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 63 insertions(+), 44 deletions(-) (limited to 'print_db.py') diff --git a/print_db.py b/print_db.py index ebcba6ce..4f90f94f 100755 --- a/print_db.py +++ b/print_db.py @@ -9,6 +9,7 @@ import sqlite3 SCREENS = 5 COLUMNS = 4 ROWS = 4 +HOTSEAT_SIZE = 5 CELL_SIZE = 110 DIR = "db_files" @@ -70,6 +71,52 @@ FUNCTIONS = { "icon": print_icon } +def render_cell_info(out, cell, occupied): + if cell is None: + out.write(" \n" % + (CELL_SIZE, CELL_SIZE)) + elif cell == occupied: + pass + else: + cellX = cell["cellX"] + cellY = cell["cellY"] + spanX = cell["spanX"] + spanY = cell["spanY"] + intent = cell["intent"] + if intent: + title = "title=\"%s\"" % cgi.escape(cell["intent"], True) + else: + title = "" + out.write((" ") % ( + spanX, spanY, + (CELL_SIZE*spanX), (CELL_SIZE*spanY), + title)) + itemType = cell["itemType"] + if itemType == 0: + out.write("""\n""" % ( cell["_id"] )) + out.write("
\n") + out.write(cgi.escape(cell["title"]) + "
(app)") + elif itemType == 1: + out.write("""\n""" % ( cell["_id"] )) + out.write("
\n") + out.write(cgi.escape(cell["title"]) + "
(shortcut)") + elif itemType == 2: + out.write("""folder""") + elif itemType == 3: + out.write("""live folder""") + elif itemType == 4: + out.write("widget %d
\n" % cell["appWidgetId"]) + elif itemType == 1000: + out.write("""clock""") + elif itemType == 1001: + out.write("""search""") + elif itemType == 1002: + out.write("""photo frame""") + else: + out.write("unknown type: %d" % itemType) + out.write("\n") + def process_file(fn): print "process_file: " + fn conn = sqlite3.connect(fn) @@ -119,6 +166,21 @@ def process_file(fn): out.write(""" """) + # Hotseat + hotseat = [] + for i in range(0, HOTSEAT_SIZE): + hotseat.append(None) + for row in data: + if row["container"] != -101: + continue + screen = row["screen"] + hotseat[screen] = row + out.write("
Hotseat
\n") + out.write("\n") + for cell in hotseat: + render_cell_info(out, cell, None) + out.write("
\n") + # Pages screens = [] for i in range(0,SCREENS): @@ -150,50 +212,7 @@ def process_file(fn): for m in screen: out.write(" \n") for cell in m: - if cell is None: - out.write(" \n" % - (CELL_SIZE, CELL_SIZE)) - elif cell == occupied: - pass - else: - cellX = cell["cellX"] - cellY = cell["cellY"] - spanX = cell["spanX"] - spanY = cell["spanY"] - intent = cell["intent"] - if intent: - title = "title=\"%s\"" % cgi.escape(cell["intent"], True) - else: - title = "" - out.write((" ") % ( - spanX, spanY, - (CELL_SIZE*spanX), (CELL_SIZE*spanY), - title)) - itemType = cell["itemType"] - if itemType == 0: - out.write("""\n""" % ( cell["_id"] )) - out.write("
\n") - out.write(cgi.escape(cell["title"]) + "
(app)") - elif itemType == 1: - out.write("""\n""" % ( cell["_id"] )) - out.write("
\n") - out.write(cgi.escape(cell["title"]) + "
(shortcut)") - elif itemType == 2: - out.write("""folder""") - elif itemType == 3: - out.write("""live folder""") - elif itemType == 4: - out.write("widget %d
\n" % cell["appWidgetId"]) - elif itemType == 1000: - out.write("""clock""") - elif itemType == 1001: - out.write("""search""") - elif itemType == 1002: - out.write("""photo frame""") - else: - out.write("unknown type: %d" % itemType) - out.write("\n") + render_cell_info(out, cell, occupied) out.write("\n") out.write("\n") i=i+1 -- cgit v1.2.3