From f79cfe42aac5f5cef8865f7a6975f6a430c923a1 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Wed, 15 Apr 2020 23:12:18 -0700 Subject: Use python format strings for args.then --- Que/client.py | 6 ++---- Que/quescripts.md | 8 ++++---- Que/tutorial.md | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Que/client.py b/Que/client.py index f4ee601..1063eb8 100755 --- a/Que/client.py +++ b/Que/client.py @@ -96,9 +96,7 @@ def then(args, msg): if args.then: logging.debug("then") subprocess.run( - args.then.replace(r"\msg", msg).replace(r"\que", args.target), - check=False, - shell=True, + args.then.format(msg=msg, que=args.target), check=False, shell=True, ) @@ -144,7 +142,7 @@ def get_args(): [ "when polling, run this shell command after each response,", "presumably for side effects," - r"replacing '\que' with the target and '\msg' with the body of the response", + r"replacing '{que}' with the target and '{msg}' with the body of the response", ] ), ) diff --git a/Que/quescripts.md b/Que/quescripts.md index 9a2e6e0..77e7004 100644 --- a/Que/quescripts.md +++ b/Que/quescripts.md @@ -10,7 +10,7 @@ the job finishes. In one terminal run the listener: - que pub/notify --then "notify-send '\que' '\msg'" + que pub/notify --then "notify-send '{que}' '{msg}'" In some other terminal run the job that takes forever: @@ -23,9 +23,9 @@ Linux with title "`pub/notify`" and content "`tests are done`". Que paths are multi-producer and multi-consumer, so you can add as many terminals as you want. -On macOS you could use: +On macOS you could use something like this (just watch your quotes): - osascript -e 'display notification "\msg" with title "\que"' + osascript -e "display notification \"{msg}\" with title \"{que}\"" in place of notify-send. @@ -39,7 +39,7 @@ It's surprisingly easy to make a collaborative jukebox. First start up a music player: - que --poll pub/music --then "playsong '\msg'" + que --poll pub/music --then "playsong '{msg}'" where `playsong` is a script that plays a file from data streaming to `stdin`. For example [vlc](https://www.videolan.org/vlc/) does this when diff --git a/Que/tutorial.md b/Que/tutorial.md index 66ecd3c..6542ad3 100644 --- a/Que/tutorial.md +++ b/Que/tutorial.md @@ -50,4 +50,4 @@ To use other namespaces and add authentication/access controls, you can Just reading and writing data isn't very exciting, so let's throw in some events. We can very quickly put together a job processor. - que pub/new-que --then "./worker.sh '\msg'" + que pub/new-que --then "./worker.sh '{msg}'" -- cgit v1.2.3