anishathalye / seashells

The official client for seashells.io 🐚
https://seashells.io
MIT License
709 stars 20 forks source link

Use seashells in code #5

Closed hemulin closed 6 years ago

hemulin commented 7 years ago

Hi and thank you for this great project.

After running for a while with

python my_script --some-flags-here 2>&1 | tee >(seashells)

I decided to add a better monitoring functionality. When I pass a --monitor flag, I want the script to launch a seashells instance (and send me the link to the webpage over some messaging app - done already) and then launch the script itself. So far I wasn't able to make it happen...

Given that the seashells is a locking process (while True: ...), I've tried with threading. So, on one thread, acquiring a lock before writing (printing script logs and tqdm progressbar), and releasing after write. And on another thread, from a slightly modified seashells main(console_lock), acquire the lock, read the stdin, release the lock and sleep for a second. This doesn't work.

Can you please suggest how can I accomplish this?

anishathalye commented 6 years ago

The Python seashells client is currently only designed to be a CLI program, not a library, but it sounds like you need something more like a library.

Perhaps you want to directly integrate Seashells into your program? E.g. you can write code that opens a socket connection to the Seashells server, waits to receive a URL, does something with it (e.g. sending over a messaging app), and then gives you a log() function that e.g. prints the output and also sends it over the socket to the Seashells server.