Changeset ff2d928 for fedd


Ignore:
Timestamp:
Dec 2, 2008 5:17:02 PM (16 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master, version-1.30, version-2.00, version-3.01, version-3.02
Children:
e087a7a
Parents:
b0b9499
Message:

mysql error handling

Location:
fedd
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • fedd/confirm_sshkey.py

    rb0b9499 rff2d928  
    1919        self.add_option('-q', '--quiet', dest='verbose', action='store_false',
    2020                default=True, help="No output")
    21         self.add_option('-C', dest=dummy,
     21        self.add_option('-C', dest='dummy',
    2222                help="Compatibility option, no function")
    2323
     
    6161query = query_template % (user, key)
    6262
    63 db = MySQLdb.connect(db='tbdb')
     63try:
     64    db = MySQLdb.connect(db='tbdb')
     65except Exception, e:
     66    if len(e.args) == 2:
     67        num, str = e.args
     68    else:
     69        str = unicode(e)
     70        num = -1
     71    sys.exit("Cannot connect: %s (%d)" % (str, num))
     72
    6473c = db.cursor()
    6574c.execute(query)
  • fedd/user_to_project.py

    rb0b9499 rff2d928  
    1010    sys.exit("Usage %s user project" % sys.argv[0])
    1111
    12 db = MySQLdb.connect(db='tbdb')
     12try:
     13    db = MySQLdb.connect(db='tbdb')
     14except Exception, e:
     15    if len(e.args) == 2:
     16        num, str = e.args
     17    else:
     18        str = unicode(e)
     19        num = -1
     20    sys.exit("Cannot connect: %s (%d)" % (str, num))
     21
    1322c = db.cursor()
    1423c.execute("select uid, uid_idx from users where uid=%s", (user,))
Note: See TracChangeset for help on using the changeset viewer.