def main(args):
    if args.verbose:
        logger.setLevel('DEBUG')
    logger.debug(args)

    build_catalogue(
        refimage=args.refimage,
        region_filename=args.refimage + '.reg',
        n_pixels=args.npix,
        threshold=args.threshold,
        fwhmfilt=args.fwhmfilt,
        isolation_radius=args.isolation_radius,
        aperture_radius=args.aperture_radius,
        db_host=args.db_host,
        db_user=args.db_user,
        db_name=args.db_name,
        db_socket=args.db_socket,
        fits_out=args.fits_out,)
    def update(self, cursor):
        try:
            ref_image_id = get_refcat_id(self.real_filename)
        except NoAutoguider:
            # Return early but ensure the job is removed from the database by
            # not propogating the exception
            return

        if not ref_catalogue_exists(cursor, ref_image_id):
            logger.info("Reference catalogue missing, creating")
            ref_image_filename = ref_image_path(ref_image_id, cursor)
            build_catalogue(ref_image_filename, cursor)
        else:
            logger.info("Reference catalogue exists")

        t = TransmissionEntry.from_file(
            self.real_filename, cursor, sky_radius_inner=RADIUS_INNER, sky_radius_outer=RADIUS_OUTER
        )
        t.upload_to_database(cursor)