Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-demosh for openSUSE:Factory checked in at 2024-10-07 21:52:26 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-demosh (Old) and /work/SRC/openSUSE:Factory/.python-demosh.new.19354 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "python-demosh" Mon Oct 7 21:52:26 2024 rev:3 rq:1206048 version:0.6.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-demosh/python-demosh.changes 2024-06-13 15:40:27.435314457 +0200 +++ /work/SRC/openSUSE:Factory/.python-demosh.new.19354/python-demosh.changes 2024-10-07 21:52:50.435774926 +0200 @@ -1,0 +2,6 @@ +Sun Oct 6 07:59:14 UTC 2024 - Johannes Kastl <opensuse_buildservice@ojkastl.de> + +- update to 0.6.0: + no changelog found + +------------------------------------------------------------------- Old: ---- demosh-0.5.0.tar.gz New: ---- demosh-0.6.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-demosh.spec ++++++ --- /var/tmp/diff_new_pack.baufY4/_old 2024-10-07 21:52:51.303811061 +0200 +++ /var/tmp/diff_new_pack.baufY4/_new 2024-10-07 21:52:51.303811061 +0200 @@ -18,7 +18,7 @@ %{?sle15_python_module_pythons} Name: python-demosh -Version: 0.5.0 +Version: 0.6.0 Release: 0 Summary: Run code in Markdown files or shell scripts very interactively License: Apache-2.0 ++++++ demosh-0.5.0.tar.gz -> demosh-0.6.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/demosh-0.5.0/DEVELOPING.md new/demosh-0.6.0/DEVELOPING.md --- old/demosh-0.5.0/DEVELOPING.md 2023-10-30 15:07:45.000000000 +0100 +++ new/demosh-0.6.0/DEVELOPING.md 2024-10-04 22:21:26.000000000 +0200 @@ -17,4 +17,5 @@ - Commit and push. - Tag the pushed commit with the same version that's contained in `__init__.py`, with a leading `v`. - +- Make sure you have a valid PyPI token in `$HOME/.pypi-token`. +- Run `make publish`. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/demosh-0.5.0/Makefile new/demosh-0.6.0/Makefile --- old/demosh-0.5.0/Makefile 2023-10-30 15:07:45.000000000 +0100 +++ new/demosh-0.6.0/Makefile 2024-10-04 22:21:26.000000000 +0200 @@ -13,3 +13,5 @@ mypy lint: mypy demosh +publish: + FLIT_USERNAME="__token__" FLIT_PASSWORD=$$(cat $$HOME/.pypi-token) flit publish diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/demosh-0.5.0/README.md new/demosh-0.6.0/README.md --- old/demosh-0.5.0/README.md 2023-10-30 15:07:45.000000000 +0100 +++ new/demosh-0.6.0/README.md 2024-10-04 22:21:26.000000000 +0200 @@ -6,23 +6,30 @@ a tool for doing live demos of relatively complex things. See `testing.md` and `testing.sh` for examples. +**To exit `demosh`, hit `Q` (capital `Q`).** `demosh` deliberately ignores +signals and won't respond to `control-C` or `control-D`, so that the commands +it runs don't get confused. + <!-- SPDX-FileCopyrightText: 2022-2023 Buoyant, Inc. SPDX-License-Identifier: Apache-2.0 --> -- For instructions on installing `demosh`, see [`INSTALLING.md`](INSTALLING.md). -- If you want to work on `demosh` itself, see [`DEVELOPING.md`](DEVELOPING.md). -- For a demo of `demosh` itself, see [`demo/DEMO.md`](demo/DEMO.md). +**To install `demosh`:** just run `pip install demosh`! or see +[`INSTALLING.md`](INSTALLING.md) if you want to install from source. + +**To use `demosh` to demo itself:** see [`demo/DEMO.md`](demo/DEMO.md). + +**To work on `demosh` itself:** see [`DEVELOPING.md`](DEVELOPING.md). + ---- -`demosh` is a demo shell: it reads shell scripts or Markdown files and -executes shell commands from them. However, it can also output commentary -from the script, show commands before running them, and pause before (or -after) running each command. Pausing and what to show can be controlled by -inline comments in the script itself. See `testing.md` and `testing.sh` for -examples. +`demosh` is a **D**emo **SH**ell: it reads shell scripts or Markdown files and +executes shell commands from them. However, it can also output commentary from +the script, show commands before running them, and pause before (or after) +running each command. Pausing and what to show can be controlled by inline +comments in the script itself. See `testing.md` and `testing.sh` for examples. ## Running @@ -35,14 +42,22 @@ ### Init Scripts and Builtins -On startup, `demosh` will load `$HOME/.demoshrc` and `$HOME/.demoshrc.md` if -they exist, parsing `.demoshrc` as a shell file and `.demoshrc.md` as a -Markdown file. The `--no-init` flag prevents this behavior. - -These files are treated exactly the same as files supplied on the command -line. In particular, `@SHOW` directives will cause them to go interactive (as -discussed below), and definitions will be available for files on the command -line to use. There's no need to supply either, and no reason to supply both. +On startup, `demosh` will search for one of four startup files to read: + +- `.demoshrc` in the current directory +- `.demoshrc.md` in the current directory +- `$HOME/.demoshrc` +- `$HOME/.demoshrc.md` + +These files are checked in the order above; if any are present, the first one +found will be loaded, with `.demoshrc` files treated as shell scripts and +`.demoshrc.md` files treated as Markdown. The `--no-init` flag prevents this +behavior. + +The startup file is treated _exactly_ the same as files supplied on the +command line. In particular, `@SHOW` directives will cause them to go +interactive (as discussed below), and anything they define will be available +for files on the command line to use. `demosh` will also load a set of builtin definitions on startup, unless the `--no-builtins` flag is present on the command line. Builtins are discussed @@ -77,11 +92,14 @@ - Hitting `+` will skip to the next command _without_ executing this one (note that this currently doesn't work well when executing a macro). +<!-- +(! isn't currently implemented!) + - Hitting `!` will spawn a subshell with all the environment variables defined in the script intact. - **NOTE WELL**: the subshell will not, at present, include functions - defined in the script. + defined in the script. --> When `demosh` has a command to execute in noninteractive mode, it just executes it. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/demosh-0.5.0/demosh/__init__.py new/demosh-0.6.0/demosh/__init__.py --- old/demosh-0.5.0/demosh/__init__.py 2023-10-30 15:07:45.000000000 +0100 +++ new/demosh-0.6.0/demosh/__init__.py 2024-10-04 22:21:26.000000000 +0200 @@ -30,7 +30,7 @@ # Flit reads this dynamically when building or publishing. -__version__ = "0.5.0" +__version__ = "0.6.0" import sys diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/demosh-0.5.0/demosh/demostate.py new/demosh-0.6.0/demosh/demostate.py --- old/demosh-0.5.0/demosh/demostate.py 2023-10-30 15:07:45.000000000 +0100 +++ new/demosh-0.6.0/demosh/demostate.py 2024-10-04 22:21:26.000000000 +0200 @@ -114,31 +114,35 @@ print("End of builtins...") if load_init and not parent: - try: - shell_init = open(os.path.expanduser("~/.demoshrc"), "r") - - if self.debug: - print("Loading ~/.demoshrc...") + init_file = None + init_path = None + init_mode = "shell" + + for path, mode in [ + ( ".demoshrc", "shell" ), + ( ".demoshrc.md", "markdown" ), + ( os.path.expanduser("~/.demoshrc"), "shell" ), + ( os.path.expanduser("~/.demoshrc.md"), "markdown" ), + ]: + try: + init_file = open(path, "r") + except FileNotFoundError: + continue - self.read_commands(shellstate, InputReader("shell", shell_init)) + init_path = path + init_mode = mode + break + if init_file: if self.debug: - print("End of ~/.demoshrc...") - except FileNotFoundError: - pass + print(f"Loading {init_path} as {init_mode}...") - try: - md_init = open(os.path.expanduser("~/.demoshrc.md"), "r") + self.read_commands(shellstate, InputReader(init_mode, init_file)) if self.debug: - print("Loading ~/.demoshrc.md...") - - self.read_commands(shellstate, InputReader("markdown", md_init)) + print("End of ~/.demoshrc...") - if self.debug: - print("End of ~/.demoshrc.md...") - except FileNotFoundError: - pass + init_file.close() self.read_commands(shellstate, InputReader(self.mode, script)) @@ -717,7 +721,8 @@ rc = self.shellstate.run(self, cmd) if (rc != 0) and self.shellstate.exit_on_failure: - print(f"{self.start_color(5)}...exiting due to failure.{self.end_color()}") + if not self.shellstate.quiet_failure: + print(f"{self.start_color(5)}...exiting due to failure.{self.end_color()}") break if self.showing and cmd.wait_after: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/demosh-0.5.0/demosh/main.py new/demosh-0.6.0/demosh/main.py --- old/demosh-0.5.0/demosh/main.py 2023-10-30 15:07:45.000000000 +0100 +++ new/demosh-0.6.0/demosh/main.py 2024-10-04 22:21:26.000000000 +0200 @@ -27,17 +27,18 @@ import argparse from . import __version__ -from .shellstate import ShellState +from .shellstate import ShellState, str2bool from .demostate import DemoState def main() -> None: - parser = argparse.ArgumentParser(description='Demo SHell: run shell scripts with commentary and pauses') + parser = argparse.ArgumentParser(description=f'Demo SHell {__version__}: run shell scripts with commentary and pauses') parser.add_argument('--version', action='version', version=f"%(prog)s {__version__}") parser.add_argument('--debug', action='store_true', help="enable debug output") parser.add_argument('--no-builtins', action='store_true', help="don't load builtin functions") parser.add_argument('--no-init', action='store_true', help="don't run ~/.demoshrc on startup") + parser.add_argument('--no-blurb', action='store_true', help="don't print the demosh blurb on startup") parser.add_argument('script', type=str, help="script to run") parser.add_argument('args', type=str, nargs=argparse.REMAINDER, help="optional arguments to pass to script") @@ -58,6 +59,23 @@ load_builtins=not args.no_builtins, load_init=not args.no_init) + demosh_no_blurb = str2bool(shellstate.env.get("DEMOSH_NO_BLURB", None)) + + if not (args.no_blurb or demosh_no_blurb): + print(f"demosh {__version__}: Interactive Demo SHell for Markdown and shell scripts") + print("(c) 2022-2024 Buoyant, Inc.; Apache 2.0 License") + print("https://github.com/BuoyantIO/demosh") + print("") + print("To exit, hit Q (capital Q!) when demosh is waiting for input.") + print("To skip this message, use --no-blurb or set DEMOSH_NO_BLURB=true.") + print("") + print("Hit RETURN to continue, Q to quit") + + action = demostate.wait_to_proceed() + + if action == "quit": + return + try: demostate.run() finally: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/demosh-0.5.0/demosh/shellstate.py new/demosh-0.6.0/demosh/shellstate.py --- old/demosh-0.5.0/demosh/shellstate.py 2023-10-30 15:07:45.000000000 +0100 +++ new/demosh-0.6.0/demosh/shellstate.py 2024-10-04 22:21:26.000000000 +0200 @@ -44,6 +44,10 @@ # looks like to us. reFunction = re.compile(r"^\s*(function\s+)?([a-zA-Z0-9_]+)\s*\(\)\s+\{") +def str2bool(v): + return str(v).lower() in ("yes", "true", "t", "y", "1") + + class ShellState: @staticmethod def ignore_signals() -> None: @@ -63,6 +67,7 @@ self.functions: List[str] = [] self.macros: Dict[str, 'DemoState'] = {} self.exit_on_failure = False + self.quiet_failure = str2bool(os.environ.get("DEMOSH_QUIET_FAILURE", "")) self._hooks: Set[str] = set() self.shell = os.environ.get("SHELL", "/bin/sh") @@ -214,7 +219,11 @@ i += 1 - # print("assign '%s' = '%s'" % (name, value)) + # print(f"assign '{name}' = '{value}'") + + if name == "DEMOSH_QUIET_FAILURE": + self.quiet_failure = str2bool(value.strip()) + # print(f"quiet_failure = {self.quiet_failure}") proc = subprocess.Popen(["bash"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=self.cwd, env=self.env, close_fds=True) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/demosh-0.5.0/testing.md new/demosh-0.6.0/testing.md --- old/demosh-0.5.0/testing.md 2023-10-30 15:07:45.000000000 +0100 +++ new/demosh-0.6.0/testing.md 2024-10-04 22:21:26.000000000 +0200 @@ -57,6 +57,13 @@ Backticks don't do other formatting, so `COLOR_NAME` should format correctly, as should `_*_*_*_*_`. +You can also use the `@print` directive to produce colorized output: + +```bash +#@print This will be ordinary black text. +#@print # This will be red like a comment. +``` + ### The @ifhook directive First let's check for hooks. If you've set `$DEMO_HOOK_BROWSER` to diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/demosh-0.5.0/testing.sh new/demosh-0.6.0/testing.sh --- old/demosh-0.5.0/testing.sh 2023-10-30 15:07:45.000000000 +0100 +++ new/demosh-0.6.0/testing.sh 2024-10-04 22:21:26.000000000 +0200 @@ -22,8 +22,13 @@ # Welcome to our demo. Isn't it awesome? -# First let's check for hooks. If you've set DEMO_HOOK_BROWSER to -# a nonempty value, you should see "we have a browser hook!" here. +# You can use the `@print` directive to produce colorized output: + +#@print This will be ordinary black text. +#@print # This will be red like a comment. + +# Next, let's check for hooks. If you've set DEMO_HOOK_BROWSER to a nonempty +# value, you should see "we have a browser hook!" here. #@ifhook show_browser #@immed @@ -55,7 +60,7 @@ echo "SHELL is $SHELL" # Here's a function definition with the "function" keyword... -hello() { +function hello() { echo "Hello, $1!" }