Ejemplo n.º 1
0
Archivo: cron.py Proyecto: tgage/asm3
def maint_db_update(dbo):
    """
    Check and run any outstanding database updates
    """
    try:
        # This should never be run at a time when users may be
        # using the system, remove any database update locks as any
        # lock at this time should be erroneous
        configuration.db_unlock(dbo)

        # Check to see if any updates need performing on this database
        if dbupdate.check_for_updates(dbo):
            ttask(dbupdate.perform_updates, dbo)

        if dbupdate.check_for_view_seq_changes(dbo):
            ttask(dbupdate.install_db_views, dbo)
            ttask(dbupdate.install_db_sequences, dbo)
            ttask(dbupdate.install_db_stored_procedures, dbo)

    except:
        em = str(sys.exc_info()[0])
        al.error("FAIL: running db updates: %s" % em, "cron.maint_db_update", dbo, sys.exc_info())
Ejemplo n.º 2
0
def daily(dbo):
    """
    Tasks to run once each day before users login for the day.
    """
    al.info("start daily tasks", "cron.daily", dbo)

    try:
        # The batch should never be run at a time when users may be
        # using the system, remove any database update locks as any
        # lock at this time should be erroneous
        configuration.db_unlock(dbo)

        # Check to see if any updates need performing on this database
        if dbupdate.check_for_updates(dbo):
            dbupdate.perform_updates(dbo)
        if dbupdate.check_for_view_seq_changes(dbo):
            dbupdate.install_db_views(dbo)
            dbupdate.install_db_sequences(dbo)

        # Get the latest news from sheltermanager.com
        dbfs.update_asm_news(dbo)

        # Shouldn't be anyone logged in at this point
        users.auto_logout(dbo)

        # Update on shelter and foster animal location fields
        animal.update_on_shelter_animal_statuses(dbo)
        animal.update_foster_animal_statuses(dbo)

        # Update all animal variable data (age, time on shelter, etc)
        animal.update_all_variable_animal_data(dbo)

        # Update animal figures for reports
        animal.update_animal_figures(dbo)
        animal.update_animal_figures_annual(dbo)
        animal.update_animal_figures_asilomar(dbo)

        # Update animal litter counts
        animal.update_active_litters(dbo)

        # Find any missing person geocodes
        person.update_missing_geocodes(dbo)

        # Clear out any old audit logs
        audit.clean(dbo)

        # Remove old publisher logs
        dbfs.delete_old_publish_logs(dbo)

        # auto cancel any reservations
        movement.auto_cancel_reservations(dbo)

        # auto cancel animal holds
        animal.auto_cancel_holds(dbo)

        # auto remove online forms
        onlineform.auto_remove_old_incoming_forms(dbo)

        # Update waiting list urgencies and auto remove
        waitinglist.auto_remove_waitinglist(dbo)
        waitinglist.auto_update_urgencies(dbo)

        # See if any new PDFs have been attached that we can scale down
        media.check_and_scale_pdfs(dbo)

        # Email diary notes to users
        diary.email_uncompleted_upto_today(dbo)

    except:
        em = str(sys.exc_info()[0])
        al.error("FAIL: running batch tasks: %s" % em, "cron.daily", dbo, sys.exc_info())

    # We're done, hurrah!
    al.info("end daily tasks", "cron.daily", dbo)
Ejemplo n.º 3
0
Archivo: cron.py Proyecto: rutaq/asm3
def daily(dbo):
    """
    Tasks to run once each day before users login for the day.
    """
    try:
        # The batch should never be run at a time when users may be
        # using the system, remove any database update locks as any
        # lock at this time should be erroneous
        configuration.db_unlock(dbo)

        # Check to see if any updates need performing on this database
        if dbupdate.check_for_updates(dbo):
            ttask(dbupdate.perform_updates, dbo)

        if dbupdate.check_for_view_seq_changes(dbo):
            ttask(dbupdate.install_db_views, dbo)
            ttask(dbupdate.install_db_sequences, dbo)
            ttask(dbupdate.install_db_stored_procedures, dbo)

        # Get the latest news from sheltermanager.com
        configuration.asm_news(dbo, update=True)

        # Update on shelter and foster animal location fields
        ttask(animal.update_on_shelter_animal_statuses, dbo)
        ttask(animal.update_foster_animal_statuses, dbo)

        # Update on shelter animal variable data (age, time on shelter, etc)
        ttask(animal.update_on_shelter_variable_animal_data, dbo)

        # Update variable data for young offshelter animals
        ttask(animal.update_offshelter_young_variable_animal_data, dbo)

        # Update animal figures for reports
        ttask(animal.update_animal_figures, dbo)
        ttask(animal.update_animal_figures_annual, dbo)

        # Update waiting list urgencies and auto remove
        ttask(waitinglist.auto_remove_waitinglist, dbo)
        ttask(waitinglist.auto_update_urgencies, dbo)

        # Email diary notes to users
        ttask(diary.email_uncompleted_upto_today, dbo)

        # Update animal litter counts
        ttask(animal.update_active_litters, dbo)

        # Find any missing person geocodes
        ttask(person.update_missing_geocodes, dbo)

        # Clear out any old audit logs
        ttask(audit.clean, dbo)

        # Remove old publisher logs
        ttask(publish.delete_old_publish_logs, dbo)

        # auto cancel any reservations
        ttask(movement.auto_cancel_reservations, dbo)

        # auto cancel animal holds
        ttask(animal.auto_cancel_holds, dbo)

        # auto remove online forms
        ttask(onlineform.auto_remove_old_incoming_forms, dbo)

        # auto anonymise expired personal data
        ttask(person.update_anonymise_personal_data, dbo)

        # auto remove expired media items
        ttask(media.remove_expired_media, dbo)

        # auto update clinic statuses
        ttask(clinic.auto_update_statuses, dbo)

        # Update the generated looking for report
        ttask(person.update_lookingfor_report, dbo)

        # Update the generated lost/found match report
        ttask(lostfound.update_match_report, dbo)

        # Email any reports set to run with batch
        ttask(extreports.email_daily_reports, dbo)

        # Send fosterer medical reports
        ttask(movement.send_fosterer_emails, dbo)

    except:
        em = str(sys.exc_info()[0])
        al.error("FAIL: running batch tasks: %s" % em, "cron.daily", dbo,
                 sys.exc_info())
