Esempio n. 1
0
def main():
    usage = """usage: %prog
    Report if all tables are the same length"""
    parser = GlobalOptionsParser(usage=usage)
    (options, args) = parser.parse_args()
    parser.check_args(0, args)
    session = LionDB(options.config, options.trace, options.app)

    # first get a list of the diffs between each language and the master language
    request = "SELECT langid FROM languages"
    session.execute_query(request)
    langs = session.cursor.fetchall()
    any_diffs_found = False
    for l in langs:
        lid = l[0]
        diffs = session.list_langtable_diffs(lid, session.masterlang)
        if diffs != None:
            any_diffs_found = True
            longer, shorter, data = diffs
            if longer == lid:
                print "%s has more entries than %s" % (lid, session.masterlang)
            else:
                print "%s has fewer entries than %s" % (lid,
                                                        session.masterlang)

    if any_diffs_found == False:
        print "All tables are the same length as %s" % session.masterlang
Esempio n. 2
0
def main():
    usage = """usage: %prog [options] sqlstatement
    Type %(table)s as a token for the language table name
    
    This will run the sql query on all language tables"""

    parser = GlobalOptionsParser(usage=usage)
    (options, args) = parser.parse_args()
    parser.check_args(1, args)

    session = LionDB(options.config, options.trace, options.app)
    sql = args[0]

    request = "SELECT langid FROM languages"

    session.execute_query(request)
    all_langs = session.cursor.fetchall()
    if parser.safety_check("run this query on each language table") == False:
        exit(1)

    for l in all_langs:
        request = sql % {"table": session.make_table_name(l[0])}
        try:
            session.execute_query(request)
            if session.cursor.rowcount > 0:
                for r in session.cursor.fetchall():
                    for field in r:
                        print field
        except Exception, e:
            print "Exception: %s" % e
Esempio n. 3
0
def main():
    usage = """usage: %prog
    Report if all tables are the same length"""
    parser = GlobalOptionsParser(usage=usage)
    (options, args) = parser.parse_args()
    parser.check_args(0, args)
    session = LionDB(options.config, options.trace, options.app)    
    
    # first get a list of the diffs between each language and the master language
    request = "SELECT langid FROM languages"
    session.execute_query(request)
    langs = session.cursor.fetchall()
    any_diffs_found = False
    for l in langs:
        lid = l[0]
        diffs = session.list_langtable_diffs(lid, session.masterlang)
        if diffs != None:
            any_diffs_found = True
            longer, shorter, data = diffs
            if longer == lid:
                print "%s has more entries than %s" % (lid, session.masterlang)
            else:
                print "%s has fewer entries than %s" % (lid, session.masterlang)
        
    if any_diffs_found == False:
        print "All tables are the same length as %s" % session.masterlang
Esempio n. 4
0
def main():
    usage = """usage: %prog [options] langid
    """
    parser = GlobalOptionsParser(usage=usage)
    (options, args) = parser.parse_args()
    parser.check_args(1, args)
    
    session = LionDB(options.config, options.trace, options.app)    
    langid = args[0]
    
    table = session.make_table_name(langid)
    session.execute_query("SELECT remarks, xmlid, textstring from %s" % table)
    results = session.cursor.fetchall()
    
    skipped = 0
    changed = 0
    for remarks, xmlid, textstring in results:
        if remarks != None and remarks != "":
            request = """UPDATE %s SET textstring="%s" WHERE xmlid="%s" """ % (table, remarks, xmlid)
            # print request
            session.execute_query(request)
            changed +=1
        else:
            print "skipping %s (text = %s)" % (xmlid, textstring)
            skipped +=1
    
    print "Skipped %d, Changed %d" % (skipped, changed)
Esempio n. 5
0
def main():
    usage = """usage: %prog [options] sqlstatement
    Run a single SQL query."""

    parser = GlobalOptionsParser(usage=usage)
    (options, args) = parser.parse_args()
    parser.check_args(1, args)

    session = LionDB(options.config, options.trace, options.app)
    sql = args[0]
    session.execute_query(sql)
    if session.cursor.rowcount != 0:
        for r in session.cursor.fetchall():
            for field in r:
                print field
Esempio n. 6
0
def main():
    """Update the release date and version info for the english table"""
    
    usage = """usage: %prog [options] version_info release_date"""
    parser = GlobalOptionsParser(usage=usage)
    
    (options, args) = parser.parse_args()
    parser.check_args(2, args)
    
    session = LionDB(options.config, options.trace, "amis")
    
    # t164 = version info
    # t165 = release date
    session.execute_query("""UPDATE eng_US SET textstring="%s" WHERE xmlid="t164" """ % args[0])
    session.execute_query("""UPDATE eng_US SET textstring="%s" WHERE xmlid="t165" """ % args[1])
    
    print "Successfully updated"
