[chuck-users] chuck - python
DANIEL MAGNUSZEWSKI
dmagnuszewski at mandtbank.com
Wed Apr 12 10:14:04 EDT 2006
I believe the command that you are looking for is:
%> chuck ^
This prints the internal shred start at the listener VM, something
like:
[chuck](VM): status (now == 0h:2m:34s) ...
[shred id]: 1 [source]: foo.ck [sporked]: 21.43s ago
[shred id]: 2 [source]: bar.ck [sporked]: 28.37s ago
(From: http://chuck.cs.princeton.edu/doc/program/otfp.html)
I am doing something similar in Perl, so perhaps I can help you out.
You can have your python script run this command on the shell (what OS
are you running?) and grab the results (shred id, filename, etc) within
that script. In Perl, it is done with the following code:
@cmd_output = `chuck ^`;
Then you can parse out the id number and run the following commands
from the script to:
Remove a shred ID:
%> chuck - $shred_id
_or_
Add:
%> chuck + $shred_id
_or_
Replace:
%> chuck = $shred_id
In Perl, assuming the above status output, the whole thing would look
something like:
# Get output from the chuck status command
@cmd_output = `chuck ^`;
# Parse IDs into shred_ids array
@shred_ids = grep { /shred id\]:\s(\d+)\s/; $_ = $1 } @cmd_output;
# Remove shred ID 1 (which is in the first array element) from the VM
`chuck - $shred_ids[0]`;
I hope this helps!
-Dan
>>> x at branwelt.de 04/07/06 6:24 AM >>>
Hello
I want to write a python program, that
adds and removes (sporks) chuck-shreds to/from the chuck VM
How to retrieve the shred-id ?
What would be the best way to do so?
Thanks,
Emanuel
_______________________________________________
chuck-users mailing list
chuck-users at lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
More information about the chuck-users
mailing list