def maint_db_reinstall(dbo): try: dbupdate.reinstall_default_data(dbo) except: em = str(sys.exc_info()[0]) al.error("FAIL: uncaught error running maint_db_reinstall: %s" % em, "cron.maint_db_reinstall", dbo, sys.exc_info())
def maint_variable_data(dbo): try: animal.update_all_variable_animal_data(dbo) except: em = str(sys.exc_info()[0]) al.error("FAIL: uncaught error running maint_variable_data: %s" % em, "cron.maint_variable_data", dbo, sys.exc_info())
def maint_recode_shelter(dbo): try: animal.maintenance_reassign_shelter_codes(dbo) except: em = str(sys.exc_info()[0]) al.error("FAIL: uncaught error running maint_recode_shelter: %s" % em, "cron.maint_recode_shelter", dbo, sys.exc_info())
def publish_3pty_sub24(dbo): try: publishers = configuration.publishers_enabled(dbo) freq = configuration.publisher_sub24_frequency(dbo) hournow = dbo.now().hour al.debug("chosen freq %s, current hour %s" % (freq, hournow), "cron.publish_3pty_sub24", dbo) if freq == 0: return # 24 hour mode is covered by regular publish_3pty with the batch elif freq == 2 and hournow not in [ 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22 ]: return elif freq == 4 and hournow not in [1, 5, 9, 13, 17, 21]: return elif freq == 6 and hournow not in [3, 9, 13, 19]: return elif freq == 8 and hournow not in [1, 9, 17]: return elif freq == 12 and hournow not in [0, 12]: return for p in publishers.split(" "): if p in publish.PUBLISHER_LIST and publish.PUBLISHER_LIST[p][ "sub24hour"]: publish.start_publisher(dbo, p, user="******", newthread=False) except: em = str(sys.exc_info()[0]) al.error( "FAIL: uncaught error running sub24 third party publishers: %s" % em, "cron.publish_3pty_sub24", dbo, sys.exc_info())
def maint_db_reset(dbo): try: dbupdate.reset_db(dbo) except: em = str(sys.exc_info()[0]) al.error("FAIL: uncaught error running maint_db_reset: %s" % em, "cron.maint_db_reset", dbo, sys.exc_info())
def maint_disk_cache(dbo): try: cachedisk.remove_expired(dbo.database) except: em = str(sys.exc_info()[0]) al.error("FAIL: uncaught error running remove_expired: %s" % em, "cron.maint_disk_cache", dbo, sys.exc_info())
def maint_scale_pdfs(dbo): try: media.scale_all_pdf(dbo) except: em = str(sys.exc_info()[0]) al.error("FAIL: uncaught error running maint_scale_pdfs: %s" % em, "cron.maint_scale_pdfs", dbo, sys.exc_info())
def maint_db_dump_merge(dbo): try: print(dbupdate.dump_merge(dbo)) except: em = str(sys.exc_info()[0]) al.error("FAIL: uncaught error running maint_db_dump_merge: %s" % em, "cron.maint_db_dump_merge", dbo, sys.exc_info())
def maint_db_dump_smcom(dbo): try: for x in dbupdate.dump_smcom(dbo): print(utils.cunicode(x).encode("utf-8")) except: em = str(sys.exc_info()[0]) al.error("FAIL: uncaught error running maint_db_dump: %s" % em, "cron.maint_db_dump_smcom", dbo, sys.exc_info())
def maint_db_dump_smcom(dbo): try: for x in dbupdate.dump_smcom(dbo): print(x) except: em = str(sys.exc_info()[0]) al.error("FAIL: uncaught error running maint_db_dump_smcom: %s" % em, "cron.maint_db_dump_smcom", dbo, sys.exc_info())
def maint_switch_dbfs_storage(dbo): try: dbfs.switch_storage(dbo) except: em = str(sys.exc_info()[0]) al.error( "FAIL: uncaught error running maint_dbfs_switch_storage: %s" % em, "cron.maint_switch_dbfs_storage", dbo, sys.exc_info())
def maint_db_delete_orphaned_media(dbo): try: dbfs.delete_orphaned_media(dbo) except: em = str(sys.exc_info()[0]) al.error( "FAIL: uncaught error running maint_db_delete_orphaned_media: %s" % em, "cron.maint_db_delete_orphaned_media", dbo, sys.exc_info())
def maint_deduplicate_people(dbo): try: person.merge_duplicate_people(dbo, "cron") except: em = str(sys.exc_info()[0]) al.error( "FAIL: uncaught error running maint_deduplicate_people: %s" % em, "cron.maint_deduplicate_people", dbo, sys.exc_info())
def maint_db_replace_html_entities(dbo): try: dbupdate.replace_html_entities(dbo) except: em = str(sys.exc_info()[0]) al.error( "FAIL: uncaught error running maint_db_replace_html_entities: %s" % em, "cron.maint_db_replace_html_entities", dbo, sys.exc_info())
def maint_db_fix_preferred_photos(dbo): try: d = dbupdate.fix_preferred_photos(dbo) print("Fixed %d" % d) except: em = str(sys.exc_info()[0]) al.error( "FAIL: uncaught error running maint_db_fix_preferred_photos: %s" % em, "cron.maint_db_fix_preferred_photos", dbo, sys.exc_info())
def maint_db_reinstall_default_onlineforms(dbo): try: dbupdate.install_default_onlineforms(dbo, True) except: em = str(sys.exc_info()[0]) al.error( "FAIL: uncaught error running maint_db_reinstall_default_onlineforms: %s" % em, "cron.maint_db_reinstall_default_onlineforms", dbo, sys.exc_info())
def maint_db_diagnostic(dbo): try: d = dbupdate.diagnostic(dbo) for k, v in d.items(): print("%s: %s" % (k, v)) except: em = str(sys.exc_info()[0]) al.error("FAIL: uncaught error running maint_db_diagnostic: %s" % em, "cron.maint_db_diagnostic", dbo, sys.exc_info())
def maint_animal_figures_annual(dbo): try: animal.maintenance_animal_figures(dbo, includeMonths=False, includeAnnual=True) except: em = str(sys.exc_info()[0]) al.error( "FAIL: uncaught error running maint_animal_figures_annual: %s" % em, "cron.maint_animal_figures_annual", dbo, sys.exc_info())
def maint_animal_figures(dbo): try: animal.update_all_animal_statuses(dbo) animal.update_all_variable_animal_data(dbo) animal.maintenance_animal_figures(dbo, includeMonths=True, includeAnnual=True) except: em = str(sys.exc_info()[0]) al.error("FAIL: uncaught error running maint_animal_figures: %s" % em, "cron.maint_animal_figures", dbo, sys.exc_info())
def maint_db_dump_personcsv(dbo): try: print( utils.csv( dbo.locale, person.get_person_find_simple(dbo, "", "all", True, True, 0))) except: em = str(sys.exc_info()[0]) al.error( "FAIL: uncaught error running maint_db_dump_personcsv: %s" % em, "cron.maint_db_dump_personcsv", dbo, sys.exc_info())
def publish_3pty(dbo): try: publishers = configuration.publishers_enabled(dbo) for p in publishers.split(" "): if p != "html": # We do html/ftp publishing separate from others publish.start_publisher(dbo, p, user="******", newthread=False) except: em = str(sys.exc_info()[0]) al.error( "FAIL: uncaught error running third party publishers: %s" % em, "cron.publish_3pty", dbo, sys.exc_info())
def publish_html(dbo): try: if configuration.publishers_enabled(dbo).find("html") != -1: publish.start_publisher(dbo, "html", user="******", newthread=False) except: em = str(sys.exc_info()[0]) al.error("FAIL: uncaught error running html publisher: %s" % em, "cron.publish_html", dbo, sys.exc_info())
def reports_email(dbo): """ Batch email reports """ try: # Email any daily reports for local time of now extreports.email_daily_reports(dbo, dbo.now()) except: em = str(sys.exc_info()[0]) al.error("FAIL: running daily email of reports_email: %s" % em, "cron.reports_email", dbo, sys.exc_info())
def maint_import_report(dbo): try: extreports.install_smcom_report_file(dbo, "system", os.environ["ASM3_REPORT"]) print("OK") except: em = str(sys.exc_info()[0]) print( em ) # This one is designed to be run from the command line rather than cron al.error("FAIL: uncaught error running import report: %s" % em, "cron.maint_import_report", dbo, sys.exc_info())
def publish_3pty(dbo): try: publishers = configuration.publishers_enabled(dbo) freq = configuration.publisher_sub24_frequency(dbo) for p in publishers.split(" "): # Services that we do more frequently than 24 hours are handled by 3pty_sub24 if publish.PUBLISHER_LIST[p]["sub24hour"] and freq != 0: continue # We do html/ftp publishing separate from other publishers if p == "html": continue publish.start_publisher(dbo, p, user="******", newthread=False) except: em = str(sys.exc_info()[0]) al.error( "FAIL: uncaught error running third party publishers: %s" % em, "cron.publish_3pty", dbo, sys.exc_info())
def maint_db_dump_animalcsv(dbo): try: print( utils.csv( dbo.locale, animal.get_animal_find_advanced( dbo, { "logicallocation": "all", "includedeceased": "true", "includenonshelter": "true" }))) except: em = str(sys.exc_info()[0]) al.error( "FAIL: uncaught error running maint_db_dump_animalcsv: %s" % em, "cron.maint_db_dump_animalcsv", dbo, sys.exc_info())
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())
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) # 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())