Esempio n. 7
0
def main():
    """Update the release date and version info for the english table"""

    usage = """usage: %prog [options] version_info release_date"""
    parser = GlobalOptionsParser(usage=usage)

    (options, args) = parser.parse_args()
    parser.check_args(2, args)

    session = LionDB(options.config, options.trace, "amis")

    # t164 = version info
    # t165 = release date
    session.execute_query(
        """UPDATE eng_US SET textstring="%s" WHERE xmlid="t164" """ % args[0])
    session.execute_query(
        """UPDATE eng_US SET textstring="%s" WHERE xmlid="t165" """ % args[1])

    print "Successfully updated"
Esempio n. 8
0
def main():
    usage = """usage: %prog
    Normalizes imbalances in the DB"""
    parser = GlobalOptionsParser(usage=usage)
    (options, args) = parser.parse_args()
    parser.check_args(0, args)
    session = LionDB(options.config, options.trace, options.app)

    warn1 = "remove items from all tables that aren't in %s" % session.masterlang
    warn2 = "add missing items to all tables from %s " % session.masterlang

    if parser.safety_check(warn1) == False:
        exit(1)
    if parser.safety_check(warn2) == False:
        exit(1)

    # first get a list of the diffs between each language and the master language
    request = "SELECT langid FROM languages"
    session.execute_query(request)
    langs = session.cursor.fetchall()

    for l in langs:
        lid = l[0]
        diffs = session.list_langtable_diffs(lid, session.masterlang)
        if diffs != None:
            longer, shorter, data = diffs
            # if the given language has more entries than the master language, remove the extras
            if longer == lid:
                for d in data:
                    xmlid = d[0]
                    session.remove_item(lid, xmlid)

            # if the given language has fewer entries than the master language, copy the relevant items over
            else:
                for d in data:
                    xmlid = d[0]
                    session.copy_item(xmlid, session.masterlang, lid)
Esempio n. 9
0
def main():
    """which are the top-level accelerators?"""
    usage = """usage: %prog [options] langid"""
    parser = GlobalOptionsParser(usage=usage)
    (options, args) = parser.parse_args()
    parser.check_args(1, args)
    session = LionDB(options.config, options.trace, options.app)
    table = session.make_table_name(args[0])
    # top level menu items
    request = "SELECT xmlid, textstring FROM %s WHERE istoplevel=1 and role=\"MENUITEM\"" % table
    session.execute_query(request)
    menuitems = session.cursor.fetchall()
    accels = []
    for id, text in menuitems:
        request = "SELECT textstring, audiouri, xmlid FROM %s WHERE target=\"%s\" and role=\"ACCELERATOR\"" % \
            (table, id)
        session.execute_query(request)
        info = (text, id), session.cursor.fetchone()
        accels.append(info)
    for a in accels:
        print "Item: %s (id=%s)" % (a[0][0], a[0][1])
        print "Shortcut: %s (id=%s)" % (a[1][0], a[1][2])
        print "Audio file: %s" % a[1][1]
        print ""
Esempio n. 10
0
File: test.py Progetto: daisy/lion
def main():
    """which are the top-level accelerators?"""
    usage = """usage: %prog [options] langid"""
    parser = GlobalOptionsParser(usage=usage)
    (options, args) = parser.parse_args()
    parser.check_args(1, args)
    session = LionDB(options.config, options.trace, options.app)    
    table = session.make_table_name(args[0])
    # top level menu items
    request = "SELECT xmlid, textstring FROM %s WHERE istoplevel=1 and role=\"MENUITEM\"" % table
    session.execute_query(request)
    menuitems = session.cursor.fetchall()
    accels = []
    for id, text in menuitems:
        request = "SELECT textstring, audiouri, xmlid FROM %s WHERE target=\"%s\" and role=\"ACCELERATOR\"" % \
            (table, id)
        session.execute_query(request)
        info = (text, id), session.cursor.fetchone()
        accels.append(info)
    for a in accels: 
        print "Item: %s (id=%s)" % (a[0][0], a[0][1])
        print "Shortcut: %s (id=%s)" % (a[1][0], a[1][2])
        print "Audio file: %s" % a[1][1]
        print ""
Esempio n. 11
0
def set_toplevel_accel():
    usage = """usage: %prog [options] langid"""
    
    parser = GlobalOptionsParser(usage=usage)
    (options, args) = parser.parse_args()
    parser.check_args(0, args)
    session = LionDB(options.config, options.trace, options.app)    
    
    request = "select xmlid from eng_US where istoplevel=1 and role=\"MENUITEM\""
    session.execute_query(request)
    menuitems = session.cursor.fetchall()
    
    accel_mnem = []
    # for each menu item, find the mnemonic and the accelerator
    for id in menuitems:
        request = "select xmlid from eng_US where target=\"%s\" and role=\"MNEMONIC\"" % id
        session.execute_query(request)
        m = session.cursor.fetchone()[0]
        request = "select xmlid from eng_US where target=\"%s\" and role=\"ACCELERATOR\"" % id
        session.execute_query(request)
        a = session.cursor.fetchone()[0]
        accel_mnem.append((a,m))
    
    # loop through all the known IDs for accelerator/mnemonic pairs representing top level menu items
    for a,m in accel_mnem:
        # for a single ID, get the mnemonic text for all languages
        request = "select textstring from %%(table)s where xmlid=\"%s\"" % m
        result = run_sql_on_all_lang_tables(session, request)
        # result is a langtable:rows dictionary
        for item in result.items():
            table = item[0]
            rows = item[1]
            row = rows[0]
            field = row[0]
            # this is what the accelerator should be
            accelstr = "Alt+%s" % field
            request2 = """UPDATE %s SET textstring="%s", actualkeys="%s" WHERE xmlid="%s" """ % \
                (table, accelstr, accelstr, a)
            print request2
            session.execute_query(request2)
