Ejemplo n.º 1
0
def try_to_parse(start: str, end: str, tries: int,
                 scraper: scrapers.FakeScraper) -> str:
    """
    Parses filings and settings between start and end dates.

    Tries `tries` times before giving up.
    If all attempts fail, returns the start and end date, otherwise returns 'success'.
    """

    for attempt in range(1, tries + 1):
        try:
            parse_filings.parse_filings_on_cloud(afterdate=start,
                                                 beforedate=end,
                                                 get_old_active=False,
                                                 scraper=scraper)
            parse_settings.parse_settings_on_cloud(afterdate=start,
                                                   beforedate=end,
                                                   write_to_sheets=False,
                                                   scraper=scraper)
            logger.info(Fore.GREEN +
                        "Successfully parsed filings and settings " +
                        f"between {start} and {end} on attempt {attempt}.\n" +
                        Style.RESET_ALL)

            return "success"
        except Exception as error:
            if attempt == tries:
                logger.error(f"Error message: {error}")

    message = f"{start}, {end}"
    logger.error(Fore.RED +
                 f"Failed to parse filings and settings between {start} " +
                 f"and {end} on all {tries} attempts.\n" + Style.RESET_ALL)
    return message
Ejemplo n.º 2
0
def try_to_parse(start, end, tries):
    for attempt in range(1, tries + 1):
        try:
            parse_filings_on_cloud(start, end, get_old_active=False)
            parse_settings_on_cloud(start, end)
            logger.info(
                Fore.GREEN +
                f"Successfully parsed filings between {start} and {end} on attempt {attempt}.\n"
                + Style.RESET_ALL)

            return "success"
        except Exception as error:
            if attempt == tries:
                logger.error(f"Error message: {error}")

    message = f"{start}, {end}"
    logger.error(
        Fore.RED +
        f"Failed to parse filings and settings between {start} and {end} on all {tries} attempts.\n"
        + Style.RESET_ALL)
    return message
Ejemplo n.º 3
0
def scrape_settings():
    """Scrapes all case settings data from 7 days ago to 90 days from now and outputs results to PostgreSQL database"""

    ninety_days_later = get_date_from_today("-", 90, "future")
    seven_days_ago = get_date_from_today("-", 7, "past")
    parse_settings.parse_settings_on_cloud(seven_days_ago, ninety_days_later)
Ejemplo n.º 4
0
def scrape_settings():
    ninety_days_later = get_date_from_today("-", 90, "future")
    seven_days_ago = get_date_from_today("-", 7, "past")
    parse_settings_on_cloud(seven_days_ago, ninety_days_later)