Demos¶
More demos, particularly related to building C++, will be added when possible.
- custom_log_stage
Simple demo for how to modify the
ci_execdefaults to suit user preferences.Go to demo ↱
Demos Program Execution¶
Wrapper module for executing each respective location from the repository root.
Each individual demo is executable on its own. However, users may also run a demo from
repository root doing python demos/ <demo_name>.
By default the programs are not run in “animated” mode. The --animated flag is what
is used to record the videos hosted on each individual demo page, which utilizes
clear, PAUSE and a delay in calls to type_message(). See
mock_shell() for more information.
clear()Clear the console screen.
pause([amount])Pause by
amountusingtime.sleep().
type_message(message, *, delay)Flush
messagetosys.stdout, sleep bydelayafter character.
mock_shell(program, *, cwd, delay, animated)Run a “shell” program from the specified working directory.
run_demo(program, cwd, animated)Run the specified demo program.
- CI_EXEC_DEMOS_COVERAGE = False¶
Whether or not this is a coverage run of the demo files.
Warning
This should not be set unless invoking from
tox. See notes in[testenv:docs]section oftox.iniat repository root.
- windows_cmd_builtin(builtin)[source]¶
Return a function that runs the specified
builtin.Note
There is a reason this is not in the main library. To deal with shell builtins requires a significant amount of extra work for little to no benefit. The demos just need
"cls"to clear and"type"tocat.The return is a function that can support:
*argsAny command line arguments to provide to the builtin.
**kwargsAny keyword arguments to provide to
subprocess.run(). This function will addcheck=Trueandshell=Trueunless these keys are already explicitly specified.
- Parameters
builtin (str) – Any of the CMD builtins, such as
"type"or"cls". No checking is performed!
- pause(amount=3.0)[source]¶
Pause by
amountusingtime.sleep().This function exists so that it can be used for
PAUSEstatements inmock_shell().- Parameters
amount (float) – The amount of time to
time.sleep()for. Default:3.0seconds.
- type_message(message, *, delay)[source]¶
Flush
messagetosys.stdout, sleep bydelayafter character.- Parameters
message (str) – What to type. A trailing newline
"\n"will be written at the end.delay (float) – The positive amount to
time.sleep()after each character inmessageis written. Suggested value for simulating typing to the console:0.05. Use0.0to avoid delays.
- mock_shell(program, *, cwd, delay, animated)[source]¶
Run a “shell” program from the specified working directory.
Lines starting with
#are “comment” lines, they will be printed to the screen usingtype_message().Lines starting with
"$ "are a command to execute.Commands executed will be printed to the screen using
type_message().
There is also a notion of “animated” mode. When
animated=True, the following special behavior is enabled:$ clear: callsclear(). In non-animated mode,clearis skipped.PAUSEorPAUSE=X.Y: callpause(),X.Yshould be parseable as afloate.g.,PAUSE=7.0would pause for 7 seconds. In non-animated mode this is skipped.Calls to
type_message()will have adelay=0.05. In non-animated mode thedelay=0.0.
These scripts are not intended to be robust. Features are implemented as needed… this is not intended to be a real shell programming language! See
demos/__main__.pyfor exampleprogram’s that can execute.- Parameters
program (str) – The “shell” program to execute.
cwd (str) – The directory to execute
programfrom.delay (float) – Pass-through parameter for
type_message().animated (bool) – Whether or not this is an “animated” shell, meaning commands such as
clearorPAUSEshould be executed.
- run_demo(program, cwd, animated)[source]¶
Run the specified demo program.
When
animated=True,clear()the screen and sleep for 2 seconds to allow recording to begin. Thedelayparameter passed-through totype_message()will be set to0.05. In non-animated mode the screen will not be cleared, and the delay will be0.0.- Parameters
program (str) – The “shell” program to execute with
mock_shell().cwd (str) – Pass-through parameter to
mock_shell().animated (bool) – Pass-through parameter to
mock_shell().