2024-07-08 18:33:18 -07:00
|
|
|
import asyncio
|
|
|
|
|
import time
|
|
|
|
|
import logging
|
|
|
|
|
from e2b import AsyncSandbox, Sandbox
|
2024-07-05 18:12:28 -07:00
|
|
|
|
|
|
|
|
import dotenv
|
|
|
|
|
|
|
|
|
|
dotenv.load_dotenv()
|
|
|
|
|
|
2024-07-08 18:33:18 -07:00
|
|
|
logging.basicConfig(level=logging.ERROR)
|
2024-06-11 13:11:36 +02:00
|
|
|
|
|
|
|
|
|
2024-07-08 18:33:18 -07:00
|
|
|
async def main():
|
2024-08-06 15:47:03 +02:00
|
|
|
sbx = await AsyncSandbox.create(timeout=10, debug=True)
|
|
|
|
|
await sbx.files.make_dir("test")
|
|
|
|
|
with open("Makefile", "rb") as f, open("Makefile", "rb") as f2:
|
|
|
|
|
await sbx.files.write("/home/user/test/a.txt", f, f2)
|
|
|
|
|
print(await sbx.files.list("test"))
|
|
|
|
|
print(await sbx.files.list("/home/user/test"))
|
2024-07-09 00:20:46 -07:00
|
|
|
# for _ in range(10):
|
|
|
|
|
# start = time.time()
|
|
|
|
|
# end = time.time()
|
|
|
|
|
# print(f"Time taken: {end - start}")
|
2024-07-05 18:12:28 -07:00
|
|
|
|
|
|
|
|
|
2024-07-08 18:33:18 -07:00
|
|
|
if __name__ == "__main__":
|
|
|
|
|
asyncio.run(main())
|