在您的打印机农场中同步GCode文件。
项目描述
Link Sync
目的
该项目的目标是同步本地“主”目录中的gcode文件到本地网络中运行PrusaLink的任何数量的Prusa打印机,当它们空闲时同时进行。
传输文件速度缓慢,因此想法是同时同步多个打印机。这对于可能有一个新模型替换旧模型的农场操作员来说是一个强大的工作流程,无需逐台发送到每个打印机,或者手动从本地机器获取USB棒/其他进行更新。
此外,通过删除不在本地“主”目录中的文件,一次性打印将自动从打印机的USB棒中清理。
操作原理
本地维护一个包含所有目标机器所需的GCode文件的“主”文件结构。同时,在本地机器上保留一个YAML或JSON格式的配置文件,其中包含每个打印机的连接详情。
程序读取配置文件,实例化打印机实例,然后对于当前不忙的打印机,启动一个线程,负责检查应从打印机中删除哪些文件,或复制哪些文件到打印机,以使其与本地“主”文件结构同步。
这些线程然后同时运行,将所有空闲打印机在大约同一时间同步。
请注意,在打印机上运行的PrusaLink拒绝删除正在打印的文件。这是一个好事。
作为一个命令行程序,使用cron
轻松设置,每小时整点从晚上7点到早上7点(夜间)运行,以确保所有打印机都能从前一天运行中同步/清理,并准备好第二天使用。
当前实现的功能
当前支持的打印机
- 运行固件5.0.0 RC1及以后的Prusa MK4。
待办事项
- Prusa XL
- Prusa Mini
- Prusa MK3
功能
- 添加在本地源中找到但不在远程存储中的新文件。
- 删除在本地源中找不到但在远程存储中的多余文件。
- 可选地操作非空闲打印机。
- 替换修改日期比远程存储中的相同文件更近(> 60秒)的旧文件。
待办事项
- 可选地,将打印机上存在的唯一文件复制回本地文件系统。
示例用法
场景
作者在他的本地工作站文件系统上维护一组文件,位于
~/master_farm_files/usb
在此目录中,他可以按需添加所有他的GCode,组织到目录中。他知道PrusaLink对打印机上的文件路径长度有限制,所以保持目录层次结构浅且名称简短。例如,如下目录结构
~/master_farm_files/usb/
apple/
prusament pla/
apple_0.4n_0.15mm_PLA_MK4IS_4h52m.gcode
prusament petg/
apple_0.4n_0.15mm_PETG_MK4IS_4h58m.gcode
banana/
prusament pla/
banana_0.4n_0.15mm_PLA_MK4IS_2h12m.gcode
prusament petg/
banana_0.4n_0.15mm_PETG_MK4IS_2h13m.gcode
作者有一组4台Original Prusa MK4打印机。他在某处创建了一个配置文件~/printers.yml
,其中包含它们的详细信息如下
Ash:
printer_type: MK4
host: http://192.168.0.1
username: maker
password: password1
Bishop:
printer_type: MK4
host: http://192.168.0.2
username: maker
password: password2
Call:
printer_type: MK4
host: http://192.168.0.3
username: maker
password: password3
David:
printer_type: MK4
host: http://192.168.0.4
username: maker
password: password4
然后,作者创建了一个虚拟Python环境并安装了link-sync
。
❯ pip install link-sync
这个Python包安装了一个名为link-sync
的命令行实用程序,可以像这样使用
❯ link-sync --config ~/printers.yml --source ~/master_farm_files/usb --destination /usb/
程序将显示如果提供了--go
选项会发生什么的预览。
如果操作看起来正确,请再次运行程序并带有--go
参数
❯ link-sync --config ~/printers.yml --source ~/master_farm_files/usb --destination /usb/ --go
然后将文件同时复制到所有打印机。
许多参数都可以缩写。例如,上面的行可以是
❯ link-sync -c ~/printers.yml -s ~/master_farm_files/usb -d /usb/ -g
注意--go
的简写是-g
。
您可以使用内置的帮助功能查看其他选项
❯ link-sync --help
usage: link_sync [-h] [-c CONFIG_PATH] [-p [INCLUDED_PRINTERS ...]]
[-x [EXCLUDED_PRINTERS ...]] -s SOURCE_PATH
[-d DESTINATION_PATH] [-r RELATIVE_TO_PATH] [-g]
[--ignore-state]
options:
-h, --help show this help message and exit
-c CONFIG_PATH, --config CONFIG_PATH
Path to a YAML or JSON file containing the
configuration of all printers. Default is
`printers.yml` in the current working directory.
-p [INCLUDED_PRINTERS ...], --printer [INCLUDED_PRINTERS ...]
Explicitly name printers to INCLUDE for processing. By
default, all idle (see the `--ignore-state` option)
printers found in the will configuration be processed.
-x [EXCLUDED_PRINTERS ...], --exclude [EXCLUDED_PRINTERS ...]
Explicitly name printers to EXCLUDE from processing.
By default, all idle (see the `--ignore-state option)
printers found in the configuration will be processed.
This option will be ignored if the `--printer` option
is used.
-s SOURCE_PATH, --source SOURCE_PATH
The local path to the root of the files that should be
synced.
-d DESTINATION_PATH, --destination DESTINATION_PATH
The relative path within the printers' storage where
the source files should be synchronized. Default is
the root of the printers' storage.
-r RELATIVE_TO_PATH, --relative-to RELATIVE_TO_PATH
If provided, the SOURCE_PATH file paths will consider
only the portion of the path that is relative to this
given path. If not provided, it is set to the
SOURCE_PATH itself.
-g, --go Make the changes (do not do a dry-run).
--ignore-state If set, all printers, including busy printers, will be
processed. Use with caution as some printers may
experience print failures when printing and API calls
are received and processed.
版权(c)2023,Martin Koistinen
项目详情
下载文件
下载适合您平台的自定义文件。如果您不确定要选择哪个,请了解更多关于安装软件包的信息。
源分布
构建分布
link-sync-0.2.5.tar.gz的散列
算法 | 散列摘要 | |
---|---|---|
SHA256 | 67e249304e5b0717d3c99ceabd404ae4db27891d5631d1d378721a815ea6b14f |
|
MD5 | b01c870fb9a8048a3d49acdf28328dcd |
|
BLAKE2b-256 | b3d581f4462e546b90d2210b001bb14ee35edf52b96c97e1f3d627b461146724 |