Source / scripts /

# Update rietveld tables when the email address changes
# this updates, 
# and, based on the nosy list s
# it does not update codereview_issue.reviewers, since it would be
# too expensive to search all issues, and since the reviewers list
# is something that has to be filled out separately in Rietveld.
# It also does not update codereview_message, since these have already
# been sent with the email addresses recorded in the database.
# This script is now part of rietveldreactor

import sys, os, base64, cPickle
import roundup.instance

verbose = sys.argv[1:] == ['-v']

homedir = os.path.join(os.path.dirname(__file__), "..")
tracker =
db ='admin')
c = db.cursor

c.execute('select,, a._address from _user a, auth_user b '
          'where and a._address !=')
for user, old, new in c.fetchall():
    old = old.decode('ascii')
    new = new.decode('ascii')
    if verbose:
        print "Update user", user, 'from', old, 'to ', new
    c.execute('update auth_user set email=%s where id=%s', (new, user))
    c.execute('update codereview_account set email=%s where id=%s', (new, user))
    # find issues where user is on nosy
    c.execute('select nodeid,cc from issue_nosy, codereview_issue '
              'where linkid=%s and nodeid=id', (user,))
    for nodeid, cc in c.fetchall():
        cc = cPickle.loads(base64.decodestring(cc))
        if verbose:
            print " Update issue", nodeid, cc
            cc[cc.index(old)] = new
        except ValueError:
        cc = base64.encodestring(cPickle.dumps(cc))
        c.execute('update codereview_issue set cc=%s where id=%s', (cc, nodeid))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.