diff --git a/zephyr/management/commands/dump_passwords.py b/zephyr/management/commands/dump_passwords.py index 0b00c01f23..62f97da726 100644 --- a/zephyr/management/commands/dump_passwords.py +++ b/zephyr/management/commands/dump_passwords.py @@ -11,7 +11,11 @@ def dump(): def restore(change): for (email, password) in simplejson.loads(file("dumped-passwords").read()): - user = User.objects.get(email__iexact=email) + try: + user = User.objects.get(email__iexact=email) + except User.DoesNotExist: + print "Skipping...", email + continue if change: user.password = password user.save() diff --git a/zephyr/management/commands/dump_pointers.py b/zephyr/management/commands/dump_pointers.py index c3fa090b42..0fe1f25cdc 100755 --- a/zephyr/management/commands/dump_pointers.py +++ b/zephyr/management/commands/dump_pointers.py @@ -17,13 +17,20 @@ def dump(): def restore(change): for (email, timestamp) in simplejson.loads(file("dumped-pointers").read()): - u = UserProfile.objects.get(user__email__iexact=email) + try: + u = UserProfile.objects.get(user__email__iexact=email) + except UserProfile.DoesNotExist: + print "Skipping...", email + continue if timestamp == -1: pointer = -1 else: - pointer = Message.objects.filter( - pub_date__gte=timestamp_to_datetime(timestamp)).order_by("id")[0].id - print "%s: pointer %s => %s" % (email, u.pointer, pointer) + try: + pointer = Message.objects.filter( + pub_date__gte=timestamp_to_datetime(timestamp - 1)).order_by("id")[0].id + except IndexError: + print "Alert...", email, timestamp + continue if change: u.pointer = pointer u.save()