コード例 #1
0
ファイル: 16x2_lcd_main.py プロジェクト: get4gopim/weatherpy
def call_weather_api(location):
    LOGGER.info("call_weather_api")

    loop = asyncio.new_event_loop()
    asyncio.set_event_loop(loop)

    f1 = asyncio.Future()

    f1.add_done_callback(callback_weather)

    tasks = []
    if util.is_uuid(location):
        tasks.append(HtmlParser2.get_weather(f1, location))
    else:
        tasks.append(HtmlParser2.get_google_weather(f1, location))

    loop.run_until_complete(asyncio.wait(tasks))

    loop.close()
    print()
コード例 #2
0
def call_apis_async(location):
    start = time.time()
    loop = asyncio.get_event_loop()

    f1 = asyncio.Future()

    f1.add_done_callback(callback_weather)

    tasks = []
    if util.is_uuid(location):
        tasks.append(HtmlParser2.get_weather(f1, location))
    else:
        tasks.append(HtmlParser2.get_google_weather(f1, location))

    loop.run_until_complete(asyncio.wait(tasks))

    loop.close()

    LOGGER.info(f'Total Time Taken {time.time() - start}')
    print()
コード例 #3
0
ファイル: 16x2_lcd_main.py プロジェクト: get4gopim/weatherpy
def call_fuel_api():
    LOGGER.info("call_fuel_api")

    loop = asyncio.new_event_loop()
    asyncio.set_event_loop(loop)

    f1 = asyncio.Future()

    f1.add_done_callback(callback_fuel)

    tasks = [HtmlParser2.get_fuel_price(f1)]
    loop.run_until_complete(asyncio.wait(tasks))

    loop.close()
    print()
コード例 #4
0
ファイル: main.py プロジェクト: get4gopim/serverless-api
# This is a sample Python script.

# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
from service import HtmlParser2

def print_hi(name):
    # Use a breakpoint in the code line below to debug your script.
    print(f'Hi, {name}')  # Press Ctrl+F8 to toggle the breakpoint.


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    print_hi('PyCharm')
    info = HtmlParser2.call_hdfc_api()
    print (info)

# See PyCharm help at https://www.jetbrains.com/help/pycharm/
コード例 #5
0
def api_hdfc_bond():
    LOGGER.info("hdfc bond fund growth api call")
    info = HtmlParser2.call_hdfc_api()
    return jsonify(info.serialize())
コード例 #6
0
def api_fuel():
    info = HtmlParser2.call_fuel_api()
    return jsonify(info.serialize())
コード例 #7
0
def api_gold():
    info = HtmlParser2.call_gold_api()
    return jsonify(info.serialize())
コード例 #8
0
def api_forecast(location):
    LOGGER.info("weather.forecast.location" + location)
    f_list = HtmlParser2.call_weather_forecast(location)
    serialized_list = [e.serialize() for e in f_list]
    return jsonify(serialized_list)
コード例 #9
0
def api_weather(location):
    LOGGER.info("weather.location" + location)
    info = HtmlParser2.call_weather_api(location)
    return jsonify(info.serialize())