Esempio n. 12
0
def main():
    # who customized the menu mnemonics?
    usage = """usage: %prog [options]"""
    
    parser = GlobalOptionsParser(usage=usage)
    (options, args) = parser.parse_args()
    parser.check_args(0, args)
    session = LionDB(options.config, options.trace, options.app)    
    
    # top level menu items
    request = "SELECT xmlid FROM eng_US WHERE istoplevel=1 and role=\"MENUITEM\""
    session.execute_query(request)
    menuitems = session.cursor.fetchall()
    
    mnemonic_ids = []
    for id in menuitems:
        request = "SELECT xmlid FROM eng_US WHERE target=\"%s\" and role=\"MNEMONIC\"" % id
        session.execute_query(request)
        mnemonic_ids.append(session.cursor.fetchone()[0])
    
    tablelist = []
    # look in each table vs eng_US for the mnemonic value and see if it's different
    for id in mnemonic_ids:
        request = """select eng_US.textstring, %%(table)s.textstring from eng_US, 
        %%(table)s where eng_US.xmlid="%s" and %%(table)s.xmlid="%s" """ % (id, id)
        result = run_sql_on_all_lang_tables(session, request)
        # result is a langtable:rows dictionary
        # ('hin_IN', ( ('H', 'X'),() ) )  
        for item in result.items():
            table = item[0]
            row = item[1][0]
            eng = row[0]
            other = row[1]
            if eng != other and table not in tablelist: tablelist.append(table)
    
    for table in tablelist:
        langid = table.replace("_", "-")
        request = "SELECT email FROM users WHERE langid=\"%s\" " % langid
        session.execute_query(request)
        e = session.cursor.fetchone()
        if e is not None: 
            e = e[0]
            print "%s, " % e
Esempio n. 13
0
File: test.py Progetto: daisy/lion
def main():
    """For whatever"""
    usage = """usage: %prog [options] xmlfile"""

    parser = GlobalOptionsParser(usage=usage)
    (options, args) = parser.parse_args()
    parser.check_args(1, args)
    session = LionDB(options.config, options.trace, options.app)

    minidom.Document = amisxml.AmisUiDoc
    doc = minidom.parse(args[0])
    doc.set_session(session)

    all_xml_ids = doc.get_all_text_ids()
    session.execute_query("SELECT langid FROM languages")
    all_langs = session.cursor.fetchall()
    count = 0

    # make the list of IDs that are to be preserved
    request = "SELECT xmlid, textstring FROM eng_US"  #"%s" % session.make_table_name(l[0])
    session.execute_query(request)
    all_table_ids = session.cursor.fetchall()
    preserve_list = []
    for id, txt in all_table_ids:
        if id not in all_xml_ids:
            count += 1
            preserve_list.append(id)
            print id, txt

    print "Of %d IDs in the DB, %d were not found" % (len(all_table_ids),
                                                      count)

    # now mark each item in that list as preserve = 1 for each language

    for l in all_langs:
        table = session.make_table_name(l[0])
        for id in preserve_list:
            request = """UPDATE %s SET preserve=1 WHERE xmlid="%s" """ % (
                table, id)
            session.execute_query(request)
Esempio n. 14
0
File: test.py Progetto: daisy/lion
def main():
    """For whatever"""
    usage = """usage: %prog [options] xmlfile"""
    
    parser = GlobalOptionsParser(usage=usage)
    (options, args) = parser.parse_args()
    parser.check_args(1, args)
    session = LionDB(options.config, options.trace, options.app)    
    
    minidom.Document = amisxml.AmisUiDoc
    doc = minidom.parse(args[0])
    doc.set_session(session)
    
    all_xml_ids = doc.get_all_text_ids()
    session.execute_query("SELECT langid FROM languages")
    all_langs = session.cursor.fetchall()
    count = 0
    
    # make the list of IDs that are to be preserved
    request = "SELECT xmlid, textstring FROM eng_US" #"%s" % session.make_table_name(l[0])
    session.execute_query(request)
    all_table_ids = session.cursor.fetchall()
    preserve_list = []
    for id, txt in all_table_ids:
        if id not in all_xml_ids:
            count += 1
            preserve_list.append(id)
            print id, txt
    
    print "Of %d IDs in the DB, %d were not found" % (len(all_table_ids), count)
    
    # now mark each item in that list as preserve = 1 for each language
    
    for l in all_langs:
        table = session.make_table_name(l[0])
        for id in preserve_list:
            request = """UPDATE %s SET preserve=1 WHERE xmlid="%s" """ % (table, id)
            session.execute_query(request)