Example #1
0
def email_mongo_sync_status():
    """Check the status of records in the mysql db versus mongodb, and, if necessary,
    invoke the command to re-sync the two databases, sending an email report to the
    admins of before and after, so that manual syncing (if necessary) can be done."""

    before_report = mongo_sync_status()
    if REMONGO_PATTERN.search(before_report):
        # synchronization is necessary
        after_report = mongo_sync_status(remongo=True)
    else:
        # no synchronization is needed
        after_report = "No synchronization needed"

    # send the before and after reports, along with instructions for
    # syncing manually, as an email to the administrators
    mail_admins("Mongo DB sync status", "\n\n".join([before_report, after_report, SYNC_MONGO_MANUAL_INSTRUCTIONS]))
Example #2
0
def email_mongo_sync_status():
    """Check the status of records in the mysql db versus mongodb, and, if necessary,
    invoke the command to re-sync the two databases, sending an email report to the
    admins of before and after, so that manual syncing (if necessary) can be done."""

    before_report = mongo_sync_status()
    if REMONGO_PATTERN.search(before_report):
        # synchronization is necessary
        after_report = mongo_sync_status(remongo=True)
    else:
        # no synchronization is needed
        after_report = "No synchronization needed"

    # send the before and after reports, along with instructions for
    # syncing manually, as an email to the administrators
    mail_admins(
        "Mongo DB sync status", '\n\n'.join(
            [before_report, after_report, SYNC_MONGO_MANUAL_INSTRUCTIONS]))
Example #3
0
def email_mongo_sync_status():
    # run function to check status
    report_string = mongo_sync_status()
    report_string += "\nTo re-sync, ssh into the server and run\n\n"\
        "python manage.py sync_mongo -r [username] [id_string]\n\n"\
        "To force complete delete and re-creationuse the -a option"\
        " \n\n"\
        "python manage.py sync_mongo -ra [username] [id_string]\n"
    # send email
    mail_admins("Mongo DB sync status", report_string)
Example #4
0
def email_mongo_sync_status():
    # run function to check status
    report_string = mongo_sync_status()
    report_string += "\nTo re-sync, ssh into the server and run\n\n"\
        "python manage.py sync_mongo -r [username] [id_string]\n\n"\
        "To force complete delete and re-creationuse the -a option"\
        " \n\n"\
        "python manage.py sync_mongo -ra [username] [id_string]\n"
    # send email
    mail_admins("Mongo DB sync status", report_string)
Example #5
0
    def handle(self, *args, **kwargs):
        user = xform = None
        if len(args) > 0:
            username = args[0]
            try:
                user = User.objects.get(username=username)
            except User.DoesNotExist:
                raise CommandError("User %s does not exist" % username)
        if len(args) > 1:
            id_string = args[1]
            try:
                xform = XForm.objects.get(user=user, id_string=id_string)
            except XForm.DoesNotExist:
                raise CommandError(
                    "Xform %s does not exist for user %s" %\
                    (id_string, user.username))

        remongo = kwargs["remongo"]
        update_all = kwargs["update_all"]

        report_string = mongo_sync_status(remongo, update_all, user, xform)
        self.stdout.write(report_string)
Example #6
0
    def handle(self, *args, **kwargs):
        user = xform = None
        if len(args) > 0:
            username = args[0]
            try:
                user = User.objects.get(username=username)
            except User.DoesNotExist:
                raise CommandError("User %s does not exist" % username)
        if len(args) > 1:
            id_string = args[1]
            try:
                xform = XForm.objects.get(user=user, id_string=id_string)
            except XForm.DoesNotExist:
                raise CommandError(
                    "Xform %s does not exist for user %s" %\
                    (id_string, user.username))

        remongo = kwargs["remongo"]
        update_all = kwargs["update_all"]

        report_string = mongo_sync_status(remongo, update_all, user, xform)
        self.stdout.write(report_string)