Exemplo n.º 1
0
def auto_execute(uuid, s=None, controller_data=None, text=None, app_uuid=None):
    if controller_data is None or text is None or app_uuid is None:
        pass
    else:
        controller_data = json.loads(controller_data)

        if Auto().is_json(text):
            controller_data[app_uuid] = {"text": json.dumps(text)}
        else:
            controller_data[app_uuid] = {"text": str(text)}

        Workflow.where('uuid', uuid).update({
            'controller_data': json.dumps(controller_data),
            'update_time': Time.get_date_time()
        })

    def thread_exec():
        async def run():
            await asyncio.gather(Auto(socket=s).run(uuid=uuid))

        try:
            asyncio.run(run())
        except RuntimeError:
            asyncio.gather(Auto(socket=s).run(uuid=uuid))

    t = threading.Thread(target=thread_exec)
    t.setDaemon(True)
    t.start()
Exemplo n.º 2
0
def auto_execute(uuid, s=None, controller_data=None, text=None, app_uuid=None):
    if controller_data is None or text is None or app_uuid is None:
        pass
    else:
        controller_data = json.loads(controller_data)
        controller_data[app_uuid] = {"text": str(text)}
        Workflow.where('uuid', uuid).update({
            'controller_data': json.dumps(controller_data),
            'update_time': Time.get_date_time()
        })

    async def run():
        await asyncio.gather(Auto(socket=s).run(uuid=uuid))

    try:
        asyncio.run(run())
    except RuntimeError as e:
        asyncio.gather(Auto(socket=s).run(uuid=uuid))