From 05e45581d1173852e33d8a4d1c7b07346da7ec8c Mon Sep 17 00:00:00 2001 From: Corentin LABBE Date: Thu, 15 Nov 2018 12:09:20 +0100 Subject: lavalab-gen.py: Remove udev template for support of interfacenum The current udev templating is bad since adding a new optional keyword lead to numerous ifelse and templates. This patch simply generate a udev line part by part. This made adding interfacenum easier. This will also permit to mix devpath/serial/etc.. without any problem --- lavalab-gen.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'lavalab-gen.py') diff --git a/lavalab-gen.py b/lavalab-gen.py index 5191f07..f873750 100755 --- a/lavalab-gen.py +++ b/lavalab-gen.py @@ -49,13 +49,6 @@ template_device_screen = string.Template(""" {% set connection_command = 'ssh -o StrictHostKeyChecking=no -t root@127.0.0.1 "TERM=xterm screen -x ${board}"' %} """) -template_udev_serial = string.Template("""# -SUBSYSTEM=="tty", ATTRS{idVendor}=="${idvendor}", ATTRS{idProduct}=="${idproduct}", ATTRS{serial}=="${serial}", MODE="0664", OWNER="uucp", SYMLINK+="${board}" -""") -template_udev_devpath = string.Template("""# -SUBSYSTEM=="tty", ATTRS{idVendor}=="${idvendor}", ATTRS{idProduct}=="${idproduct}", ATTRS{devpath}=="${devpath}", MODE="0664", OWNER="uucp", SYMLINK+="${board}" -""") - template_settings_conf = string.Template(""" { "DEBUG": false, @@ -451,12 +444,14 @@ def main(): if type(idvendor) == str: print("Please put hexadecimal IDs for vendor %s (like 0x%s)" % (board_name, idvendor)) sys.exit(1) + udev_line = 'SUBSYSTEM=="tty", ATTRS{idVendor}=="%04x", ATTRS{idProduct}=="%04x",' % (idvendor, idproduct) if "serial" in uart: - serial = board["uart"]["serial"] - udev_line = template_udev_serial.substitute(board=board_name, serial=serial, idvendor="%04x" % idvendor, idproduct="%04x" % idproduct) - else: - devpath = board["uart"]["devpath"] - udev_line = template_udev_devpath.substitute(board=board_name, devpath=devpath, idvendor="%04x" % idvendor, idproduct="%04x" % idproduct) + udev_line += 'ATTRS{serial}=="%s", ' % board["uart"]["serial"] + if "devpath" in uart: + udev_line += 'ATTRS{devpath}=="%s", ' % board["uart"]["devpath"] + if "interfacenum" in uart: + udev_line += 'ENV{ID_USB_INTERFACE_NUM}=="%s", ' % board["uart"]["interfacenum"] + udev_line += 'MODE="0664", OWNER="uucp", SYMLINK+="%s"\n' % board_name if not os.path.isdir("output/%s/udev" % host): os.mkdir("output/%s/udev" % host) fp = open("output/%s/udev/99-lavaworker-udev.rules" % host, "a") -- cgit 1.2.3-korg