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()
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()
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()
# 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/
def api_hdfc_bond(): LOGGER.info("hdfc bond fund growth api call") info = HtmlParser2.call_hdfc_api() return jsonify(info.serialize())
def api_fuel(): info = HtmlParser2.call_fuel_api() return jsonify(info.serialize())
def api_gold(): info = HtmlParser2.call_gold_api() return jsonify(info.serialize())
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)
def api_weather(location): LOGGER.info("weather.location" + location) info = HtmlParser2.call_weather_api(location) return jsonify(info.serialize())