Add basic enviroment support. Can use env values in prompts right now.

This commit is contained in:
Liu Zhicong
2023-09-04 22:36:59 -07:00
parent 25bba0742a
commit 1bbdf2e722
8 changed files with 340 additions and 23 deletions
+32
View File
@@ -0,0 +1,32 @@
import asyncio
import os
import sys
directory = os.path.dirname(__file__)
sys.path.append(directory + '/../src')
from aios_kernel import CalenderEnvironment,WorkflowEnvironment
async def test_buildin_envs():
c_env = CalenderEnvironment("calender")
c_env.start()
print(c_env.get_value("now"))
async def show_event(eventid,event):
print(event.data)
c_env.attach_event_handler("timer",show_event)
w_env = WorkflowEnvironment("workflow",os.path.abspath(directory + "/../rootfs/workflow_env.db"))
w_env.set_value("test","test_aaaa")
print(w_env.get_value("test"))
await asyncio.sleep(10)
if __name__ == "__main__":
#test_rstr = "abc is {abc}"
#values = {"abc":"123"}
#new_str = test_rstr.format_map(values)
#print(new_str)
asyncio.run(test_buildin_envs())