Ejemplo n.º 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]))
Ejemplo n.º 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]))
Ejemplo n.º 3
0
    def handle(self, username, id_string, remongo, update_all, *args,
               **kwargs):
        user = xform = None
        if username:
            try:
                user = User.objects.get(username=username)
            except User.DoesNotExist:
                raise CommandError("User %s does not exist" % username)
        if username and id_string:
            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))

        report_string = mongo_sync_status(remongo, update_all, user, xform)
        self.stdout.write(report_string)
Ejemplo n.º 4
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)