def get_refcat_id(filename): logger.debug("Extracting reference image id from {filename}".format(filename=filename)) with open_fits(filename) as infile: header = infile[0].header try: return header["agrefimg"] except KeyError: logger.exception( """No autoguider reference image found in file %s. Assuming this is ok and continuing.""", filename, ) raise NoAutoguider
def watcher_loop_step(connection): # Starts transaction for job_queue table, short lived so Paladin should not # have a write lock with transaction(connection) as cursor: transmission_jobs = fetch_transmission_jobs(cursor) njobs = len(transmission_jobs) logger.info("Found %s jobs", njobs) # Separate transaction for updating transmission database with transaction(connection) as cursor: for i, transmission_job in enumerate(transmission_jobs): logger.info("Job %d/%d", i + 1, njobs) try: transmission_job.update(cursor) except Exception as e: logger.exception("Exception occurred: %s", str(e)) else: transmission_job.remove_from_database(cursor)
def watcher(connection): logger.info("Starting watcher") logger.debug("Connecting to central hub") hub = Pyro4.Proxy("PYRONAME:central.hub") try: hub.startThread("Transparency") except Exception as err: logger.exception("Cannot connect to pyro hub") raise while True: try: logger.debug("Pinging hub") hub.update_transp(time.time()) except Exception as err: logger.exception("Failure communicating with hub process") raise with time_context(): watcher_loop_step(connection) logger.debug("Sleeping for %s seconds", SLEEP_TIME) time.sleep(SLEEP_TIME)