Last active
September 9, 2016 20:34
-
-
Save xcombelle/991cf764ddeaf77ba08c3c27880169bf to your computer and use it in GitHub Desktop.
bootstrapping egg-drop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # the idea of the bootstrap proc is that it delegate | |
| # the creation of the dialog between tcl and python | |
| # to the python script so all the protocol always match | |
| # between tcl and python | |
| proc bootstrap {scriptname args} { | |
| set fifo_name /tmp/eggdrop-bootstrap-fifo | |
| set interpreter python3 | |
| exec mkfifo $fifo_name | |
| try { | |
| set command [ | |
| concat [list exec $interpreter $scriptname "--eggdrop-bootstrap-fifo=$fifo_name"] $args | |
| ] | |
| puts $command | |
| eval $command | |
| set fp [open $fifo_name r] | |
| #here is the magic to delegate the protocol creation to the python script | |
| eval [read $fp] | |
| close $fp | |
| } finally { | |
| exec rm $fifo_name | |
| } | |
| } | |
| #usage | |
| bootstrap test.py dummy-arg1 dummy-arg2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I wonder if a pipe shouldn't be abstracted, as some people compile with Cygwin eggdrops to run them on Windows (see http://windrop.sourceforge.net/). We don't need to implement that, but a little abstraction will allow interested people to do it.
concat list is perhaps overkill in this scenario: perhaps this syntax would be more legible (and would avoid an eval):
exec -- $interpreter $scriptname "--eggdrop-bootstrap-fifo=$fifo_name" {*}$argsPer try finally, we will need to document we target TCL 8.6+ (a reasonable requirement)