[DOCs] Added examples and warnings about spaces in names
- For the replace pre-flights Related to #366
This commit is contained in:
parent
eb8c04f870
commit
16e61e6f23
12
README.md
12
README.md
|
|
@ -445,9 +445,9 @@ This section is used to specify tasks that will be executed before generating an
|
|||
This preflight modifies the PCB. Even when a back-up is done use it carefully.
|
||||
* Valid keys:
|
||||
- `date_command`: [string=''] Command to get the date to use in the PCB.\
|
||||
```git log -1 --format='%as' -- $KIBOT_PCB_NAME```\
|
||||
```git log -1 --format='%as' -- "$KIBOT_PCB_NAME"```\
|
||||
Will return the date in YYYY-MM-DD format.\
|
||||
```date -d @`git log -1 --format='%at' -- $KIBOT_PCB_NAME` +%Y-%m-%d_%H-%M-%S```\
|
||||
```date -d @`git log -1 --format='%at' -- "$KIBOT_PCB_NAME"` +%Y-%m-%d_%H-%M-%S```\
|
||||
Will return the date in YYYY-MM-DD_HH-MM-SS format.\
|
||||
Important: on KiCad 6 the title block data is optional.
|
||||
This command will work only if you have a date in the PCB/Schematic.
|
||||
|
|
@ -472,9 +472,9 @@ This section is used to specify tasks that will be executed before generating an
|
|||
This preflight modifies the schematics. Even when a back-up is done use it carefully.
|
||||
* Valid keys:
|
||||
- `date_command`: [string=''] Command to get the date to use in the SCH.\
|
||||
```git log -1 --format='%as' -- $KIBOT_SCH_NAME```\
|
||||
```git log -1 --format='%as' -- "$KIBOT_SCH_NAME"```\
|
||||
Will return the date in YYYY-MM-DD format.\
|
||||
```date -d @`git log -1 --format='%at' -- $KIBOT_SCH_NAME` +%Y-%m-%d_%H-%M-%S```\
|
||||
```date -d @`git log -1 --format='%at' -- "$KIBOT_SCH_NAME"` +%Y-%m-%d_%H-%M-%S```\
|
||||
Will return the date in YYYY-MM-DD_HH-MM-SS format.\
|
||||
Important: on KiCad 6 the title block data is optional.
|
||||
This command will work only if you have a date in the SCH/Schematic.
|
||||
|
|
@ -497,6 +497,10 @@ This section is used to specify tasks that will be executed before generating an
|
|||
- `after`: [string=''] Text to add after the output of `command`.
|
||||
- `before`: [string=''] Text to add before the output of `command`.
|
||||
- `command`: [string=''] Command to execute to get the text, will be used only if `text` is empty.
|
||||
This command will be executed using the Bash shell.
|
||||
Be careful about spaces in file names (i.e. use "$KIBOT_PCB_NAME").
|
||||
The `KIBOT_PCB_NAME` environment variable is the PCB file and the
|
||||
`KIBOT_SCH_NAME` environment variable is the schematic file.
|
||||
- `expand_kibot_patterns`: [boolean=true] Expand %X patterns. The context is `schematic`.
|
||||
- `name`: [string=''] Name of the variable. The `version` variable will be expanded using `${version}`.
|
||||
- `text`: [string=''] Text to insert instead of the variable.
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ preflight:
|
|||
# The KiCad project file is modified.
|
||||
set_text_variables:
|
||||
- name: 'git_hash'
|
||||
command: 'git log -1 --format="%h" $KIBOT_PCB_NAME'
|
||||
command: 'git log -1 --format="%h" "$KIBOT_PCB_NAME"'
|
||||
before: 'Git hash: <'
|
||||
after: '>'
|
||||
# [boolean=false] Update the QR codes.
|
||||
|
|
|
|||
|
|
@ -54,9 +54,9 @@ class Base_ReplaceOptions(Optionable):
|
|||
with document:
|
||||
self.date_command = ''
|
||||
""" Command to get the date to use in the PCB.\\
|
||||
```git log -1 --format='%as' -- $KIBOT_PCB_NAME```\\
|
||||
```git log -1 --format='%as' -- \"$KIBOT_PCB_NAME\"```\\
|
||||
Will return the date in YYYY-MM-DD format.\\
|
||||
```date -d @`git log -1 --format='%at' -- $KIBOT_PCB_NAME` +%Y-%m-%d_%H-%M-%S```\\
|
||||
```date -d @`git log -1 --format='%at' -- \"$KIBOT_PCB_NAME\"` +%Y-%m-%d_%H-%M-%S```\\
|
||||
Will return the date in YYYY-MM-DD_HH-MM-SS format.\\
|
||||
Important: on KiCad 6 the title block data is optional.
|
||||
This command will work only if you have a date in the PCB/Schematic """
|
||||
|
|
|
|||
|
|
@ -41,7 +41,11 @@ class KiCadVariable(Optionable):
|
|||
self.text = ''
|
||||
""" Text to insert instead of the variable """
|
||||
self.command = ''
|
||||
""" Command to execute to get the text, will be used only if `text` is empty """
|
||||
""" Command to execute to get the text, will be used only if `text` is empty.
|
||||
This command will be executed using the Bash shell.
|
||||
Be careful about spaces in file names (i.e. use "$KIBOT_PCB_NAME").
|
||||
The `KIBOT_PCB_NAME` environment variable is the PCB file and the
|
||||
`KIBOT_SCH_NAME` environment variable is the schematic file """
|
||||
self.before = ''
|
||||
""" Text to add before the output of `command` """
|
||||
self.after = ''
|
||||
|
|
@ -91,7 +95,7 @@ class Set_Text_Variables(BasePreFlight): # noqa: F821
|
|||
def get_example(cls):
|
||||
""" Returns a YAML value for the example config """
|
||||
return ("\n - name: 'git_hash'"
|
||||
"\n command: 'git log -1 --format=\"%h\" $KIBOT_PCB_NAME'"
|
||||
"\n command: 'git log -1 --format=\"%h\" \"$KIBOT_PCB_NAME\"'"
|
||||
"\n before: 'Git hash: <'"
|
||||
"\n after: '>'")
|
||||
|
||||
|
|
@ -132,7 +136,10 @@ class Set_Text_Variables(BasePreFlight): # noqa: F821
|
|||
result = run(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True)
|
||||
if result.returncode:
|
||||
logger.error('Failed to execute:\n{}\nreturn code {}'.format(r.command, result.returncode))
|
||||
logger.error('stdout:\n{}\nstderr:\n{}'.format(result.stdout, result.stderr))
|
||||
if result.stdout:
|
||||
logger.error('stdout:\n{}'.format(result.stdout))
|
||||
if result.stderr:
|
||||
logger.error('stderr:\n{}'.format(result.stderr))
|
||||
sys.exit(FAILED_EXECUTE)
|
||||
if not result.stdout:
|
||||
logger.warning(W_EMPTREP+"Empty value from `{}`".format(r.command))
|
||||
|
|
|
|||
Loading…
Reference in New Issue