def process(event: Dict[str, Any]) -> Dict[str, Any]: task_id = event["pathParameters"]["task_id"] db_item = task_table.get_item(Key={ "task_id": task_id, }, ) if db_item is None or "Item" not in db_item: raise Exception( f"Task with id {task_id} doesn't exist. Cannot close this task.") task = TaskAssignment.from_json(db_item["Item"]) if task.status != Status.FINISHED: raise Exception(f"Tasks in status {task.status} cannot be closed.") task.status = Status.CLOSED task.active = False json_task = task.to_json() task_table.put_item(Item=json_task, ) notify(task) return { "statusCode": 200, "body": json.dumps(json_task), }
def process(event: Dict[str, Any]) -> Dict[str, Any]: task = TaskAssignment.from_json(event["body"]) task.status = Status.IN_PROGRESS task.active = True task.task_id = str(uuid.uuid4()) json_task = task.to_json() task_table.put_item(Item=json_task, ) notify(task) return { "statusCode": 200, "body": json.dumps(json_task), }
try: p2_home = int( driver.find_element_by_xpath( "//div[@id='live-table']//div[@class='event']//div[@class='event__match event__match--live event__match--twoLine']//div[@class='event__part event__part--home event__part--2']" ).text) p2_gst = int( driver.find_element_by_xpath( "//div[@id='live-table']//div[@class='event']//div[@class='event__match event__match--live event__match--twoLine']//div[@class='event__part event__part--away event__part--2']" ).text) time2 = True except NoSuchElementException: pass # super complex strategy print('LOG: Cheking...') if cf_home < cf_guest: if p1_gst - p1_home >= 5: notify(name, home, guest, 'П1') print("LOG: " + home + ' is about to win!') elif cf_guest < cf_home: if p1_home - p1_gst >= 5: notify(name, home, guest, 'П2') print("LOG: " + guest + ' is about to win!') sleep(2100)
def __send_notification(sensor_data): # Se le envian las lecturas del sensor a notificator.py para enviar una notificación al usuario notificator.notify(sensor_data)