Exemplo n.º 1
0
def getGPlacesApi(date_now):
    get_gplaces_api = getApi(date_now, 'google_places')
    gplaces_api = pgsql.fetchone(get_gplaces_api)
    if gplaces_api == None:
        raise Exception(
            "Daily Google Places API query limit reached! Please retry tomorrow at 12:00 AM Pacific Time or increase your daily query limit.")
    else:
        return gplaces_api
Exemplo n.º 2
0
def checkDate():
    create_count_table = makeApiCountTable()
    pgsql.execScalar(create_count_table)
    date_now = dateNow()
    check_date = pgsql.fetchone(getDate(date_now))
    update_api_status = updateApiStatus(date_now)
    pgsql.execScalar(update_api_status)
    if check_date == None:
        insert_api = insertApi(date_now)
        pgsql.execScalar(insert_api)
    else:
        pass
    return date_now
Exemplo n.º 3
0
def main(argv):
    #get argument
    arg = get_arg(argv)
    working_folder = arg[0]
    table_name = arg[1]

    #making table
    match = '_matching'
    open_table_stringmatchingconcat = table_name + match
    making_table_stringmatchingconcat(open_table_stringmatchingconcat)

    #log_file
    log_file = working_folder + table_name + ".log"

    #first logging
    logger.logger(log_file, 'info', 'Input folder is: %s' % working_folder)
    logger.logger(log_file, 'info', 'Output table is: %s' % table_name)

    #run data_prep
    logger.logger(log_file, 'info',
                  '==========DATA PREPARATION IS RUNNING==========')
    start = time()
    data_prep.main(table_name, working_folder, log_file)
    end = time()
    print("\nDATA PREPARATION DONE IN %s SECOND==========" % (end - start))
    logger.logger(
        log_file, 'info',
        "==========DATA PREPARATION DONE IN %s SECOND==========" %
        (end - start))

    #run geocode and matching
    logger.logger(log_file, 'info',
                  '==========GEOCODE AND MATCHING IS RUNNING==========')
    start = time()
    check = active_record.checkGeocodeCount(table_name)
    data = pgsql.fetchone(check)
    jml_row = data[0]
    part = 0
    while jml_row >= 1:
        part += 1
        print('RUN PART %s' % part)
        run(table_name, working_folder, log_file,
            open_table_stringmatchingconcat)
        jml_row -= 100
    end = time()
    print("\n==========GEOCODE AND MATCHING DONE IN %s SECOND==========" %
          (end - start))
    logger.logger(
        log_file, 'info',
        "==========GEOCODE AND MATCHING DONE IN %s SECOND==========" %
        (end - start))