예제 #1
0
def fetch_wunderground(self, station, date):
    try:
        logger.info("Fetching {}".format(station))
        data = capture_date_range(station, date)
        # data = [datum]
    except Exception as e:
        logger.error("Error fetching from {} at {}: {}".format(station, date, e))
    try:
        logger.info("Saving {}".format(station))
        if len(data) > 0:
            save(data, schema="Municipio", table="Clima_wu")
    except Exception as e:
        logger.error("Error saving to db with {} at {}: {}".format(station, date, e))
예제 #2
0
def fetch_redemet(self, station, date):
    data = []
    try:
        logger.info("Fetching {}".format(station))
        if isinstance(date, str):
            date = datetime.strptime(date.split('T')[0], "%Y-%m-%d")
        data = capture_date_range(station, date)
    except Exception as e:
        logger.error("Error fetching from {} at {}: {}".format(station, date, e))
    try:
        logger.info("Saving {}".format(station))
        if len(data) > 0:
            save(data, schema='Municipio', table='Clima_wu')
    except Exception as e:
        logger.error("Error saving to db with {} at {}: {}".format(station, date, e))
예제 #3
0
def fetch_wunderground(self, station, date):
    try:
        logger.info("Fetching {}".format(station))
        data = capture_date_range(station, date)
        # data = [datum]
    except Exception as e:
        logger.error("Error fetching from {} at {}: {}".format(
            station, date, e))
    try:
        logger.info("Saving {}".format(station))
        if len(data) > 0:
            save(data, schema='Municipio', table='Clima_wu')
    except Exception as e:
        logger.error("Error saving to db with {} at {}: {}".format(
            station, date, e))
예제 #4
0
def fetch_redemet(self, station, date):
    data = []
    try:
        logger.info("Fetching {}".format(station))
        if isinstance(date, str):
            date = datetime.strptime(date.split('T')[0], "%Y-%m-%d")
        data = capture_date_range(station, date)
    except Exception as e:
        logger.error("Error fetching from {} at {}: {}".format(
            station, date, e))
    try:
        logger.info("Saving {}".format(station))
        if len(data) > 0:
            save(data, schema='Municipio', table='Clima_wu')
    except Exception as e:
        logger.error("Error saving to db with {} at {}: {}".format(
            station, date, e))
예제 #5
0
def fetch_redemet(self, station, date):
    data = []
    try:
        logger.info("Fetching {}".format(station))
        if isinstance(date, str):
            date = datetime.strptime(date.split("T")[0], "%Y-%m-%d")
        data = capture_date_range(station, date)
    except Exception as e:
        logger.error(
            "Error fetching from {} at {} data is {}: error: {}".format(
                station, date, data, e
            )
        )
        return
    try:
        if len(data) > 0:
            save(data, schema="Municipio", table="Clima_wu")
            logger.info("Saving {}".format(station))
        else:
            logger.info("No data found {}".format(station))
    except Exception as e:
        logger.error(
            "Error saving to db with {} at {}: {}".format(station, date, e)
        )
예제 #6
0
parser.add_argument("--codigo",
                    "-c",
                    choices=codes,
                    metavar="ICAO",
                    help="Codigo da estação")
args = parser.parse_args()

station, start, end = args.codigo, args.inicio, args.fim
data = []
i = 0

stations = codes if station == "all" else [station]
for station in stations:
    if station == "all":
        continue
    for date in date_generator(start, end):
        if not check_day(date, station):
            print("Date {} has already been captured from station {} ".format(
                date, station))
            continue
        print("Fetching data from {} at {}.".format(station, date))
        res = capture(station, date)
        print(res)
        data.append(res)
        if i % 10 == 0:
            save(data, schema="Municipio", table="Clima_wu")
            data = []
        time.sleep(1)

save(data, schema="Municipio", table="Clima_wu")
예제 #7
0
date = lambda d: datetime.strptime(d, "%Y-%m-%d")

parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--inicio", "-i", type=date, help="Data inicial de captura: yyyy-mm-dd")
parser.add_argument("--fim", "-f", type=date, help="Data final de captura: yyyy-mm-dd")
parser.add_argument("--codigo", "-c", choices=codes, metavar='ICAO', help="Codigo da estação" )
args = parser.parse_args()

station, start, end = args.codigo, args.inicio, args.fim
data = []
i = 0

stations = codes if station == 'all' else [station]
for station in stations:
    if station == 'all':
        continue
    for date in date_generator(start, end):
        if not check_day(date, station):
            print("Date {} has already been captured from station {} ".format(date, station))
            continue
        print("Fetching data from {} at {}.".format(station, date))
        res = capture(station, date)
        print(res)
        data.append(res)
        if i % 10 == 0:
            save(data, schema='Municipio', table='Clima_wu')
            data = []
        time.sleep(1)

save(data, schema='Municipio', table='Clima_wu')
예제 #8
0
parser.add_argument("--codigo",
                    "-c",
                    choices=codes,
                    metavar='ICAO',
                    help="Codigo da estação")
args = parser.parse_args()

station, start, end = args.codigo, args.inicio, args.fim
data = []
i = 0

stations = codes if station == 'all' else [station]
for station in stations:
    if station == 'all':
        continue
    for date in date_generator(start, end):
        if not check_day(date, station):
            print("Date {} has already been captured from station {} ".format(
                date, station))
            continue
        print("Fetching data from {} at {}.".format(station, date))
        res = capture(station, date)
        print(res)
        data.append(res)
        if i % 10 == 0:
            save(data, schema='Municipio', table='Clima_wu')
            data = []
        time.sleep(1)

save(data, schema='Municipio', table='Clima_wu')