def sync_users_accounts(self, old):
        print "Migrating users accounts ..."
        prog = ProgressBar(0, self.count_table(old, 'users'), 77, mode='fixed')

        old.execute('''
            select 
                u.id, 
                u.name,
                ue.email,
                ua.accountLocation,
                ua.accountAvatar,
                up.pts
            from users u 
            left join users_emails ue on ue.userId = u.id
            left join users_accounts ua on ua.userId = u.id
            left join users_pts up on up.idUser = u.id
        ''')
        for old_user in old.fetchall():
            # skipping the couple of nonames
            if not old_user[1]: continue

            if old_user[0] in self.old_root_ids:
                user = User.objects.get(pk=settings.ROOT_USERID)
            else:
                user, created = User.objects.get_or_create(pk=old_user[0])
            count = 0
            user.username = slughifi(old_user[1])[:30] or count
            while User.objects.filter(username=user.username).exclude(pk=user.pk).count():
                user.username = '%s%s' % (slughifi(old_user[1])[:28], count)
                count += 1
            user.email = old_user[2] or 'no@email.com'
            user.first_name = old_user[1]
            user.save()

            user.playlistprofile.points = old_user[5] or 0
            if old_user[3]:
                user.playlistprofile.user_location = old_user[3]
            if old_user[4]:
                user.playlistprofile.avatar_url = old_user[4]
            user.playlistprofile.save()
           
            old.execute('select * from users_accounts where userId = ' + str(old_user[0]))
            for old_account in old.fetchall():
                if old_account[1] == 'FACEBOOK':
                    p, created=FacebookProfile.objects.get_or_create(uid=old_account[2], user=user)

                    upstream = None
                    try:
                        filename, message = urllib.urlretrieve(old_account[2] % 'https://graph.facebook.com/%s')
                        fp = open(filename)
                        upstream = simplejson.load(fp)
                        fp.close()
                    except:
                        pass

                    if upstream:
                        p.nick = upstream['name']
                        if 'link' in upstream:
                            p.url = upstream['link']
                        else:
                            p.url = 'http://www.facebook.com/profile.php?id=%s' % old_account[2]

                    p.save()
                
                elif old_account[1] == 'TWITTER':
                    p, created=TwitterProfile.objects.get_or_create(twitter_id=old_account[2],user=user)
                    old.execute('select * from twitter_tokens where twitterUserId = "%s"' % old_account[2])
                    old_profile = old.fetchone()
                    if old_profile is not None:
                        p.access_token = old_profile[1]
                        p.token_secret = old_profile[2]
                    p.nick = old_account[5].replace('http://twitter.com/', '').replace('http://www.twitter.com/', '')
                    p.url = old_account[5]
                    p.save()
                
                elif old_account[1] == 'GOOGLE':
                    p, created=GfcProfile.objects.get_or_create(uid=old_account[2],user=user)
                    p.save()   

            prog.increment_amount()
            print prog, '\r',
            sys.stdout.flush()
dataset/ETHPy150Open jpic/playlistnow.fm/apps/playlist/management/commands/migrate_pln.py/Command.sync_users_accounts/swapped operands of `%`