Add scripts

This commit is contained in:
CPD 2025-04-03 19:02:48 +02:00
parent 9ac3f73566
commit 1a090224ad
4 changed files with 131 additions and 0 deletions

View File

@ -0,0 +1,31 @@
"""
Convert the docs to html, so that they can be copy-pasted into the BayernCollab Wiki
"""
import os, markdown
DOC_DIR = "~/cpd-dev/cpdctrl-gui/cpdctrl_gui/resources"
OUT_DIR = "~/cpd-dev/docs"
def convert(filepath: str):
with open(filepath, "r") as file:
content = file.read()
html = markdown.markdown(content, output_format="html")
return html
if __name__ == '__main__':
DOC_DIR = os.path.expanduser(DOC_DIR)
docs = [os.path.join(DOC_DIR, f) for f in os.listdir(DOC_DIR)]
docs.sort()
OUT_DIR = os.path.expanduser(OUT_DIR)
if not os.path.isdir(OUT_DIR):
os.makedirs(OUT_DIR)
for file in docs:
if file.endswith(".md"):
html_file = os.path.join(OUT_DIR, os.path.basename(file).replace(".md", ".html"))
print(f"{file} -> {html_file}")
html = convert(file)
html = html.replace("<br>", "<br />")
with open(html_file, "w") as file:
file.write(html)

View File

@ -0,0 +1,9 @@
# import and run cpdctrl_gui
# when packaging this with pyinstaller,
# cpdctrl_gui will be imported as python package and thus
# have the package metadata (including version number) available
from cpdctrl_gui import init
if __name__ == '__main__':
import sys
sys.exit(init.run())

16
.scripts/install_gui.ps1 Normal file
View File

@ -0,0 +1,16 @@
# This creates & installs cpdctrl-gui using pyinstaller
# into a single, gigantic exe file. Very modern.
# The --paths ..\cpdctrl is necessary, otherwise it takes the version that was installed with pip
cd ~\cpd-dev
.\venv\Scripts\activate.ps1
mkdir build
cd build
pyinstaller ..\cpdctrl_gui_launcher.py `
--onefile `
--name "cpdctrl-gui" `
--windowed `
--icon ..\cpdctrl-gui\cpdctrl_gui\resources\icons\icon.png `
--exclude-module pyside6 `
--paths ..\cpdctrl `
--paths ..\cpdctrl_gui `
--add-data ..\cpdctrl-gui\cpdctrl_gui\resources:cpdctrl_gui\resources

75
.scripts/make_manuals.py Normal file
View File

@ -0,0 +1,75 @@
"""
Create pdf manuals from the markdown files in the cpdctrl-gui resources directory
"""
import os, markdown
import pymupdf
import datetime
from markdown_pdf import MarkdownPdf, Section
DOC_DIR = "~/cpd-dev/cpdctrl-gui/cpdctrl_gui/resources"
OUT_DIR = "~/cpd-dev/docs"
def convert(filepath: str):
with open(filepath, "r") as file:
content = file.read()
html = markdown.markdown(content, output_format="html")
return html
def load_md(filename: str):
with open(os.path.join(DOC_DIR, filename), "r") as file:
return file.read()
metadata = {
"author": "Matthias Quintern",
"modDate": datetime.datetime.now().isoformat(),
}
def make_software_manual():
filepath = os.path.join(OUT_DIR, "cpdctrl-gui-manual.pdf")
sections = [[
"# N203 Vacuum CPD Setup: User Manual\n",
"user_guide.md",
"sample_changing.md",
"measurement_settings.md",
"led_control.md",
"controller_calibration.md",
"troubleshooting.md",
], [
"# cpdctrl Software Documentation",
"about.md",
"technical_information.md",
]
]
pdf = MarkdownPdf(toc_level=2)
for section in sections:
sec_md = ""
for entry in section:
if entry.endswith(".md"):
entry_md = load_md(entry)
else:
entry_md = entry
sec_md += entry_md + "\n"
pdf.add_section(Section(sec_md))
for key, val in (metadata | { "title": "cpdctrl-gui-manual"}).items():
pdf.meta[key] = val
pdf.save(filepath)
def recorder(elpos):
pass
if __name__ == '__main__':
DOC_DIR = os.path.expanduser(DOC_DIR)
docs = [os.path.join(DOC_DIR, f) for f in os.listdir(DOC_DIR)]
docs.sort()
OUT_DIR = os.path.expanduser(OUT_DIR)
if not os.path.isdir(OUT_DIR):
os.makedirs(OUT_DIR)
make_software_manual()