(self, data)
| 117 | print("error::MointeringClass.__init__>>", sys.exc_info()[1]) |
| 118 | |
| 119 | def _dataProcessing(self, data): |
| 120 | loop = asyncio.get_event_loop() |
| 121 | userdata = [] |
| 122 | try: |
| 123 | if not isinstance(data, dict): |
| 124 | raise Exception |
| 125 | media_post = data["tag"]["media"]["nodes"] |
| 126 | top_post = data["tag"]["top_posts"]["nodes"] |
| 127 | print("media post ::", len(media_post)) |
| 128 | print("top_post::", len(top_post)) |
| 129 | futures = [] |
| 130 | for i in media_post: |
| 131 | tempdict = {} |
| 132 | tempdict["url"] = "https://www.instagram.com/p/" + i["code"] + "/" |
| 133 | tempdict["code"] = i["code"] |
| 134 | userdata.append(tempdict) |
| 135 | for i in top_post: |
| 136 | tempdict = {} |
| 137 | tempdict["url"] = "https://www.instagram.com/p/" + i["code"] + "/" |
| 138 | tempdict["code"] = i["code"] |
| 139 | userdata.append(tempdict) |
| 140 | for i in userdata: |
| 141 | i["future"] = asyncio.Future() |
| 142 | futures.append(i["future"]) |
| 143 | asyncio.ensure_future(datapullpost(future=i["future"], url=i["url"])) |
| 144 | loop.run_until_complete(asyncio.wait(futures)) |
| 145 | for i in userdata: |
| 146 | i["data"] = i["future"].result() |
| 147 | except Exception as err: |
| 148 | print(f"Exception ! : {err}") |
| 149 | print("error::Monitering.dataProcessing>>", sys.exc_info()[1]) |
| 150 | finally: |
| 151 | # loop.close() |
| 152 | print("userdata::", len(userdata)) |
| 153 | print("media_post::", len(media_post)) |
| 154 | print("top post::", len(top_post)) |
| 155 | return userdata, media_post, top_post |
| 156 | |
| 157 | def _insertFunction(self, record): |
| 158 | try: |
no test coverage detected