[Stencil*] Now using Xvfb
This commit is contained in:
parent
44c7b95e77
commit
7d8cadd0f4
|
|
@ -153,6 +153,12 @@ Notes:
|
||||||
[**OpenSCAD**](https://openscad.org/) [](https://openscad.org/) [](https://packages.debian.org/bullseye/openscad)
|
[**OpenSCAD**](https://openscad.org/) [](https://openscad.org/) [](https://packages.debian.org/bullseye/openscad)
|
||||||
- Mandatory for: `stencil_3d`, `stencil_for_jig`
|
- Mandatory for: `stencil_3d`, `stencil_for_jig`
|
||||||
|
|
||||||
|
[**Xvfb**](https://www.x.org) [](https://www.x.org) [](https://packages.debian.org/bullseye/xvfb)
|
||||||
|
- Mandatory for: `stencil_3d`, `stencil_for_jig`
|
||||||
|
|
||||||
|
[**Xvfbwrapper**](https://pypi.org/project/Xvfbwrapper/) [](https://pypi.org/project/Xvfbwrapper/) [](https://packages.debian.org/bullseye/python3-xvfbwrapper) 
|
||||||
|
- Mandatory for: `stencil_3d`, `stencil_for_jig`
|
||||||
|
|
||||||
[**KiCost**](https://github.com/hildogjr/KiCost) v1.1.8 [](https://github.com/hildogjr/KiCost) 
|
[**KiCost**](https://github.com/hildogjr/KiCost) v1.1.8 [](https://github.com/hildogjr/KiCost) 
|
||||||
- Mandatory for `kicost`
|
- Mandatory for `kicost`
|
||||||
- Optional to find components costs and specs for `bom`
|
- Optional to find components costs and specs for `bom`
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,9 @@ X-Python3-Version: >= 3.6
|
||||||
Package: kibot
|
Package: kibot
|
||||||
Architecture: all
|
Architecture: all
|
||||||
Multi-Arch: foreign
|
Multi-Arch: foreign
|
||||||
Depends: ${misc:Depends}, ${python3:Depends}, python3-yaml, kicad (>= 5.1.6), python3-wxgtk4.0
|
Depends: ${misc:Depends}, ${python3:Depends}, python3-yaml, kicad (>= 5.1.6), python3-wxgtk4.0, python3-xvfb
|
||||||
Recommends: kibom.inti-cmnb (>= 1.8.0), kicost (>= 1.1.8), interactivehtmlbom.inti-cmnb (>= 2.4.1), imagemagick, librsvg2-bin, python3-xlsxwriter, rar, ghostscript, python3-lxml, python3-mistune
|
Recommends: kibom.inti-cmnb (>= 1.8.0), kicost (>= 1.1.8), interactivehtmlbom.inti-cmnb (>= 2.4.1), imagemagick, librsvg2-bin, python3-xlsxwriter, rar, ghostscript, python3-lxml, python3-mistune, kikit
|
||||||
Suggests: pandoc, texlive-latex-base, texlive-latex-recommended, git, poppler-utils, kidiff, python3-numpy, kikit
|
Suggests: pandoc, texlive-latex-base, texlive-latex-recommended, git, poppler-utils, kidiff, python3-numpy
|
||||||
Description: KiCad Bot
|
Description: KiCad Bot
|
||||||
KiBot is a program which helps you to automate the generation of KiCad
|
KiBot is a program which helps you to automate the generation of KiCad
|
||||||
output documents easily, repeatable, and most of all, scriptably.
|
output documents easily, repeatable, and most of all, scriptably.
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,17 @@ Dependencies:
|
||||||
github: yaqwsx/KiKit
|
github: yaqwsx/KiKit
|
||||||
pypi: KiKit
|
pypi: KiKit
|
||||||
downloader: pytool
|
downloader: pytool
|
||||||
|
- name: Xvfbwrapper
|
||||||
|
python_module: true
|
||||||
|
debian: python3-xvfbwrapper
|
||||||
|
arch: python-xvfbwrapper
|
||||||
|
downloader: python
|
||||||
|
- name: Xvfb
|
||||||
|
url: https://www.x.org
|
||||||
|
command: xvfb-run
|
||||||
|
debian: xvfb
|
||||||
|
arch: xorg-server-xvfb
|
||||||
|
no_cmd_line_version: true
|
||||||
"""
|
"""
|
||||||
import importlib
|
import importlib
|
||||||
import os
|
import os
|
||||||
|
|
@ -944,6 +955,7 @@ def register_dep(context, dep):
|
||||||
command = dep.get('command', None)
|
command = dep.get('command', None)
|
||||||
help_option = dep.get('help_option', None)
|
help_option = dep.get('help_option', None)
|
||||||
pypi_name = dep.get('pypi', None)
|
pypi_name = dep.get('pypi', None)
|
||||||
|
no_cmd_line_version = dep.get('no_cmd_line_version', False)
|
||||||
no_cmd_line_version_old = dep.get('no_cmd_line_version_old', False)
|
no_cmd_line_version_old = dep.get('no_cmd_line_version_old', False)
|
||||||
downloader_str = downloader = dep.get('downloader', None)
|
downloader_str = downloader = dep.get('downloader', None)
|
||||||
if downloader:
|
if downloader:
|
||||||
|
|
@ -956,7 +968,7 @@ def register_dep(context, dep):
|
||||||
extra_deb=extra_deb, is_python=is_python, module_name=module_name, plugin_dirs=plugin_dirs,
|
extra_deb=extra_deb, is_python=is_python, module_name=module_name, plugin_dirs=plugin_dirs,
|
||||||
command=command, help_option=help_option, pypi_name=pypi_name,
|
command=command, help_option=help_option, pypi_name=pypi_name,
|
||||||
no_cmd_line_version_old=no_cmd_line_version_old, downloader=downloader, arch=arch,
|
no_cmd_line_version_old=no_cmd_line_version_old, downloader=downloader, arch=arch,
|
||||||
extra_arch=extra_arch, tests=tests)
|
extra_arch=extra_arch, tests=tests, no_cmd_line_version=no_cmd_line_version)
|
||||||
# Extra comments
|
# Extra comments
|
||||||
comments = dep.get('comments', [])
|
comments = dep.get('comments', [])
|
||||||
if isinstance(comments, str):
|
if isinstance(comments, str):
|
||||||
|
|
|
||||||
|
|
@ -145,12 +145,22 @@ def debug_output(res):
|
||||||
logger.debug('- Output from command: '+res.stdout.decode())
|
logger.debug('- Output from command: '+res.stdout.decode())
|
||||||
|
|
||||||
|
|
||||||
def run_command(command, change_to=None, just_raise=False):
|
def _run_command(command, change_to):
|
||||||
|
return run(command, check=True, stdout=PIPE, stderr=STDOUT, cwd=change_to)
|
||||||
|
|
||||||
|
|
||||||
|
def run_command(command, change_to=None, just_raise=False, use_x11=False):
|
||||||
logger.debug('Executing: '+shlex.join(command))
|
logger.debug('Executing: '+shlex.join(command))
|
||||||
if change_to is not None:
|
if change_to is not None:
|
||||||
logger.debug('- CWD: '+change_to)
|
logger.debug('- CWD: '+change_to)
|
||||||
try:
|
try:
|
||||||
res = run(command, check=True, stdout=PIPE, stderr=STDOUT, cwd=change_to)
|
if use_x11 and not GS.on_windows:
|
||||||
|
logger.debug('Using Xvfb to run the command')
|
||||||
|
from xvfbwrapper import Xvfb
|
||||||
|
with Xvfb(width=640, height=480, colordepth=24):
|
||||||
|
res = _run_command(command, change_to)
|
||||||
|
else:
|
||||||
|
res = _run_command(command, change_to)
|
||||||
except CalledProcessError as e:
|
except CalledProcessError as e:
|
||||||
if just_raise:
|
if just_raise:
|
||||||
raise
|
raise
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ class Stencil_Options(VariantOptions):
|
||||||
src_name = os.path.join(src_dir, src_file)
|
src_name = os.path.join(src_dir, src_file)
|
||||||
if not os.path.isfile(src_name):
|
if not os.path.isfile(src_name):
|
||||||
raise PlotError('Missing output file {}'.format(src_name))
|
raise PlotError('Missing output file {}'.format(src_name))
|
||||||
run_command([self.cmd_openscad, '-o', dst_name, '--imgsize=1280,720', src_name])
|
run_command([self.cmd_openscad, '-o', dst_name, '--imgsize=1280,720', src_name], use_x11=True)
|
||||||
|
|
||||||
def move_output(self, src_dir, src_file, id, ext, replacement=None, patch=False, relative=False):
|
def move_output(self, src_dir, src_file, id, ext, replacement=None, patch=False, relative=False):
|
||||||
dst_name = self.expand_name(id, ext, self._parent.output_dir)
|
dst_name = self.expand_name(id, ext, self._parent.output_dir)
|
||||||
|
|
@ -100,6 +100,9 @@ class Stencil_Options(VariantOptions):
|
||||||
def run(self, output):
|
def run(self, output):
|
||||||
cmd_kikit = self.ensure_tool('KiKit')
|
cmd_kikit = self.ensure_tool('KiKit')
|
||||||
self.cmd_openscad = self.ensure_tool('OpenSCAD')
|
self.cmd_openscad = self.ensure_tool('OpenSCAD')
|
||||||
|
if not GS.on_windows:
|
||||||
|
self.ensure_tool('Xvfbwrapper')
|
||||||
|
self.ensure_tool('Xvfb')
|
||||||
super().run(output)
|
super().run(output)
|
||||||
# Apply variants and filters
|
# Apply variants and filters
|
||||||
filtered = self.filter_pcb_components(GS.board)
|
filtered = self.filter_pcb_components(GS.board)
|
||||||
|
|
@ -125,7 +128,7 @@ class Stencil_Options(VariantOptions):
|
||||||
cmd.append(fname)
|
cmd.append(fname)
|
||||||
cmd.append(tmp)
|
cmd.append(tmp)
|
||||||
try:
|
try:
|
||||||
run_command(cmd)
|
run_command(cmd, use_x11=True)
|
||||||
finally:
|
finally:
|
||||||
# Remove temporal variant
|
# Remove temporal variant
|
||||||
if filtered:
|
if filtered:
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,10 @@ Dependencies:
|
||||||
debian: openscad
|
debian: openscad
|
||||||
arch: openscad
|
arch: openscad
|
||||||
role: mandatory
|
role: mandatory
|
||||||
|
- from: Xvfbwrapper
|
||||||
|
role: mandatory
|
||||||
|
- from: Xvfb
|
||||||
|
role: mandatory
|
||||||
"""
|
"""
|
||||||
from .gs import GS
|
from .gs import GS
|
||||||
from .macros import macros, document, output_class # noqa: F401
|
from .macros import macros, document, output_class # noqa: F401
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,10 @@ Dependencies:
|
||||||
debian: openscad
|
debian: openscad
|
||||||
arch: openscad
|
arch: openscad
|
||||||
role: mandatory
|
role: mandatory
|
||||||
|
- from: Xvfbwrapper
|
||||||
|
role: mandatory
|
||||||
|
- from: Xvfb
|
||||||
|
role: mandatory
|
||||||
"""
|
"""
|
||||||
import math
|
import math
|
||||||
from .gs import GS
|
from .gs import GS
|
||||||
|
|
|
||||||
|
|
@ -950,6 +950,87 @@ deps = '{\
|
||||||
"url": null,\
|
"url": null,\
|
||||||
"url_down": null\
|
"url_down": null\
|
||||||
},\
|
},\
|
||||||
|
"Xvfb": {\
|
||||||
|
"arch": "xorg-server-xvfb",\
|
||||||
|
"command": "xvfb-run",\
|
||||||
|
"comments": [],\
|
||||||
|
"deb_package": "xvfb",\
|
||||||
|
"downloader": null,\
|
||||||
|
"downloader_str": null,\
|
||||||
|
"extra_arch": null,\
|
||||||
|
"extra_deb": null,\
|
||||||
|
"help_option": "--version",\
|
||||||
|
"importance": 20000,\
|
||||||
|
"in_debian": true,\
|
||||||
|
"is_kicad_plugin": false,\
|
||||||
|
"is_python": false,\
|
||||||
|
"name": "Xvfb",\
|
||||||
|
"no_cmd_line_version": true,\
|
||||||
|
"no_cmd_line_version_old": false,\
|
||||||
|
"output": "stencil_3d",\
|
||||||
|
"plugin_dirs": null,\
|
||||||
|
"pypi_name": "Xvfb",\
|
||||||
|
"roles": [\
|
||||||
|
{\
|
||||||
|
"desc": null,\
|
||||||
|
"mandatory": true,\
|
||||||
|
"max_version": null,\
|
||||||
|
"output": "stencil_3d",\
|
||||||
|
"version": null\
|
||||||
|
},\
|
||||||
|
{\
|
||||||
|
"desc": null,\
|
||||||
|
"mandatory": true,\
|
||||||
|
"max_version": null,\
|
||||||
|
"output": "stencil_for_jig",\
|
||||||
|
"version": null\
|
||||||
|
}\
|
||||||
|
],\
|
||||||
|
"tests": [],\
|
||||||
|
"url": "https://www.x.org",\
|
||||||
|
"url_down": null\
|
||||||
|
},\
|
||||||
|
"Xvfbwrapper": {\
|
||||||
|
"arch": "python-xvfbwrapper",\
|
||||||
|
"command": "xvfbwrapper",\
|
||||||
|
"comments": [],\
|
||||||
|
"deb_package": "python3-xvfbwrapper",\
|
||||||
|
"downloader": {},\
|
||||||
|
"downloader_str": "python",\
|
||||||
|
"extra_arch": null,\
|
||||||
|
"extra_deb": null,\
|
||||||
|
"help_option": "--version",\
|
||||||
|
"importance": 20000,\
|
||||||
|
"in_debian": true,\
|
||||||
|
"is_kicad_plugin": false,\
|
||||||
|
"is_python": true,\
|
||||||
|
"module_name": "xvfbwrapper",\
|
||||||
|
"name": "Xvfbwrapper",\
|
||||||
|
"no_cmd_line_version": false,\
|
||||||
|
"no_cmd_line_version_old": false,\
|
||||||
|
"output": "stencil_3d",\
|
||||||
|
"plugin_dirs": null,\
|
||||||
|
"pypi_name": "Xvfbwrapper",\
|
||||||
|
"roles": [\
|
||||||
|
{\
|
||||||
|
"desc": null,\
|
||||||
|
"mandatory": true,\
|
||||||
|
"max_version": null,\
|
||||||
|
"output": "stencil_3d",\
|
||||||
|
"version": null\
|
||||||
|
},\
|
||||||
|
{\
|
||||||
|
"desc": null,\
|
||||||
|
"mandatory": true,\
|
||||||
|
"max_version": null,\
|
||||||
|
"output": "stencil_for_jig",\
|
||||||
|
"version": null\
|
||||||
|
}\
|
||||||
|
],\
|
||||||
|
"tests": [],\
|
||||||
|
"url": null,\
|
||||||
|
"url_down": null\
|
||||||
|
},\
|
||||||
"mistune": {\
|
"mistune": {\
|
||||||
"arch": "python-mistune",\
|
"arch": "python-mistune",\
|
||||||
"command": "mistune",\
|
"command": "mistune",\
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue