| 265 | |
| 266 | |
| 267 | class InstaPorcessClass: |
| 268 | def _dbProcessReader(self, user, tags, productId): |
| 269 | value = True |
| 270 | mon = pymongo.MongoClient(host=config.host, port=config.mongoPort) |
| 271 | try: |
| 272 | db = mon["insta_process"] |
| 273 | collection = db["process"] |
| 274 | temp = {} |
| 275 | temp["user"] = user |
| 276 | temp["tags"] = tags |
| 277 | temp["productId"] = productId |
| 278 | records = collection.find(temp).count() |
| 279 | if records == 0: |
| 280 | raise Exception |
| 281 | value = True |
| 282 | except Exception as err: |
| 283 | print(f"exception : {err}\n") |
| 284 | value = False |
| 285 | print("error::dbProcessReader:>>", sys.exc_info()[1]) |
| 286 | finally: |
| 287 | mon.close() |
| 288 | return value |
| 289 | |
| 290 | def _processstart(self, user, tags, productId): |
| 291 | mon = pymongo.MongoClient(host=config.host, port=config.mongoPort) |
| 292 | try: |
| 293 | db = mon["insta_process"] |
| 294 | collection = db["process"] |
| 295 | temp = {} |
| 296 | temp["user"] = user |
| 297 | temp["tags"] = tags |
| 298 | temp["productId"] = productId |
| 299 | collection.insert(temp) |
| 300 | except Exception as err: |
| 301 | print(f"execption : {err}\n") |
| 302 | print("error::processstart>>", sys.exc_info()[1]) |
| 303 | finally: |
| 304 | mon.close() |
| 305 | |
| 306 | def startprocess(self, user, tags, type, productId): |
| 307 | try: |
| 308 | self._processstart(user=user, tags=tags, productId=productId) |
| 309 | while True: |
| 310 | # therad = theradPorcess(user=user, tags=tags, type=type) |
| 311 | # therad.start() |
| 312 | hashtags(user=user, tags=tags, type=type, productId=productId) |
| 313 | check = self._dbProcessReader(user=user, tags=tags, productId=productId) |
| 314 | print(check) |
| 315 | if check == False: |
| 316 | break |
| 317 | time.sleep(300) |
| 318 | # therad.join() |
| 319 | except Exception as err: |
| 320 | print(f"exception : {err}\n") |
| 321 | print("error::startPoress::>>", sys.exc_info()[1]) |
| 322 | |
| 323 | def deletProcess(self, user, tags, productId): |
| 324 | mon = pymongo.MongoClient(host=config.host, port=config.mongoPort) |