Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGhostkeeper <rubend@tutanota.com>2019-05-09 17:55:44 +0300
committerGhostkeeper <rubend@tutanota.com>2019-05-09 17:55:44 +0300
commit3629b955fe6fd5e3aa23469ad4e8a8d4eb427230 (patch)
tree7f01b9e03210552ddc75ed7bfa898e48d3d31756 /plugins/USBPrinting
parentf0ccb2504fafb3ee7ec48849a38c8021b29f9d8c (diff)
parentc8130051702245a00908291cf88c929537de63c2 (diff)
Merge branch 'port-filter' of https://github.com/joba-1/Cura into joba-1-port-filter
Diffstat (limited to 'plugins/USBPrinting')
-rw-r--r--plugins/USBPrinting/USBPrinterOutputDeviceManager.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/plugins/USBPrinting/USBPrinterOutputDeviceManager.py b/plugins/USBPrinting/USBPrinterOutputDeviceManager.py
index f84a1bb175..56f53145b0 100644
--- a/plugins/USBPrinting/USBPrinterOutputDeviceManager.py
+++ b/plugins/USBPrinting/USBPrinterOutputDeviceManager.py
@@ -4,6 +4,8 @@
import threading
import time
import serial.tools.list_ports
+from os import environ
+from re import search
from PyQt5.QtCore import QObject, pyqtSignal
@@ -112,6 +114,27 @@ class USBPrinterOutputDeviceManager(QObject, OutputDevicePlugin):
port = (port.device, port.description, port.hwid)
if only_list_usb and not port[2].startswith("USB"):
continue
+
+ # To prevent cura from messing with serial ports of other devices,
+ # filter by regular expressions passed in as environment variables.
+ # Get possible patterns with python3 -m serial.tools.list_ports -v
+
+ # set CURA_DEVICENAMES=USB[1-9] -> e.g. not matching /dev/ttyUSB0
+ pattern = environ.get('CURA_DEVICENAMES')
+ if pattern and not search(pattern, port[0]):
+ continue
+
+ # set CURA_DEVICETYPES=CP2102 -> match a type of serial converter
+ pattern = environ.get('CURA_DEVICETYPES')
+ if pattern and not search(pattern, port[1]):
+ continue
+
+ # set CURA_DEVICEINFOS=LOCATION=2-1.4 -> match a physical port
+ # set CURA_DEVICEINFOS=VID:PID=10C4:EA60 -> match a vendor:product
+ pattern = environ.get('CURA_DEVICEINFOS')
+ if pattern and not search(pattern, port[2]):
+ continue
+
base_list += [port[0]]
return list(base_list)