Ejemplo n.º 4
0
Archivo: cron.py Proyecto: magul/asm3
def daily(dbo):
    """
    Tasks to run once each day before users login for the day.
    """
    al.info("start daily tasks", "cron.daily", dbo)

    try:
        # The batch should never be run at a time when users may be
        # using the system, remove any database update locks as any
        # lock at this time should be erroneous
        configuration.db_unlock(dbo)

        try:
            # Check to see if any updates need performing on this database
            if dbupdate.check_for_updates(dbo):
                dbupdate.perform_updates(dbo)
            if dbupdate.check_for_view_seq_changes(dbo):
                dbupdate.install_db_views(dbo)
                dbupdate.install_db_sequences(dbo)
            # Get the latest news from sheltermanager.com
            dbfs.update_asm_news(dbo)
        except:
            em = str(sys.exc_info()[0])
            al.error("FAIL: running database preparation tasks: %s" % em, "cron.daily", dbo, sys.exc_info())

        try:
            # Update on shelter and foster animal location fields
            animal.update_on_shelter_animal_statuses(dbo)
            animal.update_foster_animal_statuses(dbo)
        except:
            em = str(sys.exc_info()[0])
            al.error("FAIL: running animal update tasks: %s" % em, "cron.daily", dbo, sys.exc_info())

        try:
            # Update all animal variable data (age, time on shelter, etc)
            animal.update_all_variable_animal_data(dbo)
        except:
            em = str(sys.exc_info()[0])
            al.error("FAIL: running variable data update: %s" % em, "cron.daily", dbo, sys.exc_info())

        try:
            # Update animal figures for reports
            animal.update_animal_figures(dbo)
            animal.update_animal_figures_annual(dbo)
            animal.update_animal_figures_asilomar(dbo)
            animal.update_animal_figures_monthly_asilomar(dbo)
        except:
            em = str(sys.exc_info()[0])
            al.error("FAIL: running animal figures: %s" % em, "cron.daily", dbo, sys.exc_info())

        try:
            # Update waiting list urgencies and auto remove
            waitinglist.auto_remove_waitinglist(dbo)
            waitinglist.auto_update_urgencies(dbo)
        except:
            em = str(sys.exc_info()[0])
            al.error("FAIL: running waiting list tasks: %s" % em, "cron.daily", dbo, sys.exc_info())

        # Email diary notes to users
        diary.email_uncompleted_upto_today(dbo)

        # Update animal litter counts
        animal.update_active_litters(dbo)

        # Find any missing person geocodes
        person.update_missing_geocodes(dbo)

        # Clear out any old audit logs
        audit.clean(dbo)

        # Remove old publisher logs
        dbfs.delete_old_publish_logs(dbo)

        # auto cancel any reservations
        movement.auto_cancel_reservations(dbo)

        # auto cancel animal holds
        animal.auto_cancel_holds(dbo)

        # auto remove online forms
        onlineform.auto_remove_old_incoming_forms(dbo)

        # See if any new PDFs have been attached that we can scale down
        if SCALE_PDF_DURING_BATCH:
            media.check_and_scale_pdfs(dbo)

    except:
        em = str(sys.exc_info()[0])
        al.error("FAIL: running batch tasks: %s" % em, "cron.daily", dbo, sys.exc_info())

    # We're done, hurrah!
    al.info("end daily tasks", "cron.daily", dbo)