{"diffoscope-json-version": 1, "source1": "/srv/reproducible-results/rbuild-debian/r-b-build.MRLGcStT/b1/cockpit_316-1_amd64.changes", "source2": "/srv/reproducible-results/rbuild-debian/r-b-build.MRLGcStT/b2/cockpit_316-1_amd64.changes", "unified_diff": null, "details": [{"source1": "Files", "source2": "Files", "unified_diff": "@@ -1,10 +1,10 @@\n \n df15a42a97129bf0fa93133b90438473 140368 debug optional cockpit-bridge-dbgsym_316-1_amd64.deb\n- 2fd724f3ec8abf0cc97c30e8cacd956d 359780 admin optional cockpit-bridge_316-1_amd64.deb\n+ 1914a5b455df05d3bfc56b651d64fa9a 359964 admin optional cockpit-bridge_316-1_amd64.deb\n b244333d93e755b8795d5de9bfd74a75 131516 doc optional cockpit-doc_316-1_all.deb\n 5f5f51363cccd25ac69165e1bfe089be 829340 admin optional cockpit-networkmanager_316-1_all.deb\n b259a5a3925e9a8e04317b97aff99eea 941992 admin optional cockpit-packagekit_316-1_all.deb\n 24ccc1323beb19dee85a9d7a1e3d6b5b 234644 debug optional cockpit-pcp-dbgsym_316-1_amd64.deb\n a0b03f1343e791e79ea34154494ffec4 79204 admin optional cockpit-pcp_316-1_amd64.deb\n ca337edae770f17961c72b2ed6a3a2e1 558888 admin optional cockpit-sosreport_316-1_all.deb\n 510e4876abdbe0222c7a9eaf8eed0969 879356 admin optional cockpit-storaged_316-1_all.deb\n"}, {"source1": "cockpit-bridge_316-1_amd64.deb", "source2": "cockpit-bridge_316-1_amd64.deb", "unified_diff": null, "details": [{"source1": "file list", "source2": "file list", "unified_diff": "@@ -1,3 +1,3 @@\n -rw-r--r-- 0 0 0 4 2024-04-26 05:46:21.000000 debian-binary\n -rw-r--r-- 0 0 0 3884 2024-04-26 05:46:21.000000 control.tar.xz\n--rw-r--r-- 0 0 0 355704 2024-04-26 05:46:21.000000 data.tar.xz\n+-rw-r--r-- 0 0 0 355888 2024-04-26 05:46:21.000000 data.tar.xz\n"}, {"source1": "control.tar.xz", "source2": "control.tar.xz", "unified_diff": null, "details": [{"source1": "control.tar", "source2": "control.tar", "unified_diff": null, "details": [{"source1": "./md5sums", "source2": "./md5sums", "unified_diff": null, "details": [{"source1": "./md5sums", "source2": "./md5sums", "comments": ["Files differ"], "unified_diff": null}]}]}]}, {"source1": "data.tar.xz", "source2": "data.tar.xz", "unified_diff": null, "details": [{"source1": "data.tar", "source2": "data.tar", "unified_diff": null, "details": [{"source1": "file list", "source2": "file list", "unified_diff": "@@ -60,15 +60,15 @@\n -rw-r--r-- 0 root (0) root (0) 6653 2024-04-26 05:46:21.000000 ./usr/lib/python3/dist-packages/cockpit/channels/metrics.py\n -rw-r--r-- 0 root (0) root (0) 4058 2024-04-26 05:46:21.000000 ./usr/lib/python3/dist-packages/cockpit/channels/packages.py\n -rw-r--r-- 0 root (0) root (0) 4872 2024-04-26 05:46:21.000000 ./usr/lib/python3/dist-packages/cockpit/channels/stream.py\n -rw-r--r-- 0 root (0) root (0) 1171 2024-04-26 05:46:21.000000 ./usr/lib/python3/dist-packages/cockpit/channels/trivial.py\n -rw-r--r-- 0 root (0) root (0) 3188 2024-04-26 05:46:21.000000 ./usr/lib/python3/dist-packages/cockpit/config.py\n drwxr-xr-x 0 root (0) root (0) 0 2024-04-26 05:46:21.000000 ./usr/lib/python3/dist-packages/cockpit/data/\n -rw-r--r-- 0 root (0) root (0) 574 2024-04-26 05:46:21.000000 ./usr/lib/python3/dist-packages/cockpit/data/__init__.py\n--rw-r--r-- 0 root (0) root (0) 86800 2024-04-26 05:46:21.000000 ./usr/lib/python3/dist-packages/cockpit/data/cockpit-bridge.beipack.xz\n+-rw-r--r-- 0 root (0) root (0) 87000 2024-04-26 05:46:21.000000 ./usr/lib/python3/dist-packages/cockpit/data/cockpit-bridge.beipack.xz\n -rw-r--r-- 0 root (0) root (0) 3212 2024-04-26 05:46:21.000000 ./usr/lib/python3/dist-packages/cockpit/data/fail.html\n -rw-r--r-- 0 root (0) root (0) 5517 2024-04-26 05:46:21.000000 ./usr/lib/python3/dist-packages/cockpit/internal_endpoints.py\n -rw-r--r-- 0 root (0) root (0) 7242 2024-04-26 05:46:21.000000 ./usr/lib/python3/dist-packages/cockpit/jsonutil.py\n -rw-r--r-- 0 root (0) root (0) 21539 2024-04-26 05:46:21.000000 ./usr/lib/python3/dist-packages/cockpit/packages.py\n -rw-r--r-- 0 root (0) root (0) 12729 2024-04-26 05:46:21.000000 ./usr/lib/python3/dist-packages/cockpit/peer.py\n -rw-r--r-- 0 root (0) root (0) 7580 2024-04-26 05:46:21.000000 ./usr/lib/python3/dist-packages/cockpit/polkit.py\n -rw-r--r-- 0 root (0) root (0) 2031 2024-04-26 05:46:21.000000 ./usr/lib/python3/dist-packages/cockpit/polyfills.py\n"}, {"source1": "./usr/lib/python3/dist-packages/cockpit/data/cockpit-bridge.beipack.xz", "source2": "./usr/lib/python3/dist-packages/cockpit/data/cockpit-bridge.beipack.xz", "unified_diff": null, "details": [{"source1": "cockpit-bridge.beipack", "source2": "cockpit-bridge.beipack", "has_internal_linenos": true, "unified_diff": "@@ -174,26505 +174,26505 @@\n 00000ad0: 6574 7572 6e20 696d 706f 7274 6c69 622e eturn importlib.\n 00000ae0: 7574 696c 2e73 7065 635f 6672 6f6d 5f6c util.spec_from_l\n 00000af0: 6f61 6465 7228 6675 6c6c 6e61 6d65 2c20 oader(fullname, \n 00000b00: 7365 6c66 290a 0a69 6d70 6f72 7420 7379 self)..import sy\n 00000b10: 730a 7379 732e 6d65 7461 5f70 6174 682e s.sys.meta_path.\n 00000b20: 696e 7365 7274 2830 2c20 4265 6970 6163 insert(0, Beipac\n 00000b30: 6b4c 6f61 6465 7228 7b0a 2020 2763 6f63 kLoader({. 'coc\n-00000b40: 6b70 6974 2f5f 7665 7273 696f 6e2e 7079 kpit/_version.py\n-00000b50: 273a 2062 7227 2727 5f5f 7665 7273 696f ': br'''__versio\n-00000b60: 6e5f 5f20 3d20 2733 3136 270a 2727 272c n__ = '316'.''',\n-00000b70: 0a20 2027 636f 636b 7069 742f 6a73 6f6e . 'cockpit/json\n-00000b80: 7574 696c 2e70 7927 3a20 7227 2727 2320 util.py': r'''# \n-00000b90: 5468 6973 2066 696c 6520 6973 2070 6172 This file is par\n-00000ba0: 7420 6f66 2043 6f63 6b70 6974 2e0a 230a t of Cockpit..#.\n-00000bb0: 2320 436f 7079 7269 6768 7420 2843 2920 # Copyright (C) \n-00000bc0: 3230 3233 2052 6564 2048 6174 2c20 496e 2023 Red Hat, In\n-00000bd0: 632e 0a23 0a23 2054 6869 7320 7072 6f67 c..#.# This prog\n-00000be0: 7261 6d20 6973 2066 7265 6520 736f 6674 ram is free soft\n-00000bf0: 7761 7265 3a20 796f 7520 6361 6e20 7265 ware: you can re\n-00000c00: 6469 7374 7269 6275 7465 2069 7420 616e distribute it an\n-00000c10: 642f 6f72 206d 6f64 6966 790a 2320 6974 d/or modify.# it\n-00000c20: 2075 6e64 6572 2074 6865 2074 6572 6d73 under the terms\n-00000c30: 206f 6620 7468 6520 474e 5520 4765 6e65 of the GNU Gene\n-00000c40: 7261 6c20 5075 626c 6963 204c 6963 656e ral Public Licen\n-00000c50: 7365 2061 7320 7075 626c 6973 6865 6420 se as published \n-00000c60: 6279 0a23 2074 6865 2046 7265 6520 536f by.# the Free So\n-00000c70: 6674 7761 7265 2046 6f75 6e64 6174 696f ftware Foundatio\n-00000c80: 6e2c 2065 6974 6865 7220 7665 7273 696f n, either versio\n-00000c90: 6e20 3320 6f66 2074 6865 204c 6963 656e n 3 of the Licen\n-00000ca0: 7365 2c20 6f72 0a23 2028 6174 2079 6f75 se, or.# (at you\n-00000cb0: 7220 6f70 7469 6f6e 2920 616e 7920 6c61 r option) any la\n-00000cc0: 7465 7220 7665 7273 696f 6e2e 0a23 0a23 ter version..#.#\n-00000cd0: 2054 6869 7320 7072 6f67 7261 6d20 6973 This program is\n-00000ce0: 2064 6973 7472 6962 7574 6564 2069 6e20 distributed in \n-00000cf0: 7468 6520 686f 7065 2074 6861 7420 6974 the hope that it\n-00000d00: 2077 696c 6c20 6265 2075 7365 6675 6c2c will be useful,\n-00000d10: 0a23 2062 7574 2057 4954 484f 5554 2041 .# but WITHOUT A\n-00000d20: 4e59 2057 4152 5241 4e54 593b 2077 6974 NY WARRANTY; wit\n-00000d30: 686f 7574 2065 7665 6e20 7468 6520 696d hout even the im\n-00000d40: 706c 6965 6420 7761 7272 616e 7479 206f plied warranty o\n-00000d50: 660a 2320 4d45 5243 4841 4e54 4142 494c f.# MERCHANTABIL\n-00000d60: 4954 5920 6f72 2046 4954 4e45 5353 2046 ITY or FITNESS F\n-00000d70: 4f52 2041 2050 4152 5449 4355 4c41 5220 OR A PARTICULAR \n-00000d80: 5055 5250 4f53 452e 2020 5365 6520 7468 PURPOSE. See th\n-00000d90: 650a 2320 474e 5520 4765 6e65 7261 6c20 e.# GNU General \n-00000da0: 5075 626c 6963 204c 6963 656e 7365 2066 Public License f\n-00000db0: 6f72 206d 6f72 6520 6465 7461 696c 732e or more details.\n-00000dc0: 0a23 0a23 2059 6f75 2073 686f 756c 6420 .#.# You should \n-00000dd0: 6861 7665 2072 6563 6569 7665 6420 6120 have received a \n-00000de0: 636f 7079 206f 6620 7468 6520 474e 5520 copy of the GNU \n-00000df0: 4765 6e65 7261 6c20 5075 626c 6963 204c General Public L\n-00000e00: 6963 656e 7365 0a23 2061 6c6f 6e67 2077 icense.# along w\n-00000e10: 6974 6820 7468 6973 2070 726f 6772 616d ith this program\n-00000e20: 2e20 2049 6620 6e6f 742c 2073 6565 203c . If not, see <\n-00000e30: 6874 7470 733a 2f2f 7777 772e 676e 752e https://www.gnu.\n-00000e40: 6f72 672f 6c69 6365 6e73 6573 2f3e 2e0a org/licenses/>..\n-00000e50: 0a66 726f 6d20 656e 756d 2069 6d70 6f72 .from enum impor\n-00000e60: 7420 456e 756d 0a66 726f 6d20 7479 7069 t Enum.from typi\n-00000e70: 6e67 2069 6d70 6f72 7420 4361 6c6c 6162 ng import Callab\n-00000e80: 6c65 2c20 436f 6e74 6169 6e65 722c 2044 le, Container, D\n-00000e90: 6963 742c 204c 6973 742c 204d 6170 7069 ict, List, Mappi\n-00000ea0: 6e67 2c20 4f70 7469 6f6e 616c 2c20 5365 ng, Optional, Se\n-00000eb0: 7175 656e 6365 2c20 5479 7065 2c20 5479 quence, Type, Ty\n-00000ec0: 7065 5661 722c 2055 6e69 6f6e 0a0a 4a73 peVar, Union..Js\n-00000ed0: 6f6e 4c69 7465 7261 6c20 3d20 556e 696f onLiteral = Unio\n-00000ee0: 6e5b 7374 722c 2066 6c6f 6174 2c20 626f n[str, float, bo\n-00000ef0: 6f6c 2c20 4e6f 6e65 5d0a 0a23 2069 6d6d ol, None]..# imm\n-00000f00: 7574 6162 6c65 0a4a 736f 6e56 616c 7565 utable.JsonValue\n-00000f10: 203d 2055 6e69 6f6e 5b27 4a73 6f6e 4f62 = Union['JsonOb\n-00000f20: 6a65 6374 272c 2053 6571 7565 6e63 655b ject', Sequence[\n-00000f30: 274a 736f 6e56 616c 7565 275d 2c20 4a73 'JsonValue'], Js\n-00000f40: 6f6e 4c69 7465 7261 6c5d 0a4a 736f 6e4f onLiteral].JsonO\n-00000f50: 626a 6563 7420 3d20 4d61 7070 696e 675b bject = Mapping[\n-00000f60: 7374 722c 204a 736f 6e56 616c 7565 5d0a str, JsonValue].\n-00000f70: 0a23 206d 7574 6162 6c65 0a4a 736f 6e44 .# mutable.JsonD\n-00000f80: 6f63 756d 656e 7420 3d20 556e 696f 6e5b ocument = Union[\n-00000f90: 274a 736f 6e44 6963 7427 2c20 274a 736f 'JsonDict', 'Jso\n-00000fa0: 6e4c 6973 7427 2c20 4a73 6f6e 4c69 7465 nList', JsonLite\n-00000fb0: 7261 6c5d 0a4a 736f 6e44 6963 7420 3d20 ral].JsonDict = \n-00000fc0: 4469 6374 5b73 7472 2c20 4a73 6f6e 446f Dict[str, JsonDo\n-00000fd0: 6375 6d65 6e74 5d0a 4a73 6f6e 4c69 7374 cument].JsonList\n-00000fe0: 203d 204c 6973 745b 4a73 6f6e 446f 6375 = List[JsonDocu\n-00000ff0: 6d65 6e74 5d0a 0a0a 4454 203d 2054 7970 ment]...DT = Typ\n-00001000: 6556 6172 2827 4454 2729 0a54 203d 2054 eVar('DT').T = T\n-00001010: 7970 6556 6172 2827 5427 290a 0a0a 636c ypeVar('T')...cl\n-00001020: 6173 7320 4a73 6f6e 4572 726f 7228 4578 ass JsonError(Ex\n-00001030: 6365 7074 696f 6e29 3a0a 2020 2020 7661 ception):. va\n-00001040: 6c75 653a 206f 626a 6563 740a 0a20 2020 lue: object.. \n-00001050: 2064 6566 205f 5f69 6e69 745f 5f28 7365 def __init__(se\n-00001060: 6c66 2c20 7661 6c75 653a 206f 626a 6563 lf, value: objec\n-00001070: 742c 206d 7367 3a20 7374 7229 3a0a 2020 t, msg: str):. \n-00001080: 2020 2020 2020 7375 7065 7228 292e 5f5f super().__\n-00001090: 696e 6974 5f5f 286d 7367 290a 2020 2020 init__(msg). \n-000010a0: 2020 2020 7365 6c66 2e76 616c 7565 203d self.value =\n-000010b0: 2076 616c 7565 0a0a 0a64 6566 2074 7970 value...def typ\n-000010c0: 6563 6865 636b 6564 2876 616c 7565 3a20 echecked(value: \n-000010d0: 4a73 6f6e 5661 6c75 652c 2065 7870 6563 JsonValue, expec\n-000010e0: 7465 645f 7479 7065 3a20 5479 7065 5b54 ted_type: Type[T\n-000010f0: 5d29 202d 3e20 543a 0a20 2020 2022 2222 ]) -> T:. \"\"\"\n-00001100: 456e 7375 7265 2061 204a 534f 4e20 7661 Ensure a JSON va\n-00001110: 6c75 6520 6861 7320 7468 6520 6578 7065 lue has the expe\n-00001120: 6374 6564 2074 7970 652c 2072 6574 7572 cted type, retur\n-00001130: 6e69 6e67 2069 7420 6966 2073 6f2e 2222 ning it if so.\"\"\n-00001140: 220a 2020 2020 6966 206e 6f74 2069 7369 \". if not isi\n-00001150: 6e73 7461 6e63 6528 7661 6c75 652c 2065 nstance(value, e\n-00001160: 7870 6563 7465 645f 7479 7065 293a 0a20 xpected_type):. \n-00001170: 2020 2020 2020 2072 6169 7365 204a 736f raise Jso\n-00001180: 6e45 7272 6f72 2876 616c 7565 2c20 6627 nError(value, f'\n-00001190: 6d75 7374 2068 6176 6520 7479 7065 207b must have type {\n-000011a0: 6578 7065 6374 6564 5f74 7970 652e 5f5f expected_type.__\n-000011b0: 6e61 6d65 5f5f 7d27 290a 2020 2020 7265 name__}'). re\n-000011c0: 7475 726e 2076 616c 7565 0a0a 0a23 2057 turn value...# W\n-000011d0: 6520 6361 6e27 7420 7573 6520 4e6f 6e65 e can't use None\n-000011e0: 2061 7320 6120 7365 6e74 696e 656c 2062 as a sentinel b\n-000011f0: 6563 6175 7365 2069 7427 7320 6f66 7465 ecause it's ofte\n-00001200: 6e20 7468 6520 6163 7475 616c 2064 6566 n the actual def\n-00001210: 6175 6c74 2076 616c 7565 0a23 2045 6c6c ault value.# Ell\n-00001220: 6970 7369 7354 7970 6520 6973 2064 6966 ipsisType is dif\n-00001230: 6669 6375 6c74 2062 6563 6175 7365 2069 ficult because i\n-00001240: 7427 7320 6e6f 7420 6176 6169 6c61 626c t's not availabl\n-00001250: 6520 6265 666f 7265 2033 2e31 302e 0a23 e before 3.10..#\n-00001260: 2053 6565 2068 7474 7073 3a2f 2f70 6570 See https://pep\n-00001270: 732e 7079 7468 6f6e 2e6f 7267 2f70 6570 s.python.org/pep\n-00001280: 2d30 3438 342f 2373 7570 706f 7274 2d66 -0484/#support-f\n-00001290: 6f72 2d73 696e 676c 6574 6f6e 2d74 7970 or-singleton-typ\n-000012a0: 6573 2d69 6e2d 756e 696f 6e73 0a63 6c61 es-in-unions.cla\n-000012b0: 7373 205f 456d 7074 7928 456e 756d 293a ss _Empty(Enum):\n-000012c0: 0a20 2020 2054 4f4b 454e 203d 2030 0a0a . TOKEN = 0..\n-000012d0: 0a5f 656d 7074 7920 3d20 5f45 6d70 7479 ._empty = _Empty\n-000012e0: 2e54 4f4b 454e 0a0a 0a64 6566 205f 6765 .TOKEN...def _ge\n-000012f0: 7428 6f62 6a3a 204a 736f 6e4f 626a 6563 t(obj: JsonObjec\n-00001300: 742c 2063 6173 743a 2043 616c 6c61 626c t, cast: Callabl\n-00001310: 655b 5b4a 736f 6e56 616c 7565 5d2c 2054 e[[JsonValue], T\n-00001320: 5d2c 206b 6579 3a20 7374 722c 2064 6566 ], key: str, def\n-00001330: 6175 6c74 3a20 556e 696f 6e5b 4454 2c20 ault: Union[DT, \n-00001340: 5f45 6d70 7479 5d29 202d 3e20 556e 696f _Empty]) -> Unio\n-00001350: 6e5b 542c 2044 545d 3a0a 2020 2020 7472 n[T, DT]:. tr\n-00001360: 793a 0a20 2020 2020 2020 2072 6574 7572 y:. retur\n-00001370: 6e20 6361 7374 286f 626a 5b6b 6579 5d29 n cast(obj[key])\n-00001380: 0a20 2020 2065 7863 6570 7420 4b65 7945 . except KeyE\n-00001390: 7272 6f72 3a0a 2020 2020 2020 2020 6966 rror:. if\n-000013a0: 2064 6566 6175 6c74 2069 7320 6e6f 7420 default is not \n-000013b0: 5f65 6d70 7479 3a0a 2020 2020 2020 2020 _empty:. \n-000013c0: 2020 2020 7265 7475 726e 2064 6566 6175 return defau\n-000013d0: 6c74 0a20 2020 2020 2020 2072 6169 7365 lt. raise\n-000013e0: 204a 736f 6e45 7272 6f72 286f 626a 2c20 JsonError(obj, \n-000013f0: 6622 6174 7472 6962 7574 6520 277b 6b65 f\"attribute '{ke\n-00001400: 797d 2720 7265 7175 6972 6564 2229 2066 y}' required\") f\n-00001410: 726f 6d20 4e6f 6e65 0a20 2020 2065 7863 rom None. exc\n-00001420: 6570 7420 4a73 6f6e 4572 726f 7220 6173 ept JsonError as\n-00001430: 2065 7863 3a0a 2020 2020 2020 2020 7461 exc:. ta\n-00001440: 7267 6574 203d 2066 2261 7474 7269 6275 rget = f\"attribu\n-00001450: 7465 2027 7b6b 6579 7d27 2220 2b20 2827 te '{key}'\" + ('\n-00001460: 2065 6c65 6d65 6e74 733a 2720 6966 2065 elements:' if e\n-00001470: 7863 2e76 616c 7565 2069 7320 6e6f 7420 xc.value is not \n-00001480: 6f62 6a5b 6b65 795d 2065 6c73 6520 273a obj[key] else ':\n-00001490: 2729 0a20 2020 2020 2020 2072 6169 7365 '). raise\n-000014a0: 204a 736f 6e45 7272 6f72 286f 626a 2c20 JsonError(obj, \n-000014b0: 6622 7b74 6172 6765 747d 207b 6578 6321 f\"{target} {exc!\n-000014c0: 737d 2229 2066 726f 6d20 6578 630a 0a0a s}\") from exc...\n-000014d0: 6465 6620 6765 745f 626f 6f6c 286f 626a def get_bool(obj\n-000014e0: 3a20 4a73 6f6e 4f62 6a65 6374 2c20 6b65 : JsonObject, ke\n-000014f0: 793a 2073 7472 2c20 6465 6661 756c 743a y: str, default:\n-00001500: 2055 6e69 6f6e 5b44 542c 205f 456d 7074 Union[DT, _Empt\n-00001510: 795d 203d 205f 656d 7074 7929 202d 3e20 y] = _empty) -> \n-00001520: 556e 696f 6e5b 4454 2c20 626f 6f6c 5d3a Union[DT, bool]:\n-00001530: 0a20 2020 2072 6574 7572 6e20 5f67 6574 . return _get\n-00001540: 286f 626a 2c20 6c61 6d62 6461 2076 3a20 (obj, lambda v: \n-00001550: 7479 7065 6368 6563 6b65 6428 762c 2062 typechecked(v, b\n-00001560: 6f6f 6c29 2c20 6b65 792c 2064 6566 6175 ool), key, defau\n-00001570: 6c74 290a 0a0a 6465 6620 6765 745f 696e lt)...def get_in\n-00001580: 7428 6f62 6a3a 204a 736f 6e4f 626a 6563 t(obj: JsonObjec\n-00001590: 742c 206b 6579 3a20 7374 722c 2064 6566 t, key: str, def\n-000015a0: 6175 6c74 3a20 556e 696f 6e5b 4454 2c20 ault: Union[DT, \n-000015b0: 5f45 6d70 7479 5d20 3d20 5f65 6d70 7479 _Empty] = _empty\n-000015c0: 2920 2d3e 2055 6e69 6f6e 5b44 542c 2069 ) -> Union[DT, i\n-000015d0: 6e74 5d3a 0a20 2020 2072 6574 7572 6e20 nt]:. return \n-000015e0: 5f67 6574 286f 626a 2c20 6c61 6d62 6461 _get(obj, lambda\n-000015f0: 2076 3a20 7479 7065 6368 6563 6b65 6428 v: typechecked(\n-00001600: 762c 2069 6e74 292c 206b 6579 2c20 6465 v, int), key, de\n-00001610: 6661 756c 7429 0a0a 0a64 6566 2067 6574 fault)...def get\n-00001620: 5f73 7472 286f 626a 3a20 4a73 6f6e 4f62 _str(obj: JsonOb\n-00001630: 6a65 6374 2c20 6b65 793a 2073 7472 2c20 ject, key: str, \n-00001640: 6465 6661 756c 743a 2055 6e69 6f6e 5b44 default: Union[D\n-00001650: 542c 205f 456d 7074 795d 203d 205f 656d T, _Empty] = _em\n-00001660: 7074 7929 202d 3e20 556e 696f 6e5b 4454 pty) -> Union[DT\n-00001670: 2c20 7374 725d 3a0a 2020 2020 7265 7475 , str]:. retu\n-00001680: 726e 205f 6765 7428 6f62 6a2c 206c 616d rn _get(obj, lam\n-00001690: 6264 6120 763a 2074 7970 6563 6865 636b bda v: typecheck\n-000016a0: 6564 2876 2c20 7374 7229 2c20 6b65 792c ed(v, str), key,\n-000016b0: 2064 6566 6175 6c74 290a 0a0a 6465 6620 default)...def \n-000016c0: 6765 745f 7374 725f 6f72 5f6e 6f6e 6528 get_str_or_none(\n-000016d0: 6f62 6a3a 204a 736f 6e4f 626a 6563 742c obj: JsonObject,\n-000016e0: 206b 6579 3a20 7374 722c 2064 6566 6175 key: str, defau\n-000016f0: 6c74 3a20 4f70 7469 6f6e 616c 5b73 7472 lt: Optional[str\n-00001700: 5d29 202d 3e20 4f70 7469 6f6e 616c 5b73 ]) -> Optional[s\n-00001710: 7472 5d3a 0a20 2020 2072 6574 7572 6e20 tr]:. return \n-00001720: 5f67 6574 286f 626a 2c20 6c61 6d62 6461 _get(obj, lambda\n-00001730: 2076 3a20 4e6f 6e65 2069 6620 7620 6973 v: None if v is\n-00001740: 204e 6f6e 6520 656c 7365 2074 7970 6563 None else typec\n-00001750: 6865 636b 6564 2876 2c20 7374 7229 2c20 hecked(v, str), \n-00001760: 6b65 792c 2064 6566 6175 6c74 290a 0a0a key, default)...\n-00001770: 6465 6620 6765 745f 6469 6374 286f 626a def get_dict(obj\n-00001780: 3a20 4a73 6f6e 4f62 6a65 6374 2c20 6b65 : JsonObject, ke\n-00001790: 793a 2073 7472 2c20 6465 6661 756c 743a y: str, default:\n-000017a0: 2055 6e69 6f6e 5b44 542c 205f 456d 7074 Union[DT, _Empt\n-000017b0: 795d 203d 205f 656d 7074 7929 202d 3e20 y] = _empty) -> \n-000017c0: 556e 696f 6e5b 4454 2c20 4a73 6f6e 4f62 Union[DT, JsonOb\n-000017d0: 6a65 6374 5d3a 0a20 2020 2072 6574 7572 ject]:. retur\n-000017e0: 6e20 5f67 6574 286f 626a 2c20 6c61 6d62 n _get(obj, lamb\n-000017f0: 6461 2076 3a20 7479 7065 6368 6563 6b65 da v: typechecke\n-00001800: 6428 762c 2064 6963 7429 2c20 6b65 792c d(v, dict), key,\n-00001810: 2064 6566 6175 6c74 290a 0a0a 6465 6620 default)...def \n-00001820: 6765 745f 6f62 6a65 6374 280a 2020 2020 get_object(. \n-00001830: 6f62 6a3a 204a 736f 6e4f 626a 6563 742c obj: JsonObject,\n-00001840: 0a20 2020 206b 6579 3a20 7374 722c 0a20 . key: str,. \n-00001850: 2020 2063 6f6e 7374 7275 6374 6f72 3a20 constructor: \n-00001860: 4361 6c6c 6162 6c65 5b5b 4a73 6f6e 4f62 Callable[[JsonOb\n-00001870: 6a65 6374 5d2c 2054 5d2c 0a20 2020 2064 ject], T],. d\n-00001880: 6566 6175 6c74 3a20 556e 696f 6e5b 4454 efault: Union[DT\n-00001890: 2c20 5f45 6d70 7479 5d20 3d20 5f65 6d70 , _Empty] = _emp\n-000018a0: 7479 0a29 202d 3e20 556e 696f 6e5b 4454 ty.) -> Union[DT\n-000018b0: 2c20 545d 3a0a 2020 2020 7265 7475 726e , T]:. return\n-000018c0: 205f 6765 7428 6f62 6a2c 206c 616d 6264 _get(obj, lambd\n-000018d0: 6120 763a 2063 6f6e 7374 7275 6374 6f72 a v: constructor\n-000018e0: 2874 7970 6563 6865 636b 6564 2876 2c20 (typechecked(v, \n-000018f0: 6469 6374 2929 2c20 6b65 792c 2064 6566 dict)), key, def\n-00001900: 6175 6c74 290a 0a0a 6465 6620 6765 745f ault)...def get_\n-00001910: 7374 7276 286f 626a 3a20 4a73 6f6e 4f62 strv(obj: JsonOb\n-00001920: 6a65 6374 2c20 6b65 793a 2073 7472 2c20 ject, key: str, \n-00001930: 6465 6661 756c 743a 2055 6e69 6f6e 5b44 default: Union[D\n-00001940: 542c 205f 456d 7074 795d 203d 205f 656d T, _Empty] = _em\n-00001950: 7074 7929 202d 3e20 556e 696f 6e5b 4454 pty) -> Union[DT\n-00001960: 2c20 5365 7175 656e 6365 5b73 7472 5d5d , Sequence[str]]\n-00001970: 3a0a 2020 2020 6465 6620 6173 5f73 7472 :. def as_str\n-00001980: 7628 7661 6c75 653a 204a 736f 6e56 616c v(value: JsonVal\n-00001990: 7565 2920 2d3e 2053 6571 7565 6e63 655b ue) -> Sequence[\n-000019a0: 7374 725d 3a0a 2020 2020 2020 2020 7265 str]:. re\n-000019b0: 7475 726e 2074 7570 6c65 2874 7970 6563 turn tuple(typec\n-000019c0: 6865 636b 6564 2869 7465 6d2c 2073 7472 hecked(item, str\n-000019d0: 2920 666f 7220 6974 656d 2069 6e20 7479 ) for item in ty\n-000019e0: 7065 6368 6563 6b65 6428 7661 6c75 652c pechecked(value,\n-000019f0: 206c 6973 7429 290a 2020 2020 7265 7475 list)). retu\n-00001a00: 726e 205f 6765 7428 6f62 6a2c 2061 735f rn _get(obj, as_\n-00001a10: 7374 7276 2c20 6b65 792c 2064 6566 6175 strv, key, defau\n-00001a20: 6c74 290a 0a0a 6465 6620 6765 745f 656e lt)...def get_en\n-00001a30: 756d 280a 2020 2020 6f62 6a3a 204a 736f um(. obj: Jso\n-00001a40: 6e4f 626a 6563 742c 206b 6579 3a20 7374 nObject, key: st\n-00001a50: 722c 2063 686f 6963 6573 3a20 436f 6e74 r, choices: Cont\n-00001a60: 6169 6e65 725b 7374 725d 2c20 6465 6661 ainer[str], defa\n-00001a70: 756c 743a 2055 6e69 6f6e 5b44 542c 205f ult: Union[DT, _\n-00001a80: 456d 7074 795d 203d 205f 656d 7074 790a Empty] = _empty.\n-00001a90: 2920 2d3e 2055 6e69 6f6e 5b44 542c 2073 ) -> Union[DT, s\n-00001aa0: 7472 5d3a 0a20 2020 2064 6566 2061 735f tr]:. def as_\n-00001ab0: 6368 6f69 6365 2876 616c 7565 3a20 4a73 choice(value: Js\n-00001ac0: 6f6e 5661 6c75 6529 202d 3e20 7374 723a onValue) -> str:\n-00001ad0: 0a20 2020 2020 2020 2023 206d 7970 7920 . # mypy \n-00001ae0: 6361 6e27 7420 646f 2060 5f5f 6571 5f5f can't do `__eq__\n-00001af0: 2829 602d 6261 7365 6420 7479 7065 206e ()`-based type n\n-00001b00: 6172 726f 7769 6e67 2e2e 2e0a 2020 2020 arrowing.... \n-00001b10: 2020 2020 2320 6874 7470 733a 2f2f 6769 # https://gi\n-00001b20: 7468 7562 2e63 6f6d 2f70 7974 686f 6e2f thub.com/python/\n-00001b30: 6d79 7079 2f69 7373 7565 732f 3137 3130 mypy/issues/1710\n-00001b40: 310a 2020 2020 2020 2020 6966 2069 7369 1. if isi\n-00001b50: 6e73 7461 6e63 6528 7661 6c75 652c 2073 nstance(value, s\n-00001b60: 7472 2920 616e 6420 7661 6c75 6520 696e tr) and value in\n-00001b70: 2063 686f 6963 6573 3a0a 2020 2020 2020 choices:. \n-00001b80: 2020 2020 2020 7265 7475 726e 2076 616c return val\n-00001b90: 7565 0a20 2020 2020 2020 2072 6169 7365 ue. raise\n-00001ba0: 204a 736f 6e45 7272 6f72 2876 616c 7565 JsonError(value\n-00001bb0: 2c20 6627 696e 7661 6c69 6420 7661 6c75 , f'invalid valu\n-00001bc0: 6520 227b 7661 6c75 657d 2220 6e6f 7420 e \"{value}\" not \n-00001bd0: 696e 207b 6368 6f69 6365 737d 2729 0a20 in {choices}'). \n-00001be0: 2020 2072 6574 7572 6e20 5f67 6574 286f return _get(o\n-00001bf0: 626a 2c20 6173 5f63 686f 6963 652c 206b bj, as_choice, k\n-00001c00: 6579 2c20 6465 6661 756c 7429 0a0a 0a64 ey, default)...d\n-00001c10: 6566 2067 6574 5f6f 626a 7628 6f62 6a3a ef get_objv(obj:\n-00001c20: 204a 736f 6e4f 626a 6563 742c 206b 6579 JsonObject, key\n-00001c30: 3a20 7374 722c 2063 6f6e 7374 7275 6374 : str, construct\n-00001c40: 6f72 3a20 4361 6c6c 6162 6c65 5b5b 4a73 or: Callable[[Js\n-00001c50: 6f6e 4f62 6a65 6374 5d2c 2054 5d29 202d onObject], T]) -\n-00001c60: 3e20 556e 696f 6e5b 4454 2c20 5365 7175 > Union[DT, Sequ\n-00001c70: 656e 6365 5b54 5d5d 3a0a 2020 2020 6465 ence[T]]:. de\n-00001c80: 6620 6173 5f6f 626a 7628 7661 6c75 653a f as_objv(value:\n-00001c90: 204a 736f 6e56 616c 7565 2920 2d3e 2053 JsonValue) -> S\n-00001ca0: 6571 7565 6e63 655b 545d 3a0a 2020 2020 equence[T]:. \n-00001cb0: 2020 2020 7265 7475 726e 2074 7570 6c65 return tuple\n-00001cc0: 2863 6f6e 7374 7275 6374 6f72 2874 7970 (constructor(typ\n-00001cd0: 6563 6865 636b 6564 2869 7465 6d2c 2064 echecked(item, d\n-00001ce0: 6963 7429 2920 666f 7220 6974 656d 2069 ict)) for item i\n-00001cf0: 6e20 7479 7065 6368 6563 6b65 6428 7661 n typechecked(va\n-00001d00: 6c75 652c 206c 6973 7429 290a 2020 2020 lue, list)). \n-00001d10: 7265 7475 726e 205f 6765 7428 6f62 6a2c return _get(obj,\n-00001d20: 2061 735f 6f62 6a76 2c20 6b65 792c 2028 as_objv, key, (\n-00001d30: 2929 0a0a 0a64 6566 2063 7265 6174 655f ))...def create_\n-00001d40: 6f62 6a65 6374 286d 6573 7361 6765 3a20 object(message: \n-00001d50: 274a 736f 6e4f 626a 6563 7420 7c20 4e6f 'JsonObject | No\n-00001d60: 6e65 272c 206b 7761 7267 733a 204a 736f ne', kwargs: Jso\n-00001d70: 6e4f 626a 6563 7429 202d 3e20 4a73 6f6e nObject) -> Json\n-00001d80: 4f62 6a65 6374 3a0a 2020 2020 2222 2243 Object:. \"\"\"C\n-00001d90: 6f6e 7374 7275 6374 7320 6120 4a53 4f4e onstructs a JSON\n-00001da0: 206f 626a 6563 7420 6261 7365 6420 6f6e object based on\n-00001db0: 206d 6573 7361 6765 2061 6e64 206b 7761 message and kwa\n-00001dc0: 7267 732e 0a0a 2020 2020 4966 206f 6e6c rgs... If onl\n-00001dd0: 7920 6d65 7373 6167 6520 6973 2067 6976 y message is giv\n-00001de0: 656e 2c20 6974 2069 7320 7265 7475 726e en, it is return\n-00001df0: 6564 2c20 756e 6d6f 6469 6669 6564 2e20 ed, unmodified. \n-00001e00: 2049 6620 6d65 7373 6167 6520 6973 204e If message is N\n-00001e10: 6f6e 652c 0a20 2020 2069 7420 6973 2065 one,. it is e\n-00001e20: 7175 6976 616c 656e 7420 746f 2061 6e20 quivalent to an \n-00001e30: 656d 7074 7920 6469 6374 696f 6e61 7279 empty dictionary\n-00001e40: 2e20 2041 2063 6f70 7920 6973 2061 6c77 . A copy is alw\n-00001e50: 6179 7320 6d61 6465 2e0a 0a20 2020 2049 ays made... I\n-00001e60: 6620 6b77 6172 6773 2061 7265 2070 7265 f kwargs are pre\n-00001e70: 7365 6e74 2c20 7468 656e 2061 6e79 2075 sent, then any u\n-00001e80: 6e64 6572 7363 6f72 6520 2827 5f27 2920 nderscore ('_') \n-00001e90: 7072 6573 656e 7420 696e 2061 206b 6579 present in a key\n-00001ea0: 206e 616d 6520 6973 0a20 2020 2072 6577 name is. rew\n-00001eb0: 7269 7474 656e 2074 6f20 6120 6461 7368 ritten to a dash\n-00001ec0: 2028 272d 2729 2e20 2054 6869 7320 6973 ('-'). This is\n-00001ed0: 2069 6e74 656e 6465 6420 746f 2062 7269 intended to bri\n-00001ee0: 6467 6520 6265 7477 6565 6e20 7468 6520 dge between the \n-00001ef0: 7265 7175 6972 6564 0a20 2020 2050 7974 required. Pyt\n-00001f00: 686f 6e20 7379 6e74 6178 2077 6865 6e20 hon syntax when \n-00001f10: 7072 6f76 6964 696e 6720 6b77 6172 6773 providing kwargs\n-00001f20: 2061 6e64 2069 6469 6f6d 6174 6963 204a and idiomatic J\n-00001f30: 534f 4e20 2877 6869 6368 2075 7365 7320 SON (which uses \n-00001f40: 272d 2720 666f 720a 2020 2020 6174 7472 '-' for. attr\n-00001f50: 6962 7574 6573 292e 2020 5468 6573 6520 ibutes). These \n-00001f60: 7661 6c75 6573 206f 7665 7272 6964 6520 values override \n-00001f70: 7661 6c75 6573 2069 6e20 6d65 7373 6167 values in messag\n-00001f80: 652e 0a0a 2020 2020 5468 6520 6964 6561 e... The idea\n-00001f90: 2069 7320 7468 6174 2060 6d65 7373 6167 is that `messag\n-00001fa0: 6560 2073 686f 756c 6420 6265 2075 7365 e` should be use\n-00001fb0: 6420 666f 7220 7061 7373 696e 6720 6461 d for passing da\n-00001fc0: 7461 2061 6c6f 6e67 2c20 616e 640a 2020 ta along, and. \n-00001fd0: 2020 6b77 6172 6773 2075 7365 6420 666f kwargs used fo\n-00001fe0: 7220 6461 7461 206f 7269 6769 6e61 7469 r data originati\n-00001ff0: 6e67 2061 7420 6120 6769 7665 6e20 6361 ng at a given ca\n-00002000: 6c6c 2073 6974 652c 2070 6f73 7369 626c ll site, possibl\n-00002010: 7920 696e 636c 7564 696e 670a 2020 2020 y including. \n-00002020: 6d6f 6469 6669 6361 7469 6f6e 7320 746f modifications to\n-00002030: 2061 6e20 6f72 6967 696e 616c 206d 6573 an original mes\n-00002040: 7361 6765 2e0a 2020 2020 2222 220a 2020 sage.. \"\"\". \n-00002050: 2020 7265 7375 6c74 203d 2064 6963 7428 result = dict(\n-00002060: 6d65 7373 6167 6520 6f72 207b 7d29 0a0a message or {})..\n-00002070: 2020 2020 666f 7220 6b65 792c 2076 616c for key, val\n-00002080: 7565 2069 6e20 6b77 6172 6773 2e69 7465 ue in kwargs.ite\n-00002090: 6d73 2829 3a0a 2020 2020 2020 2020 2320 ms():. # \n-000020a0: 7265 7772 6974 6520 275f 2720 286e 6563 rewrite '_' (nec\n-000020b0: 6573 7361 7279 2069 6e20 5079 7468 6f6e essary in Python\n-000020c0: 2073 796e 7461 7820 6b77 6172 6773 206c syntax kwargs l\n-000020d0: 6973 7429 2074 6f20 272d 2720 2869 6469 ist) to '-' (idi\n-000020e0: 6f6d 6174 6963 204a 534f 4e29 0a20 2020 omatic JSON). \n-000020f0: 2020 2020 206a 736f 6e5f 6b65 7920 3d20 json_key = \n-00002100: 6b65 792e 7265 706c 6163 6528 275f 272c key.replace('_',\n-00002110: 2027 2d27 290a 2020 2020 2020 2020 7265 '-'). re\n-00002120: 7375 6c74 5b6a 736f 6e5f 6b65 795d 203d sult[json_key] =\n-00002130: 2076 616c 7565 0a0a 2020 2020 7265 7475 value.. retu\n-00002140: 726e 2072 6573 756c 740a 0a0a 6465 6620 rn result...def \n-00002150: 6a73 6f6e 5f6d 6572 6765 5f70 6174 6368 json_merge_patch\n-00002160: 2863 7572 7265 6e74 3a20 4a73 6f6e 4f62 (current: JsonOb\n-00002170: 6a65 6374 2c20 7061 7463 683a 204a 736f ject, patch: Jso\n-00002180: 6e4f 626a 6563 7429 202d 3e20 4a73 6f6e nObject) -> Json\n-00002190: 4f62 6a65 6374 3a0a 2020 2020 2222 2250 Object:. \"\"\"P\n-000021a0: 6572 666f 726d 2061 204a 534f 4e20 6d65 erform a JSON me\n-000021b0: 7267 6520 7061 7463 6820 2852 4643 2037 rge patch (RFC 7\n-000021c0: 3339 3629 2075 7369 6e67 2027 6375 7272 396) using 'curr\n-000021d0: 656e 7427 2061 6e64 2027 7061 7463 6827 ent' and 'patch'\n-000021e0: 2e0a 2020 2020 4e65 6974 6865 7220 6f66 .. Neither of\n-000021f0: 2074 6865 206f 7269 6769 6e61 6c20 6469 the original di\n-00002200: 6374 696f 6e61 7269 6573 2069 7320 6d6f ctionaries is mo\n-00002210: 6469 6669 6564 20e2 8094 2074 6865 2072 dified ... the r\n-00002220: 6573 756c 7420 6973 2072 6574 7572 6e65 esult is returne\n-00002230: 642e 0a20 2020 2022 2222 0a20 2020 2023 d.. \"\"\". #\n-00002240: 2041 6c77 6179 7320 7461 6b65 2061 2063 Always take a c\n-00002250: 6f70 7920 2827 7265 7375 6c74 2729 20e2 opy ('result') .\n-00002260: 8094 2077 6520 6e65 7665 7220 6d6f 6469 .. we never modi\n-00002270: 6679 2074 6865 2069 6e70 7574 2028 2763 fy the input ('c\n-00002280: 7572 7265 6e74 2729 0a20 2020 2072 6573 urrent'). res\n-00002290: 756c 7420 3d20 6469 6374 2863 7572 7265 ult = dict(curre\n-000022a0: 6e74 290a 2020 2020 666f 7220 6b65 792c nt). for key,\n-000022b0: 2070 6174 6368 5f76 616c 7565 2069 6e20 patch_value in \n-000022c0: 7061 7463 682e 6974 656d 7328 293a 0a20 patch.items():. \n-000022d0: 2020 2020 2020 2069 6620 6973 696e 7374 if isinst\n-000022e0: 616e 6365 2870 6174 6368 5f76 616c 7565 ance(patch_value\n-000022f0: 2c20 4d61 7070 696e 6729 3a0a 2020 2020 , Mapping):. \n-00002300: 2020 2020 2020 2020 6375 7272 656e 745f current_\n-00002310: 7661 6c75 6520 3d20 6375 7272 656e 742e value = current.\n-00002320: 6765 7428 6b65 792c 204e 6f6e 6529 0a20 get(key, None). \n-00002330: 2020 2020 2020 2020 2020 2069 6620 6e6f if no\n-00002340: 7420 6973 696e 7374 616e 6365 2863 7572 t isinstance(cur\n-00002350: 7265 6e74 5f76 616c 7565 2c20 4d61 7070 rent_value, Mapp\n-00002360: 696e 6729 3a0a 2020 2020 2020 2020 2020 ing):. \n-00002370: 2020 2020 2020 6375 7272 656e 745f 7661 current_va\n-00002380: 6c75 6520 3d20 7b7d 0a20 2020 2020 2020 lue = {}. \n-00002390: 2020 2020 2072 6573 756c 745b 6b65 795d result[key]\n-000023a0: 203d 206a 736f 6e5f 6d65 7267 655f 7061 = json_merge_pa\n-000023b0: 7463 6828 6375 7272 656e 745f 7661 6c75 tch(current_valu\n-000023c0: 652c 2070 6174 6368 5f76 616c 7565 290a e, patch_value).\n-000023d0: 2020 2020 2020 2020 656c 6966 2070 6174 elif pat\n-000023e0: 6368 5f76 616c 7565 2069 7320 6e6f 7420 ch_value is not \n-000023f0: 4e6f 6e65 3a0a 2020 2020 2020 2020 2020 None:. \n-00002400: 2020 7265 7375 6c74 5b6b 6579 5d20 3d20 result[key] = \n-00002410: 7061 7463 685f 7661 6c75 650a 2020 2020 patch_value. \n-00002420: 2020 2020 656c 7365 3a0a 2020 2020 2020 else:. \n-00002430: 2020 2020 2020 7265 7375 6c74 2e70 6f70 result.pop\n-00002440: 286b 6579 2c20 4e6f 6e65 290a 0a20 2020 (key, None).. \n-00002450: 2072 6574 7572 6e20 7265 7375 6c74 0a0a return result..\n-00002460: 0a64 6566 206a 736f 6e5f 6d65 7267 655f .def json_merge_\n-00002470: 616e 645f 6669 6c74 6572 5f70 6174 6368 and_filter_patch\n-00002480: 2863 7572 7265 6e74 3a20 4a73 6f6e 4469 (current: JsonDi\n-00002490: 6374 2c20 7061 7463 683a 204a 736f 6e44 ct, patch: JsonD\n-000024a0: 6963 7429 202d 3e20 4e6f 6e65 3a0a 2020 ict) -> None:. \n-000024b0: 2020 2222 2250 6572 666f 726d 2061 204a \"\"\"Perform a J\n-000024c0: 534f 4e20 6d65 7267 6520 7061 7463 6820 SON merge patch \n-000024d0: 2852 4643 2037 3339 3629 206d 6f64 6966 (RFC 7396) modif\n-000024e0: 7969 6e67 2027 6375 7272 656e 7427 2077 ying 'current' w\n-000024f0: 6974 6820 2770 6174 6368 272e 0a20 2020 ith 'patch'.. \n-00002500: 2041 6c73 6f20 6d6f 6469 6669 6573 2027 Also modifies '\n-00002510: 7061 7463 6827 2074 6f20 7265 6d6f 7665 patch' to remove\n-00002520: 2072 6564 756e 6461 6e74 206f 7065 7261 redundant opera\n-00002530: 7469 6f6e 732e 0a20 2020 2022 2222 0a20 tions.. \"\"\". \n-00002540: 2020 2066 6f72 206b 6579 2c20 7061 7463 for key, patc\n-00002550: 685f 7661 6c75 6520 696e 2074 7570 6c65 h_value in tuple\n-00002560: 2870 6174 6368 2e69 7465 6d73 2829 293a (patch.items()):\n-00002570: 0a20 2020 2020 2020 2063 7572 7265 6e74 . current\n-00002580: 5f76 616c 7565 203d 2063 7572 7265 6e74 _value = current\n-00002590: 2e67 6574 286b 6579 2c20 4e6f 6e65 290a .get(key, None).\n-000025a0: 0a20 2020 2020 2020 2069 6620 6973 696e . if isin\n-000025b0: 7374 616e 6365 2870 6174 6368 5f76 616c stance(patch_val\n-000025c0: 7565 2c20 6469 6374 293a 0a20 2020 2020 ue, dict):. \n-000025d0: 2020 2020 2020 2069 6620 6e6f 7420 6973 if not is\n-000025e0: 696e 7374 616e 6365 2863 7572 7265 6e74 instance(current\n-000025f0: 5f76 616c 7565 2c20 6469 6374 293a 0a20 _value, dict):. \n-00002600: 2020 2020 2020 2020 2020 2020 2020 2063 c\n-00002610: 7572 7265 6e74 5b6b 6579 5d20 3d20 6375 urrent[key] = cu\n-00002620: 7272 656e 745f 7661 6c75 6520 3d20 7b7d rrent_value = {}\n-00002630: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-00002640: 206a 736f 6e5f 6d65 7267 655f 616e 645f json_merge_and_\n-00002650: 6669 6c74 6572 5f70 6174 6368 2863 7572 filter_patch(cur\n-00002660: 7265 6e74 5f76 616c 7565 2c20 7061 7463 rent_value, patc\n-00002670: 685f 7661 6c75 6529 0a20 2020 2020 2020 h_value). \n-00002680: 2020 2020 2065 6c73 653a 0a20 2020 2020 else:. \n-00002690: 2020 2020 2020 2020 2020 206a 736f 6e5f json_\n-000026a0: 6d65 7267 655f 616e 645f 6669 6c74 6572 merge_and_filter\n-000026b0: 5f70 6174 6368 2863 7572 7265 6e74 5f76 _patch(current_v\n-000026c0: 616c 7565 2c20 7061 7463 685f 7661 6c75 alue, patch_valu\n-000026d0: 6529 0a20 2020 2020 2020 2020 2020 2020 e). \n-000026e0: 2020 2069 6620 6e6f 7420 7061 7463 685f if not patch_\n-000026f0: 7661 6c75 653a 0a20 2020 2020 2020 2020 value:. \n-00002700: 2020 2020 2020 2020 2020 2064 656c 2070 del p\n-00002710: 6174 6368 5b6b 6579 5d0a 2020 2020 2020 atch[key]. \n-00002720: 2020 656c 6966 2063 7572 7265 6e74 5f76 elif current_v\n-00002730: 616c 7565 203d 3d20 7061 7463 685f 7661 alue == patch_va\n-00002740: 6c75 653a 0a20 2020 2020 2020 2020 2020 lue:. \n-00002750: 2064 656c 2070 6174 6368 5b6b 6579 5d0a del patch[key].\n-00002760: 2020 2020 2020 2020 656c 6966 2070 6174 elif pat\n-00002770: 6368 5f76 616c 7565 2069 7320 6e6f 7420 ch_value is not \n-00002780: 4e6f 6e65 3a0a 2020 2020 2020 2020 2020 None:. \n-00002790: 2020 6375 7272 656e 745b 6b65 795d 203d current[key] =\n-000027a0: 2070 6174 6368 5f76 616c 7565 0a20 2020 patch_value. \n-000027b0: 2020 2020 2065 6c73 653a 0a20 2020 2020 else:. \n-000027c0: 2020 2020 2020 2064 656c 2063 7572 7265 del curre\n-000027d0: 6e74 5b6b 6579 5d0a 2727 272e 656e 636f nt[key].'''.enco\n-000027e0: 6465 2827 7574 662d 3827 292c 0a20 2027 de('utf-8'),. '\n-000027f0: 636f 636b 7069 742f 7361 6d70 6c65 732e cockpit/samples.\n-00002800: 7079 273a 2062 7227 2727 2320 5468 6973 py': br'''# This\n-00002810: 2066 696c 6520 6973 2070 6172 7420 6f66 file is part of\n-00002820: 2043 6f63 6b70 6974 2e0a 230a 2320 436f Cockpit..#.# Co\n-00002830: 7079 7269 6768 7420 2843 2920 3230 3232 pyright (C) 2022\n-00002840: 2052 6564 2048 6174 2c20 496e 632e 0a23 Red Hat, Inc..#\n-00002850: 0a23 2054 6869 7320 7072 6f67 7261 6d20 .# This program \n-00002860: 6973 2066 7265 6520 736f 6674 7761 7265 is free software\n-00002870: 3a20 796f 7520 6361 6e20 7265 6469 7374 : you can redist\n-00002880: 7269 6275 7465 2069 7420 616e 642f 6f72 ribute it and/or\n-00002890: 206d 6f64 6966 790a 2320 6974 2075 6e64 modify.# it und\n-000028a0: 6572 2074 6865 2074 6572 6d73 206f 6620 er the terms of \n-000028b0: 7468 6520 474e 5520 4765 6e65 7261 6c20 the GNU General \n-000028c0: 5075 626c 6963 204c 6963 656e 7365 2061 Public License a\n-000028d0: 7320 7075 626c 6973 6865 6420 6279 0a23 s published by.#\n-000028e0: 2074 6865 2046 7265 6520 536f 6674 7761 the Free Softwa\n-000028f0: 7265 2046 6f75 6e64 6174 696f 6e2c 2065 re Foundation, e\n-00002900: 6974 6865 7220 7665 7273 696f 6e20 3320 ither version 3 \n-00002910: 6f66 2074 6865 204c 6963 656e 7365 2c20 of the License, \n-00002920: 6f72 0a23 2028 6174 2079 6f75 7220 6f70 or.# (at your op\n-00002930: 7469 6f6e 2920 616e 7920 6c61 7465 7220 tion) any later \n-00002940: 7665 7273 696f 6e2e 0a23 0a23 2054 6869 version..#.# Thi\n-00002950: 7320 7072 6f67 7261 6d20 6973 2064 6973 s program is dis\n-00002960: 7472 6962 7574 6564 2069 6e20 7468 6520 tributed in the \n-00002970: 686f 7065 2074 6861 7420 6974 2077 696c hope that it wil\n-00002980: 6c20 6265 2075 7365 6675 6c2c 0a23 2062 l be useful,.# b\n-00002990: 7574 2057 4954 484f 5554 2041 4e59 2057 ut WITHOUT ANY W\n-000029a0: 4152 5241 4e54 593b 2077 6974 686f 7574 ARRANTY; without\n-000029b0: 2065 7665 6e20 7468 6520 696d 706c 6965 even the implie\n-000029c0: 6420 7761 7272 616e 7479 206f 660a 2320 d warranty of.# \n-000029d0: 4d45 5243 4841 4e54 4142 494c 4954 5920 MERCHANTABILITY \n-000029e0: 6f72 2046 4954 4e45 5353 2046 4f52 2041 or FITNESS FOR A\n-000029f0: 2050 4152 5449 4355 4c41 5220 5055 5250 PARTICULAR PURP\n-00002a00: 4f53 452e 2020 5365 6520 7468 650a 2320 OSE. See the.# \n-00002a10: 474e 5520 4765 6e65 7261 6c20 5075 626c GNU General Publ\n-00002a20: 6963 204c 6963 656e 7365 2066 6f72 206d ic License for m\n-00002a30: 6f72 6520 6465 7461 696c 732e 0a23 0a23 ore details..#.#\n-00002a40: 2059 6f75 2073 686f 756c 6420 6861 7665 You should have\n-00002a50: 2072 6563 6569 7665 6420 6120 636f 7079 received a copy\n-00002a60: 206f 6620 7468 6520 474e 5520 4765 6e65 of the GNU Gene\n-00002a70: 7261 6c20 5075 626c 6963 204c 6963 656e ral Public Licen\n-00002a80: 7365 0a23 2061 6c6f 6e67 2077 6974 6820 se.# along with \n-00002a90: 7468 6973 2070 726f 6772 616d 2e20 2049 this program. I\n-00002aa0: 6620 6e6f 742c 2073 6565 203c 6874 7470 f not, see ...imp\n-00002ad0: 6f72 7420 6572 726e 6f0a 696d 706f 7274 ort errno.import\n-00002ae0: 206c 6f67 6769 6e67 0a69 6d70 6f72 7420 logging.import \n-00002af0: 6f73 0a69 6d70 6f72 7420 7265 0a66 726f os.import re.fro\n-00002b00: 6d20 7479 7069 6e67 2069 6d70 6f72 7420 m typing import \n-00002b10: 416e 792c 2044 6566 6175 6c74 4469 6374 Any, DefaultDict\n-00002b20: 2c20 4974 6572 6162 6c65 2c20 4c69 7374 , Iterable, List\n-00002b30: 2c20 4e61 6d65 6454 7570 6c65 2c20 4f70 , NamedTuple, Op\n-00002b40: 7469 6f6e 616c 2c20 5475 706c 650a 0a66 tional, Tuple..f\n-00002b50: 726f 6d20 636f 636b 7069 742e 5f76 656e rom cockpit._ven\n-00002b60: 646f 722e 7379 7374 656d 645f 6374 7970 dor.systemd_ctyp\n-00002b70: 6573 2069 6d70 6f72 7420 4861 6e64 6c65 es import Handle\n-00002b80: 0a0a 5553 4552 5f48 5a20 3d20 6f73 2e73 ..USER_HZ = os.s\n-00002b90: 7973 636f 6e66 286f 732e 7379 7363 6f6e ysconf(os.syscon\n-00002ba0: 665f 6e61 6d65 735b 2753 435f 434c 4b5f f_names['SC_CLK_\n-00002bb0: 5443 4b27 5d29 0a4d 535f 5045 525f 4a49 TCK']).MS_PER_JI\n-00002bc0: 4646 5920 3d20 3130 3030 202f 2028 5553 FFY = 1000 / (US\n-00002bd0: 4552 5f48 5a20 6966 2028 5553 4552 5f48 ER_HZ if (USER_H\n-00002be0: 5a20 3e20 3029 2065 6c73 6520 3130 3029 Z > 0) else 100)\n-00002bf0: 0a48 574d 4f4e 5f50 4154 4820 3d20 272f .HWMON_PATH = '/\n-00002c00: 7379 732f 636c 6173 732f 6877 6d6f 6e27 sys/class/hwmon'\n-00002c10: 0a0a 2320 7765 2077 6f75 6c64 206c 696b ..# we would lik\n-00002c20: 6520 746f 2064 6f20 7468 6973 2c20 6275 e to do this, bu\n-00002c30: 7420 6d79 7079 2063 6f6d 706c 6169 6e73 t mypy complains\n-00002c40: 3b20 6874 7470 733a 2f2f 6769 7468 7562 ; https://github\n-00002c50: 2e63 6f6d 2f70 7974 686f 6e2f 6d79 7079 .com/python/mypy\n-00002c60: 2f69 7373 7565 732f 3239 3030 0a23 2053 /issues/2900.# S\n-00002c70: 616d 706c 6573 203d 2063 6f6c 6c65 6374 amples = collect\n-00002c80: 696f 6e73 2e64 6566 6175 6c74 6469 6374 ions.defaultdict\n-00002c90: 5b73 7472 2c20 556e 696f 6e5b 666c 6f61 [str, Union[floa\n-00002ca0: 742c 2044 6963 745b 7374 722c 2055 6e69 t, Dict[str, Uni\n-00002cb0: 6f6e 5b66 6c6f 6174 2c20 4e6f 6e65 5d5d on[float, None]]\n-00002cc0: 5d5d 0a53 616d 706c 6573 203d 2044 6566 ]].Samples = Def\n-00002cd0: 6175 6c74 4469 6374 5b73 7472 2c20 416e aultDict[str, An\n-00002ce0: 795d 0a0a 6c6f 6767 6572 203d 206c 6f67 y]..logger = log\n-00002cf0: 6769 6e67 2e67 6574 4c6f 6767 6572 285f ging.getLogger(_\n-00002d00: 5f6e 616d 655f 5f29 0a0a 0a64 6566 2072 _name__)...def r\n-00002d10: 6561 645f 696e 745f 6669 6c65 2872 6f6f ead_int_file(roo\n-00002d20: 7466 643a 2069 6e74 2c20 7374 6174 6669 tfd: int, statfi\n-00002d30: 6c65 3a20 7374 722c 2064 6566 6175 6c74 le: str, default\n-00002d40: 3a20 4f70 7469 6f6e 616c 5b69 6e74 5d20 : Optional[int] \n-00002d50: 3d20 4e6f 6e65 2c20 6b65 793a 2062 7974 = None, key: byt\n-00002d60: 6573 203d 2062 2727 2920 2d3e 204f 7074 es = b'') -> Opt\n-00002d70: 696f 6e61 6c5b 696e 745d 3a0a 2020 2020 ional[int]:. \n-00002d80: 2320 4e6f 7420 6576 6572 7920 7374 6174 # Not every stat\n-00002d90: 2069 7320 6176 6169 6c61 626c 652c 2073 is available, s\n-00002da0: 7563 6820 6173 2063 7075 2e77 6569 6768 uch as cpu.weigh\n-00002db0: 740a 2020 2020 7472 793a 0a20 2020 2020 t. try:. \n-00002dc0: 2020 2066 6420 3d20 6f73 2e6f 7065 6e28 fd = os.open(\n-00002dd0: 7374 6174 6669 6c65 2c20 6f73 2e4f 5f52 statfile, os.O_R\n-00002de0: 444f 4e4c 592c 2064 6972 5f66 643d 726f DONLY, dir_fd=ro\n-00002df0: 6f74 6664 290a 2020 2020 6578 6365 7074 otfd). except\n-00002e00: 2046 696c 654e 6f74 466f 756e 6445 7272 FileNotFoundErr\n-00002e10: 6f72 3a0a 2020 2020 2020 2020 7265 7475 or:. retu\n-00002e20: 726e 204e 6f6e 650a 0a20 2020 2074 7279 rn None.. try\n-00002e30: 3a0a 2020 2020 2020 2020 6461 7461 203d :. data =\n-00002e40: 206f 732e 7265 6164 2866 642c 2031 3032 os.read(fd, 102\n-00002e50: 3429 0a20 2020 2065 7863 6570 7420 4f53 4). except OS\n-00002e60: 4572 726f 7220 6173 2065 3a0a 2020 2020 Error as e:. \n-00002e70: 2020 2020 2320 6367 726f 7570 7320 6361 # cgroups ca\n-00002e80: 6e20 6469 7361 7070 6561 7220 6265 7477 n disappear betw\n-00002e90: 6565 6e20 7468 6520 6f70 656e 2061 6e64 een the open and\n-00002ea0: 2072 6561 640a 2020 2020 2020 2020 6966 read. if\n-00002eb0: 2065 2e65 7272 6e6f 2021 3d20 6572 726e e.errno != errn\n-00002ec0: 6f2e 454e 4f44 4556 3a0a 2020 2020 2020 o.ENODEV:. \n-00002ed0: 2020 2020 2020 6c6f 6767 6572 2e77 6172 logger.war\n-00002ee0: 6e69 6e67 2827 4661 696c 6564 2074 6f20 ning('Failed to \n-00002ef0: 7265 6164 2025 733a 2025 7327 2c20 7374 read %s: %s', st\n-00002f00: 6174 6669 6c65 2c20 6529 0a20 2020 2020 atfile, e). \n-00002f10: 2020 2072 6574 7572 6e20 4e6f 6e65 0a20 return None. \n-00002f20: 2020 2066 696e 616c 6c79 3a0a 2020 2020 finally:. \n-00002f30: 2020 2020 6f73 2e63 6c6f 7365 2866 6429 os.close(fd)\n-00002f40: 0a0a 2020 2020 6966 206b 6579 3a0a 2020 .. if key:. \n-00002f50: 2020 2020 2020 7374 6172 7420 3d20 6461 start = da\n-00002f60: 7461 2e69 6e64 6578 286b 6579 2920 2b20 ta.index(key) + \n-00002f70: 6c65 6e28 6b65 7929 0a20 2020 2020 2020 len(key). \n-00002f80: 2065 6e64 203d 2064 6174 612e 696e 6465 end = data.inde\n-00002f90: 7828 6227 5c6e 272c 2073 7461 7274 290a x(b'\\n', start).\n-00002fa0: 2020 2020 2020 2020 6461 7461 203d 2064 data = d\n-00002fb0: 6174 615b 7374 6172 743a 656e 645d 0a0a ata[start:end]..\n-00002fc0: 2020 2020 7472 793a 0a20 2020 2020 2020 try:. \n-00002fd0: 2023 2030 206f 6674 656e 206d 6561 6e73 # 0 often means\n-00002fe0: 2022 6e6f 6e65 222c 2073 6f20 7265 706c \"none\", so repl\n-00002ff0: 6163 6520 6974 2077 6974 6820 6465 6661 ace it with defa\n-00003000: 756c 7420 7661 6c75 650a 2020 2020 2020 ult value. \n-00003010: 2020 7265 7475 726e 2069 6e74 2864 6174 return int(dat\n-00003020: 6129 206f 7220 6465 6661 756c 740a 2020 a) or default. \n-00003030: 2020 6578 6365 7074 2056 616c 7565 4572 except ValueEr\n-00003040: 726f 723a 0a20 2020 2020 2020 2023 2053 ror:. # S\n-00003050: 6f6d 6520 7361 6d70 6c65 7320 7375 6368 ome samples such\n-00003060: 2061 7320 226d 656d 6f72 792e 6d61 7822 as \"memory.max\"\n-00003070: 2063 6f6e 7461 696e 7320 226d 6178 2220 contains \"max\" \n-00003080: 7768 656e 2074 6865 7265 2069 7320 6120 when there is a \n-00003090: 6e6f 206c 696d 6974 0a20 2020 2020 2020 no limit. \n-000030a0: 2072 6574 7572 6e20 4e6f 6e65 0a0a 0a63 return None...c\n-000030b0: 6c61 7373 2053 616d 706c 6544 6573 6372 lass SampleDescr\n-000030c0: 6970 7469 6f6e 284e 616d 6564 5475 706c iption(NamedTupl\n-000030d0: 6529 3a0a 2020 2020 6e61 6d65 3a20 7374 e):. name: st\n-000030e0: 720a 2020 2020 756e 6974 733a 2073 7472 r. units: str\n-000030f0: 0a20 2020 2073 656d 616e 7469 6373 3a20 . semantics: \n-00003100: 7374 720a 2020 2020 696e 7374 616e 6365 str. instance\n-00003110: 643a 2062 6f6f 6c0a 0a0a 636c 6173 7320 d: bool...class \n-00003120: 5361 6d70 6c65 723a 0a20 2020 2064 6573 Sampler:. des\n-00003130: 6372 6970 7469 6f6e 733a 204c 6973 745b criptions: List[\n-00003140: 5361 6d70 6c65 4465 7363 7269 7074 696f SampleDescriptio\n-00003150: 6e5d 0a0a 2020 2020 6465 6620 7361 6d70 n].. def samp\n-00003160: 6c65 2873 656c 662c 2073 616d 706c 6573 le(self, samples\n-00003170: 3a20 5361 6d70 6c65 7329 202d 3e20 4e6f : Samples) -> No\n-00003180: 6e65 3a0a 2020 2020 2020 2020 7261 6973 ne:. rais\n-00003190: 6520 4e6f 7449 6d70 6c65 6d65 6e74 6564 e NotImplemented\n-000031a0: 4572 726f 720a 0a0a 636c 6173 7320 4350 Error...class CP\n-000031b0: 5553 616d 706c 6572 2853 616d 706c 6572 USampler(Sampler\n-000031c0: 293a 0a20 2020 2064 6573 6372 6970 7469 ):. descripti\n-000031d0: 6f6e 7320 3d20 5b0a 2020 2020 2020 2020 ons = [. \n-000031e0: 5361 6d70 6c65 4465 7363 7269 7074 696f SampleDescriptio\n-000031f0: 6e28 2763 7075 2e62 6173 6963 2e6e 6963 n('cpu.basic.nic\n-00003200: 6527 2c20 276d 696c 6c69 7365 6327 2c20 e', 'millisec', \n-00003210: 2763 6f75 6e74 6572 272c 2069 6e73 7461 'counter', insta\n-00003220: 6e63 6564 3d46 616c 7365 292c 0a20 2020 nced=False),. \n-00003230: 2020 2020 2053 616d 706c 6544 6573 6372 SampleDescr\n-00003240: 6970 7469 6f6e 2827 6370 752e 6261 7369 iption('cpu.basi\n-00003250: 632e 7573 6572 272c 2027 6d69 6c6c 6973 c.user', 'millis\n-00003260: 6563 272c 2027 636f 756e 7465 7227 2c20 ec', 'counter', \n-00003270: 696e 7374 616e 6365 643d 4661 6c73 6529 instanced=False)\n-00003280: 2c0a 2020 2020 2020 2020 5361 6d70 6c65 ,. Sample\n-00003290: 4465 7363 7269 7074 696f 6e28 2763 7075 Description('cpu\n-000032a0: 2e62 6173 6963 2e73 7973 7465 6d27 2c20 .basic.system', \n-000032b0: 276d 696c 6c69 7365 6327 2c20 2763 6f75 'millisec', 'cou\n-000032c0: 6e74 6572 272c 2069 6e73 7461 6e63 6564 nter', instanced\n-000032d0: 3d46 616c 7365 292c 0a20 2020 2020 2020 =False),. \n-000032e0: 2053 616d 706c 6544 6573 6372 6970 7469 SampleDescripti\n-000032f0: 6f6e 2827 6370 752e 6261 7369 632e 696f on('cpu.basic.io\n-00003300: 7761 6974 272c 2027 6d69 6c6c 6973 6563 wait', 'millisec\n-00003310: 272c 2027 636f 756e 7465 7227 2c20 696e ', 'counter', in\n-00003320: 7374 616e 6365 643d 4661 6c73 6529 2c0a stanced=False),.\n-00003330: 0a20 2020 2020 2020 2053 616d 706c 6544 . SampleD\n-00003340: 6573 6372 6970 7469 6f6e 2827 6370 752e escription('cpu.\n-00003350: 636f 7265 2e6e 6963 6527 2c20 276d 696c core.nice', 'mil\n-00003360: 6c69 7365 6327 2c20 2763 6f75 6e74 6572 lisec', 'counter\n-00003370: 272c 2069 6e73 7461 6e63 6564 3d54 7275 ', instanced=Tru\n-00003380: 6529 2c0a 2020 2020 2020 2020 5361 6d70 e),. Samp\n-00003390: 6c65 4465 7363 7269 7074 696f 6e28 2763 leDescription('c\n-000033a0: 7075 2e63 6f72 652e 7573 6572 272c 2027 pu.core.user', '\n-000033b0: 6d69 6c6c 6973 6563 272c 2027 636f 756e millisec', 'coun\n-000033c0: 7465 7227 2c20 696e 7374 616e 6365 643d ter', instanced=\n-000033d0: 5472 7565 292c 0a20 2020 2020 2020 2053 True),. S\n-000033e0: 616d 706c 6544 6573 6372 6970 7469 6f6e ampleDescription\n-000033f0: 2827 6370 752e 636f 7265 2e73 7973 7465 ('cpu.core.syste\n-00003400: 6d27 2c20 276d 696c 6c69 7365 6327 2c20 m', 'millisec', \n-00003410: 2763 6f75 6e74 6572 272c 2069 6e73 7461 'counter', insta\n-00003420: 6e63 6564 3d54 7275 6529 2c0a 2020 2020 nced=True),. \n-00003430: 2020 2020 5361 6d70 6c65 4465 7363 7269 SampleDescri\n-00003440: 7074 696f 6e28 2763 7075 2e63 6f72 652e ption('cpu.core.\n-00003450: 696f 7761 6974 272c 2027 6d69 6c6c 6973 iowait', 'millis\n-00003460: 6563 272c 2027 636f 756e 7465 7227 2c20 ec', 'counter', \n-00003470: 696e 7374 616e 6365 643d 5472 7565 292c instanced=True),\n-00003480: 0a20 2020 205d 0a0a 2020 2020 6465 6620 . ].. def \n-00003490: 7361 6d70 6c65 2873 656c 662c 2073 616d sample(self, sam\n-000034a0: 706c 6573 3a20 5361 6d70 6c65 7329 202d ples: Samples) -\n-000034b0: 3e20 4e6f 6e65 3a0a 2020 2020 2020 2020 > None:. \n-000034c0: 7769 7468 206f 7065 6e28 272f 7072 6f63 with open('/proc\n-000034d0: 2f73 7461 7427 2920 6173 2073 7461 743a /stat') as stat:\n-000034e0: 0a20 2020 2020 2020 2020 2020 2066 6f72 . for\n-000034f0: 206c 696e 6520 696e 2073 7461 743a 0a20 line in stat:. \n-00003500: 2020 2020 2020 2020 2020 2020 2020 2069 i\n-00003510: 6620 6e6f 7420 6c69 6e65 2e73 7461 7274 f not line.start\n-00003520: 7377 6974 6828 2763 7075 2729 3a0a 2020 swith('cpu'):. \n-00003530: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00003540: 2020 636f 6e74 696e 7565 0a20 2020 2020 continue. \n-00003550: 2020 2020 2020 2020 2020 2063 7075 2c20 cpu, \n-00003560: 7573 6572 2c20 6e69 6365 2c20 7379 7374 user, nice, syst\n-00003570: 656d 2c20 5f69 646c 652c 2069 6f77 6169 em, _idle, iowai\n-00003580: 7420 3d20 6c69 6e65 2e73 706c 6974 2829 t = line.split()\n-00003590: 5b3a 365d 0a20 2020 2020 2020 2020 2020 [:6]. \n-000035a0: 2020 2020 2063 6f72 6520 3d20 6370 755b core = cpu[\n-000035b0: 333a 5d20 6f72 204e 6f6e 650a 2020 2020 3:] or None. \n-000035c0: 2020 2020 2020 2020 2020 2020 6966 2063 if c\n-000035d0: 6f72 653a 0a20 2020 2020 2020 2020 2020 ore:. \n-000035e0: 2020 2020 2020 2020 2070 7265 6669 7820 prefix \n-000035f0: 3d20 2763 7075 2e63 6f72 6527 0a20 2020 = 'cpu.core'. \n-00003600: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00003610: 2073 616d 706c 6573 5b66 277b 7072 6566 samples[f'{pref\n-00003620: 6978 7d2e 6e69 6365 275d 5b63 6f72 655d ix}.nice'][core]\n-00003630: 203d 2069 6e74 286e 6963 6529 202a 204d = int(nice) * M\n-00003640: 535f 5045 525f 4a49 4646 590a 2020 2020 S_PER_JIFFY. \n-00003650: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00003660: 7361 6d70 6c65 735b 6627 7b70 7265 6669 samples[f'{prefi\n-00003670: 787d 2e75 7365 7227 5d5b 636f 7265 5d20 x}.user'][core] \n-00003680: 3d20 696e 7428 7573 6572 2920 2a20 4d53 = int(user) * MS\n-00003690: 5f50 4552 5f4a 4946 4659 0a20 2020 2020 _PER_JIFFY. \n-000036a0: 2020 2020 2020 2020 2020 2020 2020 2073 s\n-000036b0: 616d 706c 6573 5b66 277b 7072 6566 6978 amples[f'{prefix\n-000036c0: 7d2e 7379 7374 656d 275d 5b63 6f72 655d }.system'][core]\n-000036d0: 203d 2069 6e74 2873 7973 7465 6d29 202a = int(system) *\n-000036e0: 204d 535f 5045 525f 4a49 4646 590a 2020 MS_PER_JIFFY. \n-000036f0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00003700: 2020 7361 6d70 6c65 735b 6627 7b70 7265 samples[f'{pre\n-00003710: 6669 787d 2e69 6f77 6169 7427 5d5b 636f fix}.iowait'][co\n-00003720: 7265 5d20 3d20 696e 7428 696f 7761 6974 re] = int(iowait\n-00003730: 2920 2a20 4d53 5f50 4552 5f4a 4946 4659 ) * MS_PER_JIFFY\n-00003740: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-00003750: 2065 6c73 653a 0a20 2020 2020 2020 2020 else:. \n-00003760: 2020 2020 2020 2020 2020 2070 7265 6669 prefi\n-00003770: 7820 3d20 2763 7075 2e62 6173 6963 270a x = 'cpu.basic'.\n+00000b40: 6b70 6974 2f5f 5f69 6e69 745f 5f2e 7079 kpit/__init__.py\n+00000b50: 273a 2062 7227 2727 6672 6f6d 202e 5f76 ': br'''from ._v\n+00000b60: 6572 7369 6f6e 2069 6d70 6f72 7420 5f5f ersion import __\n+00000b70: 7665 7273 696f 6e5f 5f0a 0a5f 5f61 6c6c version__..__all\n+00000b80: 5f5f 203d 2028 0a20 2020 2027 5f5f 7665 __ = (. '__ve\n+00000b90: 7273 696f 6e5f 5f27 2c0a 290a 2727 272c rsion__',.).''',\n+00000ba0: 0a20 2027 636f 636b 7069 742f 696e 7465 . 'cockpit/inte\n+00000bb0: 726e 616c 5f65 6e64 706f 696e 7473 2e70 rnal_endpoints.p\n+00000bc0: 7927 3a20 6272 2727 2723 2054 6869 7320 y': br'''# This \n+00000bd0: 6669 6c65 2069 7320 7061 7274 206f 6620 file is part of \n+00000be0: 436f 636b 7069 742e 0a23 0a23 2043 6f70 Cockpit..#.# Cop\n+00000bf0: 7972 6967 6874 2028 4329 2032 3032 3220 yright (C) 2022 \n+00000c00: 5265 6420 4861 742c 2049 6e63 2e0a 230a Red Hat, Inc..#.\n+00000c10: 2320 5468 6973 2070 726f 6772 616d 2069 # This program i\n+00000c20: 7320 6672 6565 2073 6f66 7477 6172 653a s free software:\n+00000c30: 2079 6f75 2063 616e 2072 6564 6973 7472 you can redistr\n+00000c40: 6962 7574 6520 6974 2061 6e64 2f6f 7220 ibute it and/or \n+00000c50: 6d6f 6469 6679 0a23 2069 7420 756e 6465 modify.# it unde\n+00000c60: 7220 7468 6520 7465 726d 7320 6f66 2074 r the terms of t\n+00000c70: 6865 2047 4e55 2047 656e 6572 616c 2050 he GNU General P\n+00000c80: 7562 6c69 6320 4c69 6365 6e73 6520 6173 ublic License as\n+00000c90: 2070 7562 6c69 7368 6564 2062 790a 2320 published by.# \n+00000ca0: 7468 6520 4672 6565 2053 6f66 7477 6172 the Free Softwar\n+00000cb0: 6520 466f 756e 6461 7469 6f6e 2c20 6569 e Foundation, ei\n+00000cc0: 7468 6572 2076 6572 7369 6f6e 2033 206f ther version 3 o\n+00000cd0: 6620 7468 6520 4c69 6365 6e73 652c 206f f the License, o\n+00000ce0: 720a 2320 2861 7420 796f 7572 206f 7074 r.# (at your opt\n+00000cf0: 696f 6e29 2061 6e79 206c 6174 6572 2076 ion) any later v\n+00000d00: 6572 7369 6f6e 2e0a 230a 2320 5468 6973 ersion..#.# This\n+00000d10: 2070 726f 6772 616d 2069 7320 6469 7374 program is dist\n+00000d20: 7269 6275 7465 6420 696e 2074 6865 2068 ributed in the h\n+00000d30: 6f70 6520 7468 6174 2069 7420 7769 6c6c ope that it will\n+00000d40: 2062 6520 7573 6566 756c 2c0a 2320 6275 be useful,.# bu\n+00000d50: 7420 5749 5448 4f55 5420 414e 5920 5741 t WITHOUT ANY WA\n+00000d60: 5252 414e 5459 3b20 7769 7468 6f75 7420 RRANTY; without \n+00000d70: 6576 656e 2074 6865 2069 6d70 6c69 6564 even the implied\n+00000d80: 2077 6172 7261 6e74 7920 6f66 0a23 204d warranty of.# M\n+00000d90: 4552 4348 414e 5441 4249 4c49 5459 206f ERCHANTABILITY o\n+00000da0: 7220 4649 544e 4553 5320 464f 5220 4120 r FITNESS FOR A \n+00000db0: 5041 5254 4943 554c 4152 2050 5552 504f PARTICULAR PURPO\n+00000dc0: 5345 2e20 2053 6565 2074 6865 0a23 2047 SE. See the.# G\n+00000dd0: 4e55 2047 656e 6572 616c 2050 7562 6c69 NU General Publi\n+00000de0: 6320 4c69 6365 6e73 6520 666f 7220 6d6f c License for mo\n+00000df0: 7265 2064 6574 6169 6c73 2e0a 230a 2320 re details..#.# \n+00000e00: 596f 7520 7368 6f75 6c64 2068 6176 6520 You should have \n+00000e10: 7265 6365 6976 6564 2061 2063 6f70 7920 received a copy \n+00000e20: 6f66 2074 6865 2047 4e55 2047 656e 6572 of the GNU Gener\n+00000e30: 616c 2050 7562 6c69 6320 4c69 6365 6e73 al Public Licens\n+00000e40: 650a 2320 616c 6f6e 6720 7769 7468 2074 e.# along with t\n+00000e50: 6869 7320 7072 6f67 7261 6d2e 2020 4966 his program. If\n+00000e60: 206e 6f74 2c20 7365 6520 3c68 7474 7073 not, see ...impo\n+00000e90: 7274 2061 7379 6e63 696f 0a69 6d70 6f72 rt asyncio.impor\n+00000ea0: 7420 676c 6f62 0a69 6d70 6f72 7420 6772 t glob.import gr\n+00000eb0: 700a 696d 706f 7274 206a 736f 6e0a 696d p.import json.im\n+00000ec0: 706f 7274 206c 6f67 6769 6e67 0a69 6d70 port logging.imp\n+00000ed0: 6f72 7420 6f73 0a69 6d70 6f72 7420 7077 ort os.import pw\n+00000ee0: 640a 6672 6f6d 2070 6174 686c 6962 2069 d.from pathlib i\n+00000ef0: 6d70 6f72 7420 5061 7468 0a66 726f 6d20 mport Path.from \n+00000f00: 7479 7069 6e67 2069 6d70 6f72 7420 4469 typing import Di\n+00000f10: 6374 2c20 4f70 7469 6f6e 616c 0a0a 6672 ct, Optional..fr\n+00000f20: 6f6d 2063 6f63 6b70 6974 2e5f 7665 6e64 om cockpit._vend\n+00000f30: 6f72 2e73 7973 7465 6d64 5f63 7479 7065 or.systemd_ctype\n+00000f40: 7320 696d 706f 7274 2056 6172 6961 6e74 s import Variant\n+00000f50: 2c20 6275 732c 2069 6e6f 7469 6679 2c20 , bus, inotify, \n+00000f60: 7061 7468 7761 7463 680a 0a66 726f 6d20 pathwatch..from \n+00000f70: 2e20 696d 706f 7274 2063 6f6e 6669 670a . import config.\n+00000f80: 0a6c 6f67 6765 7220 3d20 6c6f 6767 696e .logger = loggin\n+00000f90: 672e 6765 744c 6f67 6765 7228 5f5f 6e61 g.getLogger(__na\n+00000fa0: 6d65 5f5f 290a 0a0a 636c 6173 7320 636f me__)...class co\n+00000fb0: 636b 7069 745f 4c6f 6769 6e4d 6573 7361 ckpit_LoginMessa\n+00000fc0: 6765 7328 6275 732e 4f62 6a65 6374 293a ges(bus.Object):\n+00000fd0: 0a20 2020 206d 6573 7361 6765 733a 204f . messages: O\n+00000fe0: 7074 696f 6e61 6c5b 7374 725d 203d 204e ptional[str] = N\n+00000ff0: 6f6e 650a 0a20 2020 2064 6566 205f 5f69 one.. def __i\n+00001000: 6e69 745f 5f28 7365 6c66 293a 0a20 2020 nit__(self):. \n+00001010: 2020 2020 2066 6473 7472 203d 206f 732e fdstr = os.\n+00001020: 656e 7669 726f 6e2e 706f 7028 2743 4f43 environ.pop('COC\n+00001030: 4b50 4954 5f4c 4f47 494e 5f4d 4553 5341 KPIT_LOGIN_MESSA\n+00001040: 4745 535f 4d45 4d46 4427 2c20 4e6f 6e65 GES_MEMFD', None\n+00001050: 290a 2020 2020 2020 2020 6966 2066 6473 ). if fds\n+00001060: 7472 2069 7320 4e6f 6e65 3a0a 2020 2020 tr is None:. \n+00001070: 2020 2020 2020 2020 6c6f 6767 6572 2e64 logger.d\n+00001080: 6562 7567 2822 434f 434b 5049 545f 4c4f ebug(\"COCKPIT_LO\n+00001090: 4749 4e5f 4d45 5353 4147 4553 5f4d 454d GIN_MESSAGES_MEM\n+000010a0: 4644 2077 6173 6e27 7420 7365 742e 2020 FD wasn't set. \n+000010b0: 4e6f 206c 6f67 696e 206d 6573 7361 6765 No login message\n+000010c0: 7320 746f 6461 792e 2229 0a20 2020 2020 s today.\"). \n+000010d0: 2020 2020 2020 2072 6574 7572 6e0a 0a20 return.. \n+000010e0: 2020 2020 2020 206c 6f67 6765 722e 6465 logger.de\n+000010f0: 6275 6728 2254 7279 696e 6720 746f 2072 bug(\"Trying to r\n+00001100: 6561 6420 6c6f 6769 6e20 6d65 7373 6167 ead login messag\n+00001110: 6573 2066 726f 6d20 6664 2025 7322 2c20 es from fd %s\", \n+00001120: 6664 7374 7229 0a20 2020 2020 2020 2074 fdstr). t\n+00001130: 7279 3a0a 2020 2020 2020 2020 2020 2020 ry:. \n+00001140: 7769 7468 206f 7065 6e28 696e 7428 6664 with open(int(fd\n+00001150: 7374 7229 2c20 2772 2729 2061 7320 6c6f str), 'r') as lo\n+00001160: 6769 6e5f 6d65 7373 6167 6573 3a0a 2020 gin_messages:. \n+00001170: 2020 2020 2020 2020 2020 2020 2020 6c6f lo\n+00001180: 6769 6e5f 6d65 7373 6167 6573 2e73 6565 gin_messages.see\n+00001190: 6b28 3029 0a20 2020 2020 2020 2020 2020 k(0). \n+000011a0: 2020 2020 2073 656c 662e 6d65 7373 6167 self.messag\n+000011b0: 6573 203d 206c 6f67 696e 5f6d 6573 7361 es = login_messa\n+000011c0: 6765 732e 7265 6164 2829 0a20 2020 2020 ges.read(). \n+000011d0: 2020 2065 7863 6570 7420 2856 616c 7565 except (Value\n+000011e0: 4572 726f 722c 204f 5345 7272 6f72 2c20 Error, OSError, \n+000011f0: 556e 6963 6f64 6544 6563 6f64 6545 7272 UnicodeDecodeErr\n+00001200: 6f72 2920 6173 2065 7863 3a0a 2020 2020 or) as exc:. \n+00001210: 2020 2020 2020 2020 2320 5661 6c75 6545 # ValueE\n+00001220: 7272 6f72 202d 2074 6865 2065 6e76 7661 rror - the envva\n+00001230: 7220 7761 736e 2774 2061 6e20 696e 740a r wasn't an int.\n+00001240: 2020 2020 2020 2020 2020 2020 2320 4f53 # OS\n+00001250: 4572 726f 7220 2d20 7468 6520 6664 2077 Error - the fd w\n+00001260: 6173 6e27 7420 6f70 656e 2c20 6f72 206f asn't open, or o\n+00001270: 7468 6572 2072 6561 6420 6661 696c 7572 ther read failur\n+00001280: 650a 2020 2020 2020 2020 2020 2020 2320 e. # \n+00001290: 556e 6963 6f64 6544 6563 6f64 6545 7272 UnicodeDecodeErr\n+000012a0: 6f72 202d 2064 6964 6e27 7420 636f 6e74 or - didn't cont\n+000012b0: 6169 6e20 7574 662d 380a 2020 2020 2020 ain utf-8. \n+000012c0: 2020 2020 2020 2320 466f 7220 616c 6c20 # For all \n+000012d0: 6f66 2074 6865 7365 2c20 7765 2073 696d of these, we sim\n+000012e0: 706c 7920 6661 696c 6564 2074 6f20 6765 ply failed to ge\n+000012f0: 7420 7468 6520 6d65 7373 6167 652e 0a20 t the message.. \n+00001300: 2020 2020 2020 2020 2020 206c 6f67 6765 logge\n+00001310: 722e 6465 6275 6728 2252 6561 6469 6e67 r.debug(\"Reading\n+00001320: 206c 6f67 696e 206d 6573 7361 6765 7320 login messages \n+00001330: 6661 696c 6564 3a20 2573 222c 2065 7863 failed: %s\", exc\n+00001340: 290a 2020 2020 2020 2020 656c 7365 3a0a ). else:.\n+00001350: 2020 2020 2020 2020 2020 2020 6c6f 6767 logg\n+00001360: 6572 2e64 6562 7567 2822 5375 6363 6573 er.debug(\"Succes\n+00001370: 7366 756c 6c79 2072 6561 6420 6c6f 6769 sfully read logi\n+00001380: 6e20 6d65 7373 6167 6573 3a20 2573 222c n messages: %s\",\n+00001390: 2073 656c 662e 6d65 7373 6167 6573 290a self.messages).\n+000013a0: 0a20 2020 2040 6275 732e 496e 7465 7266 . @bus.Interf\n+000013b0: 6163 652e 4d65 7468 6f64 286f 7574 5f74 ace.Method(out_t\n+000013c0: 7970 6573 3d5b 2773 275d 290a 2020 2020 ypes=['s']). \n+000013d0: 6465 6620 6765 7428 7365 6c66 293a 0a20 def get(self):. \n+000013e0: 2020 2020 2020 2072 6574 7572 6e20 7365 return se\n+000013f0: 6c66 2e6d 6573 7361 6765 7320 6f72 2027 lf.messages or '\n+00001400: 7b7d 270a 0a20 2020 2040 6275 732e 496e {}'.. @bus.In\n+00001410: 7465 7266 6163 652e 4d65 7468 6f64 286f terface.Method(o\n+00001420: 7574 5f74 7970 6573 3d5b 5d29 0a20 2020 ut_types=[]). \n+00001430: 2064 6566 2064 6973 6d69 7373 2873 656c def dismiss(sel\n+00001440: 6629 3a0a 2020 2020 2020 2020 7365 6c66 f):. self\n+00001450: 2e6d 6573 7361 6765 7320 3d20 4e6f 6e65 .messages = None\n+00001460: 0a0a 0a63 6c61 7373 2063 6f63 6b70 6974 ...class cockpit\n+00001470: 5f4d 6163 6869 6e65 7328 6275 732e 4f62 _Machines(bus.Ob\n+00001480: 6a65 6374 293a 0a20 2020 2070 6174 683a ject):. path:\n+00001490: 2050 6174 680a 2020 2020 7761 7463 683a Path. watch:\n+000014a0: 2070 6174 6877 6174 6368 2e50 6174 6857 pathwatch.PathW\n+000014b0: 6174 6368 0a20 2020 2070 656e 6469 6e67 atch. pending\n+000014c0: 5f6e 6f74 6966 793a 204f 7074 696f 6e61 _notify: Optiona\n+000014d0: 6c5b 6173 796e 6369 6f2e 4861 6e64 6c65 l[asyncio.Handle\n+000014e0: 5d0a 0a20 2020 2023 2044 2d42 7573 2069 ].. # D-Bus i\n+000014f0: 6d70 6c65 6d65 6e74 6174 696f 6e0a 2020 mplementation. \n+00001500: 2020 6d61 6368 696e 6573 203d 2062 7573 machines = bus\n+00001510: 2e49 6e74 6572 6661 6365 2e50 726f 7065 .Interface.Prope\n+00001520: 7274 7928 2761 7b73 617b 7376 7d7d 2729 rty('a{sa{sv}}')\n+00001530: 0a0a 2020 2020 406d 6163 6869 6e65 732e .. @machines.\n+00001540: 6765 7474 6572 0a20 2020 2064 6566 2067 getter. def g\n+00001550: 6574 5f6d 6163 6869 6e65 7328 7365 6c66 et_machines(self\n+00001560: 2920 2d3e 2044 6963 745b 7374 722c 2044 ) -> Dict[str, D\n+00001570: 6963 745b 7374 722c 2056 6172 6961 6e74 ict[str, Variant\n+00001580: 5d5d 3a0a 2020 2020 2020 2020 7265 7375 ]]:. resu\n+00001590: 6c74 733a 2044 6963 745b 7374 722c 2044 lts: Dict[str, D\n+000015a0: 6963 745b 7374 722c 2056 6172 6961 6e74 ict[str, Variant\n+000015b0: 5d5d 203d 207b 7d0a 0a20 2020 2020 2020 ]] = {}.. \n+000015c0: 2066 6f72 2066 696c 656e 616d 6520 696e for filename in\n+000015d0: 2067 6c6f 622e 676c 6f62 2866 277b 7365 glob.glob(f'{se\n+000015e0: 6c66 2e70 6174 687d 2f2a 2e6a 736f 6e27 lf.path}/*.json'\n+000015f0: 293a 0a20 2020 2020 2020 2020 2020 2077 ):. w\n+00001600: 6974 6820 6f70 656e 2866 696c 656e 616d ith open(filenam\n+00001610: 6529 2061 7320 6670 3a0a 2020 2020 2020 e) as fp:. \n+00001620: 2020 2020 2020 2020 2020 7472 793a 0a20 try:. \n+00001630: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00001640: 2020 2063 6f6e 7465 6e74 7320 3d20 6a73 contents = js\n+00001650: 6f6e 2e6c 6f61 6428 6670 290a 2020 2020 on.load(fp). \n+00001660: 2020 2020 2020 2020 2020 2020 6578 6365 exce\n+00001670: 7074 206a 736f 6e2e 4a53 4f4e 4465 636f pt json.JSONDeco\n+00001680: 6465 4572 726f 723a 0a20 2020 2020 2020 deError:. \n+00001690: 2020 2020 2020 2020 2020 2020 206c 6f67 log\n+000016a0: 6765 722e 7761 726e 696e 6728 2749 6e76 ger.warning('Inv\n+000016b0: 616c 6964 204a 534f 4e20 696e 2066 696c alid JSON in fil\n+000016c0: 6520 2573 2e20 2049 676e 6f72 696e 672e e %s. Ignoring.\n+000016d0: 272c 2066 696c 656e 616d 6529 0a20 2020 ', filename). \n+000016e0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000016f0: 2063 6f6e 7469 6e75 650a 2020 2020 2020 continue. \n+00001700: 2020 2020 2020 2020 2020 2320 6d65 7267 # merg\n+00001710: 650a 2020 2020 2020 2020 2020 2020 2020 e. \n+00001720: 2020 666f 7220 686f 7374 6e61 6d65 2c20 for hostname, \n+00001730: 6174 7472 7320 696e 2063 6f6e 7465 6e74 attrs in content\n+00001740: 732e 6974 656d 7328 293a 0a20 2020 2020 s.items():. \n+00001750: 2020 2020 2020 2020 2020 2020 2020 2072 r\n+00001760: 6573 756c 7473 5b68 6f73 746e 616d 655d esults[hostname]\n+00001770: 203d 207b 6b65 793a 2056 6172 6961 6e74 = {key: Variant\n+00001780: 2876 616c 7565 2920 666f 7220 6b65 792c (value) for key,\n+00001790: 2076 616c 7565 2069 6e20 6174 7472 732e value in attrs.\n+000017a0: 6974 656d 7328 297d 0a0a 2020 2020 2020 items()}.. \n+000017b0: 2020 7265 7475 726e 2072 6573 756c 7473 return results\n+000017c0: 0a0a 2020 2020 4062 7573 2e49 6e74 6572 .. @bus.Inter\n+000017d0: 6661 6365 2e4d 6574 686f 6428 696e 5f74 face.Method(in_t\n+000017e0: 7970 6573 3d5b 2773 272c 2027 7327 2c20 ypes=['s', 's', \n+000017f0: 2761 7b73 767d 275d 290a 2020 2020 6465 'a{sv}']). de\n+00001800: 6620 7570 6461 7465 2873 656c 662c 2066 f update(self, f\n+00001810: 696c 656e 616d 653a 2073 7472 2c20 686f ilename: str, ho\n+00001820: 7374 6e61 6d65 3a20 7374 722c 2061 7474 stname: str, att\n+00001830: 7273 3a20 4469 6374 5b73 7472 2c20 5661 rs: Dict[str, Va\n+00001840: 7269 616e 745d 2920 2d3e 204e 6f6e 653a riant]) -> None:\n+00001850: 0a20 2020 2020 2020 2074 7279 3a0a 2020 . try:. \n+00001860: 2020 2020 2020 2020 2020 7769 7468 2073 with s\n+00001870: 656c 662e 7061 7468 2e6a 6f69 6e70 6174 elf.path.joinpat\n+00001880: 6828 6669 6c65 6e61 6d65 292e 6f70 656e h(filename).open\n+00001890: 2829 2061 7320 6670 3a0a 2020 2020 2020 () as fp:. \n+000018a0: 2020 2020 2020 2020 2020 636f 6e74 656e conten\n+000018b0: 7473 203d 206a 736f 6e2e 6c6f 6164 2866 ts = json.load(f\n+000018c0: 7029 0a20 2020 2020 2020 2065 7863 6570 p). excep\n+000018d0: 7420 6a73 6f6e 2e4a 534f 4e44 6563 6f64 t json.JSONDecod\n+000018e0: 6545 7272 6f72 2061 7320 6578 633a 0a20 eError as exc:. \n+000018f0: 2020 2020 2020 2020 2020 2023 2052 6566 # Ref\n+00001900: 7573 6520 746f 2072 6570 6c61 6365 2063 use to replace c\n+00001910: 6f72 7275 7074 6564 2066 696c 650a 2020 orrupted file. \n+00001920: 2020 2020 2020 2020 2020 7261 6973 6520 raise \n+00001930: 6275 732e 4275 7345 7272 6f72 2827 636f bus.BusError('co\n+00001940: 636b 7069 742e 4d61 6368 696e 6573 2e45 ckpit.Machines.E\n+00001950: 7272 6f72 272c 2066 2746 696c 6520 7b66 rror', f'File {f\n+00001960: 696c 656e 616d 657d 2069 7320 696e 2069 ilename} is in i\n+00001970: 6e76 616c 6964 2066 6f72 6d61 743a 207b nvalid format: {\n+00001980: 6578 637d 2e27 2920 6672 6f6d 2065 7863 exc}.') from exc\n+00001990: 0a20 2020 2020 2020 2065 7863 6570 7420 . except \n+000019a0: 4669 6c65 4e6f 7446 6f75 6e64 4572 726f FileNotFoundErro\n+000019b0: 723a 0a20 2020 2020 2020 2020 2020 2023 r:. #\n+000019c0: 2042 7574 2061 6e20 656d 7074 7920 6669 But an empty fi\n+000019d0: 6c65 2069 7320 616e 2065 7870 6563 7465 le is an expecte\n+000019e0: 6420 6361 7365 0a20 2020 2020 2020 2020 d case. \n+000019f0: 2020 2063 6f6e 7465 6e74 7320 3d20 7b7d contents = {}\n+00001a00: 0a0a 2020 2020 2020 2020 636f 6e74 656e .. conten\n+00001a10: 7473 2e73 6574 6465 6661 756c 7428 686f ts.setdefault(ho\n+00001a20: 7374 6e61 6d65 2c20 7b7d 292e 7570 6461 stname, {}).upda\n+00001a30: 7465 287b 6b65 793a 2076 616c 7565 2e76 te({key: value.v\n+00001a40: 616c 7565 2066 6f72 206b 6579 2c20 7661 alue for key, va\n+00001a50: 6c75 6520 696e 2061 7474 7273 2e69 7465 lue in attrs.ite\n+00001a60: 6d73 2829 7d29 0a0a 2020 2020 2020 2020 ms()}).. \n+00001a70: 7365 6c66 2e70 6174 682e 6d6b 6469 7228 self.path.mkdir(\n+00001a80: 7061 7265 6e74 733d 5472 7565 2c20 6578 parents=True, ex\n+00001a90: 6973 745f 6f6b 3d54 7275 6529 0a20 2020 ist_ok=True). \n+00001aa0: 2020 2020 2077 6974 6820 6f70 656e 2873 with open(s\n+00001ab0: 656c 662e 7061 7468 2e6a 6f69 6e70 6174 elf.path.joinpat\n+00001ac0: 6828 6669 6c65 6e61 6d65 292c 2027 7727 h(filename), 'w'\n+00001ad0: 2920 6173 2066 703a 0a20 2020 2020 2020 ) as fp:. \n+00001ae0: 2020 2020 206a 736f 6e2e 6475 6d70 2863 json.dump(c\n+00001af0: 6f6e 7465 6e74 732c 2066 702c 2069 6e64 ontents, fp, ind\n+00001b00: 656e 743d 3229 0a0a 2020 2020 6465 6620 ent=2).. def \n+00001b10: 6e6f 7469 6679 2873 656c 6629 3a0a 2020 notify(self):. \n+00001b20: 2020 2020 2020 6465 6620 5f6e 6f74 6966 def _notif\n+00001b30: 795f 6e6f 7728 293a 0a20 2020 2020 2020 y_now():. \n+00001b40: 2020 2020 2073 656c 662e 7072 6f70 6572 self.proper\n+00001b50: 7469 6573 5f63 6861 6e67 6564 2827 636f ties_changed('co\n+00001b60: 636b 7069 742e 4d61 6368 696e 6573 272c ckpit.Machines',\n+00001b70: 207b 7d2c 205b 274d 6163 6869 6e65 7327 {}, ['Machines'\n+00001b80: 5d29 0a20 2020 2020 2020 2020 2020 2073 ]). s\n+00001b90: 656c 662e 7065 6e64 696e 675f 6e6f 7469 elf.pending_noti\n+00001ba0: 6679 203d 204e 6f6e 650a 0a20 2020 2020 fy = None.. \n+00001bb0: 2020 2023 2061 766f 6964 2061 2066 6c75 # avoid a flu\n+00001bc0: 7272 7920 6f66 2075 7064 6174 6520 6e6f rry of update no\n+00001bd0: 7469 6669 6361 7469 6f6e 730a 2020 2020 tifications. \n+00001be0: 2020 2020 6966 2073 656c 662e 7065 6e64 if self.pend\n+00001bf0: 696e 675f 6e6f 7469 6679 2069 7320 4e6f ing_notify is No\n+00001c00: 6e65 3a0a 2020 2020 2020 2020 2020 2020 ne:. \n+00001c10: 7365 6c66 2e70 656e 6469 6e67 5f6e 6f74 self.pending_not\n+00001c20: 6966 7920 3d20 6173 796e 6369 6f2e 6765 ify = asyncio.ge\n+00001c30: 745f 7275 6e6e 696e 675f 6c6f 6f70 2829 t_running_loop()\n+00001c40: 2e63 616c 6c5f 6c61 7465 7228 312e 302c .call_later(1.0,\n+00001c50: 205f 6e6f 7469 6679 5f6e 6f77 290a 0a20 _notify_now).. \n+00001c60: 2020 2023 2069 6e6f 7469 6679 2065 7665 # inotify eve\n+00001c70: 6e74 730a 2020 2020 6465 6620 646f 5f69 nts. def do_i\n+00001c80: 6e6f 7469 6679 5f65 7665 6e74 2873 656c notify_event(sel\n+00001c90: 662c 206d 6173 6b3a 2069 6e6f 7469 6679 f, mask: inotify\n+00001ca0: 2e45 7665 6e74 2c20 636f 6f6b 6965 3a20 .Event, cookie: \n+00001cb0: 696e 742c 206e 616d 653a 204f 7074 696f int, name: Optio\n+00001cc0: 6e61 6c5b 7374 725d 2920 2d3e 204e 6f6e nal[str]) -> Non\n+00001cd0: 653a 0a20 2020 2020 2020 2073 656c 662e e:. self.\n+00001ce0: 6e6f 7469 6679 2829 0a0a 2020 2020 6465 notify().. de\n+00001cf0: 6620 646f 5f69 6465 6e74 6974 795f 6368 f do_identity_ch\n+00001d00: 616e 6765 6428 7365 6c66 2c20 6664 3a20 anged(self, fd: \n+00001d10: 4f70 7469 6f6e 616c 5b69 6e74 5d2c 2065 Optional[int], e\n+00001d20: 7272 6e6f 3a20 4f70 7469 6f6e 616c 5b69 rrno: Optional[i\n+00001d30: 6e74 5d29 202d 3e20 4e6f 6e65 3a0a 2020 nt]) -> None:. \n+00001d40: 2020 2020 2020 7365 6c66 2e6e 6f74 6966 self.notif\n+00001d50: 7928 290a 0a20 2020 2064 6566 205f 5f69 y().. def __i\n+00001d60: 6e69 745f 5f28 7365 6c66 293a 0a20 2020 nit__(self):. \n+00001d70: 2020 2020 2073 656c 662e 7061 7468 203d self.path =\n+00001d80: 2063 6f6e 6669 672e 6c6f 6f6b 7570 5f63 config.lookup_c\n+00001d90: 6f6e 6669 6728 276d 6163 6869 6e65 732e onfig('machines.\n+00001da0: 6427 290a 0a20 2020 2020 2020 2023 2069 d').. # i\n+00001db0: 676e 6f72 6520 7468 6520 6669 7273 7420 gnore the first \n+00001dc0: 6361 6c6c 6261 636b 0a20 2020 2020 2020 callback. \n+00001dd0: 2073 656c 662e 7065 6e64 696e 675f 6e6f self.pending_no\n+00001de0: 7469 6679 203d 202e 2e2e 0a20 2020 2020 tify = .... \n+00001df0: 2020 2073 656c 662e 7761 7463 6820 3d20 self.watch = \n+00001e00: 7061 7468 7761 7463 682e 5061 7468 5761 pathwatch.PathWa\n+00001e10: 7463 6828 7374 7228 7365 6c66 2e70 6174 tch(str(self.pat\n+00001e20: 6829 2c20 7365 6c66 290a 2020 2020 2020 h), self). \n+00001e30: 2020 7365 6c66 2e70 656e 6469 6e67 5f6e self.pending_n\n+00001e40: 6f74 6966 7920 3d20 4e6f 6e65 0a0a 0a63 otify = None...c\n+00001e50: 6c61 7373 2063 6f63 6b70 6974 5f55 7365 lass cockpit_Use\n+00001e60: 7228 6275 732e 4f62 6a65 6374 293a 0a20 r(bus.Object):. \n+00001e70: 2020 206e 616d 6520 3d20 6275 732e 496e name = bus.In\n+00001e80: 7465 7266 6163 652e 5072 6f70 6572 7479 terface.Property\n+00001e90: 2827 7327 2c20 7661 6c75 653d 2727 290a ('s', value='').\n+00001ea0: 2020 2020 6675 6c6c 203d 2062 7573 2e49 full = bus.I\n+00001eb0: 6e74 6572 6661 6365 2e50 726f 7065 7274 nterface.Propert\n+00001ec0: 7928 2773 272c 2076 616c 7565 3d27 2729 y('s', value='')\n+00001ed0: 0a20 2020 2069 6420 3d20 6275 732e 496e . id = bus.In\n+00001ee0: 7465 7266 6163 652e 5072 6f70 6572 7479 terface.Property\n+00001ef0: 2827 6927 2c20 7661 6c75 653d 3029 0a20 ('i', value=0). \n+00001f00: 2020 2068 6f6d 6520 3d20 6275 732e 496e home = bus.In\n+00001f10: 7465 7266 6163 652e 5072 6f70 6572 7479 terface.Property\n+00001f20: 2827 7327 2c20 7661 6c75 653d 2727 290a ('s', value='').\n+00001f30: 2020 2020 7368 656c 6c20 3d20 6275 732e shell = bus.\n+00001f40: 496e 7465 7266 6163 652e 5072 6f70 6572 Interface.Proper\n+00001f50: 7479 2827 7327 2c20 7661 6c75 653d 2727 ty('s', value=''\n+00001f60: 290a 2020 2020 6772 6f75 7073 203d 2062 ). groups = b\n+00001f70: 7573 2e49 6e74 6572 6661 6365 2e50 726f us.Interface.Pro\n+00001f80: 7065 7274 7928 2761 7327 2c20 7661 6c75 perty('as', valu\n+00001f90: 653d 5b5d 290a 0a20 2020 2064 6566 205f e=[]).. def _\n+00001fa0: 5f69 6e69 745f 5f28 7365 6c66 293a 0a20 _init__(self):. \n+00001fb0: 2020 2020 2020 2075 7365 7220 3d20 7077 user = pw\n+00001fc0: 642e 6765 7470 7775 6964 286f 732e 6765 d.getpwuid(os.ge\n+00001fd0: 7475 6964 2829 290a 2020 2020 2020 2020 tuid()). \n+00001fe0: 7365 6c66 2e6e 616d 6520 3d20 7573 6572 self.name = user\n+00001ff0: 2e70 775f 6e61 6d65 0a20 2020 2020 2020 .pw_name. \n+00002000: 2073 656c 662e 6675 6c6c 203d 2075 7365 self.full = use\n+00002010: 722e 7077 5f67 6563 6f73 0a20 2020 2020 r.pw_gecos. \n+00002020: 2020 2073 656c 662e 6964 203d 2075 7365 self.id = use\n+00002030: 722e 7077 5f75 6964 0a20 2020 2020 2020 r.pw_uid. \n+00002040: 2073 656c 662e 686f 6d65 203d 2075 7365 self.home = use\n+00002050: 722e 7077 5f64 6972 0a20 2020 2020 2020 r.pw_dir. \n+00002060: 2073 656c 662e 7368 656c 6c20 3d20 7573 self.shell = us\n+00002070: 6572 2e70 775f 7368 656c 6c0a 2020 2020 er.pw_shell. \n+00002080: 2020 2020 7365 6c66 2e67 726f 7570 7320 self.groups \n+00002090: 3d20 5b67 722e 6772 5f6e 616d 6520 666f = [gr.gr_name fo\n+000020a0: 7220 6772 2069 6e20 6772 702e 6765 7467 r gr in grp.getg\n+000020b0: 7261 6c6c 2829 2069 6620 7573 6572 2e70 rall() if user.p\n+000020c0: 775f 6e61 6d65 2069 6e20 6772 2e67 725f w_name in gr.gr_\n+000020d0: 6d65 6d5d 0a0a 0a45 5850 4f52 5453 203d mem]...EXPORTS =\n+000020e0: 205b 0a20 2020 2028 272f 4c6f 6769 6e4d [. ('/LoginM\n+000020f0: 6573 7361 6765 7327 2c20 636f 636b 7069 essages', cockpi\n+00002100: 745f 4c6f 6769 6e4d 6573 7361 6765 7329 t_LoginMessages)\n+00002110: 2c0a 2020 2020 2827 2f6d 6163 6869 6e65 ,. ('/machine\n+00002120: 7327 2c20 636f 636b 7069 745f 4d61 6368 s', cockpit_Mach\n+00002130: 696e 6573 292c 0a20 2020 2028 272f 7573 ines),. ('/us\n+00002140: 6572 272c 2063 6f63 6b70 6974 5f55 7365 er', cockpit_Use\n+00002150: 7229 2c0a 5d0a 2727 272c 0a20 2027 636f r),.].''',. 'co\n+00002160: 636b 7069 742f 6265 6962 6f6f 742e 7079 ckpit/beiboot.py\n+00002170: 273a 2062 7227 2727 2320 5468 6973 2066 ': br'''# This f\n+00002180: 696c 6520 6973 2070 6172 7420 6f66 2043 ile is part of C\n+00002190: 6f63 6b70 6974 2e0a 230a 2320 436f 7079 ockpit..#.# Copy\n+000021a0: 7269 6768 7420 2843 2920 3230 3232 2052 right (C) 2022 R\n+000021b0: 6564 2048 6174 2c20 496e 632e 0a23 0a23 ed Hat, Inc..#.#\n+000021c0: 2054 6869 7320 7072 6f67 7261 6d20 6973 This program is\n+000021d0: 2066 7265 6520 736f 6674 7761 7265 3a20 free software: \n+000021e0: 796f 7520 6361 6e20 7265 6469 7374 7269 you can redistri\n+000021f0: 6275 7465 2069 7420 616e 642f 6f72 206d bute it and/or m\n+00002200: 6f64 6966 790a 2320 6974 2075 6e64 6572 odify.# it under\n+00002210: 2074 6865 2074 6572 6d73 206f 6620 7468 the terms of th\n+00002220: 6520 474e 5520 4765 6e65 7261 6c20 5075 e GNU General Pu\n+00002230: 626c 6963 204c 6963 656e 7365 2061 7320 blic License as \n+00002240: 7075 626c 6973 6865 6420 6279 0a23 2074 published by.# t\n+00002250: 6865 2046 7265 6520 536f 6674 7761 7265 he Free Software\n+00002260: 2046 6f75 6e64 6174 696f 6e2c 2065 6974 Foundation, eit\n+00002270: 6865 7220 7665 7273 696f 6e20 3320 6f66 her version 3 of\n+00002280: 2074 6865 204c 6963 656e 7365 2c20 6f72 the License, or\n+00002290: 0a23 2028 6174 2079 6f75 7220 6f70 7469 .# (at your opti\n+000022a0: 6f6e 2920 616e 7920 6c61 7465 7220 7665 on) any later ve\n+000022b0: 7273 696f 6e2e 0a23 0a23 2054 6869 7320 rsion..#.# This \n+000022c0: 7072 6f67 7261 6d20 6973 2064 6973 7472 program is distr\n+000022d0: 6962 7574 6564 2069 6e20 7468 6520 686f ibuted in the ho\n+000022e0: 7065 2074 6861 7420 6974 2077 696c 6c20 pe that it will \n+000022f0: 6265 2075 7365 6675 6c2c 0a23 2062 7574 be useful,.# but\n+00002300: 2057 4954 484f 5554 2041 4e59 2057 4152 WITHOUT ANY WAR\n+00002310: 5241 4e54 593b 2077 6974 686f 7574 2065 RANTY; without e\n+00002320: 7665 6e20 7468 6520 696d 706c 6965 6420 ven the implied \n+00002330: 7761 7272 616e 7479 206f 660a 2320 4d45 warranty of.# ME\n+00002340: 5243 4841 4e54 4142 494c 4954 5920 6f72 RCHANTABILITY or\n+00002350: 2046 4954 4e45 5353 2046 4f52 2041 2050 FITNESS FOR A P\n+00002360: 4152 5449 4355 4c41 5220 5055 5250 4f53 ARTICULAR PURPOS\n+00002370: 452e 2020 5365 6520 7468 650a 2320 474e E. See the.# GN\n+00002380: 5520 4765 6e65 7261 6c20 5075 626c 6963 U General Public\n+00002390: 204c 6963 656e 7365 2066 6f72 206d 6f72 License for mor\n+000023a0: 6520 6465 7461 696c 732e 0a23 0a23 2059 e details..#.# Y\n+000023b0: 6f75 2073 686f 756c 6420 6861 7665 2072 ou should have r\n+000023c0: 6563 6569 7665 6420 6120 636f 7079 206f eceived a copy o\n+000023d0: 6620 7468 6520 474e 5520 4765 6e65 7261 f the GNU Genera\n+000023e0: 6c20 5075 626c 6963 204c 6963 656e 7365 l Public License\n+000023f0: 0a23 2061 6c6f 6e67 2077 6974 6820 7468 .# along with th\n+00002400: 6973 2070 726f 6772 616d 2e20 2049 6620 is program. If \n+00002410: 6e6f 742c 2073 6565 203c 6874 7470 733a not, see ...impor\n+00002440: 7420 6172 6770 6172 7365 0a69 6d70 6f72 t argparse.impor\n+00002450: 7420 6173 796e 6369 6f0a 696d 706f 7274 t asyncio.import\n+00002460: 2062 6173 6536 340a 696d 706f 7274 2069 base64.import i\n+00002470: 6d70 6f72 746c 6962 2e72 6573 6f75 7263 mportlib.resourc\n+00002480: 6573 0a69 6d70 6f72 7420 6c6f 6767 696e es.import loggin\n+00002490: 670a 696d 706f 7274 206f 730a 696d 706f g.import os.impo\n+000024a0: 7274 2073 686c 6578 0a66 726f 6d20 7061 rt shlex.from pa\n+000024b0: 7468 6c69 6220 696d 706f 7274 2050 6174 thlib import Pat\n+000024c0: 680a 6672 6f6d 2074 7970 696e 6720 696d h.from typing im\n+000024d0: 706f 7274 2044 6963 742c 2049 7465 7261 port Dict, Itera\n+000024e0: 626c 652c 204f 7074 696f 6e61 6c2c 2053 ble, Optional, S\n+000024f0: 6571 7565 6e63 650a 0a66 726f 6d20 636f equence..from co\n+00002500: 636b 7069 7420 696d 706f 7274 2070 6f6c ckpit import pol\n+00002510: 7966 696c 6c73 0a66 726f 6d20 636f 636b yfills.from cock\n+00002520: 7069 742e 5f76 656e 646f 7220 696d 706f pit._vendor impo\n+00002530: 7274 2066 6572 6e79 0a66 726f 6d20 636f rt ferny.from co\n+00002540: 636b 7069 742e 5f76 656e 646f 722e 6265 ckpit._vendor.be\n+00002550: 6920 696d 706f 7274 2062 6f6f 746c 6f61 i import bootloa\n+00002560: 6465 720a 6672 6f6d 2063 6f63 6b70 6974 der.from cockpit\n+00002570: 2e62 6569 7061 636b 2069 6d70 6f72 7420 .beipack import \n+00002580: 4272 6964 6765 4265 6962 6f6f 7448 656c BridgeBeibootHel\n+00002590: 7065 720a 6672 6f6d 2063 6f63 6b70 6974 per.from cockpit\n+000025a0: 2e62 7269 6467 6520 696d 706f 7274 2073 .bridge import s\n+000025b0: 6574 7570 5f6c 6f67 6769 6e67 0a66 726f etup_logging.fro\n+000025c0: 6d20 636f 636b 7069 742e 6368 616e 6e65 m cockpit.channe\n+000025d0: 6c20 696d 706f 7274 2043 6861 6e6e 656c l import Channel\n+000025e0: 526f 7574 696e 6752 756c 650a 6672 6f6d RoutingRule.from\n+000025f0: 2063 6f63 6b70 6974 2e63 6861 6e6e 656c cockpit.channel\n+00002600: 7320 696d 706f 7274 2050 6163 6b61 6765 s import Package\n+00002610: 7343 6861 6e6e 656c 0a66 726f 6d20 636f sChannel.from co\n+00002620: 636b 7069 742e 6a73 6f6e 7574 696c 2069 ckpit.jsonutil i\n+00002630: 6d70 6f72 7420 4a73 6f6e 4f62 6a65 6374 mport JsonObject\n+00002640: 0a66 726f 6d20 636f 636b 7069 742e 7061 .from cockpit.pa\n+00002650: 636b 6167 6573 2069 6d70 6f72 7420 5061 ckages import Pa\n+00002660: 636b 6167 6573 2c20 5061 636b 6167 6573 ckages, Packages\n+00002670: 4c6f 6164 6572 2c20 7061 7463 685f 6c69 Loader, patch_li\n+00002680: 6265 7865 6364 6972 0a66 726f 6d20 636f bexecdir.from co\n+00002690: 636b 7069 742e 7065 6572 2069 6d70 6f72 ckpit.peer impor\n+000026a0: 7420 5065 6572 0a66 726f 6d20 636f 636b t Peer.from cock\n+000026b0: 7069 742e 7072 6f74 6f63 6f6c 2069 6d70 pit.protocol imp\n+000026c0: 6f72 7420 436f 636b 7069 7450 726f 626c ort CockpitProbl\n+000026d0: 656d 0a66 726f 6d20 636f 636b 7069 742e em.from cockpit.\n+000026e0: 726f 7574 6572 2069 6d70 6f72 7420 526f router import Ro\n+000026f0: 7574 6572 2c20 526f 7574 696e 6752 756c uter, RoutingRul\n+00002700: 650a 6672 6f6d 2063 6f63 6b70 6974 2e74 e.from cockpit.t\n+00002710: 7261 6e73 706f 7274 7320 696d 706f 7274 ransports import\n+00002720: 2053 7464 696f 5472 616e 7370 6f72 740a StdioTransport.\n+00002730: 0a6c 6f67 6765 7220 3d20 6c6f 6767 696e .logger = loggin\n+00002740: 672e 6765 744c 6f67 6765 7228 2763 6f63 g.getLogger('coc\n+00002750: 6b70 6974 2e62 6569 626f 6f74 2729 0a0a kpit.beiboot')..\n+00002760: 0a64 6566 2065 6e73 7572 655f 6665 726e .def ensure_fern\n+00002770: 795f 6173 6b70 6173 7328 2920 2d3e 2050 y_askpass() -> P\n+00002780: 6174 683a 0a20 2020 2022 2222 4372 6561 ath:. \"\"\"Crea\n+00002790: 7465 2061 736b 7061 7373 2065 7865 6375 te askpass execu\n+000027a0: 7461 626c 650a 0a20 2020 2057 6520 6e65 table.. We ne\n+000027b0: 6564 2074 6869 7320 666f 7220 7468 6520 ed this for the \n+000027c0: 666c 6174 7061 6b3a 2073 7368 2061 6e64 flatpak: ssh and\n+000027d0: 2074 6875 7320 7468 6520 6173 6b70 6173 thus the askpas\n+000027e0: 7320 7072 6f67 7261 6d20 7275 6e20 6f6e s program run on\n+000027f0: 2074 6865 2068 6f73 7420 2876 6961 2066 the host (via f\n+00002800: 6c61 7470 616b 2d73 7061 776e 292c 0a20 latpak-spawn),. \n+00002810: 2020 206e 6f74 2074 6865 2066 6c61 7470 not the flatp\n+00002820: 616b 2e20 5468 7573 2077 6520 6361 6e6e ak. Thus we cann\n+00002830: 6f74 2075 7365 2074 6865 2073 6869 7070 ot use the shipp\n+00002840: 6564 2063 6f63 6b70 6974 2d61 736b 7061 ed cockpit-askpa\n+00002850: 7373 2070 726f 6772 616d 2e0a 2020 2020 ss program.. \n+00002860: 2222 220a 2020 2020 7372 635f 7061 7468 \"\"\". src_path\n+00002870: 203d 2069 6d70 6f72 746c 6962 2e72 6573 = importlib.res\n+00002880: 6f75 7263 6573 2e66 696c 6573 2866 6572 ources.files(fer\n+00002890: 6e79 2e5f 5f6e 616d 655f 5f29 202f 2027 ny.__name__) / '\n+000028a0: 696e 7465 7261 6374 696f 6e5f 636c 6965 interaction_clie\n+000028b0: 6e74 2e70 7927 0a20 2020 2073 7263 5f64 nt.py'. src_d\n+000028c0: 6174 6120 3d20 7372 635f 7061 7468 2e72 ata = src_path.r\n+000028d0: 6561 645f 6279 7465 7328 290a 0a20 2020 ead_bytes().. \n+000028e0: 2023 2043 7265 6174 6520 7468 6520 6669 # Create the fi\n+000028f0: 6c65 2069 6e20 2458 4447 5f43 4143 4845 le in $XDG_CACHE\n+00002900: 5f48 4f4d 452c 206f 6e65 206f 6620 7468 _HOME, one of th\n+00002910: 6520 6665 7720 6c6f 6361 7469 6f6e 7320 e few locations \n+00002920: 7468 6174 2061 2066 6c61 7470 616b 2063 that a flatpak c\n+00002930: 616e 2077 7269 7465 2074 6f0a 2020 2020 an write to. \n+00002940: 7864 675f 6361 6368 655f 686f 6d65 203d xdg_cache_home =\n+00002950: 206f 732e 656e 7669 726f 6e2e 6765 7428 os.environ.get(\n+00002960: 2758 4447 5f43 4143 4845 5f48 4f4d 4527 'XDG_CACHE_HOME'\n+00002970: 290a 2020 2020 6966 2078 6467 5f63 6163 ). if xdg_cac\n+00002980: 6865 5f68 6f6d 6520 6973 204e 6f6e 653a he_home is None:\n+00002990: 0a20 2020 2020 2020 2078 6467 5f63 6163 . xdg_cac\n+000029a0: 6865 5f68 6f6d 6520 3d20 6f73 2e70 6174 he_home = os.pat\n+000029b0: 682e 6578 7061 6e64 7573 6572 2827 7e2f h.expanduser('~/\n+000029c0: 2e63 6163 6865 2729 0a20 2020 206f 732e .cache'). os.\n+000029d0: 6d61 6b65 6469 7273 2878 6467 5f63 6163 makedirs(xdg_cac\n+000029e0: 6865 5f68 6f6d 652c 2065 7869 7374 5f6f he_home, exist_o\n+000029f0: 6b3d 5472 7565 290a 2020 2020 6465 7374 k=True). dest\n+00002a00: 5f70 6174 6820 3d20 5061 7468 2878 6467 _path = Path(xdg\n+00002a10: 5f63 6163 6865 5f68 6f6d 652c 2027 636f _cache_home, 'co\n+00002a20: 636b 7069 742d 636c 6965 6e74 2d61 736b ckpit-client-ask\n+00002a30: 7061 7373 2729 0a0a 2020 2020 6c6f 6767 pass').. logg\n+00002a40: 6572 2e64 6562 7567 2822 4368 6563 6b69 er.debug(\"Checki\n+00002a50: 6e67 2069 6620 2573 2065 7869 7374 732e ng if %s exists.\n+00002a60: 2e2e 222c 2064 6573 745f 7061 7468 290a ..\", dest_path).\n+00002a70: 0a20 2020 2023 2043 6865 636b 2066 6972 . # Check fir\n+00002a80: 7374 2074 6f20 7365 6520 6966 2077 6520 st to see if we \n+00002a90: 616c 7265 6164 7920 7772 6f74 6520 7468 already wrote th\n+00002aa0: 6520 6375 7272 656e 7420 7665 7273 696f e current versio\n+00002ab0: 6e0a 2020 2020 7472 793a 0a20 2020 2020 n. try:. \n+00002ac0: 2020 2069 6620 6465 7374 5f70 6174 682e if dest_path.\n+00002ad0: 7265 6164 5f62 7974 6573 2829 2021 3d20 read_bytes() != \n+00002ae0: 7372 635f 6461 7461 3a0a 2020 2020 2020 src_data:. \n+00002af0: 2020 2020 2020 6c6f 6767 6572 2e64 6562 logger.deb\n+00002b00: 7567 2822 2020 2e2e 2e20 6974 2065 7869 ug(\" ... it exi\n+00002b10: 7374 7320 6275 7420 6973 206e 6f74 2074 sts but is not t\n+00002b20: 6865 2073 616d 6520 7665 7273 696f 6e2e he same version.\n+00002b30: 2e2e 2229 0a20 2020 2020 2020 2020 2020 ..\"). \n+00002b40: 2072 6169 7365 2056 616c 7565 4572 726f raise ValueErro\n+00002b50: 720a 2020 2020 2020 2020 6966 206e 6f74 r. if not\n+00002b60: 2064 6573 745f 7061 7468 2e73 7461 7428 dest_path.stat(\n+00002b70: 292e 7374 5f6d 6f64 6520 2620 306f 3130 ).st_mode & 0o10\n+00002b80: 303a 0a20 2020 2020 2020 2020 2020 206c 0:. l\n+00002b90: 6f67 6765 722e 6465 6275 6728 2220 202e ogger.debug(\" .\n+00002ba0: 2e2e 2069 7420 6861 7320 7468 6520 636f .. it has the co\n+00002bb0: 7272 6563 7420 636f 6e74 656e 7473 2c20 rrect contents, \n+00002bc0: 6275 7420 6973 206e 6f74 2065 7865 6375 but is not execu\n+00002bd0: 7461 626c 652e 2e2e 2229 0a20 2020 2020 table...\"). \n+00002be0: 2020 2020 2020 2072 6169 7365 2056 616c raise Val\n+00002bf0: 7565 4572 726f 720a 2020 2020 6578 6365 ueError. exce\n+00002c00: 7074 2028 4669 6c65 4e6f 7446 6f75 6e64 pt (FileNotFound\n+00002c10: 4572 726f 722c 2056 616c 7565 4572 726f Error, ValueErro\n+00002c20: 7229 3a0a 2020 2020 2020 2020 6c6f 6767 r):. logg\n+00002c30: 6572 2e64 6562 7567 2822 2020 2e2e 2e20 er.debug(\" ... \n+00002c40: 7772 6974 696e 6720 636f 6e74 656e 7473 writing contents\n+00002c50: 2e22 290a 2020 2020 2020 2020 6465 7374 .\"). dest\n+00002c60: 5f70 6174 682e 7772 6974 655f 6279 7465 _path.write_byte\n+00002c70: 7328 7372 635f 6461 7461 290a 2020 2020 s(src_data). \n+00002c80: 2020 2020 6465 7374 5f70 6174 682e 6368 dest_path.ch\n+00002c90: 6d6f 6428 306f 3730 3029 0a0a 2020 2020 mod(0o700).. \n+00002ca0: 7265 7475 726e 2064 6573 745f 7061 7468 return dest_path\n+00002cb0: 0a0a 0a64 6566 2067 6574 5f69 6e74 6572 ...def get_inter\n+00002cc0: 6573 7469 6e67 5f66 696c 6573 2829 202d esting_files() -\n+00002cd0: 3e20 4974 6572 6162 6c65 5b73 7472 5d3a > Iterable[str]:\n+00002ce0: 0a20 2020 2066 6f72 206d 616e 6966 6573 . for manifes\n+00002cf0: 7420 696e 2050 6163 6b61 6765 734c 6f61 t in PackagesLoa\n+00002d00: 6465 722e 6c6f 6164 5f6d 616e 6966 6573 der.load_manifes\n+00002d10: 7473 2829 3a0a 2020 2020 2020 2020 666f ts():. fo\n+00002d20: 7220 636f 6e64 6974 696f 6e20 696e 206d r condition in m\n+00002d30: 616e 6966 6573 742e 636f 6e64 6974 696f anifest.conditio\n+00002d40: 6e73 3a0a 2020 2020 2020 2020 2020 2020 ns:. \n+00002d50: 6966 2063 6f6e 6469 7469 6f6e 2e6e 616d if condition.nam\n+00002d60: 6520 696e 2028 2770 6174 682d 6578 6973 e in ('path-exis\n+00002d70: 7473 272c 2027 7061 7468 2d6e 6f74 2d65 ts', 'path-not-e\n+00002d80: 7869 7374 7327 2920 616e 6420 6973 696e xists') and isin\n+00002d90: 7374 616e 6365 2863 6f6e 6469 7469 6f6e stance(condition\n+00002da0: 2e76 616c 7565 2c20 7374 7229 3a0a 2020 .value, str):. \n+00002db0: 2020 2020 2020 2020 2020 2020 2020 7969 yi\n+00002dc0: 656c 6420 636f 6e64 6974 696f 6e2e 7661 eld condition.va\n+00002dd0: 6c75 650a 0a0a 636c 6173 7320 5072 6f78 lue...class Prox\n+00002de0: 7950 6163 6b61 6765 734c 6f61 6465 7228 yPackagesLoader(\n+00002df0: 5061 636b 6167 6573 4c6f 6164 6572 293a PackagesLoader):\n+00002e00: 0a20 2020 2066 696c 655f 7374 6174 7573 . file_status\n+00002e10: 3a20 4469 6374 5b73 7472 2c20 626f 6f6c : Dict[str, bool\n+00002e20: 5d0a 0a20 2020 2064 6566 2063 6865 636b ].. def check\n+00002e30: 5f63 6f6e 6469 7469 6f6e 2873 656c 662c _condition(self,\n+00002e40: 2063 6f6e 6469 7469 6f6e 3a20 7374 722c condition: str,\n+00002e50: 2076 616c 7565 3a20 6f62 6a65 6374 2920 value: object) \n+00002e60: 2d3e 2062 6f6f 6c3a 0a20 2020 2020 2020 -> bool:. \n+00002e70: 2061 7373 6572 7420 6973 696e 7374 616e assert isinstan\n+00002e80: 6365 2876 616c 7565 2c20 7374 7229 0a20 ce(value, str). \n+00002e90: 2020 2020 2020 2061 7373 6572 7420 7661 assert va\n+00002ea0: 6c75 6520 696e 2073 656c 662e 6669 6c65 lue in self.file\n+00002eb0: 5f73 7461 7475 730a 0a20 2020 2020 2020 _status.. \n+00002ec0: 2069 6620 636f 6e64 6974 696f 6e20 3d3d if condition ==\n+00002ed0: 2027 7061 7468 2d65 7869 7374 7327 3a0a 'path-exists':.\n+00002ee0: 2020 2020 2020 2020 2020 2020 7265 7475 retu\n+00002ef0: 726e 2073 656c 662e 6669 6c65 5f73 7461 rn self.file_sta\n+00002f00: 7475 735b 7661 6c75 655d 0a20 2020 2020 tus[value]. \n+00002f10: 2020 2065 6c69 6620 636f 6e64 6974 696f elif conditio\n+00002f20: 6e20 3d3d 2027 7061 7468 2d6e 6f74 2d65 n == 'path-not-e\n+00002f30: 7869 7374 7327 3a0a 2020 2020 2020 2020 xists':. \n+00002f40: 2020 2020 7265 7475 726e 206e 6f74 2073 return not s\n+00002f50: 656c 662e 6669 6c65 5f73 7461 7475 735b elf.file_status[\n+00002f60: 7661 6c75 655d 0a20 2020 2020 2020 2065 value]. e\n+00002f70: 6c73 653a 0a20 2020 2020 2020 2020 2020 lse:. \n+00002f80: 2072 6169 7365 204b 6579 4572 726f 720a raise KeyError.\n+00002f90: 0a20 2020 2064 6566 205f 5f69 6e69 745f . def __init_\n+00002fa0: 5f28 7365 6c66 2c20 6669 6c65 5f73 7461 _(self, file_sta\n+00002fb0: 7475 733a 2044 6963 745b 7374 722c 2062 tus: Dict[str, b\n+00002fc0: 6f6f 6c5d 293a 0a20 2020 2020 2020 2073 ool]):. s\n+00002fd0: 656c 662e 6669 6c65 5f73 7461 7475 7320 elf.file_status \n+00002fe0: 3d20 6669 6c65 5f73 7461 7475 730a 0a0a = file_status...\n+00002ff0: 4245 4942 4f4f 545f 4741 4447 4554 5320 BEIBOOT_GADGETS \n+00003000: 3d20 7b0a 2020 2020 2272 6570 6f72 745f = {. \"report_\n+00003010: 6578 6973 7473 223a 2072 2222 220a 2020 exists\": r\"\"\". \n+00003020: 2020 696d 706f 7274 206f 730a 2020 2020 import os. \n+00003030: 6465 6620 7265 706f 7274 5f65 7869 7374 def report_exist\n+00003040: 7328 6669 6c65 7329 3a0a 2020 2020 2020 s(files):. \n+00003050: 2020 636f 6d6d 616e 6428 2763 6f63 6b70 command('cockp\n+00003060: 6974 2e72 6570 6f72 742d 6578 6973 7473 it.report-exists\n+00003070: 272c 207b 6e61 6d65 3a20 6f73 2e70 6174 ', {name: os.pat\n+00003080: 682e 6578 6973 7473 286e 616d 6529 2066 h.exists(name) f\n+00003090: 6f72 206e 616d 6520 696e 2066 696c 6573 or name in files\n+000030a0: 7d29 0a20 2020 2022 2222 2c0a 2020 2020 }). \"\"\",. \n+000030b0: 2a2a 6665 726e 792e 4245 4942 4f4f 545f **ferny.BEIBOOT_\n+000030c0: 4741 4447 4554 530a 7d0a 0a0a 636c 6173 GADGETS.}...clas\n+000030d0: 7320 4465 6661 756c 7452 6f75 7469 6e67 s DefaultRouting\n+000030e0: 5275 6c65 2852 6f75 7469 6e67 5275 6c65 Rule(RoutingRule\n+000030f0: 293a 0a20 2020 2070 6565 723a 2027 5065 ):. peer: 'Pe\n+00003100: 6572 207c 204e 6f6e 6527 0a0a 2020 2020 er | None'.. \n+00003110: 6465 6620 5f5f 696e 6974 5f5f 2873 656c def __init__(sel\n+00003120: 662c 2072 6f75 7465 723a 2052 6f75 7465 f, router: Route\n+00003130: 7229 3a0a 2020 2020 2020 2020 7375 7065 r):. supe\n+00003140: 7228 292e 5f5f 696e 6974 5f5f 2872 6f75 r().__init__(rou\n+00003150: 7465 7229 0a0a 2020 2020 6465 6620 6170 ter).. def ap\n+00003160: 706c 795f 7275 6c65 2873 656c 662c 206f ply_rule(self, o\n+00003170: 7074 696f 6e73 3a20 4a73 6f6e 4f62 6a65 ptions: JsonObje\n+00003180: 6374 2920 2d3e 2027 5065 6572 207c 204e ct) -> 'Peer | N\n+00003190: 6f6e 6527 3a0a 2020 2020 2020 2020 7265 one':. re\n+000031a0: 7475 726e 2073 656c 662e 7065 6572 0a0a turn self.peer..\n+000031b0: 2020 2020 6465 6620 7368 7574 646f 776e def shutdown\n+000031c0: 2873 656c 6629 202d 3e20 4e6f 6e65 3a0a (self) -> None:.\n+000031d0: 2020 2020 2020 2020 6966 2073 656c 662e if self.\n+000031e0: 7065 6572 2069 7320 6e6f 7420 4e6f 6e65 peer is not None\n+000031f0: 3a0a 2020 2020 2020 2020 2020 2020 7365 :. se\n+00003200: 6c66 2e70 6565 722e 636c 6f73 6528 290a lf.peer.close().\n+00003210: 0a0a 636c 6173 7320 4175 7468 6f72 697a ..class Authoriz\n+00003220: 6552 6573 706f 6e64 6572 2866 6572 6e79 eResponder(ferny\n+00003230: 2e41 736b 7061 7373 4861 6e64 6c65 7229 .AskpassHandler)\n+00003240: 3a0a 2020 2020 636f 6d6d 616e 6473 203d :. commands =\n+00003250: 2028 2766 6572 6e79 2e61 736b 7061 7373 ('ferny.askpass\n+00003260: 272c 2027 636f 636b 7069 742e 7265 706f ', 'cockpit.repo\n+00003270: 7274 2d65 7869 7374 7327 290a 2020 2020 rt-exists'). \n+00003280: 726f 7574 6572 3a20 526f 7574 6572 0a0a router: Router..\n+00003290: 2020 2020 6465 6620 5f5f 696e 6974 5f5f def __init__\n+000032a0: 2873 656c 662c 2072 6f75 7465 723a 2052 (self, router: R\n+000032b0: 6f75 7465 7229 3a0a 2020 2020 2020 2020 outer):. \n+000032c0: 7365 6c66 2e72 6f75 7465 7220 3d20 726f self.router = ro\n+000032d0: 7574 6572 0a0a 2020 2020 6173 796e 6320 uter.. async \n+000032e0: 6465 6620 646f 5f61 736b 7061 7373 2873 def do_askpass(s\n+000032f0: 656c 662c 206d 6573 7361 6765 733a 2073 elf, messages: s\n+00003300: 7472 2c20 7072 6f6d 7074 3a20 7374 722c tr, prompt: str,\n+00003310: 2068 696e 743a 2073 7472 2920 2d3e 204f hint: str) -> O\n+00003320: 7074 696f 6e61 6c5b 7374 725d 3a0a 2020 ptional[str]:. \n+00003330: 2020 2020 2020 6966 2068 696e 7420 3d3d if hint ==\n+00003340: 2027 6e6f 6e65 273a 0a20 2020 2020 2020 'none':. \n+00003350: 2020 2020 2023 2057 6520 6861 7665 2074 # We have t\n+00003360: 6872 6565 2070 726f 626c 656d 7320 6865 hree problems he\n+00003370: 7265 3a0a 2020 2020 2020 2020 2020 2020 re:. \n+00003380: 230a 2020 2020 2020 2020 2020 2020 2320 #. # \n+00003390: 2020 2d20 7765 2068 6176 6520 6e6f 2077 - we have no w\n+000033a0: 6179 2074 6f20 7072 6573 656e 7420 6120 ay to present a \n+000033b0: 6d65 7373 6167 6520 6f6e 2074 6865 206c message on the l\n+000033c0: 6f67 696e 0a20 2020 2020 2020 2020 2020 ogin. \n+000033d0: 2023 2020 2020 2073 6372 6565 6e20 7769 # screen wi\n+000033e0: 7468 6f75 7420 7072 6573 656e 7469 6e67 thout presenting\n+000033f0: 2061 2070 726f 6d70 7420 616e 6420 6120 a prompt and a \n+00003400: 6275 7474 6f6e 0a20 2020 2020 2020 2020 button. \n+00003410: 2020 2023 2020 202d 2074 6865 206c 6f67 # - the log\n+00003420: 696e 2073 6372 6565 6e20 7769 6c6c 206e in screen will n\n+00003430: 6f74 2074 7279 2074 6f20 7265 706f 7374 ot try to repost\n+00003440: 2074 6865 206c 6f67 696e 0a20 2020 2020 the login. \n+00003450: 2020 2020 2020 2023 2020 2020 2072 6571 # req\n+00003460: 7565 7374 2062 6563 6175 7365 2069 7420 uest because it \n+00003470: 646f 6573 6e27 7420 756e 6465 7273 7461 doesn't understa\n+00003480: 6e64 2074 6861 7420 7765 2061 7265 206e nd that we are n\n+00003490: 6f74 0a20 2020 2020 2020 2020 2020 2023 ot. #\n+000034a0: 2020 2020 2077 6169 7469 6e67 206f 6e20 waiting on \n+000034b0: 696e 7075 742c 2077 6869 6368 206d 6561 input, which mea\n+000034c0: 6e73 2074 6861 7420 6974 2077 6f6e 2774 ns that it won't\n+000034d0: 206e 6f74 6963 650a 2020 2020 2020 2020 notice. \n+000034e0: 2020 2020 2320 2020 2020 7468 6174 2077 # that w\n+000034f0: 6527 7665 206c 6f67 6765 6420 696e 2073 e've logged in s\n+00003500: 7563 6365 7373 6675 6c6c 790a 2020 2020 uccessfully. \n+00003510: 2020 2020 2020 2020 2320 2020 2d20 636f # - co\n+00003520: 636b 7069 742d 7773 2068 6173 2061 6e20 ckpit-ws has an \n+00003530: 6973 7375 6520 7768 6572 6520 6966 2077 issue where if w\n+00003540: 6520 7265 7472 7920 7468 6520 7265 7175 e retry the requ\n+00003550: 6573 740a 2020 2020 2020 2020 2020 2020 est. \n+00003560: 2320 2020 2020 6167 6169 6e20 6166 7465 # again afte\n+00003570: 7220 6c6f 6769 6e20 7375 6363 6565 6465 r login succeede\n+00003580: 6420 7468 656e 2069 7420 776f 6e27 7420 d then it won't \n+00003590: 666f 7277 6172 6420 7468 650a 2020 2020 forward the. \n+000035a0: 2020 2020 2020 2020 2320 2020 2020 696e # in\n+000035b0: 6974 206d 6573 7361 6765 2074 6f20 7468 it message to th\n+000035c0: 6520 636c 6965 6e74 2c20 7374 616c 6c69 e client, stalli\n+000035d0: 6e67 2074 6865 206c 6f67 696e 2e20 2054 ng the login. T\n+000035e0: 6869 730a 2020 2020 2020 2020 2020 2020 his. \n+000035f0: 2320 2020 2020 6973 2061 2072 6163 6520 # is a race \n+00003600: 616e 6420 6361 6e27 7420 6265 2066 6978 and can't be fix\n+00003610: 6564 2077 6974 686f 7574 202d 7773 2063 ed without -ws c\n+00003620: 6861 6e67 6573 2e0a 2020 2020 2020 2020 hanges.. \n+00003630: 2020 2020 230a 2020 2020 2020 2020 2020 #. \n+00003640: 2020 2320 4c65 7427 7320 6176 6f69 6420 # Let's avoid \n+00003650: 616c 6c20 6f66 2074 6861 7420 6279 206a all of that by j\n+00003660: 7573 7420 7368 6f77 696e 6720 6e6f 7468 ust showing noth\n+00003670: 696e 672e 0a20 2020 2020 2020 2020 2020 ing.. \n+00003680: 2072 6574 7572 6e20 4e6f 6e65 0a0a 2020 return None.. \n+00003690: 2020 2020 2020 6368 616c 6c65 6e67 6520 challenge \n+000036a0: 3d20 2758 2d43 6f6e 7665 7273 6174 696f = 'X-Conversatio\n+000036b0: 6e20 2d20 2720 2b20 6261 7365 3634 2e62 n - ' + base64.b\n+000036c0: 3634 656e 636f 6465 2870 726f 6d70 742e 64encode(prompt.\n+000036d0: 656e 636f 6465 2829 292e 6465 636f 6465 encode()).decode\n+000036e0: 2829 0a20 2020 2020 2020 2072 6573 706f (). respo\n+000036f0: 6e73 6520 3d20 6177 6169 7420 7365 6c66 nse = await self\n+00003700: 2e72 6f75 7465 722e 7265 7175 6573 745f .router.request_\n+00003710: 6175 7468 6f72 697a 6174 696f 6e28 6368 authorization(ch\n+00003720: 616c 6c65 6e67 652c 0a20 2020 2020 2020 allenge,. \n+00003730: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00003740: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00003750: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00003760: 2020 2020 6d65 7373 6167 6573 3d6d 6573 messages=mes\n+00003770: 7361 6765 732c 0a20 2020 2020 2020 2020 sages,. \n 00003780: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00003790: 2020 2020 7361 6d70 6c65 735b 6627 7b70 samples[f'{p\n-000037a0: 7265 6669 787d 2e6e 6963 6527 5d20 3d20 refix}.nice'] = \n-000037b0: 696e 7428 6e69 6365 2920 2a20 4d53 5f50 int(nice) * MS_P\n-000037c0: 4552 5f4a 4946 4659 0a20 2020 2020 2020 ER_JIFFY. \n-000037d0: 2020 2020 2020 2020 2020 2020 2073 616d sam\n-000037e0: 706c 6573 5b66 277b 7072 6566 6978 7d2e ples[f'{prefix}.\n-000037f0: 7573 6572 275d 203d 2069 6e74 2875 7365 user'] = int(use\n-00003800: 7229 202a 204d 535f 5045 525f 4a49 4646 r) * MS_PER_JIFF\n-00003810: 590a 2020 2020 2020 2020 2020 2020 2020 Y. \n-00003820: 2020 2020 2020 7361 6d70 6c65 735b 6627 samples[f'\n-00003830: 7b70 7265 6669 787d 2e73 7973 7465 6d27 {prefix}.system'\n-00003840: 5d20 3d20 696e 7428 7379 7374 656d 2920 ] = int(system) \n-00003850: 2a20 4d53 5f50 4552 5f4a 4946 4659 0a20 * MS_PER_JIFFY. \n-00003860: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00003870: 2020 2073 616d 706c 6573 5b66 277b 7072 samples[f'{pr\n-00003880: 6566 6978 7d2e 696f 7761 6974 275d 203d efix}.iowait'] =\n-00003890: 2069 6e74 2869 6f77 6169 7429 202a 204d int(iowait) * M\n-000038a0: 535f 5045 525f 4a49 4646 590a 0a0a 636c S_PER_JIFFY...cl\n-000038b0: 6173 7320 4d65 6d6f 7279 5361 6d70 6c65 ass MemorySample\n-000038c0: 7228 5361 6d70 6c65 7229 3a0a 2020 2020 r(Sampler):. \n-000038d0: 6465 7363 7269 7074 696f 6e73 203d 205b descriptions = [\n-000038e0: 0a20 2020 2020 2020 2053 616d 706c 6544 . SampleD\n-000038f0: 6573 6372 6970 7469 6f6e 2827 6d65 6d6f escription('memo\n-00003900: 7279 2e66 7265 6527 2c20 2762 7974 6573 ry.free', 'bytes\n-00003910: 272c 2027 696e 7374 616e 7427 2c20 696e ', 'instant', in\n-00003920: 7374 616e 6365 643d 4661 6c73 6529 2c0a stanced=False),.\n-00003930: 2020 2020 2020 2020 5361 6d70 6c65 4465 SampleDe\n-00003940: 7363 7269 7074 696f 6e28 276d 656d 6f72 scription('memor\n-00003950: 792e 7573 6564 272c 2027 6279 7465 7327 y.used', 'bytes'\n-00003960: 2c20 2769 6e73 7461 6e74 272c 2069 6e73 , 'instant', ins\n-00003970: 7461 6e63 6564 3d46 616c 7365 292c 0a20 tanced=False),. \n-00003980: 2020 2020 2020 2053 616d 706c 6544 6573 SampleDes\n-00003990: 6372 6970 7469 6f6e 2827 6d65 6d6f 7279 cription('memory\n-000039a0: 2e63 6163 6865 6427 2c20 2762 7974 6573 .cached', 'bytes\n-000039b0: 272c 2027 696e 7374 616e 7427 2c20 696e ', 'instant', in\n-000039c0: 7374 616e 6365 643d 4661 6c73 6529 2c0a stanced=False),.\n-000039d0: 2020 2020 2020 2020 5361 6d70 6c65 4465 SampleDe\n-000039e0: 7363 7269 7074 696f 6e28 276d 656d 6f72 scription('memor\n-000039f0: 792e 7377 6170 2d75 7365 6427 2c20 2762 y.swap-used', 'b\n-00003a00: 7974 6573 272c 2027 696e 7374 616e 7427 ytes', 'instant'\n-00003a10: 2c20 696e 7374 616e 6365 643d 4661 6c73 , instanced=Fals\n-00003a20: 6529 2c0a 2020 2020 5d0a 0a20 2020 2064 e),. ].. d\n-00003a30: 6566 2073 616d 706c 6528 7365 6c66 2c20 ef sample(self, \n-00003a40: 7361 6d70 6c65 733a 2053 616d 706c 6573 samples: Samples\n-00003a50: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n-00003a60: 2020 2077 6974 6820 6f70 656e 2827 2f70 with open('/p\n-00003a70: 726f 632f 6d65 6d69 6e66 6f27 2920 6173 roc/meminfo') as\n-00003a80: 206d 656d 696e 666f 3a0a 2020 2020 2020 meminfo:. \n-00003a90: 2020 2020 2020 6974 656d 7320 3d20 7b6b items = {k\n-00003aa0: 3a20 696e 7428 762e 7374 7269 7028 2720 : int(v.strip(' \n-00003ab0: 6b42 5c6e 2729 2920 666f 7220 6c69 6e65 kB\\n')) for line\n-00003ac0: 2069 6e20 6d65 6d69 6e66 6f20 666f 7220 in meminfo for \n-00003ad0: 6b2c 2076 2069 6e20 5b6c 696e 652e 7370 k, v in [line.sp\n-00003ae0: 6c69 7428 273a 272c 2031 295d 7d0a 0a20 lit(':', 1)]}.. \n-00003af0: 2020 2020 2020 2073 616d 706c 6573 5b27 samples['\n-00003b00: 6d65 6d6f 7279 2e66 7265 6527 5d20 3d20 memory.free'] = \n-00003b10: 3130 3234 202a 2069 7465 6d73 5b27 4d65 1024 * items['Me\n-00003b20: 6d46 7265 6527 5d0a 2020 2020 2020 2020 mFree']. \n-00003b30: 7361 6d70 6c65 735b 276d 656d 6f72 792e samples['memory.\n-00003b40: 7573 6564 275d 203d 2031 3032 3420 2a20 used'] = 1024 * \n-00003b50: 2869 7465 6d73 5b27 4d65 6d54 6f74 616c (items['MemTotal\n-00003b60: 275d 202d 2069 7465 6d73 5b27 4d65 6d41 '] - items['MemA\n-00003b70: 7661 696c 6162 6c65 275d 290a 2020 2020 vailable']). \n-00003b80: 2020 2020 7361 6d70 6c65 735b 276d 656d samples['mem\n-00003b90: 6f72 792e 6361 6368 6564 275d 203d 2031 ory.cached'] = 1\n-00003ba0: 3032 3420 2a20 2869 7465 6d73 5b27 4275 024 * (items['Bu\n-00003bb0: 6666 6572 7327 5d20 2b20 6974 656d 735b ffers'] + items[\n-00003bc0: 2743 6163 6865 6427 5d29 0a20 2020 2020 'Cached']). \n-00003bd0: 2020 2073 616d 706c 6573 5b27 6d65 6d6f samples['memo\n-00003be0: 7279 2e73 7761 702d 7573 6564 275d 203d ry.swap-used'] =\n-00003bf0: 2031 3032 3420 2a20 2869 7465 6d73 5b27 1024 * (items['\n-00003c00: 5377 6170 546f 7461 6c27 5d20 2d20 6974 SwapTotal'] - it\n-00003c10: 656d 735b 2753 7761 7046 7265 6527 5d29 ems['SwapFree'])\n-00003c20: 0a0a 0a63 6c61 7373 2043 5055 5465 6d70 ...class CPUTemp\n-00003c30: 6572 6174 7572 6553 616d 706c 6572 2853 eratureSampler(S\n-00003c40: 616d 706c 6572 293a 0a20 2020 2023 2043 ampler):. # C\n-00003c50: 6163 6865 2066 6f75 6e64 2073 656e 736f ache found senso\n-00003c60: 7273 2c20 6173 2074 6865 7920 6361 6e27 rs, as they can'\n-00003c70: 7420 6265 2068 6f74 706c 7567 6765 642e t be hotplugged.\n-00003c80: 0a20 2020 2073 656e 736f 7273 3a20 4f70 . sensors: Op\n-00003c90: 7469 6f6e 616c 5b4c 6973 745b 7374 725d tional[List[str]\n-00003ca0: 5d20 3d20 4e6f 6e65 0a0a 2020 2020 6465 ] = None.. de\n-00003cb0: 7363 7269 7074 696f 6e73 203d 205b 0a20 scriptions = [. \n-00003cc0: 2020 2020 2020 2053 616d 706c 6544 6573 SampleDes\n-00003cd0: 6372 6970 7469 6f6e 2827 6370 752e 7465 cription('cpu.te\n-00003ce0: 6d70 6572 6174 7572 6527 2c20 2763 656c mperature', 'cel\n-00003cf0: 7369 7573 272c 2027 696e 7374 616e 7427 sius', 'instant'\n-00003d00: 2c20 696e 7374 616e 6365 643d 5472 7565 , instanced=True\n-00003d10: 292c 0a20 2020 205d 0a0a 2020 2020 4073 ),. ].. @s\n-00003d20: 7461 7469 636d 6574 686f 640a 2020 2020 taticmethod. \n-00003d30: 6465 6620 6465 7465 6374 5f63 7075 5f73 def detect_cpu_s\n-00003d40: 656e 736f 7273 2864 6972 5f66 643a 2069 ensors(dir_fd: i\n-00003d50: 6e74 2920 2d3e 2049 7465 7261 626c 655b nt) -> Iterable[\n-00003d60: 7374 725d 3a0a 2020 2020 2020 2020 2320 str]:. # \n-00003d70: 5265 6164 2074 6865 206e 616d 6520 6669 Read the name fi\n-00003d80: 6c65 2074 6f20 6465 6369 6465 2077 6861 le to decide wha\n-00003d90: 7420 746f 2064 6f20 7769 7468 2074 6869 t to do with thi\n-00003da0: 7320 6469 7265 6374 6f72 790a 2020 2020 s directory. \n-00003db0: 2020 2020 7472 793a 0a20 2020 2020 2020 try:. \n-00003dc0: 2020 2020 2077 6974 6820 4861 6e64 6c65 with Handle\n-00003dd0: 2e6f 7065 6e28 276e 616d 6527 2c20 6f73 .open('name', os\n-00003de0: 2e4f 5f52 444f 4e4c 592c 2064 6972 5f66 .O_RDONLY, dir_f\n-00003df0: 643d 6469 725f 6664 2920 6173 2066 643a d=dir_fd) as fd:\n-00003e00: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-00003e10: 206e 616d 6520 3d20 6f73 2e72 6561 6428 name = os.read(\n-00003e20: 6664 2c20 3130 3234 292e 6465 636f 6465 fd, 1024).decode\n-00003e30: 2829 2e73 7472 6970 2829 0a20 2020 2020 ().strip(). \n-00003e40: 2020 2065 7863 6570 7420 4669 6c65 4e6f except FileNo\n-00003e50: 7446 6f75 6e64 4572 726f 723a 0a20 2020 tFoundError:. \n-00003e60: 2020 2020 2020 2020 2072 6574 7572 6e0a return.\n-00003e70: 0a20 2020 2020 2020 2069 6620 6e61 6d65 . if name\n-00003e80: 203d 3d20 2761 746b 3031 3130 273a 0a20 == 'atk0110':. \n-00003e90: 2020 2020 2020 2020 2020 2023 206f 6e6c # onl\n-00003ea0: 7920 7361 6d70 6c65 2027 4350 5520 5465 y sample 'CPU Te\n-00003eb0: 6d70 6572 6174 7572 6527 2069 6e20 6174 mperature' in at\n-00003ec0: 6b30 3131 300a 2020 2020 2020 2020 2020 k0110. \n-00003ed0: 2020 7072 6564 6963 6174 6520 3d20 286c predicate = (l\n-00003ee0: 616d 6264 6120 6c61 6265 6c3a 206c 6162 ambda label: lab\n-00003ef0: 656c 203d 3d20 2743 5055 2054 656d 7065 el == 'CPU Tempe\n-00003f00: 7261 7475 7265 2729 0a20 2020 2020 2020 rature'). \n-00003f10: 2065 6c69 6620 6e61 6d65 203d 3d20 2763 elif name == 'c\n-00003f20: 7075 5f74 6865 726d 616c 273a 0a20 2020 pu_thermal':. \n-00003f30: 2020 2020 2020 2020 2023 206c 6162 656c # label\n-00003f40: 7320 6172 6520 6e6f 7420 7573 6564 206f s are not used o\n-00003f50: 6e20 4152 4d0a 2020 2020 2020 2020 2020 n ARM. \n-00003f60: 2020 7072 6564 6963 6174 6520 3d20 4e6f predicate = No\n-00003f70: 6e65 0a20 2020 2020 2020 2065 6c69 6620 ne. elif \n-00003f80: 6e61 6d65 203d 3d20 2763 6f72 6574 656d name == 'coretem\n-00003f90: 7027 3a0a 2020 2020 2020 2020 2020 2020 p':. \n-00003fa0: 2320 6163 6365 7074 2061 6c6c 206c 6162 # accept all lab\n-00003fb0: 656c 7320 6f6e 2049 6e74 656c 0a20 2020 els on Intel. \n-00003fc0: 2020 2020 2020 2020 2070 7265 6469 6361 predica\n-00003fd0: 7465 203d 204e 6f6e 650a 2020 2020 2020 te = None. \n-00003fe0: 2020 656c 6966 206e 616d 6520 696e 205b elif name in [\n-00003ff0: 276b 3874 656d 7027 2c20 276b 3130 7465 'k8temp', 'k10te\n-00004000: 6d70 275d 3a0a 2020 2020 2020 2020 2020 mp']:. \n-00004010: 2020 7072 6564 6963 6174 6520 3d20 4e6f predicate = No\n-00004020: 6e65 0a20 2020 2020 2020 2065 6c73 653a ne. else:\n-00004030: 0a20 2020 2020 2020 2020 2020 2023 204e . # N\n-00004040: 6f74 2061 2043 5055 2073 656e 736f 720a ot a CPU sensor.\n-00004050: 2020 2020 2020 2020 2020 2020 7265 7475 retu\n-00004060: 726e 0a0a 2020 2020 2020 2020 2320 4e6f rn.. # No\n-00004070: 7720 7363 616e 2074 6865 2064 6972 6563 w scan the direc\n-00004080: 746f 7279 2066 6f72 2069 6e70 7574 730a tory for inputs.\n-00004090: 2020 2020 2020 2020 666f 7220 696e 7075 for inpu\n-000040a0: 745f 6669 6c65 6e61 6d65 2069 6e20 6f73 t_filename in os\n-000040b0: 2e6c 6973 7464 6972 2864 6972 5f66 6429 .listdir(dir_fd)\n-000040c0: 3a0a 2020 2020 2020 2020 2020 2020 6966 :. if\n-000040d0: 206e 6f74 2069 6e70 7574 5f66 696c 656e not input_filen\n-000040e0: 616d 652e 656e 6473 7769 7468 2827 5f69 ame.endswith('_i\n-000040f0: 6e70 7574 2729 3a0a 2020 2020 2020 2020 nput'):. \n-00004100: 2020 2020 2020 2020 636f 6e74 696e 7565 continue\n-00004110: 0a0a 2020 2020 2020 2020 2020 2020 6966 .. if\n-00004120: 2070 7265 6469 6361 7465 3a0a 2020 2020 predicate:. \n-00004130: 2020 2020 2020 2020 2020 2020 2320 5765 # We\n-00004140: 206e 6565 6420 746f 2063 6865 636b 2074 need to check t\n-00004150: 6865 206c 6162 656c 0a20 2020 2020 2020 he label. \n-00004160: 2020 2020 2020 2020 2074 7279 3a0a 2020 try:. \n-00004170: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00004180: 2020 6c61 6265 6c5f 6669 6c65 6e61 6d65 label_filename\n-00004190: 203d 2069 6e70 7574 5f66 696c 656e 616d = input_filenam\n-000041a0: 652e 7265 706c 6163 6528 275f 696e 7075 e.replace('_inpu\n-000041b0: 7427 2c20 275f 6c61 6265 6c27 290a 2020 t', '_label'). \n-000041c0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000041d0: 2020 7769 7468 2048 616e 646c 652e 6f70 with Handle.op\n-000041e0: 656e 286c 6162 656c 5f66 696c 656e 616d en(label_filenam\n-000041f0: 652c 206f 732e 4f5f 5244 4f4e 4c59 2c20 e, os.O_RDONLY, \n-00004200: 6469 725f 6664 3d64 6972 5f66 6429 2061 dir_fd=dir_fd) a\n-00004210: 7320 6664 3a0a 2020 2020 2020 2020 2020 s fd:. \n-00004220: 2020 2020 2020 2020 2020 2020 2020 6c61 la\n-00004230: 6265 6c20 3d20 6f73 2e72 6561 6428 6664 bel = os.read(fd\n-00004240: 2c20 3130 3234 292e 6465 636f 6465 2829 , 1024).decode()\n-00004250: 2e73 7472 6970 2829 0a20 2020 2020 2020 .strip(). \n-00004260: 2020 2020 2020 2020 2065 7863 6570 7420 except \n-00004270: 4669 6c65 4e6f 7446 6f75 6e64 4572 726f FileNotFoundErro\n-00004280: 723a 0a20 2020 2020 2020 2020 2020 2020 r:. \n-00004290: 2020 2020 2020 2063 6f6e 7469 6e75 650a continue.\n-000042a0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-000042b0: 2069 6620 6e6f 7420 7072 6564 6963 6174 if not predicat\n-000042c0: 6528 6c61 6265 6c29 3a0a 2020 2020 2020 e(label):. \n-000042d0: 2020 2020 2020 2020 2020 2020 2020 636f co\n-000042e0: 6e74 696e 7565 0a0a 2020 2020 2020 2020 ntinue.. \n-000042f0: 2020 2020 7969 656c 6420 696e 7075 745f yield input_\n-00004300: 6669 6c65 6e61 6d65 0a0a 2020 2020 4073 filename.. @s\n-00004310: 7461 7469 636d 6574 686f 640a 2020 2020 taticmethod. \n-00004320: 6465 6620 7363 616e 5f73 656e 736f 7273 def scan_sensors\n-00004330: 2829 202d 3e20 4974 6572 6162 6c65 5b73 () -> Iterable[s\n-00004340: 7472 5d3a 0a20 2020 2020 2020 2074 7279 tr]:. try\n-00004350: 3a0a 2020 2020 2020 2020 2020 2020 746f :. to\n-00004360: 705f 6664 203d 2048 616e 646c 652e 6f70 p_fd = Handle.op\n-00004370: 656e 2848 574d 4f4e 5f50 4154 482c 206f en(HWMON_PATH, o\n-00004380: 732e 4f5f 5244 4f4e 4c59 207c 206f 732e s.O_RDONLY | os.\n-00004390: 4f5f 4449 5245 4354 4f52 5929 0a20 2020 O_DIRECTORY). \n-000043a0: 2020 2020 2065 7863 6570 7420 4669 6c65 except File\n-000043b0: 4e6f 7446 6f75 6e64 4572 726f 723a 0a20 NotFoundError:. \n-000043c0: 2020 2020 2020 2020 2020 2072 6574 7572 retur\n-000043d0: 6e0a 0a20 2020 2020 2020 2077 6974 6820 n.. with \n-000043e0: 746f 705f 6664 3a0a 2020 2020 2020 2020 top_fd:. \n-000043f0: 2020 2020 666f 7220 6877 6d6f 6e5f 6e61 for hwmon_na\n-00004400: 6d65 2069 6e20 6f73 2e6c 6973 7464 6972 me in os.listdir\n-00004410: 2874 6f70 5f66 6429 3a0a 2020 2020 2020 (top_fd):. \n-00004420: 2020 2020 2020 2020 2020 7769 7468 2048 with H\n-00004430: 616e 646c 652e 6f70 656e 2868 776d 6f6e andle.open(hwmon\n-00004440: 5f6e 616d 652c 206f 732e 4f5f 5244 4f4e _name, os.O_RDON\n-00004450: 4c59 207c 206f 732e 4f5f 4449 5245 4354 LY | os.O_DIRECT\n-00004460: 4f52 592c 2064 6972 5f66 643d 746f 705f ORY, dir_fd=top_\n-00004470: 6664 2920 6173 2073 7562 6469 725f 6664 fd) as subdir_fd\n-00004480: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n-00004490: 2020 2020 2020 666f 7220 7365 6e73 6f72 for sensor\n-000044a0: 2069 6e20 4350 5554 656d 7065 7261 7475 in CPUTemperatu\n-000044b0: 7265 5361 6d70 6c65 722e 6465 7465 6374 reSampler.detect\n-000044c0: 5f63 7075 5f73 656e 736f 7273 2873 7562 _cpu_sensors(sub\n-000044d0: 6469 725f 6664 293a 0a20 2020 2020 2020 dir_fd):. \n-000044e0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000044f0: 2079 6965 6c64 2066 277b 4857 4d4f 4e5f yield f'{HWMON_\n-00004500: 5041 5448 7d2f 7b68 776d 6f6e 5f6e 616d PATH}/{hwmon_nam\n-00004510: 657d 2f7b 7365 6e73 6f72 7d27 0a0a 2020 e}/{sensor}'.. \n-00004520: 2020 6465 6620 7361 6d70 6c65 2873 656c def sample(sel\n-00004530: 662c 2073 616d 706c 6573 3a20 5361 6d70 f, samples: Samp\n-00004540: 6c65 7329 202d 3e20 4e6f 6e65 3a0a 2020 les) -> None:. \n-00004550: 2020 2020 2020 6966 2073 656c 662e 7365 if self.se\n-00004560: 6e73 6f72 7320 6973 204e 6f6e 653a 0a20 nsors is None:. \n-00004570: 2020 2020 2020 2020 2020 2073 656c 662e self.\n-00004580: 7365 6e73 6f72 7320 3d20 6c69 7374 2843 sensors = list(C\n-00004590: 5055 5465 6d70 6572 6174 7572 6553 616d PUTemperatureSam\n-000045a0: 706c 6572 2e73 6361 6e5f 7365 6e73 6f72 pler.scan_sensor\n-000045b0: 7328 2929 0a0a 2020 2020 2020 2020 666f s()).. fo\n-000045c0: 7220 7365 6e73 6f72 5f70 6174 6820 696e r sensor_path in\n-000045d0: 2073 656c 662e 7365 6e73 6f72 733a 0a20 self.sensors:. \n-000045e0: 2020 2020 2020 2020 2020 2077 6974 6820 with \n-000045f0: 6f70 656e 2873 656e 736f 725f 7061 7468 open(sensor_path\n-00004600: 2920 6173 2073 656e 736f 723a 0a20 2020 ) as sensor:. \n-00004610: 2020 2020 2020 2020 2020 2020 2074 656d tem\n-00004620: 7065 7261 7475 7265 203d 2069 6e74 2873 perature = int(s\n-00004630: 656e 736f 722e 7265 6164 2829 2e73 7472 ensor.read().str\n-00004640: 6970 2829 290a 2020 2020 2020 2020 2020 ip()). \n-00004650: 2020 2020 2020 6966 2074 656d 7065 7261 if tempera\n-00004660: 7475 7265 203d 3d20 303a 0a20 2020 2020 ture == 0:. \n-00004670: 2020 2020 2020 2020 2020 2020 2020 2072 r\n-00004680: 6574 7572 6e0a 0a20 2020 2020 2020 2020 eturn.. \n-00004690: 2020 2073 616d 706c 6573 5b27 6370 752e samples['cpu.\n-000046a0: 7465 6d70 6572 6174 7572 6527 5d5b 7365 temperature'][se\n-000046b0: 6e73 6f72 5f70 6174 685d 203d 2074 656d nsor_path] = tem\n-000046c0: 7065 7261 7475 7265 202f 2031 3030 300a perature / 1000.\n-000046d0: 0a0a 636c 6173 7320 4469 736b 5361 6d70 ..class DiskSamp\n-000046e0: 6c65 7228 5361 6d70 6c65 7229 3a0a 2020 ler(Sampler):. \n-000046f0: 2020 6465 7363 7269 7074 696f 6e73 203d descriptions =\n-00004700: 205b 0a20 2020 2020 2020 2053 616d 706c [. Sampl\n-00004710: 6544 6573 6372 6970 7469 6f6e 2827 6469 eDescription('di\n-00004720: 736b 2e61 6c6c 2e72 6561 6427 2c20 2762 sk.all.read', 'b\n-00004730: 7974 6573 272c 2027 636f 756e 7465 7227 ytes', 'counter'\n-00004740: 2c20 696e 7374 616e 6365 643d 4661 6c73 , instanced=Fals\n-00004750: 6529 2c0a 2020 2020 2020 2020 5361 6d70 e),. Samp\n-00004760: 6c65 4465 7363 7269 7074 696f 6e28 2764 leDescription('d\n-00004770: 6973 6b2e 616c 6c2e 7772 6974 7465 6e27 isk.all.written'\n-00004780: 2c20 2762 7974 6573 272c 2027 636f 756e , 'bytes', 'coun\n-00004790: 7465 7227 2c20 696e 7374 616e 6365 643d ter', instanced=\n-000047a0: 4661 6c73 6529 2c0a 2020 2020 2020 2020 False),. \n-000047b0: 5361 6d70 6c65 4465 7363 7269 7074 696f SampleDescriptio\n-000047c0: 6e28 2764 6973 6b2e 6465 762e 7265 6164 n('disk.dev.read\n-000047d0: 272c 2027 6279 7465 7327 2c20 2763 6f75 ', 'bytes', 'cou\n-000047e0: 6e74 6572 272c 2069 6e73 7461 6e63 6564 nter', instanced\n-000047f0: 3d54 7275 6529 2c0a 2020 2020 2020 2020 =True),. \n-00004800: 5361 6d70 6c65 4465 7363 7269 7074 696f SampleDescriptio\n-00004810: 6e28 2764 6973 6b2e 6465 762e 7772 6974 n('disk.dev.writ\n-00004820: 7465 6e27 2c20 2762 7974 6573 272c 2027 ten', 'bytes', '\n-00004830: 636f 756e 7465 7227 2c20 696e 7374 616e counter', instan\n-00004840: 6365 643d 5472 7565 292c 0a20 2020 205d ced=True),. ]\n-00004850: 0a0a 2020 2020 6465 6620 7361 6d70 6c65 .. def sample\n-00004860: 2873 656c 662c 2073 616d 706c 6573 3a20 (self, samples: \n-00004870: 5361 6d70 6c65 7329 202d 3e20 4e6f 6e65 Samples) -> None\n-00004880: 3a0a 2020 2020 2020 2020 7769 7468 206f :. with o\n-00004890: 7065 6e28 272f 7072 6f63 2f64 6973 6b73 pen('/proc/disks\n-000048a0: 7461 7473 2729 2061 7320 6469 736b 7374 tats') as diskst\n-000048b0: 6174 733a 0a20 2020 2020 2020 2020 2020 ats:. \n-000048c0: 2061 6c6c 5f72 6561 645f 6279 7465 7320 all_read_bytes \n-000048d0: 3d20 300a 2020 2020 2020 2020 2020 2020 = 0. \n-000048e0: 616c 6c5f 7772 6974 7465 6e5f 6279 7465 all_written_byte\n-000048f0: 7320 3d20 300a 0a20 2020 2020 2020 2020 s = 0.. \n-00004900: 2020 2066 6f72 206c 696e 6520 696e 2064 for line in d\n-00004910: 6973 6b73 7461 7473 3a0a 2020 2020 2020 iskstats:. \n-00004920: 2020 2020 2020 2020 2020 2320 6874 7470 # http\n-00004930: 733a 2f2f 7777 772e 6b65 726e 656c 2e6f s://www.kernel.o\n-00004940: 7267 2f64 6f63 2f44 6f63 756d 656e 7461 rg/doc/Documenta\n-00004950: 7469 6f6e 2f41 4249 2f74 6573 7469 6e67 tion/ABI/testing\n-00004960: 2f70 726f 6366 732d 6469 736b 7374 6174 /procfs-diskstat\n-00004970: 730a 2020 2020 2020 2020 2020 2020 2020 s. \n-00004980: 2020 6669 656c 6473 203d 206c 696e 652e fields = line.\n-00004990: 7374 7269 7028 292e 7370 6c69 7428 290a strip().split().\n-000049a0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000049b0: 6465 765f 6d61 6a6f 7220 3d20 6669 656c dev_major = fiel\n-000049c0: 6473 5b30 5d0a 2020 2020 2020 2020 2020 ds[0]. \n-000049d0: 2020 2020 2020 6465 765f 6e61 6d65 203d dev_name =\n-000049e0: 2066 6965 6c64 735b 325d 0a20 2020 2020 fields[2]. \n-000049f0: 2020 2020 2020 2020 2020 206e 756d 5f73 num_s\n-00004a00: 6563 746f 7273 5f72 6561 6420 3d20 6669 ectors_read = fi\n-00004a10: 656c 6473 5b35 5d0a 2020 2020 2020 2020 elds[5]. \n-00004a20: 2020 2020 2020 2020 6e75 6d5f 7365 6374 num_sect\n-00004a30: 6f72 735f 7772 6974 7465 6e20 3d20 6669 ors_written = fi\n-00004a40: 656c 6473 5b39 5d0a 0a20 2020 2020 2020 elds[9].. \n-00004a50: 2020 2020 2020 2020 2023 2069 676e 6f72 # ignor\n-00004a60: 6520 6d64 7261 6964 0a20 2020 2020 2020 e mdraid. \n-00004a70: 2020 2020 2020 2020 2069 6620 6465 765f if dev_\n-00004a80: 6d61 6a6f 7220 3d3d 2027 3927 3a0a 2020 major == '9':. \n-00004a90: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00004aa0: 2020 636f 6e74 696e 7565 0a0a 2020 2020 continue.. \n-00004ab0: 2020 2020 2020 2020 2020 2020 2320 6967 # ig\n-00004ac0: 6e6f 7265 2064 6576 6963 652d 6d61 7070 nore device-mapp\n-00004ad0: 6572 0a20 2020 2020 2020 2020 2020 2020 er. \n-00004ae0: 2020 2069 6620 6465 765f 6e61 6d65 2e73 if dev_name.s\n-00004af0: 7461 7274 7377 6974 6828 2764 6d2d 2729 tartswith('dm-')\n-00004b00: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n-00004b10: 2020 2020 2020 636f 6e74 696e 7565 0a0a continue..\n-00004b20: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00004b30: 2320 536b 6970 2070 6172 7469 7469 6f6e # Skip partition\n-00004b40: 730a 2020 2020 2020 2020 2020 2020 2020 s. \n-00004b50: 2020 6966 2064 6576 5f6e 616d 655b 3a32 if dev_name[:2\n-00004b60: 5d20 696e 205b 2773 6427 2c20 2768 6427 ] in ['sd', 'hd'\n-00004b70: 2c20 2776 6427 5d20 616e 6420 6465 765f , 'vd'] and dev_\n-00004b80: 6e61 6d65 5b2d 315d 2e69 7364 6967 6974 name[-1].isdigit\n-00004b90: 2829 3a0a 2020 2020 2020 2020 2020 2020 ():. \n-00004ba0: 2020 2020 2020 2020 636f 6e74 696e 7565 continue\n-00004bb0: 0a0a 2020 2020 2020 2020 2020 2020 2020 .. \n-00004bc0: 2020 2320 4967 6e6f 7265 206e 766d 6520 # Ignore nvme \n-00004bd0: 7061 7274 6974 696f 6e73 0a20 2020 2020 partitions. \n-00004be0: 2020 2020 2020 2020 2020 2069 6620 6465 if de\n-00004bf0: 765f 6e61 6d65 2e73 7461 7274 7377 6974 v_name.startswit\n-00004c00: 6828 276e 766d 6527 2920 616e 6420 2770 h('nvme') and 'p\n-00004c10: 2720 696e 2064 6576 5f6e 616d 653a 0a20 ' in dev_name:. \n-00004c20: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00004c30: 2020 2063 6f6e 7469 6e75 650a 0a20 2020 continue.. \n-00004c40: 2020 2020 2020 2020 2020 2020 2072 6561 rea\n-00004c50: 645f 6279 7465 7320 3d20 696e 7428 6e75 d_bytes = int(nu\n-00004c60: 6d5f 7365 6374 6f72 735f 7265 6164 2920 m_sectors_read) \n-00004c70: 2a20 3531 320a 2020 2020 2020 2020 2020 * 512. \n-00004c80: 2020 2020 2020 7772 6974 7465 6e5f 6279 written_by\n-00004c90: 7465 7320 3d20 696e 7428 6e75 6d5f 7365 tes = int(num_se\n-00004ca0: 6374 6f72 735f 7772 6974 7465 6e29 202a ctors_written) *\n-00004cb0: 2035 3132 0a0a 2020 2020 2020 2020 2020 512.. \n-00004cc0: 2020 2020 2020 616c 6c5f 7265 6164 5f62 all_read_b\n-00004cd0: 7974 6573 202b 3d20 7265 6164 5f62 7974 ytes += read_byt\n-00004ce0: 6573 0a20 2020 2020 2020 2020 2020 2020 es. \n-00004cf0: 2020 2061 6c6c 5f77 7269 7474 656e 5f62 all_written_b\n-00004d00: 7974 6573 202b 3d20 7772 6974 7465 6e5f ytes += written_\n-00004d10: 6279 7465 730a 0a20 2020 2020 2020 2020 bytes.. \n-00004d20: 2020 2020 2020 2073 616d 706c 6573 5b27 samples['\n-00004d30: 6469 736b 2e64 6576 2e72 6561 6427 5d5b disk.dev.read'][\n-00004d40: 6465 765f 6e61 6d65 5d20 3d20 7265 6164 dev_name] = read\n-00004d50: 5f62 7974 6573 0a20 2020 2020 2020 2020 _bytes. \n-00004d60: 2020 2020 2020 2073 616d 706c 6573 5b27 samples['\n-00004d70: 6469 736b 2e64 6576 2e77 7269 7474 656e disk.dev.written\n-00004d80: 275d 5b64 6576 5f6e 616d 655d 203d 2077 '][dev_name] = w\n-00004d90: 7269 7474 656e 5f62 7974 6573 0a0a 2020 ritten_bytes.. \n-00004da0: 2020 2020 2020 2020 2020 7361 6d70 6c65 sample\n-00004db0: 735b 2764 6973 6b2e 616c 6c2e 7265 6164 s['disk.all.read\n-00004dc0: 275d 203d 2061 6c6c 5f72 6561 645f 6279 '] = all_read_by\n-00004dd0: 7465 730a 2020 2020 2020 2020 2020 2020 tes. \n-00004de0: 7361 6d70 6c65 735b 2764 6973 6b2e 616c samples['disk.al\n-00004df0: 6c2e 7772 6974 7465 6e27 5d20 3d20 616c l.written'] = al\n-00004e00: 6c5f 7772 6974 7465 6e5f 6279 7465 730a l_written_bytes.\n-00004e10: 0a0a 636c 6173 7320 4347 726f 7570 5361 ..class CGroupSa\n-00004e20: 6d70 6c65 7228 5361 6d70 6c65 7229 3a0a mpler(Sampler):.\n-00004e30: 2020 2020 6465 7363 7269 7074 696f 6e73 descriptions\n-00004e40: 203d 205b 0a20 2020 2020 2020 2053 616d = [. Sam\n-00004e50: 706c 6544 6573 6372 6970 7469 6f6e 2827 pleDescription('\n-00004e60: 6367 726f 7570 2e6d 656d 6f72 792e 7573 cgroup.memory.us\n-00004e70: 6167 6527 2c20 2762 7974 6573 272c 2027 age', 'bytes', '\n-00004e80: 696e 7374 616e 7427 2c20 696e 7374 616e instant', instan\n-00004e90: 6365 643d 5472 7565 292c 0a20 2020 2020 ced=True),. \n-00004ea0: 2020 2053 616d 706c 6544 6573 6372 6970 SampleDescrip\n-00004eb0: 7469 6f6e 2827 6367 726f 7570 2e6d 656d tion('cgroup.mem\n-00004ec0: 6f72 792e 6c69 6d69 7427 2c20 2762 7974 ory.limit', 'byt\n-00004ed0: 6573 272c 2027 696e 7374 616e 7427 2c20 es', 'instant', \n-00004ee0: 696e 7374 616e 6365 643d 5472 7565 292c instanced=True),\n-00004ef0: 0a20 2020 2020 2020 2053 616d 706c 6544 . SampleD\n-00004f00: 6573 6372 6970 7469 6f6e 2827 6367 726f escription('cgro\n-00004f10: 7570 2e6d 656d 6f72 792e 7377 2d75 7361 up.memory.sw-usa\n-00004f20: 6765 272c 2027 6279 7465 7327 2c20 2769 ge', 'bytes', 'i\n-00004f30: 6e73 7461 6e74 272c 2069 6e73 7461 6e63 nstant', instanc\n-00004f40: 6564 3d54 7275 6529 2c0a 2020 2020 2020 ed=True),. \n-00004f50: 2020 5361 6d70 6c65 4465 7363 7269 7074 SampleDescript\n-00004f60: 696f 6e28 2763 6772 6f75 702e 6d65 6d6f ion('cgroup.memo\n-00004f70: 7279 2e73 772d 6c69 6d69 7427 2c20 2762 ry.sw-limit', 'b\n-00004f80: 7974 6573 272c 2027 696e 7374 616e 7427 ytes', 'instant'\n-00004f90: 2c20 696e 7374 616e 6365 643d 5472 7565 , instanced=True\n-00004fa0: 292c 0a20 2020 2020 2020 2053 616d 706c ),. Sampl\n-00004fb0: 6544 6573 6372 6970 7469 6f6e 2827 6367 eDescription('cg\n-00004fc0: 726f 7570 2e63 7075 2e75 7361 6765 272c roup.cpu.usage',\n-00004fd0: 2027 6d69 6c6c 6973 6563 272c 2027 636f 'millisec', 'co\n-00004fe0: 756e 7465 7227 2c20 696e 7374 616e 6365 unter', instance\n-00004ff0: 643d 5472 7565 292c 0a20 2020 2020 2020 d=True),. \n-00005000: 2053 616d 706c 6544 6573 6372 6970 7469 SampleDescripti\n-00005010: 6f6e 2827 6367 726f 7570 2e63 7075 2e73 on('cgroup.cpu.s\n-00005020: 6861 7265 7327 2c20 2763 6f75 6e74 272c hares', 'count',\n-00005030: 2027 696e 7374 616e 7427 2c20 696e 7374 'instant', inst\n-00005040: 616e 6365 643d 5472 7565 292c 0a20 2020 anced=True),. \n-00005050: 205d 0a0a 2020 2020 6367 726f 7570 735f ].. cgroups_\n-00005060: 7632 3a20 4f70 7469 6f6e 616c 5b62 6f6f v2: Optional[boo\n-00005070: 6c5d 203d 204e 6f6e 650a 0a20 2020 2064 l] = None.. d\n-00005080: 6566 2073 616d 706c 6528 7365 6c66 2c20 ef sample(self, \n-00005090: 7361 6d70 6c65 733a 2053 616d 706c 6573 samples: Samples\n-000050a0: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n-000050b0: 2020 2069 6620 7365 6c66 2e63 6772 6f75 if self.cgrou\n-000050c0: 7073 5f76 3220 6973 204e 6f6e 653a 0a20 ps_v2 is None:. \n-000050d0: 2020 2020 2020 2020 2020 2073 656c 662e self.\n-000050e0: 6367 726f 7570 735f 7632 203d 206f 732e cgroups_v2 = os.\n-000050f0: 7061 7468 2e65 7869 7374 7328 272f 7379 path.exists('/sy\n-00005100: 732f 6673 2f63 6772 6f75 702f 6367 726f s/fs/cgroup/cgro\n-00005110: 7570 2e63 6f6e 7472 6f6c 6c65 7273 2729 up.controllers')\n-00005120: 0a0a 2020 2020 2020 2020 6966 2073 656c .. if sel\n-00005130: 662e 6367 726f 7570 735f 7632 3a0a 2020 f.cgroups_v2:. \n-00005140: 2020 2020 2020 2020 2020 6367 726f 7570 cgroup\n-00005150: 735f 7632 5f70 6174 6820 3d20 272f 7379 s_v2_path = '/sy\n-00005160: 732f 6673 2f63 6772 6f75 702f 270a 2020 s/fs/cgroup/'. \n-00005170: 2020 2020 2020 2020 2020 666f 7220 7061 for pa\n-00005180: 7468 2c20 5f2c 205f 2c20 726f 6f74 6664 th, _, _, rootfd\n-00005190: 2069 6e20 6f73 2e66 7761 6c6b 2863 6772 in os.fwalk(cgr\n-000051a0: 6f75 7073 5f76 325f 7061 7468 293a 0a20 oups_v2_path):. \n-000051b0: 2020 2020 2020 2020 2020 2020 2020 2063 c\n-000051c0: 6772 6f75 7020 3d20 7061 7468 2e72 6570 group = path.rep\n-000051d0: 6c61 6365 2863 6772 6f75 7073 5f76 325f lace(cgroups_v2_\n-000051e0: 7061 7468 2c20 2727 290a 0a20 2020 2020 path, '').. \n-000051f0: 2020 2020 2020 2020 2020 2069 6620 6e6f if no\n-00005200: 7420 6367 726f 7570 3a0a 2020 2020 2020 t cgroup:. \n-00005210: 2020 2020 2020 2020 2020 2020 2020 636f co\n-00005220: 6e74 696e 7565 0a0a 2020 2020 2020 2020 ntinue.. \n-00005230: 2020 2020 2020 2020 7361 6d70 6c65 735b samples[\n-00005240: 2763 6772 6f75 702e 6d65 6d6f 7279 2e75 'cgroup.memory.u\n-00005250: 7361 6765 275d 5b63 6772 6f75 705d 203d sage'][cgroup] =\n-00005260: 2072 6561 645f 696e 745f 6669 6c65 2872 read_int_file(r\n-00005270: 6f6f 7466 642c 2027 6d65 6d6f 7279 2e63 ootfd, 'memory.c\n-00005280: 7572 7265 6e74 272c 2030 290a 2020 2020 urrent', 0). \n-00005290: 2020 2020 2020 2020 2020 2020 7361 6d70 samp\n-000052a0: 6c65 735b 2763 6772 6f75 702e 6d65 6d6f les['cgroup.memo\n-000052b0: 7279 2e6c 696d 6974 275d 5b63 6772 6f75 ry.limit'][cgrou\n-000052c0: 705d 203d 2072 6561 645f 696e 745f 6669 p] = read_int_fi\n-000052d0: 6c65 2872 6f6f 7466 642c 2027 6d65 6d6f le(rootfd, 'memo\n-000052e0: 7279 2e6d 6178 2729 0a20 2020 2020 2020 ry.max'). \n-000052f0: 2020 2020 2020 2020 2073 616d 706c 6573 samples\n-00005300: 5b27 6367 726f 7570 2e6d 656d 6f72 792e ['cgroup.memory.\n-00005310: 7377 2d75 7361 6765 275d 5b63 6772 6f75 sw-usage'][cgrou\n-00005320: 705d 203d 2072 6561 645f 696e 745f 6669 p] = read_int_fi\n-00005330: 6c65 2872 6f6f 7466 642c 2027 6d65 6d6f le(rootfd, 'memo\n-00005340: 7279 2e73 7761 702e 6375 7272 656e 7427 ry.swap.current'\n-00005350: 2c20 3029 0a20 2020 2020 2020 2020 2020 , 0). \n-00005360: 2020 2020 2073 616d 706c 6573 5b27 6367 samples['cg\n-00005370: 726f 7570 2e6d 656d 6f72 792e 7377 2d6c roup.memory.sw-l\n-00005380: 696d 6974 275d 5b63 6772 6f75 705d 203d imit'][cgroup] =\n-00005390: 2072 6561 645f 696e 745f 6669 6c65 2872 read_int_file(r\n-000053a0: 6f6f 7466 642c 2027 6d65 6d6f 7279 2e73 ootfd, 'memory.s\n-000053b0: 7761 702e 6d61 7827 290a 2020 2020 2020 wap.max'). \n-000053c0: 2020 2020 2020 2020 2020 7361 6d70 6c65 sample\n-000053d0: 735b 2763 6772 6f75 702e 6370 752e 7368 s['cgroup.cpu.sh\n-000053e0: 6172 6573 275d 5b63 6772 6f75 705d 203d ares'][cgroup] =\n-000053f0: 2072 6561 645f 696e 745f 6669 6c65 2872 read_int_file(r\n-00005400: 6f6f 7466 642c 2027 6370 752e 7765 6967 ootfd, 'cpu.weig\n-00005410: 6874 2729 0a20 2020 2020 2020 2020 2020 ht'). \n-00005420: 2020 2020 2075 7361 6765 5f75 7365 6320 usage_usec \n-00005430: 3d20 7265 6164 5f69 6e74 5f66 696c 6528 = read_int_file(\n-00005440: 726f 6f74 6664 2c20 2763 7075 2e73 7461 rootfd, 'cpu.sta\n-00005450: 7427 2c20 302c 206b 6579 3d62 2775 7361 t', 0, key=b'usa\n-00005460: 6765 5f75 7365 6327 290a 2020 2020 2020 ge_usec'). \n-00005470: 2020 2020 2020 2020 2020 6966 2075 7361 if usa\n-00005480: 6765 5f75 7365 633a 0a20 2020 2020 2020 ge_usec:. \n-00005490: 2020 2020 2020 2020 2020 2020 2073 616d sam\n-000054a0: 706c 6573 5b27 6367 726f 7570 2e63 7075 ples['cgroup.cpu\n-000054b0: 2e75 7361 6765 275d 5b63 6772 6f75 705d .usage'][cgroup]\n-000054c0: 203d 2075 7361 6765 5f75 7365 6320 2f20 = usage_usec / \n-000054d0: 3130 3030 0a20 2020 2020 2020 2065 6c73 1000. els\n-000054e0: 653a 0a20 2020 2020 2020 2020 2020 206d e:. m\n-000054f0: 656d 6f72 795f 7061 7468 203d 2027 2f73 emory_path = '/s\n-00005500: 7973 2f66 732f 6367 726f 7570 2f6d 656d ys/fs/cgroup/mem\n-00005510: 6f72 792f 270a 2020 2020 2020 2020 2020 ory/'. \n-00005520: 2020 666f 7220 7061 7468 2c20 5f2c 205f for path, _, _\n-00005530: 2c20 726f 6f74 6664 2069 6e20 6f73 2e66 , rootfd in os.f\n-00005540: 7761 6c6b 286d 656d 6f72 795f 7061 7468 walk(memory_path\n-00005550: 293a 0a20 2020 2020 2020 2020 2020 2020 ):. \n-00005560: 2020 2063 6772 6f75 7020 3d20 7061 7468 cgroup = path\n-00005570: 2e72 6570 6c61 6365 286d 656d 6f72 795f .replace(memory_\n-00005580: 7061 7468 2c20 2727 290a 0a20 2020 2020 path, '').. \n-00005590: 2020 2020 2020 2020 2020 2069 6620 6e6f if no\n-000055a0: 7420 6367 726f 7570 3a0a 2020 2020 2020 t cgroup:. \n-000055b0: 2020 2020 2020 2020 2020 2020 2020 636f co\n-000055c0: 6e74 696e 7565 0a0a 2020 2020 2020 2020 ntinue.. \n-000055d0: 2020 2020 2020 2020 7361 6d70 6c65 735b samples[\n-000055e0: 2763 6772 6f75 702e 6d65 6d6f 7279 2e75 'cgroup.memory.u\n-000055f0: 7361 6765 275d 5b63 6772 6f75 705d 203d sage'][cgroup] =\n-00005600: 2072 6561 645f 696e 745f 6669 6c65 2872 read_int_file(r\n-00005610: 6f6f 7466 642c 2027 6d65 6d6f 7279 2e75 ootfd, 'memory.u\n-00005620: 7361 6765 5f69 6e5f 6279 7465 7327 2c20 sage_in_bytes', \n-00005630: 3029 0a20 2020 2020 2020 2020 2020 2020 0). \n-00005640: 2020 2073 616d 706c 6573 5b27 6367 726f samples['cgro\n-00005650: 7570 2e6d 656d 6f72 792e 6c69 6d69 7427 up.memory.limit'\n-00005660: 5d5b 6367 726f 7570 5d20 3d20 7265 6164 ][cgroup] = read\n-00005670: 5f69 6e74 5f66 696c 6528 726f 6f74 6664 _int_file(rootfd\n-00005680: 2c20 276d 656d 6f72 792e 6c69 6d69 745f , 'memory.limit_\n-00005690: 696e 5f62 7974 6573 2729 0a20 2020 2020 in_bytes'). \n-000056a0: 2020 2020 2020 2020 2020 2073 616d 706c sampl\n-000056b0: 6573 5b27 6367 726f 7570 2e6d 656d 6f72 es['cgroup.memor\n-000056c0: 792e 7377 2d75 7361 6765 275d 5b63 6772 y.sw-usage'][cgr\n-000056d0: 6f75 705d 203d 2072 6561 645f 696e 745f oup] = read_int_\n-000056e0: 6669 6c65 2872 6f6f 7466 642c 2027 6d65 file(rootfd, 'me\n-000056f0: 6d6f 7279 2e6d 656d 7377 2e75 7361 6765 mory.memsw.usage\n-00005700: 5f69 6e5f 6279 7465 7327 2c20 3029 0a20 _in_bytes', 0). \n-00005710: 2020 2020 2020 2020 2020 2020 2020 2073 s\n-00005720: 616d 706c 6573 5b27 6367 726f 7570 2e6d amples['cgroup.m\n-00005730: 656d 6f72 792e 7377 2d6c 696d 6974 275d emory.sw-limit']\n-00005740: 5b63 6772 6f75 705d 203d 2072 6561 645f [cgroup] = read_\n-00005750: 696e 745f 6669 6c65 2872 6f6f 7466 642c int_file(rootfd,\n-00005760: 2027 6d65 6d6f 7279 2e6d 656d 7377 2e6c 'memory.memsw.l\n-00005770: 696d 6974 5f69 6e5f 6279 7465 7327 290a imit_in_bytes').\n-00005780: 0a20 2020 2020 2020 2020 2020 2063 7075 . cpu\n-00005790: 5f70 6174 6820 3d20 272f 7379 732f 6673 _path = '/sys/fs\n-000057a0: 2f63 6772 6f75 702f 6370 752f 270a 2020 /cgroup/cpu/'. \n-000057b0: 2020 2020 2020 2020 2020 666f 7220 7061 for pa\n-000057c0: 7468 2c20 5f2c 205f 2c20 726f 6f74 6664 th, _, _, rootfd\n-000057d0: 2069 6e20 6f73 2e66 7761 6c6b 2863 7075 in os.fwalk(cpu\n-000057e0: 5f70 6174 6829 3a0a 2020 2020 2020 2020 _path):. \n-000057f0: 2020 2020 2020 2020 6367 726f 7570 203d cgroup =\n-00005800: 2070 6174 682e 7265 706c 6163 6528 6370 path.replace(cp\n-00005810: 755f 7061 7468 2c20 2727 290a 0a20 2020 u_path, '').. \n-00005820: 2020 2020 2020 2020 2020 2020 2069 6620 if \n-00005830: 6e6f 7420 6367 726f 7570 3a0a 2020 2020 not cgroup:. \n-00005840: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00005850: 636f 6e74 696e 7565 0a0a 2020 2020 2020 continue.. \n-00005860: 2020 2020 2020 2020 2020 7361 6d70 6c65 sample\n-00005870: 735b 2763 6772 6f75 702e 6370 752e 7368 s['cgroup.cpu.sh\n-00005880: 6172 6573 275d 5b63 6772 6f75 705d 203d ares'][cgroup] =\n-00005890: 2072 6561 645f 696e 745f 6669 6c65 2872 read_int_file(r\n-000058a0: 6f6f 7466 642c 2027 6370 752e 7368 6172 ootfd, 'cpu.shar\n-000058b0: 6573 2729 0a20 2020 2020 2020 2020 2020 es'). \n-000058c0: 2020 2020 2075 7361 6765 5f6e 7365 6320 usage_nsec \n-000058d0: 3d20 7265 6164 5f69 6e74 5f66 696c 6528 = read_int_file(\n-000058e0: 726f 6f74 6664 2c20 2763 7075 6163 6374 rootfd, 'cpuacct\n-000058f0: 2e75 7361 6765 2729 0a20 2020 2020 2020 .usage'). \n-00005900: 2020 2020 2020 2020 2069 6620 7573 6167 if usag\n-00005910: 655f 6e73 6563 3a0a 2020 2020 2020 2020 e_nsec:. \n-00005920: 2020 2020 2020 2020 2020 2020 7361 6d70 samp\n-00005930: 6c65 735b 2763 6772 6f75 702e 6370 752e les['cgroup.cpu.\n-00005940: 7573 6167 6527 5d5b 6367 726f 7570 5d20 usage'][cgroup] \n-00005950: 3d20 7573 6167 655f 6e73 6563 202f 2031 = usage_nsec / 1\n-00005960: 3030 3030 3030 0a0a 0a63 6c61 7373 2043 000000...class C\n-00005970: 4772 6f75 7044 6973 6b49 4f28 5361 6d70 GroupDiskIO(Samp\n-00005980: 6c65 7229 3a0a 2020 2020 494f 5f52 4520 ler):. IO_RE \n-00005990: 3d20 7265 2e63 6f6d 7069 6c65 2872 6227 = re.compile(rb'\n-000059a0: 5c62 7265 6164 5f62 7974 6573 3a20 283f \\bread_bytes: (?\n-000059b0: 503c 7265 6164 3e5c 642b 292e 2a5c 6e77 P\\d+).*\\nw\n-000059c0: 7269 7465 5f62 7974 6573 3a20 283f 503c rite_bytes: (?P<\n-000059d0: 7772 6974 653e 5c64 2b29 272c 2066 6c61 write>\\d+)', fla\n-000059e0: 6773 3d72 652e 5329 0a20 2020 2064 6573 gs=re.S). des\n-000059f0: 6372 6970 7469 6f6e 7320 3d20 5b0a 2020 criptions = [. \n-00005a00: 2020 2020 2020 5361 6d70 6c65 4465 7363 SampleDesc\n-00005a10: 7269 7074 696f 6e28 2764 6973 6b2e 6367 ription('disk.cg\n-00005a20: 726f 7570 2e72 6561 6427 2c20 2762 7974 roup.read', 'byt\n-00005a30: 6573 272c 2027 636f 756e 7465 7227 2c20 es', 'counter', \n-00005a40: 696e 7374 616e 6365 643d 5472 7565 292c instanced=True),\n-00005a50: 0a20 2020 2020 2020 2053 616d 706c 6544 . SampleD\n-00005a60: 6573 6372 6970 7469 6f6e 2827 6469 736b escription('disk\n-00005a70: 2e63 6772 6f75 702e 7772 6974 7465 6e27 .cgroup.written'\n-00005a80: 2c20 2762 7974 6573 272c 2027 636f 756e , 'bytes', 'coun\n-00005a90: 7465 7227 2c20 696e 7374 616e 6365 643d ter', instanced=\n-00005aa0: 5472 7565 292c 0a20 2020 205d 0a0a 2020 True),. ].. \n-00005ab0: 2020 4073 7461 7469 636d 6574 686f 640a @staticmethod.\n-00005ac0: 2020 2020 6465 6620 6765 745f 6367 726f def get_cgro\n-00005ad0: 7570 5f6e 616d 6528 6664 3a20 696e 7429 up_name(fd: int)\n-00005ae0: 202d 3e20 7374 723a 0a20 2020 2020 2020 -> str:. \n-00005af0: 2077 6974 6820 4861 6e64 6c65 2e6f 7065 with Handle.ope\n-00005b00: 6e28 2763 6772 6f75 7027 2c20 6f73 2e4f n('cgroup', os.O\n-00005b10: 5f52 444f 4e4c 592c 2064 6972 5f66 643d _RDONLY, dir_fd=\n-00005b20: 6664 2920 6173 2063 6772 6f75 705f 6664 fd) as cgroup_fd\n-00005b30: 3a0a 2020 2020 2020 2020 2020 2020 6367 :. cg\n-00005b40: 726f 7570 5f6e 616d 6520 3d20 6f73 2e72 roup_name = os.r\n-00005b50: 6561 6428 6367 726f 7570 5f66 642c 2032 ead(cgroup_fd, 2\n-00005b60: 3034 3829 2e64 6563 6f64 6528 292e 7374 048).decode().st\n-00005b70: 7269 7028 290a 0a20 2020 2020 2020 2020 rip().. \n-00005b80: 2020 2023 2053 6b69 7020 6c65 6164 696e # Skip leadin\n-00005b90: 6720 3a3a 302f 0a20 2020 2020 2020 2020 g ::0/. \n-00005ba0: 2020 2072 6574 7572 6e20 6367 726f 7570 return cgroup\n-00005bb0: 5f6e 616d 655b 343a 5d0a 0a20 2020 2040 _name[4:].. @\n-00005bc0: 7374 6174 6963 6d65 7468 6f64 0a20 2020 staticmethod. \n-00005bd0: 2064 6566 2067 6574 5f70 726f 635f 696f def get_proc_io\n-00005be0: 2866 643a 2069 6e74 2920 2d3e 2054 7570 (fd: int) -> Tup\n-00005bf0: 6c65 5b69 6e74 2c20 696e 745d 3a0a 2020 le[int, int]:. \n-00005c00: 2020 2020 2020 7769 7468 2048 616e 646c with Handl\n-00005c10: 652e 6f70 656e 2827 696f 272c 206f 732e e.open('io', os.\n-00005c20: 4f5f 5244 4f4e 4c59 2c20 6469 725f 6664 O_RDONLY, dir_fd\n-00005c30: 3d66 6429 2061 7320 696f 5f66 643a 0a20 =fd) as io_fd:. \n-00005c40: 2020 2020 2020 2020 2020 2064 6174 6120 data \n-00005c50: 3d20 6f73 2e72 6561 6428 696f 5f66 642c = os.read(io_fd,\n-00005c60: 2034 3039 3629 0a0a 2020 2020 2020 2020 4096).. \n-00005c70: 2020 2020 6d61 7463 6820 3d20 7265 2e73 match = re.s\n-00005c80: 6561 7263 6828 4347 726f 7570 4469 736b earch(CGroupDisk\n-00005c90: 494f 2e49 4f5f 5245 2c20 6461 7461 290a IO.IO_RE, data).\n-00005ca0: 2020 2020 2020 2020 2020 2020 6966 206d if m\n-00005cb0: 6174 6368 3a0a 2020 2020 2020 2020 2020 atch:. \n-00005cc0: 2020 2020 2020 7072 6f63 5f72 6561 6420 proc_read \n-00005cd0: 3d20 696e 7428 6d61 7463 682e 6772 6f75 = int(match.grou\n-00005ce0: 7028 2772 6561 6427 2929 0a20 2020 2020 p('read')). \n-00005cf0: 2020 2020 2020 2020 2020 2070 726f 635f proc_\n-00005d00: 7772 6974 6520 3d20 696e 7428 6d61 7463 write = int(matc\n-00005d10: 682e 6772 6f75 7028 2777 7269 7465 2729 h.group('write')\n-00005d20: 290a 0a20 2020 2020 2020 2020 2020 2020 ).. \n-00005d30: 2020 2072 6574 7572 6e20 7072 6f63 5f72 return proc_r\n-00005d40: 6561 642c 2070 726f 635f 7772 6974 650a ead, proc_write.\n-00005d50: 0a20 2020 2020 2020 2020 2020 2072 6574 . ret\n-00005d60: 7572 6e20 302c 2030 0a0a 2020 2020 6465 urn 0, 0.. de\n-00005d70: 6620 7361 6d70 6c65 2873 656c 662c 2073 f sample(self, s\n-00005d80: 616d 706c 6573 3a20 5361 6d70 6c65 7329 amples: Samples)\n-00005d90: 3a0a 2020 2020 2020 2020 7769 7468 2048 :. with H\n-00005da0: 616e 646c 652e 6f70 656e 2827 2f70 726f andle.open('/pro\n-00005db0: 6327 2c20 6f73 2e4f 5f52 444f 4e4c 5920 c', os.O_RDONLY \n-00005dc0: 7c20 6f73 2e4f 5f44 4952 4543 544f 5259 | os.O_DIRECTORY\n-00005dd0: 2920 6173 2070 726f 635f 6664 3a0a 2020 ) as proc_fd:. \n-00005de0: 2020 2020 2020 2020 2020 7265 6164 7320 reads \n-00005df0: 3d20 7361 6d70 6c65 735b 2764 6973 6b2e = samples['disk.\n-00005e00: 6367 726f 7570 2e72 6561 6427 5d0a 2020 cgroup.read']. \n-00005e10: 2020 2020 2020 2020 2020 7772 6974 6573 writes\n-00005e20: 203d 2073 616d 706c 6573 5b27 6469 736b = samples['disk\n-00005e30: 2e63 6772 6f75 702e 7772 6974 7465 6e27 .cgroup.written'\n-00005e40: 5d0a 0a20 2020 2020 2020 2020 2020 2066 ].. f\n-00005e50: 6f72 2070 6174 6820 696e 206f 732e 6c69 or path in os.li\n-00005e60: 7374 6469 7228 7072 6f63 5f66 6429 3a0a stdir(proc_fd):.\n-00005e70: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00005e80: 2320 6e6f 6e2d 7069 6420 656e 7472 6965 # non-pid entrie\n-00005e90: 7320 696e 2070 726f 6320 6172 6520 6775 s in proc are gu\n-00005ea0: 6172 616e 7465 6564 2074 6f20 7374 6172 aranteed to star\n-00005eb0: 7420 7769 7468 2061 2063 6861 7261 6374 t with a charact\n-00005ec0: 6572 2061 2d7a 0a20 2020 2020 2020 2020 er a-z. \n-00005ed0: 2020 2020 2020 2069 6620 7061 7468 5b30 if path[0\n-00005ee0: 5d20 3c20 2730 2720 6f72 2070 6174 685b ] < '0' or path[\n-00005ef0: 305d 203e 2027 3927 3a0a 2020 2020 2020 0] > '9':. \n-00005f00: 2020 2020 2020 2020 2020 2020 2020 636f co\n-00005f10: 6e74 696e 7565 0a0a 2020 2020 2020 2020 ntinue.. \n-00005f20: 2020 2020 2020 2020 7472 793a 0a20 2020 try:. \n-00005f30: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00005f40: 2077 6974 6820 4861 6e64 6c65 2e6f 7065 with Handle.ope\n-00005f50: 6e28 7061 7468 2c20 6f73 2e4f 5f50 4154 n(path, os.O_PAT\n-00005f60: 482c 2064 6972 5f66 643d 7072 6f63 5f66 H, dir_fd=proc_f\n-00005f70: 6429 2061 7320 7069 645f 6664 3a0a 2020 d) as pid_fd:. \n-00005f80: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00005f90: 2020 2020 2020 6367 726f 7570 5f6e 616d cgroup_nam\n-00005fa0: 6520 3d20 7365 6c66 2e67 6574 5f63 6772 e = self.get_cgr\n-00005fb0: 6f75 705f 6e61 6d65 2870 6964 5f66 6429 oup_name(pid_fd)\n-00005fc0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-00005fd0: 2020 2020 2020 2020 2070 726f 635f 7265 proc_re\n-00005fe0: 6164 2c20 7072 6f63 5f77 7269 7465 203d ad, proc_write =\n-00005ff0: 2073 656c 662e 6765 745f 7072 6f63 5f69 self.get_proc_i\n-00006000: 6f28 7069 645f 6664 290a 2020 2020 2020 o(pid_fd). \n-00006010: 2020 2020 2020 2020 2020 6578 6365 7074 except\n-00006020: 2028 4669 6c65 4e6f 7446 6f75 6e64 4572 (FileNotFoundEr\n-00006030: 726f 722c 2050 6572 6d69 7373 696f 6e45 ror, PermissionE\n-00006040: 7272 6f72 2c20 5072 6f63 6573 734c 6f6f rror, ProcessLoo\n-00006050: 6b75 7045 7272 6f72 293a 0a20 2020 2020 kupError):. \n-00006060: 2020 2020 2020 2020 2020 2020 2020 2063 c\n-00006070: 6f6e 7469 6e75 650a 0a20 2020 2020 2020 ontinue.. \n-00006080: 2020 2020 2020 2020 2072 6561 6473 5b63 reads[c\n-00006090: 6772 6f75 705f 6e61 6d65 5d20 3d20 7265 group_name] = re\n-000060a0: 6164 732e 6765 7428 6367 726f 7570 5f6e ads.get(cgroup_n\n-000060b0: 616d 652c 2030 2920 2b20 7072 6f63 5f72 ame, 0) + proc_r\n-000060c0: 6561 640a 2020 2020 2020 2020 2020 2020 ead. \n-000060d0: 2020 2020 7772 6974 6573 5b63 6772 6f75 writes[cgrou\n-000060e0: 705f 6e61 6d65 5d20 3d20 7772 6974 6573 p_name] = writes\n-000060f0: 2e67 6574 2863 6772 6f75 705f 6e61 6d65 .get(cgroup_name\n-00006100: 2c20 3029 202b 2070 726f 635f 7772 6974 , 0) + proc_writ\n-00006110: 650a 0a0a 636c 6173 7320 4e65 7477 6f72 e...class Networ\n-00006120: 6b53 616d 706c 6572 2853 616d 706c 6572 kSampler(Sampler\n-00006130: 293a 0a20 2020 2064 6573 6372 6970 7469 ):. descripti\n-00006140: 6f6e 7320 3d20 5b0a 2020 2020 2020 2020 ons = [. \n-00006150: 5361 6d70 6c65 4465 7363 7269 7074 696f SampleDescriptio\n-00006160: 6e28 276e 6574 776f 726b 2e69 6e74 6572 n('network.inter\n-00006170: 6661 6365 2e74 7827 2c20 2762 7974 6573 face.tx', 'bytes\n-00006180: 272c 2027 636f 756e 7465 7227 2c20 696e ', 'counter', in\n-00006190: 7374 616e 6365 643d 5472 7565 292c 0a20 stanced=True),. \n-000061a0: 2020 2020 2020 2053 616d 706c 6544 6573 SampleDes\n-000061b0: 6372 6970 7469 6f6e 2827 6e65 7477 6f72 cription('networ\n-000061c0: 6b2e 696e 7465 7266 6163 652e 7278 272c k.interface.rx',\n-000061d0: 2027 6279 7465 7327 2c20 2763 6f75 6e74 'bytes', 'count\n-000061e0: 6572 272c 2069 6e73 7461 6e63 6564 3d54 er', instanced=T\n-000061f0: 7275 6529 2c0a 2020 2020 5d0a 0a20 2020 rue),. ].. \n-00006200: 2064 6566 2073 616d 706c 6528 7365 6c66 def sample(self\n-00006210: 2c20 7361 6d70 6c65 733a 2053 616d 706c , samples: Sampl\n-00006220: 6573 2920 2d3e 204e 6f6e 653a 0a20 2020 es) -> None:. \n-00006230: 2020 2020 2077 6974 6820 6f70 656e 2822 with open(\"\n-00006240: 2f70 726f 632f 6e65 742f 6465 7622 2920 /proc/net/dev\") \n-00006250: 6173 206e 6574 776f 726b 5f73 616d 706c as network_sampl\n-00006260: 6573 3a0a 2020 2020 2020 2020 2020 2020 es:. \n-00006270: 666f 7220 6c69 6e65 2069 6e20 6e65 7477 for line in netw\n-00006280: 6f72 6b5f 7361 6d70 6c65 733a 0a20 2020 ork_samples:. \n-00006290: 2020 2020 2020 2020 2020 2020 2066 6965 fie\n-000062a0: 6c64 7320 3d20 6c69 6e65 2e73 706c 6974 lds = line.split\n-000062b0: 2829 0a0a 2020 2020 2020 2020 2020 2020 ().. \n-000062c0: 2020 2020 2320 536b 6970 2068 6561 6465 # Skip heade\n-000062d0: 7220 6c69 6e65 0a20 2020 2020 2020 2020 r line. \n-000062e0: 2020 2020 2020 2069 6620 6669 656c 6473 if fields\n-000062f0: 5b30 5d5b 2d31 5d20 213d 2027 3a27 3a0a [0][-1] != ':':.\n-00006300: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00006310: 2020 2020 636f 6e74 696e 7565 0a0a 2020 continue.. \n-00006320: 2020 2020 2020 2020 2020 2020 2020 6966 if\n-00006330: 6163 6520 3d20 6669 656c 6473 5b30 5d5b ace = fields[0][\n-00006340: 3a2d 315d 0a20 2020 2020 2020 2020 2020 :-1]. \n-00006350: 2020 2020 2073 616d 706c 6573 5b27 6e65 samples['ne\n-00006360: 7477 6f72 6b2e 696e 7465 7266 6163 652e twork.interface.\n-00006370: 7278 275d 5b69 6661 6365 5d20 3d20 696e rx'][iface] = in\n-00006380: 7428 6669 656c 6473 5b31 5d29 0a20 2020 t(fields[1]). \n-00006390: 2020 2020 2020 2020 2020 2020 2073 616d sam\n-000063a0: 706c 6573 5b27 6e65 7477 6f72 6b2e 696e ples['network.in\n-000063b0: 7465 7266 6163 652e 7478 275d 5b69 6661 terface.tx'][ifa\n-000063c0: 6365 5d20 3d20 696e 7428 6669 656c 6473 ce] = int(fields\n-000063d0: 5b39 5d29 0a0a 0a63 6c61 7373 204d 6f75 [9])...class Mou\n-000063e0: 6e74 5361 6d70 6c65 7228 5361 6d70 6c65 ntSampler(Sample\n-000063f0: 7229 3a0a 2020 2020 6465 7363 7269 7074 r):. descript\n-00006400: 696f 6e73 203d 205b 0a20 2020 2020 2020 ions = [. \n-00006410: 2053 616d 706c 6544 6573 6372 6970 7469 SampleDescripti\n-00006420: 6f6e 2827 6d6f 756e 742e 746f 7461 6c27 on('mount.total'\n-00006430: 2c20 2762 7974 6573 272c 2027 696e 7374 , 'bytes', 'inst\n-00006440: 616e 7427 2c20 696e 7374 616e 6365 643d ant', instanced=\n-00006450: 5472 7565 292c 0a20 2020 2020 2020 2053 True),. S\n-00006460: 616d 706c 6544 6573 6372 6970 7469 6f6e ampleDescription\n-00006470: 2827 6d6f 756e 742e 7573 6564 272c 2027 ('mount.used', '\n-00006480: 6279 7465 7327 2c20 2769 6e73 7461 6e74 bytes', 'instant\n-00006490: 272c 2069 6e73 7461 6e63 6564 3d54 7275 ', instanced=Tru\n-000064a0: 6529 2c0a 2020 2020 5d0a 0a20 2020 2064 e),. ].. d\n-000064b0: 6566 2073 616d 706c 6528 7365 6c66 2c20 ef sample(self, \n-000064c0: 7361 6d70 6c65 733a 2053 616d 706c 6573 samples: Samples\n-000064d0: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n-000064e0: 2020 2077 6974 6820 6f70 656e 2827 2f70 with open('/p\n-000064f0: 726f 632f 6d6f 756e 7473 2729 2061 7320 roc/mounts') as \n-00006500: 6d6f 756e 7473 3a0a 2020 2020 2020 2020 mounts:. \n-00006510: 2020 2020 666f 7220 6c69 6e65 2069 6e20 for line in \n-00006520: 6d6f 756e 7473 3a0a 2020 2020 2020 2020 mounts:. \n-00006530: 2020 2020 2020 2020 2320 4f6e 6c79 206c # Only l\n-00006540: 6f6f 6b20 6174 2072 6561 6c20 6465 7669 ook at real devi\n-00006550: 6365 730a 2020 2020 2020 2020 2020 2020 ces. \n-00006560: 2020 2020 6966 206c 696e 655b 305d 2021 if line[0] !\n-00006570: 3d20 272f 273a 0a20 2020 2020 2020 2020 = '/':. \n-00006580: 2020 2020 2020 2020 2020 2063 6f6e 7469 conti\n-00006590: 6e75 650a 0a20 2020 2020 2020 2020 2020 nue.. \n-000065a0: 2020 2020 2070 6174 6820 3d20 6c69 6e65 path = line\n-000065b0: 2e73 706c 6974 2829 5b31 5d0a 2020 2020 .split()[1]. \n-000065c0: 2020 2020 2020 2020 2020 2020 7472 793a try:\n-000065d0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-000065e0: 2020 2020 2072 6573 203d 206f 732e 7374 res = os.st\n-000065f0: 6174 7666 7328 7061 7468 290a 2020 2020 atvfs(path). \n-00006600: 2020 2020 2020 2020 2020 2020 6578 6365 exce\n-00006610: 7074 204f 5345 7272 6f72 3a0a 2020 2020 pt OSError:. \n-00006620: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00006630: 636f 6e74 696e 7565 0a20 2020 2020 2020 continue. \n-00006640: 2020 2020 2020 2020 2066 7273 697a 6520 frsize \n-00006650: 3d20 7265 732e 665f 6672 7369 7a65 0a20 = res.f_frsize. \n-00006660: 2020 2020 2020 2020 2020 2020 2020 2074 t\n-00006670: 6f74 616c 203d 2066 7273 697a 6520 2a20 otal = frsize * \n-00006680: 7265 732e 665f 626c 6f63 6b73 0a20 2020 res.f_blocks. \n-00006690: 2020 2020 2020 2020 2020 2020 2073 616d sam\n-000066a0: 706c 6573 5b27 6d6f 756e 742e 746f 7461 ples['mount.tota\n-000066b0: 6c27 5d5b 7061 7468 5d20 3d20 746f 7461 l'][path] = tota\n-000066c0: 6c0a 2020 2020 2020 2020 2020 2020 2020 l. \n-000066d0: 2020 7361 6d70 6c65 735b 276d 6f75 6e74 samples['mount\n-000066e0: 2e75 7365 6427 5d5b 7061 7468 5d20 3d20 .used'][path] = \n-000066f0: 746f 7461 6c20 2d20 6672 7369 7a65 202a total - frsize *\n-00006700: 2072 6573 2e66 5f62 6672 6565 0a0a 0a63 res.f_bfree...c\n-00006710: 6c61 7373 2042 6c6f 636b 5361 6d70 6c65 lass BlockSample\n-00006720: 7228 5361 6d70 6c65 7229 3a0a 2020 2020 r(Sampler):. \n-00006730: 6465 7363 7269 7074 696f 6e73 203d 205b descriptions = [\n-00006740: 0a20 2020 2020 2020 2053 616d 706c 6544 . SampleD\n-00006750: 6573 6372 6970 7469 6f6e 2827 626c 6f63 escription('bloc\n-00006760: 6b2e 6465 7669 6365 2e72 6561 6427 2c20 k.device.read', \n-00006770: 2762 7974 6573 272c 2027 636f 756e 7465 'bytes', 'counte\n-00006780: 7227 2c20 696e 7374 616e 6365 643d 5472 r', instanced=Tr\n-00006790: 7565 292c 0a20 2020 2020 2020 2053 616d ue),. Sam\n-000067a0: 706c 6544 6573 6372 6970 7469 6f6e 2827 pleDescription('\n-000067b0: 626c 6f63 6b2e 6465 7669 6365 2e77 7269 block.device.wri\n-000067c0: 7474 656e 272c 2027 6279 7465 7327 2c20 tten', 'bytes', \n-000067d0: 2763 6f75 6e74 6572 272c 2069 6e73 7461 'counter', insta\n-000067e0: 6e63 6564 3d54 7275 6529 2c0a 2020 2020 nced=True),. \n-000067f0: 5d0a 0a20 2020 2064 6566 2073 616d 706c ].. def sampl\n-00006800: 6528 7365 6c66 2c20 7361 6d70 6c65 733a e(self, samples:\n-00006810: 2053 616d 706c 6573 2920 2d3e 204e 6f6e Samples) -> Non\n-00006820: 653a 0a20 2020 2020 2020 2077 6974 6820 e:. with \n-00006830: 6f70 656e 2827 2f70 726f 632f 6469 736b open('/proc/disk\n-00006840: 7374 6174 7327 2920 6173 2064 6973 6b73 stats') as disks\n-00006850: 7461 7473 3a0a 2020 2020 2020 2020 2020 tats:. \n-00006860: 2020 666f 7220 6c69 6e65 2069 6e20 6469 for line in di\n-00006870: 736b 7374 6174 733a 0a20 2020 2020 2020 skstats:. \n-00006880: 2020 2020 2020 2020 2023 2068 7474 7073 # https\n-00006890: 3a2f 2f77 7777 2e6b 6572 6e65 6c2e 6f72 ://www.kernel.or\n-000068a0: 672f 646f 632f 446f 6375 6d65 6e74 6174 g/doc/Documentat\n-000068b0: 696f 6e2f 4142 492f 7465 7374 696e 672f ion/ABI/testing/\n-000068c0: 7072 6f63 6673 2d64 6973 6b73 7461 7473 procfs-diskstats\n-000068d0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-000068e0: 205b 5f2c 205f 2c20 6465 765f 6e61 6d65 [_, _, dev_name\n-000068f0: 2c20 5f2c 205f 2c20 7365 6374 6f72 735f , _, _, sectors_\n-00006900: 7265 6164 2c20 5f2c 205f 2c20 5f2c 2073 read, _, _, _, s\n-00006910: 6563 746f 7273 5f77 7269 7474 656e 2c20 ectors_written, \n-00006920: 2a5f 5d20 3d20 6c69 6e65 2e73 7472 6970 *_] = line.strip\n-00006930: 2829 2e73 706c 6974 2829 0a0a 2020 2020 ().split().. \n-00006940: 2020 2020 2020 2020 2020 2020 7361 6d70 samp\n-00006950: 6c65 735b 2762 6c6f 636b 2e64 6576 6963 les['block.devic\n-00006960: 652e 7265 6164 275d 5b64 6576 5f6e 616d e.read'][dev_nam\n-00006970: 655d 203d 2069 6e74 2873 6563 746f 7273 e] = int(sectors\n-00006980: 5f72 6561 6429 202a 2035 3132 0a20 2020 _read) * 512. \n-00006990: 2020 2020 2020 2020 2020 2020 2073 616d sam\n-000069a0: 706c 6573 5b27 626c 6f63 6b2e 6465 7669 ples['block.devi\n-000069b0: 6365 2e77 7269 7474 656e 275d 5b64 6576 ce.written'][dev\n-000069c0: 5f6e 616d 655d 203d 2069 6e74 2873 6563 _name] = int(sec\n-000069d0: 746f 7273 5f77 7269 7474 656e 2920 2a20 tors_written) * \n-000069e0: 3531 320a 0a0a 5341 4d50 4c45 5253 203d 512...SAMPLERS =\n-000069f0: 205b 0a20 2020 2042 6c6f 636b 5361 6d70 [. BlockSamp\n-00006a00: 6c65 722c 0a20 2020 2043 4772 6f75 7053 ler,. CGroupS\n-00006a10: 616d 706c 6572 2c0a 2020 2020 4347 726f ampler,. CGro\n-00006a20: 7570 4469 736b 494f 2c0a 2020 2020 4350 upDiskIO,. CP\n-00006a30: 5553 616d 706c 6572 2c0a 2020 2020 4350 USampler,. CP\n-00006a40: 5554 656d 7065 7261 7475 7265 5361 6d70 UTemperatureSamp\n-00006a50: 6c65 722c 0a20 2020 2044 6973 6b53 616d ler,. DiskSam\n-00006a60: 706c 6572 2c0a 2020 2020 4d65 6d6f 7279 pler,. Memory\n-00006a70: 5361 6d70 6c65 722c 0a20 2020 204d 6f75 Sampler,. Mou\n-00006a80: 6e74 5361 6d70 6c65 722c 0a20 2020 204e ntSampler,. N\n-00006a90: 6574 776f 726b 5361 6d70 6c65 722c 0a5d etworkSampler,.]\n-00006aa0: 0a27 2727 2c0a 2020 2763 6f63 6b70 6974 .''',. 'cockpit\n-00006ab0: 2f70 6f6c 6b69 742e 7079 273a 2072 2727 /polkit.py': r''\n-00006ac0: 2723 2054 6869 7320 6669 6c65 2069 7320 '# This file is \n-00006ad0: 7061 7274 206f 6620 436f 636b 7069 742e part of Cockpit.\n-00006ae0: 0a23 0a23 2043 6f70 7972 6967 6874 2028 .#.# Copyright (\n-00006af0: 4329 2032 3032 3320 5265 6420 4861 742c C) 2023 Red Hat,\n-00006b00: 2049 6e63 2e0a 230a 2320 5468 6973 2070 Inc..#.# This p\n-00006b10: 726f 6772 616d 2069 7320 6672 6565 2073 rogram is free s\n-00006b20: 6f66 7477 6172 653a 2079 6f75 2063 616e oftware: you can\n-00006b30: 2072 6564 6973 7472 6962 7574 6520 6974 redistribute it\n-00006b40: 2061 6e64 2f6f 7220 6d6f 6469 6679 0a23 and/or modify.#\n-00006b50: 2069 7420 756e 6465 7220 7468 6520 7465 it under the te\n-00006b60: 726d 7320 6f66 2074 6865 2047 4e55 2047 rms of the GNU G\n-00006b70: 656e 6572 616c 2050 7562 6c69 6320 4c69 eneral Public Li\n-00006b80: 6365 6e73 6520 6173 2070 7562 6c69 7368 cense as publish\n-00006b90: 6564 2062 790a 2320 7468 6520 4672 6565 ed by.# the Free\n-00006ba0: 2053 6f66 7477 6172 6520 466f 756e 6461 Software Founda\n-00006bb0: 7469 6f6e 2c20 6569 7468 6572 2076 6572 tion, either ver\n-00006bc0: 7369 6f6e 2033 206f 6620 7468 6520 4c69 sion 3 of the Li\n-00006bd0: 6365 6e73 652c 206f 720a 2320 2861 7420 cense, or.# (at \n-00006be0: 796f 7572 206f 7074 696f 6e29 2061 6e79 your option) any\n-00006bf0: 206c 6174 6572 2076 6572 7369 6f6e 2e0a later version..\n-00006c00: 230a 2320 5468 6973 2070 726f 6772 616d #.# This program\n-00006c10: 2069 7320 6469 7374 7269 6275 7465 6420 is distributed \n-00006c20: 696e 2074 6865 2068 6f70 6520 7468 6174 in the hope that\n-00006c30: 2069 7420 7769 6c6c 2062 6520 7573 6566 it will be usef\n-00006c40: 756c 2c0a 2320 6275 7420 5749 5448 4f55 ul,.# but WITHOU\n-00006c50: 5420 414e 5920 5741 5252 414e 5459 3b20 T ANY WARRANTY; \n-00006c60: 7769 7468 6f75 7420 6576 656e 2074 6865 without even the\n-00006c70: 2069 6d70 6c69 6564 2077 6172 7261 6e74 implied warrant\n-00006c80: 7920 6f66 0a23 204d 4552 4348 414e 5441 y of.# MERCHANTA\n-00006c90: 4249 4c49 5459 206f 7220 4649 544e 4553 BILITY or FITNES\n-00006ca0: 5320 464f 5220 4120 5041 5254 4943 554c S FOR A PARTICUL\n-00006cb0: 4152 2050 5552 504f 5345 2e20 2053 6565 AR PURPOSE. See\n-00006cc0: 2074 6865 0a23 2047 4e55 2047 656e 6572 the.# GNU Gener\n-00006cd0: 616c 2050 7562 6c69 6320 4c69 6365 6e73 al Public Licens\n-00006ce0: 6520 666f 7220 6d6f 7265 2064 6574 6169 e for more detai\n-00006cf0: 6c73 2e0a 230a 2320 596f 7520 7368 6f75 ls..#.# You shou\n-00006d00: 6c64 2068 6176 6520 7265 6365 6976 6564 ld have received\n-00006d10: 2061 2063 6f70 7920 6f66 2074 6865 2047 a copy of the G\n-00006d20: 4e55 2047 656e 6572 616c 2050 7562 6c69 NU General Publi\n-00006d30: 6320 4c69 6365 6e73 650a 2320 616c 6f6e c License.# alon\n-00006d40: 6720 7769 7468 2074 6869 7320 7072 6f67 g with this prog\n-00006d50: 7261 6d2e 2020 4966 206e 6f74 2c20 7365 ram. If not, se\n-00006d60: 6520 3c68 7474 7073 3a2f 2f77 7777 2e67 e ...import async\n-00006d90: 696f 0a69 6d70 6f72 7420 6c6f 6361 6c65 io.import locale\n-00006da0: 0a69 6d70 6f72 7420 6c6f 6767 696e 670a .import logging.\n-00006db0: 696d 706f 7274 206f 730a 696d 706f 7274 import os.import\n-00006dc0: 2070 7764 0a66 726f 6d20 7479 7069 6e67 pwd.from typing\n-00006dd0: 2069 6d70 6f72 7420 4469 6374 2c20 4c69 import Dict, Li\n-00006de0: 7374 2c20 5365 7175 656e 6365 2c20 5475 st, Sequence, Tu\n-00006df0: 706c 650a 0a66 726f 6d20 636f 636b 7069 ple..from cockpi\n-00006e00: 742e 5f76 656e 646f 722e 6665 726e 7920 t._vendor.ferny \n-00006e10: 696d 706f 7274 2041 736b 7061 7373 4861 import AskpassHa\n-00006e20: 6e64 6c65 720a 6672 6f6d 2063 6f63 6b70 ndler.from cockp\n-00006e30: 6974 2e5f 7665 6e64 6f72 2e73 7973 7465 it._vendor.syste\n-00006e40: 6d64 5f63 7479 7065 7320 696d 706f 7274 md_ctypes import\n-00006e50: 2056 6172 6961 6e74 2c20 6275 730a 0a23 Variant, bus..#\n-00006e60: 2074 6861 7420 7061 7468 2069 7320 7661 that path is va\n-00006e70: 6c69 6420 6f6e 2061 7420 6c65 6173 7420 lid on at least \n-00006e80: 4465 6269 616e 2c20 4665 646f 7261 2f52 Debian, Fedora/R\n-00006e90: 4845 4c2c 2061 6e64 2041 7263 680a 4845 HEL, and Arch.HE\n-00006ea0: 4c50 4552 5f50 4154 4820 3d20 272f 7573 LPER_PATH = '/us\n-00006eb0: 722f 6c69 622f 706f 6c6b 6974 2d31 2f70 r/lib/polkit-1/p\n-00006ec0: 6f6c 6b69 742d 6167 656e 742d 6865 6c70 olkit-agent-help\n-00006ed0: 6572 2d31 270a 0a41 4745 4e54 5f44 4255 er-1'..AGENT_DBU\n-00006ee0: 535f 5041 5448 203d 2027 2f50 6f6c 6b69 S_PATH = '/Polki\n-00006ef0: 7441 6765 6e74 270a 0a6c 6f67 6765 7220 tAgent'..logger \n-00006f00: 3d20 6c6f 6767 696e 672e 6765 744c 6f67 = logging.getLog\n-00006f10: 6765 7228 5f5f 6e61 6d65 5f5f 290a 0a49 ger(__name__)..I\n-00006f20: 6465 6e74 6974 7920 3d20 5475 706c 655b dentity = Tuple[\n-00006f30: 7374 722c 2044 6963 745b 7374 722c 2056 str, Dict[str, V\n-00006f40: 6172 6961 6e74 5d5d 0a0a 0a23 2068 7474 ariant]]...# htt\n-00006f50: 7073 3a2f 2f77 7777 2e66 7265 6564 6573 ps://www.freedes\n-00006f60: 6b74 6f70 2e6f 7267 2f73 6f66 7477 6172 ktop.org/softwar\n-00006f70: 652f 706f 6c6b 6974 2f64 6f63 732f 6c61 e/polkit/docs/la\n-00006f80: 7465 7374 2f65 6767 6462 7573 2d69 6e74 test/eggdbus-int\n-00006f90: 6572 6661 6365 2d6f 7267 2e66 7265 6564 erface-org.freed\n-00006fa0: 6573 6b74 6f70 2e50 6f6c 6963 794b 6974 esktop.PolicyKit\n-00006fb0: 312e 4175 7468 656e 7469 6361 7469 6f6e 1.Authentication\n-00006fc0: 4167 656e 742e 6874 6d6c 0a0a 2320 4e6f Agent.html..# No\n-00006fd0: 7465 2074 6861 7420 7765 2064 6f6e 2774 te that we don't\n-00006fe0: 2069 6d70 6c65 6d65 6e74 2074 6865 2043 implement the C\n-00006ff0: 616e 6365 6c41 7574 6865 6e74 6963 6174 ancelAuthenticat\n-00007000: 696f 6e28 2920 4150 492e 2070 6b65 7865 ion() API. pkexe\n-00007010: 6320 6765 7473 2063 616c 6c65 6420 696e c gets called in\n-00007020: 2061 2077 6179 2074 6861 7420 6861 7320 a way that has \n-00007030: 6e6f 206f 7070 6f72 7475 6e69 7479 2074 no opportunity t\n-00007040: 6f0a 2320 6361 6e63 656c 2061 6e20 6f6e o.# cancel an on\n-00007050: 676f 696e 6720 6175 7468 656e 7469 6361 going authentica\n-00007060: 7469 6f6e 2066 726f 6d20 7468 6520 706b tion from the pk\n-00007070: 6578 6563 2073 6964 652e 204f 6e20 7468 exec side. On th\n-00007080: 6520 5549 2073 6964 6520 6361 6e63 656c e UI side cancel\n-00007090: 6c61 7469 6f6e 2069 7320 696d 706c 656d lation is implem\n-000070a0: 656e 7465 6420 7669 6120 7468 6520 7374 ented via the st\n-000070b0: 616e 6461 7264 0a23 2061 7379 6e63 696f andard.# asyncio\n-000070c0: 2070 726f 6365 7373 206d 6563 6861 6e69 process mechani\n-000070d0: 736d 2e20 4966 2077 6520 6576 6572 206e sm. If we ever n\n-000070e0: 6565 6420 4361 6e63 656c 4175 7468 656e eed CancelAuthen\n-000070f0: 7469 6361 7469 6f6e 2829 2c20 7765 2063 tication(), we c\n-00007100: 6f75 6c64 206b 6565 7020 6120 636f 6f6b ould keep a cook\n-00007110: 6965 20e2 8692 2067 6574 5f63 7572 7265 ie ... get_curre\n-00007120: 6e74 5f74 6173 6b28 290a 2320 6d61 7070 nt_task().# mapp\n-00007130: 696e 672c 2062 7574 2074 6861 7420 6d65 ing, but that me\n-00007140: 7468 6f64 2069 7320 6e6f 7420 6176 6169 thod is not avai\n-00007150: 6c61 626c 6520 666f 7220 5079 7468 6f6e lable for Python\n-00007160: 2033 2e36 2079 6574 2e0a 0a63 6c61 7373 3.6 yet...class\n-00007170: 206f 7267 5f66 7265 6564 6573 6b74 6f70 org_freedesktop\n-00007180: 5f50 6f6c 6963 794b 6974 315f 4175 7468 _PolicyKit1_Auth\n-00007190: 656e 7469 6361 7469 6f6e 4167 656e 7428 enticationAgent(\n-000071a0: 6275 732e 4f62 6a65 6374 293a 0a20 2020 bus.Object):. \n-000071b0: 2064 6566 205f 5f69 6e69 745f 5f28 7365 def __init__(se\n-000071c0: 6c66 2c20 7265 7370 6f6e 6465 723a 2041 lf, responder: A\n-000071d0: 736b 7061 7373 4861 6e64 6c65 7229 3a0a skpassHandler):.\n-000071e0: 2020 2020 2020 2020 7375 7065 7228 292e super().\n-000071f0: 5f5f 696e 6974 5f5f 2829 0a20 2020 2020 __init__(). \n-00007200: 2020 2073 656c 662e 7265 7370 6f6e 6465 self.responde\n-00007210: 7220 3d20 7265 7370 6f6e 6465 720a 0a20 r = responder.. \n-00007220: 2020 2023 2063 6f6e 6675 7369 6e67 6c79 # confusingly\n-00007230: 206e 616d 6564 3a20 7468 6973 2061 6374 named: this act\n-00007240: 7561 6c6c 7920 646f 6573 2074 6865 2077 ually does the w\n-00007250: 686f 6c65 2061 7574 6865 6e74 6963 6174 hole authenticat\n-00007260: 696f 6e20 6469 616c 6f67 2c20 7365 6520 ion dialog, see \n-00007270: 646f 6373 0a20 2020 2040 6275 732e 496e docs. @bus.In\n-00007280: 7465 7266 6163 652e 4d65 7468 6f64 2827 terface.Method('\n-00007290: 272c 205b 2773 272c 2027 7327 2c20 2773 ', ['s', 's', 's\n-000072a0: 272c 2027 617b 7373 7d27 2c20 2773 272c ', 'a{ss}', 's',\n-000072b0: 2027 6128 7361 7b73 767d 2927 5d29 0a20 'a(sa{sv})']). \n-000072c0: 2020 2061 7379 6e63 2064 6566 2062 6567 async def beg\n-000072d0: 696e 5f61 7574 6865 6e74 6963 6174 696f in_authenticatio\n-000072e0: 6e28 7365 6c66 2c20 6163 7469 6f6e 5f69 n(self, action_i\n-000072f0: 643a 2073 7472 2c20 6d65 7373 6167 653a d: str, message:\n-00007300: 2073 7472 2c20 6963 6f6e 5f6e 616d 653a str, icon_name:\n-00007310: 2073 7472 2c0a 2020 2020 2020 2020 2020 str,. \n-00007320: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00007330: 2020 2020 2020 2020 2064 6574 6169 6c73 details\n-00007340: 3a20 4469 6374 5b73 7472 2c20 7374 725d : Dict[str, str]\n-00007350: 2c20 636f 6f6b 6965 3a20 7374 722c 2069 , cookie: str, i\n-00007360: 6465 6e74 6974 6965 733a 2053 6571 7565 dentities: Seque\n-00007370: 6e63 655b 4964 656e 7469 7479 5d29 202d nce[Identity]) -\n-00007380: 3e20 4e6f 6e65 3a0a 2020 2020 2020 2020 > None:. \n-00007390: 6c6f 6767 6572 2e64 6562 7567 2827 4265 logger.debug('Be\n-000073a0: 6769 6e41 7574 6865 6e74 6963 6174 696f ginAuthenticatio\n-000073b0: 6e3a 2061 6374 696f 6e20 2573 2c20 6d65 n: action %s, me\n-000073c0: 7373 6167 6520 2225 7322 2c20 6963 6f6e ssage \"%s\", icon\n-000073d0: 2025 732c 2064 6574 6169 6c73 2025 732c %s, details %s,\n-000073e0: 2063 6f6f 6b69 6520 2573 2c20 6964 656e cookie %s, iden\n-000073f0: 7469 7469 6573 2025 7227 2c0a 2020 2020 tities %r',. \n-00007400: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00007410: 2061 6374 696f 6e5f 6964 2c20 6d65 7373 action_id, mess\n-00007420: 6167 652c 2069 636f 6e5f 6e61 6d65 2c20 age, icon_name, \n-00007430: 6465 7461 696c 732c 2063 6f6f 6b69 652c details, cookie,\n-00007440: 2069 6465 6e74 6974 6965 7329 0a20 2020 identities). \n-00007450: 2020 2020 2023 206f 6e6c 7920 7375 7070 # only supp\n-00007460: 6f72 7420 6175 7468 656e 7469 6361 7469 ort authenticati\n-00007470: 6f6e 2061 7320 6f75 7273 656c 7665 732c on as ourselves,\n-00007480: 2061 7320 7765 2064 6f6e 2774 2079 6574 as we don't yet\n-00007490: 2068 6176 6520 7468 650a 2020 2020 2020 have the. \n-000074a0: 2020 2320 7072 6f74 6f63 6f6c 2070 6c75 # protocol plu\n-000074b0: 6d62 696e 6720 616e 6420 5549 2074 6f20 mbing and UI to \n-000074c0: 7365 6c65 6374 2061 6e20 6164 6d69 6e20 select an admin \n-000074d0: 7573 6572 0a20 2020 2020 2020 206d 795f user. my_\n-000074e0: 7569 6420 3d20 6f73 2e67 6574 6575 6964 uid = os.geteuid\n-000074f0: 2829 0a20 2020 2020 2020 2066 6f72 2028 (). for (\n-00007500: 6175 7468 5f74 7970 652c 2073 7562 6a65 auth_type, subje\n-00007510: 6374 2920 696e 2069 6465 6e74 6974 6965 ct) in identitie\n-00007520: 733a 0a20 2020 2020 2020 2020 2020 2069 s:. i\n-00007530: 6620 6175 7468 5f74 7970 6520 3d3d 2027 f auth_type == '\n-00007540: 756e 6978 2d75 7365 7227 2061 6e64 2027 unix-user' and '\n-00007550: 7569 6427 2069 6e20 7375 626a 6563 7420 uid' in subject \n-00007560: 616e 6420 7375 626a 6563 745b 2775 6964 and subject['uid\n-00007570: 275d 2e76 616c 7565 203d 3d20 6d79 5f75 '].value == my_u\n-00007580: 6964 3a0a 2020 2020 2020 2020 2020 2020 id:. \n-00007590: 2020 2020 6c6f 6767 6572 2e64 6562 7567 logger.debug\n-000075a0: 2827 4175 7468 656e 7469 6361 7469 6f6e ('Authentication\n-000075b0: 2073 7562 6a65 6374 2025 7320 6d61 7463 subject %s matc\n-000075c0: 6865 7320 6f75 7220 7569 6420 2564 272c hes our uid %d',\n-000075d0: 2073 7562 6a65 6374 2c20 6d79 5f75 6964 subject, my_uid\n-000075e0: 290a 2020 2020 2020 2020 2020 2020 2020 ). \n-000075f0: 2020 6272 6561 6b0a 2020 2020 2020 2020 break. \n-00007600: 656c 7365 3a0a 2020 2020 2020 2020 2020 else:. \n-00007610: 2020 6c6f 6767 6572 2e77 6172 6e69 6e67 logger.warning\n-00007620: 2827 4e6f 7420 7375 7070 6f72 7469 6e67 ('Not supporting\n-00007630: 2061 7574 6865 6e74 6963 6174 696f 6e20 authentication \n-00007640: 6173 2061 6e79 206f 6620 2573 272c 2069 as any of %s', i\n-00007650: 6465 6e74 6974 6965 7329 0a20 2020 2020 dentities). \n-00007660: 2020 2020 2020 2072 6574 7572 6e0a 0a20 return.. \n-00007670: 2020 2020 2020 2075 7365 725f 6e61 6d65 user_name\n-00007680: 203d 2070 7764 2e67 6574 7077 7569 6428 = pwd.getpwuid(\n-00007690: 6d79 5f75 6964 292e 7077 5f6e 616d 650a my_uid).pw_name.\n-000076a0: 2020 2020 2020 2020 7072 6f63 6573 7320 process \n-000076b0: 3d20 6177 6169 7420 6173 796e 6369 6f2e = await asyncio.\n-000076c0: 6372 6561 7465 5f73 7562 7072 6f63 6573 create_subproces\n-000076d0: 735f 6578 6563 2848 454c 5045 525f 5041 s_exec(HELPER_PA\n-000076e0: 5448 2c20 7573 6572 5f6e 616d 652c 2063 TH, user_name, c\n-000076f0: 6f6f 6b69 652c 0a20 2020 2020 2020 2020 ookie,. \n-00007700: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00007710: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00007720: 2020 2020 2020 2020 2020 2020 2020 7374 st\n-00007730: 6469 6e3d 6173 796e 6369 6f2e 7375 6270 din=asyncio.subp\n-00007740: 726f 6365 7373 2e50 4950 452c 0a20 2020 rocess.PIPE,. \n-00007750: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00007760: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00007770: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00007780: 2020 2020 7374 646f 7574 3d61 7379 6e63 stdout=async\n-00007790: 696f 2e73 7562 7072 6f63 6573 732e 5049 io.subprocess.PI\n-000077a0: 5045 290a 2020 2020 2020 2020 7472 793a PE). try:\n-000077b0: 0a20 2020 2020 2020 2020 2020 2061 7761 . awa\n-000077c0: 6974 2073 656c 662e 5f63 6f6d 6d75 6e69 it self._communi\n-000077d0: 6361 7465 2870 726f 6365 7373 290a 2020 cate(process). \n-000077e0: 2020 2020 2020 6578 6365 7074 2061 7379 except asy\n-000077f0: 6e63 696f 2e43 616e 6365 6c6c 6564 4572 ncio.CancelledEr\n-00007800: 726f 723a 0a20 2020 2020 2020 2020 2020 ror:. \n-00007810: 206c 6f67 6765 722e 6465 6275 6728 2743 logger.debug('C\n-00007820: 616e 6365 6c6c 6564 2061 7574 6865 6e74 ancelled authent\n-00007830: 6963 6174 696f 6e27 290a 2020 2020 2020 ication'). \n-00007840: 2020 2020 2020 7072 6f63 6573 732e 7465 process.te\n-00007850: 726d 696e 6174 6528 290a 2020 2020 2020 rminate(). \n-00007860: 2020 6669 6e61 6c6c 793a 0a20 2020 2020 finally:. \n-00007870: 2020 2020 2020 2072 6573 203d 2061 7761 res = awa\n-00007880: 6974 2070 726f 6365 7373 2e77 6169 7428 it process.wait(\n-00007890: 290a 2020 2020 2020 2020 2020 2020 6c6f ). lo\n-000078a0: 6767 6572 2e64 6562 7567 2827 6865 6c70 gger.debug('help\n-000078b0: 6572 2065 7869 7465 6420 7769 7468 2063 er exited with c\n-000078c0: 6f64 6520 2569 272c 2072 6573 290a 0a20 ode %i', res).. \n-000078d0: 2020 2061 7379 6e63 2064 6566 205f 636f async def _co\n-000078e0: 6d6d 756e 6963 6174 6528 7365 6c66 2c20 mmunicate(self, \n-000078f0: 7072 6f63 6573 733a 2061 7379 6e63 696f process: asyncio\n-00007900: 2e73 7562 7072 6f63 6573 732e 5072 6f63 .subprocess.Proc\n-00007910: 6573 7329 202d 3e20 4e6f 6e65 3a0a 2020 ess) -> None:. \n-00007920: 2020 2020 2020 6173 7365 7274 2070 726f assert pro\n-00007930: 6365 7373 2e73 7464 696e 0a20 2020 2020 cess.stdin. \n-00007940: 2020 2061 7373 6572 7420 7072 6f63 6573 assert proces\n-00007950: 732e 7374 646f 7574 0a0a 2020 2020 2020 s.stdout.. \n-00007960: 2020 6d65 7373 6167 6573 3a20 4c69 7374 messages: List\n-00007970: 5b73 7472 5d20 3d20 5b5d 0a0a 2020 2020 [str] = [].. \n-00007980: 2020 2020 6173 796e 6320 666f 7220 6c69 async for li\n-00007990: 6e65 2069 6e20 7072 6f63 6573 732e 7374 ne in process.st\n-000079a0: 646f 7574 3a0a 2020 2020 2020 2020 2020 dout:. \n-000079b0: 2020 6c6f 6767 6572 2e64 6562 7567 2827 logger.debug('\n-000079c0: 5265 6164 206c 696e 6520 6672 6f6d 2068 Read line from h\n-000079d0: 656c 7065 723a 2025 7327 2c20 6c69 6e65 elper: %s', line\n-000079e0: 290a 2020 2020 2020 2020 2020 2020 636f ). co\n-000079f0: 6d6d 616e 642c 205f 2c20 7661 6c75 6520 mmand, _, value \n-00007a00: 3d20 6c69 6e65 2e73 7472 6970 2829 2e64 = line.strip().d\n-00007a10: 6563 6f64 6528 292e 7061 7274 6974 696f ecode().partitio\n-00007a20: 6e28 2720 2729 0a0a 2020 2020 2020 2020 n(' ').. \n-00007a30: 2020 2020 2320 7573 7561 6c6c 793a 2050 # usually: P\n-00007a40: 414d 5f50 524f 4d50 545f 4543 484f 5f4f AM_PROMPT_ECHO_O\n-00007a50: 4646 2050 6173 7377 6f72 643a 205c 6e0a FF Password: \\n.\n-00007a60: 2020 2020 2020 2020 2020 2020 6966 2063 if c\n-00007a70: 6f6d 6d61 6e64 2e73 7461 7274 7377 6974 ommand.startswit\n-00007a80: 6828 2750 414d 5f50 524f 4d50 5427 293a h('PAM_PROMPT'):\n-00007a90: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-00007aa0: 2023 2044 6f6e 2774 2070 6173 7320 7468 # Don't pass th\n-00007ab0: 6973 2074 6f20 7468 6520 5549 2069 6620 is to the UI if \n-00007ac0: 6974 2773 2022 5061 7373 776f 7264 2220 it's \"Password\" \n-00007ad0: 2874 6865 2075 7375 616c 2063 6173 6529 (the usual case)\n-00007ae0: 2c0a 2020 2020 2020 2020 2020 2020 2020 ,. \n-00007af0: 2020 2320 736f 2074 6861 7420 7375 7065 # so that supe\n-00007b00: 7275 7365 722e 7079 2075 7365 7320 7468 ruser.py uses th\n-00007b10: 6520 7472 616e 736c 6174 6564 2064 6566 e translated def\n-00007b20: 6175 6c74 0a20 2020 2020 2020 2020 2020 ault. \n-00007b30: 2020 2020 2069 6620 7661 6c75 652e 7374 if value.st\n-00007b40: 6172 7473 7769 7468 2827 5061 7373 776f artswith('Passwo\n-00007b50: 7264 2729 3a0a 2020 2020 2020 2020 2020 rd'):. \n-00007b60: 2020 2020 2020 2020 2020 7661 6c75 6520 value \n-00007b70: 3d20 2727 0a0a 2020 2020 2020 2020 2020 = ''.. \n-00007b80: 2020 2020 2020 2320 666c 7573 6820 6f75 # flush ou\n-00007b90: 7420 6163 6375 6d75 6c61 7465 6420 696e t accumulated in\n-00007ba0: 666f 2f65 7272 6f72 206d 6573 7361 6765 fo/error message\n-00007bb0: 730a 2020 2020 2020 2020 2020 2020 2020 s. \n-00007bc0: 2020 7061 7373 7764 203d 2061 7761 6974 passwd = await\n-00007bd0: 2073 656c 662e 7265 7370 6f6e 6465 722e self.responder.\n-00007be0: 646f 5f61 736b 7061 7373 2827 5c6e 272e do_askpass('\\n'.\n-00007bf0: 6a6f 696e 286d 6573 7361 6765 7329 2c20 join(messages), \n-00007c00: 7661 6c75 652c 2027 2729 0a20 2020 2020 value, ''). \n-00007c10: 2020 2020 2020 2020 2020 206d 6573 7361 messa\n-00007c20: 6765 732e 636c 6561 7228 290a 2020 2020 ges.clear(). \n-00007c30: 2020 2020 2020 2020 2020 2020 6966 2070 if p\n-00007c40: 6173 7377 6420 6973 204e 6f6e 653a 0a20 asswd is None:. \n-00007c50: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00007c60: 2020 206c 6f67 6765 722e 6465 6275 6728 logger.debug(\n-00007c70: 2767 6f74 2050 414d 5f50 524f 4d50 5420 'got PAM_PROMPT \n-00007c80: 2573 2c20 6275 7420 646f 5f61 736b 7061 %s, but do_askpa\n-00007c90: 7373 2072 6574 7572 6e65 6420 4e6f 6e65 ss returned None\n-00007ca0: 272c 2076 616c 7565 290a 2020 2020 2020 ', value). \n-00007cb0: 2020 2020 2020 2020 2020 2020 2020 7261 ra\n-00007cc0: 6973 6520 6173 796e 6369 6f2e 4361 6e63 ise asyncio.Canc\n-00007cd0: 656c 6c65 6445 7272 6f72 2827 6e6f 2070 elledError('no p\n-00007ce0: 6173 7377 6f72 6420 6769 7665 6e27 290a assword given').\n-00007cf0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00007d00: 6c6f 6767 6572 2e64 6562 7567 2827 676f logger.debug('go\n-00007d10: 7420 5041 4d5f 5052 4f4d 5054 2025 732c t PAM_PROMPT %s,\n-00007d20: 2064 6f5f 6173 6b70 6173 7320 7265 7475 do_askpass retu\n-00007d30: 726e 6564 2061 2070 6173 7377 6f72 6427 rned a password'\n-00007d40: 2c20 7661 6c75 6529 0a20 2020 2020 2020 , value). \n-00007d50: 2020 2020 2020 2020 2070 726f 6365 7373 process\n-00007d60: 2e73 7464 696e 2e77 7269 7465 2870 6173 .stdin.write(pas\n-00007d70: 7377 642e 656e 636f 6465 2829 290a 2020 swd.encode()). \n-00007d80: 2020 2020 2020 2020 2020 2020 2020 7072 pr\n-00007d90: 6f63 6573 732e 7374 6469 6e2e 7772 6974 ocess.stdin.writ\n-00007da0: 6528 6227 5c6e 2729 0a20 2020 2020 2020 e(b'\\n'). \n-00007db0: 2020 2020 2020 2020 2064 656c 2070 6173 del pas\n-00007dc0: 7377 6420 2023 2064 6f6e 2774 206b 6565 swd # don't kee\n-00007dd0: 7020 7468 6973 2061 726f 756e 6420 6c6f p this around lo\n-00007de0: 6e67 6572 2074 6861 6e20 6e65 6365 7373 nger than necess\n-00007df0: 6172 790a 2020 2020 2020 2020 2020 2020 ary. \n-00007e00: 2020 2020 6177 6169 7420 7072 6f63 6573 await proces\n-00007e10: 732e 7374 6469 6e2e 6472 6169 6e28 290a s.stdin.drain().\n-00007e20: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00007e30: 6c6f 6767 6572 2e64 6562 7567 2827 676f logger.debug('go\n-00007e40: 7420 5041 4d5f 5052 4f4d 5054 2c20 7772 t PAM_PROMPT, wr\n-00007e50: 6f74 6520 7061 7373 776f 7264 2074 6f20 ote password to \n-00007e60: 6865 6c70 6572 2729 0a20 2020 2020 2020 helper'). \n-00007e70: 2020 2020 2065 6c69 6620 636f 6d6d 616e elif comman\n-00007e80: 6420 696e 2028 2750 414d 5f54 4558 545f d in ('PAM_TEXT_\n-00007e90: 494e 464f 272c 2027 5041 4d5f 4552 524f INFO', 'PAM_ERRO\n-00007ea0: 5227 293a 0a20 2020 2020 2020 2020 2020 R'):. \n-00007eb0: 2020 2020 206d 6573 7361 6765 732e 6170 messages.ap\n-00007ec0: 7065 6e64 2876 616c 7565 290a 2020 2020 pend(value). \n-00007ed0: 2020 2020 2020 2020 656c 6966 2063 6f6d elif com\n-00007ee0: 6d61 6e64 203d 3d20 2753 5543 4345 5353 mand == 'SUCCESS\n-00007ef0: 273a 0a20 2020 2020 2020 2020 2020 2020 ':. \n-00007f00: 2020 206c 6f67 6765 722e 6465 6275 6728 logger.debug(\n-00007f10: 2741 7574 6865 6e74 6963 6174 696f 6e20 'Authentication \n-00007f20: 7375 6363 6565 6465 6427 290a 2020 2020 succeeded'). \n-00007f30: 2020 2020 2020 2020 2020 2020 6272 6561 brea\n-00007f40: 6b0a 2020 2020 2020 2020 2020 2020 656c k. el\n-00007f50: 6966 2063 6f6d 6d61 6e64 203d 3d20 2746 if command == 'F\n-00007f60: 4149 4c55 5245 273a 0a20 2020 2020 2020 AILURE':. \n-00007f70: 2020 2020 2020 2020 206c 6f67 6765 722e logger.\n-00007f80: 7761 726e 696e 6728 2741 7574 6865 6e74 warning('Authent\n-00007f90: 6963 6174 696f 6e20 6661 696c 6564 2729 ication failed')\n-00007fa0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-00007fb0: 2062 7265 616b 0a20 2020 2020 2020 2020 break. \n-00007fc0: 2020 2065 6c73 653a 0a20 2020 2020 2020 else:. \n-00007fd0: 2020 2020 2020 2020 206c 6f67 6765 722e logger.\n-00007fe0: 7761 726e 696e 6728 2755 6e6b 6e6f 776e warning('Unknown\n-00007ff0: 206c 696e 6520 6672 6f6d 2068 656c 7065 line from helpe\n-00008000: 722c 2061 626f 7274 696e 673a 2025 7327 r, aborting: %s'\n-00008010: 2c20 6c69 6e65 290a 2020 2020 2020 2020 , line). \n-00008020: 2020 2020 2020 2020 7072 6f63 6573 732e process.\n-00008030: 7465 726d 696e 6174 6528 290a 2020 2020 terminate(). \n-00008040: 2020 2020 2020 2020 2020 2020 6272 6561 brea\n-00008050: 6b0a 0a0a 636c 6173 7320 506f 6c6b 6974 k...class Polkit\n-00008060: 4167 656e 743a 0a20 2020 2022 2222 5265 Agent:. \"\"\"Re\n-00008070: 6769 7374 6572 2070 6f6c 6b69 7420 6167 gister polkit ag\n-00008080: 656e 7420 7768 656e 2072 6571 7569 7265 ent when require\n-00008090: 640a 0a20 2020 2055 7365 2074 6869 7320 d.. Use this \n-000080a0: 6173 2061 2063 6f6e 7465 7874 206d 616e as a context man\n-000080b0: 6167 6572 2074 6f20 656e 7375 7265 2074 ager to ensure t\n-000080c0: 6861 7420 7468 6520 6167 656e 7420 6765 hat the agent ge\n-000080d0: 7473 2075 6e72 6567 6973 7465 7265 6420 ts unregistered \n-000080e0: 6167 6169 6e2e 0a20 2020 2022 2222 0a20 again.. \"\"\". \n-000080f0: 2020 2064 6566 205f 5f69 6e69 745f 5f28 def __init__(\n-00008100: 7365 6c66 2c20 7265 7370 6f6e 6465 723a self, responder:\n-00008110: 2041 736b 7061 7373 4861 6e64 6c65 7229 AskpassHandler)\n-00008120: 3a0a 2020 2020 2020 2020 7365 6c66 2e72 :. self.r\n-00008130: 6573 706f 6e64 6572 203d 2072 6573 706f esponder = respo\n-00008140: 6e64 6572 0a20 2020 2020 2020 2073 656c nder. sel\n-00008150: 662e 6167 656e 745f 736c 6f74 203d 204e f.agent_slot = N\n-00008160: 6f6e 650a 0a20 2020 2061 7379 6e63 2064 one.. async d\n-00008170: 6566 205f 5f61 656e 7465 725f 5f28 7365 ef __aenter__(se\n-00008180: 6c66 293a 0a20 2020 2020 2020 2074 7279 lf):. try\n-00008190: 3a0a 2020 2020 2020 2020 2020 2020 7365 :. se\n-000081a0: 6c66 2e73 7973 7465 6d5f 6275 7320 3d20 lf.system_bus = \n-000081b0: 6275 732e 4275 732e 6465 6661 756c 745f bus.Bus.default_\n-000081c0: 7379 7374 656d 2829 0a20 2020 2020 2020 system(). \n-000081d0: 2065 7863 6570 7420 4f53 4572 726f 7220 except OSError \n-000081e0: 6173 2065 3a0a 2020 2020 2020 2020 2020 as e:. \n-000081f0: 2020 6c6f 6767 6572 2e77 6172 6e69 6e67 logger.warning\n-00008200: 2827 6361 6e6e 6f74 2063 6f6e 6e65 6374 ('cannot connect\n-00008210: 2074 6f20 7379 7374 656d 2062 7573 2c20 to system bus, \n-00008220: 6e6f 7420 7265 6769 7374 6572 696e 6720 not registering \n-00008230: 706f 6c6b 6974 2061 6765 6e74 3a20 2573 polkit agent: %s\n-00008240: 272c 2065 290a 2020 2020 2020 2020 2020 ', e). \n-00008250: 2020 7265 7475 726e 2073 656c 660a 0a20 return self.. \n-00008260: 2020 2020 2020 2074 7279 3a0a 2020 2020 try:. \n-00008270: 2020 2020 2020 2020 2320 6d61 7920 7265 # may re\n-00008280: 6669 6e65 2074 6861 7420 7769 7468 2061 fine that with a\n-00008290: 2044 2d42 7573 2063 616c 6c20 746f 206c D-Bus call to l\n-000082a0: 6f67 696e 640a 2020 2020 2020 2020 2020 ogind. \n-000082b0: 2020 7365 6c66 2e73 7562 6a65 6374 203d self.subject =\n-000082c0: 2028 2775 6e69 782d 7365 7373 696f 6e27 ('unix-session'\n-000082d0: 2c20 7b27 7365 7373 696f 6e2d 6964 273a , {'session-id':\n-000082e0: 2056 6172 6961 6e74 286f 732e 656e 7669 Variant(os.envi\n-000082f0: 726f 6e5b 2758 4447 5f53 4553 5349 4f4e ron['XDG_SESSION\n-00008300: 5f49 4427 5d2c 2027 7327 297d 290a 2020 _ID'], 's')}). \n-00008310: 2020 2020 2020 6578 6365 7074 204b 6579 except Key\n-00008320: 4572 726f 723a 0a20 2020 2020 2020 2020 Error:. \n-00008330: 2020 206c 6f67 6765 722e 6465 6275 6728 logger.debug(\n-00008340: 2758 4447 5f53 4553 5349 4f4e 5f49 4420 'XDG_SESSION_ID \n-00008350: 6e6f 7420 7365 742c 206e 6f74 2072 6567 not set, not reg\n-00008360: 6973 7465 7269 6e67 2070 6f6c 6b69 7420 istering polkit \n-00008370: 6167 656e 7427 290a 2020 2020 2020 2020 agent'). \n-00008380: 2020 2020 7265 7475 726e 2073 656c 660a return self.\n-00008390: 0a20 2020 2020 2020 2061 6765 6e74 5f6f . agent_o\n-000083a0: 626a 6563 7420 3d20 6f72 675f 6672 6565 bject = org_free\n-000083b0: 6465 736b 746f 705f 506f 6c69 6379 4b69 desktop_PolicyKi\n-000083c0: 7431 5f41 7574 6865 6e74 6963 6174 696f t1_Authenticatio\n-000083d0: 6e41 6765 6e74 2873 656c 662e 7265 7370 nAgent(self.resp\n-000083e0: 6f6e 6465 7229 0a20 2020 2020 2020 2073 onder). s\n-000083f0: 656c 662e 6167 656e 745f 736c 6f74 203d elf.agent_slot =\n-00008400: 2073 656c 662e 7379 7374 656d 5f62 7573 self.system_bus\n-00008410: 2e61 6464 5f6f 626a 6563 7428 4147 454e .add_object(AGEN\n-00008420: 545f 4442 5553 5f50 4154 482c 2061 6765 T_DBUS_PATH, age\n-00008430: 6e74 5f6f 626a 6563 7429 0a0a 2020 2020 nt_object).. \n-00008440: 2020 2020 2320 7265 6769 7374 6572 2061 # register a\n-00008450: 6765 6e74 0a20 2020 2020 2020 206c 6f63 gent. loc\n-00008460: 616c 655f 6e61 6d65 203d 206c 6f63 616c ale_name = local\n-00008470: 652e 7365 746c 6f63 616c 6528 6c6f 6361 e.setlocale(loca\n-00008480: 6c65 2e4c 435f 4d45 5353 4147 4553 2c20 le.LC_MESSAGES, \n-00008490: 4e6f 6e65 290a 2020 2020 2020 2020 6177 None). aw\n-000084a0: 6169 7420 7365 6c66 2e73 7973 7465 6d5f ait self.system_\n-000084b0: 6275 732e 6361 6c6c 5f6d 6574 686f 645f bus.call_method_\n-000084c0: 6173 796e 6328 0a20 2020 2020 2020 2020 async(. \n-000084d0: 2020 2027 6f72 672e 6672 6565 6465 736b 'org.freedesk\n-000084e0: 746f 702e 506f 6c69 6379 4b69 7431 272c top.PolicyKit1',\n-000084f0: 0a20 2020 2020 2020 2020 2020 2027 2f6f . '/o\n-00008500: 7267 2f66 7265 6564 6573 6b74 6f70 2f50 rg/freedesktop/P\n-00008510: 6f6c 6963 794b 6974 312f 4175 7468 6f72 olicyKit1/Author\n-00008520: 6974 7927 2c0a 2020 2020 2020 2020 2020 ity',. \n-00008530: 2020 276f 7267 2e66 7265 6564 6573 6b74 'org.freedeskt\n-00008540: 6f70 2e50 6f6c 6963 794b 6974 312e 4175 op.PolicyKit1.Au\n-00008550: 7468 6f72 6974 7927 2c0a 2020 2020 2020 thority',. \n-00008560: 2020 2020 2020 2752 6567 6973 7465 7241 'RegisterA\n-00008570: 7574 6865 6e74 6963 6174 696f 6e41 6765 uthenticationAge\n-00008580: 6e74 272c 0a20 2020 2020 2020 2020 2020 nt',. \n-00008590: 2027 2873 617b 7376 7d29 7373 272c 0a20 '(sa{sv})ss',. \n-000085a0: 2020 2020 2020 2020 2020 2073 656c 662e self.\n-000085b0: 7375 626a 6563 742c 206c 6f63 616c 655f subject, locale_\n-000085c0: 6e61 6d65 2c20 4147 454e 545f 4442 5553 name, AGENT_DBUS\n-000085d0: 5f50 4154 4829 0a20 2020 2020 2020 206c _PATH). l\n-000085e0: 6f67 6765 722e 6465 6275 6728 2752 6567 ogger.debug('Reg\n-000085f0: 6973 7465 7265 6420 6167 656e 7420 666f istered agent fo\n-00008600: 7220 2572 2061 6e64 206c 6f63 616c 6520 r %r and locale \n-00008610: 2573 272c 2073 656c 662e 7375 626a 6563 %s', self.subjec\n-00008620: 742c 206c 6f63 616c 655f 6e61 6d65 290a t, locale_name).\n-00008630: 2020 2020 2020 2020 7265 7475 726e 2073 return s\n-00008640: 656c 660a 0a20 2020 2061 7379 6e63 2064 elf.. async d\n-00008650: 6566 205f 5f61 6578 6974 5f5f 2873 656c ef __aexit__(sel\n-00008660: 662c 205f 6578 635f 7479 7065 2c20 5f65 f, _exc_type, _e\n-00008670: 7863 5f76 616c 7565 2c20 5f74 7261 6365 xc_value, _trace\n-00008680: 6261 636b 293a 0a20 2020 2020 2020 2069 back):. i\n-00008690: 6620 7365 6c66 2e61 6765 6e74 5f73 6c6f f self.agent_slo\n-000086a0: 743a 0a20 2020 2020 2020 2020 2020 2061 t:. a\n-000086b0: 7761 6974 2073 656c 662e 7379 7374 656d wait self.system\n-000086c0: 5f62 7573 2e63 616c 6c5f 6d65 7468 6f64 _bus.call_method\n-000086d0: 5f61 7379 6e63 280a 2020 2020 2020 2020 _async(. \n-000086e0: 2020 2020 2020 2020 276f 7267 2e66 7265 'org.fre\n-000086f0: 6564 6573 6b74 6f70 2e50 6f6c 6963 794b edesktop.PolicyK\n-00008700: 6974 3127 2c0a 2020 2020 2020 2020 2020 it1',. \n-00008710: 2020 2020 2020 272f 6f72 672f 6672 6565 '/org/free\n-00008720: 6465 736b 746f 702f 506f 6c69 6379 4b69 desktop/PolicyKi\n-00008730: 7431 2f41 7574 686f 7269 7479 272c 0a20 t1/Authority',. \n-00008740: 2020 2020 2020 2020 2020 2020 2020 2027 '\n-00008750: 6f72 672e 6672 6565 6465 736b 746f 702e org.freedesktop.\n-00008760: 506f 6c69 6379 4b69 7431 2e41 7574 686f PolicyKit1.Autho\n-00008770: 7269 7479 272c 0a20 2020 2020 2020 2020 rity',. \n-00008780: 2020 2020 2020 2027 556e 7265 6769 7374 'Unregist\n-00008790: 6572 4175 7468 656e 7469 6361 7469 6f6e erAuthentication\n-000087a0: 4167 656e 7427 2c0a 2020 2020 2020 2020 Agent',. \n-000087b0: 2020 2020 2020 2020 2728 7361 7b73 767d '(sa{sv}\n-000087c0: 2973 272c 0a20 2020 2020 2020 2020 2020 )s',. \n-000087d0: 2020 2020 2073 656c 662e 7375 626a 6563 self.subjec\n-000087e0: 742c 2041 4745 4e54 5f44 4255 535f 5041 t, AGENT_DBUS_PA\n-000087f0: 5448 290a 2020 2020 2020 2020 2020 2020 TH). \n-00008800: 7365 6c66 2e61 6765 6e74 5f73 6c6f 742e self.agent_slot.\n-00008810: 6361 6e63 656c 2829 0a20 2020 2020 2020 cancel(). \n-00008820: 2020 2020 206c 6f67 6765 722e 6465 6275 logger.debu\n-00008830: 6728 2755 6e72 6567 6973 7465 7265 6420 g('Unregistered \n-00008840: 6167 656e 7420 666f 7220 2572 272c 2073 agent for %r', s\n-00008850: 656c 662e 7375 626a 6563 7429 0a27 2727 elf.subject).'''\n-00008860: 2e65 6e63 6f64 6528 2775 7466 2d38 2729 .encode('utf-8')\n-00008870: 2c0a 2020 2763 6f63 6b70 6974 2f72 6f75 ,. 'cockpit/rou\n-00008880: 7465 722e 7079 273a 2062 7227 2727 2320 ter.py': br'''# \n-00008890: 5468 6973 2066 696c 6520 6973 2070 6172 This file is par\n-000088a0: 7420 6f66 2043 6f63 6b70 6974 2e0a 230a t of Cockpit..#.\n-000088b0: 2320 436f 7079 7269 6768 7420 2843 2920 # Copyright (C) \n-000088c0: 3230 3232 2052 6564 2048 6174 2c20 496e 2022 Red Hat, In\n-000088d0: 632e 0a23 0a23 2054 6869 7320 7072 6f67 c..#.# This prog\n-000088e0: 7261 6d20 6973 2066 7265 6520 736f 6674 ram is free soft\n-000088f0: 7761 7265 3a20 796f 7520 6361 6e20 7265 ware: you can re\n-00008900: 6469 7374 7269 6275 7465 2069 7420 616e distribute it an\n-00008910: 642f 6f72 206d 6f64 6966 790a 2320 6974 d/or modify.# it\n-00008920: 2075 6e64 6572 2074 6865 2074 6572 6d73 under the terms\n-00008930: 206f 6620 7468 6520 474e 5520 4765 6e65 of the GNU Gene\n-00008940: 7261 6c20 5075 626c 6963 204c 6963 656e ral Public Licen\n-00008950: 7365 2061 7320 7075 626c 6973 6865 6420 se as published \n-00008960: 6279 0a23 2074 6865 2046 7265 6520 536f by.# the Free So\n-00008970: 6674 7761 7265 2046 6f75 6e64 6174 696f ftware Foundatio\n-00008980: 6e2c 2065 6974 6865 7220 7665 7273 696f n, either versio\n-00008990: 6e20 3320 6f66 2074 6865 204c 6963 656e n 3 of the Licen\n-000089a0: 7365 2c20 6f72 0a23 2028 6174 2079 6f75 se, or.# (at you\n-000089b0: 7220 6f70 7469 6f6e 2920 616e 7920 6c61 r option) any la\n-000089c0: 7465 7220 7665 7273 696f 6e2e 0a23 0a23 ter version..#.#\n-000089d0: 2054 6869 7320 7072 6f67 7261 6d20 6973 This program is\n-000089e0: 2064 6973 7472 6962 7574 6564 2069 6e20 distributed in \n-000089f0: 7468 6520 686f 7065 2074 6861 7420 6974 the hope that it\n-00008a00: 2077 696c 6c20 6265 2075 7365 6675 6c2c will be useful,\n-00008a10: 0a23 2062 7574 2057 4954 484f 5554 2041 .# but WITHOUT A\n-00008a20: 4e59 2057 4152 5241 4e54 593b 2077 6974 NY WARRANTY; wit\n-00008a30: 686f 7574 2065 7665 6e20 7468 6520 696d hout even the im\n-00008a40: 706c 6965 6420 7761 7272 616e 7479 206f plied warranty o\n-00008a50: 660a 2320 4d45 5243 4841 4e54 4142 494c f.# MERCHANTABIL\n-00008a60: 4954 5920 6f72 2046 4954 4e45 5353 2046 ITY or FITNESS F\n-00008a70: 4f52 2041 2050 4152 5449 4355 4c41 5220 OR A PARTICULAR \n-00008a80: 5055 5250 4f53 452e 2020 5365 6520 7468 PURPOSE. See th\n-00008a90: 650a 2320 474e 5520 4765 6e65 7261 6c20 e.# GNU General \n-00008aa0: 5075 626c 6963 204c 6963 656e 7365 2066 Public License f\n-00008ab0: 6f72 206d 6f72 6520 6465 7461 696c 732e or more details.\n-00008ac0: 0a23 0a23 2059 6f75 2073 686f 756c 6420 .#.# You should \n-00008ad0: 6861 7665 2072 6563 6569 7665 6420 6120 have received a \n-00008ae0: 636f 7079 206f 6620 7468 6520 474e 5520 copy of the GNU \n-00008af0: 4765 6e65 7261 6c20 5075 626c 6963 204c General Public L\n-00008b00: 6963 656e 7365 0a23 2061 6c6f 6e67 2077 icense.# along w\n-00008b10: 6974 6820 7468 6973 2070 726f 6772 616d ith this program\n-00008b20: 2e20 2049 6620 6e6f 742c 2073 6565 203c . If not, see <\n-00008b30: 6874 7470 733a 2f2f 7777 772e 676e 752e https://www.gnu.\n-00008b40: 6f72 672f 6c69 6365 6e73 6573 2f3e 2e0a org/licenses/>..\n-00008b50: 0a69 6d70 6f72 7420 6173 796e 6369 6f0a .import asyncio.\n-00008b60: 696d 706f 7274 2063 6f6c 6c65 6374 696f import collectio\n-00008b70: 6e73 0a69 6d70 6f72 7420 6c6f 6767 696e ns.import loggin\n-00008b80: 670a 6672 6f6d 2074 7970 696e 6720 696d g.from typing im\n-00008b90: 706f 7274 2044 6963 742c 204c 6973 742c port Dict, List,\n-00008ba0: 204f 7074 696f 6e61 6c0a 0a66 726f 6d20 Optional..from \n-00008bb0: 2e6a 736f 6e75 7469 6c20 696d 706f 7274 .jsonutil import\n-00008bc0: 204a 736f 6e4f 626a 6563 742c 204a 736f JsonObject, Jso\n-00008bd0: 6e56 616c 7565 0a66 726f 6d20 2e70 726f nValue.from .pro\n-00008be0: 746f 636f 6c20 696d 706f 7274 2043 6f63 tocol import Coc\n-00008bf0: 6b70 6974 5072 6f62 6c65 6d2c 2043 6f63 kpitProblem, Coc\n-00008c00: 6b70 6974 5072 6f74 6f63 6f6c 4572 726f kpitProtocolErro\n-00008c10: 722c 2043 6f63 6b70 6974 5072 6f74 6f63 r, CockpitProtoc\n-00008c20: 6f6c 5365 7276 6572 0a0a 6c6f 6767 6572 olServer..logger\n-00008c30: 203d 206c 6f67 6769 6e67 2e67 6574 4c6f = logging.getLo\n-00008c40: 6767 6572 285f 5f6e 616d 655f 5f29 0a0a gger(__name__)..\n-00008c50: 0a63 6c61 7373 2045 7865 6375 7469 6f6e .class Execution\n-00008c60: 5175 6575 653a 0a20 2020 2022 2222 5465 Queue:. \"\"\"Te\n-00008c70: 6d70 6f72 6172 696c 7920 6465 6c61 7920 mporarily delay \n-00008c80: 6361 6c6c 7320 746f 2061 2067 6976 656e calls to a given\n-00008c90: 2073 6574 206f 6620 636c 6173 7320 6d65 set of class me\n-00008ca0: 7468 6f64 732e 0a0a 2020 2020 4675 6e63 thods... Func\n-00008cb0: 7469 6f6e 7320 6279 2072 6570 6c61 6369 tions by replaci\n-00008cc0: 6e67 2074 6865 206e 616d 6564 2066 756e ng the named fun\n-00008cd0: 6374 696f 6e20 6174 2074 6865 2069 6e73 ction at the ins\n-00008ce0: 7461 6e63 6520 5f5f 6469 6374 5f5f 0a20 tance __dict__. \n-00008cf0: 2020 206c 6576 656c 2c20 6566 6665 6374 level, effect\n-00008d00: 6976 656c 7920 7072 6f76 6964 696e 6720 ively providing \n-00008d10: 616e 206f 7665 7272 6964 6520 666f 7220 an override for \n-00008d20: 6578 6163 746c 7920 6f6e 6520 696e 7374 exactly one inst\n-00008d30: 616e 6365 0a20 2020 206f 6620 606d 6574 ance. of `met\n-00008d40: 686f 6460 2773 206f 626a 6563 742e 0a20 hod`'s object.. \n-00008d50: 2020 2051 7565 7565 7320 7468 6520 696e Queues the in\n-00008d60: 766f 6361 7469 6f6e 732e 2020 5275 6e20 vocations. Run \n-00008d70: 7468 656d 206c 6174 6572 2077 6974 6820 them later with \n-00008d80: 2e72 756e 2829 2c20 7768 6963 6820 616c .run(), which al\n-00008d90: 736f 2072 6576 6572 7365 730a 2020 2020 so reverses. \n-00008da0: 7468 6520 7265 6469 7265 6374 696f 6e20 the redirection \n-00008db0: 6279 2064 656c 6574 696e 6720 7468 6520 by deleting the \n-00008dc0: 6e61 6d65 6420 6d65 7468 6f64 7320 6672 named methods fr\n-00008dd0: 6f6d 2074 6865 2069 6e73 7461 6e63 652e om the instance.\n-00008de0: 0a20 2020 2022 2222 0a20 2020 2064 6566 . \"\"\". def\n-00008df0: 205f 5f69 6e69 745f 5f28 7365 6c66 2c20 __init__(self, \n-00008e00: 6d65 7468 6f64 7329 3a0a 2020 2020 2020 methods):. \n-00008e10: 2020 7365 6c66 2e71 7565 7565 203d 2063 self.queue = c\n-00008e20: 6f6c 6c65 6374 696f 6e73 2e64 6571 7565 ollections.deque\n-00008e30: 2829 0a20 2020 2020 2020 2073 656c 662e (). self.\n-00008e40: 6d65 7468 6f64 7320 3d20 6d65 7468 6f64 methods = method\n-00008e50: 730a 0a20 2020 2020 2020 2066 6f72 206d s.. for m\n-00008e60: 6574 686f 6420 696e 2073 656c 662e 6d65 ethod in self.me\n-00008e70: 7468 6f64 733a 0a20 2020 2020 2020 2020 thods:. \n-00008e80: 2020 2073 656c 662e 5f77 7261 7028 6d65 self._wrap(me\n-00008e90: 7468 6f64 290a 0a20 2020 2064 6566 205f thod).. def _\n-00008ea0: 7772 6170 2873 656c 662c 206d 6574 686f wrap(self, metho\n-00008eb0: 6429 3a0a 2020 2020 2020 2020 2320 4e42 d):. # NB\n-00008ec0: 3a20 7468 6973 2066 756e 6374 696f 6e20 : this function \n-00008ed0: 6973 2073 746f 7265 6420 696e 2074 6865 is stored in the\n-00008ee0: 2069 6e73 7461 6e63 6520 6469 6374 2061 instance dict a\n-00008ef0: 6e64 2074 6865 7265 666f 7265 0a20 2020 nd therefore. \n-00008f00: 2020 2020 2023 2064 6f65 736e 2774 2066 # doesn't f\n-00008f10: 756e 6374 696f 6e20 6173 2061 2064 6573 unction as a des\n-00008f20: 6372 6970 746f 722c 2069 736e 2774 2061 criptor, isn't a\n-00008f30: 206d 6574 686f 642c 2064 6f65 736e 2774 method, doesn't\n-00008f40: 2067 6574 2062 6f75 6e64 2c0a 2020 2020 get bound,. \n-00008f50: 2020 2020 2320 616e 6420 7468 6572 6566 # and theref\n-00008f60: 6f72 6520 646f 6573 6e27 7420 7265 6365 ore doesn't rece\n-00008f70: 6976 6520 6120 7365 6c66 2070 6172 616d ive a self param\n-00008f80: 6574 6572 0a20 2020 2020 2020 2073 6574 eter. set\n-00008f90: 6174 7472 286d 6574 686f 642e 5f5f 7365 attr(method.__se\n-00008fa0: 6c66 5f5f 2c20 6d65 7468 6f64 2e5f 5f66 lf__, method.__f\n-00008fb0: 756e 635f 5f2e 5f5f 6e61 6d65 5f5f 2c20 unc__.__name__, \n-00008fc0: 6c61 6d62 6461 202a 6172 6773 3a20 7365 lambda *args: se\n-00008fd0: 6c66 2e71 7565 7565 2e61 7070 656e 6428 lf.queue.append(\n-00008fe0: 286d 6574 686f 642c 2061 7267 7329 2929 (method, args)))\n-00008ff0: 0a0a 2020 2020 6465 6620 7275 6e28 7365 .. def run(se\n-00009000: 6c66 293a 0a20 2020 2020 2020 206c 6f67 lf):. log\n-00009010: 6765 722e 6465 6275 6728 2745 7865 6375 ger.debug('Execu\n-00009020: 7469 6f6e 5175 6575 653a 2052 756e 6e69 tionQueue: Runni\n-00009030: 6e67 2025 6420 7175 6575 6564 206d 6574 ng %d queued met\n-00009040: 686f 6420 6361 6c6c 7327 2c20 6c65 6e28 hod calls', len(\n-00009050: 7365 6c66 2e71 7565 7565 2929 0a20 2020 self.queue)). \n-00009060: 2020 2020 2066 6f72 206d 6574 686f 642c for method,\n-00009070: 2061 7267 7320 696e 2073 656c 662e 7175 args in self.qu\n-00009080: 6575 653a 0a20 2020 2020 2020 2020 2020 eue:. \n-00009090: 206d 6574 686f 6428 2a61 7267 7329 0a0a method(*args)..\n-000090a0: 2020 2020 2020 2020 666f 7220 6d65 7468 for meth\n-000090b0: 6f64 2069 6e20 7365 6c66 2e6d 6574 686f od in self.metho\n-000090c0: 6473 3a0a 2020 2020 2020 2020 2020 2020 ds:. \n-000090d0: 6465 6c61 7474 7228 6d65 7468 6f64 2e5f delattr(method._\n-000090e0: 5f73 656c 665f 5f2c 206d 6574 686f 642e _self__, method.\n-000090f0: 5f5f 6675 6e63 5f5f 2e5f 5f6e 616d 655f __func__.__name_\n-00009100: 5f29 0a0a 0a63 6c61 7373 2045 6e64 706f _)...class Endpo\n-00009110: 696e 743a 0a20 2020 2072 6f75 7465 723a int:. router:\n-00009120: 2027 526f 7574 6572 270a 2020 2020 5f5f 'Router'. __\n-00009130: 656e 6470 6f69 6e74 5f66 726f 7a65 6e5f endpoint_frozen_\n-00009140: 7175 6575 653a 204f 7074 696f 6e61 6c5b queue: Optional[\n-00009150: 4578 6563 7574 696f 6e51 7565 7565 5d20 ExecutionQueue] \n-00009160: 3d20 4e6f 6e65 0a0a 2020 2020 6465 6620 = None.. def \n-00009170: 5f5f 696e 6974 5f5f 2873 656c 662c 2072 __init__(self, r\n-00009180: 6f75 7465 723a 2027 526f 7574 6572 2729 outer: 'Router')\n-00009190: 3a0a 2020 2020 2020 2020 726f 7574 6572 :. router\n-000091a0: 2e61 6464 5f65 6e64 706f 696e 7428 7365 .add_endpoint(se\n-000091b0: 6c66 290a 2020 2020 2020 2020 7365 6c66 lf). self\n-000091c0: 2e72 6f75 7465 7220 3d20 726f 7574 6572 .router = router\n-000091d0: 0a0a 2020 2020 6465 6620 6672 6565 7a65 .. def freeze\n-000091e0: 5f65 6e64 706f 696e 7428 7365 6c66 293a _endpoint(self):\n-000091f0: 0a20 2020 2020 2020 2061 7373 6572 7420 . assert \n-00009200: 7365 6c66 2e5f 5f65 6e64 706f 696e 745f self.__endpoint_\n-00009210: 6672 6f7a 656e 5f71 7565 7565 2069 7320 frozen_queue is \n-00009220: 4e6f 6e65 0a20 2020 2020 2020 206c 6f67 None. log\n-00009230: 6765 722e 6465 6275 6728 2746 7265 657a ger.debug('Freez\n-00009240: 696e 6720 656e 6470 6f69 6e74 2025 7327 ing endpoint %s'\n-00009250: 2c20 7365 6c66 290a 2020 2020 2020 2020 , self). \n-00009260: 7365 6c66 2e5f 5f65 6e64 706f 696e 745f self.__endpoint_\n-00009270: 6672 6f7a 656e 5f71 7565 7565 203d 2045 frozen_queue = E\n-00009280: 7865 6375 7469 6f6e 5175 6575 6528 7b73 xecutionQueue({s\n-00009290: 656c 662e 646f 5f63 6861 6e6e 656c 5f63 elf.do_channel_c\n-000092a0: 6f6e 7472 6f6c 2c20 7365 6c66 2e64 6f5f ontrol, self.do_\n-000092b0: 6368 616e 6e65 6c5f 6461 7461 2c20 7365 channel_data, se\n-000092c0: 6c66 2e64 6f5f 6b69 6c6c 7d29 0a0a 2020 lf.do_kill}).. \n-000092d0: 2020 6465 6620 7468 6177 5f65 6e64 706f def thaw_endpo\n-000092e0: 696e 7428 7365 6c66 293a 0a20 2020 2020 int(self):. \n-000092f0: 2020 2061 7373 6572 7420 7365 6c66 2e5f assert self._\n-00009300: 5f65 6e64 706f 696e 745f 6672 6f7a 656e _endpoint_frozen\n-00009310: 5f71 7565 7565 2069 7320 6e6f 7420 4e6f _queue is not No\n-00009320: 6e65 0a20 2020 2020 2020 206c 6f67 6765 ne. logge\n-00009330: 722e 6465 6275 6728 2754 6861 7769 6e67 r.debug('Thawing\n-00009340: 2065 6e64 706f 696e 7420 2573 272c 2073 endpoint %s', s\n-00009350: 656c 6629 0a20 2020 2020 2020 2073 656c elf). sel\n-00009360: 662e 5f5f 656e 6470 6f69 6e74 5f66 726f f.__endpoint_fro\n-00009370: 7a65 6e5f 7175 6575 652e 7275 6e28 290a zen_queue.run().\n-00009380: 2020 2020 2020 2020 7365 6c66 2e5f 5f65 self.__e\n-00009390: 6e64 706f 696e 745f 6672 6f7a 656e 5f71 ndpoint_frozen_q\n-000093a0: 7565 7565 203d 204e 6f6e 650a 0a20 2020 ueue = None.. \n-000093b0: 2023 2069 6e74 6572 6661 6365 2066 6f72 # interface for\n-000093c0: 2072 6563 6569 7669 6e67 206d 6573 7361 receiving messa\n-000093d0: 6765 730a 2020 2020 6465 6620 646f 5f63 ges. def do_c\n-000093e0: 6c6f 7365 2873 656c 6629 3a0a 2020 2020 lose(self):. \n-000093f0: 2020 2020 7261 6973 6520 4e6f 7449 6d70 raise NotImp\n-00009400: 6c65 6d65 6e74 6564 4572 726f 720a 0a20 lementedError.. \n-00009410: 2020 2064 6566 2064 6f5f 6368 616e 6e65 def do_channe\n-00009420: 6c5f 636f 6e74 726f 6c28 7365 6c66 2c20 l_control(self, \n-00009430: 6368 616e 6e65 6c3a 2073 7472 2c20 636f channel: str, co\n-00009440: 6d6d 616e 643a 2073 7472 2c20 6d65 7373 mmand: str, mess\n-00009450: 6167 653a 204a 736f 6e4f 626a 6563 7429 age: JsonObject)\n-00009460: 202d 3e20 4e6f 6e65 3a0a 2020 2020 2020 -> None:. \n-00009470: 2020 7261 6973 6520 4e6f 7449 6d70 6c65 raise NotImple\n-00009480: 6d65 6e74 6564 4572 726f 720a 0a20 2020 mentedError.. \n-00009490: 2064 6566 2064 6f5f 6368 616e 6e65 6c5f def do_channel_\n-000094a0: 6461 7461 2873 656c 662c 2063 6861 6e6e data(self, chann\n-000094b0: 656c 3a20 7374 722c 2064 6174 613a 2062 el: str, data: b\n-000094c0: 7974 6573 2920 2d3e 204e 6f6e 653a 0a20 ytes) -> None:. \n-000094d0: 2020 2020 2020 2072 6169 7365 204e 6f74 raise Not\n-000094e0: 496d 706c 656d 656e 7465 6445 7272 6f72 ImplementedError\n-000094f0: 0a0a 2020 2020 6465 6620 646f 5f6b 696c .. def do_kil\n-00009500: 6c28 7365 6c66 2c20 686f 7374 3a20 2773 l(self, host: 's\n-00009510: 7472 207c 204e 6f6e 6527 2c20 6772 6f75 tr | None', grou\n-00009520: 703a 2027 7374 7220 7c20 4e6f 6e65 272c p: 'str | None',\n-00009530: 206d 6573 7361 6765 3a20 4a73 6f6e 4f62 message: JsonOb\n-00009540: 6a65 6374 2920 2d3e 204e 6f6e 653a 0a20 ject) -> None:. \n-00009550: 2020 2020 2020 2072 6169 7365 204e 6f74 raise Not\n-00009560: 496d 706c 656d 656e 7465 6445 7272 6f72 ImplementedError\n-00009570: 0a0a 2020 2020 2320 696e 7465 7266 6163 .. # interfac\n-00009580: 6520 666f 7220 7365 6e64 696e 6720 6d65 e for sending me\n-00009590: 7373 6167 6573 0a20 2020 2064 6566 2073 ssages. def s\n-000095a0: 656e 645f 6368 616e 6e65 6c5f 6461 7461 end_channel_data\n-000095b0: 2873 656c 662c 2063 6861 6e6e 656c 3a20 (self, channel: \n-000095c0: 7374 722c 2064 6174 613a 2062 7974 6573 str, data: bytes\n-000095d0: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n-000095e0: 2020 2073 656c 662e 726f 7574 6572 2e77 self.router.w\n-000095f0: 7269 7465 5f63 6861 6e6e 656c 5f64 6174 rite_channel_dat\n-00009600: 6128 6368 616e 6e65 6c2c 2064 6174 6129 a(channel, data)\n-00009610: 0a0a 2020 2020 6465 6620 7365 6e64 5f63 .. def send_c\n-00009620: 6861 6e6e 656c 5f63 6f6e 7472 6f6c 280a hannel_control(.\n-00009630: 2020 2020 2020 2020 7365 6c66 2c20 6368 self, ch\n-00009640: 616e 6e65 6c3a 2073 7472 2c20 636f 6d6d annel: str, comm\n-00009650: 616e 643a 2073 7472 2c20 5f6d 7367 3a20 and: str, _msg: \n-00009660: 274a 736f 6e4f 626a 6563 7420 7c20 4e6f 'JsonObject | No\n-00009670: 6e65 272c 202a 2a6b 7761 7267 733a 204a ne', **kwargs: J\n-00009680: 736f 6e56 616c 7565 0a20 2020 2029 202d sonValue. ) -\n-00009690: 3e20 4e6f 6e65 3a0a 2020 2020 2020 2020 > None:. \n-000096a0: 7365 6c66 2e72 6f75 7465 722e 7772 6974 self.router.writ\n-000096b0: 655f 636f 6e74 726f 6c28 5f6d 7367 2c20 e_control(_msg, \n-000096c0: 6368 616e 6e65 6c3d 6368 616e 6e65 6c2c channel=channel,\n-000096d0: 2063 6f6d 6d61 6e64 3d63 6f6d 6d61 6e64 command=command\n-000096e0: 2c20 2a2a 6b77 6172 6773 290a 2020 2020 , **kwargs). \n-000096f0: 2020 2020 6966 2063 6f6d 6d61 6e64 203d if command =\n-00009700: 3d20 2763 6c6f 7365 273a 0a20 2020 2020 = 'close':. \n-00009710: 2020 2020 2020 2073 656c 662e 726f 7574 self.rout\n-00009720: 6572 2e65 6e64 706f 696e 7473 5b73 656c er.endpoints[sel\n-00009730: 665d 2e72 656d 6f76 6528 6368 616e 6e65 f].remove(channe\n-00009740: 6c29 0a20 2020 2020 2020 2020 2020 2073 l). s\n-00009750: 656c 662e 726f 7574 6572 2e64 726f 705f elf.router.drop_\n-00009760: 6368 616e 6e65 6c28 6368 616e 6e65 6c29 channel(channel)\n-00009770: 0a0a 2020 2020 6465 6620 7368 7574 646f .. def shutdo\n-00009780: 776e 5f65 6e64 706f 696e 7428 7365 6c66 wn_endpoint(self\n-00009790: 2c20 5f6d 7367 3a20 274a 736f 6e4f 626a , _msg: 'JsonObj\n-000097a0: 6563 7420 7c20 4e6f 6e65 2720 3d20 4e6f ect | None' = No\n-000097b0: 6e65 2c20 2a2a 6b77 6172 6773 3a20 4a73 ne, **kwargs: Js\n-000097c0: 6f6e 5661 6c75 6529 202d 3e20 4e6f 6e65 onValue) -> None\n-000097d0: 3a0a 2020 2020 2020 2020 7365 6c66 2e72 :. self.r\n-000097e0: 6f75 7465 722e 7368 7574 646f 776e 5f65 outer.shutdown_e\n-000097f0: 6e64 706f 696e 7428 7365 6c66 2c20 5f6d ndpoint(self, _m\n-00009800: 7367 2c20 2a2a 6b77 6172 6773 290a 0a0a sg, **kwargs)...\n-00009810: 636c 6173 7320 526f 7574 696e 6745 7272 class RoutingErr\n-00009820: 6f72 2843 6f63 6b70 6974 5072 6f62 6c65 or(CockpitProble\n-00009830: 6d29 3a0a 2020 2020 7061 7373 0a0a 0a63 m):. pass...c\n-00009840: 6c61 7373 2052 6f75 7469 6e67 5275 6c65 lass RoutingRule\n-00009850: 3a0a 2020 2020 726f 7574 6572 3a20 2752 :. router: 'R\n-00009860: 6f75 7465 7227 0a0a 2020 2020 6465 6620 outer'.. def \n-00009870: 5f5f 696e 6974 5f5f 2873 656c 662c 2072 __init__(self, r\n-00009880: 6f75 7465 723a 2027 526f 7574 6572 2729 outer: 'Router')\n-00009890: 3a0a 2020 2020 2020 2020 7365 6c66 2e72 :. self.r\n-000098a0: 6f75 7465 7220 3d20 726f 7574 6572 0a0a outer = router..\n-000098b0: 2020 2020 6465 6620 6170 706c 795f 7275 def apply_ru\n-000098c0: 6c65 2873 656c 662c 206f 7074 696f 6e73 le(self, options\n-000098d0: 3a20 4a73 6f6e 4f62 6a65 6374 2920 2d3e : JsonObject) ->\n-000098e0: 204f 7074 696f 6e61 6c5b 456e 6470 6f69 Optional[Endpoi\n-000098f0: 6e74 5d3a 0a20 2020 2020 2020 2022 2222 nt]:. \"\"\"\n-00009900: 4368 6563 6b20 6966 2061 2072 6f75 7469 Check if a routi\n-00009910: 6e67 2072 756c 6520 6170 706c 6965 7320 ng rule applies \n-00009920: 746f 2061 2067 6976 656e 2027 6f70 656e to a given 'open\n-00009930: 2720 6d65 7373 6167 652e 0a0a 2020 2020 ' message... \n-00009940: 2020 2020 5468 6973 2073 686f 756c 6420 This should \n-00009950: 696e 7370 6563 7420 7468 6520 6f70 7469 inspect the opti\n-00009960: 6f6e 7320 6469 6374 696f 6e61 7279 2061 ons dictionary a\n-00009970: 6e64 2064 6f20 6f6e 6520 6f66 2074 6865 nd do one of the\n-00009980: 2066 6f6c 6c6f 7769 6e67 2074 6872 6565 following three\n-00009990: 2074 6869 6e67 733a 0a0a 2020 2020 2020 things:.. \n-000099a0: 2020 2020 2020 2d20 7265 7475 726e 2061 - return a\n-000099b0: 6e20 456e 6470 6f69 6e74 2074 6f20 6861 n Endpoint to ha\n-000099c0: 6e64 6c65 2074 6869 7320 6368 616e 6e65 ndle this channe\n-000099d0: 6c0a 2020 2020 2020 2020 2020 2020 2d20 l. - \n-000099e0: 7261 6973 6520 6120 526f 7574 696e 6745 raise a RoutingE\n-000099f0: 7272 6f72 2074 6f20 696e 6469 6361 7465 rror to indicate\n-00009a00: 2074 6861 7420 7468 6520 6f70 656e 2073 that the open s\n-00009a10: 686f 756c 6420 6265 2072 656a 6563 7465 hould be rejecte\n-00009a20: 640a 2020 2020 2020 2020 2020 2020 2d20 d. - \n-00009a30: 7265 7475 726e 204e 6f6e 6520 746f 206c return None to l\n-00009a40: 6574 2074 6865 206e 6578 7420 7275 6c65 et the next rule\n-00009a50: 2072 756e 0a20 2020 2020 2020 2022 2222 run. \"\"\"\n-00009a60: 0a20 2020 2020 2020 2072 6169 7365 204e . raise N\n-00009a70: 6f74 496d 706c 656d 656e 7465 6445 7272 otImplementedErr\n-00009a80: 6f72 0a0a 2020 2020 6465 6620 7368 7574 or.. def shut\n-00009a90: 646f 776e 2873 656c 6629 3a0a 2020 2020 down(self):. \n-00009aa0: 2020 2020 7261 6973 6520 4e6f 7449 6d70 raise NotImp\n-00009ab0: 6c65 6d65 6e74 6564 4572 726f 720a 0a0a lementedError...\n-00009ac0: 636c 6173 7320 526f 7574 6572 2843 6f63 class Router(Coc\n-00009ad0: 6b70 6974 5072 6f74 6f63 6f6c 5365 7276 kpitProtocolServ\n-00009ae0: 6572 293a 0a20 2020 2072 6f75 7469 6e67 er):. routing\n-00009af0: 5f72 756c 6573 3a20 4c69 7374 5b52 6f75 _rules: List[Rou\n-00009b00: 7469 6e67 5275 6c65 5d0a 2020 2020 6f70 tingRule]. op\n-00009b10: 656e 5f63 6861 6e6e 656c 733a 2044 6963 en_channels: Dic\n-00009b20: 745b 7374 722c 2045 6e64 706f 696e 745d t[str, Endpoint]\n-00009b30: 0a20 2020 2065 6e64 706f 696e 7473 3a20 . endpoints: \n-00009b40: 2764 6963 745b 456e 6470 6f69 6e74 2c20 'dict[Endpoint, \n-00009b50: 7365 745b 7374 725d 5d27 0a20 2020 206e set[str]]'. n\n-00009b60: 6f5f 656e 6470 6f69 6e74 733a 2061 7379 o_endpoints: asy\n-00009b70: 6e63 696f 2e45 7665 6e74 2020 2320 7365 ncio.Event # se\n-00009b80: 7420 6966 2065 6e64 706f 696e 7473 2064 t if endpoints d\n-00009b90: 6963 7420 6973 2065 6d70 7479 0a20 2020 ict is empty. \n-00009ba0: 205f 656f 663a 2062 6f6f 6c20 3d20 4661 _eof: bool = Fa\n-00009bb0: 6c73 650a 0a20 2020 2064 6566 205f 5f69 lse.. def __i\n-00009bc0: 6e69 745f 5f28 7365 6c66 2c20 726f 7574 nit__(self, rout\n-00009bd0: 696e 675f 7275 6c65 733a 204c 6973 745b ing_rules: List[\n-00009be0: 526f 7574 696e 6752 756c 655d 293a 0a20 RoutingRule]):. \n-00009bf0: 2020 2020 2020 2066 6f72 2072 756c 6520 for rule \n-00009c00: 696e 2072 6f75 7469 6e67 5f72 756c 6573 in routing_rules\n-00009c10: 3a0a 2020 2020 2020 2020 2020 2020 7275 :. ru\n-00009c20: 6c65 2e72 6f75 7465 7220 3d20 7365 6c66 le.router = self\n-00009c30: 0a20 2020 2020 2020 2073 656c 662e 726f . self.ro\n-00009c40: 7574 696e 675f 7275 6c65 7320 3d20 726f uting_rules = ro\n-00009c50: 7574 696e 675f 7275 6c65 730a 2020 2020 uting_rules. \n-00009c60: 2020 2020 7365 6c66 2e6f 7065 6e5f 6368 self.open_ch\n-00009c70: 616e 6e65 6c73 203d 207b 7d0a 2020 2020 annels = {}. \n-00009c80: 2020 2020 7365 6c66 2e65 6e64 706f 696e self.endpoin\n-00009c90: 7473 203d 207b 7d0a 2020 2020 2020 2020 ts = {}. \n-00009ca0: 7365 6c66 2e6e 6f5f 656e 6470 6f69 6e74 self.no_endpoint\n-00009cb0: 7320 3d20 6173 796e 6369 6f2e 4576 656e s = asyncio.Even\n-00009cc0: 7428 290a 2020 2020 2020 2020 7365 6c66 t(). self\n-00009cd0: 2e6e 6f5f 656e 6470 6f69 6e74 732e 7365 .no_endpoints.se\n-00009ce0: 7428 2920 2023 2061 7420 6669 7273 7420 t() # at first \n-00009cf0: 7468 6572 6520 6172 6520 6e6f 2065 6e64 there are no end\n-00009d00: 706f 696e 7473 0a0a 2020 2020 6465 6620 points.. def \n-00009d10: 6368 6563 6b5f 7275 6c65 7328 7365 6c66 check_rules(self\n-00009d20: 2c20 6f70 7469 6f6e 733a 204a 736f 6e4f , options: JsonO\n-00009d30: 626a 6563 7429 202d 3e20 456e 6470 6f69 bject) -> Endpoi\n-00009d40: 6e74 3a0a 2020 2020 2020 2020 666f 7220 nt:. for \n-00009d50: 7275 6c65 2069 6e20 7365 6c66 2e72 6f75 rule in self.rou\n-00009d60: 7469 6e67 5f72 756c 6573 3a0a 2020 2020 ting_rules:. \n-00009d70: 2020 2020 2020 2020 6c6f 6767 6572 2e64 logger.d\n-00009d80: 6562 7567 2827 2020 6170 706c 7969 6e67 ebug(' applying\n-00009d90: 2072 756c 6520 2573 272c 2072 756c 6529 rule %s', rule)\n-00009da0: 0a20 2020 2020 2020 2020 2020 2065 6e64 . end\n-00009db0: 706f 696e 7420 3d20 7275 6c65 2e61 7070 point = rule.app\n-00009dc0: 6c79 5f72 756c 6528 6f70 7469 6f6e 7329 ly_rule(options)\n-00009dd0: 0a20 2020 2020 2020 2020 2020 2069 6620 . if \n-00009de0: 656e 6470 6f69 6e74 2069 7320 6e6f 7420 endpoint is not \n-00009df0: 4e6f 6e65 3a0a 2020 2020 2020 2020 2020 None:. \n-00009e00: 2020 2020 2020 6c6f 6767 6572 2e64 6562 logger.deb\n-00009e10: 7567 2827 2020 2020 7265 7375 6c74 696e ug(' resultin\n-00009e20: 6720 656e 6470 6f69 6e74 2069 7320 2573 g endpoint is %s\n-00009e30: 272c 2065 6e64 706f 696e 7429 0a20 2020 ', endpoint). \n-00009e40: 2020 2020 2020 2020 2020 2020 2072 6574 ret\n-00009e50: 7572 6e20 656e 6470 6f69 6e74 0a20 2020 urn endpoint. \n-00009e60: 2020 2020 2065 6c73 653a 0a20 2020 2020 else:. \n-00009e70: 2020 2020 2020 206c 6f67 6765 722e 6465 logger.de\n-00009e80: 6275 6728 2720 204e 6f20 7275 6c65 7320 bug(' No rules \n-00009e90: 6d61 7463 6865 6427 290a 2020 2020 2020 matched'). \n-00009ea0: 2020 2020 2020 7261 6973 6520 526f 7574 raise Rout\n-00009eb0: 696e 6745 7272 6f72 2827 6e6f 742d 7375 ingError('not-su\n-00009ec0: 7070 6f72 7465 6427 290a 0a20 2020 2064 pported').. d\n-00009ed0: 6566 2064 726f 705f 6368 616e 6e65 6c28 ef drop_channel(\n-00009ee0: 7365 6c66 2c20 6368 616e 6e65 6c3a 2073 self, channel: s\n-00009ef0: 7472 2920 2d3e 204e 6f6e 653a 0a20 2020 tr) -> None:. \n-00009f00: 2020 2020 2074 7279 3a0a 2020 2020 2020 try:. \n-00009f10: 2020 2020 2020 7365 6c66 2e6f 7065 6e5f self.open_\n-00009f20: 6368 616e 6e65 6c73 2e70 6f70 2863 6861 channels.pop(cha\n-00009f30: 6e6e 656c 290a 2020 2020 2020 2020 2020 nnel). \n-00009f40: 2020 6c6f 6767 6572 2e64 6562 7567 2827 logger.debug('\n-00009f50: 726f 7574 6572 2064 726f 7070 6564 2063 router dropped c\n-00009f60: 6861 6e6e 656c 2025 7327 2c20 6368 616e hannel %s', chan\n-00009f70: 6e65 6c29 0a20 2020 2020 2020 2065 7863 nel). exc\n-00009f80: 6570 7420 4b65 7945 7272 6f72 3a0a 2020 ept KeyError:. \n-00009f90: 2020 2020 2020 2020 2020 6c6f 6767 6572 logger\n-00009fa0: 2e65 7272 6f72 2827 7472 7969 6e67 2074 .error('trying t\n-00009fb0: 6f20 6472 6f70 206e 6f6e 2d65 7869 7374 o drop non-exist\n-00009fc0: 656e 7420 6368 616e 6e65 6c20 2573 2066 ent channel %s f\n-00009fd0: 726f 6d20 2573 272c 2063 6861 6e6e 656c rom %s', channel\n-00009fe0: 2c20 7365 6c66 2e6f 7065 6e5f 6368 616e , self.open_chan\n-00009ff0: 6e65 6c73 290a 0a20 2020 2064 6566 2061 nels).. def a\n-0000a000: 6464 5f65 6e64 706f 696e 7428 7365 6c66 dd_endpoint(self\n-0000a010: 2c20 656e 6470 6f69 6e74 3a20 456e 6470 , endpoint: Endp\n-0000a020: 6f69 6e74 2920 2d3e 204e 6f6e 653a 0a20 oint) -> None:. \n-0000a030: 2020 2020 2020 2073 656c 662e 656e 6470 self.endp\n-0000a040: 6f69 6e74 735b 656e 6470 6f69 6e74 5d20 oints[endpoint] \n-0000a050: 3d20 7365 7428 290a 2020 2020 2020 2020 = set(). \n-0000a060: 7365 6c66 2e6e 6f5f 656e 6470 6f69 6e74 self.no_endpoint\n-0000a070: 732e 636c 6561 7228 290a 0a20 2020 2064 s.clear().. d\n-0000a080: 6566 2073 6875 7464 6f77 6e5f 656e 6470 ef shutdown_endp\n-0000a090: 6f69 6e74 2873 656c 662c 2065 6e64 706f oint(self, endpo\n-0000a0a0: 696e 743a 2045 6e64 706f 696e 742c 205f int: Endpoint, _\n-0000a0b0: 6d73 673a 2027 4a73 6f6e 4f62 6a65 6374 msg: 'JsonObject\n-0000a0c0: 207c 204e 6f6e 6527 203d 204e 6f6e 652c | None' = None,\n-0000a0d0: 202a 2a6b 7761 7267 733a 204a 736f 6e56 **kwargs: JsonV\n-0000a0e0: 616c 7565 2920 2d3e 204e 6f6e 653a 0a20 alue) -> None:. \n-0000a0f0: 2020 2020 2020 2063 6861 6e6e 656c 7320 channels \n-0000a100: 3d20 7365 6c66 2e65 6e64 706f 696e 7473 = self.endpoints\n-0000a110: 2e70 6f70 2865 6e64 706f 696e 7429 0a20 .pop(endpoint). \n-0000a120: 2020 2020 2020 206c 6f67 6765 722e 6465 logger.de\n-0000a130: 6275 6728 2773 6875 7464 6f77 6e5f 656e bug('shutdown_en\n-0000a140: 6470 6f69 6e74 2825 732c 2025 7329 2077 dpoint(%s, %s) w\n-0000a150: 696c 6c20 636c 6f73 6520 2573 272c 2065 ill close %s', e\n-0000a160: 6e64 706f 696e 742c 206b 7761 7267 732c ndpoint, kwargs,\n-0000a170: 2063 6861 6e6e 656c 7329 0a20 2020 2020 channels). \n-0000a180: 2020 2066 6f72 2063 6861 6e6e 656c 2069 for channel i\n-0000a190: 6e20 6368 616e 6e65 6c73 3a0a 2020 2020 n channels:. \n-0000a1a0: 2020 2020 2020 2020 7365 6c66 2e77 7269 self.wri\n-0000a1b0: 7465 5f63 6f6e 7472 6f6c 285f 6d73 672c te_control(_msg,\n-0000a1c0: 2063 6f6d 6d61 6e64 3d27 636c 6f73 6527 command='close'\n-0000a1d0: 2c20 6368 616e 6e65 6c3d 6368 616e 6e65 , channel=channe\n-0000a1e0: 6c2c 202a 2a6b 7761 7267 7329 0a20 2020 l, **kwargs). \n-0000a1f0: 2020 2020 2020 2020 2073 656c 662e 6472 self.dr\n-0000a200: 6f70 5f63 6861 6e6e 656c 2863 6861 6e6e op_channel(chann\n-0000a210: 656c 290a 0a20 2020 2020 2020 2069 6620 el).. if \n-0000a220: 6e6f 7420 7365 6c66 2e65 6e64 706f 696e not self.endpoin\n-0000a230: 7473 3a0a 2020 2020 2020 2020 2020 2020 ts:. \n-0000a240: 7365 6c66 2e6e 6f5f 656e 6470 6f69 6e74 self.no_endpoint\n-0000a250: 732e 7365 7428 290a 0a20 2020 2020 2020 s.set().. \n-0000a260: 2023 2077 6572 6520 7765 2077 6169 7469 # were we waiti\n-0000a270: 6e67 2074 6f20 6578 6974 3f0a 2020 2020 ng to exit?. \n-0000a280: 2020 2020 6966 2073 656c 662e 5f65 6f66 if self._eof\n-0000a290: 3a0a 2020 2020 2020 2020 2020 2020 6c6f :. lo\n-0000a2a0: 6767 6572 2e64 6562 7567 2827 2020 656e gger.debug(' en\n-0000a2b0: 6470 6f69 6e74 7320 7265 6d61 696e 696e dpoints remainin\n-0000a2c0: 673a 2025 7227 2c20 7365 6c66 2e65 6e64 g: %r', self.end\n-0000a2d0: 706f 696e 7473 290a 2020 2020 2020 2020 points). \n-0000a2e0: 2020 2020 6966 206e 6f74 2073 656c 662e if not self.\n-0000a2f0: 656e 6470 6f69 6e74 7320 616e 6420 7365 endpoints and se\n-0000a300: 6c66 2e74 7261 6e73 706f 7274 3a0a 2020 lf.transport:. \n-0000a310: 2020 2020 2020 2020 2020 2020 2020 6c6f lo\n-0000a320: 6767 6572 2e64 6562 7567 2827 2020 636c gger.debug(' cl\n-0000a330: 6f73 6520 7472 616e 7370 6f72 7427 290a ose transport').\n-0000a340: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0000a350: 7365 6c66 2e74 7261 6e73 706f 7274 2e63 self.transport.c\n-0000a360: 6c6f 7365 2829 0a0a 2020 2020 6465 6620 lose().. def \n-0000a370: 646f 5f6b 696c 6c28 7365 6c66 2c20 686f do_kill(self, ho\n-0000a380: 7374 3a20 2773 7472 207c 204e 6f6e 6527 st: 'str | None'\n-0000a390: 2c20 6772 6f75 703a 2027 7374 7220 7c20 , group: 'str | \n-0000a3a0: 4e6f 6e65 272c 206d 6573 7361 6765 3a20 None', message: \n-0000a3b0: 4a73 6f6e 4f62 6a65 6374 2920 2d3e 204e JsonObject) -> N\n-0000a3c0: 6f6e 653a 0a20 2020 2020 2020 2065 6e64 one:. end\n-0000a3d0: 706f 696e 7473 203d 2073 6574 2873 656c points = set(sel\n-0000a3e0: 662e 656e 6470 6f69 6e74 7329 0a20 2020 f.endpoints). \n-0000a3f0: 2020 2020 206c 6f67 6765 722e 6465 6275 logger.debu\n-0000a400: 6728 2764 6f5f 6b69 6c6c 2825 732c 2025 g('do_kill(%s, %\n-0000a410: 7329 2e20 2043 6f6e 7369 6465 7269 6e67 s). Considering\n-0000a420: 2025 6420 656e 6470 6f69 6e74 732e 272c %d endpoints.',\n-0000a430: 2068 6f73 742c 2067 726f 7570 2c20 6c65 host, group, le\n-0000a440: 6e28 656e 6470 6f69 6e74 7329 290a 2020 n(endpoints)). \n-0000a450: 2020 2020 2020 666f 7220 656e 6470 6f69 for endpoi\n-0000a460: 6e74 2069 6e20 656e 6470 6f69 6e74 733a nt in endpoints:\n-0000a470: 0a20 2020 2020 2020 2020 2020 2065 6e64 . end\n-0000a480: 706f 696e 742e 646f 5f6b 696c 6c28 686f point.do_kill(ho\n-0000a490: 7374 2c20 6772 6f75 702c 206d 6573 7361 st, group, messa\n-0000a4a0: 6765 290a 0a20 2020 2064 6566 2063 6861 ge).. def cha\n-0000a4b0: 6e6e 656c 5f63 6f6e 7472 6f6c 5f72 6563 nnel_control_rec\n-0000a4c0: 6569 7665 6428 7365 6c66 2c20 6368 616e eived(self, chan\n-0000a4d0: 6e65 6c3a 2073 7472 2c20 636f 6d6d 616e nel: str, comman\n-0000a4e0: 643a 2073 7472 2c20 6d65 7373 6167 653a d: str, message:\n-0000a4f0: 204a 736f 6e4f 626a 6563 7429 202d 3e20 JsonObject) -> \n-0000a500: 4e6f 6e65 3a0a 2020 2020 2020 2020 2320 None:. # \n-0000a510: 4966 2074 6869 7320 6973 2061 6e20 6f70 If this is an op\n-0000a520: 656e 206d 6573 7361 6765 2074 6865 6e20 en message then \n-0000a530: 7765 206e 6565 6420 746f 2061 7070 6c79 we need to apply\n-0000a540: 2074 6865 2072 6f75 7469 6e67 2072 756c the routing rul\n-0000a550: 6573 2074 6f0a 2020 2020 2020 2020 2320 es to. # \n-0000a560: 6669 6775 7265 206f 7574 2074 6865 2063 figure out the c\n-0000a570: 6f72 7265 6374 2065 6e64 706f 696e 7420 orrect endpoint \n-0000a580: 746f 2063 6f6e 6e65 6374 2e20 2049 6620 to connect. If \n-0000a590: 6974 2773 206e 6f74 2061 6e20 6f70 656e it's not an open\n-0000a5a0: 0a20 2020 2020 2020 2023 206d 6573 7361 . # messa\n-0000a5b0: 6765 2c20 7468 656e 2077 6520 6578 7065 ge, then we expe\n-0000a5c0: 6374 2074 6865 2065 6e64 706f 696e 7420 ct the endpoint \n-0000a5d0: 746f 2061 6c72 6561 6479 2065 7869 7374 to already exist\n-0000a5e0: 2e0a 2020 2020 2020 2020 6966 2063 6f6d .. if com\n-0000a5f0: 6d61 6e64 203d 3d20 276f 7065 6e27 3a0a mand == 'open':.\n-0000a600: 2020 2020 2020 2020 2020 2020 6966 2063 if c\n-0000a610: 6861 6e6e 656c 2069 6e20 7365 6c66 2e6f hannel in self.o\n-0000a620: 7065 6e5f 6368 616e 6e65 6c73 3a0a 2020 pen_channels:. \n-0000a630: 2020 2020 2020 2020 2020 2020 2020 7261 ra\n-0000a640: 6973 6520 436f 636b 7069 7450 726f 746f ise CockpitProto\n-0000a650: 636f 6c45 7272 6f72 2827 6368 616e 6e65 colError('channe\n-0000a660: 6c20 6973 2061 6c72 6561 6479 206f 7065 l is already ope\n-0000a670: 6e27 290a 0a20 2020 2020 2020 2020 2020 n').. \n-0000a680: 2074 7279 3a0a 2020 2020 2020 2020 2020 try:. \n-0000a690: 2020 2020 2020 6c6f 6767 6572 2e64 6562 logger.deb\n-0000a6a0: 7567 2827 5472 7969 6e67 2074 6f20 6669 ug('Trying to fi\n-0000a6b0: 6e64 2065 6e64 706f 696e 7420 666f 7220 nd endpoint for \n-0000a6c0: 6e65 7720 6368 616e 6e65 6c20 2573 2070 new channel %s p\n-0000a6d0: 6179 6c6f 6164 3d25 7327 2c20 6368 616e ayload=%s', chan\n-0000a6e0: 6e65 6c2c 206d 6573 7361 6765 2e67 6574 nel, message.get\n-0000a6f0: 2827 7061 796c 6f61 6427 2929 0a20 2020 ('payload')). \n-0000a700: 2020 2020 2020 2020 2020 2020 2065 6e64 end\n-0000a710: 706f 696e 7420 3d20 7365 6c66 2e63 6865 point = self.che\n-0000a720: 636b 5f72 756c 6573 286d 6573 7361 6765 ck_rules(message\n-0000a730: 290a 2020 2020 2020 2020 2020 2020 6578 ). ex\n-0000a740: 6365 7074 2052 6f75 7469 6e67 4572 726f cept RoutingErro\n-0000a750: 7220 6173 2065 7863 3a0a 2020 2020 2020 r as exc:. \n-0000a760: 2020 2020 2020 2020 2020 7365 6c66 2e77 self.w\n-0000a770: 7269 7465 5f63 6f6e 7472 6f6c 2865 7863 rite_control(exc\n-0000a780: 2e67 6574 5f61 7474 7273 2829 2c20 636f .get_attrs(), co\n-0000a790: 6d6d 616e 643d 2763 6c6f 7365 272c 2063 mmand='close', c\n-0000a7a0: 6861 6e6e 656c 3d63 6861 6e6e 656c 290a hannel=channel).\n-0000a7b0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0000a7c0: 7265 7475 726e 0a0a 2020 2020 2020 2020 return.. \n-0000a7d0: 2020 2020 7365 6c66 2e6f 7065 6e5f 6368 self.open_ch\n-0000a7e0: 616e 6e65 6c73 5b63 6861 6e6e 656c 5d20 annels[channel] \n-0000a7f0: 3d20 656e 6470 6f69 6e74 0a20 2020 2020 = endpoint. \n-0000a800: 2020 2020 2020 2073 656c 662e 656e 6470 self.endp\n-0000a810: 6f69 6e74 735b 656e 6470 6f69 6e74 5d2e oints[endpoint].\n-0000a820: 6164 6428 6368 616e 6e65 6c29 0a20 2020 add(channel). \n-0000a830: 2020 2020 2065 6c73 653a 0a20 2020 2020 else:. \n-0000a840: 2020 2020 2020 2074 7279 3a0a 2020 2020 try:. \n-0000a850: 2020 2020 2020 2020 2020 2020 656e 6470 endp\n-0000a860: 6f69 6e74 203d 2073 656c 662e 6f70 656e oint = self.open\n-0000a870: 5f63 6861 6e6e 656c 735b 6368 616e 6e65 _channels[channe\n-0000a880: 6c5d 0a20 2020 2020 2020 2020 2020 2065 l]. e\n-0000a890: 7863 6570 7420 4b65 7945 7272 6f72 3a0a xcept KeyError:.\n-0000a8a0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0000a8b0: 2320 7365 6e64 696e 6720 746f 2061 206e # sending to a n\n-0000a8c0: 6f6e 2d65 7869 7374 656e 7420 6368 616e on-existent chan\n-0000a8d0: 6e65 6c20 6361 6e20 6861 7070 656e 2064 nel can happen d\n-0000a8e0: 7565 2074 6f20 7261 6365 7320 616e 6420 ue to races and \n-0000a8f0: 6973 206e 6f74 2061 6e20 6572 726f 720a is not an error.\n-0000a900: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0000a910: 7265 7475 726e 0a0a 2020 2020 2020 2020 return.. \n-0000a920: 2320 4174 2074 6869 7320 706f 696e 742c # At this point,\n-0000a930: 2077 6520 6861 7665 2074 6865 2065 6e64 we have the end\n-0000a940: 706f 696e 742e 2020 526f 7574 6520 7468 point. Route th\n-0000a950: 6520 6d65 7373 6167 652e 0a20 2020 2020 e message.. \n-0000a960: 2020 2065 6e64 706f 696e 742e 646f 5f63 endpoint.do_c\n-0000a970: 6861 6e6e 656c 5f63 6f6e 7472 6f6c 2863 hannel_control(c\n-0000a980: 6861 6e6e 656c 2c20 636f 6d6d 616e 642c hannel, command,\n-0000a990: 206d 6573 7361 6765 290a 0a20 2020 2064 message).. d\n-0000a9a0: 6566 2063 6861 6e6e 656c 5f64 6174 615f ef channel_data_\n-0000a9b0: 7265 6365 6976 6564 2873 656c 662c 2063 received(self, c\n-0000a9c0: 6861 6e6e 656c 3a20 7374 722c 2064 6174 hannel: str, dat\n-0000a9d0: 613a 2062 7974 6573 2920 2d3e 204e 6f6e a: bytes) -> Non\n-0000a9e0: 653a 0a20 2020 2020 2020 2074 7279 3a0a e:. try:.\n-0000a9f0: 2020 2020 2020 2020 2020 2020 656e 6470 endp\n-0000aa00: 6f69 6e74 203d 2073 656c 662e 6f70 656e oint = self.open\n-0000aa10: 5f63 6861 6e6e 656c 735b 6368 616e 6e65 _channels[channe\n-0000aa20: 6c5d 0a20 2020 2020 2020 2065 7863 6570 l]. excep\n-0000aa30: 7420 4b65 7945 7272 6f72 3a0a 2020 2020 t KeyError:. \n-0000aa40: 2020 2020 2020 2020 7265 7475 726e 0a0a return..\n-0000aa50: 2020 2020 2020 2020 656e 6470 6f69 6e74 endpoint\n-0000aa60: 2e64 6f5f 6368 616e 6e65 6c5f 6461 7461 .do_channel_data\n-0000aa70: 2863 6861 6e6e 656c 2c20 6461 7461 290a (channel, data).\n-0000aa80: 0a20 2020 2064 6566 2065 6f66 5f72 6563 . def eof_rec\n-0000aa90: 6569 7665 6428 7365 6c66 2920 2d3e 2062 eived(self) -> b\n-0000aaa0: 6f6f 6c3a 0a20 2020 2020 2020 206c 6f67 ool:. log\n-0000aab0: 6765 722e 6465 6275 6728 2765 6f66 5f72 ger.debug('eof_r\n-0000aac0: 6563 6569 7665 6428 2572 2927 2c20 7365 eceived(%r)', se\n-0000aad0: 6c66 290a 0a20 2020 2020 2020 2065 6e64 lf).. end\n-0000aae0: 706f 696e 7473 203d 2073 6574 2873 656c points = set(sel\n-0000aaf0: 662e 656e 6470 6f69 6e74 7329 0a20 2020 f.endpoints). \n-0000ab00: 2020 2020 2066 6f72 2065 6e64 706f 696e for endpoin\n-0000ab10: 7420 696e 2065 6e64 706f 696e 7473 3a0a t in endpoints:.\n-0000ab20: 2020 2020 2020 2020 2020 2020 656e 6470 endp\n-0000ab30: 6f69 6e74 2e64 6f5f 636c 6f73 6528 290a oint.do_close().\n-0000ab40: 0a20 2020 2020 2020 2073 656c 662e 5f65 . self._e\n-0000ab50: 6f66 203d 2054 7275 650a 2020 2020 2020 of = True. \n-0000ab60: 2020 6c6f 6767 6572 2e64 6562 7567 2827 logger.debug('\n-0000ab70: 2020 656e 6470 6f69 6e74 7320 7265 6d61 endpoints rema\n-0000ab80: 696e 696e 673a 2025 7227 2c20 7365 6c66 ining: %r', self\n-0000ab90: 2e65 6e64 706f 696e 7473 290a 2020 2020 .endpoints). \n-0000aba0: 2020 2020 7265 7475 726e 2062 6f6f 6c28 return bool(\n-0000abb0: 7365 6c66 2e65 6e64 706f 696e 7473 290a self.endpoints).\n-0000abc0: 0a20 2020 205f 636f 6d6d 756e 6963 6174 . _communicat\n-0000abd0: 696f 6e5f 646f 6e65 3a20 4f70 7469 6f6e ion_done: Option\n-0000abe0: 616c 5b61 7379 6e63 696f 2e46 7574 7572 al[asyncio.Futur\n-0000abf0: 655d 203d 204e 6f6e 650a 0a20 2020 2064 e] = None.. d\n-0000ac00: 6566 2064 6f5f 636c 6f73 6564 2873 656c ef do_closed(sel\n-0000ac10: 662c 2065 7863 3a20 4f70 7469 6f6e 616c f, exc: Optional\n-0000ac20: 5b45 7863 6570 7469 6f6e 5d29 202d 3e20 [Exception]) -> \n-0000ac30: 4e6f 6e65 3a0a 2020 2020 2020 2020 2320 None:. # \n-0000ac40: 4966 2077 6520 6469 646e 2774 2073 656e If we didn't sen\n-0000ac50: 6420 454f 4620 7965 742c 2064 6f20 6974 d EOF yet, do it\n-0000ac60: 206e 6f77 2e0a 2020 2020 2020 2020 6966 now.. if\n-0000ac70: 206e 6f74 2073 656c 662e 5f65 6f66 3a0a not self._eof:.\n-0000ac80: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n-0000ac90: 2e65 6f66 5f72 6563 6569 7665 6428 290a .eof_received().\n-0000aca0: 0a20 2020 2020 2020 2069 6620 7365 6c66 . if self\n-0000acb0: 2e5f 636f 6d6d 756e 6963 6174 696f 6e5f ._communication_\n-0000acc0: 646f 6e65 2069 7320 6e6f 7420 4e6f 6e65 done is not None\n-0000acd0: 3a0a 2020 2020 2020 2020 2020 2020 6966 :. if\n-0000ace0: 2065 7863 2069 7320 4e6f 6e65 3a0a 2020 exc is None:. \n-0000acf0: 2020 2020 2020 2020 2020 2020 2020 7365 se\n-0000ad00: 6c66 2e5f 636f 6d6d 756e 6963 6174 696f lf._communicatio\n-0000ad10: 6e5f 646f 6e65 2e73 6574 5f72 6573 756c n_done.set_resul\n-0000ad20: 7428 4e6f 6e65 290a 2020 2020 2020 2020 t(None). \n-0000ad30: 2020 2020 656c 7365 3a0a 2020 2020 2020 else:. \n-0000ad40: 2020 2020 2020 2020 2020 7365 6c66 2e5f self._\n-0000ad50: 636f 6d6d 756e 6963 6174 696f 6e5f 646f communication_do\n-0000ad60: 6e65 2e73 6574 5f65 7863 6570 7469 6f6e ne.set_exception\n-0000ad70: 2865 7863 290a 0a20 2020 2061 7379 6e63 (exc).. async\n-0000ad80: 2064 6566 2063 6f6d 6d75 6e69 6361 7465 def communicate\n-0000ad90: 2873 656c 6629 202d 3e20 4e6f 6e65 3a0a (self) -> None:.\n-0000ada0: 2020 2020 2020 2020 2222 2257 6169 7420 \"\"\"Wait \n-0000adb0: 756e 7469 6c20 636f 6d6d 756e 6963 6174 until communicat\n-0000adc0: 696f 6e20 6973 2063 6f6d 706c 6574 6520 ion is complete \n-0000add0: 6f6e 2074 6865 2072 6f75 7465 7220 616e on the router an\n-0000ade0: 6420 616c 6c20 656e 6470 6f69 6e74 7320 d all endpoints \n-0000adf0: 6172 6520 646f 6e65 2e22 2222 0a20 2020 are done.\"\"\". \n-0000ae00: 2020 2020 2061 7373 6572 7420 7365 6c66 assert self\n-0000ae10: 2e5f 636f 6d6d 756e 6963 6174 696f 6e5f ._communication_\n-0000ae20: 646f 6e65 2069 7320 4e6f 6e65 0a20 2020 done is None. \n-0000ae30: 2020 2020 2073 656c 662e 5f63 6f6d 6d75 self._commu\n-0000ae40: 6e69 6361 7469 6f6e 5f64 6f6e 6520 3d20 nication_done = \n-0000ae50: 6173 796e 6369 6f2e 6765 745f 7275 6e6e asyncio.get_runn\n-0000ae60: 696e 675f 6c6f 6f70 2829 2e63 7265 6174 ing_loop().creat\n-0000ae70: 655f 6675 7475 7265 2829 0a20 2020 2020 e_future(). \n-0000ae80: 2020 2074 7279 3a0a 2020 2020 2020 2020 try:. \n-0000ae90: 2020 2020 6177 6169 7420 7365 6c66 2e5f await self._\n-0000aea0: 636f 6d6d 756e 6963 6174 696f 6e5f 646f communication_do\n-0000aeb0: 6e65 0a20 2020 2020 2020 2065 7863 6570 ne. excep\n-0000aec0: 7420 2842 726f 6b65 6e50 6970 6545 7272 t (BrokenPipeErr\n-0000aed0: 6f72 2c20 436f 6e6e 6563 7469 6f6e 5265 or, ConnectionRe\n-0000aee0: 7365 7445 7272 6f72 293a 0a20 2020 2020 setError):. \n-0000aef0: 2020 2020 2020 2070 6173 7320 2023 2074 pass # t\n-0000af00: 6865 7365 2061 7265 206e 6f72 6d61 6c20 hese are normal \n-0000af10: 6f63 6375 7272 656e 6365 7320 7768 656e occurrences when\n-0000af20: 2063 6c6f 7365 6420 6672 6f6d 2074 6865 closed from the\n-0000af30: 206f 7468 6572 2073 6964 650a 2020 2020 other side. \n-0000af40: 2020 2020 6669 6e61 6c6c 793a 0a20 2020 finally:. \n-0000af50: 2020 2020 2020 2020 2073 656c 662e 5f63 self._c\n-0000af60: 6f6d 6d75 6e69 6361 7469 6f6e 5f64 6f6e ommunication_don\n-0000af70: 6520 3d20 4e6f 6e65 0a0a 2020 2020 2020 e = None.. \n-0000af80: 2020 2020 2020 2320 496e 2061 6e20 6f72 # In an or\n-0000af90: 6465 726c 7920 6578 6974 2c20 7468 6973 derly exit, this\n-0000afa0: 2069 7320 616c 7265 6164 7920 646f 6e65 is already done\n-0000afb0: 2c20 6275 7420 696e 2063 6173 6520 6974 , but in case it\n-0000afc0: 2077 6173 6e27 740a 2020 2020 2020 2020 wasn't. \n-0000afd0: 2020 2020 2320 6f72 6465 726c 792c 2077 # orderly, w\n-0000afe0: 6520 6e65 6564 2074 6f20 6d61 6b65 2073 e need to make s\n-0000aff0: 7572 6520 7468 6520 656e 6470 6f69 6e74 ure the endpoint\n-0000b000: 7320 7368 7574 2064 6f77 6e20 616e 7977 s shut down anyw\n-0000b010: 6179 2e2e 2e0a 2020 2020 2020 2020 2020 ay.... \n-0000b020: 2020 6177 6169 7420 7365 6c66 2e6e 6f5f await self.no_\n-0000b030: 656e 6470 6f69 6e74 732e 7761 6974 2829 endpoints.wait()\n-0000b040: 0a27 2727 2c0a 2020 2763 6f63 6b70 6974 .''',. 'cockpit\n-0000b050: 2f62 6569 626f 6f74 2e70 7927 3a20 6272 /beiboot.py': br\n-0000b060: 2727 2723 2054 6869 7320 6669 6c65 2069 '''# This file i\n-0000b070: 7320 7061 7274 206f 6620 436f 636b 7069 s part of Cockpi\n-0000b080: 742e 0a23 0a23 2043 6f70 7972 6967 6874 t..#.# Copyright\n-0000b090: 2028 4329 2032 3032 3220 5265 6420 4861 (C) 2022 Red Ha\n-0000b0a0: 742c 2049 6e63 2e0a 230a 2320 5468 6973 t, Inc..#.# This\n-0000b0b0: 2070 726f 6772 616d 2069 7320 6672 6565 program is free\n-0000b0c0: 2073 6f66 7477 6172 653a 2079 6f75 2063 software: you c\n-0000b0d0: 616e 2072 6564 6973 7472 6962 7574 6520 an redistribute \n-0000b0e0: 6974 2061 6e64 2f6f 7220 6d6f 6469 6679 it and/or modify\n-0000b0f0: 0a23 2069 7420 756e 6465 7220 7468 6520 .# it under the \n-0000b100: 7465 726d 7320 6f66 2074 6865 2047 4e55 terms of the GNU\n-0000b110: 2047 656e 6572 616c 2050 7562 6c69 6320 General Public \n-0000b120: 4c69 6365 6e73 6520 6173 2070 7562 6c69 License as publi\n-0000b130: 7368 6564 2062 790a 2320 7468 6520 4672 shed by.# the Fr\n-0000b140: 6565 2053 6f66 7477 6172 6520 466f 756e ee Software Foun\n-0000b150: 6461 7469 6f6e 2c20 6569 7468 6572 2076 dation, either v\n-0000b160: 6572 7369 6f6e 2033 206f 6620 7468 6520 ersion 3 of the \n-0000b170: 4c69 6365 6e73 652c 206f 720a 2320 2861 License, or.# (a\n-0000b180: 7420 796f 7572 206f 7074 696f 6e29 2061 t your option) a\n-0000b190: 6e79 206c 6174 6572 2076 6572 7369 6f6e ny later version\n-0000b1a0: 2e0a 230a 2320 5468 6973 2070 726f 6772 ..#.# This progr\n-0000b1b0: 616d 2069 7320 6469 7374 7269 6275 7465 am is distribute\n-0000b1c0: 6420 696e 2074 6865 2068 6f70 6520 7468 d in the hope th\n-0000b1d0: 6174 2069 7420 7769 6c6c 2062 6520 7573 at it will be us\n-0000b1e0: 6566 756c 2c0a 2320 6275 7420 5749 5448 eful,.# but WITH\n-0000b1f0: 4f55 5420 414e 5920 5741 5252 414e 5459 OUT ANY WARRANTY\n-0000b200: 3b20 7769 7468 6f75 7420 6576 656e 2074 ; without even t\n-0000b210: 6865 2069 6d70 6c69 6564 2077 6172 7261 he implied warra\n-0000b220: 6e74 7920 6f66 0a23 204d 4552 4348 414e nty of.# MERCHAN\n-0000b230: 5441 4249 4c49 5459 206f 7220 4649 544e TABILITY or FITN\n-0000b240: 4553 5320 464f 5220 4120 5041 5254 4943 ESS FOR A PARTIC\n-0000b250: 554c 4152 2050 5552 504f 5345 2e20 2053 ULAR PURPOSE. S\n-0000b260: 6565 2074 6865 0a23 2047 4e55 2047 656e ee the.# GNU Gen\n-0000b270: 6572 616c 2050 7562 6c69 6320 4c69 6365 eral Public Lice\n-0000b280: 6e73 6520 666f 7220 6d6f 7265 2064 6574 nse for more det\n-0000b290: 6169 6c73 2e0a 230a 2320 596f 7520 7368 ails..#.# You sh\n-0000b2a0: 6f75 6c64 2068 6176 6520 7265 6365 6976 ould have receiv\n-0000b2b0: 6564 2061 2063 6f70 7920 6f66 2074 6865 ed a copy of the\n-0000b2c0: 2047 4e55 2047 656e 6572 616c 2050 7562 GNU General Pub\n-0000b2d0: 6c69 6320 4c69 6365 6e73 650a 2320 616c lic License.# al\n-0000b2e0: 6f6e 6720 7769 7468 2074 6869 7320 7072 ong with this pr\n-0000b2f0: 6f67 7261 6d2e 2020 4966 206e 6f74 2c20 ogram. If not, \n-0000b300: 7365 6520 3c68 7474 7073 3a2f 2f77 7777 see ...import arg\n-0000b330: 7061 7273 650a 696d 706f 7274 2061 7379 parse.import asy\n-0000b340: 6e63 696f 0a69 6d70 6f72 7420 6261 7365 ncio.import base\n-0000b350: 3634 0a69 6d70 6f72 7420 696d 706f 7274 64.import import\n-0000b360: 6c69 622e 7265 736f 7572 6365 730a 696d lib.resources.im\n-0000b370: 706f 7274 206c 6f67 6769 6e67 0a69 6d70 port logging.imp\n-0000b380: 6f72 7420 6f73 0a69 6d70 6f72 7420 7368 ort os.import sh\n-0000b390: 6c65 780a 6672 6f6d 2070 6174 686c 6962 lex.from pathlib\n-0000b3a0: 2069 6d70 6f72 7420 5061 7468 0a66 726f import Path.fro\n-0000b3b0: 6d20 7479 7069 6e67 2069 6d70 6f72 7420 m typing import \n-0000b3c0: 4469 6374 2c20 4974 6572 6162 6c65 2c20 Dict, Iterable, \n-0000b3d0: 4f70 7469 6f6e 616c 2c20 5365 7175 656e Optional, Sequen\n-0000b3e0: 6365 0a0a 6672 6f6d 2063 6f63 6b70 6974 ce..from cockpit\n-0000b3f0: 2069 6d70 6f72 7420 706f 6c79 6669 6c6c import polyfill\n-0000b400: 730a 6672 6f6d 2063 6f63 6b70 6974 2e5f s.from cockpit._\n-0000b410: 7665 6e64 6f72 2069 6d70 6f72 7420 6665 vendor import fe\n-0000b420: 726e 790a 6672 6f6d 2063 6f63 6b70 6974 rny.from cockpit\n-0000b430: 2e5f 7665 6e64 6f72 2e62 6569 2069 6d70 ._vendor.bei imp\n-0000b440: 6f72 7420 626f 6f74 6c6f 6164 6572 0a66 ort bootloader.f\n-0000b450: 726f 6d20 636f 636b 7069 742e 6265 6970 rom cockpit.beip\n-0000b460: 6163 6b20 696d 706f 7274 2042 7269 6467 ack import Bridg\n-0000b470: 6542 6569 626f 6f74 4865 6c70 6572 0a66 eBeibootHelper.f\n-0000b480: 726f 6d20 636f 636b 7069 742e 6272 6964 rom cockpit.brid\n-0000b490: 6765 2069 6d70 6f72 7420 7365 7475 705f ge import setup_\n-0000b4a0: 6c6f 6767 696e 670a 6672 6f6d 2063 6f63 logging.from coc\n-0000b4b0: 6b70 6974 2e63 6861 6e6e 656c 2069 6d70 kpit.channel imp\n-0000b4c0: 6f72 7420 4368 616e 6e65 6c52 6f75 7469 ort ChannelRouti\n-0000b4d0: 6e67 5275 6c65 0a66 726f 6d20 636f 636b ngRule.from cock\n-0000b4e0: 7069 742e 6368 616e 6e65 6c73 2069 6d70 pit.channels imp\n-0000b4f0: 6f72 7420 5061 636b 6167 6573 4368 616e ort PackagesChan\n-0000b500: 6e65 6c0a 6672 6f6d 2063 6f63 6b70 6974 nel.from cockpit\n-0000b510: 2e6a 736f 6e75 7469 6c20 696d 706f 7274 .jsonutil import\n-0000b520: 204a 736f 6e4f 626a 6563 740a 6672 6f6d JsonObject.from\n-0000b530: 2063 6f63 6b70 6974 2e70 6163 6b61 6765 cockpit.package\n-0000b540: 7320 696d 706f 7274 2050 6163 6b61 6765 s import Package\n-0000b550: 732c 2050 6163 6b61 6765 734c 6f61 6465 s, PackagesLoade\n-0000b560: 722c 2070 6174 6368 5f6c 6962 6578 6563 r, patch_libexec\n-0000b570: 6469 720a 6672 6f6d 2063 6f63 6b70 6974 dir.from cockpit\n-0000b580: 2e70 6565 7220 696d 706f 7274 2050 6565 .peer import Pee\n-0000b590: 720a 6672 6f6d 2063 6f63 6b70 6974 2e70 r.from cockpit.p\n-0000b5a0: 726f 746f 636f 6c20 696d 706f 7274 2043 rotocol import C\n-0000b5b0: 6f63 6b70 6974 5072 6f62 6c65 6d0a 6672 ockpitProblem.fr\n-0000b5c0: 6f6d 2063 6f63 6b70 6974 2e72 6f75 7465 om cockpit.route\n-0000b5d0: 7220 696d 706f 7274 2052 6f75 7465 722c r import Router,\n-0000b5e0: 2052 6f75 7469 6e67 5275 6c65 0a66 726f RoutingRule.fro\n-0000b5f0: 6d20 636f 636b 7069 742e 7472 616e 7370 m cockpit.transp\n-0000b600: 6f72 7473 2069 6d70 6f72 7420 5374 6469 orts import Stdi\n-0000b610: 6f54 7261 6e73 706f 7274 0a0a 6c6f 6767 oTransport..logg\n-0000b620: 6572 203d 206c 6f67 6769 6e67 2e67 6574 er = logging.get\n-0000b630: 4c6f 6767 6572 2827 636f 636b 7069 742e Logger('cockpit.\n-0000b640: 6265 6962 6f6f 7427 290a 0a0a 6465 6620 beiboot')...def \n-0000b650: 656e 7375 7265 5f66 6572 6e79 5f61 736b ensure_ferny_ask\n-0000b660: 7061 7373 2829 202d 3e20 5061 7468 3a0a pass() -> Path:.\n-0000b670: 2020 2020 2222 2243 7265 6174 6520 6173 \"\"\"Create as\n-0000b680: 6b70 6173 7320 6578 6563 7574 6162 6c65 kpass executable\n-0000b690: 0a0a 2020 2020 5765 206e 6565 6420 7468 .. We need th\n-0000b6a0: 6973 2066 6f72 2074 6865 2066 6c61 7470 is for the flatp\n-0000b6b0: 616b 3a20 7373 6820 616e 6420 7468 7573 ak: ssh and thus\n-0000b6c0: 2074 6865 2061 736b 7061 7373 2070 726f the askpass pro\n-0000b6d0: 6772 616d 2072 756e 206f 6e20 7468 6520 gram run on the \n-0000b6e0: 686f 7374 2028 7669 6120 666c 6174 7061 host (via flatpa\n-0000b6f0: 6b2d 7370 6177 6e29 2c0a 2020 2020 6e6f k-spawn),. no\n-0000b700: 7420 7468 6520 666c 6174 7061 6b2e 2054 t the flatpak. T\n-0000b710: 6875 7320 7765 2063 616e 6e6f 7420 7573 hus we cannot us\n-0000b720: 6520 7468 6520 7368 6970 7065 6420 636f e the shipped co\n-0000b730: 636b 7069 742d 6173 6b70 6173 7320 7072 ckpit-askpass pr\n-0000b740: 6f67 7261 6d2e 0a20 2020 2022 2222 0a20 ogram.. \"\"\". \n-0000b750: 2020 2073 7263 5f70 6174 6820 3d20 696d src_path = im\n-0000b760: 706f 7274 6c69 622e 7265 736f 7572 6365 portlib.resource\n-0000b770: 732e 6669 6c65 7328 6665 726e 792e 5f5f s.files(ferny.__\n-0000b780: 6e61 6d65 5f5f 2920 2f20 2769 6e74 6572 name__) / 'inter\n-0000b790: 6163 7469 6f6e 5f63 6c69 656e 742e 7079 action_client.py\n-0000b7a0: 270a 2020 2020 7372 635f 6461 7461 203d '. src_data =\n-0000b7b0: 2073 7263 5f70 6174 682e 7265 6164 5f62 src_path.read_b\n-0000b7c0: 7974 6573 2829 0a0a 2020 2020 2320 4372 ytes().. # Cr\n-0000b7d0: 6561 7465 2074 6865 2066 696c 6520 696e eate the file in\n-0000b7e0: 2024 5844 475f 4341 4348 455f 484f 4d45 $XDG_CACHE_HOME\n-0000b7f0: 2c20 6f6e 6520 6f66 2074 6865 2066 6577 , one of the few\n-0000b800: 206c 6f63 6174 696f 6e73 2074 6861 7420 locations that \n-0000b810: 6120 666c 6174 7061 6b20 6361 6e20 7772 a flatpak can wr\n-0000b820: 6974 6520 746f 0a20 2020 2078 6467 5f63 ite to. xdg_c\n-0000b830: 6163 6865 5f68 6f6d 6520 3d20 6f73 2e65 ache_home = os.e\n-0000b840: 6e76 6972 6f6e 2e67 6574 2827 5844 475f nviron.get('XDG_\n-0000b850: 4341 4348 455f 484f 4d45 2729 0a20 2020 CACHE_HOME'). \n-0000b860: 2069 6620 7864 675f 6361 6368 655f 686f if xdg_cache_ho\n-0000b870: 6d65 2069 7320 4e6f 6e65 3a0a 2020 2020 me is None:. \n-0000b880: 2020 2020 7864 675f 6361 6368 655f 686f xdg_cache_ho\n-0000b890: 6d65 203d 206f 732e 7061 7468 2e65 7870 me = os.path.exp\n-0000b8a0: 616e 6475 7365 7228 277e 2f2e 6361 6368 anduser('~/.cach\n-0000b8b0: 6527 290a 2020 2020 6f73 2e6d 616b 6564 e'). os.maked\n-0000b8c0: 6972 7328 7864 675f 6361 6368 655f 686f irs(xdg_cache_ho\n-0000b8d0: 6d65 2c20 6578 6973 745f 6f6b 3d54 7275 me, exist_ok=Tru\n-0000b8e0: 6529 0a20 2020 2064 6573 745f 7061 7468 e). dest_path\n-0000b8f0: 203d 2050 6174 6828 7864 675f 6361 6368 = Path(xdg_cach\n-0000b900: 655f 686f 6d65 2c20 2763 6f63 6b70 6974 e_home, 'cockpit\n-0000b910: 2d63 6c69 656e 742d 6173 6b70 6173 7327 -client-askpass'\n-0000b920: 290a 0a20 2020 206c 6f67 6765 722e 6465 ).. logger.de\n-0000b930: 6275 6728 2243 6865 636b 696e 6720 6966 bug(\"Checking if\n-0000b940: 2025 7320 6578 6973 7473 2e2e 2e22 2c20 %s exists...\", \n-0000b950: 6465 7374 5f70 6174 6829 0a0a 2020 2020 dest_path).. \n-0000b960: 2320 4368 6563 6b20 6669 7273 7420 746f # Check first to\n-0000b970: 2073 6565 2069 6620 7765 2061 6c72 6561 see if we alrea\n-0000b980: 6479 2077 726f 7465 2074 6865 2063 7572 dy wrote the cur\n-0000b990: 7265 6e74 2076 6572 7369 6f6e 0a20 2020 rent version. \n-0000b9a0: 2074 7279 3a0a 2020 2020 2020 2020 6966 try:. if\n-0000b9b0: 2064 6573 745f 7061 7468 2e72 6561 645f dest_path.read_\n-0000b9c0: 6279 7465 7328 2920 213d 2073 7263 5f64 bytes() != src_d\n-0000b9d0: 6174 613a 0a20 2020 2020 2020 2020 2020 ata:. \n-0000b9e0: 206c 6f67 6765 722e 6465 6275 6728 2220 logger.debug(\" \n-0000b9f0: 202e 2e2e 2069 7420 6578 6973 7473 2062 ... it exists b\n-0000ba00: 7574 2069 7320 6e6f 7420 7468 6520 7361 ut is not the sa\n-0000ba10: 6d65 2076 6572 7369 6f6e 2e2e 2e22 290a me version...\").\n-0000ba20: 2020 2020 2020 2020 2020 2020 7261 6973 rais\n-0000ba30: 6520 5661 6c75 6545 7272 6f72 0a20 2020 e ValueError. \n-0000ba40: 2020 2020 2069 6620 6e6f 7420 6465 7374 if not dest\n-0000ba50: 5f70 6174 682e 7374 6174 2829 2e73 745f _path.stat().st_\n-0000ba60: 6d6f 6465 2026 2030 6f31 3030 3a0a 2020 mode & 0o100:. \n-0000ba70: 2020 2020 2020 2020 2020 6c6f 6767 6572 logger\n-0000ba80: 2e64 6562 7567 2822 2020 2e2e 2e20 6974 .debug(\" ... it\n-0000ba90: 2068 6173 2074 6865 2063 6f72 7265 6374 has the correct\n-0000baa0: 2063 6f6e 7465 6e74 732c 2062 7574 2069 contents, but i\n-0000bab0: 7320 6e6f 7420 6578 6563 7574 6162 6c65 s not executable\n-0000bac0: 2e2e 2e22 290a 2020 2020 2020 2020 2020 ...\"). \n-0000bad0: 2020 7261 6973 6520 5661 6c75 6545 7272 raise ValueErr\n-0000bae0: 6f72 0a20 2020 2065 7863 6570 7420 2846 or. except (F\n-0000baf0: 696c 654e 6f74 466f 756e 6445 7272 6f72 ileNotFoundError\n-0000bb00: 2c20 5661 6c75 6545 7272 6f72 293a 0a20 , ValueError):. \n-0000bb10: 2020 2020 2020 206c 6f67 6765 722e 6465 logger.de\n-0000bb20: 6275 6728 2220 202e 2e2e 2077 7269 7469 bug(\" ... writi\n-0000bb30: 6e67 2063 6f6e 7465 6e74 732e 2229 0a20 ng contents.\"). \n-0000bb40: 2020 2020 2020 2064 6573 745f 7061 7468 dest_path\n-0000bb50: 2e77 7269 7465 5f62 7974 6573 2873 7263 .write_bytes(src\n-0000bb60: 5f64 6174 6129 0a20 2020 2020 2020 2064 _data). d\n-0000bb70: 6573 745f 7061 7468 2e63 686d 6f64 2830 est_path.chmod(0\n-0000bb80: 6f37 3030 290a 0a20 2020 2072 6574 7572 o700).. retur\n-0000bb90: 6e20 6465 7374 5f70 6174 680a 0a0a 6465 n dest_path...de\n-0000bba0: 6620 6765 745f 696e 7465 7265 7374 696e f get_interestin\n-0000bbb0: 675f 6669 6c65 7328 2920 2d3e 2049 7465 g_files() -> Ite\n-0000bbc0: 7261 626c 655b 7374 725d 3a0a 2020 2020 rable[str]:. \n-0000bbd0: 666f 7220 6d61 6e69 6665 7374 2069 6e20 for manifest in \n-0000bbe0: 5061 636b 6167 6573 4c6f 6164 6572 2e6c PackagesLoader.l\n-0000bbf0: 6f61 645f 6d61 6e69 6665 7374 7328 293a oad_manifests():\n-0000bc00: 0a20 2020 2020 2020 2066 6f72 2063 6f6e . for con\n-0000bc10: 6469 7469 6f6e 2069 6e20 6d61 6e69 6665 dition in manife\n-0000bc20: 7374 2e63 6f6e 6469 7469 6f6e 733a 0a20 st.conditions:. \n-0000bc30: 2020 2020 2020 2020 2020 2069 6620 636f if co\n-0000bc40: 6e64 6974 696f 6e2e 6e61 6d65 2069 6e20 ndition.name in \n-0000bc50: 2827 7061 7468 2d65 7869 7374 7327 2c20 ('path-exists', \n-0000bc60: 2770 6174 682d 6e6f 742d 6578 6973 7473 'path-not-exists\n-0000bc70: 2729 2061 6e64 2069 7369 6e73 7461 6e63 ') and isinstanc\n-0000bc80: 6528 636f 6e64 6974 696f 6e2e 7661 6c75 e(condition.valu\n-0000bc90: 652c 2073 7472 293a 0a20 2020 2020 2020 e, str):. \n-0000bca0: 2020 2020 2020 2020 2079 6965 6c64 2063 yield c\n-0000bcb0: 6f6e 6469 7469 6f6e 2e76 616c 7565 0a0a ondition.value..\n-0000bcc0: 0a63 6c61 7373 2050 726f 7879 5061 636b .class ProxyPack\n-0000bcd0: 6167 6573 4c6f 6164 6572 2850 6163 6b61 agesLoader(Packa\n-0000bce0: 6765 734c 6f61 6465 7229 3a0a 2020 2020 gesLoader):. \n-0000bcf0: 6669 6c65 5f73 7461 7475 733a 2044 6963 file_status: Dic\n-0000bd00: 745b 7374 722c 2062 6f6f 6c5d 0a0a 2020 t[str, bool].. \n-0000bd10: 2020 6465 6620 6368 6563 6b5f 636f 6e64 def check_cond\n-0000bd20: 6974 696f 6e28 7365 6c66 2c20 636f 6e64 ition(self, cond\n-0000bd30: 6974 696f 6e3a 2073 7472 2c20 7661 6c75 ition: str, valu\n-0000bd40: 653a 206f 626a 6563 7429 202d 3e20 626f e: object) -> bo\n-0000bd50: 6f6c 3a0a 2020 2020 2020 2020 6173 7365 ol:. asse\n-0000bd60: 7274 2069 7369 6e73 7461 6e63 6528 7661 rt isinstance(va\n-0000bd70: 6c75 652c 2073 7472 290a 2020 2020 2020 lue, str). \n-0000bd80: 2020 6173 7365 7274 2076 616c 7565 2069 assert value i\n-0000bd90: 6e20 7365 6c66 2e66 696c 655f 7374 6174 n self.file_stat\n-0000bda0: 7573 0a0a 2020 2020 2020 2020 6966 2063 us.. if c\n-0000bdb0: 6f6e 6469 7469 6f6e 203d 3d20 2770 6174 ondition == 'pat\n-0000bdc0: 682d 6578 6973 7473 273a 0a20 2020 2020 h-exists':. \n-0000bdd0: 2020 2020 2020 2072 6574 7572 6e20 7365 return se\n-0000bde0: 6c66 2e66 696c 655f 7374 6174 7573 5b76 lf.file_status[v\n-0000bdf0: 616c 7565 5d0a 2020 2020 2020 2020 656c alue]. el\n-0000be00: 6966 2063 6f6e 6469 7469 6f6e 203d 3d20 if condition == \n-0000be10: 2770 6174 682d 6e6f 742d 6578 6973 7473 'path-not-exists\n-0000be20: 273a 0a20 2020 2020 2020 2020 2020 2072 ':. r\n-0000be30: 6574 7572 6e20 6e6f 7420 7365 6c66 2e66 eturn not self.f\n-0000be40: 696c 655f 7374 6174 7573 5b76 616c 7565 ile_status[value\n-0000be50: 5d0a 2020 2020 2020 2020 656c 7365 3a0a ]. else:.\n-0000be60: 2020 2020 2020 2020 2020 2020 7261 6973 rais\n-0000be70: 6520 4b65 7945 7272 6f72 0a0a 2020 2020 e KeyError.. \n-0000be80: 6465 6620 5f5f 696e 6974 5f5f 2873 656c def __init__(sel\n-0000be90: 662c 2066 696c 655f 7374 6174 7573 3a20 f, file_status: \n-0000bea0: 4469 6374 5b73 7472 2c20 626f 6f6c 5d29 Dict[str, bool])\n-0000beb0: 3a0a 2020 2020 2020 2020 7365 6c66 2e66 :. self.f\n-0000bec0: 696c 655f 7374 6174 7573 203d 2066 696c ile_status = fil\n-0000bed0: 655f 7374 6174 7573 0a0a 0a42 4549 424f e_status...BEIBO\n-0000bee0: 4f54 5f47 4144 4745 5453 203d 207b 0a20 OT_GADGETS = {. \n-0000bef0: 2020 2022 7265 706f 7274 5f65 7869 7374 \"report_exist\n-0000bf00: 7322 3a20 7222 2222 0a20 2020 2069 6d70 s\": r\"\"\". imp\n-0000bf10: 6f72 7420 6f73 0a20 2020 2064 6566 2072 ort os. def r\n-0000bf20: 6570 6f72 745f 6578 6973 7473 2866 696c eport_exists(fil\n-0000bf30: 6573 293a 0a20 2020 2020 2020 2063 6f6d es):. com\n-0000bf40: 6d61 6e64 2827 636f 636b 7069 742e 7265 mand('cockpit.re\n-0000bf50: 706f 7274 2d65 7869 7374 7327 2c20 7b6e port-exists', {n\n-0000bf60: 616d 653a 206f 732e 7061 7468 2e65 7869 ame: os.path.exi\n-0000bf70: 7374 7328 6e61 6d65 2920 666f 7220 6e61 sts(name) for na\n-0000bf80: 6d65 2069 6e20 6669 6c65 737d 290a 2020 me in files}). \n-0000bf90: 2020 2222 222c 0a20 2020 202a 2a66 6572 \"\"\",. **fer\n-0000bfa0: 6e79 2e42 4549 424f 4f54 5f47 4144 4745 ny.BEIBOOT_GADGE\n-0000bfb0: 5453 0a7d 0a0a 0a63 6c61 7373 2044 6566 TS.}...class Def\n-0000bfc0: 6175 6c74 526f 7574 696e 6752 756c 6528 aultRoutingRule(\n-0000bfd0: 526f 7574 696e 6752 756c 6529 3a0a 2020 RoutingRule):. \n-0000bfe0: 2020 7065 6572 3a20 2750 6565 7220 7c20 peer: 'Peer | \n-0000bff0: 4e6f 6e65 270a 0a20 2020 2064 6566 205f None'.. def _\n-0000c000: 5f69 6e69 745f 5f28 7365 6c66 2c20 726f _init__(self, ro\n-0000c010: 7574 6572 3a20 526f 7574 6572 293a 0a20 uter: Router):. \n-0000c020: 2020 2020 2020 2073 7570 6572 2829 2e5f super()._\n-0000c030: 5f69 6e69 745f 5f28 726f 7574 6572 290a _init__(router).\n-0000c040: 0a20 2020 2064 6566 2061 7070 6c79 5f72 . def apply_r\n-0000c050: 756c 6528 7365 6c66 2c20 6f70 7469 6f6e ule(self, option\n-0000c060: 733a 204a 736f 6e4f 626a 6563 7429 202d s: JsonObject) -\n-0000c070: 3e20 2750 6565 7220 7c20 4e6f 6e65 273a > 'Peer | None':\n-0000c080: 0a20 2020 2020 2020 2072 6574 7572 6e20 . return \n-0000c090: 7365 6c66 2e70 6565 720a 0a20 2020 2064 self.peer.. d\n-0000c0a0: 6566 2073 6875 7464 6f77 6e28 7365 6c66 ef shutdown(self\n-0000c0b0: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n-0000c0c0: 2020 2069 6620 7365 6c66 2e70 6565 7220 if self.peer \n-0000c0d0: 6973 206e 6f74 204e 6f6e 653a 0a20 2020 is not None:. \n-0000c0e0: 2020 2020 2020 2020 2073 656c 662e 7065 self.pe\n-0000c0f0: 6572 2e63 6c6f 7365 2829 0a0a 0a63 6c61 er.close()...cla\n-0000c100: 7373 2041 7574 686f 7269 7a65 5265 7370 ss AuthorizeResp\n-0000c110: 6f6e 6465 7228 6665 726e 792e 4173 6b70 onder(ferny.Askp\n-0000c120: 6173 7348 616e 646c 6572 293a 0a20 2020 assHandler):. \n-0000c130: 2063 6f6d 6d61 6e64 7320 3d20 2827 6665 commands = ('fe\n-0000c140: 726e 792e 6173 6b70 6173 7327 2c20 2763 rny.askpass', 'c\n-0000c150: 6f63 6b70 6974 2e72 6570 6f72 742d 6578 ockpit.report-ex\n-0000c160: 6973 7473 2729 0a20 2020 2072 6f75 7465 ists'). route\n-0000c170: 723a 2052 6f75 7465 720a 0a20 2020 2064 r: Router.. d\n-0000c180: 6566 205f 5f69 6e69 745f 5f28 7365 6c66 ef __init__(self\n-0000c190: 2c20 726f 7574 6572 3a20 526f 7574 6572 , router: Router\n-0000c1a0: 293a 0a20 2020 2020 2020 2073 656c 662e ):. self.\n-0000c1b0: 726f 7574 6572 203d 2072 6f75 7465 720a router = router.\n-0000c1c0: 0a20 2020 2061 7379 6e63 2064 6566 2064 . async def d\n-0000c1d0: 6f5f 6173 6b70 6173 7328 7365 6c66 2c20 o_askpass(self, \n-0000c1e0: 6d65 7373 6167 6573 3a20 7374 722c 2070 messages: str, p\n-0000c1f0: 726f 6d70 743a 2073 7472 2c20 6869 6e74 rompt: str, hint\n-0000c200: 3a20 7374 7229 202d 3e20 4f70 7469 6f6e : str) -> Option\n-0000c210: 616c 5b73 7472 5d3a 0a20 2020 2020 2020 al[str]:. \n-0000c220: 2069 6620 6869 6e74 203d 3d20 276e 6f6e if hint == 'non\n-0000c230: 6527 3a0a 2020 2020 2020 2020 2020 2020 e':. \n-0000c240: 2320 5765 2068 6176 6520 7468 7265 6520 # We have three \n-0000c250: 7072 6f62 6c65 6d73 2068 6572 653a 0a20 problems here:. \n-0000c260: 2020 2020 2020 2020 2020 2023 0a20 2020 #. \n-0000c270: 2020 2020 2020 2020 2023 2020 202d 2077 # - w\n-0000c280: 6520 6861 7665 206e 6f20 7761 7920 746f e have no way to\n-0000c290: 2070 7265 7365 6e74 2061 206d 6573 7361 present a messa\n-0000c2a0: 6765 206f 6e20 7468 6520 6c6f 6769 6e0a ge on the login.\n-0000c2b0: 2020 2020 2020 2020 2020 2020 2320 2020 # \n-0000c2c0: 2020 7363 7265 656e 2077 6974 686f 7574 screen without\n-0000c2d0: 2070 7265 7365 6e74 696e 6720 6120 7072 presenting a pr\n-0000c2e0: 6f6d 7074 2061 6e64 2061 2062 7574 746f ompt and a butto\n-0000c2f0: 6e0a 2020 2020 2020 2020 2020 2020 2320 n. # \n-0000c300: 2020 2d20 7468 6520 6c6f 6769 6e20 7363 - the login sc\n-0000c310: 7265 656e 2077 696c 6c20 6e6f 7420 7472 reen will not tr\n-0000c320: 7920 746f 2072 6570 6f73 7420 7468 6520 y to repost the \n-0000c330: 6c6f 6769 6e0a 2020 2020 2020 2020 2020 login. \n-0000c340: 2020 2320 2020 2020 7265 7175 6573 7420 # request \n-0000c350: 6265 6361 7573 6520 6974 2064 6f65 736e because it doesn\n-0000c360: 2774 2075 6e64 6572 7374 616e 6420 7468 't understand th\n-0000c370: 6174 2077 6520 6172 6520 6e6f 740a 2020 at we are not. \n-0000c380: 2020 2020 2020 2020 2020 2320 2020 2020 # \n-0000c390: 7761 6974 696e 6720 6f6e 2069 6e70 7574 waiting on input\n-0000c3a0: 2c20 7768 6963 6820 6d65 616e 7320 7468 , which means th\n-0000c3b0: 6174 2069 7420 776f 6e27 7420 6e6f 7469 at it won't noti\n-0000c3c0: 6365 0a20 2020 2020 2020 2020 2020 2023 ce. #\n-0000c3d0: 2020 2020 2074 6861 7420 7765 2776 6520 that we've \n-0000c3e0: 6c6f 6767 6564 2069 6e20 7375 6363 6573 logged in succes\n-0000c3f0: 7366 756c 6c79 0a20 2020 2020 2020 2020 sfully. \n-0000c400: 2020 2023 2020 202d 2063 6f63 6b70 6974 # - cockpit\n-0000c410: 2d77 7320 6861 7320 616e 2069 7373 7565 -ws has an issue\n-0000c420: 2077 6865 7265 2069 6620 7765 2072 6574 where if we ret\n-0000c430: 7279 2074 6865 2072 6571 7565 7374 0a20 ry the request. \n-0000c440: 2020 2020 2020 2020 2020 2023 2020 2020 # \n-0000c450: 2061 6761 696e 2061 6674 6572 206c 6f67 again after log\n-0000c460: 696e 2073 7563 6365 6564 6564 2074 6865 in succeeded the\n-0000c470: 6e20 6974 2077 6f6e 2774 2066 6f72 7761 n it won't forwa\n-0000c480: 7264 2074 6865 0a20 2020 2020 2020 2020 rd the. \n-0000c490: 2020 2023 2020 2020 2069 6e69 7420 6d65 # init me\n-0000c4a0: 7373 6167 6520 746f 2074 6865 2063 6c69 ssage to the cli\n-0000c4b0: 656e 742c 2073 7461 6c6c 696e 6720 7468 ent, stalling th\n-0000c4c0: 6520 6c6f 6769 6e2e 2020 5468 6973 0a20 e login. This. \n-0000c4d0: 2020 2020 2020 2020 2020 2023 2020 2020 # \n-0000c4e0: 2069 7320 6120 7261 6365 2061 6e64 2063 is a race and c\n-0000c4f0: 616e 2774 2062 6520 6669 7865 6420 7769 an't be fixed wi\n-0000c500: 7468 6f75 7420 2d77 7320 6368 616e 6765 thout -ws change\n-0000c510: 732e 0a20 2020 2020 2020 2020 2020 2023 s.. #\n-0000c520: 0a20 2020 2020 2020 2020 2020 2023 204c . # L\n-0000c530: 6574 2773 2061 766f 6964 2061 6c6c 206f et's avoid all o\n-0000c540: 6620 7468 6174 2062 7920 6a75 7374 2073 f that by just s\n-0000c550: 686f 7769 6e67 206e 6f74 6869 6e67 2e0a howing nothing..\n-0000c560: 2020 2020 2020 2020 2020 2020 7265 7475 retu\n-0000c570: 726e 204e 6f6e 650a 0a20 2020 2020 2020 rn None.. \n-0000c580: 2063 6861 6c6c 656e 6765 203d 2027 582d challenge = 'X-\n-0000c590: 436f 6e76 6572 7361 7469 6f6e 202d 2027 Conversation - '\n-0000c5a0: 202b 2062 6173 6536 342e 6236 3465 6e63 + base64.b64enc\n-0000c5b0: 6f64 6528 7072 6f6d 7074 2e65 6e63 6f64 ode(prompt.encod\n-0000c5c0: 6528 2929 2e64 6563 6f64 6528 290a 2020 e()).decode(). \n-0000c5d0: 2020 2020 2020 7265 7370 6f6e 7365 203d response =\n-0000c5e0: 2061 7761 6974 2073 656c 662e 726f 7574 await self.rout\n-0000c5f0: 6572 2e72 6571 7565 7374 5f61 7574 686f er.request_autho\n-0000c600: 7269 7a61 7469 6f6e 2863 6861 6c6c 656e rization(challen\n-0000c610: 6765 2c0a 2020 2020 2020 2020 2020 2020 ge,. \n-0000c620: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0000c630: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0000c640: 2020 2020 2020 2020 2020 2020 2020 206d m\n-0000c650: 6573 7361 6765 733d 6d65 7373 6167 6573 essages=messages\n-0000c660: 2c0a 2020 2020 2020 2020 2020 2020 2020 ,. \n-0000c670: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0000c680: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0000c690: 2020 2020 2020 2020 2020 2020 2070 726f pro\n-0000c6a0: 6d70 743d 7072 6f6d 7074 2c0a 2020 2020 mpt=prompt,. \n-0000c6b0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0000c6c0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0000c6d0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0000c6e0: 2020 2020 2020 2068 696e 743d 6869 6e74 hint=hint\n-0000c6f0: 2c0a 2020 2020 2020 2020 2020 2020 2020 ,. \n-0000c700: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0000c710: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0000c720: 2020 2020 2020 2020 2020 2020 2065 6368 ech\n-0000c730: 6f3d 4661 6c73 6529 0a0a 2020 2020 2020 o=False).. \n-0000c740: 2020 6236 3420 3d20 7265 7370 6f6e 7365 b64 = response\n-0000c750: 2e72 656d 6f76 6570 7265 6669 7828 2758 .removeprefix('X\n-0000c760: 2d43 6f6e 7665 7273 6174 696f 6e20 2d27 -Conversation -'\n-0000c770: 292e 7374 7269 7028 290a 2020 2020 2020 ).strip(). \n-0000c780: 2020 7265 7370 6f6e 7365 203d 2062 6173 response = bas\n-0000c790: 6536 342e 6236 3464 6563 6f64 6528 6236 e64.b64decode(b6\n-0000c7a0: 342e 656e 636f 6465 2829 292e 6465 636f 4.encode()).deco\n-0000c7b0: 6465 2829 0a20 2020 2020 2020 206c 6f67 de(). log\n-0000c7c0: 6765 722e 6465 6275 6728 2752 6574 7572 ger.debug('Retur\n-0000c7d0: 6e69 6e67 2061 2025 6420 6368 6172 7320 ning a %d chars \n-0000c7e0: 7265 7370 6f6e 7365 272c 206c 656e 2872 response', len(r\n-0000c7f0: 6573 706f 6e73 6529 290a 2020 2020 2020 esponse)). \n-0000c800: 2020 7265 7475 726e 2072 6573 706f 6e73 return respons\n-0000c810: 650a 0a20 2020 2061 7379 6e63 2064 6566 e.. async def\n-0000c820: 2064 6f5f 6375 7374 6f6d 5f63 6f6d 6d61 do_custom_comma\n-0000c830: 6e64 2873 656c 662c 2063 6f6d 6d61 6e64 nd(self, command\n-0000c840: 3a20 7374 722c 2061 7267 733a 2074 7570 : str, args: tup\n-0000c850: 6c65 2c20 6664 733a 206c 6973 745b 696e le, fds: list[in\n-0000c860: 745d 2c20 7374 6465 7272 3a20 7374 7229 t], stderr: str)\n-0000c870: 202d 3e20 4e6f 6e65 3a0a 2020 2020 2020 -> None:. \n-0000c880: 2020 6c6f 6767 6572 2e64 6562 7567 2827 logger.debug('\n-0000c890: 476f 7420 6665 726e 7920 636f 6d6d 616e Got ferny comman\n-0000c8a0: 6420 2573 2025 7320 2573 272c 2063 6f6d d %s %s %s', com\n-0000c8b0: 6d61 6e64 2c20 6172 6773 2c20 7374 6465 mand, args, stde\n-0000c8c0: 7272 290a 0a20 2020 2020 2020 2069 6620 rr).. if \n-0000c8d0: 636f 6d6d 616e 6420 3d3d 2027 636f 636b command == 'cock\n-0000c8e0: 7069 742e 7265 706f 7274 2d65 7869 7374 pit.report-exist\n-0000c8f0: 7327 3a0a 2020 2020 2020 2020 2020 2020 s':. \n-0000c900: 6669 6c65 5f73 7461 7475 732c 203d 2061 file_status, = a\n-0000c910: 7267 730a 2020 2020 2020 2020 2020 2020 rgs. \n-0000c920: 2320 4649 584d 453a 2065 7669 6c20 6475 # FIXME: evil du\n-0000c930: 636b 2074 7970 696e 6720 6865 7265 202d ck typing here -\n-0000c940: 2d20 7468 6973 2069 7320 6120 6861 6c66 - this is a half\n-0000c950: 2d77 6179 2042 7269 6467 650a 2020 2020 -way Bridge. \n-0000c960: 2020 2020 2020 2020 7365 6c66 2e72 6f75 self.rou\n-0000c970: 7465 722e 7061 636b 6167 6573 203d 2050 ter.packages = P\n-0000c980: 6163 6b61 6765 7328 6c6f 6164 6572 3d50 ackages(loader=P\n-0000c990: 726f 7879 5061 636b 6167 6573 4c6f 6164 roxyPackagesLoad\n-0000c9a0: 6572 2866 696c 655f 7374 6174 7573 2929 er(file_status))\n-0000c9b0: 2020 2320 7479 7065 3a20 6967 6e6f 7265 # type: ignore\n-0000c9c0: 5b61 7474 722d 6465 6669 6e65 645d 0a20 [attr-defined]. \n-0000c9d0: 2020 2020 2020 2020 2020 2073 656c 662e self.\n-0000c9e0: 726f 7574 6572 2e72 6f75 7469 6e67 5f72 router.routing_r\n-0000c9f0: 756c 6573 2e69 6e73 6572 7428 302c 2043 ules.insert(0, C\n-0000ca00: 6861 6e6e 656c 526f 7574 696e 6752 756c hannelRoutingRul\n-0000ca10: 6528 7365 6c66 2e72 6f75 7465 722c 205b e(self.router, [\n-0000ca20: 5061 636b 6167 6573 4368 616e 6e65 6c5d PackagesChannel]\n-0000ca30: 2929 0a0a 0a63 6c61 7373 2053 7368 5065 ))...class SshPe\n-0000ca40: 6572 2850 6565 7229 3a0a 2020 2020 616c er(Peer):. al\n-0000ca50: 7761 7973 3a20 626f 6f6c 0a0a 2020 2020 ways: bool.. \n-0000ca60: 6465 6620 5f5f 696e 6974 5f5f 2873 656c def __init__(sel\n-0000ca70: 662c 2072 6f75 7465 723a 2052 6f75 7465 f, router: Route\n-0000ca80: 722c 2064 6573 7469 6e61 7469 6f6e 3a20 r, destination: \n-0000ca90: 7374 722c 2061 7267 733a 2061 7267 7061 str, args: argpa\n-0000caa0: 7273 652e 4e61 6d65 7370 6163 6529 3a0a rse.Namespace):.\n-0000cab0: 2020 2020 2020 2020 7365 6c66 2e64 6573 self.des\n-0000cac0: 7469 6e61 7469 6f6e 203d 2064 6573 7469 tination = desti\n-0000cad0: 6e61 7469 6f6e 0a20 2020 2020 2020 2073 nation. s\n-0000cae0: 656c 662e 616c 7761 7973 203d 2061 7267 elf.always = arg\n-0000caf0: 732e 616c 7761 7973 0a20 2020 2020 2020 s.always. \n-0000cb00: 2073 7570 6572 2829 2e5f 5f69 6e69 745f super().__init_\n-0000cb10: 5f28 726f 7574 6572 290a 0a20 2020 2061 _(router).. a\n-0000cb20: 7379 6e63 2064 6566 2064 6f5f 636f 6e6e sync def do_conn\n-0000cb30: 6563 745f 7472 616e 7370 6f72 7428 7365 ect_transport(se\n-0000cb40: 6c66 2920 2d3e 204e 6f6e 653a 0a20 2020 lf) -> None:. \n-0000cb50: 2020 2020 2062 6569 626f 6f74 5f68 656c beiboot_hel\n-0000cb60: 7065 7220 3d20 4272 6964 6765 4265 6962 per = BridgeBeib\n-0000cb70: 6f6f 7448 656c 7065 7228 7365 6c66 290a ootHelper(self).\n-0000cb80: 0a20 2020 2020 2020 2061 6765 6e74 203d . agent =\n-0000cb90: 2066 6572 6e79 2e49 6e74 6572 6163 7469 ferny.Interacti\n-0000cba0: 6f6e 4167 656e 7428 5b41 7574 686f 7269 onAgent([Authori\n-0000cbb0: 7a65 5265 7370 6f6e 6465 7228 7365 6c66 zeResponder(self\n-0000cbc0: 2e72 6f75 7465 7229 2c20 6265 6962 6f6f .router), beiboo\n-0000cbd0: 745f 6865 6c70 6572 5d29 0a0a 2020 2020 t_helper]).. \n-0000cbe0: 2020 2020 2320 5765 2077 616e 7420 746f # We want to\n-0000cbf0: 2072 756e 2061 2070 7974 686f 6e20 696e run a python in\n-0000cc00: 7465 7270 7265 7465 7220 736f 6d65 7768 terpreter somewh\n-0000cc10: 6572 652e 2e2e 0a20 2020 2020 2020 2063 ere.... c\n-0000cc20: 6d64 3a20 5365 7175 656e 6365 5b73 7472 md: Sequence[str\n-0000cc30: 5d20 3d20 2827 7079 7468 6f6e 3327 2c20 ] = ('python3', \n-0000cc40: 272d 6963 272c 2027 2320 636f 636b 7069 '-ic', '# cockpi\n-0000cc50: 742d 6272 6964 6765 2729 0a20 2020 2020 t-bridge'). \n-0000cc60: 2020 2065 6e76 3a20 5365 7175 656e 6365 env: Sequence\n-0000cc70: 5b73 7472 5d20 3d20 2829 0a0a 2020 2020 [str] = ().. \n-0000cc80: 2020 2020 696e 5f66 6c61 7470 616b 203d in_flatpak =\n-0000cc90: 206f 732e 7061 7468 2e65 7869 7374 7328 os.path.exists(\n-0000cca0: 272f 2e66 6c61 7470 616b 2d69 6e66 6f27 '/.flatpak-info'\n-0000ccb0: 290a 0a20 2020 2020 2020 2023 2052 656d ).. # Rem\n-0000ccc0: 6f74 6520 686f 7374 3f20 2057 7261 7020 ote host? Wrap \n-0000ccd0: 636f 6d6d 616e 6420 7769 7468 2053 5348 command with SSH\n-0000cce0: 0a20 2020 2020 2020 2069 6620 7365 6c66 . if self\n-0000ccf0: 2e64 6573 7469 6e61 7469 6f6e 2021 3d20 .destination != \n-0000cd00: 276c 6f63 616c 686f 7374 273a 0a20 2020 'localhost':. \n-0000cd10: 2020 2020 2020 2020 2069 6620 696e 5f66 if in_f\n-0000cd20: 6c61 7470 616b 3a0a 2020 2020 2020 2020 latpak:. \n-0000cd30: 2020 2020 2020 2020 2320 7765 2072 756e # we run\n-0000cd40: 2073 7368 2061 6e64 2074 6875 7320 7468 ssh and thus th\n-0000cd50: 6520 6865 6c70 6572 206f 6e20 7468 6520 e helper on the \n-0000cd60: 686f 7374 2c20 616c 7761 7973 2075 7365 host, always use\n-0000cd70: 2074 6865 2078 6467 2d63 6163 6865 2068 the xdg-cache h\n-0000cd80: 656c 7065 720a 2020 2020 2020 2020 2020 elper. \n-0000cd90: 2020 2020 2020 7373 685f 6173 6b70 6173 ssh_askpas\n-0000cda0: 7320 3d20 656e 7375 7265 5f66 6572 6e79 s = ensure_ferny\n-0000cdb0: 5f61 736b 7061 7373 2829 0a20 2020 2020 _askpass(). \n-0000cdc0: 2020 2020 2020 2065 6c73 653a 0a20 2020 else:. \n-0000cdd0: 2020 2020 2020 2020 2020 2020 2023 206f # o\n-0000cde0: 7574 7369 6465 206f 6620 7468 6520 666c utside of the fl\n-0000cdf0: 6174 7061 6b20 7765 2065 7870 6563 7420 atpak we expect \n-0000ce00: 636f 636b 7069 742d 7773 2061 6e64 2074 cockpit-ws and t\n-0000ce10: 6875 7320 616e 2069 6e73 7461 6c6c 6564 hus an installed\n-0000ce20: 2068 656c 7065 720a 2020 2020 2020 2020 helper. \n-0000ce30: 2020 2020 2020 2020 6173 6b70 6173 7320 askpass \n-0000ce40: 3d20 7061 7463 685f 6c69 6265 7865 6364 = patch_libexecd\n-0000ce50: 6972 2827 247b 6c69 6265 7865 6364 6972 ir('${libexecdir\n-0000ce60: 7d2f 636f 636b 7069 742d 6173 6b70 6173 }/cockpit-askpas\n-0000ce70: 7327 290a 2020 2020 2020 2020 2020 2020 s'). \n-0000ce80: 2020 2020 6173 7365 7274 2069 7369 6e73 assert isins\n-0000ce90: 7461 6e63 6528 6173 6b70 6173 732c 2073 tance(askpass, s\n-0000cea0: 7472 290a 2020 2020 2020 2020 2020 2020 tr). \n-0000ceb0: 2020 2020 7373 685f 6173 6b70 6173 7320 ssh_askpass \n-0000cec0: 3d20 5061 7468 2861 736b 7061 7373 290a = Path(askpass).\n-0000ced0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0000cee0: 6966 206e 6f74 2073 7368 5f61 736b 7061 if not ssh_askpa\n-0000cef0: 7373 2e65 7869 7374 7328 293a 0a20 2020 ss.exists():. \n-0000cf00: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0000cf10: 206c 6f67 6765 722e 6572 726f 7228 2243 logger.error(\"C\n-0000cf20: 6f75 6c64 206e 6f74 2066 696e 6420 636f ould not find co\n-0000cf30: 636b 7069 742d 6173 6b70 6173 7320 6865 ckpit-askpass he\n-0000cf40: 6c70 6572 2061 7420 2572 222c 2061 736b lper at %r\", ask\n-0000cf50: 7061 7373 290a 0a20 2020 2020 2020 2020 pass).. \n-0000cf60: 2020 2065 6e76 203d 2028 0a20 2020 2020 env = (. \n-0000cf70: 2020 2020 2020 2020 2020 2066 2753 5348 f'SSH\n-0000cf80: 5f41 534b 5041 5353 3d7b 7373 685f 6173 _ASKPASS={ssh_as\n-0000cf90: 6b70 6173 7321 737d 272c 0a20 2020 2020 kpass!s}',. \n-0000cfa0: 2020 2020 2020 2020 2020 2027 4449 5350 'DISP\n-0000cfb0: 4c41 593d 7827 2c0a 2020 2020 2020 2020 LAY=x',. \n-0000cfc0: 2020 2020 2020 2020 2753 5348 5f41 534b 'SSH_ASK\n-0000cfd0: 5041 5353 5f52 4551 5549 5245 3d66 6f72 PASS_REQUIRE=for\n-0000cfe0: 6365 272c 0a20 2020 2020 2020 2020 2020 ce',. \n-0000cff0: 2029 0a20 2020 2020 2020 2020 2020 2068 ). h\n-0000d000: 6f73 742c 205f 2c20 706f 7274 203d 2073 ost, _, port = s\n-0000d010: 656c 662e 6465 7374 696e 6174 696f 6e2e elf.destination.\n-0000d020: 7270 6172 7469 7469 6f6e 2827 3a27 290a rpartition(':').\n-0000d030: 2020 2020 2020 2020 2020 2020 2320 6361 # ca\n-0000d040: 7463 6820 6361 7365 7320 6c69 6b65 2060 tch cases like `\n-0000d050: 686f 7374 3a31 3233 6020 6275 7420 6e6f host:123` but no\n-0000d060: 7420 6361 7365 7320 6c69 6b65 2060 5b32 t cases like `[2\n-0000d070: 3030 313a 6162 6364 3a3a 315d 0a20 2020 001:abcd::1]. \n-0000d080: 2020 2020 2020 2020 2069 6620 706f 7274 if port\n-0000d090: 2e69 7364 6967 6974 2829 3a0a 2020 2020 .isdigit():. \n-0000d0a0: 2020 2020 2020 2020 2020 2020 686f 7374 host\n-0000d0b0: 5f61 7267 7320 3d20 5b27 2d70 272c 2070 _args = ['-p', p\n-0000d0c0: 6f72 742c 2068 6f73 745d 0a20 2020 2020 ort, host]. \n-0000d0d0: 2020 2020 2020 2065 6c73 653a 0a20 2020 else:. \n-0000d0e0: 2020 2020 2020 2020 2020 2020 2068 6f73 hos\n-0000d0f0: 745f 6172 6773 203d 205b 7365 6c66 2e64 t_args = [self.d\n-0000d100: 6573 7469 6e61 7469 6f6e 5d0a 0a20 2020 estination].. \n-0000d110: 2020 2020 2020 2020 2063 6d64 203d 2028 cmd = (\n-0000d120: 2773 7368 272c 202a 686f 7374 5f61 7267 'ssh', *host_arg\n-0000d130: 732c 2073 686c 6578 2e6a 6f69 6e28 636d s, shlex.join(cm\n-0000d140: 6429 290a 0a20 2020 2020 2020 2023 2052 d)).. # R\n-0000d150: 756e 6e69 6e67 2069 6e20 666c 6174 7061 unning in flatpa\n-0000d160: 6b3f 2020 5772 6170 2063 6f6d 6d61 6e64 k? Wrap command\n-0000d170: 2077 6974 6820 666c 6174 7061 6b2d 7370 with flatpak-sp\n-0000d180: 6177 6e20 2d2d 686f 7374 0a20 2020 2020 awn --host. \n-0000d190: 2020 2069 6620 696e 5f66 6c61 7470 616b if in_flatpak\n-0000d1a0: 3a0a 2020 2020 2020 2020 2020 2020 636d :. cm\n-0000d1b0: 6420 3d20 2827 666c 6174 7061 6b2d 7370 d = ('flatpak-sp\n-0000d1c0: 6177 6e27 2c20 272d 2d68 6f73 7427 2c0a awn', '--host',.\n-0000d1d0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0000d1e0: 2020 202a 2866 272d 2d65 6e76 3d7b 6b76 *(f'--env={kv\n-0000d1f0: 7d27 2066 6f72 206b 7620 696e 2065 6e76 }' for kv in env\n-0000d200: 292c 0a20 2020 2020 2020 2020 2020 2020 ),. \n-0000d210: 2020 2020 2020 2a63 6d64 290a 2020 2020 *cmd). \n-0000d220: 2020 2020 2020 2020 656e 7620 3d20 2829 env = ()\n-0000d230: 0a0a 2020 2020 2020 2020 6c6f 6767 6572 .. logger\n-0000d240: 2e64 6562 7567 2822 4c61 756e 6368 696e .debug(\"Launchin\n-0000d250: 6720 636f 6d6d 616e 643a 2063 6d64 3d25 g command: cmd=%\n-0000d260: 7320 656e 763d 2573 222c 2063 6d64 2c20 s env=%s\", cmd, \n-0000d270: 656e 7629 0a20 2020 2020 2020 2074 7261 env). tra\n-0000d280: 6e73 706f 7274 203d 2061 7761 6974 2073 nsport = await s\n-0000d290: 656c 662e 7370 6177 6e28 636d 642c 2065 elf.spawn(cmd, e\n-0000d2a0: 6e76 2c20 7374 6465 7272 3d61 6765 6e74 nv, stderr=agent\n-0000d2b0: 2c20 7374 6172 745f 6e65 775f 7365 7373 , start_new_sess\n-0000d2c0: 696f 6e3d 5472 7565 290a 0a20 2020 2020 ion=True).. \n-0000d2d0: 2020 2069 6620 6e6f 7420 7365 6c66 2e61 if not self.a\n-0000d2e0: 6c77 6179 733a 0a20 2020 2020 2020 2020 lways:. \n-0000d2f0: 2020 2065 7865 635f 636f 636b 7069 745f exec_cockpit_\n-0000d300: 6272 6964 6765 5f73 7465 7073 203d 205b bridge_steps = [\n-0000d310: 2827 7472 795f 6578 6563 272c 2028 5b27 ('try_exec', (['\n-0000d320: 636f 636b 7069 742d 6272 6964 6765 275d cockpit-bridge']\n-0000d330: 2c29 295d 0a20 2020 2020 2020 2065 6c73 ,))]. els\n-0000d340: 653a 0a20 2020 2020 2020 2020 2020 2065 e:. e\n-0000d350: 7865 635f 636f 636b 7069 745f 6272 6964 xec_cockpit_brid\n-0000d360: 6765 5f73 7465 7073 203d 205b 5d0a 0a20 ge_steps = [].. \n-0000d370: 2020 2020 2020 2023 2053 656e 6420 7468 # Send th\n-0000d380: 6520 6669 7273 742d 7374 6167 6520 626f e first-stage bo\n-0000d390: 6f74 6c6f 6164 6572 0a20 2020 2020 2020 otloader. \n-0000d3a0: 2073 7461 6765 3120 3d20 626f 6f74 6c6f stage1 = bootlo\n-0000d3b0: 6164 6572 2e6d 616b 655f 626f 6f74 6c6f ader.make_bootlo\n-0000d3c0: 6164 6572 285b 0a20 2020 2020 2020 2020 ader([. \n-0000d3d0: 2020 202a 6578 6563 5f63 6f63 6b70 6974 *exec_cockpit\n-0000d3e0: 5f62 7269 6467 655f 7374 6570 732c 0a20 _bridge_steps,. \n-0000d3f0: 2020 2020 2020 2020 2020 2028 2772 6570 ('rep\n-0000d400: 6f72 745f 6578 6973 7473 272c 205b 6c69 ort_exists', [li\n-0000d410: 7374 2867 6574 5f69 6e74 6572 6573 7469 st(get_interesti\n-0000d420: 6e67 5f66 696c 6573 2829 295d 292c 0a20 ng_files())]),. \n-0000d430: 2020 2020 2020 2020 2020 202a 6265 6962 *beib\n-0000d440: 6f6f 745f 6865 6c70 6572 2e73 7465 7073 oot_helper.steps\n-0000d450: 2c0a 2020 2020 2020 2020 5d2c 2067 6164 ,. ], gad\n-0000d460: 6765 7473 3d42 4549 424f 4f54 5f47 4144 gets=BEIBOOT_GAD\n-0000d470: 4745 5453 290a 2020 2020 2020 2020 7472 GETS). tr\n-0000d480: 616e 7370 6f72 742e 7772 6974 6528 7374 ansport.write(st\n-0000d490: 6167 6531 2e65 6e63 6f64 6528 2929 0a0a age1.encode())..\n-0000d4a0: 2020 2020 2020 2020 2320 5761 6974 2066 # Wait f\n-0000d4b0: 6f72 2022 696e 6974 2220 6f72 2065 7272 or \"init\" or err\n-0000d4c0: 6f72 2c20 6861 6e64 6c69 6e67 2061 7574 or, handling aut\n-0000d4d0: 6820 616e 6420 6265 6962 6f6f 7420 7265 h and beiboot re\n-0000d4e0: 7175 6573 7473 0a20 2020 2020 2020 2061 quests. a\n-0000d4f0: 7761 6974 2061 6765 6e74 2e63 6f6d 6d75 wait agent.commu\n-0000d500: 6e69 6361 7465 2829 0a0a 2020 2020 6465 nicate().. de\n-0000d510: 6620 7472 616e 7370 6f72 745f 636f 6e74 f transport_cont\n-0000d520: 726f 6c5f 7265 6365 6976 6564 2873 656c rol_received(sel\n-0000d530: 662c 2063 6f6d 6d61 6e64 3a20 7374 722c f, command: str,\n-0000d540: 206d 6573 7361 6765 3a20 4a73 6f6e 4f62 message: JsonOb\n-0000d550: 6a65 6374 2920 2d3e 204e 6f6e 653a 0a20 ject) -> None:. \n-0000d560: 2020 2020 2020 2069 6620 636f 6d6d 616e if comman\n-0000d570: 6420 3d3d 2027 6175 7468 6f72 697a 6527 d == 'authorize'\n-0000d580: 3a0a 2020 2020 2020 2020 2020 2020 2320 :. # \n-0000d590: 5765 2776 6520 6469 7361 626c 6564 2074 We've disabled t\n-0000d5a0: 6869 7320 666f 7220 6578 706c 6963 6974 his for explicit\n-0000d5b0: 2d73 7570 6572 7573 6572 2062 7269 6467 -superuser bridg\n-0000d5c0: 6573 2c20 6275 7420 6f6c 6465 720a 2020 es, but older. \n-0000d5d0: 2020 2020 2020 2020 2020 2320 6272 6964 # brid\n-0000d5e0: 6765 7320 646f 6e27 7420 7375 7070 6f72 ges don't suppor\n-0000d5f0: 7420 7468 6174 2061 6e64 2077 696c 6c20 t that and will \n-0000d600: 6173 6b20 7573 2061 6e79 7761 792e 0a20 ask us anyway.. \n-0000d610: 2020 2020 2020 2020 2020 2072 6574 7572 retur\n-0000d620: 6e0a 0a20 2020 2020 2020 2073 7570 6572 n.. super\n-0000d630: 2829 2e74 7261 6e73 706f 7274 5f63 6f6e ().transport_con\n-0000d640: 7472 6f6c 5f72 6563 6569 7665 6428 636f trol_received(co\n-0000d650: 6d6d 616e 642c 206d 6573 7361 6765 290a mmand, message).\n-0000d660: 0a0a 636c 6173 7320 5373 6842 7269 6467 ..class SshBridg\n-0000d670: 6528 526f 7574 6572 293a 0a20 2020 2070 e(Router):. p\n-0000d680: 6163 6b61 6765 733a 204f 7074 696f 6e61 ackages: Optiona\n-0000d690: 6c5b 5061 636b 6167 6573 5d20 3d20 4e6f l[Packages] = No\n-0000d6a0: 6e65 0a20 2020 2073 7368 5f70 6565 723a ne. ssh_peer:\n-0000d6b0: 2053 7368 5065 6572 0a0a 2020 2020 6465 SshPeer.. de\n-0000d6c0: 6620 5f5f 696e 6974 5f5f 2873 656c 662c f __init__(self,\n-0000d6d0: 2061 7267 733a 2061 7267 7061 7273 652e args: argparse.\n-0000d6e0: 4e61 6d65 7370 6163 6529 3a0a 2020 2020 Namespace):. \n-0000d6f0: 2020 2020 2320 4279 2064 6566 6175 6c74 # By default\n-0000d700: 2c20 7765 2072 6f75 7465 2065 7665 7279 , we route every\n-0000d710: 7468 696e 6720 746f 2074 6865 206f 7468 thing to the oth\n-0000d720: 6572 2068 6f73 742e 2020 5765 2061 6464 er host. We add\n-0000d730: 2061 6e20 6578 7472 610a 2020 2020 2020 an extra. \n-0000d740: 2020 2320 726f 7574 696e 6720 7275 6c65 # routing rule\n-0000d750: 2066 6f72 2074 6865 2070 6163 6b61 6765 for the package\n-0000d760: 7320 7765 6273 6572 7665 7220 6f6e 6c79 s webserver only\n-0000d770: 2069 6620 7765 2772 6520 7275 6e6e 696e if we're runnin\n-0000d780: 6720 7468 650a 2020 2020 2020 2020 2320 g the. # \n-0000d790: 6265 6970 6163 6b2e 0a20 2020 2020 2020 beipack.. \n-0000d7a0: 2072 756c 6520 3d20 4465 6661 756c 7452 rule = DefaultR\n-0000d7b0: 6f75 7469 6e67 5275 6c65 2873 656c 6629 outingRule(self)\n-0000d7c0: 0a20 2020 2020 2020 2073 7570 6572 2829 . super()\n-0000d7d0: 2e5f 5f69 6e69 745f 5f28 5b72 756c 655d .__init__([rule]\n-0000d7e0: 290a 0a20 2020 2020 2020 2023 2054 6869 ).. # Thi\n-0000d7f0: 7320 6e65 6564 7320 746f 2062 6520 6372 s needs to be cr\n-0000d800: 6561 7465 6420 6166 7465 7220 526f 7574 eated after Rout\n-0000d810: 6572 2e5f 5f69 6e69 745f 5f20 6973 2063 er.__init__ is c\n-0000d820: 616c 6c65 642e 0a20 2020 2020 2020 2073 alled.. s\n-0000d830: 656c 662e 7373 685f 7065 6572 203d 2053 elf.ssh_peer = S\n-0000d840: 7368 5065 6572 2873 656c 662c 2061 7267 shPeer(self, arg\n-0000d850: 732e 6465 7374 696e 6174 696f 6e2c 2061 s.destination, a\n-0000d860: 7267 7329 0a20 2020 2020 2020 2072 756c rgs). rul\n-0000d870: 652e 7065 6572 203d 2073 656c 662e 7373 e.peer = self.ss\n-0000d880: 685f 7065 6572 0a0a 2020 2020 6465 6620 h_peer.. def \n-0000d890: 646f 5f73 656e 645f 696e 6974 2873 656c do_send_init(sel\n-0000d8a0: 6629 3a0a 2020 2020 2020 2020 7061 7373 f):. pass\n-0000d8b0: 2020 2320 7761 6974 2066 6f72 2074 6865 # wait for the\n-0000d8c0: 2070 6565 7220 746f 2064 6f20 6974 2066 peer to do it f\n-0000d8d0: 6972 7374 0a0a 2020 2020 6465 6620 646f irst.. def do\n-0000d8e0: 5f69 6e69 7428 7365 6c66 2c20 6d65 7373 _init(self, mess\n-0000d8f0: 6167 6529 3a0a 2020 2020 2020 2020 2320 age):. # \n-0000d900: 6874 7470 733a 2f2f 6769 7468 7562 2e63 https://github.c\n-0000d910: 6f6d 2f63 6f63 6b70 6974 2d70 726f 6a65 om/cockpit-proje\n-0000d920: 6374 2f63 6f63 6b70 6974 2f69 7373 7565 ct/cockpit/issue\n-0000d930: 732f 3138 3932 370a 2020 2020 2020 2020 s/18927. \n-0000d940: 230a 2020 2020 2020 2020 2320 5765 2074 #. # We t\n-0000d950: 656c 6c20 636f 636b 7069 742d 7773 2074 ell cockpit-ws t\n-0000d960: 6861 7420 7765 2068 6176 6520 7468 6520 hat we have the \n-0000d970: 6578 706c 6963 6974 2d73 7570 6572 7573 explicit-superus\n-0000d980: 6572 2063 6170 6162 696c 6974 7920 616e er capability an\n-0000d990: 640a 2020 2020 2020 2020 2320 6861 6e64 d. # hand\n-0000d9a0: 6c65 2069 7420 6f75 7273 656c 7665 7320 le it ourselves \n-0000d9b0: 286a 7573 7420 6265 6c6f 7729 2062 7920 (just below) by \n-0000d9c0: 7365 6e64 696e 6720 6073 7570 6572 7573 sending `superus\n-0000d9d0: 6572 2d69 6e69 742d 646f 6e65 6020 616e er-init-done` an\n-0000d9e0: 640a 2020 2020 2020 2020 2320 7061 7373 d. # pass\n-0000d9f0: 696e 6720 7b27 7375 7065 7275 7365 7227 ing {'superuser'\n-0000da00: 3a20 4661 6c73 657d 206f 6e20 746f 2074 : False} on to t\n-0000da10: 6865 2061 6374 7561 6c20 6272 6964 6765 he actual bridge\n-0000da20: 2028 5079 7468 6f6e 206f 7220 4329 2e0a (Python or C)..\n-0000da30: 2020 2020 2020 2020 6966 2069 7369 6e73 if isins\n-0000da40: 7461 6e63 6528 6d65 7373 6167 652e 6765 tance(message.ge\n-0000da50: 7428 2773 7570 6572 7573 6572 2729 2c20 t('superuser'), \n-0000da60: 6469 6374 293a 0a20 2020 2020 2020 2020 dict):. \n-0000da70: 2020 2073 656c 662e 7772 6974 655f 636f self.write_co\n-0000da80: 6e74 726f 6c28 636f 6d6d 616e 643d 2773 ntrol(command='s\n-0000da90: 7570 6572 7573 6572 2d69 6e69 742d 646f uperuser-init-do\n-0000daa0: 6e65 2729 0a20 2020 2020 2020 206d 6573 ne'). mes\n-0000dab0: 7361 6765 5b27 7375 7065 7275 7365 7227 sage['superuser'\n-0000dac0: 5d20 3d20 4661 6c73 650a 2020 2020 2020 ] = False. \n-0000dad0: 2020 7365 6c66 2e73 7368 5f70 6565 722e self.ssh_peer.\n-0000dae0: 7772 6974 655f 636f 6e74 726f 6c28 6d65 write_control(me\n-0000daf0: 7373 6167 6529 0a0a 0a61 7379 6e63 2064 ssage)...async d\n-0000db00: 6566 2072 756e 2861 7267 7329 202d 3e20 ef run(args) -> \n-0000db10: 4e6f 6e65 3a0a 2020 2020 6c6f 6767 6572 None:. logger\n-0000db20: 2e64 6562 7567 2822 4869 2e20 486f 7720 .debug(\"Hi. How \n-0000db30: 6172 6520 796f 7520 746f 6461 793f 2229 are you today?\")\n-0000db40: 0a0a 2020 2020 6272 6964 6765 203d 2053 .. bridge = S\n-0000db50: 7368 4272 6964 6765 2861 7267 7329 0a20 shBridge(args). \n-0000db60: 2020 2053 7464 696f 5472 616e 7370 6f72 StdioTranspor\n-0000db70: 7428 6173 796e 6369 6f2e 6765 745f 7275 t(asyncio.get_ru\n-0000db80: 6e6e 696e 675f 6c6f 6f70 2829 2c20 6272 nning_loop(), br\n-0000db90: 6964 6765 290a 0a20 2020 2074 7279 3a0a idge).. try:.\n-0000dba0: 2020 2020 2020 2020 6d65 7373 6167 6520 message \n-0000dbb0: 3d20 6469 6374 2861 7761 6974 2062 7269 = dict(await bri\n-0000dbc0: 6467 652e 7373 685f 7065 6572 2e73 7461 dge.ssh_peer.sta\n-0000dbd0: 7274 2829 290a 0a20 2020 2020 2020 2023 rt()).. #\n-0000dbe0: 2053 6565 2063 6f6d 6d65 6e74 2069 6e20 See comment in \n-0000dbf0: 646f 5f69 6e69 7428 2920 6162 6f76 653a do_init() above:\n-0000dc00: 2077 6520 7465 6c6c 2063 6f63 6b70 6974 we tell cockpit\n-0000dc10: 2d77 7320 7468 6174 2077 6520 7375 7070 -ws that we supp\n-0000dc20: 6f72 740a 2020 2020 2020 2020 2320 7468 ort. # th\n-0000dc30: 6973 2061 6e64 2074 6865 6e20 6861 6e64 is and then hand\n-0000dc40: 6c65 2069 7420 6f75 7273 656c 7665 7320 le it ourselves \n-0000dc50: 7768 656e 2077 6520 6765 7420 7468 6520 when we get the \n-0000dc60: 696e 6974 206d 6573 7361 6765 2e0a 2020 init message.. \n-0000dc70: 2020 2020 2020 6361 7061 6269 6c69 7469 capabiliti\n-0000dc80: 6573 203d 206d 6573 7361 6765 2e73 6574 es = message.set\n-0000dc90: 6465 6661 756c 7428 2763 6170 6162 696c default('capabil\n-0000dca0: 6974 6965 7327 2c20 7b7d 290a 2020 2020 ities', {}). \n-0000dcb0: 2020 2020 6966 206e 6f74 2069 7369 6e73 if not isins\n-0000dcc0: 7461 6e63 6528 6361 7061 6269 6c69 7469 tance(capabiliti\n-0000dcd0: 6573 2c20 6469 6374 293a 0a20 2020 2020 es, dict):. \n-0000dce0: 2020 2020 2020 2062 7269 6467 652e 7772 bridge.wr\n-0000dcf0: 6974 655f 636f 6e74 726f 6c28 636f 6d6d ite_control(comm\n-0000dd00: 616e 643d 2769 6e69 7427 2c20 7072 6f62 and='init', prob\n-0000dd10: 6c65 6d3d 2770 726f 746f 636f 6c2d 6572 lem='protocol-er\n-0000dd20: 726f 7227 2c20 6d65 7373 6167 653d 2763 ror', message='c\n-0000dd30: 6170 6162 696c 6974 6965 7320 6d75 7374 apabilities must\n-0000dd40: 2062 6520 6120 6469 6374 2729 0a20 2020 be a dict'). \n-0000dd50: 2020 2020 2020 2020 2072 6574 7572 6e0a return.\n-0000dd60: 2020 2020 2020 2020 6173 7365 7274 2069 assert i\n-0000dd70: 7369 6e73 7461 6e63 6528 6361 7061 6269 sinstance(capabi\n-0000dd80: 6c69 7469 6573 2c20 6469 6374 2920 2023 lities, dict) #\n-0000dd90: 2063 6f6e 7669 6e63 6520 6d79 7079 0a20 convince mypy. \n-0000dda0: 2020 2020 2020 2063 6170 6162 696c 6974 capabilit\n-0000ddb0: 6965 735b 2765 7870 6c69 6369 742d 7375 ies['explicit-su\n-0000ddc0: 7065 7275 7365 7227 5d20 3d20 5472 7565 peruser'] = True\n-0000ddd0: 0a0a 2020 2020 2020 2020 2320 6f6e 6c79 .. # only\n-0000dde0: 2070 6174 6368 2074 6865 2070 6163 6b61 patch the packa\n-0000ddf0: 6765 7320 6c69 6e65 2069 6620 7765 2061 ges line if we a\n-0000de00: 7265 2069 6e20 6265 6962 6f6f 7420 6d6f re in beiboot mo\n-0000de10: 6465 0a20 2020 2020 2020 2069 6620 6272 de. if br\n-0000de20: 6964 6765 2e70 6163 6b61 6765 733a 0a20 idge.packages:. \n-0000de30: 2020 2020 2020 2020 2020 206d 6573 7361 messa\n-0000de40: 6765 5b27 7061 636b 6167 6573 275d 203d ge['packages'] =\n-0000de50: 2064 6963 742e 6672 6f6d 6b65 7973 2862 dict.fromkeys(b\n-0000de60: 7269 6467 652e 7061 636b 6167 6573 2e70 ridge.packages.p\n-0000de70: 6163 6b61 6765 7329 0a0a 2020 2020 2020 ackages).. \n-0000de80: 2020 6272 6964 6765 2e77 7269 7465 5f63 bridge.write_c\n-0000de90: 6f6e 7472 6f6c 286d 6573 7361 6765 290a ontrol(message).\n-0000dea0: 2020 2020 2020 2020 6272 6964 6765 2e73 bridge.s\n-0000deb0: 7368 5f70 6565 722e 7468 6177 5f65 6e64 sh_peer.thaw_end\n-0000dec0: 706f 696e 7428 290a 2020 2020 6578 6365 point(). exce\n-0000ded0: 7074 2066 6572 6e79 2e49 6e74 6572 6163 pt ferny.Interac\n-0000dee0: 7469 6f6e 4572 726f 7220 6173 2065 7863 tionError as exc\n-0000def0: 3a0a 2020 2020 2020 2020 6572 726f 7220 :. error \n-0000df00: 3d20 6665 726e 792e 7373 685f 6572 726f = ferny.ssh_erro\n-0000df10: 7273 2e67 6574 5f65 7863 6570 7469 6f6e rs.get_exception\n-0000df20: 5f66 6f72 5f73 7368 5f73 7464 6572 7228 _for_ssh_stderr(\n-0000df30: 7374 7228 6578 6329 290a 2020 2020 2020 str(exc)). \n-0000df40: 2020 6c6f 6767 6572 2e64 6562 7567 2822 logger.debug(\"\n-0000df50: 6665 726e 792e 496e 7465 7261 6374 696f ferny.Interactio\n-0000df60: 6e45 7272 6f72 3a20 2573 2c20 696e 7465 nError: %s, inte\n-0000df70: 7270 7265 7465 6420 6173 3a20 2572 222c rpreted as: %r\",\n-0000df80: 2065 7863 2c20 6572 726f 7229 0a20 2020 exc, error). \n-0000df90: 2020 2020 2069 6620 6973 696e 7374 616e if isinstan\n-0000dfa0: 6365 2865 7272 6f72 2c20 6665 726e 792e ce(error, ferny.\n-0000dfb0: 5373 6841 7574 6865 6e74 6963 6174 696f SshAuthenticatio\n-0000dfc0: 6e45 7272 6f72 293a 0a20 2020 2020 2020 nError):. \n-0000dfd0: 2020 2020 2070 726f 626c 656d 203d 2027 problem = '\n-0000dfe0: 6175 7468 656e 7469 6361 7469 6f6e 2d66 authentication-f\n-0000dff0: 6169 6c65 6427 0a20 2020 2020 2020 2065 ailed'. e\n-0000e000: 6c69 6620 6973 696e 7374 616e 6365 2865 lif isinstance(e\n-0000e010: 7272 6f72 2c20 6665 726e 792e 5373 6848 rror, ferny.SshH\n-0000e020: 6f73 744b 6579 4572 726f 7229 3a0a 2020 ostKeyError):. \n-0000e030: 2020 2020 2020 2020 2020 7072 6f62 6c65 proble\n-0000e040: 6d20 3d20 2775 6e6b 6e6f 776e 2d68 6f73 m = 'unknown-hos\n-0000e050: 746b 6579 270a 2020 2020 2020 2020 656c tkey'. el\n-0000e060: 6966 2069 7369 6e73 7461 6e63 6528 6572 if isinstance(er\n-0000e070: 726f 722c 204f 5345 7272 6f72 293a 0a20 ror, OSError):. \n-0000e080: 2020 2020 2020 2020 2020 2023 2075 7375 # usu\n-0000e090: 616c 6c79 2044 4e53 2f73 6f63 6b65 7420 ally DNS/socket \n-0000e0a0: 6572 726f 7273 0a20 2020 2020 2020 2020 errors. \n-0000e0b0: 2020 2070 726f 626c 656d 203d 2027 756e problem = 'un\n-0000e0c0: 6b6e 6f77 6e2d 686f 7374 270a 2020 2020 known-host'. \n-0000e0d0: 2020 2020 656c 7365 3a0a 2020 2020 2020 else:. \n-0000e0e0: 2020 2020 2020 7072 6f62 6c65 6d20 3d20 problem = \n-0000e0f0: 2769 6e74 6572 6e61 6c2d 6572 726f 7227 'internal-error'\n-0000e100: 0a20 2020 2020 2020 2062 7269 6467 652e . bridge.\n-0000e110: 7772 6974 655f 636f 6e74 726f 6c28 636f write_control(co\n-0000e120: 6d6d 616e 643d 2769 6e69 7427 2c20 7072 mmand='init', pr\n-0000e130: 6f62 6c65 6d3d 7072 6f62 6c65 6d2c 206d oblem=problem, m\n-0000e140: 6573 7361 6765 3d73 7472 2865 7272 6f72 essage=str(error\n-0000e150: 2929 0a20 2020 2020 2020 2072 6574 7572 )). retur\n-0000e160: 6e0a 2020 2020 6578 6365 7074 2043 6f63 n. except Coc\n-0000e170: 6b70 6974 5072 6f62 6c65 6d20 6173 2065 kpitProblem as e\n-0000e180: 7863 3a0a 2020 2020 2020 2020 6c6f 6767 xc:. logg\n-0000e190: 6572 2e64 6562 7567 2822 436f 636b 7069 er.debug(\"Cockpi\n-0000e1a0: 7450 726f 626c 656d 3a20 2573 222c 2065 tProblem: %s\", e\n-0000e1b0: 7863 290a 2020 2020 2020 2020 6272 6964 xc). brid\n-0000e1c0: 6765 2e77 7269 7465 5f63 6f6e 7472 6f6c ge.write_control\n-0000e1d0: 2865 7863 2e61 7474 7273 2c20 636f 6d6d (exc.attrs, comm\n-0000e1e0: 616e 643d 2769 6e69 7427 290a 2020 2020 and='init'). \n-0000e1f0: 2020 2020 7265 7475 726e 0a0a 2020 2020 return.. \n-0000e200: 6c6f 6767 6572 2e64 6562 7567 2827 5374 logger.debug('St\n-0000e210: 6172 7475 7020 646f 6e65 2e20 204c 6f6f artup done. Loo\n-0000e220: 7069 6e67 2075 6e74 696c 2063 6f6e 6e65 ping until conne\n-0000e230: 6374 696f 6e20 636c 6f73 6573 2e27 290a ction closes.').\n-0000e240: 2020 2020 7472 793a 0a20 2020 2020 2020 try:. \n-0000e250: 2061 7761 6974 2062 7269 6467 652e 636f await bridge.co\n-0000e260: 6d6d 756e 6963 6174 6528 290a 2020 2020 mmunicate(). \n-0000e270: 6578 6365 7074 2042 726f 6b65 6e50 6970 except BrokenPip\n-0000e280: 6545 7272 6f72 3a0a 2020 2020 2020 2020 eError:. \n-0000e290: 2320 6578 7065 6374 6564 2069 6620 7468 # expected if th\n-0000e2a0: 6520 7065 6572 2064 6f65 736e 2774 2068 e peer doesn't h\n-0000e2b0: 616e 6720 7570 2063 6c65 616e 6c79 0a20 ang up cleanly. \n-0000e2c0: 2020 2020 2020 2070 6173 730a 0a0a 6465 pass...de\n-0000e2d0: 6620 6d61 696e 2829 202d 3e20 4e6f 6e65 f main() -> None\n-0000e2e0: 3a0a 2020 2020 706f 6c79 6669 6c6c 732e :. polyfills.\n-0000e2f0: 696e 7374 616c 6c28 290a 0a20 2020 2070 install().. p\n-0000e300: 6172 7365 7220 3d20 6172 6770 6172 7365 arser = argparse\n-0000e310: 2e41 7267 756d 656e 7450 6172 7365 7228 .ArgumentParser(\n-0000e320: 6465 7363 7269 7074 696f 6e3d 2763 6f63 description='coc\n-0000e330: 6b70 6974 2d62 7269 6467 6520 6973 2072 kpit-bridge is r\n-0000e340: 756e 2061 7574 6f6d 6174 6963 616c 6c79 un automatically\n-0000e350: 2069 6e73 6964 6520 6f66 2061 2043 6f63 inside of a Coc\n-0000e360: 6b70 6974 2073 6573 7369 6f6e 2e27 290a kpit session.').\n-0000e370: 2020 2020 7061 7273 6572 2e61 6464 5f61 parser.add_a\n-0000e380: 7267 756d 656e 7428 272d 2d61 6c77 6179 rgument('--alway\n-0000e390: 7327 2c20 6163 7469 6f6e 3d27 7374 6f72 s', action='stor\n-0000e3a0: 655f 7472 7565 272c 2068 656c 703d 224e e_true', help=\"N\n-0000e3b0: 6576 6572 2074 7279 2074 6f20 7275 6e20 ever try to run \n-0000e3c0: 636f 636b 7069 742d 6272 6964 6765 2066 cockpit-bridge f\n-0000e3d0: 726f 6d20 7468 6520 7379 7374 656d 2229 rom the system\")\n-0000e3e0: 0a20 2020 2070 6172 7365 722e 6164 645f . parser.add_\n-0000e3f0: 6172 6775 6d65 6e74 2827 2d2d 6465 6275 argument('--debu\n-0000e400: 6727 2c20 6163 7469 6f6e 3d27 7374 6f72 g', action='stor\n-0000e410: 655f 7472 7565 2729 0a20 2020 2070 6172 e_true'). par\n-0000e420: 7365 722e 6164 645f 6172 6775 6d65 6e74 ser.add_argument\n-0000e430: 2827 6465 7374 696e 6174 696f 6e27 2c20 ('destination', \n-0000e440: 6865 6c70 3d22 4e61 6d65 206f 6620 7468 help=\"Name of th\n-0000e450: 6520 7265 6d6f 7465 2068 6f73 7420 746f e remote host to\n-0000e460: 2063 6f6e 6e65 6374 2074 6f2c 206f 7220 connect to, or \n-0000e470: 276c 6f63 616c 686f 7374 2722 290a 2020 'localhost'\"). \n-0000e480: 2020 6172 6773 203d 2070 6172 7365 722e args = parser.\n-0000e490: 7061 7273 655f 6172 6773 2829 0a0a 2020 parse_args().. \n-0000e4a0: 2020 7365 7475 705f 6c6f 6767 696e 6728 setup_logging(\n-0000e4b0: 6465 6275 673d 6172 6773 2e64 6562 7567 debug=args.debug\n-0000e4c0: 290a 0a20 2020 2061 7379 6e63 696f 2e72 ).. asyncio.r\n-0000e4d0: 756e 2872 756e 2861 7267 7329 2c20 6465 un(run(args), de\n-0000e4e0: 6275 673d 6172 6773 2e64 6562 7567 290a bug=args.debug).\n-0000e4f0: 0a0a 6966 205f 5f6e 616d 655f 5f20 3d3d ..if __name__ ==\n-0000e500: 2027 5f5f 6d61 696e 5f5f 273a 0a20 2020 '__main__':. \n-0000e510: 206d 6169 6e28 290a 2727 272c 0a20 2027 main().''',. '\n-0000e520: 636f 636b 7069 742f 636f 6e66 6967 2e70 cockpit/config.p\n-0000e530: 7927 3a20 6272 2727 2723 2054 6869 7320 y': br'''# This \n-0000e540: 6669 6c65 2069 7320 7061 7274 206f 6620 file is part of \n-0000e550: 436f 636b 7069 742e 0a23 0a23 2043 6f70 Cockpit..#.# Cop\n-0000e560: 7972 6967 6874 2028 4329 2032 3032 3320 yright (C) 2023 \n-0000e570: 5265 6420 4861 742c 2049 6e63 2e0a 230a Red Hat, Inc..#.\n-0000e580: 2320 5468 6973 2070 726f 6772 616d 2069 # This program i\n-0000e590: 7320 6672 6565 2073 6f66 7477 6172 653a s free software:\n-0000e5a0: 2079 6f75 2063 616e 2072 6564 6973 7472 you can redistr\n-0000e5b0: 6962 7574 6520 6974 2061 6e64 2f6f 7220 ibute it and/or \n-0000e5c0: 6d6f 6469 6679 0a23 2069 7420 756e 6465 modify.# it unde\n-0000e5d0: 7220 7468 6520 7465 726d 7320 6f66 2074 r the terms of t\n-0000e5e0: 6865 2047 4e55 2047 656e 6572 616c 2050 he GNU General P\n-0000e5f0: 7562 6c69 6320 4c69 6365 6e73 6520 6173 ublic License as\n-0000e600: 2070 7562 6c69 7368 6564 2062 790a 2320 published by.# \n-0000e610: 7468 6520 4672 6565 2053 6f66 7477 6172 the Free Softwar\n-0000e620: 6520 466f 756e 6461 7469 6f6e 2c20 6569 e Foundation, ei\n-0000e630: 7468 6572 2076 6572 7369 6f6e 2033 206f ther version 3 o\n-0000e640: 6620 7468 6520 4c69 6365 6e73 652c 206f f the License, o\n-0000e650: 720a 2320 2861 7420 796f 7572 206f 7074 r.# (at your opt\n-0000e660: 696f 6e29 2061 6e79 206c 6174 6572 2076 ion) any later v\n-0000e670: 6572 7369 6f6e 2e0a 230a 2320 5468 6973 ersion..#.# This\n-0000e680: 2070 726f 6772 616d 2069 7320 6469 7374 program is dist\n-0000e690: 7269 6275 7465 6420 696e 2074 6865 2068 ributed in the h\n-0000e6a0: 6f70 6520 7468 6174 2069 7420 7769 6c6c ope that it will\n-0000e6b0: 2062 6520 7573 6566 756c 2c0a 2320 6275 be useful,.# bu\n-0000e6c0: 7420 5749 5448 4f55 5420 414e 5920 5741 t WITHOUT ANY WA\n-0000e6d0: 5252 414e 5459 3b20 7769 7468 6f75 7420 RRANTY; without \n-0000e6e0: 6576 656e 2074 6865 2069 6d70 6c69 6564 even the implied\n-0000e6f0: 2077 6172 7261 6e74 7920 6f66 0a23 204d warranty of.# M\n-0000e700: 4552 4348 414e 5441 4249 4c49 5459 206f ERCHANTABILITY o\n-0000e710: 7220 4649 544e 4553 5320 464f 5220 4120 r FITNESS FOR A \n-0000e720: 5041 5254 4943 554c 4152 2050 5552 504f PARTICULAR PURPO\n-0000e730: 5345 2e20 2053 6565 2074 6865 0a23 2047 SE. See the.# G\n-0000e740: 4e55 2047 656e 6572 616c 2050 7562 6c69 NU General Publi\n-0000e750: 6320 4c69 6365 6e73 6520 666f 7220 6d6f c License for mo\n-0000e760: 7265 2064 6574 6169 6c73 2e0a 230a 2320 re details..#.# \n-0000e770: 596f 7520 7368 6f75 6c64 2068 6176 6520 You should have \n-0000e780: 7265 6365 6976 6564 2061 2063 6f70 7920 received a copy \n-0000e790: 6f66 2074 6865 2047 4e55 2047 656e 6572 of the GNU Gener\n-0000e7a0: 616c 2050 7562 6c69 6320 4c69 6365 6e73 al Public Licens\n-0000e7b0: 650a 2320 616c 6f6e 6720 7769 7468 2074 e.# along with t\n-0000e7c0: 6869 7320 7072 6f67 7261 6d2e 2020 4966 his program. If\n-0000e7d0: 206e 6f74 2c20 7365 6520 3c68 7474 7073 not, see ...impo\n-0000e800: 7274 2063 6f6e 6669 6770 6172 7365 720a rt configparser.\n-0000e810: 696d 706f 7274 206c 6f67 6769 6e67 0a69 import logging.i\n-0000e820: 6d70 6f72 7420 6f73 0a66 726f 6d20 7061 mport os.from pa\n-0000e830: 7468 6c69 6220 696d 706f 7274 2050 6174 thlib import Pat\n-0000e840: 680a 0a66 726f 6d20 636f 636b 7069 742e h..from cockpit.\n-0000e850: 5f76 656e 646f 722e 7379 7374 656d 645f _vendor.systemd_\n-0000e860: 6374 7970 6573 2069 6d70 6f72 7420 6275 ctypes import bu\n-0000e870: 730a 0a6c 6f67 6765 7220 3d20 6c6f 6767 s..logger = logg\n-0000e880: 696e 672e 6765 744c 6f67 6765 7228 5f5f ing.getLogger(__\n-0000e890: 6e61 6d65 5f5f 290a 0a58 4447 5f43 4f4e name__)..XDG_CON\n-0000e8a0: 4649 475f 484f 4d45 203d 2050 6174 6828 FIG_HOME = Path(\n-0000e8b0: 6f73 2e67 6574 656e 7628 2758 4447 5f43 os.getenv('XDG_C\n-0000e8c0: 4f4e 4649 475f 484f 4d45 2729 206f 7220 ONFIG_HOME') or \n-0000e8d0: 6f73 2e70 6174 682e 6578 7061 6e64 7573 os.path.expandus\n-0000e8e0: 6572 2827 7e2f 2e63 6f6e 6669 6727 2929 er('~/.config'))\n-0000e8f0: 0a44 4f54 5f43 4f4e 4649 475f 434f 434b .DOT_CONFIG_COCK\n-0000e900: 5049 5420 3d20 5844 475f 434f 4e46 4947 PIT = XDG_CONFIG\n-0000e910: 5f48 4f4d 4520 2f20 2763 6f63 6b70 6974 _HOME / 'cockpit\n-0000e920: 270a 0a0a 6465 6620 6c6f 6f6b 7570 5f63 '...def lookup_c\n-0000e930: 6f6e 6669 6728 6669 6c65 6e61 6d65 3a20 onfig(filename: \n-0000e940: 7374 7229 202d 3e20 5061 7468 3a0a 2020 str) -> Path:. \n-0000e950: 2020 636f 6e66 6967 5f64 6972 7320 3d20 config_dirs = \n-0000e960: 6f73 2e65 6e76 6972 6f6e 2e67 6574 2827 os.environ.get('\n-0000e970: 5844 475f 434f 4e46 4947 5f44 4952 5327 XDG_CONFIG_DIRS'\n-0000e980: 2c20 272f 6574 6327 292e 7370 6c69 7428 , '/etc').split(\n-0000e990: 273a 2729 0a20 2020 2066 616c 6c62 6163 ':'). fallbac\n-0000e9a0: 6b20 3d20 4e6f 6e65 0a20 2020 2066 6f72 k = None. for\n-0000e9b0: 2063 6f6e 6669 675f 6469 7220 696e 2063 config_dir in c\n-0000e9c0: 6f6e 6669 675f 6469 7273 3a0a 2020 2020 onfig_dirs:. \n-0000e9d0: 2020 2020 636f 6e66 6967 5f70 6174 6820 config_path \n-0000e9e0: 3d20 5061 7468 2863 6f6e 6669 675f 6469 = Path(config_di\n-0000e9f0: 722c 2027 636f 636b 7069 7427 2c20 6669 r, 'cockpit', fi\n-0000ea00: 6c65 6e61 6d65 290a 2020 2020 2020 2020 lename). \n-0000ea10: 6966 206e 6f74 2066 616c 6c62 6163 6b3a if not fallback:\n-0000ea20: 0a20 2020 2020 2020 2020 2020 2066 616c . fal\n-0000ea30: 6c62 6163 6b20 3d20 636f 6e66 6967 5f70 lback = config_p\n-0000ea40: 6174 680a 2020 2020 2020 2020 6966 2063 ath. if c\n-0000ea50: 6f6e 6669 675f 7061 7468 2e65 7869 7374 onfig_path.exist\n-0000ea60: 7328 293a 0a20 2020 2020 2020 2020 2020 s():. \n-0000ea70: 206c 6f67 6765 722e 6465 6275 6728 276c logger.debug('l\n-0000ea80: 6f6f 6b75 705f 636f 6e66 6967 2825 7329 ookup_config(%s)\n-0000ea90: 3a20 666f 756e 6420 2573 272c 2066 696c : found %s', fil\n-0000eaa0: 656e 616d 652c 2063 6f6e 6669 675f 7061 ename, config_pa\n-0000eab0: 7468 290a 2020 2020 2020 2020 2020 2020 th). \n-0000eac0: 7265 7475 726e 2063 6f6e 6669 675f 7061 return config_pa\n-0000ead0: 7468 0a0a 2020 2020 2320 6465 6661 756c th.. # defaul\n-0000eae0: 7420 746f 2074 6865 2066 6972 7374 2065 t to the first e\n-0000eaf0: 6e74 7279 2069 6e20 5844 475f 434f 4e46 ntry in XDG_CONF\n-0000eb00: 4947 5f44 4952 533b 2074 6861 7427 7320 IG_DIRS; that's \n-0000eb10: 6e6f 7420 6163 636f 7264 696e 6720 746f not according to\n-0000eb20: 2074 6865 2073 7065 632c 0a20 2020 2023 the spec,. #\n-0000eb30: 2062 7574 2077 6861 7420 436f 636b 7069 but what Cockpi\n-0000eb40: 7420 6861 7320 646f 6e65 2066 6f72 2079 t has done for y\n-0000eb50: 6561 7273 0a20 2020 206c 6f67 6765 722e ears. logger.\n-0000eb60: 6465 6275 6728 276c 6f6f 6b75 705f 636f debug('lookup_co\n-0000eb70: 6e66 6967 2825 7329 3a20 6465 6661 756c nfig(%s): defaul\n-0000eb80: 7469 6e67 2074 6f20 2573 272c 2066 696c ting to %s', fil\n-0000eb90: 656e 616d 652c 2066 616c 6c62 6163 6b29 ename, fallback)\n-0000eba0: 0a20 2020 2061 7373 6572 7420 6661 6c6c . assert fall\n-0000ebb0: 6261 636b 2020 2320 6d79 7079 3b20 636f back # mypy; co\n-0000ebc0: 6e66 6967 5f64 6972 7320 616c 7761 7973 nfig_dirs always\n-0000ebd0: 2068 6173 2061 7420 6c65 6173 7420 6f6e has at least on\n-0000ebe0: 6520 7374 7269 6e67 0a20 2020 2072 6574 e string. ret\n-0000ebf0: 7572 6e20 6661 6c6c 6261 636b 0a0a 0a63 urn fallback...c\n-0000ec00: 6c61 7373 2043 6f6e 6669 6728 6275 732e lass Config(bus.\n-0000ec10: 4f62 6a65 6374 2c20 696e 7465 7266 6163 Object, interfac\n-0000ec20: 653d 2763 6f63 6b70 6974 2e43 6f6e 6669 e='cockpit.Confi\n-0000ec30: 6727 293a 0a20 2020 2064 6566 205f 5f69 g'):. def __i\n-0000ec40: 6e69 745f 5f28 7365 6c66 293a 0a20 2020 nit__(self):. \n-0000ec50: 2020 2020 2073 656c 662e 7265 6c6f 6164 self.reload\n-0000ec60: 2829 0a0a 2020 2020 4062 7573 2e49 6e74 ().. @bus.Int\n-0000ec70: 6572 6661 6365 2e4d 6574 686f 6428 6f75 erface.Method(ou\n-0000ec80: 745f 7479 7065 733d 2773 272c 2069 6e5f t_types='s', in_\n-0000ec90: 7479 7065 733d 2773 7327 290a 2020 2020 types='ss'). \n-0000eca0: 6465 6620 6765 745f 7374 7269 6e67 2873 def get_string(s\n-0000ecb0: 656c 662c 2073 6563 7469 6f6e 2c20 6b65 elf, section, ke\n-0000ecc0: 7929 3a0a 2020 2020 2020 2020 7472 793a y):. try:\n-0000ecd0: 0a20 2020 2020 2020 2020 2020 2072 6574 . ret\n-0000ece0: 7572 6e20 7365 6c66 2e63 6f6e 6669 675b urn self.config[\n-0000ecf0: 7365 6374 696f 6e5d 5b6b 6579 5d0a 2020 section][key]. \n-0000ed00: 2020 2020 2020 6578 6365 7074 204b 6579 except Key\n-0000ed10: 4572 726f 7220 6173 2065 7863 3a0a 2020 Error as exc:. \n-0000ed20: 2020 2020 2020 2020 2020 7261 6973 6520 raise \n-0000ed30: 6275 732e 4275 7345 7272 6f72 2827 636f bus.BusError('co\n-0000ed40: 636b 7069 742e 436f 6e66 6967 2e4b 6579 ckpit.Config.Key\n-0000ed50: 4572 726f 7227 2c20 6627 6b65 7920 7b6b Error', f'key {k\n-0000ed60: 6579 7d20 696e 2073 6563 7469 6f6e 207b ey} in section {\n-0000ed70: 7365 6374 696f 6e7d 2064 6f65 7320 6e6f section} does no\n-0000ed80: 7420 6578 6973 7427 2920 6672 6f6d 2065 t exist') from e\n-0000ed90: 7863 0a0a 2020 2020 4062 7573 2e49 6e74 xc.. @bus.Int\n-0000eda0: 6572 6661 6365 2e4d 6574 686f 6428 6f75 erface.Method(ou\n-0000edb0: 745f 7479 7065 733d 2775 272c 2069 6e5f t_types='u', in_\n-0000edc0: 7479 7065 733d 2773 7375 7575 2729 0a20 types='ssuuu'). \n-0000edd0: 2020 2064 6566 2067 6574 5f75 5f69 6e74 def get_u_int\n-0000ede0: 2873 656c 662c 2073 6563 7469 6f6e 2c20 (self, section, \n-0000edf0: 6b65 792c 2064 6566 6175 6c74 2c20 6d61 key, default, ma\n-0000ee00: 7869 6d75 6d2c 206d 696e 696d 756d 293a ximum, minimum):\n-0000ee10: 0a20 2020 2020 2020 2074 7279 3a0a 2020 . try:. \n-0000ee20: 2020 2020 2020 2020 2020 7661 6c75 6520 value \n-0000ee30: 3d20 7365 6c66 2e63 6f6e 6669 675b 7365 = self.config[se\n-0000ee40: 6374 696f 6e5d 5b6b 6579 5d0a 2020 2020 ction][key]. \n-0000ee50: 2020 2020 6578 6365 7074 204b 6579 4572 except KeyEr\n-0000ee60: 726f 723a 0a20 2020 2020 2020 2020 2020 ror:. \n-0000ee70: 2072 6574 7572 6e20 6465 6661 756c 740a return default.\n-0000ee80: 0a20 2020 2020 2020 2074 7279 3a0a 2020 . try:. \n-0000ee90: 2020 2020 2020 2020 2020 696e 745f 7661 int_va\n-0000eea0: 6c20 3d20 696e 7428 7661 6c75 6529 0a20 l = int(value). \n-0000eeb0: 2020 2020 2020 2065 7863 6570 7420 5661 except Va\n-0000eec0: 6c75 6545 7272 6f72 3a0a 2020 2020 2020 lueError:. \n-0000eed0: 2020 2020 2020 6c6f 6767 6572 2e77 6172 logger.war\n-0000eee0: 6e69 6e67 2827 636f 636b 7069 742e 636f ning('cockpit.co\n-0000eef0: 6e66 3a20 5b25 735d 2025 7320 6973 206e nf: [%s] %s is n\n-0000ef00: 6f74 2061 6e20 696e 7465 6765 7227 2c20 ot an integer', \n-0000ef10: 7365 6374 696f 6e2c 206b 6579 290a 2020 section, key). \n-0000ef20: 2020 2020 2020 2020 2020 7265 7475 726e return\n-0000ef30: 2064 6566 6175 6c74 0a0a 2020 2020 2020 default.. \n-0000ef40: 2020 7265 7475 726e 206d 696e 286d 6178 return min(max\n-0000ef50: 2869 6e74 5f76 616c 2c20 6d69 6e69 6d75 (int_val, minimu\n-0000ef60: 6d29 2c20 6d61 7869 6d75 6d29 0a0a 2020 m), maximum).. \n-0000ef70: 2020 4062 7573 2e49 6e74 6572 6661 6365 @bus.Interface\n-0000ef80: 2e4d 6574 686f 6428 290a 2020 2020 6465 .Method(). de\n-0000ef90: 6620 7265 6c6f 6164 2873 656c 6629 3a0a f reload(self):.\n-0000efa0: 2020 2020 2020 2020 7365 6c66 2e63 6f6e self.con\n-0000efb0: 6669 6720 3d20 636f 6e66 6967 7061 7273 fig = configpars\n-0000efc0: 6572 2e43 6f6e 6669 6750 6172 7365 7228 er.ConfigParser(\n-0000efd0: 696e 7465 7270 6f6c 6174 696f 6e3d 4e6f interpolation=No\n-0000efe0: 6e65 290a 2020 2020 2020 2020 636f 636b ne). cock\n-0000eff0: 7069 745f 636f 6e66 203d 206c 6f6f 6b75 pit_conf = looku\n-0000f000: 705f 636f 6e66 6967 2827 636f 636b 7069 p_config('cockpi\n-0000f010: 742e 636f 6e66 2729 0a20 2020 2020 2020 t.conf'). \n-0000f020: 206c 6f67 6765 722e 6465 6275 6728 2263 logger.debug(\"c\n-0000f030: 6f63 6b70 6974 2e43 6f6e 6669 673a 206c ockpit.Config: l\n-0000f040: 6f61 6469 6e67 2025 7322 2c20 636f 636b oading %s\", cock\n-0000f050: 7069 745f 636f 6e66 290a 2020 2020 2020 pit_conf). \n-0000f060: 2020 2320 7468 6973 206d 6179 206e 6f74 # this may not\n-0000f070: 2065 7869 7374 2c20 6275 7420 6974 2773 exist, but it's\n-0000f080: 206f 6b20 746f 206e 6f74 2068 6176 6520 ok to not have \n-0000f090: 6120 636f 6e66 6967 2066 696c 6520 616e a config file an\n-0000f0a0: 6420 7468 7573 206c 6561 7665 2073 656c d thus leave sel\n-0000f0b0: 662e 636f 6e66 6967 2065 6d70 7479 0a20 f.config empty. \n-0000f0c0: 2020 2020 2020 2073 656c 662e 636f 6e66 self.conf\n-0000f0d0: 6967 2e72 6561 6428 636f 636b 7069 745f ig.read(cockpit_\n-0000f0e0: 636f 6e66 290a 0a0a 636c 6173 7320 456e conf)...class En\n-0000f0f0: 7669 726f 6e6d 656e 7428 6275 732e 4f62 vironment(bus.Ob\n-0000f100: 6a65 6374 2c20 696e 7465 7266 6163 653d ject, interface=\n-0000f110: 2763 6f63 6b70 6974 2e45 6e76 6972 6f6e 'cockpit.Environ\n-0000f120: 6d65 6e74 2729 3a0a 2020 2020 7661 7269 ment'):. vari\n-0000f130: 6162 6c65 7320 3d20 6275 732e 496e 7465 ables = bus.Inte\n-0000f140: 7266 6163 652e 5072 6f70 6572 7479 2827 rface.Property('\n-0000f150: 617b 7373 7d27 290a 0a20 2020 2040 7661 a{ss}').. @va\n-0000f160: 7269 6162 6c65 732e 6765 7474 6572 0a20 riables.getter. \n-0000f170: 2020 2064 6566 2067 6574 5f76 6172 6961 def get_varia\n-0000f180: 626c 6573 2873 656c 6629 3a0a 2020 2020 bles(self):. \n-0000f190: 2020 2020 7265 7475 726e 206f 732e 656e return os.en\n-0000f1a0: 7669 726f 6e2e 636f 7079 2829 0a27 2727 viron.copy().'''\n-0000f1b0: 2c0a 2020 2763 6f63 6b70 6974 2f63 6861 ,. 'cockpit/cha\n-0000f1c0: 6e6e 656c 2e70 7927 3a20 7227 2727 2320 nnel.py': r'''# \n-0000f1d0: 5468 6973 2066 696c 6520 6973 2070 6172 This file is par\n-0000f1e0: 7420 6f66 2043 6f63 6b70 6974 2e0a 230a t of Cockpit..#.\n-0000f1f0: 2320 436f 7079 7269 6768 7420 2843 2920 # Copyright (C) \n-0000f200: 3230 3232 2052 6564 2048 6174 2c20 496e 2022 Red Hat, In\n-0000f210: 632e 0a23 0a23 2054 6869 7320 7072 6f67 c..#.# This prog\n-0000f220: 7261 6d20 6973 2066 7265 6520 736f 6674 ram is free soft\n-0000f230: 7761 7265 3a20 796f 7520 6361 6e20 7265 ware: you can re\n-0000f240: 6469 7374 7269 6275 7465 2069 7420 616e distribute it an\n-0000f250: 642f 6f72 206d 6f64 6966 790a 2320 6974 d/or modify.# it\n-0000f260: 2075 6e64 6572 2074 6865 2074 6572 6d73 under the terms\n-0000f270: 206f 6620 7468 6520 474e 5520 4765 6e65 of the GNU Gene\n-0000f280: 7261 6c20 5075 626c 6963 204c 6963 656e ral Public Licen\n-0000f290: 7365 2061 7320 7075 626c 6973 6865 6420 se as published \n-0000f2a0: 6279 0a23 2074 6865 2046 7265 6520 536f by.# the Free So\n-0000f2b0: 6674 7761 7265 2046 6f75 6e64 6174 696f ftware Foundatio\n-0000f2c0: 6e2c 2065 6974 6865 7220 7665 7273 696f n, either versio\n-0000f2d0: 6e20 3320 6f66 2074 6865 204c 6963 656e n 3 of the Licen\n-0000f2e0: 7365 2c20 6f72 0a23 2028 6174 2079 6f75 se, or.# (at you\n-0000f2f0: 7220 6f70 7469 6f6e 2920 616e 7920 6c61 r option) any la\n-0000f300: 7465 7220 7665 7273 696f 6e2e 0a23 0a23 ter version..#.#\n-0000f310: 2054 6869 7320 7072 6f67 7261 6d20 6973 This program is\n-0000f320: 2064 6973 7472 6962 7574 6564 2069 6e20 distributed in \n-0000f330: 7468 6520 686f 7065 2074 6861 7420 6974 the hope that it\n-0000f340: 2077 696c 6c20 6265 2075 7365 6675 6c2c will be useful,\n-0000f350: 0a23 2062 7574 2057 4954 484f 5554 2041 .# but WITHOUT A\n-0000f360: 4e59 2057 4152 5241 4e54 593b 2077 6974 NY WARRANTY; wit\n-0000f370: 686f 7574 2065 7665 6e20 7468 6520 696d hout even the im\n-0000f380: 706c 6965 6420 7761 7272 616e 7479 206f plied warranty o\n-0000f390: 660a 2320 4d45 5243 4841 4e54 4142 494c f.# MERCHANTABIL\n-0000f3a0: 4954 5920 6f72 2046 4954 4e45 5353 2046 ITY or FITNESS F\n-0000f3b0: 4f52 2041 2050 4152 5449 4355 4c41 5220 OR A PARTICULAR \n-0000f3c0: 5055 5250 4f53 452e 2020 5365 6520 7468 PURPOSE. See th\n-0000f3d0: 650a 2320 474e 5520 4765 6e65 7261 6c20 e.# GNU General \n-0000f3e0: 5075 626c 6963 204c 6963 656e 7365 2066 Public License f\n-0000f3f0: 6f72 206d 6f72 6520 6465 7461 696c 732e or more details.\n-0000f400: 0a23 0a23 2059 6f75 2073 686f 756c 6420 .#.# You should \n-0000f410: 6861 7665 2072 6563 6569 7665 6420 6120 have received a \n-0000f420: 636f 7079 206f 6620 7468 6520 474e 5520 copy of the GNU \n-0000f430: 4765 6e65 7261 6c20 5075 626c 6963 204c General Public L\n-0000f440: 6963 656e 7365 0a23 2061 6c6f 6e67 2077 icense.# along w\n-0000f450: 6974 6820 7468 6973 2070 726f 6772 616d ith this program\n-0000f460: 2e20 2049 6620 6e6f 742c 2073 6565 203c . If not, see <\n-0000f470: 6874 7470 733a 2f2f 7777 772e 676e 752e https://www.gnu.\n-0000f480: 6f72 672f 6c69 6365 6e73 6573 2f3e 2e0a org/licenses/>..\n-0000f490: 0a69 6d70 6f72 7420 6173 796e 6369 6f0a .import asyncio.\n-0000f4a0: 696d 706f 7274 206a 736f 6e0a 696d 706f import json.impo\n-0000f4b0: 7274 206c 6f67 6769 6e67 0a69 6d70 6f72 rt logging.impor\n-0000f4c0: 7420 7472 6163 6562 6163 6b0a 6672 6f6d t traceback.from\n-0000f4d0: 2074 7970 696e 6720 696d 706f 7274 2042 typing import B\n-0000f4e0: 696e 6172 7949 4f2c 2043 6c61 7373 5661 inaryIO, ClassVa\n-0000f4f0: 722c 2044 6963 742c 2047 656e 6572 6174 r, Dict, Generat\n-0000f500: 6f72 2c20 4c69 7374 2c20 4d61 7070 696e or, List, Mappin\n-0000f510: 672c 204f 7074 696f 6e61 6c2c 2053 6571 g, Optional, Seq\n-0000f520: 7565 6e63 652c 2053 6574 2c20 5475 706c uence, Set, Tupl\n-0000f530: 652c 2054 7970 650a 0a66 726f 6d20 2e6a e, Type..from .j\n-0000f540: 736f 6e75 7469 6c20 696d 706f 7274 204a sonutil import J\n-0000f550: 736f 6e45 7272 6f72 2c20 4a73 6f6e 4f62 sonError, JsonOb\n-0000f560: 6a65 6374 2c20 4a73 6f6e 5661 6c75 652c ject, JsonValue,\n-0000f570: 2063 7265 6174 655f 6f62 6a65 6374 2c20 create_object, \n-0000f580: 6765 745f 626f 6f6c 2c20 6765 745f 656e get_bool, get_en\n-0000f590: 756d 2c20 6765 745f 7374 720a 6672 6f6d um, get_str.from\n-0000f5a0: 202e 7072 6f74 6f63 6f6c 2069 6d70 6f72 .protocol impor\n-0000f5b0: 7420 436f 636b 7069 7450 726f 626c 656d t CockpitProblem\n-0000f5c0: 0a66 726f 6d20 2e72 6f75 7465 7220 696d .from .router im\n-0000f5d0: 706f 7274 2045 6e64 706f 696e 742c 2052 port Endpoint, R\n-0000f5e0: 6f75 7465 722c 2052 6f75 7469 6e67 5275 outer, RoutingRu\n-0000f5f0: 6c65 0a0a 6c6f 6767 6572 203d 206c 6f67 le..logger = log\n-0000f600: 6769 6e67 2e67 6574 4c6f 6767 6572 285f ging.getLogger(_\n-0000f610: 5f6e 616d 655f 5f29 0a0a 0a63 6c61 7373 _name__)...class\n-0000f620: 2043 6861 6e6e 656c 526f 7574 696e 6752 ChannelRoutingR\n-0000f630: 756c 6528 526f 7574 696e 6752 756c 6529 ule(RoutingRule)\n-0000f640: 3a0a 2020 2020 7461 626c 653a 2044 6963 :. table: Dic\n-0000f650: 745b 7374 722c 204c 6973 745b 5479 7065 t[str, List[Type\n-0000f660: 5b27 4368 616e 6e65 6c27 5d5d 5d0a 0a20 ['Channel']]].. \n-0000f670: 2020 2064 6566 205f 5f69 6e69 745f 5f28 def __init__(\n-0000f680: 7365 6c66 2c20 726f 7574 6572 3a20 526f self, router: Ro\n-0000f690: 7574 6572 2c20 6368 616e 6e65 6c5f 7479 uter, channel_ty\n-0000f6a0: 7065 733a 204c 6973 745b 5479 7065 5b27 pes: List[Type['\n-0000f6b0: 4368 616e 6e65 6c27 5d5d 293a 0a20 2020 Channel']]):. \n-0000f6c0: 2020 2020 2073 7570 6572 2829 2e5f 5f69 super().__i\n-0000f6d0: 6e69 745f 5f28 726f 7574 6572 290a 2020 nit__(router). \n-0000f6e0: 2020 2020 2020 7365 6c66 2e74 6162 6c65 self.table\n-0000f6f0: 203d 207b 7d0a 0a20 2020 2020 2020 2023 = {}.. #\n-0000f700: 2053 6f72 7420 7468 6520 6368 616e 6e65 Sort the channe\n-0000f710: 6c73 2069 6e74 6f20 6275 636b 6574 7320 ls into buckets \n-0000f720: 6279 2070 6179 6c6f 6164 2074 7970 650a by payload type.\n-0000f730: 2020 2020 2020 2020 666f 7220 636c 7320 for cls \n-0000f740: 696e 2063 6861 6e6e 656c 5f74 7970 6573 in channel_types\n-0000f750: 3a0a 2020 2020 2020 2020 2020 2020 656e :. en\n-0000f760: 7472 7920 3d20 7365 6c66 2e74 6162 6c65 try = self.table\n-0000f770: 2e73 6574 6465 6661 756c 7428 636c 732e .setdefault(cls.\n-0000f780: 7061 796c 6f61 642c 205b 5d29 0a20 2020 payload, []). \n-0000f790: 2020 2020 2020 2020 2065 6e74 7279 2e61 entry.a\n-0000f7a0: 7070 656e 6428 636c 7329 0a0a 2020 2020 ppend(cls).. \n-0000f7b0: 2020 2020 2320 5769 7468 696e 2065 6163 # Within eac\n-0000f7c0: 6820 6275 636b 6574 2c20 736f 7274 2074 h bucket, sort t\n-0000f7d0: 6865 2063 6861 6e6e 656c 7320 736f 2074 he channels so t\n-0000f7e0: 686f 7365 2077 6974 6820 6d6f 7265 0a20 hose with more. \n-0000f7f0: 2020 2020 2020 2023 2072 6573 7472 6963 # restric\n-0000f800: 7469 6f6e 7320 6172 6520 636f 6e73 6964 tions are consid\n-0000f810: 6572 6564 2066 6972 7374 2e0a 2020 2020 ered first.. \n-0000f820: 2020 2020 666f 7220 656e 7472 7920 696e for entry in\n-0000f830: 2073 656c 662e 7461 626c 652e 7661 6c75 self.table.valu\n-0000f840: 6573 2829 3a0a 2020 2020 2020 2020 2020 es():. \n-0000f850: 2020 656e 7472 792e 736f 7274 286b 6579 entry.sort(key\n-0000f860: 3d6c 616d 6264 6120 636c 733a 206c 656e =lambda cls: len\n-0000f870: 2863 6c73 2e72 6573 7472 6963 7469 6f6e (cls.restriction\n-0000f880: 7329 2c20 7265 7665 7273 653d 5472 7565 s), reverse=True\n-0000f890: 290a 0a20 2020 2064 6566 2063 6865 636b ).. def check\n-0000f8a0: 5f72 6573 7472 6963 7469 6f6e 7328 7365 _restrictions(se\n-0000f8b0: 6c66 2c20 7265 7374 7269 6374 696f 6e73 lf, restrictions\n-0000f8c0: 3a20 5365 7175 656e 6365 5b54 7570 6c65 : Sequence[Tuple\n-0000f8d0: 5b73 7472 2c20 6f62 6a65 6374 5d5d 2c20 [str, object]], \n-0000f8e0: 6f70 7469 6f6e 733a 204a 736f 6e4f 626a options: JsonObj\n-0000f8f0: 6563 7429 202d 3e20 626f 6f6c 3a0a 2020 ect) -> bool:. \n-0000f900: 2020 2020 2020 666f 7220 6b65 792c 2065 for key, e\n-0000f910: 7870 6563 7465 645f 7661 6c75 6520 696e xpected_value in\n-0000f920: 2072 6573 7472 6963 7469 6f6e 733a 0a20 restrictions:. \n-0000f930: 2020 2020 2020 2020 2020 206f 7572 5f76 our_v\n-0000f940: 616c 7565 203d 206f 7074 696f 6e73 2e67 alue = options.g\n-0000f950: 6574 286b 6579 290a 0a20 2020 2020 2020 et(key).. \n-0000f960: 2020 2020 2023 2049 6620 7468 6520 6d61 # If the ma\n-0000f970: 7463 6820 7275 6c65 2073 7065 6369 6669 tch rule specifi\n-0000f980: 6573 2074 6861 7420 6120 7661 6c75 6520 es that a value \n-0000f990: 6d75 7374 2062 6520 7072 6573 656e 7420 must be present \n-0000f9a0: 616e 640a 2020 2020 2020 2020 2020 2020 and. \n-0000f9b0: 2320 7765 2064 6f6e 2774 2068 6176 6520 # we don't have \n-0000f9c0: 6974 2c20 7468 656e 2066 6169 6c2e 0a20 it, then fail.. \n-0000f9d0: 2020 2020 2020 2020 2020 2069 6620 6f75 if ou\n-0000f9e0: 725f 7661 6c75 6520 6973 204e 6f6e 653a r_value is None:\n-0000f9f0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-0000fa00: 2072 6574 7572 6e20 4661 6c73 650a 0a20 return False.. \n-0000fa10: 2020 2020 2020 2020 2020 2023 2049 6620 # If \n-0000fa20: 7468 6520 6d61 7463 6820 7275 6c65 2073 the match rule s\n-0000fa30: 7065 6369 6669 6564 2061 2073 7065 6369 pecified a speci\n-0000fa40: 6669 6320 6578 7065 6374 6564 2076 616c fic expected val\n-0000fa50: 7565 2c20 616e 640a 2020 2020 2020 2020 ue, and. \n-0000fa60: 2020 2020 2320 6f75 7220 7661 6c75 6520 # our value \n-0000fa70: 646f 6573 6e27 7420 6d61 7463 6820 6974 doesn't match it\n-0000fa80: 2c20 7468 656e 2066 6169 6c2e 0a20 2020 , then fail.. \n-0000fa90: 2020 2020 2020 2020 2069 6620 6578 7065 if expe\n-0000faa0: 6374 6564 5f76 616c 7565 2069 7320 6e6f cted_value is no\n-0000fab0: 7420 4e6f 6e65 2061 6e64 206f 7572 5f76 t None and our_v\n-0000fac0: 616c 7565 2021 3d20 6578 7065 6374 6564 alue != expected\n-0000fad0: 5f76 616c 7565 3a0a 2020 2020 2020 2020 _value:. \n-0000fae0: 2020 2020 2020 2020 7265 7475 726e 2046 return F\n-0000faf0: 616c 7365 0a0a 2020 2020 2020 2020 2320 alse.. # \n-0000fb00: 4576 6572 7974 6869 6e67 2063 6865 636b Everything check\n-0000fb10: 6564 206f 7574 0a20 2020 2020 2020 2072 ed out. r\n-0000fb20: 6574 7572 6e20 5472 7565 0a0a 2020 2020 eturn True.. \n-0000fb30: 6465 6620 6170 706c 795f 7275 6c65 2873 def apply_rule(s\n-0000fb40: 656c 662c 206f 7074 696f 6e73 3a20 4a73 elf, options: Js\n-0000fb50: 6f6e 4f62 6a65 6374 2920 2d3e 204f 7074 onObject) -> Opt\n-0000fb60: 696f 6e61 6c5b 2743 6861 6e6e 656c 275d ional['Channel']\n-0000fb70: 3a0a 2020 2020 2020 2020 6173 7365 7274 :. assert\n-0000fb80: 2073 656c 662e 726f 7574 6572 2069 7320 self.router is \n-0000fb90: 6e6f 7420 4e6f 6e65 0a0a 2020 2020 2020 not None.. \n-0000fba0: 2020 7061 796c 6f61 6420 3d20 6f70 7469 payload = opti\n-0000fbb0: 6f6e 732e 6765 7428 2770 6179 6c6f 6164 ons.get('payload\n-0000fbc0: 2729 0a20 2020 2020 2020 2069 6620 6e6f '). if no\n-0000fbd0: 7420 6973 696e 7374 616e 6365 2870 6179 t isinstance(pay\n-0000fbe0: 6c6f 6164 2c20 7374 7229 3a0a 2020 2020 load, str):. \n-0000fbf0: 2020 2020 2020 2020 7265 7475 726e 204e return N\n-0000fc00: 6f6e 650a 0a20 2020 2020 2020 2066 6f72 one.. for\n-0000fc10: 2063 6c73 2069 6e20 7365 6c66 2e74 6162 cls in self.tab\n-0000fc20: 6c65 2e67 6574 2870 6179 6c6f 6164 2c20 le.get(payload, \n-0000fc30: 5b5d 293a 0a20 2020 2020 2020 2020 2020 []):. \n-0000fc40: 2069 6620 7365 6c66 2e63 6865 636b 5f72 if self.check_r\n-0000fc50: 6573 7472 6963 7469 6f6e 7328 636c 732e estrictions(cls.\n-0000fc60: 7265 7374 7269 6374 696f 6e73 2c20 6f70 restrictions, op\n-0000fc70: 7469 6f6e 7329 3a0a 2020 2020 2020 2020 tions):. \n-0000fc80: 2020 2020 2020 2020 7265 7475 726e 2063 return c\n-0000fc90: 6c73 2873 656c 662e 726f 7574 6572 290a ls(self.router).\n-0000fca0: 2020 2020 2020 2020 656c 7365 3a0a 2020 else:. \n-0000fcb0: 2020 2020 2020 2020 2020 7265 7475 726e return\n-0000fcc0: 204e 6f6e 650a 0a20 2020 2064 6566 2073 None.. def s\n-0000fcd0: 6875 7464 6f77 6e28 7365 6c66 293a 0a20 hutdown(self):. \n-0000fce0: 2020 2020 2020 2070 6173 7320 2023 2077 pass # w\n-0000fcf0: 6520 646f 6e27 7420 686f 6c64 2061 6e79 e don't hold any\n-0000fd00: 2073 7461 7465 0a0a 0a63 6c61 7373 2043 state...class C\n-0000fd10: 6861 6e6e 656c 4572 726f 7228 436f 636b hannelError(Cock\n-0000fd20: 7069 7450 726f 626c 656d 293a 0a20 2020 pitProblem):. \n-0000fd30: 2070 6173 730a 0a0a 636c 6173 7320 4368 pass...class Ch\n-0000fd40: 616e 6e65 6c28 456e 6470 6f69 6e74 293a annel(Endpoint):\n-0000fd50: 0a20 2020 2023 2056 616c 7565 7320 626f . # Values bo\n-0000fd60: 7272 6f77 6564 2066 726f 6d20 4320 696d rrowed from C im\n-0000fd70: 706c 656d 656e 7461 7469 6f6e 0a20 2020 plementation. \n-0000fd80: 2042 4c4f 434b 5f53 495a 4520 3d20 3136 BLOCK_SIZE = 16\n-0000fd90: 202a 2031 3032 340a 2020 2020 5345 4e44 * 1024. SEND\n-0000fda0: 5f57 494e 444f 5720 3d20 3220 2a20 3130 _WINDOW = 2 * 10\n-0000fdb0: 3234 202a 2031 3032 340a 0a20 2020 2023 24 * 1024.. #\n-0000fdc0: 2046 6c6f 7720 636f 6e74 726f 6c20 626f Flow control bo\n-0000fdd0: 6f6b 2d6b 6565 7069 6e67 0a20 2020 205f ok-keeping. _\n-0000fde0: 7365 6e64 5f70 696e 6773 3a20 626f 6f6c send_pings: bool\n-0000fdf0: 203d 2046 616c 7365 0a20 2020 205f 6f75 = False. _ou\n-0000fe00: 745f 7365 7175 656e 6365 3a20 696e 7420 t_sequence: int \n-0000fe10: 3d20 300a 2020 2020 5f6f 7574 5f77 696e = 0. _out_win\n-0000fe20: 646f 773a 2069 6e74 203d 2053 454e 445f dow: int = SEND_\n-0000fe30: 5749 4e44 4f57 0a20 2020 205f 6163 6b5f WINDOW. _ack_\n-0000fe40: 6279 7465 733a 2062 6f6f 6c0a 0a20 2020 bytes: bool.. \n-0000fe50: 2023 2054 6173 6b20 6d61 6e61 6765 6d65 # Task manageme\n-0000fe60: 6e74 0a20 2020 205f 7461 736b 733a 2053 nt. _tasks: S\n-0000fe70: 6574 5b61 7379 6e63 696f 2e54 6173 6b5d et[asyncio.Task]\n-0000fe80: 0a20 2020 205f 636c 6f73 655f 6172 6773 . _close_args\n-0000fe90: 3a20 4f70 7469 6f6e 616c 5b4a 736f 6e4f : Optional[JsonO\n-0000fea0: 626a 6563 745d 203d 204e 6f6e 650a 0a20 bject] = None.. \n-0000feb0: 2020 2023 204d 7573 7420 6265 2066 696c # Must be fil\n-0000fec0: 6c65 6420 696e 2062 7920 7468 6520 6368 led in by the ch\n-0000fed0: 616e 6e65 6c20 696d 706c 656d 656e 7461 annel implementa\n-0000fee0: 7469 6f6e 0a20 2020 2070 6179 6c6f 6164 tion. payload\n-0000fef0: 3a20 436c 6173 7356 6172 5b73 7472 5d0a : ClassVar[str].\n-0000ff00: 2020 2020 7265 7374 7269 6374 696f 6e73 restrictions\n-0000ff10: 3a20 436c 6173 7356 6172 5b53 6571 7565 : ClassVar[Seque\n-0000ff20: 6e63 655b 5475 706c 655b 7374 722c 206f nce[Tuple[str, o\n-0000ff30: 626a 6563 745d 5d5d 203d 2028 290a 0a20 bject]]] = ().. \n-0000ff40: 2020 2023 2054 6865 7365 2067 6574 2066 # These get f\n-0000ff50: 696c 6c65 6420 696e 2066 726f 6d20 2e64 illed in from .d\n-0000ff60: 6f5f 6f70 656e 2829 0a20 2020 2063 6861 o_open(). cha\n-0000ff70: 6e6e 656c 203d 2027 270a 2020 2020 6772 nnel = ''. gr\n-0000ff80: 6f75 7020 3d20 2727 0a0a 2020 2020 2320 oup = ''.. # \n-0000ff90: 696e 7075 740a 2020 2020 6465 6620 646f input. def do\n-0000ffa0: 5f63 6f6e 7472 6f6c 2873 656c 662c 2063 _control(self, c\n-0000ffb0: 6f6d 6d61 6e64 3a20 7374 722c 206d 6573 ommand: str, mes\n-0000ffc0: 7361 6765 3a20 4a73 6f6e 4f62 6a65 6374 sage: JsonObject\n-0000ffd0: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n-0000ffe0: 2020 2023 2042 7265 616b 2074 6865 2076 # Break the v\n-0000fff0: 6172 696f 7573 2064 6966 6665 7265 6e74 arious different\n-00010000: 206b 696e 6473 206f 6620 636f 6e74 726f kinds of contro\n-00010010: 6c20 6d65 7373 6167 6573 206f 7574 2069 l messages out i\n-00010020: 6e74 6f20 7468 650a 2020 2020 2020 2020 nto the. \n-00010030: 2320 7468 696e 6773 2074 6861 7420 6f75 # things that ou\n-00010040: 7220 7375 6263 6c61 7373 206d 6179 2062 r subclass may b\n-00010050: 6520 696e 7465 7265 7374 6564 2069 6e20 e interested in \n-00010060: 6861 6e64 6c69 6e67 2e20 2057 6520 6472 handling. We dr\n-00010070: 6f70 2074 6865 0a20 2020 2020 2020 2023 op the. #\n-00010080: 2027 6d65 7373 6167 6527 2066 6965 6c64 'message' field\n-00010090: 2066 6f72 2068 616e 646c 6572 7320 7468 for handlers th\n-000100a0: 6174 2064 6f6e 2774 206e 6565 6420 6974 at don't need it\n-000100b0: 2e0a 2020 2020 2020 2020 6966 2063 6f6d .. if com\n-000100c0: 6d61 6e64 203d 3d20 276f 7065 6e27 3a0a mand == 'open':.\n-000100d0: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n-000100e0: 2e5f 7461 736b 7320 3d20 7365 7428 290a ._tasks = set().\n-000100f0: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n-00010100: 2e63 6861 6e6e 656c 203d 2067 6574 5f73 .channel = get_s\n-00010110: 7472 286d 6573 7361 6765 2c20 2763 6861 tr(message, 'cha\n-00010120: 6e6e 656c 2729 0a20 2020 2020 2020 2020 nnel'). \n-00010130: 2020 2069 6620 6765 745f 626f 6f6c 286d if get_bool(m\n-00010140: 6573 7361 6765 2c20 2766 6c6f 772d 636f essage, 'flow-co\n-00010150: 6e74 726f 6c27 2c20 6465 6661 756c 743d ntrol', default=\n-00010160: 4661 6c73 6529 3a0a 2020 2020 2020 2020 False):. \n-00010170: 2020 2020 2020 2020 7365 6c66 2e5f 7365 self._se\n-00010180: 6e64 5f70 696e 6773 203d 2054 7275 650a nd_pings = True.\n-00010190: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n-000101a0: 2e5f 6163 6b5f 6279 7465 7320 3d20 6765 ._ack_bytes = ge\n-000101b0: 745f 656e 756d 286d 6573 7361 6765 2c20 t_enum(message, \n-000101c0: 2773 656e 642d 6163 6b73 272c 205b 2762 'send-acks', ['b\n-000101d0: 7974 6573 275d 2c20 4e6f 6e65 2920 6973 ytes'], None) is\n-000101e0: 206e 6f74 204e 6f6e 650a 2020 2020 2020 not None. \n-000101f0: 2020 2020 2020 7365 6c66 2e67 726f 7570 self.group\n-00010200: 203d 2067 6574 5f73 7472 286d 6573 7361 = get_str(messa\n-00010210: 6765 2c20 2767 726f 7570 272c 2027 6465 ge, 'group', 'de\n-00010220: 6661 756c 7427 290a 2020 2020 2020 2020 fault'). \n-00010230: 2020 2020 7365 6c66 2e66 7265 657a 655f self.freeze_\n-00010240: 656e 6470 6f69 6e74 2829 0a20 2020 2020 endpoint(). \n-00010250: 2020 2020 2020 2073 656c 662e 646f 5f6f self.do_o\n-00010260: 7065 6e28 6d65 7373 6167 6529 0a20 2020 pen(message). \n-00010270: 2020 2020 2065 6c69 6620 636f 6d6d 616e elif comman\n-00010280: 6420 3d3d 2027 7265 6164 7927 3a0a 2020 d == 'ready':. \n-00010290: 2020 2020 2020 2020 2020 7365 6c66 2e64 self.d\n-000102a0: 6f5f 7265 6164 7928 290a 2020 2020 2020 o_ready(). \n-000102b0: 2020 656c 6966 2063 6f6d 6d61 6e64 203d elif command =\n-000102c0: 3d20 2764 6f6e 6527 3a0a 2020 2020 2020 = 'done':. \n-000102d0: 2020 2020 2020 7365 6c66 2e64 6f5f 646f self.do_do\n-000102e0: 6e65 2829 0a20 2020 2020 2020 2065 6c69 ne(). eli\n-000102f0: 6620 636f 6d6d 616e 6420 3d3d 2027 636c f command == 'cl\n-00010300: 6f73 6527 3a0a 2020 2020 2020 2020 2020 ose':. \n-00010310: 2020 7365 6c66 2e64 6f5f 636c 6f73 6528 self.do_close(\n-00010320: 290a 2020 2020 2020 2020 656c 6966 2063 ). elif c\n-00010330: 6f6d 6d61 6e64 203d 3d20 2770 696e 6727 ommand == 'ping'\n-00010340: 3a0a 2020 2020 2020 2020 2020 2020 7365 :. se\n-00010350: 6c66 2e64 6f5f 7069 6e67 286d 6573 7361 lf.do_ping(messa\n-00010360: 6765 290a 2020 2020 2020 2020 656c 6966 ge). elif\n-00010370: 2063 6f6d 6d61 6e64 203d 3d20 2770 6f6e command == 'pon\n-00010380: 6727 3a0a 2020 2020 2020 2020 2020 2020 g':. \n-00010390: 7365 6c66 2e64 6f5f 706f 6e67 286d 6573 self.do_pong(mes\n-000103a0: 7361 6765 290a 2020 2020 2020 2020 656c sage). el\n-000103b0: 6966 2063 6f6d 6d61 6e64 203d 3d20 276f if command == 'o\n-000103c0: 7074 696f 6e73 273a 0a20 2020 2020 2020 ptions':. \n-000103d0: 2020 2020 2073 656c 662e 646f 5f6f 7074 self.do_opt\n-000103e0: 696f 6e73 286d 6573 7361 6765 290a 0a20 ions(message).. \n-000103f0: 2020 2064 6566 2064 6f5f 6368 616e 6e65 def do_channe\n-00010400: 6c5f 636f 6e74 726f 6c28 7365 6c66 2c20 l_control(self, \n-00010410: 6368 616e 6e65 6c3a 2073 7472 2c20 636f channel: str, co\n-00010420: 6d6d 616e 643a 2073 7472 2c20 6d65 7373 mmand: str, mess\n-00010430: 6167 653a 204a 736f 6e4f 626a 6563 7429 age: JsonObject)\n-00010440: 202d 3e20 4e6f 6e65 3a0a 2020 2020 2020 -> None:. \n-00010450: 2020 2320 416c 7265 6164 7920 636c 6f73 # Already clos\n-00010460: 696e 673f 2020 4967 6e6f 7265 2e0a 2020 ing? Ignore.. \n-00010470: 2020 2020 2020 6966 2073 656c 662e 5f63 if self._c\n-00010480: 6c6f 7365 5f61 7267 7320 6973 206e 6f74 lose_args is not\n-00010490: 204e 6f6e 653a 0a20 2020 2020 2020 2020 None:. \n-000104a0: 2020 2072 6574 7572 6e0a 0a20 2020 2020 return.. \n-000104b0: 2020 2023 2043 6174 6368 2065 7272 6f72 # Catch error\n-000104c0: 7320 616e 6420 7475 726e 2074 6865 6d20 s and turn them \n-000104d0: 696e 746f 2063 6c6f 7365 206d 6573 7361 into close messa\n-000104e0: 6765 730a 2020 2020 2020 2020 7472 793a ges. try:\n-000104f0: 0a20 2020 2020 2020 2020 2020 2074 7279 . try\n-00010500: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n-00010510: 2020 7365 6c66 2e64 6f5f 636f 6e74 726f self.do_contro\n-00010520: 6c28 636f 6d6d 616e 642c 206d 6573 7361 l(command, messa\n-00010530: 6765 290a 2020 2020 2020 2020 2020 2020 ge). \n-00010540: 6578 6365 7074 204a 736f 6e45 7272 6f72 except JsonError\n-00010550: 2061 7320 6578 633a 0a20 2020 2020 2020 as exc:. \n-00010560: 2020 2020 2020 2020 2072 6169 7365 2043 raise C\n-00010570: 6861 6e6e 656c 4572 726f 7228 2770 726f hannelError('pro\n-00010580: 746f 636f 6c2d 6572 726f 7227 2c20 6d65 tocol-error', me\n-00010590: 7373 6167 653d 7374 7228 6578 6329 2920 ssage=str(exc)) \n-000105a0: 6672 6f6d 2065 7863 0a20 2020 2020 2020 from exc. \n-000105b0: 2065 7863 6570 7420 4368 616e 6e65 6c45 except ChannelE\n-000105c0: 7272 6f72 2061 7320 6578 633a 0a20 2020 rror as exc:. \n-000105d0: 2020 2020 2020 2020 2073 656c 662e 636c self.cl\n-000105e0: 6f73 6528 6578 632e 6765 745f 6174 7472 ose(exc.get_attr\n-000105f0: 7328 2929 0a0a 2020 2020 6465 6620 646f s()).. def do\n-00010600: 5f6b 696c 6c28 7365 6c66 2c20 686f 7374 _kill(self, host\n-00010610: 3a20 2773 7472 207c 204e 6f6e 6527 2c20 : 'str | None', \n-00010620: 6772 6f75 703a 2027 7374 7220 7c20 4e6f group: 'str | No\n-00010630: 6e65 272c 205f 6d65 7373 6167 653a 204a ne', _message: J\n-00010640: 736f 6e4f 626a 6563 7429 202d 3e20 4e6f sonObject) -> No\n-00010650: 6e65 3a0a 2020 2020 2020 2020 2320 416c ne:. # Al\n-00010660: 7265 6164 7920 636c 6f73 696e 673f 2020 ready closing? \n-00010670: 4967 6e6f 7265 2e0a 2020 2020 2020 2020 Ignore.. \n-00010680: 6966 2073 656c 662e 5f63 6c6f 7365 5f61 if self._close_a\n-00010690: 7267 7320 6973 206e 6f74 204e 6f6e 653a rgs is not None:\n-000106a0: 0a20 2020 2020 2020 2020 2020 2072 6574 . ret\n-000106b0: 7572 6e0a 0a20 2020 2020 2020 2069 6620 urn.. if \n-000106c0: 686f 7374 2069 7320 6e6f 7420 4e6f 6e65 host is not None\n-000106d0: 3a0a 2020 2020 2020 2020 2020 2020 7265 :. re\n-000106e0: 7475 726e 0a20 2020 2020 2020 2069 6620 turn. if \n-000106f0: 6772 6f75 7020 6973 206e 6f74 204e 6f6e group is not Non\n-00010700: 6520 616e 6420 7365 6c66 2e67 726f 7570 e and self.group\n-00010710: 2021 3d20 6772 6f75 703a 0a20 2020 2020 != group:. \n-00010720: 2020 2020 2020 2072 6574 7572 6e0a 2020 return. \n-00010730: 2020 2020 2020 7365 6c66 2e64 6f5f 636c self.do_cl\n-00010740: 6f73 6528 290a 0a20 2020 2023 2041 7420 ose().. # At \n-00010750: 6c65 6173 7420 7468 6973 206f 6e65 2072 least this one r\n-00010760: 6561 6c6c 7920 6f75 6768 7420 746f 2062 eally ought to b\n-00010770: 6520 696d 706c 656d 656e 7465 642e 2e2e e implemented...\n-00010780: 0a20 2020 2064 6566 2064 6f5f 6f70 656e . def do_open\n-00010790: 2873 656c 662c 206f 7074 696f 6e73 3a20 (self, options: \n-000107a0: 4a73 6f6e 4f62 6a65 6374 2920 2d3e 204e JsonObject) -> N\n-000107b0: 6f6e 653a 0a20 2020 2020 2020 2072 6169 one:. rai\n-000107c0: 7365 204e 6f74 496d 706c 656d 656e 7465 se NotImplemente\n-000107d0: 6445 7272 6f72 0a0a 2020 2020 2320 2e2e dError.. # ..\n-000107e0: 2e20 6275 7420 6d61 6e79 2073 7562 636c . but many subcl\n-000107f0: 6173 7365 7320 6d61 7920 7265 6173 6f6e asses may reason\n-00010800: 6162 6c79 2077 616e 7420 746f 2069 676e ably want to ign\n-00010810: 6f72 6520 736f 6d65 206f 6620 7468 6573 ore some of thes\n-00010820: 652e 0a20 2020 2064 6566 2064 6f5f 7265 e.. def do_re\n-00010830: 6164 7928 7365 6c66 2920 2d3e 204e 6f6e ady(self) -> Non\n-00010840: 653a 0a20 2020 2020 2020 2070 6173 730a e:. pass.\n-00010850: 0a20 2020 2064 6566 2064 6f5f 646f 6e65 . def do_done\n-00010860: 2873 656c 6629 202d 3e20 4e6f 6e65 3a0a (self) -> None:.\n-00010870: 2020 2020 2020 2020 7061 7373 0a0a 2020 pass.. \n-00010880: 2020 6465 6620 646f 5f63 6c6f 7365 2873 def do_close(s\n-00010890: 656c 6629 202d 3e20 4e6f 6e65 3a0a 2020 elf) -> None:. \n-000108a0: 2020 2020 2020 7365 6c66 2e63 6c6f 7365 self.close\n-000108b0: 2829 0a0a 2020 2020 6465 6620 646f 5f6f ().. def do_o\n-000108c0: 7074 696f 6e73 2873 656c 662c 206d 6573 ptions(self, mes\n-000108d0: 7361 6765 3a20 4a73 6f6e 4f62 6a65 6374 sage: JsonObject\n-000108e0: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n-000108f0: 2020 2072 6169 7365 2043 6861 6e6e 656c raise Channel\n-00010900: 4572 726f 7228 276e 6f74 2d73 7570 706f Error('not-suppo\n-00010910: 7274 6564 272c 206d 6573 7361 6765 3d27 rted', message='\n-00010920: 5468 6973 2063 6861 6e6e 656c 2064 6f65 This channel doe\n-00010930: 7320 6e6f 7420 696d 706c 656d 656e 7420 s not implement \n-00010940: 226f 7074 696f 6e73 2227 290a 0a20 2020 \"options\"').. \n-00010950: 2023 2027 7265 6173 6f6e 6162 6c65 2720 # 'reasonable' \n-00010960: 6465 6661 756c 742c 206f 7665 7272 6964 default, overrid\n-00010970: 6465 6e20 696e 206f 7468 6572 2063 6861 den in other cha\n-00010980: 6e6e 656c 7320 666f 7220 7265 6365 6976 nnels for receiv\n-00010990: 652d 7369 6465 2066 6c6f 7720 636f 6e74 e-side flow cont\n-000109a0: 726f 6c0a 2020 2020 6465 6620 646f 5f70 rol. def do_p\n-000109b0: 696e 6728 7365 6c66 2c20 6d65 7373 6167 ing(self, messag\n-000109c0: 653a 204a 736f 6e4f 626a 6563 7429 202d e: JsonObject) -\n-000109d0: 3e20 4e6f 6e65 3a0a 2020 2020 2020 2020 > None:. \n-000109e0: 7365 6c66 2e73 656e 645f 706f 6e67 286d self.send_pong(m\n-000109f0: 6573 7361 6765 290a 0a20 2020 2064 6566 essage).. def\n-00010a00: 2073 656e 645f 6163 6b28 7365 6c66 2c20 send_ack(self, \n-00010a10: 6461 7461 3a20 6279 7465 7329 202d 3e20 data: bytes) -> \n-00010a20: 4e6f 6e65 3a0a 2020 2020 2020 2020 6966 None:. if\n-00010a30: 2073 656c 662e 5f61 636b 5f62 7974 6573 self._ack_bytes\n-00010a40: 3a0a 2020 2020 2020 2020 2020 2020 7365 :. se\n-00010a50: 6c66 2e73 656e 645f 636f 6e74 726f 6c28 lf.send_control(\n-00010a60: 2761 636b 272c 2062 7974 6573 3d6c 656e 'ack', bytes=len\n-00010a70: 2864 6174 6129 290a 0a20 2020 2064 6566 (data)).. def\n-00010a80: 2064 6f5f 6368 616e 6e65 6c5f 6461 7461 do_channel_data\n-00010a90: 2873 656c 662c 2063 6861 6e6e 656c 3a20 (self, channel: \n-00010aa0: 7374 722c 2064 6174 613a 2062 7974 6573 str, data: bytes\n-00010ab0: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n-00010ac0: 2020 2023 2041 6c72 6561 6479 2063 6c6f # Already clo\n-00010ad0: 7369 6e67 3f20 2049 676e 6f72 652e 0a20 sing? Ignore.. \n-00010ae0: 2020 2020 2020 2069 6620 7365 6c66 2e5f if self._\n-00010af0: 636c 6f73 655f 6172 6773 2069 7320 6e6f close_args is no\n-00010b00: 7420 4e6f 6e65 3a0a 2020 2020 2020 2020 t None:. \n-00010b10: 2020 2020 7265 7475 726e 0a0a 2020 2020 return.. \n-00010b20: 2020 2020 2320 4361 7463 6820 6572 726f # Catch erro\n-00010b30: 7273 2061 6e64 2074 7572 6e20 7468 656d rs and turn them\n-00010b40: 2069 6e74 6f20 636c 6f73 6520 6d65 7373 into close mess\n-00010b50: 6167 6573 0a20 2020 2020 2020 2074 7279 ages. try\n-00010b60: 3a0a 2020 2020 2020 2020 2020 2020 6966 :. if\n-00010b70: 206e 6f74 2073 656c 662e 646f 5f64 6174 not self.do_dat\n-00010b80: 6128 6461 7461 293a 0a20 2020 2020 2020 a(data):. \n-00010b90: 2020 2020 2020 2020 2073 656c 662e 7365 self.se\n-00010ba0: 6e64 5f61 636b 2864 6174 6129 0a20 2020 nd_ack(data). \n-00010bb0: 2020 2020 2065 7863 6570 7420 4368 616e except Chan\n-00010bc0: 6e65 6c45 7272 6f72 2061 7320 6578 633a nelError as exc:\n-00010bd0: 0a20 2020 2020 2020 2020 2020 2073 656c . sel\n-00010be0: 662e 636c 6f73 6528 6578 632e 6765 745f f.close(exc.get_\n-00010bf0: 6174 7472 7328 2929 0a0a 2020 2020 6465 attrs()).. de\n-00010c00: 6620 646f 5f64 6174 6128 7365 6c66 2c20 f do_data(self, \n-00010c10: 6461 7461 3a20 6279 7465 7329 202d 3e20 data: bytes) -> \n-00010c20: 2762 6f6f 6c20 7c20 4e6f 6e65 273a 0a20 'bool | None':. \n-00010c30: 2020 2020 2020 2022 2222 4861 6e64 6c65 \"\"\"Handle\n-00010c40: 7320 696e 636f 6d69 6e67 2064 6174 6120 s incoming data \n-00010c50: 746f 2074 6865 2063 6861 6e6e 656c 2e0a to the channel..\n-00010c60: 0a20 2020 2020 2020 2052 6574 7572 6e20 . Return \n-00010c70: 7661 6c75 6520 6973 2054 7275 6520 6966 value is True if\n-00010c80: 2074 6865 2063 6861 6e6e 656c 2074 616b the channel tak\n-00010c90: 6573 2063 6172 6520 6f66 2073 656e 6420 es care of send \n-00010ca0: 6163 6b73 206f 6e20 6974 7320 6f77 6e2c acks on its own,\n-00010cb0: 0a20 2020 2020 2020 2069 6e20 7768 6963 . in whic\n-00010cc0: 6820 6361 7365 2069 7420 7368 6f75 6c64 h case it should\n-00010cd0: 2063 616c 6c20 7365 6c66 2e73 656e 645f call self.send_\n-00010ce0: 6163 6b28 2920 6f6e 2060 6461 7461 6020 ack() on `data` \n-00010cf0: 6174 2073 6f6d 6520 706f 696e 742e 0a20 at some point.. \n-00010d00: 2020 2020 2020 204e 6f6e 6520 6f72 2046 None or F\n-00010d10: 616c 7365 206d 6561 6e73 2074 6861 7420 alse means that \n-00010d20: 7468 6520 6163 6b6e 6f77 6c65 6467 656d the acknowledgem\n-00010d30: 656e 7420 6973 2073 656e 7420 6175 746f ent is sent auto\n-00010d40: 6d61 7469 6361 6c6c 792e 2222 220a 2020 matically.\"\"\". \n-00010d50: 2020 2020 2020 2320 4279 2064 6566 6175 # By defau\n-00010d60: 6c74 2c20 6368 616e 6e65 6c73 2063 616e lt, channels can\n-00010d70: 2774 2072 6563 6569 7665 2064 6174 612e 't receive data.\n-00010d80: 0a20 2020 2020 2020 2064 656c 2064 6174 . del dat\n-00010d90: 610a 2020 2020 2020 2020 7365 6c66 2e63 a. self.c\n-00010da0: 6c6f 7365 2829 0a20 2020 2020 2020 2072 lose(). r\n-00010db0: 6574 7572 6e20 5472 7565 0a0a 2020 2020 eturn True.. \n-00010dc0: 2320 6f75 7470 7574 0a20 2020 2064 6566 # output. def\n-00010dd0: 2072 6561 6479 2873 656c 662c 202a 2a6b ready(self, **k\n-00010de0: 7761 7267 733a 204a 736f 6e56 616c 7565 wargs: JsonValue\n-00010df0: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n-00010e00: 2020 2073 656c 662e 7468 6177 5f65 6e64 self.thaw_end\n-00010e10: 706f 696e 7428 290a 2020 2020 2020 2020 point(). \n-00010e20: 7365 6c66 2e73 656e 645f 636f 6e74 726f self.send_contro\n-00010e30: 6c28 636f 6d6d 616e 643d 2772 6561 6479 l(command='ready\n-00010e40: 272c 202a 2a6b 7761 7267 7329 0a0a 2020 ', **kwargs).. \n-00010e50: 2020 6465 6620 646f 6e65 2873 656c 6629 def done(self)\n-00010e60: 202d 3e20 4e6f 6e65 3a0a 2020 2020 2020 -> None:. \n-00010e70: 2020 7365 6c66 2e73 656e 645f 636f 6e74 self.send_cont\n-00010e80: 726f 6c28 636f 6d6d 616e 643d 2764 6f6e rol(command='don\n-00010e90: 6527 290a 0a20 2020 2023 2074 6173 6b73 e').. # tasks\n-00010ea0: 2061 6e64 2063 6c6f 7365 206d 616e 6167 and close manag\n-00010eb0: 656d 656e 740a 2020 2020 6465 6620 6973 ement. def is\n-00010ec0: 5f63 6c6f 7369 6e67 2873 656c 6629 202d _closing(self) -\n-00010ed0: 3e20 626f 6f6c 3a0a 2020 2020 2020 2020 > bool:. \n-00010ee0: 7265 7475 726e 2073 656c 662e 5f63 6c6f return self._clo\n-00010ef0: 7365 5f61 7267 7320 6973 206e 6f74 204e se_args is not N\n-00010f00: 6f6e 650a 0a20 2020 2064 6566 205f 636c one.. def _cl\n-00010f10: 6f73 655f 6e6f 7728 7365 6c66 2920 2d3e ose_now(self) ->\n-00010f20: 204e 6f6e 653a 0a20 2020 2020 2020 2073 None:. s\n-00010f30: 656c 662e 7368 7574 646f 776e 5f65 6e64 elf.shutdown_end\n-00010f40: 706f 696e 7428 7365 6c66 2e5f 636c 6f73 point(self._clos\n-00010f50: 655f 6172 6773 290a 0a20 2020 2064 6566 e_args).. def\n-00010f60: 205f 7461 736b 5f64 6f6e 6528 7365 6c66 _task_done(self\n-00010f70: 2c20 7461 736b 293a 0a20 2020 2020 2020 , task):. \n-00010f80: 2023 2053 7472 6963 746c 7920 7370 6561 # Strictly spea\n-00010f90: 6b69 6e67 2c20 7765 2073 686f 756c 6420 king, we should \n-00010fa0: 7265 6164 2074 6865 2072 6573 756c 7420 read the result \n-00010fb0: 616e 6420 6368 6563 6b20 666f 7220 6578 and check for ex\n-00010fc0: 6365 7074 696f 6e73 2062 7574 3a0a 2020 ceptions but:. \n-00010fd0: 2020 2020 2020 2320 2020 2d20 6578 6365 # - exce\n-00010fe0: 7074 696f 6e73 2062 7562 626c 696e 6720 ptions bubbling \n-00010ff0: 6f75 7420 6f66 2074 6865 2074 6173 6b20 out of the task \n-00011000: 6172 6520 7072 6f67 7261 6d6d 696e 6720 are programming \n-00011010: 6572 726f 7273 0a20 2020 2020 2020 2023 errors. #\n-00011020: 2020 202d 2074 6865 206f 6e6c 7920 7468 - the only th\n-00011030: 696e 6720 7765 2764 2064 6f20 7769 7468 ing we'd do with\n-00011040: 2069 7420 616e 7977 6179 2c20 6973 2074 it anyway, is t\n-00011050: 6f20 7368 6f77 2069 740a 2020 2020 2020 o show it. \n-00011060: 2020 2320 2020 2d20 5079 7468 6f6e 2061 # - Python a\n-00011070: 6c72 6561 6479 2064 6f65 7320 7468 6174 lready does that\n-00011080: 2077 6974 6820 6974 7320 2254 6173 6b20 with its \"Task \n-00011090: 6578 6365 7074 696f 6e20 7761 7320 6e65 exception was ne\n-000110a0: 7665 7220 7265 7472 6965 7665 6422 206d ver retrieved\" m\n-000110b0: 6573 7361 6765 730a 2020 2020 2020 2020 essages. \n-000110c0: 7365 6c66 2e5f 7461 736b 732e 7265 6d6f self._tasks.remo\n-000110d0: 7665 2874 6173 6b29 0a20 2020 2020 2020 ve(task). \n-000110e0: 2069 6620 7365 6c66 2e5f 636c 6f73 655f if self._close_\n-000110f0: 6172 6773 2069 7320 6e6f 7420 4e6f 6e65 args is not None\n-00011100: 2061 6e64 206e 6f74 2073 656c 662e 5f74 and not self._t\n-00011110: 6173 6b73 3a0a 2020 2020 2020 2020 2020 asks:. \n-00011120: 2020 7365 6c66 2e5f 636c 6f73 655f 6e6f self._close_no\n-00011130: 7728 290a 0a20 2020 2064 6566 2063 7265 w().. def cre\n-00011140: 6174 655f 7461 736b 2873 656c 662c 2063 ate_task(self, c\n-00011150: 6f72 6f75 7469 6e65 2c20 6e61 6d65 3d4e oroutine, name=N\n-00011160: 6f6e 6529 3a0a 2020 2020 2020 2020 2222 one):. \"\"\n-00011170: 2243 7265 6174 6520 6120 7461 736b 2061 \"Create a task a\n-00011180: 7373 6f63 6961 7465 6420 7769 7468 2074 ssociated with t\n-00011190: 6865 2063 6861 6e6e 656c 2e0a 0a20 2020 he channel... \n-000111a0: 2020 2020 2041 6c6c 2074 6173 6b73 206d All tasks m\n-000111b0: 7573 7420 6578 6974 2062 6566 6f72 6520 ust exit before \n-000111c0: 7468 6520 6368 616e 6e65 6c20 6361 6e20 the channel can \n-000111d0: 636c 6f73 652e 2020 596f 7520 6d61 7920 close. You may \n-000111e0: 6e6f 7420 6372 6561 7465 0a20 2020 2020 not create. \n-000111f0: 2020 206e 6577 2074 6173 6b73 2061 6674 new tasks aft\n-00011200: 6572 2063 616c 6c69 6e67 202e 636c 6f73 er calling .clos\n-00011210: 6528 292e 0a20 2020 2020 2020 2022 2222 e().. \"\"\"\n-00011220: 0a20 2020 2020 2020 2061 7373 6572 7420 . assert \n-00011230: 7365 6c66 2e5f 636c 6f73 655f 6172 6773 self._close_args\n-00011240: 2069 7320 4e6f 6e65 0a20 2020 2020 2020 is None. \n-00011250: 2074 6173 6b20 3d20 6173 796e 6369 6f2e task = asyncio.\n-00011260: 6372 6561 7465 5f74 6173 6b28 636f 726f create_task(coro\n-00011270: 7574 696e 6529 0a20 2020 2020 2020 2073 utine). s\n-00011280: 656c 662e 5f74 6173 6b73 2e61 6464 2874 elf._tasks.add(t\n-00011290: 6173 6b29 0a20 2020 2020 2020 2074 6173 ask). tas\n-000112a0: 6b2e 6164 645f 646f 6e65 5f63 616c 6c62 k.add_done_callb\n-000112b0: 6163 6b28 7365 6c66 2e5f 7461 736b 5f64 ack(self._task_d\n-000112c0: 6f6e 6529 0a20 2020 2020 2020 2072 6574 one). ret\n-000112d0: 7572 6e20 7461 736b 0a0a 2020 2020 6465 urn task.. de\n-000112e0: 6620 636c 6f73 6528 7365 6c66 2c20 636c f close(self, cl\n-000112f0: 6f73 655f 6172 6773 3a20 274a 736f 6e4f ose_args: 'JsonO\n-00011300: 626a 6563 7420 7c20 4e6f 6e65 2720 3d20 bject | None' = \n-00011310: 4e6f 6e65 2920 2d3e 204e 6f6e 653a 0a20 None) -> None:. \n-00011320: 2020 2020 2020 2022 2222 5265 7175 6573 \"\"\"Reques\n-00011330: 7473 2074 6865 2063 6861 6e6e 656c 2074 ts the channel t\n-00011340: 6f20 6265 2063 6c6f 7365 642e 0a0a 2020 o be closed... \n-00011350: 2020 2020 2020 4166 7465 7220 796f 7520 After you \n-00011360: 6361 6c6c 2074 6869 7320 6d65 7468 6f64 call this method\n-00011370: 2c20 796f 7520 776f 6e27 7420 6765 7420 , you won't get \n-00011380: 616e 796d 6f72 6520 602e 646f 5f2a 2829 anymore `.do_*()\n-00011390: 6020 6361 6c6c 732e 0a0a 2020 2020 2020 ` calls... \n-000113a0: 2020 5468 6973 2077 696c 6c20 7761 6974 This will wait\n-000113b0: 2066 6f72 2061 6e79 2072 756e 6e69 6e67 for any running\n-000113c0: 2074 6173 6b73 2074 6f20 636f 6d70 6c65 tasks to comple\n-000113d0: 7465 2062 6566 6f72 6520 7365 6e64 696e te before sendin\n-000113e0: 6720 7468 650a 2020 2020 2020 2020 636c g the. cl\n-000113f0: 6f73 6520 6d65 7373 6167 652e 0a20 2020 ose message.. \n-00011400: 2020 2020 2022 2222 0a20 2020 2020 2020 \"\"\". \n-00011410: 2069 6620 7365 6c66 2e5f 636c 6f73 655f if self._close_\n-00011420: 6172 6773 2069 7320 6e6f 7420 4e6f 6e65 args is not None\n-00011430: 3a0a 2020 2020 2020 2020 2020 2020 2320 :. # \n-00011440: 636c 6f73 6520 616c 7265 6164 7920 7265 close already re\n-00011450: 7175 6573 7465 640a 2020 2020 2020 2020 quested. \n-00011460: 2020 2020 7265 7475 726e 0a20 2020 2020 return. \n-00011470: 2020 2073 656c 662e 5f63 6c6f 7365 5f61 self._close_a\n-00011480: 7267 7320 3d20 636c 6f73 655f 6172 6773 rgs = close_args\n-00011490: 206f 7220 7b7d 0a20 2020 2020 2020 2069 or {}. i\n-000114a0: 6620 6e6f 7420 7365 6c66 2e5f 7461 736b f not self._task\n-000114b0: 733a 0a20 2020 2020 2020 2020 2020 2073 s:. s\n-000114c0: 656c 662e 5f63 6c6f 7365 5f6e 6f77 2829 elf._close_now()\n-000114d0: 0a0a 2020 2020 6465 6620 7365 6e64 5f64 .. def send_d\n-000114e0: 6174 6128 7365 6c66 2c20 6461 7461 3a20 ata(self, data: \n-000114f0: 6279 7465 7329 202d 3e20 626f 6f6c 3a0a bytes) -> bool:.\n-00011500: 2020 2020 2020 2020 2222 2253 656e 6420 \"\"\"Send \n-00011510: 6461 7461 2061 6e64 2068 616e 646c 6520 data and handle \n-00011520: 626f 6f6b 2d6b 6565 7069 6e67 2066 6f72 book-keeping for\n-00011530: 2066 6c6f 7720 636f 6e74 726f 6c2e 0a0a flow control...\n-00011540: 2020 2020 2020 2020 5468 6520 666c 6f77 The flow\n-00011550: 2063 6f6e 7472 6f6c 2069 7320 2261 6476 control is \"adv\n-00011560: 6973 6f72 7922 2e20 2054 6865 2064 6174 isory\". The dat\n-00011570: 6120 6973 2073 656e 7420 696d 6d65 6469 a is sent immedi\n-00011580: 6174 656c 792c 2065 7665 6e20 6966 0a20 ately, even if. \n-00011590: 2020 2020 2020 2069 7427 7320 6c61 7267 it's larg\n-000115a0: 6572 2074 6861 6e20 7468 6520 7769 6e64 er than the wind\n-000115b0: 6f77 2e20 2049 6e20 6765 6e65 7261 6c20 ow. In general \n-000115c0: 796f 7520 7368 6f75 6c64 2074 7279 2074 you should try t\n-000115d0: 6f20 7365 6e64 2070 6163 6b65 7473 0a20 o send packets. \n-000115e0: 2020 2020 2020 2077 6869 6368 2061 7265 which are\n-000115f0: 2061 7070 726f 7869 6d61 7465 6c79 2043 approximately C\n-00011600: 6861 6e6e 656c 2e42 4c4f 434b 5f53 495a hannel.BLOCK_SIZ\n-00011610: 4520 696e 2073 697a 652e 0a0a 2020 2020 E in size... \n-00011620: 2020 2020 5265 7475 726e 7320 5472 7565 Returns True\n-00011630: 2069 6620 7468 6572 6520 6973 2073 7469 if there is sti\n-00011640: 6c6c 2072 6f6f 6d20 696e 2074 6865 2077 ll room in the w\n-00011650: 696e 646f 772c 206f 7220 4661 6c73 6520 indow, or False \n-00011660: 6966 2079 6f75 0a20 2020 2020 2020 2073 if you. s\n-00011670: 686f 756c 6420 7374 6f70 2077 7269 7469 hould stop writi\n-00011680: 6e67 2066 6f72 206e 6f77 2e20 2049 6e20 ng for now. In \n-00011690: 7468 6174 2063 6173 652c 2060 2e64 6f5f that case, `.do_\n-000116a0: 7265 7375 6d65 5f73 656e 6428 2960 2077 resume_send()` w\n-000116b0: 696c 6c20 6265 0a20 2020 2020 2020 2063 ill be. c\n-000116c0: 616c 6c65 6420 6c61 7465 7220 7768 656e alled later when\n-000116d0: 2074 6865 7265 2069 7320 6d6f 7265 2072 there is more r\n-000116e0: 6f6f 6d2e 0a20 2020 2020 2020 2022 2222 oom.. \"\"\"\n-000116f0: 0a20 2020 2020 2020 2073 656c 662e 7365 . self.se\n-00011700: 6e64 5f63 6861 6e6e 656c 5f64 6174 6128 nd_channel_data(\n-00011710: 7365 6c66 2e63 6861 6e6e 656c 2c20 6461 self.channel, da\n-00011720: 7461 290a 0a20 2020 2020 2020 2069 6620 ta).. if \n-00011730: 7365 6c66 2e5f 7365 6e64 5f70 696e 6773 self._send_pings\n-00011740: 3a0a 2020 2020 2020 2020 2020 2020 6f75 :. ou\n-00011750: 745f 7365 7175 656e 6365 203d 2073 656c t_sequence = sel\n-00011760: 662e 5f6f 7574 5f73 6571 7565 6e63 6520 f._out_sequence \n-00011770: 2b20 6c65 6e28 6461 7461 290a 2020 2020 + len(data). \n-00011780: 2020 2020 2020 2020 6966 2073 656c 662e if self.\n-00011790: 5f6f 7574 5f73 6571 7565 6e63 6520 2f2f _out_sequence //\n-000117a0: 2043 6861 6e6e 656c 2e42 4c4f 434b 5f53 Channel.BLOCK_S\n-000117b0: 495a 4520 213d 206f 7574 5f73 6571 7565 IZE != out_seque\n-000117c0: 6e63 6520 2f2f 2043 6861 6e6e 656c 2e42 nce // Channel.B\n-000117d0: 4c4f 434b 5f53 495a 453a 0a20 2020 2020 LOCK_SIZE:. \n-000117e0: 2020 2020 2020 2020 2020 2073 656c 662e self.\n-000117f0: 7365 6e64 5f63 6f6e 7472 6f6c 2863 6f6d send_control(com\n-00011800: 6d61 6e64 3d27 7069 6e67 272c 2073 6571 mand='ping', seq\n-00011810: 7565 6e63 653d 6f75 745f 7365 7175 656e uence=out_sequen\n-00011820: 6365 290a 2020 2020 2020 2020 2020 2020 ce). \n-00011830: 7365 6c66 2e5f 6f75 745f 7365 7175 656e self._out_sequen\n-00011840: 6365 203d 206f 7574 5f73 6571 7565 6e63 ce = out_sequenc\n-00011850: 650a 0a20 2020 2020 2020 2072 6574 7572 e.. retur\n-00011860: 6e20 7365 6c66 2e5f 6f75 745f 7365 7175 n self._out_sequ\n-00011870: 656e 6365 203c 2073 656c 662e 5f6f 7574 ence < self._out\n-00011880: 5f77 696e 646f 770a 0a20 2020 2064 6566 _window.. def\n-00011890: 2064 6f5f 706f 6e67 2873 656c 662c 206d do_pong(self, m\n-000118a0: 6573 7361 6765 293a 0a20 2020 2020 2020 essage):. \n-000118b0: 2069 6620 6e6f 7420 7365 6c66 2e5f 7365 if not self._se\n-000118c0: 6e64 5f70 696e 6773 3a20 2023 2068 7568 nd_pings: # huh\n-000118d0: 3f0a 2020 2020 2020 2020 2020 2020 6c6f ?. lo\n-000118e0: 6767 6572 2e77 6172 6e69 6e67 2822 476f gger.warning(\"Go\n-000118f0: 7420 7769 6c64 2070 6f6e 6720 6f6e 2063 t wild pong on c\n-00011900: 6861 6e6e 656c 2025 7322 2c20 7365 6c66 hannel %s\", self\n-00011910: 2e63 6861 6e6e 656c 290a 2020 2020 2020 .channel). \n-00011920: 2020 2020 2020 7265 7475 726e 0a0a 2020 return.. \n-00011930: 2020 2020 2020 7365 6c66 2e5f 6f75 745f self._out_\n-00011940: 7769 6e64 6f77 203d 206d 6573 7361 6765 window = message\n-00011950: 5b27 7365 7175 656e 6365 275d 202b 2043 ['sequence'] + C\n-00011960: 6861 6e6e 656c 2e53 454e 445f 5749 4e44 hannel.SEND_WIND\n-00011970: 4f57 0a20 2020 2020 2020 2069 6620 7365 OW. if se\n-00011980: 6c66 2e5f 6f75 745f 7365 7175 656e 6365 lf._out_sequence\n-00011990: 203c 2073 656c 662e 5f6f 7574 5f77 696e < self._out_win\n-000119a0: 646f 773a 0a20 2020 2020 2020 2020 2020 dow:. \n-000119b0: 2073 656c 662e 646f 5f72 6573 756d 655f self.do_resume_\n-000119c0: 7365 6e64 2829 0a0a 2020 2020 6465 6620 send().. def \n-000119d0: 646f 5f72 6573 756d 655f 7365 6e64 2873 do_resume_send(s\n-000119e0: 656c 6629 202d 3e20 4e6f 6e65 3a0a 2020 elf) -> None:. \n-000119f0: 2020 2020 2020 2222 2243 616c 6c65 6420 \"\"\"Called \n-00011a00: 746f 2069 6e64 6963 6174 6520 7468 6174 to indicate that\n-00011a10: 2074 6865 2063 6861 6e6e 656c 206d 6179 the channel may\n-00011a20: 2073 7461 7274 2073 656e 6469 6e67 2061 start sending a\n-00011a30: 6761 696e 2e22 2222 0a20 2020 2020 2020 gain.\"\"\". \n-00011a40: 2023 2063 6861 6e67 6520 746f 2060 7261 # change to `ra\n-00011a50: 6973 6520 4e6f 7449 6d70 6c65 6d65 6e74 ise NotImplement\n-00011a60: 6564 4572 726f 7260 2061 6674 6572 2065 edError` after e\n-00011a70: 7665 7279 6f6e 6520 696d 706c 656d 656e veryone implemen\n-00011a80: 7473 2069 740a 0a20 2020 206a 736f 6e5f ts it.. json_\n-00011a90: 656e 636f 6465 723a 2043 6c61 7373 5661 encoder: ClassVa\n-00011aa0: 725b 6a73 6f6e 2e4a 534f 4e45 6e63 6f64 r[json.JSONEncod\n-00011ab0: 6572 5d20 3d20 6a73 6f6e 2e4a 534f 4e45 er] = json.JSONE\n-00011ac0: 6e63 6f64 6572 2869 6e64 656e 743d 3229 ncoder(indent=2)\n-00011ad0: 0a0a 2020 2020 6465 6620 7365 6e64 5f6a .. def send_j\n-00011ae0: 736f 6e28 7365 6c66 2c20 5f6d 7367 3a20 son(self, _msg: \n-00011af0: 274a 736f 6e4f 626a 6563 7420 7c20 4e6f 'JsonObject | No\n-00011b00: 6e65 2720 3d20 4e6f 6e65 2c20 2a2a 6b77 ne' = None, **kw\n-00011b10: 6172 6773 3a20 4a73 6f6e 5661 6c75 6529 args: JsonValue)\n-00011b20: 202d 3e20 626f 6f6c 3a0a 2020 2020 2020 -> bool:. \n-00011b30: 2020 7072 6574 7479 203d 2073 656c 662e pretty = self.\n-00011b40: 6a73 6f6e 5f65 6e63 6f64 6572 2e65 6e63 json_encoder.enc\n-00011b50: 6f64 6528 6372 6561 7465 5f6f 626a 6563 ode(create_objec\n-00011b60: 7428 5f6d 7367 2c20 6b77 6172 6773 2929 t(_msg, kwargs))\n-00011b70: 202b 2027 5c6e 270a 2020 2020 2020 2020 + '\\n'. \n-00011b80: 7265 7475 726e 2073 656c 662e 7365 6e64 return self.send\n-00011b90: 5f64 6174 6128 7072 6574 7479 2e65 6e63 _data(pretty.enc\n-00011ba0: 6f64 6528 2929 0a0a 2020 2020 6465 6620 ode()).. def \n-00011bb0: 7365 6e64 5f63 6f6e 7472 6f6c 2873 656c send_control(sel\n-00011bc0: 662c 2063 6f6d 6d61 6e64 3a20 7374 722c f, command: str,\n-00011bd0: 202a 2a6b 7761 7267 733a 204a 736f 6e56 **kwargs: JsonV\n-00011be0: 616c 7565 2920 2d3e 204e 6f6e 653a 0a20 alue) -> None:. \n-00011bf0: 2020 2020 2020 2073 656c 662e 7365 6e64 self.send\n-00011c00: 5f63 6861 6e6e 656c 5f63 6f6e 7472 6f6c _channel_control\n-00011c10: 2873 656c 662e 6368 616e 6e65 6c2c 2063 (self.channel, c\n-00011c20: 6f6d 6d61 6e64 2c20 4e6f 6e65 2c20 2a2a ommand, None, **\n-00011c30: 6b77 6172 6773 290a 0a20 2020 2064 6566 kwargs).. def\n-00011c40: 2073 656e 645f 706f 6e67 2873 656c 662c send_pong(self,\n-00011c50: 206d 6573 7361 6765 3a20 4a73 6f6e 4f62 message: JsonOb\n-00011c60: 6a65 6374 2920 2d3e 204e 6f6e 653a 0a20 ject) -> None:. \n-00011c70: 2020 2020 2020 2073 656c 662e 7365 6e64 self.send\n-00011c80: 5f63 6861 6e6e 656c 5f63 6f6e 7472 6f6c _channel_control\n-00011c90: 2873 656c 662e 6368 616e 6e65 6c2c 2027 (self.channel, '\n-00011ca0: 706f 6e67 272c 206d 6573 7361 6765 290a pong', message).\n-00011cb0: 0a0a 636c 6173 7320 5072 6f74 6f63 6f6c ..class Protocol\n-00011cc0: 4368 616e 6e65 6c28 4368 616e 6e65 6c2c Channel(Channel,\n-00011cd0: 2061 7379 6e63 696f 2e50 726f 746f 636f asyncio.Protoco\n-00011ce0: 6c29 3a0a 2020 2020 2222 2241 2063 6861 l):. \"\"\"A cha\n-00011cf0: 6e6e 656c 2073 7562 636c 6173 7320 7468 nnel subclass th\n-00011d00: 6174 2069 6d70 6c65 6d65 6e74 7320 7468 at implements th\n-00011d10: 6520 6173 796e 6369 6f20 5072 6f74 6f63 e asyncio Protoc\n-00011d20: 6f6c 2069 6e74 6572 6661 6365 2e0a 0a20 ol interface... \n-00011d30: 2020 2049 6e20 6566 6665 6374 2c20 6461 In effect, da\n-00011d40: 7461 2073 656e 7420 746f 2074 6869 7320 ta sent to this \n-00011d50: 6368 616e 6e65 6c20 7769 6c6c 2062 6520 channel will be \n-00011d60: 7772 6974 7465 6e20 746f 2074 6865 2063 written to the c\n-00011d70: 6f6e 6e65 6374 6564 0a20 2020 2074 7261 onnected. tra\n-00011d80: 6e73 706f 7274 2c20 616e 6420 7669 6365 nsport, and vice\n-00011d90: 2d76 6572 7361 2e20 2046 6c6f 7720 636f -versa. Flow co\n-00011da0: 6e74 726f 6c20 6973 2073 7570 706f 7274 ntrol is support\n-00011db0: 6564 2e0a 0a20 2020 2054 6865 2064 6566 ed... The def\n-00011dc0: 6175 6c74 2069 6d70 6c65 6d65 6e74 6174 ault implementat\n-00011dd0: 696f 6e20 6f66 2074 6865 202e 646f 5f6f ion of the .do_o\n-00011de0: 7065 6e28 2920 6d65 7468 6f64 2063 616c pen() method cal\n-00011df0: 6c73 2074 6865 0a20 2020 202e 6372 6561 ls the. .crea\n-00011e00: 7465 5f74 7261 6e73 706f 7274 2829 2061 te_transport() a\n-00011e10: 6273 7472 6163 7420 6d65 7468 6f64 2e20 bstract method. \n-00011e20: 2054 6869 7320 6d65 7468 6f64 2073 686f This method sho\n-00011e30: 756c 6420 7265 7475 726e 2061 2074 7261 uld return a tra\n-00011e40: 6e73 706f 7274 0a20 2020 2077 6869 6368 nsport. which\n-00011e50: 2077 696c 6c20 6265 2075 7365 6420 666f will be used fo\n-00011e60: 7220 636f 6d6d 756e 6963 6174 696f 6e20 r communication \n-00011e70: 6f6e 2074 6865 2063 6861 6e6e 656c 2e0a on the channel..\n-00011e80: 0a20 2020 204f 7468 6572 7769 7365 2c20 . Otherwise, \n-00011e90: 6966 2074 6865 2073 7562 636c 6173 7320 if the subclass \n-00011ea0: 696d 706c 656d 656e 7473 202e 646f 5f6f implements .do_o\n-00011eb0: 7065 6e28 2920 6974 7365 6c66 2c20 6974 pen() itself, it\n-00011ec0: 2069 7320 7265 7370 6f6e 7369 626c 650a is responsible.\n-00011ed0: 2020 2020 666f 7220 7365 7474 696e 6720 for setting \n-00011ee0: 7570 2074 6865 2063 6f6e 6e65 6374 696f up the connectio\n-00011ef0: 6e20 616e 6420 656e 7375 7269 6e67 2074 n and ensuring t\n-00011f00: 6861 7420 2e63 6f6e 6e65 6374 696f 6e5f hat .connection_\n-00011f10: 6d61 6465 2829 2069 7320 6361 6c6c 6564 made() is called\n-00011f20: 2e0a 2020 2020 2222 220a 2020 2020 5f74 .. \"\"\". _t\n-00011f30: 7261 6e73 706f 7274 3a20 4f70 7469 6f6e ransport: Option\n-00011f40: 616c 5b61 7379 6e63 696f 2e54 7261 6e73 al[asyncio.Trans\n-00011f50: 706f 7274 5d0a 2020 2020 5f6c 6f6f 703a port]. _loop:\n-00011f60: 204f 7074 696f 6e61 6c5b 6173 796e 6369 Optional[asynci\n-00011f70: 6f2e 4162 7374 7261 6374 4576 656e 744c o.AbstractEventL\n-00011f80: 6f6f 705d 0a20 2020 205f 7365 6e64 5f70 oop]. _send_p\n-00011f90: 6f6e 6773 3a20 626f 6f6c 203d 2054 7275 ongs: bool = Tru\n-00011fa0: 650a 2020 2020 5f6c 6173 745f 7069 6e67 e. _last_ping\n-00011fb0: 3a20 4f70 7469 6f6e 616c 5b4a 736f 6e4f : Optional[JsonO\n-00011fc0: 626a 6563 745d 203d 204e 6f6e 650a 2020 bject] = None. \n-00011fd0: 2020 5f63 7265 6174 655f 7472 616e 7370 _create_transp\n-00011fe0: 6f72 745f 7461 736b 203d 204e 6f6e 650a ort_task = None.\n-00011ff0: 0a20 2020 2023 2072 6561 642d 7369 6465 . # read-side\n-00012000: 2045 4f46 2068 616e 646c 696e 670a 2020 EOF handling. \n-00012010: 2020 5f63 6c6f 7365 5f6f 6e5f 656f 663a _close_on_eof:\n-00012020: 2062 6f6f 6c20 3d20 4661 6c73 650a 2020 bool = False. \n-00012030: 2020 5f65 6f66 3a20 626f 6f6c 203d 2046 _eof: bool = F\n-00012040: 616c 7365 0a0a 2020 2020 6173 796e 6320 alse.. async \n-00012050: 6465 6620 6372 6561 7465 5f74 7261 6e73 def create_trans\n-00012060: 706f 7274 2873 656c 662c 206c 6f6f 703a port(self, loop:\n-00012070: 2061 7379 6e63 696f 2e41 6273 7472 6163 asyncio.Abstrac\n-00012080: 7445 7665 6e74 4c6f 6f70 2c20 6f70 7469 tEventLoop, opti\n-00012090: 6f6e 733a 204a 736f 6e4f 626a 6563 7429 ons: JsonObject)\n-000120a0: 202d 3e20 6173 796e 6369 6f2e 5472 616e -> asyncio.Tran\n-000120b0: 7370 6f72 743a 0a20 2020 2020 2020 2022 sport:. \"\n-000120c0: 2222 4372 6561 7465 7320 7468 6520 7472 \"\"Creates the tr\n-000120d0: 616e 7370 6f72 7420 666f 7220 7468 6973 ansport for this\n-000120e0: 2063 6861 6e6e 656c 2c20 6163 636f 7264 channel, accord\n-000120f0: 696e 6720 746f 206f 7074 696f 6e73 2e0a ing to options..\n-00012100: 0a20 2020 2020 2020 2054 6865 2065 7665 . The eve\n-00012110: 6e74 206c 6f6f 7020 666f 7220 7468 6520 nt loop for the \n-00012120: 7472 616e 7370 6f72 7420 6973 2070 6173 transport is pas\n-00012130: 7365 6420 746f 2074 6865 2066 756e 6374 sed to the funct\n-00012140: 696f 6e2e 2020 5468 650a 2020 2020 2020 ion. The. \n-00012150: 2020 7072 6f74 6f63 6f6c 2066 6f72 2074 protocol for t\n-00012160: 6865 2074 7261 6e73 706f 7274 2069 7320 he transport is \n-00012170: 7468 6520 6368 616e 6e65 6c20 6f62 6a65 the channel obje\n-00012180: 6374 2c20 6974 7365 6c66 2028 7365 6c66 ct, itself (self\n-00012190: 292e 0a0a 2020 2020 2020 2020 5468 6973 )... This\n-000121a0: 206e 6565 6473 2074 6f20 6265 2069 6d70 needs to be imp\n-000121b0: 6c65 6d65 6e74 6564 2062 7920 7468 6520 lemented by the \n-000121c0: 7375 6263 6c61 7373 2e0a 2020 2020 2020 subclass.. \n-000121d0: 2020 2222 220a 2020 2020 2020 2020 7261 \"\"\". ra\n-000121e0: 6973 6520 4e6f 7449 6d70 6c65 6d65 6e74 ise NotImplement\n-000121f0: 6564 4572 726f 720a 0a20 2020 2064 6566 edError.. def\n-00012200: 2064 6f5f 6f70 656e 2873 656c 662c 206f do_open(self, o\n-00012210: 7074 696f 6e73 3a20 4a73 6f6e 4f62 6a65 ptions: JsonObje\n-00012220: 6374 2920 2d3e 204e 6f6e 653a 0a20 2020 ct) -> None:. \n-00012230: 2020 2020 206c 6f6f 7020 3d20 6173 796e loop = asyn\n-00012240: 6369 6f2e 6765 745f 7275 6e6e 696e 675f cio.get_running_\n-00012250: 6c6f 6f70 2829 0a20 2020 2020 2020 2073 loop(). s\n-00012260: 656c 662e 5f63 7265 6174 655f 7472 616e elf._create_tran\n-00012270: 7370 6f72 745f 7461 736b 203d 2061 7379 sport_task = asy\n-00012280: 6e63 696f 2e63 7265 6174 655f 7461 736b ncio.create_task\n-00012290: 2873 656c 662e 6372 6561 7465 5f74 7261 (self.create_tra\n-000122a0: 6e73 706f 7274 286c 6f6f 702c 206f 7074 nsport(loop, opt\n-000122b0: 696f 6e73 2929 0a20 2020 2020 2020 2073 ions)). s\n-000122c0: 656c 662e 5f63 7265 6174 655f 7472 616e elf._create_tran\n-000122d0: 7370 6f72 745f 7461 736b 2e61 6464 5f64 sport_task.add_d\n-000122e0: 6f6e 655f 6361 6c6c 6261 636b 2873 656c one_callback(sel\n-000122f0: 662e 6372 6561 7465 5f74 7261 6e73 706f f.create_transpo\n-00012300: 7274 5f64 6f6e 6529 0a0a 2020 2020 6465 rt_done).. de\n-00012310: 6620 6372 6561 7465 5f74 7261 6e73 706f f create_transpo\n-00012320: 7274 5f64 6f6e 6528 7365 6c66 2c20 7461 rt_done(self, ta\n-00012330: 736b 3a20 2761 7379 6e63 696f 2e54 6173 sk: 'asyncio.Tas\n-00012340: 6b5b 6173 796e 6369 6f2e 5472 616e 7370 k[asyncio.Transp\n-00012350: 6f72 745d 2729 202d 3e20 4e6f 6e65 3a0a ort]') -> None:.\n-00012360: 2020 2020 2020 2020 6173 7365 7274 2074 assert t\n-00012370: 6173 6b20 6973 2073 656c 662e 5f63 7265 ask is self._cre\n-00012380: 6174 655f 7472 616e 7370 6f72 745f 7461 ate_transport_ta\n-00012390: 736b 0a20 2020 2020 2020 2073 656c 662e sk. self.\n-000123a0: 5f63 7265 6174 655f 7472 616e 7370 6f72 _create_transpor\n-000123b0: 745f 7461 736b 203d 204e 6f6e 650a 2020 t_task = None. \n-000123c0: 2020 2020 2020 7472 793a 0a20 2020 2020 try:. \n-000123d0: 2020 2020 2020 2074 7261 6e73 706f 7274 transport\n-000123e0: 203d 2074 6173 6b2e 7265 7375 6c74 2829 = task.result()\n-000123f0: 0a20 2020 2020 2020 2065 7863 6570 7420 . except \n-00012400: 4368 616e 6e65 6c45 7272 6f72 2061 7320 ChannelError as \n-00012410: 6578 633a 0a20 2020 2020 2020 2020 2020 exc:. \n-00012420: 2073 656c 662e 636c 6f73 6528 6578 632e self.close(exc.\n-00012430: 6765 745f 6174 7472 7328 2929 0a20 2020 get_attrs()). \n-00012440: 2020 2020 2020 2020 2072 6574 7572 6e0a return.\n-00012450: 0a20 2020 2020 2020 2073 656c 662e 636f . self.co\n-00012460: 6e6e 6563 7469 6f6e 5f6d 6164 6528 7472 nnection_made(tr\n-00012470: 616e 7370 6f72 7429 0a20 2020 2020 2020 ansport). \n-00012480: 2073 656c 662e 7265 6164 7928 290a 0a20 self.ready().. \n-00012490: 2020 2064 6566 2063 6f6e 6e65 6374 696f def connectio\n-000124a0: 6e5f 6d61 6465 2873 656c 662c 2074 7261 n_made(self, tra\n-000124b0: 6e73 706f 7274 3a20 6173 796e 6369 6f2e nsport: asyncio.\n-000124c0: 4261 7365 5472 616e 7370 6f72 7429 202d BaseTransport) -\n-000124d0: 3e20 4e6f 6e65 3a0a 2020 2020 2020 2020 > None:. \n-000124e0: 6173 7365 7274 2069 7369 6e73 7461 6e63 assert isinstanc\n-000124f0: 6528 7472 616e 7370 6f72 742c 2061 7379 e(transport, asy\n-00012500: 6e63 696f 2e54 7261 6e73 706f 7274 290a ncio.Transport).\n-00012510: 2020 2020 2020 2020 7365 6c66 2e5f 7472 self._tr\n-00012520: 616e 7370 6f72 7420 3d20 7472 616e 7370 ansport = transp\n-00012530: 6f72 740a 0a20 2020 2064 6566 205f 6765 ort.. def _ge\n-00012540: 745f 636c 6f73 655f 6172 6773 2873 656c t_close_args(sel\n-00012550: 6629 202d 3e20 4a73 6f6e 4f62 6a65 6374 f) -> JsonObject\n-00012560: 3a0a 2020 2020 2020 2020 7265 7475 726e :. return\n-00012570: 207b 7d0a 0a20 2020 2064 6566 2063 6f6e {}.. def con\n-00012580: 6e65 6374 696f 6e5f 6c6f 7374 2873 656c nection_lost(sel\n-00012590: 662c 2065 7863 3a20 4f70 7469 6f6e 616c f, exc: Optional\n-000125a0: 5b45 7863 6570 7469 6f6e 5d29 202d 3e20 [Exception]) -> \n-000125b0: 4e6f 6e65 3a0a 2020 2020 2020 2020 7365 None:. se\n-000125c0: 6c66 2e63 6c6f 7365 2873 656c 662e 5f67 lf.close(self._g\n-000125d0: 6574 5f63 6c6f 7365 5f61 7267 7328 2929 et_close_args())\n-000125e0: 0a0a 2020 2020 6465 6620 646f 5f64 6174 .. def do_dat\n-000125f0: 6128 7365 6c66 2c20 6461 7461 3a20 6279 a(self, data: by\n-00012600: 7465 7329 202d 3e20 4e6f 6e65 3a0a 2020 tes) -> None:. \n-00012610: 2020 2020 2020 6173 7365 7274 2073 656c assert sel\n-00012620: 662e 5f74 7261 6e73 706f 7274 2069 7320 f._transport is \n-00012630: 6e6f 7420 4e6f 6e65 0a20 2020 2020 2020 not None. \n-00012640: 2073 656c 662e 5f74 7261 6e73 706f 7274 self._transport\n-00012650: 2e77 7269 7465 2864 6174 6129 0a0a 2020 .write(data).. \n-00012660: 2020 6465 6620 646f 5f64 6f6e 6528 7365 def do_done(se\n-00012670: 6c66 2920 2d3e 204e 6f6e 653a 0a20 2020 lf) -> None:. \n-00012680: 2020 2020 2061 7373 6572 7420 7365 6c66 assert self\n-00012690: 2e5f 7472 616e 7370 6f72 7420 6973 206e ._transport is n\n-000126a0: 6f74 204e 6f6e 650a 2020 2020 2020 2020 ot None. \n-000126b0: 6966 2073 656c 662e 5f74 7261 6e73 706f if self._transpo\n-000126c0: 7274 2e63 616e 5f77 7269 7465 5f65 6f66 rt.can_write_eof\n-000126d0: 2829 3a0a 2020 2020 2020 2020 2020 2020 ():. \n-000126e0: 7365 6c66 2e5f 7472 616e 7370 6f72 742e self._transport.\n-000126f0: 7772 6974 655f 656f 6628 290a 0a20 2020 write_eof().. \n-00012700: 2064 6566 2064 6f5f 636c 6f73 6528 7365 def do_close(se\n-00012710: 6c66 2920 2d3e 204e 6f6e 653a 0a20 2020 lf) -> None:. \n-00012720: 2020 2020 2069 6620 7365 6c66 2e5f 7472 if self._tr\n-00012730: 616e 7370 6f72 7420 6973 206e 6f74 204e ansport is not N\n-00012740: 6f6e 653a 0a20 2020 2020 2020 2020 2020 one:. \n-00012750: 2073 656c 662e 5f74 7261 6e73 706f 7274 self._transport\n-00012760: 2e63 6c6f 7365 2829 0a0a 2020 2020 6465 .close().. de\n-00012770: 6620 6461 7461 5f72 6563 6569 7665 6428 f data_received(\n-00012780: 7365 6c66 2c20 6461 7461 3a20 6279 7465 self, data: byte\n-00012790: 7329 202d 3e20 4e6f 6e65 3a0a 2020 2020 s) -> None:. \n-000127a0: 2020 2020 6173 7365 7274 2073 656c 662e assert self.\n-000127b0: 5f74 7261 6e73 706f 7274 2069 7320 6e6f _transport is no\n-000127c0: 7420 4e6f 6e65 0a20 2020 2020 2020 2069 t None. i\n-000127d0: 6620 6e6f 7420 7365 6c66 2e73 656e 645f f not self.send_\n-000127e0: 6461 7461 2864 6174 6129 3a0a 2020 2020 data(data):. \n-000127f0: 2020 2020 2020 2020 7365 6c66 2e5f 7472 self._tr\n-00012800: 616e 7370 6f72 742e 7061 7573 655f 7265 ansport.pause_re\n-00012810: 6164 696e 6728 290a 0a20 2020 2064 6566 ading().. def\n-00012820: 2064 6f5f 7265 7375 6d65 5f73 656e 6428 do_resume_send(\n-00012830: 7365 6c66 2920 2d3e 204e 6f6e 653a 0a20 self) -> None:. \n-00012840: 2020 2020 2020 2061 7373 6572 7420 7365 assert se\n-00012850: 6c66 2e5f 7472 616e 7370 6f72 7420 6973 lf._transport is\n-00012860: 206e 6f74 204e 6f6e 650a 2020 2020 2020 not None. \n-00012870: 2020 7365 6c66 2e5f 7472 616e 7370 6f72 self._transpor\n-00012880: 742e 7265 7375 6d65 5f72 6561 6469 6e67 t.resume_reading\n-00012890: 2829 0a0a 2020 2020 6465 6620 636c 6f73 ().. def clos\n-000128a0: 655f 6f6e 5f65 6f66 2873 656c 6629 202d e_on_eof(self) -\n-000128b0: 3e20 4e6f 6e65 3a0a 2020 2020 2020 2020 > None:. \n-000128c0: 2222 224d 6172 6b20 7468 6520 6368 616e \"\"\"Mark the chan\n-000128d0: 6e65 6c20 746f 2062 6520 636c 6f73 6564 nel to be closed\n-000128e0: 206f 6e20 454f 462e 0a0a 2020 2020 2020 on EOF... \n-000128f0: 2020 4e6f 726d 616c 6c79 2c20 5072 6f74 Normally, Prot\n-00012900: 6f63 6f6c 4368 616e 6e65 6c20 7472 6965 ocolChannel trie\n-00012910: 7320 746f 206b 6565 7020 7468 6520 6368 s to keep the ch\n-00012920: 616e 6e65 6c20 6861 6c66 2d6f 7065 6e20 annel half-open \n-00012930: 6166 7465 720a 2020 2020 2020 2020 7265 after. re\n-00012940: 6365 6976 696e 6720 454f 4620 6672 6f6d ceiving EOF from\n-00012950: 2074 6865 2074 7261 6e73 706f 7274 2e20 the transport. \n-00012960: 2054 6869 7320 696e 7374 7275 6374 7320 This instructs \n-00012970: 7468 6174 2074 6865 2063 6861 6e6e 656c that the channel\n-00012980: 0a20 2020 2020 2020 2073 686f 756c 6420 . should \n-00012990: 6265 2063 6c6f 7365 6420 6f6e 2045 4f46 be closed on EOF\n-000129a0: 2e0a 0a20 2020 2020 2020 2049 6620 454f ... If EO\n-000129b0: 4620 7761 7320 616c 7265 6164 7920 7265 F was already re\n-000129c0: 6365 6976 6564 2c20 7468 656e 2063 616c ceived, then cal\n-000129d0: 6c69 6e67 2074 6869 7320 6675 6e63 7469 ling this functi\n-000129e0: 6f6e 2077 696c 6c20 636c 6f73 6520 7468 on will close th\n-000129f0: 650a 2020 2020 2020 2020 6368 616e 6e65 e. channe\n-00012a00: 6c20 696d 6d65 6469 6174 656c 792e 0a0a l immediately...\n-00012a10: 2020 2020 2020 2020 4966 2079 6f75 2064 If you d\n-00012a20: 6f6e 2774 2063 616c 6c20 7468 6973 2066 on't call this f\n-00012a30: 756e 6374 696f 6e2c 2079 6f75 2061 7265 unction, you are\n-00012a40: 2072 6573 706f 6e73 6962 6c65 2066 6f72 responsible for\n-00012a50: 2063 6c6f 7369 6e67 2074 6865 0a20 2020 closing the. \n-00012a60: 2020 2020 2063 6861 6e6e 656c 2079 6f75 channel you\n-00012a70: 7273 656c 662e 0a20 2020 2020 2020 2022 rself.. \"\n-00012a80: 2222 0a20 2020 2020 2020 2073 656c 662e \"\". self.\n-00012a90: 5f63 6c6f 7365 5f6f 6e5f 656f 6620 3d20 _close_on_eof = \n-00012aa0: 5472 7565 0a20 2020 2020 2020 2069 6620 True. if \n-00012ab0: 7365 6c66 2e5f 656f 663a 0a20 2020 2020 self._eof:. \n-00012ac0: 2020 2020 2020 2061 7373 6572 7420 7365 assert se\n-00012ad0: 6c66 2e5f 7472 616e 7370 6f72 7420 6973 lf._transport is\n-00012ae0: 206e 6f74 204e 6f6e 650a 2020 2020 2020 not None. \n-00012af0: 2020 2020 2020 7365 6c66 2e5f 7472 616e self._tran\n-00012b00: 7370 6f72 742e 636c 6f73 6528 290a 0a20 sport.close().. \n-00012b10: 2020 2064 6566 2065 6f66 5f72 6563 6569 def eof_recei\n-00012b20: 7665 6428 7365 6c66 2920 2d3e 2062 6f6f ved(self) -> boo\n-00012b30: 6c3a 0a20 2020 2020 2020 2073 656c 662e l:. self.\n-00012b40: 5f65 6f66 203d 2054 7275 650a 2020 2020 _eof = True. \n-00012b50: 2020 2020 7365 6c66 2e64 6f6e 6528 290a self.done().\n-00012b60: 2020 2020 2020 2020 7265 7475 726e 206e return n\n-00012b70: 6f74 2073 656c 662e 5f63 6c6f 7365 5f6f ot self._close_o\n-00012b80: 6e5f 656f 660a 0a20 2020 2023 2043 6861 n_eof.. # Cha\n-00012b90: 6e6e 656c 2072 6563 6569 7665 2d73 6964 nnel receive-sid\n-00012ba0: 6520 666c 6f77 2063 6f6e 7472 6f6c 0a20 e flow control. \n-00012bb0: 2020 2064 6566 2064 6f5f 7069 6e67 2873 def do_ping(s\n-00012bc0: 656c 662c 206d 6573 7361 6765 293a 0a20 elf, message):. \n-00012bd0: 2020 2020 2020 2069 6620 7365 6c66 2e5f if self._\n-00012be0: 7365 6e64 5f70 6f6e 6773 3a0a 2020 2020 send_pongs:. \n-00012bf0: 2020 2020 2020 2020 7365 6c66 2e73 656e self.sen\n-00012c00: 645f 706f 6e67 286d 6573 7361 6765 290a d_pong(message).\n-00012c10: 2020 2020 2020 2020 656c 7365 3a0a 2020 else:. \n-00012c20: 2020 2020 2020 2020 2020 2320 7765 276c # we'l\n-00012c30: 6c20 6861 7665 2074 6f20 706f 6e67 206c l have to pong l\n-00012c40: 6174 6572 0a20 2020 2020 2020 2020 2020 ater. \n-00012c50: 2073 656c 662e 5f6c 6173 745f 7069 6e67 self._last_ping\n-00012c60: 203d 206d 6573 7361 6765 0a0a 2020 2020 = message.. \n-00012c70: 6465 6620 7061 7573 655f 7772 6974 696e def pause_writin\n-00012c80: 6728 7365 6c66 2920 2d3e 204e 6f6e 653a g(self) -> None:\n-00012c90: 0a20 2020 2020 2020 2023 2057 6520 6361 . # We ca\n-00012ca0: 6e27 7420 6163 7475 616c 6c79 2073 746f n't actually sto\n-00012cb0: 7020 7772 6974 696e 672c 2062 7574 2077 p writing, but w\n-00012cc0: 6520 6361 6e20 7374 6f70 2072 6570 6c79 e can stop reply\n-00012cd0: 696e 6720 746f 2070 696e 6773 0a20 2020 ing to pings. \n-00012ce0: 2020 2020 2073 656c 662e 5f73 656e 645f self._send_\n-00012cf0: 706f 6e67 7320 3d20 4661 6c73 650a 0a20 pongs = False.. \n-00012d00: 2020 2064 6566 2072 6573 756d 655f 7772 def resume_wr\n-00012d10: 6974 696e 6728 7365 6c66 2920 2d3e 204e iting(self) -> N\n-00012d20: 6f6e 653a 0a20 2020 2020 2020 2073 656c one:. sel\n-00012d30: 662e 5f73 656e 645f 706f 6e67 7320 3d20 f._send_pongs = \n-00012d40: 5472 7565 0a20 2020 2020 2020 2069 6620 True. if \n-00012d50: 7365 6c66 2e5f 6c61 7374 5f70 696e 6720 self._last_ping \n-00012d60: 6973 206e 6f74 204e 6f6e 653a 0a20 2020 is not None:. \n-00012d70: 2020 2020 2020 2020 2073 656c 662e 7365 self.se\n-00012d80: 6e64 5f70 6f6e 6728 7365 6c66 2e5f 6c61 nd_pong(self._la\n-00012d90: 7374 5f70 696e 6729 0a20 2020 2020 2020 st_ping). \n-00012da0: 2020 2020 2073 656c 662e 5f6c 6173 745f self._last_\n-00012db0: 7069 6e67 203d 204e 6f6e 650a 0a0a 636c ping = None...cl\n-00012dc0: 6173 7320 4173 796e 6343 6861 6e6e 656c ass AsyncChannel\n-00012dd0: 2843 6861 6e6e 656c 293a 0a20 2020 2022 (Channel):. \"\n-00012de0: 2222 4120 7375 6263 6c61 7373 2066 6f72 \"\"A subclass for\n-00012df0: 2061 7379 6e63 2f61 7761 6974 2d73 7479 async/await-sty\n-00012e00: 6c65 2069 6d70 6c65 6d65 6e74 6174 696f le implementatio\n-00012e10: 6e20 6f66 2063 6861 6e6e 656c 732c 2077 n of channels, w\n-00012e20: 6974 6820 666c 6f77 2063 6f6e 7472 6f6c ith flow control\n-00012e30: 0a0a 2020 2020 5468 6973 2073 7562 636c .. This subcl\n-00012e40: 6173 7320 7072 6f76 6964 6573 2061 7379 ass provides asy\n-00012e50: 6e63 6872 6f6e 6f75 7320 6072 6561 6428 nchronous `read(\n-00012e60: 2960 2061 6e64 2060 7772 6974 6528 2960 )` and `write()`\n-00012e70: 2063 616c 6c73 2066 6f72 0a20 2020 2073 calls for. s\n-00012e80: 7562 636c 6173 7365 732c 2077 6974 6820 ubclasses, with \n-00012e90: 6661 6d69 6c69 6172 2073 656d 616e 7469 familiar semanti\n-00012ea0: 6373 2e20 2060 7772 6974 6528 2960 2064 cs. `write()` d\n-00012eb0: 6f65 736e 2774 2062 7566 6665 722c 2073 oesn't buffer, s\n-00012ec0: 6f20 7468 650a 2020 2020 6064 6f6e 6528 o the. `done(\n-00012ed0: 2960 206d 6574 686f 6420 6f6e 2074 6865 )` method on the\n-00012ee0: 2062 6173 6520 6368 616e 6e65 6c20 636c base channel cl\n-00012ef0: 6173 7320 6361 6e20 6265 2075 7365 6420 ass can be used \n-00012f00: 696e 2061 2077 6179 2073 696d 696c 6172 in a way similar\n-00012f10: 2074 6f0a 2020 2020 6073 6875 7464 6f77 to. `shutdow\n-00012f20: 6e28 2960 2e20 2041 2068 6967 682d 6c65 n()`. A high-le\n-00012f30: 7665 6c20 6073 656e 6466 696c 6528 2960 vel `sendfile()`\n-00012f40: 206d 6574 686f 6420 6973 2061 7661 696c method is avail\n-00012f50: 6162 6c65 2074 6f20 7365 6e64 2074 6865 able to send the\n-00012f60: 0a20 2020 2065 6e74 6972 6520 636f 6e74 . entire cont\n-00012f70: 656e 7473 206f 6620 6120 6269 6e61 7279 ents of a binary\n-00012f80: 2d6d 6f64 6520 6669 6c65 2d6c 696b 6520 -mode file-like \n-00012f90: 6f62 6a65 6374 2e0a 0a20 2020 2054 6865 object... The\n-00012fa0: 2073 7562 636c 6173 7320 6d75 7374 2070 subclass must p\n-00012fb0: 726f 7669 6465 2061 6e20 6173 796e 6320 rovide an async \n-00012fc0: 6072 756e 2829 6020 6675 6e63 7469 6f6e `run()` function\n-00012fd0: 2c20 7768 6963 6820 7769 6c6c 2062 6520 , which will be \n-00012fe0: 7370 6177 6e65 640a 2020 2020 6173 2061 spawned. as a\n-00012ff0: 2074 6173 6b2e 2020 5468 6520 7461 736b task. The task\n-00013000: 2069 7320 6361 6e63 656c 6c65 6420 7768 is cancelled wh\n-00013010: 656e 2074 6865 2063 6861 6e6e 656c 2069 en the channel i\n-00013020: 7320 636c 6f73 6564 2e0a 0a20 2020 204f s closed... O\n-00013030: 6e20 7468 6520 7265 6365 6976 696e 6720 n the receiving \n-00013040: 7369 6465 2c20 7468 6520 6368 616e 6e65 side, the channe\n-00013050: 6c20 7769 6c6c 2072 6573 706f 6e64 2074 l will respond t\n-00013060: 6f20 666c 6f77 2063 6f6e 7472 6f6c 2070 o flow control p\n-00013070: 696e 6773 2074 6f0a 2020 2020 696e 6469 ings to. indi\n-00013080: 6361 7465 2074 6861 7420 6974 2068 6173 cate that it has\n-00013090: 2072 6563 6569 7665 6420 7468 6520 6461 received the da\n-000130a0: 7461 2c20 6275 7420 6f6e 6c79 2061 6674 ta, but only aft\n-000130b0: 6572 2069 7420 6861 7320 6265 656e 2063 er it has been c\n-000130c0: 6f6e 7375 6d65 640a 2020 2020 6279 2060 onsumed. by `\n-000130d0: 7265 6164 2829 602e 0a0a 2020 2020 4f6e read()`... On\n-000130e0: 2074 6865 2073 656e 6469 6e67 2073 6964 the sending sid\n-000130f0: 652c 2077 7269 7465 2829 2077 696c 6c20 e, write() will \n-00013100: 626c 6f63 6b20 6966 2074 6865 2063 6861 block if the cha\n-00013110: 6e6e 656c 2062 6163 6b73 2075 702e 0a20 nnel backs up.. \n-00013120: 2020 2022 2222 0a0a 2020 2020 2320 5265 \"\"\".. # Re\n-00013130: 6365 6976 652d 7369 6465 2066 6c6f 7720 ceive-side flow \n-00013140: 636f 6e74 726f 6c3a 2069 6e74 6572 6d69 control: intermi\n-00013150: 7820 7069 6e67 7320 616e 6420 6461 7461 x pings and data\n-00013160: 2069 6e20 7468 6520 7175 6575 6520 616e in the queue an\n-00013170: 6420 7265 706c 790a 2020 2020 2320 746f d reply. # to\n-00013180: 2070 696e 6773 2061 7320 7765 2064 6571 pings as we deq\n-00013190: 7565 7565 2074 6865 6d2e 2020 454f 4620 ueue them. EOF \n-000131a0: 6973 204e 6f6e 652e 2020 5468 6973 2069 is None. This i\n-000131b0: 7320 6120 6275 6666 6572 3a20 7369 6e63 s a buffer: sinc\n-000131c0: 6520 7765 0a20 2020 2023 206e 6565 6420 e we. # need \n-000131d0: 746f 2068 616e 646c 6520 646f 5f64 6174 to handle do_dat\n-000131e0: 6128 2920 7769 7468 6f75 7420 626c 6f63 a() without bloc\n-000131f0: 6b69 6e67 2c20 7765 2068 6176 6520 6e6f king, we have no\n-00013200: 2063 686f 6963 652e 0a20 2020 2072 6563 choice.. rec\n-00013210: 6569 7665 5f71 7565 7565 3a20 2761 7379 eive_queue: 'asy\n-00013220: 6e63 696f 2e51 7565 7565 5b62 7974 6573 ncio.Queue[bytes\n-00013230: 207c 204a 736f 6e4f 626a 6563 7420 7c20 | JsonObject | \n-00013240: 4e6f 6e65 5d27 0a0a 2020 2020 2320 5365 None]'.. # Se\n-00013250: 6e64 2d73 6964 6520 666c 6f77 2063 6f6e nd-side flow con\n-00013260: 7472 6f6c 0a20 2020 2077 7269 7465 5f77 trol. write_w\n-00013270: 6169 7465 7220 3d20 4e6f 6e65 0a0a 2020 aiter = None.. \n-00013280: 2020 6173 796e 6320 6465 6620 7275 6e28 async def run(\n-00013290: 7365 6c66 2c20 6f70 7469 6f6e 733a 204a self, options: J\n-000132a0: 736f 6e4f 626a 6563 7429 202d 3e20 274a sonObject) -> 'J\n-000132b0: 736f 6e4f 626a 6563 7420 7c20 4e6f 6e65 sonObject | None\n-000132c0: 273a 0a20 2020 2020 2020 2072 6169 7365 ':. raise\n-000132d0: 204e 6f74 496d 706c 656d 656e 7465 6445 NotImplementedE\n-000132e0: 7272 6f72 0a0a 2020 2020 6173 796e 6320 rror.. async \n-000132f0: 6465 6620 7275 6e5f 7772 6170 7065 7228 def run_wrapper(\n-00013300: 7365 6c66 2c20 6f70 7469 6f6e 733a 204a self, options: J\n-00013310: 736f 6e4f 626a 6563 7429 202d 3e20 4e6f sonObject) -> No\n-00013320: 6e65 3a0a 2020 2020 2020 2020 7472 793a ne:. try:\n-00013330: 0a20 2020 2020 2020 2020 2020 2073 656c . sel\n-00013340: 662e 636c 6f73 6528 6177 6169 7420 7365 f.close(await se\n-00013350: 6c66 2e72 756e 286f 7074 696f 6e73 2929 lf.run(options))\n-00013360: 0a20 2020 2020 2020 2065 7863 6570 7420 . except \n-00013370: 6173 796e 6369 6f2e 4361 6e63 656c 6c65 asyncio.Cancelle\n-00013380: 6445 7272 6f72 3a20 2023 2075 7365 7220 dError: # user \n-00013390: 7265 7175 6573 7465 6420 636c 6f73 650a requested close.\n-000133a0: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n-000133b0: 2e63 6c6f 7365 2829 0a20 2020 2020 2020 .close(). \n-000133c0: 2065 7863 6570 7420 4368 616e 6e65 6c45 except ChannelE\n-000133d0: 7272 6f72 2061 7320 6578 633a 0a20 2020 rror as exc:. \n-000133e0: 2020 2020 2020 2020 2073 656c 662e 636c self.cl\n-000133f0: 6f73 6528 6578 632e 6765 745f 6174 7472 ose(exc.get_attr\n-00013400: 7328 2929 0a20 2020 2020 2020 2065 7863 s()). exc\n-00013410: 6570 7420 4261 7365 4578 6365 7074 696f ept BaseExceptio\n-00013420: 6e3a 0a20 2020 2020 2020 2020 2020 2073 n:. s\n-00013430: 656c 662e 636c 6f73 6528 7b27 7072 6f62 elf.close({'prob\n-00013440: 6c65 6d27 3a20 2769 6e74 6572 6e61 6c2d lem': 'internal-\n-00013450: 6572 726f 7227 2c20 2763 6175 7365 273a error', 'cause':\n-00013460: 2074 7261 6365 6261 636b 2e66 6f72 6d61 traceback.forma\n-00013470: 745f 6578 6328 297d 290a 2020 2020 2020 t_exc()}). \n-00013480: 2020 2020 2020 7261 6973 650a 0a20 2020 raise.. \n-00013490: 2061 7379 6e63 2064 6566 2072 6561 6428 async def read(\n-000134a0: 7365 6c66 2920 2d3e 2027 6279 7465 7320 self) -> 'bytes \n-000134b0: 7c20 4e6f 6e65 273a 0a20 2020 2020 2020 | None':. \n-000134c0: 2023 2054 6872 6565 2070 6f73 7369 6269 # Three possibi\n-000134d0: 6c69 7469 6573 2066 6f72 2077 6861 7420 lities for what \n-000134e0: 7765 276c 6c20 6669 6e64 3a0a 2020 2020 we'll find:. \n-000134f0: 2020 2020 2320 202d 204e 6f6e 6520 2845 # - None (E\n-00013500: 4f46 2920 e286 9220 7265 7475 726e 204e OF) ... return N\n-00013510: 6f6e 650a 2020 2020 2020 2020 2320 202d one. # -\n-00013520: 2061 2070 696e 6720 e286 9220 7365 6e64 a ping ... send\n-00013530: 2061 2070 6f6e 670a 2020 2020 2020 2020 a pong. \n-00013540: 2320 202d 2062 7974 6573 2028 706f 7373 # - bytes (poss\n-00013550: 6962 6c79 2065 6d70 7479 2920 e286 9220 ibly empty) ... \n-00013560: 6163 6b20 7468 6520 7265 6365 6970 742c ack the receipt,\n-00013570: 2061 6e64 2072 6574 7572 6e20 6974 0a20 and return it. \n-00013580: 2020 2020 2020 2077 6869 6c65 2054 7275 while Tru\n-00013590: 653a 0a20 2020 2020 2020 2020 2020 2069 e:. i\n-000135a0: 7465 6d20 3d20 6177 6169 7420 7365 6c66 tem = await self\n-000135b0: 2e72 6563 6569 7665 5f71 7565 7565 2e67 .receive_queue.g\n-000135c0: 6574 2829 0a20 2020 2020 2020 2020 2020 et(). \n-000135d0: 2069 6620 6974 656d 2069 7320 4e6f 6e65 if item is None\n-000135e0: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n-000135f0: 2020 7265 7475 726e 204e 6f6e 650a 2020 return None. \n-00013600: 2020 2020 2020 2020 2020 6966 2069 7369 if isi\n-00013610: 6e73 7461 6e63 6528 6974 656d 2c20 4d61 nstance(item, Ma\n-00013620: 7070 696e 6729 3a0a 2020 2020 2020 2020 pping):. \n-00013630: 2020 2020 2020 2020 7365 6c66 2e73 656e self.sen\n-00013640: 645f 706f 6e67 2869 7465 6d29 0a20 2020 d_pong(item). \n-00013650: 2020 2020 2020 2020 2065 6c73 653a 0a20 else:. \n-00013660: 2020 2020 2020 2020 2020 2020 2020 2073 s\n-00013670: 656c 662e 7365 6e64 5f61 636b 2869 7465 elf.send_ack(ite\n-00013680: 6d29 0a20 2020 2020 2020 2020 2020 2020 m). \n-00013690: 2020 2072 6574 7572 6e20 6974 656d 0a0a return item..\n-000136a0: 2020 2020 6173 796e 6320 6465 6620 7772 async def wr\n-000136b0: 6974 6528 7365 6c66 2c20 6461 7461 3a20 ite(self, data: \n-000136c0: 6279 7465 7329 202d 3e20 4e6f 6e65 3a0a bytes) -> None:.\n-000136d0: 2020 2020 2020 2020 6966 206e 6f74 2073 if not s\n-000136e0: 656c 662e 7365 6e64 5f64 6174 6128 6461 elf.send_data(da\n-000136f0: 7461 293a 0a20 2020 2020 2020 2020 2020 ta):. \n-00013700: 2073 656c 662e 7772 6974 655f 7761 6974 self.write_wait\n-00013710: 6572 203d 2061 7379 6e63 696f 2e67 6574 er = asyncio.get\n-00013720: 5f72 756e 6e69 6e67 5f6c 6f6f 7028 292e _running_loop().\n-00013730: 6372 6561 7465 5f66 7574 7572 6528 290a create_future().\n-00013740: 2020 2020 2020 2020 2020 2020 6177 6169 awai\n-00013750: 7420 7365 6c66 2e77 7269 7465 5f77 6169 t self.write_wai\n-00013760: 7465 720a 0a20 2020 2061 7379 6e63 2064 ter.. async d\n-00013770: 6566 2073 656e 6466 696c 6528 7365 6c66 ef sendfile(self\n-00013780: 2c20 7374 7265 616d 3a20 4269 6e61 7279 , stream: Binary\n-00013790: 494f 2920 2d3e 204e 6f6e 653a 0a20 2020 IO) -> None:. \n-000137a0: 2020 2020 206c 6f6f 7020 3d20 6173 796e loop = asyn\n-000137b0: 6369 6f2e 6765 745f 7275 6e6e 696e 675f cio.get_running_\n-000137c0: 6c6f 6f70 2829 0a20 2020 2020 2020 2077 loop(). w\n-000137d0: 6974 6820 7374 7265 616d 3a0a 2020 2020 ith stream:. \n-000137e0: 2020 2020 2020 2020 7768 696c 6520 5472 while Tr\n-000137f0: 7565 3a0a 2020 2020 2020 2020 2020 2020 ue:. \n-00013800: 2020 2020 6461 7461 203d 2061 7761 6974 data = await\n-00013810: 206c 6f6f 702e 7275 6e5f 696e 5f65 7865 loop.run_in_exe\n-00013820: 6375 746f 7228 4e6f 6e65 2c20 7374 7265 cutor(None, stre\n-00013830: 616d 2e72 6561 642c 2043 6861 6e6e 656c am.read, Channel\n-00013840: 2e42 4c4f 434b 5f53 495a 4529 0a20 2020 .BLOCK_SIZE). \n-00013850: 2020 2020 2020 2020 2020 2020 2069 6620 if \n-00013860: 6461 7461 203d 3d20 6227 273a 0a20 2020 data == b'':. \n-00013870: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00013880: 2062 7265 616b 0a20 2020 2020 2020 2020 break. \n-00013890: 2020 2020 2020 2061 7761 6974 2073 656c await sel\n-000138a0: 662e 7772 6974 6528 6461 7461 290a 0a20 f.write(data).. \n-000138b0: 2020 2020 2020 2020 2020 2073 656c 662e self.\n-000138c0: 646f 6e65 2829 0a0a 2020 2020 6465 6620 done().. def \n-000138d0: 646f 5f72 6573 756d 655f 7365 6e64 2873 do_resume_send(s\n-000138e0: 656c 6629 202d 3e20 4e6f 6e65 3a0a 2020 elf) -> None:. \n-000138f0: 2020 2020 2020 6966 2073 656c 662e 7772 if self.wr\n-00013900: 6974 655f 7761 6974 6572 2069 7320 6e6f ite_waiter is no\n-00013910: 7420 4e6f 6e65 3a0a 2020 2020 2020 2020 t None:. \n-00013920: 2020 2020 7365 6c66 2e77 7269 7465 5f77 self.write_w\n-00013930: 6169 7465 722e 7365 745f 7265 7375 6c74 aiter.set_result\n-00013940: 284e 6f6e 6529 0a20 2020 2020 2020 2020 (None). \n-00013950: 2020 2073 656c 662e 7772 6974 655f 7761 self.write_wa\n-00013960: 6974 6572 203d 204e 6f6e 650a 0a20 2020 iter = None.. \n-00013970: 2064 6566 2064 6f5f 6f70 656e 2873 656c def do_open(sel\n-00013980: 662c 206f 7074 696f 6e73 3a20 4a73 6f6e f, options: Json\n-00013990: 4f62 6a65 6374 2920 2d3e 204e 6f6e 653a Object) -> None:\n-000139a0: 0a20 2020 2020 2020 2073 656c 662e 7265 . self.re\n-000139b0: 6365 6976 655f 7175 6575 6520 3d20 6173 ceive_queue = as\n-000139c0: 796e 6369 6f2e 5175 6575 6528 290a 2020 yncio.Queue(). \n-000139d0: 2020 2020 2020 7365 6c66 2e5f 7275 6e5f self._run_\n-000139e0: 7461 736b 203d 2073 656c 662e 6372 6561 task = self.crea\n-000139f0: 7465 5f74 6173 6b28 7365 6c66 2e72 756e te_task(self.run\n-00013a00: 5f77 7261 7070 6572 286f 7074 696f 6e73 _wrapper(options\n-00013a10: 292c 0a20 2020 2020 2020 2020 2020 2020 ),. \n-00013a20: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00013a30: 2020 2020 2020 2020 2020 2020 206e 616d nam\n-00013a40: 653d 6627 7b73 656c 662e 5f5f 636c 6173 e=f'{self.__clas\n-00013a50: 735f 5f2e 5f5f 6e61 6d65 5f5f 7d2e 7275 s__.__name__}.ru\n-00013a60: 6e5f 7772 6170 7065 7228 7b6f 7074 696f n_wrapper({optio\n-00013a70: 6e73 7d29 2729 0a0a 2020 2020 6465 6620 ns})').. def \n-00013a80: 646f 5f64 6f6e 6528 7365 6c66 2920 2d3e do_done(self) ->\n-00013a90: 204e 6f6e 653a 0a20 2020 2020 2020 2073 None:. s\n-00013aa0: 656c 662e 7265 6365 6976 655f 7175 6575 elf.receive_queu\n-00013ab0: 652e 7075 745f 6e6f 7761 6974 284e 6f6e e.put_nowait(Non\n-00013ac0: 6529 0a0a 2020 2020 6465 6620 646f 5f63 e).. def do_c\n-00013ad0: 6c6f 7365 2873 656c 6629 202d 3e20 4e6f lose(self) -> No\n-00013ae0: 6e65 3a0a 2020 2020 2020 2020 7365 6c66 ne:. self\n-00013af0: 2e5f 7275 6e5f 7461 736b 2e63 616e 6365 ._run_task.cance\n-00013b00: 6c28 290a 0a20 2020 2064 6566 2064 6f5f l().. def do_\n-00013b10: 7069 6e67 2873 656c 662c 206d 6573 7361 ping(self, messa\n-00013b20: 6765 3a20 4a73 6f6e 4f62 6a65 6374 2920 ge: JsonObject) \n-00013b30: 2d3e 204e 6f6e 653a 0a20 2020 2020 2020 -> None:. \n-00013b40: 2073 656c 662e 7265 6365 6976 655f 7175 self.receive_qu\n-00013b50: 6575 652e 7075 745f 6e6f 7761 6974 286d eue.put_nowait(m\n-00013b60: 6573 7361 6765 290a 0a20 2020 2064 6566 essage).. def\n-00013b70: 2064 6f5f 6461 7461 2873 656c 662c 2064 do_data(self, d\n-00013b80: 6174 613a 2062 7974 6573 2920 2d3e 2062 ata: bytes) -> b\n-00013b90: 6f6f 6c3a 0a20 2020 2020 2020 2073 656c ool:. sel\n-00013ba0: 662e 7265 6365 6976 655f 7175 6575 652e f.receive_queue.\n-00013bb0: 7075 745f 6e6f 7761 6974 2864 6174 6129 put_nowait(data)\n-00013bc0: 0a20 2020 2020 2020 2072 6574 7572 6e20 . return \n-00013bd0: 5472 7565 2020 2320 7765 2077 696c 6c20 True # we will \n-00013be0: 7365 6e64 2074 6865 2027 6163 6b27 206c send the 'ack' l\n-00013bf0: 6174 6572 2028 6672 6f6d 2072 6561 6428 ater (from read(\n-00013c00: 2929 0a0a 0a63 6c61 7373 2047 656e 6572 ))...class Gener\n-00013c10: 6174 6f72 4368 616e 6e65 6c28 4368 616e atorChannel(Chan\n-00013c20: 6e65 6c29 3a0a 2020 2020 2222 2241 2074 nel):. \"\"\"A t\n-00013c30: 7269 7669 616c 2043 6861 6e6e 656c 2073 rivial Channel s\n-00013c40: 7562 636c 6173 7320 666f 7220 7365 6e64 ubclass for send\n-00013c50: 696e 6720 6461 7461 2066 726f 6d20 6120 ing data from a \n-00013c60: 6765 6e65 7261 746f 7220 7769 7468 2066 generator with f\n-00013c70: 6c6f 7720 636f 6e74 726f 6c2e 0a0a 2020 low control... \n-00013c80: 2020 4361 6c6c 7320 7468 6520 2e64 6f5f Calls the .do_\n-00013c90: 7969 656c 645f 6461 7461 2829 2067 656e yield_data() gen\n-00013ca0: 6572 6174 6f72 2077 6974 6820 7468 6520 erator with the \n-00013cb0: 6f70 7469 6f6e 7320 6672 6f6d 2074 6865 options from the\n-00013cc0: 206f 7065 6e20 6d65 7373 6167 650a 2020 open message. \n-00013cd0: 2020 616e 6420 7365 6e64 7320 7468 6520 and sends the \n-00013ce0: 6461 7461 2077 6869 6368 2069 7420 7969 data which it yi\n-00013cf0: 656c 6473 2e20 2049 6620 7468 6520 6765 elds. If the ge\n-00013d00: 6e65 7261 746f 7220 7265 7475 726e 7320 nerator returns \n-00013d10: 6120 7661 6c75 6520 6974 0a20 2020 2077 a value it. w\n-00013d20: 696c 6c20 6265 2075 7365 6420 666f 7220 ill be used for \n-00013d30: 7468 6520 636c 6f73 6520 6d65 7373 6167 the close messag\n-00013d40: 652e 0a20 2020 2022 2222 0a20 2020 2044 e.. \"\"\". D\n-00013d50: 6174 6147 656e 6572 6174 6f72 203d 2047 ataGenerator = G\n-00013d60: 656e 6572 6174 6f72 5b62 7974 6573 2c20 enerator[bytes, \n-00013d70: 4e6f 6e65 2c20 4f70 7469 6f6e 616c 5b4a None, Optional[J\n-00013d80: 736f 6e4f 626a 6563 745d 5d0a 2020 2020 sonObject]]. \n-00013d90: 5f5f 6765 6e65 7261 746f 723a 2044 6174 __generator: Dat\n-00013da0: 6147 656e 6572 6174 6f72 0a0a 2020 2020 aGenerator.. \n-00013db0: 6465 6620 646f 5f79 6965 6c64 5f64 6174 def do_yield_dat\n-00013dc0: 6128 7365 6c66 2c20 6f70 7469 6f6e 733a a(self, options:\n-00013dd0: 204a 736f 6e4f 626a 6563 7429 202d 3e20 JsonObject) -> \n-00013de0: 2744 6174 6147 656e 6572 6174 6f72 273a 'DataGenerator':\n-00013df0: 0a20 2020 2020 2020 2072 6169 7365 204e . raise N\n-00013e00: 6f74 496d 706c 656d 656e 7465 6445 7272 otImplementedErr\n-00013e10: 6f72 0a0a 2020 2020 6465 6620 646f 5f6f or.. def do_o\n-00013e20: 7065 6e28 7365 6c66 2c20 6f70 7469 6f6e pen(self, option\n-00013e30: 733a 204a 736f 6e4f 626a 6563 7429 202d s: JsonObject) -\n-00013e40: 3e20 4e6f 6e65 3a0a 2020 2020 2020 2020 > None:. \n-00013e50: 7365 6c66 2e5f 5f67 656e 6572 6174 6f72 self.__generator\n-00013e60: 203d 2073 656c 662e 646f 5f79 6965 6c64 = self.do_yield\n-00013e70: 5f64 6174 6128 6f70 7469 6f6e 7329 0a20 _data(options). \n-00013e80: 2020 2020 2020 2073 656c 662e 646f 5f72 self.do_r\n-00013e90: 6573 756d 655f 7365 6e64 2829 0a0a 2020 esume_send().. \n-00013ea0: 2020 6465 6620 646f 5f72 6573 756d 655f def do_resume_\n-00013eb0: 7365 6e64 2873 656c 6629 202d 3e20 4e6f send(self) -> No\n-00013ec0: 6e65 3a0a 2020 2020 2020 2020 7472 793a ne:. try:\n-00013ed0: 0a20 2020 2020 2020 2020 2020 2077 6869 . whi\n-00013ee0: 6c65 2073 656c 662e 7365 6e64 5f64 6174 le self.send_dat\n-00013ef0: 6128 6e65 7874 2873 656c 662e 5f5f 6765 a(next(self.__ge\n-00013f00: 6e65 7261 746f 7229 293a 0a20 2020 2020 nerator)):. \n-00013f10: 2020 2020 2020 2020 2020 2070 6173 730a pass.\n-00013f20: 2020 2020 2020 2020 6578 6365 7074 2053 except S\n-00013f30: 746f 7049 7465 7261 7469 6f6e 2061 7320 topIteration as \n-00013f40: 7374 6f70 3a0a 2020 2020 2020 2020 2020 stop:. \n-00013f50: 2020 7365 6c66 2e64 6f6e 6528 290a 2020 self.done(). \n-00013f60: 2020 2020 2020 2020 2020 7365 6c66 2e63 self.c\n-00013f70: 6c6f 7365 2873 746f 702e 7661 6c75 6529 lose(stop.value)\n-00013f80: 0a27 2727 2e65 6e63 6f64 6528 2775 7466 .'''.encode('utf\n-00013f90: 2d38 2729 2c0a 2020 2763 6f63 6b70 6974 -8'),. 'cockpit\n-00013fa0: 2f70 6565 722e 7079 273a 2072 2727 2723 /peer.py': r'''#\n-00013fb0: 2054 6869 7320 6669 6c65 2069 7320 7061 This file is pa\n-00013fc0: 7274 206f 6620 436f 636b 7069 742e 0a23 rt of Cockpit..#\n-00013fd0: 0a23 2043 6f70 7972 6967 6874 2028 4329 .# Copyright (C)\n-00013fe0: 2032 3032 3220 5265 6420 4861 742c 2049 2022 Red Hat, I\n-00013ff0: 6e63 2e0a 230a 2320 5468 6973 2070 726f nc..#.# This pro\n-00014000: 6772 616d 2069 7320 6672 6565 2073 6f66 gram is free sof\n-00014010: 7477 6172 653a 2079 6f75 2063 616e 2072 tware: you can r\n-00014020: 6564 6973 7472 6962 7574 6520 6974 2061 edistribute it a\n-00014030: 6e64 2f6f 7220 6d6f 6469 6679 0a23 2069 nd/or modify.# i\n-00014040: 7420 756e 6465 7220 7468 6520 7465 726d t under the term\n-00014050: 7320 6f66 2074 6865 2047 4e55 2047 656e s of the GNU Gen\n-00014060: 6572 616c 2050 7562 6c69 6320 4c69 6365 eral Public Lice\n-00014070: 6e73 6520 6173 2070 7562 6c69 7368 6564 nse as published\n-00014080: 2062 790a 2320 7468 6520 4672 6565 2053 by.# the Free S\n-00014090: 6f66 7477 6172 6520 466f 756e 6461 7469 oftware Foundati\n-000140a0: 6f6e 2c20 6569 7468 6572 2076 6572 7369 on, either versi\n-000140b0: 6f6e 2033 206f 6620 7468 6520 4c69 6365 on 3 of the Lice\n-000140c0: 6e73 652c 206f 720a 2320 2861 7420 796f nse, or.# (at yo\n-000140d0: 7572 206f 7074 696f 6e29 2061 6e79 206c ur option) any l\n-000140e0: 6174 6572 2076 6572 7369 6f6e 2e0a 230a ater version..#.\n-000140f0: 2320 5468 6973 2070 726f 6772 616d 2069 # This program i\n-00014100: 7320 6469 7374 7269 6275 7465 6420 696e s distributed in\n-00014110: 2074 6865 2068 6f70 6520 7468 6174 2069 the hope that i\n-00014120: 7420 7769 6c6c 2062 6520 7573 6566 756c t will be useful\n-00014130: 2c0a 2320 6275 7420 5749 5448 4f55 5420 ,.# but WITHOUT \n-00014140: 414e 5920 5741 5252 414e 5459 3b20 7769 ANY WARRANTY; wi\n-00014150: 7468 6f75 7420 6576 656e 2074 6865 2069 thout even the i\n-00014160: 6d70 6c69 6564 2077 6172 7261 6e74 7920 mplied warranty \n-00014170: 6f66 0a23 204d 4552 4348 414e 5441 4249 of.# MERCHANTABI\n-00014180: 4c49 5459 206f 7220 4649 544e 4553 5320 LITY or FITNESS \n-00014190: 464f 5220 4120 5041 5254 4943 554c 4152 FOR A PARTICULAR\n-000141a0: 2050 5552 504f 5345 2e20 2053 6565 2074 PURPOSE. See t\n-000141b0: 6865 0a23 2047 4e55 2047 656e 6572 616c he.# GNU General\n-000141c0: 2050 7562 6c69 6320 4c69 6365 6e73 6520 Public License \n-000141d0: 666f 7220 6d6f 7265 2064 6574 6169 6c73 for more details\n-000141e0: 2e0a 230a 2320 596f 7520 7368 6f75 6c64 ..#.# You should\n-000141f0: 2068 6176 6520 7265 6365 6976 6564 2061 have received a\n-00014200: 2063 6f70 7920 6f66 2074 6865 2047 4e55 copy of the GNU\n-00014210: 2047 656e 6572 616c 2050 7562 6c69 6320 General Public \n-00014220: 4c69 6365 6e73 650a 2320 616c 6f6e 6720 License.# along \n-00014230: 7769 7468 2074 6869 7320 7072 6f67 7261 with this progra\n-00014240: 6d2e 2020 4966 206e 6f74 2c20 7365 6520 m. If not, see \n-00014250: 3c68 7474 7073 3a2f 2f77 7777 2e67 6e75 .\n-00014270: 0a0a 696d 706f 7274 2061 7379 6e63 696f ..import asyncio\n-00014280: 0a69 6d70 6f72 7420 6c6f 6767 696e 670a .import logging.\n-00014290: 696d 706f 7274 206f 730a 6672 6f6d 2074 import os.from t\n-000142a0: 7970 696e 6720 696d 706f 7274 2043 616c yping import Cal\n-000142b0: 6c61 626c 652c 204c 6973 742c 204f 7074 lable, List, Opt\n-000142c0: 696f 6e61 6c2c 2053 6571 7565 6e63 650a ional, Sequence.\n-000142d0: 0a66 726f 6d20 2e6a 736f 6e75 7469 6c20 .from .jsonutil \n-000142e0: 696d 706f 7274 204a 736f 6e4f 626a 6563 import JsonObjec\n-000142f0: 742c 204a 736f 6e56 616c 7565 0a66 726f t, JsonValue.fro\n-00014300: 6d20 2e70 6163 6b61 6765 7320 696d 706f m .packages impo\n-00014310: 7274 2042 7269 6467 6543 6f6e 6669 670a rt BridgeConfig.\n-00014320: 6672 6f6d 202e 7072 6f74 6f63 6f6c 2069 from .protocol i\n-00014330: 6d70 6f72 7420 436f 636b 7069 7450 726f mport CockpitPro\n-00014340: 626c 656d 2c20 436f 636b 7069 7450 726f blem, CockpitPro\n-00014350: 746f 636f 6c2c 2043 6f63 6b70 6974 5072 tocol, CockpitPr\n-00014360: 6f74 6f63 6f6c 4572 726f 720a 6672 6f6d otocolError.from\n-00014370: 202e 726f 7574 6572 2069 6d70 6f72 7420 .router import \n-00014380: 456e 6470 6f69 6e74 2c20 526f 7574 6572 Endpoint, Router\n-00014390: 2c20 526f 7574 696e 6752 756c 650a 6672 , RoutingRule.fr\n-000143a0: 6f6d 202e 7472 616e 7370 6f72 7473 2069 om .transports i\n-000143b0: 6d70 6f72 7420 5375 6270 726f 6365 7373 mport Subprocess\n-000143c0: 5072 6f74 6f63 6f6c 2c20 5375 6270 726f Protocol, Subpro\n-000143d0: 6365 7373 5472 616e 7370 6f72 740a 0a6c cessTransport..l\n-000143e0: 6f67 6765 7220 3d20 6c6f 6767 696e 672e ogger = logging.\n-000143f0: 6765 744c 6f67 6765 7228 5f5f 6e61 6d65 getLogger(__name\n-00014400: 5f5f 290a 0a0a 636c 6173 7320 5065 6572 __)...class Peer\n-00014410: 4572 726f 7228 436f 636b 7069 7450 726f Error(CockpitPro\n-00014420: 626c 656d 293a 0a20 2020 2070 6173 730a blem):. pass.\n-00014430: 0a0a 636c 6173 7320 5065 6572 4578 6974 ..class PeerExit\n-00014440: 6564 2845 7863 6570 7469 6f6e 293a 0a20 ed(Exception):. \n-00014450: 2020 2064 6566 205f 5f69 6e69 745f 5f28 def __init__(\n-00014460: 7365 6c66 2c20 6578 6974 5f63 6f64 653a self, exit_code:\n-00014470: 2069 6e74 293a 0a20 2020 2020 2020 2073 int):. s\n-00014480: 656c 662e 6578 6974 5f63 6f64 6520 3d20 elf.exit_code = \n-00014490: 6578 6974 5f63 6f64 650a 0a0a 636c 6173 exit_code...clas\n-000144a0: 7320 5065 6572 2843 6f63 6b70 6974 5072 s Peer(CockpitPr\n-000144b0: 6f74 6f63 6f6c 2c20 5375 6270 726f 6365 otocol, Subproce\n-000144c0: 7373 5072 6f74 6f63 6f6c 2c20 456e 6470 ssProtocol, Endp\n-000144d0: 6f69 6e74 293a 0a20 2020 2064 6f6e 655f oint):. done_\n-000144e0: 6361 6c6c 6261 636b 733a 204c 6973 745b callbacks: List[\n-000144f0: 4361 6c6c 6162 6c65 5b5b 5d2c 204e 6f6e Callable[[], Non\n-00014500: 655d 5d0a 2020 2020 696e 6974 5f66 7574 e]]. init_fut\n-00014510: 7572 653a 204f 7074 696f 6e61 6c5b 6173 ure: Optional[as\n-00014520: 796e 6369 6f2e 4675 7475 7265 5d0a 0a20 yncio.Future].. \n-00014530: 2020 2064 6566 205f 5f69 6e69 745f 5f28 def __init__(\n-00014540: 7365 6c66 2c20 726f 7574 6572 3a20 526f self, router: Ro\n-00014550: 7574 6572 293a 0a20 2020 2020 2020 2073 uter):. s\n-00014560: 7570 6572 2829 2e5f 5f69 6e69 745f 5f28 uper().__init__(\n-00014570: 726f 7574 6572 290a 0a20 2020 2020 2020 router).. \n-00014580: 2023 2041 6c6c 2050 6565 7273 2073 7461 # All Peers sta\n-00014590: 7274 206f 7574 2066 726f 7a65 6e20 e280 rt out frozen ..\n-000145a0: 9420 7765 206f 6e6c 7920 756e 6672 6565 . we only unfree\n-000145b0: 7a65 2061 6674 6572 2077 6520 7365 6520 ze after we see \n-000145c0: 7468 6520 6669 7273 7420 2769 6e69 7427 the first 'init'\n-000145d0: 206d 6573 7361 6765 0a20 2020 2020 2020 message. \n-000145e0: 2073 656c 662e 6672 6565 7a65 5f65 6e64 self.freeze_end\n-000145f0: 706f 696e 7428 290a 0a20 2020 2020 2020 point().. \n-00014600: 2073 656c 662e 696e 6974 5f66 7574 7572 self.init_futur\n-00014610: 6520 3d20 6173 796e 6369 6f2e 6765 745f e = asyncio.get_\n-00014620: 7275 6e6e 696e 675f 6c6f 6f70 2829 2e63 running_loop().c\n-00014630: 7265 6174 655f 6675 7475 7265 2829 0a20 reate_future(). \n-00014640: 2020 2020 2020 2073 656c 662e 646f 6e65 self.done\n-00014650: 5f63 616c 6c62 6163 6b73 203d 205b 5d0a _callbacks = [].\n-00014660: 0a20 2020 2023 2049 6e69 7469 616c 697a . # Initializ\n-00014670: 6174 696f 6e0a 2020 2020 6173 796e 6320 ation. async \n-00014680: 6465 6620 646f 5f63 6f6e 6e65 6374 5f74 def do_connect_t\n-00014690: 7261 6e73 706f 7274 2873 656c 6629 202d ransport(self) -\n-000146a0: 3e20 4e6f 6e65 3a0a 2020 2020 2020 2020 > None:. \n-000146b0: 7261 6973 6520 4e6f 7449 6d70 6c65 6d65 raise NotImpleme\n-000146c0: 6e74 6564 4572 726f 720a 0a20 2020 2061 ntedError.. a\n-000146d0: 7379 6e63 2064 6566 2073 7061 776e 2873 sync def spawn(s\n-000146e0: 656c 662c 2061 7267 763a 2053 6571 7565 elf, argv: Seque\n-000146f0: 6e63 655b 7374 725d 2c20 656e 763a 2053 nce[str], env: S\n-00014700: 6571 7565 6e63 655b 7374 725d 2c20 2a2a equence[str], **\n-00014710: 6b77 6172 6773 2920 2d3e 2061 7379 6e63 kwargs) -> async\n-00014720: 696f 2e54 7261 6e73 706f 7274 3a0a 2020 io.Transport:. \n-00014730: 2020 2020 2020 2320 4e6f 7420 6163 7475 # Not actu\n-00014740: 616c 6c79 2061 7379 6e63 2e2e 2e0a 2020 ally async.... \n-00014750: 2020 2020 2020 6c6f 6f70 203d 2061 7379 loop = asy\n-00014760: 6e63 696f 2e67 6574 5f72 756e 6e69 6e67 ncio.get_running\n-00014770: 5f6c 6f6f 7028 290a 2020 2020 2020 2020 _loop(). \n-00014780: 7573 6572 5f65 6e76 203d 2064 6963 7428 user_env = dict(\n-00014790: 652e 7370 6c69 7428 273d 272c 2031 2920 e.split('=', 1) \n-000147a0: 666f 7220 6520 696e 2065 6e76 290a 2020 for e in env). \n-000147b0: 2020 2020 2020 7265 7475 726e 2053 7562 return Sub\n-000147c0: 7072 6f63 6573 7354 7261 6e73 706f 7274 processTransport\n-000147d0: 286c 6f6f 702c 2073 656c 662c 2061 7267 (loop, self, arg\n-000147e0: 762c 2065 6e76 3d64 6963 7428 6f73 2e65 v, env=dict(os.e\n-000147f0: 6e76 6972 6f6e 2c20 2a2a 7573 6572 5f65 nviron, **user_e\n-00014800: 6e76 292c 202a 2a6b 7761 7267 7329 0a0a nv), **kwargs)..\n-00014810: 2020 2020 6173 796e 6320 6465 6620 7374 async def st\n-00014820: 6172 7428 7365 6c66 2c20 696e 6974 5f68 art(self, init_h\n-00014830: 6f73 743a 204f 7074 696f 6e61 6c5b 7374 ost: Optional[st\n-00014840: 725d 203d 204e 6f6e 652c 202a 2a6b 7761 r] = None, **kwa\n-00014850: 7267 733a 204a 736f 6e56 616c 7565 2920 rgs: JsonValue) \n-00014860: 2d3e 204a 736f 6e4f 626a 6563 743a 0a20 -> JsonObject:. \n-00014870: 2020 2020 2020 2022 2222 5265 7175 6573 \"\"\"Reques\n-00014880: 7420 7468 6174 2074 6865 2050 6565 7220 t that the Peer \n-00014890: 6973 2073 7461 7274 6564 2061 6e64 2063 is started and c\n-000148a0: 6f6e 6e65 6374 6564 2074 6f20 7468 6520 onnected to the \n-000148b0: 726f 7574 6572 2e0a 0a20 2020 2020 2020 router... \n-000148c0: 2043 7265 6174 6573 2074 6865 2074 7261 Creates the tra\n-000148d0: 6e73 706f 7274 2c20 636f 6e6e 6563 7473 nsport, connects\n-000148e0: 2069 7420 746f 2074 6865 2070 726f 746f it to the proto\n-000148f0: 636f 6c2c 2061 6e64 2070 6172 7469 6369 col, and partici\n-00014900: 7061 7465 7320 696e 0a20 2020 2020 2020 pates in. \n-00014910: 2065 7863 6861 6e67 696e 6720 6f66 2069 exchanging of i\n-00014920: 6e69 7420 6d65 7373 6167 6573 2e20 2049 nit messages. I\n-00014930: 6620 616e 7974 6869 6e67 2067 6f65 7320 f anything goes \n-00014940: 7772 6f6e 672c 2074 6865 2063 6f6e 6e65 wrong, the conne\n-00014950: 6374 696f 6e0a 2020 2020 2020 2020 7769 ction. wi\n-00014960: 6c6c 2062 6520 636c 6f73 6564 2061 6e64 ll be closed and\n-00014970: 2061 6e20 6578 6365 7074 696f 6e20 7769 an exception wi\n-00014980: 6c6c 2062 6520 7261 6973 6564 2e0a 0a20 ll be raised... \n-00014990: 2020 2020 2020 2054 6865 2050 6565 7220 The Peer \n-000149a0: 7374 6172 7473 206f 7574 2069 6e20 6120 starts out in a \n-000149b0: 6672 6f7a 656e 2073 7461 7465 2028 6965 frozen state (ie\n-000149c0: 3a20 6174 7465 6d70 7473 2074 6f20 7365 : attempts to se\n-000149d0: 6e64 206d 6573 7361 6765 7320 746f 0a20 nd messages to. \n-000149e0: 2020 2020 2020 2069 7420 7769 6c6c 2069 it will i\n-000149f0: 6e69 7469 616c 6c79 2062 6520 7175 6575 nitially be queu\n-00014a00: 6564 292e 2049 6620 696e 6974 5f68 6f73 ed). If init_hos\n-00014a10: 7420 6973 206e 6f74 204e 6f6e 6520 7468 t is not None th\n-00014a20: 656e 2061 6e20 696e 6974 0a20 2020 2020 en an init. \n-00014a30: 2020 206d 6573 7361 6765 2069 7320 7365 message is se\n-00014a40: 6e74 2077 6974 6820 7468 6520 6769 7665 nt with the give\n-00014a50: 6e20 2768 6f73 7427 2066 6965 6c64 2c20 n 'host' field, \n-00014a60: 706c 7573 2061 6e79 2065 7874 7261 206b plus any extra k\n-00014a70: 7761 7267 732c 2061 6e64 0a20 2020 2020 wargs, and. \n-00014a80: 2020 2074 6865 2071 7565 7565 2069 7320 the queue is \n-00014a90: 7468 6177 6564 2e20 4f74 6865 7277 6973 thawed. Otherwis\n-00014aa0: 652c 2074 6865 2063 616c 6c65 7220 6973 e, the caller is\n-00014ab0: 2072 6573 706f 6e73 6962 6c65 2066 6f72 responsible for\n-00014ac0: 2073 656e 6469 6e67 0a20 2020 2020 2020 sending. \n-00014ad0: 2074 6865 2069 6e69 7420 6d65 7373 6167 the init messag\n-00014ae0: 6520 616e 6420 7468 6177 696e 6720 7468 e and thawing th\n-00014af0: 6520 7065 6572 2e0a 0a20 2020 2020 2020 e peer... \n-00014b00: 2049 6e20 616e 7920 6361 7365 2c20 7468 In any case, th\n-00014b10: 6520 7265 7475 726e 2076 616c 7565 2069 e return value i\n-00014b20: 7320 7468 6520 696e 6974 206d 6573 7361 s the init messa\n-00014b30: 6765 2066 726f 6d20 7468 6520 7065 6572 ge from the peer\n-00014b40: 2e0a 2020 2020 2020 2020 2222 220a 2020 .. \"\"\". \n-00014b50: 2020 2020 2020 6173 7365 7274 2073 656c assert sel\n-00014b60: 662e 696e 6974 5f66 7574 7572 6520 6973 f.init_future is\n-00014b70: 206e 6f74 204e 6f6e 650a 0a20 2020 2020 not None.. \n-00014b80: 2020 2064 6566 205f 636f 6e6e 6563 745f def _connect_\n-00014b90: 7461 736b 5f64 6f6e 6528 7461 736b 3a20 task_done(task: \n-00014ba0: 6173 796e 6369 6f2e 5461 736b 2920 2d3e asyncio.Task) ->\n-00014bb0: 204e 6f6e 653a 0a20 2020 2020 2020 2020 None:. \n-00014bc0: 2020 2061 7373 6572 7420 7461 736b 2069 assert task i\n-00014bd0: 7320 636f 6e6e 6563 745f 7461 736b 0a20 s connect_task. \n-00014be0: 2020 2020 2020 2020 2020 2074 7279 3a0a try:.\n-00014bf0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00014c00: 7461 736b 2e72 6573 756c 7428 290a 2020 task.result(). \n-00014c10: 2020 2020 2020 2020 2020 6578 6365 7074 except\n-00014c20: 2061 7379 6e63 696f 2e43 616e 6365 6c6c asyncio.Cancell\n-00014c30: 6564 4572 726f 723a 2020 2320 7765 2064 edError: # we d\n-00014c40: 6964 2074 6861 7420 2862 656c 6f77 290a id that (below).\n-00014c50: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00014c60: 7061 7373 2020 2020 2020 2020 2020 2020 pass \n-00014c70: 2020 2020 2020 2020 2020 2020 2320 7765 # we\n-00014c80: 2077 616e 7420 746f 2069 676e 6f72 6520 want to ignore \n-00014c90: 6974 0a20 2020 2020 2020 2020 2020 2065 it. e\n-00014ca0: 7863 6570 7420 4578 6365 7074 696f 6e20 xcept Exception \n-00014cb0: 6173 2065 7863 3a0a 2020 2020 2020 2020 as exc:. \n-00014cc0: 2020 2020 2020 2020 7365 6c66 2e63 6c6f self.clo\n-00014cd0: 7365 2865 7863 290a 0a20 2020 2020 2020 se(exc).. \n-00014ce0: 2063 6f6e 6e65 6374 5f74 6173 6b20 3d20 connect_task = \n-00014cf0: 6173 796e 6369 6f2e 6372 6561 7465 5f74 asyncio.create_t\n-00014d00: 6173 6b28 7365 6c66 2e64 6f5f 636f 6e6e ask(self.do_conn\n-00014d10: 6563 745f 7472 616e 7370 6f72 7428 2929 ect_transport())\n-00014d20: 0a20 2020 2020 2020 2063 6f6e 6e65 6374 . connect\n-00014d30: 5f74 6173 6b2e 6164 645f 646f 6e65 5f63 _task.add_done_c\n-00014d40: 616c 6c62 6163 6b28 5f63 6f6e 6e65 6374 allback(_connect\n-00014d50: 5f74 6173 6b5f 646f 6e65 290a 0a20 2020 _task_done).. \n-00014d60: 2020 2020 2074 7279 3a0a 2020 2020 2020 try:. \n-00014d70: 2020 2020 2020 2320 5761 6974 2066 6f72 # Wait for\n-00014d80: 2073 6f6d 6574 6869 6e67 2074 6f20 6861 something to ha\n-00014d90: 7070 656e 3a0a 2020 2020 2020 2020 2020 ppen:. \n-00014da0: 2020 2320 2020 2d20 6578 6365 7074 696f # - exceptio\n-00014db0: 6e20 6672 6f6d 206f 7572 2063 6f6e 6e65 n from our conne\n-00014dc0: 6374 696f 6e20 6675 6e63 7469 6f6e 0a20 ction function. \n-00014dd0: 2020 2020 2020 2020 2020 2023 2020 202d # -\n-00014de0: 2072 6563 6569 7669 6e67 2022 696e 6974 receiving \"init\n-00014df0: 2220 6672 6f6d 2074 6865 206f 7468 6572 \" from the other\n-00014e00: 2073 6964 650a 2020 2020 2020 2020 2020 side. \n-00014e10: 2020 2320 2020 2d20 7265 6365 6976 696e # - receivin\n-00014e20: 6720 454f 4620 6672 6f6d 2074 6865 206f g EOF from the o\n-00014e30: 7468 6572 2073 6964 650a 2020 2020 2020 ther side. \n-00014e40: 2020 2020 2020 2320 2020 2d20 2e63 6c6f # - .clo\n-00014e50: 7365 2829 2077 6173 2063 616c 6c65 640a se() was called.\n-00014e60: 2020 2020 2020 2020 2020 2020 2320 2020 # \n-00014e70: 2d20 6f74 6865 7220 7472 616e 7370 6f72 - other transpor\n-00014e80: 7420 6578 6365 7074 696f 6e0a 2020 2020 t exception. \n-00014e90: 2020 2020 2020 2020 696e 6974 5f6d 6573 init_mes\n-00014ea0: 7361 6765 203d 2061 7761 6974 2073 656c sage = await sel\n-00014eb0: 662e 696e 6974 5f66 7574 7572 650a 0a20 f.init_future.. \n-00014ec0: 2020 2020 2020 2065 7863 6570 7420 2850 except (P\n-00014ed0: 6565 7245 7869 7465 642c 2042 726f 6b65 eerExited, Broke\n-00014ee0: 6e50 6970 6545 7272 6f72 293a 0a20 2020 nPipeError):. \n-00014ef0: 2020 2020 2020 2020 2023 2054 6865 7365 # These\n-00014f00: 2061 7265 2066 6169 726c 7920 6765 6e65 are fairly gene\n-00014f10: 7269 6320 6572 726f 7273 2e20 5065 6572 ric errors. Peer\n-00014f20: 4578 6974 6564 206d 6561 6e73 2074 6861 Exited means tha\n-00014f30: 7420 7765 206f 6273 6572 7665 6420 7468 t we observed th\n-00014f40: 6520 7072 6f63 6573 7320 6578 6974 696e e process exitin\n-00014f50: 672e 0a20 2020 2020 2020 2020 2020 2023 g.. #\n-00014f60: 2042 726f 6b65 6e50 6970 6545 7272 6f72 BrokenPipeError\n-00014f70: 206d 6561 6e73 2074 6861 7420 7765 2067 means that we g\n-00014f80: 6f74 2045 5049 5045 2077 6865 6e20 6174 ot EPIPE when at\n-00014f90: 7465 6d70 7469 6e67 2074 6f20 7772 6974 tempting to writ\n-00014fa0: 6528 2920 746f 2069 742e 2049 6e20 626f e() to it. In bo\n-00014fb0: 7468 2063 6173 6573 2c0a 2020 2020 2020 th cases,. \n-00014fc0: 2020 2020 2020 2320 7468 6520 7072 6f63 # the proc\n-00014fd0: 6573 7320 6973 2067 6f6e 652c 2062 7574 ess is gone, but\n-00014fe0: 2069 7427 7320 6e6f 7420 636c 6561 7220 it's not clear \n-00014ff0: 7768 792e 2049 6620 7468 6520 636f 6e6e why. If the conn\n-00015000: 6563 7469 6f6e 2070 726f 6365 7373 2069 ection process i\n-00015010: 7320 7374 696c 6c20 7275 6e6e 696e 672c s still running,\n-00015020: 0a20 2020 2020 2020 2020 2020 2023 2070 . # p\n-00015030: 6572 6861 7073 2077 6527 6420 6765 7420 erhaps we'd get \n-00015040: 6120 6265 7474 6572 2065 7272 6f72 206d a better error m\n-00015050: 6573 7361 6765 2066 726f 6d20 6974 2e0a essage from it..\n-00015060: 2020 2020 2020 2020 2020 2020 6177 6169 awai\n-00015070: 7420 636f 6e6e 6563 745f 7461 736b 0a20 t connect_task. \n-00015080: 2020 2020 2020 2020 2020 2023 204f 7468 # Oth\n-00015090: 6572 7769 7365 2c20 7265 2d72 6169 7365 erwise, re-raise\n-000150a0: 0a20 2020 2020 2020 2020 2020 2072 6169 . rai\n-000150b0: 7365 0a0a 2020 2020 2020 2020 6669 6e61 se.. fina\n-000150c0: 6c6c 793a 0a20 2020 2020 2020 2020 2020 lly:. \n-000150d0: 2073 656c 662e 696e 6974 5f66 7574 7572 self.init_futur\n-000150e0: 6520 3d20 4e6f 6e65 0a0a 2020 2020 2020 e = None.. \n-000150f0: 2020 2020 2020 2320 496e 2061 6e79 2063 # In any c\n-00015100: 6173 6520 2866 6169 6c75 7265 206f 7220 ase (failure or \n-00015110: 7375 6363 6573 7329 206d 616b 6520 7375 success) make su\n-00015120: 7265 2074 6869 7320 6973 2064 6f6e 652e re this is done.\n-00015130: 0a20 2020 2020 2020 2020 2020 2069 6620 . if \n-00015140: 6e6f 7420 636f 6e6e 6563 745f 7461 736b not connect_task\n-00015150: 2e64 6f6e 6528 293a 0a20 2020 2020 2020 .done():. \n-00015160: 2020 2020 2020 2020 2063 6f6e 6e65 6374 connect\n-00015170: 5f74 6173 6b2e 6361 6e63 656c 2829 0a0a _task.cancel()..\n-00015180: 2020 2020 2020 2020 6966 2069 6e69 745f if init_\n-00015190: 686f 7374 2069 7320 6e6f 7420 4e6f 6e65 host is not None\n-000151a0: 3a0a 2020 2020 2020 2020 2020 2020 6c6f :. lo\n-000151b0: 6767 6572 2e64 6562 7567 2827 2020 7365 gger.debug(' se\n-000151c0: 6e64 696e 6720 696e 6974 206d 6573 7361 nding init messa\n-000151d0: 6765 2062 6163 6b2c 2068 6f73 7420 2573 ge back, host %s\n-000151e0: 272c 2069 6e69 745f 686f 7374 290a 2020 ', init_host). \n-000151f0: 2020 2020 2020 2020 2020 2320 5365 6e64 # Send\n-00015200: 2022 696e 6974 2220 6261 636b 0a20 2020 \"init\" back. \n-00015210: 2020 2020 2020 2020 2073 656c 662e 7772 self.wr\n-00015220: 6974 655f 636f 6e74 726f 6c28 4e6f 6e65 ite_control(None\n-00015230: 2c20 636f 6d6d 616e 643d 2769 6e69 7427 , command='init'\n-00015240: 2c20 7665 7273 696f 6e3d 312c 2068 6f73 , version=1, hos\n-00015250: 743d 696e 6974 5f68 6f73 742c 202a 2a6b t=init_host, **k\n-00015260: 7761 7267 7329 0a0a 2020 2020 2020 2020 wargs).. \n-00015270: 2020 2020 2320 5468 6177 2074 6865 2071 # Thaw the q\n-00015280: 7565 7565 6420 6d65 7373 6167 6573 0a20 ueued messages. \n-00015290: 2020 2020 2020 2020 2020 2073 656c 662e self.\n-000152a0: 7468 6177 5f65 6e64 706f 696e 7428 290a thaw_endpoint().\n-000152b0: 0a20 2020 2020 2020 2072 6574 7572 6e20 . return \n-000152c0: 696e 6974 5f6d 6573 7361 6765 0a0a 2020 init_message.. \n-000152d0: 2020 2320 4261 636b 6772 6f75 6e64 2069 # Background i\n-000152e0: 6e69 7469 616c 697a 6174 696f 6e0a 2020 nitialization. \n-000152f0: 2020 6465 6620 7374 6172 745f 696e 5f62 def start_in_b\n-00015300: 6163 6b67 726f 756e 6428 7365 6c66 2c20 ackground(self, \n-00015310: 696e 6974 5f68 6f73 743a 204f 7074 696f init_host: Optio\n-00015320: 6e61 6c5b 7374 725d 203d 204e 6f6e 652c nal[str] = None,\n-00015330: 202a 2a6b 7761 7267 733a 204a 736f 6e56 **kwargs: JsonV\n-00015340: 616c 7565 2920 2d3e 204e 6f6e 653a 0a20 alue) -> None:. \n-00015350: 2020 2020 2020 2064 6566 205f 7374 6172 def _star\n-00015360: 745f 7461 736b 5f64 6f6e 6528 7461 736b t_task_done(task\n-00015370: 3a20 6173 796e 6369 6f2e 5461 736b 2920 : asyncio.Task) \n-00015380: 2d3e 204e 6f6e 653a 0a20 2020 2020 2020 -> None:. \n-00015390: 2020 2020 2061 7373 6572 7420 7461 736b assert task\n-000153a0: 2069 7320 7374 6172 745f 7461 736b 0a0a is start_task..\n-000153b0: 2020 2020 2020 2020 2020 2020 7472 793a try:\n-000153c0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-000153d0: 2074 6173 6b2e 7265 7375 6c74 2829 0a20 task.result(). \n-000153e0: 2020 2020 2020 2020 2020 2065 7863 6570 excep\n-000153f0: 7420 284f 5345 7272 6f72 2c20 5065 6572 t (OSError, Peer\n-00015400: 4578 6974 6564 2c20 436f 636b 7069 7450 Exited, CockpitP\n-00015410: 726f 626c 656d 2c20 6173 796e 6369 6f2e roblem, asyncio.\n-00015420: 4361 6e63 656c 6c65 6445 7272 6f72 293a CancelledError):\n-00015430: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-00015440: 2070 6173 7320 2023 2054 686f 7365 2061 pass # Those a\n-00015450: 7265 2065 7870 6563 7465 642e 2020 4f74 re expected. Ot\n-00015460: 6865 7273 2077 696c 6c20 7468 726f 772e hers will throw.\n-00015470: 0a0a 2020 2020 2020 2020 7374 6172 745f .. start_\n-00015480: 7461 736b 203d 2061 7379 6e63 696f 2e63 task = asyncio.c\n-00015490: 7265 6174 655f 7461 736b 2873 656c 662e reate_task(self.\n-000154a0: 7374 6172 7428 696e 6974 5f68 6f73 742c start(init_host,\n-000154b0: 202a 2a6b 7761 7267 7329 290a 2020 2020 **kwargs)). \n-000154c0: 2020 2020 7374 6172 745f 7461 736b 2e61 start_task.a\n-000154d0: 6464 5f64 6f6e 655f 6361 6c6c 6261 636b dd_done_callback\n-000154e0: 285f 7374 6172 745f 7461 736b 5f64 6f6e (_start_task_don\n-000154f0: 6529 0a0a 2020 2020 2320 5368 7574 646f e).. # Shutdo\n-00015500: 776e 0a20 2020 2064 6566 2061 6464 5f64 wn. def add_d\n-00015510: 6f6e 655f 6361 6c6c 6261 636b 2873 656c one_callback(sel\n-00015520: 662c 2063 616c 6c62 6163 6b3a 2043 616c f, callback: Cal\n-00015530: 6c61 626c 655b 5b5d 2c20 4e6f 6e65 5d29 lable[[], None])\n-00015540: 202d 3e20 4e6f 6e65 3a0a 2020 2020 2020 -> None:. \n-00015550: 2020 7365 6c66 2e64 6f6e 655f 6361 6c6c self.done_call\n-00015560: 6261 636b 732e 6170 7065 6e64 2863 616c backs.append(cal\n-00015570: 6c62 6163 6b29 0a0a 2020 2020 2320 4861 lback).. # Ha\n-00015580: 6e64 6c69 6e67 206f 6620 696e 7465 7265 ndling of intere\n-00015590: 7374 696e 6720 6576 656e 7473 0a20 2020 sting events. \n-000155a0: 2064 6566 2064 6f5f 7375 7065 7275 7365 def do_superuse\n-000155b0: 725f 696e 6974 5f64 6f6e 6528 7365 6c66 r_init_done(self\n-000155c0: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n-000155d0: 2020 2070 6173 730a 0a20 2020 2064 6566 pass.. def\n-000155e0: 2064 6f5f 6175 7468 6f72 697a 6528 7365 do_authorize(se\n-000155f0: 6c66 2c20 6d65 7373 6167 653a 204a 736f lf, message: Jso\n-00015600: 6e4f 626a 6563 7429 202d 3e20 4e6f 6e65 nObject) -> None\n-00015610: 3a0a 2020 2020 2020 2020 7061 7373 0a0a :. pass..\n-00015620: 2020 2020 6465 6620 7472 616e 7370 6f72 def transpor\n-00015630: 745f 636f 6e74 726f 6c5f 7265 6365 6976 t_control_receiv\n-00015640: 6564 2873 656c 662c 2063 6f6d 6d61 6e64 ed(self, command\n-00015650: 3a20 7374 722c 206d 6573 7361 6765 3a20 : str, message: \n-00015660: 4a73 6f6e 4f62 6a65 6374 2920 2d3e 204e JsonObject) -> N\n-00015670: 6f6e 653a 0a20 2020 2020 2020 2069 6620 one:. if \n-00015680: 636f 6d6d 616e 6420 3d3d 2027 696e 6974 command == 'init\n-00015690: 2720 616e 6420 7365 6c66 2e69 6e69 745f ' and self.init_\n-000156a0: 6675 7475 7265 2069 7320 6e6f 7420 4e6f future is not No\n-000156b0: 6e65 3a0a 2020 2020 2020 2020 2020 2020 ne:. \n-000156c0: 6c6f 6767 6572 2e64 6562 7567 2827 476f logger.debug('Go\n-000156d0: 7420 696e 6974 206d 6573 7361 6765 2077 t init message w\n-000156e0: 6974 6820 6163 7469 7665 2069 6e69 745f ith active init_\n-000156f0: 6675 7475 7265 2e20 2053 6574 7469 6e67 future. Setting\n-00015700: 2072 6573 756c 742e 2729 0a20 2020 2020 result.'). \n-00015710: 2020 2020 2020 2073 656c 662e 696e 6974 self.init\n-00015720: 5f66 7574 7572 652e 7365 745f 7265 7375 _future.set_resu\n-00015730: 6c74 286d 6573 7361 6765 290a 2020 2020 lt(message). \n-00015740: 2020 2020 656c 6966 2063 6f6d 6d61 6e64 elif command\n-00015750: 203d 3d20 2761 7574 686f 7269 7a65 273a == 'authorize':\n-00015760: 0a20 2020 2020 2020 2020 2020 2073 656c . sel\n-00015770: 662e 646f 5f61 7574 686f 7269 7a65 286d f.do_authorize(m\n-00015780: 6573 7361 6765 290a 2020 2020 2020 2020 essage). \n-00015790: 656c 6966 2063 6f6d 6d61 6e64 203d 3d20 elif command == \n-000157a0: 2773 7570 6572 7573 6572 2d69 6e69 742d 'superuser-init-\n-000157b0: 646f 6e65 273a 0a20 2020 2020 2020 2020 done':. \n-000157c0: 2020 2073 656c 662e 646f 5f73 7570 6572 self.do_super\n-000157d0: 7573 6572 5f69 6e69 745f 646f 6e65 2829 user_init_done()\n-000157e0: 0a20 2020 2020 2020 2065 6c73 653a 0a20 . else:. \n-000157f0: 2020 2020 2020 2020 2020 2072 6169 7365 raise\n-00015800: 2043 6f63 6b70 6974 5072 6f74 6f63 6f6c CockpitProtocol\n-00015810: 4572 726f 7228 6627 5265 6365 6976 6564 Error(f'Received\n-00015820: 2075 6e65 7870 6563 7465 6420 636f 6e74 unexpected cont\n-00015830: 726f 6c20 6d65 7373 6167 6520 7b63 6f6d rol message {com\n-00015840: 6d61 6e64 7d27 290a 0a20 2020 2064 6566 mand}').. def\n-00015850: 2065 6f66 5f72 6563 6569 7665 6428 7365 eof_received(se\n-00015860: 6c66 2920 2d3e 2062 6f6f 6c3a 0a20 2020 lf) -> bool:. \n-00015870: 2020 2020 2023 2057 6520 616c 7761 7973 # We always\n-00015880: 2065 7870 6563 7420 746f 2062 6520 7468 expect to be th\n-00015890: 6520 6f6e 6573 2074 6f20 636c 6f73 6520 e ones to close \n-000158a0: 7468 6520 636f 6e6e 6563 7469 6f6e 2c20 the connection, \n-000158b0: 736f 2069 6620 7765 2067 6574 0a20 2020 so if we get. \n-000158c0: 2020 2020 2023 2061 6e20 454f 462c 2074 # an EOF, t\n-000158d0: 6865 6e20 7765 2063 6f6e 7369 6465 7220 hen we consider \n-000158e0: 6974 2074 6f20 6265 2061 6e20 6572 726f it to be an erro\n-000158f0: 722e 2020 5468 6973 2061 6c6c 6f77 7320 r. This allows \n-00015900: 7573 2074 6f0a 2020 2020 2020 2020 2320 us to. # \n-00015910: 6469 7374 696e 6775 6973 6820 636c 6f73 distinguish clos\n-00015920: 6520 6361 7573 6564 2062 7920 756e 6578 e caused by unex\n-00015930: 7065 6374 6564 2045 4f46 2028 6275 7420 pected EOF (but \n-00015940: 6e6f 2065 7272 6e6f 2066 726f 6d20 610a no errno from a.\n-00015950: 2020 2020 2020 2020 2320 7379 7363 616c # syscal\n-00015960: 6c20 6661 696c 7572 6529 2076 732e 2063 l failure) vs. c\n-00015970: 6c6f 7365 2063 6175 7365 6420 6279 2063 lose caused by c\n-00015980: 616c 6c69 6e67 202e 636c 6f73 6528 2920 alling .close() \n-00015990: 6f6e 206f 7572 2073 6964 652e 0a20 2020 on our side.. \n-000159a0: 2020 2020 2023 2054 6865 2070 726f 6365 # The proce\n-000159b0: 7373 2069 7320 7374 696c 6c20 7275 6e6e ss is still runn\n-000159c0: 696e 6720 6174 2074 6869 7320 706f 696e ing at this poin\n-000159d0: 742c 2073 6f20 6b65 6570 2069 7420 616e t, so keep it an\n-000159e0: 6420 6861 6e64 6c65 0a20 2020 2020 2020 d handle. \n-000159f0: 2023 2074 6865 2065 7272 6f72 2069 6e20 # the error in \n-00015a00: 7072 6f63 6573 735f 6578 6974 6564 2829 process_exited()\n-00015a10: 2e0a 2020 2020 2020 2020 6c6f 6767 6572 .. logger\n-00015a20: 2e64 6562 7567 2827 5065 6572 2025 7320 .debug('Peer %s \n-00015a30: 7265 6365 6976 6564 2075 6e65 7870 6563 received unexpec\n-00015a40: 7465 6420 454f 4627 2c20 7365 6c66 2e5f ted EOF', self._\n-00015a50: 5f63 6c61 7373 5f5f 2e5f 5f6e 616d 655f _class__.__name_\n-00015a60: 5f29 0a20 2020 2020 2020 2072 6574 7572 _). retur\n-00015a70: 6e20 5472 7565 0a0a 2020 2020 6465 6620 n True.. def \n-00015a80: 646f 5f63 6c6f 7365 6428 7365 6c66 2c20 do_closed(self, \n-00015a90: 6578 633a 204f 7074 696f 6e61 6c5b 4578 exc: Optional[Ex\n-00015aa0: 6365 7074 696f 6e5d 2920 2d3e 204e 6f6e ception]) -> Non\n-00015ab0: 653a 0a20 2020 2020 2020 206c 6f67 6765 e:. logge\n-00015ac0: 722e 6465 6275 6728 2750 6565 7220 2573 r.debug('Peer %s\n-00015ad0: 2063 6f6e 6e65 6374 696f 6e20 6c6f 7374 connection lost\n-00015ae0: 2025 7320 2573 272c 2073 656c 662e 5f5f %s %s', self.__\n-00015af0: 636c 6173 735f 5f2e 5f5f 6e61 6d65 5f5f class__.__name__\n-00015b00: 2c20 7479 7065 2865 7863 292c 2065 7863 , type(exc), exc\n-00015b10: 290a 0a20 2020 2020 2020 2069 6620 6578 ).. if ex\n-00015b20: 6320 6973 204e 6f6e 653a 0a20 2020 2020 c is None:. \n-00015b30: 2020 2020 2020 2073 656c 662e 7368 7574 self.shut\n-00015b40: 646f 776e 5f65 6e64 706f 696e 7428 7072 down_endpoint(pr\n-00015b50: 6f62 6c65 6d3d 2774 6572 6d69 6e61 7465 oblem='terminate\n-00015b60: 6427 290a 2020 2020 2020 2020 656c 6966 d'). elif\n-00015b70: 2069 7369 6e73 7461 6e63 6528 6578 632c isinstance(exc,\n-00015b80: 2050 6565 7245 7869 7465 6429 3a0a 2020 PeerExited):. \n-00015b90: 2020 2020 2020 2020 2020 2320 6120 636f # a co\n-00015ba0: 6d6d 6f6e 2063 6173 6520 6973 2074 6861 mmon case is tha\n-00015bb0: 7420 7468 6520 6361 6c6c 6564 2070 6565 t the called pee\n-00015bc0: 7220 646f 6573 206e 6f74 2065 7869 7374 r does not exist\n-00015bd0: 0a20 2020 2020 2020 2020 2020 2069 6620 . if \n-00015be0: 6578 632e 6578 6974 5f63 6f64 6520 3d3d exc.exit_code ==\n-00015bf0: 2031 3237 3a0a 2020 2020 2020 2020 2020 127:. \n-00015c00: 2020 2020 2020 7365 6c66 2e73 6875 7464 self.shutd\n-00015c10: 6f77 6e5f 656e 6470 6f69 6e74 2870 726f own_endpoint(pro\n-00015c20: 626c 656d 3d27 6e6f 2d63 6f63 6b70 6974 blem='no-cockpit\n-00015c30: 2729 0a20 2020 2020 2020 2020 2020 2065 '). e\n-00015c40: 6c73 653a 0a20 2020 2020 2020 2020 2020 lse:. \n-00015c50: 2020 2020 2073 656c 662e 7368 7574 646f self.shutdo\n-00015c60: 776e 5f65 6e64 706f 696e 7428 7072 6f62 wn_endpoint(prob\n-00015c70: 6c65 6d3d 2774 6572 6d69 6e61 7465 6427 lem='terminated'\n-00015c80: 2c20 6d65 7373 6167 653d 6627 5065 6572 , message=f'Peer\n-00015c90: 2065 7869 7465 6420 7769 7468 2073 7461 exited with sta\n-00015ca0: 7475 7320 7b65 7863 2e65 7869 745f 636f tus {exc.exit_co\n-00015cb0: 6465 7d27 290a 2020 2020 2020 2020 656c de}'). el\n-00015cc0: 6966 2069 7369 6e73 7461 6e63 6528 6578 if isinstance(ex\n-00015cd0: 632c 2043 6f63 6b70 6974 5072 6f62 6c65 c, CockpitProble\n-00015ce0: 6d29 3a0a 2020 2020 2020 2020 2020 2020 m):. \n-00015cf0: 7365 6c66 2e73 6875 7464 6f77 6e5f 656e self.shutdown_en\n-00015d00: 6470 6f69 6e74 2865 7863 2e61 7474 7273 dpoint(exc.attrs\n-00015d10: 290a 2020 2020 2020 2020 656c 7365 3a0a ). else:.\n-00015d20: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n-00015d30: 2e73 6875 7464 6f77 6e5f 656e 6470 6f69 .shutdown_endpoi\n-00015d40: 6e74 2870 726f 626c 656d 3d27 696e 7465 nt(problem='inte\n-00015d50: 726e 616c 2d65 7272 6f72 272c 0a20 2020 rnal-error',. \n-00015d60: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00015d70: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00015d80: 6d65 7373 6167 653d 6622 5b7b 6578 632e message=f\"[{exc.\n-00015d90: 5f5f 636c 6173 735f 5f2e 5f5f 6e61 6d65 __class__.__name\n-00015da0: 5f5f 7d5d 207b 6578 6321 737d 2229 0a0a __}] {exc!s}\")..\n-00015db0: 2020 2020 2020 2020 2320 4966 202e 7374 # If .st\n-00015dc0: 6172 7428 2920 6973 2072 756e 6e69 6e67 art() is running\n-00015dd0: 2c20 7765 206e 6565 6420 746f 206d 616b , we need to mak\n-00015de0: 6520 7375 7265 2069 7420 7374 6f70 7320 e sure it stops \n-00015df0: 7275 6e6e 696e 672c 0a20 2020 2020 2020 running,. \n-00015e00: 2023 2072 6169 7369 6e67 2074 6865 2063 # raising the c\n-00015e10: 6f72 7265 6374 2065 7863 6570 7469 6f6e orrect exception\n-00015e20: 2e0a 2020 2020 2020 2020 6966 2073 656c .. if sel\n-00015e30: 662e 696e 6974 5f66 7574 7572 6520 6973 f.init_future is\n-00015e40: 206e 6f74 204e 6f6e 6520 616e 6420 6e6f not None and no\n-00015e50: 7420 7365 6c66 2e69 6e69 745f 6675 7475 t self.init_futu\n-00015e60: 7265 2e64 6f6e 6528 293a 0a20 2020 2020 re.done():. \n-00015e70: 2020 2020 2020 2069 6620 6578 6320 6973 if exc is\n-00015e80: 206e 6f74 204e 6f6e 653a 0a20 2020 2020 not None:. \n-00015e90: 2020 2020 2020 2020 2020 2073 656c 662e self.\n-00015ea0: 696e 6974 5f66 7574 7572 652e 7365 745f init_future.set_\n-00015eb0: 6578 6365 7074 696f 6e28 6578 6329 0a20 exception(exc). \n-00015ec0: 2020 2020 2020 2020 2020 2065 6c73 653a else:\n-00015ed0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-00015ee0: 2073 656c 662e 696e 6974 5f66 7574 7572 self.init_futur\n-00015ef0: 652e 6361 6e63 656c 2829 0a0a 2020 2020 e.cancel().. \n-00015f00: 2020 2020 666f 7220 6361 6c6c 6261 636b for callback\n-00015f10: 2069 6e20 7365 6c66 2e64 6f6e 655f 6361 in self.done_ca\n-00015f20: 6c6c 6261 636b 733a 0a20 2020 2020 2020 llbacks:. \n-00015f30: 2020 2020 2063 616c 6c62 6163 6b28 290a callback().\n-00015f40: 0a20 2020 2064 6566 2070 726f 6365 7373 . def process\n-00015f50: 5f65 7869 7465 6428 7365 6c66 2920 2d3e _exited(self) ->\n-00015f60: 204e 6f6e 653a 0a20 2020 2020 2020 2061 None:. a\n-00015f70: 7373 6572 7420 6973 696e 7374 616e 6365 ssert isinstance\n-00015f80: 2873 656c 662e 7472 616e 7370 6f72 742c (self.transport,\n-00015f90: 2053 7562 7072 6f63 6573 7354 7261 6e73 SubprocessTrans\n-00015fa0: 706f 7274 290a 2020 2020 2020 2020 6c6f port). lo\n-00015fb0: 6767 6572 2e64 6562 7567 2827 5065 6572 gger.debug('Peer\n-00015fc0: 2025 7320 6578 6974 6564 2c20 7374 6174 %s exited, stat\n-00015fd0: 7573 2025 6427 2c20 7365 6c66 2e5f 5f63 us %d', self.__c\n-00015fe0: 6c61 7373 5f5f 2e5f 5f6e 616d 655f 5f2c lass__.__name__,\n-00015ff0: 2073 656c 662e 7472 616e 7370 6f72 742e self.transport.\n-00016000: 6765 745f 7265 7475 726e 636f 6465 2829 get_returncode()\n-00016010: 290a 2020 2020 2020 2020 7265 7475 726e ). return\n-00016020: 636f 6465 203d 2073 656c 662e 7472 616e code = self.tran\n-00016030: 7370 6f72 742e 6765 745f 7265 7475 726e sport.get_return\n-00016040: 636f 6465 2829 0a20 2020 2020 2020 2061 code(). a\n-00016050: 7373 6572 7420 6973 696e 7374 616e 6365 ssert isinstance\n-00016060: 2872 6574 7572 6e63 6f64 652c 2069 6e74 (returncode, int\n-00016070: 290a 2020 2020 2020 2020 7365 6c66 2e63 ). self.c\n-00016080: 6c6f 7365 2850 6565 7245 7869 7465 6428 lose(PeerExited(\n-00016090: 7265 7475 726e 636f 6465 2929 0a0a 2020 returncode)).. \n-000160a0: 2020 2320 466f 7277 6172 6469 6e67 2064 # Forwarding d\n-000160b0: 6174 613a 2066 726f 6d20 7468 6520 7065 ata: from the pe\n-000160c0: 6572 2074 6f20 7468 6520 726f 7574 6572 er to the router\n-000160d0: 0a20 2020 2064 6566 2063 6861 6e6e 656c . def channel\n-000160e0: 5f63 6f6e 7472 6f6c 5f72 6563 6569 7665 _control_receive\n-000160f0: 6428 7365 6c66 2c20 6368 616e 6e65 6c3a d(self, channel:\n-00016100: 2073 7472 2c20 636f 6d6d 616e 643a 2073 str, command: s\n-00016110: 7472 2c20 6d65 7373 6167 653a 204a 736f tr, message: Jso\n-00016120: 6e4f 626a 6563 7429 202d 3e20 4e6f 6e65 nObject) -> None\n-00016130: 3a0a 2020 2020 2020 2020 6966 2073 656c :. if sel\n-00016140: 662e 696e 6974 5f66 7574 7572 6520 6973 f.init_future is\n-00016150: 206e 6f74 204e 6f6e 653a 0a20 2020 2020 not None:. \n-00016160: 2020 2020 2020 2072 6169 7365 2043 6f63 raise Coc\n-00016170: 6b70 6974 5072 6f74 6f63 6f6c 4572 726f kpitProtocolErro\n-00016180: 7228 2752 6563 6569 7665 6420 756e 6578 r('Received unex\n-00016190: 7065 6374 6564 2063 6861 6e6e 656c 2063 pected channel c\n-000161a0: 6f6e 7472 6f6c 206d 6573 7361 6765 2062 ontrol message b\n-000161b0: 6566 6f72 6520 696e 6974 2729 0a20 2020 efore init'). \n-000161c0: 2020 2020 2073 656c 662e 7365 6e64 5f63 self.send_c\n-000161d0: 6861 6e6e 656c 5f63 6f6e 7472 6f6c 2863 hannel_control(c\n-000161e0: 6861 6e6e 656c 2c20 636f 6d6d 616e 642c hannel, command,\n-000161f0: 206d 6573 7361 6765 290a 0a20 2020 2064 message).. d\n-00016200: 6566 2063 6861 6e6e 656c 5f64 6174 615f ef channel_data_\n-00016210: 7265 6365 6976 6564 2873 656c 662c 2063 received(self, c\n-00016220: 6861 6e6e 656c 3a20 7374 722c 2064 6174 hannel: str, dat\n-00016230: 613a 2062 7974 6573 2920 2d3e 204e 6f6e a: bytes) -> Non\n-00016240: 653a 0a20 2020 2020 2020 2069 6620 7365 e:. if se\n-00016250: 6c66 2e69 6e69 745f 6675 7475 7265 2069 lf.init_future i\n-00016260: 7320 6e6f 7420 4e6f 6e65 3a0a 2020 2020 s not None:. \n-00016270: 2020 2020 2020 2020 7261 6973 6520 436f raise Co\n-00016280: 636b 7069 7450 726f 746f 636f 6c45 7272 ckpitProtocolErr\n-00016290: 6f72 2827 5265 6365 6976 6564 2075 6e65 or('Received une\n-000162a0: 7870 6563 7465 6420 6368 616e 6e65 6c20 xpected channel \n-000162b0: 6461 7461 2062 6566 6f72 6520 696e 6974 data before init\n-000162c0: 2729 0a20 2020 2020 2020 2073 656c 662e '). self.\n-000162d0: 7365 6e64 5f63 6861 6e6e 656c 5f64 6174 send_channel_dat\n-000162e0: 6128 6368 616e 6e65 6c2c 2064 6174 6129 a(channel, data)\n-000162f0: 0a0a 2020 2020 2320 466f 7277 6172 6469 .. # Forwardi\n-00016300: 6e67 2064 6174 613a 2066 726f 6d20 7468 ng data: from th\n-00016310: 6520 726f 7574 6572 2074 6f20 7468 6520 e router to the \n-00016320: 7065 6572 0a20 2020 2064 6566 2064 6f5f peer. def do_\n-00016330: 6368 616e 6e65 6c5f 636f 6e74 726f 6c28 channel_control(\n-00016340: 7365 6c66 2c20 6368 616e 6e65 6c3a 2073 self, channel: s\n-00016350: 7472 2c20 636f 6d6d 616e 643a 2073 7472 tr, command: str\n-00016360: 2c20 6d65 7373 6167 653a 204a 736f 6e4f , message: JsonO\n-00016370: 626a 6563 7429 202d 3e20 4e6f 6e65 3a0a bject) -> None:.\n-00016380: 2020 2020 2020 2020 6173 7365 7274 2073 assert s\n-00016390: 656c 662e 696e 6974 5f66 7574 7572 6520 elf.init_future \n-000163a0: 6973 204e 6f6e 650a 2020 2020 2020 2020 is None. \n-000163b0: 7365 6c66 2e77 7269 7465 5f63 6f6e 7472 self.write_contr\n-000163c0: 6f6c 286d 6573 7361 6765 290a 0a20 2020 ol(message).. \n-000163d0: 2064 6566 2064 6f5f 6368 616e 6e65 6c5f def do_channel_\n-000163e0: 6461 7461 2873 656c 662c 2063 6861 6e6e data(self, chann\n-000163f0: 656c 3a20 7374 722c 2064 6174 613a 2062 el: str, data: b\n-00016400: 7974 6573 2920 2d3e 204e 6f6e 653a 0a20 ytes) -> None:. \n-00016410: 2020 2020 2020 2061 7373 6572 7420 7365 assert se\n-00016420: 6c66 2e69 6e69 745f 6675 7475 7265 2069 lf.init_future i\n-00016430: 7320 4e6f 6e65 0a20 2020 2020 2020 2073 s None. s\n-00016440: 656c 662e 7772 6974 655f 6368 616e 6e65 elf.write_channe\n-00016450: 6c5f 6461 7461 2863 6861 6e6e 656c 2c20 l_data(channel, \n-00016460: 6461 7461 290a 0a20 2020 2064 6566 2064 data).. def d\n-00016470: 6f5f 6b69 6c6c 2873 656c 662c 2068 6f73 o_kill(self, hos\n-00016480: 743a 2027 7374 7220 7c20 4e6f 6e65 272c t: 'str | None',\n-00016490: 2067 726f 7570 3a20 2773 7472 207c 204e group: 'str | N\n-000164a0: 6f6e 6527 2c20 6d65 7373 6167 653a 204a one', message: J\n-000164b0: 736f 6e4f 626a 6563 7429 202d 3e20 4e6f sonObject) -> No\n-000164c0: 6e65 3a0a 2020 2020 2020 2020 6173 7365 ne:. asse\n-000164d0: 7274 2073 656c 662e 696e 6974 5f66 7574 rt self.init_fut\n-000164e0: 7572 6520 6973 204e 6f6e 650a 2020 2020 ure is None. \n-000164f0: 2020 2020 7365 6c66 2e77 7269 7465 5f63 self.write_c\n-00016500: 6f6e 7472 6f6c 286d 6573 7361 6765 290a ontrol(message).\n-00016510: 0a20 2020 2064 6566 2064 6f5f 636c 6f73 . def do_clos\n-00016520: 6528 7365 6c66 2920 2d3e 204e 6f6e 653a e(self) -> None:\n-00016530: 0a20 2020 2020 2020 2073 656c 662e 636c . self.cl\n-00016540: 6f73 6528 290a 0a0a 636c 6173 7320 436f ose()...class Co\n-00016550: 6e66 6967 7572 6564 5065 6572 2850 6565 nfiguredPeer(Pee\n-00016560: 7229 3a0a 2020 2020 636f 6e66 6967 3a20 r):. config: \n-00016570: 4272 6964 6765 436f 6e66 6967 0a20 2020 BridgeConfig. \n-00016580: 2061 7267 733a 2053 6571 7565 6e63 655b args: Sequence[\n-00016590: 7374 725d 0a20 2020 2065 6e76 3a20 5365 str]. env: Se\n-000165a0: 7175 656e 6365 5b73 7472 5d0a 0a20 2020 quence[str].. \n-000165b0: 2064 6566 205f 5f69 6e69 745f 5f28 7365 def __init__(se\n-000165c0: 6c66 2c20 726f 7574 6572 3a20 526f 7574 lf, router: Rout\n-000165d0: 6572 2c20 636f 6e66 6967 3a20 4272 6964 er, config: Brid\n-000165e0: 6765 436f 6e66 6967 293a 0a20 2020 2020 geConfig):. \n-000165f0: 2020 2073 656c 662e 636f 6e66 6967 203d self.config =\n-00016600: 2063 6f6e 6669 670a 2020 2020 2020 2020 config. \n-00016610: 7365 6c66 2e61 7267 7320 3d20 636f 6e66 self.args = conf\n-00016620: 6967 2e73 7061 776e 0a20 2020 2020 2020 ig.spawn. \n-00016630: 2073 656c 662e 656e 7620 3d20 636f 6e66 self.env = conf\n-00016640: 6967 2e65 6e76 6972 6f6e 0a20 2020 2020 ig.environ. \n-00016650: 2020 2073 7570 6572 2829 2e5f 5f69 6e69 super().__ini\n-00016660: 745f 5f28 726f 7574 6572 290a 0a20 2020 t__(router).. \n-00016670: 2061 7379 6e63 2064 6566 2064 6f5f 636f async def do_co\n-00016680: 6e6e 6563 745f 7472 616e 7370 6f72 7428 nnect_transport(\n-00016690: 7365 6c66 2920 2d3e 204e 6f6e 653a 0a20 self) -> None:. \n-000166a0: 2020 2020 2020 2061 7761 6974 2073 656c await sel\n-000166b0: 662e 7370 6177 6e28 7365 6c66 2e61 7267 f.spawn(self.arg\n-000166c0: 732c 2073 656c 662e 656e 7629 0a0a 0a63 s, self.env)...c\n-000166d0: 6c61 7373 2050 6565 7252 6f75 7469 6e67 lass PeerRouting\n-000166e0: 5275 6c65 2852 6f75 7469 6e67 5275 6c65 Rule(RoutingRule\n-000166f0: 293a 0a20 2020 2063 6f6e 6669 673a 2042 ):. config: B\n-00016700: 7269 6467 6543 6f6e 6669 670a 2020 2020 ridgeConfig. \n-00016710: 6d61 7463 683a 204a 736f 6e4f 626a 6563 match: JsonObjec\n-00016720: 740a 2020 2020 7065 6572 3a20 4f70 7469 t. peer: Opti\n-00016730: 6f6e 616c 5b50 6565 725d 0a0a 2020 2020 onal[Peer].. \n-00016740: 6465 6620 5f5f 696e 6974 5f5f 2873 656c def __init__(sel\n-00016750: 662c 2072 6f75 7465 723a 2052 6f75 7465 f, router: Route\n-00016760: 722c 2063 6f6e 6669 673a 2042 7269 6467 r, config: Bridg\n-00016770: 6543 6f6e 6669 6729 3a0a 2020 2020 2020 eConfig):. \n-00016780: 2020 7375 7065 7228 292e 5f5f 696e 6974 super().__init\n-00016790: 5f5f 2872 6f75 7465 7229 0a20 2020 2020 __(router). \n-000167a0: 2020 2073 656c 662e 636f 6e66 6967 203d self.config =\n-000167b0: 2063 6f6e 6669 670a 2020 2020 2020 2020 config. \n-000167c0: 7365 6c66 2e6d 6174 6368 203d 2063 6f6e self.match = con\n-000167d0: 6669 672e 6d61 7463 680a 2020 2020 2020 fig.match. \n-000167e0: 2020 7365 6c66 2e70 6565 7220 3d20 4e6f self.peer = No\n-000167f0: 6e65 0a0a 2020 2020 6465 6620 6170 706c ne.. def appl\n-00016800: 795f 7275 6c65 2873 656c 662c 206f 7074 y_rule(self, opt\n-00016810: 696f 6e73 3a20 4a73 6f6e 4f62 6a65 6374 ions: JsonObject\n-00016820: 2920 2d3e 204f 7074 696f 6e61 6c5b 5065 ) -> Optional[Pe\n-00016830: 6572 5d3a 0a20 2020 2020 2020 2023 2043 er]:. # C\n-00016840: 6865 636b 2074 6861 7420 7765 206d 6174 heck that we mat\n-00016850: 6368 0a0a 2020 2020 2020 2020 666f 7220 ch.. for \n-00016860: 6b65 792c 2076 616c 7565 2069 6e20 7365 key, value in se\n-00016870: 6c66 2e6d 6174 6368 2e69 7465 6d73 2829 lf.match.items()\n-00016880: 3a0a 2020 2020 2020 2020 2020 2020 6966 :. if\n-00016890: 206b 6579 206e 6f74 2069 6e20 6f70 7469 key not in opti\n-000168a0: 6f6e 733a 0a20 2020 2020 2020 2020 2020 ons:. \n-000168b0: 2020 2020 206c 6f67 6765 722e 6465 6275 logger.debu\n-000168c0: 6728 2720 2020 2020 2020 2072 656a 6563 g(' rejec\n-000168d0: 7469 6e67 2062 6563 6175 7365 206b 6579 ting because key\n-000168e0: 2025 7320 6973 206d 6973 7369 6e67 272c %s is missing',\n-000168f0: 206b 6579 290a 2020 2020 2020 2020 2020 key). \n-00016900: 2020 2020 2020 7265 7475 726e 204e 6f6e return Non\n-00016910: 650a 2020 2020 2020 2020 2020 2020 6966 e. if\n-00016920: 2076 616c 7565 2069 7320 6e6f 7420 4e6f value is not No\n-00016930: 6e65 2061 6e64 206f 7074 696f 6e73 5b6b ne and options[k\n-00016940: 6579 5d20 213d 2076 616c 7565 3a0a 2020 ey] != value:. \n-00016950: 2020 2020 2020 2020 2020 2020 2020 6c6f lo\n-00016960: 6767 6572 2e64 6562 7567 2827 2020 2020 gger.debug(' \n-00016970: 2020 2020 7265 6a65 6374 696e 6720 6265 rejecting be\n-00016980: 6361 7573 6520 6b65 7920 2573 2068 6173 cause key %s has\n-00016990: 2077 726f 6e67 2076 616c 7565 2025 7320 wrong value %s \n-000169a0: 2876 7320 2573 2927 2c20 6b65 792c 206f (vs %s)', key, o\n-000169b0: 7074 696f 6e73 5b6b 6579 5d2c 2076 616c ptions[key], val\n-000169c0: 7565 290a 2020 2020 2020 2020 2020 2020 ue). \n-000169d0: 2020 2020 7265 7475 726e 204e 6f6e 650a return None.\n-000169e0: 0a20 2020 2020 2020 2023 2053 7461 7274 . # Start\n-000169f0: 2074 6865 2070 6565 7220 6966 2069 7427 the peer if it'\n-00016a00: 7320 6e6f 7420 7275 6e6e 696e 6720 616c s not running al\n-00016a10: 7265 6164 790a 2020 2020 2020 2020 6966 ready. if\n-00016a20: 2073 656c 662e 7065 6572 2069 7320 4e6f self.peer is No\n-00016a30: 6e65 3a0a 2020 2020 2020 2020 2020 2020 ne:. \n-00016a40: 7365 6c66 2e70 6565 7220 3d20 436f 6e66 self.peer = Conf\n-00016a50: 6967 7572 6564 5065 6572 2873 656c 662e iguredPeer(self.\n-00016a60: 726f 7574 6572 2c20 7365 6c66 2e63 6f6e router, self.con\n-00016a70: 6669 6729 0a20 2020 2020 2020 2020 2020 fig). \n-00016a80: 2073 656c 662e 7065 6572 2e61 6464 5f64 self.peer.add_d\n-00016a90: 6f6e 655f 6361 6c6c 6261 636b 2873 656c one_callback(sel\n-00016aa0: 662e 7065 6572 5f63 6c6f 7365 6429 0a20 f.peer_closed). \n-00016ab0: 2020 2020 2020 2020 2020 2061 7373 6572 asser\n-00016ac0: 7420 7365 6c66 2e72 6f75 7465 722e 696e t self.router.in\n-00016ad0: 6974 5f68 6f73 740a 2020 2020 2020 2020 it_host. \n-00016ae0: 2020 2020 7365 6c66 2e70 6565 722e 7374 self.peer.st\n-00016af0: 6172 745f 696e 5f62 6163 6b67 726f 756e art_in_backgroun\n-00016b00: 6428 696e 6974 5f68 6f73 743d 7365 6c66 d(init_host=self\n-00016b10: 2e72 6f75 7465 722e 696e 6974 5f68 6f73 .router.init_hos\n-00016b20: 7429 0a0a 2020 2020 2020 2020 7265 7475 t).. retu\n-00016b30: 726e 2073 656c 662e 7065 6572 0a0a 2020 rn self.peer.. \n-00016b40: 2020 6465 6620 7065 6572 5f63 6c6f 7365 def peer_close\n-00016b50: 6428 7365 6c66 293a 0a20 2020 2020 2020 d(self):. \n-00016b60: 2073 656c 662e 7065 6572 203d 204e 6f6e self.peer = Non\n-00016b70: 650a 0a20 2020 2064 6566 2073 6875 7464 e.. def shutd\n-00016b80: 6f77 6e28 7365 6c66 293a 0a20 2020 2020 own(self):. \n-00016b90: 2020 2069 6620 7365 6c66 2e70 6565 7220 if self.peer \n-00016ba0: 6973 206e 6f74 204e 6f6e 653a 0a20 2020 is not None:. \n-00016bb0: 2020 2020 2020 2020 2073 656c 662e 7065 self.pe\n-00016bc0: 6572 2e63 6c6f 7365 2829 0a0a 0a63 6c61 er.close()...cla\n-00016bd0: 7373 2050 6565 7273 526f 7574 696e 6752 ss PeersRoutingR\n-00016be0: 756c 6528 526f 7574 696e 6752 756c 6529 ule(RoutingRule)\n-00016bf0: 3a0a 2020 2020 7275 6c65 733a 204c 6973 :. rules: Lis\n-00016c00: 745b 5065 6572 526f 7574 696e 6752 756c t[PeerRoutingRul\n-00016c10: 655d 203d 205b 5d0a 0a20 2020 2064 6566 e] = [].. def\n-00016c20: 2061 7070 6c79 5f72 756c 6528 7365 6c66 apply_rule(self\n-00016c30: 2c20 6f70 7469 6f6e 733a 204a 736f 6e4f , options: JsonO\n-00016c40: 626a 6563 7429 202d 3e20 4f70 7469 6f6e bject) -> Option\n-00016c50: 616c 5b45 6e64 706f 696e 745d 3a0a 2020 al[Endpoint]:. \n-00016c60: 2020 2020 2020 6c6f 6767 6572 2e64 6562 logger.deb\n-00016c70: 7567 2827 2020 2020 636f 6e73 6964 6572 ug(' consider\n-00016c80: 696e 6720 2564 2072 756c 6573 272c 206c ing %d rules', l\n-00016c90: 656e 2873 656c 662e 7275 6c65 7329 290a en(self.rules)).\n-00016ca0: 2020 2020 2020 2020 666f 7220 7275 6c65 for rule\n-00016cb0: 2069 6e20 7365 6c66 2e72 756c 6573 3a0a in self.rules:.\n-00016cc0: 2020 2020 2020 2020 2020 2020 6c6f 6767 logg\n-00016cd0: 6572 2e64 6562 7567 2827 2020 2020 2020 er.debug(' \n-00016ce0: 636f 6e73 6964 6572 696e 6720 2573 272c considering %s',\n-00016cf0: 2072 756c 652e 636f 6e66 6967 2e6e 616d rule.config.nam\n-00016d00: 6529 0a20 2020 2020 2020 2020 2020 2065 e). e\n-00016d10: 6e64 706f 696e 7420 3d20 7275 6c65 2e61 ndpoint = rule.a\n-00016d20: 7070 6c79 5f72 756c 6528 6f70 7469 6f6e pply_rule(option\n-00016d30: 7329 0a20 2020 2020 2020 2020 2020 2069 s). i\n-00016d40: 6620 656e 6470 6f69 6e74 2069 7320 6e6f f endpoint is no\n-00016d50: 7420 4e6f 6e65 3a0a 2020 2020 2020 2020 t None:. \n-00016d60: 2020 2020 2020 2020 6c6f 6767 6572 2e64 logger.d\n-00016d70: 6562 7567 2827 2020 2020 2020 2020 7365 ebug(' se\n-00016d80: 6c65 6374 6564 2729 0a20 2020 2020 2020 lected'). \n-00016d90: 2020 2020 2020 2020 2072 6574 7572 6e20 return \n-00016da0: 656e 6470 6f69 6e74 0a20 2020 2020 2020 endpoint. \n-00016db0: 206c 6f67 6765 722e 6465 6275 6728 2720 logger.debug(' \n-00016dc0: 2020 2020 206e 6f20 7065 6572 2072 756c no peer rul\n-00016dd0: 6573 206d 6174 6368 6564 2729 0a20 2020 es matched'). \n-00016de0: 2020 2020 2072 6574 7572 6e20 4e6f 6e65 return None\n-00016df0: 0a0a 2020 2020 6465 6620 7365 745f 636f .. def set_co\n-00016e00: 6e66 6967 7328 7365 6c66 2c20 6272 6964 nfigs(self, brid\n-00016e10: 6765 5f63 6f6e 6669 6773 3a20 5365 7175 ge_configs: Sequ\n-00016e20: 656e 6365 5b42 7269 6467 6543 6f6e 6669 ence[BridgeConfi\n-00016e30: 675d 2920 2d3e 204e 6f6e 653a 0a20 2020 g]) -> None:. \n-00016e40: 2020 2020 206f 6c64 5f72 756c 6573 203d old_rules =\n-00016e50: 2073 656c 662e 7275 6c65 730a 2020 2020 self.rules. \n-00016e60: 2020 2020 7365 6c66 2e72 756c 6573 203d self.rules =\n-00016e70: 205b 5d0a 0a20 2020 2020 2020 2066 6f72 [].. for\n-00016e80: 2063 6f6e 6669 6720 696e 2062 7269 6467 config in bridg\n-00016e90: 655f 636f 6e66 6967 733a 0a20 2020 2020 e_configs:. \n-00016ea0: 2020 2020 2020 2023 2054 686f 7365 2061 # Those a\n-00016eb0: 7265 2068 616e 646c 6564 2065 6c73 6577 re handled elsew\n-00016ec0: 6865 7265 2e2e 2e0a 2020 2020 2020 2020 here.... \n-00016ed0: 2020 2020 6966 2063 6f6e 6669 672e 7072 if config.pr\n-00016ee0: 6976 696c 6567 6564 206f 7220 2768 6f73 ivileged or 'hos\n-00016ef0: 7427 2069 6e20 636f 6e66 6967 2e6d 6174 t' in config.mat\n-00016f00: 6368 3a0a 2020 2020 2020 2020 2020 2020 ch:. \n-00016f10: 2020 2020 636f 6e74 696e 7565 0a0a 2020 continue.. \n-00016f20: 2020 2020 2020 2020 2020 2320 5472 7920 # Try \n-00016f30: 746f 2072 6575 7365 2061 6e20 6578 6973 to reuse an exis\n-00016f40: 7469 6e67 2072 756c 652c 2069 6620 6f6e ting rule, if on\n-00016f50: 6520 6578 6973 7473 2e2e 2e0a 2020 2020 e exists.... \n-00016f60: 2020 2020 2020 2020 666f 7220 7275 6c65 for rule\n-00016f70: 2069 6e20 6c69 7374 286f 6c64 5f72 756c in list(old_rul\n-00016f80: 6573 293a 0a20 2020 2020 2020 2020 2020 es):. \n-00016f90: 2020 2020 2069 6620 7275 6c65 2e63 6f6e if rule.con\n-00016fa0: 6669 6720 3d3d 2063 6f6e 6669 673a 0a20 fig == config:. \n-00016fb0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00016fc0: 2020 206f 6c64 5f72 756c 6573 2e72 656d old_rules.rem\n-00016fd0: 6f76 6528 7275 6c65 290a 2020 2020 2020 ove(rule). \n-00016fe0: 2020 2020 2020 2020 2020 2020 2020 6272 br\n-00016ff0: 6561 6b0a 2020 2020 2020 2020 2020 2020 eak. \n-00017000: 656c 7365 3a0a 2020 2020 2020 2020 2020 else:. \n-00017010: 2020 2020 2020 2320 2e2e 2e20 6f74 6865 # ... othe\n-00017020: 7277 6973 652c 2063 7265 6174 6520 6120 rwise, create a \n-00017030: 6e65 7720 6f6e 652e 0a20 2020 2020 2020 new one.. \n-00017040: 2020 2020 2020 2020 2072 756c 6520 3d20 rule = \n-00017050: 5065 6572 526f 7574 696e 6752 756c 6528 PeerRoutingRule(\n-00017060: 7365 6c66 2e72 6f75 7465 722c 2063 6f6e self.router, con\n-00017070: 6669 6729 0a0a 2020 2020 2020 2020 2020 fig).. \n-00017080: 2020 7365 6c66 2e72 756c 6573 2e61 7070 self.rules.app\n-00017090: 656e 6428 7275 6c65 290a 0a20 2020 2020 end(rule).. \n-000170a0: 2020 2023 2063 6c6f 7365 2064 6f77 6e20 # close down \n-000170b0: 7468 6520 6f6c 6420 7275 6c65 7320 7468 the old rules th\n-000170c0: 6174 2064 6964 6e27 7420 6765 7420 7265 at didn't get re\n-000170d0: 636c 6169 6d65 640a 2020 2020 2020 2020 claimed. \n-000170e0: 666f 7220 7275 6c65 2069 6e20 6f6c 645f for rule in old_\n-000170f0: 7275 6c65 733a 0a20 2020 2020 2020 2020 rules:. \n-00017100: 2020 2072 756c 652e 7368 7574 646f 776e rule.shutdown\n-00017110: 2829 0a0a 2020 2020 6465 6620 7368 7574 ().. def shut\n-00017120: 646f 776e 2873 656c 6629 3a0a 2020 2020 down(self):. \n-00017130: 2020 2020 666f 7220 7275 6c65 2069 6e20 for rule in \n-00017140: 7365 6c66 2e72 756c 6573 3a0a 2020 2020 self.rules:. \n-00017150: 2020 2020 2020 2020 7275 6c65 2e73 6875 rule.shu\n-00017160: 7464 6f77 6e28 290a 2727 272e 656e 636f tdown().'''.enco\n-00017170: 6465 2827 7574 662d 3827 292c 0a20 2027 de('utf-8'),. '\n-00017180: 636f 636b 7069 742f 7061 636b 6167 6573 cockpit/packages\n-00017190: 2e70 7927 3a20 6272 2727 2723 2054 6869 .py': br'''# Thi\n-000171a0: 7320 6669 6c65 2069 7320 7061 7274 206f s file is part o\n-000171b0: 6620 436f 636b 7069 742e 0a23 0a23 2043 f Cockpit..#.# C\n-000171c0: 6f70 7972 6967 6874 2028 4329 2032 3032 opyright (C) 202\n-000171d0: 3220 5265 6420 4861 742c 2049 6e63 2e0a 2 Red Hat, Inc..\n-000171e0: 230a 2320 5468 6973 2070 726f 6772 616d #.# This program\n-000171f0: 2069 7320 6672 6565 2073 6f66 7477 6172 is free softwar\n-00017200: 653a 2079 6f75 2063 616e 2072 6564 6973 e: you can redis\n-00017210: 7472 6962 7574 6520 6974 2061 6e64 2f6f tribute it and/o\n-00017220: 7220 6d6f 6469 6679 0a23 2069 7420 756e r modify.# it un\n-00017230: 6465 7220 7468 6520 7465 726d 7320 6f66 der the terms of\n-00017240: 2074 6865 2047 4e55 2047 656e 6572 616c the GNU General\n-00017250: 2050 7562 6c69 6320 4c69 6365 6e73 6520 Public License \n-00017260: 6173 2070 7562 6c69 7368 6564 2062 790a as published by.\n-00017270: 2320 7468 6520 4672 6565 2053 6f66 7477 # the Free Softw\n-00017280: 6172 6520 466f 756e 6461 7469 6f6e 2c20 are Foundation, \n-00017290: 6569 7468 6572 2076 6572 7369 6f6e 2033 either version 3\n-000172a0: 206f 6620 7468 6520 4c69 6365 6e73 652c of the License,\n-000172b0: 206f 720a 2320 2861 7420 796f 7572 206f or.# (at your o\n-000172c0: 7074 696f 6e29 2061 6e79 206c 6174 6572 ption) any later\n-000172d0: 2076 6572 7369 6f6e 2e0a 230a 2320 5468 version..#.# Th\n-000172e0: 6973 2070 726f 6772 616d 2069 7320 6469 is program is di\n-000172f0: 7374 7269 6275 7465 6420 696e 2074 6865 stributed in the\n-00017300: 2068 6f70 6520 7468 6174 2069 7420 7769 hope that it wi\n-00017310: 6c6c 2062 6520 7573 6566 756c 2c0a 2320 ll be useful,.# \n-00017320: 6275 7420 5749 5448 4f55 5420 414e 5920 but WITHOUT ANY \n-00017330: 5741 5252 414e 5459 3b20 7769 7468 6f75 WARRANTY; withou\n-00017340: 7420 6576 656e 2074 6865 2069 6d70 6c69 t even the impli\n-00017350: 6564 2077 6172 7261 6e74 7920 6f66 0a23 ed warranty of.#\n-00017360: 204d 4552 4348 414e 5441 4249 4c49 5459 MERCHANTABILITY\n-00017370: 206f 7220 4649 544e 4553 5320 464f 5220 or FITNESS FOR \n-00017380: 4120 5041 5254 4943 554c 4152 2050 5552 A PARTICULAR PUR\n-00017390: 504f 5345 2e20 2053 6565 2074 6865 0a23 POSE. See the.#\n-000173a0: 2047 4e55 2047 656e 6572 616c 2050 7562 GNU General Pub\n-000173b0: 6c69 6320 4c69 6365 6e73 6520 666f 7220 lic License for \n-000173c0: 6d6f 7265 2064 6574 6169 6c73 2e0a 230a more details..#.\n-000173d0: 2320 596f 7520 7368 6f75 6c64 2068 6176 # You should hav\n-000173e0: 6520 7265 6365 6976 6564 2061 2063 6f70 e received a cop\n-000173f0: 7920 6f66 2074 6865 2047 4e55 2047 656e y of the GNU Gen\n-00017400: 6572 616c 2050 7562 6c69 6320 4c69 6365 eral Public Lice\n-00017410: 6e73 650a 2320 616c 6f6e 6720 7769 7468 nse.# along with\n-00017420: 2074 6869 7320 7072 6f67 7261 6d2e 2020 this program. \n-00017430: 4966 206e 6f74 2c20 7365 6520 3c68 7474 If not, see ...im\n-00017460: 706f 7274 2063 6f6c 6c65 6374 696f 6e73 port collections\n-00017470: 0a69 6d70 6f72 7420 636f 6e74 6578 746c .import contextl\n-00017480: 6962 0a69 6d70 6f72 7420 6675 6e63 746f ib.import functo\n-00017490: 6f6c 730a 696d 706f 7274 2067 7a69 700a ols.import gzip.\n-000174a0: 696d 706f 7274 2069 6f0a 696d 706f 7274 import io.import\n-000174b0: 2069 7465 7274 6f6f 6c73 0a69 6d70 6f72 itertools.impor\n-000174c0: 7420 6a73 6f6e 0a69 6d70 6f72 7420 6c6f t json.import lo\n-000174d0: 6767 696e 670a 696d 706f 7274 206d 696d gging.import mim\n-000174e0: 6574 7970 6573 0a69 6d70 6f72 7420 6f73 etypes.import os\n-000174f0: 0a69 6d70 6f72 7420 7265 0a69 6d70 6f72 .import re.impor\n-00017500: 7420 7368 7574 696c 0a66 726f 6d20 7061 t shutil.from pa\n-00017510: 7468 6c69 6220 696d 706f 7274 2050 6174 thlib import Pat\n-00017520: 680a 6672 6f6d 2074 7970 696e 6720 696d h.from typing im\n-00017530: 706f 7274 2028 0a20 2020 2042 696e 6172 port (. Binar\n-00017540: 7949 4f2c 0a20 2020 2043 616c 6c61 626c yIO,. Callabl\n-00017550: 652c 0a20 2020 2043 6c61 7373 5661 722c e,. ClassVar,\n-00017560: 0a20 2020 2044 6963 742c 0a20 2020 2049 . Dict,. I\n-00017570: 7465 7261 626c 652c 0a20 2020 204c 6973 terable,. Lis\n-00017580: 742c 0a20 2020 204e 616d 6564 5475 706c t,. NamedTupl\n-00017590: 652c 0a20 2020 204f 7074 696f 6e61 6c2c e,. Optional,\n-000175a0: 0a20 2020 2050 6174 7465 726e 2c0a 2020 . Pattern,. \n-000175b0: 2020 5365 7175 656e 6365 2c0a 2020 2020 Sequence,. \n-000175c0: 5475 706c 652c 0a20 2020 2054 7970 6556 Tuple,. TypeV\n-000175d0: 6172 2c0a 290a 0a66 726f 6d20 636f 636b ar,.)..from cock\n-000175e0: 7069 742e 5f76 656e 646f 722e 7379 7374 pit._vendor.syst\n-000175f0: 656d 645f 6374 7970 6573 2069 6d70 6f72 emd_ctypes impor\n-00017600: 7420 6275 730a 0a66 726f 6d20 2e20 696d t bus..from . im\n-00017610: 706f 7274 2063 6f6e 6669 670a 6672 6f6d port config.from\n-00017620: 202e 5f76 6572 7369 6f6e 2069 6d70 6f72 ._version impor\n-00017630: 7420 5f5f 7665 7273 696f 6e5f 5f0a 6672 t __version__.fr\n-00017640: 6f6d 202e 6a73 6f6e 7574 696c 2069 6d70 om .jsonutil imp\n-00017650: 6f72 7420 280a 2020 2020 4a73 6f6e 4572 ort (. JsonEr\n-00017660: 726f 722c 0a20 2020 204a 736f 6e4f 626a ror,. JsonObj\n-00017670: 6563 742c 0a20 2020 204a 736f 6e56 616c ect,. JsonVal\n-00017680: 7565 2c0a 2020 2020 6765 745f 626f 6f6c ue,. get_bool\n-00017690: 2c0a 2020 2020 6765 745f 6469 6374 2c0a ,. get_dict,.\n-000176a0: 2020 2020 6765 745f 696e 742c 0a20 2020 get_int,. \n-000176b0: 2067 6574 5f6f 626a 762c 0a20 2020 2067 get_objv,. g\n-000176c0: 6574 5f73 7472 2c0a 2020 2020 6765 745f et_str,. get_\n-000176d0: 7374 7276 2c0a 2020 2020 6a73 6f6e 5f6d strv,. json_m\n-000176e0: 6572 6765 5f70 6174 6368 2c0a 2020 2020 erge_patch,. \n-000176f0: 7479 7065 6368 6563 6b65 642c 0a29 0a0a typechecked,.)..\n-00017700: 6c6f 6767 6572 203d 206c 6f67 6769 6e67 logger = logging\n-00017710: 2e67 6574 4c6f 6767 6572 285f 5f6e 616d .getLogger(__nam\n-00017720: 655f 5f29 0a0a 0a23 2049 6e20 7072 6163 e__)...# In prac\n-00017730: 7469 6365 2c20 7468 6973 2069 7320 676f tice, this is go\n-00017740: 696e 6720 746f 2067 6574 2063 616c 6c65 ing to get calle\n-00017750: 6420 6f76 6572 2061 6e64 206f 7665 7220 d over and over \n-00017760: 6167 6169 6e20 7769 7468 2065 7861 6374 again with exact\n-00017770: 6c79 2074 6865 0a23 2073 616d 6520 6c69 ly the.# same li\n-00017780: 7374 2e20 204c 6574 2773 2074 7279 2074 st. Let's try t\n-00017790: 6f20 6361 6368 6520 7468 6520 7265 7375 o cache the resu\n-000177a0: 6c74 2e0a 4066 756e 6374 6f6f 6c73 2e6c lt..@functools.l\n-000177b0: 7275 5f63 6163 6865 2829 0a64 6566 2070 ru_cache().def p\n-000177c0: 6172 7365 5f61 6363 6570 745f 6c61 6e67 arse_accept_lang\n-000177d0: 7561 6765 2861 6363 6570 745f 6c61 6e67 uage(accept_lang\n-000177e0: 7561 6765 3a20 7374 7229 202d 3e20 5365 uage: str) -> Se\n-000177f0: 7175 656e 6365 5b73 7472 5d3a 0a20 2020 quence[str]:. \n-00017800: 2022 2222 5061 7273 6520 7468 6520 4163 \"\"\"Parse the Ac\n-00017810: 6365 7074 2d4c 616e 6775 6167 6520 6865 cept-Language he\n-00017820: 6164 6572 2c20 6966 2069 7420 6578 6973 ader, if it exis\n-00017830: 7473 2e0a 0a20 2020 2052 6574 7572 6e73 ts... Returns\n-00017840: 2061 6e20 6f72 6465 7265 6420 6c69 7374 an ordered list\n-00017850: 206f 6620 6c61 6e67 7561 6765 732c 2077 of languages, w\n-00017860: 6974 6820 6661 6c6c 6261 636b 7320 696e ith fallbacks in\n-00017870: 7365 7274 6564 2c20 616e 640a 2020 2020 serted, and. \n-00017880: 7472 756e 6361 7465 6420 746f 2074 6865 truncated to the\n-00017890: 2070 6f73 6974 696f 6e20 7768 6572 6520 position where \n-000178a0: 2765 6e27 2077 6f75 6c64 2068 6176 6520 'en' would have \n-000178b0: 6f74 6865 7277 6973 6520 6170 7065 6172 otherwise appear\n-000178c0: 6564 2c20 6966 0a20 2020 2061 7070 6c69 ed, if. appli\n-000178d0: 6361 626c 652e 0a0a 2020 2020 6874 7470 cable... http\n-000178e0: 733a 2f2f 746f 6f6c 732e 6965 7466 2e6f s://tools.ietf.o\n-000178f0: 7267 2f68 746d 6c2f 7266 6337 3233 3123 rg/html/rfc7231#\n-00017900: 7365 6374 696f 6e2d 352e 332e 350a 2020 section-5.3.5. \n-00017910: 2020 6874 7470 733a 2f2f 6461 7461 7472 https://datatr\n-00017920: 6163 6b65 722e 6965 7466 2e6f 7267 2f64 acker.ietf.org/d\n-00017930: 6f63 2f68 746d 6c2f 7266 6334 3634 3723 oc/html/rfc4647#\n-00017940: 7365 6374 696f 6e2d 332e 340a 2020 2020 section-3.4. \n-00017950: 2222 220a 0a20 2020 206c 6f67 6765 722e \"\"\".. logger.\n-00017960: 6465 6275 6728 2770 6172 7365 5f61 6363 debug('parse_acc\n-00017970: 6570 745f 6c61 6e67 7561 6765 2825 7229 ept_language(%r)\n-00017980: 272c 2061 6363 6570 745f 6c61 6e67 7561 ', accept_langua\n-00017990: 6765 290a 2020 2020 6c6f 6361 6c65 735f ge). locales_\n-000179a0: 7769 7468 5f71 203d 205b 5d0a 2020 2020 with_q = []. \n-000179b0: 666f 7220 656e 7472 7920 696e 2061 6363 for entry in acc\n-000179c0: 6570 745f 6c61 6e67 7561 6765 2e73 706c ept_language.spl\n-000179d0: 6974 2827 2c27 293a 0a20 2020 2020 2020 it(','):. \n-000179e0: 2065 6e74 7279 203d 2065 6e74 7279 2e73 entry = entry.s\n-000179f0: 7472 6970 2829 2e6c 6f77 6572 2829 0a20 trip().lower(). \n-00017a00: 2020 2020 2020 206c 6f67 6765 722e 6465 logger.de\n-00017a10: 6275 6728 2720 2065 6e74 7279 2025 7227 bug(' entry %r'\n-00017a20: 2c20 656e 7472 7929 0a20 2020 2020 2020 , entry). \n-00017a30: 206c 6f63 616c 652c 205f 2c20 7173 7472 locale, _, qstr\n-00017a40: 203d 2065 6e74 7279 2e70 6172 7469 7469 = entry.partiti\n-00017a50: 6f6e 2827 3b71 3d27 290a 2020 2020 2020 on(';q='). \n-00017a60: 2020 7472 793a 0a20 2020 2020 2020 2020 try:. \n-00017a70: 2020 2071 203d 2066 6c6f 6174 2871 7374 q = float(qst\n-00017a80: 7220 6f72 2031 2e30 290a 2020 2020 2020 r or 1.0). \n-00017a90: 2020 6578 6365 7074 2056 616c 7565 4572 except ValueEr\n-00017aa0: 726f 723a 0a20 2020 2020 2020 2020 2020 ror:. \n-00017ab0: 2063 6f6e 7469 6e75 6520 2023 2069 676e continue # ign\n-00017ac0: 6f72 6520 6d61 6c66 6f72 6d65 6420 656e ore malformed en\n-00017ad0: 7472 790a 0a20 2020 2020 2020 2077 6869 try.. whi\n-00017ae0: 6c65 206c 6f63 616c 653a 0a20 2020 2020 le locale:. \n-00017af0: 2020 2020 2020 206c 6f67 6765 722e 6465 logger.de\n-00017b00: 6275 6728 2720 2020 2061 6464 696e 6720 bug(' adding \n-00017b10: 2572 2071 3d25 7227 2c20 6c6f 6361 6c65 %r q=%r', locale\n-00017b20: 2c20 7129 0a20 2020 2020 2020 2020 2020 , q). \n-00017b30: 206c 6f63 616c 6573 5f77 6974 685f 712e locales_with_q.\n-00017b40: 6170 7065 6e64 2828 6c6f 6361 6c65 2c20 append((locale, \n-00017b50: 7129 290a 2020 2020 2020 2020 2020 2020 q)). \n-00017b60: 2320 7374 7269 7020 6f66 6620 272d 6465 # strip off '-de\n-00017b70: 7461 696c 2720 7375 6666 6978 6573 2075 tail' suffixes u\n-00017b80: 6e74 696c 2074 6865 7265 2773 206e 6f74 ntil there's not\n-00017b90: 6869 6e67 206c 6566 740a 2020 2020 2020 hing left. \n-00017ba0: 2020 2020 2020 6c6f 6361 6c65 2c20 5f2c locale, _,\n-00017bb0: 205f 7265 6769 6f6e 203d 206c 6f63 616c _region = local\n-00017bc0: 652e 7270 6172 7469 7469 6f6e 2827 2d27 e.rpartition('-'\n-00017bd0: 290a 0a20 2020 2023 2053 6f72 7420 7468 ).. # Sort th\n-00017be0: 6520 6c69 7374 2062 7920 6869 6768 6573 e list by highes\n-00017bf0: 7420 7120 7661 6c75 652e 2020 4f74 6865 t q value. Othe\n-00017c00: 7277 6973 652c 2074 6869 7320 6973 2061 rwise, this is a\n-00017c10: 2073 7461 626c 6520 736f 7274 2e0a 2020 stable sort.. \n-00017c20: 2020 6c6f 6361 6c65 735f 7769 7468 5f71 locales_with_q\n-00017c30: 2e73 6f72 7428 6b65 793d 6c61 6d62 6461 .sort(key=lambda\n-00017c40: 2070 6169 723a 2070 6169 725b 315d 2c20 pair: pair[1], \n-00017c50: 7265 7665 7273 653d 5472 7565 290a 2020 reverse=True). \n-00017c60: 2020 6c6f 6767 6572 2e64 6562 7567 2827 logger.debug('\n-00017c70: 2020 736f 7274 6564 206c 6973 7420 6973 sorted list is\n-00017c80: 2025 7227 2c20 6c6f 6361 6c65 735f 7769 %r', locales_wi\n-00017c90: 7468 5f71 290a 0a20 2020 2023 2049 6620 th_q).. # If \n-00017ca0: 7765 2068 6176 6520 2765 6e27 2061 6e79 we have 'en' any\n-00017cb0: 7768 6572 6520 696e 206f 7572 206c 6973 where in our lis\n-00017cc0: 742c 2069 676e 6f72 6520 6974 2061 6e64 t, ignore it and\n-00017cd0: 2061 6c6c 2069 7465 6d73 2061 6674 6572 all items after\n-00017ce0: 2069 742e 0a20 2020 2023 2054 6869 7320 it.. # This \n-00017cf0: 7769 6c6c 2072 6573 756c 7420 696e 2075 will result in u\n-00017d00: 7320 6765 7474 696e 6720 616e 2075 6e74 s getting an unt\n-00017d10: 7261 6e73 6c61 7465 6420 2869 653a 2045 ranslated (ie: E\n-00017d20: 6e67 6c69 7368 2920 7665 7273 696f 6e20 nglish) version \n-00017d30: 6966 0a20 2020 2023 206e 6f6e 6520 6f66 if. # none of\n-00017d40: 2074 6865 206d 6f72 652d 7072 6566 6572 the more-prefer\n-00017d50: 7265 6420 6c61 6e67 7561 6765 7320 6172 red languages ar\n-00017d60: 6520 666f 756e 642c 2077 6869 6368 2069 e found, which i\n-00017d70: 7320 7768 6174 2077 6520 7761 6e74 2e0a s what we want..\n-00017d80: 2020 2020 2320 5765 2061 6c73 6f20 7461 # We also ta\n-00017d90: 6b65 2074 6865 2063 6861 6e63 6520 746f ke the chance to\n-00017da0: 2064 726f 7020 6475 706c 6963 6174 6520 drop duplicate \n-00017db0: 6974 656d 732e 2020 4e6f 7465 3a20 626f items. Note: bo\n-00017dc0: 7468 206f 6620 7468 6573 650a 2020 2020 th of these. \n-00017dd0: 2320 7468 696e 6773 206e 6565 6420 746f # things need to\n-00017de0: 2068 6170 7065 6e20 6166 7465 7220 736f happen after so\n-00017df0: 7274 696e 672e 0a20 2020 2072 6573 756c rting.. resul\n-00017e00: 7473 203d 205b 5d0a 2020 2020 666f 7220 ts = []. for \n-00017e10: 6c6f 6361 6c65 2c20 5f71 2069 6e20 6c6f locale, _q in lo\n-00017e20: 6361 6c65 735f 7769 7468 5f71 3a0a 2020 cales_with_q:. \n-00017e30: 2020 2020 2020 6966 206c 6f63 616c 6520 if locale \n-00017e40: 3d3d 2027 656e 273a 0a20 2020 2020 2020 == 'en':. \n-00017e50: 2020 2020 2062 7265 616b 0a20 2020 2020 break. \n-00017e60: 2020 2069 6620 6c6f 6361 6c65 206e 6f74 if locale not\n-00017e70: 2069 6e20 7265 7375 6c74 733a 0a20 2020 in results:. \n-00017e80: 2020 2020 2020 2020 2072 6573 756c 7473 results\n-00017e90: 2e61 7070 656e 6428 6c6f 6361 6c65 290a .append(locale).\n-00017ea0: 0a20 2020 206c 6f67 6765 722e 6465 6275 . logger.debu\n-00017eb0: 6728 2720 2072 6573 756c 7473 206c 6973 g(' results lis\n-00017ec0: 7420 6973 2025 7227 2c20 7265 7375 6c74 t is %r', result\n-00017ed0: 7329 0a20 2020 2072 6574 7572 6e20 7475 s). return tu\n-00017ee0: 706c 6528 7265 7375 6c74 7329 0a0a 0a64 ple(results)...d\n-00017ef0: 6566 2073 6f72 7469 6679 5f76 6572 7369 ef sortify_versi\n-00017f00: 6f6e 2876 6572 7369 6f6e 3a20 7374 7229 on(version: str)\n-00017f10: 202d 3e20 7374 723a 0a20 2020 2022 2222 -> str:. \"\"\"\n-00017f20: 436f 6e76 6572 7420 6120 7665 7273 696f Convert a versio\n-00017f30: 6e20 7374 7269 6e67 2074 6f20 6120 666f n string to a fo\n-00017f40: 726d 2074 6861 7420 6361 6e20 6265 2063 rm that can be c\n-00017f50: 6f6d 7061 7265 6422 2222 0a20 2020 2023 ompared\"\"\". #\n-00017f60: 2030 2d70 6164 2065 6163 6820 6e75 6d65 0-pad each nume\n-00017f70: 7269 6320 636f 6d70 6f6e 656e 742e 2020 ric component. \n-00017f80: 4f6e 6c79 2073 7570 706f 7274 7320 6e75 Only supports nu\n-00017f90: 6d65 7269 6320 7665 7273 696f 6e73 206c meric versions l\n-00017fa0: 696b 6520 312e 322e 332e 0a20 2020 2072 ike 1.2.3.. r\n-00017fb0: 6574 7572 6e20 272e 272e 6a6f 696e 2870 eturn '.'.join(p\n-00017fc0: 6172 742e 7a66 696c 6c28 3829 2066 6f72 art.zfill(8) for\n-00017fd0: 2070 6172 7420 696e 2076 6572 7369 6f6e part in version\n-00017fe0: 2e73 706c 6974 2827 2e27 2929 0a0a 0a40 .split('.'))...@\n-00017ff0: 6675 6e63 746f 6f6c 732e 6c72 755f 6361 functools.lru_ca\n-00018000: 6368 6528 290a 6465 6620 6765 745f 6c69 che().def get_li\n-00018010: 6265 7865 6364 6972 2829 202d 3e20 7374 bexecdir() -> st\n-00018020: 723a 0a20 2020 2022 2222 4465 7465 6374 r:. \"\"\"Detect\n-00018030: 206c 6962 6578 6563 6469 7220 6f6e 2063 libexecdir on c\n-00018040: 7572 7265 6e74 206d 6163 6869 6e65 0a0a urrent machine..\n-00018050: 2020 2020 5468 6973 206f 6e6c 7920 776f This only wo\n-00018060: 726b 7320 666f 7220 7379 7374 656d 7320 rks for systems \n-00018070: 7768 6963 6820 6861 7665 2063 6f63 6b70 which have cockp\n-00018080: 6974 2d77 7320 696e 7374 616c 6c65 642e it-ws installed.\n-00018090: 0a20 2020 2022 2222 0a20 2020 2066 6f72 . \"\"\". for\n-000180a0: 2063 616e 6469 6461 7465 2069 6e20 5b27 candidate in ['\n-000180b0: 2f75 7372 2f6c 6f63 616c 2f6c 6962 6578 /usr/local/libex\n-000180c0: 6563 272c 2027 2f75 7372 2f6c 6962 6578 ec', '/usr/libex\n-000180d0: 6563 272c 2027 2f75 7372 2f6c 6f63 616c ec', '/usr/local\n-000180e0: 2f6c 6962 2f63 6f63 6b70 6974 272c 2027 /lib/cockpit', '\n-000180f0: 2f75 7372 2f6c 6962 2f63 6f63 6b70 6974 /usr/lib/cockpit\n-00018100: 275d 3a0a 2020 2020 2020 2020 6966 206f ']:. if o\n-00018110: 732e 7061 7468 2e65 7869 7374 7328 6f73 s.path.exists(os\n-00018120: 2e70 6174 682e 6a6f 696e 2863 616e 6469 .path.join(candi\n-00018130: 6461 7465 2c20 2763 6f63 6b70 6974 2d61 date, 'cockpit-a\n-00018140: 736b 7061 7373 2729 293a 0a20 2020 2020 skpass')):. \n-00018150: 2020 2020 2020 2072 6574 7572 6e20 6361 return ca\n-00018160: 6e64 6964 6174 650a 2020 2020 656c 7365 ndidate. else\n-00018170: 3a0a 2020 2020 2020 2020 6c6f 6767 6572 :. logger\n-00018180: 2e77 6172 6e69 6e67 2827 436f 756c 6420 .warning('Could \n-00018190: 6e6f 7420 6465 7465 6374 206c 6962 6578 not detect libex\n-000181a0: 6563 6469 7227 290a 2020 2020 2020 2020 ecdir'). \n-000181b0: 2320 6769 7665 2072 6561 6461 626c 6520 # give readable \n-000181c0: 6572 726f 7220 6d65 7373 6167 6573 0a20 error messages. \n-000181d0: 2020 2020 2020 2072 6574 7572 6e20 272f return '/\n-000181e0: 6e6f 6e65 7869 7374 656e 742f 6c69 6265 nonexistent/libe\n-000181f0: 7865 6327 0a0a 0a23 2048 4143 4b3a 2054 xec'...# HACK: T\n-00018200: 7970 6520 6e61 7272 6f77 696e 6720 6f76 ype narrowing ov\n-00018210: 6572 2055 6e69 6f6e 2074 7970 6573 2069 er Union types i\n-00018220: 7320 6e6f 7420 7375 7070 6f72 7465 6420 s not supported \n-00018230: 696e 2074 6865 2067 656e 6572 616c 2063 in the general c\n-00018240: 6173 652c 0a23 2062 7574 2074 6869 7320 ase,.# but this \n-00018250: 776f 726b 7320 666f 7220 7468 6520 6361 works for the ca\n-00018260: 7365 2077 6520 6361 7265 2061 626f 7574 se we care about\n-00018270: 3a20 6b6e 6f77 696e 6720 7468 6174 2077 : knowing that w\n-00018280: 6865 6e20 7765 2070 6173 7320 696e 2061 hen we pass in a\n-00018290: 6e0a 2320 4a73 6f6e 4f62 6a65 6374 2c20 n.# JsonObject, \n-000182a0: 7765 276c 6c20 6765 7420 616e 204a 736f we'll get an Jso\n-000182b0: 6e4f 626a 6563 7420 6261 636b 2e0a 4a20 nObject back..J \n-000182c0: 3d20 5479 7065 5661 7228 274a 272c 204a = TypeVar('J', J\n-000182d0: 736f 6e4f 626a 6563 742c 204a 736f 6e56 sonObject, JsonV\n-000182e0: 616c 7565 290a 0a0a 6465 6620 7061 7463 alue)...def patc\n-000182f0: 685f 6c69 6265 7865 6364 6972 286f 626a h_libexecdir(obj\n-00018300: 3a20 4a29 202d 3e20 4a3a 0a20 2020 2069 : J) -> J:. i\n-00018310: 6620 6973 696e 7374 616e 6365 286f 626a f isinstance(obj\n-00018320: 2c20 7374 7229 3a0a 2020 2020 2020 2020 , str):. \n-00018330: 6966 2027 247b 6c69 6265 7865 6364 6972 if '${libexecdir\n-00018340: 7d2f 636f 636b 7069 742d 6173 6b70 6173 }/cockpit-askpas\n-00018350: 7327 2069 6e20 6f62 6a3a 0a20 2020 2020 s' in obj:. \n-00018360: 2020 2020 2020 2023 2065 7874 7261 2d73 # extra-s\n-00018370: 7065 6369 616c 2063 6173 653a 2077 6520 pecial case: we \n-00018380: 6861 6e64 6c65 2074 6869 7320 696e 7465 handle this inte\n-00018390: 726e 616c 6c79 0a20 2020 2020 2020 2020 rnally. \n-000183a0: 2020 2061 6273 5f61 736b 7061 7373 203d abs_askpass =\n-000183b0: 2073 6875 7469 6c2e 7768 6963 6828 2763 shutil.which('c\n-000183c0: 6f63 6b70 6974 2d61 736b 7061 7373 2729 ockpit-askpass')\n-000183d0: 0a20 2020 2020 2020 2020 2020 2069 6620 . if \n-000183e0: 6162 735f 6173 6b70 6173 7320 6973 206e abs_askpass is n\n-000183f0: 6f74 204e 6f6e 653a 0a20 2020 2020 2020 ot None:. \n-00018400: 2020 2020 2020 2020 2072 6574 7572 6e20 return \n-00018410: 6f62 6a2e 7265 706c 6163 6528 2724 7b6c obj.replace('${l\n-00018420: 6962 6578 6563 6469 727d 2f63 6f63 6b70 ibexecdir}/cockp\n-00018430: 6974 2d61 736b 7061 7373 272c 2061 6273 it-askpass', abs\n-00018440: 5f61 736b 7061 7373 290a 2020 2020 2020 _askpass). \n-00018450: 2020 7265 7475 726e 206f 626a 2e72 6570 return obj.rep\n-00018460: 6c61 6365 2827 247b 6c69 6265 7865 6364 lace('${libexecd\n-00018470: 6972 7d27 2c20 6765 745f 6c69 6265 7865 ir}', get_libexe\n-00018480: 6364 6972 2829 290a 2020 2020 656c 6966 cdir()). elif\n-00018490: 2069 7369 6e73 7461 6e63 6528 6f62 6a2c isinstance(obj,\n-000184a0: 2064 6963 7429 3a0a 2020 2020 2020 2020 dict):. \n-000184b0: 7265 7475 726e 207b 6b65 793a 2070 6174 return {key: pat\n-000184c0: 6368 5f6c 6962 6578 6563 6469 7228 7661 ch_libexecdir(va\n-000184d0: 6c75 6529 2066 6f72 206b 6579 2c20 7661 lue) for key, va\n-000184e0: 6c75 6520 696e 206f 626a 2e69 7465 6d73 lue in obj.items\n-000184f0: 2829 7d0a 2020 2020 656c 6966 2069 7369 ()}. elif isi\n-00018500: 6e73 7461 6e63 6528 6f62 6a2c 206c 6973 nstance(obj, lis\n-00018510: 7429 3a0a 2020 2020 2020 2020 7265 7475 t):. retu\n-00018520: 726e 205b 7061 7463 685f 6c69 6265 7865 rn [patch_libexe\n-00018530: 6364 6972 2869 7465 6d29 2066 6f72 2069 cdir(item) for i\n-00018540: 7465 6d20 696e 206f 626a 5d0a 2020 2020 tem in obj]. \n-00018550: 656c 7365 3a0a 2020 2020 2020 2020 7265 else:. re\n-00018560: 7475 726e 206f 626a 0a0a 0a23 2041 2064 turn obj...# A d\n-00018570: 6f63 756d 656e 7420 6973 2061 2062 696e ocument is a bin\n-00018580: 6172 7920 7374 7265 616d 2077 6974 6820 ary stream with \n-00018590: 6120 436f 6e74 656e 742d 5479 7065 2c20 a Content-Type, \n-000185a0: 6f70 7469 6f6e 616c 2043 6f6e 7465 6e74 optional Content\n-000185b0: 2d45 6e63 6f64 696e 672c 0a23 2061 6e64 -Encoding,.# and\n-000185c0: 206f 7074 696f 6e61 6c20 436f 6e74 656e optional Conten\n-000185d0: 742d 5365 6375 7269 7479 2d50 6f6c 6963 t-Security-Polic\n-000185e0: 790a 636c 6173 7320 446f 6375 6d65 6e74 y.class Document\n-000185f0: 284e 616d 6564 5475 706c 6529 3a0a 2020 (NamedTuple):. \n-00018600: 2020 6461 7461 3a20 4269 6e61 7279 494f data: BinaryIO\n-00018610: 0a20 2020 2063 6f6e 7465 6e74 5f74 7970 . content_typ\n-00018620: 653a 2073 7472 0a20 2020 2063 6f6e 7465 e: str. conte\n-00018630: 6e74 5f65 6e63 6f64 696e 673a 204f 7074 nt_encoding: Opt\n-00018640: 696f 6e61 6c5b 7374 725d 203d 204e 6f6e ional[str] = Non\n-00018650: 650a 2020 2020 636f 6e74 656e 745f 7365 e. content_se\n-00018660: 6375 7269 7479 5f70 6f6c 6963 793a 204f curity_policy: O\n-00018670: 7074 696f 6e61 6c5b 7374 725d 203d 204e ptional[str] = N\n-00018680: 6f6e 650a 0a0a 636c 6173 7320 5061 636b one...class Pack\n-00018690: 6167 6573 4c69 7374 656e 6572 3a0a 2020 agesListener:. \n-000186a0: 2020 6465 6620 7061 636b 6167 6573 5f6c def packages_l\n-000186b0: 6f61 6465 6428 7365 6c66 2920 2d3e 204e oaded(self) -> N\n-000186c0: 6f6e 653a 0a20 2020 2020 2020 2022 2222 one:. \"\"\"\n-000186d0: 4361 6c6c 6564 2077 6865 6e20 7468 6520 Called when the \n-000186e0: 7061 636b 6167 6573 2068 6176 6520 6265 packages have be\n-000186f0: 656e 2072 656c 6f61 6465 6422 2222 0a0a en reloaded\"\"\"..\n-00018700: 0a63 6c61 7373 2042 7269 6467 6543 6f6e .class BridgeCon\n-00018710: 6669 6728 6469 6374 2c20 4a73 6f6e 4f62 fig(dict, JsonOb\n-00018720: 6a65 6374 293a 0a20 2020 2064 6566 205f ject):. def _\n-00018730: 5f69 6e69 745f 5f28 7365 6c66 2c20 7661 _init__(self, va\n-00018740: 6c75 653a 204a 736f 6e4f 626a 6563 7429 lue: JsonObject)\n-00018750: 3a0a 2020 2020 2020 2020 7375 7065 7228 :. super(\n-00018760: 292e 5f5f 696e 6974 5f5f 2876 616c 7565 ).__init__(value\n-00018770: 290a 0a20 2020 2020 2020 2073 656c 662e ).. self.\n-00018780: 6c61 6265 6c20 3d20 6765 745f 7374 7228 label = get_str(\n-00018790: 7365 6c66 2c20 276c 6162 656c 272c 204e self, 'label', N\n-000187a0: 6f6e 6529 0a0a 2020 2020 2020 2020 7365 one).. se\n-000187b0: 6c66 2e70 7269 7669 6c65 6765 6420 3d20 lf.privileged = \n-000187c0: 6765 745f 626f 6f6c 2873 656c 662c 2027 get_bool(self, '\n-000187d0: 7072 6976 696c 6567 6564 272c 2064 6566 privileged', def\n-000187e0: 6175 6c74 3d46 616c 7365 290a 2020 2020 ault=False). \n-000187f0: 2020 2020 7365 6c66 2e6d 6174 6368 203d self.match =\n-00018800: 2067 6574 5f64 6963 7428 7365 6c66 2c20 get_dict(self, \n-00018810: 276d 6174 6368 272c 207b 7d29 0a20 2020 'match', {}). \n-00018820: 2020 2020 2069 6620 6e6f 7420 7365 6c66 if not self\n-00018830: 2e70 7269 7669 6c65 6765 6420 616e 6420 .privileged and \n-00018840: 6e6f 7420 7365 6c66 2e6d 6174 6368 3a0a not self.match:.\n-00018850: 2020 2020 2020 2020 2020 2020 7261 6973 rais\n-00018860: 6520 4a73 6f6e 4572 726f 7228 7661 6c75 e JsonError(valu\n-00018870: 652c 2027 6d75 7374 2068 6176 6520 6d61 e, 'must have ma\n-00018880: 7463 6820 7275 6c65 7320 6f72 2062 6520 tch rules or be \n-00018890: 7072 6976 696c 6567 6564 2729 0a0a 2020 privileged').. \n-000188a0: 2020 2020 2020 7365 6c66 2e65 6e76 6972 self.envir\n-000188b0: 6f6e 203d 2067 6574 5f73 7472 7628 7365 on = get_strv(se\n-000188c0: 6c66 2c20 2765 6e76 6972 6f6e 272c 2028 lf, 'environ', (\n-000188d0: 2929 0a20 2020 2020 2020 2073 656c 662e )). self.\n-000188e0: 7370 6177 6e20 3d20 6765 745f 7374 7276 spawn = get_strv\n-000188f0: 2873 656c 662c 2027 7370 6177 6e27 290a (self, 'spawn').\n-00018900: 2020 2020 2020 2020 6966 206e 6f74 2073 if not s\n-00018910: 656c 662e 7370 6177 6e3a 0a20 2020 2020 elf.spawn:. \n-00018920: 2020 2020 2020 2072 6169 7365 204a 736f raise Jso\n-00018930: 6e45 7272 6f72 2876 616c 7565 2c20 2773 nError(value, 's\n-00018940: 7061 776e 2076 6563 746f 7220 6d75 7374 pawn vector must\n-00018950: 2062 6520 6e6f 6e2d 656d 7074 7927 290a be non-empty').\n-00018960: 0a20 2020 2020 2020 2073 656c 662e 6e61 . self.na\n-00018970: 6d65 203d 2073 656c 662e 6c61 6265 6c20 me = self.label \n-00018980: 6f72 2073 656c 662e 7370 6177 6e5b 305d or self.spawn[0]\n-00018990: 0a0a 0a63 6c61 7373 2043 6f6e 6469 7469 ...class Conditi\n-000189a0: 6f6e 3a0a 2020 2020 6465 6620 5f5f 696e on:. def __in\n-000189b0: 6974 5f5f 2873 656c 662c 2076 616c 7565 it__(self, value\n-000189c0: 3a20 4a73 6f6e 4f62 6a65 6374 293a 0a20 : JsonObject):. \n-000189d0: 2020 2020 2020 2074 7279 3a0a 2020 2020 try:. \n-000189e0: 2020 2020 2020 2020 2873 656c 662e 6e61 (self.na\n-000189f0: 6d65 2c20 7365 6c66 2e76 616c 7565 292c me, self.value),\n-00018a00: 203d 2076 616c 7565 2e69 7465 6d73 2829 = value.items()\n-00018a10: 0a20 2020 2020 2020 2065 7863 6570 7420 . except \n-00018a20: 5661 6c75 6545 7272 6f72 2061 7320 6578 ValueError as ex\n-00018a30: 633a 0a20 2020 2020 2020 2020 2020 2072 c:. r\n-00018a40: 6169 7365 204a 736f 6e45 7272 6f72 2876 aise JsonError(v\n-00018a50: 616c 7565 2c20 276d 7573 7420 636f 6e74 alue, 'must cont\n-00018a60: 6169 6e20 6578 6163 746c 7920 6f6e 6520 ain exactly one \n-00018a70: 6b65 792f 7661 6c75 6520 7061 6972 2729 key/value pair')\n-00018a80: 2066 726f 6d20 6578 630a 0a0a 636c 6173 from exc...clas\n-00018a90: 7320 4d61 6e69 6665 7374 2864 6963 742c s Manifest(dict,\n-00018aa0: 204a 736f 6e4f 626a 6563 7429 3a0a 2020 JsonObject):. \n-00018ab0: 2020 2320 536b 6970 2076 6572 7369 6f6e # Skip version\n-00018ac0: 2063 6865 636b 2077 6865 6e20 7275 6e6e check when runn\n-00018ad0: 696e 6720 6f75 7420 6f66 2074 6865 2067 ing out of the g\n-00018ae0: 6974 2063 6865 636b 6f75 7420 285f 5f76 it checkout (__v\n-00018af0: 6572 7369 6f6e 5f5f 2069 7320 4e6f 6e65 ersion__ is None\n-00018b00: 290a 2020 2020 434f 434b 5049 545f 5645 ). COCKPIT_VE\n-00018b10: 5253 494f 4e20 3d20 5f5f 7665 7273 696f RSION = __versio\n-00018b20: 6e5f 5f20 616e 6420 736f 7274 6966 795f n__ and sortify_\n-00018b30: 7665 7273 696f 6e28 5f5f 7665 7273 696f version(__versio\n-00018b40: 6e5f 5f29 0a0a 2020 2020 6465 6620 5f5f n__).. def __\n-00018b50: 696e 6974 5f5f 2873 656c 662c 2070 6174 init__(self, pat\n-00018b60: 683a 2050 6174 682c 2076 616c 7565 3a20 h: Path, value: \n-00018b70: 4a73 6f6e 4f62 6a65 6374 293a 0a20 2020 JsonObject):. \n-00018b80: 2020 2020 2073 7570 6572 2829 2e5f 5f69 super().__i\n-00018b90: 6e69 745f 5f28 7661 6c75 6529 0a20 2020 nit__(value). \n-00018ba0: 2020 2020 2073 656c 662e 7061 7468 203d self.path =\n-00018bb0: 2070 6174 680a 2020 2020 2020 2020 7365 path. se\n-00018bc0: 6c66 2e6e 616d 6520 3d20 6765 745f 7374 lf.name = get_st\n-00018bd0: 7228 7365 6c66 2c20 276e 616d 6527 2c20 r(self, 'name', \n-00018be0: 7365 6c66 2e70 6174 682e 6e61 6d65 290a self.path.name).\n-00018bf0: 2020 2020 2020 2020 7365 6c66 2e62 7269 self.bri\n-00018c00: 6467 6573 203d 2067 6574 5f6f 626a 7628 dges = get_objv(\n-00018c10: 7365 6c66 2c20 2762 7269 6467 6573 272c self, 'bridges',\n-00018c20: 2042 7269 6467 6543 6f6e 6669 6729 0a20 BridgeConfig). \n-00018c30: 2020 2020 2020 2073 656c 662e 7072 696f self.prio\n-00018c40: 7269 7479 203d 2067 6574 5f69 6e74 2873 rity = get_int(s\n-00018c50: 656c 662c 2027 7072 696f 7269 7479 272c elf, 'priority',\n-00018c60: 2031 290a 2020 2020 2020 2020 7365 6c66 1). self\n-00018c70: 2e63 7370 203d 2067 6574 5f73 7472 2873 .csp = get_str(s\n-00018c80: 656c 662c 2027 636f 6e74 656e 742d 7365 elf, 'content-se\n-00018c90: 6375 7269 7479 2d70 6f6c 6963 7927 2c20 curity-policy', \n-00018ca0: 2727 290a 2020 2020 2020 2020 7365 6c66 ''). self\n-00018cb0: 2e63 6f6e 6469 7469 6f6e 7320 3d20 6765 .conditions = ge\n-00018cc0: 745f 6f62 6a76 2873 656c 662c 2027 636f t_objv(self, 'co\n-00018cd0: 6e64 6974 696f 6e73 272c 2043 6f6e 6469 nditions', Condi\n-00018ce0: 7469 6f6e 290a 0a20 2020 2020 2020 2023 tion).. #\n-00018cf0: 2053 6b69 7020 7665 7273 696f 6e20 6368 Skip version ch\n-00018d00: 6563 6b20 7768 656e 2072 756e 6e69 6e67 eck when running\n-00018d10: 206f 7574 206f 6620 7468 6520 6769 7420 out of the git \n-00018d20: 6368 6563 6b6f 7574 2028 434f 434b 5049 checkout (COCKPI\n-00018d30: 545f 5645 5253 494f 4e20 6973 204e 6f6e T_VERSION is Non\n-00018d40: 6529 0a20 2020 2020 2020 2069 6620 7365 e). if se\n-00018d50: 6c66 2e43 4f43 4b50 4954 5f56 4552 5349 lf.COCKPIT_VERSI\n-00018d60: 4f4e 2069 7320 6e6f 7420 4e6f 6e65 3a0a ON is not None:.\n-00018d70: 2020 2020 2020 2020 2020 2020 7265 7175 requ\n-00018d80: 6972 6573 203d 2067 6574 5f64 6963 7428 ires = get_dict(\n-00018d90: 7365 6c66 2c20 2772 6571 7569 7265 7327 self, 'requires'\n-00018da0: 2c20 7b7d 290a 2020 2020 2020 2020 2020 , {}). \n-00018db0: 2020 666f 7220 6e61 6d65 2c20 7665 7273 for name, vers\n-00018dc0: 696f 6e20 696e 2072 6571 7569 7265 732e ion in requires.\n-00018dd0: 6974 656d 7328 293a 0a20 2020 2020 2020 items():. \n-00018de0: 2020 2020 2020 2020 2069 6620 6e61 6d65 if name\n-00018df0: 2021 3d20 2763 6f63 6b70 6974 273a 0a20 != 'cockpit':. \n-00018e00: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00018e10: 2020 2072 6169 7365 204a 736f 6e45 7272 raise JsonErr\n-00018e20: 6f72 286e 616d 652c 2027 6e6f 6e2d 636f or(name, 'non-co\n-00018e30: 636b 7069 7420 7265 7175 6972 656d 656e ckpit requiremen\n-00018e40: 7420 6c69 7374 6564 2729 0a20 2020 2020 t listed'). \n-00018e50: 2020 2020 2020 2020 2020 2069 6620 736f if so\n-00018e60: 7274 6966 795f 7665 7273 696f 6e28 7479 rtify_version(ty\n-00018e70: 7065 6368 6563 6b65 6428 7665 7273 696f pechecked(versio\n-00018e80: 6e2c 2073 7472 2929 203e 2073 656c 662e n, str)) > self.\n-00018e90: 434f 434b 5049 545f 5645 5253 494f 4e3a COCKPIT_VERSION:\n-00018ea0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-00018eb0: 2020 2020 2072 6169 7365 204a 736f 6e45 raise JsonE\n-00018ec0: 7272 6f72 2876 6572 7369 6f6e 2c20 6627 rror(version, f'\n-00018ed0: 7265 7175 6972 6564 2063 6f63 6b70 6974 required cockpit\n-00018ee0: 2076 6572 7369 6f6e 2028 7b76 6572 7369 version ({versi\n-00018ef0: 6f6e 7d29 206e 6f74 206d 6574 2729 0a0a on}) not met')..\n-00018f00: 0a63 6c61 7373 2050 6163 6b61 6765 3a0a .class Package:.\n-00018f10: 2020 2020 2320 466f 7220 706f 7b2c 2e6d # For po{,.m\n-00018f20: 616e 6966 6573 747d 2e6a 7320 6669 6c65 anifest}.js file\n-00018f30: 732c 2074 6865 2069 6e74 6572 6573 7469 s, the interesti\n-00018f40: 6e67 2070 6172 7420 6973 2074 6865 206c ng part is the l\n-00018f50: 6f63 616c 6520 6e61 6d65 0a20 2020 2050 ocale name. P\n-00018f60: 4f5f 4a53 5f52 453a 2043 6c61 7373 5661 O_JS_RE: ClassVa\n-00018f70: 725b 5061 7474 6572 6e5d 203d 2072 652e r[Pattern] = re.\n-00018f80: 636f 6d70 696c 6528 7227 2870 6f7c 706f compile(r'(po|po\n-00018f90: 5c2e 6d61 6e69 6665 7374 295c 2e28 5b5e \\.manifest)\\.([^\n-00018fa0: 2e5d 2b29 5c2e 6a73 285c 2e67 7a29 3f27 .]+)\\.js(\\.gz)?'\n-00018fb0: 290a 0a20 2020 2023 2069 6d6d 7574 6162 ).. # immutab\n-00018fc0: 6c65 2061 6674 6572 205f 5f69 6e69 745f le after __init_\n-00018fd0: 5f0a 2020 2020 6d61 6e69 6665 7374 3a20 _. manifest: \n-00018fe0: 4d61 6e69 6665 7374 0a20 2020 206e 616d Manifest. nam\n-00018ff0: 653a 2073 7472 0a20 2020 2070 6174 683a e: str. path:\n-00019000: 2050 6174 680a 2020 2020 7072 696f 7269 Path. priori\n-00019010: 7479 3a20 696e 740a 0a20 2020 2023 2063 ty: int.. # c\n-00019020: 6f6d 7075 7465 6420 6c61 7465 720a 2020 omputed later. \n-00019030: 2020 7472 616e 736c 6174 696f 6e73 3a20 translations: \n-00019040: 4f70 7469 6f6e 616c 5b44 6963 745b 7374 Optional[Dict[st\n-00019050: 722c 2044 6963 745b 7374 722c 2073 7472 r, Dict[str, str\n-00019060: 5d5d 5d20 3d20 4e6f 6e65 0a20 2020 2066 ]]] = None. f\n-00019070: 696c 6573 3a20 4f70 7469 6f6e 616c 5b44 iles: Optional[D\n-00019080: 6963 745b 7374 722c 2073 7472 5d5d 203d ict[str, str]] =\n-00019090: 204e 6f6e 650a 0a20 2020 2064 6566 205f None.. def _\n-000190a0: 5f69 6e69 745f 5f28 7365 6c66 2c20 6d61 _init__(self, ma\n-000190b0: 6e69 6665 7374 3a20 4d61 6e69 6665 7374 nifest: Manifest\n-000190c0: 293a 0a20 2020 2020 2020 2073 656c 662e ):. self.\n-000190d0: 6d61 6e69 6665 7374 203d 206d 616e 6966 manifest = manif\n-000190e0: 6573 740a 2020 2020 2020 2020 7365 6c66 est. self\n-000190f0: 2e6e 616d 6520 3d20 6d61 6e69 6665 7374 .name = manifest\n-00019100: 2e6e 616d 650a 2020 2020 2020 2020 7365 .name. se\n-00019110: 6c66 2e70 6174 6820 3d20 6d61 6e69 6665 lf.path = manife\n-00019120: 7374 2e70 6174 680a 2020 2020 2020 2020 st.path. \n-00019130: 7365 6c66 2e70 7269 6f72 6974 7920 3d20 self.priority = \n-00019140: 6d61 6e69 6665 7374 2e70 7269 6f72 6974 manifest.priorit\n-00019150: 790a 0a20 2020 2064 6566 2065 6e73 7572 y.. def ensur\n-00019160: 655f 7363 616e 6e65 6428 7365 6c66 2920 e_scanned(self) \n-00019170: 2d3e 204e 6f6e 653a 0a20 2020 2020 2020 -> None:. \n-00019180: 2022 2222 456e 7375 7265 2074 6861 7420 \"\"\"Ensure that \n-00019190: 7468 6520 7061 636b 6167 6520 6861 7320 the package has \n-000191a0: 6265 656e 2073 6361 6e6e 6564 2e0a 0a20 been scanned... \n-000191b0: 2020 2020 2020 2054 6869 7320 616c 6c6f This allo\n-000191c0: 7773 2075 7320 746f 2064 6566 6572 2073 ws us to defer s\n-000191d0: 6361 6e6e 696e 6720 7468 6520 6669 6c65 canning the file\n-000191e0: 7320 6f66 2074 6865 2070 6163 6b61 6765 s of the package\n-000191f0: 2075 6e74 696c 2077 6520 6b6e 6f77 0a20 until we know. \n-00019200: 2020 2020 2020 2074 6861 7420 7765 276c that we'l\n-00019210: 6c20 6163 7475 616c 6c79 2075 7365 2069 l actually use i\n-00019220: 742e 0a20 2020 2020 2020 2022 2222 0a0a t.. \"\"\"..\n-00019230: 2020 2020 2020 2020 6966 2073 656c 662e if self.\n-00019240: 6669 6c65 7320 6973 206e 6f74 204e 6f6e files is not Non\n-00019250: 653a 0a20 2020 2020 2020 2020 2020 2072 e:. r\n-00019260: 6574 7572 6e0a 0a20 2020 2020 2020 2073 eturn.. s\n-00019270: 656c 662e 6669 6c65 7320 3d20 7b7d 0a20 elf.files = {}. \n-00019280: 2020 2020 2020 2073 656c 662e 7472 616e self.tran\n-00019290: 736c 6174 696f 6e73 203d 207b 2770 6f2e slations = {'po.\n-000192a0: 6a73 273a 207b 7d2c 2027 706f 2e6d 616e js': {}, 'po.man\n-000192b0: 6966 6573 742e 6a73 273a 207b 7d7d 0a0a ifest.js': {}}..\n-000192c0: 2020 2020 2020 2020 666f 7220 6669 6c65 for file\n-000192d0: 2069 6e20 7365 6c66 2e70 6174 682e 7267 in self.path.rg\n-000192e0: 6c6f 6228 272a 2729 3a0a 2020 2020 2020 lob('*'):. \n-000192f0: 2020 2020 2020 6e61 6d65 203d 2073 7472 name = str\n-00019300: 2866 696c 652e 7265 6c61 7469 7665 5f74 (file.relative_t\n-00019310: 6f28 7365 6c66 2e70 6174 6829 290a 2020 o(self.path)). \n-00019320: 2020 2020 2020 2020 2020 6966 206e 616d if nam\n-00019330: 6520 696e 205b 272e 272c 2027 2e2e 272c e in ['.', '..',\n-00019340: 2027 6d61 6e69 6665 7374 2e6a 736f 6e27 'manifest.json'\n-00019350: 5d3a 0a20 2020 2020 2020 2020 2020 2020 ]:. \n-00019360: 2020 2063 6f6e 7469 6e75 650a 0a20 2020 continue.. \n-00019370: 2020 2020 2020 2020 2070 6f5f 6d61 7463 po_matc\n-00019380: 6820 3d20 5061 636b 6167 652e 504f 5f4a h = Package.PO_J\n-00019390: 535f 5245 2e66 756c 6c6d 6174 6368 286e S_RE.fullmatch(n\n-000193a0: 616d 6529 0a20 2020 2020 2020 2020 2020 ame). \n-000193b0: 2069 6620 706f 5f6d 6174 6368 3a0a 2020 if po_match:. \n-000193c0: 2020 2020 2020 2020 2020 2020 2020 6261 ba\n-000193d0: 7365 6e61 6d65 203d 2070 6f5f 6d61 7463 sename = po_matc\n-000193e0: 682e 6772 6f75 7028 3129 0a20 2020 2020 h.group(1). \n-000193f0: 2020 2020 2020 2020 2020 206c 6f63 616c local\n-00019400: 6520 3d20 706f 5f6d 6174 6368 2e67 726f e = po_match.gro\n-00019410: 7570 2832 290a 2020 2020 2020 2020 2020 up(2). \n-00019420: 2020 2020 2020 2320 4163 6365 7074 2d4c # Accept-L\n-00019430: 616e 6775 6167 6520 6973 2063 6173 652d anguage is case-\n-00019440: 696e 7365 6e73 6974 6976 6520 616e 6420 insensitive and \n-00019450: 7573 6573 2027 2d27 2074 6f20 7365 7061 uses '-' to sepa\n-00019460: 7261 7465 2076 6172 6961 6e74 730a 2020 rate variants. \n-00019470: 2020 2020 2020 2020 2020 2020 2020 6c6f lo\n-00019480: 7765 725f 6c6f 6361 6c65 203d 206c 6f63 wer_locale = loc\n-00019490: 616c 652e 6c6f 7765 7228 292e 7265 706c ale.lower().repl\n-000194a0: 6163 6528 275f 272c 2027 2d27 290a 0a20 ace('_', '-').. \n-000194b0: 2020 2020 2020 2020 2020 2020 2020 206c l\n-000194c0: 6f67 6765 722e 6465 6275 6728 2741 6464 ogger.debug('Add\n-000194d0: 696e 6720 7472 616e 736c 6174 696f 6e20 ing translation \n-000194e0: 2572 2025 7220 2d3e 2025 7227 2c20 6261 %r %r -> %r', ba\n-000194f0: 7365 6e61 6d65 2c20 6c6f 7765 725f 6c6f sename, lower_lo\n-00019500: 6361 6c65 2c20 6e61 6d65 290a 2020 2020 cale, name). \n-00019510: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n-00019520: 2e74 7261 6e73 6c61 7469 6f6e 735b 6627 .translations[f'\n-00019530: 7b62 6173 656e 616d 657d 2e6a 7327 5d5b {basename}.js'][\n-00019540: 6c6f 7765 725f 6c6f 6361 6c65 5d20 3d20 lower_locale] = \n-00019550: 6e61 6d65 0a20 2020 2020 2020 2020 2020 name. \n-00019560: 2065 6c73 653a 0a20 2020 2020 2020 2020 else:. \n-00019570: 2020 2020 2020 2023 2073 7472 6970 206f # strip o\n-00019580: 7574 2074 7261 696c 696e 6720 272e 677a ut trailing '.gz\n-00019590: 2720 636f 6d70 6f6e 656e 7473 0a20 2020 ' components. \n-000195a0: 2020 2020 2020 2020 2020 2020 2062 6173 bas\n-000195b0: 656e 616d 6520 3d20 7265 2e73 7562 2827 ename = re.sub('\n-000195c0: 2e67 7a24 272c 2027 272c 206e 616d 6529 .gz$', '', name)\n-000195d0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-000195e0: 206c 6f67 6765 722e 6465 6275 6728 2741 logger.debug('A\n-000195f0: 6464 696e 6720 636f 6e74 656e 7420 2572 dding content %r\n-00019600: 202d 3e20 2572 272c 2062 6173 656e 616d -> %r', basenam\n-00019610: 652c 206e 616d 6529 0a20 2020 2020 2020 e, name). \n-00019620: 2020 2020 2020 2020 2073 656c 662e 6669 self.fi\n-00019630: 6c65 735b 6261 7365 6e61 6d65 5d20 3d20 les[basename] = \n-00019640: 6e61 6d65 0a0a 2020 2020 2020 2020 2020 name.. \n-00019650: 2020 2020 2020 2320 4966 2077 6520 7365 # If we se\n-00019660: 6520 6120 6669 6c65 6e61 6d65 206c 696b e a filename lik\n-00019670: 6520 6078 2e6d 696e 2e6a 7360 2077 6520 e `x.min.js` we \n-00019680: 7761 6e74 2074 6f20 616c 736f 206f 6666 want to also off\n-00019690: 6572 2069 740a 2020 2020 2020 2020 2020 er it. \n-000196a0: 2020 2020 2020 2320 6174 2060 782e 6a73 # at `x.js\n-000196b0: 602c 2062 7574 206f 6e6c 7920 6966 2060 `, but only if `\n-000196c0: 782e 6a73 282e 677a 2960 2069 7473 656c x.js(.gz)` itsel\n-000196d0: 6620 6973 206e 6f74 2070 7265 7365 6e74 f is not present\n-000196e0: 2e0a 2020 2020 2020 2020 2020 2020 2020 .. \n-000196f0: 2020 2320 4e6f 7465 3a20 7468 6973 2077 # Note: this w\n-00019700: 6f72 6b73 2066 6f72 2062 6f74 6820 7468 orks for both th\n-00019710: 6520 6361 7365 2077 6865 7265 2077 6520 e case where we \n-00019720: 666f 756e 6420 7468 6520 6078 2e6a 7360 found the `x.js`\n-00019730: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-00019740: 2023 2066 6972 7374 2028 6974 2773 2061 # first (it's a\n-00019750: 6c72 6561 6479 2069 6e20 7468 6520 6d61 lready in the ma\n-00019760: 7029 2061 6e64 2061 6c73 6f20 6966 2077 p) and also if w\n-00019770: 6520 6669 6e64 2069 7420 7365 636f 6e64 e find it second\n-00019780: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-00019790: 2023 2028 6974 2077 696c 6c20 6265 2072 # (it will be r\n-000197a0: 6570 6c61 6365 6420 696e 2074 6865 206d eplaced in the m\n-000197b0: 6170 2062 7920 7468 6520 6c69 6e65 206a ap by the line j\n-000197c0: 7573 7420 6162 6f76 6529 2e0a 2020 2020 ust above).. \n-000197d0: 2020 2020 2020 2020 2020 2020 2320 5365 # Se\n-000197e0: 6520 6874 7470 733a 2f2f 6769 7468 7562 e https://github\n-000197f0: 2e63 6f6d 2f63 6f63 6b70 6974 2d70 726f .com/cockpit-pro\n-00019800: 6a65 6374 2f63 6f63 6b70 6974 2f70 756c ject/cockpit/pul\n-00019810: 6c2f 3139 3731 360a 2020 2020 2020 2020 l/19716. \n-00019820: 2020 2020 2020 2020 7365 6c66 2e66 696c self.fil\n-00019830: 6573 2e73 6574 6465 6661 756c 7428 6261 es.setdefault(ba\n-00019840: 7365 6e61 6d65 2e72 6570 6c61 6365 2827 sename.replace('\n-00019850: 2e6d 696e 2e27 2c20 272e 2729 2c20 6e61 .min.', '.'), na\n-00019860: 6d65 290a 0a20 2020 2020 2020 2023 2073 me).. # s\n-00019870: 7570 706f 7274 206f 6c64 2063 6f63 6b70 upport old cockp\n-00019880: 6974 2d70 6f2d 706c 7567 696e 2077 6869 it-po-plugin whi\n-00019890: 6368 2064 6964 6e27 7420 7772 6974 6520 ch didn't write \n-000198a0: 706f 2e6d 616e 6966 6573 742e 3f3f 2e6a po.manifest.??.j\n-000198b0: 730a 2020 2020 2020 2020 6966 206e 6f74 s. if not\n-000198c0: 2073 656c 662e 7472 616e 736c 6174 696f self.translatio\n-000198d0: 6e73 5b27 706f 2e6d 616e 6966 6573 742e ns['po.manifest.\n-000198e0: 6a73 275d 3a0a 2020 2020 2020 2020 2020 js']:. \n-000198f0: 2020 7365 6c66 2e74 7261 6e73 6c61 7469 self.translati\n-00019900: 6f6e 735b 2770 6f2e 6d61 6e69 6665 7374 ons['po.manifest\n-00019910: 2e6a 7327 5d20 3d20 7365 6c66 2e74 7261 .js'] = self.tra\n-00019920: 6e73 6c61 7469 6f6e 735b 2770 6f2e 6a73 nslations['po.js\n-00019930: 275d 0a0a 2020 2020 6465 6620 6765 745f '].. def get_\n-00019940: 636f 6e74 656e 745f 7365 6375 7269 7479 content_security\n-00019950: 5f70 6f6c 6963 7928 7365 6c66 2920 2d3e _policy(self) ->\n-00019960: 2073 7472 3a0a 2020 2020 2020 2020 706f str:. po\n-00019970: 6c69 6379 203d 207b 0a20 2020 2020 2020 licy = {. \n-00019980: 2020 2020 2022 6465 6661 756c 742d 7372 \"default-sr\n-00019990: 6322 3a20 2227 7365 6c66 2722 2c0a 2020 c\": \"'self'\",. \n-000199a0: 2020 2020 2020 2020 2020 2263 6f6e 6e65 \"conne\n-000199b0: 6374 2d73 7263 223a 2022 2773 656c 6627 ct-src\": \"'self'\n-000199c0: 222c 0a20 2020 2020 2020 2020 2020 2022 \",. \"\n-000199d0: 666f 726d 2d61 6374 696f 6e22 3a20 2227 form-action\": \"'\n-000199e0: 7365 6c66 2722 2c0a 2020 2020 2020 2020 self'\",. \n-000199f0: 2020 2020 2262 6173 652d 7572 6922 3a20 \"base-uri\": \n-00019a00: 2227 7365 6c66 2722 2c0a 2020 2020 2020 \"'self'\",. \n-00019a10: 2020 2020 2020 226f 626a 6563 742d 7372 \"object-sr\n-00019a20: 6322 3a20 2227 6e6f 6e65 2722 2c0a 2020 c\": \"'none'\",. \n-00019a30: 2020 2020 2020 2020 2020 2266 6f6e 742d \"font-\n-00019a40: 7372 6322 3a20 2227 7365 6c66 2720 6461 src\": \"'self' da\n-00019a50: 7461 3a22 2c0a 2020 2020 2020 2020 2020 ta:\",. \n-00019a60: 2020 2269 6d67 2d73 7263 223a 2022 2773 \"img-src\": \"'s\n-00019a70: 656c 6627 2064 6174 613a 222c 0a20 2020 elf' data:\",. \n-00019a80: 2020 2020 207d 0a0a 2020 2020 2020 2020 }.. \n-00019a90: 666f 7220 6974 656d 2069 6e20 7365 6c66 for item in self\n-00019aa0: 2e6d 616e 6966 6573 742e 6373 702e 7370 .manifest.csp.sp\n-00019ab0: 6c69 7428 273b 2729 3a0a 2020 2020 2020 lit(';'):. \n-00019ac0: 2020 2020 2020 6974 656d 203d 2069 7465 item = ite\n-00019ad0: 6d2e 7374 7269 7028 290a 2020 2020 2020 m.strip(). \n-00019ae0: 2020 2020 2020 6966 2069 7465 6d3a 0a20 if item:. \n-00019af0: 2020 2020 2020 2020 2020 2020 2020 206b k\n-00019b00: 6579 2c20 5f2c 2076 616c 7565 203d 2069 ey, _, value = i\n-00019b10: 7465 6d2e 7374 7269 7028 292e 7061 7274 tem.strip().part\n-00019b20: 6974 696f 6e28 2720 2729 0a20 2020 2020 ition(' '). \n-00019b30: 2020 2020 2020 2020 2020 2070 6f6c 6963 polic\n-00019b40: 795b 6b65 795d 203d 2076 616c 7565 0a0a y[key] = value..\n-00019b50: 2020 2020 2020 2020 7265 7475 726e 2027 return '\n-00019b60: 2027 2e6a 6f69 6e28 6627 7b6b 7d20 7b76 '.join(f'{k} {v\n-00019b70: 7d3b 2720 666f 7220 6b2c 2076 2069 6e20 };' for k, v in \n-00019b80: 706f 6c69 6379 2e69 7465 6d73 2829 2920 policy.items()) \n-00019b90: 2b20 2720 626c 6f63 6b2d 616c 6c2d 6d69 + ' block-all-mi\n-00019ba0: 7865 642d 636f 6e74 656e 7427 0a0a 2020 xed-content'.. \n-00019bb0: 2020 6465 6620 6c6f 6164 5f66 696c 6528 def load_file(\n-00019bc0: 7365 6c66 2c20 6669 6c65 6e61 6d65 3a20 self, filename: \n-00019bd0: 7374 7229 202d 3e20 446f 6375 6d65 6e74 str) -> Document\n-00019be0: 3a0a 2020 2020 2020 2020 636f 6e74 656e :. conten\n-00019bf0: 745f 7479 7065 2c20 636f 6e74 656e 745f t_type, content_\n-00019c00: 656e 636f 6469 6e67 203d 206d 696d 6574 encoding = mimet\n-00019c10: 7970 6573 2e67 7565 7373 5f74 7970 6528 ypes.guess_type(\n-00019c20: 6669 6c65 6e61 6d65 290a 2020 2020 2020 filename). \n-00019c30: 2020 636f 6e74 656e 745f 7365 6375 7269 content_securi\n-00019c40: 7479 5f70 6f6c 6963 7920 3d20 4e6f 6e65 ty_policy = None\n-00019c50: 0a0a 2020 2020 2020 2020 6966 2063 6f6e .. if con\n-00019c60: 7465 6e74 5f74 7970 6520 6973 204e 6f6e tent_type is Non\n-00019c70: 653a 0a20 2020 2020 2020 2020 2020 2063 e:. c\n-00019c80: 6f6e 7465 6e74 5f74 7970 6520 3d20 2774 ontent_type = 't\n-00019c90: 6578 742f 706c 6169 6e27 0a20 2020 2020 ext/plain'. \n-00019ca0: 2020 2065 6c69 6620 636f 6e74 656e 745f elif content_\n-00019cb0: 7479 7065 2e73 7461 7274 7377 6974 6828 type.startswith(\n-00019cc0: 2774 6578 742f 6874 6d6c 2729 3a0a 2020 'text/html'):. \n-00019cd0: 2020 2020 2020 2020 2020 636f 6e74 656e conten\n-00019ce0: 745f 7365 6375 7269 7479 5f70 6f6c 6963 t_security_polic\n-00019cf0: 7920 3d20 7365 6c66 2e67 6574 5f63 6f6e y = self.get_con\n-00019d00: 7465 6e74 5f73 6563 7572 6974 795f 706f tent_security_po\n-00019d10: 6c69 6379 2829 0a0a 2020 2020 2020 2020 licy().. \n-00019d20: 7061 7468 203d 2073 656c 662e 7061 7468 path = self.path\n-00019d30: 202f 2066 696c 656e 616d 650a 2020 2020 / filename. \n-00019d40: 2020 2020 6c6f 6767 6572 2e64 6562 7567 logger.debug\n-00019d50: 2827 2020 6c6f 6164 696e 6720 6461 7461 (' loading data\n-00019d60: 2066 726f 6d20 2573 272c 2070 6174 6829 from %s', path)\n-00019d70: 0a0a 2020 2020 2020 2020 7265 7475 726e .. return\n-00019d80: 2044 6f63 756d 656e 7428 7061 7468 2e6f Document(path.o\n-00019d90: 7065 6e28 2772 6227 292c 2063 6f6e 7465 pen('rb'), conte\n-00019da0: 6e74 5f74 7970 652c 2063 6f6e 7465 6e74 nt_type, content\n-00019db0: 5f65 6e63 6f64 696e 672c 2063 6f6e 7465 _encoding, conte\n-00019dc0: 6e74 5f73 6563 7572 6974 795f 706f 6c69 nt_security_poli\n-00019dd0: 6379 290a 0a20 2020 2064 6566 206c 6f61 cy).. def loa\n-00019de0: 645f 7472 616e 736c 6174 696f 6e28 7365 d_translation(se\n-00019df0: 6c66 2c20 7061 7468 3a20 7374 722c 206c lf, path: str, l\n-00019e00: 6f63 616c 6573 3a20 5365 7175 656e 6365 ocales: Sequence\n-00019e10: 5b73 7472 5d29 202d 3e20 446f 6375 6d65 [str]) -> Docume\n-00019e20: 6e74 3a0a 2020 2020 2020 2020 7365 6c66 nt:. self\n-00019e30: 2e65 6e73 7572 655f 7363 616e 6e65 6428 .ensure_scanned(\n-00019e40: 290a 2020 2020 2020 2020 6173 7365 7274 ). assert\n-00019e50: 2073 656c 662e 7472 616e 736c 6174 696f self.translatio\n-00019e60: 6e73 2069 7320 6e6f 7420 4e6f 6e65 0a0a ns is not None..\n-00019e70: 2020 2020 2020 2020 2320 4669 7273 7420 # First \n-00019e80: 6d61 7463 6820 7769 6e73 0a20 2020 2020 match wins. \n-00019e90: 2020 2066 6f72 206c 6f63 616c 6520 696e for locale in\n-00019ea0: 206c 6f63 616c 6573 3a0a 2020 2020 2020 locales:. \n-00019eb0: 2020 2020 2020 7769 7468 2063 6f6e 7465 with conte\n-00019ec0: 7874 6c69 622e 7375 7070 7265 7373 284b xtlib.suppress(K\n-00019ed0: 6579 4572 726f 7229 3a0a 2020 2020 2020 eyError):. \n-00019ee0: 2020 2020 2020 2020 2020 7265 7475 726e return\n-00019ef0: 2073 656c 662e 6c6f 6164 5f66 696c 6528 self.load_file(\n-00019f00: 7365 6c66 2e74 7261 6e73 6c61 7469 6f6e self.translation\n-00019f10: 735b 7061 7468 5d5b 6c6f 6361 6c65 5d29 s[path][locale])\n-00019f20: 0a0a 2020 2020 2020 2020 2320 5765 2070 .. # We p\n-00019f30: 7265 6665 7220 746f 2072 6574 7572 6e20 refer to return \n-00019f40: 616e 2065 6d70 7479 2064 6f63 756d 656e an empty documen\n-00019f50: 7420 7468 616e 2034 3034 2069 6e20 6f72 t than 404 in or\n-00019f60: 6465 7220 746f 2061 766f 6964 0a20 2020 der to avoid. \n-00019f70: 2020 2020 2023 2065 7272 6f72 7320 696e # errors in\n-00019f80: 2074 6865 2063 6f6e 736f 6c65 2077 6865 the console whe\n-00019f90: 6e20 6120 7472 616e 736c 6174 696f 6e20 n a translation \n-00019fa0: 6361 6e27 7420 6265 2066 6f75 6e64 0a20 can't be found. \n-00019fb0: 2020 2020 2020 2072 6574 7572 6e20 446f return Do\n-00019fc0: 6375 6d65 6e74 2869 6f2e 4279 7465 7349 cument(io.BytesI\n-00019fd0: 4f28 292c 2027 7465 7874 2f6a 6176 6173 O(), 'text/javas\n-00019fe0: 6372 6970 7427 290a 0a20 2020 2064 6566 cript').. def\n-00019ff0: 206c 6f61 645f 7061 7468 2873 656c 662c load_path(self,\n-0001a000: 2070 6174 683a 2073 7472 2c20 6865 6164 path: str, head\n-0001a010: 6572 733a 204a 736f 6e4f 626a 6563 7429 ers: JsonObject)\n-0001a020: 202d 3e20 446f 6375 6d65 6e74 3a0a 2020 -> Document:. \n-0001a030: 2020 2020 2020 7365 6c66 2e65 6e73 7572 self.ensur\n-0001a040: 655f 7363 616e 6e65 6428 290a 2020 2020 e_scanned(). \n-0001a050: 2020 2020 6173 7365 7274 2073 656c 662e assert self.\n-0001a060: 6669 6c65 7320 6973 206e 6f74 204e 6f6e files is not Non\n-0001a070: 650a 2020 2020 2020 2020 6173 7365 7274 e. assert\n-0001a080: 2073 656c 662e 7472 616e 736c 6174 696f self.translatio\n-0001a090: 6e73 2069 7320 6e6f 7420 4e6f 6e65 0a0a ns is not None..\n-0001a0a0: 2020 2020 2020 2020 6966 2070 6174 6820 if path \n-0001a0b0: 696e 2073 656c 662e 7472 616e 736c 6174 in self.translat\n-0001a0c0: 696f 6e73 3a0a 2020 2020 2020 2020 2020 ions:. \n-0001a0d0: 2020 6c6f 6361 6c65 7320 3d20 7061 7273 locales = pars\n-0001a0e0: 655f 6163 6365 7074 5f6c 616e 6775 6167 e_accept_languag\n-0001a0f0: 6528 6765 745f 7374 7228 6865 6164 6572 e(get_str(header\n-0001a100: 732c 2027 4163 6365 7074 2d4c 616e 6775 s, 'Accept-Langu\n-0001a110: 6167 6527 2c20 2727 2929 0a20 2020 2020 age', '')). \n-0001a120: 2020 2020 2020 2072 6574 7572 6e20 7365 return se\n-0001a130: 6c66 2e6c 6f61 645f 7472 616e 736c 6174 lf.load_translat\n-0001a140: 696f 6e28 7061 7468 2c20 6c6f 6361 6c65 ion(path, locale\n-0001a150: 7329 0a20 2020 2020 2020 2065 6c73 653a s). else:\n-0001a160: 0a20 2020 2020 2020 2020 2020 2072 6574 . ret\n-0001a170: 7572 6e20 7365 6c66 2e6c 6f61 645f 6669 urn self.load_fi\n-0001a180: 6c65 2873 656c 662e 6669 6c65 735b 7061 le(self.files[pa\n-0001a190: 7468 5d29 0a0a 0a63 6c61 7373 2050 6163 th])...class Pac\n-0001a1a0: 6b61 6765 734c 6f61 6465 723a 0a20 2020 kagesLoader:. \n-0001a1b0: 2043 4f4e 4449 5449 4f4e 533a 2043 6c61 CONDITIONS: Cla\n-0001a1c0: 7373 5661 725b 4469 6374 5b73 7472 2c20 ssVar[Dict[str, \n-0001a1d0: 4361 6c6c 6162 6c65 5b5b 7374 725d 2c20 Callable[[str], \n-0001a1e0: 626f 6f6c 5d5d 5d20 3d20 7b0a 2020 2020 bool]]] = {. \n-0001a1f0: 2020 2020 2770 6174 682d 6578 6973 7473 'path-exists\n-0001a200: 273a 206f 732e 7061 7468 2e65 7869 7374 ': os.path.exist\n-0001a210: 732c 0a20 2020 2020 2020 2027 7061 7468 s,. 'path\n-0001a220: 2d6e 6f74 2d65 7869 7374 7327 3a20 6c61 -not-exists': la\n-0001a230: 6d62 6461 2070 3a20 6e6f 7420 6f73 2e70 mbda p: not os.p\n-0001a240: 6174 682e 6578 6973 7473 2870 292c 0a20 ath.exists(p),. \n-0001a250: 2020 207d 0a0a 2020 2020 4063 6c61 7373 }.. @class\n-0001a260: 6d65 7468 6f64 0a20 2020 2064 6566 2067 method. def g\n-0001a270: 6574 5f78 6467 5f64 6174 615f 6469 7273 et_xdg_data_dirs\n-0001a280: 2863 6c73 2920 2d3e 2049 7465 7261 626c (cls) -> Iterabl\n-0001a290: 655b 7374 725d 3a0a 2020 2020 2020 2020 e[str]:. \n-0001a2a0: 7472 793a 0a20 2020 2020 2020 2020 2020 try:. \n-0001a2b0: 2079 6965 6c64 206f 732e 656e 7669 726f yield os.enviro\n-0001a2c0: 6e5b 2758 4447 5f44 4154 415f 484f 4d45 n['XDG_DATA_HOME\n-0001a2d0: 275d 0a20 2020 2020 2020 2065 7863 6570 ']. excep\n-0001a2e0: 7420 4b65 7945 7272 6f72 3a0a 2020 2020 t KeyError:. \n-0001a2f0: 2020 2020 2020 2020 7969 656c 6420 6f73 yield os\n-0001a300: 2e70 6174 682e 6578 7061 6e64 7573 6572 .path.expanduser\n-0001a310: 2827 7e2f 2e6c 6f63 616c 2f73 6861 7265 ('~/.local/share\n-0001a320: 2729 0a0a 2020 2020 2020 2020 7472 793a ').. try:\n-0001a330: 0a20 2020 2020 2020 2020 2020 2079 6965 . yie\n-0001a340: 6c64 2066 726f 6d20 6f73 2e65 6e76 6972 ld from os.envir\n-0001a350: 6f6e 5b27 5844 475f 4441 5441 5f44 4952 on['XDG_DATA_DIR\n-0001a360: 5327 5d2e 7370 6c69 7428 273a 2729 0a20 S'].split(':'). \n-0001a370: 2020 2020 2020 2065 7863 6570 7420 4b65 except Ke\n-0001a380: 7945 7272 6f72 3a0a 2020 2020 2020 2020 yError:. \n-0001a390: 2020 2020 7969 656c 6420 6672 6f6d 2028 yield from (\n-0001a3a0: 272f 7573 722f 6c6f 6361 6c2f 7368 6172 '/usr/local/shar\n-0001a3b0: 6527 2c20 272f 7573 722f 7368 6172 6527 e', '/usr/share'\n-0001a3c0: 290a 0a20 2020 2040 636c 6173 736d 6574 ).. @classmet\n-0001a3d0: 686f 640a 2020 2020 6465 6620 7061 7463 hod. def patc\n-0001a3e0: 685f 6d61 6e69 6665 7374 2863 6c73 2c20 h_manifest(cls, \n-0001a3f0: 6d61 6e69 6665 7374 3a20 4a73 6f6e 4f62 manifest: JsonOb\n-0001a400: 6a65 6374 2c20 7061 7265 6e74 3a20 5061 ject, parent: Pa\n-0001a410: 7468 2920 2d3e 204a 736f 6e4f 626a 6563 th) -> JsonObjec\n-0001a420: 743a 0a20 2020 2020 2020 206f 7665 7272 t:. overr\n-0001a430: 6964 655f 6669 6c65 7320 3d20 5b0a 2020 ide_files = [. \n-0001a440: 2020 2020 2020 2020 2020 7061 7265 6e74 parent\n-0001a450: 202f 2027 6f76 6572 7269 6465 2e6a 736f / 'override.jso\n-0001a460: 6e27 2c0a 2020 2020 2020 2020 2020 2020 n',. \n-0001a470: 636f 6e66 6967 2e6c 6f6f 6b75 705f 636f config.lookup_co\n-0001a480: 6e66 6967 2866 277b 7061 7265 6e74 2e6e nfig(f'{parent.n\n-0001a490: 616d 657d 2e6f 7665 7272 6964 652e 6a73 ame}.override.js\n-0001a4a0: 6f6e 2729 2c0a 2020 2020 2020 2020 2020 on'),. \n-0001a4b0: 2020 636f 6e66 6967 2e44 4f54 5f43 4f4e config.DOT_CON\n-0001a4c0: 4649 475f 434f 434b 5049 5420 2f20 6627 FIG_COCKPIT / f'\n-0001a4d0: 7b70 6172 656e 742e 6e61 6d65 7d2e 6f76 {parent.name}.ov\n-0001a4e0: 6572 7269 6465 2e6a 736f 6e27 2c0a 2020 erride.json',. \n-0001a4f0: 2020 2020 2020 5d0a 0a20 2020 2020 2020 ].. \n-0001a500: 2066 6f72 206f 7665 7272 6964 655f 6669 for override_fi\n-0001a510: 6c65 2069 6e20 6f76 6572 7269 6465 5f66 le in override_f\n-0001a520: 696c 6573 3a0a 2020 2020 2020 2020 2020 iles:. \n-0001a530: 2020 7472 793a 0a20 2020 2020 2020 2020 try:. \n-0001a540: 2020 2020 2020 206f 7665 7272 6964 653a override:\n-0001a550: 204a 736f 6e56 616c 7565 203d 206a 736f JsonValue = jso\n-0001a560: 6e2e 6c6f 6164 7328 6f76 6572 7269 6465 n.loads(override\n-0001a570: 5f66 696c 652e 7265 6164 5f62 7974 6573 _file.read_bytes\n-0001a580: 2829 290a 2020 2020 2020 2020 2020 2020 ()). \n-0001a590: 6578 6365 7074 2046 696c 654e 6f74 466f except FileNotFo\n-0001a5a0: 756e 6445 7272 6f72 3a0a 2020 2020 2020 undError:. \n-0001a5b0: 2020 2020 2020 2020 2020 636f 6e74 696e contin\n-0001a5c0: 7565 0a20 2020 2020 2020 2020 2020 2065 ue. e\n-0001a5d0: 7863 6570 7420 6a73 6f6e 2e4a 534f 4e44 xcept json.JSOND\n-0001a5e0: 6563 6f64 6545 7272 6f72 2061 7320 6578 ecodeError as ex\n-0001a5f0: 633a 0a20 2020 2020 2020 2020 2020 2020 c:. \n-0001a600: 2020 2023 2055 7365 7220 696e 7075 7420 # User input \n-0001a610: 6572 726f 723a 2072 6570 6f72 7420 6120 error: report a \n-0001a620: 7761 726e 696e 670a 2020 2020 2020 2020 warning. \n-0001a630: 2020 2020 2020 2020 6c6f 6767 6572 2e77 logger.w\n-0001a640: 6172 6e69 6e67 2827 2573 3a20 2573 272c arning('%s: %s',\n-0001a650: 206f 7665 7272 6964 655f 6669 6c65 2c20 override_file, \n-0001a660: 6578 6329 0a0a 2020 2020 2020 2020 2020 exc).. \n-0001a670: 2020 6966 206e 6f74 2069 7369 6e73 7461 if not isinsta\n-0001a680: 6e63 6528 6f76 6572 7269 6465 2c20 6469 nce(override, di\n-0001a690: 6374 293a 0a20 2020 2020 2020 2020 2020 ct):. \n-0001a6a0: 2020 2020 206c 6f67 6765 722e 7761 726e logger.warn\n-0001a6b0: 696e 6728 2725 733a 206f 7665 7272 6964 ing('%s: overrid\n-0001a6c0: 6520 6669 6c65 2069 7320 6e6f 7420 6120 e file is not a \n-0001a6d0: 6469 6374 696f 6e61 7279 272c 206f 7665 dictionary', ove\n-0001a6e0: 7272 6964 655f 6669 6c65 290a 2020 2020 rride_file). \n-0001a6f0: 2020 2020 2020 2020 2020 2020 636f 6e74 cont\n-0001a700: 696e 7565 0a0a 2020 2020 2020 2020 2020 inue.. \n-0001a710: 2020 6d61 6e69 6665 7374 203d 206a 736f manifest = jso\n-0001a720: 6e5f 6d65 7267 655f 7061 7463 6828 6d61 n_merge_patch(ma\n-0001a730: 6e69 6665 7374 2c20 6f76 6572 7269 6465 nifest, override\n-0001a740: 290a 0a20 2020 2020 2020 2072 6574 7572 ).. retur\n-0001a750: 6e20 7061 7463 685f 6c69 6265 7865 6364 n patch_libexecd\n-0001a760: 6972 286d 616e 6966 6573 7429 0a0a 2020 ir(manifest).. \n-0001a770: 2020 4063 6c61 7373 6d65 7468 6f64 0a20 @classmethod. \n-0001a780: 2020 2064 6566 206c 6f61 645f 6d61 6e69 def load_mani\n-0001a790: 6665 7374 7328 636c 7329 202d 3e20 4974 fests(cls) -> It\n-0001a7a0: 6572 6162 6c65 5b4d 616e 6966 6573 745d erable[Manifest]\n-0001a7b0: 3a0a 2020 2020 2020 2020 666f 7220 6461 :. for da\n-0001a7c0: 7461 6469 7220 696e 2063 6c73 2e67 6574 tadir in cls.get\n-0001a7d0: 5f78 6467 5f64 6174 615f 6469 7273 2829 _xdg_data_dirs()\n-0001a7e0: 3a0a 2020 2020 2020 2020 2020 2020 6c6f :. lo\n-0001a7f0: 6767 6572 2e64 6562 7567 2822 5363 616e gger.debug(\"Scan\n-0001a800: 6e69 6e67 2066 6f72 206d 616e 6966 6573 ning for manifes\n-0001a810: 7420 6669 6c65 7320 756e 6465 7220 2573 t files under %s\n-0001a820: 222c 2064 6174 6164 6972 290a 2020 2020 \", datadir). \n-0001a830: 2020 2020 2020 2020 666f 7220 6669 6c65 for file\n-0001a840: 2069 6e20 5061 7468 2864 6174 6164 6972 in Path(datadir\n-0001a850: 292e 676c 6f62 2827 636f 636b 7069 742f ).glob('cockpit/\n-0001a860: 2a2f 6d61 6e69 6665 7374 2e6a 736f 6e27 */manifest.json'\n-0001a870: 293a 0a20 2020 2020 2020 2020 2020 2020 ):. \n-0001a880: 2020 206c 6f67 6765 722e 6465 6275 6728 logger.debug(\n-0001a890: 2243 6f6e 7369 6465 7269 6e67 2066 696c \"Considering fil\n-0001a8a0: 6520 2573 222c 2066 696c 6529 0a20 2020 e %s\", file). \n-0001a8b0: 2020 2020 2020 2020 2020 2020 2074 7279 try\n-0001a8c0: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n-0001a8d0: 2020 2020 2020 6d61 6e69 6665 7374 203d manifest =\n-0001a8e0: 206a 736f 6e2e 6c6f 6164 7328 6669 6c65 json.loads(file\n-0001a8f0: 2e72 6561 645f 7465 7874 2829 290a 2020 .read_text()). \n-0001a900: 2020 2020 2020 2020 2020 2020 2020 6578 ex\n-0001a910: 6365 7074 206a 736f 6e2e 4a53 4f4e 4465 cept json.JSONDe\n-0001a920: 636f 6465 4572 726f 7220 6173 2065 7863 codeError as exc\n-0001a930: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n-0001a940: 2020 2020 2020 6c6f 6767 6572 2e65 7272 logger.err\n-0001a950: 6f72 2822 2573 3a20 2573 222c 2066 696c or(\"%s: %s\", fil\n-0001a960: 652c 2065 7863 290a 2020 2020 2020 2020 e, exc). \n-0001a970: 2020 2020 2020 2020 2020 2020 636f 6e74 cont\n-0001a980: 696e 7565 0a20 2020 2020 2020 2020 2020 inue. \n-0001a990: 2020 2020 2069 6620 6e6f 7420 6973 696e if not isin\n-0001a9a0: 7374 616e 6365 286d 616e 6966 6573 742c stance(manifest,\n-0001a9b0: 2064 6963 7429 3a0a 2020 2020 2020 2020 dict):. \n-0001a9c0: 2020 2020 2020 2020 2020 2020 6c6f 6767 logg\n-0001a9d0: 6572 2e65 7272 6f72 2822 2573 3a20 6a73 er.error(\"%s: js\n-0001a9e0: 6f6e 2064 6f63 756d 656e 7420 6973 6e27 on document isn'\n-0001a9f0: 7420 616e 206f 626a 6563 7422 2c20 6669 t an object\", fi\n-0001aa00: 6c65 290a 2020 2020 2020 2020 2020 2020 le). \n-0001aa10: 2020 2020 2020 2020 636f 6e74 696e 7565 continue\n-0001aa20: 0a0a 2020 2020 2020 2020 2020 2020 2020 .. \n-0001aa30: 2020 7061 7265 6e74 203d 2066 696c 652e parent = file.\n-0001aa40: 7061 7265 6e74 0a20 2020 2020 2020 2020 parent. \n-0001aa50: 2020 2020 2020 206d 616e 6966 6573 7420 manifest \n-0001aa60: 3d20 636c 732e 7061 7463 685f 6d61 6e69 = cls.patch_mani\n-0001aa70: 6665 7374 286d 616e 6966 6573 742c 2070 fest(manifest, p\n-0001aa80: 6172 656e 7429 0a20 2020 2020 2020 2020 arent). \n-0001aa90: 2020 2020 2020 2074 7279 3a0a 2020 2020 try:. \n-0001aaa0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0001aab0: 7969 656c 6420 4d61 6e69 6665 7374 2870 yield Manifest(p\n-0001aac0: 6172 656e 742c 206d 616e 6966 6573 7429 arent, manifest)\n-0001aad0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-0001aae0: 2065 7863 6570 7420 4a73 6f6e 4572 726f except JsonErro\n-0001aaf0: 7220 6173 2065 7863 3a0a 2020 2020 2020 r as exc:. \n-0001ab00: 2020 2020 2020 2020 2020 2020 2020 6c6f lo\n-0001ab10: 6767 6572 2e77 6172 6e69 6e67 2827 2573 gger.warning('%s\n-0001ab20: 2025 7327 2c20 6669 6c65 2c20 6578 6329 %s', file, exc)\n-0001ab30: 0a0a 2020 2020 6465 6620 6368 6563 6b5f .. def check_\n-0001ab40: 636f 6e64 6974 696f 6e28 7365 6c66 2c20 condition(self, \n-0001ab50: 636f 6e64 6974 696f 6e3a 2073 7472 2c20 condition: str, \n-0001ab60: 7661 6c75 653a 206f 626a 6563 7429 202d value: object) -\n-0001ab70: 3e20 626f 6f6c 3a0a 2020 2020 2020 2020 > bool:. \n-0001ab80: 6368 6563 6b5f 666e 203d 2073 656c 662e check_fn = self.\n-0001ab90: 434f 4e44 4954 494f 4e53 5b63 6f6e 6469 CONDITIONS[condi\n-0001aba0: 7469 6f6e 5d0a 0a20 2020 2020 2020 2023 tion].. #\n-0001abb0: 2041 6c6c 206b 6e6f 776e 2070 7265 6469 All known predi\n-0001abc0: 6361 7465 7320 6375 7272 656e 746c 7920 cates currently \n-0001abd0: 6f6e 6c79 2077 6f72 6b20 6f6e 2073 7472 only work on str\n-0001abe0: 696e 6773 0a20 2020 2020 2020 2069 6620 ings. if \n-0001abf0: 6e6f 7420 6973 696e 7374 616e 6365 2876 not isinstance(v\n-0001ac00: 616c 7565 2c20 7374 7229 3a0a 2020 2020 alue, str):. \n-0001ac10: 2020 2020 2020 2020 7265 7475 726e 2046 return F\n-0001ac20: 616c 7365 0a0a 2020 2020 2020 2020 7265 alse.. re\n-0001ac30: 7475 726e 2063 6865 636b 5f66 6e28 7661 turn check_fn(va\n-0001ac40: 6c75 6529 0a0a 2020 2020 6465 6620 6368 lue).. def ch\n-0001ac50: 6563 6b5f 636f 6e64 6974 696f 6e73 2873 eck_conditions(s\n-0001ac60: 656c 662c 206d 616e 6966 6573 743a 204d elf, manifest: M\n-0001ac70: 616e 6966 6573 7429 202d 3e20 626f 6f6c anifest) -> bool\n-0001ac80: 3a0a 2020 2020 2020 2020 666f 7220 636f :. for co\n-0001ac90: 6e64 6974 696f 6e20 696e 206d 616e 6966 ndition in manif\n-0001aca0: 6573 742e 636f 6e64 6974 696f 6e73 3a0a est.conditions:.\n-0001acb0: 2020 2020 2020 2020 2020 2020 7472 793a try:\n-0001acc0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-0001acd0: 206f 6b61 7920 3d20 7365 6c66 2e63 6865 okay = self.che\n-0001ace0: 636b 5f63 6f6e 6469 7469 6f6e 2863 6f6e ck_condition(con\n-0001acf0: 6469 7469 6f6e 2e6e 616d 652c 2063 6f6e dition.name, con\n-0001ad00: 6469 7469 6f6e 2e76 616c 7565 290a 2020 dition.value). \n-0001ad10: 2020 2020 2020 2020 2020 6578 6365 7074 except\n-0001ad20: 204b 6579 4572 726f 723a 0a20 2020 2020 KeyError:. \n-0001ad30: 2020 2020 2020 2020 2020 2023 2064 6f20 # do \n-0001ad40: 2a6e 6f74 2a20 6967 6e6f 7265 206d 616e *not* ignore man\n-0001ad50: 6966 6573 7473 2077 6974 6820 756e 6b6e ifests with unkn\n-0001ad60: 6f77 6e20 7072 6564 6963 6174 6573 2c20 own predicates, \n-0001ad70: 666f 7220 666f 7277 6172 6420 636f 6d70 for forward comp\n-0001ad80: 6174 6962 696c 6974 790a 2020 2020 2020 atibility. \n-0001ad90: 2020 2020 2020 2020 2020 6c6f 6767 6572 logger\n-0001ada0: 2e77 6172 6e69 6e67 2827 2020 2573 3a20 .warning(' %s: \n-0001adb0: 6967 6e6f 7269 6e67 2075 6e6b 6e6f 776e ignoring unknown\n-0001adc0: 2070 7265 6469 6361 7465 2069 6e20 6d61 predicate in ma\n-0001add0: 6e69 6665 7374 3a20 2573 272c 206d 616e nifest: %s', man\n-0001ade0: 6966 6573 742e 7061 7468 2c20 636f 6e64 ifest.path, cond\n-0001adf0: 6974 696f 6e2e 6e61 6d65 290a 2020 2020 ition.name). \n-0001ae00: 2020 2020 2020 2020 2020 2020 636f 6e74 cont\n-0001ae10: 696e 7565 0a0a 2020 2020 2020 2020 2020 inue.. \n-0001ae20: 2020 6966 206e 6f74 206f 6b61 793a 0a20 if not okay:. \n-0001ae30: 2020 2020 2020 2020 2020 2020 2020 206c l\n-0001ae40: 6f67 6765 722e 6465 6275 6728 2720 2068 ogger.debug(' h\n-0001ae50: 6964 696e 6720 7061 636b 6167 6520 2573 iding package %s\n-0001ae60: 2061 7320 6974 7320 2573 2063 6f6e 6469 as its %s condi\n-0001ae70: 7469 6f6e 2069 7320 6e6f 7420 6d65 7427 tion is not met'\n-0001ae80: 2c20 6d61 6e69 6665 7374 2e70 6174 682c , manifest.path,\n-0001ae90: 2063 6f6e 6469 7469 6f6e 290a 2020 2020 condition). \n-0001aea0: 2020 2020 2020 2020 2020 2020 7265 7475 retu\n-0001aeb0: 726e 2046 616c 7365 0a0a 2020 2020 2020 rn False.. \n-0001aec0: 2020 7265 7475 726e 2054 7275 650a 0a20 return True.. \n-0001aed0: 2020 2064 6566 206c 6f61 645f 7061 636b def load_pack\n-0001aee0: 6167 6573 2873 656c 6629 202d 3e20 4974 ages(self) -> It\n-0001aef0: 6572 6162 6c65 5b54 7570 6c65 5b73 7472 erable[Tuple[str\n-0001af00: 2c20 5061 636b 6167 655d 5d3a 0a20 2020 , Package]]:. \n-0001af10: 2020 2020 206c 6f67 6765 722e 6465 6275 logger.debu\n-0001af20: 6728 2753 6361 6e6e 696e 6720 666f 7220 g('Scanning for \n-0001af30: 6176 6169 6c61 626c 6520 7061 636b 6167 available packag\n-0001af40: 6520 6d61 6e69 6665 7374 733a 2729 0a20 e manifests:'). \n-0001af50: 2020 2020 2020 2023 2053 6f72 7420 616c # Sort al\n-0001af60: 6c20 6176 6169 6c61 626c 6520 7061 636b l available pack\n-0001af70: 6167 6573 2069 6e74 6f20 6275 636b 6574 ages into bucket\n-0001af80: 7320 6279 2074 6f20 7468 6569 7220 636c s by to their cl\n-0001af90: 6169 6d65 6420 6e61 6d65 0a20 2020 2020 aimed name. \n-0001afa0: 2020 206e 616d 6573 3a20 4469 6374 5b73 names: Dict[s\n-0001afb0: 7472 2c20 4c69 7374 5b4d 616e 6966 6573 tr, List[Manifes\n-0001afc0: 745d 5d20 3d20 636f 6c6c 6563 7469 6f6e t]] = collection\n-0001afd0: 732e 6465 6661 756c 7464 6963 7428 6c69 s.defaultdict(li\n-0001afe0: 7374 290a 2020 2020 2020 2020 666f 7220 st). for \n-0001aff0: 6d61 6e69 6665 7374 2069 6e20 7365 6c66 manifest in self\n-0001b000: 2e6c 6f61 645f 6d61 6e69 6665 7374 7328 .load_manifests(\n-0001b010: 293a 0a20 2020 2020 2020 2020 2020 206c ):. l\n-0001b020: 6f67 6765 722e 6465 6275 6728 2720 2025 ogger.debug(' %\n-0001b030: 732f 6d61 6e69 6665 7374 2e6a 736f 6e27 s/manifest.json'\n-0001b040: 2c20 6d61 6e69 6665 7374 2e70 6174 6829 , manifest.path)\n-0001b050: 0a20 2020 2020 2020 2020 2020 206e 616d . nam\n-0001b060: 6573 5b6d 616e 6966 6573 742e 6e61 6d65 es[manifest.name\n-0001b070: 5d2e 6170 7065 6e64 286d 616e 6966 6573 ].append(manifes\n-0001b080: 7429 0a20 2020 2020 2020 206c 6f67 6765 t). logge\n-0001b090: 722e 6465 6275 6728 2764 6f6e 652e 2729 r.debug('done.')\n-0001b0a0: 0a0a 2020 2020 2020 2020 6c6f 6767 6572 .. logger\n-0001b0b0: 2e64 6562 7567 2827 5365 6c65 6374 696e .debug('Selectin\n-0001b0c0: 6720 7061 636b 6167 6573 2074 6f20 7365 g packages to se\n-0001b0d0: 7276 653a 2729 0a20 2020 2020 2020 2066 rve:'). f\n-0001b0e0: 6f72 206e 616d 652c 2063 616e 6469 6461 or name, candida\n-0001b0f0: 7465 7320 696e 206e 616d 6573 2e69 7465 tes in names.ite\n-0001b100: 6d73 2829 3a0a 2020 2020 2020 2020 2020 ms():. \n-0001b110: 2020 2320 466f 7220 6561 6368 2070 6163 # For each pac\n-0001b120: 6b61 6765 206e 616d 652c 2069 7465 7261 kage name, itera\n-0001b130: 7465 2074 6865 2063 616e 6469 6461 7465 te the candidate\n-0001b140: 7320 696e 2064 6573 6365 6e64 696e 670a s in descending.\n-0001b150: 2020 2020 2020 2020 2020 2020 2320 7072 # pr\n-0001b160: 696f 7269 7479 206f 7264 6572 2061 6e64 iority order and\n-0001b170: 2073 656c 6563 7420 7468 6520 6669 7273 select the firs\n-0001b180: 7420 6f6e 6520 7768 6963 6820 7061 7373 t one which pass\n-0001b190: 6573 2061 6c6c 2063 6865 636b 730a 2020 es all checks. \n-0001b1a0: 2020 2020 2020 2020 2020 666f 7220 6361 for ca\n-0001b1b0: 6e64 6964 6174 6520 696e 2073 6f72 7465 ndidate in sorte\n-0001b1c0: 6428 6361 6e64 6964 6174 6573 2c20 6b65 d(candidates, ke\n-0001b1d0: 793d 6c61 6d62 6461 206d 616e 6966 6573 y=lambda manifes\n-0001b1e0: 743a 206d 616e 6966 6573 742e 7072 696f t: manifest.prio\n-0001b1f0: 7269 7479 2c20 7265 7665 7273 653d 5472 rity, reverse=Tr\n-0001b200: 7565 293a 0a20 2020 2020 2020 2020 2020 ue):. \n-0001b210: 2020 2020 2074 7279 3a0a 2020 2020 2020 try:. \n-0001b220: 2020 2020 2020 2020 2020 2020 2020 6966 if\n-0001b230: 2073 656c 662e 6368 6563 6b5f 636f 6e64 self.check_cond\n-0001b240: 6974 696f 6e73 2863 616e 6469 6461 7465 itions(candidate\n-0001b250: 293a 0a20 2020 2020 2020 2020 2020 2020 ):. \n-0001b260: 2020 2020 2020 2020 2020 206c 6f67 6765 logge\n-0001b270: 722e 6465 6275 6728 2720 2063 7265 6174 r.debug(' creat\n-0001b280: 696e 6720 7061 636b 6167 6520 2573 202d ing package %s -\n-0001b290: 3e20 2573 272c 206e 616d 652c 2063 616e > %s', name, can\n-0001b2a0: 6469 6461 7465 2e70 6174 6829 0a20 2020 didate.path). \n-0001b2b0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0001b2c0: 2020 2020 2079 6965 6c64 206e 616d 652c yield name,\n-0001b2d0: 2050 6163 6b61 6765 2863 616e 6469 6461 Package(candida\n-0001b2e0: 7465 290a 2020 2020 2020 2020 2020 2020 te). \n-0001b2f0: 2020 2020 2020 2020 2020 2020 6272 6561 brea\n-0001b300: 6b0a 2020 2020 2020 2020 2020 2020 2020 k. \n-0001b310: 2020 6578 6365 7074 204a 736f 6e45 7272 except JsonErr\n-0001b320: 6f72 3a0a 2020 2020 2020 2020 2020 2020 or:. \n-0001b330: 2020 2020 2020 2020 6c6f 6767 6572 2e77 logger.w\n-0001b340: 6172 6e69 6e67 2827 2020 2573 3a20 6967 arning(' %s: ig\n-0001b350: 6e6f 7269 6e67 2070 6163 6b61 6765 2077 noring package w\n-0001b360: 6974 6820 696e 7661 6c69 6420 6d61 6e69 ith invalid mani\n-0001b370: 6665 7374 2066 696c 6527 2c20 6361 6e64 fest file', cand\n-0001b380: 6964 6174 652e 7061 7468 290a 0a20 2020 idate.path).. \n-0001b390: 2020 2020 2020 2020 2020 2020 206c 6f67 log\n-0001b3a0: 6765 722e 6465 6275 6728 2720 2069 676e ger.debug(' ign\n-0001b3b0: 6f72 696e 6720 2573 3a20 756e 6d65 7420 oring %s: unmet \n-0001b3c0: 636f 6e64 6974 696f 6e73 272c 2063 616e conditions', can\n-0001b3d0: 6469 6461 7465 2e70 6174 6829 0a20 2020 didate.path). \n-0001b3e0: 2020 2020 206c 6f67 6765 722e 6465 6275 logger.debu\n-0001b3f0: 6728 2764 6f6e 652e 2729 0a0a 0a63 6c61 g('done.')...cla\n-0001b400: 7373 2050 6163 6b61 6765 7328 6275 732e ss Packages(bus.\n-0001b410: 4f62 6a65 6374 2c20 696e 7465 7266 6163 Object, interfac\n-0001b420: 653d 2763 6f63 6b70 6974 2e50 6163 6b61 e='cockpit.Packa\n-0001b430: 6765 7327 293a 0a20 2020 206c 6f61 6465 ges'):. loade\n-0001b440: 723a 2050 6163 6b61 6765 734c 6f61 6465 r: PackagesLoade\n-0001b450: 720a 2020 2020 6c69 7374 656e 6572 3a20 r. listener: \n-0001b460: 4f70 7469 6f6e 616c 5b50 6163 6b61 6765 Optional[Package\n-0001b470: 734c 6973 7465 6e65 725d 0a20 2020 2070 sListener]. p\n-0001b480: 6163 6b61 6765 733a 2044 6963 745b 7374 ackages: Dict[st\n-0001b490: 722c 2050 6163 6b61 6765 5d0a 2020 2020 r, Package]. \n-0001b4a0: 7361 775f 6669 7273 745f 7265 6c6f 6164 saw_first_reload\n-0001b4b0: 5f68 696e 743a 2062 6f6f 6c0a 0a20 2020 _hint: bool.. \n-0001b4c0: 2064 6566 205f 5f69 6e69 745f 5f28 7365 def __init__(se\n-0001b4d0: 6c66 2c20 6c69 7374 656e 6572 3a20 4f70 lf, listener: Op\n-0001b4e0: 7469 6f6e 616c 5b50 6163 6b61 6765 734c tional[PackagesL\n-0001b4f0: 6973 7465 6e65 725d 203d 204e 6f6e 652c istener] = None,\n-0001b500: 206c 6f61 6465 723a 204f 7074 696f 6e61 loader: Optiona\n-0001b510: 6c5b 5061 636b 6167 6573 4c6f 6164 6572 l[PackagesLoader\n-0001b520: 5d20 3d20 4e6f 6e65 293a 0a20 2020 2020 ] = None):. \n-0001b530: 2020 2073 656c 662e 6c69 7374 656e 6572 self.listener\n-0001b540: 203d 206c 6973 7465 6e65 720a 2020 2020 = listener. \n-0001b550: 2020 2020 7365 6c66 2e6c 6f61 6465 7220 self.loader \n-0001b560: 3d20 6c6f 6164 6572 206f 7220 5061 636b = loader or Pack\n-0001b570: 6167 6573 4c6f 6164 6572 2829 0a20 2020 agesLoader(). \n-0001b580: 2020 2020 2073 656c 662e 6c6f 6164 2829 self.load()\n-0001b590: 0a0a 2020 2020 2020 2020 2320 5265 6c6f .. # Relo\n-0001b5a0: 6164 696e 6720 7468 6520 5368 656c 6c20 ading the Shell \n-0001b5b0: 696e 2074 6865 2062 726f 7773 6572 2073 in the browser s\n-0001b5c0: 686f 756c 6420 7265 6c6f 6164 2074 6865 hould reload the\n-0001b5d0: 0a20 2020 2020 2020 2023 2070 6163 6b61 . # packa\n-0001b5e0: 6765 732e 2020 5468 6973 2069 7320 696d ges. This is im\n-0001b5f0: 706c 656d 656e 7465 6420 6279 2068 6176 plemented by hav\n-0001b600: 696e 6720 7468 6520 5368 656c 6c20 6361 ing the Shell ca\n-0001b610: 6c6c 0a20 2020 2020 2020 2023 2072 656c ll. # rel\n-0001b620: 6f61 645f 6869 6e74 2077 6865 6e65 7665 oad_hint wheneve\n-0001b630: 7220 6974 2073 7461 7274 732e 2020 5468 r it starts. Th\n-0001b640: 6520 6669 7273 7420 6361 6c6c 206f 6620 e first call of \n-0001b650: 7468 6973 0a20 2020 2020 2020 2023 206d this. # m\n-0001b660: 6574 686f 6420 696e 2065 6163 6820 7365 ethod in each se\n-0001b670: 7373 696f 6e20 6973 2069 676e 6f72 6564 ssion is ignored\n-0001b680: 2073 6f20 7468 6174 2070 6163 6b61 6765 so that package\n-0001b690: 7320 6172 6520 6e6f 740a 2020 2020 2020 s are not. \n-0001b6a0: 2020 2320 6c6f 6164 6564 2074 7769 6365 # loaded twice\n-0001b6b0: 2072 6967 6874 2061 6674 6572 206c 6f67 right after log\n-0001b6c0: 6769 6e67 2069 6e2e 0a20 2020 2020 2020 ging in.. \n-0001b6d0: 2023 0a20 2020 2020 2020 2073 656c 662e #. self.\n-0001b6e0: 7361 775f 6669 7273 745f 7265 6c6f 6164 saw_first_reload\n-0001b6f0: 5f68 696e 7420 3d20 4661 6c73 650a 0a20 _hint = False.. \n-0001b700: 2020 2064 6566 206c 6f61 6428 7365 6c66 def load(self\n-0001b710: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n-0001b720: 2020 2073 656c 662e 7061 636b 6167 6573 self.packages\n-0001b730: 203d 2064 6963 7428 7365 6c66 2e6c 6f61 = dict(self.loa\n-0001b740: 6465 722e 6c6f 6164 5f70 6163 6b61 6765 der.load_package\n-0001b750: 7328 2929 0a20 2020 2020 2020 2073 656c s()). sel\n-0001b760: 662e 6d61 6e69 6665 7374 7320 3d20 6a73 f.manifests = js\n-0001b770: 6f6e 2e64 756d 7073 287b 6e61 6d65 3a20 on.dumps({name: \n-0001b780: 6469 6374 2870 6163 6b61 6765 2e6d 616e dict(package.man\n-0001b790: 6966 6573 7429 2066 6f72 206e 616d 652c ifest) for name,\n-0001b7a0: 2070 6163 6b61 6765 2069 6e20 7365 6c66 package in self\n-0001b7b0: 2e70 6163 6b61 6765 732e 6974 656d 7328 .packages.items(\n-0001b7c0: 297d 290a 2020 2020 2020 2020 6c6f 6767 )}). logg\n-0001b7d0: 6572 2e64 6562 7567 2827 5061 636b 6167 er.debug('Packag\n-0001b7e0: 6573 206c 6f61 6465 643a 2025 7327 2c20 es loaded: %s', \n-0001b7f0: 6c69 7374 2873 656c 662e 7061 636b 6167 list(self.packag\n-0001b800: 6573 2929 0a0a 2020 2020 6465 6620 7368 es)).. def sh\n-0001b810: 6f77 2873 656c 6629 3a0a 2020 2020 2020 ow(self):. \n-0001b820: 2020 666f 7220 6e61 6d65 2069 6e20 736f for name in so\n-0001b830: 7274 6564 2873 656c 662e 7061 636b 6167 rted(self.packag\n-0001b840: 6573 293a 0a20 2020 2020 2020 2020 2020 es):. \n-0001b850: 2070 6163 6b61 6765 203d 2073 656c 662e package = self.\n-0001b860: 7061 636b 6167 6573 5b6e 616d 655d 0a20 packages[name]. \n-0001b870: 2020 2020 2020 2020 2020 206d 656e 7569 menui\n-0001b880: 7465 6d73 203d 205b 5d0a 2020 2020 2020 tems = []. \n-0001b890: 2020 2020 2020 666f 7220 656e 7472 7920 for entry \n-0001b8a0: 696e 2069 7465 7274 6f6f 6c73 2e63 6861 in itertools.cha\n-0001b8b0: 696e 280a 2020 2020 2020 2020 2020 2020 in(. \n-0001b8c0: 2020 2020 2020 2020 7061 636b 6167 652e package.\n-0001b8d0: 6d61 6e69 6665 7374 2e67 6574 2827 6d65 manifest.get('me\n-0001b8e0: 6e75 272c 207b 7d29 2e76 616c 7565 7328 nu', {}).values(\n-0001b8f0: 292c 0a20 2020 2020 2020 2020 2020 2020 ),. \n-0001b900: 2020 2020 2020 2070 6163 6b61 6765 2e6d package.m\n-0001b910: 616e 6966 6573 742e 6765 7428 2774 6f6f anifest.get('too\n-0001b920: 6c73 272c 207b 7d29 2e76 616c 7565 7328 ls', {}).values(\n-0001b930: 2929 3a0a 2020 2020 2020 2020 2020 2020 )):. \n-0001b940: 2020 2020 7769 7468 2063 6f6e 7465 7874 with context\n-0001b950: 6c69 622e 7375 7070 7265 7373 284b 6579 lib.suppress(Key\n-0001b960: 4572 726f 7229 3a0a 2020 2020 2020 2020 Error):. \n-0001b970: 2020 2020 2020 2020 2020 2020 6d65 6e75 menu\n-0001b980: 6974 656d 732e 6170 7065 6e64 2865 6e74 items.append(ent\n-0001b990: 7279 5b27 6c61 6265 6c27 5d29 0a20 2020 ry['label']). \n-0001b9a0: 2020 2020 2020 2020 2070 7269 6e74 2866 print(f\n-0001b9b0: 277b 6e61 6d65 3a32 307d 207b 222c 2022 '{name:20} {\", \"\n-0001b9c0: 2e6a 6f69 6e28 6d65 6e75 6974 656d 7329 .join(menuitems)\n-0001b9d0: 3a34 307d 207b 7061 636b 6167 652e 7061 :40} {package.pa\n-0001b9e0: 7468 7d27 290a 0a20 2020 2064 6566 2067 th}').. def g\n-0001b9f0: 6574 5f62 7269 6467 655f 636f 6e66 6967 et_bridge_config\n-0001ba00: 7328 7365 6c66 2920 2d3e 2053 6571 7565 s(self) -> Seque\n-0001ba10: 6e63 655b 4272 6964 6765 436f 6e66 6967 nce[BridgeConfig\n-0001ba20: 5d3a 0a20 2020 2020 2020 2064 6566 2079 ]:. def y\n-0001ba30: 6965 6c64 5f63 6f6e 6669 6773 2829 3a0a ield_configs():.\n-0001ba40: 2020 2020 2020 2020 2020 2020 666f 7220 for \n-0001ba50: 7061 636b 6167 6520 696e 2073 6f72 7465 package in sorte\n-0001ba60: 6428 7365 6c66 2e70 6163 6b61 6765 732e d(self.packages.\n-0001ba70: 7661 6c75 6573 2829 2c20 6b65 793d 6c61 values(), key=la\n-0001ba80: 6d62 6461 2070 6163 6b61 6765 3a20 2d70 mbda package: -p\n-0001ba90: 6163 6b61 6765 2e70 7269 6f72 6974 7929 ackage.priority)\n-0001baa0: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n-0001bab0: 2020 7969 656c 6420 6672 6f6d 2070 6163 yield from pac\n-0001bac0: 6b61 6765 2e6d 616e 6966 6573 742e 6272 kage.manifest.br\n-0001bad0: 6964 6765 730a 2020 2020 2020 2020 7265 idges. re\n-0001bae0: 7475 726e 2074 7570 6c65 2879 6965 6c64 turn tuple(yield\n-0001baf0: 5f63 6f6e 6669 6773 2829 290a 0a20 2020 _configs()).. \n-0001bb00: 2023 2044 2d42 7573 2049 6e74 6572 6661 # D-Bus Interfa\n-0001bb10: 6365 0a20 2020 206d 616e 6966 6573 7473 ce. manifests\n-0001bb20: 203d 2062 7573 2e49 6e74 6572 6661 6365 = bus.Interface\n-0001bb30: 2e50 726f 7065 7274 7928 2773 272c 2076 .Property('s', v\n-0001bb40: 616c 7565 3d22 7b7d 2229 0a0a 2020 2020 alue=\"{}\").. \n-0001bb50: 4062 7573 2e49 6e74 6572 6661 6365 2e4d @bus.Interface.M\n-0001bb60: 6574 686f 6428 290a 2020 2020 6465 6620 ethod(). def \n-0001bb70: 7265 6c6f 6164 2873 656c 6629 3a0a 2020 reload(self):. \n-0001bb80: 2020 2020 2020 7365 6c66 2e6c 6f61 6428 self.load(\n-0001bb90: 290a 2020 2020 2020 2020 6966 2073 656c ). if sel\n-0001bba0: 662e 6c69 7374 656e 6572 2069 7320 6e6f f.listener is no\n-0001bbb0: 7420 4e6f 6e65 3a0a 2020 2020 2020 2020 t None:. \n-0001bbc0: 2020 2020 7365 6c66 2e6c 6973 7465 6e65 self.listene\n-0001bbd0: 722e 7061 636b 6167 6573 5f6c 6f61 6465 r.packages_loade\n-0001bbe0: 6428 290a 0a20 2020 2040 6275 732e 496e d().. @bus.In\n-0001bbf0: 7465 7266 6163 652e 4d65 7468 6f64 2829 terface.Method()\n-0001bc00: 0a20 2020 2064 6566 2072 656c 6f61 645f . def reload_\n-0001bc10: 6869 6e74 2873 656c 6629 3a0a 2020 2020 hint(self):. \n-0001bc20: 2020 2020 6966 2073 656c 662e 7361 775f if self.saw_\n-0001bc30: 6669 7273 745f 7265 6c6f 6164 5f68 696e first_reload_hin\n-0001bc40: 743a 0a20 2020 2020 2020 2020 2020 2073 t:. s\n-0001bc50: 656c 662e 7265 6c6f 6164 2829 0a20 2020 elf.reload(). \n-0001bc60: 2020 2020 2073 656c 662e 7361 775f 6669 self.saw_fi\n-0001bc70: 7273 745f 7265 6c6f 6164 5f68 696e 7420 rst_reload_hint \n-0001bc80: 3d20 5472 7565 0a0a 2020 2020 6465 6620 = True.. def \n-0001bc90: 6c6f 6164 5f6d 616e 6966 6573 7473 5f6a load_manifests_j\n-0001bca0: 7328 7365 6c66 2c20 6865 6164 6572 733a s(self, headers:\n-0001bcb0: 204a 736f 6e4f 626a 6563 7429 202d 3e20 JsonObject) -> \n-0001bcc0: 446f 6375 6d65 6e74 3a0a 2020 2020 2020 Document:. \n-0001bcd0: 2020 6c6f 6767 6572 2e64 6562 7567 2827 logger.debug('\n-0001bce0: 5365 7276 696e 6720 2f6d 616e 6966 6573 Serving /manifes\n-0001bcf0: 7473 2e6a 7327 290a 0a20 2020 2020 2020 ts.js').. \n-0001bd00: 2063 6875 6e6b 733a 204c 6973 745b 6279 chunks: List[by\n-0001bd10: 7465 735d 203d 205b 5d0a 0a20 2020 2020 tes] = [].. \n-0001bd20: 2020 2023 2053 656e 6420 7468 6520 7472 # Send the tr\n-0001bd30: 616e 736c 6174 696f 6e73 2072 6571 7569 anslations requi\n-0001bd40: 7265 6420 666f 7220 7468 6520 6d61 6e69 red for the mani\n-0001bd50: 6665 7374 2066 696c 6573 2c20 6672 6f6d fest files, from\n-0001bd60: 2065 6163 6820 7061 636b 6167 650a 2020 each package. \n-0001bd70: 2020 2020 2020 6c6f 6361 6c65 7320 3d20 locales = \n-0001bd80: 7061 7273 655f 6163 6365 7074 5f6c 616e parse_accept_lan\n-0001bd90: 6775 6167 6528 6765 745f 7374 7228 6865 guage(get_str(he\n-0001bda0: 6164 6572 732c 2027 4163 6365 7074 2d4c aders, 'Accept-L\n-0001bdb0: 616e 6775 6167 6527 2c20 2727 2929 0a20 anguage', '')). \n-0001bdc0: 2020 2020 2020 2066 6f72 206e 616d 652c for name,\n-0001bdd0: 2070 6163 6b61 6765 2069 6e20 7365 6c66 package in self\n-0001bde0: 2e70 6163 6b61 6765 732e 6974 656d 7328 .packages.items(\n-0001bdf0: 293a 0a20 2020 2020 2020 2020 2020 2069 ):. i\n-0001be00: 6620 6e61 6d65 2069 6e20 5b27 7374 6174 f name in ['stat\n-0001be10: 6963 272c 2027 6261 7365 3127 5d3a 0a20 ic', 'base1']:. \n-0001be20: 2020 2020 2020 2020 2020 2020 2020 2063 c\n-0001be30: 6f6e 7469 6e75 650a 0a20 2020 2020 2020 ontinue.. \n-0001be40: 2020 2020 2023 2066 696e 645f 7472 616e # find_tran\n-0001be50: 736c 6174 696f 6e20 7769 6c6c 2061 6c77 slation will alw\n-0001be60: 6179 7320 6669 6e64 2061 7420 6c65 6173 ays find at leas\n-0001be70: 7420 2765 6e27 0a20 2020 2020 2020 2020 t 'en'. \n-0001be80: 2020 2074 7261 6e73 6c61 7469 6f6e 203d translation =\n-0001be90: 2070 6163 6b61 6765 2e6c 6f61 645f 7472 package.load_tr\n-0001bea0: 616e 736c 6174 696f 6e28 2770 6f2e 6d61 anslation('po.ma\n-0001beb0: 6e69 6665 7374 2e6a 7327 2c20 6c6f 6361 nifest.js', loca\n-0001bec0: 6c65 7329 0a20 2020 2020 2020 2020 2020 les). \n-0001bed0: 2077 6974 6820 7472 616e 736c 6174 696f with translatio\n-0001bee0: 6e2e 6461 7461 3a0a 2020 2020 2020 2020 n.data:. \n-0001bef0: 2020 2020 2020 2020 6966 2074 7261 6e73 if trans\n-0001bf00: 6c61 7469 6f6e 2e63 6f6e 7465 6e74 5f65 lation.content_e\n-0001bf10: 6e63 6f64 696e 6720 3d3d 2027 677a 6970 ncoding == 'gzip\n-0001bf20: 273a 0a20 2020 2020 2020 2020 2020 2020 ':. \n-0001bf30: 2020 2020 2020 2064 6174 6120 3d20 677a data = gz\n-0001bf40: 6970 2e64 6563 6f6d 7072 6573 7328 7472 ip.decompress(tr\n-0001bf50: 616e 736c 6174 696f 6e2e 6461 7461 2e72 anslation.data.r\n-0001bf60: 6561 6428 2929 0a20 2020 2020 2020 2020 ead()). \n-0001bf70: 2020 2020 2020 2065 6c73 653a 0a20 2020 else:. \n-0001bf80: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0001bf90: 2064 6174 6120 3d20 7472 616e 736c 6174 data = translat\n-0001bfa0: 696f 6e2e 6461 7461 2e72 6561 6428 290a ion.data.read().\n-0001bfb0: 0a20 2020 2020 2020 2020 2020 2063 6875 . chu\n-0001bfc0: 6e6b 732e 6170 7065 6e64 2864 6174 6129 nks.append(data)\n-0001bfd0: 0a0a 2020 2020 2020 2020 6368 756e 6b73 .. chunks\n-0001bfe0: 2e61 7070 656e 6428 6222 2222 0a20 2020 .append(b\"\"\". \n-0001bff0: 2020 2020 2020 2020 2028 6675 6e63 7469 (functi\n-0001c000: 6f6e 2028 726f 6f74 2c20 6461 7461 2920 on (root, data) \n-0001c010: 7b0a 2020 2020 2020 2020 2020 2020 2020 {. \n-0001c020: 2020 6966 2028 7479 7065 6f66 2064 6566 if (typeof def\n-0001c030: 696e 6520 3d3d 3d20 2766 756e 6374 696f ine === 'functio\n-0001c040: 6e27 2026 2620 6465 6669 6e65 2e61 6d64 n' && define.amd\n-0001c050: 2920 7b0a 2020 2020 2020 2020 2020 2020 ) {. \n-0001c060: 2020 2020 2020 2020 6465 6669 6e65 2864 define(d\n-0001c070: 6174 6129 3b0a 2020 2020 2020 2020 2020 ata);. \n-0001c080: 2020 2020 2020 7d0a 0a20 2020 2020 2020 }.. \n-0001c090: 2020 2020 2020 2020 2069 6620 2874 7970 if (typ\n-0001c0a0: 656f 6620 636f 636b 7069 7420 3d3d 3d20 eof cockpit === \n-0001c0b0: 276f 626a 6563 7427 2920 7b0a 2020 2020 'object') {. \n-0001c0c0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0001c0d0: 636f 636b 7069 742e 6d61 6e69 6665 7374 cockpit.manifest\n-0001c0e0: 7320 3d20 6461 7461 3b0a 2020 2020 2020 s = data;. \n-0001c0f0: 2020 2020 2020 2020 2020 7d20 656c 7365 } else\n-0001c100: 207b 0a20 2020 2020 2020 2020 2020 2020 {. \n-0001c110: 2020 2020 2020 2072 6f6f 742e 6d61 6e69 root.mani\n-0001c120: 6665 7374 7320 3d20 6461 7461 3b0a 2020 fests = data;. \n-0001c130: 2020 2020 2020 2020 2020 2020 2020 7d0a }.\n-0001c140: 2020 2020 2020 2020 2020 2020 7d28 7468 }(th\n-0001c150: 6973 2c20 2222 2220 2b20 7365 6c66 2e6d is, \"\"\" + self.m\n-0001c160: 616e 6966 6573 7473 2e65 6e63 6f64 6528 anifests.encode(\n-0001c170: 2920 2b20 6222 2222 2929 2222 2229 0a0a ) + b\"\"\"))\"\"\")..\n-0001c180: 2020 2020 2020 2020 7265 7475 726e 2044 return D\n-0001c190: 6f63 756d 656e 7428 696f 2e42 7974 6573 ocument(io.Bytes\n-0001c1a0: 494f 2862 275c 6e27 2e6a 6f69 6e28 6368 IO(b'\\n'.join(ch\n-0001c1b0: 756e 6b73 2929 2c20 2774 6578 742f 6a61 unks)), 'text/ja\n-0001c1c0: 7661 7363 7269 7074 2729 0a0a 2020 2020 vascript').. \n-0001c1d0: 6465 6620 6c6f 6164 5f6d 616e 6966 6573 def load_manifes\n-0001c1e0: 7473 5f6a 736f 6e28 7365 6c66 2920 2d3e ts_json(self) ->\n-0001c1f0: 2044 6f63 756d 656e 743a 0a20 2020 2020 Document:. \n-0001c200: 2020 206c 6f67 6765 722e 6465 6275 6728 logger.debug(\n-0001c210: 2753 6572 7669 6e67 202f 6d61 6e69 6665 'Serving /manife\n-0001c220: 7374 732e 6a73 6f6e 2729 0a20 2020 2020 sts.json'). \n-0001c230: 2020 2072 6574 7572 6e20 446f 6375 6d65 return Docume\n-0001c240: 6e74 2869 6f2e 4279 7465 7349 4f28 7365 nt(io.BytesIO(se\n-0001c250: 6c66 2e6d 616e 6966 6573 7473 2e65 6e63 lf.manifests.enc\n-0001c260: 6f64 6528 2929 2c20 2761 7070 6c69 6361 ode()), 'applica\n-0001c270: 7469 6f6e 2f6a 736f 6e27 290a 0a20 2020 tion/json').. \n-0001c280: 2050 4154 485f 5245 203d 2072 652e 636f PATH_RE = re.co\n-0001c290: 6d70 696c 6528 0a20 2020 2020 2020 2072 mpile(. r\n-0001c2a0: 272f 2720 2020 2020 2020 2020 2020 2020 '/' \n-0001c2b0: 2020 2020 2020 2320 6c65 6164 696e 6720 # leading \n-0001c2c0: 272f 270a 2020 2020 2020 2020 7227 283f '/'. r'(?\n-0001c2d0: 3a28 5b5e 2f5d 2b29 2f29 3f27 2020 2020 :([^/]+)/)?' \n-0001c2e0: 2020 2023 206f 7074 696f 6e61 6c20 6c65 # optional le\n-0001c2f0: 6164 696e 6720 7061 7468 2063 6f6d 706f ading path compo\n-0001c300: 6e65 6e74 0a20 2020 2020 2020 2072 2728 nent. r'(\n-0001c310: 283f 3a5b 5e2f 5d2b 2f29 2a5b 5e2f 5d2b (?:[^/]+/)*[^/]+\n-0001c320: 2927 2020 2320 7265 6d61 696e 696e 6720 )' # remaining \n-0001c330: 7061 7468 2063 6f6d 706f 6e65 6e74 730a path components.\n-0001c340: 2020 2020 290a 0a20 2020 2064 6566 206c ).. def l\n-0001c350: 6f61 645f 7061 7468 2873 656c 662c 2070 oad_path(self, p\n-0001c360: 6174 683a 2073 7472 2c20 6865 6164 6572 ath: str, header\n-0001c370: 733a 204a 736f 6e4f 626a 6563 7429 202d s: JsonObject) -\n-0001c380: 3e20 446f 6375 6d65 6e74 3a0a 2020 2020 > Document:. \n-0001c390: 2020 2020 6c6f 6767 6572 2e64 6562 7567 logger.debug\n-0001c3a0: 2827 7061 636b 6167 6573 3a20 7365 7276 ('packages: serv\n-0001c3b0: 696e 6720 2573 272c 2070 6174 6829 0a0a ing %s', path)..\n-0001c3c0: 2020 2020 2020 2020 6d61 7463 6820 3d20 match = \n-0001c3d0: 7365 6c66 2e50 4154 485f 5245 2e66 756c self.PATH_RE.ful\n-0001c3e0: 6c6d 6174 6368 2870 6174 6829 0a20 2020 lmatch(path). \n-0001c3f0: 2020 2020 2069 6620 6d61 7463 6820 6973 if match is\n-0001c400: 204e 6f6e 653a 0a20 2020 2020 2020 2020 None:. \n-0001c410: 2020 2072 6169 7365 2056 616c 7565 4572 raise ValueEr\n-0001c420: 726f 7228 6627 496e 7661 6c69 6420 4854 ror(f'Invalid HT\n-0001c430: 5450 2070 6174 6820 7b70 6174 687d 2729 TP path {path}')\n-0001c440: 0a20 2020 2020 2020 2070 6163 6b61 6765 . package\n-0001c450: 6e61 6d65 2c20 6669 6c65 6e61 6d65 203d name, filename =\n-0001c460: 206d 6174 6368 2e67 726f 7570 7328 290a match.groups().\n-0001c470: 0a20 2020 2020 2020 2069 6620 7061 636b . if pack\n-0001c480: 6167 656e 616d 6520 6973 206e 6f74 204e agename is not N\n-0001c490: 6f6e 653a 0a20 2020 2020 2020 2020 2020 one:. \n-0001c4a0: 2072 6574 7572 6e20 7365 6c66 2e70 6163 return self.pac\n-0001c4b0: 6b61 6765 735b 7061 636b 6167 656e 616d kages[packagenam\n-0001c4c0: 655d 2e6c 6f61 645f 7061 7468 2866 696c e].load_path(fil\n-0001c4d0: 656e 616d 652c 2068 6561 6465 7273 290a ename, headers).\n-0001c4e0: 2020 2020 2020 2020 656c 6966 2066 696c elif fil\n-0001c4f0: 656e 616d 6520 3d3d 2027 6d61 6e69 6665 ename == 'manife\n-0001c500: 7374 732e 6a73 273a 0a20 2020 2020 2020 sts.js':. \n-0001c510: 2020 2020 2072 6574 7572 6e20 7365 6c66 return self\n-0001c520: 2e6c 6f61 645f 6d61 6e69 6665 7374 735f .load_manifests_\n-0001c530: 6a73 2868 6561 6465 7273 290a 2020 2020 js(headers). \n-0001c540: 2020 2020 656c 6966 2066 696c 656e 616d elif filenam\n-0001c550: 6520 3d3d 2027 6d61 6e69 6665 7374 732e e == 'manifests.\n-0001c560: 6a73 6f6e 273a 0a20 2020 2020 2020 2020 json':. \n-0001c570: 2020 2072 6574 7572 6e20 7365 6c66 2e6c return self.l\n-0001c580: 6f61 645f 6d61 6e69 6665 7374 735f 6a73 oad_manifests_js\n-0001c590: 6f6e 2829 0a20 2020 2020 2020 2065 6c73 on(). els\n-0001c5a0: 653a 0a20 2020 2020 2020 2020 2020 2072 e:. r\n-0001c5b0: 6169 7365 204b 6579 4572 726f 720a 2727 aise KeyError.''\n-0001c5c0: 272c 0a20 2027 636f 636b 7069 742f 696e ',. 'cockpit/in\n-0001c5d0: 7465 726e 616c 5f65 6e64 706f 696e 7473 ternal_endpoints\n-0001c5e0: 2e70 7927 3a20 6272 2727 2723 2054 6869 .py': br'''# Thi\n-0001c5f0: 7320 6669 6c65 2069 7320 7061 7274 206f s file is part o\n-0001c600: 6620 436f 636b 7069 742e 0a23 0a23 2043 f Cockpit..#.# C\n-0001c610: 6f70 7972 6967 6874 2028 4329 2032 3032 opyright (C) 202\n-0001c620: 3220 5265 6420 4861 742c 2049 6e63 2e0a 2 Red Hat, Inc..\n-0001c630: 230a 2320 5468 6973 2070 726f 6772 616d #.# This program\n-0001c640: 2069 7320 6672 6565 2073 6f66 7477 6172 is free softwar\n-0001c650: 653a 2079 6f75 2063 616e 2072 6564 6973 e: you can redis\n-0001c660: 7472 6962 7574 6520 6974 2061 6e64 2f6f tribute it and/o\n-0001c670: 7220 6d6f 6469 6679 0a23 2069 7420 756e r modify.# it un\n-0001c680: 6465 7220 7468 6520 7465 726d 7320 6f66 der the terms of\n-0001c690: 2074 6865 2047 4e55 2047 656e 6572 616c the GNU General\n-0001c6a0: 2050 7562 6c69 6320 4c69 6365 6e73 6520 Public License \n-0001c6b0: 6173 2070 7562 6c69 7368 6564 2062 790a as published by.\n-0001c6c0: 2320 7468 6520 4672 6565 2053 6f66 7477 # the Free Softw\n-0001c6d0: 6172 6520 466f 756e 6461 7469 6f6e 2c20 are Foundation, \n-0001c6e0: 6569 7468 6572 2076 6572 7369 6f6e 2033 either version 3\n-0001c6f0: 206f 6620 7468 6520 4c69 6365 6e73 652c of the License,\n-0001c700: 206f 720a 2320 2861 7420 796f 7572 206f or.# (at your o\n-0001c710: 7074 696f 6e29 2061 6e79 206c 6174 6572 ption) any later\n-0001c720: 2076 6572 7369 6f6e 2e0a 230a 2320 5468 version..#.# Th\n-0001c730: 6973 2070 726f 6772 616d 2069 7320 6469 is program is di\n-0001c740: 7374 7269 6275 7465 6420 696e 2074 6865 stributed in the\n-0001c750: 2068 6f70 6520 7468 6174 2069 7420 7769 hope that it wi\n-0001c760: 6c6c 2062 6520 7573 6566 756c 2c0a 2320 ll be useful,.# \n-0001c770: 6275 7420 5749 5448 4f55 5420 414e 5920 but WITHOUT ANY \n-0001c780: 5741 5252 414e 5459 3b20 7769 7468 6f75 WARRANTY; withou\n-0001c790: 7420 6576 656e 2074 6865 2069 6d70 6c69 t even the impli\n-0001c7a0: 6564 2077 6172 7261 6e74 7920 6f66 0a23 ed warranty of.#\n-0001c7b0: 204d 4552 4348 414e 5441 4249 4c49 5459 MERCHANTABILITY\n-0001c7c0: 206f 7220 4649 544e 4553 5320 464f 5220 or FITNESS FOR \n-0001c7d0: 4120 5041 5254 4943 554c 4152 2050 5552 A PARTICULAR PUR\n-0001c7e0: 504f 5345 2e20 2053 6565 2074 6865 0a23 POSE. See the.#\n-0001c7f0: 2047 4e55 2047 656e 6572 616c 2050 7562 GNU General Pub\n-0001c800: 6c69 6320 4c69 6365 6e73 6520 666f 7220 lic License for \n-0001c810: 6d6f 7265 2064 6574 6169 6c73 2e0a 230a more details..#.\n-0001c820: 2320 596f 7520 7368 6f75 6c64 2068 6176 # You should hav\n-0001c830: 6520 7265 6365 6976 6564 2061 2063 6f70 e received a cop\n-0001c840: 7920 6f66 2074 6865 2047 4e55 2047 656e y of the GNU Gen\n-0001c850: 6572 616c 2050 7562 6c69 6320 4c69 6365 eral Public Lice\n-0001c860: 6e73 650a 2320 616c 6f6e 6720 7769 7468 nse.# along with\n-0001c870: 2074 6869 7320 7072 6f67 7261 6d2e 2020 this program. \n-0001c880: 4966 206e 6f74 2c20 7365 6520 3c68 7474 If not, see ...im\n-0001c8b0: 706f 7274 2061 7379 6e63 696f 0a69 6d70 port asyncio.imp\n-0001c8c0: 6f72 7420 676c 6f62 0a69 6d70 6f72 7420 ort glob.import \n-0001c8d0: 6772 700a 696d 706f 7274 206a 736f 6e0a grp.import json.\n-0001c8e0: 696d 706f 7274 206c 6f67 6769 6e67 0a69 import logging.i\n-0001c8f0: 6d70 6f72 7420 6f73 0a69 6d70 6f72 7420 mport os.import \n-0001c900: 7077 640a 6672 6f6d 2070 6174 686c 6962 pwd.from pathlib\n-0001c910: 2069 6d70 6f72 7420 5061 7468 0a66 726f import Path.fro\n-0001c920: 6d20 7479 7069 6e67 2069 6d70 6f72 7420 m typing import \n-0001c930: 4469 6374 2c20 4f70 7469 6f6e 616c 0a0a Dict, Optional..\n-0001c940: 6672 6f6d 2063 6f63 6b70 6974 2e5f 7665 from cockpit._ve\n-0001c950: 6e64 6f72 2e73 7973 7465 6d64 5f63 7479 ndor.systemd_cty\n-0001c960: 7065 7320 696d 706f 7274 2056 6172 6961 pes import Varia\n-0001c970: 6e74 2c20 6275 732c 2069 6e6f 7469 6679 nt, bus, inotify\n-0001c980: 2c20 7061 7468 7761 7463 680a 0a66 726f , pathwatch..fro\n-0001c990: 6d20 2e20 696d 706f 7274 2063 6f6e 6669 m . import confi\n-0001c9a0: 670a 0a6c 6f67 6765 7220 3d20 6c6f 6767 g..logger = logg\n-0001c9b0: 696e 672e 6765 744c 6f67 6765 7228 5f5f ing.getLogger(__\n-0001c9c0: 6e61 6d65 5f5f 290a 0a0a 636c 6173 7320 name__)...class \n-0001c9d0: 636f 636b 7069 745f 4c6f 6769 6e4d 6573 cockpit_LoginMes\n-0001c9e0: 7361 6765 7328 6275 732e 4f62 6a65 6374 sages(bus.Object\n-0001c9f0: 293a 0a20 2020 206d 6573 7361 6765 733a ):. messages:\n-0001ca00: 204f 7074 696f 6e61 6c5b 7374 725d 203d Optional[str] =\n-0001ca10: 204e 6f6e 650a 0a20 2020 2064 6566 205f None.. def _\n-0001ca20: 5f69 6e69 745f 5f28 7365 6c66 293a 0a20 _init__(self):. \n-0001ca30: 2020 2020 2020 2066 6473 7472 203d 206f fdstr = o\n-0001ca40: 732e 656e 7669 726f 6e2e 706f 7028 2743 s.environ.pop('C\n-0001ca50: 4f43 4b50 4954 5f4c 4f47 494e 5f4d 4553 OCKPIT_LOGIN_MES\n-0001ca60: 5341 4745 535f 4d45 4d46 4427 2c20 4e6f SAGES_MEMFD', No\n-0001ca70: 6e65 290a 2020 2020 2020 2020 6966 2066 ne). if f\n-0001ca80: 6473 7472 2069 7320 4e6f 6e65 3a0a 2020 dstr is None:. \n-0001ca90: 2020 2020 2020 2020 2020 6c6f 6767 6572 logger\n-0001caa0: 2e64 6562 7567 2822 434f 434b 5049 545f .debug(\"COCKPIT_\n-0001cab0: 4c4f 4749 4e5f 4d45 5353 4147 4553 5f4d LOGIN_MESSAGES_M\n-0001cac0: 454d 4644 2077 6173 6e27 7420 7365 742e EMFD wasn't set.\n-0001cad0: 2020 4e6f 206c 6f67 696e 206d 6573 7361 No login messa\n-0001cae0: 6765 7320 746f 6461 792e 2229 0a20 2020 ges today.\"). \n-0001caf0: 2020 2020 2020 2020 2072 6574 7572 6e0a return.\n-0001cb00: 0a20 2020 2020 2020 206c 6f67 6765 722e . logger.\n-0001cb10: 6465 6275 6728 2254 7279 696e 6720 746f debug(\"Trying to\n-0001cb20: 2072 6561 6420 6c6f 6769 6e20 6d65 7373 read login mess\n-0001cb30: 6167 6573 2066 726f 6d20 6664 2025 7322 ages from fd %s\"\n-0001cb40: 2c20 6664 7374 7229 0a20 2020 2020 2020 , fdstr). \n-0001cb50: 2074 7279 3a0a 2020 2020 2020 2020 2020 try:. \n-0001cb60: 2020 7769 7468 206f 7065 6e28 696e 7428 with open(int(\n-0001cb70: 6664 7374 7229 2c20 2772 2729 2061 7320 fdstr), 'r') as \n-0001cb80: 6c6f 6769 6e5f 6d65 7373 6167 6573 3a0a login_messages:.\n-0001cb90: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0001cba0: 6c6f 6769 6e5f 6d65 7373 6167 6573 2e73 login_messages.s\n-0001cbb0: 6565 6b28 3029 0a20 2020 2020 2020 2020 eek(0). \n-0001cbc0: 2020 2020 2020 2073 656c 662e 6d65 7373 self.mess\n-0001cbd0: 6167 6573 203d 206c 6f67 696e 5f6d 6573 ages = login_mes\n-0001cbe0: 7361 6765 732e 7265 6164 2829 0a20 2020 sages.read(). \n-0001cbf0: 2020 2020 2065 7863 6570 7420 2856 616c except (Val\n-0001cc00: 7565 4572 726f 722c 204f 5345 7272 6f72 ueError, OSError\n-0001cc10: 2c20 556e 6963 6f64 6544 6563 6f64 6545 , UnicodeDecodeE\n-0001cc20: 7272 6f72 2920 6173 2065 7863 3a0a 2020 rror) as exc:. \n-0001cc30: 2020 2020 2020 2020 2020 2320 5661 6c75 # Valu\n-0001cc40: 6545 7272 6f72 202d 2074 6865 2065 6e76 eError - the env\n-0001cc50: 7661 7220 7761 736e 2774 2061 6e20 696e var wasn't an in\n-0001cc60: 740a 2020 2020 2020 2020 2020 2020 2320 t. # \n-0001cc70: 4f53 4572 726f 7220 2d20 7468 6520 6664 OSError - the fd\n-0001cc80: 2077 6173 6e27 7420 6f70 656e 2c20 6f72 wasn't open, or\n-0001cc90: 206f 7468 6572 2072 6561 6420 6661 696c other read fail\n-0001cca0: 7572 650a 2020 2020 2020 2020 2020 2020 ure. \n-0001ccb0: 2320 556e 6963 6f64 6544 6563 6f64 6545 # UnicodeDecodeE\n-0001ccc0: 7272 6f72 202d 2064 6964 6e27 7420 636f rror - didn't co\n-0001ccd0: 6e74 6169 6e20 7574 662d 380a 2020 2020 ntain utf-8. \n-0001cce0: 2020 2020 2020 2020 2320 466f 7220 616c # For al\n-0001ccf0: 6c20 6f66 2074 6865 7365 2c20 7765 2073 l of these, we s\n-0001cd00: 696d 706c 7920 6661 696c 6564 2074 6f20 imply failed to \n-0001cd10: 6765 7420 7468 6520 6d65 7373 6167 652e get the message.\n-0001cd20: 0a20 2020 2020 2020 2020 2020 206c 6f67 . log\n-0001cd30: 6765 722e 6465 6275 6728 2252 6561 6469 ger.debug(\"Readi\n-0001cd40: 6e67 206c 6f67 696e 206d 6573 7361 6765 ng login message\n-0001cd50: 7320 6661 696c 6564 3a20 2573 222c 2065 s failed: %s\", e\n-0001cd60: 7863 290a 2020 2020 2020 2020 656c 7365 xc). else\n-0001cd70: 3a0a 2020 2020 2020 2020 2020 2020 6c6f :. lo\n-0001cd80: 6767 6572 2e64 6562 7567 2822 5375 6363 gger.debug(\"Succ\n-0001cd90: 6573 7366 756c 6c79 2072 6561 6420 6c6f essfully read lo\n-0001cda0: 6769 6e20 6d65 7373 6167 6573 3a20 2573 gin messages: %s\n-0001cdb0: 222c 2073 656c 662e 6d65 7373 6167 6573 \", self.messages\n-0001cdc0: 290a 0a20 2020 2040 6275 732e 496e 7465 ).. @bus.Inte\n-0001cdd0: 7266 6163 652e 4d65 7468 6f64 286f 7574 rface.Method(out\n-0001cde0: 5f74 7970 6573 3d5b 2773 275d 290a 2020 _types=['s']). \n-0001cdf0: 2020 6465 6620 6765 7428 7365 6c66 293a def get(self):\n-0001ce00: 0a20 2020 2020 2020 2072 6574 7572 6e20 . return \n-0001ce10: 7365 6c66 2e6d 6573 7361 6765 7320 6f72 self.messages or\n-0001ce20: 2027 7b7d 270a 0a20 2020 2040 6275 732e '{}'.. @bus.\n-0001ce30: 496e 7465 7266 6163 652e 4d65 7468 6f64 Interface.Method\n-0001ce40: 286f 7574 5f74 7970 6573 3d5b 5d29 0a20 (out_types=[]). \n-0001ce50: 2020 2064 6566 2064 6973 6d69 7373 2873 def dismiss(s\n-0001ce60: 656c 6629 3a0a 2020 2020 2020 2020 7365 elf):. se\n-0001ce70: 6c66 2e6d 6573 7361 6765 7320 3d20 4e6f lf.messages = No\n-0001ce80: 6e65 0a0a 0a63 6c61 7373 2063 6f63 6b70 ne...class cockp\n-0001ce90: 6974 5f4d 6163 6869 6e65 7328 6275 732e it_Machines(bus.\n-0001cea0: 4f62 6a65 6374 293a 0a20 2020 2070 6174 Object):. pat\n-0001ceb0: 683a 2050 6174 680a 2020 2020 7761 7463 h: Path. watc\n-0001cec0: 683a 2070 6174 6877 6174 6368 2e50 6174 h: pathwatch.Pat\n-0001ced0: 6857 6174 6368 0a20 2020 2070 656e 6469 hWatch. pendi\n-0001cee0: 6e67 5f6e 6f74 6966 793a 204f 7074 696f ng_notify: Optio\n-0001cef0: 6e61 6c5b 6173 796e 6369 6f2e 4861 6e64 nal[asyncio.Hand\n-0001cf00: 6c65 5d0a 0a20 2020 2023 2044 2d42 7573 le].. # D-Bus\n-0001cf10: 2069 6d70 6c65 6d65 6e74 6174 696f 6e0a implementation.\n-0001cf20: 2020 2020 6d61 6368 696e 6573 203d 2062 machines = b\n-0001cf30: 7573 2e49 6e74 6572 6661 6365 2e50 726f us.Interface.Pro\n-0001cf40: 7065 7274 7928 2761 7b73 617b 7376 7d7d perty('a{sa{sv}}\n-0001cf50: 2729 0a0a 2020 2020 406d 6163 6869 6e65 ').. @machine\n-0001cf60: 732e 6765 7474 6572 0a20 2020 2064 6566 s.getter. def\n-0001cf70: 2067 6574 5f6d 6163 6869 6e65 7328 7365 get_machines(se\n-0001cf80: 6c66 2920 2d3e 2044 6963 745b 7374 722c lf) -> Dict[str,\n-0001cf90: 2044 6963 745b 7374 722c 2056 6172 6961 Dict[str, Varia\n-0001cfa0: 6e74 5d5d 3a0a 2020 2020 2020 2020 7265 nt]]:. re\n-0001cfb0: 7375 6c74 733a 2044 6963 745b 7374 722c sults: Dict[str,\n-0001cfc0: 2044 6963 745b 7374 722c 2056 6172 6961 Dict[str, Varia\n-0001cfd0: 6e74 5d5d 203d 207b 7d0a 0a20 2020 2020 nt]] = {}.. \n-0001cfe0: 2020 2066 6f72 2066 696c 656e 616d 6520 for filename \n-0001cff0: 696e 2067 6c6f 622e 676c 6f62 2866 277b in glob.glob(f'{\n-0001d000: 7365 6c66 2e70 6174 687d 2f2a 2e6a 736f self.path}/*.jso\n-0001d010: 6e27 293a 0a20 2020 2020 2020 2020 2020 n'):. \n-0001d020: 2077 6974 6820 6f70 656e 2866 696c 656e with open(filen\n-0001d030: 616d 6529 2061 7320 6670 3a0a 2020 2020 ame) as fp:. \n-0001d040: 2020 2020 2020 2020 2020 2020 7472 793a try:\n-0001d050: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-0001d060: 2020 2020 2063 6f6e 7465 6e74 7320 3d20 contents = \n-0001d070: 6a73 6f6e 2e6c 6f61 6428 6670 290a 2020 json.load(fp). \n-0001d080: 2020 2020 2020 2020 2020 2020 2020 6578 ex\n-0001d090: 6365 7074 206a 736f 6e2e 4a53 4f4e 4465 cept json.JSONDe\n-0001d0a0: 636f 6465 4572 726f 723a 0a20 2020 2020 codeError:. \n-0001d0b0: 2020 2020 2020 2020 2020 2020 2020 206c l\n-0001d0c0: 6f67 6765 722e 7761 726e 696e 6728 2749 ogger.warning('I\n-0001d0d0: 6e76 616c 6964 204a 534f 4e20 696e 2066 nvalid JSON in f\n-0001d0e0: 696c 6520 2573 2e20 2049 676e 6f72 696e ile %s. Ignorin\n-0001d0f0: 672e 272c 2066 696c 656e 616d 6529 0a20 g.', filename). \n-0001d100: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0001d110: 2020 2063 6f6e 7469 6e75 650a 2020 2020 continue. \n-0001d120: 2020 2020 2020 2020 2020 2020 2320 6d65 # me\n-0001d130: 7267 650a 2020 2020 2020 2020 2020 2020 rge. \n-0001d140: 2020 2020 666f 7220 686f 7374 6e61 6d65 for hostname\n-0001d150: 2c20 6174 7472 7320 696e 2063 6f6e 7465 , attrs in conte\n-0001d160: 6e74 732e 6974 656d 7328 293a 0a20 2020 nts.items():. \n-0001d170: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0001d180: 2072 6573 756c 7473 5b68 6f73 746e 616d results[hostnam\n-0001d190: 655d 203d 207b 6b65 793a 2056 6172 6961 e] = {key: Varia\n-0001d1a0: 6e74 2876 616c 7565 2920 666f 7220 6b65 nt(value) for ke\n-0001d1b0: 792c 2076 616c 7565 2069 6e20 6174 7472 y, value in attr\n-0001d1c0: 732e 6974 656d 7328 297d 0a0a 2020 2020 s.items()}.. \n-0001d1d0: 2020 2020 7265 7475 726e 2072 6573 756c return resul\n-0001d1e0: 7473 0a0a 2020 2020 4062 7573 2e49 6e74 ts.. @bus.Int\n-0001d1f0: 6572 6661 6365 2e4d 6574 686f 6428 696e erface.Method(in\n-0001d200: 5f74 7970 6573 3d5b 2773 272c 2027 7327 _types=['s', 's'\n-0001d210: 2c20 2761 7b73 767d 275d 290a 2020 2020 , 'a{sv}']). \n-0001d220: 6465 6620 7570 6461 7465 2873 656c 662c def update(self,\n-0001d230: 2066 696c 656e 616d 653a 2073 7472 2c20 filename: str, \n-0001d240: 686f 7374 6e61 6d65 3a20 7374 722c 2061 hostname: str, a\n-0001d250: 7474 7273 3a20 4469 6374 5b73 7472 2c20 ttrs: Dict[str, \n-0001d260: 5661 7269 616e 745d 2920 2d3e 204e 6f6e Variant]) -> Non\n-0001d270: 653a 0a20 2020 2020 2020 2074 7279 3a0a e:. try:.\n-0001d280: 2020 2020 2020 2020 2020 2020 7769 7468 with\n-0001d290: 2073 656c 662e 7061 7468 2e6a 6f69 6e70 self.path.joinp\n-0001d2a0: 6174 6828 6669 6c65 6e61 6d65 292e 6f70 ath(filename).op\n-0001d2b0: 656e 2829 2061 7320 6670 3a0a 2020 2020 en() as fp:. \n-0001d2c0: 2020 2020 2020 2020 2020 2020 636f 6e74 cont\n-0001d2d0: 656e 7473 203d 206a 736f 6e2e 6c6f 6164 ents = json.load\n-0001d2e0: 2866 7029 0a20 2020 2020 2020 2065 7863 (fp). exc\n-0001d2f0: 6570 7420 6a73 6f6e 2e4a 534f 4e44 6563 ept json.JSONDec\n-0001d300: 6f64 6545 7272 6f72 2061 7320 6578 633a odeError as exc:\n-0001d310: 0a20 2020 2020 2020 2020 2020 2023 2052 . # R\n-0001d320: 6566 7573 6520 746f 2072 6570 6c61 6365 efuse to replace\n-0001d330: 2063 6f72 7275 7074 6564 2066 696c 650a corrupted file.\n-0001d340: 2020 2020 2020 2020 2020 2020 7261 6973 rais\n-0001d350: 6520 6275 732e 4275 7345 7272 6f72 2827 e bus.BusError('\n-0001d360: 636f 636b 7069 742e 4d61 6368 696e 6573 cockpit.Machines\n-0001d370: 2e45 7272 6f72 272c 2066 2746 696c 6520 .Error', f'File \n-0001d380: 7b66 696c 656e 616d 657d 2069 7320 696e {filename} is in\n-0001d390: 2069 6e76 616c 6964 2066 6f72 6d61 743a invalid format:\n-0001d3a0: 207b 6578 637d 2e27 2920 6672 6f6d 2065 {exc}.') from e\n-0001d3b0: 7863 0a20 2020 2020 2020 2065 7863 6570 xc. excep\n-0001d3c0: 7420 4669 6c65 4e6f 7446 6f75 6e64 4572 t FileNotFoundEr\n-0001d3d0: 726f 723a 0a20 2020 2020 2020 2020 2020 ror:. \n-0001d3e0: 2023 2042 7574 2061 6e20 656d 7074 7920 # But an empty \n-0001d3f0: 6669 6c65 2069 7320 616e 2065 7870 6563 file is an expec\n-0001d400: 7465 6420 6361 7365 0a20 2020 2020 2020 ted case. \n-0001d410: 2020 2020 2063 6f6e 7465 6e74 7320 3d20 contents = \n-0001d420: 7b7d 0a0a 2020 2020 2020 2020 636f 6e74 {}.. cont\n-0001d430: 656e 7473 2e73 6574 6465 6661 756c 7428 ents.setdefault(\n-0001d440: 686f 7374 6e61 6d65 2c20 7b7d 292e 7570 hostname, {}).up\n-0001d450: 6461 7465 287b 6b65 793a 2076 616c 7565 date({key: value\n-0001d460: 2e76 616c 7565 2066 6f72 206b 6579 2c20 .value for key, \n-0001d470: 7661 6c75 6520 696e 2061 7474 7273 2e69 value in attrs.i\n-0001d480: 7465 6d73 2829 7d29 0a0a 2020 2020 2020 tems()}).. \n-0001d490: 2020 7365 6c66 2e70 6174 682e 6d6b 6469 self.path.mkdi\n-0001d4a0: 7228 7061 7265 6e74 733d 5472 7565 2c20 r(parents=True, \n-0001d4b0: 6578 6973 745f 6f6b 3d54 7275 6529 0a20 exist_ok=True). \n-0001d4c0: 2020 2020 2020 2077 6974 6820 6f70 656e with open\n-0001d4d0: 2873 656c 662e 7061 7468 2e6a 6f69 6e70 (self.path.joinp\n-0001d4e0: 6174 6828 6669 6c65 6e61 6d65 292c 2027 ath(filename), '\n-0001d4f0: 7727 2920 6173 2066 703a 0a20 2020 2020 w') as fp:. \n-0001d500: 2020 2020 2020 206a 736f 6e2e 6475 6d70 json.dump\n-0001d510: 2863 6f6e 7465 6e74 732c 2066 702c 2069 (contents, fp, i\n-0001d520: 6e64 656e 743d 3229 0a0a 2020 2020 6465 ndent=2).. de\n-0001d530: 6620 6e6f 7469 6679 2873 656c 6629 3a0a f notify(self):.\n-0001d540: 2020 2020 2020 2020 6465 6620 5f6e 6f74 def _not\n-0001d550: 6966 795f 6e6f 7728 293a 0a20 2020 2020 ify_now():. \n-0001d560: 2020 2020 2020 2073 656c 662e 7072 6f70 self.prop\n-0001d570: 6572 7469 6573 5f63 6861 6e67 6564 2827 erties_changed('\n-0001d580: 636f 636b 7069 742e 4d61 6368 696e 6573 cockpit.Machines\n-0001d590: 272c 207b 7d2c 205b 274d 6163 6869 6e65 ', {}, ['Machine\n-0001d5a0: 7327 5d29 0a20 2020 2020 2020 2020 2020 s']). \n-0001d5b0: 2073 656c 662e 7065 6e64 696e 675f 6e6f self.pending_no\n-0001d5c0: 7469 6679 203d 204e 6f6e 650a 0a20 2020 tify = None.. \n-0001d5d0: 2020 2020 2023 2061 766f 6964 2061 2066 # avoid a f\n-0001d5e0: 6c75 7272 7920 6f66 2075 7064 6174 6520 lurry of update \n-0001d5f0: 6e6f 7469 6669 6361 7469 6f6e 730a 2020 notifications. \n-0001d600: 2020 2020 2020 6966 2073 656c 662e 7065 if self.pe\n-0001d610: 6e64 696e 675f 6e6f 7469 6679 2069 7320 nding_notify is \n-0001d620: 4e6f 6e65 3a0a 2020 2020 2020 2020 2020 None:. \n-0001d630: 2020 7365 6c66 2e70 656e 6469 6e67 5f6e self.pending_n\n-0001d640: 6f74 6966 7920 3d20 6173 796e 6369 6f2e otify = asyncio.\n-0001d650: 6765 745f 7275 6e6e 696e 675f 6c6f 6f70 get_running_loop\n-0001d660: 2829 2e63 616c 6c5f 6c61 7465 7228 312e ().call_later(1.\n-0001d670: 302c 205f 6e6f 7469 6679 5f6e 6f77 290a 0, _notify_now).\n-0001d680: 0a20 2020 2023 2069 6e6f 7469 6679 2065 . # inotify e\n-0001d690: 7665 6e74 730a 2020 2020 6465 6620 646f vents. def do\n-0001d6a0: 5f69 6e6f 7469 6679 5f65 7665 6e74 2873 _inotify_event(s\n-0001d6b0: 656c 662c 206d 6173 6b3a 2069 6e6f 7469 elf, mask: inoti\n-0001d6c0: 6679 2e45 7665 6e74 2c20 636f 6f6b 6965 fy.Event, cookie\n-0001d6d0: 3a20 696e 742c 206e 616d 653a 204f 7074 : int, name: Opt\n-0001d6e0: 696f 6e61 6c5b 7374 725d 2920 2d3e 204e ional[str]) -> N\n-0001d6f0: 6f6e 653a 0a20 2020 2020 2020 2073 656c one:. sel\n-0001d700: 662e 6e6f 7469 6679 2829 0a0a 2020 2020 f.notify().. \n-0001d710: 6465 6620 646f 5f69 6465 6e74 6974 795f def do_identity_\n-0001d720: 6368 616e 6765 6428 7365 6c66 2c20 6664 changed(self, fd\n-0001d730: 3a20 4f70 7469 6f6e 616c 5b69 6e74 5d2c : Optional[int],\n-0001d740: 2065 7272 6e6f 3a20 4f70 7469 6f6e 616c errno: Optional\n-0001d750: 5b69 6e74 5d29 202d 3e20 4e6f 6e65 3a0a [int]) -> None:.\n-0001d760: 2020 2020 2020 2020 7365 6c66 2e6e 6f74 self.not\n-0001d770: 6966 7928 290a 0a20 2020 2064 6566 205f ify().. def _\n-0001d780: 5f69 6e69 745f 5f28 7365 6c66 293a 0a20 _init__(self):. \n-0001d790: 2020 2020 2020 2073 656c 662e 7061 7468 self.path\n-0001d7a0: 203d 2063 6f6e 6669 672e 6c6f 6f6b 7570 = config.lookup\n-0001d7b0: 5f63 6f6e 6669 6728 276d 6163 6869 6e65 _config('machine\n-0001d7c0: 732e 6427 290a 0a20 2020 2020 2020 2023 s.d').. #\n-0001d7d0: 2069 676e 6f72 6520 7468 6520 6669 7273 ignore the firs\n-0001d7e0: 7420 6361 6c6c 6261 636b 0a20 2020 2020 t callback. \n-0001d7f0: 2020 2073 656c 662e 7065 6e64 696e 675f self.pending_\n-0001d800: 6e6f 7469 6679 203d 202e 2e2e 0a20 2020 notify = .... \n-0001d810: 2020 2020 2073 656c 662e 7761 7463 6820 self.watch \n-0001d820: 3d20 7061 7468 7761 7463 682e 5061 7468 = pathwatch.Path\n-0001d830: 5761 7463 6828 7374 7228 7365 6c66 2e70 Watch(str(self.p\n-0001d840: 6174 6829 2c20 7365 6c66 290a 2020 2020 ath), self). \n-0001d850: 2020 2020 7365 6c66 2e70 656e 6469 6e67 self.pending\n-0001d860: 5f6e 6f74 6966 7920 3d20 4e6f 6e65 0a0a _notify = None..\n-0001d870: 0a63 6c61 7373 2063 6f63 6b70 6974 5f55 .class cockpit_U\n-0001d880: 7365 7228 6275 732e 4f62 6a65 6374 293a ser(bus.Object):\n-0001d890: 0a20 2020 206e 616d 6520 3d20 6275 732e . name = bus.\n-0001d8a0: 496e 7465 7266 6163 652e 5072 6f70 6572 Interface.Proper\n-0001d8b0: 7479 2827 7327 2c20 7661 6c75 653d 2727 ty('s', value=''\n-0001d8c0: 290a 2020 2020 6675 6c6c 203d 2062 7573 ). full = bus\n-0001d8d0: 2e49 6e74 6572 6661 6365 2e50 726f 7065 .Interface.Prope\n-0001d8e0: 7274 7928 2773 272c 2076 616c 7565 3d27 rty('s', value='\n-0001d8f0: 2729 0a20 2020 2069 6420 3d20 6275 732e '). id = bus.\n-0001d900: 496e 7465 7266 6163 652e 5072 6f70 6572 Interface.Proper\n-0001d910: 7479 2827 6927 2c20 7661 6c75 653d 3029 ty('i', value=0)\n-0001d920: 0a20 2020 2068 6f6d 6520 3d20 6275 732e . home = bus.\n-0001d930: 496e 7465 7266 6163 652e 5072 6f70 6572 Interface.Proper\n-0001d940: 7479 2827 7327 2c20 7661 6c75 653d 2727 ty('s', value=''\n-0001d950: 290a 2020 2020 7368 656c 6c20 3d20 6275 ). shell = bu\n-0001d960: 732e 496e 7465 7266 6163 652e 5072 6f70 s.Interface.Prop\n-0001d970: 6572 7479 2827 7327 2c20 7661 6c75 653d erty('s', value=\n-0001d980: 2727 290a 2020 2020 6772 6f75 7073 203d ''). groups =\n-0001d990: 2062 7573 2e49 6e74 6572 6661 6365 2e50 bus.Interface.P\n-0001d9a0: 726f 7065 7274 7928 2761 7327 2c20 7661 roperty('as', va\n-0001d9b0: 6c75 653d 5b5d 290a 0a20 2020 2064 6566 lue=[]).. def\n-0001d9c0: 205f 5f69 6e69 745f 5f28 7365 6c66 293a __init__(self):\n-0001d9d0: 0a20 2020 2020 2020 2075 7365 7220 3d20 . user = \n-0001d9e0: 7077 642e 6765 7470 7775 6964 286f 732e pwd.getpwuid(os.\n-0001d9f0: 6765 7475 6964 2829 290a 2020 2020 2020 getuid()). \n-0001da00: 2020 7365 6c66 2e6e 616d 6520 3d20 7573 self.name = us\n-0001da10: 6572 2e70 775f 6e61 6d65 0a20 2020 2020 er.pw_name. \n-0001da20: 2020 2073 656c 662e 6675 6c6c 203d 2075 self.full = u\n-0001da30: 7365 722e 7077 5f67 6563 6f73 0a20 2020 ser.pw_gecos. \n-0001da40: 2020 2020 2073 656c 662e 6964 203d 2075 self.id = u\n-0001da50: 7365 722e 7077 5f75 6964 0a20 2020 2020 ser.pw_uid. \n-0001da60: 2020 2073 656c 662e 686f 6d65 203d 2075 self.home = u\n-0001da70: 7365 722e 7077 5f64 6972 0a20 2020 2020 ser.pw_dir. \n-0001da80: 2020 2073 656c 662e 7368 656c 6c20 3d20 self.shell = \n-0001da90: 7573 6572 2e70 775f 7368 656c 6c0a 2020 user.pw_shell. \n-0001daa0: 2020 2020 2020 7365 6c66 2e67 726f 7570 self.group\n-0001dab0: 7320 3d20 5b67 722e 6772 5f6e 616d 6520 s = [gr.gr_name \n-0001dac0: 666f 7220 6772 2069 6e20 6772 702e 6765 for gr in grp.ge\n-0001dad0: 7467 7261 6c6c 2829 2069 6620 7573 6572 tgrall() if user\n-0001dae0: 2e70 775f 6e61 6d65 2069 6e20 6772 2e67 .pw_name in gr.g\n-0001daf0: 725f 6d65 6d5d 0a0a 0a45 5850 4f52 5453 r_mem]...EXPORTS\n-0001db00: 203d 205b 0a20 2020 2028 272f 4c6f 6769 = [. ('/Logi\n-0001db10: 6e4d 6573 7361 6765 7327 2c20 636f 636b nMessages', cock\n-0001db20: 7069 745f 4c6f 6769 6e4d 6573 7361 6765 pit_LoginMessage\n-0001db30: 7329 2c0a 2020 2020 2827 2f6d 6163 6869 s),. ('/machi\n-0001db40: 6e65 7327 2c20 636f 636b 7069 745f 4d61 nes', cockpit_Ma\n-0001db50: 6368 696e 6573 292c 0a20 2020 2028 272f chines),. ('/\n-0001db60: 7573 6572 272c 2063 6f63 6b70 6974 5f55 user', cockpit_U\n-0001db70: 7365 7229 2c0a 5d0a 2727 272c 0a20 2027 ser),.].''',. '\n-0001db80: 636f 636b 7069 742f 5f5f 696e 6974 5f5f cockpit/__init__\n-0001db90: 2e70 7927 3a20 6272 2727 2766 726f 6d20 .py': br'''from \n-0001dba0: 2e5f 7665 7273 696f 6e20 696d 706f 7274 ._version import\n-0001dbb0: 205f 5f76 6572 7369 6f6e 5f5f 0a0a 5f5f __version__..__\n-0001dbc0: 616c 6c5f 5f20 3d20 280a 2020 2020 275f all__ = (. '_\n-0001dbd0: 5f76 6572 7369 6f6e 5f5f 272c 0a29 0a27 _version__',.).'\n-0001dbe0: 2727 2c0a 2020 2763 6f63 6b70 6974 2f62 '',. 'cockpit/b\n-0001dbf0: 7269 6467 652e 7079 273a 2072 2727 2723 ridge.py': r'''#\n-0001dc00: 2054 6869 7320 6669 6c65 2069 7320 7061 This file is pa\n-0001dc10: 7274 206f 6620 436f 636b 7069 742e 0a23 rt of Cockpit..#\n-0001dc20: 0a23 2043 6f70 7972 6967 6874 2028 4329 .# Copyright (C)\n-0001dc30: 2032 3032 3220 5265 6420 4861 742c 2049 2022 Red Hat, I\n-0001dc40: 6e63 2e0a 230a 2320 5468 6973 2070 726f nc..#.# This pro\n-0001dc50: 6772 616d 2069 7320 6672 6565 2073 6f66 gram is free sof\n-0001dc60: 7477 6172 653a 2079 6f75 2063 616e 2072 tware: you can r\n-0001dc70: 6564 6973 7472 6962 7574 6520 6974 2061 edistribute it a\n-0001dc80: 6e64 2f6f 7220 6d6f 6469 6679 0a23 2069 nd/or modify.# i\n-0001dc90: 7420 756e 6465 7220 7468 6520 7465 726d t under the term\n-0001dca0: 7320 6f66 2074 6865 2047 4e55 2047 656e s of the GNU Gen\n-0001dcb0: 6572 616c 2050 7562 6c69 6320 4c69 6365 eral Public Lice\n-0001dcc0: 6e73 6520 6173 2070 7562 6c69 7368 6564 nse as published\n-0001dcd0: 2062 790a 2320 7468 6520 4672 6565 2053 by.# the Free S\n-0001dce0: 6f66 7477 6172 6520 466f 756e 6461 7469 oftware Foundati\n-0001dcf0: 6f6e 2c20 6569 7468 6572 2076 6572 7369 on, either versi\n-0001dd00: 6f6e 2033 206f 6620 7468 6520 4c69 6365 on 3 of the Lice\n-0001dd10: 6e73 652c 206f 720a 2320 2861 7420 796f nse, or.# (at yo\n-0001dd20: 7572 206f 7074 696f 6e29 2061 6e79 206c ur option) any l\n-0001dd30: 6174 6572 2076 6572 7369 6f6e 2e0a 230a ater version..#.\n-0001dd40: 2320 5468 6973 2070 726f 6772 616d 2069 # This program i\n-0001dd50: 7320 6469 7374 7269 6275 7465 6420 696e s distributed in\n-0001dd60: 2074 6865 2068 6f70 6520 7468 6174 2069 the hope that i\n-0001dd70: 7420 7769 6c6c 2062 6520 7573 6566 756c t will be useful\n-0001dd80: 2c0a 2320 6275 7420 5749 5448 4f55 5420 ,.# but WITHOUT \n-0001dd90: 414e 5920 5741 5252 414e 5459 3b20 7769 ANY WARRANTY; wi\n-0001dda0: 7468 6f75 7420 6576 656e 2074 6865 2069 thout even the i\n-0001ddb0: 6d70 6c69 6564 2077 6172 7261 6e74 7920 mplied warranty \n-0001ddc0: 6f66 0a23 204d 4552 4348 414e 5441 4249 of.# MERCHANTABI\n-0001ddd0: 4c49 5459 206f 7220 4649 544e 4553 5320 LITY or FITNESS \n-0001dde0: 464f 5220 4120 5041 5254 4943 554c 4152 FOR A PARTICULAR\n-0001ddf0: 2050 5552 504f 5345 2e20 2053 6565 2074 PURPOSE. See t\n-0001de00: 6865 0a23 2047 4e55 2047 656e 6572 616c he.# GNU General\n-0001de10: 2050 7562 6c69 6320 4c69 6365 6e73 6520 Public License \n-0001de20: 666f 7220 6d6f 7265 2064 6574 6169 6c73 for more details\n-0001de30: 2e0a 230a 2320 596f 7520 7368 6f75 6c64 ..#.# You should\n-0001de40: 2068 6176 6520 7265 6365 6976 6564 2061 have received a\n-0001de50: 2063 6f70 7920 6f66 2074 6865 2047 4e55 copy of the GNU\n-0001de60: 2047 656e 6572 616c 2050 7562 6c69 6320 General Public \n-0001de70: 4c69 6365 6e73 650a 2320 616c 6f6e 6720 License.# along \n-0001de80: 7769 7468 2074 6869 7320 7072 6f67 7261 with this progra\n-0001de90: 6d2e 2020 4966 206e 6f74 2c20 7365 6520 m. If not, see \n-0001dea0: 3c68 7474 7073 3a2f 2f77 7777 2e67 6e75 .\n-0001dec0: 0a0a 696d 706f 7274 2061 7267 7061 7273 ..import argpars\n-0001ded0: 650a 696d 706f 7274 2061 7379 6e63 696f e.import asyncio\n-0001dee0: 0a69 6d70 6f72 7420 636f 6e74 6578 746c .import contextl\n-0001def0: 6962 0a69 6d70 6f72 7420 6a73 6f6e 0a69 ib.import json.i\n-0001df00: 6d70 6f72 7420 6c6f 6767 696e 670a 696d mport logging.im\n-0001df10: 706f 7274 206f 730a 696d 706f 7274 2070 port os.import p\n-0001df20: 7764 0a69 6d70 6f72 7420 7368 6c65 780a wd.import shlex.\n-0001df30: 696d 706f 7274 2073 6f63 6b65 740a 696d import socket.im\n-0001df40: 706f 7274 2073 7461 740a 696d 706f 7274 port stat.import\n-0001df50: 2073 7562 7072 6f63 6573 730a 6672 6f6d subprocess.from\n-0001df60: 2074 7970 696e 6720 696d 706f 7274 2049 typing import I\n-0001df70: 7465 7261 626c 652c 204c 6973 742c 204f terable, List, O\n-0001df80: 7074 696f 6e61 6c2c 2053 6571 7565 6e63 ptional, Sequenc\n-0001df90: 652c 2054 7570 6c65 2c20 5479 7065 0a0a e, Tuple, Type..\n-0001dfa0: 6672 6f6d 2063 6f63 6b70 6974 2e5f 7665 from cockpit._ve\n-0001dfb0: 6e64 6f72 2e66 6572 6e79 2069 6d70 6f72 ndor.ferny impor\n-0001dfc0: 7420 696e 7465 7261 6374 696f 6e5f 636c t interaction_cl\n-0001dfd0: 6965 6e74 0a66 726f 6d20 636f 636b 7069 ient.from cockpi\n-0001dfe0: 742e 5f76 656e 646f 722e 7379 7374 656d t._vendor.system\n-0001dff0: 645f 6374 7970 6573 2069 6d70 6f72 7420 d_ctypes import \n-0001e000: 6275 732c 2072 756e 5f61 7379 6e63 0a0a bus, run_async..\n-0001e010: 6672 6f6d 202e 2069 6d70 6f72 7420 706f from . import po\n-0001e020: 6c79 6669 6c6c 730a 6672 6f6d 202e 5f76 lyfills.from ._v\n-0001e030: 6572 7369 6f6e 2069 6d70 6f72 7420 5f5f ersion import __\n-0001e040: 7665 7273 696f 6e5f 5f0a 6672 6f6d 202e version__.from .\n-0001e050: 6368 616e 6e65 6c20 696d 706f 7274 2043 channel import C\n-0001e060: 6861 6e6e 656c 526f 7574 696e 6752 756c hannelRoutingRul\n-0001e070: 650a 6672 6f6d 202e 6368 616e 6e65 6c73 e.from .channels\n-0001e080: 2069 6d70 6f72 7420 4348 414e 4e45 4c5f import CHANNEL_\n-0001e090: 5459 5045 530a 6672 6f6d 202e 636f 6e66 TYPES.from .conf\n-0001e0a0: 6967 2069 6d70 6f72 7420 436f 6e66 6967 ig import Config\n-0001e0b0: 2c20 456e 7669 726f 6e6d 656e 740a 6672 , Environment.fr\n-0001e0c0: 6f6d 202e 696e 7465 726e 616c 5f65 6e64 om .internal_end\n-0001e0d0: 706f 696e 7473 2069 6d70 6f72 7420 4558 points import EX\n-0001e0e0: 504f 5254 530a 6672 6f6d 202e 6a73 6f6e PORTS.from .json\n-0001e0f0: 7574 696c 2069 6d70 6f72 7420 4a73 6f6e util import Json\n-0001e100: 4572 726f 722c 204a 736f 6e4f 626a 6563 Error, JsonObjec\n-0001e110: 742c 2067 6574 5f64 6963 740a 6672 6f6d t, get_dict.from\n-0001e120: 202e 7061 636b 6167 6573 2069 6d70 6f72 .packages impor\n-0001e130: 7420 4272 6964 6765 436f 6e66 6967 2c20 t BridgeConfig, \n-0001e140: 5061 636b 6167 6573 2c20 5061 636b 6167 Packages, Packag\n-0001e150: 6573 4c69 7374 656e 6572 0a66 726f 6d20 esListener.from \n-0001e160: 2e70 6565 7220 696d 706f 7274 2050 6565 .peer import Pee\n-0001e170: 7273 526f 7574 696e 6752 756c 650a 6672 rsRoutingRule.fr\n-0001e180: 6f6d 202e 7265 6d6f 7465 2069 6d70 6f72 om .remote impor\n-0001e190: 7420 486f 7374 526f 7574 696e 6752 756c t HostRoutingRul\n-0001e1a0: 650a 6672 6f6d 202e 726f 7574 6572 2069 e.from .router i\n-0001e1b0: 6d70 6f72 7420 526f 7574 6572 0a66 726f mport Router.fro\n-0001e1c0: 6d20 2e73 7570 6572 7573 6572 2069 6d70 m .superuser imp\n-0001e1d0: 6f72 7420 5375 7065 7275 7365 7252 6f75 ort SuperuserRou\n-0001e1e0: 7469 6e67 5275 6c65 0a66 726f 6d20 2e74 tingRule.from .t\n-0001e1f0: 7261 6e73 706f 7274 7320 696d 706f 7274 ransports import\n-0001e200: 2053 7464 696f 5472 616e 7370 6f72 740a StdioTransport.\n-0001e210: 0a6c 6f67 6765 7220 3d20 6c6f 6767 696e .logger = loggin\n-0001e220: 672e 6765 744c 6f67 6765 7228 5f5f 6e61 g.getLogger(__na\n-0001e230: 6d65 5f5f 290a 0a0a 636c 6173 7320 496e me__)...class In\n-0001e240: 7465 726e 616c 4275 733a 0a20 2020 2065 ternalBus:. e\n-0001e250: 7870 6f72 7465 6573 3a20 4c69 7374 5b62 xportees: List[b\n-0001e260: 7573 2e53 6c6f 745d 0a0a 2020 2020 6465 us.Slot].. de\n-0001e270: 6620 5f5f 696e 6974 5f5f 2873 656c 662c f __init__(self,\n-0001e280: 2065 7870 6f72 7473 3a20 4974 6572 6162 exports: Iterab\n-0001e290: 6c65 5b54 7570 6c65 5b73 7472 2c20 5479 le[Tuple[str, Ty\n-0001e2a0: 7065 5b62 7573 2e42 6173 654f 626a 6563 pe[bus.BaseObjec\n-0001e2b0: 745d 5d5d 293a 0a20 2020 2020 2020 2063 t]]]):. c\n-0001e2c0: 6c69 656e 745f 736f 636b 6574 2c20 7365 lient_socket, se\n-0001e2d0: 7276 6572 5f73 6f63 6b65 7420 3d20 736f rver_socket = so\n-0001e2e0: 636b 6574 2e73 6f63 6b65 7470 6169 7228 cket.socketpair(\n-0001e2f0: 290a 2020 2020 2020 2020 7365 6c66 2e63 ). self.c\n-0001e300: 6c69 656e 7420 3d20 6275 732e 4275 732e lient = bus.Bus.\n-0001e310: 6e65 7728 6664 3d63 6c69 656e 745f 736f new(fd=client_so\n-0001e320: 636b 6574 2e64 6574 6163 6828 2929 0a20 cket.detach()). \n-0001e330: 2020 2020 2020 2073 656c 662e 7365 7276 self.serv\n-0001e340: 6572 203d 2062 7573 2e42 7573 2e6e 6577 er = bus.Bus.new\n-0001e350: 2866 643d 7365 7276 6572 5f73 6f63 6b65 (fd=server_socke\n-0001e360: 742e 6465 7461 6368 2829 2c20 7365 7276 t.detach(), serv\n-0001e370: 6572 3d54 7275 6529 0a20 2020 2020 2020 er=True). \n-0001e380: 2073 656c 662e 6578 706f 7274 6565 7320 self.exportees \n-0001e390: 3d20 5b73 656c 662e 7365 7276 6572 2e61 = [self.server.a\n-0001e3a0: 6464 5f6f 626a 6563 7428 7061 7468 2c20 dd_object(path, \n-0001e3b0: 636c 7328 2929 2066 6f72 2070 6174 682c cls()) for path,\n-0001e3c0: 2063 6c73 2069 6e20 6578 706f 7274 735d cls in exports]\n-0001e3d0: 0a0a 2020 2020 6465 6620 6578 706f 7274 .. def export\n-0001e3e0: 2873 656c 662c 2070 6174 683a 2073 7472 (self, path: str\n-0001e3f0: 2c20 6f62 6a3a 2062 7573 2e42 6173 654f , obj: bus.BaseO\n-0001e400: 626a 6563 7429 202d 3e20 4e6f 6e65 3a0a bject) -> None:.\n-0001e410: 2020 2020 2020 2020 7365 6c66 2e65 7870 self.exp\n-0001e420: 6f72 7465 6573 2e61 7070 656e 6428 7365 ortees.append(se\n-0001e430: 6c66 2e73 6572 7665 722e 6164 645f 6f62 lf.server.add_ob\n-0001e440: 6a65 6374 2870 6174 682c 206f 626a 2929 ject(path, obj))\n-0001e450: 0a0a 0a63 6c61 7373 2042 7269 6467 6528 ...class Bridge(\n-0001e460: 526f 7574 6572 2c20 5061 636b 6167 6573 Router, Packages\n-0001e470: 4c69 7374 656e 6572 293a 0a20 2020 2069 Listener):. i\n-0001e480: 6e74 6572 6e61 6c5f 6275 733a 2049 6e74 nternal_bus: Int\n-0001e490: 6572 6e61 6c42 7573 0a20 2020 2070 6163 ernalBus. pac\n-0001e4a0: 6b61 6765 733a 204f 7074 696f 6e61 6c5b kages: Optional[\n-0001e4b0: 5061 636b 6167 6573 5d0a 2020 2020 6272 Packages]. br\n-0001e4c0: 6964 6765 5f63 6f6e 6669 6773 3a20 5365 idge_configs: Se\n-0001e4d0: 7175 656e 6365 5b42 7269 6467 6543 6f6e quence[BridgeCon\n-0001e4e0: 6669 675d 0a20 2020 2061 7267 733a 2061 fig]. args: a\n-0001e4f0: 7267 7061 7273 652e 4e61 6d65 7370 6163 rgparse.Namespac\n-0001e500: 650a 0a20 2020 2064 6566 205f 5f69 6e69 e.. def __ini\n-0001e510: 745f 5f28 7365 6c66 2c20 6172 6773 3a20 t__(self, args: \n-0001e520: 6172 6770 6172 7365 2e4e 616d 6573 7061 argparse.Namespa\n-0001e530: 6365 293a 0a20 2020 2020 2020 2073 656c ce):. sel\n-0001e540: 662e 696e 7465 726e 616c 5f62 7573 203d f.internal_bus =\n-0001e550: 2049 6e74 6572 6e61 6c42 7573 2845 5850 InternalBus(EXP\n-0001e560: 4f52 5453 290a 2020 2020 2020 2020 7365 ORTS). se\n-0001e570: 6c66 2e62 7269 6467 655f 636f 6e66 6967 lf.bridge_config\n-0001e580: 7320 3d20 5b5d 0a20 2020 2020 2020 2073 s = []. s\n-0001e590: 656c 662e 6172 6773 203d 2061 7267 730a elf.args = args.\n-0001e5a0: 0a20 2020 2020 2020 2073 656c 662e 7375 . self.su\n-0001e5b0: 7065 7275 7365 725f 7275 6c65 203d 2053 peruser_rule = S\n-0001e5c0: 7570 6572 7573 6572 526f 7574 696e 6752 uperuserRoutingR\n-0001e5d0: 756c 6528 7365 6c66 2c20 7072 6976 696c ule(self, privil\n-0001e5e0: 6567 6564 3d61 7267 732e 7072 6976 696c eged=args.privil\n-0001e5f0: 6567 6564 290a 2020 2020 2020 2020 7365 eged). se\n-0001e600: 6c66 2e69 6e74 6572 6e61 6c5f 6275 732e lf.internal_bus.\n-0001e610: 6578 706f 7274 2827 2f73 7570 6572 7573 export('/superus\n-0001e620: 6572 272c 2073 656c 662e 7375 7065 7275 er', self.superu\n-0001e630: 7365 725f 7275 6c65 290a 0a20 2020 2020 ser_rule).. \n-0001e640: 2020 2073 656c 662e 696e 7465 726e 616c self.internal\n-0001e650: 5f62 7573 2e65 7870 6f72 7428 272f 636f _bus.export('/co\n-0001e660: 6e66 6967 272c 2043 6f6e 6669 6728 2929 nfig', Config())\n-0001e670: 0a20 2020 2020 2020 2073 656c 662e 696e . self.in\n-0001e680: 7465 726e 616c 5f62 7573 2e65 7870 6f72 ternal_bus.expor\n-0001e690: 7428 272f 656e 7669 726f 6e6d 656e 7427 t('/environment'\n-0001e6a0: 2c20 456e 7669 726f 6e6d 656e 7428 2929 , Environment())\n-0001e6b0: 0a0a 2020 2020 2020 2020 7365 6c66 2e70 .. self.p\n-0001e6c0: 6565 7273 5f72 756c 6520 3d20 5065 6572 eers_rule = Peer\n-0001e6d0: 7352 6f75 7469 6e67 5275 6c65 2873 656c sRoutingRule(sel\n-0001e6e0: 6629 0a0a 2020 2020 2020 2020 6966 2061 f).. if a\n-0001e6f0: 7267 732e 6265 6970 6163 6b3a 0a20 2020 rgs.beipack:. \n-0001e700: 2020 2020 2020 2020 2023 2053 6f6d 6520 # Some \n-0001e710: 7370 6563 6961 6c20 7374 7566 6620 666f special stuff fo\n-0001e720: 7220 6265 6970 6163 6b0a 2020 2020 2020 r beipack. \n-0001e730: 2020 2020 2020 7365 6c66 2e73 7570 6572 self.super\n-0001e740: 7573 6572 5f72 756c 652e 7365 745f 636f user_rule.set_co\n-0001e750: 6e66 6967 7328 280a 2020 2020 2020 2020 nfigs((. \n-0001e760: 2020 2020 2020 2020 4272 6964 6765 436f BridgeCo\n-0001e770: 6e66 6967 287b 0a20 2020 2020 2020 2020 nfig({. \n-0001e780: 2020 2020 2020 2020 2020 2022 7072 6976 \"priv\n-0001e790: 696c 6567 6564 223a 2054 7275 652c 0a20 ileged\": True,. \n-0001e7a0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0001e7b0: 2020 2022 7370 6177 6e22 3a20 5b22 7375 \"spawn\": [\"su\n-0001e7c0: 646f 222c 2022 2d6b 222c 2022 2d41 222c do\", \"-k\", \"-A\",\n-0001e7d0: 2022 7079 7468 6f6e 3322 2c20 222d 6963 \"python3\", \"-ic\n-0001e7e0: 222c 2022 2320 636f 636b 7069 742d 6272 \", \"# cockpit-br\n-0001e7f0: 6964 6765 222c 2022 2d2d 7072 6976 696c idge\", \"--privil\n-0001e800: 6567 6564 225d 2c0a 2020 2020 2020 2020 eged\"],. \n-0001e810: 2020 2020 2020 2020 2020 2020 2265 6e76 \"env\n-0001e820: 6972 6f6e 223a 205b 2253 5544 4f5f 4153 iron\": [\"SUDO_AS\n-0001e830: 4b50 4153 533d 6665 726e 792d 6173 6b70 KPASS=ferny-askp\n-0001e840: 6173 7322 5d2c 0a20 2020 2020 2020 2020 ass\"],. \n-0001e850: 2020 2020 2020 207d 292c 0a20 2020 2020 }),. \n-0001e860: 2020 2020 2020 2029 290a 2020 2020 2020 )). \n-0001e870: 2020 2020 2020 7365 6c66 2e70 6163 6b61 self.packa\n-0001e880: 6765 7320 3d20 4e6f 6e65 0a20 2020 2020 ges = None. \n-0001e890: 2020 2065 6c69 6620 6172 6773 2e70 7269 elif args.pri\n-0001e8a0: 7669 6c65 6765 643a 0a20 2020 2020 2020 vileged:. \n-0001e8b0: 2020 2020 2073 656c 662e 7061 636b 6167 self.packag\n-0001e8c0: 6573 203d 204e 6f6e 650a 2020 2020 2020 es = None. \n-0001e8d0: 2020 656c 7365 3a0a 2020 2020 2020 2020 else:. \n-0001e8e0: 2020 2020 7365 6c66 2e70 6163 6b61 6765 self.package\n-0001e8f0: 7320 3d20 5061 636b 6167 6573 2873 656c s = Packages(sel\n-0001e900: 6629 0a20 2020 2020 2020 2020 2020 2073 f). s\n-0001e910: 656c 662e 696e 7465 726e 616c 5f62 7573 elf.internal_bus\n-0001e920: 2e65 7870 6f72 7428 272f 7061 636b 6167 .export('/packag\n-0001e930: 6573 272c 2073 656c 662e 7061 636b 6167 es', self.packag\n-0001e940: 6573 290a 2020 2020 2020 2020 2020 2020 es). \n-0001e950: 7365 6c66 2e70 6163 6b61 6765 735f 6c6f self.packages_lo\n-0001e960: 6164 6564 2829 0a0a 2020 2020 2020 2020 aded().. \n-0001e970: 7375 7065 7228 292e 5f5f 696e 6974 5f5f super().__init__\n-0001e980: 285b 0a20 2020 2020 2020 2020 2020 2048 ([. H\n-0001e990: 6f73 7452 6f75 7469 6e67 5275 6c65 2873 ostRoutingRule(s\n-0001e9a0: 656c 6629 2c0a 2020 2020 2020 2020 2020 elf),. \n-0001e9b0: 2020 7365 6c66 2e73 7570 6572 7573 6572 self.superuser\n-0001e9c0: 5f72 756c 652c 0a20 2020 2020 2020 2020 _rule,. \n-0001e9d0: 2020 2043 6861 6e6e 656c 526f 7574 696e ChannelRoutin\n-0001e9e0: 6752 756c 6528 7365 6c66 2c20 4348 414e gRule(self, CHAN\n-0001e9f0: 4e45 4c5f 5459 5045 5329 2c0a 2020 2020 NEL_TYPES),. \n-0001ea00: 2020 2020 2020 2020 7365 6c66 2e70 6565 self.pee\n-0001ea10: 7273 5f72 756c 652c 0a20 2020 2020 2020 rs_rule,. \n-0001ea20: 205d 290a 0a20 2020 2040 7374 6174 6963 ]).. @static\n-0001ea30: 6d65 7468 6f64 0a20 2020 2064 6566 2067 method. def g\n-0001ea40: 6574 5f6f 735f 7265 6c65 6173 6528 293a et_os_release():\n-0001ea50: 0a20 2020 2020 2020 2074 7279 3a0a 2020 . try:. \n-0001ea60: 2020 2020 2020 2020 2020 6669 6c65 203d file =\n-0001ea70: 206f 7065 6e28 272f 6574 632f 6f73 2d72 open('/etc/os-r\n-0001ea80: 656c 6561 7365 272c 2065 6e63 6f64 696e elease', encodin\n-0001ea90: 673d 2775 7466 2d38 2729 0a20 2020 2020 g='utf-8'). \n-0001eaa0: 2020 2065 7863 6570 7420 4669 6c65 4e6f except FileNo\n-0001eab0: 7446 6f75 6e64 4572 726f 723a 0a20 2020 tFoundError:. \n-0001eac0: 2020 2020 2020 2020 2074 7279 3a0a 2020 try:. \n-0001ead0: 2020 2020 2020 2020 2020 2020 2020 6669 fi\n-0001eae0: 6c65 203d 206f 7065 6e28 272f 7573 722f le = open('/usr/\n-0001eaf0: 6c69 622f 6f73 2d72 656c 6561 7365 272c lib/os-release',\n-0001eb00: 2065 6e63 6f64 696e 673d 2775 7466 2d38 encoding='utf-8\n-0001eb10: 2729 0a20 2020 2020 2020 2020 2020 2065 '). e\n-0001eb20: 7863 6570 7420 4669 6c65 4e6f 7446 6f75 xcept FileNotFou\n-0001eb30: 6e64 4572 726f 723a 0a20 2020 2020 2020 ndError:. \n-0001eb40: 2020 2020 2020 2020 206c 6f67 6765 722e logger.\n-0001eb50: 7761 726e 696e 6728 224e 6569 7468 6572 warning(\"Neither\n-0001eb60: 202f 6574 632f 6f73 2d72 656c 6561 7365 /etc/os-release\n-0001eb70: 206e 6f72 202f 7573 722f 6c69 622f 6f73 nor /usr/lib/os\n-0001eb80: 2d72 656c 6561 7365 2065 7869 7374 7322 -release exists\"\n-0001eb90: 290a 2020 2020 2020 2020 2020 2020 2020 ). \n-0001eba0: 2020 7265 7475 726e 207b 7d0a 0a20 2020 return {}.. \n-0001ebb0: 2020 2020 206f 735f 7265 6c65 6173 6520 os_release \n-0001ebc0: 3d20 7b7d 0a20 2020 2020 2020 2066 6f72 = {}. for\n-0001ebd0: 206c 696e 6520 696e 2066 696c 652e 7265 line in file.re\n-0001ebe0: 6164 6c69 6e65 7328 293a 0a20 2020 2020 adlines():. \n-0001ebf0: 2020 2020 2020 206c 696e 6520 3d20 6c69 line = li\n-0001ec00: 6e65 2e73 7472 6970 2829 0a20 2020 2020 ne.strip(). \n-0001ec10: 2020 2020 2020 2069 6620 6e6f 7420 6c69 if not li\n-0001ec20: 6e65 206f 7220 6c69 6e65 2e73 7461 7274 ne or line.start\n-0001ec30: 7377 6974 6828 2723 2729 3a0a 2020 2020 swith('#'):. \n-0001ec40: 2020 2020 2020 2020 2020 2020 636f 6e74 cont\n-0001ec50: 696e 7565 0a20 2020 2020 2020 2020 2020 inue. \n-0001ec60: 2074 7279 3a0a 2020 2020 2020 2020 2020 try:. \n-0001ec70: 2020 2020 2020 6b2c 2076 203d 206c 696e k, v = lin\n-0001ec80: 652e 7370 6c69 7428 273d 2729 0a20 2020 e.split('='). \n-0001ec90: 2020 2020 2020 2020 2020 2020 2028 765f (v_\n-0001eca0: 7061 7273 6564 2c20 2920 3d20 7368 6c65 parsed, ) = shle\n-0001ecb0: 782e 7370 6c69 7428 7629 2020 2320 6578 x.split(v) # ex\n-0001ecc0: 7065 6374 2065 7861 6374 6c79 206f 6e65 pect exactly one\n-0001ecd0: 2074 6f6b 656e 0a20 2020 2020 2020 2020 token. \n-0001ece0: 2020 2065 7863 6570 7420 5661 6c75 6545 except ValueE\n-0001ecf0: 7272 6f72 3a0a 2020 2020 2020 2020 2020 rror:. \n-0001ed00: 2020 2020 2020 6c6f 6767 6572 2e77 6172 logger.war\n-0001ed10: 6e69 6e67 2827 4967 6e6f 7269 6e67 2069 ning('Ignoring i\n-0001ed20: 6e76 616c 6964 206c 696e 6520 696e 206f nvalid line in o\n-0001ed30: 732d 7265 6c65 6173 653a 2025 7227 2c20 s-release: %r', \n-0001ed40: 6c69 6e65 290a 2020 2020 2020 2020 2020 line). \n-0001ed50: 2020 2020 2020 636f 6e74 696e 7565 0a20 continue. \n-0001ed60: 2020 2020 2020 2020 2020 206f 735f 7265 os_re\n-0001ed70: 6c65 6173 655b 6b5d 203d 2076 5f70 6172 lease[k] = v_par\n-0001ed80: 7365 640a 2020 2020 2020 2020 7265 7475 sed. retu\n-0001ed90: 726e 206f 735f 7265 6c65 6173 650a 0a20 rn os_release.. \n-0001eda0: 2020 2064 6566 2064 6f5f 696e 6974 2873 def do_init(s\n-0001edb0: 656c 662c 206d 6573 7361 6765 3a20 4a73 elf, message: Js\n-0001edc0: 6f6e 4f62 6a65 6374 2920 2d3e 204e 6f6e onObject) -> Non\n-0001edd0: 653a 0a20 2020 2020 2020 2023 2077 6527 e:. # we'\n-0001ede0: 7265 206f 6e6c 7920 696e 7465 7265 7374 re only interest\n-0001edf0: 6564 2069 6e20 7468 6520 6361 7365 2077 ed in the case w\n-0001ee00: 6865 7265 2074 6869 7320 6973 2061 2064 here this is a d\n-0001ee10: 6963 742c 2062 7574 0a20 2020 2020 2020 ict, but. \n-0001ee20: 2023 2027 7375 7065 7275 7365 7227 206d # 'superuser' m\n-0001ee30: 6179 2077 656c 6c20 6265 2060 4661 6c73 ay well be `Fals\n-0001ee40: 6560 2061 6e64 2074 6861 7427 7320 6e6f e` and that's no\n-0001ee50: 7420 616e 2065 7272 6f72 0a20 2020 2020 t an error. \n-0001ee60: 2020 2077 6974 6820 636f 6e74 6578 746c with contextl\n-0001ee70: 6962 2e73 7570 7072 6573 7328 4a73 6f6e ib.suppress(Json\n-0001ee80: 4572 726f 7229 3a0a 2020 2020 2020 2020 Error):. \n-0001ee90: 2020 2020 7375 7065 7275 7365 7220 3d20 superuser = \n-0001eea0: 6765 745f 6469 6374 286d 6573 7361 6765 get_dict(message\n-0001eeb0: 2c20 2773 7570 6572 7573 6572 2729 0a20 , 'superuser'). \n-0001eec0: 2020 2020 2020 2020 2020 2073 656c 662e self.\n-0001eed0: 7375 7065 7275 7365 725f 7275 6c65 2e69 superuser_rule.i\n-0001eee0: 6e69 7428 7375 7065 7275 7365 7229 0a0a nit(superuser)..\n-0001eef0: 2020 2020 6465 6620 646f 5f73 656e 645f def do_send_\n-0001ef00: 696e 6974 2873 656c 6629 202d 3e20 4e6f init(self) -> No\n-0001ef10: 6e65 3a0a 2020 2020 2020 2020 696e 6974 ne:. init\n-0001ef20: 5f61 7267 7320 3d20 7b0a 2020 2020 2020 _args = {. \n-0001ef30: 2020 2020 2020 2763 6170 6162 696c 6974 'capabilit\n-0001ef40: 6965 7327 3a20 7b27 6578 706c 6963 6974 ies': {'explicit\n-0001ef50: 2d73 7570 6572 7573 6572 273a 2054 7275 -superuser': Tru\n-0001ef60: 657d 2c0a 2020 2020 2020 2020 2020 2020 e},. \n-0001ef70: 2763 6f6d 6d61 6e64 273a 2027 696e 6974 'command': 'init\n-0001ef80: 272c 0a20 2020 2020 2020 2020 2020 2027 ',. '\n-0001ef90: 6f73 2d72 656c 6561 7365 273a 2073 656c os-release': sel\n-0001efa0: 662e 6765 745f 6f73 5f72 656c 6561 7365 f.get_os_release\n-0001efb0: 2829 2c0a 2020 2020 2020 2020 2020 2020 (),. \n-0001efc0: 2776 6572 7369 6f6e 273a 2031 2c0a 2020 'version': 1,. \n-0001efd0: 2020 2020 2020 7d0a 0a20 2020 2020 2020 }.. \n-0001efe0: 2069 6620 7365 6c66 2e70 6163 6b61 6765 if self.package\n-0001eff0: 7320 6973 206e 6f74 204e 6f6e 653a 0a20 s is not None:. \n-0001f000: 2020 2020 2020 2020 2020 2069 6e69 745f init_\n-0001f010: 6172 6773 5b27 7061 636b 6167 6573 275d args['packages']\n-0001f020: 203d 2064 6963 742e 6672 6f6d 6b65 7973 = dict.fromkeys\n-0001f030: 2873 656c 662e 7061 636b 6167 6573 2e70 (self.packages.p\n-0001f040: 6163 6b61 6765 7329 0a0a 2020 2020 2020 ackages).. \n-0001f050: 2020 7365 6c66 2e77 7269 7465 5f63 6f6e self.write_con\n-0001f060: 7472 6f6c 2869 6e69 745f 6172 6773 290a trol(init_args).\n-0001f070: 0a20 2020 2023 2050 6163 6b61 6765 734c . # PackagesL\n-0001f080: 6973 7465 6e65 7220 696e 7465 7266 6163 istener interfac\n-0001f090: 650a 2020 2020 6465 6620 7061 636b 6167 e. def packag\n-0001f0a0: 6573 5f6c 6f61 6465 6428 7365 6c66 2920 es_loaded(self) \n-0001f0b0: 2d3e 204e 6f6e 653a 0a20 2020 2020 2020 -> None:. \n-0001f0c0: 2061 7373 6572 7420 7365 6c66 2e70 6163 assert self.pac\n-0001f0d0: 6b61 6765 730a 2020 2020 2020 2020 6272 kages. br\n-0001f0e0: 6964 6765 5f63 6f6e 6669 6773 203d 2073 idge_configs = s\n-0001f0f0: 656c 662e 7061 636b 6167 6573 2e67 6574 elf.packages.get\n-0001f100: 5f62 7269 6467 655f 636f 6e66 6967 7328 _bridge_configs(\n-0001f110: 290a 2020 2020 2020 2020 6966 2073 656c ). if sel\n-0001f120: 662e 6272 6964 6765 5f63 6f6e 6669 6773 f.bridge_configs\n-0001f130: 2021 3d20 6272 6964 6765 5f63 6f6e 6669 != bridge_confi\n-0001f140: 6773 3a0a 2020 2020 2020 2020 2020 2020 gs:. \n-0001f150: 7365 6c66 2e73 7570 6572 7573 6572 5f72 self.superuser_r\n-0001f160: 756c 652e 7365 745f 636f 6e66 6967 7328 ule.set_configs(\n-0001f170: 6272 6964 6765 5f63 6f6e 6669 6773 290a bridge_configs).\n-0001f180: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n-0001f190: 2e70 6565 7273 5f72 756c 652e 7365 745f .peers_rule.set_\n-0001f1a0: 636f 6e66 6967 7328 6272 6964 6765 5f63 configs(bridge_c\n-0001f1b0: 6f6e 6669 6773 290a 2020 2020 2020 2020 onfigs). \n-0001f1c0: 2020 2020 7365 6c66 2e62 7269 6467 655f self.bridge_\n-0001f1d0: 636f 6e66 6967 7320 3d20 6272 6964 6765 configs = bridge\n-0001f1e0: 5f63 6f6e 6669 6773 0a0a 0a61 7379 6e63 _configs...async\n-0001f1f0: 2064 6566 2072 756e 2861 7267 7329 202d def run(args) -\n-0001f200: 3e20 4e6f 6e65 3a0a 2020 2020 6c6f 6767 > None:. logg\n-0001f210: 6572 2e64 6562 7567 2822 4869 2e20 486f er.debug(\"Hi. Ho\n-0001f220: 7720 6172 6520 796f 7520 746f 6461 793f w are you today?\n-0001f230: 2229 0a0a 2020 2020 2320 556e 6974 2074 \").. # Unit t\n-0001f240: 6573 7473 2072 6571 7569 7265 2074 6869 ests require thi\n-0001f250: 730a 2020 2020 6d65 203d 2070 7764 2e67 s. me = pwd.g\n-0001f260: 6574 7077 7569 6428 6f73 2e67 6574 7569 etpwuid(os.getui\n-0001f270: 6428 2929 0a20 2020 206f 732e 656e 7669 d()). os.envi\n-0001f280: 726f 6e5b 2748 4f4d 4527 5d20 3d20 6d65 ron['HOME'] = me\n-0001f290: 2e70 775f 6469 720a 2020 2020 6f73 2e65 .pw_dir. os.e\n-0001f2a0: 6e76 6972 6f6e 5b27 5348 454c 4c27 5d20 nviron['SHELL'] \n-0001f2b0: 3d20 6d65 2e70 775f 7368 656c 6c0a 2020 = me.pw_shell. \n-0001f2c0: 2020 6f73 2e65 6e76 6972 6f6e 5b27 5553 os.environ['US\n-0001f2d0: 4552 275d 203d 206d 652e 7077 5f6e 616d ER'] = me.pw_nam\n-0001f2e0: 650a 0a20 2020 206c 6f67 6765 722e 6465 e.. logger.de\n-0001f2f0: 6275 6728 2753 7461 7274 696e 6720 7468 bug('Starting th\n-0001f300: 6520 726f 7574 6572 2e27 290a 2020 2020 e router.'). \n-0001f310: 726f 7574 6572 203d 2042 7269 6467 6528 router = Bridge(\n-0001f320: 6172 6773 290a 2020 2020 5374 6469 6f54 args). StdioT\n-0001f330: 7261 6e73 706f 7274 2861 7379 6e63 696f ransport(asyncio\n-0001f340: 2e67 6574 5f72 756e 6e69 6e67 5f6c 6f6f .get_running_loo\n-0001f350: 7028 292c 2072 6f75 7465 7229 0a0a 2020 p(), router).. \n-0001f360: 2020 6c6f 6767 6572 2e64 6562 7567 2827 logger.debug('\n-0001f370: 5374 6172 7475 7020 646f 6e65 2e20 204c Startup done. L\n-0001f380: 6f6f 7069 6e67 2075 6e74 696c 2063 6f6e ooping until con\n-0001f390: 6e65 6374 696f 6e20 636c 6f73 6573 2e27 nection closes.'\n-0001f3a0: 290a 0a20 2020 2074 7279 3a0a 2020 2020 ).. try:. \n-0001f3b0: 2020 2020 6177 6169 7420 726f 7574 6572 await router\n-0001f3c0: 2e63 6f6d 6d75 6e69 6361 7465 2829 0a20 .communicate(). \n-0001f3d0: 2020 2065 7863 6570 7420 2842 726f 6b65 except (Broke\n-0001f3e0: 6e50 6970 6545 7272 6f72 2c20 436f 6e6e nPipeError, Conn\n-0001f3f0: 6563 7469 6f6e 5265 7365 7445 7272 6f72 ectionResetError\n-0001f400: 293a 0a20 2020 2020 2020 2023 206e 6f74 ):. # not\n-0001f410: 2075 6e65 7870 6563 7465 6420 6966 2074 unexpected if t\n-0001f420: 6865 2070 6565 7220 646f 6573 6e27 7420 he peer doesn't \n-0001f430: 6861 6e67 2075 7020 636c 6561 6e6c 790a hang up cleanly.\n-0001f440: 2020 2020 2020 2020 7061 7373 0a0a 0a64 pass...d\n-0001f450: 6566 2074 7279 5f74 6f5f 7265 6365 6976 ef try_to_receiv\n-0001f460: 655f 7374 6465 7272 2829 3a0a 2020 2020 e_stderr():. \n-0001f470: 7472 793a 0a20 2020 2020 2020 206f 7572 try:. our\n-0001f480: 732c 2074 6865 6972 7320 3d20 736f 636b s, theirs = sock\n-0001f490: 6574 2e73 6f63 6b65 7470 6169 7228 290a et.socketpair().\n-0001f4a0: 2020 2020 2020 2020 7769 7468 206f 7572 with our\n-0001f4b0: 733a 0a20 2020 2020 2020 2020 2020 2077 s:. w\n-0001f4c0: 6974 6820 7468 6569 7273 3a0a 2020 2020 ith theirs:. \n-0001f4d0: 2020 2020 2020 2020 2020 2020 696e 7465 inte\n-0001f4e0: 7261 6374 696f 6e5f 636c 6965 6e74 2e63 raction_client.c\n-0001f4f0: 6f6d 6d61 6e64 2832 2c20 2763 6f63 6b70 ommand(2, 'cockp\n-0001f500: 6974 2e73 656e 642d 7374 6465 7272 272c it.send-stderr',\n-0001f510: 2066 6473 3d5b 7468 6569 7273 2e66 696c fds=[theirs.fil\n-0001f520: 656e 6f28 295d 290a 2020 2020 2020 2020 eno()]). \n-0001f530: 2020 2020 5f6d 7367 2c20 6664 732c 205f _msg, fds, _\n-0001f540: 666c 6167 732c 205f 6164 6472 203d 2073 flags, _addr = s\n-0001f550: 6f63 6b65 742e 7265 6376 5f66 6473 286f ocket.recv_fds(o\n-0001f560: 7572 732c 2031 2c20 3129 0a20 2020 2065 urs, 1, 1). e\n-0001f570: 7863 6570 7420 4f53 4572 726f 723a 0a20 xcept OSError:. \n-0001f580: 2020 2020 2020 2072 6574 7572 6e0a 0a20 return.. \n-0001f590: 2020 2074 7279 3a0a 2020 2020 2020 2020 try:. \n-0001f5a0: 7374 6465 7272 5f66 642c 203d 2066 6473 stderr_fd, = fds\n-0001f5b0: 0a20 2020 2020 2020 2023 2057 6527 7265 . # We're\n-0001f5c0: 2061 626f 7574 2074 6f20 6162 7275 7074 about to abrupt\n-0001f5d0: 6c79 2064 726f 7020 6f75 7220 656e 6420 ly drop our end \n-0001f5e0: 6f66 2074 6865 2073 7464 6572 7220 736f of the stderr so\n-0001f5f0: 636b 6574 7061 6972 2074 6861 7420 7765 cketpair that we\n-0001f600: 0a20 2020 2020 2020 2023 2073 6861 7265 . # share\n-0001f610: 2077 6974 6820 7468 6520 6665 726e 7920 with the ferny \n-0001f620: 6167 656e 742e 2020 6665 726e 7920 776f agent. ferny wo\n-0001f630: 756c 6420 6e6f 726d 616c 6c79 2074 7265 uld normally tre\n-0001f640: 6174 2074 6861 7420 6173 2061 6e0a 2020 at that as an. \n-0001f650: 2020 2020 2020 2320 756e 6578 7065 6374 # unexpect\n-0001f660: 6564 2065 7272 6f72 2e20 496e 7374 7275 ed error. Instru\n-0001f670: 6374 2069 7420 746f 2064 6f20 6120 636c ct it to do a cl\n-0001f680: 6561 6e20 6578 6974 2c20 696e 7374 6561 ean exit, instea\n-0001f690: 642e 0a20 2020 2020 2020 2069 6e74 6572 d.. inter\n-0001f6a0: 6163 7469 6f6e 5f63 6c69 656e 742e 636f action_client.co\n-0001f6b0: 6d6d 616e 6428 322c 2027 6665 726e 792e mmand(2, 'ferny.\n-0001f6c0: 656e 6427 290a 2020 2020 2020 2020 6f73 end'). os\n-0001f6d0: 2e64 7570 3228 7374 6465 7272 5f66 642c .dup2(stderr_fd,\n-0001f6e0: 2032 290a 2020 2020 6669 6e61 6c6c 793a 2). finally:\n-0001f6f0: 0a20 2020 2020 2020 2066 6f72 2066 6420 . for fd \n-0001f700: 696e 2066 6473 3a0a 2020 2020 2020 2020 in fds:. \n-0001f710: 2020 2020 6f73 2e63 6c6f 7365 2866 6429 os.close(fd)\n-0001f720: 0a0a 0a64 6566 2073 6574 7570 5f6a 6f75 ...def setup_jou\n-0001f730: 726e 616c 6428 2920 2d3e 2062 6f6f 6c3a rnald() -> bool:\n-0001f740: 0a20 2020 2023 2049 6620 7374 6465 7272 . # If stderr\n-0001f750: 2069 7320 6120 736f 636b 6574 2c20 7072 is a socket, pr\n-0001f760: 6566 6572 2073 7973 7465 6d64 2d6a 6f75 efer systemd-jou\n-0001f770: 726e 616c 206c 6f67 6769 6e67 2e20 2054 rnal logging. T\n-0001f780: 6869 7320 636f 7665 7273 2074 6865 0a20 his covers the. \n-0001f790: 2020 2023 2063 6173 6520 7765 2772 6520 # case we're \n-0001f7a0: 616c 7265 6164 7920 636f 6e6e 6563 7465 already connecte\n-0001f7b0: 6420 746f 2074 6865 206a 6f75 726e 616c d to the journal\n-0001f7c0: 2062 7574 2061 6c73 6f20 7468 6520 6361 but also the ca\n-0001f7d0: 7365 2077 6865 7265 2077 6527 7265 0a20 se where we're. \n-0001f7e0: 2020 2023 2074 616c 6b69 6e67 2074 6f20 # talking to \n-0001f7f0: 7468 6520 6665 726e 7920 6167 656e 742c the ferny agent,\n-0001f800: 2077 6869 6c65 206c 6561 7669 6e67 206c while leaving l\n-0001f810: 6f67 6769 6e67 2074 6f20 6669 6c65 206f ogging to file o\n-0001f820: 7220 7465 726d 696e 616c 0a20 2020 2023 r terminal. #\n-0001f830: 2075 6e61 6666 6563 7465 642e 0a20 2020 unaffected.. \n-0001f840: 2069 6620 6e6f 7420 7374 6174 2e53 5f49 if not stat.S_I\n-0001f850: 5353 4f43 4b28 6f73 2e66 7374 6174 2832 SSOCK(os.fstat(2\n-0001f860: 292e 7374 5f6d 6f64 6529 3a0a 2020 2020 ).st_mode):. \n-0001f870: 2020 2020 2320 6e6f 7420 6120 736f 636b # not a sock\n-0001f880: 6574 3f20 2044 6f6e 2774 2072 6564 6972 et? Don't redir\n-0001f890: 6563 742e 0a20 2020 2020 2020 2072 6574 ect.. ret\n-0001f8a0: 7572 6e20 4661 6c73 650a 0a20 2020 2074 urn False.. t\n-0001f8b0: 7279 3a0a 2020 2020 2020 2020 696d 706f ry:. impo\n-0001f8c0: 7274 2073 7973 7465 6d64 2e6a 6f75 726e rt systemd.journ\n-0001f8d0: 616c 2020 2320 7479 7065 3a20 6967 6e6f al # type: igno\n-0001f8e0: 7265 5b69 6d70 6f72 745d 0a20 2020 2065 re[import]. e\n-0001f8f0: 7863 6570 7420 496d 706f 7274 4572 726f xcept ImportErro\n-0001f900: 723a 0a20 2020 2020 2020 2023 204e 6f20 r:. # No \n-0001f910: 7079 7468 6f6e 332d 7379 7374 656d 643f python3-systemd?\n-0001f920: 2020 446f 6e27 7420 7265 6469 7265 6374 Don't redirect\n-0001f930: 2e0a 2020 2020 2020 2020 7265 7475 726e .. return\n-0001f940: 2046 616c 7365 0a0a 2020 2020 6c6f 6767 False.. logg\n-0001f950: 696e 672e 726f 6f74 2e61 6464 4861 6e64 ing.root.addHand\n-0001f960: 6c65 7228 7379 7374 656d 642e 6a6f 7572 ler(systemd.jour\n-0001f970: 6e61 6c2e 4a6f 7572 6e61 6c48 616e 646c nal.JournalHandl\n-0001f980: 6572 2829 290a 2020 2020 7265 7475 726e er()). return\n-0001f990: 2054 7275 650a 0a0a 6465 6620 7365 7475 True...def setu\n-0001f9a0: 705f 6c6f 6767 696e 6728 2a2c 2064 6562 p_logging(*, deb\n-0001f9b0: 7567 3a20 626f 6f6c 2920 2d3e 204e 6f6e ug: bool) -> Non\n-0001f9c0: 653a 0a20 2020 2022 2222 5365 7475 7020 e:. \"\"\"Setup \n-0001f9d0: 6f75 7220 6c6f 6767 6572 2077 6974 6820 our logger with \n-0001f9e0: 6f70 7469 6f6e 616c 2066 696c 7465 7269 optional filteri\n-0001f9f0: 6e67 206f 6620 6d6f 6475 6c65 7320 6966 ng of modules if\n-0001fa00: 2043 4f43 4b50 4954 5f44 4542 5547 2065 COCKPIT_DEBUG e\n-0001fa10: 6e76 2069 7320 7365 7422 2222 0a0a 2020 nv is set\"\"\".. \n-0001fa20: 2020 6d6f 6475 6c65 7320 3d20 6f73 2e67 modules = os.g\n-0001fa30: 6574 656e 7628 2743 4f43 4b50 4954 5f44 etenv('COCKPIT_D\n-0001fa40: 4542 5547 272c 2027 2729 0a0a 2020 2020 EBUG', '').. \n-0001fa50: 2320 4569 7468 6572 2073 6574 7570 206c # Either setup l\n-0001fa60: 6f67 6769 6e67 2076 6961 206a 6f75 726e ogging via journ\n-0001fa70: 616c 206f 7220 7669 6120 666f 726d 6174 al or via format\n-0001fa80: 7465 6420 6d65 7373 6167 6573 2074 6f20 ted messages to \n-0001fa90: 7374 6465 7272 0a20 2020 2069 6620 6e6f stderr. if no\n-0001faa0: 7420 7365 7475 705f 6a6f 7572 6e61 6c64 t setup_journald\n-0001fab0: 2829 3a0a 2020 2020 2020 2020 6c6f 6767 ():. logg\n-0001fac0: 696e 672e 6261 7369 6343 6f6e 6669 6728 ing.basicConfig(\n-0001fad0: 666f 726d 6174 3d27 2528 6e61 6d65 2973 format='%(name)s\n-0001fae0: 2d25 286c 6576 656c 6e61 6d65 2973 3a20 -%(levelname)s: \n-0001faf0: 2528 6d65 7373 6167 6529 7327 290a 0a20 %(message)s').. \n-0001fb00: 2020 2069 6620 6465 6275 6720 6f72 206d if debug or m\n-0001fb10: 6f64 756c 6573 203d 3d20 2761 6c6c 273a odules == 'all':\n-0001fb20: 0a20 2020 2020 2020 206c 6f67 6769 6e67 . logging\n-0001fb30: 2e67 6574 4c6f 6767 6572 2829 2e73 6574 .getLogger().set\n-0001fb40: 4c65 7665 6c28 6c65 7665 6c3d 6c6f 6767 Level(level=logg\n-0001fb50: 696e 672e 4445 4255 4729 0a20 2020 2065 ing.DEBUG). e\n-0001fb60: 6c69 6620 6d6f 6475 6c65 733a 0a20 2020 lif modules:. \n-0001fb70: 2020 2020 2066 6f72 206d 6f64 756c 6520 for module \n-0001fb80: 696e 206d 6f64 756c 6573 2e73 706c 6974 in modules.split\n-0001fb90: 2827 2c27 293a 0a20 2020 2020 2020 2020 (','):. \n-0001fba0: 2020 206d 6f64 756c 6520 3d20 6d6f 6475 module = modu\n-0001fbb0: 6c65 2e73 7472 6970 2829 0a20 2020 2020 le.strip(). \n-0001fbc0: 2020 2020 2020 2069 6620 6e6f 7420 6d6f if not mo\n-0001fbd0: 6475 6c65 3a0a 2020 2020 2020 2020 2020 dule:. \n-0001fbe0: 2020 2020 2020 636f 6e74 696e 7565 0a0a continue..\n-0001fbf0: 2020 2020 2020 2020 2020 2020 6c6f 6767 logg\n-0001fc00: 696e 672e 6765 744c 6f67 6765 7228 6d6f ing.getLogger(mo\n-0001fc10: 6475 6c65 292e 7365 744c 6576 656c 286c dule).setLevel(l\n-0001fc20: 6f67 6769 6e67 2e44 4542 5547 290a 0a0a ogging.DEBUG)...\n-0001fc30: 6465 6620 7374 6172 745f 7373 685f 6167 def start_ssh_ag\n-0001fc40: 656e 7428 2920 2d3e 204e 6f6e 653a 0a20 ent() -> None:. \n-0001fc50: 2020 2023 204c 6175 6e63 6820 7468 6520 # Launch the \n-0001fc60: 6167 656e 7420 736f 2074 6861 7420 6974 agent so that it\n-0001fc70: 2067 6f65 7320 646f 776e 2077 6974 6820 goes down with \n-0001fc80: 7573 206f 6e20 454f 463b 2050 4445 4154 us on EOF; PDEAT\n-0001fc90: 4853 4947 2077 6f75 6c64 2062 6520 6d6f HSIG would be mo\n-0001fca0: 7265 2072 6f62 7573 742c 0a20 2020 2023 re robust,. #\n-0001fcb0: 2062 7574 2069 7420 6765 7473 2063 6c65 but it gets cle\n-0001fcc0: 6172 6564 206f 6e20 7365 7467 6964 2073 ared on setgid s\n-0001fcd0: 7368 2d61 6765 6e74 2c20 7768 6963 6820 sh-agent, which \n-0001fce0: 736f 6d65 2064 6973 7472 6f73 2073 7469 some distros sti\n-0001fcf0: 6c6c 2064 6f0a 2020 2020 7472 793a 0a20 ll do. try:. \n-0001fd00: 2020 2020 2020 2070 726f 6320 3d20 7375 proc = su\n-0001fd10: 6270 726f 6365 7373 2e50 6f70 656e 285b bprocess.Popen([\n-0001fd20: 2773 7368 2d61 6765 6e74 272c 2027 7368 'ssh-agent', 'sh\n-0001fd30: 272c 2027 2d65 6327 2c20 2765 6368 6f20 ', '-ec', 'echo \n-0001fd40: 5353 485f 4155 5448 5f53 4f43 4b3d 2453 SSH_AUTH_SOCK=$S\n-0001fd50: 5348 5f41 5554 485f 534f 434b 3b20 7265 SH_AUTH_SOCK; re\n-0001fd60: 6164 2061 275d 2c0a 2020 2020 2020 2020 ad a'],. \n-0001fd70: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0001fd80: 2020 2020 2020 2020 7374 6469 6e3d 7375 stdin=su\n-0001fd90: 6270 726f 6365 7373 2e50 4950 452c 2073 bprocess.PIPE, s\n-0001fda0: 7464 6f75 743d 7375 6270 726f 6365 7373 tdout=subprocess\n-0001fdb0: 2e50 4950 452c 2075 6e69 7665 7273 616c .PIPE, universal\n-0001fdc0: 5f6e 6577 6c69 6e65 733d 5472 7565 290a _newlines=True).\n-0001fdd0: 2020 2020 2020 2020 6173 7365 7274 2070 assert p\n-0001fde0: 726f 632e 7374 646f 7574 2069 7320 6e6f roc.stdout is no\n-0001fdf0: 7420 4e6f 6e65 0a0a 2020 2020 2020 2020 t None.. \n-0001fe00: 2320 5761 6974 2066 6f72 2074 6865 2061 # Wait for the a\n-0001fe10: 6765 6e74 2074 6f20 7772 6974 6520 6174 gent to write at\n-0001fe20: 206c 6561 7374 206f 6e65 206c 696e 6520 least one line \n-0001fe30: 616e 6420 6c6f 6f6b 2066 6f72 2074 6865 and look for the\n-0001fe40: 0a20 2020 2020 2020 2023 206c 6973 7465 . # liste\n-0001fe50: 6e65 7220 736f 636b 6574 2e20 2049 6620 ner socket. If \n-0001fe60: 7765 2066 6169 6c20 746f 2066 696e 6420 we fail to find \n-0001fe70: 6974 2c20 6b69 6c6c 2074 6865 2061 6765 it, kill the age\n-0001fe80: 6e74 20e2 8094 2073 6f6d 6574 6869 6e67 nt ... something\n-0001fe90: 0a20 2020 2020 2020 2023 2077 656e 7420 . # went \n-0001fea0: 7772 6f6e 672e 0a20 2020 2020 2020 2066 wrong.. f\n-0001feb0: 6f72 2074 6f6b 656e 2069 6e20 7368 6c65 or token in shle\n-0001fec0: 782e 7368 6c65 7828 7072 6f63 2e73 7464 x.shlex(proc.std\n-0001fed0: 6f75 742e 7265 6164 6c69 6e65 2829 2c20 out.readline(), \n-0001fee0: 7075 6e63 7475 6174 696f 6e5f 6368 6172 punctuation_char\n-0001fef0: 733d 5472 7565 293a 0a20 2020 2020 2020 s=True):. \n-0001ff00: 2020 2020 2069 6620 746f 6b65 6e2e 7374 if token.st\n-0001ff10: 6172 7473 7769 7468 2827 5353 485f 4155 artswith('SSH_AU\n-0001ff20: 5448 5f53 4f43 4b3d 2729 3a0a 2020 2020 TH_SOCK='):. \n-0001ff30: 2020 2020 2020 2020 2020 2020 6f73 2e65 os.e\n-0001ff40: 6e76 6972 6f6e 5b27 5353 485f 4155 5448 nviron['SSH_AUTH\n-0001ff50: 5f53 4f43 4b27 5d20 3d20 746f 6b65 6e2e _SOCK'] = token.\n-0001ff60: 7265 706c 6163 6528 2753 5348 5f41 5554 replace('SSH_AUT\n-0001ff70: 485f 534f 434b 3d27 2c20 2727 2c20 3129 H_SOCK=', '', 1)\n-0001ff80: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-0001ff90: 2062 7265 616b 0a20 2020 2020 2020 2065 break. e\n-0001ffa0: 6c73 653a 0a20 2020 2020 2020 2020 2020 lse:. \n-0001ffb0: 2070 726f 632e 7465 726d 696e 6174 6528 proc.terminate(\n-0001ffc0: 290a 2020 2020 2020 2020 2020 2020 7072 ). pr\n-0001ffd0: 6f63 2e77 6169 7428 290a 0a20 2020 2065 oc.wait().. e\n-0001ffe0: 7863 6570 7420 4669 6c65 4e6f 7446 6f75 xcept FileNotFou\n-0001fff0: 6e64 4572 726f 723a 0a20 2020 2020 2020 ndError:. \n-00020000: 206c 6f67 6765 722e 6465 6275 6728 2243 logger.debug(\"C\n-00020010: 6f75 6c64 6e27 7420 7374 6172 7420 7373 ouldn't start ss\n-00020020: 682d 6167 656e 7420 2846 696c 654e 6f74 h-agent (FileNot\n-00020030: 466f 756e 6445 7272 6f72 2922 290a 0a20 FoundError)\").. \n-00020040: 2020 2065 7863 6570 7420 4f53 4572 726f except OSErro\n-00020050: 7220 6173 2065 7863 3a0a 2020 2020 2020 r as exc:. \n-00020060: 2020 6c6f 6767 6572 2e77 6172 6e69 6e67 logger.warning\n-00020070: 2822 436f 756c 6420 6e6f 7420 7374 6172 (\"Could not star\n-00020080: 7420 7373 682d 6167 656e 743a 2025 7322 t ssh-agent: %s\"\n-00020090: 2c20 6578 6329 0a0a 0a64 6566 206d 6169 , exc)...def mai\n-000200a0: 6e28 2a2c 2062 6569 7061 636b 3a20 626f n(*, beipack: bo\n-000200b0: 6f6c 203d 2046 616c 7365 2920 2d3e 204e ol = False) -> N\n-000200c0: 6f6e 653a 0a20 2020 2070 6f6c 7966 696c one:. polyfil\n-000200d0: 6c73 2e69 6e73 7461 6c6c 2829 0a0a 2020 ls.install().. \n-000200e0: 2020 7061 7273 6572 203d 2061 7267 7061 parser = argpa\n-000200f0: 7273 652e 4172 6775 6d65 6e74 5061 7273 rse.ArgumentPars\n-00020100: 6572 2864 6573 6372 6970 7469 6f6e 3d27 er(description='\n-00020110: 636f 636b 7069 742d 6272 6964 6765 2069 cockpit-bridge i\n-00020120: 7320 7275 6e20 6175 746f 6d61 7469 6361 s run automatica\n-00020130: 6c6c 7920 696e 7369 6465 206f 6620 6120 lly inside of a \n-00020140: 436f 636b 7069 7420 7365 7373 696f 6e2e Cockpit session.\n-00020150: 2729 0a20 2020 2070 6172 7365 722e 6164 '). parser.ad\n-00020160: 645f 6172 6775 6d65 6e74 2827 2d2d 7072 d_argument('--pr\n-00020170: 6976 696c 6567 6564 272c 2061 6374 696f ivileged', actio\n-00020180: 6e3d 2773 746f 7265 5f74 7275 6527 2c20 n='store_true', \n-00020190: 6865 6c70 3d27 5072 6976 696c 6567 6564 help='Privileged\n-000201a0: 2063 6f70 7920 6f66 2074 6865 2062 7269 copy of the bri\n-000201b0: 6467 6527 290a 2020 2020 7061 7273 6572 dge'). parser\n-000201c0: 2e61 6464 5f61 7267 756d 656e 7428 272d .add_argument('-\n-000201d0: 2d70 6163 6b61 6765 7327 2c20 6163 7469 -packages', acti\n-000201e0: 6f6e 3d27 7374 6f72 655f 7472 7565 272c on='store_true',\n-000201f0: 2068 656c 703d 2753 686f 7720 436f 636b help='Show Cock\n-00020200: 7069 7420 7061 636b 6167 6520 696e 666f pit package info\n-00020210: 726d 6174 696f 6e27 290a 2020 2020 7061 rmation'). pa\n-00020220: 7273 6572 2e61 6464 5f61 7267 756d 656e rser.add_argumen\n-00020230: 7428 272d 2d62 7269 6467 6573 272c 2061 t('--bridges', a\n-00020240: 6374 696f 6e3d 2773 746f 7265 5f74 7275 ction='store_tru\n-00020250: 6527 2c20 6865 6c70 3d27 5368 6f77 2043 e', help='Show C\n-00020260: 6f63 6b70 6974 2062 7269 6467 6573 2069 ockpit bridges i\n-00020270: 6e66 6f72 6d61 7469 6f6e 2729 0a20 2020 nformation'). \n-00020280: 2070 6172 7365 722e 6164 645f 6172 6775 parser.add_argu\n-00020290: 6d65 6e74 2827 2d2d 6465 6275 6727 2c20 ment('--debug', \n-000202a0: 6163 7469 6f6e 3d27 7374 6f72 655f 7472 action='store_tr\n-000202b0: 7565 272c 2068 656c 703d 2745 6e61 626c ue', help='Enabl\n-000202c0: 6520 6465 6275 6720 6f75 7470 7574 2028 e debug output (\n-000202d0: 7665 7279 2076 6572 626f 7365 2927 290a very verbose)').\n-000202e0: 2020 2020 7061 7273 6572 2e61 6464 5f61 parser.add_a\n-000202f0: 7267 756d 656e 7428 272d 2d76 6572 7369 rgument('--versi\n-00020300: 6f6e 272c 2061 6374 696f 6e3d 2773 746f on', action='sto\n-00020310: 7265 5f74 7275 6527 2c20 6865 6c70 3d27 re_true', help='\n-00020320: 5368 6f77 2043 6f63 6b70 6974 2076 6572 Show Cockpit ver\n-00020330: 7369 6f6e 2069 6e66 6f72 6d61 7469 6f6e sion information\n-00020340: 2729 0a20 2020 2061 7267 7320 3d20 7061 '). args = pa\n-00020350: 7273 6572 2e70 6172 7365 5f61 7267 7328 rser.parse_args(\n-00020360: 290a 0a20 2020 2023 2054 6869 7320 6973 ).. # This is\n-00020370: 2064 6574 6572 6d69 6e65 6420 6279 2077 determined by w\n-00020380: 686f 2063 616c 6c73 2075 730a 2020 2020 ho calls us. \n-00020390: 6172 6773 2e62 6569 7061 636b 203d 2062 args.beipack = b\n-000203a0: 6569 7061 636b 0a0a 2020 2020 2320 4966 eipack.. # If\n-000203b0: 2077 6520 7765 7265 2072 756e 2077 6974 we were run wit\n-000203c0: 6820 2d2d 7072 6976 696c 6567 6564 2074 h --privileged t\n-000203d0: 6865 6e20 6f75 7220 7374 6465 7272 2069 hen our stderr i\n-000203e0: 7320 6375 7272 656e 746c 7920 6265 696e s currently bein\n-000203f0: 670a 2020 2020 2320 636f 6e73 756d 6564 g. # consumed\n-00020400: 2062 7920 7468 6520 6d61 696e 2062 7269 by the main bri\n-00020410: 6467 6520 6c6f 6f6b 696e 6720 666f 7220 dge looking for \n-00020420: 7374 6172 7475 702d 7265 6c61 7465 6420 startup-related \n-00020430: 6572 726f 7220 6d65 7373 6167 6573 2e0a error messages..\n-00020440: 2020 2020 2320 4c65 7427 7320 7377 6974 # Let's swit\n-00020450: 6368 2062 6163 6b20 746f 2074 6865 206f ch back to the o\n-00020460: 7269 6769 6e61 6c20 7374 6465 7272 2073 riginal stderr s\n-00020470: 7472 6561 6d2c 2077 6869 6368 2068 6173 tream, which has\n-00020480: 2061 2073 6964 652d 6566 6665 6374 0a20 a side-effect. \n-00020490: 2020 2023 206f 6620 696e 6469 6361 7469 # of indicati\n-000204a0: 6e67 2074 6861 7420 6f75 7220 7374 6172 ng that our star\n-000204b0: 7475 7020 6973 206d 6f72 6520 6f72 206c tup is more or l\n-000204c0: 6573 7320 636f 6d70 6c65 7465 2e20 2041 ess complete. A\n-000204d0: 6e79 2065 7272 6f72 730a 2020 2020 2320 ny errors. # \n-000204e0: 6166 7465 7220 7468 6973 2070 6f69 6e74 after this point\n-000204f0: 2077 696c 6c20 6c61 6e64 2069 6e20 7468 will land in th\n-00020500: 6520 6a6f 7572 6e61 6c2e 0a20 2020 2069 e journal.. i\n-00020510: 6620 6172 6773 2e70 7269 7669 6c65 6765 f args.privilege\n-00020520: 643a 0a20 2020 2020 2020 2074 7279 5f74 d:. try_t\n-00020530: 6f5f 7265 6365 6976 655f 7374 6465 7272 o_receive_stderr\n-00020540: 2829 0a0a 2020 2020 7365 7475 705f 6c6f ().. setup_lo\n-00020550: 6767 696e 6728 6465 6275 673d 6172 6773 gging(debug=args\n-00020560: 2e64 6562 7567 290a 0a20 2020 2023 2053 .debug).. # S\n-00020570: 7065 6369 616c 206d 6f64 6573 0a20 2020 pecial modes. \n-00020580: 2069 6620 6172 6773 2e70 6163 6b61 6765 if args.package\n-00020590: 733a 0a20 2020 2020 2020 2050 6163 6b61 s:. Packa\n-000205a0: 6765 7328 292e 7368 6f77 2829 0a20 2020 ges().show(). \n-000205b0: 2020 2020 2072 6574 7572 6e0a 2020 2020 return. \n-000205c0: 656c 6966 2061 7267 732e 7665 7273 696f elif args.versio\n-000205d0: 6e3a 0a20 2020 2020 2020 2070 7269 6e74 n:. print\n-000205e0: 2866 2756 6572 7369 6f6e 3a20 7b5f 5f76 (f'Version: {__v\n-000205f0: 6572 7369 6f6e 5f5f 7d5c 6e50 726f 746f ersion__}\\nProto\n-00020600: 636f 6c3a 2031 2729 0a20 2020 2020 2020 col: 1'). \n-00020610: 2072 6574 7572 6e0a 2020 2020 656c 6966 return. elif\n-00020620: 2061 7267 732e 6272 6964 6765 733a 0a20 args.bridges:. \n-00020630: 2020 2020 2020 2070 7269 6e74 286a 736f print(jso\n-00020640: 6e2e 6475 6d70 7328 5b63 6f6e 6669 672e n.dumps([config.\n-00020650: 5f5f 6469 6374 5f5f 2066 6f72 2063 6f6e __dict__ for con\n-00020660: 6669 6720 696e 2050 6163 6b61 6765 7328 fig in Packages(\n-00020670: 292e 6765 745f 6272 6964 6765 5f63 6f6e ).get_bridge_con\n-00020680: 6669 6773 2829 5d2c 2069 6e64 656e 743d figs()], indent=\n-00020690: 3229 290a 2020 2020 2020 2020 7265 7475 2)). retu\n-000206a0: 726e 0a0a 2020 2020 2320 5468 6520 7072 rn.. # The pr\n-000206b0: 6976 696c 6567 6564 2062 7269 6467 6520 ivileged bridge \n-000206c0: 646f 6573 6e27 7420 6e65 6564 2073 7368 doesn't need ssh\n-000206d0: 2d61 6765 6e74 2c20 6275 7420 7468 6520 -agent, but the \n-000206e0: 6d61 696e 206f 6e65 2064 6f65 730a 2020 main one does. \n-000206f0: 2020 6966 2027 5353 485f 4155 5448 5f53 if 'SSH_AUTH_S\n-00020700: 4f43 4b27 206e 6f74 2069 6e20 6f73 2e65 OCK' not in os.e\n-00020710: 6e76 6972 6f6e 2061 6e64 206e 6f74 2061 nviron and not a\n-00020720: 7267 732e 7072 6976 696c 6567 6564 3a0a rgs.privileged:.\n-00020730: 2020 2020 2020 2020 7374 6172 745f 7373 start_ss\n-00020740: 685f 6167 656e 7428 290a 0a20 2020 2023 h_agent().. #\n-00020750: 2061 7379 6e63 696f 2e72 756e 2829 2073 asyncio.run() s\n-00020760: 6869 6d20 666f 7220 5079 7468 6f6e 2033 him for Python 3\n-00020770: 2e36 2073 7570 706f 7274 0a20 2020 2072 .6 support. r\n-00020780: 756e 5f61 7379 6e63 2872 756e 2861 7267 un_async(run(arg\n-00020790: 7329 2c20 6465 6275 673d 6172 6773 2e64 s), debug=args.d\n-000207a0: 6562 7567 290a 0a0a 6966 205f 5f6e 616d ebug)...if __nam\n-000207b0: 655f 5f20 3d3d 2027 5f5f 6d61 696e 5f5f e__ == '__main__\n-000207c0: 273a 0a20 2020 206d 6169 6e28 290a 2727 ':. main().''\n-000207d0: 272e 656e 636f 6465 2827 7574 662d 3827 '.encode('utf-8'\n-000207e0: 292c 0a20 2027 636f 636b 7069 742f 7375 ),. 'cockpit/su\n-000207f0: 7065 7275 7365 722e 7079 273a 2062 7227 peruser.py': br'\n-00020800: 2727 2320 5468 6973 2066 696c 6520 6973 ''# This file is\n-00020810: 2070 6172 7420 6f66 2043 6f63 6b70 6974 part of Cockpit\n-00020820: 2e0a 230a 2320 436f 7079 7269 6768 7420 ..#.# Copyright \n-00020830: 2843 2920 3230 3232 2052 6564 2048 6174 (C) 2022 Red Hat\n-00020840: 2c20 496e 632e 0a23 0a23 2054 6869 7320 , Inc..#.# This \n-00020850: 7072 6f67 7261 6d20 6973 2066 7265 6520 program is free \n-00020860: 736f 6674 7761 7265 3a20 796f 7520 6361 software: you ca\n-00020870: 6e20 7265 6469 7374 7269 6275 7465 2069 n redistribute i\n-00020880: 7420 616e 642f 6f72 206d 6f64 6966 790a t and/or modify.\n-00020890: 2320 6974 2075 6e64 6572 2074 6865 2074 # it under the t\n-000208a0: 6572 6d73 206f 6620 7468 6520 474e 5520 erms of the GNU \n-000208b0: 4765 6e65 7261 6c20 5075 626c 6963 204c General Public L\n-000208c0: 6963 656e 7365 2061 7320 7075 626c 6973 icense as publis\n-000208d0: 6865 6420 6279 0a23 2074 6865 2046 7265 hed by.# the Fre\n-000208e0: 6520 536f 6674 7761 7265 2046 6f75 6e64 e Software Found\n-000208f0: 6174 696f 6e2c 2065 6974 6865 7220 7665 ation, either ve\n-00020900: 7273 696f 6e20 3320 6f66 2074 6865 204c rsion 3 of the L\n-00020910: 6963 656e 7365 2c20 6f72 0a23 2028 6174 icense, or.# (at\n-00020920: 2079 6f75 7220 6f70 7469 6f6e 2920 616e your option) an\n-00020930: 7920 6c61 7465 7220 7665 7273 696f 6e2e y later version.\n-00020940: 0a23 0a23 2054 6869 7320 7072 6f67 7261 .#.# This progra\n-00020950: 6d20 6973 2064 6973 7472 6962 7574 6564 m is distributed\n-00020960: 2069 6e20 7468 6520 686f 7065 2074 6861 in the hope tha\n-00020970: 7420 6974 2077 696c 6c20 6265 2075 7365 t it will be use\n-00020980: 6675 6c2c 0a23 2062 7574 2057 4954 484f ful,.# but WITHO\n-00020990: 5554 2041 4e59 2057 4152 5241 4e54 593b UT ANY WARRANTY;\n-000209a0: 2077 6974 686f 7574 2065 7665 6e20 7468 without even th\n-000209b0: 6520 696d 706c 6965 6420 7761 7272 616e e implied warran\n-000209c0: 7479 206f 660a 2320 4d45 5243 4841 4e54 ty of.# MERCHANT\n-000209d0: 4142 494c 4954 5920 6f72 2046 4954 4e45 ABILITY or FITNE\n-000209e0: 5353 2046 4f52 2041 2050 4152 5449 4355 SS FOR A PARTICU\n-000209f0: 4c41 5220 5055 5250 4f53 452e 2020 5365 LAR PURPOSE. Se\n-00020a00: 6520 7468 650a 2320 474e 5520 4765 6e65 e the.# GNU Gene\n-00020a10: 7261 6c20 5075 626c 6963 204c 6963 656e ral Public Licen\n-00020a20: 7365 2066 6f72 206d 6f72 6520 6465 7461 se for more deta\n-00020a30: 696c 732e 0a23 0a23 2059 6f75 2073 686f ils..#.# You sho\n-00020a40: 756c 6420 6861 7665 2072 6563 6569 7665 uld have receive\n-00020a50: 6420 6120 636f 7079 206f 6620 7468 6520 d a copy of the \n-00020a60: 474e 5520 4765 6e65 7261 6c20 5075 626c GNU General Publ\n-00020a70: 6963 204c 6963 656e 7365 0a23 2061 6c6f ic License.# alo\n-00020a80: 6e67 2077 6974 6820 7468 6973 2070 726f ng with this pro\n-00020a90: 6772 616d 2e20 2049 6620 6e6f 742c 2073 gram. If not, s\n-00020aa0: 6565 203c 6874 7470 733a 2f2f 7777 772e ee ...import arra\n-00020ad0: 790a 696d 706f 7274 2061 7379 6e63 696f y.import asyncio\n-00020ae0: 0a69 6d70 6f72 7420 636f 6e74 6578 746c .import contextl\n-00020af0: 6962 0a69 6d70 6f72 7420 6765 7470 6173 ib.import getpas\n-00020b00: 730a 696d 706f 7274 206c 6f67 6769 6e67 s.import logging\n-00020b10: 0a69 6d70 6f72 7420 6f73 0a69 6d70 6f72 .import os.impor\n-00020b20: 7420 736f 636b 6574 0a66 726f 6d20 7465 t socket.from te\n-00020b30: 6d70 6669 6c65 2069 6d70 6f72 7420 5465 mpfile import Te\n-00020b40: 6d70 6f72 6172 7944 6972 6563 746f 7279 mporaryDirectory\n-00020b50: 0a66 726f 6d20 7479 7069 6e67 2069 6d70 .from typing imp\n-00020b60: 6f72 7420 4c69 7374 2c20 4f70 7469 6f6e ort List, Option\n-00020b70: 616c 2c20 5365 7175 656e 6365 2c20 5475 al, Sequence, Tu\n-00020b80: 706c 650a 0a66 726f 6d20 636f 636b 7069 ple..from cockpi\n-00020b90: 742e 5f76 656e 646f 7220 696d 706f 7274 t._vendor import\n-00020ba0: 2066 6572 6e79 0a66 726f 6d20 636f 636b ferny.from cock\n-00020bb0: 7069 742e 5f76 656e 646f 722e 6265 692e pit._vendor.bei.\n-00020bc0: 626f 6f74 6c6f 6164 6572 2069 6d70 6f72 bootloader impor\n-00020bd0: 7420 6d61 6b65 5f62 6f6f 746c 6f61 6465 t make_bootloade\n-00020be0: 720a 6672 6f6d 2063 6f63 6b70 6974 2e5f r.from cockpit._\n-00020bf0: 7665 6e64 6f72 2e73 7973 7465 6d64 5f63 vendor.systemd_c\n-00020c00: 7479 7065 7320 696d 706f 7274 2056 6172 types import Var\n-00020c10: 6961 6e74 2c20 6275 730a 0a66 726f 6d20 iant, bus..from \n-00020c20: 2e62 6569 7061 636b 2069 6d70 6f72 7420 .beipack import \n-00020c30: 4272 6964 6765 4265 6962 6f6f 7448 656c BridgeBeibootHel\n-00020c40: 7065 720a 6672 6f6d 202e 6a73 6f6e 7574 per.from .jsonut\n-00020c50: 696c 2069 6d70 6f72 7420 4a73 6f6e 4f62 il import JsonOb\n-00020c60: 6a65 6374 2c20 6765 745f 7374 720a 6672 ject, get_str.fr\n-00020c70: 6f6d 202e 7061 636b 6167 6573 2069 6d70 om .packages imp\n-00020c80: 6f72 7420 4272 6964 6765 436f 6e66 6967 ort BridgeConfig\n-00020c90: 0a66 726f 6d20 2e70 6565 7220 696d 706f .from .peer impo\n-00020ca0: 7274 2043 6f6e 6669 6775 7265 6450 6565 rt ConfiguredPee\n-00020cb0: 722c 2050 6565 722c 2050 6565 7245 7272 r, Peer, PeerErr\n-00020cc0: 6f72 0a66 726f 6d20 2e70 6f6c 6b69 7420 or.from .polkit \n-00020cd0: 696d 706f 7274 2050 6f6c 6b69 7441 6765 import PolkitAge\n-00020ce0: 6e74 0a66 726f 6d20 2e72 6f75 7465 7220 nt.from .router \n-00020cf0: 696d 706f 7274 2052 6f75 7465 722c 2052 import Router, R\n-00020d00: 6f75 7469 6e67 4572 726f 722c 2052 6f75 outingError, Rou\n-00020d10: 7469 6e67 5275 6c65 0a0a 6c6f 6767 6572 tingRule..logger\n-00020d20: 203d 206c 6f67 6769 6e67 2e67 6574 4c6f = logging.getLo\n-00020d30: 6767 6572 285f 5f6e 616d 655f 5f29 0a0a gger(__name__)..\n-00020d40: 0a63 6c61 7373 2053 7570 6572 7573 6572 .class Superuser\n-00020d50: 5065 6572 2843 6f6e 6669 6775 7265 6450 Peer(ConfiguredP\n-00020d60: 6565 7229 3a0a 2020 2020 7265 7370 6f6e eer):. respon\n-00020d70: 6465 723a 2066 6572 6e79 2e41 736b 7061 der: ferny.Askpa\n-00020d80: 7373 4861 6e64 6c65 720a 0a20 2020 2064 ssHandler.. d\n-00020d90: 6566 205f 5f69 6e69 745f 5f28 7365 6c66 ef __init__(self\n-00020da0: 2c20 726f 7574 6572 3a20 526f 7574 6572 , router: Router\n-00020db0: 2c20 636f 6e66 6967 3a20 4272 6964 6765 , config: Bridge\n-00020dc0: 436f 6e66 6967 2c20 7265 7370 6f6e 6465 Config, responde\n-00020dd0: 723a 2066 6572 6e79 2e41 736b 7061 7373 r: ferny.Askpass\n-00020de0: 4861 6e64 6c65 7229 3a0a 2020 2020 2020 Handler):. \n-00020df0: 2020 7375 7065 7228 292e 5f5f 696e 6974 super().__init\n-00020e00: 5f5f 2872 6f75 7465 722c 2063 6f6e 6669 __(router, confi\n-00020e10: 6729 0a20 2020 2020 2020 2073 656c 662e g). self.\n-00020e20: 7265 7370 6f6e 6465 7220 3d20 7265 7370 responder = resp\n-00020e30: 6f6e 6465 720a 0a20 2020 2061 7379 6e63 onder.. async\n-00020e40: 2064 6566 2064 6f5f 636f 6e6e 6563 745f def do_connect_\n-00020e50: 7472 616e 7370 6f72 7428 7365 6c66 2920 transport(self) \n-00020e60: 2d3e 204e 6f6e 653a 0a20 2020 2020 2020 -> None:. \n-00020e70: 2061 7379 6e63 2077 6974 6820 636f 6e74 async with cont\n-00020e80: 6578 746c 6962 2e41 7379 6e63 4578 6974 extlib.AsyncExit\n-00020e90: 5374 6163 6b28 2920 6173 2063 6f6e 7465 Stack() as conte\n-00020ea0: 7874 3a0a 2020 2020 2020 2020 2020 2020 xt:. \n-00020eb0: 6966 2027 706b 6578 6563 2720 696e 2073 if 'pkexec' in s\n-00020ec0: 656c 662e 6172 6773 3a0a 2020 2020 2020 elf.args:. \n-00020ed0: 2020 2020 2020 2020 2020 6c6f 6767 6572 logger\n-00020ee0: 2e64 6562 7567 2827 636f 6e6e 6563 7469 .debug('connecti\n-00020ef0: 6e67 2070 6f6c 6b69 7420 7375 7065 7275 ng polkit superu\n-00020f00: 7365 7220 7065 6572 2074 7261 6e73 706f ser peer transpo\n-00020f10: 7274 2025 7227 2c20 7365 6c66 2e61 7267 rt %r', self.arg\n-00020f20: 7329 0a20 2020 2020 2020 2020 2020 2020 s). \n-00020f30: 2020 2061 7761 6974 2063 6f6e 7465 7874 await context\n-00020f40: 2e65 6e74 6572 5f61 7379 6e63 5f63 6f6e .enter_async_con\n-00020f50: 7465 7874 2850 6f6c 6b69 7441 6765 6e74 text(PolkitAgent\n-00020f60: 2873 656c 662e 7265 7370 6f6e 6465 7229 (self.responder)\n-00020f70: 290a 2020 2020 2020 2020 2020 2020 656c ). el\n-00020f80: 7365 3a0a 2020 2020 2020 2020 2020 2020 se:. \n-00020f90: 2020 2020 6c6f 6767 6572 2e64 6562 7567 logger.debug\n-00020fa0: 2827 636f 6e6e 6563 7469 6e67 206e 6f6e ('connecting non\n-00020fb0: 2d70 6f6c 6b69 7420 7375 7065 7275 7365 -polkit superuse\n-00020fc0: 7220 7065 6572 2074 7261 6e73 706f 7274 r peer transport\n-00020fd0: 2025 7227 2c20 7365 6c66 2e61 7267 7329 %r', self.args)\n-00020fe0: 0a0a 2020 2020 2020 2020 2020 2020 7265 .. re\n-00020ff0: 7370 6f6e 6465 7273 3a20 276c 6973 745b sponders: 'list[\n-00021000: 6665 726e 792e 496e 7465 7261 6374 696f ferny.Interactio\n-00021010: 6e48 616e 646c 6572 5d27 203d 205b 7365 nHandler]' = [se\n-00021020: 6c66 2e72 6573 706f 6e64 6572 5d0a 0a20 lf.responder].. \n-00021030: 2020 2020 2020 2020 2020 2069 6620 2723 if '#\n-00021040: 2063 6f63 6b70 6974 2d62 7269 6467 6527 cockpit-bridge'\n-00021050: 2069 6e20 7365 6c66 2e61 7267 733a 0a20 in self.args:. \n-00021060: 2020 2020 2020 2020 2020 2020 2020 206c l\n-00021070: 6f67 6765 722e 6465 6275 6728 2767 6f69 ogger.debug('goi\n-00021080: 6e67 2074 6f20 6265 6962 6f6f 7420 7375 ng to beiboot su\n-00021090: 7065 7275 7365 7220 6272 6964 6765 2025 peruser bridge %\n-000210a0: 7227 2c20 7365 6c66 2e61 7267 7329 0a20 r', self.args). \n-000210b0: 2020 2020 2020 2020 2020 2020 2020 2068 h\n-000210c0: 656c 7065 7220 3d20 4272 6964 6765 4265 elper = BridgeBe\n-000210d0: 6962 6f6f 7448 656c 7065 7228 7365 6c66 ibootHelper(self\n-000210e0: 2c20 5b27 2d2d 7072 6976 696c 6567 6564 , ['--privileged\n-000210f0: 275d 290a 2020 2020 2020 2020 2020 2020 ']). \n-00021100: 2020 2020 7265 7370 6f6e 6465 7273 2e61 responders.a\n-00021110: 7070 656e 6428 6865 6c70 6572 290a 2020 ppend(helper). \n-00021120: 2020 2020 2020 2020 2020 2020 2020 7374 st\n-00021130: 6167 6531 203d 206d 616b 655f 626f 6f74 age1 = make_boot\n-00021140: 6c6f 6164 6572 2868 656c 7065 722e 7374 loader(helper.st\n-00021150: 6570 732c 2067 6164 6765 7473 3d66 6572 eps, gadgets=fer\n-00021160: 6e79 2e42 4549 424f 4f54 5f47 4144 4745 ny.BEIBOOT_GADGE\n-00021170: 5453 292e 656e 636f 6465 2829 0a20 2020 TS).encode(). \n-00021180: 2020 2020 2020 2020 2065 6c73 653a 0a20 else:. \n-00021190: 2020 2020 2020 2020 2020 2020 2020 2073 s\n-000211a0: 7461 6765 3120 3d20 4e6f 6e65 0a0a 2020 tage1 = None.. \n-000211b0: 2020 2020 2020 2020 2020 6167 656e 7420 agent \n-000211c0: 3d20 6665 726e 792e 496e 7465 7261 6374 = ferny.Interact\n-000211d0: 696f 6e41 6765 6e74 2872 6573 706f 6e64 ionAgent(respond\n-000211e0: 6572 7329 0a0a 2020 2020 2020 2020 2020 ers).. \n-000211f0: 2020 6966 2027 5355 444f 5f41 534b 5041 if 'SUDO_ASKPA\n-00021200: 5353 3d66 6572 6e79 2d61 736b 7061 7373 SS=ferny-askpass\n-00021210: 2720 696e 2073 656c 662e 656e 763a 0a20 ' in self.env:. \n-00021220: 2020 2020 2020 2020 2020 2020 2020 2074 t\n-00021230: 6d70 6469 7220 3d20 636f 6e74 6578 742e mpdir = context.\n-00021240: 656e 7465 725f 636f 6e74 6578 7428 5465 enter_context(Te\n-00021250: 6d70 6f72 6172 7944 6972 6563 746f 7279 mporaryDirectory\n-00021260: 2829 290a 2020 2020 2020 2020 2020 2020 ()). \n-00021270: 2020 2020 6665 726e 795f 6173 6b70 6173 ferny_askpas\n-00021280: 7320 3d20 6665 726e 792e 7772 6974 655f s = ferny.write_\n-00021290: 6173 6b70 6173 735f 746f 5f74 6d70 6469 askpass_to_tmpdi\n-000212a0: 7228 746d 7064 6972 290a 2020 2020 2020 r(tmpdir). \n-000212b0: 2020 2020 2020 2020 2020 656e 763a 2053 env: S\n-000212c0: 6571 7565 6e63 655b 7374 725d 203d 205b equence[str] = [\n-000212d0: 6627 5355 444f 5f41 534b 5041 5353 3d7b f'SUDO_ASKPASS={\n-000212e0: 6665 726e 795f 6173 6b70 6173 737d 275d ferny_askpass}']\n-000212f0: 0a20 2020 2020 2020 2020 2020 2065 6c73 . els\n-00021300: 653a 0a20 2020 2020 2020 2020 2020 2020 e:. \n-00021310: 2020 2065 6e76 203d 2073 656c 662e 656e env = self.en\n-00021320: 760a 0a20 2020 2020 2020 2020 2020 2074 v.. t\n-00021330: 7261 6e73 706f 7274 203d 2061 7761 6974 ransport = await\n-00021340: 2073 656c 662e 7370 6177 6e28 7365 6c66 self.spawn(self\n-00021350: 2e61 7267 732c 2065 6e76 2c20 7374 6465 .args, env, stde\n-00021360: 7272 3d61 6765 6e74 2c20 7374 6172 745f rr=agent, start_\n-00021370: 6e65 775f 7365 7373 696f 6e3d 5472 7565 new_session=True\n-00021380: 290a 0a20 2020 2020 2020 2020 2020 2069 ).. i\n-00021390: 6620 7374 6167 6531 2069 7320 6e6f 7420 f stage1 is not \n-000213a0: 4e6f 6e65 3a0a 2020 2020 2020 2020 2020 None:. \n-000213b0: 2020 2020 2020 7472 616e 7370 6f72 742e transport.\n-000213c0: 7772 6974 6528 7374 6167 6531 290a 0a20 write(stage1).. \n-000213d0: 2020 2020 2020 2020 2020 2074 7279 3a0a try:.\n-000213e0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000213f0: 6177 6169 7420 6167 656e 742e 636f 6d6d await agent.comm\n-00021400: 756e 6963 6174 6528 290a 2020 2020 2020 unicate(). \n-00021410: 2020 2020 2020 6578 6365 7074 2066 6572 except fer\n-00021420: 6e79 2e49 6e74 6572 6163 7469 6f6e 4572 ny.InteractionEr\n-00021430: 726f 7220 6173 2065 7863 3a0a 2020 2020 ror as exc:. \n-00021440: 2020 2020 2020 2020 2020 2020 7261 6973 rais\n-00021450: 6520 5065 6572 4572 726f 7228 2761 7574 e PeerError('aut\n-00021460: 6865 6e74 6963 6174 696f 6e2d 6661 696c hentication-fail\n-00021470: 6564 272c 206d 6573 7361 6765 3d73 7472 ed', message=str\n-00021480: 2865 7863 2929 2066 726f 6d20 6578 630a (exc)) from exc.\n-00021490: 0a0a 636c 6173 7320 436f 636b 7069 7452 ..class CockpitR\n-000214a0: 6573 706f 6e64 6572 2866 6572 6e79 2e41 esponder(ferny.A\n-000214b0: 736b 7061 7373 4861 6e64 6c65 7229 3a0a skpassHandler):.\n-000214c0: 2020 2020 636f 6d6d 616e 6473 203d 2028 commands = (\n-000214d0: 2766 6572 6e79 2e61 736b 7061 7373 272c 'ferny.askpass',\n-000214e0: 2027 636f 636b 7069 742e 7365 6e64 2d73 'cockpit.send-s\n-000214f0: 7464 6572 7227 290a 0a20 2020 2061 7379 tderr').. asy\n-00021500: 6e63 2064 6566 2064 6f5f 6375 7374 6f6d nc def do_custom\n-00021510: 5f63 6f6d 6d61 6e64 2873 656c 662c 2063 _command(self, c\n-00021520: 6f6d 6d61 6e64 3a20 7374 722c 2061 7267 ommand: str, arg\n-00021530: 733a 2054 7570 6c65 2c20 6664 733a 204c s: Tuple, fds: L\n-00021540: 6973 745b 696e 745d 2c20 7374 6465 7272 ist[int], stderr\n-00021550: 3a20 7374 7229 202d 3e20 4e6f 6e65 3a0a : str) -> None:.\n-00021560: 2020 2020 2020 2020 6966 2063 6f6d 6d61 if comma\n-00021570: 6e64 203d 3d20 2763 6f63 6b70 6974 2e73 nd == 'cockpit.s\n-00021580: 656e 642d 7374 6465 7272 273a 0a20 2020 end-stderr':. \n-00021590: 2020 2020 2020 2020 2077 6974 6820 736f with so\n-000215a0: 636b 6574 2e73 6f63 6b65 7428 6669 6c65 cket.socket(file\n-000215b0: 6e6f 3d66 6473 5b30 5d29 2061 7320 736f no=fds[0]) as so\n-000215c0: 636b 3a0a 2020 2020 2020 2020 2020 2020 ck:. \n-000215d0: 2020 2020 6664 732e 706f 7028 3029 0a20 fds.pop(0). \n-000215e0: 2020 2020 2020 2020 2020 2020 2020 2023 #\n-000215f0: 2073 6f63 6b65 742e 7365 6e64 5f66 6473 socket.send_fds\n-00021600: 2873 6f63 6b2c 205b 6227 5c30 275d 2c20 (sock, [b'\\0'], \n-00021610: 5b32 5d29 2020 2320 4e65 7720 696e 2050 [2]) # New in P\n-00021620: 7974 686f 6e20 332e 390a 2020 2020 2020 ython 3.9. \n-00021630: 2020 2020 2020 2020 2020 736f 636b 2e73 sock.s\n-00021640: 656e 646d 7367 285b 6227 5c30 275d 2c20 endmsg([b'\\0'], \n-00021650: 5b28 736f 636b 6574 2e53 4f4c 5f53 4f43 [(socket.SOL_SOC\n-00021660: 4b45 542c 2073 6f63 6b65 742e 5343 4d5f KET, socket.SCM_\n-00021670: 5249 4748 5453 2c20 6172 7261 792e 6172 RIGHTS, array.ar\n-00021680: 7261 7928 2269 222c 205b 325d 2929 5d29 ray(\"i\", [2]))])\n-00021690: 0a0a 0a63 6c61 7373 2041 7574 686f 7269 ...class Authori\n-000216a0: 7a65 5265 7370 6f6e 6465 7228 436f 636b zeResponder(Cock\n-000216b0: 7069 7452 6573 706f 6e64 6572 293a 0a20 pitResponder):. \n-000216c0: 2020 2064 6566 205f 5f69 6e69 745f 5f28 def __init__(\n-000216d0: 7365 6c66 2c20 726f 7574 6572 3a20 526f self, router: Ro\n-000216e0: 7574 6572 293a 0a20 2020 2020 2020 2073 uter):. s\n-000216f0: 656c 662e 726f 7574 6572 203d 2072 6f75 elf.router = rou\n-00021700: 7465 720a 0a20 2020 2061 7379 6e63 2064 ter.. async d\n-00021710: 6566 2064 6f5f 6173 6b70 6173 7328 7365 ef do_askpass(se\n-00021720: 6c66 2c20 6d65 7373 6167 6573 3a20 7374 lf, messages: st\n-00021730: 722c 2070 726f 6d70 743a 2073 7472 2c20 r, prompt: str, \n-00021740: 6869 6e74 3a20 7374 7229 202d 3e20 7374 hint: str) -> st\n-00021750: 723a 0a20 2020 2020 2020 2068 6578 7573 r:. hexus\n-00021760: 6572 203d 2027 272e 6a6f 696e 2866 277b er = ''.join(f'{\n-00021770: 633a 3032 787d 2720 666f 7220 6320 696e c:02x}' for c in\n-00021780: 2067 6574 7061 7373 2e67 6574 7573 6572 getpass.getuser\n-00021790: 2829 2e65 6e63 6f64 6528 2761 7363 6969 ().encode('ascii\n-000217a0: 2729 290a 2020 2020 2020 2020 7265 7475 ')). retu\n-000217b0: 726e 2061 7761 6974 2073 656c 662e 726f rn await self.ro\n-000217c0: 7574 6572 2e72 6571 7565 7374 5f61 7574 uter.request_aut\n-000217d0: 686f 7269 7a61 7469 6f6e 2866 2770 6c61 horization(f'pla\n-000217e0: 696e 313a 7b68 6578 7573 6572 7d27 290a in1:{hexuser}').\n-000217f0: 0a0a 636c 6173 7320 5375 7065 7275 7365 ..class Superuse\n-00021800: 7252 6f75 7469 6e67 5275 6c65 2852 6f75 rRoutingRule(Rou\n-00021810: 7469 6e67 5275 6c65 2c20 436f 636b 7069 tingRule, Cockpi\n-00021820: 7452 6573 706f 6e64 6572 2c20 6275 732e tResponder, bus.\n-00021830: 4f62 6a65 6374 2c20 696e 7465 7266 6163 Object, interfac\n-00021840: 653d 2763 6f63 6b70 6974 2e53 7570 6572 e='cockpit.Super\n-00021850: 7573 6572 2729 3a0a 2020 2020 7375 7065 user'):. supe\n-00021860: 7275 7365 725f 636f 6e66 6967 733a 2053 ruser_configs: S\n-00021870: 6571 7565 6e63 655b 4272 6964 6765 436f equence[BridgeCo\n-00021880: 6e66 6967 5d20 3d20 2829 0a20 2020 2070 nfig] = (). p\n-00021890: 656e 6469 6e67 5f70 726f 6d70 743a 204f ending_prompt: O\n-000218a0: 7074 696f 6e61 6c5b 6173 796e 6369 6f2e ptional[asyncio.\n-000218b0: 4675 7475 7265 5d0a 2020 2020 7065 6572 Future]. peer\n-000218c0: 3a20 4f70 7469 6f6e 616c 5b53 7570 6572 : Optional[Super\n-000218d0: 7573 6572 5065 6572 5d0a 0a20 2020 2023 userPeer].. #\n-000218e0: 2044 2d42 7573 2073 6967 6e61 6c73 0a20 D-Bus signals. \n-000218f0: 2020 2070 726f 6d70 7420 3d20 6275 732e prompt = bus.\n-00021900: 496e 7465 7266 6163 652e 5369 676e 616c Interface.Signal\n-00021910: 2827 7327 2c20 2773 272c 2027 7327 2c20 ('s', 's', 's', \n-00021920: 2762 272c 2027 7327 2920 2023 206d 6573 'b', 's') # mes\n-00021930: 7361 6765 2c20 7072 6f6d 7074 2c20 6465 sage, prompt, de\n-00021940: 6661 756c 742c 2065 6368 6f2c 2065 7272 fault, echo, err\n-00021950: 6f72 0a0a 2020 2020 2320 442d 4275 7320 or.. # D-Bus \n-00021960: 7072 6f70 6572 7469 6573 0a20 2020 2062 properties. b\n-00021970: 7269 6467 6573 203d 2062 7573 2e49 6e74 ridges = bus.Int\n-00021980: 6572 6661 6365 2e50 726f 7065 7274 7928 erface.Property(\n-00021990: 2761 7327 2c20 7661 6c75 653d 5b5d 290a 'as', value=[]).\n-000219a0: 2020 2020 6375 7272 656e 7420 3d20 6275 current = bu\n-000219b0: 732e 496e 7465 7266 6163 652e 5072 6f70 s.Interface.Prop\n-000219c0: 6572 7479 2827 7327 2c20 7661 6c75 653d erty('s', value=\n-000219d0: 276e 6f6e 6527 290a 2020 2020 6d65 7468 'none'). meth\n-000219e0: 6f64 7320 3d20 6275 732e 496e 7465 7266 ods = bus.Interf\n-000219f0: 6163 652e 5072 6f70 6572 7479 2827 617b ace.Property('a{\n-00021a00: 7376 7d27 2c20 7661 6c75 653d 7b7d 290a sv}', value={}).\n-00021a10: 0a20 2020 2023 2052 6f75 7469 6e67 5275 . # RoutingRu\n-00021a20: 6c65 0a20 2020 2064 6566 2061 7070 6c79 le. def apply\n-00021a30: 5f72 756c 6528 7365 6c66 2c20 6f70 7469 _rule(self, opti\n-00021a40: 6f6e 733a 204a 736f 6e4f 626a 6563 7429 ons: JsonObject)\n-00021a50: 202d 3e20 4f70 7469 6f6e 616c 5b50 6565 -> Optional[Pee\n-00021a60: 725d 3a0a 2020 2020 2020 2020 7375 7065 r]:. supe\n-00021a70: 7275 7365 7220 3d20 6f70 7469 6f6e 732e ruser = options.\n-00021a80: 6765 7428 2773 7570 6572 7573 6572 2729 get('superuser')\n-00021a90: 0a0a 2020 2020 2020 2020 6966 206e 6f74 .. if not\n-00021aa0: 2073 7570 6572 7573 6572 206f 7220 7365 superuser or se\n-00021ab0: 6c66 2e63 7572 7265 6e74 203d 3d20 2772 lf.current == 'r\n-00021ac0: 6f6f 7427 3a0a 2020 2020 2020 2020 2020 oot':. \n-00021ad0: 2020 2320 7375 7065 7275 7365 7220 6e6f # superuser no\n-00021ae0: 7420 7265 7175 6573 7465 642c 206f 7220 t requested, or \n-00021af0: 616c 7265 6164 7920 7375 7065 7275 7365 already superuse\n-00021b00: 723f 2020 4e65 7874 2072 756c 652e 0a20 r? Next rule.. \n-00021b10: 2020 2020 2020 2020 2020 2072 6574 7572 retur\n-00021b20: 6e20 4e6f 6e65 0a20 2020 2020 2020 2065 n None. e\n-00021b30: 6c69 6620 7365 6c66 2e70 6565 7220 6f72 lif self.peer or\n-00021b40: 2073 7570 6572 7573 6572 203d 3d20 2774 superuser == 't\n-00021b50: 7279 273a 0a20 2020 2020 2020 2020 2020 ry':. \n-00021b60: 2023 2073 7570 6572 7573 6572 2072 6571 # superuser req\n-00021b70: 7565 7374 6564 2061 6e64 2061 6374 6976 uested and activ\n-00021b80: 653f 2020 5265 7475 726e 2069 742e 0a20 e? Return it.. \n-00021b90: 2020 2020 2020 2020 2020 2023 2027 7472 # 'tr\n-00021ba0: 7927 2072 6571 7565 7374 6564 3f20 2045 y' requested? E\n-00021bb0: 6974 6865 7220 7265 7475 726e 2074 6865 ither return the\n-00021bc0: 2070 6565 722c 206f 7220 4e6f 6e65 2e0a peer, or None..\n-00021bd0: 2020 2020 2020 2020 2020 2020 7265 7475 retu\n-00021be0: 726e 2073 656c 662e 7065 6572 0a20 2020 rn self.peer. \n-00021bf0: 2020 2020 2065 6c73 653a 0a20 2020 2020 else:. \n-00021c00: 2020 2020 2020 2023 2073 7570 6572 7573 # superus\n-00021c10: 6572 2072 6571 7565 7374 6564 2c20 6275 er requested, bu\n-00021c20: 7420 6e6f 7420 6163 7469 7665 3f20 2054 t not active? T\n-00021c30: 6861 7427 7320 616e 2065 7272 6f72 2e0a hat's an error..\n-00021c40: 2020 2020 2020 2020 2020 2020 7261 6973 rais\n-00021c50: 6520 526f 7574 696e 6745 7272 6f72 2827 e RoutingError('\n-00021c60: 6163 6365 7373 2d64 656e 6965 6427 290a access-denied').\n-00021c70: 0a20 2020 2023 2066 6572 6e79 2e41 736b . # ferny.Ask\n-00021c80: 7061 7373 4861 6e64 6c65 720a 2020 2020 passHandler. \n-00021c90: 6173 796e 6320 6465 6620 646f 5f61 736b async def do_ask\n-00021ca0: 7061 7373 2873 656c 662c 206d 6573 7361 pass(self, messa\n-00021cb0: 6765 733a 2073 7472 2c20 7072 6f6d 7074 ges: str, prompt\n-00021cc0: 3a20 7374 722c 2068 696e 743a 2073 7472 : str, hint: str\n-00021cd0: 2920 2d3e 204f 7074 696f 6e61 6c5b 7374 ) -> Optional[st\n-00021ce0: 725d 3a0a 2020 2020 2020 2020 6173 7365 r]:. asse\n-00021cf0: 7274 2073 656c 662e 7065 6e64 696e 675f rt self.pending_\n-00021d00: 7072 6f6d 7074 2069 7320 4e6f 6e65 0a20 prompt is None. \n-00021d10: 2020 2020 2020 2065 6368 6f20 3d20 6869 echo = hi\n-00021d20: 6e74 203d 3d20 2263 6f6e 6669 726d 220a nt == \"confirm\".\n-00021d30: 2020 2020 2020 2020 7365 6c66 2e70 656e self.pen\n-00021d40: 6469 6e67 5f70 726f 6d70 7420 3d20 6173 ding_prompt = as\n-00021d50: 796e 6369 6f2e 6765 745f 7275 6e6e 696e yncio.get_runnin\n-00021d60: 675f 6c6f 6f70 2829 2e63 7265 6174 655f g_loop().create_\n-00021d70: 6675 7475 7265 2829 0a20 2020 2020 2020 future(). \n-00021d80: 2074 7279 3a0a 2020 2020 2020 2020 2020 try:. \n-00021d90: 2020 6c6f 6767 6572 2e64 6562 7567 2827 logger.debug('\n-00021da0: 7072 6f6d 7074 696e 6720 666f 7220 2573 prompting for %s\n-00021db0: 272c 2070 726f 6d70 7429 0a20 2020 2020 ', prompt). \n-00021dc0: 2020 2020 2020 2023 2077 6974 6820 7375 # with su\n-00021dd0: 646f 2c20 616c 6c20 7374 6465 7272 206d do, all stderr m\n-00021de0: 6573 7361 6765 7320 6172 6520 7472 6561 essages are trea\n-00021df0: 7465 6420 6173 2077 6172 6e69 6e67 2f65 ted as warning/e\n-00021e00: 7272 6f72 7320 6279 2074 6865 2055 490a rrors by the UI.\n-00021e10: 2020 2020 2020 2020 2020 2020 2320 2873 # (s\n-00021e20: 7563 6820 6173 2074 6865 206c 6563 7475 uch as the lectu\n-00021e30: 7265 206f 7220 2277 726f 6e67 2070 6173 re or \"wrong pas\n-00021e40: 7377 6f72 6422 292c 2073 6f20 7061 7373 sword\"), so pass\n-00021e50: 2074 6865 6d20 696e 2074 6865 2022 6572 them in the \"er\n-00021e60: 726f 7222 2066 6965 6c64 0a20 2020 2020 ror\" field. \n-00021e70: 2020 2020 2020 2073 656c 662e 7072 6f6d self.prom\n-00021e80: 7074 2827 272c 2070 726f 6d70 742c 2027 pt('', prompt, '\n-00021e90: 272c 2065 6368 6f2c 206d 6573 7361 6765 ', echo, message\n-00021ea0: 7329 0a20 2020 2020 2020 2020 2020 2072 s). r\n-00021eb0: 6574 7572 6e20 6177 6169 7420 7365 6c66 eturn await self\n-00021ec0: 2e70 656e 6469 6e67 5f70 726f 6d70 740a .pending_prompt.\n-00021ed0: 2020 2020 2020 2020 6669 6e61 6c6c 793a finally:\n-00021ee0: 0a20 2020 2020 2020 2020 2020 2073 656c . sel\n-00021ef0: 662e 7065 6e64 696e 675f 7072 6f6d 7074 f.pending_prompt\n-00021f00: 203d 204e 6f6e 650a 0a20 2020 2064 6566 = None.. def\n-00021f10: 205f 5f69 6e69 745f 5f28 7365 6c66 2c20 __init__(self, \n-00021f20: 726f 7574 6572 3a20 526f 7574 6572 2c20 router: Router, \n-00021f30: 2a2c 2070 7269 7669 6c65 6765 643a 2062 *, privileged: b\n-00021f40: 6f6f 6c20 3d20 4661 6c73 6529 3a0a 2020 ool = False):. \n-00021f50: 2020 2020 2020 7375 7065 7228 292e 5f5f super().__\n-00021f60: 696e 6974 5f5f 2872 6f75 7465 7229 0a0a init__(router)..\n-00021f70: 2020 2020 2020 2020 7365 6c66 2e70 656e self.pen\n-00021f80: 6469 6e67 5f70 726f 6d70 7420 3d20 4e6f ding_prompt = No\n-00021f90: 6e65 0a20 2020 2020 2020 2073 656c 662e ne. self.\n-00021fa0: 7065 6572 203d 204e 6f6e 650a 2020 2020 peer = None. \n-00021fb0: 2020 2020 7365 6c66 2e73 7461 7274 7570 self.startup\n-00021fc0: 203d 204e 6f6e 650a 0a20 2020 2020 2020 = None.. \n-00021fd0: 2069 6620 7072 6976 696c 6567 6564 206f if privileged o\n-00021fe0: 7220 6f73 2e67 6574 7569 6428 2920 3d3d r os.getuid() ==\n-00021ff0: 2030 3a0a 2020 2020 2020 2020 2020 2020 0:. \n-00022000: 7365 6c66 2e63 7572 7265 6e74 203d 2027 self.current = '\n-00022010: 726f 6f74 270a 0a20 2020 2064 6566 2070 root'.. def p\n-00022020: 6565 725f 646f 6e65 2873 656c 6629 3a0a eer_done(self):.\n-00022030: 2020 2020 2020 2020 7365 6c66 2e63 7572 self.cur\n-00022040: 7265 6e74 203d 2027 6e6f 6e65 270a 2020 rent = 'none'. \n-00022050: 2020 2020 2020 7365 6c66 2e70 6565 7220 self.peer \n-00022060: 3d20 4e6f 6e65 0a0a 2020 2020 6173 796e = None.. asyn\n-00022070: 6320 6465 6620 676f 2873 656c 662c 206e c def go(self, n\n-00022080: 616d 653a 2073 7472 2c20 7265 7370 6f6e ame: str, respon\n-00022090: 6465 723a 2066 6572 6e79 2e41 736b 7061 der: ferny.Askpa\n-000220a0: 7373 4861 6e64 6c65 7229 202d 3e20 4e6f ssHandler) -> No\n-000220b0: 6e65 3a0a 2020 2020 2020 2020 6966 2073 ne:. if s\n-000220c0: 656c 662e 6375 7272 656e 7420 213d 2027 elf.current != '\n-000220d0: 6e6f 6e65 273a 0a20 2020 2020 2020 2020 none':. \n-000220e0: 2020 2072 6169 7365 2062 7573 2e42 7573 raise bus.Bus\n-000220f0: 4572 726f 7228 2763 6f63 6b70 6974 2e53 Error('cockpit.S\n-00022100: 7570 6572 7573 6572 2e45 7272 6f72 272c uperuser.Error',\n-00022110: 2027 5375 7065 7275 7365 7220 6272 6964 'Superuser brid\n-00022120: 6765 2061 6c72 6561 6479 2072 756e 6e69 ge already runni\n-00022130: 6e67 2729 0a0a 2020 2020 2020 2020 6173 ng').. as\n-00022140: 7365 7274 2073 656c 662e 7065 6572 2069 sert self.peer i\n-00022150: 7320 4e6f 6e65 0a20 2020 2020 2020 2061 s None. a\n-00022160: 7373 6572 7420 7365 6c66 2e73 7461 7274 ssert self.start\n-00022170: 7570 2069 7320 4e6f 6e65 0a0a 2020 2020 up is None.. \n-00022180: 2020 2020 666f 7220 636f 6e66 6967 2069 for config i\n-00022190: 6e20 7365 6c66 2e73 7570 6572 7573 6572 n self.superuser\n-000221a0: 5f63 6f6e 6669 6773 3a0a 2020 2020 2020 _configs:. \n-000221b0: 2020 2020 2020 6966 206e 616d 6520 696e if name in\n-000221c0: 2028 636f 6e66 6967 2e6e 616d 652c 2027 (config.name, '\n-000221d0: 616e 7927 293a 0a20 2020 2020 2020 2020 any'):. \n-000221e0: 2020 2020 2020 2062 7265 616b 0a20 2020 break. \n-000221f0: 2020 2020 2065 6c73 653a 0a20 2020 2020 else:. \n-00022200: 2020 2020 2020 2072 6169 7365 2062 7573 raise bus\n-00022210: 2e42 7573 4572 726f 7228 2763 6f63 6b70 .BusError('cockp\n-00022220: 6974 2e53 7570 6572 7573 6572 2e45 7272 it.Superuser.Err\n-00022230: 6f72 272c 2066 2755 6e6b 6e6f 776e 2073 or', f'Unknown s\n-00022240: 7570 6572 7573 6572 2062 7269 6467 6520 uperuser bridge \n-00022250: 7479 7065 2022 7b6e 616d 657d 2227 290a type \"{name}\"').\n-00022260: 0a20 2020 2020 2020 2073 656c 662e 6375 . self.cu\n-00022270: 7272 656e 7420 3d20 2769 6e69 7427 0a20 rrent = 'init'. \n-00022280: 2020 2020 2020 2073 656c 662e 7065 6572 self.peer\n-00022290: 203d 2053 7570 6572 7573 6572 5065 6572 = SuperuserPeer\n-000222a0: 2873 656c 662e 726f 7574 6572 2c20 636f (self.router, co\n-000222b0: 6e66 6967 2c20 7265 7370 6f6e 6465 7229 nfig, responder)\n-000222c0: 0a20 2020 2020 2020 2073 656c 662e 7065 . self.pe\n-000222d0: 6572 2e61 6464 5f64 6f6e 655f 6361 6c6c er.add_done_call\n-000222e0: 6261 636b 2873 656c 662e 7065 6572 5f64 back(self.peer_d\n-000222f0: 6f6e 6529 0a0a 2020 2020 2020 2020 7472 one).. tr\n-00022300: 793a 0a20 2020 2020 2020 2020 2020 2061 y:. a\n-00022310: 7761 6974 2073 656c 662e 7065 6572 2e73 wait self.peer.s\n-00022320: 7461 7274 2869 6e69 745f 686f 7374 3d73 tart(init_host=s\n-00022330: 656c 662e 726f 7574 6572 2e69 6e69 745f elf.router.init_\n-00022340: 686f 7374 290a 2020 2020 2020 2020 6578 host). ex\n-00022350: 6365 7074 2061 7379 6e63 696f 2e43 616e cept asyncio.Can\n-00022360: 6365 6c6c 6564 4572 726f 723a 0a20 2020 celledError:. \n-00022370: 2020 2020 2020 2020 2072 6169 7365 2062 raise b\n-00022380: 7573 2e42 7573 4572 726f 7228 2763 6f63 us.BusError('coc\n-00022390: 6b70 6974 2e53 7570 6572 7573 6572 2e45 kpit.Superuser.E\n-000223a0: 7272 6f72 2e43 616e 6365 6c6c 6564 272c rror.Cancelled',\n-000223b0: 2027 4f70 6572 6174 696f 6e20 6162 6f72 'Operation abor\n-000223c0: 7465 6427 2920 6672 6f6d 204e 6f6e 650a ted') from None.\n-000223d0: 2020 2020 2020 2020 6578 6365 7074 2028 except (\n-000223e0: 4f53 4572 726f 722c 2050 6565 7245 7272 OSError, PeerErr\n-000223f0: 6f72 2920 6173 2065 7863 3a0a 2020 2020 or) as exc:. \n-00022400: 2020 2020 2020 2020 7261 6973 6520 6275 raise bu\n-00022410: 732e 4275 7345 7272 6f72 2827 636f 636b s.BusError('cock\n-00022420: 7069 742e 5375 7065 7275 7365 722e 4572 pit.Superuser.Er\n-00022430: 726f 7227 2c20 7374 7228 6578 6329 2920 ror', str(exc)) \n-00022440: 6672 6f6d 2065 7863 0a0a 2020 2020 2020 from exc.. \n-00022450: 2020 7365 6c66 2e63 7572 7265 6e74 203d self.current =\n-00022460: 2073 656c 662e 7065 6572 2e63 6f6e 6669 self.peer.confi\n-00022470: 672e 6e61 6d65 0a0a 2020 2020 6465 6620 g.name.. def \n-00022480: 7365 745f 636f 6e66 6967 7328 7365 6c66 set_configs(self\n-00022490: 2c20 636f 6e66 6967 733a 2053 6571 7565 , configs: Seque\n-000224a0: 6e63 655b 4272 6964 6765 436f 6e66 6967 nce[BridgeConfig\n-000224b0: 5d29 3a0a 2020 2020 2020 2020 6c6f 6767 ]):. logg\n-000224c0: 6572 2e64 6562 7567 2822 7365 745f 636f er.debug(\"set_co\n-000224d0: 6e66 6967 7328 2920 7769 7468 2025 6420 nfigs() with %d \n-000224e0: 6974 656d 7322 2c20 6c65 6e28 636f 6e66 items\", len(conf\n-000224f0: 6967 7329 290a 2020 2020 2020 2020 636f igs)). co\n-00022500: 6e66 6967 7320 3d20 5b63 6f6e 6669 6720 nfigs = [config \n-00022510: 666f 7220 636f 6e66 6967 2069 6e20 636f for config in co\n-00022520: 6e66 6967 7320 6966 2063 6f6e 6669 672e nfigs if config.\n-00022530: 7072 6976 696c 6567 6564 5d0a 2020 2020 privileged]. \n-00022540: 2020 2020 7365 6c66 2e73 7570 6572 7573 self.superus\n-00022550: 6572 5f63 6f6e 6669 6773 203d 2074 7570 er_configs = tup\n-00022560: 6c65 2863 6f6e 6669 6773 290a 2020 2020 le(configs). \n-00022570: 2020 2020 7365 6c66 2e62 7269 6467 6573 self.bridges\n-00022580: 203d 205b 636f 6e66 6967 2e6e 616d 6520 = [config.name \n-00022590: 666f 7220 636f 6e66 6967 2069 6e20 7365 for config in se\n-000225a0: 6c66 2e73 7570 6572 7573 6572 5f63 6f6e lf.superuser_con\n-000225b0: 6669 6773 5d0a 2020 2020 2020 2020 7365 figs]. se\n-000225c0: 6c66 2e6d 6574 686f 6473 203d 207b 632e lf.methods = {c.\n-000225d0: 6c61 6265 6c3a 2056 6172 6961 6e74 287b label: Variant({\n-000225e0: 276c 6162 656c 273a 2056 6172 6961 6e74 'label': Variant\n-000225f0: 2863 2e6c 6162 656c 297d 2c20 2761 7b73 (c.label)}, 'a{s\n-00022600: 767d 2729 2066 6f72 2063 2069 6e20 636f v}') for c in co\n-00022610: 6e66 6967 7320 6966 2063 2e6c 6162 656c nfigs if c.label\n-00022620: 7d0a 0a20 2020 2020 2020 206c 6f67 6765 }.. logge\n-00022630: 722e 6465 6275 6728 2220 2062 7269 6467 r.debug(\" bridg\n-00022640: 6573 2061 7265 206e 6f77 2025 7322 2c20 es are now %s\", \n-00022650: 7365 6c66 2e62 7269 6467 6573 290a 0a20 self.bridges).. \n-00022660: 2020 2020 2020 2023 2049 6620 7468 6520 # If the \n-00022670: 6375 7272 656e 746c 7920 6163 7469 7665 currently active\n-00022680: 2062 7269 6467 6520 636f 6e66 6967 2069 bridge config i\n-00022690: 7320 6e6f 7420 696e 2074 6865 206e 6577 s not in the new\n-000226a0: 2073 6574 206f 6620 636f 6e66 6967 732c set of configs,\n-000226b0: 2073 746f 7020 6974 0a20 2020 2020 2020 stop it. \n-000226c0: 2069 6620 7365 6c66 2e70 6565 7220 6973 if self.peer is\n-000226d0: 206e 6f74 204e 6f6e 653a 0a20 2020 2020 not None:. \n-000226e0: 2020 2020 2020 2069 6620 7365 6c66 2e70 if self.p\n-000226f0: 6565 722e 636f 6e66 6967 206e 6f74 2069 eer.config not i\n-00022700: 6e20 7365 6c66 2e73 7570 6572 7573 6572 n self.superuser\n-00022710: 5f63 6f6e 6669 6773 3a0a 2020 2020 2020 _configs:. \n-00022720: 2020 2020 2020 2020 2020 6c6f 6767 6572 logger\n-00022730: 2e64 6562 7567 2822 2020 7374 6f70 7069 .debug(\" stoppi\n-00022740: 6e67 2073 7570 6572 7573 6572 2062 7269 ng superuser bri\n-00022750: 6467 6520 2725 7327 3a20 6974 2064 6973 dge '%s': it dis\n-00022760: 6170 7065 6172 6564 2066 726f 6d20 636f appeared from co\n-00022770: 6e66 6967 7322 2c20 7365 6c66 2e70 6565 nfigs\", self.pee\n-00022780: 722e 636f 6e66 6967 2e6e 616d 6529 0a20 r.config.name). \n-00022790: 2020 2020 2020 2020 2020 2020 2020 2073 s\n-000227a0: 656c 662e 7374 6f70 2829 0a0a 2020 2020 elf.stop().. \n-000227b0: 6465 6620 6361 6e63 656c 5f70 726f 6d70 def cancel_promp\n-000227c0: 7428 7365 6c66 293a 0a20 2020 2020 2020 t(self):. \n-000227d0: 2069 6620 7365 6c66 2e70 656e 6469 6e67 if self.pending\n-000227e0: 5f70 726f 6d70 7420 6973 206e 6f74 204e _prompt is not N\n-000227f0: 6f6e 653a 0a20 2020 2020 2020 2020 2020 one:. \n-00022800: 2073 656c 662e 7065 6e64 696e 675f 7072 self.pending_pr\n-00022810: 6f6d 7074 2e63 616e 6365 6c28 290a 2020 ompt.cancel(). \n-00022820: 2020 2020 2020 2020 2020 7365 6c66 2e70 self.p\n-00022830: 656e 6469 6e67 5f70 726f 6d70 7420 3d20 ending_prompt = \n-00022840: 4e6f 6e65 0a0a 2020 2020 6465 6620 7368 None.. def sh\n-00022850: 7574 646f 776e 2873 656c 6629 3a0a 2020 utdown(self):. \n-00022860: 2020 2020 2020 7365 6c66 2e63 616e 6365 self.cance\n-00022870: 6c5f 7072 6f6d 7074 2829 0a0a 2020 2020 l_prompt().. \n-00022880: 2020 2020 6966 2073 656c 662e 7065 6572 if self.peer\n-00022890: 2069 7320 6e6f 7420 4e6f 6e65 3a0a 2020 is not None:. \n-000228a0: 2020 2020 2020 2020 2020 7365 6c66 2e70 self.p\n-000228b0: 6565 722e 636c 6f73 6528 290a 0a20 2020 eer.close().. \n-000228c0: 2020 2020 2023 2063 6c6f 7365 2829 2073 # close() s\n-000228d0: 686f 756c 6420 6861 7665 2064 6973 636f hould have disco\n-000228e0: 6e6e 6563 7465 6420 7468 6520 7065 6572 nnected the peer\n-000228f0: 2069 6d6d 6564 6961 7465 6c79 0a20 2020 immediately. \n-00022900: 2020 2020 2061 7373 6572 7420 7365 6c66 assert self\n-00022910: 2e70 6565 7220 6973 204e 6f6e 650a 0a20 .peer is None.. \n-00022920: 2020 2023 2043 6f6e 6e65 6374 2d6f 6e2d # Connect-on-\n-00022930: 7374 6172 7475 7020 6675 6e63 7469 6f6e startup function\n-00022940: 616c 6974 790a 2020 2020 6465 6620 696e ality. def in\n-00022950: 6974 2873 656c 662c 2070 6172 616d 733a it(self, params:\n-00022960: 204a 736f 6e4f 626a 6563 7429 202d 3e20 JsonObject) -> \n-00022970: 4e6f 6e65 3a0a 2020 2020 2020 2020 6e61 None:. na\n-00022980: 6d65 203d 2067 6574 5f73 7472 2870 6172 me = get_str(par\n-00022990: 616d 732c 2027 6964 272c 2027 616e 7927 ams, 'id', 'any'\n-000229a0: 290a 2020 2020 2020 2020 7265 7370 6f6e ). respon\n-000229b0: 6465 7220 3d20 4175 7468 6f72 697a 6552 der = AuthorizeR\n-000229c0: 6573 706f 6e64 6572 2873 656c 662e 726f esponder(self.ro\n-000229d0: 7574 6572 290a 2020 2020 2020 2020 7365 uter). se\n-000229e0: 6c66 2e5f 696e 6974 5f74 6173 6b20 3d20 lf._init_task = \n-000229f0: 6173 796e 6369 6f2e 6372 6561 7465 5f74 asyncio.create_t\n-00022a00: 6173 6b28 7365 6c66 2e67 6f28 6e61 6d65 ask(self.go(name\n-00022a10: 2c20 7265 7370 6f6e 6465 7229 290a 2020 , responder)). \n-00022a20: 2020 2020 2020 7365 6c66 2e5f 696e 6974 self._init\n-00022a30: 5f74 6173 6b2e 6164 645f 646f 6e65 5f63 _task.add_done_c\n-00022a40: 616c 6c62 6163 6b28 7365 6c66 2e5f 696e allback(self._in\n-00022a50: 6974 5f64 6f6e 6529 0a0a 2020 2020 6465 it_done).. de\n-00022a60: 6620 5f69 6e69 745f 646f 6e65 2873 656c f _init_done(sel\n-00022a70: 662c 2074 6173 6b3a 2027 6173 796e 6369 f, task: 'asynci\n-00022a80: 6f2e 5461 736b 5b4e 6f6e 655d 2729 202d o.Task[None]') -\n-00022a90: 3e20 4e6f 6e65 3a0a 2020 2020 2020 2020 > None:. \n-00022aa0: 6c6f 6767 6572 2e64 6562 7567 2827 7375 logger.debug('su\n-00022ab0: 7065 7275 7365 7220 696e 6974 2064 6f6e peruser init don\n-00022ac0: 6521 2025 7327 2c20 7461 736b 2e65 7863 e! %s', task.exc\n-00022ad0: 6570 7469 6f6e 2829 290a 2020 2020 2020 eption()). \n-00022ae0: 2020 7365 6c66 2e72 6f75 7465 722e 7772 self.router.wr\n-00022af0: 6974 655f 636f 6e74 726f 6c28 636f 6d6d ite_control(comm\n-00022b00: 616e 643d 2773 7570 6572 7573 6572 2d69 and='superuser-i\n-00022b10: 6e69 742d 646f 6e65 2729 0a20 2020 2020 nit-done'). \n-00022b20: 2020 2064 656c 2073 656c 662e 5f69 6e69 del self._ini\n-00022b30: 745f 7461 736b 0a0a 2020 2020 2320 442d t_task.. # D-\n-00022b40: 4275 7320 6d65 7468 6f64 730a 2020 2020 Bus methods. \n-00022b50: 4062 7573 2e49 6e74 6572 6661 6365 2e4d @bus.Interface.M\n-00022b60: 6574 686f 6428 696e 5f74 7970 6573 3d5b ethod(in_types=[\n-00022b70: 2773 275d 290a 2020 2020 6173 796e 6320 's']). async \n-00022b80: 6465 6620 7374 6172 7428 7365 6c66 2c20 def start(self, \n-00022b90: 6e61 6d65 3a20 7374 7229 202d 3e20 4e6f name: str) -> No\n-00022ba0: 6e65 3a0a 2020 2020 2020 2020 6177 6169 ne:. awai\n-00022bb0: 7420 7365 6c66 2e67 6f28 6e61 6d65 2c20 t self.go(name, \n-00022bc0: 7365 6c66 290a 0a20 2020 2040 6275 732e self).. @bus.\n-00022bd0: 496e 7465 7266 6163 652e 4d65 7468 6f64 Interface.Method\n-00022be0: 2829 0a20 2020 2064 6566 2073 746f 7028 (). def stop(\n-00022bf0: 7365 6c66 2920 2d3e 204e 6f6e 653a 0a20 self) -> None:. \n-00022c00: 2020 2020 2020 2073 656c 662e 7368 7574 self.shut\n-00022c10: 646f 776e 2829 0a0a 2020 2020 4062 7573 down().. @bus\n-00022c20: 2e49 6e74 6572 6661 6365 2e4d 6574 686f .Interface.Metho\n-00022c30: 6428 696e 5f74 7970 6573 3d5b 2773 275d d(in_types=['s']\n-00022c40: 290a 2020 2020 6465 6620 616e 7377 6572 ). def answer\n-00022c50: 2873 656c 662c 2072 6570 6c79 3a20 7374 (self, reply: st\n-00022c60: 7229 202d 3e20 4e6f 6e65 3a0a 2020 2020 r) -> None:. \n-00022c70: 2020 2020 6966 2073 656c 662e 7065 6e64 if self.pend\n-00022c80: 696e 675f 7072 6f6d 7074 2069 7320 6e6f ing_prompt is no\n-00022c90: 7420 4e6f 6e65 3a0a 2020 2020 2020 2020 t None:. \n-00022ca0: 2020 2020 6c6f 6767 6572 2e64 6562 7567 logger.debug\n-00022cb0: 2827 7265 7370 6f6e 6469 6e67 2074 6f20 ('responding to \n-00022cc0: 7065 6e64 696e 6720 7072 6f6d 7074 2729 pending prompt')\n-00022cd0: 0a20 2020 2020 2020 2020 2020 2073 656c . sel\n-00022ce0: 662e 7065 6e64 696e 675f 7072 6f6d 7074 f.pending_prompt\n-00022cf0: 2e73 6574 5f72 6573 756c 7428 7265 706c .set_result(repl\n-00022d00: 7929 0a20 2020 2020 2020 2065 6c73 653a y). else:\n-00022d10: 0a20 2020 2020 2020 2020 2020 206c 6f67 . log\n-00022d20: 6765 722e 6465 6275 6728 2767 6f74 2041 ger.debug('got A\n-00022d30: 6e73 7765 722c 2062 7574 206e 6f20 7072 nswer, but no pr\n-00022d40: 6f6d 7074 2070 656e 6469 6e67 2729 0a27 ompt pending').'\n-00022d50: 2727 2c0a 2020 2763 6f63 6b70 6974 2f70 '',. 'cockpit/p\n-00022d60: 726f 746f 636f 6c2e 7079 273a 2062 7227 rotocol.py': br'\n-00022d70: 2727 2320 5468 6973 2066 696c 6520 6973 ''# This file is\n-00022d80: 2070 6172 7420 6f66 2043 6f63 6b70 6974 part of Cockpit\n-00022d90: 2e0a 230a 2320 436f 7079 7269 6768 7420 ..#.# Copyright \n-00022da0: 2843 2920 3230 3232 2052 6564 2048 6174 (C) 2022 Red Hat\n-00022db0: 2c20 496e 632e 0a23 0a23 2054 6869 7320 , Inc..#.# This \n-00022dc0: 7072 6f67 7261 6d20 6973 2066 7265 6520 program is free \n-00022dd0: 736f 6674 7761 7265 3a20 796f 7520 6361 software: you ca\n-00022de0: 6e20 7265 6469 7374 7269 6275 7465 2069 n redistribute i\n-00022df0: 7420 616e 642f 6f72 206d 6f64 6966 790a t and/or modify.\n-00022e00: 2320 6974 2075 6e64 6572 2074 6865 2074 # it under the t\n-00022e10: 6572 6d73 206f 6620 7468 6520 474e 5520 erms of the GNU \n-00022e20: 4765 6e65 7261 6c20 5075 626c 6963 204c General Public L\n-00022e30: 6963 656e 7365 2061 7320 7075 626c 6973 icense as publis\n-00022e40: 6865 6420 6279 0a23 2074 6865 2046 7265 hed by.# the Fre\n-00022e50: 6520 536f 6674 7761 7265 2046 6f75 6e64 e Software Found\n-00022e60: 6174 696f 6e2c 2065 6974 6865 7220 7665 ation, either ve\n-00022e70: 7273 696f 6e20 3320 6f66 2074 6865 204c rsion 3 of the L\n-00022e80: 6963 656e 7365 2c20 6f72 0a23 2028 6174 icense, or.# (at\n-00022e90: 2079 6f75 7220 6f70 7469 6f6e 2920 616e your option) an\n-00022ea0: 7920 6c61 7465 7220 7665 7273 696f 6e2e y later version.\n-00022eb0: 0a23 0a23 2054 6869 7320 7072 6f67 7261 .#.# This progra\n-00022ec0: 6d20 6973 2064 6973 7472 6962 7574 6564 m is distributed\n-00022ed0: 2069 6e20 7468 6520 686f 7065 2074 6861 in the hope tha\n-00022ee0: 7420 6974 2077 696c 6c20 6265 2075 7365 t it will be use\n-00022ef0: 6675 6c2c 0a23 2062 7574 2057 4954 484f ful,.# but WITHO\n-00022f00: 5554 2041 4e59 2057 4152 5241 4e54 593b UT ANY WARRANTY;\n-00022f10: 2077 6974 686f 7574 2065 7665 6e20 7468 without even th\n-00022f20: 6520 696d 706c 6965 6420 7761 7272 616e e implied warran\n-00022f30: 7479 206f 660a 2320 4d45 5243 4841 4e54 ty of.# MERCHANT\n-00022f40: 4142 494c 4954 5920 6f72 2046 4954 4e45 ABILITY or FITNE\n-00022f50: 5353 2046 4f52 2041 2050 4152 5449 4355 SS FOR A PARTICU\n-00022f60: 4c41 5220 5055 5250 4f53 452e 2020 5365 LAR PURPOSE. Se\n-00022f70: 6520 7468 650a 2320 474e 5520 4765 6e65 e the.# GNU Gene\n-00022f80: 7261 6c20 5075 626c 6963 204c 6963 656e ral Public Licen\n-00022f90: 7365 2066 6f72 206d 6f72 6520 6465 7461 se for more deta\n-00022fa0: 696c 732e 0a23 0a23 2059 6f75 2073 686f ils..#.# You sho\n-00022fb0: 756c 6420 6861 7665 2072 6563 6569 7665 uld have receive\n-00022fc0: 6420 6120 636f 7079 206f 6620 7468 6520 d a copy of the \n-00022fd0: 474e 5520 4765 6e65 7261 6c20 5075 626c GNU General Publ\n-00022fe0: 6963 204c 6963 656e 7365 0a23 2061 6c6f ic License.# alo\n-00022ff0: 6e67 2077 6974 6820 7468 6973 2070 726f ng with this pro\n-00023000: 6772 616d 2e20 2049 6620 6e6f 742c 2073 gram. If not, s\n-00023010: 6565 203c 6874 7470 733a 2f2f 7777 772e ee ...import asyn\n-00023040: 6369 6f0a 696d 706f 7274 206a 736f 6e0a cio.import json.\n-00023050: 696d 706f 7274 206c 6f67 6769 6e67 0a69 import logging.i\n-00023060: 6d70 6f72 7420 7472 6163 6562 6163 6b0a mport traceback.\n-00023070: 696d 706f 7274 2075 7569 640a 0a66 726f import uuid..fro\n-00023080: 6d20 2e6a 736f 6e75 7469 6c20 696d 706f m .jsonutil impo\n-00023090: 7274 204a 736f 6e45 7272 6f72 2c20 4a73 rt JsonError, Js\n-000230a0: 6f6e 4f62 6a65 6374 2c20 4a73 6f6e 5661 onObject, JsonVa\n-000230b0: 6c75 652c 2063 7265 6174 655f 6f62 6a65 lue, create_obje\n-000230c0: 6374 2c20 6765 745f 696e 742c 2067 6574 ct, get_int, get\n-000230d0: 5f73 7472 2c20 6765 745f 7374 725f 6f72 _str, get_str_or\n-000230e0: 5f6e 6f6e 652c 2074 7970 6563 6865 636b _none, typecheck\n-000230f0: 6564 0a0a 6c6f 6767 6572 203d 206c 6f67 ed..logger = log\n-00023100: 6769 6e67 2e67 6574 4c6f 6767 6572 285f ging.getLogger(_\n-00023110: 5f6e 616d 655f 5f29 0a0a 0a63 6c61 7373 _name__)...class\n-00023120: 2043 6f63 6b70 6974 5072 6f62 6c65 6d28 CockpitProblem(\n-00023130: 4578 6365 7074 696f 6e29 3a0a 2020 2020 Exception):. \n-00023140: 2222 2241 2074 7970 6520 6f66 2065 7863 \"\"\"A type of exc\n-00023150: 6570 7469 6f6e 2074 6861 7420 6361 7272 eption that carr\n-00023160: 6965 7320 6120 7072 6f62 6c65 6d20 636f ies a problem co\n-00023170: 6465 2061 6e64 2061 206d 6573 7361 6765 de and a message\n-00023180: 2e0a 0a20 2020 2044 6570 656e 6469 6e67 ... Depending\n-00023190: 206f 6e20 7468 6520 7363 6f70 652c 2074 on the scope, t\n-000231a0: 6869 7320 6973 2075 7365 6420 746f 2068 his is used to h\n-000231b0: 616e 646c 6520 7368 7574 7469 6e67 2064 andle shutting d\n-000231c0: 6f77 6e3a 0a0a 2020 2020 2020 2d20 616e own:.. - an\n-000231d0: 2069 6e64 6976 6964 7561 6c20 6368 616e individual chan\n-000231e0: 6e65 6c20 2873 656e 6473 2070 726f 626c nel (sends probl\n-000231f0: 656d 2063 6f64 6520 696e 2074 6865 2063 em code in the c\n-00023200: 6c6f 7365 206d 6573 7361 6765 290a 2020 lose message). \n-00023210: 2020 2020 2d20 7065 6572 2063 6f6e 6e65 - peer conne\n-00023220: 6374 696f 6e73 2028 7365 6e64 7320 7072 ctions (sends pr\n-00023230: 6f62 6c65 6d20 636f 6465 2069 6e20 636c oblem code in cl\n-00023240: 6f73 6520 6d65 7373 6167 6520 666f 7220 ose message for \n-00023250: 6561 6368 206f 7065 6e20 6368 616e 6e65 each open channe\n-00023260: 6c29 0a20 2020 2020 202d 2074 6865 206d l). - the m\n-00023270: 6169 6e20 7374 6469 6f20 696e 7465 7261 ain stdio intera\n-00023280: 6374 696f 6e20 7769 7468 2074 6865 2062 ction with the b\n-00023290: 7269 6467 650a 0a20 2020 2049 7420 6973 ridge.. It is\n-000232a0: 2075 7375 616c 6c79 2074 6872 6f77 6e20 usually thrown \n-000232b0: 696e 2072 6573 706f 6e73 6520 746f 2073 in response to s\n-000232c0: 6f6d 6520 7669 6f6c 6174 696f 6e20 6f66 ome violation of\n-000232d0: 2065 7870 6563 7465 6420 7072 6f74 6f63 expected protoc\n-000232e0: 6f6c 0a20 2020 2077 6865 6e20 7061 7273 ol. when pars\n-000232f0: 696e 6720 6d65 7373 6167 6573 2c20 636f ing messages, co\n-00023300: 6e6e 6563 7469 6e67 2074 6f20 6120 7065 nnecting to a pe\n-00023310: 6572 2c20 6f72 206f 7065 6e69 6e67 2061 er, or opening a\n-00023320: 2063 6861 6e6e 656c 2e0a 2020 2020 2222 channel.. \"\"\n-00023330: 220a 2020 2020 6174 7472 733a 204a 736f \". attrs: Jso\n-00023340: 6e4f 626a 6563 740a 0a20 2020 2064 6566 nObject.. def\n-00023350: 205f 5f69 6e69 745f 5f28 7365 6c66 2c20 __init__(self, \n-00023360: 7072 6f62 6c65 6d3a 2073 7472 2c20 5f6d problem: str, _m\n-00023370: 7367 3a20 274a 736f 6e4f 626a 6563 7420 sg: 'JsonObject \n-00023380: 7c20 4e6f 6e65 2720 3d20 4e6f 6e65 2c20 | None' = None, \n-00023390: 2a2a 6b77 6172 6773 3a20 4a73 6f6e 5661 **kwargs: JsonVa\n-000233a0: 6c75 6529 202d 3e20 4e6f 6e65 3a0a 2020 lue) -> None:. \n-000233b0: 2020 2020 2020 6b77 6172 6773 5b27 7072 kwargs['pr\n-000233c0: 6f62 6c65 6d27 5d20 3d20 7072 6f62 6c65 oblem'] = proble\n-000233d0: 6d0a 2020 2020 2020 2020 7365 6c66 2e61 m. self.a\n-000233e0: 7474 7273 203d 2063 7265 6174 655f 6f62 ttrs = create_ob\n-000233f0: 6a65 6374 285f 6d73 672c 206b 7761 7267 ject(_msg, kwarg\n-00023400: 7329 0a20 2020 2020 2020 2073 7570 6572 s). super\n-00023410: 2829 2e5f 5f69 6e69 745f 5f28 6765 745f ().__init__(get_\n-00023420: 7374 7228 7365 6c66 2e61 7474 7273 2c20 str(self.attrs, \n-00023430: 276d 6573 7361 6765 272c 2070 726f 626c 'message', probl\n-00023440: 656d 2929 0a0a 2020 2020 6465 6620 6765 em)).. def ge\n-00023450: 745f 6174 7472 7328 7365 6c66 2920 2d3e t_attrs(self) ->\n-00023460: 204a 736f 6e4f 626a 6563 743a 0a20 2020 JsonObject:. \n-00023470: 2020 2020 2069 6620 7365 6c66 2e61 7474 if self.att\n-00023480: 7273 5b27 7072 6f62 6c65 6d27 5d20 3d3d rs['problem'] ==\n-00023490: 2027 696e 7465 726e 616c 2d65 7272 6f72 'internal-error\n-000234a0: 2720 616e 6420 7365 6c66 2e5f 5f63 6175 ' and self.__cau\n-000234b0: 7365 5f5f 2069 7320 6e6f 7420 4e6f 6e65 se__ is not None\n-000234c0: 3a0a 2020 2020 2020 2020 2020 2020 7265 :. re\n-000234d0: 7475 726e 2064 6963 7428 7365 6c66 2e61 turn dict(self.a\n-000234e0: 7474 7273 2c20 6361 7573 653d 7472 6163 ttrs, cause=trac\n-000234f0: 6562 6163 6b2e 666f 726d 6174 5f65 7863 eback.format_exc\n-00023500: 6570 7469 6f6e 280a 2020 2020 2020 2020 eption(. \n-00023510: 2020 2020 2020 2020 7365 6c66 2e5f 5f63 self.__c\n-00023520: 6175 7365 5f5f 2e5f 5f63 6c61 7373 5f5f ause__.__class__\n-00023530: 2c20 7365 6c66 2e5f 5f63 6175 7365 5f5f , self.__cause__\n-00023540: 2c20 7365 6c66 2e5f 5f63 6175 7365 5f5f , self.__cause__\n-00023550: 2e5f 5f74 7261 6365 6261 636b 5f5f 0a20 .__traceback__. \n-00023560: 2020 2020 2020 2020 2020 2029 290a 2020 )). \n-00023570: 2020 2020 2020 656c 7365 3a0a 2020 2020 else:. \n-00023580: 2020 2020 2020 2020 7265 7475 726e 2073 return s\n-00023590: 656c 662e 6174 7472 730a 0a0a 636c 6173 elf.attrs...clas\n-000235a0: 7320 436f 636b 7069 7450 726f 746f 636f s CockpitProtoco\n-000235b0: 6c45 7272 6f72 2843 6f63 6b70 6974 5072 lError(CockpitPr\n-000235c0: 6f62 6c65 6d29 3a0a 2020 2020 6465 6620 oblem):. def \n-000235d0: 5f5f 696e 6974 5f5f 2873 656c 662c 206d __init__(self, m\n-000235e0: 6573 7361 6765 3a20 7374 722c 2070 726f essage: str, pro\n-000235f0: 626c 656d 3a20 7374 7220 3d20 2770 726f blem: str = 'pro\n-00023600: 746f 636f 6c2d 6572 726f 7227 293a 0a20 tocol-error'):. \n-00023610: 2020 2020 2020 2073 7570 6572 2829 2e5f super()._\n-00023620: 5f69 6e69 745f 5f28 7072 6f62 6c65 6d2c _init__(problem,\n-00023630: 206d 6573 7361 6765 3d6d 6573 7361 6765 message=message\n-00023640: 290a 0a0a 636c 6173 7320 436f 636b 7069 )...class Cockpi\n-00023650: 7450 726f 746f 636f 6c28 6173 796e 6369 tProtocol(asynci\n-00023660: 6f2e 5072 6f74 6f63 6f6c 293a 0a20 2020 o.Protocol):. \n-00023670: 2022 2222 4120 6e61 6976 6520 696d 706c \"\"\"A naive impl\n-00023680: 656d 656e 7461 7469 6f6e 206f 6620 7468 ementation of th\n-00023690: 6520 436f 636b 7069 7420 6672 616d 6520 e Cockpit frame \n-000236a0: 7072 6f74 6f63 6f6c 0a0a 2020 2020 5765 protocol.. We\n-000236b0: 206e 6565 6420 746f 2075 7365 2074 6869 need to use thi\n-000236c0: 7320 6265 6361 7573 6520 5079 7468 6f6e s because Python\n-000236d0: 2773 2053 656c 6563 746f 7245 7665 6e74 's SelectorEvent\n-000236e0: 4c6f 6f70 2064 6f65 736e 2774 2073 7570 Loop doesn't sup\n-000236f0: 706f 7274 6564 0a20 2020 2062 7566 6665 ported. buffe\n-00023700: 7265 6420 7072 6f74 6f63 6f6c 732e 0a20 red protocols.. \n-00023710: 2020 2022 2222 0a20 2020 2074 7261 6e73 \"\"\". trans\n-00023720: 706f 7274 3a20 2761 7379 6e63 696f 2e54 port: 'asyncio.T\n-00023730: 7261 6e73 706f 7274 207c 204e 6f6e 6527 ransport | None'\n-00023740: 203d 204e 6f6e 650a 2020 2020 6275 6666 = None. buff\n-00023750: 6572 203d 2062 2727 0a20 2020 205f 636c er = b''. _cl\n-00023760: 6f73 6564 3a20 626f 6f6c 203d 2046 616c osed: bool = Fal\n-00023770: 7365 0a20 2020 205f 636f 6d6d 756e 6963 se. _communic\n-00023780: 6174 696f 6e5f 646f 6e65 3a20 2761 7379 ation_done: 'asy\n-00023790: 6e63 696f 2e46 7574 7572 655b 4e6f 6e65 ncio.Future[None\n-000237a0: 5d20 7c20 4e6f 6e65 2720 3d20 4e6f 6e65 ] | None' = None\n-000237b0: 0a0a 2020 2020 6465 6620 646f 5f72 6561 .. def do_rea\n-000237c0: 6479 2873 656c 6629 202d 3e20 4e6f 6e65 dy(self) -> None\n-000237d0: 3a0a 2020 2020 2020 2020 7061 7373 0a0a :. pass..\n-000237e0: 2020 2020 6465 6620 646f 5f63 6c6f 7365 def do_close\n-000237f0: 6428 7365 6c66 2c20 6578 633a 2027 4578 d(self, exc: 'Ex\n-00023800: 6365 7074 696f 6e20 7c20 4e6f 6e65 2729 ception | None')\n-00023810: 202d 3e20 4e6f 6e65 3a0a 2020 2020 2020 -> None:. \n-00023820: 2020 7061 7373 0a0a 2020 2020 6465 6620 pass.. def \n-00023830: 7472 616e 7370 6f72 745f 636f 6e74 726f transport_contro\n-00023840: 6c5f 7265 6365 6976 6564 2873 656c 662c l_received(self,\n-00023850: 2063 6f6d 6d61 6e64 3a20 7374 722c 206d command: str, m\n-00023860: 6573 7361 6765 3a20 4a73 6f6e 4f62 6a65 essage: JsonObje\n-00023870: 6374 2920 2d3e 204e 6f6e 653a 0a20 2020 ct) -> None:. \n-00023880: 2020 2020 2072 6169 7365 204e 6f74 496d raise NotIm\n-00023890: 706c 656d 656e 7465 6445 7272 6f72 0a0a plementedError..\n-000238a0: 2020 2020 6465 6620 6368 616e 6e65 6c5f def channel_\n-000238b0: 636f 6e74 726f 6c5f 7265 6365 6976 6564 control_received\n-000238c0: 2873 656c 662c 2063 6861 6e6e 656c 3a20 (self, channel: \n-000238d0: 7374 722c 2063 6f6d 6d61 6e64 3a20 7374 str, command: st\n-000238e0: 722c 206d 6573 7361 6765 3a20 4a73 6f6e r, message: Json\n-000238f0: 4f62 6a65 6374 2920 2d3e 204e 6f6e 653a Object) -> None:\n-00023900: 0a20 2020 2020 2020 2072 6169 7365 204e . raise N\n-00023910: 6f74 496d 706c 656d 656e 7465 6445 7272 otImplementedErr\n-00023920: 6f72 0a0a 2020 2020 6465 6620 6368 616e or.. def chan\n-00023930: 6e65 6c5f 6461 7461 5f72 6563 6569 7665 nel_data_receive\n-00023940: 6428 7365 6c66 2c20 6368 616e 6e65 6c3a d(self, channel:\n-00023950: 2073 7472 2c20 6461 7461 3a20 6279 7465 str, data: byte\n-00023960: 7329 202d 3e20 4e6f 6e65 3a0a 2020 2020 s) -> None:. \n-00023970: 2020 2020 7261 6973 6520 4e6f 7449 6d70 raise NotImp\n-00023980: 6c65 6d65 6e74 6564 4572 726f 720a 0a20 lementedError.. \n-00023990: 2020 2064 6566 2066 7261 6d65 5f72 6563 def frame_rec\n-000239a0: 6569 7665 6428 7365 6c66 2c20 6672 616d eived(self, fram\n-000239b0: 653a 2062 7974 6573 2920 2d3e 204e 6f6e e: bytes) -> Non\n-000239c0: 653a 0a20 2020 2020 2020 2068 6561 6465 e:. heade\n-000239d0: 722c 205f 2c20 6461 7461 203d 2066 7261 r, _, data = fra\n-000239e0: 6d65 2e70 6172 7469 7469 6f6e 2862 275c me.partition(b'\\\n-000239f0: 6e27 290a 0a20 2020 2020 2020 2069 6620 n').. if \n-00023a00: 6865 6164 6572 2021 3d20 6227 273a 0a20 header != b'':. \n-00023a10: 2020 2020 2020 2020 2020 2063 6861 6e6e chann\n-00023a20: 656c 203d 2068 6561 6465 722e 6465 636f el = header.deco\n-00023a30: 6465 2827 6173 6369 6927 290a 2020 2020 de('ascii'). \n-00023a40: 2020 2020 2020 2020 6c6f 6767 6572 2e64 logger.d\n-00023a50: 6562 7567 2827 6461 7461 2072 6563 6569 ebug('data recei\n-00023a60: 7665 643a 2025 6420 6279 7465 7320 6f66 ved: %d bytes of\n-00023a70: 2064 6174 6120 666f 7220 6368 616e 6e65 data for channe\n-00023a80: 6c20 2573 272c 206c 656e 2864 6174 6129 l %s', len(data)\n-00023a90: 2c20 6368 616e 6e65 6c29 0a20 2020 2020 , channel). \n-00023aa0: 2020 2020 2020 2073 656c 662e 6368 616e self.chan\n-00023ab0: 6e65 6c5f 6461 7461 5f72 6563 6569 7665 nel_data_receive\n-00023ac0: 6428 6368 616e 6e65 6c2c 2064 6174 6129 d(channel, data)\n-00023ad0: 0a0a 2020 2020 2020 2020 656c 7365 3a0a .. else:.\n-00023ae0: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n-00023af0: 2e63 6f6e 7472 6f6c 5f72 6563 6569 7665 .control_receive\n-00023b00: 6428 6461 7461 290a 0a20 2020 2064 6566 d(data).. def\n-00023b10: 2063 6f6e 7472 6f6c 5f72 6563 6569 7665 control_receive\n-00023b20: 6428 7365 6c66 2c20 6461 7461 3a20 6279 d(self, data: by\n-00023b30: 7465 7329 202d 3e20 4e6f 6e65 3a0a 2020 tes) -> None:. \n-00023b40: 2020 2020 2020 7472 793a 0a20 2020 2020 try:. \n-00023b50: 2020 2020 2020 206d 6573 7361 6765 203d message =\n-00023b60: 2074 7970 6563 6865 636b 6564 286a 736f typechecked(jso\n-00023b70: 6e2e 6c6f 6164 7328 6461 7461 292c 2064 n.loads(data), d\n-00023b80: 6963 7429 0a20 2020 2020 2020 2020 2020 ict). \n-00023b90: 2063 6f6d 6d61 6e64 203d 2067 6574 5f73 command = get_s\n-00023ba0: 7472 286d 6573 7361 6765 2c20 2763 6f6d tr(message, 'com\n-00023bb0: 6d61 6e64 2729 0a20 2020 2020 2020 2020 mand'). \n-00023bc0: 2020 2063 6861 6e6e 656c 203d 2067 6574 channel = get\n-00023bd0: 5f73 7472 286d 6573 7361 6765 2c20 2763 _str(message, 'c\n-00023be0: 6861 6e6e 656c 272c 204e 6f6e 6529 0a0a hannel', None)..\n-00023bf0: 2020 2020 2020 2020 2020 2020 6966 2063 if c\n-00023c00: 6861 6e6e 656c 2069 7320 6e6f 7420 4e6f hannel is not No\n-00023c10: 6e65 3a0a 2020 2020 2020 2020 2020 2020 ne:. \n-00023c20: 2020 2020 6c6f 6767 6572 2e64 6562 7567 logger.debug\n-00023c30: 2827 6368 616e 6e65 6c20 636f 6e74 726f ('channel contro\n-00023c40: 6c20 7265 6365 6976 6564 2025 7327 2c20 l received %s', \n-00023c50: 6d65 7373 6167 6529 0a20 2020 2020 2020 message). \n-00023c60: 2020 2020 2020 2020 2073 656c 662e 6368 self.ch\n-00023c70: 616e 6e65 6c5f 636f 6e74 726f 6c5f 7265 annel_control_re\n-00023c80: 6365 6976 6564 2863 6861 6e6e 656c 2c20 ceived(channel, \n-00023c90: 636f 6d6d 616e 642c 206d 6573 7361 6765 command, message\n-00023ca0: 290a 2020 2020 2020 2020 2020 2020 656c ). el\n-00023cb0: 7365 3a0a 2020 2020 2020 2020 2020 2020 se:. \n-00023cc0: 2020 2020 6c6f 6767 6572 2e64 6562 7567 logger.debug\n-00023cd0: 2827 7472 616e 7370 6f72 7420 636f 6e74 ('transport cont\n-00023ce0: 726f 6c20 7265 6365 6976 6564 2025 7327 rol received %s'\n-00023cf0: 2c20 6d65 7373 6167 6529 0a20 2020 2020 , message). \n-00023d00: 2020 2020 2020 2020 2020 2073 656c 662e self.\n-00023d10: 7472 616e 7370 6f72 745f 636f 6e74 726f transport_contro\n-00023d20: 6c5f 7265 6365 6976 6564 2863 6f6d 6d61 l_received(comma\n-00023d30: 6e64 2c20 6d65 7373 6167 6529 0a0a 2020 nd, message).. \n-00023d40: 2020 2020 2020 6578 6365 7074 2028 6a73 except (js\n-00023d50: 6f6e 2e4a 534f 4e44 6563 6f64 6545 7272 on.JSONDecodeErr\n-00023d60: 6f72 2c20 4a73 6f6e 4572 726f 7229 2061 or, JsonError) a\n-00023d70: 7320 6578 633a 0a20 2020 2020 2020 2020 s exc:. \n-00023d80: 2020 2072 6169 7365 2043 6f63 6b70 6974 raise Cockpit\n-00023d90: 5072 6f74 6f63 6f6c 4572 726f 7228 6627 ProtocolError(f'\n-00023da0: 636f 6e74 726f 6c20 6d65 7373 6167 653a control message:\n-00023db0: 207b 6578 6321 737d 2729 2066 726f 6d20 {exc!s}') from \n-00023dc0: 6578 630a 0a20 2020 2064 6566 2063 6f6e exc.. def con\n-00023dd0: 7375 6d65 5f6f 6e65 5f66 7261 6d65 2873 sume_one_frame(s\n-00023de0: 656c 662c 2064 6174 613a 2062 7974 6573 elf, data: bytes\n-00023df0: 2920 2d3e 2069 6e74 3a0a 2020 2020 2020 ) -> int:. \n-00023e00: 2020 2222 2243 6f6e 7375 6d65 7320 6120 \"\"\"Consumes a \n-00023e10: 7369 6e67 6c65 2066 7261 6d65 2066 726f single frame fro\n-00023e20: 6d20 7669 6577 2e0a 0a20 2020 2020 2020 m view... \n-00023e30: 2052 6574 7572 6e73 2070 6f73 6974 6976 Returns positiv\n-00023e40: 6520 6966 2061 206e 756d 6265 7220 6f66 e if a number of\n-00023e50: 2062 7974 6573 2077 6572 6520 636f 6e73 bytes were cons\n-00023e60: 756d 6564 2c20 6f72 206e 6567 6174 6976 umed, or negativ\n-00023e70: 6520 6966 206e 6f0a 2020 2020 2020 2020 e if no. \n-00023e80: 776f 726b 2063 616e 2062 6520 646f 6e65 work can be done\n-00023e90: 2062 6563 6175 7365 206f 6620 6120 6769 because of a gi\n-00023ea0: 7665 6e20 6e75 6d62 6572 206f 6620 6279 ven number of by\n-00023eb0: 7465 7320 6d69 7373 696e 672e 0a20 2020 tes missing.. \n-00023ec0: 2020 2020 2022 2222 0a0a 2020 2020 2020 \"\"\".. \n-00023ed0: 2020 7472 793a 0a20 2020 2020 2020 2020 try:. \n-00023ee0: 2020 206e 6577 6c69 6e65 203d 2064 6174 newline = dat\n-00023ef0: 612e 696e 6465 7828 6227 5c6e 2729 0a20 a.index(b'\\n'). \n-00023f00: 2020 2020 2020 2065 7863 6570 7420 5661 except Va\n-00023f10: 6c75 6545 7272 6f72 2061 7320 6578 633a lueError as exc:\n-00023f20: 0a20 2020 2020 2020 2020 2020 2069 6620 . if \n-00023f30: 6c65 6e28 6461 7461 2920 3c20 3130 3a0a len(data) < 10:.\n-00023f40: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00023f50: 2320 4c65 7427 7320 7472 7920 7265 6164 # Let's try read\n-00023f60: 696e 6720 6d6f 7265 0a20 2020 2020 2020 ing more. \n-00023f70: 2020 2020 2020 2020 2072 6574 7572 6e20 return \n-00023f80: 6c65 6e28 6461 7461 2920 2d20 3130 0a20 len(data) - 10. \n-00023f90: 2020 2020 2020 2020 2020 2072 6169 7365 raise\n-00023fa0: 2043 6f63 6b70 6974 5072 6f74 6f63 6f6c CockpitProtocol\n-00023fb0: 4572 726f 7228 2273 697a 6520 6c69 6e65 Error(\"size line\n-00023fc0: 2069 7320 746f 6f20 6c6f 6e67 2229 2066 is too long\") f\n-00023fd0: 726f 6d20 6578 630a 0a20 2020 2020 2020 rom exc.. \n-00023fe0: 2074 7279 3a0a 2020 2020 2020 2020 2020 try:. \n-00023ff0: 2020 6c65 6e67 7468 203d 2069 6e74 2864 length = int(d\n-00024000: 6174 615b 3a6e 6577 6c69 6e65 5d29 0a20 ata[:newline]). \n-00024010: 2020 2020 2020 2065 7863 6570 7420 5661 except Va\n-00024020: 6c75 6545 7272 6f72 2061 7320 6578 633a lueError as exc:\n-00024030: 0a20 2020 2020 2020 2020 2020 2072 6169 . rai\n-00024040: 7365 2043 6f63 6b70 6974 5072 6f74 6f63 se CockpitProtoc\n-00024050: 6f6c 4572 726f 7228 2266 7261 6d65 2073 olError(\"frame s\n-00024060: 697a 6520 6973 206e 6f74 2061 6e20 696e ize is not an in\n-00024070: 7465 6765 7222 2920 6672 6f6d 2065 7863 teger\") from exc\n-00024080: 0a0a 2020 2020 2020 2020 7374 6172 7420 .. start \n-00024090: 3d20 6e65 776c 696e 6520 2b20 310a 2020 = newline + 1. \n-000240a0: 2020 2020 2020 656e 6420 3d20 7374 6172 end = star\n-000240b0: 7420 2b20 6c65 6e67 7468 0a0a 2020 2020 t + length.. \n-000240c0: 2020 2020 6966 2065 6e64 203e 206c 656e if end > len\n-000240d0: 2864 6174 6129 3a0a 2020 2020 2020 2020 (data):. \n-000240e0: 2020 2020 2320 5765 206e 6565 6420 746f # We need to\n-000240f0: 2072 6561 6420 6d6f 7265 0a20 2020 2020 read more. \n-00024100: 2020 2020 2020 2072 6574 7572 6e20 6c65 return le\n-00024110: 6e28 6461 7461 2920 2d20 656e 640a 0a20 n(data) - end.. \n-00024120: 2020 2020 2020 2023 2057 6520 6361 6e20 # We can \n-00024130: 636f 6e73 756d 6520 6120 6675 6c6c 2066 consume a full f\n-00024140: 7261 6d65 0a20 2020 2020 2020 2073 656c rame. sel\n-00024150: 662e 6672 616d 655f 7265 6365 6976 6564 f.frame_received\n-00024160: 2864 6174 615b 7374 6172 743a 656e 645d (data[start:end]\n-00024170: 290a 2020 2020 2020 2020 7265 7475 726e ). return\n-00024180: 2065 6e64 0a0a 2020 2020 6465 6620 636f end.. def co\n-00024190: 6e6e 6563 7469 6f6e 5f6d 6164 6528 7365 nnection_made(se\n-000241a0: 6c66 2c20 7472 616e 7370 6f72 743a 2061 lf, transport: a\n-000241b0: 7379 6e63 696f 2e42 6173 6554 7261 6e73 syncio.BaseTrans\n-000241c0: 706f 7274 2920 2d3e 204e 6f6e 653a 0a20 port) -> None:. \n-000241d0: 2020 2020 2020 206c 6f67 6765 722e 6465 logger.de\n-000241e0: 6275 6728 2763 6f6e 6e65 6374 696f 6e5f bug('connection_\n-000241f0: 6d61 6465 2825 7329 272c 2074 7261 6e73 made(%s)', trans\n-00024200: 706f 7274 290a 2020 2020 2020 2020 6173 port). as\n-00024210: 7365 7274 2069 7369 6e73 7461 6e63 6528 sert isinstance(\n-00024220: 7472 616e 7370 6f72 742c 2061 7379 6e63 transport, async\n-00024230: 696f 2e54 7261 6e73 706f 7274 290a 2020 io.Transport). \n-00024240: 2020 2020 2020 7365 6c66 2e74 7261 6e73 self.trans\n-00024250: 706f 7274 203d 2074 7261 6e73 706f 7274 port = transport\n-00024260: 0a20 2020 2020 2020 2073 656c 662e 646f . self.do\n-00024270: 5f72 6561 6479 2829 0a0a 2020 2020 2020 _ready().. \n-00024280: 2020 6966 2073 656c 662e 5f63 6c6f 7365 if self._close\n-00024290: 643a 0a20 2020 2020 2020 2020 2020 206c d:. l\n-000242a0: 6f67 6765 722e 6465 6275 6728 2720 2062 ogger.debug(' b\n-000242b0: 7574 2074 6865 2070 726f 746f 636f 6c20 ut the protocol \n-000242c0: 616c 7265 6164 7920 7761 7320 636c 6f73 already was clos\n-000242d0: 6564 2c20 736f 2063 6c6f 7369 6e67 2074 ed, so closing t\n-000242e0: 7261 6e73 706f 7274 2729 0a20 2020 2020 ransport'). \n-000242f0: 2020 2020 2020 2074 7261 6e73 706f 7274 transport\n-00024300: 2e63 6c6f 7365 2829 0a0a 2020 2020 6465 .close().. de\n-00024310: 6620 636f 6e6e 6563 7469 6f6e 5f6c 6f73 f connection_los\n-00024320: 7428 7365 6c66 2c20 6578 633a 2027 4578 t(self, exc: 'Ex\n-00024330: 6365 7074 696f 6e20 7c20 4e6f 6e65 2729 ception | None')\n-00024340: 202d 3e20 4e6f 6e65 3a0a 2020 2020 2020 -> None:. \n-00024350: 2020 6c6f 6767 6572 2e64 6562 7567 2827 logger.debug('\n-00024360: 636f 6e6e 6563 7469 6f6e 5f6c 6f73 7427 connection_lost'\n-00024370: 290a 2020 2020 2020 2020 6173 7365 7274 ). assert\n-00024380: 2073 656c 662e 7472 616e 7370 6f72 7420 self.transport \n-00024390: 6973 206e 6f74 204e 6f6e 650a 2020 2020 is not None. \n-000243a0: 2020 2020 7365 6c66 2e74 7261 6e73 706f self.transpo\n-000243b0: 7274 203d 204e 6f6e 650a 2020 2020 2020 rt = None. \n-000243c0: 2020 7365 6c66 2e63 6c6f 7365 2865 7863 self.close(exc\n-000243d0: 290a 0a20 2020 2064 6566 2063 6c6f 7365 ).. def close\n-000243e0: 2873 656c 662c 2065 7863 3a20 2745 7863 (self, exc: 'Exc\n-000243f0: 6570 7469 6f6e 207c 204e 6f6e 6527 203d eption | None' =\n-00024400: 204e 6f6e 6529 202d 3e20 4e6f 6e65 3a0a None) -> None:.\n-00024410: 2020 2020 2020 2020 6966 2073 656c 662e if self.\n-00024420: 5f63 6c6f 7365 643a 0a20 2020 2020 2020 _closed:. \n-00024430: 2020 2020 2072 6574 7572 6e0a 2020 2020 return. \n-00024440: 2020 2020 7365 6c66 2e5f 636c 6f73 6564 self._closed\n-00024450: 203d 2054 7275 650a 0a20 2020 2020 2020 = True.. \n-00024460: 2069 6620 7365 6c66 2e74 7261 6e73 706f if self.transpo\n-00024470: 7274 3a0a 2020 2020 2020 2020 2020 2020 rt:. \n-00024480: 7365 6c66 2e74 7261 6e73 706f 7274 2e63 self.transport.c\n-00024490: 6c6f 7365 2829 0a0a 2020 2020 2020 2020 lose().. \n-000244a0: 7365 6c66 2e64 6f5f 636c 6f73 6564 2865 self.do_closed(e\n-000244b0: 7863 290a 0a20 2020 2064 6566 2077 7269 xc).. def wri\n-000244c0: 7465 5f63 6861 6e6e 656c 5f64 6174 6128 te_channel_data(\n-000244d0: 7365 6c66 2c20 6368 616e 6e65 6c3a 2073 self, channel: s\n-000244e0: 7472 2c20 7061 796c 6f61 643a 2062 7974 tr, payload: byt\n-000244f0: 6573 2920 2d3e 204e 6f6e 653a 0a20 2020 es) -> None:. \n-00024500: 2020 2020 2022 2222 5365 6e64 2061 2067 \"\"\"Send a g\n-00024510: 6976 656e 2070 6179 6c6f 6164 2028 6279 iven payload (by\n-00024520: 7465 7329 206f 6e20 6368 616e 6e65 6c20 tes) on channel \n-00024530: 2873 7472 696e 6729 2222 220a 2020 2020 (string)\"\"\". \n-00024540: 2020 2020 2320 4368 616e 6e65 6c20 6973 # Channel is\n-00024550: 2063 6572 7461 696e 6c79 2061 7363 6969 certainly ascii\n-00024560: 2028 6173 2065 6e66 6f72 6365 6420 6279 (as enforced by\n-00024570: 202e 656e 636f 6465 2829 2062 656c 6f77 .encode() below\n-00024580: 290a 2020 2020 2020 2020 6672 616d 655f ). frame_\n-00024590: 6c65 6e67 7468 203d 206c 656e 2863 6861 length = len(cha\n-000245a0: 6e6e 656c 202b 2027 5c6e 2729 202b 206c nnel + '\\n') + l\n-000245b0: 656e 2870 6179 6c6f 6164 290a 2020 2020 en(payload). \n-000245c0: 2020 2020 6865 6164 6572 203d 2066 277b header = f'{\n-000245d0: 6672 616d 655f 6c65 6e67 7468 7d5c 6e7b frame_length}\\n{\n-000245e0: 6368 616e 6e65 6c7d 5c6e 272e 656e 636f channel}\\n'.enco\n-000245f0: 6465 2827 6173 6369 6927 290a 2020 2020 de('ascii'). \n-00024600: 2020 2020 6966 2073 656c 662e 7472 616e if self.tran\n-00024610: 7370 6f72 7420 6973 206e 6f74 204e 6f6e sport is not Non\n-00024620: 653a 0a20 2020 2020 2020 2020 2020 206c e:. l\n-00024630: 6f67 6765 722e 6465 6275 6728 2777 7269 ogger.debug('wri\n-00024640: 7469 6e67 2074 6f20 7472 616e 7370 6f72 ting to transpor\n-00024650: 7420 2573 272c 2073 656c 662e 7472 616e t %s', self.tran\n-00024660: 7370 6f72 7429 0a20 2020 2020 2020 2020 sport). \n-00024670: 2020 2073 656c 662e 7472 616e 7370 6f72 self.transpor\n-00024680: 742e 7772 6974 6528 6865 6164 6572 202b t.write(header +\n-00024690: 2070 6179 6c6f 6164 290a 2020 2020 2020 payload). \n-000246a0: 2020 656c 7365 3a0a 2020 2020 2020 2020 else:. \n-000246b0: 2020 2020 6c6f 6767 6572 2e64 6562 7567 logger.debug\n-000246c0: 2827 6361 6e6e 6f74 2077 7269 7465 2074 ('cannot write t\n-000246d0: 6f20 636c 6f73 6564 2074 7261 6e73 706f o closed transpo\n-000246e0: 7274 2729 0a0a 2020 2020 6465 6620 7772 rt').. def wr\n-000246f0: 6974 655f 636f 6e74 726f 6c28 7365 6c66 ite_control(self\n-00024700: 2c20 5f6d 7367 3a20 274a 736f 6e4f 626a , _msg: 'JsonObj\n-00024710: 6563 7420 7c20 4e6f 6e65 2720 3d20 4e6f ect | None' = No\n-00024720: 6e65 2c20 2a2a 6b77 6172 6773 3a20 4a73 ne, **kwargs: Js\n-00024730: 6f6e 5661 6c75 6529 202d 3e20 4e6f 6e65 onValue) -> None\n-00024740: 3a0a 2020 2020 2020 2020 2222 2257 7269 :. \"\"\"Wri\n-00024750: 7465 2061 2063 6f6e 7472 6f6c 206d 6573 te a control mes\n-00024760: 7361 6765 2e20 2053 6565 206a 736f 6e75 sage. See jsonu\n-00024770: 7469 6c2e 6372 6561 7465 5f6f 626a 6563 til.create_objec\n-00024780: 7428 2920 666f 7220 6465 7461 696c 732e t() for details.\n-00024790: 2222 220a 2020 2020 2020 2020 6c6f 6767 \"\"\". logg\n-000247a0: 6572 2e64 6562 7567 2827 7365 6e64 696e er.debug('sendin\n-000247b0: 6720 636f 6e74 726f 6c20 6d65 7373 6167 g control messag\n-000247c0: 6520 2572 2025 7227 2c20 5f6d 7367 2c20 e %r %r', _msg, \n-000247d0: 6b77 6172 6773 290a 2020 2020 2020 2020 kwargs). \n-000247e0: 7072 6574 7479 203d 206a 736f 6e2e 6475 pretty = json.du\n-000247f0: 6d70 7328 6372 6561 7465 5f6f 626a 6563 mps(create_objec\n-00024800: 7428 5f6d 7367 2c20 6b77 6172 6773 292c t(_msg, kwargs),\n-00024810: 2069 6e64 656e 743d 3229 202b 2027 5c6e indent=2) + '\\n\n-00024820: 270a 2020 2020 2020 2020 7365 6c66 2e77 '. self.w\n-00024830: 7269 7465 5f63 6861 6e6e 656c 5f64 6174 rite_channel_dat\n-00024840: 6128 2727 2c20 7072 6574 7479 2e65 6e63 a('', pretty.enc\n-00024850: 6f64 6528 2929 0a0a 2020 2020 6465 6620 ode()).. def \n-00024860: 6461 7461 5f72 6563 6569 7665 6428 7365 data_received(se\n-00024870: 6c66 2c20 6461 7461 3a20 6279 7465 7329 lf, data: bytes)\n-00024880: 202d 3e20 4e6f 6e65 3a0a 2020 2020 2020 -> None:. \n-00024890: 2020 7472 793a 0a20 2020 2020 2020 2020 try:. \n-000248a0: 2020 2073 656c 662e 6275 6666 6572 202b self.buffer +\n-000248b0: 3d20 6461 7461 0a20 2020 2020 2020 2020 = data. \n-000248c0: 2020 2077 6869 6c65 2073 656c 662e 6275 while self.bu\n-000248d0: 6666 6572 3a0a 2020 2020 2020 2020 2020 ffer:. \n-000248e0: 2020 2020 2020 7265 7375 6c74 203d 2073 result = s\n-000248f0: 656c 662e 636f 6e73 756d 655f 6f6e 655f elf.consume_one_\n-00024900: 6672 616d 6528 7365 6c66 2e62 7566 6665 frame(self.buffe\n-00024910: 7229 0a20 2020 2020 2020 2020 2020 2020 r). \n-00024920: 2020 2069 6620 7265 7375 6c74 203c 3d20 if result <= \n-00024930: 303a 0a20 2020 2020 2020 2020 2020 2020 0:. \n-00024940: 2020 2020 2020 2072 6574 7572 6e0a 2020 return. \n-00024950: 2020 2020 2020 2020 2020 2020 2020 7365 se\n-00024960: 6c66 2e62 7566 6665 7220 3d20 7365 6c66 lf.buffer = self\n-00024970: 2e62 7566 6665 725b 7265 7375 6c74 3a5d .buffer[result:]\n-00024980: 0a20 2020 2020 2020 2065 7863 6570 7420 . except \n-00024990: 436f 636b 7069 7450 726f 746f 636f 6c45 CockpitProtocolE\n-000249a0: 7272 6f72 2061 7320 6578 633a 0a20 2020 rror as exc:. \n-000249b0: 2020 2020 2020 2020 2073 656c 662e 636c self.cl\n-000249c0: 6f73 6528 6578 6329 0a0a 2020 2020 6465 ose(exc).. de\n-000249d0: 6620 656f 665f 7265 6365 6976 6564 2873 f eof_received(s\n-000249e0: 656c 6629 202d 3e20 626f 6f6c 3a0a 2020 elf) -> bool:. \n-000249f0: 2020 2020 2020 7265 7475 726e 2046 616c return Fal\n-00024a00: 7365 0a0a 0a23 2048 656c 7066 756c 2066 se...# Helpful f\n-00024a10: 756e 6374 696f 6e61 6c69 7479 2066 6f72 unctionality for\n-00024a20: 2022 7365 7276 6572 222d 7369 6465 2070 \"server\"-side p\n-00024a30: 726f 746f 636f 6c20 696d 706c 656d 656e rotocol implemen\n-00024a40: 7461 7469 6f6e 730a 636c 6173 7320 436f tations.class Co\n-00024a50: 636b 7069 7450 726f 746f 636f 6c53 6572 ckpitProtocolSer\n-00024a60: 7665 7228 436f 636b 7069 7450 726f 746f ver(CockpitProto\n-00024a70: 636f 6c29 3a0a 2020 2020 696e 6974 5f68 col):. init_h\n-00024a80: 6f73 743a 2027 7374 7220 7c20 4e6f 6e65 ost: 'str | None\n-00024a90: 2720 3d20 4e6f 6e65 0a20 2020 2061 7574 ' = None. aut\n-00024aa0: 686f 7269 7a61 7469 6f6e 733a 2027 6469 horizations: 'di\n-00024ab0: 6374 5b73 7472 2c20 6173 796e 6369 6f2e ct[str, asyncio.\n-00024ac0: 4675 7475 7265 5b73 7472 5d5d 207c 204e Future[str]] | N\n-00024ad0: 6f6e 6527 203d 204e 6f6e 650a 0a20 2020 one' = None.. \n-00024ae0: 2064 6566 2064 6f5f 7365 6e64 5f69 6e69 def do_send_ini\n-00024af0: 7428 7365 6c66 2920 2d3e 204e 6f6e 653a t(self) -> None:\n-00024b00: 0a20 2020 2020 2020 2072 6169 7365 204e . raise N\n-00024b10: 6f74 496d 706c 656d 656e 7465 6445 7272 otImplementedErr\n-00024b20: 6f72 0a0a 2020 2020 6465 6620 646f 5f69 or.. def do_i\n-00024b30: 6e69 7428 7365 6c66 2c20 6d65 7373 6167 nit(self, messag\n-00024b40: 653a 204a 736f 6e4f 626a 6563 7429 202d e: JsonObject) -\n-00024b50: 3e20 4e6f 6e65 3a0a 2020 2020 2020 2020 > None:. \n-00024b60: 7061 7373 0a0a 2020 2020 6465 6620 646f pass.. def do\n-00024b70: 5f6b 696c 6c28 7365 6c66 2c20 686f 7374 _kill(self, host\n-00024b80: 3a20 2773 7472 207c 204e 6f6e 6527 2c20 : 'str | None', \n-00024b90: 6772 6f75 703a 2027 7374 7220 7c20 4e6f group: 'str | No\n-00024ba0: 6e65 272c 206d 6573 7361 6765 3a20 4a73 ne', message: Js\n-00024bb0: 6f6e 4f62 6a65 6374 2920 2d3e 204e 6f6e onObject) -> Non\n-00024bc0: 653a 0a20 2020 2020 2020 2072 6169 7365 e:. raise\n-00024bd0: 204e 6f74 496d 706c 656d 656e 7465 6445 NotImplementedE\n-00024be0: 7272 6f72 0a0a 2020 2020 6465 6620 7472 rror.. def tr\n-00024bf0: 616e 7370 6f72 745f 636f 6e74 726f 6c5f ansport_control_\n-00024c00: 7265 6365 6976 6564 2873 656c 662c 2063 received(self, c\n-00024c10: 6f6d 6d61 6e64 3a20 7374 722c 206d 6573 ommand: str, mes\n-00024c20: 7361 6765 3a20 4a73 6f6e 4f62 6a65 6374 sage: JsonObject\n-00024c30: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n-00024c40: 2020 2069 6620 636f 6d6d 616e 6420 3d3d if command ==\n-00024c50: 2027 696e 6974 273a 0a20 2020 2020 2020 'init':. \n-00024c60: 2020 2020 2069 6620 6765 745f 696e 7428 if get_int(\n-00024c70: 6d65 7373 6167 652c 2027 7665 7273 696f message, 'versio\n-00024c80: 6e27 2920 213d 2031 3a0a 2020 2020 2020 n') != 1:. \n-00024c90: 2020 2020 2020 2020 2020 7261 6973 6520 raise \n-00024ca0: 436f 636b 7069 7450 726f 746f 636f 6c45 CockpitProtocolE\n-00024cb0: 7272 6f72 2827 696e 636f 7272 6563 7420 rror('incorrect \n-00024cc0: 7665 7273 696f 6e20 6e75 6d62 6572 2729 version number')\n-00024cd0: 0a20 2020 2020 2020 2020 2020 2073 656c . sel\n-00024ce0: 662e 696e 6974 5f68 6f73 7420 3d20 6765 f.init_host = ge\n-00024cf0: 745f 7374 7228 6d65 7373 6167 652c 2027 t_str(message, '\n-00024d00: 686f 7374 2729 0a20 2020 2020 2020 2020 host'). \n-00024d10: 2020 2073 656c 662e 646f 5f69 6e69 7428 self.do_init(\n-00024d20: 6d65 7373 6167 6529 0a20 2020 2020 2020 message). \n-00024d30: 2065 6c69 6620 636f 6d6d 616e 6420 3d3d elif command ==\n-00024d40: 2027 6b69 6c6c 273a 0a20 2020 2020 2020 'kill':. \n-00024d50: 2020 2020 2073 656c 662e 646f 5f6b 696c self.do_kil\n-00024d60: 6c28 6765 745f 7374 725f 6f72 5f6e 6f6e l(get_str_or_non\n-00024d70: 6528 6d65 7373 6167 652c 2027 686f 7374 e(message, 'host\n-00024d80: 272c 204e 6f6e 6529 2c20 6765 745f 7374 ', None), get_st\n-00024d90: 725f 6f72 5f6e 6f6e 6528 6d65 7373 6167 r_or_none(messag\n-00024da0: 652c 2027 6772 6f75 7027 2c20 4e6f 6e65 e, 'group', None\n-00024db0: 292c 206d 6573 7361 6765 290a 2020 2020 ), message). \n-00024dc0: 2020 2020 656c 6966 2063 6f6d 6d61 6e64 elif command\n-00024dd0: 203d 3d20 2761 7574 686f 7269 7a65 273a == 'authorize':\n-00024de0: 0a20 2020 2020 2020 2020 2020 2073 656c . sel\n-00024df0: 662e 646f 5f61 7574 686f 7269 7a65 286d f.do_authorize(m\n-00024e00: 6573 7361 6765 290a 2020 2020 2020 2020 essage). \n-00024e10: 656c 7365 3a0a 2020 2020 2020 2020 2020 else:. \n-00024e20: 2020 7261 6973 6520 436f 636b 7069 7450 raise CockpitP\n-00024e30: 726f 746f 636f 6c45 7272 6f72 2866 2775 rotocolError(f'u\n-00024e40: 6e65 7870 6563 7465 6420 636f 6e74 726f nexpected contro\n-00024e50: 6c20 6d65 7373 6167 6520 7b63 6f6d 6d61 l message {comma\n-00024e60: 6e64 7d20 7265 6365 6976 6564 2729 0a0a nd} received')..\n-00024e70: 2020 2020 6465 6620 646f 5f72 6561 6479 def do_ready\n-00024e80: 2873 656c 6629 202d 3e20 4e6f 6e65 3a0a (self) -> None:.\n-00024e90: 2020 2020 2020 2020 7365 6c66 2e64 6f5f self.do_\n-00024ea0: 7365 6e64 5f69 6e69 7428 290a 0a20 2020 send_init().. \n-00024eb0: 2023 2061 7574 686f 7269 7a65 2072 6571 # authorize req\n-00024ec0: 7565 7374 2f72 6573 706f 6e73 6520 4150 uest/response AP\n-00024ed0: 490a 2020 2020 6173 796e 6320 6465 6620 I. async def \n-00024ee0: 7265 7175 6573 745f 6175 7468 6f72 697a request_authoriz\n-00024ef0: 6174 696f 6e28 0a20 2020 2020 2020 2073 ation(. s\n-00024f00: 656c 662c 2063 6861 6c6c 656e 6765 3a20 elf, challenge: \n-00024f10: 7374 722c 2074 696d 656f 7574 3a20 2769 str, timeout: 'i\n-00024f20: 6e74 207c 204e 6f6e 6527 203d 204e 6f6e nt | None' = Non\n-00024f30: 652c 202a 2a6b 7761 7267 733a 204a 736f e, **kwargs: Jso\n-00024f40: 6e56 616c 7565 0a20 2020 2029 202d 3e20 nValue. ) -> \n-00024f50: 7374 723a 0a20 2020 2020 2020 2069 6620 str:. if \n-00024f60: 7365 6c66 2e61 7574 686f 7269 7a61 7469 self.authorizati\n-00024f70: 6f6e 7320 6973 204e 6f6e 653a 0a20 2020 ons is None:. \n-00024f80: 2020 2020 2020 2020 2073 656c 662e 6175 self.au\n-00024f90: 7468 6f72 697a 6174 696f 6e73 203d 207b thorizations = {\n-00024fa0: 7d0a 2020 2020 2020 2020 636f 6f6b 6965 }. cookie\n-00024fb0: 203d 2073 7472 2875 7569 642e 7575 6964 = str(uuid.uuid\n-00024fc0: 3428 2929 0a20 2020 2020 2020 2066 7574 4()). fut\n-00024fd0: 7572 6520 3d20 6173 796e 6369 6f2e 6765 ure = asyncio.ge\n-00024fe0: 745f 7275 6e6e 696e 675f 6c6f 6f70 2829 t_running_loop()\n-00024ff0: 2e63 7265 6174 655f 6675 7475 7265 2829 .create_future()\n-00025000: 0a20 2020 2020 2020 2074 7279 3a0a 2020 . try:. \n-00025010: 2020 2020 2020 2020 2020 7365 6c66 2e61 self.a\n-00025020: 7574 686f 7269 7a61 7469 6f6e 735b 636f uthorizations[co\n-00025030: 6f6b 6965 5d20 3d20 6675 7475 7265 0a20 okie] = future. \n-00025040: 2020 2020 2020 2020 2020 2073 656c 662e self.\n-00025050: 7772 6974 655f 636f 6e74 726f 6c28 4e6f write_control(No\n-00025060: 6e65 2c20 636f 6d6d 616e 643d 2761 7574 ne, command='aut\n-00025070: 686f 7269 7a65 272c 2063 6861 6c6c 656e horize', challen\n-00025080: 6765 3d63 6861 6c6c 656e 6765 2c20 636f ge=challenge, co\n-00025090: 6f6b 6965 3d63 6f6f 6b69 652c 202a 2a6b okie=cookie, **k\n-000250a0: 7761 7267 7329 0a20 2020 2020 2020 2020 wargs). \n-000250b0: 2020 2072 6574 7572 6e20 6177 6169 7420 return await \n-000250c0: 6173 796e 6369 6f2e 7761 6974 5f66 6f72 asyncio.wait_for\n-000250d0: 2866 7574 7572 652c 2074 696d 656f 7574 (future, timeout\n-000250e0: 290a 2020 2020 2020 2020 6669 6e61 6c6c ). finall\n-000250f0: 793a 0a20 2020 2020 2020 2020 2020 2073 y:. s\n-00025100: 656c 662e 6175 7468 6f72 697a 6174 696f elf.authorizatio\n-00025110: 6e73 2e70 6f70 2863 6f6f 6b69 6529 0a0a ns.pop(cookie)..\n-00025120: 2020 2020 6465 6620 646f 5f61 7574 686f def do_autho\n-00025130: 7269 7a65 2873 656c 662c 206d 6573 7361 rize(self, messa\n-00025140: 6765 3a20 4a73 6f6e 4f62 6a65 6374 2920 ge: JsonObject) \n-00025150: 2d3e 204e 6f6e 653a 0a20 2020 2020 2020 -> None:. \n-00025160: 2063 6f6f 6b69 6520 3d20 6765 745f 7374 cookie = get_st\n-00025170: 7228 6d65 7373 6167 652c 2027 636f 6f6b r(message, 'cook\n-00025180: 6965 2729 0a20 2020 2020 2020 2072 6573 ie'). res\n-00025190: 706f 6e73 6520 3d20 6765 745f 7374 7228 ponse = get_str(\n-000251a0: 6d65 7373 6167 652c 2027 7265 7370 6f6e message, 'respon\n-000251b0: 7365 2729 0a0a 2020 2020 2020 2020 6966 se').. if\n-000251c0: 2073 656c 662e 6175 7468 6f72 697a 6174 self.authorizat\n-000251d0: 696f 6e73 2069 7320 4e6f 6e65 206f 7220 ions is None or \n-000251e0: 636f 6f6b 6965 206e 6f74 2069 6e20 7365 cookie not in se\n-000251f0: 6c66 2e61 7574 686f 7269 7a61 7469 6f6e lf.authorization\n-00025200: 733a 0a20 2020 2020 2020 2020 2020 206c s:. l\n-00025210: 6f67 6765 722e 7761 726e 696e 6728 276e ogger.warning('n\n-00025220: 6f20 6d61 7463 6869 6e67 2061 7574 686f o matching autho\n-00025230: 7269 7a65 2072 6571 7565 7374 2729 0a20 rize request'). \n-00025240: 2020 2020 2020 2020 2020 2072 6574 7572 retur\n-00025250: 6e0a 0a20 2020 2020 2020 2073 656c 662e n.. self.\n-00025260: 6175 7468 6f72 697a 6174 696f 6e73 5b63 authorizations[c\n-00025270: 6f6f 6b69 655d 2e73 6574 5f72 6573 756c ookie].set_resul\n-00025280: 7428 7265 7370 6f6e 7365 290a 2727 272c t(response).''',\n-00025290: 0a20 2027 636f 636b 7069 742f 7265 6d6f . 'cockpit/remo\n-000252a0: 7465 2e70 7927 3a20 7227 2727 2320 5468 te.py': r'''# Th\n-000252b0: 6973 2066 696c 6520 6973 2070 6172 7420 is file is part \n-000252c0: 6f66 2043 6f63 6b70 6974 2e0a 230a 2320 of Cockpit..#.# \n-000252d0: 436f 7079 7269 6768 7420 2843 2920 3230 Copyright (C) 20\n-000252e0: 3232 2052 6564 2048 6174 2c20 496e 632e 22 Red Hat, Inc.\n-000252f0: 0a23 0a23 2054 6869 7320 7072 6f67 7261 .#.# This progra\n-00025300: 6d20 6973 2066 7265 6520 736f 6674 7761 m is free softwa\n-00025310: 7265 3a20 796f 7520 6361 6e20 7265 6469 re: you can redi\n-00025320: 7374 7269 6275 7465 2069 7420 616e 642f stribute it and/\n-00025330: 6f72 206d 6f64 6966 790a 2320 6974 2075 or modify.# it u\n-00025340: 6e64 6572 2074 6865 2074 6572 6d73 206f nder the terms o\n-00025350: 6620 7468 6520 474e 5520 4765 6e65 7261 f the GNU Genera\n-00025360: 6c20 5075 626c 6963 204c 6963 656e 7365 l Public License\n-00025370: 2061 7320 7075 626c 6973 6865 6420 6279 as published by\n-00025380: 0a23 2074 6865 2046 7265 6520 536f 6674 .# the Free Soft\n-00025390: 7761 7265 2046 6f75 6e64 6174 696f 6e2c ware Foundation,\n-000253a0: 2065 6974 6865 7220 7665 7273 696f 6e20 either version \n-000253b0: 3320 6f66 2074 6865 204c 6963 656e 7365 3 of the License\n-000253c0: 2c20 6f72 0a23 2028 6174 2079 6f75 7220 , or.# (at your \n-000253d0: 6f70 7469 6f6e 2920 616e 7920 6c61 7465 option) any late\n-000253e0: 7220 7665 7273 696f 6e2e 0a23 0a23 2054 r version..#.# T\n-000253f0: 6869 7320 7072 6f67 7261 6d20 6973 2064 his program is d\n-00025400: 6973 7472 6962 7574 6564 2069 6e20 7468 istributed in th\n-00025410: 6520 686f 7065 2074 6861 7420 6974 2077 e hope that it w\n-00025420: 696c 6c20 6265 2075 7365 6675 6c2c 0a23 ill be useful,.#\n-00025430: 2062 7574 2057 4954 484f 5554 2041 4e59 but WITHOUT ANY\n-00025440: 2057 4152 5241 4e54 593b 2077 6974 686f WARRANTY; witho\n-00025450: 7574 2065 7665 6e20 7468 6520 696d 706c ut even the impl\n-00025460: 6965 6420 7761 7272 616e 7479 206f 660a ied warranty of.\n-00025470: 2320 4d45 5243 4841 4e54 4142 494c 4954 # MERCHANTABILIT\n-00025480: 5920 6f72 2046 4954 4e45 5353 2046 4f52 Y or FITNESS FOR\n-00025490: 2041 2050 4152 5449 4355 4c41 5220 5055 A PARTICULAR PU\n-000254a0: 5250 4f53 452e 2020 5365 6520 7468 650a RPOSE. See the.\n-000254b0: 2320 474e 5520 4765 6e65 7261 6c20 5075 # GNU General Pu\n-000254c0: 626c 6963 204c 6963 656e 7365 2066 6f72 blic License for\n-000254d0: 206d 6f72 6520 6465 7461 696c 732e 0a23 more details..#\n-000254e0: 0a23 2059 6f75 2073 686f 756c 6420 6861 .# You should ha\n-000254f0: 7665 2072 6563 6569 7665 6420 6120 636f ve received a co\n-00025500: 7079 206f 6620 7468 6520 474e 5520 4765 py of the GNU Ge\n-00025510: 6e65 7261 6c20 5075 626c 6963 204c 6963 neral Public Lic\n-00025520: 656e 7365 0a23 2061 6c6f 6e67 2077 6974 ense.# along wit\n-00025530: 6820 7468 6973 2070 726f 6772 616d 2e20 h this program. \n-00025540: 2049 6620 6e6f 742c 2073 6565 203c 6874 If not, see ...i\n-00025570: 6d70 6f72 7420 6765 7470 6173 730a 696d mport getpass.im\n-00025580: 706f 7274 206c 6f67 6769 6e67 0a69 6d70 port logging.imp\n-00025590: 6f72 7420 7265 0a69 6d70 6f72 7420 736f ort re.import so\n-000255a0: 636b 6574 0a66 726f 6d20 7479 7069 6e67 cket.from typing\n-000255b0: 2069 6d70 6f72 7420 4469 6374 2c20 4c69 import Dict, Li\n-000255c0: 7374 2c20 4f70 7469 6f6e 616c 2c20 5475 st, Optional, Tu\n-000255d0: 706c 650a 0a66 726f 6d20 636f 636b 7069 ple..from cockpi\n-000255e0: 742e 5f76 656e 646f 7220 696d 706f 7274 t._vendor import\n-000255f0: 2066 6572 6e79 0a0a 6672 6f6d 202e 6a73 ferny..from .js\n-00025600: 6f6e 7574 696c 2069 6d70 6f72 7420 4a73 onutil import Js\n-00025610: 6f6e 4f62 6a65 6374 2c20 4a73 6f6e 5661 onObject, JsonVa\n-00025620: 6c75 652c 2067 6574 5f73 7472 2c20 6765 lue, get_str, ge\n-00025630: 745f 7374 725f 6f72 5f6e 6f6e 650a 6672 t_str_or_none.fr\n-00025640: 6f6d 202e 7065 6572 2069 6d70 6f72 7420 om .peer import \n-00025650: 5065 6572 2c20 5065 6572 4572 726f 720a Peer, PeerError.\n-00025660: 6672 6f6d 202e 726f 7574 6572 2069 6d70 from .router imp\n-00025670: 6f72 7420 526f 7574 6572 2c20 526f 7574 ort Router, Rout\n-00025680: 696e 6752 756c 650a 0a6c 6f67 6765 7220 ingRule..logger \n-00025690: 3d20 6c6f 6767 696e 672e 6765 744c 6f67 = logging.getLog\n-000256a0: 6765 7228 5f5f 6e61 6d65 5f5f 290a 0a0a ger(__name__)...\n-000256b0: 636c 6173 7320 5061 7373 776f 7264 5265 class PasswordRe\n-000256c0: 7370 6f6e 6465 7228 6665 726e 792e 4173 sponder(ferny.As\n-000256d0: 6b70 6173 7348 616e 646c 6572 293a 0a20 kpassHandler):. \n-000256e0: 2020 2050 4153 5350 4852 4153 455f 5245 PASSPHRASE_RE\n-000256f0: 203d 2072 652e 636f 6d70 696c 6528 7222 = re.compile(r\"\n-00025700: 456e 7465 7220 7061 7373 7068 7261 7365 Enter passphrase\n-00025710: 2066 6f72 206b 6579 2027 282e 2a29 273a for key '(.*)':\n-00025720: 2022 290a 0a20 2020 2070 6173 7377 6f72 \").. passwor\n-00025730: 643a 204f 7074 696f 6e61 6c5b 7374 725d d: Optional[str]\n-00025740: 0a0a 2020 2020 686f 7374 6b65 7973 5f73 .. hostkeys_s\n-00025750: 6565 6e3a 204c 6973 745b 5475 706c 655b een: List[Tuple[\n-00025760: 7374 722c 2073 7472 2c20 7374 722c 2073 str, str, str, s\n-00025770: 7472 2c20 7374 725d 5d0a 2020 2020 6572 tr, str]]. er\n-00025780: 726f 725f 6d65 7373 6167 653a 204f 7074 ror_message: Opt\n-00025790: 696f 6e61 6c5b 7374 725d 0a20 2020 2070 ional[str]. p\n-000257a0: 6173 7377 6f72 645f 6174 7465 6d70 7473 assword_attempts\n-000257b0: 3a20 696e 740a 0a20 2020 2064 6566 205f : int.. def _\n-000257c0: 5f69 6e69 745f 5f28 7365 6c66 2c20 7061 _init__(self, pa\n-000257d0: 7373 776f 7264 3a20 4f70 7469 6f6e 616c ssword: Optional\n-000257e0: 5b73 7472 5d29 3a0a 2020 2020 2020 2020 [str]):. \n-000257f0: 7365 6c66 2e70 6173 7377 6f72 6420 3d20 self.password = \n-00025800: 7061 7373 776f 7264 0a0a 2020 2020 2020 password.. \n-00025810: 2020 7365 6c66 2e68 6f73 746b 6579 735f self.hostkeys_\n-00025820: 7365 656e 203d 205b 5d0a 2020 2020 2020 seen = []. \n-00025830: 2020 7365 6c66 2e65 7272 6f72 5f6d 6573 self.error_mes\n-00025840: 7361 6765 203d 204e 6f6e 650a 2020 2020 sage = None. \n-00025850: 2020 2020 7365 6c66 2e70 6173 7377 6f72 self.passwor\n-00025860: 645f 6174 7465 6d70 7473 203d 2030 0a0a d_attempts = 0..\n-00025870: 2020 2020 6173 796e 6320 6465 6620 646f async def do\n-00025880: 5f68 6f73 746b 6579 2873 656c 662c 2072 _hostkey(self, r\n-00025890: 6561 736f 6e3a 2073 7472 2c20 686f 7374 eason: str, host\n-000258a0: 3a20 7374 722c 2061 6c67 6f72 6974 686d : str, algorithm\n-000258b0: 3a20 7374 722c 206b 6579 3a20 7374 722c : str, key: str,\n-000258c0: 2066 696e 6765 7270 7269 6e74 3a20 7374 fingerprint: st\n-000258d0: 7229 202d 3e20 626f 6f6c 3a0a 2020 2020 r) -> bool:. \n-000258e0: 2020 2020 7365 6c66 2e68 6f73 746b 6579 self.hostkey\n-000258f0: 735f 7365 656e 2e61 7070 656e 6428 2872 s_seen.append((r\n-00025900: 6561 736f 6e2c 2068 6f73 742c 2061 6c67 eason, host, alg\n-00025910: 6f72 6974 686d 2c20 6b65 792c 2066 696e orithm, key, fin\n-00025920: 6765 7270 7269 6e74 2929 0a20 2020 2020 gerprint)). \n-00025930: 2020 2072 6574 7572 6e20 4661 6c73 650a return False.\n-00025940: 0a20 2020 2061 7379 6e63 2064 6566 2064 . async def d\n-00025950: 6f5f 6173 6b70 6173 7328 7365 6c66 2c20 o_askpass(self, \n-00025960: 6d65 7373 6167 6573 3a20 7374 722c 2070 messages: str, p\n-00025970: 726f 6d70 743a 2073 7472 2c20 6869 6e74 rompt: str, hint\n-00025980: 3a20 7374 7229 202d 3e20 4f70 7469 6f6e : str) -> Option\n-00025990: 616c 5b73 7472 5d3a 0a20 2020 2020 2020 al[str]:. \n-000259a0: 206c 6f67 6765 722e 6465 6275 6728 2747 logger.debug('G\n-000259b0: 6f74 2061 736b 7061 7373 2825 7329 3a20 ot askpass(%s): \n-000259c0: 2573 272c 2068 696e 742c 2070 726f 6d70 %s', hint, promp\n-000259d0: 7429 0a0a 2020 2020 2020 2020 6d61 7463 t).. matc\n-000259e0: 6820 3d20 5061 7373 776f 7264 5265 7370 h = PasswordResp\n-000259f0: 6f6e 6465 722e 5041 5353 5048 5241 5345 onder.PASSPHRASE\n-00025a00: 5f52 452e 6675 6c6c 6d61 7463 6828 7072 _RE.fullmatch(pr\n-00025a10: 6f6d 7074 290a 2020 2020 2020 2020 6966 ompt). if\n-00025a20: 206d 6174 6368 2069 7320 6e6f 7420 4e6f match is not No\n-00025a30: 6e65 3a0a 2020 2020 2020 2020 2020 2020 ne:. \n-00025a40: 2320 5765 206e 6576 6572 2075 6e6c 6f63 # We never unloc\n-00025a50: 6b20 7072 6976 6174 6520 6b65 7973 20e2 k private keys .\n-00025a60: 8094 2077 6520 7261 7468 6572 206e 6565 .. we rather nee\n-00025a70: 6420 746f 2074 6872 6f77 2061 0a20 2020 d to throw a. \n-00025a80: 2020 2020 2020 2020 2023 2073 7065 6369 # speci\n-00025a90: 616c 6c79 2d66 6f72 6d61 7474 6564 2065 ally-formatted e\n-00025aa0: 7272 6f72 206d 6573 7361 6765 2077 6869 rror message whi\n-00025ab0: 6368 2077 696c 6c20 6361 7573 6520 7468 ch will cause th\n-00025ac0: 6520 6672 6f6e 7465 6e64 0a20 2020 2020 e frontend. \n-00025ad0: 2020 2020 2020 2023 2074 6f20 6c6f 6164 # to load\n-00025ae0: 2074 6865 206e 616d 6564 206b 6579 2069 the named key i\n-00025af0: 6e74 6f20 7468 6520 6167 656e 7420 666f nto the agent fo\n-00025b00: 7220 7573 2061 6e64 2074 7279 2061 6761 r us and try aga\n-00025b10: 696e 2e0a 2020 2020 2020 2020 2020 2020 in.. \n-00025b20: 7061 7468 203d 206d 6174 6368 2e67 726f path = match.gro\n-00025b30: 7570 2831 290a 2020 2020 2020 2020 2020 up(1). \n-00025b40: 2020 6c6f 6767 6572 2e64 6562 7567 2822 logger.debug(\"\n-00025b50: 5468 6973 2069 7320 6120 7061 7373 7068 This is a passph\n-00025b60: 7261 7365 2072 6571 7565 7374 2066 6f72 rase request for\n-00025b70: 2025 732c 2062 7574 2077 6520 646f 6e27 %s, but we don'\n-00025b80: 7420 646f 2074 686f 7365 2e20 2041 626f t do those. Abo\n-00025b90: 7274 2e22 2c20 7061 7468 290a 2020 2020 rt.\", path). \n-00025ba0: 2020 2020 2020 2020 7365 6c66 2e65 7272 self.err\n-00025bb0: 6f72 5f6d 6573 7361 6765 203d 2066 276c or_message = f'l\n-00025bc0: 6f63 6b65 6420 6964 656e 7469 7479 3a20 ocked identity: \n-00025bd0: 7b70 6174 687d 270a 2020 2020 2020 2020 {path}'. \n-00025be0: 2020 2020 7265 7475 726e 204e 6f6e 650a return None.\n-00025bf0: 0a20 2020 2020 2020 2061 7373 6572 7420 . assert \n-00025c00: 7365 6c66 2e70 6173 7377 6f72 6420 6973 self.password is\n-00025c10: 206e 6f74 204e 6f6e 650a 2020 2020 2020 not None. \n-00025c20: 2020 6173 7365 7274 2073 656c 662e 7061 assert self.pa\n-00025c30: 7373 776f 7264 5f61 7474 656d 7074 7320 ssword_attempts \n-00025c40: 3d3d 2030 0a20 2020 2020 2020 2073 656c == 0. sel\n-00025c50: 662e 7061 7373 776f 7264 5f61 7474 656d f.password_attem\n-00025c60: 7074 7320 2b3d 2031 0a20 2020 2020 2020 pts += 1. \n-00025c70: 2072 6574 7572 6e20 7365 6c66 2e70 6173 return self.pas\n-00025c80: 7377 6f72 640a 0a0a 636c 6173 7320 5373 sword...class Ss\n-00025c90: 6850 6565 7228 5065 6572 293a 0a20 2020 hPeer(Peer):. \n-00025ca0: 2073 6573 7369 6f6e 3a20 4f70 7469 6f6e session: Option\n-00025cb0: 616c 5b66 6572 6e79 2e53 6573 7369 6f6e al[ferny.Session\n-00025cc0: 5d20 3d20 4e6f 6e65 0a20 2020 2068 6f73 ] = None. hos\n-00025cd0: 743a 2073 7472 0a20 2020 2075 7365 723a t: str. user:\n-00025ce0: 204f 7074 696f 6e61 6c5b 7374 725d 0a20 Optional[str]. \n-00025cf0: 2020 2070 6173 7377 6f72 643a 204f 7074 password: Opt\n-00025d00: 696f 6e61 6c5b 7374 725d 0a20 2020 2070 ional[str]. p\n-00025d10: 7269 7661 7465 3a20 626f 6f6c 0a0a 2020 rivate: bool.. \n-00025d20: 2020 6173 796e 6320 6465 6620 646f 5f63 async def do_c\n-00025d30: 6f6e 6e65 6374 5f74 7261 6e73 706f 7274 onnect_transport\n-00025d40: 2873 656c 6629 202d 3e20 4e6f 6e65 3a0a (self) -> None:.\n-00025d50: 2020 2020 2020 2020 6173 7365 7274 2073 assert s\n-00025d60: 656c 662e 7365 7373 696f 6e20 6973 206e elf.session is n\n-00025d70: 6f74 204e 6f6e 650a 2020 2020 2020 2020 ot None. \n-00025d80: 6c6f 6767 6572 2e64 6562 7567 2827 5374 logger.debug('St\n-00025d90: 6172 7469 6e67 2073 7368 2073 6573 7369 arting ssh sessi\n-00025da0: 6f6e 2075 7365 723d 2573 2c20 686f 7374 on user=%s, host\n-00025db0: 3d25 732c 2070 7269 7661 7465 3d25 7327 =%s, private=%s'\n-00025dc0: 2c20 7365 6c66 2e75 7365 722c 2073 656c , self.user, sel\n-00025dd0: 662e 686f 7374 2c20 7365 6c66 2e70 7269 f.host, self.pri\n-00025de0: 7661 7465 290a 0a20 2020 2020 2020 2062 vate).. b\n-00025df0: 6173 656e 616d 652c 2063 6f6c 6f6e 2c20 asename, colon, \n-00025e00: 706f 7274 7374 7220 3d20 7365 6c66 2e68 portstr = self.h\n-00025e10: 6f73 742e 7270 6172 7469 7469 6f6e 2827 ost.rpartition('\n-00025e20: 3a27 290a 2020 2020 2020 2020 6966 2063 :'). if c\n-00025e30: 6f6c 6f6e 2061 6e64 2070 6f72 7473 7472 olon and portstr\n-00025e40: 2e69 7364 6967 6974 2829 3a0a 2020 2020 .isdigit():. \n-00025e50: 2020 2020 2020 2020 686f 7374 203d 2062 host = b\n-00025e60: 6173 656e 616d 650a 2020 2020 2020 2020 asename. \n-00025e70: 2020 2020 706f 7274 203d 2069 6e74 2870 port = int(p\n-00025e80: 6f72 7473 7472 290a 2020 2020 2020 2020 ortstr). \n-00025e90: 656c 7365 3a0a 2020 2020 2020 2020 2020 else:. \n-00025ea0: 2020 686f 7374 203d 2073 656c 662e 686f host = self.ho\n-00025eb0: 7374 0a20 2020 2020 2020 2020 2020 2070 st. p\n-00025ec0: 6f72 7420 3d20 4e6f 6e65 0a0a 2020 2020 ort = None.. \n-00025ed0: 2020 2020 7265 7370 6f6e 6465 7220 3d20 responder = \n-00025ee0: 5061 7373 776f 7264 5265 7370 6f6e 6465 PasswordResponde\n-00025ef0: 7228 7365 6c66 2e70 6173 7377 6f72 6429 r(self.password)\n-00025f00: 0a20 2020 2020 2020 206f 7074 696f 6e73 . options\n-00025f10: 203d 207b 2253 7472 6963 7448 6f73 744b = {\"StrictHostK\n-00025f20: 6579 4368 6563 6b69 6e67 223a 2027 7965 eyChecking\": 'ye\n-00025f30: 7327 7d0a 0a20 2020 2020 2020 2069 6620 s'}.. if \n-00025f40: 7365 6c66 2e70 6173 7377 6f72 6420 6973 self.password is\n-00025f50: 206e 6f74 204e 6f6e 653a 0a20 2020 2020 not None:. \n-00025f60: 2020 2020 2020 206f 7074 696f 6e73 2e75 options.u\n-00025f70: 7064 6174 6528 4e75 6d62 6572 4f66 5061 pdate(NumberOfPa\n-00025f80: 7373 776f 7264 5072 6f6d 7074 733d 2731 sswordPrompts='1\n-00025f90: 2729 0a20 2020 2020 2020 2065 6c73 653a '). else:\n-00025fa0: 0a20 2020 2020 2020 2020 2020 206f 7074 . opt\n-00025fb0: 696f 6e73 2e75 7064 6174 6528 5061 7373 ions.update(Pass\n-00025fc0: 776f 7264 4175 7468 656e 7469 6361 7469 wordAuthenticati\n-00025fd0: 6f6e 3d22 6e6f 222c 204b 6264 496e 7465 on=\"no\", KbdInte\n-00025fe0: 7261 6374 6976 6541 7574 6865 6e74 6963 ractiveAuthentic\n-00025ff0: 6174 696f 6e3d 226e 6f22 290a 0a20 2020 ation=\"no\").. \n-00026000: 2020 2020 2074 7279 3a0a 2020 2020 2020 try:. \n-00026010: 2020 2020 2020 6177 6169 7420 7365 6c66 await self\n-00026020: 2e73 6573 7369 6f6e 2e63 6f6e 6e65 6374 .session.connect\n-00026030: 2868 6f73 742c 206c 6f67 696e 5f6e 616d (host, login_nam\n-00026040: 653d 7365 6c66 2e75 7365 722c 2070 6f72 e=self.user, por\n-00026050: 743d 706f 7274 2c0a 2020 2020 2020 2020 t=port,. \n-00026060: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00026070: 2020 2020 2020 2020 2020 2020 2020 2068 h\n-00026080: 616e 646c 655f 686f 7374 5f6b 6579 3d73 andle_host_key=s\n-00026090: 656c 662e 7072 6976 6174 652c 206f 7074 elf.private, opt\n-000260a0: 696f 6e73 3d6f 7074 696f 6e73 2c0a 2020 ions=options,. \n-000260b0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000260c0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000260d0: 2020 2020 2069 6e74 6572 6163 7469 6f6e interaction\n-000260e0: 5f72 6573 706f 6e64 6572 3d72 6573 706f _responder=respo\n-000260f0: 6e64 6572 290a 2020 2020 2020 2020 6578 nder). ex\n-00026100: 6365 7074 2028 4f53 4572 726f 722c 2073 cept (OSError, s\n-00026110: 6f63 6b65 742e 6761 6965 7272 6f72 2920 ocket.gaierror) \n-00026120: 6173 2065 7863 3a0a 2020 2020 2020 2020 as exc:. \n-00026130: 2020 2020 6c6f 6767 6572 2e64 6562 7567 logger.debug\n-00026140: 2827 636f 6e6e 6563 7469 6e67 2074 6f20 ('connecting to \n-00026150: 686f 7374 2025 7320 6661 696c 6564 3a20 host %s failed: \n-00026160: 2573 272c 2068 6f73 742c 2065 7863 290a %s', host, exc).\n-00026170: 2020 2020 2020 2020 2020 2020 7261 6973 rais\n-00026180: 6520 5065 6572 4572 726f 7228 276e 6f2d e PeerError('no-\n-00026190: 686f 7374 272c 2065 7272 6f72 3d27 6e6f host', error='no\n-000261a0: 2d68 6f73 7427 2c20 6d65 7373 6167 653d -host', message=\n-000261b0: 7374 7228 6578 6329 2920 6672 6f6d 2065 str(exc)) from e\n-000261c0: 7863 0a0a 2020 2020 2020 2020 6578 6365 xc.. exce\n-000261d0: 7074 2066 6572 6e79 2e53 7368 486f 7374 pt ferny.SshHost\n-000261e0: 4b65 7945 7272 6f72 2061 7320 6578 633a KeyError as exc:\n-000261f0: 0a20 2020 2020 2020 2020 2020 2069 6620 . if \n-00026200: 7265 7370 6f6e 6465 722e 686f 7374 6b65 responder.hostke\n-00026210: 7973 5f73 6565 6e3a 0a20 2020 2020 2020 ys_seen:. \n-00026220: 2020 2020 2020 2020 2023 2049 6620 7765 # If we\n-00026230: 2073 6177 2061 2068 6f73 746b 6579 2074 saw a hostkey t\n-00026240: 6865 6e20 7765 2063 616e 2069 7373 7565 hen we can issue\n-00026250: 2061 2064 6574 6169 6c65 6420 6572 726f a detailed erro\n-00026260: 7220 6d65 7373 6167 650a 2020 2020 2020 r message. \n-00026270: 2020 2020 2020 2020 2020 2320 636f 6e74 # cont\n-00026280: 6169 6e69 6e67 2074 6865 206b 6579 2074 aining the key t\n-00026290: 6861 7420 776f 756c 6420 6e65 6564 2074 hat would need t\n-000262a0: 6f20 6265 2061 6363 6570 7465 642e 2020 o be accepted. \n-000262b0: 5468 6174 2077 696c 6c0a 2020 2020 2020 That will. \n-000262c0: 2020 2020 2020 2020 2020 2320 6361 7573 # caus\n-000262d0: 6520 7468 6520 6672 6f6e 742d 656e 6420 e the front-end \n-000262e0: 746f 2070 7265 7365 6e74 2061 2064 6961 to present a dia\n-000262f0: 6c6f 672e 0a20 2020 2020 2020 2020 2020 log.. \n-00026300: 2020 2020 205f 7265 6173 6f6e 2c20 686f _reason, ho\n-00026310: 7374 2c20 616c 676f 7269 7468 6d2c 206b st, algorithm, k\n-00026320: 6579 2c20 6669 6e67 6572 7072 696e 7420 ey, fingerprint \n-00026330: 3d20 7265 7370 6f6e 6465 722e 686f 7374 = responder.host\n-00026340: 6b65 7973 5f73 6565 6e5b 305d 0a20 2020 keys_seen[0]. \n-00026350: 2020 2020 2020 2020 2020 2020 2065 7272 err\n-00026360: 6f72 5f61 7267 7320 3d20 7b27 686f 7374 or_args = {'host\n-00026370: 2d6b 6579 273a 2066 277b 686f 7374 7d20 -key': f'{host} \n-00026380: 7b61 6c67 6f72 6974 686d 7d20 7b6b 6579 {algorithm} {key\n-00026390: 7d27 2c20 2768 6f73 742d 6669 6e67 6572 }', 'host-finger\n-000263a0: 7072 696e 7427 3a20 6669 6e67 6572 7072 print': fingerpr\n-000263b0: 696e 747d 0a20 2020 2020 2020 2020 2020 int}. \n-000263c0: 2065 6c73 653a 0a20 2020 2020 2020 2020 else:. \n-000263d0: 2020 2020 2020 2065 7272 6f72 5f61 7267 error_arg\n-000263e0: 7320 3d20 7b7d 0a0a 2020 2020 2020 2020 s = {}.. \n-000263f0: 2020 2020 6966 2069 7369 6e73 7461 6e63 if isinstanc\n-00026400: 6528 6578 632c 2066 6572 6e79 2e53 7368 e(exc, ferny.Ssh\n-00026410: 4368 616e 6765 6448 6f73 744b 6579 4572 ChangedHostKeyEr\n-00026420: 726f 7229 3a0a 2020 2020 2020 2020 2020 ror):. \n-00026430: 2020 2020 2020 6572 726f 7220 3d20 2769 error = 'i\n-00026440: 6e76 616c 6964 2d68 6f73 746b 6579 270a nvalid-hostkey'.\n-00026450: 2020 2020 2020 2020 2020 2020 656c 6966 elif\n-00026460: 2073 656c 662e 7072 6976 6174 653a 0a20 self.private:. \n-00026470: 2020 2020 2020 2020 2020 2020 2020 2065 e\n-00026480: 7272 6f72 203d 2027 756e 6b6e 6f77 6e2d rror = 'unknown-\n-00026490: 686f 7374 6b65 7927 0a20 2020 2020 2020 hostkey'. \n-000264a0: 2020 2020 2065 6c73 653a 0a20 2020 2020 else:. \n-000264b0: 2020 2020 2020 2020 2020 2023 206e 6f6e # non\n-000264c0: 2d70 7269 7661 7465 2073 6573 7369 6f6e -private session\n-000264d0: 2063 6173 652e 2020 7468 726f 7720 6120 case. throw a \n-000264e0: 6765 6e65 7269 6320 6572 726f 722e 0a20 generic error.. \n-000264f0: 2020 2020 2020 2020 2020 2020 2020 2065 e\n-00026500: 7272 6f72 203d 2027 756e 6b6e 6f77 6e2d rror = 'unknown-\n-00026510: 686f 7374 270a 0a20 2020 2020 2020 2020 host'.. \n-00026520: 2020 206c 6f67 6765 722e 6465 6275 6728 logger.debug(\n-00026530: 2753 7368 5065 6572 2067 6f74 2061 2025 'SshPeer got a %\n-00026540: 7320 2573 3b20 7072 6976 6174 6520 2573 s %s; private %s\n-00026550: 2c20 7365 656e 2068 6f73 746b 6579 7320 , seen hostkeys \n-00026560: 2572 3b20 7261 6973 696e 6720 2573 2077 %r; raising %s w\n-00026570: 6974 6820 6578 7472 6120 6172 6773 2025 ith extra args %\n-00026580: 7227 2c0a 2020 2020 2020 2020 2020 2020 r',. \n-00026590: 2020 2020 2020 2020 2020 2020 2074 7970 typ\n-000265a0: 6528 6578 6329 2c20 6578 632c 2073 656c e(exc), exc, sel\n-000265b0: 662e 7072 6976 6174 652c 2072 6573 706f f.private, respo\n-000265c0: 6e64 6572 2e68 6f73 746b 6579 735f 7365 nder.hostkeys_se\n-000265d0: 656e 2c20 6572 726f 722c 2065 7272 6f72 en, error, error\n-000265e0: 5f61 7267 7329 0a20 2020 2020 2020 2020 _args). \n-000265f0: 2020 2072 6169 7365 2050 6565 7245 7272 raise PeerErr\n-00026600: 6f72 2865 7272 6f72 2c20 6572 726f 725f or(error, error_\n-00026610: 6172 6773 2c20 6572 726f 723d 6572 726f args, error=erro\n-00026620: 722c 2061 7574 685f 6d65 7468 6f64 5f72 r, auth_method_r\n-00026630: 6573 756c 7473 3d7b 7d29 2066 726f 6d20 esults={}) from \n-00026640: 6578 630a 0a20 2020 2020 2020 2065 7863 exc.. exc\n-00026650: 6570 7420 6665 726e 792e 5373 6841 7574 ept ferny.SshAut\n-00026660: 6865 6e74 6963 6174 696f 6e45 7272 6f72 henticationError\n-00026670: 2061 7320 6578 633a 0a20 2020 2020 2020 as exc:. \n-00026680: 2020 2020 206c 6f67 6765 722e 6465 6275 logger.debu\n-00026690: 6728 2761 7574 6865 6e74 6963 6174 696f g('authenticatio\n-000266a0: 6e20 746f 2068 6f73 7420 2573 2066 6169 n to host %s fai\n-000266b0: 6c65 643a 2025 7327 2c20 686f 7374 2c20 led: %s', host, \n-000266c0: 6578 6329 0a0a 2020 2020 2020 2020 2020 exc).. \n-000266d0: 2020 7265 7375 6c74 7320 3d20 6469 6374 results = dict\n-000266e0: 2e66 726f 6d6b 6579 7328 6578 632e 6d65 .fromkeys(exc.me\n-000266f0: 7468 6f64 732c 2022 6e6f 742d 7072 6f76 thods, \"not-prov\n-00026700: 6964 6564 2229 0a20 2020 2020 2020 2020 ided\"). \n-00026710: 2020 2069 6620 2770 6173 7377 6f72 6427 if 'password'\n-00026720: 2069 6e20 7265 7375 6c74 7320 616e 6420 in results and \n-00026730: 7365 6c66 2e70 6173 7377 6f72 6420 6973 self.password is\n-00026740: 206e 6f74 204e 6f6e 653a 0a20 2020 2020 not None:. \n-00026750: 2020 2020 2020 2020 2020 2069 6620 7265 if re\n-00026760: 7370 6f6e 6465 722e 7061 7373 776f 7264 sponder.password\n-00026770: 5f61 7474 656d 7074 7320 3d3d 2030 3a0a _attempts == 0:.\n-00026780: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00026790: 2020 2020 7265 7375 6c74 735b 2770 6173 results['pas\n-000267a0: 7377 6f72 6427 5d20 3d20 276e 6f74 2d74 sword'] = 'not-t\n-000267b0: 7269 6564 270a 2020 2020 2020 2020 2020 ried'. \n-000267c0: 2020 2020 2020 656c 7365 3a0a 2020 2020 else:. \n-000267d0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000267e0: 7265 7375 6c74 735b 2770 6173 7377 6f72 results['passwor\n-000267f0: 6427 5d20 3d20 2764 656e 6965 6427 0a0a d'] = 'denied'..\n-00026800: 2020 2020 2020 2020 2020 2020 7261 6973 rais\n-00026810: 6520 5065 6572 4572 726f 7228 2761 7574 e PeerError('aut\n-00026820: 6865 6e74 6963 6174 696f 6e2d 6661 696c hentication-fail\n-00026830: 6564 272c 0a20 2020 2020 2020 2020 2020 ed',. \n-00026840: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00026850: 2065 7272 6f72 3d72 6573 706f 6e64 6572 error=responder\n-00026860: 2e65 7272 6f72 5f6d 6573 7361 6765 206f .error_message o\n-00026870: 7220 2761 7574 6865 6e74 6963 6174 696f r 'authenticatio\n-00026880: 6e2d 6661 696c 6564 272c 0a20 2020 2020 n-failed',. \n-00026890: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000268a0: 2020 2020 2020 2061 7574 685f 6d65 7468 auth_meth\n-000268b0: 6f64 5f72 6573 756c 7473 3d72 6573 756c od_results=resul\n-000268c0: 7473 2920 6672 6f6d 2065 7863 0a0a 2020 ts) from exc.. \n-000268d0: 2020 2020 2020 6578 6365 7074 2066 6572 except fer\n-000268e0: 6e79 2e53 7368 4572 726f 7220 6173 2065 ny.SshError as e\n-000268f0: 7863 3a0a 2020 2020 2020 2020 2020 2020 xc:. \n-00026900: 6c6f 6767 6572 2e64 6562 7567 2827 756e logger.debug('un\n-00026910: 6b6e 6f77 6e20 6661 696c 7572 6520 636f known failure co\n-00026920: 6e6e 6563 7469 6e67 2074 6f20 686f 7374 nnecting to host\n-00026930: 2025 733a 2025 7327 2c20 686f 7374 2c20 %s: %s', host, \n-00026940: 6578 6329 0a20 2020 2020 2020 2020 2020 exc). \n-00026950: 2072 6169 7365 2050 6565 7245 7272 6f72 raise PeerError\n-00026960: 2827 696e 7465 726e 616c 2d65 7272 6f72 ('internal-error\n-00026970: 272c 206d 6573 7361 6765 3d73 7472 2865 ', message=str(e\n-00026980: 7863 2929 2066 726f 6d20 6578 630a 0a20 xc)) from exc.. \n-00026990: 2020 2020 2020 2061 7267 7320 3d20 7365 args = se\n-000269a0: 6c66 2e73 6573 7369 6f6e 2e77 7261 705f lf.session.wrap_\n-000269b0: 7375 6270 726f 6365 7373 5f61 7267 7328 subprocess_args(\n-000269c0: 5b27 636f 636b 7069 742d 6272 6964 6765 ['cockpit-bridge\n-000269d0: 275d 290a 2020 2020 2020 2020 6177 6169 ']). awai\n-000269e0: 7420 7365 6c66 2e73 7061 776e 2861 7267 t self.spawn(arg\n-000269f0: 732c 205b 5d29 0a0a 2020 2020 6465 6620 s, []).. def \n-00026a00: 646f 5f6b 696c 6c28 7365 6c66 2c20 686f do_kill(self, ho\n-00026a10: 7374 3a20 2773 7472 207c 204e 6f6e 6527 st: 'str | None'\n-00026a20: 2c20 6772 6f75 703a 2027 7374 7220 7c20 , group: 'str | \n-00026a30: 4e6f 6e65 272c 206d 6573 7361 6765 3a20 None', message: \n-00026a40: 4a73 6f6e 4f62 6a65 6374 2920 2d3e 204e JsonObject) -> N\n-00026a50: 6f6e 653a 0a20 2020 2020 2020 2069 6620 one:. if \n-00026a60: 686f 7374 203d 3d20 7365 6c66 2e68 6f73 host == self.hos\n-00026a70: 743a 0a20 2020 2020 2020 2020 2020 2073 t:. s\n-00026a80: 656c 662e 636c 6f73 6528 290a 2020 2020 elf.close(). \n-00026a90: 2020 2020 656c 6966 2068 6f73 7420 6973 elif host is\n-00026aa0: 204e 6f6e 653a 0a20 2020 2020 2020 2020 None:. \n-00026ab0: 2020 2073 7570 6572 2829 2e64 6f5f 6b69 super().do_ki\n-00026ac0: 6c6c 2868 6f73 742c 2067 726f 7570 2c20 ll(host, group, \n-00026ad0: 6d65 7373 6167 6529 0a0a 2020 2020 6465 message).. de\n-00026ae0: 6620 646f 5f61 7574 686f 7269 7a65 2873 f do_authorize(s\n-00026af0: 656c 662c 206d 6573 7361 6765 3a20 4a73 elf, message: Js\n-00026b00: 6f6e 4f62 6a65 6374 2920 2d3e 204e 6f6e onObject) -> Non\n-00026b10: 653a 0a20 2020 2020 2020 2069 6620 6765 e:. if ge\n-00026b20: 745f 7374 7228 6d65 7373 6167 652c 2027 t_str(message, '\n-00026b30: 6368 616c 6c65 6e67 6527 292e 7374 6172 challenge').star\n-00026b40: 7473 7769 7468 2827 706c 6169 6e31 3a27 tswith('plain1:'\n-00026b50: 293a 0a20 2020 2020 2020 2020 2020 2063 ):. c\n-00026b60: 6f6f 6b69 6520 3d20 6765 745f 7374 7228 ookie = get_str(\n-00026b70: 6d65 7373 6167 652c 2027 636f 6f6b 6965 message, 'cookie\n-00026b80: 2729 0a20 2020 2020 2020 2020 2020 2073 '). s\n-00026b90: 656c 662e 7772 6974 655f 636f 6e74 726f elf.write_contro\n-00026ba0: 6c28 636f 6d6d 616e 643d 2761 7574 686f l(command='autho\n-00026bb0: 7269 7a65 272c 2063 6f6f 6b69 653d 636f rize', cookie=co\n-00026bc0: 6f6b 6965 2c20 7265 7370 6f6e 7365 3d73 okie, response=s\n-00026bd0: 656c 662e 7061 7373 776f 7264 206f 7220 elf.password or \n-00026be0: 2727 290a 2020 2020 2020 2020 2020 2020 ''). \n-00026bf0: 7365 6c66 2e70 6173 7377 6f72 6420 3d20 self.password = \n-00026c00: 4e6f 6e65 2020 2320 6f6e 6365 2069 7320 None # once is \n-00026c10: 656e 6f75 6768 2e2e 2e0a 0a20 2020 2064 enough..... d\n-00026c20: 6566 2064 6f5f 7375 7065 7275 7365 725f ef do_superuser_\n-00026c30: 696e 6974 5f64 6f6e 6528 7365 6c66 2920 init_done(self) \n-00026c40: 2d3e 204e 6f6e 653a 0a20 2020 2020 2020 -> None:. \n-00026c50: 2073 656c 662e 7061 7373 776f 7264 203d self.password =\n-00026c60: 204e 6f6e 650a 0a20 2020 2064 6566 205f None.. def _\n-00026c70: 5f69 6e69 745f 5f28 7365 6c66 2c20 726f _init__(self, ro\n-00026c80: 7574 6572 3a20 526f 7574 6572 2c20 686f uter: Router, ho\n-00026c90: 7374 3a20 7374 722c 2075 7365 723a 204f st: str, user: O\n-00026ca0: 7074 696f 6e61 6c5b 7374 725d 2c20 6f70 ptional[str], op\n-00026cb0: 7469 6f6e 733a 204a 736f 6e4f 626a 6563 tions: JsonObjec\n-00026cc0: 742c 202a 2c20 7072 6976 6174 653a 2062 t, *, private: b\n-00026cd0: 6f6f 6c29 202d 3e20 4e6f 6e65 3a0a 2020 ool) -> None:. \n-00026ce0: 2020 2020 2020 7375 7065 7228 292e 5f5f super().__\n-00026cf0: 696e 6974 5f5f 2872 6f75 7465 7229 0a20 init__(router). \n-00026d00: 2020 2020 2020 2073 656c 662e 686f 7374 self.host\n-00026d10: 203d 2068 6f73 740a 2020 2020 2020 2020 = host. \n-00026d20: 7365 6c66 2e75 7365 7220 3d20 7573 6572 self.user = user\n-00026d30: 0a20 2020 2020 2020 2073 656c 662e 7061 . self.pa\n-00026d40: 7373 776f 7264 203d 2067 6574 5f73 7472 ssword = get_str\n-00026d50: 286f 7074 696f 6e73 2c20 2770 6173 7377 (options, 'passw\n-00026d60: 6f72 6427 2c20 4e6f 6e65 290a 2020 2020 ord', None). \n-00026d70: 2020 2020 7365 6c66 2e70 7269 7661 7465 self.private\n-00026d80: 203d 2070 7269 7661 7465 0a0a 2020 2020 = private.. \n-00026d90: 2020 2020 7365 6c66 2e73 6573 7369 6f6e self.session\n-00026da0: 203d 2066 6572 6e79 2e53 6573 7369 6f6e = ferny.Session\n-00026db0: 2829 0a0a 2020 2020 2020 2020 7375 7065 ().. supe\n-00026dc0: 7275 7365 723a 204a 736f 6e56 616c 7565 ruser: JsonValue\n-00026dd0: 0a20 2020 2020 2020 2069 6e69 745f 7375 . init_su\n-00026de0: 7065 7275 7365 7220 3d20 6765 745f 7374 peruser = get_st\n-00026df0: 725f 6f72 5f6e 6f6e 6528 6f70 7469 6f6e r_or_none(option\n-00026e00: 732c 2027 696e 6974 2d73 7570 6572 7573 s, 'init-superus\n-00026e10: 6572 272c 204e 6f6e 6529 0a20 2020 2020 er', None). \n-00026e20: 2020 2069 6620 696e 6974 5f73 7570 6572 if init_super\n-00026e30: 7573 6572 2069 6e20 284e 6f6e 652c 2027 user in (None, '\n-00026e40: 6e6f 6e65 2729 3a0a 2020 2020 2020 2020 none'):. \n-00026e50: 2020 2020 7375 7065 7275 7365 7220 3d20 superuser = \n-00026e60: 4661 6c73 650a 2020 2020 2020 2020 656c False. el\n-00026e70: 7365 3a0a 2020 2020 2020 2020 2020 2020 se:. \n-00026e80: 7375 7065 7275 7365 7220 3d20 7b27 6964 superuser = {'id\n-00026e90: 273a 2069 6e69 745f 7375 7065 7275 7365 ': init_superuse\n-00026ea0: 727d 0a0a 2020 2020 2020 2020 7365 6c66 r}.. self\n-00026eb0: 2e73 7461 7274 5f69 6e5f 6261 636b 6772 .start_in_backgr\n-00026ec0: 6f75 6e64 2869 6e69 745f 686f 7374 3d68 ound(init_host=h\n-00026ed0: 6f73 742c 2073 7570 6572 7573 6572 3d73 ost, superuser=s\n-00026ee0: 7570 6572 7573 6572 290a 0a0a 636c 6173 uperuser)...clas\n-00026ef0: 7320 486f 7374 526f 7574 696e 6752 756c s HostRoutingRul\n-00026f00: 6528 526f 7574 696e 6752 756c 6529 3a0a e(RoutingRule):.\n-00026f10: 2020 2020 7265 6d6f 7465 733a 2044 6963 remotes: Dic\n-00026f20: 745b 5475 706c 655b 7374 722c 204f 7074 t[Tuple[str, Opt\n-00026f30: 696f 6e61 6c5b 7374 725d 2c20 4f70 7469 ional[str], Opti\n-00026f40: 6f6e 616c 5b73 7472 5d5d 2c20 5065 6572 onal[str]], Peer\n-00026f50: 5d0a 0a20 2020 2064 6566 205f 5f69 6e69 ].. def __ini\n-00026f60: 745f 5f28 7365 6c66 2c20 726f 7574 6572 t__(self, router\n-00026f70: 293a 0a20 2020 2020 2020 2073 7570 6572 ):. super\n-00026f80: 2829 2e5f 5f69 6e69 745f 5f28 726f 7574 ().__init__(rout\n-00026f90: 6572 290a 2020 2020 2020 2020 7365 6c66 er). self\n-00026fa0: 2e72 656d 6f74 6573 203d 207b 7d0a 0a20 .remotes = {}.. \n-00026fb0: 2020 2064 6566 2061 7070 6c79 5f72 756c def apply_rul\n-00026fc0: 6528 7365 6c66 2c20 6f70 7469 6f6e 733a e(self, options:\n-00026fd0: 204a 736f 6e4f 626a 6563 7429 202d 3e20 JsonObject) -> \n-00026fe0: 4f70 7469 6f6e 616c 5b50 6565 725d 3a0a Optional[Peer]:.\n-00026ff0: 2020 2020 2020 2020 6173 7365 7274 2073 assert s\n-00027000: 656c 662e 726f 7574 6572 2069 7320 6e6f elf.router is no\n-00027010: 7420 4e6f 6e65 0a20 2020 2020 2020 2061 t None. a\n-00027020: 7373 6572 7420 7365 6c66 2e72 6f75 7465 ssert self.route\n-00027030: 722e 696e 6974 5f68 6f73 7420 6973 206e r.init_host is n\n-00027040: 6f74 204e 6f6e 650a 0a20 2020 2020 2020 ot None.. \n-00027050: 2068 6f73 7420 3d20 6765 745f 7374 7228 host = get_str(\n-00027060: 6f70 7469 6f6e 732c 2027 686f 7374 272c options, 'host',\n-00027070: 2073 656c 662e 726f 7574 6572 2e69 6e69 self.router.ini\n-00027080: 745f 686f 7374 290a 2020 2020 2020 2020 t_host). \n-00027090: 6966 2068 6f73 7420 3d3d 2073 656c 662e if host == self.\n-000270a0: 726f 7574 6572 2e69 6e69 745f 686f 7374 router.init_host\n-000270b0: 3a0a 2020 2020 2020 2020 2020 2020 7265 :. re\n-000270c0: 7475 726e 204e 6f6e 650a 0a20 2020 2020 turn None.. \n-000270d0: 2020 2075 7365 7220 3d20 6765 745f 7374 user = get_st\n-000270e0: 7228 6f70 7469 6f6e 732c 2027 7573 6572 r(options, 'user\n-000270f0: 272c 204e 6f6e 6529 0a20 2020 2020 2020 ', None). \n-00027100: 2023 2048 4143 4b3a 2074 6865 2066 726f # HACK: the fro\n-00027110: 6e74 2d65 6e64 2072 656c 6965 7320 6f6e nt-end relies on\n-00027120: 2074 6869 7320 666f 7220 7472 6163 6b69 this for tracki\n-00027130: 6e67 2063 6f6e 6e65 6374 696f 6e73 2077 ng connections w\n-00027140: 6974 686f 7574 2061 6e20 6578 706c 6963 ithout an explic\n-00027150: 6974 2075 7365 7220 6e61 6d65 3b0a 2020 it user name;. \n-00027160: 2020 2020 2020 2320 7468 6520 7573 6572 # the user\n-00027170: 2077 696c 6c20 7468 656e 2062 6520 6465 will then be de\n-00027180: 7465 726d 696e 6564 2062 7920 5353 4820 termined by SSH \n-00027190: 2860 5573 6572 6020 696e 2074 6865 2063 (`User` in the c\n-000271a0: 6f6e 6669 6720 6f72 2074 6865 2063 7572 onfig or the cur\n-000271b0: 7265 6e74 2075 7365 7229 0a20 2020 2020 rent user). \n-000271c0: 2020 2023 2053 6565 2063 6f63 6b70 6974 # See cockpit\n-000271d0: 5f72 6f75 7465 725f 6e6f 726d 616c 697a _router_normaliz\n-000271e0: 655f 686f 7374 5f70 6172 616d 7328 2920 e_host_params() \n-000271f0: 696e 2073 7263 2f62 7269 6467 652f 636f in src/bridge/co\n-00027200: 636b 7069 7472 6f75 7465 722e 630a 2020 ckpitrouter.c. \n-00027210: 2020 2020 2020 6966 2075 7365 7220 3d3d if user ==\n-00027220: 2067 6574 7061 7373 2e67 6574 7573 6572 getpass.getuser\n-00027230: 2829 3a0a 2020 2020 2020 2020 2020 2020 ():. \n-00027240: 7573 6572 203d 204e 6f6e 650a 2020 2020 user = None. \n-00027250: 2020 2020 6966 206e 6f74 2075 7365 723a if not user:\n-00027260: 0a20 2020 2020 2020 2020 2020 2075 7365 . use\n-00027270: 725f 6672 6f6d 5f68 6f73 742c 205f 2c20 r_from_host, _, \n-00027280: 5f20 3d20 686f 7374 2e72 7061 7274 6974 _ = host.rpartit\n-00027290: 696f 6e28 2740 2729 0a20 2020 2020 2020 ion('@'). \n-000272a0: 2020 2020 2075 7365 7220 3d20 7573 6572 user = user\n-000272b0: 5f66 726f 6d5f 686f 7374 206f 7220 4e6f _from_host or No\n-000272c0: 6e65 2020 2320 6176 6f69 6420 2727 0a0a ne # avoid ''..\n-000272d0: 2020 2020 2020 2020 6966 2067 6574 5f73 if get_s\n-000272e0: 7472 286f 7074 696f 6e73 2c20 2773 6573 tr(options, 'ses\n-000272f0: 7369 6f6e 272c 204e 6f6e 6529 203d 3d20 sion', None) == \n-00027300: 2770 7269 7661 7465 273a 0a20 2020 2020 'private':. \n-00027310: 2020 2020 2020 206e 6f6e 6365 203d 2067 nonce = g\n-00027320: 6574 5f73 7472 286f 7074 696f 6e73 2c20 et_str(options, \n-00027330: 2763 6861 6e6e 656c 2729 0a20 2020 2020 'channel'). \n-00027340: 2020 2065 6c73 653a 0a20 2020 2020 2020 else:. \n-00027350: 2020 2020 206e 6f6e 6365 203d 204e 6f6e nonce = Non\n-00027360: 650a 0a20 2020 2020 2020 2061 7373 6572 e.. asser\n-00027370: 7420 6973 696e 7374 616e 6365 2868 6f73 t isinstance(hos\n-00027380: 742c 2073 7472 290a 2020 2020 2020 2020 t, str). \n-00027390: 6173 7365 7274 2075 7365 7220 6973 204e assert user is N\n-000273a0: 6f6e 6520 6f72 2069 7369 6e73 7461 6e63 one or isinstanc\n-000273b0: 6528 7573 6572 2c20 7374 7229 0a20 2020 e(user, str). \n-000273c0: 2020 2020 2061 7373 6572 7420 6e6f 6e63 assert nonc\n-000273d0: 6520 6973 204e 6f6e 6520 6f72 2069 7369 e is None or isi\n-000273e0: 6e73 7461 6e63 6528 6e6f 6e63 652c 2073 nstance(nonce, s\n-000273f0: 7472 290a 0a20 2020 2020 2020 206b 6579 tr).. key\n-00027400: 203d 2068 6f73 742c 2075 7365 722c 206e = host, user, n\n-00027410: 6f6e 6365 0a0a 2020 2020 2020 2020 6c6f once.. lo\n-00027420: 6767 6572 2e64 6562 7567 2827 5265 7175 gger.debug('Requ\n-00027430: 6573 7420 666f 7220 6368 616e 6e65 6c20 est for channel \n-00027440: 2573 2069 7320 7265 6d6f 7465 2e27 2c20 %s is remote.', \n-00027450: 6f70 7469 6f6e 7329 0a20 2020 2020 2020 options). \n-00027460: 206c 6f67 6765 722e 6465 6275 6728 276b logger.debug('k\n-00027470: 6579 3d25 7327 2c20 6b65 7929 0a0a 2020 ey=%s', key).. \n-00027480: 2020 2020 2020 6966 206b 6579 206e 6f74 if key not\n-00027490: 2069 6e20 7365 6c66 2e72 656d 6f74 6573 in self.remotes\n-000274a0: 3a0a 2020 2020 2020 2020 2020 2020 6c6f :. lo\n-000274b0: 6767 6572 2e64 6562 7567 2827 2573 2069 gger.debug('%s i\n-000274c0: 7320 6e6f 7420 616d 6f6e 6720 7468 6520 s not among the \n-000274d0: 6578 6973 7469 6e67 2072 656d 6f74 6573 existing remotes\n-000274e0: 2025 732e 2020 4f70 656e 696e 6720 6120 %s. Opening a \n-000274f0: 6e65 7720 636f 6e6e 6563 7469 6f6e 2e27 new connection.'\n-00027500: 2c20 6b65 792c 2073 656c 662e 7265 6d6f , key, self.remo\n-00027510: 7465 7329 0a20 2020 2020 2020 2020 2020 tes). \n-00027520: 2070 6565 7220 3d20 5373 6850 6565 7228 peer = SshPeer(\n-00027530: 7365 6c66 2e72 6f75 7465 722c 2068 6f73 self.router, hos\n-00027540: 742c 2075 7365 722c 206f 7074 696f 6e73 t, user, options\n-00027550: 2c20 7072 6976 6174 653d 6e6f 6e63 6520 , private=nonce \n-00027560: 6973 206e 6f74 204e 6f6e 6529 0a20 2020 is not None). \n-00027570: 2020 2020 2020 2020 2070 6565 722e 6164 peer.ad\n-00027580: 645f 646f 6e65 5f63 616c 6c62 6163 6b28 d_done_callback(\n-00027590: 6c61 6d62 6461 3a20 7365 6c66 2e72 656d lambda: self.rem\n-000275a0: 6f74 6573 2e5f 5f64 656c 6974 656d 5f5f otes.__delitem__\n-000275b0: 286b 6579 2929 0a20 2020 2020 2020 2020 (key)). \n-000275c0: 2020 2073 656c 662e 7265 6d6f 7465 735b self.remotes[\n-000275d0: 6b65 795d 203d 2070 6565 720a 0a20 2020 key] = peer.. \n-000275e0: 2020 2020 2072 6574 7572 6e20 7365 6c66 return self\n-000275f0: 2e72 656d 6f74 6573 5b6b 6579 5d0a 0a20 .remotes[key].. \n-00027600: 2020 2064 6566 2073 6875 7464 6f77 6e28 def shutdown(\n-00027610: 7365 6c66 293a 0a20 2020 2020 2020 2066 self):. f\n-00027620: 6f72 2070 6565 7220 696e 2073 6574 2873 or peer in set(s\n-00027630: 656c 662e 7265 6d6f 7465 732e 7661 6c75 elf.remotes.valu\n-00027640: 6573 2829 293a 0a20 2020 2020 2020 2020 es()):. \n-00027650: 2020 2070 6565 722e 636c 6f73 6528 290a peer.close().\n-00027660: 2727 272e 656e 636f 6465 2827 7574 662d '''.encode('utf-\n-00027670: 3827 292c 0a20 2027 636f 636b 7069 742f 8'),. 'cockpit/\n-00027680: 7472 616e 7370 6f72 7473 2e70 7927 3a20 transports.py': \n-00027690: 6272 2727 2723 2054 6869 7320 6669 6c65 br'''# This file\n-000276a0: 2069 7320 7061 7274 206f 6620 436f 636b is part of Cock\n-000276b0: 7069 742e 0a23 0a23 2043 6f70 7972 6967 pit..#.# Copyrig\n-000276c0: 6874 2028 4329 2032 3032 3220 5265 6420 ht (C) 2022 Red \n-000276d0: 4861 742c 2049 6e63 2e0a 230a 2320 5468 Hat, Inc..#.# Th\n-000276e0: 6973 2070 726f 6772 616d 2069 7320 6672 is program is fr\n-000276f0: 6565 2073 6f66 7477 6172 653a 2079 6f75 ee software: you\n-00027700: 2063 616e 2072 6564 6973 7472 6962 7574 can redistribut\n-00027710: 6520 6974 2061 6e64 2f6f 7220 6d6f 6469 e it and/or modi\n-00027720: 6679 0a23 2069 7420 756e 6465 7220 7468 fy.# it under th\n-00027730: 6520 7465 726d 7320 6f66 2074 6865 2047 e terms of the G\n-00027740: 4e55 2047 656e 6572 616c 2050 7562 6c69 NU General Publi\n-00027750: 6320 4c69 6365 6e73 6520 6173 2070 7562 c License as pub\n-00027760: 6c69 7368 6564 2062 790a 2320 7468 6520 lished by.# the \n-00027770: 4672 6565 2053 6f66 7477 6172 6520 466f Free Software Fo\n-00027780: 756e 6461 7469 6f6e 2c20 6569 7468 6572 undation, either\n-00027790: 2076 6572 7369 6f6e 2033 206f 6620 7468 version 3 of th\n-000277a0: 6520 4c69 6365 6e73 652c 206f 720a 2320 e License, or.# \n-000277b0: 2861 7420 796f 7572 206f 7074 696f 6e29 (at your option)\n-000277c0: 2061 6e79 206c 6174 6572 2076 6572 7369 any later versi\n-000277d0: 6f6e 2e0a 230a 2320 5468 6973 2070 726f on..#.# This pro\n-000277e0: 6772 616d 2069 7320 6469 7374 7269 6275 gram is distribu\n-000277f0: 7465 6420 696e 2074 6865 2068 6f70 6520 ted in the hope \n-00027800: 7468 6174 2069 7420 7769 6c6c 2062 6520 that it will be \n-00027810: 7573 6566 756c 2c0a 2320 6275 7420 5749 useful,.# but WI\n-00027820: 5448 4f55 5420 414e 5920 5741 5252 414e THOUT ANY WARRAN\n-00027830: 5459 3b20 7769 7468 6f75 7420 6576 656e TY; without even\n-00027840: 2074 6865 2069 6d70 6c69 6564 2077 6172 the implied war\n-00027850: 7261 6e74 7920 6f66 0a23 204d 4552 4348 ranty of.# MERCH\n-00027860: 414e 5441 4249 4c49 5459 206f 7220 4649 ANTABILITY or FI\n-00027870: 544e 4553 5320 464f 5220 4120 5041 5254 TNESS FOR A PART\n-00027880: 4943 554c 4152 2050 5552 504f 5345 2e20 ICULAR PURPOSE. \n-00027890: 2053 6565 2074 6865 0a23 2047 4e55 2047 See the.# GNU G\n-000278a0: 656e 6572 616c 2050 7562 6c69 6320 4c69 eneral Public Li\n-000278b0: 6365 6e73 6520 666f 7220 6d6f 7265 2064 cense for more d\n-000278c0: 6574 6169 6c73 2e0a 230a 2320 596f 7520 etails..#.# You \n-000278d0: 7368 6f75 6c64 2068 6176 6520 7265 6365 should have rece\n-000278e0: 6976 6564 2061 2063 6f70 7920 6f66 2074 ived a copy of t\n-000278f0: 6865 2047 4e55 2047 656e 6572 616c 2050 he GNU General P\n-00027900: 7562 6c69 6320 4c69 6365 6e73 650a 2320 ublic License.# \n-00027910: 616c 6f6e 6720 7769 7468 2074 6869 7320 along with this \n-00027920: 7072 6f67 7261 6d2e 2020 4966 206e 6f74 program. If not\n-00027930: 2c20 7365 6520 3c68 7474 7073 3a2f 2f77 , see ...\"\"\"Bi-di\n-00027960: 7265 6374 696f 6e61 6c20 6173 796e 6369 rectional asynci\n-00027970: 6f2e 5472 616e 7370 6f72 7420 696d 706c o.Transport impl\n-00027980: 656d 656e 7461 7469 6f6e 7320 6261 7365 ementations base\n-00027990: 6420 6f6e 2066 696c 6520 6465 7363 7269 d on file descri\n-000279a0: 7074 6f72 732e 2222 220a 0a69 6d70 6f72 ptors.\"\"\"..impor\n-000279b0: 7420 6173 796e 6369 6f0a 696d 706f 7274 t asyncio.import\n-000279c0: 2063 6f6c 6c65 6374 696f 6e73 0a69 6d70 collections.imp\n-000279d0: 6f72 7420 6374 7970 6573 0a69 6d70 6f72 ort ctypes.impor\n-000279e0: 7420 6572 726e 6f0a 696d 706f 7274 2066 t errno.import f\n-000279f0: 636e 746c 0a69 6d70 6f72 7420 6c6f 6767 cntl.import logg\n-00027a00: 696e 670a 696d 706f 7274 206f 730a 696d ing.import os.im\n-00027a10: 706f 7274 2073 656c 6563 740a 696d 706f port select.impo\n-00027a20: 7274 2073 6967 6e61 6c0a 696d 706f 7274 rt signal.import\n-00027a30: 2073 7472 7563 740a 696d 706f 7274 2073 struct.import s\n-00027a40: 7562 7072 6f63 6573 730a 696d 706f 7274 ubprocess.import\n-00027a50: 2074 6572 6d69 6f73 0a66 726f 6d20 7479 termios.from ty\n-00027a60: 7069 6e67 2069 6d70 6f72 7420 416e 792c ping import Any,\n-00027a70: 2043 6c61 7373 5661 722c 2053 6571 7565 ClassVar, Seque\n-00027a80: 6e63 650a 0a66 726f 6d20 2e6a 736f 6e75 nce..from .jsonu\n-00027a90: 7469 6c20 696d 706f 7274 204a 736f 6e4f til import JsonO\n-00027aa0: 626a 6563 742c 2067 6574 5f69 6e74 0a0a bject, get_int..\n-00027ab0: 6c69 6263 3620 3d20 6374 7970 6573 2e63 libc6 = ctypes.c\n-00027ac0: 646c 6c2e 4c6f 6164 4c69 6272 6172 7928 dll.LoadLibrary(\n-00027ad0: 276c 6962 632e 736f 2e36 2729 0a0a 0a64 'libc.so.6')...d\n-00027ae0: 6566 2070 7263 746c 282a 6172 6773 3a20 ef prctl(*args: \n-00027af0: 696e 7429 202d 3e20 4e6f 6e65 3a0a 2020 int) -> None:. \n-00027b00: 2020 6966 206c 6962 6336 2e70 7263 746c if libc6.prctl\n-00027b10: 282a 6172 6773 2920 213d 2030 3a0a 2020 (*args) != 0:. \n-00027b20: 2020 2020 2020 7261 6973 6520 4f53 4572 raise OSEr\n-00027b30: 726f 7228 2770 7263 746c 2829 2066 6169 ror('prctl() fai\n-00027b40: 6c65 6427 290a 0a0a 5345 545f 5044 4541 led')...SET_PDEA\n-00027b50: 5448 5349 4720 3d20 310a 0a0a 6c6f 6767 THSIG = 1...logg\n-00027b60: 6572 203d 206c 6f67 6769 6e67 2e67 6574 er = logging.get\n-00027b70: 4c6f 6767 6572 285f 5f6e 616d 655f 5f29 Logger(__name__)\n-00027b80: 0a49 4f56 5f4d 4158 203d 2031 3032 3420 .IOV_MAX = 1024 \n-00027b90: 2023 206d 616e 2032 2077 7269 7465 760a # man 2 writev.\n-00027ba0: 0a0a 636c 6173 7320 5f54 7261 6e73 706f ..class _Transpo\n-00027bb0: 7274 2861 7379 6e63 696f 2e54 7261 6e73 rt(asyncio.Trans\n-00027bc0: 706f 7274 293a 0a20 2020 2042 4c4f 434b port):. BLOCK\n-00027bd0: 5f53 495a 453a 2043 6c61 7373 5661 725b _SIZE: ClassVar[\n-00027be0: 696e 745d 203d 2031 3032 3420 2a20 3130 int] = 1024 * 10\n-00027bf0: 3234 0a0a 2020 2020 2320 4120 7472 616e 24.. # A tran\n-00027c00: 7370 6f72 7420 616c 7761 7973 2068 6173 sport always has\n-00027c10: 2061 206c 6f6f 7020 616e 6420 6120 7072 a loop and a pr\n-00027c20: 6f74 6f63 6f6c 0a20 2020 205f 6c6f 6f70 otocol. _loop\n-00027c30: 3a20 6173 796e 6369 6f2e 4162 7374 7261 : asyncio.Abstra\n-00027c40: 6374 4576 656e 744c 6f6f 700a 2020 2020 ctEventLoop. \n-00027c50: 5f70 726f 746f 636f 6c3a 2061 7379 6e63 _protocol: async\n-00027c60: 696f 2e50 726f 746f 636f 6c0a 0a20 2020 io.Protocol.. \n-00027c70: 205f 7175 6575 653a 2027 636f 6c6c 6563 _queue: 'collec\n-00027c80: 7469 6f6e 732e 6465 7175 655b 6279 7465 tions.deque[byte\n-00027c90: 735d 207c 204e 6f6e 6527 0a20 2020 205f s] | None'. _\n-00027ca0: 696e 5f66 643a 2069 6e74 0a20 2020 205f in_fd: int. _\n-00027cb0: 6f75 745f 6664 3a20 696e 740a 2020 2020 out_fd: int. \n-00027cc0: 5f63 6c6f 7369 6e67 3a20 626f 6f6c 0a20 _closing: bool. \n-00027cd0: 2020 205f 6973 5f72 6561 6469 6e67 3a20 _is_reading: \n-00027ce0: 626f 6f6c 0a20 2020 205f 656f 663a 2062 bool. _eof: b\n-00027cf0: 6f6f 6c0a 2020 2020 5f65 696f 5f69 735f ool. _eio_is_\n-00027d00: 656f 663a 2062 6f6f 6c20 3d20 4661 6c73 eof: bool = Fals\n-00027d10: 650a 0a20 2020 2064 6566 205f 5f69 6e69 e.. def __ini\n-00027d20: 745f 5f28 7365 6c66 2c0a 2020 2020 2020 t__(self,. \n-00027d30: 2020 2020 2020 2020 2020 206c 6f6f 703a loop:\n-00027d40: 2061 7379 6e63 696f 2e41 6273 7472 6163 asyncio.Abstrac\n-00027d50: 7445 7665 6e74 4c6f 6f70 2c0a 2020 2020 tEventLoop,. \n-00027d60: 2020 2020 2020 2020 2020 2020 2070 726f pro\n-00027d70: 746f 636f 6c3a 2061 7379 6e63 696f 2e50 tocol: asyncio.P\n-00027d80: 726f 746f 636f 6c2c 0a20 2020 2020 2020 rotocol,. \n-00027d90: 2020 2020 2020 2020 2020 696e 5f66 643a in_fd:\n-00027da0: 2069 6e74 203d 202d 312c 206f 7574 5f66 int = -1, out_f\n-00027db0: 643a 2069 6e74 203d 202d 312c 0a20 2020 d: int = -1,. \n-00027dc0: 2020 2020 2020 2020 2020 2020 2020 6578 ex\n-00027dd0: 7472 613a 2027 6469 6374 5b73 7472 2c20 tra: 'dict[str, \n-00027de0: 6f62 6a65 6374 5d20 7c20 4e6f 6e65 2720 object] | None' \n-00027df0: 3d20 4e6f 6e65 293a 0a20 2020 2020 2020 = None):. \n-00027e00: 2073 7570 6572 2829 2e5f 5f69 6e69 745f super().__init_\n-00027e10: 5f28 6578 7472 6129 0a0a 2020 2020 2020 _(extra).. \n-00027e20: 2020 7365 6c66 2e5f 6c6f 6f70 203d 206c self._loop = l\n-00027e30: 6f6f 700a 2020 2020 2020 2020 7365 6c66 oop. self\n-00027e40: 2e5f 7072 6f74 6f63 6f6c 203d 2070 726f ._protocol = pro\n-00027e50: 746f 636f 6c0a 0a20 2020 2020 2020 206c tocol.. l\n-00027e60: 6f67 6765 722e 6465 6275 6728 2743 7265 ogger.debug('Cre\n-00027e70: 6174 6564 2074 7261 6e73 706f 7274 2025 ated transport %\n-00027e80: 7320 666f 7220 7072 6f74 6f63 6f6c 2025 s for protocol %\n-00027e90: 732c 2066 6473 2025 6420 2564 272c 2073 s, fds %d %d', s\n-00027ea0: 656c 662c 2070 726f 746f 636f 6c2c 2069 elf, protocol, i\n-00027eb0: 6e5f 6664 2c20 6f75 745f 6664 290a 0a20 n_fd, out_fd).. \n-00027ec0: 2020 2020 2020 2073 656c 662e 5f71 7565 self._que\n-00027ed0: 7565 203d 204e 6f6e 650a 2020 2020 2020 ue = None. \n-00027ee0: 2020 7365 6c66 2e5f 6973 5f72 6561 6469 self._is_readi\n-00027ef0: 6e67 203d 2046 616c 7365 0a20 2020 2020 ng = False. \n-00027f00: 2020 2073 656c 662e 5f65 6f66 203d 2046 self._eof = F\n-00027f10: 616c 7365 0a20 2020 2020 2020 2073 656c alse. sel\n-00027f20: 662e 5f63 6c6f 7369 6e67 203d 2046 616c f._closing = Fal\n-00027f30: 7365 0a0a 2020 2020 2020 2020 7365 6c66 se.. self\n-00027f40: 2e5f 696e 5f66 6420 3d20 696e 5f66 640a ._in_fd = in_fd.\n-00027f50: 2020 2020 2020 2020 7365 6c66 2e5f 6f75 self._ou\n-00027f60: 745f 6664 203d 206f 7574 5f66 640a 0a20 t_fd = out_fd.. \n-00027f70: 2020 2020 2020 206f 732e 7365 745f 626c os.set_bl\n-00027f80: 6f63 6b69 6e67 2869 6e5f 6664 2c20 4661 ocking(in_fd, Fa\n-00027f90: 6c73 6529 0a20 2020 2020 2020 2069 6620 lse). if \n-00027fa0: 6f75 745f 6664 2021 3d20 696e 5f66 643a out_fd != in_fd:\n-00027fb0: 0a20 2020 2020 2020 2020 2020 206f 732e . os.\n-00027fc0: 7365 745f 626c 6f63 6b69 6e67 286f 7574 set_blocking(out\n-00027fd0: 5f66 642c 2046 616c 7365 290a 0a20 2020 _fd, False).. \n-00027fe0: 2020 2020 2073 656c 662e 5f70 726f 746f self._proto\n-00027ff0: 636f 6c2e 636f 6e6e 6563 7469 6f6e 5f6d col.connection_m\n-00028000: 6164 6528 7365 6c66 290a 2020 2020 2020 ade(self). \n-00028010: 2020 7365 6c66 2e72 6573 756d 655f 7265 self.resume_re\n-00028020: 6164 696e 6728 290a 0a20 2020 2064 6566 ading().. def\n-00028030: 205f 7265 6164 5f72 6561 6479 2873 656c _read_ready(sel\n-00028040: 6629 202d 3e20 4e6f 6e65 3a0a 2020 2020 f) -> None:. \n-00028050: 2020 2020 6c6f 6767 6572 2e64 6562 7567 logger.debug\n-00028060: 2827 5265 6164 2072 6561 6479 206f 6e20 ('Read ready on \n-00028070: 2573 2025 7320 2564 272c 2073 656c 662c %s %s %d', self,\n-00028080: 2073 656c 662e 5f70 726f 746f 636f 6c2c self._protocol,\n-00028090: 2073 656c 662e 5f69 6e5f 6664 290a 2020 self._in_fd). \n-000280a0: 2020 2020 2020 7472 793a 0a20 2020 2020 try:. \n-000280b0: 2020 2020 2020 2064 6174 6120 3d20 6f73 data = os\n-000280c0: 2e72 6561 6428 7365 6c66 2e5f 696e 5f66 .read(self._in_f\n-000280d0: 642c 205f 5472 616e 7370 6f72 742e 424c d, _Transport.BL\n-000280e0: 4f43 4b5f 5349 5a45 290a 2020 2020 2020 OCK_SIZE). \n-000280f0: 2020 6578 6365 7074 2042 6c6f 636b 696e except Blockin\n-00028100: 6749 4f45 7272 6f72 3a20 2023 2070 7261 gIOError: # pra\n-00028110: 676d 613a 206e 6f20 636f 7665 720a 2020 gma: no cover. \n-00028120: 2020 2020 2020 2020 2020 7265 7475 726e return\n-00028130: 0a20 2020 2020 2020 2065 7863 6570 7420 . except \n-00028140: 4f53 4572 726f 7220 6173 2065 7863 3a0a OSError as exc:.\n-00028150: 2020 2020 2020 2020 2020 2020 6966 2073 if s\n-00028160: 656c 662e 5f65 696f 5f69 735f 656f 6620 elf._eio_is_eof \n-00028170: 616e 6420 6578 632e 6572 726e 6f20 3d3d and exc.errno ==\n-00028180: 2065 7272 6e6f 2e45 494f 3a0a 2020 2020 errno.EIO:. \n-00028190: 2020 2020 2020 2020 2020 2020 2320 5054 # PT\n-000281a0: 5920 6465 7669 6365 7320 7265 7475 726e Y devices return\n-000281b0: 2045 494f 2074 6f20 6d65 616e 2022 454f EIO to mean \"EO\n-000281c0: 4622 0a20 2020 2020 2020 2020 2020 2020 F\". \n-000281d0: 2020 2064 6174 6120 3d20 6227 270a 2020 data = b''. \n-000281e0: 2020 2020 2020 2020 2020 656c 7365 3a0a else:.\n-000281f0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00028200: 2320 4f74 6865 7220 6572 726f 7273 3a20 # Other errors: \n-00028210: 7465 726d 696e 6174 6520 7468 6520 636f terminate the co\n-00028220: 6e6e 6563 7469 6f6e 0a20 2020 2020 2020 nnection. \n-00028230: 2020 2020 2020 2020 2073 656c 662e 6162 self.ab\n-00028240: 6f72 7428 6578 6329 0a20 2020 2020 2020 ort(exc). \n-00028250: 2020 2020 2020 2020 2072 6574 7572 6e0a return.\n-00028260: 0a20 2020 2020 2020 2069 6620 6461 7461 . if data\n-00028270: 2021 3d20 6227 273a 0a20 2020 2020 2020 != b'':. \n-00028280: 2020 2020 206c 6f67 6765 722e 6465 6275 logger.debu\n-00028290: 6728 2720 2072 6561 6420 2564 2062 7974 g(' read %d byt\n-000282a0: 6573 272c 206c 656e 2864 6174 6129 290a es', len(data)).\n-000282b0: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n-000282c0: 2e5f 7072 6f74 6f63 6f6c 2e64 6174 615f ._protocol.data_\n-000282d0: 7265 6365 6976 6564 2864 6174 6129 0a20 received(data). \n-000282e0: 2020 2020 2020 2065 6c73 653a 0a20 2020 else:. \n-000282f0: 2020 2020 2020 2020 206c 6f67 6765 722e logger.\n-00028300: 6465 6275 6728 2720 2067 6f74 2045 4f46 debug(' got EOF\n-00028310: 2729 0a20 2020 2020 2020 2020 2020 2073 '). s\n-00028320: 656c 662e 5f63 6c6f 7365 5f72 6561 6465 elf._close_reade\n-00028330: 7228 290a 2020 2020 2020 2020 2020 2020 r(). \n-00028340: 6b65 6570 5f6f 7065 6e20 3d20 7365 6c66 keep_open = self\n-00028350: 2e5f 7072 6f74 6f63 6f6c 2e65 6f66 5f72 ._protocol.eof_r\n-00028360: 6563 6569 7665 6428 290a 2020 2020 2020 eceived(). \n-00028370: 2020 2020 2020 6966 206e 6f74 206b 6565 if not kee\n-00028380: 705f 6f70 656e 3a0a 2020 2020 2020 2020 p_open:. \n-00028390: 2020 2020 2020 2020 7365 6c66 2e63 6c6f self.clo\n-000283a0: 7365 2829 0a0a 2020 2020 6465 6620 6973 se().. def is\n-000283b0: 5f72 6561 6469 6e67 2873 656c 6629 202d _reading(self) -\n-000283c0: 3e20 626f 6f6c 3a0a 2020 2020 2020 2020 > bool:. \n-000283d0: 7265 7475 726e 2073 656c 662e 5f69 735f return self._is_\n-000283e0: 7265 6164 696e 670a 0a20 2020 2064 6566 reading.. def\n-000283f0: 205f 636c 6f73 655f 7265 6164 6572 2873 _close_reader(s\n-00028400: 656c 6629 202d 3e20 4e6f 6e65 3a0a 2020 elf) -> None:. \n-00028410: 2020 2020 2020 7365 6c66 2e70 6175 7365 self.pause\n-00028420: 5f72 6561 6469 6e67 2829 0a20 2020 2020 _reading(). \n-00028430: 2020 2073 656c 662e 5f69 6e5f 6664 203d self._in_fd =\n-00028440: 202d 310a 0a20 2020 2064 6566 2070 6175 -1.. def pau\n-00028450: 7365 5f72 6561 6469 6e67 2873 656c 6629 se_reading(self)\n-00028460: 202d 3e20 4e6f 6e65 3a0a 2020 2020 2020 -> None:. \n-00028470: 2020 6966 2073 656c 662e 5f69 735f 7265 if self._is_re\n-00028480: 6164 696e 673a 0a20 2020 2020 2020 2020 ading:. \n-00028490: 2020 2073 656c 662e 5f6c 6f6f 702e 7265 self._loop.re\n-000284a0: 6d6f 7665 5f72 6561 6465 7228 7365 6c66 move_reader(self\n-000284b0: 2e5f 696e 5f66 6429 0a20 2020 2020 2020 ._in_fd). \n-000284c0: 2020 2020 2073 656c 662e 5f69 735f 7265 self._is_re\n-000284d0: 6164 696e 6720 3d20 4661 6c73 650a 0a20 ading = False.. \n-000284e0: 2020 2064 6566 2072 6573 756d 655f 7265 def resume_re\n-000284f0: 6164 696e 6728 7365 6c66 2920 2d3e 204e ading(self) -> N\n-00028500: 6f6e 653a 0a20 2020 2020 2020 2023 2049 one:. # I\n-00028510: 7427 7320 706f 7373 6962 6c65 2074 6861 t's possible tha\n-00028520: 7420 7468 6520 5072 6f74 6f63 6f6c 2063 t the Protocol c\n-00028530: 6f75 6c64 2064 6563 6964 6520 746f 2061 ould decide to a\n-00028540: 7474 656d 7074 2074 6f20 756e 7061 7573 ttempt to unpaus\n-00028550: 650a 2020 2020 2020 2020 2320 7265 6164 e. # read\n-00028560: 696e 6720 6166 7465 7220 5f63 6c6f 7365 ing after _close\n-00028570: 5f72 6561 6465 7228 2920 676f 7420 6361 _reader() got ca\n-00028580: 6c6c 6564 2e20 2043 6865 636b 2074 6861 lled. Check tha\n-00028590: 7420 7468 6520 6664 2069 7320 213d 202d t the fd is != -\n-000285a0: 310a 2020 2020 2020 2020 2320 6265 666f 1. # befo\n-000285b0: 7265 2061 6374 7561 6c6c 7920 7265 7375 re actually resu\n-000285c0: 6d69 6e67 2e0a 2020 2020 2020 2020 6966 ming.. if\n-000285d0: 206e 6f74 2073 656c 662e 5f69 735f 7265 not self._is_re\n-000285e0: 6164 696e 6720 616e 6420 7365 6c66 2e5f ading and self._\n-000285f0: 696e 5f66 6420 213d 202d 313a 0a20 2020 in_fd != -1:. \n-00028600: 2020 2020 2020 2020 2073 656c 662e 5f6c self._l\n-00028610: 6f6f 702e 6164 645f 7265 6164 6572 2873 oop.add_reader(s\n-00028620: 656c 662e 5f69 6e5f 6664 2c20 7365 6c66 elf._in_fd, self\n-00028630: 2e5f 7265 6164 5f72 6561 6479 290a 2020 ._read_ready). \n-00028640: 2020 2020 2020 2020 2020 7365 6c66 2e5f self._\n-00028650: 6973 5f72 6561 6469 6e67 203d 2054 7275 is_reading = Tru\n-00028660: 650a 0a20 2020 2064 6566 205f 636c 6f73 e.. def _clos\n-00028670: 6528 7365 6c66 2920 2d3e 204e 6f6e 653a e(self) -> None:\n-00028680: 0a20 2020 2020 2020 2070 6173 730a 0a20 . pass.. \n-00028690: 2020 2064 6566 2061 626f 7274 2873 656c def abort(sel\n-000286a0: 662c 2065 7863 3a20 2745 7863 6570 7469 f, exc: 'Excepti\n-000286b0: 6f6e 207c 204e 6f6e 6527 203d 204e 6f6e on | None' = Non\n-000286c0: 6529 202d 3e20 4e6f 6e65 3a0a 2020 2020 e) -> None:. \n-000286d0: 2020 2020 7365 6c66 2e5f 636c 6f73 696e self._closin\n-000286e0: 6720 3d20 5472 7565 0a20 2020 2020 2020 g = True. \n-000286f0: 2073 656c 662e 5f63 6c6f 7365 5f72 6561 self._close_rea\n-00028700: 6465 7228 290a 2020 2020 2020 2020 7365 der(). se\n-00028710: 6c66 2e5f 7265 6d6f 7665 5f77 7269 7465 lf._remove_write\n-00028720: 5f71 7565 7565 2829 0a20 2020 2020 2020 _queue(). \n-00028730: 2073 656c 662e 5f70 726f 746f 636f 6c2e self._protocol.\n-00028740: 636f 6e6e 6563 7469 6f6e 5f6c 6f73 7428 connection_lost(\n-00028750: 6578 6329 0a20 2020 2020 2020 2073 656c exc). sel\n-00028760: 662e 5f63 6c6f 7365 2829 0a0a 2020 2020 f._close().. \n-00028770: 6465 6620 6361 6e5f 7772 6974 655f 656f def can_write_eo\n-00028780: 6628 7365 6c66 2920 2d3e 2062 6f6f 6c3a f(self) -> bool:\n-00028790: 0a20 2020 2020 2020 2072 6169 7365 204e . raise N\n-000287a0: 6f74 496d 706c 656d 656e 7465 6445 7272 otImplementedErr\n-000287b0: 6f72 0a0a 2020 2020 6465 6620 7772 6974 or.. def writ\n-000287c0: 655f 656f 6628 7365 6c66 2920 2d3e 204e e_eof(self) -> N\n-000287d0: 6f6e 653a 0a20 2020 2020 2020 2061 7373 one:. ass\n-000287e0: 6572 7420 6e6f 7420 7365 6c66 2e5f 656f ert not self._eo\n-000287f0: 660a 2020 2020 2020 2020 7365 6c66 2e5f f. self._\n-00028800: 656f 6620 3d20 5472 7565 0a20 2020 2020 eof = True. \n-00028810: 2020 2069 6620 7365 6c66 2e5f 7175 6575 if self._queu\n-00028820: 6520 6973 204e 6f6e 653a 0a20 2020 2020 e is None:. \n-00028830: 2020 2020 2020 206c 6f67 6765 722e 6465 logger.de\n-00028840: 6275 6728 2725 7320 676f 7420 454f 462e bug('%s got EOF.\n-00028850: 2020 636c 6f73 696e 6720 6261 636b 656e closing backen\n-00028860: 642e 272c 2073 656c 6629 0a20 2020 2020 d.', self). \n-00028870: 2020 2020 2020 2073 656c 662e 5f77 7269 self._wri\n-00028880: 7465 5f65 6f66 5f6e 6f77 2829 0a20 2020 te_eof_now(). \n-00028890: 2020 2020 2065 6c73 653a 0a20 2020 2020 else:. \n-000288a0: 2020 2020 2020 206c 6f67 6765 722e 6465 logger.de\n-000288b0: 6275 6728 2725 7320 676f 7420 454f 462e bug('%s got EOF.\n-000288c0: 2020 6279 7465 7320 696e 2071 7565 7565 bytes in queue\n-000288d0: 2c20 6465 6665 7272 696e 6720 636c 6f73 , deferring clos\n-000288e0: 6527 2c20 7365 6c66 290a 0a20 2020 2064 e', self).. d\n-000288f0: 6566 2067 6574 5f77 7269 7465 5f62 7566 ef get_write_buf\n-00028900: 6665 725f 7369 7a65 2873 656c 6629 202d fer_size(self) -\n-00028910: 3e20 696e 743a 0a20 2020 2020 2020 2069 > int:. i\n-00028920: 6620 7365 6c66 2e5f 7175 6575 6520 6973 f self._queue is\n-00028930: 204e 6f6e 653a 0a20 2020 2020 2020 2020 None:. \n-00028940: 2020 2072 6574 7572 6e20 300a 2020 2020 return 0. \n-00028950: 2020 2020 7265 7475 726e 2073 756d 286c return sum(l\n-00028960: 656e 2862 6c6f 636b 2920 666f 7220 626c en(block) for bl\n-00028970: 6f63 6b20 696e 2073 656c 662e 5f71 7565 ock in self._que\n-00028980: 7565 290a 0a20 2020 2064 6566 2067 6574 ue).. def get\n-00028990: 5f77 7269 7465 5f62 7566 6665 725f 6c69 _write_buffer_li\n-000289a0: 6d69 7473 2873 656c 6629 202d 3e20 2774 mits(self) -> 't\n-000289b0: 7570 6c65 5b69 6e74 2c20 696e 745d 273a uple[int, int]':\n-000289c0: 0a20 2020 2020 2020 2072 6574 7572 6e20 . return \n-000289d0: 2830 2c20 3029 0a0a 2020 2020 6465 6620 (0, 0).. def \n-000289e0: 7365 745f 7772 6974 655f 6275 6666 6572 set_write_buffer\n-000289f0: 5f6c 696d 6974 7328 7365 6c66 2c20 6869 _limits(self, hi\n-00028a00: 6768 3a20 2769 6e74 207c 204e 6f6e 6527 gh: 'int | None'\n-00028a10: 203d 204e 6f6e 652c 206c 6f77 3a20 2769 = None, low: 'i\n-00028a20: 6e74 207c 204e 6f6e 6527 203d 204e 6f6e nt | None' = Non\n-00028a30: 6529 202d 3e20 4e6f 6e65 3a0a 2020 2020 e) -> None:. \n-00028a40: 2020 2020 6173 7365 7274 2068 6967 6820 assert high \n-00028a50: 6973 204e 6f6e 6520 6f72 2068 6967 6820 is None or high \n-00028a60: 3d3d 2030 0a20 2020 2020 2020 2061 7373 == 0. ass\n-00028a70: 6572 7420 6c6f 7720 6973 204e 6f6e 6520 ert low is None \n-00028a80: 6f72 206c 6f77 203d 3d20 300a 0a20 2020 or low == 0.. \n-00028a90: 2064 6566 205f 7772 6974 655f 656f 665f def _write_eof_\n-00028aa0: 6e6f 7728 7365 6c66 2920 2d3e 204e 6f6e now(self) -> Non\n-00028ab0: 653a 0a20 2020 2020 2020 2072 6169 7365 e:. raise\n-00028ac0: 204e 6f74 496d 706c 656d 656e 7465 6445 NotImplementedE\n-00028ad0: 7272 6f72 0a0a 2020 2020 6465 6620 5f77 rror.. def _w\n-00028ae0: 7269 7465 5f72 6561 6479 2873 656c 6629 rite_ready(self)\n-00028af0: 202d 3e20 4e6f 6e65 3a0a 2020 2020 2020 -> None:. \n-00028b00: 2020 6c6f 6767 6572 2e64 6562 7567 2827 logger.debug('\n-00028b10: 2573 205f 7772 6974 655f 7265 6164 7927 %s _write_ready'\n-00028b20: 2c20 7365 6c66 290a 2020 2020 2020 2020 , self). \n-00028b30: 6173 7365 7274 2073 656c 662e 5f71 7565 assert self._que\n-00028b40: 7565 2069 7320 6e6f 7420 4e6f 6e65 0a0a ue is not None..\n-00028b50: 2020 2020 2020 2020 7472 793a 0a20 2020 try:. \n-00028b60: 2020 2020 2020 2020 206e 5f62 7974 6573 n_bytes\n-00028b70: 203d 206f 732e 7772 6974 6576 2873 656c = os.writev(sel\n-00028b80: 662e 5f6f 7574 5f66 642c 2073 656c 662e f._out_fd, self.\n-00028b90: 5f71 7565 7565 290a 2020 2020 2020 2020 _queue). \n-00028ba0: 6578 6365 7074 2042 6c6f 636b 696e 6749 except BlockingI\n-00028bb0: 4f45 7272 6f72 3a20 2023 2070 7261 676d OError: # pragm\n-00028bc0: 613a 206e 6f20 636f 7665 720a 2020 2020 a: no cover. \n-00028bd0: 2020 2020 2020 2020 6e5f 6279 7465 7320 n_bytes \n-00028be0: 3d20 300a 2020 2020 2020 2020 6578 6365 = 0. exce\n-00028bf0: 7074 204f 5345 7272 6f72 2061 7320 6578 pt OSError as ex\n-00028c00: 633a 0a20 2020 2020 2020 2020 2020 2073 c:. s\n-00028c10: 656c 662e 6162 6f72 7428 6578 6329 0a20 elf.abort(exc). \n-00028c20: 2020 2020 2020 2020 2020 2072 6574 7572 retur\n-00028c30: 6e0a 0a20 2020 2020 2020 206c 6f67 6765 n.. logge\n-00028c40: 722e 6465 6275 6728 2720 2073 7563 6365 r.debug(' succe\n-00028c50: 7373 6675 6c6c 7920 7772 6f74 6520 2564 ssfully wrote %d\n-00028c60: 2062 7974 6573 2066 726f 6d20 7468 6520 bytes from the \n-00028c70: 7175 6575 6527 2c20 6e5f 6279 7465 7329 queue', n_bytes)\n-00028c80: 0a0a 2020 2020 2020 2020 7768 696c 6520 .. while \n-00028c90: 6e5f 6279 7465 733a 0a20 2020 2020 2020 n_bytes:. \n-00028ca0: 2020 2020 2062 6c6f 636b 203d 2073 656c block = sel\n-00028cb0: 662e 5f71 7565 7565 2e70 6f70 6c65 6674 f._queue.popleft\n-00028cc0: 2829 0a20 2020 2020 2020 2020 2020 2069 (). i\n-00028cd0: 6620 6c65 6e28 626c 6f63 6b29 203e 206e f len(block) > n\n-00028ce0: 5f62 7974 6573 3a0a 2020 2020 2020 2020 _bytes:. \n-00028cf0: 2020 2020 2020 2020 2320 5468 6973 2062 # This b\n-00028d00: 6c6f 636b 2077 6173 6e27 7420 636f 6d70 lock wasn't comp\n-00028d10: 6c65 7465 6c79 2077 7269 7474 656e 2e0a letely written..\n-00028d20: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00028d30: 6c6f 6767 6572 2e64 6562 7567 2827 2020 logger.debug(' \n-00028d40: 696e 636f 6d70 6c65 7465 2062 6c6f 636b incomplete block\n-00028d50: 2e20 2053 746f 702e 2729 0a20 2020 2020 . Stop.'). \n-00028d60: 2020 2020 2020 2020 2020 2073 656c 662e self.\n-00028d70: 5f71 7565 7565 2e61 7070 656e 646c 6566 _queue.appendlef\n-00028d80: 7428 626c 6f63 6b5b 6e5f 6279 7465 733a t(block[n_bytes:\n-00028d90: 5d29 0a20 2020 2020 2020 2020 2020 2020 ]). \n-00028da0: 2020 2062 7265 616b 0a20 2020 2020 2020 break. \n-00028db0: 2020 2020 206e 5f62 7974 6573 202d 3d20 n_bytes -= \n-00028dc0: 6c65 6e28 626c 6f63 6b29 0a20 2020 2020 len(block). \n-00028dd0: 2020 2020 2020 206c 6f67 6765 722e 6465 logger.de\n-00028de0: 6275 6728 2720 2072 656d 6f76 6564 2063 bug(' removed c\n-00028df0: 6f6d 706c 6574 6520 626c 6f63 6b2e 2020 omplete block. \n-00028e00: 2564 2072 656d 6169 6e73 2e27 2c20 6e5f %d remains.', n_\n-00028e10: 6279 7465 7329 0a0a 2020 2020 2020 2020 bytes).. \n-00028e20: 6966 206e 6f74 2073 656c 662e 5f71 7565 if not self._que\n-00028e30: 7565 3a0a 2020 2020 2020 2020 2020 2020 ue:. \n-00028e40: 6c6f 6767 6572 2e64 6562 7567 2827 2573 logger.debug('%s\n-00028e50: 2071 7565 7565 2064 7261 696e 6564 2e27 queue drained.'\n-00028e60: 290a 2020 2020 2020 2020 2020 2020 7365 ). se\n-00028e70: 6c66 2e5f 7265 6d6f 7665 5f77 7269 7465 lf._remove_write\n-00028e80: 5f71 7565 7565 2829 0a20 2020 2020 2020 _queue(). \n-00028e90: 2020 2020 2069 6620 7365 6c66 2e5f 656f if self._eo\n-00028ea0: 663a 0a20 2020 2020 2020 2020 2020 2020 f:. \n-00028eb0: 2020 206c 6f67 6765 722e 6465 6275 6728 logger.debug(\n-00028ec0: 2725 7320 7175 6575 6520 6472 6169 6e65 '%s queue draine\n-00028ed0: 642e 2020 636c 6f73 696e 6720 6261 636b d. closing back\n-00028ee0: 656e 6420 6e6f 772e 2729 0a20 2020 2020 end now.'). \n-00028ef0: 2020 2020 2020 2020 2020 2073 656c 662e self.\n-00028f00: 5f77 7269 7465 5f65 6f66 5f6e 6f77 2829 _write_eof_now()\n-00028f10: 0a20 2020 2020 2020 2020 2020 2069 6620 . if \n-00028f20: 7365 6c66 2e5f 636c 6f73 696e 673a 0a20 self._closing:. \n-00028f30: 2020 2020 2020 2020 2020 2020 2020 2073 s\n-00028f40: 656c 662e 6162 6f72 7428 290a 0a20 2020 elf.abort().. \n-00028f50: 2064 6566 205f 7265 6d6f 7665 5f77 7269 def _remove_wri\n-00028f60: 7465 5f71 7565 7565 2873 656c 6629 202d te_queue(self) -\n-00028f70: 3e20 4e6f 6e65 3a0a 2020 2020 2020 2020 > None:. \n-00028f80: 6966 2073 656c 662e 5f71 7565 7565 2069 if self._queue i\n-00028f90: 7320 6e6f 7420 4e6f 6e65 3a0a 2020 2020 s not None:. \n-00028fa0: 2020 2020 2020 2020 7365 6c66 2e5f 7072 self._pr\n-00028fb0: 6f74 6f63 6f6c 2e72 6573 756d 655f 7772 otocol.resume_wr\n-00028fc0: 6974 696e 6728 290a 2020 2020 2020 2020 iting(). \n-00028fd0: 2020 2020 7365 6c66 2e5f 6c6f 6f70 2e72 self._loop.r\n-00028fe0: 656d 6f76 655f 7772 6974 6572 2873 656c emove_writer(sel\n-00028ff0: 662e 5f6f 7574 5f66 6429 0a20 2020 2020 f._out_fd). \n-00029000: 2020 2020 2020 2073 656c 662e 5f71 7565 self._que\n-00029010: 7565 203d 204e 6f6e 650a 0a20 2020 2064 ue = None.. d\n-00029020: 6566 205f 6372 6561 7465 5f77 7269 7465 ef _create_write\n-00029030: 5f71 7565 7565 2873 656c 662c 2064 6174 _queue(self, dat\n-00029040: 613a 2062 7974 6573 2920 2d3e 204e 6f6e a: bytes) -> Non\n-00029050: 653a 0a20 2020 2020 2020 206c 6f67 6765 e:. logge\n-00029060: 722e 6465 6275 6728 2725 7320 6372 6561 r.debug('%s crea\n-00029070: 7469 6e67 2077 7269 7465 2071 7565 7565 ting write queue\n-00029080: 2066 6f72 2066 6420 2573 272c 2073 656c for fd %s', sel\n-00029090: 662c 2073 656c 662e 5f6f 7574 5f66 6429 f, self._out_fd)\n-000290a0: 0a20 2020 2020 2020 2061 7373 6572 7420 . assert \n-000290b0: 7365 6c66 2e5f 7175 6575 6520 6973 204e self._queue is N\n-000290c0: 6f6e 650a 2020 2020 2020 2020 7365 6c66 one. self\n-000290d0: 2e5f 6c6f 6f70 2e61 6464 5f77 7269 7465 ._loop.add_write\n-000290e0: 7228 7365 6c66 2e5f 6f75 745f 6664 2c20 r(self._out_fd, \n-000290f0: 7365 6c66 2e5f 7772 6974 655f 7265 6164 self._write_read\n-00029100: 7929 0a20 2020 2020 2020 2073 656c 662e y). self.\n-00029110: 5f71 7565 7565 203d 2063 6f6c 6c65 6374 _queue = collect\n-00029120: 696f 6e73 2e64 6571 7565 2828 6461 7461 ions.deque((data\n-00029130: 2c29 290a 2020 2020 2020 2020 7365 6c66 ,)). self\n-00029140: 2e5f 7072 6f74 6f63 6f6c 2e70 6175 7365 ._protocol.pause\n-00029150: 5f77 7269 7469 6e67 2829 0a0a 2020 2020 _writing().. \n-00029160: 6465 6620 7772 6974 6528 7365 6c66 2c20 def write(self, \n-00029170: 6461 7461 3a20 6279 7465 7329 202d 3e20 data: bytes) -> \n-00029180: 4e6f 6e65 3a0a 2020 2020 2020 2020 2320 None:. # \n-00029190: 7468 6973 2069 7320 6120 7261 6365 2063 this is a race c\n-000291a0: 6f6e 6469 7469 6f6e 2077 6974 6820 7375 ondition with su\n-000291b0: 6270 726f 6365 7373 6573 3a20 6966 2077 bprocesses: if w\n-000291c0: 6520 6765 7420 616e 6420 7072 6f63 6573 e get and proces\n-000291d0: 7320 7468 6520 7468 6520 2265 7869 7465 s the the \"exite\n-000291e0: 6422 0a20 2020 2020 2020 2023 2065 7665 d\". # eve\n-000291f0: 6e74 2062 6566 6f72 6520 7365 6569 6e67 nt before seeing\n-00029200: 2042 726f 6b65 6e50 6970 6545 7272 6f72 BrokenPipeError\n-00029210: 2c20 7765 276c 6c20 7472 7920 746f 2077 , we'll try to w\n-00029220: 7269 7465 2074 6f20 6120 636c 6f73 6564 rite to a closed\n-00029230: 2070 6970 652e 0a20 2020 2020 2020 2023 pipe.. #\n-00029240: 2044 6f20 7768 6174 2074 6865 2073 7461 Do what the sta\n-00029250: 6e64 6172 6420 6c69 6272 6172 7920 646f ndard library do\n-00029260: 6573 2061 6e64 2069 676e 6f72 652c 2069 es and ignore, i\n-00029270: 6e73 7465 6164 206f 6620 6173 7365 7274 nstead of assert\n-00029280: 0a20 2020 2020 2020 2069 6620 7365 6c66 . if self\n-00029290: 2e5f 636c 6f73 696e 673a 0a20 2020 2020 ._closing:. \n-000292a0: 2020 2020 2020 206c 6f67 6765 722e 6465 logger.de\n-000292b0: 6275 6728 2769 676e 6f72 696e 6720 7772 bug('ignoring wr\n-000292c0: 6974 6528 2920 746f 2063 6c6f 7369 6e67 ite() to closing\n-000292d0: 2074 7261 6e73 706f 7274 2066 6420 2569 transport fd %i\n-000292e0: 272c 2073 656c 662e 5f6f 7574 5f66 6429 ', self._out_fd)\n-000292f0: 0a20 2020 2020 2020 2020 2020 2072 6574 . ret\n-00029300: 7572 6e0a 0a20 2020 2020 2020 2061 7373 urn.. ass\n-00029310: 6572 7420 6e6f 7420 7365 6c66 2e5f 656f ert not self._eo\n-00029320: 660a 0a20 2020 2020 2020 2069 6620 7365 f.. if se\n-00029330: 6c66 2e5f 7175 6575 6520 6973 206e 6f74 lf._queue is not\n-00029340: 204e 6f6e 653a 0a20 2020 2020 2020 2020 None:. \n-00029350: 2020 2073 656c 662e 5f71 7565 7565 2e61 self._queue.a\n-00029360: 7070 656e 6428 6461 7461 290a 0a20 2020 ppend(data).. \n-00029370: 2020 2020 2020 2020 2023 2077 7269 7465 # write\n-00029380: 7628 2920 7769 6c6c 2063 6f6d 706c 6169 v() will complai\n-00029390: 6e20 6966 2074 6865 2071 7565 7565 2069 n if the queue i\n-000293a0: 7320 746f 6f20 6c6f 6e67 2e20 2043 6f6e s too long. Con\n-000293b0: 736f 6c69 6461 7465 2069 742e 0a20 2020 solidate it.. \n-000293c0: 2020 2020 2020 2020 2069 6620 6c65 6e28 if len(\n-000293d0: 7365 6c66 2e5f 7175 6575 6529 203e 2049 self._queue) > I\n-000293e0: 4f56 5f4d 4158 3a0a 2020 2020 2020 2020 OV_MAX:. \n-000293f0: 2020 2020 2020 2020 616c 6c5f 6461 7461 all_data\n-00029400: 203d 2062 2727 2e6a 6f69 6e28 7365 6c66 = b''.join(self\n-00029410: 2e5f 7175 6575 6529 0a20 2020 2020 2020 ._queue). \n-00029420: 2020 2020 2020 2020 2073 656c 662e 5f71 self._q\n-00029430: 7565 7565 2e63 6c65 6172 2829 0a20 2020 ueue.clear(). \n-00029440: 2020 2020 2020 2020 2020 2020 2073 656c sel\n-00029450: 662e 5f71 7565 7565 2e61 7070 656e 6428 f._queue.append(\n-00029460: 616c 6c5f 6461 7461 290a 0a20 2020 2020 all_data).. \n-00029470: 2020 2020 2020 2072 6574 7572 6e0a 0a20 return.. \n-00029480: 2020 2020 2020 2074 7279 3a0a 2020 2020 try:. \n-00029490: 2020 2020 2020 2020 6e5f 6279 7465 7320 n_bytes \n-000294a0: 3d20 6f73 2e77 7269 7465 2873 656c 662e = os.write(self.\n-000294b0: 5f6f 7574 5f66 642c 2064 6174 6129 0a20 _out_fd, data). \n-000294c0: 2020 2020 2020 2065 7863 6570 7420 426c except Bl\n-000294d0: 6f63 6b69 6e67 494f 4572 726f 723a 0a20 ockingIOError:. \n-000294e0: 2020 2020 2020 2020 2020 206e 5f62 7974 n_byt\n-000294f0: 6573 203d 2030 0a20 2020 2020 2020 2065 es = 0. e\n-00029500: 7863 6570 7420 4f53 4572 726f 7220 6173 xcept OSError as\n-00029510: 2065 7863 3a0a 2020 2020 2020 2020 2020 exc:. \n-00029520: 2020 7365 6c66 2e61 626f 7274 2865 7863 self.abort(exc\n-00029530: 290a 2020 2020 2020 2020 2020 2020 7265 ). re\n-00029540: 7475 726e 0a0a 2020 2020 2020 2020 6966 turn.. if\n-00029550: 206e 5f62 7974 6573 2021 3d20 6c65 6e28 n_bytes != len(\n-00029560: 6461 7461 293a 0a20 2020 2020 2020 2020 data):. \n-00029570: 2020 2073 656c 662e 5f63 7265 6174 655f self._create_\n-00029580: 7772 6974 655f 7175 6575 6528 6461 7461 write_queue(data\n-00029590: 5b6e 5f62 7974 6573 3a5d 290a 0a20 2020 [n_bytes:]).. \n-000295a0: 2064 6566 2063 6c6f 7365 2873 656c 6629 def close(self)\n-000295b0: 202d 3e20 4e6f 6e65 3a0a 2020 2020 2020 -> None:. \n-000295c0: 2020 6966 2073 656c 662e 5f63 6c6f 7369 if self._closi\n-000295d0: 6e67 3a0a 2020 2020 2020 2020 2020 2020 ng:. \n-000295e0: 7265 7475 726e 0a0a 2020 2020 2020 2020 return.. \n-000295f0: 7365 6c66 2e5f 636c 6f73 696e 6720 3d20 self._closing = \n-00029600: 5472 7565 0a20 2020 2020 2020 2073 656c True. sel\n-00029610: 662e 5f63 6c6f 7365 5f72 6561 6465 7228 f._close_reader(\n-00029620: 290a 0a20 2020 2020 2020 2069 6620 7365 ).. if se\n-00029630: 6c66 2e5f 7175 6575 6520 6973 206e 6f74 lf._queue is not\n-00029640: 204e 6f6e 653a 0a20 2020 2020 2020 2020 None:. \n-00029650: 2020 2023 2061 626f 7274 2829 2077 696c # abort() wil\n-00029660: 6c20 6265 2063 616c 6c65 6420 6672 6f6d l be called from\n-00029670: 205f 7772 6974 655f 7265 6164 7928 2920 _write_ready() \n-00029680: 7768 656e 2069 7427 7320 646f 6e65 0a20 when it's done. \n-00029690: 2020 2020 2020 2020 2020 2072 6574 7572 retur\n-000296a0: 6e0a 0a20 2020 2020 2020 2073 656c 662e n.. self.\n-000296b0: 6162 6f72 7428 290a 0a20 2020 2064 6566 abort().. def\n-000296c0: 2067 6574 5f70 726f 746f 636f 6c28 7365 get_protocol(se\n-000296d0: 6c66 2920 2d3e 2061 7379 6e63 696f 2e42 lf) -> asyncio.B\n-000296e0: 6173 6550 726f 746f 636f 6c3a 0a20 2020 aseProtocol:. \n-000296f0: 2020 2020 2072 6574 7572 6e20 7365 6c66 return self\n-00029700: 2e5f 7072 6f74 6f63 6f6c 0a0a 2020 2020 ._protocol.. \n-00029710: 6465 6620 6973 5f63 6c6f 7369 6e67 2873 def is_closing(s\n-00029720: 656c 6629 202d 3e20 626f 6f6c 3a0a 2020 elf) -> bool:. \n-00029730: 2020 2020 2020 7265 7475 726e 2073 656c return sel\n-00029740: 662e 5f63 6c6f 7369 6e67 0a0a 2020 2020 f._closing.. \n-00029750: 6465 6620 7365 745f 7072 6f74 6f63 6f6c def set_protocol\n-00029760: 2873 656c 662c 2070 726f 746f 636f 6c3a (self, protocol:\n-00029770: 2061 7379 6e63 696f 2e42 6173 6550 726f asyncio.BasePro\n-00029780: 746f 636f 6c29 202d 3e20 4e6f 6e65 3a0a tocol) -> None:.\n-00029790: 2020 2020 2020 2020 7261 6973 6520 4e6f raise No\n-000297a0: 7449 6d70 6c65 6d65 6e74 6564 4572 726f tImplementedErro\n-000297b0: 720a 0a20 2020 2064 6566 205f 5f64 656c r.. def __del\n-000297c0: 5f5f 2873 656c 6629 202d 3e20 4e6f 6e65 __(self) -> None\n-000297d0: 3a0a 2020 2020 2020 2020 7365 6c66 2e5f :. self._\n-000297e0: 636c 6f73 6528 290a 0a0a 636c 6173 7320 close()...class \n-000297f0: 5375 6270 726f 6365 7373 5072 6f74 6f63 SubprocessProtoc\n-00029800: 6f6c 2861 7379 6e63 696f 2e50 726f 746f ol(asyncio.Proto\n-00029810: 636f 6c29 3a0a 2020 2020 2222 2241 6e20 col):. \"\"\"An \n-00029820: 6578 7465 6e73 696f 6e20 746f 2061 7379 extension to asy\n-00029830: 6e63 696f 2e50 726f 746f 636f 6c20 666f ncio.Protocol fo\n-00029840: 7220 7573 6520 7769 7468 2053 7562 7072 r use with Subpr\n-00029850: 6f63 6573 7354 7261 6e73 706f 7274 2e22 ocessTransport.\"\n-00029860: 2222 0a20 2020 2064 6566 2070 726f 6365 \"\". def proce\n-00029870: 7373 5f65 7869 7465 6428 7365 6c66 2920 ss_exited(self) \n-00029880: 2d3e 204e 6f6e 653a 0a20 2020 2020 2020 -> None:. \n-00029890: 2022 2222 4361 6c6c 6564 2077 6865 6e20 \"\"\"Called when \n-000298a0: 7375 6270 726f 6365 7373 2068 6173 2065 subprocess has e\n-000298b0: 7869 7465 642e 2222 220a 2020 2020 2020 xited.\"\"\". \n-000298c0: 2020 7261 6973 6520 4e6f 7449 6d70 6c65 raise NotImple\n-000298d0: 6d65 6e74 6564 4572 726f 720a 0a0a 636c mentedError...cl\n-000298e0: 6173 7320 5769 6e64 6f77 5369 7a65 3a0a ass WindowSize:.\n-000298f0: 2020 2020 6465 6620 5f5f 696e 6974 5f5f def __init__\n-00029900: 2873 656c 662c 2076 616c 7565 3a20 4a73 (self, value: Js\n-00029910: 6f6e 4f62 6a65 6374 293a 0a20 2020 2020 onObject):. \n-00029920: 2020 2073 656c 662e 726f 7773 203d 2067 self.rows = g\n-00029930: 6574 5f69 6e74 2876 616c 7565 2c20 2772 et_int(value, 'r\n-00029940: 6f77 7327 290a 2020 2020 2020 2020 7365 ows'). se\n-00029950: 6c66 2e63 6f6c 7320 3d20 6765 745f 696e lf.cols = get_in\n-00029960: 7428 7661 6c75 652c 2027 636f 6c73 2729 t(value, 'cols')\n-00029970: 0a0a 0a63 6c61 7373 2053 7562 7072 6f63 ...class Subproc\n-00029980: 6573 7354 7261 6e73 706f 7274 285f 5472 essTransport(_Tr\n-00029990: 616e 7370 6f72 742c 2061 7379 6e63 696f ansport, asyncio\n-000299a0: 2e53 7562 7072 6f63 6573 7354 7261 6e73 .SubprocessTrans\n-000299b0: 706f 7274 293a 0a20 2020 2022 2222 4120 port):. \"\"\"A \n-000299c0: 6269 2d64 6972 6563 7469 6f6e 616c 2074 bi-directional t\n-000299d0: 7261 6e73 706f 7274 2073 7065 616b 696e ransport speakin\n-000299e0: 6720 7769 7468 2073 7464 696e 2f6f 7574 g with stdin/out\n-000299f0: 206f 6620 6120 7375 6270 726f 6365 7373 of a subprocess\n-00029a00: 2e0a 0a20 2020 204e 6f74 653a 2074 6869 ... Note: thi\n-00029a10: 7320 6973 206e 6f74 2072 6561 6c6c 7920 s is not really \n-00029a20: 6120 6e6f 726d 616c 2053 7562 7072 6f63 a normal Subproc\n-00029a30: 6573 7354 7261 6e73 706f 7274 2e20 2041 essTransport. A\n-00029a40: 6c74 686f 7567 6820 6974 0a20 2020 2069 lthough it. i\n-00029a50: 6d70 6c65 6d65 6e74 7320 7468 6520 656e mplements the en\n-00029a60: 7469 7265 2041 5049 206f 6620 6173 796e tire API of asyn\n-00029a70: 6369 6f2e 5375 6270 726f 6365 7373 5472 cio.SubprocessTr\n-00029a80: 616e 7370 6f72 742c 2069 7420 6973 206e ansport, it is n\n-00029a90: 6f74 0a20 2020 2064 6573 6967 6e65 6420 ot. designed \n-00029aa0: 746f 2062 6520 7573 6564 2077 6974 6820 to be used with \n-00029ab0: 6173 796e 6369 6f2e 5375 6270 726f 6365 asyncio.Subproce\n-00029ac0: 7373 5072 6f74 6f63 6f6c 206f 626a 6563 ssProtocol objec\n-00029ad0: 7473 2e20 2049 6e73 7465 6164 2c20 6974 ts. Instead, it\n-00029ae0: 0a20 2020 2070 6169 7220 7769 7468 206e . pair with n\n-00029af0: 6f72 6d61 6c20 5072 6f74 6f63 6f6c 206f ormal Protocol o\n-00029b00: 626a 6563 7473 2077 6869 6368 2061 6c73 bjects which als\n-00029b10: 6f20 696d 706c 656d 656e 7420 7468 650a o implement the.\n-00029b20: 2020 2020 5375 6270 726f 6365 7373 5072 SubprocessPr\n-00029b30: 6f74 6f63 6f6c 2064 6566 696e 6564 2069 otocol defined i\n-00029b40: 6e20 7468 6973 206d 6f64 756c 6520 2877 n this module (w\n-00029b50: 6869 6368 206f 6e6c 7920 6861 7320 610a hich only has a.\n-00029b60: 2020 2020 7072 6f63 6573 735f 6578 6974 process_exit\n-00029b70: 6564 2829 206d 6574 686f 6429 2e20 2057 ed() method). W\n-00029b80: 6861 7465 7665 7220 7468 6520 7072 6f74 hatever the prot\n-00029b90: 6f63 6f6c 2077 7269 7465 7320 6973 2073 ocol writes is s\n-00029ba0: 656e 7420 746f 2073 7464 696e 2c0a 2020 ent to stdin,. \n-00029bb0: 2020 616e 6420 7768 6174 6576 6572 2063 and whatever c\n-00029bc0: 6f6d 6573 2066 726f 6d20 7374 646f 7574 omes from stdout\n-00029bd0: 2069 7320 6769 7665 6e20 746f 2074 6865 is given to the\n-00029be0: 2050 726f 746f 636f 6c20 7669 6120 7468 Protocol via th\n-00029bf0: 650a 2020 2020 2e64 6174 615f 7265 6365 e. .data_rece\n-00029c00: 6976 6564 2829 2066 756e 6374 696f 6e2e ived() function.\n-00029c10: 0a0a 2020 2020 4966 2073 7464 6572 7220 .. If stderr \n-00029c20: 6973 2063 6f6e 6669 6775 7265 6420 6173 is configured as\n-00029c30: 2061 2070 6970 652c 2074 6865 2074 7261 a pipe, the tra\n-00029c40: 6e73 706f 7274 2077 696c 6c20 7365 7061 nsport will sepa\n-00029c50: 7261 7465 6c79 2063 6f6c 6c65 6374 0a20 rately collect. \n-00029c60: 2020 2064 6174 6120 6672 6f6d 2069 742c data from it,\n-00029c70: 206d 616b 696e 6720 6974 2061 7661 696c making it avail\n-00029c80: 6162 6c65 2076 6961 2074 6865 202e 6765 able via the .ge\n-00029c90: 745f 7374 6465 7272 2829 206d 6574 686f t_stderr() metho\n-00029ca0: 642e 0a20 2020 2022 2222 0a0a 2020 2020 d.. \"\"\".. \n-00029cb0: 5f72 6574 7572 6e63 6f64 653a 2027 696e _returncode: 'in\n-00029cc0: 7420 7c20 4e6f 6e65 2720 3d20 4e6f 6e65 t | None' = None\n-00029cd0: 0a0a 2020 2020 5f70 7479 5f66 643a 2027 .. _pty_fd: '\n-00029ce0: 696e 7420 7c20 4e6f 6e65 2720 3d20 4e6f int | None' = No\n-00029cf0: 6e65 0a20 2020 205f 7072 6f63 6573 733a ne. _process:\n-00029d00: 2027 7375 6270 726f 6365 7373 2e50 6f70 'subprocess.Pop\n-00029d10: 656e 5b62 7974 6573 5d20 7c20 4e6f 6e65 en[bytes] | None\n-00029d20: 2720 3d20 4e6f 6e65 0a20 2020 205f 7374 ' = None. _st\n-00029d30: 6465 7272 3a20 2753 706f 6f6c 6572 207c derr: 'Spooler |\n-00029d40: 204e 6f6e 6527 0a0a 2020 2020 4073 7461 None'.. @sta\n-00029d50: 7469 636d 6574 686f 640a 2020 2020 6465 ticmethod. de\n-00029d60: 6620 5f63 7265 6174 655f 7761 7463 6865 f _create_watche\n-00029d70: 7228 2920 2d3e 2061 7379 6e63 696f 2e41 r() -> asyncio.A\n-00029d80: 6273 7472 6163 7443 6869 6c64 5761 7463 bstractChildWatc\n-00029d90: 6865 723a 0a20 2020 2020 2020 2074 7279 her:. try\n-00029da0: 3a0a 2020 2020 2020 2020 2020 2020 6f73 :. os\n-00029db0: 2e63 6c6f 7365 286f 732e 7069 6466 645f .close(os.pidfd_\n-00029dc0: 6f70 656e 286f 732e 6765 7470 6964 2829 open(os.getpid()\n-00029dd0: 2c20 3029 2920 2023 2063 6865 636b 2066 , 0)) # check f\n-00029de0: 6f72 206b 6572 6e65 6c20 7375 7070 6f72 or kernel suppor\n-00029df0: 740a 2020 2020 2020 2020 2020 2020 7265 t. re\n-00029e00: 7475 726e 2061 7379 6e63 696f 2e50 6964 turn asyncio.Pid\n-00029e10: 6664 4368 696c 6457 6174 6368 6572 2829 fdChildWatcher()\n-00029e20: 0a20 2020 2020 2020 2065 7863 6570 7420 . except \n-00029e30: 2841 7474 7269 6275 7465 4572 726f 722c (AttributeError,\n-00029e40: 204f 5345 7272 6f72 293a 0a20 2020 2020 OSError):. \n-00029e50: 2020 2020 2020 2070 6173 730a 0a20 2020 pass.. \n-00029e60: 2020 2020 2072 6574 7572 6e20 6173 796e return asyn\n-00029e70: 6369 6f2e 5361 6665 4368 696c 6457 6174 cio.SafeChildWat\n-00029e80: 6368 6572 2829 0a0a 2020 2020 4073 7461 cher().. @sta\n-00029e90: 7469 636d 6574 686f 640a 2020 2020 6465 ticmethod. de\n-00029ea0: 6620 5f67 6574 5f77 6174 6368 6572 286c f _get_watcher(l\n-00029eb0: 6f6f 703a 2061 7379 6e63 696f 2e41 6273 oop: asyncio.Abs\n-00029ec0: 7472 6163 7445 7665 6e74 4c6f 6f70 2920 tractEventLoop) \n-00029ed0: 2d3e 2061 7379 6e63 696f 2e41 6273 7472 -> asyncio.Abstr\n-00029ee0: 6163 7443 6869 6c64 5761 7463 6865 723a actChildWatcher:\n-00029ef0: 0a20 2020 2020 2020 2071 7561 726b 203d . quark =\n-00029f00: 2027 5f63 6f63 6b70 6974 5f74 7261 6e73 '_cockpit_trans\n-00029f10: 706f 7274 735f 6368 696c 645f 7761 7463 ports_child_watc\n-00029f20: 6865 7227 0a20 2020 2020 2020 2077 6174 her'. wat\n-00029f30: 6368 6572 203d 2067 6574 6174 7472 286c cher = getattr(l\n-00029f40: 6f6f 702c 2071 7561 726b 2c20 4e6f 6e65 oop, quark, None\n-00029f50: 290a 0a20 2020 2020 2020 2069 6620 7761 ).. if wa\n-00029f60: 7463 6865 7220 6973 204e 6f6e 653a 0a20 tcher is None:. \n-00029f70: 2020 2020 2020 2020 2020 2077 6174 6368 watch\n-00029f80: 6572 203d 2053 7562 7072 6f63 6573 7354 er = SubprocessT\n-00029f90: 7261 6e73 706f 7274 2e5f 6372 6561 7465 ransport._create\n-00029fa0: 5f77 6174 6368 6572 2829 0a20 2020 2020 _watcher(). \n-00029fb0: 2020 2020 2020 2077 6174 6368 6572 2e61 watcher.a\n-00029fc0: 7474 6163 685f 6c6f 6f70 286c 6f6f 7029 ttach_loop(loop)\n-00029fd0: 0a20 2020 2020 2020 2020 2020 2073 6574 . set\n-00029fe0: 6174 7472 286c 6f6f 702c 2071 7561 726b attr(loop, quark\n-00029ff0: 2c20 7761 7463 6865 7229 0a0a 2020 2020 , watcher).. \n-0002a000: 2020 2020 7265 7475 726e 2077 6174 6368 return watch\n-0002a010: 6572 0a0a 2020 2020 6465 6620 6765 745f er.. def get_\n-0002a020: 7374 6465 7272 2873 656c 662c 202a 2c20 stderr(self, *, \n-0002a030: 7265 7365 743a 2062 6f6f 6c20 3d20 4661 reset: bool = Fa\n-0002a040: 6c73 6529 202d 3e20 7374 723a 0a20 2020 lse) -> str:. \n-0002a050: 2020 2020 2069 6620 7365 6c66 2e5f 7374 if self._st\n-0002a060: 6465 7272 2069 7320 6e6f 7420 4e6f 6e65 derr is not None\n-0002a070: 3a0a 2020 2020 2020 2020 2020 2020 7265 :. re\n-0002a080: 7475 726e 2073 656c 662e 5f73 7464 6572 turn self._stder\n-0002a090: 722e 6765 7428 7265 7365 743d 7265 7365 r.get(reset=rese\n-0002a0a0: 7429 2e64 6563 6f64 6528 6572 726f 7273 t).decode(errors\n-0002a0b0: 3d27 7265 706c 6163 6527 290a 2020 2020 ='replace'). \n-0002a0c0: 2020 2020 656c 7365 3a0a 2020 2020 2020 else:. \n-0002a0d0: 2020 2020 2020 7265 7475 726e 2027 270a return ''.\n-0002a0e0: 0a20 2020 2064 6566 205f 6578 6974 6564 . def _exited\n-0002a0f0: 2873 656c 662c 2070 6964 3a20 696e 742c (self, pid: int,\n-0002a100: 2063 6f64 653a 2069 6e74 2920 2d3e 204e code: int) -> N\n-0002a110: 6f6e 653a 0a20 2020 2020 2020 2023 204e one:. # N\n-0002a120: 423a 2070 6572 2041 6273 7472 6163 7443 B: per AbstractC\n-0002a130: 6869 6c64 5761 7463 6865 7220 4150 492c hildWatcher API,\n-0002a140: 2074 6869 7320 6861 6e64 6c65 7220 7368 this handler sh\n-0002a150: 6f75 6c64 2062 6520 7468 7265 6164 2d73 ould be thread-s\n-0002a160: 6166 652c 0a20 2020 2020 2020 2023 2062 afe,. # b\n-0002a170: 7574 2077 6520 6f6e 6c79 2065 7665 7220 ut we only ever \n-0002a180: 7573 6520 6e6f 6e2d 7468 7265 6164 6564 use non-threaded\n-0002a190: 2063 6869 6c64 2077 6174 6368 6572 2069 child watcher i\n-0002a1a0: 6d70 6c65 6d65 6e74 6174 696f 6e73 2c20 mplementations, \n-0002a1b0: 736f 0a20 2020 2020 2020 2023 2077 6520 so. # we \n-0002a1c0: 6361 6e20 6173 7375 6d65 2077 6527 6c6c can assume we'll\n-0002a1d0: 2061 6c77 6179 7320 6265 2063 616c 6c65 always be calle\n-0002a1e0: 6420 696e 2074 6865 206d 6169 6e20 7468 d in the main th\n-0002a1f0: 7265 6164 2e0a 0a20 2020 2020 2020 2023 read... #\n-0002a200: 204e 423a 2074 6865 2073 7562 7072 6f63 NB: the subproc\n-0002a210: 6573 7320 6973 2067 6f69 6e67 2074 6f20 ess is going to \n-0002a220: 7761 6e74 2074 6f20 7761 6974 7069 6428 want to waitpid(\n-0002a230: 2920 6974 7365 6c66 2061 7320 7765 6c6c ) itself as well\n-0002a240: 2c20 6275 740a 2020 2020 2020 2020 2320 , but. # \n-0002a250: 7769 6c6c 2067 6574 2045 4348 494c 4420 will get ECHILD \n-0002a260: 7369 6e63 6520 7765 2061 6c72 6561 6479 since we already\n-0002a270: 2072 6561 7065 6420 6974 2e20 2046 6f72 reaped it. For\n-0002a280: 7475 6e61 7465 6c79 2c20 7369 6e63 650a tunately, since.\n-0002a290: 2020 2020 2020 2020 2320 5079 7468 6f6e # Python\n-0002a2a0: 2033 2e32 2074 6869 7320 6973 2073 7570 3.2 this is sup\n-0002a2b0: 706f 7274 6564 2c20 616e 6420 7072 6f63 ported, and proc\n-0002a2c0: 6573 7320 6765 7473 2061 2072 6574 7572 ess gets a retur\n-0002a2d0: 6e20 7374 6174 7573 206f 660a 2020 2020 n status of. \n-0002a2e0: 2020 2020 2320 7a65 726f 2e20 2046 6f72 # zero. For\n-0002a2f0: 2074 6861 7420 7265 6173 6f6e 2c20 7765 that reason, we\n-0002a300: 206e 6565 6420 746f 2073 746f 7265 206f need to store o\n-0002a310: 7572 206f 776e 2063 6f70 7920 6f66 2074 ur own copy of t\n-0002a320: 6865 2072 6574 7572 6e0a 2020 2020 2020 he return. \n-0002a330: 2020 2320 7374 6174 7573 2e20 2053 6565 # status. See\n-0002a340: 2068 7474 7073 3a2f 2f67 6974 6875 622e https://github.\n-0002a350: 636f 6d2f 7079 7468 6f6e 2f63 7079 7468 com/python/cpyth\n-0002a360: 6f6e 2f69 7373 7565 732f 3539 3936 300a on/issues/59960.\n-0002a370: 2020 2020 2020 2020 6173 7365 7274 2069 assert i\n-0002a380: 7369 6e73 7461 6e63 6528 7365 6c66 2e5f sinstance(self._\n-0002a390: 7072 6f74 6f63 6f6c 2c20 5375 6270 726f protocol, Subpro\n-0002a3a0: 6365 7373 5072 6f74 6f63 6f6c 290a 2020 cessProtocol). \n-0002a3b0: 2020 2020 2020 6173 7365 7274 2073 656c assert sel\n-0002a3c0: 662e 5f70 726f 6365 7373 2069 7320 6e6f f._process is no\n-0002a3d0: 7420 4e6f 6e65 0a20 2020 2020 2020 2061 t None. a\n-0002a3e0: 7373 6572 7420 7365 6c66 2e5f 7072 6f63 ssert self._proc\n-0002a3f0: 6573 732e 7069 6420 3d3d 2070 6964 0a20 ess.pid == pid. \n-0002a400: 2020 2020 2020 2073 656c 662e 5f72 6574 self._ret\n-0002a410: 7572 6e63 6f64 6520 3d20 636f 6465 0a20 urncode = code. \n-0002a420: 2020 2020 2020 206c 6f67 6765 722e 6465 logger.de\n-0002a430: 6275 6728 2750 726f 6365 7373 2065 7869 bug('Process exi\n-0002a440: 7465 6420 7769 7468 2073 7461 7475 7320 ted with status \n-0002a450: 2564 272c 2073 656c 662e 5f72 6574 7572 %d', self._retur\n-0002a460: 6e63 6f64 6529 0a20 2020 2020 2020 2069 ncode). i\n-0002a470: 6620 6e6f 7420 7365 6c66 2e5f 636c 6f73 f not self._clos\n-0002a480: 696e 673a 0a20 2020 2020 2020 2020 2020 ing:. \n-0002a490: 2073 656c 662e 5f70 726f 746f 636f 6c2e self._protocol.\n-0002a4a0: 7072 6f63 6573 735f 6578 6974 6564 2829 process_exited()\n-0002a4b0: 0a0a 2020 2020 6465 6620 5f5f 696e 6974 .. def __init\n-0002a4c0: 5f5f 2873 656c 662c 0a20 2020 2020 2020 __(self,. \n-0002a4d0: 2020 2020 2020 2020 2020 6c6f 6f70 3a20 loop: \n-0002a4e0: 6173 796e 6369 6f2e 4162 7374 7261 6374 asyncio.Abstract\n-0002a4f0: 4576 656e 744c 6f6f 702c 0a20 2020 2020 EventLoop,. \n-0002a500: 2020 2020 2020 2020 2020 2020 7072 6f74 prot\n-0002a510: 6f63 6f6c 3a20 5375 6270 726f 6365 7373 ocol: Subprocess\n-0002a520: 5072 6f74 6f63 6f6c 2c0a 2020 2020 2020 Protocol,. \n-0002a530: 2020 2020 2020 2020 2020 2061 7267 733a args:\n-0002a540: 2053 6571 7565 6e63 655b 7374 725d 2c0a Sequence[str],.\n-0002a550: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0002a560: 202a 2c0a 2020 2020 2020 2020 2020 2020 *,. \n-0002a570: 2020 2020 2070 7479 3a20 626f 6f6c 203d pty: bool =\n-0002a580: 2046 616c 7365 2c0a 2020 2020 2020 2020 False,. \n-0002a590: 2020 2020 2020 2020 2077 696e 646f 773a window:\n-0002a5a0: 2027 5769 6e64 6f77 5369 7a65 207c 204e 'WindowSize | N\n-0002a5b0: 6f6e 6527 203d 204e 6f6e 652c 0a20 2020 one' = None,. \n-0002a5c0: 2020 2020 2020 2020 2020 2020 2020 2a2a **\n-0002a5d0: 6b77 6172 6773 3a20 416e 7929 3a0a 0a20 kwargs: Any):.. \n-0002a5e0: 2020 2020 2020 2023 2067 6f20 646f 776e # go down\n-0002a5f0: 2061 7320 6120 7465 616d 202d 2d20 7765 as a team -- we\n-0002a600: 2064 6f6e 2774 2077 616e 7420 616e 7920 don't want any \n-0002a610: 6c65 616b 6564 2070 726f 6365 7373 6573 leaked processes\n-0002a620: 2077 6865 6e20 7468 6520 6272 6964 6765 when the bridge\n-0002a630: 2074 6572 6d69 6e61 7465 730a 2020 2020 terminates. \n-0002a640: 2020 2020 6465 6620 7072 6565 7865 635f def preexec_\n-0002a650: 666e 2829 202d 3e20 4e6f 6e65 3a0a 2020 fn() -> None:. \n-0002a660: 2020 2020 2020 2020 2020 7072 6374 6c28 prctl(\n-0002a670: 5345 545f 5044 4541 5448 5349 472c 2073 SET_PDEATHSIG, s\n-0002a680: 6967 6e61 6c2e 5349 4754 4552 4d29 0a20 ignal.SIGTERM). \n-0002a690: 2020 2020 2020 2020 2020 2069 6620 7074 if pt\n-0002a6a0: 793a 0a20 2020 2020 2020 2020 2020 2020 y:. \n-0002a6b0: 2020 2066 636e 746c 2e69 6f63 746c 2830 fcntl.ioctl(0\n-0002a6c0: 2c20 7465 726d 696f 732e 5449 4f43 5343 , termios.TIOCSC\n-0002a6d0: 5454 592c 2030 290a 0a20 2020 2020 2020 TTY, 0).. \n-0002a6e0: 2069 6620 7074 793a 0a20 2020 2020 2020 if pty:. \n-0002a6f0: 2020 2020 2073 656c 662e 5f70 7479 5f66 self._pty_f\n-0002a700: 642c 2073 6573 7369 6f6e 5f66 6420 3d20 d, session_fd = \n-0002a710: 6f73 2e6f 7065 6e70 7479 2829 0a0a 2020 os.openpty().. \n-0002a720: 2020 2020 2020 2020 2020 6966 2077 696e if win\n-0002a730: 646f 7720 6973 206e 6f74 204e 6f6e 653a dow is not None:\n-0002a740: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-0002a750: 2073 656c 662e 7365 745f 7769 6e64 6f77 self.set_window\n-0002a760: 5f73 697a 6528 7769 6e64 6f77 290a 0a20 _size(window).. \n-0002a770: 2020 2020 2020 2020 2020 206b 7761 7267 kwarg\n-0002a780: 735b 2773 7464 6572 7227 5d20 3d20 7365 s['stderr'] = se\n-0002a790: 7373 696f 6e5f 6664 0a20 2020 2020 2020 ssion_fd. \n-0002a7a0: 2020 2020 2073 656c 662e 5f70 726f 6365 self._proce\n-0002a7b0: 7373 203d 2073 7562 7072 6f63 6573 732e ss = subprocess.\n-0002a7c0: 506f 7065 6e28 6172 6773 2c0a 2020 2020 Popen(args,. \n-0002a7d0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0002a7e0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0002a7f0: 2020 2020 2020 2020 2073 7464 696e 3d73 stdin=s\n-0002a800: 6573 7369 6f6e 5f66 642c 2073 7464 6f75 ession_fd, stdou\n-0002a810: 743d 7365 7373 696f 6e5f 6664 2c0a 2020 t=session_fd,. \n-0002a820: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0002a830: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0002a840: 2020 2020 2020 2020 2020 2070 7265 6578 preex\n-0002a850: 6563 5f66 6e3d 7072 6565 7865 635f 666e ec_fn=preexec_fn\n-0002a860: 2c20 7374 6172 745f 6e65 775f 7365 7373 , start_new_sess\n-0002a870: 696f 6e3d 5472 7565 2c20 2a2a 6b77 6172 ion=True, **kwar\n-0002a880: 6773 290a 2020 2020 2020 2020 2020 2020 gs). \n-0002a890: 6f73 2e63 6c6f 7365 2873 6573 7369 6f6e os.close(session\n-0002a8a0: 5f66 6429 0a0a 2020 2020 2020 2020 2020 _fd).. \n-0002a8b0: 2020 696e 5f66 642c 206f 7574 5f66 6420 in_fd, out_fd \n-0002a8c0: 3d20 7365 6c66 2e5f 7074 795f 6664 2c20 = self._pty_fd, \n-0002a8d0: 7365 6c66 2e5f 7074 795f 6664 0a20 2020 self._pty_fd. \n-0002a8e0: 2020 2020 2020 2020 2073 656c 662e 5f65 self._e\n-0002a8f0: 696f 5f69 735f 656f 6620 3d20 5472 7565 io_is_eof = True\n-0002a900: 0a0a 2020 2020 2020 2020 656c 7365 3a0a .. else:.\n-0002a910: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n-0002a920: 2e5f 7072 6f63 6573 7320 3d20 7375 6270 ._process = subp\n-0002a930: 726f 6365 7373 2e50 6f70 656e 2861 7267 rocess.Popen(arg\n-0002a940: 732c 2073 7464 696e 3d73 7562 7072 6f63 s, stdin=subproc\n-0002a950: 6573 732e 5049 5045 2c20 7374 646f 7574 ess.PIPE, stdout\n-0002a960: 3d73 7562 7072 6f63 6573 732e 5049 5045 =subprocess.PIPE\n-0002a970: 2c0a 2020 2020 2020 2020 2020 2020 2020 ,. \n-0002a980: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0002a990: 2020 2020 2020 2020 2020 2020 2020 2070 p\n-0002a9a0: 7265 6578 6563 5f66 6e3d 7072 6565 7865 reexec_fn=preexe\n-0002a9b0: 635f 666e 2c20 2a2a 6b77 6172 6773 290a c_fn, **kwargs).\n-0002a9c0: 2020 2020 2020 2020 2020 2020 6173 7365 asse\n-0002a9d0: 7274 2073 656c 662e 5f70 726f 6365 7373 rt self._process\n-0002a9e0: 2e73 7464 696e 0a20 2020 2020 2020 2020 .stdin. \n-0002a9f0: 2020 2061 7373 6572 7420 7365 6c66 2e5f assert self._\n-0002aa00: 7072 6f63 6573 732e 7374 646f 7574 0a20 process.stdout. \n-0002aa10: 2020 2020 2020 2020 2020 2069 6e5f 6664 in_fd\n-0002aa20: 203d 2073 656c 662e 5f70 726f 6365 7373 = self._process\n-0002aa30: 2e73 7464 6f75 742e 6669 6c65 6e6f 2829 .stdout.fileno()\n-0002aa40: 0a20 2020 2020 2020 2020 2020 206f 7574 . out\n-0002aa50: 5f66 6420 3d20 7365 6c66 2e5f 7072 6f63 _fd = self._proc\n-0002aa60: 6573 732e 7374 6469 6e2e 6669 6c65 6e6f ess.stdin.fileno\n-0002aa70: 2829 0a0a 2020 2020 2020 2020 6966 2073 ().. if s\n-0002aa80: 656c 662e 5f70 726f 6365 7373 2e73 7464 elf._process.std\n-0002aa90: 6572 7220 6973 206e 6f74 204e 6f6e 653a err is not None:\n-0002aaa0: 0a20 2020 2020 2020 2020 2020 2073 656c . sel\n-0002aab0: 662e 5f73 7464 6572 7220 3d20 5370 6f6f f._stderr = Spoo\n-0002aac0: 6c65 7228 6c6f 6f70 2c20 7365 6c66 2e5f ler(loop, self._\n-0002aad0: 7072 6f63 6573 732e 7374 6465 7272 2e66 process.stderr.f\n-0002aae0: 696c 656e 6f28 2929 0a20 2020 2020 2020 ileno()). \n-0002aaf0: 2065 6c73 653a 0a20 2020 2020 2020 2020 else:. \n-0002ab00: 2020 2073 656c 662e 5f73 7464 6572 7220 self._stderr \n-0002ab10: 3d20 4e6f 6e65 0a0a 2020 2020 2020 2020 = None.. \n-0002ab20: 7375 7065 7228 292e 5f5f 696e 6974 5f5f super().__init__\n-0002ab30: 286c 6f6f 702c 2070 726f 746f 636f 6c2c (loop, protocol,\n-0002ab40: 2069 6e5f 6664 2c20 6f75 745f 6664 290a in_fd, out_fd).\n-0002ab50: 0a20 2020 2020 2020 2073 656c 662e 5f67 . self._g\n-0002ab60: 6574 5f77 6174 6368 6572 286c 6f6f 7029 et_watcher(loop)\n-0002ab70: 2e61 6464 5f63 6869 6c64 5f68 616e 646c .add_child_handl\n-0002ab80: 6572 2873 656c 662e 5f70 726f 6365 7373 er(self._process\n-0002ab90: 2e70 6964 2c20 7365 6c66 2e5f 6578 6974 .pid, self._exit\n-0002aba0: 6564 290a 0a20 2020 2064 6566 2073 6574 ed).. def set\n-0002abb0: 5f77 696e 646f 775f 7369 7a65 2873 656c _window_size(sel\n-0002abc0: 662c 2073 697a 653a 2057 696e 646f 7753 f, size: WindowS\n-0002abd0: 697a 6529 202d 3e20 4e6f 6e65 3a0a 2020 ize) -> None:. \n-0002abe0: 2020 2020 2020 6173 7365 7274 2073 656c assert sel\n-0002abf0: 662e 5f70 7479 5f66 6420 6973 206e 6f74 f._pty_fd is not\n-0002ac00: 204e 6f6e 650a 2020 2020 2020 2020 6663 None. fc\n-0002ac10: 6e74 6c2e 696f 6374 6c28 7365 6c66 2e5f ntl.ioctl(self._\n-0002ac20: 7074 795f 6664 2c20 7465 726d 696f 732e pty_fd, termios.\n-0002ac30: 5449 4f43 5357 494e 535a 2c20 7374 7275 TIOCSWINSZ, stru\n-0002ac40: 6374 2e70 6163 6b28 2732 4834 7827 2c20 ct.pack('2H4x', \n-0002ac50: 7369 7a65 2e72 6f77 732c 2073 697a 652e size.rows, size.\n-0002ac60: 636f 6c73 2929 0a0a 2020 2020 6465 6620 cols)).. def \n-0002ac70: 6361 6e5f 7772 6974 655f 656f 6628 7365 can_write_eof(se\n-0002ac80: 6c66 2920 2d3e 2062 6f6f 6c3a 0a20 2020 lf) -> bool:. \n-0002ac90: 2020 2020 2061 7373 6572 7420 7365 6c66 assert self\n-0002aca0: 2e5f 7072 6f63 6573 7320 6973 206e 6f74 ._process is not\n-0002acb0: 204e 6f6e 650a 2020 2020 2020 2020 7265 None. re\n-0002acc0: 7475 726e 2073 656c 662e 5f70 726f 6365 turn self._proce\n-0002acd0: 7373 2e73 7464 696e 2069 7320 6e6f 7420 ss.stdin is not \n-0002ace0: 4e6f 6e65 0a0a 2020 2020 6465 6620 5f77 None.. def _w\n-0002acf0: 7269 7465 5f65 6f66 5f6e 6f77 2873 656c rite_eof_now(sel\n-0002ad00: 6629 202d 3e20 4e6f 6e65 3a0a 2020 2020 f) -> None:. \n-0002ad10: 2020 2020 6173 7365 7274 2073 656c 662e assert self.\n-0002ad20: 5f70 726f 6365 7373 2069 7320 6e6f 7420 _process is not \n-0002ad30: 4e6f 6e65 0a20 2020 2020 2020 2061 7373 None. ass\n-0002ad40: 6572 7420 7365 6c66 2e5f 7072 6f63 6573 ert self._proces\n-0002ad50: 732e 7374 6469 6e20 6973 206e 6f74 204e s.stdin is not N\n-0002ad60: 6f6e 650a 2020 2020 2020 2020 7365 6c66 one. self\n-0002ad70: 2e5f 7072 6f63 6573 732e 7374 6469 6e2e ._process.stdin.\n-0002ad80: 636c 6f73 6528 290a 2020 2020 2020 2020 close(). \n-0002ad90: 7365 6c66 2e5f 6f75 745f 6664 203d 202d self._out_fd = -\n-0002ada0: 310a 0a20 2020 2064 6566 2067 6574 5f70 1.. def get_p\n-0002adb0: 6964 2873 656c 6629 202d 3e20 696e 743a id(self) -> int:\n-0002adc0: 0a20 2020 2020 2020 2061 7373 6572 7420 . assert \n-0002add0: 7365 6c66 2e5f 7072 6f63 6573 7320 6973 self._process is\n-0002ade0: 206e 6f74 204e 6f6e 650a 2020 2020 2020 not None. \n-0002adf0: 2020 7265 7475 726e 2073 656c 662e 5f70 return self._p\n-0002ae00: 726f 6365 7373 2e70 6964 0a0a 2020 2020 rocess.pid.. \n-0002ae10: 6465 6620 6765 745f 7265 7475 726e 636f def get_returnco\n-0002ae20: 6465 2873 656c 6629 202d 3e20 2769 6e74 de(self) -> 'int\n-0002ae30: 207c 204e 6f6e 6527 3a0a 2020 2020 2020 | None':. \n-0002ae40: 2020 7265 7475 726e 2073 656c 662e 5f72 return self._r\n-0002ae50: 6574 7572 6e63 6f64 650a 0a20 2020 2064 eturncode.. d\n-0002ae60: 6566 2067 6574 5f70 6970 655f 7472 616e ef get_pipe_tran\n-0002ae70: 7370 6f72 7428 7365 6c66 2c20 6664 3a20 sport(self, fd: \n-0002ae80: 696e 7429 202d 3e20 6173 796e 6369 6f2e int) -> asyncio.\n-0002ae90: 5472 616e 7370 6f72 743a 0a20 2020 2020 Transport:. \n-0002aea0: 2020 2072 6169 7365 204e 6f74 496d 706c raise NotImpl\n-0002aeb0: 656d 656e 7465 6445 7272 6f72 0a0a 2020 ementedError.. \n-0002aec0: 2020 6465 6620 7365 6e64 5f73 6967 6e61 def send_signa\n-0002aed0: 6c28 7365 6c66 2c20 7369 673a 2073 6967 l(self, sig: sig\n-0002aee0: 6e61 6c2e 5369 676e 616c 7329 202d 3e20 nal.Signals) -> \n-0002aef0: 4e6f 6e65 3a20 2023 2074 7970 653a 2069 None: # type: i\n-0002af00: 676e 6f72 655b 6f76 6572 7269 6465 5d20 gnore[override] \n-0002af10: 2320 6d79 7079 2f69 7373 7565 732f 3133 # mypy/issues/13\n-0002af20: 3838 350a 2020 2020 2020 2020 6173 7365 885. asse\n-0002af30: 7274 2073 656c 662e 5f70 726f 6365 7373 rt self._process\n-0002af40: 2069 7320 6e6f 7420 4e6f 6e65 0a20 2020 is not None. \n-0002af50: 2020 2020 2023 2057 6520 7472 7920 746f # We try to\n-0002af60: 2061 766f 6964 2075 7369 6e67 2073 7562 avoid using sub\n-0002af70: 7072 6f63 6573 732e 7365 6e64 5f73 6967 process.send_sig\n-0002af80: 6e61 6c28 292e 2020 4974 2063 6f6e 7461 nal(). It conta\n-0002af90: 696e 7320 6120 6361 6c6c 0a20 2020 2020 ins a call. \n-0002afa0: 2020 2023 2074 6f20 7761 6974 7069 6428 # to waitpid(\n-0002afb0: 2920 696e 7465 726e 616c 6c79 2074 6f20 ) internally to \n-0002afc0: 6176 6f69 6420 7369 676e 616c 6c69 6e67 avoid signalling\n-0002afd0: 2074 6865 2077 726f 6e67 2070 726f 6365 the wrong proce\n-0002afe0: 7373 2028 6966 2061 0a20 2020 2020 2020 ss (if a. \n-0002aff0: 2023 2050 4944 2067 6574 7320 7265 7573 # PID gets reus\n-0002b000: 6564 292c 2062 7574 3a0a 2020 2020 2020 ed), but:. \n-0002b010: 2020 230a 2020 2020 2020 2020 2320 202d #. # -\n-0002b020: 2077 6520 616c 7265 6164 7920 6465 7465 we already dete\n-0002b030: 6374 2074 6865 2070 726f 6365 7373 2065 ct the process e\n-0002b040: 7869 7469 6e67 2076 6961 206f 7572 2050 xiting via our P\n-0002b050: 6964 6664 4368 696c 6457 6174 6368 6572 idfdChildWatcher\n-0002b060: 0a20 2020 2020 2020 2023 0a20 2020 2020 . #. \n-0002b070: 2020 2023 2020 2d20 7468 6520 6368 6563 # - the chec\n-0002b080: 6b20 6973 2061 6374 7561 6c6c 7920 6861 k is actually ha\n-0002b090: 726d 6675 6c20 7369 6e63 6520 636f 6c6c rmful since coll\n-0002b0a0: 6563 7469 6e67 2074 6865 2070 726f 6365 ecting the proce\n-0002b0b0: 7373 2076 6961 0a20 2020 2020 2020 2023 ss via. #\n-0002b0c0: 2020 2020 7761 6974 7069 6428 2920 7072 waitpid() pr\n-0002b0d0: 6576 656e 7473 2074 6865 2050 6964 6664 events the Pidfd\n-0002b0e0: 4368 696c 6457 6174 6368 6572 2066 726f ChildWatcher fro\n-0002b0f0: 6d20 646f 696e 6720 7468 6520 7361 6d65 m doing the same\n-0002b100: 2c0a 2020 2020 2020 2020 2320 2020 2072 ,. # r\n-0002b110: 6573 756c 7469 6e67 2069 6e20 616e 2065 esulting in an e\n-0002b120: 7272 6f72 2e0a 2020 2020 2020 2020 230a rror.. #.\n-0002b130: 2020 2020 2020 2020 2320 4974 2773 206f # It's o\n-0002b140: 6e20 7573 206e 6f77 2074 6f20 6368 6563 n us now to chec\n-0002b150: 6b20 6974 2c20 6275 7420 7468 6174 2773 k it, but that's\n-0002b160: 2065 6173 793a 0a20 2020 2020 2020 2069 easy:. i\n-0002b170: 6620 7365 6c66 2e5f 7265 7475 726e 636f f self._returnco\n-0002b180: 6465 2069 7320 6e6f 7420 4e6f 6e65 3a0a de is not None:.\n-0002b190: 2020 2020 2020 2020 2020 2020 6c6f 6767 logg\n-0002b1a0: 6572 2e64 6562 7567 2822 776f 6e27 7420 er.debug(\"won't \n-0002b1b0: 6174 7465 6d70 7420 2573 2074 6f20 7072 attempt %s to pr\n-0002b1c0: 6f63 6573 7320 2569 2e20 2049 7420 6578 ocess %i. It ex\n-0002b1d0: 6974 6564 2061 6c72 6561 6479 2e22 2c20 ited already.\", \n-0002b1e0: 7369 672c 2073 656c 662e 5f70 726f 6365 sig, self._proce\n-0002b1f0: 7373 2e70 6964 290a 2020 2020 2020 2020 ss.pid). \n-0002b200: 2020 2020 7265 7475 726e 0a0a 2020 2020 return.. \n-0002b210: 2020 2020 7472 793a 0a20 2020 2020 2020 try:. \n-0002b220: 2020 2020 206f 732e 6b69 6c6c 2873 656c os.kill(sel\n-0002b230: 662e 5f70 726f 6365 7373 2e70 6964 2c20 f._process.pid, \n-0002b240: 7369 6729 0a20 2020 2020 2020 2020 2020 sig). \n-0002b250: 206c 6f67 6765 722e 6465 6275 6728 2773 logger.debug('s\n-0002b260: 656e 7420 2573 2074 6f20 7072 6f63 6573 ent %s to proces\n-0002b270: 7320 2569 272c 2073 6967 2c20 7365 6c66 s %i', sig, self\n-0002b280: 2e5f 7072 6f63 6573 732e 7069 6429 0a20 ._process.pid). \n-0002b290: 2020 2020 2020 2065 7863 6570 7420 5072 except Pr\n-0002b2a0: 6f63 6573 734c 6f6f 6b75 7045 7272 6f72 ocessLookupError\n-0002b2b0: 3a0a 2020 2020 2020 2020 2020 2020 2320 :. # \n-0002b2c0: 616c 7265 6164 7920 676f 6e65 3f20 6669 already gone? fi\n-0002b2d0: 6e65 0a20 2020 2020 2020 2020 2020 206c ne. l\n-0002b2e0: 6f67 6765 722e 6465 6275 6728 2263 616e ogger.debug(\"can\n-0002b2f0: 2774 2073 656e 6420 2573 2074 6f20 7072 't send %s to pr\n-0002b300: 6f63 6573 7320 2569 2e20 2049 7427 7320 ocess %i. It's \n-0002b310: 6578 6974 6564 206a 7573 7420 6e6f 772e exited just now.\n-0002b320: 222c 2073 6967 2c20 7365 6c66 2e5f 7072 \", sig, self._pr\n-0002b330: 6f63 6573 732e 7069 6429 0a0a 2020 2020 ocess.pid).. \n-0002b340: 6465 6620 7465 726d 696e 6174 6528 7365 def terminate(se\n-0002b350: 6c66 2920 2d3e 204e 6f6e 653a 0a20 2020 lf) -> None:. \n-0002b360: 2020 2020 2073 656c 662e 7365 6e64 5f73 self.send_s\n-0002b370: 6967 6e61 6c28 7369 676e 616c 2e53 4947 ignal(signal.SIG\n-0002b380: 5445 524d 290a 0a20 2020 2064 6566 206b TERM).. def k\n-0002b390: 696c 6c28 7365 6c66 2920 2d3e 204e 6f6e ill(self) -> Non\n-0002b3a0: 653a 0a20 2020 2020 2020 2073 656c 662e e:. self.\n-0002b3b0: 7365 6e64 5f73 6967 6e61 6c28 7369 676e send_signal(sign\n-0002b3c0: 616c 2e53 4947 4b49 4c4c 290a 0a20 2020 al.SIGKILL).. \n-0002b3d0: 2064 6566 205f 636c 6f73 6528 7365 6c66 def _close(self\n-0002b3e0: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n-0002b3f0: 2020 2069 6620 7365 6c66 2e5f 7074 795f if self._pty_\n-0002b400: 6664 2069 7320 6e6f 7420 4e6f 6e65 3a0a fd is not None:.\n-0002b410: 2020 2020 2020 2020 2020 2020 6f73 2e63 os.c\n-0002b420: 6c6f 7365 2873 656c 662e 5f70 7479 5f66 lose(self._pty_f\n-0002b430: 6429 0a20 2020 2020 2020 2020 2020 2073 d). s\n-0002b440: 656c 662e 5f70 7479 5f66 6420 3d20 4e6f elf._pty_fd = No\n-0002b450: 6e65 0a0a 2020 2020 2020 2020 6966 2073 ne.. if s\n-0002b460: 656c 662e 5f70 726f 6365 7373 2069 7320 elf._process is \n-0002b470: 6e6f 7420 4e6f 6e65 3a0a 2020 2020 2020 not None:. \n-0002b480: 2020 2020 2020 6966 2073 656c 662e 5f70 if self._p\n-0002b490: 726f 6365 7373 2e73 7464 696e 2069 7320 rocess.stdin is \n-0002b4a0: 6e6f 7420 4e6f 6e65 3a0a 2020 2020 2020 not None:. \n-0002b4b0: 2020 2020 2020 2020 2020 7365 6c66 2e5f self._\n-0002b4c0: 7072 6f63 6573 732e 7374 6469 6e2e 636c process.stdin.cl\n-0002b4d0: 6f73 6528 290a 2020 2020 2020 2020 2020 ose(). \n-0002b4e0: 2020 2020 2020 7365 6c66 2e5f 7072 6f63 self._proc\n-0002b4f0: 6573 732e 7374 6469 6e20 3d20 4e6f 6e65 ess.stdin = None\n-0002b500: 0a20 2020 2020 2020 2020 2020 2074 7279 . try\n-0002b510: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n-0002b520: 2020 7365 6c66 2e74 6572 6d69 6e61 7465 self.terminate\n-0002b530: 2829 2020 2320 6265 7374 2065 6666 6f72 () # best effor\n-0002b540: 742e 2e2e 0a20 2020 2020 2020 2020 2020 t.... \n-0002b550: 2065 7863 6570 7420 5065 726d 6973 7369 except Permissi\n-0002b560: 6f6e 4572 726f 723a 0a20 2020 2020 2020 onError:. \n-0002b570: 2020 2020 2020 2020 206c 6f67 6765 722e logger.\n-0002b580: 6465 6275 6728 2263 616e 2774 206b 696c debug(\"can't kil\n-0002b590: 6c20 2569 2064 7565 2074 6f20 4550 4552 l %i due to EPER\n-0002b5a0: 4d22 2c20 7365 6c66 2e5f 7072 6f63 6573 M\", self._proces\n-0002b5b0: 732e 7069 6429 0a0a 0a63 6c61 7373 2053 s.pid)...class S\n-0002b5c0: 7464 696f 5472 616e 7370 6f72 7428 5f54 tdioTransport(_T\n-0002b5d0: 7261 6e73 706f 7274 293a 0a20 2020 2022 ransport):. \"\n-0002b5e0: 2222 4120 6269 2d64 6972 6563 7469 6f6e \"\"A bi-direction\n-0002b5f0: 616c 2074 7261 6e73 706f 7274 2074 6861 al transport tha\n-0002b600: 7420 636f 7272 6573 706f 6e64 7320 746f t corresponds to\n-0002b610: 2073 7464 696e 2f6f 7574 2e0a 0a20 2020 stdin/out... \n-0002b620: 2043 616e 2074 616c 6b20 746f 206a 7573 Can talk to jus\n-0002b630: 7420 6162 6f75 7420 616e 7974 6869 6e67 t about anything\n-0002b640: 3a0a 2020 2020 2020 2020 2d20 6669 6c65 :. - file\n-0002b650: 730a 2020 2020 2020 2020 2d20 7069 7065 s. - pipe\n-0002b660: 730a 2020 2020 2020 2020 2d20 6368 6172 s. - char\n-0002b670: 6163 7465 7220 6465 7669 6365 7320 2869 acter devices (i\n-0002b680: 6e63 6c75 6469 6e67 2074 6572 6d69 6e61 ncluding termina\n-0002b690: 6c73 290a 2020 2020 2020 2020 2d20 736f ls). - so\n-0002b6a0: 636b 6574 730a 2020 2020 2222 220a 0a20 ckets. \"\"\".. \n-0002b6b0: 2020 2064 6566 205f 5f69 6e69 745f 5f28 def __init__(\n-0002b6c0: 7365 6c66 2c20 6c6f 6f70 3a20 6173 796e self, loop: asyn\n-0002b6d0: 6369 6f2e 4162 7374 7261 6374 4576 656e cio.AbstractEven\n-0002b6e0: 744c 6f6f 702c 2070 726f 746f 636f 6c3a tLoop, protocol:\n-0002b6f0: 2061 7379 6e63 696f 2e50 726f 746f 636f asyncio.Protoco\n-0002b700: 6c2c 2073 7464 696e 3a20 696e 7420 3d20 l, stdin: int = \n-0002b710: 302c 2073 7464 6f75 743a 2069 6e74 203d 0, stdout: int =\n-0002b720: 2031 293a 0a20 2020 2020 2020 2073 7570 1):. sup\n-0002b730: 6572 2829 2e5f 5f69 6e69 745f 5f28 6c6f er().__init__(lo\n-0002b740: 6f70 2c20 7072 6f74 6f63 6f6c 2c20 7374 op, protocol, st\n-0002b750: 6469 6e2c 2073 7464 6f75 7429 0a0a 2020 din, stdout).. \n-0002b760: 2020 6465 6620 6361 6e5f 7772 6974 655f def can_write_\n-0002b770: 656f 6628 7365 6c66 2920 2d3e 2062 6f6f eof(self) -> boo\n-0002b780: 6c3a 0a20 2020 2020 2020 2072 6574 7572 l:. retur\n-0002b790: 6e20 4661 6c73 650a 0a20 2020 2064 6566 n False.. def\n-0002b7a0: 205f 7772 6974 655f 656f 665f 6e6f 7728 _write_eof_now(\n-0002b7b0: 7365 6c66 2920 2d3e 204e 6f6e 653a 0a20 self) -> None:. \n-0002b7c0: 2020 2020 2020 2072 6169 7365 2052 756e raise Run\n-0002b7d0: 7469 6d65 4572 726f 7228 2243 616e 2774 timeError(\"Can't\n-0002b7e0: 2077 7269 7465 2045 4f46 2074 6f20 7374 write EOF to st\n-0002b7f0: 646f 7574 2229 0a0a 0a63 6c61 7373 2053 dout\")...class S\n-0002b800: 706f 6f6c 6572 3a0a 2020 2020 2222 2243 pooler:. \"\"\"C\n-0002b810: 6f6e 7375 6d65 7320 6461 7461 2066 726f onsumes data fro\n-0002b820: 6d20 616e 2066 642c 2073 746f 7269 6e67 m an fd, storing\n-0002b830: 2069 7420 696e 2061 2062 7566 6665 722e it in a buffer.\n-0002b840: 0a0a 2020 2020 5468 6973 206d 616b 6573 .. This makes\n-0002b850: 2061 2063 6f70 7920 6f66 2074 6865 2066 a copy of the f\n-0002b860: 642c 2073 6f20 796f 7520 646f 6e27 7420 d, so you don't \n-0002b870: 6861 7665 2074 6f20 776f 7272 7920 6162 have to worry ab\n-0002b880: 6f75 7420 686f 6c64 696e 6720 6974 0a20 out holding it. \n-0002b890: 2020 206f 7065 6e2e 0a20 2020 2022 2222 open.. \"\"\"\n-0002b8a0: 0a0a 2020 2020 5f6c 6f6f 703a 2061 7379 .. _loop: asy\n-0002b8b0: 6e63 696f 2e41 6273 7472 6163 7445 7665 ncio.AbstractEve\n-0002b8c0: 6e74 4c6f 6f70 0a20 2020 205f 6664 3a20 ntLoop. _fd: \n-0002b8d0: 696e 740a 2020 2020 5f63 6f6e 7465 6e74 int. _content\n-0002b8e0: 733a 2027 6c69 7374 5b62 7974 6573 5d27 s: 'list[bytes]'\n-0002b8f0: 0a0a 2020 2020 6465 6620 5f5f 696e 6974 .. def __init\n-0002b900: 5f5f 2873 656c 662c 206c 6f6f 703a 2061 __(self, loop: a\n-0002b910: 7379 6e63 696f 2e41 6273 7472 6163 7445 syncio.AbstractE\n-0002b920: 7665 6e74 4c6f 6f70 2c20 6664 3a20 696e ventLoop, fd: in\n-0002b930: 7429 3a0a 2020 2020 2020 2020 7365 6c66 t):. self\n-0002b940: 2e5f 6c6f 6f70 203d 206c 6f6f 700a 2020 ._loop = loop. \n-0002b950: 2020 2020 2020 7365 6c66 2e5f 6664 203d self._fd =\n-0002b960: 202d 3120 2023 2069 6e20 6361 7365 2064 -1 # in case d\n-0002b970: 7570 2829 2072 6169 7365 7320 616e 2065 up() raises an e\n-0002b980: 7863 6570 7469 6f6e 0a20 2020 2020 2020 xception. \n-0002b990: 2073 656c 662e 5f63 6f6e 7465 6e74 7320 self._contents \n-0002b9a0: 3d20 5b5d 0a0a 2020 2020 2020 2020 7365 = [].. se\n-0002b9b0: 6c66 2e5f 6664 203d 206f 732e 6475 7028 lf._fd = os.dup(\n-0002b9c0: 6664 290a 0a20 2020 2020 2020 206f 732e fd).. os.\n-0002b9d0: 7365 745f 626c 6f63 6b69 6e67 2873 656c set_blocking(sel\n-0002b9e0: 662e 5f66 642c 2046 616c 7365 290a 2020 f._fd, False). \n-0002b9f0: 2020 2020 2020 6c6f 6f70 2e61 6464 5f72 loop.add_r\n-0002ba00: 6561 6465 7228 7365 6c66 2e5f 6664 2c20 eader(self._fd, \n-0002ba10: 7365 6c66 2e5f 7265 6164 5f72 6561 6479 self._read_ready\n-0002ba20: 290a 0a20 2020 2064 6566 205f 7265 6164 ).. def _read\n-0002ba30: 5f72 6561 6479 2873 656c 6629 202d 3e20 _ready(self) -> \n-0002ba40: 4e6f 6e65 3a0a 2020 2020 2020 2020 7472 None:. tr\n-0002ba50: 793a 0a20 2020 2020 2020 2020 2020 2064 y:. d\n-0002ba60: 6174 6120 3d20 6f73 2e72 6561 6428 7365 ata = os.read(se\n-0002ba70: 6c66 2e5f 6664 2c20 3831 3932 290a 2020 lf._fd, 8192). \n-0002ba80: 2020 2020 2020 6578 6365 7074 2042 6c6f except Blo\n-0002ba90: 636b 696e 6749 4f45 7272 6f72 3a20 2023 ckingIOError: #\n-0002baa0: 2070 7261 676d 613a 206e 6f20 636f 7665 pragma: no cove\n-0002bab0: 720a 2020 2020 2020 2020 2020 2020 7265 r. re\n-0002bac0: 7475 726e 0a20 2020 2020 2020 2065 7863 turn. exc\n-0002bad0: 6570 7420 4f53 4572 726f 723a 0a20 2020 ept OSError:. \n-0002bae0: 2020 2020 2020 2020 2023 2061 6c6c 206f # all o\n-0002baf0: 7468 6572 2065 7272 6f72 7320 2d3e 2045 ther errors -> E\n-0002bb00: 4f46 0a20 2020 2020 2020 2020 2020 2064 OF. d\n-0002bb10: 6174 6120 3d20 6227 270a 0a20 2020 2020 ata = b''.. \n-0002bb20: 2020 2069 6620 6461 7461 2021 3d20 6227 if data != b'\n-0002bb30: 273a 0a20 2020 2020 2020 2020 2020 2073 ':. s\n-0002bb40: 656c 662e 5f63 6f6e 7465 6e74 732e 6170 elf._contents.ap\n-0002bb50: 7065 6e64 2864 6174 6129 0a20 2020 2020 pend(data). \n-0002bb60: 2020 2065 6c73 653a 0a20 2020 2020 2020 else:. \n-0002bb70: 2020 2020 2073 656c 662e 636c 6f73 6528 self.close(\n-0002bb80: 290a 0a20 2020 2064 6566 205f 6973 5f72 ).. def _is_r\n-0002bb90: 6561 6479 2873 656c 6629 202d 3e20 626f eady(self) -> bo\n-0002bba0: 6f6c 3a0a 2020 2020 2020 2020 6966 2073 ol:. if s\n-0002bbb0: 656c 662e 5f66 6420 3d3d 202d 313a 0a20 elf._fd == -1:. \n-0002bbc0: 2020 2020 2020 2020 2020 2072 6574 7572 retur\n-0002bbd0: 6e20 4661 6c73 650a 2020 2020 2020 2020 n False. \n-0002bbe0: 7265 7475 726e 2073 656c 6563 742e 7365 return select.se\n-0002bbf0: 6c65 6374 285b 7365 6c66 2e5f 6664 5d2c lect([self._fd],\n-0002bc00: 205b 5d2c 205b 5d2c 2030 2920 213d 2028 [], [], 0) != (\n-0002bc10: 5b5d 2c20 5b5d 2c20 5b5d 290a 0a20 2020 [], [], []).. \n-0002bc20: 2064 6566 2067 6574 2873 656c 662c 202a def get(self, *\n-0002bc30: 2c20 7265 7365 743a 2062 6f6f 6c20 3d20 , reset: bool = \n-0002bc40: 4661 6c73 6529 202d 3e20 6279 7465 733a False) -> bytes:\n-0002bc50: 0a20 2020 2020 2020 2077 6869 6c65 2073 . while s\n-0002bc60: 656c 662e 5f69 735f 7265 6164 7928 293a elf._is_ready():\n-0002bc70: 0a20 2020 2020 2020 2020 2020 2073 656c . sel\n-0002bc80: 662e 5f72 6561 645f 7265 6164 7928 290a f._read_ready().\n-0002bc90: 0a20 2020 2020 2020 2072 6573 756c 7420 . result \n-0002bca0: 3d20 6227 272e 6a6f 696e 2873 656c 662e = b''.join(self.\n-0002bcb0: 5f63 6f6e 7465 6e74 7329 0a20 2020 2020 _contents). \n-0002bcc0: 2020 2069 6620 7265 7365 743a 0a20 2020 if reset:. \n-0002bcd0: 2020 2020 2020 2020 2073 656c 662e 5f63 self._c\n-0002bce0: 6f6e 7465 6e74 7320 3d20 5b5d 0a20 2020 ontents = []. \n-0002bcf0: 2020 2020 2072 6574 7572 6e20 7265 7375 return resu\n-0002bd00: 6c74 0a0a 2020 2020 6465 6620 636c 6f73 lt.. def clos\n-0002bd10: 6528 7365 6c66 2920 2d3e 204e 6f6e 653a e(self) -> None:\n-0002bd20: 0a20 2020 2020 2020 2069 6620 7365 6c66 . if self\n-0002bd30: 2e5f 6664 2021 3d20 2d31 3a0a 2020 2020 ._fd != -1:. \n-0002bd40: 2020 2020 2020 2020 7365 6c66 2e5f 6c6f self._lo\n-0002bd50: 6f70 2e72 656d 6f76 655f 7265 6164 6572 op.remove_reader\n-0002bd60: 2873 656c 662e 5f66 6429 0a20 2020 2020 (self._fd). \n-0002bd70: 2020 2020 2020 206f 732e 636c 6f73 6528 os.close(\n-0002bd80: 7365 6c66 2e5f 6664 290a 2020 2020 2020 self._fd). \n-0002bd90: 2020 2020 2020 7365 6c66 2e5f 6664 203d self._fd =\n-0002bda0: 202d 310a 0a20 2020 2064 6566 205f 5f64 -1.. def __d\n-0002bdb0: 656c 5f5f 2873 656c 6629 202d 3e20 4e6f el__(self) -> No\n-0002bdc0: 6e65 3a0a 2020 2020 2020 2020 7365 6c66 ne:. self\n-0002bdd0: 2e63 6c6f 7365 2829 0a27 2727 2c0a 2020 .close().''',. \n-0002bde0: 2763 6f63 6b70 6974 2f62 6569 7061 636b 'cockpit/beipack\n-0002bdf0: 2e70 7927 3a20 6272 2727 2723 2054 6869 .py': br'''# Thi\n-0002be00: 7320 6669 6c65 2069 7320 7061 7274 206f s file is part o\n-0002be10: 6620 436f 636b 7069 742e 0a23 0a23 2043 f Cockpit..#.# C\n-0002be20: 6f70 7972 6967 6874 2028 4329 2032 3032 opyright (C) 202\n-0002be30: 3320 5265 6420 4861 742c 2049 6e63 2e0a 3 Red Hat, Inc..\n-0002be40: 230a 2320 5468 6973 2070 726f 6772 616d #.# This program\n-0002be50: 2069 7320 6672 6565 2073 6f66 7477 6172 is free softwar\n-0002be60: 653a 2079 6f75 2063 616e 2072 6564 6973 e: you can redis\n-0002be70: 7472 6962 7574 6520 6974 2061 6e64 2f6f tribute it and/o\n-0002be80: 7220 6d6f 6469 6679 0a23 2069 7420 756e r modify.# it un\n-0002be90: 6465 7220 7468 6520 7465 726d 7320 6f66 der the terms of\n-0002bea0: 2074 6865 2047 4e55 2047 656e 6572 616c the GNU General\n-0002beb0: 2050 7562 6c69 6320 4c69 6365 6e73 6520 Public License \n-0002bec0: 6173 2070 7562 6c69 7368 6564 2062 790a as published by.\n-0002bed0: 2320 7468 6520 4672 6565 2053 6f66 7477 # the Free Softw\n-0002bee0: 6172 6520 466f 756e 6461 7469 6f6e 2c20 are Foundation, \n-0002bef0: 6569 7468 6572 2076 6572 7369 6f6e 2033 either version 3\n-0002bf00: 206f 6620 7468 6520 4c69 6365 6e73 652c of the License,\n-0002bf10: 206f 720a 2320 2861 7420 796f 7572 206f or.# (at your o\n-0002bf20: 7074 696f 6e29 2061 6e79 206c 6174 6572 ption) any later\n-0002bf30: 2076 6572 7369 6f6e 2e0a 230a 2320 5468 version..#.# Th\n-0002bf40: 6973 2070 726f 6772 616d 2069 7320 6469 is program is di\n-0002bf50: 7374 7269 6275 7465 6420 696e 2074 6865 stributed in the\n-0002bf60: 2068 6f70 6520 7468 6174 2069 7420 7769 hope that it wi\n-0002bf70: 6c6c 2062 6520 7573 6566 756c 2c0a 2320 ll be useful,.# \n-0002bf80: 6275 7420 5749 5448 4f55 5420 414e 5920 but WITHOUT ANY \n-0002bf90: 5741 5252 414e 5459 3b20 7769 7468 6f75 WARRANTY; withou\n-0002bfa0: 7420 6576 656e 2074 6865 2069 6d70 6c69 t even the impli\n-0002bfb0: 6564 2077 6172 7261 6e74 7920 6f66 0a23 ed warranty of.#\n-0002bfc0: 204d 4552 4348 414e 5441 4249 4c49 5459 MERCHANTABILITY\n-0002bfd0: 206f 7220 4649 544e 4553 5320 464f 5220 or FITNESS FOR \n-0002bfe0: 4120 5041 5254 4943 554c 4152 2050 5552 A PARTICULAR PUR\n-0002bff0: 504f 5345 2e20 2053 6565 2074 6865 0a23 POSE. See the.#\n-0002c000: 2047 4e55 2047 656e 6572 616c 2050 7562 GNU General Pub\n-0002c010: 6c69 6320 4c69 6365 6e73 6520 666f 7220 lic License for \n-0002c020: 6d6f 7265 2064 6574 6169 6c73 2e0a 230a more details..#.\n-0002c030: 2320 596f 7520 7368 6f75 6c64 2068 6176 # You should hav\n-0002c040: 6520 7265 6365 6976 6564 2061 2063 6f70 e received a cop\n-0002c050: 7920 6f66 2074 6865 2047 4e55 2047 656e y of the GNU Gen\n-0002c060: 6572 616c 2050 7562 6c69 6320 4c69 6365 eral Public Lice\n-0002c070: 6e73 650a 2320 616c 6f6e 6720 7769 7468 nse.# along with\n-0002c080: 2074 6869 7320 7072 6f67 7261 6d2e 2020 this program. \n-0002c090: 4966 206e 6f74 2c20 7365 6520 3c68 7474 If not, see ...im\n-0002c0c0: 706f 7274 206c 6f67 6769 6e67 0a69 6d70 port logging.imp\n-0002c0d0: 6f72 7420 6c7a 6d61 0a66 726f 6d20 7479 ort lzma.from ty\n-0002c0e0: 7069 6e67 2069 6d70 6f72 7420 4c69 7374 ping import List\n-0002c0f0: 2c20 5365 7175 656e 6365 2c20 5475 706c , Sequence, Tupl\n-0002c100: 650a 0a66 726f 6d20 636f 636b 7069 742e e..from cockpit.\n-0002c110: 5f76 656e 646f 7220 696d 706f 7274 2066 _vendor import f\n-0002c120: 6572 6e79 0a66 726f 6d20 636f 636b 7069 erny.from cockpi\n-0002c130: 742e 5f76 656e 646f 722e 6265 6920 696d t._vendor.bei im\n-0002c140: 706f 7274 2062 6569 7061 636b 0a0a 6672 port beipack..fr\n-0002c150: 6f6d 202e 6461 7461 2069 6d70 6f72 7420 om .data import \n-0002c160: 7265 6164 5f63 6f63 6b70 6974 5f64 6174 read_cockpit_dat\n-0002c170: 615f 6669 6c65 0a66 726f 6d20 2e70 6565 a_file.from .pee\n-0002c180: 7220 696d 706f 7274 2050 6565 722c 2050 r import Peer, P\n-0002c190: 6565 7245 7272 6f72 0a0a 6c6f 6767 6572 eerError..logger\n-0002c1a0: 203d 206c 6f67 6769 6e67 2e67 6574 4c6f = logging.getLo\n-0002c1b0: 6767 6572 285f 5f6e 616d 655f 5f29 0a0a gger(__name__)..\n-0002c1c0: 0a64 6566 2067 6574 5f62 7269 6467 655f .def get_bridge_\n-0002c1d0: 6265 6970 6163 6b5f 787a 2829 202d 3e20 beipack_xz() -> \n-0002c1e0: 5475 706c 655b 7374 722c 2062 7974 6573 Tuple[str, bytes\n-0002c1f0: 5d3a 0a20 2020 2074 7279 3a0a 2020 2020 ]:. try:. \n-0002c200: 2020 2020 6272 6964 6765 5f62 6569 7061 bridge_beipa\n-0002c210: 636b 5f78 7a20 3d20 7265 6164 5f63 6f63 ck_xz = read_coc\n-0002c220: 6b70 6974 5f64 6174 615f 6669 6c65 2827 kpit_data_file('\n-0002c230: 636f 636b 7069 742d 6272 6964 6765 2e62 cockpit-bridge.b\n-0002c240: 6569 7061 636b 2e78 7a27 290a 2020 2020 eipack.xz'). \n-0002c250: 2020 2020 6c6f 6767 6572 2e64 6562 7567 logger.debug\n-0002c260: 2827 476f 7420 7072 652d 6275 696c 7420 ('Got pre-built \n-0002c270: 636f 636b 7069 742d 6272 6964 6765 2e62 cockpit-bridge.b\n-0002c280: 6569 7061 636b 2e78 7a27 290a 2020 2020 eipack.xz'). \n-0002c290: 6578 6365 7074 2046 696c 654e 6f74 466f except FileNotFo\n-0002c2a0: 756e 6445 7272 6f72 3a0a 2020 2020 2020 undError:. \n-0002c2b0: 2020 6c6f 6767 6572 2e64 6562 7567 2827 logger.debug('\n-0002c2c0: 5072 652d 6275 696c 7420 636f 636b 7069 Pre-built cockpi\n-0002c2d0: 742d 6272 6964 6765 2e62 6569 7061 636b t-bridge.beipack\n-0002c2e0: 2e78 7a3b 2062 7569 6c64 696e 6720 6f75 .xz; building ou\n-0002c2f0: 7220 6f77 6e2e 2729 0a20 2020 2020 2020 r own.'). \n-0002c300: 2023 2062 6569 7061 636b 206f 7572 7365 # beipack ourse\n-0002c310: 6c76 6573 0a20 2020 2020 2020 2063 6f63 lves. coc\n-0002c320: 6b70 6974 5f63 6f6e 7465 6e74 7320 3d20 kpit_contents = \n-0002c330: 6265 6970 6163 6b2e 636f 6c6c 6563 745f beipack.collect_\n-0002c340: 6d6f 6475 6c65 2827 636f 636b 7069 7427 module('cockpit'\n-0002c350: 2c20 7265 6375 7273 6976 653d 5472 7565 , recursive=True\n-0002c360: 290a 2020 2020 2020 2020 6272 6964 6765 ). bridge\n-0002c370: 5f62 6569 7061 636b 203d 2062 6569 7061 _beipack = beipa\n-0002c380: 636b 2e70 6163 6b28 636f 636b 7069 745f ck.pack(cockpit_\n-0002c390: 636f 6e74 656e 7473 2c20 656e 7472 7970 contents, entryp\n-0002c3a0: 6f69 6e74 3d27 636f 636b 7069 742e 6272 oint='cockpit.br\n-0002c3b0: 6964 6765 3a6d 6169 6e27 2c20 6172 6773 idge:main', args\n-0002c3c0: 3d27 6265 6970 6163 6b3d 5472 7565 2729 ='beipack=True')\n-0002c3d0: 0a20 2020 2020 2020 2062 7269 6467 655f . bridge_\n-0002c3e0: 6265 6970 6163 6b5f 787a 203d 206c 7a6d beipack_xz = lzm\n-0002c3f0: 612e 636f 6d70 7265 7373 2862 7269 6467 a.compress(bridg\n-0002c400: 655f 6265 6970 6163 6b2e 656e 636f 6465 e_beipack.encode\n-0002c410: 2829 290a 2020 2020 2020 2020 6c6f 6767 ()). logg\n-0002c420: 6572 2e64 6562 7567 2827 2020 2e2e 2e20 er.debug(' ... \n-0002c430: 646f 6e65 2127 290a 0a20 2020 2072 6574 done!').. ret\n-0002c440: 7572 6e20 2763 6f63 6b70 6974 2f64 6174 urn 'cockpit/dat\n-0002c450: 612f 636f 636b 7069 742d 6272 6964 6765 a/cockpit-bridge\n-0002c460: 2e62 6569 7061 636b 2e78 7a27 2c20 6272 .beipack.xz', br\n-0002c470: 6964 6765 5f62 6569 7061 636b 5f78 7a0a idge_beipack_xz.\n-0002c480: 0a0a 636c 6173 7320 4272 6964 6765 4265 ..class BridgeBe\n-0002c490: 6962 6f6f 7448 656c 7065 7228 6665 726e ibootHelper(fern\n-0002c4a0: 792e 496e 7465 7261 6374 696f 6e48 616e y.InteractionHan\n-0002c4b0: 646c 6572 293a 0a20 2020 2023 2066 6572 dler):. # fer\n-0002c4c0: 6e79 2e49 6e74 6572 6163 7469 6f6e 4861 ny.InteractionHa\n-0002c4d0: 6e64 6c65 7220 436c 6173 7356 6172 0a20 ndler ClassVar. \n-0002c4e0: 2020 2063 6f6d 6d61 6e64 7320 3d20 5b27 commands = ['\n-0002c4f0: 6265 6962 6f6f 742e 7072 6f76 6964 6527 beiboot.provide'\n-0002c500: 2c20 2762 6569 626f 6f74 2e65 7863 275d , 'beiboot.exc']\n-0002c510: 0a0a 2020 2020 7065 6572 3a20 5065 6572 .. peer: Peer\n-0002c520: 0a20 2020 2070 6179 6c6f 6164 3a20 6279 . payload: by\n-0002c530: 7465 730a 2020 2020 7374 6570 733a 2053 tes. steps: S\n-0002c540: 6571 7565 6e63 655b 5475 706c 655b 7374 equence[Tuple[st\n-0002c550: 722c 2053 6571 7565 6e63 655b 6f62 6a65 r, Sequence[obje\n-0002c560: 6374 5d5d 5d0a 0a20 2020 2064 6566 205f ct]]].. def _\n-0002c570: 5f69 6e69 745f 5f28 7365 6c66 2c20 7065 _init__(self, pe\n-0002c580: 6572 3a20 5065 6572 2c20 6172 6773 3a20 er: Peer, args: \n-0002c590: 5365 7175 656e 6365 5b73 7472 5d20 3d20 Sequence[str] = \n-0002c5a0: 2829 2920 2d3e 204e 6f6e 653a 0a20 2020 ()) -> None:. \n-0002c5b0: 2020 2020 2066 696c 656e 616d 652c 2070 filename, p\n-0002c5c0: 6179 6c6f 6164 203d 2067 6574 5f62 7269 ayload = get_bri\n-0002c5d0: 6467 655f 6265 6970 6163 6b5f 787a 2829 dge_beipack_xz()\n-0002c5e0: 0a0a 2020 2020 2020 2020 7365 6c66 2e70 .. self.p\n-0002c5f0: 6565 7220 3d20 7065 6572 0a20 2020 2020 eer = peer. \n-0002c600: 2020 2073 656c 662e 7061 796c 6f61 6420 self.payload \n-0002c610: 3d20 7061 796c 6f61 640a 2020 2020 2020 = payload. \n-0002c620: 2020 7365 6c66 2e73 7465 7073 203d 2028 self.steps = (\n-0002c630: 2827 626f 6f74 5f78 7a27 2c20 2866 696c ('boot_xz', (fil\n-0002c640: 656e 616d 652c 206c 656e 2870 6179 6c6f ename, len(paylo\n-0002c650: 6164 292c 2074 7570 6c65 2861 7267 7329 ad), tuple(args)\n-0002c660: 2929 2c29 0a0a 2020 2020 6173 796e 6320 )),).. async \n-0002c670: 6465 6620 7275 6e5f 636f 6d6d 616e 6428 def run_command(\n-0002c680: 7365 6c66 2c20 636f 6d6d 616e 643a 2073 self, command: s\n-0002c690: 7472 2c20 6172 6773 3a20 5475 706c 652c tr, args: Tuple,\n-0002c6a0: 2066 6473 3a20 4c69 7374 5b69 6e74 5d2c fds: List[int],\n-0002c6b0: 2073 7464 6572 723a 2073 7472 2920 2d3e stderr: str) ->\n-0002c6c0: 204e 6f6e 653a 0a20 2020 2020 2020 206c None:. l\n-0002c6d0: 6f67 6765 722e 6465 6275 6728 2747 6f74 ogger.debug('Got\n-0002c6e0: 2066 6572 6e79 2072 6571 7565 7374 2025 ferny request %\n-0002c6f0: 7320 2573 2025 7320 2573 272c 2063 6f6d s %s %s %s', com\n-0002c700: 6d61 6e64 2c20 6172 6773 2c20 6664 732c mand, args, fds,\n-0002c710: 2073 7464 6572 7229 0a20 2020 2020 2020 stderr). \n-0002c720: 2069 6620 636f 6d6d 616e 6420 3d3d 2027 if command == '\n-0002c730: 6265 6962 6f6f 742e 7072 6f76 6964 6527 beiboot.provide'\n-0002c740: 3a0a 2020 2020 2020 2020 2020 2020 7472 :. tr\n-0002c750: 793a 0a20 2020 2020 2020 2020 2020 2020 y:. \n-0002c760: 2020 2073 697a 652c 203d 2061 7267 730a size, = args.\n-0002c770: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0002c780: 6173 7365 7274 2073 697a 6520 3d3d 206c assert size == l\n-0002c790: 656e 2873 656c 662e 7061 796c 6f61 6429 en(self.payload)\n-0002c7a0: 0a20 2020 2020 2020 2020 2020 2065 7863 . exc\n-0002c7b0: 6570 7420 2841 7373 6572 7469 6f6e 4572 ept (AssertionEr\n-0002c7c0: 726f 722c 2056 616c 7565 4572 726f 7229 ror, ValueError)\n-0002c7d0: 2061 7320 6578 633a 0a20 2020 2020 2020 as exc:. \n-0002c7e0: 2020 2020 2020 2020 2072 6169 7365 2050 raise P\n-0002c7f0: 6565 7245 7272 6f72 2827 696e 7465 726e eerError('intern\n-0002c800: 616c 2d65 7272 6f72 272c 206d 6573 7361 al-error', messa\n-0002c810: 6765 3d66 2766 6572 6e79 2069 6e74 6572 ge=f'ferny inter\n-0002c820: 6163 7469 6f6e 2065 7272 6f72 207b 6578 action error {ex\n-0002c830: 6321 737d 2729 2066 726f 6d20 6578 630a c!s}') from exc.\n-0002c840: 0a20 2020 2020 2020 2020 2020 2061 7373 . ass\n-0002c850: 6572 7420 7365 6c66 2e70 6565 722e 7472 ert self.peer.tr\n-0002c860: 616e 7370 6f72 7420 6973 206e 6f74 204e ansport is not N\n-0002c870: 6f6e 650a 2020 2020 2020 2020 2020 2020 one. \n-0002c880: 6c6f 6767 6572 2e64 6562 7567 2827 5772 logger.debug('Wr\n-0002c890: 6974 696e 6720 2564 2062 7974 6573 206f iting %d bytes o\n-0002c8a0: 6620 7061 796c 6f61 6427 2c20 6c65 6e28 f payload', len(\n-0002c8b0: 7365 6c66 2e70 6179 6c6f 6164 2929 0a20 self.payload)). \n-0002c8c0: 2020 2020 2020 2020 2020 2073 656c 662e self.\n-0002c8d0: 7065 6572 2e74 7261 6e73 706f 7274 2e77 peer.transport.w\n-0002c8e0: 7269 7465 2873 656c 662e 7061 796c 6f61 rite(self.payloa\n-0002c8f0: 6429 0a20 2020 2020 2020 2065 6c69 6620 d). elif \n-0002c900: 636f 6d6d 616e 6420 3d3d 2027 6265 6962 command == 'beib\n-0002c910: 6f6f 742e 6578 6327 3a0a 2020 2020 2020 oot.exc':. \n-0002c920: 2020 2020 2020 7261 6973 6520 5065 6572 raise Peer\n-0002c930: 4572 726f 7228 2769 6e74 6572 6e61 6c2d Error('internal-\n-0002c940: 6572 726f 7227 2c20 6d65 7373 6167 653d error', message=\n-0002c950: 6627 5265 6d6f 7465 2065 7863 6570 7469 f'Remote excepti\n-0002c960: 6f6e 3a20 7b61 7267 735b 305d 7d27 290a on: {args[0]}').\n-0002c970: 2020 2020 2020 2020 656c 7365 3a0a 2020 else:. \n-0002c980: 2020 2020 2020 2020 2020 7261 6973 6520 raise \n-0002c990: 5065 6572 4572 726f 7228 2769 6e74 6572 PeerError('inter\n-0002c9a0: 6e61 6c2d 6572 726f 7227 2c20 6d65 7373 nal-error', mess\n-0002c9b0: 6167 653d 6627 556e 6578 7065 6374 6564 age=f'Unexpected\n-0002c9c0: 2066 6572 6e79 2069 6e74 6572 6163 7469 ferny interacti\n-0002c9d0: 6f6e 2063 6f6d 6d61 6e64 207b 636f 6d6d on command {comm\n-0002c9e0: 616e 647d 2729 0a27 2727 2c0a 2020 2763 and}').''',. 'c\n-0002c9f0: 6f63 6b70 6974 2f70 6f6c 7966 696c 6c73 ockpit/polyfills\n-0002ca00: 2e70 7927 3a20 6272 2727 2723 2054 6869 .py': br'''# Thi\n-0002ca10: 7320 6669 6c65 2069 7320 7061 7274 206f s file is part o\n-0002ca20: 6620 436f 636b 7069 742e 0a23 0a23 2043 f Cockpit..#.# C\n-0002ca30: 6f70 7972 6967 6874 2028 4329 2032 3032 opyright (C) 202\n-0002ca40: 3320 5265 6420 4861 742c 2049 6e63 2e0a 3 Red Hat, Inc..\n-0002ca50: 230a 2320 5468 6973 2070 726f 6772 616d #.# This program\n-0002ca60: 2069 7320 6672 6565 2073 6f66 7477 6172 is free softwar\n-0002ca70: 653a 2079 6f75 2063 616e 2072 6564 6973 e: you can redis\n-0002ca80: 7472 6962 7574 6520 6974 2061 6e64 2f6f tribute it and/o\n-0002ca90: 7220 6d6f 6469 6679 0a23 2069 7420 756e r modify.# it un\n-0002caa0: 6465 7220 7468 6520 7465 726d 7320 6f66 der the terms of\n-0002cab0: 2074 6865 2047 4e55 2047 656e 6572 616c the GNU General\n-0002cac0: 2050 7562 6c69 6320 4c69 6365 6e73 6520 Public License \n-0002cad0: 6173 2070 7562 6c69 7368 6564 2062 790a as published by.\n-0002cae0: 2320 7468 6520 4672 6565 2053 6f66 7477 # the Free Softw\n-0002caf0: 6172 6520 466f 756e 6461 7469 6f6e 2c20 are Foundation, \n-0002cb00: 6569 7468 6572 2076 6572 7369 6f6e 2033 either version 3\n-0002cb10: 206f 6620 7468 6520 4c69 6365 6e73 652c of the License,\n-0002cb20: 206f 720a 2320 2861 7420 796f 7572 206f or.# (at your o\n-0002cb30: 7074 696f 6e29 2061 6e79 206c 6174 6572 ption) any later\n-0002cb40: 2076 6572 7369 6f6e 2e0a 230a 2320 5468 version..#.# Th\n-0002cb50: 6973 2070 726f 6772 616d 2069 7320 6469 is program is di\n-0002cb60: 7374 7269 6275 7465 6420 696e 2074 6865 stributed in the\n-0002cb70: 2068 6f70 6520 7468 6174 2069 7420 7769 hope that it wi\n-0002cb80: 6c6c 2062 6520 7573 6566 756c 2c0a 2320 ll be useful,.# \n-0002cb90: 6275 7420 5749 5448 4f55 5420 414e 5920 but WITHOUT ANY \n-0002cba0: 5741 5252 414e 5459 3b20 7769 7468 6f75 WARRANTY; withou\n-0002cbb0: 7420 6576 656e 2074 6865 2069 6d70 6c69 t even the impli\n-0002cbc0: 6564 2077 6172 7261 6e74 7920 6f66 0a23 ed warranty of.#\n-0002cbd0: 204d 4552 4348 414e 5441 4249 4c49 5459 MERCHANTABILITY\n-0002cbe0: 206f 7220 4649 544e 4553 5320 464f 5220 or FITNESS FOR \n-0002cbf0: 4120 5041 5254 4943 554c 4152 2050 5552 A PARTICULAR PUR\n-0002cc00: 504f 5345 2e20 2053 6565 2074 6865 0a23 POSE. See the.#\n-0002cc10: 2047 4e55 2047 656e 6572 616c 2050 7562 GNU General Pub\n-0002cc20: 6c69 6320 4c69 6365 6e73 6520 666f 7220 lic License for \n-0002cc30: 6d6f 7265 2064 6574 6169 6c73 2e0a 230a more details..#.\n-0002cc40: 2320 596f 7520 7368 6f75 6c64 2068 6176 # You should hav\n-0002cc50: 6520 7265 6365 6976 6564 2061 2063 6f70 e received a cop\n-0002cc60: 7920 6f66 2074 6865 2047 4e55 2047 656e y of the GNU Gen\n-0002cc70: 6572 616c 2050 7562 6c69 6320 4c69 6365 eral Public Lice\n-0002cc80: 6e73 650a 2320 616c 6f6e 6720 7769 7468 nse.# along with\n-0002cc90: 2074 6869 7320 7072 6f67 7261 6d2e 2020 this program. \n-0002cca0: 4966 206e 6f74 2c20 7365 6520 3c68 7474 If not, see ...im\n-0002ccd0: 706f 7274 2063 6f6e 7465 7874 6c69 620a port contextlib.\n-0002cce0: 696d 706f 7274 2073 6f63 6b65 740a 0a0a import socket...\n-0002ccf0: 6465 6620 696e 7374 616c 6c28 293a 0a20 def install():. \n-0002cd00: 2020 2022 2222 4164 6420 7368 696d 7320 \"\"\"Add shims \n-0002cd10: 666f 7220 6f6c 6465 7220 5079 7468 6f6e for older Python\n-0002cd20: 2076 6572 7369 6f6e 7322 2222 0a0a 2020 versions\"\"\".. \n-0002cd30: 2020 2320 696e 7472 6f64 7563 6564 2069 # introduced i\n-0002cd40: 6e20 332e 390a 2020 2020 6966 206e 6f74 n 3.9. if not\n-0002cd50: 2068 6173 6174 7472 2873 6f63 6b65 742c hasattr(socket,\n-0002cd60: 2027 7265 6376 5f66 6473 2729 3a0a 2020 'recv_fds'):. \n-0002cd70: 2020 2020 2020 696d 706f 7274 2061 7272 import arr\n-0002cd80: 6179 0a0a 2020 2020 2020 2020 696d 706f ay.. impo\n-0002cd90: 7274 205f 736f 636b 6574 0a0a 2020 2020 rt _socket.. \n-0002cda0: 2020 2020 6465 6620 7265 6376 5f66 6473 def recv_fds\n-0002cdb0: 2873 6f63 6b2c 2062 7566 7369 7a65 2c20 (sock, bufsize, \n-0002cdc0: 6d61 7866 6473 2c20 666c 6167 733d 3029 maxfds, flags=0)\n-0002cdd0: 3a0a 2020 2020 2020 2020 2020 2020 6664 :. fd\n-0002cde0: 7320 3d20 6172 7261 792e 6172 7261 7928 s = array.array(\n-0002cdf0: 2269 2229 0a20 2020 2020 2020 2020 2020 \"i\"). \n-0002ce00: 206d 7367 2c20 616e 6364 6174 612c 2066 msg, ancdata, f\n-0002ce10: 6c61 6773 2c20 6164 6472 203d 2073 6f63 lags, addr = soc\n-0002ce20: 6b2e 7265 6376 6d73 6728 6275 6673 697a k.recvmsg(bufsiz\n-0002ce30: 652c 205f 736f 636b 6574 2e43 4d53 475f e, _socket.CMSG_\n-0002ce40: 4c45 4e28 6d61 7866 6473 202a 2066 6473 LEN(maxfds * fds\n-0002ce50: 2e69 7465 6d73 697a 6529 290a 2020 2020 .itemsize)). \n-0002ce60: 2020 2020 2020 2020 666f 7220 636d 7367 for cmsg\n-0002ce70: 5f6c 6576 656c 2c20 636d 7367 5f74 7970 _level, cmsg_typ\n-0002ce80: 652c 2063 6d73 675f 6461 7461 2069 6e20 e, cmsg_data in \n-0002ce90: 616e 6364 6174 613a 0a20 2020 2020 2020 ancdata:. \n-0002cea0: 2020 2020 2020 2020 2069 6620 2863 6d73 if (cms\n-0002ceb0: 675f 6c65 7665 6c20 3d3d 205f 736f 636b g_level == _sock\n-0002cec0: 6574 2e53 4f4c 5f53 4f43 4b45 5420 616e et.SOL_SOCKET an\n-0002ced0: 6420 636d 7367 5f74 7970 6520 3d3d 205f d cmsg_type == _\n-0002cee0: 736f 636b 6574 2e53 434d 5f52 4947 4854 socket.SCM_RIGHT\n-0002cef0: 5329 3a0a 2020 2020 2020 2020 2020 2020 S):. \n-0002cf00: 2020 2020 2020 2020 6664 732e 6672 6f6d fds.from\n-0002cf10: 6279 7465 7328 636d 7367 5f64 6174 615b bytes(cmsg_data[\n-0002cf20: 3a6c 656e 2863 6d73 675f 6461 7461 2920 :len(cmsg_data) \n-0002cf30: 2d20 286c 656e 2863 6d73 675f 6461 7461 - (len(cmsg_data\n-0002cf40: 2920 2520 6664 732e 6974 656d 7369 7a65 ) % fds.itemsize\n-0002cf50: 295d 290a 2020 2020 2020 2020 2020 2020 )]). \n-0002cf60: 7265 7475 726e 206d 7367 2c20 6c69 7374 return msg, list\n-0002cf70: 2866 6473 292c 2066 6c61 6773 2c20 6164 (fds), flags, ad\n-0002cf80: 6472 0a0a 2020 2020 2020 2020 736f 636b dr.. sock\n-0002cf90: 6574 2e72 6563 765f 6664 7320 3d20 7265 et.recv_fds = re\n-0002cfa0: 6376 5f66 6473 0a0a 2020 2020 2320 696e cv_fds.. # in\n-0002cfb0: 7472 6f64 7563 6564 2069 6e20 332e 370a troduced in 3.7.\n-0002cfc0: 2020 2020 6966 206e 6f74 2068 6173 6174 if not hasat\n-0002cfd0: 7472 2863 6f6e 7465 7874 6c69 622c 2027 tr(contextlib, '\n-0002cfe0: 4173 796e 6345 7869 7453 7461 636b 2729 AsyncExitStack')\n-0002cff0: 3a0a 2020 2020 2020 2020 636c 6173 7320 :. class \n-0002d000: 4173 796e 6345 7869 7453 7461 636b 3a0a AsyncExitStack:.\n-0002d010: 2020 2020 2020 2020 2020 2020 6173 796e asyn\n-0002d020: 6320 6465 6620 5f5f 6165 6e74 6572 5f5f c def __aenter__\n-0002d030: 2873 656c 6629 3a0a 2020 2020 2020 2020 (self):. \n-0002d040: 2020 2020 2020 2020 7365 6c66 2e63 6d73 self.cms\n-0002d050: 203d 205b 5d0a 2020 2020 2020 2020 2020 = []. \n-0002d060: 2020 2020 2020 7265 7475 726e 2073 656c return sel\n-0002d070: 660a 0a20 2020 2020 2020 2020 2020 2061 f.. a\n-0002d080: 7379 6e63 2064 6566 2065 6e74 6572 5f61 sync def enter_a\n-0002d090: 7379 6e63 5f63 6f6e 7465 7874 2873 656c sync_context(sel\n-0002d0a0: 662c 2063 6d29 3a0a 2020 2020 2020 2020 f, cm):. \n-0002d0b0: 2020 2020 2020 2020 7265 7375 6c74 203d result =\n-0002d0c0: 2061 7761 6974 2063 6d2e 5f5f 6165 6e74 await cm.__aent\n-0002d0d0: 6572 5f5f 2829 0a20 2020 2020 2020 2020 er__(). \n-0002d0e0: 2020 2020 2020 2073 656c 662e 636d 732e self.cms.\n-0002d0f0: 6170 7065 6e64 2863 6d29 0a20 2020 2020 append(cm). \n-0002d100: 2020 2020 2020 2020 2020 2072 6574 7572 retur\n-0002d110: 6e20 7265 7375 6c74 0a0a 2020 2020 2020 n result.. \n-0002d120: 2020 2020 2020 6173 796e 6320 6465 6620 async def \n-0002d130: 5f5f 6165 7869 745f 5f28 7365 6c66 2c20 __aexit__(self, \n-0002d140: 6578 635f 7479 7065 2c20 6578 635f 7661 exc_type, exc_va\n-0002d150: 6c75 652c 2074 7261 6365 6261 636b 293a lue, traceback):\n-0002d160: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-0002d170: 2066 6f72 2063 6d20 696e 2073 656c 662e for cm in self.\n-0002d180: 636d 733a 0a20 2020 2020 2020 2020 2020 cms:. \n-0002d190: 2020 2020 2020 2020 2063 6d2e 5f5f 6165 cm.__ae\n-0002d1a0: 7869 745f 5f28 6578 635f 7479 7065 2c20 xit__(exc_type, \n-0002d1b0: 6578 635f 7661 6c75 652c 2074 7261 6365 exc_value, trace\n-0002d1c0: 6261 636b 290a 0a20 2020 2020 2020 2063 back).. c\n-0002d1d0: 6f6e 7465 7874 6c69 622e 4173 796e 6345 ontextlib.AsyncE\n-0002d1e0: 7869 7453 7461 636b 203d 2041 7379 6e63 xitStack = Async\n-0002d1f0: 4578 6974 5374 6163 6b0a 2727 272c 0a20 ExitStack.''',. \n-0002d200: 2027 636f 636b 7069 742f 6368 616e 6e65 'cockpit/channe\n-0002d210: 6c73 2f6d 6574 7269 6373 2e70 7927 3a20 ls/metrics.py': \n-0002d220: 6272 2727 2723 2054 6869 7320 6669 6c65 br'''# This file\n-0002d230: 2069 7320 7061 7274 206f 6620 436f 636b is part of Cock\n-0002d240: 7069 742e 0a23 0a23 2043 6f70 7972 6967 pit..#.# Copyrig\n-0002d250: 6874 2028 4329 2032 3032 3220 5265 6420 ht (C) 2022 Red \n-0002d260: 4861 742c 2049 6e63 2e0a 230a 2320 5468 Hat, Inc..#.# Th\n-0002d270: 6973 2070 726f 6772 616d 2069 7320 6672 is program is fr\n-0002d280: 6565 2073 6f66 7477 6172 653a 2079 6f75 ee software: you\n-0002d290: 2063 616e 2072 6564 6973 7472 6962 7574 can redistribut\n-0002d2a0: 6520 6974 2061 6e64 2f6f 7220 6d6f 6469 e it and/or modi\n-0002d2b0: 6679 0a23 2069 7420 756e 6465 7220 7468 fy.# it under th\n-0002d2c0: 6520 7465 726d 7320 6f66 2074 6865 2047 e terms of the G\n-0002d2d0: 4e55 2047 656e 6572 616c 2050 7562 6c69 NU General Publi\n-0002d2e0: 6320 4c69 6365 6e73 6520 6173 2070 7562 c License as pub\n-0002d2f0: 6c69 7368 6564 2062 790a 2320 7468 6520 lished by.# the \n-0002d300: 4672 6565 2053 6f66 7477 6172 6520 466f Free Software Fo\n-0002d310: 756e 6461 7469 6f6e 2c20 6569 7468 6572 undation, either\n-0002d320: 2076 6572 7369 6f6e 2033 206f 6620 7468 version 3 of th\n-0002d330: 6520 4c69 6365 6e73 652c 206f 720a 2320 e License, or.# \n-0002d340: 2861 7420 796f 7572 206f 7074 696f 6e29 (at your option)\n-0002d350: 2061 6e79 206c 6174 6572 2076 6572 7369 any later versi\n-0002d360: 6f6e 2e0a 230a 2320 5468 6973 2070 726f on..#.# This pro\n-0002d370: 6772 616d 2069 7320 6469 7374 7269 6275 gram is distribu\n-0002d380: 7465 6420 696e 2074 6865 2068 6f70 6520 ted in the hope \n-0002d390: 7468 6174 2069 7420 7769 6c6c 2062 6520 that it will be \n-0002d3a0: 7573 6566 756c 2c0a 2320 6275 7420 5749 useful,.# but WI\n-0002d3b0: 5448 4f55 5420 414e 5920 5741 5252 414e THOUT ANY WARRAN\n-0002d3c0: 5459 3b20 7769 7468 6f75 7420 6576 656e TY; without even\n-0002d3d0: 2074 6865 2069 6d70 6c69 6564 2077 6172 the implied war\n-0002d3e0: 7261 6e74 7920 6f66 0a23 204d 4552 4348 ranty of.# MERCH\n-0002d3f0: 414e 5441 4249 4c49 5459 206f 7220 4649 ANTABILITY or FI\n-0002d400: 544e 4553 5320 464f 5220 4120 5041 5254 TNESS FOR A PART\n-0002d410: 4943 554c 4152 2050 5552 504f 5345 2e20 ICULAR PURPOSE. \n-0002d420: 2053 6565 2074 6865 0a23 2047 4e55 2047 See the.# GNU G\n-0002d430: 656e 6572 616c 2050 7562 6c69 6320 4c69 eneral Public Li\n-0002d440: 6365 6e73 6520 666f 7220 6d6f 7265 2064 cense for more d\n-0002d450: 6574 6169 6c73 2e0a 230a 2320 596f 7520 etails..#.# You \n-0002d460: 7368 6f75 6c64 2068 6176 6520 7265 6365 should have rece\n-0002d470: 6976 6564 2061 2063 6f70 7920 6f66 2074 ived a copy of t\n-0002d480: 6865 2047 4e55 2047 656e 6572 616c 2050 he GNU General P\n-0002d490: 7562 6c69 6320 4c69 6365 6e73 650a 2320 ublic License.# \n-0002d4a0: 616c 6f6e 6720 7769 7468 2074 6869 7320 along with this \n-0002d4b0: 7072 6f67 7261 6d2e 2020 4966 206e 6f74 program. If not\n-0002d4c0: 2c20 7365 6520 3c68 7474 7073 3a2f 2f77 , see ...import a\n-0002d4f0: 7379 6e63 696f 0a69 6d70 6f72 7420 6a73 syncio.import js\n-0002d500: 6f6e 0a69 6d70 6f72 7420 6c6f 6767 696e on.import loggin\n-0002d510: 670a 696d 706f 7274 2073 7973 0a69 6d70 g.import sys.imp\n-0002d520: 6f72 7420 7469 6d65 0a66 726f 6d20 636f ort time.from co\n-0002d530: 6c6c 6563 7469 6f6e 7320 696d 706f 7274 llections import\n-0002d540: 2064 6566 6175 6c74 6469 6374 0a66 726f defaultdict.fro\n-0002d550: 6d20 7479 7069 6e67 2069 6d70 6f72 7420 m typing import \n-0002d560: 4469 6374 2c20 4c69 7374 2c20 4e61 6d65 Dict, List, Name\n-0002d570: 6454 7570 6c65 2c20 4f70 7469 6f6e 616c dTuple, Optional\n-0002d580: 2c20 5365 742c 2054 7570 6c65 2c20 556e , Set, Tuple, Un\n-0002d590: 696f 6e0a 0a66 726f 6d20 2e2e 6368 616e ion..from ..chan\n-0002d5a0: 6e65 6c20 696d 706f 7274 2041 7379 6e63 nel import Async\n-0002d5b0: 4368 616e 6e65 6c2c 2043 6861 6e6e 656c Channel, Channel\n-0002d5c0: 4572 726f 720a 6672 6f6d 202e 2e6a 736f Error.from ..jso\n-0002d5d0: 6e75 7469 6c20 696d 706f 7274 204a 736f nutil import Jso\n-0002d5e0: 6e4c 6973 740a 6672 6f6d 202e 2e73 616d nList.from ..sam\n-0002d5f0: 706c 6573 2069 6d70 6f72 7420 5341 4d50 ples import SAMP\n-0002d600: 4c45 5253 2c20 5361 6d70 6c65 4465 7363 LERS, SampleDesc\n-0002d610: 7269 7074 696f 6e2c 2053 616d 706c 6572 ription, Sampler\n-0002d620: 2c20 5361 6d70 6c65 730a 0a6c 6f67 6765 , Samples..logge\n-0002d630: 7220 3d20 6c6f 6767 696e 672e 6765 744c r = logging.getL\n-0002d640: 6f67 6765 7228 5f5f 6e61 6d65 5f5f 290a ogger(__name__).\n-0002d650: 0a0a 636c 6173 7320 4d65 7472 6963 496e ..class MetricIn\n-0002d660: 666f 284e 616d 6564 5475 706c 6529 3a0a fo(NamedTuple):.\n-0002d670: 2020 2020 6465 7269 7665 3a20 4f70 7469 derive: Opti\n-0002d680: 6f6e 616c 5b73 7472 5d0a 2020 2020 6465 onal[str]. de\n-0002d690: 7363 3a20 5361 6d70 6c65 4465 7363 7269 sc: SampleDescri\n-0002d6a0: 7074 696f 6e0a 0a0a 636c 6173 7320 496e ption...class In\n-0002d6b0: 7465 726e 616c 4d65 7472 6963 7343 6861 ternalMetricsCha\n-0002d6c0: 6e6e 656c 2841 7379 6e63 4368 616e 6e65 nnel(AsyncChanne\n-0002d6d0: 6c29 3a0a 2020 2020 7061 796c 6f61 6420 l):. payload \n-0002d6e0: 3d20 276d 6574 7269 6373 3127 0a20 2020 = 'metrics1'. \n-0002d6f0: 2072 6573 7472 6963 7469 6f6e 7320 3d20 restrictions = \n-0002d700: 5b28 2773 6f75 7263 6527 2c20 2769 6e74 [('source', 'int\n-0002d710: 6572 6e61 6c27 295d 0a0a 2020 2020 6d65 ernal')].. me\n-0002d720: 7472 6963 733a 204c 6973 745b 4d65 7472 trics: List[Metr\n-0002d730: 6963 496e 666f 5d0a 2020 2020 7361 6d70 icInfo]. samp\n-0002d740: 6c65 7273 3a20 5365 740a 2020 2020 7361 lers: Set. sa\n-0002d750: 6d70 6c65 7273 5f63 6163 6865 3a20 4f70 mplers_cache: Op\n-0002d760: 7469 6f6e 616c 5b44 6963 745b 7374 722c tional[Dict[str,\n-0002d770: 2054 7570 6c65 5b53 616d 706c 6572 2c20 Tuple[Sampler, \n-0002d780: 5361 6d70 6c65 4465 7363 7269 7074 696f SampleDescriptio\n-0002d790: 6e5d 5d5d 203d 204e 6f6e 650a 0a20 2020 n]]] = None.. \n-0002d7a0: 2069 6e74 6572 7661 6c3a 2069 6e74 203d interval: int =\n-0002d7b0: 2031 3030 300a 2020 2020 6e65 6564 5f6d 1000. need_m\n-0002d7c0: 6574 613a 2062 6f6f 6c20 3d20 5472 7565 eta: bool = True\n-0002d7d0: 0a20 2020 206c 6173 745f 7469 6d65 7374 . last_timest\n-0002d7e0: 616d 703a 2066 6c6f 6174 203d 2030 0a20 amp: float = 0. \n-0002d7f0: 2020 206e 6578 745f 7469 6d65 7374 616d next_timestam\n-0002d800: 703a 2066 6c6f 6174 203d 2030 0a0a 2020 p: float = 0.. \n-0002d810: 2020 4063 6c61 7373 6d65 7468 6f64 0a20 @classmethod. \n-0002d820: 2020 2064 6566 2065 6e73 7572 655f 7361 def ensure_sa\n-0002d830: 6d70 6c65 7273 2863 6c73 293a 0a20 2020 mplers(cls):. \n-0002d840: 2020 2020 2069 6620 636c 732e 7361 6d70 if cls.samp\n-0002d850: 6c65 7273 5f63 6163 6865 2069 7320 4e6f lers_cache is No\n-0002d860: 6e65 3a0a 2020 2020 2020 2020 2020 2020 ne:. \n-0002d870: 636c 732e 7361 6d70 6c65 7273 5f63 6163 cls.samplers_cac\n-0002d880: 6865 203d 207b 6465 7363 2e6e 616d 653a he = {desc.name:\n-0002d890: 2028 7361 6d70 6c65 722c 2064 6573 6329 (sampler, desc)\n-0002d8a0: 2066 6f72 2073 616d 706c 6572 2069 6e20 for sampler in \n-0002d8b0: 5341 4d50 4c45 5253 2066 6f72 2064 6573 SAMPLERS for des\n-0002d8c0: 6320 696e 2073 616d 706c 6572 2e64 6573 c in sampler.des\n-0002d8d0: 6372 6970 7469 6f6e 737d 0a0a 2020 2020 criptions}.. \n-0002d8e0: 6465 6620 7061 7273 655f 6f70 7469 6f6e def parse_option\n-0002d8f0: 7328 7365 6c66 2c20 6f70 7469 6f6e 7329 s(self, options)\n-0002d900: 3a0a 2020 2020 2020 2020 6c6f 6767 6572 :. logger\n-0002d910: 2e64 6562 7567 2827 6d65 7472 6963 7320 .debug('metrics \n-0002d920: 696e 7465 726e 616c 206f 7065 6e3a 2025 internal open: %\n-0002d930: 732c 2063 6861 6e6e 656c 3a20 2573 272c s, channel: %s',\n-0002d940: 206f 7074 696f 6e73 2c20 7365 6c66 2e63 options, self.c\n-0002d950: 6861 6e6e 656c 290a 0a20 2020 2020 2020 hannel).. \n-0002d960: 2069 6e74 6572 7661 6c20 3d20 6f70 7469 interval = opti\n-0002d970: 6f6e 732e 6765 7428 2769 6e74 6572 7661 ons.get('interva\n-0002d980: 6c27 2c20 7365 6c66 2e69 6e74 6572 7661 l', self.interva\n-0002d990: 6c29 0a20 2020 2020 2020 2069 6620 6e6f l). if no\n-0002d9a0: 7420 6973 696e 7374 616e 6365 2869 6e74 t isinstance(int\n-0002d9b0: 6572 7661 6c2c 2069 6e74 2920 6f72 2069 erval, int) or i\n-0002d9c0: 6e74 6572 7661 6c20 3c3d 2030 206f 7220 nterval <= 0 or \n-0002d9d0: 696e 7465 7276 616c 203e 2073 7973 2e6d interval > sys.m\n-0002d9e0: 6178 7369 7a65 3a0a 2020 2020 2020 2020 axsize:. \n-0002d9f0: 2020 2020 7261 6973 6520 4368 616e 6e65 raise Channe\n-0002da00: 6c45 7272 6f72 2827 7072 6f74 6f63 6f6c lError('protocol\n-0002da10: 2d65 7272 6f72 272c 206d 6573 7361 6765 -error', message\n-0002da20: 3d66 2769 6e76 616c 6964 2022 696e 7465 =f'invalid \"inte\n-0002da30: 7276 616c 2220 7661 6c75 653a 207b 696e rval\" value: {in\n-0002da40: 7465 7276 616c 7d27 290a 0a20 2020 2020 terval}').. \n-0002da50: 2020 2073 656c 662e 696e 7465 7276 616c self.interval\n-0002da60: 203d 2069 6e74 6572 7661 6c0a 0a20 2020 = interval.. \n-0002da70: 2020 2020 206d 6574 7269 6373 203d 206f metrics = o\n-0002da80: 7074 696f 6e73 2e67 6574 2827 6d65 7472 ptions.get('metr\n-0002da90: 6963 7327 290a 2020 2020 2020 2020 6966 ics'). if\n-0002daa0: 206e 6f74 2069 7369 6e73 7461 6e63 6528 not isinstance(\n-0002dab0: 6d65 7472 6963 732c 206c 6973 7429 206f metrics, list) o\n-0002dac0: 7220 6c65 6e28 6d65 7472 6963 7329 203d r len(metrics) =\n-0002dad0: 3d20 303a 0a20 2020 2020 2020 2020 2020 = 0:. \n-0002dae0: 206c 6f67 6765 722e 6572 726f 7228 2769 logger.error('i\n-0002daf0: 6e76 616c 6964 2022 6d65 7472 6963 7322 nvalid \"metrics\"\n-0002db00: 2076 616c 7565 3a20 2573 272c 206d 6574 value: %s', met\n-0002db10: 7269 6373 290a 2020 2020 2020 2020 2020 rics). \n-0002db20: 2020 7261 6973 6520 4368 616e 6e65 6c45 raise ChannelE\n-0002db30: 7272 6f72 2827 7072 6f74 6f63 6f6c 2d65 rror('protocol-e\n-0002db40: 7272 6f72 272c 206d 6573 7361 6765 3d27 rror', message='\n-0002db50: 696e 7661 6c69 6420 226d 6574 7269 6373 invalid \"metrics\n-0002db60: 2220 6f70 7469 6f6e 2077 6173 2073 7065 \" option was spe\n-0002db70: 6369 6669 6564 2028 6e6f 7420 616e 2061 cified (not an a\n-0002db80: 7272 6179 2927 290a 0a20 2020 2020 2020 rray)').. \n-0002db90: 2073 616d 706c 6572 5f63 6c61 7373 6573 sampler_classes\n-0002dba0: 203d 2073 6574 2829 0a20 2020 2020 2020 = set(). \n-0002dbb0: 2066 6f72 206d 6574 7269 6320 696e 206d for metric in m\n-0002dbc0: 6574 7269 6373 3a0a 2020 2020 2020 2020 etrics:. \n-0002dbd0: 2020 2020 2320 7661 6c69 6461 7465 2069 # validate i\n-0002dbe0: 7427 7320 616e 206f 626a 6563 740a 2020 t's an object. \n-0002dbf0: 2020 2020 2020 2020 2020 6e61 6d65 203d name =\n-0002dc00: 206d 6574 7269 632e 6765 7428 276e 616d metric.get('nam\n-0002dc10: 6527 290a 2020 2020 2020 2020 2020 2020 e'). \n-0002dc20: 756e 6974 7320 3d20 6d65 7472 6963 2e67 units = metric.g\n-0002dc30: 6574 2827 756e 6974 7327 290a 2020 2020 et('units'). \n-0002dc40: 2020 2020 2020 2020 6465 7269 7665 203d derive =\n-0002dc50: 206d 6574 7269 632e 6765 7428 2764 6572 metric.get('der\n-0002dc60: 6976 6527 290a 0a20 2020 2020 2020 2020 ive').. \n-0002dc70: 2020 2074 7279 3a0a 2020 2020 2020 2020 try:. \n-0002dc80: 2020 2020 2020 2020 7361 6d70 6c65 722c sampler,\n-0002dc90: 2064 6573 6320 3d20 7365 6c66 2e73 616d desc = self.sam\n-0002dca0: 706c 6572 735f 6361 6368 655b 6e61 6d65 plers_cache[name\n-0002dcb0: 5d0a 2020 2020 2020 2020 2020 2020 6578 ]. ex\n-0002dcc0: 6365 7074 204b 6579 4572 726f 7220 6173 cept KeyError as\n-0002dcd0: 2065 7863 3a0a 2020 2020 2020 2020 2020 exc:. \n-0002dce0: 2020 2020 2020 6c6f 6767 6572 2e65 7272 logger.err\n-0002dcf0: 6f72 2827 756e 7375 7070 6f72 7465 6420 or('unsupported \n-0002dd00: 6d65 7472 6963 3a20 2573 272c 206e 616d metric: %s', nam\n-0002dd10: 6529 0a20 2020 2020 2020 2020 2020 2020 e). \n-0002dd20: 2020 2072 6169 7365 2043 6861 6e6e 656c raise Channel\n-0002dd30: 4572 726f 7228 276e 6f74 2d73 7570 706f Error('not-suppo\n-0002dd40: 7274 6564 272c 206d 6573 7361 6765 3d66 rted', message=f\n-0002dd50: 2775 6e73 7570 706f 7274 6564 206d 6574 'unsupported met\n-0002dd60: 7269 633a 207b 6e61 6d65 7d27 2920 6672 ric: {name}') fr\n-0002dd70: 6f6d 2065 7863 0a0a 2020 2020 2020 2020 om exc.. \n-0002dd80: 2020 2020 6966 2075 6e69 7473 2061 6e64 if units and\n-0002dd90: 2075 6e69 7473 2021 3d20 6465 7363 2e75 units != desc.u\n-0002dda0: 6e69 7473 3a0a 2020 2020 2020 2020 2020 nits:. \n-0002ddb0: 2020 2020 2020 7261 6973 6520 4368 616e raise Chan\n-0002ddc0: 6e65 6c45 7272 6f72 2827 6e6f 742d 7375 nelError('not-su\n-0002ddd0: 7070 6f72 7465 6427 2c20 6d65 7373 6167 pported', messag\n-0002dde0: 653d 6627 7b6e 616d 657d 2068 6173 2075 e=f'{name} has u\n-0002ddf0: 6e69 7473 207b 6465 7363 2e75 6e69 7473 nits {desc.units\n-0002de00: 7d2c 206e 6f74 207b 756e 6974 737d 2729 }, not {units}')\n-0002de10: 0a0a 2020 2020 2020 2020 2020 2020 7361 .. sa\n-0002de20: 6d70 6c65 725f 636c 6173 7365 732e 6164 mpler_classes.ad\n-0002de30: 6428 7361 6d70 6c65 7229 0a20 2020 2020 d(sampler). \n-0002de40: 2020 2020 2020 2073 656c 662e 6d65 7472 self.metr\n-0002de50: 6963 732e 6170 7065 6e64 284d 6574 7269 ics.append(Metri\n-0002de60: 6349 6e66 6f28 6465 7269 7665 3d64 6572 cInfo(derive=der\n-0002de70: 6976 652c 2064 6573 633d 6465 7363 2929 ive, desc=desc))\n-0002de80: 0a0a 2020 2020 2020 2020 7365 6c66 2e73 .. self.s\n-0002de90: 616d 706c 6572 7320 3d20 7b63 6c73 2829 amplers = {cls()\n-0002dea0: 2066 6f72 2063 6c73 2069 6e20 7361 6d70 for cls in samp\n-0002deb0: 6c65 725f 636c 6173 7365 737d 0a0a 2020 ler_classes}.. \n-0002dec0: 2020 6465 6620 7365 6e64 5f6d 6574 6128 def send_meta(\n-0002ded0: 7365 6c66 2c20 7361 6d70 6c65 733a 2053 self, samples: S\n-0002dee0: 616d 706c 6573 2c20 7469 6d65 7374 616d amples, timestam\n-0002def0: 703a 2066 6c6f 6174 293a 0a20 2020 2020 p: float):. \n-0002df00: 2020 206d 6574 7269 6373 3a20 4a73 6f6e metrics: Json\n-0002df10: 4c69 7374 203d 205b 5d0a 2020 2020 2020 List = []. \n-0002df20: 2020 666f 7220 6d65 7472 6963 696e 666f for metricinfo\n-0002df30: 2069 6e20 7365 6c66 2e6d 6574 7269 6373 in self.metrics\n-0002df40: 3a0a 2020 2020 2020 2020 2020 2020 6966 :. if\n-0002df50: 206d 6574 7269 6369 6e66 6f2e 6465 7363 metricinfo.desc\n-0002df60: 2e69 6e73 7461 6e63 6564 3a0a 2020 2020 .instanced:. \n-0002df70: 2020 2020 2020 2020 2020 2020 6d65 7472 metr\n-0002df80: 6963 732e 6170 7065 6e64 287b 0a20 2020 ics.append({. \n-0002df90: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0002dfa0: 2027 6e61 6d65 273a 206d 6574 7269 6369 'name': metrici\n-0002dfb0: 6e66 6f2e 6465 7363 2e6e 616d 652c 0a20 nfo.desc.name,. \n-0002dfc0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0002dfd0: 2020 2027 756e 6974 7327 3a20 6d65 7472 'units': metr\n-0002dfe0: 6963 696e 666f 2e64 6573 632e 756e 6974 icinfo.desc.unit\n-0002dff0: 732c 0a20 2020 2020 2020 2020 2020 2020 s,. \n-0002e000: 2020 2020 2020 2027 696e 7374 616e 6365 'instance\n-0002e010: 7327 3a20 6c69 7374 2873 616d 706c 6573 s': list(samples\n-0002e020: 5b6d 6574 7269 6369 6e66 6f2e 6465 7363 [metricinfo.desc\n-0002e030: 2e6e 616d 655d 2e6b 6579 7328 2929 2c0a .name].keys()),.\n-0002e040: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0002e050: 2020 2020 2773 656d 616e 7469 6373 273a 'semantics':\n-0002e060: 206d 6574 7269 6369 6e66 6f2e 6465 7363 metricinfo.desc\n-0002e070: 2e73 656d 616e 7469 6373 0a20 2020 2020 .semantics. \n-0002e080: 2020 2020 2020 2020 2020 207d 290a 2020 }). \n-0002e090: 2020 2020 2020 2020 2020 656c 7365 3a0a else:.\n-0002e0a0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0002e0b0: 6d65 7472 6963 732e 6170 7065 6e64 287b metrics.append({\n-0002e0c0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-0002e0d0: 2020 2020 2027 6e61 6d65 273a 206d 6574 'name': met\n-0002e0e0: 7269 6369 6e66 6f2e 6465 7363 2e6e 616d ricinfo.desc.nam\n-0002e0f0: 652c 0a20 2020 2020 2020 2020 2020 2020 e,. \n-0002e100: 2020 2020 2020 2027 6465 7269 7665 273a 'derive':\n-0002e110: 206d 6574 7269 6369 6e66 6f2e 6465 7269 metricinfo.deri\n-0002e120: 7665 2c20 2023 2074 7970 653a 2069 676e ve, # type: ign\n-0002e130: 6f72 655b 6469 6374 2d69 7465 6d5d 0a20 ore[dict-item]. \n-0002e140: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0002e150: 2020 2027 756e 6974 7327 3a20 6d65 7472 'units': metr\n-0002e160: 6963 696e 666f 2e64 6573 632e 756e 6974 icinfo.desc.unit\n-0002e170: 732c 0a20 2020 2020 2020 2020 2020 2020 s,. \n-0002e180: 2020 2020 2020 2027 7365 6d61 6e74 6963 'semantic\n-0002e190: 7327 3a20 6d65 7472 6963 696e 666f 2e64 s': metricinfo.d\n-0002e1a0: 6573 632e 7365 6d61 6e74 6963 730a 2020 esc.semantics. \n-0002e1b0: 2020 2020 2020 2020 2020 2020 2020 7d29 })\n-0002e1c0: 0a0a 2020 2020 2020 2020 7365 6c66 2e73 .. self.s\n-0002e1d0: 656e 645f 6a73 6f6e 2873 6f75 7263 653d end_json(source=\n-0002e1e0: 2769 6e74 6572 6e61 6c27 2c20 696e 7465 'internal', inte\n-0002e1f0: 7276 616c 3d73 656c 662e 696e 7465 7276 rval=self.interv\n-0002e200: 616c 2c20 7469 6d65 7374 616d 703d 7469 al, timestamp=ti\n-0002e210: 6d65 7374 616d 7020 2a20 3130 3030 2c20 mestamp * 1000, \n-0002e220: 6d65 7472 6963 733d 6d65 7472 6963 7329 metrics=metrics)\n-0002e230: 0a20 2020 2020 2020 2073 656c 662e 6e65 . self.ne\n-0002e240: 6564 5f6d 6574 6120 3d20 4661 6c73 650a ed_meta = False.\n-0002e250: 0a20 2020 2064 6566 2073 616d 706c 6528 . def sample(\n-0002e260: 7365 6c66 293a 0a20 2020 2020 2020 2073 self):. s\n-0002e270: 616d 706c 6573 203d 2064 6566 6175 6c74 amples = default\n-0002e280: 6469 6374 2864 6963 7429 0a20 2020 2020 dict(dict). \n-0002e290: 2020 2066 6f72 2073 616d 706c 6572 2069 for sampler i\n-0002e2a0: 6e20 7365 6c66 2e73 616d 706c 6572 733a n self.samplers:\n-0002e2b0: 0a20 2020 2020 2020 2020 2020 2073 616d . sam\n-0002e2c0: 706c 6572 2e73 616d 706c 6528 7361 6d70 pler.sample(samp\n-0002e2d0: 6c65 7329 0a20 2020 2020 2020 2072 6574 les). ret\n-0002e2e0: 7572 6e20 7361 6d70 6c65 730a 0a20 2020 urn samples.. \n-0002e2f0: 2064 6566 2063 616c 6375 6c61 7465 5f73 def calculate_s\n-0002e300: 616d 706c 655f 7261 7465 2873 656c 662c ample_rate(self,\n-0002e310: 2076 616c 7565 3a20 666c 6f61 742c 206f value: float, o\n-0002e320: 6c64 5f76 616c 7565 3a20 4f70 7469 6f6e ld_value: Option\n-0002e330: 616c 5b66 6c6f 6174 5d29 202d 3e20 556e al[float]) -> Un\n-0002e340: 696f 6e5b 666c 6f61 742c 2062 6f6f 6c5d ion[float, bool]\n-0002e350: 3a0a 2020 2020 2020 2020 6966 206f 6c64 :. if old\n-0002e360: 5f76 616c 7565 2069 7320 6e6f 7420 4e6f _value is not No\n-0002e370: 6e65 2061 6e64 2073 656c 662e 6c61 7374 ne and self.last\n-0002e380: 5f74 696d 6573 7461 6d70 3a0a 2020 2020 _timestamp:. \n-0002e390: 2020 2020 2020 2020 7265 7475 726e 2028 return (\n-0002e3a0: 7661 6c75 6520 2d20 6f6c 645f 7661 6c75 value - old_valu\n-0002e3b0: 6529 202f 2028 7365 6c66 2e6e 6578 745f e) / (self.next_\n-0002e3c0: 7469 6d65 7374 616d 7020 2d20 7365 6c66 timestamp - self\n-0002e3d0: 2e6c 6173 745f 7469 6d65 7374 616d 7029 .last_timestamp)\n-0002e3e0: 0a20 2020 2020 2020 2065 6c73 653a 0a20 . else:. \n-0002e3f0: 2020 2020 2020 2020 2020 2072 6574 7572 retur\n-0002e400: 6e20 4661 6c73 650a 0a20 2020 2064 6566 n False.. def\n-0002e410: 2073 656e 645f 7570 6461 7465 7328 7365 send_updates(se\n-0002e420: 6c66 2c20 7361 6d70 6c65 733a 2053 616d lf, samples: Sam\n-0002e430: 706c 6573 2c20 6c61 7374 5f73 616d 706c ples, last_sampl\n-0002e440: 6573 3a20 5361 6d70 6c65 7329 3a0a 2020 es: Samples):. \n-0002e450: 2020 2020 2020 6461 7461 3a20 4c69 7374 data: List\n-0002e460: 5b55 6e69 6f6e 5b66 6c6f 6174 2c20 4c69 [Union[float, Li\n-0002e470: 7374 5b4f 7074 696f 6e61 6c5b 556e 696f st[Optional[Unio\n-0002e480: 6e5b 666c 6f61 742c 2062 6f6f 6c5d 5d5d n[float, bool]]]\n-0002e490: 5d5d 203d 205b 5d0a 2020 2020 2020 2020 ]] = []. \n-0002e4a0: 7469 6d65 7374 616d 7020 3d20 7469 6d65 timestamp = time\n-0002e4b0: 2e74 696d 6528 290a 2020 2020 2020 2020 .time(). \n-0002e4c0: 7365 6c66 2e6e 6578 745f 7469 6d65 7374 self.next_timest\n-0002e4d0: 616d 7020 3d20 7469 6d65 7374 616d 700a amp = timestamp.\n-0002e4e0: 0a20 2020 2020 2020 2066 6f72 206d 6574 . for met\n-0002e4f0: 7269 6369 6e66 6f20 696e 2073 656c 662e ricinfo in self.\n-0002e500: 6d65 7472 6963 733a 0a20 2020 2020 2020 metrics:. \n-0002e510: 2020 2020 2076 616c 7565 203d 2073 616d value = sam\n-0002e520: 706c 6573 5b6d 6574 7269 6369 6e66 6f2e ples[metricinfo.\n-0002e530: 6465 7363 2e6e 616d 655d 0a0a 2020 2020 desc.name].. \n-0002e540: 2020 2020 2020 2020 6966 206d 6574 7269 if metri\n-0002e550: 6369 6e66 6f2e 6465 7363 2e69 6e73 7461 cinfo.desc.insta\n-0002e560: 6e63 6564 3a0a 2020 2020 2020 2020 2020 nced:. \n-0002e570: 2020 2020 2020 6f6c 645f 7661 6c75 6520 old_value \n-0002e580: 3d20 6c61 7374 5f73 616d 706c 6573 5b6d = last_samples[m\n-0002e590: 6574 7269 6369 6e66 6f2e 6465 7363 2e6e etricinfo.desc.n\n-0002e5a0: 616d 655d 0a20 2020 2020 2020 2020 2020 ame]. \n-0002e5b0: 2020 2020 2061 7373 6572 7420 6973 696e assert isin\n-0002e5c0: 7374 616e 6365 2876 616c 7565 2c20 6469 stance(value, di\n-0002e5d0: 6374 290a 2020 2020 2020 2020 2020 2020 ct). \n-0002e5e0: 2020 2020 6173 7365 7274 2069 7369 6e73 assert isins\n-0002e5f0: 7461 6e63 6528 6f6c 645f 7661 6c75 652c tance(old_value,\n-0002e600: 2064 6963 7429 0a0a 2020 2020 2020 2020 dict).. \n-0002e610: 2020 2020 2020 2020 2320 4966 2077 6520 # If we \n-0002e620: 6861 7665 206c 6573 7320 6f72 206d 6f72 have less or mor\n-0002e630: 6520 6b65 7973 2074 6865 2064 6174 6120 e keys the data \n-0002e640: 6368 616e 6765 642c 2073 656e 6420 6120 changed, send a \n-0002e650: 6d65 7461 206d 6573 7361 6765 2e0a 2020 meta message.. \n-0002e660: 2020 2020 2020 2020 2020 2020 2020 6966 if\n-0002e670: 2076 616c 7565 2e6b 6579 7328 2920 213d value.keys() !=\n-0002e680: 206f 6c64 5f76 616c 7565 2e6b 6579 7328 old_value.keys(\n-0002e690: 293a 0a20 2020 2020 2020 2020 2020 2020 ):. \n-0002e6a0: 2020 2020 2020 2073 656c 662e 6e65 6564 self.need\n-0002e6b0: 5f6d 6574 6120 3d20 5472 7565 0a0a 2020 _meta = True.. \n-0002e6c0: 2020 2020 2020 2020 2020 2020 2020 6966 if\n-0002e6d0: 206d 6574 7269 6369 6e66 6f2e 6465 7269 metricinfo.deri\n-0002e6e0: 7665 203d 3d20 2772 6174 6527 3a0a 2020 ve == 'rate':. \n-0002e6f0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0002e700: 2020 696e 7374 616e 6365 733a 204c 6973 instances: Lis\n-0002e710: 745b 4f70 7469 6f6e 616c 5b55 6e69 6f6e t[Optional[Union\n-0002e720: 5b66 6c6f 6174 2c20 626f 6f6c 5d5d 5d20 [float, bool]]] \n-0002e730: 3d20 5b5d 0a20 2020 2020 2020 2020 2020 = []. \n-0002e740: 2020 2020 2020 2020 2066 6f72 206b 6579 for key\n-0002e750: 2c20 7661 6c20 696e 2076 616c 7565 2e69 , val in value.i\n-0002e760: 7465 6d73 2829 3a0a 2020 2020 2020 2020 tems():. \n-0002e770: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0002e780: 696e 7374 616e 6365 732e 6170 7065 6e64 instances.append\n-0002e790: 2873 656c 662e 6361 6c63 756c 6174 655f (self.calculate_\n-0002e7a0: 7361 6d70 6c65 5f72 6174 6528 7661 6c2c sample_rate(val,\n-0002e7b0: 206f 6c64 5f76 616c 7565 2e67 6574 286b old_value.get(k\n-0002e7c0: 6579 2929 290a 0a20 2020 2020 2020 2020 ey))).. \n-0002e7d0: 2020 2020 2020 2020 2020 2064 6174 612e data.\n-0002e7e0: 6170 7065 6e64 2869 6e73 7461 6e63 6573 append(instances\n-0002e7f0: 290a 2020 2020 2020 2020 2020 2020 2020 ). \n-0002e800: 2020 656c 7365 3a0a 2020 2020 2020 2020 else:. \n-0002e810: 2020 2020 2020 2020 2020 2020 6461 7461 data\n-0002e820: 2e61 7070 656e 6428 6c69 7374 2876 616c .append(list(val\n-0002e830: 7565 2e76 616c 7565 7328 2929 290a 2020 ue.values())). \n-0002e840: 2020 2020 2020 2020 2020 656c 7365 3a0a else:.\n-0002e850: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0002e860: 6f6c 645f 7661 6c75 6520 3d20 6c61 7374 old_value = last\n-0002e870: 5f73 616d 706c 6573 2e67 6574 286d 6574 _samples.get(met\n-0002e880: 7269 6369 6e66 6f2e 6465 7363 2e6e 616d ricinfo.desc.nam\n-0002e890: 6529 0a20 2020 2020 2020 2020 2020 2020 e). \n-0002e8a0: 2020 2061 7373 6572 7420 6e6f 7420 6973 assert not is\n-0002e8b0: 696e 7374 616e 6365 2876 616c 7565 2c20 instance(value, \n-0002e8c0: 6469 6374 290a 2020 2020 2020 2020 2020 dict). \n-0002e8d0: 2020 2020 2020 6173 7365 7274 206e 6f74 assert not\n-0002e8e0: 2069 7369 6e73 7461 6e63 6528 6f6c 645f isinstance(old_\n-0002e8f0: 7661 6c75 652c 2064 6963 7429 0a0a 2020 value, dict).. \n-0002e900: 2020 2020 2020 2020 2020 2020 2020 6966 if\n-0002e910: 206d 6574 7269 6369 6e66 6f2e 6465 7269 metricinfo.deri\n-0002e920: 7665 203d 3d20 2772 6174 6527 3a0a 2020 ve == 'rate':. \n-0002e930: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0002e940: 2020 6461 7461 2e61 7070 656e 6428 7365 data.append(se\n-0002e950: 6c66 2e63 616c 6375 6c61 7465 5f73 616d lf.calculate_sam\n-0002e960: 706c 655f 7261 7465 2876 616c 7565 2c20 ple_rate(value, \n-0002e970: 6f6c 645f 7661 6c75 6529 290a 2020 2020 old_value)). \n-0002e980: 2020 2020 2020 2020 2020 2020 656c 7365 else\n-0002e990: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n-0002e9a0: 2020 2020 2020 6461 7461 2e61 7070 656e data.appen\n-0002e9b0: 6428 7661 6c75 6529 0a0a 2020 2020 2020 d(value).. \n-0002e9c0: 2020 6966 2073 656c 662e 6e65 6564 5f6d if self.need_m\n-0002e9d0: 6574 613a 0a20 2020 2020 2020 2020 2020 eta:. \n-0002e9e0: 2073 656c 662e 7365 6e64 5f6d 6574 6128 self.send_meta(\n-0002e9f0: 7361 6d70 6c65 732c 2074 696d 6573 7461 samples, timesta\n-0002ea00: 6d70 290a 0a20 2020 2020 2020 2073 656c mp).. sel\n-0002ea10: 662e 6c61 7374 5f74 696d 6573 7461 6d70 f.last_timestamp\n-0002ea20: 203d 2073 656c 662e 6e65 7874 5f74 696d = self.next_tim\n-0002ea30: 6573 7461 6d70 0a20 2020 2020 2020 2073 estamp. s\n-0002ea40: 656c 662e 7365 6e64 5f64 6174 6128 6a73 elf.send_data(js\n-0002ea50: 6f6e 2e64 756d 7073 285b 6461 7461 5d29 on.dumps([data])\n-0002ea60: 2e65 6e63 6f64 6528 2929 0a0a 2020 2020 .encode()).. \n-0002ea70: 6173 796e 6320 6465 6620 7275 6e28 7365 async def run(se\n-0002ea80: 6c66 2c20 6f70 7469 6f6e 7329 3a0a 2020 lf, options):. \n-0002ea90: 2020 2020 2020 7365 6c66 2e6d 6574 7269 self.metri\n-0002eaa0: 6373 203d 205b 5d0a 2020 2020 2020 2020 cs = []. \n-0002eab0: 7365 6c66 2e73 616d 706c 6572 7320 3d20 self.samplers = \n-0002eac0: 7365 7428 290a 0a20 2020 2020 2020 2049 set().. I\n-0002ead0: 6e74 6572 6e61 6c4d 6574 7269 6373 4368 nternalMetricsCh\n-0002eae0: 616e 6e65 6c2e 656e 7375 7265 5f73 616d annel.ensure_sam\n-0002eaf0: 706c 6572 7328 290a 0a20 2020 2020 2020 plers().. \n-0002eb00: 2073 656c 662e 7061 7273 655f 6f70 7469 self.parse_opti\n-0002eb10: 6f6e 7328 6f70 7469 6f6e 7329 0a20 2020 ons(options). \n-0002eb20: 2020 2020 2073 656c 662e 7265 6164 7928 self.ready(\n-0002eb30: 290a 0a20 2020 2020 2020 206c 6173 745f ).. last_\n-0002eb40: 7361 6d70 6c65 7320 3d20 6465 6661 756c samples = defaul\n-0002eb50: 7464 6963 7428 6469 6374 290a 2020 2020 tdict(dict). \n-0002eb60: 2020 2020 7768 696c 6520 5472 7565 3a0a while True:.\n-0002eb70: 2020 2020 2020 2020 2020 2020 7361 6d70 samp\n-0002eb80: 6c65 7320 3d20 7365 6c66 2e73 616d 706c les = self.sampl\n-0002eb90: 6528 290a 2020 2020 2020 2020 2020 2020 e(). \n-0002eba0: 7365 6c66 2e73 656e 645f 7570 6461 7465 self.send_update\n-0002ebb0: 7328 7361 6d70 6c65 732c 206c 6173 745f s(samples, last_\n-0002ebc0: 7361 6d70 6c65 7329 0a20 2020 2020 2020 samples). \n-0002ebd0: 2020 2020 206c 6173 745f 7361 6d70 6c65 last_sample\n-0002ebe0: 7320 3d20 7361 6d70 6c65 730a 2020 2020 s = samples. \n-0002ebf0: 2020 2020 2020 2020 6177 6169 7420 6173 await as\n-0002ec00: 796e 6369 6f2e 736c 6565 7028 7365 6c66 yncio.sleep(self\n-0002ec10: 2e69 6e74 6572 7661 6c20 2f20 3130 3030 .interval / 1000\n-0002ec20: 290a 2727 272c 0a20 2027 636f 636b 7069 ).''',. 'cockpi\n-0002ec30: 742f 6368 616e 6e65 6c73 2f70 6163 6b61 t/channels/packa\n-0002ec40: 6765 732e 7079 273a 2062 7227 2727 2320 ges.py': br'''# \n-0002ec50: 5468 6973 2066 696c 6520 6973 2070 6172 This file is par\n-0002ec60: 7420 6f66 2043 6f63 6b70 6974 2e0a 230a t of Cockpit..#.\n-0002ec70: 2320 436f 7079 7269 6768 7420 2843 2920 # Copyright (C) \n-0002ec80: 3230 3232 2052 6564 2048 6174 2c20 496e 2022 Red Hat, In\n-0002ec90: 632e 0a23 0a23 2054 6869 7320 7072 6f67 c..#.# This prog\n-0002eca0: 7261 6d20 6973 2066 7265 6520 736f 6674 ram is free soft\n-0002ecb0: 7761 7265 3a20 796f 7520 6361 6e20 7265 ware: you can re\n-0002ecc0: 6469 7374 7269 6275 7465 2069 7420 616e distribute it an\n-0002ecd0: 642f 6f72 206d 6f64 6966 790a 2320 6974 d/or modify.# it\n-0002ece0: 2075 6e64 6572 2074 6865 2074 6572 6d73 under the terms\n-0002ecf0: 206f 6620 7468 6520 474e 5520 4765 6e65 of the GNU Gene\n-0002ed00: 7261 6c20 5075 626c 6963 204c 6963 656e ral Public Licen\n-0002ed10: 7365 2061 7320 7075 626c 6973 6865 6420 se as published \n-0002ed20: 6279 0a23 2074 6865 2046 7265 6520 536f by.# the Free So\n-0002ed30: 6674 7761 7265 2046 6f75 6e64 6174 696f ftware Foundatio\n-0002ed40: 6e2c 2065 6974 6865 7220 7665 7273 696f n, either versio\n-0002ed50: 6e20 3320 6f66 2074 6865 204c 6963 656e n 3 of the Licen\n-0002ed60: 7365 2c20 6f72 0a23 2028 6174 2079 6f75 se, or.# (at you\n-0002ed70: 7220 6f70 7469 6f6e 2920 616e 7920 6c61 r option) any la\n-0002ed80: 7465 7220 7665 7273 696f 6e2e 0a23 0a23 ter version..#.#\n-0002ed90: 2054 6869 7320 7072 6f67 7261 6d20 6973 This program is\n-0002eda0: 2064 6973 7472 6962 7574 6564 2069 6e20 distributed in \n-0002edb0: 7468 6520 686f 7065 2074 6861 7420 6974 the hope that it\n-0002edc0: 2077 696c 6c20 6265 2075 7365 6675 6c2c will be useful,\n-0002edd0: 0a23 2062 7574 2057 4954 484f 5554 2041 .# but WITHOUT A\n-0002ede0: 4e59 2057 4152 5241 4e54 593b 2077 6974 NY WARRANTY; wit\n-0002edf0: 686f 7574 2065 7665 6e20 7468 6520 696d hout even the im\n-0002ee00: 706c 6965 6420 7761 7272 616e 7479 206f plied warranty o\n-0002ee10: 660a 2320 4d45 5243 4841 4e54 4142 494c f.# MERCHANTABIL\n-0002ee20: 4954 5920 6f72 2046 4954 4e45 5353 2046 ITY or FITNESS F\n-0002ee30: 4f52 2041 2050 4152 5449 4355 4c41 5220 OR A PARTICULAR \n-0002ee40: 5055 5250 4f53 452e 2020 5365 6520 7468 PURPOSE. See th\n-0002ee50: 650a 2320 474e 5520 4765 6e65 7261 6c20 e.# GNU General \n-0002ee60: 5075 626c 6963 204c 6963 656e 7365 2066 Public License f\n-0002ee70: 6f72 206d 6f72 6520 6465 7461 696c 732e or more details.\n-0002ee80: 0a23 0a23 2059 6f75 2073 686f 756c 6420 .#.# You should \n-0002ee90: 6861 7665 2072 6563 6569 7665 6420 6120 have received a \n-0002eea0: 636f 7079 206f 6620 7468 6520 474e 5520 copy of the GNU \n-0002eeb0: 4765 6e65 7261 6c20 5075 626c 6963 204c General Public L\n-0002eec0: 6963 656e 7365 0a23 2061 6c6f 6e67 2077 icense.# along w\n-0002eed0: 6974 6820 7468 6973 2070 726f 6772 616d ith this program\n-0002eee0: 2e20 2049 6620 6e6f 742c 2073 6565 203c . If not, see <\n-0002eef0: 6874 7470 733a 2f2f 7777 772e 676e 752e https://www.gnu.\n-0002ef00: 6f72 672f 6c69 6365 6e73 6573 2f3e 2e0a org/licenses/>..\n-0002ef10: 0a69 6d70 6f72 7420 6c6f 6767 696e 670a .import logging.\n-0002ef20: 6672 6f6d 2074 7970 696e 6720 696d 706f from typing impo\n-0002ef30: 7274 204f 7074 696f 6e61 6c0a 0a66 726f rt Optional..fro\n-0002ef40: 6d20 2e2e 6368 616e 6e65 6c20 696d 706f m ..channel impo\n-0002ef50: 7274 2041 7379 6e63 4368 616e 6e65 6c0a rt AsyncChannel.\n-0002ef60: 6672 6f6d 202e 2e64 6174 6120 696d 706f from ..data impo\n-0002ef70: 7274 2072 6561 645f 636f 636b 7069 745f rt read_cockpit_\n-0002ef80: 6461 7461 5f66 696c 650a 6672 6f6d 202e data_file.from .\n-0002ef90: 2e6a 736f 6e75 7469 6c20 696d 706f 7274 .jsonutil import\n-0002efa0: 204a 736f 6e4f 626a 6563 742c 2067 6574 JsonObject, get\n-0002efb0: 5f64 6963 742c 2067 6574 5f73 7472 0a66 _dict, get_str.f\n-0002efc0: 726f 6d20 2e2e 7061 636b 6167 6573 2069 rom ..packages i\n-0002efd0: 6d70 6f72 7420 5061 636b 6167 6573 0a0a mport Packages..\n-0002efe0: 6c6f 6767 6572 203d 206c 6f67 6769 6e67 logger = logging\n-0002eff0: 2e67 6574 4c6f 6767 6572 285f 5f6e 616d .getLogger(__nam\n-0002f000: 655f 5f29 0a0a 0a63 6c61 7373 2050 6163 e__)...class Pac\n-0002f010: 6b61 6765 7343 6861 6e6e 656c 2841 7379 kagesChannel(Asy\n-0002f020: 6e63 4368 616e 6e65 6c29 3a0a 2020 2020 ncChannel):. \n-0002f030: 7061 796c 6f61 6420 3d20 2768 7474 702d payload = 'http-\n-0002f040: 7374 7265 616d 3127 0a20 2020 2072 6573 stream1'. res\n-0002f050: 7472 6963 7469 6f6e 7320 3d20 5b28 2269 trictions = [(\"i\n-0002f060: 6e74 6572 6e61 6c22 2c20 2270 6163 6b61 nternal\", \"packa\n-0002f070: 6765 7322 295d 0a0a 2020 2020 2320 7573 ges\")].. # us\n-0002f080: 6564 2074 6f20 6361 7272 7920 6461 7461 ed to carry data\n-0002f090: 2066 6f72 7761 7264 2066 726f 6d20 6f70 forward from op\n-0002f0a0: 656e 2074 6f20 646f 6e65 0a20 2020 206f en to done. o\n-0002f0b0: 7074 696f 6e73 3a20 4f70 7469 6f6e 616c ptions: Optional\n-0002f0c0: 5b4a 736f 6e4f 626a 6563 745d 203d 204e [JsonObject] = N\n-0002f0d0: 6f6e 650a 0a20 2020 2064 6566 2068 7474 one.. def htt\n-0002f0e0: 705f 6572 726f 7228 7365 6c66 2c20 7374 p_error(self, st\n-0002f0f0: 6174 7573 3a20 696e 742c 206d 6573 7361 atus: int, messa\n-0002f100: 6765 3a20 7374 7229 202d 3e20 4e6f 6e65 ge: str) -> None\n-0002f110: 3a0a 2020 2020 2020 2020 7465 6d70 6c61 :. templa\n-0002f120: 7465 203d 2072 6561 645f 636f 636b 7069 te = read_cockpi\n-0002f130: 745f 6461 7461 5f66 696c 6528 2766 6169 t_data_file('fai\n-0002f140: 6c2e 6874 6d6c 2729 0a20 2020 2020 2020 l.html'). \n-0002f150: 2073 656c 662e 7365 6e64 5f6a 736f 6e28 self.send_json(\n-0002f160: 7374 6174 7573 3d73 7461 7475 732c 2072 status=status, r\n-0002f170: 6561 736f 6e3d 2745 5252 4f52 272c 2068 eason='ERROR', h\n-0002f180: 6561 6465 7273 3d7b 2743 6f6e 7465 6e74 eaders={'Content\n-0002f190: 2d54 7970 6527 3a20 2774 6578 742f 6874 -Type': 'text/ht\n-0002f1a0: 6d6c 3b20 6368 6172 7365 743d 7574 662d ml; charset=utf-\n-0002f1b0: 3827 7d29 0a20 2020 2020 2020 2073 656c 8'}). sel\n-0002f1c0: 662e 7365 6e64 5f64 6174 6128 7465 6d70 f.send_data(temp\n-0002f1d0: 6c61 7465 2e72 6570 6c61 6365 2862 2740 late.replace(b'@\n-0002f1e0: 406d 6573 7361 6765 4040 272c 206d 6573 @message@@', mes\n-0002f1f0: 7361 6765 2e65 6e63 6f64 6528 2775 7466 sage.encode('utf\n-0002f200: 2d38 2729 2929 0a20 2020 2020 2020 2073 -8'))). s\n-0002f210: 656c 662e 646f 6e65 2829 0a20 2020 2020 elf.done(). \n-0002f220: 2020 2073 656c 662e 636c 6f73 6528 290a self.close().\n-0002f230: 0a20 2020 2061 7379 6e63 2064 6566 2072 . async def r\n-0002f240: 756e 2873 656c 662c 206f 7074 696f 6e73 un(self, options\n-0002f250: 3a20 4a73 6f6e 4f62 6a65 6374 2920 2d3e : JsonObject) ->\n-0002f260: 204e 6f6e 653a 0a20 2020 2020 2020 2070 None:. p\n-0002f270: 6163 6b61 6765 733a 2050 6163 6b61 6765 ackages: Package\n-0002f280: 7320 3d20 7365 6c66 2e72 6f75 7465 722e s = self.router.\n-0002f290: 7061 636b 6167 6573 2020 2320 7479 7065 packages # type\n-0002f2a0: 3a20 6967 6e6f 7265 5b61 7474 722d 6465 : ignore[attr-de\n-0002f2b0: 6669 6e65 645d 2020 2320 7965 732c 2074 fined] # yes, t\n-0002f2c0: 6869 7320 6973 2065 7669 6c0a 0a20 2020 his is evil.. \n-0002f2d0: 2020 2020 2074 7279 3a0a 2020 2020 2020 try:. \n-0002f2e0: 2020 2020 2020 6966 2067 6574 5f73 7472 if get_str\n-0002f2f0: 286f 7074 696f 6e73 2c20 276d 6574 686f (options, 'metho\n-0002f300: 6427 2920 213d 2027 4745 5427 3a0a 2020 d') != 'GET':. \n-0002f310: 2020 2020 2020 2020 2020 2020 2020 7261 ra\n-0002f320: 6973 6520 5661 6c75 6545 7272 6f72 2866 ise ValueError(f\n-0002f330: 2755 6e73 7570 706f 7274 6564 2048 5454 'Unsupported HTT\n-0002f340: 5020 6d65 7468 6f64 207b 6f70 7469 6f6e P method {option\n-0002f350: 735b 226d 6574 686f 6422 5d7d 2729 0a0a s[\"method\"]}')..\n-0002f360: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n-0002f370: 2e72 6561 6479 2829 0a20 2020 2020 2020 .ready(). \n-0002f380: 2020 2020 2069 6620 6177 6169 7420 7365 if await se\n-0002f390: 6c66 2e72 6561 6428 2920 6973 206e 6f74 lf.read() is not\n-0002f3a0: 204e 6f6e 653a 0a20 2020 2020 2020 2020 None:. \n-0002f3b0: 2020 2020 2020 2072 6169 7365 2056 616c raise Val\n-0002f3c0: 7565 4572 726f 7228 2752 6563 6569 7665 ueError('Receive\n-0002f3d0: 6420 756e 6578 7065 6374 6564 2064 6174 d unexpected dat\n-0002f3e0: 6127 290a 0a20 2020 2020 2020 2020 2020 a').. \n-0002f3f0: 2070 6174 6820 3d20 6765 745f 7374 7228 path = get_str(\n-0002f400: 6f70 7469 6f6e 732c 2027 7061 7468 2729 options, 'path')\n-0002f410: 0a20 2020 2020 2020 2020 2020 2068 6561 . hea\n-0002f420: 6465 7273 203d 2067 6574 5f64 6963 7428 ders = get_dict(\n-0002f430: 6f70 7469 6f6e 732c 2027 6865 6164 6572 options, 'header\n-0002f440: 7327 290a 2020 2020 2020 2020 2020 2020 s'). \n-0002f450: 646f 6375 6d65 6e74 203d 2070 6163 6b61 document = packa\n-0002f460: 6765 732e 6c6f 6164 5f70 6174 6828 7061 ges.load_path(pa\n-0002f470: 7468 2c20 6865 6164 6572 7329 0a0a 2020 th, headers).. \n-0002f480: 2020 2020 2020 2020 2020 2320 4e6f 7465 # Note\n-0002f490: 3a20 7765 2063 616e 2774 2063 6163 6865 : we can't cache\n-0002f4a0: 2064 6f63 756d 656e 7473 2072 6967 6874 documents right\n-0002f4b0: 206e 6f77 2e20 2053 6565 0a20 2020 2020 now. See. \n-0002f4c0: 2020 2020 2020 2023 2068 7474 7073 3a2f # https:/\n-0002f4d0: 2f67 6974 6875 622e 636f 6d2f 636f 636b /github.com/cock\n-0002f4e0: 7069 742d 7072 6f6a 6563 742f 636f 636b pit-project/cock\n-0002f4f0: 7069 742f 6973 7375 6573 2f31 3930 3731 pit/issues/19071\n-0002f500: 0a20 2020 2020 2020 2020 2020 2023 2066 . # f\n-0002f510: 6f72 2066 7574 7572 6520 706c 616e 732e or future plans.\n-0002f520: 0a20 2020 2020 2020 2020 2020 206f 7574 . out\n-0002f530: 5f68 6561 6465 7273 203d 207b 0a20 2020 _headers = {. \n-0002f540: 2020 2020 2020 2020 2020 2020 2027 4361 'Ca\n-0002f550: 6368 652d 436f 6e74 726f 6c27 3a20 276e che-Control': 'n\n-0002f560: 6f2d 6361 6368 652c 206e 6f2d 7374 6f72 o-cache, no-stor\n-0002f570: 6527 2c0a 2020 2020 2020 2020 2020 2020 e',. \n-0002f580: 2020 2020 2743 6f6e 7465 6e74 2d54 7970 'Content-Typ\n-0002f590: 6527 3a20 646f 6375 6d65 6e74 2e63 6f6e e': document.con\n-0002f5a0: 7465 6e74 5f74 7970 652c 0a20 2020 2020 tent_type,. \n-0002f5b0: 2020 2020 2020 207d 0a0a 2020 2020 2020 }.. \n-0002f5c0: 2020 2020 2020 6966 2064 6f63 756d 656e if documen\n-0002f5d0: 742e 636f 6e74 656e 745f 656e 636f 6469 t.content_encodi\n-0002f5e0: 6e67 2069 7320 6e6f 7420 4e6f 6e65 3a0a ng is not None:.\n-0002f5f0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0002f600: 6f75 745f 6865 6164 6572 735b 2743 6f6e out_headers['Con\n-0002f610: 7465 6e74 2d45 6e63 6f64 696e 6727 5d20 tent-Encoding'] \n-0002f620: 3d20 646f 6375 6d65 6e74 2e63 6f6e 7465 = document.conte\n-0002f630: 6e74 5f65 6e63 6f64 696e 670a 0a20 2020 nt_encoding.. \n-0002f640: 2020 2020 2020 2020 2069 6620 646f 6375 if docu\n-0002f650: 6d65 6e74 2e63 6f6e 7465 6e74 5f73 6563 ment.content_sec\n-0002f660: 7572 6974 795f 706f 6c69 6379 2069 7320 urity_policy is \n-0002f670: 6e6f 7420 4e6f 6e65 3a0a 2020 2020 2020 not None:. \n-0002f680: 2020 2020 2020 2020 2020 706f 6c69 6379 policy\n-0002f690: 203d 2064 6f63 756d 656e 742e 636f 6e74 = document.cont\n-0002f6a0: 656e 745f 7365 6375 7269 7479 5f70 6f6c ent_security_pol\n-0002f6b0: 6963 790a 0a20 2020 2020 2020 2020 2020 icy.. \n-0002f6c0: 2020 2020 2023 2068 7474 7073 3a2f 2f64 # https://d\n-0002f6d0: 6576 656c 6f70 6572 2e6d 6f7a 696c 6c61 eveloper.mozilla\n-0002f6e0: 2e6f 7267 2f65 6e2d 5553 2f64 6f63 732f .org/en-US/docs/\n-0002f6f0: 5765 622f 4854 5450 2f48 6561 6465 7273 Web/HTTP/Headers\n-0002f700: 2f43 6f6e 7465 6e74 2d53 6563 7572 6974 /Content-Securit\n-0002f710: 792d 506f 6c69 6379 2f63 6f6e 6e65 6374 y-Policy/connect\n-0002f720: 2d73 7263 0a20 2020 2020 2020 2020 2020 -src. \n-0002f730: 2020 2020 2023 0a20 2020 2020 2020 2020 #. \n-0002f740: 2020 2020 2020 2023 2020 2020 4e6f 7465 # Note\n-0002f750: 3a20 636f 6e6e 6563 742d 7372 6320 2773 : connect-src 's\n-0002f760: 656c 6627 2064 6f65 7320 6e6f 7420 7265 elf' does not re\n-0002f770: 736f 6c76 6520 746f 2077 6562 736f 636b solve to websock\n-0002f780: 6574 0a20 2020 2020 2020 2020 2020 2020 et. \n-0002f790: 2020 2023 2020 2020 7363 6865 6d65 7320 # schemes \n-0002f7a0: 696e 2061 6c6c 2062 726f 7773 6572 732c in all browsers,\n-0002f7b0: 206d 6f72 6520 696e 666f 2069 6e20 7468 more info in th\n-0002f7c0: 6973 2069 7373 7565 2e0a 2020 2020 2020 is issue.. \n-0002f7d0: 2020 2020 2020 2020 2020 230a 2020 2020 #. \n-0002f7e0: 2020 2020 2020 2020 2020 2020 2320 6874 # ht\n-0002f7f0: 7470 733a 2f2f 6769 7468 7562 2e63 6f6d tps://github.com\n-0002f800: 2f77 3363 2f77 6562 6170 7073 6563 2d63 /w3c/webappsec-c\n-0002f810: 7370 2f69 7373 7565 732f 370a 2020 2020 sp/issues/7. \n-0002f820: 2020 2020 2020 2020 2020 2020 6966 2022 if \"\n-0002f830: 636f 6e6e 6563 742d 7372 6320 2773 656c connect-src 'sel\n-0002f840: 6627 3b22 2069 6e20 706f 6c69 6379 3a0a f';\" in policy:.\n-0002f850: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0002f860: 2020 2020 7072 6f74 6f63 6f6c 203d 2068 protocol = h\n-0002f870: 6561 6465 7273 2e67 6574 2827 582d 466f eaders.get('X-Fo\n-0002f880: 7277 6172 6465 642d 5072 6f74 6f27 290a rwarded-Proto').\n-0002f890: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0002f8a0: 2020 2020 686f 7374 203d 2068 6561 6465 host = heade\n-0002f8b0: 7273 2e67 6574 2827 582d 466f 7277 6172 rs.get('X-Forwar\n-0002f8c0: 6465 642d 486f 7374 2729 0a20 2020 2020 ded-Host'). \n-0002f8d0: 2020 2020 2020 2020 2020 2020 2020 2069 i\n-0002f8e0: 6620 6e6f 7420 6973 696e 7374 616e 6365 f not isinstance\n-0002f8f0: 2870 726f 746f 636f 6c2c 2073 7472 2920 (protocol, str) \n-0002f900: 6f72 206e 6f74 2069 7369 6e73 7461 6e63 or not isinstanc\n-0002f910: 6528 686f 7374 2c20 7374 7229 3a0a 2020 e(host, str):. \n-0002f920: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0002f930: 2020 2020 2020 7261 6973 6520 5661 6c75 raise Valu\n-0002f940: 6545 7272 6f72 2827 496e 7661 6c69 6420 eError('Invalid \n-0002f950: 686f 7374 206f 7220 7072 6f74 6f63 6f6c host or protocol\n-0002f960: 2068 6561 6465 7227 290a 0a20 2020 2020 header').. \n-0002f970: 2020 2020 2020 2020 2020 2020 2020 2077 w\n-0002f980: 6562 736f 636b 6574 5f73 6368 656d 6520 ebsocket_scheme \n-0002f990: 3d20 2277 7373 2220 6966 2070 726f 746f = \"wss\" if proto\n-0002f9a0: 636f 6c20 3d3d 2022 6874 7470 7322 2065 col == \"https\" e\n-0002f9b0: 6c73 6520 2277 7322 0a20 2020 2020 2020 lse \"ws\". \n-0002f9c0: 2020 2020 2020 2020 2020 2020 2077 6562 web\n-0002f9d0: 736f 636b 6574 5f6f 7269 6769 6e20 3d20 socket_origin = \n-0002f9e0: 6622 7b77 6562 736f 636b 6574 5f73 6368 f\"{websocket_sch\n-0002f9f0: 656d 657d 3a2f 2f7b 686f 7374 7d22 0a20 eme}://{host}\". \n-0002fa00: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0002fa10: 2020 2070 6f6c 6963 7920 3d20 706f 6c69 policy = poli\n-0002fa20: 6379 2e72 6570 6c61 6365 2822 636f 6e6e cy.replace(\"conn\n-0002fa30: 6563 742d 7372 6320 2773 656c 6627 3b22 ect-src 'self';\"\n-0002fa40: 2c20 6622 636f 6e6e 6563 742d 7372 6320 , f\"connect-src \n-0002fa50: 7b77 6562 736f 636b 6574 5f6f 7269 6769 {websocket_origi\n-0002fa60: 6e7d 2027 7365 6c66 273b 2229 0a0a 2020 n} 'self';\").. \n-0002fa70: 2020 2020 2020 2020 2020 2020 2020 6f75 ou\n-0002fa80: 745f 6865 6164 6572 735b 2743 6f6e 7465 t_headers['Conte\n-0002fa90: 6e74 2d53 6563 7572 6974 792d 506f 6c69 nt-Security-Poli\n-0002faa0: 6379 275d 203d 2070 6f6c 6963 790a 0a20 cy'] = policy.. \n-0002fab0: 2020 2020 2020 2065 7863 6570 7420 5661 except Va\n-0002fac0: 6c75 6545 7272 6f72 2061 7320 6578 633a lueError as exc:\n-0002fad0: 0a20 2020 2020 2020 2020 2020 2073 656c . sel\n-0002fae0: 662e 6874 7470 5f65 7272 6f72 2834 3030 f.http_error(400\n-0002faf0: 2c20 7374 7228 6578 6329 290a 0a20 2020 , str(exc)).. \n-0002fb00: 2020 2020 2065 7863 6570 7420 4b65 7945 except KeyE\n-0002fb10: 7272 6f72 3a0a 2020 2020 2020 2020 2020 rror:. \n-0002fb20: 2020 7365 6c66 2e68 7474 705f 6572 726f self.http_erro\n-0002fb30: 7228 3430 342c 2027 4e6f 7420 666f 756e r(404, 'Not foun\n-0002fb40: 6427 290a 0a20 2020 2020 2020 2065 7863 d').. exc\n-0002fb50: 6570 7420 4f53 4572 726f 7220 6173 2065 ept OSError as e\n-0002fb60: 7863 3a0a 2020 2020 2020 2020 2020 2020 xc:. \n-0002fb70: 7365 6c66 2e68 7474 705f 6572 726f 7228 self.http_error(\n-0002fb80: 3530 302c 2066 2749 6e74 6572 6e61 6c20 500, f'Internal \n-0002fb90: 6572 726f 723a 207b 6578 6321 737d 2729 error: {exc!s}')\n-0002fba0: 0a0a 2020 2020 2020 2020 656c 7365 3a0a .. else:.\n-0002fbb0: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n-0002fbc0: 2e73 656e 645f 6a73 6f6e 2873 7461 7475 .send_json(statu\n-0002fbd0: 733d 3230 302c 2072 6561 736f 6e3d 274f s=200, reason='O\n-0002fbe0: 4b27 2c20 6865 6164 6572 733d 6f75 745f K', headers=out_\n-0002fbf0: 6865 6164 6572 7329 0a20 2020 2020 2020 headers). \n-0002fc00: 2020 2020 2061 7761 6974 2073 656c 662e await self.\n-0002fc10: 7365 6e64 6669 6c65 2864 6f63 756d 656e sendfile(documen\n-0002fc20: 742e 6461 7461 290a 2727 272c 0a20 2027 t.data).''',. '\n-0002fc30: 636f 636b 7069 742f 6368 616e 6e65 6c73 cockpit/channels\n-0002fc40: 2f74 7269 7669 616c 2e70 7927 3a20 6272 /trivial.py': br\n-0002fc50: 2727 2723 2054 6869 7320 6669 6c65 2069 '''# This file i\n-0002fc60: 7320 7061 7274 206f 6620 436f 636b 7069 s part of Cockpi\n-0002fc70: 742e 0a23 0a23 2043 6f70 7972 6967 6874 t..#.# Copyright\n-0002fc80: 2028 4329 2032 3032 3220 5265 6420 4861 (C) 2022 Red Ha\n-0002fc90: 742c 2049 6e63 2e0a 230a 2320 5468 6973 t, Inc..#.# This\n-0002fca0: 2070 726f 6772 616d 2069 7320 6672 6565 program is free\n-0002fcb0: 2073 6f66 7477 6172 653a 2079 6f75 2063 software: you c\n-0002fcc0: 616e 2072 6564 6973 7472 6962 7574 6520 an redistribute \n-0002fcd0: 6974 2061 6e64 2f6f 7220 6d6f 6469 6679 it and/or modify\n-0002fce0: 0a23 2069 7420 756e 6465 7220 7468 6520 .# it under the \n-0002fcf0: 7465 726d 7320 6f66 2074 6865 2047 4e55 terms of the GNU\n-0002fd00: 2047 656e 6572 616c 2050 7562 6c69 6320 General Public \n-0002fd10: 4c69 6365 6e73 6520 6173 2070 7562 6c69 License as publi\n-0002fd20: 7368 6564 2062 790a 2320 7468 6520 4672 shed by.# the Fr\n-0002fd30: 6565 2053 6f66 7477 6172 6520 466f 756e ee Software Foun\n-0002fd40: 6461 7469 6f6e 2c20 6569 7468 6572 2076 dation, either v\n-0002fd50: 6572 7369 6f6e 2033 206f 6620 7468 6520 ersion 3 of the \n-0002fd60: 4c69 6365 6e73 652c 206f 720a 2320 2861 License, or.# (a\n-0002fd70: 7420 796f 7572 206f 7074 696f 6e29 2061 t your option) a\n-0002fd80: 6e79 206c 6174 6572 2076 6572 7369 6f6e ny later version\n-0002fd90: 2e0a 230a 2320 5468 6973 2070 726f 6772 ..#.# This progr\n-0002fda0: 616d 2069 7320 6469 7374 7269 6275 7465 am is distribute\n-0002fdb0: 6420 696e 2074 6865 2068 6f70 6520 7468 d in the hope th\n-0002fdc0: 6174 2069 7420 7769 6c6c 2062 6520 7573 at it will be us\n-0002fdd0: 6566 756c 2c0a 2320 6275 7420 5749 5448 eful,.# but WITH\n-0002fde0: 4f55 5420 414e 5920 5741 5252 414e 5459 OUT ANY WARRANTY\n-0002fdf0: 3b20 7769 7468 6f75 7420 6576 656e 2074 ; without even t\n-0002fe00: 6865 2069 6d70 6c69 6564 2077 6172 7261 he implied warra\n-0002fe10: 6e74 7920 6f66 0a23 204d 4552 4348 414e nty of.# MERCHAN\n-0002fe20: 5441 4249 4c49 5459 206f 7220 4649 544e TABILITY or FITN\n-0002fe30: 4553 5320 464f 5220 4120 5041 5254 4943 ESS FOR A PARTIC\n-0002fe40: 554c 4152 2050 5552 504f 5345 2e20 2053 ULAR PURPOSE. S\n-0002fe50: 6565 2074 6865 0a23 2047 4e55 2047 656e ee the.# GNU Gen\n-0002fe60: 6572 616c 2050 7562 6c69 6320 4c69 6365 eral Public Lice\n-0002fe70: 6e73 6520 666f 7220 6d6f 7265 2064 6574 nse for more det\n-0002fe80: 6169 6c73 2e0a 230a 2320 596f 7520 7368 ails..#.# You sh\n-0002fe90: 6f75 6c64 2068 6176 6520 7265 6365 6976 ould have receiv\n-0002fea0: 6564 2061 2063 6f70 7920 6f66 2074 6865 ed a copy of the\n-0002feb0: 2047 4e55 2047 656e 6572 616c 2050 7562 GNU General Pub\n-0002fec0: 6c69 6320 4c69 6365 6e73 650a 2320 616c lic License.# al\n-0002fed0: 6f6e 6720 7769 7468 2074 6869 7320 7072 ong with this pr\n-0002fee0: 6f67 7261 6d2e 2020 4966 206e 6f74 2c20 ogram. If not, \n-0002fef0: 7365 6520 3c68 7474 7073 3a2f 2f77 7777 see ...import log\n-0002ff20: 6769 6e67 0a0a 6672 6f6d 202e 2e63 6861 ging..from ..cha\n-0002ff30: 6e6e 656c 2069 6d70 6f72 7420 4368 616e nnel import Chan\n-0002ff40: 6e65 6c0a 0a6c 6f67 6765 7220 3d20 6c6f nel..logger = lo\n-0002ff50: 6767 696e 672e 6765 744c 6f67 6765 7228 gging.getLogger(\n-0002ff60: 5f5f 6e61 6d65 5f5f 290a 0a0a 636c 6173 __name__)...clas\n-0002ff70: 7320 4563 686f 4368 616e 6e65 6c28 4368 s EchoChannel(Ch\n-0002ff80: 616e 6e65 6c29 3a0a 2020 2020 7061 796c annel):. payl\n-0002ff90: 6f61 6420 3d20 2765 6368 6f27 0a0a 2020 oad = 'echo'.. \n-0002ffa0: 2020 6465 6620 646f 5f6f 7065 6e28 7365 def do_open(se\n-0002ffb0: 6c66 2c20 6f70 7469 6f6e 7329 3a0a 2020 lf, options):. \n-0002ffc0: 2020 2020 2020 7365 6c66 2e72 6561 6479 self.ready\n-0002ffd0: 2829 0a0a 2020 2020 6465 6620 646f 5f64 ().. def do_d\n-0002ffe0: 6174 6128 7365 6c66 2c20 6461 7461 293a ata(self, data):\n-0002fff0: 0a20 2020 2020 2020 2073 656c 662e 7365 . self.se\n-00030000: 6e64 5f64 6174 6128 6461 7461 290a 0a20 nd_data(data).. \n-00030010: 2020 2064 6566 2064 6f5f 646f 6e65 2873 def do_done(s\n-00030020: 656c 6629 3a0a 2020 2020 2020 2020 7365 elf):. se\n-00030030: 6c66 2e64 6f6e 6528 290a 2020 2020 2020 lf.done(). \n-00030040: 2020 7365 6c66 2e63 6c6f 7365 2829 0a0a self.close()..\n-00030050: 0a63 6c61 7373 204e 756c 6c43 6861 6e6e .class NullChann\n-00030060: 656c 2843 6861 6e6e 656c 293a 0a20 2020 el(Channel):. \n-00030070: 2070 6179 6c6f 6164 203d 2027 6e75 6c6c payload = 'null\n-00030080: 270a 0a20 2020 2064 6566 2064 6f5f 6f70 '.. def do_op\n-00030090: 656e 2873 656c 662c 206f 7074 696f 6e73 en(self, options\n-000300a0: 293a 0a20 2020 2020 2020 2073 656c 662e ):. self.\n-000300b0: 7265 6164 7928 290a 0a20 2020 2064 6566 ready().. def\n-000300c0: 2064 6f5f 636c 6f73 6528 7365 6c66 293a do_close(self):\n-000300d0: 0a20 2020 2020 2020 2073 656c 662e 636c . self.cl\n-000300e0: 6f73 6528 290a 2727 272c 0a20 2027 636f ose().''',. 'co\n-000300f0: 636b 7069 742f 6368 616e 6e65 6c73 2f5f ckpit/channels/_\n-00030100: 5f69 6e69 745f 5f2e 7079 273a 2062 7227 _init__.py': br'\n-00030110: 2727 2320 5468 6973 2066 696c 6520 6973 ''# This file is\n-00030120: 2070 6172 7420 6f66 2043 6f63 6b70 6974 part of Cockpit\n-00030130: 2e0a 230a 2320 436f 7079 7269 6768 7420 ..#.# Copyright \n-00030140: 2843 2920 3230 3232 2052 6564 2048 6174 (C) 2022 Red Hat\n-00030150: 2c20 496e 632e 0a23 0a23 2054 6869 7320 , Inc..#.# This \n-00030160: 7072 6f67 7261 6d20 6973 2066 7265 6520 program is free \n-00030170: 736f 6674 7761 7265 3a20 796f 7520 6361 software: you ca\n-00030180: 6e20 7265 6469 7374 7269 6275 7465 2069 n redistribute i\n-00030190: 7420 616e 642f 6f72 206d 6f64 6966 790a t and/or modify.\n-000301a0: 2320 6974 2075 6e64 6572 2074 6865 2074 # it under the t\n-000301b0: 6572 6d73 206f 6620 7468 6520 474e 5520 erms of the GNU \n-000301c0: 4765 6e65 7261 6c20 5075 626c 6963 204c General Public L\n-000301d0: 6963 656e 7365 2061 7320 7075 626c 6973 icense as publis\n-000301e0: 6865 6420 6279 0a23 2074 6865 2046 7265 hed by.# the Fre\n-000301f0: 6520 536f 6674 7761 7265 2046 6f75 6e64 e Software Found\n-00030200: 6174 696f 6e2c 2065 6974 6865 7220 7665 ation, either ve\n-00030210: 7273 696f 6e20 3320 6f66 2074 6865 204c rsion 3 of the L\n-00030220: 6963 656e 7365 2c20 6f72 0a23 2028 6174 icense, or.# (at\n-00030230: 2079 6f75 7220 6f70 7469 6f6e 2920 616e your option) an\n-00030240: 7920 6c61 7465 7220 7665 7273 696f 6e2e y later version.\n-00030250: 0a23 0a23 2054 6869 7320 7072 6f67 7261 .#.# This progra\n-00030260: 6d20 6973 2064 6973 7472 6962 7574 6564 m is distributed\n-00030270: 2069 6e20 7468 6520 686f 7065 2074 6861 in the hope tha\n-00030280: 7420 6974 2077 696c 6c20 6265 2075 7365 t it will be use\n-00030290: 6675 6c2c 0a23 2062 7574 2057 4954 484f ful,.# but WITHO\n-000302a0: 5554 2041 4e59 2057 4152 5241 4e54 593b UT ANY WARRANTY;\n-000302b0: 2077 6974 686f 7574 2065 7665 6e20 7468 without even th\n-000302c0: 6520 696d 706c 6965 6420 7761 7272 616e e implied warran\n-000302d0: 7479 206f 660a 2320 4d45 5243 4841 4e54 ty of.# MERCHANT\n-000302e0: 4142 494c 4954 5920 6f72 2046 4954 4e45 ABILITY or FITNE\n-000302f0: 5353 2046 4f52 2041 2050 4152 5449 4355 SS FOR A PARTICU\n-00030300: 4c41 5220 5055 5250 4f53 452e 2020 5365 LAR PURPOSE. Se\n-00030310: 6520 7468 650a 2320 474e 5520 4765 6e65 e the.# GNU Gene\n-00030320: 7261 6c20 5075 626c 6963 204c 6963 656e ral Public Licen\n-00030330: 7365 2066 6f72 206d 6f72 6520 6465 7461 se for more deta\n-00030340: 696c 732e 0a23 0a23 2059 6f75 2073 686f ils..#.# You sho\n-00030350: 756c 6420 6861 7665 2072 6563 6569 7665 uld have receive\n-00030360: 6420 6120 636f 7079 206f 6620 7468 6520 d a copy of the \n-00030370: 474e 5520 4765 6e65 7261 6c20 5075 626c GNU General Publ\n-00030380: 6963 204c 6963 656e 7365 0a23 2061 6c6f ic License.# alo\n-00030390: 6e67 2077 6974 6820 7468 6973 2070 726f ng with this pro\n-000303a0: 6772 616d 2e20 2049 6620 6e6f 742c 2073 gram. If not, s\n-000303b0: 6565 203c 6874 7470 733a 2f2f 7777 772e ee ...from .dbus \n-000303e0: 696d 706f 7274 2044 4275 7343 6861 6e6e import DBusChann\n-000303f0: 656c 0a66 726f 6d20 2e66 696c 6573 7973 el.from .filesys\n-00030400: 7465 6d20 696d 706f 7274 2046 7349 6e66 tem import FsInf\n-00030410: 6f43 6861 6e6e 656c 2c20 4673 4c69 7374 oChannel, FsList\n-00030420: 4368 616e 6e65 6c2c 2046 7352 6561 6443 Channel, FsReadC\n-00030430: 6861 6e6e 656c 2c20 4673 5265 706c 6163 hannel, FsReplac\n-00030440: 6543 6861 6e6e 656c 2c20 4673 5761 7463 eChannel, FsWatc\n-00030450: 6843 6861 6e6e 656c 0a66 726f 6d20 2e68 hChannel.from .h\n-00030460: 7474 7020 696d 706f 7274 2048 7474 7043 ttp import HttpC\n-00030470: 6861 6e6e 656c 0a66 726f 6d20 2e6d 6574 hannel.from .met\n-00030480: 7269 6373 2069 6d70 6f72 7420 496e 7465 rics import Inte\n-00030490: 726e 616c 4d65 7472 6963 7343 6861 6e6e rnalMetricsChann\n-000304a0: 656c 0a66 726f 6d20 2e70 6163 6b61 6765 el.from .package\n-000304b0: 7320 696d 706f 7274 2050 6163 6b61 6765 s import Package\n-000304c0: 7343 6861 6e6e 656c 0a66 726f 6d20 2e73 sChannel.from .s\n-000304d0: 7472 6561 6d20 696d 706f 7274 2053 6f63 tream import Soc\n-000304e0: 6b65 7453 7472 6561 6d43 6861 6e6e 656c ketStreamChannel\n-000304f0: 2c20 5375 6270 726f 6365 7373 5374 7265 , SubprocessStre\n-00030500: 616d 4368 616e 6e65 6c0a 6672 6f6d 202e amChannel.from .\n-00030510: 7472 6976 6961 6c20 696d 706f 7274 2045 trivial import E\n-00030520: 6368 6f43 6861 6e6e 656c 2c20 4e75 6c6c choChannel, Null\n-00030530: 4368 616e 6e65 6c0a 0a43 4841 4e4e 454c Channel..CHANNEL\n-00030540: 5f54 5950 4553 203d 205b 0a20 2020 2044 _TYPES = [. D\n-00030550: 4275 7343 6861 6e6e 656c 2c0a 2020 2020 BusChannel,. \n-00030560: 4563 686f 4368 616e 6e65 6c2c 0a20 2020 EchoChannel,. \n-00030570: 2046 7349 6e66 6f43 6861 6e6e 656c 2c0a FsInfoChannel,.\n-00030580: 2020 2020 4673 4c69 7374 4368 616e 6e65 FsListChanne\n-00030590: 6c2c 0a20 2020 2046 7352 6561 6443 6861 l,. FsReadCha\n-000305a0: 6e6e 656c 2c0a 2020 2020 4673 5265 706c nnel,. FsRepl\n-000305b0: 6163 6543 6861 6e6e 656c 2c0a 2020 2020 aceChannel,. \n-000305c0: 4673 5761 7463 6843 6861 6e6e 656c 2c0a FsWatchChannel,.\n-000305d0: 2020 2020 4874 7470 4368 616e 6e65 6c2c HttpChannel,\n-000305e0: 0a20 2020 2049 6e74 6572 6e61 6c4d 6574 . InternalMet\n-000305f0: 7269 6373 4368 616e 6e65 6c2c 0a20 2020 ricsChannel,. \n-00030600: 204e 756c 6c43 6861 6e6e 656c 2c0a 2020 NullChannel,. \n-00030610: 2020 5061 636b 6167 6573 4368 616e 6e65 PackagesChanne\n-00030620: 6c2c 0a20 2020 2053 7562 7072 6f63 6573 l,. Subproces\n-00030630: 7353 7472 6561 6d43 6861 6e6e 656c 2c0a sStreamChannel,.\n-00030640: 2020 2020 536f 636b 6574 5374 7265 616d SocketStream\n-00030650: 4368 616e 6e65 6c2c 0a5d 0a27 2727 2c0a Channel,.].''',.\n-00030660: 2020 2763 6f63 6b70 6974 2f63 6861 6e6e 'cockpit/chann\n-00030670: 656c 732f 7374 7265 616d 2e70 7927 3a20 els/stream.py': \n-00030680: 6272 2727 2723 2054 6869 7320 6669 6c65 br'''# This file\n-00030690: 2069 7320 7061 7274 206f 6620 436f 636b is part of Cock\n-000306a0: 7069 742e 0a23 0a23 2043 6f70 7972 6967 pit..#.# Copyrig\n-000306b0: 6874 2028 4329 2032 3032 3220 5265 6420 ht (C) 2022 Red \n-000306c0: 4861 742c 2049 6e63 2e0a 230a 2320 5468 Hat, Inc..#.# Th\n-000306d0: 6973 2070 726f 6772 616d 2069 7320 6672 is program is fr\n-000306e0: 6565 2073 6f66 7477 6172 653a 2079 6f75 ee software: you\n-000306f0: 2063 616e 2072 6564 6973 7472 6962 7574 can redistribut\n-00030700: 6520 6974 2061 6e64 2f6f 7220 6d6f 6469 e it and/or modi\n-00030710: 6679 0a23 2069 7420 756e 6465 7220 7468 fy.# it under th\n-00030720: 6520 7465 726d 7320 6f66 2074 6865 2047 e terms of the G\n-00030730: 4e55 2047 656e 6572 616c 2050 7562 6c69 NU General Publi\n-00030740: 6320 4c69 6365 6e73 6520 6173 2070 7562 c License as pub\n-00030750: 6c69 7368 6564 2062 790a 2320 7468 6520 lished by.# the \n-00030760: 4672 6565 2053 6f66 7477 6172 6520 466f Free Software Fo\n-00030770: 756e 6461 7469 6f6e 2c20 6569 7468 6572 undation, either\n-00030780: 2076 6572 7369 6f6e 2033 206f 6620 7468 version 3 of th\n-00030790: 6520 4c69 6365 6e73 652c 206f 720a 2320 e License, or.# \n-000307a0: 2861 7420 796f 7572 206f 7074 696f 6e29 (at your option)\n-000307b0: 2061 6e79 206c 6174 6572 2076 6572 7369 any later versi\n-000307c0: 6f6e 2e0a 230a 2320 5468 6973 2070 726f on..#.# This pro\n-000307d0: 6772 616d 2069 7320 6469 7374 7269 6275 gram is distribu\n-000307e0: 7465 6420 696e 2074 6865 2068 6f70 6520 ted in the hope \n-000307f0: 7468 6174 2069 7420 7769 6c6c 2062 6520 that it will be \n-00030800: 7573 6566 756c 2c0a 2320 6275 7420 5749 useful,.# but WI\n-00030810: 5448 4f55 5420 414e 5920 5741 5252 414e THOUT ANY WARRAN\n-00030820: 5459 3b20 7769 7468 6f75 7420 6576 656e TY; without even\n-00030830: 2074 6865 2069 6d70 6c69 6564 2077 6172 the implied war\n-00030840: 7261 6e74 7920 6f66 0a23 204d 4552 4348 ranty of.# MERCH\n-00030850: 414e 5441 4249 4c49 5459 206f 7220 4649 ANTABILITY or FI\n-00030860: 544e 4553 5320 464f 5220 4120 5041 5254 TNESS FOR A PART\n-00030870: 4943 554c 4152 2050 5552 504f 5345 2e20 ICULAR PURPOSE. \n-00030880: 2053 6565 2074 6865 0a23 2047 4e55 2047 See the.# GNU G\n-00030890: 656e 6572 616c 2050 7562 6c69 6320 4c69 eneral Public Li\n-000308a0: 6365 6e73 6520 666f 7220 6d6f 7265 2064 cense for more d\n-000308b0: 6574 6169 6c73 2e0a 230a 2320 596f 7520 etails..#.# You \n-000308c0: 7368 6f75 6c64 2068 6176 6520 7265 6365 should have rece\n-000308d0: 6976 6564 2061 2063 6f70 7920 6f66 2074 ived a copy of t\n-000308e0: 6865 2047 4e55 2047 656e 6572 616c 2050 he GNU General P\n-000308f0: 7562 6c69 6320 4c69 6365 6e73 650a 2320 ublic License.# \n-00030900: 616c 6f6e 6720 7769 7468 2074 6869 7320 along with this \n-00030910: 7072 6f67 7261 6d2e 2020 4966 206e 6f74 program. If not\n-00030920: 2c20 7365 6520 3c68 7474 7073 3a2f 2f77 , see ...import a\n-00030950: 7379 6e63 696f 0a69 6d70 6f72 7420 6c6f syncio.import lo\n-00030960: 6767 696e 670a 696d 706f 7274 206f 730a gging.import os.\n-00030970: 696d 706f 7274 2073 7562 7072 6f63 6573 import subproces\n-00030980: 730a 6672 6f6d 2074 7970 696e 6720 696d s.from typing im\n-00030990: 706f 7274 2044 6963 740a 0a66 726f 6d20 port Dict..from \n-000309a0: 2e2e 6368 616e 6e65 6c20 696d 706f 7274 ..channel import\n-000309b0: 2043 6861 6e6e 656c 4572 726f 722c 2050 ChannelError, P\n-000309c0: 726f 746f 636f 6c43 6861 6e6e 656c 0a66 rotocolChannel.f\n-000309d0: 726f 6d20 2e2e 6a73 6f6e 7574 696c 2069 rom ..jsonutil i\n-000309e0: 6d70 6f72 7420 4a73 6f6e 4469 6374 2c20 mport JsonDict, \n-000309f0: 4a73 6f6e 4f62 6a65 6374 2c20 6765 745f JsonObject, get_\n-00030a00: 626f 6f6c 2c20 6765 745f 656e 756d 2c20 bool, get_enum, \n-00030a10: 6765 745f 696e 742c 2067 6574 5f6f 626a get_int, get_obj\n-00030a20: 6563 742c 2067 6574 5f73 7472 2c20 6765 ect, get_str, ge\n-00030a30: 745f 7374 7276 0a66 726f 6d20 2e2e 7472 t_strv.from ..tr\n-00030a40: 616e 7370 6f72 7473 2069 6d70 6f72 7420 ansports import \n-00030a50: 5375 6270 726f 6365 7373 5072 6f74 6f63 SubprocessProtoc\n-00030a60: 6f6c 2c20 5375 6270 726f 6365 7373 5472 ol, SubprocessTr\n-00030a70: 616e 7370 6f72 742c 2057 696e 646f 7753 ansport, WindowS\n-00030a80: 697a 650a 0a6c 6f67 6765 7220 3d20 6c6f ize..logger = lo\n-00030a90: 6767 696e 672e 6765 744c 6f67 6765 7228 gging.getLogger(\n-00030aa0: 5f5f 6e61 6d65 5f5f 290a 0a0a 636c 6173 __name__)...clas\n-00030ab0: 7320 536f 636b 6574 5374 7265 616d 4368 s SocketStreamCh\n-00030ac0: 616e 6e65 6c28 5072 6f74 6f63 6f6c 4368 annel(ProtocolCh\n-00030ad0: 616e 6e65 6c29 3a0a 2020 2020 7061 796c annel):. payl\n-00030ae0: 6f61 6420 3d20 2773 7472 6561 6d27 0a0a oad = 'stream'..\n-00030af0: 2020 2020 6173 796e 6320 6465 6620 6372 async def cr\n-00030b00: 6561 7465 5f74 7261 6e73 706f 7274 2873 eate_transport(s\n-00030b10: 656c 662c 206c 6f6f 703a 2061 7379 6e63 elf, loop: async\n-00030b20: 696f 2e41 6273 7472 6163 7445 7665 6e74 io.AbstractEvent\n-00030b30: 4c6f 6f70 2c20 6f70 7469 6f6e 733a 204a Loop, options: J\n-00030b40: 736f 6e4f 626a 6563 7429 202d 3e20 6173 sonObject) -> as\n-00030b50: 796e 6369 6f2e 5472 616e 7370 6f72 743a yncio.Transport:\n-00030b60: 0a20 2020 2020 2020 2069 6620 2775 6e69 . if 'uni\n-00030b70: 7827 2069 6e20 6f70 7469 6f6e 7320 616e x' in options an\n-00030b80: 6420 2770 6f72 7427 2069 6e20 6f70 7469 d 'port' in opti\n-00030b90: 6f6e 733a 0a20 2020 2020 2020 2020 2020 ons:. \n-00030ba0: 2072 6169 7365 2043 6861 6e6e 656c 4572 raise ChannelEr\n-00030bb0: 726f 7228 2770 726f 746f 636f 6c2d 6572 ror('protocol-er\n-00030bc0: 726f 7227 2c20 6d65 7373 6167 653d 2763 ror', message='c\n-00030bd0: 616e 6e6f 7420 7370 6563 6966 7920 626f annot specify bo\n-00030be0: 7468 2022 706f 7274 2220 616e 6420 2275 th \"port\" and \"u\n-00030bf0: 6e69 7822 206f 7074 696f 6e73 2729 0a0a nix\" options')..\n-00030c00: 2020 2020 2020 2020 7472 793a 0a20 2020 try:. \n-00030c10: 2020 2020 2020 2020 2023 2055 6e69 780a # Unix.\n-00030c20: 2020 2020 2020 2020 2020 2020 6966 2027 if '\n-00030c30: 756e 6978 2720 696e 206f 7074 696f 6e73 unix' in options\n-00030c40: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n-00030c50: 2020 7061 7468 203d 2067 6574 5f73 7472 path = get_str\n-00030c60: 286f 7074 696f 6e73 2c20 2775 6e69 7827 (options, 'unix'\n-00030c70: 290a 2020 2020 2020 2020 2020 2020 2020 ). \n-00030c80: 2020 6c61 6265 6c20 3d20 6627 556e 6978 label = f'Unix\n-00030c90: 2073 6f63 6b65 7420 7b70 6174 687d 270a socket {path}'.\n-00030ca0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00030cb0: 7472 616e 7370 6f72 742c 205f 203d 2061 transport, _ = a\n-00030cc0: 7761 6974 206c 6f6f 702e 6372 6561 7465 wait loop.create\n-00030cd0: 5f75 6e69 785f 636f 6e6e 6563 7469 6f6e _unix_connection\n-00030ce0: 286c 616d 6264 613a 2073 656c 662c 2070 (lambda: self, p\n-00030cf0: 6174 6829 0a0a 2020 2020 2020 2020 2020 ath).. \n-00030d00: 2020 2320 5443 500a 2020 2020 2020 2020 # TCP. \n-00030d10: 2020 2020 656c 6966 2027 706f 7274 2720 elif 'port' \n-00030d20: 696e 206f 7074 696f 6e73 3a0a 2020 2020 in options:. \n-00030d30: 2020 2020 2020 2020 2020 2020 706f 7274 port\n-00030d40: 203d 2067 6574 5f69 6e74 286f 7074 696f = get_int(optio\n-00030d50: 6e73 2c20 2770 6f72 7427 290a 2020 2020 ns, 'port'). \n-00030d60: 2020 2020 2020 2020 2020 2020 686f 7374 host\n-00030d70: 203d 2067 6574 5f73 7472 286f 7074 696f = get_str(optio\n-00030d80: 6e73 2c20 2761 6464 7265 7373 272c 2027 ns, 'address', '\n-00030d90: 6c6f 6361 6c68 6f73 7427 290a 2020 2020 localhost'). \n-00030da0: 2020 2020 2020 2020 2020 2020 6c61 6265 labe\n-00030db0: 6c20 3d20 6627 5443 5020 736f 636b 6574 l = f'TCP socket\n-00030dc0: 207b 686f 7374 7d3a 7b70 6f72 747d 270a {host}:{port}'.\n-00030dd0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-00030de0: 2074 7261 6e73 706f 7274 2c20 5f20 3d20 transport, _ = \n-00030df0: 6177 6169 7420 6c6f 6f70 2e63 7265 6174 await loop.creat\n-00030e00: 655f 636f 6e6e 6563 7469 6f6e 286c 616d e_connection(lam\n-00030e10: 6264 613a 2073 656c 662c 2068 6f73 742c bda: self, host,\n-00030e20: 2070 6f72 7429 0a20 2020 2020 2020 2020 port). \n-00030e30: 2020 2065 6c73 653a 0a20 2020 2020 2020 else:. \n-00030e40: 2020 2020 2020 2020 2072 6169 7365 2043 raise C\n-00030e50: 6861 6e6e 656c 4572 726f 7228 2770 726f hannelError('pro\n-00030e60: 746f 636f 6c2d 6572 726f 7227 2c0a 2020 tocol-error',. \n-00030e70: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00030e80: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00030e90: 206d 6573 7361 6765 3d27 6e6f 2022 706f message='no \"po\n-00030ea0: 7274 2220 6f72 2022 756e 6978 2220 6f72 rt\" or \"unix\" or\n-00030eb0: 206f 7468 6572 2061 6464 7265 7373 206f other address o\n-00030ec0: 7074 696f 6e20 666f 7220 6368 616e 6e65 ption for channe\n-00030ed0: 6c27 290a 0a20 2020 2020 2020 2020 2020 l').. \n-00030ee0: 206c 6f67 6765 722e 6465 6275 6728 2753 logger.debug('S\n-00030ef0: 6f63 6b65 7453 7472 6561 6d43 6861 6e6e ocketStreamChann\n-00030f00: 656c 3a20 636f 6e6e 6563 7465 6420 746f el: connected to\n-00030f10: 2025 7327 2c20 6c61 6265 6c29 0a20 2020 %s', label). \n-00030f20: 2020 2020 2065 7863 6570 7420 4f53 4572 except OSEr\n-00030f30: 726f 7220 6173 2065 7272 6f72 3a0a 2020 ror as error:. \n-00030f40: 2020 2020 2020 2020 2020 6c6f 6767 6572 logger\n-00030f50: 2e69 6e66 6f28 2753 6f63 6b65 7453 7472 .info('SocketStr\n-00030f60: 6561 6d43 6861 6e6e 656c 3a20 636f 6e6e eamChannel: conn\n-00030f70: 6563 7469 6e67 2074 6f20 2573 2066 6169 ecting to %s fai\n-00030f80: 6c65 643a 2025 7327 2c20 6c61 6265 6c2c led: %s', label,\n-00030f90: 2065 7272 6f72 290a 2020 2020 2020 2020 error). \n-00030fa0: 2020 2020 6966 2069 7369 6e73 7461 6e63 if isinstanc\n-00030fb0: 6528 6572 726f 722c 2043 6f6e 6e65 6374 e(error, Connect\n-00030fc0: 696f 6e52 6566 7573 6564 4572 726f 7229 ionRefusedError)\n-00030fd0: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n-00030fe0: 2020 7072 6f62 6c65 6d20 3d20 276e 6f74 problem = 'not\n-00030ff0: 2d66 6f75 6e64 270a 2020 2020 2020 2020 -found'. \n-00031000: 2020 2020 656c 7365 3a0a 2020 2020 2020 else:. \n-00031010: 2020 2020 2020 2020 2020 7072 6f62 6c65 proble\n-00031020: 6d20 3d20 2774 6572 6d69 6e61 7465 6427 m = 'terminated'\n-00031030: 0a20 2020 2020 2020 2020 2020 2072 6169 . rai\n-00031040: 7365 2043 6861 6e6e 656c 4572 726f 7228 se ChannelError(\n-00031050: 7072 6f62 6c65 6d2c 206d 6573 7361 6765 problem, message\n-00031060: 3d73 7472 2865 7272 6f72 2929 2066 726f =str(error)) fro\n-00031070: 6d20 6572 726f 720a 2020 2020 2020 2020 m error. \n-00031080: 7365 6c66 2e63 6c6f 7365 5f6f 6e5f 656f self.close_on_eo\n-00031090: 6628 290a 2020 2020 2020 2020 6173 7365 f(). asse\n-000310a0: 7274 2069 7369 6e73 7461 6e63 6528 7472 rt isinstance(tr\n-000310b0: 616e 7370 6f72 742c 2061 7379 6e63 696f ansport, asyncio\n-000310c0: 2e54 7261 6e73 706f 7274 290a 2020 2020 .Transport). \n-000310d0: 2020 2020 7265 7475 726e 2074 7261 6e73 return trans\n-000310e0: 706f 7274 0a0a 0a63 6c61 7373 2053 7562 port...class Sub\n-000310f0: 7072 6f63 6573 7353 7472 6561 6d43 6861 processStreamCha\n-00031100: 6e6e 656c 2850 726f 746f 636f 6c43 6861 nnel(ProtocolCha\n-00031110: 6e6e 656c 2c20 5375 6270 726f 6365 7373 nnel, Subprocess\n-00031120: 5072 6f74 6f63 6f6c 293a 0a20 2020 2070 Protocol):. p\n-00031130: 6179 6c6f 6164 203d 2027 7374 7265 616d ayload = 'stream\n-00031140: 270a 2020 2020 7265 7374 7269 6374 696f '. restrictio\n-00031150: 6e73 203d 2028 2827 7370 6177 6e27 2c20 ns = (('spawn', \n-00031160: 4e6f 6e65 292c 290a 0a20 2020 2064 6566 None),).. def\n-00031170: 2070 726f 6365 7373 5f65 7869 7465 6428 process_exited(\n-00031180: 7365 6c66 2920 2d3e 204e 6f6e 653a 0a20 self) -> None:. \n-00031190: 2020 2020 2020 2073 656c 662e 636c 6f73 self.clos\n-000311a0: 655f 6f6e 5f65 6f66 2829 0a0a 2020 2020 e_on_eof().. \n-000311b0: 6465 6620 5f67 6574 5f63 6c6f 7365 5f61 def _get_close_a\n-000311c0: 7267 7328 7365 6c66 2920 2d3e 204a 736f rgs(self) -> Jso\n-000311d0: 6e4f 626a 6563 743a 0a20 2020 2020 2020 nObject:. \n-000311e0: 2061 7373 6572 7420 6973 696e 7374 616e assert isinstan\n-000311f0: 6365 2873 656c 662e 5f74 7261 6e73 706f ce(self._transpo\n-00031200: 7274 2c20 5375 6270 726f 6365 7373 5472 rt, SubprocessTr\n-00031210: 616e 7370 6f72 7429 0a20 2020 2020 2020 ansport). \n-00031220: 2061 7267 733a 204a 736f 6e44 6963 7420 args: JsonDict \n-00031230: 3d20 7b27 6578 6974 2d73 7461 7475 7327 = {'exit-status'\n-00031240: 3a20 7365 6c66 2e5f 7472 616e 7370 6f72 : self._transpor\n-00031250: 742e 6765 745f 7265 7475 726e 636f 6465 t.get_returncode\n-00031260: 2829 7d0a 2020 2020 2020 2020 7374 6465 ()}. stde\n-00031270: 7272 203d 2073 656c 662e 5f74 7261 6e73 rr = self._trans\n-00031280: 706f 7274 2e67 6574 5f73 7464 6572 7228 port.get_stderr(\n-00031290: 290a 2020 2020 2020 2020 6966 2073 7464 ). if std\n-000312a0: 6572 7220 6973 206e 6f74 204e 6f6e 653a err is not None:\n-000312b0: 0a20 2020 2020 2020 2020 2020 2061 7267 . arg\n-000312c0: 735b 276d 6573 7361 6765 275d 203d 2073 s['message'] = s\n-000312d0: 7464 6572 720a 2020 2020 2020 2020 7265 tderr. re\n-000312e0: 7475 726e 2061 7267 730a 0a20 2020 2064 turn args.. d\n-000312f0: 6566 2064 6f5f 6f70 7469 6f6e 7328 7365 ef do_options(se\n-00031300: 6c66 2c20 6f70 7469 6f6e 7329 3a0a 2020 lf, options):. \n-00031310: 2020 2020 2020 7769 6e64 6f77 203d 2067 window = g\n-00031320: 6574 5f6f 626a 6563 7428 6f70 7469 6f6e et_object(option\n-00031330: 732c 2027 7769 6e64 6f77 272c 2057 696e s, 'window', Win\n-00031340: 646f 7753 697a 652c 204e 6f6e 6529 0a20 dowSize, None). \n-00031350: 2020 2020 2020 2069 6620 7769 6e64 6f77 if window\n-00031360: 2069 7320 6e6f 7420 4e6f 6e65 3a0a 2020 is not None:. \n-00031370: 2020 2020 2020 2020 2020 7365 6c66 2e5f self._\n-00031380: 7472 616e 7370 6f72 742e 7365 745f 7769 transport.set_wi\n-00031390: 6e64 6f77 5f73 697a 6528 7769 6e64 6f77 ndow_size(window\n-000313a0: 290a 0a20 2020 2061 7379 6e63 2064 6566 ).. async def\n-000313b0: 2063 7265 6174 655f 7472 616e 7370 6f72 create_transpor\n-000313c0: 7428 7365 6c66 2c20 6c6f 6f70 3a20 6173 t(self, loop: as\n-000313d0: 796e 6369 6f2e 4162 7374 7261 6374 4576 yncio.AbstractEv\n-000313e0: 656e 744c 6f6f 702c 206f 7074 696f 6e73 entLoop, options\n-000313f0: 3a20 4a73 6f6e 4f62 6a65 6374 2920 2d3e : JsonObject) ->\n-00031400: 2053 7562 7072 6f63 6573 7354 7261 6e73 SubprocessTrans\n-00031410: 706f 7274 3a0a 2020 2020 2020 2020 6172 port:. ar\n-00031420: 6773 203d 2067 6574 5f73 7472 7628 6f70 gs = get_strv(op\n-00031430: 7469 6f6e 732c 2027 7370 6177 6e27 290a tions, 'spawn').\n-00031440: 2020 2020 2020 2020 6572 7220 3d20 6765 err = ge\n-00031450: 745f 656e 756d 286f 7074 696f 6e73 2c20 t_enum(options, \n-00031460: 2765 7272 272c 205b 276f 7574 272c 2027 'err', ['out', '\n-00031470: 6967 6e6f 7265 272c 2027 6d65 7373 6167 ignore', 'messag\n-00031480: 6527 5d2c 2027 6d65 7373 6167 6527 290a e'], 'message').\n-00031490: 2020 2020 2020 2020 6377 6420 3d20 6765 cwd = ge\n-000314a0: 745f 7374 7228 6f70 7469 6f6e 732c 2027 t_str(options, '\n-000314b0: 6469 7265 6374 6f72 7927 2c20 272e 2729 directory', '.')\n-000314c0: 0a20 2020 2020 2020 2070 7479 203d 2067 . pty = g\n-000314d0: 6574 5f62 6f6f 6c28 6f70 7469 6f6e 732c et_bool(options,\n-000314e0: 2027 7074 7927 2c20 6465 6661 756c 743d 'pty', default=\n-000314f0: 4661 6c73 6529 0a20 2020 2020 2020 2077 False). w\n-00031500: 696e 646f 7720 3d20 6765 745f 6f62 6a65 indow = get_obje\n-00031510: 6374 286f 7074 696f 6e73 2c20 2777 696e ct(options, 'win\n-00031520: 646f 7727 2c20 5769 6e64 6f77 5369 7a65 dow', WindowSize\n-00031530: 2c20 4e6f 6e65 290a 2020 2020 2020 2020 , None). \n-00031540: 656e 7669 726f 6e20 3d20 6765 745f 7374 environ = get_st\n-00031550: 7276 286f 7074 696f 6e73 2c20 2765 6e76 rv(options, 'env\n-00031560: 6972 6f6e 272c 205b 5d29 0a0a 2020 2020 iron', []).. \n-00031570: 2020 2020 6966 2065 7272 203d 3d20 276f if err == 'o\n-00031580: 7574 273a 0a20 2020 2020 2020 2020 2020 ut':. \n-00031590: 2073 7464 6572 7220 3d20 7375 6270 726f stderr = subpro\n-000315a0: 6365 7373 2e53 5444 4f55 540a 2020 2020 cess.STDOUT. \n-000315b0: 2020 2020 656c 6966 2065 7272 203d 3d20 elif err == \n-000315c0: 2769 676e 6f72 6527 3a0a 2020 2020 2020 'ignore':. \n-000315d0: 2020 2020 2020 7374 6465 7272 203d 2073 stderr = s\n-000315e0: 7562 7072 6f63 6573 732e 4445 564e 554c ubprocess.DEVNUL\n-000315f0: 4c0a 2020 2020 2020 2020 656c 7365 3a0a L. else:.\n-00031600: 2020 2020 2020 2020 2020 2020 7374 6465 stde\n-00031610: 7272 203d 2073 7562 7072 6f63 6573 732e rr = subprocess.\n-00031620: 5049 5045 0a0a 2020 2020 2020 2020 656e PIPE.. en\n-00031630: 763a 2044 6963 745b 7374 722c 2073 7472 v: Dict[str, str\n-00031640: 5d20 3d20 6469 6374 286f 732e 656e 7669 ] = dict(os.envi\n-00031650: 726f 6e29 0a20 2020 2020 2020 2074 7279 ron). try\n-00031660: 3a0a 2020 2020 2020 2020 2020 2020 656e :. en\n-00031670: 762e 7570 6461 7465 2864 6963 7428 652e v.update(dict(e.\n-00031680: 7370 6c69 7428 273d 272c 2031 2920 666f split('=', 1) fo\n-00031690: 7220 6520 696e 2065 6e76 6972 6f6e 2929 r e in environ))\n-000316a0: 0a20 2020 2020 2020 2065 7863 6570 7420 . except \n-000316b0: 5661 6c75 6545 7272 6f72 3a0a 2020 2020 ValueError:. \n-000316c0: 2020 2020 2020 2020 7261 6973 6520 4368 raise Ch\n-000316d0: 616e 6e65 6c45 7272 6f72 2827 7072 6f74 annelError('prot\n-000316e0: 6f63 6f6c 2d65 7272 6f72 272c 206d 6573 ocol-error', mes\n-000316f0: 7361 6765 3d27 696e 7661 6c69 6420 2265 sage='invalid \"e\n-00031700: 6e76 6972 6f6e 2220 6f70 7469 6f6e 2066 nviron\" option f\n-00031710: 6f72 2073 7472 6561 6d20 6368 616e 6e65 or stream channe\n-00031720: 6c27 2920 6672 6f6d 204e 6f6e 650a 0a20 l') from None.. \n-00031730: 2020 2020 2020 2074 7279 3a0a 2020 2020 try:. \n-00031740: 2020 2020 2020 2020 7472 616e 7370 6f72 transpor\n-00031750: 7420 3d20 5375 6270 726f 6365 7373 5472 t = SubprocessTr\n-00031760: 616e 7370 6f72 7428 6c6f 6f70 2c20 7365 ansport(loop, se\n-00031770: 6c66 2c20 6172 6773 2c20 7074 793d 7074 lf, args, pty=pt\n-00031780: 792c 2077 696e 646f 773d 7769 6e64 6f77 y, window=window\n-00031790: 2c20 656e 763d 656e 762c 2063 7764 3d63 , env=env, cwd=c\n-000317a0: 7764 2c20 7374 6465 7272 3d73 7464 6572 wd, stderr=stder\n-000317b0: 7229 0a20 2020 2020 2020 2020 2020 206c r). l\n-000317c0: 6f67 6765 722e 6465 6275 6728 2753 7061 ogger.debug('Spa\n-000317d0: 776e 6564 2070 726f 6365 7373 2061 7267 wned process arg\n-000317e0: 733d 2573 2070 6964 3d25 6927 2c20 6172 s=%s pid=%i', ar\n-000317f0: 6773 2c20 7472 616e 7370 6f72 742e 6765 gs, transport.ge\n-00031800: 745f 7069 6428 2929 0a20 2020 2020 2020 t_pid()). \n-00031810: 2020 2020 2072 6574 7572 6e20 7472 616e return tran\n-00031820: 7370 6f72 740a 2020 2020 2020 2020 6578 sport. ex\n-00031830: 6365 7074 2046 696c 654e 6f74 466f 756e cept FileNotFoun\n-00031840: 6445 7272 6f72 2061 7320 6572 726f 723a dError as error:\n-00031850: 0a20 2020 2020 2020 2020 2020 2072 6169 . rai\n-00031860: 7365 2043 6861 6e6e 656c 4572 726f 7228 se ChannelError(\n-00031870: 276e 6f74 2d66 6f75 6e64 2729 2066 726f 'not-found') fro\n-00031880: 6d20 6572 726f 720a 2020 2020 2020 2020 m error. \n-00031890: 6578 6365 7074 2050 6572 6d69 7373 696f except Permissio\n-000318a0: 6e45 7272 6f72 2061 7320 6572 726f 723a nError as error:\n-000318b0: 0a20 2020 2020 2020 2020 2020 2072 6169 . rai\n-000318c0: 7365 2043 6861 6e6e 656c 4572 726f 7228 se ChannelError(\n-000318d0: 2761 6363 6573 732d 6465 6e69 6564 2729 'access-denied')\n-000318e0: 2066 726f 6d20 6572 726f 720a 2020 2020 from error. \n-000318f0: 2020 2020 6578 6365 7074 204f 5345 7272 except OSErr\n-00031900: 6f72 2061 7320 6572 726f 723a 0a20 2020 or as error:. \n-00031910: 2020 2020 2020 2020 206c 6f67 6765 722e logger.\n-00031920: 696e 666f 2822 4661 696c 6564 2074 6f20 info(\"Failed to \n-00031930: 7370 6177 6e20 2573 3a20 2573 222c 2061 spawn %s: %s\", a\n-00031940: 7267 732c 2073 7472 2865 7272 6f72 2929 rgs, str(error))\n-00031950: 0a20 2020 2020 2020 2020 2020 2072 6169 . rai\n-00031960: 7365 2043 6861 6e6e 656c 4572 726f 7228 se ChannelError(\n-00031970: 2769 6e74 6572 6e61 6c2d 6572 726f 7227 'internal-error'\n-00031980: 2920 6672 6f6d 2065 7272 6f72 0a27 2727 ) from error.'''\n-00031990: 2c0a 2020 2763 6f63 6b70 6974 2f63 6861 ,. 'cockpit/cha\n-000319a0: 6e6e 656c 732f 6462 7573 2e70 7927 3a20 nnels/dbus.py': \n-000319b0: 7227 2727 2320 5468 6973 2066 696c 6520 r'''# This file \n-000319c0: 6973 2070 6172 7420 6f66 2043 6f63 6b70 is part of Cockp\n-000319d0: 6974 2e0a 230a 2320 436f 7079 7269 6768 it..#.# Copyrigh\n-000319e0: 7420 2843 2920 3230 3232 2052 6564 2048 t (C) 2022 Red H\n-000319f0: 6174 2c20 496e 632e 0a23 0a23 2054 6869 at, Inc..#.# Thi\n-00031a00: 7320 7072 6f67 7261 6d20 6973 2066 7265 s program is fre\n-00031a10: 6520 736f 6674 7761 7265 3a20 796f 7520 e software: you \n-00031a20: 6361 6e20 7265 6469 7374 7269 6275 7465 can redistribute\n-00031a30: 2069 7420 616e 642f 6f72 206d 6f64 6966 it and/or modif\n-00031a40: 790a 2320 6974 2075 6e64 6572 2074 6865 y.# it under the\n-00031a50: 2074 6572 6d73 206f 6620 7468 6520 474e terms of the GN\n-00031a60: 5520 4765 6e65 7261 6c20 5075 626c 6963 U General Public\n-00031a70: 204c 6963 656e 7365 2061 7320 7075 626c License as publ\n-00031a80: 6973 6865 6420 6279 0a23 2074 6865 2046 ished by.# the F\n-00031a90: 7265 6520 536f 6674 7761 7265 2046 6f75 ree Software Fou\n-00031aa0: 6e64 6174 696f 6e2c 2065 6974 6865 7220 ndation, either \n-00031ab0: 7665 7273 696f 6e20 3320 6f66 2074 6865 version 3 of the\n-00031ac0: 204c 6963 656e 7365 2c20 6f72 0a23 2028 License, or.# (\n-00031ad0: 6174 2079 6f75 7220 6f70 7469 6f6e 2920 at your option) \n-00031ae0: 616e 7920 6c61 7465 7220 7665 7273 696f any later versio\n-00031af0: 6e2e 0a23 0a23 2054 6869 7320 7072 6f67 n..#.# This prog\n-00031b00: 7261 6d20 6973 2064 6973 7472 6962 7574 ram is distribut\n-00031b10: 6564 2069 6e20 7468 6520 686f 7065 2074 ed in the hope t\n-00031b20: 6861 7420 6974 2077 696c 6c20 6265 2075 hat it will be u\n-00031b30: 7365 6675 6c2c 0a23 2062 7574 2057 4954 seful,.# but WIT\n-00031b40: 484f 5554 2041 4e59 2057 4152 5241 4e54 HOUT ANY WARRANT\n-00031b50: 593b 2077 6974 686f 7574 2065 7665 6e20 Y; without even \n-00031b60: 7468 6520 696d 706c 6965 6420 7761 7272 the implied warr\n-00031b70: 616e 7479 206f 660a 2320 4d45 5243 4841 anty of.# MERCHA\n-00031b80: 4e54 4142 494c 4954 5920 6f72 2046 4954 NTABILITY or FIT\n-00031b90: 4e45 5353 2046 4f52 2041 2050 4152 5449 NESS FOR A PARTI\n-00031ba0: 4355 4c41 5220 5055 5250 4f53 452e 2020 CULAR PURPOSE. \n-00031bb0: 5365 6520 7468 650a 2320 474e 5520 4765 See the.# GNU Ge\n-00031bc0: 6e65 7261 6c20 5075 626c 6963 204c 6963 neral Public Lic\n-00031bd0: 656e 7365 2066 6f72 206d 6f72 6520 6465 ense for more de\n-00031be0: 7461 696c 732e 0a23 0a23 2059 6f75 2073 tails..#.# You s\n-00031bf0: 686f 756c 6420 6861 7665 2072 6563 6569 hould have recei\n-00031c00: 7665 6420 6120 636f 7079 206f 6620 7468 ved a copy of th\n-00031c10: 6520 474e 5520 4765 6e65 7261 6c20 5075 e GNU General Pu\n-00031c20: 626c 6963 204c 6963 656e 7365 0a23 2061 blic License.# a\n-00031c30: 6c6f 6e67 2077 6974 6820 7468 6973 2070 long with this p\n-00031c40: 726f 6772 616d 2e20 2049 6620 6e6f 742c rogram. If not,\n-00031c50: 2073 6565 203c 6874 7470 733a 2f2f 7777 see ...# Missing\n-00031c80: 2073 7475 6666 2063 6f6d 7061 7265 6420 stuff compared \n-00031c90: 746f 2074 6865 2043 2062 7269 6467 6520 to the C bridge \n-00031ca0: 7468 6174 2077 6520 7368 6f75 6c64 2070 that we should p\n-00031cb0: 726f 6261 626c 7920 6164 643a 0a23 0a23 robably add:.#.#\n-00031cc0: 202d 2072 656d 6f76 696e 6720 6d61 7463 - removing matc\n-00031cd0: 6865 730a 2320 2d20 7265 6d6f 7669 6e67 hes.# - removing\n-00031ce0: 2077 6174 6368 6573 0a23 202d 2065 6d69 watches.# - emi\n-00031cf0: 7474 696e 6720 6f66 2073 6967 6e61 6c73 tting of signals\n-00031d00: 0a23 202d 2070 7562 6c69 7368 696e 6720 .# - publishing \n-00031d10: 6f66 206f 626a 6563 7473 0a23 202d 2066 of objects.# - f\n-00031d20: 6169 6c69 6e67 206d 6f72 6520 6772 6163 ailing more grac\n-00031d30: 6566 756c 6c79 2069 6e20 736f 6d65 2063 efully in some c\n-00031d40: 6173 6573 2028 6475 7269 6e67 206f 7065 ases (during ope\n-00031d50: 6e2c 2065 7463 290a 230a 2320 5374 7566 n, etc).#.# Stuf\n-00031d60: 6620 7765 206d 6967 6874 206f 7220 6d69 f we might or mi\n-00031d70: 6768 7420 6e6f 7420 646f 3a0a 230a 2320 ght not do:.#.# \n-00031d80: 2d20 7573 696e 6720 6e6f 6e2d 6465 6661 - using non-defa\n-00031d90: 756c 7420 7365 7276 6963 6520 6e61 6d65 ult service name\n-00031da0: 730a 230a 2320 5374 7566 6620 7765 2073 s.#.# Stuff we s\n-00031db0: 686f 756c 6420 7072 6f62 6162 6c79 206e hould probably n\n-00031dc0: 6f74 2064 6f3a 0a23 0a23 202d 2065 6d75 ot do:.#.# - emu\n-00031dd0: 6c61 7469 6f6e 206f 6620 4f62 6a65 6374 lation of Object\n-00031de0: 4d61 6e61 6765 7220 7669 6120 7265 6375 Manager via recu\n-00031df0: 7273 6976 6520 696e 7472 6f73 7065 6374 rsive introspect\n-00031e00: 696f 6e0a 2320 2d20 6175 746f 6d61 7469 ion.# - automati\n-00031e10: 6320 6465 7465 6374 696f 6e20 6f66 204f c detection of O\n-00031e20: 626a 6563 744d 616e 6167 6572 2062 656c bjectManager bel\n-00031e30: 6f77 2074 6865 2067 6976 656e 2070 6174 ow the given pat\n-00031e40: 685f 6e61 6d65 7370 6163 650a 2320 2d20 h_namespace.# - \n-00031e50: 7265 6375 7273 6976 6520 7363 7261 7069 recursive scrapi\n-00031e60: 6e67 206f 6620 7072 6f70 6572 7469 6573 ng of properties\n-00031e70: 2066 6f72 206e 6577 206f 626a 6563 7420 for new object \n-00031e80: 7061 7468 730a 2320 2020 2866 6f72 2070 paths.# (for p\n-00031e90: 6174 685f 6e61 6d65 7370 6163 6520 7761 ath_namespace wa\n-00031ea0: 7463 6865 7320 7468 6174 2064 6f6e 2774 tches that don't\n-00031eb0: 2068 6974 2061 6e20 4f62 6a65 6374 4d61 hit an ObjectMa\n-00031ec0: 6e61 6765 7229 0a0a 696d 706f 7274 2061 nager)..import a\n-00031ed0: 7379 6e63 696f 0a69 6d70 6f72 7420 6572 syncio.import er\n-00031ee0: 726e 6f0a 696d 706f 7274 206a 736f 6e0a rno.import json.\n-00031ef0: 696d 706f 7274 206c 6f67 6769 6e67 0a69 import logging.i\n-00031f00: 6d70 6f72 7420 7472 6163 6562 6163 6b0a mport traceback.\n-00031f10: 696d 706f 7274 2078 6d6c 2e65 7472 6565 import xml.etree\n-00031f20: 2e45 6c65 6d65 6e74 5472 6565 2061 7320 .ElementTree as \n-00031f30: 4554 0a0a 6672 6f6d 2063 6f63 6b70 6974 ET..from cockpit\n-00031f40: 2e5f 7665 6e64 6f72 2069 6d70 6f72 7420 ._vendor import \n-00031f50: 7379 7374 656d 645f 6374 7970 6573 0a66 systemd_ctypes.f\n-00031f60: 726f 6d20 636f 636b 7069 742e 5f76 656e rom cockpit._ven\n-00031f70: 646f 722e 7379 7374 656d 645f 6374 7970 dor.systemd_ctyp\n-00031f80: 6573 2069 6d70 6f72 7420 4275 732c 2042 es import Bus, B\n-00031f90: 7573 4572 726f 722c 2069 6e74 726f 7370 usError, introsp\n-00031fa0: 6563 7469 6f6e 0a0a 6672 6f6d 202e 2e63 ection..from ..c\n-00031fb0: 6861 6e6e 656c 2069 6d70 6f72 7420 4368 hannel import Ch\n-00031fc0: 616e 6e65 6c2c 2043 6861 6e6e 656c 4572 annel, ChannelEr\n-00031fd0: 726f 720a 0a6c 6f67 6765 7220 3d20 6c6f ror..logger = lo\n-00031fe0: 6767 696e 672e 6765 744c 6f67 6765 7228 gging.getLogger(\n-00031ff0: 5f5f 6e61 6d65 5f5f 290a 0a23 2054 6865 __name__)..# The\n-00032000: 2064 6275 736a 736f 6e33 2070 6179 6c6f dbusjson3 paylo\n-00032010: 6164 0a23 0a23 2054 6869 7320 6368 616e ad.#.# This chan\n-00032020: 6e65 6c20 7061 796c 6f61 6420 7479 7065 nel payload type\n-00032030: 2074 7261 6e73 6c61 7465 7320 4a53 4f4e translates JSON\n-00032040: 2065 6e63 6f64 6564 206d 6573 7361 6765 encoded message\n-00032050: 7320 6f6e 2061 0a23 2043 6f63 6b70 6974 s on a.# Cockpit\n-00032060: 2063 6861 6e6e 656c 2074 6f20 442d 4275 channel to D-Bu\n-00032070: 7320 6d65 7373 6167 6573 2c20 696e 2061 s messages, in a\n-00032080: 206d 6f73 746c 7920 7374 7261 6967 6874 mostly straight\n-00032090: 666f 7277 6172 6420 7761 792e 0a23 2053 forward way..# S\n-000320a0: 6565 2064 6f63 2f70 726f 746f 636f 6c2e ee doc/protocol.\n-000320b0: 6d64 2066 6f72 2061 2064 6573 6372 6970 md for a descrip\n-000320c0: 7469 6f6e 206f 6620 7468 6520 6261 7369 tion of the basi\n-000320d0: 6373 2e0a 230a 2320 486f 7765 7665 722c cs..#.# However,\n-000320e0: 2064 6275 736a 736f 6e33 206f 6666 6572 dbusjson3 offer\n-000320f0: 7320 736f 6d65 2061 6476 616e 6365 6420 s some advanced \n-00032100: 6665 6174 7572 6573 2061 7320 7765 6c6c features as well\n-00032110: 2074 6861 7420 6172 650a 2320 6d65 616e that are.# mean\n-00032120: 7420 746f 2073 7570 706f 7274 2074 6865 t to support the\n-00032130: 2022 6d61 6769 6322 2044 4275 7350 726f \"magic\" DBusPro\n-00032140: 7879 206f 626a 6563 7473 2069 6d70 6c65 xy objects imple\n-00032150: 6d65 6e74 6564 2062 790a 2320 636f 636b mented by.# cock\n-00032160: 7069 742e 6a73 2e20 2054 686f 7365 2070 pit.js. Those p\n-00032170: 726f 7879 206f 626a 6563 7473 2022 6d61 roxy objects \"ma\n-00032180: 6769 6361 6c6c 7922 2065 7870 6f73 6520 gically\" expose \n-00032190: 616c 6c20 7468 6520 6d65 7468 6f64 730a all the methods.\n-000321a0: 2320 616e 6420 7072 6f70 6572 7469 6573 # and properties\n-000321b0: 206f 6620 6120 442d 4275 7320 696e 7465 of a D-Bus inte\n-000321c0: 7266 6163 6520 7769 7468 6f75 7420 7265 rface without re\n-000321d0: 7175 6972 696e 6720 616e 7920 6578 706c quiring any expl\n-000321e0: 6963 6974 0a23 2062 696e 6469 6e67 2063 icit.# binding c\n-000321f0: 6f64 6520 746f 2062 6520 6765 6e65 7261 ode to be genera\n-00032200: 7465 6420 666f 7220 6120 4a61 7661 5363 ted for a JavaSc\n-00032210: 7269 7074 2063 6c69 656e 742e 2020 4120 ript client. A \n-00032220: 6462 7573 6a73 6f6e 330a 2320 6368 616e dbusjson3.# chan\n-00032230: 6e65 6c20 646f 6573 2074 6869 7320 6279 nel does this by\n-00032240: 2064 6f69 6e67 2061 7574 6f6d 6174 6963 doing automatic\n-00032250: 2069 6e74 726f 7370 6563 7469 6f6e 2061 introspection a\n-00032260: 6e64 2070 726f 7065 7274 790a 2320 7265 nd property.# re\n-00032270: 7472 6965 7661 6c20 7769 7468 6f75 7420 trieval without \n-00032280: 6d75 6368 2064 6972 6563 7469 6f6e 2066 much direction f\n-00032290: 726f 6d20 7468 6520 4a61 7661 5363 7269 rom the JavaScri\n-000322a0: 7074 2063 6c69 656e 742e 0a23 0a23 2054 pt client..#.# T\n-000322b0: 6865 2064 6574 6169 6c73 206f 6620 7768 he details of wh\n-000322c0: 6174 2065 7861 6374 6c79 2069 7320 646f at exactly is do\n-000322d0: 6e65 2069 7320 6e6f 7420 7370 6563 6966 ne is not specif\n-000322e0: 6965 6420 7665 7279 2073 7472 6963 746c ied very strictl\n-000322f0: 792c 0a23 2061 6e64 2074 6865 2050 7974 y,.# and the Pyt\n-00032300: 686f 6e20 6272 6964 6765 2077 696c 6c20 hon bridge will \n-00032310: 6c69 6b65 6c79 2064 6966 6665 7220 6672 likely differ fr\n-00032320: 6f6d 2074 6865 2043 2062 7269 6467 650a om the C bridge.\n-00032330: 2320 7369 676e 6966 6963 616e 746c 792e # significantly.\n-00032340: 2054 6869 7320 7769 6c6c 2062 6520 696e This will be in\n-00032350: 666f 726d 6564 2062 7920 7768 6174 2065 formed by what e\n-00032360: 7869 7374 696e 6720 636f 6465 2061 6374 xisting code act\n-00032370: 7561 6c6c 790a 2320 6e65 6564 732c 2061 ually.# needs, a\n-00032380: 6e64 2077 6520 6d69 6768 7420 656e 6420 nd we might end \n-00032390: 7570 2077 6974 6820 6120 6d6f 7265 2063 up with a more c\n-000323a0: 6f6e 6372 6574 6520 6465 7363 7269 7074 oncrete descript\n-000323b0: 696f 6e20 6f66 2077 6861 740a 2320 6120 ion of what.# a \n-000323c0: 636c 6965 6e74 2063 616e 2061 6374 7561 client can actua\n-000323d0: 6c6c 7920 6578 7065 6374 2e0a 230a 2320 lly expect..#.# \n-000323e0: 4865 7265 2069 7320 616e 2065 7861 6d70 Here is an examp\n-000323f0: 6c65 206f 6620 6120 6d6f 7265 2063 6f6d le of a more com\n-00032400: 706c 6578 2073 6365 6e61 7269 6f3a 0a23 plex scenario:.#\n-00032410: 0a23 202d 2054 6865 2063 6c69 656e 7420 .# - The client \n-00032420: 6164 6473 2061 2022 7761 7463 6822 2066 adds a \"watch\" f\n-00032430: 6f72 2061 2070 6174 6820 6e61 6d65 7370 or a path namesp\n-00032440: 6163 652e 2020 5468 6572 6520 6973 2061 ace. There is a\n-00032450: 0a23 2020 204f 626a 6563 744d 616e 6167 .# ObjectManag\n-00032460: 6572 2061 7420 7468 6520 6769 7665 6e20 er at the given \n-00032470: 7061 7468 2061 6e64 2074 6865 2062 7269 path and the bri\n-00032480: 6467 6520 656d 6974 7320 226d 6574 6122 dge emits \"meta\"\n-00032490: 2061 6e64 0a23 2020 2022 6e6f 7469 6679 and.# \"notify\n-000324a0: 2220 6d65 7373 6167 6573 2074 6f20 6465 \" messages to de\n-000324b0: 7363 7269 6265 2061 6c6c 2069 6e74 6572 scribe all inter\n-000324c0: 6661 6365 7320 616e 6420 6f62 6a65 6374 faces and object\n-000324d0: 7320 7265 706f 7274 6564 0a23 2020 2062 s reported.# b\n-000324e0: 7920 7468 6174 204f 626a 6563 744d 616e y that ObjectMan\n-000324f0: 6167 6572 2e0a 230a 2320 2d20 5468 6520 ager..#.# - The \n-00032500: 636c 6965 6e74 206d 616b 6573 2061 206d client makes a m\n-00032510: 6574 686f 6420 6361 6c6c 2074 6861 7420 ethod call that \n-00032520: 6361 7573 6573 2061 206e 6577 206f 626a causes a new obj\n-00032530: 6563 7420 7769 7468 2061 206e 6577 0a23 ect with a new.#\n-00032540: 2020 2069 6e74 6572 6661 6365 2074 6f20 interface to \n-00032550: 6170 7065 6172 2061 7420 7468 6520 4f62 appear at the Ob\n-00032560: 6a65 6374 4d61 6e61 6765 722e 2020 5468 jectManager. Th\n-00032570: 6520 6272 6964 6765 2077 696c 6c20 7365 e bridge will se\n-00032580: 6e64 2061 0a23 2020 2022 6d65 7461 2220 nd a.# \"meta\" \n-00032590: 616e 6420 226e 6f74 6966 7922 206d 6573 and \"notify\" mes\n-000325a0: 7361 6765 2074 6f20 6465 7363 7269 6265 sage to describe\n-000325b0: 2074 6869 7320 6e65 7720 6f62 6a65 6374 this new object\n-000325c0: 2e0a 230a 2320 2d20 5369 6e63 6520 7468 ..#.# - Since th\n-000325d0: 6520 496e 7465 7266 6163 6573 4164 6465 e InterfacesAdde\n-000325e0: 6420 7369 676e 616c 2077 6173 2065 6d69 d signal was emi\n-000325f0: 7474 6564 2062 6566 6f72 6520 7468 6520 tted before the \n-00032600: 6d65 7468 6f64 0a23 2020 2072 6570 6c79 method.# reply\n-00032610: 2c20 7468 6520 6272 6964 6765 206d 7573 , the bridge mus\n-00032620: 7420 7365 6e64 2074 6865 2022 6d65 7461 t send the \"meta\n-00032630: 2220 616e 6420 226e 6f74 6966 7922 206d \" and \"notify\" m\n-00032640: 6573 7361 6765 730a 2320 2020 6265 666f essages.# befo\n-00032650: 7265 2074 6865 206d 6574 686f 6420 7265 re the method re\n-00032660: 706c 7920 6d65 7373 6167 652e 0a23 0a23 ply message..#.#\n-00032670: 202d 2048 6f77 6576 6572 2c20 696e 206f - However, in o\n-00032680: 7264 6572 2074 6f20 636f 6e73 7472 7563 rder to construc\n-00032690: 7420 7468 6520 226d 6574 6122 206d 6573 t the \"meta\" mes\n-000326a0: 7361 6765 2c20 7468 6520 6272 6964 6765 sage, the bridge\n-000326b0: 206d 7573 740a 2320 2020 7065 7266 6f72 must.# perfor\n-000326c0: 6d20 6120 496e 7472 6f73 7065 6374 2063 m a Introspect c\n-000326d0: 616c 6c2c 2061 6e64 2063 6f6e 7365 7175 all, and consequ\n-000326e0: 656e 746c 7920 6d75 7374 2064 656c 6179 ently must delay\n-000326f0: 2073 656e 6469 6e67 2074 6865 0a23 2020 sending the.# \n-00032700: 206d 6574 686f 6420 7265 706c 7920 756e method reply un\n-00032710: 7469 6c20 7468 6174 2063 616c 6c20 6861 til that call ha\n-00032720: 7320 6669 6e69 7368 6564 2e0a 230a 2320 s finished..#.# \n-00032730: 5468 6520 5079 7468 6f6e 2062 7269 6467 The Python bridg\n-00032740: 6520 696d 706c 656d 656e 7473 2074 6869 e implements thi\n-00032750: 7320 6465 6c61 7969 6e67 206f 6620 6d65 s delaying of me\n-00032760: 7373 6167 6573 2077 6974 680a 2320 636f ssages with.# co\n-00032770: 726f 7574 696e 6573 2061 6e64 2061 2066 routines and a f\n-00032780: 6169 7220 6d75 7465 782e 2045 7665 7279 air mutex. Every\n-00032790: 206d 6573 7361 6765 2063 6f6d 696e 6720 message coming \n-000327a0: 6672 6f6d 2044 2d42 7573 2077 696c 6c0a from D-Bus will.\n-000327b0: 2320 7761 6974 206f 6e20 7468 6520 6d75 # wait on the mu\n-000327c0: 7465 7820 666f 7220 6974 7320 7475 726e tex for its turn\n-000327d0: 2074 6f20 7365 6e64 2069 7473 206d 6573 to send its mes\n-000327e0: 7361 6765 206f 6e20 7468 6520 436f 636b sage on the Cock\n-000327f0: 7069 740a 2320 6368 616e 6e65 6c2c 2061 pit.# channel, a\n-00032800: 6e64 2077 696c 6c20 6b65 6570 2074 6861 nd will keep tha\n-00032810: 7420 6d75 7465 7820 6c6f 636b 6564 2075 t mutex locked u\n-00032820: 6e74 696c 2069 7420 6973 2064 6f6e 6520 ntil it is done \n-00032830: 7769 7468 0a23 2073 656e 6469 6e67 2e20 with.# sending. \n-00032840: 2053 696e 6365 2074 6865 206d 7574 6578 Since the mutex\n-00032850: 2069 7320 6661 6972 2c20 6576 6572 796f is fair, everyo\n-00032860: 6e65 2077 696c 6c20 6e69 6365 6c79 2077 ne will nicely w\n-00032870: 6169 7420 696e 206c 696e 650a 2320 7769 ait in line.# wi\n-00032880: 7468 6f75 7420 6d65 7373 6167 6573 2067 thout messages g\n-00032890: 6574 7469 6e67 2072 652d 6f72 6465 7265 etting re-ordere\n-000328a0: 642e 0a23 0a23 2054 6865 2073 6365 6e61 d..#.# The scena\n-000328b0: 7269 6f20 6162 6f76 6520 7769 6c6c 2070 rio above will p\n-000328c0: 6c61 7920 6f75 7420 6c69 6b65 2074 6869 lay out like thi\n-000328d0: 733a 0a23 0a23 202d 2057 6869 6c65 2061 s:.#.# - While a\n-000328e0: 6464 696e 6720 7468 6520 696e 6974 6961 dding the initia\n-000328f0: 6c20 2277 6174 6368 222c 2074 6865 206c l \"watch\", the l\n-00032900: 6f63 6b20 6973 2068 656c 6420 756e 7469 ock is held unti\n-00032910: 6c20 7468 650a 2320 2020 226d 6574 6122 l the.# \"meta\"\n-00032920: 2061 6e64 2022 6e6f 7469 6679 2220 6d65 and \"notify\" me\n-00032930: 7373 6167 6573 2068 6176 6520 6265 656e ssages have been\n-00032940: 2073 656e 742e 0a23 0a23 202d 204c 6174 sent..#.# - Lat\n-00032950: 6572 2c20 7768 656e 2074 6865 2049 6e74 er, when the Int\n-00032960: 6572 6661 6365 7341 6464 6564 2073 6967 erfacesAdded sig\n-00032970: 6e61 6c20 636f 6d65 7320 696e 2074 6861 nal comes in tha\n-00032980: 7420 6861 7320 6265 656e 0a23 2020 2074 t has been.# t\n-00032990: 7269 6767 6572 6564 2062 7920 7468 6520 riggered by the \n-000329a0: 6d65 7468 6f64 2063 616c 6c2c 2074 6865 method call, the\n-000329b0: 206d 7574 6578 2077 696c 6c20 6265 206c mutex will be l\n-000329c0: 6f63 6b65 6420 7768 696c 6520 7468 650a ocked while the.\n-000329d0: 2320 2020 6e65 6365 7373 6172 7920 696e # necessary in\n-000329e0: 7472 6f73 7065 6374 696f 6e20 6973 2067 trospection is g\n-000329f0: 6f69 6e67 206f 6e2e 0a23 0a23 202d 2054 oing on..#.# - T\n-00032a00: 6865 206d 6574 686f 6420 7265 706c 7920 he method reply \n-00032a10: 7769 6c6c 206c 696b 656c 7920 636f 6d65 will likely come\n-00032a20: 2077 6869 6c65 2074 6865 206d 7574 6578 while the mutex\n-00032a30: 2069 7320 6c6f 636b 6564 2c20 616e 640a is locked, and.\n-00032a40: 2320 2020 7468 6520 7461 736b 2066 6f72 # the task for\n-00032a50: 2073 656e 6469 6e67 2074 6861 7420 7265 sending that re\n-00032a60: 706c 7920 6f6e 2074 6865 2043 6f63 6b70 ply on the Cockp\n-00032a70: 6974 2063 6861 6e6e 656c 2077 696c 6c20 it channel will \n-00032a80: 656e 7465 720a 2320 2020 7468 6520 7761 enter.# the wa\n-00032a90: 6974 2071 7565 7565 206f 6620 7468 6520 it queue of the \n-00032aa0: 6d75 7465 782e 0a23 0a23 202d 204f 6e63 mutex..#.# - Onc\n-00032ab0: 6520 7468 6520 696e 7472 6f73 7065 6374 e the introspect\n-00032ac0: 696f 6e20 6973 2064 6f6e 6520 616e 6420 ion is done and \n-00032ad0: 7468 6520 6e65 7720 226d 6574 6122 2061 the new \"meta\" a\n-00032ae0: 6e64 2022 6e6f 7469 6679 220a 2320 2020 nd \"notify\".# \n-00032af0: 6d65 7373 6167 6573 2068 6176 6520 6265 messages have be\n-00032b00: 656e 2073 656e 742c 2074 6865 206d 7574 en sent, the mut\n-00032b10: 6578 2069 7320 756e 6c6f 636b 6564 2c20 ex is unlocked, \n-00032b20: 7468 6520 6d65 7468 6f64 2072 6570 6c79 the method reply\n-00032b30: 0a23 2020 2074 6173 6b20 6163 7175 6972 .# task acquir\n-00032b40: 6573 2069 742c 2061 6e64 2073 656e 6473 es it, and sends\n-00032b50: 2069 7473 206d 6573 7361 6765 2e0a 0a0a its message....\n-00032b60: 636c 6173 7320 496e 7465 7266 6163 6543 class InterfaceC\n-00032b70: 6163 6865 3a0a 2020 2020 6465 6620 5f5f ache:. def __\n-00032b80: 696e 6974 5f5f 2873 656c 6629 3a0a 2020 init__(self):. \n-00032b90: 2020 2020 2020 7365 6c66 2e63 6163 6865 self.cache\n-00032ba0: 203d 207b 7d0a 2020 2020 2020 2020 7365 = {}. se\n-00032bb0: 6c66 2e6f 6c64 203d 2073 6574 2829 2020 lf.old = set() \n-00032bc0: 2320 496e 7465 7266 6163 6573 2061 6c72 # Interfaces alr\n-00032bd0: 6561 6479 2072 6574 7572 6e65 6420 6279 eady returned by\n-00032be0: 2067 6574 5f69 6e74 6572 6661 6365 5f69 get_interface_i\n-00032bf0: 665f 6e65 770a 0a20 2020 2064 6566 2069 f_new.. def i\n-00032c00: 6e6a 6563 7428 7365 6c66 2c20 696e 7465 nject(self, inte\n-00032c10: 7266 6163 6573 293a 0a20 2020 2020 2020 rfaces):. \n-00032c20: 2073 656c 662e 6361 6368 652e 7570 6461 self.cache.upda\n-00032c30: 7465 2869 6e74 6572 6661 6365 7329 0a0a te(interfaces)..\n-00032c40: 2020 2020 6173 796e 6320 6465 6620 696e async def in\n-00032c50: 7472 6f73 7065 6374 5f70 6174 6828 7365 trospect_path(se\n-00032c60: 6c66 2c20 6275 732c 2064 6573 7469 6e61 lf, bus, destina\n-00032c70: 7469 6f6e 2c20 6f62 6a65 6374 5f70 6174 tion, object_pat\n-00032c80: 6829 3a0a 2020 2020 2020 2020 786d 6c2c h):. xml,\n-00032c90: 203d 2061 7761 6974 2062 7573 2e63 616c = await bus.cal\n-00032ca0: 6c5f 6d65 7468 6f64 5f61 7379 6e63 2864 l_method_async(d\n-00032cb0: 6573 7469 6e61 7469 6f6e 2c20 6f62 6a65 estination, obje\n-00032cc0: 6374 5f70 6174 682c 0a20 2020 2020 2020 ct_path,. \n-00032cd0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00032ce0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00032cf0: 2020 2020 276f 7267 2e66 7265 6564 6573 'org.freedes\n-00032d00: 6b74 6f70 2e44 4275 732e 496e 7472 6f73 ktop.DBus.Intros\n-00032d10: 7065 6374 6162 6c65 272c 0a20 2020 2020 pectable',. \n-00032d20: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00032d30: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00032d40: 2020 2020 2020 2749 6e74 726f 7370 6563 'Introspec\n-00032d50: 7427 290a 0a20 2020 2020 2020 2065 7420 t').. et \n-00032d60: 3d20 4554 2e66 726f 6d73 7472 696e 6728 = ET.fromstring(\n-00032d70: 786d 6c29 0a0a 2020 2020 2020 2020 696e xml).. in\n-00032d80: 7465 7266 6163 6573 203d 207b 7461 672e terfaces = {tag.\n-00032d90: 6174 7472 6962 5b27 6e61 6d65 275d 3a20 attrib['name']: \n-00032da0: 696e 7472 6f73 7065 6374 696f 6e2e 7061 introspection.pa\n-00032db0: 7273 655f 696e 7465 7266 6163 6528 7461 rse_interface(ta\n-00032dc0: 6729 2066 6f72 2074 6167 2069 6e20 6574 g) for tag in et\n-00032dd0: 2e66 696e 6461 6c6c 2827 696e 7465 7266 .findall('interf\n-00032de0: 6163 6527 297d 0a0a 2020 2020 2020 2020 ace')}.. \n-00032df0: 2320 4164 6420 616c 6c20 696e 7465 7266 # Add all interf\n-00032e00: 6163 6573 2077 6520 666f 756e 643a 2077 aces we found: w\n-00032e10: 6520 6d69 6768 7420 7573 6520 7468 656d e might use them\n-00032e20: 206c 6174 6572 0a20 2020 2020 2020 2073 later. s\n-00032e30: 656c 662e 696e 6a65 6374 2869 6e74 6572 elf.inject(inter\n-00032e40: 6661 6365 7329 0a0a 2020 2020 2020 2020 faces).. \n-00032e50: 7265 7475 726e 2069 6e74 6572 6661 6365 return interface\n-00032e60: 730a 0a20 2020 2061 7379 6e63 2064 6566 s.. async def\n-00032e70: 2067 6574 5f69 6e74 6572 6661 6365 2873 get_interface(s\n-00032e80: 656c 662c 2069 6e74 6572 6661 6365 5f6e elf, interface_n\n-00032e90: 616d 652c 2062 7573 3d4e 6f6e 652c 2064 ame, bus=None, d\n-00032ea0: 6573 7469 6e61 7469 6f6e 3d4e 6f6e 652c estination=None,\n-00032eb0: 206f 626a 6563 745f 7061 7468 3d4e 6f6e object_path=Non\n-00032ec0: 6529 3a0a 2020 2020 2020 2020 7472 793a e):. try:\n-00032ed0: 0a20 2020 2020 2020 2020 2020 2072 6574 . ret\n-00032ee0: 7572 6e20 7365 6c66 2e63 6163 6865 5b69 urn self.cache[i\n-00032ef0: 6e74 6572 6661 6365 5f6e 616d 655d 0a20 nterface_name]. \n-00032f00: 2020 2020 2020 2065 7863 6570 7420 4b65 except Ke\n-00032f10: 7945 7272 6f72 3a0a 2020 2020 2020 2020 yError:. \n-00032f20: 2020 2020 7061 7373 0a0a 2020 2020 2020 pass.. \n-00032f30: 2020 6966 2062 7573 2061 6e64 206f 626a if bus and obj\n-00032f40: 6563 745f 7061 7468 3a0a 2020 2020 2020 ect_path:. \n-00032f50: 2020 2020 2020 7472 793a 0a20 2020 2020 try:. \n-00032f60: 2020 2020 2020 2020 2020 2061 7761 6974 await\n-00032f70: 2073 656c 662e 696e 7472 6f73 7065 6374 self.introspect\n-00032f80: 5f70 6174 6828 6275 732c 2064 6573 7469 _path(bus, desti\n-00032f90: 6e61 7469 6f6e 2c20 6f62 6a65 6374 5f70 nation, object_p\n-00032fa0: 6174 6829 0a20 2020 2020 2020 2020 2020 ath). \n-00032fb0: 2065 7863 6570 7420 4275 7345 7272 6f72 except BusError\n-00032fc0: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n-00032fd0: 2020 7061 7373 0a0a 2020 2020 2020 2020 pass.. \n-00032fe0: 7265 7475 726e 2073 656c 662e 6361 6368 return self.cach\n-00032ff0: 652e 6765 7428 696e 7465 7266 6163 655f e.get(interface_\n-00033000: 6e61 6d65 290a 0a20 2020 2061 7379 6e63 name).. async\n-00033010: 2064 6566 2067 6574 5f69 6e74 6572 6661 def get_interfa\n-00033020: 6365 5f69 665f 6e65 7728 7365 6c66 2c20 ce_if_new(self, \n-00033030: 696e 7465 7266 6163 655f 6e61 6d65 2c20 interface_name, \n-00033040: 6275 732c 2064 6573 7469 6e61 7469 6f6e bus, destination\n-00033050: 2c20 6f62 6a65 6374 5f70 6174 6829 3a0a , object_path):.\n-00033060: 2020 2020 2020 2020 6966 2069 6e74 6572 if inter\n-00033070: 6661 6365 5f6e 616d 6520 696e 2073 656c face_name in sel\n-00033080: 662e 6f6c 643a 0a20 2020 2020 2020 2020 f.old:. \n-00033090: 2020 2072 6574 7572 6e20 4e6f 6e65 0a20 return None. \n-000330a0: 2020 2020 2020 2073 656c 662e 6f6c 642e self.old.\n-000330b0: 6164 6428 696e 7465 7266 6163 655f 6e61 add(interface_na\n-000330c0: 6d65 290a 2020 2020 2020 2020 7265 7475 me). retu\n-000330d0: 726e 2061 7761 6974 2073 656c 662e 6765 rn await self.ge\n-000330e0: 745f 696e 7465 7266 6163 6528 696e 7465 t_interface(inte\n-000330f0: 7266 6163 655f 6e61 6d65 2c20 6275 732c rface_name, bus,\n-00033100: 2064 6573 7469 6e61 7469 6f6e 2c20 6f62 destination, ob\n-00033110: 6a65 6374 5f70 6174 6829 0a0a 2020 2020 ject_path).. \n-00033120: 6173 796e 6320 6465 6620 6765 745f 7369 async def get_si\n-00033130: 676e 6174 7572 6528 7365 6c66 2c20 696e gnature(self, in\n-00033140: 7465 7266 6163 655f 6e61 6d65 2c20 6d65 terface_name, me\n-00033150: 7468 6f64 2c20 6275 733d 4e6f 6e65 2c20 thod, bus=None, \n-00033160: 6465 7374 696e 6174 696f 6e3d 4e6f 6e65 destination=None\n-00033170: 2c20 6f62 6a65 6374 5f70 6174 683d 4e6f , object_path=No\n-00033180: 6e65 293a 0a20 2020 2020 2020 2069 6e74 ne):. int\n-00033190: 6572 6661 6365 203d 2061 7761 6974 2073 erface = await s\n-000331a0: 656c 662e 6765 745f 696e 7465 7266 6163 elf.get_interfac\n-000331b0: 6528 696e 7465 7266 6163 655f 6e61 6d65 e(interface_name\n-000331c0: 2c20 6275 732c 2064 6573 7469 6e61 7469 , bus, destinati\n-000331d0: 6f6e 2c20 6f62 6a65 6374 5f70 6174 6829 on, object_path)\n-000331e0: 0a20 2020 2020 2020 2069 6620 696e 7465 . if inte\n-000331f0: 7266 6163 6520 6973 204e 6f6e 653a 0a20 rface is None:. \n-00033200: 2020 2020 2020 2020 2020 2072 6169 7365 raise\n-00033210: 204b 6579 4572 726f 7228 6627 496e 7465 KeyError(f'Inte\n-00033220: 7266 6163 6520 7b69 6e74 6572 6661 6365 rface {interface\n-00033230: 5f6e 616d 657d 2069 7320 6e6f 7420 666f _name} is not fo\n-00033240: 756e 6427 290a 0a20 2020 2020 2020 2072 und').. r\n-00033250: 6574 7572 6e20 2727 2e6a 6f69 6e28 696e eturn ''.join(in\n-00033260: 7465 7266 6163 655b 276d 6574 686f 6473 terface['methods\n-00033270: 275d 5b6d 6574 686f 645d 5b27 696e 275d '][method]['in']\n-00033280: 290a 0a0a 6465 6620 6e6f 7469 6679 5f75 )...def notify_u\n-00033290: 7064 6174 6528 6e6f 7469 6679 2c20 7061 pdate(notify, pa\n-000332a0: 7468 2c20 696e 7465 7266 6163 655f 6e61 th, interface_na\n-000332b0: 6d65 2c20 7072 6f70 7329 3a0a 2020 2020 me, props):. \n-000332c0: 6e6f 7469 6679 2e73 6574 6465 6661 756c notify.setdefaul\n-000332d0: 7428 7061 7468 2c20 7b7d 295b 696e 7465 t(path, {})[inte\n-000332e0: 7266 6163 655f 6e61 6d65 5d20 3d20 7b6b rface_name] = {k\n-000332f0: 3a20 762e 7661 6c75 6520 666f 7220 6b2c : v.value for k,\n-00033300: 2076 2069 6e20 7072 6f70 732e 6974 656d v in props.item\n-00033310: 7328 297d 0a0a 0a63 6c61 7373 2044 4275 s()}...class DBu\n-00033320: 7343 6861 6e6e 656c 2843 6861 6e6e 656c sChannel(Channel\n-00033330: 293a 0a20 2020 206a 736f 6e5f 656e 636f ):. json_enco\n-00033340: 6465 7220 3d20 7379 7374 656d 645f 6374 der = systemd_ct\n-00033350: 7970 6573 2e4a 534f 4e45 6e63 6f64 6572 ypes.JSONEncoder\n-00033360: 2869 6e64 656e 743d 3229 0a20 2020 2070 (indent=2). p\n-00033370: 6179 6c6f 6164 203d 2027 6462 7573 2d6a ayload = 'dbus-j\n-00033380: 736f 6e33 270a 0a20 2020 206d 6174 6368 son3'.. match\n-00033390: 6573 203d 204e 6f6e 650a 2020 2020 6e61 es = None. na\n-000333a0: 6d65 203d 204e 6f6e 650a 2020 2020 6275 me = None. bu\n-000333b0: 7320 3d20 4e6f 6e65 0a20 2020 206f 776e s = None. own\n-000333c0: 6572 203d 204e 6f6e 650a 0a20 2020 2061 er = None.. a\n-000333d0: 7379 6e63 2064 6566 2073 6574 7570 5f6e sync def setup_n\n-000333e0: 616d 655f 6f77 6e65 725f 7472 6163 6b69 ame_owner_tracki\n-000333f0: 6e67 2873 656c 6629 3a0a 2020 2020 2020 ng(self):. \n-00033400: 2020 6465 6620 7365 6e64 5f6f 776e 6572 def send_owner\n-00033410: 286f 776e 6572 293a 0a20 2020 2020 2020 (owner):. \n-00033420: 2020 2020 2023 2057 6520 6d75 7374 2062 # We must b\n-00033430: 6520 6361 7265 6675 6c20 6e6f 7420 746f e careful not to\n-00033440: 2073 656e 6420 6475 706c 6963 6174 6520 send duplicate \n-00033450: 6f77 6e65 720a 2020 2020 2020 2020 2020 owner. \n-00033460: 2020 2320 6e6f 7469 6669 6361 7469 6f6e # notification\n-00033470: 732e 2063 6f63 6b70 6974 2e6a 7320 7265 s. cockpit.js re\n-00033480: 6c69 6573 206f 6e20 7468 6174 2e0a 2020 lies on that.. \n-00033490: 2020 2020 2020 2020 2020 6966 2073 656c if sel\n-000334a0: 662e 6f77 6e65 7220 213d 206f 776e 6572 f.owner != owner\n-000334b0: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n-000334c0: 2020 7365 6c66 2e6f 776e 6572 203d 206f self.owner = o\n-000334d0: 776e 6572 0a20 2020 2020 2020 2020 2020 wner. \n-000334e0: 2020 2020 2073 656c 662e 7365 6e64 5f6a self.send_j\n-000334f0: 736f 6e28 6f77 6e65 723d 6f77 6e65 7229 son(owner=owner)\n-00033500: 0a0a 2020 2020 2020 2020 6465 6620 6861 .. def ha\n-00033510: 6e64 6c65 7228 6d65 7373 6167 6529 3a0a ndler(message):.\n-00033520: 2020 2020 2020 2020 2020 2020 5f6e 616d _nam\n-00033530: 652c 205f 6f6c 642c 206e 6577 203d 206d e, _old, new = m\n-00033540: 6573 7361 6765 2e67 6574 5f62 6f64 7928 essage.get_body(\n-00033550: 290a 2020 2020 2020 2020 2020 2020 7365 ). se\n-00033560: 6e64 5f6f 776e 6572 286f 776e 6572 3d6e nd_owner(owner=n\n-00033570: 6577 2069 6620 6e65 7720 213d 2022 2220 ew if new != \"\" \n-00033580: 656c 7365 204e 6f6e 6529 0a20 2020 2020 else None). \n-00033590: 2020 2073 656c 662e 6164 645f 7369 676e self.add_sign\n-000335a0: 616c 5f68 616e 646c 6572 2868 616e 646c al_handler(handl\n-000335b0: 6572 2c0a 2020 2020 2020 2020 2020 2020 er,. \n-000335c0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000335d0: 2020 2020 7365 6e64 6572 3d27 6f72 672e sender='org.\n-000335e0: 6672 6565 6465 736b 746f 702e 4442 7573 freedesktop.DBus\n-000335f0: 272c 0a20 2020 2020 2020 2020 2020 2020 ',. \n-00033600: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00033610: 2020 2070 6174 683d 272f 6f72 672f 6672 path='/org/fr\n-00033620: 6565 6465 736b 746f 702f 4442 7573 272c eedesktop/DBus',\n-00033630: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-00033640: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00033650: 2069 6e74 6572 6661 6365 3d27 6f72 672e interface='org.\n-00033660: 6672 6565 6465 736b 746f 702e 4442 7573 freedesktop.DBus\n-00033670: 272c 0a20 2020 2020 2020 2020 2020 2020 ',. \n-00033680: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00033690: 2020 206d 656d 6265 723d 274e 616d 654f member='NameO\n-000336a0: 776e 6572 4368 616e 6765 6427 2c0a 2020 wnerChanged',. \n-000336b0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000336c0: 2020 2020 2020 2020 2020 2020 2020 6172 ar\n-000336d0: 6730 3d73 656c 662e 6e61 6d65 290a 2020 g0=self.name). \n-000336e0: 2020 2020 2020 7472 793a 0a20 2020 2020 try:. \n-000336f0: 2020 2020 2020 2075 6e69 7175 655f 6e61 unique_na\n-00033700: 6d65 2c20 3d20 6177 6169 7420 7365 6c66 me, = await self\n-00033710: 2e62 7573 2e63 616c 6c5f 6d65 7468 6f64 .bus.call_method\n-00033720: 5f61 7379 6e63 2822 6f72 672e 6672 6565 _async(\"org.free\n-00033730: 6465 736b 746f 702e 4442 7573 222c 0a20 desktop.DBus\",. \n-00033740: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00033750: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00033760: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00033770: 2020 2020 2020 2020 2020 2022 2f6f 7267 \"/org\n-00033780: 2f66 7265 6564 6573 6b74 6f70 2f44 4275 /freedesktop/DBu\n-00033790: 7322 2c0a 2020 2020 2020 2020 2020 2020 s\",. \n-000337a0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000337b0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000337c0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000337d0: 226f 7267 2e66 7265 6564 6573 6b74 6f70 \"org.freedesktop\n-000337e0: 2e44 4275 7322 2c0a 2020 2020 2020 2020 .DBus\",. \n-000337f0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00033800: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00033810: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00033820: 2020 2020 2247 6574 4e61 6d65 4f77 6e65 \"GetNameOwne\n-00033830: 7222 2c20 2273 222c 2073 656c 662e 6e61 r\", \"s\", self.na\n-00033840: 6d65 290a 2020 2020 2020 2020 6578 6365 me). exce\n-00033850: 7074 2042 7573 4572 726f 7220 6173 2065 pt BusError as e\n-00033860: 7272 6f72 3a0a 2020 2020 2020 2020 2020 rror:. \n-00033870: 2020 6966 2065 7272 6f72 2e6e 616d 6520 if error.name \n-00033880: 3d3d 2022 6f72 672e 6672 6565 6465 736b == \"org.freedesk\n-00033890: 746f 702e 4442 7573 2e45 7272 6f72 2e4e top.DBus.Error.N\n-000338a0: 616d 6548 6173 4e6f 4f77 6e65 7222 3a0a ameHasNoOwner\":.\n-000338b0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000338c0: 2320 5472 7920 746f 2073 7461 7274 2069 # Try to start i\n-000338d0: 742e 2020 4966 2069 7420 7374 6172 7473 t. If it starts\n-000338e0: 2073 7563 6365 7373 6675 6c6c 792c 2077 successfully, w\n-000338f0: 6520 7769 6c6c 0a20 2020 2020 2020 2020 e will. \n-00033900: 2020 2020 2020 2023 2067 6574 2061 204e # get a N\n-00033910: 616d 654f 776e 6572 4368 616e 6765 6420 ameOwnerChanged \n-00033920: 7369 676e 616c 2028 7768 6963 6820 7769 signal (which wi\n-00033930: 6c6c 2073 6574 0a20 2020 2020 2020 2020 ll set. \n-00033940: 2020 2020 2020 2023 2073 656c 662e 6f77 # self.ow\n-00033950: 6e65 7229 2062 6566 6f72 6520 5374 6172 ner) before Star\n-00033960: 7453 6572 7669 6365 4279 4e61 6d65 2072 tServiceByName r\n-00033970: 6574 7572 6e73 2e0a 2020 2020 2020 2020 eturns.. \n-00033980: 2020 2020 2020 2020 7472 793a 0a20 2020 try:. \n-00033990: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000339a0: 2061 7761 6974 2073 656c 662e 6275 732e await self.bus.\n-000339b0: 6361 6c6c 5f6d 6574 686f 645f 6173 796e call_method_asyn\n-000339c0: 6328 226f 7267 2e66 7265 6564 6573 6b74 c(\"org.freedeskt\n-000339d0: 6f70 2e44 4275 7322 2c0a 2020 2020 2020 op.DBus\",. \n-000339e0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000339f0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00033a00: 2020 2020 2020 2020 2020 2020 2020 2022 \"\n-00033a10: 2f6f 7267 2f66 7265 6564 6573 6b74 6f70 /org/freedesktop\n-00033a20: 2f44 4275 7322 2c0a 2020 2020 2020 2020 /DBus\",. \n-00033a30: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00033a40: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00033a50: 2020 2020 2020 2020 2020 2020 2022 6f72 \"or\n-00033a60: 672e 6672 6565 6465 736b 746f 702e 4442 g.freedesktop.DB\n-00033a70: 7573 222c 0a20 2020 2020 2020 2020 2020 us\",. \n-00033a80: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00033a90: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00033aa0: 2020 2020 2020 2020 2020 2253 7461 7274 \"Start\n-00033ab0: 5365 7276 6963 6542 794e 616d 6522 2c20 ServiceByName\", \n-00033ac0: 2273 7522 2c20 7365 6c66 2e6e 616d 652c \"su\", self.name,\n-00033ad0: 2030 290a 2020 2020 2020 2020 2020 2020 0). \n-00033ae0: 2020 2020 6578 6365 7074 2042 7573 4572 except BusEr\n-00033af0: 726f 7220 6173 2073 7461 7274 5f65 7272 ror as start_err\n-00033b00: 6f72 3a0a 2020 2020 2020 2020 2020 2020 or:. \n-00033b10: 2020 2020 2020 2020 6c6f 6767 6572 2e64 logger.d\n-00033b20: 6562 7567 2822 4661 696c 6564 2074 6f20 ebug(\"Failed to \n-00033b30: 7374 6172 7420 7365 7276 6963 6520 2725 start service '%\n-00033b40: 7327 3a20 2573 222c 2073 656c 662e 6e61 s': %s\", self.na\n-00033b50: 6d65 2c20 7374 6172 745f 6572 726f 722e me, start_error.\n-00033b60: 6d65 7373 6167 6529 0a20 2020 2020 2020 message). \n-00033b70: 2020 2020 2020 2020 2020 2020 2073 656c sel\n-00033b80: 662e 7365 6e64 5f6a 736f 6e28 6f77 6e65 f.send_json(owne\n-00033b90: 723d 4e6f 6e65 290a 2020 2020 2020 2020 r=None). \n-00033ba0: 2020 2020 656c 7365 3a0a 2020 2020 2020 else:. \n-00033bb0: 2020 2020 2020 2020 2020 6c6f 6767 6572 logger\n-00033bc0: 2e64 6562 7567 2822 4661 696c 6564 2074 .debug(\"Failed t\n-00033bd0: 6f20 6765 7420 6f77 6e65 7220 6f66 2073 o get owner of s\n-00033be0: 6572 7669 6365 2027 2573 273a 2025 7322 ervice '%s': %s\"\n-00033bf0: 2c20 7365 6c66 2e6e 616d 652c 2065 7272 , self.name, err\n-00033c00: 6f72 2e6d 6573 7361 6765 290a 2020 2020 or.message). \n-00033c10: 2020 2020 656c 7365 3a0a 2020 2020 2020 else:. \n-00033c20: 2020 2020 2020 7365 6e64 5f6f 776e 6572 send_owner\n-00033c30: 2875 6e69 7175 655f 6e61 6d65 290a 0a20 (unique_name).. \n-00033c40: 2020 2064 6566 2064 6f5f 6f70 656e 2873 def do_open(s\n-00033c50: 656c 662c 206f 7074 696f 6e73 293a 0a20 elf, options):. \n-00033c60: 2020 2020 2020 2073 656c 662e 6361 6368 self.cach\n-00033c70: 6520 3d20 496e 7465 7266 6163 6543 6163 e = InterfaceCac\n-00033c80: 6865 2829 0a20 2020 2020 2020 2073 656c he(). sel\n-00033c90: 662e 6e61 6d65 203d 206f 7074 696f 6e73 f.name = options\n-00033ca0: 2e67 6574 2827 6e61 6d65 2729 0a20 2020 .get('name'). \n-00033cb0: 2020 2020 2073 656c 662e 6d61 7463 6865 self.matche\n-00033cc0: 7320 3d20 5b5d 0a0a 2020 2020 2020 2020 s = [].. \n-00033cd0: 6275 7320 3d20 6f70 7469 6f6e 732e 6765 bus = options.ge\n-00033ce0: 7428 2762 7573 2729 0a20 2020 2020 2020 t('bus'). \n-00033cf0: 2061 6464 7265 7373 203d 206f 7074 696f address = optio\n-00033d00: 6e73 2e67 6574 2827 6164 6472 6573 7327 ns.get('address'\n-00033d10: 290a 0a20 2020 2020 2020 2074 7279 3a0a ).. try:.\n-00033d20: 2020 2020 2020 2020 2020 2020 6966 2061 if a\n-00033d30: 6464 7265 7373 2069 7320 6e6f 7420 4e6f ddress is not No\n-00033d40: 6e65 3a0a 2020 2020 2020 2020 2020 2020 ne:. \n-00033d50: 2020 2020 6966 2062 7573 2069 7320 6e6f if bus is no\n-00033d60: 7420 4e6f 6e65 2061 6e64 2062 7573 2021 t None and bus !\n-00033d70: 3d20 276e 6f6e 6527 3a0a 2020 2020 2020 = 'none':. \n-00033d80: 2020 2020 2020 2020 2020 2020 2020 7261 ra\n-00033d90: 6973 6520 4368 616e 6e65 6c45 7272 6f72 ise ChannelError\n-00033da0: 2827 7072 6f74 6f63 6f6c 2d65 7272 6f72 ('protocol-error\n-00033db0: 272c 206d 6573 7361 6765 3d27 6f6e 6c79 ', message='only\n-00033dc0: 206f 6e65 206f 6620 2262 7573 2220 616e one of \"bus\" an\n-00033dd0: 6420 2261 6464 7265 7373 2220 6361 6e20 d \"address\" can \n-00033de0: 6265 2073 7065 6369 6669 6564 2729 0a20 be specified'). \n-00033df0: 2020 2020 2020 2020 2020 2020 2020 206c l\n-00033e00: 6f67 6765 722e 6465 6275 6728 2767 6574 ogger.debug('get\n-00033e10: 2062 7573 2077 6974 6820 6164 6472 6573 bus with addres\n-00033e20: 7320 2573 2066 6f72 2025 7327 2c20 6164 s %s for %s', ad\n-00033e30: 6472 6573 732c 2073 656c 662e 6e61 6d65 dress, self.name\n-00033e40: 290a 2020 2020 2020 2020 2020 2020 2020 ). \n-00033e50: 2020 7365 6c66 2e62 7573 203d 2042 7573 self.bus = Bus\n-00033e60: 2e6e 6577 2861 6464 7265 7373 3d61 6464 .new(address=add\n-00033e70: 7265 7373 2c20 6275 735f 636c 6965 6e74 ress, bus_client\n-00033e80: 3d73 656c 662e 6e61 6d65 2069 7320 6e6f =self.name is no\n-00033e90: 7420 4e6f 6e65 290a 2020 2020 2020 2020 t None). \n-00033ea0: 2020 2020 656c 6966 2062 7573 203d 3d20 elif bus == \n-00033eb0: 2769 6e74 6572 6e61 6c27 3a0a 2020 2020 'internal':. \n-00033ec0: 2020 2020 2020 2020 2020 2020 6c6f 6767 logg\n-00033ed0: 6572 2e64 6562 7567 2827 6765 7420 696e er.debug('get in\n-00033ee0: 7465 726e 616c 2062 7573 2066 6f72 2025 ternal bus for %\n-00033ef0: 7327 2c20 7365 6c66 2e6e 616d 6529 0a20 s', self.name). \n-00033f00: 2020 2020 2020 2020 2020 2020 2020 2073 s\n-00033f10: 656c 662e 6275 7320 3d20 7365 6c66 2e72 elf.bus = self.r\n-00033f20: 6f75 7465 722e 696e 7465 726e 616c 5f62 outer.internal_b\n-00033f30: 7573 2e63 6c69 656e 740a 2020 2020 2020 us.client. \n-00033f40: 2020 2020 2020 656c 7365 3a0a 2020 2020 else:. \n-00033f50: 2020 2020 2020 2020 2020 2020 6966 2062 if b\n-00033f60: 7573 203d 3d20 2773 6573 7369 6f6e 273a us == 'session':\n-00033f70: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-00033f80: 2020 2020 206c 6f67 6765 722e 6465 6275 logger.debu\n-00033f90: 6728 2767 6574 2073 6573 7369 6f6e 2062 g('get session b\n-00033fa0: 7573 2066 6f72 2025 7327 2c20 7365 6c66 us for %s', self\n-00033fb0: 2e6e 616d 6529 0a20 2020 2020 2020 2020 .name). \n-00033fc0: 2020 2020 2020 2020 2020 2073 656c 662e self.\n-00033fd0: 6275 7320 3d20 4275 732e 6465 6661 756c bus = Bus.defaul\n-00033fe0: 745f 7573 6572 2829 0a20 2020 2020 2020 t_user(). \n-00033ff0: 2020 2020 2020 2020 2065 6c69 6620 6275 elif bu\n-00034000: 7320 3d3d 2027 7379 7374 656d 2720 6f72 s == 'system' or\n-00034010: 2062 7573 2069 7320 4e6f 6e65 3a0a 2020 bus is None:. \n-00034020: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00034030: 2020 6c6f 6767 6572 2e64 6562 7567 2827 logger.debug('\n-00034040: 6765 7420 7379 7374 656d 2062 7573 2066 get system bus f\n-00034050: 6f72 2025 7327 2c20 7365 6c66 2e6e 616d or %s', self.nam\n-00034060: 6529 0a20 2020 2020 2020 2020 2020 2020 e). \n-00034070: 2020 2020 2020 2073 656c 662e 6275 7320 self.bus \n-00034080: 3d20 4275 732e 6465 6661 756c 745f 7379 = Bus.default_sy\n-00034090: 7374 656d 2829 0a20 2020 2020 2020 2020 stem(). \n-000340a0: 2020 2020 2020 2065 6c73 653a 0a20 2020 else:. \n-000340b0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000340c0: 2072 6169 7365 2043 6861 6e6e 656c 4572 raise ChannelEr\n-000340d0: 726f 7228 2770 726f 746f 636f 6c2d 6572 ror('protocol-er\n-000340e0: 726f 7227 2c20 6d65 7373 6167 653d 6627 ror', message=f'\n-000340f0: 696e 7661 6c69 6420 6275 7320 227b 6275 invalid bus \"{bu\n-00034100: 737d 2227 290a 2020 2020 2020 2020 6578 s}\"'). ex\n-00034110: 6365 7074 204f 5345 7272 6f72 2061 7320 cept OSError as \n-00034120: 6578 633a 0a20 2020 2020 2020 2020 2020 exc:. \n-00034130: 2072 6169 7365 2043 6861 6e6e 656c 4572 raise ChannelEr\n-00034140: 726f 7228 2770 726f 746f 636f 6c2d 6572 ror('protocol-er\n-00034150: 726f 7227 2c20 6d65 7373 6167 653d 6627 ror', message=f'\n-00034160: 6661 696c 6564 2074 6f20 636f 6e6e 6563 failed to connec\n-00034170: 7420 746f 207b 6275 737d 2062 7573 3a20 t to {bus} bus: \n-00034180: 7b65 7863 7d27 2920 6672 6f6d 2065 7863 {exc}') from exc\n-00034190: 0a0a 2020 2020 2020 2020 7472 793a 0a20 .. try:. \n-000341a0: 2020 2020 2020 2020 2020 2073 656c 662e self.\n-000341b0: 6275 732e 6174 7461 6368 5f65 7665 6e74 bus.attach_event\n-000341c0: 284e 6f6e 652c 2030 290a 2020 2020 2020 (None, 0). \n-000341d0: 2020 6578 6365 7074 204f 5345 7272 6f72 except OSError\n-000341e0: 2061 7320 6572 723a 0a20 2020 2020 2020 as err:. \n-000341f0: 2020 2020 2069 6620 6572 722e 6572 726e if err.errn\n-00034200: 6f20 213d 2065 7272 6e6f 2e45 4255 5359 o != errno.EBUSY\n-00034210: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n-00034220: 2020 7261 6973 650a 0a20 2020 2020 2020 raise.. \n-00034230: 2023 2054 6869 7320 6e65 6564 7320 746f # This needs to\n-00034240: 2062 6520 6120 6661 6972 206d 7574 6578 be a fair mutex\n-00034250: 2073 6f20 7468 6174 206f 7574 676f 696e so that outgoin\n-00034260: 6720 6d65 7373 6167 6573 2064 6f6e 2774 g messages don't\n-00034270: 0a20 2020 2020 2020 2023 2067 6574 2072 . # get r\n-00034280: 652d 6f72 6465 7265 642e 2020 6173 796e e-ordered. asyn\n-00034290: 6369 6f2e 4c6f 636b 2069 7320 6661 6972 cio.Lock is fair\n-000342a0: 2e0a 2020 2020 2020 2020 7365 6c66 2e77 .. self.w\n-000342b0: 6174 6368 5f70 726f 6365 7373 696e 675f atch_processing_\n-000342c0: 6c6f 636b 203d 2061 7379 6e63 696f 2e4c lock = asyncio.L\n-000342d0: 6f63 6b28 290a 0a20 2020 2020 2020 2069 ock().. i\n-000342e0: 6620 7365 6c66 2e6e 616d 6520 6973 206e f self.name is n\n-000342f0: 6f74 204e 6f6e 653a 0a20 2020 2020 2020 ot None:. \n-00034300: 2020 2020 2061 7379 6e63 2064 6566 2067 async def g\n-00034310: 6574 5f72 6561 6479 2829 3a0a 2020 2020 et_ready():. \n-00034320: 2020 2020 2020 2020 2020 2020 6173 796e asyn\n-00034330: 6320 7769 7468 2073 656c 662e 7761 7463 c with self.watc\n-00034340: 685f 7072 6f63 6573 7369 6e67 5f6c 6f63 h_processing_loc\n-00034350: 6b3a 0a20 2020 2020 2020 2020 2020 2020 k:. \n-00034360: 2020 2020 2020 2061 7761 6974 2073 656c await sel\n-00034370: 662e 7365 7475 705f 6e61 6d65 5f6f 776e f.setup_name_own\n-00034380: 6572 5f74 7261 636b 696e 6728 290a 2020 er_tracking(). \n-00034390: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000343a0: 2020 6966 2073 656c 662e 6f77 6e65 723a if self.owner:\n-000343b0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-000343c0: 2020 2020 2020 2020 2073 656c 662e 7265 self.re\n-000343d0: 6164 7928 756e 6971 7565 5f6e 616d 653d ady(unique_name=\n-000343e0: 7365 6c66 2e6f 776e 6572 290a 2020 2020 self.owner). \n-000343f0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00034400: 656c 7365 3a0a 2020 2020 2020 2020 2020 else:. \n-00034410: 2020 2020 2020 2020 2020 2020 2020 7365 se\n-00034420: 6c66 2e63 6c6f 7365 287b 2770 726f 626c lf.close({'probl\n-00034430: 656d 273a 2027 6e6f 742d 666f 756e 6427 em': 'not-found'\n-00034440: 7d29 0a20 2020 2020 2020 2020 2020 2073 }). s\n-00034450: 656c 662e 6372 6561 7465 5f74 6173 6b28 elf.create_task(\n-00034460: 6765 745f 7265 6164 7928 2929 0a20 2020 get_ready()). \n-00034470: 2020 2020 2065 6c73 653a 0a20 2020 2020 else:. \n-00034480: 2020 2020 2020 2073 656c 662e 7265 6164 self.read\n-00034490: 7928 290a 0a20 2020 2064 6566 2061 6464 y().. def add\n-000344a0: 5f73 6967 6e61 6c5f 6861 6e64 6c65 7228 _signal_handler(\n-000344b0: 7365 6c66 2c20 6861 6e64 6c65 722c 202a self, handler, *\n-000344c0: 2a6b 7761 7267 7329 3a0a 2020 2020 2020 *kwargs):. \n-000344d0: 2020 7220 3d20 6469 6374 282a 2a6b 7761 r = dict(**kwa\n-000344e0: 7267 7329 0a20 2020 2020 2020 2072 5b27 rgs). r['\n-000344f0: 7479 7065 275d 203d 2027 7369 676e 616c type'] = 'signal\n-00034500: 270a 2020 2020 2020 2020 6966 2027 7365 '. if 'se\n-00034510: 6e64 6572 2720 6e6f 7420 696e 2072 2061 nder' not in r a\n-00034520: 6e64 2073 656c 662e 6e61 6d65 2069 7320 nd self.name is \n-00034530: 6e6f 7420 4e6f 6e65 3a0a 2020 2020 2020 not None:. \n-00034540: 2020 2020 2020 725b 2773 656e 6465 7227 r['sender'\n-00034550: 5d20 3d20 7365 6c66 2e6e 616d 650a 2020 ] = self.name. \n-00034560: 2020 2020 2020 2320 4841 434b 202d 2068 # HACK - h\n-00034570: 7474 7073 3a2f 2f67 6974 6875 622e 636f ttps://github.co\n-00034580: 6d2f 6275 7331 2f64 6275 732d 6272 6f6b m/bus1/dbus-brok\n-00034590: 6572 2f69 7373 7565 732f 3330 390a 2020 er/issues/309. \n-000345a0: 2020 2020 2020 2320 7061 7468 5f6e 616d # path_nam\n-000345b0: 6573 7061 6365 3d27 2f27 2069 6e20 6120 espace='/' in a \n-000345c0: 7275 6c65 2064 6f65 7320 6e6f 7420 776f rule does not wo\n-000345d0: 726b 2e0a 2020 2020 2020 2020 6966 2072 rk.. if r\n-000345e0: 2e67 6574 2827 7061 7468 5f6e 616d 6573 .get('path_names\n-000345f0: 7061 6365 2729 203d 3d20 222f 223a 0a20 pace') == \"/\":. \n-00034600: 2020 2020 2020 2020 2020 2064 656c 2072 del r\n-00034610: 5b27 7061 7468 5f6e 616d 6573 7061 6365 ['path_namespace\n-00034620: 275d 0a0a 2020 2020 2020 2020 6465 6620 '].. def \n-00034630: 6669 6c74 6572 5f6f 776e 6572 286d 6573 filter_owner(mes\n-00034640: 7361 6765 293a 0a20 2020 2020 2020 2020 sage):. \n-00034650: 2020 2069 6620 7365 6c66 2e6f 776e 6572 if self.owner\n-00034660: 2069 7320 6e6f 7420 4e6f 6e65 2061 6e64 is not None and\n-00034670: 2073 656c 662e 6f77 6e65 7220 3d3d 206d self.owner == m\n-00034680: 6573 7361 6765 2e67 6574 5f73 656e 6465 essage.get_sende\n-00034690: 7228 293a 0a20 2020 2020 2020 2020 2020 r():. \n-000346a0: 2020 2020 2068 616e 646c 6572 286d 6573 handler(mes\n-000346b0: 7361 6765 290a 0a20 2020 2020 2020 2069 sage).. i\n-000346c0: 6620 7365 6c66 2e6e 616d 6520 6973 206e f self.name is n\n-000346d0: 6f74 204e 6f6e 6520 616e 6420 2773 656e ot None and 'sen\n-000346e0: 6465 7227 2069 6e20 7220 616e 6420 725b der' in r and r[\n-000346f0: 2773 656e 6465 7227 5d20 3d3d 2073 656c 'sender'] == sel\n-00034700: 662e 6e61 6d65 3a0a 2020 2020 2020 2020 f.name:. \n-00034710: 2020 2020 6675 6e63 203d 2066 696c 7465 func = filte\n-00034720: 725f 6f77 6e65 720a 2020 2020 2020 2020 r_owner. \n-00034730: 656c 7365 3a0a 2020 2020 2020 2020 2020 else:. \n-00034740: 2020 6675 6e63 203d 2068 616e 646c 6572 func = handler\n-00034750: 0a20 2020 2020 2020 2072 5f73 7472 696e . r_strin\n-00034760: 6720 3d20 272c 272e 6a6f 696e 2866 227b g = ','.join(f\"{\n-00034770: 6b65 797d 3d27 7b76 616c 7565 7d27 2220 key}='{value}'\" \n-00034780: 666f 7220 6b65 792c 2076 616c 7565 2069 for key, value i\n-00034790: 6e20 722e 6974 656d 7328 2929 0a20 2020 n r.items()). \n-000347a0: 2020 2020 2069 6620 6e6f 7420 7365 6c66 if not self\n-000347b0: 2e69 735f 636c 6f73 696e 6728 293a 0a20 .is_closing():. \n-000347c0: 2020 2020 2020 2020 2020 2023 2074 6869 # thi\n-000347d0: 7320 6765 7473 2061 6e20 4549 4e54 5220 s gets an EINTR \n-000347e0: 7665 7279 206f 6674 656e 2065 7370 6563 very often espec\n-000347f0: 6961 6c6c 7920 6f6e 2052 4845 4c20 380a ially on RHEL 8.\n-00034800: 2020 2020 2020 2020 2020 2020 7768 696c whil\n-00034810: 6520 5472 7565 3a0a 2020 2020 2020 2020 e True:. \n-00034820: 2020 2020 2020 2020 7472 793a 0a20 2020 try:. \n-00034830: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00034840: 206d 6174 6368 203d 2073 656c 662e 6275 match = self.bu\n-00034850: 732e 6164 645f 6d61 7463 6828 725f 7374 s.add_match(r_st\n-00034860: 7269 6e67 2c20 6675 6e63 290a 2020 2020 ring, func). \n-00034870: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00034880: 6272 6561 6b0a 2020 2020 2020 2020 2020 break. \n-00034890: 2020 2020 2020 6578 6365 7074 2049 6e74 except Int\n-000348a0: 6572 7275 7074 6564 4572 726f 723a 0a20 erruptedError:. \n-000348b0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000348c0: 2020 2070 6173 730a 0a20 2020 2020 2020 pass.. \n-000348d0: 2020 2020 2073 656c 662e 6d61 7463 6865 self.matche\n-000348e0: 732e 6170 7065 6e64 286d 6174 6368 290a s.append(match).\n-000348f0: 0a20 2020 2064 6566 2061 6464 5f61 7379 . def add_asy\n-00034900: 6e63 5f73 6967 6e61 6c5f 6861 6e64 6c65 nc_signal_handle\n-00034910: 7228 7365 6c66 2c20 6861 6e64 6c65 722c r(self, handler,\n-00034920: 202a 2a6b 7761 7267 7329 3a0a 2020 2020 **kwargs):. \n-00034930: 2020 2020 6465 6620 7379 6e63 5f68 616e def sync_han\n-00034940: 646c 6572 286d 6573 7361 6765 293a 0a20 dler(message):. \n-00034950: 2020 2020 2020 2020 2020 2073 656c 662e self.\n-00034960: 6372 6561 7465 5f74 6173 6b28 6861 6e64 create_task(hand\n-00034970: 6c65 7228 6d65 7373 6167 6529 290a 2020 ler(message)). \n-00034980: 2020 2020 2020 7365 6c66 2e61 6464 5f73 self.add_s\n-00034990: 6967 6e61 6c5f 6861 6e64 6c65 7228 7379 ignal_handler(sy\n-000349a0: 6e63 5f68 616e 646c 6572 2c20 2a2a 6b77 nc_handler, **kw\n-000349b0: 6172 6773 290a 0a20 2020 2061 7379 6e63 args).. async\n-000349c0: 2064 6566 2064 6f5f 6361 6c6c 2873 656c def do_call(sel\n-000349d0: 662c 206d 6573 7361 6765 293a 0a20 2020 f, message):. \n-000349e0: 2020 2020 2070 6174 682c 2069 6661 6365 path, iface\n-000349f0: 2c20 6d65 7468 6f64 2c20 6172 6773 203d , method, args =\n-00034a00: 206d 6573 7361 6765 5b27 6361 6c6c 275d message['call']\n-00034a10: 0a20 2020 2020 2020 2063 6f6f 6b69 6520 . cookie \n-00034a20: 3d20 6d65 7373 6167 652e 6765 7428 2769 = message.get('i\n-00034a30: 6427 290a 2020 2020 2020 2020 666c 6167 d'). flag\n-00034a40: 7320 3d20 6d65 7373 6167 652e 6765 7428 s = message.get(\n-00034a50: 2766 6c61 6773 2729 0a0a 2020 2020 2020 'flags').. \n-00034a60: 2020 7469 6d65 6f75 7420 3d20 6d65 7373 timeout = mess\n-00034a70: 6167 652e 6765 7428 2774 696d 656f 7574 age.get('timeout\n-00034a80: 2729 0a20 2020 2020 2020 2069 6620 7469 '). if ti\n-00034a90: 6d65 6f75 7420 6973 206e 6f74 204e 6f6e meout is not Non\n-00034aa0: 653a 0a20 2020 2020 2020 2020 2020 2023 e:. #\n-00034ab0: 2073 645f 6275 7320 7469 6d65 6f75 7420 sd_bus timeout \n-00034ac0: 6973 20ce bc73 2c20 636f 636b 7069 7420 is ..s, cockpit \n-00034ad0: 4150 4920 7469 6d65 6f75 7420 6973 206d API timeout is m\n-00034ae0: 730a 2020 2020 2020 2020 2020 2020 7469 s. ti\n-00034af0: 6d65 6f75 7420 2a3d 2031 3030 300a 2020 meout *= 1000. \n-00034b00: 2020 2020 2020 656c 7365 3a0a 2020 2020 else:. \n-00034b10: 2020 2020 2020 2020 2320 7364 5f62 7573 # sd_bus\n-00034b20: 2068 6173 206e 6f20 2269 6e64 6566 696e has no \"indefin\n-00034b30: 6974 6522 2074 696d 656f 7574 2c20 736f ite\" timeout, so\n-00034b40: 2075 7365 204d 4158 5f55 494e 5436 340a use MAX_UINT64.\n-00034b50: 2020 2020 2020 2020 2020 2020 7469 6d65 time\n-00034b60: 6f75 7420 3d20 3220 2a2a 2036 3420 2d20 out = 2 ** 64 - \n-00034b70: 310a 0a20 2020 2020 2020 2023 2057 6520 1.. # We \n-00034b80: 6861 7665 2074 6f20 6669 6775 7265 206f have to figure o\n-00034b90: 7574 2074 6865 2073 6967 6e61 7475 7265 ut the signature\n-00034ba0: 206f 6620 7468 6520 6361 6c6c 2e20 2045 of the call. E\n-00034bb0: 6974 6865 7220 7765 2067 6f74 2074 6f6c ither we got tol\n-00034bc0: 6420 6974 3a0a 2020 2020 2020 2020 7369 d it:. si\n-00034bd0: 676e 6174 7572 6520 3d20 6d65 7373 6167 gnature = messag\n-00034be0: 652e 6765 7428 2774 7970 6527 290a 0a20 e.get('type').. \n-00034bf0: 2020 2020 2020 2023 202e 2e2e 206f 7220 # ... or \n-00034c00: 7468 6572 6520 6172 656e 2774 2061 6e79 there aren't any\n-00034c10: 2061 7267 756d 656e 7473 0a20 2020 2020 arguments. \n-00034c20: 2020 2069 6620 7369 676e 6174 7572 6520 if signature \n-00034c30: 6973 204e 6f6e 6520 616e 6420 6c65 6e28 is None and len(\n-00034c40: 6172 6773 2920 3d3d 2030 3a0a 2020 2020 args) == 0:. \n-00034c50: 2020 2020 2020 2020 7369 676e 6174 7572 signatur\n-00034c60: 6520 3d20 2727 0a0a 2020 2020 2020 2020 e = ''.. \n-00034c70: 2320 2e2e 2e20 6f72 2077 6520 6e65 6564 # ... or we need\n-00034c80: 2074 6f20 696e 7472 6f73 7065 6374 0a20 to introspect. \n-00034c90: 2020 2020 2020 2069 6620 7369 676e 6174 if signat\n-00034ca0: 7572 6520 6973 204e 6f6e 653a 0a20 2020 ure is None:. \n-00034cb0: 2020 2020 2020 2020 2074 7279 3a0a 2020 try:. \n-00034cc0: 2020 2020 2020 2020 2020 2020 2020 6c6f lo\n-00034cd0: 6767 6572 2e64 6562 7567 2827 446f 696e gger.debug('Doin\n-00034ce0: 6720 696e 7472 6f73 7065 6374 696f 6e20 g introspection \n-00034cf0: 7265 7175 6573 7420 666f 7220 2573 2025 request for %s %\n-00034d00: 7327 2c20 6966 6163 652c 206d 6574 686f s', iface, metho\n-00034d10: 6429 0a20 2020 2020 2020 2020 2020 2020 d). \n-00034d20: 2020 2073 6967 6e61 7475 7265 203d 2061 signature = a\n-00034d30: 7761 6974 2073 656c 662e 6361 6368 652e wait self.cache.\n-00034d40: 6765 745f 7369 676e 6174 7572 6528 6966 get_signature(if\n-00034d50: 6163 652c 206d 6574 686f 642c 2073 656c ace, method, sel\n-00034d60: 662e 6275 732c 2073 656c 662e 6e61 6d65 f.bus, self.name\n-00034d70: 2c20 7061 7468 290a 2020 2020 2020 2020 , path). \n-00034d80: 2020 2020 6578 6365 7074 2042 7573 4572 except BusEr\n-00034d90: 726f 7220 6173 2065 7272 6f72 3a0a 2020 ror as error:. \n-00034da0: 2020 2020 2020 2020 2020 2020 2020 7365 se\n-00034db0: 6c66 2e73 656e 645f 6a73 6f6e 2865 7272 lf.send_json(err\n-00034dc0: 6f72 3d5b 6572 726f 722e 6e61 6d65 2c20 or=[error.name, \n-00034dd0: 5b66 2749 6e74 726f 7370 6563 7469 6f6e [f'Introspection\n-00034de0: 3a20 7b65 7272 6f72 2e6d 6573 7361 6765 : {error.message\n-00034df0: 7d27 5d5d 2c20 6964 3d63 6f6f 6b69 6529 }']], id=cookie)\n-00034e00: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-00034e10: 2072 6574 7572 6e0a 2020 2020 2020 2020 return. \n-00034e20: 2020 2020 6578 6365 7074 204b 6579 4572 except KeyEr\n-00034e30: 726f 723a 0a20 2020 2020 2020 2020 2020 ror:. \n-00034e40: 2020 2020 2073 656c 662e 7365 6e64 5f6a self.send_j\n-00034e50: 736f 6e28 0a20 2020 2020 2020 2020 2020 son(. \n-00034e60: 2020 2020 2020 2020 2065 7272 6f72 3d5b error=[\n-00034e70: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-00034e80: 2020 2020 2020 2020 2022 6f72 672e 6672 \"org.fr\n-00034e90: 6565 6465 736b 746f 702e 4442 7573 2e45 eedesktop.DBus.E\n-00034ea0: 7272 6f72 2e55 6e6b 6e6f 776e 4d65 7468 rror.UnknownMeth\n-00034eb0: 6f64 222c 0a20 2020 2020 2020 2020 2020 od\",. \n-00034ec0: 2020 2020 2020 2020 2020 2020 205b 6622 [f\"\n-00034ed0: 496e 7472 6f73 7065 6374 696f 6e20 6461 Introspection da\n-00034ee0: 7461 2066 6f72 206d 6574 686f 6420 7b69 ta for method {i\n-00034ef0: 6661 6365 7d20 7b6d 6574 686f 647d 206e face} {method} n\n-00034f00: 6f74 2061 7661 696c 6162 6c65 225d 5d2c ot available\"]],\n-00034f10: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-00034f20: 2020 2020 2069 643d 636f 6f6b 6965 290a id=cookie).\n-00034f30: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00034f40: 7265 7475 726e 0a20 2020 2020 2020 2020 return. \n-00034f50: 2020 2065 7863 6570 7420 4578 6365 7074 except Except\n-00034f60: 696f 6e20 6173 2065 7863 3a0a 2020 2020 ion as exc:. \n-00034f70: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n-00034f80: 2e73 656e 645f 6a73 6f6e 2865 7272 6f72 .send_json(error\n-00034f90: 3d5b 2770 7974 686f 6e2e 6572 726f 7227 =['python.error'\n-00034fa0: 2c20 5b66 2749 6e74 726f 7370 6563 7469 , [f'Introspecti\n-00034fb0: 6f6e 3a20 7b65 7863 2173 7d27 5d5d 2c20 on: {exc!s}']], \n-00034fc0: 6964 3d63 6f6f 6b69 6529 0a20 2020 2020 id=cookie). \n-00034fd0: 2020 2020 2020 2020 2020 2072 6574 7572 retur\n-00034fe0: 6e0a 0a20 2020 2020 2020 2074 7279 3a0a n.. try:.\n-00034ff0: 2020 2020 2020 2020 2020 2020 6d65 7468 meth\n-00035000: 6f64 5f63 616c 6c20 3d20 7365 6c66 2e62 od_call = self.b\n-00035010: 7573 2e6d 6573 7361 6765 5f6e 6577 5f6d us.message_new_m\n-00035020: 6574 686f 645f 6361 6c6c 2873 656c 662e ethod_call(self.\n-00035030: 6e61 6d65 2c20 7061 7468 2c20 6966 6163 name, path, ifac\n-00035040: 652c 206d 6574 686f 642c 2073 6967 6e61 e, method, signa\n-00035050: 7475 7265 2c20 2a61 7267 7329 0a20 2020 ture, *args). \n-00035060: 2020 2020 2020 2020 2072 6570 6c79 203d reply =\n-00035070: 2061 7761 6974 2073 656c 662e 6275 732e await self.bus.\n-00035080: 6361 6c6c 5f61 7379 6e63 286d 6574 686f call_async(metho\n-00035090: 645f 6361 6c6c 2c20 7469 6d65 6f75 743d d_call, timeout=\n-000350a0: 7469 6d65 6f75 7429 0a20 2020 2020 2020 timeout). \n-000350b0: 2020 2020 2023 2049 6620 7468 6520 6d65 # If the me\n-000350c0: 7468 6f64 2063 616c 6c20 6861 7320 6b69 thod call has ki\n-000350d0: 636b 6564 206f 6666 2061 6e79 2073 6967 cked off any sig\n-000350e0: 6e61 6c73 2072 656c 6174 6564 2074 6f0a nals related to.\n-000350f0: 2020 2020 2020 2020 2020 2020 2320 7761 # wa\n-00035100: 7463 6820 7072 6f63 6573 7369 6e67 2c20 tch processing, \n-00035110: 7761 6974 2066 6f72 2074 6861 7420 746f wait for that to\n-00035120: 2062 6520 646f 6e65 2e0a 2020 2020 2020 be done.. \n-00035130: 2020 2020 2020 6173 796e 6320 7769 7468 async with\n-00035140: 2073 656c 662e 7761 7463 685f 7072 6f63 self.watch_proc\n-00035150: 6573 7369 6e67 5f6c 6f63 6b3a 0a20 2020 essing_lock:. \n-00035160: 2020 2020 2020 2020 2020 2020 2023 2054 # T\n-00035170: 4f44 4f3a 2073 746f 7020 6861 7264 2d63 ODO: stop hard-c\n-00035180: 6f64 696e 6720 7468 6520 656e 6469 616e oding the endian\n-00035190: 2066 6c61 6720 6865 7265 2e0a 2020 2020 flag here.. \n-000351a0: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n-000351b0: 2e73 656e 645f 6a73 6f6e 280a 2020 2020 .send_json(. \n-000351c0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000351d0: 7265 706c 793d 5b72 6570 6c79 2e67 6574 reply=[reply.get\n-000351e0: 5f62 6f64 7928 295d 2c20 6964 3d63 6f6f _body()], id=coo\n-000351f0: 6b69 652c 0a20 2020 2020 2020 2020 2020 kie,. \n-00035200: 2020 2020 2020 2020 2066 6c61 6773 3d22 flags=\"\n-00035210: 3c22 2069 6620 666c 6167 7320 6973 206e <\" if flags is n\n-00035220: 6f74 204e 6f6e 6520 656c 7365 204e 6f6e ot None else Non\n-00035230: 652c 0a20 2020 2020 2020 2020 2020 2020 e,. \n-00035240: 2020 2020 2020 2074 7970 653d 7265 706c type=repl\n-00035250: 792e 6765 745f 7369 676e 6174 7572 6528 y.get_signature(\n-00035260: 5472 7565 2929 2020 2320 6e6f 7161 3a20 True)) # noqa: \n-00035270: 4642 5430 3033 0a20 2020 2020 2020 2065 FBT003. e\n-00035280: 7863 6570 7420 4275 7345 7272 6f72 2061 xcept BusError a\n-00035290: 7320 6572 726f 723a 0a20 2020 2020 2020 s error:. \n-000352a0: 2020 2020 2023 2061 6374 7561 6c6c 792c # actually,\n-000352b0: 2073 686f 756c 6420 7365 6e64 2074 6865 should send the\n-000352c0: 2066 6965 6c64 7320 6672 6f6d 2074 6865 fields from the\n-000352d0: 206d 6573 7361 6765 2062 6f64 790a 2020 message body. \n-000352e0: 2020 2020 2020 2020 2020 7365 6c66 2e73 self.s\n-000352f0: 656e 645f 6a73 6f6e 2865 7272 6f72 3d5b end_json(error=[\n-00035300: 6572 726f 722e 6e61 6d65 2c20 5b65 7272 error.name, [err\n-00035310: 6f72 2e6d 6573 7361 6765 5d5d 2c20 6964 or.message]], id\n-00035320: 3d63 6f6f 6b69 6529 0a20 2020 2020 2020 =cookie). \n-00035330: 2065 7863 6570 7420 4578 6365 7074 696f except Exceptio\n-00035340: 6e3a 0a20 2020 2020 2020 2020 2020 206c n:. l\n-00035350: 6f67 6765 722e 6578 6365 7074 696f 6e28 ogger.exception(\n-00035360: 2264 6f5f 6361 6c6c 2825 7329 3a20 6765 \"do_call(%s): ge\n-00035370: 6e65 7269 6320 6578 6365 7074 696f 6e22 neric exception\"\n-00035380: 2c20 6d65 7373 6167 6529 0a20 2020 2020 , message). \n-00035390: 2020 2020 2020 2073 656c 662e 7365 6e64 self.send\n-000353a0: 5f6a 736f 6e28 6572 726f 723d 5b27 7079 _json(error=['py\n-000353b0: 7468 6f6e 2e65 7272 6f72 272c 205b 7472 thon.error', [tr\n-000353c0: 6163 6562 6163 6b2e 666f 726d 6174 5f65 aceback.format_e\n-000353d0: 7863 2829 5d5d 2c20 6964 3d63 6f6f 6b69 xc()]], id=cooki\n-000353e0: 6529 0a0a 2020 2020 6173 796e 6320 6465 e).. async de\n-000353f0: 6620 646f 5f61 6464 5f6d 6174 6368 2873 f do_add_match(s\n-00035400: 656c 662c 206d 6573 7361 6765 293a 0a20 elf, message):. \n-00035410: 2020 2020 2020 2061 6464 5f6d 6174 6368 add_match\n-00035420: 203d 206d 6573 7361 6765 5b27 6164 642d = message['add-\n-00035430: 6d61 7463 6827 5d0a 2020 2020 2020 2020 match']. \n-00035440: 6c6f 6767 6572 2e64 6562 7567 2827 6164 logger.debug('ad\n-00035450: 6469 6e67 206d 6174 6368 2025 7327 2c20 ding match %s', \n-00035460: 6164 645f 6d61 7463 6829 0a0a 2020 2020 add_match).. \n-00035470: 2020 2020 6173 796e 6320 6465 6620 6d61 async def ma\n-00035480: 7463 685f 6869 7428 6d65 7373 6167 6529 tch_hit(message)\n-00035490: 3a0a 2020 2020 2020 2020 2020 2020 6c6f :. lo\n-000354a0: 6767 6572 2e64 6562 7567 2827 676f 7420 gger.debug('got \n-000354b0: 6d61 7463 6827 290a 2020 2020 2020 2020 match'). \n-000354c0: 2020 2020 6173 796e 6320 7769 7468 2073 async with s\n-000354d0: 656c 662e 7761 7463 685f 7072 6f63 6573 elf.watch_proces\n-000354e0: 7369 6e67 5f6c 6f63 6b3a 0a20 2020 2020 sing_lock:. \n-000354f0: 2020 2020 2020 2020 2020 2073 656c 662e self.\n-00035500: 7365 6e64 5f6a 736f 6e28 7369 676e 616c send_json(signal\n-00035510: 3d5b 0a20 2020 2020 2020 2020 2020 2020 =[. \n-00035520: 2020 2020 2020 206d 6573 7361 6765 2e67 message.g\n-00035530: 6574 5f70 6174 6828 292c 0a20 2020 2020 et_path(),. \n-00035540: 2020 2020 2020 2020 2020 2020 2020 206d m\n-00035550: 6573 7361 6765 2e67 6574 5f69 6e74 6572 essage.get_inter\n-00035560: 6661 6365 2829 2c0a 2020 2020 2020 2020 face(),. \n-00035570: 2020 2020 2020 2020 2020 2020 6d65 7373 mess\n-00035580: 6167 652e 6765 745f 6d65 6d62 6572 2829 age.get_member()\n-00035590: 2c0a 2020 2020 2020 2020 2020 2020 2020 ,. \n-000355a0: 2020 2020 2020 6c69 7374 286d 6573 7361 list(messa\n-000355b0: 6765 2e67 6574 5f62 6f64 7928 2929 0a20 ge.get_body()). \n-000355c0: 2020 2020 2020 2020 2020 2020 2020 205d ]\n-000355d0: 290a 0a20 2020 2020 2020 2073 656c 662e ).. self.\n-000355e0: 6164 645f 6173 796e 635f 7369 676e 616c add_async_signal\n-000355f0: 5f68 616e 646c 6572 286d 6174 6368 5f68 _handler(match_h\n-00035600: 6974 2c20 2a2a 6164 645f 6d61 7463 6829 it, **add_match)\n-00035610: 0a0a 2020 2020 6173 796e 6320 6465 6620 .. async def \n-00035620: 7365 7475 705f 6f62 6a65 6374 6d61 6e61 setup_objectmana\n-00035630: 6765 725f 7761 7463 6828 7365 6c66 2c20 ger_watch(self, \n-00035640: 7061 7468 2c20 696e 7465 7266 6163 655f path, interface_\n-00035650: 6e61 6d65 2c20 6d65 7461 2c20 6e6f 7469 name, meta, noti\n-00035660: 6679 293a 0a20 2020 2020 2020 2023 2057 fy):. # W\n-00035670: 6174 6368 2074 6865 206f 626a 6563 7473 atch the objects\n-00035680: 206d 616e 6167 6564 2062 7920 7468 6520 managed by the \n-00035690: 4f62 6a65 6374 4d61 6e61 6765 7220 6174 ObjectManager at\n-000356a0: 2022 7061 7468 222e 0a20 2020 2020 2020 \"path\".. \n-000356b0: 2023 2050 726f 7065 7274 6965 7320 6172 # Properties ar\n-000356c0: 6520 6e6f 7420 7761 7463 6865 642c 2074 e not watched, t\n-000356d0: 6861 7420 6973 2064 6f6e 6520 6279 2073 hat is done by s\n-000356e0: 6574 7570 5f70 6174 685f 7761 7463 680a etup_path_watch.\n-000356f0: 2020 2020 2020 2020 2320 6265 6c6f 7720 # below \n-00035700: 7669 6120 7265 6375 7273 6976 655f 7072 via recursive_pr\n-00035710: 6f70 7320 3d3d 2054 7275 652e 0a0a 2020 ops == True... \n-00035720: 2020 2020 2020 6173 796e 6320 6465 6620 async def \n-00035730: 6861 6e64 6c65 7228 6d65 7373 6167 6529 handler(message)\n-00035740: 3a0a 2020 2020 2020 2020 2020 2020 6d65 :. me\n-00035750: 6d62 6572 203d 206d 6573 7361 6765 2e67 mber = message.g\n-00035760: 6574 5f6d 656d 6265 7228 290a 2020 2020 et_member(). \n-00035770: 2020 2020 2020 2020 6966 206d 656d 6265 if membe\n-00035780: 7220 3d3d 2022 496e 7465 7266 6163 6573 r == \"Interfaces\n-00035790: 4164 6465 6422 3a0a 2020 2020 2020 2020 Added\":. \n-000357a0: 2020 2020 2020 2020 2870 6174 682c 2069 (path, i\n-000357b0: 6e74 6572 6661 6365 5f70 726f 7073 2920 nterface_props) \n-000357c0: 3d20 6d65 7373 6167 652e 6765 745f 626f = message.get_bo\n-000357d0: 6479 2829 0a20 2020 2020 2020 2020 2020 dy(). \n-000357e0: 2020 2020 206c 6f67 6765 722e 6465 6275 logger.debu\n-000357f0: 6728 2769 6e74 6572 6661 6365 7320 6164 g('interfaces ad\n-00035800: 6465 6420 2573 2025 7327 2c20 7061 7468 ded %s %s', path\n-00035810: 2c20 696e 7465 7266 6163 655f 7072 6f70 , interface_prop\n-00035820: 7329 0a20 2020 2020 2020 2020 2020 2020 s). \n-00035830: 2020 206d 6574 6120 3d20 7b7d 0a20 2020 meta = {}. \n-00035840: 2020 2020 2020 2020 2020 2020 206e 6f74 not\n-00035850: 6966 7920 3d20 7b7d 0a20 2020 2020 2020 ify = {}. \n-00035860: 2020 2020 2020 2020 2061 7379 6e63 2077 async w\n-00035870: 6974 6820 7365 6c66 2e77 6174 6368 5f70 ith self.watch_p\n-00035880: 726f 6365 7373 696e 675f 6c6f 636b 3a0a rocessing_lock:.\n-00035890: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000358a0: 2020 2020 666f 7220 6e61 6d65 2c20 7072 for name, pr\n-000358b0: 6f70 7320 696e 2069 6e74 6572 6661 6365 ops in interface\n-000358c0: 5f70 726f 7073 2e69 7465 6d73 2829 3a0a _props.items():.\n-000358d0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000358e0: 2020 2020 2020 2020 6966 2069 6e74 6572 if inter\n-000358f0: 6661 6365 5f6e 616d 6520 6973 204e 6f6e face_name is Non\n-00035900: 6520 6f72 206e 616d 6520 3d3d 2069 6e74 e or name == int\n-00035910: 6572 6661 6365 5f6e 616d 653a 0a20 2020 erface_name:. \n-00035920: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00035930: 2020 2020 2020 2020 206d 6d20 3d20 6177 mm = aw\n-00035940: 6169 7420 7365 6c66 2e63 6163 6865 2e67 ait self.cache.g\n-00035950: 6574 5f69 6e74 6572 6661 6365 5f69 665f et_interface_if_\n-00035960: 6e65 7728 6e61 6d65 2c20 7365 6c66 2e62 new(name, self.b\n-00035970: 7573 2c20 7365 6c66 2e6e 616d 652c 2070 us, self.name, p\n-00035980: 6174 6829 0a20 2020 2020 2020 2020 2020 ath). \n-00035990: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000359a0: 2069 6620 6d6d 3a0a 2020 2020 2020 2020 if mm:. \n-000359b0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000359c0: 2020 2020 2020 2020 6d65 7461 2e75 7064 meta.upd\n-000359d0: 6174 6528 7b6e 616d 653a 206d 6d7d 290a ate({name: mm}).\n-000359e0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000359f0: 2020 2020 2020 2020 2020 2020 6e6f 7469 noti\n-00035a00: 6679 5f75 7064 6174 6528 6e6f 7469 6679 fy_update(notify\n-00035a10: 2c20 7061 7468 2c20 6e61 6d65 2c20 7072 , path, name, pr\n-00035a20: 6f70 7329 0a20 2020 2020 2020 2020 2020 ops). \n-00035a30: 2020 2020 2020 2020 2073 656c 662e 7365 self.se\n-00035a40: 6e64 5f6a 736f 6e28 6d65 7461 3d6d 6574 nd_json(meta=met\n-00035a50: 6129 0a20 2020 2020 2020 2020 2020 2020 a). \n-00035a60: 2020 2020 2020 2073 656c 662e 7365 6e64 self.send\n-00035a70: 5f6a 736f 6e28 6e6f 7469 6679 3d6e 6f74 _json(notify=not\n-00035a80: 6966 7929 0a20 2020 2020 2020 2020 2020 ify). \n-00035a90: 2065 6c69 6620 6d65 6d62 6572 203d 3d20 elif member == \n-00035aa0: 2249 6e74 6572 6661 6365 7352 656d 6f76 \"InterfacesRemov\n-00035ab0: 6564 223a 0a20 2020 2020 2020 2020 2020 ed\":. \n-00035ac0: 2020 2020 2028 7061 7468 2c20 696e 7465 (path, inte\n-00035ad0: 7266 6163 6573 2920 3d20 6d65 7373 6167 rfaces) = messag\n-00035ae0: 652e 6765 745f 626f 6479 2829 0a20 2020 e.get_body(). \n-00035af0: 2020 2020 2020 2020 2020 2020 206c 6f67 log\n-00035b00: 6765 722e 6465 6275 6728 2769 6e74 6572 ger.debug('inter\n-00035b10: 6661 6365 7320 7265 6d6f 7665 6420 2573 faces removed %s\n-00035b20: 2025 7327 2c20 7061 7468 2c20 696e 7465 %s', path, inte\n-00035b30: 7266 6163 6573 290a 2020 2020 2020 2020 rfaces). \n-00035b40: 2020 2020 2020 2020 6173 796e 6320 7769 async wi\n-00035b50: 7468 2073 656c 662e 7761 7463 685f 7072 th self.watch_pr\n-00035b60: 6f63 6573 7369 6e67 5f6c 6f63 6b3a 0a20 ocessing_lock:. \n-00035b70: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00035b80: 2020 206e 6f74 6966 7920 3d20 7b70 6174 notify = {pat\n-00035b90: 683a 2064 6963 742e 6672 6f6d 6b65 7973 h: dict.fromkeys\n-00035ba0: 2869 6e74 6572 6661 6365 7329 7d0a 2020 (interfaces)}. \n-00035bb0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00035bc0: 2020 7365 6c66 2e73 656e 645f 6a73 6f6e self.send_json\n-00035bd0: 286e 6f74 6966 793d 6e6f 7469 6679 290a (notify=notify).\n-00035be0: 0a20 2020 2020 2020 2073 656c 662e 6164 . self.ad\n-00035bf0: 645f 6173 796e 635f 7369 676e 616c 5f68 d_async_signal_h\n-00035c00: 616e 646c 6572 2868 616e 646c 6572 2c0a andler(handler,.\n-00035c10: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00035c20: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00035c30: 2020 2020 2020 7061 7468 3d70 6174 682c path=path,\n-00035c40: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-00035c50: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00035c60: 2020 2020 2020 2069 6e74 6572 6661 6365 interface\n-00035c70: 3d22 6f72 672e 6672 6565 6465 736b 746f =\"org.freedeskto\n-00035c80: 702e 4442 7573 2e4f 626a 6563 744d 616e p.DBus.ObjectMan\n-00035c90: 6167 6572 2229 0a20 2020 2020 2020 206f ager\"). o\n-00035ca0: 626a 6563 7473 2c20 3d20 6177 6169 7420 bjects, = await \n-00035cb0: 7365 6c66 2e62 7573 2e63 616c 6c5f 6d65 self.bus.call_me\n-00035cc0: 7468 6f64 5f61 7379 6e63 2873 656c 662e thod_async(self.\n-00035cd0: 6e61 6d65 2c20 7061 7468 2c0a 2020 2020 name, path,. \n-00035ce0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00035cf0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00035d00: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00035d10: 276f 7267 2e66 7265 6564 6573 6b74 6f70 'org.freedesktop\n-00035d20: 2e44 4275 732e 4f62 6a65 6374 4d61 6e61 .DBus.ObjectMana\n-00035d30: 6765 7227 2c0a 2020 2020 2020 2020 2020 ger',. \n-00035d40: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00035d50: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00035d60: 2020 2020 2020 2020 2020 2747 6574 4d61 'GetMa\n-00035d70: 6e61 6765 644f 626a 6563 7473 2729 0a20 nagedObjects'). \n-00035d80: 2020 2020 2020 2066 6f72 2070 2c20 6966 for p, if\n-00035d90: 6163 6573 2069 6e20 6f62 6a65 6374 732e aces in objects.\n-00035da0: 6974 656d 7328 293a 0a20 2020 2020 2020 items():. \n-00035db0: 2020 2020 2066 6f72 2069 6661 6365 2c20 for iface, \n-00035dc0: 7072 6f70 7320 696e 2069 6661 6365 732e props in ifaces.\n-00035dd0: 6974 656d 7328 293a 0a20 2020 2020 2020 items():. \n-00035de0: 2020 2020 2020 2020 2069 6620 696e 7465 if inte\n-00035df0: 7266 6163 655f 6e61 6d65 2069 7320 4e6f rface_name is No\n-00035e00: 6e65 206f 7220 6966 6163 6520 3d3d 2069 ne or iface == i\n-00035e10: 6e74 6572 6661 6365 5f6e 616d 653a 0a20 nterface_name:. \n-00035e20: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00035e30: 2020 206d 6d20 3d20 6177 6169 7420 7365 mm = await se\n-00035e40: 6c66 2e63 6163 6865 2e67 6574 5f69 6e74 lf.cache.get_int\n-00035e50: 6572 6661 6365 5f69 665f 6e65 7728 6966 erface_if_new(if\n-00035e60: 6163 652c 2073 656c 662e 6275 732c 2073 ace, self.bus, s\n-00035e70: 656c 662e 6e61 6d65 2c20 7029 0a20 2020 elf.name, p). \n-00035e80: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00035e90: 2069 6620 6d6d 3a0a 2020 2020 2020 2020 if mm:. \n+00003790: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000037a0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000037b0: 2020 7072 6f6d 7074 3d70 726f 6d70 742c prompt=prompt,\n+000037c0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+000037d0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000037e0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000037f0: 2020 2020 2020 2020 2020 2020 6869 6e74 hint\n+00003800: 3d68 696e 742c 0a20 2020 2020 2020 2020 =hint,. \n+00003810: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00003820: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00003830: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00003840: 2020 6563 686f 3d46 616c 7365 290a 0a20 echo=False).. \n+00003850: 2020 2020 2020 2062 3634 203d 2072 6573 b64 = res\n+00003860: 706f 6e73 652e 7265 6d6f 7665 7072 6566 ponse.removepref\n+00003870: 6978 2827 582d 436f 6e76 6572 7361 7469 ix('X-Conversati\n+00003880: 6f6e 202d 2729 2e73 7472 6970 2829 0a20 on -').strip(). \n+00003890: 2020 2020 2020 2072 6573 706f 6e73 6520 response \n+000038a0: 3d20 6261 7365 3634 2e62 3634 6465 636f = base64.b64deco\n+000038b0: 6465 2862 3634 2e65 6e63 6f64 6528 2929 de(b64.encode())\n+000038c0: 2e64 6563 6f64 6528 290a 2020 2020 2020 .decode(). \n+000038d0: 2020 6c6f 6767 6572 2e64 6562 7567 2827 logger.debug('\n+000038e0: 5265 7475 726e 696e 6720 6120 2564 2063 Returning a %d c\n+000038f0: 6861 7273 2072 6573 706f 6e73 6527 2c20 hars response', \n+00003900: 6c65 6e28 7265 7370 6f6e 7365 2929 0a20 len(response)). \n+00003910: 2020 2020 2020 2072 6574 7572 6e20 7265 return re\n+00003920: 7370 6f6e 7365 0a0a 2020 2020 6173 796e sponse.. asyn\n+00003930: 6320 6465 6620 646f 5f63 7573 746f 6d5f c def do_custom_\n+00003940: 636f 6d6d 616e 6428 7365 6c66 2c20 636f command(self, co\n+00003950: 6d6d 616e 643a 2073 7472 2c20 6172 6773 mmand: str, args\n+00003960: 3a20 7475 706c 652c 2066 6473 3a20 6c69 : tuple, fds: li\n+00003970: 7374 5b69 6e74 5d2c 2073 7464 6572 723a st[int], stderr:\n+00003980: 2073 7472 2920 2d3e 204e 6f6e 653a 0a20 str) -> None:. \n+00003990: 2020 2020 2020 206c 6f67 6765 722e 6465 logger.de\n+000039a0: 6275 6728 2747 6f74 2066 6572 6e79 2063 bug('Got ferny c\n+000039b0: 6f6d 6d61 6e64 2025 7320 2573 2025 7327 ommand %s %s %s'\n+000039c0: 2c20 636f 6d6d 616e 642c 2061 7267 732c , command, args,\n+000039d0: 2073 7464 6572 7229 0a0a 2020 2020 2020 stderr).. \n+000039e0: 2020 6966 2063 6f6d 6d61 6e64 203d 3d20 if command == \n+000039f0: 2763 6f63 6b70 6974 2e72 6570 6f72 742d 'cockpit.report-\n+00003a00: 6578 6973 7473 273a 0a20 2020 2020 2020 exists':. \n+00003a10: 2020 2020 2066 696c 655f 7374 6174 7573 file_status\n+00003a20: 2c20 3d20 6172 6773 0a20 2020 2020 2020 , = args. \n+00003a30: 2020 2020 2023 2046 4958 4d45 3a20 6576 # FIXME: ev\n+00003a40: 696c 2064 7563 6b20 7479 7069 6e67 2068 il duck typing h\n+00003a50: 6572 6520 2d2d 2074 6869 7320 6973 2061 ere -- this is a\n+00003a60: 2068 616c 662d 7761 7920 4272 6964 6765 half-way Bridge\n+00003a70: 0a20 2020 2020 2020 2020 2020 2073 656c . sel\n+00003a80: 662e 726f 7574 6572 2e70 6163 6b61 6765 f.router.package\n+00003a90: 7320 3d20 5061 636b 6167 6573 286c 6f61 s = Packages(loa\n+00003aa0: 6465 723d 5072 6f78 7950 6163 6b61 6765 der=ProxyPackage\n+00003ab0: 734c 6f61 6465 7228 6669 6c65 5f73 7461 sLoader(file_sta\n+00003ac0: 7475 7329 2920 2023 2074 7970 653a 2069 tus)) # type: i\n+00003ad0: 676e 6f72 655b 6174 7472 2d64 6566 696e gnore[attr-defin\n+00003ae0: 6564 5d0a 2020 2020 2020 2020 2020 2020 ed]. \n+00003af0: 7365 6c66 2e72 6f75 7465 722e 726f 7574 self.router.rout\n+00003b00: 696e 675f 7275 6c65 732e 696e 7365 7274 ing_rules.insert\n+00003b10: 2830 2c20 4368 616e 6e65 6c52 6f75 7469 (0, ChannelRouti\n+00003b20: 6e67 5275 6c65 2873 656c 662e 726f 7574 ngRule(self.rout\n+00003b30: 6572 2c20 5b50 6163 6b61 6765 7343 6861 er, [PackagesCha\n+00003b40: 6e6e 656c 5d29 290a 0a0a 636c 6173 7320 nnel]))...class \n+00003b50: 5373 6850 6565 7228 5065 6572 293a 0a20 SshPeer(Peer):. \n+00003b60: 2020 2061 6c77 6179 733a 2062 6f6f 6c0a always: bool.\n+00003b70: 0a20 2020 2064 6566 205f 5f69 6e69 745f . def __init_\n+00003b80: 5f28 7365 6c66 2c20 726f 7574 6572 3a20 _(self, router: \n+00003b90: 526f 7574 6572 2c20 6465 7374 696e 6174 Router, destinat\n+00003ba0: 696f 6e3a 2073 7472 2c20 6172 6773 3a20 ion: str, args: \n+00003bb0: 6172 6770 6172 7365 2e4e 616d 6573 7061 argparse.Namespa\n+00003bc0: 6365 293a 0a20 2020 2020 2020 2073 656c ce):. sel\n+00003bd0: 662e 6465 7374 696e 6174 696f 6e20 3d20 f.destination = \n+00003be0: 6465 7374 696e 6174 696f 6e0a 2020 2020 destination. \n+00003bf0: 2020 2020 7365 6c66 2e61 6c77 6179 7320 self.always \n+00003c00: 3d20 6172 6773 2e61 6c77 6179 730a 2020 = args.always. \n+00003c10: 2020 2020 2020 7375 7065 7228 292e 5f5f super().__\n+00003c20: 696e 6974 5f5f 2872 6f75 7465 7229 0a0a init__(router)..\n+00003c30: 2020 2020 6173 796e 6320 6465 6620 646f async def do\n+00003c40: 5f63 6f6e 6e65 6374 5f74 7261 6e73 706f _connect_transpo\n+00003c50: 7274 2873 656c 6629 202d 3e20 4e6f 6e65 rt(self) -> None\n+00003c60: 3a0a 2020 2020 2020 2020 6265 6962 6f6f :. beiboo\n+00003c70: 745f 6865 6c70 6572 203d 2042 7269 6467 t_helper = Bridg\n+00003c80: 6542 6569 626f 6f74 4865 6c70 6572 2873 eBeibootHelper(s\n+00003c90: 656c 6629 0a0a 2020 2020 2020 2020 6167 elf).. ag\n+00003ca0: 656e 7420 3d20 6665 726e 792e 496e 7465 ent = ferny.Inte\n+00003cb0: 7261 6374 696f 6e41 6765 6e74 285b 4175 ractionAgent([Au\n+00003cc0: 7468 6f72 697a 6552 6573 706f 6e64 6572 thorizeResponder\n+00003cd0: 2873 656c 662e 726f 7574 6572 292c 2062 (self.router), b\n+00003ce0: 6569 626f 6f74 5f68 656c 7065 725d 290a eiboot_helper]).\n+00003cf0: 0a20 2020 2020 2020 2023 2057 6520 7761 . # We wa\n+00003d00: 6e74 2074 6f20 7275 6e20 6120 7079 7468 nt to run a pyth\n+00003d10: 6f6e 2069 6e74 6572 7072 6574 6572 2073 on interpreter s\n+00003d20: 6f6d 6577 6865 7265 2e2e 2e0a 2020 2020 omewhere.... \n+00003d30: 2020 2020 636d 643a 2053 6571 7565 6e63 cmd: Sequenc\n+00003d40: 655b 7374 725d 203d 2028 2770 7974 686f e[str] = ('pytho\n+00003d50: 6e33 272c 2027 2d69 6327 2c20 2723 2063 n3', '-ic', '# c\n+00003d60: 6f63 6b70 6974 2d62 7269 6467 6527 290a ockpit-bridge').\n+00003d70: 2020 2020 2020 2020 656e 763a 2053 6571 env: Seq\n+00003d80: 7565 6e63 655b 7374 725d 203d 2028 290a uence[str] = ().\n+00003d90: 0a20 2020 2020 2020 2069 6e5f 666c 6174 . in_flat\n+00003da0: 7061 6b20 3d20 6f73 2e70 6174 682e 6578 pak = os.path.ex\n+00003db0: 6973 7473 2827 2f2e 666c 6174 7061 6b2d ists('/.flatpak-\n+00003dc0: 696e 666f 2729 0a0a 2020 2020 2020 2020 info').. \n+00003dd0: 2320 5265 6d6f 7465 2068 6f73 743f 2020 # Remote host? \n+00003de0: 5772 6170 2063 6f6d 6d61 6e64 2077 6974 Wrap command wit\n+00003df0: 6820 5353 480a 2020 2020 2020 2020 6966 h SSH. if\n+00003e00: 2073 656c 662e 6465 7374 696e 6174 696f self.destinatio\n+00003e10: 6e20 213d 2027 6c6f 6361 6c68 6f73 7427 n != 'localhost'\n+00003e20: 3a0a 2020 2020 2020 2020 2020 2020 6966 :. if\n+00003e30: 2069 6e5f 666c 6174 7061 6b3a 0a20 2020 in_flatpak:. \n+00003e40: 2020 2020 2020 2020 2020 2020 2023 2077 # w\n+00003e50: 6520 7275 6e20 7373 6820 616e 6420 7468 e run ssh and th\n+00003e60: 7573 2074 6865 2068 656c 7065 7220 6f6e us the helper on\n+00003e70: 2074 6865 2068 6f73 742c 2061 6c77 6179 the host, alway\n+00003e80: 7320 7573 6520 7468 6520 7864 672d 6361 s use the xdg-ca\n+00003e90: 6368 6520 6865 6c70 6572 0a20 2020 2020 che helper. \n+00003ea0: 2020 2020 2020 2020 2020 2073 7368 5f61 ssh_a\n+00003eb0: 736b 7061 7373 203d 2065 6e73 7572 655f skpass = ensure_\n+00003ec0: 6665 726e 795f 6173 6b70 6173 7328 290a ferny_askpass().\n+00003ed0: 2020 2020 2020 2020 2020 2020 656c 7365 else\n+00003ee0: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n+00003ef0: 2020 2320 6f75 7473 6964 6520 6f66 2074 # outside of t\n+00003f00: 6865 2066 6c61 7470 616b 2077 6520 6578 he flatpak we ex\n+00003f10: 7065 6374 2063 6f63 6b70 6974 2d77 7320 pect cockpit-ws \n+00003f20: 616e 6420 7468 7573 2061 6e20 696e 7374 and thus an inst\n+00003f30: 616c 6c65 6420 6865 6c70 6572 0a20 2020 alled helper. \n+00003f40: 2020 2020 2020 2020 2020 2020 2061 736b ask\n+00003f50: 7061 7373 203d 2070 6174 6368 5f6c 6962 pass = patch_lib\n+00003f60: 6578 6563 6469 7228 2724 7b6c 6962 6578 execdir('${libex\n+00003f70: 6563 6469 727d 2f63 6f63 6b70 6974 2d61 ecdir}/cockpit-a\n+00003f80: 736b 7061 7373 2729 0a20 2020 2020 2020 skpass'). \n+00003f90: 2020 2020 2020 2020 2061 7373 6572 7420 assert \n+00003fa0: 6973 696e 7374 616e 6365 2861 736b 7061 isinstance(askpa\n+00003fb0: 7373 2c20 7374 7229 0a20 2020 2020 2020 ss, str). \n+00003fc0: 2020 2020 2020 2020 2073 7368 5f61 736b ssh_ask\n+00003fd0: 7061 7373 203d 2050 6174 6828 6173 6b70 pass = Path(askp\n+00003fe0: 6173 7329 0a20 2020 2020 2020 2020 2020 ass). \n+00003ff0: 2020 2020 2069 6620 6e6f 7420 7373 685f if not ssh_\n+00004000: 6173 6b70 6173 732e 6578 6973 7473 2829 askpass.exists()\n+00004010: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n+00004020: 2020 2020 2020 6c6f 6767 6572 2e65 7272 logger.err\n+00004030: 6f72 2822 436f 756c 6420 6e6f 7420 6669 or(\"Could not fi\n+00004040: 6e64 2063 6f63 6b70 6974 2d61 736b 7061 nd cockpit-askpa\n+00004050: 7373 2068 656c 7065 7220 6174 2025 7222 ss helper at %r\"\n+00004060: 2c20 6173 6b70 6173 7329 0a0a 2020 2020 , askpass).. \n+00004070: 2020 2020 2020 2020 656e 7620 3d20 280a env = (.\n+00004080: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00004090: 6627 5353 485f 4153 4b50 4153 533d 7b73 f'SSH_ASKPASS={s\n+000040a0: 7368 5f61 736b 7061 7373 2173 7d27 2c0a sh_askpass!s}',.\n+000040b0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000040c0: 2744 4953 504c 4159 3d78 272c 0a20 2020 'DISPLAY=x',. \n+000040d0: 2020 2020 2020 2020 2020 2020 2027 5353 'SS\n+000040e0: 485f 4153 4b50 4153 535f 5245 5155 4952 H_ASKPASS_REQUIR\n+000040f0: 453d 666f 7263 6527 2c0a 2020 2020 2020 E=force',. \n+00004100: 2020 2020 2020 290a 2020 2020 2020 2020 ). \n+00004110: 2020 2020 686f 7374 2c20 5f2c 2070 6f72 host, _, por\n+00004120: 7420 3d20 7365 6c66 2e64 6573 7469 6e61 t = self.destina\n+00004130: 7469 6f6e 2e72 7061 7274 6974 696f 6e28 tion.rpartition(\n+00004140: 273a 2729 0a20 2020 2020 2020 2020 2020 ':'). \n+00004150: 2023 2063 6174 6368 2063 6173 6573 206c # catch cases l\n+00004160: 696b 6520 6068 6f73 743a 3132 3360 2062 ike `host:123` b\n+00004170: 7574 206e 6f74 2063 6173 6573 206c 696b ut not cases lik\n+00004180: 6520 605b 3230 3031 3a61 6263 643a 3a31 e `[2001:abcd::1\n+00004190: 5d0a 2020 2020 2020 2020 2020 2020 6966 ]. if\n+000041a0: 2070 6f72 742e 6973 6469 6769 7428 293a port.isdigit():\n+000041b0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+000041c0: 2068 6f73 745f 6172 6773 203d 205b 272d host_args = ['-\n+000041d0: 7027 2c20 706f 7274 2c20 686f 7374 5d0a p', port, host].\n+000041e0: 2020 2020 2020 2020 2020 2020 656c 7365 else\n+000041f0: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n+00004200: 2020 686f 7374 5f61 7267 7320 3d20 5b73 host_args = [s\n+00004210: 656c 662e 6465 7374 696e 6174 696f 6e5d elf.destination]\n+00004220: 0a0a 2020 2020 2020 2020 2020 2020 636d .. cm\n+00004230: 6420 3d20 2827 7373 6827 2c20 2a68 6f73 d = ('ssh', *hos\n+00004240: 745f 6172 6773 2c20 7368 6c65 782e 6a6f t_args, shlex.jo\n+00004250: 696e 2863 6d64 2929 0a0a 2020 2020 2020 in(cmd)).. \n+00004260: 2020 2320 5275 6e6e 696e 6720 696e 2066 # Running in f\n+00004270: 6c61 7470 616b 3f20 2057 7261 7020 636f latpak? Wrap co\n+00004280: 6d6d 616e 6420 7769 7468 2066 6c61 7470 mmand with flatp\n+00004290: 616b 2d73 7061 776e 202d 2d68 6f73 740a ak-spawn --host.\n+000042a0: 2020 2020 2020 2020 6966 2069 6e5f 666c if in_fl\n+000042b0: 6174 7061 6b3a 0a20 2020 2020 2020 2020 atpak:. \n+000042c0: 2020 2063 6d64 203d 2028 2766 6c61 7470 cmd = ('flatp\n+000042d0: 616b 2d73 7061 776e 272c 2027 2d2d 686f ak-spawn', '--ho\n+000042e0: 7374 272c 0a20 2020 2020 2020 2020 2020 st',. \n+000042f0: 2020 2020 2020 2020 2a28 6627 2d2d 656e *(f'--en\n+00004300: 763d 7b6b 767d 2720 666f 7220 6b76 2069 v={kv}' for kv i\n+00004310: 6e20 656e 7629 2c0a 2020 2020 2020 2020 n env),. \n+00004320: 2020 2020 2020 2020 2020 202a 636d 6429 *cmd)\n+00004330: 0a20 2020 2020 2020 2020 2020 2065 6e76 . env\n+00004340: 203d 2028 290a 0a20 2020 2020 2020 206c = ().. l\n+00004350: 6f67 6765 722e 6465 6275 6728 224c 6175 ogger.debug(\"Lau\n+00004360: 6e63 6869 6e67 2063 6f6d 6d61 6e64 3a20 nching command: \n+00004370: 636d 643d 2573 2065 6e76 3d25 7322 2c20 cmd=%s env=%s\", \n+00004380: 636d 642c 2065 6e76 290a 2020 2020 2020 cmd, env). \n+00004390: 2020 7472 616e 7370 6f72 7420 3d20 6177 transport = aw\n+000043a0: 6169 7420 7365 6c66 2e73 7061 776e 2863 ait self.spawn(c\n+000043b0: 6d64 2c20 656e 762c 2073 7464 6572 723d md, env, stderr=\n+000043c0: 6167 656e 742c 2073 7461 7274 5f6e 6577 agent, start_new\n+000043d0: 5f73 6573 7369 6f6e 3d54 7275 6529 0a0a _session=True)..\n+000043e0: 2020 2020 2020 2020 6966 206e 6f74 2073 if not s\n+000043f0: 656c 662e 616c 7761 7973 3a0a 2020 2020 elf.always:. \n+00004400: 2020 2020 2020 2020 6578 6563 5f63 6f63 exec_coc\n+00004410: 6b70 6974 5f62 7269 6467 655f 7374 6570 kpit_bridge_step\n+00004420: 7320 3d20 5b28 2774 7279 5f65 7865 6327 s = [('try_exec'\n+00004430: 2c20 285b 2763 6f63 6b70 6974 2d62 7269 , (['cockpit-bri\n+00004440: 6467 6527 5d2c 2929 5d0a 2020 2020 2020 dge'],))]. \n+00004450: 2020 656c 7365 3a0a 2020 2020 2020 2020 else:. \n+00004460: 2020 2020 6578 6563 5f63 6f63 6b70 6974 exec_cockpit\n+00004470: 5f62 7269 6467 655f 7374 6570 7320 3d20 _bridge_steps = \n+00004480: 5b5d 0a0a 2020 2020 2020 2020 2320 5365 [].. # Se\n+00004490: 6e64 2074 6865 2066 6972 7374 2d73 7461 nd the first-sta\n+000044a0: 6765 2062 6f6f 746c 6f61 6465 720a 2020 ge bootloader. \n+000044b0: 2020 2020 2020 7374 6167 6531 203d 2062 stage1 = b\n+000044c0: 6f6f 746c 6f61 6465 722e 6d61 6b65 5f62 ootloader.make_b\n+000044d0: 6f6f 746c 6f61 6465 7228 5b0a 2020 2020 ootloader([. \n+000044e0: 2020 2020 2020 2020 2a65 7865 635f 636f *exec_co\n+000044f0: 636b 7069 745f 6272 6964 6765 5f73 7465 ckpit_bridge_ste\n+00004500: 7073 2c0a 2020 2020 2020 2020 2020 2020 ps,. \n+00004510: 2827 7265 706f 7274 5f65 7869 7374 7327 ('report_exists'\n+00004520: 2c20 5b6c 6973 7428 6765 745f 696e 7465 , [list(get_inte\n+00004530: 7265 7374 696e 675f 6669 6c65 7328 2929 resting_files())\n+00004540: 5d29 2c0a 2020 2020 2020 2020 2020 2020 ]),. \n+00004550: 2a62 6569 626f 6f74 5f68 656c 7065 722e *beiboot_helper.\n+00004560: 7374 6570 732c 0a20 2020 2020 2020 205d steps,. ]\n+00004570: 2c20 6761 6467 6574 733d 4245 4942 4f4f , gadgets=BEIBOO\n+00004580: 545f 4741 4447 4554 5329 0a20 2020 2020 T_GADGETS). \n+00004590: 2020 2074 7261 6e73 706f 7274 2e77 7269 transport.wri\n+000045a0: 7465 2873 7461 6765 312e 656e 636f 6465 te(stage1.encode\n+000045b0: 2829 290a 0a20 2020 2020 2020 2023 2057 ()).. # W\n+000045c0: 6169 7420 666f 7220 2269 6e69 7422 206f ait for \"init\" o\n+000045d0: 7220 6572 726f 722c 2068 616e 646c 696e r error, handlin\n+000045e0: 6720 6175 7468 2061 6e64 2062 6569 626f g auth and beibo\n+000045f0: 6f74 2072 6571 7565 7374 730a 2020 2020 ot requests. \n+00004600: 2020 2020 6177 6169 7420 6167 656e 742e await agent.\n+00004610: 636f 6d6d 756e 6963 6174 6528 290a 0a20 communicate().. \n+00004620: 2020 2064 6566 2074 7261 6e73 706f 7274 def transport\n+00004630: 5f63 6f6e 7472 6f6c 5f72 6563 6569 7665 _control_receive\n+00004640: 6428 7365 6c66 2c20 636f 6d6d 616e 643a d(self, command:\n+00004650: 2073 7472 2c20 6d65 7373 6167 653a 204a str, message: J\n+00004660: 736f 6e4f 626a 6563 7429 202d 3e20 4e6f sonObject) -> No\n+00004670: 6e65 3a0a 2020 2020 2020 2020 6966 2063 ne:. if c\n+00004680: 6f6d 6d61 6e64 203d 3d20 2761 7574 686f ommand == 'autho\n+00004690: 7269 7a65 273a 0a20 2020 2020 2020 2020 rize':. \n+000046a0: 2020 2023 2057 6527 7665 2064 6973 6162 # We've disab\n+000046b0: 6c65 6420 7468 6973 2066 6f72 2065 7870 led this for exp\n+000046c0: 6c69 6369 742d 7375 7065 7275 7365 7220 licit-superuser \n+000046d0: 6272 6964 6765 732c 2062 7574 206f 6c64 bridges, but old\n+000046e0: 6572 0a20 2020 2020 2020 2020 2020 2023 er. #\n+000046f0: 2062 7269 6467 6573 2064 6f6e 2774 2073 bridges don't s\n+00004700: 7570 706f 7274 2074 6861 7420 616e 6420 upport that and \n+00004710: 7769 6c6c 2061 736b 2075 7320 616e 7977 will ask us anyw\n+00004720: 6179 2e0a 2020 2020 2020 2020 2020 2020 ay.. \n+00004730: 7265 7475 726e 0a0a 2020 2020 2020 2020 return.. \n+00004740: 7375 7065 7228 292e 7472 616e 7370 6f72 super().transpor\n+00004750: 745f 636f 6e74 726f 6c5f 7265 6365 6976 t_control_receiv\n+00004760: 6564 2863 6f6d 6d61 6e64 2c20 6d65 7373 ed(command, mess\n+00004770: 6167 6529 0a0a 0a63 6c61 7373 2053 7368 age)...class Ssh\n+00004780: 4272 6964 6765 2852 6f75 7465 7229 3a0a Bridge(Router):.\n+00004790: 2020 2020 7061 636b 6167 6573 3a20 4f70 packages: Op\n+000047a0: 7469 6f6e 616c 5b50 6163 6b61 6765 735d tional[Packages]\n+000047b0: 203d 204e 6f6e 650a 2020 2020 7373 685f = None. ssh_\n+000047c0: 7065 6572 3a20 5373 6850 6565 720a 0a20 peer: SshPeer.. \n+000047d0: 2020 2064 6566 205f 5f69 6e69 745f 5f28 def __init__(\n+000047e0: 7365 6c66 2c20 6172 6773 3a20 6172 6770 self, args: argp\n+000047f0: 6172 7365 2e4e 616d 6573 7061 6365 293a arse.Namespace):\n+00004800: 0a20 2020 2020 2020 2023 2042 7920 6465 . # By de\n+00004810: 6661 756c 742c 2077 6520 726f 7574 6520 fault, we route \n+00004820: 6576 6572 7974 6869 6e67 2074 6f20 7468 everything to th\n+00004830: 6520 6f74 6865 7220 686f 7374 2e20 2057 e other host. W\n+00004840: 6520 6164 6420 616e 2065 7874 7261 0a20 e add an extra. \n+00004850: 2020 2020 2020 2023 2072 6f75 7469 6e67 # routing\n+00004860: 2072 756c 6520 666f 7220 7468 6520 7061 rule for the pa\n+00004870: 636b 6167 6573 2077 6562 7365 7276 6572 ckages webserver\n+00004880: 206f 6e6c 7920 6966 2077 6527 7265 2072 only if we're r\n+00004890: 756e 6e69 6e67 2074 6865 0a20 2020 2020 unning the. \n+000048a0: 2020 2023 2062 6569 7061 636b 2e0a 2020 # beipack.. \n+000048b0: 2020 2020 2020 7275 6c65 203d 2044 6566 rule = Def\n+000048c0: 6175 6c74 526f 7574 696e 6752 756c 6528 aultRoutingRule(\n+000048d0: 7365 6c66 290a 2020 2020 2020 2020 7375 self). su\n+000048e0: 7065 7228 292e 5f5f 696e 6974 5f5f 285b per().__init__([\n+000048f0: 7275 6c65 5d29 0a0a 2020 2020 2020 2020 rule]).. \n+00004900: 2320 5468 6973 206e 6565 6473 2074 6f20 # This needs to \n+00004910: 6265 2063 7265 6174 6564 2061 6674 6572 be created after\n+00004920: 2052 6f75 7465 722e 5f5f 696e 6974 5f5f Router.__init__\n+00004930: 2069 7320 6361 6c6c 6564 2e0a 2020 2020 is called.. \n+00004940: 2020 2020 7365 6c66 2e73 7368 5f70 6565 self.ssh_pee\n+00004950: 7220 3d20 5373 6850 6565 7228 7365 6c66 r = SshPeer(self\n+00004960: 2c20 6172 6773 2e64 6573 7469 6e61 7469 , args.destinati\n+00004970: 6f6e 2c20 6172 6773 290a 2020 2020 2020 on, args). \n+00004980: 2020 7275 6c65 2e70 6565 7220 3d20 7365 rule.peer = se\n+00004990: 6c66 2e73 7368 5f70 6565 720a 0a20 2020 lf.ssh_peer.. \n+000049a0: 2064 6566 2064 6f5f 7365 6e64 5f69 6e69 def do_send_ini\n+000049b0: 7428 7365 6c66 293a 0a20 2020 2020 2020 t(self):. \n+000049c0: 2070 6173 7320 2023 2077 6169 7420 666f pass # wait fo\n+000049d0: 7220 7468 6520 7065 6572 2074 6f20 646f r the peer to do\n+000049e0: 2069 7420 6669 7273 740a 0a20 2020 2064 it first.. d\n+000049f0: 6566 2064 6f5f 696e 6974 2873 656c 662c ef do_init(self,\n+00004a00: 206d 6573 7361 6765 293a 0a20 2020 2020 message):. \n+00004a10: 2020 2023 2068 7474 7073 3a2f 2f67 6974 # https://git\n+00004a20: 6875 622e 636f 6d2f 636f 636b 7069 742d hub.com/cockpit-\n+00004a30: 7072 6f6a 6563 742f 636f 636b 7069 742f project/cockpit/\n+00004a40: 6973 7375 6573 2f31 3839 3237 0a20 2020 issues/18927. \n+00004a50: 2020 2020 2023 0a20 2020 2020 2020 2023 #. #\n+00004a60: 2057 6520 7465 6c6c 2063 6f63 6b70 6974 We tell cockpit\n+00004a70: 2d77 7320 7468 6174 2077 6520 6861 7665 -ws that we have\n+00004a80: 2074 6865 2065 7870 6c69 6369 742d 7375 the explicit-su\n+00004a90: 7065 7275 7365 7220 6361 7061 6269 6c69 peruser capabili\n+00004aa0: 7479 2061 6e64 0a20 2020 2020 2020 2023 ty and. #\n+00004ab0: 2068 616e 646c 6520 6974 206f 7572 7365 handle it ourse\n+00004ac0: 6c76 6573 2028 6a75 7374 2062 656c 6f77 lves (just below\n+00004ad0: 2920 6279 2073 656e 6469 6e67 2060 7375 ) by sending `su\n+00004ae0: 7065 7275 7365 722d 696e 6974 2d64 6f6e peruser-init-don\n+00004af0: 6560 2061 6e64 0a20 2020 2020 2020 2023 e` and. #\n+00004b00: 2070 6173 7369 6e67 207b 2773 7570 6572 passing {'super\n+00004b10: 7573 6572 273a 2046 616c 7365 7d20 6f6e user': False} on\n+00004b20: 2074 6f20 7468 6520 6163 7475 616c 2062 to the actual b\n+00004b30: 7269 6467 6520 2850 7974 686f 6e20 6f72 ridge (Python or\n+00004b40: 2043 292e 0a20 2020 2020 2020 2069 6620 C).. if \n+00004b50: 6973 696e 7374 616e 6365 286d 6573 7361 isinstance(messa\n+00004b60: 6765 2e67 6574 2827 7375 7065 7275 7365 ge.get('superuse\n+00004b70: 7227 292c 2064 6963 7429 3a0a 2020 2020 r'), dict):. \n+00004b80: 2020 2020 2020 2020 7365 6c66 2e77 7269 self.wri\n+00004b90: 7465 5f63 6f6e 7472 6f6c 2863 6f6d 6d61 te_control(comma\n+00004ba0: 6e64 3d27 7375 7065 7275 7365 722d 696e nd='superuser-in\n+00004bb0: 6974 2d64 6f6e 6527 290a 2020 2020 2020 it-done'). \n+00004bc0: 2020 6d65 7373 6167 655b 2773 7570 6572 message['super\n+00004bd0: 7573 6572 275d 203d 2046 616c 7365 0a20 user'] = False. \n+00004be0: 2020 2020 2020 2073 656c 662e 7373 685f self.ssh_\n+00004bf0: 7065 6572 2e77 7269 7465 5f63 6f6e 7472 peer.write_contr\n+00004c00: 6f6c 286d 6573 7361 6765 290a 0a0a 6173 ol(message)...as\n+00004c10: 796e 6320 6465 6620 7275 6e28 6172 6773 ync def run(args\n+00004c20: 2920 2d3e 204e 6f6e 653a 0a20 2020 206c ) -> None:. l\n+00004c30: 6f67 6765 722e 6465 6275 6728 2248 692e ogger.debug(\"Hi.\n+00004c40: 2048 6f77 2061 7265 2079 6f75 2074 6f64 How are you tod\n+00004c50: 6179 3f22 290a 0a20 2020 2062 7269 6467 ay?\").. bridg\n+00004c60: 6520 3d20 5373 6842 7269 6467 6528 6172 e = SshBridge(ar\n+00004c70: 6773 290a 2020 2020 5374 6469 6f54 7261 gs). StdioTra\n+00004c80: 6e73 706f 7274 2861 7379 6e63 696f 2e67 nsport(asyncio.g\n+00004c90: 6574 5f72 756e 6e69 6e67 5f6c 6f6f 7028 et_running_loop(\n+00004ca0: 292c 2062 7269 6467 6529 0a0a 2020 2020 ), bridge).. \n+00004cb0: 7472 793a 0a20 2020 2020 2020 206d 6573 try:. mes\n+00004cc0: 7361 6765 203d 2064 6963 7428 6177 6169 sage = dict(awai\n+00004cd0: 7420 6272 6964 6765 2e73 7368 5f70 6565 t bridge.ssh_pee\n+00004ce0: 722e 7374 6172 7428 2929 0a0a 2020 2020 r.start()).. \n+00004cf0: 2020 2020 2320 5365 6520 636f 6d6d 656e # See commen\n+00004d00: 7420 696e 2064 6f5f 696e 6974 2829 2061 t in do_init() a\n+00004d10: 626f 7665 3a20 7765 2074 656c 6c20 636f bove: we tell co\n+00004d20: 636b 7069 742d 7773 2074 6861 7420 7765 ckpit-ws that we\n+00004d30: 2073 7570 706f 7274 0a20 2020 2020 2020 support. \n+00004d40: 2023 2074 6869 7320 616e 6420 7468 656e # this and then\n+00004d50: 2068 616e 646c 6520 6974 206f 7572 7365 handle it ourse\n+00004d60: 6c76 6573 2077 6865 6e20 7765 2067 6574 lves when we get\n+00004d70: 2074 6865 2069 6e69 7420 6d65 7373 6167 the init messag\n+00004d80: 652e 0a20 2020 2020 2020 2063 6170 6162 e.. capab\n+00004d90: 696c 6974 6965 7320 3d20 6d65 7373 6167 ilities = messag\n+00004da0: 652e 7365 7464 6566 6175 6c74 2827 6361 e.setdefault('ca\n+00004db0: 7061 6269 6c69 7469 6573 272c 207b 7d29 pabilities', {})\n+00004dc0: 0a20 2020 2020 2020 2069 6620 6e6f 7420 . if not \n+00004dd0: 6973 696e 7374 616e 6365 2863 6170 6162 isinstance(capab\n+00004de0: 696c 6974 6965 732c 2064 6963 7429 3a0a ilities, dict):.\n+00004df0: 2020 2020 2020 2020 2020 2020 6272 6964 brid\n+00004e00: 6765 2e77 7269 7465 5f63 6f6e 7472 6f6c ge.write_control\n+00004e10: 2863 6f6d 6d61 6e64 3d27 696e 6974 272c (command='init',\n+00004e20: 2070 726f 626c 656d 3d27 7072 6f74 6f63 problem='protoc\n+00004e30: 6f6c 2d65 7272 6f72 272c 206d 6573 7361 ol-error', messa\n+00004e40: 6765 3d27 6361 7061 6269 6c69 7469 6573 ge='capabilities\n+00004e50: 206d 7573 7420 6265 2061 2064 6963 7427 must be a dict'\n+00004e60: 290a 2020 2020 2020 2020 2020 2020 7265 ). re\n+00004e70: 7475 726e 0a20 2020 2020 2020 2061 7373 turn. ass\n+00004e80: 6572 7420 6973 696e 7374 616e 6365 2863 ert isinstance(c\n+00004e90: 6170 6162 696c 6974 6965 732c 2064 6963 apabilities, dic\n+00004ea0: 7429 2020 2320 636f 6e76 696e 6365 206d t) # convince m\n+00004eb0: 7970 790a 2020 2020 2020 2020 6361 7061 ypy. capa\n+00004ec0: 6269 6c69 7469 6573 5b27 6578 706c 6963 bilities['explic\n+00004ed0: 6974 2d73 7570 6572 7573 6572 275d 203d it-superuser'] =\n+00004ee0: 2054 7275 650a 0a20 2020 2020 2020 2023 True.. #\n+00004ef0: 206f 6e6c 7920 7061 7463 6820 7468 6520 only patch the \n+00004f00: 7061 636b 6167 6573 206c 696e 6520 6966 packages line if\n+00004f10: 2077 6520 6172 6520 696e 2062 6569 626f we are in beibo\n+00004f20: 6f74 206d 6f64 650a 2020 2020 2020 2020 ot mode. \n+00004f30: 6966 2062 7269 6467 652e 7061 636b 6167 if bridge.packag\n+00004f40: 6573 3a0a 2020 2020 2020 2020 2020 2020 es:. \n+00004f50: 6d65 7373 6167 655b 2770 6163 6b61 6765 message['package\n+00004f60: 7327 5d20 3d20 6469 6374 2e66 726f 6d6b s'] = dict.fromk\n+00004f70: 6579 7328 6272 6964 6765 2e70 6163 6b61 eys(bridge.packa\n+00004f80: 6765 732e 7061 636b 6167 6573 290a 0a20 ges.packages).. \n+00004f90: 2020 2020 2020 2062 7269 6467 652e 7772 bridge.wr\n+00004fa0: 6974 655f 636f 6e74 726f 6c28 6d65 7373 ite_control(mess\n+00004fb0: 6167 6529 0a20 2020 2020 2020 2062 7269 age). bri\n+00004fc0: 6467 652e 7373 685f 7065 6572 2e74 6861 dge.ssh_peer.tha\n+00004fd0: 775f 656e 6470 6f69 6e74 2829 0a20 2020 w_endpoint(). \n+00004fe0: 2065 7863 6570 7420 6665 726e 792e 496e except ferny.In\n+00004ff0: 7465 7261 6374 696f 6e45 7272 6f72 2061 teractionError a\n+00005000: 7320 6578 633a 0a20 2020 2020 2020 2065 s exc:. e\n+00005010: 7272 6f72 203d 2066 6572 6e79 2e73 7368 rror = ferny.ssh\n+00005020: 5f65 7272 6f72 732e 6765 745f 6578 6365 _errors.get_exce\n+00005030: 7074 696f 6e5f 666f 725f 7373 685f 7374 ption_for_ssh_st\n+00005040: 6465 7272 2873 7472 2865 7863 2929 0a20 derr(str(exc)). \n+00005050: 2020 2020 2020 206c 6f67 6765 722e 6465 logger.de\n+00005060: 6275 6728 2266 6572 6e79 2e49 6e74 6572 bug(\"ferny.Inter\n+00005070: 6163 7469 6f6e 4572 726f 723a 2025 732c actionError: %s,\n+00005080: 2069 6e74 6572 7072 6574 6564 2061 733a interpreted as:\n+00005090: 2025 7222 2c20 6578 632c 2065 7272 6f72 %r\", exc, error\n+000050a0: 290a 2020 2020 2020 2020 6966 2069 7369 ). if isi\n+000050b0: 6e73 7461 6e63 6528 6572 726f 722c 2066 nstance(error, f\n+000050c0: 6572 6e79 2e53 7368 4175 7468 656e 7469 erny.SshAuthenti\n+000050d0: 6361 7469 6f6e 4572 726f 7229 3a0a 2020 cationError):. \n+000050e0: 2020 2020 2020 2020 2020 7072 6f62 6c65 proble\n+000050f0: 6d20 3d20 2761 7574 6865 6e74 6963 6174 m = 'authenticat\n+00005100: 696f 6e2d 6661 696c 6564 270a 2020 2020 ion-failed'. \n+00005110: 2020 2020 656c 6966 2069 7369 6e73 7461 elif isinsta\n+00005120: 6e63 6528 6572 726f 722c 2066 6572 6e79 nce(error, ferny\n+00005130: 2e53 7368 486f 7374 4b65 7945 7272 6f72 .SshHostKeyError\n+00005140: 293a 0a20 2020 2020 2020 2020 2020 2070 ):. p\n+00005150: 726f 626c 656d 203d 2027 756e 6b6e 6f77 roblem = 'unknow\n+00005160: 6e2d 686f 7374 6b65 7927 0a20 2020 2020 n-hostkey'. \n+00005170: 2020 2065 6c69 6620 6973 696e 7374 616e elif isinstan\n+00005180: 6365 2865 7272 6f72 2c20 4f53 4572 726f ce(error, OSErro\n+00005190: 7229 3a0a 2020 2020 2020 2020 2020 2020 r):. \n+000051a0: 2320 7573 7561 6c6c 7920 444e 532f 736f # usually DNS/so\n+000051b0: 636b 6574 2065 7272 6f72 730a 2020 2020 cket errors. \n+000051c0: 2020 2020 2020 2020 7072 6f62 6c65 6d20 problem \n+000051d0: 3d20 2775 6e6b 6e6f 776e 2d68 6f73 7427 = 'unknown-host'\n+000051e0: 0a20 2020 2020 2020 2065 6c73 653a 0a20 . else:. \n+000051f0: 2020 2020 2020 2020 2020 2070 726f 626c probl\n+00005200: 656d 203d 2027 696e 7465 726e 616c 2d65 em = 'internal-e\n+00005210: 7272 6f72 270a 2020 2020 2020 2020 6272 rror'. br\n+00005220: 6964 6765 2e77 7269 7465 5f63 6f6e 7472 idge.write_contr\n+00005230: 6f6c 2863 6f6d 6d61 6e64 3d27 696e 6974 ol(command='init\n+00005240: 272c 2070 726f 626c 656d 3d70 726f 626c ', problem=probl\n+00005250: 656d 2c20 6d65 7373 6167 653d 7374 7228 em, message=str(\n+00005260: 6572 726f 7229 290a 2020 2020 2020 2020 error)). \n+00005270: 7265 7475 726e 0a20 2020 2065 7863 6570 return. excep\n+00005280: 7420 436f 636b 7069 7450 726f 626c 656d t CockpitProblem\n+00005290: 2061 7320 6578 633a 0a20 2020 2020 2020 as exc:. \n+000052a0: 206c 6f67 6765 722e 6465 6275 6728 2243 logger.debug(\"C\n+000052b0: 6f63 6b70 6974 5072 6f62 6c65 6d3a 2025 ockpitProblem: %\n+000052c0: 7322 2c20 6578 6329 0a20 2020 2020 2020 s\", exc). \n+000052d0: 2062 7269 6467 652e 7772 6974 655f 636f bridge.write_co\n+000052e0: 6e74 726f 6c28 6578 632e 6174 7472 732c ntrol(exc.attrs,\n+000052f0: 2063 6f6d 6d61 6e64 3d27 696e 6974 2729 command='init')\n+00005300: 0a20 2020 2020 2020 2072 6574 7572 6e0a . return.\n+00005310: 0a20 2020 206c 6f67 6765 722e 6465 6275 . logger.debu\n+00005320: 6728 2753 7461 7274 7570 2064 6f6e 652e g('Startup done.\n+00005330: 2020 4c6f 6f70 696e 6720 756e 7469 6c20 Looping until \n+00005340: 636f 6e6e 6563 7469 6f6e 2063 6c6f 7365 connection close\n+00005350: 732e 2729 0a20 2020 2074 7279 3a0a 2020 s.'). try:. \n+00005360: 2020 2020 2020 6177 6169 7420 6272 6964 await brid\n+00005370: 6765 2e63 6f6d 6d75 6e69 6361 7465 2829 ge.communicate()\n+00005380: 0a20 2020 2065 7863 6570 7420 4272 6f6b . except Brok\n+00005390: 656e 5069 7065 4572 726f 723a 0a20 2020 enPipeError:. \n+000053a0: 2020 2020 2023 2065 7870 6563 7465 6420 # expected \n+000053b0: 6966 2074 6865 2070 6565 7220 646f 6573 if the peer does\n+000053c0: 6e27 7420 6861 6e67 2075 7020 636c 6561 n't hang up clea\n+000053d0: 6e6c 790a 2020 2020 2020 2020 7061 7373 nly. pass\n+000053e0: 0a0a 0a64 6566 206d 6169 6e28 2920 2d3e ...def main() ->\n+000053f0: 204e 6f6e 653a 0a20 2020 2070 6f6c 7966 None:. polyf\n+00005400: 696c 6c73 2e69 6e73 7461 6c6c 2829 0a0a ills.install()..\n+00005410: 2020 2020 7061 7273 6572 203d 2061 7267 parser = arg\n+00005420: 7061 7273 652e 4172 6775 6d65 6e74 5061 parse.ArgumentPa\n+00005430: 7273 6572 2864 6573 6372 6970 7469 6f6e rser(description\n+00005440: 3d27 636f 636b 7069 742d 6272 6964 6765 ='cockpit-bridge\n+00005450: 2069 7320 7275 6e20 6175 746f 6d61 7469 is run automati\n+00005460: 6361 6c6c 7920 696e 7369 6465 206f 6620 cally inside of \n+00005470: 6120 436f 636b 7069 7420 7365 7373 696f a Cockpit sessio\n+00005480: 6e2e 2729 0a20 2020 2070 6172 7365 722e n.'). parser.\n+00005490: 6164 645f 6172 6775 6d65 6e74 2827 2d2d add_argument('--\n+000054a0: 616c 7761 7973 272c 2061 6374 696f 6e3d always', action=\n+000054b0: 2773 746f 7265 5f74 7275 6527 2c20 6865 'store_true', he\n+000054c0: 6c70 3d22 4e65 7665 7220 7472 7920 746f lp=\"Never try to\n+000054d0: 2072 756e 2063 6f63 6b70 6974 2d62 7269 run cockpit-bri\n+000054e0: 6467 6520 6672 6f6d 2074 6865 2073 7973 dge from the sys\n+000054f0: 7465 6d22 290a 2020 2020 7061 7273 6572 tem\"). parser\n+00005500: 2e61 6464 5f61 7267 756d 656e 7428 272d .add_argument('-\n+00005510: 2d64 6562 7567 272c 2061 6374 696f 6e3d -debug', action=\n+00005520: 2773 746f 7265 5f74 7275 6527 290a 2020 'store_true'). \n+00005530: 2020 7061 7273 6572 2e61 6464 5f61 7267 parser.add_arg\n+00005540: 756d 656e 7428 2764 6573 7469 6e61 7469 ument('destinati\n+00005550: 6f6e 272c 2068 656c 703d 224e 616d 6520 on', help=\"Name \n+00005560: 6f66 2074 6865 2072 656d 6f74 6520 686f of the remote ho\n+00005570: 7374 2074 6f20 636f 6e6e 6563 7420 746f st to connect to\n+00005580: 2c20 6f72 2027 6c6f 6361 6c68 6f73 7427 , or 'localhost'\n+00005590: 2229 0a20 2020 2061 7267 7320 3d20 7061 \"). args = pa\n+000055a0: 7273 6572 2e70 6172 7365 5f61 7267 7328 rser.parse_args(\n+000055b0: 290a 0a20 2020 2073 6574 7570 5f6c 6f67 ).. setup_log\n+000055c0: 6769 6e67 2864 6562 7567 3d61 7267 732e ging(debug=args.\n+000055d0: 6465 6275 6729 0a0a 2020 2020 6173 796e debug).. asyn\n+000055e0: 6369 6f2e 7275 6e28 7275 6e28 6172 6773 cio.run(run(args\n+000055f0: 292c 2064 6562 7567 3d61 7267 732e 6465 ), debug=args.de\n+00005600: 6275 6729 0a0a 0a69 6620 5f5f 6e61 6d65 bug)...if __name\n+00005610: 5f5f 203d 3d20 275f 5f6d 6169 6e5f 5f27 __ == '__main__'\n+00005620: 3a0a 2020 2020 6d61 696e 2829 0a27 2727 :. main().'''\n+00005630: 2c0a 2020 2763 6f63 6b70 6974 2f74 7261 ,. 'cockpit/tra\n+00005640: 6e73 706f 7274 732e 7079 273a 2062 7227 nsports.py': br'\n+00005650: 2727 2320 5468 6973 2066 696c 6520 6973 ''# This file is\n+00005660: 2070 6172 7420 6f66 2043 6f63 6b70 6974 part of Cockpit\n+00005670: 2e0a 230a 2320 436f 7079 7269 6768 7420 ..#.# Copyright \n+00005680: 2843 2920 3230 3232 2052 6564 2048 6174 (C) 2022 Red Hat\n+00005690: 2c20 496e 632e 0a23 0a23 2054 6869 7320 , Inc..#.# This \n+000056a0: 7072 6f67 7261 6d20 6973 2066 7265 6520 program is free \n+000056b0: 736f 6674 7761 7265 3a20 796f 7520 6361 software: you ca\n+000056c0: 6e20 7265 6469 7374 7269 6275 7465 2069 n redistribute i\n+000056d0: 7420 616e 642f 6f72 206d 6f64 6966 790a t and/or modify.\n+000056e0: 2320 6974 2075 6e64 6572 2074 6865 2074 # it under the t\n+000056f0: 6572 6d73 206f 6620 7468 6520 474e 5520 erms of the GNU \n+00005700: 4765 6e65 7261 6c20 5075 626c 6963 204c General Public L\n+00005710: 6963 656e 7365 2061 7320 7075 626c 6973 icense as publis\n+00005720: 6865 6420 6279 0a23 2074 6865 2046 7265 hed by.# the Fre\n+00005730: 6520 536f 6674 7761 7265 2046 6f75 6e64 e Software Found\n+00005740: 6174 696f 6e2c 2065 6974 6865 7220 7665 ation, either ve\n+00005750: 7273 696f 6e20 3320 6f66 2074 6865 204c rsion 3 of the L\n+00005760: 6963 656e 7365 2c20 6f72 0a23 2028 6174 icense, or.# (at\n+00005770: 2079 6f75 7220 6f70 7469 6f6e 2920 616e your option) an\n+00005780: 7920 6c61 7465 7220 7665 7273 696f 6e2e y later version.\n+00005790: 0a23 0a23 2054 6869 7320 7072 6f67 7261 .#.# This progra\n+000057a0: 6d20 6973 2064 6973 7472 6962 7574 6564 m is distributed\n+000057b0: 2069 6e20 7468 6520 686f 7065 2074 6861 in the hope tha\n+000057c0: 7420 6974 2077 696c 6c20 6265 2075 7365 t it will be use\n+000057d0: 6675 6c2c 0a23 2062 7574 2057 4954 484f ful,.# but WITHO\n+000057e0: 5554 2041 4e59 2057 4152 5241 4e54 593b UT ANY WARRANTY;\n+000057f0: 2077 6974 686f 7574 2065 7665 6e20 7468 without even th\n+00005800: 6520 696d 706c 6965 6420 7761 7272 616e e implied warran\n+00005810: 7479 206f 660a 2320 4d45 5243 4841 4e54 ty of.# MERCHANT\n+00005820: 4142 494c 4954 5920 6f72 2046 4954 4e45 ABILITY or FITNE\n+00005830: 5353 2046 4f52 2041 2050 4152 5449 4355 SS FOR A PARTICU\n+00005840: 4c41 5220 5055 5250 4f53 452e 2020 5365 LAR PURPOSE. Se\n+00005850: 6520 7468 650a 2320 474e 5520 4765 6e65 e the.# GNU Gene\n+00005860: 7261 6c20 5075 626c 6963 204c 6963 656e ral Public Licen\n+00005870: 7365 2066 6f72 206d 6f72 6520 6465 7461 se for more deta\n+00005880: 696c 732e 0a23 0a23 2059 6f75 2073 686f ils..#.# You sho\n+00005890: 756c 6420 6861 7665 2072 6563 6569 7665 uld have receive\n+000058a0: 6420 6120 636f 7079 206f 6620 7468 6520 d a copy of the \n+000058b0: 474e 5520 4765 6e65 7261 6c20 5075 626c GNU General Publ\n+000058c0: 6963 204c 6963 656e 7365 0a23 2061 6c6f ic License.# alo\n+000058d0: 6e67 2077 6974 6820 7468 6973 2070 726f ng with this pro\n+000058e0: 6772 616d 2e20 2049 6620 6e6f 742c 2073 gram. If not, s\n+000058f0: 6565 203c 6874 7470 733a 2f2f 7777 772e ee ...\"\"\"Bi-direc\n+00005920: 7469 6f6e 616c 2061 7379 6e63 696f 2e54 tional asyncio.T\n+00005930: 7261 6e73 706f 7274 2069 6d70 6c65 6d65 ransport impleme\n+00005940: 6e74 6174 696f 6e73 2062 6173 6564 206f ntations based o\n+00005950: 6e20 6669 6c65 2064 6573 6372 6970 746f n file descripto\n+00005960: 7273 2e22 2222 0a0a 696d 706f 7274 2061 rs.\"\"\"..import a\n+00005970: 7379 6e63 696f 0a69 6d70 6f72 7420 636f syncio.import co\n+00005980: 6c6c 6563 7469 6f6e 730a 696d 706f 7274 llections.import\n+00005990: 2063 7479 7065 730a 696d 706f 7274 2065 ctypes.import e\n+000059a0: 7272 6e6f 0a69 6d70 6f72 7420 6663 6e74 rrno.import fcnt\n+000059b0: 6c0a 696d 706f 7274 206c 6f67 6769 6e67 l.import logging\n+000059c0: 0a69 6d70 6f72 7420 6f73 0a69 6d70 6f72 .import os.impor\n+000059d0: 7420 7365 6c65 6374 0a69 6d70 6f72 7420 t select.import \n+000059e0: 7369 676e 616c 0a69 6d70 6f72 7420 7374 signal.import st\n+000059f0: 7275 6374 0a69 6d70 6f72 7420 7375 6270 ruct.import subp\n+00005a00: 726f 6365 7373 0a69 6d70 6f72 7420 7465 rocess.import te\n+00005a10: 726d 696f 730a 6672 6f6d 2074 7970 696e rmios.from typin\n+00005a20: 6720 696d 706f 7274 2041 6e79 2c20 436c g import Any, Cl\n+00005a30: 6173 7356 6172 2c20 5365 7175 656e 6365 assVar, Sequence\n+00005a40: 0a0a 6672 6f6d 202e 6a73 6f6e 7574 696c ..from .jsonutil\n+00005a50: 2069 6d70 6f72 7420 4a73 6f6e 4f62 6a65 import JsonObje\n+00005a60: 6374 2c20 6765 745f 696e 740a 0a6c 6962 ct, get_int..lib\n+00005a70: 6336 203d 2063 7479 7065 732e 6364 6c6c c6 = ctypes.cdll\n+00005a80: 2e4c 6f61 644c 6962 7261 7279 2827 6c69 .LoadLibrary('li\n+00005a90: 6263 2e73 6f2e 3627 290a 0a0a 6465 6620 bc.so.6')...def \n+00005aa0: 7072 6374 6c28 2a61 7267 733a 2069 6e74 prctl(*args: int\n+00005ab0: 2920 2d3e 204e 6f6e 653a 0a20 2020 2069 ) -> None:. i\n+00005ac0: 6620 6c69 6263 362e 7072 6374 6c28 2a61 f libc6.prctl(*a\n+00005ad0: 7267 7329 2021 3d20 303a 0a20 2020 2020 rgs) != 0:. \n+00005ae0: 2020 2072 6169 7365 204f 5345 7272 6f72 raise OSError\n+00005af0: 2827 7072 6374 6c28 2920 6661 696c 6564 ('prctl() failed\n+00005b00: 2729 0a0a 0a53 4554 5f50 4445 4154 4853 ')...SET_PDEATHS\n+00005b10: 4947 203d 2031 0a0a 0a6c 6f67 6765 7220 IG = 1...logger \n+00005b20: 3d20 6c6f 6767 696e 672e 6765 744c 6f67 = logging.getLog\n+00005b30: 6765 7228 5f5f 6e61 6d65 5f5f 290a 494f ger(__name__).IO\n+00005b40: 565f 4d41 5820 3d20 3130 3234 2020 2320 V_MAX = 1024 # \n+00005b50: 6d61 6e20 3220 7772 6974 6576 0a0a 0a63 man 2 writev...c\n+00005b60: 6c61 7373 205f 5472 616e 7370 6f72 7428 lass _Transport(\n+00005b70: 6173 796e 6369 6f2e 5472 616e 7370 6f72 asyncio.Transpor\n+00005b80: 7429 3a0a 2020 2020 424c 4f43 4b5f 5349 t):. BLOCK_SI\n+00005b90: 5a45 3a20 436c 6173 7356 6172 5b69 6e74 ZE: ClassVar[int\n+00005ba0: 5d20 3d20 3130 3234 202a 2031 3032 340a ] = 1024 * 1024.\n+00005bb0: 0a20 2020 2023 2041 2074 7261 6e73 706f . # A transpo\n+00005bc0: 7274 2061 6c77 6179 7320 6861 7320 6120 rt always has a \n+00005bd0: 6c6f 6f70 2061 6e64 2061 2070 726f 746f loop and a proto\n+00005be0: 636f 6c0a 2020 2020 5f6c 6f6f 703a 2061 col. _loop: a\n+00005bf0: 7379 6e63 696f 2e41 6273 7472 6163 7445 syncio.AbstractE\n+00005c00: 7665 6e74 4c6f 6f70 0a20 2020 205f 7072 ventLoop. _pr\n+00005c10: 6f74 6f63 6f6c 3a20 6173 796e 6369 6f2e otocol: asyncio.\n+00005c20: 5072 6f74 6f63 6f6c 0a0a 2020 2020 5f71 Protocol.. _q\n+00005c30: 7565 7565 3a20 2763 6f6c 6c65 6374 696f ueue: 'collectio\n+00005c40: 6e73 2e64 6571 7565 5b62 7974 6573 5d20 ns.deque[bytes] \n+00005c50: 7c20 4e6f 6e65 270a 2020 2020 5f69 6e5f | None'. _in_\n+00005c60: 6664 3a20 696e 740a 2020 2020 5f6f 7574 fd: int. _out\n+00005c70: 5f66 643a 2069 6e74 0a20 2020 205f 636c _fd: int. _cl\n+00005c80: 6f73 696e 673a 2062 6f6f 6c0a 2020 2020 osing: bool. \n+00005c90: 5f69 735f 7265 6164 696e 673a 2062 6f6f _is_reading: boo\n+00005ca0: 6c0a 2020 2020 5f65 6f66 3a20 626f 6f6c l. _eof: bool\n+00005cb0: 0a20 2020 205f 6569 6f5f 6973 5f65 6f66 . _eio_is_eof\n+00005cc0: 3a20 626f 6f6c 203d 2046 616c 7365 0a0a : bool = False..\n+00005cd0: 2020 2020 6465 6620 5f5f 696e 6974 5f5f def __init__\n+00005ce0: 2873 656c 662c 0a20 2020 2020 2020 2020 (self,. \n+00005cf0: 2020 2020 2020 2020 6c6f 6f70 3a20 6173 loop: as\n+00005d00: 796e 6369 6f2e 4162 7374 7261 6374 4576 yncio.AbstractEv\n+00005d10: 656e 744c 6f6f 702c 0a20 2020 2020 2020 entLoop,. \n+00005d20: 2020 2020 2020 2020 2020 7072 6f74 6f63 protoc\n+00005d30: 6f6c 3a20 6173 796e 6369 6f2e 5072 6f74 ol: asyncio.Prot\n+00005d40: 6f63 6f6c 2c0a 2020 2020 2020 2020 2020 ocol,. \n+00005d50: 2020 2020 2020 2069 6e5f 6664 3a20 696e in_fd: in\n+00005d60: 7420 3d20 2d31 2c20 6f75 745f 6664 3a20 t = -1, out_fd: \n+00005d70: 696e 7420 3d20 2d31 2c0a 2020 2020 2020 int = -1,. \n+00005d80: 2020 2020 2020 2020 2020 2065 7874 7261 extra\n+00005d90: 3a20 2764 6963 745b 7374 722c 206f 626a : 'dict[str, obj\n+00005da0: 6563 745d 207c 204e 6f6e 6527 203d 204e ect] | None' = N\n+00005db0: 6f6e 6529 3a0a 2020 2020 2020 2020 7375 one):. su\n+00005dc0: 7065 7228 292e 5f5f 696e 6974 5f5f 2865 per().__init__(e\n+00005dd0: 7874 7261 290a 0a20 2020 2020 2020 2073 xtra).. s\n+00005de0: 656c 662e 5f6c 6f6f 7020 3d20 6c6f 6f70 elf._loop = loop\n+00005df0: 0a20 2020 2020 2020 2073 656c 662e 5f70 . self._p\n+00005e00: 726f 746f 636f 6c20 3d20 7072 6f74 6f63 rotocol = protoc\n+00005e10: 6f6c 0a0a 2020 2020 2020 2020 6c6f 6767 ol.. logg\n+00005e20: 6572 2e64 6562 7567 2827 4372 6561 7465 er.debug('Create\n+00005e30: 6420 7472 616e 7370 6f72 7420 2573 2066 d transport %s f\n+00005e40: 6f72 2070 726f 746f 636f 6c20 2573 2c20 or protocol %s, \n+00005e50: 6664 7320 2564 2025 6427 2c20 7365 6c66 fds %d %d', self\n+00005e60: 2c20 7072 6f74 6f63 6f6c 2c20 696e 5f66 , protocol, in_f\n+00005e70: 642c 206f 7574 5f66 6429 0a0a 2020 2020 d, out_fd).. \n+00005e80: 2020 2020 7365 6c66 2e5f 7175 6575 6520 self._queue \n+00005e90: 3d20 4e6f 6e65 0a20 2020 2020 2020 2073 = None. s\n+00005ea0: 656c 662e 5f69 735f 7265 6164 696e 6720 elf._is_reading \n+00005eb0: 3d20 4661 6c73 650a 2020 2020 2020 2020 = False. \n+00005ec0: 7365 6c66 2e5f 656f 6620 3d20 4661 6c73 self._eof = Fals\n+00005ed0: 650a 2020 2020 2020 2020 7365 6c66 2e5f e. self._\n+00005ee0: 636c 6f73 696e 6720 3d20 4661 6c73 650a closing = False.\n+00005ef0: 0a20 2020 2020 2020 2073 656c 662e 5f69 . self._i\n+00005f00: 6e5f 6664 203d 2069 6e5f 6664 0a20 2020 n_fd = in_fd. \n+00005f10: 2020 2020 2073 656c 662e 5f6f 7574 5f66 self._out_f\n+00005f20: 6420 3d20 6f75 745f 6664 0a0a 2020 2020 d = out_fd.. \n+00005f30: 2020 2020 6f73 2e73 6574 5f62 6c6f 636b os.set_block\n+00005f40: 696e 6728 696e 5f66 642c 2046 616c 7365 ing(in_fd, False\n+00005f50: 290a 2020 2020 2020 2020 6966 206f 7574 ). if out\n+00005f60: 5f66 6420 213d 2069 6e5f 6664 3a0a 2020 _fd != in_fd:. \n+00005f70: 2020 2020 2020 2020 2020 6f73 2e73 6574 os.set\n+00005f80: 5f62 6c6f 636b 696e 6728 6f75 745f 6664 _blocking(out_fd\n+00005f90: 2c20 4661 6c73 6529 0a0a 2020 2020 2020 , False).. \n+00005fa0: 2020 7365 6c66 2e5f 7072 6f74 6f63 6f6c self._protocol\n+00005fb0: 2e63 6f6e 6e65 6374 696f 6e5f 6d61 6465 .connection_made\n+00005fc0: 2873 656c 6629 0a20 2020 2020 2020 2073 (self). s\n+00005fd0: 656c 662e 7265 7375 6d65 5f72 6561 6469 elf.resume_readi\n+00005fe0: 6e67 2829 0a0a 2020 2020 6465 6620 5f72 ng().. def _r\n+00005ff0: 6561 645f 7265 6164 7928 7365 6c66 2920 ead_ready(self) \n+00006000: 2d3e 204e 6f6e 653a 0a20 2020 2020 2020 -> None:. \n+00006010: 206c 6f67 6765 722e 6465 6275 6728 2752 logger.debug('R\n+00006020: 6561 6420 7265 6164 7920 6f6e 2025 7320 ead ready on %s \n+00006030: 2573 2025 6427 2c20 7365 6c66 2c20 7365 %s %d', self, se\n+00006040: 6c66 2e5f 7072 6f74 6f63 6f6c 2c20 7365 lf._protocol, se\n+00006050: 6c66 2e5f 696e 5f66 6429 0a20 2020 2020 lf._in_fd). \n+00006060: 2020 2074 7279 3a0a 2020 2020 2020 2020 try:. \n+00006070: 2020 2020 6461 7461 203d 206f 732e 7265 data = os.re\n+00006080: 6164 2873 656c 662e 5f69 6e5f 6664 2c20 ad(self._in_fd, \n+00006090: 5f54 7261 6e73 706f 7274 2e42 4c4f 434b _Transport.BLOCK\n+000060a0: 5f53 495a 4529 0a20 2020 2020 2020 2065 _SIZE). e\n+000060b0: 7863 6570 7420 426c 6f63 6b69 6e67 494f xcept BlockingIO\n+000060c0: 4572 726f 723a 2020 2320 7072 6167 6d61 Error: # pragma\n+000060d0: 3a20 6e6f 2063 6f76 6572 0a20 2020 2020 : no cover. \n+000060e0: 2020 2020 2020 2072 6574 7572 6e0a 2020 return. \n+000060f0: 2020 2020 2020 6578 6365 7074 204f 5345 except OSE\n+00006100: 7272 6f72 2061 7320 6578 633a 0a20 2020 rror as exc:. \n+00006110: 2020 2020 2020 2020 2069 6620 7365 6c66 if self\n+00006120: 2e5f 6569 6f5f 6973 5f65 6f66 2061 6e64 ._eio_is_eof and\n+00006130: 2065 7863 2e65 7272 6e6f 203d 3d20 6572 exc.errno == er\n+00006140: 726e 6f2e 4549 4f3a 0a20 2020 2020 2020 rno.EIO:. \n+00006150: 2020 2020 2020 2020 2023 2050 5459 2064 # PTY d\n+00006160: 6576 6963 6573 2072 6574 7572 6e20 4549 evices return EI\n+00006170: 4f20 746f 206d 6561 6e20 2245 4f46 220a O to mean \"EOF\".\n+00006180: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00006190: 6461 7461 203d 2062 2727 0a20 2020 2020 data = b''. \n+000061a0: 2020 2020 2020 2065 6c73 653a 0a20 2020 else:. \n+000061b0: 2020 2020 2020 2020 2020 2020 2023 204f # O\n+000061c0: 7468 6572 2065 7272 6f72 733a 2074 6572 ther errors: ter\n+000061d0: 6d69 6e61 7465 2074 6865 2063 6f6e 6e65 minate the conne\n+000061e0: 6374 696f 6e0a 2020 2020 2020 2020 2020 ction. \n+000061f0: 2020 2020 2020 7365 6c66 2e61 626f 7274 self.abort\n+00006200: 2865 7863 290a 2020 2020 2020 2020 2020 (exc). \n+00006210: 2020 2020 2020 7265 7475 726e 0a0a 2020 return.. \n+00006220: 2020 2020 2020 6966 2064 6174 6120 213d if data !=\n+00006230: 2062 2727 3a0a 2020 2020 2020 2020 2020 b'':. \n+00006240: 2020 6c6f 6767 6572 2e64 6562 7567 2827 logger.debug('\n+00006250: 2020 7265 6164 2025 6420 6279 7465 7327 read %d bytes'\n+00006260: 2c20 6c65 6e28 6461 7461 2929 0a20 2020 , len(data)). \n+00006270: 2020 2020 2020 2020 2073 656c 662e 5f70 self._p\n+00006280: 726f 746f 636f 6c2e 6461 7461 5f72 6563 rotocol.data_rec\n+00006290: 6569 7665 6428 6461 7461 290a 2020 2020 eived(data). \n+000062a0: 2020 2020 656c 7365 3a0a 2020 2020 2020 else:. \n+000062b0: 2020 2020 2020 6c6f 6767 6572 2e64 6562 logger.deb\n+000062c0: 7567 2827 2020 676f 7420 454f 4627 290a ug(' got EOF').\n+000062d0: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n+000062e0: 2e5f 636c 6f73 655f 7265 6164 6572 2829 ._close_reader()\n+000062f0: 0a20 2020 2020 2020 2020 2020 206b 6565 . kee\n+00006300: 705f 6f70 656e 203d 2073 656c 662e 5f70 p_open = self._p\n+00006310: 726f 746f 636f 6c2e 656f 665f 7265 6365 rotocol.eof_rece\n+00006320: 6976 6564 2829 0a20 2020 2020 2020 2020 ived(). \n+00006330: 2020 2069 6620 6e6f 7420 6b65 6570 5f6f if not keep_o\n+00006340: 7065 6e3a 0a20 2020 2020 2020 2020 2020 pen:. \n+00006350: 2020 2020 2073 656c 662e 636c 6f73 6528 self.close(\n+00006360: 290a 0a20 2020 2064 6566 2069 735f 7265 ).. def is_re\n+00006370: 6164 696e 6728 7365 6c66 2920 2d3e 2062 ading(self) -> b\n+00006380: 6f6f 6c3a 0a20 2020 2020 2020 2072 6574 ool:. ret\n+00006390: 7572 6e20 7365 6c66 2e5f 6973 5f72 6561 urn self._is_rea\n+000063a0: 6469 6e67 0a0a 2020 2020 6465 6620 5f63 ding.. def _c\n+000063b0: 6c6f 7365 5f72 6561 6465 7228 7365 6c66 lose_reader(self\n+000063c0: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n+000063d0: 2020 2073 656c 662e 7061 7573 655f 7265 self.pause_re\n+000063e0: 6164 696e 6728 290a 2020 2020 2020 2020 ading(). \n+000063f0: 7365 6c66 2e5f 696e 5f66 6420 3d20 2d31 self._in_fd = -1\n+00006400: 0a0a 2020 2020 6465 6620 7061 7573 655f .. def pause_\n+00006410: 7265 6164 696e 6728 7365 6c66 2920 2d3e reading(self) ->\n+00006420: 204e 6f6e 653a 0a20 2020 2020 2020 2069 None:. i\n+00006430: 6620 7365 6c66 2e5f 6973 5f72 6561 6469 f self._is_readi\n+00006440: 6e67 3a0a 2020 2020 2020 2020 2020 2020 ng:. \n+00006450: 7365 6c66 2e5f 6c6f 6f70 2e72 656d 6f76 self._loop.remov\n+00006460: 655f 7265 6164 6572 2873 656c 662e 5f69 e_reader(self._i\n+00006470: 6e5f 6664 290a 2020 2020 2020 2020 2020 n_fd). \n+00006480: 2020 7365 6c66 2e5f 6973 5f72 6561 6469 self._is_readi\n+00006490: 6e67 203d 2046 616c 7365 0a0a 2020 2020 ng = False.. \n+000064a0: 6465 6620 7265 7375 6d65 5f72 6561 6469 def resume_readi\n+000064b0: 6e67 2873 656c 6629 202d 3e20 4e6f 6e65 ng(self) -> None\n+000064c0: 3a0a 2020 2020 2020 2020 2320 4974 2773 :. # It's\n+000064d0: 2070 6f73 7369 626c 6520 7468 6174 2074 possible that t\n+000064e0: 6865 2050 726f 746f 636f 6c20 636f 756c he Protocol coul\n+000064f0: 6420 6465 6369 6465 2074 6f20 6174 7465 d decide to atte\n+00006500: 6d70 7420 746f 2075 6e70 6175 7365 0a20 mpt to unpause. \n+00006510: 2020 2020 2020 2023 2072 6561 6469 6e67 # reading\n+00006520: 2061 6674 6572 205f 636c 6f73 655f 7265 after _close_re\n+00006530: 6164 6572 2829 2067 6f74 2063 616c 6c65 ader() got calle\n+00006540: 642e 2020 4368 6563 6b20 7468 6174 2074 d. Check that t\n+00006550: 6865 2066 6420 6973 2021 3d20 2d31 0a20 he fd is != -1. \n+00006560: 2020 2020 2020 2023 2062 6566 6f72 6520 # before \n+00006570: 6163 7475 616c 6c79 2072 6573 756d 696e actually resumin\n+00006580: 672e 0a20 2020 2020 2020 2069 6620 6e6f g.. if no\n+00006590: 7420 7365 6c66 2e5f 6973 5f72 6561 6469 t self._is_readi\n+000065a0: 6e67 2061 6e64 2073 656c 662e 5f69 6e5f ng and self._in_\n+000065b0: 6664 2021 3d20 2d31 3a0a 2020 2020 2020 fd != -1:. \n+000065c0: 2020 2020 2020 7365 6c66 2e5f 6c6f 6f70 self._loop\n+000065d0: 2e61 6464 5f72 6561 6465 7228 7365 6c66 .add_reader(self\n+000065e0: 2e5f 696e 5f66 642c 2073 656c 662e 5f72 ._in_fd, self._r\n+000065f0: 6561 645f 7265 6164 7929 0a20 2020 2020 ead_ready). \n+00006600: 2020 2020 2020 2073 656c 662e 5f69 735f self._is_\n+00006610: 7265 6164 696e 6720 3d20 5472 7565 0a0a reading = True..\n+00006620: 2020 2020 6465 6620 5f63 6c6f 7365 2873 def _close(s\n+00006630: 656c 6629 202d 3e20 4e6f 6e65 3a0a 2020 elf) -> None:. \n+00006640: 2020 2020 2020 7061 7373 0a0a 2020 2020 pass.. \n+00006650: 6465 6620 6162 6f72 7428 7365 6c66 2c20 def abort(self, \n+00006660: 6578 633a 2027 4578 6365 7074 696f 6e20 exc: 'Exception \n+00006670: 7c20 4e6f 6e65 2720 3d20 4e6f 6e65 2920 | None' = None) \n+00006680: 2d3e 204e 6f6e 653a 0a20 2020 2020 2020 -> None:. \n+00006690: 2073 656c 662e 5f63 6c6f 7369 6e67 203d self._closing =\n+000066a0: 2054 7275 650a 2020 2020 2020 2020 7365 True. se\n+000066b0: 6c66 2e5f 636c 6f73 655f 7265 6164 6572 lf._close_reader\n+000066c0: 2829 0a20 2020 2020 2020 2073 656c 662e (). self.\n+000066d0: 5f72 656d 6f76 655f 7772 6974 655f 7175 _remove_write_qu\n+000066e0: 6575 6528 290a 2020 2020 2020 2020 7365 eue(). se\n+000066f0: 6c66 2e5f 7072 6f74 6f63 6f6c 2e63 6f6e lf._protocol.con\n+00006700: 6e65 6374 696f 6e5f 6c6f 7374 2865 7863 nection_lost(exc\n+00006710: 290a 2020 2020 2020 2020 7365 6c66 2e5f ). self._\n+00006720: 636c 6f73 6528 290a 0a20 2020 2064 6566 close().. def\n+00006730: 2063 616e 5f77 7269 7465 5f65 6f66 2873 can_write_eof(s\n+00006740: 656c 6629 202d 3e20 626f 6f6c 3a0a 2020 elf) -> bool:. \n+00006750: 2020 2020 2020 7261 6973 6520 4e6f 7449 raise NotI\n+00006760: 6d70 6c65 6d65 6e74 6564 4572 726f 720a mplementedError.\n+00006770: 0a20 2020 2064 6566 2077 7269 7465 5f65 . def write_e\n+00006780: 6f66 2873 656c 6629 202d 3e20 4e6f 6e65 of(self) -> None\n+00006790: 3a0a 2020 2020 2020 2020 6173 7365 7274 :. assert\n+000067a0: 206e 6f74 2073 656c 662e 5f65 6f66 0a20 not self._eof. \n+000067b0: 2020 2020 2020 2073 656c 662e 5f65 6f66 self._eof\n+000067c0: 203d 2054 7275 650a 2020 2020 2020 2020 = True. \n+000067d0: 6966 2073 656c 662e 5f71 7565 7565 2069 if self._queue i\n+000067e0: 7320 4e6f 6e65 3a0a 2020 2020 2020 2020 s None:. \n+000067f0: 2020 2020 6c6f 6767 6572 2e64 6562 7567 logger.debug\n+00006800: 2827 2573 2067 6f74 2045 4f46 2e20 2063 ('%s got EOF. c\n+00006810: 6c6f 7369 6e67 2062 6163 6b65 6e64 2e27 losing backend.'\n+00006820: 2c20 7365 6c66 290a 2020 2020 2020 2020 , self). \n+00006830: 2020 2020 7365 6c66 2e5f 7772 6974 655f self._write_\n+00006840: 656f 665f 6e6f 7728 290a 2020 2020 2020 eof_now(). \n+00006850: 2020 656c 7365 3a0a 2020 2020 2020 2020 else:. \n+00006860: 2020 2020 6c6f 6767 6572 2e64 6562 7567 logger.debug\n+00006870: 2827 2573 2067 6f74 2045 4f46 2e20 2062 ('%s got EOF. b\n+00006880: 7974 6573 2069 6e20 7175 6575 652c 2064 ytes in queue, d\n+00006890: 6566 6572 7269 6e67 2063 6c6f 7365 272c eferring close',\n+000068a0: 2073 656c 6629 0a0a 2020 2020 6465 6620 self).. def \n+000068b0: 6765 745f 7772 6974 655f 6275 6666 6572 get_write_buffer\n+000068c0: 5f73 697a 6528 7365 6c66 2920 2d3e 2069 _size(self) -> i\n+000068d0: 6e74 3a0a 2020 2020 2020 2020 6966 2073 nt:. if s\n+000068e0: 656c 662e 5f71 7565 7565 2069 7320 4e6f elf._queue is No\n+000068f0: 6e65 3a0a 2020 2020 2020 2020 2020 2020 ne:. \n+00006900: 7265 7475 726e 2030 0a20 2020 2020 2020 return 0. \n+00006910: 2072 6574 7572 6e20 7375 6d28 6c65 6e28 return sum(len(\n+00006920: 626c 6f63 6b29 2066 6f72 2062 6c6f 636b block) for block\n+00006930: 2069 6e20 7365 6c66 2e5f 7175 6575 6529 in self._queue)\n+00006940: 0a0a 2020 2020 6465 6620 6765 745f 7772 .. def get_wr\n+00006950: 6974 655f 6275 6666 6572 5f6c 696d 6974 ite_buffer_limit\n+00006960: 7328 7365 6c66 2920 2d3e 2027 7475 706c s(self) -> 'tupl\n+00006970: 655b 696e 742c 2069 6e74 5d27 3a0a 2020 e[int, int]':. \n+00006980: 2020 2020 2020 7265 7475 726e 2028 302c return (0,\n+00006990: 2030 290a 0a20 2020 2064 6566 2073 6574 0).. def set\n+000069a0: 5f77 7269 7465 5f62 7566 6665 725f 6c69 _write_buffer_li\n+000069b0: 6d69 7473 2873 656c 662c 2068 6967 683a mits(self, high:\n+000069c0: 2027 696e 7420 7c20 4e6f 6e65 2720 3d20 'int | None' = \n+000069d0: 4e6f 6e65 2c20 6c6f 773a 2027 696e 7420 None, low: 'int \n+000069e0: 7c20 4e6f 6e65 2720 3d20 4e6f 6e65 2920 | None' = None) \n+000069f0: 2d3e 204e 6f6e 653a 0a20 2020 2020 2020 -> None:. \n+00006a00: 2061 7373 6572 7420 6869 6768 2069 7320 assert high is \n+00006a10: 4e6f 6e65 206f 7220 6869 6768 203d 3d20 None or high == \n+00006a20: 300a 2020 2020 2020 2020 6173 7365 7274 0. assert\n+00006a30: 206c 6f77 2069 7320 4e6f 6e65 206f 7220 low is None or \n+00006a40: 6c6f 7720 3d3d 2030 0a0a 2020 2020 6465 low == 0.. de\n+00006a50: 6620 5f77 7269 7465 5f65 6f66 5f6e 6f77 f _write_eof_now\n+00006a60: 2873 656c 6629 202d 3e20 4e6f 6e65 3a0a (self) -> None:.\n+00006a70: 2020 2020 2020 2020 7261 6973 6520 4e6f raise No\n+00006a80: 7449 6d70 6c65 6d65 6e74 6564 4572 726f tImplementedErro\n+00006a90: 720a 0a20 2020 2064 6566 205f 7772 6974 r.. def _writ\n+00006aa0: 655f 7265 6164 7928 7365 6c66 2920 2d3e e_ready(self) ->\n+00006ab0: 204e 6f6e 653a 0a20 2020 2020 2020 206c None:. l\n+00006ac0: 6f67 6765 722e 6465 6275 6728 2725 7320 ogger.debug('%s \n+00006ad0: 5f77 7269 7465 5f72 6561 6479 272c 2073 _write_ready', s\n+00006ae0: 656c 6629 0a20 2020 2020 2020 2061 7373 elf). ass\n+00006af0: 6572 7420 7365 6c66 2e5f 7175 6575 6520 ert self._queue \n+00006b00: 6973 206e 6f74 204e 6f6e 650a 0a20 2020 is not None.. \n+00006b10: 2020 2020 2074 7279 3a0a 2020 2020 2020 try:. \n+00006b20: 2020 2020 2020 6e5f 6279 7465 7320 3d20 n_bytes = \n+00006b30: 6f73 2e77 7269 7465 7628 7365 6c66 2e5f os.writev(self._\n+00006b40: 6f75 745f 6664 2c20 7365 6c66 2e5f 7175 out_fd, self._qu\n+00006b50: 6575 6529 0a20 2020 2020 2020 2065 7863 eue). exc\n+00006b60: 6570 7420 426c 6f63 6b69 6e67 494f 4572 ept BlockingIOEr\n+00006b70: 726f 723a 2020 2320 7072 6167 6d61 3a20 ror: # pragma: \n+00006b80: 6e6f 2063 6f76 6572 0a20 2020 2020 2020 no cover. \n+00006b90: 2020 2020 206e 5f62 7974 6573 203d 2030 n_bytes = 0\n+00006ba0: 0a20 2020 2020 2020 2065 7863 6570 7420 . except \n+00006bb0: 4f53 4572 726f 7220 6173 2065 7863 3a0a OSError as exc:.\n+00006bc0: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n+00006bd0: 2e61 626f 7274 2865 7863 290a 2020 2020 .abort(exc). \n+00006be0: 2020 2020 2020 2020 7265 7475 726e 0a0a return..\n+00006bf0: 2020 2020 2020 2020 6c6f 6767 6572 2e64 logger.d\n+00006c00: 6562 7567 2827 2020 7375 6363 6573 7366 ebug(' successf\n+00006c10: 756c 6c79 2077 726f 7465 2025 6420 6279 ully wrote %d by\n+00006c20: 7465 7320 6672 6f6d 2074 6865 2071 7565 tes from the que\n+00006c30: 7565 272c 206e 5f62 7974 6573 290a 0a20 ue', n_bytes).. \n+00006c40: 2020 2020 2020 2077 6869 6c65 206e 5f62 while n_b\n+00006c50: 7974 6573 3a0a 2020 2020 2020 2020 2020 ytes:. \n+00006c60: 2020 626c 6f63 6b20 3d20 7365 6c66 2e5f block = self._\n+00006c70: 7175 6575 652e 706f 706c 6566 7428 290a queue.popleft().\n+00006c80: 2020 2020 2020 2020 2020 2020 6966 206c if l\n+00006c90: 656e 2862 6c6f 636b 2920 3e20 6e5f 6279 en(block) > n_by\n+00006ca0: 7465 733a 0a20 2020 2020 2020 2020 2020 tes:. \n+00006cb0: 2020 2020 2023 2054 6869 7320 626c 6f63 # This bloc\n+00006cc0: 6b20 7761 736e 2774 2063 6f6d 706c 6574 k wasn't complet\n+00006cd0: 656c 7920 7772 6974 7465 6e2e 0a20 2020 ely written.. \n+00006ce0: 2020 2020 2020 2020 2020 2020 206c 6f67 log\n+00006cf0: 6765 722e 6465 6275 6728 2720 2069 6e63 ger.debug(' inc\n+00006d00: 6f6d 706c 6574 6520 626c 6f63 6b2e 2020 omplete block. \n+00006d10: 5374 6f70 2e27 290a 2020 2020 2020 2020 Stop.'). \n+00006d20: 2020 2020 2020 2020 7365 6c66 2e5f 7175 self._qu\n+00006d30: 6575 652e 6170 7065 6e64 6c65 6674 2862 eue.appendleft(b\n+00006d40: 6c6f 636b 5b6e 5f62 7974 6573 3a5d 290a lock[n_bytes:]).\n+00006d50: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00006d60: 6272 6561 6b0a 2020 2020 2020 2020 2020 break. \n+00006d70: 2020 6e5f 6279 7465 7320 2d3d 206c 656e n_bytes -= len\n+00006d80: 2862 6c6f 636b 290a 2020 2020 2020 2020 (block). \n+00006d90: 2020 2020 6c6f 6767 6572 2e64 6562 7567 logger.debug\n+00006da0: 2827 2020 7265 6d6f 7665 6420 636f 6d70 (' removed comp\n+00006db0: 6c65 7465 2062 6c6f 636b 2e20 2025 6420 lete block. %d \n+00006dc0: 7265 6d61 696e 732e 272c 206e 5f62 7974 remains.', n_byt\n+00006dd0: 6573 290a 0a20 2020 2020 2020 2069 6620 es).. if \n+00006de0: 6e6f 7420 7365 6c66 2e5f 7175 6575 653a not self._queue:\n+00006df0: 0a20 2020 2020 2020 2020 2020 206c 6f67 . log\n+00006e00: 6765 722e 6465 6275 6728 2725 7320 7175 ger.debug('%s qu\n+00006e10: 6575 6520 6472 6169 6e65 642e 2729 0a20 eue drained.'). \n+00006e20: 2020 2020 2020 2020 2020 2073 656c 662e self.\n+00006e30: 5f72 656d 6f76 655f 7772 6974 655f 7175 _remove_write_qu\n+00006e40: 6575 6528 290a 2020 2020 2020 2020 2020 eue(). \n+00006e50: 2020 6966 2073 656c 662e 5f65 6f66 3a0a if self._eof:.\n+00006e60: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00006e70: 6c6f 6767 6572 2e64 6562 7567 2827 2573 logger.debug('%s\n+00006e80: 2071 7565 7565 2064 7261 696e 6564 2e20 queue drained. \n+00006e90: 2063 6c6f 7369 6e67 2062 6163 6b65 6e64 closing backend\n+00006ea0: 206e 6f77 2e27 290a 2020 2020 2020 2020 now.'). \n+00006eb0: 2020 2020 2020 2020 7365 6c66 2e5f 7772 self._wr\n+00006ec0: 6974 655f 656f 665f 6e6f 7728 290a 2020 ite_eof_now(). \n+00006ed0: 2020 2020 2020 2020 2020 6966 2073 656c if sel\n+00006ee0: 662e 5f63 6c6f 7369 6e67 3a0a 2020 2020 f._closing:. \n+00006ef0: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n+00006f00: 2e61 626f 7274 2829 0a0a 2020 2020 6465 .abort().. de\n+00006f10: 6620 5f72 656d 6f76 655f 7772 6974 655f f _remove_write_\n+00006f20: 7175 6575 6528 7365 6c66 2920 2d3e 204e queue(self) -> N\n+00006f30: 6f6e 653a 0a20 2020 2020 2020 2069 6620 one:. if \n+00006f40: 7365 6c66 2e5f 7175 6575 6520 6973 206e self._queue is n\n+00006f50: 6f74 204e 6f6e 653a 0a20 2020 2020 2020 ot None:. \n+00006f60: 2020 2020 2073 656c 662e 5f70 726f 746f self._proto\n+00006f70: 636f 6c2e 7265 7375 6d65 5f77 7269 7469 col.resume_writi\n+00006f80: 6e67 2829 0a20 2020 2020 2020 2020 2020 ng(). \n+00006f90: 2073 656c 662e 5f6c 6f6f 702e 7265 6d6f self._loop.remo\n+00006fa0: 7665 5f77 7269 7465 7228 7365 6c66 2e5f ve_writer(self._\n+00006fb0: 6f75 745f 6664 290a 2020 2020 2020 2020 out_fd). \n+00006fc0: 2020 2020 7365 6c66 2e5f 7175 6575 6520 self._queue \n+00006fd0: 3d20 4e6f 6e65 0a0a 2020 2020 6465 6620 = None.. def \n+00006fe0: 5f63 7265 6174 655f 7772 6974 655f 7175 _create_write_qu\n+00006ff0: 6575 6528 7365 6c66 2c20 6461 7461 3a20 eue(self, data: \n+00007000: 6279 7465 7329 202d 3e20 4e6f 6e65 3a0a bytes) -> None:.\n+00007010: 2020 2020 2020 2020 6c6f 6767 6572 2e64 logger.d\n+00007020: 6562 7567 2827 2573 2063 7265 6174 696e ebug('%s creatin\n+00007030: 6720 7772 6974 6520 7175 6575 6520 666f g write queue fo\n+00007040: 7220 6664 2025 7327 2c20 7365 6c66 2c20 r fd %s', self, \n+00007050: 7365 6c66 2e5f 6f75 745f 6664 290a 2020 self._out_fd). \n+00007060: 2020 2020 2020 6173 7365 7274 2073 656c assert sel\n+00007070: 662e 5f71 7565 7565 2069 7320 4e6f 6e65 f._queue is None\n+00007080: 0a20 2020 2020 2020 2073 656c 662e 5f6c . self._l\n+00007090: 6f6f 702e 6164 645f 7772 6974 6572 2873 oop.add_writer(s\n+000070a0: 656c 662e 5f6f 7574 5f66 642c 2073 656c elf._out_fd, sel\n+000070b0: 662e 5f77 7269 7465 5f72 6561 6479 290a f._write_ready).\n+000070c0: 2020 2020 2020 2020 7365 6c66 2e5f 7175 self._qu\n+000070d0: 6575 6520 3d20 636f 6c6c 6563 7469 6f6e eue = collection\n+000070e0: 732e 6465 7175 6528 2864 6174 612c 2929 s.deque((data,))\n+000070f0: 0a20 2020 2020 2020 2073 656c 662e 5f70 . self._p\n+00007100: 726f 746f 636f 6c2e 7061 7573 655f 7772 rotocol.pause_wr\n+00007110: 6974 696e 6728 290a 0a20 2020 2064 6566 iting().. def\n+00007120: 2077 7269 7465 2873 656c 662c 2064 6174 write(self, dat\n+00007130: 613a 2062 7974 6573 2920 2d3e 204e 6f6e a: bytes) -> Non\n+00007140: 653a 0a20 2020 2020 2020 2023 2074 6869 e:. # thi\n+00007150: 7320 6973 2061 2072 6163 6520 636f 6e64 s is a race cond\n+00007160: 6974 696f 6e20 7769 7468 2073 7562 7072 ition with subpr\n+00007170: 6f63 6573 7365 733a 2069 6620 7765 2067 ocesses: if we g\n+00007180: 6574 2061 6e64 2070 726f 6365 7373 2074 et and process t\n+00007190: 6865 2074 6865 2022 6578 6974 6564 220a he the \"exited\".\n+000071a0: 2020 2020 2020 2020 2320 6576 656e 7420 # event \n+000071b0: 6265 666f 7265 2073 6565 696e 6720 4272 before seeing Br\n+000071c0: 6f6b 656e 5069 7065 4572 726f 722c 2077 okenPipeError, w\n+000071d0: 6527 6c6c 2074 7279 2074 6f20 7772 6974 e'll try to writ\n+000071e0: 6520 746f 2061 2063 6c6f 7365 6420 7069 e to a closed pi\n+000071f0: 7065 2e0a 2020 2020 2020 2020 2320 446f pe.. # Do\n+00007200: 2077 6861 7420 7468 6520 7374 616e 6461 what the standa\n+00007210: 7264 206c 6962 7261 7279 2064 6f65 7320 rd library does \n+00007220: 616e 6420 6967 6e6f 7265 2c20 696e 7374 and ignore, inst\n+00007230: 6561 6420 6f66 2061 7373 6572 740a 2020 ead of assert. \n+00007240: 2020 2020 2020 6966 2073 656c 662e 5f63 if self._c\n+00007250: 6c6f 7369 6e67 3a0a 2020 2020 2020 2020 losing:. \n+00007260: 2020 2020 6c6f 6767 6572 2e64 6562 7567 logger.debug\n+00007270: 2827 6967 6e6f 7269 6e67 2077 7269 7465 ('ignoring write\n+00007280: 2829 2074 6f20 636c 6f73 696e 6720 7472 () to closing tr\n+00007290: 616e 7370 6f72 7420 6664 2025 6927 2c20 ansport fd %i', \n+000072a0: 7365 6c66 2e5f 6f75 745f 6664 290a 2020 self._out_fd). \n+000072b0: 2020 2020 2020 2020 2020 7265 7475 726e return\n+000072c0: 0a0a 2020 2020 2020 2020 6173 7365 7274 .. assert\n+000072d0: 206e 6f74 2073 656c 662e 5f65 6f66 0a0a not self._eof..\n+000072e0: 2020 2020 2020 2020 6966 2073 656c 662e if self.\n+000072f0: 5f71 7565 7565 2069 7320 6e6f 7420 4e6f _queue is not No\n+00007300: 6e65 3a0a 2020 2020 2020 2020 2020 2020 ne:. \n+00007310: 7365 6c66 2e5f 7175 6575 652e 6170 7065 self._queue.appe\n+00007320: 6e64 2864 6174 6129 0a0a 2020 2020 2020 nd(data).. \n+00007330: 2020 2020 2020 2320 7772 6974 6576 2829 # writev()\n+00007340: 2077 696c 6c20 636f 6d70 6c61 696e 2069 will complain i\n+00007350: 6620 7468 6520 7175 6575 6520 6973 2074 f the queue is t\n+00007360: 6f6f 206c 6f6e 672e 2020 436f 6e73 6f6c oo long. Consol\n+00007370: 6964 6174 6520 6974 2e0a 2020 2020 2020 idate it.. \n+00007380: 2020 2020 2020 6966 206c 656e 2873 656c if len(sel\n+00007390: 662e 5f71 7565 7565 2920 3e20 494f 565f f._queue) > IOV_\n+000073a0: 4d41 583a 0a20 2020 2020 2020 2020 2020 MAX:. \n+000073b0: 2020 2020 2061 6c6c 5f64 6174 6120 3d20 all_data = \n+000073c0: 6227 272e 6a6f 696e 2873 656c 662e 5f71 b''.join(self._q\n+000073d0: 7565 7565 290a 2020 2020 2020 2020 2020 ueue). \n+000073e0: 2020 2020 2020 7365 6c66 2e5f 7175 6575 self._queu\n+000073f0: 652e 636c 6561 7228 290a 2020 2020 2020 e.clear(). \n+00007400: 2020 2020 2020 2020 2020 7365 6c66 2e5f self._\n+00007410: 7175 6575 652e 6170 7065 6e64 2861 6c6c queue.append(all\n+00007420: 5f64 6174 6129 0a0a 2020 2020 2020 2020 _data).. \n+00007430: 2020 2020 7265 7475 726e 0a0a 2020 2020 return.. \n+00007440: 2020 2020 7472 793a 0a20 2020 2020 2020 try:. \n+00007450: 2020 2020 206e 5f62 7974 6573 203d 206f n_bytes = o\n+00007460: 732e 7772 6974 6528 7365 6c66 2e5f 6f75 s.write(self._ou\n+00007470: 745f 6664 2c20 6461 7461 290a 2020 2020 t_fd, data). \n+00007480: 2020 2020 6578 6365 7074 2042 6c6f 636b except Block\n+00007490: 696e 6749 4f45 7272 6f72 3a0a 2020 2020 ingIOError:. \n+000074a0: 2020 2020 2020 2020 6e5f 6279 7465 7320 n_bytes \n+000074b0: 3d20 300a 2020 2020 2020 2020 6578 6365 = 0. exce\n+000074c0: 7074 204f 5345 7272 6f72 2061 7320 6578 pt OSError as ex\n+000074d0: 633a 0a20 2020 2020 2020 2020 2020 2073 c:. s\n+000074e0: 656c 662e 6162 6f72 7428 6578 6329 0a20 elf.abort(exc). \n+000074f0: 2020 2020 2020 2020 2020 2072 6574 7572 retur\n+00007500: 6e0a 0a20 2020 2020 2020 2069 6620 6e5f n.. if n_\n+00007510: 6279 7465 7320 213d 206c 656e 2864 6174 bytes != len(dat\n+00007520: 6129 3a0a 2020 2020 2020 2020 2020 2020 a):. \n+00007530: 7365 6c66 2e5f 6372 6561 7465 5f77 7269 self._create_wri\n+00007540: 7465 5f71 7565 7565 2864 6174 615b 6e5f te_queue(data[n_\n+00007550: 6279 7465 733a 5d29 0a0a 2020 2020 6465 bytes:]).. de\n+00007560: 6620 636c 6f73 6528 7365 6c66 2920 2d3e f close(self) ->\n+00007570: 204e 6f6e 653a 0a20 2020 2020 2020 2069 None:. i\n+00007580: 6620 7365 6c66 2e5f 636c 6f73 696e 673a f self._closing:\n+00007590: 0a20 2020 2020 2020 2020 2020 2072 6574 . ret\n+000075a0: 7572 6e0a 0a20 2020 2020 2020 2073 656c urn.. sel\n+000075b0: 662e 5f63 6c6f 7369 6e67 203d 2054 7275 f._closing = Tru\n+000075c0: 650a 2020 2020 2020 2020 7365 6c66 2e5f e. self._\n+000075d0: 636c 6f73 655f 7265 6164 6572 2829 0a0a close_reader()..\n+000075e0: 2020 2020 2020 2020 6966 2073 656c 662e if self.\n+000075f0: 5f71 7565 7565 2069 7320 6e6f 7420 4e6f _queue is not No\n+00007600: 6e65 3a0a 2020 2020 2020 2020 2020 2020 ne:. \n+00007610: 2320 6162 6f72 7428 2920 7769 6c6c 2062 # abort() will b\n+00007620: 6520 6361 6c6c 6564 2066 726f 6d20 5f77 e called from _w\n+00007630: 7269 7465 5f72 6561 6479 2829 2077 6865 rite_ready() whe\n+00007640: 6e20 6974 2773 2064 6f6e 650a 2020 2020 n it's done. \n+00007650: 2020 2020 2020 2020 7265 7475 726e 0a0a return..\n+00007660: 2020 2020 2020 2020 7365 6c66 2e61 626f self.abo\n+00007670: 7274 2829 0a0a 2020 2020 6465 6620 6765 rt().. def ge\n+00007680: 745f 7072 6f74 6f63 6f6c 2873 656c 6629 t_protocol(self)\n+00007690: 202d 3e20 6173 796e 6369 6f2e 4261 7365 -> asyncio.Base\n+000076a0: 5072 6f74 6f63 6f6c 3a0a 2020 2020 2020 Protocol:. \n+000076b0: 2020 7265 7475 726e 2073 656c 662e 5f70 return self._p\n+000076c0: 726f 746f 636f 6c0a 0a20 2020 2064 6566 rotocol.. def\n+000076d0: 2069 735f 636c 6f73 696e 6728 7365 6c66 is_closing(self\n+000076e0: 2920 2d3e 2062 6f6f 6c3a 0a20 2020 2020 ) -> bool:. \n+000076f0: 2020 2072 6574 7572 6e20 7365 6c66 2e5f return self._\n+00007700: 636c 6f73 696e 670a 0a20 2020 2064 6566 closing.. def\n+00007710: 2073 6574 5f70 726f 746f 636f 6c28 7365 set_protocol(se\n+00007720: 6c66 2c20 7072 6f74 6f63 6f6c 3a20 6173 lf, protocol: as\n+00007730: 796e 6369 6f2e 4261 7365 5072 6f74 6f63 yncio.BaseProtoc\n+00007740: 6f6c 2920 2d3e 204e 6f6e 653a 0a20 2020 ol) -> None:. \n+00007750: 2020 2020 2072 6169 7365 204e 6f74 496d raise NotIm\n+00007760: 706c 656d 656e 7465 6445 7272 6f72 0a0a plementedError..\n+00007770: 2020 2020 6465 6620 5f5f 6465 6c5f 5f28 def __del__(\n+00007780: 7365 6c66 2920 2d3e 204e 6f6e 653a 0a20 self) -> None:. \n+00007790: 2020 2020 2020 2073 656c 662e 5f63 6c6f self._clo\n+000077a0: 7365 2829 0a0a 0a63 6c61 7373 2053 7562 se()...class Sub\n+000077b0: 7072 6f63 6573 7350 726f 746f 636f 6c28 processProtocol(\n+000077c0: 6173 796e 6369 6f2e 5072 6f74 6f63 6f6c asyncio.Protocol\n+000077d0: 293a 0a20 2020 2022 2222 416e 2065 7874 ):. \"\"\"An ext\n+000077e0: 656e 7369 6f6e 2074 6f20 6173 796e 6369 ension to asynci\n+000077f0: 6f2e 5072 6f74 6f63 6f6c 2066 6f72 2075 o.Protocol for u\n+00007800: 7365 2077 6974 6820 5375 6270 726f 6365 se with Subproce\n+00007810: 7373 5472 616e 7370 6f72 742e 2222 220a ssTransport.\"\"\".\n+00007820: 2020 2020 6465 6620 7072 6f63 6573 735f def process_\n+00007830: 6578 6974 6564 2873 656c 6629 202d 3e20 exited(self) -> \n+00007840: 4e6f 6e65 3a0a 2020 2020 2020 2020 2222 None:. \"\"\n+00007850: 2243 616c 6c65 6420 7768 656e 2073 7562 \"Called when sub\n+00007860: 7072 6f63 6573 7320 6861 7320 6578 6974 process has exit\n+00007870: 6564 2e22 2222 0a20 2020 2020 2020 2072 ed.\"\"\". r\n+00007880: 6169 7365 204e 6f74 496d 706c 656d 656e aise NotImplemen\n+00007890: 7465 6445 7272 6f72 0a0a 0a63 6c61 7373 tedError...class\n+000078a0: 2057 696e 646f 7753 697a 653a 0a20 2020 WindowSize:. \n+000078b0: 2064 6566 205f 5f69 6e69 745f 5f28 7365 def __init__(se\n+000078c0: 6c66 2c20 7661 6c75 653a 204a 736f 6e4f lf, value: JsonO\n+000078d0: 626a 6563 7429 3a0a 2020 2020 2020 2020 bject):. \n+000078e0: 7365 6c66 2e72 6f77 7320 3d20 6765 745f self.rows = get_\n+000078f0: 696e 7428 7661 6c75 652c 2027 726f 7773 int(value, 'rows\n+00007900: 2729 0a20 2020 2020 2020 2073 656c 662e '). self.\n+00007910: 636f 6c73 203d 2067 6574 5f69 6e74 2876 cols = get_int(v\n+00007920: 616c 7565 2c20 2763 6f6c 7327 290a 0a0a alue, 'cols')...\n+00007930: 636c 6173 7320 5375 6270 726f 6365 7373 class Subprocess\n+00007940: 5472 616e 7370 6f72 7428 5f54 7261 6e73 Transport(_Trans\n+00007950: 706f 7274 2c20 6173 796e 6369 6f2e 5375 port, asyncio.Su\n+00007960: 6270 726f 6365 7373 5472 616e 7370 6f72 bprocessTranspor\n+00007970: 7429 3a0a 2020 2020 2222 2241 2062 692d t):. \"\"\"A bi-\n+00007980: 6469 7265 6374 696f 6e61 6c20 7472 616e directional tran\n+00007990: 7370 6f72 7420 7370 6561 6b69 6e67 2077 sport speaking w\n+000079a0: 6974 6820 7374 6469 6e2f 6f75 7420 6f66 ith stdin/out of\n+000079b0: 2061 2073 7562 7072 6f63 6573 732e 0a0a a subprocess...\n+000079c0: 2020 2020 4e6f 7465 3a20 7468 6973 2069 Note: this i\n+000079d0: 7320 6e6f 7420 7265 616c 6c79 2061 206e s not really a n\n+000079e0: 6f72 6d61 6c20 5375 6270 726f 6365 7373 ormal Subprocess\n+000079f0: 5472 616e 7370 6f72 742e 2020 416c 7468 Transport. Alth\n+00007a00: 6f75 6768 2069 740a 2020 2020 696d 706c ough it. impl\n+00007a10: 656d 656e 7473 2074 6865 2065 6e74 6972 ements the entir\n+00007a20: 6520 4150 4920 6f66 2061 7379 6e63 696f e API of asyncio\n+00007a30: 2e53 7562 7072 6f63 6573 7354 7261 6e73 .SubprocessTrans\n+00007a40: 706f 7274 2c20 6974 2069 7320 6e6f 740a port, it is not.\n+00007a50: 2020 2020 6465 7369 676e 6564 2074 6f20 designed to \n+00007a60: 6265 2075 7365 6420 7769 7468 2061 7379 be used with asy\n+00007a70: 6e63 696f 2e53 7562 7072 6f63 6573 7350 ncio.SubprocessP\n+00007a80: 726f 746f 636f 6c20 6f62 6a65 6374 732e rotocol objects.\n+00007a90: 2020 496e 7374 6561 642c 2069 740a 2020 Instead, it. \n+00007aa0: 2020 7061 6972 2077 6974 6820 6e6f 726d pair with norm\n+00007ab0: 616c 2050 726f 746f 636f 6c20 6f62 6a65 al Protocol obje\n+00007ac0: 6374 7320 7768 6963 6820 616c 736f 2069 cts which also i\n+00007ad0: 6d70 6c65 6d65 6e74 2074 6865 0a20 2020 mplement the. \n+00007ae0: 2053 7562 7072 6f63 6573 7350 726f 746f SubprocessProto\n+00007af0: 636f 6c20 6465 6669 6e65 6420 696e 2074 col defined in t\n+00007b00: 6869 7320 6d6f 6475 6c65 2028 7768 6963 his module (whic\n+00007b10: 6820 6f6e 6c79 2068 6173 2061 0a20 2020 h only has a. \n+00007b20: 2070 726f 6365 7373 5f65 7869 7465 6428 process_exited(\n+00007b30: 2920 6d65 7468 6f64 292e 2020 5768 6174 ) method). What\n+00007b40: 6576 6572 2074 6865 2070 726f 746f 636f ever the protoco\n+00007b50: 6c20 7772 6974 6573 2069 7320 7365 6e74 l writes is sent\n+00007b60: 2074 6f20 7374 6469 6e2c 0a20 2020 2061 to stdin,. a\n+00007b70: 6e64 2077 6861 7465 7665 7220 636f 6d65 nd whatever come\n+00007b80: 7320 6672 6f6d 2073 7464 6f75 7420 6973 s from stdout is\n+00007b90: 2067 6976 656e 2074 6f20 7468 6520 5072 given to the Pr\n+00007ba0: 6f74 6f63 6f6c 2076 6961 2074 6865 0a20 otocol via the. \n+00007bb0: 2020 202e 6461 7461 5f72 6563 6569 7665 .data_receive\n+00007bc0: 6428 2920 6675 6e63 7469 6f6e 2e0a 0a20 d() function... \n+00007bd0: 2020 2049 6620 7374 6465 7272 2069 7320 If stderr is \n+00007be0: 636f 6e66 6967 7572 6564 2061 7320 6120 configured as a \n+00007bf0: 7069 7065 2c20 7468 6520 7472 616e 7370 pipe, the transp\n+00007c00: 6f72 7420 7769 6c6c 2073 6570 6172 6174 ort will separat\n+00007c10: 656c 7920 636f 6c6c 6563 740a 2020 2020 ely collect. \n+00007c20: 6461 7461 2066 726f 6d20 6974 2c20 6d61 data from it, ma\n+00007c30: 6b69 6e67 2069 7420 6176 6169 6c61 626c king it availabl\n+00007c40: 6520 7669 6120 7468 6520 2e67 6574 5f73 e via the .get_s\n+00007c50: 7464 6572 7228 2920 6d65 7468 6f64 2e0a tderr() method..\n+00007c60: 2020 2020 2222 220a 0a20 2020 205f 7265 \"\"\".. _re\n+00007c70: 7475 726e 636f 6465 3a20 2769 6e74 207c turncode: 'int |\n+00007c80: 204e 6f6e 6527 203d 204e 6f6e 650a 0a20 None' = None.. \n+00007c90: 2020 205f 7074 795f 6664 3a20 2769 6e74 _pty_fd: 'int\n+00007ca0: 207c 204e 6f6e 6527 203d 204e 6f6e 650a | None' = None.\n+00007cb0: 2020 2020 5f70 726f 6365 7373 3a20 2773 _process: 's\n+00007cc0: 7562 7072 6f63 6573 732e 506f 7065 6e5b ubprocess.Popen[\n+00007cd0: 6279 7465 735d 207c 204e 6f6e 6527 203d bytes] | None' =\n+00007ce0: 204e 6f6e 650a 2020 2020 5f73 7464 6572 None. _stder\n+00007cf0: 723a 2027 5370 6f6f 6c65 7220 7c20 4e6f r: 'Spooler | No\n+00007d00: 6e65 270a 0a20 2020 2040 7374 6174 6963 ne'.. @static\n+00007d10: 6d65 7468 6f64 0a20 2020 2064 6566 205f method. def _\n+00007d20: 6372 6561 7465 5f77 6174 6368 6572 2829 create_watcher()\n+00007d30: 202d 3e20 6173 796e 6369 6f2e 4162 7374 -> asyncio.Abst\n+00007d40: 7261 6374 4368 696c 6457 6174 6368 6572 ractChildWatcher\n+00007d50: 3a0a 2020 2020 2020 2020 7472 793a 0a20 :. try:. \n+00007d60: 2020 2020 2020 2020 2020 206f 732e 636c os.cl\n+00007d70: 6f73 6528 6f73 2e70 6964 6664 5f6f 7065 ose(os.pidfd_ope\n+00007d80: 6e28 6f73 2e67 6574 7069 6428 292c 2030 n(os.getpid(), 0\n+00007d90: 2929 2020 2320 6368 6563 6b20 666f 7220 )) # check for \n+00007da0: 6b65 726e 656c 2073 7570 706f 7274 0a20 kernel support. \n+00007db0: 2020 2020 2020 2020 2020 2072 6574 7572 retur\n+00007dc0: 6e20 6173 796e 6369 6f2e 5069 6466 6443 n asyncio.PidfdC\n+00007dd0: 6869 6c64 5761 7463 6865 7228 290a 2020 hildWatcher(). \n+00007de0: 2020 2020 2020 6578 6365 7074 2028 4174 except (At\n+00007df0: 7472 6962 7574 6545 7272 6f72 2c20 4f53 tributeError, OS\n+00007e00: 4572 726f 7229 3a0a 2020 2020 2020 2020 Error):. \n+00007e10: 2020 2020 7061 7373 0a0a 2020 2020 2020 pass.. \n+00007e20: 2020 7265 7475 726e 2061 7379 6e63 696f return asyncio\n+00007e30: 2e53 6166 6543 6869 6c64 5761 7463 6865 .SafeChildWatche\n+00007e40: 7228 290a 0a20 2020 2040 7374 6174 6963 r().. @static\n+00007e50: 6d65 7468 6f64 0a20 2020 2064 6566 205f method. def _\n+00007e60: 6765 745f 7761 7463 6865 7228 6c6f 6f70 get_watcher(loop\n+00007e70: 3a20 6173 796e 6369 6f2e 4162 7374 7261 : asyncio.Abstra\n+00007e80: 6374 4576 656e 744c 6f6f 7029 202d 3e20 ctEventLoop) -> \n+00007e90: 6173 796e 6369 6f2e 4162 7374 7261 6374 asyncio.Abstract\n+00007ea0: 4368 696c 6457 6174 6368 6572 3a0a 2020 ChildWatcher:. \n+00007eb0: 2020 2020 2020 7175 6172 6b20 3d20 275f quark = '_\n+00007ec0: 636f 636b 7069 745f 7472 616e 7370 6f72 cockpit_transpor\n+00007ed0: 7473 5f63 6869 6c64 5f77 6174 6368 6572 ts_child_watcher\n+00007ee0: 270a 2020 2020 2020 2020 7761 7463 6865 '. watche\n+00007ef0: 7220 3d20 6765 7461 7474 7228 6c6f 6f70 r = getattr(loop\n+00007f00: 2c20 7175 6172 6b2c 204e 6f6e 6529 0a0a , quark, None)..\n+00007f10: 2020 2020 2020 2020 6966 2077 6174 6368 if watch\n+00007f20: 6572 2069 7320 4e6f 6e65 3a0a 2020 2020 er is None:. \n+00007f30: 2020 2020 2020 2020 7761 7463 6865 7220 watcher \n+00007f40: 3d20 5375 6270 726f 6365 7373 5472 616e = SubprocessTran\n+00007f50: 7370 6f72 742e 5f63 7265 6174 655f 7761 sport._create_wa\n+00007f60: 7463 6865 7228 290a 2020 2020 2020 2020 tcher(). \n+00007f70: 2020 2020 7761 7463 6865 722e 6174 7461 watcher.atta\n+00007f80: 6368 5f6c 6f6f 7028 6c6f 6f70 290a 2020 ch_loop(loop). \n+00007f90: 2020 2020 2020 2020 2020 7365 7461 7474 setatt\n+00007fa0: 7228 6c6f 6f70 2c20 7175 6172 6b2c 2077 r(loop, quark, w\n+00007fb0: 6174 6368 6572 290a 0a20 2020 2020 2020 atcher).. \n+00007fc0: 2072 6574 7572 6e20 7761 7463 6865 720a return watcher.\n+00007fd0: 0a20 2020 2064 6566 2067 6574 5f73 7464 . def get_std\n+00007fe0: 6572 7228 7365 6c66 2c20 2a2c 2072 6573 err(self, *, res\n+00007ff0: 6574 3a20 626f 6f6c 203d 2046 616c 7365 et: bool = False\n+00008000: 2920 2d3e 2073 7472 3a0a 2020 2020 2020 ) -> str:. \n+00008010: 2020 6966 2073 656c 662e 5f73 7464 6572 if self._stder\n+00008020: 7220 6973 206e 6f74 204e 6f6e 653a 0a20 r is not None:. \n+00008030: 2020 2020 2020 2020 2020 2072 6574 7572 retur\n+00008040: 6e20 7365 6c66 2e5f 7374 6465 7272 2e67 n self._stderr.g\n+00008050: 6574 2872 6573 6574 3d72 6573 6574 292e et(reset=reset).\n+00008060: 6465 636f 6465 2865 7272 6f72 733d 2772 decode(errors='r\n+00008070: 6570 6c61 6365 2729 0a20 2020 2020 2020 eplace'). \n+00008080: 2065 6c73 653a 0a20 2020 2020 2020 2020 else:. \n+00008090: 2020 2072 6574 7572 6e20 2727 0a0a 2020 return ''.. \n+000080a0: 2020 6465 6620 5f65 7869 7465 6428 7365 def _exited(se\n+000080b0: 6c66 2c20 7069 643a 2069 6e74 2c20 636f lf, pid: int, co\n+000080c0: 6465 3a20 696e 7429 202d 3e20 4e6f 6e65 de: int) -> None\n+000080d0: 3a0a 2020 2020 2020 2020 2320 4e42 3a20 :. # NB: \n+000080e0: 7065 7220 4162 7374 7261 6374 4368 696c per AbstractChil\n+000080f0: 6457 6174 6368 6572 2041 5049 2c20 7468 dWatcher API, th\n+00008100: 6973 2068 616e 646c 6572 2073 686f 756c is handler shoul\n+00008110: 6420 6265 2074 6872 6561 642d 7361 6665 d be thread-safe\n+00008120: 2c0a 2020 2020 2020 2020 2320 6275 7420 ,. # but \n+00008130: 7765 206f 6e6c 7920 6576 6572 2075 7365 we only ever use\n+00008140: 206e 6f6e 2d74 6872 6561 6465 6420 6368 non-threaded ch\n+00008150: 696c 6420 7761 7463 6865 7220 696d 706c ild watcher impl\n+00008160: 656d 656e 7461 7469 6f6e 732c 2073 6f0a ementations, so.\n+00008170: 2020 2020 2020 2020 2320 7765 2063 616e # we can\n+00008180: 2061 7373 756d 6520 7765 276c 6c20 616c assume we'll al\n+00008190: 7761 7973 2062 6520 6361 6c6c 6564 2069 ways be called i\n+000081a0: 6e20 7468 6520 6d61 696e 2074 6872 6561 n the main threa\n+000081b0: 642e 0a0a 2020 2020 2020 2020 2320 4e42 d... # NB\n+000081c0: 3a20 7468 6520 7375 6270 726f 6365 7373 : the subprocess\n+000081d0: 2069 7320 676f 696e 6720 746f 2077 616e is going to wan\n+000081e0: 7420 746f 2077 6169 7470 6964 2829 2069 t to waitpid() i\n+000081f0: 7473 656c 6620 6173 2077 656c 6c2c 2062 tself as well, b\n+00008200: 7574 0a20 2020 2020 2020 2023 2077 696c ut. # wil\n+00008210: 6c20 6765 7420 4543 4849 4c44 2073 696e l get ECHILD sin\n+00008220: 6365 2077 6520 616c 7265 6164 7920 7265 ce we already re\n+00008230: 6170 6564 2069 742e 2020 466f 7274 756e aped it. Fortun\n+00008240: 6174 656c 792c 2073 696e 6365 0a20 2020 ately, since. \n+00008250: 2020 2020 2023 2050 7974 686f 6e20 332e # Python 3.\n+00008260: 3220 7468 6973 2069 7320 7375 7070 6f72 2 this is suppor\n+00008270: 7465 642c 2061 6e64 2070 726f 6365 7373 ted, and process\n+00008280: 2067 6574 7320 6120 7265 7475 726e 2073 gets a return s\n+00008290: 7461 7475 7320 6f66 0a20 2020 2020 2020 tatus of. \n+000082a0: 2023 207a 6572 6f2e 2020 466f 7220 7468 # zero. For th\n+000082b0: 6174 2072 6561 736f 6e2c 2077 6520 6e65 at reason, we ne\n+000082c0: 6564 2074 6f20 7374 6f72 6520 6f75 7220 ed to store our \n+000082d0: 6f77 6e20 636f 7079 206f 6620 7468 6520 own copy of the \n+000082e0: 7265 7475 726e 0a20 2020 2020 2020 2023 return. #\n+000082f0: 2073 7461 7475 732e 2020 5365 6520 6874 status. See ht\n+00008300: 7470 733a 2f2f 6769 7468 7562 2e63 6f6d tps://github.com\n+00008310: 2f70 7974 686f 6e2f 6370 7974 686f 6e2f /python/cpython/\n+00008320: 6973 7375 6573 2f35 3939 3630 0a20 2020 issues/59960. \n+00008330: 2020 2020 2061 7373 6572 7420 6973 696e assert isin\n+00008340: 7374 616e 6365 2873 656c 662e 5f70 726f stance(self._pro\n+00008350: 746f 636f 6c2c 2053 7562 7072 6f63 6573 tocol, Subproces\n+00008360: 7350 726f 746f 636f 6c29 0a20 2020 2020 sProtocol). \n+00008370: 2020 2061 7373 6572 7420 7365 6c66 2e5f assert self._\n+00008380: 7072 6f63 6573 7320 6973 206e 6f74 204e process is not N\n+00008390: 6f6e 650a 2020 2020 2020 2020 6173 7365 one. asse\n+000083a0: 7274 2073 656c 662e 5f70 726f 6365 7373 rt self._process\n+000083b0: 2e70 6964 203d 3d20 7069 640a 2020 2020 .pid == pid. \n+000083c0: 2020 2020 7365 6c66 2e5f 7265 7475 726e self._return\n+000083d0: 636f 6465 203d 2063 6f64 650a 2020 2020 code = code. \n+000083e0: 2020 2020 6c6f 6767 6572 2e64 6562 7567 logger.debug\n+000083f0: 2827 5072 6f63 6573 7320 6578 6974 6564 ('Process exited\n+00008400: 2077 6974 6820 7374 6174 7573 2025 6427 with status %d'\n+00008410: 2c20 7365 6c66 2e5f 7265 7475 726e 636f , self._returnco\n+00008420: 6465 290a 2020 2020 2020 2020 6966 206e de). if n\n+00008430: 6f74 2073 656c 662e 5f63 6c6f 7369 6e67 ot self._closing\n+00008440: 3a0a 2020 2020 2020 2020 2020 2020 7365 :. se\n+00008450: 6c66 2e5f 7072 6f74 6f63 6f6c 2e70 726f lf._protocol.pro\n+00008460: 6365 7373 5f65 7869 7465 6428 290a 0a20 cess_exited().. \n+00008470: 2020 2064 6566 205f 5f69 6e69 745f 5f28 def __init__(\n+00008480: 7365 6c66 2c0a 2020 2020 2020 2020 2020 self,. \n+00008490: 2020 2020 2020 206c 6f6f 703a 2061 7379 loop: asy\n+000084a0: 6e63 696f 2e41 6273 7472 6163 7445 7665 ncio.AbstractEve\n+000084b0: 6e74 4c6f 6f70 2c0a 2020 2020 2020 2020 ntLoop,. \n+000084c0: 2020 2020 2020 2020 2070 726f 746f 636f protoco\n+000084d0: 6c3a 2053 7562 7072 6f63 6573 7350 726f l: SubprocessPro\n+000084e0: 746f 636f 6c2c 0a20 2020 2020 2020 2020 tocol,. \n+000084f0: 2020 2020 2020 2020 6172 6773 3a20 5365 args: Se\n+00008500: 7175 656e 6365 5b73 7472 5d2c 0a20 2020 quence[str],. \n+00008510: 2020 2020 2020 2020 2020 2020 2020 2a2c *,\n+00008520: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+00008530: 2020 7074 793a 2062 6f6f 6c20 3d20 4661 pty: bool = Fa\n+00008540: 6c73 652c 0a20 2020 2020 2020 2020 2020 lse,. \n+00008550: 2020 2020 2020 7769 6e64 6f77 3a20 2757 window: 'W\n+00008560: 696e 646f 7753 697a 6520 7c20 4e6f 6e65 indowSize | None\n+00008570: 2720 3d20 4e6f 6e65 2c0a 2020 2020 2020 ' = None,. \n+00008580: 2020 2020 2020 2020 2020 202a 2a6b 7761 **kwa\n+00008590: 7267 733a 2041 6e79 293a 0a0a 2020 2020 rgs: Any):.. \n+000085a0: 2020 2020 2320 676f 2064 6f77 6e20 6173 # go down as\n+000085b0: 2061 2074 6561 6d20 2d2d 2077 6520 646f a team -- we do\n+000085c0: 6e27 7420 7761 6e74 2061 6e79 206c 6561 n't want any lea\n+000085d0: 6b65 6420 7072 6f63 6573 7365 7320 7768 ked processes wh\n+000085e0: 656e 2074 6865 2062 7269 6467 6520 7465 en the bridge te\n+000085f0: 726d 696e 6174 6573 0a20 2020 2020 2020 rminates. \n+00008600: 2064 6566 2070 7265 6578 6563 5f66 6e28 def preexec_fn(\n+00008610: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n+00008620: 2020 2020 2020 2070 7263 746c 2853 4554 prctl(SET\n+00008630: 5f50 4445 4154 4853 4947 2c20 7369 676e _PDEATHSIG, sign\n+00008640: 616c 2e53 4947 5445 524d 290a 2020 2020 al.SIGTERM). \n+00008650: 2020 2020 2020 2020 6966 2070 7479 3a0a if pty:.\n+00008660: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00008670: 6663 6e74 6c2e 696f 6374 6c28 302c 2074 fcntl.ioctl(0, t\n+00008680: 6572 6d69 6f73 2e54 494f 4353 4354 5459 ermios.TIOCSCTTY\n+00008690: 2c20 3029 0a0a 2020 2020 2020 2020 6966 , 0).. if\n+000086a0: 2070 7479 3a0a 2020 2020 2020 2020 2020 pty:. \n+000086b0: 2020 7365 6c66 2e5f 7074 795f 6664 2c20 self._pty_fd, \n+000086c0: 7365 7373 696f 6e5f 6664 203d 206f 732e session_fd = os.\n+000086d0: 6f70 656e 7074 7928 290a 0a20 2020 2020 openpty().. \n+000086e0: 2020 2020 2020 2069 6620 7769 6e64 6f77 if window\n+000086f0: 2069 7320 6e6f 7420 4e6f 6e65 3a0a 2020 is not None:. \n+00008700: 2020 2020 2020 2020 2020 2020 2020 7365 se\n+00008710: 6c66 2e73 6574 5f77 696e 646f 775f 7369 lf.set_window_si\n+00008720: 7a65 2877 696e 646f 7729 0a0a 2020 2020 ze(window).. \n+00008730: 2020 2020 2020 2020 6b77 6172 6773 5b27 kwargs['\n+00008740: 7374 6465 7272 275d 203d 2073 6573 7369 stderr'] = sessi\n+00008750: 6f6e 5f66 640a 2020 2020 2020 2020 2020 on_fd. \n+00008760: 2020 7365 6c66 2e5f 7072 6f63 6573 7320 self._process \n+00008770: 3d20 7375 6270 726f 6365 7373 2e50 6f70 = subprocess.Pop\n+00008780: 656e 2861 7267 732c 0a20 2020 2020 2020 en(args,. \n+00008790: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000087a0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000087b0: 2020 2020 2020 7374 6469 6e3d 7365 7373 stdin=sess\n+000087c0: 696f 6e5f 6664 2c20 7374 646f 7574 3d73 ion_fd, stdout=s\n+000087d0: 6573 7369 6f6e 5f66 642c 0a20 2020 2020 ession_fd,. \n+000087e0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000087f0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00008800: 2020 2020 2020 2020 7072 6565 7865 635f preexec_\n+00008810: 666e 3d70 7265 6578 6563 5f66 6e2c 2073 fn=preexec_fn, s\n+00008820: 7461 7274 5f6e 6577 5f73 6573 7369 6f6e tart_new_session\n+00008830: 3d54 7275 652c 202a 2a6b 7761 7267 7329 =True, **kwargs)\n+00008840: 0a20 2020 2020 2020 2020 2020 206f 732e . os.\n+00008850: 636c 6f73 6528 7365 7373 696f 6e5f 6664 close(session_fd\n+00008860: 290a 0a20 2020 2020 2020 2020 2020 2069 ).. i\n+00008870: 6e5f 6664 2c20 6f75 745f 6664 203d 2073 n_fd, out_fd = s\n+00008880: 656c 662e 5f70 7479 5f66 642c 2073 656c elf._pty_fd, sel\n+00008890: 662e 5f70 7479 5f66 640a 2020 2020 2020 f._pty_fd. \n+000088a0: 2020 2020 2020 7365 6c66 2e5f 6569 6f5f self._eio_\n+000088b0: 6973 5f65 6f66 203d 2054 7275 650a 0a20 is_eof = True.. \n+000088c0: 2020 2020 2020 2065 6c73 653a 0a20 2020 else:. \n+000088d0: 2020 2020 2020 2020 2073 656c 662e 5f70 self._p\n+000088e0: 726f 6365 7373 203d 2073 7562 7072 6f63 rocess = subproc\n+000088f0: 6573 732e 506f 7065 6e28 6172 6773 2c20 ess.Popen(args, \n+00008900: 7374 6469 6e3d 7375 6270 726f 6365 7373 stdin=subprocess\n+00008910: 2e50 4950 452c 2073 7464 6f75 743d 7375 .PIPE, stdout=su\n+00008920: 6270 726f 6365 7373 2e50 4950 452c 0a20 bprocess.PIPE,. \n+00008930: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00008940: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00008950: 2020 2020 2020 2020 2020 2020 7072 6565 pree\n+00008960: 7865 635f 666e 3d70 7265 6578 6563 5f66 xec_fn=preexec_f\n+00008970: 6e2c 202a 2a6b 7761 7267 7329 0a20 2020 n, **kwargs). \n+00008980: 2020 2020 2020 2020 2061 7373 6572 7420 assert \n+00008990: 7365 6c66 2e5f 7072 6f63 6573 732e 7374 self._process.st\n+000089a0: 6469 6e0a 2020 2020 2020 2020 2020 2020 din. \n+000089b0: 6173 7365 7274 2073 656c 662e 5f70 726f assert self._pro\n+000089c0: 6365 7373 2e73 7464 6f75 740a 2020 2020 cess.stdout. \n+000089d0: 2020 2020 2020 2020 696e 5f66 6420 3d20 in_fd = \n+000089e0: 7365 6c66 2e5f 7072 6f63 6573 732e 7374 self._process.st\n+000089f0: 646f 7574 2e66 696c 656e 6f28 290a 2020 dout.fileno(). \n+00008a00: 2020 2020 2020 2020 2020 6f75 745f 6664 out_fd\n+00008a10: 203d 2073 656c 662e 5f70 726f 6365 7373 = self._process\n+00008a20: 2e73 7464 696e 2e66 696c 656e 6f28 290a .stdin.fileno().\n+00008a30: 0a20 2020 2020 2020 2069 6620 7365 6c66 . if self\n+00008a40: 2e5f 7072 6f63 6573 732e 7374 6465 7272 ._process.stderr\n+00008a50: 2069 7320 6e6f 7420 4e6f 6e65 3a0a 2020 is not None:. \n+00008a60: 2020 2020 2020 2020 2020 7365 6c66 2e5f self._\n+00008a70: 7374 6465 7272 203d 2053 706f 6f6c 6572 stderr = Spooler\n+00008a80: 286c 6f6f 702c 2073 656c 662e 5f70 726f (loop, self._pro\n+00008a90: 6365 7373 2e73 7464 6572 722e 6669 6c65 cess.stderr.file\n+00008aa0: 6e6f 2829 290a 2020 2020 2020 2020 656c no()). el\n+00008ab0: 7365 3a0a 2020 2020 2020 2020 2020 2020 se:. \n+00008ac0: 7365 6c66 2e5f 7374 6465 7272 203d 204e self._stderr = N\n+00008ad0: 6f6e 650a 0a20 2020 2020 2020 2073 7570 one.. sup\n+00008ae0: 6572 2829 2e5f 5f69 6e69 745f 5f28 6c6f er().__init__(lo\n+00008af0: 6f70 2c20 7072 6f74 6f63 6f6c 2c20 696e op, protocol, in\n+00008b00: 5f66 642c 206f 7574 5f66 6429 0a0a 2020 _fd, out_fd).. \n+00008b10: 2020 2020 2020 7365 6c66 2e5f 6765 745f self._get_\n+00008b20: 7761 7463 6865 7228 6c6f 6f70 292e 6164 watcher(loop).ad\n+00008b30: 645f 6368 696c 645f 6861 6e64 6c65 7228 d_child_handler(\n+00008b40: 7365 6c66 2e5f 7072 6f63 6573 732e 7069 self._process.pi\n+00008b50: 642c 2073 656c 662e 5f65 7869 7465 6429 d, self._exited)\n+00008b60: 0a0a 2020 2020 6465 6620 7365 745f 7769 .. def set_wi\n+00008b70: 6e64 6f77 5f73 697a 6528 7365 6c66 2c20 ndow_size(self, \n+00008b80: 7369 7a65 3a20 5769 6e64 6f77 5369 7a65 size: WindowSize\n+00008b90: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n+00008ba0: 2020 2061 7373 6572 7420 7365 6c66 2e5f assert self._\n+00008bb0: 7074 795f 6664 2069 7320 6e6f 7420 4e6f pty_fd is not No\n+00008bc0: 6e65 0a20 2020 2020 2020 2066 636e 746c ne. fcntl\n+00008bd0: 2e69 6f63 746c 2873 656c 662e 5f70 7479 .ioctl(self._pty\n+00008be0: 5f66 642c 2074 6572 6d69 6f73 2e54 494f _fd, termios.TIO\n+00008bf0: 4353 5749 4e53 5a2c 2073 7472 7563 742e CSWINSZ, struct.\n+00008c00: 7061 636b 2827 3248 3478 272c 2073 697a pack('2H4x', siz\n+00008c10: 652e 726f 7773 2c20 7369 7a65 2e63 6f6c e.rows, size.col\n+00008c20: 7329 290a 0a20 2020 2064 6566 2063 616e s)).. def can\n+00008c30: 5f77 7269 7465 5f65 6f66 2873 656c 6629 _write_eof(self)\n+00008c40: 202d 3e20 626f 6f6c 3a0a 2020 2020 2020 -> bool:. \n+00008c50: 2020 6173 7365 7274 2073 656c 662e 5f70 assert self._p\n+00008c60: 726f 6365 7373 2069 7320 6e6f 7420 4e6f rocess is not No\n+00008c70: 6e65 0a20 2020 2020 2020 2072 6574 7572 ne. retur\n+00008c80: 6e20 7365 6c66 2e5f 7072 6f63 6573 732e n self._process.\n+00008c90: 7374 6469 6e20 6973 206e 6f74 204e 6f6e stdin is not Non\n+00008ca0: 650a 0a20 2020 2064 6566 205f 7772 6974 e.. def _writ\n+00008cb0: 655f 656f 665f 6e6f 7728 7365 6c66 2920 e_eof_now(self) \n+00008cc0: 2d3e 204e 6f6e 653a 0a20 2020 2020 2020 -> None:. \n+00008cd0: 2061 7373 6572 7420 7365 6c66 2e5f 7072 assert self._pr\n+00008ce0: 6f63 6573 7320 6973 206e 6f74 204e 6f6e ocess is not Non\n+00008cf0: 650a 2020 2020 2020 2020 6173 7365 7274 e. assert\n+00008d00: 2073 656c 662e 5f70 726f 6365 7373 2e73 self._process.s\n+00008d10: 7464 696e 2069 7320 6e6f 7420 4e6f 6e65 tdin is not None\n+00008d20: 0a20 2020 2020 2020 2073 656c 662e 5f70 . self._p\n+00008d30: 726f 6365 7373 2e73 7464 696e 2e63 6c6f rocess.stdin.clo\n+00008d40: 7365 2829 0a20 2020 2020 2020 2073 656c se(). sel\n+00008d50: 662e 5f6f 7574 5f66 6420 3d20 2d31 0a0a f._out_fd = -1..\n+00008d60: 2020 2020 6465 6620 6765 745f 7069 6428 def get_pid(\n+00008d70: 7365 6c66 2920 2d3e 2069 6e74 3a0a 2020 self) -> int:. \n+00008d80: 2020 2020 2020 6173 7365 7274 2073 656c assert sel\n+00008d90: 662e 5f70 726f 6365 7373 2069 7320 6e6f f._process is no\n+00008da0: 7420 4e6f 6e65 0a20 2020 2020 2020 2072 t None. r\n+00008db0: 6574 7572 6e20 7365 6c66 2e5f 7072 6f63 eturn self._proc\n+00008dc0: 6573 732e 7069 640a 0a20 2020 2064 6566 ess.pid.. def\n+00008dd0: 2067 6574 5f72 6574 7572 6e63 6f64 6528 get_returncode(\n+00008de0: 7365 6c66 2920 2d3e 2027 696e 7420 7c20 self) -> 'int | \n+00008df0: 4e6f 6e65 273a 0a20 2020 2020 2020 2072 None':. r\n+00008e00: 6574 7572 6e20 7365 6c66 2e5f 7265 7475 eturn self._retu\n+00008e10: 726e 636f 6465 0a0a 2020 2020 6465 6620 rncode.. def \n+00008e20: 6765 745f 7069 7065 5f74 7261 6e73 706f get_pipe_transpo\n+00008e30: 7274 2873 656c 662c 2066 643a 2069 6e74 rt(self, fd: int\n+00008e40: 2920 2d3e 2061 7379 6e63 696f 2e54 7261 ) -> asyncio.Tra\n+00008e50: 6e73 706f 7274 3a0a 2020 2020 2020 2020 nsport:. \n+00008e60: 7261 6973 6520 4e6f 7449 6d70 6c65 6d65 raise NotImpleme\n+00008e70: 6e74 6564 4572 726f 720a 0a20 2020 2064 ntedError.. d\n+00008e80: 6566 2073 656e 645f 7369 676e 616c 2873 ef send_signal(s\n+00008e90: 656c 662c 2073 6967 3a20 7369 676e 616c elf, sig: signal\n+00008ea0: 2e53 6967 6e61 6c73 2920 2d3e 204e 6f6e .Signals) -> Non\n+00008eb0: 653a 2020 2320 7479 7065 3a20 6967 6e6f e: # type: igno\n+00008ec0: 7265 5b6f 7665 7272 6964 655d 2023 206d re[override] # m\n+00008ed0: 7970 792f 6973 7375 6573 2f31 3338 3835 ypy/issues/13885\n+00008ee0: 0a20 2020 2020 2020 2061 7373 6572 7420 . assert \n+00008ef0: 7365 6c66 2e5f 7072 6f63 6573 7320 6973 self._process is\n+00008f00: 206e 6f74 204e 6f6e 650a 2020 2020 2020 not None. \n+00008f10: 2020 2320 5765 2074 7279 2074 6f20 6176 # We try to av\n+00008f20: 6f69 6420 7573 696e 6720 7375 6270 726f oid using subpro\n+00008f30: 6365 7373 2e73 656e 645f 7369 676e 616c cess.send_signal\n+00008f40: 2829 2e20 2049 7420 636f 6e74 6169 6e73 (). It contains\n+00008f50: 2061 2063 616c 6c0a 2020 2020 2020 2020 a call. \n+00008f60: 2320 746f 2077 6169 7470 6964 2829 2069 # to waitpid() i\n+00008f70: 6e74 6572 6e61 6c6c 7920 746f 2061 766f nternally to avo\n+00008f80: 6964 2073 6967 6e61 6c6c 696e 6720 7468 id signalling th\n+00008f90: 6520 7772 6f6e 6720 7072 6f63 6573 7320 e wrong process \n+00008fa0: 2869 6620 610a 2020 2020 2020 2020 2320 (if a. # \n+00008fb0: 5049 4420 6765 7473 2072 6575 7365 6429 PID gets reused)\n+00008fc0: 2c20 6275 743a 0a20 2020 2020 2020 2023 , but:. #\n+00008fd0: 0a20 2020 2020 2020 2023 2020 2d20 7765 . # - we\n+00008fe0: 2061 6c72 6561 6479 2064 6574 6563 7420 already detect \n+00008ff0: 7468 6520 7072 6f63 6573 7320 6578 6974 the process exit\n+00009000: 696e 6720 7669 6120 6f75 7220 5069 6466 ing via our Pidf\n+00009010: 6443 6869 6c64 5761 7463 6865 720a 2020 dChildWatcher. \n+00009020: 2020 2020 2020 230a 2020 2020 2020 2020 #. \n+00009030: 2320 202d 2074 6865 2063 6865 636b 2069 # - the check i\n+00009040: 7320 6163 7475 616c 6c79 2068 6172 6d66 s actually harmf\n+00009050: 756c 2073 696e 6365 2063 6f6c 6c65 6374 ul since collect\n+00009060: 696e 6720 7468 6520 7072 6f63 6573 7320 ing the process \n+00009070: 7669 610a 2020 2020 2020 2020 2320 2020 via. # \n+00009080: 2077 6169 7470 6964 2829 2070 7265 7665 waitpid() preve\n+00009090: 6e74 7320 7468 6520 5069 6466 6443 6869 nts the PidfdChi\n+000090a0: 6c64 5761 7463 6865 7220 6672 6f6d 2064 ldWatcher from d\n+000090b0: 6f69 6e67 2074 6865 2073 616d 652c 0a20 oing the same,. \n+000090c0: 2020 2020 2020 2023 2020 2020 7265 7375 # resu\n+000090d0: 6c74 696e 6720 696e 2061 6e20 6572 726f lting in an erro\n+000090e0: 722e 0a20 2020 2020 2020 2023 0a20 2020 r.. #. \n+000090f0: 2020 2020 2023 2049 7427 7320 6f6e 2075 # It's on u\n+00009100: 7320 6e6f 7720 746f 2063 6865 636b 2069 s now to check i\n+00009110: 742c 2062 7574 2074 6861 7427 7320 6561 t, but that's ea\n+00009120: 7379 3a0a 2020 2020 2020 2020 6966 2073 sy:. if s\n+00009130: 656c 662e 5f72 6574 7572 6e63 6f64 6520 elf._returncode \n+00009140: 6973 206e 6f74 204e 6f6e 653a 0a20 2020 is not None:. \n+00009150: 2020 2020 2020 2020 206c 6f67 6765 722e logger.\n+00009160: 6465 6275 6728 2277 6f6e 2774 2061 7474 debug(\"won't att\n+00009170: 656d 7074 2025 7320 746f 2070 726f 6365 empt %s to proce\n+00009180: 7373 2025 692e 2020 4974 2065 7869 7465 ss %i. It exite\n+00009190: 6420 616c 7265 6164 792e 222c 2073 6967 d already.\", sig\n+000091a0: 2c20 7365 6c66 2e5f 7072 6f63 6573 732e , self._process.\n+000091b0: 7069 6429 0a20 2020 2020 2020 2020 2020 pid). \n+000091c0: 2072 6574 7572 6e0a 0a20 2020 2020 2020 return.. \n+000091d0: 2074 7279 3a0a 2020 2020 2020 2020 2020 try:. \n+000091e0: 2020 6f73 2e6b 696c 6c28 7365 6c66 2e5f os.kill(self._\n+000091f0: 7072 6f63 6573 732e 7069 642c 2073 6967 process.pid, sig\n+00009200: 290a 2020 2020 2020 2020 2020 2020 6c6f ). lo\n+00009210: 6767 6572 2e64 6562 7567 2827 7365 6e74 gger.debug('sent\n+00009220: 2025 7320 746f 2070 726f 6365 7373 2025 %s to process %\n+00009230: 6927 2c20 7369 672c 2073 656c 662e 5f70 i', sig, self._p\n+00009240: 726f 6365 7373 2e70 6964 290a 2020 2020 rocess.pid). \n+00009250: 2020 2020 6578 6365 7074 2050 726f 6365 except Proce\n+00009260: 7373 4c6f 6f6b 7570 4572 726f 723a 0a20 ssLookupError:. \n+00009270: 2020 2020 2020 2020 2020 2023 2061 6c72 # alr\n+00009280: 6561 6479 2067 6f6e 653f 2066 696e 650a eady gone? fine.\n+00009290: 2020 2020 2020 2020 2020 2020 6c6f 6767 logg\n+000092a0: 6572 2e64 6562 7567 2822 6361 6e27 7420 er.debug(\"can't \n+000092b0: 7365 6e64 2025 7320 746f 2070 726f 6365 send %s to proce\n+000092c0: 7373 2025 692e 2020 4974 2773 2065 7869 ss %i. It's exi\n+000092d0: 7465 6420 6a75 7374 206e 6f77 2e22 2c20 ted just now.\", \n+000092e0: 7369 672c 2073 656c 662e 5f70 726f 6365 sig, self._proce\n+000092f0: 7373 2e70 6964 290a 0a20 2020 2064 6566 ss.pid).. def\n+00009300: 2074 6572 6d69 6e61 7465 2873 656c 6629 terminate(self)\n+00009310: 202d 3e20 4e6f 6e65 3a0a 2020 2020 2020 -> None:. \n+00009320: 2020 7365 6c66 2e73 656e 645f 7369 676e self.send_sign\n+00009330: 616c 2873 6967 6e61 6c2e 5349 4754 4552 al(signal.SIGTER\n+00009340: 4d29 0a0a 2020 2020 6465 6620 6b69 6c6c M).. def kill\n+00009350: 2873 656c 6629 202d 3e20 4e6f 6e65 3a0a (self) -> None:.\n+00009360: 2020 2020 2020 2020 7365 6c66 2e73 656e self.sen\n+00009370: 645f 7369 676e 616c 2873 6967 6e61 6c2e d_signal(signal.\n+00009380: 5349 474b 494c 4c29 0a0a 2020 2020 6465 SIGKILL).. de\n+00009390: 6620 5f63 6c6f 7365 2873 656c 6629 202d f _close(self) -\n+000093a0: 3e20 4e6f 6e65 3a0a 2020 2020 2020 2020 > None:. \n+000093b0: 6966 2073 656c 662e 5f70 7479 5f66 6420 if self._pty_fd \n+000093c0: 6973 206e 6f74 204e 6f6e 653a 0a20 2020 is not None:. \n+000093d0: 2020 2020 2020 2020 206f 732e 636c 6f73 os.clos\n+000093e0: 6528 7365 6c66 2e5f 7074 795f 6664 290a e(self._pty_fd).\n+000093f0: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n+00009400: 2e5f 7074 795f 6664 203d 204e 6f6e 650a ._pty_fd = None.\n+00009410: 0a20 2020 2020 2020 2069 6620 7365 6c66 . if self\n+00009420: 2e5f 7072 6f63 6573 7320 6973 206e 6f74 ._process is not\n+00009430: 204e 6f6e 653a 0a20 2020 2020 2020 2020 None:. \n+00009440: 2020 2069 6620 7365 6c66 2e5f 7072 6f63 if self._proc\n+00009450: 6573 732e 7374 6469 6e20 6973 206e 6f74 ess.stdin is not\n+00009460: 204e 6f6e 653a 0a20 2020 2020 2020 2020 None:. \n+00009470: 2020 2020 2020 2073 656c 662e 5f70 726f self._pro\n+00009480: 6365 7373 2e73 7464 696e 2e63 6c6f 7365 cess.stdin.close\n+00009490: 2829 0a20 2020 2020 2020 2020 2020 2020 (). \n+000094a0: 2020 2073 656c 662e 5f70 726f 6365 7373 self._process\n+000094b0: 2e73 7464 696e 203d 204e 6f6e 650a 2020 .stdin = None. \n+000094c0: 2020 2020 2020 2020 2020 7472 793a 0a20 try:. \n+000094d0: 2020 2020 2020 2020 2020 2020 2020 2073 s\n+000094e0: 656c 662e 7465 726d 696e 6174 6528 2920 elf.terminate() \n+000094f0: 2023 2062 6573 7420 6566 666f 7274 2e2e # best effort..\n+00009500: 2e0a 2020 2020 2020 2020 2020 2020 6578 .. ex\n+00009510: 6365 7074 2050 6572 6d69 7373 696f 6e45 cept PermissionE\n+00009520: 7272 6f72 3a0a 2020 2020 2020 2020 2020 rror:. \n+00009530: 2020 2020 2020 6c6f 6767 6572 2e64 6562 logger.deb\n+00009540: 7567 2822 6361 6e27 7420 6b69 6c6c 2025 ug(\"can't kill %\n+00009550: 6920 6475 6520 746f 2045 5045 524d 222c i due to EPERM\",\n+00009560: 2073 656c 662e 5f70 726f 6365 7373 2e70 self._process.p\n+00009570: 6964 290a 0a0a 636c 6173 7320 5374 6469 id)...class Stdi\n+00009580: 6f54 7261 6e73 706f 7274 285f 5472 616e oTransport(_Tran\n+00009590: 7370 6f72 7429 3a0a 2020 2020 2222 2241 sport):. \"\"\"A\n+000095a0: 2062 692d 6469 7265 6374 696f 6e61 6c20 bi-directional \n+000095b0: 7472 616e 7370 6f72 7420 7468 6174 2063 transport that c\n+000095c0: 6f72 7265 7370 6f6e 6473 2074 6f20 7374 orresponds to st\n+000095d0: 6469 6e2f 6f75 742e 0a0a 2020 2020 4361 din/out... Ca\n+000095e0: 6e20 7461 6c6b 2074 6f20 6a75 7374 2061 n talk to just a\n+000095f0: 626f 7574 2061 6e79 7468 696e 673a 0a20 bout anything:. \n+00009600: 2020 2020 2020 202d 2066 696c 6573 0a20 - files. \n+00009610: 2020 2020 2020 202d 2070 6970 6573 0a20 - pipes. \n+00009620: 2020 2020 2020 202d 2063 6861 7261 6374 - charact\n+00009630: 6572 2064 6576 6963 6573 2028 696e 636c er devices (incl\n+00009640: 7564 696e 6720 7465 726d 696e 616c 7329 uding terminals)\n+00009650: 0a20 2020 2020 2020 202d 2073 6f63 6b65 . - socke\n+00009660: 7473 0a20 2020 2022 2222 0a0a 2020 2020 ts. \"\"\".. \n+00009670: 6465 6620 5f5f 696e 6974 5f5f 2873 656c def __init__(sel\n+00009680: 662c 206c 6f6f 703a 2061 7379 6e63 696f f, loop: asyncio\n+00009690: 2e41 6273 7472 6163 7445 7665 6e74 4c6f .AbstractEventLo\n+000096a0: 6f70 2c20 7072 6f74 6f63 6f6c 3a20 6173 op, protocol: as\n+000096b0: 796e 6369 6f2e 5072 6f74 6f63 6f6c 2c20 yncio.Protocol, \n+000096c0: 7374 6469 6e3a 2069 6e74 203d 2030 2c20 stdin: int = 0, \n+000096d0: 7374 646f 7574 3a20 696e 7420 3d20 3129 stdout: int = 1)\n+000096e0: 3a0a 2020 2020 2020 2020 7375 7065 7228 :. super(\n+000096f0: 292e 5f5f 696e 6974 5f5f 286c 6f6f 702c ).__init__(loop,\n+00009700: 2070 726f 746f 636f 6c2c 2073 7464 696e protocol, stdin\n+00009710: 2c20 7374 646f 7574 290a 0a20 2020 2064 , stdout).. d\n+00009720: 6566 2063 616e 5f77 7269 7465 5f65 6f66 ef can_write_eof\n+00009730: 2873 656c 6629 202d 3e20 626f 6f6c 3a0a (self) -> bool:.\n+00009740: 2020 2020 2020 2020 7265 7475 726e 2046 return F\n+00009750: 616c 7365 0a0a 2020 2020 6465 6620 5f77 alse.. def _w\n+00009760: 7269 7465 5f65 6f66 5f6e 6f77 2873 656c rite_eof_now(sel\n+00009770: 6629 202d 3e20 4e6f 6e65 3a0a 2020 2020 f) -> None:. \n+00009780: 2020 2020 7261 6973 6520 5275 6e74 696d raise Runtim\n+00009790: 6545 7272 6f72 2822 4361 6e27 7420 7772 eError(\"Can't wr\n+000097a0: 6974 6520 454f 4620 746f 2073 7464 6f75 ite EOF to stdou\n+000097b0: 7422 290a 0a0a 636c 6173 7320 5370 6f6f t\")...class Spoo\n+000097c0: 6c65 723a 0a20 2020 2022 2222 436f 6e73 ler:. \"\"\"Cons\n+000097d0: 756d 6573 2064 6174 6120 6672 6f6d 2061 umes data from a\n+000097e0: 6e20 6664 2c20 7374 6f72 696e 6720 6974 n fd, storing it\n+000097f0: 2069 6e20 6120 6275 6666 6572 2e0a 0a20 in a buffer... \n+00009800: 2020 2054 6869 7320 6d61 6b65 7320 6120 This makes a \n+00009810: 636f 7079 206f 6620 7468 6520 6664 2c20 copy of the fd, \n+00009820: 736f 2079 6f75 2064 6f6e 2774 2068 6176 so you don't hav\n+00009830: 6520 746f 2077 6f72 7279 2061 626f 7574 e to worry about\n+00009840: 2068 6f6c 6469 6e67 2069 740a 2020 2020 holding it. \n+00009850: 6f70 656e 2e0a 2020 2020 2222 220a 0a20 open.. \"\"\".. \n+00009860: 2020 205f 6c6f 6f70 3a20 6173 796e 6369 _loop: asynci\n+00009870: 6f2e 4162 7374 7261 6374 4576 656e 744c o.AbstractEventL\n+00009880: 6f6f 700a 2020 2020 5f66 643a 2069 6e74 oop. _fd: int\n+00009890: 0a20 2020 205f 636f 6e74 656e 7473 3a20 . _contents: \n+000098a0: 276c 6973 745b 6279 7465 735d 270a 0a20 'list[bytes]'.. \n+000098b0: 2020 2064 6566 205f 5f69 6e69 745f 5f28 def __init__(\n+000098c0: 7365 6c66 2c20 6c6f 6f70 3a20 6173 796e self, loop: asyn\n+000098d0: 6369 6f2e 4162 7374 7261 6374 4576 656e cio.AbstractEven\n+000098e0: 744c 6f6f 702c 2066 643a 2069 6e74 293a tLoop, fd: int):\n+000098f0: 0a20 2020 2020 2020 2073 656c 662e 5f6c . self._l\n+00009900: 6f6f 7020 3d20 6c6f 6f70 0a20 2020 2020 oop = loop. \n+00009910: 2020 2073 656c 662e 5f66 6420 3d20 2d31 self._fd = -1\n+00009920: 2020 2320 696e 2063 6173 6520 6475 7028 # in case dup(\n+00009930: 2920 7261 6973 6573 2061 6e20 6578 6365 ) raises an exce\n+00009940: 7074 696f 6e0a 2020 2020 2020 2020 7365 ption. se\n+00009950: 6c66 2e5f 636f 6e74 656e 7473 203d 205b lf._contents = [\n+00009960: 5d0a 0a20 2020 2020 2020 2073 656c 662e ].. self.\n+00009970: 5f66 6420 3d20 6f73 2e64 7570 2866 6429 _fd = os.dup(fd)\n+00009980: 0a0a 2020 2020 2020 2020 6f73 2e73 6574 .. os.set\n+00009990: 5f62 6c6f 636b 696e 6728 7365 6c66 2e5f _blocking(self._\n+000099a0: 6664 2c20 4661 6c73 6529 0a20 2020 2020 fd, False). \n+000099b0: 2020 206c 6f6f 702e 6164 645f 7265 6164 loop.add_read\n+000099c0: 6572 2873 656c 662e 5f66 642c 2073 656c er(self._fd, sel\n+000099d0: 662e 5f72 6561 645f 7265 6164 7929 0a0a f._read_ready)..\n+000099e0: 2020 2020 6465 6620 5f72 6561 645f 7265 def _read_re\n+000099f0: 6164 7928 7365 6c66 2920 2d3e 204e 6f6e ady(self) -> Non\n+00009a00: 653a 0a20 2020 2020 2020 2074 7279 3a0a e:. try:.\n+00009a10: 2020 2020 2020 2020 2020 2020 6461 7461 data\n+00009a20: 203d 206f 732e 7265 6164 2873 656c 662e = os.read(self.\n+00009a30: 5f66 642c 2038 3139 3229 0a20 2020 2020 _fd, 8192). \n+00009a40: 2020 2065 7863 6570 7420 426c 6f63 6b69 except Blocki\n+00009a50: 6e67 494f 4572 726f 723a 2020 2320 7072 ngIOError: # pr\n+00009a60: 6167 6d61 3a20 6e6f 2063 6f76 6572 0a20 agma: no cover. \n+00009a70: 2020 2020 2020 2020 2020 2072 6574 7572 retur\n+00009a80: 6e0a 2020 2020 2020 2020 6578 6365 7074 n. except\n+00009a90: 204f 5345 7272 6f72 3a0a 2020 2020 2020 OSError:. \n+00009aa0: 2020 2020 2020 2320 616c 6c20 6f74 6865 # all othe\n+00009ab0: 7220 6572 726f 7273 202d 3e20 454f 460a r errors -> EOF.\n+00009ac0: 2020 2020 2020 2020 2020 2020 6461 7461 data\n+00009ad0: 203d 2062 2727 0a0a 2020 2020 2020 2020 = b''.. \n+00009ae0: 6966 2064 6174 6120 213d 2062 2727 3a0a if data != b'':.\n+00009af0: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n+00009b00: 2e5f 636f 6e74 656e 7473 2e61 7070 656e ._contents.appen\n+00009b10: 6428 6461 7461 290a 2020 2020 2020 2020 d(data). \n+00009b20: 656c 7365 3a0a 2020 2020 2020 2020 2020 else:. \n+00009b30: 2020 7365 6c66 2e63 6c6f 7365 2829 0a0a self.close()..\n+00009b40: 2020 2020 6465 6620 5f69 735f 7265 6164 def _is_read\n+00009b50: 7928 7365 6c66 2920 2d3e 2062 6f6f 6c3a y(self) -> bool:\n+00009b60: 0a20 2020 2020 2020 2069 6620 7365 6c66 . if self\n+00009b70: 2e5f 6664 203d 3d20 2d31 3a0a 2020 2020 ._fd == -1:. \n+00009b80: 2020 2020 2020 2020 7265 7475 726e 2046 return F\n+00009b90: 616c 7365 0a20 2020 2020 2020 2072 6574 alse. ret\n+00009ba0: 7572 6e20 7365 6c65 6374 2e73 656c 6563 urn select.selec\n+00009bb0: 7428 5b73 656c 662e 5f66 645d 2c20 5b5d t([self._fd], []\n+00009bc0: 2c20 5b5d 2c20 3029 2021 3d20 285b 5d2c , [], 0) != ([],\n+00009bd0: 205b 5d2c 205b 5d29 0a0a 2020 2020 6465 [], []).. de\n+00009be0: 6620 6765 7428 7365 6c66 2c20 2a2c 2072 f get(self, *, r\n+00009bf0: 6573 6574 3a20 626f 6f6c 203d 2046 616c eset: bool = Fal\n+00009c00: 7365 2920 2d3e 2062 7974 6573 3a0a 2020 se) -> bytes:. \n+00009c10: 2020 2020 2020 7768 696c 6520 7365 6c66 while self\n+00009c20: 2e5f 6973 5f72 6561 6479 2829 3a0a 2020 ._is_ready():. \n+00009c30: 2020 2020 2020 2020 2020 7365 6c66 2e5f self._\n+00009c40: 7265 6164 5f72 6561 6479 2829 0a0a 2020 read_ready().. \n+00009c50: 2020 2020 2020 7265 7375 6c74 203d 2062 result = b\n+00009c60: 2727 2e6a 6f69 6e28 7365 6c66 2e5f 636f ''.join(self._co\n+00009c70: 6e74 656e 7473 290a 2020 2020 2020 2020 ntents). \n+00009c80: 6966 2072 6573 6574 3a0a 2020 2020 2020 if reset:. \n+00009c90: 2020 2020 2020 7365 6c66 2e5f 636f 6e74 self._cont\n+00009ca0: 656e 7473 203d 205b 5d0a 2020 2020 2020 ents = []. \n+00009cb0: 2020 7265 7475 726e 2072 6573 756c 740a return result.\n+00009cc0: 0a20 2020 2064 6566 2063 6c6f 7365 2873 . def close(s\n+00009cd0: 656c 6629 202d 3e20 4e6f 6e65 3a0a 2020 elf) -> None:. \n+00009ce0: 2020 2020 2020 6966 2073 656c 662e 5f66 if self._f\n+00009cf0: 6420 213d 202d 313a 0a20 2020 2020 2020 d != -1:. \n+00009d00: 2020 2020 2073 656c 662e 5f6c 6f6f 702e self._loop.\n+00009d10: 7265 6d6f 7665 5f72 6561 6465 7228 7365 remove_reader(se\n+00009d20: 6c66 2e5f 6664 290a 2020 2020 2020 2020 lf._fd). \n+00009d30: 2020 2020 6f73 2e63 6c6f 7365 2873 656c os.close(sel\n+00009d40: 662e 5f66 6429 0a20 2020 2020 2020 2020 f._fd). \n+00009d50: 2020 2073 656c 662e 5f66 6420 3d20 2d31 self._fd = -1\n+00009d60: 0a0a 2020 2020 6465 6620 5f5f 6465 6c5f .. def __del_\n+00009d70: 5f28 7365 6c66 2920 2d3e 204e 6f6e 653a _(self) -> None:\n+00009d80: 0a20 2020 2020 2020 2073 656c 662e 636c . self.cl\n+00009d90: 6f73 6528 290a 2727 272c 0a20 2027 636f ose().''',. 'co\n+00009da0: 636b 7069 742f 726f 7574 6572 2e70 7927 ckpit/router.py'\n+00009db0: 3a20 6272 2727 2723 2054 6869 7320 6669 : br'''# This fi\n+00009dc0: 6c65 2069 7320 7061 7274 206f 6620 436f le is part of Co\n+00009dd0: 636b 7069 742e 0a23 0a23 2043 6f70 7972 ckpit..#.# Copyr\n+00009de0: 6967 6874 2028 4329 2032 3032 3220 5265 ight (C) 2022 Re\n+00009df0: 6420 4861 742c 2049 6e63 2e0a 230a 2320 d Hat, Inc..#.# \n+00009e00: 5468 6973 2070 726f 6772 616d 2069 7320 This program is \n+00009e10: 6672 6565 2073 6f66 7477 6172 653a 2079 free software: y\n+00009e20: 6f75 2063 616e 2072 6564 6973 7472 6962 ou can redistrib\n+00009e30: 7574 6520 6974 2061 6e64 2f6f 7220 6d6f ute it and/or mo\n+00009e40: 6469 6679 0a23 2069 7420 756e 6465 7220 dify.# it under \n+00009e50: 7468 6520 7465 726d 7320 6f66 2074 6865 the terms of the\n+00009e60: 2047 4e55 2047 656e 6572 616c 2050 7562 GNU General Pub\n+00009e70: 6c69 6320 4c69 6365 6e73 6520 6173 2070 lic License as p\n+00009e80: 7562 6c69 7368 6564 2062 790a 2320 7468 ublished by.# th\n+00009e90: 6520 4672 6565 2053 6f66 7477 6172 6520 e Free Software \n+00009ea0: 466f 756e 6461 7469 6f6e 2c20 6569 7468 Foundation, eith\n+00009eb0: 6572 2076 6572 7369 6f6e 2033 206f 6620 er version 3 of \n+00009ec0: 7468 6520 4c69 6365 6e73 652c 206f 720a the License, or.\n+00009ed0: 2320 2861 7420 796f 7572 206f 7074 696f # (at your optio\n+00009ee0: 6e29 2061 6e79 206c 6174 6572 2076 6572 n) any later ver\n+00009ef0: 7369 6f6e 2e0a 230a 2320 5468 6973 2070 sion..#.# This p\n+00009f00: 726f 6772 616d 2069 7320 6469 7374 7269 rogram is distri\n+00009f10: 6275 7465 6420 696e 2074 6865 2068 6f70 buted in the hop\n+00009f20: 6520 7468 6174 2069 7420 7769 6c6c 2062 e that it will b\n+00009f30: 6520 7573 6566 756c 2c0a 2320 6275 7420 e useful,.# but \n+00009f40: 5749 5448 4f55 5420 414e 5920 5741 5252 WITHOUT ANY WARR\n+00009f50: 414e 5459 3b20 7769 7468 6f75 7420 6576 ANTY; without ev\n+00009f60: 656e 2074 6865 2069 6d70 6c69 6564 2077 en the implied w\n+00009f70: 6172 7261 6e74 7920 6f66 0a23 204d 4552 arranty of.# MER\n+00009f80: 4348 414e 5441 4249 4c49 5459 206f 7220 CHANTABILITY or \n+00009f90: 4649 544e 4553 5320 464f 5220 4120 5041 FITNESS FOR A PA\n+00009fa0: 5254 4943 554c 4152 2050 5552 504f 5345 RTICULAR PURPOSE\n+00009fb0: 2e20 2053 6565 2074 6865 0a23 2047 4e55 . See the.# GNU\n+00009fc0: 2047 656e 6572 616c 2050 7562 6c69 6320 General Public \n+00009fd0: 4c69 6365 6e73 6520 666f 7220 6d6f 7265 License for more\n+00009fe0: 2064 6574 6169 6c73 2e0a 230a 2320 596f details..#.# Yo\n+00009ff0: 7520 7368 6f75 6c64 2068 6176 6520 7265 u should have re\n+0000a000: 6365 6976 6564 2061 2063 6f70 7920 6f66 ceived a copy of\n+0000a010: 2074 6865 2047 4e55 2047 656e 6572 616c the GNU General\n+0000a020: 2050 7562 6c69 6320 4c69 6365 6e73 650a Public License.\n+0000a030: 2320 616c 6f6e 6720 7769 7468 2074 6869 # along with thi\n+0000a040: 7320 7072 6f67 7261 6d2e 2020 4966 206e s program. If n\n+0000a050: 6f74 2c20 7365 6520 3c68 7474 7073 3a2f ot, see ...import\n+0000a080: 2061 7379 6e63 696f 0a69 6d70 6f72 7420 asyncio.import \n+0000a090: 636f 6c6c 6563 7469 6f6e 730a 696d 706f collections.impo\n+0000a0a0: 7274 206c 6f67 6769 6e67 0a66 726f 6d20 rt logging.from \n+0000a0b0: 7479 7069 6e67 2069 6d70 6f72 7420 4469 typing import Di\n+0000a0c0: 6374 2c20 4c69 7374 2c20 4f70 7469 6f6e ct, List, Option\n+0000a0d0: 616c 0a0a 6672 6f6d 202e 6a73 6f6e 7574 al..from .jsonut\n+0000a0e0: 696c 2069 6d70 6f72 7420 4a73 6f6e 4f62 il import JsonOb\n+0000a0f0: 6a65 6374 2c20 4a73 6f6e 5661 6c75 650a ject, JsonValue.\n+0000a100: 6672 6f6d 202e 7072 6f74 6f63 6f6c 2069 from .protocol i\n+0000a110: 6d70 6f72 7420 436f 636b 7069 7450 726f mport CockpitPro\n+0000a120: 626c 656d 2c20 436f 636b 7069 7450 726f blem, CockpitPro\n+0000a130: 746f 636f 6c45 7272 6f72 2c20 436f 636b tocolError, Cock\n+0000a140: 7069 7450 726f 746f 636f 6c53 6572 7665 pitProtocolServe\n+0000a150: 720a 0a6c 6f67 6765 7220 3d20 6c6f 6767 r..logger = logg\n+0000a160: 696e 672e 6765 744c 6f67 6765 7228 5f5f ing.getLogger(__\n+0000a170: 6e61 6d65 5f5f 290a 0a0a 636c 6173 7320 name__)...class \n+0000a180: 4578 6563 7574 696f 6e51 7565 7565 3a0a ExecutionQueue:.\n+0000a190: 2020 2020 2222 2254 656d 706f 7261 7269 \"\"\"Temporari\n+0000a1a0: 6c79 2064 656c 6179 2063 616c 6c73 2074 ly delay calls t\n+0000a1b0: 6f20 6120 6769 7665 6e20 7365 7420 6f66 o a given set of\n+0000a1c0: 2063 6c61 7373 206d 6574 686f 6473 2e0a class methods..\n+0000a1d0: 0a20 2020 2046 756e 6374 696f 6e73 2062 . Functions b\n+0000a1e0: 7920 7265 706c 6163 696e 6720 7468 6520 y replacing the \n+0000a1f0: 6e61 6d65 6420 6675 6e63 7469 6f6e 2061 named function a\n+0000a200: 7420 7468 6520 696e 7374 616e 6365 205f t the instance _\n+0000a210: 5f64 6963 745f 5f0a 2020 2020 6c65 7665 _dict__. leve\n+0000a220: 6c2c 2065 6666 6563 7469 7665 6c79 2070 l, effectively p\n+0000a230: 726f 7669 6469 6e67 2061 6e20 6f76 6572 roviding an over\n+0000a240: 7269 6465 2066 6f72 2065 7861 6374 6c79 ride for exactly\n+0000a250: 206f 6e65 2069 6e73 7461 6e63 650a 2020 one instance. \n+0000a260: 2020 6f66 2060 6d65 7468 6f64 6027 7320 of `method`'s \n+0000a270: 6f62 6a65 6374 2e0a 2020 2020 5175 6575 object.. Queu\n+0000a280: 6573 2074 6865 2069 6e76 6f63 6174 696f es the invocatio\n+0000a290: 6e73 2e20 2052 756e 2074 6865 6d20 6c61 ns. Run them la\n+0000a2a0: 7465 7220 7769 7468 202e 7275 6e28 292c ter with .run(),\n+0000a2b0: 2077 6869 6368 2061 6c73 6f20 7265 7665 which also reve\n+0000a2c0: 7273 6573 0a20 2020 2074 6865 2072 6564 rses. the red\n+0000a2d0: 6972 6563 7469 6f6e 2062 7920 6465 6c65 irection by dele\n+0000a2e0: 7469 6e67 2074 6865 206e 616d 6564 206d ting the named m\n+0000a2f0: 6574 686f 6473 2066 726f 6d20 7468 6520 ethods from the \n+0000a300: 696e 7374 616e 6365 2e0a 2020 2020 2222 instance.. \"\"\n+0000a310: 220a 2020 2020 6465 6620 5f5f 696e 6974 \". def __init\n+0000a320: 5f5f 2873 656c 662c 206d 6574 686f 6473 __(self, methods\n+0000a330: 293a 0a20 2020 2020 2020 2073 656c 662e ):. self.\n+0000a340: 7175 6575 6520 3d20 636f 6c6c 6563 7469 queue = collecti\n+0000a350: 6f6e 732e 6465 7175 6528 290a 2020 2020 ons.deque(). \n+0000a360: 2020 2020 7365 6c66 2e6d 6574 686f 6473 self.methods\n+0000a370: 203d 206d 6574 686f 6473 0a0a 2020 2020 = methods.. \n+0000a380: 2020 2020 666f 7220 6d65 7468 6f64 2069 for method i\n+0000a390: 6e20 7365 6c66 2e6d 6574 686f 6473 3a0a n self.methods:.\n+0000a3a0: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n+0000a3b0: 2e5f 7772 6170 286d 6574 686f 6429 0a0a ._wrap(method)..\n+0000a3c0: 2020 2020 6465 6620 5f77 7261 7028 7365 def _wrap(se\n+0000a3d0: 6c66 2c20 6d65 7468 6f64 293a 0a20 2020 lf, method):. \n+0000a3e0: 2020 2020 2023 204e 423a 2074 6869 7320 # NB: this \n+0000a3f0: 6675 6e63 7469 6f6e 2069 7320 7374 6f72 function is stor\n+0000a400: 6564 2069 6e20 7468 6520 696e 7374 616e ed in the instan\n+0000a410: 6365 2064 6963 7420 616e 6420 7468 6572 ce dict and ther\n+0000a420: 6566 6f72 650a 2020 2020 2020 2020 2320 efore. # \n+0000a430: 646f 6573 6e27 7420 6675 6e63 7469 6f6e doesn't function\n+0000a440: 2061 7320 6120 6465 7363 7269 7074 6f72 as a descriptor\n+0000a450: 2c20 6973 6e27 7420 6120 6d65 7468 6f64 , isn't a method\n+0000a460: 2c20 646f 6573 6e27 7420 6765 7420 626f , doesn't get bo\n+0000a470: 756e 642c 0a20 2020 2020 2020 2023 2061 und,. # a\n+0000a480: 6e64 2074 6865 7265 666f 7265 2064 6f65 nd therefore doe\n+0000a490: 736e 2774 2072 6563 6569 7665 2061 2073 sn't receive a s\n+0000a4a0: 656c 6620 7061 7261 6d65 7465 720a 2020 elf parameter. \n+0000a4b0: 2020 2020 2020 7365 7461 7474 7228 6d65 setattr(me\n+0000a4c0: 7468 6f64 2e5f 5f73 656c 665f 5f2c 206d thod.__self__, m\n+0000a4d0: 6574 686f 642e 5f5f 6675 6e63 5f5f 2e5f ethod.__func__._\n+0000a4e0: 5f6e 616d 655f 5f2c 206c 616d 6264 6120 _name__, lambda \n+0000a4f0: 2a61 7267 733a 2073 656c 662e 7175 6575 *args: self.queu\n+0000a500: 652e 6170 7065 6e64 2828 6d65 7468 6f64 e.append((method\n+0000a510: 2c20 6172 6773 2929 290a 0a20 2020 2064 , args))).. d\n+0000a520: 6566 2072 756e 2873 656c 6629 3a0a 2020 ef run(self):. \n+0000a530: 2020 2020 2020 6c6f 6767 6572 2e64 6562 logger.deb\n+0000a540: 7567 2827 4578 6563 7574 696f 6e51 7565 ug('ExecutionQue\n+0000a550: 7565 3a20 5275 6e6e 696e 6720 2564 2071 ue: Running %d q\n+0000a560: 7565 7565 6420 6d65 7468 6f64 2063 616c ueued method cal\n+0000a570: 6c73 272c 206c 656e 2873 656c 662e 7175 ls', len(self.qu\n+0000a580: 6575 6529 290a 2020 2020 2020 2020 666f eue)). fo\n+0000a590: 7220 6d65 7468 6f64 2c20 6172 6773 2069 r method, args i\n+0000a5a0: 6e20 7365 6c66 2e71 7565 7565 3a0a 2020 n self.queue:. \n+0000a5b0: 2020 2020 2020 2020 2020 6d65 7468 6f64 method\n+0000a5c0: 282a 6172 6773 290a 0a20 2020 2020 2020 (*args).. \n+0000a5d0: 2066 6f72 206d 6574 686f 6420 696e 2073 for method in s\n+0000a5e0: 656c 662e 6d65 7468 6f64 733a 0a20 2020 elf.methods:. \n+0000a5f0: 2020 2020 2020 2020 2064 656c 6174 7472 delattr\n+0000a600: 286d 6574 686f 642e 5f5f 7365 6c66 5f5f (method.__self__\n+0000a610: 2c20 6d65 7468 6f64 2e5f 5f66 756e 635f , method.__func_\n+0000a620: 5f2e 5f5f 6e61 6d65 5f5f 290a 0a0a 636c _.__name__)...cl\n+0000a630: 6173 7320 456e 6470 6f69 6e74 3a0a 2020 ass Endpoint:. \n+0000a640: 2020 726f 7574 6572 3a20 2752 6f75 7465 router: 'Route\n+0000a650: 7227 0a20 2020 205f 5f65 6e64 706f 696e r'. __endpoin\n+0000a660: 745f 6672 6f7a 656e 5f71 7565 7565 3a20 t_frozen_queue: \n+0000a670: 4f70 7469 6f6e 616c 5b45 7865 6375 7469 Optional[Executi\n+0000a680: 6f6e 5175 6575 655d 203d 204e 6f6e 650a onQueue] = None.\n+0000a690: 0a20 2020 2064 6566 205f 5f69 6e69 745f . def __init_\n+0000a6a0: 5f28 7365 6c66 2c20 726f 7574 6572 3a20 _(self, router: \n+0000a6b0: 2752 6f75 7465 7227 293a 0a20 2020 2020 'Router'):. \n+0000a6c0: 2020 2072 6f75 7465 722e 6164 645f 656e router.add_en\n+0000a6d0: 6470 6f69 6e74 2873 656c 6629 0a20 2020 dpoint(self). \n+0000a6e0: 2020 2020 2073 656c 662e 726f 7574 6572 self.router\n+0000a6f0: 203d 2072 6f75 7465 720a 0a20 2020 2064 = router.. d\n+0000a700: 6566 2066 7265 657a 655f 656e 6470 6f69 ef freeze_endpoi\n+0000a710: 6e74 2873 656c 6629 3a0a 2020 2020 2020 nt(self):. \n+0000a720: 2020 6173 7365 7274 2073 656c 662e 5f5f assert self.__\n+0000a730: 656e 6470 6f69 6e74 5f66 726f 7a65 6e5f endpoint_frozen_\n+0000a740: 7175 6575 6520 6973 204e 6f6e 650a 2020 queue is None. \n+0000a750: 2020 2020 2020 6c6f 6767 6572 2e64 6562 logger.deb\n+0000a760: 7567 2827 4672 6565 7a69 6e67 2065 6e64 ug('Freezing end\n+0000a770: 706f 696e 7420 2573 272c 2073 656c 6629 point %s', self)\n+0000a780: 0a20 2020 2020 2020 2073 656c 662e 5f5f . self.__\n+0000a790: 656e 6470 6f69 6e74 5f66 726f 7a65 6e5f endpoint_frozen_\n+0000a7a0: 7175 6575 6520 3d20 4578 6563 7574 696f queue = Executio\n+0000a7b0: 6e51 7565 7565 287b 7365 6c66 2e64 6f5f nQueue({self.do_\n+0000a7c0: 6368 616e 6e65 6c5f 636f 6e74 726f 6c2c channel_control,\n+0000a7d0: 2073 656c 662e 646f 5f63 6861 6e6e 656c self.do_channel\n+0000a7e0: 5f64 6174 612c 2073 656c 662e 646f 5f6b _data, self.do_k\n+0000a7f0: 696c 6c7d 290a 0a20 2020 2064 6566 2074 ill}).. def t\n+0000a800: 6861 775f 656e 6470 6f69 6e74 2873 656c haw_endpoint(sel\n+0000a810: 6629 3a0a 2020 2020 2020 2020 6173 7365 f):. asse\n+0000a820: 7274 2073 656c 662e 5f5f 656e 6470 6f69 rt self.__endpoi\n+0000a830: 6e74 5f66 726f 7a65 6e5f 7175 6575 6520 nt_frozen_queue \n+0000a840: 6973 206e 6f74 204e 6f6e 650a 2020 2020 is not None. \n+0000a850: 2020 2020 6c6f 6767 6572 2e64 6562 7567 logger.debug\n+0000a860: 2827 5468 6177 696e 6720 656e 6470 6f69 ('Thawing endpoi\n+0000a870: 6e74 2025 7327 2c20 7365 6c66 290a 2020 nt %s', self). \n+0000a880: 2020 2020 2020 7365 6c66 2e5f 5f65 6e64 self.__end\n+0000a890: 706f 696e 745f 6672 6f7a 656e 5f71 7565 point_frozen_que\n+0000a8a0: 7565 2e72 756e 2829 0a20 2020 2020 2020 ue.run(). \n+0000a8b0: 2073 656c 662e 5f5f 656e 6470 6f69 6e74 self.__endpoint\n+0000a8c0: 5f66 726f 7a65 6e5f 7175 6575 6520 3d20 _frozen_queue = \n+0000a8d0: 4e6f 6e65 0a0a 2020 2020 2320 696e 7465 None.. # inte\n+0000a8e0: 7266 6163 6520 666f 7220 7265 6365 6976 rface for receiv\n+0000a8f0: 696e 6720 6d65 7373 6167 6573 0a20 2020 ing messages. \n+0000a900: 2064 6566 2064 6f5f 636c 6f73 6528 7365 def do_close(se\n+0000a910: 6c66 293a 0a20 2020 2020 2020 2072 6169 lf):. rai\n+0000a920: 7365 204e 6f74 496d 706c 656d 656e 7465 se NotImplemente\n+0000a930: 6445 7272 6f72 0a0a 2020 2020 6465 6620 dError.. def \n+0000a940: 646f 5f63 6861 6e6e 656c 5f63 6f6e 7472 do_channel_contr\n+0000a950: 6f6c 2873 656c 662c 2063 6861 6e6e 656c ol(self, channel\n+0000a960: 3a20 7374 722c 2063 6f6d 6d61 6e64 3a20 : str, command: \n+0000a970: 7374 722c 206d 6573 7361 6765 3a20 4a73 str, message: Js\n+0000a980: 6f6e 4f62 6a65 6374 2920 2d3e 204e 6f6e onObject) -> Non\n+0000a990: 653a 0a20 2020 2020 2020 2072 6169 7365 e:. raise\n+0000a9a0: 204e 6f74 496d 706c 656d 656e 7465 6445 NotImplementedE\n+0000a9b0: 7272 6f72 0a0a 2020 2020 6465 6620 646f rror.. def do\n+0000a9c0: 5f63 6861 6e6e 656c 5f64 6174 6128 7365 _channel_data(se\n+0000a9d0: 6c66 2c20 6368 616e 6e65 6c3a 2073 7472 lf, channel: str\n+0000a9e0: 2c20 6461 7461 3a20 6279 7465 7329 202d , data: bytes) -\n+0000a9f0: 3e20 4e6f 6e65 3a0a 2020 2020 2020 2020 > None:. \n+0000aa00: 7261 6973 6520 4e6f 7449 6d70 6c65 6d65 raise NotImpleme\n+0000aa10: 6e74 6564 4572 726f 720a 0a20 2020 2064 ntedError.. d\n+0000aa20: 6566 2064 6f5f 6b69 6c6c 2873 656c 662c ef do_kill(self,\n+0000aa30: 2068 6f73 743a 2027 7374 7220 7c20 4e6f host: 'str | No\n+0000aa40: 6e65 272c 2067 726f 7570 3a20 2773 7472 ne', group: 'str\n+0000aa50: 207c 204e 6f6e 6527 2c20 6d65 7373 6167 | None', messag\n+0000aa60: 653a 204a 736f 6e4f 626a 6563 7429 202d e: JsonObject) -\n+0000aa70: 3e20 4e6f 6e65 3a0a 2020 2020 2020 2020 > None:. \n+0000aa80: 7261 6973 6520 4e6f 7449 6d70 6c65 6d65 raise NotImpleme\n+0000aa90: 6e74 6564 4572 726f 720a 0a20 2020 2023 ntedError.. #\n+0000aaa0: 2069 6e74 6572 6661 6365 2066 6f72 2073 interface for s\n+0000aab0: 656e 6469 6e67 206d 6573 7361 6765 730a ending messages.\n+0000aac0: 2020 2020 6465 6620 7365 6e64 5f63 6861 def send_cha\n+0000aad0: 6e6e 656c 5f64 6174 6128 7365 6c66 2c20 nnel_data(self, \n+0000aae0: 6368 616e 6e65 6c3a 2073 7472 2c20 6461 channel: str, da\n+0000aaf0: 7461 3a20 6279 7465 7329 202d 3e20 4e6f ta: bytes) -> No\n+0000ab00: 6e65 3a0a 2020 2020 2020 2020 7365 6c66 ne:. self\n+0000ab10: 2e72 6f75 7465 722e 7772 6974 655f 6368 .router.write_ch\n+0000ab20: 616e 6e65 6c5f 6461 7461 2863 6861 6e6e annel_data(chann\n+0000ab30: 656c 2c20 6461 7461 290a 0a20 2020 2064 el, data).. d\n+0000ab40: 6566 2073 656e 645f 6368 616e 6e65 6c5f ef send_channel_\n+0000ab50: 636f 6e74 726f 6c28 0a20 2020 2020 2020 control(. \n+0000ab60: 2073 656c 662c 2063 6861 6e6e 656c 3a20 self, channel: \n+0000ab70: 7374 722c 2063 6f6d 6d61 6e64 3a20 7374 str, command: st\n+0000ab80: 722c 205f 6d73 673a 2027 4a73 6f6e 4f62 r, _msg: 'JsonOb\n+0000ab90: 6a65 6374 207c 204e 6f6e 6527 2c20 2a2a ject | None', **\n+0000aba0: 6b77 6172 6773 3a20 4a73 6f6e 5661 6c75 kwargs: JsonValu\n+0000abb0: 650a 2020 2020 2920 2d3e 204e 6f6e 653a e. ) -> None:\n+0000abc0: 0a20 2020 2020 2020 2073 656c 662e 726f . self.ro\n+0000abd0: 7574 6572 2e77 7269 7465 5f63 6f6e 7472 uter.write_contr\n+0000abe0: 6f6c 285f 6d73 672c 2063 6861 6e6e 656c ol(_msg, channel\n+0000abf0: 3d63 6861 6e6e 656c 2c20 636f 6d6d 616e =channel, comman\n+0000ac00: 643d 636f 6d6d 616e 642c 202a 2a6b 7761 d=command, **kwa\n+0000ac10: 7267 7329 0a20 2020 2020 2020 2069 6620 rgs). if \n+0000ac20: 636f 6d6d 616e 6420 3d3d 2027 636c 6f73 command == 'clos\n+0000ac30: 6527 3a0a 2020 2020 2020 2020 2020 2020 e':. \n+0000ac40: 7365 6c66 2e72 6f75 7465 722e 656e 6470 self.router.endp\n+0000ac50: 6f69 6e74 735b 7365 6c66 5d2e 7265 6d6f oints[self].remo\n+0000ac60: 7665 2863 6861 6e6e 656c 290a 2020 2020 ve(channel). \n+0000ac70: 2020 2020 2020 2020 7365 6c66 2e72 6f75 self.rou\n+0000ac80: 7465 722e 6472 6f70 5f63 6861 6e6e 656c ter.drop_channel\n+0000ac90: 2863 6861 6e6e 656c 290a 0a20 2020 2064 (channel).. d\n+0000aca0: 6566 2073 6875 7464 6f77 6e5f 656e 6470 ef shutdown_endp\n+0000acb0: 6f69 6e74 2873 656c 662c 205f 6d73 673a oint(self, _msg:\n+0000acc0: 2027 4a73 6f6e 4f62 6a65 6374 207c 204e 'JsonObject | N\n+0000acd0: 6f6e 6527 203d 204e 6f6e 652c 202a 2a6b one' = None, **k\n+0000ace0: 7761 7267 733a 204a 736f 6e56 616c 7565 wargs: JsonValue\n+0000acf0: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n+0000ad00: 2020 2073 656c 662e 726f 7574 6572 2e73 self.router.s\n+0000ad10: 6875 7464 6f77 6e5f 656e 6470 6f69 6e74 hutdown_endpoint\n+0000ad20: 2873 656c 662c 205f 6d73 672c 202a 2a6b (self, _msg, **k\n+0000ad30: 7761 7267 7329 0a0a 0a63 6c61 7373 2052 wargs)...class R\n+0000ad40: 6f75 7469 6e67 4572 726f 7228 436f 636b outingError(Cock\n+0000ad50: 7069 7450 726f 626c 656d 293a 0a20 2020 pitProblem):. \n+0000ad60: 2070 6173 730a 0a0a 636c 6173 7320 526f pass...class Ro\n+0000ad70: 7574 696e 6752 756c 653a 0a20 2020 2072 utingRule:. r\n+0000ad80: 6f75 7465 723a 2027 526f 7574 6572 270a outer: 'Router'.\n+0000ad90: 0a20 2020 2064 6566 205f 5f69 6e69 745f . def __init_\n+0000ada0: 5f28 7365 6c66 2c20 726f 7574 6572 3a20 _(self, router: \n+0000adb0: 2752 6f75 7465 7227 293a 0a20 2020 2020 'Router'):. \n+0000adc0: 2020 2073 656c 662e 726f 7574 6572 203d self.router =\n+0000add0: 2072 6f75 7465 720a 0a20 2020 2064 6566 router.. def\n+0000ade0: 2061 7070 6c79 5f72 756c 6528 7365 6c66 apply_rule(self\n+0000adf0: 2c20 6f70 7469 6f6e 733a 204a 736f 6e4f , options: JsonO\n+0000ae00: 626a 6563 7429 202d 3e20 4f70 7469 6f6e bject) -> Option\n+0000ae10: 616c 5b45 6e64 706f 696e 745d 3a0a 2020 al[Endpoint]:. \n+0000ae20: 2020 2020 2020 2222 2243 6865 636b 2069 \"\"\"Check i\n+0000ae30: 6620 6120 726f 7574 696e 6720 7275 6c65 f a routing rule\n+0000ae40: 2061 7070 6c69 6573 2074 6f20 6120 6769 applies to a gi\n+0000ae50: 7665 6e20 276f 7065 6e27 206d 6573 7361 ven 'open' messa\n+0000ae60: 6765 2e0a 0a20 2020 2020 2020 2054 6869 ge... Thi\n+0000ae70: 7320 7368 6f75 6c64 2069 6e73 7065 6374 s should inspect\n+0000ae80: 2074 6865 206f 7074 696f 6e73 2064 6963 the options dic\n+0000ae90: 7469 6f6e 6172 7920 616e 6420 646f 206f tionary and do o\n+0000aea0: 6e65 206f 6620 7468 6520 666f 6c6c 6f77 ne of the follow\n+0000aeb0: 696e 6720 7468 7265 6520 7468 696e 6773 ing three things\n+0000aec0: 3a0a 0a20 2020 2020 2020 2020 2020 202d :.. -\n+0000aed0: 2072 6574 7572 6e20 616e 2045 6e64 706f return an Endpo\n+0000aee0: 696e 7420 746f 2068 616e 646c 6520 7468 int to handle th\n+0000aef0: 6973 2063 6861 6e6e 656c 0a20 2020 2020 is channel. \n+0000af00: 2020 2020 2020 202d 2072 6169 7365 2061 - raise a\n+0000af10: 2052 6f75 7469 6e67 4572 726f 7220 746f RoutingError to\n+0000af20: 2069 6e64 6963 6174 6520 7468 6174 2074 indicate that t\n+0000af30: 6865 206f 7065 6e20 7368 6f75 6c64 2062 he open should b\n+0000af40: 6520 7265 6a65 6374 6564 0a20 2020 2020 e rejected. \n+0000af50: 2020 2020 2020 202d 2072 6574 7572 6e20 - return \n+0000af60: 4e6f 6e65 2074 6f20 6c65 7420 7468 6520 None to let the \n+0000af70: 6e65 7874 2072 756c 6520 7275 6e0a 2020 next rule run. \n+0000af80: 2020 2020 2020 2222 220a 2020 2020 2020 \"\"\". \n+0000af90: 2020 7261 6973 6520 4e6f 7449 6d70 6c65 raise NotImple\n+0000afa0: 6d65 6e74 6564 4572 726f 720a 0a20 2020 mentedError.. \n+0000afb0: 2064 6566 2073 6875 7464 6f77 6e28 7365 def shutdown(se\n+0000afc0: 6c66 293a 0a20 2020 2020 2020 2072 6169 lf):. rai\n+0000afd0: 7365 204e 6f74 496d 706c 656d 656e 7465 se NotImplemente\n+0000afe0: 6445 7272 6f72 0a0a 0a63 6c61 7373 2052 dError...class R\n+0000aff0: 6f75 7465 7228 436f 636b 7069 7450 726f outer(CockpitPro\n+0000b000: 746f 636f 6c53 6572 7665 7229 3a0a 2020 tocolServer):. \n+0000b010: 2020 726f 7574 696e 675f 7275 6c65 733a routing_rules:\n+0000b020: 204c 6973 745b 526f 7574 696e 6752 756c List[RoutingRul\n+0000b030: 655d 0a20 2020 206f 7065 6e5f 6368 616e e]. open_chan\n+0000b040: 6e65 6c73 3a20 4469 6374 5b73 7472 2c20 nels: Dict[str, \n+0000b050: 456e 6470 6f69 6e74 5d0a 2020 2020 656e Endpoint]. en\n+0000b060: 6470 6f69 6e74 733a 2027 6469 6374 5b45 dpoints: 'dict[E\n+0000b070: 6e64 706f 696e 742c 2073 6574 5b73 7472 ndpoint, set[str\n+0000b080: 5d5d 270a 2020 2020 6e6f 5f65 6e64 706f ]]'. no_endpo\n+0000b090: 696e 7473 3a20 6173 796e 6369 6f2e 4576 ints: asyncio.Ev\n+0000b0a0: 656e 7420 2023 2073 6574 2069 6620 656e ent # set if en\n+0000b0b0: 6470 6f69 6e74 7320 6469 6374 2069 7320 dpoints dict is \n+0000b0c0: 656d 7074 790a 2020 2020 5f65 6f66 3a20 empty. _eof: \n+0000b0d0: 626f 6f6c 203d 2046 616c 7365 0a0a 2020 bool = False.. \n+0000b0e0: 2020 6465 6620 5f5f 696e 6974 5f5f 2873 def __init__(s\n+0000b0f0: 656c 662c 2072 6f75 7469 6e67 5f72 756c elf, routing_rul\n+0000b100: 6573 3a20 4c69 7374 5b52 6f75 7469 6e67 es: List[Routing\n+0000b110: 5275 6c65 5d29 3a0a 2020 2020 2020 2020 Rule]):. \n+0000b120: 666f 7220 7275 6c65 2069 6e20 726f 7574 for rule in rout\n+0000b130: 696e 675f 7275 6c65 733a 0a20 2020 2020 ing_rules:. \n+0000b140: 2020 2020 2020 2072 756c 652e 726f 7574 rule.rout\n+0000b150: 6572 203d 2073 656c 660a 2020 2020 2020 er = self. \n+0000b160: 2020 7365 6c66 2e72 6f75 7469 6e67 5f72 self.routing_r\n+0000b170: 756c 6573 203d 2072 6f75 7469 6e67 5f72 ules = routing_r\n+0000b180: 756c 6573 0a20 2020 2020 2020 2073 656c ules. sel\n+0000b190: 662e 6f70 656e 5f63 6861 6e6e 656c 7320 f.open_channels \n+0000b1a0: 3d20 7b7d 0a20 2020 2020 2020 2073 656c = {}. sel\n+0000b1b0: 662e 656e 6470 6f69 6e74 7320 3d20 7b7d f.endpoints = {}\n+0000b1c0: 0a20 2020 2020 2020 2073 656c 662e 6e6f . self.no\n+0000b1d0: 5f65 6e64 706f 696e 7473 203d 2061 7379 _endpoints = asy\n+0000b1e0: 6e63 696f 2e45 7665 6e74 2829 0a20 2020 ncio.Event(). \n+0000b1f0: 2020 2020 2073 656c 662e 6e6f 5f65 6e64 self.no_end\n+0000b200: 706f 696e 7473 2e73 6574 2829 2020 2320 points.set() # \n+0000b210: 6174 2066 6972 7374 2074 6865 7265 2061 at first there a\n+0000b220: 7265 206e 6f20 656e 6470 6f69 6e74 730a re no endpoints.\n+0000b230: 0a20 2020 2064 6566 2063 6865 636b 5f72 . def check_r\n+0000b240: 756c 6573 2873 656c 662c 206f 7074 696f ules(self, optio\n+0000b250: 6e73 3a20 4a73 6f6e 4f62 6a65 6374 2920 ns: JsonObject) \n+0000b260: 2d3e 2045 6e64 706f 696e 743a 0a20 2020 -> Endpoint:. \n+0000b270: 2020 2020 2066 6f72 2072 756c 6520 696e for rule in\n+0000b280: 2073 656c 662e 726f 7574 696e 675f 7275 self.routing_ru\n+0000b290: 6c65 733a 0a20 2020 2020 2020 2020 2020 les:. \n+0000b2a0: 206c 6f67 6765 722e 6465 6275 6728 2720 logger.debug(' \n+0000b2b0: 2061 7070 6c79 696e 6720 7275 6c65 2025 applying rule %\n+0000b2c0: 7327 2c20 7275 6c65 290a 2020 2020 2020 s', rule). \n+0000b2d0: 2020 2020 2020 656e 6470 6f69 6e74 203d endpoint =\n+0000b2e0: 2072 756c 652e 6170 706c 795f 7275 6c65 rule.apply_rule\n+0000b2f0: 286f 7074 696f 6e73 290a 2020 2020 2020 (options). \n+0000b300: 2020 2020 2020 6966 2065 6e64 706f 696e if endpoin\n+0000b310: 7420 6973 206e 6f74 204e 6f6e 653a 0a20 t is not None:. \n+0000b320: 2020 2020 2020 2020 2020 2020 2020 206c l\n+0000b330: 6f67 6765 722e 6465 6275 6728 2720 2020 ogger.debug(' \n+0000b340: 2072 6573 756c 7469 6e67 2065 6e64 706f resulting endpo\n+0000b350: 696e 7420 6973 2025 7327 2c20 656e 6470 int is %s', endp\n+0000b360: 6f69 6e74 290a 2020 2020 2020 2020 2020 oint). \n+0000b370: 2020 2020 2020 7265 7475 726e 2065 6e64 return end\n+0000b380: 706f 696e 740a 2020 2020 2020 2020 656c point. el\n+0000b390: 7365 3a0a 2020 2020 2020 2020 2020 2020 se:. \n+0000b3a0: 6c6f 6767 6572 2e64 6562 7567 2827 2020 logger.debug(' \n+0000b3b0: 4e6f 2072 756c 6573 206d 6174 6368 6564 No rules matched\n+0000b3c0: 2729 0a20 2020 2020 2020 2020 2020 2072 '). r\n+0000b3d0: 6169 7365 2052 6f75 7469 6e67 4572 726f aise RoutingErro\n+0000b3e0: 7228 276e 6f74 2d73 7570 706f 7274 6564 r('not-supported\n+0000b3f0: 2729 0a0a 2020 2020 6465 6620 6472 6f70 ').. def drop\n+0000b400: 5f63 6861 6e6e 656c 2873 656c 662c 2063 _channel(self, c\n+0000b410: 6861 6e6e 656c 3a20 7374 7229 202d 3e20 hannel: str) -> \n+0000b420: 4e6f 6e65 3a0a 2020 2020 2020 2020 7472 None:. tr\n+0000b430: 793a 0a20 2020 2020 2020 2020 2020 2073 y:. s\n+0000b440: 656c 662e 6f70 656e 5f63 6861 6e6e 656c elf.open_channel\n+0000b450: 732e 706f 7028 6368 616e 6e65 6c29 0a20 s.pop(channel). \n+0000b460: 2020 2020 2020 2020 2020 206c 6f67 6765 logge\n+0000b470: 722e 6465 6275 6728 2772 6f75 7465 7220 r.debug('router \n+0000b480: 6472 6f70 7065 6420 6368 616e 6e65 6c20 dropped channel \n+0000b490: 2573 272c 2063 6861 6e6e 656c 290a 2020 %s', channel). \n+0000b4a0: 2020 2020 2020 6578 6365 7074 204b 6579 except Key\n+0000b4b0: 4572 726f 723a 0a20 2020 2020 2020 2020 Error:. \n+0000b4c0: 2020 206c 6f67 6765 722e 6572 726f 7228 logger.error(\n+0000b4d0: 2774 7279 696e 6720 746f 2064 726f 7020 'trying to drop \n+0000b4e0: 6e6f 6e2d 6578 6973 7465 6e74 2063 6861 non-existent cha\n+0000b4f0: 6e6e 656c 2025 7320 6672 6f6d 2025 7327 nnel %s from %s'\n+0000b500: 2c20 6368 616e 6e65 6c2c 2073 656c 662e , channel, self.\n+0000b510: 6f70 656e 5f63 6861 6e6e 656c 7329 0a0a open_channels)..\n+0000b520: 2020 2020 6465 6620 6164 645f 656e 6470 def add_endp\n+0000b530: 6f69 6e74 2873 656c 662c 2065 6e64 706f oint(self, endpo\n+0000b540: 696e 743a 2045 6e64 706f 696e 7429 202d int: Endpoint) -\n+0000b550: 3e20 4e6f 6e65 3a0a 2020 2020 2020 2020 > None:. \n+0000b560: 7365 6c66 2e65 6e64 706f 696e 7473 5b65 self.endpoints[e\n+0000b570: 6e64 706f 696e 745d 203d 2073 6574 2829 ndpoint] = set()\n+0000b580: 0a20 2020 2020 2020 2073 656c 662e 6e6f . self.no\n+0000b590: 5f65 6e64 706f 696e 7473 2e63 6c65 6172 _endpoints.clear\n+0000b5a0: 2829 0a0a 2020 2020 6465 6620 7368 7574 ().. def shut\n+0000b5b0: 646f 776e 5f65 6e64 706f 696e 7428 7365 down_endpoint(se\n+0000b5c0: 6c66 2c20 656e 6470 6f69 6e74 3a20 456e lf, endpoint: En\n+0000b5d0: 6470 6f69 6e74 2c20 5f6d 7367 3a20 274a dpoint, _msg: 'J\n+0000b5e0: 736f 6e4f 626a 6563 7420 7c20 4e6f 6e65 sonObject | None\n+0000b5f0: 2720 3d20 4e6f 6e65 2c20 2a2a 6b77 6172 ' = None, **kwar\n+0000b600: 6773 3a20 4a73 6f6e 5661 6c75 6529 202d gs: JsonValue) -\n+0000b610: 3e20 4e6f 6e65 3a0a 2020 2020 2020 2020 > None:. \n+0000b620: 6368 616e 6e65 6c73 203d 2073 656c 662e channels = self.\n+0000b630: 656e 6470 6f69 6e74 732e 706f 7028 656e endpoints.pop(en\n+0000b640: 6470 6f69 6e74 290a 2020 2020 2020 2020 dpoint). \n+0000b650: 6c6f 6767 6572 2e64 6562 7567 2827 7368 logger.debug('sh\n+0000b660: 7574 646f 776e 5f65 6e64 706f 696e 7428 utdown_endpoint(\n+0000b670: 2573 2c20 2573 2920 7769 6c6c 2063 6c6f %s, %s) will clo\n+0000b680: 7365 2025 7327 2c20 656e 6470 6f69 6e74 se %s', endpoint\n+0000b690: 2c20 6b77 6172 6773 2c20 6368 616e 6e65 , kwargs, channe\n+0000b6a0: 6c73 290a 2020 2020 2020 2020 666f 7220 ls). for \n+0000b6b0: 6368 616e 6e65 6c20 696e 2063 6861 6e6e channel in chann\n+0000b6c0: 656c 733a 0a20 2020 2020 2020 2020 2020 els:. \n+0000b6d0: 2073 656c 662e 7772 6974 655f 636f 6e74 self.write_cont\n+0000b6e0: 726f 6c28 5f6d 7367 2c20 636f 6d6d 616e rol(_msg, comman\n+0000b6f0: 643d 2763 6c6f 7365 272c 2063 6861 6e6e d='close', chann\n+0000b700: 656c 3d63 6861 6e6e 656c 2c20 2a2a 6b77 el=channel, **kw\n+0000b710: 6172 6773 290a 2020 2020 2020 2020 2020 args). \n+0000b720: 2020 7365 6c66 2e64 726f 705f 6368 616e self.drop_chan\n+0000b730: 6e65 6c28 6368 616e 6e65 6c29 0a0a 2020 nel(channel).. \n+0000b740: 2020 2020 2020 6966 206e 6f74 2073 656c if not sel\n+0000b750: 662e 656e 6470 6f69 6e74 733a 0a20 2020 f.endpoints:. \n+0000b760: 2020 2020 2020 2020 2073 656c 662e 6e6f self.no\n+0000b770: 5f65 6e64 706f 696e 7473 2e73 6574 2829 _endpoints.set()\n+0000b780: 0a0a 2020 2020 2020 2020 2320 7765 7265 .. # were\n+0000b790: 2077 6520 7761 6974 696e 6720 746f 2065 we waiting to e\n+0000b7a0: 7869 743f 0a20 2020 2020 2020 2069 6620 xit?. if \n+0000b7b0: 7365 6c66 2e5f 656f 663a 0a20 2020 2020 self._eof:. \n+0000b7c0: 2020 2020 2020 206c 6f67 6765 722e 6465 logger.de\n+0000b7d0: 6275 6728 2720 2065 6e64 706f 696e 7473 bug(' endpoints\n+0000b7e0: 2072 656d 6169 6e69 6e67 3a20 2572 272c remaining: %r',\n+0000b7f0: 2073 656c 662e 656e 6470 6f69 6e74 7329 self.endpoints)\n+0000b800: 0a20 2020 2020 2020 2020 2020 2069 6620 . if \n+0000b810: 6e6f 7420 7365 6c66 2e65 6e64 706f 696e not self.endpoin\n+0000b820: 7473 2061 6e64 2073 656c 662e 7472 616e ts and self.tran\n+0000b830: 7370 6f72 743a 0a20 2020 2020 2020 2020 sport:. \n+0000b840: 2020 2020 2020 206c 6f67 6765 722e 6465 logger.de\n+0000b850: 6275 6728 2720 2063 6c6f 7365 2074 7261 bug(' close tra\n+0000b860: 6e73 706f 7274 2729 0a20 2020 2020 2020 nsport'). \n+0000b870: 2020 2020 2020 2020 2073 656c 662e 7472 self.tr\n+0000b880: 616e 7370 6f72 742e 636c 6f73 6528 290a ansport.close().\n+0000b890: 0a20 2020 2064 6566 2064 6f5f 6b69 6c6c . def do_kill\n+0000b8a0: 2873 656c 662c 2068 6f73 743a 2027 7374 (self, host: 'st\n+0000b8b0: 7220 7c20 4e6f 6e65 272c 2067 726f 7570 r | None', group\n+0000b8c0: 3a20 2773 7472 207c 204e 6f6e 6527 2c20 : 'str | None', \n+0000b8d0: 6d65 7373 6167 653a 204a 736f 6e4f 626a message: JsonObj\n+0000b8e0: 6563 7429 202d 3e20 4e6f 6e65 3a0a 2020 ect) -> None:. \n+0000b8f0: 2020 2020 2020 656e 6470 6f69 6e74 7320 endpoints \n+0000b900: 3d20 7365 7428 7365 6c66 2e65 6e64 706f = set(self.endpo\n+0000b910: 696e 7473 290a 2020 2020 2020 2020 6c6f ints). lo\n+0000b920: 6767 6572 2e64 6562 7567 2827 646f 5f6b gger.debug('do_k\n+0000b930: 696c 6c28 2573 2c20 2573 292e 2020 436f ill(%s, %s). Co\n+0000b940: 6e73 6964 6572 696e 6720 2564 2065 6e64 nsidering %d end\n+0000b950: 706f 696e 7473 2e27 2c20 686f 7374 2c20 points.', host, \n+0000b960: 6772 6f75 702c 206c 656e 2865 6e64 706f group, len(endpo\n+0000b970: 696e 7473 2929 0a20 2020 2020 2020 2066 ints)). f\n+0000b980: 6f72 2065 6e64 706f 696e 7420 696e 2065 or endpoint in e\n+0000b990: 6e64 706f 696e 7473 3a0a 2020 2020 2020 ndpoints:. \n+0000b9a0: 2020 2020 2020 656e 6470 6f69 6e74 2e64 endpoint.d\n+0000b9b0: 6f5f 6b69 6c6c 2868 6f73 742c 2067 726f o_kill(host, gro\n+0000b9c0: 7570 2c20 6d65 7373 6167 6529 0a0a 2020 up, message).. \n+0000b9d0: 2020 6465 6620 6368 616e 6e65 6c5f 636f def channel_co\n+0000b9e0: 6e74 726f 6c5f 7265 6365 6976 6564 2873 ntrol_received(s\n+0000b9f0: 656c 662c 2063 6861 6e6e 656c 3a20 7374 elf, channel: st\n+0000ba00: 722c 2063 6f6d 6d61 6e64 3a20 7374 722c r, command: str,\n+0000ba10: 206d 6573 7361 6765 3a20 4a73 6f6e 4f62 message: JsonOb\n+0000ba20: 6a65 6374 2920 2d3e 204e 6f6e 653a 0a20 ject) -> None:. \n+0000ba30: 2020 2020 2020 2023 2049 6620 7468 6973 # If this\n+0000ba40: 2069 7320 616e 206f 7065 6e20 6d65 7373 is an open mess\n+0000ba50: 6167 6520 7468 656e 2077 6520 6e65 6564 age then we need\n+0000ba60: 2074 6f20 6170 706c 7920 7468 6520 726f to apply the ro\n+0000ba70: 7574 696e 6720 7275 6c65 7320 746f 0a20 uting rules to. \n+0000ba80: 2020 2020 2020 2023 2066 6967 7572 6520 # figure \n+0000ba90: 6f75 7420 7468 6520 636f 7272 6563 7420 out the correct \n+0000baa0: 656e 6470 6f69 6e74 2074 6f20 636f 6e6e endpoint to conn\n+0000bab0: 6563 742e 2020 4966 2069 7427 7320 6e6f ect. If it's no\n+0000bac0: 7420 616e 206f 7065 6e0a 2020 2020 2020 t an open. \n+0000bad0: 2020 2320 6d65 7373 6167 652c 2074 6865 # message, the\n+0000bae0: 6e20 7765 2065 7870 6563 7420 7468 6520 n we expect the \n+0000baf0: 656e 6470 6f69 6e74 2074 6f20 616c 7265 endpoint to alre\n+0000bb00: 6164 7920 6578 6973 742e 0a20 2020 2020 ady exist.. \n+0000bb10: 2020 2069 6620 636f 6d6d 616e 6420 3d3d if command ==\n+0000bb20: 2027 6f70 656e 273a 0a20 2020 2020 2020 'open':. \n+0000bb30: 2020 2020 2069 6620 6368 616e 6e65 6c20 if channel \n+0000bb40: 696e 2073 656c 662e 6f70 656e 5f63 6861 in self.open_cha\n+0000bb50: 6e6e 656c 733a 0a20 2020 2020 2020 2020 nnels:. \n+0000bb60: 2020 2020 2020 2072 6169 7365 2043 6f63 raise Coc\n+0000bb70: 6b70 6974 5072 6f74 6f63 6f6c 4572 726f kpitProtocolErro\n+0000bb80: 7228 2763 6861 6e6e 656c 2069 7320 616c r('channel is al\n+0000bb90: 7265 6164 7920 6f70 656e 2729 0a0a 2020 ready open').. \n+0000bba0: 2020 2020 2020 2020 2020 7472 793a 0a20 try:. \n+0000bbb0: 2020 2020 2020 2020 2020 2020 2020 206c l\n+0000bbc0: 6f67 6765 722e 6465 6275 6728 2754 7279 ogger.debug('Try\n+0000bbd0: 696e 6720 746f 2066 696e 6420 656e 6470 ing to find endp\n+0000bbe0: 6f69 6e74 2066 6f72 206e 6577 2063 6861 oint for new cha\n+0000bbf0: 6e6e 656c 2025 7320 7061 796c 6f61 643d nnel %s payload=\n+0000bc00: 2573 272c 2063 6861 6e6e 656c 2c20 6d65 %s', channel, me\n+0000bc10: 7373 6167 652e 6765 7428 2770 6179 6c6f ssage.get('paylo\n+0000bc20: 6164 2729 290a 2020 2020 2020 2020 2020 ad')). \n+0000bc30: 2020 2020 2020 656e 6470 6f69 6e74 203d endpoint =\n+0000bc40: 2073 656c 662e 6368 6563 6b5f 7275 6c65 self.check_rule\n+0000bc50: 7328 6d65 7373 6167 6529 0a20 2020 2020 s(message). \n+0000bc60: 2020 2020 2020 2065 7863 6570 7420 526f except Ro\n+0000bc70: 7574 696e 6745 7272 6f72 2061 7320 6578 utingError as ex\n+0000bc80: 633a 0a20 2020 2020 2020 2020 2020 2020 c:. \n+0000bc90: 2020 2073 656c 662e 7772 6974 655f 636f self.write_co\n+0000bca0: 6e74 726f 6c28 6578 632e 6765 745f 6174 ntrol(exc.get_at\n+0000bcb0: 7472 7328 292c 2063 6f6d 6d61 6e64 3d27 trs(), command='\n+0000bcc0: 636c 6f73 6527 2c20 6368 616e 6e65 6c3d close', channel=\n+0000bcd0: 6368 616e 6e65 6c29 0a20 2020 2020 2020 channel). \n+0000bce0: 2020 2020 2020 2020 2072 6574 7572 6e0a return.\n+0000bcf0: 0a20 2020 2020 2020 2020 2020 2073 656c . sel\n+0000bd00: 662e 6f70 656e 5f63 6861 6e6e 656c 735b f.open_channels[\n+0000bd10: 6368 616e 6e65 6c5d 203d 2065 6e64 706f channel] = endpo\n+0000bd20: 696e 740a 2020 2020 2020 2020 2020 2020 int. \n+0000bd30: 7365 6c66 2e65 6e64 706f 696e 7473 5b65 self.endpoints[e\n+0000bd40: 6e64 706f 696e 745d 2e61 6464 2863 6861 ndpoint].add(cha\n+0000bd50: 6e6e 656c 290a 2020 2020 2020 2020 656c nnel). el\n+0000bd60: 7365 3a0a 2020 2020 2020 2020 2020 2020 se:. \n+0000bd70: 7472 793a 0a20 2020 2020 2020 2020 2020 try:. \n+0000bd80: 2020 2020 2065 6e64 706f 696e 7420 3d20 endpoint = \n+0000bd90: 7365 6c66 2e6f 7065 6e5f 6368 616e 6e65 self.open_channe\n+0000bda0: 6c73 5b63 6861 6e6e 656c 5d0a 2020 2020 ls[channel]. \n+0000bdb0: 2020 2020 2020 2020 6578 6365 7074 204b except K\n+0000bdc0: 6579 4572 726f 723a 0a20 2020 2020 2020 eyError:. \n+0000bdd0: 2020 2020 2020 2020 2023 2073 656e 6469 # sendi\n+0000bde0: 6e67 2074 6f20 6120 6e6f 6e2d 6578 6973 ng to a non-exis\n+0000bdf0: 7465 6e74 2063 6861 6e6e 656c 2063 616e tent channel can\n+0000be00: 2068 6170 7065 6e20 6475 6520 746f 2072 happen due to r\n+0000be10: 6163 6573 2061 6e64 2069 7320 6e6f 7420 aces and is not \n+0000be20: 616e 2065 7272 6f72 0a20 2020 2020 2020 an error. \n+0000be30: 2020 2020 2020 2020 2072 6574 7572 6e0a return.\n+0000be40: 0a20 2020 2020 2020 2023 2041 7420 7468 . # At th\n+0000be50: 6973 2070 6f69 6e74 2c20 7765 2068 6176 is point, we hav\n+0000be60: 6520 7468 6520 656e 6470 6f69 6e74 2e20 e the endpoint. \n+0000be70: 2052 6f75 7465 2074 6865 206d 6573 7361 Route the messa\n+0000be80: 6765 2e0a 2020 2020 2020 2020 656e 6470 ge.. endp\n+0000be90: 6f69 6e74 2e64 6f5f 6368 616e 6e65 6c5f oint.do_channel_\n+0000bea0: 636f 6e74 726f 6c28 6368 616e 6e65 6c2c control(channel,\n+0000beb0: 2063 6f6d 6d61 6e64 2c20 6d65 7373 6167 command, messag\n+0000bec0: 6529 0a0a 2020 2020 6465 6620 6368 616e e).. def chan\n+0000bed0: 6e65 6c5f 6461 7461 5f72 6563 6569 7665 nel_data_receive\n+0000bee0: 6428 7365 6c66 2c20 6368 616e 6e65 6c3a d(self, channel:\n+0000bef0: 2073 7472 2c20 6461 7461 3a20 6279 7465 str, data: byte\n+0000bf00: 7329 202d 3e20 4e6f 6e65 3a0a 2020 2020 s) -> None:. \n+0000bf10: 2020 2020 7472 793a 0a20 2020 2020 2020 try:. \n+0000bf20: 2020 2020 2065 6e64 706f 696e 7420 3d20 endpoint = \n+0000bf30: 7365 6c66 2e6f 7065 6e5f 6368 616e 6e65 self.open_channe\n+0000bf40: 6c73 5b63 6861 6e6e 656c 5d0a 2020 2020 ls[channel]. \n+0000bf50: 2020 2020 6578 6365 7074 204b 6579 4572 except KeyEr\n+0000bf60: 726f 723a 0a20 2020 2020 2020 2020 2020 ror:. \n+0000bf70: 2072 6574 7572 6e0a 0a20 2020 2020 2020 return.. \n+0000bf80: 2065 6e64 706f 696e 742e 646f 5f63 6861 endpoint.do_cha\n+0000bf90: 6e6e 656c 5f64 6174 6128 6368 616e 6e65 nnel_data(channe\n+0000bfa0: 6c2c 2064 6174 6129 0a0a 2020 2020 6465 l, data).. de\n+0000bfb0: 6620 656f 665f 7265 6365 6976 6564 2873 f eof_received(s\n+0000bfc0: 656c 6629 202d 3e20 626f 6f6c 3a0a 2020 elf) -> bool:. \n+0000bfd0: 2020 2020 2020 6c6f 6767 6572 2e64 6562 logger.deb\n+0000bfe0: 7567 2827 656f 665f 7265 6365 6976 6564 ug('eof_received\n+0000bff0: 2825 7229 272c 2073 656c 6629 0a0a 2020 (%r)', self).. \n+0000c000: 2020 2020 2020 656e 6470 6f69 6e74 7320 endpoints \n+0000c010: 3d20 7365 7428 7365 6c66 2e65 6e64 706f = set(self.endpo\n+0000c020: 696e 7473 290a 2020 2020 2020 2020 666f ints). fo\n+0000c030: 7220 656e 6470 6f69 6e74 2069 6e20 656e r endpoint in en\n+0000c040: 6470 6f69 6e74 733a 0a20 2020 2020 2020 dpoints:. \n+0000c050: 2020 2020 2065 6e64 706f 696e 742e 646f endpoint.do\n+0000c060: 5f63 6c6f 7365 2829 0a0a 2020 2020 2020 _close().. \n+0000c070: 2020 7365 6c66 2e5f 656f 6620 3d20 5472 self._eof = Tr\n+0000c080: 7565 0a20 2020 2020 2020 206c 6f67 6765 ue. logge\n+0000c090: 722e 6465 6275 6728 2720 2065 6e64 706f r.debug(' endpo\n+0000c0a0: 696e 7473 2072 656d 6169 6e69 6e67 3a20 ints remaining: \n+0000c0b0: 2572 272c 2073 656c 662e 656e 6470 6f69 %r', self.endpoi\n+0000c0c0: 6e74 7329 0a20 2020 2020 2020 2072 6574 nts). ret\n+0000c0d0: 7572 6e20 626f 6f6c 2873 656c 662e 656e urn bool(self.en\n+0000c0e0: 6470 6f69 6e74 7329 0a0a 2020 2020 5f63 dpoints).. _c\n+0000c0f0: 6f6d 6d75 6e69 6361 7469 6f6e 5f64 6f6e ommunication_don\n+0000c100: 653a 204f 7074 696f 6e61 6c5b 6173 796e e: Optional[asyn\n+0000c110: 6369 6f2e 4675 7475 7265 5d20 3d20 4e6f cio.Future] = No\n+0000c120: 6e65 0a0a 2020 2020 6465 6620 646f 5f63 ne.. def do_c\n+0000c130: 6c6f 7365 6428 7365 6c66 2c20 6578 633a losed(self, exc:\n+0000c140: 204f 7074 696f 6e61 6c5b 4578 6365 7074 Optional[Except\n+0000c150: 696f 6e5d 2920 2d3e 204e 6f6e 653a 0a20 ion]) -> None:. \n+0000c160: 2020 2020 2020 2023 2049 6620 7765 2064 # If we d\n+0000c170: 6964 6e27 7420 7365 6e64 2045 4f46 2079 idn't send EOF y\n+0000c180: 6574 2c20 646f 2069 7420 6e6f 772e 0a20 et, do it now.. \n+0000c190: 2020 2020 2020 2069 6620 6e6f 7420 7365 if not se\n+0000c1a0: 6c66 2e5f 656f 663a 0a20 2020 2020 2020 lf._eof:. \n+0000c1b0: 2020 2020 2073 656c 662e 656f 665f 7265 self.eof_re\n+0000c1c0: 6365 6976 6564 2829 0a0a 2020 2020 2020 ceived().. \n+0000c1d0: 2020 6966 2073 656c 662e 5f63 6f6d 6d75 if self._commu\n+0000c1e0: 6e69 6361 7469 6f6e 5f64 6f6e 6520 6973 nication_done is\n+0000c1f0: 206e 6f74 204e 6f6e 653a 0a20 2020 2020 not None:. \n+0000c200: 2020 2020 2020 2069 6620 6578 6320 6973 if exc is\n+0000c210: 204e 6f6e 653a 0a20 2020 2020 2020 2020 None:. \n+0000c220: 2020 2020 2020 2073 656c 662e 5f63 6f6d self._com\n+0000c230: 6d75 6e69 6361 7469 6f6e 5f64 6f6e 652e munication_done.\n+0000c240: 7365 745f 7265 7375 6c74 284e 6f6e 6529 set_result(None)\n+0000c250: 0a20 2020 2020 2020 2020 2020 2065 6c73 . els\n+0000c260: 653a 0a20 2020 2020 2020 2020 2020 2020 e:. \n+0000c270: 2020 2073 656c 662e 5f63 6f6d 6d75 6e69 self._communi\n+0000c280: 6361 7469 6f6e 5f64 6f6e 652e 7365 745f cation_done.set_\n+0000c290: 6578 6365 7074 696f 6e28 6578 6329 0a0a exception(exc)..\n+0000c2a0: 2020 2020 6173 796e 6320 6465 6620 636f async def co\n+0000c2b0: 6d6d 756e 6963 6174 6528 7365 6c66 2920 mmunicate(self) \n+0000c2c0: 2d3e 204e 6f6e 653a 0a20 2020 2020 2020 -> None:. \n+0000c2d0: 2022 2222 5761 6974 2075 6e74 696c 2063 \"\"\"Wait until c\n+0000c2e0: 6f6d 6d75 6e69 6361 7469 6f6e 2069 7320 ommunication is \n+0000c2f0: 636f 6d70 6c65 7465 206f 6e20 7468 6520 complete on the \n+0000c300: 726f 7574 6572 2061 6e64 2061 6c6c 2065 router and all e\n+0000c310: 6e64 706f 696e 7473 2061 7265 2064 6f6e ndpoints are don\n+0000c320: 652e 2222 220a 2020 2020 2020 2020 6173 e.\"\"\". as\n+0000c330: 7365 7274 2073 656c 662e 5f63 6f6d 6d75 sert self._commu\n+0000c340: 6e69 6361 7469 6f6e 5f64 6f6e 6520 6973 nication_done is\n+0000c350: 204e 6f6e 650a 2020 2020 2020 2020 7365 None. se\n+0000c360: 6c66 2e5f 636f 6d6d 756e 6963 6174 696f lf._communicatio\n+0000c370: 6e5f 646f 6e65 203d 2061 7379 6e63 696f n_done = asyncio\n+0000c380: 2e67 6574 5f72 756e 6e69 6e67 5f6c 6f6f .get_running_loo\n+0000c390: 7028 292e 6372 6561 7465 5f66 7574 7572 p().create_futur\n+0000c3a0: 6528 290a 2020 2020 2020 2020 7472 793a e(). try:\n+0000c3b0: 0a20 2020 2020 2020 2020 2020 2061 7761 . awa\n+0000c3c0: 6974 2073 656c 662e 5f63 6f6d 6d75 6e69 it self._communi\n+0000c3d0: 6361 7469 6f6e 5f64 6f6e 650a 2020 2020 cation_done. \n+0000c3e0: 2020 2020 6578 6365 7074 2028 4272 6f6b except (Brok\n+0000c3f0: 656e 5069 7065 4572 726f 722c 2043 6f6e enPipeError, Con\n+0000c400: 6e65 6374 696f 6e52 6573 6574 4572 726f nectionResetErro\n+0000c410: 7229 3a0a 2020 2020 2020 2020 2020 2020 r):. \n+0000c420: 7061 7373 2020 2320 7468 6573 6520 6172 pass # these ar\n+0000c430: 6520 6e6f 726d 616c 206f 6363 7572 7265 e normal occurre\n+0000c440: 6e63 6573 2077 6865 6e20 636c 6f73 6564 nces when closed\n+0000c450: 2066 726f 6d20 7468 6520 6f74 6865 7220 from the other \n+0000c460: 7369 6465 0a20 2020 2020 2020 2066 696e side. fin\n+0000c470: 616c 6c79 3a0a 2020 2020 2020 2020 2020 ally:. \n+0000c480: 2020 7365 6c66 2e5f 636f 6d6d 756e 6963 self._communic\n+0000c490: 6174 696f 6e5f 646f 6e65 203d 204e 6f6e ation_done = Non\n+0000c4a0: 650a 0a20 2020 2020 2020 2020 2020 2023 e.. #\n+0000c4b0: 2049 6e20 616e 206f 7264 6572 6c79 2065 In an orderly e\n+0000c4c0: 7869 742c 2074 6869 7320 6973 2061 6c72 xit, this is alr\n+0000c4d0: 6561 6479 2064 6f6e 652c 2062 7574 2069 eady done, but i\n+0000c4e0: 6e20 6361 7365 2069 7420 7761 736e 2774 n case it wasn't\n+0000c4f0: 0a20 2020 2020 2020 2020 2020 2023 206f . # o\n+0000c500: 7264 6572 6c79 2c20 7765 206e 6565 6420 rderly, we need \n+0000c510: 746f 206d 616b 6520 7375 7265 2074 6865 to make sure the\n+0000c520: 2065 6e64 706f 696e 7473 2073 6875 7420 endpoints shut \n+0000c530: 646f 776e 2061 6e79 7761 792e 2e2e 0a20 down anyway.... \n+0000c540: 2020 2020 2020 2020 2020 2061 7761 6974 await\n+0000c550: 2073 656c 662e 6e6f 5f65 6e64 706f 696e self.no_endpoin\n+0000c560: 7473 2e77 6169 7428 290a 2727 272c 0a20 ts.wait().''',. \n+0000c570: 2027 636f 636b 7069 742f 7072 6f74 6f63 'cockpit/protoc\n+0000c580: 6f6c 2e70 7927 3a20 6272 2727 2723 2054 ol.py': br'''# T\n+0000c590: 6869 7320 6669 6c65 2069 7320 7061 7274 his file is part\n+0000c5a0: 206f 6620 436f 636b 7069 742e 0a23 0a23 of Cockpit..#.#\n+0000c5b0: 2043 6f70 7972 6967 6874 2028 4329 2032 Copyright (C) 2\n+0000c5c0: 3032 3220 5265 6420 4861 742c 2049 6e63 022 Red Hat, Inc\n+0000c5d0: 2e0a 230a 2320 5468 6973 2070 726f 6772 ..#.# This progr\n+0000c5e0: 616d 2069 7320 6672 6565 2073 6f66 7477 am is free softw\n+0000c5f0: 6172 653a 2079 6f75 2063 616e 2072 6564 are: you can red\n+0000c600: 6973 7472 6962 7574 6520 6974 2061 6e64 istribute it and\n+0000c610: 2f6f 7220 6d6f 6469 6679 0a23 2069 7420 /or modify.# it \n+0000c620: 756e 6465 7220 7468 6520 7465 726d 7320 under the terms \n+0000c630: 6f66 2074 6865 2047 4e55 2047 656e 6572 of the GNU Gener\n+0000c640: 616c 2050 7562 6c69 6320 4c69 6365 6e73 al Public Licens\n+0000c650: 6520 6173 2070 7562 6c69 7368 6564 2062 e as published b\n+0000c660: 790a 2320 7468 6520 4672 6565 2053 6f66 y.# the Free Sof\n+0000c670: 7477 6172 6520 466f 756e 6461 7469 6f6e tware Foundation\n+0000c680: 2c20 6569 7468 6572 2076 6572 7369 6f6e , either version\n+0000c690: 2033 206f 6620 7468 6520 4c69 6365 6e73 3 of the Licens\n+0000c6a0: 652c 206f 720a 2320 2861 7420 796f 7572 e, or.# (at your\n+0000c6b0: 206f 7074 696f 6e29 2061 6e79 206c 6174 option) any lat\n+0000c6c0: 6572 2076 6572 7369 6f6e 2e0a 230a 2320 er version..#.# \n+0000c6d0: 5468 6973 2070 726f 6772 616d 2069 7320 This program is \n+0000c6e0: 6469 7374 7269 6275 7465 6420 696e 2074 distributed in t\n+0000c6f0: 6865 2068 6f70 6520 7468 6174 2069 7420 he hope that it \n+0000c700: 7769 6c6c 2062 6520 7573 6566 756c 2c0a will be useful,.\n+0000c710: 2320 6275 7420 5749 5448 4f55 5420 414e # but WITHOUT AN\n+0000c720: 5920 5741 5252 414e 5459 3b20 7769 7468 Y WARRANTY; with\n+0000c730: 6f75 7420 6576 656e 2074 6865 2069 6d70 out even the imp\n+0000c740: 6c69 6564 2077 6172 7261 6e74 7920 6f66 lied warranty of\n+0000c750: 0a23 204d 4552 4348 414e 5441 4249 4c49 .# MERCHANTABILI\n+0000c760: 5459 206f 7220 4649 544e 4553 5320 464f TY or FITNESS FO\n+0000c770: 5220 4120 5041 5254 4943 554c 4152 2050 R A PARTICULAR P\n+0000c780: 5552 504f 5345 2e20 2053 6565 2074 6865 URPOSE. See the\n+0000c790: 0a23 2047 4e55 2047 656e 6572 616c 2050 .# GNU General P\n+0000c7a0: 7562 6c69 6320 4c69 6365 6e73 6520 666f ublic License fo\n+0000c7b0: 7220 6d6f 7265 2064 6574 6169 6c73 2e0a r more details..\n+0000c7c0: 230a 2320 596f 7520 7368 6f75 6c64 2068 #.# You should h\n+0000c7d0: 6176 6520 7265 6365 6976 6564 2061 2063 ave received a c\n+0000c7e0: 6f70 7920 6f66 2074 6865 2047 4e55 2047 opy of the GNU G\n+0000c7f0: 656e 6572 616c 2050 7562 6c69 6320 4c69 eneral Public Li\n+0000c800: 6365 6e73 650a 2320 616c 6f6e 6720 7769 cense.# along wi\n+0000c810: 7468 2074 6869 7320 7072 6f67 7261 6d2e th this program.\n+0000c820: 2020 4966 206e 6f74 2c20 7365 6520 3c68 If not, see ...\n+0000c850: 696d 706f 7274 2061 7379 6e63 696f 0a69 import asyncio.i\n+0000c860: 6d70 6f72 7420 6a73 6f6e 0a69 6d70 6f72 mport json.impor\n+0000c870: 7420 6c6f 6767 696e 670a 696d 706f 7274 t logging.import\n+0000c880: 2074 7261 6365 6261 636b 0a69 6d70 6f72 traceback.impor\n+0000c890: 7420 7575 6964 0a0a 6672 6f6d 202e 6a73 t uuid..from .js\n+0000c8a0: 6f6e 7574 696c 2069 6d70 6f72 7420 4a73 onutil import Js\n+0000c8b0: 6f6e 4572 726f 722c 204a 736f 6e4f 626a onError, JsonObj\n+0000c8c0: 6563 742c 204a 736f 6e56 616c 7565 2c20 ect, JsonValue, \n+0000c8d0: 6372 6561 7465 5f6f 626a 6563 742c 2067 create_object, g\n+0000c8e0: 6574 5f69 6e74 2c20 6765 745f 7374 722c et_int, get_str,\n+0000c8f0: 2067 6574 5f73 7472 5f6f 725f 6e6f 6e65 get_str_or_none\n+0000c900: 2c20 7479 7065 6368 6563 6b65 640a 0a6c , typechecked..l\n+0000c910: 6f67 6765 7220 3d20 6c6f 6767 696e 672e ogger = logging.\n+0000c920: 6765 744c 6f67 6765 7228 5f5f 6e61 6d65 getLogger(__name\n+0000c930: 5f5f 290a 0a0a 636c 6173 7320 436f 636b __)...class Cock\n+0000c940: 7069 7450 726f 626c 656d 2845 7863 6570 pitProblem(Excep\n+0000c950: 7469 6f6e 293a 0a20 2020 2022 2222 4120 tion):. \"\"\"A \n+0000c960: 7479 7065 206f 6620 6578 6365 7074 696f type of exceptio\n+0000c970: 6e20 7468 6174 2063 6172 7269 6573 2061 n that carries a\n+0000c980: 2070 726f 626c 656d 2063 6f64 6520 616e problem code an\n+0000c990: 6420 6120 6d65 7373 6167 652e 0a0a 2020 d a message... \n+0000c9a0: 2020 4465 7065 6e64 696e 6720 6f6e 2074 Depending on t\n+0000c9b0: 6865 2073 636f 7065 2c20 7468 6973 2069 he scope, this i\n+0000c9c0: 7320 7573 6564 2074 6f20 6861 6e64 6c65 s used to handle\n+0000c9d0: 2073 6875 7474 696e 6720 646f 776e 3a0a shutting down:.\n+0000c9e0: 0a20 2020 2020 202d 2061 6e20 696e 6469 . - an indi\n+0000c9f0: 7669 6475 616c 2063 6861 6e6e 656c 2028 vidual channel (\n+0000ca00: 7365 6e64 7320 7072 6f62 6c65 6d20 636f sends problem co\n+0000ca10: 6465 2069 6e20 7468 6520 636c 6f73 6520 de in the close \n+0000ca20: 6d65 7373 6167 6529 0a20 2020 2020 202d message). -\n+0000ca30: 2070 6565 7220 636f 6e6e 6563 7469 6f6e peer connection\n+0000ca40: 7320 2873 656e 6473 2070 726f 626c 656d s (sends problem\n+0000ca50: 2063 6f64 6520 696e 2063 6c6f 7365 206d code in close m\n+0000ca60: 6573 7361 6765 2066 6f72 2065 6163 6820 essage for each \n+0000ca70: 6f70 656e 2063 6861 6e6e 656c 290a 2020 open channel). \n+0000ca80: 2020 2020 2d20 7468 6520 6d61 696e 2073 - the main s\n+0000ca90: 7464 696f 2069 6e74 6572 6163 7469 6f6e tdio interaction\n+0000caa0: 2077 6974 6820 7468 6520 6272 6964 6765 with the bridge\n+0000cab0: 0a0a 2020 2020 4974 2069 7320 7573 7561 .. It is usua\n+0000cac0: 6c6c 7920 7468 726f 776e 2069 6e20 7265 lly thrown in re\n+0000cad0: 7370 6f6e 7365 2074 6f20 736f 6d65 2076 sponse to some v\n+0000cae0: 696f 6c61 7469 6f6e 206f 6620 6578 7065 iolation of expe\n+0000caf0: 6374 6564 2070 726f 746f 636f 6c0a 2020 cted protocol. \n+0000cb00: 2020 7768 656e 2070 6172 7369 6e67 206d when parsing m\n+0000cb10: 6573 7361 6765 732c 2063 6f6e 6e65 6374 essages, connect\n+0000cb20: 696e 6720 746f 2061 2070 6565 722c 206f ing to a peer, o\n+0000cb30: 7220 6f70 656e 696e 6720 6120 6368 616e r opening a chan\n+0000cb40: 6e65 6c2e 0a20 2020 2022 2222 0a20 2020 nel.. \"\"\". \n+0000cb50: 2061 7474 7273 3a20 4a73 6f6e 4f62 6a65 attrs: JsonObje\n+0000cb60: 6374 0a0a 2020 2020 6465 6620 5f5f 696e ct.. def __in\n+0000cb70: 6974 5f5f 2873 656c 662c 2070 726f 626c it__(self, probl\n+0000cb80: 656d 3a20 7374 722c 205f 6d73 673a 2027 em: str, _msg: '\n+0000cb90: 4a73 6f6e 4f62 6a65 6374 207c 204e 6f6e JsonObject | Non\n+0000cba0: 6527 203d 204e 6f6e 652c 202a 2a6b 7761 e' = None, **kwa\n+0000cbb0: 7267 733a 204a 736f 6e56 616c 7565 2920 rgs: JsonValue) \n+0000cbc0: 2d3e 204e 6f6e 653a 0a20 2020 2020 2020 -> None:. \n+0000cbd0: 206b 7761 7267 735b 2770 726f 626c 656d kwargs['problem\n+0000cbe0: 275d 203d 2070 726f 626c 656d 0a20 2020 '] = problem. \n+0000cbf0: 2020 2020 2073 656c 662e 6174 7472 7320 self.attrs \n+0000cc00: 3d20 6372 6561 7465 5f6f 626a 6563 7428 = create_object(\n+0000cc10: 5f6d 7367 2c20 6b77 6172 6773 290a 2020 _msg, kwargs). \n+0000cc20: 2020 2020 2020 7375 7065 7228 292e 5f5f super().__\n+0000cc30: 696e 6974 5f5f 2867 6574 5f73 7472 2873 init__(get_str(s\n+0000cc40: 656c 662e 6174 7472 732c 2027 6d65 7373 elf.attrs, 'mess\n+0000cc50: 6167 6527 2c20 7072 6f62 6c65 6d29 290a age', problem)).\n+0000cc60: 0a20 2020 2064 6566 2067 6574 5f61 7474 . def get_att\n+0000cc70: 7273 2873 656c 6629 202d 3e20 4a73 6f6e rs(self) -> Json\n+0000cc80: 4f62 6a65 6374 3a0a 2020 2020 2020 2020 Object:. \n+0000cc90: 6966 2073 656c 662e 6174 7472 735b 2770 if self.attrs['p\n+0000cca0: 726f 626c 656d 275d 203d 3d20 2769 6e74 roblem'] == 'int\n+0000ccb0: 6572 6e61 6c2d 6572 726f 7227 2061 6e64 ernal-error' and\n+0000ccc0: 2073 656c 662e 5f5f 6361 7573 655f 5f20 self.__cause__ \n+0000ccd0: 6973 206e 6f74 204e 6f6e 653a 0a20 2020 is not None:. \n+0000cce0: 2020 2020 2020 2020 2072 6574 7572 6e20 return \n+0000ccf0: 6469 6374 2873 656c 662e 6174 7472 732c dict(self.attrs,\n+0000cd00: 2063 6175 7365 3d74 7261 6365 6261 636b cause=traceback\n+0000cd10: 2e66 6f72 6d61 745f 6578 6365 7074 696f .format_exceptio\n+0000cd20: 6e28 0a20 2020 2020 2020 2020 2020 2020 n(. \n+0000cd30: 2020 2073 656c 662e 5f5f 6361 7573 655f self.__cause_\n+0000cd40: 5f2e 5f5f 636c 6173 735f 5f2c 2073 656c _.__class__, sel\n+0000cd50: 662e 5f5f 6361 7573 655f 5f2c 2073 656c f.__cause__, sel\n+0000cd60: 662e 5f5f 6361 7573 655f 5f2e 5f5f 7472 f.__cause__.__tr\n+0000cd70: 6163 6562 6163 6b5f 5f0a 2020 2020 2020 aceback__. \n+0000cd80: 2020 2020 2020 2929 0a20 2020 2020 2020 )). \n+0000cd90: 2065 6c73 653a 0a20 2020 2020 2020 2020 else:. \n+0000cda0: 2020 2072 6574 7572 6e20 7365 6c66 2e61 return self.a\n+0000cdb0: 7474 7273 0a0a 0a63 6c61 7373 2043 6f63 ttrs...class Coc\n+0000cdc0: 6b70 6974 5072 6f74 6f63 6f6c 4572 726f kpitProtocolErro\n+0000cdd0: 7228 436f 636b 7069 7450 726f 626c 656d r(CockpitProblem\n+0000cde0: 293a 0a20 2020 2064 6566 205f 5f69 6e69 ):. def __ini\n+0000cdf0: 745f 5f28 7365 6c66 2c20 6d65 7373 6167 t__(self, messag\n+0000ce00: 653a 2073 7472 2c20 7072 6f62 6c65 6d3a e: str, problem:\n+0000ce10: 2073 7472 203d 2027 7072 6f74 6f63 6f6c str = 'protocol\n+0000ce20: 2d65 7272 6f72 2729 3a0a 2020 2020 2020 -error'):. \n+0000ce30: 2020 7375 7065 7228 292e 5f5f 696e 6974 super().__init\n+0000ce40: 5f5f 2870 726f 626c 656d 2c20 6d65 7373 __(problem, mess\n+0000ce50: 6167 653d 6d65 7373 6167 6529 0a0a 0a63 age=message)...c\n+0000ce60: 6c61 7373 2043 6f63 6b70 6974 5072 6f74 lass CockpitProt\n+0000ce70: 6f63 6f6c 2861 7379 6e63 696f 2e50 726f ocol(asyncio.Pro\n+0000ce80: 746f 636f 6c29 3a0a 2020 2020 2222 2241 tocol):. \"\"\"A\n+0000ce90: 206e 6169 7665 2069 6d70 6c65 6d65 6e74 naive implement\n+0000cea0: 6174 696f 6e20 6f66 2074 6865 2043 6f63 ation of the Coc\n+0000ceb0: 6b70 6974 2066 7261 6d65 2070 726f 746f kpit frame proto\n+0000cec0: 636f 6c0a 0a20 2020 2057 6520 6e65 6564 col.. We need\n+0000ced0: 2074 6f20 7573 6520 7468 6973 2062 6563 to use this bec\n+0000cee0: 6175 7365 2050 7974 686f 6e27 7320 5365 ause Python's Se\n+0000cef0: 6c65 6374 6f72 4576 656e 744c 6f6f 7020 lectorEventLoop \n+0000cf00: 646f 6573 6e27 7420 7375 7070 6f72 7465 doesn't supporte\n+0000cf10: 640a 2020 2020 6275 6666 6572 6564 2070 d. buffered p\n+0000cf20: 726f 746f 636f 6c73 2e0a 2020 2020 2222 rotocols.. \"\"\n+0000cf30: 220a 2020 2020 7472 616e 7370 6f72 743a \". transport:\n+0000cf40: 2027 6173 796e 6369 6f2e 5472 616e 7370 'asyncio.Transp\n+0000cf50: 6f72 7420 7c20 4e6f 6e65 2720 3d20 4e6f ort | None' = No\n+0000cf60: 6e65 0a20 2020 2062 7566 6665 7220 3d20 ne. buffer = \n+0000cf70: 6227 270a 2020 2020 5f63 6c6f 7365 643a b''. _closed:\n+0000cf80: 2062 6f6f 6c20 3d20 4661 6c73 650a 2020 bool = False. \n+0000cf90: 2020 5f63 6f6d 6d75 6e69 6361 7469 6f6e _communication\n+0000cfa0: 5f64 6f6e 653a 2027 6173 796e 6369 6f2e _done: 'asyncio.\n+0000cfb0: 4675 7475 7265 5b4e 6f6e 655d 207c 204e Future[None] | N\n+0000cfc0: 6f6e 6527 203d 204e 6f6e 650a 0a20 2020 one' = None.. \n+0000cfd0: 2064 6566 2064 6f5f 7265 6164 7928 7365 def do_ready(se\n+0000cfe0: 6c66 2920 2d3e 204e 6f6e 653a 0a20 2020 lf) -> None:. \n+0000cff0: 2020 2020 2070 6173 730a 0a20 2020 2064 pass.. d\n+0000d000: 6566 2064 6f5f 636c 6f73 6564 2873 656c ef do_closed(sel\n+0000d010: 662c 2065 7863 3a20 2745 7863 6570 7469 f, exc: 'Excepti\n+0000d020: 6f6e 207c 204e 6f6e 6527 2920 2d3e 204e on | None') -> N\n+0000d030: 6f6e 653a 0a20 2020 2020 2020 2070 6173 one:. pas\n+0000d040: 730a 0a20 2020 2064 6566 2074 7261 6e73 s.. def trans\n+0000d050: 706f 7274 5f63 6f6e 7472 6f6c 5f72 6563 port_control_rec\n+0000d060: 6569 7665 6428 7365 6c66 2c20 636f 6d6d eived(self, comm\n+0000d070: 616e 643a 2073 7472 2c20 6d65 7373 6167 and: str, messag\n+0000d080: 653a 204a 736f 6e4f 626a 6563 7429 202d e: JsonObject) -\n+0000d090: 3e20 4e6f 6e65 3a0a 2020 2020 2020 2020 > None:. \n+0000d0a0: 7261 6973 6520 4e6f 7449 6d70 6c65 6d65 raise NotImpleme\n+0000d0b0: 6e74 6564 4572 726f 720a 0a20 2020 2064 ntedError.. d\n+0000d0c0: 6566 2063 6861 6e6e 656c 5f63 6f6e 7472 ef channel_contr\n+0000d0d0: 6f6c 5f72 6563 6569 7665 6428 7365 6c66 ol_received(self\n+0000d0e0: 2c20 6368 616e 6e65 6c3a 2073 7472 2c20 , channel: str, \n+0000d0f0: 636f 6d6d 616e 643a 2073 7472 2c20 6d65 command: str, me\n+0000d100: 7373 6167 653a 204a 736f 6e4f 626a 6563 ssage: JsonObjec\n+0000d110: 7429 202d 3e20 4e6f 6e65 3a0a 2020 2020 t) -> None:. \n+0000d120: 2020 2020 7261 6973 6520 4e6f 7449 6d70 raise NotImp\n+0000d130: 6c65 6d65 6e74 6564 4572 726f 720a 0a20 lementedError.. \n+0000d140: 2020 2064 6566 2063 6861 6e6e 656c 5f64 def channel_d\n+0000d150: 6174 615f 7265 6365 6976 6564 2873 656c ata_received(sel\n+0000d160: 662c 2063 6861 6e6e 656c 3a20 7374 722c f, channel: str,\n+0000d170: 2064 6174 613a 2062 7974 6573 2920 2d3e data: bytes) ->\n+0000d180: 204e 6f6e 653a 0a20 2020 2020 2020 2072 None:. r\n+0000d190: 6169 7365 204e 6f74 496d 706c 656d 656e aise NotImplemen\n+0000d1a0: 7465 6445 7272 6f72 0a0a 2020 2020 6465 tedError.. de\n+0000d1b0: 6620 6672 616d 655f 7265 6365 6976 6564 f frame_received\n+0000d1c0: 2873 656c 662c 2066 7261 6d65 3a20 6279 (self, frame: by\n+0000d1d0: 7465 7329 202d 3e20 4e6f 6e65 3a0a 2020 tes) -> None:. \n+0000d1e0: 2020 2020 2020 6865 6164 6572 2c20 5f2c header, _,\n+0000d1f0: 2064 6174 6120 3d20 6672 616d 652e 7061 data = frame.pa\n+0000d200: 7274 6974 696f 6e28 6227 5c6e 2729 0a0a rtition(b'\\n')..\n+0000d210: 2020 2020 2020 2020 6966 2068 6561 6465 if heade\n+0000d220: 7220 213d 2062 2727 3a0a 2020 2020 2020 r != b'':. \n+0000d230: 2020 2020 2020 6368 616e 6e65 6c20 3d20 channel = \n+0000d240: 6865 6164 6572 2e64 6563 6f64 6528 2761 header.decode('a\n+0000d250: 7363 6969 2729 0a20 2020 2020 2020 2020 scii'). \n+0000d260: 2020 206c 6f67 6765 722e 6465 6275 6728 logger.debug(\n+0000d270: 2764 6174 6120 7265 6365 6976 6564 3a20 'data received: \n+0000d280: 2564 2062 7974 6573 206f 6620 6461 7461 %d bytes of data\n+0000d290: 2066 6f72 2063 6861 6e6e 656c 2025 7327 for channel %s'\n+0000d2a0: 2c20 6c65 6e28 6461 7461 292c 2063 6861 , len(data), cha\n+0000d2b0: 6e6e 656c 290a 2020 2020 2020 2020 2020 nnel). \n+0000d2c0: 2020 7365 6c66 2e63 6861 6e6e 656c 5f64 self.channel_d\n+0000d2d0: 6174 615f 7265 6365 6976 6564 2863 6861 ata_received(cha\n+0000d2e0: 6e6e 656c 2c20 6461 7461 290a 0a20 2020 nnel, data).. \n+0000d2f0: 2020 2020 2065 6c73 653a 0a20 2020 2020 else:. \n+0000d300: 2020 2020 2020 2073 656c 662e 636f 6e74 self.cont\n+0000d310: 726f 6c5f 7265 6365 6976 6564 2864 6174 rol_received(dat\n+0000d320: 6129 0a0a 2020 2020 6465 6620 636f 6e74 a).. def cont\n+0000d330: 726f 6c5f 7265 6365 6976 6564 2873 656c rol_received(sel\n+0000d340: 662c 2064 6174 613a 2062 7974 6573 2920 f, data: bytes) \n+0000d350: 2d3e 204e 6f6e 653a 0a20 2020 2020 2020 -> None:. \n+0000d360: 2074 7279 3a0a 2020 2020 2020 2020 2020 try:. \n+0000d370: 2020 6d65 7373 6167 6520 3d20 7479 7065 message = type\n+0000d380: 6368 6563 6b65 6428 6a73 6f6e 2e6c 6f61 checked(json.loa\n+0000d390: 6473 2864 6174 6129 2c20 6469 6374 290a ds(data), dict).\n+0000d3a0: 2020 2020 2020 2020 2020 2020 636f 6d6d comm\n+0000d3b0: 616e 6420 3d20 6765 745f 7374 7228 6d65 and = get_str(me\n+0000d3c0: 7373 6167 652c 2027 636f 6d6d 616e 6427 ssage, 'command'\n+0000d3d0: 290a 2020 2020 2020 2020 2020 2020 6368 ). ch\n+0000d3e0: 616e 6e65 6c20 3d20 6765 745f 7374 7228 annel = get_str(\n+0000d3f0: 6d65 7373 6167 652c 2027 6368 616e 6e65 message, 'channe\n+0000d400: 6c27 2c20 4e6f 6e65 290a 0a20 2020 2020 l', None).. \n+0000d410: 2020 2020 2020 2069 6620 6368 616e 6e65 if channe\n+0000d420: 6c20 6973 206e 6f74 204e 6f6e 653a 0a20 l is not None:. \n+0000d430: 2020 2020 2020 2020 2020 2020 2020 206c l\n+0000d440: 6f67 6765 722e 6465 6275 6728 2763 6861 ogger.debug('cha\n+0000d450: 6e6e 656c 2063 6f6e 7472 6f6c 2072 6563 nnel control rec\n+0000d460: 6569 7665 6420 2573 272c 206d 6573 7361 eived %s', messa\n+0000d470: 6765 290a 2020 2020 2020 2020 2020 2020 ge). \n+0000d480: 2020 2020 7365 6c66 2e63 6861 6e6e 656c self.channel\n+0000d490: 5f63 6f6e 7472 6f6c 5f72 6563 6569 7665 _control_receive\n+0000d4a0: 6428 6368 616e 6e65 6c2c 2063 6f6d 6d61 d(channel, comma\n+0000d4b0: 6e64 2c20 6d65 7373 6167 6529 0a20 2020 nd, message). \n+0000d4c0: 2020 2020 2020 2020 2065 6c73 653a 0a20 else:. \n+0000d4d0: 2020 2020 2020 2020 2020 2020 2020 206c l\n+0000d4e0: 6f67 6765 722e 6465 6275 6728 2774 7261 ogger.debug('tra\n+0000d4f0: 6e73 706f 7274 2063 6f6e 7472 6f6c 2072 nsport control r\n+0000d500: 6563 6569 7665 6420 2573 272c 206d 6573 eceived %s', mes\n+0000d510: 7361 6765 290a 2020 2020 2020 2020 2020 sage). \n+0000d520: 2020 2020 2020 7365 6c66 2e74 7261 6e73 self.trans\n+0000d530: 706f 7274 5f63 6f6e 7472 6f6c 5f72 6563 port_control_rec\n+0000d540: 6569 7665 6428 636f 6d6d 616e 642c 206d eived(command, m\n+0000d550: 6573 7361 6765 290a 0a20 2020 2020 2020 essage).. \n+0000d560: 2065 7863 6570 7420 286a 736f 6e2e 4a53 except (json.JS\n+0000d570: 4f4e 4465 636f 6465 4572 726f 722c 204a ONDecodeError, J\n+0000d580: 736f 6e45 7272 6f72 2920 6173 2065 7863 sonError) as exc\n+0000d590: 3a0a 2020 2020 2020 2020 2020 2020 7261 :. ra\n+0000d5a0: 6973 6520 436f 636b 7069 7450 726f 746f ise CockpitProto\n+0000d5b0: 636f 6c45 7272 6f72 2866 2763 6f6e 7472 colError(f'contr\n+0000d5c0: 6f6c 206d 6573 7361 6765 3a20 7b65 7863 ol message: {exc\n+0000d5d0: 2173 7d27 2920 6672 6f6d 2065 7863 0a0a !s}') from exc..\n+0000d5e0: 2020 2020 6465 6620 636f 6e73 756d 655f def consume_\n+0000d5f0: 6f6e 655f 6672 616d 6528 7365 6c66 2c20 one_frame(self, \n+0000d600: 6461 7461 3a20 6279 7465 7329 202d 3e20 data: bytes) -> \n+0000d610: 696e 743a 0a20 2020 2020 2020 2022 2222 int:. \"\"\"\n+0000d620: 436f 6e73 756d 6573 2061 2073 696e 676c Consumes a singl\n+0000d630: 6520 6672 616d 6520 6672 6f6d 2076 6965 e frame from vie\n+0000d640: 772e 0a0a 2020 2020 2020 2020 5265 7475 w... Retu\n+0000d650: 726e 7320 706f 7369 7469 7665 2069 6620 rns positive if \n+0000d660: 6120 6e75 6d62 6572 206f 6620 6279 7465 a number of byte\n+0000d670: 7320 7765 7265 2063 6f6e 7375 6d65 642c s were consumed,\n+0000d680: 206f 7220 6e65 6761 7469 7665 2069 6620 or negative if \n+0000d690: 6e6f 0a20 2020 2020 2020 2077 6f72 6b20 no. work \n+0000d6a0: 6361 6e20 6265 2064 6f6e 6520 6265 6361 can be done beca\n+0000d6b0: 7573 6520 6f66 2061 2067 6976 656e 206e use of a given n\n+0000d6c0: 756d 6265 7220 6f66 2062 7974 6573 206d umber of bytes m\n+0000d6d0: 6973 7369 6e67 2e0a 2020 2020 2020 2020 issing.. \n+0000d6e0: 2222 220a 0a20 2020 2020 2020 2074 7279 \"\"\".. try\n+0000d6f0: 3a0a 2020 2020 2020 2020 2020 2020 6e65 :. ne\n+0000d700: 776c 696e 6520 3d20 6461 7461 2e69 6e64 wline = data.ind\n+0000d710: 6578 2862 275c 6e27 290a 2020 2020 2020 ex(b'\\n'). \n+0000d720: 2020 6578 6365 7074 2056 616c 7565 4572 except ValueEr\n+0000d730: 726f 7220 6173 2065 7863 3a0a 2020 2020 ror as exc:. \n+0000d740: 2020 2020 2020 2020 6966 206c 656e 2864 if len(d\n+0000d750: 6174 6129 203c 2031 303a 0a20 2020 2020 ata) < 10:. \n+0000d760: 2020 2020 2020 2020 2020 2023 204c 6574 # Let\n+0000d770: 2773 2074 7279 2072 6561 6469 6e67 206d 's try reading m\n+0000d780: 6f72 650a 2020 2020 2020 2020 2020 2020 ore. \n+0000d790: 2020 2020 7265 7475 726e 206c 656e 2864 return len(d\n+0000d7a0: 6174 6129 202d 2031 300a 2020 2020 2020 ata) - 10. \n+0000d7b0: 2020 2020 2020 7261 6973 6520 436f 636b raise Cock\n+0000d7c0: 7069 7450 726f 746f 636f 6c45 7272 6f72 pitProtocolError\n+0000d7d0: 2822 7369 7a65 206c 696e 6520 6973 2074 (\"size line is t\n+0000d7e0: 6f6f 206c 6f6e 6722 2920 6672 6f6d 2065 oo long\") from e\n+0000d7f0: 7863 0a0a 2020 2020 2020 2020 7472 793a xc.. try:\n+0000d800: 0a20 2020 2020 2020 2020 2020 206c 656e . len\n+0000d810: 6774 6820 3d20 696e 7428 6461 7461 5b3a gth = int(data[:\n+0000d820: 6e65 776c 696e 655d 290a 2020 2020 2020 newline]). \n+0000d830: 2020 6578 6365 7074 2056 616c 7565 4572 except ValueEr\n+0000d840: 726f 7220 6173 2065 7863 3a0a 2020 2020 ror as exc:. \n+0000d850: 2020 2020 2020 2020 7261 6973 6520 436f raise Co\n+0000d860: 636b 7069 7450 726f 746f 636f 6c45 7272 ckpitProtocolErr\n+0000d870: 6f72 2822 6672 616d 6520 7369 7a65 2069 or(\"frame size i\n+0000d880: 7320 6e6f 7420 616e 2069 6e74 6567 6572 s not an integer\n+0000d890: 2229 2066 726f 6d20 6578 630a 0a20 2020 \") from exc.. \n+0000d8a0: 2020 2020 2073 7461 7274 203d 206e 6577 start = new\n+0000d8b0: 6c69 6e65 202b 2031 0a20 2020 2020 2020 line + 1. \n+0000d8c0: 2065 6e64 203d 2073 7461 7274 202b 206c end = start + l\n+0000d8d0: 656e 6774 680a 0a20 2020 2020 2020 2069 ength.. i\n+0000d8e0: 6620 656e 6420 3e20 6c65 6e28 6461 7461 f end > len(data\n+0000d8f0: 293a 0a20 2020 2020 2020 2020 2020 2023 ):. #\n+0000d900: 2057 6520 6e65 6564 2074 6f20 7265 6164 We need to read\n+0000d910: 206d 6f72 650a 2020 2020 2020 2020 2020 more. \n+0000d920: 2020 7265 7475 726e 206c 656e 2864 6174 return len(dat\n+0000d930: 6129 202d 2065 6e64 0a0a 2020 2020 2020 a) - end.. \n+0000d940: 2020 2320 5765 2063 616e 2063 6f6e 7375 # We can consu\n+0000d950: 6d65 2061 2066 756c 6c20 6672 616d 650a me a full frame.\n+0000d960: 2020 2020 2020 2020 7365 6c66 2e66 7261 self.fra\n+0000d970: 6d65 5f72 6563 6569 7665 6428 6461 7461 me_received(data\n+0000d980: 5b73 7461 7274 3a65 6e64 5d29 0a20 2020 [start:end]). \n+0000d990: 2020 2020 2072 6574 7572 6e20 656e 640a return end.\n+0000d9a0: 0a20 2020 2064 6566 2063 6f6e 6e65 6374 . def connect\n+0000d9b0: 696f 6e5f 6d61 6465 2873 656c 662c 2074 ion_made(self, t\n+0000d9c0: 7261 6e73 706f 7274 3a20 6173 796e 6369 ransport: asynci\n+0000d9d0: 6f2e 4261 7365 5472 616e 7370 6f72 7429 o.BaseTransport)\n+0000d9e0: 202d 3e20 4e6f 6e65 3a0a 2020 2020 2020 -> None:. \n+0000d9f0: 2020 6c6f 6767 6572 2e64 6562 7567 2827 logger.debug('\n+0000da00: 636f 6e6e 6563 7469 6f6e 5f6d 6164 6528 connection_made(\n+0000da10: 2573 2927 2c20 7472 616e 7370 6f72 7429 %s)', transport)\n+0000da20: 0a20 2020 2020 2020 2061 7373 6572 7420 . assert \n+0000da30: 6973 696e 7374 616e 6365 2874 7261 6e73 isinstance(trans\n+0000da40: 706f 7274 2c20 6173 796e 6369 6f2e 5472 port, asyncio.Tr\n+0000da50: 616e 7370 6f72 7429 0a20 2020 2020 2020 ansport). \n+0000da60: 2073 656c 662e 7472 616e 7370 6f72 7420 self.transport \n+0000da70: 3d20 7472 616e 7370 6f72 740a 2020 2020 = transport. \n+0000da80: 2020 2020 7365 6c66 2e64 6f5f 7265 6164 self.do_read\n+0000da90: 7928 290a 0a20 2020 2020 2020 2069 6620 y().. if \n+0000daa0: 7365 6c66 2e5f 636c 6f73 6564 3a0a 2020 self._closed:. \n+0000dab0: 2020 2020 2020 2020 2020 6c6f 6767 6572 logger\n+0000dac0: 2e64 6562 7567 2827 2020 6275 7420 7468 .debug(' but th\n+0000dad0: 6520 7072 6f74 6f63 6f6c 2061 6c72 6561 e protocol alrea\n+0000dae0: 6479 2077 6173 2063 6c6f 7365 642c 2073 dy was closed, s\n+0000daf0: 6f20 636c 6f73 696e 6720 7472 616e 7370 o closing transp\n+0000db00: 6f72 7427 290a 2020 2020 2020 2020 2020 ort'). \n+0000db10: 2020 7472 616e 7370 6f72 742e 636c 6f73 transport.clos\n+0000db20: 6528 290a 0a20 2020 2064 6566 2063 6f6e e().. def con\n+0000db30: 6e65 6374 696f 6e5f 6c6f 7374 2873 656c nection_lost(sel\n+0000db40: 662c 2065 7863 3a20 2745 7863 6570 7469 f, exc: 'Excepti\n+0000db50: 6f6e 207c 204e 6f6e 6527 2920 2d3e 204e on | None') -> N\n+0000db60: 6f6e 653a 0a20 2020 2020 2020 206c 6f67 one:. log\n+0000db70: 6765 722e 6465 6275 6728 2763 6f6e 6e65 ger.debug('conne\n+0000db80: 6374 696f 6e5f 6c6f 7374 2729 0a20 2020 ction_lost'). \n+0000db90: 2020 2020 2061 7373 6572 7420 7365 6c66 assert self\n+0000dba0: 2e74 7261 6e73 706f 7274 2069 7320 6e6f .transport is no\n+0000dbb0: 7420 4e6f 6e65 0a20 2020 2020 2020 2073 t None. s\n+0000dbc0: 656c 662e 7472 616e 7370 6f72 7420 3d20 elf.transport = \n+0000dbd0: 4e6f 6e65 0a20 2020 2020 2020 2073 656c None. sel\n+0000dbe0: 662e 636c 6f73 6528 6578 6329 0a0a 2020 f.close(exc).. \n+0000dbf0: 2020 6465 6620 636c 6f73 6528 7365 6c66 def close(self\n+0000dc00: 2c20 6578 633a 2027 4578 6365 7074 696f , exc: 'Exceptio\n+0000dc10: 6e20 7c20 4e6f 6e65 2720 3d20 4e6f 6e65 n | None' = None\n+0000dc20: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n+0000dc30: 2020 2069 6620 7365 6c66 2e5f 636c 6f73 if self._clos\n+0000dc40: 6564 3a0a 2020 2020 2020 2020 2020 2020 ed:. \n+0000dc50: 7265 7475 726e 0a20 2020 2020 2020 2073 return. s\n+0000dc60: 656c 662e 5f63 6c6f 7365 6420 3d20 5472 elf._closed = Tr\n+0000dc70: 7565 0a0a 2020 2020 2020 2020 6966 2073 ue.. if s\n+0000dc80: 656c 662e 7472 616e 7370 6f72 743a 0a20 elf.transport:. \n+0000dc90: 2020 2020 2020 2020 2020 2073 656c 662e self.\n+0000dca0: 7472 616e 7370 6f72 742e 636c 6f73 6528 transport.close(\n+0000dcb0: 290a 0a20 2020 2020 2020 2073 656c 662e ).. self.\n+0000dcc0: 646f 5f63 6c6f 7365 6428 6578 6329 0a0a do_closed(exc)..\n+0000dcd0: 2020 2020 6465 6620 7772 6974 655f 6368 def write_ch\n+0000dce0: 616e 6e65 6c5f 6461 7461 2873 656c 662c annel_data(self,\n+0000dcf0: 2063 6861 6e6e 656c 3a20 7374 722c 2070 channel: str, p\n+0000dd00: 6179 6c6f 6164 3a20 6279 7465 7329 202d ayload: bytes) -\n+0000dd10: 3e20 4e6f 6e65 3a0a 2020 2020 2020 2020 > None:. \n+0000dd20: 2222 2253 656e 6420 6120 6769 7665 6e20 \"\"\"Send a given \n+0000dd30: 7061 796c 6f61 6420 2862 7974 6573 2920 payload (bytes) \n+0000dd40: 6f6e 2063 6861 6e6e 656c 2028 7374 7269 on channel (stri\n+0000dd50: 6e67 2922 2222 0a20 2020 2020 2020 2023 ng)\"\"\". #\n+0000dd60: 2043 6861 6e6e 656c 2069 7320 6365 7274 Channel is cert\n+0000dd70: 6169 6e6c 7920 6173 6369 6920 2861 7320 ainly ascii (as \n+0000dd80: 656e 666f 7263 6564 2062 7920 2e65 6e63 enforced by .enc\n+0000dd90: 6f64 6528 2920 6265 6c6f 7729 0a20 2020 ode() below). \n+0000dda0: 2020 2020 2066 7261 6d65 5f6c 656e 6774 frame_lengt\n+0000ddb0: 6820 3d20 6c65 6e28 6368 616e 6e65 6c20 h = len(channel \n+0000ddc0: 2b20 275c 6e27 2920 2b20 6c65 6e28 7061 + '\\n') + len(pa\n+0000ddd0: 796c 6f61 6429 0a20 2020 2020 2020 2068 yload). h\n+0000dde0: 6561 6465 7220 3d20 6627 7b66 7261 6d65 eader = f'{frame\n+0000ddf0: 5f6c 656e 6774 687d 5c6e 7b63 6861 6e6e _length}\\n{chann\n+0000de00: 656c 7d5c 6e27 2e65 6e63 6f64 6528 2761 el}\\n'.encode('a\n+0000de10: 7363 6969 2729 0a20 2020 2020 2020 2069 scii'). i\n+0000de20: 6620 7365 6c66 2e74 7261 6e73 706f 7274 f self.transport\n+0000de30: 2069 7320 6e6f 7420 4e6f 6e65 3a0a 2020 is not None:. \n+0000de40: 2020 2020 2020 2020 2020 6c6f 6767 6572 logger\n+0000de50: 2e64 6562 7567 2827 7772 6974 696e 6720 .debug('writing \n+0000de60: 746f 2074 7261 6e73 706f 7274 2025 7327 to transport %s'\n+0000de70: 2c20 7365 6c66 2e74 7261 6e73 706f 7274 , self.transport\n+0000de80: 290a 2020 2020 2020 2020 2020 2020 7365 ). se\n+0000de90: 6c66 2e74 7261 6e73 706f 7274 2e77 7269 lf.transport.wri\n+0000dea0: 7465 2868 6561 6465 7220 2b20 7061 796c te(header + payl\n+0000deb0: 6f61 6429 0a20 2020 2020 2020 2065 6c73 oad). els\n+0000dec0: 653a 0a20 2020 2020 2020 2020 2020 206c e:. l\n+0000ded0: 6f67 6765 722e 6465 6275 6728 2763 616e ogger.debug('can\n+0000dee0: 6e6f 7420 7772 6974 6520 746f 2063 6c6f not write to clo\n+0000def0: 7365 6420 7472 616e 7370 6f72 7427 290a sed transport').\n+0000df00: 0a20 2020 2064 6566 2077 7269 7465 5f63 . def write_c\n+0000df10: 6f6e 7472 6f6c 2873 656c 662c 205f 6d73 ontrol(self, _ms\n+0000df20: 673a 2027 4a73 6f6e 4f62 6a65 6374 207c g: 'JsonObject |\n+0000df30: 204e 6f6e 6527 203d 204e 6f6e 652c 202a None' = None, *\n+0000df40: 2a6b 7761 7267 733a 204a 736f 6e56 616c *kwargs: JsonVal\n+0000df50: 7565 2920 2d3e 204e 6f6e 653a 0a20 2020 ue) -> None:. \n+0000df60: 2020 2020 2022 2222 5772 6974 6520 6120 \"\"\"Write a \n+0000df70: 636f 6e74 726f 6c20 6d65 7373 6167 652e control message.\n+0000df80: 2020 5365 6520 6a73 6f6e 7574 696c 2e63 See jsonutil.c\n+0000df90: 7265 6174 655f 6f62 6a65 6374 2829 2066 reate_object() f\n+0000dfa0: 6f72 2064 6574 6169 6c73 2e22 2222 0a20 or details.\"\"\". \n+0000dfb0: 2020 2020 2020 206c 6f67 6765 722e 6465 logger.de\n+0000dfc0: 6275 6728 2773 656e 6469 6e67 2063 6f6e bug('sending con\n+0000dfd0: 7472 6f6c 206d 6573 7361 6765 2025 7220 trol message %r \n+0000dfe0: 2572 272c 205f 6d73 672c 206b 7761 7267 %r', _msg, kwarg\n+0000dff0: 7329 0a20 2020 2020 2020 2070 7265 7474 s). prett\n+0000e000: 7920 3d20 6a73 6f6e 2e64 756d 7073 2863 y = json.dumps(c\n+0000e010: 7265 6174 655f 6f62 6a65 6374 285f 6d73 reate_object(_ms\n+0000e020: 672c 206b 7761 7267 7329 2c20 696e 6465 g, kwargs), inde\n+0000e030: 6e74 3d32 2920 2b20 275c 6e27 0a20 2020 nt=2) + '\\n'. \n+0000e040: 2020 2020 2073 656c 662e 7772 6974 655f self.write_\n+0000e050: 6368 616e 6e65 6c5f 6461 7461 2827 272c channel_data('',\n+0000e060: 2070 7265 7474 792e 656e 636f 6465 2829 pretty.encode()\n+0000e070: 290a 0a20 2020 2064 6566 2064 6174 615f ).. def data_\n+0000e080: 7265 6365 6976 6564 2873 656c 662c 2064 received(self, d\n+0000e090: 6174 613a 2062 7974 6573 2920 2d3e 204e ata: bytes) -> N\n+0000e0a0: 6f6e 653a 0a20 2020 2020 2020 2074 7279 one:. try\n+0000e0b0: 3a0a 2020 2020 2020 2020 2020 2020 7365 :. se\n+0000e0c0: 6c66 2e62 7566 6665 7220 2b3d 2064 6174 lf.buffer += dat\n+0000e0d0: 610a 2020 2020 2020 2020 2020 2020 7768 a. wh\n+0000e0e0: 696c 6520 7365 6c66 2e62 7566 6665 723a ile self.buffer:\n+0000e0f0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+0000e100: 2072 6573 756c 7420 3d20 7365 6c66 2e63 result = self.c\n+0000e110: 6f6e 7375 6d65 5f6f 6e65 5f66 7261 6d65 onsume_one_frame\n+0000e120: 2873 656c 662e 6275 6666 6572 290a 2020 (self.buffer). \n+0000e130: 2020 2020 2020 2020 2020 2020 2020 6966 if\n+0000e140: 2072 6573 756c 7420 3c3d 2030 3a0a 2020 result <= 0:. \n+0000e150: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0000e160: 2020 7265 7475 726e 0a20 2020 2020 2020 return. \n+0000e170: 2020 2020 2020 2020 2073 656c 662e 6275 self.bu\n+0000e180: 6666 6572 203d 2073 656c 662e 6275 6666 ffer = self.buff\n+0000e190: 6572 5b72 6573 756c 743a 5d0a 2020 2020 er[result:]. \n+0000e1a0: 2020 2020 6578 6365 7074 2043 6f63 6b70 except Cockp\n+0000e1b0: 6974 5072 6f74 6f63 6f6c 4572 726f 7220 itProtocolError \n+0000e1c0: 6173 2065 7863 3a0a 2020 2020 2020 2020 as exc:. \n+0000e1d0: 2020 2020 7365 6c66 2e63 6c6f 7365 2865 self.close(e\n+0000e1e0: 7863 290a 0a20 2020 2064 6566 2065 6f66 xc).. def eof\n+0000e1f0: 5f72 6563 6569 7665 6428 7365 6c66 2920 _received(self) \n+0000e200: 2d3e 2062 6f6f 6c3a 0a20 2020 2020 2020 -> bool:. \n+0000e210: 2072 6574 7572 6e20 4661 6c73 650a 0a0a return False...\n+0000e220: 2320 4865 6c70 6675 6c20 6675 6e63 7469 # Helpful functi\n+0000e230: 6f6e 616c 6974 7920 666f 7220 2273 6572 onality for \"ser\n+0000e240: 7665 7222 2d73 6964 6520 7072 6f74 6f63 ver\"-side protoc\n+0000e250: 6f6c 2069 6d70 6c65 6d65 6e74 6174 696f ol implementatio\n+0000e260: 6e73 0a63 6c61 7373 2043 6f63 6b70 6974 ns.class Cockpit\n+0000e270: 5072 6f74 6f63 6f6c 5365 7276 6572 2843 ProtocolServer(C\n+0000e280: 6f63 6b70 6974 5072 6f74 6f63 6f6c 293a ockpitProtocol):\n+0000e290: 0a20 2020 2069 6e69 745f 686f 7374 3a20 . init_host: \n+0000e2a0: 2773 7472 207c 204e 6f6e 6527 203d 204e 'str | None' = N\n+0000e2b0: 6f6e 650a 2020 2020 6175 7468 6f72 697a one. authoriz\n+0000e2c0: 6174 696f 6e73 3a20 2764 6963 745b 7374 ations: 'dict[st\n+0000e2d0: 722c 2061 7379 6e63 696f 2e46 7574 7572 r, asyncio.Futur\n+0000e2e0: 655b 7374 725d 5d20 7c20 4e6f 6e65 2720 e[str]] | None' \n+0000e2f0: 3d20 4e6f 6e65 0a0a 2020 2020 6465 6620 = None.. def \n+0000e300: 646f 5f73 656e 645f 696e 6974 2873 656c do_send_init(sel\n+0000e310: 6629 202d 3e20 4e6f 6e65 3a0a 2020 2020 f) -> None:. \n+0000e320: 2020 2020 7261 6973 6520 4e6f 7449 6d70 raise NotImp\n+0000e330: 6c65 6d65 6e74 6564 4572 726f 720a 0a20 lementedError.. \n+0000e340: 2020 2064 6566 2064 6f5f 696e 6974 2873 def do_init(s\n+0000e350: 656c 662c 206d 6573 7361 6765 3a20 4a73 elf, message: Js\n+0000e360: 6f6e 4f62 6a65 6374 2920 2d3e 204e 6f6e onObject) -> Non\n+0000e370: 653a 0a20 2020 2020 2020 2070 6173 730a e:. pass.\n+0000e380: 0a20 2020 2064 6566 2064 6f5f 6b69 6c6c . def do_kill\n+0000e390: 2873 656c 662c 2068 6f73 743a 2027 7374 (self, host: 'st\n+0000e3a0: 7220 7c20 4e6f 6e65 272c 2067 726f 7570 r | None', group\n+0000e3b0: 3a20 2773 7472 207c 204e 6f6e 6527 2c20 : 'str | None', \n+0000e3c0: 6d65 7373 6167 653a 204a 736f 6e4f 626a message: JsonObj\n+0000e3d0: 6563 7429 202d 3e20 4e6f 6e65 3a0a 2020 ect) -> None:. \n+0000e3e0: 2020 2020 2020 7261 6973 6520 4e6f 7449 raise NotI\n+0000e3f0: 6d70 6c65 6d65 6e74 6564 4572 726f 720a mplementedError.\n+0000e400: 0a20 2020 2064 6566 2074 7261 6e73 706f . def transpo\n+0000e410: 7274 5f63 6f6e 7472 6f6c 5f72 6563 6569 rt_control_recei\n+0000e420: 7665 6428 7365 6c66 2c20 636f 6d6d 616e ved(self, comman\n+0000e430: 643a 2073 7472 2c20 6d65 7373 6167 653a d: str, message:\n+0000e440: 204a 736f 6e4f 626a 6563 7429 202d 3e20 JsonObject) -> \n+0000e450: 4e6f 6e65 3a0a 2020 2020 2020 2020 6966 None:. if\n+0000e460: 2063 6f6d 6d61 6e64 203d 3d20 2769 6e69 command == 'ini\n+0000e470: 7427 3a0a 2020 2020 2020 2020 2020 2020 t':. \n+0000e480: 6966 2067 6574 5f69 6e74 286d 6573 7361 if get_int(messa\n+0000e490: 6765 2c20 2776 6572 7369 6f6e 2729 2021 ge, 'version') !\n+0000e4a0: 3d20 313a 0a20 2020 2020 2020 2020 2020 = 1:. \n+0000e4b0: 2020 2020 2072 6169 7365 2043 6f63 6b70 raise Cockp\n+0000e4c0: 6974 5072 6f74 6f63 6f6c 4572 726f 7228 itProtocolError(\n+0000e4d0: 2769 6e63 6f72 7265 6374 2076 6572 7369 'incorrect versi\n+0000e4e0: 6f6e 206e 756d 6265 7227 290a 2020 2020 on number'). \n+0000e4f0: 2020 2020 2020 2020 7365 6c66 2e69 6e69 self.ini\n+0000e500: 745f 686f 7374 203d 2067 6574 5f73 7472 t_host = get_str\n+0000e510: 286d 6573 7361 6765 2c20 2768 6f73 7427 (message, 'host'\n+0000e520: 290a 2020 2020 2020 2020 2020 2020 7365 ). se\n+0000e530: 6c66 2e64 6f5f 696e 6974 286d 6573 7361 lf.do_init(messa\n+0000e540: 6765 290a 2020 2020 2020 2020 656c 6966 ge). elif\n+0000e550: 2063 6f6d 6d61 6e64 203d 3d20 276b 696c command == 'kil\n+0000e560: 6c27 3a0a 2020 2020 2020 2020 2020 2020 l':. \n+0000e570: 7365 6c66 2e64 6f5f 6b69 6c6c 2867 6574 self.do_kill(get\n+0000e580: 5f73 7472 5f6f 725f 6e6f 6e65 286d 6573 _str_or_none(mes\n+0000e590: 7361 6765 2c20 2768 6f73 7427 2c20 4e6f sage, 'host', No\n+0000e5a0: 6e65 292c 2067 6574 5f73 7472 5f6f 725f ne), get_str_or_\n+0000e5b0: 6e6f 6e65 286d 6573 7361 6765 2c20 2767 none(message, 'g\n+0000e5c0: 726f 7570 272c 204e 6f6e 6529 2c20 6d65 roup', None), me\n+0000e5d0: 7373 6167 6529 0a20 2020 2020 2020 2065 ssage). e\n+0000e5e0: 6c69 6620 636f 6d6d 616e 6420 3d3d 2027 lif command == '\n+0000e5f0: 6175 7468 6f72 697a 6527 3a0a 2020 2020 authorize':. \n+0000e600: 2020 2020 2020 2020 7365 6c66 2e64 6f5f self.do_\n+0000e610: 6175 7468 6f72 697a 6528 6d65 7373 6167 authorize(messag\n+0000e620: 6529 0a20 2020 2020 2020 2065 6c73 653a e). else:\n+0000e630: 0a20 2020 2020 2020 2020 2020 2072 6169 . rai\n+0000e640: 7365 2043 6f63 6b70 6974 5072 6f74 6f63 se CockpitProtoc\n+0000e650: 6f6c 4572 726f 7228 6627 756e 6578 7065 olError(f'unexpe\n+0000e660: 6374 6564 2063 6f6e 7472 6f6c 206d 6573 cted control mes\n+0000e670: 7361 6765 207b 636f 6d6d 616e 647d 2072 sage {command} r\n+0000e680: 6563 6569 7665 6427 290a 0a20 2020 2064 eceived').. d\n+0000e690: 6566 2064 6f5f 7265 6164 7928 7365 6c66 ef do_ready(self\n+0000e6a0: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n+0000e6b0: 2020 2073 656c 662e 646f 5f73 656e 645f self.do_send_\n+0000e6c0: 696e 6974 2829 0a0a 2020 2020 2320 6175 init().. # au\n+0000e6d0: 7468 6f72 697a 6520 7265 7175 6573 742f thorize request/\n+0000e6e0: 7265 7370 6f6e 7365 2041 5049 0a20 2020 response API. \n+0000e6f0: 2061 7379 6e63 2064 6566 2072 6571 7565 async def reque\n+0000e700: 7374 5f61 7574 686f 7269 7a61 7469 6f6e st_authorization\n+0000e710: 280a 2020 2020 2020 2020 7365 6c66 2c20 (. self, \n+0000e720: 6368 616c 6c65 6e67 653a 2073 7472 2c20 challenge: str, \n+0000e730: 7469 6d65 6f75 743a 2027 696e 7420 7c20 timeout: 'int | \n+0000e740: 4e6f 6e65 2720 3d20 4e6f 6e65 2c20 2a2a None' = None, **\n+0000e750: 6b77 6172 6773 3a20 4a73 6f6e 5661 6c75 kwargs: JsonValu\n+0000e760: 650a 2020 2020 2920 2d3e 2073 7472 3a0a e. ) -> str:.\n+0000e770: 2020 2020 2020 2020 6966 2073 656c 662e if self.\n+0000e780: 6175 7468 6f72 697a 6174 696f 6e73 2069 authorizations i\n+0000e790: 7320 4e6f 6e65 3a0a 2020 2020 2020 2020 s None:. \n+0000e7a0: 2020 2020 7365 6c66 2e61 7574 686f 7269 self.authori\n+0000e7b0: 7a61 7469 6f6e 7320 3d20 7b7d 0a20 2020 zations = {}. \n+0000e7c0: 2020 2020 2063 6f6f 6b69 6520 3d20 7374 cookie = st\n+0000e7d0: 7228 7575 6964 2e75 7569 6434 2829 290a r(uuid.uuid4()).\n+0000e7e0: 2020 2020 2020 2020 6675 7475 7265 203d future =\n+0000e7f0: 2061 7379 6e63 696f 2e67 6574 5f72 756e asyncio.get_run\n+0000e800: 6e69 6e67 5f6c 6f6f 7028 292e 6372 6561 ning_loop().crea\n+0000e810: 7465 5f66 7574 7572 6528 290a 2020 2020 te_future(). \n+0000e820: 2020 2020 7472 793a 0a20 2020 2020 2020 try:. \n+0000e830: 2020 2020 2073 656c 662e 6175 7468 6f72 self.author\n+0000e840: 697a 6174 696f 6e73 5b63 6f6f 6b69 655d izations[cookie]\n+0000e850: 203d 2066 7574 7572 650a 2020 2020 2020 = future. \n+0000e860: 2020 2020 2020 7365 6c66 2e77 7269 7465 self.write\n+0000e870: 5f63 6f6e 7472 6f6c 284e 6f6e 652c 2063 _control(None, c\n+0000e880: 6f6d 6d61 6e64 3d27 6175 7468 6f72 697a ommand='authoriz\n+0000e890: 6527 2c20 6368 616c 6c65 6e67 653d 6368 e', challenge=ch\n+0000e8a0: 616c 6c65 6e67 652c 2063 6f6f 6b69 653d allenge, cookie=\n+0000e8b0: 636f 6f6b 6965 2c20 2a2a 6b77 6172 6773 cookie, **kwargs\n+0000e8c0: 290a 2020 2020 2020 2020 2020 2020 7265 ). re\n+0000e8d0: 7475 726e 2061 7761 6974 2061 7379 6e63 turn await async\n+0000e8e0: 696f 2e77 6169 745f 666f 7228 6675 7475 io.wait_for(futu\n+0000e8f0: 7265 2c20 7469 6d65 6f75 7429 0a20 2020 re, timeout). \n+0000e900: 2020 2020 2066 696e 616c 6c79 3a0a 2020 finally:. \n+0000e910: 2020 2020 2020 2020 2020 7365 6c66 2e61 self.a\n+0000e920: 7574 686f 7269 7a61 7469 6f6e 732e 706f uthorizations.po\n+0000e930: 7028 636f 6f6b 6965 290a 0a20 2020 2064 p(cookie).. d\n+0000e940: 6566 2064 6f5f 6175 7468 6f72 697a 6528 ef do_authorize(\n+0000e950: 7365 6c66 2c20 6d65 7373 6167 653a 204a self, message: J\n+0000e960: 736f 6e4f 626a 6563 7429 202d 3e20 4e6f sonObject) -> No\n+0000e970: 6e65 3a0a 2020 2020 2020 2020 636f 6f6b ne:. cook\n+0000e980: 6965 203d 2067 6574 5f73 7472 286d 6573 ie = get_str(mes\n+0000e990: 7361 6765 2c20 2763 6f6f 6b69 6527 290a sage, 'cookie').\n+0000e9a0: 2020 2020 2020 2020 7265 7370 6f6e 7365 response\n+0000e9b0: 203d 2067 6574 5f73 7472 286d 6573 7361 = get_str(messa\n+0000e9c0: 6765 2c20 2772 6573 706f 6e73 6527 290a ge, 'response').\n+0000e9d0: 0a20 2020 2020 2020 2069 6620 7365 6c66 . if self\n+0000e9e0: 2e61 7574 686f 7269 7a61 7469 6f6e 7320 .authorizations \n+0000e9f0: 6973 204e 6f6e 6520 6f72 2063 6f6f 6b69 is None or cooki\n+0000ea00: 6520 6e6f 7420 696e 2073 656c 662e 6175 e not in self.au\n+0000ea10: 7468 6f72 697a 6174 696f 6e73 3a0a 2020 thorizations:. \n+0000ea20: 2020 2020 2020 2020 2020 6c6f 6767 6572 logger\n+0000ea30: 2e77 6172 6e69 6e67 2827 6e6f 206d 6174 .warning('no mat\n+0000ea40: 6368 696e 6720 6175 7468 6f72 697a 6520 ching authorize \n+0000ea50: 7265 7175 6573 7427 290a 2020 2020 2020 request'). \n+0000ea60: 2020 2020 2020 7265 7475 726e 0a0a 2020 return.. \n+0000ea70: 2020 2020 2020 7365 6c66 2e61 7574 686f self.autho\n+0000ea80: 7269 7a61 7469 6f6e 735b 636f 6f6b 6965 rizations[cookie\n+0000ea90: 5d2e 7365 745f 7265 7375 6c74 2872 6573 ].set_result(res\n+0000eaa0: 706f 6e73 6529 0a27 2727 2c0a 2020 2763 ponse).''',. 'c\n+0000eab0: 6f63 6b70 6974 2f63 6861 6e6e 656c 2e70 ockpit/channel.p\n+0000eac0: 7927 3a20 7227 2727 2320 5468 6973 2066 y': r'''# This f\n+0000ead0: 696c 6520 6973 2070 6172 7420 6f66 2043 ile is part of C\n+0000eae0: 6f63 6b70 6974 2e0a 230a 2320 436f 7079 ockpit..#.# Copy\n+0000eaf0: 7269 6768 7420 2843 2920 3230 3232 2052 right (C) 2022 R\n+0000eb00: 6564 2048 6174 2c20 496e 632e 0a23 0a23 ed Hat, Inc..#.#\n+0000eb10: 2054 6869 7320 7072 6f67 7261 6d20 6973 This program is\n+0000eb20: 2066 7265 6520 736f 6674 7761 7265 3a20 free software: \n+0000eb30: 796f 7520 6361 6e20 7265 6469 7374 7269 you can redistri\n+0000eb40: 6275 7465 2069 7420 616e 642f 6f72 206d bute it and/or m\n+0000eb50: 6f64 6966 790a 2320 6974 2075 6e64 6572 odify.# it under\n+0000eb60: 2074 6865 2074 6572 6d73 206f 6620 7468 the terms of th\n+0000eb70: 6520 474e 5520 4765 6e65 7261 6c20 5075 e GNU General Pu\n+0000eb80: 626c 6963 204c 6963 656e 7365 2061 7320 blic License as \n+0000eb90: 7075 626c 6973 6865 6420 6279 0a23 2074 published by.# t\n+0000eba0: 6865 2046 7265 6520 536f 6674 7761 7265 he Free Software\n+0000ebb0: 2046 6f75 6e64 6174 696f 6e2c 2065 6974 Foundation, eit\n+0000ebc0: 6865 7220 7665 7273 696f 6e20 3320 6f66 her version 3 of\n+0000ebd0: 2074 6865 204c 6963 656e 7365 2c20 6f72 the License, or\n+0000ebe0: 0a23 2028 6174 2079 6f75 7220 6f70 7469 .# (at your opti\n+0000ebf0: 6f6e 2920 616e 7920 6c61 7465 7220 7665 on) any later ve\n+0000ec00: 7273 696f 6e2e 0a23 0a23 2054 6869 7320 rsion..#.# This \n+0000ec10: 7072 6f67 7261 6d20 6973 2064 6973 7472 program is distr\n+0000ec20: 6962 7574 6564 2069 6e20 7468 6520 686f ibuted in the ho\n+0000ec30: 7065 2074 6861 7420 6974 2077 696c 6c20 pe that it will \n+0000ec40: 6265 2075 7365 6675 6c2c 0a23 2062 7574 be useful,.# but\n+0000ec50: 2057 4954 484f 5554 2041 4e59 2057 4152 WITHOUT ANY WAR\n+0000ec60: 5241 4e54 593b 2077 6974 686f 7574 2065 RANTY; without e\n+0000ec70: 7665 6e20 7468 6520 696d 706c 6965 6420 ven the implied \n+0000ec80: 7761 7272 616e 7479 206f 660a 2320 4d45 warranty of.# ME\n+0000ec90: 5243 4841 4e54 4142 494c 4954 5920 6f72 RCHANTABILITY or\n+0000eca0: 2046 4954 4e45 5353 2046 4f52 2041 2050 FITNESS FOR A P\n+0000ecb0: 4152 5449 4355 4c41 5220 5055 5250 4f53 ARTICULAR PURPOS\n+0000ecc0: 452e 2020 5365 6520 7468 650a 2320 474e E. See the.# GN\n+0000ecd0: 5520 4765 6e65 7261 6c20 5075 626c 6963 U General Public\n+0000ece0: 204c 6963 656e 7365 2066 6f72 206d 6f72 License for mor\n+0000ecf0: 6520 6465 7461 696c 732e 0a23 0a23 2059 e details..#.# Y\n+0000ed00: 6f75 2073 686f 756c 6420 6861 7665 2072 ou should have r\n+0000ed10: 6563 6569 7665 6420 6120 636f 7079 206f eceived a copy o\n+0000ed20: 6620 7468 6520 474e 5520 4765 6e65 7261 f the GNU Genera\n+0000ed30: 6c20 5075 626c 6963 204c 6963 656e 7365 l Public License\n+0000ed40: 0a23 2061 6c6f 6e67 2077 6974 6820 7468 .# along with th\n+0000ed50: 6973 2070 726f 6772 616d 2e20 2049 6620 is program. If \n+0000ed60: 6e6f 742c 2073 6565 203c 6874 7470 733a not, see ...impor\n+0000ed90: 7420 6173 796e 6369 6f0a 696d 706f 7274 t asyncio.import\n+0000eda0: 206a 736f 6e0a 696d 706f 7274 206c 6f67 json.import log\n+0000edb0: 6769 6e67 0a69 6d70 6f72 7420 7472 6163 ging.import trac\n+0000edc0: 6562 6163 6b0a 6672 6f6d 2074 7970 696e eback.from typin\n+0000edd0: 6720 696d 706f 7274 2042 696e 6172 7949 g import BinaryI\n+0000ede0: 4f2c 2043 6c61 7373 5661 722c 2044 6963 O, ClassVar, Dic\n+0000edf0: 742c 2047 656e 6572 6174 6f72 2c20 4c69 t, Generator, Li\n+0000ee00: 7374 2c20 4d61 7070 696e 672c 204f 7074 st, Mapping, Opt\n+0000ee10: 696f 6e61 6c2c 2053 6571 7565 6e63 652c ional, Sequence,\n+0000ee20: 2053 6574 2c20 5475 706c 652c 2054 7970 Set, Tuple, Typ\n+0000ee30: 650a 0a66 726f 6d20 2e6a 736f 6e75 7469 e..from .jsonuti\n+0000ee40: 6c20 696d 706f 7274 204a 736f 6e45 7272 l import JsonErr\n+0000ee50: 6f72 2c20 4a73 6f6e 4f62 6a65 6374 2c20 or, JsonObject, \n+0000ee60: 4a73 6f6e 5661 6c75 652c 2063 7265 6174 JsonValue, creat\n+0000ee70: 655f 6f62 6a65 6374 2c20 6765 745f 626f e_object, get_bo\n+0000ee80: 6f6c 2c20 6765 745f 656e 756d 2c20 6765 ol, get_enum, ge\n+0000ee90: 745f 7374 720a 6672 6f6d 202e 7072 6f74 t_str.from .prot\n+0000eea0: 6f63 6f6c 2069 6d70 6f72 7420 436f 636b ocol import Cock\n+0000eeb0: 7069 7450 726f 626c 656d 0a66 726f 6d20 pitProblem.from \n+0000eec0: 2e72 6f75 7465 7220 696d 706f 7274 2045 .router import E\n+0000eed0: 6e64 706f 696e 742c 2052 6f75 7465 722c ndpoint, Router,\n+0000eee0: 2052 6f75 7469 6e67 5275 6c65 0a0a 6c6f RoutingRule..lo\n+0000eef0: 6767 6572 203d 206c 6f67 6769 6e67 2e67 gger = logging.g\n+0000ef00: 6574 4c6f 6767 6572 285f 5f6e 616d 655f etLogger(__name_\n+0000ef10: 5f29 0a0a 0a63 6c61 7373 2043 6861 6e6e _)...class Chann\n+0000ef20: 656c 526f 7574 696e 6752 756c 6528 526f elRoutingRule(Ro\n+0000ef30: 7574 696e 6752 756c 6529 3a0a 2020 2020 utingRule):. \n+0000ef40: 7461 626c 653a 2044 6963 745b 7374 722c table: Dict[str,\n+0000ef50: 204c 6973 745b 5479 7065 5b27 4368 616e List[Type['Chan\n+0000ef60: 6e65 6c27 5d5d 5d0a 0a20 2020 2064 6566 nel']]].. def\n+0000ef70: 205f 5f69 6e69 745f 5f28 7365 6c66 2c20 __init__(self, \n+0000ef80: 726f 7574 6572 3a20 526f 7574 6572 2c20 router: Router, \n+0000ef90: 6368 616e 6e65 6c5f 7479 7065 733a 204c channel_types: L\n+0000efa0: 6973 745b 5479 7065 5b27 4368 616e 6e65 ist[Type['Channe\n+0000efb0: 6c27 5d5d 293a 0a20 2020 2020 2020 2073 l']]):. s\n+0000efc0: 7570 6572 2829 2e5f 5f69 6e69 745f 5f28 uper().__init__(\n+0000efd0: 726f 7574 6572 290a 2020 2020 2020 2020 router). \n+0000efe0: 7365 6c66 2e74 6162 6c65 203d 207b 7d0a self.table = {}.\n+0000eff0: 0a20 2020 2020 2020 2023 2053 6f72 7420 . # Sort \n+0000f000: 7468 6520 6368 616e 6e65 6c73 2069 6e74 the channels int\n+0000f010: 6f20 6275 636b 6574 7320 6279 2070 6179 o buckets by pay\n+0000f020: 6c6f 6164 2074 7970 650a 2020 2020 2020 load type. \n+0000f030: 2020 666f 7220 636c 7320 696e 2063 6861 for cls in cha\n+0000f040: 6e6e 656c 5f74 7970 6573 3a0a 2020 2020 nnel_types:. \n+0000f050: 2020 2020 2020 2020 656e 7472 7920 3d20 entry = \n+0000f060: 7365 6c66 2e74 6162 6c65 2e73 6574 6465 self.table.setde\n+0000f070: 6661 756c 7428 636c 732e 7061 796c 6f61 fault(cls.payloa\n+0000f080: 642c 205b 5d29 0a20 2020 2020 2020 2020 d, []). \n+0000f090: 2020 2065 6e74 7279 2e61 7070 656e 6428 entry.append(\n+0000f0a0: 636c 7329 0a0a 2020 2020 2020 2020 2320 cls).. # \n+0000f0b0: 5769 7468 696e 2065 6163 6820 6275 636b Within each buck\n+0000f0c0: 6574 2c20 736f 7274 2074 6865 2063 6861 et, sort the cha\n+0000f0d0: 6e6e 656c 7320 736f 2074 686f 7365 2077 nnels so those w\n+0000f0e0: 6974 6820 6d6f 7265 0a20 2020 2020 2020 ith more. \n+0000f0f0: 2023 2072 6573 7472 6963 7469 6f6e 7320 # restrictions \n+0000f100: 6172 6520 636f 6e73 6964 6572 6564 2066 are considered f\n+0000f110: 6972 7374 2e0a 2020 2020 2020 2020 666f irst.. fo\n+0000f120: 7220 656e 7472 7920 696e 2073 656c 662e r entry in self.\n+0000f130: 7461 626c 652e 7661 6c75 6573 2829 3a0a table.values():.\n+0000f140: 2020 2020 2020 2020 2020 2020 656e 7472 entr\n+0000f150: 792e 736f 7274 286b 6579 3d6c 616d 6264 y.sort(key=lambd\n+0000f160: 6120 636c 733a 206c 656e 2863 6c73 2e72 a cls: len(cls.r\n+0000f170: 6573 7472 6963 7469 6f6e 7329 2c20 7265 estrictions), re\n+0000f180: 7665 7273 653d 5472 7565 290a 0a20 2020 verse=True).. \n+0000f190: 2064 6566 2063 6865 636b 5f72 6573 7472 def check_restr\n+0000f1a0: 6963 7469 6f6e 7328 7365 6c66 2c20 7265 ictions(self, re\n+0000f1b0: 7374 7269 6374 696f 6e73 3a20 5365 7175 strictions: Sequ\n+0000f1c0: 656e 6365 5b54 7570 6c65 5b73 7472 2c20 ence[Tuple[str, \n+0000f1d0: 6f62 6a65 6374 5d5d 2c20 6f70 7469 6f6e object]], option\n+0000f1e0: 733a 204a 736f 6e4f 626a 6563 7429 202d s: JsonObject) -\n+0000f1f0: 3e20 626f 6f6c 3a0a 2020 2020 2020 2020 > bool:. \n+0000f200: 666f 7220 6b65 792c 2065 7870 6563 7465 for key, expecte\n+0000f210: 645f 7661 6c75 6520 696e 2072 6573 7472 d_value in restr\n+0000f220: 6963 7469 6f6e 733a 0a20 2020 2020 2020 ictions:. \n+0000f230: 2020 2020 206f 7572 5f76 616c 7565 203d our_value =\n+0000f240: 206f 7074 696f 6e73 2e67 6574 286b 6579 options.get(key\n+0000f250: 290a 0a20 2020 2020 2020 2020 2020 2023 ).. #\n+0000f260: 2049 6620 7468 6520 6d61 7463 6820 7275 If the match ru\n+0000f270: 6c65 2073 7065 6369 6669 6573 2074 6861 le specifies tha\n+0000f280: 7420 6120 7661 6c75 6520 6d75 7374 2062 t a value must b\n+0000f290: 6520 7072 6573 656e 7420 616e 640a 2020 e present and. \n+0000f2a0: 2020 2020 2020 2020 2020 2320 7765 2064 # we d\n+0000f2b0: 6f6e 2774 2068 6176 6520 6974 2c20 7468 on't have it, th\n+0000f2c0: 656e 2066 6169 6c2e 0a20 2020 2020 2020 en fail.. \n+0000f2d0: 2020 2020 2069 6620 6f75 725f 7661 6c75 if our_valu\n+0000f2e0: 6520 6973 204e 6f6e 653a 0a20 2020 2020 e is None:. \n+0000f2f0: 2020 2020 2020 2020 2020 2072 6574 7572 retur\n+0000f300: 6e20 4661 6c73 650a 0a20 2020 2020 2020 n False.. \n+0000f310: 2020 2020 2023 2049 6620 7468 6520 6d61 # If the ma\n+0000f320: 7463 6820 7275 6c65 2073 7065 6369 6669 tch rule specifi\n+0000f330: 6564 2061 2073 7065 6369 6669 6320 6578 ed a specific ex\n+0000f340: 7065 6374 6564 2076 616c 7565 2c20 616e pected value, an\n+0000f350: 640a 2020 2020 2020 2020 2020 2020 2320 d. # \n+0000f360: 6f75 7220 7661 6c75 6520 646f 6573 6e27 our value doesn'\n+0000f370: 7420 6d61 7463 6820 6974 2c20 7468 656e t match it, then\n+0000f380: 2066 6169 6c2e 0a20 2020 2020 2020 2020 fail.. \n+0000f390: 2020 2069 6620 6578 7065 6374 6564 5f76 if expected_v\n+0000f3a0: 616c 7565 2069 7320 6e6f 7420 4e6f 6e65 alue is not None\n+0000f3b0: 2061 6e64 206f 7572 5f76 616c 7565 2021 and our_value !\n+0000f3c0: 3d20 6578 7065 6374 6564 5f76 616c 7565 = expected_value\n+0000f3d0: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n+0000f3e0: 2020 7265 7475 726e 2046 616c 7365 0a0a return False..\n+0000f3f0: 2020 2020 2020 2020 2320 4576 6572 7974 # Everyt\n+0000f400: 6869 6e67 2063 6865 636b 6564 206f 7574 hing checked out\n+0000f410: 0a20 2020 2020 2020 2072 6574 7572 6e20 . return \n+0000f420: 5472 7565 0a0a 2020 2020 6465 6620 6170 True.. def ap\n+0000f430: 706c 795f 7275 6c65 2873 656c 662c 206f ply_rule(self, o\n+0000f440: 7074 696f 6e73 3a20 4a73 6f6e 4f62 6a65 ptions: JsonObje\n+0000f450: 6374 2920 2d3e 204f 7074 696f 6e61 6c5b ct) -> Optional[\n+0000f460: 2743 6861 6e6e 656c 275d 3a0a 2020 2020 'Channel']:. \n+0000f470: 2020 2020 6173 7365 7274 2073 656c 662e assert self.\n+0000f480: 726f 7574 6572 2069 7320 6e6f 7420 4e6f router is not No\n+0000f490: 6e65 0a0a 2020 2020 2020 2020 7061 796c ne.. payl\n+0000f4a0: 6f61 6420 3d20 6f70 7469 6f6e 732e 6765 oad = options.ge\n+0000f4b0: 7428 2770 6179 6c6f 6164 2729 0a20 2020 t('payload'). \n+0000f4c0: 2020 2020 2069 6620 6e6f 7420 6973 696e if not isin\n+0000f4d0: 7374 616e 6365 2870 6179 6c6f 6164 2c20 stance(payload, \n+0000f4e0: 7374 7229 3a0a 2020 2020 2020 2020 2020 str):. \n+0000f4f0: 2020 7265 7475 726e 204e 6f6e 650a 0a20 return None.. \n+0000f500: 2020 2020 2020 2066 6f72 2063 6c73 2069 for cls i\n+0000f510: 6e20 7365 6c66 2e74 6162 6c65 2e67 6574 n self.table.get\n+0000f520: 2870 6179 6c6f 6164 2c20 5b5d 293a 0a20 (payload, []):. \n+0000f530: 2020 2020 2020 2020 2020 2069 6620 7365 if se\n+0000f540: 6c66 2e63 6865 636b 5f72 6573 7472 6963 lf.check_restric\n+0000f550: 7469 6f6e 7328 636c 732e 7265 7374 7269 tions(cls.restri\n+0000f560: 6374 696f 6e73 2c20 6f70 7469 6f6e 7329 ctions, options)\n+0000f570: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n+0000f580: 2020 7265 7475 726e 2063 6c73 2873 656c return cls(sel\n+0000f590: 662e 726f 7574 6572 290a 2020 2020 2020 f.router). \n+0000f5a0: 2020 656c 7365 3a0a 2020 2020 2020 2020 else:. \n+0000f5b0: 2020 2020 7265 7475 726e 204e 6f6e 650a return None.\n+0000f5c0: 0a20 2020 2064 6566 2073 6875 7464 6f77 . def shutdow\n+0000f5d0: 6e28 7365 6c66 293a 0a20 2020 2020 2020 n(self):. \n+0000f5e0: 2070 6173 7320 2023 2077 6520 646f 6e27 pass # we don'\n+0000f5f0: 7420 686f 6c64 2061 6e79 2073 7461 7465 t hold any state\n+0000f600: 0a0a 0a63 6c61 7373 2043 6861 6e6e 656c ...class Channel\n+0000f610: 4572 726f 7228 436f 636b 7069 7450 726f Error(CockpitPro\n+0000f620: 626c 656d 293a 0a20 2020 2070 6173 730a blem):. pass.\n+0000f630: 0a0a 636c 6173 7320 4368 616e 6e65 6c28 ..class Channel(\n+0000f640: 456e 6470 6f69 6e74 293a 0a20 2020 2023 Endpoint):. #\n+0000f650: 2056 616c 7565 7320 626f 7272 6f77 6564 Values borrowed\n+0000f660: 2066 726f 6d20 4320 696d 706c 656d 656e from C implemen\n+0000f670: 7461 7469 6f6e 0a20 2020 2042 4c4f 434b tation. BLOCK\n+0000f680: 5f53 495a 4520 3d20 3136 202a 2031 3032 _SIZE = 16 * 102\n+0000f690: 340a 2020 2020 5345 4e44 5f57 494e 444f 4. SEND_WINDO\n+0000f6a0: 5720 3d20 3220 2a20 3130 3234 202a 2031 W = 2 * 1024 * 1\n+0000f6b0: 3032 340a 0a20 2020 2023 2046 6c6f 7720 024.. # Flow \n+0000f6c0: 636f 6e74 726f 6c20 626f 6f6b 2d6b 6565 control book-kee\n+0000f6d0: 7069 6e67 0a20 2020 205f 7365 6e64 5f70 ping. _send_p\n+0000f6e0: 696e 6773 3a20 626f 6f6c 203d 2046 616c ings: bool = Fal\n+0000f6f0: 7365 0a20 2020 205f 6f75 745f 7365 7175 se. _out_sequ\n+0000f700: 656e 6365 3a20 696e 7420 3d20 300a 2020 ence: int = 0. \n+0000f710: 2020 5f6f 7574 5f77 696e 646f 773a 2069 _out_window: i\n+0000f720: 6e74 203d 2053 454e 445f 5749 4e44 4f57 nt = SEND_WINDOW\n+0000f730: 0a20 2020 205f 6163 6b5f 6279 7465 733a . _ack_bytes:\n+0000f740: 2062 6f6f 6c0a 0a20 2020 2023 2054 6173 bool.. # Tas\n+0000f750: 6b20 6d61 6e61 6765 6d65 6e74 0a20 2020 k management. \n+0000f760: 205f 7461 736b 733a 2053 6574 5b61 7379 _tasks: Set[asy\n+0000f770: 6e63 696f 2e54 6173 6b5d 0a20 2020 205f ncio.Task]. _\n+0000f780: 636c 6f73 655f 6172 6773 3a20 4f70 7469 close_args: Opti\n+0000f790: 6f6e 616c 5b4a 736f 6e4f 626a 6563 745d onal[JsonObject]\n+0000f7a0: 203d 204e 6f6e 650a 0a20 2020 2023 204d = None.. # M\n+0000f7b0: 7573 7420 6265 2066 696c 6c65 6420 696e ust be filled in\n+0000f7c0: 2062 7920 7468 6520 6368 616e 6e65 6c20 by the channel \n+0000f7d0: 696d 706c 656d 656e 7461 7469 6f6e 0a20 implementation. \n+0000f7e0: 2020 2070 6179 6c6f 6164 3a20 436c 6173 payload: Clas\n+0000f7f0: 7356 6172 5b73 7472 5d0a 2020 2020 7265 sVar[str]. re\n+0000f800: 7374 7269 6374 696f 6e73 3a20 436c 6173 strictions: Clas\n+0000f810: 7356 6172 5b53 6571 7565 6e63 655b 5475 sVar[Sequence[Tu\n+0000f820: 706c 655b 7374 722c 206f 626a 6563 745d ple[str, object]\n+0000f830: 5d5d 203d 2028 290a 0a20 2020 2023 2054 ]] = ().. # T\n+0000f840: 6865 7365 2067 6574 2066 696c 6c65 6420 hese get filled \n+0000f850: 696e 2066 726f 6d20 2e64 6f5f 6f70 656e in from .do_open\n+0000f860: 2829 0a20 2020 2063 6861 6e6e 656c 203d (). channel =\n+0000f870: 2027 270a 2020 2020 6772 6f75 7020 3d20 ''. group = \n+0000f880: 2727 0a0a 2020 2020 2320 696e 7075 740a ''.. # input.\n+0000f890: 2020 2020 6465 6620 646f 5f63 6f6e 7472 def do_contr\n+0000f8a0: 6f6c 2873 656c 662c 2063 6f6d 6d61 6e64 ol(self, command\n+0000f8b0: 3a20 7374 722c 206d 6573 7361 6765 3a20 : str, message: \n+0000f8c0: 4a73 6f6e 4f62 6a65 6374 2920 2d3e 204e JsonObject) -> N\n+0000f8d0: 6f6e 653a 0a20 2020 2020 2020 2023 2042 one:. # B\n+0000f8e0: 7265 616b 2074 6865 2076 6172 696f 7573 reak the various\n+0000f8f0: 2064 6966 6665 7265 6e74 206b 696e 6473 different kinds\n+0000f900: 206f 6620 636f 6e74 726f 6c20 6d65 7373 of control mess\n+0000f910: 6167 6573 206f 7574 2069 6e74 6f20 7468 ages out into th\n+0000f920: 650a 2020 2020 2020 2020 2320 7468 696e e. # thin\n+0000f930: 6773 2074 6861 7420 6f75 7220 7375 6263 gs that our subc\n+0000f940: 6c61 7373 206d 6179 2062 6520 696e 7465 lass may be inte\n+0000f950: 7265 7374 6564 2069 6e20 6861 6e64 6c69 rested in handli\n+0000f960: 6e67 2e20 2057 6520 6472 6f70 2074 6865 ng. We drop the\n+0000f970: 0a20 2020 2020 2020 2023 2027 6d65 7373 . # 'mess\n+0000f980: 6167 6527 2066 6965 6c64 2066 6f72 2068 age' field for h\n+0000f990: 616e 646c 6572 7320 7468 6174 2064 6f6e andlers that don\n+0000f9a0: 2774 206e 6565 6420 6974 2e0a 2020 2020 't need it.. \n+0000f9b0: 2020 2020 6966 2063 6f6d 6d61 6e64 203d if command =\n+0000f9c0: 3d20 276f 7065 6e27 3a0a 2020 2020 2020 = 'open':. \n+0000f9d0: 2020 2020 2020 7365 6c66 2e5f 7461 736b self._task\n+0000f9e0: 7320 3d20 7365 7428 290a 2020 2020 2020 s = set(). \n+0000f9f0: 2020 2020 2020 7365 6c66 2e63 6861 6e6e self.chann\n+0000fa00: 656c 203d 2067 6574 5f73 7472 286d 6573 el = get_str(mes\n+0000fa10: 7361 6765 2c20 2763 6861 6e6e 656c 2729 sage, 'channel')\n+0000fa20: 0a20 2020 2020 2020 2020 2020 2069 6620 . if \n+0000fa30: 6765 745f 626f 6f6c 286d 6573 7361 6765 get_bool(message\n+0000fa40: 2c20 2766 6c6f 772d 636f 6e74 726f 6c27 , 'flow-control'\n+0000fa50: 2c20 6465 6661 756c 743d 4661 6c73 6529 , default=False)\n+0000fa60: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n+0000fa70: 2020 7365 6c66 2e5f 7365 6e64 5f70 696e self._send_pin\n+0000fa80: 6773 203d 2054 7275 650a 2020 2020 2020 gs = True. \n+0000fa90: 2020 2020 2020 7365 6c66 2e5f 6163 6b5f self._ack_\n+0000faa0: 6279 7465 7320 3d20 6765 745f 656e 756d bytes = get_enum\n+0000fab0: 286d 6573 7361 6765 2c20 2773 656e 642d (message, 'send-\n+0000fac0: 6163 6b73 272c 205b 2762 7974 6573 275d acks', ['bytes']\n+0000fad0: 2c20 4e6f 6e65 2920 6973 206e 6f74 204e , None) is not N\n+0000fae0: 6f6e 650a 2020 2020 2020 2020 2020 2020 one. \n+0000faf0: 7365 6c66 2e67 726f 7570 203d 2067 6574 self.group = get\n+0000fb00: 5f73 7472 286d 6573 7361 6765 2c20 2767 _str(message, 'g\n+0000fb10: 726f 7570 272c 2027 6465 6661 756c 7427 roup', 'default'\n+0000fb20: 290a 2020 2020 2020 2020 2020 2020 7365 ). se\n+0000fb30: 6c66 2e66 7265 657a 655f 656e 6470 6f69 lf.freeze_endpoi\n+0000fb40: 6e74 2829 0a20 2020 2020 2020 2020 2020 nt(). \n+0000fb50: 2073 656c 662e 646f 5f6f 7065 6e28 6d65 self.do_open(me\n+0000fb60: 7373 6167 6529 0a20 2020 2020 2020 2065 ssage). e\n+0000fb70: 6c69 6620 636f 6d6d 616e 6420 3d3d 2027 lif command == '\n+0000fb80: 7265 6164 7927 3a0a 2020 2020 2020 2020 ready':. \n+0000fb90: 2020 2020 7365 6c66 2e64 6f5f 7265 6164 self.do_read\n+0000fba0: 7928 290a 2020 2020 2020 2020 656c 6966 y(). elif\n+0000fbb0: 2063 6f6d 6d61 6e64 203d 3d20 2764 6f6e command == 'don\n+0000fbc0: 6527 3a0a 2020 2020 2020 2020 2020 2020 e':. \n+0000fbd0: 7365 6c66 2e64 6f5f 646f 6e65 2829 0a20 self.do_done(). \n+0000fbe0: 2020 2020 2020 2065 6c69 6620 636f 6d6d elif comm\n+0000fbf0: 616e 6420 3d3d 2027 636c 6f73 6527 3a0a and == 'close':.\n+0000fc00: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n+0000fc10: 2e64 6f5f 636c 6f73 6528 290a 2020 2020 .do_close(). \n+0000fc20: 2020 2020 656c 6966 2063 6f6d 6d61 6e64 elif command\n+0000fc30: 203d 3d20 2770 696e 6727 3a0a 2020 2020 == 'ping':. \n+0000fc40: 2020 2020 2020 2020 7365 6c66 2e64 6f5f self.do_\n+0000fc50: 7069 6e67 286d 6573 7361 6765 290a 2020 ping(message). \n+0000fc60: 2020 2020 2020 656c 6966 2063 6f6d 6d61 elif comma\n+0000fc70: 6e64 203d 3d20 2770 6f6e 6727 3a0a 2020 nd == 'pong':. \n+0000fc80: 2020 2020 2020 2020 2020 7365 6c66 2e64 self.d\n+0000fc90: 6f5f 706f 6e67 286d 6573 7361 6765 290a o_pong(message).\n+0000fca0: 2020 2020 2020 2020 656c 6966 2063 6f6d elif com\n+0000fcb0: 6d61 6e64 203d 3d20 276f 7074 696f 6e73 mand == 'options\n+0000fcc0: 273a 0a20 2020 2020 2020 2020 2020 2073 ':. s\n+0000fcd0: 656c 662e 646f 5f6f 7074 696f 6e73 286d elf.do_options(m\n+0000fce0: 6573 7361 6765 290a 0a20 2020 2064 6566 essage).. def\n+0000fcf0: 2064 6f5f 6368 616e 6e65 6c5f 636f 6e74 do_channel_cont\n+0000fd00: 726f 6c28 7365 6c66 2c20 6368 616e 6e65 rol(self, channe\n+0000fd10: 6c3a 2073 7472 2c20 636f 6d6d 616e 643a l: str, command:\n+0000fd20: 2073 7472 2c20 6d65 7373 6167 653a 204a str, message: J\n+0000fd30: 736f 6e4f 626a 6563 7429 202d 3e20 4e6f sonObject) -> No\n+0000fd40: 6e65 3a0a 2020 2020 2020 2020 2320 416c ne:. # Al\n+0000fd50: 7265 6164 7920 636c 6f73 696e 673f 2020 ready closing? \n+0000fd60: 4967 6e6f 7265 2e0a 2020 2020 2020 2020 Ignore.. \n+0000fd70: 6966 2073 656c 662e 5f63 6c6f 7365 5f61 if self._close_a\n+0000fd80: 7267 7320 6973 206e 6f74 204e 6f6e 653a rgs is not None:\n+0000fd90: 0a20 2020 2020 2020 2020 2020 2072 6574 . ret\n+0000fda0: 7572 6e0a 0a20 2020 2020 2020 2023 2043 urn.. # C\n+0000fdb0: 6174 6368 2065 7272 6f72 7320 616e 6420 atch errors and \n+0000fdc0: 7475 726e 2074 6865 6d20 696e 746f 2063 turn them into c\n+0000fdd0: 6c6f 7365 206d 6573 7361 6765 730a 2020 lose messages. \n+0000fde0: 2020 2020 2020 7472 793a 0a20 2020 2020 try:. \n+0000fdf0: 2020 2020 2020 2074 7279 3a0a 2020 2020 try:. \n+0000fe00: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n+0000fe10: 2e64 6f5f 636f 6e74 726f 6c28 636f 6d6d .do_control(comm\n+0000fe20: 616e 642c 206d 6573 7361 6765 290a 2020 and, message). \n+0000fe30: 2020 2020 2020 2020 2020 6578 6365 7074 except\n+0000fe40: 204a 736f 6e45 7272 6f72 2061 7320 6578 JsonError as ex\n+0000fe50: 633a 0a20 2020 2020 2020 2020 2020 2020 c:. \n+0000fe60: 2020 2072 6169 7365 2043 6861 6e6e 656c raise Channel\n+0000fe70: 4572 726f 7228 2770 726f 746f 636f 6c2d Error('protocol-\n+0000fe80: 6572 726f 7227 2c20 6d65 7373 6167 653d error', message=\n+0000fe90: 7374 7228 6578 6329 2920 6672 6f6d 2065 str(exc)) from e\n+0000fea0: 7863 0a20 2020 2020 2020 2065 7863 6570 xc. excep\n+0000feb0: 7420 4368 616e 6e65 6c45 7272 6f72 2061 t ChannelError a\n+0000fec0: 7320 6578 633a 0a20 2020 2020 2020 2020 s exc:. \n+0000fed0: 2020 2073 656c 662e 636c 6f73 6528 6578 self.close(ex\n+0000fee0: 632e 6765 745f 6174 7472 7328 2929 0a0a c.get_attrs())..\n+0000fef0: 2020 2020 6465 6620 646f 5f6b 696c 6c28 def do_kill(\n+0000ff00: 7365 6c66 2c20 686f 7374 3a20 2773 7472 self, host: 'str\n+0000ff10: 207c 204e 6f6e 6527 2c20 6772 6f75 703a | None', group:\n+0000ff20: 2027 7374 7220 7c20 4e6f 6e65 272c 205f 'str | None', _\n+0000ff30: 6d65 7373 6167 653a 204a 736f 6e4f 626a message: JsonObj\n+0000ff40: 6563 7429 202d 3e20 4e6f 6e65 3a0a 2020 ect) -> None:. \n+0000ff50: 2020 2020 2020 2320 416c 7265 6164 7920 # Already \n+0000ff60: 636c 6f73 696e 673f 2020 4967 6e6f 7265 closing? Ignore\n+0000ff70: 2e0a 2020 2020 2020 2020 6966 2073 656c .. if sel\n+0000ff80: 662e 5f63 6c6f 7365 5f61 7267 7320 6973 f._close_args is\n+0000ff90: 206e 6f74 204e 6f6e 653a 0a20 2020 2020 not None:. \n+0000ffa0: 2020 2020 2020 2072 6574 7572 6e0a 0a20 return.. \n+0000ffb0: 2020 2020 2020 2069 6620 686f 7374 2069 if host i\n+0000ffc0: 7320 6e6f 7420 4e6f 6e65 3a0a 2020 2020 s not None:. \n+0000ffd0: 2020 2020 2020 2020 7265 7475 726e 0a20 return. \n+0000ffe0: 2020 2020 2020 2069 6620 6772 6f75 7020 if group \n+0000fff0: 6973 206e 6f74 204e 6f6e 6520 616e 6420 is not None and \n+00010000: 7365 6c66 2e67 726f 7570 2021 3d20 6772 self.group != gr\n+00010010: 6f75 703a 0a20 2020 2020 2020 2020 2020 oup:. \n+00010020: 2072 6574 7572 6e0a 2020 2020 2020 2020 return. \n+00010030: 7365 6c66 2e64 6f5f 636c 6f73 6528 290a self.do_close().\n+00010040: 0a20 2020 2023 2041 7420 6c65 6173 7420 . # At least \n+00010050: 7468 6973 206f 6e65 2072 6561 6c6c 7920 this one really \n+00010060: 6f75 6768 7420 746f 2062 6520 696d 706c ought to be impl\n+00010070: 656d 656e 7465 642e 2e2e 0a20 2020 2064 emented.... d\n+00010080: 6566 2064 6f5f 6f70 656e 2873 656c 662c ef do_open(self,\n+00010090: 206f 7074 696f 6e73 3a20 4a73 6f6e 4f62 options: JsonOb\n+000100a0: 6a65 6374 2920 2d3e 204e 6f6e 653a 0a20 ject) -> None:. \n+000100b0: 2020 2020 2020 2072 6169 7365 204e 6f74 raise Not\n+000100c0: 496d 706c 656d 656e 7465 6445 7272 6f72 ImplementedError\n+000100d0: 0a0a 2020 2020 2320 2e2e 2e20 6275 7420 .. # ... but \n+000100e0: 6d61 6e79 2073 7562 636c 6173 7365 7320 many subclasses \n+000100f0: 6d61 7920 7265 6173 6f6e 6162 6c79 2077 may reasonably w\n+00010100: 616e 7420 746f 2069 676e 6f72 6520 736f ant to ignore so\n+00010110: 6d65 206f 6620 7468 6573 652e 0a20 2020 me of these.. \n+00010120: 2064 6566 2064 6f5f 7265 6164 7928 7365 def do_ready(se\n+00010130: 6c66 2920 2d3e 204e 6f6e 653a 0a20 2020 lf) -> None:. \n+00010140: 2020 2020 2070 6173 730a 0a20 2020 2064 pass.. d\n+00010150: 6566 2064 6f5f 646f 6e65 2873 656c 6629 ef do_done(self)\n+00010160: 202d 3e20 4e6f 6e65 3a0a 2020 2020 2020 -> None:. \n+00010170: 2020 7061 7373 0a0a 2020 2020 6465 6620 pass.. def \n+00010180: 646f 5f63 6c6f 7365 2873 656c 6629 202d do_close(self) -\n+00010190: 3e20 4e6f 6e65 3a0a 2020 2020 2020 2020 > None:. \n+000101a0: 7365 6c66 2e63 6c6f 7365 2829 0a0a 2020 self.close().. \n+000101b0: 2020 6465 6620 646f 5f6f 7074 696f 6e73 def do_options\n+000101c0: 2873 656c 662c 206d 6573 7361 6765 3a20 (self, message: \n+000101d0: 4a73 6f6e 4f62 6a65 6374 2920 2d3e 204e JsonObject) -> N\n+000101e0: 6f6e 653a 0a20 2020 2020 2020 2072 6169 one:. rai\n+000101f0: 7365 2043 6861 6e6e 656c 4572 726f 7228 se ChannelError(\n+00010200: 276e 6f74 2d73 7570 706f 7274 6564 272c 'not-supported',\n+00010210: 206d 6573 7361 6765 3d27 5468 6973 2063 message='This c\n+00010220: 6861 6e6e 656c 2064 6f65 7320 6e6f 7420 hannel does not \n+00010230: 696d 706c 656d 656e 7420 226f 7074 696f implement \"optio\n+00010240: 6e73 2227 290a 0a20 2020 2023 2027 7265 ns\"').. # 're\n+00010250: 6173 6f6e 6162 6c65 2720 6465 6661 756c asonable' defaul\n+00010260: 742c 206f 7665 7272 6964 6465 6e20 696e t, overridden in\n+00010270: 206f 7468 6572 2063 6861 6e6e 656c 7320 other channels \n+00010280: 666f 7220 7265 6365 6976 652d 7369 6465 for receive-side\n+00010290: 2066 6c6f 7720 636f 6e74 726f 6c0a 2020 flow control. \n+000102a0: 2020 6465 6620 646f 5f70 696e 6728 7365 def do_ping(se\n+000102b0: 6c66 2c20 6d65 7373 6167 653a 204a 736f lf, message: Jso\n+000102c0: 6e4f 626a 6563 7429 202d 3e20 4e6f 6e65 nObject) -> None\n+000102d0: 3a0a 2020 2020 2020 2020 7365 6c66 2e73 :. self.s\n+000102e0: 656e 645f 706f 6e67 286d 6573 7361 6765 end_pong(message\n+000102f0: 290a 0a20 2020 2064 6566 2073 656e 645f ).. def send_\n+00010300: 6163 6b28 7365 6c66 2c20 6461 7461 3a20 ack(self, data: \n+00010310: 6279 7465 7329 202d 3e20 4e6f 6e65 3a0a bytes) -> None:.\n+00010320: 2020 2020 2020 2020 6966 2073 656c 662e if self.\n+00010330: 5f61 636b 5f62 7974 6573 3a0a 2020 2020 _ack_bytes:. \n+00010340: 2020 2020 2020 2020 7365 6c66 2e73 656e self.sen\n+00010350: 645f 636f 6e74 726f 6c28 2761 636b 272c d_control('ack',\n+00010360: 2062 7974 6573 3d6c 656e 2864 6174 6129 bytes=len(data)\n+00010370: 290a 0a20 2020 2064 6566 2064 6f5f 6368 ).. def do_ch\n+00010380: 616e 6e65 6c5f 6461 7461 2873 656c 662c annel_data(self,\n+00010390: 2063 6861 6e6e 656c 3a20 7374 722c 2064 channel: str, d\n+000103a0: 6174 613a 2062 7974 6573 2920 2d3e 204e ata: bytes) -> N\n+000103b0: 6f6e 653a 0a20 2020 2020 2020 2023 2041 one:. # A\n+000103c0: 6c72 6561 6479 2063 6c6f 7369 6e67 3f20 lready closing? \n+000103d0: 2049 676e 6f72 652e 0a20 2020 2020 2020 Ignore.. \n+000103e0: 2069 6620 7365 6c66 2e5f 636c 6f73 655f if self._close_\n+000103f0: 6172 6773 2069 7320 6e6f 7420 4e6f 6e65 args is not None\n+00010400: 3a0a 2020 2020 2020 2020 2020 2020 7265 :. re\n+00010410: 7475 726e 0a0a 2020 2020 2020 2020 2320 turn.. # \n+00010420: 4361 7463 6820 6572 726f 7273 2061 6e64 Catch errors and\n+00010430: 2074 7572 6e20 7468 656d 2069 6e74 6f20 turn them into \n+00010440: 636c 6f73 6520 6d65 7373 6167 6573 0a20 close messages. \n+00010450: 2020 2020 2020 2074 7279 3a0a 2020 2020 try:. \n+00010460: 2020 2020 2020 2020 6966 206e 6f74 2073 if not s\n+00010470: 656c 662e 646f 5f64 6174 6128 6461 7461 elf.do_data(data\n+00010480: 293a 0a20 2020 2020 2020 2020 2020 2020 ):. \n+00010490: 2020 2073 656c 662e 7365 6e64 5f61 636b self.send_ack\n+000104a0: 2864 6174 6129 0a20 2020 2020 2020 2065 (data). e\n+000104b0: 7863 6570 7420 4368 616e 6e65 6c45 7272 xcept ChannelErr\n+000104c0: 6f72 2061 7320 6578 633a 0a20 2020 2020 or as exc:. \n+000104d0: 2020 2020 2020 2073 656c 662e 636c 6f73 self.clos\n+000104e0: 6528 6578 632e 6765 745f 6174 7472 7328 e(exc.get_attrs(\n+000104f0: 2929 0a0a 2020 2020 6465 6620 646f 5f64 )).. def do_d\n+00010500: 6174 6128 7365 6c66 2c20 6461 7461 3a20 ata(self, data: \n+00010510: 6279 7465 7329 202d 3e20 2762 6f6f 6c20 bytes) -> 'bool \n+00010520: 7c20 4e6f 6e65 273a 0a20 2020 2020 2020 | None':. \n+00010530: 2022 2222 4861 6e64 6c65 7320 696e 636f \"\"\"Handles inco\n+00010540: 6d69 6e67 2064 6174 6120 746f 2074 6865 ming data to the\n+00010550: 2063 6861 6e6e 656c 2e0a 0a20 2020 2020 channel... \n+00010560: 2020 2052 6574 7572 6e20 7661 6c75 6520 Return value \n+00010570: 6973 2054 7275 6520 6966 2074 6865 2063 is True if the c\n+00010580: 6861 6e6e 656c 2074 616b 6573 2063 6172 hannel takes car\n+00010590: 6520 6f66 2073 656e 6420 6163 6b73 206f e of send acks o\n+000105a0: 6e20 6974 7320 6f77 6e2c 0a20 2020 2020 n its own,. \n+000105b0: 2020 2069 6e20 7768 6963 6820 6361 7365 in which case\n+000105c0: 2069 7420 7368 6f75 6c64 2063 616c 6c20 it should call \n+000105d0: 7365 6c66 2e73 656e 645f 6163 6b28 2920 self.send_ack() \n+000105e0: 6f6e 2060 6461 7461 6020 6174 2073 6f6d on `data` at som\n+000105f0: 6520 706f 696e 742e 0a20 2020 2020 2020 e point.. \n+00010600: 204e 6f6e 6520 6f72 2046 616c 7365 206d None or False m\n+00010610: 6561 6e73 2074 6861 7420 7468 6520 6163 eans that the ac\n+00010620: 6b6e 6f77 6c65 6467 656d 656e 7420 6973 knowledgement is\n+00010630: 2073 656e 7420 6175 746f 6d61 7469 6361 sent automatica\n+00010640: 6c6c 792e 2222 220a 2020 2020 2020 2020 lly.\"\"\". \n+00010650: 2320 4279 2064 6566 6175 6c74 2c20 6368 # By default, ch\n+00010660: 616e 6e65 6c73 2063 616e 2774 2072 6563 annels can't rec\n+00010670: 6569 7665 2064 6174 612e 0a20 2020 2020 eive data.. \n+00010680: 2020 2064 656c 2064 6174 610a 2020 2020 del data. \n+00010690: 2020 2020 7365 6c66 2e63 6c6f 7365 2829 self.close()\n+000106a0: 0a20 2020 2020 2020 2072 6574 7572 6e20 . return \n+000106b0: 5472 7565 0a0a 2020 2020 2320 6f75 7470 True.. # outp\n+000106c0: 7574 0a20 2020 2064 6566 2072 6561 6479 ut. def ready\n+000106d0: 2873 656c 662c 202a 2a6b 7761 7267 733a (self, **kwargs:\n+000106e0: 204a 736f 6e56 616c 7565 2920 2d3e 204e JsonValue) -> N\n+000106f0: 6f6e 653a 0a20 2020 2020 2020 2073 656c one:. sel\n+00010700: 662e 7468 6177 5f65 6e64 706f 696e 7428 f.thaw_endpoint(\n+00010710: 290a 2020 2020 2020 2020 7365 6c66 2e73 ). self.s\n+00010720: 656e 645f 636f 6e74 726f 6c28 636f 6d6d end_control(comm\n+00010730: 616e 643d 2772 6561 6479 272c 202a 2a6b and='ready', **k\n+00010740: 7761 7267 7329 0a0a 2020 2020 6465 6620 wargs).. def \n+00010750: 646f 6e65 2873 656c 6629 202d 3e20 4e6f done(self) -> No\n+00010760: 6e65 3a0a 2020 2020 2020 2020 7365 6c66 ne:. self\n+00010770: 2e73 656e 645f 636f 6e74 726f 6c28 636f .send_control(co\n+00010780: 6d6d 616e 643d 2764 6f6e 6527 290a 0a20 mmand='done').. \n+00010790: 2020 2023 2074 6173 6b73 2061 6e64 2063 # tasks and c\n+000107a0: 6c6f 7365 206d 616e 6167 656d 656e 740a lose management.\n+000107b0: 2020 2020 6465 6620 6973 5f63 6c6f 7369 def is_closi\n+000107c0: 6e67 2873 656c 6629 202d 3e20 626f 6f6c ng(self) -> bool\n+000107d0: 3a0a 2020 2020 2020 2020 7265 7475 726e :. return\n+000107e0: 2073 656c 662e 5f63 6c6f 7365 5f61 7267 self._close_arg\n+000107f0: 7320 6973 206e 6f74 204e 6f6e 650a 0a20 s is not None.. \n+00010800: 2020 2064 6566 205f 636c 6f73 655f 6e6f def _close_no\n+00010810: 7728 7365 6c66 2920 2d3e 204e 6f6e 653a w(self) -> None:\n+00010820: 0a20 2020 2020 2020 2073 656c 662e 7368 . self.sh\n+00010830: 7574 646f 776e 5f65 6e64 706f 696e 7428 utdown_endpoint(\n+00010840: 7365 6c66 2e5f 636c 6f73 655f 6172 6773 self._close_args\n+00010850: 290a 0a20 2020 2064 6566 205f 7461 736b ).. def _task\n+00010860: 5f64 6f6e 6528 7365 6c66 2c20 7461 736b _done(self, task\n+00010870: 293a 0a20 2020 2020 2020 2023 2053 7472 ):. # Str\n+00010880: 6963 746c 7920 7370 6561 6b69 6e67 2c20 ictly speaking, \n+00010890: 7765 2073 686f 756c 6420 7265 6164 2074 we should read t\n+000108a0: 6865 2072 6573 756c 7420 616e 6420 6368 he result and ch\n+000108b0: 6563 6b20 666f 7220 6578 6365 7074 696f eck for exceptio\n+000108c0: 6e73 2062 7574 3a0a 2020 2020 2020 2020 ns but:. \n+000108d0: 2320 2020 2d20 6578 6365 7074 696f 6e73 # - exceptions\n+000108e0: 2062 7562 626c 696e 6720 6f75 7420 6f66 bubbling out of\n+000108f0: 2074 6865 2074 6173 6b20 6172 6520 7072 the task are pr\n+00010900: 6f67 7261 6d6d 696e 6720 6572 726f 7273 ogramming errors\n+00010910: 0a20 2020 2020 2020 2023 2020 202d 2074 . # - t\n+00010920: 6865 206f 6e6c 7920 7468 696e 6720 7765 he only thing we\n+00010930: 2764 2064 6f20 7769 7468 2069 7420 616e 'd do with it an\n+00010940: 7977 6179 2c20 6973 2074 6f20 7368 6f77 yway, is to show\n+00010950: 2069 740a 2020 2020 2020 2020 2320 2020 it. # \n+00010960: 2d20 5079 7468 6f6e 2061 6c72 6561 6479 - Python already\n+00010970: 2064 6f65 7320 7468 6174 2077 6974 6820 does that with \n+00010980: 6974 7320 2254 6173 6b20 6578 6365 7074 its \"Task except\n+00010990: 696f 6e20 7761 7320 6e65 7665 7220 7265 ion was never re\n+000109a0: 7472 6965 7665 6422 206d 6573 7361 6765 trieved\" message\n+000109b0: 730a 2020 2020 2020 2020 7365 6c66 2e5f s. self._\n+000109c0: 7461 736b 732e 7265 6d6f 7665 2874 6173 tasks.remove(tas\n+000109d0: 6b29 0a20 2020 2020 2020 2069 6620 7365 k). if se\n+000109e0: 6c66 2e5f 636c 6f73 655f 6172 6773 2069 lf._close_args i\n+000109f0: 7320 6e6f 7420 4e6f 6e65 2061 6e64 206e s not None and n\n+00010a00: 6f74 2073 656c 662e 5f74 6173 6b73 3a0a ot self._tasks:.\n+00010a10: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n+00010a20: 2e5f 636c 6f73 655f 6e6f 7728 290a 0a20 ._close_now().. \n+00010a30: 2020 2064 6566 2063 7265 6174 655f 7461 def create_ta\n+00010a40: 736b 2873 656c 662c 2063 6f72 6f75 7469 sk(self, corouti\n+00010a50: 6e65 2c20 6e61 6d65 3d4e 6f6e 6529 3a0a ne, name=None):.\n+00010a60: 2020 2020 2020 2020 2222 2243 7265 6174 \"\"\"Creat\n+00010a70: 6520 6120 7461 736b 2061 7373 6f63 6961 e a task associa\n+00010a80: 7465 6420 7769 7468 2074 6865 2063 6861 ted with the cha\n+00010a90: 6e6e 656c 2e0a 0a20 2020 2020 2020 2041 nnel... A\n+00010aa0: 6c6c 2074 6173 6b73 206d 7573 7420 6578 ll tasks must ex\n+00010ab0: 6974 2062 6566 6f72 6520 7468 6520 6368 it before the ch\n+00010ac0: 616e 6e65 6c20 6361 6e20 636c 6f73 652e annel can close.\n+00010ad0: 2020 596f 7520 6d61 7920 6e6f 7420 6372 You may not cr\n+00010ae0: 6561 7465 0a20 2020 2020 2020 206e 6577 eate. new\n+00010af0: 2074 6173 6b73 2061 6674 6572 2063 616c tasks after cal\n+00010b00: 6c69 6e67 202e 636c 6f73 6528 292e 0a20 ling .close().. \n+00010b10: 2020 2020 2020 2022 2222 0a20 2020 2020 \"\"\". \n+00010b20: 2020 2061 7373 6572 7420 7365 6c66 2e5f assert self._\n+00010b30: 636c 6f73 655f 6172 6773 2069 7320 4e6f close_args is No\n+00010b40: 6e65 0a20 2020 2020 2020 2074 6173 6b20 ne. task \n+00010b50: 3d20 6173 796e 6369 6f2e 6372 6561 7465 = asyncio.create\n+00010b60: 5f74 6173 6b28 636f 726f 7574 696e 6529 _task(coroutine)\n+00010b70: 0a20 2020 2020 2020 2073 656c 662e 5f74 . self._t\n+00010b80: 6173 6b73 2e61 6464 2874 6173 6b29 0a20 asks.add(task). \n+00010b90: 2020 2020 2020 2074 6173 6b2e 6164 645f task.add_\n+00010ba0: 646f 6e65 5f63 616c 6c62 6163 6b28 7365 done_callback(se\n+00010bb0: 6c66 2e5f 7461 736b 5f64 6f6e 6529 0a20 lf._task_done). \n+00010bc0: 2020 2020 2020 2072 6574 7572 6e20 7461 return ta\n+00010bd0: 736b 0a0a 2020 2020 6465 6620 636c 6f73 sk.. def clos\n+00010be0: 6528 7365 6c66 2c20 636c 6f73 655f 6172 e(self, close_ar\n+00010bf0: 6773 3a20 274a 736f 6e4f 626a 6563 7420 gs: 'JsonObject \n+00010c00: 7c20 4e6f 6e65 2720 3d20 4e6f 6e65 2920 | None' = None) \n+00010c10: 2d3e 204e 6f6e 653a 0a20 2020 2020 2020 -> None:. \n+00010c20: 2022 2222 5265 7175 6573 7473 2074 6865 \"\"\"Requests the\n+00010c30: 2063 6861 6e6e 656c 2074 6f20 6265 2063 channel to be c\n+00010c40: 6c6f 7365 642e 0a0a 2020 2020 2020 2020 losed... \n+00010c50: 4166 7465 7220 796f 7520 6361 6c6c 2074 After you call t\n+00010c60: 6869 7320 6d65 7468 6f64 2c20 796f 7520 his method, you \n+00010c70: 776f 6e27 7420 6765 7420 616e 796d 6f72 won't get anymor\n+00010c80: 6520 602e 646f 5f2a 2829 6020 6361 6c6c e `.do_*()` call\n+00010c90: 732e 0a0a 2020 2020 2020 2020 5468 6973 s... This\n+00010ca0: 2077 696c 6c20 7761 6974 2066 6f72 2061 will wait for a\n+00010cb0: 6e79 2072 756e 6e69 6e67 2074 6173 6b73 ny running tasks\n+00010cc0: 2074 6f20 636f 6d70 6c65 7465 2062 6566 to complete bef\n+00010cd0: 6f72 6520 7365 6e64 696e 6720 7468 650a ore sending the.\n+00010ce0: 2020 2020 2020 2020 636c 6f73 6520 6d65 close me\n+00010cf0: 7373 6167 652e 0a20 2020 2020 2020 2022 ssage.. \"\n+00010d00: 2222 0a20 2020 2020 2020 2069 6620 7365 \"\". if se\n+00010d10: 6c66 2e5f 636c 6f73 655f 6172 6773 2069 lf._close_args i\n+00010d20: 7320 6e6f 7420 4e6f 6e65 3a0a 2020 2020 s not None:. \n+00010d30: 2020 2020 2020 2020 2320 636c 6f73 6520 # close \n+00010d40: 616c 7265 6164 7920 7265 7175 6573 7465 already requeste\n+00010d50: 640a 2020 2020 2020 2020 2020 2020 7265 d. re\n+00010d60: 7475 726e 0a20 2020 2020 2020 2073 656c turn. sel\n+00010d70: 662e 5f63 6c6f 7365 5f61 7267 7320 3d20 f._close_args = \n+00010d80: 636c 6f73 655f 6172 6773 206f 7220 7b7d close_args or {}\n+00010d90: 0a20 2020 2020 2020 2069 6620 6e6f 7420 . if not \n+00010da0: 7365 6c66 2e5f 7461 736b 733a 0a20 2020 self._tasks:. \n+00010db0: 2020 2020 2020 2020 2073 656c 662e 5f63 self._c\n+00010dc0: 6c6f 7365 5f6e 6f77 2829 0a0a 2020 2020 lose_now().. \n+00010dd0: 6465 6620 7365 6e64 5f64 6174 6128 7365 def send_data(se\n+00010de0: 6c66 2c20 6461 7461 3a20 6279 7465 7329 lf, data: bytes)\n+00010df0: 202d 3e20 626f 6f6c 3a0a 2020 2020 2020 -> bool:. \n+00010e00: 2020 2222 2253 656e 6420 6461 7461 2061 \"\"\"Send data a\n+00010e10: 6e64 2068 616e 646c 6520 626f 6f6b 2d6b nd handle book-k\n+00010e20: 6565 7069 6e67 2066 6f72 2066 6c6f 7720 eeping for flow \n+00010e30: 636f 6e74 726f 6c2e 0a0a 2020 2020 2020 control... \n+00010e40: 2020 5468 6520 666c 6f77 2063 6f6e 7472 The flow contr\n+00010e50: 6f6c 2069 7320 2261 6476 6973 6f72 7922 ol is \"advisory\"\n+00010e60: 2e20 2054 6865 2064 6174 6120 6973 2073 . The data is s\n+00010e70: 656e 7420 696d 6d65 6469 6174 656c 792c ent immediately,\n+00010e80: 2065 7665 6e20 6966 0a20 2020 2020 2020 even if. \n+00010e90: 2069 7427 7320 6c61 7267 6572 2074 6861 it's larger tha\n+00010ea0: 6e20 7468 6520 7769 6e64 6f77 2e20 2049 n the window. I\n+00010eb0: 6e20 6765 6e65 7261 6c20 796f 7520 7368 n general you sh\n+00010ec0: 6f75 6c64 2074 7279 2074 6f20 7365 6e64 ould try to send\n+00010ed0: 2070 6163 6b65 7473 0a20 2020 2020 2020 packets. \n+00010ee0: 2077 6869 6368 2061 7265 2061 7070 726f which are appro\n+00010ef0: 7869 6d61 7465 6c79 2043 6861 6e6e 656c ximately Channel\n+00010f00: 2e42 4c4f 434b 5f53 495a 4520 696e 2073 .BLOCK_SIZE in s\n+00010f10: 697a 652e 0a0a 2020 2020 2020 2020 5265 ize... Re\n+00010f20: 7475 726e 7320 5472 7565 2069 6620 7468 turns True if th\n+00010f30: 6572 6520 6973 2073 7469 6c6c 2072 6f6f ere is still roo\n+00010f40: 6d20 696e 2074 6865 2077 696e 646f 772c m in the window,\n+00010f50: 206f 7220 4661 6c73 6520 6966 2079 6f75 or False if you\n+00010f60: 0a20 2020 2020 2020 2073 686f 756c 6420 . should \n+00010f70: 7374 6f70 2077 7269 7469 6e67 2066 6f72 stop writing for\n+00010f80: 206e 6f77 2e20 2049 6e20 7468 6174 2063 now. In that c\n+00010f90: 6173 652c 2060 2e64 6f5f 7265 7375 6d65 ase, `.do_resume\n+00010fa0: 5f73 656e 6428 2960 2077 696c 6c20 6265 _send()` will be\n+00010fb0: 0a20 2020 2020 2020 2063 616c 6c65 6420 . called \n+00010fc0: 6c61 7465 7220 7768 656e 2074 6865 7265 later when there\n+00010fd0: 2069 7320 6d6f 7265 2072 6f6f 6d2e 0a20 is more room.. \n+00010fe0: 2020 2020 2020 2022 2222 0a20 2020 2020 \"\"\". \n+00010ff0: 2020 2073 656c 662e 7365 6e64 5f63 6861 self.send_cha\n+00011000: 6e6e 656c 5f64 6174 6128 7365 6c66 2e63 nnel_data(self.c\n+00011010: 6861 6e6e 656c 2c20 6461 7461 290a 0a20 hannel, data).. \n+00011020: 2020 2020 2020 2069 6620 7365 6c66 2e5f if self._\n+00011030: 7365 6e64 5f70 696e 6773 3a0a 2020 2020 send_pings:. \n+00011040: 2020 2020 2020 2020 6f75 745f 7365 7175 out_sequ\n+00011050: 656e 6365 203d 2073 656c 662e 5f6f 7574 ence = self._out\n+00011060: 5f73 6571 7565 6e63 6520 2b20 6c65 6e28 _sequence + len(\n+00011070: 6461 7461 290a 2020 2020 2020 2020 2020 data). \n+00011080: 2020 6966 2073 656c 662e 5f6f 7574 5f73 if self._out_s\n+00011090: 6571 7565 6e63 6520 2f2f 2043 6861 6e6e equence // Chann\n+000110a0: 656c 2e42 4c4f 434b 5f53 495a 4520 213d el.BLOCK_SIZE !=\n+000110b0: 206f 7574 5f73 6571 7565 6e63 6520 2f2f out_sequence //\n+000110c0: 2043 6861 6e6e 656c 2e42 4c4f 434b 5f53 Channel.BLOCK_S\n+000110d0: 495a 453a 0a20 2020 2020 2020 2020 2020 IZE:. \n+000110e0: 2020 2020 2073 656c 662e 7365 6e64 5f63 self.send_c\n+000110f0: 6f6e 7472 6f6c 2863 6f6d 6d61 6e64 3d27 ontrol(command='\n+00011100: 7069 6e67 272c 2073 6571 7565 6e63 653d ping', sequence=\n+00011110: 6f75 745f 7365 7175 656e 6365 290a 2020 out_sequence). \n+00011120: 2020 2020 2020 2020 2020 7365 6c66 2e5f self._\n+00011130: 6f75 745f 7365 7175 656e 6365 203d 206f out_sequence = o\n+00011140: 7574 5f73 6571 7565 6e63 650a 0a20 2020 ut_sequence.. \n+00011150: 2020 2020 2072 6574 7572 6e20 7365 6c66 return self\n+00011160: 2e5f 6f75 745f 7365 7175 656e 6365 203c ._out_sequence <\n+00011170: 2073 656c 662e 5f6f 7574 5f77 696e 646f self._out_windo\n+00011180: 770a 0a20 2020 2064 6566 2064 6f5f 706f w.. def do_po\n+00011190: 6e67 2873 656c 662c 206d 6573 7361 6765 ng(self, message\n+000111a0: 293a 0a20 2020 2020 2020 2069 6620 6e6f ):. if no\n+000111b0: 7420 7365 6c66 2e5f 7365 6e64 5f70 696e t self._send_pin\n+000111c0: 6773 3a20 2023 2068 7568 3f0a 2020 2020 gs: # huh?. \n+000111d0: 2020 2020 2020 2020 6c6f 6767 6572 2e77 logger.w\n+000111e0: 6172 6e69 6e67 2822 476f 7420 7769 6c64 arning(\"Got wild\n+000111f0: 2070 6f6e 6720 6f6e 2063 6861 6e6e 656c pong on channel\n+00011200: 2025 7322 2c20 7365 6c66 2e63 6861 6e6e %s\", self.chann\n+00011210: 656c 290a 2020 2020 2020 2020 2020 2020 el). \n+00011220: 7265 7475 726e 0a0a 2020 2020 2020 2020 return.. \n+00011230: 7365 6c66 2e5f 6f75 745f 7769 6e64 6f77 self._out_window\n+00011240: 203d 206d 6573 7361 6765 5b27 7365 7175 = message['sequ\n+00011250: 656e 6365 275d 202b 2043 6861 6e6e 656c ence'] + Channel\n+00011260: 2e53 454e 445f 5749 4e44 4f57 0a20 2020 .SEND_WINDOW. \n+00011270: 2020 2020 2069 6620 7365 6c66 2e5f 6f75 if self._ou\n+00011280: 745f 7365 7175 656e 6365 203c 2073 656c t_sequence < sel\n+00011290: 662e 5f6f 7574 5f77 696e 646f 773a 0a20 f._out_window:. \n+000112a0: 2020 2020 2020 2020 2020 2073 656c 662e self.\n+000112b0: 646f 5f72 6573 756d 655f 7365 6e64 2829 do_resume_send()\n+000112c0: 0a0a 2020 2020 6465 6620 646f 5f72 6573 .. def do_res\n+000112d0: 756d 655f 7365 6e64 2873 656c 6629 202d ume_send(self) -\n+000112e0: 3e20 4e6f 6e65 3a0a 2020 2020 2020 2020 > None:. \n+000112f0: 2222 2243 616c 6c65 6420 746f 2069 6e64 \"\"\"Called to ind\n+00011300: 6963 6174 6520 7468 6174 2074 6865 2063 icate that the c\n+00011310: 6861 6e6e 656c 206d 6179 2073 7461 7274 hannel may start\n+00011320: 2073 656e 6469 6e67 2061 6761 696e 2e22 sending again.\"\n+00011330: 2222 0a20 2020 2020 2020 2023 2063 6861 \"\". # cha\n+00011340: 6e67 6520 746f 2060 7261 6973 6520 4e6f nge to `raise No\n+00011350: 7449 6d70 6c65 6d65 6e74 6564 4572 726f tImplementedErro\n+00011360: 7260 2061 6674 6572 2065 7665 7279 6f6e r` after everyon\n+00011370: 6520 696d 706c 656d 656e 7473 2069 740a e implements it.\n+00011380: 0a20 2020 206a 736f 6e5f 656e 636f 6465 . json_encode\n+00011390: 723a 2043 6c61 7373 5661 725b 6a73 6f6e r: ClassVar[json\n+000113a0: 2e4a 534f 4e45 6e63 6f64 6572 5d20 3d20 .JSONEncoder] = \n+000113b0: 6a73 6f6e 2e4a 534f 4e45 6e63 6f64 6572 json.JSONEncoder\n+000113c0: 2869 6e64 656e 743d 3229 0a0a 2020 2020 (indent=2).. \n+000113d0: 6465 6620 7365 6e64 5f6a 736f 6e28 7365 def send_json(se\n+000113e0: 6c66 2c20 5f6d 7367 3a20 274a 736f 6e4f lf, _msg: 'JsonO\n+000113f0: 626a 6563 7420 7c20 4e6f 6e65 2720 3d20 bject | None' = \n+00011400: 4e6f 6e65 2c20 2a2a 6b77 6172 6773 3a20 None, **kwargs: \n+00011410: 4a73 6f6e 5661 6c75 6529 202d 3e20 626f JsonValue) -> bo\n+00011420: 6f6c 3a0a 2020 2020 2020 2020 7072 6574 ol:. pret\n+00011430: 7479 203d 2073 656c 662e 6a73 6f6e 5f65 ty = self.json_e\n+00011440: 6e63 6f64 6572 2e65 6e63 6f64 6528 6372 ncoder.encode(cr\n+00011450: 6561 7465 5f6f 626a 6563 7428 5f6d 7367 eate_object(_msg\n+00011460: 2c20 6b77 6172 6773 2929 202b 2027 5c6e , kwargs)) + '\\n\n+00011470: 270a 2020 2020 2020 2020 7265 7475 726e '. return\n+00011480: 2073 656c 662e 7365 6e64 5f64 6174 6128 self.send_data(\n+00011490: 7072 6574 7479 2e65 6e63 6f64 6528 2929 pretty.encode())\n+000114a0: 0a0a 2020 2020 6465 6620 7365 6e64 5f63 .. def send_c\n+000114b0: 6f6e 7472 6f6c 2873 656c 662c 2063 6f6d ontrol(self, com\n+000114c0: 6d61 6e64 3a20 7374 722c 202a 2a6b 7761 mand: str, **kwa\n+000114d0: 7267 733a 204a 736f 6e56 616c 7565 2920 rgs: JsonValue) \n+000114e0: 2d3e 204e 6f6e 653a 0a20 2020 2020 2020 -> None:. \n+000114f0: 2073 656c 662e 7365 6e64 5f63 6861 6e6e self.send_chann\n+00011500: 656c 5f63 6f6e 7472 6f6c 2873 656c 662e el_control(self.\n+00011510: 6368 616e 6e65 6c2c 2063 6f6d 6d61 6e64 channel, command\n+00011520: 2c20 4e6f 6e65 2c20 2a2a 6b77 6172 6773 , None, **kwargs\n+00011530: 290a 0a20 2020 2064 6566 2073 656e 645f ).. def send_\n+00011540: 706f 6e67 2873 656c 662c 206d 6573 7361 pong(self, messa\n+00011550: 6765 3a20 4a73 6f6e 4f62 6a65 6374 2920 ge: JsonObject) \n+00011560: 2d3e 204e 6f6e 653a 0a20 2020 2020 2020 -> None:. \n+00011570: 2073 656c 662e 7365 6e64 5f63 6861 6e6e self.send_chann\n+00011580: 656c 5f63 6f6e 7472 6f6c 2873 656c 662e el_control(self.\n+00011590: 6368 616e 6e65 6c2c 2027 706f 6e67 272c channel, 'pong',\n+000115a0: 206d 6573 7361 6765 290a 0a0a 636c 6173 message)...clas\n+000115b0: 7320 5072 6f74 6f63 6f6c 4368 616e 6e65 s ProtocolChanne\n+000115c0: 6c28 4368 616e 6e65 6c2c 2061 7379 6e63 l(Channel, async\n+000115d0: 696f 2e50 726f 746f 636f 6c29 3a0a 2020 io.Protocol):. \n+000115e0: 2020 2222 2241 2063 6861 6e6e 656c 2073 \"\"\"A channel s\n+000115f0: 7562 636c 6173 7320 7468 6174 2069 6d70 ubclass that imp\n+00011600: 6c65 6d65 6e74 7320 7468 6520 6173 796e lements the asyn\n+00011610: 6369 6f20 5072 6f74 6f63 6f6c 2069 6e74 cio Protocol int\n+00011620: 6572 6661 6365 2e0a 0a20 2020 2049 6e20 erface... In \n+00011630: 6566 6665 6374 2c20 6461 7461 2073 656e effect, data sen\n+00011640: 7420 746f 2074 6869 7320 6368 616e 6e65 t to this channe\n+00011650: 6c20 7769 6c6c 2062 6520 7772 6974 7465 l will be writte\n+00011660: 6e20 746f 2074 6865 2063 6f6e 6e65 6374 n to the connect\n+00011670: 6564 0a20 2020 2074 7261 6e73 706f 7274 ed. transport\n+00011680: 2c20 616e 6420 7669 6365 2d76 6572 7361 , and vice-versa\n+00011690: 2e20 2046 6c6f 7720 636f 6e74 726f 6c20 . Flow control \n+000116a0: 6973 2073 7570 706f 7274 6564 2e0a 0a20 is supported... \n+000116b0: 2020 2054 6865 2064 6566 6175 6c74 2069 The default i\n+000116c0: 6d70 6c65 6d65 6e74 6174 696f 6e20 6f66 mplementation of\n+000116d0: 2074 6865 202e 646f 5f6f 7065 6e28 2920 the .do_open() \n+000116e0: 6d65 7468 6f64 2063 616c 6c73 2074 6865 method calls the\n+000116f0: 0a20 2020 202e 6372 6561 7465 5f74 7261 . .create_tra\n+00011700: 6e73 706f 7274 2829 2061 6273 7472 6163 nsport() abstrac\n+00011710: 7420 6d65 7468 6f64 2e20 2054 6869 7320 t method. This \n+00011720: 6d65 7468 6f64 2073 686f 756c 6420 7265 method should re\n+00011730: 7475 726e 2061 2074 7261 6e73 706f 7274 turn a transport\n+00011740: 0a20 2020 2077 6869 6368 2077 696c 6c20 . which will \n+00011750: 6265 2075 7365 6420 666f 7220 636f 6d6d be used for comm\n+00011760: 756e 6963 6174 696f 6e20 6f6e 2074 6865 unication on the\n+00011770: 2063 6861 6e6e 656c 2e0a 0a20 2020 204f channel... O\n+00011780: 7468 6572 7769 7365 2c20 6966 2074 6865 therwise, if the\n+00011790: 2073 7562 636c 6173 7320 696d 706c 656d subclass implem\n+000117a0: 656e 7473 202e 646f 5f6f 7065 6e28 2920 ents .do_open() \n+000117b0: 6974 7365 6c66 2c20 6974 2069 7320 7265 itself, it is re\n+000117c0: 7370 6f6e 7369 626c 650a 2020 2020 666f sponsible. fo\n+000117d0: 7220 7365 7474 696e 6720 7570 2074 6865 r setting up the\n+000117e0: 2063 6f6e 6e65 6374 696f 6e20 616e 6420 connection and \n+000117f0: 656e 7375 7269 6e67 2074 6861 7420 2e63 ensuring that .c\n+00011800: 6f6e 6e65 6374 696f 6e5f 6d61 6465 2829 onnection_made()\n+00011810: 2069 7320 6361 6c6c 6564 2e0a 2020 2020 is called.. \n+00011820: 2222 220a 2020 2020 5f74 7261 6e73 706f \"\"\". _transpo\n+00011830: 7274 3a20 4f70 7469 6f6e 616c 5b61 7379 rt: Optional[asy\n+00011840: 6e63 696f 2e54 7261 6e73 706f 7274 5d0a ncio.Transport].\n+00011850: 2020 2020 5f6c 6f6f 703a 204f 7074 696f _loop: Optio\n+00011860: 6e61 6c5b 6173 796e 6369 6f2e 4162 7374 nal[asyncio.Abst\n+00011870: 7261 6374 4576 656e 744c 6f6f 705d 0a20 ractEventLoop]. \n+00011880: 2020 205f 7365 6e64 5f70 6f6e 6773 3a20 _send_pongs: \n+00011890: 626f 6f6c 203d 2054 7275 650a 2020 2020 bool = True. \n+000118a0: 5f6c 6173 745f 7069 6e67 3a20 4f70 7469 _last_ping: Opti\n+000118b0: 6f6e 616c 5b4a 736f 6e4f 626a 6563 745d onal[JsonObject]\n+000118c0: 203d 204e 6f6e 650a 2020 2020 5f63 7265 = None. _cre\n+000118d0: 6174 655f 7472 616e 7370 6f72 745f 7461 ate_transport_ta\n+000118e0: 736b 203d 204e 6f6e 650a 0a20 2020 2023 sk = None.. #\n+000118f0: 2072 6561 642d 7369 6465 2045 4f46 2068 read-side EOF h\n+00011900: 616e 646c 696e 670a 2020 2020 5f63 6c6f andling. _clo\n+00011910: 7365 5f6f 6e5f 656f 663a 2062 6f6f 6c20 se_on_eof: bool \n+00011920: 3d20 4661 6c73 650a 2020 2020 5f65 6f66 = False. _eof\n+00011930: 3a20 626f 6f6c 203d 2046 616c 7365 0a0a : bool = False..\n+00011940: 2020 2020 6173 796e 6320 6465 6620 6372 async def cr\n+00011950: 6561 7465 5f74 7261 6e73 706f 7274 2873 eate_transport(s\n+00011960: 656c 662c 206c 6f6f 703a 2061 7379 6e63 elf, loop: async\n+00011970: 696f 2e41 6273 7472 6163 7445 7665 6e74 io.AbstractEvent\n+00011980: 4c6f 6f70 2c20 6f70 7469 6f6e 733a 204a Loop, options: J\n+00011990: 736f 6e4f 626a 6563 7429 202d 3e20 6173 sonObject) -> as\n+000119a0: 796e 6369 6f2e 5472 616e 7370 6f72 743a yncio.Transport:\n+000119b0: 0a20 2020 2020 2020 2022 2222 4372 6561 . \"\"\"Crea\n+000119c0: 7465 7320 7468 6520 7472 616e 7370 6f72 tes the transpor\n+000119d0: 7420 666f 7220 7468 6973 2063 6861 6e6e t for this chann\n+000119e0: 656c 2c20 6163 636f 7264 696e 6720 746f el, according to\n+000119f0: 206f 7074 696f 6e73 2e0a 0a20 2020 2020 options... \n+00011a00: 2020 2054 6865 2065 7665 6e74 206c 6f6f The event loo\n+00011a10: 7020 666f 7220 7468 6520 7472 616e 7370 p for the transp\n+00011a20: 6f72 7420 6973 2070 6173 7365 6420 746f ort is passed to\n+00011a30: 2074 6865 2066 756e 6374 696f 6e2e 2020 the function. \n+00011a40: 5468 650a 2020 2020 2020 2020 7072 6f74 The. prot\n+00011a50: 6f63 6f6c 2066 6f72 2074 6865 2074 7261 ocol for the tra\n+00011a60: 6e73 706f 7274 2069 7320 7468 6520 6368 nsport is the ch\n+00011a70: 616e 6e65 6c20 6f62 6a65 6374 2c20 6974 annel object, it\n+00011a80: 7365 6c66 2028 7365 6c66 292e 0a0a 2020 self (self)... \n+00011a90: 2020 2020 2020 5468 6973 206e 6565 6473 This needs\n+00011aa0: 2074 6f20 6265 2069 6d70 6c65 6d65 6e74 to be implement\n+00011ab0: 6564 2062 7920 7468 6520 7375 6263 6c61 ed by the subcla\n+00011ac0: 7373 2e0a 2020 2020 2020 2020 2222 220a ss.. \"\"\".\n+00011ad0: 2020 2020 2020 2020 7261 6973 6520 4e6f raise No\n+00011ae0: 7449 6d70 6c65 6d65 6e74 6564 4572 726f tImplementedErro\n+00011af0: 720a 0a20 2020 2064 6566 2064 6f5f 6f70 r.. def do_op\n+00011b00: 656e 2873 656c 662c 206f 7074 696f 6e73 en(self, options\n+00011b10: 3a20 4a73 6f6e 4f62 6a65 6374 2920 2d3e : JsonObject) ->\n+00011b20: 204e 6f6e 653a 0a20 2020 2020 2020 206c None:. l\n+00011b30: 6f6f 7020 3d20 6173 796e 6369 6f2e 6765 oop = asyncio.ge\n+00011b40: 745f 7275 6e6e 696e 675f 6c6f 6f70 2829 t_running_loop()\n+00011b50: 0a20 2020 2020 2020 2073 656c 662e 5f63 . self._c\n+00011b60: 7265 6174 655f 7472 616e 7370 6f72 745f reate_transport_\n+00011b70: 7461 736b 203d 2061 7379 6e63 696f 2e63 task = asyncio.c\n+00011b80: 7265 6174 655f 7461 736b 2873 656c 662e reate_task(self.\n+00011b90: 6372 6561 7465 5f74 7261 6e73 706f 7274 create_transport\n+00011ba0: 286c 6f6f 702c 206f 7074 696f 6e73 2929 (loop, options))\n+00011bb0: 0a20 2020 2020 2020 2073 656c 662e 5f63 . self._c\n+00011bc0: 7265 6174 655f 7472 616e 7370 6f72 745f reate_transport_\n+00011bd0: 7461 736b 2e61 6464 5f64 6f6e 655f 6361 task.add_done_ca\n+00011be0: 6c6c 6261 636b 2873 656c 662e 6372 6561 llback(self.crea\n+00011bf0: 7465 5f74 7261 6e73 706f 7274 5f64 6f6e te_transport_don\n+00011c00: 6529 0a0a 2020 2020 6465 6620 6372 6561 e).. def crea\n+00011c10: 7465 5f74 7261 6e73 706f 7274 5f64 6f6e te_transport_don\n+00011c20: 6528 7365 6c66 2c20 7461 736b 3a20 2761 e(self, task: 'a\n+00011c30: 7379 6e63 696f 2e54 6173 6b5b 6173 796e syncio.Task[asyn\n+00011c40: 6369 6f2e 5472 616e 7370 6f72 745d 2729 cio.Transport]')\n+00011c50: 202d 3e20 4e6f 6e65 3a0a 2020 2020 2020 -> None:. \n+00011c60: 2020 6173 7365 7274 2074 6173 6b20 6973 assert task is\n+00011c70: 2073 656c 662e 5f63 7265 6174 655f 7472 self._create_tr\n+00011c80: 616e 7370 6f72 745f 7461 736b 0a20 2020 ansport_task. \n+00011c90: 2020 2020 2073 656c 662e 5f63 7265 6174 self._creat\n+00011ca0: 655f 7472 616e 7370 6f72 745f 7461 736b e_transport_task\n+00011cb0: 203d 204e 6f6e 650a 2020 2020 2020 2020 = None. \n+00011cc0: 7472 793a 0a20 2020 2020 2020 2020 2020 try:. \n+00011cd0: 2074 7261 6e73 706f 7274 203d 2074 6173 transport = tas\n+00011ce0: 6b2e 7265 7375 6c74 2829 0a20 2020 2020 k.result(). \n+00011cf0: 2020 2065 7863 6570 7420 4368 616e 6e65 except Channe\n+00011d00: 6c45 7272 6f72 2061 7320 6578 633a 0a20 lError as exc:. \n+00011d10: 2020 2020 2020 2020 2020 2073 656c 662e self.\n+00011d20: 636c 6f73 6528 6578 632e 6765 745f 6174 close(exc.get_at\n+00011d30: 7472 7328 2929 0a20 2020 2020 2020 2020 trs()). \n+00011d40: 2020 2072 6574 7572 6e0a 0a20 2020 2020 return.. \n+00011d50: 2020 2073 656c 662e 636f 6e6e 6563 7469 self.connecti\n+00011d60: 6f6e 5f6d 6164 6528 7472 616e 7370 6f72 on_made(transpor\n+00011d70: 7429 0a20 2020 2020 2020 2073 656c 662e t). self.\n+00011d80: 7265 6164 7928 290a 0a20 2020 2064 6566 ready().. def\n+00011d90: 2063 6f6e 6e65 6374 696f 6e5f 6d61 6465 connection_made\n+00011da0: 2873 656c 662c 2074 7261 6e73 706f 7274 (self, transport\n+00011db0: 3a20 6173 796e 6369 6f2e 4261 7365 5472 : asyncio.BaseTr\n+00011dc0: 616e 7370 6f72 7429 202d 3e20 4e6f 6e65 ansport) -> None\n+00011dd0: 3a0a 2020 2020 2020 2020 6173 7365 7274 :. assert\n+00011de0: 2069 7369 6e73 7461 6e63 6528 7472 616e isinstance(tran\n+00011df0: 7370 6f72 742c 2061 7379 6e63 696f 2e54 sport, asyncio.T\n+00011e00: 7261 6e73 706f 7274 290a 2020 2020 2020 ransport). \n+00011e10: 2020 7365 6c66 2e5f 7472 616e 7370 6f72 self._transpor\n+00011e20: 7420 3d20 7472 616e 7370 6f72 740a 0a20 t = transport.. \n+00011e30: 2020 2064 6566 205f 6765 745f 636c 6f73 def _get_clos\n+00011e40: 655f 6172 6773 2873 656c 6629 202d 3e20 e_args(self) -> \n+00011e50: 4a73 6f6e 4f62 6a65 6374 3a0a 2020 2020 JsonObject:. \n+00011e60: 2020 2020 7265 7475 726e 207b 7d0a 0a20 return {}.. \n+00011e70: 2020 2064 6566 2063 6f6e 6e65 6374 696f def connectio\n+00011e80: 6e5f 6c6f 7374 2873 656c 662c 2065 7863 n_lost(self, exc\n+00011e90: 3a20 4f70 7469 6f6e 616c 5b45 7863 6570 : Optional[Excep\n+00011ea0: 7469 6f6e 5d29 202d 3e20 4e6f 6e65 3a0a tion]) -> None:.\n+00011eb0: 2020 2020 2020 2020 7365 6c66 2e63 6c6f self.clo\n+00011ec0: 7365 2873 656c 662e 5f67 6574 5f63 6c6f se(self._get_clo\n+00011ed0: 7365 5f61 7267 7328 2929 0a0a 2020 2020 se_args()).. \n+00011ee0: 6465 6620 646f 5f64 6174 6128 7365 6c66 def do_data(self\n+00011ef0: 2c20 6461 7461 3a20 6279 7465 7329 202d , data: bytes) -\n+00011f00: 3e20 4e6f 6e65 3a0a 2020 2020 2020 2020 > None:. \n+00011f10: 6173 7365 7274 2073 656c 662e 5f74 7261 assert self._tra\n+00011f20: 6e73 706f 7274 2069 7320 6e6f 7420 4e6f nsport is not No\n+00011f30: 6e65 0a20 2020 2020 2020 2073 656c 662e ne. self.\n+00011f40: 5f74 7261 6e73 706f 7274 2e77 7269 7465 _transport.write\n+00011f50: 2864 6174 6129 0a0a 2020 2020 6465 6620 (data).. def \n+00011f60: 646f 5f64 6f6e 6528 7365 6c66 2920 2d3e do_done(self) ->\n+00011f70: 204e 6f6e 653a 0a20 2020 2020 2020 2061 None:. a\n+00011f80: 7373 6572 7420 7365 6c66 2e5f 7472 616e ssert self._tran\n+00011f90: 7370 6f72 7420 6973 206e 6f74 204e 6f6e sport is not Non\n+00011fa0: 650a 2020 2020 2020 2020 6966 2073 656c e. if sel\n+00011fb0: 662e 5f74 7261 6e73 706f 7274 2e63 616e f._transport.can\n+00011fc0: 5f77 7269 7465 5f65 6f66 2829 3a0a 2020 _write_eof():. \n+00011fd0: 2020 2020 2020 2020 2020 7365 6c66 2e5f self._\n+00011fe0: 7472 616e 7370 6f72 742e 7772 6974 655f transport.write_\n+00011ff0: 656f 6628 290a 0a20 2020 2064 6566 2064 eof().. def d\n+00012000: 6f5f 636c 6f73 6528 7365 6c66 2920 2d3e o_close(self) ->\n+00012010: 204e 6f6e 653a 0a20 2020 2020 2020 2069 None:. i\n+00012020: 6620 7365 6c66 2e5f 7472 616e 7370 6f72 f self._transpor\n+00012030: 7420 6973 206e 6f74 204e 6f6e 653a 0a20 t is not None:. \n+00012040: 2020 2020 2020 2020 2020 2073 656c 662e self.\n+00012050: 5f74 7261 6e73 706f 7274 2e63 6c6f 7365 _transport.close\n+00012060: 2829 0a0a 2020 2020 6465 6620 6461 7461 ().. def data\n+00012070: 5f72 6563 6569 7665 6428 7365 6c66 2c20 _received(self, \n+00012080: 6461 7461 3a20 6279 7465 7329 202d 3e20 data: bytes) -> \n+00012090: 4e6f 6e65 3a0a 2020 2020 2020 2020 6173 None:. as\n+000120a0: 7365 7274 2073 656c 662e 5f74 7261 6e73 sert self._trans\n+000120b0: 706f 7274 2069 7320 6e6f 7420 4e6f 6e65 port is not None\n+000120c0: 0a20 2020 2020 2020 2069 6620 6e6f 7420 . if not \n+000120d0: 7365 6c66 2e73 656e 645f 6461 7461 2864 self.send_data(d\n+000120e0: 6174 6129 3a0a 2020 2020 2020 2020 2020 ata):. \n+000120f0: 2020 7365 6c66 2e5f 7472 616e 7370 6f72 self._transpor\n+00012100: 742e 7061 7573 655f 7265 6164 696e 6728 t.pause_reading(\n+00012110: 290a 0a20 2020 2064 6566 2064 6f5f 7265 ).. def do_re\n+00012120: 7375 6d65 5f73 656e 6428 7365 6c66 2920 sume_send(self) \n+00012130: 2d3e 204e 6f6e 653a 0a20 2020 2020 2020 -> None:. \n+00012140: 2061 7373 6572 7420 7365 6c66 2e5f 7472 assert self._tr\n+00012150: 616e 7370 6f72 7420 6973 206e 6f74 204e ansport is not N\n+00012160: 6f6e 650a 2020 2020 2020 2020 7365 6c66 one. self\n+00012170: 2e5f 7472 616e 7370 6f72 742e 7265 7375 ._transport.resu\n+00012180: 6d65 5f72 6561 6469 6e67 2829 0a0a 2020 me_reading().. \n+00012190: 2020 6465 6620 636c 6f73 655f 6f6e 5f65 def close_on_e\n+000121a0: 6f66 2873 656c 6629 202d 3e20 4e6f 6e65 of(self) -> None\n+000121b0: 3a0a 2020 2020 2020 2020 2222 224d 6172 :. \"\"\"Mar\n+000121c0: 6b20 7468 6520 6368 616e 6e65 6c20 746f k the channel to\n+000121d0: 2062 6520 636c 6f73 6564 206f 6e20 454f be closed on EO\n+000121e0: 462e 0a0a 2020 2020 2020 2020 4e6f 726d F... Norm\n+000121f0: 616c 6c79 2c20 5072 6f74 6f63 6f6c 4368 ally, ProtocolCh\n+00012200: 616e 6e65 6c20 7472 6965 7320 746f 206b annel tries to k\n+00012210: 6565 7020 7468 6520 6368 616e 6e65 6c20 eep the channel \n+00012220: 6861 6c66 2d6f 7065 6e20 6166 7465 720a half-open after.\n+00012230: 2020 2020 2020 2020 7265 6365 6976 696e receivin\n+00012240: 6720 454f 4620 6672 6f6d 2074 6865 2074 g EOF from the t\n+00012250: 7261 6e73 706f 7274 2e20 2054 6869 7320 ransport. This \n+00012260: 696e 7374 7275 6374 7320 7468 6174 2074 instructs that t\n+00012270: 6865 2063 6861 6e6e 656c 0a20 2020 2020 he channel. \n+00012280: 2020 2073 686f 756c 6420 6265 2063 6c6f should be clo\n+00012290: 7365 6420 6f6e 2045 4f46 2e0a 0a20 2020 sed on EOF... \n+000122a0: 2020 2020 2049 6620 454f 4620 7761 7320 If EOF was \n+000122b0: 616c 7265 6164 7920 7265 6365 6976 6564 already received\n+000122c0: 2c20 7468 656e 2063 616c 6c69 6e67 2074 , then calling t\n+000122d0: 6869 7320 6675 6e63 7469 6f6e 2077 696c his function wil\n+000122e0: 6c20 636c 6f73 6520 7468 650a 2020 2020 l close the. \n+000122f0: 2020 2020 6368 616e 6e65 6c20 696d 6d65 channel imme\n+00012300: 6469 6174 656c 792e 0a0a 2020 2020 2020 diately... \n+00012310: 2020 4966 2079 6f75 2064 6f6e 2774 2063 If you don't c\n+00012320: 616c 6c20 7468 6973 2066 756e 6374 696f all this functio\n+00012330: 6e2c 2079 6f75 2061 7265 2072 6573 706f n, you are respo\n+00012340: 6e73 6962 6c65 2066 6f72 2063 6c6f 7369 nsible for closi\n+00012350: 6e67 2074 6865 0a20 2020 2020 2020 2063 ng the. c\n+00012360: 6861 6e6e 656c 2079 6f75 7273 656c 662e hannel yourself.\n+00012370: 0a20 2020 2020 2020 2022 2222 0a20 2020 . \"\"\". \n+00012380: 2020 2020 2073 656c 662e 5f63 6c6f 7365 self._close\n+00012390: 5f6f 6e5f 656f 6620 3d20 5472 7565 0a20 _on_eof = True. \n+000123a0: 2020 2020 2020 2069 6620 7365 6c66 2e5f if self._\n+000123b0: 656f 663a 0a20 2020 2020 2020 2020 2020 eof:. \n+000123c0: 2061 7373 6572 7420 7365 6c66 2e5f 7472 assert self._tr\n+000123d0: 616e 7370 6f72 7420 6973 206e 6f74 204e ansport is not N\n+000123e0: 6f6e 650a 2020 2020 2020 2020 2020 2020 one. \n+000123f0: 7365 6c66 2e5f 7472 616e 7370 6f72 742e self._transport.\n+00012400: 636c 6f73 6528 290a 0a20 2020 2064 6566 close().. def\n+00012410: 2065 6f66 5f72 6563 6569 7665 6428 7365 eof_received(se\n+00012420: 6c66 2920 2d3e 2062 6f6f 6c3a 0a20 2020 lf) -> bool:. \n+00012430: 2020 2020 2073 656c 662e 5f65 6f66 203d self._eof =\n+00012440: 2054 7275 650a 2020 2020 2020 2020 7365 True. se\n+00012450: 6c66 2e64 6f6e 6528 290a 2020 2020 2020 lf.done(). \n+00012460: 2020 7265 7475 726e 206e 6f74 2073 656c return not sel\n+00012470: 662e 5f63 6c6f 7365 5f6f 6e5f 656f 660a f._close_on_eof.\n+00012480: 0a20 2020 2023 2043 6861 6e6e 656c 2072 . # Channel r\n+00012490: 6563 6569 7665 2d73 6964 6520 666c 6f77 eceive-side flow\n+000124a0: 2063 6f6e 7472 6f6c 0a20 2020 2064 6566 control. def\n+000124b0: 2064 6f5f 7069 6e67 2873 656c 662c 206d do_ping(self, m\n+000124c0: 6573 7361 6765 293a 0a20 2020 2020 2020 essage):. \n+000124d0: 2069 6620 7365 6c66 2e5f 7365 6e64 5f70 if self._send_p\n+000124e0: 6f6e 6773 3a0a 2020 2020 2020 2020 2020 ongs:. \n+000124f0: 2020 7365 6c66 2e73 656e 645f 706f 6e67 self.send_pong\n+00012500: 286d 6573 7361 6765 290a 2020 2020 2020 (message). \n+00012510: 2020 656c 7365 3a0a 2020 2020 2020 2020 else:. \n+00012520: 2020 2020 2320 7765 276c 6c20 6861 7665 # we'll have\n+00012530: 2074 6f20 706f 6e67 206c 6174 6572 0a20 to pong later. \n+00012540: 2020 2020 2020 2020 2020 2073 656c 662e self.\n+00012550: 5f6c 6173 745f 7069 6e67 203d 206d 6573 _last_ping = mes\n+00012560: 7361 6765 0a0a 2020 2020 6465 6620 7061 sage.. def pa\n+00012570: 7573 655f 7772 6974 696e 6728 7365 6c66 use_writing(self\n+00012580: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n+00012590: 2020 2023 2057 6520 6361 6e27 7420 6163 # We can't ac\n+000125a0: 7475 616c 6c79 2073 746f 7020 7772 6974 tually stop writ\n+000125b0: 696e 672c 2062 7574 2077 6520 6361 6e20 ing, but we can \n+000125c0: 7374 6f70 2072 6570 6c79 696e 6720 746f stop replying to\n+000125d0: 2070 696e 6773 0a20 2020 2020 2020 2073 pings. s\n+000125e0: 656c 662e 5f73 656e 645f 706f 6e67 7320 elf._send_pongs \n+000125f0: 3d20 4661 6c73 650a 0a20 2020 2064 6566 = False.. def\n+00012600: 2072 6573 756d 655f 7772 6974 696e 6728 resume_writing(\n+00012610: 7365 6c66 2920 2d3e 204e 6f6e 653a 0a20 self) -> None:. \n+00012620: 2020 2020 2020 2073 656c 662e 5f73 656e self._sen\n+00012630: 645f 706f 6e67 7320 3d20 5472 7565 0a20 d_pongs = True. \n+00012640: 2020 2020 2020 2069 6620 7365 6c66 2e5f if self._\n+00012650: 6c61 7374 5f70 696e 6720 6973 206e 6f74 last_ping is not\n+00012660: 204e 6f6e 653a 0a20 2020 2020 2020 2020 None:. \n+00012670: 2020 2073 656c 662e 7365 6e64 5f70 6f6e self.send_pon\n+00012680: 6728 7365 6c66 2e5f 6c61 7374 5f70 696e g(self._last_pin\n+00012690: 6729 0a20 2020 2020 2020 2020 2020 2073 g). s\n+000126a0: 656c 662e 5f6c 6173 745f 7069 6e67 203d elf._last_ping =\n+000126b0: 204e 6f6e 650a 0a0a 636c 6173 7320 4173 None...class As\n+000126c0: 796e 6343 6861 6e6e 656c 2843 6861 6e6e yncChannel(Chann\n+000126d0: 656c 293a 0a20 2020 2022 2222 4120 7375 el):. \"\"\"A su\n+000126e0: 6263 6c61 7373 2066 6f72 2061 7379 6e63 bclass for async\n+000126f0: 2f61 7761 6974 2d73 7479 6c65 2069 6d70 /await-style imp\n+00012700: 6c65 6d65 6e74 6174 696f 6e20 6f66 2063 lementation of c\n+00012710: 6861 6e6e 656c 732c 2077 6974 6820 666c hannels, with fl\n+00012720: 6f77 2063 6f6e 7472 6f6c 0a0a 2020 2020 ow control.. \n+00012730: 5468 6973 2073 7562 636c 6173 7320 7072 This subclass pr\n+00012740: 6f76 6964 6573 2061 7379 6e63 6872 6f6e ovides asynchron\n+00012750: 6f75 7320 6072 6561 6428 2960 2061 6e64 ous `read()` and\n+00012760: 2060 7772 6974 6528 2960 2063 616c 6c73 `write()` calls\n+00012770: 2066 6f72 0a20 2020 2073 7562 636c 6173 for. subclas\n+00012780: 7365 732c 2077 6974 6820 6661 6d69 6c69 ses, with famili\n+00012790: 6172 2073 656d 616e 7469 6373 2e20 2060 ar semantics. `\n+000127a0: 7772 6974 6528 2960 2064 6f65 736e 2774 write()` doesn't\n+000127b0: 2062 7566 6665 722c 2073 6f20 7468 650a buffer, so the.\n+000127c0: 2020 2020 6064 6f6e 6528 2960 206d 6574 `done()` met\n+000127d0: 686f 6420 6f6e 2074 6865 2062 6173 6520 hod on the base \n+000127e0: 6368 616e 6e65 6c20 636c 6173 7320 6361 channel class ca\n+000127f0: 6e20 6265 2075 7365 6420 696e 2061 2077 n be used in a w\n+00012800: 6179 2073 696d 696c 6172 2074 6f0a 2020 ay similar to. \n+00012810: 2020 6073 6875 7464 6f77 6e28 2960 2e20 `shutdown()`. \n+00012820: 2041 2068 6967 682d 6c65 7665 6c20 6073 A high-level `s\n+00012830: 656e 6466 696c 6528 2960 206d 6574 686f endfile()` metho\n+00012840: 6420 6973 2061 7661 696c 6162 6c65 2074 d is available t\n+00012850: 6f20 7365 6e64 2074 6865 0a20 2020 2065 o send the. e\n+00012860: 6e74 6972 6520 636f 6e74 656e 7473 206f ntire contents o\n+00012870: 6620 6120 6269 6e61 7279 2d6d 6f64 6520 f a binary-mode \n+00012880: 6669 6c65 2d6c 696b 6520 6f62 6a65 6374 file-like object\n+00012890: 2e0a 0a20 2020 2054 6865 2073 7562 636c ... The subcl\n+000128a0: 6173 7320 6d75 7374 2070 726f 7669 6465 ass must provide\n+000128b0: 2061 6e20 6173 796e 6320 6072 756e 2829 an async `run()\n+000128c0: 6020 6675 6e63 7469 6f6e 2c20 7768 6963 ` function, whic\n+000128d0: 6820 7769 6c6c 2062 6520 7370 6177 6e65 h will be spawne\n+000128e0: 640a 2020 2020 6173 2061 2074 6173 6b2e d. as a task.\n+000128f0: 2020 5468 6520 7461 736b 2069 7320 6361 The task is ca\n+00012900: 6e63 656c 6c65 6420 7768 656e 2074 6865 ncelled when the\n+00012910: 2063 6861 6e6e 656c 2069 7320 636c 6f73 channel is clos\n+00012920: 6564 2e0a 0a20 2020 204f 6e20 7468 6520 ed... On the \n+00012930: 7265 6365 6976 696e 6720 7369 6465 2c20 receiving side, \n+00012940: 7468 6520 6368 616e 6e65 6c20 7769 6c6c the channel will\n+00012950: 2072 6573 706f 6e64 2074 6f20 666c 6f77 respond to flow\n+00012960: 2063 6f6e 7472 6f6c 2070 696e 6773 2074 control pings t\n+00012970: 6f0a 2020 2020 696e 6469 6361 7465 2074 o. indicate t\n+00012980: 6861 7420 6974 2068 6173 2072 6563 6569 hat it has recei\n+00012990: 7665 6420 7468 6520 6461 7461 2c20 6275 ved the data, bu\n+000129a0: 7420 6f6e 6c79 2061 6674 6572 2069 7420 t only after it \n+000129b0: 6861 7320 6265 656e 2063 6f6e 7375 6d65 has been consume\n+000129c0: 640a 2020 2020 6279 2060 7265 6164 2829 d. by `read()\n+000129d0: 602e 0a0a 2020 2020 4f6e 2074 6865 2073 `... On the s\n+000129e0: 656e 6469 6e67 2073 6964 652c 2077 7269 ending side, wri\n+000129f0: 7465 2829 2077 696c 6c20 626c 6f63 6b20 te() will block \n+00012a00: 6966 2074 6865 2063 6861 6e6e 656c 2062 if the channel b\n+00012a10: 6163 6b73 2075 702e 0a20 2020 2022 2222 acks up.. \"\"\"\n+00012a20: 0a0a 2020 2020 2320 5265 6365 6976 652d .. # Receive-\n+00012a30: 7369 6465 2066 6c6f 7720 636f 6e74 726f side flow contro\n+00012a40: 6c3a 2069 6e74 6572 6d69 7820 7069 6e67 l: intermix ping\n+00012a50: 7320 616e 6420 6461 7461 2069 6e20 7468 s and data in th\n+00012a60: 6520 7175 6575 6520 616e 6420 7265 706c e queue and repl\n+00012a70: 790a 2020 2020 2320 746f 2070 696e 6773 y. # to pings\n+00012a80: 2061 7320 7765 2064 6571 7565 7565 2074 as we dequeue t\n+00012a90: 6865 6d2e 2020 454f 4620 6973 204e 6f6e hem. EOF is Non\n+00012aa0: 652e 2020 5468 6973 2069 7320 6120 6275 e. This is a bu\n+00012ab0: 6666 6572 3a20 7369 6e63 6520 7765 0a20 ffer: since we. \n+00012ac0: 2020 2023 206e 6565 6420 746f 2068 616e # need to han\n+00012ad0: 646c 6520 646f 5f64 6174 6128 2920 7769 dle do_data() wi\n+00012ae0: 7468 6f75 7420 626c 6f63 6b69 6e67 2c20 thout blocking, \n+00012af0: 7765 2068 6176 6520 6e6f 2063 686f 6963 we have no choic\n+00012b00: 652e 0a20 2020 2072 6563 6569 7665 5f71 e.. receive_q\n+00012b10: 7565 7565 3a20 2761 7379 6e63 696f 2e51 ueue: 'asyncio.Q\n+00012b20: 7565 7565 5b62 7974 6573 207c 204a 736f ueue[bytes | Jso\n+00012b30: 6e4f 626a 6563 7420 7c20 4e6f 6e65 5d27 nObject | None]'\n+00012b40: 0a0a 2020 2020 2320 5365 6e64 2d73 6964 .. # Send-sid\n+00012b50: 6520 666c 6f77 2063 6f6e 7472 6f6c 0a20 e flow control. \n+00012b60: 2020 2077 7269 7465 5f77 6169 7465 7220 write_waiter \n+00012b70: 3d20 4e6f 6e65 0a0a 2020 2020 6173 796e = None.. asyn\n+00012b80: 6320 6465 6620 7275 6e28 7365 6c66 2c20 c def run(self, \n+00012b90: 6f70 7469 6f6e 733a 204a 736f 6e4f 626a options: JsonObj\n+00012ba0: 6563 7429 202d 3e20 274a 736f 6e4f 626a ect) -> 'JsonObj\n+00012bb0: 6563 7420 7c20 4e6f 6e65 273a 0a20 2020 ect | None':. \n+00012bc0: 2020 2020 2072 6169 7365 204e 6f74 496d raise NotIm\n+00012bd0: 706c 656d 656e 7465 6445 7272 6f72 0a0a plementedError..\n+00012be0: 2020 2020 6173 796e 6320 6465 6620 7275 async def ru\n+00012bf0: 6e5f 7772 6170 7065 7228 7365 6c66 2c20 n_wrapper(self, \n+00012c00: 6f70 7469 6f6e 733a 204a 736f 6e4f 626a options: JsonObj\n+00012c10: 6563 7429 202d 3e20 4e6f 6e65 3a0a 2020 ect) -> None:. \n+00012c20: 2020 2020 2020 7472 793a 0a20 2020 2020 try:. \n+00012c30: 2020 2020 2020 2073 656c 662e 636c 6f73 self.clos\n+00012c40: 6528 6177 6169 7420 7365 6c66 2e72 756e e(await self.run\n+00012c50: 286f 7074 696f 6e73 2929 0a20 2020 2020 (options)). \n+00012c60: 2020 2065 7863 6570 7420 6173 796e 6369 except asynci\n+00012c70: 6f2e 4361 6e63 656c 6c65 6445 7272 6f72 o.CancelledError\n+00012c80: 3a20 2023 2075 7365 7220 7265 7175 6573 : # user reques\n+00012c90: 7465 6420 636c 6f73 650a 2020 2020 2020 ted close. \n+00012ca0: 2020 2020 2020 7365 6c66 2e63 6c6f 7365 self.close\n+00012cb0: 2829 0a20 2020 2020 2020 2065 7863 6570 (). excep\n+00012cc0: 7420 4368 616e 6e65 6c45 7272 6f72 2061 t ChannelError a\n+00012cd0: 7320 6578 633a 0a20 2020 2020 2020 2020 s exc:. \n+00012ce0: 2020 2073 656c 662e 636c 6f73 6528 6578 self.close(ex\n+00012cf0: 632e 6765 745f 6174 7472 7328 2929 0a20 c.get_attrs()). \n+00012d00: 2020 2020 2020 2065 7863 6570 7420 4261 except Ba\n+00012d10: 7365 4578 6365 7074 696f 6e3a 0a20 2020 seException:. \n+00012d20: 2020 2020 2020 2020 2073 656c 662e 636c self.cl\n+00012d30: 6f73 6528 7b27 7072 6f62 6c65 6d27 3a20 ose({'problem': \n+00012d40: 2769 6e74 6572 6e61 6c2d 6572 726f 7227 'internal-error'\n+00012d50: 2c20 2763 6175 7365 273a 2074 7261 6365 , 'cause': trace\n+00012d60: 6261 636b 2e66 6f72 6d61 745f 6578 6328 back.format_exc(\n+00012d70: 297d 290a 2020 2020 2020 2020 2020 2020 )}). \n+00012d80: 7261 6973 650a 0a20 2020 2061 7379 6e63 raise.. async\n+00012d90: 2064 6566 2072 6561 6428 7365 6c66 2920 def read(self) \n+00012da0: 2d3e 2027 6279 7465 7320 7c20 4e6f 6e65 -> 'bytes | None\n+00012db0: 273a 0a20 2020 2020 2020 2023 2054 6872 ':. # Thr\n+00012dc0: 6565 2070 6f73 7369 6269 6c69 7469 6573 ee possibilities\n+00012dd0: 2066 6f72 2077 6861 7420 7765 276c 6c20 for what we'll \n+00012de0: 6669 6e64 3a0a 2020 2020 2020 2020 2320 find:. # \n+00012df0: 202d 204e 6f6e 6520 2845 4f46 2920 e286 - None (EOF) ..\n+00012e00: 9220 7265 7475 726e 204e 6f6e 650a 2020 . return None. \n+00012e10: 2020 2020 2020 2320 202d 2061 2070 696e # - a pin\n+00012e20: 6720 e286 9220 7365 6e64 2061 2070 6f6e g ... send a pon\n+00012e30: 670a 2020 2020 2020 2020 2320 202d 2062 g. # - b\n+00012e40: 7974 6573 2028 706f 7373 6962 6c79 2065 ytes (possibly e\n+00012e50: 6d70 7479 2920 e286 9220 6163 6b20 7468 mpty) ... ack th\n+00012e60: 6520 7265 6365 6970 742c 2061 6e64 2072 e receipt, and r\n+00012e70: 6574 7572 6e20 6974 0a20 2020 2020 2020 eturn it. \n+00012e80: 2077 6869 6c65 2054 7275 653a 0a20 2020 while True:. \n+00012e90: 2020 2020 2020 2020 2069 7465 6d20 3d20 item = \n+00012ea0: 6177 6169 7420 7365 6c66 2e72 6563 6569 await self.recei\n+00012eb0: 7665 5f71 7565 7565 2e67 6574 2829 0a20 ve_queue.get(). \n+00012ec0: 2020 2020 2020 2020 2020 2069 6620 6974 if it\n+00012ed0: 656d 2069 7320 4e6f 6e65 3a0a 2020 2020 em is None:. \n+00012ee0: 2020 2020 2020 2020 2020 2020 7265 7475 retu\n+00012ef0: 726e 204e 6f6e 650a 2020 2020 2020 2020 rn None. \n+00012f00: 2020 2020 6966 2069 7369 6e73 7461 6e63 if isinstanc\n+00012f10: 6528 6974 656d 2c20 4d61 7070 696e 6729 e(item, Mapping)\n+00012f20: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n+00012f30: 2020 7365 6c66 2e73 656e 645f 706f 6e67 self.send_pong\n+00012f40: 2869 7465 6d29 0a20 2020 2020 2020 2020 (item). \n+00012f50: 2020 2065 6c73 653a 0a20 2020 2020 2020 else:. \n+00012f60: 2020 2020 2020 2020 2073 656c 662e 7365 self.se\n+00012f70: 6e64 5f61 636b 2869 7465 6d29 0a20 2020 nd_ack(item). \n+00012f80: 2020 2020 2020 2020 2020 2020 2072 6574 ret\n+00012f90: 7572 6e20 6974 656d 0a0a 2020 2020 6173 urn item.. as\n+00012fa0: 796e 6320 6465 6620 7772 6974 6528 7365 ync def write(se\n+00012fb0: 6c66 2c20 6461 7461 3a20 6279 7465 7329 lf, data: bytes)\n+00012fc0: 202d 3e20 4e6f 6e65 3a0a 2020 2020 2020 -> None:. \n+00012fd0: 2020 6966 206e 6f74 2073 656c 662e 7365 if not self.se\n+00012fe0: 6e64 5f64 6174 6128 6461 7461 293a 0a20 nd_data(data):. \n+00012ff0: 2020 2020 2020 2020 2020 2073 656c 662e self.\n+00013000: 7772 6974 655f 7761 6974 6572 203d 2061 write_waiter = a\n+00013010: 7379 6e63 696f 2e67 6574 5f72 756e 6e69 syncio.get_runni\n+00013020: 6e67 5f6c 6f6f 7028 292e 6372 6561 7465 ng_loop().create\n+00013030: 5f66 7574 7572 6528 290a 2020 2020 2020 _future(). \n+00013040: 2020 2020 2020 6177 6169 7420 7365 6c66 await self\n+00013050: 2e77 7269 7465 5f77 6169 7465 720a 0a20 .write_waiter.. \n+00013060: 2020 2061 7379 6e63 2064 6566 2073 656e async def sen\n+00013070: 6466 696c 6528 7365 6c66 2c20 7374 7265 dfile(self, stre\n+00013080: 616d 3a20 4269 6e61 7279 494f 2920 2d3e am: BinaryIO) ->\n+00013090: 204e 6f6e 653a 0a20 2020 2020 2020 206c None:. l\n+000130a0: 6f6f 7020 3d20 6173 796e 6369 6f2e 6765 oop = asyncio.ge\n+000130b0: 745f 7275 6e6e 696e 675f 6c6f 6f70 2829 t_running_loop()\n+000130c0: 0a20 2020 2020 2020 2077 6974 6820 7374 . with st\n+000130d0: 7265 616d 3a0a 2020 2020 2020 2020 2020 ream:. \n+000130e0: 2020 7768 696c 6520 5472 7565 3a0a 2020 while True:. \n+000130f0: 2020 2020 2020 2020 2020 2020 2020 6461 da\n+00013100: 7461 203d 2061 7761 6974 206c 6f6f 702e ta = await loop.\n+00013110: 7275 6e5f 696e 5f65 7865 6375 746f 7228 run_in_executor(\n+00013120: 4e6f 6e65 2c20 7374 7265 616d 2e72 6561 None, stream.rea\n+00013130: 642c 2043 6861 6e6e 656c 2e42 4c4f 434b d, Channel.BLOCK\n+00013140: 5f53 495a 4529 0a20 2020 2020 2020 2020 _SIZE). \n+00013150: 2020 2020 2020 2069 6620 6461 7461 203d if data =\n+00013160: 3d20 6227 273a 0a20 2020 2020 2020 2020 = b'':. \n+00013170: 2020 2020 2020 2020 2020 2062 7265 616b break\n+00013180: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+00013190: 2061 7761 6974 2073 656c 662e 7772 6974 await self.writ\n+000131a0: 6528 6461 7461 290a 0a20 2020 2020 2020 e(data).. \n+000131b0: 2020 2020 2073 656c 662e 646f 6e65 2829 self.done()\n+000131c0: 0a0a 2020 2020 6465 6620 646f 5f72 6573 .. def do_res\n+000131d0: 756d 655f 7365 6e64 2873 656c 6629 202d ume_send(self) -\n+000131e0: 3e20 4e6f 6e65 3a0a 2020 2020 2020 2020 > None:. \n+000131f0: 6966 2073 656c 662e 7772 6974 655f 7761 if self.write_wa\n+00013200: 6974 6572 2069 7320 6e6f 7420 4e6f 6e65 iter is not None\n+00013210: 3a0a 2020 2020 2020 2020 2020 2020 7365 :. se\n+00013220: 6c66 2e77 7269 7465 5f77 6169 7465 722e lf.write_waiter.\n+00013230: 7365 745f 7265 7375 6c74 284e 6f6e 6529 set_result(None)\n+00013240: 0a20 2020 2020 2020 2020 2020 2073 656c . sel\n+00013250: 662e 7772 6974 655f 7761 6974 6572 203d f.write_waiter =\n+00013260: 204e 6f6e 650a 0a20 2020 2064 6566 2064 None.. def d\n+00013270: 6f5f 6f70 656e 2873 656c 662c 206f 7074 o_open(self, opt\n+00013280: 696f 6e73 3a20 4a73 6f6e 4f62 6a65 6374 ions: JsonObject\n+00013290: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n+000132a0: 2020 2073 656c 662e 7265 6365 6976 655f self.receive_\n+000132b0: 7175 6575 6520 3d20 6173 796e 6369 6f2e queue = asyncio.\n+000132c0: 5175 6575 6528 290a 2020 2020 2020 2020 Queue(). \n+000132d0: 7365 6c66 2e5f 7275 6e5f 7461 736b 203d self._run_task =\n+000132e0: 2073 656c 662e 6372 6561 7465 5f74 6173 self.create_tas\n+000132f0: 6b28 7365 6c66 2e72 756e 5f77 7261 7070 k(self.run_wrapp\n+00013300: 6572 286f 7074 696f 6e73 292c 0a20 2020 er(options),. \n+00013310: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00013320: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00013330: 2020 2020 2020 206e 616d 653d 6627 7b73 name=f'{s\n+00013340: 656c 662e 5f5f 636c 6173 735f 5f2e 5f5f elf.__class__.__\n+00013350: 6e61 6d65 5f5f 7d2e 7275 6e5f 7772 6170 name__}.run_wrap\n+00013360: 7065 7228 7b6f 7074 696f 6e73 7d29 2729 per({options})')\n+00013370: 0a0a 2020 2020 6465 6620 646f 5f64 6f6e .. def do_don\n+00013380: 6528 7365 6c66 2920 2d3e 204e 6f6e 653a e(self) -> None:\n+00013390: 0a20 2020 2020 2020 2073 656c 662e 7265 . self.re\n+000133a0: 6365 6976 655f 7175 6575 652e 7075 745f ceive_queue.put_\n+000133b0: 6e6f 7761 6974 284e 6f6e 6529 0a0a 2020 nowait(None).. \n+000133c0: 2020 6465 6620 646f 5f63 6c6f 7365 2873 def do_close(s\n+000133d0: 656c 6629 202d 3e20 4e6f 6e65 3a0a 2020 elf) -> None:. \n+000133e0: 2020 2020 2020 7365 6c66 2e5f 7275 6e5f self._run_\n+000133f0: 7461 736b 2e63 616e 6365 6c28 290a 0a20 task.cancel().. \n+00013400: 2020 2064 6566 2064 6f5f 7069 6e67 2873 def do_ping(s\n+00013410: 656c 662c 206d 6573 7361 6765 3a20 4a73 elf, message: Js\n+00013420: 6f6e 4f62 6a65 6374 2920 2d3e 204e 6f6e onObject) -> Non\n+00013430: 653a 0a20 2020 2020 2020 2073 656c 662e e:. self.\n+00013440: 7265 6365 6976 655f 7175 6575 652e 7075 receive_queue.pu\n+00013450: 745f 6e6f 7761 6974 286d 6573 7361 6765 t_nowait(message\n+00013460: 290a 0a20 2020 2064 6566 2064 6f5f 6461 ).. def do_da\n+00013470: 7461 2873 656c 662c 2064 6174 613a 2062 ta(self, data: b\n+00013480: 7974 6573 2920 2d3e 2062 6f6f 6c3a 0a20 ytes) -> bool:. \n+00013490: 2020 2020 2020 2073 656c 662e 7265 6365 self.rece\n+000134a0: 6976 655f 7175 6575 652e 7075 745f 6e6f ive_queue.put_no\n+000134b0: 7761 6974 2864 6174 6129 0a20 2020 2020 wait(data). \n+000134c0: 2020 2072 6574 7572 6e20 5472 7565 2020 return True \n+000134d0: 2320 7765 2077 696c 6c20 7365 6e64 2074 # we will send t\n+000134e0: 6865 2027 6163 6b27 206c 6174 6572 2028 he 'ack' later (\n+000134f0: 6672 6f6d 2072 6561 6428 2929 0a0a 0a63 from read())...c\n+00013500: 6c61 7373 2047 656e 6572 6174 6f72 4368 lass GeneratorCh\n+00013510: 616e 6e65 6c28 4368 616e 6e65 6c29 3a0a annel(Channel):.\n+00013520: 2020 2020 2222 2241 2074 7269 7669 616c \"\"\"A trivial\n+00013530: 2043 6861 6e6e 656c 2073 7562 636c 6173 Channel subclas\n+00013540: 7320 666f 7220 7365 6e64 696e 6720 6461 s for sending da\n+00013550: 7461 2066 726f 6d20 6120 6765 6e65 7261 ta from a genera\n+00013560: 746f 7220 7769 7468 2066 6c6f 7720 636f tor with flow co\n+00013570: 6e74 726f 6c2e 0a0a 2020 2020 4361 6c6c ntrol... Call\n+00013580: 7320 7468 6520 2e64 6f5f 7969 656c 645f s the .do_yield_\n+00013590: 6461 7461 2829 2067 656e 6572 6174 6f72 data() generator\n+000135a0: 2077 6974 6820 7468 6520 6f70 7469 6f6e with the option\n+000135b0: 7320 6672 6f6d 2074 6865 206f 7065 6e20 s from the open \n+000135c0: 6d65 7373 6167 650a 2020 2020 616e 6420 message. and \n+000135d0: 7365 6e64 7320 7468 6520 6461 7461 2077 sends the data w\n+000135e0: 6869 6368 2069 7420 7969 656c 6473 2e20 hich it yields. \n+000135f0: 2049 6620 7468 6520 6765 6e65 7261 746f If the generato\n+00013600: 7220 7265 7475 726e 7320 6120 7661 6c75 r returns a valu\n+00013610: 6520 6974 0a20 2020 2077 696c 6c20 6265 e it. will be\n+00013620: 2075 7365 6420 666f 7220 7468 6520 636c used for the cl\n+00013630: 6f73 6520 6d65 7373 6167 652e 0a20 2020 ose message.. \n+00013640: 2022 2222 0a20 2020 2044 6174 6147 656e \"\"\". DataGen\n+00013650: 6572 6174 6f72 203d 2047 656e 6572 6174 erator = Generat\n+00013660: 6f72 5b62 7974 6573 2c20 4e6f 6e65 2c20 or[bytes, None, \n+00013670: 4f70 7469 6f6e 616c 5b4a 736f 6e4f 626a Optional[JsonObj\n+00013680: 6563 745d 5d0a 2020 2020 5f5f 6765 6e65 ect]]. __gene\n+00013690: 7261 746f 723a 2044 6174 6147 656e 6572 rator: DataGener\n+000136a0: 6174 6f72 0a0a 2020 2020 6465 6620 646f ator.. def do\n+000136b0: 5f79 6965 6c64 5f64 6174 6128 7365 6c66 _yield_data(self\n+000136c0: 2c20 6f70 7469 6f6e 733a 204a 736f 6e4f , options: JsonO\n+000136d0: 626a 6563 7429 202d 3e20 2744 6174 6147 bject) -> 'DataG\n+000136e0: 656e 6572 6174 6f72 273a 0a20 2020 2020 enerator':. \n+000136f0: 2020 2072 6169 7365 204e 6f74 496d 706c raise NotImpl\n+00013700: 656d 656e 7465 6445 7272 6f72 0a0a 2020 ementedError.. \n+00013710: 2020 6465 6620 646f 5f6f 7065 6e28 7365 def do_open(se\n+00013720: 6c66 2c20 6f70 7469 6f6e 733a 204a 736f lf, options: Jso\n+00013730: 6e4f 626a 6563 7429 202d 3e20 4e6f 6e65 nObject) -> None\n+00013740: 3a0a 2020 2020 2020 2020 7365 6c66 2e5f :. self._\n+00013750: 5f67 656e 6572 6174 6f72 203d 2073 656c _generator = sel\n+00013760: 662e 646f 5f79 6965 6c64 5f64 6174 6128 f.do_yield_data(\n+00013770: 6f70 7469 6f6e 7329 0a20 2020 2020 2020 options). \n+00013780: 2073 656c 662e 646f 5f72 6573 756d 655f self.do_resume_\n+00013790: 7365 6e64 2829 0a0a 2020 2020 6465 6620 send().. def \n+000137a0: 646f 5f72 6573 756d 655f 7365 6e64 2873 do_resume_send(s\n+000137b0: 656c 6629 202d 3e20 4e6f 6e65 3a0a 2020 elf) -> None:. \n+000137c0: 2020 2020 2020 7472 793a 0a20 2020 2020 try:. \n+000137d0: 2020 2020 2020 2077 6869 6c65 2073 656c while sel\n+000137e0: 662e 7365 6e64 5f64 6174 6128 6e65 7874 f.send_data(next\n+000137f0: 2873 656c 662e 5f5f 6765 6e65 7261 746f (self.__generato\n+00013800: 7229 293a 0a20 2020 2020 2020 2020 2020 r)):. \n+00013810: 2020 2020 2070 6173 730a 2020 2020 2020 pass. \n+00013820: 2020 6578 6365 7074 2053 746f 7049 7465 except StopIte\n+00013830: 7261 7469 6f6e 2061 7320 7374 6f70 3a0a ration as stop:.\n+00013840: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n+00013850: 2e64 6f6e 6528 290a 2020 2020 2020 2020 .done(). \n+00013860: 2020 2020 7365 6c66 2e63 6c6f 7365 2873 self.close(s\n+00013870: 746f 702e 7661 6c75 6529 0a27 2727 2e65 top.value).'''.e\n+00013880: 6e63 6f64 6528 2775 7466 2d38 2729 2c0a ncode('utf-8'),.\n+00013890: 2020 2763 6f63 6b70 6974 2f73 7570 6572 'cockpit/super\n+000138a0: 7573 6572 2e70 7927 3a20 6272 2727 2723 user.py': br'''#\n+000138b0: 2054 6869 7320 6669 6c65 2069 7320 7061 This file is pa\n+000138c0: 7274 206f 6620 436f 636b 7069 742e 0a23 rt of Cockpit..#\n+000138d0: 0a23 2043 6f70 7972 6967 6874 2028 4329 .# Copyright (C)\n+000138e0: 2032 3032 3220 5265 6420 4861 742c 2049 2022 Red Hat, I\n+000138f0: 6e63 2e0a 230a 2320 5468 6973 2070 726f nc..#.# This pro\n+00013900: 6772 616d 2069 7320 6672 6565 2073 6f66 gram is free sof\n+00013910: 7477 6172 653a 2079 6f75 2063 616e 2072 tware: you can r\n+00013920: 6564 6973 7472 6962 7574 6520 6974 2061 edistribute it a\n+00013930: 6e64 2f6f 7220 6d6f 6469 6679 0a23 2069 nd/or modify.# i\n+00013940: 7420 756e 6465 7220 7468 6520 7465 726d t under the term\n+00013950: 7320 6f66 2074 6865 2047 4e55 2047 656e s of the GNU Gen\n+00013960: 6572 616c 2050 7562 6c69 6320 4c69 6365 eral Public Lice\n+00013970: 6e73 6520 6173 2070 7562 6c69 7368 6564 nse as published\n+00013980: 2062 790a 2320 7468 6520 4672 6565 2053 by.# the Free S\n+00013990: 6f66 7477 6172 6520 466f 756e 6461 7469 oftware Foundati\n+000139a0: 6f6e 2c20 6569 7468 6572 2076 6572 7369 on, either versi\n+000139b0: 6f6e 2033 206f 6620 7468 6520 4c69 6365 on 3 of the Lice\n+000139c0: 6e73 652c 206f 720a 2320 2861 7420 796f nse, or.# (at yo\n+000139d0: 7572 206f 7074 696f 6e29 2061 6e79 206c ur option) any l\n+000139e0: 6174 6572 2076 6572 7369 6f6e 2e0a 230a ater version..#.\n+000139f0: 2320 5468 6973 2070 726f 6772 616d 2069 # This program i\n+00013a00: 7320 6469 7374 7269 6275 7465 6420 696e s distributed in\n+00013a10: 2074 6865 2068 6f70 6520 7468 6174 2069 the hope that i\n+00013a20: 7420 7769 6c6c 2062 6520 7573 6566 756c t will be useful\n+00013a30: 2c0a 2320 6275 7420 5749 5448 4f55 5420 ,.# but WITHOUT \n+00013a40: 414e 5920 5741 5252 414e 5459 3b20 7769 ANY WARRANTY; wi\n+00013a50: 7468 6f75 7420 6576 656e 2074 6865 2069 thout even the i\n+00013a60: 6d70 6c69 6564 2077 6172 7261 6e74 7920 mplied warranty \n+00013a70: 6f66 0a23 204d 4552 4348 414e 5441 4249 of.# MERCHANTABI\n+00013a80: 4c49 5459 206f 7220 4649 544e 4553 5320 LITY or FITNESS \n+00013a90: 464f 5220 4120 5041 5254 4943 554c 4152 FOR A PARTICULAR\n+00013aa0: 2050 5552 504f 5345 2e20 2053 6565 2074 PURPOSE. See t\n+00013ab0: 6865 0a23 2047 4e55 2047 656e 6572 616c he.# GNU General\n+00013ac0: 2050 7562 6c69 6320 4c69 6365 6e73 6520 Public License \n+00013ad0: 666f 7220 6d6f 7265 2064 6574 6169 6c73 for more details\n+00013ae0: 2e0a 230a 2320 596f 7520 7368 6f75 6c64 ..#.# You should\n+00013af0: 2068 6176 6520 7265 6365 6976 6564 2061 have received a\n+00013b00: 2063 6f70 7920 6f66 2074 6865 2047 4e55 copy of the GNU\n+00013b10: 2047 656e 6572 616c 2050 7562 6c69 6320 General Public \n+00013b20: 4c69 6365 6e73 650a 2320 616c 6f6e 6720 License.# along \n+00013b30: 7769 7468 2074 6869 7320 7072 6f67 7261 with this progra\n+00013b40: 6d2e 2020 4966 206e 6f74 2c20 7365 6520 m. If not, see \n+00013b50: 3c68 7474 7073 3a2f 2f77 7777 2e67 6e75 .\n+00013b70: 0a0a 696d 706f 7274 2061 7272 6179 0a69 ..import array.i\n+00013b80: 6d70 6f72 7420 6173 796e 6369 6f0a 696d mport asyncio.im\n+00013b90: 706f 7274 2063 6f6e 7465 7874 6c69 620a port contextlib.\n+00013ba0: 696d 706f 7274 2067 6574 7061 7373 0a69 import getpass.i\n+00013bb0: 6d70 6f72 7420 6c6f 6767 696e 670a 696d mport logging.im\n+00013bc0: 706f 7274 206f 730a 696d 706f 7274 2073 port os.import s\n+00013bd0: 6f63 6b65 740a 6672 6f6d 2074 656d 7066 ocket.from tempf\n+00013be0: 696c 6520 696d 706f 7274 2054 656d 706f ile import Tempo\n+00013bf0: 7261 7279 4469 7265 6374 6f72 790a 6672 raryDirectory.fr\n+00013c00: 6f6d 2074 7970 696e 6720 696d 706f 7274 om typing import\n+00013c10: 204c 6973 742c 204f 7074 696f 6e61 6c2c List, Optional,\n+00013c20: 2053 6571 7565 6e63 652c 2054 7570 6c65 Sequence, Tuple\n+00013c30: 0a0a 6672 6f6d 2063 6f63 6b70 6974 2e5f ..from cockpit._\n+00013c40: 7665 6e64 6f72 2069 6d70 6f72 7420 6665 vendor import fe\n+00013c50: 726e 790a 6672 6f6d 2063 6f63 6b70 6974 rny.from cockpit\n+00013c60: 2e5f 7665 6e64 6f72 2e62 6569 2e62 6f6f ._vendor.bei.boo\n+00013c70: 746c 6f61 6465 7220 696d 706f 7274 206d tloader import m\n+00013c80: 616b 655f 626f 6f74 6c6f 6164 6572 0a66 ake_bootloader.f\n+00013c90: 726f 6d20 636f 636b 7069 742e 5f76 656e rom cockpit._ven\n+00013ca0: 646f 722e 7379 7374 656d 645f 6374 7970 dor.systemd_ctyp\n+00013cb0: 6573 2069 6d70 6f72 7420 5661 7269 616e es import Varian\n+00013cc0: 742c 2062 7573 0a0a 6672 6f6d 202e 6265 t, bus..from .be\n+00013cd0: 6970 6163 6b20 696d 706f 7274 2042 7269 ipack import Bri\n+00013ce0: 6467 6542 6569 626f 6f74 4865 6c70 6572 dgeBeibootHelper\n+00013cf0: 0a66 726f 6d20 2e6a 736f 6e75 7469 6c20 .from .jsonutil \n+00013d00: 696d 706f 7274 204a 736f 6e4f 626a 6563 import JsonObjec\n+00013d10: 742c 2067 6574 5f73 7472 0a66 726f 6d20 t, get_str.from \n+00013d20: 2e70 6163 6b61 6765 7320 696d 706f 7274 .packages import\n+00013d30: 2042 7269 6467 6543 6f6e 6669 670a 6672 BridgeConfig.fr\n+00013d40: 6f6d 202e 7065 6572 2069 6d70 6f72 7420 om .peer import \n+00013d50: 436f 6e66 6967 7572 6564 5065 6572 2c20 ConfiguredPeer, \n+00013d60: 5065 6572 2c20 5065 6572 4572 726f 720a Peer, PeerError.\n+00013d70: 6672 6f6d 202e 706f 6c6b 6974 2069 6d70 from .polkit imp\n+00013d80: 6f72 7420 506f 6c6b 6974 4167 656e 740a ort PolkitAgent.\n+00013d90: 6672 6f6d 202e 726f 7574 6572 2069 6d70 from .router imp\n+00013da0: 6f72 7420 526f 7574 6572 2c20 526f 7574 ort Router, Rout\n+00013db0: 696e 6745 7272 6f72 2c20 526f 7574 696e ingError, Routin\n+00013dc0: 6752 756c 650a 0a6c 6f67 6765 7220 3d20 gRule..logger = \n+00013dd0: 6c6f 6767 696e 672e 6765 744c 6f67 6765 logging.getLogge\n+00013de0: 7228 5f5f 6e61 6d65 5f5f 290a 0a0a 636c r(__name__)...cl\n+00013df0: 6173 7320 5375 7065 7275 7365 7250 6565 ass SuperuserPee\n+00013e00: 7228 436f 6e66 6967 7572 6564 5065 6572 r(ConfiguredPeer\n+00013e10: 293a 0a20 2020 2072 6573 706f 6e64 6572 ):. responder\n+00013e20: 3a20 6665 726e 792e 4173 6b70 6173 7348 : ferny.AskpassH\n+00013e30: 616e 646c 6572 0a0a 2020 2020 6465 6620 andler.. def \n+00013e40: 5f5f 696e 6974 5f5f 2873 656c 662c 2072 __init__(self, r\n+00013e50: 6f75 7465 723a 2052 6f75 7465 722c 2063 outer: Router, c\n+00013e60: 6f6e 6669 673a 2042 7269 6467 6543 6f6e onfig: BridgeCon\n+00013e70: 6669 672c 2072 6573 706f 6e64 6572 3a20 fig, responder: \n+00013e80: 6665 726e 792e 4173 6b70 6173 7348 616e ferny.AskpassHan\n+00013e90: 646c 6572 293a 0a20 2020 2020 2020 2073 dler):. s\n+00013ea0: 7570 6572 2829 2e5f 5f69 6e69 745f 5f28 uper().__init__(\n+00013eb0: 726f 7574 6572 2c20 636f 6e66 6967 290a router, config).\n+00013ec0: 2020 2020 2020 2020 7365 6c66 2e72 6573 self.res\n+00013ed0: 706f 6e64 6572 203d 2072 6573 706f 6e64 ponder = respond\n+00013ee0: 6572 0a0a 2020 2020 6173 796e 6320 6465 er.. async de\n+00013ef0: 6620 646f 5f63 6f6e 6e65 6374 5f74 7261 f do_connect_tra\n+00013f00: 6e73 706f 7274 2873 656c 6629 202d 3e20 nsport(self) -> \n+00013f10: 4e6f 6e65 3a0a 2020 2020 2020 2020 6173 None:. as\n+00013f20: 796e 6320 7769 7468 2063 6f6e 7465 7874 ync with context\n+00013f30: 6c69 622e 4173 796e 6345 7869 7453 7461 lib.AsyncExitSta\n+00013f40: 636b 2829 2061 7320 636f 6e74 6578 743a ck() as context:\n+00013f50: 0a20 2020 2020 2020 2020 2020 2069 6620 . if \n+00013f60: 2770 6b65 7865 6327 2069 6e20 7365 6c66 'pkexec' in self\n+00013f70: 2e61 7267 733a 0a20 2020 2020 2020 2020 .args:. \n+00013f80: 2020 2020 2020 206c 6f67 6765 722e 6465 logger.de\n+00013f90: 6275 6728 2763 6f6e 6e65 6374 696e 6720 bug('connecting \n+00013fa0: 706f 6c6b 6974 2073 7570 6572 7573 6572 polkit superuser\n+00013fb0: 2070 6565 7220 7472 616e 7370 6f72 7420 peer transport \n+00013fc0: 2572 272c 2073 656c 662e 6172 6773 290a %r', self.args).\n+00013fd0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00013fe0: 6177 6169 7420 636f 6e74 6578 742e 656e await context.en\n+00013ff0: 7465 725f 6173 796e 635f 636f 6e74 6578 ter_async_contex\n+00014000: 7428 506f 6c6b 6974 4167 656e 7428 7365 t(PolkitAgent(se\n+00014010: 6c66 2e72 6573 706f 6e64 6572 2929 0a20 lf.responder)). \n+00014020: 2020 2020 2020 2020 2020 2065 6c73 653a else:\n+00014030: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+00014040: 206c 6f67 6765 722e 6465 6275 6728 2763 logger.debug('c\n+00014050: 6f6e 6e65 6374 696e 6720 6e6f 6e2d 706f onnecting non-po\n+00014060: 6c6b 6974 2073 7570 6572 7573 6572 2070 lkit superuser p\n+00014070: 6565 7220 7472 616e 7370 6f72 7420 2572 eer transport %r\n+00014080: 272c 2073 656c 662e 6172 6773 290a 0a20 ', self.args).. \n+00014090: 2020 2020 2020 2020 2020 2072 6573 706f respo\n+000140a0: 6e64 6572 733a 2027 6c69 7374 5b66 6572 nders: 'list[fer\n+000140b0: 6e79 2e49 6e74 6572 6163 7469 6f6e 4861 ny.InteractionHa\n+000140c0: 6e64 6c65 725d 2720 3d20 5b73 656c 662e ndler]' = [self.\n+000140d0: 7265 7370 6f6e 6465 725d 0a0a 2020 2020 responder].. \n+000140e0: 2020 2020 2020 2020 6966 2027 2320 636f if '# co\n+000140f0: 636b 7069 742d 6272 6964 6765 2720 696e ckpit-bridge' in\n+00014100: 2073 656c 662e 6172 6773 3a0a 2020 2020 self.args:. \n+00014110: 2020 2020 2020 2020 2020 2020 6c6f 6767 logg\n+00014120: 6572 2e64 6562 7567 2827 676f 696e 6720 er.debug('going \n+00014130: 746f 2062 6569 626f 6f74 2073 7570 6572 to beiboot super\n+00014140: 7573 6572 2062 7269 6467 6520 2572 272c user bridge %r',\n+00014150: 2073 656c 662e 6172 6773 290a 2020 2020 self.args). \n+00014160: 2020 2020 2020 2020 2020 2020 6865 6c70 help\n+00014170: 6572 203d 2042 7269 6467 6542 6569 626f er = BridgeBeibo\n+00014180: 6f74 4865 6c70 6572 2873 656c 662c 205b otHelper(self, [\n+00014190: 272d 2d70 7269 7669 6c65 6765 6427 5d29 '--privileged'])\n+000141a0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+000141b0: 2072 6573 706f 6e64 6572 732e 6170 7065 responders.appe\n+000141c0: 6e64 2868 656c 7065 7229 0a20 2020 2020 nd(helper). \n+000141d0: 2020 2020 2020 2020 2020 2073 7461 6765 stage\n+000141e0: 3120 3d20 6d61 6b65 5f62 6f6f 746c 6f61 1 = make_bootloa\n+000141f0: 6465 7228 6865 6c70 6572 2e73 7465 7073 der(helper.steps\n+00014200: 2c20 6761 6467 6574 733d 6665 726e 792e , gadgets=ferny.\n+00014210: 4245 4942 4f4f 545f 4741 4447 4554 5329 BEIBOOT_GADGETS)\n+00014220: 2e65 6e63 6f64 6528 290a 2020 2020 2020 .encode(). \n+00014230: 2020 2020 2020 656c 7365 3a0a 2020 2020 else:. \n+00014240: 2020 2020 2020 2020 2020 2020 7374 6167 stag\n+00014250: 6531 203d 204e 6f6e 650a 0a20 2020 2020 e1 = None.. \n+00014260: 2020 2020 2020 2061 6765 6e74 203d 2066 agent = f\n+00014270: 6572 6e79 2e49 6e74 6572 6163 7469 6f6e erny.Interaction\n+00014280: 4167 656e 7428 7265 7370 6f6e 6465 7273 Agent(responders\n+00014290: 290a 0a20 2020 2020 2020 2020 2020 2069 ).. i\n+000142a0: 6620 2753 5544 4f5f 4153 4b50 4153 533d f 'SUDO_ASKPASS=\n+000142b0: 6665 726e 792d 6173 6b70 6173 7327 2069 ferny-askpass' i\n+000142c0: 6e20 7365 6c66 2e65 6e76 3a0a 2020 2020 n self.env:. \n+000142d0: 2020 2020 2020 2020 2020 2020 746d 7064 tmpd\n+000142e0: 6972 203d 2063 6f6e 7465 7874 2e65 6e74 ir = context.ent\n+000142f0: 6572 5f63 6f6e 7465 7874 2854 656d 706f er_context(Tempo\n+00014300: 7261 7279 4469 7265 6374 6f72 7928 2929 raryDirectory())\n+00014310: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+00014320: 2066 6572 6e79 5f61 736b 7061 7373 203d ferny_askpass =\n+00014330: 2066 6572 6e79 2e77 7269 7465 5f61 736b ferny.write_ask\n+00014340: 7061 7373 5f74 6f5f 746d 7064 6972 2874 pass_to_tmpdir(t\n+00014350: 6d70 6469 7229 0a20 2020 2020 2020 2020 mpdir). \n+00014360: 2020 2020 2020 2065 6e76 3a20 5365 7175 env: Sequ\n+00014370: 656e 6365 5b73 7472 5d20 3d20 5b66 2753 ence[str] = [f'S\n+00014380: 5544 4f5f 4153 4b50 4153 533d 7b66 6572 UDO_ASKPASS={fer\n+00014390: 6e79 5f61 736b 7061 7373 7d27 5d0a 2020 ny_askpass}']. \n+000143a0: 2020 2020 2020 2020 2020 656c 7365 3a0a else:.\n+000143b0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000143c0: 656e 7620 3d20 7365 6c66 2e65 6e76 0a0a env = self.env..\n+000143d0: 2020 2020 2020 2020 2020 2020 7472 616e tran\n+000143e0: 7370 6f72 7420 3d20 6177 6169 7420 7365 sport = await se\n+000143f0: 6c66 2e73 7061 776e 2873 656c 662e 6172 lf.spawn(self.ar\n+00014400: 6773 2c20 656e 762c 2073 7464 6572 723d gs, env, stderr=\n+00014410: 6167 656e 742c 2073 7461 7274 5f6e 6577 agent, start_new\n+00014420: 5f73 6573 7369 6f6e 3d54 7275 6529 0a0a _session=True)..\n+00014430: 2020 2020 2020 2020 2020 2020 6966 2073 if s\n+00014440: 7461 6765 3120 6973 206e 6f74 204e 6f6e tage1 is not Non\n+00014450: 653a 0a20 2020 2020 2020 2020 2020 2020 e:. \n+00014460: 2020 2074 7261 6e73 706f 7274 2e77 7269 transport.wri\n+00014470: 7465 2873 7461 6765 3129 0a0a 2020 2020 te(stage1).. \n+00014480: 2020 2020 2020 2020 7472 793a 0a20 2020 try:. \n+00014490: 2020 2020 2020 2020 2020 2020 2061 7761 awa\n+000144a0: 6974 2061 6765 6e74 2e63 6f6d 6d75 6e69 it agent.communi\n+000144b0: 6361 7465 2829 0a20 2020 2020 2020 2020 cate(). \n+000144c0: 2020 2065 7863 6570 7420 6665 726e 792e except ferny.\n+000144d0: 496e 7465 7261 6374 696f 6e45 7272 6f72 InteractionError\n+000144e0: 2061 7320 6578 633a 0a20 2020 2020 2020 as exc:. \n+000144f0: 2020 2020 2020 2020 2072 6169 7365 2050 raise P\n+00014500: 6565 7245 7272 6f72 2827 6175 7468 656e eerError('authen\n+00014510: 7469 6361 7469 6f6e 2d66 6169 6c65 6427 tication-failed'\n+00014520: 2c20 6d65 7373 6167 653d 7374 7228 6578 , message=str(ex\n+00014530: 6329 2920 6672 6f6d 2065 7863 0a0a 0a63 c)) from exc...c\n+00014540: 6c61 7373 2043 6f63 6b70 6974 5265 7370 lass CockpitResp\n+00014550: 6f6e 6465 7228 6665 726e 792e 4173 6b70 onder(ferny.Askp\n+00014560: 6173 7348 616e 646c 6572 293a 0a20 2020 assHandler):. \n+00014570: 2063 6f6d 6d61 6e64 7320 3d20 2827 6665 commands = ('fe\n+00014580: 726e 792e 6173 6b70 6173 7327 2c20 2763 rny.askpass', 'c\n+00014590: 6f63 6b70 6974 2e73 656e 642d 7374 6465 ockpit.send-stde\n+000145a0: 7272 2729 0a0a 2020 2020 6173 796e 6320 rr').. async \n+000145b0: 6465 6620 646f 5f63 7573 746f 6d5f 636f def do_custom_co\n+000145c0: 6d6d 616e 6428 7365 6c66 2c20 636f 6d6d mmand(self, comm\n+000145d0: 616e 643a 2073 7472 2c20 6172 6773 3a20 and: str, args: \n+000145e0: 5475 706c 652c 2066 6473 3a20 4c69 7374 Tuple, fds: List\n+000145f0: 5b69 6e74 5d2c 2073 7464 6572 723a 2073 [int], stderr: s\n+00014600: 7472 2920 2d3e 204e 6f6e 653a 0a20 2020 tr) -> None:. \n+00014610: 2020 2020 2069 6620 636f 6d6d 616e 6420 if command \n+00014620: 3d3d 2027 636f 636b 7069 742e 7365 6e64 == 'cockpit.send\n+00014630: 2d73 7464 6572 7227 3a0a 2020 2020 2020 -stderr':. \n+00014640: 2020 2020 2020 7769 7468 2073 6f63 6b65 with socke\n+00014650: 742e 736f 636b 6574 2866 696c 656e 6f3d t.socket(fileno=\n+00014660: 6664 735b 305d 2920 6173 2073 6f63 6b3a fds[0]) as sock:\n+00014670: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+00014680: 2066 6473 2e70 6f70 2830 290a 2020 2020 fds.pop(0). \n+00014690: 2020 2020 2020 2020 2020 2020 2320 736f # so\n+000146a0: 636b 6574 2e73 656e 645f 6664 7328 736f cket.send_fds(so\n+000146b0: 636b 2c20 5b62 275c 3027 5d2c 205b 325d ck, [b'\\0'], [2]\n+000146c0: 2920 2023 204e 6577 2069 6e20 5079 7468 ) # New in Pyth\n+000146d0: 6f6e 2033 2e39 0a20 2020 2020 2020 2020 on 3.9. \n+000146e0: 2020 2020 2020 2073 6f63 6b2e 7365 6e64 sock.send\n+000146f0: 6d73 6728 5b62 275c 3027 5d2c 205b 2873 msg([b'\\0'], [(s\n+00014700: 6f63 6b65 742e 534f 4c5f 534f 434b 4554 ocket.SOL_SOCKET\n+00014710: 2c20 736f 636b 6574 2e53 434d 5f52 4947 , socket.SCM_RIG\n+00014720: 4854 532c 2061 7272 6179 2e61 7272 6179 HTS, array.array\n+00014730: 2822 6922 2c20 5b32 5d29 295d 290a 0a0a (\"i\", [2]))])...\n+00014740: 636c 6173 7320 4175 7468 6f72 697a 6552 class AuthorizeR\n+00014750: 6573 706f 6e64 6572 2843 6f63 6b70 6974 esponder(Cockpit\n+00014760: 5265 7370 6f6e 6465 7229 3a0a 2020 2020 Responder):. \n+00014770: 6465 6620 5f5f 696e 6974 5f5f 2873 656c def __init__(sel\n+00014780: 662c 2072 6f75 7465 723a 2052 6f75 7465 f, router: Route\n+00014790: 7229 3a0a 2020 2020 2020 2020 7365 6c66 r):. self\n+000147a0: 2e72 6f75 7465 7220 3d20 726f 7574 6572 .router = router\n+000147b0: 0a0a 2020 2020 6173 796e 6320 6465 6620 .. async def \n+000147c0: 646f 5f61 736b 7061 7373 2873 656c 662c do_askpass(self,\n+000147d0: 206d 6573 7361 6765 733a 2073 7472 2c20 messages: str, \n+000147e0: 7072 6f6d 7074 3a20 7374 722c 2068 696e prompt: str, hin\n+000147f0: 743a 2073 7472 2920 2d3e 2073 7472 3a0a t: str) -> str:.\n+00014800: 2020 2020 2020 2020 6865 7875 7365 7220 hexuser \n+00014810: 3d20 2727 2e6a 6f69 6e28 6627 7b63 3a30 = ''.join(f'{c:0\n+00014820: 3278 7d27 2066 6f72 2063 2069 6e20 6765 2x}' for c in ge\n+00014830: 7470 6173 732e 6765 7475 7365 7228 292e tpass.getuser().\n+00014840: 656e 636f 6465 2827 6173 6369 6927 2929 encode('ascii'))\n+00014850: 0a20 2020 2020 2020 2072 6574 7572 6e20 . return \n+00014860: 6177 6169 7420 7365 6c66 2e72 6f75 7465 await self.route\n+00014870: 722e 7265 7175 6573 745f 6175 7468 6f72 r.request_author\n+00014880: 697a 6174 696f 6e28 6627 706c 6169 6e31 ization(f'plain1\n+00014890: 3a7b 6865 7875 7365 727d 2729 0a0a 0a63 :{hexuser}')...c\n+000148a0: 6c61 7373 2053 7570 6572 7573 6572 526f lass SuperuserRo\n+000148b0: 7574 696e 6752 756c 6528 526f 7574 696e utingRule(Routin\n+000148c0: 6752 756c 652c 2043 6f63 6b70 6974 5265 gRule, CockpitRe\n+000148d0: 7370 6f6e 6465 722c 2062 7573 2e4f 626a sponder, bus.Obj\n+000148e0: 6563 742c 2069 6e74 6572 6661 6365 3d27 ect, interface='\n+000148f0: 636f 636b 7069 742e 5375 7065 7275 7365 cockpit.Superuse\n+00014900: 7227 293a 0a20 2020 2073 7570 6572 7573 r'):. superus\n+00014910: 6572 5f63 6f6e 6669 6773 3a20 5365 7175 er_configs: Sequ\n+00014920: 656e 6365 5b42 7269 6467 6543 6f6e 6669 ence[BridgeConfi\n+00014930: 675d 203d 2028 290a 2020 2020 7065 6e64 g] = (). pend\n+00014940: 696e 675f 7072 6f6d 7074 3a20 4f70 7469 ing_prompt: Opti\n+00014950: 6f6e 616c 5b61 7379 6e63 696f 2e46 7574 onal[asyncio.Fut\n+00014960: 7572 655d 0a20 2020 2070 6565 723a 204f ure]. peer: O\n+00014970: 7074 696f 6e61 6c5b 5375 7065 7275 7365 ptional[Superuse\n+00014980: 7250 6565 725d 0a0a 2020 2020 2320 442d rPeer].. # D-\n+00014990: 4275 7320 7369 676e 616c 730a 2020 2020 Bus signals. \n+000149a0: 7072 6f6d 7074 203d 2062 7573 2e49 6e74 prompt = bus.Int\n+000149b0: 6572 6661 6365 2e53 6967 6e61 6c28 2773 erface.Signal('s\n+000149c0: 272c 2027 7327 2c20 2773 272c 2027 6227 ', 's', 's', 'b'\n+000149d0: 2c20 2773 2729 2020 2320 6d65 7373 6167 , 's') # messag\n+000149e0: 652c 2070 726f 6d70 742c 2064 6566 6175 e, prompt, defau\n+000149f0: 6c74 2c20 6563 686f 2c20 6572 726f 720a lt, echo, error.\n+00014a00: 0a20 2020 2023 2044 2d42 7573 2070 726f . # D-Bus pro\n+00014a10: 7065 7274 6965 730a 2020 2020 6272 6964 perties. brid\n+00014a20: 6765 7320 3d20 6275 732e 496e 7465 7266 ges = bus.Interf\n+00014a30: 6163 652e 5072 6f70 6572 7479 2827 6173 ace.Property('as\n+00014a40: 272c 2076 616c 7565 3d5b 5d29 0a20 2020 ', value=[]). \n+00014a50: 2063 7572 7265 6e74 203d 2062 7573 2e49 current = bus.I\n+00014a60: 6e74 6572 6661 6365 2e50 726f 7065 7274 nterface.Propert\n+00014a70: 7928 2773 272c 2076 616c 7565 3d27 6e6f y('s', value='no\n+00014a80: 6e65 2729 0a20 2020 206d 6574 686f 6473 ne'). methods\n+00014a90: 203d 2062 7573 2e49 6e74 6572 6661 6365 = bus.Interface\n+00014aa0: 2e50 726f 7065 7274 7928 2761 7b73 767d .Property('a{sv}\n+00014ab0: 272c 2076 616c 7565 3d7b 7d29 0a0a 2020 ', value={}).. \n+00014ac0: 2020 2320 526f 7574 696e 6752 756c 650a # RoutingRule.\n+00014ad0: 2020 2020 6465 6620 6170 706c 795f 7275 def apply_ru\n+00014ae0: 6c65 2873 656c 662c 206f 7074 696f 6e73 le(self, options\n+00014af0: 3a20 4a73 6f6e 4f62 6a65 6374 2920 2d3e : JsonObject) ->\n+00014b00: 204f 7074 696f 6e61 6c5b 5065 6572 5d3a Optional[Peer]:\n+00014b10: 0a20 2020 2020 2020 2073 7570 6572 7573 . superus\n+00014b20: 6572 203d 206f 7074 696f 6e73 2e67 6574 er = options.get\n+00014b30: 2827 7375 7065 7275 7365 7227 290a 0a20 ('superuser').. \n+00014b40: 2020 2020 2020 2069 6620 6e6f 7420 7375 if not su\n+00014b50: 7065 7275 7365 7220 6f72 2073 656c 662e peruser or self.\n+00014b60: 6375 7272 656e 7420 3d3d 2027 726f 6f74 current == 'root\n+00014b70: 273a 0a20 2020 2020 2020 2020 2020 2023 ':. #\n+00014b80: 2073 7570 6572 7573 6572 206e 6f74 2072 superuser not r\n+00014b90: 6571 7565 7374 6564 2c20 6f72 2061 6c72 equested, or alr\n+00014ba0: 6561 6479 2073 7570 6572 7573 6572 3f20 eady superuser? \n+00014bb0: 204e 6578 7420 7275 6c65 2e0a 2020 2020 Next rule.. \n+00014bc0: 2020 2020 2020 2020 7265 7475 726e 204e return N\n+00014bd0: 6f6e 650a 2020 2020 2020 2020 656c 6966 one. elif\n+00014be0: 2073 656c 662e 7065 6572 206f 7220 7375 self.peer or su\n+00014bf0: 7065 7275 7365 7220 3d3d 2027 7472 7927 peruser == 'try'\n+00014c00: 3a0a 2020 2020 2020 2020 2020 2020 2320 :. # \n+00014c10: 7375 7065 7275 7365 7220 7265 7175 6573 superuser reques\n+00014c20: 7465 6420 616e 6420 6163 7469 7665 3f20 ted and active? \n+00014c30: 2052 6574 7572 6e20 6974 2e0a 2020 2020 Return it.. \n+00014c40: 2020 2020 2020 2020 2320 2774 7279 2720 # 'try' \n+00014c50: 7265 7175 6573 7465 643f 2020 4569 7468 requested? Eith\n+00014c60: 6572 2072 6574 7572 6e20 7468 6520 7065 er return the pe\n+00014c70: 6572 2c20 6f72 204e 6f6e 652e 0a20 2020 er, or None.. \n+00014c80: 2020 2020 2020 2020 2072 6574 7572 6e20 return \n+00014c90: 7365 6c66 2e70 6565 720a 2020 2020 2020 self.peer. \n+00014ca0: 2020 656c 7365 3a0a 2020 2020 2020 2020 else:. \n+00014cb0: 2020 2020 2320 7375 7065 7275 7365 7220 # superuser \n+00014cc0: 7265 7175 6573 7465 642c 2062 7574 206e requested, but n\n+00014cd0: 6f74 2061 6374 6976 653f 2020 5468 6174 ot active? That\n+00014ce0: 2773 2061 6e20 6572 726f 722e 0a20 2020 's an error.. \n+00014cf0: 2020 2020 2020 2020 2072 6169 7365 2052 raise R\n+00014d00: 6f75 7469 6e67 4572 726f 7228 2761 6363 outingError('acc\n+00014d10: 6573 732d 6465 6e69 6564 2729 0a0a 2020 ess-denied').. \n+00014d20: 2020 2320 6665 726e 792e 4173 6b70 6173 # ferny.Askpas\n+00014d30: 7348 616e 646c 6572 0a20 2020 2061 7379 sHandler. asy\n+00014d40: 6e63 2064 6566 2064 6f5f 6173 6b70 6173 nc def do_askpas\n+00014d50: 7328 7365 6c66 2c20 6d65 7373 6167 6573 s(self, messages\n+00014d60: 3a20 7374 722c 2070 726f 6d70 743a 2073 : str, prompt: s\n+00014d70: 7472 2c20 6869 6e74 3a20 7374 7229 202d tr, hint: str) -\n+00014d80: 3e20 4f70 7469 6f6e 616c 5b73 7472 5d3a > Optional[str]:\n+00014d90: 0a20 2020 2020 2020 2061 7373 6572 7420 . assert \n+00014da0: 7365 6c66 2e70 656e 6469 6e67 5f70 726f self.pending_pro\n+00014db0: 6d70 7420 6973 204e 6f6e 650a 2020 2020 mpt is None. \n+00014dc0: 2020 2020 6563 686f 203d 2068 696e 7420 echo = hint \n+00014dd0: 3d3d 2022 636f 6e66 6972 6d22 0a20 2020 == \"confirm\". \n+00014de0: 2020 2020 2073 656c 662e 7065 6e64 696e self.pendin\n+00014df0: 675f 7072 6f6d 7074 203d 2061 7379 6e63 g_prompt = async\n+00014e00: 696f 2e67 6574 5f72 756e 6e69 6e67 5f6c io.get_running_l\n+00014e10: 6f6f 7028 292e 6372 6561 7465 5f66 7574 oop().create_fut\n+00014e20: 7572 6528 290a 2020 2020 2020 2020 7472 ure(). tr\n+00014e30: 793a 0a20 2020 2020 2020 2020 2020 206c y:. l\n+00014e40: 6f67 6765 722e 6465 6275 6728 2770 726f ogger.debug('pro\n+00014e50: 6d70 7469 6e67 2066 6f72 2025 7327 2c20 mpting for %s', \n+00014e60: 7072 6f6d 7074 290a 2020 2020 2020 2020 prompt). \n+00014e70: 2020 2020 2320 7769 7468 2073 7564 6f2c # with sudo,\n+00014e80: 2061 6c6c 2073 7464 6572 7220 6d65 7373 all stderr mess\n+00014e90: 6167 6573 2061 7265 2074 7265 6174 6564 ages are treated\n+00014ea0: 2061 7320 7761 726e 696e 672f 6572 726f as warning/erro\n+00014eb0: 7273 2062 7920 7468 6520 5549 0a20 2020 rs by the UI. \n+00014ec0: 2020 2020 2020 2020 2023 2028 7375 6368 # (such\n+00014ed0: 2061 7320 7468 6520 6c65 6374 7572 6520 as the lecture \n+00014ee0: 6f72 2022 7772 6f6e 6720 7061 7373 776f or \"wrong passwo\n+00014ef0: 7264 2229 2c20 736f 2070 6173 7320 7468 rd\"), so pass th\n+00014f00: 656d 2069 6e20 7468 6520 2265 7272 6f72 em in the \"error\n+00014f10: 2220 6669 656c 640a 2020 2020 2020 2020 \" field. \n+00014f20: 2020 2020 7365 6c66 2e70 726f 6d70 7428 self.prompt(\n+00014f30: 2727 2c20 7072 6f6d 7074 2c20 2727 2c20 '', prompt, '', \n+00014f40: 6563 686f 2c20 6d65 7373 6167 6573 290a echo, messages).\n+00014f50: 2020 2020 2020 2020 2020 2020 7265 7475 retu\n+00014f60: 726e 2061 7761 6974 2073 656c 662e 7065 rn await self.pe\n+00014f70: 6e64 696e 675f 7072 6f6d 7074 0a20 2020 nding_prompt. \n+00014f80: 2020 2020 2066 696e 616c 6c79 3a0a 2020 finally:. \n+00014f90: 2020 2020 2020 2020 2020 7365 6c66 2e70 self.p\n+00014fa0: 656e 6469 6e67 5f70 726f 6d70 7420 3d20 ending_prompt = \n+00014fb0: 4e6f 6e65 0a0a 2020 2020 6465 6620 5f5f None.. def __\n+00014fc0: 696e 6974 5f5f 2873 656c 662c 2072 6f75 init__(self, rou\n+00014fd0: 7465 723a 2052 6f75 7465 722c 202a 2c20 ter: Router, *, \n+00014fe0: 7072 6976 696c 6567 6564 3a20 626f 6f6c privileged: bool\n+00014ff0: 203d 2046 616c 7365 293a 0a20 2020 2020 = False):. \n+00015000: 2020 2073 7570 6572 2829 2e5f 5f69 6e69 super().__ini\n+00015010: 745f 5f28 726f 7574 6572 290a 0a20 2020 t__(router).. \n+00015020: 2020 2020 2073 656c 662e 7065 6e64 696e self.pendin\n+00015030: 675f 7072 6f6d 7074 203d 204e 6f6e 650a g_prompt = None.\n+00015040: 2020 2020 2020 2020 7365 6c66 2e70 6565 self.pee\n+00015050: 7220 3d20 4e6f 6e65 0a20 2020 2020 2020 r = None. \n+00015060: 2073 656c 662e 7374 6172 7475 7020 3d20 self.startup = \n+00015070: 4e6f 6e65 0a0a 2020 2020 2020 2020 6966 None.. if\n+00015080: 2070 7269 7669 6c65 6765 6420 6f72 206f privileged or o\n+00015090: 732e 6765 7475 6964 2829 203d 3d20 303a s.getuid() == 0:\n+000150a0: 0a20 2020 2020 2020 2020 2020 2073 656c . sel\n+000150b0: 662e 6375 7272 656e 7420 3d20 2772 6f6f f.current = 'roo\n+000150c0: 7427 0a0a 2020 2020 6465 6620 7065 6572 t'.. def peer\n+000150d0: 5f64 6f6e 6528 7365 6c66 293a 0a20 2020 _done(self):. \n+000150e0: 2020 2020 2073 656c 662e 6375 7272 656e self.curren\n+000150f0: 7420 3d20 276e 6f6e 6527 0a20 2020 2020 t = 'none'. \n+00015100: 2020 2073 656c 662e 7065 6572 203d 204e self.peer = N\n+00015110: 6f6e 650a 0a20 2020 2061 7379 6e63 2064 one.. async d\n+00015120: 6566 2067 6f28 7365 6c66 2c20 6e61 6d65 ef go(self, name\n+00015130: 3a20 7374 722c 2072 6573 706f 6e64 6572 : str, responder\n+00015140: 3a20 6665 726e 792e 4173 6b70 6173 7348 : ferny.AskpassH\n+00015150: 616e 646c 6572 2920 2d3e 204e 6f6e 653a andler) -> None:\n+00015160: 0a20 2020 2020 2020 2069 6620 7365 6c66 . if self\n+00015170: 2e63 7572 7265 6e74 2021 3d20 276e 6f6e .current != 'non\n+00015180: 6527 3a0a 2020 2020 2020 2020 2020 2020 e':. \n+00015190: 7261 6973 6520 6275 732e 4275 7345 7272 raise bus.BusErr\n+000151a0: 6f72 2827 636f 636b 7069 742e 5375 7065 or('cockpit.Supe\n+000151b0: 7275 7365 722e 4572 726f 7227 2c20 2753 ruser.Error', 'S\n+000151c0: 7570 6572 7573 6572 2062 7269 6467 6520 uperuser bridge \n+000151d0: 616c 7265 6164 7920 7275 6e6e 696e 6727 already running'\n+000151e0: 290a 0a20 2020 2020 2020 2061 7373 6572 ).. asser\n+000151f0: 7420 7365 6c66 2e70 6565 7220 6973 204e t self.peer is N\n+00015200: 6f6e 650a 2020 2020 2020 2020 6173 7365 one. asse\n+00015210: 7274 2073 656c 662e 7374 6172 7475 7020 rt self.startup \n+00015220: 6973 204e 6f6e 650a 0a20 2020 2020 2020 is None.. \n+00015230: 2066 6f72 2063 6f6e 6669 6720 696e 2073 for config in s\n+00015240: 656c 662e 7375 7065 7275 7365 725f 636f elf.superuser_co\n+00015250: 6e66 6967 733a 0a20 2020 2020 2020 2020 nfigs:. \n+00015260: 2020 2069 6620 6e61 6d65 2069 6e20 2863 if name in (c\n+00015270: 6f6e 6669 672e 6e61 6d65 2c20 2761 6e79 onfig.name, 'any\n+00015280: 2729 3a0a 2020 2020 2020 2020 2020 2020 '):. \n+00015290: 2020 2020 6272 6561 6b0a 2020 2020 2020 break. \n+000152a0: 2020 656c 7365 3a0a 2020 2020 2020 2020 else:. \n+000152b0: 2020 2020 7261 6973 6520 6275 732e 4275 raise bus.Bu\n+000152c0: 7345 7272 6f72 2827 636f 636b 7069 742e sError('cockpit.\n+000152d0: 5375 7065 7275 7365 722e 4572 726f 7227 Superuser.Error'\n+000152e0: 2c20 6627 556e 6b6e 6f77 6e20 7375 7065 , f'Unknown supe\n+000152f0: 7275 7365 7220 6272 6964 6765 2074 7970 ruser bridge typ\n+00015300: 6520 227b 6e61 6d65 7d22 2729 0a0a 2020 e \"{name}\"').. \n+00015310: 2020 2020 2020 7365 6c66 2e63 7572 7265 self.curre\n+00015320: 6e74 203d 2027 696e 6974 270a 2020 2020 nt = 'init'. \n+00015330: 2020 2020 7365 6c66 2e70 6565 7220 3d20 self.peer = \n+00015340: 5375 7065 7275 7365 7250 6565 7228 7365 SuperuserPeer(se\n+00015350: 6c66 2e72 6f75 7465 722c 2063 6f6e 6669 lf.router, confi\n+00015360: 672c 2072 6573 706f 6e64 6572 290a 2020 g, responder). \n+00015370: 2020 2020 2020 7365 6c66 2e70 6565 722e self.peer.\n+00015380: 6164 645f 646f 6e65 5f63 616c 6c62 6163 add_done_callbac\n+00015390: 6b28 7365 6c66 2e70 6565 725f 646f 6e65 k(self.peer_done\n+000153a0: 290a 0a20 2020 2020 2020 2074 7279 3a0a ).. try:.\n+000153b0: 2020 2020 2020 2020 2020 2020 6177 6169 awai\n+000153c0: 7420 7365 6c66 2e70 6565 722e 7374 6172 t self.peer.star\n+000153d0: 7428 696e 6974 5f68 6f73 743d 7365 6c66 t(init_host=self\n+000153e0: 2e72 6f75 7465 722e 696e 6974 5f68 6f73 .router.init_hos\n+000153f0: 7429 0a20 2020 2020 2020 2065 7863 6570 t). excep\n+00015400: 7420 6173 796e 6369 6f2e 4361 6e63 656c t asyncio.Cancel\n+00015410: 6c65 6445 7272 6f72 3a0a 2020 2020 2020 ledError:. \n+00015420: 2020 2020 2020 7261 6973 6520 6275 732e raise bus.\n+00015430: 4275 7345 7272 6f72 2827 636f 636b 7069 BusError('cockpi\n+00015440: 742e 5375 7065 7275 7365 722e 4572 726f t.Superuser.Erro\n+00015450: 722e 4361 6e63 656c 6c65 6427 2c20 274f r.Cancelled', 'O\n+00015460: 7065 7261 7469 6f6e 2061 626f 7274 6564 peration aborted\n+00015470: 2729 2066 726f 6d20 4e6f 6e65 0a20 2020 ') from None. \n+00015480: 2020 2020 2065 7863 6570 7420 284f 5345 except (OSE\n+00015490: 7272 6f72 2c20 5065 6572 4572 726f 7229 rror, PeerError)\n+000154a0: 2061 7320 6578 633a 0a20 2020 2020 2020 as exc:. \n+000154b0: 2020 2020 2072 6169 7365 2062 7573 2e42 raise bus.B\n+000154c0: 7573 4572 726f 7228 2763 6f63 6b70 6974 usError('cockpit\n+000154d0: 2e53 7570 6572 7573 6572 2e45 7272 6f72 .Superuser.Error\n+000154e0: 272c 2073 7472 2865 7863 2929 2066 726f ', str(exc)) fro\n+000154f0: 6d20 6578 630a 0a20 2020 2020 2020 2073 m exc.. s\n+00015500: 656c 662e 6375 7272 656e 7420 3d20 7365 elf.current = se\n+00015510: 6c66 2e70 6565 722e 636f 6e66 6967 2e6e lf.peer.config.n\n+00015520: 616d 650a 0a20 2020 2064 6566 2073 6574 ame.. def set\n+00015530: 5f63 6f6e 6669 6773 2873 656c 662c 2063 _configs(self, c\n+00015540: 6f6e 6669 6773 3a20 5365 7175 656e 6365 onfigs: Sequence\n+00015550: 5b42 7269 6467 6543 6f6e 6669 675d 293a [BridgeConfig]):\n+00015560: 0a20 2020 2020 2020 206c 6f67 6765 722e . logger.\n+00015570: 6465 6275 6728 2273 6574 5f63 6f6e 6669 debug(\"set_confi\n+00015580: 6773 2829 2077 6974 6820 2564 2069 7465 gs() with %d ite\n+00015590: 6d73 222c 206c 656e 2863 6f6e 6669 6773 ms\", len(configs\n+000155a0: 2929 0a20 2020 2020 2020 2063 6f6e 6669 )). confi\n+000155b0: 6773 203d 205b 636f 6e66 6967 2066 6f72 gs = [config for\n+000155c0: 2063 6f6e 6669 6720 696e 2063 6f6e 6669 config in confi\n+000155d0: 6773 2069 6620 636f 6e66 6967 2e70 7269 gs if config.pri\n+000155e0: 7669 6c65 6765 645d 0a20 2020 2020 2020 vileged]. \n+000155f0: 2073 656c 662e 7375 7065 7275 7365 725f self.superuser_\n+00015600: 636f 6e66 6967 7320 3d20 7475 706c 6528 configs = tuple(\n+00015610: 636f 6e66 6967 7329 0a20 2020 2020 2020 configs). \n+00015620: 2073 656c 662e 6272 6964 6765 7320 3d20 self.bridges = \n+00015630: 5b63 6f6e 6669 672e 6e61 6d65 2066 6f72 [config.name for\n+00015640: 2063 6f6e 6669 6720 696e 2073 656c 662e config in self.\n+00015650: 7375 7065 7275 7365 725f 636f 6e66 6967 superuser_config\n+00015660: 735d 0a20 2020 2020 2020 2073 656c 662e s]. self.\n+00015670: 6d65 7468 6f64 7320 3d20 7b63 2e6c 6162 methods = {c.lab\n+00015680: 656c 3a20 5661 7269 616e 7428 7b27 6c61 el: Variant({'la\n+00015690: 6265 6c27 3a20 5661 7269 616e 7428 632e bel': Variant(c.\n+000156a0: 6c61 6265 6c29 7d2c 2027 617b 7376 7d27 label)}, 'a{sv}'\n+000156b0: 2920 666f 7220 6320 696e 2063 6f6e 6669 ) for c in confi\n+000156c0: 6773 2069 6620 632e 6c61 6265 6c7d 0a0a gs if c.label}..\n+000156d0: 2020 2020 2020 2020 6c6f 6767 6572 2e64 logger.d\n+000156e0: 6562 7567 2822 2020 6272 6964 6765 7320 ebug(\" bridges \n+000156f0: 6172 6520 6e6f 7720 2573 222c 2073 656c are now %s\", sel\n+00015700: 662e 6272 6964 6765 7329 0a0a 2020 2020 f.bridges).. \n+00015710: 2020 2020 2320 4966 2074 6865 2063 7572 # If the cur\n+00015720: 7265 6e74 6c79 2061 6374 6976 6520 6272 rently active br\n+00015730: 6964 6765 2063 6f6e 6669 6720 6973 206e idge config is n\n+00015740: 6f74 2069 6e20 7468 6520 6e65 7720 7365 ot in the new se\n+00015750: 7420 6f66 2063 6f6e 6669 6773 2c20 7374 t of configs, st\n+00015760: 6f70 2069 740a 2020 2020 2020 2020 6966 op it. if\n+00015770: 2073 656c 662e 7065 6572 2069 7320 6e6f self.peer is no\n+00015780: 7420 4e6f 6e65 3a0a 2020 2020 2020 2020 t None:. \n+00015790: 2020 2020 6966 2073 656c 662e 7065 6572 if self.peer\n+000157a0: 2e63 6f6e 6669 6720 6e6f 7420 696e 2073 .config not in s\n+000157b0: 656c 662e 7375 7065 7275 7365 725f 636f elf.superuser_co\n+000157c0: 6e66 6967 733a 0a20 2020 2020 2020 2020 nfigs:. \n+000157d0: 2020 2020 2020 206c 6f67 6765 722e 6465 logger.de\n+000157e0: 6275 6728 2220 2073 746f 7070 696e 6720 bug(\" stopping \n+000157f0: 7375 7065 7275 7365 7220 6272 6964 6765 superuser bridge\n+00015800: 2027 2573 273a 2069 7420 6469 7361 7070 '%s': it disapp\n+00015810: 6561 7265 6420 6672 6f6d 2063 6f6e 6669 eared from confi\n+00015820: 6773 222c 2073 656c 662e 7065 6572 2e63 gs\", self.peer.c\n+00015830: 6f6e 6669 672e 6e61 6d65 290a 2020 2020 onfig.name). \n+00015840: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n+00015850: 2e73 746f 7028 290a 0a20 2020 2064 6566 .stop().. def\n+00015860: 2063 616e 6365 6c5f 7072 6f6d 7074 2873 cancel_prompt(s\n+00015870: 656c 6629 3a0a 2020 2020 2020 2020 6966 elf):. if\n+00015880: 2073 656c 662e 7065 6e64 696e 675f 7072 self.pending_pr\n+00015890: 6f6d 7074 2069 7320 6e6f 7420 4e6f 6e65 ompt is not None\n+000158a0: 3a0a 2020 2020 2020 2020 2020 2020 7365 :. se\n+000158b0: 6c66 2e70 656e 6469 6e67 5f70 726f 6d70 lf.pending_promp\n+000158c0: 742e 6361 6e63 656c 2829 0a20 2020 2020 t.cancel(). \n+000158d0: 2020 2020 2020 2073 656c 662e 7065 6e64 self.pend\n+000158e0: 696e 675f 7072 6f6d 7074 203d 204e 6f6e ing_prompt = Non\n+000158f0: 650a 0a20 2020 2064 6566 2073 6875 7464 e.. def shutd\n+00015900: 6f77 6e28 7365 6c66 293a 0a20 2020 2020 own(self):. \n+00015910: 2020 2073 656c 662e 6361 6e63 656c 5f70 self.cancel_p\n+00015920: 726f 6d70 7428 290a 0a20 2020 2020 2020 rompt().. \n+00015930: 2069 6620 7365 6c66 2e70 6565 7220 6973 if self.peer is\n+00015940: 206e 6f74 204e 6f6e 653a 0a20 2020 2020 not None:. \n+00015950: 2020 2020 2020 2073 656c 662e 7065 6572 self.peer\n+00015960: 2e63 6c6f 7365 2829 0a0a 2020 2020 2020 .close().. \n+00015970: 2020 2320 636c 6f73 6528 2920 7368 6f75 # close() shou\n+00015980: 6c64 2068 6176 6520 6469 7363 6f6e 6e65 ld have disconne\n+00015990: 6374 6564 2074 6865 2070 6565 7220 696d cted the peer im\n+000159a0: 6d65 6469 6174 656c 790a 2020 2020 2020 mediately. \n+000159b0: 2020 6173 7365 7274 2073 656c 662e 7065 assert self.pe\n+000159c0: 6572 2069 7320 4e6f 6e65 0a0a 2020 2020 er is None.. \n+000159d0: 2320 436f 6e6e 6563 742d 6f6e 2d73 7461 # Connect-on-sta\n+000159e0: 7274 7570 2066 756e 6374 696f 6e61 6c69 rtup functionali\n+000159f0: 7479 0a20 2020 2064 6566 2069 6e69 7428 ty. def init(\n+00015a00: 7365 6c66 2c20 7061 7261 6d73 3a20 4a73 self, params: Js\n+00015a10: 6f6e 4f62 6a65 6374 2920 2d3e 204e 6f6e onObject) -> Non\n+00015a20: 653a 0a20 2020 2020 2020 206e 616d 6520 e:. name \n+00015a30: 3d20 6765 745f 7374 7228 7061 7261 6d73 = get_str(params\n+00015a40: 2c20 2769 6427 2c20 2761 6e79 2729 0a20 , 'id', 'any'). \n+00015a50: 2020 2020 2020 2072 6573 706f 6e64 6572 responder\n+00015a60: 203d 2041 7574 686f 7269 7a65 5265 7370 = AuthorizeResp\n+00015a70: 6f6e 6465 7228 7365 6c66 2e72 6f75 7465 onder(self.route\n+00015a80: 7229 0a20 2020 2020 2020 2073 656c 662e r). self.\n+00015a90: 5f69 6e69 745f 7461 736b 203d 2061 7379 _init_task = asy\n+00015aa0: 6e63 696f 2e63 7265 6174 655f 7461 736b ncio.create_task\n+00015ab0: 2873 656c 662e 676f 286e 616d 652c 2072 (self.go(name, r\n+00015ac0: 6573 706f 6e64 6572 2929 0a20 2020 2020 esponder)). \n+00015ad0: 2020 2073 656c 662e 5f69 6e69 745f 7461 self._init_ta\n+00015ae0: 736b 2e61 6464 5f64 6f6e 655f 6361 6c6c sk.add_done_call\n+00015af0: 6261 636b 2873 656c 662e 5f69 6e69 745f back(self._init_\n+00015b00: 646f 6e65 290a 0a20 2020 2064 6566 205f done).. def _\n+00015b10: 696e 6974 5f64 6f6e 6528 7365 6c66 2c20 init_done(self, \n+00015b20: 7461 736b 3a20 2761 7379 6e63 696f 2e54 task: 'asyncio.T\n+00015b30: 6173 6b5b 4e6f 6e65 5d27 2920 2d3e 204e ask[None]') -> N\n+00015b40: 6f6e 653a 0a20 2020 2020 2020 206c 6f67 one:. log\n+00015b50: 6765 722e 6465 6275 6728 2773 7570 6572 ger.debug('super\n+00015b60: 7573 6572 2069 6e69 7420 646f 6e65 2120 user init done! \n+00015b70: 2573 272c 2074 6173 6b2e 6578 6365 7074 %s', task.except\n+00015b80: 696f 6e28 2929 0a20 2020 2020 2020 2073 ion()). s\n+00015b90: 656c 662e 726f 7574 6572 2e77 7269 7465 elf.router.write\n+00015ba0: 5f63 6f6e 7472 6f6c 2863 6f6d 6d61 6e64 _control(command\n+00015bb0: 3d27 7375 7065 7275 7365 722d 696e 6974 ='superuser-init\n+00015bc0: 2d64 6f6e 6527 290a 2020 2020 2020 2020 -done'). \n+00015bd0: 6465 6c20 7365 6c66 2e5f 696e 6974 5f74 del self._init_t\n+00015be0: 6173 6b0a 0a20 2020 2023 2044 2d42 7573 ask.. # D-Bus\n+00015bf0: 206d 6574 686f 6473 0a20 2020 2040 6275 methods. @bu\n+00015c00: 732e 496e 7465 7266 6163 652e 4d65 7468 s.Interface.Meth\n+00015c10: 6f64 2869 6e5f 7479 7065 733d 5b27 7327 od(in_types=['s'\n+00015c20: 5d29 0a20 2020 2061 7379 6e63 2064 6566 ]). async def\n+00015c30: 2073 7461 7274 2873 656c 662c 206e 616d start(self, nam\n+00015c40: 653a 2073 7472 2920 2d3e 204e 6f6e 653a e: str) -> None:\n+00015c50: 0a20 2020 2020 2020 2061 7761 6974 2073 . await s\n+00015c60: 656c 662e 676f 286e 616d 652c 2073 656c elf.go(name, sel\n+00015c70: 6629 0a0a 2020 2020 4062 7573 2e49 6e74 f).. @bus.Int\n+00015c80: 6572 6661 6365 2e4d 6574 686f 6428 290a erface.Method().\n+00015c90: 2020 2020 6465 6620 7374 6f70 2873 656c def stop(sel\n+00015ca0: 6629 202d 3e20 4e6f 6e65 3a0a 2020 2020 f) -> None:. \n+00015cb0: 2020 2020 7365 6c66 2e73 6875 7464 6f77 self.shutdow\n+00015cc0: 6e28 290a 0a20 2020 2040 6275 732e 496e n().. @bus.In\n+00015cd0: 7465 7266 6163 652e 4d65 7468 6f64 2869 terface.Method(i\n+00015ce0: 6e5f 7479 7065 733d 5b27 7327 5d29 0a20 n_types=['s']). \n+00015cf0: 2020 2064 6566 2061 6e73 7765 7228 7365 def answer(se\n+00015d00: 6c66 2c20 7265 706c 793a 2073 7472 2920 lf, reply: str) \n+00015d10: 2d3e 204e 6f6e 653a 0a20 2020 2020 2020 -> None:. \n+00015d20: 2069 6620 7365 6c66 2e70 656e 6469 6e67 if self.pending\n+00015d30: 5f70 726f 6d70 7420 6973 206e 6f74 204e _prompt is not N\n+00015d40: 6f6e 653a 0a20 2020 2020 2020 2020 2020 one:. \n+00015d50: 206c 6f67 6765 722e 6465 6275 6728 2772 logger.debug('r\n+00015d60: 6573 706f 6e64 696e 6720 746f 2070 656e esponding to pen\n+00015d70: 6469 6e67 2070 726f 6d70 7427 290a 2020 ding prompt'). \n+00015d80: 2020 2020 2020 2020 2020 7365 6c66 2e70 self.p\n+00015d90: 656e 6469 6e67 5f70 726f 6d70 742e 7365 ending_prompt.se\n+00015da0: 745f 7265 7375 6c74 2872 6570 6c79 290a t_result(reply).\n+00015db0: 2020 2020 2020 2020 656c 7365 3a0a 2020 else:. \n+00015dc0: 2020 2020 2020 2020 2020 6c6f 6767 6572 logger\n+00015dd0: 2e64 6562 7567 2827 676f 7420 416e 7377 .debug('got Answ\n+00015de0: 6572 2c20 6275 7420 6e6f 2070 726f 6d70 er, but no promp\n+00015df0: 7420 7065 6e64 696e 6727 290a 2727 272c t pending').''',\n+00015e00: 0a20 2027 636f 636b 7069 742f 7361 6d70 . 'cockpit/samp\n+00015e10: 6c65 732e 7079 273a 2062 7227 2727 2320 les.py': br'''# \n+00015e20: 5468 6973 2066 696c 6520 6973 2070 6172 This file is par\n+00015e30: 7420 6f66 2043 6f63 6b70 6974 2e0a 230a t of Cockpit..#.\n+00015e40: 2320 436f 7079 7269 6768 7420 2843 2920 # Copyright (C) \n+00015e50: 3230 3232 2052 6564 2048 6174 2c20 496e 2022 Red Hat, In\n+00015e60: 632e 0a23 0a23 2054 6869 7320 7072 6f67 c..#.# This prog\n+00015e70: 7261 6d20 6973 2066 7265 6520 736f 6674 ram is free soft\n+00015e80: 7761 7265 3a20 796f 7520 6361 6e20 7265 ware: you can re\n+00015e90: 6469 7374 7269 6275 7465 2069 7420 616e distribute it an\n+00015ea0: 642f 6f72 206d 6f64 6966 790a 2320 6974 d/or modify.# it\n+00015eb0: 2075 6e64 6572 2074 6865 2074 6572 6d73 under the terms\n+00015ec0: 206f 6620 7468 6520 474e 5520 4765 6e65 of the GNU Gene\n+00015ed0: 7261 6c20 5075 626c 6963 204c 6963 656e ral Public Licen\n+00015ee0: 7365 2061 7320 7075 626c 6973 6865 6420 se as published \n+00015ef0: 6279 0a23 2074 6865 2046 7265 6520 536f by.# the Free So\n+00015f00: 6674 7761 7265 2046 6f75 6e64 6174 696f ftware Foundatio\n+00015f10: 6e2c 2065 6974 6865 7220 7665 7273 696f n, either versio\n+00015f20: 6e20 3320 6f66 2074 6865 204c 6963 656e n 3 of the Licen\n+00015f30: 7365 2c20 6f72 0a23 2028 6174 2079 6f75 se, or.# (at you\n+00015f40: 7220 6f70 7469 6f6e 2920 616e 7920 6c61 r option) any la\n+00015f50: 7465 7220 7665 7273 696f 6e2e 0a23 0a23 ter version..#.#\n+00015f60: 2054 6869 7320 7072 6f67 7261 6d20 6973 This program is\n+00015f70: 2064 6973 7472 6962 7574 6564 2069 6e20 distributed in \n+00015f80: 7468 6520 686f 7065 2074 6861 7420 6974 the hope that it\n+00015f90: 2077 696c 6c20 6265 2075 7365 6675 6c2c will be useful,\n+00015fa0: 0a23 2062 7574 2057 4954 484f 5554 2041 .# but WITHOUT A\n+00015fb0: 4e59 2057 4152 5241 4e54 593b 2077 6974 NY WARRANTY; wit\n+00015fc0: 686f 7574 2065 7665 6e20 7468 6520 696d hout even the im\n+00015fd0: 706c 6965 6420 7761 7272 616e 7479 206f plied warranty o\n+00015fe0: 660a 2320 4d45 5243 4841 4e54 4142 494c f.# MERCHANTABIL\n+00015ff0: 4954 5920 6f72 2046 4954 4e45 5353 2046 ITY or FITNESS F\n+00016000: 4f52 2041 2050 4152 5449 4355 4c41 5220 OR A PARTICULAR \n+00016010: 5055 5250 4f53 452e 2020 5365 6520 7468 PURPOSE. See th\n+00016020: 650a 2320 474e 5520 4765 6e65 7261 6c20 e.# GNU General \n+00016030: 5075 626c 6963 204c 6963 656e 7365 2066 Public License f\n+00016040: 6f72 206d 6f72 6520 6465 7461 696c 732e or more details.\n+00016050: 0a23 0a23 2059 6f75 2073 686f 756c 6420 .#.# You should \n+00016060: 6861 7665 2072 6563 6569 7665 6420 6120 have received a \n+00016070: 636f 7079 206f 6620 7468 6520 474e 5520 copy of the GNU \n+00016080: 4765 6e65 7261 6c20 5075 626c 6963 204c General Public L\n+00016090: 6963 656e 7365 0a23 2061 6c6f 6e67 2077 icense.# along w\n+000160a0: 6974 6820 7468 6973 2070 726f 6772 616d ith this program\n+000160b0: 2e20 2049 6620 6e6f 742c 2073 6565 203c . If not, see <\n+000160c0: 6874 7470 733a 2f2f 7777 772e 676e 752e https://www.gnu.\n+000160d0: 6f72 672f 6c69 6365 6e73 6573 2f3e 2e0a org/licenses/>..\n+000160e0: 0a69 6d70 6f72 7420 6572 726e 6f0a 696d .import errno.im\n+000160f0: 706f 7274 206c 6f67 6769 6e67 0a69 6d70 port logging.imp\n+00016100: 6f72 7420 6f73 0a69 6d70 6f72 7420 7265 ort os.import re\n+00016110: 0a66 726f 6d20 7479 7069 6e67 2069 6d70 .from typing imp\n+00016120: 6f72 7420 416e 792c 2044 6566 6175 6c74 ort Any, Default\n+00016130: 4469 6374 2c20 4974 6572 6162 6c65 2c20 Dict, Iterable, \n+00016140: 4c69 7374 2c20 4e61 6d65 6454 7570 6c65 List, NamedTuple\n+00016150: 2c20 4f70 7469 6f6e 616c 2c20 5475 706c , Optional, Tupl\n+00016160: 650a 0a66 726f 6d20 636f 636b 7069 742e e..from cockpit.\n+00016170: 5f76 656e 646f 722e 7379 7374 656d 645f _vendor.systemd_\n+00016180: 6374 7970 6573 2069 6d70 6f72 7420 4861 ctypes import Ha\n+00016190: 6e64 6c65 0a0a 5553 4552 5f48 5a20 3d20 ndle..USER_HZ = \n+000161a0: 6f73 2e73 7973 636f 6e66 286f 732e 7379 os.sysconf(os.sy\n+000161b0: 7363 6f6e 665f 6e61 6d65 735b 2753 435f sconf_names['SC_\n+000161c0: 434c 4b5f 5443 4b27 5d29 0a4d 535f 5045 CLK_TCK']).MS_PE\n+000161d0: 525f 4a49 4646 5920 3d20 3130 3030 202f R_JIFFY = 1000 /\n+000161e0: 2028 5553 4552 5f48 5a20 6966 2028 5553 (USER_HZ if (US\n+000161f0: 4552 5f48 5a20 3e20 3029 2065 6c73 6520 ER_HZ > 0) else \n+00016200: 3130 3029 0a48 574d 4f4e 5f50 4154 4820 100).HWMON_PATH \n+00016210: 3d20 272f 7379 732f 636c 6173 732f 6877 = '/sys/class/hw\n+00016220: 6d6f 6e27 0a0a 2320 7765 2077 6f75 6c64 mon'..# we would\n+00016230: 206c 696b 6520 746f 2064 6f20 7468 6973 like to do this\n+00016240: 2c20 6275 7420 6d79 7079 2063 6f6d 706c , but mypy compl\n+00016250: 6169 6e73 3b20 6874 7470 733a 2f2f 6769 ains; https://gi\n+00016260: 7468 7562 2e63 6f6d 2f70 7974 686f 6e2f thub.com/python/\n+00016270: 6d79 7079 2f69 7373 7565 732f 3239 3030 mypy/issues/2900\n+00016280: 0a23 2053 616d 706c 6573 203d 2063 6f6c .# Samples = col\n+00016290: 6c65 6374 696f 6e73 2e64 6566 6175 6c74 lections.default\n+000162a0: 6469 6374 5b73 7472 2c20 556e 696f 6e5b dict[str, Union[\n+000162b0: 666c 6f61 742c 2044 6963 745b 7374 722c float, Dict[str,\n+000162c0: 2055 6e69 6f6e 5b66 6c6f 6174 2c20 4e6f Union[float, No\n+000162d0: 6e65 5d5d 5d5d 0a53 616d 706c 6573 203d ne]]]].Samples =\n+000162e0: 2044 6566 6175 6c74 4469 6374 5b73 7472 DefaultDict[str\n+000162f0: 2c20 416e 795d 0a0a 6c6f 6767 6572 203d , Any]..logger =\n+00016300: 206c 6f67 6769 6e67 2e67 6574 4c6f 6767 logging.getLogg\n+00016310: 6572 285f 5f6e 616d 655f 5f29 0a0a 0a64 er(__name__)...d\n+00016320: 6566 2072 6561 645f 696e 745f 6669 6c65 ef read_int_file\n+00016330: 2872 6f6f 7466 643a 2069 6e74 2c20 7374 (rootfd: int, st\n+00016340: 6174 6669 6c65 3a20 7374 722c 2064 6566 atfile: str, def\n+00016350: 6175 6c74 3a20 4f70 7469 6f6e 616c 5b69 ault: Optional[i\n+00016360: 6e74 5d20 3d20 4e6f 6e65 2c20 6b65 793a nt] = None, key:\n+00016370: 2062 7974 6573 203d 2062 2727 2920 2d3e bytes = b'') ->\n+00016380: 204f 7074 696f 6e61 6c5b 696e 745d 3a0a Optional[int]:.\n+00016390: 2020 2020 2320 4e6f 7420 6576 6572 7920 # Not every \n+000163a0: 7374 6174 2069 7320 6176 6169 6c61 626c stat is availabl\n+000163b0: 652c 2073 7563 6820 6173 2063 7075 2e77 e, such as cpu.w\n+000163c0: 6569 6768 740a 2020 2020 7472 793a 0a20 eight. try:. \n+000163d0: 2020 2020 2020 2066 6420 3d20 6f73 2e6f fd = os.o\n+000163e0: 7065 6e28 7374 6174 6669 6c65 2c20 6f73 pen(statfile, os\n+000163f0: 2e4f 5f52 444f 4e4c 592c 2064 6972 5f66 .O_RDONLY, dir_f\n+00016400: 643d 726f 6f74 6664 290a 2020 2020 6578 d=rootfd). ex\n+00016410: 6365 7074 2046 696c 654e 6f74 466f 756e cept FileNotFoun\n+00016420: 6445 7272 6f72 3a0a 2020 2020 2020 2020 dError:. \n+00016430: 7265 7475 726e 204e 6f6e 650a 0a20 2020 return None.. \n+00016440: 2074 7279 3a0a 2020 2020 2020 2020 6461 try:. da\n+00016450: 7461 203d 206f 732e 7265 6164 2866 642c ta = os.read(fd,\n+00016460: 2031 3032 3429 0a20 2020 2065 7863 6570 1024). excep\n+00016470: 7420 4f53 4572 726f 7220 6173 2065 3a0a t OSError as e:.\n+00016480: 2020 2020 2020 2020 2320 6367 726f 7570 # cgroup\n+00016490: 7320 6361 6e20 6469 7361 7070 6561 7220 s can disappear \n+000164a0: 6265 7477 6565 6e20 7468 6520 6f70 656e between the open\n+000164b0: 2061 6e64 2072 6561 640a 2020 2020 2020 and read. \n+000164c0: 2020 6966 2065 2e65 7272 6e6f 2021 3d20 if e.errno != \n+000164d0: 6572 726e 6f2e 454e 4f44 4556 3a0a 2020 errno.ENODEV:. \n+000164e0: 2020 2020 2020 2020 2020 6c6f 6767 6572 logger\n+000164f0: 2e77 6172 6e69 6e67 2827 4661 696c 6564 .warning('Failed\n+00016500: 2074 6f20 7265 6164 2025 733a 2025 7327 to read %s: %s'\n+00016510: 2c20 7374 6174 6669 6c65 2c20 6529 0a20 , statfile, e). \n+00016520: 2020 2020 2020 2072 6574 7572 6e20 4e6f return No\n+00016530: 6e65 0a20 2020 2066 696e 616c 6c79 3a0a ne. finally:.\n+00016540: 2020 2020 2020 2020 6f73 2e63 6c6f 7365 os.close\n+00016550: 2866 6429 0a0a 2020 2020 6966 206b 6579 (fd).. if key\n+00016560: 3a0a 2020 2020 2020 2020 7374 6172 7420 :. start \n+00016570: 3d20 6461 7461 2e69 6e64 6578 286b 6579 = data.index(key\n+00016580: 2920 2b20 6c65 6e28 6b65 7929 0a20 2020 ) + len(key). \n+00016590: 2020 2020 2065 6e64 203d 2064 6174 612e end = data.\n+000165a0: 696e 6465 7828 6227 5c6e 272c 2073 7461 index(b'\\n', sta\n+000165b0: 7274 290a 2020 2020 2020 2020 6461 7461 rt). data\n+000165c0: 203d 2064 6174 615b 7374 6172 743a 656e = data[start:en\n+000165d0: 645d 0a0a 2020 2020 7472 793a 0a20 2020 d].. try:. \n+000165e0: 2020 2020 2023 2030 206f 6674 656e 206d # 0 often m\n+000165f0: 6561 6e73 2022 6e6f 6e65 222c 2073 6f20 eans \"none\", so \n+00016600: 7265 706c 6163 6520 6974 2077 6974 6820 replace it with \n+00016610: 6465 6661 756c 7420 7661 6c75 650a 2020 default value. \n+00016620: 2020 2020 2020 7265 7475 726e 2069 6e74 return int\n+00016630: 2864 6174 6129 206f 7220 6465 6661 756c (data) or defaul\n+00016640: 740a 2020 2020 6578 6365 7074 2056 616c t. except Val\n+00016650: 7565 4572 726f 723a 0a20 2020 2020 2020 ueError:. \n+00016660: 2023 2053 6f6d 6520 7361 6d70 6c65 7320 # Some samples \n+00016670: 7375 6368 2061 7320 226d 656d 6f72 792e such as \"memory.\n+00016680: 6d61 7822 2063 6f6e 7461 696e 7320 226d max\" contains \"m\n+00016690: 6178 2220 7768 656e 2074 6865 7265 2069 ax\" when there i\n+000166a0: 7320 6120 6e6f 206c 696d 6974 0a20 2020 s a no limit. \n+000166b0: 2020 2020 2072 6574 7572 6e20 4e6f 6e65 return None\n+000166c0: 0a0a 0a63 6c61 7373 2053 616d 706c 6544 ...class SampleD\n+000166d0: 6573 6372 6970 7469 6f6e 284e 616d 6564 escription(Named\n+000166e0: 5475 706c 6529 3a0a 2020 2020 6e61 6d65 Tuple):. name\n+000166f0: 3a20 7374 720a 2020 2020 756e 6974 733a : str. units:\n+00016700: 2073 7472 0a20 2020 2073 656d 616e 7469 str. semanti\n+00016710: 6373 3a20 7374 720a 2020 2020 696e 7374 cs: str. inst\n+00016720: 616e 6365 643a 2062 6f6f 6c0a 0a0a 636c anced: bool...cl\n+00016730: 6173 7320 5361 6d70 6c65 723a 0a20 2020 ass Sampler:. \n+00016740: 2064 6573 6372 6970 7469 6f6e 733a 204c descriptions: L\n+00016750: 6973 745b 5361 6d70 6c65 4465 7363 7269 ist[SampleDescri\n+00016760: 7074 696f 6e5d 0a0a 2020 2020 6465 6620 ption].. def \n+00016770: 7361 6d70 6c65 2873 656c 662c 2073 616d sample(self, sam\n+00016780: 706c 6573 3a20 5361 6d70 6c65 7329 202d ples: Samples) -\n+00016790: 3e20 4e6f 6e65 3a0a 2020 2020 2020 2020 > None:. \n+000167a0: 7261 6973 6520 4e6f 7449 6d70 6c65 6d65 raise NotImpleme\n+000167b0: 6e74 6564 4572 726f 720a 0a0a 636c 6173 ntedError...clas\n+000167c0: 7320 4350 5553 616d 706c 6572 2853 616d s CPUSampler(Sam\n+000167d0: 706c 6572 293a 0a20 2020 2064 6573 6372 pler):. descr\n+000167e0: 6970 7469 6f6e 7320 3d20 5b0a 2020 2020 iptions = [. \n+000167f0: 2020 2020 5361 6d70 6c65 4465 7363 7269 SampleDescri\n+00016800: 7074 696f 6e28 2763 7075 2e62 6173 6963 ption('cpu.basic\n+00016810: 2e6e 6963 6527 2c20 276d 696c 6c69 7365 .nice', 'millise\n+00016820: 6327 2c20 2763 6f75 6e74 6572 272c 2069 c', 'counter', i\n+00016830: 6e73 7461 6e63 6564 3d46 616c 7365 292c nstanced=False),\n+00016840: 0a20 2020 2020 2020 2053 616d 706c 6544 . SampleD\n+00016850: 6573 6372 6970 7469 6f6e 2827 6370 752e escription('cpu.\n+00016860: 6261 7369 632e 7573 6572 272c 2027 6d69 basic.user', 'mi\n+00016870: 6c6c 6973 6563 272c 2027 636f 756e 7465 llisec', 'counte\n+00016880: 7227 2c20 696e 7374 616e 6365 643d 4661 r', instanced=Fa\n+00016890: 6c73 6529 2c0a 2020 2020 2020 2020 5361 lse),. Sa\n+000168a0: 6d70 6c65 4465 7363 7269 7074 696f 6e28 mpleDescription(\n+000168b0: 2763 7075 2e62 6173 6963 2e73 7973 7465 'cpu.basic.syste\n+000168c0: 6d27 2c20 276d 696c 6c69 7365 6327 2c20 m', 'millisec', \n+000168d0: 2763 6f75 6e74 6572 272c 2069 6e73 7461 'counter', insta\n+000168e0: 6e63 6564 3d46 616c 7365 292c 0a20 2020 nced=False),. \n+000168f0: 2020 2020 2053 616d 706c 6544 6573 6372 SampleDescr\n+00016900: 6970 7469 6f6e 2827 6370 752e 6261 7369 iption('cpu.basi\n+00016910: 632e 696f 7761 6974 272c 2027 6d69 6c6c c.iowait', 'mill\n+00016920: 6973 6563 272c 2027 636f 756e 7465 7227 isec', 'counter'\n+00016930: 2c20 696e 7374 616e 6365 643d 4661 6c73 , instanced=Fals\n+00016940: 6529 2c0a 0a20 2020 2020 2020 2053 616d e),.. Sam\n+00016950: 706c 6544 6573 6372 6970 7469 6f6e 2827 pleDescription('\n+00016960: 6370 752e 636f 7265 2e6e 6963 6527 2c20 cpu.core.nice', \n+00016970: 276d 696c 6c69 7365 6327 2c20 2763 6f75 'millisec', 'cou\n+00016980: 6e74 6572 272c 2069 6e73 7461 6e63 6564 nter', instanced\n+00016990: 3d54 7275 6529 2c0a 2020 2020 2020 2020 =True),. \n+000169a0: 5361 6d70 6c65 4465 7363 7269 7074 696f SampleDescriptio\n+000169b0: 6e28 2763 7075 2e63 6f72 652e 7573 6572 n('cpu.core.user\n+000169c0: 272c 2027 6d69 6c6c 6973 6563 272c 2027 ', 'millisec', '\n+000169d0: 636f 756e 7465 7227 2c20 696e 7374 616e counter', instan\n+000169e0: 6365 643d 5472 7565 292c 0a20 2020 2020 ced=True),. \n+000169f0: 2020 2053 616d 706c 6544 6573 6372 6970 SampleDescrip\n+00016a00: 7469 6f6e 2827 6370 752e 636f 7265 2e73 tion('cpu.core.s\n+00016a10: 7973 7465 6d27 2c20 276d 696c 6c69 7365 ystem', 'millise\n+00016a20: 6327 2c20 2763 6f75 6e74 6572 272c 2069 c', 'counter', i\n+00016a30: 6e73 7461 6e63 6564 3d54 7275 6529 2c0a nstanced=True),.\n+00016a40: 2020 2020 2020 2020 5361 6d70 6c65 4465 SampleDe\n+00016a50: 7363 7269 7074 696f 6e28 2763 7075 2e63 scription('cpu.c\n+00016a60: 6f72 652e 696f 7761 6974 272c 2027 6d69 ore.iowait', 'mi\n+00016a70: 6c6c 6973 6563 272c 2027 636f 756e 7465 llisec', 'counte\n+00016a80: 7227 2c20 696e 7374 616e 6365 643d 5472 r', instanced=Tr\n+00016a90: 7565 292c 0a20 2020 205d 0a0a 2020 2020 ue),. ].. \n+00016aa0: 6465 6620 7361 6d70 6c65 2873 656c 662c def sample(self,\n+00016ab0: 2073 616d 706c 6573 3a20 5361 6d70 6c65 samples: Sample\n+00016ac0: 7329 202d 3e20 4e6f 6e65 3a0a 2020 2020 s) -> None:. \n+00016ad0: 2020 2020 7769 7468 206f 7065 6e28 272f with open('/\n+00016ae0: 7072 6f63 2f73 7461 7427 2920 6173 2073 proc/stat') as s\n+00016af0: 7461 743a 0a20 2020 2020 2020 2020 2020 tat:. \n+00016b00: 2066 6f72 206c 696e 6520 696e 2073 7461 for line in sta\n+00016b10: 743a 0a20 2020 2020 2020 2020 2020 2020 t:. \n+00016b20: 2020 2069 6620 6e6f 7420 6c69 6e65 2e73 if not line.s\n+00016b30: 7461 7274 7377 6974 6828 2763 7075 2729 tartswith('cpu')\n+00016b40: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n+00016b50: 2020 2020 2020 636f 6e74 696e 7565 0a20 continue. \n+00016b60: 2020 2020 2020 2020 2020 2020 2020 2063 c\n+00016b70: 7075 2c20 7573 6572 2c20 6e69 6365 2c20 pu, user, nice, \n+00016b80: 7379 7374 656d 2c20 5f69 646c 652c 2069 system, _idle, i\n+00016b90: 6f77 6169 7420 3d20 6c69 6e65 2e73 706c owait = line.spl\n+00016ba0: 6974 2829 5b3a 365d 0a20 2020 2020 2020 it()[:6]. \n+00016bb0: 2020 2020 2020 2020 2063 6f72 6520 3d20 core = \n+00016bc0: 6370 755b 333a 5d20 6f72 204e 6f6e 650a cpu[3:] or None.\n+00016bd0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00016be0: 6966 2063 6f72 653a 0a20 2020 2020 2020 if core:. \n+00016bf0: 2020 2020 2020 2020 2020 2020 2070 7265 pre\n+00016c00: 6669 7820 3d20 2763 7075 2e63 6f72 6527 fix = 'cpu.core'\n+00016c10: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+00016c20: 2020 2020 2073 616d 706c 6573 5b66 277b samples[f'{\n+00016c30: 7072 6566 6978 7d2e 6e69 6365 275d 5b63 prefix}.nice'][c\n+00016c40: 6f72 655d 203d 2069 6e74 286e 6963 6529 ore] = int(nice)\n+00016c50: 202a 204d 535f 5045 525f 4a49 4646 590a * MS_PER_JIFFY.\n+00016c60: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00016c70: 2020 2020 7361 6d70 6c65 735b 6627 7b70 samples[f'{p\n+00016c80: 7265 6669 787d 2e75 7365 7227 5d5b 636f refix}.user'][co\n+00016c90: 7265 5d20 3d20 696e 7428 7573 6572 2920 re] = int(user) \n+00016ca0: 2a20 4d53 5f50 4552 5f4a 4946 4659 0a20 * MS_PER_JIFFY. \n+00016cb0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00016cc0: 2020 2073 616d 706c 6573 5b66 277b 7072 samples[f'{pr\n+00016cd0: 6566 6978 7d2e 7379 7374 656d 275d 5b63 efix}.system'][c\n+00016ce0: 6f72 655d 203d 2069 6e74 2873 7973 7465 ore] = int(syste\n+00016cf0: 6d29 202a 204d 535f 5045 525f 4a49 4646 m) * MS_PER_JIFF\n+00016d00: 590a 2020 2020 2020 2020 2020 2020 2020 Y. \n+00016d10: 2020 2020 2020 7361 6d70 6c65 735b 6627 samples[f'\n+00016d20: 7b70 7265 6669 787d 2e69 6f77 6169 7427 {prefix}.iowait'\n+00016d30: 5d5b 636f 7265 5d20 3d20 696e 7428 696f ][core] = int(io\n+00016d40: 7761 6974 2920 2a20 4d53 5f50 4552 5f4a wait) * MS_PER_J\n+00016d50: 4946 4659 0a20 2020 2020 2020 2020 2020 IFFY. \n+00016d60: 2020 2020 2065 6c73 653a 0a20 2020 2020 else:. \n+00016d70: 2020 2020 2020 2020 2020 2020 2020 2070 p\n+00016d80: 7265 6669 7820 3d20 2763 7075 2e62 6173 refix = 'cpu.bas\n+00016d90: 6963 270a 2020 2020 2020 2020 2020 2020 ic'. \n+00016da0: 2020 2020 2020 2020 7361 6d70 6c65 735b samples[\n+00016db0: 6627 7b70 7265 6669 787d 2e6e 6963 6527 f'{prefix}.nice'\n+00016dc0: 5d20 3d20 696e 7428 6e69 6365 2920 2a20 ] = int(nice) * \n+00016dd0: 4d53 5f50 4552 5f4a 4946 4659 0a20 2020 MS_PER_JIFFY. \n+00016de0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00016df0: 2073 616d 706c 6573 5b66 277b 7072 6566 samples[f'{pref\n+00016e00: 6978 7d2e 7573 6572 275d 203d 2069 6e74 ix}.user'] = int\n+00016e10: 2875 7365 7229 202a 204d 535f 5045 525f (user) * MS_PER_\n+00016e20: 4a49 4646 590a 2020 2020 2020 2020 2020 JIFFY. \n+00016e30: 2020 2020 2020 2020 2020 7361 6d70 6c65 sample\n+00016e40: 735b 6627 7b70 7265 6669 787d 2e73 7973 s[f'{prefix}.sys\n+00016e50: 7465 6d27 5d20 3d20 696e 7428 7379 7374 tem'] = int(syst\n+00016e60: 656d 2920 2a20 4d53 5f50 4552 5f4a 4946 em) * MS_PER_JIF\n+00016e70: 4659 0a20 2020 2020 2020 2020 2020 2020 FY. \n+00016e80: 2020 2020 2020 2073 616d 706c 6573 5b66 samples[f\n+00016e90: 277b 7072 6566 6978 7d2e 696f 7761 6974 '{prefix}.iowait\n+00016ea0: 275d 203d 2069 6e74 2869 6f77 6169 7429 '] = int(iowait)\n+00016eb0: 202a 204d 535f 5045 525f 4a49 4646 590a * MS_PER_JIFFY.\n+00016ec0: 0a0a 636c 6173 7320 4d65 6d6f 7279 5361 ..class MemorySa\n+00016ed0: 6d70 6c65 7228 5361 6d70 6c65 7229 3a0a mpler(Sampler):.\n+00016ee0: 2020 2020 6465 7363 7269 7074 696f 6e73 descriptions\n+00016ef0: 203d 205b 0a20 2020 2020 2020 2053 616d = [. Sam\n+00016f00: 706c 6544 6573 6372 6970 7469 6f6e 2827 pleDescription('\n+00016f10: 6d65 6d6f 7279 2e66 7265 6527 2c20 2762 memory.free', 'b\n+00016f20: 7974 6573 272c 2027 696e 7374 616e 7427 ytes', 'instant'\n+00016f30: 2c20 696e 7374 616e 6365 643d 4661 6c73 , instanced=Fals\n+00016f40: 6529 2c0a 2020 2020 2020 2020 5361 6d70 e),. Samp\n+00016f50: 6c65 4465 7363 7269 7074 696f 6e28 276d leDescription('m\n+00016f60: 656d 6f72 792e 7573 6564 272c 2027 6279 emory.used', 'by\n+00016f70: 7465 7327 2c20 2769 6e73 7461 6e74 272c tes', 'instant',\n+00016f80: 2069 6e73 7461 6e63 6564 3d46 616c 7365 instanced=False\n+00016f90: 292c 0a20 2020 2020 2020 2053 616d 706c ),. Sampl\n+00016fa0: 6544 6573 6372 6970 7469 6f6e 2827 6d65 eDescription('me\n+00016fb0: 6d6f 7279 2e63 6163 6865 6427 2c20 2762 mory.cached', 'b\n+00016fc0: 7974 6573 272c 2027 696e 7374 616e 7427 ytes', 'instant'\n+00016fd0: 2c20 696e 7374 616e 6365 643d 4661 6c73 , instanced=Fals\n+00016fe0: 6529 2c0a 2020 2020 2020 2020 5361 6d70 e),. Samp\n+00016ff0: 6c65 4465 7363 7269 7074 696f 6e28 276d leDescription('m\n+00017000: 656d 6f72 792e 7377 6170 2d75 7365 6427 emory.swap-used'\n+00017010: 2c20 2762 7974 6573 272c 2027 696e 7374 , 'bytes', 'inst\n+00017020: 616e 7427 2c20 696e 7374 616e 6365 643d ant', instanced=\n+00017030: 4661 6c73 6529 2c0a 2020 2020 5d0a 0a20 False),. ].. \n+00017040: 2020 2064 6566 2073 616d 706c 6528 7365 def sample(se\n+00017050: 6c66 2c20 7361 6d70 6c65 733a 2053 616d lf, samples: Sam\n+00017060: 706c 6573 2920 2d3e 204e 6f6e 653a 0a20 ples) -> None:. \n+00017070: 2020 2020 2020 2077 6974 6820 6f70 656e with open\n+00017080: 2827 2f70 726f 632f 6d65 6d69 6e66 6f27 ('/proc/meminfo'\n+00017090: 2920 6173 206d 656d 696e 666f 3a0a 2020 ) as meminfo:. \n+000170a0: 2020 2020 2020 2020 2020 6974 656d 7320 items \n+000170b0: 3d20 7b6b 3a20 696e 7428 762e 7374 7269 = {k: int(v.stri\n+000170c0: 7028 2720 6b42 5c6e 2729 2920 666f 7220 p(' kB\\n')) for \n+000170d0: 6c69 6e65 2069 6e20 6d65 6d69 6e66 6f20 line in meminfo \n+000170e0: 666f 7220 6b2c 2076 2069 6e20 5b6c 696e for k, v in [lin\n+000170f0: 652e 7370 6c69 7428 273a 272c 2031 295d e.split(':', 1)]\n+00017100: 7d0a 0a20 2020 2020 2020 2073 616d 706c }.. sampl\n+00017110: 6573 5b27 6d65 6d6f 7279 2e66 7265 6527 es['memory.free'\n+00017120: 5d20 3d20 3130 3234 202a 2069 7465 6d73 ] = 1024 * items\n+00017130: 5b27 4d65 6d46 7265 6527 5d0a 2020 2020 ['MemFree']. \n+00017140: 2020 2020 7361 6d70 6c65 735b 276d 656d samples['mem\n+00017150: 6f72 792e 7573 6564 275d 203d 2031 3032 ory.used'] = 102\n+00017160: 3420 2a20 2869 7465 6d73 5b27 4d65 6d54 4 * (items['MemT\n+00017170: 6f74 616c 275d 202d 2069 7465 6d73 5b27 otal'] - items['\n+00017180: 4d65 6d41 7661 696c 6162 6c65 275d 290a MemAvailable']).\n+00017190: 2020 2020 2020 2020 7361 6d70 6c65 735b samples[\n+000171a0: 276d 656d 6f72 792e 6361 6368 6564 275d 'memory.cached']\n+000171b0: 203d 2031 3032 3420 2a20 2869 7465 6d73 = 1024 * (items\n+000171c0: 5b27 4275 6666 6572 7327 5d20 2b20 6974 ['Buffers'] + it\n+000171d0: 656d 735b 2743 6163 6865 6427 5d29 0a20 ems['Cached']). \n+000171e0: 2020 2020 2020 2073 616d 706c 6573 5b27 samples['\n+000171f0: 6d65 6d6f 7279 2e73 7761 702d 7573 6564 memory.swap-used\n+00017200: 275d 203d 2031 3032 3420 2a20 2869 7465 '] = 1024 * (ite\n+00017210: 6d73 5b27 5377 6170 546f 7461 6c27 5d20 ms['SwapTotal'] \n+00017220: 2d20 6974 656d 735b 2753 7761 7046 7265 - items['SwapFre\n+00017230: 6527 5d29 0a0a 0a63 6c61 7373 2043 5055 e'])...class CPU\n+00017240: 5465 6d70 6572 6174 7572 6553 616d 706c TemperatureSampl\n+00017250: 6572 2853 616d 706c 6572 293a 0a20 2020 er(Sampler):. \n+00017260: 2023 2043 6163 6865 2066 6f75 6e64 2073 # Cache found s\n+00017270: 656e 736f 7273 2c20 6173 2074 6865 7920 ensors, as they \n+00017280: 6361 6e27 7420 6265 2068 6f74 706c 7567 can't be hotplug\n+00017290: 6765 642e 0a20 2020 2073 656e 736f 7273 ged.. sensors\n+000172a0: 3a20 4f70 7469 6f6e 616c 5b4c 6973 745b : Optional[List[\n+000172b0: 7374 725d 5d20 3d20 4e6f 6e65 0a0a 2020 str]] = None.. \n+000172c0: 2020 6465 7363 7269 7074 696f 6e73 203d descriptions =\n+000172d0: 205b 0a20 2020 2020 2020 2053 616d 706c [. Sampl\n+000172e0: 6544 6573 6372 6970 7469 6f6e 2827 6370 eDescription('cp\n+000172f0: 752e 7465 6d70 6572 6174 7572 6527 2c20 u.temperature', \n+00017300: 2763 656c 7369 7573 272c 2027 696e 7374 'celsius', 'inst\n+00017310: 616e 7427 2c20 696e 7374 616e 6365 643d ant', instanced=\n+00017320: 5472 7565 292c 0a20 2020 205d 0a0a 2020 True),. ].. \n+00017330: 2020 4073 7461 7469 636d 6574 686f 640a @staticmethod.\n+00017340: 2020 2020 6465 6620 6465 7465 6374 5f63 def detect_c\n+00017350: 7075 5f73 656e 736f 7273 2864 6972 5f66 pu_sensors(dir_f\n+00017360: 643a 2069 6e74 2920 2d3e 2049 7465 7261 d: int) -> Itera\n+00017370: 626c 655b 7374 725d 3a0a 2020 2020 2020 ble[str]:. \n+00017380: 2020 2320 5265 6164 2074 6865 206e 616d # Read the nam\n+00017390: 6520 6669 6c65 2074 6f20 6465 6369 6465 e file to decide\n+000173a0: 2077 6861 7420 746f 2064 6f20 7769 7468 what to do with\n+000173b0: 2074 6869 7320 6469 7265 6374 6f72 790a this directory.\n+000173c0: 2020 2020 2020 2020 7472 793a 0a20 2020 try:. \n+000173d0: 2020 2020 2020 2020 2077 6974 6820 4861 with Ha\n+000173e0: 6e64 6c65 2e6f 7065 6e28 276e 616d 6527 ndle.open('name'\n+000173f0: 2c20 6f73 2e4f 5f52 444f 4e4c 592c 2064 , os.O_RDONLY, d\n+00017400: 6972 5f66 643d 6469 725f 6664 2920 6173 ir_fd=dir_fd) as\n+00017410: 2066 643a 0a20 2020 2020 2020 2020 2020 fd:. \n+00017420: 2020 2020 206e 616d 6520 3d20 6f73 2e72 name = os.r\n+00017430: 6561 6428 6664 2c20 3130 3234 292e 6465 ead(fd, 1024).de\n+00017440: 636f 6465 2829 2e73 7472 6970 2829 0a20 code().strip(). \n+00017450: 2020 2020 2020 2065 7863 6570 7420 4669 except Fi\n+00017460: 6c65 4e6f 7446 6f75 6e64 4572 726f 723a leNotFoundError:\n+00017470: 0a20 2020 2020 2020 2020 2020 2072 6574 . ret\n+00017480: 7572 6e0a 0a20 2020 2020 2020 2069 6620 urn.. if \n+00017490: 6e61 6d65 203d 3d20 2761 746b 3031 3130 name == 'atk0110\n+000174a0: 273a 0a20 2020 2020 2020 2020 2020 2023 ':. #\n+000174b0: 206f 6e6c 7920 7361 6d70 6c65 2027 4350 only sample 'CP\n+000174c0: 5520 5465 6d70 6572 6174 7572 6527 2069 U Temperature' i\n+000174d0: 6e20 6174 6b30 3131 300a 2020 2020 2020 n atk0110. \n+000174e0: 2020 2020 2020 7072 6564 6963 6174 6520 predicate \n+000174f0: 3d20 286c 616d 6264 6120 6c61 6265 6c3a = (lambda label:\n+00017500: 206c 6162 656c 203d 3d20 2743 5055 2054 label == 'CPU T\n+00017510: 656d 7065 7261 7475 7265 2729 0a20 2020 emperature'). \n+00017520: 2020 2020 2065 6c69 6620 6e61 6d65 203d elif name =\n+00017530: 3d20 2763 7075 5f74 6865 726d 616c 273a = 'cpu_thermal':\n+00017540: 0a20 2020 2020 2020 2020 2020 2023 206c . # l\n+00017550: 6162 656c 7320 6172 6520 6e6f 7420 7573 abels are not us\n+00017560: 6564 206f 6e20 4152 4d0a 2020 2020 2020 ed on ARM. \n+00017570: 2020 2020 2020 7072 6564 6963 6174 6520 predicate \n+00017580: 3d20 4e6f 6e65 0a20 2020 2020 2020 2065 = None. e\n+00017590: 6c69 6620 6e61 6d65 203d 3d20 2763 6f72 lif name == 'cor\n+000175a0: 6574 656d 7027 3a0a 2020 2020 2020 2020 etemp':. \n+000175b0: 2020 2020 2320 6163 6365 7074 2061 6c6c # accept all\n+000175c0: 206c 6162 656c 7320 6f6e 2049 6e74 656c labels on Intel\n+000175d0: 0a20 2020 2020 2020 2020 2020 2070 7265 . pre\n+000175e0: 6469 6361 7465 203d 204e 6f6e 650a 2020 dicate = None. \n+000175f0: 2020 2020 2020 656c 6966 206e 616d 6520 elif name \n+00017600: 696e 205b 276b 3874 656d 7027 2c20 276b in ['k8temp', 'k\n+00017610: 3130 7465 6d70 275d 3a0a 2020 2020 2020 10temp']:. \n+00017620: 2020 2020 2020 7072 6564 6963 6174 6520 predicate \n+00017630: 3d20 4e6f 6e65 0a20 2020 2020 2020 2065 = None. e\n+00017640: 6c73 653a 0a20 2020 2020 2020 2020 2020 lse:. \n+00017650: 2023 204e 6f74 2061 2043 5055 2073 656e # Not a CPU sen\n+00017660: 736f 720a 2020 2020 2020 2020 2020 2020 sor. \n+00017670: 7265 7475 726e 0a0a 2020 2020 2020 2020 return.. \n+00017680: 2320 4e6f 7720 7363 616e 2074 6865 2064 # Now scan the d\n+00017690: 6972 6563 746f 7279 2066 6f72 2069 6e70 irectory for inp\n+000176a0: 7574 730a 2020 2020 2020 2020 666f 7220 uts. for \n+000176b0: 696e 7075 745f 6669 6c65 6e61 6d65 2069 input_filename i\n+000176c0: 6e20 6f73 2e6c 6973 7464 6972 2864 6972 n os.listdir(dir\n+000176d0: 5f66 6429 3a0a 2020 2020 2020 2020 2020 _fd):. \n+000176e0: 2020 6966 206e 6f74 2069 6e70 7574 5f66 if not input_f\n+000176f0: 696c 656e 616d 652e 656e 6473 7769 7468 ilename.endswith\n+00017700: 2827 5f69 6e70 7574 2729 3a0a 2020 2020 ('_input'):. \n+00017710: 2020 2020 2020 2020 2020 2020 636f 6e74 cont\n+00017720: 696e 7565 0a0a 2020 2020 2020 2020 2020 inue.. \n+00017730: 2020 6966 2070 7265 6469 6361 7465 3a0a if predicate:.\n+00017740: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00017750: 2320 5765 206e 6565 6420 746f 2063 6865 # We need to che\n+00017760: 636b 2074 6865 206c 6162 656c 0a20 2020 ck the label. \n+00017770: 2020 2020 2020 2020 2020 2020 2074 7279 try\n+00017780: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n+00017790: 2020 2020 2020 6c61 6265 6c5f 6669 6c65 label_file\n+000177a0: 6e61 6d65 203d 2069 6e70 7574 5f66 696c name = input_fil\n+000177b0: 656e 616d 652e 7265 706c 6163 6528 275f ename.replace('_\n+000177c0: 696e 7075 7427 2c20 275f 6c61 6265 6c27 input', '_label'\n+000177d0: 290a 2020 2020 2020 2020 2020 2020 2020 ). \n+000177e0: 2020 2020 2020 7769 7468 2048 616e 646c with Handl\n+000177f0: 652e 6f70 656e 286c 6162 656c 5f66 696c e.open(label_fil\n+00017800: 656e 616d 652c 206f 732e 4f5f 5244 4f4e ename, os.O_RDON\n+00017810: 4c59 2c20 6469 725f 6664 3d64 6972 5f66 LY, dir_fd=dir_f\n+00017820: 6429 2061 7320 6664 3a0a 2020 2020 2020 d) as fd:. \n+00017830: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00017840: 2020 6c61 6265 6c20 3d20 6f73 2e72 6561 label = os.rea\n+00017850: 6428 6664 2c20 3130 3234 292e 6465 636f d(fd, 1024).deco\n+00017860: 6465 2829 2e73 7472 6970 2829 0a20 2020 de().strip(). \n+00017870: 2020 2020 2020 2020 2020 2020 2065 7863 exc\n+00017880: 6570 7420 4669 6c65 4e6f 7446 6f75 6e64 ept FileNotFound\n+00017890: 4572 726f 723a 0a20 2020 2020 2020 2020 Error:. \n+000178a0: 2020 2020 2020 2020 2020 2063 6f6e 7469 conti\n+000178b0: 6e75 650a 0a20 2020 2020 2020 2020 2020 nue.. \n+000178c0: 2020 2020 2069 6620 6e6f 7420 7072 6564 if not pred\n+000178d0: 6963 6174 6528 6c61 6265 6c29 3a0a 2020 icate(label):. \n+000178e0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000178f0: 2020 636f 6e74 696e 7565 0a0a 2020 2020 continue.. \n+00017900: 2020 2020 2020 2020 7969 656c 6420 696e yield in\n+00017910: 7075 745f 6669 6c65 6e61 6d65 0a0a 2020 put_filename.. \n+00017920: 2020 4073 7461 7469 636d 6574 686f 640a @staticmethod.\n+00017930: 2020 2020 6465 6620 7363 616e 5f73 656e def scan_sen\n+00017940: 736f 7273 2829 202d 3e20 4974 6572 6162 sors() -> Iterab\n+00017950: 6c65 5b73 7472 5d3a 0a20 2020 2020 2020 le[str]:. \n+00017960: 2074 7279 3a0a 2020 2020 2020 2020 2020 try:. \n+00017970: 2020 746f 705f 6664 203d 2048 616e 646c top_fd = Handl\n+00017980: 652e 6f70 656e 2848 574d 4f4e 5f50 4154 e.open(HWMON_PAT\n+00017990: 482c 206f 732e 4f5f 5244 4f4e 4c59 207c H, os.O_RDONLY |\n+000179a0: 206f 732e 4f5f 4449 5245 4354 4f52 5929 os.O_DIRECTORY)\n+000179b0: 0a20 2020 2020 2020 2065 7863 6570 7420 . except \n+000179c0: 4669 6c65 4e6f 7446 6f75 6e64 4572 726f FileNotFoundErro\n+000179d0: 723a 0a20 2020 2020 2020 2020 2020 2072 r:. r\n+000179e0: 6574 7572 6e0a 0a20 2020 2020 2020 2077 eturn.. w\n+000179f0: 6974 6820 746f 705f 6664 3a0a 2020 2020 ith top_fd:. \n+00017a00: 2020 2020 2020 2020 666f 7220 6877 6d6f for hwmo\n+00017a10: 6e5f 6e61 6d65 2069 6e20 6f73 2e6c 6973 n_name in os.lis\n+00017a20: 7464 6972 2874 6f70 5f66 6429 3a0a 2020 tdir(top_fd):. \n+00017a30: 2020 2020 2020 2020 2020 2020 2020 7769 wi\n+00017a40: 7468 2048 616e 646c 652e 6f70 656e 2868 th Handle.open(h\n+00017a50: 776d 6f6e 5f6e 616d 652c 206f 732e 4f5f wmon_name, os.O_\n+00017a60: 5244 4f4e 4c59 207c 206f 732e 4f5f 4449 RDONLY | os.O_DI\n+00017a70: 5245 4354 4f52 592c 2064 6972 5f66 643d RECTORY, dir_fd=\n+00017a80: 746f 705f 6664 2920 6173 2073 7562 6469 top_fd) as subdi\n+00017a90: 725f 6664 3a0a 2020 2020 2020 2020 2020 r_fd:. \n+00017aa0: 2020 2020 2020 2020 2020 666f 7220 7365 for se\n+00017ab0: 6e73 6f72 2069 6e20 4350 5554 656d 7065 nsor in CPUTempe\n+00017ac0: 7261 7475 7265 5361 6d70 6c65 722e 6465 ratureSampler.de\n+00017ad0: 7465 6374 5f63 7075 5f73 656e 736f 7273 tect_cpu_sensors\n+00017ae0: 2873 7562 6469 725f 6664 293a 0a20 2020 (subdir_fd):. \n+00017af0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00017b00: 2020 2020 2079 6965 6c64 2066 277b 4857 yield f'{HW\n+00017b10: 4d4f 4e5f 5041 5448 7d2f 7b68 776d 6f6e MON_PATH}/{hwmon\n+00017b20: 5f6e 616d 657d 2f7b 7365 6e73 6f72 7d27 _name}/{sensor}'\n+00017b30: 0a0a 2020 2020 6465 6620 7361 6d70 6c65 .. def sample\n+00017b40: 2873 656c 662c 2073 616d 706c 6573 3a20 (self, samples: \n+00017b50: 5361 6d70 6c65 7329 202d 3e20 4e6f 6e65 Samples) -> None\n+00017b60: 3a0a 2020 2020 2020 2020 6966 2073 656c :. if sel\n+00017b70: 662e 7365 6e73 6f72 7320 6973 204e 6f6e f.sensors is Non\n+00017b80: 653a 0a20 2020 2020 2020 2020 2020 2073 e:. s\n+00017b90: 656c 662e 7365 6e73 6f72 7320 3d20 6c69 elf.sensors = li\n+00017ba0: 7374 2843 5055 5465 6d70 6572 6174 7572 st(CPUTemperatur\n+00017bb0: 6553 616d 706c 6572 2e73 6361 6e5f 7365 eSampler.scan_se\n+00017bc0: 6e73 6f72 7328 2929 0a0a 2020 2020 2020 nsors()).. \n+00017bd0: 2020 666f 7220 7365 6e73 6f72 5f70 6174 for sensor_pat\n+00017be0: 6820 696e 2073 656c 662e 7365 6e73 6f72 h in self.sensor\n+00017bf0: 733a 0a20 2020 2020 2020 2020 2020 2077 s:. w\n+00017c00: 6974 6820 6f70 656e 2873 656e 736f 725f ith open(sensor_\n+00017c10: 7061 7468 2920 6173 2073 656e 736f 723a path) as sensor:\n+00017c20: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+00017c30: 2074 656d 7065 7261 7475 7265 203d 2069 temperature = i\n+00017c40: 6e74 2873 656e 736f 722e 7265 6164 2829 nt(sensor.read()\n+00017c50: 2e73 7472 6970 2829 290a 2020 2020 2020 .strip()). \n+00017c60: 2020 2020 2020 2020 2020 6966 2074 656d if tem\n+00017c70: 7065 7261 7475 7265 203d 3d20 303a 0a20 perature == 0:. \n+00017c80: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00017c90: 2020 2072 6574 7572 6e0a 0a20 2020 2020 return.. \n+00017ca0: 2020 2020 2020 2073 616d 706c 6573 5b27 samples['\n+00017cb0: 6370 752e 7465 6d70 6572 6174 7572 6527 cpu.temperature'\n+00017cc0: 5d5b 7365 6e73 6f72 5f70 6174 685d 203d ][sensor_path] =\n+00017cd0: 2074 656d 7065 7261 7475 7265 202f 2031 temperature / 1\n+00017ce0: 3030 300a 0a0a 636c 6173 7320 4469 736b 000...class Disk\n+00017cf0: 5361 6d70 6c65 7228 5361 6d70 6c65 7229 Sampler(Sampler)\n+00017d00: 3a0a 2020 2020 6465 7363 7269 7074 696f :. descriptio\n+00017d10: 6e73 203d 205b 0a20 2020 2020 2020 2053 ns = [. S\n+00017d20: 616d 706c 6544 6573 6372 6970 7469 6f6e ampleDescription\n+00017d30: 2827 6469 736b 2e61 6c6c 2e72 6561 6427 ('disk.all.read'\n+00017d40: 2c20 2762 7974 6573 272c 2027 636f 756e , 'bytes', 'coun\n+00017d50: 7465 7227 2c20 696e 7374 616e 6365 643d ter', instanced=\n+00017d60: 4661 6c73 6529 2c0a 2020 2020 2020 2020 False),. \n+00017d70: 5361 6d70 6c65 4465 7363 7269 7074 696f SampleDescriptio\n+00017d80: 6e28 2764 6973 6b2e 616c 6c2e 7772 6974 n('disk.all.writ\n+00017d90: 7465 6e27 2c20 2762 7974 6573 272c 2027 ten', 'bytes', '\n+00017da0: 636f 756e 7465 7227 2c20 696e 7374 616e counter', instan\n+00017db0: 6365 643d 4661 6c73 6529 2c0a 2020 2020 ced=False),. \n+00017dc0: 2020 2020 5361 6d70 6c65 4465 7363 7269 SampleDescri\n+00017dd0: 7074 696f 6e28 2764 6973 6b2e 6465 762e ption('disk.dev.\n+00017de0: 7265 6164 272c 2027 6279 7465 7327 2c20 read', 'bytes', \n+00017df0: 2763 6f75 6e74 6572 272c 2069 6e73 7461 'counter', insta\n+00017e00: 6e63 6564 3d54 7275 6529 2c0a 2020 2020 nced=True),. \n+00017e10: 2020 2020 5361 6d70 6c65 4465 7363 7269 SampleDescri\n+00017e20: 7074 696f 6e28 2764 6973 6b2e 6465 762e ption('disk.dev.\n+00017e30: 7772 6974 7465 6e27 2c20 2762 7974 6573 written', 'bytes\n+00017e40: 272c 2027 636f 756e 7465 7227 2c20 696e ', 'counter', in\n+00017e50: 7374 616e 6365 643d 5472 7565 292c 0a20 stanced=True),. \n+00017e60: 2020 205d 0a0a 2020 2020 6465 6620 7361 ].. def sa\n+00017e70: 6d70 6c65 2873 656c 662c 2073 616d 706c mple(self, sampl\n+00017e80: 6573 3a20 5361 6d70 6c65 7329 202d 3e20 es: Samples) -> \n+00017e90: 4e6f 6e65 3a0a 2020 2020 2020 2020 7769 None:. wi\n+00017ea0: 7468 206f 7065 6e28 272f 7072 6f63 2f64 th open('/proc/d\n+00017eb0: 6973 6b73 7461 7473 2729 2061 7320 6469 iskstats') as di\n+00017ec0: 736b 7374 6174 733a 0a20 2020 2020 2020 skstats:. \n+00017ed0: 2020 2020 2061 6c6c 5f72 6561 645f 6279 all_read_by\n+00017ee0: 7465 7320 3d20 300a 2020 2020 2020 2020 tes = 0. \n+00017ef0: 2020 2020 616c 6c5f 7772 6974 7465 6e5f all_written_\n+00017f00: 6279 7465 7320 3d20 300a 0a20 2020 2020 bytes = 0.. \n+00017f10: 2020 2020 2020 2066 6f72 206c 696e 6520 for line \n+00017f20: 696e 2064 6973 6b73 7461 7473 3a0a 2020 in diskstats:. \n+00017f30: 2020 2020 2020 2020 2020 2020 2020 2320 # \n+00017f40: 6874 7470 733a 2f2f 7777 772e 6b65 726e https://www.kern\n+00017f50: 656c 2e6f 7267 2f64 6f63 2f44 6f63 756d el.org/doc/Docum\n+00017f60: 656e 7461 7469 6f6e 2f41 4249 2f74 6573 entation/ABI/tes\n+00017f70: 7469 6e67 2f70 726f 6366 732d 6469 736b ting/procfs-disk\n+00017f80: 7374 6174 730a 2020 2020 2020 2020 2020 stats. \n+00017f90: 2020 2020 2020 6669 656c 6473 203d 206c fields = l\n+00017fa0: 696e 652e 7374 7269 7028 292e 7370 6c69 ine.strip().spli\n+00017fb0: 7428 290a 2020 2020 2020 2020 2020 2020 t(). \n+00017fc0: 2020 2020 6465 765f 6d61 6a6f 7220 3d20 dev_major = \n+00017fd0: 6669 656c 6473 5b30 5d0a 2020 2020 2020 fields[0]. \n+00017fe0: 2020 2020 2020 2020 2020 6465 765f 6e61 dev_na\n+00017ff0: 6d65 203d 2066 6965 6c64 735b 325d 0a20 me = fields[2]. \n+00018000: 2020 2020 2020 2020 2020 2020 2020 206e n\n+00018010: 756d 5f73 6563 746f 7273 5f72 6561 6420 um_sectors_read \n+00018020: 3d20 6669 656c 6473 5b35 5d0a 2020 2020 = fields[5]. \n+00018030: 2020 2020 2020 2020 2020 2020 6e75 6d5f num_\n+00018040: 7365 6374 6f72 735f 7772 6974 7465 6e20 sectors_written \n+00018050: 3d20 6669 656c 6473 5b39 5d0a 0a20 2020 = fields[9].. \n+00018060: 2020 2020 2020 2020 2020 2020 2023 2069 # i\n+00018070: 676e 6f72 6520 6d64 7261 6964 0a20 2020 gnore mdraid. \n+00018080: 2020 2020 2020 2020 2020 2020 2069 6620 if \n+00018090: 6465 765f 6d61 6a6f 7220 3d3d 2027 3927 dev_major == '9'\n+000180a0: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n+000180b0: 2020 2020 2020 636f 6e74 696e 7565 0a0a continue..\n+000180c0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000180d0: 2320 6967 6e6f 7265 2064 6576 6963 652d # ignore device-\n+000180e0: 6d61 7070 6572 0a20 2020 2020 2020 2020 mapper. \n+000180f0: 2020 2020 2020 2069 6620 6465 765f 6e61 if dev_na\n+00018100: 6d65 2e73 7461 7274 7377 6974 6828 2764 me.startswith('d\n+00018110: 6d2d 2729 3a0a 2020 2020 2020 2020 2020 m-'):. \n+00018120: 2020 2020 2020 2020 2020 636f 6e74 696e contin\n+00018130: 7565 0a0a 2020 2020 2020 2020 2020 2020 ue.. \n+00018140: 2020 2020 2320 536b 6970 2070 6172 7469 # Skip parti\n+00018150: 7469 6f6e 730a 2020 2020 2020 2020 2020 tions. \n+00018160: 2020 2020 2020 6966 2064 6576 5f6e 616d if dev_nam\n+00018170: 655b 3a32 5d20 696e 205b 2773 6427 2c20 e[:2] in ['sd', \n+00018180: 2768 6427 2c20 2776 6427 5d20 616e 6420 'hd', 'vd'] and \n+00018190: 6465 765f 6e61 6d65 5b2d 315d 2e69 7364 dev_name[-1].isd\n+000181a0: 6967 6974 2829 3a0a 2020 2020 2020 2020 igit():. \n+000181b0: 2020 2020 2020 2020 2020 2020 636f 6e74 cont\n+000181c0: 696e 7565 0a0a 2020 2020 2020 2020 2020 inue.. \n+000181d0: 2020 2020 2020 2320 4967 6e6f 7265 206e # Ignore n\n+000181e0: 766d 6520 7061 7274 6974 696f 6e73 0a20 vme partitions. \n+000181f0: 2020 2020 2020 2020 2020 2020 2020 2069 i\n+00018200: 6620 6465 765f 6e61 6d65 2e73 7461 7274 f dev_name.start\n+00018210: 7377 6974 6828 276e 766d 6527 2920 616e swith('nvme') an\n+00018220: 6420 2770 2720 696e 2064 6576 5f6e 616d d 'p' in dev_nam\n+00018230: 653a 0a20 2020 2020 2020 2020 2020 2020 e:. \n+00018240: 2020 2020 2020 2063 6f6e 7469 6e75 650a continue.\n+00018250: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+00018260: 2072 6561 645f 6279 7465 7320 3d20 696e read_bytes = in\n+00018270: 7428 6e75 6d5f 7365 6374 6f72 735f 7265 t(num_sectors_re\n+00018280: 6164 2920 2a20 3531 320a 2020 2020 2020 ad) * 512. \n+00018290: 2020 2020 2020 2020 2020 7772 6974 7465 writte\n+000182a0: 6e5f 6279 7465 7320 3d20 696e 7428 6e75 n_bytes = int(nu\n+000182b0: 6d5f 7365 6374 6f72 735f 7772 6974 7465 m_sectors_writte\n+000182c0: 6e29 202a 2035 3132 0a0a 2020 2020 2020 n) * 512.. \n+000182d0: 2020 2020 2020 2020 2020 616c 6c5f 7265 all_re\n+000182e0: 6164 5f62 7974 6573 202b 3d20 7265 6164 ad_bytes += read\n+000182f0: 5f62 7974 6573 0a20 2020 2020 2020 2020 _bytes. \n+00018300: 2020 2020 2020 2061 6c6c 5f77 7269 7474 all_writt\n+00018310: 656e 5f62 7974 6573 202b 3d20 7772 6974 en_bytes += writ\n+00018320: 7465 6e5f 6279 7465 730a 0a20 2020 2020 ten_bytes.. \n+00018330: 2020 2020 2020 2020 2020 2073 616d 706c sampl\n+00018340: 6573 5b27 6469 736b 2e64 6576 2e72 6561 es['disk.dev.rea\n+00018350: 6427 5d5b 6465 765f 6e61 6d65 5d20 3d20 d'][dev_name] = \n+00018360: 7265 6164 5f62 7974 6573 0a20 2020 2020 read_bytes. \n+00018370: 2020 2020 2020 2020 2020 2073 616d 706c sampl\n+00018380: 6573 5b27 6469 736b 2e64 6576 2e77 7269 es['disk.dev.wri\n+00018390: 7474 656e 275d 5b64 6576 5f6e 616d 655d tten'][dev_name]\n+000183a0: 203d 2077 7269 7474 656e 5f62 7974 6573 = written_bytes\n+000183b0: 0a0a 2020 2020 2020 2020 2020 2020 7361 .. sa\n+000183c0: 6d70 6c65 735b 2764 6973 6b2e 616c 6c2e mples['disk.all.\n+000183d0: 7265 6164 275d 203d 2061 6c6c 5f72 6561 read'] = all_rea\n+000183e0: 645f 6279 7465 730a 2020 2020 2020 2020 d_bytes. \n+000183f0: 2020 2020 7361 6d70 6c65 735b 2764 6973 samples['dis\n+00018400: 6b2e 616c 6c2e 7772 6974 7465 6e27 5d20 k.all.written'] \n+00018410: 3d20 616c 6c5f 7772 6974 7465 6e5f 6279 = all_written_by\n+00018420: 7465 730a 0a0a 636c 6173 7320 4347 726f tes...class CGro\n+00018430: 7570 5361 6d70 6c65 7228 5361 6d70 6c65 upSampler(Sample\n+00018440: 7229 3a0a 2020 2020 6465 7363 7269 7074 r):. descript\n+00018450: 696f 6e73 203d 205b 0a20 2020 2020 2020 ions = [. \n+00018460: 2053 616d 706c 6544 6573 6372 6970 7469 SampleDescripti\n+00018470: 6f6e 2827 6367 726f 7570 2e6d 656d 6f72 on('cgroup.memor\n+00018480: 792e 7573 6167 6527 2c20 2762 7974 6573 y.usage', 'bytes\n+00018490: 272c 2027 696e 7374 616e 7427 2c20 696e ', 'instant', in\n+000184a0: 7374 616e 6365 643d 5472 7565 292c 0a20 stanced=True),. \n+000184b0: 2020 2020 2020 2053 616d 706c 6544 6573 SampleDes\n+000184c0: 6372 6970 7469 6f6e 2827 6367 726f 7570 cription('cgroup\n+000184d0: 2e6d 656d 6f72 792e 6c69 6d69 7427 2c20 .memory.limit', \n+000184e0: 2762 7974 6573 272c 2027 696e 7374 616e 'bytes', 'instan\n+000184f0: 7427 2c20 696e 7374 616e 6365 643d 5472 t', instanced=Tr\n+00018500: 7565 292c 0a20 2020 2020 2020 2053 616d ue),. Sam\n+00018510: 706c 6544 6573 6372 6970 7469 6f6e 2827 pleDescription('\n+00018520: 6367 726f 7570 2e6d 656d 6f72 792e 7377 cgroup.memory.sw\n+00018530: 2d75 7361 6765 272c 2027 6279 7465 7327 -usage', 'bytes'\n+00018540: 2c20 2769 6e73 7461 6e74 272c 2069 6e73 , 'instant', ins\n+00018550: 7461 6e63 6564 3d54 7275 6529 2c0a 2020 tanced=True),. \n+00018560: 2020 2020 2020 5361 6d70 6c65 4465 7363 SampleDesc\n+00018570: 7269 7074 696f 6e28 2763 6772 6f75 702e ription('cgroup.\n+00018580: 6d65 6d6f 7279 2e73 772d 6c69 6d69 7427 memory.sw-limit'\n+00018590: 2c20 2762 7974 6573 272c 2027 696e 7374 , 'bytes', 'inst\n+000185a0: 616e 7427 2c20 696e 7374 616e 6365 643d ant', instanced=\n+000185b0: 5472 7565 292c 0a20 2020 2020 2020 2053 True),. S\n+000185c0: 616d 706c 6544 6573 6372 6970 7469 6f6e ampleDescription\n+000185d0: 2827 6367 726f 7570 2e63 7075 2e75 7361 ('cgroup.cpu.usa\n+000185e0: 6765 272c 2027 6d69 6c6c 6973 6563 272c ge', 'millisec',\n+000185f0: 2027 636f 756e 7465 7227 2c20 696e 7374 'counter', inst\n+00018600: 616e 6365 643d 5472 7565 292c 0a20 2020 anced=True),. \n+00018610: 2020 2020 2053 616d 706c 6544 6573 6372 SampleDescr\n+00018620: 6970 7469 6f6e 2827 6367 726f 7570 2e63 iption('cgroup.c\n+00018630: 7075 2e73 6861 7265 7327 2c20 2763 6f75 pu.shares', 'cou\n+00018640: 6e74 272c 2027 696e 7374 616e 7427 2c20 nt', 'instant', \n+00018650: 696e 7374 616e 6365 643d 5472 7565 292c instanced=True),\n+00018660: 0a20 2020 205d 0a0a 2020 2020 6367 726f . ].. cgro\n+00018670: 7570 735f 7632 3a20 4f70 7469 6f6e 616c ups_v2: Optional\n+00018680: 5b62 6f6f 6c5d 203d 204e 6f6e 650a 0a20 [bool] = None.. \n+00018690: 2020 2064 6566 2073 616d 706c 6528 7365 def sample(se\n+000186a0: 6c66 2c20 7361 6d70 6c65 733a 2053 616d lf, samples: Sam\n+000186b0: 706c 6573 2920 2d3e 204e 6f6e 653a 0a20 ples) -> None:. \n+000186c0: 2020 2020 2020 2069 6620 7365 6c66 2e63 if self.c\n+000186d0: 6772 6f75 7073 5f76 3220 6973 204e 6f6e groups_v2 is Non\n+000186e0: 653a 0a20 2020 2020 2020 2020 2020 2073 e:. s\n+000186f0: 656c 662e 6367 726f 7570 735f 7632 203d elf.cgroups_v2 =\n+00018700: 206f 732e 7061 7468 2e65 7869 7374 7328 os.path.exists(\n+00018710: 272f 7379 732f 6673 2f63 6772 6f75 702f '/sys/fs/cgroup/\n+00018720: 6367 726f 7570 2e63 6f6e 7472 6f6c 6c65 cgroup.controlle\n+00018730: 7273 2729 0a0a 2020 2020 2020 2020 6966 rs').. if\n+00018740: 2073 656c 662e 6367 726f 7570 735f 7632 self.cgroups_v2\n+00018750: 3a0a 2020 2020 2020 2020 2020 2020 6367 :. cg\n+00018760: 726f 7570 735f 7632 5f70 6174 6820 3d20 roups_v2_path = \n+00018770: 272f 7379 732f 6673 2f63 6772 6f75 702f '/sys/fs/cgroup/\n+00018780: 270a 2020 2020 2020 2020 2020 2020 666f '. fo\n+00018790: 7220 7061 7468 2c20 5f2c 205f 2c20 726f r path, _, _, ro\n+000187a0: 6f74 6664 2069 6e20 6f73 2e66 7761 6c6b otfd in os.fwalk\n+000187b0: 2863 6772 6f75 7073 5f76 325f 7061 7468 (cgroups_v2_path\n+000187c0: 293a 0a20 2020 2020 2020 2020 2020 2020 ):. \n+000187d0: 2020 2063 6772 6f75 7020 3d20 7061 7468 cgroup = path\n+000187e0: 2e72 6570 6c61 6365 2863 6772 6f75 7073 .replace(cgroups\n+000187f0: 5f76 325f 7061 7468 2c20 2727 290a 0a20 _v2_path, '').. \n+00018800: 2020 2020 2020 2020 2020 2020 2020 2069 i\n+00018810: 6620 6e6f 7420 6367 726f 7570 3a0a 2020 f not cgroup:. \n+00018820: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00018830: 2020 636f 6e74 696e 7565 0a0a 2020 2020 continue.. \n+00018840: 2020 2020 2020 2020 2020 2020 7361 6d70 samp\n+00018850: 6c65 735b 2763 6772 6f75 702e 6d65 6d6f les['cgroup.memo\n+00018860: 7279 2e75 7361 6765 275d 5b63 6772 6f75 ry.usage'][cgrou\n+00018870: 705d 203d 2072 6561 645f 696e 745f 6669 p] = read_int_fi\n+00018880: 6c65 2872 6f6f 7466 642c 2027 6d65 6d6f le(rootfd, 'memo\n+00018890: 7279 2e63 7572 7265 6e74 272c 2030 290a ry.current', 0).\n+000188a0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000188b0: 7361 6d70 6c65 735b 2763 6772 6f75 702e samples['cgroup.\n+000188c0: 6d65 6d6f 7279 2e6c 696d 6974 275d 5b63 memory.limit'][c\n+000188d0: 6772 6f75 705d 203d 2072 6561 645f 696e group] = read_in\n+000188e0: 745f 6669 6c65 2872 6f6f 7466 642c 2027 t_file(rootfd, '\n+000188f0: 6d65 6d6f 7279 2e6d 6178 2729 0a20 2020 memory.max'). \n+00018900: 2020 2020 2020 2020 2020 2020 2073 616d sam\n+00018910: 706c 6573 5b27 6367 726f 7570 2e6d 656d ples['cgroup.mem\n+00018920: 6f72 792e 7377 2d75 7361 6765 275d 5b63 ory.sw-usage'][c\n+00018930: 6772 6f75 705d 203d 2072 6561 645f 696e group] = read_in\n+00018940: 745f 6669 6c65 2872 6f6f 7466 642c 2027 t_file(rootfd, '\n+00018950: 6d65 6d6f 7279 2e73 7761 702e 6375 7272 memory.swap.curr\n+00018960: 656e 7427 2c20 3029 0a20 2020 2020 2020 ent', 0). \n+00018970: 2020 2020 2020 2020 2073 616d 706c 6573 samples\n+00018980: 5b27 6367 726f 7570 2e6d 656d 6f72 792e ['cgroup.memory.\n+00018990: 7377 2d6c 696d 6974 275d 5b63 6772 6f75 sw-limit'][cgrou\n+000189a0: 705d 203d 2072 6561 645f 696e 745f 6669 p] = read_int_fi\n+000189b0: 6c65 2872 6f6f 7466 642c 2027 6d65 6d6f le(rootfd, 'memo\n+000189c0: 7279 2e73 7761 702e 6d61 7827 290a 2020 ry.swap.max'). \n+000189d0: 2020 2020 2020 2020 2020 2020 2020 7361 sa\n+000189e0: 6d70 6c65 735b 2763 6772 6f75 702e 6370 mples['cgroup.cp\n+000189f0: 752e 7368 6172 6573 275d 5b63 6772 6f75 u.shares'][cgrou\n+00018a00: 705d 203d 2072 6561 645f 696e 745f 6669 p] = read_int_fi\n+00018a10: 6c65 2872 6f6f 7466 642c 2027 6370 752e le(rootfd, 'cpu.\n+00018a20: 7765 6967 6874 2729 0a20 2020 2020 2020 weight'). \n+00018a30: 2020 2020 2020 2020 2075 7361 6765 5f75 usage_u\n+00018a40: 7365 6320 3d20 7265 6164 5f69 6e74 5f66 sec = read_int_f\n+00018a50: 696c 6528 726f 6f74 6664 2c20 2763 7075 ile(rootfd, 'cpu\n+00018a60: 2e73 7461 7427 2c20 302c 206b 6579 3d62 .stat', 0, key=b\n+00018a70: 2775 7361 6765 5f75 7365 6327 290a 2020 'usage_usec'). \n+00018a80: 2020 2020 2020 2020 2020 2020 2020 6966 if\n+00018a90: 2075 7361 6765 5f75 7365 633a 0a20 2020 usage_usec:. \n+00018aa0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00018ab0: 2073 616d 706c 6573 5b27 6367 726f 7570 samples['cgroup\n+00018ac0: 2e63 7075 2e75 7361 6765 275d 5b63 6772 .cpu.usage'][cgr\n+00018ad0: 6f75 705d 203d 2075 7361 6765 5f75 7365 oup] = usage_use\n+00018ae0: 6320 2f20 3130 3030 0a20 2020 2020 2020 c / 1000. \n+00018af0: 2065 6c73 653a 0a20 2020 2020 2020 2020 else:. \n+00018b00: 2020 206d 656d 6f72 795f 7061 7468 203d memory_path =\n+00018b10: 2027 2f73 7973 2f66 732f 6367 726f 7570 '/sys/fs/cgroup\n+00018b20: 2f6d 656d 6f72 792f 270a 2020 2020 2020 /memory/'. \n+00018b30: 2020 2020 2020 666f 7220 7061 7468 2c20 for path, \n+00018b40: 5f2c 205f 2c20 726f 6f74 6664 2069 6e20 _, _, rootfd in \n+00018b50: 6f73 2e66 7761 6c6b 286d 656d 6f72 795f os.fwalk(memory_\n+00018b60: 7061 7468 293a 0a20 2020 2020 2020 2020 path):. \n+00018b70: 2020 2020 2020 2063 6772 6f75 7020 3d20 cgroup = \n+00018b80: 7061 7468 2e72 6570 6c61 6365 286d 656d path.replace(mem\n+00018b90: 6f72 795f 7061 7468 2c20 2727 290a 0a20 ory_path, '').. \n+00018ba0: 2020 2020 2020 2020 2020 2020 2020 2069 i\n+00018bb0: 6620 6e6f 7420 6367 726f 7570 3a0a 2020 f not cgroup:. \n+00018bc0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00018bd0: 2020 636f 6e74 696e 7565 0a0a 2020 2020 continue.. \n+00018be0: 2020 2020 2020 2020 2020 2020 7361 6d70 samp\n+00018bf0: 6c65 735b 2763 6772 6f75 702e 6d65 6d6f les['cgroup.memo\n+00018c00: 7279 2e75 7361 6765 275d 5b63 6772 6f75 ry.usage'][cgrou\n+00018c10: 705d 203d 2072 6561 645f 696e 745f 6669 p] = read_int_fi\n+00018c20: 6c65 2872 6f6f 7466 642c 2027 6d65 6d6f le(rootfd, 'memo\n+00018c30: 7279 2e75 7361 6765 5f69 6e5f 6279 7465 ry.usage_in_byte\n+00018c40: 7327 2c20 3029 0a20 2020 2020 2020 2020 s', 0). \n+00018c50: 2020 2020 2020 2073 616d 706c 6573 5b27 samples['\n+00018c60: 6367 726f 7570 2e6d 656d 6f72 792e 6c69 cgroup.memory.li\n+00018c70: 6d69 7427 5d5b 6367 726f 7570 5d20 3d20 mit'][cgroup] = \n+00018c80: 7265 6164 5f69 6e74 5f66 696c 6528 726f read_int_file(ro\n+00018c90: 6f74 6664 2c20 276d 656d 6f72 792e 6c69 otfd, 'memory.li\n+00018ca0: 6d69 745f 696e 5f62 7974 6573 2729 0a20 mit_in_bytes'). \n+00018cb0: 2020 2020 2020 2020 2020 2020 2020 2073 s\n+00018cc0: 616d 706c 6573 5b27 6367 726f 7570 2e6d amples['cgroup.m\n+00018cd0: 656d 6f72 792e 7377 2d75 7361 6765 275d emory.sw-usage']\n+00018ce0: 5b63 6772 6f75 705d 203d 2072 6561 645f [cgroup] = read_\n+00018cf0: 696e 745f 6669 6c65 2872 6f6f 7466 642c int_file(rootfd,\n+00018d00: 2027 6d65 6d6f 7279 2e6d 656d 7377 2e75 'memory.memsw.u\n+00018d10: 7361 6765 5f69 6e5f 6279 7465 7327 2c20 sage_in_bytes', \n+00018d20: 3029 0a20 2020 2020 2020 2020 2020 2020 0). \n+00018d30: 2020 2073 616d 706c 6573 5b27 6367 726f samples['cgro\n+00018d40: 7570 2e6d 656d 6f72 792e 7377 2d6c 696d up.memory.sw-lim\n+00018d50: 6974 275d 5b63 6772 6f75 705d 203d 2072 it'][cgroup] = r\n+00018d60: 6561 645f 696e 745f 6669 6c65 2872 6f6f ead_int_file(roo\n+00018d70: 7466 642c 2027 6d65 6d6f 7279 2e6d 656d tfd, 'memory.mem\n+00018d80: 7377 2e6c 696d 6974 5f69 6e5f 6279 7465 sw.limit_in_byte\n+00018d90: 7327 290a 0a20 2020 2020 2020 2020 2020 s').. \n+00018da0: 2063 7075 5f70 6174 6820 3d20 272f 7379 cpu_path = '/sy\n+00018db0: 732f 6673 2f63 6772 6f75 702f 6370 752f s/fs/cgroup/cpu/\n+00018dc0: 270a 2020 2020 2020 2020 2020 2020 666f '. fo\n+00018dd0: 7220 7061 7468 2c20 5f2c 205f 2c20 726f r path, _, _, ro\n+00018de0: 6f74 6664 2069 6e20 6f73 2e66 7761 6c6b otfd in os.fwalk\n+00018df0: 2863 7075 5f70 6174 6829 3a0a 2020 2020 (cpu_path):. \n+00018e00: 2020 2020 2020 2020 2020 2020 6367 726f cgro\n+00018e10: 7570 203d 2070 6174 682e 7265 706c 6163 up = path.replac\n+00018e20: 6528 6370 755f 7061 7468 2c20 2727 290a e(cpu_path, '').\n+00018e30: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+00018e40: 2069 6620 6e6f 7420 6367 726f 7570 3a0a if not cgroup:.\n+00018e50: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00018e60: 2020 2020 636f 6e74 696e 7565 0a0a 2020 continue.. \n+00018e70: 2020 2020 2020 2020 2020 2020 2020 7361 sa\n+00018e80: 6d70 6c65 735b 2763 6772 6f75 702e 6370 mples['cgroup.cp\n+00018e90: 752e 7368 6172 6573 275d 5b63 6772 6f75 u.shares'][cgrou\n+00018ea0: 705d 203d 2072 6561 645f 696e 745f 6669 p] = read_int_fi\n+00018eb0: 6c65 2872 6f6f 7466 642c 2027 6370 752e le(rootfd, 'cpu.\n+00018ec0: 7368 6172 6573 2729 0a20 2020 2020 2020 shares'). \n+00018ed0: 2020 2020 2020 2020 2075 7361 6765 5f6e usage_n\n+00018ee0: 7365 6320 3d20 7265 6164 5f69 6e74 5f66 sec = read_int_f\n+00018ef0: 696c 6528 726f 6f74 6664 2c20 2763 7075 ile(rootfd, 'cpu\n+00018f00: 6163 6374 2e75 7361 6765 2729 0a20 2020 acct.usage'). \n+00018f10: 2020 2020 2020 2020 2020 2020 2069 6620 if \n+00018f20: 7573 6167 655f 6e73 6563 3a0a 2020 2020 usage_nsec:. \n+00018f30: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00018f40: 7361 6d70 6c65 735b 2763 6772 6f75 702e samples['cgroup.\n+00018f50: 6370 752e 7573 6167 6527 5d5b 6367 726f cpu.usage'][cgro\n+00018f60: 7570 5d20 3d20 7573 6167 655f 6e73 6563 up] = usage_nsec\n+00018f70: 202f 2031 3030 3030 3030 0a0a 0a63 6c61 / 1000000...cla\n+00018f80: 7373 2043 4772 6f75 7044 6973 6b49 4f28 ss CGroupDiskIO(\n+00018f90: 5361 6d70 6c65 7229 3a0a 2020 2020 494f Sampler):. IO\n+00018fa0: 5f52 4520 3d20 7265 2e63 6f6d 7069 6c65 _RE = re.compile\n+00018fb0: 2872 6227 5c62 7265 6164 5f62 7974 6573 (rb'\\bread_bytes\n+00018fc0: 3a20 283f 503c 7265 6164 3e5c 642b 292e : (?P\\d+).\n+00018fd0: 2a5c 6e77 7269 7465 5f62 7974 6573 3a20 *\\nwrite_bytes: \n+00018fe0: 283f 503c 7772 6974 653e 5c64 2b29 272c (?P\\d+)',\n+00018ff0: 2066 6c61 6773 3d72 652e 5329 0a20 2020 flags=re.S). \n+00019000: 2064 6573 6372 6970 7469 6f6e 7320 3d20 descriptions = \n+00019010: 5b0a 2020 2020 2020 2020 5361 6d70 6c65 [. Sample\n+00019020: 4465 7363 7269 7074 696f 6e28 2764 6973 Description('dis\n+00019030: 6b2e 6367 726f 7570 2e72 6561 6427 2c20 k.cgroup.read', \n+00019040: 2762 7974 6573 272c 2027 636f 756e 7465 'bytes', 'counte\n+00019050: 7227 2c20 696e 7374 616e 6365 643d 5472 r', instanced=Tr\n+00019060: 7565 292c 0a20 2020 2020 2020 2053 616d ue),. Sam\n+00019070: 706c 6544 6573 6372 6970 7469 6f6e 2827 pleDescription('\n+00019080: 6469 736b 2e63 6772 6f75 702e 7772 6974 disk.cgroup.writ\n+00019090: 7465 6e27 2c20 2762 7974 6573 272c 2027 ten', 'bytes', '\n+000190a0: 636f 756e 7465 7227 2c20 696e 7374 616e counter', instan\n+000190b0: 6365 643d 5472 7565 292c 0a20 2020 205d ced=True),. ]\n+000190c0: 0a0a 2020 2020 4073 7461 7469 636d 6574 .. @staticmet\n+000190d0: 686f 640a 2020 2020 6465 6620 6765 745f hod. def get_\n+000190e0: 6367 726f 7570 5f6e 616d 6528 6664 3a20 cgroup_name(fd: \n+000190f0: 696e 7429 202d 3e20 7374 723a 0a20 2020 int) -> str:. \n+00019100: 2020 2020 2077 6974 6820 4861 6e64 6c65 with Handle\n+00019110: 2e6f 7065 6e28 2763 6772 6f75 7027 2c20 .open('cgroup', \n+00019120: 6f73 2e4f 5f52 444f 4e4c 592c 2064 6972 os.O_RDONLY, dir\n+00019130: 5f66 643d 6664 2920 6173 2063 6772 6f75 _fd=fd) as cgrou\n+00019140: 705f 6664 3a0a 2020 2020 2020 2020 2020 p_fd:. \n+00019150: 2020 6367 726f 7570 5f6e 616d 6520 3d20 cgroup_name = \n+00019160: 6f73 2e72 6561 6428 6367 726f 7570 5f66 os.read(cgroup_f\n+00019170: 642c 2032 3034 3829 2e64 6563 6f64 6528 d, 2048).decode(\n+00019180: 292e 7374 7269 7028 290a 0a20 2020 2020 ).strip().. \n+00019190: 2020 2020 2020 2023 2053 6b69 7020 6c65 # Skip le\n+000191a0: 6164 696e 6720 3a3a 302f 0a20 2020 2020 ading ::0/. \n+000191b0: 2020 2020 2020 2072 6574 7572 6e20 6367 return cg\n+000191c0: 726f 7570 5f6e 616d 655b 343a 5d0a 0a20 roup_name[4:].. \n+000191d0: 2020 2040 7374 6174 6963 6d65 7468 6f64 @staticmethod\n+000191e0: 0a20 2020 2064 6566 2067 6574 5f70 726f . def get_pro\n+000191f0: 635f 696f 2866 643a 2069 6e74 2920 2d3e c_io(fd: int) ->\n+00019200: 2054 7570 6c65 5b69 6e74 2c20 696e 745d Tuple[int, int]\n+00019210: 3a0a 2020 2020 2020 2020 7769 7468 2048 :. with H\n+00019220: 616e 646c 652e 6f70 656e 2827 696f 272c andle.open('io',\n+00019230: 206f 732e 4f5f 5244 4f4e 4c59 2c20 6469 os.O_RDONLY, di\n+00019240: 725f 6664 3d66 6429 2061 7320 696f 5f66 r_fd=fd) as io_f\n+00019250: 643a 0a20 2020 2020 2020 2020 2020 2064 d:. d\n+00019260: 6174 6120 3d20 6f73 2e72 6561 6428 696f ata = os.read(io\n+00019270: 5f66 642c 2034 3039 3629 0a0a 2020 2020 _fd, 4096).. \n+00019280: 2020 2020 2020 2020 6d61 7463 6820 3d20 match = \n+00019290: 7265 2e73 6561 7263 6828 4347 726f 7570 re.search(CGroup\n+000192a0: 4469 736b 494f 2e49 4f5f 5245 2c20 6461 DiskIO.IO_RE, da\n+000192b0: 7461 290a 2020 2020 2020 2020 2020 2020 ta). \n+000192c0: 6966 206d 6174 6368 3a0a 2020 2020 2020 if match:. \n+000192d0: 2020 2020 2020 2020 2020 7072 6f63 5f72 proc_r\n+000192e0: 6561 6420 3d20 696e 7428 6d61 7463 682e ead = int(match.\n+000192f0: 6772 6f75 7028 2772 6561 6427 2929 0a20 group('read')). \n+00019300: 2020 2020 2020 2020 2020 2020 2020 2070 p\n+00019310: 726f 635f 7772 6974 6520 3d20 696e 7428 roc_write = int(\n+00019320: 6d61 7463 682e 6772 6f75 7028 2777 7269 match.group('wri\n+00019330: 7465 2729 290a 0a20 2020 2020 2020 2020 te')).. \n+00019340: 2020 2020 2020 2072 6574 7572 6e20 7072 return pr\n+00019350: 6f63 5f72 6561 642c 2070 726f 635f 7772 oc_read, proc_wr\n+00019360: 6974 650a 0a20 2020 2020 2020 2020 2020 ite.. \n+00019370: 2072 6574 7572 6e20 302c 2030 0a0a 2020 return 0, 0.. \n+00019380: 2020 6465 6620 7361 6d70 6c65 2873 656c def sample(sel\n+00019390: 662c 2073 616d 706c 6573 3a20 5361 6d70 f, samples: Samp\n+000193a0: 6c65 7329 3a0a 2020 2020 2020 2020 7769 les):. wi\n+000193b0: 7468 2048 616e 646c 652e 6f70 656e 2827 th Handle.open('\n+000193c0: 2f70 726f 6327 2c20 6f73 2e4f 5f52 444f /proc', os.O_RDO\n+000193d0: 4e4c 5920 7c20 6f73 2e4f 5f44 4952 4543 NLY | os.O_DIREC\n+000193e0: 544f 5259 2920 6173 2070 726f 635f 6664 TORY) as proc_fd\n+000193f0: 3a0a 2020 2020 2020 2020 2020 2020 7265 :. re\n+00019400: 6164 7320 3d20 7361 6d70 6c65 735b 2764 ads = samples['d\n+00019410: 6973 6b2e 6367 726f 7570 2e72 6561 6427 isk.cgroup.read'\n+00019420: 5d0a 2020 2020 2020 2020 2020 2020 7772 ]. wr\n+00019430: 6974 6573 203d 2073 616d 706c 6573 5b27 ites = samples['\n+00019440: 6469 736b 2e63 6772 6f75 702e 7772 6974 disk.cgroup.writ\n+00019450: 7465 6e27 5d0a 0a20 2020 2020 2020 2020 ten'].. \n+00019460: 2020 2066 6f72 2070 6174 6820 696e 206f for path in o\n+00019470: 732e 6c69 7374 6469 7228 7072 6f63 5f66 s.listdir(proc_f\n+00019480: 6429 3a0a 2020 2020 2020 2020 2020 2020 d):. \n+00019490: 2020 2020 2320 6e6f 6e2d 7069 6420 656e # non-pid en\n+000194a0: 7472 6965 7320 696e 2070 726f 6320 6172 tries in proc ar\n+000194b0: 6520 6775 6172 616e 7465 6564 2074 6f20 e guaranteed to \n+000194c0: 7374 6172 7420 7769 7468 2061 2063 6861 start with a cha\n+000194d0: 7261 6374 6572 2061 2d7a 0a20 2020 2020 racter a-z. \n+000194e0: 2020 2020 2020 2020 2020 2069 6620 7061 if pa\n+000194f0: 7468 5b30 5d20 3c20 2730 2720 6f72 2070 th[0] < '0' or p\n+00019500: 6174 685b 305d 203e 2027 3927 3a0a 2020 ath[0] > '9':. \n+00019510: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00019520: 2020 636f 6e74 696e 7565 0a0a 2020 2020 continue.. \n+00019530: 2020 2020 2020 2020 2020 2020 7472 793a try:\n+00019540: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+00019550: 2020 2020 2077 6974 6820 4861 6e64 6c65 with Handle\n+00019560: 2e6f 7065 6e28 7061 7468 2c20 6f73 2e4f .open(path, os.O\n+00019570: 5f50 4154 482c 2064 6972 5f66 643d 7072 _PATH, dir_fd=pr\n+00019580: 6f63 5f66 6429 2061 7320 7069 645f 6664 oc_fd) as pid_fd\n+00019590: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n+000195a0: 2020 2020 2020 2020 2020 6367 726f 7570 cgroup\n+000195b0: 5f6e 616d 6520 3d20 7365 6c66 2e67 6574 _name = self.get\n+000195c0: 5f63 6772 6f75 705f 6e61 6d65 2870 6964 _cgroup_name(pid\n+000195d0: 5f66 6429 0a20 2020 2020 2020 2020 2020 _fd). \n+000195e0: 2020 2020 2020 2020 2020 2020 2070 726f pro\n+000195f0: 635f 7265 6164 2c20 7072 6f63 5f77 7269 c_read, proc_wri\n+00019600: 7465 203d 2073 656c 662e 6765 745f 7072 te = self.get_pr\n+00019610: 6f63 5f69 6f28 7069 645f 6664 290a 2020 oc_io(pid_fd). \n+00019620: 2020 2020 2020 2020 2020 2020 2020 6578 ex\n+00019630: 6365 7074 2028 4669 6c65 4e6f 7446 6f75 cept (FileNotFou\n+00019640: 6e64 4572 726f 722c 2050 6572 6d69 7373 ndError, Permiss\n+00019650: 696f 6e45 7272 6f72 2c20 5072 6f63 6573 ionError, Proces\n+00019660: 734c 6f6f 6b75 7045 7272 6f72 293a 0a20 sLookupError):. \n+00019670: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00019680: 2020 2063 6f6e 7469 6e75 650a 0a20 2020 continue.. \n+00019690: 2020 2020 2020 2020 2020 2020 2072 6561 rea\n+000196a0: 6473 5b63 6772 6f75 705f 6e61 6d65 5d20 ds[cgroup_name] \n+000196b0: 3d20 7265 6164 732e 6765 7428 6367 726f = reads.get(cgro\n+000196c0: 7570 5f6e 616d 652c 2030 2920 2b20 7072 up_name, 0) + pr\n+000196d0: 6f63 5f72 6561 640a 2020 2020 2020 2020 oc_read. \n+000196e0: 2020 2020 2020 2020 7772 6974 6573 5b63 writes[c\n+000196f0: 6772 6f75 705f 6e61 6d65 5d20 3d20 7772 group_name] = wr\n+00019700: 6974 6573 2e67 6574 2863 6772 6f75 705f ites.get(cgroup_\n+00019710: 6e61 6d65 2c20 3029 202b 2070 726f 635f name, 0) + proc_\n+00019720: 7772 6974 650a 0a0a 636c 6173 7320 4e65 write...class Ne\n+00019730: 7477 6f72 6b53 616d 706c 6572 2853 616d tworkSampler(Sam\n+00019740: 706c 6572 293a 0a20 2020 2064 6573 6372 pler):. descr\n+00019750: 6970 7469 6f6e 7320 3d20 5b0a 2020 2020 iptions = [. \n+00019760: 2020 2020 5361 6d70 6c65 4465 7363 7269 SampleDescri\n+00019770: 7074 696f 6e28 276e 6574 776f 726b 2e69 ption('network.i\n+00019780: 6e74 6572 6661 6365 2e74 7827 2c20 2762 nterface.tx', 'b\n+00019790: 7974 6573 272c 2027 636f 756e 7465 7227 ytes', 'counter'\n+000197a0: 2c20 696e 7374 616e 6365 643d 5472 7565 , instanced=True\n+000197b0: 292c 0a20 2020 2020 2020 2053 616d 706c ),. Sampl\n+000197c0: 6544 6573 6372 6970 7469 6f6e 2827 6e65 eDescription('ne\n+000197d0: 7477 6f72 6b2e 696e 7465 7266 6163 652e twork.interface.\n+000197e0: 7278 272c 2027 6279 7465 7327 2c20 2763 rx', 'bytes', 'c\n+000197f0: 6f75 6e74 6572 272c 2069 6e73 7461 6e63 ounter', instanc\n+00019800: 6564 3d54 7275 6529 2c0a 2020 2020 5d0a ed=True),. ].\n+00019810: 0a20 2020 2064 6566 2073 616d 706c 6528 . def sample(\n+00019820: 7365 6c66 2c20 7361 6d70 6c65 733a 2053 self, samples: S\n+00019830: 616d 706c 6573 2920 2d3e 204e 6f6e 653a amples) -> None:\n+00019840: 0a20 2020 2020 2020 2077 6974 6820 6f70 . with op\n+00019850: 656e 2822 2f70 726f 632f 6e65 742f 6465 en(\"/proc/net/de\n+00019860: 7622 2920 6173 206e 6574 776f 726b 5f73 v\") as network_s\n+00019870: 616d 706c 6573 3a0a 2020 2020 2020 2020 amples:. \n+00019880: 2020 2020 666f 7220 6c69 6e65 2069 6e20 for line in \n+00019890: 6e65 7477 6f72 6b5f 7361 6d70 6c65 733a network_samples:\n+000198a0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+000198b0: 2066 6965 6c64 7320 3d20 6c69 6e65 2e73 fields = line.s\n+000198c0: 706c 6974 2829 0a0a 2020 2020 2020 2020 plit().. \n+000198d0: 2020 2020 2020 2020 2320 536b 6970 2068 # Skip h\n+000198e0: 6561 6465 7220 6c69 6e65 0a20 2020 2020 eader line. \n+000198f0: 2020 2020 2020 2020 2020 2069 6620 6669 if fi\n+00019900: 656c 6473 5b30 5d5b 2d31 5d20 213d 2027 elds[0][-1] != '\n+00019910: 3a27 3a0a 2020 2020 2020 2020 2020 2020 :':. \n+00019920: 2020 2020 2020 2020 636f 6e74 696e 7565 continue\n+00019930: 0a0a 2020 2020 2020 2020 2020 2020 2020 .. \n+00019940: 2020 6966 6163 6520 3d20 6669 656c 6473 iface = fields\n+00019950: 5b30 5d5b 3a2d 315d 0a20 2020 2020 2020 [0][:-1]. \n+00019960: 2020 2020 2020 2020 2073 616d 706c 6573 samples\n+00019970: 5b27 6e65 7477 6f72 6b2e 696e 7465 7266 ['network.interf\n+00019980: 6163 652e 7278 275d 5b69 6661 6365 5d20 ace.rx'][iface] \n+00019990: 3d20 696e 7428 6669 656c 6473 5b31 5d29 = int(fields[1])\n+000199a0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+000199b0: 2073 616d 706c 6573 5b27 6e65 7477 6f72 samples['networ\n+000199c0: 6b2e 696e 7465 7266 6163 652e 7478 275d k.interface.tx']\n+000199d0: 5b69 6661 6365 5d20 3d20 696e 7428 6669 [iface] = int(fi\n+000199e0: 656c 6473 5b39 5d29 0a0a 0a63 6c61 7373 elds[9])...class\n+000199f0: 204d 6f75 6e74 5361 6d70 6c65 7228 5361 MountSampler(Sa\n+00019a00: 6d70 6c65 7229 3a0a 2020 2020 6465 7363 mpler):. desc\n+00019a10: 7269 7074 696f 6e73 203d 205b 0a20 2020 riptions = [. \n+00019a20: 2020 2020 2053 616d 706c 6544 6573 6372 SampleDescr\n+00019a30: 6970 7469 6f6e 2827 6d6f 756e 742e 746f iption('mount.to\n+00019a40: 7461 6c27 2c20 2762 7974 6573 272c 2027 tal', 'bytes', '\n+00019a50: 696e 7374 616e 7427 2c20 696e 7374 616e instant', instan\n+00019a60: 6365 643d 5472 7565 292c 0a20 2020 2020 ced=True),. \n+00019a70: 2020 2053 616d 706c 6544 6573 6372 6970 SampleDescrip\n+00019a80: 7469 6f6e 2827 6d6f 756e 742e 7573 6564 tion('mount.used\n+00019a90: 272c 2027 6279 7465 7327 2c20 2769 6e73 ', 'bytes', 'ins\n+00019aa0: 7461 6e74 272c 2069 6e73 7461 6e63 6564 tant', instanced\n+00019ab0: 3d54 7275 6529 2c0a 2020 2020 5d0a 0a20 =True),. ].. \n+00019ac0: 2020 2064 6566 2073 616d 706c 6528 7365 def sample(se\n+00019ad0: 6c66 2c20 7361 6d70 6c65 733a 2053 616d lf, samples: Sam\n+00019ae0: 706c 6573 2920 2d3e 204e 6f6e 653a 0a20 ples) -> None:. \n+00019af0: 2020 2020 2020 2077 6974 6820 6f70 656e with open\n+00019b00: 2827 2f70 726f 632f 6d6f 756e 7473 2729 ('/proc/mounts')\n+00019b10: 2061 7320 6d6f 756e 7473 3a0a 2020 2020 as mounts:. \n+00019b20: 2020 2020 2020 2020 666f 7220 6c69 6e65 for line\n+00019b30: 2069 6e20 6d6f 756e 7473 3a0a 2020 2020 in mounts:. \n+00019b40: 2020 2020 2020 2020 2020 2020 2320 4f6e # On\n+00019b50: 6c79 206c 6f6f 6b20 6174 2072 6561 6c20 ly look at real \n+00019b60: 6465 7669 6365 730a 2020 2020 2020 2020 devices. \n+00019b70: 2020 2020 2020 2020 6966 206c 696e 655b if line[\n+00019b80: 305d 2021 3d20 272f 273a 0a20 2020 2020 0] != '/':. \n+00019b90: 2020 2020 2020 2020 2020 2020 2020 2063 c\n+00019ba0: 6f6e 7469 6e75 650a 0a20 2020 2020 2020 ontinue.. \n+00019bb0: 2020 2020 2020 2020 2070 6174 6820 3d20 path = \n+00019bc0: 6c69 6e65 2e73 706c 6974 2829 5b31 5d0a line.split()[1].\n+00019bd0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00019be0: 7472 793a 0a20 2020 2020 2020 2020 2020 try:. \n+00019bf0: 2020 2020 2020 2020 2072 6573 203d 206f res = o\n+00019c00: 732e 7374 6174 7666 7328 7061 7468 290a s.statvfs(path).\n+00019c10: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00019c20: 6578 6365 7074 204f 5345 7272 6f72 3a0a except OSError:.\n+00019c30: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00019c40: 2020 2020 636f 6e74 696e 7565 0a20 2020 continue. \n+00019c50: 2020 2020 2020 2020 2020 2020 2066 7273 frs\n+00019c60: 697a 6520 3d20 7265 732e 665f 6672 7369 ize = res.f_frsi\n+00019c70: 7a65 0a20 2020 2020 2020 2020 2020 2020 ze. \n+00019c80: 2020 2074 6f74 616c 203d 2066 7273 697a total = frsiz\n+00019c90: 6520 2a20 7265 732e 665f 626c 6f63 6b73 e * res.f_blocks\n+00019ca0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+00019cb0: 2073 616d 706c 6573 5b27 6d6f 756e 742e samples['mount.\n+00019cc0: 746f 7461 6c27 5d5b 7061 7468 5d20 3d20 total'][path] = \n+00019cd0: 746f 7461 6c0a 2020 2020 2020 2020 2020 total. \n+00019ce0: 2020 2020 2020 7361 6d70 6c65 735b 276d samples['m\n+00019cf0: 6f75 6e74 2e75 7365 6427 5d5b 7061 7468 ount.used'][path\n+00019d00: 5d20 3d20 746f 7461 6c20 2d20 6672 7369 ] = total - frsi\n+00019d10: 7a65 202a 2072 6573 2e66 5f62 6672 6565 ze * res.f_bfree\n+00019d20: 0a0a 0a63 6c61 7373 2042 6c6f 636b 5361 ...class BlockSa\n+00019d30: 6d70 6c65 7228 5361 6d70 6c65 7229 3a0a mpler(Sampler):.\n+00019d40: 2020 2020 6465 7363 7269 7074 696f 6e73 descriptions\n+00019d50: 203d 205b 0a20 2020 2020 2020 2053 616d = [. Sam\n+00019d60: 706c 6544 6573 6372 6970 7469 6f6e 2827 pleDescription('\n+00019d70: 626c 6f63 6b2e 6465 7669 6365 2e72 6561 block.device.rea\n+00019d80: 6427 2c20 2762 7974 6573 272c 2027 636f d', 'bytes', 'co\n+00019d90: 756e 7465 7227 2c20 696e 7374 616e 6365 unter', instance\n+00019da0: 643d 5472 7565 292c 0a20 2020 2020 2020 d=True),. \n+00019db0: 2053 616d 706c 6544 6573 6372 6970 7469 SampleDescripti\n+00019dc0: 6f6e 2827 626c 6f63 6b2e 6465 7669 6365 on('block.device\n+00019dd0: 2e77 7269 7474 656e 272c 2027 6279 7465 .written', 'byte\n+00019de0: 7327 2c20 2763 6f75 6e74 6572 272c 2069 s', 'counter', i\n+00019df0: 6e73 7461 6e63 6564 3d54 7275 6529 2c0a nstanced=True),.\n+00019e00: 2020 2020 5d0a 0a20 2020 2064 6566 2073 ].. def s\n+00019e10: 616d 706c 6528 7365 6c66 2c20 7361 6d70 ample(self, samp\n+00019e20: 6c65 733a 2053 616d 706c 6573 2920 2d3e les: Samples) ->\n+00019e30: 204e 6f6e 653a 0a20 2020 2020 2020 2077 None:. w\n+00019e40: 6974 6820 6f70 656e 2827 2f70 726f 632f ith open('/proc/\n+00019e50: 6469 736b 7374 6174 7327 2920 6173 2064 diskstats') as d\n+00019e60: 6973 6b73 7461 7473 3a0a 2020 2020 2020 iskstats:. \n+00019e70: 2020 2020 2020 666f 7220 6c69 6e65 2069 for line i\n+00019e80: 6e20 6469 736b 7374 6174 733a 0a20 2020 n diskstats:. \n+00019e90: 2020 2020 2020 2020 2020 2020 2023 2068 # h\n+00019ea0: 7474 7073 3a2f 2f77 7777 2e6b 6572 6e65 ttps://www.kerne\n+00019eb0: 6c2e 6f72 672f 646f 632f 446f 6375 6d65 l.org/doc/Docume\n+00019ec0: 6e74 6174 696f 6e2f 4142 492f 7465 7374 ntation/ABI/test\n+00019ed0: 696e 672f 7072 6f63 6673 2d64 6973 6b73 ing/procfs-disks\n+00019ee0: 7461 7473 0a20 2020 2020 2020 2020 2020 tats. \n+00019ef0: 2020 2020 205b 5f2c 205f 2c20 6465 765f [_, _, dev_\n+00019f00: 6e61 6d65 2c20 5f2c 205f 2c20 7365 6374 name, _, _, sect\n+00019f10: 6f72 735f 7265 6164 2c20 5f2c 205f 2c20 ors_read, _, _, \n+00019f20: 5f2c 2073 6563 746f 7273 5f77 7269 7474 _, sectors_writt\n+00019f30: 656e 2c20 2a5f 5d20 3d20 6c69 6e65 2e73 en, *_] = line.s\n+00019f40: 7472 6970 2829 2e73 706c 6974 2829 0a0a trip().split()..\n+00019f50: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00019f60: 7361 6d70 6c65 735b 2762 6c6f 636b 2e64 samples['block.d\n+00019f70: 6576 6963 652e 7265 6164 275d 5b64 6576 evice.read'][dev\n+00019f80: 5f6e 616d 655d 203d 2069 6e74 2873 6563 _name] = int(sec\n+00019f90: 746f 7273 5f72 6561 6429 202a 2035 3132 tors_read) * 512\n+00019fa0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+00019fb0: 2073 616d 706c 6573 5b27 626c 6f63 6b2e samples['block.\n+00019fc0: 6465 7669 6365 2e77 7269 7474 656e 275d device.written']\n+00019fd0: 5b64 6576 5f6e 616d 655d 203d 2069 6e74 [dev_name] = int\n+00019fe0: 2873 6563 746f 7273 5f77 7269 7474 656e (sectors_written\n+00019ff0: 2920 2a20 3531 320a 0a0a 5341 4d50 4c45 ) * 512...SAMPLE\n+0001a000: 5253 203d 205b 0a20 2020 2042 6c6f 636b RS = [. Block\n+0001a010: 5361 6d70 6c65 722c 0a20 2020 2043 4772 Sampler,. CGr\n+0001a020: 6f75 7053 616d 706c 6572 2c0a 2020 2020 oupSampler,. \n+0001a030: 4347 726f 7570 4469 736b 494f 2c0a 2020 CGroupDiskIO,. \n+0001a040: 2020 4350 5553 616d 706c 6572 2c0a 2020 CPUSampler,. \n+0001a050: 2020 4350 5554 656d 7065 7261 7475 7265 CPUTemperature\n+0001a060: 5361 6d70 6c65 722c 0a20 2020 2044 6973 Sampler,. Dis\n+0001a070: 6b53 616d 706c 6572 2c0a 2020 2020 4d65 kSampler,. Me\n+0001a080: 6d6f 7279 5361 6d70 6c65 722c 0a20 2020 morySampler,. \n+0001a090: 204d 6f75 6e74 5361 6d70 6c65 722c 0a20 MountSampler,. \n+0001a0a0: 2020 204e 6574 776f 726b 5361 6d70 6c65 NetworkSample\n+0001a0b0: 722c 0a5d 0a27 2727 2c0a 2020 2763 6f63 r,.].''',. 'coc\n+0001a0c0: 6b70 6974 2f5f 7665 7273 696f 6e2e 7079 kpit/_version.py\n+0001a0d0: 273a 2062 7227 2727 5f5f 7665 7273 696f ': br'''__versio\n+0001a0e0: 6e5f 5f20 3d20 2733 3136 270a 2727 272c n__ = '316'.''',\n+0001a0f0: 0a20 2027 636f 636b 7069 742f 6a73 6f6e . 'cockpit/json\n+0001a100: 7574 696c 2e70 7927 3a20 7227 2727 2320 util.py': r'''# \n+0001a110: 5468 6973 2066 696c 6520 6973 2070 6172 This file is par\n+0001a120: 7420 6f66 2043 6f63 6b70 6974 2e0a 230a t of Cockpit..#.\n+0001a130: 2320 436f 7079 7269 6768 7420 2843 2920 # Copyright (C) \n+0001a140: 3230 3233 2052 6564 2048 6174 2c20 496e 2023 Red Hat, In\n+0001a150: 632e 0a23 0a23 2054 6869 7320 7072 6f67 c..#.# This prog\n+0001a160: 7261 6d20 6973 2066 7265 6520 736f 6674 ram is free soft\n+0001a170: 7761 7265 3a20 796f 7520 6361 6e20 7265 ware: you can re\n+0001a180: 6469 7374 7269 6275 7465 2069 7420 616e distribute it an\n+0001a190: 642f 6f72 206d 6f64 6966 790a 2320 6974 d/or modify.# it\n+0001a1a0: 2075 6e64 6572 2074 6865 2074 6572 6d73 under the terms\n+0001a1b0: 206f 6620 7468 6520 474e 5520 4765 6e65 of the GNU Gene\n+0001a1c0: 7261 6c20 5075 626c 6963 204c 6963 656e ral Public Licen\n+0001a1d0: 7365 2061 7320 7075 626c 6973 6865 6420 se as published \n+0001a1e0: 6279 0a23 2074 6865 2046 7265 6520 536f by.# the Free So\n+0001a1f0: 6674 7761 7265 2046 6f75 6e64 6174 696f ftware Foundatio\n+0001a200: 6e2c 2065 6974 6865 7220 7665 7273 696f n, either versio\n+0001a210: 6e20 3320 6f66 2074 6865 204c 6963 656e n 3 of the Licen\n+0001a220: 7365 2c20 6f72 0a23 2028 6174 2079 6f75 se, or.# (at you\n+0001a230: 7220 6f70 7469 6f6e 2920 616e 7920 6c61 r option) any la\n+0001a240: 7465 7220 7665 7273 696f 6e2e 0a23 0a23 ter version..#.#\n+0001a250: 2054 6869 7320 7072 6f67 7261 6d20 6973 This program is\n+0001a260: 2064 6973 7472 6962 7574 6564 2069 6e20 distributed in \n+0001a270: 7468 6520 686f 7065 2074 6861 7420 6974 the hope that it\n+0001a280: 2077 696c 6c20 6265 2075 7365 6675 6c2c will be useful,\n+0001a290: 0a23 2062 7574 2057 4954 484f 5554 2041 .# but WITHOUT A\n+0001a2a0: 4e59 2057 4152 5241 4e54 593b 2077 6974 NY WARRANTY; wit\n+0001a2b0: 686f 7574 2065 7665 6e20 7468 6520 696d hout even the im\n+0001a2c0: 706c 6965 6420 7761 7272 616e 7479 206f plied warranty o\n+0001a2d0: 660a 2320 4d45 5243 4841 4e54 4142 494c f.# MERCHANTABIL\n+0001a2e0: 4954 5920 6f72 2046 4954 4e45 5353 2046 ITY or FITNESS F\n+0001a2f0: 4f52 2041 2050 4152 5449 4355 4c41 5220 OR A PARTICULAR \n+0001a300: 5055 5250 4f53 452e 2020 5365 6520 7468 PURPOSE. See th\n+0001a310: 650a 2320 474e 5520 4765 6e65 7261 6c20 e.# GNU General \n+0001a320: 5075 626c 6963 204c 6963 656e 7365 2066 Public License f\n+0001a330: 6f72 206d 6f72 6520 6465 7461 696c 732e or more details.\n+0001a340: 0a23 0a23 2059 6f75 2073 686f 756c 6420 .#.# You should \n+0001a350: 6861 7665 2072 6563 6569 7665 6420 6120 have received a \n+0001a360: 636f 7079 206f 6620 7468 6520 474e 5520 copy of the GNU \n+0001a370: 4765 6e65 7261 6c20 5075 626c 6963 204c General Public L\n+0001a380: 6963 656e 7365 0a23 2061 6c6f 6e67 2077 icense.# along w\n+0001a390: 6974 6820 7468 6973 2070 726f 6772 616d ith this program\n+0001a3a0: 2e20 2049 6620 6e6f 742c 2073 6565 203c . If not, see <\n+0001a3b0: 6874 7470 733a 2f2f 7777 772e 676e 752e https://www.gnu.\n+0001a3c0: 6f72 672f 6c69 6365 6e73 6573 2f3e 2e0a org/licenses/>..\n+0001a3d0: 0a66 726f 6d20 656e 756d 2069 6d70 6f72 .from enum impor\n+0001a3e0: 7420 456e 756d 0a66 726f 6d20 7479 7069 t Enum.from typi\n+0001a3f0: 6e67 2069 6d70 6f72 7420 4361 6c6c 6162 ng import Callab\n+0001a400: 6c65 2c20 436f 6e74 6169 6e65 722c 2044 le, Container, D\n+0001a410: 6963 742c 204c 6973 742c 204d 6170 7069 ict, List, Mappi\n+0001a420: 6e67 2c20 4f70 7469 6f6e 616c 2c20 5365 ng, Optional, Se\n+0001a430: 7175 656e 6365 2c20 5479 7065 2c20 5479 quence, Type, Ty\n+0001a440: 7065 5661 722c 2055 6e69 6f6e 0a0a 4a73 peVar, Union..Js\n+0001a450: 6f6e 4c69 7465 7261 6c20 3d20 556e 696f onLiteral = Unio\n+0001a460: 6e5b 7374 722c 2066 6c6f 6174 2c20 626f n[str, float, bo\n+0001a470: 6f6c 2c20 4e6f 6e65 5d0a 0a23 2069 6d6d ol, None]..# imm\n+0001a480: 7574 6162 6c65 0a4a 736f 6e56 616c 7565 utable.JsonValue\n+0001a490: 203d 2055 6e69 6f6e 5b27 4a73 6f6e 4f62 = Union['JsonOb\n+0001a4a0: 6a65 6374 272c 2053 6571 7565 6e63 655b ject', Sequence[\n+0001a4b0: 274a 736f 6e56 616c 7565 275d 2c20 4a73 'JsonValue'], Js\n+0001a4c0: 6f6e 4c69 7465 7261 6c5d 0a4a 736f 6e4f onLiteral].JsonO\n+0001a4d0: 626a 6563 7420 3d20 4d61 7070 696e 675b bject = Mapping[\n+0001a4e0: 7374 722c 204a 736f 6e56 616c 7565 5d0a str, JsonValue].\n+0001a4f0: 0a23 206d 7574 6162 6c65 0a4a 736f 6e44 .# mutable.JsonD\n+0001a500: 6f63 756d 656e 7420 3d20 556e 696f 6e5b ocument = Union[\n+0001a510: 274a 736f 6e44 6963 7427 2c20 274a 736f 'JsonDict', 'Jso\n+0001a520: 6e4c 6973 7427 2c20 4a73 6f6e 4c69 7465 nList', JsonLite\n+0001a530: 7261 6c5d 0a4a 736f 6e44 6963 7420 3d20 ral].JsonDict = \n+0001a540: 4469 6374 5b73 7472 2c20 4a73 6f6e 446f Dict[str, JsonDo\n+0001a550: 6375 6d65 6e74 5d0a 4a73 6f6e 4c69 7374 cument].JsonList\n+0001a560: 203d 204c 6973 745b 4a73 6f6e 446f 6375 = List[JsonDocu\n+0001a570: 6d65 6e74 5d0a 0a0a 4454 203d 2054 7970 ment]...DT = Typ\n+0001a580: 6556 6172 2827 4454 2729 0a54 203d 2054 eVar('DT').T = T\n+0001a590: 7970 6556 6172 2827 5427 290a 0a0a 636c ypeVar('T')...cl\n+0001a5a0: 6173 7320 4a73 6f6e 4572 726f 7228 4578 ass JsonError(Ex\n+0001a5b0: 6365 7074 696f 6e29 3a0a 2020 2020 7661 ception):. va\n+0001a5c0: 6c75 653a 206f 626a 6563 740a 0a20 2020 lue: object.. \n+0001a5d0: 2064 6566 205f 5f69 6e69 745f 5f28 7365 def __init__(se\n+0001a5e0: 6c66 2c20 7661 6c75 653a 206f 626a 6563 lf, value: objec\n+0001a5f0: 742c 206d 7367 3a20 7374 7229 3a0a 2020 t, msg: str):. \n+0001a600: 2020 2020 2020 7375 7065 7228 292e 5f5f super().__\n+0001a610: 696e 6974 5f5f 286d 7367 290a 2020 2020 init__(msg). \n+0001a620: 2020 2020 7365 6c66 2e76 616c 7565 203d self.value =\n+0001a630: 2076 616c 7565 0a0a 0a64 6566 2074 7970 value...def typ\n+0001a640: 6563 6865 636b 6564 2876 616c 7565 3a20 echecked(value: \n+0001a650: 4a73 6f6e 5661 6c75 652c 2065 7870 6563 JsonValue, expec\n+0001a660: 7465 645f 7479 7065 3a20 5479 7065 5b54 ted_type: Type[T\n+0001a670: 5d29 202d 3e20 543a 0a20 2020 2022 2222 ]) -> T:. \"\"\"\n+0001a680: 456e 7375 7265 2061 204a 534f 4e20 7661 Ensure a JSON va\n+0001a690: 6c75 6520 6861 7320 7468 6520 6578 7065 lue has the expe\n+0001a6a0: 6374 6564 2074 7970 652c 2072 6574 7572 cted type, retur\n+0001a6b0: 6e69 6e67 2069 7420 6966 2073 6f2e 2222 ning it if so.\"\"\n+0001a6c0: 220a 2020 2020 6966 206e 6f74 2069 7369 \". if not isi\n+0001a6d0: 6e73 7461 6e63 6528 7661 6c75 652c 2065 nstance(value, e\n+0001a6e0: 7870 6563 7465 645f 7479 7065 293a 0a20 xpected_type):. \n+0001a6f0: 2020 2020 2020 2072 6169 7365 204a 736f raise Jso\n+0001a700: 6e45 7272 6f72 2876 616c 7565 2c20 6627 nError(value, f'\n+0001a710: 6d75 7374 2068 6176 6520 7479 7065 207b must have type {\n+0001a720: 6578 7065 6374 6564 5f74 7970 652e 5f5f expected_type.__\n+0001a730: 6e61 6d65 5f5f 7d27 290a 2020 2020 7265 name__}'). re\n+0001a740: 7475 726e 2076 616c 7565 0a0a 0a23 2057 turn value...# W\n+0001a750: 6520 6361 6e27 7420 7573 6520 4e6f 6e65 e can't use None\n+0001a760: 2061 7320 6120 7365 6e74 696e 656c 2062 as a sentinel b\n+0001a770: 6563 6175 7365 2069 7427 7320 6f66 7465 ecause it's ofte\n+0001a780: 6e20 7468 6520 6163 7475 616c 2064 6566 n the actual def\n+0001a790: 6175 6c74 2076 616c 7565 0a23 2045 6c6c ault value.# Ell\n+0001a7a0: 6970 7369 7354 7970 6520 6973 2064 6966 ipsisType is dif\n+0001a7b0: 6669 6375 6c74 2062 6563 6175 7365 2069 ficult because i\n+0001a7c0: 7427 7320 6e6f 7420 6176 6169 6c61 626c t's not availabl\n+0001a7d0: 6520 6265 666f 7265 2033 2e31 302e 0a23 e before 3.10..#\n+0001a7e0: 2053 6565 2068 7474 7073 3a2f 2f70 6570 See https://pep\n+0001a7f0: 732e 7079 7468 6f6e 2e6f 7267 2f70 6570 s.python.org/pep\n+0001a800: 2d30 3438 342f 2373 7570 706f 7274 2d66 -0484/#support-f\n+0001a810: 6f72 2d73 696e 676c 6574 6f6e 2d74 7970 or-singleton-typ\n+0001a820: 6573 2d69 6e2d 756e 696f 6e73 0a63 6c61 es-in-unions.cla\n+0001a830: 7373 205f 456d 7074 7928 456e 756d 293a ss _Empty(Enum):\n+0001a840: 0a20 2020 2054 4f4b 454e 203d 2030 0a0a . TOKEN = 0..\n+0001a850: 0a5f 656d 7074 7920 3d20 5f45 6d70 7479 ._empty = _Empty\n+0001a860: 2e54 4f4b 454e 0a0a 0a64 6566 205f 6765 .TOKEN...def _ge\n+0001a870: 7428 6f62 6a3a 204a 736f 6e4f 626a 6563 t(obj: JsonObjec\n+0001a880: 742c 2063 6173 743a 2043 616c 6c61 626c t, cast: Callabl\n+0001a890: 655b 5b4a 736f 6e56 616c 7565 5d2c 2054 e[[JsonValue], T\n+0001a8a0: 5d2c 206b 6579 3a20 7374 722c 2064 6566 ], key: str, def\n+0001a8b0: 6175 6c74 3a20 556e 696f 6e5b 4454 2c20 ault: Union[DT, \n+0001a8c0: 5f45 6d70 7479 5d29 202d 3e20 556e 696f _Empty]) -> Unio\n+0001a8d0: 6e5b 542c 2044 545d 3a0a 2020 2020 7472 n[T, DT]:. tr\n+0001a8e0: 793a 0a20 2020 2020 2020 2072 6574 7572 y:. retur\n+0001a8f0: 6e20 6361 7374 286f 626a 5b6b 6579 5d29 n cast(obj[key])\n+0001a900: 0a20 2020 2065 7863 6570 7420 4b65 7945 . except KeyE\n+0001a910: 7272 6f72 3a0a 2020 2020 2020 2020 6966 rror:. if\n+0001a920: 2064 6566 6175 6c74 2069 7320 6e6f 7420 default is not \n+0001a930: 5f65 6d70 7479 3a0a 2020 2020 2020 2020 _empty:. \n+0001a940: 2020 2020 7265 7475 726e 2064 6566 6175 return defau\n+0001a950: 6c74 0a20 2020 2020 2020 2072 6169 7365 lt. raise\n+0001a960: 204a 736f 6e45 7272 6f72 286f 626a 2c20 JsonError(obj, \n+0001a970: 6622 6174 7472 6962 7574 6520 277b 6b65 f\"attribute '{ke\n+0001a980: 797d 2720 7265 7175 6972 6564 2229 2066 y}' required\") f\n+0001a990: 726f 6d20 4e6f 6e65 0a20 2020 2065 7863 rom None. exc\n+0001a9a0: 6570 7420 4a73 6f6e 4572 726f 7220 6173 ept JsonError as\n+0001a9b0: 2065 7863 3a0a 2020 2020 2020 2020 7461 exc:. ta\n+0001a9c0: 7267 6574 203d 2066 2261 7474 7269 6275 rget = f\"attribu\n+0001a9d0: 7465 2027 7b6b 6579 7d27 2220 2b20 2827 te '{key}'\" + ('\n+0001a9e0: 2065 6c65 6d65 6e74 733a 2720 6966 2065 elements:' if e\n+0001a9f0: 7863 2e76 616c 7565 2069 7320 6e6f 7420 xc.value is not \n+0001aa00: 6f62 6a5b 6b65 795d 2065 6c73 6520 273a obj[key] else ':\n+0001aa10: 2729 0a20 2020 2020 2020 2072 6169 7365 '). raise\n+0001aa20: 204a 736f 6e45 7272 6f72 286f 626a 2c20 JsonError(obj, \n+0001aa30: 6622 7b74 6172 6765 747d 207b 6578 6321 f\"{target} {exc!\n+0001aa40: 737d 2229 2066 726f 6d20 6578 630a 0a0a s}\") from exc...\n+0001aa50: 6465 6620 6765 745f 626f 6f6c 286f 626a def get_bool(obj\n+0001aa60: 3a20 4a73 6f6e 4f62 6a65 6374 2c20 6b65 : JsonObject, ke\n+0001aa70: 793a 2073 7472 2c20 6465 6661 756c 743a y: str, default:\n+0001aa80: 2055 6e69 6f6e 5b44 542c 205f 456d 7074 Union[DT, _Empt\n+0001aa90: 795d 203d 205f 656d 7074 7929 202d 3e20 y] = _empty) -> \n+0001aaa0: 556e 696f 6e5b 4454 2c20 626f 6f6c 5d3a Union[DT, bool]:\n+0001aab0: 0a20 2020 2072 6574 7572 6e20 5f67 6574 . return _get\n+0001aac0: 286f 626a 2c20 6c61 6d62 6461 2076 3a20 (obj, lambda v: \n+0001aad0: 7479 7065 6368 6563 6b65 6428 762c 2062 typechecked(v, b\n+0001aae0: 6f6f 6c29 2c20 6b65 792c 2064 6566 6175 ool), key, defau\n+0001aaf0: 6c74 290a 0a0a 6465 6620 6765 745f 696e lt)...def get_in\n+0001ab00: 7428 6f62 6a3a 204a 736f 6e4f 626a 6563 t(obj: JsonObjec\n+0001ab10: 742c 206b 6579 3a20 7374 722c 2064 6566 t, key: str, def\n+0001ab20: 6175 6c74 3a20 556e 696f 6e5b 4454 2c20 ault: Union[DT, \n+0001ab30: 5f45 6d70 7479 5d20 3d20 5f65 6d70 7479 _Empty] = _empty\n+0001ab40: 2920 2d3e 2055 6e69 6f6e 5b44 542c 2069 ) -> Union[DT, i\n+0001ab50: 6e74 5d3a 0a20 2020 2072 6574 7572 6e20 nt]:. return \n+0001ab60: 5f67 6574 286f 626a 2c20 6c61 6d62 6461 _get(obj, lambda\n+0001ab70: 2076 3a20 7479 7065 6368 6563 6b65 6428 v: typechecked(\n+0001ab80: 762c 2069 6e74 292c 206b 6579 2c20 6465 v, int), key, de\n+0001ab90: 6661 756c 7429 0a0a 0a64 6566 2067 6574 fault)...def get\n+0001aba0: 5f73 7472 286f 626a 3a20 4a73 6f6e 4f62 _str(obj: JsonOb\n+0001abb0: 6a65 6374 2c20 6b65 793a 2073 7472 2c20 ject, key: str, \n+0001abc0: 6465 6661 756c 743a 2055 6e69 6f6e 5b44 default: Union[D\n+0001abd0: 542c 205f 456d 7074 795d 203d 205f 656d T, _Empty] = _em\n+0001abe0: 7074 7929 202d 3e20 556e 696f 6e5b 4454 pty) -> Union[DT\n+0001abf0: 2c20 7374 725d 3a0a 2020 2020 7265 7475 , str]:. retu\n+0001ac00: 726e 205f 6765 7428 6f62 6a2c 206c 616d rn _get(obj, lam\n+0001ac10: 6264 6120 763a 2074 7970 6563 6865 636b bda v: typecheck\n+0001ac20: 6564 2876 2c20 7374 7229 2c20 6b65 792c ed(v, str), key,\n+0001ac30: 2064 6566 6175 6c74 290a 0a0a 6465 6620 default)...def \n+0001ac40: 6765 745f 7374 725f 6f72 5f6e 6f6e 6528 get_str_or_none(\n+0001ac50: 6f62 6a3a 204a 736f 6e4f 626a 6563 742c obj: JsonObject,\n+0001ac60: 206b 6579 3a20 7374 722c 2064 6566 6175 key: str, defau\n+0001ac70: 6c74 3a20 4f70 7469 6f6e 616c 5b73 7472 lt: Optional[str\n+0001ac80: 5d29 202d 3e20 4f70 7469 6f6e 616c 5b73 ]) -> Optional[s\n+0001ac90: 7472 5d3a 0a20 2020 2072 6574 7572 6e20 tr]:. return \n+0001aca0: 5f67 6574 286f 626a 2c20 6c61 6d62 6461 _get(obj, lambda\n+0001acb0: 2076 3a20 4e6f 6e65 2069 6620 7620 6973 v: None if v is\n+0001acc0: 204e 6f6e 6520 656c 7365 2074 7970 6563 None else typec\n+0001acd0: 6865 636b 6564 2876 2c20 7374 7229 2c20 hecked(v, str), \n+0001ace0: 6b65 792c 2064 6566 6175 6c74 290a 0a0a key, default)...\n+0001acf0: 6465 6620 6765 745f 6469 6374 286f 626a def get_dict(obj\n+0001ad00: 3a20 4a73 6f6e 4f62 6a65 6374 2c20 6b65 : JsonObject, ke\n+0001ad10: 793a 2073 7472 2c20 6465 6661 756c 743a y: str, default:\n+0001ad20: 2055 6e69 6f6e 5b44 542c 205f 456d 7074 Union[DT, _Empt\n+0001ad30: 795d 203d 205f 656d 7074 7929 202d 3e20 y] = _empty) -> \n+0001ad40: 556e 696f 6e5b 4454 2c20 4a73 6f6e 4f62 Union[DT, JsonOb\n+0001ad50: 6a65 6374 5d3a 0a20 2020 2072 6574 7572 ject]:. retur\n+0001ad60: 6e20 5f67 6574 286f 626a 2c20 6c61 6d62 n _get(obj, lamb\n+0001ad70: 6461 2076 3a20 7479 7065 6368 6563 6b65 da v: typechecke\n+0001ad80: 6428 762c 2064 6963 7429 2c20 6b65 792c d(v, dict), key,\n+0001ad90: 2064 6566 6175 6c74 290a 0a0a 6465 6620 default)...def \n+0001ada0: 6765 745f 6f62 6a65 6374 280a 2020 2020 get_object(. \n+0001adb0: 6f62 6a3a 204a 736f 6e4f 626a 6563 742c obj: JsonObject,\n+0001adc0: 0a20 2020 206b 6579 3a20 7374 722c 0a20 . key: str,. \n+0001add0: 2020 2063 6f6e 7374 7275 6374 6f72 3a20 constructor: \n+0001ade0: 4361 6c6c 6162 6c65 5b5b 4a73 6f6e 4f62 Callable[[JsonOb\n+0001adf0: 6a65 6374 5d2c 2054 5d2c 0a20 2020 2064 ject], T],. d\n+0001ae00: 6566 6175 6c74 3a20 556e 696f 6e5b 4454 efault: Union[DT\n+0001ae10: 2c20 5f45 6d70 7479 5d20 3d20 5f65 6d70 , _Empty] = _emp\n+0001ae20: 7479 0a29 202d 3e20 556e 696f 6e5b 4454 ty.) -> Union[DT\n+0001ae30: 2c20 545d 3a0a 2020 2020 7265 7475 726e , T]:. return\n+0001ae40: 205f 6765 7428 6f62 6a2c 206c 616d 6264 _get(obj, lambd\n+0001ae50: 6120 763a 2063 6f6e 7374 7275 6374 6f72 a v: constructor\n+0001ae60: 2874 7970 6563 6865 636b 6564 2876 2c20 (typechecked(v, \n+0001ae70: 6469 6374 2929 2c20 6b65 792c 2064 6566 dict)), key, def\n+0001ae80: 6175 6c74 290a 0a0a 6465 6620 6765 745f ault)...def get_\n+0001ae90: 7374 7276 286f 626a 3a20 4a73 6f6e 4f62 strv(obj: JsonOb\n+0001aea0: 6a65 6374 2c20 6b65 793a 2073 7472 2c20 ject, key: str, \n+0001aeb0: 6465 6661 756c 743a 2055 6e69 6f6e 5b44 default: Union[D\n+0001aec0: 542c 205f 456d 7074 795d 203d 205f 656d T, _Empty] = _em\n+0001aed0: 7074 7929 202d 3e20 556e 696f 6e5b 4454 pty) -> Union[DT\n+0001aee0: 2c20 5365 7175 656e 6365 5b73 7472 5d5d , Sequence[str]]\n+0001aef0: 3a0a 2020 2020 6465 6620 6173 5f73 7472 :. def as_str\n+0001af00: 7628 7661 6c75 653a 204a 736f 6e56 616c v(value: JsonVal\n+0001af10: 7565 2920 2d3e 2053 6571 7565 6e63 655b ue) -> Sequence[\n+0001af20: 7374 725d 3a0a 2020 2020 2020 2020 7265 str]:. re\n+0001af30: 7475 726e 2074 7570 6c65 2874 7970 6563 turn tuple(typec\n+0001af40: 6865 636b 6564 2869 7465 6d2c 2073 7472 hecked(item, str\n+0001af50: 2920 666f 7220 6974 656d 2069 6e20 7479 ) for item in ty\n+0001af60: 7065 6368 6563 6b65 6428 7661 6c75 652c pechecked(value,\n+0001af70: 206c 6973 7429 290a 2020 2020 7265 7475 list)). retu\n+0001af80: 726e 205f 6765 7428 6f62 6a2c 2061 735f rn _get(obj, as_\n+0001af90: 7374 7276 2c20 6b65 792c 2064 6566 6175 strv, key, defau\n+0001afa0: 6c74 290a 0a0a 6465 6620 6765 745f 656e lt)...def get_en\n+0001afb0: 756d 280a 2020 2020 6f62 6a3a 204a 736f um(. obj: Jso\n+0001afc0: 6e4f 626a 6563 742c 206b 6579 3a20 7374 nObject, key: st\n+0001afd0: 722c 2063 686f 6963 6573 3a20 436f 6e74 r, choices: Cont\n+0001afe0: 6169 6e65 725b 7374 725d 2c20 6465 6661 ainer[str], defa\n+0001aff0: 756c 743a 2055 6e69 6f6e 5b44 542c 205f ult: Union[DT, _\n+0001b000: 456d 7074 795d 203d 205f 656d 7074 790a Empty] = _empty.\n+0001b010: 2920 2d3e 2055 6e69 6f6e 5b44 542c 2073 ) -> Union[DT, s\n+0001b020: 7472 5d3a 0a20 2020 2064 6566 2061 735f tr]:. def as_\n+0001b030: 6368 6f69 6365 2876 616c 7565 3a20 4a73 choice(value: Js\n+0001b040: 6f6e 5661 6c75 6529 202d 3e20 7374 723a onValue) -> str:\n+0001b050: 0a20 2020 2020 2020 2023 206d 7970 7920 . # mypy \n+0001b060: 6361 6e27 7420 646f 2060 5f5f 6571 5f5f can't do `__eq__\n+0001b070: 2829 602d 6261 7365 6420 7479 7065 206e ()`-based type n\n+0001b080: 6172 726f 7769 6e67 2e2e 2e0a 2020 2020 arrowing.... \n+0001b090: 2020 2020 2320 6874 7470 733a 2f2f 6769 # https://gi\n+0001b0a0: 7468 7562 2e63 6f6d 2f70 7974 686f 6e2f thub.com/python/\n+0001b0b0: 6d79 7079 2f69 7373 7565 732f 3137 3130 mypy/issues/1710\n+0001b0c0: 310a 2020 2020 2020 2020 6966 2069 7369 1. if isi\n+0001b0d0: 6e73 7461 6e63 6528 7661 6c75 652c 2073 nstance(value, s\n+0001b0e0: 7472 2920 616e 6420 7661 6c75 6520 696e tr) and value in\n+0001b0f0: 2063 686f 6963 6573 3a0a 2020 2020 2020 choices:. \n+0001b100: 2020 2020 2020 7265 7475 726e 2076 616c return val\n+0001b110: 7565 0a20 2020 2020 2020 2072 6169 7365 ue. raise\n+0001b120: 204a 736f 6e45 7272 6f72 2876 616c 7565 JsonError(value\n+0001b130: 2c20 6627 696e 7661 6c69 6420 7661 6c75 , f'invalid valu\n+0001b140: 6520 227b 7661 6c75 657d 2220 6e6f 7420 e \"{value}\" not \n+0001b150: 696e 207b 6368 6f69 6365 737d 2729 0a20 in {choices}'). \n+0001b160: 2020 2072 6574 7572 6e20 5f67 6574 286f return _get(o\n+0001b170: 626a 2c20 6173 5f63 686f 6963 652c 206b bj, as_choice, k\n+0001b180: 6579 2c20 6465 6661 756c 7429 0a0a 0a64 ey, default)...d\n+0001b190: 6566 2067 6574 5f6f 626a 7628 6f62 6a3a ef get_objv(obj:\n+0001b1a0: 204a 736f 6e4f 626a 6563 742c 206b 6579 JsonObject, key\n+0001b1b0: 3a20 7374 722c 2063 6f6e 7374 7275 6374 : str, construct\n+0001b1c0: 6f72 3a20 4361 6c6c 6162 6c65 5b5b 4a73 or: Callable[[Js\n+0001b1d0: 6f6e 4f62 6a65 6374 5d2c 2054 5d29 202d onObject], T]) -\n+0001b1e0: 3e20 556e 696f 6e5b 4454 2c20 5365 7175 > Union[DT, Sequ\n+0001b1f0: 656e 6365 5b54 5d5d 3a0a 2020 2020 6465 ence[T]]:. de\n+0001b200: 6620 6173 5f6f 626a 7628 7661 6c75 653a f as_objv(value:\n+0001b210: 204a 736f 6e56 616c 7565 2920 2d3e 2053 JsonValue) -> S\n+0001b220: 6571 7565 6e63 655b 545d 3a0a 2020 2020 equence[T]:. \n+0001b230: 2020 2020 7265 7475 726e 2074 7570 6c65 return tuple\n+0001b240: 2863 6f6e 7374 7275 6374 6f72 2874 7970 (constructor(typ\n+0001b250: 6563 6865 636b 6564 2869 7465 6d2c 2064 echecked(item, d\n+0001b260: 6963 7429 2920 666f 7220 6974 656d 2069 ict)) for item i\n+0001b270: 6e20 7479 7065 6368 6563 6b65 6428 7661 n typechecked(va\n+0001b280: 6c75 652c 206c 6973 7429 290a 2020 2020 lue, list)). \n+0001b290: 7265 7475 726e 205f 6765 7428 6f62 6a2c return _get(obj,\n+0001b2a0: 2061 735f 6f62 6a76 2c20 6b65 792c 2028 as_objv, key, (\n+0001b2b0: 2929 0a0a 0a64 6566 2063 7265 6174 655f ))...def create_\n+0001b2c0: 6f62 6a65 6374 286d 6573 7361 6765 3a20 object(message: \n+0001b2d0: 274a 736f 6e4f 626a 6563 7420 7c20 4e6f 'JsonObject | No\n+0001b2e0: 6e65 272c 206b 7761 7267 733a 204a 736f ne', kwargs: Jso\n+0001b2f0: 6e4f 626a 6563 7429 202d 3e20 4a73 6f6e nObject) -> Json\n+0001b300: 4f62 6a65 6374 3a0a 2020 2020 2222 2243 Object:. \"\"\"C\n+0001b310: 6f6e 7374 7275 6374 7320 6120 4a53 4f4e onstructs a JSON\n+0001b320: 206f 626a 6563 7420 6261 7365 6420 6f6e object based on\n+0001b330: 206d 6573 7361 6765 2061 6e64 206b 7761 message and kwa\n+0001b340: 7267 732e 0a0a 2020 2020 4966 206f 6e6c rgs... If onl\n+0001b350: 7920 6d65 7373 6167 6520 6973 2067 6976 y message is giv\n+0001b360: 656e 2c20 6974 2069 7320 7265 7475 726e en, it is return\n+0001b370: 6564 2c20 756e 6d6f 6469 6669 6564 2e20 ed, unmodified. \n+0001b380: 2049 6620 6d65 7373 6167 6520 6973 204e If message is N\n+0001b390: 6f6e 652c 0a20 2020 2069 7420 6973 2065 one,. it is e\n+0001b3a0: 7175 6976 616c 656e 7420 746f 2061 6e20 quivalent to an \n+0001b3b0: 656d 7074 7920 6469 6374 696f 6e61 7279 empty dictionary\n+0001b3c0: 2e20 2041 2063 6f70 7920 6973 2061 6c77 . A copy is alw\n+0001b3d0: 6179 7320 6d61 6465 2e0a 0a20 2020 2049 ays made... I\n+0001b3e0: 6620 6b77 6172 6773 2061 7265 2070 7265 f kwargs are pre\n+0001b3f0: 7365 6e74 2c20 7468 656e 2061 6e79 2075 sent, then any u\n+0001b400: 6e64 6572 7363 6f72 6520 2827 5f27 2920 nderscore ('_') \n+0001b410: 7072 6573 656e 7420 696e 2061 206b 6579 present in a key\n+0001b420: 206e 616d 6520 6973 0a20 2020 2072 6577 name is. rew\n+0001b430: 7269 7474 656e 2074 6f20 6120 6461 7368 ritten to a dash\n+0001b440: 2028 272d 2729 2e20 2054 6869 7320 6973 ('-'). This is\n+0001b450: 2069 6e74 656e 6465 6420 746f 2062 7269 intended to bri\n+0001b460: 6467 6520 6265 7477 6565 6e20 7468 6520 dge between the \n+0001b470: 7265 7175 6972 6564 0a20 2020 2050 7974 required. Pyt\n+0001b480: 686f 6e20 7379 6e74 6178 2077 6865 6e20 hon syntax when \n+0001b490: 7072 6f76 6964 696e 6720 6b77 6172 6773 providing kwargs\n+0001b4a0: 2061 6e64 2069 6469 6f6d 6174 6963 204a and idiomatic J\n+0001b4b0: 534f 4e20 2877 6869 6368 2075 7365 7320 SON (which uses \n+0001b4c0: 272d 2720 666f 720a 2020 2020 6174 7472 '-' for. attr\n+0001b4d0: 6962 7574 6573 292e 2020 5468 6573 6520 ibutes). These \n+0001b4e0: 7661 6c75 6573 206f 7665 7272 6964 6520 values override \n+0001b4f0: 7661 6c75 6573 2069 6e20 6d65 7373 6167 values in messag\n+0001b500: 652e 0a0a 2020 2020 5468 6520 6964 6561 e... The idea\n+0001b510: 2069 7320 7468 6174 2060 6d65 7373 6167 is that `messag\n+0001b520: 6560 2073 686f 756c 6420 6265 2075 7365 e` should be use\n+0001b530: 6420 666f 7220 7061 7373 696e 6720 6461 d for passing da\n+0001b540: 7461 2061 6c6f 6e67 2c20 616e 640a 2020 ta along, and. \n+0001b550: 2020 6b77 6172 6773 2075 7365 6420 666f kwargs used fo\n+0001b560: 7220 6461 7461 206f 7269 6769 6e61 7469 r data originati\n+0001b570: 6e67 2061 7420 6120 6769 7665 6e20 6361 ng at a given ca\n+0001b580: 6c6c 2073 6974 652c 2070 6f73 7369 626c ll site, possibl\n+0001b590: 7920 696e 636c 7564 696e 670a 2020 2020 y including. \n+0001b5a0: 6d6f 6469 6669 6361 7469 6f6e 7320 746f modifications to\n+0001b5b0: 2061 6e20 6f72 6967 696e 616c 206d 6573 an original mes\n+0001b5c0: 7361 6765 2e0a 2020 2020 2222 220a 2020 sage.. \"\"\". \n+0001b5d0: 2020 7265 7375 6c74 203d 2064 6963 7428 result = dict(\n+0001b5e0: 6d65 7373 6167 6520 6f72 207b 7d29 0a0a message or {})..\n+0001b5f0: 2020 2020 666f 7220 6b65 792c 2076 616c for key, val\n+0001b600: 7565 2069 6e20 6b77 6172 6773 2e69 7465 ue in kwargs.ite\n+0001b610: 6d73 2829 3a0a 2020 2020 2020 2020 2320 ms():. # \n+0001b620: 7265 7772 6974 6520 275f 2720 286e 6563 rewrite '_' (nec\n+0001b630: 6573 7361 7279 2069 6e20 5079 7468 6f6e essary in Python\n+0001b640: 2073 796e 7461 7820 6b77 6172 6773 206c syntax kwargs l\n+0001b650: 6973 7429 2074 6f20 272d 2720 2869 6469 ist) to '-' (idi\n+0001b660: 6f6d 6174 6963 204a 534f 4e29 0a20 2020 omatic JSON). \n+0001b670: 2020 2020 206a 736f 6e5f 6b65 7920 3d20 json_key = \n+0001b680: 6b65 792e 7265 706c 6163 6528 275f 272c key.replace('_',\n+0001b690: 2027 2d27 290a 2020 2020 2020 2020 7265 '-'). re\n+0001b6a0: 7375 6c74 5b6a 736f 6e5f 6b65 795d 203d sult[json_key] =\n+0001b6b0: 2076 616c 7565 0a0a 2020 2020 7265 7475 value.. retu\n+0001b6c0: 726e 2072 6573 756c 740a 0a0a 6465 6620 rn result...def \n+0001b6d0: 6a73 6f6e 5f6d 6572 6765 5f70 6174 6368 json_merge_patch\n+0001b6e0: 2863 7572 7265 6e74 3a20 4a73 6f6e 4f62 (current: JsonOb\n+0001b6f0: 6a65 6374 2c20 7061 7463 683a 204a 736f ject, patch: Jso\n+0001b700: 6e4f 626a 6563 7429 202d 3e20 4a73 6f6e nObject) -> Json\n+0001b710: 4f62 6a65 6374 3a0a 2020 2020 2222 2250 Object:. \"\"\"P\n+0001b720: 6572 666f 726d 2061 204a 534f 4e20 6d65 erform a JSON me\n+0001b730: 7267 6520 7061 7463 6820 2852 4643 2037 rge patch (RFC 7\n+0001b740: 3339 3629 2075 7369 6e67 2027 6375 7272 396) using 'curr\n+0001b750: 656e 7427 2061 6e64 2027 7061 7463 6827 ent' and 'patch'\n+0001b760: 2e0a 2020 2020 4e65 6974 6865 7220 6f66 .. Neither of\n+0001b770: 2074 6865 206f 7269 6769 6e61 6c20 6469 the original di\n+0001b780: 6374 696f 6e61 7269 6573 2069 7320 6d6f ctionaries is mo\n+0001b790: 6469 6669 6564 20e2 8094 2074 6865 2072 dified ... the r\n+0001b7a0: 6573 756c 7420 6973 2072 6574 7572 6e65 esult is returne\n+0001b7b0: 642e 0a20 2020 2022 2222 0a20 2020 2023 d.. \"\"\". #\n+0001b7c0: 2041 6c77 6179 7320 7461 6b65 2061 2063 Always take a c\n+0001b7d0: 6f70 7920 2827 7265 7375 6c74 2729 20e2 opy ('result') .\n+0001b7e0: 8094 2077 6520 6e65 7665 7220 6d6f 6469 .. we never modi\n+0001b7f0: 6679 2074 6865 2069 6e70 7574 2028 2763 fy the input ('c\n+0001b800: 7572 7265 6e74 2729 0a20 2020 2072 6573 urrent'). res\n+0001b810: 756c 7420 3d20 6469 6374 2863 7572 7265 ult = dict(curre\n+0001b820: 6e74 290a 2020 2020 666f 7220 6b65 792c nt). for key,\n+0001b830: 2070 6174 6368 5f76 616c 7565 2069 6e20 patch_value in \n+0001b840: 7061 7463 682e 6974 656d 7328 293a 0a20 patch.items():. \n+0001b850: 2020 2020 2020 2069 6620 6973 696e 7374 if isinst\n+0001b860: 616e 6365 2870 6174 6368 5f76 616c 7565 ance(patch_value\n+0001b870: 2c20 4d61 7070 696e 6729 3a0a 2020 2020 , Mapping):. \n+0001b880: 2020 2020 2020 2020 6375 7272 656e 745f current_\n+0001b890: 7661 6c75 6520 3d20 6375 7272 656e 742e value = current.\n+0001b8a0: 6765 7428 6b65 792c 204e 6f6e 6529 0a20 get(key, None). \n+0001b8b0: 2020 2020 2020 2020 2020 2069 6620 6e6f if no\n+0001b8c0: 7420 6973 696e 7374 616e 6365 2863 7572 t isinstance(cur\n+0001b8d0: 7265 6e74 5f76 616c 7565 2c20 4d61 7070 rent_value, Mapp\n+0001b8e0: 696e 6729 3a0a 2020 2020 2020 2020 2020 ing):. \n+0001b8f0: 2020 2020 2020 6375 7272 656e 745f 7661 current_va\n+0001b900: 6c75 6520 3d20 7b7d 0a20 2020 2020 2020 lue = {}. \n+0001b910: 2020 2020 2072 6573 756c 745b 6b65 795d result[key]\n+0001b920: 203d 206a 736f 6e5f 6d65 7267 655f 7061 = json_merge_pa\n+0001b930: 7463 6828 6375 7272 656e 745f 7661 6c75 tch(current_valu\n+0001b940: 652c 2070 6174 6368 5f76 616c 7565 290a e, patch_value).\n+0001b950: 2020 2020 2020 2020 656c 6966 2070 6174 elif pat\n+0001b960: 6368 5f76 616c 7565 2069 7320 6e6f 7420 ch_value is not \n+0001b970: 4e6f 6e65 3a0a 2020 2020 2020 2020 2020 None:. \n+0001b980: 2020 7265 7375 6c74 5b6b 6579 5d20 3d20 result[key] = \n+0001b990: 7061 7463 685f 7661 6c75 650a 2020 2020 patch_value. \n+0001b9a0: 2020 2020 656c 7365 3a0a 2020 2020 2020 else:. \n+0001b9b0: 2020 2020 2020 7265 7375 6c74 2e70 6f70 result.pop\n+0001b9c0: 286b 6579 2c20 4e6f 6e65 290a 0a20 2020 (key, None).. \n+0001b9d0: 2072 6574 7572 6e20 7265 7375 6c74 0a0a return result..\n+0001b9e0: 0a64 6566 206a 736f 6e5f 6d65 7267 655f .def json_merge_\n+0001b9f0: 616e 645f 6669 6c74 6572 5f70 6174 6368 and_filter_patch\n+0001ba00: 2863 7572 7265 6e74 3a20 4a73 6f6e 4469 (current: JsonDi\n+0001ba10: 6374 2c20 7061 7463 683a 204a 736f 6e44 ct, patch: JsonD\n+0001ba20: 6963 7429 202d 3e20 4e6f 6e65 3a0a 2020 ict) -> None:. \n+0001ba30: 2020 2222 2250 6572 666f 726d 2061 204a \"\"\"Perform a J\n+0001ba40: 534f 4e20 6d65 7267 6520 7061 7463 6820 SON merge patch \n+0001ba50: 2852 4643 2037 3339 3629 206d 6f64 6966 (RFC 7396) modif\n+0001ba60: 7969 6e67 2027 6375 7272 656e 7427 2077 ying 'current' w\n+0001ba70: 6974 6820 2770 6174 6368 272e 0a20 2020 ith 'patch'.. \n+0001ba80: 2041 6c73 6f20 6d6f 6469 6669 6573 2027 Also modifies '\n+0001ba90: 7061 7463 6827 2074 6f20 7265 6d6f 7665 patch' to remove\n+0001baa0: 2072 6564 756e 6461 6e74 206f 7065 7261 redundant opera\n+0001bab0: 7469 6f6e 732e 0a20 2020 2022 2222 0a20 tions.. \"\"\". \n+0001bac0: 2020 2066 6f72 206b 6579 2c20 7061 7463 for key, patc\n+0001bad0: 685f 7661 6c75 6520 696e 2074 7570 6c65 h_value in tuple\n+0001bae0: 2870 6174 6368 2e69 7465 6d73 2829 293a (patch.items()):\n+0001baf0: 0a20 2020 2020 2020 2063 7572 7265 6e74 . current\n+0001bb00: 5f76 616c 7565 203d 2063 7572 7265 6e74 _value = current\n+0001bb10: 2e67 6574 286b 6579 2c20 4e6f 6e65 290a .get(key, None).\n+0001bb20: 0a20 2020 2020 2020 2069 6620 6973 696e . if isin\n+0001bb30: 7374 616e 6365 2870 6174 6368 5f76 616c stance(patch_val\n+0001bb40: 7565 2c20 6469 6374 293a 0a20 2020 2020 ue, dict):. \n+0001bb50: 2020 2020 2020 2069 6620 6e6f 7420 6973 if not is\n+0001bb60: 696e 7374 616e 6365 2863 7572 7265 6e74 instance(current\n+0001bb70: 5f76 616c 7565 2c20 6469 6374 293a 0a20 _value, dict):. \n+0001bb80: 2020 2020 2020 2020 2020 2020 2020 2063 c\n+0001bb90: 7572 7265 6e74 5b6b 6579 5d20 3d20 6375 urrent[key] = cu\n+0001bba0: 7272 656e 745f 7661 6c75 6520 3d20 7b7d rrent_value = {}\n+0001bbb0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+0001bbc0: 206a 736f 6e5f 6d65 7267 655f 616e 645f json_merge_and_\n+0001bbd0: 6669 6c74 6572 5f70 6174 6368 2863 7572 filter_patch(cur\n+0001bbe0: 7265 6e74 5f76 616c 7565 2c20 7061 7463 rent_value, patc\n+0001bbf0: 685f 7661 6c75 6529 0a20 2020 2020 2020 h_value). \n+0001bc00: 2020 2020 2065 6c73 653a 0a20 2020 2020 else:. \n+0001bc10: 2020 2020 2020 2020 2020 206a 736f 6e5f json_\n+0001bc20: 6d65 7267 655f 616e 645f 6669 6c74 6572 merge_and_filter\n+0001bc30: 5f70 6174 6368 2863 7572 7265 6e74 5f76 _patch(current_v\n+0001bc40: 616c 7565 2c20 7061 7463 685f 7661 6c75 alue, patch_valu\n+0001bc50: 6529 0a20 2020 2020 2020 2020 2020 2020 e). \n+0001bc60: 2020 2069 6620 6e6f 7420 7061 7463 685f if not patch_\n+0001bc70: 7661 6c75 653a 0a20 2020 2020 2020 2020 value:. \n+0001bc80: 2020 2020 2020 2020 2020 2064 656c 2070 del p\n+0001bc90: 6174 6368 5b6b 6579 5d0a 2020 2020 2020 atch[key]. \n+0001bca0: 2020 656c 6966 2063 7572 7265 6e74 5f76 elif current_v\n+0001bcb0: 616c 7565 203d 3d20 7061 7463 685f 7661 alue == patch_va\n+0001bcc0: 6c75 653a 0a20 2020 2020 2020 2020 2020 lue:. \n+0001bcd0: 2064 656c 2070 6174 6368 5b6b 6579 5d0a del patch[key].\n+0001bce0: 2020 2020 2020 2020 656c 6966 2070 6174 elif pat\n+0001bcf0: 6368 5f76 616c 7565 2069 7320 6e6f 7420 ch_value is not \n+0001bd00: 4e6f 6e65 3a0a 2020 2020 2020 2020 2020 None:. \n+0001bd10: 2020 6375 7272 656e 745b 6b65 795d 203d current[key] =\n+0001bd20: 2070 6174 6368 5f76 616c 7565 0a20 2020 patch_value. \n+0001bd30: 2020 2020 2065 6c73 653a 0a20 2020 2020 else:. \n+0001bd40: 2020 2020 2020 2064 656c 2063 7572 7265 del curre\n+0001bd50: 6e74 5b6b 6579 5d0a 2727 272e 656e 636f nt[key].'''.enco\n+0001bd60: 6465 2827 7574 662d 3827 292c 0a20 2027 de('utf-8'),. '\n+0001bd70: 636f 636b 7069 742f 6265 6970 6163 6b2e cockpit/beipack.\n+0001bd80: 7079 273a 2062 7227 2727 2320 5468 6973 py': br'''# This\n+0001bd90: 2066 696c 6520 6973 2070 6172 7420 6f66 file is part of\n+0001bda0: 2043 6f63 6b70 6974 2e0a 230a 2320 436f Cockpit..#.# Co\n+0001bdb0: 7079 7269 6768 7420 2843 2920 3230 3233 pyright (C) 2023\n+0001bdc0: 2052 6564 2048 6174 2c20 496e 632e 0a23 Red Hat, Inc..#\n+0001bdd0: 0a23 2054 6869 7320 7072 6f67 7261 6d20 .# This program \n+0001bde0: 6973 2066 7265 6520 736f 6674 7761 7265 is free software\n+0001bdf0: 3a20 796f 7520 6361 6e20 7265 6469 7374 : you can redist\n+0001be00: 7269 6275 7465 2069 7420 616e 642f 6f72 ribute it and/or\n+0001be10: 206d 6f64 6966 790a 2320 6974 2075 6e64 modify.# it und\n+0001be20: 6572 2074 6865 2074 6572 6d73 206f 6620 er the terms of \n+0001be30: 7468 6520 474e 5520 4765 6e65 7261 6c20 the GNU General \n+0001be40: 5075 626c 6963 204c 6963 656e 7365 2061 Public License a\n+0001be50: 7320 7075 626c 6973 6865 6420 6279 0a23 s published by.#\n+0001be60: 2074 6865 2046 7265 6520 536f 6674 7761 the Free Softwa\n+0001be70: 7265 2046 6f75 6e64 6174 696f 6e2c 2065 re Foundation, e\n+0001be80: 6974 6865 7220 7665 7273 696f 6e20 3320 ither version 3 \n+0001be90: 6f66 2074 6865 204c 6963 656e 7365 2c20 of the License, \n+0001bea0: 6f72 0a23 2028 6174 2079 6f75 7220 6f70 or.# (at your op\n+0001beb0: 7469 6f6e 2920 616e 7920 6c61 7465 7220 tion) any later \n+0001bec0: 7665 7273 696f 6e2e 0a23 0a23 2054 6869 version..#.# Thi\n+0001bed0: 7320 7072 6f67 7261 6d20 6973 2064 6973 s program is dis\n+0001bee0: 7472 6962 7574 6564 2069 6e20 7468 6520 tributed in the \n+0001bef0: 686f 7065 2074 6861 7420 6974 2077 696c hope that it wil\n+0001bf00: 6c20 6265 2075 7365 6675 6c2c 0a23 2062 l be useful,.# b\n+0001bf10: 7574 2057 4954 484f 5554 2041 4e59 2057 ut WITHOUT ANY W\n+0001bf20: 4152 5241 4e54 593b 2077 6974 686f 7574 ARRANTY; without\n+0001bf30: 2065 7665 6e20 7468 6520 696d 706c 6965 even the implie\n+0001bf40: 6420 7761 7272 616e 7479 206f 660a 2320 d warranty of.# \n+0001bf50: 4d45 5243 4841 4e54 4142 494c 4954 5920 MERCHANTABILITY \n+0001bf60: 6f72 2046 4954 4e45 5353 2046 4f52 2041 or FITNESS FOR A\n+0001bf70: 2050 4152 5449 4355 4c41 5220 5055 5250 PARTICULAR PURP\n+0001bf80: 4f53 452e 2020 5365 6520 7468 650a 2320 OSE. See the.# \n+0001bf90: 474e 5520 4765 6e65 7261 6c20 5075 626c GNU General Publ\n+0001bfa0: 6963 204c 6963 656e 7365 2066 6f72 206d ic License for m\n+0001bfb0: 6f72 6520 6465 7461 696c 732e 0a23 0a23 ore details..#.#\n+0001bfc0: 2059 6f75 2073 686f 756c 6420 6861 7665 You should have\n+0001bfd0: 2072 6563 6569 7665 6420 6120 636f 7079 received a copy\n+0001bfe0: 206f 6620 7468 6520 474e 5520 4765 6e65 of the GNU Gene\n+0001bff0: 7261 6c20 5075 626c 6963 204c 6963 656e ral Public Licen\n+0001c000: 7365 0a23 2061 6c6f 6e67 2077 6974 6820 se.# along with \n+0001c010: 7468 6973 2070 726f 6772 616d 2e20 2049 this program. I\n+0001c020: 6620 6e6f 742c 2073 6565 203c 6874 7470 f not, see ...imp\n+0001c050: 6f72 7420 6c6f 6767 696e 670a 696d 706f ort logging.impo\n+0001c060: 7274 206c 7a6d 610a 6672 6f6d 2074 7970 rt lzma.from typ\n+0001c070: 696e 6720 696d 706f 7274 204c 6973 742c ing import List,\n+0001c080: 2053 6571 7565 6e63 652c 2054 7570 6c65 Sequence, Tuple\n+0001c090: 0a0a 6672 6f6d 2063 6f63 6b70 6974 2e5f ..from cockpit._\n+0001c0a0: 7665 6e64 6f72 2069 6d70 6f72 7420 6665 vendor import fe\n+0001c0b0: 726e 790a 6672 6f6d 2063 6f63 6b70 6974 rny.from cockpit\n+0001c0c0: 2e5f 7665 6e64 6f72 2e62 6569 2069 6d70 ._vendor.bei imp\n+0001c0d0: 6f72 7420 6265 6970 6163 6b0a 0a66 726f ort beipack..fro\n+0001c0e0: 6d20 2e64 6174 6120 696d 706f 7274 2072 m .data import r\n+0001c0f0: 6561 645f 636f 636b 7069 745f 6461 7461 ead_cockpit_data\n+0001c100: 5f66 696c 650a 6672 6f6d 202e 7065 6572 _file.from .peer\n+0001c110: 2069 6d70 6f72 7420 5065 6572 2c20 5065 import Peer, Pe\n+0001c120: 6572 4572 726f 720a 0a6c 6f67 6765 7220 erError..logger \n+0001c130: 3d20 6c6f 6767 696e 672e 6765 744c 6f67 = logging.getLog\n+0001c140: 6765 7228 5f5f 6e61 6d65 5f5f 290a 0a0a ger(__name__)...\n+0001c150: 6465 6620 6765 745f 6272 6964 6765 5f62 def get_bridge_b\n+0001c160: 6569 7061 636b 5f78 7a28 2920 2d3e 2054 eipack_xz() -> T\n+0001c170: 7570 6c65 5b73 7472 2c20 6279 7465 735d uple[str, bytes]\n+0001c180: 3a0a 2020 2020 7472 793a 0a20 2020 2020 :. try:. \n+0001c190: 2020 2062 7269 6467 655f 6265 6970 6163 bridge_beipac\n+0001c1a0: 6b5f 787a 203d 2072 6561 645f 636f 636b k_xz = read_cock\n+0001c1b0: 7069 745f 6461 7461 5f66 696c 6528 2763 pit_data_file('c\n+0001c1c0: 6f63 6b70 6974 2d62 7269 6467 652e 6265 ockpit-bridge.be\n+0001c1d0: 6970 6163 6b2e 787a 2729 0a20 2020 2020 ipack.xz'). \n+0001c1e0: 2020 206c 6f67 6765 722e 6465 6275 6728 logger.debug(\n+0001c1f0: 2747 6f74 2070 7265 2d62 7569 6c74 2063 'Got pre-built c\n+0001c200: 6f63 6b70 6974 2d62 7269 6467 652e 6265 ockpit-bridge.be\n+0001c210: 6970 6163 6b2e 787a 2729 0a20 2020 2065 ipack.xz'). e\n+0001c220: 7863 6570 7420 4669 6c65 4e6f 7446 6f75 xcept FileNotFou\n+0001c230: 6e64 4572 726f 723a 0a20 2020 2020 2020 ndError:. \n+0001c240: 206c 6f67 6765 722e 6465 6275 6728 2750 logger.debug('P\n+0001c250: 7265 2d62 7569 6c74 2063 6f63 6b70 6974 re-built cockpit\n+0001c260: 2d62 7269 6467 652e 6265 6970 6163 6b2e -bridge.beipack.\n+0001c270: 787a 3b20 6275 696c 6469 6e67 206f 7572 xz; building our\n+0001c280: 206f 776e 2e27 290a 2020 2020 2020 2020 own.'). \n+0001c290: 2320 6265 6970 6163 6b20 6f75 7273 656c # beipack oursel\n+0001c2a0: 7665 730a 2020 2020 2020 2020 636f 636b ves. cock\n+0001c2b0: 7069 745f 636f 6e74 656e 7473 203d 2062 pit_contents = b\n+0001c2c0: 6569 7061 636b 2e63 6f6c 6c65 6374 5f6d eipack.collect_m\n+0001c2d0: 6f64 756c 6528 2763 6f63 6b70 6974 272c odule('cockpit',\n+0001c2e0: 2072 6563 7572 7369 7665 3d54 7275 6529 recursive=True)\n+0001c2f0: 0a20 2020 2020 2020 2062 7269 6467 655f . bridge_\n+0001c300: 6265 6970 6163 6b20 3d20 6265 6970 6163 beipack = beipac\n+0001c310: 6b2e 7061 636b 2863 6f63 6b70 6974 5f63 k.pack(cockpit_c\n+0001c320: 6f6e 7465 6e74 732c 2065 6e74 7279 706f ontents, entrypo\n+0001c330: 696e 743d 2763 6f63 6b70 6974 2e62 7269 int='cockpit.bri\n+0001c340: 6467 653a 6d61 696e 272c 2061 7267 733d dge:main', args=\n+0001c350: 2762 6569 7061 636b 3d54 7275 6527 290a 'beipack=True').\n+0001c360: 2020 2020 2020 2020 6272 6964 6765 5f62 bridge_b\n+0001c370: 6569 7061 636b 5f78 7a20 3d20 6c7a 6d61 eipack_xz = lzma\n+0001c380: 2e63 6f6d 7072 6573 7328 6272 6964 6765 .compress(bridge\n+0001c390: 5f62 6569 7061 636b 2e65 6e63 6f64 6528 _beipack.encode(\n+0001c3a0: 2929 0a20 2020 2020 2020 206c 6f67 6765 )). logge\n+0001c3b0: 722e 6465 6275 6728 2720 202e 2e2e 2064 r.debug(' ... d\n+0001c3c0: 6f6e 6521 2729 0a0a 2020 2020 7265 7475 one!').. retu\n+0001c3d0: 726e 2027 636f 636b 7069 742f 6461 7461 rn 'cockpit/data\n+0001c3e0: 2f63 6f63 6b70 6974 2d62 7269 6467 652e /cockpit-bridge.\n+0001c3f0: 6265 6970 6163 6b2e 787a 272c 2062 7269 beipack.xz', bri\n+0001c400: 6467 655f 6265 6970 6163 6b5f 787a 0a0a dge_beipack_xz..\n+0001c410: 0a63 6c61 7373 2042 7269 6467 6542 6569 .class BridgeBei\n+0001c420: 626f 6f74 4865 6c70 6572 2866 6572 6e79 bootHelper(ferny\n+0001c430: 2e49 6e74 6572 6163 7469 6f6e 4861 6e64 .InteractionHand\n+0001c440: 6c65 7229 3a0a 2020 2020 2320 6665 726e ler):. # fern\n+0001c450: 792e 496e 7465 7261 6374 696f 6e48 616e y.InteractionHan\n+0001c460: 646c 6572 2043 6c61 7373 5661 720a 2020 dler ClassVar. \n+0001c470: 2020 636f 6d6d 616e 6473 203d 205b 2762 commands = ['b\n+0001c480: 6569 626f 6f74 2e70 726f 7669 6465 272c eiboot.provide',\n+0001c490: 2027 6265 6962 6f6f 742e 6578 6327 5d0a 'beiboot.exc'].\n+0001c4a0: 0a20 2020 2070 6565 723a 2050 6565 720a . peer: Peer.\n+0001c4b0: 2020 2020 7061 796c 6f61 643a 2062 7974 payload: byt\n+0001c4c0: 6573 0a20 2020 2073 7465 7073 3a20 5365 es. steps: Se\n+0001c4d0: 7175 656e 6365 5b54 7570 6c65 5b73 7472 quence[Tuple[str\n+0001c4e0: 2c20 5365 7175 656e 6365 5b6f 626a 6563 , Sequence[objec\n+0001c4f0: 745d 5d5d 0a0a 2020 2020 6465 6620 5f5f t]]].. def __\n+0001c500: 696e 6974 5f5f 2873 656c 662c 2070 6565 init__(self, pee\n+0001c510: 723a 2050 6565 722c 2061 7267 733a 2053 r: Peer, args: S\n+0001c520: 6571 7565 6e63 655b 7374 725d 203d 2028 equence[str] = (\n+0001c530: 2929 202d 3e20 4e6f 6e65 3a0a 2020 2020 )) -> None:. \n+0001c540: 2020 2020 6669 6c65 6e61 6d65 2c20 7061 filename, pa\n+0001c550: 796c 6f61 6420 3d20 6765 745f 6272 6964 yload = get_brid\n+0001c560: 6765 5f62 6569 7061 636b 5f78 7a28 290a ge_beipack_xz().\n+0001c570: 0a20 2020 2020 2020 2073 656c 662e 7065 . self.pe\n+0001c580: 6572 203d 2070 6565 720a 2020 2020 2020 er = peer. \n+0001c590: 2020 7365 6c66 2e70 6179 6c6f 6164 203d self.payload =\n+0001c5a0: 2070 6179 6c6f 6164 0a20 2020 2020 2020 payload. \n+0001c5b0: 2073 656c 662e 7374 6570 7320 3d20 2828 self.steps = ((\n+0001c5c0: 2762 6f6f 745f 787a 272c 2028 6669 6c65 'boot_xz', (file\n+0001c5d0: 6e61 6d65 2c20 6c65 6e28 7061 796c 6f61 name, len(payloa\n+0001c5e0: 6429 2c20 7475 706c 6528 6172 6773 2929 d), tuple(args))\n+0001c5f0: 292c 290a 0a20 2020 2061 7379 6e63 2064 ),).. async d\n+0001c600: 6566 2072 756e 5f63 6f6d 6d61 6e64 2873 ef run_command(s\n+0001c610: 656c 662c 2063 6f6d 6d61 6e64 3a20 7374 elf, command: st\n+0001c620: 722c 2061 7267 733a 2054 7570 6c65 2c20 r, args: Tuple, \n+0001c630: 6664 733a 204c 6973 745b 696e 745d 2c20 fds: List[int], \n+0001c640: 7374 6465 7272 3a20 7374 7229 202d 3e20 stderr: str) -> \n+0001c650: 4e6f 6e65 3a0a 2020 2020 2020 2020 6c6f None:. lo\n+0001c660: 6767 6572 2e64 6562 7567 2827 476f 7420 gger.debug('Got \n+0001c670: 6665 726e 7920 7265 7175 6573 7420 2573 ferny request %s\n+0001c680: 2025 7320 2573 2025 7327 2c20 636f 6d6d %s %s %s', comm\n+0001c690: 616e 642c 2061 7267 732c 2066 6473 2c20 and, args, fds, \n+0001c6a0: 7374 6465 7272 290a 2020 2020 2020 2020 stderr). \n+0001c6b0: 6966 2063 6f6d 6d61 6e64 203d 3d20 2762 if command == 'b\n+0001c6c0: 6569 626f 6f74 2e70 726f 7669 6465 273a eiboot.provide':\n+0001c6d0: 0a20 2020 2020 2020 2020 2020 2074 7279 . try\n+0001c6e0: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n+0001c6f0: 2020 7369 7a65 2c20 3d20 6172 6773 0a20 size, = args. \n+0001c700: 2020 2020 2020 2020 2020 2020 2020 2061 a\n+0001c710: 7373 6572 7420 7369 7a65 203d 3d20 6c65 ssert size == le\n+0001c720: 6e28 7365 6c66 2e70 6179 6c6f 6164 290a n(self.payload).\n+0001c730: 2020 2020 2020 2020 2020 2020 6578 6365 exce\n+0001c740: 7074 2028 4173 7365 7274 696f 6e45 7272 pt (AssertionErr\n+0001c750: 6f72 2c20 5661 6c75 6545 7272 6f72 2920 or, ValueError) \n+0001c760: 6173 2065 7863 3a0a 2020 2020 2020 2020 as exc:. \n+0001c770: 2020 2020 2020 2020 7261 6973 6520 5065 raise Pe\n+0001c780: 6572 4572 726f 7228 2769 6e74 6572 6e61 erError('interna\n+0001c790: 6c2d 6572 726f 7227 2c20 6d65 7373 6167 l-error', messag\n+0001c7a0: 653d 6627 6665 726e 7920 696e 7465 7261 e=f'ferny intera\n+0001c7b0: 6374 696f 6e20 6572 726f 7220 7b65 7863 ction error {exc\n+0001c7c0: 2173 7d27 2920 6672 6f6d 2065 7863 0a0a !s}') from exc..\n+0001c7d0: 2020 2020 2020 2020 2020 2020 6173 7365 asse\n+0001c7e0: 7274 2073 656c 662e 7065 6572 2e74 7261 rt self.peer.tra\n+0001c7f0: 6e73 706f 7274 2069 7320 6e6f 7420 4e6f nsport is not No\n+0001c800: 6e65 0a20 2020 2020 2020 2020 2020 206c ne. l\n+0001c810: 6f67 6765 722e 6465 6275 6728 2757 7269 ogger.debug('Wri\n+0001c820: 7469 6e67 2025 6420 6279 7465 7320 6f66 ting %d bytes of\n+0001c830: 2070 6179 6c6f 6164 272c 206c 656e 2873 payload', len(s\n+0001c840: 656c 662e 7061 796c 6f61 6429 290a 2020 elf.payload)). \n+0001c850: 2020 2020 2020 2020 2020 7365 6c66 2e70 self.p\n+0001c860: 6565 722e 7472 616e 7370 6f72 742e 7772 eer.transport.wr\n+0001c870: 6974 6528 7365 6c66 2e70 6179 6c6f 6164 ite(self.payload\n+0001c880: 290a 2020 2020 2020 2020 656c 6966 2063 ). elif c\n+0001c890: 6f6d 6d61 6e64 203d 3d20 2762 6569 626f ommand == 'beibo\n+0001c8a0: 6f74 2e65 7863 273a 0a20 2020 2020 2020 ot.exc':. \n+0001c8b0: 2020 2020 2072 6169 7365 2050 6565 7245 raise PeerE\n+0001c8c0: 7272 6f72 2827 696e 7465 726e 616c 2d65 rror('internal-e\n+0001c8d0: 7272 6f72 272c 206d 6573 7361 6765 3d66 rror', message=f\n+0001c8e0: 2752 656d 6f74 6520 6578 6365 7074 696f 'Remote exceptio\n+0001c8f0: 6e3a 207b 6172 6773 5b30 5d7d 2729 0a20 n: {args[0]}'). \n+0001c900: 2020 2020 2020 2065 6c73 653a 0a20 2020 else:. \n+0001c910: 2020 2020 2020 2020 2072 6169 7365 2050 raise P\n+0001c920: 6565 7245 7272 6f72 2827 696e 7465 726e eerError('intern\n+0001c930: 616c 2d65 7272 6f72 272c 206d 6573 7361 al-error', messa\n+0001c940: 6765 3d66 2755 6e65 7870 6563 7465 6420 ge=f'Unexpected \n+0001c950: 6665 726e 7920 696e 7465 7261 6374 696f ferny interactio\n+0001c960: 6e20 636f 6d6d 616e 6420 7b63 6f6d 6d61 n command {comma\n+0001c970: 6e64 7d27 290a 2727 272c 0a20 2027 636f nd}').''',. 'co\n+0001c980: 636b 7069 742f 7061 636b 6167 6573 2e70 ckpit/packages.p\n+0001c990: 7927 3a20 6272 2727 2723 2054 6869 7320 y': br'''# This \n+0001c9a0: 6669 6c65 2069 7320 7061 7274 206f 6620 file is part of \n+0001c9b0: 436f 636b 7069 742e 0a23 0a23 2043 6f70 Cockpit..#.# Cop\n+0001c9c0: 7972 6967 6874 2028 4329 2032 3032 3220 yright (C) 2022 \n+0001c9d0: 5265 6420 4861 742c 2049 6e63 2e0a 230a Red Hat, Inc..#.\n+0001c9e0: 2320 5468 6973 2070 726f 6772 616d 2069 # This program i\n+0001c9f0: 7320 6672 6565 2073 6f66 7477 6172 653a s free software:\n+0001ca00: 2079 6f75 2063 616e 2072 6564 6973 7472 you can redistr\n+0001ca10: 6962 7574 6520 6974 2061 6e64 2f6f 7220 ibute it and/or \n+0001ca20: 6d6f 6469 6679 0a23 2069 7420 756e 6465 modify.# it unde\n+0001ca30: 7220 7468 6520 7465 726d 7320 6f66 2074 r the terms of t\n+0001ca40: 6865 2047 4e55 2047 656e 6572 616c 2050 he GNU General P\n+0001ca50: 7562 6c69 6320 4c69 6365 6e73 6520 6173 ublic License as\n+0001ca60: 2070 7562 6c69 7368 6564 2062 790a 2320 published by.# \n+0001ca70: 7468 6520 4672 6565 2053 6f66 7477 6172 the Free Softwar\n+0001ca80: 6520 466f 756e 6461 7469 6f6e 2c20 6569 e Foundation, ei\n+0001ca90: 7468 6572 2076 6572 7369 6f6e 2033 206f ther version 3 o\n+0001caa0: 6620 7468 6520 4c69 6365 6e73 652c 206f f the License, o\n+0001cab0: 720a 2320 2861 7420 796f 7572 206f 7074 r.# (at your opt\n+0001cac0: 696f 6e29 2061 6e79 206c 6174 6572 2076 ion) any later v\n+0001cad0: 6572 7369 6f6e 2e0a 230a 2320 5468 6973 ersion..#.# This\n+0001cae0: 2070 726f 6772 616d 2069 7320 6469 7374 program is dist\n+0001caf0: 7269 6275 7465 6420 696e 2074 6865 2068 ributed in the h\n+0001cb00: 6f70 6520 7468 6174 2069 7420 7769 6c6c ope that it will\n+0001cb10: 2062 6520 7573 6566 756c 2c0a 2320 6275 be useful,.# bu\n+0001cb20: 7420 5749 5448 4f55 5420 414e 5920 5741 t WITHOUT ANY WA\n+0001cb30: 5252 414e 5459 3b20 7769 7468 6f75 7420 RRANTY; without \n+0001cb40: 6576 656e 2074 6865 2069 6d70 6c69 6564 even the implied\n+0001cb50: 2077 6172 7261 6e74 7920 6f66 0a23 204d warranty of.# M\n+0001cb60: 4552 4348 414e 5441 4249 4c49 5459 206f ERCHANTABILITY o\n+0001cb70: 7220 4649 544e 4553 5320 464f 5220 4120 r FITNESS FOR A \n+0001cb80: 5041 5254 4943 554c 4152 2050 5552 504f PARTICULAR PURPO\n+0001cb90: 5345 2e20 2053 6565 2074 6865 0a23 2047 SE. See the.# G\n+0001cba0: 4e55 2047 656e 6572 616c 2050 7562 6c69 NU General Publi\n+0001cbb0: 6320 4c69 6365 6e73 6520 666f 7220 6d6f c License for mo\n+0001cbc0: 7265 2064 6574 6169 6c73 2e0a 230a 2320 re details..#.# \n+0001cbd0: 596f 7520 7368 6f75 6c64 2068 6176 6520 You should have \n+0001cbe0: 7265 6365 6976 6564 2061 2063 6f70 7920 received a copy \n+0001cbf0: 6f66 2074 6865 2047 4e55 2047 656e 6572 of the GNU Gener\n+0001cc00: 616c 2050 7562 6c69 6320 4c69 6365 6e73 al Public Licens\n+0001cc10: 650a 2320 616c 6f6e 6720 7769 7468 2074 e.# along with t\n+0001cc20: 6869 7320 7072 6f67 7261 6d2e 2020 4966 his program. If\n+0001cc30: 206e 6f74 2c20 7365 6520 3c68 7474 7073 not, see ...impo\n+0001cc60: 7274 2063 6f6c 6c65 6374 696f 6e73 0a69 rt collections.i\n+0001cc70: 6d70 6f72 7420 636f 6e74 6578 746c 6962 mport contextlib\n+0001cc80: 0a69 6d70 6f72 7420 6675 6e63 746f 6f6c .import functool\n+0001cc90: 730a 696d 706f 7274 2067 7a69 700a 696d s.import gzip.im\n+0001cca0: 706f 7274 2069 6f0a 696d 706f 7274 2069 port io.import i\n+0001ccb0: 7465 7274 6f6f 6c73 0a69 6d70 6f72 7420 tertools.import \n+0001ccc0: 6a73 6f6e 0a69 6d70 6f72 7420 6c6f 6767 json.import logg\n+0001ccd0: 696e 670a 696d 706f 7274 206d 696d 6574 ing.import mimet\n+0001cce0: 7970 6573 0a69 6d70 6f72 7420 6f73 0a69 ypes.import os.i\n+0001ccf0: 6d70 6f72 7420 7265 0a69 6d70 6f72 7420 mport re.import \n+0001cd00: 7368 7574 696c 0a66 726f 6d20 7061 7468 shutil.from path\n+0001cd10: 6c69 6220 696d 706f 7274 2050 6174 680a lib import Path.\n+0001cd20: 6672 6f6d 2074 7970 696e 6720 696d 706f from typing impo\n+0001cd30: 7274 2028 0a20 2020 2042 696e 6172 7949 rt (. BinaryI\n+0001cd40: 4f2c 0a20 2020 2043 616c 6c61 626c 652c O,. Callable,\n+0001cd50: 0a20 2020 2043 6c61 7373 5661 722c 0a20 . ClassVar,. \n+0001cd60: 2020 2044 6963 742c 0a20 2020 2049 7465 Dict,. Ite\n+0001cd70: 7261 626c 652c 0a20 2020 204c 6973 742c rable,. List,\n+0001cd80: 0a20 2020 204e 616d 6564 5475 706c 652c . NamedTuple,\n+0001cd90: 0a20 2020 204f 7074 696f 6e61 6c2c 0a20 . Optional,. \n+0001cda0: 2020 2050 6174 7465 726e 2c0a 2020 2020 Pattern,. \n+0001cdb0: 5365 7175 656e 6365 2c0a 2020 2020 5475 Sequence,. Tu\n+0001cdc0: 706c 652c 0a20 2020 2054 7970 6556 6172 ple,. TypeVar\n+0001cdd0: 2c0a 290a 0a66 726f 6d20 636f 636b 7069 ,.)..from cockpi\n+0001cde0: 742e 5f76 656e 646f 722e 7379 7374 656d t._vendor.system\n+0001cdf0: 645f 6374 7970 6573 2069 6d70 6f72 7420 d_ctypes import \n+0001ce00: 6275 730a 0a66 726f 6d20 2e20 696d 706f bus..from . impo\n+0001ce10: 7274 2063 6f6e 6669 670a 6672 6f6d 202e rt config.from .\n+0001ce20: 5f76 6572 7369 6f6e 2069 6d70 6f72 7420 _version import \n+0001ce30: 5f5f 7665 7273 696f 6e5f 5f0a 6672 6f6d __version__.from\n+0001ce40: 202e 6a73 6f6e 7574 696c 2069 6d70 6f72 .jsonutil impor\n+0001ce50: 7420 280a 2020 2020 4a73 6f6e 4572 726f t (. JsonErro\n+0001ce60: 722c 0a20 2020 204a 736f 6e4f 626a 6563 r,. JsonObjec\n+0001ce70: 742c 0a20 2020 204a 736f 6e56 616c 7565 t,. JsonValue\n+0001ce80: 2c0a 2020 2020 6765 745f 626f 6f6c 2c0a ,. get_bool,.\n+0001ce90: 2020 2020 6765 745f 6469 6374 2c0a 2020 get_dict,. \n+0001cea0: 2020 6765 745f 696e 742c 0a20 2020 2067 get_int,. g\n+0001ceb0: 6574 5f6f 626a 762c 0a20 2020 2067 6574 et_objv,. get\n+0001cec0: 5f73 7472 2c0a 2020 2020 6765 745f 7374 _str,. get_st\n+0001ced0: 7276 2c0a 2020 2020 6a73 6f6e 5f6d 6572 rv,. json_mer\n+0001cee0: 6765 5f70 6174 6368 2c0a 2020 2020 7479 ge_patch,. ty\n+0001cef0: 7065 6368 6563 6b65 642c 0a29 0a0a 6c6f pechecked,.)..lo\n+0001cf00: 6767 6572 203d 206c 6f67 6769 6e67 2e67 gger = logging.g\n+0001cf10: 6574 4c6f 6767 6572 285f 5f6e 616d 655f etLogger(__name_\n+0001cf20: 5f29 0a0a 0a23 2049 6e20 7072 6163 7469 _)...# In practi\n+0001cf30: 6365 2c20 7468 6973 2069 7320 676f 696e ce, this is goin\n+0001cf40: 6720 746f 2067 6574 2063 616c 6c65 6420 g to get called \n+0001cf50: 6f76 6572 2061 6e64 206f 7665 7220 6167 over and over ag\n+0001cf60: 6169 6e20 7769 7468 2065 7861 6374 6c79 ain with exactly\n+0001cf70: 2074 6865 0a23 2073 616d 6520 6c69 7374 the.# same list\n+0001cf80: 2e20 204c 6574 2773 2074 7279 2074 6f20 . Let's try to \n+0001cf90: 6361 6368 6520 7468 6520 7265 7375 6c74 cache the result\n+0001cfa0: 2e0a 4066 756e 6374 6f6f 6c73 2e6c 7275 ..@functools.lru\n+0001cfb0: 5f63 6163 6865 2829 0a64 6566 2070 6172 _cache().def par\n+0001cfc0: 7365 5f61 6363 6570 745f 6c61 6e67 7561 se_accept_langua\n+0001cfd0: 6765 2861 6363 6570 745f 6c61 6e67 7561 ge(accept_langua\n+0001cfe0: 6765 3a20 7374 7229 202d 3e20 5365 7175 ge: str) -> Sequ\n+0001cff0: 656e 6365 5b73 7472 5d3a 0a20 2020 2022 ence[str]:. \"\n+0001d000: 2222 5061 7273 6520 7468 6520 4163 6365 \"\"Parse the Acce\n+0001d010: 7074 2d4c 616e 6775 6167 6520 6865 6164 pt-Language head\n+0001d020: 6572 2c20 6966 2069 7420 6578 6973 7473 er, if it exists\n+0001d030: 2e0a 0a20 2020 2052 6574 7572 6e73 2061 ... Returns a\n+0001d040: 6e20 6f72 6465 7265 6420 6c69 7374 206f n ordered list o\n+0001d050: 6620 6c61 6e67 7561 6765 732c 2077 6974 f languages, wit\n+0001d060: 6820 6661 6c6c 6261 636b 7320 696e 7365 h fallbacks inse\n+0001d070: 7274 6564 2c20 616e 640a 2020 2020 7472 rted, and. tr\n+0001d080: 756e 6361 7465 6420 746f 2074 6865 2070 uncated to the p\n+0001d090: 6f73 6974 696f 6e20 7768 6572 6520 2765 osition where 'e\n+0001d0a0: 6e27 2077 6f75 6c64 2068 6176 6520 6f74 n' would have ot\n+0001d0b0: 6865 7277 6973 6520 6170 7065 6172 6564 herwise appeared\n+0001d0c0: 2c20 6966 0a20 2020 2061 7070 6c69 6361 , if. applica\n+0001d0d0: 626c 652e 0a0a 2020 2020 6874 7470 733a ble... https:\n+0001d0e0: 2f2f 746f 6f6c 732e 6965 7466 2e6f 7267 //tools.ietf.org\n+0001d0f0: 2f68 746d 6c2f 7266 6337 3233 3123 7365 /html/rfc7231#se\n+0001d100: 6374 696f 6e2d 352e 332e 350a 2020 2020 ction-5.3.5. \n+0001d110: 6874 7470 733a 2f2f 6461 7461 7472 6163 https://datatrac\n+0001d120: 6b65 722e 6965 7466 2e6f 7267 2f64 6f63 ker.ietf.org/doc\n+0001d130: 2f68 746d 6c2f 7266 6334 3634 3723 7365 /html/rfc4647#se\n+0001d140: 6374 696f 6e2d 332e 340a 2020 2020 2222 ction-3.4. \"\"\n+0001d150: 220a 0a20 2020 206c 6f67 6765 722e 6465 \".. logger.de\n+0001d160: 6275 6728 2770 6172 7365 5f61 6363 6570 bug('parse_accep\n+0001d170: 745f 6c61 6e67 7561 6765 2825 7229 272c t_language(%r)',\n+0001d180: 2061 6363 6570 745f 6c61 6e67 7561 6765 accept_language\n+0001d190: 290a 2020 2020 6c6f 6361 6c65 735f 7769 ). locales_wi\n+0001d1a0: 7468 5f71 203d 205b 5d0a 2020 2020 666f th_q = []. fo\n+0001d1b0: 7220 656e 7472 7920 696e 2061 6363 6570 r entry in accep\n+0001d1c0: 745f 6c61 6e67 7561 6765 2e73 706c 6974 t_language.split\n+0001d1d0: 2827 2c27 293a 0a20 2020 2020 2020 2065 (','):. e\n+0001d1e0: 6e74 7279 203d 2065 6e74 7279 2e73 7472 ntry = entry.str\n+0001d1f0: 6970 2829 2e6c 6f77 6572 2829 0a20 2020 ip().lower(). \n+0001d200: 2020 2020 206c 6f67 6765 722e 6465 6275 logger.debu\n+0001d210: 6728 2720 2065 6e74 7279 2025 7227 2c20 g(' entry %r', \n+0001d220: 656e 7472 7929 0a20 2020 2020 2020 206c entry). l\n+0001d230: 6f63 616c 652c 205f 2c20 7173 7472 203d ocale, _, qstr =\n+0001d240: 2065 6e74 7279 2e70 6172 7469 7469 6f6e entry.partition\n+0001d250: 2827 3b71 3d27 290a 2020 2020 2020 2020 (';q='). \n+0001d260: 7472 793a 0a20 2020 2020 2020 2020 2020 try:. \n+0001d270: 2071 203d 2066 6c6f 6174 2871 7374 7220 q = float(qstr \n+0001d280: 6f72 2031 2e30 290a 2020 2020 2020 2020 or 1.0). \n+0001d290: 6578 6365 7074 2056 616c 7565 4572 726f except ValueErro\n+0001d2a0: 723a 0a20 2020 2020 2020 2020 2020 2063 r:. c\n+0001d2b0: 6f6e 7469 6e75 6520 2023 2069 676e 6f72 ontinue # ignor\n+0001d2c0: 6520 6d61 6c66 6f72 6d65 6420 656e 7472 e malformed entr\n+0001d2d0: 790a 0a20 2020 2020 2020 2077 6869 6c65 y.. while\n+0001d2e0: 206c 6f63 616c 653a 0a20 2020 2020 2020 locale:. \n+0001d2f0: 2020 2020 206c 6f67 6765 722e 6465 6275 logger.debu\n+0001d300: 6728 2720 2020 2061 6464 696e 6720 2572 g(' adding %r\n+0001d310: 2071 3d25 7227 2c20 6c6f 6361 6c65 2c20 q=%r', locale, \n+0001d320: 7129 0a20 2020 2020 2020 2020 2020 206c q). l\n+0001d330: 6f63 616c 6573 5f77 6974 685f 712e 6170 ocales_with_q.ap\n+0001d340: 7065 6e64 2828 6c6f 6361 6c65 2c20 7129 pend((locale, q)\n+0001d350: 290a 2020 2020 2020 2020 2020 2020 2320 ). # \n+0001d360: 7374 7269 7020 6f66 6620 272d 6465 7461 strip off '-deta\n+0001d370: 696c 2720 7375 6666 6978 6573 2075 6e74 il' suffixes unt\n+0001d380: 696c 2074 6865 7265 2773 206e 6f74 6869 il there's nothi\n+0001d390: 6e67 206c 6566 740a 2020 2020 2020 2020 ng left. \n+0001d3a0: 2020 2020 6c6f 6361 6c65 2c20 5f2c 205f locale, _, _\n+0001d3b0: 7265 6769 6f6e 203d 206c 6f63 616c 652e region = locale.\n+0001d3c0: 7270 6172 7469 7469 6f6e 2827 2d27 290a rpartition('-').\n+0001d3d0: 0a20 2020 2023 2053 6f72 7420 7468 6520 . # Sort the \n+0001d3e0: 6c69 7374 2062 7920 6869 6768 6573 7420 list by highest \n+0001d3f0: 7120 7661 6c75 652e 2020 4f74 6865 7277 q value. Otherw\n+0001d400: 6973 652c 2074 6869 7320 6973 2061 2073 ise, this is a s\n+0001d410: 7461 626c 6520 736f 7274 2e0a 2020 2020 table sort.. \n+0001d420: 6c6f 6361 6c65 735f 7769 7468 5f71 2e73 locales_with_q.s\n+0001d430: 6f72 7428 6b65 793d 6c61 6d62 6461 2070 ort(key=lambda p\n+0001d440: 6169 723a 2070 6169 725b 315d 2c20 7265 air: pair[1], re\n+0001d450: 7665 7273 653d 5472 7565 290a 2020 2020 verse=True). \n+0001d460: 6c6f 6767 6572 2e64 6562 7567 2827 2020 logger.debug(' \n+0001d470: 736f 7274 6564 206c 6973 7420 6973 2025 sorted list is %\n+0001d480: 7227 2c20 6c6f 6361 6c65 735f 7769 7468 r', locales_with\n+0001d490: 5f71 290a 0a20 2020 2023 2049 6620 7765 _q).. # If we\n+0001d4a0: 2068 6176 6520 2765 6e27 2061 6e79 7768 have 'en' anywh\n+0001d4b0: 6572 6520 696e 206f 7572 206c 6973 742c ere in our list,\n+0001d4c0: 2069 676e 6f72 6520 6974 2061 6e64 2061 ignore it and a\n+0001d4d0: 6c6c 2069 7465 6d73 2061 6674 6572 2069 ll items after i\n+0001d4e0: 742e 0a20 2020 2023 2054 6869 7320 7769 t.. # This wi\n+0001d4f0: 6c6c 2072 6573 756c 7420 696e 2075 7320 ll result in us \n+0001d500: 6765 7474 696e 6720 616e 2075 6e74 7261 getting an untra\n+0001d510: 6e73 6c61 7465 6420 2869 653a 2045 6e67 nslated (ie: Eng\n+0001d520: 6c69 7368 2920 7665 7273 696f 6e20 6966 lish) version if\n+0001d530: 0a20 2020 2023 206e 6f6e 6520 6f66 2074 . # none of t\n+0001d540: 6865 206d 6f72 652d 7072 6566 6572 7265 he more-preferre\n+0001d550: 6420 6c61 6e67 7561 6765 7320 6172 6520 d languages are \n+0001d560: 666f 756e 642c 2077 6869 6368 2069 7320 found, which is \n+0001d570: 7768 6174 2077 6520 7761 6e74 2e0a 2020 what we want.. \n+0001d580: 2020 2320 5765 2061 6c73 6f20 7461 6b65 # We also take\n+0001d590: 2074 6865 2063 6861 6e63 6520 746f 2064 the chance to d\n+0001d5a0: 726f 7020 6475 706c 6963 6174 6520 6974 rop duplicate it\n+0001d5b0: 656d 732e 2020 4e6f 7465 3a20 626f 7468 ems. Note: both\n+0001d5c0: 206f 6620 7468 6573 650a 2020 2020 2320 of these. # \n+0001d5d0: 7468 696e 6773 206e 6565 6420 746f 2068 things need to h\n+0001d5e0: 6170 7065 6e20 6166 7465 7220 736f 7274 appen after sort\n+0001d5f0: 696e 672e 0a20 2020 2072 6573 756c 7473 ing.. results\n+0001d600: 203d 205b 5d0a 2020 2020 666f 7220 6c6f = []. for lo\n+0001d610: 6361 6c65 2c20 5f71 2069 6e20 6c6f 6361 cale, _q in loca\n+0001d620: 6c65 735f 7769 7468 5f71 3a0a 2020 2020 les_with_q:. \n+0001d630: 2020 2020 6966 206c 6f63 616c 6520 3d3d if locale ==\n+0001d640: 2027 656e 273a 0a20 2020 2020 2020 2020 'en':. \n+0001d650: 2020 2062 7265 616b 0a20 2020 2020 2020 break. \n+0001d660: 2069 6620 6c6f 6361 6c65 206e 6f74 2069 if locale not i\n+0001d670: 6e20 7265 7375 6c74 733a 0a20 2020 2020 n results:. \n+0001d680: 2020 2020 2020 2072 6573 756c 7473 2e61 results.a\n+0001d690: 7070 656e 6428 6c6f 6361 6c65 290a 0a20 ppend(locale).. \n+0001d6a0: 2020 206c 6f67 6765 722e 6465 6275 6728 logger.debug(\n+0001d6b0: 2720 2072 6573 756c 7473 206c 6973 7420 ' results list \n+0001d6c0: 6973 2025 7227 2c20 7265 7375 6c74 7329 is %r', results)\n+0001d6d0: 0a20 2020 2072 6574 7572 6e20 7475 706c . return tupl\n+0001d6e0: 6528 7265 7375 6c74 7329 0a0a 0a64 6566 e(results)...def\n+0001d6f0: 2073 6f72 7469 6679 5f76 6572 7369 6f6e sortify_version\n+0001d700: 2876 6572 7369 6f6e 3a20 7374 7229 202d (version: str) -\n+0001d710: 3e20 7374 723a 0a20 2020 2022 2222 436f > str:. \"\"\"Co\n+0001d720: 6e76 6572 7420 6120 7665 7273 696f 6e20 nvert a version \n+0001d730: 7374 7269 6e67 2074 6f20 6120 666f 726d string to a form\n+0001d740: 2074 6861 7420 6361 6e20 6265 2063 6f6d that can be com\n+0001d750: 7061 7265 6422 2222 0a20 2020 2023 2030 pared\"\"\". # 0\n+0001d760: 2d70 6164 2065 6163 6820 6e75 6d65 7269 -pad each numeri\n+0001d770: 6320 636f 6d70 6f6e 656e 742e 2020 4f6e c component. On\n+0001d780: 6c79 2073 7570 706f 7274 7320 6e75 6d65 ly supports nume\n+0001d790: 7269 6320 7665 7273 696f 6e73 206c 696b ric versions lik\n+0001d7a0: 6520 312e 322e 332e 0a20 2020 2072 6574 e 1.2.3.. ret\n+0001d7b0: 7572 6e20 272e 272e 6a6f 696e 2870 6172 urn '.'.join(par\n+0001d7c0: 742e 7a66 696c 6c28 3829 2066 6f72 2070 t.zfill(8) for p\n+0001d7d0: 6172 7420 696e 2076 6572 7369 6f6e 2e73 art in version.s\n+0001d7e0: 706c 6974 2827 2e27 2929 0a0a 0a40 6675 plit('.'))...@fu\n+0001d7f0: 6e63 746f 6f6c 732e 6c72 755f 6361 6368 nctools.lru_cach\n+0001d800: 6528 290a 6465 6620 6765 745f 6c69 6265 e().def get_libe\n+0001d810: 7865 6364 6972 2829 202d 3e20 7374 723a xecdir() -> str:\n+0001d820: 0a20 2020 2022 2222 4465 7465 6374 206c . \"\"\"Detect l\n+0001d830: 6962 6578 6563 6469 7220 6f6e 2063 7572 ibexecdir on cur\n+0001d840: 7265 6e74 206d 6163 6869 6e65 0a0a 2020 rent machine.. \n+0001d850: 2020 5468 6973 206f 6e6c 7920 776f 726b This only work\n+0001d860: 7320 666f 7220 7379 7374 656d 7320 7768 s for systems wh\n+0001d870: 6963 6820 6861 7665 2063 6f63 6b70 6974 ich have cockpit\n+0001d880: 2d77 7320 696e 7374 616c 6c65 642e 0a20 -ws installed.. \n+0001d890: 2020 2022 2222 0a20 2020 2066 6f72 2063 \"\"\". for c\n+0001d8a0: 616e 6469 6461 7465 2069 6e20 5b27 2f75 andidate in ['/u\n+0001d8b0: 7372 2f6c 6f63 616c 2f6c 6962 6578 6563 sr/local/libexec\n+0001d8c0: 272c 2027 2f75 7372 2f6c 6962 6578 6563 ', '/usr/libexec\n+0001d8d0: 272c 2027 2f75 7372 2f6c 6f63 616c 2f6c ', '/usr/local/l\n+0001d8e0: 6962 2f63 6f63 6b70 6974 272c 2027 2f75 ib/cockpit', '/u\n+0001d8f0: 7372 2f6c 6962 2f63 6f63 6b70 6974 275d sr/lib/cockpit']\n+0001d900: 3a0a 2020 2020 2020 2020 6966 206f 732e :. if os.\n+0001d910: 7061 7468 2e65 7869 7374 7328 6f73 2e70 path.exists(os.p\n+0001d920: 6174 682e 6a6f 696e 2863 616e 6469 6461 ath.join(candida\n+0001d930: 7465 2c20 2763 6f63 6b70 6974 2d61 736b te, 'cockpit-ask\n+0001d940: 7061 7373 2729 293a 0a20 2020 2020 2020 pass')):. \n+0001d950: 2020 2020 2072 6574 7572 6e20 6361 6e64 return cand\n+0001d960: 6964 6174 650a 2020 2020 656c 7365 3a0a idate. else:.\n+0001d970: 2020 2020 2020 2020 6c6f 6767 6572 2e77 logger.w\n+0001d980: 6172 6e69 6e67 2827 436f 756c 6420 6e6f arning('Could no\n+0001d990: 7420 6465 7465 6374 206c 6962 6578 6563 t detect libexec\n+0001d9a0: 6469 7227 290a 2020 2020 2020 2020 2320 dir'). # \n+0001d9b0: 6769 7665 2072 6561 6461 626c 6520 6572 give readable er\n+0001d9c0: 726f 7220 6d65 7373 6167 6573 0a20 2020 ror messages. \n+0001d9d0: 2020 2020 2072 6574 7572 6e20 272f 6e6f return '/no\n+0001d9e0: 6e65 7869 7374 656e 742f 6c69 6265 7865 nexistent/libexe\n+0001d9f0: 6327 0a0a 0a23 2048 4143 4b3a 2054 7970 c'...# HACK: Typ\n+0001da00: 6520 6e61 7272 6f77 696e 6720 6f76 6572 e narrowing over\n+0001da10: 2055 6e69 6f6e 2074 7970 6573 2069 7320 Union types is \n+0001da20: 6e6f 7420 7375 7070 6f72 7465 6420 696e not supported in\n+0001da30: 2074 6865 2067 656e 6572 616c 2063 6173 the general cas\n+0001da40: 652c 0a23 2062 7574 2074 6869 7320 776f e,.# but this wo\n+0001da50: 726b 7320 666f 7220 7468 6520 6361 7365 rks for the case\n+0001da60: 2077 6520 6361 7265 2061 626f 7574 3a20 we care about: \n+0001da70: 6b6e 6f77 696e 6720 7468 6174 2077 6865 knowing that whe\n+0001da80: 6e20 7765 2070 6173 7320 696e 2061 6e0a n we pass in an.\n+0001da90: 2320 4a73 6f6e 4f62 6a65 6374 2c20 7765 # JsonObject, we\n+0001daa0: 276c 6c20 6765 7420 616e 204a 736f 6e4f 'll get an JsonO\n+0001dab0: 626a 6563 7420 6261 636b 2e0a 4a20 3d20 bject back..J = \n+0001dac0: 5479 7065 5661 7228 274a 272c 204a 736f TypeVar('J', Jso\n+0001dad0: 6e4f 626a 6563 742c 204a 736f 6e56 616c nObject, JsonVal\n+0001dae0: 7565 290a 0a0a 6465 6620 7061 7463 685f ue)...def patch_\n+0001daf0: 6c69 6265 7865 6364 6972 286f 626a 3a20 libexecdir(obj: \n+0001db00: 4a29 202d 3e20 4a3a 0a20 2020 2069 6620 J) -> J:. if \n+0001db10: 6973 696e 7374 616e 6365 286f 626a 2c20 isinstance(obj, \n+0001db20: 7374 7229 3a0a 2020 2020 2020 2020 6966 str):. if\n+0001db30: 2027 247b 6c69 6265 7865 6364 6972 7d2f '${libexecdir}/\n+0001db40: 636f 636b 7069 742d 6173 6b70 6173 7327 cockpit-askpass'\n+0001db50: 2069 6e20 6f62 6a3a 0a20 2020 2020 2020 in obj:. \n+0001db60: 2020 2020 2023 2065 7874 7261 2d73 7065 # extra-spe\n+0001db70: 6369 616c 2063 6173 653a 2077 6520 6861 cial case: we ha\n+0001db80: 6e64 6c65 2074 6869 7320 696e 7465 726e ndle this intern\n+0001db90: 616c 6c79 0a20 2020 2020 2020 2020 2020 ally. \n+0001dba0: 2061 6273 5f61 736b 7061 7373 203d 2073 abs_askpass = s\n+0001dbb0: 6875 7469 6c2e 7768 6963 6828 2763 6f63 hutil.which('coc\n+0001dbc0: 6b70 6974 2d61 736b 7061 7373 2729 0a20 kpit-askpass'). \n+0001dbd0: 2020 2020 2020 2020 2020 2069 6620 6162 if ab\n+0001dbe0: 735f 6173 6b70 6173 7320 6973 206e 6f74 s_askpass is not\n+0001dbf0: 204e 6f6e 653a 0a20 2020 2020 2020 2020 None:. \n+0001dc00: 2020 2020 2020 2072 6574 7572 6e20 6f62 return ob\n+0001dc10: 6a2e 7265 706c 6163 6528 2724 7b6c 6962 j.replace('${lib\n+0001dc20: 6578 6563 6469 727d 2f63 6f63 6b70 6974 execdir}/cockpit\n+0001dc30: 2d61 736b 7061 7373 272c 2061 6273 5f61 -askpass', abs_a\n+0001dc40: 736b 7061 7373 290a 2020 2020 2020 2020 skpass). \n+0001dc50: 7265 7475 726e 206f 626a 2e72 6570 6c61 return obj.repla\n+0001dc60: 6365 2827 247b 6c69 6265 7865 6364 6972 ce('${libexecdir\n+0001dc70: 7d27 2c20 6765 745f 6c69 6265 7865 6364 }', get_libexecd\n+0001dc80: 6972 2829 290a 2020 2020 656c 6966 2069 ir()). elif i\n+0001dc90: 7369 6e73 7461 6e63 6528 6f62 6a2c 2064 sinstance(obj, d\n+0001dca0: 6963 7429 3a0a 2020 2020 2020 2020 7265 ict):. re\n+0001dcb0: 7475 726e 207b 6b65 793a 2070 6174 6368 turn {key: patch\n+0001dcc0: 5f6c 6962 6578 6563 6469 7228 7661 6c75 _libexecdir(valu\n+0001dcd0: 6529 2066 6f72 206b 6579 2c20 7661 6c75 e) for key, valu\n+0001dce0: 6520 696e 206f 626a 2e69 7465 6d73 2829 e in obj.items()\n+0001dcf0: 7d0a 2020 2020 656c 6966 2069 7369 6e73 }. elif isins\n+0001dd00: 7461 6e63 6528 6f62 6a2c 206c 6973 7429 tance(obj, list)\n+0001dd10: 3a0a 2020 2020 2020 2020 7265 7475 726e :. return\n+0001dd20: 205b 7061 7463 685f 6c69 6265 7865 6364 [patch_libexecd\n+0001dd30: 6972 2869 7465 6d29 2066 6f72 2069 7465 ir(item) for ite\n+0001dd40: 6d20 696e 206f 626a 5d0a 2020 2020 656c m in obj]. el\n+0001dd50: 7365 3a0a 2020 2020 2020 2020 7265 7475 se:. retu\n+0001dd60: 726e 206f 626a 0a0a 0a23 2041 2064 6f63 rn obj...# A doc\n+0001dd70: 756d 656e 7420 6973 2061 2062 696e 6172 ument is a binar\n+0001dd80: 7920 7374 7265 616d 2077 6974 6820 6120 y stream with a \n+0001dd90: 436f 6e74 656e 742d 5479 7065 2c20 6f70 Content-Type, op\n+0001dda0: 7469 6f6e 616c 2043 6f6e 7465 6e74 2d45 tional Content-E\n+0001ddb0: 6e63 6f64 696e 672c 0a23 2061 6e64 206f ncoding,.# and o\n+0001ddc0: 7074 696f 6e61 6c20 436f 6e74 656e 742d ptional Content-\n+0001ddd0: 5365 6375 7269 7479 2d50 6f6c 6963 790a Security-Policy.\n+0001dde0: 636c 6173 7320 446f 6375 6d65 6e74 284e class Document(N\n+0001ddf0: 616d 6564 5475 706c 6529 3a0a 2020 2020 amedTuple):. \n+0001de00: 6461 7461 3a20 4269 6e61 7279 494f 0a20 data: BinaryIO. \n+0001de10: 2020 2063 6f6e 7465 6e74 5f74 7970 653a content_type:\n+0001de20: 2073 7472 0a20 2020 2063 6f6e 7465 6e74 str. content\n+0001de30: 5f65 6e63 6f64 696e 673a 204f 7074 696f _encoding: Optio\n+0001de40: 6e61 6c5b 7374 725d 203d 204e 6f6e 650a nal[str] = None.\n+0001de50: 2020 2020 636f 6e74 656e 745f 7365 6375 content_secu\n+0001de60: 7269 7479 5f70 6f6c 6963 793a 204f 7074 rity_policy: Opt\n+0001de70: 696f 6e61 6c5b 7374 725d 203d 204e 6f6e ional[str] = Non\n+0001de80: 650a 0a0a 636c 6173 7320 5061 636b 6167 e...class Packag\n+0001de90: 6573 4c69 7374 656e 6572 3a0a 2020 2020 esListener:. \n+0001dea0: 6465 6620 7061 636b 6167 6573 5f6c 6f61 def packages_loa\n+0001deb0: 6465 6428 7365 6c66 2920 2d3e 204e 6f6e ded(self) -> Non\n+0001dec0: 653a 0a20 2020 2020 2020 2022 2222 4361 e:. \"\"\"Ca\n+0001ded0: 6c6c 6564 2077 6865 6e20 7468 6520 7061 lled when the pa\n+0001dee0: 636b 6167 6573 2068 6176 6520 6265 656e ckages have been\n+0001def0: 2072 656c 6f61 6465 6422 2222 0a0a 0a63 reloaded\"\"\"...c\n+0001df00: 6c61 7373 2042 7269 6467 6543 6f6e 6669 lass BridgeConfi\n+0001df10: 6728 6469 6374 2c20 4a73 6f6e 4f62 6a65 g(dict, JsonObje\n+0001df20: 6374 293a 0a20 2020 2064 6566 205f 5f69 ct):. def __i\n+0001df30: 6e69 745f 5f28 7365 6c66 2c20 7661 6c75 nit__(self, valu\n+0001df40: 653a 204a 736f 6e4f 626a 6563 7429 3a0a e: JsonObject):.\n+0001df50: 2020 2020 2020 2020 7375 7065 7228 292e super().\n+0001df60: 5f5f 696e 6974 5f5f 2876 616c 7565 290a __init__(value).\n+0001df70: 0a20 2020 2020 2020 2073 656c 662e 6c61 . self.la\n+0001df80: 6265 6c20 3d20 6765 745f 7374 7228 7365 bel = get_str(se\n+0001df90: 6c66 2c20 276c 6162 656c 272c 204e 6f6e lf, 'label', Non\n+0001dfa0: 6529 0a0a 2020 2020 2020 2020 7365 6c66 e).. self\n+0001dfb0: 2e70 7269 7669 6c65 6765 6420 3d20 6765 .privileged = ge\n+0001dfc0: 745f 626f 6f6c 2873 656c 662c 2027 7072 t_bool(self, 'pr\n+0001dfd0: 6976 696c 6567 6564 272c 2064 6566 6175 ivileged', defau\n+0001dfe0: 6c74 3d46 616c 7365 290a 2020 2020 2020 lt=False). \n+0001dff0: 2020 7365 6c66 2e6d 6174 6368 203d 2067 self.match = g\n+0001e000: 6574 5f64 6963 7428 7365 6c66 2c20 276d et_dict(self, 'm\n+0001e010: 6174 6368 272c 207b 7d29 0a20 2020 2020 atch', {}). \n+0001e020: 2020 2069 6620 6e6f 7420 7365 6c66 2e70 if not self.p\n+0001e030: 7269 7669 6c65 6765 6420 616e 6420 6e6f rivileged and no\n+0001e040: 7420 7365 6c66 2e6d 6174 6368 3a0a 2020 t self.match:. \n+0001e050: 2020 2020 2020 2020 2020 7261 6973 6520 raise \n+0001e060: 4a73 6f6e 4572 726f 7228 7661 6c75 652c JsonError(value,\n+0001e070: 2027 6d75 7374 2068 6176 6520 6d61 7463 'must have matc\n+0001e080: 6820 7275 6c65 7320 6f72 2062 6520 7072 h rules or be pr\n+0001e090: 6976 696c 6567 6564 2729 0a0a 2020 2020 ivileged').. \n+0001e0a0: 2020 2020 7365 6c66 2e65 6e76 6972 6f6e self.environ\n+0001e0b0: 203d 2067 6574 5f73 7472 7628 7365 6c66 = get_strv(self\n+0001e0c0: 2c20 2765 6e76 6972 6f6e 272c 2028 2929 , 'environ', ())\n+0001e0d0: 0a20 2020 2020 2020 2073 656c 662e 7370 . self.sp\n+0001e0e0: 6177 6e20 3d20 6765 745f 7374 7276 2873 awn = get_strv(s\n+0001e0f0: 656c 662c 2027 7370 6177 6e27 290a 2020 elf, 'spawn'). \n+0001e100: 2020 2020 2020 6966 206e 6f74 2073 656c if not sel\n+0001e110: 662e 7370 6177 6e3a 0a20 2020 2020 2020 f.spawn:. \n+0001e120: 2020 2020 2072 6169 7365 204a 736f 6e45 raise JsonE\n+0001e130: 7272 6f72 2876 616c 7565 2c20 2773 7061 rror(value, 'spa\n+0001e140: 776e 2076 6563 746f 7220 6d75 7374 2062 wn vector must b\n+0001e150: 6520 6e6f 6e2d 656d 7074 7927 290a 0a20 e non-empty').. \n+0001e160: 2020 2020 2020 2073 656c 662e 6e61 6d65 self.name\n+0001e170: 203d 2073 656c 662e 6c61 6265 6c20 6f72 = self.label or\n+0001e180: 2073 656c 662e 7370 6177 6e5b 305d 0a0a self.spawn[0]..\n+0001e190: 0a63 6c61 7373 2043 6f6e 6469 7469 6f6e .class Condition\n+0001e1a0: 3a0a 2020 2020 6465 6620 5f5f 696e 6974 :. def __init\n+0001e1b0: 5f5f 2873 656c 662c 2076 616c 7565 3a20 __(self, value: \n+0001e1c0: 4a73 6f6e 4f62 6a65 6374 293a 0a20 2020 JsonObject):. \n+0001e1d0: 2020 2020 2074 7279 3a0a 2020 2020 2020 try:. \n+0001e1e0: 2020 2020 2020 2873 656c 662e 6e61 6d65 (self.name\n+0001e1f0: 2c20 7365 6c66 2e76 616c 7565 292c 203d , self.value), =\n+0001e200: 2076 616c 7565 2e69 7465 6d73 2829 0a20 value.items(). \n+0001e210: 2020 2020 2020 2065 7863 6570 7420 5661 except Va\n+0001e220: 6c75 6545 7272 6f72 2061 7320 6578 633a lueError as exc:\n+0001e230: 0a20 2020 2020 2020 2020 2020 2072 6169 . rai\n+0001e240: 7365 204a 736f 6e45 7272 6f72 2876 616c se JsonError(val\n+0001e250: 7565 2c20 276d 7573 7420 636f 6e74 6169 ue, 'must contai\n+0001e260: 6e20 6578 6163 746c 7920 6f6e 6520 6b65 n exactly one ke\n+0001e270: 792f 7661 6c75 6520 7061 6972 2729 2066 y/value pair') f\n+0001e280: 726f 6d20 6578 630a 0a0a 636c 6173 7320 rom exc...class \n+0001e290: 4d61 6e69 6665 7374 2864 6963 742c 204a Manifest(dict, J\n+0001e2a0: 736f 6e4f 626a 6563 7429 3a0a 2020 2020 sonObject):. \n+0001e2b0: 2320 536b 6970 2076 6572 7369 6f6e 2063 # Skip version c\n+0001e2c0: 6865 636b 2077 6865 6e20 7275 6e6e 696e heck when runnin\n+0001e2d0: 6720 6f75 7420 6f66 2074 6865 2067 6974 g out of the git\n+0001e2e0: 2063 6865 636b 6f75 7420 285f 5f76 6572 checkout (__ver\n+0001e2f0: 7369 6f6e 5f5f 2069 7320 4e6f 6e65 290a sion__ is None).\n+0001e300: 2020 2020 434f 434b 5049 545f 5645 5253 COCKPIT_VERS\n+0001e310: 494f 4e20 3d20 5f5f 7665 7273 696f 6e5f ION = __version_\n+0001e320: 5f20 616e 6420 736f 7274 6966 795f 7665 _ and sortify_ve\n+0001e330: 7273 696f 6e28 5f5f 7665 7273 696f 6e5f rsion(__version_\n+0001e340: 5f29 0a0a 2020 2020 6465 6620 5f5f 696e _).. def __in\n+0001e350: 6974 5f5f 2873 656c 662c 2070 6174 683a it__(self, path:\n+0001e360: 2050 6174 682c 2076 616c 7565 3a20 4a73 Path, value: Js\n+0001e370: 6f6e 4f62 6a65 6374 293a 0a20 2020 2020 onObject):. \n+0001e380: 2020 2073 7570 6572 2829 2e5f 5f69 6e69 super().__ini\n+0001e390: 745f 5f28 7661 6c75 6529 0a20 2020 2020 t__(value). \n+0001e3a0: 2020 2073 656c 662e 7061 7468 203d 2070 self.path = p\n+0001e3b0: 6174 680a 2020 2020 2020 2020 7365 6c66 ath. self\n+0001e3c0: 2e6e 616d 6520 3d20 6765 745f 7374 7228 .name = get_str(\n+0001e3d0: 7365 6c66 2c20 276e 616d 6527 2c20 7365 self, 'name', se\n+0001e3e0: 6c66 2e70 6174 682e 6e61 6d65 290a 2020 lf.path.name). \n+0001e3f0: 2020 2020 2020 7365 6c66 2e62 7269 6467 self.bridg\n+0001e400: 6573 203d 2067 6574 5f6f 626a 7628 7365 es = get_objv(se\n+0001e410: 6c66 2c20 2762 7269 6467 6573 272c 2042 lf, 'bridges', B\n+0001e420: 7269 6467 6543 6f6e 6669 6729 0a20 2020 ridgeConfig). \n+0001e430: 2020 2020 2073 656c 662e 7072 696f 7269 self.priori\n+0001e440: 7479 203d 2067 6574 5f69 6e74 2873 656c ty = get_int(sel\n+0001e450: 662c 2027 7072 696f 7269 7479 272c 2031 f, 'priority', 1\n+0001e460: 290a 2020 2020 2020 2020 7365 6c66 2e63 ). self.c\n+0001e470: 7370 203d 2067 6574 5f73 7472 2873 656c sp = get_str(sel\n+0001e480: 662c 2027 636f 6e74 656e 742d 7365 6375 f, 'content-secu\n+0001e490: 7269 7479 2d70 6f6c 6963 7927 2c20 2727 rity-policy', ''\n+0001e4a0: 290a 2020 2020 2020 2020 7365 6c66 2e63 ). self.c\n+0001e4b0: 6f6e 6469 7469 6f6e 7320 3d20 6765 745f onditions = get_\n+0001e4c0: 6f62 6a76 2873 656c 662c 2027 636f 6e64 objv(self, 'cond\n+0001e4d0: 6974 696f 6e73 272c 2043 6f6e 6469 7469 itions', Conditi\n+0001e4e0: 6f6e 290a 0a20 2020 2020 2020 2023 2053 on).. # S\n+0001e4f0: 6b69 7020 7665 7273 696f 6e20 6368 6563 kip version chec\n+0001e500: 6b20 7768 656e 2072 756e 6e69 6e67 206f k when running o\n+0001e510: 7574 206f 6620 7468 6520 6769 7420 6368 ut of the git ch\n+0001e520: 6563 6b6f 7574 2028 434f 434b 5049 545f eckout (COCKPIT_\n+0001e530: 5645 5253 494f 4e20 6973 204e 6f6e 6529 VERSION is None)\n+0001e540: 0a20 2020 2020 2020 2069 6620 7365 6c66 . if self\n+0001e550: 2e43 4f43 4b50 4954 5f56 4552 5349 4f4e .COCKPIT_VERSION\n+0001e560: 2069 7320 6e6f 7420 4e6f 6e65 3a0a 2020 is not None:. \n+0001e570: 2020 2020 2020 2020 2020 7265 7175 6972 requir\n+0001e580: 6573 203d 2067 6574 5f64 6963 7428 7365 es = get_dict(se\n+0001e590: 6c66 2c20 2772 6571 7569 7265 7327 2c20 lf, 'requires', \n+0001e5a0: 7b7d 290a 2020 2020 2020 2020 2020 2020 {}). \n+0001e5b0: 666f 7220 6e61 6d65 2c20 7665 7273 696f for name, versio\n+0001e5c0: 6e20 696e 2072 6571 7569 7265 732e 6974 n in requires.it\n+0001e5d0: 656d 7328 293a 0a20 2020 2020 2020 2020 ems():. \n+0001e5e0: 2020 2020 2020 2069 6620 6e61 6d65 2021 if name !\n+0001e5f0: 3d20 2763 6f63 6b70 6974 273a 0a20 2020 = 'cockpit':. \n+0001e600: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0001e610: 2072 6169 7365 204a 736f 6e45 7272 6f72 raise JsonError\n+0001e620: 286e 616d 652c 2027 6e6f 6e2d 636f 636b (name, 'non-cock\n+0001e630: 7069 7420 7265 7175 6972 656d 656e 7420 pit requirement \n+0001e640: 6c69 7374 6564 2729 0a20 2020 2020 2020 listed'). \n+0001e650: 2020 2020 2020 2020 2069 6620 736f 7274 if sort\n+0001e660: 6966 795f 7665 7273 696f 6e28 7479 7065 ify_version(type\n+0001e670: 6368 6563 6b65 6428 7665 7273 696f 6e2c checked(version,\n+0001e680: 2073 7472 2929 203e 2073 656c 662e 434f str)) > self.CO\n+0001e690: 434b 5049 545f 5645 5253 494f 4e3a 0a20 CKPIT_VERSION:. \n+0001e6a0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0001e6b0: 2020 2072 6169 7365 204a 736f 6e45 7272 raise JsonErr\n+0001e6c0: 6f72 2876 6572 7369 6f6e 2c20 6627 7265 or(version, f're\n+0001e6d0: 7175 6972 6564 2063 6f63 6b70 6974 2076 quired cockpit v\n+0001e6e0: 6572 7369 6f6e 2028 7b76 6572 7369 6f6e ersion ({version\n+0001e6f0: 7d29 206e 6f74 206d 6574 2729 0a0a 0a63 }) not met')...c\n+0001e700: 6c61 7373 2050 6163 6b61 6765 3a0a 2020 lass Package:. \n+0001e710: 2020 2320 466f 7220 706f 7b2c 2e6d 616e # For po{,.man\n+0001e720: 6966 6573 747d 2e6a 7320 6669 6c65 732c ifest}.js files,\n+0001e730: 2074 6865 2069 6e74 6572 6573 7469 6e67 the interesting\n+0001e740: 2070 6172 7420 6973 2074 6865 206c 6f63 part is the loc\n+0001e750: 616c 6520 6e61 6d65 0a20 2020 2050 4f5f ale name. PO_\n+0001e760: 4a53 5f52 453a 2043 6c61 7373 5661 725b JS_RE: ClassVar[\n+0001e770: 5061 7474 6572 6e5d 203d 2072 652e 636f Pattern] = re.co\n+0001e780: 6d70 696c 6528 7227 2870 6f7c 706f 5c2e mpile(r'(po|po\\.\n+0001e790: 6d61 6e69 6665 7374 295c 2e28 5b5e 2e5d manifest)\\.([^.]\n+0001e7a0: 2b29 5c2e 6a73 285c 2e67 7a29 3f27 290a +)\\.js(\\.gz)?').\n+0001e7b0: 0a20 2020 2023 2069 6d6d 7574 6162 6c65 . # immutable\n+0001e7c0: 2061 6674 6572 205f 5f69 6e69 745f 5f0a after __init__.\n+0001e7d0: 2020 2020 6d61 6e69 6665 7374 3a20 4d61 manifest: Ma\n+0001e7e0: 6e69 6665 7374 0a20 2020 206e 616d 653a nifest. name:\n+0001e7f0: 2073 7472 0a20 2020 2070 6174 683a 2050 str. path: P\n+0001e800: 6174 680a 2020 2020 7072 696f 7269 7479 ath. priority\n+0001e810: 3a20 696e 740a 0a20 2020 2023 2063 6f6d : int.. # com\n+0001e820: 7075 7465 6420 6c61 7465 720a 2020 2020 puted later. \n+0001e830: 7472 616e 736c 6174 696f 6e73 3a20 4f70 translations: Op\n+0001e840: 7469 6f6e 616c 5b44 6963 745b 7374 722c tional[Dict[str,\n+0001e850: 2044 6963 745b 7374 722c 2073 7472 5d5d Dict[str, str]]\n+0001e860: 5d20 3d20 4e6f 6e65 0a20 2020 2066 696c ] = None. fil\n+0001e870: 6573 3a20 4f70 7469 6f6e 616c 5b44 6963 es: Optional[Dic\n+0001e880: 745b 7374 722c 2073 7472 5d5d 203d 204e t[str, str]] = N\n+0001e890: 6f6e 650a 0a20 2020 2064 6566 205f 5f69 one.. def __i\n+0001e8a0: 6e69 745f 5f28 7365 6c66 2c20 6d61 6e69 nit__(self, mani\n+0001e8b0: 6665 7374 3a20 4d61 6e69 6665 7374 293a fest: Manifest):\n+0001e8c0: 0a20 2020 2020 2020 2073 656c 662e 6d61 . self.ma\n+0001e8d0: 6e69 6665 7374 203d 206d 616e 6966 6573 nifest = manifes\n+0001e8e0: 740a 2020 2020 2020 2020 7365 6c66 2e6e t. self.n\n+0001e8f0: 616d 6520 3d20 6d61 6e69 6665 7374 2e6e ame = manifest.n\n+0001e900: 616d 650a 2020 2020 2020 2020 7365 6c66 ame. self\n+0001e910: 2e70 6174 6820 3d20 6d61 6e69 6665 7374 .path = manifest\n+0001e920: 2e70 6174 680a 2020 2020 2020 2020 7365 .path. se\n+0001e930: 6c66 2e70 7269 6f72 6974 7920 3d20 6d61 lf.priority = ma\n+0001e940: 6e69 6665 7374 2e70 7269 6f72 6974 790a nifest.priority.\n+0001e950: 0a20 2020 2064 6566 2065 6e73 7572 655f . def ensure_\n+0001e960: 7363 616e 6e65 6428 7365 6c66 2920 2d3e scanned(self) ->\n+0001e970: 204e 6f6e 653a 0a20 2020 2020 2020 2022 None:. \"\n+0001e980: 2222 456e 7375 7265 2074 6861 7420 7468 \"\"Ensure that th\n+0001e990: 6520 7061 636b 6167 6520 6861 7320 6265 e package has be\n+0001e9a0: 656e 2073 6361 6e6e 6564 2e0a 0a20 2020 en scanned... \n+0001e9b0: 2020 2020 2054 6869 7320 616c 6c6f 7773 This allows\n+0001e9c0: 2075 7320 746f 2064 6566 6572 2073 6361 us to defer sca\n+0001e9d0: 6e6e 696e 6720 7468 6520 6669 6c65 7320 nning the files \n+0001e9e0: 6f66 2074 6865 2070 6163 6b61 6765 2075 of the package u\n+0001e9f0: 6e74 696c 2077 6520 6b6e 6f77 0a20 2020 ntil we know. \n+0001ea00: 2020 2020 2074 6861 7420 7765 276c 6c20 that we'll \n+0001ea10: 6163 7475 616c 6c79 2075 7365 2069 742e actually use it.\n+0001ea20: 0a20 2020 2020 2020 2022 2222 0a0a 2020 . \"\"\".. \n+0001ea30: 2020 2020 2020 6966 2073 656c 662e 6669 if self.fi\n+0001ea40: 6c65 7320 6973 206e 6f74 204e 6f6e 653a les is not None:\n+0001ea50: 0a20 2020 2020 2020 2020 2020 2072 6574 . ret\n+0001ea60: 7572 6e0a 0a20 2020 2020 2020 2073 656c urn.. sel\n+0001ea70: 662e 6669 6c65 7320 3d20 7b7d 0a20 2020 f.files = {}. \n+0001ea80: 2020 2020 2073 656c 662e 7472 616e 736c self.transl\n+0001ea90: 6174 696f 6e73 203d 207b 2770 6f2e 6a73 ations = {'po.js\n+0001eaa0: 273a 207b 7d2c 2027 706f 2e6d 616e 6966 ': {}, 'po.manif\n+0001eab0: 6573 742e 6a73 273a 207b 7d7d 0a0a 2020 est.js': {}}.. \n+0001eac0: 2020 2020 2020 666f 7220 6669 6c65 2069 for file i\n+0001ead0: 6e20 7365 6c66 2e70 6174 682e 7267 6c6f n self.path.rglo\n+0001eae0: 6228 272a 2729 3a0a 2020 2020 2020 2020 b('*'):. \n+0001eaf0: 2020 2020 6e61 6d65 203d 2073 7472 2866 name = str(f\n+0001eb00: 696c 652e 7265 6c61 7469 7665 5f74 6f28 ile.relative_to(\n+0001eb10: 7365 6c66 2e70 6174 6829 290a 2020 2020 self.path)). \n+0001eb20: 2020 2020 2020 2020 6966 206e 616d 6520 if name \n+0001eb30: 696e 205b 272e 272c 2027 2e2e 272c 2027 in ['.', '..', '\n+0001eb40: 6d61 6e69 6665 7374 2e6a 736f 6e27 5d3a manifest.json']:\n+0001eb50: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+0001eb60: 2063 6f6e 7469 6e75 650a 0a20 2020 2020 continue.. \n+0001eb70: 2020 2020 2020 2070 6f5f 6d61 7463 6820 po_match \n+0001eb80: 3d20 5061 636b 6167 652e 504f 5f4a 535f = Package.PO_JS_\n+0001eb90: 5245 2e66 756c 6c6d 6174 6368 286e 616d RE.fullmatch(nam\n+0001eba0: 6529 0a20 2020 2020 2020 2020 2020 2069 e). i\n+0001ebb0: 6620 706f 5f6d 6174 6368 3a0a 2020 2020 f po_match:. \n+0001ebc0: 2020 2020 2020 2020 2020 2020 6261 7365 base\n+0001ebd0: 6e61 6d65 203d 2070 6f5f 6d61 7463 682e name = po_match.\n+0001ebe0: 6772 6f75 7028 3129 0a20 2020 2020 2020 group(1). \n+0001ebf0: 2020 2020 2020 2020 206c 6f63 616c 6520 locale \n+0001ec00: 3d20 706f 5f6d 6174 6368 2e67 726f 7570 = po_match.group\n+0001ec10: 2832 290a 2020 2020 2020 2020 2020 2020 (2). \n+0001ec20: 2020 2020 2320 4163 6365 7074 2d4c 616e # Accept-Lan\n+0001ec30: 6775 6167 6520 6973 2063 6173 652d 696e guage is case-in\n+0001ec40: 7365 6e73 6974 6976 6520 616e 6420 7573 sensitive and us\n+0001ec50: 6573 2027 2d27 2074 6f20 7365 7061 7261 es '-' to separa\n+0001ec60: 7465 2076 6172 6961 6e74 730a 2020 2020 te variants. \n+0001ec70: 2020 2020 2020 2020 2020 2020 6c6f 7765 lowe\n+0001ec80: 725f 6c6f 6361 6c65 203d 206c 6f63 616c r_locale = local\n+0001ec90: 652e 6c6f 7765 7228 292e 7265 706c 6163 e.lower().replac\n+0001eca0: 6528 275f 272c 2027 2d27 290a 0a20 2020 e('_', '-').. \n+0001ecb0: 2020 2020 2020 2020 2020 2020 206c 6f67 log\n+0001ecc0: 6765 722e 6465 6275 6728 2741 6464 696e ger.debug('Addin\n+0001ecd0: 6720 7472 616e 736c 6174 696f 6e20 2572 g translation %r\n+0001ece0: 2025 7220 2d3e 2025 7227 2c20 6261 7365 %r -> %r', base\n+0001ecf0: 6e61 6d65 2c20 6c6f 7765 725f 6c6f 6361 name, lower_loca\n+0001ed00: 6c65 2c20 6e61 6d65 290a 2020 2020 2020 le, name). \n+0001ed10: 2020 2020 2020 2020 2020 7365 6c66 2e74 self.t\n+0001ed20: 7261 6e73 6c61 7469 6f6e 735b 6627 7b62 ranslations[f'{b\n+0001ed30: 6173 656e 616d 657d 2e6a 7327 5d5b 6c6f asename}.js'][lo\n+0001ed40: 7765 725f 6c6f 6361 6c65 5d20 3d20 6e61 wer_locale] = na\n+0001ed50: 6d65 0a20 2020 2020 2020 2020 2020 2065 me. e\n+0001ed60: 6c73 653a 0a20 2020 2020 2020 2020 2020 lse:. \n+0001ed70: 2020 2020 2023 2073 7472 6970 206f 7574 # strip out\n+0001ed80: 2074 7261 696c 696e 6720 272e 677a 2720 trailing '.gz' \n+0001ed90: 636f 6d70 6f6e 656e 7473 0a20 2020 2020 components. \n+0001eda0: 2020 2020 2020 2020 2020 2062 6173 656e basen\n+0001edb0: 616d 6520 3d20 7265 2e73 7562 2827 2e67 ame = re.sub('.g\n+0001edc0: 7a24 272c 2027 272c 206e 616d 6529 0a20 z$', '', name). \n+0001edd0: 2020 2020 2020 2020 2020 2020 2020 206c l\n+0001ede0: 6f67 6765 722e 6465 6275 6728 2741 6464 ogger.debug('Add\n+0001edf0: 696e 6720 636f 6e74 656e 7420 2572 202d ing content %r -\n+0001ee00: 3e20 2572 272c 2062 6173 656e 616d 652c > %r', basename,\n+0001ee10: 206e 616d 6529 0a20 2020 2020 2020 2020 name). \n+0001ee20: 2020 2020 2020 2073 656c 662e 6669 6c65 self.file\n+0001ee30: 735b 6261 7365 6e61 6d65 5d20 3d20 6e61 s[basename] = na\n+0001ee40: 6d65 0a0a 2020 2020 2020 2020 2020 2020 me.. \n+0001ee50: 2020 2020 2320 4966 2077 6520 7365 6520 # If we see \n+0001ee60: 6120 6669 6c65 6e61 6d65 206c 696b 6520 a filename like \n+0001ee70: 6078 2e6d 696e 2e6a 7360 2077 6520 7761 `x.min.js` we wa\n+0001ee80: 6e74 2074 6f20 616c 736f 206f 6666 6572 nt to also offer\n+0001ee90: 2069 740a 2020 2020 2020 2020 2020 2020 it. \n+0001eea0: 2020 2020 2320 6174 2060 782e 6a73 602c # at `x.js`,\n+0001eeb0: 2062 7574 206f 6e6c 7920 6966 2060 782e but only if `x.\n+0001eec0: 6a73 282e 677a 2960 2069 7473 656c 6620 js(.gz)` itself \n+0001eed0: 6973 206e 6f74 2070 7265 7365 6e74 2e0a is not present..\n+0001eee0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0001eef0: 2320 4e6f 7465 3a20 7468 6973 2077 6f72 # Note: this wor\n+0001ef00: 6b73 2066 6f72 2062 6f74 6820 7468 6520 ks for both the \n+0001ef10: 6361 7365 2077 6865 7265 2077 6520 666f case where we fo\n+0001ef20: 756e 6420 7468 6520 6078 2e6a 7360 0a20 und the `x.js`. \n+0001ef30: 2020 2020 2020 2020 2020 2020 2020 2023 #\n+0001ef40: 2066 6972 7374 2028 6974 2773 2061 6c72 first (it's alr\n+0001ef50: 6561 6479 2069 6e20 7468 6520 6d61 7029 eady in the map)\n+0001ef60: 2061 6e64 2061 6c73 6f20 6966 2077 6520 and also if we \n+0001ef70: 6669 6e64 2069 7420 7365 636f 6e64 0a20 find it second. \n+0001ef80: 2020 2020 2020 2020 2020 2020 2020 2023 #\n+0001ef90: 2028 6974 2077 696c 6c20 6265 2072 6570 (it will be rep\n+0001efa0: 6c61 6365 6420 696e 2074 6865 206d 6170 laced in the map\n+0001efb0: 2062 7920 7468 6520 6c69 6e65 206a 7573 by the line jus\n+0001efc0: 7420 6162 6f76 6529 2e0a 2020 2020 2020 t above).. \n+0001efd0: 2020 2020 2020 2020 2020 2320 5365 6520 # See \n+0001efe0: 6874 7470 733a 2f2f 6769 7468 7562 2e63 https://github.c\n+0001eff0: 6f6d 2f63 6f63 6b70 6974 2d70 726f 6a65 om/cockpit-proje\n+0001f000: 6374 2f63 6f63 6b70 6974 2f70 756c 6c2f ct/cockpit/pull/\n+0001f010: 3139 3731 360a 2020 2020 2020 2020 2020 19716. \n+0001f020: 2020 2020 2020 7365 6c66 2e66 696c 6573 self.files\n+0001f030: 2e73 6574 6465 6661 756c 7428 6261 7365 .setdefault(base\n+0001f040: 6e61 6d65 2e72 6570 6c61 6365 2827 2e6d name.replace('.m\n+0001f050: 696e 2e27 2c20 272e 2729 2c20 6e61 6d65 in.', '.'), name\n+0001f060: 290a 0a20 2020 2020 2020 2023 2073 7570 ).. # sup\n+0001f070: 706f 7274 206f 6c64 2063 6f63 6b70 6974 port old cockpit\n+0001f080: 2d70 6f2d 706c 7567 696e 2077 6869 6368 -po-plugin which\n+0001f090: 2064 6964 6e27 7420 7772 6974 6520 706f didn't write po\n+0001f0a0: 2e6d 616e 6966 6573 742e 3f3f 2e6a 730a .manifest.??.js.\n+0001f0b0: 2020 2020 2020 2020 6966 206e 6f74 2073 if not s\n+0001f0c0: 656c 662e 7472 616e 736c 6174 696f 6e73 elf.translations\n+0001f0d0: 5b27 706f 2e6d 616e 6966 6573 742e 6a73 ['po.manifest.js\n+0001f0e0: 275d 3a0a 2020 2020 2020 2020 2020 2020 ']:. \n+0001f0f0: 7365 6c66 2e74 7261 6e73 6c61 7469 6f6e self.translation\n+0001f100: 735b 2770 6f2e 6d61 6e69 6665 7374 2e6a s['po.manifest.j\n+0001f110: 7327 5d20 3d20 7365 6c66 2e74 7261 6e73 s'] = self.trans\n+0001f120: 6c61 7469 6f6e 735b 2770 6f2e 6a73 275d lations['po.js']\n+0001f130: 0a0a 2020 2020 6465 6620 6765 745f 636f .. def get_co\n+0001f140: 6e74 656e 745f 7365 6375 7269 7479 5f70 ntent_security_p\n+0001f150: 6f6c 6963 7928 7365 6c66 2920 2d3e 2073 olicy(self) -> s\n+0001f160: 7472 3a0a 2020 2020 2020 2020 706f 6c69 tr:. poli\n+0001f170: 6379 203d 207b 0a20 2020 2020 2020 2020 cy = {. \n+0001f180: 2020 2022 6465 6661 756c 742d 7372 6322 \"default-src\"\n+0001f190: 3a20 2227 7365 6c66 2722 2c0a 2020 2020 : \"'self'\",. \n+0001f1a0: 2020 2020 2020 2020 2263 6f6e 6e65 6374 \"connect\n+0001f1b0: 2d73 7263 223a 2022 2773 656c 6627 222c -src\": \"'self'\",\n+0001f1c0: 0a20 2020 2020 2020 2020 2020 2022 666f . \"fo\n+0001f1d0: 726d 2d61 6374 696f 6e22 3a20 2227 7365 rm-action\": \"'se\n+0001f1e0: 6c66 2722 2c0a 2020 2020 2020 2020 2020 lf'\",. \n+0001f1f0: 2020 2262 6173 652d 7572 6922 3a20 2227 \"base-uri\": \"'\n+0001f200: 7365 6c66 2722 2c0a 2020 2020 2020 2020 self'\",. \n+0001f210: 2020 2020 226f 626a 6563 742d 7372 6322 \"object-src\"\n+0001f220: 3a20 2227 6e6f 6e65 2722 2c0a 2020 2020 : \"'none'\",. \n+0001f230: 2020 2020 2020 2020 2266 6f6e 742d 7372 \"font-sr\n+0001f240: 6322 3a20 2227 7365 6c66 2720 6461 7461 c\": \"'self' data\n+0001f250: 3a22 2c0a 2020 2020 2020 2020 2020 2020 :\",. \n+0001f260: 2269 6d67 2d73 7263 223a 2022 2773 656c \"img-src\": \"'sel\n+0001f270: 6627 2064 6174 613a 222c 0a20 2020 2020 f' data:\",. \n+0001f280: 2020 207d 0a0a 2020 2020 2020 2020 666f }.. fo\n+0001f290: 7220 6974 656d 2069 6e20 7365 6c66 2e6d r item in self.m\n+0001f2a0: 616e 6966 6573 742e 6373 702e 7370 6c69 anifest.csp.spli\n+0001f2b0: 7428 273b 2729 3a0a 2020 2020 2020 2020 t(';'):. \n+0001f2c0: 2020 2020 6974 656d 203d 2069 7465 6d2e item = item.\n+0001f2d0: 7374 7269 7028 290a 2020 2020 2020 2020 strip(). \n+0001f2e0: 2020 2020 6966 2069 7465 6d3a 0a20 2020 if item:. \n+0001f2f0: 2020 2020 2020 2020 2020 2020 206b 6579 key\n+0001f300: 2c20 5f2c 2076 616c 7565 203d 2069 7465 , _, value = ite\n+0001f310: 6d2e 7374 7269 7028 292e 7061 7274 6974 m.strip().partit\n+0001f320: 696f 6e28 2720 2729 0a20 2020 2020 2020 ion(' '). \n+0001f330: 2020 2020 2020 2020 2070 6f6c 6963 795b policy[\n+0001f340: 6b65 795d 203d 2076 616c 7565 0a0a 2020 key] = value.. \n+0001f350: 2020 2020 2020 7265 7475 726e 2027 2027 return ' '\n+0001f360: 2e6a 6f69 6e28 6627 7b6b 7d20 7b76 7d3b .join(f'{k} {v};\n+0001f370: 2720 666f 7220 6b2c 2076 2069 6e20 706f ' for k, v in po\n+0001f380: 6c69 6379 2e69 7465 6d73 2829 2920 2b20 licy.items()) + \n+0001f390: 2720 626c 6f63 6b2d 616c 6c2d 6d69 7865 ' block-all-mixe\n+0001f3a0: 642d 636f 6e74 656e 7427 0a0a 2020 2020 d-content'.. \n+0001f3b0: 6465 6620 6c6f 6164 5f66 696c 6528 7365 def load_file(se\n+0001f3c0: 6c66 2c20 6669 6c65 6e61 6d65 3a20 7374 lf, filename: st\n+0001f3d0: 7229 202d 3e20 446f 6375 6d65 6e74 3a0a r) -> Document:.\n+0001f3e0: 2020 2020 2020 2020 636f 6e74 656e 745f content_\n+0001f3f0: 7479 7065 2c20 636f 6e74 656e 745f 656e type, content_en\n+0001f400: 636f 6469 6e67 203d 206d 696d 6574 7970 coding = mimetyp\n+0001f410: 6573 2e67 7565 7373 5f74 7970 6528 6669 es.guess_type(fi\n+0001f420: 6c65 6e61 6d65 290a 2020 2020 2020 2020 lename). \n+0001f430: 636f 6e74 656e 745f 7365 6375 7269 7479 content_security\n+0001f440: 5f70 6f6c 6963 7920 3d20 4e6f 6e65 0a0a _policy = None..\n+0001f450: 2020 2020 2020 2020 6966 2063 6f6e 7465 if conte\n+0001f460: 6e74 5f74 7970 6520 6973 204e 6f6e 653a nt_type is None:\n+0001f470: 0a20 2020 2020 2020 2020 2020 2063 6f6e . con\n+0001f480: 7465 6e74 5f74 7970 6520 3d20 2774 6578 tent_type = 'tex\n+0001f490: 742f 706c 6169 6e27 0a20 2020 2020 2020 t/plain'. \n+0001f4a0: 2065 6c69 6620 636f 6e74 656e 745f 7479 elif content_ty\n+0001f4b0: 7065 2e73 7461 7274 7377 6974 6828 2774 pe.startswith('t\n+0001f4c0: 6578 742f 6874 6d6c 2729 3a0a 2020 2020 ext/html'):. \n+0001f4d0: 2020 2020 2020 2020 636f 6e74 656e 745f content_\n+0001f4e0: 7365 6375 7269 7479 5f70 6f6c 6963 7920 security_policy \n+0001f4f0: 3d20 7365 6c66 2e67 6574 5f63 6f6e 7465 = self.get_conte\n+0001f500: 6e74 5f73 6563 7572 6974 795f 706f 6c69 nt_security_poli\n+0001f510: 6379 2829 0a0a 2020 2020 2020 2020 7061 cy().. pa\n+0001f520: 7468 203d 2073 656c 662e 7061 7468 202f th = self.path /\n+0001f530: 2066 696c 656e 616d 650a 2020 2020 2020 filename. \n+0001f540: 2020 6c6f 6767 6572 2e64 6562 7567 2827 logger.debug('\n+0001f550: 2020 6c6f 6164 696e 6720 6461 7461 2066 loading data f\n+0001f560: 726f 6d20 2573 272c 2070 6174 6829 0a0a rom %s', path)..\n+0001f570: 2020 2020 2020 2020 7265 7475 726e 2044 return D\n+0001f580: 6f63 756d 656e 7428 7061 7468 2e6f 7065 ocument(path.ope\n+0001f590: 6e28 2772 6227 292c 2063 6f6e 7465 6e74 n('rb'), content\n+0001f5a0: 5f74 7970 652c 2063 6f6e 7465 6e74 5f65 _type, content_e\n+0001f5b0: 6e63 6f64 696e 672c 2063 6f6e 7465 6e74 ncoding, content\n+0001f5c0: 5f73 6563 7572 6974 795f 706f 6c69 6379 _security_policy\n+0001f5d0: 290a 0a20 2020 2064 6566 206c 6f61 645f ).. def load_\n+0001f5e0: 7472 616e 736c 6174 696f 6e28 7365 6c66 translation(self\n+0001f5f0: 2c20 7061 7468 3a20 7374 722c 206c 6f63 , path: str, loc\n+0001f600: 616c 6573 3a20 5365 7175 656e 6365 5b73 ales: Sequence[s\n+0001f610: 7472 5d29 202d 3e20 446f 6375 6d65 6e74 tr]) -> Document\n+0001f620: 3a0a 2020 2020 2020 2020 7365 6c66 2e65 :. self.e\n+0001f630: 6e73 7572 655f 7363 616e 6e65 6428 290a nsure_scanned().\n+0001f640: 2020 2020 2020 2020 6173 7365 7274 2073 assert s\n+0001f650: 656c 662e 7472 616e 736c 6174 696f 6e73 elf.translations\n+0001f660: 2069 7320 6e6f 7420 4e6f 6e65 0a0a 2020 is not None.. \n+0001f670: 2020 2020 2020 2320 4669 7273 7420 6d61 # First ma\n+0001f680: 7463 6820 7769 6e73 0a20 2020 2020 2020 tch wins. \n+0001f690: 2066 6f72 206c 6f63 616c 6520 696e 206c for locale in l\n+0001f6a0: 6f63 616c 6573 3a0a 2020 2020 2020 2020 ocales:. \n+0001f6b0: 2020 2020 7769 7468 2063 6f6e 7465 7874 with context\n+0001f6c0: 6c69 622e 7375 7070 7265 7373 284b 6579 lib.suppress(Key\n+0001f6d0: 4572 726f 7229 3a0a 2020 2020 2020 2020 Error):. \n+0001f6e0: 2020 2020 2020 2020 7265 7475 726e 2073 return s\n+0001f6f0: 656c 662e 6c6f 6164 5f66 696c 6528 7365 elf.load_file(se\n+0001f700: 6c66 2e74 7261 6e73 6c61 7469 6f6e 735b lf.translations[\n+0001f710: 7061 7468 5d5b 6c6f 6361 6c65 5d29 0a0a path][locale])..\n+0001f720: 2020 2020 2020 2020 2320 5765 2070 7265 # We pre\n+0001f730: 6665 7220 746f 2072 6574 7572 6e20 616e fer to return an\n+0001f740: 2065 6d70 7479 2064 6f63 756d 656e 7420 empty document \n+0001f750: 7468 616e 2034 3034 2069 6e20 6f72 6465 than 404 in orde\n+0001f760: 7220 746f 2061 766f 6964 0a20 2020 2020 r to avoid. \n+0001f770: 2020 2023 2065 7272 6f72 7320 696e 2074 # errors in t\n+0001f780: 6865 2063 6f6e 736f 6c65 2077 6865 6e20 he console when \n+0001f790: 6120 7472 616e 736c 6174 696f 6e20 6361 a translation ca\n+0001f7a0: 6e27 7420 6265 2066 6f75 6e64 0a20 2020 n't be found. \n+0001f7b0: 2020 2020 2072 6574 7572 6e20 446f 6375 return Docu\n+0001f7c0: 6d65 6e74 2869 6f2e 4279 7465 7349 4f28 ment(io.BytesIO(\n+0001f7d0: 292c 2027 7465 7874 2f6a 6176 6173 6372 ), 'text/javascr\n+0001f7e0: 6970 7427 290a 0a20 2020 2064 6566 206c ipt').. def l\n+0001f7f0: 6f61 645f 7061 7468 2873 656c 662c 2070 oad_path(self, p\n+0001f800: 6174 683a 2073 7472 2c20 6865 6164 6572 ath: str, header\n+0001f810: 733a 204a 736f 6e4f 626a 6563 7429 202d s: JsonObject) -\n+0001f820: 3e20 446f 6375 6d65 6e74 3a0a 2020 2020 > Document:. \n+0001f830: 2020 2020 7365 6c66 2e65 6e73 7572 655f self.ensure_\n+0001f840: 7363 616e 6e65 6428 290a 2020 2020 2020 scanned(). \n+0001f850: 2020 6173 7365 7274 2073 656c 662e 6669 assert self.fi\n+0001f860: 6c65 7320 6973 206e 6f74 204e 6f6e 650a les is not None.\n+0001f870: 2020 2020 2020 2020 6173 7365 7274 2073 assert s\n+0001f880: 656c 662e 7472 616e 736c 6174 696f 6e73 elf.translations\n+0001f890: 2069 7320 6e6f 7420 4e6f 6e65 0a0a 2020 is not None.. \n+0001f8a0: 2020 2020 2020 6966 2070 6174 6820 696e if path in\n+0001f8b0: 2073 656c 662e 7472 616e 736c 6174 696f self.translatio\n+0001f8c0: 6e73 3a0a 2020 2020 2020 2020 2020 2020 ns:. \n+0001f8d0: 6c6f 6361 6c65 7320 3d20 7061 7273 655f locales = parse_\n+0001f8e0: 6163 6365 7074 5f6c 616e 6775 6167 6528 accept_language(\n+0001f8f0: 6765 745f 7374 7228 6865 6164 6572 732c get_str(headers,\n+0001f900: 2027 4163 6365 7074 2d4c 616e 6775 6167 'Accept-Languag\n+0001f910: 6527 2c20 2727 2929 0a20 2020 2020 2020 e', '')). \n+0001f920: 2020 2020 2072 6574 7572 6e20 7365 6c66 return self\n+0001f930: 2e6c 6f61 645f 7472 616e 736c 6174 696f .load_translatio\n+0001f940: 6e28 7061 7468 2c20 6c6f 6361 6c65 7329 n(path, locales)\n+0001f950: 0a20 2020 2020 2020 2065 6c73 653a 0a20 . else:. \n+0001f960: 2020 2020 2020 2020 2020 2072 6574 7572 retur\n+0001f970: 6e20 7365 6c66 2e6c 6f61 645f 6669 6c65 n self.load_file\n+0001f980: 2873 656c 662e 6669 6c65 735b 7061 7468 (self.files[path\n+0001f990: 5d29 0a0a 0a63 6c61 7373 2050 6163 6b61 ])...class Packa\n+0001f9a0: 6765 734c 6f61 6465 723a 0a20 2020 2043 gesLoader:. C\n+0001f9b0: 4f4e 4449 5449 4f4e 533a 2043 6c61 7373 ONDITIONS: Class\n+0001f9c0: 5661 725b 4469 6374 5b73 7472 2c20 4361 Var[Dict[str, Ca\n+0001f9d0: 6c6c 6162 6c65 5b5b 7374 725d 2c20 626f llable[[str], bo\n+0001f9e0: 6f6c 5d5d 5d20 3d20 7b0a 2020 2020 2020 ol]]] = {. \n+0001f9f0: 2020 2770 6174 682d 6578 6973 7473 273a 'path-exists':\n+0001fa00: 206f 732e 7061 7468 2e65 7869 7374 732c os.path.exists,\n+0001fa10: 0a20 2020 2020 2020 2027 7061 7468 2d6e . 'path-n\n+0001fa20: 6f74 2d65 7869 7374 7327 3a20 6c61 6d62 ot-exists': lamb\n+0001fa30: 6461 2070 3a20 6e6f 7420 6f73 2e70 6174 da p: not os.pat\n+0001fa40: 682e 6578 6973 7473 2870 292c 0a20 2020 h.exists(p),. \n+0001fa50: 207d 0a0a 2020 2020 4063 6c61 7373 6d65 }.. @classme\n+0001fa60: 7468 6f64 0a20 2020 2064 6566 2067 6574 thod. def get\n+0001fa70: 5f78 6467 5f64 6174 615f 6469 7273 2863 _xdg_data_dirs(c\n+0001fa80: 6c73 2920 2d3e 2049 7465 7261 626c 655b ls) -> Iterable[\n+0001fa90: 7374 725d 3a0a 2020 2020 2020 2020 7472 str]:. tr\n+0001faa0: 793a 0a20 2020 2020 2020 2020 2020 2079 y:. y\n+0001fab0: 6965 6c64 206f 732e 656e 7669 726f 6e5b ield os.environ[\n+0001fac0: 2758 4447 5f44 4154 415f 484f 4d45 275d 'XDG_DATA_HOME']\n+0001fad0: 0a20 2020 2020 2020 2065 7863 6570 7420 . except \n+0001fae0: 4b65 7945 7272 6f72 3a0a 2020 2020 2020 KeyError:. \n+0001faf0: 2020 2020 2020 7969 656c 6420 6f73 2e70 yield os.p\n+0001fb00: 6174 682e 6578 7061 6e64 7573 6572 2827 ath.expanduser('\n+0001fb10: 7e2f 2e6c 6f63 616c 2f73 6861 7265 2729 ~/.local/share')\n+0001fb20: 0a0a 2020 2020 2020 2020 7472 793a 0a20 .. try:. \n+0001fb30: 2020 2020 2020 2020 2020 2079 6965 6c64 yield\n+0001fb40: 2066 726f 6d20 6f73 2e65 6e76 6972 6f6e from os.environ\n+0001fb50: 5b27 5844 475f 4441 5441 5f44 4952 5327 ['XDG_DATA_DIRS'\n+0001fb60: 5d2e 7370 6c69 7428 273a 2729 0a20 2020 ].split(':'). \n+0001fb70: 2020 2020 2065 7863 6570 7420 4b65 7945 except KeyE\n+0001fb80: 7272 6f72 3a0a 2020 2020 2020 2020 2020 rror:. \n+0001fb90: 2020 7969 656c 6420 6672 6f6d 2028 272f yield from ('/\n+0001fba0: 7573 722f 6c6f 6361 6c2f 7368 6172 6527 usr/local/share'\n+0001fbb0: 2c20 272f 7573 722f 7368 6172 6527 290a , '/usr/share').\n+0001fbc0: 0a20 2020 2040 636c 6173 736d 6574 686f . @classmetho\n+0001fbd0: 640a 2020 2020 6465 6620 7061 7463 685f d. def patch_\n+0001fbe0: 6d61 6e69 6665 7374 2863 6c73 2c20 6d61 manifest(cls, ma\n+0001fbf0: 6e69 6665 7374 3a20 4a73 6f6e 4f62 6a65 nifest: JsonObje\n+0001fc00: 6374 2c20 7061 7265 6e74 3a20 5061 7468 ct, parent: Path\n+0001fc10: 2920 2d3e 204a 736f 6e4f 626a 6563 743a ) -> JsonObject:\n+0001fc20: 0a20 2020 2020 2020 206f 7665 7272 6964 . overrid\n+0001fc30: 655f 6669 6c65 7320 3d20 5b0a 2020 2020 e_files = [. \n+0001fc40: 2020 2020 2020 2020 7061 7265 6e74 202f parent /\n+0001fc50: 2027 6f76 6572 7269 6465 2e6a 736f 6e27 'override.json'\n+0001fc60: 2c0a 2020 2020 2020 2020 2020 2020 636f ,. co\n+0001fc70: 6e66 6967 2e6c 6f6f 6b75 705f 636f 6e66 nfig.lookup_conf\n+0001fc80: 6967 2866 277b 7061 7265 6e74 2e6e 616d ig(f'{parent.nam\n+0001fc90: 657d 2e6f 7665 7272 6964 652e 6a73 6f6e e}.override.json\n+0001fca0: 2729 2c0a 2020 2020 2020 2020 2020 2020 '),. \n+0001fcb0: 636f 6e66 6967 2e44 4f54 5f43 4f4e 4649 config.DOT_CONFI\n+0001fcc0: 475f 434f 434b 5049 5420 2f20 6627 7b70 G_COCKPIT / f'{p\n+0001fcd0: 6172 656e 742e 6e61 6d65 7d2e 6f76 6572 arent.name}.over\n+0001fce0: 7269 6465 2e6a 736f 6e27 2c0a 2020 2020 ride.json',. \n+0001fcf0: 2020 2020 5d0a 0a20 2020 2020 2020 2066 ].. f\n+0001fd00: 6f72 206f 7665 7272 6964 655f 6669 6c65 or override_file\n+0001fd10: 2069 6e20 6f76 6572 7269 6465 5f66 696c in override_fil\n+0001fd20: 6573 3a0a 2020 2020 2020 2020 2020 2020 es:. \n+0001fd30: 7472 793a 0a20 2020 2020 2020 2020 2020 try:. \n+0001fd40: 2020 2020 206f 7665 7272 6964 653a 204a override: J\n+0001fd50: 736f 6e56 616c 7565 203d 206a 736f 6e2e sonValue = json.\n+0001fd60: 6c6f 6164 7328 6f76 6572 7269 6465 5f66 loads(override_f\n+0001fd70: 696c 652e 7265 6164 5f62 7974 6573 2829 ile.read_bytes()\n+0001fd80: 290a 2020 2020 2020 2020 2020 2020 6578 ). ex\n+0001fd90: 6365 7074 2046 696c 654e 6f74 466f 756e cept FileNotFoun\n+0001fda0: 6445 7272 6f72 3a0a 2020 2020 2020 2020 dError:. \n+0001fdb0: 2020 2020 2020 2020 636f 6e74 696e 7565 continue\n+0001fdc0: 0a20 2020 2020 2020 2020 2020 2065 7863 . exc\n+0001fdd0: 6570 7420 6a73 6f6e 2e4a 534f 4e44 6563 ept json.JSONDec\n+0001fde0: 6f64 6545 7272 6f72 2061 7320 6578 633a odeError as exc:\n+0001fdf0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+0001fe00: 2023 2055 7365 7220 696e 7075 7420 6572 # User input er\n+0001fe10: 726f 723a 2072 6570 6f72 7420 6120 7761 ror: report a wa\n+0001fe20: 726e 696e 670a 2020 2020 2020 2020 2020 rning. \n+0001fe30: 2020 2020 2020 6c6f 6767 6572 2e77 6172 logger.war\n+0001fe40: 6e69 6e67 2827 2573 3a20 2573 272c 206f ning('%s: %s', o\n+0001fe50: 7665 7272 6964 655f 6669 6c65 2c20 6578 verride_file, ex\n+0001fe60: 6329 0a0a 2020 2020 2020 2020 2020 2020 c).. \n+0001fe70: 6966 206e 6f74 2069 7369 6e73 7461 6e63 if not isinstanc\n+0001fe80: 6528 6f76 6572 7269 6465 2c20 6469 6374 e(override, dict\n+0001fe90: 293a 0a20 2020 2020 2020 2020 2020 2020 ):. \n+0001fea0: 2020 206c 6f67 6765 722e 7761 726e 696e logger.warnin\n+0001feb0: 6728 2725 733a 206f 7665 7272 6964 6520 g('%s: override \n+0001fec0: 6669 6c65 2069 7320 6e6f 7420 6120 6469 file is not a di\n+0001fed0: 6374 696f 6e61 7279 272c 206f 7665 7272 ctionary', overr\n+0001fee0: 6964 655f 6669 6c65 290a 2020 2020 2020 ide_file). \n+0001fef0: 2020 2020 2020 2020 2020 636f 6e74 696e contin\n+0001ff00: 7565 0a0a 2020 2020 2020 2020 2020 2020 ue.. \n+0001ff10: 6d61 6e69 6665 7374 203d 206a 736f 6e5f manifest = json_\n+0001ff20: 6d65 7267 655f 7061 7463 6828 6d61 6e69 merge_patch(mani\n+0001ff30: 6665 7374 2c20 6f76 6572 7269 6465 290a fest, override).\n+0001ff40: 0a20 2020 2020 2020 2072 6574 7572 6e20 . return \n+0001ff50: 7061 7463 685f 6c69 6265 7865 6364 6972 patch_libexecdir\n+0001ff60: 286d 616e 6966 6573 7429 0a0a 2020 2020 (manifest).. \n+0001ff70: 4063 6c61 7373 6d65 7468 6f64 0a20 2020 @classmethod. \n+0001ff80: 2064 6566 206c 6f61 645f 6d61 6e69 6665 def load_manife\n+0001ff90: 7374 7328 636c 7329 202d 3e20 4974 6572 sts(cls) -> Iter\n+0001ffa0: 6162 6c65 5b4d 616e 6966 6573 745d 3a0a able[Manifest]:.\n+0001ffb0: 2020 2020 2020 2020 666f 7220 6461 7461 for data\n+0001ffc0: 6469 7220 696e 2063 6c73 2e67 6574 5f78 dir in cls.get_x\n+0001ffd0: 6467 5f64 6174 615f 6469 7273 2829 3a0a dg_data_dirs():.\n+0001ffe0: 2020 2020 2020 2020 2020 2020 6c6f 6767 logg\n+0001fff0: 6572 2e64 6562 7567 2822 5363 616e 6e69 er.debug(\"Scanni\n+00020000: 6e67 2066 6f72 206d 616e 6966 6573 7420 ng for manifest \n+00020010: 6669 6c65 7320 756e 6465 7220 2573 222c files under %s\",\n+00020020: 2064 6174 6164 6972 290a 2020 2020 2020 datadir). \n+00020030: 2020 2020 2020 666f 7220 6669 6c65 2069 for file i\n+00020040: 6e20 5061 7468 2864 6174 6164 6972 292e n Path(datadir).\n+00020050: 676c 6f62 2827 636f 636b 7069 742f 2a2f glob('cockpit/*/\n+00020060: 6d61 6e69 6665 7374 2e6a 736f 6e27 293a manifest.json'):\n+00020070: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+00020080: 206c 6f67 6765 722e 6465 6275 6728 2243 logger.debug(\"C\n+00020090: 6f6e 7369 6465 7269 6e67 2066 696c 6520 onsidering file \n+000200a0: 2573 222c 2066 696c 6529 0a20 2020 2020 %s\", file). \n+000200b0: 2020 2020 2020 2020 2020 2074 7279 3a0a try:.\n+000200c0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000200d0: 2020 2020 6d61 6e69 6665 7374 203d 206a manifest = j\n+000200e0: 736f 6e2e 6c6f 6164 7328 6669 6c65 2e72 son.loads(file.r\n+000200f0: 6561 645f 7465 7874 2829 290a 2020 2020 ead_text()). \n+00020100: 2020 2020 2020 2020 2020 2020 6578 6365 exce\n+00020110: 7074 206a 736f 6e2e 4a53 4f4e 4465 636f pt json.JSONDeco\n+00020120: 6465 4572 726f 7220 6173 2065 7863 3a0a deError as exc:.\n+00020130: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00020140: 2020 2020 6c6f 6767 6572 2e65 7272 6f72 logger.error\n+00020150: 2822 2573 3a20 2573 222c 2066 696c 652c (\"%s: %s\", file,\n+00020160: 2065 7863 290a 2020 2020 2020 2020 2020 exc). \n+00020170: 2020 2020 2020 2020 2020 636f 6e74 696e contin\n+00020180: 7565 0a20 2020 2020 2020 2020 2020 2020 ue. \n+00020190: 2020 2069 6620 6e6f 7420 6973 696e 7374 if not isinst\n+000201a0: 616e 6365 286d 616e 6966 6573 742c 2064 ance(manifest, d\n+000201b0: 6963 7429 3a0a 2020 2020 2020 2020 2020 ict):. \n+000201c0: 2020 2020 2020 2020 2020 6c6f 6767 6572 logger\n+000201d0: 2e65 7272 6f72 2822 2573 3a20 6a73 6f6e .error(\"%s: json\n+000201e0: 2064 6f63 756d 656e 7420 6973 6e27 7420 document isn't \n+000201f0: 616e 206f 626a 6563 7422 2c20 6669 6c65 an object\", file\n+00020200: 290a 2020 2020 2020 2020 2020 2020 2020 ). \n+00020210: 2020 2020 2020 636f 6e74 696e 7565 0a0a continue..\n+00020220: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00020230: 7061 7265 6e74 203d 2066 696c 652e 7061 parent = file.pa\n+00020240: 7265 6e74 0a20 2020 2020 2020 2020 2020 rent. \n+00020250: 2020 2020 206d 616e 6966 6573 7420 3d20 manifest = \n+00020260: 636c 732e 7061 7463 685f 6d61 6e69 6665 cls.patch_manife\n+00020270: 7374 286d 616e 6966 6573 742c 2070 6172 st(manifest, par\n+00020280: 656e 7429 0a20 2020 2020 2020 2020 2020 ent). \n+00020290: 2020 2020 2074 7279 3a0a 2020 2020 2020 try:. \n+000202a0: 2020 2020 2020 2020 2020 2020 2020 7969 yi\n+000202b0: 656c 6420 4d61 6e69 6665 7374 2870 6172 eld Manifest(par\n+000202c0: 656e 742c 206d 616e 6966 6573 7429 0a20 ent, manifest). \n+000202d0: 2020 2020 2020 2020 2020 2020 2020 2065 e\n+000202e0: 7863 6570 7420 4a73 6f6e 4572 726f 7220 xcept JsonError \n+000202f0: 6173 2065 7863 3a0a 2020 2020 2020 2020 as exc:. \n+00020300: 2020 2020 2020 2020 2020 2020 6c6f 6767 logg\n+00020310: 6572 2e77 6172 6e69 6e67 2827 2573 2025 er.warning('%s %\n+00020320: 7327 2c20 6669 6c65 2c20 6578 6329 0a0a s', file, exc)..\n+00020330: 2020 2020 6465 6620 6368 6563 6b5f 636f def check_co\n+00020340: 6e64 6974 696f 6e28 7365 6c66 2c20 636f ndition(self, co\n+00020350: 6e64 6974 696f 6e3a 2073 7472 2c20 7661 ndition: str, va\n+00020360: 6c75 653a 206f 626a 6563 7429 202d 3e20 lue: object) -> \n+00020370: 626f 6f6c 3a0a 2020 2020 2020 2020 6368 bool:. ch\n+00020380: 6563 6b5f 666e 203d 2073 656c 662e 434f eck_fn = self.CO\n+00020390: 4e44 4954 494f 4e53 5b63 6f6e 6469 7469 NDITIONS[conditi\n+000203a0: 6f6e 5d0a 0a20 2020 2020 2020 2023 2041 on].. # A\n+000203b0: 6c6c 206b 6e6f 776e 2070 7265 6469 6361 ll known predica\n+000203c0: 7465 7320 6375 7272 656e 746c 7920 6f6e tes currently on\n+000203d0: 6c79 2077 6f72 6b20 6f6e 2073 7472 696e ly work on strin\n+000203e0: 6773 0a20 2020 2020 2020 2069 6620 6e6f gs. if no\n+000203f0: 7420 6973 696e 7374 616e 6365 2876 616c t isinstance(val\n+00020400: 7565 2c20 7374 7229 3a0a 2020 2020 2020 ue, str):. \n+00020410: 2020 2020 2020 7265 7475 726e 2046 616c return Fal\n+00020420: 7365 0a0a 2020 2020 2020 2020 7265 7475 se.. retu\n+00020430: 726e 2063 6865 636b 5f66 6e28 7661 6c75 rn check_fn(valu\n+00020440: 6529 0a0a 2020 2020 6465 6620 6368 6563 e).. def chec\n+00020450: 6b5f 636f 6e64 6974 696f 6e73 2873 656c k_conditions(sel\n+00020460: 662c 206d 616e 6966 6573 743a 204d 616e f, manifest: Man\n+00020470: 6966 6573 7429 202d 3e20 626f 6f6c 3a0a ifest) -> bool:.\n+00020480: 2020 2020 2020 2020 666f 7220 636f 6e64 for cond\n+00020490: 6974 696f 6e20 696e 206d 616e 6966 6573 ition in manifes\n+000204a0: 742e 636f 6e64 6974 696f 6e73 3a0a 2020 t.conditions:. \n+000204b0: 2020 2020 2020 2020 2020 7472 793a 0a20 try:. \n+000204c0: 2020 2020 2020 2020 2020 2020 2020 206f o\n+000204d0: 6b61 7920 3d20 7365 6c66 2e63 6865 636b kay = self.check\n+000204e0: 5f63 6f6e 6469 7469 6f6e 2863 6f6e 6469 _condition(condi\n+000204f0: 7469 6f6e 2e6e 616d 652c 2063 6f6e 6469 tion.name, condi\n+00020500: 7469 6f6e 2e76 616c 7565 290a 2020 2020 tion.value). \n+00020510: 2020 2020 2020 2020 6578 6365 7074 204b except K\n+00020520: 6579 4572 726f 723a 0a20 2020 2020 2020 eyError:. \n+00020530: 2020 2020 2020 2020 2023 2064 6f20 2a6e # do *n\n+00020540: 6f74 2a20 6967 6e6f 7265 206d 616e 6966 ot* ignore manif\n+00020550: 6573 7473 2077 6974 6820 756e 6b6e 6f77 ests with unknow\n+00020560: 6e20 7072 6564 6963 6174 6573 2c20 666f n predicates, fo\n+00020570: 7220 666f 7277 6172 6420 636f 6d70 6174 r forward compat\n+00020580: 6962 696c 6974 790a 2020 2020 2020 2020 ibility. \n+00020590: 2020 2020 2020 2020 6c6f 6767 6572 2e77 logger.w\n+000205a0: 6172 6e69 6e67 2827 2020 2573 3a20 6967 arning(' %s: ig\n+000205b0: 6e6f 7269 6e67 2075 6e6b 6e6f 776e 2070 noring unknown p\n+000205c0: 7265 6469 6361 7465 2069 6e20 6d61 6e69 redicate in mani\n+000205d0: 6665 7374 3a20 2573 272c 206d 616e 6966 fest: %s', manif\n+000205e0: 6573 742e 7061 7468 2c20 636f 6e64 6974 est.path, condit\n+000205f0: 696f 6e2e 6e61 6d65 290a 2020 2020 2020 ion.name). \n+00020600: 2020 2020 2020 2020 2020 636f 6e74 696e contin\n+00020610: 7565 0a0a 2020 2020 2020 2020 2020 2020 ue.. \n+00020620: 6966 206e 6f74 206f 6b61 793a 0a20 2020 if not okay:. \n+00020630: 2020 2020 2020 2020 2020 2020 206c 6f67 log\n+00020640: 6765 722e 6465 6275 6728 2720 2068 6964 ger.debug(' hid\n+00020650: 696e 6720 7061 636b 6167 6520 2573 2061 ing package %s a\n+00020660: 7320 6974 7320 2573 2063 6f6e 6469 7469 s its %s conditi\n+00020670: 6f6e 2069 7320 6e6f 7420 6d65 7427 2c20 on is not met', \n+00020680: 6d61 6e69 6665 7374 2e70 6174 682c 2063 manifest.path, c\n+00020690: 6f6e 6469 7469 6f6e 290a 2020 2020 2020 ondition). \n+000206a0: 2020 2020 2020 2020 2020 7265 7475 726e return\n+000206b0: 2046 616c 7365 0a0a 2020 2020 2020 2020 False.. \n+000206c0: 7265 7475 726e 2054 7275 650a 0a20 2020 return True.. \n+000206d0: 2064 6566 206c 6f61 645f 7061 636b 6167 def load_packag\n+000206e0: 6573 2873 656c 6629 202d 3e20 4974 6572 es(self) -> Iter\n+000206f0: 6162 6c65 5b54 7570 6c65 5b73 7472 2c20 able[Tuple[str, \n+00020700: 5061 636b 6167 655d 5d3a 0a20 2020 2020 Package]]:. \n+00020710: 2020 206c 6f67 6765 722e 6465 6275 6728 logger.debug(\n+00020720: 2753 6361 6e6e 696e 6720 666f 7220 6176 'Scanning for av\n+00020730: 6169 6c61 626c 6520 7061 636b 6167 6520 ailable package \n+00020740: 6d61 6e69 6665 7374 733a 2729 0a20 2020 manifests:'). \n+00020750: 2020 2020 2023 2053 6f72 7420 616c 6c20 # Sort all \n+00020760: 6176 6169 6c61 626c 6520 7061 636b 6167 available packag\n+00020770: 6573 2069 6e74 6f20 6275 636b 6574 7320 es into buckets \n+00020780: 6279 2074 6f20 7468 6569 7220 636c 6169 by to their clai\n+00020790: 6d65 6420 6e61 6d65 0a20 2020 2020 2020 med name. \n+000207a0: 206e 616d 6573 3a20 4469 6374 5b73 7472 names: Dict[str\n+000207b0: 2c20 4c69 7374 5b4d 616e 6966 6573 745d , List[Manifest]\n+000207c0: 5d20 3d20 636f 6c6c 6563 7469 6f6e 732e ] = collections.\n+000207d0: 6465 6661 756c 7464 6963 7428 6c69 7374 defaultdict(list\n+000207e0: 290a 2020 2020 2020 2020 666f 7220 6d61 ). for ma\n+000207f0: 6e69 6665 7374 2069 6e20 7365 6c66 2e6c nifest in self.l\n+00020800: 6f61 645f 6d61 6e69 6665 7374 7328 293a oad_manifests():\n+00020810: 0a20 2020 2020 2020 2020 2020 206c 6f67 . log\n+00020820: 6765 722e 6465 6275 6728 2720 2025 732f ger.debug(' %s/\n+00020830: 6d61 6e69 6665 7374 2e6a 736f 6e27 2c20 manifest.json', \n+00020840: 6d61 6e69 6665 7374 2e70 6174 6829 0a20 manifest.path). \n+00020850: 2020 2020 2020 2020 2020 206e 616d 6573 names\n+00020860: 5b6d 616e 6966 6573 742e 6e61 6d65 5d2e [manifest.name].\n+00020870: 6170 7065 6e64 286d 616e 6966 6573 7429 append(manifest)\n+00020880: 0a20 2020 2020 2020 206c 6f67 6765 722e . logger.\n+00020890: 6465 6275 6728 2764 6f6e 652e 2729 0a0a debug('done.')..\n+000208a0: 2020 2020 2020 2020 6c6f 6767 6572 2e64 logger.d\n+000208b0: 6562 7567 2827 5365 6c65 6374 696e 6720 ebug('Selecting \n+000208c0: 7061 636b 6167 6573 2074 6f20 7365 7276 packages to serv\n+000208d0: 653a 2729 0a20 2020 2020 2020 2066 6f72 e:'). for\n+000208e0: 206e 616d 652c 2063 616e 6469 6461 7465 name, candidate\n+000208f0: 7320 696e 206e 616d 6573 2e69 7465 6d73 s in names.items\n+00020900: 2829 3a0a 2020 2020 2020 2020 2020 2020 ():. \n+00020910: 2320 466f 7220 6561 6368 2070 6163 6b61 # For each packa\n+00020920: 6765 206e 616d 652c 2069 7465 7261 7465 ge name, iterate\n+00020930: 2074 6865 2063 616e 6469 6461 7465 7320 the candidates \n+00020940: 696e 2064 6573 6365 6e64 696e 670a 2020 in descending. \n+00020950: 2020 2020 2020 2020 2020 2320 7072 696f # prio\n+00020960: 7269 7479 206f 7264 6572 2061 6e64 2073 rity order and s\n+00020970: 656c 6563 7420 7468 6520 6669 7273 7420 elect the first \n+00020980: 6f6e 6520 7768 6963 6820 7061 7373 6573 one which passes\n+00020990: 2061 6c6c 2063 6865 636b 730a 2020 2020 all checks. \n+000209a0: 2020 2020 2020 2020 666f 7220 6361 6e64 for cand\n+000209b0: 6964 6174 6520 696e 2073 6f72 7465 6428 idate in sorted(\n+000209c0: 6361 6e64 6964 6174 6573 2c20 6b65 793d candidates, key=\n+000209d0: 6c61 6d62 6461 206d 616e 6966 6573 743a lambda manifest:\n+000209e0: 206d 616e 6966 6573 742e 7072 696f 7269 manifest.priori\n+000209f0: 7479 2c20 7265 7665 7273 653d 5472 7565 ty, reverse=True\n+00020a00: 293a 0a20 2020 2020 2020 2020 2020 2020 ):. \n+00020a10: 2020 2074 7279 3a0a 2020 2020 2020 2020 try:. \n+00020a20: 2020 2020 2020 2020 2020 2020 6966 2073 if s\n+00020a30: 656c 662e 6368 6563 6b5f 636f 6e64 6974 elf.check_condit\n+00020a40: 696f 6e73 2863 616e 6469 6461 7465 293a ions(candidate):\n+00020a50: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+00020a60: 2020 2020 2020 2020 206c 6f67 6765 722e logger.\n+00020a70: 6465 6275 6728 2720 2063 7265 6174 696e debug(' creatin\n+00020a80: 6720 7061 636b 6167 6520 2573 202d 3e20 g package %s -> \n+00020a90: 2573 272c 206e 616d 652c 2063 616e 6469 %s', name, candi\n+00020aa0: 6461 7465 2e70 6174 6829 0a20 2020 2020 date.path). \n+00020ab0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00020ac0: 2020 2079 6965 6c64 206e 616d 652c 2050 yield name, P\n+00020ad0: 6163 6b61 6765 2863 616e 6469 6461 7465 ackage(candidate\n+00020ae0: 290a 2020 2020 2020 2020 2020 2020 2020 ). \n+00020af0: 2020 2020 2020 2020 2020 6272 6561 6b0a break.\n+00020b00: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00020b10: 6578 6365 7074 204a 736f 6e45 7272 6f72 except JsonError\n+00020b20: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n+00020b30: 2020 2020 2020 6c6f 6767 6572 2e77 6172 logger.war\n+00020b40: 6e69 6e67 2827 2020 2573 3a20 6967 6e6f ning(' %s: igno\n+00020b50: 7269 6e67 2070 6163 6b61 6765 2077 6974 ring package wit\n+00020b60: 6820 696e 7661 6c69 6420 6d61 6e69 6665 h invalid manife\n+00020b70: 7374 2066 696c 6527 2c20 6361 6e64 6964 st file', candid\n+00020b80: 6174 652e 7061 7468 290a 0a20 2020 2020 ate.path).. \n+00020b90: 2020 2020 2020 2020 2020 206c 6f67 6765 logge\n+00020ba0: 722e 6465 6275 6728 2720 2069 676e 6f72 r.debug(' ignor\n+00020bb0: 696e 6720 2573 3a20 756e 6d65 7420 636f ing %s: unmet co\n+00020bc0: 6e64 6974 696f 6e73 272c 2063 616e 6469 nditions', candi\n+00020bd0: 6461 7465 2e70 6174 6829 0a20 2020 2020 date.path). \n+00020be0: 2020 206c 6f67 6765 722e 6465 6275 6728 logger.debug(\n+00020bf0: 2764 6f6e 652e 2729 0a0a 0a63 6c61 7373 'done.')...class\n+00020c00: 2050 6163 6b61 6765 7328 6275 732e 4f62 Packages(bus.Ob\n+00020c10: 6a65 6374 2c20 696e 7465 7266 6163 653d ject, interface=\n+00020c20: 2763 6f63 6b70 6974 2e50 6163 6b61 6765 'cockpit.Package\n+00020c30: 7327 293a 0a20 2020 206c 6f61 6465 723a s'):. loader:\n+00020c40: 2050 6163 6b61 6765 734c 6f61 6465 720a PackagesLoader.\n+00020c50: 2020 2020 6c69 7374 656e 6572 3a20 4f70 listener: Op\n+00020c60: 7469 6f6e 616c 5b50 6163 6b61 6765 734c tional[PackagesL\n+00020c70: 6973 7465 6e65 725d 0a20 2020 2070 6163 istener]. pac\n+00020c80: 6b61 6765 733a 2044 6963 745b 7374 722c kages: Dict[str,\n+00020c90: 2050 6163 6b61 6765 5d0a 2020 2020 7361 Package]. sa\n+00020ca0: 775f 6669 7273 745f 7265 6c6f 6164 5f68 w_first_reload_h\n+00020cb0: 696e 743a 2062 6f6f 6c0a 0a20 2020 2064 int: bool.. d\n+00020cc0: 6566 205f 5f69 6e69 745f 5f28 7365 6c66 ef __init__(self\n+00020cd0: 2c20 6c69 7374 656e 6572 3a20 4f70 7469 , listener: Opti\n+00020ce0: 6f6e 616c 5b50 6163 6b61 6765 734c 6973 onal[PackagesLis\n+00020cf0: 7465 6e65 725d 203d 204e 6f6e 652c 206c tener] = None, l\n+00020d00: 6f61 6465 723a 204f 7074 696f 6e61 6c5b oader: Optional[\n+00020d10: 5061 636b 6167 6573 4c6f 6164 6572 5d20 PackagesLoader] \n+00020d20: 3d20 4e6f 6e65 293a 0a20 2020 2020 2020 = None):. \n+00020d30: 2073 656c 662e 6c69 7374 656e 6572 203d self.listener =\n+00020d40: 206c 6973 7465 6e65 720a 2020 2020 2020 listener. \n+00020d50: 2020 7365 6c66 2e6c 6f61 6465 7220 3d20 self.loader = \n+00020d60: 6c6f 6164 6572 206f 7220 5061 636b 6167 loader or Packag\n+00020d70: 6573 4c6f 6164 6572 2829 0a20 2020 2020 esLoader(). \n+00020d80: 2020 2073 656c 662e 6c6f 6164 2829 0a0a self.load()..\n+00020d90: 2020 2020 2020 2020 2320 5265 6c6f 6164 # Reload\n+00020da0: 696e 6720 7468 6520 5368 656c 6c20 696e ing the Shell in\n+00020db0: 2074 6865 2062 726f 7773 6572 2073 686f the browser sho\n+00020dc0: 756c 6420 7265 6c6f 6164 2074 6865 0a20 uld reload the. \n+00020dd0: 2020 2020 2020 2023 2070 6163 6b61 6765 # package\n+00020de0: 732e 2020 5468 6973 2069 7320 696d 706c s. This is impl\n+00020df0: 656d 656e 7465 6420 6279 2068 6176 696e emented by havin\n+00020e00: 6720 7468 6520 5368 656c 6c20 6361 6c6c g the Shell call\n+00020e10: 0a20 2020 2020 2020 2023 2072 656c 6f61 . # reloa\n+00020e20: 645f 6869 6e74 2077 6865 6e65 7665 7220 d_hint whenever \n+00020e30: 6974 2073 7461 7274 732e 2020 5468 6520 it starts. The \n+00020e40: 6669 7273 7420 6361 6c6c 206f 6620 7468 first call of th\n+00020e50: 6973 0a20 2020 2020 2020 2023 206d 6574 is. # met\n+00020e60: 686f 6420 696e 2065 6163 6820 7365 7373 hod in each sess\n+00020e70: 696f 6e20 6973 2069 676e 6f72 6564 2073 ion is ignored s\n+00020e80: 6f20 7468 6174 2070 6163 6b61 6765 7320 o that packages \n+00020e90: 6172 6520 6e6f 740a 2020 2020 2020 2020 are not. \n+00020ea0: 2320 6c6f 6164 6564 2074 7769 6365 2072 # loaded twice r\n+00020eb0: 6967 6874 2061 6674 6572 206c 6f67 6769 ight after loggi\n+00020ec0: 6e67 2069 6e2e 0a20 2020 2020 2020 2023 ng in.. #\n+00020ed0: 0a20 2020 2020 2020 2073 656c 662e 7361 . self.sa\n+00020ee0: 775f 6669 7273 745f 7265 6c6f 6164 5f68 w_first_reload_h\n+00020ef0: 696e 7420 3d20 4661 6c73 650a 0a20 2020 int = False.. \n+00020f00: 2064 6566 206c 6f61 6428 7365 6c66 2920 def load(self) \n+00020f10: 2d3e 204e 6f6e 653a 0a20 2020 2020 2020 -> None:. \n+00020f20: 2073 656c 662e 7061 636b 6167 6573 203d self.packages =\n+00020f30: 2064 6963 7428 7365 6c66 2e6c 6f61 6465 dict(self.loade\n+00020f40: 722e 6c6f 6164 5f70 6163 6b61 6765 7328 r.load_packages(\n+00020f50: 2929 0a20 2020 2020 2020 2073 656c 662e )). self.\n+00020f60: 6d61 6e69 6665 7374 7320 3d20 6a73 6f6e manifests = json\n+00020f70: 2e64 756d 7073 287b 6e61 6d65 3a20 6469 .dumps({name: di\n+00020f80: 6374 2870 6163 6b61 6765 2e6d 616e 6966 ct(package.manif\n+00020f90: 6573 7429 2066 6f72 206e 616d 652c 2070 est) for name, p\n+00020fa0: 6163 6b61 6765 2069 6e20 7365 6c66 2e70 ackage in self.p\n+00020fb0: 6163 6b61 6765 732e 6974 656d 7328 297d ackages.items()}\n+00020fc0: 290a 2020 2020 2020 2020 6c6f 6767 6572 ). logger\n+00020fd0: 2e64 6562 7567 2827 5061 636b 6167 6573 .debug('Packages\n+00020fe0: 206c 6f61 6465 643a 2025 7327 2c20 6c69 loaded: %s', li\n+00020ff0: 7374 2873 656c 662e 7061 636b 6167 6573 st(self.packages\n+00021000: 2929 0a0a 2020 2020 6465 6620 7368 6f77 )).. def show\n+00021010: 2873 656c 6629 3a0a 2020 2020 2020 2020 (self):. \n+00021020: 666f 7220 6e61 6d65 2069 6e20 736f 7274 for name in sort\n+00021030: 6564 2873 656c 662e 7061 636b 6167 6573 ed(self.packages\n+00021040: 293a 0a20 2020 2020 2020 2020 2020 2070 ):. p\n+00021050: 6163 6b61 6765 203d 2073 656c 662e 7061 ackage = self.pa\n+00021060: 636b 6167 6573 5b6e 616d 655d 0a20 2020 ckages[name]. \n+00021070: 2020 2020 2020 2020 206d 656e 7569 7465 menuite\n+00021080: 6d73 203d 205b 5d0a 2020 2020 2020 2020 ms = []. \n+00021090: 2020 2020 666f 7220 656e 7472 7920 696e for entry in\n+000210a0: 2069 7465 7274 6f6f 6c73 2e63 6861 696e itertools.chain\n+000210b0: 280a 2020 2020 2020 2020 2020 2020 2020 (. \n+000210c0: 2020 2020 2020 7061 636b 6167 652e 6d61 package.ma\n+000210d0: 6e69 6665 7374 2e67 6574 2827 6d65 6e75 nifest.get('menu\n+000210e0: 272c 207b 7d29 2e76 616c 7565 7328 292c ', {}).values(),\n+000210f0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+00021100: 2020 2020 2070 6163 6b61 6765 2e6d 616e package.man\n+00021110: 6966 6573 742e 6765 7428 2774 6f6f 6c73 ifest.get('tools\n+00021120: 272c 207b 7d29 2e76 616c 7565 7328 2929 ', {}).values())\n+00021130: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n+00021140: 2020 7769 7468 2063 6f6e 7465 7874 6c69 with contextli\n+00021150: 622e 7375 7070 7265 7373 284b 6579 4572 b.suppress(KeyEr\n+00021160: 726f 7229 3a0a 2020 2020 2020 2020 2020 ror):. \n+00021170: 2020 2020 2020 2020 2020 6d65 6e75 6974 menuit\n+00021180: 656d 732e 6170 7065 6e64 2865 6e74 7279 ems.append(entry\n+00021190: 5b27 6c61 6265 6c27 5d29 0a20 2020 2020 ['label']). \n+000211a0: 2020 2020 2020 2070 7269 6e74 2866 277b print(f'{\n+000211b0: 6e61 6d65 3a32 307d 207b 222c 2022 2e6a name:20} {\", \".j\n+000211c0: 6f69 6e28 6d65 6e75 6974 656d 7329 3a34 oin(menuitems):4\n+000211d0: 307d 207b 7061 636b 6167 652e 7061 7468 0} {package.path\n+000211e0: 7d27 290a 0a20 2020 2064 6566 2067 6574 }').. def get\n+000211f0: 5f62 7269 6467 655f 636f 6e66 6967 7328 _bridge_configs(\n+00021200: 7365 6c66 2920 2d3e 2053 6571 7565 6e63 self) -> Sequenc\n+00021210: 655b 4272 6964 6765 436f 6e66 6967 5d3a e[BridgeConfig]:\n+00021220: 0a20 2020 2020 2020 2064 6566 2079 6965 . def yie\n+00021230: 6c64 5f63 6f6e 6669 6773 2829 3a0a 2020 ld_configs():. \n+00021240: 2020 2020 2020 2020 2020 666f 7220 7061 for pa\n+00021250: 636b 6167 6520 696e 2073 6f72 7465 6428 ckage in sorted(\n+00021260: 7365 6c66 2e70 6163 6b61 6765 732e 7661 self.packages.va\n+00021270: 6c75 6573 2829 2c20 6b65 793d 6c61 6d62 lues(), key=lamb\n+00021280: 6461 2070 6163 6b61 6765 3a20 2d70 6163 da package: -pac\n+00021290: 6b61 6765 2e70 7269 6f72 6974 7929 3a0a kage.priority):.\n+000212a0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000212b0: 7969 656c 6420 6672 6f6d 2070 6163 6b61 yield from packa\n+000212c0: 6765 2e6d 616e 6966 6573 742e 6272 6964 ge.manifest.brid\n+000212d0: 6765 730a 2020 2020 2020 2020 7265 7475 ges. retu\n+000212e0: 726e 2074 7570 6c65 2879 6965 6c64 5f63 rn tuple(yield_c\n+000212f0: 6f6e 6669 6773 2829 290a 0a20 2020 2023 onfigs()).. #\n+00021300: 2044 2d42 7573 2049 6e74 6572 6661 6365 D-Bus Interface\n+00021310: 0a20 2020 206d 616e 6966 6573 7473 203d . manifests =\n+00021320: 2062 7573 2e49 6e74 6572 6661 6365 2e50 bus.Interface.P\n+00021330: 726f 7065 7274 7928 2773 272c 2076 616c roperty('s', val\n+00021340: 7565 3d22 7b7d 2229 0a0a 2020 2020 4062 ue=\"{}\").. @b\n+00021350: 7573 2e49 6e74 6572 6661 6365 2e4d 6574 us.Interface.Met\n+00021360: 686f 6428 290a 2020 2020 6465 6620 7265 hod(). def re\n+00021370: 6c6f 6164 2873 656c 6629 3a0a 2020 2020 load(self):. \n+00021380: 2020 2020 7365 6c66 2e6c 6f61 6428 290a self.load().\n+00021390: 2020 2020 2020 2020 6966 2073 656c 662e if self.\n+000213a0: 6c69 7374 656e 6572 2069 7320 6e6f 7420 listener is not \n+000213b0: 4e6f 6e65 3a0a 2020 2020 2020 2020 2020 None:. \n+000213c0: 2020 7365 6c66 2e6c 6973 7465 6e65 722e self.listener.\n+000213d0: 7061 636b 6167 6573 5f6c 6f61 6465 6428 packages_loaded(\n+000213e0: 290a 0a20 2020 2040 6275 732e 496e 7465 ).. @bus.Inte\n+000213f0: 7266 6163 652e 4d65 7468 6f64 2829 0a20 rface.Method(). \n+00021400: 2020 2064 6566 2072 656c 6f61 645f 6869 def reload_hi\n+00021410: 6e74 2873 656c 6629 3a0a 2020 2020 2020 nt(self):. \n+00021420: 2020 6966 2073 656c 662e 7361 775f 6669 if self.saw_fi\n+00021430: 7273 745f 7265 6c6f 6164 5f68 696e 743a rst_reload_hint:\n+00021440: 0a20 2020 2020 2020 2020 2020 2073 656c . sel\n+00021450: 662e 7265 6c6f 6164 2829 0a20 2020 2020 f.reload(). \n+00021460: 2020 2073 656c 662e 7361 775f 6669 7273 self.saw_firs\n+00021470: 745f 7265 6c6f 6164 5f68 696e 7420 3d20 t_reload_hint = \n+00021480: 5472 7565 0a0a 2020 2020 6465 6620 6c6f True.. def lo\n+00021490: 6164 5f6d 616e 6966 6573 7473 5f6a 7328 ad_manifests_js(\n+000214a0: 7365 6c66 2c20 6865 6164 6572 733a 204a self, headers: J\n+000214b0: 736f 6e4f 626a 6563 7429 202d 3e20 446f sonObject) -> Do\n+000214c0: 6375 6d65 6e74 3a0a 2020 2020 2020 2020 cument:. \n+000214d0: 6c6f 6767 6572 2e64 6562 7567 2827 5365 logger.debug('Se\n+000214e0: 7276 696e 6720 2f6d 616e 6966 6573 7473 rving /manifests\n+000214f0: 2e6a 7327 290a 0a20 2020 2020 2020 2063 .js').. c\n+00021500: 6875 6e6b 733a 204c 6973 745b 6279 7465 hunks: List[byte\n+00021510: 735d 203d 205b 5d0a 0a20 2020 2020 2020 s] = [].. \n+00021520: 2023 2053 656e 6420 7468 6520 7472 616e # Send the tran\n+00021530: 736c 6174 696f 6e73 2072 6571 7569 7265 slations require\n+00021540: 6420 666f 7220 7468 6520 6d61 6e69 6665 d for the manife\n+00021550: 7374 2066 696c 6573 2c20 6672 6f6d 2065 st files, from e\n+00021560: 6163 6820 7061 636b 6167 650a 2020 2020 ach package. \n+00021570: 2020 2020 6c6f 6361 6c65 7320 3d20 7061 locales = pa\n+00021580: 7273 655f 6163 6365 7074 5f6c 616e 6775 rse_accept_langu\n+00021590: 6167 6528 6765 745f 7374 7228 6865 6164 age(get_str(head\n+000215a0: 6572 732c 2027 4163 6365 7074 2d4c 616e ers, 'Accept-Lan\n+000215b0: 6775 6167 6527 2c20 2727 2929 0a20 2020 guage', '')). \n+000215c0: 2020 2020 2066 6f72 206e 616d 652c 2070 for name, p\n+000215d0: 6163 6b61 6765 2069 6e20 7365 6c66 2e70 ackage in self.p\n+000215e0: 6163 6b61 6765 732e 6974 656d 7328 293a ackages.items():\n+000215f0: 0a20 2020 2020 2020 2020 2020 2069 6620 . if \n+00021600: 6e61 6d65 2069 6e20 5b27 7374 6174 6963 name in ['static\n+00021610: 272c 2027 6261 7365 3127 5d3a 0a20 2020 ', 'base1']:. \n+00021620: 2020 2020 2020 2020 2020 2020 2063 6f6e con\n+00021630: 7469 6e75 650a 0a20 2020 2020 2020 2020 tinue.. \n+00021640: 2020 2023 2066 696e 645f 7472 616e 736c # find_transl\n+00021650: 6174 696f 6e20 7769 6c6c 2061 6c77 6179 ation will alway\n+00021660: 7320 6669 6e64 2061 7420 6c65 6173 7420 s find at least \n+00021670: 2765 6e27 0a20 2020 2020 2020 2020 2020 'en'. \n+00021680: 2074 7261 6e73 6c61 7469 6f6e 203d 2070 translation = p\n+00021690: 6163 6b61 6765 2e6c 6f61 645f 7472 616e ackage.load_tran\n+000216a0: 736c 6174 696f 6e28 2770 6f2e 6d61 6e69 slation('po.mani\n+000216b0: 6665 7374 2e6a 7327 2c20 6c6f 6361 6c65 fest.js', locale\n+000216c0: 7329 0a20 2020 2020 2020 2020 2020 2077 s). w\n+000216d0: 6974 6820 7472 616e 736c 6174 696f 6e2e ith translation.\n+000216e0: 6461 7461 3a0a 2020 2020 2020 2020 2020 data:. \n+000216f0: 2020 2020 2020 6966 2074 7261 6e73 6c61 if transla\n+00021700: 7469 6f6e 2e63 6f6e 7465 6e74 5f65 6e63 tion.content_enc\n+00021710: 6f64 696e 6720 3d3d 2027 677a 6970 273a oding == 'gzip':\n+00021720: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+00021730: 2020 2020 2064 6174 6120 3d20 677a 6970 data = gzip\n+00021740: 2e64 6563 6f6d 7072 6573 7328 7472 616e .decompress(tran\n+00021750: 736c 6174 696f 6e2e 6461 7461 2e72 6561 slation.data.rea\n+00021760: 6428 2929 0a20 2020 2020 2020 2020 2020 d()). \n+00021770: 2020 2020 2065 6c73 653a 0a20 2020 2020 else:. \n+00021780: 2020 2020 2020 2020 2020 2020 2020 2064 d\n+00021790: 6174 6120 3d20 7472 616e 736c 6174 696f ata = translatio\n+000217a0: 6e2e 6461 7461 2e72 6561 6428 290a 0a20 n.data.read().. \n+000217b0: 2020 2020 2020 2020 2020 2063 6875 6e6b chunk\n+000217c0: 732e 6170 7065 6e64 2864 6174 6129 0a0a s.append(data)..\n+000217d0: 2020 2020 2020 2020 6368 756e 6b73 2e61 chunks.a\n+000217e0: 7070 656e 6428 6222 2222 0a20 2020 2020 ppend(b\"\"\". \n+000217f0: 2020 2020 2020 2028 6675 6e63 7469 6f6e (function\n+00021800: 2028 726f 6f74 2c20 6461 7461 2920 7b0a (root, data) {.\n+00021810: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00021820: 6966 2028 7479 7065 6f66 2064 6566 696e if (typeof defin\n+00021830: 6520 3d3d 3d20 2766 756e 6374 696f 6e27 e === 'function'\n+00021840: 2026 2620 6465 6669 6e65 2e61 6d64 2920 && define.amd) \n+00021850: 7b0a 2020 2020 2020 2020 2020 2020 2020 {. \n+00021860: 2020 2020 2020 6465 6669 6e65 2864 6174 define(dat\n+00021870: 6129 3b0a 2020 2020 2020 2020 2020 2020 a);. \n+00021880: 2020 2020 7d0a 0a20 2020 2020 2020 2020 }.. \n+00021890: 2020 2020 2020 2069 6620 2874 7970 656f if (typeo\n+000218a0: 6620 636f 636b 7069 7420 3d3d 3d20 276f f cockpit === 'o\n+000218b0: 626a 6563 7427 2920 7b0a 2020 2020 2020 bject') {. \n+000218c0: 2020 2020 2020 2020 2020 2020 2020 636f co\n+000218d0: 636b 7069 742e 6d61 6e69 6665 7374 7320 ckpit.manifests \n+000218e0: 3d20 6461 7461 3b0a 2020 2020 2020 2020 = data;. \n+000218f0: 2020 2020 2020 2020 7d20 656c 7365 207b } else {\n+00021900: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+00021910: 2020 2020 2072 6f6f 742e 6d61 6e69 6665 root.manife\n+00021920: 7374 7320 3d20 6461 7461 3b0a 2020 2020 sts = data;. \n+00021930: 2020 2020 2020 2020 2020 2020 7d0a 2020 }. \n+00021940: 2020 2020 2020 2020 2020 7d28 7468 6973 }(this\n+00021950: 2c20 2222 2220 2b20 7365 6c66 2e6d 616e , \"\"\" + self.man\n+00021960: 6966 6573 7473 2e65 6e63 6f64 6528 2920 ifests.encode() \n+00021970: 2b20 6222 2222 2929 2222 2229 0a0a 2020 + b\"\"\"))\"\"\").. \n+00021980: 2020 2020 2020 7265 7475 726e 2044 6f63 return Doc\n+00021990: 756d 656e 7428 696f 2e42 7974 6573 494f ument(io.BytesIO\n+000219a0: 2862 275c 6e27 2e6a 6f69 6e28 6368 756e (b'\\n'.join(chun\n+000219b0: 6b73 2929 2c20 2774 6578 742f 6a61 7661 ks)), 'text/java\n+000219c0: 7363 7269 7074 2729 0a0a 2020 2020 6465 script').. de\n+000219d0: 6620 6c6f 6164 5f6d 616e 6966 6573 7473 f load_manifests\n+000219e0: 5f6a 736f 6e28 7365 6c66 2920 2d3e 2044 _json(self) -> D\n+000219f0: 6f63 756d 656e 743a 0a20 2020 2020 2020 ocument:. \n+00021a00: 206c 6f67 6765 722e 6465 6275 6728 2753 logger.debug('S\n+00021a10: 6572 7669 6e67 202f 6d61 6e69 6665 7374 erving /manifest\n+00021a20: 732e 6a73 6f6e 2729 0a20 2020 2020 2020 s.json'). \n+00021a30: 2072 6574 7572 6e20 446f 6375 6d65 6e74 return Document\n+00021a40: 2869 6f2e 4279 7465 7349 4f28 7365 6c66 (io.BytesIO(self\n+00021a50: 2e6d 616e 6966 6573 7473 2e65 6e63 6f64 .manifests.encod\n+00021a60: 6528 2929 2c20 2761 7070 6c69 6361 7469 e()), 'applicati\n+00021a70: 6f6e 2f6a 736f 6e27 290a 0a20 2020 2050 on/json').. P\n+00021a80: 4154 485f 5245 203d 2072 652e 636f 6d70 ATH_RE = re.comp\n+00021a90: 696c 6528 0a20 2020 2020 2020 2072 272f ile(. r'/\n+00021aa0: 2720 2020 2020 2020 2020 2020 2020 2020 ' \n+00021ab0: 2020 2020 2320 6c65 6164 696e 6720 272f # leading '/\n+00021ac0: 270a 2020 2020 2020 2020 7227 283f 3a28 '. r'(?:(\n+00021ad0: 5b5e 2f5d 2b29 2f29 3f27 2020 2020 2020 [^/]+)/)?' \n+00021ae0: 2023 206f 7074 696f 6e61 6c20 6c65 6164 # optional lead\n+00021af0: 696e 6720 7061 7468 2063 6f6d 706f 6e65 ing path compone\n+00021b00: 6e74 0a20 2020 2020 2020 2072 2728 283f nt. r'((?\n+00021b10: 3a5b 5e2f 5d2b 2f29 2a5b 5e2f 5d2b 2927 :[^/]+/)*[^/]+)'\n+00021b20: 2020 2320 7265 6d61 696e 696e 6720 7061 # remaining pa\n+00021b30: 7468 2063 6f6d 706f 6e65 6e74 730a 2020 th components. \n+00021b40: 2020 290a 0a20 2020 2064 6566 206c 6f61 ).. def loa\n+00021b50: 645f 7061 7468 2873 656c 662c 2070 6174 d_path(self, pat\n+00021b60: 683a 2073 7472 2c20 6865 6164 6572 733a h: str, headers:\n+00021b70: 204a 736f 6e4f 626a 6563 7429 202d 3e20 JsonObject) -> \n+00021b80: 446f 6375 6d65 6e74 3a0a 2020 2020 2020 Document:. \n+00021b90: 2020 6c6f 6767 6572 2e64 6562 7567 2827 logger.debug('\n+00021ba0: 7061 636b 6167 6573 3a20 7365 7276 696e packages: servin\n+00021bb0: 6720 2573 272c 2070 6174 6829 0a0a 2020 g %s', path).. \n+00021bc0: 2020 2020 2020 6d61 7463 6820 3d20 7365 match = se\n+00021bd0: 6c66 2e50 4154 485f 5245 2e66 756c 6c6d lf.PATH_RE.fullm\n+00021be0: 6174 6368 2870 6174 6829 0a20 2020 2020 atch(path). \n+00021bf0: 2020 2069 6620 6d61 7463 6820 6973 204e if match is N\n+00021c00: 6f6e 653a 0a20 2020 2020 2020 2020 2020 one:. \n+00021c10: 2072 6169 7365 2056 616c 7565 4572 726f raise ValueErro\n+00021c20: 7228 6627 496e 7661 6c69 6420 4854 5450 r(f'Invalid HTTP\n+00021c30: 2070 6174 6820 7b70 6174 687d 2729 0a20 path {path}'). \n+00021c40: 2020 2020 2020 2070 6163 6b61 6765 6e61 packagena\n+00021c50: 6d65 2c20 6669 6c65 6e61 6d65 203d 206d me, filename = m\n+00021c60: 6174 6368 2e67 726f 7570 7328 290a 0a20 atch.groups().. \n+00021c70: 2020 2020 2020 2069 6620 7061 636b 6167 if packag\n+00021c80: 656e 616d 6520 6973 206e 6f74 204e 6f6e ename is not Non\n+00021c90: 653a 0a20 2020 2020 2020 2020 2020 2072 e:. r\n+00021ca0: 6574 7572 6e20 7365 6c66 2e70 6163 6b61 eturn self.packa\n+00021cb0: 6765 735b 7061 636b 6167 656e 616d 655d ges[packagename]\n+00021cc0: 2e6c 6f61 645f 7061 7468 2866 696c 656e .load_path(filen\n+00021cd0: 616d 652c 2068 6561 6465 7273 290a 2020 ame, headers). \n+00021ce0: 2020 2020 2020 656c 6966 2066 696c 656e elif filen\n+00021cf0: 616d 6520 3d3d 2027 6d61 6e69 6665 7374 ame == 'manifest\n+00021d00: 732e 6a73 273a 0a20 2020 2020 2020 2020 s.js':. \n+00021d10: 2020 2072 6574 7572 6e20 7365 6c66 2e6c return self.l\n+00021d20: 6f61 645f 6d61 6e69 6665 7374 735f 6a73 oad_manifests_js\n+00021d30: 2868 6561 6465 7273 290a 2020 2020 2020 (headers). \n+00021d40: 2020 656c 6966 2066 696c 656e 616d 6520 elif filename \n+00021d50: 3d3d 2027 6d61 6e69 6665 7374 732e 6a73 == 'manifests.js\n+00021d60: 6f6e 273a 0a20 2020 2020 2020 2020 2020 on':. \n+00021d70: 2072 6574 7572 6e20 7365 6c66 2e6c 6f61 return self.loa\n+00021d80: 645f 6d61 6e69 6665 7374 735f 6a73 6f6e d_manifests_json\n+00021d90: 2829 0a20 2020 2020 2020 2065 6c73 653a (). else:\n+00021da0: 0a20 2020 2020 2020 2020 2020 2072 6169 . rai\n+00021db0: 7365 204b 6579 4572 726f 720a 2727 272c se KeyError.''',\n+00021dc0: 0a20 2027 636f 636b 7069 742f 636f 6e66 . 'cockpit/conf\n+00021dd0: 6967 2e70 7927 3a20 6272 2727 2723 2054 ig.py': br'''# T\n+00021de0: 6869 7320 6669 6c65 2069 7320 7061 7274 his file is part\n+00021df0: 206f 6620 436f 636b 7069 742e 0a23 0a23 of Cockpit..#.#\n+00021e00: 2043 6f70 7972 6967 6874 2028 4329 2032 Copyright (C) 2\n+00021e10: 3032 3320 5265 6420 4861 742c 2049 6e63 023 Red Hat, Inc\n+00021e20: 2e0a 230a 2320 5468 6973 2070 726f 6772 ..#.# This progr\n+00021e30: 616d 2069 7320 6672 6565 2073 6f66 7477 am is free softw\n+00021e40: 6172 653a 2079 6f75 2063 616e 2072 6564 are: you can red\n+00021e50: 6973 7472 6962 7574 6520 6974 2061 6e64 istribute it and\n+00021e60: 2f6f 7220 6d6f 6469 6679 0a23 2069 7420 /or modify.# it \n+00021e70: 756e 6465 7220 7468 6520 7465 726d 7320 under the terms \n+00021e80: 6f66 2074 6865 2047 4e55 2047 656e 6572 of the GNU Gener\n+00021e90: 616c 2050 7562 6c69 6320 4c69 6365 6e73 al Public Licens\n+00021ea0: 6520 6173 2070 7562 6c69 7368 6564 2062 e as published b\n+00021eb0: 790a 2320 7468 6520 4672 6565 2053 6f66 y.# the Free Sof\n+00021ec0: 7477 6172 6520 466f 756e 6461 7469 6f6e tware Foundation\n+00021ed0: 2c20 6569 7468 6572 2076 6572 7369 6f6e , either version\n+00021ee0: 2033 206f 6620 7468 6520 4c69 6365 6e73 3 of the Licens\n+00021ef0: 652c 206f 720a 2320 2861 7420 796f 7572 e, or.# (at your\n+00021f00: 206f 7074 696f 6e29 2061 6e79 206c 6174 option) any lat\n+00021f10: 6572 2076 6572 7369 6f6e 2e0a 230a 2320 er version..#.# \n+00021f20: 5468 6973 2070 726f 6772 616d 2069 7320 This program is \n+00021f30: 6469 7374 7269 6275 7465 6420 696e 2074 distributed in t\n+00021f40: 6865 2068 6f70 6520 7468 6174 2069 7420 he hope that it \n+00021f50: 7769 6c6c 2062 6520 7573 6566 756c 2c0a will be useful,.\n+00021f60: 2320 6275 7420 5749 5448 4f55 5420 414e # but WITHOUT AN\n+00021f70: 5920 5741 5252 414e 5459 3b20 7769 7468 Y WARRANTY; with\n+00021f80: 6f75 7420 6576 656e 2074 6865 2069 6d70 out even the imp\n+00021f90: 6c69 6564 2077 6172 7261 6e74 7920 6f66 lied warranty of\n+00021fa0: 0a23 204d 4552 4348 414e 5441 4249 4c49 .# MERCHANTABILI\n+00021fb0: 5459 206f 7220 4649 544e 4553 5320 464f TY or FITNESS FO\n+00021fc0: 5220 4120 5041 5254 4943 554c 4152 2050 R A PARTICULAR P\n+00021fd0: 5552 504f 5345 2e20 2053 6565 2074 6865 URPOSE. See the\n+00021fe0: 0a23 2047 4e55 2047 656e 6572 616c 2050 .# GNU General P\n+00021ff0: 7562 6c69 6320 4c69 6365 6e73 6520 666f ublic License fo\n+00022000: 7220 6d6f 7265 2064 6574 6169 6c73 2e0a r more details..\n+00022010: 230a 2320 596f 7520 7368 6f75 6c64 2068 #.# You should h\n+00022020: 6176 6520 7265 6365 6976 6564 2061 2063 ave received a c\n+00022030: 6f70 7920 6f66 2074 6865 2047 4e55 2047 opy of the GNU G\n+00022040: 656e 6572 616c 2050 7562 6c69 6320 4c69 eneral Public Li\n+00022050: 6365 6e73 650a 2320 616c 6f6e 6720 7769 cense.# along wi\n+00022060: 7468 2074 6869 7320 7072 6f67 7261 6d2e th this program.\n+00022070: 2020 4966 206e 6f74 2c20 7365 6520 3c68 If not, see ...\n+000220a0: 696d 706f 7274 2063 6f6e 6669 6770 6172 import configpar\n+000220b0: 7365 720a 696d 706f 7274 206c 6f67 6769 ser.import loggi\n+000220c0: 6e67 0a69 6d70 6f72 7420 6f73 0a66 726f ng.import os.fro\n+000220d0: 6d20 7061 7468 6c69 6220 696d 706f 7274 m pathlib import\n+000220e0: 2050 6174 680a 0a66 726f 6d20 636f 636b Path..from cock\n+000220f0: 7069 742e 5f76 656e 646f 722e 7379 7374 pit._vendor.syst\n+00022100: 656d 645f 6374 7970 6573 2069 6d70 6f72 emd_ctypes impor\n+00022110: 7420 6275 730a 0a6c 6f67 6765 7220 3d20 t bus..logger = \n+00022120: 6c6f 6767 696e 672e 6765 744c 6f67 6765 logging.getLogge\n+00022130: 7228 5f5f 6e61 6d65 5f5f 290a 0a58 4447 r(__name__)..XDG\n+00022140: 5f43 4f4e 4649 475f 484f 4d45 203d 2050 _CONFIG_HOME = P\n+00022150: 6174 6828 6f73 2e67 6574 656e 7628 2758 ath(os.getenv('X\n+00022160: 4447 5f43 4f4e 4649 475f 484f 4d45 2729 DG_CONFIG_HOME')\n+00022170: 206f 7220 6f73 2e70 6174 682e 6578 7061 or os.path.expa\n+00022180: 6e64 7573 6572 2827 7e2f 2e63 6f6e 6669 nduser('~/.confi\n+00022190: 6727 2929 0a44 4f54 5f43 4f4e 4649 475f g')).DOT_CONFIG_\n+000221a0: 434f 434b 5049 5420 3d20 5844 475f 434f COCKPIT = XDG_CO\n+000221b0: 4e46 4947 5f48 4f4d 4520 2f20 2763 6f63 NFIG_HOME / 'coc\n+000221c0: 6b70 6974 270a 0a0a 6465 6620 6c6f 6f6b kpit'...def look\n+000221d0: 7570 5f63 6f6e 6669 6728 6669 6c65 6e61 up_config(filena\n+000221e0: 6d65 3a20 7374 7229 202d 3e20 5061 7468 me: str) -> Path\n+000221f0: 3a0a 2020 2020 636f 6e66 6967 5f64 6972 :. config_dir\n+00022200: 7320 3d20 6f73 2e65 6e76 6972 6f6e 2e67 s = os.environ.g\n+00022210: 6574 2827 5844 475f 434f 4e46 4947 5f44 et('XDG_CONFIG_D\n+00022220: 4952 5327 2c20 272f 6574 6327 292e 7370 IRS', '/etc').sp\n+00022230: 6c69 7428 273a 2729 0a20 2020 2066 616c lit(':'). fal\n+00022240: 6c62 6163 6b20 3d20 4e6f 6e65 0a20 2020 lback = None. \n+00022250: 2066 6f72 2063 6f6e 6669 675f 6469 7220 for config_dir \n+00022260: 696e 2063 6f6e 6669 675f 6469 7273 3a0a in config_dirs:.\n+00022270: 2020 2020 2020 2020 636f 6e66 6967 5f70 config_p\n+00022280: 6174 6820 3d20 5061 7468 2863 6f6e 6669 ath = Path(confi\n+00022290: 675f 6469 722c 2027 636f 636b 7069 7427 g_dir, 'cockpit'\n+000222a0: 2c20 6669 6c65 6e61 6d65 290a 2020 2020 , filename). \n+000222b0: 2020 2020 6966 206e 6f74 2066 616c 6c62 if not fallb\n+000222c0: 6163 6b3a 0a20 2020 2020 2020 2020 2020 ack:. \n+000222d0: 2066 616c 6c62 6163 6b20 3d20 636f 6e66 fallback = conf\n+000222e0: 6967 5f70 6174 680a 2020 2020 2020 2020 ig_path. \n+000222f0: 6966 2063 6f6e 6669 675f 7061 7468 2e65 if config_path.e\n+00022300: 7869 7374 7328 293a 0a20 2020 2020 2020 xists():. \n+00022310: 2020 2020 206c 6f67 6765 722e 6465 6275 logger.debu\n+00022320: 6728 276c 6f6f 6b75 705f 636f 6e66 6967 g('lookup_config\n+00022330: 2825 7329 3a20 666f 756e 6420 2573 272c (%s): found %s',\n+00022340: 2066 696c 656e 616d 652c 2063 6f6e 6669 filename, confi\n+00022350: 675f 7061 7468 290a 2020 2020 2020 2020 g_path). \n+00022360: 2020 2020 7265 7475 726e 2063 6f6e 6669 return confi\n+00022370: 675f 7061 7468 0a0a 2020 2020 2320 6465 g_path.. # de\n+00022380: 6661 756c 7420 746f 2074 6865 2066 6972 fault to the fir\n+00022390: 7374 2065 6e74 7279 2069 6e20 5844 475f st entry in XDG_\n+000223a0: 434f 4e46 4947 5f44 4952 533b 2074 6861 CONFIG_DIRS; tha\n+000223b0: 7427 7320 6e6f 7420 6163 636f 7264 696e t's not accordin\n+000223c0: 6720 746f 2074 6865 2073 7065 632c 0a20 g to the spec,. \n+000223d0: 2020 2023 2062 7574 2077 6861 7420 436f # but what Co\n+000223e0: 636b 7069 7420 6861 7320 646f 6e65 2066 ckpit has done f\n+000223f0: 6f72 2079 6561 7273 0a20 2020 206c 6f67 or years. log\n+00022400: 6765 722e 6465 6275 6728 276c 6f6f 6b75 ger.debug('looku\n+00022410: 705f 636f 6e66 6967 2825 7329 3a20 6465 p_config(%s): de\n+00022420: 6661 756c 7469 6e67 2074 6f20 2573 272c faulting to %s',\n+00022430: 2066 696c 656e 616d 652c 2066 616c 6c62 filename, fallb\n+00022440: 6163 6b29 0a20 2020 2061 7373 6572 7420 ack). assert \n+00022450: 6661 6c6c 6261 636b 2020 2320 6d79 7079 fallback # mypy\n+00022460: 3b20 636f 6e66 6967 5f64 6972 7320 616c ; config_dirs al\n+00022470: 7761 7973 2068 6173 2061 7420 6c65 6173 ways has at leas\n+00022480: 7420 6f6e 6520 7374 7269 6e67 0a20 2020 t one string. \n+00022490: 2072 6574 7572 6e20 6661 6c6c 6261 636b return fallback\n+000224a0: 0a0a 0a63 6c61 7373 2043 6f6e 6669 6728 ...class Config(\n+000224b0: 6275 732e 4f62 6a65 6374 2c20 696e 7465 bus.Object, inte\n+000224c0: 7266 6163 653d 2763 6f63 6b70 6974 2e43 rface='cockpit.C\n+000224d0: 6f6e 6669 6727 293a 0a20 2020 2064 6566 onfig'):. def\n+000224e0: 205f 5f69 6e69 745f 5f28 7365 6c66 293a __init__(self):\n+000224f0: 0a20 2020 2020 2020 2073 656c 662e 7265 . self.re\n+00022500: 6c6f 6164 2829 0a0a 2020 2020 4062 7573 load().. @bus\n+00022510: 2e49 6e74 6572 6661 6365 2e4d 6574 686f .Interface.Metho\n+00022520: 6428 6f75 745f 7479 7065 733d 2773 272c d(out_types='s',\n+00022530: 2069 6e5f 7479 7065 733d 2773 7327 290a in_types='ss').\n+00022540: 2020 2020 6465 6620 6765 745f 7374 7269 def get_stri\n+00022550: 6e67 2873 656c 662c 2073 6563 7469 6f6e ng(self, section\n+00022560: 2c20 6b65 7929 3a0a 2020 2020 2020 2020 , key):. \n+00022570: 7472 793a 0a20 2020 2020 2020 2020 2020 try:. \n+00022580: 2072 6574 7572 6e20 7365 6c66 2e63 6f6e return self.con\n+00022590: 6669 675b 7365 6374 696f 6e5d 5b6b 6579 fig[section][key\n+000225a0: 5d0a 2020 2020 2020 2020 6578 6365 7074 ]. except\n+000225b0: 204b 6579 4572 726f 7220 6173 2065 7863 KeyError as exc\n+000225c0: 3a0a 2020 2020 2020 2020 2020 2020 7261 :. ra\n+000225d0: 6973 6520 6275 732e 4275 7345 7272 6f72 ise bus.BusError\n+000225e0: 2827 636f 636b 7069 742e 436f 6e66 6967 ('cockpit.Config\n+000225f0: 2e4b 6579 4572 726f 7227 2c20 6627 6b65 .KeyError', f'ke\n+00022600: 7920 7b6b 6579 7d20 696e 2073 6563 7469 y {key} in secti\n+00022610: 6f6e 207b 7365 6374 696f 6e7d 2064 6f65 on {section} doe\n+00022620: 7320 6e6f 7420 6578 6973 7427 2920 6672 s not exist') fr\n+00022630: 6f6d 2065 7863 0a0a 2020 2020 4062 7573 om exc.. @bus\n+00022640: 2e49 6e74 6572 6661 6365 2e4d 6574 686f .Interface.Metho\n+00022650: 6428 6f75 745f 7479 7065 733d 2775 272c d(out_types='u',\n+00022660: 2069 6e5f 7479 7065 733d 2773 7375 7575 in_types='ssuuu\n+00022670: 2729 0a20 2020 2064 6566 2067 6574 5f75 '). def get_u\n+00022680: 5f69 6e74 2873 656c 662c 2073 6563 7469 _int(self, secti\n+00022690: 6f6e 2c20 6b65 792c 2064 6566 6175 6c74 on, key, default\n+000226a0: 2c20 6d61 7869 6d75 6d2c 206d 696e 696d , maximum, minim\n+000226b0: 756d 293a 0a20 2020 2020 2020 2074 7279 um):. try\n+000226c0: 3a0a 2020 2020 2020 2020 2020 2020 7661 :. va\n+000226d0: 6c75 6520 3d20 7365 6c66 2e63 6f6e 6669 lue = self.confi\n+000226e0: 675b 7365 6374 696f 6e5d 5b6b 6579 5d0a g[section][key].\n+000226f0: 2020 2020 2020 2020 6578 6365 7074 204b except K\n+00022700: 6579 4572 726f 723a 0a20 2020 2020 2020 eyError:. \n+00022710: 2020 2020 2072 6574 7572 6e20 6465 6661 return defa\n+00022720: 756c 740a 0a20 2020 2020 2020 2074 7279 ult.. try\n+00022730: 3a0a 2020 2020 2020 2020 2020 2020 696e :. in\n+00022740: 745f 7661 6c20 3d20 696e 7428 7661 6c75 t_val = int(valu\n+00022750: 6529 0a20 2020 2020 2020 2065 7863 6570 e). excep\n+00022760: 7420 5661 6c75 6545 7272 6f72 3a0a 2020 t ValueError:. \n+00022770: 2020 2020 2020 2020 2020 6c6f 6767 6572 logger\n+00022780: 2e77 6172 6e69 6e67 2827 636f 636b 7069 .warning('cockpi\n+00022790: 742e 636f 6e66 3a20 5b25 735d 2025 7320 t.conf: [%s] %s \n+000227a0: 6973 206e 6f74 2061 6e20 696e 7465 6765 is not an intege\n+000227b0: 7227 2c20 7365 6374 696f 6e2c 206b 6579 r', section, key\n+000227c0: 290a 2020 2020 2020 2020 2020 2020 7265 ). re\n+000227d0: 7475 726e 2064 6566 6175 6c74 0a0a 2020 turn default.. \n+000227e0: 2020 2020 2020 7265 7475 726e 206d 696e return min\n+000227f0: 286d 6178 2869 6e74 5f76 616c 2c20 6d69 (max(int_val, mi\n+00022800: 6e69 6d75 6d29 2c20 6d61 7869 6d75 6d29 nimum), maximum)\n+00022810: 0a0a 2020 2020 4062 7573 2e49 6e74 6572 .. @bus.Inter\n+00022820: 6661 6365 2e4d 6574 686f 6428 290a 2020 face.Method(). \n+00022830: 2020 6465 6620 7265 6c6f 6164 2873 656c def reload(sel\n+00022840: 6629 3a0a 2020 2020 2020 2020 7365 6c66 f):. self\n+00022850: 2e63 6f6e 6669 6720 3d20 636f 6e66 6967 .config = config\n+00022860: 7061 7273 6572 2e43 6f6e 6669 6750 6172 parser.ConfigPar\n+00022870: 7365 7228 696e 7465 7270 6f6c 6174 696f ser(interpolatio\n+00022880: 6e3d 4e6f 6e65 290a 2020 2020 2020 2020 n=None). \n+00022890: 636f 636b 7069 745f 636f 6e66 203d 206c cockpit_conf = l\n+000228a0: 6f6f 6b75 705f 636f 6e66 6967 2827 636f ookup_config('co\n+000228b0: 636b 7069 742e 636f 6e66 2729 0a20 2020 ckpit.conf'). \n+000228c0: 2020 2020 206c 6f67 6765 722e 6465 6275 logger.debu\n+000228d0: 6728 2263 6f63 6b70 6974 2e43 6f6e 6669 g(\"cockpit.Confi\n+000228e0: 673a 206c 6f61 6469 6e67 2025 7322 2c20 g: loading %s\", \n+000228f0: 636f 636b 7069 745f 636f 6e66 290a 2020 cockpit_conf). \n+00022900: 2020 2020 2020 2320 7468 6973 206d 6179 # this may\n+00022910: 206e 6f74 2065 7869 7374 2c20 6275 7420 not exist, but \n+00022920: 6974 2773 206f 6b20 746f 206e 6f74 2068 it's ok to not h\n+00022930: 6176 6520 6120 636f 6e66 6967 2066 696c ave a config fil\n+00022940: 6520 616e 6420 7468 7573 206c 6561 7665 e and thus leave\n+00022950: 2073 656c 662e 636f 6e66 6967 2065 6d70 self.config emp\n+00022960: 7479 0a20 2020 2020 2020 2073 656c 662e ty. self.\n+00022970: 636f 6e66 6967 2e72 6561 6428 636f 636b config.read(cock\n+00022980: 7069 745f 636f 6e66 290a 0a0a 636c 6173 pit_conf)...clas\n+00022990: 7320 456e 7669 726f 6e6d 656e 7428 6275 s Environment(bu\n+000229a0: 732e 4f62 6a65 6374 2c20 696e 7465 7266 s.Object, interf\n+000229b0: 6163 653d 2763 6f63 6b70 6974 2e45 6e76 ace='cockpit.Env\n+000229c0: 6972 6f6e 6d65 6e74 2729 3a0a 2020 2020 ironment'):. \n+000229d0: 7661 7269 6162 6c65 7320 3d20 6275 732e variables = bus.\n+000229e0: 496e 7465 7266 6163 652e 5072 6f70 6572 Interface.Proper\n+000229f0: 7479 2827 617b 7373 7d27 290a 0a20 2020 ty('a{ss}').. \n+00022a00: 2040 7661 7269 6162 6c65 732e 6765 7474 @variables.gett\n+00022a10: 6572 0a20 2020 2064 6566 2067 6574 5f76 er. def get_v\n+00022a20: 6172 6961 626c 6573 2873 656c 6629 3a0a ariables(self):.\n+00022a30: 2020 2020 2020 2020 7265 7475 726e 206f return o\n+00022a40: 732e 656e 7669 726f 6e2e 636f 7079 2829 s.environ.copy()\n+00022a50: 0a27 2727 2c0a 2020 2763 6f63 6b70 6974 .''',. 'cockpit\n+00022a60: 2f70 6f6c 7966 696c 6c73 2e70 7927 3a20 /polyfills.py': \n+00022a70: 6272 2727 2723 2054 6869 7320 6669 6c65 br'''# This file\n+00022a80: 2069 7320 7061 7274 206f 6620 436f 636b is part of Cock\n+00022a90: 7069 742e 0a23 0a23 2043 6f70 7972 6967 pit..#.# Copyrig\n+00022aa0: 6874 2028 4329 2032 3032 3320 5265 6420 ht (C) 2023 Red \n+00022ab0: 4861 742c 2049 6e63 2e0a 230a 2320 5468 Hat, Inc..#.# Th\n+00022ac0: 6973 2070 726f 6772 616d 2069 7320 6672 is program is fr\n+00022ad0: 6565 2073 6f66 7477 6172 653a 2079 6f75 ee software: you\n+00022ae0: 2063 616e 2072 6564 6973 7472 6962 7574 can redistribut\n+00022af0: 6520 6974 2061 6e64 2f6f 7220 6d6f 6469 e it and/or modi\n+00022b00: 6679 0a23 2069 7420 756e 6465 7220 7468 fy.# it under th\n+00022b10: 6520 7465 726d 7320 6f66 2074 6865 2047 e terms of the G\n+00022b20: 4e55 2047 656e 6572 616c 2050 7562 6c69 NU General Publi\n+00022b30: 6320 4c69 6365 6e73 6520 6173 2070 7562 c License as pub\n+00022b40: 6c69 7368 6564 2062 790a 2320 7468 6520 lished by.# the \n+00022b50: 4672 6565 2053 6f66 7477 6172 6520 466f Free Software Fo\n+00022b60: 756e 6461 7469 6f6e 2c20 6569 7468 6572 undation, either\n+00022b70: 2076 6572 7369 6f6e 2033 206f 6620 7468 version 3 of th\n+00022b80: 6520 4c69 6365 6e73 652c 206f 720a 2320 e License, or.# \n+00022b90: 2861 7420 796f 7572 206f 7074 696f 6e29 (at your option)\n+00022ba0: 2061 6e79 206c 6174 6572 2076 6572 7369 any later versi\n+00022bb0: 6f6e 2e0a 230a 2320 5468 6973 2070 726f on..#.# This pro\n+00022bc0: 6772 616d 2069 7320 6469 7374 7269 6275 gram is distribu\n+00022bd0: 7465 6420 696e 2074 6865 2068 6f70 6520 ted in the hope \n+00022be0: 7468 6174 2069 7420 7769 6c6c 2062 6520 that it will be \n+00022bf0: 7573 6566 756c 2c0a 2320 6275 7420 5749 useful,.# but WI\n+00022c00: 5448 4f55 5420 414e 5920 5741 5252 414e THOUT ANY WARRAN\n+00022c10: 5459 3b20 7769 7468 6f75 7420 6576 656e TY; without even\n+00022c20: 2074 6865 2069 6d70 6c69 6564 2077 6172 the implied war\n+00022c30: 7261 6e74 7920 6f66 0a23 204d 4552 4348 ranty of.# MERCH\n+00022c40: 414e 5441 4249 4c49 5459 206f 7220 4649 ANTABILITY or FI\n+00022c50: 544e 4553 5320 464f 5220 4120 5041 5254 TNESS FOR A PART\n+00022c60: 4943 554c 4152 2050 5552 504f 5345 2e20 ICULAR PURPOSE. \n+00022c70: 2053 6565 2074 6865 0a23 2047 4e55 2047 See the.# GNU G\n+00022c80: 656e 6572 616c 2050 7562 6c69 6320 4c69 eneral Public Li\n+00022c90: 6365 6e73 6520 666f 7220 6d6f 7265 2064 cense for more d\n+00022ca0: 6574 6169 6c73 2e0a 230a 2320 596f 7520 etails..#.# You \n+00022cb0: 7368 6f75 6c64 2068 6176 6520 7265 6365 should have rece\n+00022cc0: 6976 6564 2061 2063 6f70 7920 6f66 2074 ived a copy of t\n+00022cd0: 6865 2047 4e55 2047 656e 6572 616c 2050 he GNU General P\n+00022ce0: 7562 6c69 6320 4c69 6365 6e73 650a 2320 ublic License.# \n+00022cf0: 616c 6f6e 6720 7769 7468 2074 6869 7320 along with this \n+00022d00: 7072 6f67 7261 6d2e 2020 4966 206e 6f74 program. If not\n+00022d10: 2c20 7365 6520 3c68 7474 7073 3a2f 2f77 , see ...import c\n+00022d40: 6f6e 7465 7874 6c69 620a 696d 706f 7274 ontextlib.import\n+00022d50: 2073 6f63 6b65 740a 0a0a 6465 6620 696e socket...def in\n+00022d60: 7374 616c 6c28 293a 0a20 2020 2022 2222 stall():. \"\"\"\n+00022d70: 4164 6420 7368 696d 7320 666f 7220 6f6c Add shims for ol\n+00022d80: 6465 7220 5079 7468 6f6e 2076 6572 7369 der Python versi\n+00022d90: 6f6e 7322 2222 0a0a 2020 2020 2320 696e ons\"\"\".. # in\n+00022da0: 7472 6f64 7563 6564 2069 6e20 332e 390a troduced in 3.9.\n+00022db0: 2020 2020 6966 206e 6f74 2068 6173 6174 if not hasat\n+00022dc0: 7472 2873 6f63 6b65 742c 2027 7265 6376 tr(socket, 'recv\n+00022dd0: 5f66 6473 2729 3a0a 2020 2020 2020 2020 _fds'):. \n+00022de0: 696d 706f 7274 2061 7272 6179 0a0a 2020 import array.. \n+00022df0: 2020 2020 2020 696d 706f 7274 205f 736f import _so\n+00022e00: 636b 6574 0a0a 2020 2020 2020 2020 6465 cket.. de\n+00022e10: 6620 7265 6376 5f66 6473 2873 6f63 6b2c f recv_fds(sock,\n+00022e20: 2062 7566 7369 7a65 2c20 6d61 7866 6473 bufsize, maxfds\n+00022e30: 2c20 666c 6167 733d 3029 3a0a 2020 2020 , flags=0):. \n+00022e40: 2020 2020 2020 2020 6664 7320 3d20 6172 fds = ar\n+00022e50: 7261 792e 6172 7261 7928 2269 2229 0a20 ray.array(\"i\"). \n+00022e60: 2020 2020 2020 2020 2020 206d 7367 2c20 msg, \n+00022e70: 616e 6364 6174 612c 2066 6c61 6773 2c20 ancdata, flags, \n+00022e80: 6164 6472 203d 2073 6f63 6b2e 7265 6376 addr = sock.recv\n+00022e90: 6d73 6728 6275 6673 697a 652c 205f 736f msg(bufsize, _so\n+00022ea0: 636b 6574 2e43 4d53 475f 4c45 4e28 6d61 cket.CMSG_LEN(ma\n+00022eb0: 7866 6473 202a 2066 6473 2e69 7465 6d73 xfds * fds.items\n+00022ec0: 697a 6529 290a 2020 2020 2020 2020 2020 ize)). \n+00022ed0: 2020 666f 7220 636d 7367 5f6c 6576 656c for cmsg_level\n+00022ee0: 2c20 636d 7367 5f74 7970 652c 2063 6d73 , cmsg_type, cms\n+00022ef0: 675f 6461 7461 2069 6e20 616e 6364 6174 g_data in ancdat\n+00022f00: 613a 0a20 2020 2020 2020 2020 2020 2020 a:. \n+00022f10: 2020 2069 6620 2863 6d73 675f 6c65 7665 if (cmsg_leve\n+00022f20: 6c20 3d3d 205f 736f 636b 6574 2e53 4f4c l == _socket.SOL\n+00022f30: 5f53 4f43 4b45 5420 616e 6420 636d 7367 _SOCKET and cmsg\n+00022f40: 5f74 7970 6520 3d3d 205f 736f 636b 6574 _type == _socket\n+00022f50: 2e53 434d 5f52 4947 4854 5329 3a0a 2020 .SCM_RIGHTS):. \n+00022f60: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00022f70: 2020 6664 732e 6672 6f6d 6279 7465 7328 fds.frombytes(\n+00022f80: 636d 7367 5f64 6174 615b 3a6c 656e 2863 cmsg_data[:len(c\n+00022f90: 6d73 675f 6461 7461 2920 2d20 286c 656e msg_data) - (len\n+00022fa0: 2863 6d73 675f 6461 7461 2920 2520 6664 (cmsg_data) % fd\n+00022fb0: 732e 6974 656d 7369 7a65 295d 290a 2020 s.itemsize)]). \n+00022fc0: 2020 2020 2020 2020 2020 7265 7475 726e return\n+00022fd0: 206d 7367 2c20 6c69 7374 2866 6473 292c msg, list(fds),\n+00022fe0: 2066 6c61 6773 2c20 6164 6472 0a0a 2020 flags, addr.. \n+00022ff0: 2020 2020 2020 736f 636b 6574 2e72 6563 socket.rec\n+00023000: 765f 6664 7320 3d20 7265 6376 5f66 6473 v_fds = recv_fds\n+00023010: 0a0a 2020 2020 2320 696e 7472 6f64 7563 .. # introduc\n+00023020: 6564 2069 6e20 332e 370a 2020 2020 6966 ed in 3.7. if\n+00023030: 206e 6f74 2068 6173 6174 7472 2863 6f6e not hasattr(con\n+00023040: 7465 7874 6c69 622c 2027 4173 796e 6345 textlib, 'AsyncE\n+00023050: 7869 7453 7461 636b 2729 3a0a 2020 2020 xitStack'):. \n+00023060: 2020 2020 636c 6173 7320 4173 796e 6345 class AsyncE\n+00023070: 7869 7453 7461 636b 3a0a 2020 2020 2020 xitStack:. \n+00023080: 2020 2020 2020 6173 796e 6320 6465 6620 async def \n+00023090: 5f5f 6165 6e74 6572 5f5f 2873 656c 6629 __aenter__(self)\n+000230a0: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n+000230b0: 2020 7365 6c66 2e63 6d73 203d 205b 5d0a self.cms = [].\n+000230c0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000230d0: 7265 7475 726e 2073 656c 660a 0a20 2020 return self.. \n+000230e0: 2020 2020 2020 2020 2061 7379 6e63 2064 async d\n+000230f0: 6566 2065 6e74 6572 5f61 7379 6e63 5f63 ef enter_async_c\n+00023100: 6f6e 7465 7874 2873 656c 662c 2063 6d29 ontext(self, cm)\n+00023110: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n+00023120: 2020 7265 7375 6c74 203d 2061 7761 6974 result = await\n+00023130: 2063 6d2e 5f5f 6165 6e74 6572 5f5f 2829 cm.__aenter__()\n+00023140: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+00023150: 2073 656c 662e 636d 732e 6170 7065 6e64 self.cms.append\n+00023160: 2863 6d29 0a20 2020 2020 2020 2020 2020 (cm). \n+00023170: 2020 2020 2072 6574 7572 6e20 7265 7375 return resu\n+00023180: 6c74 0a0a 2020 2020 2020 2020 2020 2020 lt.. \n+00023190: 6173 796e 6320 6465 6620 5f5f 6165 7869 async def __aexi\n+000231a0: 745f 5f28 7365 6c66 2c20 6578 635f 7479 t__(self, exc_ty\n+000231b0: 7065 2c20 6578 635f 7661 6c75 652c 2074 pe, exc_value, t\n+000231c0: 7261 6365 6261 636b 293a 0a20 2020 2020 raceback):. \n+000231d0: 2020 2020 2020 2020 2020 2066 6f72 2063 for c\n+000231e0: 6d20 696e 2073 656c 662e 636d 733a 0a20 m in self.cms:. \n+000231f0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00023200: 2020 2063 6d2e 5f5f 6165 7869 745f 5f28 cm.__aexit__(\n+00023210: 6578 635f 7479 7065 2c20 6578 635f 7661 exc_type, exc_va\n+00023220: 6c75 652c 2074 7261 6365 6261 636b 290a lue, traceback).\n+00023230: 0a20 2020 2020 2020 2063 6f6e 7465 7874 . context\n+00023240: 6c69 622e 4173 796e 6345 7869 7453 7461 lib.AsyncExitSta\n+00023250: 636b 203d 2041 7379 6e63 4578 6974 5374 ck = AsyncExitSt\n+00023260: 6163 6b0a 2727 272c 0a20 2027 636f 636b ack.''',. 'cock\n+00023270: 7069 742f 7065 6572 2e70 7927 3a20 7227 pit/peer.py': r'\n+00023280: 2727 2320 5468 6973 2066 696c 6520 6973 ''# This file is\n+00023290: 2070 6172 7420 6f66 2043 6f63 6b70 6974 part of Cockpit\n+000232a0: 2e0a 230a 2320 436f 7079 7269 6768 7420 ..#.# Copyright \n+000232b0: 2843 2920 3230 3232 2052 6564 2048 6174 (C) 2022 Red Hat\n+000232c0: 2c20 496e 632e 0a23 0a23 2054 6869 7320 , Inc..#.# This \n+000232d0: 7072 6f67 7261 6d20 6973 2066 7265 6520 program is free \n+000232e0: 736f 6674 7761 7265 3a20 796f 7520 6361 software: you ca\n+000232f0: 6e20 7265 6469 7374 7269 6275 7465 2069 n redistribute i\n+00023300: 7420 616e 642f 6f72 206d 6f64 6966 790a t and/or modify.\n+00023310: 2320 6974 2075 6e64 6572 2074 6865 2074 # it under the t\n+00023320: 6572 6d73 206f 6620 7468 6520 474e 5520 erms of the GNU \n+00023330: 4765 6e65 7261 6c20 5075 626c 6963 204c General Public L\n+00023340: 6963 656e 7365 2061 7320 7075 626c 6973 icense as publis\n+00023350: 6865 6420 6279 0a23 2074 6865 2046 7265 hed by.# the Fre\n+00023360: 6520 536f 6674 7761 7265 2046 6f75 6e64 e Software Found\n+00023370: 6174 696f 6e2c 2065 6974 6865 7220 7665 ation, either ve\n+00023380: 7273 696f 6e20 3320 6f66 2074 6865 204c rsion 3 of the L\n+00023390: 6963 656e 7365 2c20 6f72 0a23 2028 6174 icense, or.# (at\n+000233a0: 2079 6f75 7220 6f70 7469 6f6e 2920 616e your option) an\n+000233b0: 7920 6c61 7465 7220 7665 7273 696f 6e2e y later version.\n+000233c0: 0a23 0a23 2054 6869 7320 7072 6f67 7261 .#.# This progra\n+000233d0: 6d20 6973 2064 6973 7472 6962 7574 6564 m is distributed\n+000233e0: 2069 6e20 7468 6520 686f 7065 2074 6861 in the hope tha\n+000233f0: 7420 6974 2077 696c 6c20 6265 2075 7365 t it will be use\n+00023400: 6675 6c2c 0a23 2062 7574 2057 4954 484f ful,.# but WITHO\n+00023410: 5554 2041 4e59 2057 4152 5241 4e54 593b UT ANY WARRANTY;\n+00023420: 2077 6974 686f 7574 2065 7665 6e20 7468 without even th\n+00023430: 6520 696d 706c 6965 6420 7761 7272 616e e implied warran\n+00023440: 7479 206f 660a 2320 4d45 5243 4841 4e54 ty of.# MERCHANT\n+00023450: 4142 494c 4954 5920 6f72 2046 4954 4e45 ABILITY or FITNE\n+00023460: 5353 2046 4f52 2041 2050 4152 5449 4355 SS FOR A PARTICU\n+00023470: 4c41 5220 5055 5250 4f53 452e 2020 5365 LAR PURPOSE. Se\n+00023480: 6520 7468 650a 2320 474e 5520 4765 6e65 e the.# GNU Gene\n+00023490: 7261 6c20 5075 626c 6963 204c 6963 656e ral Public Licen\n+000234a0: 7365 2066 6f72 206d 6f72 6520 6465 7461 se for more deta\n+000234b0: 696c 732e 0a23 0a23 2059 6f75 2073 686f ils..#.# You sho\n+000234c0: 756c 6420 6861 7665 2072 6563 6569 7665 uld have receive\n+000234d0: 6420 6120 636f 7079 206f 6620 7468 6520 d a copy of the \n+000234e0: 474e 5520 4765 6e65 7261 6c20 5075 626c GNU General Publ\n+000234f0: 6963 204c 6963 656e 7365 0a23 2061 6c6f ic License.# alo\n+00023500: 6e67 2077 6974 6820 7468 6973 2070 726f ng with this pro\n+00023510: 6772 616d 2e20 2049 6620 6e6f 742c 2073 gram. If not, s\n+00023520: 6565 203c 6874 7470 733a 2f2f 7777 772e ee ...import asyn\n+00023550: 6369 6f0a 696d 706f 7274 206c 6f67 6769 cio.import loggi\n+00023560: 6e67 0a69 6d70 6f72 7420 6f73 0a66 726f ng.import os.fro\n+00023570: 6d20 7479 7069 6e67 2069 6d70 6f72 7420 m typing import \n+00023580: 4361 6c6c 6162 6c65 2c20 4c69 7374 2c20 Callable, List, \n+00023590: 4f70 7469 6f6e 616c 2c20 5365 7175 656e Optional, Sequen\n+000235a0: 6365 0a0a 6672 6f6d 202e 6a73 6f6e 7574 ce..from .jsonut\n+000235b0: 696c 2069 6d70 6f72 7420 4a73 6f6e 4f62 il import JsonOb\n+000235c0: 6a65 6374 2c20 4a73 6f6e 5661 6c75 650a ject, JsonValue.\n+000235d0: 6672 6f6d 202e 7061 636b 6167 6573 2069 from .packages i\n+000235e0: 6d70 6f72 7420 4272 6964 6765 436f 6e66 mport BridgeConf\n+000235f0: 6967 0a66 726f 6d20 2e70 726f 746f 636f ig.from .protoco\n+00023600: 6c20 696d 706f 7274 2043 6f63 6b70 6974 l import Cockpit\n+00023610: 5072 6f62 6c65 6d2c 2043 6f63 6b70 6974 Problem, Cockpit\n+00023620: 5072 6f74 6f63 6f6c 2c20 436f 636b 7069 Protocol, Cockpi\n+00023630: 7450 726f 746f 636f 6c45 7272 6f72 0a66 tProtocolError.f\n+00023640: 726f 6d20 2e72 6f75 7465 7220 696d 706f rom .router impo\n+00023650: 7274 2045 6e64 706f 696e 742c 2052 6f75 rt Endpoint, Rou\n+00023660: 7465 722c 2052 6f75 7469 6e67 5275 6c65 ter, RoutingRule\n+00023670: 0a66 726f 6d20 2e74 7261 6e73 706f 7274 .from .transport\n+00023680: 7320 696d 706f 7274 2053 7562 7072 6f63 s import Subproc\n+00023690: 6573 7350 726f 746f 636f 6c2c 2053 7562 essProtocol, Sub\n+000236a0: 7072 6f63 6573 7354 7261 6e73 706f 7274 processTransport\n+000236b0: 0a0a 6c6f 6767 6572 203d 206c 6f67 6769 ..logger = loggi\n+000236c0: 6e67 2e67 6574 4c6f 6767 6572 285f 5f6e ng.getLogger(__n\n+000236d0: 616d 655f 5f29 0a0a 0a63 6c61 7373 2050 ame__)...class P\n+000236e0: 6565 7245 7272 6f72 2843 6f63 6b70 6974 eerError(Cockpit\n+000236f0: 5072 6f62 6c65 6d29 3a0a 2020 2020 7061 Problem):. pa\n+00023700: 7373 0a0a 0a63 6c61 7373 2050 6565 7245 ss...class PeerE\n+00023710: 7869 7465 6428 4578 6365 7074 696f 6e29 xited(Exception)\n+00023720: 3a0a 2020 2020 6465 6620 5f5f 696e 6974 :. def __init\n+00023730: 5f5f 2873 656c 662c 2065 7869 745f 636f __(self, exit_co\n+00023740: 6465 3a20 696e 7429 3a0a 2020 2020 2020 de: int):. \n+00023750: 2020 7365 6c66 2e65 7869 745f 636f 6465 self.exit_code\n+00023760: 203d 2065 7869 745f 636f 6465 0a0a 0a63 = exit_code...c\n+00023770: 6c61 7373 2050 6565 7228 436f 636b 7069 lass Peer(Cockpi\n+00023780: 7450 726f 746f 636f 6c2c 2053 7562 7072 tProtocol, Subpr\n+00023790: 6f63 6573 7350 726f 746f 636f 6c2c 2045 ocessProtocol, E\n+000237a0: 6e64 706f 696e 7429 3a0a 2020 2020 646f ndpoint):. do\n+000237b0: 6e65 5f63 616c 6c62 6163 6b73 3a20 4c69 ne_callbacks: Li\n+000237c0: 7374 5b43 616c 6c61 626c 655b 5b5d 2c20 st[Callable[[], \n+000237d0: 4e6f 6e65 5d5d 0a20 2020 2069 6e69 745f None]]. init_\n+000237e0: 6675 7475 7265 3a20 4f70 7469 6f6e 616c future: Optional\n+000237f0: 5b61 7379 6e63 696f 2e46 7574 7572 655d [asyncio.Future]\n+00023800: 0a0a 2020 2020 6465 6620 5f5f 696e 6974 .. def __init\n+00023810: 5f5f 2873 656c 662c 2072 6f75 7465 723a __(self, router:\n+00023820: 2052 6f75 7465 7229 3a0a 2020 2020 2020 Router):. \n+00023830: 2020 7375 7065 7228 292e 5f5f 696e 6974 super().__init\n+00023840: 5f5f 2872 6f75 7465 7229 0a0a 2020 2020 __(router).. \n+00023850: 2020 2020 2320 416c 6c20 5065 6572 7320 # All Peers \n+00023860: 7374 6172 7420 6f75 7420 6672 6f7a 656e start out frozen\n+00023870: 20e2 8094 2077 6520 6f6e 6c79 2075 6e66 ... we only unf\n+00023880: 7265 657a 6520 6166 7465 7220 7765 2073 reeze after we s\n+00023890: 6565 2074 6865 2066 6972 7374 2027 696e ee the first 'in\n+000238a0: 6974 2720 6d65 7373 6167 650a 2020 2020 it' message. \n+000238b0: 2020 2020 7365 6c66 2e66 7265 657a 655f self.freeze_\n+000238c0: 656e 6470 6f69 6e74 2829 0a0a 2020 2020 endpoint().. \n+000238d0: 2020 2020 7365 6c66 2e69 6e69 745f 6675 self.init_fu\n+000238e0: 7475 7265 203d 2061 7379 6e63 696f 2e67 ture = asyncio.g\n+000238f0: 6574 5f72 756e 6e69 6e67 5f6c 6f6f 7028 et_running_loop(\n+00023900: 292e 6372 6561 7465 5f66 7574 7572 6528 ).create_future(\n+00023910: 290a 2020 2020 2020 2020 7365 6c66 2e64 ). self.d\n+00023920: 6f6e 655f 6361 6c6c 6261 636b 7320 3d20 one_callbacks = \n+00023930: 5b5d 0a0a 2020 2020 2320 496e 6974 6961 [].. # Initia\n+00023940: 6c69 7a61 7469 6f6e 0a20 2020 2061 7379 lization. asy\n+00023950: 6e63 2064 6566 2064 6f5f 636f 6e6e 6563 nc def do_connec\n+00023960: 745f 7472 616e 7370 6f72 7428 7365 6c66 t_transport(self\n+00023970: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n+00023980: 2020 2072 6169 7365 204e 6f74 496d 706c raise NotImpl\n+00023990: 656d 656e 7465 6445 7272 6f72 0a0a 2020 ementedError.. \n+000239a0: 2020 6173 796e 6320 6465 6620 7370 6177 async def spaw\n+000239b0: 6e28 7365 6c66 2c20 6172 6776 3a20 5365 n(self, argv: Se\n+000239c0: 7175 656e 6365 5b73 7472 5d2c 2065 6e76 quence[str], env\n+000239d0: 3a20 5365 7175 656e 6365 5b73 7472 5d2c : Sequence[str],\n+000239e0: 202a 2a6b 7761 7267 7329 202d 3e20 6173 **kwargs) -> as\n+000239f0: 796e 6369 6f2e 5472 616e 7370 6f72 743a yncio.Transport:\n+00023a00: 0a20 2020 2020 2020 2023 204e 6f74 2061 . # Not a\n+00023a10: 6374 7561 6c6c 7920 6173 796e 632e 2e2e ctually async...\n+00023a20: 0a20 2020 2020 2020 206c 6f6f 7020 3d20 . loop = \n+00023a30: 6173 796e 6369 6f2e 6765 745f 7275 6e6e asyncio.get_runn\n+00023a40: 696e 675f 6c6f 6f70 2829 0a20 2020 2020 ing_loop(). \n+00023a50: 2020 2075 7365 725f 656e 7620 3d20 6469 user_env = di\n+00023a60: 6374 2865 2e73 706c 6974 2827 3d27 2c20 ct(e.split('=', \n+00023a70: 3129 2066 6f72 2065 2069 6e20 656e 7629 1) for e in env)\n+00023a80: 0a20 2020 2020 2020 2072 6574 7572 6e20 . return \n+00023a90: 5375 6270 726f 6365 7373 5472 616e 7370 SubprocessTransp\n+00023aa0: 6f72 7428 6c6f 6f70 2c20 7365 6c66 2c20 ort(loop, self, \n+00023ab0: 6172 6776 2c20 656e 763d 6469 6374 286f argv, env=dict(o\n+00023ac0: 732e 656e 7669 726f 6e2c 202a 2a75 7365 s.environ, **use\n+00023ad0: 725f 656e 7629 2c20 2a2a 6b77 6172 6773 r_env), **kwargs\n+00023ae0: 290a 0a20 2020 2061 7379 6e63 2064 6566 ).. async def\n+00023af0: 2073 7461 7274 2873 656c 662c 2069 6e69 start(self, ini\n+00023b00: 745f 686f 7374 3a20 4f70 7469 6f6e 616c t_host: Optional\n+00023b10: 5b73 7472 5d20 3d20 4e6f 6e65 2c20 2a2a [str] = None, **\n+00023b20: 6b77 6172 6773 3a20 4a73 6f6e 5661 6c75 kwargs: JsonValu\n+00023b30: 6529 202d 3e20 4a73 6f6e 4f62 6a65 6374 e) -> JsonObject\n+00023b40: 3a0a 2020 2020 2020 2020 2222 2252 6571 :. \"\"\"Req\n+00023b50: 7565 7374 2074 6861 7420 7468 6520 5065 uest that the Pe\n+00023b60: 6572 2069 7320 7374 6172 7465 6420 616e er is started an\n+00023b70: 6420 636f 6e6e 6563 7465 6420 746f 2074 d connected to t\n+00023b80: 6865 2072 6f75 7465 722e 0a0a 2020 2020 he router... \n+00023b90: 2020 2020 4372 6561 7465 7320 7468 6520 Creates the \n+00023ba0: 7472 616e 7370 6f72 742c 2063 6f6e 6e65 transport, conne\n+00023bb0: 6374 7320 6974 2074 6f20 7468 6520 7072 cts it to the pr\n+00023bc0: 6f74 6f63 6f6c 2c20 616e 6420 7061 7274 otocol, and part\n+00023bd0: 6963 6970 6174 6573 2069 6e0a 2020 2020 icipates in. \n+00023be0: 2020 2020 6578 6368 616e 6769 6e67 206f exchanging o\n+00023bf0: 6620 696e 6974 206d 6573 7361 6765 732e f init messages.\n+00023c00: 2020 4966 2061 6e79 7468 696e 6720 676f If anything go\n+00023c10: 6573 2077 726f 6e67 2c20 7468 6520 636f es wrong, the co\n+00023c20: 6e6e 6563 7469 6f6e 0a20 2020 2020 2020 nnection. \n+00023c30: 2077 696c 6c20 6265 2063 6c6f 7365 6420 will be closed \n+00023c40: 616e 6420 616e 2065 7863 6570 7469 6f6e and an exception\n+00023c50: 2077 696c 6c20 6265 2072 6169 7365 642e will be raised.\n+00023c60: 0a0a 2020 2020 2020 2020 5468 6520 5065 .. The Pe\n+00023c70: 6572 2073 7461 7274 7320 6f75 7420 696e er starts out in\n+00023c80: 2061 2066 726f 7a65 6e20 7374 6174 6520 a frozen state \n+00023c90: 2869 653a 2061 7474 656d 7074 7320 746f (ie: attempts to\n+00023ca0: 2073 656e 6420 6d65 7373 6167 6573 2074 send messages t\n+00023cb0: 6f0a 2020 2020 2020 2020 6974 2077 696c o. it wil\n+00023cc0: 6c20 696e 6974 6961 6c6c 7920 6265 2071 l initially be q\n+00023cd0: 7565 7565 6429 2e20 4966 2069 6e69 745f ueued). If init_\n+00023ce0: 686f 7374 2069 7320 6e6f 7420 4e6f 6e65 host is not None\n+00023cf0: 2074 6865 6e20 616e 2069 6e69 740a 2020 then an init. \n+00023d00: 2020 2020 2020 6d65 7373 6167 6520 6973 message is\n+00023d10: 2073 656e 7420 7769 7468 2074 6865 2067 sent with the g\n+00023d20: 6976 656e 2027 686f 7374 2720 6669 656c iven 'host' fiel\n+00023d30: 642c 2070 6c75 7320 616e 7920 6578 7472 d, plus any extr\n+00023d40: 6120 6b77 6172 6773 2c20 616e 640a 2020 a kwargs, and. \n+00023d50: 2020 2020 2020 7468 6520 7175 6575 6520 the queue \n+00023d60: 6973 2074 6861 7765 642e 204f 7468 6572 is thawed. Other\n+00023d70: 7769 7365 2c20 7468 6520 6361 6c6c 6572 wise, the caller\n+00023d80: 2069 7320 7265 7370 6f6e 7369 626c 6520 is responsible \n+00023d90: 666f 7220 7365 6e64 696e 670a 2020 2020 for sending. \n+00023da0: 2020 2020 7468 6520 696e 6974 206d 6573 the init mes\n+00023db0: 7361 6765 2061 6e64 2074 6861 7769 6e67 sage and thawing\n+00023dc0: 2074 6865 2070 6565 722e 0a0a 2020 2020 the peer... \n+00023dd0: 2020 2020 496e 2061 6e79 2063 6173 652c In any case,\n+00023de0: 2074 6865 2072 6574 7572 6e20 7661 6c75 the return valu\n+00023df0: 6520 6973 2074 6865 2069 6e69 7420 6d65 e is the init me\n+00023e00: 7373 6167 6520 6672 6f6d 2074 6865 2070 ssage from the p\n+00023e10: 6565 722e 0a20 2020 2020 2020 2022 2222 eer.. \"\"\"\n+00023e20: 0a20 2020 2020 2020 2061 7373 6572 7420 . assert \n+00023e30: 7365 6c66 2e69 6e69 745f 6675 7475 7265 self.init_future\n+00023e40: 2069 7320 6e6f 7420 4e6f 6e65 0a0a 2020 is not None.. \n+00023e50: 2020 2020 2020 6465 6620 5f63 6f6e 6e65 def _conne\n+00023e60: 6374 5f74 6173 6b5f 646f 6e65 2874 6173 ct_task_done(tas\n+00023e70: 6b3a 2061 7379 6e63 696f 2e54 6173 6b29 k: asyncio.Task)\n+00023e80: 202d 3e20 4e6f 6e65 3a0a 2020 2020 2020 -> None:. \n+00023e90: 2020 2020 2020 6173 7365 7274 2074 6173 assert tas\n+00023ea0: 6b20 6973 2063 6f6e 6e65 6374 5f74 6173 k is connect_tas\n+00023eb0: 6b0a 2020 2020 2020 2020 2020 2020 7472 k. tr\n+00023ec0: 793a 0a20 2020 2020 2020 2020 2020 2020 y:. \n+00023ed0: 2020 2074 6173 6b2e 7265 7375 6c74 2829 task.result()\n+00023ee0: 0a20 2020 2020 2020 2020 2020 2065 7863 . exc\n+00023ef0: 6570 7420 6173 796e 6369 6f2e 4361 6e63 ept asyncio.Canc\n+00023f00: 656c 6c65 6445 7272 6f72 3a20 2023 2077 elledError: # w\n+00023f10: 6520 6469 6420 7468 6174 2028 6265 6c6f e did that (belo\n+00023f20: 7729 0a20 2020 2020 2020 2020 2020 2020 w). \n+00023f30: 2020 2070 6173 7320 2020 2020 2020 2020 pass \n+00023f40: 2020 2020 2020 2020 2020 2020 2020 2023 #\n+00023f50: 2077 6520 7761 6e74 2074 6f20 6967 6e6f we want to igno\n+00023f60: 7265 2069 740a 2020 2020 2020 2020 2020 re it. \n+00023f70: 2020 6578 6365 7074 2045 7863 6570 7469 except Excepti\n+00023f80: 6f6e 2061 7320 6578 633a 0a20 2020 2020 on as exc:. \n+00023f90: 2020 2020 2020 2020 2020 2073 656c 662e self.\n+00023fa0: 636c 6f73 6528 6578 6329 0a0a 2020 2020 close(exc).. \n+00023fb0: 2020 2020 636f 6e6e 6563 745f 7461 736b connect_task\n+00023fc0: 203d 2061 7379 6e63 696f 2e63 7265 6174 = asyncio.creat\n+00023fd0: 655f 7461 736b 2873 656c 662e 646f 5f63 e_task(self.do_c\n+00023fe0: 6f6e 6e65 6374 5f74 7261 6e73 706f 7274 onnect_transport\n+00023ff0: 2829 290a 2020 2020 2020 2020 636f 6e6e ()). conn\n+00024000: 6563 745f 7461 736b 2e61 6464 5f64 6f6e ect_task.add_don\n+00024010: 655f 6361 6c6c 6261 636b 285f 636f 6e6e e_callback(_conn\n+00024020: 6563 745f 7461 736b 5f64 6f6e 6529 0a0a ect_task_done)..\n+00024030: 2020 2020 2020 2020 7472 793a 0a20 2020 try:. \n+00024040: 2020 2020 2020 2020 2023 2057 6169 7420 # Wait \n+00024050: 666f 7220 736f 6d65 7468 696e 6720 746f for something to\n+00024060: 2068 6170 7065 6e3a 0a20 2020 2020 2020 happen:. \n+00024070: 2020 2020 2023 2020 202d 2065 7863 6570 # - excep\n+00024080: 7469 6f6e 2066 726f 6d20 6f75 7220 636f tion from our co\n+00024090: 6e6e 6563 7469 6f6e 2066 756e 6374 696f nnection functio\n+000240a0: 6e0a 2020 2020 2020 2020 2020 2020 2320 n. # \n+000240b0: 2020 2d20 7265 6365 6976 696e 6720 2269 - receiving \"i\n+000240c0: 6e69 7422 2066 726f 6d20 7468 6520 6f74 nit\" from the ot\n+000240d0: 6865 7220 7369 6465 0a20 2020 2020 2020 her side. \n+000240e0: 2020 2020 2023 2020 202d 2072 6563 6569 # - recei\n+000240f0: 7669 6e67 2045 4f46 2066 726f 6d20 7468 ving EOF from th\n+00024100: 6520 6f74 6865 7220 7369 6465 0a20 2020 e other side. \n+00024110: 2020 2020 2020 2020 2023 2020 202d 202e # - .\n+00024120: 636c 6f73 6528 2920 7761 7320 6361 6c6c close() was call\n+00024130: 6564 0a20 2020 2020 2020 2020 2020 2023 ed. #\n+00024140: 2020 202d 206f 7468 6572 2074 7261 6e73 - other trans\n+00024150: 706f 7274 2065 7863 6570 7469 6f6e 0a20 port exception. \n+00024160: 2020 2020 2020 2020 2020 2069 6e69 745f init_\n+00024170: 6d65 7373 6167 6520 3d20 6177 6169 7420 message = await \n+00024180: 7365 6c66 2e69 6e69 745f 6675 7475 7265 self.init_future\n+00024190: 0a0a 2020 2020 2020 2020 6578 6365 7074 .. except\n+000241a0: 2028 5065 6572 4578 6974 6564 2c20 4272 (PeerExited, Br\n+000241b0: 6f6b 656e 5069 7065 4572 726f 7229 3a0a okenPipeError):.\n+000241c0: 2020 2020 2020 2020 2020 2020 2320 5468 # Th\n+000241d0: 6573 6520 6172 6520 6661 6972 6c79 2067 ese are fairly g\n+000241e0: 656e 6572 6963 2065 7272 6f72 732e 2050 eneric errors. P\n+000241f0: 6565 7245 7869 7465 6420 6d65 616e 7320 eerExited means \n+00024200: 7468 6174 2077 6520 6f62 7365 7276 6564 that we observed\n+00024210: 2074 6865 2070 726f 6365 7373 2065 7869 the process exi\n+00024220: 7469 6e67 2e0a 2020 2020 2020 2020 2020 ting.. \n+00024230: 2020 2320 4272 6f6b 656e 5069 7065 4572 # BrokenPipeEr\n+00024240: 726f 7220 6d65 616e 7320 7468 6174 2077 ror means that w\n+00024250: 6520 676f 7420 4550 4950 4520 7768 656e e got EPIPE when\n+00024260: 2061 7474 656d 7074 696e 6720 746f 2077 attempting to w\n+00024270: 7269 7465 2829 2074 6f20 6974 2e20 496e rite() to it. In\n+00024280: 2062 6f74 6820 6361 7365 732c 0a20 2020 both cases,. \n+00024290: 2020 2020 2020 2020 2023 2074 6865 2070 # the p\n+000242a0: 726f 6365 7373 2069 7320 676f 6e65 2c20 rocess is gone, \n+000242b0: 6275 7420 6974 2773 206e 6f74 2063 6c65 but it's not cle\n+000242c0: 6172 2077 6879 2e20 4966 2074 6865 2063 ar why. If the c\n+000242d0: 6f6e 6e65 6374 696f 6e20 7072 6f63 6573 onnection proces\n+000242e0: 7320 6973 2073 7469 6c6c 2072 756e 6e69 s is still runni\n+000242f0: 6e67 2c0a 2020 2020 2020 2020 2020 2020 ng,. \n+00024300: 2320 7065 7268 6170 7320 7765 2764 2067 # perhaps we'd g\n+00024310: 6574 2061 2062 6574 7465 7220 6572 726f et a better erro\n+00024320: 7220 6d65 7373 6167 6520 6672 6f6d 2069 r message from i\n+00024330: 742e 0a20 2020 2020 2020 2020 2020 2061 t.. a\n+00024340: 7761 6974 2063 6f6e 6e65 6374 5f74 6173 wait connect_tas\n+00024350: 6b0a 2020 2020 2020 2020 2020 2020 2320 k. # \n+00024360: 4f74 6865 7277 6973 652c 2072 652d 7261 Otherwise, re-ra\n+00024370: 6973 650a 2020 2020 2020 2020 2020 2020 ise. \n+00024380: 7261 6973 650a 0a20 2020 2020 2020 2066 raise.. f\n+00024390: 696e 616c 6c79 3a0a 2020 2020 2020 2020 inally:. \n+000243a0: 2020 2020 7365 6c66 2e69 6e69 745f 6675 self.init_fu\n+000243b0: 7475 7265 203d 204e 6f6e 650a 0a20 2020 ture = None.. \n+000243c0: 2020 2020 2020 2020 2023 2049 6e20 616e # In an\n+000243d0: 7920 6361 7365 2028 6661 696c 7572 6520 y case (failure \n+000243e0: 6f72 2073 7563 6365 7373 2920 6d61 6b65 or success) make\n+000243f0: 2073 7572 6520 7468 6973 2069 7320 646f sure this is do\n+00024400: 6e65 2e0a 2020 2020 2020 2020 2020 2020 ne.. \n+00024410: 6966 206e 6f74 2063 6f6e 6e65 6374 5f74 if not connect_t\n+00024420: 6173 6b2e 646f 6e65 2829 3a0a 2020 2020 ask.done():. \n+00024430: 2020 2020 2020 2020 2020 2020 636f 6e6e conn\n+00024440: 6563 745f 7461 736b 2e63 616e 6365 6c28 ect_task.cancel(\n+00024450: 290a 0a20 2020 2020 2020 2069 6620 696e ).. if in\n+00024460: 6974 5f68 6f73 7420 6973 206e 6f74 204e it_host is not N\n+00024470: 6f6e 653a 0a20 2020 2020 2020 2020 2020 one:. \n+00024480: 206c 6f67 6765 722e 6465 6275 6728 2720 logger.debug(' \n+00024490: 2073 656e 6469 6e67 2069 6e69 7420 6d65 sending init me\n+000244a0: 7373 6167 6520 6261 636b 2c20 686f 7374 ssage back, host\n+000244b0: 2025 7327 2c20 696e 6974 5f68 6f73 7429 %s', init_host)\n+000244c0: 0a20 2020 2020 2020 2020 2020 2023 2053 . # S\n+000244d0: 656e 6420 2269 6e69 7422 2062 6163 6b0a end \"init\" back.\n+000244e0: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n+000244f0: 2e77 7269 7465 5f63 6f6e 7472 6f6c 284e .write_control(N\n+00024500: 6f6e 652c 2063 6f6d 6d61 6e64 3d27 696e one, command='in\n+00024510: 6974 272c 2076 6572 7369 6f6e 3d31 2c20 it', version=1, \n+00024520: 686f 7374 3d69 6e69 745f 686f 7374 2c20 host=init_host, \n+00024530: 2a2a 6b77 6172 6773 290a 0a20 2020 2020 **kwargs).. \n+00024540: 2020 2020 2020 2023 2054 6861 7720 7468 # Thaw th\n+00024550: 6520 7175 6575 6564 206d 6573 7361 6765 e queued message\n+00024560: 730a 2020 2020 2020 2020 2020 2020 7365 s. se\n+00024570: 6c66 2e74 6861 775f 656e 6470 6f69 6e74 lf.thaw_endpoint\n+00024580: 2829 0a0a 2020 2020 2020 2020 7265 7475 ().. retu\n+00024590: 726e 2069 6e69 745f 6d65 7373 6167 650a rn init_message.\n+000245a0: 0a20 2020 2023 2042 6163 6b67 726f 756e . # Backgroun\n+000245b0: 6420 696e 6974 6961 6c69 7a61 7469 6f6e d initialization\n+000245c0: 0a20 2020 2064 6566 2073 7461 7274 5f69 . def start_i\n+000245d0: 6e5f 6261 636b 6772 6f75 6e64 2873 656c n_background(sel\n+000245e0: 662c 2069 6e69 745f 686f 7374 3a20 4f70 f, init_host: Op\n+000245f0: 7469 6f6e 616c 5b73 7472 5d20 3d20 4e6f tional[str] = No\n+00024600: 6e65 2c20 2a2a 6b77 6172 6773 3a20 4a73 ne, **kwargs: Js\n+00024610: 6f6e 5661 6c75 6529 202d 3e20 4e6f 6e65 onValue) -> None\n+00024620: 3a0a 2020 2020 2020 2020 6465 6620 5f73 :. def _s\n+00024630: 7461 7274 5f74 6173 6b5f 646f 6e65 2874 tart_task_done(t\n+00024640: 6173 6b3a 2061 7379 6e63 696f 2e54 6173 ask: asyncio.Tas\n+00024650: 6b29 202d 3e20 4e6f 6e65 3a0a 2020 2020 k) -> None:. \n+00024660: 2020 2020 2020 2020 6173 7365 7274 2074 assert t\n+00024670: 6173 6b20 6973 2073 7461 7274 5f74 6173 ask is start_tas\n+00024680: 6b0a 0a20 2020 2020 2020 2020 2020 2074 k.. t\n+00024690: 7279 3a0a 2020 2020 2020 2020 2020 2020 ry:. \n+000246a0: 2020 2020 7461 736b 2e72 6573 756c 7428 task.result(\n+000246b0: 290a 2020 2020 2020 2020 2020 2020 6578 ). ex\n+000246c0: 6365 7074 2028 4f53 4572 726f 722c 2050 cept (OSError, P\n+000246d0: 6565 7245 7869 7465 642c 2043 6f63 6b70 eerExited, Cockp\n+000246e0: 6974 5072 6f62 6c65 6d2c 2061 7379 6e63 itProblem, async\n+000246f0: 696f 2e43 616e 6365 6c6c 6564 4572 726f io.CancelledErro\n+00024700: 7229 3a0a 2020 2020 2020 2020 2020 2020 r):. \n+00024710: 2020 2020 7061 7373 2020 2320 5468 6f73 pass # Thos\n+00024720: 6520 6172 6520 6578 7065 6374 6564 2e20 e are expected. \n+00024730: 204f 7468 6572 7320 7769 6c6c 2074 6872 Others will thr\n+00024740: 6f77 2e0a 0a20 2020 2020 2020 2073 7461 ow... sta\n+00024750: 7274 5f74 6173 6b20 3d20 6173 796e 6369 rt_task = asynci\n+00024760: 6f2e 6372 6561 7465 5f74 6173 6b28 7365 o.create_task(se\n+00024770: 6c66 2e73 7461 7274 2869 6e69 745f 686f lf.start(init_ho\n+00024780: 7374 2c20 2a2a 6b77 6172 6773 2929 0a20 st, **kwargs)). \n+00024790: 2020 2020 2020 2073 7461 7274 5f74 6173 start_tas\n+000247a0: 6b2e 6164 645f 646f 6e65 5f63 616c 6c62 k.add_done_callb\n+000247b0: 6163 6b28 5f73 7461 7274 5f74 6173 6b5f ack(_start_task_\n+000247c0: 646f 6e65 290a 0a20 2020 2023 2053 6875 done).. # Shu\n+000247d0: 7464 6f77 6e0a 2020 2020 6465 6620 6164 tdown. def ad\n+000247e0: 645f 646f 6e65 5f63 616c 6c62 6163 6b28 d_done_callback(\n+000247f0: 7365 6c66 2c20 6361 6c6c 6261 636b 3a20 self, callback: \n+00024800: 4361 6c6c 6162 6c65 5b5b 5d2c 204e 6f6e Callable[[], Non\n+00024810: 655d 2920 2d3e 204e 6f6e 653a 0a20 2020 e]) -> None:. \n+00024820: 2020 2020 2073 656c 662e 646f 6e65 5f63 self.done_c\n+00024830: 616c 6c62 6163 6b73 2e61 7070 656e 6428 allbacks.append(\n+00024840: 6361 6c6c 6261 636b 290a 0a20 2020 2023 callback).. #\n+00024850: 2048 616e 646c 696e 6720 6f66 2069 6e74 Handling of int\n+00024860: 6572 6573 7469 6e67 2065 7665 6e74 730a eresting events.\n+00024870: 2020 2020 6465 6620 646f 5f73 7570 6572 def do_super\n+00024880: 7573 6572 5f69 6e69 745f 646f 6e65 2873 user_init_done(s\n+00024890: 656c 6629 202d 3e20 4e6f 6e65 3a0a 2020 elf) -> None:. \n+000248a0: 2020 2020 2020 7061 7373 0a0a 2020 2020 pass.. \n+000248b0: 6465 6620 646f 5f61 7574 686f 7269 7a65 def do_authorize\n+000248c0: 2873 656c 662c 206d 6573 7361 6765 3a20 (self, message: \n+000248d0: 4a73 6f6e 4f62 6a65 6374 2920 2d3e 204e JsonObject) -> N\n+000248e0: 6f6e 653a 0a20 2020 2020 2020 2070 6173 one:. pas\n+000248f0: 730a 0a20 2020 2064 6566 2074 7261 6e73 s.. def trans\n+00024900: 706f 7274 5f63 6f6e 7472 6f6c 5f72 6563 port_control_rec\n+00024910: 6569 7665 6428 7365 6c66 2c20 636f 6d6d eived(self, comm\n+00024920: 616e 643a 2073 7472 2c20 6d65 7373 6167 and: str, messag\n+00024930: 653a 204a 736f 6e4f 626a 6563 7429 202d e: JsonObject) -\n+00024940: 3e20 4e6f 6e65 3a0a 2020 2020 2020 2020 > None:. \n+00024950: 6966 2063 6f6d 6d61 6e64 203d 3d20 2769 if command == 'i\n+00024960: 6e69 7427 2061 6e64 2073 656c 662e 696e nit' and self.in\n+00024970: 6974 5f66 7574 7572 6520 6973 206e 6f74 it_future is not\n+00024980: 204e 6f6e 653a 0a20 2020 2020 2020 2020 None:. \n+00024990: 2020 206c 6f67 6765 722e 6465 6275 6728 logger.debug(\n+000249a0: 2747 6f74 2069 6e69 7420 6d65 7373 6167 'Got init messag\n+000249b0: 6520 7769 7468 2061 6374 6976 6520 696e e with active in\n+000249c0: 6974 5f66 7574 7572 652e 2020 5365 7474 it_future. Sett\n+000249d0: 696e 6720 7265 7375 6c74 2e27 290a 2020 ing result.'). \n+000249e0: 2020 2020 2020 2020 2020 7365 6c66 2e69 self.i\n+000249f0: 6e69 745f 6675 7475 7265 2e73 6574 5f72 nit_future.set_r\n+00024a00: 6573 756c 7428 6d65 7373 6167 6529 0a20 esult(message). \n+00024a10: 2020 2020 2020 2065 6c69 6620 636f 6d6d elif comm\n+00024a20: 616e 6420 3d3d 2027 6175 7468 6f72 697a and == 'authoriz\n+00024a30: 6527 3a0a 2020 2020 2020 2020 2020 2020 e':. \n+00024a40: 7365 6c66 2e64 6f5f 6175 7468 6f72 697a self.do_authoriz\n+00024a50: 6528 6d65 7373 6167 6529 0a20 2020 2020 e(message). \n+00024a60: 2020 2065 6c69 6620 636f 6d6d 616e 6420 elif command \n+00024a70: 3d3d 2027 7375 7065 7275 7365 722d 696e == 'superuser-in\n+00024a80: 6974 2d64 6f6e 6527 3a0a 2020 2020 2020 it-done':. \n+00024a90: 2020 2020 2020 7365 6c66 2e64 6f5f 7375 self.do_su\n+00024aa0: 7065 7275 7365 725f 696e 6974 5f64 6f6e peruser_init_don\n+00024ab0: 6528 290a 2020 2020 2020 2020 656c 7365 e(). else\n+00024ac0: 3a0a 2020 2020 2020 2020 2020 2020 7261 :. ra\n+00024ad0: 6973 6520 436f 636b 7069 7450 726f 746f ise CockpitProto\n+00024ae0: 636f 6c45 7272 6f72 2866 2752 6563 6569 colError(f'Recei\n+00024af0: 7665 6420 756e 6578 7065 6374 6564 2063 ved unexpected c\n+00024b00: 6f6e 7472 6f6c 206d 6573 7361 6765 207b ontrol message {\n+00024b10: 636f 6d6d 616e 647d 2729 0a0a 2020 2020 command}').. \n+00024b20: 6465 6620 656f 665f 7265 6365 6976 6564 def eof_received\n+00024b30: 2873 656c 6629 202d 3e20 626f 6f6c 3a0a (self) -> bool:.\n+00024b40: 2020 2020 2020 2020 2320 5765 2061 6c77 # We alw\n+00024b50: 6179 7320 6578 7065 6374 2074 6f20 6265 ays expect to be\n+00024b60: 2074 6865 206f 6e65 7320 746f 2063 6c6f the ones to clo\n+00024b70: 7365 2074 6865 2063 6f6e 6e65 6374 696f se the connectio\n+00024b80: 6e2c 2073 6f20 6966 2077 6520 6765 740a n, so if we get.\n+00024b90: 2020 2020 2020 2020 2320 616e 2045 4f46 # an EOF\n+00024ba0: 2c20 7468 656e 2077 6520 636f 6e73 6964 , then we consid\n+00024bb0: 6572 2069 7420 746f 2062 6520 616e 2065 er it to be an e\n+00024bc0: 7272 6f72 2e20 2054 6869 7320 616c 6c6f rror. This allo\n+00024bd0: 7773 2075 7320 746f 0a20 2020 2020 2020 ws us to. \n+00024be0: 2023 2064 6973 7469 6e67 7569 7368 2063 # distinguish c\n+00024bf0: 6c6f 7365 2063 6175 7365 6420 6279 2075 lose caused by u\n+00024c00: 6e65 7870 6563 7465 6420 454f 4620 2862 nexpected EOF (b\n+00024c10: 7574 206e 6f20 6572 726e 6f20 6672 6f6d ut no errno from\n+00024c20: 2061 0a20 2020 2020 2020 2023 2073 7973 a. # sys\n+00024c30: 6361 6c6c 2066 6169 6c75 7265 2920 7673 call failure) vs\n+00024c40: 2e20 636c 6f73 6520 6361 7573 6564 2062 . close caused b\n+00024c50: 7920 6361 6c6c 696e 6720 2e63 6c6f 7365 y calling .close\n+00024c60: 2829 206f 6e20 6f75 7220 7369 6465 2e0a () on our side..\n+00024c70: 2020 2020 2020 2020 2320 5468 6520 7072 # The pr\n+00024c80: 6f63 6573 7320 6973 2073 7469 6c6c 2072 ocess is still r\n+00024c90: 756e 6e69 6e67 2061 7420 7468 6973 2070 unning at this p\n+00024ca0: 6f69 6e74 2c20 736f 206b 6565 7020 6974 oint, so keep it\n+00024cb0: 2061 6e64 2068 616e 646c 650a 2020 2020 and handle. \n+00024cc0: 2020 2020 2320 7468 6520 6572 726f 7220 # the error \n+00024cd0: 696e 2070 726f 6365 7373 5f65 7869 7465 in process_exite\n+00024ce0: 6428 292e 0a20 2020 2020 2020 206c 6f67 d().. log\n+00024cf0: 6765 722e 6465 6275 6728 2750 6565 7220 ger.debug('Peer \n+00024d00: 2573 2072 6563 6569 7665 6420 756e 6578 %s received unex\n+00024d10: 7065 6374 6564 2045 4f46 272c 2073 656c pected EOF', sel\n+00024d20: 662e 5f5f 636c 6173 735f 5f2e 5f5f 6e61 f.__class__.__na\n+00024d30: 6d65 5f5f 290a 2020 2020 2020 2020 7265 me__). re\n+00024d40: 7475 726e 2054 7275 650a 0a20 2020 2064 turn True.. d\n+00024d50: 6566 2064 6f5f 636c 6f73 6564 2873 656c ef do_closed(sel\n+00024d60: 662c 2065 7863 3a20 4f70 7469 6f6e 616c f, exc: Optional\n+00024d70: 5b45 7863 6570 7469 6f6e 5d29 202d 3e20 [Exception]) -> \n+00024d80: 4e6f 6e65 3a0a 2020 2020 2020 2020 6c6f None:. lo\n+00024d90: 6767 6572 2e64 6562 7567 2827 5065 6572 gger.debug('Peer\n+00024da0: 2025 7320 636f 6e6e 6563 7469 6f6e 206c %s connection l\n+00024db0: 6f73 7420 2573 2025 7327 2c20 7365 6c66 ost %s %s', self\n+00024dc0: 2e5f 5f63 6c61 7373 5f5f 2e5f 5f6e 616d .__class__.__nam\n+00024dd0: 655f 5f2c 2074 7970 6528 6578 6329 2c20 e__, type(exc), \n+00024de0: 6578 6329 0a0a 2020 2020 2020 2020 6966 exc).. if\n+00024df0: 2065 7863 2069 7320 4e6f 6e65 3a0a 2020 exc is None:. \n+00024e00: 2020 2020 2020 2020 2020 7365 6c66 2e73 self.s\n+00024e10: 6875 7464 6f77 6e5f 656e 6470 6f69 6e74 hutdown_endpoint\n+00024e20: 2870 726f 626c 656d 3d27 7465 726d 696e (problem='termin\n+00024e30: 6174 6564 2729 0a20 2020 2020 2020 2065 ated'). e\n+00024e40: 6c69 6620 6973 696e 7374 616e 6365 2865 lif isinstance(e\n+00024e50: 7863 2c20 5065 6572 4578 6974 6564 293a xc, PeerExited):\n+00024e60: 0a20 2020 2020 2020 2020 2020 2023 2061 . # a\n+00024e70: 2063 6f6d 6d6f 6e20 6361 7365 2069 7320 common case is \n+00024e80: 7468 6174 2074 6865 2063 616c 6c65 6420 that the called \n+00024e90: 7065 6572 2064 6f65 7320 6e6f 7420 6578 peer does not ex\n+00024ea0: 6973 740a 2020 2020 2020 2020 2020 2020 ist. \n+00024eb0: 6966 2065 7863 2e65 7869 745f 636f 6465 if exc.exit_code\n+00024ec0: 203d 3d20 3132 373a 0a20 2020 2020 2020 == 127:. \n+00024ed0: 2020 2020 2020 2020 2073 656c 662e 7368 self.sh\n+00024ee0: 7574 646f 776e 5f65 6e64 706f 696e 7428 utdown_endpoint(\n+00024ef0: 7072 6f62 6c65 6d3d 276e 6f2d 636f 636b problem='no-cock\n+00024f00: 7069 7427 290a 2020 2020 2020 2020 2020 pit'). \n+00024f10: 2020 656c 7365 3a0a 2020 2020 2020 2020 else:. \n+00024f20: 2020 2020 2020 2020 7365 6c66 2e73 6875 self.shu\n+00024f30: 7464 6f77 6e5f 656e 6470 6f69 6e74 2870 tdown_endpoint(p\n+00024f40: 726f 626c 656d 3d27 7465 726d 696e 6174 roblem='terminat\n+00024f50: 6564 272c 206d 6573 7361 6765 3d66 2750 ed', message=f'P\n+00024f60: 6565 7220 6578 6974 6564 2077 6974 6820 eer exited with \n+00024f70: 7374 6174 7573 207b 6578 632e 6578 6974 status {exc.exit\n+00024f80: 5f63 6f64 657d 2729 0a20 2020 2020 2020 _code}'). \n+00024f90: 2065 6c69 6620 6973 696e 7374 616e 6365 elif isinstance\n+00024fa0: 2865 7863 2c20 436f 636b 7069 7450 726f (exc, CockpitPro\n+00024fb0: 626c 656d 293a 0a20 2020 2020 2020 2020 blem):. \n+00024fc0: 2020 2073 656c 662e 7368 7574 646f 776e self.shutdown\n+00024fd0: 5f65 6e64 706f 696e 7428 6578 632e 6174 _endpoint(exc.at\n+00024fe0: 7472 7329 0a20 2020 2020 2020 2065 6c73 trs). els\n+00024ff0: 653a 0a20 2020 2020 2020 2020 2020 2073 e:. s\n+00025000: 656c 662e 7368 7574 646f 776e 5f65 6e64 elf.shutdown_end\n+00025010: 706f 696e 7428 7072 6f62 6c65 6d3d 2769 point(problem='i\n+00025020: 6e74 6572 6e61 6c2d 6572 726f 7227 2c0a nternal-error',.\n+00025030: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00025040: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00025050: 2020 206d 6573 7361 6765 3d66 225b 7b65 message=f\"[{e\n+00025060: 7863 2e5f 5f63 6c61 7373 5f5f 2e5f 5f6e xc.__class__.__n\n+00025070: 616d 655f 5f7d 5d20 7b65 7863 2173 7d22 ame__}] {exc!s}\"\n+00025080: 290a 0a20 2020 2020 2020 2023 2049 6620 ).. # If \n+00025090: 2e73 7461 7274 2829 2069 7320 7275 6e6e .start() is runn\n+000250a0: 696e 672c 2077 6520 6e65 6564 2074 6f20 ing, we need to \n+000250b0: 6d61 6b65 2073 7572 6520 6974 2073 746f make sure it sto\n+000250c0: 7073 2072 756e 6e69 6e67 2c0a 2020 2020 ps running,. \n+000250d0: 2020 2020 2320 7261 6973 696e 6720 7468 # raising th\n+000250e0: 6520 636f 7272 6563 7420 6578 6365 7074 e correct except\n+000250f0: 696f 6e2e 0a20 2020 2020 2020 2069 6620 ion.. if \n+00025100: 7365 6c66 2e69 6e69 745f 6675 7475 7265 self.init_future\n+00025110: 2069 7320 6e6f 7420 4e6f 6e65 2061 6e64 is not None and\n+00025120: 206e 6f74 2073 656c 662e 696e 6974 5f66 not self.init_f\n+00025130: 7574 7572 652e 646f 6e65 2829 3a0a 2020 uture.done():. \n+00025140: 2020 2020 2020 2020 2020 6966 2065 7863 if exc\n+00025150: 2069 7320 6e6f 7420 4e6f 6e65 3a0a 2020 is not None:. \n+00025160: 2020 2020 2020 2020 2020 2020 2020 7365 se\n+00025170: 6c66 2e69 6e69 745f 6675 7475 7265 2e73 lf.init_future.s\n+00025180: 6574 5f65 7863 6570 7469 6f6e 2865 7863 et_exception(exc\n+00025190: 290a 2020 2020 2020 2020 2020 2020 656c ). el\n+000251a0: 7365 3a0a 2020 2020 2020 2020 2020 2020 se:. \n+000251b0: 2020 2020 7365 6c66 2e69 6e69 745f 6675 self.init_fu\n+000251c0: 7475 7265 2e63 616e 6365 6c28 290a 0a20 ture.cancel().. \n+000251d0: 2020 2020 2020 2066 6f72 2063 616c 6c62 for callb\n+000251e0: 6163 6b20 696e 2073 656c 662e 646f 6e65 ack in self.done\n+000251f0: 5f63 616c 6c62 6163 6b73 3a0a 2020 2020 _callbacks:. \n+00025200: 2020 2020 2020 2020 6361 6c6c 6261 636b callback\n+00025210: 2829 0a0a 2020 2020 6465 6620 7072 6f63 ().. def proc\n+00025220: 6573 735f 6578 6974 6564 2873 656c 6629 ess_exited(self)\n+00025230: 202d 3e20 4e6f 6e65 3a0a 2020 2020 2020 -> None:. \n+00025240: 2020 6173 7365 7274 2069 7369 6e73 7461 assert isinsta\n+00025250: 6e63 6528 7365 6c66 2e74 7261 6e73 706f nce(self.transpo\n+00025260: 7274 2c20 5375 6270 726f 6365 7373 5472 rt, SubprocessTr\n+00025270: 616e 7370 6f72 7429 0a20 2020 2020 2020 ansport). \n+00025280: 206c 6f67 6765 722e 6465 6275 6728 2750 logger.debug('P\n+00025290: 6565 7220 2573 2065 7869 7465 642c 2073 eer %s exited, s\n+000252a0: 7461 7475 7320 2564 272c 2073 656c 662e tatus %d', self.\n+000252b0: 5f5f 636c 6173 735f 5f2e 5f5f 6e61 6d65 __class__.__name\n+000252c0: 5f5f 2c20 7365 6c66 2e74 7261 6e73 706f __, self.transpo\n+000252d0: 7274 2e67 6574 5f72 6574 7572 6e63 6f64 rt.get_returncod\n+000252e0: 6528 2929 0a20 2020 2020 2020 2072 6574 e()). ret\n+000252f0: 7572 6e63 6f64 6520 3d20 7365 6c66 2e74 urncode = self.t\n+00025300: 7261 6e73 706f 7274 2e67 6574 5f72 6574 ransport.get_ret\n+00025310: 7572 6e63 6f64 6528 290a 2020 2020 2020 urncode(). \n+00025320: 2020 6173 7365 7274 2069 7369 6e73 7461 assert isinsta\n+00025330: 6e63 6528 7265 7475 726e 636f 6465 2c20 nce(returncode, \n+00025340: 696e 7429 0a20 2020 2020 2020 2073 656c int). sel\n+00025350: 662e 636c 6f73 6528 5065 6572 4578 6974 f.close(PeerExit\n+00025360: 6564 2872 6574 7572 6e63 6f64 6529 290a ed(returncode)).\n+00025370: 0a20 2020 2023 2046 6f72 7761 7264 696e . # Forwardin\n+00025380: 6720 6461 7461 3a20 6672 6f6d 2074 6865 g data: from the\n+00025390: 2070 6565 7220 746f 2074 6865 2072 6f75 peer to the rou\n+000253a0: 7465 720a 2020 2020 6465 6620 6368 616e ter. def chan\n+000253b0: 6e65 6c5f 636f 6e74 726f 6c5f 7265 6365 nel_control_rece\n+000253c0: 6976 6564 2873 656c 662c 2063 6861 6e6e ived(self, chann\n+000253d0: 656c 3a20 7374 722c 2063 6f6d 6d61 6e64 el: str, command\n+000253e0: 3a20 7374 722c 206d 6573 7361 6765 3a20 : str, message: \n+000253f0: 4a73 6f6e 4f62 6a65 6374 2920 2d3e 204e JsonObject) -> N\n+00025400: 6f6e 653a 0a20 2020 2020 2020 2069 6620 one:. if \n+00025410: 7365 6c66 2e69 6e69 745f 6675 7475 7265 self.init_future\n+00025420: 2069 7320 6e6f 7420 4e6f 6e65 3a0a 2020 is not None:. \n+00025430: 2020 2020 2020 2020 2020 7261 6973 6520 raise \n+00025440: 436f 636b 7069 7450 726f 746f 636f 6c45 CockpitProtocolE\n+00025450: 7272 6f72 2827 5265 6365 6976 6564 2075 rror('Received u\n+00025460: 6e65 7870 6563 7465 6420 6368 616e 6e65 nexpected channe\n+00025470: 6c20 636f 6e74 726f 6c20 6d65 7373 6167 l control messag\n+00025480: 6520 6265 666f 7265 2069 6e69 7427 290a e before init').\n+00025490: 2020 2020 2020 2020 7365 6c66 2e73 656e self.sen\n+000254a0: 645f 6368 616e 6e65 6c5f 636f 6e74 726f d_channel_contro\n+000254b0: 6c28 6368 616e 6e65 6c2c 2063 6f6d 6d61 l(channel, comma\n+000254c0: 6e64 2c20 6d65 7373 6167 6529 0a0a 2020 nd, message).. \n+000254d0: 2020 6465 6620 6368 616e 6e65 6c5f 6461 def channel_da\n+000254e0: 7461 5f72 6563 6569 7665 6428 7365 6c66 ta_received(self\n+000254f0: 2c20 6368 616e 6e65 6c3a 2073 7472 2c20 , channel: str, \n+00025500: 6461 7461 3a20 6279 7465 7329 202d 3e20 data: bytes) -> \n+00025510: 4e6f 6e65 3a0a 2020 2020 2020 2020 6966 None:. if\n+00025520: 2073 656c 662e 696e 6974 5f66 7574 7572 self.init_futur\n+00025530: 6520 6973 206e 6f74 204e 6f6e 653a 0a20 e is not None:. \n+00025540: 2020 2020 2020 2020 2020 2072 6169 7365 raise\n+00025550: 2043 6f63 6b70 6974 5072 6f74 6f63 6f6c CockpitProtocol\n+00025560: 4572 726f 7228 2752 6563 6569 7665 6420 Error('Received \n+00025570: 756e 6578 7065 6374 6564 2063 6861 6e6e unexpected chann\n+00025580: 656c 2064 6174 6120 6265 666f 7265 2069 el data before i\n+00025590: 6e69 7427 290a 2020 2020 2020 2020 7365 nit'). se\n+000255a0: 6c66 2e73 656e 645f 6368 616e 6e65 6c5f lf.send_channel_\n+000255b0: 6461 7461 2863 6861 6e6e 656c 2c20 6461 data(channel, da\n+000255c0: 7461 290a 0a20 2020 2023 2046 6f72 7761 ta).. # Forwa\n+000255d0: 7264 696e 6720 6461 7461 3a20 6672 6f6d rding data: from\n+000255e0: 2074 6865 2072 6f75 7465 7220 746f 2074 the router to t\n+000255f0: 6865 2070 6565 720a 2020 2020 6465 6620 he peer. def \n+00025600: 646f 5f63 6861 6e6e 656c 5f63 6f6e 7472 do_channel_contr\n+00025610: 6f6c 2873 656c 662c 2063 6861 6e6e 656c ol(self, channel\n+00025620: 3a20 7374 722c 2063 6f6d 6d61 6e64 3a20 : str, command: \n+00025630: 7374 722c 206d 6573 7361 6765 3a20 4a73 str, message: Js\n+00025640: 6f6e 4f62 6a65 6374 2920 2d3e 204e 6f6e onObject) -> Non\n+00025650: 653a 0a20 2020 2020 2020 2061 7373 6572 e:. asser\n+00025660: 7420 7365 6c66 2e69 6e69 745f 6675 7475 t self.init_futu\n+00025670: 7265 2069 7320 4e6f 6e65 0a20 2020 2020 re is None. \n+00025680: 2020 2073 656c 662e 7772 6974 655f 636f self.write_co\n+00025690: 6e74 726f 6c28 6d65 7373 6167 6529 0a0a ntrol(message)..\n+000256a0: 2020 2020 6465 6620 646f 5f63 6861 6e6e def do_chann\n+000256b0: 656c 5f64 6174 6128 7365 6c66 2c20 6368 el_data(self, ch\n+000256c0: 616e 6e65 6c3a 2073 7472 2c20 6461 7461 annel: str, data\n+000256d0: 3a20 6279 7465 7329 202d 3e20 4e6f 6e65 : bytes) -> None\n+000256e0: 3a0a 2020 2020 2020 2020 6173 7365 7274 :. assert\n+000256f0: 2073 656c 662e 696e 6974 5f66 7574 7572 self.init_futur\n+00025700: 6520 6973 204e 6f6e 650a 2020 2020 2020 e is None. \n+00025710: 2020 7365 6c66 2e77 7269 7465 5f63 6861 self.write_cha\n+00025720: 6e6e 656c 5f64 6174 6128 6368 616e 6e65 nnel_data(channe\n+00025730: 6c2c 2064 6174 6129 0a0a 2020 2020 6465 l, data).. de\n+00025740: 6620 646f 5f6b 696c 6c28 7365 6c66 2c20 f do_kill(self, \n+00025750: 686f 7374 3a20 2773 7472 207c 204e 6f6e host: 'str | Non\n+00025760: 6527 2c20 6772 6f75 703a 2027 7374 7220 e', group: 'str \n+00025770: 7c20 4e6f 6e65 272c 206d 6573 7361 6765 | None', message\n+00025780: 3a20 4a73 6f6e 4f62 6a65 6374 2920 2d3e : JsonObject) ->\n+00025790: 204e 6f6e 653a 0a20 2020 2020 2020 2061 None:. a\n+000257a0: 7373 6572 7420 7365 6c66 2e69 6e69 745f ssert self.init_\n+000257b0: 6675 7475 7265 2069 7320 4e6f 6e65 0a20 future is None. \n+000257c0: 2020 2020 2020 2073 656c 662e 7772 6974 self.writ\n+000257d0: 655f 636f 6e74 726f 6c28 6d65 7373 6167 e_control(messag\n+000257e0: 6529 0a0a 2020 2020 6465 6620 646f 5f63 e).. def do_c\n+000257f0: 6c6f 7365 2873 656c 6629 202d 3e20 4e6f lose(self) -> No\n+00025800: 6e65 3a0a 2020 2020 2020 2020 7365 6c66 ne:. self\n+00025810: 2e63 6c6f 7365 2829 0a0a 0a63 6c61 7373 .close()...class\n+00025820: 2043 6f6e 6669 6775 7265 6450 6565 7228 ConfiguredPeer(\n+00025830: 5065 6572 293a 0a20 2020 2063 6f6e 6669 Peer):. confi\n+00025840: 673a 2042 7269 6467 6543 6f6e 6669 670a g: BridgeConfig.\n+00025850: 2020 2020 6172 6773 3a20 5365 7175 656e args: Sequen\n+00025860: 6365 5b73 7472 5d0a 2020 2020 656e 763a ce[str]. env:\n+00025870: 2053 6571 7565 6e63 655b 7374 725d 0a0a Sequence[str]..\n+00025880: 2020 2020 6465 6620 5f5f 696e 6974 5f5f def __init__\n+00025890: 2873 656c 662c 2072 6f75 7465 723a 2052 (self, router: R\n+000258a0: 6f75 7465 722c 2063 6f6e 6669 673a 2042 outer, config: B\n+000258b0: 7269 6467 6543 6f6e 6669 6729 3a0a 2020 ridgeConfig):. \n+000258c0: 2020 2020 2020 7365 6c66 2e63 6f6e 6669 self.confi\n+000258d0: 6720 3d20 636f 6e66 6967 0a20 2020 2020 g = config. \n+000258e0: 2020 2073 656c 662e 6172 6773 203d 2063 self.args = c\n+000258f0: 6f6e 6669 672e 7370 6177 6e0a 2020 2020 onfig.spawn. \n+00025900: 2020 2020 7365 6c66 2e65 6e76 203d 2063 self.env = c\n+00025910: 6f6e 6669 672e 656e 7669 726f 6e0a 2020 onfig.environ. \n+00025920: 2020 2020 2020 7375 7065 7228 292e 5f5f super().__\n+00025930: 696e 6974 5f5f 2872 6f75 7465 7229 0a0a init__(router)..\n+00025940: 2020 2020 6173 796e 6320 6465 6620 646f async def do\n+00025950: 5f63 6f6e 6e65 6374 5f74 7261 6e73 706f _connect_transpo\n+00025960: 7274 2873 656c 6629 202d 3e20 4e6f 6e65 rt(self) -> None\n+00025970: 3a0a 2020 2020 2020 2020 6177 6169 7420 :. await \n+00025980: 7365 6c66 2e73 7061 776e 2873 656c 662e self.spawn(self.\n+00025990: 6172 6773 2c20 7365 6c66 2e65 6e76 290a args, self.env).\n+000259a0: 0a0a 636c 6173 7320 5065 6572 526f 7574 ..class PeerRout\n+000259b0: 696e 6752 756c 6528 526f 7574 696e 6752 ingRule(RoutingR\n+000259c0: 756c 6529 3a0a 2020 2020 636f 6e66 6967 ule):. config\n+000259d0: 3a20 4272 6964 6765 436f 6e66 6967 0a20 : BridgeConfig. \n+000259e0: 2020 206d 6174 6368 3a20 4a73 6f6e 4f62 match: JsonOb\n+000259f0: 6a65 6374 0a20 2020 2070 6565 723a 204f ject. peer: O\n+00025a00: 7074 696f 6e61 6c5b 5065 6572 5d0a 0a20 ptional[Peer].. \n+00025a10: 2020 2064 6566 205f 5f69 6e69 745f 5f28 def __init__(\n+00025a20: 7365 6c66 2c20 726f 7574 6572 3a20 526f self, router: Ro\n+00025a30: 7574 6572 2c20 636f 6e66 6967 3a20 4272 uter, config: Br\n+00025a40: 6964 6765 436f 6e66 6967 293a 0a20 2020 idgeConfig):. \n+00025a50: 2020 2020 2073 7570 6572 2829 2e5f 5f69 super().__i\n+00025a60: 6e69 745f 5f28 726f 7574 6572 290a 2020 nit__(router). \n+00025a70: 2020 2020 2020 7365 6c66 2e63 6f6e 6669 self.confi\n+00025a80: 6720 3d20 636f 6e66 6967 0a20 2020 2020 g = config. \n+00025a90: 2020 2073 656c 662e 6d61 7463 6820 3d20 self.match = \n+00025aa0: 636f 6e66 6967 2e6d 6174 6368 0a20 2020 config.match. \n+00025ab0: 2020 2020 2073 656c 662e 7065 6572 203d self.peer =\n+00025ac0: 204e 6f6e 650a 0a20 2020 2064 6566 2061 None.. def a\n+00025ad0: 7070 6c79 5f72 756c 6528 7365 6c66 2c20 pply_rule(self, \n+00025ae0: 6f70 7469 6f6e 733a 204a 736f 6e4f 626a options: JsonObj\n+00025af0: 6563 7429 202d 3e20 4f70 7469 6f6e 616c ect) -> Optional\n+00025b00: 5b50 6565 725d 3a0a 2020 2020 2020 2020 [Peer]:. \n+00025b10: 2320 4368 6563 6b20 7468 6174 2077 6520 # Check that we \n+00025b20: 6d61 7463 680a 0a20 2020 2020 2020 2066 match.. f\n+00025b30: 6f72 206b 6579 2c20 7661 6c75 6520 696e or key, value in\n+00025b40: 2073 656c 662e 6d61 7463 682e 6974 656d self.match.item\n+00025b50: 7328 293a 0a20 2020 2020 2020 2020 2020 s():. \n+00025b60: 2069 6620 6b65 7920 6e6f 7420 696e 206f if key not in o\n+00025b70: 7074 696f 6e73 3a0a 2020 2020 2020 2020 ptions:. \n+00025b80: 2020 2020 2020 2020 6c6f 6767 6572 2e64 logger.d\n+00025b90: 6562 7567 2827 2020 2020 2020 2020 7265 ebug(' re\n+00025ba0: 6a65 6374 696e 6720 6265 6361 7573 6520 jecting because \n+00025bb0: 6b65 7920 2573 2069 7320 6d69 7373 696e key %s is missin\n+00025bc0: 6727 2c20 6b65 7929 0a20 2020 2020 2020 g', key). \n+00025bd0: 2020 2020 2020 2020 2072 6574 7572 6e20 return \n+00025be0: 4e6f 6e65 0a20 2020 2020 2020 2020 2020 None. \n+00025bf0: 2069 6620 7661 6c75 6520 6973 206e 6f74 if value is not\n+00025c00: 204e 6f6e 6520 616e 6420 6f70 7469 6f6e None and option\n+00025c10: 735b 6b65 795d 2021 3d20 7661 6c75 653a s[key] != value:\n+00025c20: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+00025c30: 206c 6f67 6765 722e 6465 6275 6728 2720 logger.debug(' \n+00025c40: 2020 2020 2020 2072 656a 6563 7469 6e67 rejecting\n+00025c50: 2062 6563 6175 7365 206b 6579 2025 7320 because key %s \n+00025c60: 6861 7320 7772 6f6e 6720 7661 6c75 6520 has wrong value \n+00025c70: 2573 2028 7673 2025 7329 272c 206b 6579 %s (vs %s)', key\n+00025c80: 2c20 6f70 7469 6f6e 735b 6b65 795d 2c20 , options[key], \n+00025c90: 7661 6c75 6529 0a20 2020 2020 2020 2020 value). \n+00025ca0: 2020 2020 2020 2072 6574 7572 6e20 4e6f return No\n+00025cb0: 6e65 0a0a 2020 2020 2020 2020 2320 5374 ne.. # St\n+00025cc0: 6172 7420 7468 6520 7065 6572 2069 6620 art the peer if \n+00025cd0: 6974 2773 206e 6f74 2072 756e 6e69 6e67 it's not running\n+00025ce0: 2061 6c72 6561 6479 0a20 2020 2020 2020 already. \n+00025cf0: 2069 6620 7365 6c66 2e70 6565 7220 6973 if self.peer is\n+00025d00: 204e 6f6e 653a 0a20 2020 2020 2020 2020 None:. \n+00025d10: 2020 2073 656c 662e 7065 6572 203d 2043 self.peer = C\n+00025d20: 6f6e 6669 6775 7265 6450 6565 7228 7365 onfiguredPeer(se\n+00025d30: 6c66 2e72 6f75 7465 722c 2073 656c 662e lf.router, self.\n+00025d40: 636f 6e66 6967 290a 2020 2020 2020 2020 config). \n+00025d50: 2020 2020 7365 6c66 2e70 6565 722e 6164 self.peer.ad\n+00025d60: 645f 646f 6e65 5f63 616c 6c62 6163 6b28 d_done_callback(\n+00025d70: 7365 6c66 2e70 6565 725f 636c 6f73 6564 self.peer_closed\n+00025d80: 290a 2020 2020 2020 2020 2020 2020 6173 ). as\n+00025d90: 7365 7274 2073 656c 662e 726f 7574 6572 sert self.router\n+00025da0: 2e69 6e69 745f 686f 7374 0a20 2020 2020 .init_host. \n+00025db0: 2020 2020 2020 2073 656c 662e 7065 6572 self.peer\n+00025dc0: 2e73 7461 7274 5f69 6e5f 6261 636b 6772 .start_in_backgr\n+00025dd0: 6f75 6e64 2869 6e69 745f 686f 7374 3d73 ound(init_host=s\n+00025de0: 656c 662e 726f 7574 6572 2e69 6e69 745f elf.router.init_\n+00025df0: 686f 7374 290a 0a20 2020 2020 2020 2072 host).. r\n+00025e00: 6574 7572 6e20 7365 6c66 2e70 6565 720a eturn self.peer.\n+00025e10: 0a20 2020 2064 6566 2070 6565 725f 636c . def peer_cl\n+00025e20: 6f73 6564 2873 656c 6629 3a0a 2020 2020 osed(self):. \n+00025e30: 2020 2020 7365 6c66 2e70 6565 7220 3d20 self.peer = \n+00025e40: 4e6f 6e65 0a0a 2020 2020 6465 6620 7368 None.. def sh\n+00025e50: 7574 646f 776e 2873 656c 6629 3a0a 2020 utdown(self):. \n+00025e60: 2020 2020 2020 6966 2073 656c 662e 7065 if self.pe\n+00025e70: 6572 2069 7320 6e6f 7420 4e6f 6e65 3a0a er is not None:.\n+00025e80: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n+00025e90: 2e70 6565 722e 636c 6f73 6528 290a 0a0a .peer.close()...\n+00025ea0: 636c 6173 7320 5065 6572 7352 6f75 7469 class PeersRouti\n+00025eb0: 6e67 5275 6c65 2852 6f75 7469 6e67 5275 ngRule(RoutingRu\n+00025ec0: 6c65 293a 0a20 2020 2072 756c 6573 3a20 le):. rules: \n+00025ed0: 4c69 7374 5b50 6565 7252 6f75 7469 6e67 List[PeerRouting\n+00025ee0: 5275 6c65 5d20 3d20 5b5d 0a0a 2020 2020 Rule] = [].. \n+00025ef0: 6465 6620 6170 706c 795f 7275 6c65 2873 def apply_rule(s\n+00025f00: 656c 662c 206f 7074 696f 6e73 3a20 4a73 elf, options: Js\n+00025f10: 6f6e 4f62 6a65 6374 2920 2d3e 204f 7074 onObject) -> Opt\n+00025f20: 696f 6e61 6c5b 456e 6470 6f69 6e74 5d3a ional[Endpoint]:\n+00025f30: 0a20 2020 2020 2020 206c 6f67 6765 722e . logger.\n+00025f40: 6465 6275 6728 2720 2020 2063 6f6e 7369 debug(' consi\n+00025f50: 6465 7269 6e67 2025 6420 7275 6c65 7327 dering %d rules'\n+00025f60: 2c20 6c65 6e28 7365 6c66 2e72 756c 6573 , len(self.rules\n+00025f70: 2929 0a20 2020 2020 2020 2066 6f72 2072 )). for r\n+00025f80: 756c 6520 696e 2073 656c 662e 7275 6c65 ule in self.rule\n+00025f90: 733a 0a20 2020 2020 2020 2020 2020 206c s:. l\n+00025fa0: 6f67 6765 722e 6465 6275 6728 2720 2020 ogger.debug(' \n+00025fb0: 2020 2063 6f6e 7369 6465 7269 6e67 2025 considering %\n+00025fc0: 7327 2c20 7275 6c65 2e63 6f6e 6669 672e s', rule.config.\n+00025fd0: 6e61 6d65 290a 2020 2020 2020 2020 2020 name). \n+00025fe0: 2020 656e 6470 6f69 6e74 203d 2072 756c endpoint = rul\n+00025ff0: 652e 6170 706c 795f 7275 6c65 286f 7074 e.apply_rule(opt\n+00026000: 696f 6e73 290a 2020 2020 2020 2020 2020 ions). \n+00026010: 2020 6966 2065 6e64 706f 696e 7420 6973 if endpoint is\n+00026020: 206e 6f74 204e 6f6e 653a 0a20 2020 2020 not None:. \n+00026030: 2020 2020 2020 2020 2020 206c 6f67 6765 logge\n+00026040: 722e 6465 6275 6728 2720 2020 2020 2020 r.debug(' \n+00026050: 2073 656c 6563 7465 6427 290a 2020 2020 selected'). \n+00026060: 2020 2020 2020 2020 2020 2020 7265 7475 retu\n+00026070: 726e 2065 6e64 706f 696e 740a 2020 2020 rn endpoint. \n+00026080: 2020 2020 6c6f 6767 6572 2e64 6562 7567 logger.debug\n+00026090: 2827 2020 2020 2020 6e6f 2070 6565 7220 (' no peer \n+000260a0: 7275 6c65 7320 6d61 7463 6865 6427 290a rules matched').\n+000260b0: 2020 2020 2020 2020 7265 7475 726e 204e return N\n+000260c0: 6f6e 650a 0a20 2020 2064 6566 2073 6574 one.. def set\n+000260d0: 5f63 6f6e 6669 6773 2873 656c 662c 2062 _configs(self, b\n+000260e0: 7269 6467 655f 636f 6e66 6967 733a 2053 ridge_configs: S\n+000260f0: 6571 7565 6e63 655b 4272 6964 6765 436f equence[BridgeCo\n+00026100: 6e66 6967 5d29 202d 3e20 4e6f 6e65 3a0a nfig]) -> None:.\n+00026110: 2020 2020 2020 2020 6f6c 645f 7275 6c65 old_rule\n+00026120: 7320 3d20 7365 6c66 2e72 756c 6573 0a20 s = self.rules. \n+00026130: 2020 2020 2020 2073 656c 662e 7275 6c65 self.rule\n+00026140: 7320 3d20 5b5d 0a0a 2020 2020 2020 2020 s = [].. \n+00026150: 666f 7220 636f 6e66 6967 2069 6e20 6272 for config in br\n+00026160: 6964 6765 5f63 6f6e 6669 6773 3a0a 2020 idge_configs:. \n+00026170: 2020 2020 2020 2020 2020 2320 5468 6f73 # Thos\n+00026180: 6520 6172 6520 6861 6e64 6c65 6420 656c e are handled el\n+00026190: 7365 7768 6572 652e 2e2e 0a20 2020 2020 sewhere.... \n+000261a0: 2020 2020 2020 2069 6620 636f 6e66 6967 if config\n+000261b0: 2e70 7269 7669 6c65 6765 6420 6f72 2027 .privileged or '\n+000261c0: 686f 7374 2720 696e 2063 6f6e 6669 672e host' in config.\n+000261d0: 6d61 7463 683a 0a20 2020 2020 2020 2020 match:. \n+000261e0: 2020 2020 2020 2063 6f6e 7469 6e75 650a continue.\n+000261f0: 0a20 2020 2020 2020 2020 2020 2023 2054 . # T\n+00026200: 7279 2074 6f20 7265 7573 6520 616e 2065 ry to reuse an e\n+00026210: 7869 7374 696e 6720 7275 6c65 2c20 6966 xisting rule, if\n+00026220: 206f 6e65 2065 7869 7374 732e 2e2e 0a20 one exists.... \n+00026230: 2020 2020 2020 2020 2020 2066 6f72 2072 for r\n+00026240: 756c 6520 696e 206c 6973 7428 6f6c 645f ule in list(old_\n+00026250: 7275 6c65 7329 3a0a 2020 2020 2020 2020 rules):. \n+00026260: 2020 2020 2020 2020 6966 2072 756c 652e if rule.\n+00026270: 636f 6e66 6967 203d 3d20 636f 6e66 6967 config == config\n+00026280: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n+00026290: 2020 2020 2020 6f6c 645f 7275 6c65 732e old_rules.\n+000262a0: 7265 6d6f 7665 2872 756c 6529 0a20 2020 remove(rule). \n+000262b0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000262c0: 2062 7265 616b 0a20 2020 2020 2020 2020 break. \n+000262d0: 2020 2065 6c73 653a 0a20 2020 2020 2020 else:. \n+000262e0: 2020 2020 2020 2020 2023 202e 2e2e 206f # ... o\n+000262f0: 7468 6572 7769 7365 2c20 6372 6561 7465 therwise, create\n+00026300: 2061 206e 6577 206f 6e65 2e0a 2020 2020 a new one.. \n+00026310: 2020 2020 2020 2020 2020 2020 7275 6c65 rule\n+00026320: 203d 2050 6565 7252 6f75 7469 6e67 5275 = PeerRoutingRu\n+00026330: 6c65 2873 656c 662e 726f 7574 6572 2c20 le(self.router, \n+00026340: 636f 6e66 6967 290a 0a20 2020 2020 2020 config).. \n+00026350: 2020 2020 2073 656c 662e 7275 6c65 732e self.rules.\n+00026360: 6170 7065 6e64 2872 756c 6529 0a0a 2020 append(rule).. \n+00026370: 2020 2020 2020 2320 636c 6f73 6520 646f # close do\n+00026380: 776e 2074 6865 206f 6c64 2072 756c 6573 wn the old rules\n+00026390: 2074 6861 7420 6469 646e 2774 2067 6574 that didn't get\n+000263a0: 2072 6563 6c61 696d 6564 0a20 2020 2020 reclaimed. \n+000263b0: 2020 2066 6f72 2072 756c 6520 696e 206f for rule in o\n+000263c0: 6c64 5f72 756c 6573 3a0a 2020 2020 2020 ld_rules:. \n+000263d0: 2020 2020 2020 7275 6c65 2e73 6875 7464 rule.shutd\n+000263e0: 6f77 6e28 290a 0a20 2020 2064 6566 2073 own().. def s\n+000263f0: 6875 7464 6f77 6e28 7365 6c66 293a 0a20 hutdown(self):. \n+00026400: 2020 2020 2020 2066 6f72 2072 756c 6520 for rule \n+00026410: 696e 2073 656c 662e 7275 6c65 733a 0a20 in self.rules:. \n+00026420: 2020 2020 2020 2020 2020 2072 756c 652e rule.\n+00026430: 7368 7574 646f 776e 2829 0a27 2727 2e65 shutdown().'''.e\n+00026440: 6e63 6f64 6528 2775 7466 2d38 2729 2c0a ncode('utf-8'),.\n+00026450: 2020 2763 6f63 6b70 6974 2f70 6f6c 6b69 'cockpit/polki\n+00026460: 742e 7079 273a 2072 2727 2723 2054 6869 t.py': r'''# Thi\n+00026470: 7320 6669 6c65 2069 7320 7061 7274 206f s file is part o\n+00026480: 6620 436f 636b 7069 742e 0a23 0a23 2043 f Cockpit..#.# C\n+00026490: 6f70 7972 6967 6874 2028 4329 2032 3032 opyright (C) 202\n+000264a0: 3320 5265 6420 4861 742c 2049 6e63 2e0a 3 Red Hat, Inc..\n+000264b0: 230a 2320 5468 6973 2070 726f 6772 616d #.# This program\n+000264c0: 2069 7320 6672 6565 2073 6f66 7477 6172 is free softwar\n+000264d0: 653a 2079 6f75 2063 616e 2072 6564 6973 e: you can redis\n+000264e0: 7472 6962 7574 6520 6974 2061 6e64 2f6f tribute it and/o\n+000264f0: 7220 6d6f 6469 6679 0a23 2069 7420 756e r modify.# it un\n+00026500: 6465 7220 7468 6520 7465 726d 7320 6f66 der the terms of\n+00026510: 2074 6865 2047 4e55 2047 656e 6572 616c the GNU General\n+00026520: 2050 7562 6c69 6320 4c69 6365 6e73 6520 Public License \n+00026530: 6173 2070 7562 6c69 7368 6564 2062 790a as published by.\n+00026540: 2320 7468 6520 4672 6565 2053 6f66 7477 # the Free Softw\n+00026550: 6172 6520 466f 756e 6461 7469 6f6e 2c20 are Foundation, \n+00026560: 6569 7468 6572 2076 6572 7369 6f6e 2033 either version 3\n+00026570: 206f 6620 7468 6520 4c69 6365 6e73 652c of the License,\n+00026580: 206f 720a 2320 2861 7420 796f 7572 206f or.# (at your o\n+00026590: 7074 696f 6e29 2061 6e79 206c 6174 6572 ption) any later\n+000265a0: 2076 6572 7369 6f6e 2e0a 230a 2320 5468 version..#.# Th\n+000265b0: 6973 2070 726f 6772 616d 2069 7320 6469 is program is di\n+000265c0: 7374 7269 6275 7465 6420 696e 2074 6865 stributed in the\n+000265d0: 2068 6f70 6520 7468 6174 2069 7420 7769 hope that it wi\n+000265e0: 6c6c 2062 6520 7573 6566 756c 2c0a 2320 ll be useful,.# \n+000265f0: 6275 7420 5749 5448 4f55 5420 414e 5920 but WITHOUT ANY \n+00026600: 5741 5252 414e 5459 3b20 7769 7468 6f75 WARRANTY; withou\n+00026610: 7420 6576 656e 2074 6865 2069 6d70 6c69 t even the impli\n+00026620: 6564 2077 6172 7261 6e74 7920 6f66 0a23 ed warranty of.#\n+00026630: 204d 4552 4348 414e 5441 4249 4c49 5459 MERCHANTABILITY\n+00026640: 206f 7220 4649 544e 4553 5320 464f 5220 or FITNESS FOR \n+00026650: 4120 5041 5254 4943 554c 4152 2050 5552 A PARTICULAR PUR\n+00026660: 504f 5345 2e20 2053 6565 2074 6865 0a23 POSE. See the.#\n+00026670: 2047 4e55 2047 656e 6572 616c 2050 7562 GNU General Pub\n+00026680: 6c69 6320 4c69 6365 6e73 6520 666f 7220 lic License for \n+00026690: 6d6f 7265 2064 6574 6169 6c73 2e0a 230a more details..#.\n+000266a0: 2320 596f 7520 7368 6f75 6c64 2068 6176 # You should hav\n+000266b0: 6520 7265 6365 6976 6564 2061 2063 6f70 e received a cop\n+000266c0: 7920 6f66 2074 6865 2047 4e55 2047 656e y of the GNU Gen\n+000266d0: 6572 616c 2050 7562 6c69 6320 4c69 6365 eral Public Lice\n+000266e0: 6e73 650a 2320 616c 6f6e 6720 7769 7468 nse.# along with\n+000266f0: 2074 6869 7320 7072 6f67 7261 6d2e 2020 this program. \n+00026700: 4966 206e 6f74 2c20 7365 6520 3c68 7474 If not, see ...im\n+00026730: 706f 7274 2061 7379 6e63 696f 0a69 6d70 port asyncio.imp\n+00026740: 6f72 7420 6c6f 6361 6c65 0a69 6d70 6f72 ort locale.impor\n+00026750: 7420 6c6f 6767 696e 670a 696d 706f 7274 t logging.import\n+00026760: 206f 730a 696d 706f 7274 2070 7764 0a66 os.import pwd.f\n+00026770: 726f 6d20 7479 7069 6e67 2069 6d70 6f72 rom typing impor\n+00026780: 7420 4469 6374 2c20 4c69 7374 2c20 5365 t Dict, List, Se\n+00026790: 7175 656e 6365 2c20 5475 706c 650a 0a66 quence, Tuple..f\n+000267a0: 726f 6d20 636f 636b 7069 742e 5f76 656e rom cockpit._ven\n+000267b0: 646f 722e 6665 726e 7920 696d 706f 7274 dor.ferny import\n+000267c0: 2041 736b 7061 7373 4861 6e64 6c65 720a AskpassHandler.\n+000267d0: 6672 6f6d 2063 6f63 6b70 6974 2e5f 7665 from cockpit._ve\n+000267e0: 6e64 6f72 2e73 7973 7465 6d64 5f63 7479 ndor.systemd_cty\n+000267f0: 7065 7320 696d 706f 7274 2056 6172 6961 pes import Varia\n+00026800: 6e74 2c20 6275 730a 0a23 2074 6861 7420 nt, bus..# that \n+00026810: 7061 7468 2069 7320 7661 6c69 6420 6f6e path is valid on\n+00026820: 2061 7420 6c65 6173 7420 4465 6269 616e at least Debian\n+00026830: 2c20 4665 646f 7261 2f52 4845 4c2c 2061 , Fedora/RHEL, a\n+00026840: 6e64 2041 7263 680a 4845 4c50 4552 5f50 nd Arch.HELPER_P\n+00026850: 4154 4820 3d20 272f 7573 722f 6c69 622f ATH = '/usr/lib/\n+00026860: 706f 6c6b 6974 2d31 2f70 6f6c 6b69 742d polkit-1/polkit-\n+00026870: 6167 656e 742d 6865 6c70 6572 2d31 270a agent-helper-1'.\n+00026880: 0a41 4745 4e54 5f44 4255 535f 5041 5448 .AGENT_DBUS_PATH\n+00026890: 203d 2027 2f50 6f6c 6b69 7441 6765 6e74 = '/PolkitAgent\n+000268a0: 270a 0a6c 6f67 6765 7220 3d20 6c6f 6767 '..logger = logg\n+000268b0: 696e 672e 6765 744c 6f67 6765 7228 5f5f ing.getLogger(__\n+000268c0: 6e61 6d65 5f5f 290a 0a49 6465 6e74 6974 name__)..Identit\n+000268d0: 7920 3d20 5475 706c 655b 7374 722c 2044 y = Tuple[str, D\n+000268e0: 6963 745b 7374 722c 2056 6172 6961 6e74 ict[str, Variant\n+000268f0: 5d5d 0a0a 0a23 2068 7474 7073 3a2f 2f77 ]]...# https://w\n+00026900: 7777 2e66 7265 6564 6573 6b74 6f70 2e6f ww.freedesktop.o\n+00026910: 7267 2f73 6f66 7477 6172 652f 706f 6c6b rg/software/polk\n+00026920: 6974 2f64 6f63 732f 6c61 7465 7374 2f65 it/docs/latest/e\n+00026930: 6767 6462 7573 2d69 6e74 6572 6661 6365 ggdbus-interface\n+00026940: 2d6f 7267 2e66 7265 6564 6573 6b74 6f70 -org.freedesktop\n+00026950: 2e50 6f6c 6963 794b 6974 312e 4175 7468 .PolicyKit1.Auth\n+00026960: 656e 7469 6361 7469 6f6e 4167 656e 742e enticationAgent.\n+00026970: 6874 6d6c 0a0a 2320 4e6f 7465 2074 6861 html..# Note tha\n+00026980: 7420 7765 2064 6f6e 2774 2069 6d70 6c65 t we don't imple\n+00026990: 6d65 6e74 2074 6865 2043 616e 6365 6c41 ment the CancelA\n+000269a0: 7574 6865 6e74 6963 6174 696f 6e28 2920 uthentication() \n+000269b0: 4150 492e 2070 6b65 7865 6320 6765 7473 API. pkexec gets\n+000269c0: 2063 616c 6c65 6420 696e 2061 2077 6179 called in a way\n+000269d0: 2074 6861 7420 6861 7320 6e6f 206f 7070 that has no opp\n+000269e0: 6f72 7475 6e69 7479 2074 6f0a 2320 6361 ortunity to.# ca\n+000269f0: 6e63 656c 2061 6e20 6f6e 676f 696e 6720 ncel an ongoing \n+00026a00: 6175 7468 656e 7469 6361 7469 6f6e 2066 authentication f\n+00026a10: 726f 6d20 7468 6520 706b 6578 6563 2073 rom the pkexec s\n+00026a20: 6964 652e 204f 6e20 7468 6520 5549 2073 ide. On the UI s\n+00026a30: 6964 6520 6361 6e63 656c 6c61 7469 6f6e ide cancellation\n+00026a40: 2069 7320 696d 706c 656d 656e 7465 6420 is implemented \n+00026a50: 7669 6120 7468 6520 7374 616e 6461 7264 via the standard\n+00026a60: 0a23 2061 7379 6e63 696f 2070 726f 6365 .# asyncio proce\n+00026a70: 7373 206d 6563 6861 6e69 736d 2e20 4966 ss mechanism. If\n+00026a80: 2077 6520 6576 6572 206e 6565 6420 4361 we ever need Ca\n+00026a90: 6e63 656c 4175 7468 656e 7469 6361 7469 ncelAuthenticati\n+00026aa0: 6f6e 2829 2c20 7765 2063 6f75 6c64 206b on(), we could k\n+00026ab0: 6565 7020 6120 636f 6f6b 6965 20e2 8692 eep a cookie ...\n+00026ac0: 2067 6574 5f63 7572 7265 6e74 5f74 6173 get_current_tas\n+00026ad0: 6b28 290a 2320 6d61 7070 696e 672c 2062 k().# mapping, b\n+00026ae0: 7574 2074 6861 7420 6d65 7468 6f64 2069 ut that method i\n+00026af0: 7320 6e6f 7420 6176 6169 6c61 626c 6520 s not available \n+00026b00: 666f 7220 5079 7468 6f6e 2033 2e36 2079 for Python 3.6 y\n+00026b10: 6574 2e0a 0a63 6c61 7373 206f 7267 5f66 et...class org_f\n+00026b20: 7265 6564 6573 6b74 6f70 5f50 6f6c 6963 reedesktop_Polic\n+00026b30: 794b 6974 315f 4175 7468 656e 7469 6361 yKit1_Authentica\n+00026b40: 7469 6f6e 4167 656e 7428 6275 732e 4f62 tionAgent(bus.Ob\n+00026b50: 6a65 6374 293a 0a20 2020 2064 6566 205f ject):. def _\n+00026b60: 5f69 6e69 745f 5f28 7365 6c66 2c20 7265 _init__(self, re\n+00026b70: 7370 6f6e 6465 723a 2041 736b 7061 7373 sponder: Askpass\n+00026b80: 4861 6e64 6c65 7229 3a0a 2020 2020 2020 Handler):. \n+00026b90: 2020 7375 7065 7228 292e 5f5f 696e 6974 super().__init\n+00026ba0: 5f5f 2829 0a20 2020 2020 2020 2073 656c __(). sel\n+00026bb0: 662e 7265 7370 6f6e 6465 7220 3d20 7265 f.responder = re\n+00026bc0: 7370 6f6e 6465 720a 0a20 2020 2023 2063 sponder.. # c\n+00026bd0: 6f6e 6675 7369 6e67 6c79 206e 616d 6564 onfusingly named\n+00026be0: 3a20 7468 6973 2061 6374 7561 6c6c 7920 : this actually \n+00026bf0: 646f 6573 2074 6865 2077 686f 6c65 2061 does the whole a\n+00026c00: 7574 6865 6e74 6963 6174 696f 6e20 6469 uthentication di\n+00026c10: 616c 6f67 2c20 7365 6520 646f 6373 0a20 alog, see docs. \n+00026c20: 2020 2040 6275 732e 496e 7465 7266 6163 @bus.Interfac\n+00026c30: 652e 4d65 7468 6f64 2827 272c 205b 2773 e.Method('', ['s\n+00026c40: 272c 2027 7327 2c20 2773 272c 2027 617b ', 's', 's', 'a{\n+00026c50: 7373 7d27 2c20 2773 272c 2027 6128 7361 ss}', 's', 'a(sa\n+00026c60: 7b73 767d 2927 5d29 0a20 2020 2061 7379 {sv})']). asy\n+00026c70: 6e63 2064 6566 2062 6567 696e 5f61 7574 nc def begin_aut\n+00026c80: 6865 6e74 6963 6174 696f 6e28 7365 6c66 hentication(self\n+00026c90: 2c20 6163 7469 6f6e 5f69 643a 2073 7472 , action_id: str\n+00026ca0: 2c20 6d65 7373 6167 653a 2073 7472 2c20 , message: str, \n+00026cb0: 6963 6f6e 5f6e 616d 653a 2073 7472 2c0a icon_name: str,.\n+00026cc0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00026cd0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00026ce0: 2020 2064 6574 6169 6c73 3a20 4469 6374 details: Dict\n+00026cf0: 5b73 7472 2c20 7374 725d 2c20 636f 6f6b [str, str], cook\n+00026d00: 6965 3a20 7374 722c 2069 6465 6e74 6974 ie: str, identit\n+00026d10: 6965 733a 2053 6571 7565 6e63 655b 4964 ies: Sequence[Id\n+00026d20: 656e 7469 7479 5d29 202d 3e20 4e6f 6e65 entity]) -> None\n+00026d30: 3a0a 2020 2020 2020 2020 6c6f 6767 6572 :. logger\n+00026d40: 2e64 6562 7567 2827 4265 6769 6e41 7574 .debug('BeginAut\n+00026d50: 6865 6e74 6963 6174 696f 6e3a 2061 6374 hentication: act\n+00026d60: 696f 6e20 2573 2c20 6d65 7373 6167 6520 ion %s, message \n+00026d70: 2225 7322 2c20 6963 6f6e 2025 732c 2064 \"%s\", icon %s, d\n+00026d80: 6574 6169 6c73 2025 732c 2063 6f6f 6b69 etails %s, cooki\n+00026d90: 6520 2573 2c20 6964 656e 7469 7469 6573 e %s, identities\n+00026da0: 2025 7227 2c0a 2020 2020 2020 2020 2020 %r',. \n+00026db0: 2020 2020 2020 2020 2020 2061 6374 696f actio\n+00026dc0: 6e5f 6964 2c20 6d65 7373 6167 652c 2069 n_id, message, i\n+00026dd0: 636f 6e5f 6e61 6d65 2c20 6465 7461 696c con_name, detail\n+00026de0: 732c 2063 6f6f 6b69 652c 2069 6465 6e74 s, cookie, ident\n+00026df0: 6974 6965 7329 0a20 2020 2020 2020 2023 ities). #\n+00026e00: 206f 6e6c 7920 7375 7070 6f72 7420 6175 only support au\n+00026e10: 7468 656e 7469 6361 7469 6f6e 2061 7320 thentication as \n+00026e20: 6f75 7273 656c 7665 732c 2061 7320 7765 ourselves, as we\n+00026e30: 2064 6f6e 2774 2079 6574 2068 6176 6520 don't yet have \n+00026e40: 7468 650a 2020 2020 2020 2020 2320 7072 the. # pr\n+00026e50: 6f74 6f63 6f6c 2070 6c75 6d62 696e 6720 otocol plumbing \n+00026e60: 616e 6420 5549 2074 6f20 7365 6c65 6374 and UI to select\n+00026e70: 2061 6e20 6164 6d69 6e20 7573 6572 0a20 an admin user. \n+00026e80: 2020 2020 2020 206d 795f 7569 6420 3d20 my_uid = \n+00026e90: 6f73 2e67 6574 6575 6964 2829 0a20 2020 os.geteuid(). \n+00026ea0: 2020 2020 2066 6f72 2028 6175 7468 5f74 for (auth_t\n+00026eb0: 7970 652c 2073 7562 6a65 6374 2920 696e ype, subject) in\n+00026ec0: 2069 6465 6e74 6974 6965 733a 0a20 2020 identities:. \n+00026ed0: 2020 2020 2020 2020 2069 6620 6175 7468 if auth\n+00026ee0: 5f74 7970 6520 3d3d 2027 756e 6978 2d75 _type == 'unix-u\n+00026ef0: 7365 7227 2061 6e64 2027 7569 6427 2069 ser' and 'uid' i\n+00026f00: 6e20 7375 626a 6563 7420 616e 6420 7375 n subject and su\n+00026f10: 626a 6563 745b 2775 6964 275d 2e76 616c bject['uid'].val\n+00026f20: 7565 203d 3d20 6d79 5f75 6964 3a0a 2020 ue == my_uid:. \n+00026f30: 2020 2020 2020 2020 2020 2020 2020 6c6f lo\n+00026f40: 6767 6572 2e64 6562 7567 2827 4175 7468 gger.debug('Auth\n+00026f50: 656e 7469 6361 7469 6f6e 2073 7562 6a65 entication subje\n+00026f60: 6374 2025 7320 6d61 7463 6865 7320 6f75 ct %s matches ou\n+00026f70: 7220 7569 6420 2564 272c 2073 7562 6a65 r uid %d', subje\n+00026f80: 6374 2c20 6d79 5f75 6964 290a 2020 2020 ct, my_uid). \n+00026f90: 2020 2020 2020 2020 2020 2020 6272 6561 brea\n+00026fa0: 6b0a 2020 2020 2020 2020 656c 7365 3a0a k. else:.\n+00026fb0: 2020 2020 2020 2020 2020 2020 6c6f 6767 logg\n+00026fc0: 6572 2e77 6172 6e69 6e67 2827 4e6f 7420 er.warning('Not \n+00026fd0: 7375 7070 6f72 7469 6e67 2061 7574 6865 supporting authe\n+00026fe0: 6e74 6963 6174 696f 6e20 6173 2061 6e79 ntication as any\n+00026ff0: 206f 6620 2573 272c 2069 6465 6e74 6974 of %s', identit\n+00027000: 6965 7329 0a20 2020 2020 2020 2020 2020 ies). \n+00027010: 2072 6574 7572 6e0a 0a20 2020 2020 2020 return.. \n+00027020: 2075 7365 725f 6e61 6d65 203d 2070 7764 user_name = pwd\n+00027030: 2e67 6574 7077 7569 6428 6d79 5f75 6964 .getpwuid(my_uid\n+00027040: 292e 7077 5f6e 616d 650a 2020 2020 2020 ).pw_name. \n+00027050: 2020 7072 6f63 6573 7320 3d20 6177 6169 process = awai\n+00027060: 7420 6173 796e 6369 6f2e 6372 6561 7465 t asyncio.create\n+00027070: 5f73 7562 7072 6f63 6573 735f 6578 6563 _subprocess_exec\n+00027080: 2848 454c 5045 525f 5041 5448 2c20 7573 (HELPER_PATH, us\n+00027090: 6572 5f6e 616d 652c 2063 6f6f 6b69 652c er_name, cookie,\n+000270a0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+000270b0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000270c0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000270d0: 2020 2020 2020 2020 7374 6469 6e3d 6173 stdin=as\n+000270e0: 796e 6369 6f2e 7375 6270 726f 6365 7373 yncio.subprocess\n+000270f0: 2e50 4950 452c 0a20 2020 2020 2020 2020 .PIPE,. \n+00027100: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00027110: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00027120: 2020 2020 2020 2020 2020 2020 2020 7374 st\n+00027130: 646f 7574 3d61 7379 6e63 696f 2e73 7562 dout=asyncio.sub\n+00027140: 7072 6f63 6573 732e 5049 5045 290a 2020 process.PIPE). \n+00027150: 2020 2020 2020 7472 793a 0a20 2020 2020 try:. \n+00027160: 2020 2020 2020 2061 7761 6974 2073 656c await sel\n+00027170: 662e 5f63 6f6d 6d75 6e69 6361 7465 2870 f._communicate(p\n+00027180: 726f 6365 7373 290a 2020 2020 2020 2020 rocess). \n+00027190: 6578 6365 7074 2061 7379 6e63 696f 2e43 except asyncio.C\n+000271a0: 616e 6365 6c6c 6564 4572 726f 723a 0a20 ancelledError:. \n+000271b0: 2020 2020 2020 2020 2020 206c 6f67 6765 logge\n+000271c0: 722e 6465 6275 6728 2743 616e 6365 6c6c r.debug('Cancell\n+000271d0: 6564 2061 7574 6865 6e74 6963 6174 696f ed authenticatio\n+000271e0: 6e27 290a 2020 2020 2020 2020 2020 2020 n'). \n+000271f0: 7072 6f63 6573 732e 7465 726d 696e 6174 process.terminat\n+00027200: 6528 290a 2020 2020 2020 2020 6669 6e61 e(). fina\n+00027210: 6c6c 793a 0a20 2020 2020 2020 2020 2020 lly:. \n+00027220: 2072 6573 203d 2061 7761 6974 2070 726f res = await pro\n+00027230: 6365 7373 2e77 6169 7428 290a 2020 2020 cess.wait(). \n+00027240: 2020 2020 2020 2020 6c6f 6767 6572 2e64 logger.d\n+00027250: 6562 7567 2827 6865 6c70 6572 2065 7869 ebug('helper exi\n+00027260: 7465 6420 7769 7468 2063 6f64 6520 2569 ted with code %i\n+00027270: 272c 2072 6573 290a 0a20 2020 2061 7379 ', res).. asy\n+00027280: 6e63 2064 6566 205f 636f 6d6d 756e 6963 nc def _communic\n+00027290: 6174 6528 7365 6c66 2c20 7072 6f63 6573 ate(self, proces\n+000272a0: 733a 2061 7379 6e63 696f 2e73 7562 7072 s: asyncio.subpr\n+000272b0: 6f63 6573 732e 5072 6f63 6573 7329 202d ocess.Process) -\n+000272c0: 3e20 4e6f 6e65 3a0a 2020 2020 2020 2020 > None:. \n+000272d0: 6173 7365 7274 2070 726f 6365 7373 2e73 assert process.s\n+000272e0: 7464 696e 0a20 2020 2020 2020 2061 7373 tdin. ass\n+000272f0: 6572 7420 7072 6f63 6573 732e 7374 646f ert process.stdo\n+00027300: 7574 0a0a 2020 2020 2020 2020 6d65 7373 ut.. mess\n+00027310: 6167 6573 3a20 4c69 7374 5b73 7472 5d20 ages: List[str] \n+00027320: 3d20 5b5d 0a0a 2020 2020 2020 2020 6173 = [].. as\n+00027330: 796e 6320 666f 7220 6c69 6e65 2069 6e20 ync for line in \n+00027340: 7072 6f63 6573 732e 7374 646f 7574 3a0a process.stdout:.\n+00027350: 2020 2020 2020 2020 2020 2020 6c6f 6767 logg\n+00027360: 6572 2e64 6562 7567 2827 5265 6164 206c er.debug('Read l\n+00027370: 696e 6520 6672 6f6d 2068 656c 7065 723a ine from helper:\n+00027380: 2025 7327 2c20 6c69 6e65 290a 2020 2020 %s', line). \n+00027390: 2020 2020 2020 2020 636f 6d6d 616e 642c command,\n+000273a0: 205f 2c20 7661 6c75 6520 3d20 6c69 6e65 _, value = line\n+000273b0: 2e73 7472 6970 2829 2e64 6563 6f64 6528 .strip().decode(\n+000273c0: 292e 7061 7274 6974 696f 6e28 2720 2729 ).partition(' ')\n+000273d0: 0a0a 2020 2020 2020 2020 2020 2020 2320 .. # \n+000273e0: 7573 7561 6c6c 793a 2050 414d 5f50 524f usually: PAM_PRO\n+000273f0: 4d50 545f 4543 484f 5f4f 4646 2050 6173 MPT_ECHO_OFF Pas\n+00027400: 7377 6f72 643a 205c 6e0a 2020 2020 2020 sword: \\n. \n+00027410: 2020 2020 2020 6966 2063 6f6d 6d61 6e64 if command\n+00027420: 2e73 7461 7274 7377 6974 6828 2750 414d .startswith('PAM\n+00027430: 5f50 524f 4d50 5427 293a 0a20 2020 2020 _PROMPT'):. \n+00027440: 2020 2020 2020 2020 2020 2023 2044 6f6e # Don\n+00027450: 2774 2070 6173 7320 7468 6973 2074 6f20 't pass this to \n+00027460: 7468 6520 5549 2069 6620 6974 2773 2022 the UI if it's \"\n+00027470: 5061 7373 776f 7264 2220 2874 6865 2075 Password\" (the u\n+00027480: 7375 616c 2063 6173 6529 2c0a 2020 2020 sual case),. \n+00027490: 2020 2020 2020 2020 2020 2020 2320 736f # so\n+000274a0: 2074 6861 7420 7375 7065 7275 7365 722e that superuser.\n+000274b0: 7079 2075 7365 7320 7468 6520 7472 616e py uses the tran\n+000274c0: 736c 6174 6564 2064 6566 6175 6c74 0a20 slated default. \n+000274d0: 2020 2020 2020 2020 2020 2020 2020 2069 i\n+000274e0: 6620 7661 6c75 652e 7374 6172 7473 7769 f value.startswi\n+000274f0: 7468 2827 5061 7373 776f 7264 2729 3a0a th('Password'):.\n+00027500: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00027510: 2020 2020 7661 6c75 6520 3d20 2727 0a0a value = ''..\n+00027520: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00027530: 2320 666c 7573 6820 6f75 7420 6163 6375 # flush out accu\n+00027540: 6d75 6c61 7465 6420 696e 666f 2f65 7272 mulated info/err\n+00027550: 6f72 206d 6573 7361 6765 730a 2020 2020 or messages. \n+00027560: 2020 2020 2020 2020 2020 2020 7061 7373 pass\n+00027570: 7764 203d 2061 7761 6974 2073 656c 662e wd = await self.\n+00027580: 7265 7370 6f6e 6465 722e 646f 5f61 736b responder.do_ask\n+00027590: 7061 7373 2827 5c6e 272e 6a6f 696e 286d pass('\\n'.join(m\n+000275a0: 6573 7361 6765 7329 2c20 7661 6c75 652c essages), value,\n+000275b0: 2027 2729 0a20 2020 2020 2020 2020 2020 ''). \n+000275c0: 2020 2020 206d 6573 7361 6765 732e 636c messages.cl\n+000275d0: 6561 7228 290a 2020 2020 2020 2020 2020 ear(). \n+000275e0: 2020 2020 2020 6966 2070 6173 7377 6420 if passwd \n+000275f0: 6973 204e 6f6e 653a 0a20 2020 2020 2020 is None:. \n+00027600: 2020 2020 2020 2020 2020 2020 206c 6f67 log\n+00027610: 6765 722e 6465 6275 6728 2767 6f74 2050 ger.debug('got P\n+00027620: 414d 5f50 524f 4d50 5420 2573 2c20 6275 AM_PROMPT %s, bu\n+00027630: 7420 646f 5f61 736b 7061 7373 2072 6574 t do_askpass ret\n+00027640: 7572 6e65 6420 4e6f 6e65 272c 2076 616c urned None', val\n+00027650: 7565 290a 2020 2020 2020 2020 2020 2020 ue). \n+00027660: 2020 2020 2020 2020 7261 6973 6520 6173 raise as\n+00027670: 796e 6369 6f2e 4361 6e63 656c 6c65 6445 yncio.CancelledE\n+00027680: 7272 6f72 2827 6e6f 2070 6173 7377 6f72 rror('no passwor\n+00027690: 6420 6769 7665 6e27 290a 2020 2020 2020 d given'). \n+000276a0: 2020 2020 2020 2020 2020 6c6f 6767 6572 logger\n+000276b0: 2e64 6562 7567 2827 676f 7420 5041 4d5f .debug('got PAM_\n+000276c0: 5052 4f4d 5054 2025 732c 2064 6f5f 6173 PROMPT %s, do_as\n+000276d0: 6b70 6173 7320 7265 7475 726e 6564 2061 kpass returned a\n+000276e0: 2070 6173 7377 6f72 6427 2c20 7661 6c75 password', valu\n+000276f0: 6529 0a20 2020 2020 2020 2020 2020 2020 e). \n+00027700: 2020 2070 726f 6365 7373 2e73 7464 696e process.stdin\n+00027710: 2e77 7269 7465 2870 6173 7377 642e 656e .write(passwd.en\n+00027720: 636f 6465 2829 290a 2020 2020 2020 2020 code()). \n+00027730: 2020 2020 2020 2020 7072 6f63 6573 732e process.\n+00027740: 7374 6469 6e2e 7772 6974 6528 6227 5c6e stdin.write(b'\\n\n+00027750: 2729 0a20 2020 2020 2020 2020 2020 2020 '). \n+00027760: 2020 2064 656c 2070 6173 7377 6420 2023 del passwd #\n+00027770: 2064 6f6e 2774 206b 6565 7020 7468 6973 don't keep this\n+00027780: 2061 726f 756e 6420 6c6f 6e67 6572 2074 around longer t\n+00027790: 6861 6e20 6e65 6365 7373 6172 790a 2020 han necessary. \n+000277a0: 2020 2020 2020 2020 2020 2020 2020 6177 aw\n+000277b0: 6169 7420 7072 6f63 6573 732e 7374 6469 ait process.stdi\n+000277c0: 6e2e 6472 6169 6e28 290a 2020 2020 2020 n.drain(). \n+000277d0: 2020 2020 2020 2020 2020 6c6f 6767 6572 logger\n+000277e0: 2e64 6562 7567 2827 676f 7420 5041 4d5f .debug('got PAM_\n+000277f0: 5052 4f4d 5054 2c20 7772 6f74 6520 7061 PROMPT, wrote pa\n+00027800: 7373 776f 7264 2074 6f20 6865 6c70 6572 ssword to helper\n+00027810: 2729 0a20 2020 2020 2020 2020 2020 2065 '). e\n+00027820: 6c69 6620 636f 6d6d 616e 6420 696e 2028 lif command in (\n+00027830: 2750 414d 5f54 4558 545f 494e 464f 272c 'PAM_TEXT_INFO',\n+00027840: 2027 5041 4d5f 4552 524f 5227 293a 0a20 'PAM_ERROR'):. \n+00027850: 2020 2020 2020 2020 2020 2020 2020 206d m\n+00027860: 6573 7361 6765 732e 6170 7065 6e64 2876 essages.append(v\n+00027870: 616c 7565 290a 2020 2020 2020 2020 2020 alue). \n+00027880: 2020 656c 6966 2063 6f6d 6d61 6e64 203d elif command =\n+00027890: 3d20 2753 5543 4345 5353 273a 0a20 2020 = 'SUCCESS':. \n+000278a0: 2020 2020 2020 2020 2020 2020 206c 6f67 log\n+000278b0: 6765 722e 6465 6275 6728 2741 7574 6865 ger.debug('Authe\n+000278c0: 6e74 6963 6174 696f 6e20 7375 6363 6565 ntication succee\n+000278d0: 6465 6427 290a 2020 2020 2020 2020 2020 ded'). \n+000278e0: 2020 2020 2020 6272 6561 6b0a 2020 2020 break. \n+000278f0: 2020 2020 2020 2020 656c 6966 2063 6f6d elif com\n+00027900: 6d61 6e64 203d 3d20 2746 4149 4c55 5245 mand == 'FAILURE\n+00027910: 273a 0a20 2020 2020 2020 2020 2020 2020 ':. \n+00027920: 2020 206c 6f67 6765 722e 7761 726e 696e logger.warnin\n+00027930: 6728 2741 7574 6865 6e74 6963 6174 696f g('Authenticatio\n+00027940: 6e20 6661 696c 6564 2729 0a20 2020 2020 n failed'). \n+00027950: 2020 2020 2020 2020 2020 2062 7265 616b break\n+00027960: 0a20 2020 2020 2020 2020 2020 2065 6c73 . els\n+00027970: 653a 0a20 2020 2020 2020 2020 2020 2020 e:. \n+00027980: 2020 206c 6f67 6765 722e 7761 726e 696e logger.warnin\n+00027990: 6728 2755 6e6b 6e6f 776e 206c 696e 6520 g('Unknown line \n+000279a0: 6672 6f6d 2068 656c 7065 722c 2061 626f from helper, abo\n+000279b0: 7274 696e 673a 2025 7327 2c20 6c69 6e65 rting: %s', line\n+000279c0: 290a 2020 2020 2020 2020 2020 2020 2020 ). \n+000279d0: 2020 7072 6f63 6573 732e 7465 726d 696e process.termin\n+000279e0: 6174 6528 290a 2020 2020 2020 2020 2020 ate(). \n+000279f0: 2020 2020 2020 6272 6561 6b0a 0a0a 636c break...cl\n+00027a00: 6173 7320 506f 6c6b 6974 4167 656e 743a ass PolkitAgent:\n+00027a10: 0a20 2020 2022 2222 5265 6769 7374 6572 . \"\"\"Register\n+00027a20: 2070 6f6c 6b69 7420 6167 656e 7420 7768 polkit agent wh\n+00027a30: 656e 2072 6571 7569 7265 640a 0a20 2020 en required.. \n+00027a40: 2055 7365 2074 6869 7320 6173 2061 2063 Use this as a c\n+00027a50: 6f6e 7465 7874 206d 616e 6167 6572 2074 ontext manager t\n+00027a60: 6f20 656e 7375 7265 2074 6861 7420 7468 o ensure that th\n+00027a70: 6520 6167 656e 7420 6765 7473 2075 6e72 e agent gets unr\n+00027a80: 6567 6973 7465 7265 6420 6167 6169 6e2e egistered again.\n+00027a90: 0a20 2020 2022 2222 0a20 2020 2064 6566 . \"\"\". def\n+00027aa0: 205f 5f69 6e69 745f 5f28 7365 6c66 2c20 __init__(self, \n+00027ab0: 7265 7370 6f6e 6465 723a 2041 736b 7061 responder: Askpa\n+00027ac0: 7373 4861 6e64 6c65 7229 3a0a 2020 2020 ssHandler):. \n+00027ad0: 2020 2020 7365 6c66 2e72 6573 706f 6e64 self.respond\n+00027ae0: 6572 203d 2072 6573 706f 6e64 6572 0a20 er = responder. \n+00027af0: 2020 2020 2020 2073 656c 662e 6167 656e self.agen\n+00027b00: 745f 736c 6f74 203d 204e 6f6e 650a 0a20 t_slot = None.. \n+00027b10: 2020 2061 7379 6e63 2064 6566 205f 5f61 async def __a\n+00027b20: 656e 7465 725f 5f28 7365 6c66 293a 0a20 enter__(self):. \n+00027b30: 2020 2020 2020 2074 7279 3a0a 2020 2020 try:. \n+00027b40: 2020 2020 2020 2020 7365 6c66 2e73 7973 self.sys\n+00027b50: 7465 6d5f 6275 7320 3d20 6275 732e 4275 tem_bus = bus.Bu\n+00027b60: 732e 6465 6661 756c 745f 7379 7374 656d s.default_system\n+00027b70: 2829 0a20 2020 2020 2020 2065 7863 6570 (). excep\n+00027b80: 7420 4f53 4572 726f 7220 6173 2065 3a0a t OSError as e:.\n+00027b90: 2020 2020 2020 2020 2020 2020 6c6f 6767 logg\n+00027ba0: 6572 2e77 6172 6e69 6e67 2827 6361 6e6e er.warning('cann\n+00027bb0: 6f74 2063 6f6e 6e65 6374 2074 6f20 7379 ot connect to sy\n+00027bc0: 7374 656d 2062 7573 2c20 6e6f 7420 7265 stem bus, not re\n+00027bd0: 6769 7374 6572 696e 6720 706f 6c6b 6974 gistering polkit\n+00027be0: 2061 6765 6e74 3a20 2573 272c 2065 290a agent: %s', e).\n+00027bf0: 2020 2020 2020 2020 2020 2020 7265 7475 retu\n+00027c00: 726e 2073 656c 660a 0a20 2020 2020 2020 rn self.. \n+00027c10: 2074 7279 3a0a 2020 2020 2020 2020 2020 try:. \n+00027c20: 2020 2320 6d61 7920 7265 6669 6e65 2074 # may refine t\n+00027c30: 6861 7420 7769 7468 2061 2044 2d42 7573 hat with a D-Bus\n+00027c40: 2063 616c 6c20 746f 206c 6f67 696e 640a call to logind.\n+00027c50: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n+00027c60: 2e73 7562 6a65 6374 203d 2028 2775 6e69 .subject = ('uni\n+00027c70: 782d 7365 7373 696f 6e27 2c20 7b27 7365 x-session', {'se\n+00027c80: 7373 696f 6e2d 6964 273a 2056 6172 6961 ssion-id': Varia\n+00027c90: 6e74 286f 732e 656e 7669 726f 6e5b 2758 nt(os.environ['X\n+00027ca0: 4447 5f53 4553 5349 4f4e 5f49 4427 5d2c DG_SESSION_ID'],\n+00027cb0: 2027 7327 297d 290a 2020 2020 2020 2020 's')}). \n+00027cc0: 6578 6365 7074 204b 6579 4572 726f 723a except KeyError:\n+00027cd0: 0a20 2020 2020 2020 2020 2020 206c 6f67 . log\n+00027ce0: 6765 722e 6465 6275 6728 2758 4447 5f53 ger.debug('XDG_S\n+00027cf0: 4553 5349 4f4e 5f49 4420 6e6f 7420 7365 ESSION_ID not se\n+00027d00: 742c 206e 6f74 2072 6567 6973 7465 7269 t, not registeri\n+00027d10: 6e67 2070 6f6c 6b69 7420 6167 656e 7427 ng polkit agent'\n+00027d20: 290a 2020 2020 2020 2020 2020 2020 7265 ). re\n+00027d30: 7475 726e 2073 656c 660a 0a20 2020 2020 turn self.. \n+00027d40: 2020 2061 6765 6e74 5f6f 626a 6563 7420 agent_object \n+00027d50: 3d20 6f72 675f 6672 6565 6465 736b 746f = org_freedeskto\n+00027d60: 705f 506f 6c69 6379 4b69 7431 5f41 7574 p_PolicyKit1_Aut\n+00027d70: 6865 6e74 6963 6174 696f 6e41 6765 6e74 henticationAgent\n+00027d80: 2873 656c 662e 7265 7370 6f6e 6465 7229 (self.responder)\n+00027d90: 0a20 2020 2020 2020 2073 656c 662e 6167 . self.ag\n+00027da0: 656e 745f 736c 6f74 203d 2073 656c 662e ent_slot = self.\n+00027db0: 7379 7374 656d 5f62 7573 2e61 6464 5f6f system_bus.add_o\n+00027dc0: 626a 6563 7428 4147 454e 545f 4442 5553 bject(AGENT_DBUS\n+00027dd0: 5f50 4154 482c 2061 6765 6e74 5f6f 626a _PATH, agent_obj\n+00027de0: 6563 7429 0a0a 2020 2020 2020 2020 2320 ect).. # \n+00027df0: 7265 6769 7374 6572 2061 6765 6e74 0a20 register agent. \n+00027e00: 2020 2020 2020 206c 6f63 616c 655f 6e61 locale_na\n+00027e10: 6d65 203d 206c 6f63 616c 652e 7365 746c me = locale.setl\n+00027e20: 6f63 616c 6528 6c6f 6361 6c65 2e4c 435f ocale(locale.LC_\n+00027e30: 4d45 5353 4147 4553 2c20 4e6f 6e65 290a MESSAGES, None).\n+00027e40: 2020 2020 2020 2020 6177 6169 7420 7365 await se\n+00027e50: 6c66 2e73 7973 7465 6d5f 6275 732e 6361 lf.system_bus.ca\n+00027e60: 6c6c 5f6d 6574 686f 645f 6173 796e 6328 ll_method_async(\n+00027e70: 0a20 2020 2020 2020 2020 2020 2027 6f72 . 'or\n+00027e80: 672e 6672 6565 6465 736b 746f 702e 506f g.freedesktop.Po\n+00027e90: 6c69 6379 4b69 7431 272c 0a20 2020 2020 licyKit1',. \n+00027ea0: 2020 2020 2020 2027 2f6f 7267 2f66 7265 '/org/fre\n+00027eb0: 6564 6573 6b74 6f70 2f50 6f6c 6963 794b edesktop/PolicyK\n+00027ec0: 6974 312f 4175 7468 6f72 6974 7927 2c0a it1/Authority',.\n+00027ed0: 2020 2020 2020 2020 2020 2020 276f 7267 'org\n+00027ee0: 2e66 7265 6564 6573 6b74 6f70 2e50 6f6c .freedesktop.Pol\n+00027ef0: 6963 794b 6974 312e 4175 7468 6f72 6974 icyKit1.Authorit\n+00027f00: 7927 2c0a 2020 2020 2020 2020 2020 2020 y',. \n+00027f10: 2752 6567 6973 7465 7241 7574 6865 6e74 'RegisterAuthent\n+00027f20: 6963 6174 696f 6e41 6765 6e74 272c 0a20 icationAgent',. \n+00027f30: 2020 2020 2020 2020 2020 2027 2873 617b '(sa{\n+00027f40: 7376 7d29 7373 272c 0a20 2020 2020 2020 sv})ss',. \n+00027f50: 2020 2020 2073 656c 662e 7375 626a 6563 self.subjec\n+00027f60: 742c 206c 6f63 616c 655f 6e61 6d65 2c20 t, locale_name, \n+00027f70: 4147 454e 545f 4442 5553 5f50 4154 4829 AGENT_DBUS_PATH)\n+00027f80: 0a20 2020 2020 2020 206c 6f67 6765 722e . logger.\n+00027f90: 6465 6275 6728 2752 6567 6973 7465 7265 debug('Registere\n+00027fa0: 6420 6167 656e 7420 666f 7220 2572 2061 d agent for %r a\n+00027fb0: 6e64 206c 6f63 616c 6520 2573 272c 2073 nd locale %s', s\n+00027fc0: 656c 662e 7375 626a 6563 742c 206c 6f63 elf.subject, loc\n+00027fd0: 616c 655f 6e61 6d65 290a 2020 2020 2020 ale_name). \n+00027fe0: 2020 7265 7475 726e 2073 656c 660a 0a20 return self.. \n+00027ff0: 2020 2061 7379 6e63 2064 6566 205f 5f61 async def __a\n+00028000: 6578 6974 5f5f 2873 656c 662c 205f 6578 exit__(self, _ex\n+00028010: 635f 7479 7065 2c20 5f65 7863 5f76 616c c_type, _exc_val\n+00028020: 7565 2c20 5f74 7261 6365 6261 636b 293a ue, _traceback):\n+00028030: 0a20 2020 2020 2020 2069 6620 7365 6c66 . if self\n+00028040: 2e61 6765 6e74 5f73 6c6f 743a 0a20 2020 .agent_slot:. \n+00028050: 2020 2020 2020 2020 2061 7761 6974 2073 await s\n+00028060: 656c 662e 7379 7374 656d 5f62 7573 2e63 elf.system_bus.c\n+00028070: 616c 6c5f 6d65 7468 6f64 5f61 7379 6e63 all_method_async\n+00028080: 280a 2020 2020 2020 2020 2020 2020 2020 (. \n+00028090: 2020 276f 7267 2e66 7265 6564 6573 6b74 'org.freedeskt\n+000280a0: 6f70 2e50 6f6c 6963 794b 6974 3127 2c0a op.PolicyKit1',.\n+000280b0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000280c0: 272f 6f72 672f 6672 6565 6465 736b 746f '/org/freedeskto\n+000280d0: 702f 506f 6c69 6379 4b69 7431 2f41 7574 p/PolicyKit1/Aut\n+000280e0: 686f 7269 7479 272c 0a20 2020 2020 2020 hority',. \n+000280f0: 2020 2020 2020 2020 2027 6f72 672e 6672 'org.fr\n+00028100: 6565 6465 736b 746f 702e 506f 6c69 6379 eedesktop.Policy\n+00028110: 4b69 7431 2e41 7574 686f 7269 7479 272c Kit1.Authority',\n+00028120: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+00028130: 2027 556e 7265 6769 7374 6572 4175 7468 'UnregisterAuth\n+00028140: 656e 7469 6361 7469 6f6e 4167 656e 7427 enticationAgent'\n+00028150: 2c0a 2020 2020 2020 2020 2020 2020 2020 ,. \n+00028160: 2020 2728 7361 7b73 767d 2973 272c 0a20 '(sa{sv})s',. \n+00028170: 2020 2020 2020 2020 2020 2020 2020 2073 s\n+00028180: 656c 662e 7375 626a 6563 742c 2041 4745 elf.subject, AGE\n+00028190: 4e54 5f44 4255 535f 5041 5448 290a 2020 NT_DBUS_PATH). \n+000281a0: 2020 2020 2020 2020 2020 7365 6c66 2e61 self.a\n+000281b0: 6765 6e74 5f73 6c6f 742e 6361 6e63 656c gent_slot.cancel\n+000281c0: 2829 0a20 2020 2020 2020 2020 2020 206c (). l\n+000281d0: 6f67 6765 722e 6465 6275 6728 2755 6e72 ogger.debug('Unr\n+000281e0: 6567 6973 7465 7265 6420 6167 656e 7420 egistered agent \n+000281f0: 666f 7220 2572 272c 2073 656c 662e 7375 for %r', self.su\n+00028200: 626a 6563 7429 0a27 2727 2e65 6e63 6f64 bject).'''.encod\n+00028210: 6528 2775 7466 2d38 2729 2c0a 2020 2763 e('utf-8'),. 'c\n+00028220: 6f63 6b70 6974 2f72 656d 6f74 652e 7079 ockpit/remote.py\n+00028230: 273a 2072 2727 2723 2054 6869 7320 6669 ': r'''# This fi\n+00028240: 6c65 2069 7320 7061 7274 206f 6620 436f le is part of Co\n+00028250: 636b 7069 742e 0a23 0a23 2043 6f70 7972 ckpit..#.# Copyr\n+00028260: 6967 6874 2028 4329 2032 3032 3220 5265 ight (C) 2022 Re\n+00028270: 6420 4861 742c 2049 6e63 2e0a 230a 2320 d Hat, Inc..#.# \n+00028280: 5468 6973 2070 726f 6772 616d 2069 7320 This program is \n+00028290: 6672 6565 2073 6f66 7477 6172 653a 2079 free software: y\n+000282a0: 6f75 2063 616e 2072 6564 6973 7472 6962 ou can redistrib\n+000282b0: 7574 6520 6974 2061 6e64 2f6f 7220 6d6f ute it and/or mo\n+000282c0: 6469 6679 0a23 2069 7420 756e 6465 7220 dify.# it under \n+000282d0: 7468 6520 7465 726d 7320 6f66 2074 6865 the terms of the\n+000282e0: 2047 4e55 2047 656e 6572 616c 2050 7562 GNU General Pub\n+000282f0: 6c69 6320 4c69 6365 6e73 6520 6173 2070 lic License as p\n+00028300: 7562 6c69 7368 6564 2062 790a 2320 7468 ublished by.# th\n+00028310: 6520 4672 6565 2053 6f66 7477 6172 6520 e Free Software \n+00028320: 466f 756e 6461 7469 6f6e 2c20 6569 7468 Foundation, eith\n+00028330: 6572 2076 6572 7369 6f6e 2033 206f 6620 er version 3 of \n+00028340: 7468 6520 4c69 6365 6e73 652c 206f 720a the License, or.\n+00028350: 2320 2861 7420 796f 7572 206f 7074 696f # (at your optio\n+00028360: 6e29 2061 6e79 206c 6174 6572 2076 6572 n) any later ver\n+00028370: 7369 6f6e 2e0a 230a 2320 5468 6973 2070 sion..#.# This p\n+00028380: 726f 6772 616d 2069 7320 6469 7374 7269 rogram is distri\n+00028390: 6275 7465 6420 696e 2074 6865 2068 6f70 buted in the hop\n+000283a0: 6520 7468 6174 2069 7420 7769 6c6c 2062 e that it will b\n+000283b0: 6520 7573 6566 756c 2c0a 2320 6275 7420 e useful,.# but \n+000283c0: 5749 5448 4f55 5420 414e 5920 5741 5252 WITHOUT ANY WARR\n+000283d0: 414e 5459 3b20 7769 7468 6f75 7420 6576 ANTY; without ev\n+000283e0: 656e 2074 6865 2069 6d70 6c69 6564 2077 en the implied w\n+000283f0: 6172 7261 6e74 7920 6f66 0a23 204d 4552 arranty of.# MER\n+00028400: 4348 414e 5441 4249 4c49 5459 206f 7220 CHANTABILITY or \n+00028410: 4649 544e 4553 5320 464f 5220 4120 5041 FITNESS FOR A PA\n+00028420: 5254 4943 554c 4152 2050 5552 504f 5345 RTICULAR PURPOSE\n+00028430: 2e20 2053 6565 2074 6865 0a23 2047 4e55 . See the.# GNU\n+00028440: 2047 656e 6572 616c 2050 7562 6c69 6320 General Public \n+00028450: 4c69 6365 6e73 6520 666f 7220 6d6f 7265 License for more\n+00028460: 2064 6574 6169 6c73 2e0a 230a 2320 596f details..#.# Yo\n+00028470: 7520 7368 6f75 6c64 2068 6176 6520 7265 u should have re\n+00028480: 6365 6976 6564 2061 2063 6f70 7920 6f66 ceived a copy of\n+00028490: 2074 6865 2047 4e55 2047 656e 6572 616c the GNU General\n+000284a0: 2050 7562 6c69 6320 4c69 6365 6e73 650a Public License.\n+000284b0: 2320 616c 6f6e 6720 7769 7468 2074 6869 # along with thi\n+000284c0: 7320 7072 6f67 7261 6d2e 2020 4966 206e s program. If n\n+000284d0: 6f74 2c20 7365 6520 3c68 7474 7073 3a2f ot, see ...import\n+00028500: 2067 6574 7061 7373 0a69 6d70 6f72 7420 getpass.import \n+00028510: 6c6f 6767 696e 670a 696d 706f 7274 2072 logging.import r\n+00028520: 650a 696d 706f 7274 2073 6f63 6b65 740a e.import socket.\n+00028530: 6672 6f6d 2074 7970 696e 6720 696d 706f from typing impo\n+00028540: 7274 2044 6963 742c 204c 6973 742c 204f rt Dict, List, O\n+00028550: 7074 696f 6e61 6c2c 2054 7570 6c65 0a0a ptional, Tuple..\n+00028560: 6672 6f6d 2063 6f63 6b70 6974 2e5f 7665 from cockpit._ve\n+00028570: 6e64 6f72 2069 6d70 6f72 7420 6665 726e ndor import fern\n+00028580: 790a 0a66 726f 6d20 2e6a 736f 6e75 7469 y..from .jsonuti\n+00028590: 6c20 696d 706f 7274 204a 736f 6e4f 626a l import JsonObj\n+000285a0: 6563 742c 204a 736f 6e56 616c 7565 2c20 ect, JsonValue, \n+000285b0: 6765 745f 7374 722c 2067 6574 5f73 7472 get_str, get_str\n+000285c0: 5f6f 725f 6e6f 6e65 0a66 726f 6d20 2e70 _or_none.from .p\n+000285d0: 6565 7220 696d 706f 7274 2050 6565 722c eer import Peer,\n+000285e0: 2050 6565 7245 7272 6f72 0a66 726f 6d20 PeerError.from \n+000285f0: 2e72 6f75 7465 7220 696d 706f 7274 2052 .router import R\n+00028600: 6f75 7465 722c 2052 6f75 7469 6e67 5275 outer, RoutingRu\n+00028610: 6c65 0a0a 6c6f 6767 6572 203d 206c 6f67 le..logger = log\n+00028620: 6769 6e67 2e67 6574 4c6f 6767 6572 285f ging.getLogger(_\n+00028630: 5f6e 616d 655f 5f29 0a0a 0a63 6c61 7373 _name__)...class\n+00028640: 2050 6173 7377 6f72 6452 6573 706f 6e64 PasswordRespond\n+00028650: 6572 2866 6572 6e79 2e41 736b 7061 7373 er(ferny.Askpass\n+00028660: 4861 6e64 6c65 7229 3a0a 2020 2020 5041 Handler):. PA\n+00028670: 5353 5048 5241 5345 5f52 4520 3d20 7265 SSPHRASE_RE = re\n+00028680: 2e63 6f6d 7069 6c65 2872 2245 6e74 6572 .compile(r\"Enter\n+00028690: 2070 6173 7370 6872 6173 6520 666f 7220 passphrase for \n+000286a0: 6b65 7920 2728 2e2a 2927 3a20 2229 0a0a key '(.*)': \")..\n+000286b0: 2020 2020 7061 7373 776f 7264 3a20 4f70 password: Op\n+000286c0: 7469 6f6e 616c 5b73 7472 5d0a 0a20 2020 tional[str].. \n+000286d0: 2068 6f73 746b 6579 735f 7365 656e 3a20 hostkeys_seen: \n+000286e0: 4c69 7374 5b54 7570 6c65 5b73 7472 2c20 List[Tuple[str, \n+000286f0: 7374 722c 2073 7472 2c20 7374 722c 2073 str, str, str, s\n+00028700: 7472 5d5d 0a20 2020 2065 7272 6f72 5f6d tr]]. error_m\n+00028710: 6573 7361 6765 3a20 4f70 7469 6f6e 616c essage: Optional\n+00028720: 5b73 7472 5d0a 2020 2020 7061 7373 776f [str]. passwo\n+00028730: 7264 5f61 7474 656d 7074 733a 2069 6e74 rd_attempts: int\n+00028740: 0a0a 2020 2020 6465 6620 5f5f 696e 6974 .. def __init\n+00028750: 5f5f 2873 656c 662c 2070 6173 7377 6f72 __(self, passwor\n+00028760: 643a 204f 7074 696f 6e61 6c5b 7374 725d d: Optional[str]\n+00028770: 293a 0a20 2020 2020 2020 2073 656c 662e ):. self.\n+00028780: 7061 7373 776f 7264 203d 2070 6173 7377 password = passw\n+00028790: 6f72 640a 0a20 2020 2020 2020 2073 656c ord.. sel\n+000287a0: 662e 686f 7374 6b65 7973 5f73 6565 6e20 f.hostkeys_seen \n+000287b0: 3d20 5b5d 0a20 2020 2020 2020 2073 656c = []. sel\n+000287c0: 662e 6572 726f 725f 6d65 7373 6167 6520 f.error_message \n+000287d0: 3d20 4e6f 6e65 0a20 2020 2020 2020 2073 = None. s\n+000287e0: 656c 662e 7061 7373 776f 7264 5f61 7474 elf.password_att\n+000287f0: 656d 7074 7320 3d20 300a 0a20 2020 2061 empts = 0.. a\n+00028800: 7379 6e63 2064 6566 2064 6f5f 686f 7374 sync def do_host\n+00028810: 6b65 7928 7365 6c66 2c20 7265 6173 6f6e key(self, reason\n+00028820: 3a20 7374 722c 2068 6f73 743a 2073 7472 : str, host: str\n+00028830: 2c20 616c 676f 7269 7468 6d3a 2073 7472 , algorithm: str\n+00028840: 2c20 6b65 793a 2073 7472 2c20 6669 6e67 , key: str, fing\n+00028850: 6572 7072 696e 743a 2073 7472 2920 2d3e erprint: str) ->\n+00028860: 2062 6f6f 6c3a 0a20 2020 2020 2020 2073 bool:. s\n+00028870: 656c 662e 686f 7374 6b65 7973 5f73 6565 elf.hostkeys_see\n+00028880: 6e2e 6170 7065 6e64 2828 7265 6173 6f6e n.append((reason\n+00028890: 2c20 686f 7374 2c20 616c 676f 7269 7468 , host, algorith\n+000288a0: 6d2c 206b 6579 2c20 6669 6e67 6572 7072 m, key, fingerpr\n+000288b0: 696e 7429 290a 2020 2020 2020 2020 7265 int)). re\n+000288c0: 7475 726e 2046 616c 7365 0a0a 2020 2020 turn False.. \n+000288d0: 6173 796e 6320 6465 6620 646f 5f61 736b async def do_ask\n+000288e0: 7061 7373 2873 656c 662c 206d 6573 7361 pass(self, messa\n+000288f0: 6765 733a 2073 7472 2c20 7072 6f6d 7074 ges: str, prompt\n+00028900: 3a20 7374 722c 2068 696e 743a 2073 7472 : str, hint: str\n+00028910: 2920 2d3e 204f 7074 696f 6e61 6c5b 7374 ) -> Optional[st\n+00028920: 725d 3a0a 2020 2020 2020 2020 6c6f 6767 r]:. logg\n+00028930: 6572 2e64 6562 7567 2827 476f 7420 6173 er.debug('Got as\n+00028940: 6b70 6173 7328 2573 293a 2025 7327 2c20 kpass(%s): %s', \n+00028950: 6869 6e74 2c20 7072 6f6d 7074 290a 0a20 hint, prompt).. \n+00028960: 2020 2020 2020 206d 6174 6368 203d 2050 match = P\n+00028970: 6173 7377 6f72 6452 6573 706f 6e64 6572 asswordResponder\n+00028980: 2e50 4153 5350 4852 4153 455f 5245 2e66 .PASSPHRASE_RE.f\n+00028990: 756c 6c6d 6174 6368 2870 726f 6d70 7429 ullmatch(prompt)\n+000289a0: 0a20 2020 2020 2020 2069 6620 6d61 7463 . if matc\n+000289b0: 6820 6973 206e 6f74 204e 6f6e 653a 0a20 h is not None:. \n+000289c0: 2020 2020 2020 2020 2020 2023 2057 6520 # We \n+000289d0: 6e65 7665 7220 756e 6c6f 636b 2070 7269 never unlock pri\n+000289e0: 7661 7465 206b 6579 7320 e280 9420 7765 vate keys ... we\n+000289f0: 2072 6174 6865 7220 6e65 6564 2074 6f20 rather need to \n+00028a00: 7468 726f 7720 610a 2020 2020 2020 2020 throw a. \n+00028a10: 2020 2020 2320 7370 6563 6961 6c6c 792d # specially-\n+00028a20: 666f 726d 6174 7465 6420 6572 726f 7220 formatted error \n+00028a30: 6d65 7373 6167 6520 7768 6963 6820 7769 message which wi\n+00028a40: 6c6c 2063 6175 7365 2074 6865 2066 726f ll cause the fro\n+00028a50: 6e74 656e 640a 2020 2020 2020 2020 2020 ntend. \n+00028a60: 2020 2320 746f 206c 6f61 6420 7468 6520 # to load the \n+00028a70: 6e61 6d65 6420 6b65 7920 696e 746f 2074 named key into t\n+00028a80: 6865 2061 6765 6e74 2066 6f72 2075 7320 he agent for us \n+00028a90: 616e 6420 7472 7920 6167 6169 6e2e 0a20 and try again.. \n+00028aa0: 2020 2020 2020 2020 2020 2070 6174 6820 path \n+00028ab0: 3d20 6d61 7463 682e 6772 6f75 7028 3129 = match.group(1)\n+00028ac0: 0a20 2020 2020 2020 2020 2020 206c 6f67 . log\n+00028ad0: 6765 722e 6465 6275 6728 2254 6869 7320 ger.debug(\"This \n+00028ae0: 6973 2061 2070 6173 7370 6872 6173 6520 is a passphrase \n+00028af0: 7265 7175 6573 7420 666f 7220 2573 2c20 request for %s, \n+00028b00: 6275 7420 7765 2064 6f6e 2774 2064 6f20 but we don't do \n+00028b10: 7468 6f73 652e 2020 4162 6f72 742e 222c those. Abort.\",\n+00028b20: 2070 6174 6829 0a20 2020 2020 2020 2020 path). \n+00028b30: 2020 2073 656c 662e 6572 726f 725f 6d65 self.error_me\n+00028b40: 7373 6167 6520 3d20 6627 6c6f 636b 6564 ssage = f'locked\n+00028b50: 2069 6465 6e74 6974 793a 207b 7061 7468 identity: {path\n+00028b60: 7d27 0a20 2020 2020 2020 2020 2020 2072 }'. r\n+00028b70: 6574 7572 6e20 4e6f 6e65 0a0a 2020 2020 eturn None.. \n+00028b80: 2020 2020 6173 7365 7274 2073 656c 662e assert self.\n+00028b90: 7061 7373 776f 7264 2069 7320 6e6f 7420 password is not \n+00028ba0: 4e6f 6e65 0a20 2020 2020 2020 2061 7373 None. ass\n+00028bb0: 6572 7420 7365 6c66 2e70 6173 7377 6f72 ert self.passwor\n+00028bc0: 645f 6174 7465 6d70 7473 203d 3d20 300a d_attempts == 0.\n+00028bd0: 2020 2020 2020 2020 7365 6c66 2e70 6173 self.pas\n+00028be0: 7377 6f72 645f 6174 7465 6d70 7473 202b sword_attempts +\n+00028bf0: 3d20 310a 2020 2020 2020 2020 7265 7475 = 1. retu\n+00028c00: 726e 2073 656c 662e 7061 7373 776f 7264 rn self.password\n+00028c10: 0a0a 0a63 6c61 7373 2053 7368 5065 6572 ...class SshPeer\n+00028c20: 2850 6565 7229 3a0a 2020 2020 7365 7373 (Peer):. sess\n+00028c30: 696f 6e3a 204f 7074 696f 6e61 6c5b 6665 ion: Optional[fe\n+00028c40: 726e 792e 5365 7373 696f 6e5d 203d 204e rny.Session] = N\n+00028c50: 6f6e 650a 2020 2020 686f 7374 3a20 7374 one. host: st\n+00028c60: 720a 2020 2020 7573 6572 3a20 4f70 7469 r. user: Opti\n+00028c70: 6f6e 616c 5b73 7472 5d0a 2020 2020 7061 onal[str]. pa\n+00028c80: 7373 776f 7264 3a20 4f70 7469 6f6e 616c ssword: Optional\n+00028c90: 5b73 7472 5d0a 2020 2020 7072 6976 6174 [str]. privat\n+00028ca0: 653a 2062 6f6f 6c0a 0a20 2020 2061 7379 e: bool.. asy\n+00028cb0: 6e63 2064 6566 2064 6f5f 636f 6e6e 6563 nc def do_connec\n+00028cc0: 745f 7472 616e 7370 6f72 7428 7365 6c66 t_transport(self\n+00028cd0: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n+00028ce0: 2020 2061 7373 6572 7420 7365 6c66 2e73 assert self.s\n+00028cf0: 6573 7369 6f6e 2069 7320 6e6f 7420 4e6f ession is not No\n+00028d00: 6e65 0a20 2020 2020 2020 206c 6f67 6765 ne. logge\n+00028d10: 722e 6465 6275 6728 2753 7461 7274 696e r.debug('Startin\n+00028d20: 6720 7373 6820 7365 7373 696f 6e20 7573 g ssh session us\n+00028d30: 6572 3d25 732c 2068 6f73 743d 2573 2c20 er=%s, host=%s, \n+00028d40: 7072 6976 6174 653d 2573 272c 2073 656c private=%s', sel\n+00028d50: 662e 7573 6572 2c20 7365 6c66 2e68 6f73 f.user, self.hos\n+00028d60: 742c 2073 656c 662e 7072 6976 6174 6529 t, self.private)\n+00028d70: 0a0a 2020 2020 2020 2020 6261 7365 6e61 .. basena\n+00028d80: 6d65 2c20 636f 6c6f 6e2c 2070 6f72 7473 me, colon, ports\n+00028d90: 7472 203d 2073 656c 662e 686f 7374 2e72 tr = self.host.r\n+00028da0: 7061 7274 6974 696f 6e28 273a 2729 0a20 partition(':'). \n+00028db0: 2020 2020 2020 2069 6620 636f 6c6f 6e20 if colon \n+00028dc0: 616e 6420 706f 7274 7374 722e 6973 6469 and portstr.isdi\n+00028dd0: 6769 7428 293a 0a20 2020 2020 2020 2020 git():. \n+00028de0: 2020 2068 6f73 7420 3d20 6261 7365 6e61 host = basena\n+00028df0: 6d65 0a20 2020 2020 2020 2020 2020 2070 me. p\n+00028e00: 6f72 7420 3d20 696e 7428 706f 7274 7374 ort = int(portst\n+00028e10: 7229 0a20 2020 2020 2020 2065 6c73 653a r). else:\n+00028e20: 0a20 2020 2020 2020 2020 2020 2068 6f73 . hos\n+00028e30: 7420 3d20 7365 6c66 2e68 6f73 740a 2020 t = self.host. \n+00028e40: 2020 2020 2020 2020 2020 706f 7274 203d port =\n+00028e50: 204e 6f6e 650a 0a20 2020 2020 2020 2072 None.. r\n+00028e60: 6573 706f 6e64 6572 203d 2050 6173 7377 esponder = Passw\n+00028e70: 6f72 6452 6573 706f 6e64 6572 2873 656c ordResponder(sel\n+00028e80: 662e 7061 7373 776f 7264 290a 2020 2020 f.password). \n+00028e90: 2020 2020 6f70 7469 6f6e 7320 3d20 7b22 options = {\"\n+00028ea0: 5374 7269 6374 486f 7374 4b65 7943 6865 StrictHostKeyChe\n+00028eb0: 636b 696e 6722 3a20 2779 6573 277d 0a0a cking\": 'yes'}..\n+00028ec0: 2020 2020 2020 2020 6966 2073 656c 662e if self.\n+00028ed0: 7061 7373 776f 7264 2069 7320 6e6f 7420 password is not \n+00028ee0: 4e6f 6e65 3a0a 2020 2020 2020 2020 2020 None:. \n+00028ef0: 2020 6f70 7469 6f6e 732e 7570 6461 7465 options.update\n+00028f00: 284e 756d 6265 724f 6650 6173 7377 6f72 (NumberOfPasswor\n+00028f10: 6450 726f 6d70 7473 3d27 3127 290a 2020 dPrompts='1'). \n+00028f20: 2020 2020 2020 656c 7365 3a0a 2020 2020 else:. \n+00028f30: 2020 2020 2020 2020 6f70 7469 6f6e 732e options.\n+00028f40: 7570 6461 7465 2850 6173 7377 6f72 6441 update(PasswordA\n+00028f50: 7574 6865 6e74 6963 6174 696f 6e3d 226e uthentication=\"n\n+00028f60: 6f22 2c20 4b62 6449 6e74 6572 6163 7469 o\", KbdInteracti\n+00028f70: 7665 4175 7468 656e 7469 6361 7469 6f6e veAuthentication\n+00028f80: 3d22 6e6f 2229 0a0a 2020 2020 2020 2020 =\"no\").. \n+00028f90: 7472 793a 0a20 2020 2020 2020 2020 2020 try:. \n+00028fa0: 2061 7761 6974 2073 656c 662e 7365 7373 await self.sess\n+00028fb0: 696f 6e2e 636f 6e6e 6563 7428 686f 7374 ion.connect(host\n+00028fc0: 2c20 6c6f 6769 6e5f 6e61 6d65 3d73 656c , login_name=sel\n+00028fd0: 662e 7573 6572 2c20 706f 7274 3d70 6f72 f.user, port=por\n+00028fe0: 742c 0a20 2020 2020 2020 2020 2020 2020 t,. \n+00028ff0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00029000: 2020 2020 2020 2020 2020 6861 6e64 6c65 handle\n+00029010: 5f68 6f73 745f 6b65 793d 7365 6c66 2e70 _host_key=self.p\n+00029020: 7269 7661 7465 2c20 6f70 7469 6f6e 733d rivate, options=\n+00029030: 6f70 7469 6f6e 732c 0a20 2020 2020 2020 options,. \n+00029040: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00029050: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00029060: 696e 7465 7261 6374 696f 6e5f 7265 7370 interaction_resp\n+00029070: 6f6e 6465 723d 7265 7370 6f6e 6465 7229 onder=responder)\n+00029080: 0a20 2020 2020 2020 2065 7863 6570 7420 . except \n+00029090: 284f 5345 7272 6f72 2c20 736f 636b 6574 (OSError, socket\n+000290a0: 2e67 6169 6572 726f 7229 2061 7320 6578 .gaierror) as ex\n+000290b0: 633a 0a20 2020 2020 2020 2020 2020 206c c:. l\n+000290c0: 6f67 6765 722e 6465 6275 6728 2763 6f6e ogger.debug('con\n+000290d0: 6e65 6374 696e 6720 746f 2068 6f73 7420 necting to host \n+000290e0: 2573 2066 6169 6c65 643a 2025 7327 2c20 %s failed: %s', \n+000290f0: 686f 7374 2c20 6578 6329 0a20 2020 2020 host, exc). \n+00029100: 2020 2020 2020 2072 6169 7365 2050 6565 raise Pee\n+00029110: 7245 7272 6f72 2827 6e6f 2d68 6f73 7427 rError('no-host'\n+00029120: 2c20 6572 726f 723d 276e 6f2d 686f 7374 , error='no-host\n+00029130: 272c 206d 6573 7361 6765 3d73 7472 2865 ', message=str(e\n+00029140: 7863 2929 2066 726f 6d20 6578 630a 0a20 xc)) from exc.. \n+00029150: 2020 2020 2020 2065 7863 6570 7420 6665 except fe\n+00029160: 726e 792e 5373 6848 6f73 744b 6579 4572 rny.SshHostKeyEr\n+00029170: 726f 7220 6173 2065 7863 3a0a 2020 2020 ror as exc:. \n+00029180: 2020 2020 2020 2020 6966 2072 6573 706f if respo\n+00029190: 6e64 6572 2e68 6f73 746b 6579 735f 7365 nder.hostkeys_se\n+000291a0: 656e 3a0a 2020 2020 2020 2020 2020 2020 en:. \n+000291b0: 2020 2020 2320 4966 2077 6520 7361 7720 # If we saw \n+000291c0: 6120 686f 7374 6b65 7920 7468 656e 2077 a hostkey then w\n+000291d0: 6520 6361 6e20 6973 7375 6520 6120 6465 e can issue a de\n+000291e0: 7461 696c 6564 2065 7272 6f72 206d 6573 tailed error mes\n+000291f0: 7361 6765 0a20 2020 2020 2020 2020 2020 sage. \n+00029200: 2020 2020 2023 2063 6f6e 7461 696e 696e # containin\n+00029210: 6720 7468 6520 6b65 7920 7468 6174 2077 g the key that w\n+00029220: 6f75 6c64 206e 6565 6420 746f 2062 6520 ould need to be \n+00029230: 6163 6365 7074 6564 2e20 2054 6861 7420 accepted. That \n+00029240: 7769 6c6c 0a20 2020 2020 2020 2020 2020 will. \n+00029250: 2020 2020 2023 2063 6175 7365 2074 6865 # cause the\n+00029260: 2066 726f 6e74 2d65 6e64 2074 6f20 7072 front-end to pr\n+00029270: 6573 656e 7420 6120 6469 616c 6f67 2e0a esent a dialog..\n+00029280: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00029290: 5f72 6561 736f 6e2c 2068 6f73 742c 2061 _reason, host, a\n+000292a0: 6c67 6f72 6974 686d 2c20 6b65 792c 2066 lgorithm, key, f\n+000292b0: 696e 6765 7270 7269 6e74 203d 2072 6573 ingerprint = res\n+000292c0: 706f 6e64 6572 2e68 6f73 746b 6579 735f ponder.hostkeys_\n+000292d0: 7365 656e 5b30 5d0a 2020 2020 2020 2020 seen[0]. \n+000292e0: 2020 2020 2020 2020 6572 726f 725f 6172 error_ar\n+000292f0: 6773 203d 207b 2768 6f73 742d 6b65 7927 gs = {'host-key'\n+00029300: 3a20 6627 7b68 6f73 747d 207b 616c 676f : f'{host} {algo\n+00029310: 7269 7468 6d7d 207b 6b65 797d 272c 2027 rithm} {key}', '\n+00029320: 686f 7374 2d66 696e 6765 7270 7269 6e74 host-fingerprint\n+00029330: 273a 2066 696e 6765 7270 7269 6e74 7d0a ': fingerprint}.\n+00029340: 2020 2020 2020 2020 2020 2020 656c 7365 else\n+00029350: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n+00029360: 2020 6572 726f 725f 6172 6773 203d 207b error_args = {\n+00029370: 7d0a 0a20 2020 2020 2020 2020 2020 2069 }.. i\n+00029380: 6620 6973 696e 7374 616e 6365 2865 7863 f isinstance(exc\n+00029390: 2c20 6665 726e 792e 5373 6843 6861 6e67 , ferny.SshChang\n+000293a0: 6564 486f 7374 4b65 7945 7272 6f72 293a edHostKeyError):\n+000293b0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+000293c0: 2065 7272 6f72 203d 2027 696e 7661 6c69 error = 'invali\n+000293d0: 642d 686f 7374 6b65 7927 0a20 2020 2020 d-hostkey'. \n+000293e0: 2020 2020 2020 2065 6c69 6620 7365 6c66 elif self\n+000293f0: 2e70 7269 7661 7465 3a0a 2020 2020 2020 .private:. \n+00029400: 2020 2020 2020 2020 2020 6572 726f 7220 error \n+00029410: 3d20 2775 6e6b 6e6f 776e 2d68 6f73 746b = 'unknown-hostk\n+00029420: 6579 270a 2020 2020 2020 2020 2020 2020 ey'. \n+00029430: 656c 7365 3a0a 2020 2020 2020 2020 2020 else:. \n+00029440: 2020 2020 2020 2320 6e6f 6e2d 7072 6976 # non-priv\n+00029450: 6174 6520 7365 7373 696f 6e20 6361 7365 ate session case\n+00029460: 2e20 2074 6872 6f77 2061 2067 656e 6572 . throw a gener\n+00029470: 6963 2065 7272 6f72 2e0a 2020 2020 2020 ic error.. \n+00029480: 2020 2020 2020 2020 2020 6572 726f 7220 error \n+00029490: 3d20 2775 6e6b 6e6f 776e 2d68 6f73 7427 = 'unknown-host'\n+000294a0: 0a0a 2020 2020 2020 2020 2020 2020 6c6f .. lo\n+000294b0: 6767 6572 2e64 6562 7567 2827 5373 6850 gger.debug('SshP\n+000294c0: 6565 7220 676f 7420 6120 2573 2025 733b eer got a %s %s;\n+000294d0: 2070 7269 7661 7465 2025 732c 2073 6565 private %s, see\n+000294e0: 6e20 686f 7374 6b65 7973 2025 723b 2072 n hostkeys %r; r\n+000294f0: 6169 7369 6e67 2025 7320 7769 7468 2065 aising %s with e\n+00029500: 7874 7261 2061 7267 7320 2572 272c 0a20 xtra args %r',. \n+00029510: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00029520: 2020 2020 2020 2020 7479 7065 2865 7863 type(exc\n+00029530: 292c 2065 7863 2c20 7365 6c66 2e70 7269 ), exc, self.pri\n+00029540: 7661 7465 2c20 7265 7370 6f6e 6465 722e vate, responder.\n+00029550: 686f 7374 6b65 7973 5f73 6565 6e2c 2065 hostkeys_seen, e\n+00029560: 7272 6f72 2c20 6572 726f 725f 6172 6773 rror, error_args\n+00029570: 290a 2020 2020 2020 2020 2020 2020 7261 ). ra\n+00029580: 6973 6520 5065 6572 4572 726f 7228 6572 ise PeerError(er\n+00029590: 726f 722c 2065 7272 6f72 5f61 7267 732c ror, error_args,\n+000295a0: 2065 7272 6f72 3d65 7272 6f72 2c20 6175 error=error, au\n+000295b0: 7468 5f6d 6574 686f 645f 7265 7375 6c74 th_method_result\n+000295c0: 733d 7b7d 2920 6672 6f6d 2065 7863 0a0a s={}) from exc..\n+000295d0: 2020 2020 2020 2020 6578 6365 7074 2066 except f\n+000295e0: 6572 6e79 2e53 7368 4175 7468 656e 7469 erny.SshAuthenti\n+000295f0: 6361 7469 6f6e 4572 726f 7220 6173 2065 cationError as e\n+00029600: 7863 3a0a 2020 2020 2020 2020 2020 2020 xc:. \n+00029610: 6c6f 6767 6572 2e64 6562 7567 2827 6175 logger.debug('au\n+00029620: 7468 656e 7469 6361 7469 6f6e 2074 6f20 thentication to \n+00029630: 686f 7374 2025 7320 6661 696c 6564 3a20 host %s failed: \n+00029640: 2573 272c 2068 6f73 742c 2065 7863 290a %s', host, exc).\n+00029650: 0a20 2020 2020 2020 2020 2020 2072 6573 . res\n+00029660: 756c 7473 203d 2064 6963 742e 6672 6f6d ults = dict.from\n+00029670: 6b65 7973 2865 7863 2e6d 6574 686f 6473 keys(exc.methods\n+00029680: 2c20 226e 6f74 2d70 726f 7669 6465 6422 , \"not-provided\"\n+00029690: 290a 2020 2020 2020 2020 2020 2020 6966 ). if\n+000296a0: 2027 7061 7373 776f 7264 2720 696e 2072 'password' in r\n+000296b0: 6573 756c 7473 2061 6e64 2073 656c 662e esults and self.\n+000296c0: 7061 7373 776f 7264 2069 7320 6e6f 7420 password is not \n+000296d0: 4e6f 6e65 3a0a 2020 2020 2020 2020 2020 None:. \n+000296e0: 2020 2020 2020 6966 2072 6573 706f 6e64 if respond\n+000296f0: 6572 2e70 6173 7377 6f72 645f 6174 7465 er.password_atte\n+00029700: 6d70 7473 203d 3d20 303a 0a20 2020 2020 mpts == 0:. \n+00029710: 2020 2020 2020 2020 2020 2020 2020 2072 r\n+00029720: 6573 756c 7473 5b27 7061 7373 776f 7264 esults['password\n+00029730: 275d 203d 2027 6e6f 742d 7472 6965 6427 '] = 'not-tried'\n+00029740: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+00029750: 2065 6c73 653a 0a20 2020 2020 2020 2020 else:. \n+00029760: 2020 2020 2020 2020 2020 2072 6573 756c resul\n+00029770: 7473 5b27 7061 7373 776f 7264 275d 203d ts['password'] =\n+00029780: 2027 6465 6e69 6564 270a 0a20 2020 2020 'denied'.. \n+00029790: 2020 2020 2020 2072 6169 7365 2050 6565 raise Pee\n+000297a0: 7245 7272 6f72 2827 6175 7468 656e 7469 rError('authenti\n+000297b0: 6361 7469 6f6e 2d66 6169 6c65 6427 2c0a cation-failed',.\n+000297c0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000297d0: 2020 2020 2020 2020 2020 2020 6572 726f erro\n+000297e0: 723d 7265 7370 6f6e 6465 722e 6572 726f r=responder.erro\n+000297f0: 725f 6d65 7373 6167 6520 6f72 2027 6175 r_message or 'au\n+00029800: 7468 656e 7469 6361 7469 6f6e 2d66 6169 thentication-fai\n+00029810: 6c65 6427 2c0a 2020 2020 2020 2020 2020 led',. \n+00029820: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00029830: 2020 6175 7468 5f6d 6574 686f 645f 7265 auth_method_re\n+00029840: 7375 6c74 733d 7265 7375 6c74 7329 2066 sults=results) f\n+00029850: 726f 6d20 6578 630a 0a20 2020 2020 2020 rom exc.. \n+00029860: 2065 7863 6570 7420 6665 726e 792e 5373 except ferny.Ss\n+00029870: 6845 7272 6f72 2061 7320 6578 633a 0a20 hError as exc:. \n+00029880: 2020 2020 2020 2020 2020 206c 6f67 6765 logge\n+00029890: 722e 6465 6275 6728 2775 6e6b 6e6f 776e r.debug('unknown\n+000298a0: 2066 6169 6c75 7265 2063 6f6e 6e65 6374 failure connect\n+000298b0: 696e 6720 746f 2068 6f73 7420 2573 3a20 ing to host %s: \n+000298c0: 2573 272c 2068 6f73 742c 2065 7863 290a %s', host, exc).\n+000298d0: 2020 2020 2020 2020 2020 2020 7261 6973 rais\n+000298e0: 6520 5065 6572 4572 726f 7228 2769 6e74 e PeerError('int\n+000298f0: 6572 6e61 6c2d 6572 726f 7227 2c20 6d65 ernal-error', me\n+00029900: 7373 6167 653d 7374 7228 6578 6329 2920 ssage=str(exc)) \n+00029910: 6672 6f6d 2065 7863 0a0a 2020 2020 2020 from exc.. \n+00029920: 2020 6172 6773 203d 2073 656c 662e 7365 args = self.se\n+00029930: 7373 696f 6e2e 7772 6170 5f73 7562 7072 ssion.wrap_subpr\n+00029940: 6f63 6573 735f 6172 6773 285b 2763 6f63 ocess_args(['coc\n+00029950: 6b70 6974 2d62 7269 6467 6527 5d29 0a20 kpit-bridge']). \n+00029960: 2020 2020 2020 2061 7761 6974 2073 656c await sel\n+00029970: 662e 7370 6177 6e28 6172 6773 2c20 5b5d f.spawn(args, []\n+00029980: 290a 0a20 2020 2064 6566 2064 6f5f 6b69 ).. def do_ki\n+00029990: 6c6c 2873 656c 662c 2068 6f73 743a 2027 ll(self, host: '\n+000299a0: 7374 7220 7c20 4e6f 6e65 272c 2067 726f str | None', gro\n+000299b0: 7570 3a20 2773 7472 207c 204e 6f6e 6527 up: 'str | None'\n+000299c0: 2c20 6d65 7373 6167 653a 204a 736f 6e4f , message: JsonO\n+000299d0: 626a 6563 7429 202d 3e20 4e6f 6e65 3a0a bject) -> None:.\n+000299e0: 2020 2020 2020 2020 6966 2068 6f73 7420 if host \n+000299f0: 3d3d 2073 656c 662e 686f 7374 3a0a 2020 == self.host:. \n+00029a00: 2020 2020 2020 2020 2020 7365 6c66 2e63 self.c\n+00029a10: 6c6f 7365 2829 0a20 2020 2020 2020 2065 lose(). e\n+00029a20: 6c69 6620 686f 7374 2069 7320 4e6f 6e65 lif host is None\n+00029a30: 3a0a 2020 2020 2020 2020 2020 2020 7375 :. su\n+00029a40: 7065 7228 292e 646f 5f6b 696c 6c28 686f per().do_kill(ho\n+00029a50: 7374 2c20 6772 6f75 702c 206d 6573 7361 st, group, messa\n+00029a60: 6765 290a 0a20 2020 2064 6566 2064 6f5f ge).. def do_\n+00029a70: 6175 7468 6f72 697a 6528 7365 6c66 2c20 authorize(self, \n+00029a80: 6d65 7373 6167 653a 204a 736f 6e4f 626a message: JsonObj\n+00029a90: 6563 7429 202d 3e20 4e6f 6e65 3a0a 2020 ect) -> None:. \n+00029aa0: 2020 2020 2020 6966 2067 6574 5f73 7472 if get_str\n+00029ab0: 286d 6573 7361 6765 2c20 2763 6861 6c6c (message, 'chall\n+00029ac0: 656e 6765 2729 2e73 7461 7274 7377 6974 enge').startswit\n+00029ad0: 6828 2770 6c61 696e 313a 2729 3a0a 2020 h('plain1:'):. \n+00029ae0: 2020 2020 2020 2020 2020 636f 6f6b 6965 cookie\n+00029af0: 203d 2067 6574 5f73 7472 286d 6573 7361 = get_str(messa\n+00029b00: 6765 2c20 2763 6f6f 6b69 6527 290a 2020 ge, 'cookie'). \n+00029b10: 2020 2020 2020 2020 2020 7365 6c66 2e77 self.w\n+00029b20: 7269 7465 5f63 6f6e 7472 6f6c 2863 6f6d rite_control(com\n+00029b30: 6d61 6e64 3d27 6175 7468 6f72 697a 6527 mand='authorize'\n+00029b40: 2c20 636f 6f6b 6965 3d63 6f6f 6b69 652c , cookie=cookie,\n+00029b50: 2072 6573 706f 6e73 653d 7365 6c66 2e70 response=self.p\n+00029b60: 6173 7377 6f72 6420 6f72 2027 2729 0a20 assword or ''). \n+00029b70: 2020 2020 2020 2020 2020 2073 656c 662e self.\n+00029b80: 7061 7373 776f 7264 203d 204e 6f6e 6520 password = None \n+00029b90: 2023 206f 6e63 6520 6973 2065 6e6f 7567 # once is enoug\n+00029ba0: 682e 2e2e 0a0a 2020 2020 6465 6620 646f h..... def do\n+00029bb0: 5f73 7570 6572 7573 6572 5f69 6e69 745f _superuser_init_\n+00029bc0: 646f 6e65 2873 656c 6629 202d 3e20 4e6f done(self) -> No\n+00029bd0: 6e65 3a0a 2020 2020 2020 2020 7365 6c66 ne:. self\n+00029be0: 2e70 6173 7377 6f72 6420 3d20 4e6f 6e65 .password = None\n+00029bf0: 0a0a 2020 2020 6465 6620 5f5f 696e 6974 .. def __init\n+00029c00: 5f5f 2873 656c 662c 2072 6f75 7465 723a __(self, router:\n+00029c10: 2052 6f75 7465 722c 2068 6f73 743a 2073 Router, host: s\n+00029c20: 7472 2c20 7573 6572 3a20 4f70 7469 6f6e tr, user: Option\n+00029c30: 616c 5b73 7472 5d2c 206f 7074 696f 6e73 al[str], options\n+00029c40: 3a20 4a73 6f6e 4f62 6a65 6374 2c20 2a2c : JsonObject, *,\n+00029c50: 2070 7269 7661 7465 3a20 626f 6f6c 2920 private: bool) \n+00029c60: 2d3e 204e 6f6e 653a 0a20 2020 2020 2020 -> None:. \n+00029c70: 2073 7570 6572 2829 2e5f 5f69 6e69 745f super().__init_\n+00029c80: 5f28 726f 7574 6572 290a 2020 2020 2020 _(router). \n+00029c90: 2020 7365 6c66 2e68 6f73 7420 3d20 686f self.host = ho\n+00029ca0: 7374 0a20 2020 2020 2020 2073 656c 662e st. self.\n+00029cb0: 7573 6572 203d 2075 7365 720a 2020 2020 user = user. \n+00029cc0: 2020 2020 7365 6c66 2e70 6173 7377 6f72 self.passwor\n+00029cd0: 6420 3d20 6765 745f 7374 7228 6f70 7469 d = get_str(opti\n+00029ce0: 6f6e 732c 2027 7061 7373 776f 7264 272c ons, 'password',\n+00029cf0: 204e 6f6e 6529 0a20 2020 2020 2020 2073 None). s\n+00029d00: 656c 662e 7072 6976 6174 6520 3d20 7072 elf.private = pr\n+00029d10: 6976 6174 650a 0a20 2020 2020 2020 2073 ivate.. s\n+00029d20: 656c 662e 7365 7373 696f 6e20 3d20 6665 elf.session = fe\n+00029d30: 726e 792e 5365 7373 696f 6e28 290a 0a20 rny.Session().. \n+00029d40: 2020 2020 2020 2073 7570 6572 7573 6572 superuser\n+00029d50: 3a20 4a73 6f6e 5661 6c75 650a 2020 2020 : JsonValue. \n+00029d60: 2020 2020 696e 6974 5f73 7570 6572 7573 init_superus\n+00029d70: 6572 203d 2067 6574 5f73 7472 5f6f 725f er = get_str_or_\n+00029d80: 6e6f 6e65 286f 7074 696f 6e73 2c20 2769 none(options, 'i\n+00029d90: 6e69 742d 7375 7065 7275 7365 7227 2c20 nit-superuser', \n+00029da0: 4e6f 6e65 290a 2020 2020 2020 2020 6966 None). if\n+00029db0: 2069 6e69 745f 7375 7065 7275 7365 7220 init_superuser \n+00029dc0: 696e 2028 4e6f 6e65 2c20 276e 6f6e 6527 in (None, 'none'\n+00029dd0: 293a 0a20 2020 2020 2020 2020 2020 2073 ):. s\n+00029de0: 7570 6572 7573 6572 203d 2046 616c 7365 uperuser = False\n+00029df0: 0a20 2020 2020 2020 2065 6c73 653a 0a20 . else:. \n+00029e00: 2020 2020 2020 2020 2020 2073 7570 6572 super\n+00029e10: 7573 6572 203d 207b 2769 6427 3a20 696e user = {'id': in\n+00029e20: 6974 5f73 7570 6572 7573 6572 7d0a 0a20 it_superuser}.. \n+00029e30: 2020 2020 2020 2073 656c 662e 7374 6172 self.star\n+00029e40: 745f 696e 5f62 6163 6b67 726f 756e 6428 t_in_background(\n+00029e50: 696e 6974 5f68 6f73 743d 686f 7374 2c20 init_host=host, \n+00029e60: 7375 7065 7275 7365 723d 7375 7065 7275 superuser=superu\n+00029e70: 7365 7229 0a0a 0a63 6c61 7373 2048 6f73 ser)...class Hos\n+00029e80: 7452 6f75 7469 6e67 5275 6c65 2852 6f75 tRoutingRule(Rou\n+00029e90: 7469 6e67 5275 6c65 293a 0a20 2020 2072 tingRule):. r\n+00029ea0: 656d 6f74 6573 3a20 4469 6374 5b54 7570 emotes: Dict[Tup\n+00029eb0: 6c65 5b73 7472 2c20 4f70 7469 6f6e 616c le[str, Optional\n+00029ec0: 5b73 7472 5d2c 204f 7074 696f 6e61 6c5b [str], Optional[\n+00029ed0: 7374 725d 5d2c 2050 6565 725d 0a0a 2020 str]], Peer].. \n+00029ee0: 2020 6465 6620 5f5f 696e 6974 5f5f 2873 def __init__(s\n+00029ef0: 656c 662c 2072 6f75 7465 7229 3a0a 2020 elf, router):. \n+00029f00: 2020 2020 2020 7375 7065 7228 292e 5f5f super().__\n+00029f10: 696e 6974 5f5f 2872 6f75 7465 7229 0a20 init__(router). \n+00029f20: 2020 2020 2020 2073 656c 662e 7265 6d6f self.remo\n+00029f30: 7465 7320 3d20 7b7d 0a0a 2020 2020 6465 tes = {}.. de\n+00029f40: 6620 6170 706c 795f 7275 6c65 2873 656c f apply_rule(sel\n+00029f50: 662c 206f 7074 696f 6e73 3a20 4a73 6f6e f, options: Json\n+00029f60: 4f62 6a65 6374 2920 2d3e 204f 7074 696f Object) -> Optio\n+00029f70: 6e61 6c5b 5065 6572 5d3a 0a20 2020 2020 nal[Peer]:. \n+00029f80: 2020 2061 7373 6572 7420 7365 6c66 2e72 assert self.r\n+00029f90: 6f75 7465 7220 6973 206e 6f74 204e 6f6e outer is not Non\n+00029fa0: 650a 2020 2020 2020 2020 6173 7365 7274 e. assert\n+00029fb0: 2073 656c 662e 726f 7574 6572 2e69 6e69 self.router.ini\n+00029fc0: 745f 686f 7374 2069 7320 6e6f 7420 4e6f t_host is not No\n+00029fd0: 6e65 0a0a 2020 2020 2020 2020 686f 7374 ne.. host\n+00029fe0: 203d 2067 6574 5f73 7472 286f 7074 696f = get_str(optio\n+00029ff0: 6e73 2c20 2768 6f73 7427 2c20 7365 6c66 ns, 'host', self\n+0002a000: 2e72 6f75 7465 722e 696e 6974 5f68 6f73 .router.init_hos\n+0002a010: 7429 0a20 2020 2020 2020 2069 6620 686f t). if ho\n+0002a020: 7374 203d 3d20 7365 6c66 2e72 6f75 7465 st == self.route\n+0002a030: 722e 696e 6974 5f68 6f73 743a 0a20 2020 r.init_host:. \n+0002a040: 2020 2020 2020 2020 2072 6574 7572 6e20 return \n+0002a050: 4e6f 6e65 0a0a 2020 2020 2020 2020 7573 None.. us\n+0002a060: 6572 203d 2067 6574 5f73 7472 286f 7074 er = get_str(opt\n+0002a070: 696f 6e73 2c20 2775 7365 7227 2c20 4e6f ions, 'user', No\n+0002a080: 6e65 290a 2020 2020 2020 2020 2320 4841 ne). # HA\n+0002a090: 434b 3a20 7468 6520 6672 6f6e 742d 656e CK: the front-en\n+0002a0a0: 6420 7265 6c69 6573 206f 6e20 7468 6973 d relies on this\n+0002a0b0: 2066 6f72 2074 7261 636b 696e 6720 636f for tracking co\n+0002a0c0: 6e6e 6563 7469 6f6e 7320 7769 7468 6f75 nnections withou\n+0002a0d0: 7420 616e 2065 7870 6c69 6369 7420 7573 t an explicit us\n+0002a0e0: 6572 206e 616d 653b 0a20 2020 2020 2020 er name;. \n+0002a0f0: 2023 2074 6865 2075 7365 7220 7769 6c6c # the user will\n+0002a100: 2074 6865 6e20 6265 2064 6574 6572 6d69 then be determi\n+0002a110: 6e65 6420 6279 2053 5348 2028 6055 7365 ned by SSH (`Use\n+0002a120: 7260 2069 6e20 7468 6520 636f 6e66 6967 r` in the config\n+0002a130: 206f 7220 7468 6520 6375 7272 656e 7420 or the current \n+0002a140: 7573 6572 290a 2020 2020 2020 2020 2320 user). # \n+0002a150: 5365 6520 636f 636b 7069 745f 726f 7574 See cockpit_rout\n+0002a160: 6572 5f6e 6f72 6d61 6c69 7a65 5f68 6f73 er_normalize_hos\n+0002a170: 745f 7061 7261 6d73 2829 2069 6e20 7372 t_params() in sr\n+0002a180: 632f 6272 6964 6765 2f63 6f63 6b70 6974 c/bridge/cockpit\n+0002a190: 726f 7574 6572 2e63 0a20 2020 2020 2020 router.c. \n+0002a1a0: 2069 6620 7573 6572 203d 3d20 6765 7470 if user == getp\n+0002a1b0: 6173 732e 6765 7475 7365 7228 293a 0a20 ass.getuser():. \n+0002a1c0: 2020 2020 2020 2020 2020 2075 7365 7220 user \n+0002a1d0: 3d20 4e6f 6e65 0a20 2020 2020 2020 2069 = None. i\n+0002a1e0: 6620 6e6f 7420 7573 6572 3a0a 2020 2020 f not user:. \n+0002a1f0: 2020 2020 2020 2020 7573 6572 5f66 726f user_fro\n+0002a200: 6d5f 686f 7374 2c20 5f2c 205f 203d 2068 m_host, _, _ = h\n+0002a210: 6f73 742e 7270 6172 7469 7469 6f6e 2827 ost.rpartition('\n+0002a220: 4027 290a 2020 2020 2020 2020 2020 2020 @'). \n+0002a230: 7573 6572 203d 2075 7365 725f 6672 6f6d user = user_from\n+0002a240: 5f68 6f73 7420 6f72 204e 6f6e 6520 2023 _host or None #\n+0002a250: 2061 766f 6964 2027 270a 0a20 2020 2020 avoid ''.. \n+0002a260: 2020 2069 6620 6765 745f 7374 7228 6f70 if get_str(op\n+0002a270: 7469 6f6e 732c 2027 7365 7373 696f 6e27 tions, 'session'\n+0002a280: 2c20 4e6f 6e65 2920 3d3d 2027 7072 6976 , None) == 'priv\n+0002a290: 6174 6527 3a0a 2020 2020 2020 2020 2020 ate':. \n+0002a2a0: 2020 6e6f 6e63 6520 3d20 6765 745f 7374 nonce = get_st\n+0002a2b0: 7228 6f70 7469 6f6e 732c 2027 6368 616e r(options, 'chan\n+0002a2c0: 6e65 6c27 290a 2020 2020 2020 2020 656c nel'). el\n+0002a2d0: 7365 3a0a 2020 2020 2020 2020 2020 2020 se:. \n+0002a2e0: 6e6f 6e63 6520 3d20 4e6f 6e65 0a0a 2020 nonce = None.. \n+0002a2f0: 2020 2020 2020 6173 7365 7274 2069 7369 assert isi\n+0002a300: 6e73 7461 6e63 6528 686f 7374 2c20 7374 nstance(host, st\n+0002a310: 7229 0a20 2020 2020 2020 2061 7373 6572 r). asser\n+0002a320: 7420 7573 6572 2069 7320 4e6f 6e65 206f t user is None o\n+0002a330: 7220 6973 696e 7374 616e 6365 2875 7365 r isinstance(use\n+0002a340: 722c 2073 7472 290a 2020 2020 2020 2020 r, str). \n+0002a350: 6173 7365 7274 206e 6f6e 6365 2069 7320 assert nonce is \n+0002a360: 4e6f 6e65 206f 7220 6973 696e 7374 616e None or isinstan\n+0002a370: 6365 286e 6f6e 6365 2c20 7374 7229 0a0a ce(nonce, str)..\n+0002a380: 2020 2020 2020 2020 6b65 7920 3d20 686f key = ho\n+0002a390: 7374 2c20 7573 6572 2c20 6e6f 6e63 650a st, user, nonce.\n+0002a3a0: 0a20 2020 2020 2020 206c 6f67 6765 722e . logger.\n+0002a3b0: 6465 6275 6728 2752 6571 7565 7374 2066 debug('Request f\n+0002a3c0: 6f72 2063 6861 6e6e 656c 2025 7320 6973 or channel %s is\n+0002a3d0: 2072 656d 6f74 652e 272c 206f 7074 696f remote.', optio\n+0002a3e0: 6e73 290a 2020 2020 2020 2020 6c6f 6767 ns). logg\n+0002a3f0: 6572 2e64 6562 7567 2827 6b65 793d 2573 er.debug('key=%s\n+0002a400: 272c 206b 6579 290a 0a20 2020 2020 2020 ', key).. \n+0002a410: 2069 6620 6b65 7920 6e6f 7420 696e 2073 if key not in s\n+0002a420: 656c 662e 7265 6d6f 7465 733a 0a20 2020 elf.remotes:. \n+0002a430: 2020 2020 2020 2020 206c 6f67 6765 722e logger.\n+0002a440: 6465 6275 6728 2725 7320 6973 206e 6f74 debug('%s is not\n+0002a450: 2061 6d6f 6e67 2074 6865 2065 7869 7374 among the exist\n+0002a460: 696e 6720 7265 6d6f 7465 7320 2573 2e20 ing remotes %s. \n+0002a470: 204f 7065 6e69 6e67 2061 206e 6577 2063 Opening a new c\n+0002a480: 6f6e 6e65 6374 696f 6e2e 272c 206b 6579 onnection.', key\n+0002a490: 2c20 7365 6c66 2e72 656d 6f74 6573 290a , self.remotes).\n+0002a4a0: 2020 2020 2020 2020 2020 2020 7065 6572 peer\n+0002a4b0: 203d 2053 7368 5065 6572 2873 656c 662e = SshPeer(self.\n+0002a4c0: 726f 7574 6572 2c20 686f 7374 2c20 7573 router, host, us\n+0002a4d0: 6572 2c20 6f70 7469 6f6e 732c 2070 7269 er, options, pri\n+0002a4e0: 7661 7465 3d6e 6f6e 6365 2069 7320 6e6f vate=nonce is no\n+0002a4f0: 7420 4e6f 6e65 290a 2020 2020 2020 2020 t None). \n+0002a500: 2020 2020 7065 6572 2e61 6464 5f64 6f6e peer.add_don\n+0002a510: 655f 6361 6c6c 6261 636b 286c 616d 6264 e_callback(lambd\n+0002a520: 613a 2073 656c 662e 7265 6d6f 7465 732e a: self.remotes.\n+0002a530: 5f5f 6465 6c69 7465 6d5f 5f28 6b65 7929 __delitem__(key)\n+0002a540: 290a 2020 2020 2020 2020 2020 2020 7365 ). se\n+0002a550: 6c66 2e72 656d 6f74 6573 5b6b 6579 5d20 lf.remotes[key] \n+0002a560: 3d20 7065 6572 0a0a 2020 2020 2020 2020 = peer.. \n+0002a570: 7265 7475 726e 2073 656c 662e 7265 6d6f return self.remo\n+0002a580: 7465 735b 6b65 795d 0a0a 2020 2020 6465 tes[key].. de\n+0002a590: 6620 7368 7574 646f 776e 2873 656c 6629 f shutdown(self)\n+0002a5a0: 3a0a 2020 2020 2020 2020 666f 7220 7065 :. for pe\n+0002a5b0: 6572 2069 6e20 7365 7428 7365 6c66 2e72 er in set(self.r\n+0002a5c0: 656d 6f74 6573 2e76 616c 7565 7328 2929 emotes.values())\n+0002a5d0: 3a0a 2020 2020 2020 2020 2020 2020 7065 :. pe\n+0002a5e0: 6572 2e63 6c6f 7365 2829 0a27 2727 2e65 er.close().'''.e\n+0002a5f0: 6e63 6f64 6528 2775 7466 2d38 2729 2c0a ncode('utf-8'),.\n+0002a600: 2020 2763 6f63 6b70 6974 2f62 7269 6467 'cockpit/bridg\n+0002a610: 652e 7079 273a 2072 2727 2723 2054 6869 e.py': r'''# Thi\n+0002a620: 7320 6669 6c65 2069 7320 7061 7274 206f s file is part o\n+0002a630: 6620 436f 636b 7069 742e 0a23 0a23 2043 f Cockpit..#.# C\n+0002a640: 6f70 7972 6967 6874 2028 4329 2032 3032 opyright (C) 202\n+0002a650: 3220 5265 6420 4861 742c 2049 6e63 2e0a 2 Red Hat, Inc..\n+0002a660: 230a 2320 5468 6973 2070 726f 6772 616d #.# This program\n+0002a670: 2069 7320 6672 6565 2073 6f66 7477 6172 is free softwar\n+0002a680: 653a 2079 6f75 2063 616e 2072 6564 6973 e: you can redis\n+0002a690: 7472 6962 7574 6520 6974 2061 6e64 2f6f tribute it and/o\n+0002a6a0: 7220 6d6f 6469 6679 0a23 2069 7420 756e r modify.# it un\n+0002a6b0: 6465 7220 7468 6520 7465 726d 7320 6f66 der the terms of\n+0002a6c0: 2074 6865 2047 4e55 2047 656e 6572 616c the GNU General\n+0002a6d0: 2050 7562 6c69 6320 4c69 6365 6e73 6520 Public License \n+0002a6e0: 6173 2070 7562 6c69 7368 6564 2062 790a as published by.\n+0002a6f0: 2320 7468 6520 4672 6565 2053 6f66 7477 # the Free Softw\n+0002a700: 6172 6520 466f 756e 6461 7469 6f6e 2c20 are Foundation, \n+0002a710: 6569 7468 6572 2076 6572 7369 6f6e 2033 either version 3\n+0002a720: 206f 6620 7468 6520 4c69 6365 6e73 652c of the License,\n+0002a730: 206f 720a 2320 2861 7420 796f 7572 206f or.# (at your o\n+0002a740: 7074 696f 6e29 2061 6e79 206c 6174 6572 ption) any later\n+0002a750: 2076 6572 7369 6f6e 2e0a 230a 2320 5468 version..#.# Th\n+0002a760: 6973 2070 726f 6772 616d 2069 7320 6469 is program is di\n+0002a770: 7374 7269 6275 7465 6420 696e 2074 6865 stributed in the\n+0002a780: 2068 6f70 6520 7468 6174 2069 7420 7769 hope that it wi\n+0002a790: 6c6c 2062 6520 7573 6566 756c 2c0a 2320 ll be useful,.# \n+0002a7a0: 6275 7420 5749 5448 4f55 5420 414e 5920 but WITHOUT ANY \n+0002a7b0: 5741 5252 414e 5459 3b20 7769 7468 6f75 WARRANTY; withou\n+0002a7c0: 7420 6576 656e 2074 6865 2069 6d70 6c69 t even the impli\n+0002a7d0: 6564 2077 6172 7261 6e74 7920 6f66 0a23 ed warranty of.#\n+0002a7e0: 204d 4552 4348 414e 5441 4249 4c49 5459 MERCHANTABILITY\n+0002a7f0: 206f 7220 4649 544e 4553 5320 464f 5220 or FITNESS FOR \n+0002a800: 4120 5041 5254 4943 554c 4152 2050 5552 A PARTICULAR PUR\n+0002a810: 504f 5345 2e20 2053 6565 2074 6865 0a23 POSE. See the.#\n+0002a820: 2047 4e55 2047 656e 6572 616c 2050 7562 GNU General Pub\n+0002a830: 6c69 6320 4c69 6365 6e73 6520 666f 7220 lic License for \n+0002a840: 6d6f 7265 2064 6574 6169 6c73 2e0a 230a more details..#.\n+0002a850: 2320 596f 7520 7368 6f75 6c64 2068 6176 # You should hav\n+0002a860: 6520 7265 6365 6976 6564 2061 2063 6f70 e received a cop\n+0002a870: 7920 6f66 2074 6865 2047 4e55 2047 656e y of the GNU Gen\n+0002a880: 6572 616c 2050 7562 6c69 6320 4c69 6365 eral Public Lice\n+0002a890: 6e73 650a 2320 616c 6f6e 6720 7769 7468 nse.# along with\n+0002a8a0: 2074 6869 7320 7072 6f67 7261 6d2e 2020 this program. \n+0002a8b0: 4966 206e 6f74 2c20 7365 6520 3c68 7474 If not, see ...im\n+0002a8e0: 706f 7274 2061 7267 7061 7273 650a 696d port argparse.im\n+0002a8f0: 706f 7274 2061 7379 6e63 696f 0a69 6d70 port asyncio.imp\n+0002a900: 6f72 7420 636f 6e74 6578 746c 6962 0a69 ort contextlib.i\n+0002a910: 6d70 6f72 7420 6a73 6f6e 0a69 6d70 6f72 mport json.impor\n+0002a920: 7420 6c6f 6767 696e 670a 696d 706f 7274 t logging.import\n+0002a930: 206f 730a 696d 706f 7274 2070 7764 0a69 os.import pwd.i\n+0002a940: 6d70 6f72 7420 7368 6c65 780a 696d 706f mport shlex.impo\n+0002a950: 7274 2073 6f63 6b65 740a 696d 706f 7274 rt socket.import\n+0002a960: 2073 7461 740a 696d 706f 7274 2073 7562 stat.import sub\n+0002a970: 7072 6f63 6573 730a 6672 6f6d 2074 7970 process.from typ\n+0002a980: 696e 6720 696d 706f 7274 2049 7465 7261 ing import Itera\n+0002a990: 626c 652c 204c 6973 742c 204f 7074 696f ble, List, Optio\n+0002a9a0: 6e61 6c2c 2053 6571 7565 6e63 652c 2054 nal, Sequence, T\n+0002a9b0: 7570 6c65 2c20 5479 7065 0a0a 6672 6f6d uple, Type..from\n+0002a9c0: 2063 6f63 6b70 6974 2e5f 7665 6e64 6f72 cockpit._vendor\n+0002a9d0: 2e66 6572 6e79 2069 6d70 6f72 7420 696e .ferny import in\n+0002a9e0: 7465 7261 6374 696f 6e5f 636c 6965 6e74 teraction_client\n+0002a9f0: 0a66 726f 6d20 636f 636b 7069 742e 5f76 .from cockpit._v\n+0002aa00: 656e 646f 722e 7379 7374 656d 645f 6374 endor.systemd_ct\n+0002aa10: 7970 6573 2069 6d70 6f72 7420 6275 732c ypes import bus,\n+0002aa20: 2072 756e 5f61 7379 6e63 0a0a 6672 6f6d run_async..from\n+0002aa30: 202e 2069 6d70 6f72 7420 706f 6c79 6669 . import polyfi\n+0002aa40: 6c6c 730a 6672 6f6d 202e 5f76 6572 7369 lls.from ._versi\n+0002aa50: 6f6e 2069 6d70 6f72 7420 5f5f 7665 7273 on import __vers\n+0002aa60: 696f 6e5f 5f0a 6672 6f6d 202e 6368 616e ion__.from .chan\n+0002aa70: 6e65 6c20 696d 706f 7274 2043 6861 6e6e nel import Chann\n+0002aa80: 656c 526f 7574 696e 6752 756c 650a 6672 elRoutingRule.fr\n+0002aa90: 6f6d 202e 6368 616e 6e65 6c73 2069 6d70 om .channels imp\n+0002aaa0: 6f72 7420 4348 414e 4e45 4c5f 5459 5045 ort CHANNEL_TYPE\n+0002aab0: 530a 6672 6f6d 202e 636f 6e66 6967 2069 S.from .config i\n+0002aac0: 6d70 6f72 7420 436f 6e66 6967 2c20 456e mport Config, En\n+0002aad0: 7669 726f 6e6d 656e 740a 6672 6f6d 202e vironment.from .\n+0002aae0: 696e 7465 726e 616c 5f65 6e64 706f 696e internal_endpoin\n+0002aaf0: 7473 2069 6d70 6f72 7420 4558 504f 5254 ts import EXPORT\n+0002ab00: 530a 6672 6f6d 202e 6a73 6f6e 7574 696c S.from .jsonutil\n+0002ab10: 2069 6d70 6f72 7420 4a73 6f6e 4572 726f import JsonErro\n+0002ab20: 722c 204a 736f 6e4f 626a 6563 742c 2067 r, JsonObject, g\n+0002ab30: 6574 5f64 6963 740a 6672 6f6d 202e 7061 et_dict.from .pa\n+0002ab40: 636b 6167 6573 2069 6d70 6f72 7420 4272 ckages import Br\n+0002ab50: 6964 6765 436f 6e66 6967 2c20 5061 636b idgeConfig, Pack\n+0002ab60: 6167 6573 2c20 5061 636b 6167 6573 4c69 ages, PackagesLi\n+0002ab70: 7374 656e 6572 0a66 726f 6d20 2e70 6565 stener.from .pee\n+0002ab80: 7220 696d 706f 7274 2050 6565 7273 526f r import PeersRo\n+0002ab90: 7574 696e 6752 756c 650a 6672 6f6d 202e utingRule.from .\n+0002aba0: 7265 6d6f 7465 2069 6d70 6f72 7420 486f remote import Ho\n+0002abb0: 7374 526f 7574 696e 6752 756c 650a 6672 stRoutingRule.fr\n+0002abc0: 6f6d 202e 726f 7574 6572 2069 6d70 6f72 om .router impor\n+0002abd0: 7420 526f 7574 6572 0a66 726f 6d20 2e73 t Router.from .s\n+0002abe0: 7570 6572 7573 6572 2069 6d70 6f72 7420 uperuser import \n+0002abf0: 5375 7065 7275 7365 7252 6f75 7469 6e67 SuperuserRouting\n+0002ac00: 5275 6c65 0a66 726f 6d20 2e74 7261 6e73 Rule.from .trans\n+0002ac10: 706f 7274 7320 696d 706f 7274 2053 7464 ports import Std\n+0002ac20: 696f 5472 616e 7370 6f72 740a 0a6c 6f67 ioTransport..log\n+0002ac30: 6765 7220 3d20 6c6f 6767 696e 672e 6765 ger = logging.ge\n+0002ac40: 744c 6f67 6765 7228 5f5f 6e61 6d65 5f5f tLogger(__name__\n+0002ac50: 290a 0a0a 636c 6173 7320 496e 7465 726e )...class Intern\n+0002ac60: 616c 4275 733a 0a20 2020 2065 7870 6f72 alBus:. expor\n+0002ac70: 7465 6573 3a20 4c69 7374 5b62 7573 2e53 tees: List[bus.S\n+0002ac80: 6c6f 745d 0a0a 2020 2020 6465 6620 5f5f lot].. def __\n+0002ac90: 696e 6974 5f5f 2873 656c 662c 2065 7870 init__(self, exp\n+0002aca0: 6f72 7473 3a20 4974 6572 6162 6c65 5b54 orts: Iterable[T\n+0002acb0: 7570 6c65 5b73 7472 2c20 5479 7065 5b62 uple[str, Type[b\n+0002acc0: 7573 2e42 6173 654f 626a 6563 745d 5d5d us.BaseObject]]]\n+0002acd0: 293a 0a20 2020 2020 2020 2063 6c69 656e ):. clien\n+0002ace0: 745f 736f 636b 6574 2c20 7365 7276 6572 t_socket, server\n+0002acf0: 5f73 6f63 6b65 7420 3d20 736f 636b 6574 _socket = socket\n+0002ad00: 2e73 6f63 6b65 7470 6169 7228 290a 2020 .socketpair(). \n+0002ad10: 2020 2020 2020 7365 6c66 2e63 6c69 656e self.clien\n+0002ad20: 7420 3d20 6275 732e 4275 732e 6e65 7728 t = bus.Bus.new(\n+0002ad30: 6664 3d63 6c69 656e 745f 736f 636b 6574 fd=client_socket\n+0002ad40: 2e64 6574 6163 6828 2929 0a20 2020 2020 .detach()). \n+0002ad50: 2020 2073 656c 662e 7365 7276 6572 203d self.server =\n+0002ad60: 2062 7573 2e42 7573 2e6e 6577 2866 643d bus.Bus.new(fd=\n+0002ad70: 7365 7276 6572 5f73 6f63 6b65 742e 6465 server_socket.de\n+0002ad80: 7461 6368 2829 2c20 7365 7276 6572 3d54 tach(), server=T\n+0002ad90: 7275 6529 0a20 2020 2020 2020 2073 656c rue). sel\n+0002ada0: 662e 6578 706f 7274 6565 7320 3d20 5b73 f.exportees = [s\n+0002adb0: 656c 662e 7365 7276 6572 2e61 6464 5f6f elf.server.add_o\n+0002adc0: 626a 6563 7428 7061 7468 2c20 636c 7328 bject(path, cls(\n+0002add0: 2929 2066 6f72 2070 6174 682c 2063 6c73 )) for path, cls\n+0002ade0: 2069 6e20 6578 706f 7274 735d 0a0a 2020 in exports].. \n+0002adf0: 2020 6465 6620 6578 706f 7274 2873 656c def export(sel\n+0002ae00: 662c 2070 6174 683a 2073 7472 2c20 6f62 f, path: str, ob\n+0002ae10: 6a3a 2062 7573 2e42 6173 654f 626a 6563 j: bus.BaseObjec\n+0002ae20: 7429 202d 3e20 4e6f 6e65 3a0a 2020 2020 t) -> None:. \n+0002ae30: 2020 2020 7365 6c66 2e65 7870 6f72 7465 self.exporte\n+0002ae40: 6573 2e61 7070 656e 6428 7365 6c66 2e73 es.append(self.s\n+0002ae50: 6572 7665 722e 6164 645f 6f62 6a65 6374 erver.add_object\n+0002ae60: 2870 6174 682c 206f 626a 2929 0a0a 0a63 (path, obj))...c\n+0002ae70: 6c61 7373 2042 7269 6467 6528 526f 7574 lass Bridge(Rout\n+0002ae80: 6572 2c20 5061 636b 6167 6573 4c69 7374 er, PackagesList\n+0002ae90: 656e 6572 293a 0a20 2020 2069 6e74 6572 ener):. inter\n+0002aea0: 6e61 6c5f 6275 733a 2049 6e74 6572 6e61 nal_bus: Interna\n+0002aeb0: 6c42 7573 0a20 2020 2070 6163 6b61 6765 lBus. package\n+0002aec0: 733a 204f 7074 696f 6e61 6c5b 5061 636b s: Optional[Pack\n+0002aed0: 6167 6573 5d0a 2020 2020 6272 6964 6765 ages]. bridge\n+0002aee0: 5f63 6f6e 6669 6773 3a20 5365 7175 656e _configs: Sequen\n+0002aef0: 6365 5b42 7269 6467 6543 6f6e 6669 675d ce[BridgeConfig]\n+0002af00: 0a20 2020 2061 7267 733a 2061 7267 7061 . args: argpa\n+0002af10: 7273 652e 4e61 6d65 7370 6163 650a 0a20 rse.Namespace.. \n+0002af20: 2020 2064 6566 205f 5f69 6e69 745f 5f28 def __init__(\n+0002af30: 7365 6c66 2c20 6172 6773 3a20 6172 6770 self, args: argp\n+0002af40: 6172 7365 2e4e 616d 6573 7061 6365 293a arse.Namespace):\n+0002af50: 0a20 2020 2020 2020 2073 656c 662e 696e . self.in\n+0002af60: 7465 726e 616c 5f62 7573 203d 2049 6e74 ternal_bus = Int\n+0002af70: 6572 6e61 6c42 7573 2845 5850 4f52 5453 ernalBus(EXPORTS\n+0002af80: 290a 2020 2020 2020 2020 7365 6c66 2e62 ). self.b\n+0002af90: 7269 6467 655f 636f 6e66 6967 7320 3d20 ridge_configs = \n+0002afa0: 5b5d 0a20 2020 2020 2020 2073 656c 662e []. self.\n+0002afb0: 6172 6773 203d 2061 7267 730a 0a20 2020 args = args.. \n+0002afc0: 2020 2020 2073 656c 662e 7375 7065 7275 self.superu\n+0002afd0: 7365 725f 7275 6c65 203d 2053 7570 6572 ser_rule = Super\n+0002afe0: 7573 6572 526f 7574 696e 6752 756c 6528 userRoutingRule(\n+0002aff0: 7365 6c66 2c20 7072 6976 696c 6567 6564 self, privileged\n+0002b000: 3d61 7267 732e 7072 6976 696c 6567 6564 =args.privileged\n+0002b010: 290a 2020 2020 2020 2020 7365 6c66 2e69 ). self.i\n+0002b020: 6e74 6572 6e61 6c5f 6275 732e 6578 706f nternal_bus.expo\n+0002b030: 7274 2827 2f73 7570 6572 7573 6572 272c rt('/superuser',\n+0002b040: 2073 656c 662e 7375 7065 7275 7365 725f self.superuser_\n+0002b050: 7275 6c65 290a 0a20 2020 2020 2020 2073 rule).. s\n+0002b060: 656c 662e 696e 7465 726e 616c 5f62 7573 elf.internal_bus\n+0002b070: 2e65 7870 6f72 7428 272f 636f 6e66 6967 .export('/config\n+0002b080: 272c 2043 6f6e 6669 6728 2929 0a20 2020 ', Config()). \n+0002b090: 2020 2020 2073 656c 662e 696e 7465 726e self.intern\n+0002b0a0: 616c 5f62 7573 2e65 7870 6f72 7428 272f al_bus.export('/\n+0002b0b0: 656e 7669 726f 6e6d 656e 7427 2c20 456e environment', En\n+0002b0c0: 7669 726f 6e6d 656e 7428 2929 0a0a 2020 vironment()).. \n+0002b0d0: 2020 2020 2020 7365 6c66 2e70 6565 7273 self.peers\n+0002b0e0: 5f72 756c 6520 3d20 5065 6572 7352 6f75 _rule = PeersRou\n+0002b0f0: 7469 6e67 5275 6c65 2873 656c 6629 0a0a tingRule(self)..\n+0002b100: 2020 2020 2020 2020 6966 2061 7267 732e if args.\n+0002b110: 6265 6970 6163 6b3a 0a20 2020 2020 2020 beipack:. \n+0002b120: 2020 2020 2023 2053 6f6d 6520 7370 6563 # Some spec\n+0002b130: 6961 6c20 7374 7566 6620 666f 7220 6265 ial stuff for be\n+0002b140: 6970 6163 6b0a 2020 2020 2020 2020 2020 ipack. \n+0002b150: 2020 7365 6c66 2e73 7570 6572 7573 6572 self.superuser\n+0002b160: 5f72 756c 652e 7365 745f 636f 6e66 6967 _rule.set_config\n+0002b170: 7328 280a 2020 2020 2020 2020 2020 2020 s((. \n+0002b180: 2020 2020 4272 6964 6765 436f 6e66 6967 BridgeConfig\n+0002b190: 287b 0a20 2020 2020 2020 2020 2020 2020 ({. \n+0002b1a0: 2020 2020 2020 2022 7072 6976 696c 6567 \"privileg\n+0002b1b0: 6564 223a 2054 7275 652c 0a20 2020 2020 ed\": True,. \n+0002b1c0: 2020 2020 2020 2020 2020 2020 2020 2022 \"\n+0002b1d0: 7370 6177 6e22 3a20 5b22 7375 646f 222c spawn\": [\"sudo\",\n+0002b1e0: 2022 2d6b 222c 2022 2d41 222c 2022 7079 \"-k\", \"-A\", \"py\n+0002b1f0: 7468 6f6e 3322 2c20 222d 6963 222c 2022 thon3\", \"-ic\", \"\n+0002b200: 2320 636f 636b 7069 742d 6272 6964 6765 # cockpit-bridge\n+0002b210: 222c 2022 2d2d 7072 6976 696c 6567 6564 \", \"--privileged\n+0002b220: 225d 2c0a 2020 2020 2020 2020 2020 2020 \"],. \n+0002b230: 2020 2020 2020 2020 2265 6e76 6972 6f6e \"environ\n+0002b240: 223a 205b 2253 5544 4f5f 4153 4b50 4153 \": [\"SUDO_ASKPAS\n+0002b250: 533d 6665 726e 792d 6173 6b70 6173 7322 S=ferny-askpass\"\n+0002b260: 5d2c 0a20 2020 2020 2020 2020 2020 2020 ],. \n+0002b270: 2020 207d 292c 0a20 2020 2020 2020 2020 }),. \n+0002b280: 2020 2029 290a 2020 2020 2020 2020 2020 )). \n+0002b290: 2020 7365 6c66 2e70 6163 6b61 6765 7320 self.packages \n+0002b2a0: 3d20 4e6f 6e65 0a20 2020 2020 2020 2065 = None. e\n+0002b2b0: 6c69 6620 6172 6773 2e70 7269 7669 6c65 lif args.privile\n+0002b2c0: 6765 643a 0a20 2020 2020 2020 2020 2020 ged:. \n+0002b2d0: 2073 656c 662e 7061 636b 6167 6573 203d self.packages =\n+0002b2e0: 204e 6f6e 650a 2020 2020 2020 2020 656c None. el\n+0002b2f0: 7365 3a0a 2020 2020 2020 2020 2020 2020 se:. \n+0002b300: 7365 6c66 2e70 6163 6b61 6765 7320 3d20 self.packages = \n+0002b310: 5061 636b 6167 6573 2873 656c 6629 0a20 Packages(self). \n+0002b320: 2020 2020 2020 2020 2020 2073 656c 662e self.\n+0002b330: 696e 7465 726e 616c 5f62 7573 2e65 7870 internal_bus.exp\n+0002b340: 6f72 7428 272f 7061 636b 6167 6573 272c ort('/packages',\n+0002b350: 2073 656c 662e 7061 636b 6167 6573 290a self.packages).\n+0002b360: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n+0002b370: 2e70 6163 6b61 6765 735f 6c6f 6164 6564 .packages_loaded\n+0002b380: 2829 0a0a 2020 2020 2020 2020 7375 7065 ().. supe\n+0002b390: 7228 292e 5f5f 696e 6974 5f5f 285b 0a20 r().__init__([. \n+0002b3a0: 2020 2020 2020 2020 2020 2048 6f73 7452 HostR\n+0002b3b0: 6f75 7469 6e67 5275 6c65 2873 656c 6629 outingRule(self)\n+0002b3c0: 2c0a 2020 2020 2020 2020 2020 2020 7365 ,. se\n+0002b3d0: 6c66 2e73 7570 6572 7573 6572 5f72 756c lf.superuser_rul\n+0002b3e0: 652c 0a20 2020 2020 2020 2020 2020 2043 e,. C\n+0002b3f0: 6861 6e6e 656c 526f 7574 696e 6752 756c hannelRoutingRul\n+0002b400: 6528 7365 6c66 2c20 4348 414e 4e45 4c5f e(self, CHANNEL_\n+0002b410: 5459 5045 5329 2c0a 2020 2020 2020 2020 TYPES),. \n+0002b420: 2020 2020 7365 6c66 2e70 6565 7273 5f72 self.peers_r\n+0002b430: 756c 652c 0a20 2020 2020 2020 205d 290a ule,. ]).\n+0002b440: 0a20 2020 2040 7374 6174 6963 6d65 7468 . @staticmeth\n+0002b450: 6f64 0a20 2020 2064 6566 2067 6574 5f6f od. def get_o\n+0002b460: 735f 7265 6c65 6173 6528 293a 0a20 2020 s_release():. \n+0002b470: 2020 2020 2074 7279 3a0a 2020 2020 2020 try:. \n+0002b480: 2020 2020 2020 6669 6c65 203d 206f 7065 file = ope\n+0002b490: 6e28 272f 6574 632f 6f73 2d72 656c 6561 n('/etc/os-relea\n+0002b4a0: 7365 272c 2065 6e63 6f64 696e 673d 2775 se', encoding='u\n+0002b4b0: 7466 2d38 2729 0a20 2020 2020 2020 2065 tf-8'). e\n+0002b4c0: 7863 6570 7420 4669 6c65 4e6f 7446 6f75 xcept FileNotFou\n+0002b4d0: 6e64 4572 726f 723a 0a20 2020 2020 2020 ndError:. \n+0002b4e0: 2020 2020 2074 7279 3a0a 2020 2020 2020 try:. \n+0002b4f0: 2020 2020 2020 2020 2020 6669 6c65 203d file =\n+0002b500: 206f 7065 6e28 272f 7573 722f 6c69 622f open('/usr/lib/\n+0002b510: 6f73 2d72 656c 6561 7365 272c 2065 6e63 os-release', enc\n+0002b520: 6f64 696e 673d 2775 7466 2d38 2729 0a20 oding='utf-8'). \n+0002b530: 2020 2020 2020 2020 2020 2065 7863 6570 excep\n+0002b540: 7420 4669 6c65 4e6f 7446 6f75 6e64 4572 t FileNotFoundEr\n+0002b550: 726f 723a 0a20 2020 2020 2020 2020 2020 ror:. \n+0002b560: 2020 2020 206c 6f67 6765 722e 7761 726e logger.warn\n+0002b570: 696e 6728 224e 6569 7468 6572 202f 6574 ing(\"Neither /et\n+0002b580: 632f 6f73 2d72 656c 6561 7365 206e 6f72 c/os-release nor\n+0002b590: 202f 7573 722f 6c69 622f 6f73 2d72 656c /usr/lib/os-rel\n+0002b5a0: 6561 7365 2065 7869 7374 7322 290a 2020 ease exists\"). \n+0002b5b0: 2020 2020 2020 2020 2020 2020 2020 7265 re\n+0002b5c0: 7475 726e 207b 7d0a 0a20 2020 2020 2020 turn {}.. \n+0002b5d0: 206f 735f 7265 6c65 6173 6520 3d20 7b7d os_release = {}\n+0002b5e0: 0a20 2020 2020 2020 2066 6f72 206c 696e . for lin\n+0002b5f0: 6520 696e 2066 696c 652e 7265 6164 6c69 e in file.readli\n+0002b600: 6e65 7328 293a 0a20 2020 2020 2020 2020 nes():. \n+0002b610: 2020 206c 696e 6520 3d20 6c69 6e65 2e73 line = line.s\n+0002b620: 7472 6970 2829 0a20 2020 2020 2020 2020 trip(). \n+0002b630: 2020 2069 6620 6e6f 7420 6c69 6e65 206f if not line o\n+0002b640: 7220 6c69 6e65 2e73 7461 7274 7377 6974 r line.startswit\n+0002b650: 6828 2723 2729 3a0a 2020 2020 2020 2020 h('#'):. \n+0002b660: 2020 2020 2020 2020 636f 6e74 696e 7565 continue\n+0002b670: 0a20 2020 2020 2020 2020 2020 2074 7279 . try\n+0002b680: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n+0002b690: 2020 6b2c 2076 203d 206c 696e 652e 7370 k, v = line.sp\n+0002b6a0: 6c69 7428 273d 2729 0a20 2020 2020 2020 lit('='). \n+0002b6b0: 2020 2020 2020 2020 2028 765f 7061 7273 (v_pars\n+0002b6c0: 6564 2c20 2920 3d20 7368 6c65 782e 7370 ed, ) = shlex.sp\n+0002b6d0: 6c69 7428 7629 2020 2320 6578 7065 6374 lit(v) # expect\n+0002b6e0: 2065 7861 6374 6c79 206f 6e65 2074 6f6b exactly one tok\n+0002b6f0: 656e 0a20 2020 2020 2020 2020 2020 2065 en. e\n+0002b700: 7863 6570 7420 5661 6c75 6545 7272 6f72 xcept ValueError\n+0002b710: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n+0002b720: 2020 6c6f 6767 6572 2e77 6172 6e69 6e67 logger.warning\n+0002b730: 2827 4967 6e6f 7269 6e67 2069 6e76 616c ('Ignoring inval\n+0002b740: 6964 206c 696e 6520 696e 206f 732d 7265 id line in os-re\n+0002b750: 6c65 6173 653a 2025 7227 2c20 6c69 6e65 lease: %r', line\n+0002b760: 290a 2020 2020 2020 2020 2020 2020 2020 ). \n+0002b770: 2020 636f 6e74 696e 7565 0a20 2020 2020 continue. \n+0002b780: 2020 2020 2020 206f 735f 7265 6c65 6173 os_releas\n+0002b790: 655b 6b5d 203d 2076 5f70 6172 7365 640a e[k] = v_parsed.\n+0002b7a0: 2020 2020 2020 2020 7265 7475 726e 206f return o\n+0002b7b0: 735f 7265 6c65 6173 650a 0a20 2020 2064 s_release.. d\n+0002b7c0: 6566 2064 6f5f 696e 6974 2873 656c 662c ef do_init(self,\n+0002b7d0: 206d 6573 7361 6765 3a20 4a73 6f6e 4f62 message: JsonOb\n+0002b7e0: 6a65 6374 2920 2d3e 204e 6f6e 653a 0a20 ject) -> None:. \n+0002b7f0: 2020 2020 2020 2023 2077 6527 7265 206f # we're o\n+0002b800: 6e6c 7920 696e 7465 7265 7374 6564 2069 nly interested i\n+0002b810: 6e20 7468 6520 6361 7365 2077 6865 7265 n the case where\n+0002b820: 2074 6869 7320 6973 2061 2064 6963 742c this is a dict,\n+0002b830: 2062 7574 0a20 2020 2020 2020 2023 2027 but. # '\n+0002b840: 7375 7065 7275 7365 7227 206d 6179 2077 superuser' may w\n+0002b850: 656c 6c20 6265 2060 4661 6c73 6560 2061 ell be `False` a\n+0002b860: 6e64 2074 6861 7427 7320 6e6f 7420 616e nd that's not an\n+0002b870: 2065 7272 6f72 0a20 2020 2020 2020 2077 error. w\n+0002b880: 6974 6820 636f 6e74 6578 746c 6962 2e73 ith contextlib.s\n+0002b890: 7570 7072 6573 7328 4a73 6f6e 4572 726f uppress(JsonErro\n+0002b8a0: 7229 3a0a 2020 2020 2020 2020 2020 2020 r):. \n+0002b8b0: 7375 7065 7275 7365 7220 3d20 6765 745f superuser = get_\n+0002b8c0: 6469 6374 286d 6573 7361 6765 2c20 2773 dict(message, 's\n+0002b8d0: 7570 6572 7573 6572 2729 0a20 2020 2020 uperuser'). \n+0002b8e0: 2020 2020 2020 2073 656c 662e 7375 7065 self.supe\n+0002b8f0: 7275 7365 725f 7275 6c65 2e69 6e69 7428 ruser_rule.init(\n+0002b900: 7375 7065 7275 7365 7229 0a0a 2020 2020 superuser).. \n+0002b910: 6465 6620 646f 5f73 656e 645f 696e 6974 def do_send_init\n+0002b920: 2873 656c 6629 202d 3e20 4e6f 6e65 3a0a (self) -> None:.\n+0002b930: 2020 2020 2020 2020 696e 6974 5f61 7267 init_arg\n+0002b940: 7320 3d20 7b0a 2020 2020 2020 2020 2020 s = {. \n+0002b950: 2020 2763 6170 6162 696c 6974 6965 7327 'capabilities'\n+0002b960: 3a20 7b27 6578 706c 6963 6974 2d73 7570 : {'explicit-sup\n+0002b970: 6572 7573 6572 273a 2054 7275 657d 2c0a eruser': True},.\n+0002b980: 2020 2020 2020 2020 2020 2020 2763 6f6d 'com\n+0002b990: 6d61 6e64 273a 2027 696e 6974 272c 0a20 mand': 'init',. \n+0002b9a0: 2020 2020 2020 2020 2020 2027 6f73 2d72 'os-r\n+0002b9b0: 656c 6561 7365 273a 2073 656c 662e 6765 elease': self.ge\n+0002b9c0: 745f 6f73 5f72 656c 6561 7365 2829 2c0a t_os_release(),.\n+0002b9d0: 2020 2020 2020 2020 2020 2020 2776 6572 'ver\n+0002b9e0: 7369 6f6e 273a 2031 2c0a 2020 2020 2020 sion': 1,. \n+0002b9f0: 2020 7d0a 0a20 2020 2020 2020 2069 6620 }.. if \n+0002ba00: 7365 6c66 2e70 6163 6b61 6765 7320 6973 self.packages is\n+0002ba10: 206e 6f74 204e 6f6e 653a 0a20 2020 2020 not None:. \n+0002ba20: 2020 2020 2020 2069 6e69 745f 6172 6773 init_args\n+0002ba30: 5b27 7061 636b 6167 6573 275d 203d 2064 ['packages'] = d\n+0002ba40: 6963 742e 6672 6f6d 6b65 7973 2873 656c ict.fromkeys(sel\n+0002ba50: 662e 7061 636b 6167 6573 2e70 6163 6b61 f.packages.packa\n+0002ba60: 6765 7329 0a0a 2020 2020 2020 2020 7365 ges).. se\n+0002ba70: 6c66 2e77 7269 7465 5f63 6f6e 7472 6f6c lf.write_control\n+0002ba80: 2869 6e69 745f 6172 6773 290a 0a20 2020 (init_args).. \n+0002ba90: 2023 2050 6163 6b61 6765 734c 6973 7465 # PackagesListe\n+0002baa0: 6e65 7220 696e 7465 7266 6163 650a 2020 ner interface. \n+0002bab0: 2020 6465 6620 7061 636b 6167 6573 5f6c def packages_l\n+0002bac0: 6f61 6465 6428 7365 6c66 2920 2d3e 204e oaded(self) -> N\n+0002bad0: 6f6e 653a 0a20 2020 2020 2020 2061 7373 one:. ass\n+0002bae0: 6572 7420 7365 6c66 2e70 6163 6b61 6765 ert self.package\n+0002baf0: 730a 2020 2020 2020 2020 6272 6964 6765 s. bridge\n+0002bb00: 5f63 6f6e 6669 6773 203d 2073 656c 662e _configs = self.\n+0002bb10: 7061 636b 6167 6573 2e67 6574 5f62 7269 packages.get_bri\n+0002bb20: 6467 655f 636f 6e66 6967 7328 290a 2020 dge_configs(). \n+0002bb30: 2020 2020 2020 6966 2073 656c 662e 6272 if self.br\n+0002bb40: 6964 6765 5f63 6f6e 6669 6773 2021 3d20 idge_configs != \n+0002bb50: 6272 6964 6765 5f63 6f6e 6669 6773 3a0a bridge_configs:.\n+0002bb60: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n+0002bb70: 2e73 7570 6572 7573 6572 5f72 756c 652e .superuser_rule.\n+0002bb80: 7365 745f 636f 6e66 6967 7328 6272 6964 set_configs(brid\n+0002bb90: 6765 5f63 6f6e 6669 6773 290a 2020 2020 ge_configs). \n+0002bba0: 2020 2020 2020 2020 7365 6c66 2e70 6565 self.pee\n+0002bbb0: 7273 5f72 756c 652e 7365 745f 636f 6e66 rs_rule.set_conf\n+0002bbc0: 6967 7328 6272 6964 6765 5f63 6f6e 6669 igs(bridge_confi\n+0002bbd0: 6773 290a 2020 2020 2020 2020 2020 2020 gs). \n+0002bbe0: 7365 6c66 2e62 7269 6467 655f 636f 6e66 self.bridge_conf\n+0002bbf0: 6967 7320 3d20 6272 6964 6765 5f63 6f6e igs = bridge_con\n+0002bc00: 6669 6773 0a0a 0a61 7379 6e63 2064 6566 figs...async def\n+0002bc10: 2072 756e 2861 7267 7329 202d 3e20 4e6f run(args) -> No\n+0002bc20: 6e65 3a0a 2020 2020 6c6f 6767 6572 2e64 ne:. logger.d\n+0002bc30: 6562 7567 2822 4869 2e20 486f 7720 6172 ebug(\"Hi. How ar\n+0002bc40: 6520 796f 7520 746f 6461 793f 2229 0a0a e you today?\")..\n+0002bc50: 2020 2020 2320 556e 6974 2074 6573 7473 # Unit tests\n+0002bc60: 2072 6571 7569 7265 2074 6869 730a 2020 require this. \n+0002bc70: 2020 6d65 203d 2070 7764 2e67 6574 7077 me = pwd.getpw\n+0002bc80: 7569 6428 6f73 2e67 6574 7569 6428 2929 uid(os.getuid())\n+0002bc90: 0a20 2020 206f 732e 656e 7669 726f 6e5b . os.environ[\n+0002bca0: 2748 4f4d 4527 5d20 3d20 6d65 2e70 775f 'HOME'] = me.pw_\n+0002bcb0: 6469 720a 2020 2020 6f73 2e65 6e76 6972 dir. os.envir\n+0002bcc0: 6f6e 5b27 5348 454c 4c27 5d20 3d20 6d65 on['SHELL'] = me\n+0002bcd0: 2e70 775f 7368 656c 6c0a 2020 2020 6f73 .pw_shell. os\n+0002bce0: 2e65 6e76 6972 6f6e 5b27 5553 4552 275d .environ['USER']\n+0002bcf0: 203d 206d 652e 7077 5f6e 616d 650a 0a20 = me.pw_name.. \n+0002bd00: 2020 206c 6f67 6765 722e 6465 6275 6728 logger.debug(\n+0002bd10: 2753 7461 7274 696e 6720 7468 6520 726f 'Starting the ro\n+0002bd20: 7574 6572 2e27 290a 2020 2020 726f 7574 uter.'). rout\n+0002bd30: 6572 203d 2042 7269 6467 6528 6172 6773 er = Bridge(args\n+0002bd40: 290a 2020 2020 5374 6469 6f54 7261 6e73 ). StdioTrans\n+0002bd50: 706f 7274 2861 7379 6e63 696f 2e67 6574 port(asyncio.get\n+0002bd60: 5f72 756e 6e69 6e67 5f6c 6f6f 7028 292c _running_loop(),\n+0002bd70: 2072 6f75 7465 7229 0a0a 2020 2020 6c6f router).. lo\n+0002bd80: 6767 6572 2e64 6562 7567 2827 5374 6172 gger.debug('Star\n+0002bd90: 7475 7020 646f 6e65 2e20 204c 6f6f 7069 tup done. Loopi\n+0002bda0: 6e67 2075 6e74 696c 2063 6f6e 6e65 6374 ng until connect\n+0002bdb0: 696f 6e20 636c 6f73 6573 2e27 290a 0a20 ion closes.').. \n+0002bdc0: 2020 2074 7279 3a0a 2020 2020 2020 2020 try:. \n+0002bdd0: 6177 6169 7420 726f 7574 6572 2e63 6f6d await router.com\n+0002bde0: 6d75 6e69 6361 7465 2829 0a20 2020 2065 municate(). e\n+0002bdf0: 7863 6570 7420 2842 726f 6b65 6e50 6970 xcept (BrokenPip\n+0002be00: 6545 7272 6f72 2c20 436f 6e6e 6563 7469 eError, Connecti\n+0002be10: 6f6e 5265 7365 7445 7272 6f72 293a 0a20 onResetError):. \n+0002be20: 2020 2020 2020 2023 206e 6f74 2075 6e65 # not une\n+0002be30: 7870 6563 7465 6420 6966 2074 6865 2070 xpected if the p\n+0002be40: 6565 7220 646f 6573 6e27 7420 6861 6e67 eer doesn't hang\n+0002be50: 2075 7020 636c 6561 6e6c 790a 2020 2020 up cleanly. \n+0002be60: 2020 2020 7061 7373 0a0a 0a64 6566 2074 pass...def t\n+0002be70: 7279 5f74 6f5f 7265 6365 6976 655f 7374 ry_to_receive_st\n+0002be80: 6465 7272 2829 3a0a 2020 2020 7472 793a derr():. try:\n+0002be90: 0a20 2020 2020 2020 206f 7572 732c 2074 . ours, t\n+0002bea0: 6865 6972 7320 3d20 736f 636b 6574 2e73 heirs = socket.s\n+0002beb0: 6f63 6b65 7470 6169 7228 290a 2020 2020 ocketpair(). \n+0002bec0: 2020 2020 7769 7468 206f 7572 733a 0a20 with ours:. \n+0002bed0: 2020 2020 2020 2020 2020 2077 6974 6820 with \n+0002bee0: 7468 6569 7273 3a0a 2020 2020 2020 2020 theirs:. \n+0002bef0: 2020 2020 2020 2020 696e 7465 7261 6374 interact\n+0002bf00: 696f 6e5f 636c 6965 6e74 2e63 6f6d 6d61 ion_client.comma\n+0002bf10: 6e64 2832 2c20 2763 6f63 6b70 6974 2e73 nd(2, 'cockpit.s\n+0002bf20: 656e 642d 7374 6465 7272 272c 2066 6473 end-stderr', fds\n+0002bf30: 3d5b 7468 6569 7273 2e66 696c 656e 6f28 =[theirs.fileno(\n+0002bf40: 295d 290a 2020 2020 2020 2020 2020 2020 )]). \n+0002bf50: 5f6d 7367 2c20 6664 732c 205f 666c 6167 _msg, fds, _flag\n+0002bf60: 732c 205f 6164 6472 203d 2073 6f63 6b65 s, _addr = socke\n+0002bf70: 742e 7265 6376 5f66 6473 286f 7572 732c t.recv_fds(ours,\n+0002bf80: 2031 2c20 3129 0a20 2020 2065 7863 6570 1, 1). excep\n+0002bf90: 7420 4f53 4572 726f 723a 0a20 2020 2020 t OSError:. \n+0002bfa0: 2020 2072 6574 7572 6e0a 0a20 2020 2074 return.. t\n+0002bfb0: 7279 3a0a 2020 2020 2020 2020 7374 6465 ry:. stde\n+0002bfc0: 7272 5f66 642c 203d 2066 6473 0a20 2020 rr_fd, = fds. \n+0002bfd0: 2020 2020 2023 2057 6527 7265 2061 626f # We're abo\n+0002bfe0: 7574 2074 6f20 6162 7275 7074 6c79 2064 ut to abruptly d\n+0002bff0: 726f 7020 6f75 7220 656e 6420 6f66 2074 rop our end of t\n+0002c000: 6865 2073 7464 6572 7220 736f 636b 6574 he stderr socket\n+0002c010: 7061 6972 2074 6861 7420 7765 0a20 2020 pair that we. \n+0002c020: 2020 2020 2023 2073 6861 7265 2077 6974 # share wit\n+0002c030: 6820 7468 6520 6665 726e 7920 6167 656e h the ferny agen\n+0002c040: 742e 2020 6665 726e 7920 776f 756c 6420 t. ferny would \n+0002c050: 6e6f 726d 616c 6c79 2074 7265 6174 2074 normally treat t\n+0002c060: 6861 7420 6173 2061 6e0a 2020 2020 2020 hat as an. \n+0002c070: 2020 2320 756e 6578 7065 6374 6564 2065 # unexpected e\n+0002c080: 7272 6f72 2e20 496e 7374 7275 6374 2069 rror. Instruct i\n+0002c090: 7420 746f 2064 6f20 6120 636c 6561 6e20 t to do a clean \n+0002c0a0: 6578 6974 2c20 696e 7374 6561 642e 0a20 exit, instead.. \n+0002c0b0: 2020 2020 2020 2069 6e74 6572 6163 7469 interacti\n+0002c0c0: 6f6e 5f63 6c69 656e 742e 636f 6d6d 616e on_client.comman\n+0002c0d0: 6428 322c 2027 6665 726e 792e 656e 6427 d(2, 'ferny.end'\n+0002c0e0: 290a 2020 2020 2020 2020 6f73 2e64 7570 ). os.dup\n+0002c0f0: 3228 7374 6465 7272 5f66 642c 2032 290a 2(stderr_fd, 2).\n+0002c100: 2020 2020 6669 6e61 6c6c 793a 0a20 2020 finally:. \n+0002c110: 2020 2020 2066 6f72 2066 6420 696e 2066 for fd in f\n+0002c120: 6473 3a0a 2020 2020 2020 2020 2020 2020 ds:. \n+0002c130: 6f73 2e63 6c6f 7365 2866 6429 0a0a 0a64 os.close(fd)...d\n+0002c140: 6566 2073 6574 7570 5f6a 6f75 726e 616c ef setup_journal\n+0002c150: 6428 2920 2d3e 2062 6f6f 6c3a 0a20 2020 d() -> bool:. \n+0002c160: 2023 2049 6620 7374 6465 7272 2069 7320 # If stderr is \n+0002c170: 6120 736f 636b 6574 2c20 7072 6566 6572 a socket, prefer\n+0002c180: 2073 7973 7465 6d64 2d6a 6f75 726e 616c systemd-journal\n+0002c190: 206c 6f67 6769 6e67 2e20 2054 6869 7320 logging. This \n+0002c1a0: 636f 7665 7273 2074 6865 0a20 2020 2023 covers the. #\n+0002c1b0: 2063 6173 6520 7765 2772 6520 616c 7265 case we're alre\n+0002c1c0: 6164 7920 636f 6e6e 6563 7465 6420 746f ady connected to\n+0002c1d0: 2074 6865 206a 6f75 726e 616c 2062 7574 the journal but\n+0002c1e0: 2061 6c73 6f20 7468 6520 6361 7365 2077 also the case w\n+0002c1f0: 6865 7265 2077 6527 7265 0a20 2020 2023 here we're. #\n+0002c200: 2074 616c 6b69 6e67 2074 6f20 7468 6520 talking to the \n+0002c210: 6665 726e 7920 6167 656e 742c 2077 6869 ferny agent, whi\n+0002c220: 6c65 206c 6561 7669 6e67 206c 6f67 6769 le leaving loggi\n+0002c230: 6e67 2074 6f20 6669 6c65 206f 7220 7465 ng to file or te\n+0002c240: 726d 696e 616c 0a20 2020 2023 2075 6e61 rminal. # una\n+0002c250: 6666 6563 7465 642e 0a20 2020 2069 6620 ffected.. if \n+0002c260: 6e6f 7420 7374 6174 2e53 5f49 5353 4f43 not stat.S_ISSOC\n+0002c270: 4b28 6f73 2e66 7374 6174 2832 292e 7374 K(os.fstat(2).st\n+0002c280: 5f6d 6f64 6529 3a0a 2020 2020 2020 2020 _mode):. \n+0002c290: 2320 6e6f 7420 6120 736f 636b 6574 3f20 # not a socket? \n+0002c2a0: 2044 6f6e 2774 2072 6564 6972 6563 742e Don't redirect.\n+0002c2b0: 0a20 2020 2020 2020 2072 6574 7572 6e20 . return \n+0002c2c0: 4661 6c73 650a 0a20 2020 2074 7279 3a0a False.. try:.\n+0002c2d0: 2020 2020 2020 2020 696d 706f 7274 2073 import s\n+0002c2e0: 7973 7465 6d64 2e6a 6f75 726e 616c 2020 ystemd.journal \n+0002c2f0: 2320 7479 7065 3a20 6967 6e6f 7265 5b69 # type: ignore[i\n+0002c300: 6d70 6f72 745d 0a20 2020 2065 7863 6570 mport]. excep\n+0002c310: 7420 496d 706f 7274 4572 726f 723a 0a20 t ImportError:. \n+0002c320: 2020 2020 2020 2023 204e 6f20 7079 7468 # No pyth\n+0002c330: 6f6e 332d 7379 7374 656d 643f 2020 446f on3-systemd? Do\n+0002c340: 6e27 7420 7265 6469 7265 6374 2e0a 2020 n't redirect.. \n+0002c350: 2020 2020 2020 7265 7475 726e 2046 616c return Fal\n+0002c360: 7365 0a0a 2020 2020 6c6f 6767 696e 672e se.. logging.\n+0002c370: 726f 6f74 2e61 6464 4861 6e64 6c65 7228 root.addHandler(\n+0002c380: 7379 7374 656d 642e 6a6f 7572 6e61 6c2e systemd.journal.\n+0002c390: 4a6f 7572 6e61 6c48 616e 646c 6572 2829 JournalHandler()\n+0002c3a0: 290a 2020 2020 7265 7475 726e 2054 7275 ). return Tru\n+0002c3b0: 650a 0a0a 6465 6620 7365 7475 705f 6c6f e...def setup_lo\n+0002c3c0: 6767 696e 6728 2a2c 2064 6562 7567 3a20 gging(*, debug: \n+0002c3d0: 626f 6f6c 2920 2d3e 204e 6f6e 653a 0a20 bool) -> None:. \n+0002c3e0: 2020 2022 2222 5365 7475 7020 6f75 7220 \"\"\"Setup our \n+0002c3f0: 6c6f 6767 6572 2077 6974 6820 6f70 7469 logger with opti\n+0002c400: 6f6e 616c 2066 696c 7465 7269 6e67 206f onal filtering o\n+0002c410: 6620 6d6f 6475 6c65 7320 6966 2043 4f43 f modules if COC\n+0002c420: 4b50 4954 5f44 4542 5547 2065 6e76 2069 KPIT_DEBUG env i\n+0002c430: 7320 7365 7422 2222 0a0a 2020 2020 6d6f s set\"\"\".. mo\n+0002c440: 6475 6c65 7320 3d20 6f73 2e67 6574 656e dules = os.geten\n+0002c450: 7628 2743 4f43 4b50 4954 5f44 4542 5547 v('COCKPIT_DEBUG\n+0002c460: 272c 2027 2729 0a0a 2020 2020 2320 4569 ', '').. # Ei\n+0002c470: 7468 6572 2073 6574 7570 206c 6f67 6769 ther setup loggi\n+0002c480: 6e67 2076 6961 206a 6f75 726e 616c 206f ng via journal o\n+0002c490: 7220 7669 6120 666f 726d 6174 7465 6420 r via formatted \n+0002c4a0: 6d65 7373 6167 6573 2074 6f20 7374 6465 messages to stde\n+0002c4b0: 7272 0a20 2020 2069 6620 6e6f 7420 7365 rr. if not se\n+0002c4c0: 7475 705f 6a6f 7572 6e61 6c64 2829 3a0a tup_journald():.\n+0002c4d0: 2020 2020 2020 2020 6c6f 6767 696e 672e logging.\n+0002c4e0: 6261 7369 6343 6f6e 6669 6728 666f 726d basicConfig(form\n+0002c4f0: 6174 3d27 2528 6e61 6d65 2973 2d25 286c at='%(name)s-%(l\n+0002c500: 6576 656c 6e61 6d65 2973 3a20 2528 6d65 evelname)s: %(me\n+0002c510: 7373 6167 6529 7327 290a 0a20 2020 2069 ssage)s').. i\n+0002c520: 6620 6465 6275 6720 6f72 206d 6f64 756c f debug or modul\n+0002c530: 6573 203d 3d20 2761 6c6c 273a 0a20 2020 es == 'all':. \n+0002c540: 2020 2020 206c 6f67 6769 6e67 2e67 6574 logging.get\n+0002c550: 4c6f 6767 6572 2829 2e73 6574 4c65 7665 Logger().setLeve\n+0002c560: 6c28 6c65 7665 6c3d 6c6f 6767 696e 672e l(level=logging.\n+0002c570: 4445 4255 4729 0a20 2020 2065 6c69 6620 DEBUG). elif \n+0002c580: 6d6f 6475 6c65 733a 0a20 2020 2020 2020 modules:. \n+0002c590: 2066 6f72 206d 6f64 756c 6520 696e 206d for module in m\n+0002c5a0: 6f64 756c 6573 2e73 706c 6974 2827 2c27 odules.split(','\n+0002c5b0: 293a 0a20 2020 2020 2020 2020 2020 206d ):. m\n+0002c5c0: 6f64 756c 6520 3d20 6d6f 6475 6c65 2e73 odule = module.s\n+0002c5d0: 7472 6970 2829 0a20 2020 2020 2020 2020 trip(). \n+0002c5e0: 2020 2069 6620 6e6f 7420 6d6f 6475 6c65 if not module\n+0002c5f0: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n+0002c600: 2020 636f 6e74 696e 7565 0a0a 2020 2020 continue.. \n+0002c610: 2020 2020 2020 2020 6c6f 6767 696e 672e logging.\n+0002c620: 6765 744c 6f67 6765 7228 6d6f 6475 6c65 getLogger(module\n+0002c630: 292e 7365 744c 6576 656c 286c 6f67 6769 ).setLevel(loggi\n+0002c640: 6e67 2e44 4542 5547 290a 0a0a 6465 6620 ng.DEBUG)...def \n+0002c650: 7374 6172 745f 7373 685f 6167 656e 7428 start_ssh_agent(\n+0002c660: 2920 2d3e 204e 6f6e 653a 0a20 2020 2023 ) -> None:. #\n+0002c670: 204c 6175 6e63 6820 7468 6520 6167 656e Launch the agen\n+0002c680: 7420 736f 2074 6861 7420 6974 2067 6f65 t so that it goe\n+0002c690: 7320 646f 776e 2077 6974 6820 7573 206f s down with us o\n+0002c6a0: 6e20 454f 463b 2050 4445 4154 4853 4947 n EOF; PDEATHSIG\n+0002c6b0: 2077 6f75 6c64 2062 6520 6d6f 7265 2072 would be more r\n+0002c6c0: 6f62 7573 742c 0a20 2020 2023 2062 7574 obust,. # but\n+0002c6d0: 2069 7420 6765 7473 2063 6c65 6172 6564 it gets cleared\n+0002c6e0: 206f 6e20 7365 7467 6964 2073 7368 2d61 on setgid ssh-a\n+0002c6f0: 6765 6e74 2c20 7768 6963 6820 736f 6d65 gent, which some\n+0002c700: 2064 6973 7472 6f73 2073 7469 6c6c 2064 distros still d\n+0002c710: 6f0a 2020 2020 7472 793a 0a20 2020 2020 o. try:. \n+0002c720: 2020 2070 726f 6320 3d20 7375 6270 726f proc = subpro\n+0002c730: 6365 7373 2e50 6f70 656e 285b 2773 7368 cess.Popen(['ssh\n+0002c740: 2d61 6765 6e74 272c 2027 7368 272c 2027 -agent', 'sh', '\n+0002c750: 2d65 6327 2c20 2765 6368 6f20 5353 485f -ec', 'echo SSH_\n+0002c760: 4155 5448 5f53 4f43 4b3d 2453 5348 5f41 AUTH_SOCK=$SSH_A\n+0002c770: 5554 485f 534f 434b 3b20 7265 6164 2061 UTH_SOCK; read a\n+0002c780: 275d 2c0a 2020 2020 2020 2020 2020 2020 '],. \n+0002c790: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0002c7a0: 2020 2020 7374 6469 6e3d 7375 6270 726f stdin=subpro\n+0002c7b0: 6365 7373 2e50 4950 452c 2073 7464 6f75 cess.PIPE, stdou\n+0002c7c0: 743d 7375 6270 726f 6365 7373 2e50 4950 t=subprocess.PIP\n+0002c7d0: 452c 2075 6e69 7665 7273 616c 5f6e 6577 E, universal_new\n+0002c7e0: 6c69 6e65 733d 5472 7565 290a 2020 2020 lines=True). \n+0002c7f0: 2020 2020 6173 7365 7274 2070 726f 632e assert proc.\n+0002c800: 7374 646f 7574 2069 7320 6e6f 7420 4e6f stdout is not No\n+0002c810: 6e65 0a0a 2020 2020 2020 2020 2320 5761 ne.. # Wa\n+0002c820: 6974 2066 6f72 2074 6865 2061 6765 6e74 it for the agent\n+0002c830: 2074 6f20 7772 6974 6520 6174 206c 6561 to write at lea\n+0002c840: 7374 206f 6e65 206c 696e 6520 616e 6420 st one line and \n+0002c850: 6c6f 6f6b 2066 6f72 2074 6865 0a20 2020 look for the. \n+0002c860: 2020 2020 2023 206c 6973 7465 6e65 7220 # listener \n+0002c870: 736f 636b 6574 2e20 2049 6620 7765 2066 socket. If we f\n+0002c880: 6169 6c20 746f 2066 696e 6420 6974 2c20 ail to find it, \n+0002c890: 6b69 6c6c 2074 6865 2061 6765 6e74 20e2 kill the agent .\n+0002c8a0: 8094 2073 6f6d 6574 6869 6e67 0a20 2020 .. something. \n+0002c8b0: 2020 2020 2023 2077 656e 7420 7772 6f6e # went wron\n+0002c8c0: 672e 0a20 2020 2020 2020 2066 6f72 2074 g.. for t\n+0002c8d0: 6f6b 656e 2069 6e20 7368 6c65 782e 7368 oken in shlex.sh\n+0002c8e0: 6c65 7828 7072 6f63 2e73 7464 6f75 742e lex(proc.stdout.\n+0002c8f0: 7265 6164 6c69 6e65 2829 2c20 7075 6e63 readline(), punc\n+0002c900: 7475 6174 696f 6e5f 6368 6172 733d 5472 tuation_chars=Tr\n+0002c910: 7565 293a 0a20 2020 2020 2020 2020 2020 ue):. \n+0002c920: 2069 6620 746f 6b65 6e2e 7374 6172 7473 if token.starts\n+0002c930: 7769 7468 2827 5353 485f 4155 5448 5f53 with('SSH_AUTH_S\n+0002c940: 4f43 4b3d 2729 3a0a 2020 2020 2020 2020 OCK='):. \n+0002c950: 2020 2020 2020 2020 6f73 2e65 6e76 6972 os.envir\n+0002c960: 6f6e 5b27 5353 485f 4155 5448 5f53 4f43 on['SSH_AUTH_SOC\n+0002c970: 4b27 5d20 3d20 746f 6b65 6e2e 7265 706c K'] = token.repl\n+0002c980: 6163 6528 2753 5348 5f41 5554 485f 534f ace('SSH_AUTH_SO\n+0002c990: 434b 3d27 2c20 2727 2c20 3129 0a20 2020 CK=', '', 1). \n+0002c9a0: 2020 2020 2020 2020 2020 2020 2062 7265 bre\n+0002c9b0: 616b 0a20 2020 2020 2020 2065 6c73 653a ak. else:\n+0002c9c0: 0a20 2020 2020 2020 2020 2020 2070 726f . pro\n+0002c9d0: 632e 7465 726d 696e 6174 6528 290a 2020 c.terminate(). \n+0002c9e0: 2020 2020 2020 2020 2020 7072 6f63 2e77 proc.w\n+0002c9f0: 6169 7428 290a 0a20 2020 2065 7863 6570 ait().. excep\n+0002ca00: 7420 4669 6c65 4e6f 7446 6f75 6e64 4572 t FileNotFoundEr\n+0002ca10: 726f 723a 0a20 2020 2020 2020 206c 6f67 ror:. log\n+0002ca20: 6765 722e 6465 6275 6728 2243 6f75 6c64 ger.debug(\"Could\n+0002ca30: 6e27 7420 7374 6172 7420 7373 682d 6167 n't start ssh-ag\n+0002ca40: 656e 7420 2846 696c 654e 6f74 466f 756e ent (FileNotFoun\n+0002ca50: 6445 7272 6f72 2922 290a 0a20 2020 2065 dError)\").. e\n+0002ca60: 7863 6570 7420 4f53 4572 726f 7220 6173 xcept OSError as\n+0002ca70: 2065 7863 3a0a 2020 2020 2020 2020 6c6f exc:. lo\n+0002ca80: 6767 6572 2e77 6172 6e69 6e67 2822 436f gger.warning(\"Co\n+0002ca90: 756c 6420 6e6f 7420 7374 6172 7420 7373 uld not start ss\n+0002caa0: 682d 6167 656e 743a 2025 7322 2c20 6578 h-agent: %s\", ex\n+0002cab0: 6329 0a0a 0a64 6566 206d 6169 6e28 2a2c c)...def main(*,\n+0002cac0: 2062 6569 7061 636b 3a20 626f 6f6c 203d beipack: bool =\n+0002cad0: 2046 616c 7365 2920 2d3e 204e 6f6e 653a False) -> None:\n+0002cae0: 0a20 2020 2070 6f6c 7966 696c 6c73 2e69 . polyfills.i\n+0002caf0: 6e73 7461 6c6c 2829 0a0a 2020 2020 7061 nstall().. pa\n+0002cb00: 7273 6572 203d 2061 7267 7061 7273 652e rser = argparse.\n+0002cb10: 4172 6775 6d65 6e74 5061 7273 6572 2864 ArgumentParser(d\n+0002cb20: 6573 6372 6970 7469 6f6e 3d27 636f 636b escription='cock\n+0002cb30: 7069 742d 6272 6964 6765 2069 7320 7275 pit-bridge is ru\n+0002cb40: 6e20 6175 746f 6d61 7469 6361 6c6c 7920 n automatically \n+0002cb50: 696e 7369 6465 206f 6620 6120 436f 636b inside of a Cock\n+0002cb60: 7069 7420 7365 7373 696f 6e2e 2729 0a20 pit session.'). \n+0002cb70: 2020 2070 6172 7365 722e 6164 645f 6172 parser.add_ar\n+0002cb80: 6775 6d65 6e74 2827 2d2d 7072 6976 696c gument('--privil\n+0002cb90: 6567 6564 272c 2061 6374 696f 6e3d 2773 eged', action='s\n+0002cba0: 746f 7265 5f74 7275 6527 2c20 6865 6c70 tore_true', help\n+0002cbb0: 3d27 5072 6976 696c 6567 6564 2063 6f70 ='Privileged cop\n+0002cbc0: 7920 6f66 2074 6865 2062 7269 6467 6527 y of the bridge'\n+0002cbd0: 290a 2020 2020 7061 7273 6572 2e61 6464 ). parser.add\n+0002cbe0: 5f61 7267 756d 656e 7428 272d 2d70 6163 _argument('--pac\n+0002cbf0: 6b61 6765 7327 2c20 6163 7469 6f6e 3d27 kages', action='\n+0002cc00: 7374 6f72 655f 7472 7565 272c 2068 656c store_true', hel\n+0002cc10: 703d 2753 686f 7720 436f 636b 7069 7420 p='Show Cockpit \n+0002cc20: 7061 636b 6167 6520 696e 666f 726d 6174 package informat\n+0002cc30: 696f 6e27 290a 2020 2020 7061 7273 6572 ion'). parser\n+0002cc40: 2e61 6464 5f61 7267 756d 656e 7428 272d .add_argument('-\n+0002cc50: 2d62 7269 6467 6573 272c 2061 6374 696f -bridges', actio\n+0002cc60: 6e3d 2773 746f 7265 5f74 7275 6527 2c20 n='store_true', \n+0002cc70: 6865 6c70 3d27 5368 6f77 2043 6f63 6b70 help='Show Cockp\n+0002cc80: 6974 2062 7269 6467 6573 2069 6e66 6f72 it bridges infor\n+0002cc90: 6d61 7469 6f6e 2729 0a20 2020 2070 6172 mation'). par\n+0002cca0: 7365 722e 6164 645f 6172 6775 6d65 6e74 ser.add_argument\n+0002ccb0: 2827 2d2d 6465 6275 6727 2c20 6163 7469 ('--debug', acti\n+0002ccc0: 6f6e 3d27 7374 6f72 655f 7472 7565 272c on='store_true',\n+0002ccd0: 2068 656c 703d 2745 6e61 626c 6520 6465 help='Enable de\n+0002cce0: 6275 6720 6f75 7470 7574 2028 7665 7279 bug output (very\n+0002ccf0: 2076 6572 626f 7365 2927 290a 2020 2020 verbose)'). \n+0002cd00: 7061 7273 6572 2e61 6464 5f61 7267 756d parser.add_argum\n+0002cd10: 656e 7428 272d 2d76 6572 7369 6f6e 272c ent('--version',\n+0002cd20: 2061 6374 696f 6e3d 2773 746f 7265 5f74 action='store_t\n+0002cd30: 7275 6527 2c20 6865 6c70 3d27 5368 6f77 rue', help='Show\n+0002cd40: 2043 6f63 6b70 6974 2076 6572 7369 6f6e Cockpit version\n+0002cd50: 2069 6e66 6f72 6d61 7469 6f6e 2729 0a20 information'). \n+0002cd60: 2020 2061 7267 7320 3d20 7061 7273 6572 args = parser\n+0002cd70: 2e70 6172 7365 5f61 7267 7328 290a 0a20 .parse_args().. \n+0002cd80: 2020 2023 2054 6869 7320 6973 2064 6574 # This is det\n+0002cd90: 6572 6d69 6e65 6420 6279 2077 686f 2063 ermined by who c\n+0002cda0: 616c 6c73 2075 730a 2020 2020 6172 6773 alls us. args\n+0002cdb0: 2e62 6569 7061 636b 203d 2062 6569 7061 .beipack = beipa\n+0002cdc0: 636b 0a0a 2020 2020 2320 4966 2077 6520 ck.. # If we \n+0002cdd0: 7765 7265 2072 756e 2077 6974 6820 2d2d were run with --\n+0002cde0: 7072 6976 696c 6567 6564 2074 6865 6e20 privileged then \n+0002cdf0: 6f75 7220 7374 6465 7272 2069 7320 6375 our stderr is cu\n+0002ce00: 7272 656e 746c 7920 6265 696e 670a 2020 rrently being. \n+0002ce10: 2020 2320 636f 6e73 756d 6564 2062 7920 # consumed by \n+0002ce20: 7468 6520 6d61 696e 2062 7269 6467 6520 the main bridge \n+0002ce30: 6c6f 6f6b 696e 6720 666f 7220 7374 6172 looking for star\n+0002ce40: 7475 702d 7265 6c61 7465 6420 6572 726f tup-related erro\n+0002ce50: 7220 6d65 7373 6167 6573 2e0a 2020 2020 r messages.. \n+0002ce60: 2320 4c65 7427 7320 7377 6974 6368 2062 # Let's switch b\n+0002ce70: 6163 6b20 746f 2074 6865 206f 7269 6769 ack to the origi\n+0002ce80: 6e61 6c20 7374 6465 7272 2073 7472 6561 nal stderr strea\n+0002ce90: 6d2c 2077 6869 6368 2068 6173 2061 2073 m, which has a s\n+0002cea0: 6964 652d 6566 6665 6374 0a20 2020 2023 ide-effect. #\n+0002ceb0: 206f 6620 696e 6469 6361 7469 6e67 2074 of indicating t\n+0002cec0: 6861 7420 6f75 7220 7374 6172 7475 7020 hat our startup \n+0002ced0: 6973 206d 6f72 6520 6f72 206c 6573 7320 is more or less \n+0002cee0: 636f 6d70 6c65 7465 2e20 2041 6e79 2065 complete. Any e\n+0002cef0: 7272 6f72 730a 2020 2020 2320 6166 7465 rrors. # afte\n+0002cf00: 7220 7468 6973 2070 6f69 6e74 2077 696c r this point wil\n+0002cf10: 6c20 6c61 6e64 2069 6e20 7468 6520 6a6f l land in the jo\n+0002cf20: 7572 6e61 6c2e 0a20 2020 2069 6620 6172 urnal.. if ar\n+0002cf30: 6773 2e70 7269 7669 6c65 6765 643a 0a20 gs.privileged:. \n+0002cf40: 2020 2020 2020 2074 7279 5f74 6f5f 7265 try_to_re\n+0002cf50: 6365 6976 655f 7374 6465 7272 2829 0a0a ceive_stderr()..\n+0002cf60: 2020 2020 7365 7475 705f 6c6f 6767 696e setup_loggin\n+0002cf70: 6728 6465 6275 673d 6172 6773 2e64 6562 g(debug=args.deb\n+0002cf80: 7567 290a 0a20 2020 2023 2053 7065 6369 ug).. # Speci\n+0002cf90: 616c 206d 6f64 6573 0a20 2020 2069 6620 al modes. if \n+0002cfa0: 6172 6773 2e70 6163 6b61 6765 733a 0a20 args.packages:. \n+0002cfb0: 2020 2020 2020 2050 6163 6b61 6765 7328 Packages(\n+0002cfc0: 292e 7368 6f77 2829 0a20 2020 2020 2020 ).show(). \n+0002cfd0: 2072 6574 7572 6e0a 2020 2020 656c 6966 return. elif\n+0002cfe0: 2061 7267 732e 7665 7273 696f 6e3a 0a20 args.version:. \n+0002cff0: 2020 2020 2020 2070 7269 6e74 2866 2756 print(f'V\n+0002d000: 6572 7369 6f6e 3a20 7b5f 5f76 6572 7369 ersion: {__versi\n+0002d010: 6f6e 5f5f 7d5c 6e50 726f 746f 636f 6c3a on__}\\nProtocol:\n+0002d020: 2031 2729 0a20 2020 2020 2020 2072 6574 1'). ret\n+0002d030: 7572 6e0a 2020 2020 656c 6966 2061 7267 urn. elif arg\n+0002d040: 732e 6272 6964 6765 733a 0a20 2020 2020 s.bridges:. \n+0002d050: 2020 2070 7269 6e74 286a 736f 6e2e 6475 print(json.du\n+0002d060: 6d70 7328 5b63 6f6e 6669 672e 5f5f 6469 mps([config.__di\n+0002d070: 6374 5f5f 2066 6f72 2063 6f6e 6669 6720 ct__ for config \n+0002d080: 696e 2050 6163 6b61 6765 7328 292e 6765 in Packages().ge\n+0002d090: 745f 6272 6964 6765 5f63 6f6e 6669 6773 t_bridge_configs\n+0002d0a0: 2829 5d2c 2069 6e64 656e 743d 3229 290a ()], indent=2)).\n+0002d0b0: 2020 2020 2020 2020 7265 7475 726e 0a0a return..\n+0002d0c0: 2020 2020 2320 5468 6520 7072 6976 696c # The privil\n+0002d0d0: 6567 6564 2062 7269 6467 6520 646f 6573 eged bridge does\n+0002d0e0: 6e27 7420 6e65 6564 2073 7368 2d61 6765 n't need ssh-age\n+0002d0f0: 6e74 2c20 6275 7420 7468 6520 6d61 696e nt, but the main\n+0002d100: 206f 6e65 2064 6f65 730a 2020 2020 6966 one does. if\n+0002d110: 2027 5353 485f 4155 5448 5f53 4f43 4b27 'SSH_AUTH_SOCK'\n+0002d120: 206e 6f74 2069 6e20 6f73 2e65 6e76 6972 not in os.envir\n+0002d130: 6f6e 2061 6e64 206e 6f74 2061 7267 732e on and not args.\n+0002d140: 7072 6976 696c 6567 6564 3a0a 2020 2020 privileged:. \n+0002d150: 2020 2020 7374 6172 745f 7373 685f 6167 start_ssh_ag\n+0002d160: 656e 7428 290a 0a20 2020 2023 2061 7379 ent().. # asy\n+0002d170: 6e63 696f 2e72 756e 2829 2073 6869 6d20 ncio.run() shim \n+0002d180: 666f 7220 5079 7468 6f6e 2033 2e36 2073 for Python 3.6 s\n+0002d190: 7570 706f 7274 0a20 2020 2072 756e 5f61 upport. run_a\n+0002d1a0: 7379 6e63 2872 756e 2861 7267 7329 2c20 sync(run(args), \n+0002d1b0: 6465 6275 673d 6172 6773 2e64 6562 7567 debug=args.debug\n+0002d1c0: 290a 0a0a 6966 205f 5f6e 616d 655f 5f20 )...if __name__ \n+0002d1d0: 3d3d 2027 5f5f 6d61 696e 5f5f 273a 0a20 == '__main__':. \n+0002d1e0: 2020 206d 6169 6e28 290a 2727 272e 656e main().'''.en\n+0002d1f0: 636f 6465 2827 7574 662d 3827 292c 0a20 code('utf-8'),. \n+0002d200: 2027 636f 636b 7069 742f 6461 7461 2f5f 'cockpit/data/_\n+0002d210: 5f69 6e69 745f 5f2e 7079 273a 2062 7227 _init__.py': br'\n+0002d220: 2727 696d 706f 7274 2073 7973 0a0a 6966 ''import sys..if\n+0002d230: 2073 7973 2e76 6572 7369 6f6e 5f69 6e66 sys.version_inf\n+0002d240: 6f20 3e3d 2028 332c 2031 3129 3a0a 2020 o >= (3, 11):. \n+0002d250: 2020 696d 706f 7274 2069 6d70 6f72 746c import importl\n+0002d260: 6962 2e72 6573 6f75 7263 6573 0a0a 2020 ib.resources.. \n+0002d270: 2020 6465 6620 7265 6164 5f63 6f63 6b70 def read_cockp\n+0002d280: 6974 5f64 6174 615f 6669 6c65 2866 696c it_data_file(fil\n+0002d290: 656e 616d 653a 2073 7472 2920 2d3e 2062 ename: str) -> b\n+0002d2a0: 7974 6573 3a0a 2020 2020 2020 2020 7265 ytes:. re\n+0002d2b0: 7475 726e 2028 696d 706f 7274 6c69 622e turn (importlib.\n+0002d2c0: 7265 736f 7572 6365 732e 6669 6c65 7328 resources.files(\n+0002d2d0: 2763 6f63 6b70 6974 2e64 6174 6127 2920 'cockpit.data') \n+0002d2e0: 2f20 6669 6c65 6e61 6d65 292e 7265 6164 / filename).read\n+0002d2f0: 5f62 7974 6573 2829 0a0a 656c 7365 3a0a _bytes()..else:.\n+0002d300: 2020 2020 696d 706f 7274 2069 6d70 6f72 import impor\n+0002d310: 746c 6962 2e61 6263 0a0a 2020 2020 6465 tlib.abc.. de\n+0002d320: 6620 7265 6164 5f63 6f63 6b70 6974 5f64 f read_cockpit_d\n+0002d330: 6174 615f 6669 6c65 2866 696c 656e 616d ata_file(filenam\n+0002d340: 653a 2073 7472 2920 2d3e 2062 7974 6573 e: str) -> bytes\n+0002d350: 3a0a 2020 2020 2020 2020 2320 6874 7470 :. # http\n+0002d360: 733a 2f2f 6769 7468 7562 2e63 6f6d 2f70 s://github.com/p\n+0002d370: 7974 686f 6e2f 6d79 7079 2f69 7373 7565 ython/mypy/issue\n+0002d380: 732f 3431 3832 0a20 2020 2020 2020 206c s/4182. l\n+0002d390: 6f61 6465 7220 3d20 5f5f 6c6f 6164 6572 oader = __loader\n+0002d3a0: 5f5f 2020 2320 7479 7065 3a20 6967 6e6f __ # type: igno\n+0002d3b0: 7265 5b6e 616d 652d 6465 6669 6e65 645d re[name-defined]\n+0002d3c0: 0a20 2020 2020 2020 2061 7373 6572 7420 . assert \n+0002d3d0: 6973 696e 7374 616e 6365 286c 6f61 6465 isinstance(loade\n+0002d3e0: 722c 2069 6d70 6f72 746c 6962 2e61 6263 r, importlib.abc\n+0002d3f0: 2e52 6573 6f75 7263 654c 6f61 6465 7229 .ResourceLoader)\n+0002d400: 0a0a 2020 2020 2020 2020 7061 7468 203d .. path =\n+0002d410: 205f 5f66 696c 655f 5f2e 7265 706c 6163 __file__.replac\n+0002d420: 6528 275f 5f69 6e69 745f 5f2e 7079 272c e('__init__.py',\n+0002d430: 2066 696c 656e 616d 6529 0a20 2020 2020 filename). \n+0002d440: 2020 2072 6574 7572 6e20 6c6f 6164 6572 return loader\n+0002d450: 2e67 6574 5f64 6174 6128 7061 7468 290a .get_data(path).\n+0002d460: 2727 272c 0a20 2027 636f 636b 7069 742f ''',. 'cockpit/\n+0002d470: 6461 7461 2f66 6169 6c2e 6874 6d6c 273a data/fail.html':\n+0002d480: 2062 7227 2727 3c21 444f 4354 5950 4520 br'''... @\n+0002d4b0: 406d 6573 7361 6765 4040 3c2f 7469 746c @message@@</titl\n+0002d4c0: 653e 0a20 2020 203c 6d65 7461 2068 7474 e>. <meta htt\n+0002d4d0: 702d 6571 7569 763d 2243 6f6e 7465 6e74 p-equiv=\"Content\n+0002d4e0: 2d54 7970 6522 2063 6f6e 7465 6e74 3d22 -Type\" content=\"\n+0002d4f0: 7465 7874 2f68 746d 6c3b 2063 6861 7273 text/html; chars\n+0002d500: 6574 3d75 7466 2d38 223e 0a20 2020 203c et=utf-8\">. <\n+0002d510: 6d65 7461 206e 616d 653d 2276 6965 7770 meta name=\"viewp\n+0002d520: 6f72 7422 2063 6f6e 7465 6e74 3d22 7769 ort\" content=\"wi\n+0002d530: 6474 683d 6465 7669 6365 2d77 6964 7468 dth=device-width\n+0002d540: 2c20 696e 6974 6961 6c2d 7363 616c 653d , initial-scale=\n+0002d550: 312e 3022 3e0a 2020 2020 3c73 7479 6c65 1.0\">. <style\n+0002d560: 3e0a 0962 6f64 7920 7b0a 2020 2020 2020 >..body {. \n+0002d570: 2020 2020 2020 6d61 7267 696e 3a20 303b margin: 0;\n+0002d580: 0a20 2020 2020 2020 2020 2020 2066 6f6e . fon\n+0002d590: 742d 6661 6d69 6c79 3a20 2252 6564 4861 t-family: \"RedHa\n+0002d5a0: 7444 6973 706c 6179 222c 2022 4f70 656e tDisplay\", \"Open\n+0002d5b0: 2053 616e 7322 2c20 4865 6c76 6574 6963 Sans\", Helvetic\n+0002d5c0: 612c 2041 7269 616c 2c20 7361 6e73 2d73 a, Arial, sans-s\n+0002d5d0: 6572 6966 3b0a 2020 2020 2020 2020 2020 erif;. \n+0002d5e0: 2020 666f 6e74 2d73 697a 653a 2031 3270 font-size: 12p\n+0002d5f0: 783b 0a20 2020 2020 2020 2020 2020 206c x;. l\n+0002d600: 696e 652d 6865 6967 6874 3a20 312e 3636 ine-height: 1.66\n+0002d610: 3636 3636 3637 3b0a 2020 2020 2020 2020 666667;. \n+0002d620: 2020 2020 636f 6c6f 723a 2023 3333 3333 color: #3333\n+0002d630: 3333 3b0a 2020 2020 2020 2020 2020 2020 33;. \n+0002d640: 6261 636b 6772 6f75 6e64 2d63 6f6c 6f72 background-color\n+0002d650: 3a20 2366 3566 3566 353b 0a20 2020 2020 : #f5f5f5;. \n+0002d660: 2020 207d 0a20 2020 2020 2020 2069 6d67 }. img\n+0002d670: 207b 0a20 2020 2020 2020 2020 2020 2062 {. b\n+0002d680: 6f72 6465 723a 2030 3b0a 2020 2020 2020 order: 0;. \n+0002d690: 2020 2020 2020 7665 7274 6963 616c 2d61 vertical-a\n+0002d6a0: 6c69 676e 3a20 6d69 6464 6c65 3b0a 2020 lign: middle;. \n+0002d6b0: 2020 2020 2020 7d0a 2020 2020 2020 2020 }. \n+0002d6c0: 6831 207b 0a20 2020 2020 2020 2020 2020 h1 {. \n+0002d6d0: 2066 6f6e 742d 7765 6967 6874 3a20 3330 font-weight: 30\n+0002d6e0: 303b 0a20 2020 2020 2020 207d 0a20 2020 0;. }. \n+0002d6f0: 2020 2020 2070 207b 0a20 2020 2020 2020 p {. \n+0002d700: 2020 2020 206d 6172 6769 6e3a 2030 2030 margin: 0 0\n+0002d710: 2031 3070 783b 0a20 2020 2020 2020 207d 10px;. }\n+0002d720: 0a20 2020 2020 2020 2040 666f 6e74 2d66 . @font-f\n+0002d730: 6163 6520 7b0a 2020 2020 2020 2020 2020 ace {. \n+0002d740: 2020 666f 6e74 2d66 616d 696c 793a 2027 font-family: '\n+0002d750: 5265 6448 6174 4469 7370 6c61 7927 3b0a RedHatDisplay';.\n+0002d760: 2020 2020 2020 2020 2020 2020 666f 6e74 font\n+0002d770: 2d73 7479 6c65 3a20 6e6f 726d 616c 3b0a -style: normal;.\n+0002d780: 2020 2020 2020 2020 2020 2020 666f 6e74 font\n+0002d790: 2d77 6569 6768 743a 2033 3030 3b0a 2020 -weight: 300;. \n+0002d7a0: 2020 2020 2020 2020 2020 7372 633a 2075 src: u\n+0002d7b0: 726c 2827 2f63 6f63 6b70 6974 2f73 7461 rl('/cockpit/sta\n+0002d7c0: 7469 632f 666f 6e74 732f 5265 6448 6174 tic/fonts/RedHat\n+0002d7d0: 4469 7370 6c61 792d 4d65 6469 756d 2e77 Display-Medium.w\n+0002d7e0: 6f66 6632 2729 2066 6f72 6d61 7428 2777 off2') format('w\n+0002d7f0: 6f66 6632 2729 3b0a 2020 2020 2020 2020 off2');. \n+0002d800: 7d0a 2020 2020 2020 2020 2e62 6c61 6e6b }. .blank\n+0002d810: 2d73 6c61 7465 2d70 6620 7b0a 2020 2020 -slate-pf {. \n+0002d820: 2020 2020 2020 2020 7465 7874 2d61 6c69 text-ali\n+0002d830: 676e 3a20 6365 6e74 6572 3b0a 2020 2020 gn: center;. \n+0002d840: 2020 2020 2020 2020 7061 6464 696e 673a padding:\n+0002d850: 2039 3070 7820 3132 3070 783b 0a20 2020 90px 120px;. \n+0002d860: 2020 2020 207d 0a20 2020 203c 2f73 7479 }. </sty\n+0002d870: 6c65 3e0a 3c2f 6865 6164 3e0a 3c62 6f64 le>.</head>.<bod\n+0002d880: 793e 0a20 2020 203c 6469 7620 636c 6173 y>. <div clas\n+0002d890: 733d 2262 6c61 6e6b 2d73 6c61 7465 2d70 s=\"blank-slate-p\n+0002d8a0: 6622 3e0a 2020 2020 2020 2020 3c69 6d67 f\">. <img\n+0002d8b0: 2073 7263 3d22 6461 7461 3a69 6d61 6765 src=\"data:image\n+0002d8c0: 2f70 6e67 3b62 6173 6536 342c 6956 424f /png;base64,iVBO\n+0002d8d0: 5277 304b 4767 6f41 4141 414e 5355 6845 Rw0KGgoAAAANSUhE\n+0002d8e0: 5567 4141 4144 7741 4141 4138 4341 5941 UgAAADwAAAA8CAYA\n+0002d8f0: 4141 4136 2f4e 6c79 4141 4141 4248 4e43 AAA6/NlyAAAABHNC\n+0002d900: 5356 5149 4341 6749 6641 686b 6941 4141 SVQICAgIfAhkiAAA\n+0002d910: 4141 6c77 5346 6c7a 4141 414e 3177 4141 AAlwSFlzAAAN1wAA\n+0002d920: 4464 6342 5169 6962 6541 4141 4142 6c30 DdcBQiibeAAAABl0\n+0002d930: 5256 6830 5532 396d 6448 6468 636d 5541 RVh0U29mdHdhcmUA\n+0002d940: 6433 6433 4c6d 6c75 6133 4e6a 5958 426c d3d3Lmlua3NjYXBl\n+0002d950: 4c6d 3979 5a35 7675 5042 6f41 4141 5747 Lm9yZ5vuPBoAAAWG\n+0002d960: 5355 5242 5647 6942 7a5a 744e 614a 7846 SURBVGiBzZtNaJxF\n+0002d970: 474d 642f 7a32 5233 5978 4862 745a 6132 GMd/z2R3YxHbtZa2\n+0002d980: 7071 6463 5049 6e53 3943 4355 6f76 3351 pqdcPInS9CCUov3Q\n+0002d990: 6975 6846 3268 4955 6a4f 5a72 6435 4e41 iuhF2hIUjOZrd5NA\n+0002d9a0: 3956 6f50 7569 4a53 5478 3653 3073 3237 9VoPuiJSTx6S0s27\n+0002d9b0: 5356 784a 3861 4f70 5053 6771 7062 5a56 SVxJ8aOpPSgqpbZV\n+0002d9c0: 6c49 4949 4a69 7271 7452 644e 7042 5533 lIIIJirqtRdNpBU3\n+0002d9d0: 4655 7168 6d35 3348 517a 5a70 506a 6676 FUqhm53HQzZpPjfv\n+0002d9e0: 6d35 314a 386f 6546 5a64 356e 3576 2f38 m51J8oeFZd5n5v/8\n+0002d9f0: 6557 6265 6d58 666d 4763 4554 4267 6348 eWbemXfmGcETBgcH\n+0002da00: 7431 7072 6d31 5331 4357 6753 6b55 5a56 t1prm1S1CWgSkUZV\n+0002da10: 3351 496b 6753 3056 7335 7641 5a4f 5633 3QIkgS0Vs5vAZOV3\n+0002da20: 4452 6856 3156 4672 3757 6833 6433 6652 DRhV1VFr7Wh3d3fR\n+0002da30: 6831 2f69 7372 4663 4c72 6572 7271 3775 h1/isrFcLrerrq7u\n+0002da40: 4b48 424d 5666 6657 3250 3466 716a 6f63 KHBMVffW2P4fqjoc\n+0002da50: 6a38 6650 744c 6533 6a7a 7479 3059 3367 j8fPtLe3jzty0Y3g\n+0002da60: 6644 372f 704c 5832 6849 6a73 4234 794c fD7/pLX2hIjsB4yL\n+0002da70: 4e75 6641 416c 6573 7465 3930 6458 5639 NufAAleste90dXV9\n+0002da80: 5732 746a 4e51 6b4f 676d 4366 7172 346c W2tjNQkOgmCfqr4l\n+0002da90: 4967 6472 6453 514d 524f 5371 7466 624e IgdrdSQMROSqtfbN\n+0002daa0: 5443 5a7a 6564 5674 724b 6253 774d 4441 TCZzedVtrKbSwMDA\n+0002dab0: 6a6e 4b35 6e42 4f52 3531 644c 5841 7455 jnK5nBOR51dLXAtU\n+0002dac0: 3959 7434 504a 3565 5456 6550 4c44 6749 9Yt4PJ5eTVePLDgI\n+0002dad0: 676d 5041 6157 4262 314c 714f 5552 5352 gmPAaWBb1LqOURSR\n+0002dae0: 5631 4f70 314a 6b6f 6c55 494c 4868 6b5a V1Op1JkolUILHhkZ\n+0002daf0: 5352 534c 7855 4867 7063 6975 2b63 5837 SRSLxUHgpciu+cX7\n+0002db00: 5143 6164 5470 6643 4749 6353 5044 5130 QCadTpfCGIcSPDQ0\n+0002db10: 6446 2b70 5644 6f6e 496b 2f58 354a 6f2f dF+pVDonIk/X5Jo/\n+0002db20: 5841 614f 704e 5070 6d79 735a 7269 6734 XAaOpNPpmysZrig4\n+0002db30: 6c38 7674 4d73 5a63 4142 3532 345a 6c48 l8vtMsZcAB524ZlH\n+0002db40: 2f41 4938 6b30 366e 4a36 6f5a 565a 3143 /AI8k06nJ6oZVZ1C\n+0002db50: 656e 7437 4e78 746a 766d 546a 6977 5634 ent7NxtjvmTjiwV4\n+0002db60: 464c 6859 4b42 5353 3159 7957 6a58 426c FLhYKBSS1YyWjXBl\n+0002db70: 7a48 3446 484b 7252 6b59 3832 6264 7155 zH4FHKrRkY82bdqU\n+0002db80: 616d 6c70 7556 584e 6148 6834 2b4e 3762 amlpuVXNaHh4+N7b\n+0002db90: 7432 2f6e 6752 6472 354c 7349 504c 6663 t2/ngRdr5LsIPLfc\n+0002dba0: 6d46 3432 7773 5669 735a 2f61 7861 4b71 mF42wsVisZ/axaKq\n+0002dbb0: 5631 5953 4339 4453 306e 4a4c 5661 2f55 V1YSC9DS0nJLVa/U\n+0002dbc0: 7967 6363 5a6e 6f57 5752 4a4c 4375 3776 ygccZnoWWRJLCu7v\n+0002dbd0: 3732 3847 5768 3251 4979 4b4a 434c 6233 728GWh2QIyKJCLb3\n+0002dbe0: 754f 4145 4f69 7254 3579 4973 4568 7745 uOAEOirT5yIsEhwE\n+0002dbf0: 7754 5952 3658 5645 4446 4166 7764 6156 wTYR6XVEDFAfwdaV\n+0002dc00: 5949 4454 4177 4d44 4f78 5957 4c68 4973 YIDTAwMDOxYWLhIs\n+0002dc10: 496a 6c67 7530 5069 3043 4b69 3949 5951 Ijlgu0Pi0CKi9IYQ\n+0002dc20: 3247 6174 3756 7459 4f45 3977 5a57 3138 2Gat7VtYOE9wZW18\n+0002dc30: 3143 4670 4a42 4857 5770 6352 426a 6957 1CFpJBHWWpcRBjiW\n+0002dc40: 7a2b 6566 6d46 7377 5437 4349 764f 3259 z+efmFswT7CIvO2Y\n+0002dc50: 4546 554e 3361 574e 4d56 4736 6679 6859 EFUN3aWNMVG6fyhY\n+0002dc60: 6139 2b59 787a 487a 4a77 6943 4136 7136 a9+YxzHzJwiCA6q6\n+0002dc70: 337a 5568 4563 6177 6877 676a 4967 666e 3zUhEcawhwgjIgfn\n+0002dc80: 526e 6c75 6846 3933 5456 5a42 6142 452b RnluhF93TVZBaBE+\n+0002dc90: 4967 7867 7254 3078 7977 4551 424d 4744 IgxgrT0xywEQBMGD\n+0002dca0: 7741 4566 5a4b 7136 6e6d 4d59 4142 4635 wAEfZKq6nmMYABF5\n+0002dcb0: 616d 686f 7141 4875 5272 675a 7150 4e42 amhoqAHuRrgZqPNB\n+0002dcc0: 4669 5671 7669 494d 6d46 4b70 6441 5171 FiVqviIMmFKpdAQq\n+0002dcd0: 676c 5731 3252 4e52 704a 6557 7277 6744 glW12RNRpJeWrwgD\n+0002dce0: 4747 4f61 4163 7a67 344f 4257 4558 6e4d GGOaAczg4OBWEXnM\n+0002dcf0: 4631 4755 315a 5048 434b 4f71 6577 7546 F1GU1ZPHCKOqewuF\n+0002dd00: 5174 4a59 6135 7477 7648 7535 6743 6a30 QtJYa5twvHu5gCj0\n+0002dd10: 4749 3753 4731 5942 7558 506e 7a6d 356a GI7SG1YBuXPnzm5j\n+0002dd20: 7264 336a 6b53 5353 4349 6472 3665 5861 rd3jkSSSCIdr6eXa\n+0002dd30: 3332 4e45 5a4c 646e 6b74 4169 5045 6359 32NEZLdnktAiPEcY\n+0002dd40: 5664 3174 524b 5452 4a77 6e72 392f 4777 Vd1tRKTRJwnr9/Gw\n+0002dd50: 4642 714e 716c 6264 4958 4341 4b49 4b39 FBqNqlbdIXCAKIK9\n+0002dd60: 5268 6934 337a 4239 3175 4d54 4779 6e43 Rhi43zB91uMTGynC\n+0002dd70: 5363 5064 6779 3166 3248 4152 5673 386b ScPdgy1f2HARVs8k\n+0002dd80: 4730 6d77 4e55 7766 5666 7245 5275 7253 G0mwNUwfVfrERurS\n+0002dd90: 6b34 6270 4d31 7166 4343 5659 5651 5677 k4bpM1qfCCVYVQVw\n+0002dda0: 7565 4f78 4643 5933 5449 5437 2b76 6f53 ueOxFCY3TIT7+voS\n+0002ddb0: 6546 7a78 5656 4130 544a 2b38 2b34 544a eFzxVVA0TJ+8+4TJ\n+0002ddc0: 5a72 4f78 4548 612b 7879 2b71 6573 3041 ZrOxEHa+xy+qes0A\n+0002ddd0: 6f37 364a 6475 3763 7565 4c69 4a70 4649 o76Jdu7cueLiJpFI\n+0002dde0: 504f 5462 4478 455a 6936 6e71 7149 6a66 POTbDxEZi6nqqIjf\n+0002ddf0: 6e69 5169 502b 627a 2b5a 3956 6457 6f5a niQiP+bz+Z9VdWoZ\n+0002de00: 6b7a 6a51 354e 574a 6159 7a47 5972 4859 kzjQ5NWJaYzGYrHY\n+0002de10: 574c 6c63 5676 794f 6e36 536e 2f62 496f WLlcVvyOn6Sn/bIo\n+0002de20: 3045 5169 4d57 5936 4f6a 722b 4258 3559 0EQiMWY6Ojr+BX5Y\n+0002de30: 5a32 6657 416c 6462 5731 736e 4459 4349 Z2fWAldbW1snDYCI\n+0002de40: 6e46 3176 6239 5941 5a77 4669 414f 5679 nF1vb9YAZwFiAOVy\n+0002de50: 2b56 4e6a 7a48 7534 7a38 4142 5145 5461 +VNjzHu4z8ABQETa\n+0002de60: 7838 6648 5038 686d 7333 6170 3536 6f71 x8fHP8hms3ap56oq\n+0002de70: 2b58 7a2b 4265 4244 482f 7841 4754 6750 +Xz+BeBDH/xAGTgP\n+0002de80: 4659 4664 5856 312f 4164 3934 4971 4f61 FYFdXV1/Ad94IqOa\n+0002de90: 5741 4152 3059 6d4a 6955 3938 3851 4f58 WAAR0YmJiU988QOX\n+0002dea0: 5a77 374b 5a79 4d71 4975 2f36 5971 736d Zw7KZyMqIu/6Yqsm\n+0002deb0: 4e6f 724e 616d 4774 5054 6e7a 6631 5a77 NorNamGtPTnzf1Zw\n+0002dec0: 4b70 5736 4248 7a6e 6933 5339 4943 4a58 KpW6BHzni3S9ICJX\n+0002ded0: 3579 6130 6554 3962 576d 2b49 794e 4a6e 5ya0eT9bWm+IyNJn\n+0002dee0: 537a 4162 3563 2f58 3143 4f50 454a 4850 SzAb5c/X1COPEJHP\n+0002def0: 4f6a 7337 3532 5556 4c48 6f72 782b 5078 Ojs752UVLHorx+Px\n+0002df00: 4475 4436 6d6e 6e6c 442f 2b55 5371 584d DuD6mnnlD/+USqXM\n+0002df10: 7773 4a46 6774 7661 326d 366f 366d 7472 wsJFgtva2m6o6mtr\n+0002df20: 3435 4d2f 6945 6850 5430 2f50 3377 764c 45M/iEhPT0/P3wvL\n+0002df30: 6c35 7833 4d35 6e4d 7879 4979 3749 6f38 l5x3M5nMxyIy7Io8\n+0002df40: 6d38 3275 4f4c 2b48 7359 6d41 5169 7156 m82uOL+HsYmAQiqV\n+0002df50: 476c 6e71 7762 496b 7957 5379 3031 4657 GlnqwbIkyWSy01FW\n+0002df60: 4451 304e 4461 3955 4536 5371 3074 4451 DQ0NDa9UE6Sq0tDQ\n+0002df70: 3443 727a 3442 4b51 5875 3568 3151 2b47 4Crz4BKQXu5h1Q+G\n+0002df80: 3374 3765 7a66 5831 3964 3844 6a7a 6879 3t7ezfX19d8Djzhy\n+0002df90: 786a 642b 5479 5153 2b31 7062 5735 6664 xjd+TyQS+1pbW5fd\n+0002dfa0: 314b 6a61 6a59 3466 502f 3666 4d65 5a5a 1KjajY4fP/6fMeZZ\n+0002dfb0: 3444 666e 7272 6e48 7237 4659 3748 4131 4DfnrrnHr7FY7HA1\n+0002dfc0: 7352 4269 3764 7a5a 3266 6c6e 4c42 6262 sRBi7dzZ2flnLBbb\n+0002dfd0: 4331 7877 3570 7037 5841 4965 4435 4d2f C1xw5pp7XAIeD5M/\n+0002dfe0: 4854 5639 4f41 2b38 5849 746e 486a 4149 HTV9OA+8XItnHjAI\n+0002dff0: 6444 744e 4835 364c 445a 5167 666c 3145 dDtNH56LDZQgfl1E\n+0002e000: 756c 4f70 3150 6b6f 6c56 6131 7935 484c ulOp1PkolVa1y5HL\n+0002e010: 3562 614c 5350 3936 5851 4541 7a73 586a 5baLSP96XQEAzsXj\n+0002e020: 385a 3632 7472 5962 5553 7657 664d 6b44 8Z62trYbUSvWfMkD\n+0002e030: 794f 4967 4354 554d 3175 3253 7830 4945 yOIgCTUM1u2Sx0IE\n+0002e040: 5158 4241 5245 366f 3669 4863 6279 4b55 QXBARE6o6iHcbyKU\n+0002e050: 6761 3956 3957 516d 6b36 6e35 6138 3770 ga9V9WQmk6n5a87p\n+0002e060: 7874 3270 5536 6365 694d 666a 5230 536b xt2pU6ceiMfjR0Sk\n+0002e070: 7863 4646 725a 3945 3549 7971 6a71 7955 xcFFrZ9E5IyqjqyU\n+0002e080: 3552 3446 336e 5971 4334 5643 636d 7071 5R4F3nYqC4VCcmpq\n+0002e090: 6176 5971 6e72 5732 5555 5353 5442 2f50 avYqnrW2UUSSTB/P\n+0002e0a0: 7a68 7a52 7a6c 7a44 4b31 4b35 6967 654d zhzRzlzDK1K5igeM\n+0002e0b0: 4a68 4b4a 735a 586d 3039 5869 6679 4950 JhKJsZXm09XifyIP\n+0002e0c0: 3565 5346 2b42 4b70 4141 4141 4145 6c46 5eSF+BKpAAAAAElF\n+0002e0d0: 546b 5375 516d 4322 3e0a 2020 2020 2020 TkSuQmC\">. \n+0002e0e0: 2020 3c68 313e 4040 6d65 7373 6167 6540 <h1>@@message@\n+0002e0f0: 403c 2f68 313e 0a20 2020 203c 2f64 6976 @</h1>. </div\n+0002e100: 3e0a 3c2f 626f 6479 3e0a 3c2f 6874 6d6c >.</body>.</html\n+0002e110: 3e0a 2727 272c 0a20 2027 636f 636b 7069 >.''',. 'cockpi\n+0002e120: 742f 6368 616e 6e65 6c73 2f5f 5f69 6e69 t/channels/__ini\n+0002e130: 745f 5f2e 7079 273a 2062 7227 2727 2320 t__.py': br'''# \n+0002e140: 5468 6973 2066 696c 6520 6973 2070 6172 This file is par\n+0002e150: 7420 6f66 2043 6f63 6b70 6974 2e0a 230a t of Cockpit..#.\n+0002e160: 2320 436f 7079 7269 6768 7420 2843 2920 # Copyright (C) \n+0002e170: 3230 3232 2052 6564 2048 6174 2c20 496e 2022 Red Hat, In\n+0002e180: 632e 0a23 0a23 2054 6869 7320 7072 6f67 c..#.# This prog\n+0002e190: 7261 6d20 6973 2066 7265 6520 736f 6674 ram is free soft\n+0002e1a0: 7761 7265 3a20 796f 7520 6361 6e20 7265 ware: you can re\n+0002e1b0: 6469 7374 7269 6275 7465 2069 7420 616e distribute it an\n+0002e1c0: 642f 6f72 206d 6f64 6966 790a 2320 6974 d/or modify.# it\n+0002e1d0: 2075 6e64 6572 2074 6865 2074 6572 6d73 under the terms\n+0002e1e0: 206f 6620 7468 6520 474e 5520 4765 6e65 of the GNU Gene\n+0002e1f0: 7261 6c20 5075 626c 6963 204c 6963 656e ral Public Licen\n+0002e200: 7365 2061 7320 7075 626c 6973 6865 6420 se as published \n+0002e210: 6279 0a23 2074 6865 2046 7265 6520 536f by.# the Free So\n+0002e220: 6674 7761 7265 2046 6f75 6e64 6174 696f ftware Foundatio\n+0002e230: 6e2c 2065 6974 6865 7220 7665 7273 696f n, either versio\n+0002e240: 6e20 3320 6f66 2074 6865 204c 6963 656e n 3 of the Licen\n+0002e250: 7365 2c20 6f72 0a23 2028 6174 2079 6f75 se, or.# (at you\n+0002e260: 7220 6f70 7469 6f6e 2920 616e 7920 6c61 r option) any la\n+0002e270: 7465 7220 7665 7273 696f 6e2e 0a23 0a23 ter version..#.#\n+0002e280: 2054 6869 7320 7072 6f67 7261 6d20 6973 This program is\n+0002e290: 2064 6973 7472 6962 7574 6564 2069 6e20 distributed in \n+0002e2a0: 7468 6520 686f 7065 2074 6861 7420 6974 the hope that it\n+0002e2b0: 2077 696c 6c20 6265 2075 7365 6675 6c2c will be useful,\n+0002e2c0: 0a23 2062 7574 2057 4954 484f 5554 2041 .# but WITHOUT A\n+0002e2d0: 4e59 2057 4152 5241 4e54 593b 2077 6974 NY WARRANTY; wit\n+0002e2e0: 686f 7574 2065 7665 6e20 7468 6520 696d hout even the im\n+0002e2f0: 706c 6965 6420 7761 7272 616e 7479 206f plied warranty o\n+0002e300: 660a 2320 4d45 5243 4841 4e54 4142 494c f.# MERCHANTABIL\n+0002e310: 4954 5920 6f72 2046 4954 4e45 5353 2046 ITY or FITNESS F\n+0002e320: 4f52 2041 2050 4152 5449 4355 4c41 5220 OR A PARTICULAR \n+0002e330: 5055 5250 4f53 452e 2020 5365 6520 7468 PURPOSE. See th\n+0002e340: 650a 2320 474e 5520 4765 6e65 7261 6c20 e.# GNU General \n+0002e350: 5075 626c 6963 204c 6963 656e 7365 2066 Public License f\n+0002e360: 6f72 206d 6f72 6520 6465 7461 696c 732e or more details.\n+0002e370: 0a23 0a23 2059 6f75 2073 686f 756c 6420 .#.# You should \n+0002e380: 6861 7665 2072 6563 6569 7665 6420 6120 have received a \n+0002e390: 636f 7079 206f 6620 7468 6520 474e 5520 copy of the GNU \n+0002e3a0: 4765 6e65 7261 6c20 5075 626c 6963 204c General Public L\n+0002e3b0: 6963 656e 7365 0a23 2061 6c6f 6e67 2077 icense.# along w\n+0002e3c0: 6974 6820 7468 6973 2070 726f 6772 616d ith this program\n+0002e3d0: 2e20 2049 6620 6e6f 742c 2073 6565 203c . If not, see <\n+0002e3e0: 6874 7470 733a 2f2f 7777 772e 676e 752e https://www.gnu.\n+0002e3f0: 6f72 672f 6c69 6365 6e73 6573 2f3e 2e0a org/licenses/>..\n+0002e400: 0a66 726f 6d20 2e64 6275 7320 696d 706f .from .dbus impo\n+0002e410: 7274 2044 4275 7343 6861 6e6e 656c 0a66 rt DBusChannel.f\n+0002e420: 726f 6d20 2e66 696c 6573 7973 7465 6d20 rom .filesystem \n+0002e430: 696d 706f 7274 2046 7349 6e66 6f43 6861 import FsInfoCha\n+0002e440: 6e6e 656c 2c20 4673 4c69 7374 4368 616e nnel, FsListChan\n+0002e450: 6e65 6c2c 2046 7352 6561 6443 6861 6e6e nel, FsReadChann\n+0002e460: 656c 2c20 4673 5265 706c 6163 6543 6861 el, FsReplaceCha\n+0002e470: 6e6e 656c 2c20 4673 5761 7463 6843 6861 nnel, FsWatchCha\n+0002e480: 6e6e 656c 0a66 726f 6d20 2e68 7474 7020 nnel.from .http \n+0002e490: 696d 706f 7274 2048 7474 7043 6861 6e6e import HttpChann\n+0002e4a0: 656c 0a66 726f 6d20 2e6d 6574 7269 6373 el.from .metrics\n+0002e4b0: 2069 6d70 6f72 7420 496e 7465 726e 616c import Internal\n+0002e4c0: 4d65 7472 6963 7343 6861 6e6e 656c 0a66 MetricsChannel.f\n+0002e4d0: 726f 6d20 2e70 6163 6b61 6765 7320 696d rom .packages im\n+0002e4e0: 706f 7274 2050 6163 6b61 6765 7343 6861 port PackagesCha\n+0002e4f0: 6e6e 656c 0a66 726f 6d20 2e73 7472 6561 nnel.from .strea\n+0002e500: 6d20 696d 706f 7274 2053 6f63 6b65 7453 m import SocketS\n+0002e510: 7472 6561 6d43 6861 6e6e 656c 2c20 5375 treamChannel, Su\n+0002e520: 6270 726f 6365 7373 5374 7265 616d 4368 bprocessStreamCh\n+0002e530: 616e 6e65 6c0a 6672 6f6d 202e 7472 6976 annel.from .triv\n+0002e540: 6961 6c20 696d 706f 7274 2045 6368 6f43 ial import EchoC\n+0002e550: 6861 6e6e 656c 2c20 4e75 6c6c 4368 616e hannel, NullChan\n+0002e560: 6e65 6c0a 0a43 4841 4e4e 454c 5f54 5950 nel..CHANNEL_TYP\n+0002e570: 4553 203d 205b 0a20 2020 2044 4275 7343 ES = [. DBusC\n+0002e580: 6861 6e6e 656c 2c0a 2020 2020 4563 686f hannel,. Echo\n+0002e590: 4368 616e 6e65 6c2c 0a20 2020 2046 7349 Channel,. FsI\n+0002e5a0: 6e66 6f43 6861 6e6e 656c 2c0a 2020 2020 nfoChannel,. \n+0002e5b0: 4673 4c69 7374 4368 616e 6e65 6c2c 0a20 FsListChannel,. \n+0002e5c0: 2020 2046 7352 6561 6443 6861 6e6e 656c FsReadChannel\n+0002e5d0: 2c0a 2020 2020 4673 5265 706c 6163 6543 ,. FsReplaceC\n+0002e5e0: 6861 6e6e 656c 2c0a 2020 2020 4673 5761 hannel,. FsWa\n+0002e5f0: 7463 6843 6861 6e6e 656c 2c0a 2020 2020 tchChannel,. \n+0002e600: 4874 7470 4368 616e 6e65 6c2c 0a20 2020 HttpChannel,. \n+0002e610: 2049 6e74 6572 6e61 6c4d 6574 7269 6373 InternalMetrics\n+0002e620: 4368 616e 6e65 6c2c 0a20 2020 204e 756c Channel,. Nul\n+0002e630: 6c43 6861 6e6e 656c 2c0a 2020 2020 5061 lChannel,. Pa\n+0002e640: 636b 6167 6573 4368 616e 6e65 6c2c 0a20 ckagesChannel,. \n+0002e650: 2020 2053 7562 7072 6f63 6573 7353 7472 SubprocessStr\n+0002e660: 6561 6d43 6861 6e6e 656c 2c0a 2020 2020 eamChannel,. \n+0002e670: 536f 636b 6574 5374 7265 616d 4368 616e SocketStreamChan\n+0002e680: 6e65 6c2c 0a5d 0a27 2727 2c0a 2020 2763 nel,.].''',. 'c\n+0002e690: 6f63 6b70 6974 2f63 6861 6e6e 656c 732f ockpit/channels/\n+0002e6a0: 6d65 7472 6963 732e 7079 273a 2062 7227 metrics.py': br'\n+0002e6b0: 2727 2320 5468 6973 2066 696c 6520 6973 ''# This file is\n+0002e6c0: 2070 6172 7420 6f66 2043 6f63 6b70 6974 part of Cockpit\n+0002e6d0: 2e0a 230a 2320 436f 7079 7269 6768 7420 ..#.# Copyright \n+0002e6e0: 2843 2920 3230 3232 2052 6564 2048 6174 (C) 2022 Red Hat\n+0002e6f0: 2c20 496e 632e 0a23 0a23 2054 6869 7320 , Inc..#.# This \n+0002e700: 7072 6f67 7261 6d20 6973 2066 7265 6520 program is free \n+0002e710: 736f 6674 7761 7265 3a20 796f 7520 6361 software: you ca\n+0002e720: 6e20 7265 6469 7374 7269 6275 7465 2069 n redistribute i\n+0002e730: 7420 616e 642f 6f72 206d 6f64 6966 790a t and/or modify.\n+0002e740: 2320 6974 2075 6e64 6572 2074 6865 2074 # it under the t\n+0002e750: 6572 6d73 206f 6620 7468 6520 474e 5520 erms of the GNU \n+0002e760: 4765 6e65 7261 6c20 5075 626c 6963 204c General Public L\n+0002e770: 6963 656e 7365 2061 7320 7075 626c 6973 icense as publis\n+0002e780: 6865 6420 6279 0a23 2074 6865 2046 7265 hed by.# the Fre\n+0002e790: 6520 536f 6674 7761 7265 2046 6f75 6e64 e Software Found\n+0002e7a0: 6174 696f 6e2c 2065 6974 6865 7220 7665 ation, either ve\n+0002e7b0: 7273 696f 6e20 3320 6f66 2074 6865 204c rsion 3 of the L\n+0002e7c0: 6963 656e 7365 2c20 6f72 0a23 2028 6174 icense, or.# (at\n+0002e7d0: 2079 6f75 7220 6f70 7469 6f6e 2920 616e your option) an\n+0002e7e0: 7920 6c61 7465 7220 7665 7273 696f 6e2e y later version.\n+0002e7f0: 0a23 0a23 2054 6869 7320 7072 6f67 7261 .#.# This progra\n+0002e800: 6d20 6973 2064 6973 7472 6962 7574 6564 m is distributed\n+0002e810: 2069 6e20 7468 6520 686f 7065 2074 6861 in the hope tha\n+0002e820: 7420 6974 2077 696c 6c20 6265 2075 7365 t it will be use\n+0002e830: 6675 6c2c 0a23 2062 7574 2057 4954 484f ful,.# but WITHO\n+0002e840: 5554 2041 4e59 2057 4152 5241 4e54 593b UT ANY WARRANTY;\n+0002e850: 2077 6974 686f 7574 2065 7665 6e20 7468 without even th\n+0002e860: 6520 696d 706c 6965 6420 7761 7272 616e e implied warran\n+0002e870: 7479 206f 660a 2320 4d45 5243 4841 4e54 ty of.# MERCHANT\n+0002e880: 4142 494c 4954 5920 6f72 2046 4954 4e45 ABILITY or FITNE\n+0002e890: 5353 2046 4f52 2041 2050 4152 5449 4355 SS FOR A PARTICU\n+0002e8a0: 4c41 5220 5055 5250 4f53 452e 2020 5365 LAR PURPOSE. Se\n+0002e8b0: 6520 7468 650a 2320 474e 5520 4765 6e65 e the.# GNU Gene\n+0002e8c0: 7261 6c20 5075 626c 6963 204c 6963 656e ral Public Licen\n+0002e8d0: 7365 2066 6f72 206d 6f72 6520 6465 7461 se for more deta\n+0002e8e0: 696c 732e 0a23 0a23 2059 6f75 2073 686f ils..#.# You sho\n+0002e8f0: 756c 6420 6861 7665 2072 6563 6569 7665 uld have receive\n+0002e900: 6420 6120 636f 7079 206f 6620 7468 6520 d a copy of the \n+0002e910: 474e 5520 4765 6e65 7261 6c20 5075 626c GNU General Publ\n+0002e920: 6963 204c 6963 656e 7365 0a23 2061 6c6f ic License.# alo\n+0002e930: 6e67 2077 6974 6820 7468 6973 2070 726f ng with this pro\n+0002e940: 6772 616d 2e20 2049 6620 6e6f 742c 2073 gram. If not, s\n+0002e950: 6565 203c 6874 7470 733a 2f2f 7777 772e ee <https://www.\n+0002e960: 676e 752e 6f72 672f 6c69 6365 6e73 6573 gnu.org/licenses\n+0002e970: 2f3e 2e0a 0a69 6d70 6f72 7420 6173 796e />...import asyn\n+0002e980: 6369 6f0a 696d 706f 7274 206a 736f 6e0a cio.import json.\n+0002e990: 696d 706f 7274 206c 6f67 6769 6e67 0a69 import logging.i\n+0002e9a0: 6d70 6f72 7420 7379 730a 696d 706f 7274 mport sys.import\n+0002e9b0: 2074 696d 650a 6672 6f6d 2063 6f6c 6c65 time.from colle\n+0002e9c0: 6374 696f 6e73 2069 6d70 6f72 7420 6465 ctions import de\n+0002e9d0: 6661 756c 7464 6963 740a 6672 6f6d 2074 faultdict.from t\n+0002e9e0: 7970 696e 6720 696d 706f 7274 2044 6963 yping import Dic\n+0002e9f0: 742c 204c 6973 742c 204e 616d 6564 5475 t, List, NamedTu\n+0002ea00: 706c 652c 204f 7074 696f 6e61 6c2c 2053 ple, Optional, S\n+0002ea10: 6574 2c20 5475 706c 652c 2055 6e69 6f6e et, Tuple, Union\n+0002ea20: 0a0a 6672 6f6d 202e 2e63 6861 6e6e 656c ..from ..channel\n+0002ea30: 2069 6d70 6f72 7420 4173 796e 6343 6861 import AsyncCha\n+0002ea40: 6e6e 656c 2c20 4368 616e 6e65 6c45 7272 nnel, ChannelErr\n+0002ea50: 6f72 0a66 726f 6d20 2e2e 6a73 6f6e 7574 or.from ..jsonut\n+0002ea60: 696c 2069 6d70 6f72 7420 4a73 6f6e 4c69 il import JsonLi\n+0002ea70: 7374 0a66 726f 6d20 2e2e 7361 6d70 6c65 st.from ..sample\n+0002ea80: 7320 696d 706f 7274 2053 414d 504c 4552 s import SAMPLER\n+0002ea90: 532c 2053 616d 706c 6544 6573 6372 6970 S, SampleDescrip\n+0002eaa0: 7469 6f6e 2c20 5361 6d70 6c65 722c 2053 tion, Sampler, S\n+0002eab0: 616d 706c 6573 0a0a 6c6f 6767 6572 203d amples..logger =\n+0002eac0: 206c 6f67 6769 6e67 2e67 6574 4c6f 6767 logging.getLogg\n+0002ead0: 6572 285f 5f6e 616d 655f 5f29 0a0a 0a63 er(__name__)...c\n+0002eae0: 6c61 7373 204d 6574 7269 6349 6e66 6f28 lass MetricInfo(\n+0002eaf0: 4e61 6d65 6454 7570 6c65 293a 0a20 2020 NamedTuple):. \n+0002eb00: 2064 6572 6976 653a 204f 7074 696f 6e61 derive: Optiona\n+0002eb10: 6c5b 7374 725d 0a20 2020 2064 6573 633a l[str]. desc:\n+0002eb20: 2053 616d 706c 6544 6573 6372 6970 7469 SampleDescripti\n+0002eb30: 6f6e 0a0a 0a63 6c61 7373 2049 6e74 6572 on...class Inter\n+0002eb40: 6e61 6c4d 6574 7269 6373 4368 616e 6e65 nalMetricsChanne\n+0002eb50: 6c28 4173 796e 6343 6861 6e6e 656c 293a l(AsyncChannel):\n+0002eb60: 0a20 2020 2070 6179 6c6f 6164 203d 2027 . payload = '\n+0002eb70: 6d65 7472 6963 7331 270a 2020 2020 7265 metrics1'. re\n+0002eb80: 7374 7269 6374 696f 6e73 203d 205b 2827 strictions = [('\n+0002eb90: 736f 7572 6365 272c 2027 696e 7465 726e source', 'intern\n+0002eba0: 616c 2729 5d0a 0a20 2020 206d 6574 7269 al')].. metri\n+0002ebb0: 6373 3a20 4c69 7374 5b4d 6574 7269 6349 cs: List[MetricI\n+0002ebc0: 6e66 6f5d 0a20 2020 2073 616d 706c 6572 nfo]. sampler\n+0002ebd0: 733a 2053 6574 0a20 2020 2073 616d 706c s: Set. sampl\n+0002ebe0: 6572 735f 6361 6368 653a 204f 7074 696f ers_cache: Optio\n+0002ebf0: 6e61 6c5b 4469 6374 5b73 7472 2c20 5475 nal[Dict[str, Tu\n+0002ec00: 706c 655b 5361 6d70 6c65 722c 2053 616d ple[Sampler, Sam\n+0002ec10: 706c 6544 6573 6372 6970 7469 6f6e 5d5d pleDescription]]\n+0002ec20: 5d20 3d20 4e6f 6e65 0a0a 2020 2020 696e ] = None.. in\n+0002ec30: 7465 7276 616c 3a20 696e 7420 3d20 3130 terval: int = 10\n+0002ec40: 3030 0a20 2020 206e 6565 645f 6d65 7461 00. need_meta\n+0002ec50: 3a20 626f 6f6c 203d 2054 7275 650a 2020 : bool = True. \n+0002ec60: 2020 6c61 7374 5f74 696d 6573 7461 6d70 last_timestamp\n+0002ec70: 3a20 666c 6f61 7420 3d20 300a 2020 2020 : float = 0. \n+0002ec80: 6e65 7874 5f74 696d 6573 7461 6d70 3a20 next_timestamp: \n+0002ec90: 666c 6f61 7420 3d20 300a 0a20 2020 2040 float = 0.. @\n+0002eca0: 636c 6173 736d 6574 686f 640a 2020 2020 classmethod. \n+0002ecb0: 6465 6620 656e 7375 7265 5f73 616d 706c def ensure_sampl\n+0002ecc0: 6572 7328 636c 7329 3a0a 2020 2020 2020 ers(cls):. \n+0002ecd0: 2020 6966 2063 6c73 2e73 616d 706c 6572 if cls.sampler\n+0002ece0: 735f 6361 6368 6520 6973 204e 6f6e 653a s_cache is None:\n+0002ecf0: 0a20 2020 2020 2020 2020 2020 2063 6c73 . cls\n+0002ed00: 2e73 616d 706c 6572 735f 6361 6368 6520 .samplers_cache \n+0002ed10: 3d20 7b64 6573 632e 6e61 6d65 3a20 2873 = {desc.name: (s\n+0002ed20: 616d 706c 6572 2c20 6465 7363 2920 666f ampler, desc) fo\n+0002ed30: 7220 7361 6d70 6c65 7220 696e 2053 414d r sampler in SAM\n+0002ed40: 504c 4552 5320 666f 7220 6465 7363 2069 PLERS for desc i\n+0002ed50: 6e20 7361 6d70 6c65 722e 6465 7363 7269 n sampler.descri\n+0002ed60: 7074 696f 6e73 7d0a 0a20 2020 2064 6566 ptions}.. def\n+0002ed70: 2070 6172 7365 5f6f 7074 696f 6e73 2873 parse_options(s\n+0002ed80: 656c 662c 206f 7074 696f 6e73 293a 0a20 elf, options):. \n+0002ed90: 2020 2020 2020 206c 6f67 6765 722e 6465 logger.de\n+0002eda0: 6275 6728 276d 6574 7269 6373 2069 6e74 bug('metrics int\n+0002edb0: 6572 6e61 6c20 6f70 656e 3a20 2573 2c20 ernal open: %s, \n+0002edc0: 6368 616e 6e65 6c3a 2025 7327 2c20 6f70 channel: %s', op\n+0002edd0: 7469 6f6e 732c 2073 656c 662e 6368 616e tions, self.chan\n+0002ede0: 6e65 6c29 0a0a 2020 2020 2020 2020 696e nel).. in\n+0002edf0: 7465 7276 616c 203d 206f 7074 696f 6e73 terval = options\n+0002ee00: 2e67 6574 2827 696e 7465 7276 616c 272c .get('interval',\n+0002ee10: 2073 656c 662e 696e 7465 7276 616c 290a self.interval).\n+0002ee20: 2020 2020 2020 2020 6966 206e 6f74 2069 if not i\n+0002ee30: 7369 6e73 7461 6e63 6528 696e 7465 7276 sinstance(interv\n+0002ee40: 616c 2c20 696e 7429 206f 7220 696e 7465 al, int) or inte\n+0002ee50: 7276 616c 203c 3d20 3020 6f72 2069 6e74 rval <= 0 or int\n+0002ee60: 6572 7661 6c20 3e20 7379 732e 6d61 7873 erval > sys.maxs\n+0002ee70: 697a 653a 0a20 2020 2020 2020 2020 2020 ize:. \n+0002ee80: 2072 6169 7365 2043 6861 6e6e 656c 4572 raise ChannelEr\n+0002ee90: 726f 7228 2770 726f 746f 636f 6c2d 6572 ror('protocol-er\n+0002eea0: 726f 7227 2c20 6d65 7373 6167 653d 6627 ror', message=f'\n+0002eeb0: 696e 7661 6c69 6420 2269 6e74 6572 7661 invalid \"interva\n+0002eec0: 6c22 2076 616c 7565 3a20 7b69 6e74 6572 l\" value: {inter\n+0002eed0: 7661 6c7d 2729 0a0a 2020 2020 2020 2020 val}').. \n+0002eee0: 7365 6c66 2e69 6e74 6572 7661 6c20 3d20 self.interval = \n+0002eef0: 696e 7465 7276 616c 0a0a 2020 2020 2020 interval.. \n+0002ef00: 2020 6d65 7472 6963 7320 3d20 6f70 7469 metrics = opti\n+0002ef10: 6f6e 732e 6765 7428 276d 6574 7269 6373 ons.get('metrics\n+0002ef20: 2729 0a20 2020 2020 2020 2069 6620 6e6f '). if no\n+0002ef30: 7420 6973 696e 7374 616e 6365 286d 6574 t isinstance(met\n+0002ef40: 7269 6373 2c20 6c69 7374 2920 6f72 206c rics, list) or l\n+0002ef50: 656e 286d 6574 7269 6373 2920 3d3d 2030 en(metrics) == 0\n+0002ef60: 3a0a 2020 2020 2020 2020 2020 2020 6c6f :. lo\n+0002ef70: 6767 6572 2e65 7272 6f72 2827 696e 7661 gger.error('inva\n+0002ef80: 6c69 6420 226d 6574 7269 6373 2220 7661 lid \"metrics\" va\n+0002ef90: 6c75 653a 2025 7327 2c20 6d65 7472 6963 lue: %s', metric\n+0002efa0: 7329 0a20 2020 2020 2020 2020 2020 2072 s). r\n+0002efb0: 6169 7365 2043 6861 6e6e 656c 4572 726f aise ChannelErro\n+0002efc0: 7228 2770 726f 746f 636f 6c2d 6572 726f r('protocol-erro\n+0002efd0: 7227 2c20 6d65 7373 6167 653d 2769 6e76 r', message='inv\n+0002efe0: 616c 6964 2022 6d65 7472 6963 7322 206f alid \"metrics\" o\n+0002eff0: 7074 696f 6e20 7761 7320 7370 6563 6966 ption was specif\n+0002f000: 6965 6420 286e 6f74 2061 6e20 6172 7261 ied (not an arra\n+0002f010: 7929 2729 0a0a 2020 2020 2020 2020 7361 y)').. sa\n+0002f020: 6d70 6c65 725f 636c 6173 7365 7320 3d20 mpler_classes = \n+0002f030: 7365 7428 290a 2020 2020 2020 2020 666f set(). fo\n+0002f040: 7220 6d65 7472 6963 2069 6e20 6d65 7472 r metric in metr\n+0002f050: 6963 733a 0a20 2020 2020 2020 2020 2020 ics:. \n+0002f060: 2023 2076 616c 6964 6174 6520 6974 2773 # validate it's\n+0002f070: 2061 6e20 6f62 6a65 6374 0a20 2020 2020 an object. \n+0002f080: 2020 2020 2020 206e 616d 6520 3d20 6d65 name = me\n+0002f090: 7472 6963 2e67 6574 2827 6e61 6d65 2729 tric.get('name')\n+0002f0a0: 0a20 2020 2020 2020 2020 2020 2075 6e69 . uni\n+0002f0b0: 7473 203d 206d 6574 7269 632e 6765 7428 ts = metric.get(\n+0002f0c0: 2775 6e69 7473 2729 0a20 2020 2020 2020 'units'). \n+0002f0d0: 2020 2020 2064 6572 6976 6520 3d20 6d65 derive = me\n+0002f0e0: 7472 6963 2e67 6574 2827 6465 7269 7665 tric.get('derive\n+0002f0f0: 2729 0a0a 2020 2020 2020 2020 2020 2020 ').. \n+0002f100: 7472 793a 0a20 2020 2020 2020 2020 2020 try:. \n+0002f110: 2020 2020 2073 616d 706c 6572 2c20 6465 sampler, de\n+0002f120: 7363 203d 2073 656c 662e 7361 6d70 6c65 sc = self.sample\n+0002f130: 7273 5f63 6163 6865 5b6e 616d 655d 0a20 rs_cache[name]. \n+0002f140: 2020 2020 2020 2020 2020 2065 7863 6570 excep\n+0002f150: 7420 4b65 7945 7272 6f72 2061 7320 6578 t KeyError as ex\n+0002f160: 633a 0a20 2020 2020 2020 2020 2020 2020 c:. \n+0002f170: 2020 206c 6f67 6765 722e 6572 726f 7228 logger.error(\n+0002f180: 2775 6e73 7570 706f 7274 6564 206d 6574 'unsupported met\n+0002f190: 7269 633a 2025 7327 2c20 6e61 6d65 290a ric: %s', name).\n+0002f1a0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0002f1b0: 7261 6973 6520 4368 616e 6e65 6c45 7272 raise ChannelErr\n+0002f1c0: 6f72 2827 6e6f 742d 7375 7070 6f72 7465 or('not-supporte\n+0002f1d0: 6427 2c20 6d65 7373 6167 653d 6627 756e d', message=f'un\n+0002f1e0: 7375 7070 6f72 7465 6420 6d65 7472 6963 supported metric\n+0002f1f0: 3a20 7b6e 616d 657d 2729 2066 726f 6d20 : {name}') from \n+0002f200: 6578 630a 0a20 2020 2020 2020 2020 2020 exc.. \n+0002f210: 2069 6620 756e 6974 7320 616e 6420 756e if units and un\n+0002f220: 6974 7320 213d 2064 6573 632e 756e 6974 its != desc.unit\n+0002f230: 733a 0a20 2020 2020 2020 2020 2020 2020 s:. \n+0002f240: 2020 2072 6169 7365 2043 6861 6e6e 656c raise Channel\n+0002f250: 4572 726f 7228 276e 6f74 2d73 7570 706f Error('not-suppo\n+0002f260: 7274 6564 272c 206d 6573 7361 6765 3d66 rted', message=f\n+0002f270: 277b 6e61 6d65 7d20 6861 7320 756e 6974 '{name} has unit\n+0002f280: 7320 7b64 6573 632e 756e 6974 737d 2c20 s {desc.units}, \n+0002f290: 6e6f 7420 7b75 6e69 7473 7d27 290a 0a20 not {units}').. \n+0002f2a0: 2020 2020 2020 2020 2020 2073 616d 706c sampl\n+0002f2b0: 6572 5f63 6c61 7373 6573 2e61 6464 2873 er_classes.add(s\n+0002f2c0: 616d 706c 6572 290a 2020 2020 2020 2020 ampler). \n+0002f2d0: 2020 2020 7365 6c66 2e6d 6574 7269 6373 self.metrics\n+0002f2e0: 2e61 7070 656e 6428 4d65 7472 6963 496e .append(MetricIn\n+0002f2f0: 666f 2864 6572 6976 653d 6465 7269 7665 fo(derive=derive\n+0002f300: 2c20 6465 7363 3d64 6573 6329 290a 0a20 , desc=desc)).. \n+0002f310: 2020 2020 2020 2073 656c 662e 7361 6d70 self.samp\n+0002f320: 6c65 7273 203d 207b 636c 7328 2920 666f lers = {cls() fo\n+0002f330: 7220 636c 7320 696e 2073 616d 706c 6572 r cls in sampler\n+0002f340: 5f63 6c61 7373 6573 7d0a 0a20 2020 2064 _classes}.. d\n+0002f350: 6566 2073 656e 645f 6d65 7461 2873 656c ef send_meta(sel\n+0002f360: 662c 2073 616d 706c 6573 3a20 5361 6d70 f, samples: Samp\n+0002f370: 6c65 732c 2074 696d 6573 7461 6d70 3a20 les, timestamp: \n+0002f380: 666c 6f61 7429 3a0a 2020 2020 2020 2020 float):. \n+0002f390: 6d65 7472 6963 733a 204a 736f 6e4c 6973 metrics: JsonLis\n+0002f3a0: 7420 3d20 5b5d 0a20 2020 2020 2020 2066 t = []. f\n+0002f3b0: 6f72 206d 6574 7269 6369 6e66 6f20 696e or metricinfo in\n+0002f3c0: 2073 656c 662e 6d65 7472 6963 733a 0a20 self.metrics:. \n+0002f3d0: 2020 2020 2020 2020 2020 2069 6620 6d65 if me\n+0002f3e0: 7472 6963 696e 666f 2e64 6573 632e 696e tricinfo.desc.in\n+0002f3f0: 7374 616e 6365 643a 0a20 2020 2020 2020 stanced:. \n+0002f400: 2020 2020 2020 2020 206d 6574 7269 6373 metrics\n+0002f410: 2e61 7070 656e 6428 7b0a 2020 2020 2020 .append({. \n+0002f420: 2020 2020 2020 2020 2020 2020 2020 276e 'n\n+0002f430: 616d 6527 3a20 6d65 7472 6963 696e 666f ame': metricinfo\n+0002f440: 2e64 6573 632e 6e61 6d65 2c0a 2020 2020 .desc.name,. \n+0002f450: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0002f460: 2775 6e69 7473 273a 206d 6574 7269 6369 'units': metrici\n+0002f470: 6e66 6f2e 6465 7363 2e75 6e69 7473 2c0a nfo.desc.units,.\n+0002f480: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0002f490: 2020 2020 2769 6e73 7461 6e63 6573 273a 'instances':\n+0002f4a0: 206c 6973 7428 7361 6d70 6c65 735b 6d65 list(samples[me\n+0002f4b0: 7472 6963 696e 666f 2e64 6573 632e 6e61 tricinfo.desc.na\n+0002f4c0: 6d65 5d2e 6b65 7973 2829 292c 0a20 2020 me].keys()),. \n+0002f4d0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0002f4e0: 2027 7365 6d61 6e74 6963 7327 3a20 6d65 'semantics': me\n+0002f4f0: 7472 6963 696e 666f 2e64 6573 632e 7365 tricinfo.desc.se\n+0002f500: 6d61 6e74 6963 730a 2020 2020 2020 2020 mantics. \n+0002f510: 2020 2020 2020 2020 7d29 0a20 2020 2020 }). \n+0002f520: 2020 2020 2020 2065 6c73 653a 0a20 2020 else:. \n+0002f530: 2020 2020 2020 2020 2020 2020 206d 6574 met\n+0002f540: 7269 6373 2e61 7070 656e 6428 7b0a 2020 rics.append({. \n+0002f550: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0002f560: 2020 276e 616d 6527 3a20 6d65 7472 6963 'name': metric\n+0002f570: 696e 666f 2e64 6573 632e 6e61 6d65 2c0a info.desc.name,.\n+0002f580: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0002f590: 2020 2020 2764 6572 6976 6527 3a20 6d65 'derive': me\n+0002f5a0: 7472 6963 696e 666f 2e64 6572 6976 652c tricinfo.derive,\n+0002f5b0: 2020 2320 7479 7065 3a20 6967 6e6f 7265 # type: ignore\n+0002f5c0: 5b64 6963 742d 6974 656d 5d0a 2020 2020 [dict-item]. \n+0002f5d0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0002f5e0: 2775 6e69 7473 273a 206d 6574 7269 6369 'units': metrici\n+0002f5f0: 6e66 6f2e 6465 7363 2e75 6e69 7473 2c0a nfo.desc.units,.\n+0002f600: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0002f610: 2020 2020 2773 656d 616e 7469 6373 273a 'semantics':\n+0002f620: 206d 6574 7269 6369 6e66 6f2e 6465 7363 metricinfo.desc\n+0002f630: 2e73 656d 616e 7469 6373 0a20 2020 2020 .semantics. \n+0002f640: 2020 2020 2020 2020 2020 207d 290a 0a20 }).. \n+0002f650: 2020 2020 2020 2073 656c 662e 7365 6e64 self.send\n+0002f660: 5f6a 736f 6e28 736f 7572 6365 3d27 696e _json(source='in\n+0002f670: 7465 726e 616c 272c 2069 6e74 6572 7661 ternal', interva\n+0002f680: 6c3d 7365 6c66 2e69 6e74 6572 7661 6c2c l=self.interval,\n+0002f690: 2074 696d 6573 7461 6d70 3d74 696d 6573 timestamp=times\n+0002f6a0: 7461 6d70 202a 2031 3030 302c 206d 6574 tamp * 1000, met\n+0002f6b0: 7269 6373 3d6d 6574 7269 6373 290a 2020 rics=metrics). \n+0002f6c0: 2020 2020 2020 7365 6c66 2e6e 6565 645f self.need_\n+0002f6d0: 6d65 7461 203d 2046 616c 7365 0a0a 2020 meta = False.. \n+0002f6e0: 2020 6465 6620 7361 6d70 6c65 2873 656c def sample(sel\n+0002f6f0: 6629 3a0a 2020 2020 2020 2020 7361 6d70 f):. samp\n+0002f700: 6c65 7320 3d20 6465 6661 756c 7464 6963 les = defaultdic\n+0002f710: 7428 6469 6374 290a 2020 2020 2020 2020 t(dict). \n+0002f720: 666f 7220 7361 6d70 6c65 7220 696e 2073 for sampler in s\n+0002f730: 656c 662e 7361 6d70 6c65 7273 3a0a 2020 elf.samplers:. \n+0002f740: 2020 2020 2020 2020 2020 7361 6d70 6c65 sample\n+0002f750: 722e 7361 6d70 6c65 2873 616d 706c 6573 r.sample(samples\n+0002f760: 290a 2020 2020 2020 2020 7265 7475 726e ). return\n+0002f770: 2073 616d 706c 6573 0a0a 2020 2020 6465 samples.. de\n+0002f780: 6620 6361 6c63 756c 6174 655f 7361 6d70 f calculate_samp\n+0002f790: 6c65 5f72 6174 6528 7365 6c66 2c20 7661 le_rate(self, va\n+0002f7a0: 6c75 653a 2066 6c6f 6174 2c20 6f6c 645f lue: float, old_\n+0002f7b0: 7661 6c75 653a 204f 7074 696f 6e61 6c5b value: Optional[\n+0002f7c0: 666c 6f61 745d 2920 2d3e 2055 6e69 6f6e float]) -> Union\n+0002f7d0: 5b66 6c6f 6174 2c20 626f 6f6c 5d3a 0a20 [float, bool]:. \n+0002f7e0: 2020 2020 2020 2069 6620 6f6c 645f 7661 if old_va\n+0002f7f0: 6c75 6520 6973 206e 6f74 204e 6f6e 6520 lue is not None \n+0002f800: 616e 6420 7365 6c66 2e6c 6173 745f 7469 and self.last_ti\n+0002f810: 6d65 7374 616d 703a 0a20 2020 2020 2020 mestamp:. \n+0002f820: 2020 2020 2072 6574 7572 6e20 2876 616c return (val\n+0002f830: 7565 202d 206f 6c64 5f76 616c 7565 2920 ue - old_value) \n+0002f840: 2f20 2873 656c 662e 6e65 7874 5f74 696d / (self.next_tim\n+0002f850: 6573 7461 6d70 202d 2073 656c 662e 6c61 estamp - self.la\n+0002f860: 7374 5f74 696d 6573 7461 6d70 290a 2020 st_timestamp). \n+0002f870: 2020 2020 2020 656c 7365 3a0a 2020 2020 else:. \n+0002f880: 2020 2020 2020 2020 7265 7475 726e 2046 return F\n+0002f890: 616c 7365 0a0a 2020 2020 6465 6620 7365 alse.. def se\n+0002f8a0: 6e64 5f75 7064 6174 6573 2873 656c 662c nd_updates(self,\n+0002f8b0: 2073 616d 706c 6573 3a20 5361 6d70 6c65 samples: Sample\n+0002f8c0: 732c 206c 6173 745f 7361 6d70 6c65 733a s, last_samples:\n+0002f8d0: 2053 616d 706c 6573 293a 0a20 2020 2020 Samples):. \n+0002f8e0: 2020 2064 6174 613a 204c 6973 745b 556e data: List[Un\n+0002f8f0: 696f 6e5b 666c 6f61 742c 204c 6973 745b ion[float, List[\n+0002f900: 4f70 7469 6f6e 616c 5b55 6e69 6f6e 5b66 Optional[Union[f\n+0002f910: 6c6f 6174 2c20 626f 6f6c 5d5d 5d5d 5d20 loat, bool]]]]] \n+0002f920: 3d20 5b5d 0a20 2020 2020 2020 2074 696d = []. tim\n+0002f930: 6573 7461 6d70 203d 2074 696d 652e 7469 estamp = time.ti\n+0002f940: 6d65 2829 0a20 2020 2020 2020 2073 656c me(). sel\n+0002f950: 662e 6e65 7874 5f74 696d 6573 7461 6d70 f.next_timestamp\n+0002f960: 203d 2074 696d 6573 7461 6d70 0a0a 2020 = timestamp.. \n+0002f970: 2020 2020 2020 666f 7220 6d65 7472 6963 for metric\n+0002f980: 696e 666f 2069 6e20 7365 6c66 2e6d 6574 info in self.met\n+0002f990: 7269 6373 3a0a 2020 2020 2020 2020 2020 rics:. \n+0002f9a0: 2020 7661 6c75 6520 3d20 7361 6d70 6c65 value = sample\n+0002f9b0: 735b 6d65 7472 6963 696e 666f 2e64 6573 s[metricinfo.des\n+0002f9c0: 632e 6e61 6d65 5d0a 0a20 2020 2020 2020 c.name].. \n+0002f9d0: 2020 2020 2069 6620 6d65 7472 6963 696e if metricin\n+0002f9e0: 666f 2e64 6573 632e 696e 7374 616e 6365 fo.desc.instance\n+0002f9f0: 643a 0a20 2020 2020 2020 2020 2020 2020 d:. \n+0002fa00: 2020 206f 6c64 5f76 616c 7565 203d 206c old_value = l\n+0002fa10: 6173 745f 7361 6d70 6c65 735b 6d65 7472 ast_samples[metr\n+0002fa20: 6963 696e 666f 2e64 6573 632e 6e61 6d65 icinfo.desc.name\n+0002fa30: 5d0a 2020 2020 2020 2020 2020 2020 2020 ]. \n+0002fa40: 2020 6173 7365 7274 2069 7369 6e73 7461 assert isinsta\n+0002fa50: 6e63 6528 7661 6c75 652c 2064 6963 7429 nce(value, dict)\n+0002fa60: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+0002fa70: 2061 7373 6572 7420 6973 696e 7374 616e assert isinstan\n+0002fa80: 6365 286f 6c64 5f76 616c 7565 2c20 6469 ce(old_value, di\n+0002fa90: 6374 290a 0a20 2020 2020 2020 2020 2020 ct).. \n+0002faa0: 2020 2020 2023 2049 6620 7765 2068 6176 # If we hav\n+0002fab0: 6520 6c65 7373 206f 7220 6d6f 7265 206b e less or more k\n+0002fac0: 6579 7320 7468 6520 6461 7461 2063 6861 eys the data cha\n+0002fad0: 6e67 6564 2c20 7365 6e64 2061 206d 6574 nged, send a met\n+0002fae0: 6120 6d65 7373 6167 652e 0a20 2020 2020 a message.. \n+0002faf0: 2020 2020 2020 2020 2020 2069 6620 7661 if va\n+0002fb00: 6c75 652e 6b65 7973 2829 2021 3d20 6f6c lue.keys() != ol\n+0002fb10: 645f 7661 6c75 652e 6b65 7973 2829 3a0a d_value.keys():.\n+0002fb20: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0002fb30: 2020 2020 7365 6c66 2e6e 6565 645f 6d65 self.need_me\n+0002fb40: 7461 203d 2054 7275 650a 0a20 2020 2020 ta = True.. \n+0002fb50: 2020 2020 2020 2020 2020 2069 6620 6d65 if me\n+0002fb60: 7472 6963 696e 666f 2e64 6572 6976 6520 tricinfo.derive \n+0002fb70: 3d3d 2027 7261 7465 273a 0a20 2020 2020 == 'rate':. \n+0002fb80: 2020 2020 2020 2020 2020 2020 2020 2069 i\n+0002fb90: 6e73 7461 6e63 6573 3a20 4c69 7374 5b4f nstances: List[O\n+0002fba0: 7074 696f 6e61 6c5b 556e 696f 6e5b 666c ptional[Union[fl\n+0002fbb0: 6f61 742c 2062 6f6f 6c5d 5d5d 203d 205b oat, bool]]] = [\n+0002fbc0: 5d0a 2020 2020 2020 2020 2020 2020 2020 ]. \n+0002fbd0: 2020 2020 2020 666f 7220 6b65 792c 2076 for key, v\n+0002fbe0: 616c 2069 6e20 7661 6c75 652e 6974 656d al in value.item\n+0002fbf0: 7328 293a 0a20 2020 2020 2020 2020 2020 s():. \n+0002fc00: 2020 2020 2020 2020 2020 2020 2069 6e73 ins\n+0002fc10: 7461 6e63 6573 2e61 7070 656e 6428 7365 tances.append(se\n+0002fc20: 6c66 2e63 616c 6375 6c61 7465 5f73 616d lf.calculate_sam\n+0002fc30: 706c 655f 7261 7465 2876 616c 2c20 6f6c ple_rate(val, ol\n+0002fc40: 645f 7661 6c75 652e 6765 7428 6b65 7929 d_value.get(key)\n+0002fc50: 2929 0a0a 2020 2020 2020 2020 2020 2020 )).. \n+0002fc60: 2020 2020 2020 2020 6461 7461 2e61 7070 data.app\n+0002fc70: 656e 6428 696e 7374 616e 6365 7329 0a20 end(instances). \n+0002fc80: 2020 2020 2020 2020 2020 2020 2020 2065 e\n+0002fc90: 6c73 653a 0a20 2020 2020 2020 2020 2020 lse:. \n+0002fca0: 2020 2020 2020 2020 2064 6174 612e 6170 data.ap\n+0002fcb0: 7065 6e64 286c 6973 7428 7661 6c75 652e pend(list(value.\n+0002fcc0: 7661 6c75 6573 2829 2929 0a20 2020 2020 values())). \n+0002fcd0: 2020 2020 2020 2065 6c73 653a 0a20 2020 else:. \n+0002fce0: 2020 2020 2020 2020 2020 2020 206f 6c64 old\n+0002fcf0: 5f76 616c 7565 203d 206c 6173 745f 7361 _value = last_sa\n+0002fd00: 6d70 6c65 732e 6765 7428 6d65 7472 6963 mples.get(metric\n+0002fd10: 696e 666f 2e64 6573 632e 6e61 6d65 290a info.desc.name).\n+0002fd20: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0002fd30: 6173 7365 7274 206e 6f74 2069 7369 6e73 assert not isins\n+0002fd40: 7461 6e63 6528 7661 6c75 652c 2064 6963 tance(value, dic\n+0002fd50: 7429 0a20 2020 2020 2020 2020 2020 2020 t). \n+0002fd60: 2020 2061 7373 6572 7420 6e6f 7420 6973 assert not is\n+0002fd70: 696e 7374 616e 6365 286f 6c64 5f76 616c instance(old_val\n+0002fd80: 7565 2c20 6469 6374 290a 0a20 2020 2020 ue, dict).. \n+0002fd90: 2020 2020 2020 2020 2020 2069 6620 6d65 if me\n+0002fda0: 7472 6963 696e 666f 2e64 6572 6976 6520 tricinfo.derive \n+0002fdb0: 3d3d 2027 7261 7465 273a 0a20 2020 2020 == 'rate':. \n+0002fdc0: 2020 2020 2020 2020 2020 2020 2020 2064 d\n+0002fdd0: 6174 612e 6170 7065 6e64 2873 656c 662e ata.append(self.\n+0002fde0: 6361 6c63 756c 6174 655f 7361 6d70 6c65 calculate_sample\n+0002fdf0: 5f72 6174 6528 7661 6c75 652c 206f 6c64 _rate(value, old\n+0002fe00: 5f76 616c 7565 2929 0a20 2020 2020 2020 _value)). \n+0002fe10: 2020 2020 2020 2020 2065 6c73 653a 0a20 else:. \n+0002fe20: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0002fe30: 2020 2064 6174 612e 6170 7065 6e64 2876 data.append(v\n+0002fe40: 616c 7565 290a 0a20 2020 2020 2020 2069 alue).. i\n+0002fe50: 6620 7365 6c66 2e6e 6565 645f 6d65 7461 f self.need_meta\n+0002fe60: 3a0a 2020 2020 2020 2020 2020 2020 7365 :. se\n+0002fe70: 6c66 2e73 656e 645f 6d65 7461 2873 616d lf.send_meta(sam\n+0002fe80: 706c 6573 2c20 7469 6d65 7374 616d 7029 ples, timestamp)\n+0002fe90: 0a0a 2020 2020 2020 2020 7365 6c66 2e6c .. self.l\n+0002fea0: 6173 745f 7469 6d65 7374 616d 7020 3d20 ast_timestamp = \n+0002feb0: 7365 6c66 2e6e 6578 745f 7469 6d65 7374 self.next_timest\n+0002fec0: 616d 700a 2020 2020 2020 2020 7365 6c66 amp. self\n+0002fed0: 2e73 656e 645f 6461 7461 286a 736f 6e2e .send_data(json.\n+0002fee0: 6475 6d70 7328 5b64 6174 615d 292e 656e dumps([data]).en\n+0002fef0: 636f 6465 2829 290a 0a20 2020 2061 7379 code()).. asy\n+0002ff00: 6e63 2064 6566 2072 756e 2873 656c 662c nc def run(self,\n+0002ff10: 206f 7074 696f 6e73 293a 0a20 2020 2020 options):. \n+0002ff20: 2020 2073 656c 662e 6d65 7472 6963 7320 self.metrics \n+0002ff30: 3d20 5b5d 0a20 2020 2020 2020 2073 656c = []. sel\n+0002ff40: 662e 7361 6d70 6c65 7273 203d 2073 6574 f.samplers = set\n+0002ff50: 2829 0a0a 2020 2020 2020 2020 496e 7465 ().. Inte\n+0002ff60: 726e 616c 4d65 7472 6963 7343 6861 6e6e rnalMetricsChann\n+0002ff70: 656c 2e65 6e73 7572 655f 7361 6d70 6c65 el.ensure_sample\n+0002ff80: 7273 2829 0a0a 2020 2020 2020 2020 7365 rs().. se\n+0002ff90: 6c66 2e70 6172 7365 5f6f 7074 696f 6e73 lf.parse_options\n+0002ffa0: 286f 7074 696f 6e73 290a 2020 2020 2020 (options). \n+0002ffb0: 2020 7365 6c66 2e72 6561 6479 2829 0a0a self.ready()..\n+0002ffc0: 2020 2020 2020 2020 6c61 7374 5f73 616d last_sam\n+0002ffd0: 706c 6573 203d 2064 6566 6175 6c74 6469 ples = defaultdi\n+0002ffe0: 6374 2864 6963 7429 0a20 2020 2020 2020 ct(dict). \n+0002fff0: 2077 6869 6c65 2054 7275 653a 0a20 2020 while True:. \n+00030000: 2020 2020 2020 2020 2073 616d 706c 6573 samples\n+00030010: 203d 2073 656c 662e 7361 6d70 6c65 2829 = self.sample()\n+00030020: 0a20 2020 2020 2020 2020 2020 2073 656c . sel\n+00030030: 662e 7365 6e64 5f75 7064 6174 6573 2873 f.send_updates(s\n+00030040: 616d 706c 6573 2c20 6c61 7374 5f73 616d amples, last_sam\n+00030050: 706c 6573 290a 2020 2020 2020 2020 2020 ples). \n+00030060: 2020 6c61 7374 5f73 616d 706c 6573 203d last_samples =\n+00030070: 2073 616d 706c 6573 0a20 2020 2020 2020 samples. \n+00030080: 2020 2020 2061 7761 6974 2061 7379 6e63 await async\n+00030090: 696f 2e73 6c65 6570 2873 656c 662e 696e io.sleep(self.in\n+000300a0: 7465 7276 616c 202f 2031 3030 3029 0a27 terval / 1000).'\n+000300b0: 2727 2c0a 2020 2763 6f63 6b70 6974 2f63 '',. 'cockpit/c\n+000300c0: 6861 6e6e 656c 732f 7374 7265 616d 2e70 hannels/stream.p\n+000300d0: 7927 3a20 6272 2727 2723 2054 6869 7320 y': br'''# This \n+000300e0: 6669 6c65 2069 7320 7061 7274 206f 6620 file is part of \n+000300f0: 436f 636b 7069 742e 0a23 0a23 2043 6f70 Cockpit..#.# Cop\n+00030100: 7972 6967 6874 2028 4329 2032 3032 3220 yright (C) 2022 \n+00030110: 5265 6420 4861 742c 2049 6e63 2e0a 230a Red Hat, Inc..#.\n+00030120: 2320 5468 6973 2070 726f 6772 616d 2069 # This program i\n+00030130: 7320 6672 6565 2073 6f66 7477 6172 653a s free software:\n+00030140: 2079 6f75 2063 616e 2072 6564 6973 7472 you can redistr\n+00030150: 6962 7574 6520 6974 2061 6e64 2f6f 7220 ibute it and/or \n+00030160: 6d6f 6469 6679 0a23 2069 7420 756e 6465 modify.# it unde\n+00030170: 7220 7468 6520 7465 726d 7320 6f66 2074 r the terms of t\n+00030180: 6865 2047 4e55 2047 656e 6572 616c 2050 he GNU General P\n+00030190: 7562 6c69 6320 4c69 6365 6e73 6520 6173 ublic License as\n+000301a0: 2070 7562 6c69 7368 6564 2062 790a 2320 published by.# \n+000301b0: 7468 6520 4672 6565 2053 6f66 7477 6172 the Free Softwar\n+000301c0: 6520 466f 756e 6461 7469 6f6e 2c20 6569 e Foundation, ei\n+000301d0: 7468 6572 2076 6572 7369 6f6e 2033 206f ther version 3 o\n+000301e0: 6620 7468 6520 4c69 6365 6e73 652c 206f f the License, o\n+000301f0: 720a 2320 2861 7420 796f 7572 206f 7074 r.# (at your opt\n+00030200: 696f 6e29 2061 6e79 206c 6174 6572 2076 ion) any later v\n+00030210: 6572 7369 6f6e 2e0a 230a 2320 5468 6973 ersion..#.# This\n+00030220: 2070 726f 6772 616d 2069 7320 6469 7374 program is dist\n+00030230: 7269 6275 7465 6420 696e 2074 6865 2068 ributed in the h\n+00030240: 6f70 6520 7468 6174 2069 7420 7769 6c6c ope that it will\n+00030250: 2062 6520 7573 6566 756c 2c0a 2320 6275 be useful,.# bu\n+00030260: 7420 5749 5448 4f55 5420 414e 5920 5741 t WITHOUT ANY WA\n+00030270: 5252 414e 5459 3b20 7769 7468 6f75 7420 RRANTY; without \n+00030280: 6576 656e 2074 6865 2069 6d70 6c69 6564 even the implied\n+00030290: 2077 6172 7261 6e74 7920 6f66 0a23 204d warranty of.# M\n+000302a0: 4552 4348 414e 5441 4249 4c49 5459 206f ERCHANTABILITY o\n+000302b0: 7220 4649 544e 4553 5320 464f 5220 4120 r FITNESS FOR A \n+000302c0: 5041 5254 4943 554c 4152 2050 5552 504f PARTICULAR PURPO\n+000302d0: 5345 2e20 2053 6565 2074 6865 0a23 2047 SE. See the.# G\n+000302e0: 4e55 2047 656e 6572 616c 2050 7562 6c69 NU General Publi\n+000302f0: 6320 4c69 6365 6e73 6520 666f 7220 6d6f c License for mo\n+00030300: 7265 2064 6574 6169 6c73 2e0a 230a 2320 re details..#.# \n+00030310: 596f 7520 7368 6f75 6c64 2068 6176 6520 You should have \n+00030320: 7265 6365 6976 6564 2061 2063 6f70 7920 received a copy \n+00030330: 6f66 2074 6865 2047 4e55 2047 656e 6572 of the GNU Gener\n+00030340: 616c 2050 7562 6c69 6320 4c69 6365 6e73 al Public Licens\n+00030350: 650a 2320 616c 6f6e 6720 7769 7468 2074 e.# along with t\n+00030360: 6869 7320 7072 6f67 7261 6d2e 2020 4966 his program. If\n+00030370: 206e 6f74 2c20 7365 6520 3c68 7474 7073 not, see <https\n+00030380: 3a2f 2f77 7777 2e67 6e75 2e6f 7267 2f6c ://www.gnu.org/l\n+00030390: 6963 656e 7365 732f 3e2e 0a0a 696d 706f icenses/>...impo\n+000303a0: 7274 2061 7379 6e63 696f 0a69 6d70 6f72 rt asyncio.impor\n+000303b0: 7420 6c6f 6767 696e 670a 696d 706f 7274 t logging.import\n+000303c0: 206f 730a 696d 706f 7274 2073 7562 7072 os.import subpr\n+000303d0: 6f63 6573 730a 6672 6f6d 2074 7970 696e ocess.from typin\n+000303e0: 6720 696d 706f 7274 2044 6963 740a 0a66 g import Dict..f\n+000303f0: 726f 6d20 2e2e 6368 616e 6e65 6c20 696d rom ..channel im\n+00030400: 706f 7274 2043 6861 6e6e 656c 4572 726f port ChannelErro\n+00030410: 722c 2050 726f 746f 636f 6c43 6861 6e6e r, ProtocolChann\n+00030420: 656c 0a66 726f 6d20 2e2e 6a73 6f6e 7574 el.from ..jsonut\n+00030430: 696c 2069 6d70 6f72 7420 4a73 6f6e 4469 il import JsonDi\n+00030440: 6374 2c20 4a73 6f6e 4f62 6a65 6374 2c20 ct, JsonObject, \n+00030450: 6765 745f 626f 6f6c 2c20 6765 745f 656e get_bool, get_en\n+00030460: 756d 2c20 6765 745f 696e 742c 2067 6574 um, get_int, get\n+00030470: 5f6f 626a 6563 742c 2067 6574 5f73 7472 _object, get_str\n+00030480: 2c20 6765 745f 7374 7276 0a66 726f 6d20 , get_strv.from \n+00030490: 2e2e 7472 616e 7370 6f72 7473 2069 6d70 ..transports imp\n+000304a0: 6f72 7420 5375 6270 726f 6365 7373 5072 ort SubprocessPr\n+000304b0: 6f74 6f63 6f6c 2c20 5375 6270 726f 6365 otocol, Subproce\n+000304c0: 7373 5472 616e 7370 6f72 742c 2057 696e ssTransport, Win\n+000304d0: 646f 7753 697a 650a 0a6c 6f67 6765 7220 dowSize..logger \n+000304e0: 3d20 6c6f 6767 696e 672e 6765 744c 6f67 = logging.getLog\n+000304f0: 6765 7228 5f5f 6e61 6d65 5f5f 290a 0a0a ger(__name__)...\n+00030500: 636c 6173 7320 536f 636b 6574 5374 7265 class SocketStre\n+00030510: 616d 4368 616e 6e65 6c28 5072 6f74 6f63 amChannel(Protoc\n+00030520: 6f6c 4368 616e 6e65 6c29 3a0a 2020 2020 olChannel):. \n+00030530: 7061 796c 6f61 6420 3d20 2773 7472 6561 payload = 'strea\n+00030540: 6d27 0a0a 2020 2020 6173 796e 6320 6465 m'.. async de\n+00030550: 6620 6372 6561 7465 5f74 7261 6e73 706f f create_transpo\n+00030560: 7274 2873 656c 662c 206c 6f6f 703a 2061 rt(self, loop: a\n+00030570: 7379 6e63 696f 2e41 6273 7472 6163 7445 syncio.AbstractE\n+00030580: 7665 6e74 4c6f 6f70 2c20 6f70 7469 6f6e ventLoop, option\n+00030590: 733a 204a 736f 6e4f 626a 6563 7429 202d s: JsonObject) -\n+000305a0: 3e20 6173 796e 6369 6f2e 5472 616e 7370 > asyncio.Transp\n+000305b0: 6f72 743a 0a20 2020 2020 2020 2069 6620 ort:. if \n+000305c0: 2775 6e69 7827 2069 6e20 6f70 7469 6f6e 'unix' in option\n+000305d0: 7320 616e 6420 2770 6f72 7427 2069 6e20 s and 'port' in \n+000305e0: 6f70 7469 6f6e 733a 0a20 2020 2020 2020 options:. \n+000305f0: 2020 2020 2072 6169 7365 2043 6861 6e6e raise Chann\n+00030600: 656c 4572 726f 7228 2770 726f 746f 636f elError('protoco\n+00030610: 6c2d 6572 726f 7227 2c20 6d65 7373 6167 l-error', messag\n+00030620: 653d 2763 616e 6e6f 7420 7370 6563 6966 e='cannot specif\n+00030630: 7920 626f 7468 2022 706f 7274 2220 616e y both \"port\" an\n+00030640: 6420 2275 6e69 7822 206f 7074 696f 6e73 d \"unix\" options\n+00030650: 2729 0a0a 2020 2020 2020 2020 7472 793a ').. try:\n+00030660: 0a20 2020 2020 2020 2020 2020 2023 2055 . # U\n+00030670: 6e69 780a 2020 2020 2020 2020 2020 2020 nix. \n+00030680: 6966 2027 756e 6978 2720 696e 206f 7074 if 'unix' in opt\n+00030690: 696f 6e73 3a0a 2020 2020 2020 2020 2020 ions:. \n+000306a0: 2020 2020 2020 7061 7468 203d 2067 6574 path = get\n+000306b0: 5f73 7472 286f 7074 696f 6e73 2c20 2775 _str(options, 'u\n+000306c0: 6e69 7827 290a 2020 2020 2020 2020 2020 nix'). \n+000306d0: 2020 2020 2020 6c61 6265 6c20 3d20 6627 label = f'\n+000306e0: 556e 6978 2073 6f63 6b65 7420 7b70 6174 Unix socket {pat\n+000306f0: 687d 270a 2020 2020 2020 2020 2020 2020 h}'. \n+00030700: 2020 2020 7472 616e 7370 6f72 742c 205f transport, _\n+00030710: 203d 2061 7761 6974 206c 6f6f 702e 6372 = await loop.cr\n+00030720: 6561 7465 5f75 6e69 785f 636f 6e6e 6563 eate_unix_connec\n+00030730: 7469 6f6e 286c 616d 6264 613a 2073 656c tion(lambda: sel\n+00030740: 662c 2070 6174 6829 0a0a 2020 2020 2020 f, path).. \n+00030750: 2020 2020 2020 2320 5443 500a 2020 2020 # TCP. \n+00030760: 2020 2020 2020 2020 656c 6966 2027 706f elif 'po\n+00030770: 7274 2720 696e 206f 7074 696f 6e73 3a0a rt' in options:.\n+00030780: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00030790: 706f 7274 203d 2067 6574 5f69 6e74 286f port = get_int(o\n+000307a0: 7074 696f 6e73 2c20 2770 6f72 7427 290a ptions, 'port').\n+000307b0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000307c0: 686f 7374 203d 2067 6574 5f73 7472 286f host = get_str(o\n+000307d0: 7074 696f 6e73 2c20 2761 6464 7265 7373 ptions, 'address\n+000307e0: 272c 2027 6c6f 6361 6c68 6f73 7427 290a ', 'localhost').\n+000307f0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00030800: 6c61 6265 6c20 3d20 6627 5443 5020 736f label = f'TCP so\n+00030810: 636b 6574 207b 686f 7374 7d3a 7b70 6f72 cket {host}:{por\n+00030820: 747d 270a 0a20 2020 2020 2020 2020 2020 t}'.. \n+00030830: 2020 2020 2074 7261 6e73 706f 7274 2c20 transport, \n+00030840: 5f20 3d20 6177 6169 7420 6c6f 6f70 2e63 _ = await loop.c\n+00030850: 7265 6174 655f 636f 6e6e 6563 7469 6f6e reate_connection\n+00030860: 286c 616d 6264 613a 2073 656c 662c 2068 (lambda: self, h\n+00030870: 6f73 742c 2070 6f72 7429 0a20 2020 2020 ost, port). \n+00030880: 2020 2020 2020 2065 6c73 653a 0a20 2020 else:. \n+00030890: 2020 2020 2020 2020 2020 2020 2072 6169 rai\n+000308a0: 7365 2043 6861 6e6e 656c 4572 726f 7228 se ChannelError(\n+000308b0: 2770 726f 746f 636f 6c2d 6572 726f 7227 'protocol-error'\n+000308c0: 2c0a 2020 2020 2020 2020 2020 2020 2020 ,. \n+000308d0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000308e0: 2020 2020 206d 6573 7361 6765 3d27 6e6f message='no\n+000308f0: 2022 706f 7274 2220 6f72 2022 756e 6978 \"port\" or \"unix\n+00030900: 2220 6f72 206f 7468 6572 2061 6464 7265 \" or other addre\n+00030910: 7373 206f 7074 696f 6e20 666f 7220 6368 ss option for ch\n+00030920: 616e 6e65 6c27 290a 0a20 2020 2020 2020 annel').. \n+00030930: 2020 2020 206c 6f67 6765 722e 6465 6275 logger.debu\n+00030940: 6728 2753 6f63 6b65 7453 7472 6561 6d43 g('SocketStreamC\n+00030950: 6861 6e6e 656c 3a20 636f 6e6e 6563 7465 hannel: connecte\n+00030960: 6420 746f 2025 7327 2c20 6c61 6265 6c29 d to %s', label)\n+00030970: 0a20 2020 2020 2020 2065 7863 6570 7420 . except \n+00030980: 4f53 4572 726f 7220 6173 2065 7272 6f72 OSError as error\n+00030990: 3a0a 2020 2020 2020 2020 2020 2020 6c6f :. lo\n+000309a0: 6767 6572 2e69 6e66 6f28 2753 6f63 6b65 gger.info('Socke\n+000309b0: 7453 7472 6561 6d43 6861 6e6e 656c 3a20 tStreamChannel: \n+000309c0: 636f 6e6e 6563 7469 6e67 2074 6f20 2573 connecting to %s\n+000309d0: 2066 6169 6c65 643a 2025 7327 2c20 6c61 failed: %s', la\n+000309e0: 6265 6c2c 2065 7272 6f72 290a 2020 2020 bel, error). \n+000309f0: 2020 2020 2020 2020 6966 2069 7369 6e73 if isins\n+00030a00: 7461 6e63 6528 6572 726f 722c 2043 6f6e tance(error, Con\n+00030a10: 6e65 6374 696f 6e52 6566 7573 6564 4572 nectionRefusedEr\n+00030a20: 726f 7229 3a0a 2020 2020 2020 2020 2020 ror):. \n+00030a30: 2020 2020 2020 7072 6f62 6c65 6d20 3d20 problem = \n+00030a40: 276e 6f74 2d66 6f75 6e64 270a 2020 2020 'not-found'. \n+00030a50: 2020 2020 2020 2020 656c 7365 3a0a 2020 else:. \n+00030a60: 2020 2020 2020 2020 2020 2020 2020 7072 pr\n+00030a70: 6f62 6c65 6d20 3d20 2774 6572 6d69 6e61 oblem = 'termina\n+00030a80: 7465 6427 0a20 2020 2020 2020 2020 2020 ted'. \n+00030a90: 2072 6169 7365 2043 6861 6e6e 656c 4572 raise ChannelEr\n+00030aa0: 726f 7228 7072 6f62 6c65 6d2c 206d 6573 ror(problem, mes\n+00030ab0: 7361 6765 3d73 7472 2865 7272 6f72 2929 sage=str(error))\n+00030ac0: 2066 726f 6d20 6572 726f 720a 2020 2020 from error. \n+00030ad0: 2020 2020 7365 6c66 2e63 6c6f 7365 5f6f self.close_o\n+00030ae0: 6e5f 656f 6628 290a 2020 2020 2020 2020 n_eof(). \n+00030af0: 6173 7365 7274 2069 7369 6e73 7461 6e63 assert isinstanc\n+00030b00: 6528 7472 616e 7370 6f72 742c 2061 7379 e(transport, asy\n+00030b10: 6e63 696f 2e54 7261 6e73 706f 7274 290a ncio.Transport).\n+00030b20: 2020 2020 2020 2020 7265 7475 726e 2074 return t\n+00030b30: 7261 6e73 706f 7274 0a0a 0a63 6c61 7373 ransport...class\n+00030b40: 2053 7562 7072 6f63 6573 7353 7472 6561 SubprocessStrea\n+00030b50: 6d43 6861 6e6e 656c 2850 726f 746f 636f mChannel(Protoco\n+00030b60: 6c43 6861 6e6e 656c 2c20 5375 6270 726f lChannel, Subpro\n+00030b70: 6365 7373 5072 6f74 6f63 6f6c 293a 0a20 cessProtocol):. \n+00030b80: 2020 2070 6179 6c6f 6164 203d 2027 7374 payload = 'st\n+00030b90: 7265 616d 270a 2020 2020 7265 7374 7269 ream'. restri\n+00030ba0: 6374 696f 6e73 203d 2028 2827 7370 6177 ctions = (('spaw\n+00030bb0: 6e27 2c20 4e6f 6e65 292c 290a 0a20 2020 n', None),).. \n+00030bc0: 2064 6566 2070 726f 6365 7373 5f65 7869 def process_exi\n+00030bd0: 7465 6428 7365 6c66 2920 2d3e 204e 6f6e ted(self) -> Non\n+00030be0: 653a 0a20 2020 2020 2020 2073 656c 662e e:. self.\n+00030bf0: 636c 6f73 655f 6f6e 5f65 6f66 2829 0a0a close_on_eof()..\n+00030c00: 2020 2020 6465 6620 5f67 6574 5f63 6c6f def _get_clo\n+00030c10: 7365 5f61 7267 7328 7365 6c66 2920 2d3e se_args(self) ->\n+00030c20: 204a 736f 6e4f 626a 6563 743a 0a20 2020 JsonObject:. \n+00030c30: 2020 2020 2061 7373 6572 7420 6973 696e assert isin\n+00030c40: 7374 616e 6365 2873 656c 662e 5f74 7261 stance(self._tra\n+00030c50: 6e73 706f 7274 2c20 5375 6270 726f 6365 nsport, Subproce\n+00030c60: 7373 5472 616e 7370 6f72 7429 0a20 2020 ssTransport). \n+00030c70: 2020 2020 2061 7267 733a 204a 736f 6e44 args: JsonD\n+00030c80: 6963 7420 3d20 7b27 6578 6974 2d73 7461 ict = {'exit-sta\n+00030c90: 7475 7327 3a20 7365 6c66 2e5f 7472 616e tus': self._tran\n+00030ca0: 7370 6f72 742e 6765 745f 7265 7475 726e sport.get_return\n+00030cb0: 636f 6465 2829 7d0a 2020 2020 2020 2020 code()}. \n+00030cc0: 7374 6465 7272 203d 2073 656c 662e 5f74 stderr = self._t\n+00030cd0: 7261 6e73 706f 7274 2e67 6574 5f73 7464 ransport.get_std\n+00030ce0: 6572 7228 290a 2020 2020 2020 2020 6966 err(). if\n+00030cf0: 2073 7464 6572 7220 6973 206e 6f74 204e stderr is not N\n+00030d00: 6f6e 653a 0a20 2020 2020 2020 2020 2020 one:. \n+00030d10: 2061 7267 735b 276d 6573 7361 6765 275d args['message']\n+00030d20: 203d 2073 7464 6572 720a 2020 2020 2020 = stderr. \n+00030d30: 2020 7265 7475 726e 2061 7267 730a 0a20 return args.. \n+00030d40: 2020 2064 6566 2064 6f5f 6f70 7469 6f6e def do_option\n+00030d50: 7328 7365 6c66 2c20 6f70 7469 6f6e 7329 s(self, options)\n+00030d60: 3a0a 2020 2020 2020 2020 7769 6e64 6f77 :. window\n+00030d70: 203d 2067 6574 5f6f 626a 6563 7428 6f70 = get_object(op\n+00030d80: 7469 6f6e 732c 2027 7769 6e64 6f77 272c tions, 'window',\n+00030d90: 2057 696e 646f 7753 697a 652c 204e 6f6e WindowSize, Non\n+00030da0: 6529 0a20 2020 2020 2020 2069 6620 7769 e). if wi\n+00030db0: 6e64 6f77 2069 7320 6e6f 7420 4e6f 6e65 ndow is not None\n+00030dc0: 3a0a 2020 2020 2020 2020 2020 2020 7365 :. se\n+00030dd0: 6c66 2e5f 7472 616e 7370 6f72 742e 7365 lf._transport.se\n+00030de0: 745f 7769 6e64 6f77 5f73 697a 6528 7769 t_window_size(wi\n+00030df0: 6e64 6f77 290a 0a20 2020 2061 7379 6e63 ndow).. async\n+00030e00: 2064 6566 2063 7265 6174 655f 7472 616e def create_tran\n+00030e10: 7370 6f72 7428 7365 6c66 2c20 6c6f 6f70 sport(self, loop\n+00030e20: 3a20 6173 796e 6369 6f2e 4162 7374 7261 : asyncio.Abstra\n+00030e30: 6374 4576 656e 744c 6f6f 702c 206f 7074 ctEventLoop, opt\n+00030e40: 696f 6e73 3a20 4a73 6f6e 4f62 6a65 6374 ions: JsonObject\n+00030e50: 2920 2d3e 2053 7562 7072 6f63 6573 7354 ) -> SubprocessT\n+00030e60: 7261 6e73 706f 7274 3a0a 2020 2020 2020 ransport:. \n+00030e70: 2020 6172 6773 203d 2067 6574 5f73 7472 args = get_str\n+00030e80: 7628 6f70 7469 6f6e 732c 2027 7370 6177 v(options, 'spaw\n+00030e90: 6e27 290a 2020 2020 2020 2020 6572 7220 n'). err \n+00030ea0: 3d20 6765 745f 656e 756d 286f 7074 696f = get_enum(optio\n+00030eb0: 6e73 2c20 2765 7272 272c 205b 276f 7574 ns, 'err', ['out\n+00030ec0: 272c 2027 6967 6e6f 7265 272c 2027 6d65 ', 'ignore', 'me\n+00030ed0: 7373 6167 6527 5d2c 2027 6d65 7373 6167 ssage'], 'messag\n+00030ee0: 6527 290a 2020 2020 2020 2020 6377 6420 e'). cwd \n+00030ef0: 3d20 6765 745f 7374 7228 6f70 7469 6f6e = get_str(option\n+00030f00: 732c 2027 6469 7265 6374 6f72 7927 2c20 s, 'directory', \n+00030f10: 272e 2729 0a20 2020 2020 2020 2070 7479 '.'). pty\n+00030f20: 203d 2067 6574 5f62 6f6f 6c28 6f70 7469 = get_bool(opti\n+00030f30: 6f6e 732c 2027 7074 7927 2c20 6465 6661 ons, 'pty', defa\n+00030f40: 756c 743d 4661 6c73 6529 0a20 2020 2020 ult=False). \n+00030f50: 2020 2077 696e 646f 7720 3d20 6765 745f window = get_\n+00030f60: 6f62 6a65 6374 286f 7074 696f 6e73 2c20 object(options, \n+00030f70: 2777 696e 646f 7727 2c20 5769 6e64 6f77 'window', Window\n+00030f80: 5369 7a65 2c20 4e6f 6e65 290a 2020 2020 Size, None). \n+00030f90: 2020 2020 656e 7669 726f 6e20 3d20 6765 environ = ge\n+00030fa0: 745f 7374 7276 286f 7074 696f 6e73 2c20 t_strv(options, \n+00030fb0: 2765 6e76 6972 6f6e 272c 205b 5d29 0a0a 'environ', [])..\n+00030fc0: 2020 2020 2020 2020 6966 2065 7272 203d if err =\n+00030fd0: 3d20 276f 7574 273a 0a20 2020 2020 2020 = 'out':. \n+00030fe0: 2020 2020 2073 7464 6572 7220 3d20 7375 stderr = su\n+00030ff0: 6270 726f 6365 7373 2e53 5444 4f55 540a bprocess.STDOUT.\n+00031000: 2020 2020 2020 2020 656c 6966 2065 7272 elif err\n+00031010: 203d 3d20 2769 676e 6f72 6527 3a0a 2020 == 'ignore':. \n+00031020: 2020 2020 2020 2020 2020 7374 6465 7272 stderr\n+00031030: 203d 2073 7562 7072 6f63 6573 732e 4445 = subprocess.DE\n+00031040: 564e 554c 4c0a 2020 2020 2020 2020 656c VNULL. el\n+00031050: 7365 3a0a 2020 2020 2020 2020 2020 2020 se:. \n+00031060: 7374 6465 7272 203d 2073 7562 7072 6f63 stderr = subproc\n+00031070: 6573 732e 5049 5045 0a0a 2020 2020 2020 ess.PIPE.. \n+00031080: 2020 656e 763a 2044 6963 745b 7374 722c env: Dict[str,\n+00031090: 2073 7472 5d20 3d20 6469 6374 286f 732e str] = dict(os.\n+000310a0: 656e 7669 726f 6e29 0a20 2020 2020 2020 environ). \n+000310b0: 2074 7279 3a0a 2020 2020 2020 2020 2020 try:. \n+000310c0: 2020 656e 762e 7570 6461 7465 2864 6963 env.update(dic\n+000310d0: 7428 652e 7370 6c69 7428 273d 272c 2031 t(e.split('=', 1\n+000310e0: 2920 666f 7220 6520 696e 2065 6e76 6972 ) for e in envir\n+000310f0: 6f6e 2929 0a20 2020 2020 2020 2065 7863 on)). exc\n+00031100: 6570 7420 5661 6c75 6545 7272 6f72 3a0a ept ValueError:.\n+00031110: 2020 2020 2020 2020 2020 2020 7261 6973 rais\n+00031120: 6520 4368 616e 6e65 6c45 7272 6f72 2827 e ChannelError('\n+00031130: 7072 6f74 6f63 6f6c 2d65 7272 6f72 272c protocol-error',\n+00031140: 206d 6573 7361 6765 3d27 696e 7661 6c69 message='invali\n+00031150: 6420 2265 6e76 6972 6f6e 2220 6f70 7469 d \"environ\" opti\n+00031160: 6f6e 2066 6f72 2073 7472 6561 6d20 6368 on for stream ch\n+00031170: 616e 6e65 6c27 2920 6672 6f6d 204e 6f6e annel') from Non\n+00031180: 650a 0a20 2020 2020 2020 2074 7279 3a0a e.. try:.\n+00031190: 2020 2020 2020 2020 2020 2020 7472 616e tran\n+000311a0: 7370 6f72 7420 3d20 5375 6270 726f 6365 sport = Subproce\n+000311b0: 7373 5472 616e 7370 6f72 7428 6c6f 6f70 ssTransport(loop\n+000311c0: 2c20 7365 6c66 2c20 6172 6773 2c20 7074 , self, args, pt\n+000311d0: 793d 7074 792c 2077 696e 646f 773d 7769 y=pty, window=wi\n+000311e0: 6e64 6f77 2c20 656e 763d 656e 762c 2063 ndow, env=env, c\n+000311f0: 7764 3d63 7764 2c20 7374 6465 7272 3d73 wd=cwd, stderr=s\n+00031200: 7464 6572 7229 0a20 2020 2020 2020 2020 tderr). \n+00031210: 2020 206c 6f67 6765 722e 6465 6275 6728 logger.debug(\n+00031220: 2753 7061 776e 6564 2070 726f 6365 7373 'Spawned process\n+00031230: 2061 7267 733d 2573 2070 6964 3d25 6927 args=%s pid=%i'\n+00031240: 2c20 6172 6773 2c20 7472 616e 7370 6f72 , args, transpor\n+00031250: 742e 6765 745f 7069 6428 2929 0a20 2020 t.get_pid()). \n+00031260: 2020 2020 2020 2020 2072 6574 7572 6e20 return \n+00031270: 7472 616e 7370 6f72 740a 2020 2020 2020 transport. \n+00031280: 2020 6578 6365 7074 2046 696c 654e 6f74 except FileNot\n+00031290: 466f 756e 6445 7272 6f72 2061 7320 6572 FoundError as er\n+000312a0: 726f 723a 0a20 2020 2020 2020 2020 2020 ror:. \n+000312b0: 2072 6169 7365 2043 6861 6e6e 656c 4572 raise ChannelEr\n+000312c0: 726f 7228 276e 6f74 2d66 6f75 6e64 2729 ror('not-found')\n+000312d0: 2066 726f 6d20 6572 726f 720a 2020 2020 from error. \n+000312e0: 2020 2020 6578 6365 7074 2050 6572 6d69 except Permi\n+000312f0: 7373 696f 6e45 7272 6f72 2061 7320 6572 ssionError as er\n+00031300: 726f 723a 0a20 2020 2020 2020 2020 2020 ror:. \n+00031310: 2072 6169 7365 2043 6861 6e6e 656c 4572 raise ChannelEr\n+00031320: 726f 7228 2761 6363 6573 732d 6465 6e69 ror('access-deni\n+00031330: 6564 2729 2066 726f 6d20 6572 726f 720a ed') from error.\n+00031340: 2020 2020 2020 2020 6578 6365 7074 204f except O\n+00031350: 5345 7272 6f72 2061 7320 6572 726f 723a SError as error:\n+00031360: 0a20 2020 2020 2020 2020 2020 206c 6f67 . log\n+00031370: 6765 722e 696e 666f 2822 4661 696c 6564 ger.info(\"Failed\n+00031380: 2074 6f20 7370 6177 6e20 2573 3a20 2573 to spawn %s: %s\n+00031390: 222c 2061 7267 732c 2073 7472 2865 7272 \", args, str(err\n+000313a0: 6f72 2929 0a20 2020 2020 2020 2020 2020 or)). \n+000313b0: 2072 6169 7365 2043 6861 6e6e 656c 4572 raise ChannelEr\n+000313c0: 726f 7228 2769 6e74 6572 6e61 6c2d 6572 ror('internal-er\n+000313d0: 726f 7227 2920 6672 6f6d 2065 7272 6f72 ror') from error\n+000313e0: 0a27 2727 2c0a 2020 2763 6f63 6b70 6974 .''',. 'cockpit\n+000313f0: 2f63 6861 6e6e 656c 732f 7472 6976 6961 /channels/trivia\n+00031400: 6c2e 7079 273a 2062 7227 2727 2320 5468 l.py': br'''# Th\n+00031410: 6973 2066 696c 6520 6973 2070 6172 7420 is file is part \n+00031420: 6f66 2043 6f63 6b70 6974 2e0a 230a 2320 of Cockpit..#.# \n+00031430: 436f 7079 7269 6768 7420 2843 2920 3230 Copyright (C) 20\n+00031440: 3232 2052 6564 2048 6174 2c20 496e 632e 22 Red Hat, Inc.\n+00031450: 0a23 0a23 2054 6869 7320 7072 6f67 7261 .#.# This progra\n+00031460: 6d20 6973 2066 7265 6520 736f 6674 7761 m is free softwa\n+00031470: 7265 3a20 796f 7520 6361 6e20 7265 6469 re: you can redi\n+00031480: 7374 7269 6275 7465 2069 7420 616e 642f stribute it and/\n+00031490: 6f72 206d 6f64 6966 790a 2320 6974 2075 or modify.# it u\n+000314a0: 6e64 6572 2074 6865 2074 6572 6d73 206f nder the terms o\n+000314b0: 6620 7468 6520 474e 5520 4765 6e65 7261 f the GNU Genera\n+000314c0: 6c20 5075 626c 6963 204c 6963 656e 7365 l Public License\n+000314d0: 2061 7320 7075 626c 6973 6865 6420 6279 as published by\n+000314e0: 0a23 2074 6865 2046 7265 6520 536f 6674 .# the Free Soft\n+000314f0: 7761 7265 2046 6f75 6e64 6174 696f 6e2c ware Foundation,\n+00031500: 2065 6974 6865 7220 7665 7273 696f 6e20 either version \n+00031510: 3320 6f66 2074 6865 204c 6963 656e 7365 3 of the License\n+00031520: 2c20 6f72 0a23 2028 6174 2079 6f75 7220 , or.# (at your \n+00031530: 6f70 7469 6f6e 2920 616e 7920 6c61 7465 option) any late\n+00031540: 7220 7665 7273 696f 6e2e 0a23 0a23 2054 r version..#.# T\n+00031550: 6869 7320 7072 6f67 7261 6d20 6973 2064 his program is d\n+00031560: 6973 7472 6962 7574 6564 2069 6e20 7468 istributed in th\n+00031570: 6520 686f 7065 2074 6861 7420 6974 2077 e hope that it w\n+00031580: 696c 6c20 6265 2075 7365 6675 6c2c 0a23 ill be useful,.#\n+00031590: 2062 7574 2057 4954 484f 5554 2041 4e59 but WITHOUT ANY\n+000315a0: 2057 4152 5241 4e54 593b 2077 6974 686f WARRANTY; witho\n+000315b0: 7574 2065 7665 6e20 7468 6520 696d 706c ut even the impl\n+000315c0: 6965 6420 7761 7272 616e 7479 206f 660a ied warranty of.\n+000315d0: 2320 4d45 5243 4841 4e54 4142 494c 4954 # MERCHANTABILIT\n+000315e0: 5920 6f72 2046 4954 4e45 5353 2046 4f52 Y or FITNESS FOR\n+000315f0: 2041 2050 4152 5449 4355 4c41 5220 5055 A PARTICULAR PU\n+00031600: 5250 4f53 452e 2020 5365 6520 7468 650a RPOSE. See the.\n+00031610: 2320 474e 5520 4765 6e65 7261 6c20 5075 # GNU General Pu\n+00031620: 626c 6963 204c 6963 656e 7365 2066 6f72 blic License for\n+00031630: 206d 6f72 6520 6465 7461 696c 732e 0a23 more details..#\n+00031640: 0a23 2059 6f75 2073 686f 756c 6420 6861 .# You should ha\n+00031650: 7665 2072 6563 6569 7665 6420 6120 636f ve received a co\n+00031660: 7079 206f 6620 7468 6520 474e 5520 4765 py of the GNU Ge\n+00031670: 6e65 7261 6c20 5075 626c 6963 204c 6963 neral Public Lic\n+00031680: 656e 7365 0a23 2061 6c6f 6e67 2077 6974 ense.# along wit\n+00031690: 6820 7468 6973 2070 726f 6772 616d 2e20 h this program. \n+000316a0: 2049 6620 6e6f 742c 2073 6565 203c 6874 If not, see <ht\n+000316b0: 7470 733a 2f2f 7777 772e 676e 752e 6f72 tps://www.gnu.or\n+000316c0: 672f 6c69 6365 6e73 6573 2f3e 2e0a 0a69 g/licenses/>...i\n+000316d0: 6d70 6f72 7420 6c6f 6767 696e 670a 0a66 mport logging..f\n+000316e0: 726f 6d20 2e2e 6368 616e 6e65 6c20 696d rom ..channel im\n+000316f0: 706f 7274 2043 6861 6e6e 656c 0a0a 6c6f port Channel..lo\n+00031700: 6767 6572 203d 206c 6f67 6769 6e67 2e67 gger = logging.g\n+00031710: 6574 4c6f 6767 6572 285f 5f6e 616d 655f etLogger(__name_\n+00031720: 5f29 0a0a 0a63 6c61 7373 2045 6368 6f43 _)...class EchoC\n+00031730: 6861 6e6e 656c 2843 6861 6e6e 656c 293a hannel(Channel):\n+00031740: 0a20 2020 2070 6179 6c6f 6164 203d 2027 . payload = '\n+00031750: 6563 686f 270a 0a20 2020 2064 6566 2064 echo'.. def d\n+00031760: 6f5f 6f70 656e 2873 656c 662c 206f 7074 o_open(self, opt\n+00031770: 696f 6e73 293a 0a20 2020 2020 2020 2073 ions):. s\n+00031780: 656c 662e 7265 6164 7928 290a 0a20 2020 elf.ready().. \n+00031790: 2064 6566 2064 6f5f 6461 7461 2873 656c def do_data(sel\n+000317a0: 662c 2064 6174 6129 3a0a 2020 2020 2020 f, data):. \n+000317b0: 2020 7365 6c66 2e73 656e 645f 6461 7461 self.send_data\n+000317c0: 2864 6174 6129 0a0a 2020 2020 6465 6620 (data).. def \n+000317d0: 646f 5f64 6f6e 6528 7365 6c66 293a 0a20 do_done(self):. \n+000317e0: 2020 2020 2020 2073 656c 662e 646f 6e65 self.done\n+000317f0: 2829 0a20 2020 2020 2020 2073 656c 662e (). self.\n+00031800: 636c 6f73 6528 290a 0a0a 636c 6173 7320 close()...class \n+00031810: 4e75 6c6c 4368 616e 6e65 6c28 4368 616e NullChannel(Chan\n+00031820: 6e65 6c29 3a0a 2020 2020 7061 796c 6f61 nel):. payloa\n+00031830: 6420 3d20 276e 756c 6c27 0a0a 2020 2020 d = 'null'.. \n+00031840: 6465 6620 646f 5f6f 7065 6e28 7365 6c66 def do_open(self\n+00031850: 2c20 6f70 7469 6f6e 7329 3a0a 2020 2020 , options):. \n+00031860: 2020 2020 7365 6c66 2e72 6561 6479 2829 self.ready()\n+00031870: 0a0a 2020 2020 6465 6620 646f 5f63 6c6f .. def do_clo\n+00031880: 7365 2873 656c 6629 3a0a 2020 2020 2020 se(self):. \n+00031890: 2020 7365 6c66 2e63 6c6f 7365 2829 0a27 self.close().'\n+000318a0: 2727 2c0a 2020 2763 6f63 6b70 6974 2f63 '',. 'cockpit/c\n+000318b0: 6861 6e6e 656c 732f 7061 636b 6167 6573 hannels/packages\n+000318c0: 2e70 7927 3a20 6272 2727 2723 2054 6869 .py': br'''# Thi\n+000318d0: 7320 6669 6c65 2069 7320 7061 7274 206f s file is part o\n+000318e0: 6620 436f 636b 7069 742e 0a23 0a23 2043 f Cockpit..#.# C\n+000318f0: 6f70 7972 6967 6874 2028 4329 2032 3032 opyright (C) 202\n+00031900: 3220 5265 6420 4861 742c 2049 6e63 2e0a 2 Red Hat, Inc..\n+00031910: 230a 2320 5468 6973 2070 726f 6772 616d #.# This program\n+00031920: 2069 7320 6672 6565 2073 6f66 7477 6172 is free softwar\n+00031930: 653a 2079 6f75 2063 616e 2072 6564 6973 e: you can redis\n+00031940: 7472 6962 7574 6520 6974 2061 6e64 2f6f tribute it and/o\n+00031950: 7220 6d6f 6469 6679 0a23 2069 7420 756e r modify.# it un\n+00031960: 6465 7220 7468 6520 7465 726d 7320 6f66 der the terms of\n+00031970: 2074 6865 2047 4e55 2047 656e 6572 616c the GNU General\n+00031980: 2050 7562 6c69 6320 4c69 6365 6e73 6520 Public License \n+00031990: 6173 2070 7562 6c69 7368 6564 2062 790a as published by.\n+000319a0: 2320 7468 6520 4672 6565 2053 6f66 7477 # the Free Softw\n+000319b0: 6172 6520 466f 756e 6461 7469 6f6e 2c20 are Foundation, \n+000319c0: 6569 7468 6572 2076 6572 7369 6f6e 2033 either version 3\n+000319d0: 206f 6620 7468 6520 4c69 6365 6e73 652c of the License,\n+000319e0: 206f 720a 2320 2861 7420 796f 7572 206f or.# (at your o\n+000319f0: 7074 696f 6e29 2061 6e79 206c 6174 6572 ption) any later\n+00031a00: 2076 6572 7369 6f6e 2e0a 230a 2320 5468 version..#.# Th\n+00031a10: 6973 2070 726f 6772 616d 2069 7320 6469 is program is di\n+00031a20: 7374 7269 6275 7465 6420 696e 2074 6865 stributed in the\n+00031a30: 2068 6f70 6520 7468 6174 2069 7420 7769 hope that it wi\n+00031a40: 6c6c 2062 6520 7573 6566 756c 2c0a 2320 ll be useful,.# \n+00031a50: 6275 7420 5749 5448 4f55 5420 414e 5920 but WITHOUT ANY \n+00031a60: 5741 5252 414e 5459 3b20 7769 7468 6f75 WARRANTY; withou\n+00031a70: 7420 6576 656e 2074 6865 2069 6d70 6c69 t even the impli\n+00031a80: 6564 2077 6172 7261 6e74 7920 6f66 0a23 ed warranty of.#\n+00031a90: 204d 4552 4348 414e 5441 4249 4c49 5459 MERCHANTABILITY\n+00031aa0: 206f 7220 4649 544e 4553 5320 464f 5220 or FITNESS FOR \n+00031ab0: 4120 5041 5254 4943 554c 4152 2050 5552 A PARTICULAR PUR\n+00031ac0: 504f 5345 2e20 2053 6565 2074 6865 0a23 POSE. See the.#\n+00031ad0: 2047 4e55 2047 656e 6572 616c 2050 7562 GNU General Pub\n+00031ae0: 6c69 6320 4c69 6365 6e73 6520 666f 7220 lic License for \n+00031af0: 6d6f 7265 2064 6574 6169 6c73 2e0a 230a more details..#.\n+00031b00: 2320 596f 7520 7368 6f75 6c64 2068 6176 # You should hav\n+00031b10: 6520 7265 6365 6976 6564 2061 2063 6f70 e received a cop\n+00031b20: 7920 6f66 2074 6865 2047 4e55 2047 656e y of the GNU Gen\n+00031b30: 6572 616c 2050 7562 6c69 6320 4c69 6365 eral Public Lice\n+00031b40: 6e73 650a 2320 616c 6f6e 6720 7769 7468 nse.# along with\n+00031b50: 2074 6869 7320 7072 6f67 7261 6d2e 2020 this program. \n+00031b60: 4966 206e 6f74 2c20 7365 6520 3c68 7474 If not, see <htt\n+00031b70: 7073 3a2f 2f77 7777 2e67 6e75 2e6f 7267 ps://www.gnu.org\n+00031b80: 2f6c 6963 656e 7365 732f 3e2e 0a0a 696d /licenses/>...im\n+00031b90: 706f 7274 206c 6f67 6769 6e67 0a66 726f port logging.fro\n+00031ba0: 6d20 7479 7069 6e67 2069 6d70 6f72 7420 m typing import \n+00031bb0: 4f70 7469 6f6e 616c 0a0a 6672 6f6d 202e Optional..from .\n+00031bc0: 2e63 6861 6e6e 656c 2069 6d70 6f72 7420 .channel import \n+00031bd0: 4173 796e 6343 6861 6e6e 656c 0a66 726f AsyncChannel.fro\n+00031be0: 6d20 2e2e 6461 7461 2069 6d70 6f72 7420 m ..data import \n+00031bf0: 7265 6164 5f63 6f63 6b70 6974 5f64 6174 read_cockpit_dat\n+00031c00: 615f 6669 6c65 0a66 726f 6d20 2e2e 6a73 a_file.from ..js\n+00031c10: 6f6e 7574 696c 2069 6d70 6f72 7420 4a73 onutil import Js\n+00031c20: 6f6e 4f62 6a65 6374 2c20 6765 745f 6469 onObject, get_di\n+00031c30: 6374 2c20 6765 745f 7374 720a 6672 6f6d ct, get_str.from\n+00031c40: 202e 2e70 6163 6b61 6765 7320 696d 706f ..packages impo\n+00031c50: 7274 2050 6163 6b61 6765 730a 0a6c 6f67 rt Packages..log\n+00031c60: 6765 7220 3d20 6c6f 6767 696e 672e 6765 ger = logging.ge\n+00031c70: 744c 6f67 6765 7228 5f5f 6e61 6d65 5f5f tLogger(__name__\n+00031c80: 290a 0a0a 636c 6173 7320 5061 636b 6167 )...class Packag\n+00031c90: 6573 4368 616e 6e65 6c28 4173 796e 6343 esChannel(AsyncC\n+00031ca0: 6861 6e6e 656c 293a 0a20 2020 2070 6179 hannel):. pay\n+00031cb0: 6c6f 6164 203d 2027 6874 7470 2d73 7472 load = 'http-str\n+00031cc0: 6561 6d31 270a 2020 2020 7265 7374 7269 eam1'. restri\n+00031cd0: 6374 696f 6e73 203d 205b 2822 696e 7465 ctions = [(\"inte\n+00031ce0: 726e 616c 222c 2022 7061 636b 6167 6573 rnal\", \"packages\n+00031cf0: 2229 5d0a 0a20 2020 2023 2075 7365 6420 \")].. # used \n+00031d00: 746f 2063 6172 7279 2064 6174 6120 666f to carry data fo\n+00031d10: 7277 6172 6420 6672 6f6d 206f 7065 6e20 rward from open \n+00031d20: 746f 2064 6f6e 650a 2020 2020 6f70 7469 to done. opti\n+00031d30: 6f6e 733a 204f 7074 696f 6e61 6c5b 4a73 ons: Optional[Js\n+00031d40: 6f6e 4f62 6a65 6374 5d20 3d20 4e6f 6e65 onObject] = None\n+00031d50: 0a0a 2020 2020 6465 6620 6874 7470 5f65 .. def http_e\n+00031d60: 7272 6f72 2873 656c 662c 2073 7461 7475 rror(self, statu\n+00031d70: 733a 2069 6e74 2c20 6d65 7373 6167 653a s: int, message:\n+00031d80: 2073 7472 2920 2d3e 204e 6f6e 653a 0a20 str) -> None:. \n+00031d90: 2020 2020 2020 2074 656d 706c 6174 6520 template \n+00031da0: 3d20 7265 6164 5f63 6f63 6b70 6974 5f64 = read_cockpit_d\n+00031db0: 6174 615f 6669 6c65 2827 6661 696c 2e68 ata_file('fail.h\n+00031dc0: 746d 6c27 290a 2020 2020 2020 2020 7365 tml'). se\n+00031dd0: 6c66 2e73 656e 645f 6a73 6f6e 2873 7461 lf.send_json(sta\n+00031de0: 7475 733d 7374 6174 7573 2c20 7265 6173 tus=status, reas\n+00031df0: 6f6e 3d27 4552 524f 5227 2c20 6865 6164 on='ERROR', head\n+00031e00: 6572 733d 7b27 436f 6e74 656e 742d 5479 ers={'Content-Ty\n+00031e10: 7065 273a 2027 7465 7874 2f68 746d 6c3b pe': 'text/html;\n+00031e20: 2063 6861 7273 6574 3d75 7466 2d38 277d charset=utf-8'}\n+00031e30: 290a 2020 2020 2020 2020 7365 6c66 2e73 ). self.s\n+00031e40: 656e 645f 6461 7461 2874 656d 706c 6174 end_data(templat\n+00031e50: 652e 7265 706c 6163 6528 6227 4040 6d65 e.replace(b'@@me\n+00031e60: 7373 6167 6540 4027 2c20 6d65 7373 6167 ssage@@', messag\n+00031e70: 652e 656e 636f 6465 2827 7574 662d 3827 e.encode('utf-8'\n+00031e80: 2929 290a 2020 2020 2020 2020 7365 6c66 ))). self\n+00031e90: 2e64 6f6e 6528 290a 2020 2020 2020 2020 .done(). \n+00031ea0: 7365 6c66 2e63 6c6f 7365 2829 0a0a 2020 self.close().. \n+00031eb0: 2020 6173 796e 6320 6465 6620 7275 6e28 async def run(\n+00031ec0: 7365 6c66 2c20 6f70 7469 6f6e 733a 204a self, options: J\n+00031ed0: 736f 6e4f 626a 6563 7429 202d 3e20 4e6f sonObject) -> No\n+00031ee0: 6e65 3a0a 2020 2020 2020 2020 7061 636b ne:. pack\n+00031ef0: 6167 6573 3a20 5061 636b 6167 6573 203d ages: Packages =\n+00031f00: 2073 656c 662e 726f 7574 6572 2e70 6163 self.router.pac\n+00031f10: 6b61 6765 7320 2023 2074 7970 653a 2069 kages # type: i\n+00031f20: 676e 6f72 655b 6174 7472 2d64 6566 696e gnore[attr-defin\n+00031f30: 6564 5d20 2023 2079 6573 2c20 7468 6973 ed] # yes, this\n+00031f40: 2069 7320 6576 696c 0a0a 2020 2020 2020 is evil.. \n+00031f50: 2020 7472 793a 0a20 2020 2020 2020 2020 try:. \n+00031f60: 2020 2069 6620 6765 745f 7374 7228 6f70 if get_str(op\n+00031f70: 7469 6f6e 732c 2027 6d65 7468 6f64 2729 tions, 'method')\n+00031f80: 2021 3d20 2747 4554 273a 0a20 2020 2020 != 'GET':. \n+00031f90: 2020 2020 2020 2020 2020 2072 6169 7365 raise\n+00031fa0: 2056 616c 7565 4572 726f 7228 6627 556e ValueError(f'Un\n+00031fb0: 7375 7070 6f72 7465 6420 4854 5450 206d supported HTTP m\n+00031fc0: 6574 686f 6420 7b6f 7074 696f 6e73 5b22 ethod {options[\"\n+00031fd0: 6d65 7468 6f64 225d 7d27 290a 0a20 2020 method\"]}').. \n+00031fe0: 2020 2020 2020 2020 2073 656c 662e 7265 self.re\n+00031ff0: 6164 7928 290a 2020 2020 2020 2020 2020 ady(). \n+00032000: 2020 6966 2061 7761 6974 2073 656c 662e if await self.\n+00032010: 7265 6164 2829 2069 7320 6e6f 7420 4e6f read() is not No\n+00032020: 6e65 3a0a 2020 2020 2020 2020 2020 2020 ne:. \n+00032030: 2020 2020 7261 6973 6520 5661 6c75 6545 raise ValueE\n+00032040: 7272 6f72 2827 5265 6365 6976 6564 2075 rror('Received u\n+00032050: 6e65 7870 6563 7465 6420 6461 7461 2729 nexpected data')\n+00032060: 0a0a 2020 2020 2020 2020 2020 2020 7061 .. pa\n+00032070: 7468 203d 2067 6574 5f73 7472 286f 7074 th = get_str(opt\n+00032080: 696f 6e73 2c20 2770 6174 6827 290a 2020 ions, 'path'). \n+00032090: 2020 2020 2020 2020 2020 6865 6164 6572 header\n+000320a0: 7320 3d20 6765 745f 6469 6374 286f 7074 s = get_dict(opt\n+000320b0: 696f 6e73 2c20 2768 6561 6465 7273 2729 ions, 'headers')\n+000320c0: 0a20 2020 2020 2020 2020 2020 2064 6f63 . doc\n+000320d0: 756d 656e 7420 3d20 7061 636b 6167 6573 ument = packages\n+000320e0: 2e6c 6f61 645f 7061 7468 2870 6174 682c .load_path(path,\n+000320f0: 2068 6561 6465 7273 290a 0a20 2020 2020 headers).. \n+00032100: 2020 2020 2020 2023 204e 6f74 653a 2077 # Note: w\n+00032110: 6520 6361 6e27 7420 6361 6368 6520 646f e can't cache do\n+00032120: 6375 6d65 6e74 7320 7269 6768 7420 6e6f cuments right no\n+00032130: 772e 2020 5365 650a 2020 2020 2020 2020 w. See. \n+00032140: 2020 2020 2320 6874 7470 733a 2f2f 6769 # https://gi\n+00032150: 7468 7562 2e63 6f6d 2f63 6f63 6b70 6974 thub.com/cockpit\n+00032160: 2d70 726f 6a65 6374 2f63 6f63 6b70 6974 -project/cockpit\n+00032170: 2f69 7373 7565 732f 3139 3037 310a 2020 /issues/19071. \n+00032180: 2020 2020 2020 2020 2020 2320 666f 7220 # for \n+00032190: 6675 7475 7265 2070 6c61 6e73 2e0a 2020 future plans.. \n+000321a0: 2020 2020 2020 2020 2020 6f75 745f 6865 out_he\n+000321b0: 6164 6572 7320 3d20 7b0a 2020 2020 2020 aders = {. \n+000321c0: 2020 2020 2020 2020 2020 2743 6163 6865 'Cache\n+000321d0: 2d43 6f6e 7472 6f6c 273a 2027 6e6f 2d63 -Control': 'no-c\n+000321e0: 6163 6865 2c20 6e6f 2d73 746f 7265 272c ache, no-store',\n+000321f0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+00032200: 2027 436f 6e74 656e 742d 5479 7065 273a 'Content-Type':\n+00032210: 2064 6f63 756d 656e 742e 636f 6e74 656e document.conten\n+00032220: 745f 7479 7065 2c0a 2020 2020 2020 2020 t_type,. \n+00032230: 2020 2020 7d0a 0a20 2020 2020 2020 2020 }.. \n+00032240: 2020 2069 6620 646f 6375 6d65 6e74 2e63 if document.c\n+00032250: 6f6e 7465 6e74 5f65 6e63 6f64 696e 6720 ontent_encoding \n+00032260: 6973 206e 6f74 204e 6f6e 653a 0a20 2020 is not None:. \n+00032270: 2020 2020 2020 2020 2020 2020 206f 7574 out\n+00032280: 5f68 6561 6465 7273 5b27 436f 6e74 656e _headers['Conten\n+00032290: 742d 456e 636f 6469 6e67 275d 203d 2064 t-Encoding'] = d\n+000322a0: 6f63 756d 656e 742e 636f 6e74 656e 745f ocument.content_\n+000322b0: 656e 636f 6469 6e67 0a0a 2020 2020 2020 encoding.. \n+000322c0: 2020 2020 2020 6966 2064 6f63 756d 656e if documen\n+000322d0: 742e 636f 6e74 656e 745f 7365 6375 7269 t.content_securi\n+000322e0: 7479 5f70 6f6c 6963 7920 6973 206e 6f74 ty_policy is not\n+000322f0: 204e 6f6e 653a 0a20 2020 2020 2020 2020 None:. \n+00032300: 2020 2020 2020 2070 6f6c 6963 7920 3d20 policy = \n+00032310: 646f 6375 6d65 6e74 2e63 6f6e 7465 6e74 document.content\n+00032320: 5f73 6563 7572 6974 795f 706f 6c69 6379 _security_policy\n+00032330: 0a0a 2020 2020 2020 2020 2020 2020 2020 .. \n+00032340: 2020 2320 6874 7470 733a 2f2f 6465 7665 # https://deve\n+00032350: 6c6f 7065 722e 6d6f 7a69 6c6c 612e 6f72 loper.mozilla.or\n+00032360: 672f 656e 2d55 532f 646f 6373 2f57 6562 g/en-US/docs/Web\n+00032370: 2f48 5454 502f 4865 6164 6572 732f 436f /HTTP/Headers/Co\n+00032380: 6e74 656e 742d 5365 6375 7269 7479 2d50 ntent-Security-P\n+00032390: 6f6c 6963 792f 636f 6e6e 6563 742d 7372 olicy/connect-sr\n+000323a0: 630a 2020 2020 2020 2020 2020 2020 2020 c. \n+000323b0: 2020 230a 2020 2020 2020 2020 2020 2020 #. \n+000323c0: 2020 2020 2320 2020 204e 6f74 653a 2063 # Note: c\n+000323d0: 6f6e 6e65 6374 2d73 7263 2027 7365 6c66 onnect-src 'self\n+000323e0: 2720 646f 6573 206e 6f74 2072 6573 6f6c ' does not resol\n+000323f0: 7665 2074 6f20 7765 6273 6f63 6b65 740a ve to websocket.\n+00032400: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00032410: 2320 2020 2073 6368 656d 6573 2069 6e20 # schemes in \n+00032420: 616c 6c20 6272 6f77 7365 7273 2c20 6d6f all browsers, mo\n+00032430: 7265 2069 6e66 6f20 696e 2074 6869 7320 re info in this \n+00032440: 6973 7375 652e 0a20 2020 2020 2020 2020 issue.. \n+00032450: 2020 2020 2020 2023 0a20 2020 2020 2020 #. \n+00032460: 2020 2020 2020 2020 2023 2068 7474 7073 # https\n+00032470: 3a2f 2f67 6974 6875 622e 636f 6d2f 7733 ://github.com/w3\n+00032480: 632f 7765 6261 7070 7365 632d 6373 702f c/webappsec-csp/\n+00032490: 6973 7375 6573 2f37 0a20 2020 2020 2020 issues/7. \n+000324a0: 2020 2020 2020 2020 2069 6620 2263 6f6e if \"con\n+000324b0: 6e65 6374 2d73 7263 2027 7365 6c66 273b nect-src 'self';\n+000324c0: 2220 696e 2070 6f6c 6963 793a 0a20 2020 \" in policy:. \n+000324d0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000324e0: 2070 726f 746f 636f 6c20 3d20 6865 6164 protocol = head\n+000324f0: 6572 732e 6765 7428 2758 2d46 6f72 7761 ers.get('X-Forwa\n+00032500: 7264 6564 2d50 726f 746f 2729 0a20 2020 rded-Proto'). \n+00032510: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00032520: 2068 6f73 7420 3d20 6865 6164 6572 732e host = headers.\n+00032530: 6765 7428 2758 2d46 6f72 7761 7264 6564 get('X-Forwarded\n+00032540: 2d48 6f73 7427 290a 2020 2020 2020 2020 -Host'). \n+00032550: 2020 2020 2020 2020 2020 2020 6966 206e if n\n+00032560: 6f74 2069 7369 6e73 7461 6e63 6528 7072 ot isinstance(pr\n+00032570: 6f74 6f63 6f6c 2c20 7374 7229 206f 7220 otocol, str) or \n+00032580: 6e6f 7420 6973 696e 7374 616e 6365 2868 not isinstance(h\n+00032590: 6f73 742c 2073 7472 293a 0a20 2020 2020 ost, str):. \n+000325a0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000325b0: 2020 2072 6169 7365 2056 616c 7565 4572 raise ValueEr\n+000325c0: 726f 7228 2749 6e76 616c 6964 2068 6f73 ror('Invalid hos\n+000325d0: 7420 6f72 2070 726f 746f 636f 6c20 6865 t or protocol he\n+000325e0: 6164 6572 2729 0a0a 2020 2020 2020 2020 ader').. \n+000325f0: 2020 2020 2020 2020 2020 2020 7765 6273 webs\n+00032600: 6f63 6b65 745f 7363 6865 6d65 203d 2022 ocket_scheme = \"\n+00032610: 7773 7322 2069 6620 7072 6f74 6f63 6f6c wss\" if protocol\n+00032620: 203d 3d20 2268 7474 7073 2220 656c 7365 == \"https\" else\n+00032630: 2022 7773 220a 2020 2020 2020 2020 2020 \"ws\". \n+00032640: 2020 2020 2020 2020 2020 7765 6273 6f63 websoc\n+00032650: 6b65 745f 6f72 6967 696e 203d 2066 227b ket_origin = f\"{\n+00032660: 7765 6273 6f63 6b65 745f 7363 6865 6d65 websocket_scheme\n+00032670: 7d3a 2f2f 7b68 6f73 747d 220a 2020 2020 }://{host}\". \n+00032680: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00032690: 706f 6c69 6379 203d 2070 6f6c 6963 792e policy = policy.\n+000326a0: 7265 706c 6163 6528 2263 6f6e 6e65 6374 replace(\"connect\n+000326b0: 2d73 7263 2027 7365 6c66 273b 222c 2066 -src 'self';\", f\n+000326c0: 2263 6f6e 6e65 6374 2d73 7263 207b 7765 \"connect-src {we\n+000326d0: 6273 6f63 6b65 745f 6f72 6967 696e 7d20 bsocket_origin} \n+000326e0: 2773 656c 6627 3b22 290a 0a20 2020 2020 'self';\").. \n+000326f0: 2020 2020 2020 2020 2020 206f 7574 5f68 out_h\n+00032700: 6561 6465 7273 5b27 436f 6e74 656e 742d eaders['Content-\n+00032710: 5365 6375 7269 7479 2d50 6f6c 6963 7927 Security-Policy'\n+00032720: 5d20 3d20 706f 6c69 6379 0a0a 2020 2020 ] = policy.. \n+00032730: 2020 2020 6578 6365 7074 2056 616c 7565 except Value\n+00032740: 4572 726f 7220 6173 2065 7863 3a0a 2020 Error as exc:. \n+00032750: 2020 2020 2020 2020 2020 7365 6c66 2e68 self.h\n+00032760: 7474 705f 6572 726f 7228 3430 302c 2073 ttp_error(400, s\n+00032770: 7472 2865 7863 2929 0a0a 2020 2020 2020 tr(exc)).. \n+00032780: 2020 6578 6365 7074 204b 6579 4572 726f except KeyErro\n+00032790: 723a 0a20 2020 2020 2020 2020 2020 2073 r:. s\n+000327a0: 656c 662e 6874 7470 5f65 7272 6f72 2834 elf.http_error(4\n+000327b0: 3034 2c20 274e 6f74 2066 6f75 6e64 2729 04, 'Not found')\n+000327c0: 0a0a 2020 2020 2020 2020 6578 6365 7074 .. except\n+000327d0: 204f 5345 7272 6f72 2061 7320 6578 633a OSError as exc:\n+000327e0: 0a20 2020 2020 2020 2020 2020 2073 656c . sel\n+000327f0: 662e 6874 7470 5f65 7272 6f72 2835 3030 f.http_error(500\n+00032800: 2c20 6627 496e 7465 726e 616c 2065 7272 , f'Internal err\n+00032810: 6f72 3a20 7b65 7863 2173 7d27 290a 0a20 or: {exc!s}').. \n+00032820: 2020 2020 2020 2065 6c73 653a 0a20 2020 else:. \n+00032830: 2020 2020 2020 2020 2073 656c 662e 7365 self.se\n+00032840: 6e64 5f6a 736f 6e28 7374 6174 7573 3d32 nd_json(status=2\n+00032850: 3030 2c20 7265 6173 6f6e 3d27 4f4b 272c 00, reason='OK',\n+00032860: 2068 6561 6465 7273 3d6f 7574 5f68 6561 headers=out_hea\n+00032870: 6465 7273 290a 2020 2020 2020 2020 2020 ders). \n+00032880: 2020 6177 6169 7420 7365 6c66 2e73 656e await self.sen\n+00032890: 6466 696c 6528 646f 6375 6d65 6e74 2e64 dfile(document.d\n+000328a0: 6174 6129 0a27 2727 2c0a 2020 2763 6f63 ata).''',. 'coc\n+000328b0: 6b70 6974 2f63 6861 6e6e 656c 732f 6874 kpit/channels/ht\n+000328c0: 7470 2e70 7927 3a20 6272 2727 2723 2054 tp.py': br'''# T\n+000328d0: 6869 7320 6669 6c65 2069 7320 7061 7274 his file is part\n+000328e0: 206f 6620 436f 636b 7069 742e 0a23 0a23 of Cockpit..#.#\n+000328f0: 2043 6f70 7972 6967 6874 2028 4329 2032 Copyright (C) 2\n+00032900: 3032 3220 5265 6420 4861 742c 2049 6e63 022 Red Hat, Inc\n+00032910: 2e0a 230a 2320 5468 6973 2070 726f 6772 ..#.# This progr\n+00032920: 616d 2069 7320 6672 6565 2073 6f66 7477 am is free softw\n+00032930: 6172 653a 2079 6f75 2063 616e 2072 6564 are: you can red\n+00032940: 6973 7472 6962 7574 6520 6974 2061 6e64 istribute it and\n+00032950: 2f6f 7220 6d6f 6469 6679 0a23 2069 7420 /or modify.# it \n+00032960: 756e 6465 7220 7468 6520 7465 726d 7320 under the terms \n+00032970: 6f66 2074 6865 2047 4e55 2047 656e 6572 of the GNU Gener\n+00032980: 616c 2050 7562 6c69 6320 4c69 6365 6e73 al Public Licens\n+00032990: 6520 6173 2070 7562 6c69 7368 6564 2062 e as published b\n+000329a0: 790a 2320 7468 6520 4672 6565 2053 6f66 y.# the Free Sof\n+000329b0: 7477 6172 6520 466f 756e 6461 7469 6f6e tware Foundation\n+000329c0: 2c20 6569 7468 6572 2076 6572 7369 6f6e , either version\n+000329d0: 2033 206f 6620 7468 6520 4c69 6365 6e73 3 of the Licens\n+000329e0: 652c 206f 720a 2320 2861 7420 796f 7572 e, or.# (at your\n+000329f0: 206f 7074 696f 6e29 2061 6e79 206c 6174 option) any lat\n+00032a00: 6572 2076 6572 7369 6f6e 2e0a 230a 2320 er version..#.# \n+00032a10: 5468 6973 2070 726f 6772 616d 2069 7320 This program is \n+00032a20: 6469 7374 7269 6275 7465 6420 696e 2074 distributed in t\n+00032a30: 6865 2068 6f70 6520 7468 6174 2069 7420 he hope that it \n+00032a40: 7769 6c6c 2062 6520 7573 6566 756c 2c0a will be useful,.\n+00032a50: 2320 6275 7420 5749 5448 4f55 5420 414e # but WITHOUT AN\n+00032a60: 5920 5741 5252 414e 5459 3b20 7769 7468 Y WARRANTY; with\n+00032a70: 6f75 7420 6576 656e 2074 6865 2069 6d70 out even the imp\n+00032a80: 6c69 6564 2077 6172 7261 6e74 7920 6f66 lied warranty of\n+00032a90: 0a23 204d 4552 4348 414e 5441 4249 4c49 .# MERCHANTABILI\n+00032aa0: 5459 206f 7220 4649 544e 4553 5320 464f TY or FITNESS FO\n+00032ab0: 5220 4120 5041 5254 4943 554c 4152 2050 R A PARTICULAR P\n+00032ac0: 5552 504f 5345 2e20 2053 6565 2074 6865 URPOSE. See the\n+00032ad0: 0a23 2047 4e55 2047 656e 6572 616c 2050 .# GNU General P\n+00032ae0: 7562 6c69 6320 4c69 6365 6e73 6520 666f ublic License fo\n+00032af0: 7220 6d6f 7265 2064 6574 6169 6c73 2e0a r more details..\n+00032b00: 230a 2320 596f 7520 7368 6f75 6c64 2068 #.# You should h\n+00032b10: 6176 6520 7265 6365 6976 6564 2061 2063 ave received a c\n+00032b20: 6f70 7920 6f66 2074 6865 2047 4e55 2047 opy of the GNU G\n+00032b30: 656e 6572 616c 2050 7562 6c69 6320 4c69 eneral Public Li\n+00032b40: 6365 6e73 650a 2320 616c 6f6e 6720 7769 cense.# along wi\n+00032b50: 7468 2074 6869 7320 7072 6f67 7261 6d2e th this program.\n+00032b60: 2020 4966 206e 6f74 2c20 7365 6520 3c68 If not, see <h\n+00032b70: 7474 7073 3a2f 2f77 7777 2e67 6e75 2e6f ttps://www.gnu.o\n+00032b80: 7267 2f6c 6963 656e 7365 732f 3e2e 0a0a rg/licenses/>...\n+00032b90: 696d 706f 7274 2061 7379 6e63 696f 0a69 import asyncio.i\n+00032ba0: 6d70 6f72 7420 6874 7470 2e63 6c69 656e mport http.clien\n+00032bb0: 740a 696d 706f 7274 206c 6f67 6769 6e67 t.import logging\n+00032bc0: 0a69 6d70 6f72 7420 736f 636b 6574 0a69 .import socket.i\n+00032bd0: 6d70 6f72 7420 7373 6c0a 0a66 726f 6d20 mport ssl..from \n+00032be0: 2e2e 6368 616e 6e65 6c20 696d 706f 7274 ..channel import\n+00032bf0: 2041 7379 6e63 4368 616e 6e65 6c2c 2043 AsyncChannel, C\n+00032c00: 6861 6e6e 656c 4572 726f 720a 6672 6f6d hannelError.from\n+00032c10: 202e 2e6a 736f 6e75 7469 6c20 696d 706f ..jsonutil impo\n+00032c20: 7274 204a 736f 6e4f 626a 6563 742c 2067 rt JsonObject, g\n+00032c30: 6574 5f64 6963 742c 2067 6574 5f65 6e75 et_dict, get_enu\n+00032c40: 6d2c 2067 6574 5f69 6e74 2c20 6765 745f m, get_int, get_\n+00032c50: 6f62 6a65 6374 2c20 6765 745f 7374 722c object, get_str,\n+00032c60: 2074 7970 6563 6865 636b 6564 0a0a 6c6f typechecked..lo\n+00032c70: 6767 6572 203d 206c 6f67 6769 6e67 2e67 gger = logging.g\n+00032c80: 6574 4c6f 6767 6572 285f 5f6e 616d 655f etLogger(__name_\n+00032c90: 5f29 0a0a 0a63 6c61 7373 2048 7474 7043 _)...class HttpC\n+00032ca0: 6861 6e6e 656c 2841 7379 6e63 4368 616e hannel(AsyncChan\n+00032cb0: 6e65 6c29 3a0a 2020 2020 7061 796c 6f61 nel):. payloa\n+00032cc0: 6420 3d20 2768 7474 702d 7374 7265 616d d = 'http-stream\n+00032cd0: 3227 0a0a 2020 2020 4073 7461 7469 636d 2'.. @staticm\n+00032ce0: 6574 686f 640a 2020 2020 6465 6620 6765 ethod. def ge\n+00032cf0: 745f 6865 6164 6572 7328 7265 7370 6f6e t_headers(respon\n+00032d00: 7365 3a20 6874 7470 2e63 6c69 656e 742e se: http.client.\n+00032d10: 4854 5450 5265 7370 6f6e 7365 2c20 2a2c HTTPResponse, *,\n+00032d20: 2062 696e 6172 793a 2062 6f6f 6c29 202d binary: bool) -\n+00032d30: 3e20 4a73 6f6e 4f62 6a65 6374 3a0a 2020 > JsonObject:. \n+00032d40: 2020 2020 2020 2320 4e65 7665 7220 7365 # Never se\n+00032d50: 6e64 2074 6865 7365 2068 6561 6465 7273 nd these headers\n+00032d60: 0a20 2020 2020 2020 2072 656d 6f76 6520 . remove \n+00032d70: 3d20 7b27 436f 6e6e 6563 7469 6f6e 272c = {'Connection',\n+00032d80: 2027 5472 616e 7366 6572 2d45 6e63 6f64 'Transfer-Encod\n+00032d90: 696e 6727 7d0a 0a20 2020 2020 2020 2069 ing'}.. i\n+00032da0: 6620 6e6f 7420 6269 6e61 7279 3a0a 2020 f not binary:. \n+00032db0: 2020 2020 2020 2020 2020 2320 4f6e 6c79 # Only\n+00032dc0: 2073 656e 6420 7468 6573 6520 6865 6164 send these head\n+00032dd0: 6572 7320 666f 7220 7261 7720 6269 6e61 ers for raw bina\n+00032de0: 7279 2073 7472 6561 6d73 0a20 2020 2020 ry streams. \n+00032df0: 2020 2020 2020 2072 656d 6f76 652e 7570 remove.up\n+00032e00: 6461 7465 287b 2743 6f6e 7465 6e74 2d4c date({'Content-L\n+00032e10: 656e 6774 6827 2c20 2752 616e 6765 277d ength', 'Range'}\n+00032e20: 290a 0a20 2020 2020 2020 2072 6574 7572 ).. retur\n+00032e30: 6e20 7b6b 6579 3a20 7661 6c75 6520 666f n {key: value fo\n+00032e40: 7220 6b65 792c 2076 616c 7565 2069 6e20 r key, value in \n+00032e50: 7265 7370 6f6e 7365 2e67 6574 6865 6164 response.gethead\n+00032e60: 6572 7328 2920 6966 206b 6579 206e 6f74 ers() if key not\n+00032e70: 2069 6e20 7265 6d6f 7665 7d0a 0a20 2020 in remove}.. \n+00032e80: 2040 7374 6174 6963 6d65 7468 6f64 0a20 @staticmethod. \n+00032e90: 2020 2064 6566 2063 7265 6174 655f 636c def create_cl\n+00032ea0: 6965 6e74 286f 7074 696f 6e73 3a20 4a73 ient(options: Js\n+00032eb0: 6f6e 4f62 6a65 6374 2920 2d3e 2068 7474 onObject) -> htt\n+00032ec0: 702e 636c 6965 6e74 2e48 5454 5043 6f6e p.client.HTTPCon\n+00032ed0: 6e65 6374 696f 6e3a 0a20 2020 2020 2020 nection:. \n+00032ee0: 206f 7074 5f61 6464 7265 7373 203d 2067 opt_address = g\n+00032ef0: 6574 5f73 7472 286f 7074 696f 6e73 2c20 et_str(options, \n+00032f00: 2761 6464 7265 7373 272c 2027 6c6f 6361 'address', 'loca\n+00032f10: 6c68 6f73 7427 290a 2020 2020 2020 2020 lhost'). \n+00032f20: 6f70 745f 746c 7320 3d20 6765 745f 6469 opt_tls = get_di\n+00032f30: 6374 286f 7074 696f 6e73 2c20 2774 6c73 ct(options, 'tls\n+00032f40: 272c 204e 6f6e 6529 0a20 2020 2020 2020 ', None). \n+00032f50: 206f 7074 5f75 6e69 7820 3d20 6765 745f opt_unix = get_\n+00032f60: 7374 7228 6f70 7469 6f6e 732c 2027 756e str(options, 'un\n+00032f70: 6978 272c 204e 6f6e 6529 0a20 2020 2020 ix', None). \n+00032f80: 2020 206f 7074 5f70 6f72 7420 3d20 6765 opt_port = ge\n+00032f90: 745f 696e 7428 6f70 7469 6f6e 732c 2027 t_int(options, '\n+00032fa0: 706f 7274 272c 204e 6f6e 6529 0a0a 2020 port', None).. \n+00032fb0: 2020 2020 2020 6966 206f 7074 5f74 6c73 if opt_tls\n+00032fc0: 2069 7320 6e6f 7420 4e6f 6e65 2061 6e64 is not None and\n+00032fd0: 206f 7074 5f75 6e69 7820 6973 206e 6f74 opt_unix is not\n+00032fe0: 204e 6f6e 653a 0a20 2020 2020 2020 2020 None:. \n+00032ff0: 2020 2072 6169 7365 2043 6861 6e6e 656c raise Channel\n+00033000: 4572 726f 7228 2770 726f 746f 636f 6c2d Error('protocol-\n+00033010: 6572 726f 7227 2c20 6d65 7373 6167 653d error', message=\n+00033020: 2754 4c53 206f 6e20 556e 6978 2073 6f63 'TLS on Unix soc\n+00033030: 6b65 7420 6973 206e 6f74 2073 7570 706f ket is not suppo\n+00033040: 7274 6564 2729 0a20 2020 2020 2020 2069 rted'). i\n+00033050: 6620 6f70 745f 706f 7274 2069 7320 4e6f f opt_port is No\n+00033060: 6e65 2061 6e64 206f 7074 5f75 6e69 7820 ne and opt_unix \n+00033070: 6973 204e 6f6e 653a 0a20 2020 2020 2020 is None:. \n+00033080: 2020 2020 2072 6169 7365 2043 6861 6e6e raise Chann\n+00033090: 656c 4572 726f 7228 2770 726f 746f 636f elError('protoco\n+000330a0: 6c2d 6572 726f 7227 2c20 6d65 7373 6167 l-error', messag\n+000330b0: 653d 276e 6f20 2270 6f72 7422 206f 7220 e='no \"port\" or \n+000330c0: 2275 6e69 7822 206f 7074 696f 6e20 666f \"unix\" option fo\n+000330d0: 7220 6368 616e 6e65 6c27 290a 2020 2020 r channel'). \n+000330e0: 2020 2020 6966 206f 7074 5f70 6f72 7420 if opt_port \n+000330f0: 6973 206e 6f74 204e 6f6e 6520 616e 6420 is not None and \n+00033100: 6f70 745f 756e 6978 2069 7320 6e6f 7420 opt_unix is not \n+00033110: 4e6f 6e65 3a0a 2020 2020 2020 2020 2020 None:. \n+00033120: 2020 7261 6973 6520 4368 616e 6e65 6c45 raise ChannelE\n+00033130: 7272 6f72 2827 7072 6f74 6f63 6f6c 2d65 rror('protocol-e\n+00033140: 7272 6f72 272c 206d 6573 7361 6765 3d27 rror', message='\n+00033150: 6361 6e6e 6f74 2073 7065 6369 6679 2062 cannot specify b\n+00033160: 6f74 6820 2270 6f72 7422 2061 6e64 2022 oth \"port\" and \"\n+00033170: 756e 6978 2220 6f70 7469 6f6e 7327 290a unix\" options').\n+00033180: 0a20 2020 2020 2020 2069 6620 6f70 745f . if opt_\n+00033190: 746c 7320 6973 206e 6f74 204e 6f6e 653a tls is not None:\n+000331a0: 0a20 2020 2020 2020 2020 2020 2061 7574 . aut\n+000331b0: 686f 7269 7479 203d 2067 6574 5f64 6963 hority = get_dic\n+000331c0: 7428 6f70 745f 746c 732c 2027 6175 7468 t(opt_tls, 'auth\n+000331d0: 6f72 6974 7927 2c20 4e6f 6e65 290a 2020 ority', None). \n+000331e0: 2020 2020 2020 2020 2020 6966 2061 7574 if aut\n+000331f0: 686f 7269 7479 2069 7320 6e6f 7420 4e6f hority is not No\n+00033200: 6e65 3a0a 2020 2020 2020 2020 2020 2020 ne:. \n+00033210: 2020 2020 6461 7461 203d 2067 6574 5f73 data = get_s\n+00033220: 7472 2861 7574 686f 7269 7479 2c20 2764 tr(authority, 'd\n+00033230: 6174 6127 2c20 4e6f 6e65 290a 2020 2020 ata', None). \n+00033240: 2020 2020 2020 2020 2020 2020 6966 2064 if d\n+00033250: 6174 6120 6973 206e 6f74 204e 6f6e 653a ata is not None:\n+00033260: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+00033270: 2020 2020 2063 6f6e 7465 7874 203d 2073 context = s\n+00033280: 736c 2e63 7265 6174 655f 6465 6661 756c sl.create_defaul\n+00033290: 745f 636f 6e74 6578 7428 6361 6461 7461 t_context(cadata\n+000332a0: 3d64 6174 6129 0a20 2020 2020 2020 2020 =data). \n+000332b0: 2020 2020 2020 2065 6c73 653a 0a20 2020 else:. \n+000332c0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000332d0: 2063 6f6e 7465 7874 203d 2073 736c 2e63 context = ssl.c\n+000332e0: 7265 6174 655f 6465 6661 756c 745f 636f reate_default_co\n+000332f0: 6e74 6578 7428 6361 6669 6c65 3d67 6574 ntext(cafile=get\n+00033300: 5f73 7472 2861 7574 686f 7269 7479 2c20 _str(authority, \n+00033310: 2766 696c 6527 2929 0a20 2020 2020 2020 'file')). \n+00033320: 2020 2020 2065 6c73 653a 0a20 2020 2020 else:. \n+00033330: 2020 2020 2020 2020 2020 2063 6f6e 7465 conte\n+00033340: 7874 203d 2073 736c 2e63 7265 6174 655f xt = ssl.create_\n+00033350: 6465 6661 756c 745f 636f 6e74 6578 7428 default_context(\n+00033360: 290a 0a20 2020 2020 2020 2020 2020 2069 ).. i\n+00033370: 6620 2776 616c 6964 6174 6527 2069 6e20 f 'validate' in \n+00033380: 6f70 745f 746c 7320 616e 6420 6e6f 7420 opt_tls and not \n+00033390: 6f70 745f 746c 735b 2776 616c 6964 6174 opt_tls['validat\n+000333a0: 6527 5d3a 0a20 2020 2020 2020 2020 2020 e']:. \n+000333b0: 2020 2020 2063 6f6e 7465 7874 2e63 6865 context.che\n+000333c0: 636b 5f68 6f73 746e 616d 6520 3d20 4661 ck_hostname = Fa\n+000333d0: 6c73 650a 2020 2020 2020 2020 2020 2020 lse. \n+000333e0: 2020 2020 636f 6e74 6578 742e 7665 7269 context.veri\n+000333f0: 6679 5f6d 6f64 6520 3d20 7373 6c2e 5665 fy_mode = ssl.Ve\n+00033400: 7269 6679 4d6f 6465 2e43 4552 545f 4e4f rifyMode.CERT_NO\n+00033410: 4e45 0a0a 2020 2020 2020 2020 2020 2020 NE.. \n+00033420: 2320 5365 6520 6874 7470 733a 2f2f 6769 # See https://gi\n+00033430: 7468 7562 2e63 6f6d 2f70 7974 686f 6e2f thub.com/python/\n+00033440: 7479 7065 7368 6564 2f69 7373 7565 732f typeshed/issues/\n+00033450: 3131 3035 370a 2020 2020 2020 2020 2020 11057. \n+00033460: 2020 7265 7475 726e 2068 7474 702e 636c return http.cl\n+00033470: 6965 6e74 2e48 5454 5053 436f 6e6e 6563 ient.HTTPSConnec\n+00033480: 7469 6f6e 286f 7074 5f61 6464 7265 7373 tion(opt_address\n+00033490: 2c20 706f 7274 3d6f 7074 5f70 6f72 742c , port=opt_port,\n+000334a0: 2063 6f6e 7465 7874 3d63 6f6e 7465 7874 context=context\n+000334b0: 2920 2023 2074 7970 653a 2069 676e 6f72 ) # type: ignor\n+000334c0: 655b 6172 672d 7479 7065 5d0a 0a20 2020 e[arg-type].. \n+000334d0: 2020 2020 2065 6c73 653a 0a20 2020 2020 else:. \n+000334e0: 2020 2020 2020 2072 6574 7572 6e20 6874 return ht\n+000334f0: 7470 2e63 6c69 656e 742e 4854 5450 436f tp.client.HTTPCo\n+00033500: 6e6e 6563 7469 6f6e 286f 7074 5f61 6464 nnection(opt_add\n+00033510: 7265 7373 2c20 706f 7274 3d6f 7074 5f70 ress, port=opt_p\n+00033520: 6f72 7429 0a0a 2020 2020 4073 7461 7469 ort).. @stati\n+00033530: 636d 6574 686f 640a 2020 2020 6465 6620 cmethod. def \n+00033540: 636f 6e6e 6563 7428 636f 6e6e 6563 7469 connect(connecti\n+00033550: 6f6e 3a20 6874 7470 2e63 6c69 656e 742e on: http.client.\n+00033560: 4854 5450 436f 6e6e 6563 7469 6f6e 2c20 HTTPConnection, \n+00033570: 6f70 745f 756e 6978 3a20 2773 7472 207c opt_unix: 'str |\n+00033580: 204e 6f6e 6527 2920 2d3e 204e 6f6e 653a None') -> None:\n+00033590: 0a20 2020 2020 2020 2023 2042 6c6f 636b . # Block\n+000335a0: 732e 2020 5275 6e73 2069 6e20 6120 7468 s. Runs in a th\n+000335b0: 7265 6164 2e0a 2020 2020 2020 2020 6966 read.. if\n+000335c0: 206f 7074 5f75 6e69 783a 0a20 2020 2020 opt_unix:. \n+000335d0: 2020 2020 2020 2023 2063 7265 6174 6520 # create \n+000335e0: 7468 6520 636f 6e6e 6563 7469 6f6e 2773 the connection's\n+000335f0: 2073 6f63 6b65 7420 736f 2074 6861 7420 socket so that \n+00033600: 6974 2077 6f6e 2774 2063 616c 6c20 2e63 it won't call .c\n+00033610: 6f6e 6e65 6374 2829 2069 6e74 6572 6e61 onnect() interna\n+00033620: 6c6c 7920 2877 6869 6368 206f 6e6c 7920 lly (which only \n+00033630: 7375 7070 6f72 7473 2054 4350 290a 2020 supports TCP). \n+00033640: 2020 2020 2020 2020 2020 636f 6e6e 6563 connec\n+00033650: 7469 6f6e 2e73 6f63 6b20 3d20 736f 636b tion.sock = sock\n+00033660: 6574 2e73 6f63 6b65 7428 736f 636b 6574 et.socket(socket\n+00033670: 2e41 465f 554e 4958 290a 2020 2020 2020 .AF_UNIX). \n+00033680: 2020 2020 2020 636f 6e6e 6563 7469 6f6e connection\n+00033690: 2e73 6f63 6b2e 636f 6e6e 6563 7428 6f70 .sock.connect(op\n+000336a0: 745f 756e 6978 290a 2020 2020 2020 2020 t_unix). \n+000336b0: 656c 7365 3a0a 2020 2020 2020 2020 2020 else:. \n+000336c0: 2020 2320 6578 706c 6963 6974 6c79 2063 # explicitly c\n+000336d0: 616c 6c20 636f 6e6e 6563 7428 292c 2073 all connect(), s\n+000336e0: 6f20 7468 6174 2077 6520 6361 6e20 646f o that we can do\n+000336f0: 2070 726f 7065 7220 6572 726f 7220 6861 proper error ha\n+00033700: 6e64 6c69 6e67 0a20 2020 2020 2020 2020 ndling. \n+00033710: 2020 2063 6f6e 6e65 6374 696f 6e2e 636f connection.co\n+00033720: 6e6e 6563 7428 290a 0a20 2020 2040 7374 nnect().. @st\n+00033730: 6174 6963 6d65 7468 6f64 0a20 2020 2064 aticmethod. d\n+00033740: 6566 2072 6571 7565 7374 280a 2020 2020 ef request(. \n+00033750: 2020 2020 636f 6e6e 6563 7469 6f6e 3a20 connection: \n+00033760: 6874 7470 2e63 6c69 656e 742e 4854 5450 http.client.HTTP\n+00033770: 436f 6e6e 6563 7469 6f6e 2c20 6d65 7468 Connection, meth\n+00033780: 6f64 3a20 7374 722c 2070 6174 683a 2073 od: str, path: s\n+00033790: 7472 2c20 6865 6164 6572 733a 2027 6469 tr, headers: 'di\n+000337a0: 6374 5b73 7472 2c20 7374 725d 272c 2062 ct[str, str]', b\n+000337b0: 6f64 793a 2062 7974 6573 0a20 2020 2029 ody: bytes. )\n+000337c0: 202d 3e20 6874 7470 2e63 6c69 656e 742e -> http.client.\n+000337d0: 4854 5450 5265 7370 6f6e 7365 3a0a 2020 HTTPResponse:. \n+000337e0: 2020 2020 2020 2320 426c 6f63 6b73 2e20 # Blocks. \n+000337f0: 2052 756e 7320 696e 2061 2074 6872 6561 Runs in a threa\n+00033800: 642e 0a20 2020 2020 2020 2063 6f6e 6e65 d.. conne\n+00033810: 6374 696f 6e2e 7265 7175 6573 7428 6d65 ction.request(me\n+00033820: 7468 6f64 2c20 7061 7468 2c20 6865 6164 thod, path, head\n+00033830: 6572 733d 6865 6164 6572 7320 6f72 207b ers=headers or {\n+00033840: 7d2c 2062 6f64 793d 626f 6479 290a 2020 }, body=body). \n+00033850: 2020 2020 2020 7265 7475 726e 2063 6f6e return con\n+00033860: 6e65 6374 696f 6e2e 6765 7472 6573 706f nection.getrespo\n+00033870: 6e73 6528 290a 0a20 2020 2061 7379 6e63 nse().. async\n+00033880: 2064 6566 2072 756e 2873 656c 662c 206f def run(self, o\n+00033890: 7074 696f 6e73 3a20 4a73 6f6e 4f62 6a65 ptions: JsonObje\n+000338a0: 6374 2920 2d3e 204e 6f6e 653a 0a20 2020 ct) -> None:. \n+000338b0: 2020 2020 206c 6f67 6765 722e 6465 6275 logger.debu\n+000338c0: 6728 276f 7065 6e20 2573 272c 206f 7074 g('open %s', opt\n+000338d0: 696f 6e73 290a 0a20 2020 2020 2020 2062 ions).. b\n+000338e0: 696e 6172 7920 3d20 6765 745f 656e 756d inary = get_enum\n+000338f0: 286f 7074 696f 6e73 2c20 2762 696e 6172 (options, 'binar\n+00033900: 7927 2c20 5b27 7261 7727 5d2c 204e 6f6e y', ['raw'], Non\n+00033910: 6529 2069 7320 6e6f 7420 4e6f 6e65 0a20 e) is not None. \n+00033920: 2020 2020 2020 206d 6574 686f 6420 3d20 method = \n+00033930: 6765 745f 7374 7228 6f70 7469 6f6e 732c get_str(options,\n+00033940: 2027 6d65 7468 6f64 2729 0a20 2020 2020 'method'). \n+00033950: 2020 2070 6174 6820 3d20 6765 745f 7374 path = get_st\n+00033960: 7228 6f70 7469 6f6e 732c 2027 7061 7468 r(options, 'path\n+00033970: 2729 0a20 2020 2020 2020 2068 6561 6465 '). heade\n+00033980: 7273 203d 2067 6574 5f6f 626a 6563 7428 rs = get_object(\n+00033990: 6f70 7469 6f6e 732c 2027 6865 6164 6572 options, 'header\n+000339a0: 7327 2c20 6c61 6d62 6461 2064 3a20 7b6b s', lambda d: {k\n+000339b0: 3a20 7479 7065 6368 6563 6b65 6428 762c : typechecked(v,\n+000339c0: 2073 7472 2920 666f 7220 6b2c 2076 2069 str) for k, v i\n+000339d0: 6e20 642e 6974 656d 7328 297d 2c20 4e6f n d.items()}, No\n+000339e0: 6e65 290a 0a20 2020 2020 2020 2069 6620 ne).. if \n+000339f0: 2763 6f6e 6e65 6374 696f 6e27 2069 6e20 'connection' in \n+00033a00: 6f70 7469 6f6e 733a 0a20 2020 2020 2020 options:. \n+00033a10: 2020 2020 2072 6169 7365 2043 6861 6e6e raise Chann\n+00033a20: 656c 4572 726f 7228 2770 726f 746f 636f elError('protoco\n+00033a30: 6c2d 6572 726f 7227 2c20 6d65 7373 6167 l-error', messag\n+00033a40: 653d 2763 6f6e 6e65 6374 696f 6e20 7368 e='connection sh\n+00033a50: 6172 696e 6720 6973 206e 6f74 2069 6d70 aring is not imp\n+00033a60: 6c65 6d65 6e74 6564 206f 6e20 7468 6973 lemented on this\n+00033a70: 2062 7269 6467 6527 290a 0a20 2020 2020 bridge').. \n+00033a80: 2020 206c 6f6f 7020 3d20 6173 796e 6369 loop = asynci\n+00033a90: 6f2e 6765 745f 7275 6e6e 696e 675f 6c6f o.get_running_lo\n+00033aa0: 6f70 2829 0a20 2020 2020 2020 2063 6f6e op(). con\n+00033ab0: 6e65 6374 696f 6e20 3d20 7365 6c66 2e63 nection = self.c\n+00033ac0: 7265 6174 655f 636c 6965 6e74 286f 7074 reate_client(opt\n+00033ad0: 696f 6e73 290a 0a20 2020 2020 2020 2073 ions).. s\n+00033ae0: 656c 662e 7265 6164 7928 290a 0a20 2020 elf.ready().. \n+00033af0: 2020 2020 2062 6f64 7920 3d20 6227 270a body = b''.\n+00033b00: 2020 2020 2020 2020 7768 696c 6520 5472 while Tr\n+00033b10: 7565 3a0a 2020 2020 2020 2020 2020 2020 ue:. \n+00033b20: 6461 7461 203d 2061 7761 6974 2073 656c data = await sel\n+00033b30: 662e 7265 6164 2829 0a20 2020 2020 2020 f.read(). \n+00033b40: 2020 2020 2069 6620 6461 7461 2069 7320 if data is \n+00033b50: 4e6f 6e65 3a0a 2020 2020 2020 2020 2020 None:. \n+00033b60: 2020 2020 2020 6272 6561 6b0a 2020 2020 break. \n+00033b70: 2020 2020 2020 2020 626f 6479 202b 3d20 body += \n+00033b80: 6461 7461 0a0a 2020 2020 2020 2020 2320 data.. # \n+00033b90: 436f 6e6e 6563 7420 696e 2061 2074 6872 Connect in a thr\n+00033ba0: 6561 6420 616e 6420 6861 6e64 6c65 2065 ead and handle e\n+00033bb0: 7272 6f72 730a 2020 2020 2020 2020 7472 rrors. tr\n+00033bc0: 793a 0a20 2020 2020 2020 2020 2020 2061 y:. a\n+00033bd0: 7761 6974 206c 6f6f 702e 7275 6e5f 696e wait loop.run_in\n+00033be0: 5f65 7865 6375 746f 7228 4e6f 6e65 2c20 _executor(None, \n+00033bf0: 7365 6c66 2e63 6f6e 6e65 6374 2c20 636f self.connect, co\n+00033c00: 6e6e 6563 7469 6f6e 2c20 6765 745f 7374 nnection, get_st\n+00033c10: 7228 6f70 7469 6f6e 732c 2027 756e 6978 r(options, 'unix\n+00033c20: 272c 204e 6f6e 6529 290a 2020 2020 2020 ', None)). \n+00033c30: 2020 6578 6365 7074 2073 736c 2e53 534c except ssl.SSL\n+00033c40: 4365 7274 5665 7269 6669 6361 7469 6f6e CertVerification\n+00033c50: 4572 726f 7220 6173 2065 7863 3a0a 2020 Error as exc:. \n+00033c60: 2020 2020 2020 2020 2020 7261 6973 6520 raise \n+00033c70: 4368 616e 6e65 6c45 7272 6f72 2827 756e ChannelError('un\n+00033c80: 6b6e 6f77 6e2d 686f 7374 6b65 7927 2c20 known-hostkey', \n+00033c90: 6d65 7373 6167 653d 7374 7228 6578 6329 message=str(exc)\n+00033ca0: 2920 6672 6f6d 2065 7863 0a20 2020 2020 ) from exc. \n+00033cb0: 2020 2065 7863 6570 7420 284f 5345 7272 except (OSErr\n+00033cc0: 6f72 2c20 494f 4572 726f 7229 2061 7320 or, IOError) as \n+00033cd0: 6578 633a 0a20 2020 2020 2020 2020 2020 exc:. \n+00033ce0: 2072 6169 7365 2043 6861 6e6e 656c 4572 raise ChannelEr\n+00033cf0: 726f 7228 276e 6f74 2d66 6f75 6e64 272c ror('not-found',\n+00033d00: 206d 6573 7361 6765 3d73 7472 2865 7863 message=str(exc\n+00033d10: 2929 2066 726f 6d20 6578 630a 0a20 2020 )) from exc.. \n+00033d20: 2020 2020 2023 2053 7562 6d69 7420 7265 # Submit re\n+00033d30: 7175 6573 7420 696e 2061 2074 6872 6561 quest in a threa\n+00033d40: 6420 616e 6420 6861 6e64 6c65 2065 7272 d and handle err\n+00033d50: 6f72 730a 2020 2020 2020 2020 7472 793a ors. try:\n+00033d60: 0a20 2020 2020 2020 2020 2020 2072 6573 . res\n+00033d70: 706f 6e73 6520 3d20 6177 6169 7420 6c6f ponse = await lo\n+00033d80: 6f70 2e72 756e 5f69 6e5f 6578 6563 7574 op.run_in_execut\n+00033d90: 6f72 284e 6f6e 652c 2073 656c 662e 7265 or(None, self.re\n+00033da0: 7175 6573 742c 2063 6f6e 6e65 6374 696f quest, connectio\n+00033db0: 6e2c 206d 6574 686f 642c 2070 6174 682c n, method, path,\n+00033dc0: 2068 6561 6465 7273 206f 7220 7b7d 2c20 headers or {}, \n+00033dd0: 626f 6479 290a 2020 2020 2020 2020 6578 body). ex\n+00033de0: 6365 7074 2028 6874 7470 2e63 6c69 656e cept (http.clien\n+00033df0: 742e 4854 5450 4578 6365 7074 696f 6e2c t.HTTPException,\n+00033e00: 204f 5345 7272 6f72 2920 6173 2065 7863 OSError) as exc\n+00033e10: 3a0a 2020 2020 2020 2020 2020 2020 7261 :. ra\n+00033e20: 6973 6520 4368 616e 6e65 6c45 7272 6f72 ise ChannelError\n+00033e30: 2827 7465 726d 696e 6174 6564 272c 206d ('terminated', m\n+00033e40: 6573 7361 6765 3d73 7472 2865 7863 2929 essage=str(exc))\n+00033e50: 2066 726f 6d20 6578 630a 0a20 2020 2020 from exc.. \n+00033e60: 2020 2073 656c 662e 7365 6e64 5f63 6f6e self.send_con\n+00033e70: 7472 6f6c 2863 6f6d 6d61 6e64 3d27 7265 trol(command='re\n+00033e80: 7370 6f6e 7365 272c 0a20 2020 2020 2020 sponse',. \n+00033e90: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00033ea0: 2020 2073 7461 7475 733d 7265 7370 6f6e status=respon\n+00033eb0: 7365 2e73 7461 7475 732c 0a20 2020 2020 se.status,. \n+00033ec0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00033ed0: 2020 2020 2072 6561 736f 6e3d 7265 7370 reason=resp\n+00033ee0: 6f6e 7365 2e72 6561 736f 6e2c 0a20 2020 onse.reason,. \n+00033ef0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00033f00: 2020 2020 2020 2068 6561 6465 7273 3d73 headers=s\n+00033f10: 656c 662e 6765 745f 6865 6164 6572 7328 elf.get_headers(\n+00033f20: 7265 7370 6f6e 7365 2c20 6269 6e61 7279 response, binary\n+00033f30: 3d62 696e 6172 7929 290a 0a20 2020 2020 =binary)).. \n+00033f40: 2020 2023 2052 6563 6569 7665 2074 6865 # Receive the\n+00033f50: 2062 6f64 7920 616e 6420 6669 6e69 7368 body and finish\n+00033f60: 2075 700a 2020 2020 2020 2020 7472 793a up. try:\n+00033f70: 0a20 2020 2020 2020 2020 2020 2077 6869 . whi\n+00033f80: 6c65 2054 7275 653a 0a20 2020 2020 2020 le True:. \n+00033f90: 2020 2020 2020 2020 2062 6c6f 636b 203d block =\n+00033fa0: 2061 7761 6974 206c 6f6f 702e 7275 6e5f await loop.run_\n+00033fb0: 696e 5f65 7865 6375 746f 7228 4e6f 6e65 in_executor(None\n+00033fc0: 2c20 7265 7370 6f6e 7365 2e72 6561 6431 , response.read1\n+00033fd0: 2c20 7365 6c66 2e42 4c4f 434b 5f53 495a , self.BLOCK_SIZ\n+00033fe0: 4529 0a20 2020 2020 2020 2020 2020 2020 E). \n+00033ff0: 2020 2069 6620 6e6f 7420 626c 6f63 6b3a if not block:\n+00034000: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+00034010: 2020 2020 2062 7265 616b 0a20 2020 2020 break. \n+00034020: 2020 2020 2020 2020 2020 2061 7761 6974 await\n+00034030: 2073 656c 662e 7772 6974 6528 626c 6f63 self.write(bloc\n+00034040: 6b29 0a0a 2020 2020 2020 2020 2020 2020 k).. \n+00034050: 6c6f 6767 6572 2e64 6562 7567 2827 7265 logger.debug('re\n+00034060: 6164 696e 6720 7265 7370 6f6e 7365 2064 ading response d\n+00034070: 6f6e 6527 290a 2020 2020 2020 2020 2020 one'). \n+00034080: 2020 2320 7468 6973 2072 6574 7572 6e73 # this returns\n+00034090: 2069 6d6d 6564 6961 7465 6c79 2061 6e64 immediately and\n+000340a0: 2064 6f65 7320 6e6f 7420 7265 6164 2061 does not read a\n+000340b0: 6e79 7468 696e 6720 6d6f 7265 2c20 6275 nything more, bu\n+000340c0: 7420 7570 6461 7465 7320 7468 6520 6874 t updates the ht\n+000340d0: 7470 2e63 6c69 656e 7427 730a 2020 2020 tp.client's. \n+000340e0: 2020 2020 2020 2020 2320 696e 7465 726e # intern\n+000340f0: 616c 2073 7461 7465 206d 6163 6869 6e65 al state machine\n+00034100: 2074 6f20 2272 6573 706f 6e73 6520 646f to \"response do\n+00034110: 6e65 220a 2020 2020 2020 2020 2020 2020 ne\". \n+00034120: 626c 6f63 6b20 3d20 7265 7370 6f6e 7365 block = response\n+00034130: 2e72 6561 6428 290a 2020 2020 2020 2020 .read(). \n+00034140: 2020 2020 6173 7365 7274 2062 6c6f 636b assert block\n+00034150: 203d 3d20 6227 270a 0a20 2020 2020 2020 == b''.. \n+00034160: 2020 2020 2061 7761 6974 206c 6f6f 702e await loop.\n+00034170: 7275 6e5f 696e 5f65 7865 6375 746f 7228 run_in_executor(\n+00034180: 4e6f 6e65 2c20 636f 6e6e 6563 7469 6f6e None, connection\n+00034190: 2e63 6c6f 7365 290a 2020 2020 2020 2020 .close). \n+000341a0: 6578 6365 7074 2028 6874 7470 2e63 6c69 except (http.cli\n+000341b0: 656e 742e 4854 5450 4578 6365 7074 696f ent.HTTPExceptio\n+000341c0: 6e2c 204f 5345 7272 6f72 2920 6173 2065 n, OSError) as e\n+000341d0: 7863 3a0a 2020 2020 2020 2020 2020 2020 xc:. \n+000341e0: 7261 6973 6520 4368 616e 6e65 6c45 7272 raise ChannelErr\n+000341f0: 6f72 2827 7465 726d 696e 6174 6564 272c or('terminated',\n+00034200: 206d 6573 7361 6765 3d73 7472 2865 7863 message=str(exc\n+00034210: 2929 2066 726f 6d20 6578 630a 0a20 2020 )) from exc.. \n+00034220: 2020 2020 2073 656c 662e 646f 6e65 2829 self.done()\n+00034230: 0a27 2727 2c0a 2020 2763 6f63 6b70 6974 .''',. 'cockpit\n+00034240: 2f63 6861 6e6e 656c 732f 6462 7573 2e70 /channels/dbus.p\n+00034250: 7927 3a20 7227 2727 2320 5468 6973 2066 y': r'''# This f\n+00034260: 696c 6520 6973 2070 6172 7420 6f66 2043 ile is part of C\n+00034270: 6f63 6b70 6974 2e0a 230a 2320 436f 7079 ockpit..#.# Copy\n+00034280: 7269 6768 7420 2843 2920 3230 3232 2052 right (C) 2022 R\n+00034290: 6564 2048 6174 2c20 496e 632e 0a23 0a23 ed Hat, Inc..#.#\n+000342a0: 2054 6869 7320 7072 6f67 7261 6d20 6973 This program is\n+000342b0: 2066 7265 6520 736f 6674 7761 7265 3a20 free software: \n+000342c0: 796f 7520 6361 6e20 7265 6469 7374 7269 you can redistri\n+000342d0: 6275 7465 2069 7420 616e 642f 6f72 206d bute it and/or m\n+000342e0: 6f64 6966 790a 2320 6974 2075 6e64 6572 odify.# it under\n+000342f0: 2074 6865 2074 6572 6d73 206f 6620 7468 the terms of th\n+00034300: 6520 474e 5520 4765 6e65 7261 6c20 5075 e GNU General Pu\n+00034310: 626c 6963 204c 6963 656e 7365 2061 7320 blic License as \n+00034320: 7075 626c 6973 6865 6420 6279 0a23 2074 published by.# t\n+00034330: 6865 2046 7265 6520 536f 6674 7761 7265 he Free Software\n+00034340: 2046 6f75 6e64 6174 696f 6e2c 2065 6974 Foundation, eit\n+00034350: 6865 7220 7665 7273 696f 6e20 3320 6f66 her version 3 of\n+00034360: 2074 6865 204c 6963 656e 7365 2c20 6f72 the License, or\n+00034370: 0a23 2028 6174 2079 6f75 7220 6f70 7469 .# (at your opti\n+00034380: 6f6e 2920 616e 7920 6c61 7465 7220 7665 on) any later ve\n+00034390: 7273 696f 6e2e 0a23 0a23 2054 6869 7320 rsion..#.# This \n+000343a0: 7072 6f67 7261 6d20 6973 2064 6973 7472 program is distr\n+000343b0: 6962 7574 6564 2069 6e20 7468 6520 686f ibuted in the ho\n+000343c0: 7065 2074 6861 7420 6974 2077 696c 6c20 pe that it will \n+000343d0: 6265 2075 7365 6675 6c2c 0a23 2062 7574 be useful,.# but\n+000343e0: 2057 4954 484f 5554 2041 4e59 2057 4152 WITHOUT ANY WAR\n+000343f0: 5241 4e54 593b 2077 6974 686f 7574 2065 RANTY; without e\n+00034400: 7665 6e20 7468 6520 696d 706c 6965 6420 ven the implied \n+00034410: 7761 7272 616e 7479 206f 660a 2320 4d45 warranty of.# ME\n+00034420: 5243 4841 4e54 4142 494c 4954 5920 6f72 RCHANTABILITY or\n+00034430: 2046 4954 4e45 5353 2046 4f52 2041 2050 FITNESS FOR A P\n+00034440: 4152 5449 4355 4c41 5220 5055 5250 4f53 ARTICULAR PURPOS\n+00034450: 452e 2020 5365 6520 7468 650a 2320 474e E. See the.# GN\n+00034460: 5520 4765 6e65 7261 6c20 5075 626c 6963 U General Public\n+00034470: 204c 6963 656e 7365 2066 6f72 206d 6f72 License for mor\n+00034480: 6520 6465 7461 696c 732e 0a23 0a23 2059 e details..#.# Y\n+00034490: 6f75 2073 686f 756c 6420 6861 7665 2072 ou should have r\n+000344a0: 6563 6569 7665 6420 6120 636f 7079 206f eceived a copy o\n+000344b0: 6620 7468 6520 474e 5520 4765 6e65 7261 f the GNU Genera\n+000344c0: 6c20 5075 626c 6963 204c 6963 656e 7365 l Public License\n+000344d0: 0a23 2061 6c6f 6e67 2077 6974 6820 7468 .# along with th\n+000344e0: 6973 2070 726f 6772 616d 2e20 2049 6620 is program. If \n+000344f0: 6e6f 742c 2073 6565 203c 6874 7470 733a not, see <https:\n+00034500: 2f2f 7777 772e 676e 752e 6f72 672f 6c69 //www.gnu.org/li\n+00034510: 6365 6e73 6573 2f3e 2e0a 0a23 204d 6973 censes/>...# Mis\n+00034520: 7369 6e67 2073 7475 6666 2063 6f6d 7061 sing stuff compa\n+00034530: 7265 6420 746f 2074 6865 2043 2062 7269 red to the C bri\n+00034540: 6467 6520 7468 6174 2077 6520 7368 6f75 dge that we shou\n+00034550: 6c64 2070 726f 6261 626c 7920 6164 643a ld probably add:\n+00034560: 0a23 0a23 202d 2072 656d 6f76 696e 6720 .#.# - removing \n+00034570: 6d61 7463 6865 730a 2320 2d20 7265 6d6f matches.# - remo\n+00034580: 7669 6e67 2077 6174 6368 6573 0a23 202d ving watches.# -\n+00034590: 2065 6d69 7474 696e 6720 6f66 2073 6967 emitting of sig\n+000345a0: 6e61 6c73 0a23 202d 2070 7562 6c69 7368 nals.# - publish\n+000345b0: 696e 6720 6f66 206f 626a 6563 7473 0a23 ing of objects.#\n+000345c0: 202d 2066 6169 6c69 6e67 206d 6f72 6520 - failing more \n+000345d0: 6772 6163 6566 756c 6c79 2069 6e20 736f gracefully in so\n+000345e0: 6d65 2063 6173 6573 2028 6475 7269 6e67 me cases (during\n+000345f0: 206f 7065 6e2c 2065 7463 290a 230a 2320 open, etc).#.# \n+00034600: 5374 7566 6620 7765 206d 6967 6874 206f Stuff we might o\n+00034610: 7220 6d69 6768 7420 6e6f 7420 646f 3a0a r might not do:.\n+00034620: 230a 2320 2d20 7573 696e 6720 6e6f 6e2d #.# - using non-\n+00034630: 6465 6661 756c 7420 7365 7276 6963 6520 default service \n+00034640: 6e61 6d65 730a 230a 2320 5374 7566 6620 names.#.# Stuff \n+00034650: 7765 2073 686f 756c 6420 7072 6f62 6162 we should probab\n+00034660: 6c79 206e 6f74 2064 6f3a 0a23 0a23 202d ly not do:.#.# -\n+00034670: 2065 6d75 6c61 7469 6f6e 206f 6620 4f62 emulation of Ob\n+00034680: 6a65 6374 4d61 6e61 6765 7220 7669 6120 jectManager via \n+00034690: 7265 6375 7273 6976 6520 696e 7472 6f73 recursive intros\n+000346a0: 7065 6374 696f 6e0a 2320 2d20 6175 746f pection.# - auto\n+000346b0: 6d61 7469 6320 6465 7465 6374 696f 6e20 matic detection \n+000346c0: 6f66 204f 626a 6563 744d 616e 6167 6572 of ObjectManager\n+000346d0: 2062 656c 6f77 2074 6865 2067 6976 656e below the given\n+000346e0: 2070 6174 685f 6e61 6d65 7370 6163 650a path_namespace.\n+000346f0: 2320 2d20 7265 6375 7273 6976 6520 7363 # - recursive sc\n+00034700: 7261 7069 6e67 206f 6620 7072 6f70 6572 raping of proper\n+00034710: 7469 6573 2066 6f72 206e 6577 206f 626a ties for new obj\n+00034720: 6563 7420 7061 7468 730a 2320 2020 2866 ect paths.# (f\n+00034730: 6f72 2070 6174 685f 6e61 6d65 7370 6163 or path_namespac\n+00034740: 6520 7761 7463 6865 7320 7468 6174 2064 e watches that d\n+00034750: 6f6e 2774 2068 6974 2061 6e20 4f62 6a65 on't hit an Obje\n+00034760: 6374 4d61 6e61 6765 7229 0a0a 696d 706f ctManager)..impo\n+00034770: 7274 2061 7379 6e63 696f 0a69 6d70 6f72 rt asyncio.impor\n+00034780: 7420 6572 726e 6f0a 696d 706f 7274 206a t errno.import j\n+00034790: 736f 6e0a 696d 706f 7274 206c 6f67 6769 son.import loggi\n+000347a0: 6e67 0a69 6d70 6f72 7420 7472 6163 6562 ng.import traceb\n+000347b0: 6163 6b0a 696d 706f 7274 2078 6d6c 2e65 ack.import xml.e\n+000347c0: 7472 6565 2e45 6c65 6d65 6e74 5472 6565 tree.ElementTree\n+000347d0: 2061 7320 4554 0a0a 6672 6f6d 2063 6f63 as ET..from coc\n+000347e0: 6b70 6974 2e5f 7665 6e64 6f72 2069 6d70 kpit._vendor imp\n+000347f0: 6f72 7420 7379 7374 656d 645f 6374 7970 ort systemd_ctyp\n+00034800: 6573 0a66 726f 6d20 636f 636b 7069 742e es.from cockpit.\n+00034810: 5f76 656e 646f 722e 7379 7374 656d 645f _vendor.systemd_\n+00034820: 6374 7970 6573 2069 6d70 6f72 7420 4275 ctypes import Bu\n+00034830: 732c 2042 7573 4572 726f 722c 2069 6e74 s, BusError, int\n+00034840: 726f 7370 6563 7469 6f6e 0a0a 6672 6f6d rospection..from\n+00034850: 202e 2e63 6861 6e6e 656c 2069 6d70 6f72 ..channel impor\n+00034860: 7420 4368 616e 6e65 6c2c 2043 6861 6e6e t Channel, Chann\n+00034870: 656c 4572 726f 720a 0a6c 6f67 6765 7220 elError..logger \n+00034880: 3d20 6c6f 6767 696e 672e 6765 744c 6f67 = logging.getLog\n+00034890: 6765 7228 5f5f 6e61 6d65 5f5f 290a 0a23 ger(__name__)..#\n+000348a0: 2054 6865 2064 6275 736a 736f 6e33 2070 The dbusjson3 p\n+000348b0: 6179 6c6f 6164 0a23 0a23 2054 6869 7320 ayload.#.# This \n+000348c0: 6368 616e 6e65 6c20 7061 796c 6f61 6420 channel payload \n+000348d0: 7479 7065 2074 7261 6e73 6c61 7465 7320 type translates \n+000348e0: 4a53 4f4e 2065 6e63 6f64 6564 206d 6573 JSON encoded mes\n+000348f0: 7361 6765 7320 6f6e 2061 0a23 2043 6f63 sages on a.# Coc\n+00034900: 6b70 6974 2063 6861 6e6e 656c 2074 6f20 kpit channel to \n+00034910: 442d 4275 7320 6d65 7373 6167 6573 2c20 D-Bus messages, \n+00034920: 696e 2061 206d 6f73 746c 7920 7374 7261 in a mostly stra\n+00034930: 6967 6874 666f 7277 6172 6420 7761 792e ightforward way.\n+00034940: 0a23 2053 6565 2064 6f63 2f70 726f 746f .# See doc/proto\n+00034950: 636f 6c2e 6d64 2066 6f72 2061 2064 6573 col.md for a des\n+00034960: 6372 6970 7469 6f6e 206f 6620 7468 6520 cription of the \n+00034970: 6261 7369 6373 2e0a 230a 2320 486f 7765 basics..#.# Howe\n+00034980: 7665 722c 2064 6275 736a 736f 6e33 206f ver, dbusjson3 o\n+00034990: 6666 6572 7320 736f 6d65 2061 6476 616e ffers some advan\n+000349a0: 6365 6420 6665 6174 7572 6573 2061 7320 ced features as \n+000349b0: 7765 6c6c 2074 6861 7420 6172 650a 2320 well that are.# \n+000349c0: 6d65 616e 7420 746f 2073 7570 706f 7274 meant to support\n+000349d0: 2074 6865 2022 6d61 6769 6322 2044 4275 the \"magic\" DBu\n+000349e0: 7350 726f 7879 206f 626a 6563 7473 2069 sProxy objects i\n+000349f0: 6d70 6c65 6d65 6e74 6564 2062 790a 2320 mplemented by.# \n+00034a00: 636f 636b 7069 742e 6a73 2e20 2054 686f cockpit.js. Tho\n+00034a10: 7365 2070 726f 7879 206f 626a 6563 7473 se proxy objects\n+00034a20: 2022 6d61 6769 6361 6c6c 7922 2065 7870 \"magically\" exp\n+00034a30: 6f73 6520 616c 6c20 7468 6520 6d65 7468 ose all the meth\n+00034a40: 6f64 730a 2320 616e 6420 7072 6f70 6572 ods.# and proper\n+00034a50: 7469 6573 206f 6620 6120 442d 4275 7320 ties of a D-Bus \n+00034a60: 696e 7465 7266 6163 6520 7769 7468 6f75 interface withou\n+00034a70: 7420 7265 7175 6972 696e 6720 616e 7920 t requiring any \n+00034a80: 6578 706c 6963 6974 0a23 2062 696e 6469 explicit.# bindi\n+00034a90: 6e67 2063 6f64 6520 746f 2062 6520 6765 ng code to be ge\n+00034aa0: 6e65 7261 7465 6420 666f 7220 6120 4a61 nerated for a Ja\n+00034ab0: 7661 5363 7269 7074 2063 6c69 656e 742e vaScript client.\n+00034ac0: 2020 4120 6462 7573 6a73 6f6e 330a 2320 A dbusjson3.# \n+00034ad0: 6368 616e 6e65 6c20 646f 6573 2074 6869 channel does thi\n+00034ae0: 7320 6279 2064 6f69 6e67 2061 7574 6f6d s by doing autom\n+00034af0: 6174 6963 2069 6e74 726f 7370 6563 7469 atic introspecti\n+00034b00: 6f6e 2061 6e64 2070 726f 7065 7274 790a on and property.\n+00034b10: 2320 7265 7472 6965 7661 6c20 7769 7468 # retrieval with\n+00034b20: 6f75 7420 6d75 6368 2064 6972 6563 7469 out much directi\n+00034b30: 6f6e 2066 726f 6d20 7468 6520 4a61 7661 on from the Java\n+00034b40: 5363 7269 7074 2063 6c69 656e 742e 0a23 Script client..#\n+00034b50: 0a23 2054 6865 2064 6574 6169 6c73 206f .# The details o\n+00034b60: 6620 7768 6174 2065 7861 6374 6c79 2069 f what exactly i\n+00034b70: 7320 646f 6e65 2069 7320 6e6f 7420 7370 s done is not sp\n+00034b80: 6563 6966 6965 6420 7665 7279 2073 7472 ecified very str\n+00034b90: 6963 746c 792c 0a23 2061 6e64 2074 6865 ictly,.# and the\n+00034ba0: 2050 7974 686f 6e20 6272 6964 6765 2077 Python bridge w\n+00034bb0: 696c 6c20 6c69 6b65 6c79 2064 6966 6665 ill likely diffe\n+00034bc0: 7220 6672 6f6d 2074 6865 2043 2062 7269 r from the C bri\n+00034bd0: 6467 650a 2320 7369 676e 6966 6963 616e dge.# significan\n+00034be0: 746c 792e 2054 6869 7320 7769 6c6c 2062 tly. This will b\n+00034bf0: 6520 696e 666f 726d 6564 2062 7920 7768 e informed by wh\n+00034c00: 6174 2065 7869 7374 696e 6720 636f 6465 at existing code\n+00034c10: 2061 6374 7561 6c6c 790a 2320 6e65 6564 actually.# need\n+00034c20: 732c 2061 6e64 2077 6520 6d69 6768 7420 s, and we might \n+00034c30: 656e 6420 7570 2077 6974 6820 6120 6d6f end up with a mo\n+00034c40: 7265 2063 6f6e 6372 6574 6520 6465 7363 re concrete desc\n+00034c50: 7269 7074 696f 6e20 6f66 2077 6861 740a ription of what.\n+00034c60: 2320 6120 636c 6965 6e74 2063 616e 2061 # a client can a\n+00034c70: 6374 7561 6c6c 7920 6578 7065 6374 2e0a ctually expect..\n+00034c80: 230a 2320 4865 7265 2069 7320 616e 2065 #.# Here is an e\n+00034c90: 7861 6d70 6c65 206f 6620 6120 6d6f 7265 xample of a more\n+00034ca0: 2063 6f6d 706c 6578 2073 6365 6e61 7269 complex scenari\n+00034cb0: 6f3a 0a23 0a23 202d 2054 6865 2063 6c69 o:.#.# - The cli\n+00034cc0: 656e 7420 6164 6473 2061 2022 7761 7463 ent adds a \"watc\n+00034cd0: 6822 2066 6f72 2061 2070 6174 6820 6e61 h\" for a path na\n+00034ce0: 6d65 7370 6163 652e 2020 5468 6572 6520 mespace. There \n+00034cf0: 6973 2061 0a23 2020 204f 626a 6563 744d is a.# ObjectM\n+00034d00: 616e 6167 6572 2061 7420 7468 6520 6769 anager at the gi\n+00034d10: 7665 6e20 7061 7468 2061 6e64 2074 6865 ven path and the\n+00034d20: 2062 7269 6467 6520 656d 6974 7320 226d bridge emits \"m\n+00034d30: 6574 6122 2061 6e64 0a23 2020 2022 6e6f eta\" and.# \"no\n+00034d40: 7469 6679 2220 6d65 7373 6167 6573 2074 tify\" messages t\n+00034d50: 6f20 6465 7363 7269 6265 2061 6c6c 2069 o describe all i\n+00034d60: 6e74 6572 6661 6365 7320 616e 6420 6f62 nterfaces and ob\n+00034d70: 6a65 6374 7320 7265 706f 7274 6564 0a23 jects reported.#\n+00034d80: 2020 2062 7920 7468 6174 204f 626a 6563 by that Objec\n+00034d90: 744d 616e 6167 6572 2e0a 230a 2320 2d20 tManager..#.# - \n+00034da0: 5468 6520 636c 6965 6e74 206d 616b 6573 The client makes\n+00034db0: 2061 206d 6574 686f 6420 6361 6c6c 2074 a method call t\n+00034dc0: 6861 7420 6361 7573 6573 2061 206e 6577 hat causes a new\n+00034dd0: 206f 626a 6563 7420 7769 7468 2061 206e object with a n\n+00034de0: 6577 0a23 2020 2069 6e74 6572 6661 6365 ew.# interface\n+00034df0: 2074 6f20 6170 7065 6172 2061 7420 7468 to appear at th\n+00034e00: 6520 4f62 6a65 6374 4d61 6e61 6765 722e e ObjectManager.\n+00034e10: 2020 5468 6520 6272 6964 6765 2077 696c The bridge wil\n+00034e20: 6c20 7365 6e64 2061 0a23 2020 2022 6d65 l send a.# \"me\n+00034e30: 7461 2220 616e 6420 226e 6f74 6966 7922 ta\" and \"notify\"\n+00034e40: 206d 6573 7361 6765 2074 6f20 6465 7363 message to desc\n+00034e50: 7269 6265 2074 6869 7320 6e65 7720 6f62 ribe this new ob\n+00034e60: 6a65 6374 2e0a 230a 2320 2d20 5369 6e63 ject..#.# - Sinc\n+00034e70: 6520 7468 6520 496e 7465 7266 6163 6573 e the Interfaces\n+00034e80: 4164 6465 6420 7369 676e 616c 2077 6173 Added signal was\n+00034e90: 2065 6d69 7474 6564 2062 6566 6f72 6520 emitted before \n+00034ea0: 7468 6520 6d65 7468 6f64 0a23 2020 2072 the method.# r\n+00034eb0: 6570 6c79 2c20 7468 6520 6272 6964 6765 eply, the bridge\n+00034ec0: 206d 7573 7420 7365 6e64 2074 6865 2022 must send the \"\n+00034ed0: 6d65 7461 2220 616e 6420 226e 6f74 6966 meta\" and \"notif\n+00034ee0: 7922 206d 6573 7361 6765 730a 2320 2020 y\" messages.# \n+00034ef0: 6265 666f 7265 2074 6865 206d 6574 686f before the metho\n+00034f00: 6420 7265 706c 7920 6d65 7373 6167 652e d reply message.\n+00034f10: 0a23 0a23 202d 2048 6f77 6576 6572 2c20 .#.# - However, \n+00034f20: 696e 206f 7264 6572 2074 6f20 636f 6e73 in order to cons\n+00034f30: 7472 7563 7420 7468 6520 226d 6574 6122 truct the \"meta\"\n+00034f40: 206d 6573 7361 6765 2c20 7468 6520 6272 message, the br\n+00034f50: 6964 6765 206d 7573 740a 2320 2020 7065 idge must.# pe\n+00034f60: 7266 6f72 6d20 6120 496e 7472 6f73 7065 rform a Introspe\n+00034f70: 6374 2063 616c 6c2c 2061 6e64 2063 6f6e ct call, and con\n+00034f80: 7365 7175 656e 746c 7920 6d75 7374 2064 sequently must d\n+00034f90: 656c 6179 2073 656e 6469 6e67 2074 6865 elay sending the\n+00034fa0: 0a23 2020 206d 6574 686f 6420 7265 706c .# method repl\n+00034fb0: 7920 756e 7469 6c20 7468 6174 2063 616c y until that cal\n+00034fc0: 6c20 6861 7320 6669 6e69 7368 6564 2e0a l has finished..\n+00034fd0: 230a 2320 5468 6520 5079 7468 6f6e 2062 #.# The Python b\n+00034fe0: 7269 6467 6520 696d 706c 656d 656e 7473 ridge implements\n+00034ff0: 2074 6869 7320 6465 6c61 7969 6e67 206f this delaying o\n+00035000: 6620 6d65 7373 6167 6573 2077 6974 680a f messages with.\n+00035010: 2320 636f 726f 7574 696e 6573 2061 6e64 # coroutines and\n+00035020: 2061 2066 6169 7220 6d75 7465 782e 2045 a fair mutex. E\n+00035030: 7665 7279 206d 6573 7361 6765 2063 6f6d very message com\n+00035040: 696e 6720 6672 6f6d 2044 2d42 7573 2077 ing from D-Bus w\n+00035050: 696c 6c0a 2320 7761 6974 206f 6e20 7468 ill.# wait on th\n+00035060: 6520 6d75 7465 7820 666f 7220 6974 7320 e mutex for its \n+00035070: 7475 726e 2074 6f20 7365 6e64 2069 7473 turn to send its\n+00035080: 206d 6573 7361 6765 206f 6e20 7468 6520 message on the \n+00035090: 436f 636b 7069 740a 2320 6368 616e 6e65 Cockpit.# channe\n+000350a0: 6c2c 2061 6e64 2077 696c 6c20 6b65 6570 l, and will keep\n+000350b0: 2074 6861 7420 6d75 7465 7820 6c6f 636b that mutex lock\n+000350c0: 6564 2075 6e74 696c 2069 7420 6973 2064 ed until it is d\n+000350d0: 6f6e 6520 7769 7468 0a23 2073 656e 6469 one with.# sendi\n+000350e0: 6e67 2e20 2053 696e 6365 2074 6865 206d ng. Since the m\n+000350f0: 7574 6578 2069 7320 6661 6972 2c20 6576 utex is fair, ev\n+00035100: 6572 796f 6e65 2077 696c 6c20 6e69 6365 eryone will nice\n+00035110: 6c79 2077 6169 7420 696e 206c 696e 650a ly wait in line.\n+00035120: 2320 7769 7468 6f75 7420 6d65 7373 6167 # without messag\n+00035130: 6573 2067 6574 7469 6e67 2072 652d 6f72 es getting re-or\n+00035140: 6465 7265 642e 0a23 0a23 2054 6865 2073 dered..#.# The s\n+00035150: 6365 6e61 7269 6f20 6162 6f76 6520 7769 cenario above wi\n+00035160: 6c6c 2070 6c61 7920 6f75 7420 6c69 6b65 ll play out like\n+00035170: 2074 6869 733a 0a23 0a23 202d 2057 6869 this:.#.# - Whi\n+00035180: 6c65 2061 6464 696e 6720 7468 6520 696e le adding the in\n+00035190: 6974 6961 6c20 2277 6174 6368 222c 2074 itial \"watch\", t\n+000351a0: 6865 206c 6f63 6b20 6973 2068 656c 6420 he lock is held \n+000351b0: 756e 7469 6c20 7468 650a 2320 2020 226d until the.# \"m\n+000351c0: 6574 6122 2061 6e64 2022 6e6f 7469 6679 eta\" and \"notify\n+000351d0: 2220 6d65 7373 6167 6573 2068 6176 6520 \" messages have \n+000351e0: 6265 656e 2073 656e 742e 0a23 0a23 202d been sent..#.# -\n+000351f0: 204c 6174 6572 2c20 7768 656e 2074 6865 Later, when the\n+00035200: 2049 6e74 6572 6661 6365 7341 6464 6564 InterfacesAdded\n+00035210: 2073 6967 6e61 6c20 636f 6d65 7320 696e signal comes in\n+00035220: 2074 6861 7420 6861 7320 6265 656e 0a23 that has been.#\n+00035230: 2020 2074 7269 6767 6572 6564 2062 7920 triggered by \n+00035240: 7468 6520 6d65 7468 6f64 2063 616c 6c2c the method call,\n+00035250: 2074 6865 206d 7574 6578 2077 696c 6c20 the mutex will \n+00035260: 6265 206c 6f63 6b65 6420 7768 696c 6520 be locked while \n+00035270: 7468 650a 2320 2020 6e65 6365 7373 6172 the.# necessar\n+00035280: 7920 696e 7472 6f73 7065 6374 696f 6e20 y introspection \n+00035290: 6973 2067 6f69 6e67 206f 6e2e 0a23 0a23 is going on..#.#\n+000352a0: 202d 2054 6865 206d 6574 686f 6420 7265 - The method re\n+000352b0: 706c 7920 7769 6c6c 206c 696b 656c 7920 ply will likely \n+000352c0: 636f 6d65 2077 6869 6c65 2074 6865 206d come while the m\n+000352d0: 7574 6578 2069 7320 6c6f 636b 6564 2c20 utex is locked, \n+000352e0: 616e 640a 2320 2020 7468 6520 7461 736b and.# the task\n+000352f0: 2066 6f72 2073 656e 6469 6e67 2074 6861 for sending tha\n+00035300: 7420 7265 706c 7920 6f6e 2074 6865 2043 t reply on the C\n+00035310: 6f63 6b70 6974 2063 6861 6e6e 656c 2077 ockpit channel w\n+00035320: 696c 6c20 656e 7465 720a 2320 2020 7468 ill enter.# th\n+00035330: 6520 7761 6974 2071 7565 7565 206f 6620 e wait queue of \n+00035340: 7468 6520 6d75 7465 782e 0a23 0a23 202d the mutex..#.# -\n+00035350: 204f 6e63 6520 7468 6520 696e 7472 6f73 Once the intros\n+00035360: 7065 6374 696f 6e20 6973 2064 6f6e 6520 pection is done \n+00035370: 616e 6420 7468 6520 6e65 7720 226d 6574 and the new \"met\n+00035380: 6122 2061 6e64 2022 6e6f 7469 6679 220a a\" and \"notify\".\n+00035390: 2320 2020 6d65 7373 6167 6573 2068 6176 # messages hav\n+000353a0: 6520 6265 656e 2073 656e 742c 2074 6865 e been sent, the\n+000353b0: 206d 7574 6578 2069 7320 756e 6c6f 636b mutex is unlock\n+000353c0: 6564 2c20 7468 6520 6d65 7468 6f64 2072 ed, the method r\n+000353d0: 6570 6c79 0a23 2020 2074 6173 6b20 6163 eply.# task ac\n+000353e0: 7175 6972 6573 2069 742c 2061 6e64 2073 quires it, and s\n+000353f0: 656e 6473 2069 7473 206d 6573 7361 6765 ends its message\n+00035400: 2e0a 0a0a 636c 6173 7320 496e 7465 7266 ....class Interf\n+00035410: 6163 6543 6163 6865 3a0a 2020 2020 6465 aceCache:. de\n+00035420: 6620 5f5f 696e 6974 5f5f 2873 656c 6629 f __init__(self)\n+00035430: 3a0a 2020 2020 2020 2020 7365 6c66 2e63 :. self.c\n+00035440: 6163 6865 203d 207b 7d0a 2020 2020 2020 ache = {}. \n+00035450: 2020 7365 6c66 2e6f 6c64 203d 2073 6574 self.old = set\n+00035460: 2829 2020 2320 496e 7465 7266 6163 6573 () # Interfaces\n+00035470: 2061 6c72 6561 6479 2072 6574 7572 6e65 already returne\n+00035480: 6420 6279 2067 6574 5f69 6e74 6572 6661 d by get_interfa\n+00035490: 6365 5f69 665f 6e65 770a 0a20 2020 2064 ce_if_new.. d\n+000354a0: 6566 2069 6e6a 6563 7428 7365 6c66 2c20 ef inject(self, \n+000354b0: 696e 7465 7266 6163 6573 293a 0a20 2020 interfaces):. \n+000354c0: 2020 2020 2073 656c 662e 6361 6368 652e self.cache.\n+000354d0: 7570 6461 7465 2869 6e74 6572 6661 6365 update(interface\n+000354e0: 7329 0a0a 2020 2020 6173 796e 6320 6465 s).. async de\n+000354f0: 6620 696e 7472 6f73 7065 6374 5f70 6174 f introspect_pat\n+00035500: 6828 7365 6c66 2c20 6275 732c 2064 6573 h(self, bus, des\n+00035510: 7469 6e61 7469 6f6e 2c20 6f62 6a65 6374 tination, object\n+00035520: 5f70 6174 6829 3a0a 2020 2020 2020 2020 _path):. \n+00035530: 786d 6c2c 203d 2061 7761 6974 2062 7573 xml, = await bus\n+00035540: 2e63 616c 6c5f 6d65 7468 6f64 5f61 7379 .call_method_asy\n+00035550: 6e63 2864 6573 7469 6e61 7469 6f6e 2c20 nc(destination, \n+00035560: 6f62 6a65 6374 5f70 6174 682c 0a20 2020 object_path,. \n+00035570: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00035580: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00035590: 2020 2020 2020 2020 276f 7267 2e66 7265 'org.fre\n+000355a0: 6564 6573 6b74 6f70 2e44 4275 732e 496e edesktop.DBus.In\n+000355b0: 7472 6f73 7065 6374 6162 6c65 272c 0a20 trospectable',. \n+000355c0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000355d0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000355e0: 2020 2020 2020 2020 2020 2749 6e74 726f 'Intro\n+000355f0: 7370 6563 7427 290a 0a20 2020 2020 2020 spect').. \n+00035600: 2065 7420 3d20 4554 2e66 726f 6d73 7472 et = ET.fromstr\n+00035610: 696e 6728 786d 6c29 0a0a 2020 2020 2020 ing(xml).. \n+00035620: 2020 696e 7465 7266 6163 6573 203d 207b interfaces = {\n+00035630: 7461 672e 6174 7472 6962 5b27 6e61 6d65 tag.attrib['name\n+00035640: 275d 3a20 696e 7472 6f73 7065 6374 696f ']: introspectio\n+00035650: 6e2e 7061 7273 655f 696e 7465 7266 6163 n.parse_interfac\n+00035660: 6528 7461 6729 2066 6f72 2074 6167 2069 e(tag) for tag i\n+00035670: 6e20 6574 2e66 696e 6461 6c6c 2827 696e n et.findall('in\n+00035680: 7465 7266 6163 6527 297d 0a0a 2020 2020 terface')}.. \n+00035690: 2020 2020 2320 4164 6420 616c 6c20 696e # Add all in\n+000356a0: 7465 7266 6163 6573 2077 6520 666f 756e terfaces we foun\n+000356b0: 643a 2077 6520 6d69 6768 7420 7573 6520 d: we might use \n+000356c0: 7468 656d 206c 6174 6572 0a20 2020 2020 them later. \n+000356d0: 2020 2073 656c 662e 696e 6a65 6374 2869 self.inject(i\n+000356e0: 6e74 6572 6661 6365 7329 0a0a 2020 2020 nterfaces).. \n+000356f0: 2020 2020 7265 7475 726e 2069 6e74 6572 return inter\n+00035700: 6661 6365 730a 0a20 2020 2061 7379 6e63 faces.. async\n+00035710: 2064 6566 2067 6574 5f69 6e74 6572 6661 def get_interfa\n+00035720: 6365 2873 656c 662c 2069 6e74 6572 6661 ce(self, interfa\n+00035730: 6365 5f6e 616d 652c 2062 7573 3d4e 6f6e ce_name, bus=Non\n+00035740: 652c 2064 6573 7469 6e61 7469 6f6e 3d4e e, destination=N\n+00035750: 6f6e 652c 206f 626a 6563 745f 7061 7468 one, object_path\n+00035760: 3d4e 6f6e 6529 3a0a 2020 2020 2020 2020 =None):. \n+00035770: 7472 793a 0a20 2020 2020 2020 2020 2020 try:. \n+00035780: 2072 6574 7572 6e20 7365 6c66 2e63 6163 return self.cac\n+00035790: 6865 5b69 6e74 6572 6661 6365 5f6e 616d he[interface_nam\n+000357a0: 655d 0a20 2020 2020 2020 2065 7863 6570 e]. excep\n+000357b0: 7420 4b65 7945 7272 6f72 3a0a 2020 2020 t KeyError:. \n+000357c0: 2020 2020 2020 2020 7061 7373 0a0a 2020 pass.. \n+000357d0: 2020 2020 2020 6966 2062 7573 2061 6e64 if bus and\n+000357e0: 206f 626a 6563 745f 7061 7468 3a0a 2020 object_path:. \n+000357f0: 2020 2020 2020 2020 2020 7472 793a 0a20 try:. \n+00035800: 2020 2020 2020 2020 2020 2020 2020 2061 a\n+00035810: 7761 6974 2073 656c 662e 696e 7472 6f73 wait self.intros\n+00035820: 7065 6374 5f70 6174 6828 6275 732c 2064 pect_path(bus, d\n+00035830: 6573 7469 6e61 7469 6f6e 2c20 6f62 6a65 estination, obje\n+00035840: 6374 5f70 6174 6829 0a20 2020 2020 2020 ct_path). \n+00035850: 2020 2020 2065 7863 6570 7420 4275 7345 except BusE\n+00035860: 7272 6f72 3a0a 2020 2020 2020 2020 2020 rror:. \n+00035870: 2020 2020 2020 7061 7373 0a0a 2020 2020 pass.. \n+00035880: 2020 2020 7265 7475 726e 2073 656c 662e return self.\n+00035890: 6361 6368 652e 6765 7428 696e 7465 7266 cache.get(interf\n+000358a0: 6163 655f 6e61 6d65 290a 0a20 2020 2061 ace_name).. a\n+000358b0: 7379 6e63 2064 6566 2067 6574 5f69 6e74 sync def get_int\n+000358c0: 6572 6661 6365 5f69 665f 6e65 7728 7365 erface_if_new(se\n+000358d0: 6c66 2c20 696e 7465 7266 6163 655f 6e61 lf, interface_na\n+000358e0: 6d65 2c20 6275 732c 2064 6573 7469 6e61 me, bus, destina\n+000358f0: 7469 6f6e 2c20 6f62 6a65 6374 5f70 6174 tion, object_pat\n+00035900: 6829 3a0a 2020 2020 2020 2020 6966 2069 h):. if i\n+00035910: 6e74 6572 6661 6365 5f6e 616d 6520 696e nterface_name in\n+00035920: 2073 656c 662e 6f6c 643a 0a20 2020 2020 self.old:. \n+00035930: 2020 2020 2020 2072 6574 7572 6e20 4e6f return No\n+00035940: 6e65 0a20 2020 2020 2020 2073 656c 662e ne. self.\n+00035950: 6f6c 642e 6164 6428 696e 7465 7266 6163 old.add(interfac\n+00035960: 655f 6e61 6d65 290a 2020 2020 2020 2020 e_name). \n+00035970: 7265 7475 726e 2061 7761 6974 2073 656c return await sel\n+00035980: 662e 6765 745f 696e 7465 7266 6163 6528 f.get_interface(\n+00035990: 696e 7465 7266 6163 655f 6e61 6d65 2c20 interface_name, \n+000359a0: 6275 732c 2064 6573 7469 6e61 7469 6f6e bus, destination\n+000359b0: 2c20 6f62 6a65 6374 5f70 6174 6829 0a0a , object_path)..\n+000359c0: 2020 2020 6173 796e 6320 6465 6620 6765 async def ge\n+000359d0: 745f 7369 676e 6174 7572 6528 7365 6c66 t_signature(self\n+000359e0: 2c20 696e 7465 7266 6163 655f 6e61 6d65 , interface_name\n+000359f0: 2c20 6d65 7468 6f64 2c20 6275 733d 4e6f , method, bus=No\n+00035a00: 6e65 2c20 6465 7374 696e 6174 696f 6e3d ne, destination=\n+00035a10: 4e6f 6e65 2c20 6f62 6a65 6374 5f70 6174 None, object_pat\n+00035a20: 683d 4e6f 6e65 293a 0a20 2020 2020 2020 h=None):. \n+00035a30: 2069 6e74 6572 6661 6365 203d 2061 7761 interface = awa\n+00035a40: 6974 2073 656c 662e 6765 745f 696e 7465 it self.get_inte\n+00035a50: 7266 6163 6528 696e 7465 7266 6163 655f rface(interface_\n+00035a60: 6e61 6d65 2c20 6275 732c 2064 6573 7469 name, bus, desti\n+00035a70: 6e61 7469 6f6e 2c20 6f62 6a65 6374 5f70 nation, object_p\n+00035a80: 6174 6829 0a20 2020 2020 2020 2069 6620 ath). if \n+00035a90: 696e 7465 7266 6163 6520 6973 204e 6f6e interface is Non\n+00035aa0: 653a 0a20 2020 2020 2020 2020 2020 2072 e:. r\n+00035ab0: 6169 7365 204b 6579 4572 726f 7228 6627 aise KeyError(f'\n+00035ac0: 496e 7465 7266 6163 6520 7b69 6e74 6572 Interface {inter\n+00035ad0: 6661 6365 5f6e 616d 657d 2069 7320 6e6f face_name} is no\n+00035ae0: 7420 666f 756e 6427 290a 0a20 2020 2020 t found').. \n+00035af0: 2020 2072 6574 7572 6e20 2727 2e6a 6f69 return ''.joi\n+00035b00: 6e28 696e 7465 7266 6163 655b 276d 6574 n(interface['met\n+00035b10: 686f 6473 275d 5b6d 6574 686f 645d 5b27 hods'][method]['\n+00035b20: 696e 275d 290a 0a0a 6465 6620 6e6f 7469 in'])...def noti\n+00035b30: 6679 5f75 7064 6174 6528 6e6f 7469 6679 fy_update(notify\n+00035b40: 2c20 7061 7468 2c20 696e 7465 7266 6163 , path, interfac\n+00035b50: 655f 6e61 6d65 2c20 7072 6f70 7329 3a0a e_name, props):.\n+00035b60: 2020 2020 6e6f 7469 6679 2e73 6574 6465 notify.setde\n+00035b70: 6661 756c 7428 7061 7468 2c20 7b7d 295b fault(path, {})[\n+00035b80: 696e 7465 7266 6163 655f 6e61 6d65 5d20 interface_name] \n+00035b90: 3d20 7b6b 3a20 762e 7661 6c75 6520 666f = {k: v.value fo\n+00035ba0: 7220 6b2c 2076 2069 6e20 7072 6f70 732e r k, v in props.\n+00035bb0: 6974 656d 7328 297d 0a0a 0a63 6c61 7373 items()}...class\n+00035bc0: 2044 4275 7343 6861 6e6e 656c 2843 6861 DBusChannel(Cha\n+00035bd0: 6e6e 656c 293a 0a20 2020 206a 736f 6e5f nnel):. json_\n+00035be0: 656e 636f 6465 7220 3d20 7379 7374 656d encoder = system\n+00035bf0: 645f 6374 7970 6573 2e4a 534f 4e45 6e63 d_ctypes.JSONEnc\n+00035c00: 6f64 6572 2869 6e64 656e 743d 3229 0a20 oder(indent=2). \n+00035c10: 2020 2070 6179 6c6f 6164 203d 2027 6462 payload = 'db\n+00035c20: 7573 2d6a 736f 6e33 270a 0a20 2020 206d us-json3'.. m\n+00035c30: 6174 6368 6573 203d 204e 6f6e 650a 2020 atches = None. \n+00035c40: 2020 6e61 6d65 203d 204e 6f6e 650a 2020 name = None. \n+00035c50: 2020 6275 7320 3d20 4e6f 6e65 0a20 2020 bus = None. \n+00035c60: 206f 776e 6572 203d 204e 6f6e 650a 0a20 owner = None.. \n+00035c70: 2020 2061 7379 6e63 2064 6566 2073 6574 async def set\n+00035c80: 7570 5f6e 616d 655f 6f77 6e65 725f 7472 up_name_owner_tr\n+00035c90: 6163 6b69 6e67 2873 656c 6629 3a0a 2020 acking(self):. \n+00035ca0: 2020 2020 2020 6465 6620 7365 6e64 5f6f def send_o\n+00035cb0: 776e 6572 286f 776e 6572 293a 0a20 2020 wner(owner):. \n+00035cc0: 2020 2020 2020 2020 2023 2057 6520 6d75 # We mu\n+00035cd0: 7374 2062 6520 6361 7265 6675 6c20 6e6f st be careful no\n+00035ce0: 7420 746f 2073 656e 6420 6475 706c 6963 t to send duplic\n+00035cf0: 6174 6520 6f77 6e65 720a 2020 2020 2020 ate owner. \n+00035d00: 2020 2020 2020 2320 6e6f 7469 6669 6361 # notifica\n+00035d10: 7469 6f6e 732e 2063 6f63 6b70 6974 2e6a tions. cockpit.j\n+00035d20: 7320 7265 6c69 6573 206f 6e20 7468 6174 s relies on that\n+00035d30: 2e0a 2020 2020 2020 2020 2020 2020 6966 .. if\n+00035d40: 2073 656c 662e 6f77 6e65 7220 213d 206f self.owner != o\n+00035d50: 776e 6572 3a0a 2020 2020 2020 2020 2020 wner:. \n+00035d60: 2020 2020 2020 7365 6c66 2e6f 776e 6572 self.owner\n+00035d70: 203d 206f 776e 6572 0a20 2020 2020 2020 = owner. \n+00035d80: 2020 2020 2020 2020 2073 656c 662e 7365 self.se\n+00035d90: 6e64 5f6a 736f 6e28 6f77 6e65 723d 6f77 nd_json(owner=ow\n+00035da0: 6e65 7229 0a0a 2020 2020 2020 2020 6465 ner).. de\n+00035db0: 6620 6861 6e64 6c65 7228 6d65 7373 6167 f handler(messag\n+00035dc0: 6529 3a0a 2020 2020 2020 2020 2020 2020 e):. \n+00035dd0: 5f6e 616d 652c 205f 6f6c 642c 206e 6577 _name, _old, new\n+00035de0: 203d 206d 6573 7361 6765 2e67 6574 5f62 = message.get_b\n+00035df0: 6f64 7928 290a 2020 2020 2020 2020 2020 ody(). \n+00035e00: 2020 7365 6e64 5f6f 776e 6572 286f 776e send_owner(own\n+00035e10: 6572 3d6e 6577 2069 6620 6e65 7720 213d er=new if new !=\n+00035e20: 2022 2220 656c 7365 204e 6f6e 6529 0a20 \"\" else None). \n+00035e30: 2020 2020 2020 2073 656c 662e 6164 645f self.add_\n+00035e40: 7369 676e 616c 5f68 616e 646c 6572 2868 signal_handler(h\n+00035e50: 616e 646c 6572 2c0a 2020 2020 2020 2020 andler,. \n+00035e60: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00035e70: 2020 2020 2020 2020 7365 6e64 6572 3d27 sender='\n+00035e80: 6f72 672e 6672 6565 6465 736b 746f 702e org.freedesktop.\n+00035e90: 4442 7573 272c 0a20 2020 2020 2020 2020 DBus',. \n 00035ea0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00035eb0: 6d65 7461 2e75 7064 6174 6528 7b69 6661 meta.update({ifa\n-00035ec0: 6365 3a20 6d6d 7d29 0a20 2020 2020 2020 ce: mm}). \n-00035ed0: 2020 2020 2020 2020 2020 2020 206e 6f74 not\n-00035ee0: 6966 795f 7570 6461 7465 286e 6f74 6966 ify_update(notif\n-00035ef0: 792c 2070 2c20 6966 6163 652c 2070 726f y, p, iface, pro\n-00035f00: 7073 290a 0a20 2020 2061 7379 6e63 2064 ps).. async d\n-00035f10: 6566 2073 6574 7570 5f70 6174 685f 7761 ef setup_path_wa\n-00035f20: 7463 6828 7365 6c66 2c20 7061 7468 2c20 tch(self, path, \n-00035f30: 696e 7465 7266 6163 655f 6e61 6d65 2c20 interface_name, \n-00035f40: 7265 6375 7273 6976 655f 7072 6f70 732c recursive_props,\n-00035f50: 206d 6574 612c 206e 6f74 6966 7929 3a0a meta, notify):.\n-00035f60: 2020 2020 2020 2020 2320 5761 7463 6820 # Watch \n-00035f70: 6120 7369 6e67 6c65 206f 626a 6563 7420 a single object \n-00035f80: 6174 2022 7061 7468 222c 2062 7574 206d at \"path\", but m\n-00035f90: 6179 6265 2061 6c73 6f20 7761 7463 6820 aybe also watch \n-00035fa0: 666f 720a 2020 2020 2020 2020 2320 7072 for. # pr\n-00035fb0: 6f70 6572 7479 2063 6861 6e67 6573 2066 operty changes f\n-00035fc0: 6f72 2061 6c6c 206f 626a 6563 7473 2062 or all objects b\n-00035fd0: 656c 6f77 2022 7061 7468 222e 0a0a 2020 elow \"path\"... \n-00035fe0: 2020 2020 2020 6173 796e 6320 6465 6620 async def \n-00035ff0: 6861 6e64 6c65 7228 6d65 7373 6167 6529 handler(message)\n-00036000: 3a0a 2020 2020 2020 2020 2020 2020 6173 :. as\n-00036010: 796e 6320 7769 7468 2073 656c 662e 7761 ync with self.wa\n-00036020: 7463 685f 7072 6f63 6573 7369 6e67 5f6c tch_processing_l\n-00036030: 6f63 6b3a 0a20 2020 2020 2020 2020 2020 ock:. \n-00036040: 2020 2020 2070 6174 6820 3d20 6d65 7373 path = mess\n-00036050: 6167 652e 6765 745f 7061 7468 2829 0a20 age.get_path(). \n-00036060: 2020 2020 2020 2020 2020 2020 2020 206e n\n-00036070: 616d 652c 2070 726f 7073 2c20 696e 7661 ame, props, inva\n-00036080: 6c69 6473 203d 206d 6573 7361 6765 2e67 lids = message.g\n-00036090: 6574 5f62 6f64 7928 290a 2020 2020 2020 et_body(). \n-000360a0: 2020 2020 2020 2020 2020 6c6f 6767 6572 logger\n-000360b0: 2e64 6562 7567 2827 4e4f 5449 4659 3a20 .debug('NOTIFY: \n-000360c0: 2573 2025 7320 2573 2025 7327 2c20 7061 %s %s %s %s', pa\n-000360d0: 7468 2c20 6e61 6d65 2c20 7072 6f70 732c th, name, props,\n-000360e0: 2069 6e76 616c 6964 7329 0a20 2020 2020 invalids). \n-000360f0: 2020 2020 2020 2020 2020 2066 6f72 2069 for i\n-00036100: 6e76 2069 6e20 696e 7661 6c69 6473 3a0a nv in invalids:.\n-00036110: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00036120: 2020 2020 7472 793a 0a20 2020 2020 2020 try:. \n-00036130: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00036140: 2072 6570 6c79 2c20 3d20 6177 6169 7420 reply, = await \n-00036150: 7365 6c66 2e62 7573 2e63 616c 6c5f 6d65 self.bus.call_me\n-00036160: 7468 6f64 5f61 7379 6e63 2873 656c 662e thod_async(self.\n-00036170: 6e61 6d65 2c20 7061 7468 2c0a 2020 2020 name, path,. \n-00036180: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00036190: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000361a0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000361b0: 2020 2020 2020 2020 2020 2020 2020 276f 'o\n-000361c0: 7267 2e66 7265 6564 6573 6b74 6f70 2e44 rg.freedesktop.D\n-000361d0: 4275 732e 5072 6f70 6572 7469 6573 272c Bus.Properties',\n-000361e0: 2027 4765 7427 2c0a 2020 2020 2020 2020 'Get',. \n-000361f0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00036200: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00036210: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00036220: 2020 2020 2020 2020 2020 2773 7327 2c20 'ss', \n-00036230: 6e61 6d65 2c20 696e 7629 0a20 2020 2020 name, inv). \n-00036240: 2020 2020 2020 2020 2020 2020 2020 2065 e\n-00036250: 7863 6570 7420 4275 7345 7272 6f72 2061 xcept BusError a\n-00036260: 7320 6578 633a 0a20 2020 2020 2020 2020 s exc:. \n-00036270: 2020 2020 2020 2020 2020 2020 2020 206c l\n-00036280: 6f67 6765 722e 6465 6275 6728 2766 6169 ogger.debug('fai\n-00036290: 6c65 6420 746f 2066 6574 6368 2070 726f led to fetch pro\n-000362a0: 7065 7274 7920 2573 2e25 7320 6f6e 2025 perty %s.%s on %\n-000362b0: 7320 2573 3a20 2573 272c 0a20 2020 2020 s %s: %s',. \n-000362c0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00035eb0: 2020 2020 2020 2070 6174 683d 272f 6f72 path='/or\n+00035ec0: 672f 6672 6565 6465 736b 746f 702f 4442 g/freedesktop/DB\n+00035ed0: 7573 272c 0a20 2020 2020 2020 2020 2020 us',. \n+00035ee0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00035ef0: 2020 2020 2069 6e74 6572 6661 6365 3d27 interface='\n+00035f00: 6f72 672e 6672 6565 6465 736b 746f 702e org.freedesktop.\n+00035f10: 4442 7573 272c 0a20 2020 2020 2020 2020 DBus',. \n+00035f20: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00035f30: 2020 2020 2020 206d 656d 6265 723d 274e member='N\n+00035f40: 616d 654f 776e 6572 4368 616e 6765 6427 ameOwnerChanged'\n+00035f50: 2c0a 2020 2020 2020 2020 2020 2020 2020 ,. \n+00035f60: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00035f70: 2020 6172 6730 3d73 656c 662e 6e61 6d65 arg0=self.name\n+00035f80: 290a 2020 2020 2020 2020 7472 793a 0a20 ). try:. \n+00035f90: 2020 2020 2020 2020 2020 2075 6e69 7175 uniqu\n+00035fa0: 655f 6e61 6d65 2c20 3d20 6177 6169 7420 e_name, = await \n+00035fb0: 7365 6c66 2e62 7573 2e63 616c 6c5f 6d65 self.bus.call_me\n+00035fc0: 7468 6f64 5f61 7379 6e63 2822 6f72 672e thod_async(\"org.\n+00035fd0: 6672 6565 6465 736b 746f 702e 4442 7573 freedesktop.DBus\n+00035fe0: 222c 0a20 2020 2020 2020 2020 2020 2020 \",. \n+00035ff0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00036000: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00036010: 2020 2020 2020 2020 2020 2020 2020 2022 \"\n+00036020: 2f6f 7267 2f66 7265 6564 6573 6b74 6f70 /org/freedesktop\n+00036030: 2f44 4275 7322 2c0a 2020 2020 2020 2020 /DBus\",. \n+00036040: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00036050: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00036060: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00036070: 2020 2020 226f 7267 2e66 7265 6564 6573 \"org.freedes\n+00036080: 6b74 6f70 2e44 4275 7322 2c0a 2020 2020 ktop.DBus\",. \n+00036090: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000360a0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000360b0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000360c0: 2020 2020 2020 2020 2247 6574 4e61 6d65 \"GetName\n+000360d0: 4f77 6e65 7222 2c20 2273 222c 2073 656c Owner\", \"s\", sel\n+000360e0: 662e 6e61 6d65 290a 2020 2020 2020 2020 f.name). \n+000360f0: 6578 6365 7074 2042 7573 4572 726f 7220 except BusError \n+00036100: 6173 2065 7272 6f72 3a0a 2020 2020 2020 as error:. \n+00036110: 2020 2020 2020 6966 2065 7272 6f72 2e6e if error.n\n+00036120: 616d 6520 3d3d 2022 6f72 672e 6672 6565 ame == \"org.free\n+00036130: 6465 736b 746f 702e 4442 7573 2e45 7272 desktop.DBus.Err\n+00036140: 6f72 2e4e 616d 6548 6173 4e6f 4f77 6e65 or.NameHasNoOwne\n+00036150: 7222 3a0a 2020 2020 2020 2020 2020 2020 r\":. \n+00036160: 2020 2020 2320 5472 7920 746f 2073 7461 # Try to sta\n+00036170: 7274 2069 742e 2020 4966 2069 7420 7374 rt it. If it st\n+00036180: 6172 7473 2073 7563 6365 7373 6675 6c6c arts successfull\n+00036190: 792c 2077 6520 7769 6c6c 0a20 2020 2020 y, we will. \n+000361a0: 2020 2020 2020 2020 2020 2023 2067 6574 # get\n+000361b0: 2061 204e 616d 654f 776e 6572 4368 616e a NameOwnerChan\n+000361c0: 6765 6420 7369 676e 616c 2028 7768 6963 ged signal (whic\n+000361d0: 6820 7769 6c6c 2073 6574 0a20 2020 2020 h will set. \n+000361e0: 2020 2020 2020 2020 2020 2023 2073 656c # sel\n+000361f0: 662e 6f77 6e65 7229 2062 6566 6f72 6520 f.owner) before \n+00036200: 5374 6172 7453 6572 7669 6365 4279 4e61 StartServiceByNa\n+00036210: 6d65 2072 6574 7572 6e73 2e0a 2020 2020 me returns.. \n+00036220: 2020 2020 2020 2020 2020 2020 7472 793a try:\n+00036230: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+00036240: 2020 2020 2061 7761 6974 2073 656c 662e await self.\n+00036250: 6275 732e 6361 6c6c 5f6d 6574 686f 645f bus.call_method_\n+00036260: 6173 796e 6328 226f 7267 2e66 7265 6564 async(\"org.freed\n+00036270: 6573 6b74 6f70 2e44 4275 7322 2c0a 2020 esktop.DBus\",. \n+00036280: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00036290: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000362a0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000362b0: 2020 2022 2f6f 7267 2f66 7265 6564 6573 \"/org/freedes\n+000362c0: 6b74 6f70 2f44 4275 7322 2c0a 2020 2020 ktop/DBus\",. \n 000362d0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000362e0: 6e61 6d65 2c20 696e 762c 2073 656c 662e name, inv, self.\n-000362f0: 6e61 6d65 2c20 7061 7468 2c20 7374 7228 name, path, str(\n-00036300: 6578 6329 290a 2020 2020 2020 2020 2020 exc)). \n-00036310: 2020 2020 2020 2020 2020 2020 2020 636f co\n-00036320: 6e74 696e 7565 0a20 2020 2020 2020 2020 ntinue. \n-00036330: 2020 2020 2020 2020 2020 2070 726f 7073 props\n-00036340: 5b69 6e76 5d20 3d20 7265 706c 790a 2020 [inv] = reply. \n-00036350: 2020 2020 2020 2020 2020 2020 2020 6e6f no\n-00036360: 7469 6679 203d 207b 7d0a 2020 2020 2020 tify = {}. \n-00036370: 2020 2020 2020 2020 2020 6e6f 7469 6679 notify\n-00036380: 5f75 7064 6174 6528 6e6f 7469 6679 2c20 _update(notify, \n-00036390: 7061 7468 2c20 6e61 6d65 2c20 7072 6f70 path, name, prop\n-000363a0: 7329 0a20 2020 2020 2020 2020 2020 2020 s). \n-000363b0: 2020 2073 656c 662e 7365 6e64 5f6a 736f self.send_jso\n-000363c0: 6e28 6e6f 7469 6679 3d6e 6f74 6966 7929 n(notify=notify)\n-000363d0: 0a0a 2020 2020 2020 2020 7468 6973 5f6d .. this_m\n-000363e0: 6574 6120 3d20 6177 6169 7420 7365 6c66 eta = await self\n-000363f0: 2e63 6163 6865 2e69 6e74 726f 7370 6563 .cache.introspec\n-00036400: 745f 7061 7468 2873 656c 662e 6275 732c t_path(self.bus,\n-00036410: 2073 656c 662e 6e61 6d65 2c20 7061 7468 self.name, path\n-00036420: 290a 2020 2020 2020 2020 6966 2069 6e74 ). if int\n-00036430: 6572 6661 6365 5f6e 616d 6520 6973 206e erface_name is n\n-00036440: 6f74 204e 6f6e 653a 0a20 2020 2020 2020 ot None:. \n-00036450: 2020 2020 2069 6e74 6572 6661 6365 203d interface =\n-00036460: 2074 6869 735f 6d65 7461 2e67 6574 2869 this_meta.get(i\n-00036470: 6e74 6572 6661 6365 5f6e 616d 6529 0a20 nterface_name). \n-00036480: 2020 2020 2020 2020 2020 2074 6869 735f this_\n-00036490: 6d65 7461 203d 207b 696e 7465 7266 6163 meta = {interfac\n-000364a0: 655f 6e61 6d65 3a20 696e 7465 7266 6163 e_name: interfac\n-000364b0: 657d 0a20 2020 2020 2020 206d 6574 612e e}. meta.\n-000364c0: 7570 6461 7465 2874 6869 735f 6d65 7461 update(this_meta\n-000364d0: 290a 2020 2020 2020 2020 6966 2072 6563 ). if rec\n-000364e0: 7572 7369 7665 5f70 726f 7073 3a0a 2020 ursive_props:. \n-000364f0: 2020 2020 2020 2020 2020 7365 6c66 2e61 self.a\n-00036500: 6464 5f61 7379 6e63 5f73 6967 6e61 6c5f dd_async_signal_\n-00036510: 6861 6e64 6c65 7228 6861 6e64 6c65 722c handler(handler,\n-00036520: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-00036530: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00036540: 2020 2020 2020 2020 2020 2069 6e74 6572 inter\n-00036550: 6661 6365 3d22 6f72 672e 6672 6565 6465 face=\"org.freede\n-00036560: 736b 746f 702e 4442 7573 2e50 726f 7065 sktop.DBus.Prope\n-00036570: 7274 6965 7322 2c0a 2020 2020 2020 2020 rties\",. \n-00036580: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00036590: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000365a0: 2020 7061 7468 5f6e 616d 6573 7061 6365 path_namespace\n-000365b0: 3d70 6174 6829 0a20 2020 2020 2020 2065 =path). e\n-000365c0: 6c73 653a 0a20 2020 2020 2020 2020 2020 lse:. \n-000365d0: 2073 656c 662e 6164 645f 6173 796e 635f self.add_async_\n-000365e0: 7369 676e 616c 5f68 616e 646c 6572 2868 signal_handler(h\n-000365f0: 616e 646c 6572 2c0a 2020 2020 2020 2020 andler,. \n-00036600: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00036610: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00036620: 2020 696e 7465 7266 6163 653d 226f 7267 interface=\"org\n-00036630: 2e66 7265 6564 6573 6b74 6f70 2e44 4275 .freedesktop.DBu\n-00036640: 732e 5072 6f70 6572 7469 6573 222c 0a20 s.Properties\",. \n-00036650: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00036660: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00036670: 2020 2020 2020 2020 2070 6174 683d 7061 path=pa\n-00036680: 7468 290a 0a20 2020 2020 2020 2066 6f72 th).. for\n-00036690: 206e 616d 6520 696e 206d 6574 613a 0a20 name in meta:. \n-000366a0: 2020 2020 2020 2020 2020 2069 6620 6e61 if na\n-000366b0: 6d65 2e73 7461 7274 7377 6974 6828 226f me.startswith(\"o\n-000366c0: 7267 2e66 7265 6564 6573 6b74 6f70 2e44 rg.freedesktop.D\n-000366d0: 4275 732e 2229 3a0a 2020 2020 2020 2020 Bus.\"):. \n-000366e0: 2020 2020 2020 2020 636f 6e74 696e 7565 continue\n-000366f0: 0a20 2020 2020 2020 2020 2020 2074 7279 . try\n-00036700: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n-00036710: 2020 7072 6f70 732c 203d 2061 7761 6974 props, = await\n-00036720: 2073 656c 662e 6275 732e 6361 6c6c 5f6d self.bus.call_m\n-00036730: 6574 686f 645f 6173 796e 6328 7365 6c66 ethod_async(self\n-00036740: 2e6e 616d 652c 2070 6174 682c 0a20 2020 .name, path,. \n-00036750: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000362e0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000362f0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00036300: 2022 6f72 672e 6672 6565 6465 736b 746f \"org.freedeskto\n+00036310: 702e 4442 7573 222c 0a20 2020 2020 2020 p.DBus\",. \n+00036320: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00036330: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00036340: 2020 2020 2020 2020 2020 2020 2020 2253 \"S\n+00036350: 7461 7274 5365 7276 6963 6542 794e 616d tartServiceByNam\n+00036360: 6522 2c20 2273 7522 2c20 7365 6c66 2e6e e\", \"su\", self.n\n+00036370: 616d 652c 2030 290a 2020 2020 2020 2020 ame, 0). \n+00036380: 2020 2020 2020 2020 6578 6365 7074 2042 except B\n+00036390: 7573 4572 726f 7220 6173 2073 7461 7274 usError as start\n+000363a0: 5f65 7272 6f72 3a0a 2020 2020 2020 2020 _error:. \n+000363b0: 2020 2020 2020 2020 2020 2020 6c6f 6767 logg\n+000363c0: 6572 2e64 6562 7567 2822 4661 696c 6564 er.debug(\"Failed\n+000363d0: 2074 6f20 7374 6172 7420 7365 7276 6963 to start servic\n+000363e0: 6520 2725 7327 3a20 2573 222c 2073 656c e '%s': %s\", sel\n+000363f0: 662e 6e61 6d65 2c20 7374 6172 745f 6572 f.name, start_er\n+00036400: 726f 722e 6d65 7373 6167 6529 0a20 2020 ror.message). \n+00036410: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00036420: 2073 656c 662e 7365 6e64 5f6a 736f 6e28 self.send_json(\n+00036430: 6f77 6e65 723d 4e6f 6e65 290a 2020 2020 owner=None). \n+00036440: 2020 2020 2020 2020 656c 7365 3a0a 2020 else:. \n+00036450: 2020 2020 2020 2020 2020 2020 2020 6c6f lo\n+00036460: 6767 6572 2e64 6562 7567 2822 4661 696c gger.debug(\"Fail\n+00036470: 6564 2074 6f20 6765 7420 6f77 6e65 7220 ed to get owner \n+00036480: 6f66 2073 6572 7669 6365 2027 2573 273a of service '%s':\n+00036490: 2025 7322 2c20 7365 6c66 2e6e 616d 652c %s\", self.name,\n+000364a0: 2065 7272 6f72 2e6d 6573 7361 6765 290a error.message).\n+000364b0: 2020 2020 2020 2020 656c 7365 3a0a 2020 else:. \n+000364c0: 2020 2020 2020 2020 2020 7365 6e64 5f6f send_o\n+000364d0: 776e 6572 2875 6e69 7175 655f 6e61 6d65 wner(unique_name\n+000364e0: 290a 0a20 2020 2064 6566 2064 6f5f 6f70 ).. def do_op\n+000364f0: 656e 2873 656c 662c 206f 7074 696f 6e73 en(self, options\n+00036500: 293a 0a20 2020 2020 2020 2073 656c 662e ):. self.\n+00036510: 6361 6368 6520 3d20 496e 7465 7266 6163 cache = Interfac\n+00036520: 6543 6163 6865 2829 0a20 2020 2020 2020 eCache(). \n+00036530: 2073 656c 662e 6e61 6d65 203d 206f 7074 self.name = opt\n+00036540: 696f 6e73 2e67 6574 2827 6e61 6d65 2729 ions.get('name')\n+00036550: 0a20 2020 2020 2020 2073 656c 662e 6d61 . self.ma\n+00036560: 7463 6865 7320 3d20 5b5d 0a0a 2020 2020 tches = [].. \n+00036570: 2020 2020 6275 7320 3d20 6f70 7469 6f6e bus = option\n+00036580: 732e 6765 7428 2762 7573 2729 0a20 2020 s.get('bus'). \n+00036590: 2020 2020 2061 6464 7265 7373 203d 206f address = o\n+000365a0: 7074 696f 6e73 2e67 6574 2827 6164 6472 ptions.get('addr\n+000365b0: 6573 7327 290a 0a20 2020 2020 2020 2074 ess').. t\n+000365c0: 7279 3a0a 2020 2020 2020 2020 2020 2020 ry:. \n+000365d0: 6966 2061 6464 7265 7373 2069 7320 6e6f if address is no\n+000365e0: 7420 4e6f 6e65 3a0a 2020 2020 2020 2020 t None:. \n+000365f0: 2020 2020 2020 2020 6966 2062 7573 2069 if bus i\n+00036600: 7320 6e6f 7420 4e6f 6e65 2061 6e64 2062 s not None and b\n+00036610: 7573 2021 3d20 276e 6f6e 6527 3a0a 2020 us != 'none':. \n+00036620: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00036630: 2020 7261 6973 6520 4368 616e 6e65 6c45 raise ChannelE\n+00036640: 7272 6f72 2827 7072 6f74 6f63 6f6c 2d65 rror('protocol-e\n+00036650: 7272 6f72 272c 206d 6573 7361 6765 3d27 rror', message='\n+00036660: 6f6e 6c79 206f 6e65 206f 6620 2262 7573 only one of \"bus\n+00036670: 2220 616e 6420 2261 6464 7265 7373 2220 \" and \"address\" \n+00036680: 6361 6e20 6265 2073 7065 6369 6669 6564 can be specified\n+00036690: 2729 0a20 2020 2020 2020 2020 2020 2020 '). \n+000366a0: 2020 206c 6f67 6765 722e 6465 6275 6728 logger.debug(\n+000366b0: 2767 6574 2062 7573 2077 6974 6820 6164 'get bus with ad\n+000366c0: 6472 6573 7320 2573 2066 6f72 2025 7327 dress %s for %s'\n+000366d0: 2c20 6164 6472 6573 732c 2073 656c 662e , address, self.\n+000366e0: 6e61 6d65 290a 2020 2020 2020 2020 2020 name). \n+000366f0: 2020 2020 2020 7365 6c66 2e62 7573 203d self.bus =\n+00036700: 2042 7573 2e6e 6577 2861 6464 7265 7373 Bus.new(address\n+00036710: 3d61 6464 7265 7373 2c20 6275 735f 636c =address, bus_cl\n+00036720: 6965 6e74 3d73 656c 662e 6e61 6d65 2069 ient=self.name i\n+00036730: 7320 6e6f 7420 4e6f 6e65 290a 2020 2020 s not None). \n+00036740: 2020 2020 2020 2020 656c 6966 2062 7573 elif bus\n+00036750: 203d 3d20 2769 6e74 6572 6e61 6c27 3a0a == 'internal':.\n 00036760: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00036770: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00036780: 2020 2020 2020 2027 6f72 672e 6672 6565 'org.free\n-00036790: 6465 736b 746f 702e 4442 7573 2e50 726f desktop.DBus.Pro\n-000367a0: 7065 7274 6965 7327 2c0a 2020 2020 2020 perties',. \n-000367b0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000367c0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000367d0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000367e0: 2020 2020 2747 6574 416c 6c27 2c20 2773 'GetAll', 's\n-000367f0: 272c 206e 616d 6529 0a20 2020 2020 2020 ', name). \n-00036800: 2020 2020 2020 2020 206e 6f74 6966 795f notify_\n-00036810: 7570 6461 7465 286e 6f74 6966 792c 2070 update(notify, p\n-00036820: 6174 682c 206e 616d 652c 2070 726f 7073 ath, name, props\n-00036830: 290a 2020 2020 2020 2020 2020 2020 6578 ). ex\n-00036840: 6365 7074 2042 7573 4572 726f 723a 0a20 cept BusError:. \n-00036850: 2020 2020 2020 2020 2020 2020 2020 2070 p\n-00036860: 6173 730a 0a20 2020 2061 7379 6e63 2064 ass.. async d\n-00036870: 6566 2064 6f5f 7761 7463 6828 7365 6c66 ef do_watch(self\n-00036880: 2c20 6d65 7373 6167 6529 3a0a 2020 2020 , message):. \n-00036890: 2020 2020 7761 7463 6820 3d20 6d65 7373 watch = mess\n-000368a0: 6167 655b 2777 6174 6368 275d 0a20 2020 age['watch']. \n-000368b0: 2020 2020 2070 6174 6820 3d20 7761 7463 path = watc\n-000368c0: 682e 6765 7428 2770 6174 6827 290a 2020 h.get('path'). \n-000368d0: 2020 2020 2020 7061 7468 5f6e 616d 6573 path_names\n-000368e0: 7061 6365 203d 2077 6174 6368 2e67 6574 pace = watch.get\n-000368f0: 2827 7061 7468 5f6e 616d 6573 7061 6365 ('path_namespace\n-00036900: 2729 0a20 2020 2020 2020 2069 6e74 6572 '). inter\n-00036910: 6661 6365 5f6e 616d 6520 3d20 7761 7463 face_name = watc\n-00036920: 682e 6765 7428 2769 6e74 6572 6661 6365 h.get('interface\n-00036930: 2729 0a20 2020 2020 2020 2063 6f6f 6b69 '). cooki\n-00036940: 6520 3d20 6d65 7373 6167 652e 6765 7428 e = message.get(\n-00036950: 2769 6427 290a 0a20 2020 2020 2020 2070 'id').. p\n-00036960: 6174 6820 3d20 7061 7468 206f 7220 7061 ath = path or pa\n-00036970: 7468 5f6e 616d 6573 7061 6365 0a20 2020 th_namespace. \n-00036980: 2020 2020 2072 6563 7572 7369 7665 203d recursive =\n-00036990: 2070 6174 6820 3d3d 2070 6174 685f 6e61 path == path_na\n-000369a0: 6d65 7370 6163 650a 0a20 2020 2020 2020 mespace.. \n-000369b0: 2069 6620 7061 7468 2069 7320 4e6f 6e65 if path is None\n-000369c0: 206f 7220 636f 6f6b 6965 2069 7320 4e6f or cookie is No\n-000369d0: 6e65 3a0a 2020 2020 2020 2020 2020 2020 ne:. \n-000369e0: 6c6f 6767 6572 2e64 6562 7567 2827 6967 logger.debug('ig\n-000369f0: 6e6f 7265 6420 696e 636f 6d70 6c65 7465 nored incomplete\n-00036a00: 2077 6174 6368 2072 6571 7565 7374 2025 watch request %\n-00036a10: 7327 2c20 6d65 7373 6167 6529 0a20 2020 s', message). \n-00036a20: 2020 2020 2020 2020 2073 656c 662e 7365 self.se\n-00036a30: 6e64 5f6a 736f 6e28 6572 726f 723d 5b27 nd_json(error=['\n-00036a40: 782e 792e 7a27 2c20 5b27 4e6f 7420 496d x.y.z', ['Not Im\n-00036a50: 706c 656d 656e 7465 6427 5d5d 2c20 6964 plemented']], id\n-00036a60: 3d63 6f6f 6b69 6529 0a20 2020 2020 2020 =cookie). \n-00036a70: 2020 2020 2073 656c 662e 7365 6e64 5f6a self.send_j\n-00036a80: 736f 6e28 7265 706c 793d 5b5d 2c20 6964 son(reply=[], id\n-00036a90: 3d63 6f6f 6b69 6529 0a20 2020 2020 2020 =cookie). \n-00036aa0: 2020 2020 2072 6574 7572 6e0a 0a20 2020 return.. \n-00036ab0: 2020 2020 2074 7279 3a0a 2020 2020 2020 try:. \n-00036ac0: 2020 2020 2020 6173 796e 6320 7769 7468 async with\n-00036ad0: 2073 656c 662e 7761 7463 685f 7072 6f63 self.watch_proc\n-00036ae0: 6573 7369 6e67 5f6c 6f63 6b3a 0a20 2020 essing_lock:. \n-00036af0: 2020 2020 2020 2020 2020 2020 206d 6574 met\n-00036b00: 6120 3d20 7b7d 0a20 2020 2020 2020 2020 a = {}. \n-00036b10: 2020 2020 2020 206e 6f74 6966 7920 3d20 notify = \n-00036b20: 7b7d 0a20 2020 2020 2020 2020 2020 2020 {}. \n-00036b30: 2020 2061 7761 6974 2073 656c 662e 7365 await self.se\n-00036b40: 7475 705f 7061 7468 5f77 6174 6368 2870 tup_path_watch(p\n-00036b50: 6174 682c 2069 6e74 6572 6661 6365 5f6e ath, interface_n\n-00036b60: 616d 652c 2072 6563 7572 7369 7665 2c20 ame, recursive, \n-00036b70: 6d65 7461 2c20 6e6f 7469 6679 290a 2020 meta, notify). \n-00036b80: 2020 2020 2020 2020 2020 2020 2020 6966 if\n-00036b90: 2072 6563 7572 7369 7665 3a0a 2020 2020 recursive:. \n-00036ba0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00036bb0: 6177 6169 7420 7365 6c66 2e73 6574 7570 await self.setup\n-00036bc0: 5f6f 626a 6563 746d 616e 6167 6572 5f77 _objectmanager_w\n-00036bd0: 6174 6368 2870 6174 682c 2069 6e74 6572 atch(path, inter\n-00036be0: 6661 6365 5f6e 616d 652c 206d 6574 612c face_name, meta,\n-00036bf0: 206e 6f74 6966 7929 0a20 2020 2020 2020 notify). \n-00036c00: 2020 2020 2020 2020 2073 656c 662e 7365 self.se\n-00036c10: 6e64 5f6a 736f 6e28 6d65 7461 3d6d 6574 nd_json(meta=met\n-00036c20: 6129 0a20 2020 2020 2020 2020 2020 2020 a). \n-00036c30: 2020 2073 656c 662e 7365 6e64 5f6a 736f self.send_jso\n-00036c40: 6e28 6e6f 7469 6679 3d6e 6f74 6966 7929 n(notify=notify)\n-00036c50: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-00036c60: 2073 656c 662e 7365 6e64 5f6a 736f 6e28 self.send_json(\n-00036c70: 7265 706c 793d 5b5d 2c20 6964 3d6d 6573 reply=[], id=mes\n-00036c80: 7361 6765 5b27 6964 275d 290a 2020 2020 sage['id']). \n-00036c90: 2020 2020 6578 6365 7074 2042 7573 4572 except BusEr\n-00036ca0: 726f 7220 6173 2065 7272 6f72 3a0a 2020 ror as error:. \n-00036cb0: 2020 2020 2020 2020 2020 6c6f 6767 6572 logger\n-00036cc0: 2e64 6562 7567 2822 646f 5f77 6174 6368 .debug(\"do_watch\n-00036cd0: 2825 7329 2063 6175 6768 7420 442d 4275 (%s) caught D-Bu\n-00036ce0: 7320 6572 726f 723a 2025 7322 2c20 6d65 s error: %s\", me\n-00036cf0: 7373 6167 652c 2065 7272 6f72 2e6d 6573 ssage, error.mes\n-00036d00: 7361 6765 290a 2020 2020 2020 2020 2020 sage). \n-00036d10: 2020 7365 6c66 2e73 656e 645f 6a73 6f6e self.send_json\n-00036d20: 2865 7272 6f72 3d5b 6572 726f 722e 6e61 (error=[error.na\n-00036d30: 6d65 2c20 5b65 7272 6f72 2e6d 6573 7361 me, [error.messa\n-00036d40: 6765 5d5d 2c20 6964 3d63 6f6f 6b69 6529 ge]], id=cookie)\n-00036d50: 0a0a 2020 2020 6173 796e 6320 6465 6620 .. async def \n-00036d60: 646f 5f6d 6574 6128 7365 6c66 2c20 6d65 do_meta(self, me\n-00036d70: 7373 6167 6529 3a0a 2020 2020 2020 2020 ssage):. \n-00036d80: 7365 6c66 2e63 6163 6865 2e69 6e6a 6563 self.cache.injec\n-00036d90: 7428 6d65 7373 6167 655b 276d 6574 6127 t(message['meta'\n-00036da0: 5d29 0a0a 2020 2020 6465 6620 646f 5f64 ]).. def do_d\n-00036db0: 6174 6128 7365 6c66 2c20 6461 7461 293a ata(self, data):\n-00036dc0: 0a20 2020 2020 2020 206d 6573 7361 6765 . message\n-00036dd0: 203d 206a 736f 6e2e 6c6f 6164 7328 6461 = json.loads(da\n-00036de0: 7461 290a 2020 2020 2020 2020 6c6f 6767 ta). logg\n-00036df0: 6572 2e64 6562 7567 2827 7265 6365 6976 er.debug('receiv\n-00036e00: 6520 6462 7573 2072 6571 7565 7374 2025 e dbus request %\n-00036e10: 7320 2573 272c 2073 656c 662e 6e61 6d65 s %s', self.name\n-00036e20: 2c20 6d65 7373 6167 6529 0a0a 2020 2020 , message).. \n-00036e30: 2020 2020 6966 2027 6361 6c6c 2720 696e if 'call' in\n-00036e40: 206d 6573 7361 6765 3a0a 2020 2020 2020 message:. \n-00036e50: 2020 2020 2020 7365 6c66 2e63 7265 6174 self.creat\n-00036e60: 655f 7461 736b 2873 656c 662e 646f 5f63 e_task(self.do_c\n-00036e70: 616c 6c28 6d65 7373 6167 6529 290a 2020 all(message)). \n-00036e80: 2020 2020 2020 656c 6966 2027 6164 642d elif 'add-\n-00036e90: 6d61 7463 6827 2069 6e20 6d65 7373 6167 match' in messag\n-00036ea0: 653a 0a20 2020 2020 2020 2020 2020 2073 e:. s\n-00036eb0: 656c 662e 6372 6561 7465 5f74 6173 6b28 elf.create_task(\n-00036ec0: 7365 6c66 2e64 6f5f 6164 645f 6d61 7463 self.do_add_matc\n-00036ed0: 6828 6d65 7373 6167 6529 290a 2020 2020 h(message)). \n-00036ee0: 2020 2020 656c 6966 2027 7761 7463 6827 elif 'watch'\n-00036ef0: 2069 6e20 6d65 7373 6167 653a 0a20 2020 in message:. \n-00036f00: 2020 2020 2020 2020 2073 656c 662e 6372 self.cr\n-00036f10: 6561 7465 5f74 6173 6b28 7365 6c66 2e64 eate_task(self.d\n-00036f20: 6f5f 7761 7463 6828 6d65 7373 6167 6529 o_watch(message)\n-00036f30: 290a 2020 2020 2020 2020 656c 6966 2027 ). elif '\n-00036f40: 6d65 7461 2720 696e 206d 6573 7361 6765 meta' in message\n-00036f50: 3a0a 2020 2020 2020 2020 2020 2020 7365 :. se\n-00036f60: 6c66 2e63 7265 6174 655f 7461 736b 2873 lf.create_task(s\n-00036f70: 656c 662e 646f 5f6d 6574 6128 6d65 7373 elf.do_meta(mess\n-00036f80: 6167 6529 290a 2020 2020 2020 2020 656c age)). el\n-00036f90: 7365 3a0a 2020 2020 2020 2020 2020 2020 se:. \n-00036fa0: 6c6f 6767 6572 2e64 6562 7567 2827 6967 logger.debug('ig\n-00036fb0: 6e6f 7265 6420 6462 7573 2072 6571 7565 nored dbus reque\n-00036fc0: 7374 2025 7327 2c20 6d65 7373 6167 6529 st %s', message)\n-00036fd0: 0a20 2020 2020 2020 2020 2020 2072 6574 . ret\n-00036fe0: 7572 6e0a 0a20 2020 2064 6566 2064 6f5f urn.. def do_\n-00036ff0: 636c 6f73 6528 7365 6c66 293a 0a20 2020 close(self):. \n-00037000: 2020 2020 2066 6f72 2073 6c6f 7420 696e for slot in\n-00037010: 2073 656c 662e 6d61 7463 6865 733a 0a20 self.matches:. \n-00037020: 2020 2020 2020 2020 2020 2073 6c6f 742e slot.\n-00037030: 6361 6e63 656c 2829 0a20 2020 2020 2020 cancel(). \n-00037040: 2073 656c 662e 6d61 7463 6865 7320 3d20 self.matches = \n-00037050: 5b5d 0a20 2020 2020 2020 2073 656c 662e []. self.\n-00037060: 636c 6f73 6528 290a 2727 272e 656e 636f close().'''.enco\n-00037070: 6465 2827 7574 662d 3827 292c 0a20 2027 de('utf-8'),. '\n-00037080: 636f 636b 7069 742f 6368 616e 6e65 6c73 cockpit/channels\n-00037090: 2f66 696c 6573 7973 7465 6d2e 7079 273a /filesystem.py':\n-000370a0: 2072 2727 2723 2054 6869 7320 6669 6c65 r'''# This file\n-000370b0: 2069 7320 7061 7274 206f 6620 436f 636b is part of Cock\n-000370c0: 7069 742e 0a23 0a23 2043 6f70 7972 6967 pit..#.# Copyrig\n-000370d0: 6874 2028 4329 2032 3032 3220 5265 6420 ht (C) 2022 Red \n-000370e0: 4861 742c 2049 6e63 2e0a 230a 2320 5468 Hat, Inc..#.# Th\n-000370f0: 6973 2070 726f 6772 616d 2069 7320 6672 is program is fr\n-00037100: 6565 2073 6f66 7477 6172 653a 2079 6f75 ee software: you\n-00037110: 2063 616e 2072 6564 6973 7472 6962 7574 can redistribut\n-00037120: 6520 6974 2061 6e64 2f6f 7220 6d6f 6469 e it and/or modi\n-00037130: 6679 0a23 2069 7420 756e 6465 7220 7468 fy.# it under th\n-00037140: 6520 7465 726d 7320 6f66 2074 6865 2047 e terms of the G\n-00037150: 4e55 2047 656e 6572 616c 2050 7562 6c69 NU General Publi\n-00037160: 6320 4c69 6365 6e73 6520 6173 2070 7562 c License as pub\n-00037170: 6c69 7368 6564 2062 790a 2320 7468 6520 lished by.# the \n-00037180: 4672 6565 2053 6f66 7477 6172 6520 466f Free Software Fo\n-00037190: 756e 6461 7469 6f6e 2c20 6569 7468 6572 undation, either\n-000371a0: 2076 6572 7369 6f6e 2033 206f 6620 7468 version 3 of th\n-000371b0: 6520 4c69 6365 6e73 652c 206f 720a 2320 e License, or.# \n-000371c0: 2861 7420 796f 7572 206f 7074 696f 6e29 (at your option)\n-000371d0: 2061 6e79 206c 6174 6572 2076 6572 7369 any later versi\n-000371e0: 6f6e 2e0a 230a 2320 5468 6973 2070 726f on..#.# This pro\n-000371f0: 6772 616d 2069 7320 6469 7374 7269 6275 gram is distribu\n-00037200: 7465 6420 696e 2074 6865 2068 6f70 6520 ted in the hope \n-00037210: 7468 6174 2069 7420 7769 6c6c 2062 6520 that it will be \n-00037220: 7573 6566 756c 2c0a 2320 6275 7420 5749 useful,.# but WI\n-00037230: 5448 4f55 5420 414e 5920 5741 5252 414e THOUT ANY WARRAN\n-00037240: 5459 3b20 7769 7468 6f75 7420 6576 656e TY; without even\n-00037250: 2074 6865 2069 6d70 6c69 6564 2077 6172 the implied war\n-00037260: 7261 6e74 7920 6f66 0a23 204d 4552 4348 ranty of.# MERCH\n-00037270: 414e 5441 4249 4c49 5459 206f 7220 4649 ANTABILITY or FI\n-00037280: 544e 4553 5320 464f 5220 4120 5041 5254 TNESS FOR A PART\n-00037290: 4943 554c 4152 2050 5552 504f 5345 2e20 ICULAR PURPOSE. \n-000372a0: 2053 6565 2074 6865 0a23 2047 4e55 2047 See the.# GNU G\n-000372b0: 656e 6572 616c 2050 7562 6c69 6320 4c69 eneral Public Li\n-000372c0: 6365 6e73 6520 666f 7220 6d6f 7265 2064 cense for more d\n-000372d0: 6574 6169 6c73 2e0a 230a 2320 596f 7520 etails..#.# You \n-000372e0: 7368 6f75 6c64 2068 6176 6520 7265 6365 should have rece\n-000372f0: 6976 6564 2061 2063 6f70 7920 6f66 2074 ived a copy of t\n-00037300: 6865 2047 4e55 2047 656e 6572 616c 2050 he GNU General P\n-00037310: 7562 6c69 6320 4c69 6365 6e73 650a 2320 ublic License.# \n-00037320: 616c 6f6e 6720 7769 7468 2074 6869 7320 along with this \n-00037330: 7072 6f67 7261 6d2e 2020 4966 206e 6f74 program. If not\n-00037340: 2c20 7365 6520 3c68 7474 7073 3a2f 2f77 , see <https://w\n-00037350: 7777 2e67 6e75 2e6f 7267 2f6c 6963 656e ww.gnu.org/licen\n-00037360: 7365 732f 3e2e 0a0a 696d 706f 7274 2061 ses/>...import a\n-00037370: 7379 6e63 696f 0a69 6d70 6f72 7420 636f syncio.import co\n-00037380: 6e74 6578 746c 6962 0a69 6d70 6f72 7420 ntextlib.import \n-00037390: 656e 756d 0a69 6d70 6f72 7420 6572 726e enum.import errn\n-000373a0: 6f0a 696d 706f 7274 2066 6e6d 6174 6368 o.import fnmatch\n-000373b0: 0a69 6d70 6f72 7420 6675 6e63 746f 6f6c .import functool\n-000373c0: 730a 696d 706f 7274 2067 7270 0a69 6d70 s.import grp.imp\n-000373d0: 6f72 7420 6c6f 6767 696e 670a 696d 706f ort logging.impo\n-000373e0: 7274 206f 730a 696d 706f 7274 2070 7764 rt os.import pwd\n-000373f0: 0a69 6d70 6f72 7420 7265 0a69 6d70 6f72 .import re.impor\n-00037400: 7420 7374 6174 0a69 6d70 6f72 7420 7465 t stat.import te\n-00037410: 6d70 6669 6c65 0a66 726f 6d20 7061 7468 mpfile.from path\n-00037420: 6c69 6220 696d 706f 7274 2050 6174 680a lib import Path.\n-00037430: 6672 6f6d 2074 7970 696e 6720 696d 706f from typing impo\n-00037440: 7274 2043 616c 6c61 626c 652c 2049 7465 rt Callable, Ite\n-00037450: 7261 626c 650a 0a66 726f 6d20 636f 636b rable..from cock\n-00037460: 7069 742e 5f76 656e 646f 722e 7379 7374 pit._vendor.syst\n-00037470: 656d 645f 6374 7970 6573 2069 6d70 6f72 emd_ctypes impor\n-00037480: 7420 4861 6e64 6c65 2c20 5061 7468 5761 t Handle, PathWa\n-00037490: 7463 680a 6672 6f6d 2063 6f63 6b70 6974 tch.from cockpit\n-000374a0: 2e5f 7665 6e64 6f72 2e73 7973 7465 6d64 ._vendor.systemd\n-000374b0: 5f63 7479 7065 732e 696e 6f74 6966 7920 _ctypes.inotify \n-000374c0: 696d 706f 7274 2045 7665 6e74 2061 7320 import Event as \n-000374d0: 496e 6f74 6966 7945 7665 6e74 0a66 726f InotifyEvent.fro\n-000374e0: 6d20 636f 636b 7069 742e 5f76 656e 646f m cockpit._vendo\n-000374f0: 722e 7379 7374 656d 645f 6374 7970 6573 r.systemd_ctypes\n-00037500: 2e70 6174 6877 6174 6368 2069 6d70 6f72 .pathwatch impor\n-00037510: 7420 4c69 7374 656e 6572 2061 7320 5061 t Listener as Pa\n-00037520: 7468 5761 7463 684c 6973 7465 6e65 720a thWatchListener.\n-00037530: 0a66 726f 6d20 2e2e 6368 616e 6e65 6c20 .from ..channel \n-00037540: 696d 706f 7274 2041 7379 6e63 4368 616e import AsyncChan\n-00037550: 6e65 6c2c 2043 6861 6e6e 656c 2c20 4368 nel, Channel, Ch\n-00037560: 616e 6e65 6c45 7272 6f72 2c20 4765 6e65 annelError, Gene\n-00037570: 7261 746f 7243 6861 6e6e 656c 0a66 726f ratorChannel.fro\n-00037580: 6d20 2e2e 6a73 6f6e 7574 696c 2069 6d70 m ..jsonutil imp\n-00037590: 6f72 7420 280a 2020 2020 4a73 6f6e 4469 ort (. JsonDi\n-000375a0: 6374 2c0a 2020 2020 4a73 6f6e 446f 6375 ct,. JsonDocu\n-000375b0: 6d65 6e74 2c0a 2020 2020 4a73 6f6e 4572 ment,. JsonEr\n-000375c0: 726f 722c 0a20 2020 204a 736f 6e4f 626a ror,. JsonObj\n-000375d0: 6563 742c 0a20 2020 2067 6574 5f62 6f6f ect,. get_boo\n-000375e0: 6c2c 0a20 2020 2067 6574 5f65 6e75 6d2c l,. get_enum,\n-000375f0: 0a20 2020 2067 6574 5f69 6e74 2c0a 2020 . get_int,. \n-00037600: 2020 6765 745f 7374 722c 0a20 2020 2067 get_str,. g\n-00037610: 6574 5f73 7472 762c 0a20 2020 206a 736f et_strv,. jso\n-00037620: 6e5f 6d65 7267 655f 616e 645f 6669 6c74 n_merge_and_filt\n-00037630: 6572 5f70 6174 6368 2c0a 290a 0a6c 6f67 er_patch,.)..log\n-00037640: 6765 7220 3d20 6c6f 6767 696e 672e 6765 ger = logging.ge\n-00037650: 744c 6f67 6765 7228 5f5f 6e61 6d65 5f5f tLogger(__name__\n-00037660: 290a 0a0a 4066 756e 6374 6f6f 6c73 2e6c )...@functools.l\n-00037670: 7275 5f63 6163 6865 2829 0a64 6566 206d ru_cache().def m\n-00037680: 795f 756d 6173 6b28 2920 2d3e 2069 6e74 y_umask() -> int\n-00037690: 3a0a 2020 2020 6d61 7463 6820 3d20 7265 :. match = re\n-000376a0: 2e73 6561 7263 6828 7227 5e55 6d61 736b .search(r'^Umask\n-000376b0: 3a5c 732a 3028 5b30 2d37 5d2a 2924 272c :\\s*0([0-7]*)$',\n-000376c0: 2050 6174 6828 272f 7072 6f63 2f73 656c Path('/proc/sel\n-000376d0: 662f 7374 6174 7573 2729 2e72 6561 645f f/status').read_\n-000376e0: 7465 7874 2829 2c20 7265 2e4d 290a 2020 text(), re.M). \n-000376f0: 2020 7265 7475 726e 2028 6d61 7463 6820 return (match \n-00037700: 616e 6420 696e 7428 6d61 7463 682e 6772 and int(match.gr\n-00037710: 6f75 7028 3129 2c20 3829 2920 6f72 2030 oup(1), 8)) or 0\n-00037720: 6f30 3737 0a0a 0a64 6566 2074 6167 5f66 o077...def tag_f\n-00037730: 726f 6d5f 7374 6174 2862 7566 293a 0a20 rom_stat(buf):. \n-00037740: 2020 2072 6574 7572 6e20 6627 313a 7b62 return f'1:{b\n-00037750: 7566 2e73 745f 696e 6f7d 2d7b 6275 662e uf.st_ino}-{buf.\n-00037760: 7374 5f6d 7469 6d65 7d2d 7b62 7566 2e73 st_mtime}-{buf.s\n-00037770: 745f 6d6f 6465 3a6f 7d2d 7b62 7566 2e73 t_mode:o}-{buf.s\n-00037780: 745f 7569 647d 2d7b 6275 662e 7374 5f67 t_uid}-{buf.st_g\n-00037790: 6964 7d27 0a0a 0a64 6566 2074 6167 5f66 id}'...def tag_f\n-000377a0: 726f 6d5f 7061 7468 2870 6174 6829 3a0a rom_path(path):.\n-000377b0: 2020 2020 7472 793a 0a20 2020 2020 2020 try:. \n-000377c0: 2072 6574 7572 6e20 7461 675f 6672 6f6d return tag_from\n-000377d0: 5f73 7461 7428 6f73 2e73 7461 7428 7061 _stat(os.stat(pa\n-000377e0: 7468 2929 0a20 2020 2065 7863 6570 7420 th)). except \n-000377f0: 4669 6c65 4e6f 7446 6f75 6e64 4572 726f FileNotFoundErro\n-00037800: 723a 0a20 2020 2020 2020 2072 6574 7572 r:. retur\n-00037810: 6e20 272d 270a 2020 2020 6578 6365 7074 n '-'. except\n-00037820: 204f 5345 7272 6f72 3a0a 2020 2020 2020 OSError:. \n-00037830: 2020 7265 7475 726e 204e 6f6e 650a 0a0a return None...\n-00037840: 6465 6620 7461 675f 6672 6f6d 5f66 6428 def tag_from_fd(\n-00037850: 6664 293a 0a20 2020 2074 7279 3a0a 2020 fd):. try:. \n-00037860: 2020 2020 2020 7265 7475 726e 2074 6167 return tag\n-00037870: 5f66 726f 6d5f 7374 6174 286f 732e 6673 _from_stat(os.fs\n-00037880: 7461 7428 6664 2929 0a20 2020 2065 7863 tat(fd)). exc\n-00037890: 6570 7420 4f53 4572 726f 723a 0a20 2020 ept OSError:. \n-000378a0: 2020 2020 2072 6574 7572 6e20 4e6f 6e65 return None\n-000378b0: 0a0a 0a63 6c61 7373 2046 734c 6973 7443 ...class FsListC\n-000378c0: 6861 6e6e 656c 2843 6861 6e6e 656c 293a hannel(Channel):\n-000378d0: 0a20 2020 2070 6179 6c6f 6164 203d 2027 . payload = '\n-000378e0: 6673 6c69 7374 3127 0a0a 2020 2020 6465 fslist1'.. de\n-000378f0: 6620 7365 6e64 5f65 6e74 7279 2873 656c f send_entry(sel\n-00037900: 662c 2065 7665 6e74 2c20 656e 7472 7929 f, event, entry)\n-00037910: 3a0a 2020 2020 2020 2020 6966 2065 6e74 :. if ent\n-00037920: 7279 2e69 735f 7379 6d6c 696e 6b28 293a ry.is_symlink():\n-00037930: 0a20 2020 2020 2020 2020 2020 206d 6f64 . mod\n-00037940: 6520 3d20 276c 696e 6b27 0a20 2020 2020 e = 'link'. \n-00037950: 2020 2065 6c69 6620 656e 7472 792e 6973 elif entry.is\n-00037960: 5f66 696c 6528 293a 0a20 2020 2020 2020 _file():. \n-00037970: 2020 2020 206d 6f64 6520 3d20 2766 696c mode = 'fil\n-00037980: 6527 0a20 2020 2020 2020 2065 6c69 6620 e'. elif \n-00037990: 656e 7472 792e 6973 5f64 6972 2829 3a0a entry.is_dir():.\n-000379a0: 2020 2020 2020 2020 2020 2020 6d6f 6465 mode\n-000379b0: 203d 2027 6469 7265 6374 6f72 7927 0a20 = 'directory'. \n-000379c0: 2020 2020 2020 2065 6c73 653a 0a20 2020 else:. \n-000379d0: 2020 2020 2020 2020 206d 6f64 6520 3d20 mode = \n-000379e0: 2773 7065 6369 616c 270a 0a20 2020 2020 'special'.. \n-000379f0: 2020 2073 656c 662e 7365 6e64 5f6a 736f self.send_jso\n-00037a00: 6e28 6576 656e 743d 6576 656e 742c 2070 n(event=event, p\n-00037a10: 6174 683d 656e 7472 792e 6e61 6d65 2c20 ath=entry.name, \n-00037a20: 7479 7065 3d6d 6f64 6529 0a0a 2020 2020 type=mode).. \n-00037a30: 6465 6620 646f 5f6f 7065 6e28 7365 6c66 def do_open(self\n-00037a40: 2c20 6f70 7469 6f6e 7329 3a0a 2020 2020 , options):. \n-00037a50: 2020 2020 7061 7468 203d 206f 7074 696f path = optio\n-00037a60: 6e73 2e67 6574 2827 7061 7468 2729 0a20 ns.get('path'). \n-00037a70: 2020 2020 2020 2077 6174 6368 203d 206f watch = o\n-00037a80: 7074 696f 6e73 2e67 6574 2827 7761 7463 ptions.get('watc\n-00037a90: 6827 2c20 5472 7565 290a 0a20 2020 2020 h', True).. \n-00037aa0: 2020 2069 6620 7761 7463 683a 0a20 2020 if watch:. \n-00037ab0: 2020 2020 2020 2020 2072 6169 7365 2043 raise C\n-00037ac0: 6861 6e6e 656c 4572 726f 7228 276e 6f74 hannelError('not\n-00037ad0: 2d73 7570 706f 7274 6564 272c 206d 6573 -supported', mes\n-00037ae0: 7361 6765 3d27 7761 7463 6869 6e67 2069 sage='watching i\n-00037af0: 7320 6e6f 7420 696d 706c 656d 656e 7465 s not implemente\n-00037b00: 642c 2075 7365 2066 7377 6174 6368 3127 d, use fswatch1'\n-00037b10: 290a 0a20 2020 2020 2020 2074 7279 3a0a ).. try:.\n-00037b20: 2020 2020 2020 2020 2020 2020 7363 616e scan\n-00037b30: 5f64 6972 203d 206f 732e 7363 616e 6469 _dir = os.scandi\n-00037b40: 7228 7061 7468 290a 2020 2020 2020 2020 r(path). \n-00037b50: 6578 6365 7074 2046 696c 654e 6f74 466f except FileNotFo\n-00037b60: 756e 6445 7272 6f72 2061 7320 6572 726f undError as erro\n-00037b70: 723a 0a20 2020 2020 2020 2020 2020 2072 r:. r\n-00037b80: 6169 7365 2043 6861 6e6e 656c 4572 726f aise ChannelErro\n-00037b90: 7228 276e 6f74 2d66 6f75 6e64 272c 206d r('not-found', m\n-00037ba0: 6573 7361 6765 3d73 7472 2865 7272 6f72 essage=str(error\n-00037bb0: 2929 2066 726f 6d20 6572 726f 720a 2020 )) from error. \n-00037bc0: 2020 2020 2020 6578 6365 7074 2050 6572 except Per\n-00037bd0: 6d69 7373 696f 6e45 7272 6f72 2061 7320 missionError as \n-00037be0: 6572 726f 723a 0a20 2020 2020 2020 2020 error:. \n-00037bf0: 2020 2072 6169 7365 2043 6861 6e6e 656c raise Channel\n-00037c00: 4572 726f 7228 2761 6363 6573 732d 6465 Error('access-de\n-00037c10: 6e69 6564 272c 206d 6573 7361 6765 3d73 nied', message=s\n-00037c20: 7472 2865 7272 6f72 2929 2066 726f 6d20 tr(error)) from \n-00037c30: 6572 726f 720a 2020 2020 2020 2020 6578 error. ex\n-00037c40: 6365 7074 204f 5345 7272 6f72 2061 7320 cept OSError as \n-00037c50: 6572 726f 723a 0a20 2020 2020 2020 2020 error:. \n-00037c60: 2020 2072 6169 7365 2043 6861 6e6e 656c raise Channel\n-00037c70: 4572 726f 7228 2769 6e74 6572 6e61 6c2d Error('internal-\n-00037c80: 6572 726f 7227 2c20 6d65 7373 6167 653d error', message=\n-00037c90: 7374 7228 6572 726f 7229 2920 6672 6f6d str(error)) from\n-00037ca0: 2065 7272 6f72 0a0a 2020 2020 2020 2020 error.. \n-00037cb0: 7365 6c66 2e72 6561 6479 2829 0a20 2020 self.ready(). \n-00037cc0: 2020 2020 2066 6f72 2065 6e74 7279 2069 for entry i\n-00037cd0: 6e20 7363 616e 5f64 6972 3a0a 2020 2020 n scan_dir:. \n-00037ce0: 2020 2020 2020 2020 7365 6c66 2e73 656e self.sen\n-00037cf0: 645f 656e 7472 7928 2270 7265 7365 6e74 d_entry(\"present\n-00037d00: 222c 2065 6e74 7279 290a 0a20 2020 2020 \", entry).. \n-00037d10: 2020 2069 6620 6e6f 7420 7761 7463 683a if not watch:\n-00037d20: 0a20 2020 2020 2020 2020 2020 2073 656c . sel\n-00037d30: 662e 646f 6e65 2829 0a20 2020 2020 2020 f.done(). \n-00037d40: 2020 2020 2073 656c 662e 636c 6f73 6528 self.close(\n-00037d50: 290a 0a0a 636c 6173 7320 4673 5265 6164 )...class FsRead\n-00037d60: 4368 616e 6e65 6c28 4765 6e65 7261 746f Channel(Generato\n-00037d70: 7243 6861 6e6e 656c 293a 0a20 2020 2070 rChannel):. p\n-00037d80: 6179 6c6f 6164 203d 2027 6673 7265 6164 ayload = 'fsread\n-00037d90: 3127 0a0a 2020 2020 6465 6620 646f 5f79 1'.. def do_y\n-00037da0: 6965 6c64 5f64 6174 6128 7365 6c66 2c20 ield_data(self, \n-00037db0: 6f70 7469 6f6e 733a 204a 736f 6e4f 626a options: JsonObj\n-00037dc0: 6563 7429 202d 3e20 4765 6e65 7261 746f ect) -> Generato\n-00037dd0: 7243 6861 6e6e 656c 2e44 6174 6147 656e rChannel.DataGen\n-00037de0: 6572 6174 6f72 3a0a 2020 2020 2020 2020 erator:. \n-00037df0: 7061 7468 203d 2067 6574 5f73 7472 286f path = get_str(o\n-00037e00: 7074 696f 6e73 2c20 2770 6174 6827 290a ptions, 'path').\n-00037e10: 2020 2020 2020 2020 6269 6e61 7279 203d binary =\n-00037e20: 2067 6574 5f65 6e75 6d28 6f70 7469 6f6e get_enum(option\n-00037e30: 732c 2027 6269 6e61 7279 272c 205b 2772 s, 'binary', ['r\n-00037e40: 6177 275d 2c20 4e6f 6e65 2920 6973 206e aw'], None) is n\n-00037e50: 6f74 204e 6f6e 650a 2020 2020 2020 2020 ot None. \n-00037e60: 6d61 785f 7265 6164 5f73 697a 6520 3d20 max_read_size = \n-00037e70: 6765 745f 696e 7428 6f70 7469 6f6e 732c get_int(options,\n-00037e80: 2027 6d61 785f 7265 6164 5f73 697a 6527 'max_read_size'\n-00037e90: 2c20 4e6f 6e65 290a 0a20 2020 2020 2020 , None).. \n-00037ea0: 206c 6f67 6765 722e 6465 6275 6728 274f logger.debug('O\n-00037eb0: 7065 6e69 6e67 2066 696c 6520 2225 7322 pening file \"%s\"\n-00037ec0: 2066 6f72 2072 6561 6469 6e67 272c 2070 for reading', p\n-00037ed0: 6174 6829 0a0a 2020 2020 2020 2020 7472 ath).. tr\n-00037ee0: 793a 0a20 2020 2020 2020 2020 2020 2077 y:. w\n-00037ef0: 6974 6820 6f70 656e 2870 6174 682c 2027 ith open(path, '\n-00037f00: 7262 2729 2061 7320 6669 6c65 703a 0a20 rb') as filep:. \n-00037f10: 2020 2020 2020 2020 2020 2020 2020 2062 b\n-00037f20: 7566 203d 206f 732e 7374 6174 2866 696c uf = os.stat(fil\n-00037f30: 6570 2e66 696c 656e 6f28 2929 0a20 2020 ep.fileno()). \n-00037f40: 2020 2020 2020 2020 2020 2020 2069 6620 if \n-00037f50: 6d61 785f 7265 6164 5f73 697a 6520 6973 max_read_size is\n-00037f60: 206e 6f74 204e 6f6e 6520 616e 6420 6275 not None and bu\n-00037f70: 662e 7374 5f73 697a 6520 3e20 6d61 785f f.st_size > max_\n-00037f80: 7265 6164 5f73 697a 653a 0a20 2020 2020 read_size:. \n-00037f90: 2020 2020 2020 2020 2020 2020 2020 2072 r\n-00037fa0: 6169 7365 2043 6861 6e6e 656c 4572 726f aise ChannelErro\n-00037fb0: 7228 2774 6f6f 2d6c 6172 6765 2729 0a0a r('too-large')..\n-00037fc0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00037fd0: 6966 2062 696e 6172 7920 616e 6420 7374 if binary and st\n-00037fe0: 6174 2e53 5f49 5352 4547 2862 7566 2e73 at.S_ISREG(buf.s\n-00037ff0: 745f 6d6f 6465 293a 0a20 2020 2020 2020 t_mode):. \n-00038000: 2020 2020 2020 2020 2020 2020 2073 656c sel\n-00038010: 662e 7265 6164 7928 7369 7a65 5f68 696e f.ready(size_hin\n-00038020: 743d 6275 662e 7374 5f73 697a 6529 0a20 t=buf.st_size). \n-00038030: 2020 2020 2020 2020 2020 2020 2020 2065 e\n-00038040: 6c73 653a 0a20 2020 2020 2020 2020 2020 lse:. \n-00038050: 2020 2020 2020 2020 2073 656c 662e 7265 self.re\n-00038060: 6164 7928 290a 0a20 2020 2020 2020 2020 ady().. \n-00038070: 2020 2020 2020 2077 6869 6c65 2054 7275 while Tru\n-00038080: 653a 0a20 2020 2020 2020 2020 2020 2020 e:. \n-00038090: 2020 2020 2020 2064 6174 6120 3d20 6669 data = fi\n-000380a0: 6c65 702e 7265 6164 3128 4368 616e 6e65 lep.read1(Channe\n-000380b0: 6c2e 424c 4f43 4b5f 5349 5a45 290a 2020 l.BLOCK_SIZE). \n-000380c0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000380d0: 2020 6966 2064 6174 6120 3d3d 2062 2727 if data == b''\n-000380e0: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n-000380f0: 2020 2020 2020 2020 2020 6272 6561 6b0a break.\n-00038100: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00038110: 2020 2020 6c6f 6767 6572 2e64 6562 7567 logger.debug\n-00038120: 2827 2020 2e2e 2e73 656e 6469 6e67 2025 (' ...sending %\n-00038130: 6420 6279 7465 7327 2c20 6c65 6e28 6461 d bytes', len(da\n-00038140: 7461 2929 0a20 2020 2020 2020 2020 2020 ta)). \n-00038150: 2020 2020 2020 2020 2069 6620 6e6f 7420 if not \n-00038160: 6269 6e61 7279 3a0a 2020 2020 2020 2020 binary:. \n-00038170: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00038180: 6461 7461 203d 2064 6174 612e 7265 706c data = data.repl\n-00038190: 6163 6528 6227 5c30 272c 2062 2727 292e ace(b'\\0', b'').\n-000381a0: 6465 636f 6465 2827 7574 662d 3827 2c20 decode('utf-8', \n-000381b0: 6572 726f 7273 3d27 6967 6e6f 7265 2729 errors='ignore')\n-000381c0: 2e65 6e63 6f64 6528 2775 7466 2d38 2729 .encode('utf-8')\n-000381d0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-000381e0: 2020 2020 2079 6965 6c64 2064 6174 610a yield data.\n-000381f0: 0a20 2020 2020 2020 2020 2020 2072 6574 . ret\n-00038200: 7572 6e20 7b27 7461 6727 3a20 7461 675f urn {'tag': tag_\n-00038210: 6672 6f6d 5f73 7461 7428 6275 6629 7d0a from_stat(buf)}.\n-00038220: 0a20 2020 2020 2020 2065 7863 6570 7420 . except \n-00038230: 4669 6c65 4e6f 7446 6f75 6e64 4572 726f FileNotFoundErro\n-00038240: 723a 0a20 2020 2020 2020 2020 2020 2072 r:. r\n-00038250: 6574 7572 6e20 7b27 7461 6727 3a20 272d eturn {'tag': '-\n-00038260: 277d 0a20 2020 2020 2020 2065 7863 6570 '}. excep\n-00038270: 7420 5065 726d 6973 7369 6f6e 4572 726f t PermissionErro\n-00038280: 7220 6173 2065 7863 3a0a 2020 2020 2020 r as exc:. \n-00038290: 2020 2020 2020 7261 6973 6520 4368 616e raise Chan\n-000382a0: 6e65 6c45 7272 6f72 2827 6163 6365 7373 nelError('access\n-000382b0: 2d64 656e 6965 6427 2920 6672 6f6d 2065 -denied') from e\n-000382c0: 7863 0a20 2020 2020 2020 2065 7863 6570 xc. excep\n-000382d0: 7420 4f53 4572 726f 7220 6173 2065 7863 t OSError as exc\n-000382e0: 3a0a 2020 2020 2020 2020 2020 2020 7261 :. ra\n-000382f0: 6973 6520 4368 616e 6e65 6c45 7272 6f72 ise ChannelError\n-00038300: 2827 696e 7465 726e 616c 2d65 7272 6f72 ('internal-error\n-00038310: 272c 206d 6573 7361 6765 3d73 7472 2865 ', message=str(e\n-00038320: 7863 2929 2066 726f 6d20 6578 630a 0a0a xc)) from exc...\n-00038330: 636c 6173 7320 4673 5265 706c 6163 6543 class FsReplaceC\n-00038340: 6861 6e6e 656c 2841 7379 6e63 4368 616e hannel(AsyncChan\n-00038350: 6e65 6c29 3a0a 2020 2020 7061 796c 6f61 nel):. payloa\n-00038360: 6420 3d20 2766 7372 6570 6c61 6365 3127 d = 'fsreplace1'\n-00038370: 0a0a 2020 2020 6173 796e 6320 6465 6620 .. async def \n-00038380: 7275 6e28 7365 6c66 2c20 6f70 7469 6f6e run(self, option\n-00038390: 733a 204a 736f 6e4f 626a 6563 7429 202d s: JsonObject) -\n-000383a0: 3e20 4a73 6f6e 4f62 6a65 6374 3a0a 2020 > JsonObject:. \n-000383b0: 2020 2020 2020 7061 7468 203d 2067 6574 path = get\n-000383c0: 5f73 7472 286f 7074 696f 6e73 2c20 2770 _str(options, 'p\n-000383d0: 6174 6827 290a 2020 2020 2020 2020 7461 ath'). ta\n-000383e0: 6720 3d20 6765 745f 7374 7228 6f70 7469 g = get_str(opti\n-000383f0: 6f6e 732c 2027 7461 6727 2c20 4e6f 6e65 ons, 'tag', None\n-00038400: 290a 2020 2020 2020 2020 6469 726e 616d ). dirnam\n-00038410: 652c 2062 6173 656e 616d 6520 3d20 6f73 e, basename = os\n-00038420: 2e70 6174 682e 7370 6c69 7428 6765 745f .path.split(get_\n-00038430: 7374 7228 6f70 7469 6f6e 732c 2027 7061 str(options, 'pa\n-00038440: 7468 2729 290a 0a20 2020 2020 2020 2073 th')).. s\n-00038450: 656c 662e 7265 6164 7928 290a 0a20 2020 elf.ready().. \n-00038460: 2020 2020 2074 7279 3a0a 2020 2020 2020 try:. \n-00038470: 2020 2020 2020 6465 6c65 7465 5f6f 6e5f delete_on_\n-00038480: 6578 6974 203d 204e 6f6e 650a 2020 2020 exit = None. \n-00038490: 2020 2020 2020 2020 6461 7461 203d 2061 data = a\n-000384a0: 7761 6974 2073 656c 662e 7265 6164 2829 wait self.read()\n-000384b0: 0a20 2020 2020 2020 2020 2020 2069 6620 . if \n-000384c0: 6461 7461 2069 7320 4e6f 6e65 3a0a 2020 data is None:. \n-000384d0: 2020 2020 2020 2020 2020 2020 2020 2320 # \n-000384e0: 6966 2077 6520 6765 7420 454f 4620 7269 if we get EOF ri\n-000384f0: 6768 7420 6177 6179 2c20 7468 6174 2773 ght away, that's\n-00038500: 2061 2072 6571 7565 7374 2074 6f20 6465 a request to de\n-00038510: 6c65 7465 0a20 2020 2020 2020 2020 2020 lete. \n-00038520: 2020 2020 2069 6620 7461 6720 6973 206e if tag is n\n-00038530: 6f74 204e 6f6e 6520 616e 6420 7461 6720 ot None and tag \n-00038540: 213d 2074 6167 5f66 726f 6d5f 7061 7468 != tag_from_path\n-00038550: 2870 6174 6829 3a0a 2020 2020 2020 2020 (path):. \n-00038560: 2020 2020 2020 2020 2020 2020 7261 6973 rais\n-00038570: 6520 4368 616e 6e65 6c45 7272 6f72 2827 e ChannelError('\n-00038580: 6368 616e 6765 2d63 6f6e 666c 6963 7427 change-conflict'\n-00038590: 290a 2020 2020 2020 2020 2020 2020 2020 ). \n-000385a0: 2020 7769 7468 2063 6f6e 7465 7874 6c69 with contextli\n-000385b0: 622e 7375 7070 7265 7373 2846 696c 654e b.suppress(FileN\n-000385c0: 6f74 466f 756e 6445 7272 6f72 293a 2020 otFoundError): \n-000385d0: 2320 6465 6c65 7465 2069 7320 6964 656d # delete is idem\n-000385e0: 706f 7465 6e74 0a20 2020 2020 2020 2020 potent. \n-000385f0: 2020 2020 2020 2020 2020 206f 732e 756e os.un\n-00038600: 6c69 6e6b 2870 6174 6829 0a20 2020 2020 link(path). \n-00038610: 2020 2020 2020 2065 6c73 653a 0a20 2020 else:. \n-00038620: 2020 2020 2020 2020 2020 2020 2023 206f # o\n-00038630: 7468 6572 7769 7365 2c20 7370 6f6f 6c20 therwise, spool \n-00038640: 6461 7461 2069 6e74 6f20 6120 7465 6d70 data into a temp\n-00038650: 6f72 6172 7920 6669 6c65 2075 6e74 696c orary file until\n-00038660: 2045 4f46 2074 6865 6e20 7265 6e61 6d65 EOF then rename\n-00038670: 2069 6e74 6f20 706c 6163 652e 2e2e 0a20 into place.... \n-00038680: 2020 2020 2020 2020 2020 2020 2020 2077 w\n-00038690: 6974 6820 7465 6d70 6669 6c65 2e4e 616d ith tempfile.Nam\n-000386a0: 6564 5465 6d70 6f72 6172 7946 696c 6528 edTemporaryFile(\n-000386b0: 6469 723d 6469 726e 616d 652c 2070 7265 dir=dirname, pre\n-000386c0: 6669 783d 6627 2e7b 6261 7365 6e61 6d65 fix=f'.{basename\n-000386d0: 7d2d 272c 2064 656c 6574 653d 4661 6c73 }-', delete=Fals\n-000386e0: 6529 2061 7320 746d 703a 0a20 2020 2020 e) as tmp:. \n-000386f0: 2020 2020 2020 2020 2020 2020 2020 2064 d\n-00038700: 656c 6574 655f 6f6e 5f65 7869 7420 3d20 elete_on_exit = \n-00038710: 746d 702e 6e61 6d65 0a20 2020 2020 2020 tmp.name. \n-00038720: 2020 2020 2020 2020 2020 2020 206c 6f6f loo\n-00038730: 7020 3d20 6173 796e 6369 6f2e 6765 745f p = asyncio.get_\n-00038740: 7275 6e6e 696e 675f 6c6f 6f70 2829 0a20 running_loop(). \n-00038750: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00038760: 2020 2077 6869 6c65 2064 6174 6120 6973 while data is\n-00038770: 206e 6f74 204e 6f6e 653a 0a20 2020 2020 not None:. \n-00038780: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00038790: 2020 2061 7761 6974 206c 6f6f 702e 7275 await loop.ru\n-000387a0: 6e5f 696e 5f65 7865 6375 746f 7228 4e6f n_in_executor(No\n-000387b0: 6e65 2c20 746d 702e 7772 6974 652c 2064 ne, tmp.write, d\n-000387c0: 6174 6129 0a20 2020 2020 2020 2020 2020 ata). \n-000387d0: 2020 2020 2020 2020 2020 2020 2064 6174 dat\n-000387e0: 6120 3d20 6177 6169 7420 7365 6c66 2e72 a = await self.r\n-000387f0: 6561 6428 290a 0a20 2020 2020 2020 2020 ead().. \n-00038800: 2020 2020 2020 2020 2020 2061 7761 6974 await\n-00038810: 206c 6f6f 702e 7275 6e5f 696e 5f65 7865 loop.run_in_exe\n-00038820: 6375 746f 7228 4e6f 6e65 2c20 6f73 2e66 cutor(None, os.f\n-00038830: 6461 7461 7379 6e63 2c20 746d 702e 6669 datasync, tmp.fi\n-00038840: 6c65 6e6f 2829 290a 0a20 2020 2020 2020 leno()).. \n-00038850: 2020 2020 2020 2020 2020 2020 2069 6620 if \n-00038860: 7461 6720 6973 204e 6f6e 653a 0a20 2020 tag is None:. \n-00038870: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00038880: 2020 2020 2023 206e 6f20 7072 6563 6f6e # no precon\n-00038890: 6469 7469 6f6e 7320 6162 6f75 7420 7768 ditions about wh\n-000388a0: 6174 2063 7572 7265 6e74 6c79 2065 7869 at currently exi\n-000388b0: 7374 7320 6f72 206e 6f74 0a20 2020 2020 sts or not. \n-000388c0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000388d0: 2020 2023 2063 616c 6375 6c61 7465 2074 # calculate t\n-000388e0: 6865 2066 696c 6520 6d6f 6465 2066 726f he file mode fro\n-000388f0: 6d20 7468 6520 756d 6173 6b0a 2020 2020 m the umask. \n-00038900: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00038910: 2020 2020 6f73 2e66 6368 6d6f 6428 746d os.fchmod(tm\n-00038920: 702e 6669 6c65 6e6f 2829 2c20 306f 3636 p.fileno(), 0o66\n-00038930: 3620 2620 7e6d 795f 756d 6173 6b28 2929 6 & ~my_umask())\n-00038940: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-00038950: 2020 2020 2020 2020 206f 732e 7265 6e61 os.rena\n-00038960: 6d65 2874 6d70 2e6e 616d 652c 2070 6174 me(tmp.name, pat\n-00038970: 6829 0a20 2020 2020 2020 2020 2020 2020 h). \n-00038980: 2020 2020 2020 2020 2020 2064 656c 6574 delet\n-00038990: 655f 6f6e 5f65 7869 7420 3d20 4e6f 6e65 e_on_exit = None\n-000389a0: 0a0a 2020 2020 2020 2020 2020 2020 2020 .. \n-000389b0: 2020 2020 2020 656c 6966 2074 6167 203d elif tag =\n-000389c0: 3d20 272d 273a 0a20 2020 2020 2020 2020 = '-':. \n-000389d0: 2020 2020 2020 2020 2020 2020 2020 2023 #\n-000389e0: 2074 6865 2066 696c 6520 6d75 7374 206e the file must n\n-000389f0: 6f74 2065 7869 7374 2e20 2066 696c 6520 ot exist. file \n-00038a00: 6d6f 6465 2066 726f 6d20 756d 6173 6b2e mode from umask.\n-00038a10: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-00038a20: 2020 2020 2020 2020 206f 732e 6663 686d os.fchm\n-00038a30: 6f64 2874 6d70 2e66 696c 656e 6f28 292c od(tmp.fileno(),\n-00038a40: 2030 6f36 3636 2026 207e 6d79 5f75 6d61 0o666 & ~my_uma\n-00038a50: 736b 2829 290a 2020 2020 2020 2020 2020 sk()). \n-00038a60: 2020 2020 2020 2020 2020 2020 2020 6f73 os\n-00038a70: 2e6c 696e 6b28 746d 702e 6e61 6d65 2c20 .link(tmp.name, \n-00038a80: 7061 7468 2920 2023 2077 696c 6c20 6661 path) # will fa\n-00038a90: 696c 2069 6620 6669 6c65 2065 7869 7374 il if file exist\n-00038aa0: 730a 0a20 2020 2020 2020 2020 2020 2020 s.. \n-00038ab0: 2020 2020 2020 2065 6c73 653a 0a20 2020 else:. \n-00038ac0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00038ad0: 2020 2020 2023 2074 6865 2066 696c 6520 # the file \n-00038ae0: 6d75 7374 2065 7869 7374 2077 6974 6820 must exist with \n-00038af0: 7468 6520 6769 7665 6e20 7461 670a 2020 the given tag. \n-00038b00: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00038b10: 2020 2020 2020 6275 6620 3d20 6f73 2e73 buf = os.s\n-00038b20: 7461 7428 7061 7468 290a 2020 2020 2020 tat(path). \n-00038b30: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00038b40: 2020 6966 2074 6167 2021 3d20 7461 675f if tag != tag_\n-00038b50: 6672 6f6d 5f73 7461 7428 6275 6629 3a0a from_stat(buf):.\n+00036770: 6c6f 6767 6572 2e64 6562 7567 2827 6765 logger.debug('ge\n+00036780: 7420 696e 7465 726e 616c 2062 7573 2066 t internal bus f\n+00036790: 6f72 2025 7327 2c20 7365 6c66 2e6e 616d or %s', self.nam\n+000367a0: 6529 0a20 2020 2020 2020 2020 2020 2020 e). \n+000367b0: 2020 2073 656c 662e 6275 7320 3d20 7365 self.bus = se\n+000367c0: 6c66 2e72 6f75 7465 722e 696e 7465 726e lf.router.intern\n+000367d0: 616c 5f62 7573 2e63 6c69 656e 740a 2020 al_bus.client. \n+000367e0: 2020 2020 2020 2020 2020 656c 7365 3a0a else:.\n+000367f0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00036800: 6966 2062 7573 203d 3d20 2773 6573 7369 if bus == 'sessi\n+00036810: 6f6e 273a 0a20 2020 2020 2020 2020 2020 on':. \n+00036820: 2020 2020 2020 2020 206c 6f67 6765 722e logger.\n+00036830: 6465 6275 6728 2767 6574 2073 6573 7369 debug('get sessi\n+00036840: 6f6e 2062 7573 2066 6f72 2025 7327 2c20 on bus for %s', \n+00036850: 7365 6c66 2e6e 616d 6529 0a20 2020 2020 self.name). \n+00036860: 2020 2020 2020 2020 2020 2020 2020 2073 s\n+00036870: 656c 662e 6275 7320 3d20 4275 732e 6465 elf.bus = Bus.de\n+00036880: 6661 756c 745f 7573 6572 2829 0a20 2020 fault_user(). \n+00036890: 2020 2020 2020 2020 2020 2020 2065 6c69 eli\n+000368a0: 6620 6275 7320 3d3d 2027 7379 7374 656d f bus == 'system\n+000368b0: 2720 6f72 2062 7573 2069 7320 4e6f 6e65 ' or bus is None\n+000368c0: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n+000368d0: 2020 2020 2020 6c6f 6767 6572 2e64 6562 logger.deb\n+000368e0: 7567 2827 6765 7420 7379 7374 656d 2062 ug('get system b\n+000368f0: 7573 2066 6f72 2025 7327 2c20 7365 6c66 us for %s', self\n+00036900: 2e6e 616d 6529 0a20 2020 2020 2020 2020 .name). \n+00036910: 2020 2020 2020 2020 2020 2073 656c 662e self.\n+00036920: 6275 7320 3d20 4275 732e 6465 6661 756c bus = Bus.defaul\n+00036930: 745f 7379 7374 656d 2829 0a20 2020 2020 t_system(). \n+00036940: 2020 2020 2020 2020 2020 2065 6c73 653a else:\n+00036950: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+00036960: 2020 2020 2072 6169 7365 2043 6861 6e6e raise Chann\n+00036970: 656c 4572 726f 7228 2770 726f 746f 636f elError('protoco\n+00036980: 6c2d 6572 726f 7227 2c20 6d65 7373 6167 l-error', messag\n+00036990: 653d 6627 696e 7661 6c69 6420 6275 7320 e=f'invalid bus \n+000369a0: 227b 6275 737d 2227 290a 2020 2020 2020 \"{bus}\"'). \n+000369b0: 2020 6578 6365 7074 204f 5345 7272 6f72 except OSError\n+000369c0: 2061 7320 6578 633a 0a20 2020 2020 2020 as exc:. \n+000369d0: 2020 2020 2072 6169 7365 2043 6861 6e6e raise Chann\n+000369e0: 656c 4572 726f 7228 2770 726f 746f 636f elError('protoco\n+000369f0: 6c2d 6572 726f 7227 2c20 6d65 7373 6167 l-error', messag\n+00036a00: 653d 6627 6661 696c 6564 2074 6f20 636f e=f'failed to co\n+00036a10: 6e6e 6563 7420 746f 207b 6275 737d 2062 nnect to {bus} b\n+00036a20: 7573 3a20 7b65 7863 7d27 2920 6672 6f6d us: {exc}') from\n+00036a30: 2065 7863 0a0a 2020 2020 2020 2020 7472 exc.. tr\n+00036a40: 793a 0a20 2020 2020 2020 2020 2020 2073 y:. s\n+00036a50: 656c 662e 6275 732e 6174 7461 6368 5f65 elf.bus.attach_e\n+00036a60: 7665 6e74 284e 6f6e 652c 2030 290a 2020 vent(None, 0). \n+00036a70: 2020 2020 2020 6578 6365 7074 204f 5345 except OSE\n+00036a80: 7272 6f72 2061 7320 6572 723a 0a20 2020 rror as err:. \n+00036a90: 2020 2020 2020 2020 2069 6620 6572 722e if err.\n+00036aa0: 6572 726e 6f20 213d 2065 7272 6e6f 2e45 errno != errno.E\n+00036ab0: 4255 5359 3a0a 2020 2020 2020 2020 2020 BUSY:. \n+00036ac0: 2020 2020 2020 7261 6973 650a 0a20 2020 raise.. \n+00036ad0: 2020 2020 2023 2054 6869 7320 6e65 6564 # This need\n+00036ae0: 7320 746f 2062 6520 6120 6661 6972 206d s to be a fair m\n+00036af0: 7574 6578 2073 6f20 7468 6174 206f 7574 utex so that out\n+00036b00: 676f 696e 6720 6d65 7373 6167 6573 2064 going messages d\n+00036b10: 6f6e 2774 0a20 2020 2020 2020 2023 2067 on't. # g\n+00036b20: 6574 2072 652d 6f72 6465 7265 642e 2020 et re-ordered. \n+00036b30: 6173 796e 6369 6f2e 4c6f 636b 2069 7320 asyncio.Lock is \n+00036b40: 6661 6972 2e0a 2020 2020 2020 2020 7365 fair.. se\n+00036b50: 6c66 2e77 6174 6368 5f70 726f 6365 7373 lf.watch_process\n+00036b60: 696e 675f 6c6f 636b 203d 2061 7379 6e63 ing_lock = async\n+00036b70: 696f 2e4c 6f63 6b28 290a 0a20 2020 2020 io.Lock().. \n+00036b80: 2020 2069 6620 7365 6c66 2e6e 616d 6520 if self.name \n+00036b90: 6973 206e 6f74 204e 6f6e 653a 0a20 2020 is not None:. \n+00036ba0: 2020 2020 2020 2020 2061 7379 6e63 2064 async d\n+00036bb0: 6566 2067 6574 5f72 6561 6479 2829 3a0a ef get_ready():.\n+00036bc0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00036bd0: 6173 796e 6320 7769 7468 2073 656c 662e async with self.\n+00036be0: 7761 7463 685f 7072 6f63 6573 7369 6e67 watch_processing\n+00036bf0: 5f6c 6f63 6b3a 0a20 2020 2020 2020 2020 _lock:. \n+00036c00: 2020 2020 2020 2020 2020 2061 7761 6974 await\n+00036c10: 2073 656c 662e 7365 7475 705f 6e61 6d65 self.setup_name\n+00036c20: 5f6f 776e 6572 5f74 7261 636b 696e 6728 _owner_tracking(\n+00036c30: 290a 2020 2020 2020 2020 2020 2020 2020 ). \n+00036c40: 2020 2020 2020 6966 2073 656c 662e 6f77 if self.ow\n+00036c50: 6e65 723a 0a20 2020 2020 2020 2020 2020 ner:. \n+00036c60: 2020 2020 2020 2020 2020 2020 2073 656c sel\n+00036c70: 662e 7265 6164 7928 756e 6971 7565 5f6e f.ready(unique_n\n+00036c80: 616d 653d 7365 6c66 2e6f 776e 6572 290a ame=self.owner).\n+00036c90: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00036ca0: 2020 2020 656c 7365 3a0a 2020 2020 2020 else:. \n+00036cb0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00036cc0: 2020 7365 6c66 2e63 6c6f 7365 287b 2770 self.close({'p\n+00036cd0: 726f 626c 656d 273a 2027 6e6f 742d 666f roblem': 'not-fo\n+00036ce0: 756e 6427 7d29 0a20 2020 2020 2020 2020 und'}). \n+00036cf0: 2020 2073 656c 662e 6372 6561 7465 5f74 self.create_t\n+00036d00: 6173 6b28 6765 745f 7265 6164 7928 2929 ask(get_ready())\n+00036d10: 0a20 2020 2020 2020 2065 6c73 653a 0a20 . else:. \n+00036d20: 2020 2020 2020 2020 2020 2073 656c 662e self.\n+00036d30: 7265 6164 7928 290a 0a20 2020 2064 6566 ready().. def\n+00036d40: 2061 6464 5f73 6967 6e61 6c5f 6861 6e64 add_signal_hand\n+00036d50: 6c65 7228 7365 6c66 2c20 6861 6e64 6c65 ler(self, handle\n+00036d60: 722c 202a 2a6b 7761 7267 7329 3a0a 2020 r, **kwargs):. \n+00036d70: 2020 2020 2020 7220 3d20 6469 6374 282a r = dict(*\n+00036d80: 2a6b 7761 7267 7329 0a20 2020 2020 2020 *kwargs). \n+00036d90: 2072 5b27 7479 7065 275d 203d 2027 7369 r['type'] = 'si\n+00036da0: 676e 616c 270a 2020 2020 2020 2020 6966 gnal'. if\n+00036db0: 2027 7365 6e64 6572 2720 6e6f 7420 696e 'sender' not in\n+00036dc0: 2072 2061 6e64 2073 656c 662e 6e61 6d65 r and self.name\n+00036dd0: 2069 7320 6e6f 7420 4e6f 6e65 3a0a 2020 is not None:. \n+00036de0: 2020 2020 2020 2020 2020 725b 2773 656e r['sen\n+00036df0: 6465 7227 5d20 3d20 7365 6c66 2e6e 616d der'] = self.nam\n+00036e00: 650a 2020 2020 2020 2020 2320 4841 434b e. # HACK\n+00036e10: 202d 2068 7474 7073 3a2f 2f67 6974 6875 - https://githu\n+00036e20: 622e 636f 6d2f 6275 7331 2f64 6275 732d b.com/bus1/dbus-\n+00036e30: 6272 6f6b 6572 2f69 7373 7565 732f 3330 broker/issues/30\n+00036e40: 390a 2020 2020 2020 2020 2320 7061 7468 9. # path\n+00036e50: 5f6e 616d 6573 7061 6365 3d27 2f27 2069 _namespace='/' i\n+00036e60: 6e20 6120 7275 6c65 2064 6f65 7320 6e6f n a rule does no\n+00036e70: 7420 776f 726b 2e0a 2020 2020 2020 2020 t work.. \n+00036e80: 6966 2072 2e67 6574 2827 7061 7468 5f6e if r.get('path_n\n+00036e90: 616d 6573 7061 6365 2729 203d 3d20 222f amespace') == \"/\n+00036ea0: 223a 0a20 2020 2020 2020 2020 2020 2064 \":. d\n+00036eb0: 656c 2072 5b27 7061 7468 5f6e 616d 6573 el r['path_names\n+00036ec0: 7061 6365 275d 0a0a 2020 2020 2020 2020 pace'].. \n+00036ed0: 6465 6620 6669 6c74 6572 5f6f 776e 6572 def filter_owner\n+00036ee0: 286d 6573 7361 6765 293a 0a20 2020 2020 (message):. \n+00036ef0: 2020 2020 2020 2069 6620 7365 6c66 2e6f if self.o\n+00036f00: 776e 6572 2069 7320 6e6f 7420 4e6f 6e65 wner is not None\n+00036f10: 2061 6e64 2073 656c 662e 6f77 6e65 7220 and self.owner \n+00036f20: 3d3d 206d 6573 7361 6765 2e67 6574 5f73 == message.get_s\n+00036f30: 656e 6465 7228 293a 0a20 2020 2020 2020 ender():. \n+00036f40: 2020 2020 2020 2020 2068 616e 646c 6572 handler\n+00036f50: 286d 6573 7361 6765 290a 0a20 2020 2020 (message).. \n+00036f60: 2020 2069 6620 7365 6c66 2e6e 616d 6520 if self.name \n+00036f70: 6973 206e 6f74 204e 6f6e 6520 616e 6420 is not None and \n+00036f80: 2773 656e 6465 7227 2069 6e20 7220 616e 'sender' in r an\n+00036f90: 6420 725b 2773 656e 6465 7227 5d20 3d3d d r['sender'] ==\n+00036fa0: 2073 656c 662e 6e61 6d65 3a0a 2020 2020 self.name:. \n+00036fb0: 2020 2020 2020 2020 6675 6e63 203d 2066 func = f\n+00036fc0: 696c 7465 725f 6f77 6e65 720a 2020 2020 ilter_owner. \n+00036fd0: 2020 2020 656c 7365 3a0a 2020 2020 2020 else:. \n+00036fe0: 2020 2020 2020 6675 6e63 203d 2068 616e func = han\n+00036ff0: 646c 6572 0a20 2020 2020 2020 2072 5f73 dler. r_s\n+00037000: 7472 696e 6720 3d20 272c 272e 6a6f 696e tring = ','.join\n+00037010: 2866 227b 6b65 797d 3d27 7b76 616c 7565 (f\"{key}='{value\n+00037020: 7d27 2220 666f 7220 6b65 792c 2076 616c }'\" for key, val\n+00037030: 7565 2069 6e20 722e 6974 656d 7328 2929 ue in r.items())\n+00037040: 0a20 2020 2020 2020 2069 6620 6e6f 7420 . if not \n+00037050: 7365 6c66 2e69 735f 636c 6f73 696e 6728 self.is_closing(\n+00037060: 293a 0a20 2020 2020 2020 2020 2020 2023 ):. #\n+00037070: 2074 6869 7320 6765 7473 2061 6e20 4549 this gets an EI\n+00037080: 4e54 5220 7665 7279 206f 6674 656e 2065 NTR very often e\n+00037090: 7370 6563 6961 6c6c 7920 6f6e 2052 4845 specially on RHE\n+000370a0: 4c20 380a 2020 2020 2020 2020 2020 2020 L 8. \n+000370b0: 7768 696c 6520 5472 7565 3a0a 2020 2020 while True:. \n+000370c0: 2020 2020 2020 2020 2020 2020 7472 793a try:\n+000370d0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+000370e0: 2020 2020 206d 6174 6368 203d 2073 656c match = sel\n+000370f0: 662e 6275 732e 6164 645f 6d61 7463 6828 f.bus.add_match(\n+00037100: 725f 7374 7269 6e67 2c20 6675 6e63 290a r_string, func).\n+00037110: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00037120: 2020 2020 6272 6561 6b0a 2020 2020 2020 break. \n+00037130: 2020 2020 2020 2020 2020 6578 6365 7074 except\n+00037140: 2049 6e74 6572 7275 7074 6564 4572 726f InterruptedErro\n+00037150: 723a 0a20 2020 2020 2020 2020 2020 2020 r:. \n+00037160: 2020 2020 2020 2070 6173 730a 0a20 2020 pass.. \n+00037170: 2020 2020 2020 2020 2073 656c 662e 6d61 self.ma\n+00037180: 7463 6865 732e 6170 7065 6e64 286d 6174 tches.append(mat\n+00037190: 6368 290a 0a20 2020 2064 6566 2061 6464 ch).. def add\n+000371a0: 5f61 7379 6e63 5f73 6967 6e61 6c5f 6861 _async_signal_ha\n+000371b0: 6e64 6c65 7228 7365 6c66 2c20 6861 6e64 ndler(self, hand\n+000371c0: 6c65 722c 202a 2a6b 7761 7267 7329 3a0a ler, **kwargs):.\n+000371d0: 2020 2020 2020 2020 6465 6620 7379 6e63 def sync\n+000371e0: 5f68 616e 646c 6572 286d 6573 7361 6765 _handler(message\n+000371f0: 293a 0a20 2020 2020 2020 2020 2020 2073 ):. s\n+00037200: 656c 662e 6372 6561 7465 5f74 6173 6b28 elf.create_task(\n+00037210: 6861 6e64 6c65 7228 6d65 7373 6167 6529 handler(message)\n+00037220: 290a 2020 2020 2020 2020 7365 6c66 2e61 ). self.a\n+00037230: 6464 5f73 6967 6e61 6c5f 6861 6e64 6c65 dd_signal_handle\n+00037240: 7228 7379 6e63 5f68 616e 646c 6572 2c20 r(sync_handler, \n+00037250: 2a2a 6b77 6172 6773 290a 0a20 2020 2061 **kwargs).. a\n+00037260: 7379 6e63 2064 6566 2064 6f5f 6361 6c6c sync def do_call\n+00037270: 2873 656c 662c 206d 6573 7361 6765 293a (self, message):\n+00037280: 0a20 2020 2020 2020 2070 6174 682c 2069 . path, i\n+00037290: 6661 6365 2c20 6d65 7468 6f64 2c20 6172 face, method, ar\n+000372a0: 6773 203d 206d 6573 7361 6765 5b27 6361 gs = message['ca\n+000372b0: 6c6c 275d 0a20 2020 2020 2020 2063 6f6f ll']. coo\n+000372c0: 6b69 6520 3d20 6d65 7373 6167 652e 6765 kie = message.ge\n+000372d0: 7428 2769 6427 290a 2020 2020 2020 2020 t('id'). \n+000372e0: 666c 6167 7320 3d20 6d65 7373 6167 652e flags = message.\n+000372f0: 6765 7428 2766 6c61 6773 2729 0a0a 2020 get('flags').. \n+00037300: 2020 2020 2020 7469 6d65 6f75 7420 3d20 timeout = \n+00037310: 6d65 7373 6167 652e 6765 7428 2774 696d message.get('tim\n+00037320: 656f 7574 2729 0a20 2020 2020 2020 2069 eout'). i\n+00037330: 6620 7469 6d65 6f75 7420 6973 206e 6f74 f timeout is not\n+00037340: 204e 6f6e 653a 0a20 2020 2020 2020 2020 None:. \n+00037350: 2020 2023 2073 645f 6275 7320 7469 6d65 # sd_bus time\n+00037360: 6f75 7420 6973 20ce bc73 2c20 636f 636b out is ..s, cock\n+00037370: 7069 7420 4150 4920 7469 6d65 6f75 7420 pit API timeout \n+00037380: 6973 206d 730a 2020 2020 2020 2020 2020 is ms. \n+00037390: 2020 7469 6d65 6f75 7420 2a3d 2031 3030 timeout *= 100\n+000373a0: 300a 2020 2020 2020 2020 656c 7365 3a0a 0. else:.\n+000373b0: 2020 2020 2020 2020 2020 2020 2320 7364 # sd\n+000373c0: 5f62 7573 2068 6173 206e 6f20 2269 6e64 _bus has no \"ind\n+000373d0: 6566 696e 6974 6522 2074 696d 656f 7574 efinite\" timeout\n+000373e0: 2c20 736f 2075 7365 204d 4158 5f55 494e , so use MAX_UIN\n+000373f0: 5436 340a 2020 2020 2020 2020 2020 2020 T64. \n+00037400: 7469 6d65 6f75 7420 3d20 3220 2a2a 2036 timeout = 2 ** 6\n+00037410: 3420 2d20 310a 0a20 2020 2020 2020 2023 4 - 1.. #\n+00037420: 2057 6520 6861 7665 2074 6f20 6669 6775 We have to figu\n+00037430: 7265 206f 7574 2074 6865 2073 6967 6e61 re out the signa\n+00037440: 7475 7265 206f 6620 7468 6520 6361 6c6c ture of the call\n+00037450: 2e20 2045 6974 6865 7220 7765 2067 6f74 . Either we got\n+00037460: 2074 6f6c 6420 6974 3a0a 2020 2020 2020 told it:. \n+00037470: 2020 7369 676e 6174 7572 6520 3d20 6d65 signature = me\n+00037480: 7373 6167 652e 6765 7428 2774 7970 6527 ssage.get('type'\n+00037490: 290a 0a20 2020 2020 2020 2023 202e 2e2e ).. # ...\n+000374a0: 206f 7220 7468 6572 6520 6172 656e 2774 or there aren't\n+000374b0: 2061 6e79 2061 7267 756d 656e 7473 0a20 any arguments. \n+000374c0: 2020 2020 2020 2069 6620 7369 676e 6174 if signat\n+000374d0: 7572 6520 6973 204e 6f6e 6520 616e 6420 ure is None and \n+000374e0: 6c65 6e28 6172 6773 2920 3d3d 2030 3a0a len(args) == 0:.\n+000374f0: 2020 2020 2020 2020 2020 2020 7369 676e sign\n+00037500: 6174 7572 6520 3d20 2727 0a0a 2020 2020 ature = ''.. \n+00037510: 2020 2020 2320 2e2e 2e20 6f72 2077 6520 # ... or we \n+00037520: 6e65 6564 2074 6f20 696e 7472 6f73 7065 need to introspe\n+00037530: 6374 0a20 2020 2020 2020 2069 6620 7369 ct. if si\n+00037540: 676e 6174 7572 6520 6973 204e 6f6e 653a gnature is None:\n+00037550: 0a20 2020 2020 2020 2020 2020 2074 7279 . try\n+00037560: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n+00037570: 2020 6c6f 6767 6572 2e64 6562 7567 2827 logger.debug('\n+00037580: 446f 696e 6720 696e 7472 6f73 7065 6374 Doing introspect\n+00037590: 696f 6e20 7265 7175 6573 7420 666f 7220 ion request for \n+000375a0: 2573 2025 7327 2c20 6966 6163 652c 206d %s %s', iface, m\n+000375b0: 6574 686f 6429 0a20 2020 2020 2020 2020 ethod). \n+000375c0: 2020 2020 2020 2073 6967 6e61 7475 7265 signature\n+000375d0: 203d 2061 7761 6974 2073 656c 662e 6361 = await self.ca\n+000375e0: 6368 652e 6765 745f 7369 676e 6174 7572 che.get_signatur\n+000375f0: 6528 6966 6163 652c 206d 6574 686f 642c e(iface, method,\n+00037600: 2073 656c 662e 6275 732c 2073 656c 662e self.bus, self.\n+00037610: 6e61 6d65 2c20 7061 7468 290a 2020 2020 name, path). \n+00037620: 2020 2020 2020 2020 6578 6365 7074 2042 except B\n+00037630: 7573 4572 726f 7220 6173 2065 7272 6f72 usError as error\n+00037640: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n+00037650: 2020 7365 6c66 2e73 656e 645f 6a73 6f6e self.send_json\n+00037660: 2865 7272 6f72 3d5b 6572 726f 722e 6e61 (error=[error.na\n+00037670: 6d65 2c20 5b66 2749 6e74 726f 7370 6563 me, [f'Introspec\n+00037680: 7469 6f6e 3a20 7b65 7272 6f72 2e6d 6573 tion: {error.mes\n+00037690: 7361 6765 7d27 5d5d 2c20 6964 3d63 6f6f sage}']], id=coo\n+000376a0: 6b69 6529 0a20 2020 2020 2020 2020 2020 kie). \n+000376b0: 2020 2020 2072 6574 7572 6e0a 2020 2020 return. \n+000376c0: 2020 2020 2020 2020 6578 6365 7074 204b except K\n+000376d0: 6579 4572 726f 723a 0a20 2020 2020 2020 eyError:. \n+000376e0: 2020 2020 2020 2020 2073 656c 662e 7365 self.se\n+000376f0: 6e64 5f6a 736f 6e28 0a20 2020 2020 2020 nd_json(. \n+00037700: 2020 2020 2020 2020 2020 2020 2065 7272 err\n+00037710: 6f72 3d5b 0a20 2020 2020 2020 2020 2020 or=[. \n+00037720: 2020 2020 2020 2020 2020 2020 2022 6f72 \"or\n+00037730: 672e 6672 6565 6465 736b 746f 702e 4442 g.freedesktop.DB\n+00037740: 7573 2e45 7272 6f72 2e55 6e6b 6e6f 776e us.Error.Unknown\n+00037750: 4d65 7468 6f64 222c 0a20 2020 2020 2020 Method\",. \n+00037760: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00037770: 205b 6622 496e 7472 6f73 7065 6374 696f [f\"Introspectio\n+00037780: 6e20 6461 7461 2066 6f72 206d 6574 686f n data for metho\n+00037790: 6420 7b69 6661 6365 7d20 7b6d 6574 686f d {iface} {metho\n+000377a0: 647d 206e 6f74 2061 7661 696c 6162 6c65 d} not available\n+000377b0: 225d 5d2c 0a20 2020 2020 2020 2020 2020 \"]],. \n+000377c0: 2020 2020 2020 2020 2069 643d 636f 6f6b id=cook\n+000377d0: 6965 290a 2020 2020 2020 2020 2020 2020 ie). \n+000377e0: 2020 2020 7265 7475 726e 0a20 2020 2020 return. \n+000377f0: 2020 2020 2020 2065 7863 6570 7420 4578 except Ex\n+00037800: 6365 7074 696f 6e20 6173 2065 7863 3a0a ception as exc:.\n+00037810: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00037820: 7365 6c66 2e73 656e 645f 6a73 6f6e 2865 self.send_json(e\n+00037830: 7272 6f72 3d5b 2770 7974 686f 6e2e 6572 rror=['python.er\n+00037840: 726f 7227 2c20 5b66 2749 6e74 726f 7370 ror', [f'Introsp\n+00037850: 6563 7469 6f6e 3a20 7b65 7863 2173 7d27 ection: {exc!s}'\n+00037860: 5d5d 2c20 6964 3d63 6f6f 6b69 6529 0a20 ]], id=cookie). \n+00037870: 2020 2020 2020 2020 2020 2020 2020 2072 r\n+00037880: 6574 7572 6e0a 0a20 2020 2020 2020 2074 eturn.. t\n+00037890: 7279 3a0a 2020 2020 2020 2020 2020 2020 ry:. \n+000378a0: 6d65 7468 6f64 5f63 616c 6c20 3d20 7365 method_call = se\n+000378b0: 6c66 2e62 7573 2e6d 6573 7361 6765 5f6e lf.bus.message_n\n+000378c0: 6577 5f6d 6574 686f 645f 6361 6c6c 2873 ew_method_call(s\n+000378d0: 656c 662e 6e61 6d65 2c20 7061 7468 2c20 elf.name, path, \n+000378e0: 6966 6163 652c 206d 6574 686f 642c 2073 iface, method, s\n+000378f0: 6967 6e61 7475 7265 2c20 2a61 7267 7329 ignature, *args)\n+00037900: 0a20 2020 2020 2020 2020 2020 2072 6570 . rep\n+00037910: 6c79 203d 2061 7761 6974 2073 656c 662e ly = await self.\n+00037920: 6275 732e 6361 6c6c 5f61 7379 6e63 286d bus.call_async(m\n+00037930: 6574 686f 645f 6361 6c6c 2c20 7469 6d65 ethod_call, time\n+00037940: 6f75 743d 7469 6d65 6f75 7429 0a20 2020 out=timeout). \n+00037950: 2020 2020 2020 2020 2023 2049 6620 7468 # If th\n+00037960: 6520 6d65 7468 6f64 2063 616c 6c20 6861 e method call ha\n+00037970: 7320 6b69 636b 6564 206f 6666 2061 6e79 s kicked off any\n+00037980: 2073 6967 6e61 6c73 2072 656c 6174 6564 signals related\n+00037990: 2074 6f0a 2020 2020 2020 2020 2020 2020 to. \n+000379a0: 2320 7761 7463 6820 7072 6f63 6573 7369 # watch processi\n+000379b0: 6e67 2c20 7761 6974 2066 6f72 2074 6861 ng, wait for tha\n+000379c0: 7420 746f 2062 6520 646f 6e65 2e0a 2020 t to be done.. \n+000379d0: 2020 2020 2020 2020 2020 6173 796e 6320 async \n+000379e0: 7769 7468 2073 656c 662e 7761 7463 685f with self.watch_\n+000379f0: 7072 6f63 6573 7369 6e67 5f6c 6f63 6b3a processing_lock:\n+00037a00: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+00037a10: 2023 2054 4f44 4f3a 2073 746f 7020 6861 # TODO: stop ha\n+00037a20: 7264 2d63 6f64 696e 6720 7468 6520 656e rd-coding the en\n+00037a30: 6469 616e 2066 6c61 6720 6865 7265 2e0a dian flag here..\n+00037a40: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00037a50: 7365 6c66 2e73 656e 645f 6a73 6f6e 280a self.send_json(.\n+00037a60: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00037a70: 2020 2020 7265 706c 793d 5b72 6570 6c79 reply=[reply\n+00037a80: 2e67 6574 5f62 6f64 7928 295d 2c20 6964 .get_body()], id\n+00037a90: 3d63 6f6f 6b69 652c 0a20 2020 2020 2020 =cookie,. \n+00037aa0: 2020 2020 2020 2020 2020 2020 2066 6c61 fla\n+00037ab0: 6773 3d22 3c22 2069 6620 666c 6167 7320 gs=\"<\" if flags \n+00037ac0: 6973 206e 6f74 204e 6f6e 6520 656c 7365 is not None else\n+00037ad0: 204e 6f6e 652c 0a20 2020 2020 2020 2020 None,. \n+00037ae0: 2020 2020 2020 2020 2020 2074 7970 653d type=\n+00037af0: 7265 706c 792e 6765 745f 7369 676e 6174 reply.get_signat\n+00037b00: 7572 6528 5472 7565 2929 2020 2320 6e6f ure(True)) # no\n+00037b10: 7161 3a20 4642 5430 3033 0a20 2020 2020 qa: FBT003. \n+00037b20: 2020 2065 7863 6570 7420 4275 7345 7272 except BusErr\n+00037b30: 6f72 2061 7320 6572 726f 723a 0a20 2020 or as error:. \n+00037b40: 2020 2020 2020 2020 2023 2061 6374 7561 # actua\n+00037b50: 6c6c 792c 2073 686f 756c 6420 7365 6e64 lly, should send\n+00037b60: 2074 6865 2066 6965 6c64 7320 6672 6f6d the fields from\n+00037b70: 2074 6865 206d 6573 7361 6765 2062 6f64 the message bod\n+00037b80: 790a 2020 2020 2020 2020 2020 2020 7365 y. se\n+00037b90: 6c66 2e73 656e 645f 6a73 6f6e 2865 7272 lf.send_json(err\n+00037ba0: 6f72 3d5b 6572 726f 722e 6e61 6d65 2c20 or=[error.name, \n+00037bb0: 5b65 7272 6f72 2e6d 6573 7361 6765 5d5d [error.message]]\n+00037bc0: 2c20 6964 3d63 6f6f 6b69 6529 0a20 2020 , id=cookie). \n+00037bd0: 2020 2020 2065 7863 6570 7420 4578 6365 except Exce\n+00037be0: 7074 696f 6e3a 0a20 2020 2020 2020 2020 ption:. \n+00037bf0: 2020 206c 6f67 6765 722e 6578 6365 7074 logger.except\n+00037c00: 696f 6e28 2264 6f5f 6361 6c6c 2825 7329 ion(\"do_call(%s)\n+00037c10: 3a20 6765 6e65 7269 6320 6578 6365 7074 : generic except\n+00037c20: 696f 6e22 2c20 6d65 7373 6167 6529 0a20 ion\", message). \n+00037c30: 2020 2020 2020 2020 2020 2073 656c 662e self.\n+00037c40: 7365 6e64 5f6a 736f 6e28 6572 726f 723d send_json(error=\n+00037c50: 5b27 7079 7468 6f6e 2e65 7272 6f72 272c ['python.error',\n+00037c60: 205b 7472 6163 6562 6163 6b2e 666f 726d [traceback.form\n+00037c70: 6174 5f65 7863 2829 5d5d 2c20 6964 3d63 at_exc()]], id=c\n+00037c80: 6f6f 6b69 6529 0a0a 2020 2020 6173 796e ookie).. asyn\n+00037c90: 6320 6465 6620 646f 5f61 6464 5f6d 6174 c def do_add_mat\n+00037ca0: 6368 2873 656c 662c 206d 6573 7361 6765 ch(self, message\n+00037cb0: 293a 0a20 2020 2020 2020 2061 6464 5f6d ):. add_m\n+00037cc0: 6174 6368 203d 206d 6573 7361 6765 5b27 atch = message['\n+00037cd0: 6164 642d 6d61 7463 6827 5d0a 2020 2020 add-match']. \n+00037ce0: 2020 2020 6c6f 6767 6572 2e64 6562 7567 logger.debug\n+00037cf0: 2827 6164 6469 6e67 206d 6174 6368 2025 ('adding match %\n+00037d00: 7327 2c20 6164 645f 6d61 7463 6829 0a0a s', add_match)..\n+00037d10: 2020 2020 2020 2020 6173 796e 6320 6465 async de\n+00037d20: 6620 6d61 7463 685f 6869 7428 6d65 7373 f match_hit(mess\n+00037d30: 6167 6529 3a0a 2020 2020 2020 2020 2020 age):. \n+00037d40: 2020 6c6f 6767 6572 2e64 6562 7567 2827 logger.debug('\n+00037d50: 676f 7420 6d61 7463 6827 290a 2020 2020 got match'). \n+00037d60: 2020 2020 2020 2020 6173 796e 6320 7769 async wi\n+00037d70: 7468 2073 656c 662e 7761 7463 685f 7072 th self.watch_pr\n+00037d80: 6f63 6573 7369 6e67 5f6c 6f63 6b3a 0a20 ocessing_lock:. \n+00037d90: 2020 2020 2020 2020 2020 2020 2020 2073 s\n+00037da0: 656c 662e 7365 6e64 5f6a 736f 6e28 7369 elf.send_json(si\n+00037db0: 676e 616c 3d5b 0a20 2020 2020 2020 2020 gnal=[. \n+00037dc0: 2020 2020 2020 2020 2020 206d 6573 7361 messa\n+00037dd0: 6765 2e67 6574 5f70 6174 6828 292c 0a20 ge.get_path(),. \n+00037de0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00037df0: 2020 206d 6573 7361 6765 2e67 6574 5f69 message.get_i\n+00037e00: 6e74 6572 6661 6365 2829 2c0a 2020 2020 nterface(),. \n+00037e10: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00037e20: 6d65 7373 6167 652e 6765 745f 6d65 6d62 message.get_memb\n+00037e30: 6572 2829 2c0a 2020 2020 2020 2020 2020 er(),. \n+00037e40: 2020 2020 2020 2020 2020 6c69 7374 286d list(m\n+00037e50: 6573 7361 6765 2e67 6574 5f62 6f64 7928 essage.get_body(\n+00037e60: 2929 0a20 2020 2020 2020 2020 2020 2020 )). \n+00037e70: 2020 205d 290a 0a20 2020 2020 2020 2073 ]).. s\n+00037e80: 656c 662e 6164 645f 6173 796e 635f 7369 elf.add_async_si\n+00037e90: 676e 616c 5f68 616e 646c 6572 286d 6174 gnal_handler(mat\n+00037ea0: 6368 5f68 6974 2c20 2a2a 6164 645f 6d61 ch_hit, **add_ma\n+00037eb0: 7463 6829 0a0a 2020 2020 6173 796e 6320 tch).. async \n+00037ec0: 6465 6620 7365 7475 705f 6f62 6a65 6374 def setup_object\n+00037ed0: 6d61 6e61 6765 725f 7761 7463 6828 7365 manager_watch(se\n+00037ee0: 6c66 2c20 7061 7468 2c20 696e 7465 7266 lf, path, interf\n+00037ef0: 6163 655f 6e61 6d65 2c20 6d65 7461 2c20 ace_name, meta, \n+00037f00: 6e6f 7469 6679 293a 0a20 2020 2020 2020 notify):. \n+00037f10: 2023 2057 6174 6368 2074 6865 206f 626a # Watch the obj\n+00037f20: 6563 7473 206d 616e 6167 6564 2062 7920 ects managed by \n+00037f30: 7468 6520 4f62 6a65 6374 4d61 6e61 6765 the ObjectManage\n+00037f40: 7220 6174 2022 7061 7468 222e 0a20 2020 r at \"path\".. \n+00037f50: 2020 2020 2023 2050 726f 7065 7274 6965 # Propertie\n+00037f60: 7320 6172 6520 6e6f 7420 7761 7463 6865 s are not watche\n+00037f70: 642c 2074 6861 7420 6973 2064 6f6e 6520 d, that is done \n+00037f80: 6279 2073 6574 7570 5f70 6174 685f 7761 by setup_path_wa\n+00037f90: 7463 680a 2020 2020 2020 2020 2320 6265 tch. # be\n+00037fa0: 6c6f 7720 7669 6120 7265 6375 7273 6976 low via recursiv\n+00037fb0: 655f 7072 6f70 7320 3d3d 2054 7275 652e e_props == True.\n+00037fc0: 0a0a 2020 2020 2020 2020 6173 796e 6320 .. async \n+00037fd0: 6465 6620 6861 6e64 6c65 7228 6d65 7373 def handler(mess\n+00037fe0: 6167 6529 3a0a 2020 2020 2020 2020 2020 age):. \n+00037ff0: 2020 6d65 6d62 6572 203d 206d 6573 7361 member = messa\n+00038000: 6765 2e67 6574 5f6d 656d 6265 7228 290a ge.get_member().\n+00038010: 2020 2020 2020 2020 2020 2020 6966 206d if m\n+00038020: 656d 6265 7220 3d3d 2022 496e 7465 7266 ember == \"Interf\n+00038030: 6163 6573 4164 6465 6422 3a0a 2020 2020 acesAdded\":. \n+00038040: 2020 2020 2020 2020 2020 2020 2870 6174 (pat\n+00038050: 682c 2069 6e74 6572 6661 6365 5f70 726f h, interface_pro\n+00038060: 7073 2920 3d20 6d65 7373 6167 652e 6765 ps) = message.ge\n+00038070: 745f 626f 6479 2829 0a20 2020 2020 2020 t_body(). \n+00038080: 2020 2020 2020 2020 206c 6f67 6765 722e logger.\n+00038090: 6465 6275 6728 2769 6e74 6572 6661 6365 debug('interface\n+000380a0: 7320 6164 6465 6420 2573 2025 7327 2c20 s added %s %s', \n+000380b0: 7061 7468 2c20 696e 7465 7266 6163 655f path, interface_\n+000380c0: 7072 6f70 7329 0a20 2020 2020 2020 2020 props). \n+000380d0: 2020 2020 2020 206d 6574 6120 3d20 7b7d meta = {}\n+000380e0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+000380f0: 206e 6f74 6966 7920 3d20 7b7d 0a20 2020 notify = {}. \n+00038100: 2020 2020 2020 2020 2020 2020 2061 7379 asy\n+00038110: 6e63 2077 6974 6820 7365 6c66 2e77 6174 nc with self.wat\n+00038120: 6368 5f70 726f 6365 7373 696e 675f 6c6f ch_processing_lo\n+00038130: 636b 3a0a 2020 2020 2020 2020 2020 2020 ck:. \n+00038140: 2020 2020 2020 2020 666f 7220 6e61 6d65 for name\n+00038150: 2c20 7072 6f70 7320 696e 2069 6e74 6572 , props in inter\n+00038160: 6661 6365 5f70 726f 7073 2e69 7465 6d73 face_props.items\n+00038170: 2829 3a0a 2020 2020 2020 2020 2020 2020 ():. \n+00038180: 2020 2020 2020 2020 2020 2020 6966 2069 if i\n+00038190: 6e74 6572 6661 6365 5f6e 616d 6520 6973 nterface_name is\n+000381a0: 204e 6f6e 6520 6f72 206e 616d 6520 3d3d None or name ==\n+000381b0: 2069 6e74 6572 6661 6365 5f6e 616d 653a interface_name:\n+000381c0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+000381d0: 2020 2020 2020 2020 2020 2020 206d 6d20 mm \n+000381e0: 3d20 6177 6169 7420 7365 6c66 2e63 6163 = await self.cac\n+000381f0: 6865 2e67 6574 5f69 6e74 6572 6661 6365 he.get_interface\n+00038200: 5f69 665f 6e65 7728 6e61 6d65 2c20 7365 _if_new(name, se\n+00038210: 6c66 2e62 7573 2c20 7365 6c66 2e6e 616d lf.bus, self.nam\n+00038220: 652c 2070 6174 6829 0a20 2020 2020 2020 e, path). \n+00038230: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00038240: 2020 2020 2069 6620 6d6d 3a0a 2020 2020 if mm:. \n+00038250: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00038260: 2020 2020 2020 2020 2020 2020 6d65 7461 meta\n+00038270: 2e75 7064 6174 6528 7b6e 616d 653a 206d .update({name: m\n+00038280: 6d7d 290a 2020 2020 2020 2020 2020 2020 m}). \n+00038290: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000382a0: 6e6f 7469 6679 5f75 7064 6174 6528 6e6f notify_update(no\n+000382b0: 7469 6679 2c20 7061 7468 2c20 6e61 6d65 tify, path, name\n+000382c0: 2c20 7072 6f70 7329 0a20 2020 2020 2020 , props). \n+000382d0: 2020 2020 2020 2020 2020 2020 2073 656c sel\n+000382e0: 662e 7365 6e64 5f6a 736f 6e28 6d65 7461 f.send_json(meta\n+000382f0: 3d6d 6574 6129 0a20 2020 2020 2020 2020 =meta). \n+00038300: 2020 2020 2020 2020 2020 2073 656c 662e self.\n+00038310: 7365 6e64 5f6a 736f 6e28 6e6f 7469 6679 send_json(notify\n+00038320: 3d6e 6f74 6966 7929 0a20 2020 2020 2020 =notify). \n+00038330: 2020 2020 2065 6c69 6620 6d65 6d62 6572 elif member\n+00038340: 203d 3d20 2249 6e74 6572 6661 6365 7352 == \"InterfacesR\n+00038350: 656d 6f76 6564 223a 0a20 2020 2020 2020 emoved\":. \n+00038360: 2020 2020 2020 2020 2028 7061 7468 2c20 (path, \n+00038370: 696e 7465 7266 6163 6573 2920 3d20 6d65 interfaces) = me\n+00038380: 7373 6167 652e 6765 745f 626f 6479 2829 ssage.get_body()\n+00038390: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+000383a0: 206c 6f67 6765 722e 6465 6275 6728 2769 logger.debug('i\n+000383b0: 6e74 6572 6661 6365 7320 7265 6d6f 7665 nterfaces remove\n+000383c0: 6420 2573 2025 7327 2c20 7061 7468 2c20 d %s %s', path, \n+000383d0: 696e 7465 7266 6163 6573 290a 2020 2020 interfaces). \n+000383e0: 2020 2020 2020 2020 2020 2020 6173 796e asyn\n+000383f0: 6320 7769 7468 2073 656c 662e 7761 7463 c with self.watc\n+00038400: 685f 7072 6f63 6573 7369 6e67 5f6c 6f63 h_processing_loc\n+00038410: 6b3a 0a20 2020 2020 2020 2020 2020 2020 k:. \n+00038420: 2020 2020 2020 206e 6f74 6966 7920 3d20 notify = \n+00038430: 7b70 6174 683a 2064 6963 742e 6672 6f6d {path: dict.from\n+00038440: 6b65 7973 2869 6e74 6572 6661 6365 7329 keys(interfaces)\n+00038450: 7d0a 2020 2020 2020 2020 2020 2020 2020 }. \n+00038460: 2020 2020 2020 7365 6c66 2e73 656e 645f self.send_\n+00038470: 6a73 6f6e 286e 6f74 6966 793d 6e6f 7469 json(notify=noti\n+00038480: 6679 290a 0a20 2020 2020 2020 2073 656c fy).. sel\n+00038490: 662e 6164 645f 6173 796e 635f 7369 676e f.add_async_sign\n+000384a0: 616c 5f68 616e 646c 6572 2868 616e 646c al_handler(handl\n+000384b0: 6572 2c0a 2020 2020 2020 2020 2020 2020 er,. \n+000384c0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000384d0: 2020 2020 2020 2020 2020 7061 7468 3d70 path=p\n+000384e0: 6174 682c 0a20 2020 2020 2020 2020 2020 ath,. \n+000384f0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00038500: 2020 2020 2020 2020 2020 2069 6e74 6572 inter\n+00038510: 6661 6365 3d22 6f72 672e 6672 6565 6465 face=\"org.freede\n+00038520: 736b 746f 702e 4442 7573 2e4f 626a 6563 sktop.DBus.Objec\n+00038530: 744d 616e 6167 6572 2229 0a20 2020 2020 tManager\"). \n+00038540: 2020 206f 626a 6563 7473 2c20 3d20 6177 objects, = aw\n+00038550: 6169 7420 7365 6c66 2e62 7573 2e63 616c ait self.bus.cal\n+00038560: 6c5f 6d65 7468 6f64 5f61 7379 6e63 2873 l_method_async(s\n+00038570: 656c 662e 6e61 6d65 2c20 7061 7468 2c0a elf.name, path,.\n+00038580: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00038590: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000385a0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000385b0: 2020 2020 276f 7267 2e66 7265 6564 6573 'org.freedes\n+000385c0: 6b74 6f70 2e44 4275 732e 4f62 6a65 6374 ktop.DBus.Object\n+000385d0: 4d61 6e61 6765 7227 2c0a 2020 2020 2020 Manager',. \n+000385e0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000385f0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00038600: 2020 2020 2020 2020 2020 2020 2020 2747 'G\n+00038610: 6574 4d61 6e61 6765 644f 626a 6563 7473 etManagedObjects\n+00038620: 2729 0a20 2020 2020 2020 2066 6f72 2070 '). for p\n+00038630: 2c20 6966 6163 6573 2069 6e20 6f62 6a65 , ifaces in obje\n+00038640: 6374 732e 6974 656d 7328 293a 0a20 2020 cts.items():. \n+00038650: 2020 2020 2020 2020 2066 6f72 2069 6661 for ifa\n+00038660: 6365 2c20 7072 6f70 7320 696e 2069 6661 ce, props in ifa\n+00038670: 6365 732e 6974 656d 7328 293a 0a20 2020 ces.items():. \n+00038680: 2020 2020 2020 2020 2020 2020 2069 6620 if \n+00038690: 696e 7465 7266 6163 655f 6e61 6d65 2069 interface_name i\n+000386a0: 7320 4e6f 6e65 206f 7220 6966 6163 6520 s None or iface \n+000386b0: 3d3d 2069 6e74 6572 6661 6365 5f6e 616d == interface_nam\n+000386c0: 653a 0a20 2020 2020 2020 2020 2020 2020 e:. \n+000386d0: 2020 2020 2020 206d 6d20 3d20 6177 6169 mm = awai\n+000386e0: 7420 7365 6c66 2e63 6163 6865 2e67 6574 t self.cache.get\n+000386f0: 5f69 6e74 6572 6661 6365 5f69 665f 6e65 _interface_if_ne\n+00038700: 7728 6966 6163 652c 2073 656c 662e 6275 w(iface, self.bu\n+00038710: 732c 2073 656c 662e 6e61 6d65 2c20 7029 s, self.name, p)\n+00038720: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+00038730: 2020 2020 2069 6620 6d6d 3a0a 2020 2020 if mm:. \n+00038740: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00038750: 2020 2020 6d65 7461 2e75 7064 6174 6528 meta.update(\n+00038760: 7b69 6661 6365 3a20 6d6d 7d29 0a20 2020 {iface: mm}). \n+00038770: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00038780: 206e 6f74 6966 795f 7570 6461 7465 286e notify_update(n\n+00038790: 6f74 6966 792c 2070 2c20 6966 6163 652c otify, p, iface,\n+000387a0: 2070 726f 7073 290a 0a20 2020 2061 7379 props).. asy\n+000387b0: 6e63 2064 6566 2073 6574 7570 5f70 6174 nc def setup_pat\n+000387c0: 685f 7761 7463 6828 7365 6c66 2c20 7061 h_watch(self, pa\n+000387d0: 7468 2c20 696e 7465 7266 6163 655f 6e61 th, interface_na\n+000387e0: 6d65 2c20 7265 6375 7273 6976 655f 7072 me, recursive_pr\n+000387f0: 6f70 732c 206d 6574 612c 206e 6f74 6966 ops, meta, notif\n+00038800: 7929 3a0a 2020 2020 2020 2020 2320 5761 y):. # Wa\n+00038810: 7463 6820 6120 7369 6e67 6c65 206f 626a tch a single obj\n+00038820: 6563 7420 6174 2022 7061 7468 222c 2062 ect at \"path\", b\n+00038830: 7574 206d 6179 6265 2061 6c73 6f20 7761 ut maybe also wa\n+00038840: 7463 6820 666f 720a 2020 2020 2020 2020 tch for. \n+00038850: 2320 7072 6f70 6572 7479 2063 6861 6e67 # property chang\n+00038860: 6573 2066 6f72 2061 6c6c 206f 626a 6563 es for all objec\n+00038870: 7473 2062 656c 6f77 2022 7061 7468 222e ts below \"path\".\n+00038880: 0a0a 2020 2020 2020 2020 6173 796e 6320 .. async \n+00038890: 6465 6620 6861 6e64 6c65 7228 6d65 7373 def handler(mess\n+000388a0: 6167 6529 3a0a 2020 2020 2020 2020 2020 age):. \n+000388b0: 2020 6173 796e 6320 7769 7468 2073 656c async with sel\n+000388c0: 662e 7761 7463 685f 7072 6f63 6573 7369 f.watch_processi\n+000388d0: 6e67 5f6c 6f63 6b3a 0a20 2020 2020 2020 ng_lock:. \n+000388e0: 2020 2020 2020 2020 2070 6174 6820 3d20 path = \n+000388f0: 6d65 7373 6167 652e 6765 745f 7061 7468 message.get_path\n+00038900: 2829 0a20 2020 2020 2020 2020 2020 2020 (). \n+00038910: 2020 206e 616d 652c 2070 726f 7073 2c20 name, props, \n+00038920: 696e 7661 6c69 6473 203d 206d 6573 7361 invalids = messa\n+00038930: 6765 2e67 6574 5f62 6f64 7928 290a 2020 ge.get_body(). \n+00038940: 2020 2020 2020 2020 2020 2020 2020 6c6f lo\n+00038950: 6767 6572 2e64 6562 7567 2827 4e4f 5449 gger.debug('NOTI\n+00038960: 4659 3a20 2573 2025 7320 2573 2025 7327 FY: %s %s %s %s'\n+00038970: 2c20 7061 7468 2c20 6e61 6d65 2c20 7072 , path, name, pr\n+00038980: 6f70 732c 2069 6e76 616c 6964 7329 0a20 ops, invalids). \n+00038990: 2020 2020 2020 2020 2020 2020 2020 2066 f\n+000389a0: 6f72 2069 6e76 2069 6e20 696e 7661 6c69 or inv in invali\n+000389b0: 6473 3a0a 2020 2020 2020 2020 2020 2020 ds:. \n+000389c0: 2020 2020 2020 2020 7472 793a 0a20 2020 try:. \n+000389d0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000389e0: 2020 2020 2072 6570 6c79 2c20 3d20 6177 reply, = aw\n+000389f0: 6169 7420 7365 6c66 2e62 7573 2e63 616c ait self.bus.cal\n+00038a00: 6c5f 6d65 7468 6f64 5f61 7379 6e63 2873 l_method_async(s\n+00038a10: 656c 662e 6e61 6d65 2c20 7061 7468 2c0a elf.name, path,.\n+00038a20: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00038a30: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00038a40: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00038a50: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00038a60: 2020 276f 7267 2e66 7265 6564 6573 6b74 'org.freedeskt\n+00038a70: 6f70 2e44 4275 732e 5072 6f70 6572 7469 op.DBus.Properti\n+00038a80: 6573 272c 2027 4765 7427 2c0a 2020 2020 es', 'Get',. \n+00038a90: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00038aa0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00038ab0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00038ac0: 2020 2020 2020 2020 2020 2020 2020 2773 's\n+00038ad0: 7327 2c20 6e61 6d65 2c20 696e 7629 0a20 s', name, inv). \n+00038ae0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00038af0: 2020 2065 7863 6570 7420 4275 7345 7272 except BusErr\n+00038b00: 6f72 2061 7320 6578 633a 0a20 2020 2020 or as exc:. \n+00038b10: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00038b20: 2020 206c 6f67 6765 722e 6465 6275 6728 logger.debug(\n+00038b30: 2766 6169 6c65 6420 746f 2066 6574 6368 'failed to fetch\n+00038b40: 2070 726f 7065 7274 7920 2573 2e25 7320 property %s.%s \n+00038b50: 6f6e 2025 7320 2573 3a20 2573 272c 0a20 on %s %s: %s',. \n 00038b60: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00038b70: 2020 2020 2020 2020 2020 2020 7261 6973 rais\n-00038b80: 6520 4368 616e 6e65 6c45 7272 6f72 2827 e ChannelError('\n-00038b90: 6368 616e 6765 2d63 6f6e 666c 6963 7427 change-conflict'\n-00038ba0: 290a 2020 2020 2020 2020 2020 2020 2020 ). \n-00038bb0: 2020 2020 2020 2020 2020 2320 6368 6f77 # chow\n-00038bc0: 6e2f 6368 6d6f 6420 6672 6f6d 2074 6865 n/chmod from the\n-00038bd0: 2065 7869 7374 696e 6720 6669 6c65 2070 existing file p\n-00038be0: 6572 6d69 7373 696f 6e73 0a20 2020 2020 ermissions. \n-00038bf0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00038c00: 2020 206f 732e 6663 686d 6f64 2874 6d70 os.fchmod(tmp\n-00038c10: 2e66 696c 656e 6f28 292c 2073 7461 742e .fileno(), stat.\n-00038c20: 535f 494d 4f44 4528 6275 662e 7374 5f6d S_IMODE(buf.st_m\n-00038c30: 6f64 6529 290a 2020 2020 2020 2020 2020 ode)). \n-00038c40: 2020 2020 2020 2020 2020 2020 2020 6f73 os\n-00038c50: 2e66 6368 6f77 6e28 746d 702e 6669 6c65 .fchown(tmp.file\n-00038c60: 6e6f 2829 2c20 6275 662e 7374 5f75 6964 no(), buf.st_uid\n-00038c70: 2c20 6275 662e 7374 5f67 6964 290a 2020 , buf.st_gid). \n-00038c80: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00038c90: 2020 2020 2020 6f73 2e72 656e 616d 6528 os.rename(\n-00038ca0: 746d 702e 6e61 6d65 2c20 7061 7468 290a tmp.name, path).\n-00038cb0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00038cc0: 2020 2020 2020 2020 6465 6c65 7465 5f6f delete_o\n-00038cd0: 6e5f 6578 6974 203d 204e 6f6e 650a 0a20 n_exit = None.. \n-00038ce0: 2020 2020 2020 2065 7863 6570 7420 4669 except Fi\n-00038cf0: 6c65 4e6f 7446 6f75 6e64 4572 726f 7220 leNotFoundError \n-00038d00: 6173 2065 7863 3a0a 2020 2020 2020 2020 as exc:. \n-00038d10: 2020 2020 7261 6973 6520 4368 616e 6e65 raise Channe\n-00038d20: 6c45 7272 6f72 2827 6e6f 742d 666f 756e lError('not-foun\n-00038d30: 6427 2920 6672 6f6d 2065 7863 0a20 2020 d') from exc. \n-00038d40: 2020 2020 2065 7863 6570 7420 4669 6c65 except File\n-00038d50: 4578 6973 7473 4572 726f 7220 6173 2065 ExistsError as e\n-00038d60: 7863 3a0a 2020 2020 2020 2020 2020 2020 xc:. \n-00038d70: 2320 7468 6174 2773 2066 726f 6d20 6c69 # that's from li\n-00038d80: 6e6b 2829 206e 6f74 6963 696e 6720 7468 nk() noticing th\n-00038d90: 6174 2074 6865 2074 6172 6765 7420 6669 at the target fi\n-00038da0: 6c65 2061 6c72 6561 6479 2065 7869 7374 le already exist\n-00038db0: 730a 2020 2020 2020 2020 2020 2020 7261 s. ra\n-00038dc0: 6973 6520 4368 616e 6e65 6c45 7272 6f72 ise ChannelError\n-00038dd0: 2827 6368 616e 6765 2d63 6f6e 666c 6963 ('change-conflic\n-00038de0: 7427 2920 6672 6f6d 2065 7863 0a20 2020 t') from exc. \n-00038df0: 2020 2020 2065 7863 6570 7420 5065 726d except Perm\n-00038e00: 6973 7369 6f6e 4572 726f 7220 6173 2065 issionError as e\n-00038e10: 7863 3a0a 2020 2020 2020 2020 2020 2020 xc:. \n-00038e20: 7261 6973 6520 4368 616e 6e65 6c45 7272 raise ChannelErr\n-00038e30: 6f72 2827 6163 6365 7373 2d64 656e 6965 or('access-denie\n-00038e40: 6427 2920 6672 6f6d 2065 7863 0a20 2020 d') from exc. \n-00038e50: 2020 2020 2065 7863 6570 7420 4973 4144 except IsAD\n-00038e60: 6972 6563 746f 7279 4572 726f 7220 6173 irectoryError as\n-00038e70: 2065 7863 3a0a 2020 2020 2020 2020 2020 exc:. \n-00038e80: 2020 2320 6e6f 7420 6964 6561 6c2c 2062 # not ideal, b\n-00038e90: 7574 2074 6865 2063 6c6f 7365 7374 2063 ut the closest c\n-00038ea0: 6f64 6520 7765 2068 6176 650a 2020 2020 ode we have. \n-00038eb0: 2020 2020 2020 2020 7261 6973 6520 4368 raise Ch\n-00038ec0: 616e 6e65 6c45 7272 6f72 2827 6163 6365 annelError('acce\n-00038ed0: 7373 2d64 656e 6965 6427 2c20 6d65 7373 ss-denied', mess\n-00038ee0: 6167 653d 7374 7228 6578 6329 2920 6672 age=str(exc)) fr\n-00038ef0: 6f6d 2065 7863 0a20 2020 2020 2020 2065 om exc. e\n-00038f00: 7863 6570 7420 4f53 4572 726f 7220 6173 xcept OSError as\n-00038f10: 2065 7863 3a0a 2020 2020 2020 2020 2020 exc:. \n-00038f20: 2020 7261 6973 6520 4368 616e 6e65 6c45 raise ChannelE\n-00038f30: 7272 6f72 2827 696e 7465 726e 616c 2d65 rror('internal-e\n-00038f40: 7272 6f72 272c 206d 6573 7361 6765 3d73 rror', message=s\n-00038f50: 7472 2865 7863 2929 2066 726f 6d20 6578 tr(exc)) from ex\n-00038f60: 630a 2020 2020 2020 2020 6669 6e61 6c6c c. finall\n-00038f70: 793a 0a20 2020 2020 2020 2020 2020 2069 y:. i\n-00038f80: 6620 6465 6c65 7465 5f6f 6e5f 6578 6974 f delete_on_exit\n-00038f90: 2069 7320 6e6f 7420 4e6f 6e65 3a0a 2020 is not None:. \n-00038fa0: 2020 2020 2020 2020 2020 2020 2020 6f73 os\n-00038fb0: 2e75 6e6c 696e 6b28 6465 6c65 7465 5f6f .unlink(delete_o\n-00038fc0: 6e5f 6578 6974 290a 0a20 2020 2020 2020 n_exit).. \n-00038fd0: 2073 656c 662e 646f 6e65 2829 0a0a 2020 self.done().. \n-00038fe0: 2020 2020 2020 7265 7475 726e 207b 2774 return {'t\n-00038ff0: 6167 273a 2074 6167 5f66 726f 6d5f 7061 ag': tag_from_pa\n-00039000: 7468 2870 6174 6829 7d0a 0a0a 636c 6173 th(path)}...clas\n-00039010: 7320 4673 5761 7463 6843 6861 6e6e 656c s FsWatchChannel\n-00039020: 2843 6861 6e6e 656c 293a 0a20 2020 2070 (Channel):. p\n-00039030: 6179 6c6f 6164 203d 2027 6673 7761 7463 ayload = 'fswatc\n-00039040: 6831 270a 2020 2020 5f74 6167 203d 204e h1'. _tag = N\n-00039050: 6f6e 650a 2020 2020 5f70 6174 6820 3d20 one. _path = \n-00039060: 4e6f 6e65 0a20 2020 205f 7761 7463 6820 None. _watch \n-00039070: 3d20 4e6f 6e65 0a0a 2020 2020 2320 5468 = None.. # Th\n-00039080: 6520 4320 6272 6964 6765 2064 6f65 736e e C bridge doesn\n-00039090: 2774 2073 656e 6420 7468 6520 696e 6974 't send the init\n-000390a0: 6961 6c20 6576 656e 742c 2061 6e64 2074 ial event, and t\n-000390b0: 6865 204a 5320 6361 6c6c 7320 7265 6164 he JS calls read\n-000390c0: 2829 0a20 2020 2023 2069 6e73 7465 6164 (). # instead\n-000390d0: 2074 6f20 6669 6775 7265 206f 7574 2074 to figure out t\n-000390e0: 6865 2069 6e69 7469 616c 2073 7461 7465 he initial state\n-000390f0: 206f 6620 7468 6520 6669 6c65 2e20 2049 of the file. I\n-00039100: 6620 7765 2073 656e 6420 7468 650a 2020 f we send the. \n-00039110: 2020 2320 696e 6974 6961 6c20 7374 6174 # initial stat\n-00039120: 6520 7468 656e 2077 6520 6361 7573 6520 e then we cause \n-00039130: 7468 6520 6576 656e 7420 746f 2067 6574 the event to get\n-00039140: 2064 656c 6976 6572 6564 2074 7769 6365 delivered twice\n-00039150: 2e0a 2020 2020 2320 4964 6561 6c6c 7920 .. # Ideally \n-00039160: 7765 276c 6c20 736f 7274 2074 6861 7420 we'll sort that \n-00039170: 6f75 7420 6174 2073 6f6d 6520 706f 696e out at some poin\n-00039180: 742c 2062 7574 2066 6f72 206e 6f77 2c20 t, but for now, \n-00039190: 7375 7070 7265 7373 2069 742e 0a20 2020 suppress it.. \n-000391a0: 205f 6163 7469 7665 203d 2046 616c 7365 _active = False\n-000391b0: 0a0a 2020 2020 4073 7461 7469 636d 6574 .. @staticmet\n-000391c0: 686f 640a 2020 2020 6465 6620 6d61 736b hod. def mask\n-000391d0: 5f74 6f5f 6576 656e 745f 616e 645f 7479 _to_event_and_ty\n-000391e0: 7065 286d 6173 6b29 3a0a 2020 2020 2020 pe(mask):. \n-000391f0: 2020 6966 2028 496e 6f74 6966 7945 7665 if (InotifyEve\n-00039200: 6e74 2e43 5245 4154 4520 6f72 2049 6e6f nt.CREATE or Ino\n-00039210: 7469 6679 4576 656e 742e 4d4f 5645 445f tifyEvent.MOVED_\n-00039220: 544f 2920 696e 206d 6173 6b3a 0a20 2020 TO) in mask:. \n-00039230: 2020 2020 2020 2020 2072 6574 7572 6e20 return \n-00039240: 2763 7265 6174 6564 272c 2027 6469 7265 'created', 'dire\n-00039250: 6374 6f72 7927 2069 6620 496e 6f74 6966 ctory' if Inotif\n-00039260: 7945 7665 6e74 2e49 5344 4952 2069 6e20 yEvent.ISDIR in \n-00039270: 6d61 736b 2065 6c73 6520 2766 696c 6527 mask else 'file'\n-00039280: 0a20 2020 2020 2020 2065 6c69 6620 496e . elif In\n-00039290: 6f74 6966 7945 7665 6e74 2e4d 4f56 4544 otifyEvent.MOVED\n-000392a0: 5f46 524f 4d20 696e 206d 6173 6b20 6f72 _FROM in mask or\n-000392b0: 2049 6e6f 7469 6679 4576 656e 742e 4445 InotifyEvent.DE\n-000392c0: 4c45 5445 2069 6e20 6d61 736b 206f 7220 LETE in mask or \n-000392d0: 496e 6f74 6966 7945 7665 6e74 2e44 454c InotifyEvent.DEL\n-000392e0: 4554 455f 5345 4c46 2069 6e20 6d61 736b ETE_SELF in mask\n-000392f0: 3a0a 2020 2020 2020 2020 2020 2020 7265 :. re\n-00039300: 7475 726e 2027 6465 6c65 7465 6427 2c20 turn 'deleted', \n-00039310: 4e6f 6e65 0a20 2020 2020 2020 2065 6c69 None. eli\n-00039320: 6620 496e 6f74 6966 7945 7665 6e74 2e41 f InotifyEvent.A\n-00039330: 5454 5249 4220 696e 206d 6173 6b3a 0a20 TTRIB in mask:. \n-00039340: 2020 2020 2020 2020 2020 2072 6574 7572 retur\n-00039350: 6e20 2761 7474 7269 6275 7465 2d63 6861 n 'attribute-cha\n-00039360: 6e67 6564 272c 204e 6f6e 650a 2020 2020 nged', None. \n-00039370: 2020 2020 656c 6966 2049 6e6f 7469 6679 elif Inotify\n-00039380: 4576 656e 742e 434c 4f53 455f 5752 4954 Event.CLOSE_WRIT\n-00039390: 4520 696e 206d 6173 6b3a 0a20 2020 2020 E in mask:. \n-000393a0: 2020 2020 2020 2072 6574 7572 6e20 2764 return 'd\n-000393b0: 6f6e 652d 6869 6e74 272c 204e 6f6e 650a one-hint', None.\n-000393c0: 2020 2020 2020 2020 656c 7365 3a0a 2020 else:. \n-000393d0: 2020 2020 2020 2020 2020 7265 7475 726e return\n-000393e0: 2027 6368 616e 6765 6427 2c20 4e6f 6e65 'changed', None\n-000393f0: 0a0a 2020 2020 6465 6620 646f 5f69 6e6f .. def do_ino\n-00039400: 7469 6679 5f65 7665 6e74 2873 656c 662c tify_event(self,\n-00039410: 206d 6173 6b2c 205f 636f 6f6b 6965 2c20 mask, _cookie, \n-00039420: 6e61 6d65 293a 0a20 2020 2020 2020 206c name):. l\n-00039430: 6f67 6765 722e 6465 6275 6728 2264 6f5f ogger.debug(\"do_\n-00039440: 696e 6f74 6966 795f 6576 656e 7428 2573 inotify_event(%s\n-00039450: 293a 206d 6173 6b20 2558 206e 616d 6520 ): mask %X name \n-00039460: 2573 222c 2073 656c 662e 5f70 6174 682c %s\", self._path,\n-00039470: 206d 6173 6b2c 206e 616d 6529 0a20 2020 mask, name). \n-00039480: 2020 2020 2065 7665 6e74 2c20 7479 7065 event, type\n-00039490: 5f20 3d20 7365 6c66 2e6d 6173 6b5f 746f _ = self.mask_to\n-000394a0: 5f65 7665 6e74 5f61 6e64 5f74 7970 6528 _event_and_type(\n-000394b0: 6d61 736b 290a 2020 2020 2020 2020 6966 mask). if\n-000394c0: 206e 616d 653a 0a20 2020 2020 2020 2020 name:. \n-000394d0: 2020 2023 2066 696c 6520 696e 7369 6465 # file inside\n-000394e0: 2077 6174 6368 6564 2064 6972 6563 746f watched directo\n-000394f0: 7279 2063 6861 6e67 6564 0a20 2020 2020 ry changed. \n-00039500: 2020 2020 2020 2070 6174 6820 3d20 6f73 path = os\n-00039510: 2e70 6174 682e 6a6f 696e 2873 656c 662e .path.join(self.\n-00039520: 5f70 6174 682c 206e 616d 652e 6465 636f _path, name.deco\n-00039530: 6465 2829 290a 2020 2020 2020 2020 2020 de()). \n-00039540: 2020 7461 6720 3d20 7461 675f 6672 6f6d tag = tag_from\n-00039550: 5f70 6174 6828 7061 7468 290a 2020 2020 _path(path). \n-00039560: 2020 2020 2020 2020 7365 6c66 2e73 656e self.sen\n-00039570: 645f 6a73 6f6e 2865 7665 6e74 3d65 7665 d_json(event=eve\n-00039580: 6e74 2c20 7061 7468 3d70 6174 682c 2074 nt, path=path, t\n-00039590: 6167 3d74 6167 2c20 7479 7065 3d74 7970 ag=tag, type=typ\n-000395a0: 655f 290a 2020 2020 2020 2020 656c 7365 e_). else\n-000395b0: 3a0a 2020 2020 2020 2020 2020 2020 2320 :. # \n-000395c0: 7468 6520 7761 7463 6865 6420 7061 7468 the watched path\n-000395d0: 2069 7473 656c 6620 6368 616e 6765 643b itself changed;\n-000395e0: 2066 696c 7465 7220 6f75 7420 6475 706c filter out dupl\n-000395f0: 6963 6174 6520 6576 656e 7473 0a20 2020 icate events. \n-00039600: 2020 2020 2020 2020 2074 6167 203d 2074 tag = t\n-00039610: 6167 5f66 726f 6d5f 7061 7468 2873 656c ag_from_path(sel\n-00039620: 662e 5f70 6174 6829 0a20 2020 2020 2020 f._path). \n-00039630: 2020 2020 2069 6620 7461 6720 3d3d 2073 if tag == s\n-00039640: 656c 662e 5f74 6167 3a0a 2020 2020 2020 elf._tag:. \n-00039650: 2020 2020 2020 2020 2020 7265 7475 726e return\n-00039660: 0a20 2020 2020 2020 2020 2020 2073 656c . sel\n-00039670: 662e 5f74 6167 203d 2074 6167 0a20 2020 f._tag = tag. \n-00039680: 2020 2020 2020 2020 2073 656c 662e 7365 self.se\n-00039690: 6e64 5f6a 736f 6e28 6576 656e 743d 6576 nd_json(event=ev\n-000396a0: 656e 742c 2070 6174 683d 7365 6c66 2e5f ent, path=self._\n-000396b0: 7061 7468 2c20 7461 673d 7365 6c66 2e5f path, tag=self._\n-000396c0: 7461 672c 2074 7970 653d 7479 7065 5f29 tag, type=type_)\n-000396d0: 0a0a 2020 2020 6465 6620 646f 5f69 6465 .. def do_ide\n-000396e0: 6e74 6974 795f 6368 616e 6765 6428 7365 ntity_changed(se\n-000396f0: 6c66 2c20 6664 2c20 6572 7229 3a0a 2020 lf, fd, err):. \n-00039700: 2020 2020 2020 6c6f 6767 6572 2e64 6562 logger.deb\n-00039710: 7567 2822 646f 5f69 6465 6e74 6974 795f ug(\"do_identity_\n-00039720: 6368 616e 6765 6428 2573 293a 2066 6420 changed(%s): fd \n-00039730: 2573 2c20 6572 7220 2573 222c 2073 656c %s, err %s\", sel\n-00039740: 662e 5f70 6174 682c 2073 7472 2866 6429 f._path, str(fd)\n-00039750: 2c20 6572 7229 0a20 2020 2020 2020 2073 , err). s\n-00039760: 656c 662e 5f74 6167 203d 2074 6167 5f66 elf._tag = tag_f\n-00039770: 726f 6d5f 6664 2866 6429 2069 6620 6664 rom_fd(fd) if fd\n-00039780: 2065 6c73 6520 272d 270a 2020 2020 2020 else '-'. \n-00039790: 2020 6966 2073 656c 662e 5f61 6374 6976 if self._activ\n-000397a0: 653a 0a20 2020 2020 2020 2020 2020 2073 e:. s\n-000397b0: 656c 662e 7365 6e64 5f6a 736f 6e28 6576 elf.send_json(ev\n-000397c0: 656e 743d 2763 7265 6174 6564 2720 6966 ent='created' if\n-000397d0: 2066 6420 656c 7365 2027 6465 6c65 7465 fd else 'delete\n-000397e0: 6427 2c20 7061 7468 3d73 656c 662e 5f70 d', path=self._p\n-000397f0: 6174 682c 2074 6167 3d73 656c 662e 5f74 ath, tag=self._t\n-00039800: 6167 290a 0a20 2020 2064 6566 2064 6f5f ag).. def do_\n-00039810: 6f70 656e 2873 656c 662c 206f 7074 696f open(self, optio\n-00039820: 6e73 293a 0a20 2020 2020 2020 2073 656c ns):. sel\n-00039830: 662e 5f70 6174 6820 3d20 6f70 7469 6f6e f._path = option\n-00039840: 735b 2770 6174 6827 5d0a 2020 2020 2020 s['path']. \n-00039850: 2020 7365 6c66 2e5f 7461 6720 3d20 4e6f self._tag = No\n-00039860: 6e65 0a0a 2020 2020 2020 2020 7365 6c66 ne.. self\n-00039870: 2e5f 6163 7469 7665 203d 2046 616c 7365 ._active = False\n-00039880: 0a20 2020 2020 2020 2073 656c 662e 5f77 . self._w\n-00039890: 6174 6368 203d 2050 6174 6857 6174 6368 atch = PathWatch\n-000398a0: 2873 656c 662e 5f70 6174 682c 2073 656c (self._path, sel\n-000398b0: 6629 0a20 2020 2020 2020 2073 656c 662e f). self.\n-000398c0: 5f61 6374 6976 6520 3d20 5472 7565 0a0a _active = True..\n-000398d0: 2020 2020 2020 2020 7365 6c66 2e72 6561 self.rea\n-000398e0: 6479 2829 0a0a 2020 2020 6465 6620 646f dy().. def do\n-000398f0: 5f63 6c6f 7365 2873 656c 6629 3a0a 2020 _close(self):. \n-00039900: 2020 2020 2020 7365 6c66 2e5f 7761 7463 self._watc\n-00039910: 682e 636c 6f73 6528 290a 2020 2020 2020 h.close(). \n-00039920: 2020 7365 6c66 2e5f 7761 7463 6820 3d20 self._watch = \n-00039930: 4e6f 6e65 0a20 2020 2020 2020 2073 656c None. sel\n-00039940: 662e 636c 6f73 6528 290a 0a0a 636c 6173 f.close()...clas\n-00039950: 7320 466f 6c6c 6f77 2865 6e75 6d2e 456e s Follow(enum.En\n-00039960: 756d 293a 0a20 2020 204e 4f20 3d20 4661 um):. NO = Fa\n-00039970: 6c73 650a 2020 2020 5945 5320 3d20 5472 lse. YES = Tr\n-00039980: 7565 0a0a 0a63 6c61 7373 2046 7349 6e66 ue...class FsInf\n-00039990: 6f43 6861 6e6e 656c 2843 6861 6e6e 656c oChannel(Channel\n-000399a0: 2c20 5061 7468 5761 7463 684c 6973 7465 , PathWatchListe\n-000399b0: 6e65 7229 3a0a 2020 2020 7061 796c 6f61 ner):. payloa\n-000399c0: 6420 3d20 2766 7369 6e66 6f27 0a0a 2020 d = 'fsinfo'.. \n-000399d0: 2020 2320 4f70 7469 6f6e 7320 2861 6c6c # Options (all\n-000399e0: 2067 6574 2073 6574 2069 6e20 6064 6f5f get set in `do_\n-000399f0: 6f70 656e 2829 6029 0a20 2020 2070 6174 open()`). pat\n-00039a00: 683a 2073 7472 0a20 2020 2061 7474 7273 h: str. attrs\n-00039a10: 3a20 2773 6574 5b73 7472 5d27 0a20 2020 : 'set[str]'. \n-00039a20: 2066 6e6d 6174 6368 3a20 7374 720a 2020 fnmatch: str. \n-00039a30: 2020 7461 7267 6574 733a 2062 6f6f 6c0a targets: bool.\n-00039a40: 2020 2020 666f 6c6c 6f77 3a20 626f 6f6c follow: bool\n-00039a50: 0a20 2020 2077 6174 6368 3a20 626f 6f6c . watch: bool\n-00039a60: 0a0a 2020 2020 2320 5374 6174 650a 2020 .. # State. \n-00039a70: 2020 6375 7272 656e 745f 7661 6c75 653a current_value:\n-00039a80: 204a 736f 6e44 6963 740a 2020 2020 6566 JsonDict. ef\n-00039a90: 6665 6374 6976 655f 666e 6d61 7463 683a fective_fnmatch:\n-00039aa0: 2073 7472 203d 2027 270a 2020 2020 6664 str = ''. fd\n-00039ab0: 3a20 2748 616e 646c 6520 7c20 4e6f 6e65 : 'Handle | None\n-00039ac0: 2720 3d20 4e6f 6e65 0a20 2020 2070 656e ' = None. pen\n-00039ad0: 6469 6e67 3a20 2773 6574 5b73 7472 5d20 ding: 'set[str] \n-00039ae0: 7c20 4e6f 6e65 2720 3d20 4e6f 6e65 0a20 | None' = None. \n-00039af0: 2020 2070 6174 685f 7761 7463 683a 2027 path_watch: '\n-00039b00: 5061 7468 5761 7463 6820 7c20 4e6f 6e65 PathWatch | None\n-00039b10: 2720 3d20 4e6f 6e65 0a20 2020 2067 6574 ' = None. get\n-00039b20: 6174 7472 733a 2027 4361 6c6c 6162 6c65 attrs: 'Callable\n-00039b30: 5b5b 696e 742c 2073 7472 2c20 466f 6c6c [[int, str, Foll\n-00039b40: 6f77 5d2c 204a 736f 6e44 6f63 756d 656e ow], JsonDocumen\n-00039b50: 745d 270a 0a20 2020 2040 7374 6174 6963 t]'.. @static\n-00039b60: 6d65 7468 6f64 0a20 2020 2064 6566 206d method. def m\n-00039b70: 616b 655f 6765 7461 7474 7273 2861 7474 ake_getattrs(att\n-00039b80: 7273 3a20 4974 6572 6162 6c65 5b73 7472 rs: Iterable[str\n-00039b90: 5d29 202d 3e20 2743 616c 6c61 626c 655b ]) -> 'Callable[\n-00039ba0: 5b69 6e74 2c20 7374 722c 2046 6f6c 6c6f [int, str, Follo\n-00039bb0: 775d 2c20 4a73 6f6e 446f 6375 6d65 6e74 w], JsonDocument\n-00039bc0: 207c 204e 6f6e 655d 273a 0a20 2020 2020 | None]':. \n-00039bd0: 2020 2023 2043 6163 6865 6420 666f 7220 # Cached for \n-00039be0: 7468 6520 6475 7261 7469 6f6e 206f 6620 the duration of \n-00039bf0: 7468 6520 636c 6f73 7572 6520 7765 2772 the closure we'r\n-00039c00: 6520 6372 6561 7469 6e67 0a20 2020 2020 e creating. \n-00039c10: 2020 2040 6675 6e63 746f 6f6c 732e 6c72 @functools.lr\n-00039c20: 755f 6361 6368 6528 290a 2020 2020 2020 u_cache(). \n-00039c30: 2020 6465 6620 6765 745f 7573 6572 2875 def get_user(u\n-00039c40: 6964 3a20 696e 7429 202d 3e20 2773 7472 id: int) -> 'str\n-00039c50: 207c 2069 6e74 273a 0a20 2020 2020 2020 | int':. \n-00039c60: 2020 2020 2074 7279 3a0a 2020 2020 2020 try:. \n-00039c70: 2020 2020 2020 2020 2020 7265 7475 726e return\n-00039c80: 2070 7764 2e67 6574 7077 7569 6428 7569 pwd.getpwuid(ui\n-00039c90: 6429 2e70 775f 6e61 6d65 0a20 2020 2020 d).pw_name. \n-00039ca0: 2020 2020 2020 2065 7863 6570 7420 4b65 except Ke\n-00039cb0: 7945 7272 6f72 3a0a 2020 2020 2020 2020 yError:. \n-00039cc0: 2020 2020 2020 2020 7265 7475 726e 2075 return u\n-00039cd0: 6964 0a0a 2020 2020 2020 2020 4066 756e id.. @fun\n-00039ce0: 6374 6f6f 6c73 2e6c 7275 5f63 6163 6865 ctools.lru_cache\n-00039cf0: 2829 0a20 2020 2020 2020 2064 6566 2067 (). def g\n-00039d00: 6574 5f67 726f 7570 2867 6964 3a20 696e et_group(gid: in\n-00039d10: 7429 202d 3e20 2773 7472 207c 2069 6e74 t) -> 'str | int\n-00039d20: 273a 0a20 2020 2020 2020 2020 2020 2074 ':. t\n-00039d30: 7279 3a0a 2020 2020 2020 2020 2020 2020 ry:. \n-00039d40: 2020 2020 7265 7475 726e 2067 7270 2e67 return grp.g\n-00039d50: 6574 6772 6769 6428 6769 6429 2e67 725f etgrgid(gid).gr_\n-00039d60: 6e61 6d65 0a20 2020 2020 2020 2020 2020 name. \n-00039d70: 2065 7863 6570 7420 4b65 7945 7272 6f72 except KeyError\n-00039d80: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n-00039d90: 2020 7265 7475 726e 2067 6964 0a0a 2020 return gid.. \n-00039da0: 2020 2020 2020 7374 6174 5f74 7970 6573 stat_types\n-00039db0: 203d 207b 7374 6174 2e53 5f49 4652 4547 = {stat.S_IFREG\n-00039dc0: 3a20 2772 6567 272c 2073 7461 742e 535f : 'reg', stat.S_\n-00039dd0: 4946 4449 523a 2027 6469 7227 2c20 7374 IFDIR: 'dir', st\n-00039de0: 6174 2e53 5f49 464c 4e4b 3a20 276c 6e6b at.S_IFLNK: 'lnk\n-00039df0: 272c 2073 7461 742e 535f 4946 4348 523a ', stat.S_IFCHR:\n-00039e00: 2027 6368 7227 2c0a 2020 2020 2020 2020 'chr',. \n-00039e10: 2020 2020 2020 2020 2020 2020 2020 7374 st\n-00039e20: 6174 2e53 5f49 4642 4c4b 3a20 2762 6c6b at.S_IFBLK: 'blk\n-00039e30: 272c 2073 7461 742e 535f 4946 4946 4f3a ', stat.S_IFIFO:\n-00039e40: 2027 6669 666f 272c 2073 7461 742e 535f 'fifo', stat.S_\n-00039e50: 4946 534f 434b 3a20 2773 6f63 6b27 7d0a IFSOCK: 'sock'}.\n-00039e60: 2020 2020 2020 2020 6176 6169 6c61 626c availabl\n-00039e70: 655f 7374 6174 5f67 6574 7465 7273 203d e_stat_getters =\n-00039e80: 207b 0a20 2020 2020 2020 2020 2020 2027 {. '\n-00039e90: 7479 7065 273a 206c 616d 6264 6120 6275 type': lambda bu\n-00039ea0: 663a 2073 7461 745f 7479 7065 732e 6765 f: stat_types.ge\n-00039eb0: 7428 7374 6174 2e53 5f49 464d 5428 6275 t(stat.S_IFMT(bu\n-00039ec0: 662e 7374 5f6d 6f64 6529 292c 0a20 2020 f.st_mode)),. \n-00039ed0: 2020 2020 2020 2020 2027 7461 6727 3a20 'tag': \n-00039ee0: 7461 675f 6672 6f6d 5f73 7461 742c 0a20 tag_from_stat,. \n-00039ef0: 2020 2020 2020 2020 2020 2027 6d6f 6465 'mode\n-00039f00: 273a 206c 616d 6264 6120 6275 663a 2073 ': lambda buf: s\n-00039f10: 7461 742e 535f 494d 4f44 4528 6275 662e tat.S_IMODE(buf.\n-00039f20: 7374 5f6d 6f64 6529 2c0a 2020 2020 2020 st_mode),. \n-00039f30: 2020 2020 2020 2773 697a 6527 3a20 6c61 'size': la\n-00039f40: 6d62 6461 2062 7566 3a20 6275 662e 7374 mbda buf: buf.st\n-00039f50: 5f73 697a 652c 0a20 2020 2020 2020 2020 _size,. \n-00039f60: 2020 2027 7569 6427 3a20 6c61 6d62 6461 'uid': lambda\n-00039f70: 2062 7566 3a20 6275 662e 7374 5f75 6964 buf: buf.st_uid\n-00039f80: 2c0a 2020 2020 2020 2020 2020 2020 2767 ,. 'g\n-00039f90: 6964 273a 206c 616d 6264 6120 6275 663a id': lambda buf:\n-00039fa0: 2062 7566 2e73 745f 6769 642c 0a20 2020 buf.st_gid,. \n-00039fb0: 2020 2020 2020 2020 2027 6d74 696d 6527 'mtime'\n-00039fc0: 3a20 6c61 6d62 6461 2062 7566 3a20 6275 : lambda buf: bu\n-00039fd0: 662e 7374 5f6d 7469 6d65 2c0a 2020 2020 f.st_mtime,. \n-00039fe0: 2020 2020 2020 2020 2775 7365 7227 3a20 'user': \n-00039ff0: 6c61 6d62 6461 2062 7566 3a20 6765 745f lambda buf: get_\n-0003a000: 7573 6572 2862 7566 2e73 745f 7569 6429 user(buf.st_uid)\n-0003a010: 2c0a 2020 2020 2020 2020 2020 2020 2767 ,. 'g\n-0003a020: 726f 7570 273a 206c 616d 6264 6120 6275 roup': lambda bu\n-0003a030: 663a 2067 6574 5f67 726f 7570 2862 7566 f: get_group(buf\n-0003a040: 2e73 745f 6769 6429 2c0a 2020 2020 2020 .st_gid),. \n-0003a050: 2020 7d0a 2020 2020 2020 2020 7374 6174 }. stat\n-0003a060: 5f67 6574 7465 7273 203d 2074 7570 6c65 _getters = tuple\n-0003a070: 2828 6b65 792c 2061 7661 696c 6162 6c65 ((key, available\n-0003a080: 5f73 7461 745f 6765 7474 6572 732e 6765 _stat_getters.ge\n-0003a090: 7428 6b65 792c 206c 616d 6264 6120 5f3a t(key, lambda _:\n-0003a0a0: 204e 6f6e 6529 2920 666f 7220 6b65 7920 None)) for key \n-0003a0b0: 696e 2061 7474 7273 290a 0a20 2020 2020 in attrs).. \n-0003a0c0: 2020 2064 6566 2067 6574 5f61 7474 7273 def get_attrs\n-0003a0d0: 2866 643a 2069 6e74 2c20 6e61 6d65 3a20 (fd: int, name: \n-0003a0e0: 7374 722c 2066 6f6c 6c6f 773a 2046 6f6c str, follow: Fol\n-0003a0f0: 6c6f 7729 202d 3e20 274a 736f 6e44 6963 low) -> 'JsonDic\n-0003a100: 7420 7c20 4e6f 6e65 273a 0a20 2020 2020 t | None':. \n-0003a110: 2020 2020 2020 2074 7279 3a0a 2020 2020 try:. \n-0003a120: 2020 2020 2020 2020 2020 2020 6275 6620 buf \n-0003a130: 3d20 6f73 2e73 7461 7428 6e61 6d65 2c20 = os.stat(name, \n-0003a140: 666f 6c6c 6f77 5f73 796d 6c69 6e6b 733d follow_symlinks=\n-0003a150: 666f 6c6c 6f77 2e76 616c 7565 2c20 6469 follow.value, di\n-0003a160: 725f 6664 3d66 6429 2069 6620 6e61 6d65 r_fd=fd) if name\n-0003a170: 2065 6c73 6520 6f73 2e66 7374 6174 2866 else os.fstat(f\n-0003a180: 6429 0a20 2020 2020 2020 2020 2020 2065 d). e\n-0003a190: 7863 6570 7420 4669 6c65 4e6f 7446 6f75 xcept FileNotFou\n-0003a1a0: 6e64 4572 726f 723a 0a20 2020 2020 2020 ndError:. \n-0003a1b0: 2020 2020 2020 2020 2072 6574 7572 6e20 return \n-0003a1c0: 4e6f 6e65 0a20 2020 2020 2020 2020 2020 None. \n-0003a1d0: 2065 7863 6570 7420 4f53 4572 726f 723a except OSError:\n-0003a1e0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-0003a1f0: 2072 6574 7572 6e20 7b6e 616d 653a 204e return {name: N\n-0003a200: 6f6e 6520 666f 7220 6e61 6d65 2c20 6675 one for name, fu\n-0003a210: 6e63 2069 6e20 7374 6174 5f67 6574 7465 nc in stat_gette\n-0003a220: 7273 7d0a 0a20 2020 2020 2020 2020 2020 rs}.. \n-0003a230: 2072 6573 756c 7420 3d20 7b6b 6579 3a20 result = {key: \n-0003a240: 6675 6e63 2862 7566 2920 666f 7220 6b65 func(buf) for ke\n-0003a250: 792c 2066 756e 6320 696e 2073 7461 745f y, func in stat_\n-0003a260: 6765 7474 6572 737d 0a0a 2020 2020 2020 getters}.. \n-0003a270: 2020 2020 2020 6966 2027 7461 7267 6574 if 'target\n-0003a280: 2720 696e 2072 6573 756c 7420 616e 6420 ' in result and \n-0003a290: 7374 6174 2e53 5f49 464d 5428 6275 662e stat.S_IFMT(buf.\n-0003a2a0: 7374 5f6d 6f64 6529 203d 3d20 7374 6174 st_mode) == stat\n-0003a2b0: 2e53 5f49 464c 4e4b 3a0a 2020 2020 2020 .S_IFLNK:. \n-0003a2c0: 2020 2020 2020 2020 2020 7769 7468 2063 with c\n-0003a2d0: 6f6e 7465 7874 6c69 622e 7375 7070 7265 ontextlib.suppre\n-0003a2e0: 7373 284f 5345 7272 6f72 293a 0a20 2020 ss(OSError):. \n-0003a2f0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0003a300: 2072 6573 756c 745b 2774 6172 6765 7427 result['target'\n-0003a310: 5d20 3d20 6f73 2e72 6561 646c 696e 6b28 ] = os.readlink(\n-0003a320: 6e61 6d65 2c20 6469 725f 6664 3d66 6429 name, dir_fd=fd)\n-0003a330: 0a0a 2020 2020 2020 2020 2020 2020 7265 .. re\n-0003a340: 7475 726e 2072 6573 756c 740a 0a20 2020 turn result.. \n-0003a350: 2020 2020 2072 6574 7572 6e20 6765 745f return get_\n-0003a360: 6174 7472 730a 0a20 2020 2064 6566 2073 attrs.. def s\n-0003a370: 656e 645f 7570 6461 7465 2873 656c 662c end_update(self,\n-0003a380: 2075 7064 6174 6573 3a20 4a73 6f6e 4469 updates: JsonDi\n-0003a390: 6374 2c20 2a2c 2072 6573 6574 3a20 626f ct, *, reset: bo\n-0003a3a0: 6f6c 203d 2046 616c 7365 2920 2d3e 204e ol = False) -> N\n-0003a3b0: 6f6e 653a 0a20 2020 2020 2020 2069 6620 one:. if \n-0003a3c0: 7265 7365 743a 0a20 2020 2020 2020 2020 reset:. \n-0003a3d0: 2020 2069 6620 7365 7428 7365 6c66 2e63 if set(self.c\n-0003a3e0: 7572 7265 6e74 5f76 616c 7565 2920 2620 urrent_value) & \n-0003a3f0: 7365 7428 7570 6461 7465 7329 3a0a 2020 set(updates):. \n-0003a400: 2020 2020 2020 2020 2020 2020 2020 2320 # \n-0003a410: 6966 2077 6520 6861 7665 2061 6e20 6f76 if we have an ov\n-0003a420: 6572 6c61 702c 2077 6520 6e65 6564 2074 erlap, we need t\n-0003a430: 6f20 646f 2061 2070 726f 7065 7220 7265 o do a proper re\n-0003a440: 7365 740a 2020 2020 2020 2020 2020 2020 set. \n-0003a450: 2020 2020 7365 6c66 2e73 656e 645f 6a73 self.send_js\n-0003a460: 6f6e 2864 6963 742e 6672 6f6d 6b65 7973 on(dict.fromkeys\n-0003a470: 2873 656c 662e 6375 7272 656e 745f 7661 (self.current_va\n-0003a480: 6c75 6529 2c20 7061 7274 6961 6c3d 5472 lue), partial=Tr\n-0003a490: 7565 290a 2020 2020 2020 2020 2020 2020 ue). \n-0003a4a0: 2020 2020 7365 6c66 2e63 7572 7265 6e74 self.current\n-0003a4b0: 5f76 616c 7565 203d 207b 2770 6172 7469 _value = {'parti\n-0003a4c0: 616c 273a 2054 7275 657d 0a20 2020 2020 al': True}. \n-0003a4d0: 2020 2020 2020 2020 2020 2075 7064 6174 updat\n-0003a4e0: 6573 2e75 7064 6174 6528 7061 7274 6961 es.update(partia\n-0003a4f0: 6c3d 4e6f 6e65 290a 2020 2020 2020 2020 l=None). \n-0003a500: 2020 2020 656c 7365 3a0a 2020 2020 2020 else:. \n-0003a510: 2020 2020 2020 2020 2020 2320 6f74 6865 # othe\n-0003a520: 7277 6973 6520 7468 6572 6527 7320 6e6f rwise there's no\n-0003a530: 206f 7665 726c 6170 3a20 7765 2063 616e overlap: we can\n-0003a540: 206a 7573 7420 7265 6d6f 7665 2074 6865 just remove the\n-0003a550: 206f 6c64 206b 6579 730a 2020 2020 2020 old keys. \n-0003a560: 2020 2020 2020 2020 2020 7570 6461 7465 update\n-0003a570: 732e 7570 6461 7465 2864 6963 742e 6672 s.update(dict.fr\n-0003a580: 6f6d 6b65 7973 2873 656c 662e 6375 7272 omkeys(self.curr\n-0003a590: 656e 745f 7661 6c75 6529 290a 0a20 2020 ent_value)).. \n-0003a5a0: 2020 2020 206a 736f 6e5f 6d65 7267 655f json_merge_\n-0003a5b0: 616e 645f 6669 6c74 6572 5f70 6174 6368 and_filter_patch\n-0003a5c0: 2873 656c 662e 6375 7272 656e 745f 7661 (self.current_va\n-0003a5d0: 6c75 652c 2075 7064 6174 6573 290a 2020 lue, updates). \n-0003a5e0: 2020 2020 2020 6966 2075 7064 6174 6573 if updates\n-0003a5f0: 3a0a 2020 2020 2020 2020 2020 2020 7365 :. se\n-0003a600: 6c66 2e73 656e 645f 6a73 6f6e 2875 7064 lf.send_json(upd\n-0003a610: 6174 6573 290a 0a20 2020 2064 6566 2070 ates).. def p\n-0003a620: 726f 6365 7373 5f75 7064 6174 6528 7365 rocess_update(se\n-0003a630: 6c66 2c20 7570 6461 7465 733a 2027 7365 lf, updates: 'se\n-0003a640: 745b 7374 725d 272c 202a 2c20 7265 7365 t[str]', *, rese\n-0003a650: 743a 2062 6f6f 6c20 3d20 4661 6c73 6529 t: bool = False)\n-0003a660: 202d 3e20 4e6f 6e65 3a0a 2020 2020 2020 -> None:. \n-0003a670: 2020 6173 7365 7274 2073 656c 662e 6664 assert self.fd\n-0003a680: 2069 7320 6e6f 7420 4e6f 6e65 0a0a 2020 is not None.. \n-0003a690: 2020 2020 2020 656e 7472 6965 733a 204a entries: J\n-0003a6a0: 736f 6e44 6963 7420 3d20 7b6e 616d 653a sonDict = {name:\n-0003a6b0: 2073 656c 662e 6765 7461 7474 7273 2873 self.getattrs(s\n-0003a6c0: 656c 662e 6664 2c20 6e61 6d65 2c20 466f elf.fd, name, Fo\n-0003a6d0: 6c6c 6f77 2e4e 4f29 2066 6f72 206e 616d llow.NO) for nam\n-0003a6e0: 6520 696e 2075 7064 6174 6573 7d0a 0a20 e in updates}.. \n-0003a6f0: 2020 2020 2020 2069 6e66 6f20 3d20 656e info = en\n-0003a700: 7472 6965 732e 706f 7028 2727 2c20 7b7d tries.pop('', {}\n-0003a710: 290a 2020 2020 2020 2020 6173 7365 7274 ). assert\n-0003a720: 2069 7369 6e73 7461 6e63 6528 696e 666f isinstance(info\n-0003a730: 2c20 6469 6374 2920 2023 2066 7374 6174 , dict) # fstat\n-0003a740: 2829 2077 696c 6c20 6e65 7665 7220 6661 () will never fa\n-0003a750: 696c 2077 6974 6820 4669 6c65 4e6f 7446 il with FileNotF\n-0003a760: 6f75 6e64 4572 726f 720a 0a20 2020 2020 oundError.. \n-0003a770: 2020 2069 6620 7365 6c66 2e65 6666 6563 if self.effec\n-0003a780: 7469 7665 5f66 6e6d 6174 6368 3a0a 2020 tive_fnmatch:. \n-0003a790: 2020 2020 2020 2020 2020 696e 666f 5b27 info['\n-0003a7a0: 656e 7472 6965 7327 5d20 3d20 656e 7472 entries'] = entr\n-0003a7b0: 6965 730a 0a20 2020 2020 2020 2069 6620 ies.. if \n-0003a7c0: 7365 6c66 2e74 6172 6765 7473 3a0a 2020 self.targets:. \n-0003a7d0: 2020 2020 2020 2020 2020 696e 666f 5b27 info['\n-0003a7e0: 7461 7267 6574 7327 5d20 3d20 7461 7267 targets'] = targ\n-0003a7f0: 6574 7320 3d20 7b7d 0a20 2020 2020 2020 ets = {}. \n-0003a800: 2020 2020 2066 6f72 206e 616d 6520 696e for name in\n-0003a810: 207b 652e 6765 7428 2774 6172 6765 7427 {e.get('target'\n-0003a820: 2920 666f 7220 6520 696e 2065 6e74 7269 ) for e in entri\n-0003a830: 6573 2e76 616c 7565 7328 2920 6966 2069 es.values() if i\n-0003a840: 7369 6e73 7461 6e63 6528 652c 2064 6963 sinstance(e, dic\n-0003a850: 7429 7d3a 0a20 2020 2020 2020 2020 2020 t)}:. \n-0003a860: 2020 2020 2069 6620 6973 696e 7374 616e if isinstan\n-0003a870: 6365 286e 616d 652c 2073 7472 2920 616e ce(name, str) an\n-0003a880: 6420 2827 2f27 2069 6e20 6e61 6d65 206f d ('/' in name o\n-0003a890: 7220 6e6f 7420 7365 6c66 2e69 6e74 6572 r not self.inter\n-0003a8a0: 6573 7469 6e67 286e 616d 6529 293a 0a20 esting(name)):. \n-0003a8b0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0003a8c0: 2020 2023 2069 6620 7468 6973 2074 6172 # if this tar\n-0003a8d0: 6765 7420 6973 2061 2073 7472 696e 6720 get is a string \n-0003a8e0: 7468 6174 2077 6520 776f 756c 646e 2774 that we wouldn't\n-0003a8f0: 206f 7468 6572 7769 7365 0a20 2020 2020 otherwise. \n-0003a900: 2020 2020 2020 2020 2020 2020 2020 2023 #\n-0003a910: 2072 6570 6f72 742c 2074 6865 6e20 7265 report, then re\n-0003a920: 706f 7274 2069 7420 7669 6120 6f75 7220 port it via our \n-0003a930: 2274 6172 6765 7473 2220 6174 7472 6962 \"targets\" attrib\n-0003a940: 7574 652e 0a20 2020 2020 2020 2020 2020 ute.. \n-0003a950: 2020 2020 2020 2020 2074 6172 6765 7473 targets\n-0003a960: 5b6e 616d 655d 203d 2073 656c 662e 6765 [name] = self.ge\n-0003a970: 7461 7474 7273 2873 656c 662e 6664 2c20 tattrs(self.fd, \n-0003a980: 6e61 6d65 2c20 466f 6c6c 6f77 2e59 4553 name, Follow.YES\n-0003a990: 290a 0a20 2020 2020 2020 2073 656c 662e ).. self.\n-0003a9a0: 7365 6e64 5f75 7064 6174 6528 7b27 696e send_update({'in\n-0003a9b0: 666f 273a 2069 6e66 6f7d 2c20 7265 7365 fo': info}, rese\n-0003a9c0: 743d 7265 7365 7429 0a0a 2020 2020 6465 t=reset).. de\n-0003a9d0: 6620 7072 6f63 6573 735f 7065 6e64 696e f process_pendin\n-0003a9e0: 675f 7570 6461 7465 7328 7365 6c66 2920 g_updates(self) \n-0003a9f0: 2d3e 204e 6f6e 653a 0a20 2020 2020 2020 -> None:. \n-0003aa00: 2061 7373 6572 7420 7365 6c66 2e70 656e assert self.pen\n-0003aa10: 6469 6e67 2069 7320 6e6f 7420 4e6f 6e65 ding is not None\n-0003aa20: 0a20 2020 2020 2020 2069 6620 7365 6c66 . if self\n-0003aa30: 2e70 656e 6469 6e67 3a0a 2020 2020 2020 .pending:. \n-0003aa40: 2020 2020 2020 7365 6c66 2e70 726f 6365 self.proce\n-0003aa50: 7373 5f75 7064 6174 6528 7365 6c66 2e70 ss_update(self.p\n-0003aa60: 656e 6469 6e67 290a 2020 2020 2020 2020 ending). \n-0003aa70: 7365 6c66 2e70 656e 6469 6e67 203d 204e self.pending = N\n-0003aa80: 6f6e 650a 0a20 2020 2064 6566 2069 6e74 one.. def int\n-0003aa90: 6572 6573 7469 6e67 2873 656c 662c 206e eresting(self, n\n-0003aaa0: 616d 653a 2073 7472 2920 2d3e 2062 6f6f ame: str) -> boo\n-0003aab0: 6c3a 0a20 2020 2020 2020 2069 6620 6e61 l:. if na\n-0003aac0: 6d65 203d 3d20 2727 3a0a 2020 2020 2020 me == '':. \n-0003aad0: 2020 2020 2020 7265 7475 726e 2054 7275 return Tru\n-0003aae0: 650a 2020 2020 2020 2020 656c 7365 3a0a e. else:.\n-0003aaf0: 2020 2020 2020 2020 2020 2020 2320 6f6e # on\n-0003ab00: 6c79 2072 6570 6f72 7420 7570 6461 7465 ly report update\n-0003ab10: 7320 6f6e 2065 6e74 7279 2066 696c 656e s on entry filen\n-0003ab20: 616d 6573 2069 6620 7765 206d 6174 6368 ames if we match\n-0003ab30: 2074 6865 6d0a 2020 2020 2020 2020 2020 them. \n-0003ab40: 2020 7265 7475 726e 2066 6e6d 6174 6368 return fnmatch\n-0003ab50: 2e66 6e6d 6174 6368 286e 616d 652c 2073 .fnmatch(name, s\n-0003ab60: 656c 662e 6566 6665 6374 6976 655f 666e elf.effective_fn\n-0003ab70: 6d61 7463 6829 0a0a 2020 2020 6465 6620 match).. def \n-0003ab80: 7363 6865 6475 6c65 5f75 7064 6174 6528 schedule_update(\n-0003ab90: 7365 6c66 2c20 6e61 6d65 3a20 7374 7229 self, name: str)\n-0003aba0: 202d 3e20 4e6f 6e65 3a0a 2020 2020 2020 -> None:. \n-0003abb0: 2020 6966 206e 6f74 2073 656c 662e 696e if not self.in\n-0003abc0: 7465 7265 7374 696e 6728 6e61 6d65 293a teresting(name):\n-0003abd0: 0a20 2020 2020 2020 2020 2020 2072 6574 . ret\n-0003abe0: 7572 6e0a 0a20 2020 2020 2020 2069 6620 urn.. if \n-0003abf0: 7365 6c66 2e70 656e 6469 6e67 2069 7320 self.pending is \n-0003ac00: 4e6f 6e65 3a0a 2020 2020 2020 2020 2020 None:. \n-0003ac10: 2020 6173 796e 6369 6f2e 6765 745f 7275 asyncio.get_ru\n-0003ac20: 6e6e 696e 675f 6c6f 6f70 2829 2e63 616c nning_loop().cal\n-0003ac30: 6c5f 6c61 7465 7228 302e 312c 2073 656c l_later(0.1, sel\n-0003ac40: 662e 7072 6f63 6573 735f 7065 6e64 696e f.process_pendin\n-0003ac50: 675f 7570 6461 7465 7329 0a20 2020 2020 g_updates). \n-0003ac60: 2020 2020 2020 2073 656c 662e 7065 6e64 self.pend\n-0003ac70: 696e 6720 3d20 7365 7428 290a 0a20 2020 ing = set().. \n-0003ac80: 2020 2020 2073 656c 662e 7065 6e64 696e self.pendin\n-0003ac90: 672e 6164 6428 6e61 6d65 290a 0a20 2020 g.add(name).. \n-0003aca0: 2064 6566 2072 6570 6f72 745f 6572 726f def report_erro\n-0003acb0: 7228 7365 6c66 2c20 6572 723a 2069 6e74 r(self, err: int\n-0003acc0: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n-0003acd0: 2020 2069 6620 6572 7220 3d3d 2065 7272 if err == err\n-0003ace0: 6e6f 2e45 4e4f 454e 543a 0a20 2020 2020 no.ENOENT:. \n-0003acf0: 2020 2020 2020 2070 726f 626c 656d 203d problem =\n-0003ad00: 2027 6e6f 742d 666f 756e 6427 0a20 2020 'not-found'. \n-0003ad10: 2020 2020 2065 6c69 6620 6572 7220 696e elif err in\n-0003ad20: 2028 6572 726e 6f2e 4550 4552 4d2c 2065 (errno.EPERM, e\n-0003ad30: 7272 6e6f 2e45 4143 4345 5329 3a0a 2020 rrno.EACCES):. \n-0003ad40: 2020 2020 2020 2020 2020 7072 6f62 6c65 proble\n-0003ad50: 6d20 3d20 2761 6363 6573 732d 6465 6e69 m = 'access-deni\n-0003ad60: 6564 270a 2020 2020 2020 2020 656c 6966 ed'. elif\n-0003ad70: 2065 7272 203d 3d20 6572 726e 6f2e 454e err == errno.EN\n-0003ad80: 4f54 4449 523a 0a20 2020 2020 2020 2020 OTDIR:. \n-0003ad90: 2020 2070 726f 626c 656d 203d 2027 6e6f problem = 'no\n-0003ada0: 742d 6469 7265 6374 6f72 7927 0a20 2020 t-directory'. \n-0003adb0: 2020 2020 2065 6c73 653a 0a20 2020 2020 else:. \n-0003adc0: 2020 2020 2020 2070 726f 626c 656d 203d problem =\n-0003add0: 2027 696e 7465 726e 616c 2d65 7272 6f72 'internal-error\n-0003ade0: 270a 0a20 2020 2020 2020 2073 656c 662e '.. self.\n-0003adf0: 7365 6e64 5f75 7064 6174 6528 7b27 6572 send_update({'er\n-0003ae00: 726f 7227 3a20 7b0a 2020 2020 2020 2020 ror': {. \n-0003ae10: 2020 2020 2770 726f 626c 656d 273a 2070 'problem': p\n-0003ae20: 726f 626c 656d 2c20 276d 6573 7361 6765 roblem, 'message\n-0003ae30: 273a 206f 732e 7374 7265 7272 6f72 2865 ': os.strerror(e\n-0003ae40: 7272 292c 2027 6572 726e 6f27 3a20 6572 rr), 'errno': er\n-0003ae50: 726e 6f2e 6572 726f 7263 6f64 655b 6572 rno.errorcode[er\n-0003ae60: 725d 0a20 2020 2020 2020 207d 7d2c 2072 r]. }}, r\n-0003ae70: 6573 6574 3d54 7275 6529 0a0a 2020 2020 eset=True).. \n-0003ae80: 6465 6620 666c 6167 5f6f 6e6c 7964 6972 def flag_onlydir\n-0003ae90: 5f65 7272 6f72 2873 656c 662c 2066 643a _error(self, fd:\n-0003aea0: 2048 616e 646c 6529 202d 3e20 626f 6f6c Handle) -> bool\n-0003aeb0: 3a0a 2020 2020 2020 2020 2320 4966 206f :. # If o\n-0003aec0: 7572 2072 6571 7565 7374 6564 2070 6174 ur requested pat\n-0003aed0: 6820 656e 6465 6420 7769 7468 2027 2f27 h ended with '/'\n-0003aee0: 2074 6865 6e20 6d61 6b65 2073 7572 6520 then make sure \n-0003aef0: 7765 2067 6f74 2061 0a20 2020 2020 2020 we got a. \n-0003af00: 2023 2064 6972 6563 746f 7279 2c20 6f72 # directory, or\n-0003af10: 2065 6c73 6520 6974 2773 2061 6e20 6572 else it's an er\n-0003af20: 726f 722e 2020 6f70 656e 2829 2077 696c ror. open() wil\n-0003af30: 6c20 6861 7665 2061 6c72 6561 6479 2066 l have already f\n-0003af40: 6c61 6767 6564 0a20 2020 2020 2020 2023 lagged. #\n-0003af50: 2074 6861 7420 666f 7220 7573 2c20 6275 that for us, bu\n-0003af60: 7420 7379 7374 656d 645f 6374 7970 6573 t systemd_ctypes\n-0003af70: 2064 6f65 736e 2774 2064 6f20 7468 6174 doesn't do that\n-0003af80: 2028 7965 7429 2e0a 2020 2020 2020 2020 (yet).. \n-0003af90: 6966 206e 6f74 2073 656c 662e 7761 7463 if not self.watc\n-0003afa0: 6820 6f72 206e 6f74 2073 656c 662e 7061 h or not self.pa\n-0003afb0: 7468 2e65 6e64 7377 6974 6828 272f 2729 th.endswith('/')\n-0003afc0: 3a0a 2020 2020 2020 2020 2020 2020 7265 :. re\n-0003afd0: 7475 726e 2046 616c 7365 0a0a 2020 2020 turn False.. \n-0003afe0: 2020 2020 6275 6620 3d20 6f73 2e66 7374 buf = os.fst\n-0003aff0: 6174 2866 6429 2020 2320 7468 6973 2073 at(fd) # this s\n-0003b000: 686f 756c 6420 6e65 7665 7220 6661 696c hould never fail\n-0003b010: 0a20 2020 2020 2020 2069 6620 7374 6174 . if stat\n-0003b020: 2e53 5f49 464d 5428 6275 662e 7374 5f6d .S_IFMT(buf.st_m\n-0003b030: 6f64 6529 2021 3d20 7374 6174 2e53 5f49 ode) != stat.S_I\n-0003b040: 4644 4952 3a0a 2020 2020 2020 2020 2020 FDIR:. \n-0003b050: 2020 7365 6c66 2e72 6570 6f72 745f 6572 self.report_er\n-0003b060: 726f 7228 6572 726e 6f2e 454e 4f54 4449 ror(errno.ENOTDI\n-0003b070: 5229 0a20 2020 2020 2020 2020 2020 2072 R). r\n-0003b080: 6574 7572 6e20 5472 7565 0a0a 2020 2020 eturn True.. \n-0003b090: 2020 2020 7265 7475 726e 2046 616c 7365 return False\n-0003b0a0: 0a0a 2020 2020 6465 6620 7265 706f 7274 .. def report\n-0003b0b0: 5f69 6e69 7469 616c 5f73 7461 7465 2873 _initial_state(s\n-0003b0c0: 656c 662c 2066 643a 2048 616e 646c 6529 elf, fd: Handle)\n-0003b0d0: 202d 3e20 4e6f 6e65 3a0a 2020 2020 2020 -> None:. \n-0003b0e0: 2020 6966 2073 656c 662e 666c 6167 5f6f if self.flag_o\n-0003b0f0: 6e6c 7964 6972 5f65 7272 6f72 2866 6429 nlydir_error(fd)\n-0003b100: 3a0a 2020 2020 2020 2020 2020 2020 7265 :. re\n-0003b110: 7475 726e 0a0a 2020 2020 2020 2020 7365 turn.. se\n-0003b120: 6c66 2e66 6420 3d20 6664 0a0a 2020 2020 lf.fd = fd.. \n-0003b130: 2020 2020 656e 7472 6965 7320 3d20 7b27 entries = {'\n-0003b140: 277d 0a20 2020 2020 2020 2069 6620 7365 '}. if se\n-0003b150: 6c66 2e66 6e6d 6174 6368 3a0a 2020 2020 lf.fnmatch:. \n-0003b160: 2020 2020 2020 2020 7472 793a 0a20 2020 try:. \n-0003b170: 2020 2020 2020 2020 2020 2020 2065 6e74 ent\n-0003b180: 7269 6573 2e75 7064 6174 6528 6f73 2e6c ries.update(os.l\n-0003b190: 6973 7464 6972 2866 272f 7072 6f63 2f73 istdir(f'/proc/s\n-0003b1a0: 656c 662f 6664 2f7b 7365 6c66 2e66 647d elf/fd/{self.fd}\n-0003b1b0: 2729 290a 2020 2020 2020 2020 2020 2020 ')). \n-0003b1c0: 2020 2020 7365 6c66 2e65 6666 6563 7469 self.effecti\n-0003b1d0: 7665 5f66 6e6d 6174 6368 203d 2073 656c ve_fnmatch = sel\n-0003b1e0: 662e 666e 6d61 7463 680a 2020 2020 2020 f.fnmatch. \n-0003b1f0: 2020 2020 2020 6578 6365 7074 204f 5345 except OSE\n-0003b200: 7272 6f72 3a0a 2020 2020 2020 2020 2020 rror:. \n-0003b210: 2020 2020 2020 2320 4966 2077 6520 6661 # If we fa\n-0003b220: 696c 6564 2074 6f20 6765 7420 616e 2069 iled to get an i\n-0003b230: 6e69 7469 616c 206c 6973 742c 2074 6865 nitial list, the\n-0003b240: 6e20 7265 706f 7274 206e 6f74 6869 6e67 n report nothing\n-0003b250: 2066 726f 6d20 6e6f 7720 6f6e 0a20 2020 from now on. \n-0003b260: 2020 2020 2020 2020 2020 2020 2073 656c sel\n-0003b270: 662e 6566 6665 6374 6976 655f 666e 6d61 f.effective_fnma\n-0003b280: 7463 6820 3d20 2727 0a0a 2020 2020 2020 tch = ''.. \n-0003b290: 2020 7365 6c66 2e70 726f 6365 7373 5f75 self.process_u\n-0003b2a0: 7064 6174 6528 7b65 2066 6f72 2065 2069 pdate({e for e i\n-0003b2b0: 6e20 656e 7472 6965 7320 6966 2073 656c n entries if sel\n-0003b2c0: 662e 696e 7465 7265 7374 696e 6728 6529 f.interesting(e)\n-0003b2d0: 7d2c 2072 6573 6574 3d54 7275 6529 0a0a }, reset=True)..\n-0003b2e0: 2020 2020 6465 6620 646f 5f69 6e6f 7469 def do_inoti\n-0003b2f0: 6679 5f65 7665 6e74 2873 656c 662c 206d fy_event(self, m\n-0003b300: 6173 6b3a 2049 6e6f 7469 6679 4576 656e ask: InotifyEven\n-0003b310: 742c 2063 6f6f 6b69 653a 2069 6e74 2c20 t, cookie: int, \n-0003b320: 7261 776e 616d 653a 2027 6279 7465 7320 rawname: 'bytes \n-0003b330: 7c20 4e6f 6e65 2729 202d 3e20 4e6f 6e65 | None') -> None\n-0003b340: 3a0a 2020 2020 2020 2020 6c6f 6767 6572 :. logger\n-0003b350: 2e64 6562 7567 2827 646f 5f69 6e6f 7469 .debug('do_inoti\n-0003b360: 6679 5f65 7665 6e74 2825 722c 2025 722c fy_event(%r, %r,\n-0003b370: 2025 7229 272c 206d 6173 6b2c 2063 6f6f %r)', mask, coo\n-0003b380: 6b69 652c 2072 6177 6e61 6d65 290a 2020 kie, rawname). \n-0003b390: 2020 2020 2020 6e61 6d65 203d 2028 7261 name = (ra\n-0003b3a0: 776e 616d 6520 6f72 2062 2727 292e 6465 wname or b'').de\n-0003b3b0: 636f 6465 2865 7272 6f72 733d 2773 7572 code(errors='sur\n-0003b3c0: 726f 6761 7465 6573 6361 7065 2729 0a0a rogateescape')..\n-0003b3d0: 2020 2020 2020 2020 7365 6c66 2e73 6368 self.sch\n-0003b3e0: 6564 756c 655f 7570 6461 7465 286e 616d edule_update(nam\n-0003b3f0: 6529 0a0a 2020 2020 2020 2020 6966 206e e).. if n\n-0003b400: 616d 6520 616e 6420 6d61 736b 207c 2028 ame and mask | (\n-0003b410: 496e 6f74 6966 7945 7665 6e74 2e43 5245 InotifyEvent.CRE\n-0003b420: 4154 4520 7c20 496e 6f74 6966 7945 7665 ATE | InotifyEve\n-0003b430: 6e74 2e44 454c 4554 4520 7c0a 2020 2020 nt.DELETE |. \n-0003b440: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0003b450: 2020 2020 2020 2020 496e 6f74 6966 7945 InotifyE\n-0003b460: 7665 6e74 2e4d 4f56 4544 5f54 4f20 7c20 vent.MOVED_TO | \n-0003b470: 496e 6f74 6966 7945 7665 6e74 2e4d 4f56 InotifyEvent.MOV\n-0003b480: 4544 5f46 524f 4d29 3a0a 2020 2020 2020 ED_FROM):. \n-0003b490: 2020 2020 2020 2320 5468 6573 6520 6576 # These ev\n-0003b4a0: 656e 7473 2063 6861 6e67 6520 7468 6520 ents change the \n-0003b4b0: 6d74 696d 6520 6f66 2074 6865 2064 6972 mtime of the dir\n-0003b4c0: 6563 746f 7279 0a20 2020 2020 2020 2020 ectory. \n-0003b4d0: 2020 2073 656c 662e 7363 6865 6475 6c65 self.schedule\n-0003b4e0: 5f75 7064 6174 6528 2727 290a 0a20 2020 _update('').. \n-0003b4f0: 2064 6566 2064 6f5f 6964 656e 7469 7479 def do_identity\n-0003b500: 5f63 6861 6e67 6564 2873 656c 662c 2066 _changed(self, f\n-0003b510: 643a 2027 4861 6e64 6c65 207c 204e 6f6e d: 'Handle | Non\n-0003b520: 6527 2c20 6572 723a 2027 696e 7420 7c20 e', err: 'int | \n-0003b530: 4e6f 6e65 2729 202d 3e20 4e6f 6e65 3a0a None') -> None:.\n-0003b540: 2020 2020 2020 2020 6c6f 6767 6572 2e64 logger.d\n-0003b550: 6562 7567 2827 646f 5f69 6465 6e74 6974 ebug('do_identit\n-0003b560: 795f 6368 616e 6765 6428 2572 2c20 2572 y_changed(%r, %r\n-0003b570: 2927 2c20 6664 2c20 6572 7229 0a20 2020 )', fd, err). \n-0003b580: 2020 2020 2023 2049 6620 7468 6572 6520 # If there \n-0003b590: 7765 7265 2070 7265 7669 6f75 736c 7920 were previously \n-0003b5a0: 7065 6e64 696e 6720 6368 616e 6765 732c pending changes,\n-0003b5b0: 2074 6865 7920 6172 6520 6e6f 7720 6972 they are now ir\n-0003b5c0: 7265 6c65 7661 6e74 2e0a 2020 2020 2020 relevant.. \n-0003b5d0: 2020 6966 2073 656c 662e 7065 6e64 696e if self.pendin\n-0003b5e0: 6720 6973 206e 6f74 204e 6f6e 653a 0a20 g is not None:. \n-0003b5f0: 2020 2020 2020 2020 2020 2023 204e 6f74 # Not\n-0003b600: 653a 2064 6f6e 2774 2073 6574 2074 6f20 e: don't set to \n-0003b610: 4e6f 6e65 2c20 7369 6e63 6520 7468 6520 None, since the \n-0003b620: 6861 6e64 6c65 7220 6973 2073 7469 6c6c handler is still\n-0003b630: 2070 656e 6469 6e67 0a20 2020 2020 2020 pending. \n-0003b640: 2020 2020 2073 656c 662e 7065 6e64 696e self.pendin\n-0003b650: 672e 636c 6561 7228 290a 0a20 2020 2020 g.clear().. \n-0003b660: 2020 2069 6620 6572 7220 6973 204e 6f6e if err is Non\n-0003b670: 653a 0a20 2020 2020 2020 2020 2020 2061 e:. a\n-0003b680: 7373 6572 7420 6664 2069 7320 6e6f 7420 ssert fd is not \n-0003b690: 4e6f 6e65 0a20 2020 2020 2020 2020 2020 None. \n-0003b6a0: 2073 656c 662e 7265 706f 7274 5f69 6e69 self.report_ini\n-0003b6b0: 7469 616c 5f73 7461 7465 2866 6429 0a20 tial_state(fd). \n-0003b6c0: 2020 2020 2020 2065 6c73 653a 0a20 2020 else:. \n-0003b6d0: 2020 2020 2020 2020 2073 656c 662e 7265 self.re\n-0003b6e0: 706f 7274 5f65 7272 6f72 2865 7272 290a port_error(err).\n-0003b6f0: 0a20 2020 2064 6566 2064 6f5f 636c 6f73 . def do_clos\n-0003b700: 6528 7365 6c66 2920 2d3e 204e 6f6e 653a e(self) -> None:\n-0003b710: 0a20 2020 2020 2020 2023 206e 6f6e 2d77 . # non-w\n-0003b720: 6174 6368 2063 6861 6e6e 656c 7320 636c atch channels cl\n-0003b730: 6f73 6520 696d 6d65 6469 6174 656c 7920 ose immediately \n-0003b740: e280 9420 6966 2077 6520 6765 7420 7468 ... if we get th\n-0003b750: 6973 2c20 7765 2772 6520 7761 7463 6869 is, we're watchi\n-0003b760: 6e67 0a20 2020 2020 2020 2061 7373 6572 ng. asser\n-0003b770: 7420 7365 6c66 2e70 6174 685f 7761 7463 t self.path_watc\n-0003b780: 6820 6973 206e 6f74 204e 6f6e 650a 2020 h is not None. \n-0003b790: 2020 2020 2020 7365 6c66 2e70 6174 685f self.path_\n-0003b7a0: 7761 7463 682e 636c 6f73 6528 290a 2020 watch.close(). \n-0003b7b0: 2020 2020 2020 7365 6c66 2e63 6c6f 7365 self.close\n-0003b7c0: 2829 0a0a 2020 2020 6465 6620 646f 5f6f ().. def do_o\n-0003b7d0: 7065 6e28 7365 6c66 2c20 6f70 7469 6f6e pen(self, option\n-0003b7e0: 733a 204a 736f 6e4f 626a 6563 7429 202d s: JsonObject) -\n-0003b7f0: 3e20 4e6f 6e65 3a0a 2020 2020 2020 2020 > None:. \n-0003b800: 7365 6c66 2e70 6174 6820 3d20 6765 745f self.path = get_\n-0003b810: 7374 7228 6f70 7469 6f6e 732c 2027 7061 str(options, 'pa\n-0003b820: 7468 2729 0a20 2020 2020 2020 2069 6620 th'). if \n-0003b830: 6e6f 7420 6f73 2e70 6174 682e 6973 6162 not os.path.isab\n-0003b840: 7328 7365 6c66 2e70 6174 6829 3a0a 2020 s(self.path):. \n-0003b850: 2020 2020 2020 2020 2020 7261 6973 6520 raise \n-0003b860: 4a73 6f6e 4572 726f 7228 6f70 7469 6f6e JsonError(option\n-0003b870: 732c 2027 2270 6174 6822 206d 7573 7420 s, '\"path\" must \n-0003b880: 6265 2061 6e20 6162 736f 6c75 7465 2070 be an absolute p\n-0003b890: 6174 6827 290a 0a20 2020 2020 2020 2061 ath').. a\n-0003b8a0: 7474 7273 203d 2073 6574 2867 6574 5f73 ttrs = set(get_s\n-0003b8b0: 7472 7628 6f70 7469 6f6e 732c 2027 6174 trv(options, 'at\n-0003b8c0: 7472 7327 2929 0a20 2020 2020 2020 2073 trs')). s\n-0003b8d0: 656c 662e 6765 7461 7474 7273 203d 2073 elf.getattrs = s\n-0003b8e0: 656c 662e 6d61 6b65 5f67 6574 6174 7472 elf.make_getattr\n-0003b8f0: 7328 6174 7472 7320 2d20 7b27 7461 7267 s(attrs - {'targ\n-0003b900: 6574 7327 2c20 2765 6e74 7269 6573 277d ets', 'entries'}\n-0003b910: 290a 2020 2020 2020 2020 7365 6c66 2e66 ). self.f\n-0003b920: 6e6d 6174 6368 203d 2067 6574 5f73 7472 nmatch = get_str\n-0003b930: 286f 7074 696f 6e73 2c20 2766 6e6d 6174 (options, 'fnmat\n-0003b940: 6368 272c 2027 2a27 2069 6620 2765 6e74 ch', '*' if 'ent\n-0003b950: 7269 6573 2720 696e 2061 7474 7273 2065 ries' in attrs e\n-0003b960: 6c73 6520 2727 290a 2020 2020 2020 2020 lse ''). \n-0003b970: 7365 6c66 2e74 6172 6765 7473 203d 2027 self.targets = '\n-0003b980: 7461 7267 6574 7327 2069 6e20 6174 7472 targets' in attr\n-0003b990: 730a 2020 2020 2020 2020 7365 6c66 2e66 s. self.f\n-0003b9a0: 6f6c 6c6f 7720 3d20 6765 745f 626f 6f6c ollow = get_bool\n-0003b9b0: 286f 7074 696f 6e73 2c20 2766 6f6c 6c6f (options, 'follo\n-0003b9c0: 7727 2c20 6465 6661 756c 743d 5472 7565 w', default=True\n-0003b9d0: 290a 2020 2020 2020 2020 7365 6c66 2e77 ). self.w\n-0003b9e0: 6174 6368 203d 2067 6574 5f62 6f6f 6c28 atch = get_bool(\n-0003b9f0: 6f70 7469 6f6e 732c 2027 7761 7463 6827 options, 'watch'\n-0003ba00: 2c20 6465 6661 756c 743d 4661 6c73 6529 , default=False)\n-0003ba10: 0a20 2020 2020 2020 2069 6620 7365 6c66 . if self\n-0003ba20: 2e77 6174 6368 2061 6e64 206e 6f74 2073 .watch and not s\n-0003ba30: 656c 662e 666f 6c6c 6f77 3a0a 2020 2020 elf.follow:. \n-0003ba40: 2020 2020 2020 2020 7261 6973 6520 4a73 raise Js\n-0003ba50: 6f6e 4572 726f 7228 6f70 7469 6f6e 732c onError(options,\n-0003ba60: 2027 2277 6174 6368 3a20 7472 7565 2220 '\"watch: true\" \n-0003ba70: 616e 6420 2266 6f6c 6c6f 773a 2066 616c and \"follow: fal\n-0003ba80: 7365 2220 6172 6520 2863 7572 7265 6e74 se\" are (current\n-0003ba90: 6c79 2920 696e 636f 6d70 6174 6962 6c65 ly) incompatible\n-0003baa0: 2729 0a20 2020 2020 2020 2069 6620 7365 '). if se\n-0003bab0: 6c66 2e74 6172 6765 7473 2061 6e64 206e lf.targets and n\n-0003bac0: 6f74 2073 656c 662e 666f 6c6c 6f77 3a0a ot self.follow:.\n-0003bad0: 2020 2020 2020 2020 2020 2020 7261 6973 rais\n-0003bae0: 6520 4a73 6f6e 4572 726f 7228 6f70 7469 e JsonError(opti\n-0003baf0: 6f6e 732c 2027 6074 6172 6765 7473 3a20 ons, '`targets: \n-0003bb00: 2273 7461 7422 6020 616e 6420 6066 6f6c \"stat\"` and `fol\n-0003bb10: 6c6f 773a 2066 616c 7365 6020 6172 6520 low: false` are \n-0003bb20: 2863 7572 7265 6e74 6c79 2920 696e 636f (currently) inco\n-0003bb30: 6d70 6174 6962 6c65 2729 0a0a 2020 2020 mpatible').. \n-0003bb40: 2020 2020 7365 6c66 2e63 7572 7265 6e74 self.current\n-0003bb50: 5f76 616c 7565 203d 207b 7d0a 2020 2020 _value = {}. \n-0003bb60: 2020 2020 7365 6c66 2e72 6561 6479 2829 self.ready()\n-0003bb70: 0a0a 2020 2020 2020 2020 6966 206e 6f74 .. if not\n-0003bb80: 2073 656c 662e 7761 7463 683a 0a20 2020 self.watch:. \n-0003bb90: 2020 2020 2020 2020 2074 7279 3a0a 2020 try:. \n-0003bba0: 2020 2020 2020 2020 2020 2020 2020 6664 fd\n-0003bbb0: 203d 2048 616e 646c 652e 6f70 656e 2873 = Handle.open(s\n-0003bbc0: 656c 662e 7061 7468 2c20 6f73 2e4f 5f50 elf.path, os.O_P\n-0003bbd0: 4154 4820 6966 2073 656c 662e 666f 6c6c ATH if self.foll\n-0003bbe0: 6f77 2065 6c73 6520 6f73 2e4f 5f50 4154 ow else os.O_PAT\n-0003bbf0: 4820 7c20 6f73 2e4f 5f4e 4f46 4f4c 4c4f H | os.O_NOFOLLO\n-0003bc00: 5729 0a20 2020 2020 2020 2020 2020 2065 W). e\n-0003bc10: 7863 6570 7420 4f53 4572 726f 7220 6173 xcept OSError as\n-0003bc20: 2065 7863 3a0a 2020 2020 2020 2020 2020 exc:. \n-0003bc30: 2020 2020 2020 7365 6c66 2e72 6570 6f72 self.repor\n-0003bc40: 745f 6572 726f 7228 6578 632e 6572 726e t_error(exc.errn\n-0003bc50: 6f29 0a20 2020 2020 2020 2020 2020 2065 o). e\n-0003bc60: 6c73 653a 0a20 2020 2020 2020 2020 2020 lse:. \n-0003bc70: 2020 2020 2073 656c 662e 7265 706f 7274 self.report\n-0003bc80: 5f69 6e69 7469 616c 5f73 7461 7465 2866 _initial_state(f\n-0003bc90: 6429 0a20 2020 2020 2020 2020 2020 2020 d). \n-0003bca0: 2020 2066 642e 636c 6f73 6528 290a 0a20 fd.close().. \n-0003bcb0: 2020 2020 2020 2020 2020 2073 656c 662e self.\n-0003bcc0: 646f 6e65 2829 0a20 2020 2020 2020 2020 done(). \n-0003bcd0: 2020 2073 656c 662e 636c 6f73 6528 290a self.close().\n-0003bce0: 0a20 2020 2020 2020 2065 6c73 653a 0a20 . else:. \n-0003bcf0: 2020 2020 2020 2020 2020 2023 2050 6174 # Pat\n-0003bd00: 6857 6174 6368 2077 696c 6c20 6361 6c6c hWatch will call\n-0003bd10: 2064 6f5f 6964 656e 7469 7479 5f63 6861 do_identity_cha\n-0003bd20: 6e67 6564 2829 2c20 7768 6963 6820 646f nged(), which do\n-0003bd30: 6573 2074 6865 2073 616d 6520 6173 0a20 es the same as. \n-0003bd40: 2020 2020 2020 2020 2020 2023 2061 626f # abo\n-0003bd50: 7665 3a20 6361 6c6c 7320 6569 7468 6572 ve: calls either\n-0003bd60: 2072 6570 6f72 745f 696e 6974 6961 6c5f report_initial_\n-0003bd70: 7374 6174 6528 2920 6f72 2072 6570 6f72 state() or repor\n-0003bd80: 745f 6572 726f 7228 292c 0a20 2020 2020 t_error(),. \n-0003bd90: 2020 2020 2020 2023 2064 6570 656e 6469 # dependi\n-0003bda0: 6e67 206f 6e20 6966 2069 7420 7761 7320 ng on if it was \n-0003bdb0: 7072 6f76 6964 6564 2077 6974 6820 616e provided with an\n-0003bdc0: 2066 6420 6f72 2061 6e20 6572 726f 7220 fd or an error \n-0003bdd0: 636f 6465 2e0a 2020 2020 2020 2020 2020 code.. \n-0003bde0: 2020 7365 6c66 2e70 6174 685f 7761 7463 self.path_watc\n-0003bdf0: 6820 3d20 5061 7468 5761 7463 6828 7365 h = PathWatch(se\n-0003be00: 6c66 2e70 6174 682c 2073 656c 6629 0a27 lf.path, self).'\n-0003be10: 2727 2e65 6e63 6f64 6528 2775 7466 2d38 ''.encode('utf-8\n-0003be20: 2729 2c0a 2020 2763 6f63 6b70 6974 2f63 '),. 'cockpit/c\n-0003be30: 6861 6e6e 656c 732f 6874 7470 2e70 7927 hannels/http.py'\n-0003be40: 3a20 6272 2727 2723 2054 6869 7320 6669 : br'''# This fi\n-0003be50: 6c65 2069 7320 7061 7274 206f 6620 436f le is part of Co\n-0003be60: 636b 7069 742e 0a23 0a23 2043 6f70 7972 ckpit..#.# Copyr\n-0003be70: 6967 6874 2028 4329 2032 3032 3220 5265 ight (C) 2022 Re\n-0003be80: 6420 4861 742c 2049 6e63 2e0a 230a 2320 d Hat, Inc..#.# \n-0003be90: 5468 6973 2070 726f 6772 616d 2069 7320 This program is \n-0003bea0: 6672 6565 2073 6f66 7477 6172 653a 2079 free software: y\n-0003beb0: 6f75 2063 616e 2072 6564 6973 7472 6962 ou can redistrib\n-0003bec0: 7574 6520 6974 2061 6e64 2f6f 7220 6d6f ute it and/or mo\n-0003bed0: 6469 6679 0a23 2069 7420 756e 6465 7220 dify.# it under \n-0003bee0: 7468 6520 7465 726d 7320 6f66 2074 6865 the terms of the\n-0003bef0: 2047 4e55 2047 656e 6572 616c 2050 7562 GNU General Pub\n-0003bf00: 6c69 6320 4c69 6365 6e73 6520 6173 2070 lic License as p\n-0003bf10: 7562 6c69 7368 6564 2062 790a 2320 7468 ublished by.# th\n-0003bf20: 6520 4672 6565 2053 6f66 7477 6172 6520 e Free Software \n-0003bf30: 466f 756e 6461 7469 6f6e 2c20 6569 7468 Foundation, eith\n-0003bf40: 6572 2076 6572 7369 6f6e 2033 206f 6620 er version 3 of \n-0003bf50: 7468 6520 4c69 6365 6e73 652c 206f 720a the License, or.\n-0003bf60: 2320 2861 7420 796f 7572 206f 7074 696f # (at your optio\n-0003bf70: 6e29 2061 6e79 206c 6174 6572 2076 6572 n) any later ver\n-0003bf80: 7369 6f6e 2e0a 230a 2320 5468 6973 2070 sion..#.# This p\n-0003bf90: 726f 6772 616d 2069 7320 6469 7374 7269 rogram is distri\n-0003bfa0: 6275 7465 6420 696e 2074 6865 2068 6f70 buted in the hop\n-0003bfb0: 6520 7468 6174 2069 7420 7769 6c6c 2062 e that it will b\n-0003bfc0: 6520 7573 6566 756c 2c0a 2320 6275 7420 e useful,.# but \n-0003bfd0: 5749 5448 4f55 5420 414e 5920 5741 5252 WITHOUT ANY WARR\n-0003bfe0: 414e 5459 3b20 7769 7468 6f75 7420 6576 ANTY; without ev\n-0003bff0: 656e 2074 6865 2069 6d70 6c69 6564 2077 en the implied w\n-0003c000: 6172 7261 6e74 7920 6f66 0a23 204d 4552 arranty of.# MER\n-0003c010: 4348 414e 5441 4249 4c49 5459 206f 7220 CHANTABILITY or \n-0003c020: 4649 544e 4553 5320 464f 5220 4120 5041 FITNESS FOR A PA\n-0003c030: 5254 4943 554c 4152 2050 5552 504f 5345 RTICULAR PURPOSE\n-0003c040: 2e20 2053 6565 2074 6865 0a23 2047 4e55 . See the.# GNU\n-0003c050: 2047 656e 6572 616c 2050 7562 6c69 6320 General Public \n-0003c060: 4c69 6365 6e73 6520 666f 7220 6d6f 7265 License for more\n-0003c070: 2064 6574 6169 6c73 2e0a 230a 2320 596f details..#.# Yo\n-0003c080: 7520 7368 6f75 6c64 2068 6176 6520 7265 u should have re\n-0003c090: 6365 6976 6564 2061 2063 6f70 7920 6f66 ceived a copy of\n-0003c0a0: 2074 6865 2047 4e55 2047 656e 6572 616c the GNU General\n-0003c0b0: 2050 7562 6c69 6320 4c69 6365 6e73 650a Public License.\n-0003c0c0: 2320 616c 6f6e 6720 7769 7468 2074 6869 # along with thi\n-0003c0d0: 7320 7072 6f67 7261 6d2e 2020 4966 206e s program. If n\n-0003c0e0: 6f74 2c20 7365 6520 3c68 7474 7073 3a2f ot, see <https:/\n-0003c0f0: 2f77 7777 2e67 6e75 2e6f 7267 2f6c 6963 /www.gnu.org/lic\n-0003c100: 656e 7365 732f 3e2e 0a0a 696d 706f 7274 enses/>...import\n-0003c110: 2061 7379 6e63 696f 0a69 6d70 6f72 7420 asyncio.import \n-0003c120: 6874 7470 2e63 6c69 656e 740a 696d 706f http.client.impo\n-0003c130: 7274 206c 6f67 6769 6e67 0a69 6d70 6f72 rt logging.impor\n-0003c140: 7420 736f 636b 6574 0a69 6d70 6f72 7420 t socket.import \n-0003c150: 7373 6c0a 0a66 726f 6d20 2e2e 6368 616e ssl..from ..chan\n-0003c160: 6e65 6c20 696d 706f 7274 2041 7379 6e63 nel import Async\n-0003c170: 4368 616e 6e65 6c2c 2043 6861 6e6e 656c Channel, Channel\n-0003c180: 4572 726f 720a 6672 6f6d 202e 2e6a 736f Error.from ..jso\n-0003c190: 6e75 7469 6c20 696d 706f 7274 204a 736f nutil import Jso\n-0003c1a0: 6e4f 626a 6563 742c 2067 6574 5f64 6963 nObject, get_dic\n-0003c1b0: 742c 2067 6574 5f65 6e75 6d2c 2067 6574 t, get_enum, get\n-0003c1c0: 5f69 6e74 2c20 6765 745f 6f62 6a65 6374 _int, get_object\n-0003c1d0: 2c20 6765 745f 7374 722c 2074 7970 6563 , get_str, typec\n-0003c1e0: 6865 636b 6564 0a0a 6c6f 6767 6572 203d hecked..logger =\n-0003c1f0: 206c 6f67 6769 6e67 2e67 6574 4c6f 6767 logging.getLogg\n-0003c200: 6572 285f 5f6e 616d 655f 5f29 0a0a 0a63 er(__name__)...c\n-0003c210: 6c61 7373 2048 7474 7043 6861 6e6e 656c lass HttpChannel\n-0003c220: 2841 7379 6e63 4368 616e 6e65 6c29 3a0a (AsyncChannel):.\n-0003c230: 2020 2020 7061 796c 6f61 6420 3d20 2768 payload = 'h\n-0003c240: 7474 702d 7374 7265 616d 3227 0a0a 2020 ttp-stream2'.. \n-0003c250: 2020 4073 7461 7469 636d 6574 686f 640a @staticmethod.\n-0003c260: 2020 2020 6465 6620 6765 745f 6865 6164 def get_head\n-0003c270: 6572 7328 7265 7370 6f6e 7365 3a20 6874 ers(response: ht\n-0003c280: 7470 2e63 6c69 656e 742e 4854 5450 5265 tp.client.HTTPRe\n-0003c290: 7370 6f6e 7365 2c20 2a2c 2062 696e 6172 sponse, *, binar\n-0003c2a0: 793a 2062 6f6f 6c29 202d 3e20 4a73 6f6e y: bool) -> Json\n-0003c2b0: 4f62 6a65 6374 3a0a 2020 2020 2020 2020 Object:. \n-0003c2c0: 2320 4e65 7665 7220 7365 6e64 2074 6865 # Never send the\n-0003c2d0: 7365 2068 6561 6465 7273 0a20 2020 2020 se headers. \n-0003c2e0: 2020 2072 656d 6f76 6520 3d20 7b27 436f remove = {'Co\n-0003c2f0: 6e6e 6563 7469 6f6e 272c 2027 5472 616e nnection', 'Tran\n-0003c300: 7366 6572 2d45 6e63 6f64 696e 6727 7d0a sfer-Encoding'}.\n-0003c310: 0a20 2020 2020 2020 2069 6620 6e6f 7420 . if not \n-0003c320: 6269 6e61 7279 3a0a 2020 2020 2020 2020 binary:. \n-0003c330: 2020 2020 2320 4f6e 6c79 2073 656e 6420 # Only send \n-0003c340: 7468 6573 6520 6865 6164 6572 7320 666f these headers fo\n-0003c350: 7220 7261 7720 6269 6e61 7279 2073 7472 r raw binary str\n-0003c360: 6561 6d73 0a20 2020 2020 2020 2020 2020 eams. \n-0003c370: 2072 656d 6f76 652e 7570 6461 7465 287b remove.update({\n-0003c380: 2743 6f6e 7465 6e74 2d4c 656e 6774 6827 'Content-Length'\n-0003c390: 2c20 2752 616e 6765 277d 290a 0a20 2020 , 'Range'}).. \n-0003c3a0: 2020 2020 2072 6574 7572 6e20 7b6b 6579 return {key\n-0003c3b0: 3a20 7661 6c75 6520 666f 7220 6b65 792c : value for key,\n-0003c3c0: 2076 616c 7565 2069 6e20 7265 7370 6f6e value in respon\n-0003c3d0: 7365 2e67 6574 6865 6164 6572 7328 2920 se.getheaders() \n-0003c3e0: 6966 206b 6579 206e 6f74 2069 6e20 7265 if key not in re\n-0003c3f0: 6d6f 7665 7d0a 0a20 2020 2040 7374 6174 move}.. @stat\n-0003c400: 6963 6d65 7468 6f64 0a20 2020 2064 6566 icmethod. def\n-0003c410: 2063 7265 6174 655f 636c 6965 6e74 286f create_client(o\n-0003c420: 7074 696f 6e73 3a20 4a73 6f6e 4f62 6a65 ptions: JsonObje\n-0003c430: 6374 2920 2d3e 2068 7474 702e 636c 6965 ct) -> http.clie\n-0003c440: 6e74 2e48 5454 5043 6f6e 6e65 6374 696f nt.HTTPConnectio\n-0003c450: 6e3a 0a20 2020 2020 2020 206f 7074 5f61 n:. opt_a\n-0003c460: 6464 7265 7373 203d 2067 6574 5f73 7472 ddress = get_str\n-0003c470: 286f 7074 696f 6e73 2c20 2761 6464 7265 (options, 'addre\n-0003c480: 7373 272c 2027 6c6f 6361 6c68 6f73 7427 ss', 'localhost'\n-0003c490: 290a 2020 2020 2020 2020 6f70 745f 746c ). opt_tl\n-0003c4a0: 7320 3d20 6765 745f 6469 6374 286f 7074 s = get_dict(opt\n-0003c4b0: 696f 6e73 2c20 2774 6c73 272c 204e 6f6e ions, 'tls', Non\n-0003c4c0: 6529 0a20 2020 2020 2020 206f 7074 5f75 e). opt_u\n-0003c4d0: 6e69 7820 3d20 6765 745f 7374 7228 6f70 nix = get_str(op\n-0003c4e0: 7469 6f6e 732c 2027 756e 6978 272c 204e tions, 'unix', N\n-0003c4f0: 6f6e 6529 0a20 2020 2020 2020 206f 7074 one). opt\n-0003c500: 5f70 6f72 7420 3d20 6765 745f 696e 7428 _port = get_int(\n-0003c510: 6f70 7469 6f6e 732c 2027 706f 7274 272c options, 'port',\n-0003c520: 204e 6f6e 6529 0a0a 2020 2020 2020 2020 None).. \n-0003c530: 6966 206f 7074 5f74 6c73 2069 7320 6e6f if opt_tls is no\n-0003c540: 7420 4e6f 6e65 2061 6e64 206f 7074 5f75 t None and opt_u\n-0003c550: 6e69 7820 6973 206e 6f74 204e 6f6e 653a nix is not None:\n-0003c560: 0a20 2020 2020 2020 2020 2020 2072 6169 . rai\n-0003c570: 7365 2043 6861 6e6e 656c 4572 726f 7228 se ChannelError(\n-0003c580: 2770 726f 746f 636f 6c2d 6572 726f 7227 'protocol-error'\n-0003c590: 2c20 6d65 7373 6167 653d 2754 4c53 206f , message='TLS o\n-0003c5a0: 6e20 556e 6978 2073 6f63 6b65 7420 6973 n Unix socket is\n-0003c5b0: 206e 6f74 2073 7570 706f 7274 6564 2729 not supported')\n-0003c5c0: 0a20 2020 2020 2020 2069 6620 6f70 745f . if opt_\n-0003c5d0: 706f 7274 2069 7320 4e6f 6e65 2061 6e64 port is None and\n-0003c5e0: 206f 7074 5f75 6e69 7820 6973 204e 6f6e opt_unix is Non\n-0003c5f0: 653a 0a20 2020 2020 2020 2020 2020 2072 e:. r\n-0003c600: 6169 7365 2043 6861 6e6e 656c 4572 726f aise ChannelErro\n-0003c610: 7228 2770 726f 746f 636f 6c2d 6572 726f r('protocol-erro\n-0003c620: 7227 2c20 6d65 7373 6167 653d 276e 6f20 r', message='no \n-0003c630: 2270 6f72 7422 206f 7220 2275 6e69 7822 \"port\" or \"unix\"\n-0003c640: 206f 7074 696f 6e20 666f 7220 6368 616e option for chan\n-0003c650: 6e65 6c27 290a 2020 2020 2020 2020 6966 nel'). if\n-0003c660: 206f 7074 5f70 6f72 7420 6973 206e 6f74 opt_port is not\n-0003c670: 204e 6f6e 6520 616e 6420 6f70 745f 756e None and opt_un\n-0003c680: 6978 2069 7320 6e6f 7420 4e6f 6e65 3a0a ix is not None:.\n-0003c690: 2020 2020 2020 2020 2020 2020 7261 6973 rais\n-0003c6a0: 6520 4368 616e 6e65 6c45 7272 6f72 2827 e ChannelError('\n-0003c6b0: 7072 6f74 6f63 6f6c 2d65 7272 6f72 272c protocol-error',\n-0003c6c0: 206d 6573 7361 6765 3d27 6361 6e6e 6f74 message='cannot\n-0003c6d0: 2073 7065 6369 6679 2062 6f74 6820 2270 specify both \"p\n-0003c6e0: 6f72 7422 2061 6e64 2022 756e 6978 2220 ort\" and \"unix\" \n-0003c6f0: 6f70 7469 6f6e 7327 290a 0a20 2020 2020 options').. \n-0003c700: 2020 2069 6620 6f70 745f 746c 7320 6973 if opt_tls is\n-0003c710: 206e 6f74 204e 6f6e 653a 0a20 2020 2020 not None:. \n-0003c720: 2020 2020 2020 2061 7574 686f 7269 7479 authority\n-0003c730: 203d 2067 6574 5f64 6963 7428 6f70 745f = get_dict(opt_\n-0003c740: 746c 732c 2027 6175 7468 6f72 6974 7927 tls, 'authority'\n-0003c750: 2c20 4e6f 6e65 290a 2020 2020 2020 2020 , None). \n-0003c760: 2020 2020 6966 2061 7574 686f 7269 7479 if authority\n-0003c770: 2069 7320 6e6f 7420 4e6f 6e65 3a0a 2020 is not None:. \n-0003c780: 2020 2020 2020 2020 2020 2020 2020 6461 da\n-0003c790: 7461 203d 2067 6574 5f73 7472 2861 7574 ta = get_str(aut\n-0003c7a0: 686f 7269 7479 2c20 2764 6174 6127 2c20 hority, 'data', \n-0003c7b0: 4e6f 6e65 290a 2020 2020 2020 2020 2020 None). \n-0003c7c0: 2020 2020 2020 6966 2064 6174 6120 6973 if data is\n-0003c7d0: 206e 6f74 204e 6f6e 653a 0a20 2020 2020 not None:. \n-0003c7e0: 2020 2020 2020 2020 2020 2020 2020 2063 c\n-0003c7f0: 6f6e 7465 7874 203d 2073 736c 2e63 7265 ontext = ssl.cre\n-0003c800: 6174 655f 6465 6661 756c 745f 636f 6e74 ate_default_cont\n-0003c810: 6578 7428 6361 6461 7461 3d64 6174 6129 ext(cadata=data)\n-0003c820: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-0003c830: 2065 6c73 653a 0a20 2020 2020 2020 2020 else:. \n-0003c840: 2020 2020 2020 2020 2020 2063 6f6e 7465 conte\n-0003c850: 7874 203d 2073 736c 2e63 7265 6174 655f xt = ssl.create_\n-0003c860: 6465 6661 756c 745f 636f 6e74 6578 7428 default_context(\n-0003c870: 6361 6669 6c65 3d67 6574 5f73 7472 2861 cafile=get_str(a\n-0003c880: 7574 686f 7269 7479 2c20 2766 696c 6527 uthority, 'file'\n-0003c890: 2929 0a20 2020 2020 2020 2020 2020 2065 )). e\n-0003c8a0: 6c73 653a 0a20 2020 2020 2020 2020 2020 lse:. \n-0003c8b0: 2020 2020 2063 6f6e 7465 7874 203d 2073 context = s\n-0003c8c0: 736c 2e63 7265 6174 655f 6465 6661 756c sl.create_defaul\n-0003c8d0: 745f 636f 6e74 6578 7428 290a 0a20 2020 t_context().. \n-0003c8e0: 2020 2020 2020 2020 2069 6620 2776 616c if 'val\n-0003c8f0: 6964 6174 6527 2069 6e20 6f70 745f 746c idate' in opt_tl\n-0003c900: 7320 616e 6420 6e6f 7420 6f70 745f 746c s and not opt_tl\n-0003c910: 735b 2776 616c 6964 6174 6527 5d3a 0a20 s['validate']:. \n-0003c920: 2020 2020 2020 2020 2020 2020 2020 2063 c\n-0003c930: 6f6e 7465 7874 2e63 6865 636b 5f68 6f73 ontext.check_hos\n-0003c940: 746e 616d 6520 3d20 4661 6c73 650a 2020 tname = False. \n-0003c950: 2020 2020 2020 2020 2020 2020 2020 636f co\n-0003c960: 6e74 6578 742e 7665 7269 6679 5f6d 6f64 ntext.verify_mod\n-0003c970: 6520 3d20 7373 6c2e 5665 7269 6679 4d6f e = ssl.VerifyMo\n-0003c980: 6465 2e43 4552 545f 4e4f 4e45 0a0a 2020 de.CERT_NONE.. \n-0003c990: 2020 2020 2020 2020 2020 2320 5365 6520 # See \n-0003c9a0: 6874 7470 733a 2f2f 6769 7468 7562 2e63 https://github.c\n-0003c9b0: 6f6d 2f70 7974 686f 6e2f 7479 7065 7368 om/python/typesh\n-0003c9c0: 6564 2f69 7373 7565 732f 3131 3035 370a ed/issues/11057.\n-0003c9d0: 2020 2020 2020 2020 2020 2020 7265 7475 retu\n-0003c9e0: 726e 2068 7474 702e 636c 6965 6e74 2e48 rn http.client.H\n-0003c9f0: 5454 5053 436f 6e6e 6563 7469 6f6e 286f TTPSConnection(o\n-0003ca00: 7074 5f61 6464 7265 7373 2c20 706f 7274 pt_address, port\n-0003ca10: 3d6f 7074 5f70 6f72 742c 2063 6f6e 7465 =opt_port, conte\n-0003ca20: 7874 3d63 6f6e 7465 7874 2920 2023 2074 xt=context) # t\n-0003ca30: 7970 653a 2069 676e 6f72 655b 6172 672d ype: ignore[arg-\n-0003ca40: 7479 7065 5d0a 0a20 2020 2020 2020 2065 type].. e\n-0003ca50: 6c73 653a 0a20 2020 2020 2020 2020 2020 lse:. \n-0003ca60: 2072 6574 7572 6e20 6874 7470 2e63 6c69 return http.cli\n-0003ca70: 656e 742e 4854 5450 436f 6e6e 6563 7469 ent.HTTPConnecti\n-0003ca80: 6f6e 286f 7074 5f61 6464 7265 7373 2c20 on(opt_address, \n-0003ca90: 706f 7274 3d6f 7074 5f70 6f72 7429 0a0a port=opt_port)..\n-0003caa0: 2020 2020 4073 7461 7469 636d 6574 686f @staticmetho\n-0003cab0: 640a 2020 2020 6465 6620 636f 6e6e 6563 d. def connec\n-0003cac0: 7428 636f 6e6e 6563 7469 6f6e 3a20 6874 t(connection: ht\n-0003cad0: 7470 2e63 6c69 656e 742e 4854 5450 436f tp.client.HTTPCo\n-0003cae0: 6e6e 6563 7469 6f6e 2c20 6f70 745f 756e nnection, opt_un\n-0003caf0: 6978 3a20 2773 7472 207c 204e 6f6e 6527 ix: 'str | None'\n-0003cb00: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n-0003cb10: 2020 2023 2042 6c6f 636b 732e 2020 5275 # Blocks. Ru\n-0003cb20: 6e73 2069 6e20 6120 7468 7265 6164 2e0a ns in a thread..\n-0003cb30: 2020 2020 2020 2020 6966 206f 7074 5f75 if opt_u\n-0003cb40: 6e69 783a 0a20 2020 2020 2020 2020 2020 nix:. \n-0003cb50: 2023 2063 7265 6174 6520 7468 6520 636f # create the co\n-0003cb60: 6e6e 6563 7469 6f6e 2773 2073 6f63 6b65 nnection's socke\n-0003cb70: 7420 736f 2074 6861 7420 6974 2077 6f6e t so that it won\n-0003cb80: 2774 2063 616c 6c20 2e63 6f6e 6e65 6374 't call .connect\n-0003cb90: 2829 2069 6e74 6572 6e61 6c6c 7920 2877 () internally (w\n-0003cba0: 6869 6368 206f 6e6c 7920 7375 7070 6f72 hich only suppor\n-0003cbb0: 7473 2054 4350 290a 2020 2020 2020 2020 ts TCP). \n-0003cbc0: 2020 2020 636f 6e6e 6563 7469 6f6e 2e73 connection.s\n-0003cbd0: 6f63 6b20 3d20 736f 636b 6574 2e73 6f63 ock = socket.soc\n-0003cbe0: 6b65 7428 736f 636b 6574 2e41 465f 554e ket(socket.AF_UN\n-0003cbf0: 4958 290a 2020 2020 2020 2020 2020 2020 IX). \n-0003cc00: 636f 6e6e 6563 7469 6f6e 2e73 6f63 6b2e connection.sock.\n-0003cc10: 636f 6e6e 6563 7428 6f70 745f 756e 6978 connect(opt_unix\n-0003cc20: 290a 2020 2020 2020 2020 656c 7365 3a0a ). else:.\n-0003cc30: 2020 2020 2020 2020 2020 2020 2320 6578 # ex\n-0003cc40: 706c 6963 6974 6c79 2063 616c 6c20 636f plicitly call co\n-0003cc50: 6e6e 6563 7428 292c 2073 6f20 7468 6174 nnect(), so that\n-0003cc60: 2077 6520 6361 6e20 646f 2070 726f 7065 we can do prope\n-0003cc70: 7220 6572 726f 7220 6861 6e64 6c69 6e67 r error handling\n-0003cc80: 0a20 2020 2020 2020 2020 2020 2063 6f6e . con\n-0003cc90: 6e65 6374 696f 6e2e 636f 6e6e 6563 7428 nection.connect(\n-0003cca0: 290a 0a20 2020 2040 7374 6174 6963 6d65 ).. @staticme\n-0003ccb0: 7468 6f64 0a20 2020 2064 6566 2072 6571 thod. def req\n-0003ccc0: 7565 7374 280a 2020 2020 2020 2020 636f uest(. co\n-0003ccd0: 6e6e 6563 7469 6f6e 3a20 6874 7470 2e63 nnection: http.c\n-0003cce0: 6c69 656e 742e 4854 5450 436f 6e6e 6563 lient.HTTPConnec\n-0003ccf0: 7469 6f6e 2c20 6d65 7468 6f64 3a20 7374 tion, method: st\n-0003cd00: 722c 2070 6174 683a 2073 7472 2c20 6865 r, path: str, he\n-0003cd10: 6164 6572 733a 2027 6469 6374 5b73 7472 aders: 'dict[str\n-0003cd20: 2c20 7374 725d 272c 2062 6f64 793a 2062 , str]', body: b\n-0003cd30: 7974 6573 0a20 2020 2029 202d 3e20 6874 ytes. ) -> ht\n-0003cd40: 7470 2e63 6c69 656e 742e 4854 5450 5265 tp.client.HTTPRe\n-0003cd50: 7370 6f6e 7365 3a0a 2020 2020 2020 2020 sponse:. \n-0003cd60: 2320 426c 6f63 6b73 2e20 2052 756e 7320 # Blocks. Runs \n-0003cd70: 696e 2061 2074 6872 6561 642e 0a20 2020 in a thread.. \n-0003cd80: 2020 2020 2063 6f6e 6e65 6374 696f 6e2e connection.\n-0003cd90: 7265 7175 6573 7428 6d65 7468 6f64 2c20 request(method, \n-0003cda0: 7061 7468 2c20 6865 6164 6572 733d 6865 path, headers=he\n-0003cdb0: 6164 6572 7320 6f72 207b 7d2c 2062 6f64 aders or {}, bod\n-0003cdc0: 793d 626f 6479 290a 2020 2020 2020 2020 y=body). \n-0003cdd0: 7265 7475 726e 2063 6f6e 6e65 6374 696f return connectio\n-0003cde0: 6e2e 6765 7472 6573 706f 6e73 6528 290a n.getresponse().\n-0003cdf0: 0a20 2020 2061 7379 6e63 2064 6566 2072 . async def r\n-0003ce00: 756e 2873 656c 662c 206f 7074 696f 6e73 un(self, options\n-0003ce10: 3a20 4a73 6f6e 4f62 6a65 6374 2920 2d3e : JsonObject) ->\n-0003ce20: 204e 6f6e 653a 0a20 2020 2020 2020 206c None:. l\n-0003ce30: 6f67 6765 722e 6465 6275 6728 276f 7065 ogger.debug('ope\n-0003ce40: 6e20 2573 272c 206f 7074 696f 6e73 290a n %s', options).\n-0003ce50: 0a20 2020 2020 2020 2062 696e 6172 7920 . binary \n-0003ce60: 3d20 6765 745f 656e 756d 286f 7074 696f = get_enum(optio\n-0003ce70: 6e73 2c20 2762 696e 6172 7927 2c20 5b27 ns, 'binary', ['\n-0003ce80: 7261 7727 5d2c 204e 6f6e 6529 2069 7320 raw'], None) is \n-0003ce90: 6e6f 7420 4e6f 6e65 0a20 2020 2020 2020 not None. \n-0003cea0: 206d 6574 686f 6420 3d20 6765 745f 7374 method = get_st\n-0003ceb0: 7228 6f70 7469 6f6e 732c 2027 6d65 7468 r(options, 'meth\n-0003cec0: 6f64 2729 0a20 2020 2020 2020 2070 6174 od'). pat\n-0003ced0: 6820 3d20 6765 745f 7374 7228 6f70 7469 h = get_str(opti\n-0003cee0: 6f6e 732c 2027 7061 7468 2729 0a20 2020 ons, 'path'). \n-0003cef0: 2020 2020 2068 6561 6465 7273 203d 2067 headers = g\n-0003cf00: 6574 5f6f 626a 6563 7428 6f70 7469 6f6e et_object(option\n-0003cf10: 732c 2027 6865 6164 6572 7327 2c20 6c61 s, 'headers', la\n-0003cf20: 6d62 6461 2064 3a20 7b6b 3a20 7479 7065 mbda d: {k: type\n-0003cf30: 6368 6563 6b65 6428 762c 2073 7472 2920 checked(v, str) \n-0003cf40: 666f 7220 6b2c 2076 2069 6e20 642e 6974 for k, v in d.it\n-0003cf50: 656d 7328 297d 2c20 4e6f 6e65 290a 0a20 ems()}, None).. \n-0003cf60: 2020 2020 2020 2069 6620 2763 6f6e 6e65 if 'conne\n-0003cf70: 6374 696f 6e27 2069 6e20 6f70 7469 6f6e ction' in option\n-0003cf80: 733a 0a20 2020 2020 2020 2020 2020 2072 s:. r\n-0003cf90: 6169 7365 2043 6861 6e6e 656c 4572 726f aise ChannelErro\n-0003cfa0: 7228 2770 726f 746f 636f 6c2d 6572 726f r('protocol-erro\n-0003cfb0: 7227 2c20 6d65 7373 6167 653d 2763 6f6e r', message='con\n-0003cfc0: 6e65 6374 696f 6e20 7368 6172 696e 6720 nection sharing \n-0003cfd0: 6973 206e 6f74 2069 6d70 6c65 6d65 6e74 is not implement\n-0003cfe0: 6564 206f 6e20 7468 6973 2062 7269 6467 ed on this bridg\n-0003cff0: 6527 290a 0a20 2020 2020 2020 206c 6f6f e').. loo\n-0003d000: 7020 3d20 6173 796e 6369 6f2e 6765 745f p = asyncio.get_\n-0003d010: 7275 6e6e 696e 675f 6c6f 6f70 2829 0a20 running_loop(). \n-0003d020: 2020 2020 2020 2063 6f6e 6e65 6374 696f connectio\n-0003d030: 6e20 3d20 7365 6c66 2e63 7265 6174 655f n = self.create_\n-0003d040: 636c 6965 6e74 286f 7074 696f 6e73 290a client(options).\n-0003d050: 0a20 2020 2020 2020 2073 656c 662e 7265 . self.re\n-0003d060: 6164 7928 290a 0a20 2020 2020 2020 2062 ady().. b\n-0003d070: 6f64 7920 3d20 6227 270a 2020 2020 2020 ody = b''. \n-0003d080: 2020 7768 696c 6520 5472 7565 3a0a 2020 while True:. \n-0003d090: 2020 2020 2020 2020 2020 6461 7461 203d data =\n-0003d0a0: 2061 7761 6974 2073 656c 662e 7265 6164 await self.read\n-0003d0b0: 2829 0a20 2020 2020 2020 2020 2020 2069 (). i\n-0003d0c0: 6620 6461 7461 2069 7320 4e6f 6e65 3a0a f data is None:.\n-0003d0d0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0003d0e0: 6272 6561 6b0a 2020 2020 2020 2020 2020 break. \n-0003d0f0: 2020 626f 6479 202b 3d20 6461 7461 0a0a body += data..\n-0003d100: 2020 2020 2020 2020 2320 436f 6e6e 6563 # Connec\n-0003d110: 7420 696e 2061 2074 6872 6561 6420 616e t in a thread an\n-0003d120: 6420 6861 6e64 6c65 2065 7272 6f72 730a d handle errors.\n-0003d130: 2020 2020 2020 2020 7472 793a 0a20 2020 try:. \n-0003d140: 2020 2020 2020 2020 2061 7761 6974 206c await l\n-0003d150: 6f6f 702e 7275 6e5f 696e 5f65 7865 6375 oop.run_in_execu\n-0003d160: 746f 7228 4e6f 6e65 2c20 7365 6c66 2e63 tor(None, self.c\n-0003d170: 6f6e 6e65 6374 2c20 636f 6e6e 6563 7469 onnect, connecti\n-0003d180: 6f6e 2c20 6765 745f 7374 7228 6f70 7469 on, get_str(opti\n-0003d190: 6f6e 732c 2027 756e 6978 272c 204e 6f6e ons, 'unix', Non\n-0003d1a0: 6529 290a 2020 2020 2020 2020 6578 6365 e)). exce\n-0003d1b0: 7074 2073 736c 2e53 534c 4365 7274 5665 pt ssl.SSLCertVe\n-0003d1c0: 7269 6669 6361 7469 6f6e 4572 726f 7220 rificationError \n-0003d1d0: 6173 2065 7863 3a0a 2020 2020 2020 2020 as exc:. \n-0003d1e0: 2020 2020 7261 6973 6520 4368 616e 6e65 raise Channe\n-0003d1f0: 6c45 7272 6f72 2827 756e 6b6e 6f77 6e2d lError('unknown-\n-0003d200: 686f 7374 6b65 7927 2c20 6d65 7373 6167 hostkey', messag\n-0003d210: 653d 7374 7228 6578 6329 2920 6672 6f6d e=str(exc)) from\n-0003d220: 2065 7863 0a20 2020 2020 2020 2065 7863 exc. exc\n-0003d230: 6570 7420 284f 5345 7272 6f72 2c20 494f ept (OSError, IO\n-0003d240: 4572 726f 7229 2061 7320 6578 633a 0a20 Error) as exc:. \n-0003d250: 2020 2020 2020 2020 2020 2072 6169 7365 raise\n-0003d260: 2043 6861 6e6e 656c 4572 726f 7228 276e ChannelError('n\n-0003d270: 6f74 2d66 6f75 6e64 272c 206d 6573 7361 ot-found', messa\n-0003d280: 6765 3d73 7472 2865 7863 2929 2066 726f ge=str(exc)) fro\n-0003d290: 6d20 6578 630a 0a20 2020 2020 2020 2023 m exc.. #\n-0003d2a0: 2053 7562 6d69 7420 7265 7175 6573 7420 Submit request \n-0003d2b0: 696e 2061 2074 6872 6561 6420 616e 6420 in a thread and \n-0003d2c0: 6861 6e64 6c65 2065 7272 6f72 730a 2020 handle errors. \n-0003d2d0: 2020 2020 2020 7472 793a 0a20 2020 2020 try:. \n-0003d2e0: 2020 2020 2020 2072 6573 706f 6e73 6520 response \n-0003d2f0: 3d20 6177 6169 7420 6c6f 6f70 2e72 756e = await loop.run\n-0003d300: 5f69 6e5f 6578 6563 7574 6f72 284e 6f6e _in_executor(Non\n-0003d310: 652c 2073 656c 662e 7265 7175 6573 742c e, self.request,\n-0003d320: 2063 6f6e 6e65 6374 696f 6e2c 206d 6574 connection, met\n-0003d330: 686f 642c 2070 6174 682c 2068 6561 6465 hod, path, heade\n-0003d340: 7273 206f 7220 7b7d 2c20 626f 6479 290a rs or {}, body).\n-0003d350: 2020 2020 2020 2020 6578 6365 7074 2028 except (\n-0003d360: 6874 7470 2e63 6c69 656e 742e 4854 5450 http.client.HTTP\n-0003d370: 4578 6365 7074 696f 6e2c 204f 5345 7272 Exception, OSErr\n-0003d380: 6f72 2920 6173 2065 7863 3a0a 2020 2020 or) as exc:. \n-0003d390: 2020 2020 2020 2020 7261 6973 6520 4368 raise Ch\n-0003d3a0: 616e 6e65 6c45 7272 6f72 2827 7465 726d annelError('term\n-0003d3b0: 696e 6174 6564 272c 206d 6573 7361 6765 inated', message\n-0003d3c0: 3d73 7472 2865 7863 2929 2066 726f 6d20 =str(exc)) from \n-0003d3d0: 6578 630a 0a20 2020 2020 2020 2073 656c exc.. sel\n-0003d3e0: 662e 7365 6e64 5f63 6f6e 7472 6f6c 2863 f.send_control(c\n-0003d3f0: 6f6d 6d61 6e64 3d27 7265 7370 6f6e 7365 ommand='response\n-0003d400: 272c 0a20 2020 2020 2020 2020 2020 2020 ',. \n-0003d410: 2020 2020 2020 2020 2020 2020 2073 7461 sta\n-0003d420: 7475 733d 7265 7370 6f6e 7365 2e73 7461 tus=response.sta\n-0003d430: 7475 732c 0a20 2020 2020 2020 2020 2020 tus,. \n-0003d440: 2020 2020 2020 2020 2020 2020 2020 2072 r\n-0003d450: 6561 736f 6e3d 7265 7370 6f6e 7365 2e72 eason=response.r\n-0003d460: 6561 736f 6e2c 0a20 2020 2020 2020 2020 eason,. \n-0003d470: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0003d480: 2068 6561 6465 7273 3d73 656c 662e 6765 headers=self.ge\n-0003d490: 745f 6865 6164 6572 7328 7265 7370 6f6e t_headers(respon\n-0003d4a0: 7365 2c20 6269 6e61 7279 3d62 696e 6172 se, binary=binar\n-0003d4b0: 7929 290a 0a20 2020 2020 2020 2023 2052 y)).. # R\n-0003d4c0: 6563 6569 7665 2074 6865 2062 6f64 7920 eceive the body \n-0003d4d0: 616e 6420 6669 6e69 7368 2075 700a 2020 and finish up. \n-0003d4e0: 2020 2020 2020 7472 793a 0a20 2020 2020 try:. \n-0003d4f0: 2020 2020 2020 2077 6869 6c65 2054 7275 while Tru\n-0003d500: 653a 0a20 2020 2020 2020 2020 2020 2020 e:. \n-0003d510: 2020 2062 6c6f 636b 203d 2061 7761 6974 block = await\n-0003d520: 206c 6f6f 702e 7275 6e5f 696e 5f65 7865 loop.run_in_exe\n-0003d530: 6375 746f 7228 4e6f 6e65 2c20 7265 7370 cutor(None, resp\n-0003d540: 6f6e 7365 2e72 6561 6431 2c20 7365 6c66 onse.read1, self\n-0003d550: 2e42 4c4f 434b 5f53 495a 4529 0a20 2020 .BLOCK_SIZE). \n-0003d560: 2020 2020 2020 2020 2020 2020 2069 6620 if \n-0003d570: 6e6f 7420 626c 6f63 6b3a 0a20 2020 2020 not block:. \n-0003d580: 2020 2020 2020 2020 2020 2020 2020 2062 b\n-0003d590: 7265 616b 0a20 2020 2020 2020 2020 2020 reak. \n-0003d5a0: 2020 2020 2061 7761 6974 2073 656c 662e await self.\n-0003d5b0: 7772 6974 6528 626c 6f63 6b29 0a0a 2020 write(block).. \n-0003d5c0: 2020 2020 2020 2020 2020 6c6f 6767 6572 logger\n-0003d5d0: 2e64 6562 7567 2827 7265 6164 696e 6720 .debug('reading \n-0003d5e0: 7265 7370 6f6e 7365 2064 6f6e 6527 290a response done').\n-0003d5f0: 2020 2020 2020 2020 2020 2020 2320 7468 # th\n-0003d600: 6973 2072 6574 7572 6e73 2069 6d6d 6564 is returns immed\n-0003d610: 6961 7465 6c79 2061 6e64 2064 6f65 7320 iately and does \n-0003d620: 6e6f 7420 7265 6164 2061 6e79 7468 696e not read anythin\n-0003d630: 6720 6d6f 7265 2c20 6275 7420 7570 6461 g more, but upda\n-0003d640: 7465 7320 7468 6520 6874 7470 2e63 6c69 tes the http.cli\n-0003d650: 656e 7427 730a 2020 2020 2020 2020 2020 ent's. \n-0003d660: 2020 2320 696e 7465 726e 616c 2073 7461 # internal sta\n-0003d670: 7465 206d 6163 6869 6e65 2074 6f20 2272 te machine to \"r\n-0003d680: 6573 706f 6e73 6520 646f 6e65 220a 2020 esponse done\". \n-0003d690: 2020 2020 2020 2020 2020 626c 6f63 6b20 block \n-0003d6a0: 3d20 7265 7370 6f6e 7365 2e72 6561 6428 = response.read(\n-0003d6b0: 290a 2020 2020 2020 2020 2020 2020 6173 ). as\n-0003d6c0: 7365 7274 2062 6c6f 636b 203d 3d20 6227 sert block == b'\n-0003d6d0: 270a 0a20 2020 2020 2020 2020 2020 2061 '.. a\n-0003d6e0: 7761 6974 206c 6f6f 702e 7275 6e5f 696e wait loop.run_in\n-0003d6f0: 5f65 7865 6375 746f 7228 4e6f 6e65 2c20 _executor(None, \n-0003d700: 636f 6e6e 6563 7469 6f6e 2e63 6c6f 7365 connection.close\n-0003d710: 290a 2020 2020 2020 2020 6578 6365 7074 ). except\n-0003d720: 2028 6874 7470 2e63 6c69 656e 742e 4854 (http.client.HT\n-0003d730: 5450 4578 6365 7074 696f 6e2c 204f 5345 TPException, OSE\n-0003d740: 7272 6f72 2920 6173 2065 7863 3a0a 2020 rror) as exc:. \n-0003d750: 2020 2020 2020 2020 2020 7261 6973 6520 raise \n-0003d760: 4368 616e 6e65 6c45 7272 6f72 2827 7465 ChannelError('te\n-0003d770: 726d 696e 6174 6564 272c 206d 6573 7361 rminated', messa\n-0003d780: 6765 3d73 7472 2865 7863 2929 2066 726f ge=str(exc)) fro\n-0003d790: 6d20 6578 630a 0a20 2020 2020 2020 2073 m exc.. s\n-0003d7a0: 656c 662e 646f 6e65 2829 0a27 2727 2c0a elf.done().''',.\n-0003d7b0: 2020 2763 6f63 6b70 6974 2f5f 7665 6e64 'cockpit/_vend\n-0003d7c0: 6f72 2f5f 5f69 6e69 745f 5f2e 7079 273a or/__init__.py':\n-0003d7d0: 2062 7227 2727 2727 272c 0a20 2027 636f br'''''',. 'co\n-0003d7e0: 636b 7069 742f 5f76 656e 646f 722f 7379 ckpit/_vendor/sy\n-0003d7f0: 7374 656d 645f 6374 7970 6573 2f69 6e74 stemd_ctypes/int\n-0003d800: 726f 7370 6563 7469 6f6e 2e70 7927 3a20 rospection.py': \n-0003d810: 6272 2727 2723 2073 7973 7465 6d64 5f63 br'''# systemd_c\n-0003d820: 7479 7065 730a 230a 2320 436f 7079 7269 types.#.# Copyri\n-0003d830: 6768 7420 2843 2920 3230 3232 2041 6c6c ght (C) 2022 All\n-0003d840: 6973 6f6e 204b 6172 6c69 7473 6b61 7961 ison Karlitskaya\n-0003d850: 203c 616c 6c69 736f 6e2e 6b61 726c 6974 <allison.karlit\n-0003d860: 736b 6179 6140 7265 6468 6174 2e63 6f6d skaya@redhat.com\n-0003d870: 3e0a 230a 2320 5468 6973 2070 726f 6772 >.#.# This progr\n-0003d880: 616d 2069 7320 6672 6565 2073 6f66 7477 am is free softw\n-0003d890: 6172 653a 2079 6f75 2063 616e 2072 6564 are: you can red\n-0003d8a0: 6973 7472 6962 7574 6520 6974 2061 6e64 istribute it and\n-0003d8b0: 2f6f 7220 6d6f 6469 6679 0a23 2069 7420 /or modify.# it \n-0003d8c0: 756e 6465 7220 7468 6520 7465 726d 7320 under the terms \n-0003d8d0: 6f66 2074 6865 2047 4e55 2047 656e 6572 of the GNU Gener\n-0003d8e0: 616c 2050 7562 6c69 6320 4c69 6365 6e73 al Public Licens\n-0003d8f0: 6520 6173 2070 7562 6c69 7368 6564 2062 e as published b\n-0003d900: 790a 2320 7468 6520 4672 6565 2053 6f66 y.# the Free Sof\n-0003d910: 7477 6172 6520 466f 756e 6461 7469 6f6e tware Foundation\n-0003d920: 2c20 6569 7468 6572 2076 6572 7369 6f6e , either version\n-0003d930: 2033 206f 6620 7468 6520 4c69 6365 6e73 3 of the Licens\n-0003d940: 652c 206f 720a 2320 2861 7420 796f 7572 e, or.# (at your\n-0003d950: 206f 7074 696f 6e29 2061 6e79 206c 6174 option) any lat\n-0003d960: 6572 2076 6572 7369 6f6e 2e0a 230a 2320 er version..#.# \n-0003d970: 5468 6973 2070 726f 6772 616d 2069 7320 This program is \n-0003d980: 6469 7374 7269 6275 7465 6420 696e 2074 distributed in t\n-0003d990: 6865 2068 6f70 6520 7468 6174 2069 7420 he hope that it \n-0003d9a0: 7769 6c6c 2062 6520 7573 6566 756c 2c0a will be useful,.\n-0003d9b0: 2320 6275 7420 5749 5448 4f55 5420 414e # but WITHOUT AN\n-0003d9c0: 5920 5741 5252 414e 5459 3b20 7769 7468 Y WARRANTY; with\n-0003d9d0: 6f75 7420 6576 656e 2074 6865 2069 6d70 out even the imp\n-0003d9e0: 6c69 6564 2077 6172 7261 6e74 7920 6f66 lied warranty of\n-0003d9f0: 0a23 204d 4552 4348 414e 5441 4249 4c49 .# MERCHANTABILI\n-0003da00: 5459 206f 7220 4649 544e 4553 5320 464f TY or FITNESS FO\n-0003da10: 5220 4120 5041 5254 4943 554c 4152 2050 R A PARTICULAR P\n-0003da20: 5552 504f 5345 2e20 2053 6565 2074 6865 URPOSE. See the\n-0003da30: 0a23 2047 4e55 2047 656e 6572 616c 2050 .# GNU General P\n-0003da40: 7562 6c69 6320 4c69 6365 6e73 6520 666f ublic License fo\n-0003da50: 7220 6d6f 7265 2064 6574 6169 6c73 2e0a r more details..\n-0003da60: 230a 2320 596f 7520 7368 6f75 6c64 2068 #.# You should h\n-0003da70: 6176 6520 7265 6365 6976 6564 2061 2063 ave received a c\n-0003da80: 6f70 7920 6f66 2074 6865 2047 4e55 2047 opy of the GNU G\n-0003da90: 656e 6572 616c 2050 7562 6c69 6320 4c69 eneral Public Li\n-0003daa0: 6365 6e73 650a 2320 616c 6f6e 6720 7769 cense.# along wi\n-0003dab0: 7468 2074 6869 7320 7072 6f67 7261 6d2e th this program.\n-0003dac0: 2020 4966 206e 6f74 2c20 7365 6520 3c68 If not, see <h\n-0003dad0: 7474 703a 2f2f 7777 772e 676e 752e 6f72 ttp://www.gnu.or\n-0003dae0: 672f 6c69 6365 6e73 6573 2f3e 2e0a 0a69 g/licenses/>...i\n-0003daf0: 6d70 6f72 7420 786d 6c2e 6574 7265 652e mport xml.etree.\n-0003db00: 456c 656d 656e 7454 7265 6520 6173 2045 ElementTree as E\n-0003db10: 540a 0a0a 6465 6620 7061 7273 655f 6d65 T...def parse_me\n-0003db20: 7468 6f64 286d 6574 686f 6429 3a0a 2020 thod(method):. \n-0003db30: 2020 7265 7475 726e 207b 0a20 2020 2020 return {. \n-0003db40: 2020 2022 696e 223a 205b 7461 672e 6174 \"in\": [tag.at\n-0003db50: 7472 6962 5b27 7479 7065 275d 2066 6f72 trib['type'] for\n-0003db60: 2074 6167 2069 6e20 6d65 7468 6f64 2e66 tag in method.f\n-0003db70: 696e 6461 6c6c 2822 6172 6722 2920 6966 indall(\"arg\") if\n-0003db80: 2074 6167 2e67 6574 2827 6469 7265 6374 tag.get('direct\n-0003db90: 696f 6e27 2c20 2769 6e27 2920 3d3d 2027 ion', 'in') == '\n-0003dba0: 696e 275d 2c0a 2020 2020 2020 2020 226f in'],. \"o\n-0003dbb0: 7574 223a 205b 7461 672e 6174 7472 6962 ut\": [tag.attrib\n-0003dbc0: 5b27 7479 7065 275d 2066 6f72 2074 6167 ['type'] for tag\n-0003dbd0: 2069 6e20 6d65 7468 6f64 2e66 696e 6461 in method.finda\n-0003dbe0: 6c6c 2822 6172 675b 4064 6972 6563 7469 ll(\"arg[@directi\n-0003dbf0: 6f6e 3d27 6f75 7427 5d22 295d 0a20 2020 on='out']\")]. \n-0003dc00: 207d 0a0a 0a64 6566 2070 6172 7365 5f70 }...def parse_p\n-0003dc10: 726f 7065 7274 7928 7072 6f70 293a 0a20 roperty(prop):. \n-0003dc20: 2020 2072 6574 7572 6e20 7b0a 2020 2020 return {. \n-0003dc30: 2020 2020 2266 6c61 6773 223a 2027 7727 \"flags\": 'w'\n-0003dc40: 2069 6620 7072 6f70 2e61 7474 7269 622e if prop.attrib.\n-0003dc50: 6765 7428 2761 6363 6573 7327 2920 3d3d get('access') ==\n-0003dc60: 2027 7772 6974 6527 2065 6c73 6520 2772 'write' else 'r\n-0003dc70: 272c 0a20 2020 2020 2020 2022 7479 7065 ',. \"type\n-0003dc80: 223a 2070 726f 702e 6174 7472 6962 5b27 \": prop.attrib['\n-0003dc90: 7479 7065 275d 0a20 2020 207d 0a0a 0a64 type']. }...d\n-0003dca0: 6566 2070 6172 7365 5f73 6967 6e61 6c28 ef parse_signal(\n-0003dcb0: 7369 676e 616c 293a 0a20 2020 2072 6574 signal):. ret\n-0003dcc0: 7572 6e20 7b22 696e 223a 205b 7461 672e urn {\"in\": [tag.\n-0003dcd0: 6174 7472 6962 5b27 7479 7065 275d 2066 attrib['type'] f\n-0003dce0: 6f72 2074 6167 2069 6e20 7369 676e 616c or tag in signal\n-0003dcf0: 2e66 696e 6461 6c6c 2822 6172 6722 295d .findall(\"arg\")]\n-0003dd00: 7d0a 0a0a 6465 6620 7061 7273 655f 696e }...def parse_in\n-0003dd10: 7465 7266 6163 6528 696e 7465 7266 6163 terface(interfac\n-0003dd20: 6529 3a0a 2020 2020 7265 7475 726e 207b e):. return {\n-0003dd30: 0a20 2020 2020 2020 2022 6d65 7468 6f64 . \"method\n-0003dd40: 7322 3a20 7b74 6167 2e61 7474 7269 625b s\": {tag.attrib[\n-0003dd50: 276e 616d 6527 5d3a 2070 6172 7365 5f6d 'name']: parse_m\n-0003dd60: 6574 686f 6428 7461 6729 2066 6f72 2074 ethod(tag) for t\n-0003dd70: 6167 2069 6e20 696e 7465 7266 6163 652e ag in interface.\n-0003dd80: 6669 6e64 616c 6c28 276d 6574 686f 6427 findall('method'\n-0003dd90: 297d 2c0a 2020 2020 2020 2020 2270 726f )},. \"pro\n-0003dda0: 7065 7274 6965 7322 3a20 7b74 6167 2e61 perties\": {tag.a\n-0003ddb0: 7474 7269 625b 276e 616d 6527 5d3a 2070 ttrib['name']: p\n-0003ddc0: 6172 7365 5f70 726f 7065 7274 7928 7461 arse_property(ta\n-0003ddd0: 6729 2066 6f72 2074 6167 2069 6e20 696e g) for tag in in\n-0003dde0: 7465 7266 6163 652e 6669 6e64 616c 6c28 terface.findall(\n-0003ddf0: 2770 726f 7065 7274 7927 297d 2c0a 2020 'property')},. \n-0003de00: 2020 2020 2020 2273 6967 6e61 6c73 223a \"signals\":\n-0003de10: 207b 7461 672e 6174 7472 6962 5b27 6e61 {tag.attrib['na\n-0003de20: 6d65 275d 3a20 7061 7273 655f 7369 676e me']: parse_sign\n-0003de30: 616c 2874 6167 2920 666f 7220 7461 6720 al(tag) for tag \n-0003de40: 696e 2069 6e74 6572 6661 6365 2e66 696e in interface.fin\n-0003de50: 6461 6c6c 2827 7369 676e 616c 2729 7d0a dall('signal')}.\n-0003de60: 2020 2020 7d0a 0a0a 6465 6620 7061 7273 }...def pars\n-0003de70: 655f 786d 6c28 786d 6c29 3a0a 2020 2020 e_xml(xml):. \n-0003de80: 6574 203d 2045 542e 6672 6f6d 7374 7269 et = ET.fromstri\n-0003de90: 6e67 2878 6d6c 290a 2020 2020 7265 7475 ng(xml). retu\n-0003dea0: 726e 207b 7461 672e 6174 7472 6962 5b27 rn {tag.attrib['\n-0003deb0: 6e61 6d65 275d 3a20 7061 7273 655f 696e name']: parse_in\n-0003dec0: 7465 7266 6163 6528 7461 6729 2066 6f72 terface(tag) for\n-0003ded0: 2074 6167 2069 6e20 6574 2e66 696e 6461 tag in et.finda\n-0003dee0: 6c6c 2827 696e 7465 7266 6163 6527 297d ll('interface')}\n-0003def0: 0a0a 0a23 2050 7265 7465 6e64 206c 696b ...# Pretend lik\n-0003df00: 6520 7468 6973 2069 7320 6120 6c69 7474 e this is a litt\n-0003df10: 6c65 2062 6974 2066 756e 6374 696f 6e61 le bit functiona\n-0003df20: 6c0a 6465 6620 656c 656d 656e 7428 7461 l.def element(ta\n-0003df30: 672c 2063 6869 6c64 7265 6e3d 2829 2c20 g, children=(), \n-0003df40: 2a2a 6b77 6172 6773 293a 0a20 2020 2074 **kwargs):. t\n-0003df50: 6167 203d 2045 542e 456c 656d 656e 7428 ag = ET.Element(\n-0003df60: 7461 672c 206b 7761 7267 7329 0a20 2020 tag, kwargs). \n-0003df70: 2074 6167 2e65 7874 656e 6428 6368 696c tag.extend(chil\n-0003df80: 6472 656e 290a 2020 2020 7265 7475 726e dren). return\n-0003df90: 2074 6167 0a0a 0a64 6566 206d 6574 686f tag...def metho\n-0003dfa0: 645f 746f 5f78 6d6c 286e 616d 652c 206d d_to_xml(name, m\n-0003dfb0: 6574 686f 645f 696e 666f 293a 0a20 2020 ethod_info):. \n-0003dfc0: 2072 6574 7572 6e20 656c 656d 656e 7428 return element(\n-0003dfd0: 276d 6574 686f 6427 2c20 6e61 6d65 3d6e 'method', name=n\n-0003dfe0: 616d 652c 0a20 2020 2020 2020 2020 2020 ame,. \n-0003dff0: 2020 2020 2020 2020 6368 696c 6472 656e children\n-0003e000: 3d5b 0a20 2020 2020 2020 2020 2020 2020 =[. \n-0003e010: 2020 2020 2020 2020 2020 656c 656d 656e elemen\n-0003e020: 7428 2761 7267 272c 2074 7970 653d 6172 t('arg', type=ar\n-0003e030: 675f 7479 7065 2c20 6469 7265 6374 696f g_type, directio\n-0003e040: 6e3d 6469 7265 6374 696f 6e29 0a20 2020 n=direction). \n-0003e050: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0003e060: 2020 2020 666f 7220 6469 7265 6374 696f for directio\n-0003e070: 6e20 696e 205b 2769 6e27 2c20 276f 7574 n in ['in', 'out\n-0003e080: 275d 0a20 2020 2020 2020 2020 2020 2020 ']. \n-0003e090: 2020 2020 2020 2020 2020 666f 7220 6172 for ar\n-0003e0a0: 675f 7479 7065 2069 6e20 6d65 7468 6f64 g_type in method\n-0003e0b0: 5f69 6e66 6f5b 6469 7265 6374 696f 6e5d _info[direction]\n-0003e0c0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-0003e0d0: 2020 2020 5d29 0a0a 0a64 6566 2070 726f ])...def pro\n-0003e0e0: 7065 7274 795f 746f 5f78 6d6c 286e 616d perty_to_xml(nam\n-0003e0f0: 652c 2070 726f 7065 7274 795f 696e 666f e, property_info\n-0003e100: 293a 0a20 2020 2072 6574 7572 6e20 656c ):. return el\n-0003e110: 656d 656e 7428 2770 726f 7065 7274 7927 ement('property'\n-0003e120: 2c20 6e61 6d65 3d6e 616d 652c 0a20 2020 , name=name,. \n-0003e130: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0003e140: 6163 6365 7373 3d27 7772 6974 6527 2069 access='write' i\n-0003e150: 6620 7072 6f70 6572 7479 5f69 6e66 6f5b f property_info[\n-0003e160: 2766 6c61 6773 275d 203d 3d20 2777 2720 'flags'] == 'w' \n-0003e170: 656c 7365 2027 7265 6164 272c 0a20 2020 else 'read',. \n-0003e180: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0003e190: 7479 7065 3d70 726f 7065 7274 795f 696e type=property_in\n-0003e1a0: 666f 5b27 7479 7065 275d 290a 0a0a 6465 fo['type'])...de\n-0003e1b0: 6620 7369 676e 616c 5f74 6f5f 786d 6c28 f signal_to_xml(\n-0003e1c0: 6e61 6d65 2c20 7369 676e 616c 5f69 6e66 name, signal_inf\n-0003e1d0: 6f29 3a0a 2020 2020 7265 7475 726e 2065 o):. return e\n-0003e1e0: 6c65 6d65 6e74 2827 7369 676e 616c 272c lement('signal',\n-0003e1f0: 206e 616d 653d 6e61 6d65 2c0a 2020 2020 name=name,. \n-0003e200: 2020 2020 2020 2020 2020 2020 2020 2063 c\n-0003e210: 6869 6c64 7265 6e3d 5b0a 2020 2020 2020 hildren=[. \n-0003e220: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0003e230: 2065 6c65 6d65 6e74 2827 6172 6727 2c20 element('arg', \n-0003e240: 7479 7065 3d61 7267 5f74 7970 6529 2066 type=arg_type) f\n-0003e250: 6f72 2061 7267 5f74 7970 6520 696e 2073 or arg_type in s\n-0003e260: 6967 6e61 6c5f 696e 666f 5b27 696e 275d ignal_info['in']\n-0003e270: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-0003e280: 2020 2020 5d29 0a0a 0a64 6566 2069 6e74 ])...def int\n-0003e290: 6572 6661 6365 5f74 6f5f 786d 6c28 6e61 erface_to_xml(na\n-0003e2a0: 6d65 2c20 696e 7465 7266 6163 655f 696e me, interface_in\n-0003e2b0: 666f 293a 0a20 2020 2072 6574 7572 6e20 fo):. return \n-0003e2c0: 656c 656d 656e 7428 2769 6e74 6572 6661 element('interfa\n-0003e2d0: 6365 272c 206e 616d 653d 6e61 6d65 2c0a ce', name=name,.\n-0003e2e0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0003e2f0: 2020 2063 6869 6c64 7265 6e3d 5b0a 2020 children=[. \n-0003e300: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0003e310: 2020 2020 202a 286d 6574 686f 645f 746f *(method_to\n-0003e320: 5f78 6d6c 286e 616d 652c 2069 6e66 6f29 _xml(name, info)\n-0003e330: 2066 6f72 206e 616d 652c 2069 6e66 6f20 for name, info \n-0003e340: 696e 2069 6e74 6572 6661 6365 5f69 6e66 in interface_inf\n-0003e350: 6f5b 276d 6574 686f 6473 275d 2e69 7465 o['methods'].ite\n-0003e360: 6d73 2829 292c 0a20 2020 2020 2020 2020 ms()),. \n-0003e370: 2020 2020 2020 2020 2020 2020 2020 2a28 *(\n-0003e380: 7072 6f70 6572 7479 5f74 6f5f 786d 6c28 property_to_xml(\n-0003e390: 6e61 6d65 2c20 696e 666f 2920 666f 7220 name, info) for \n-0003e3a0: 6e61 6d65 2c20 696e 666f 2069 6e20 696e name, info in in\n-0003e3b0: 7465 7266 6163 655f 696e 666f 5b27 7072 terface_info['pr\n-0003e3c0: 6f70 6572 7469 6573 275d 2e69 7465 6d73 operties'].items\n-0003e3d0: 2829 292c 0a20 2020 2020 2020 2020 2020 ()),. \n-0003e3e0: 2020 2020 2020 2020 2020 2020 2a28 7369 *(si\n-0003e3f0: 676e 616c 5f74 6f5f 786d 6c28 6e61 6d65 gnal_to_xml(name\n-0003e400: 2c20 696e 666f 2920 666f 7220 6e61 6d65 , info) for name\n-0003e410: 2c20 696e 666f 2069 6e20 696e 7465 7266 , info in interf\n-0003e420: 6163 655f 696e 666f 5b27 7369 676e 616c ace_info['signal\n-0003e430: 7327 5d2e 6974 656d 7328 2929 2c0a 2020 s'].items()),. \n-0003e440: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0003e450: 205d 290a 0a0a 6465 6620 746f 5f78 6d6c ])...def to_xml\n-0003e460: 2869 6e74 6572 6661 6365 7329 3a0a 2020 (interfaces):. \n-0003e470: 2020 6e6f 6465 203d 2065 6c65 6d65 6e74 node = element\n-0003e480: 2827 6e6f 6465 272c 2063 6869 6c64 7265 ('node', childre\n-0003e490: 6e3d 2869 6e74 6572 6661 6365 5f74 6f5f n=(interface_to_\n-0003e4a0: 786d 6c28 6e61 6d65 2c20 6d65 6d62 6572 xml(name, member\n-0003e4b0: 7329 2066 6f72 206e 616d 652c 206d 656d s) for name, mem\n-0003e4c0: 6265 7273 2069 6e20 696e 7465 7266 6163 bers in interfac\n-0003e4d0: 6573 2e69 7465 6d73 2829 2929 0a20 2020 es.items())). \n-0003e4e0: 2072 6574 7572 6e20 4554 2e74 6f73 7472 return ET.tostr\n-0003e4f0: 696e 6728 6e6f 6465 2c20 656e 636f 6469 ing(node, encodi\n-0003e500: 6e67 3d27 756e 6963 6f64 6527 290a 2727 ng='unicode').''\n-0003e510: 272c 0a20 2027 636f 636b 7069 742f 5f76 ',. 'cockpit/_v\n-0003e520: 656e 646f 722f 7379 7374 656d 645f 6374 endor/systemd_ct\n-0003e530: 7970 6573 2f65 7665 6e74 2e70 7927 3a20 ypes/event.py': \n-0003e540: 6272 2727 2723 2073 7973 7465 6d64 5f63 br'''# systemd_c\n-0003e550: 7479 7065 730a 230a 2320 436f 7079 7269 types.#.# Copyri\n-0003e560: 6768 7420 2843 2920 3230 3232 2041 6c6c ght (C) 2022 All\n-0003e570: 6973 6f6e 204b 6172 6c69 7473 6b61 7961 ison Karlitskaya\n-0003e580: 203c 616c 6c69 736f 6e2e 6b61 726c 6974 <allison.karlit\n-0003e590: 736b 6179 6140 7265 6468 6174 2e63 6f6d skaya@redhat.com\n-0003e5a0: 3e0a 230a 2320 5468 6973 2070 726f 6772 >.#.# This progr\n-0003e5b0: 616d 2069 7320 6672 6565 2073 6f66 7477 am is free softw\n-0003e5c0: 6172 653a 2079 6f75 2063 616e 2072 6564 are: you can red\n-0003e5d0: 6973 7472 6962 7574 6520 6974 2061 6e64 istribute it and\n-0003e5e0: 2f6f 7220 6d6f 6469 6679 0a23 2069 7420 /or modify.# it \n-0003e5f0: 756e 6465 7220 7468 6520 7465 726d 7320 under the terms \n-0003e600: 6f66 2074 6865 2047 4e55 2047 656e 6572 of the GNU Gener\n-0003e610: 616c 2050 7562 6c69 6320 4c69 6365 6e73 al Public Licens\n-0003e620: 6520 6173 2070 7562 6c69 7368 6564 2062 e as published b\n-0003e630: 790a 2320 7468 6520 4672 6565 2053 6f66 y.# the Free Sof\n-0003e640: 7477 6172 6520 466f 756e 6461 7469 6f6e tware Foundation\n-0003e650: 2c20 6569 7468 6572 2076 6572 7369 6f6e , either version\n-0003e660: 2033 206f 6620 7468 6520 4c69 6365 6e73 3 of the Licens\n-0003e670: 652c 206f 720a 2320 2861 7420 796f 7572 e, or.# (at your\n-0003e680: 206f 7074 696f 6e29 2061 6e79 206c 6174 option) any lat\n-0003e690: 6572 2076 6572 7369 6f6e 2e0a 230a 2320 er version..#.# \n-0003e6a0: 5468 6973 2070 726f 6772 616d 2069 7320 This program is \n-0003e6b0: 6469 7374 7269 6275 7465 6420 696e 2074 distributed in t\n-0003e6c0: 6865 2068 6f70 6520 7468 6174 2069 7420 he hope that it \n-0003e6d0: 7769 6c6c 2062 6520 7573 6566 756c 2c0a will be useful,.\n-0003e6e0: 2320 6275 7420 5749 5448 4f55 5420 414e # but WITHOUT AN\n-0003e6f0: 5920 5741 5252 414e 5459 3b20 7769 7468 Y WARRANTY; with\n-0003e700: 6f75 7420 6576 656e 2074 6865 2069 6d70 out even the imp\n-0003e710: 6c69 6564 2077 6172 7261 6e74 7920 6f66 lied warranty of\n-0003e720: 0a23 204d 4552 4348 414e 5441 4249 4c49 .# MERCHANTABILI\n-0003e730: 5459 206f 7220 4649 544e 4553 5320 464f TY or FITNESS FO\n-0003e740: 5220 4120 5041 5254 4943 554c 4152 2050 R A PARTICULAR P\n-0003e750: 5552 504f 5345 2e20 2053 6565 2074 6865 URPOSE. See the\n-0003e760: 0a23 2047 4e55 2047 656e 6572 616c 2050 .# GNU General P\n-0003e770: 7562 6c69 6320 4c69 6365 6e73 6520 666f ublic License fo\n-0003e780: 7220 6d6f 7265 2064 6574 6169 6c73 2e0a r more details..\n-0003e790: 230a 2320 596f 7520 7368 6f75 6c64 2068 #.# You should h\n-0003e7a0: 6176 6520 7265 6365 6976 6564 2061 2063 ave received a c\n-0003e7b0: 6f70 7920 6f66 2074 6865 2047 4e55 2047 opy of the GNU G\n-0003e7c0: 656e 6572 616c 2050 7562 6c69 6320 4c69 eneral Public Li\n-0003e7d0: 6365 6e73 650a 2320 616c 6f6e 6720 7769 cense.# along wi\n-0003e7e0: 7468 2074 6869 7320 7072 6f67 7261 6d2e th this program.\n-0003e7f0: 2020 4966 206e 6f74 2c20 7365 6520 3c68 If not, see <h\n-0003e800: 7474 703a 2f2f 7777 772e 676e 752e 6f72 ttp://www.gnu.or\n-0003e810: 672f 6c69 6365 6e73 6573 2f3e 2e0a 0a69 g/licenses/>...i\n-0003e820: 6d70 6f72 7420 6173 796e 6369 6f0a 696d mport asyncio.im\n-0003e830: 706f 7274 2073 656c 6563 746f 7273 0a69 port selectors.i\n-0003e840: 6d70 6f72 7420 7379 730a 6672 6f6d 2074 mport sys.from t\n-0003e850: 7970 696e 6720 696d 706f 7274 2043 616c yping import Cal\n-0003e860: 6c61 626c 652c 2043 6c61 7373 5661 722c lable, ClassVar,\n-0003e870: 2043 6f72 6f75 7469 6e65 2c20 4c69 7374 Coroutine, List\n-0003e880: 2c20 4f70 7469 6f6e 616c 2c20 5475 706c , Optional, Tupl\n-0003e890: 650a 0a66 726f 6d20 2e20 696d 706f 7274 e..from . import\n-0003e8a0: 2069 6e6f 7469 6679 2c20 6c69 6273 7973 inotify, libsys\n-0003e8b0: 7465 6d64 0a66 726f 6d20 2e6c 6962 7261 temd.from .libra\n-0003e8c0: 7279 7772 6170 7065 7220 696d 706f 7274 rywrapper import\n-0003e8d0: 2052 6566 6572 656e 6365 2c20 5573 6572 Reference, User\n-0003e8e0: 4461 7461 2c20 6279 7265 660a 0a0a 636c Data, byref...cl\n-0003e8f0: 6173 7320 4576 656e 7428 6c69 6273 7973 ass Event(libsys\n-0003e900: 7465 6d64 2e73 645f 6576 656e 7429 3a0a temd.sd_event):.\n-0003e910: 2020 2020 636c 6173 7320 536f 7572 6365 class Source\n-0003e920: 286c 6962 7379 7374 656d 642e 7364 5f65 (libsystemd.sd_e\n-0003e930: 7665 6e74 5f73 6f75 7263 6529 3a0a 2020 vent_source):. \n-0003e940: 2020 2020 2020 6465 6620 6361 6e63 656c def cancel\n-0003e950: 2873 656c 6629 202d 3e20 4e6f 6e65 3a0a (self) -> None:.\n-0003e960: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n-0003e970: 2e5f 756e 7265 6628 290a 2020 2020 2020 ._unref(). \n-0003e980: 2020 2020 2020 7365 6c66 2e76 616c 7565 self.value\n-0003e990: 203d 204e 6f6e 650a 0a20 2020 205f 6465 = None.. _de\n-0003e9a0: 6661 756c 745f 696e 7374 616e 6365 3a20 fault_instance: \n-0003e9b0: 436c 6173 7356 6172 5b4f 7074 696f 6e61 ClassVar[Optiona\n-0003e9c0: 6c5b 2745 7665 6e74 275d 5d20 3d20 4e6f l['Event']] = No\n-0003e9d0: 6e65 0a0a 2020 2020 4073 7461 7469 636d ne.. @staticm\n-0003e9e0: 6574 686f 640a 2020 2020 6465 6620 6465 ethod. def de\n-0003e9f0: 6661 756c 7428 2920 2d3e 2027 4576 656e fault() -> 'Even\n-0003ea00: 7427 3a0a 2020 2020 2020 2020 6966 2045 t':. if E\n-0003ea10: 7665 6e74 2e5f 6465 6661 756c 745f 696e vent._default_in\n-0003ea20: 7374 616e 6365 2069 7320 4e6f 6e65 3a0a stance is None:.\n-0003ea30: 2020 2020 2020 2020 2020 2020 4576 656e Even\n-0003ea40: 742e 5f64 6566 6175 6c74 5f69 6e73 7461 t._default_insta\n-0003ea50: 6e63 6520 3d20 4576 656e 7428 290a 2020 nce = Event(). \n-0003ea60: 2020 2020 2020 2020 2020 4576 656e 742e Event.\n-0003ea70: 5f64 6566 6175 6c74 2862 7972 6566 2845 _default(byref(E\n-0003ea80: 7665 6e74 2e5f 6465 6661 756c 745f 696e vent._default_in\n-0003ea90: 7374 616e 6365 2929 0a20 2020 2020 2020 stance)). \n-0003eaa0: 2072 6574 7572 6e20 4576 656e 742e 5f64 return Event._d\n-0003eab0: 6566 6175 6c74 5f69 6e73 7461 6e63 650a efault_instance.\n-0003eac0: 0a20 2020 2049 6e6f 7469 6679 4861 6e64 . InotifyHand\n-0003ead0: 6c65 7220 3d20 4361 6c6c 6162 6c65 5b5b ler = Callable[[\n-0003eae0: 696e 6f74 6966 792e 4576 656e 742c 2069 inotify.Event, i\n-0003eaf0: 6e74 2c20 4f70 7469 6f6e 616c 5b62 7974 nt, Optional[byt\n-0003eb00: 6573 5d5d 2c20 4e6f 6e65 5d0a 0a20 2020 es]], None].. \n-0003eb10: 2063 6c61 7373 2049 6e6f 7469 6679 536f class InotifySo\n-0003eb20: 7572 6365 2853 6f75 7263 6529 3a0a 2020 urce(Source):. \n-0003eb30: 2020 2020 2020 6465 6620 5f5f 696e 6974 def __init\n-0003eb40: 5f5f 2873 656c 662c 2068 616e 646c 6572 __(self, handler\n-0003eb50: 3a20 2745 7665 6e74 2e49 6e6f 7469 6679 : 'Event.Inotify\n-0003eb60: 4861 6e64 6c65 7227 2920 2d3e 204e 6f6e Handler') -> Non\n-0003eb70: 653a 0a20 2020 2020 2020 2020 2020 2064 e:. d\n-0003eb80: 6566 2063 616c 6c62 6163 6b28 736f 7572 ef callback(sour\n-0003eb90: 6365 3a20 6c69 6273 7973 7465 6d64 2e73 ce: libsystemd.s\n-0003eba0: 645f 6576 656e 745f 736f 7572 6365 2c0a d_event_source,.\n-0003ebb0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0003ebc0: 2020 2020 2020 2020 205f 6576 656e 743a _event:\n-0003ebd0: 2052 6566 6572 656e 6365 5b69 6e6f 7469 Reference[inoti\n-0003ebe0: 6679 2e69 6e6f 7469 6679 5f65 7665 6e74 fy.inotify_event\n-0003ebf0: 5d2c 0a20 2020 2020 2020 2020 2020 2020 ],. \n-0003ec00: 2020 2020 2020 2020 2020 2020 7573 6572 user\n-0003ec10: 6461 7461 3a20 5573 6572 4461 7461 2920 data: UserData) \n-0003ec20: 2d3e 2069 6e74 3a0a 2020 2020 2020 2020 -> int:. \n-0003ec30: 2020 2020 2020 2020 6576 656e 7420 3d20 event = \n-0003ec40: 5f65 7665 6e74 2e63 6f6e 7465 6e74 730a _event.contents.\n-0003ec50: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0003ec60: 6861 6e64 6c65 7228 696e 6f74 6966 792e handler(inotify.\n-0003ec70: 4576 656e 7428 6576 656e 742e 6d61 736b Event(event.mask\n-0003ec80: 292c 2065 7665 6e74 2e63 6f6f 6b69 652c ), event.cookie,\n-0003ec90: 2065 7665 6e74 2e6e 616d 6529 0a20 2020 event.name). \n-0003eca0: 2020 2020 2020 2020 2020 2020 2072 6574 ret\n-0003ecb0: 7572 6e20 300a 2020 2020 2020 2020 2020 urn 0. \n-0003ecc0: 2020 7365 6c66 2e74 7261 6d70 6f6c 696e self.trampolin\n-0003ecd0: 6520 3d20 6c69 6273 7973 7465 6d64 2e73 e = libsystemd.s\n-0003ece0: 645f 6576 656e 745f 696e 6f74 6966 795f d_event_inotify_\n-0003ecf0: 6861 6e64 6c65 725f 7428 6361 6c6c 6261 handler_t(callba\n-0003ed00: 636b 290a 0a20 2020 2064 6566 2061 6464 ck).. def add\n-0003ed10: 5f69 6e6f 7469 6679 2873 656c 662c 2070 _inotify(self, p\n-0003ed20: 6174 683a 2073 7472 2c20 6d61 736b 3a20 ath: str, mask: \n-0003ed30: 696e 6f74 6966 792e 4576 656e 742c 2068 inotify.Event, h\n-0003ed40: 616e 646c 6572 3a20 496e 6f74 6966 7948 andler: InotifyH\n-0003ed50: 616e 646c 6572 2920 2d3e 2049 6e6f 7469 andler) -> Inoti\n-0003ed60: 6679 536f 7572 6365 3a0a 2020 2020 2020 fySource:. \n-0003ed70: 2020 736f 7572 6365 203d 2045 7665 6e74 source = Event\n-0003ed80: 2e49 6e6f 7469 6679 536f 7572 6365 2868 .InotifySource(h\n-0003ed90: 616e 646c 6572 290a 2020 2020 2020 2020 andler). \n-0003eda0: 7365 6c66 2e5f 6164 645f 696e 6f74 6966 self._add_inotif\n-0003edb0: 7928 6279 7265 6628 736f 7572 6365 292c y(byref(source),\n-0003edc0: 2070 6174 682c 206d 6173 6b2c 2073 6f75 path, mask, sou\n-0003edd0: 7263 652e 7472 616d 706f 6c69 6e65 2c20 rce.trampoline, \n-0003ede0: 736f 7572 6365 2e75 7365 7264 6174 6129 source.userdata)\n-0003edf0: 0a20 2020 2020 2020 2072 6574 7572 6e20 . return \n-0003ee00: 736f 7572 6365 0a0a 2020 2020 6465 6620 source.. def \n-0003ee10: 6164 645f 696e 6f74 6966 795f 6664 2873 add_inotify_fd(s\n-0003ee20: 656c 662c 2066 643a 2069 6e74 2c20 6d61 elf, fd: int, ma\n-0003ee30: 736b 3a20 696e 6f74 6966 792e 4576 656e sk: inotify.Even\n-0003ee40: 742c 2068 616e 646c 6572 3a20 496e 6f74 t, handler: Inot\n-0003ee50: 6966 7948 616e 646c 6572 2920 2d3e 2049 ifyHandler) -> I\n-0003ee60: 6e6f 7469 6679 536f 7572 6365 3a0a 2020 notifySource:. \n-0003ee70: 2020 2020 2020 2320 4841 434b 3a20 7364 # HACK: sd\n-0003ee80: 5f65 7665 6e74 5f61 6464 5f69 6e6f 7469 _event_add_inoti\n-0003ee90: 6679 5f66 6428 2920 676f 7420 6164 6465 fy_fd() got adde\n-0003eea0: 6420 696e 2032 3530 2c20 7768 6963 6820 d in 250, which \n-0003eeb0: 6973 2074 6f6f 206e 6577 2e20 2046 616b is too new. Fak\n-0003eec0: 6520 6974 2e0a 2020 2020 2020 2020 7265 e it.. re\n-0003eed0: 7475 726e 2073 656c 662e 6164 645f 696e turn self.add_in\n-0003eee0: 6f74 6966 7928 6627 2f70 726f 632f 7365 otify(f'/proc/se\n-0003eef0: 6c66 2f66 642f 7b66 647d 272c 206d 6173 lf/fd/{fd}', mas\n-0003ef00: 6b2c 2068 616e 646c 6572 290a 0a0a 2320 k, handler)...# \n-0003ef10: 5468 6973 2069 7320 616c 6c20 6120 6269 This is all a bi\n-0003ef20: 7420 6d6f 7265 2061 776b 7761 7264 2074 t more awkward t\n-0003ef30: 6861 6e20 6974 2073 686f 756c 6420 6861 han it should ha\n-0003ef40: 7665 2074 6f20 6265 3a20 7379 7374 656d ve to be: system\n-0003ef50: 6427 7320 6576 656e 740a 2320 6c6f 6f70 d's event.# loop\n-0003ef60: 2063 6861 696e 696e 6720 6d6f 6465 6c20 chaining model \n-0003ef70: 6973 2064 6573 6967 6e65 6420 666f 7220 is designed for \n-0003ef80: 676c 6962 2773 2070 7265 7061 7265 2f63 glib's prepare/c\n-0003ef90: 6865 636b 2f64 6973 7061 7463 6820 7061 heck/dispatch pa\n-0003efa0: 7261 6469 676d 3b0a 2320 6661 696c 696e radigm;.# failin\n-0003efb0: 6720 746f 2063 616c 6c20 7072 6570 6172 g to call prepar\n-0003efc0: 6528 2920 6361 6e20 6c65 6164 2074 6f20 e() can lead to \n-0003efd0: 6465 6164 6c6f 636b 732c 2066 6f72 2065 deadlocks, for e\n-0003efe0: 7861 6d70 6c65 2e0a 230a 2320 4861 636b xample..#.# Hack\n-0003eff0: 2061 2073 656c 6563 746f 7220 7375 6263 a selector subc\n-0003f000: 6c61 7373 2077 6869 6368 2063 616c 6c73 lass which calls\n-0003f010: 2070 7265 7061 7265 2829 2062 6566 6f72 prepare() befor\n-0003f020: 6520 736c 6565 7069 6e67 2061 6e64 2074 e sleeping and t\n-0003f030: 6869 7320 666f 7220 7573 2e0a 636c 6173 his for us..clas\n-0003f040: 7320 5365 6c65 6374 6f72 2873 656c 6563 s Selector(selec\n-0003f050: 746f 7273 2e44 6566 6175 6c74 5365 6c65 tors.DefaultSele\n-0003f060: 6374 6f72 293a 0a20 2020 2064 6566 205f ctor):. def _\n-0003f070: 5f69 6e69 745f 5f28 7365 6c66 2c20 6576 _init__(self, ev\n-0003f080: 656e 743a 204f 7074 696f 6e61 6c5b 4576 ent: Optional[Ev\n-0003f090: 656e 745d 203d 204e 6f6e 6529 202d 3e20 ent] = None) -> \n-0003f0a0: 4e6f 6e65 3a0a 2020 2020 2020 2020 7375 None:. su\n-0003f0b0: 7065 7228 292e 5f5f 696e 6974 5f5f 2829 per().__init__()\n-0003f0c0: 0a20 2020 2020 2020 2073 656c 662e 7364 . self.sd\n-0003f0d0: 5f65 7665 6e74 203d 2065 7665 6e74 206f _event = event o\n-0003f0e0: 7220 4576 656e 742e 6465 6661 756c 7428 r Event.default(\n-0003f0f0: 290a 2020 2020 2020 2020 7365 6c66 2e6b ). self.k\n-0003f100: 6579 203d 2073 656c 662e 7265 6769 7374 ey = self.regist\n-0003f110: 6572 2873 656c 662e 7364 5f65 7665 6e74 er(self.sd_event\n-0003f120: 2e67 6574 5f66 6428 292c 2073 656c 6563 .get_fd(), selec\n-0003f130: 746f 7273 2e45 5645 4e54 5f52 4541 4429 tors.EVENT_READ)\n-0003f140: 0a0a 2020 2020 6465 6620 7365 6c65 6374 .. def select\n-0003f150: 280a 2020 2020 2020 2020 2020 2020 7365 (. se\n-0003f160: 6c66 2c20 7469 6d65 6f75 743a 204f 7074 lf, timeout: Opt\n-0003f170: 696f 6e61 6c5b 666c 6f61 745d 203d 204e ional[float] = N\n-0003f180: 6f6e 650a 2020 2020 2920 2d3e 204c 6973 one. ) -> Lis\n-0003f190: 745b 5475 706c 655b 7365 6c65 6374 6f72 t[Tuple[selector\n-0003f1a0: 732e 5365 6c65 6374 6f72 4b65 792c 2069 s.SelectorKey, i\n-0003f1b0: 6e74 5d5d 3a0a 2020 2020 2020 2020 2320 nt]]:. # \n-0003f1c0: 4974 2773 2063 6f6d 6d6f 6e20 746f 2064 It's common to d\n-0003f1d0: 726f 7020 7468 6520 6c61 7374 2072 6566 rop the last ref\n-0003f1e0: 6572 656e 6365 2074 6f20 6120 536f 7572 erence to a Sour\n-0003f1f0: 6365 206f 7220 536c 6f74 206f 626a 6563 ce or Slot objec\n-0003f200: 7420 6f6e 0a20 2020 2020 2020 2023 2061 t on. # a\n-0003f210: 2064 6973 7061 7463 6820 6f66 2074 6861 dispatch of tha\n-0003f220: 7420 7361 6d65 2073 6f75 7263 652f 736c t same source/sl\n-0003f230: 6f74 2066 726f 6d20 7468 6520 6d61 696e ot from the main\n-0003f240: 206c 6f6f 702e 2020 4966 2077 6520 6861 loop. If we ha\n-0003f250: 7070 656e 0a20 2020 2020 2020 2023 2074 ppen. # t\n-0003f260: 6f20 6761 7262 6167 6520 636f 6c6c 6563 o garbage collec\n-0003f270: 7420 6265 666f 7265 2072 6574 7572 6e69 t before returni\n-0003f280: 6e67 2c20 7468 6520 7472 616d 706f 6c69 ng, the trampoli\n-0003f290: 6e65 2063 6f75 6c64 2062 650a 2020 2020 ne could be. \n-0003f2a0: 2020 2020 2320 6465 7374 726f 7965 6420 # destroyed \n-0003f2b0: 6265 666f 7265 2077 6527 7265 2064 6f6e before we're don\n-0003f2c0: 6520 7573 696e 6720 6974 2e20 2050 726f e using it. Pro\n-0003f2d0: 7669 6465 2061 206d 6563 6861 6e69 736d vide a mechanism\n-0003f2e0: 2074 6f20 6465 6665 720a 2020 2020 2020 to defer. \n-0003f2f0: 2020 2320 7468 6520 6465 7374 7275 6374 # the destruct\n-0003f300: 696f 6e20 6f66 2074 7261 6d70 6f6c 696e ion of trampolin\n-0003f310: 6573 2066 6f72 2061 7320 6c6f 6e67 2061 es for as long a\n-0003f320: 7320 7765 206d 6967 6874 2062 650a 2020 s we might be. \n-0003f330: 2020 2020 2020 2320 6469 7370 6174 6368 # dispatch\n-0003f340: 696e 672e 2020 5468 6973 2067 6574 7320 ing. This gets \n-0003f350: 636c 6561 7265 6420 6167 6169 6e20 6174 cleared again at\n-0003f360: 2074 6865 2062 6f74 746f 6d2c 2062 6566 the bottom, bef\n-0003f370: 6f72 6520 7265 7475 726e 2e0a 2020 2020 ore return.. \n-0003f380: 2020 2020 6c69 6273 7973 7465 6d64 2e54 libsystemd.T\n-0003f390: 7261 6d70 6f6c 696e 652e 6465 6665 7272 rampoline.deferr\n-0003f3a0: 6564 203d 205b 5d0a 0a20 2020 2020 2020 ed = [].. \n-0003f3b0: 2077 6869 6c65 2073 656c 662e 7364 5f65 while self.sd_e\n-0003f3c0: 7665 6e74 2e70 7265 7061 7265 2829 3a0a vent.prepare():.\n-0003f3d0: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n-0003f3e0: 2e73 645f 6576 656e 742e 6469 7370 6174 .sd_event.dispat\n-0003f3f0: 6368 2829 0a20 2020 2020 2020 2072 6561 ch(). rea\n-0003f400: 6479 203d 2073 7570 6572 2829 2e73 656c dy = super().sel\n-0003f410: 6563 7428 7469 6d65 6f75 7429 0a20 2020 ect(timeout). \n-0003f420: 2020 2020 2023 2077 6f72 6b61 726f 756e # workaroun\n-0003f430: 6420 6874 7470 733a 2f2f 6769 7468 7562 d https://github\n-0003f440: 2e63 6f6d 2f73 7973 7465 6d64 2f73 7973 .com/systemd/sys\n-0003f450: 7465 6d64 2f69 7373 7565 732f 3233 3832 temd/issues/2382\n-0003f460: 360a 2020 2020 2020 2020 2320 6b65 6570 6. # keep\n-0003f470: 2063 616c 6c69 6e67 2077 6169 7428 2920 calling wait() \n-0003f480: 756e 7469 6c20 7468 6572 6527 7320 6e6f until there's no\n-0003f490: 7468 696e 6720 6c65 6674 0a20 2020 2020 thing left. \n-0003f4a0: 2020 2077 6869 6c65 2073 656c 662e 7364 while self.sd\n-0003f4b0: 5f65 7665 6e74 2e77 6169 7428 3029 3a0a _event.wait(0):.\n-0003f4c0: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n-0003f4d0: 2e73 645f 6576 656e 742e 6469 7370 6174 .sd_event.dispat\n-0003f4e0: 6368 2829 0a20 2020 2020 2020 2020 2020 ch(). \n-0003f4f0: 2077 6869 6c65 2073 656c 662e 7364 5f65 while self.sd_e\n-0003f500: 7665 6e74 2e70 7265 7061 7265 2829 3a0a vent.prepare():.\n-0003f510: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0003f520: 7365 6c66 2e73 645f 6576 656e 742e 6469 self.sd_event.di\n-0003f530: 7370 6174 6368 2829 0a0a 2020 2020 2020 spatch().. \n-0003f540: 2020 2320 5765 2063 616e 2062 6520 7375 # We can be su\n-0003f550: 7265 2077 6527 7265 206e 6f74 2064 6973 re we're not dis\n-0003f560: 7061 7463 6869 6e67 2063 616c 6c62 6163 patching callbac\n-0003f570: 6b73 2061 6e79 6d6f 7265 0a20 2020 2020 ks anymore. \n-0003f580: 2020 206c 6962 7379 7374 656d 642e 5472 libsystemd.Tr\n-0003f590: 616d 706f 6c69 6e65 2e64 6566 6572 7265 ampoline.deferre\n-0003f5a0: 6420 3d20 4e6f 6e65 0a0a 2020 2020 2020 d = None.. \n-0003f5b0: 2020 2320 5468 6973 2063 6f75 6c64 2072 # This could r\n-0003f5c0: 6574 7572 6e20 7a65 726f 2065 7665 6e74 eturn zero event\n-0003f5d0: 7320 7769 7468 2069 6e66 696e 6974 6520 s with infinite \n-0003f5e0: 7469 6d65 6f75 742c 2062 7574 206e 6f62 timeout, but nob\n-0003f5f0: 6f64 7920 7365 656d 7320 746f 206d 696e ody seems to min\n-0003f600: 642e 0a20 2020 2020 2020 2072 6574 7572 d.. retur\n-0003f610: 6e20 5b28 6b65 792c 2065 7665 6e74 7329 n [(key, events)\n-0003f620: 2066 6f72 2028 6b65 792c 2065 7665 6e74 for (key, event\n-0003f630: 7329 2069 6e20 7265 6164 7920 6966 206b s) in ready if k\n-0003f640: 6579 2021 3d20 7365 6c66 2e6b 6579 5d0a ey != self.key].\n-0003f650: 0a0a 636c 6173 7320 4576 656e 744c 6f6f ..class EventLoo\n-0003f660: 7050 6f6c 6963 7928 6173 796e 6369 6f2e pPolicy(asyncio.\n-0003f670: 4465 6661 756c 7445 7665 6e74 4c6f 6f70 DefaultEventLoop\n-0003f680: 506f 6c69 6379 293a 0a20 2020 2064 6566 Policy):. def\n-0003f690: 206e 6577 5f65 7665 6e74 5f6c 6f6f 7028 new_event_loop(\n-0003f6a0: 7365 6c66 2920 2d3e 2061 7379 6e63 696f self) -> asyncio\n-0003f6b0: 2e41 6273 7472 6163 7445 7665 6e74 4c6f .AbstractEventLo\n-0003f6c0: 6f70 3a0a 2020 2020 2020 2020 7265 7475 op:. retu\n-0003f6d0: 726e 2061 7379 6e63 696f 2e53 656c 6563 rn asyncio.Selec\n-0003f6e0: 746f 7245 7665 6e74 4c6f 6f70 2853 656c torEventLoop(Sel\n-0003f6f0: 6563 746f 7228 2929 0a0a 0a64 6566 2072 ector())...def r\n-0003f700: 756e 5f61 7379 6e63 286d 6169 6e3a 2043 un_async(main: C\n-0003f710: 6f72 6f75 7469 6e65 5b4e 6f6e 652c 204e oroutine[None, N\n-0003f720: 6f6e 652c 204e 6f6e 655d 2c20 6465 6275 one, None], debu\n-0003f730: 673a 204f 7074 696f 6e61 6c5b 626f 6f6c g: Optional[bool\n-0003f740: 5d20 3d20 4e6f 6e65 2920 2d3e 204e 6f6e ] = None) -> Non\n-0003f750: 653a 0a20 2020 2061 7379 6e63 696f 2e73 e:. asyncio.s\n-0003f760: 6574 5f65 7665 6e74 5f6c 6f6f 705f 706f et_event_loop_po\n-0003f770: 6c69 6379 2845 7665 6e74 4c6f 6f70 506f licy(EventLoopPo\n-0003f780: 6c69 6379 2829 290a 0a20 2020 2070 6f6c licy()).. pol\n-0003f790: 7966 696c 6c20 3d20 7379 732e 7665 7273 yfill = sys.vers\n-0003f7a0: 696f 6e5f 696e 666f 203c 2028 332c 2037 ion_info < (3, 7\n-0003f7b0: 2c20 3029 2061 6e64 206e 6f74 2068 6173 , 0) and not has\n-0003f7c0: 6174 7472 2861 7379 6e63 696f 2c20 2772 attr(asyncio, 'r\n-0003f7d0: 756e 2729 0a20 2020 2069 6620 706f 6c79 un'). if poly\n-0003f7e0: 6669 6c6c 3a0a 2020 2020 2020 2020 2320 fill:. # \n-0003f7f0: 506f 6c79 6669 6c6c 7320 666f 7220 5079 Polyfills for Py\n-0003f800: 7468 6f6e 2033 2e36 3a0a 2020 2020 2020 thon 3.6:. \n-0003f810: 2020 6c6f 6f70 203d 2061 7379 6e63 696f loop = asyncio\n-0003f820: 2e67 6574 5f65 7665 6e74 5f6c 6f6f 7028 .get_event_loop(\n-0003f830: 290a 0a20 2020 2020 2020 2061 7373 6572 ).. asser\n-0003f840: 7420 6e6f 7420 6861 7361 7474 7228 6173 t not hasattr(as\n-0003f850: 796e 6369 6f2c 2027 6765 745f 7275 6e6e yncio, 'get_runn\n-0003f860: 696e 675f 6c6f 6f70 2729 0a20 2020 2020 ing_loop'). \n-0003f870: 2020 2061 7379 6e63 696f 2e67 6574 5f72 asyncio.get_r\n-0003f880: 756e 6e69 6e67 5f6c 6f6f 7020 3d20 6c61 unning_loop = la\n-0003f890: 6d62 6461 3a20 6c6f 6f70 0a0a 2020 2020 mbda: loop.. \n-0003f8a0: 2020 2020 6173 7365 7274 206e 6f74 2068 assert not h\n-0003f8b0: 6173 6174 7472 2861 7379 6e63 696f 2c20 asattr(asyncio, \n-0003f8c0: 2763 7265 6174 655f 7461 736b 2729 0a20 'create_task'). \n-0003f8d0: 2020 2020 2020 2061 7379 6e63 696f 2e63 asyncio.c\n-0003f8e0: 7265 6174 655f 7461 736b 203d 206c 6f6f reate_task = loo\n-0003f8f0: 702e 6372 6561 7465 5f74 6173 6b0a 0a20 p.create_task.. \n-0003f900: 2020 2020 2020 2061 7373 6572 7420 6e6f assert no\n-0003f910: 7420 6861 7361 7474 7228 6173 796e 6369 t hasattr(asynci\n-0003f920: 6f2c 2027 7275 6e27 290a 0a20 2020 2020 o, 'run').. \n-0003f930: 2020 2064 6566 2072 756e 280a 2020 2020 def run(. \n-0003f940: 2020 2020 2020 2020 2020 2020 6d61 696e main\n-0003f950: 3a20 436f 726f 7574 696e 655b 4e6f 6e65 : Coroutine[None\n-0003f960: 2c20 4e6f 6e65 2c20 4e6f 6e65 5d2c 2064 , None, None], d\n-0003f970: 6562 7567 3a20 4f70 7469 6f6e 616c 5b62 ebug: Optional[b\n-0003f980: 6f6f 6c5d 203d 204e 6f6e 650a 2020 2020 ool] = None. \n-0003f990: 2020 2020 2920 2d3e 204e 6f6e 653a 0a20 ) -> None:. \n-0003f9a0: 2020 2020 2020 2020 2020 2069 6620 6465 if de\n-0003f9b0: 6275 6720 6973 206e 6f74 204e 6f6e 653a bug is not None:\n-0003f9c0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-0003f9d0: 206c 6f6f 702e 7365 745f 6465 6275 6728 loop.set_debug(\n-0003f9e0: 6465 6275 6729 0a20 2020 2020 2020 2020 debug). \n-0003f9f0: 2020 206c 6f6f 702e 7275 6e5f 756e 7469 loop.run_unti\n-0003fa00: 6c5f 636f 6d70 6c65 7465 286d 6169 6e29 l_complete(main)\n-0003fa10: 0a0a 2020 2020 2020 2020 6173 796e 6369 .. asynci\n-0003fa20: 6f2e 7275 6e20 3d20 7275 6e20 2023 2074 o.run = run # t\n-0003fa30: 7970 653a 2069 676e 6f72 655b 6173 7369 ype: ignore[assi\n-0003fa40: 676e 6d65 6e74 5d0a 0a20 2020 2020 2020 gnment].. \n-0003fa50: 2061 7379 6e63 696f 2e5f 7379 7374 656d asyncio._system\n-0003fa60: 645f 6374 7970 6573 5f70 6f6c 7966 696c d_ctypes_polyfil\n-0003fa70: 6c73 203d 2054 7275 6520 2023 2074 7970 ls = True # typ\n-0003fa80: 653a 2069 676e 6f72 655b 6174 7472 2d64 e: ignore[attr-d\n-0003fa90: 6566 696e 6564 5d0a 0a20 2020 2061 7379 efined].. asy\n-0003faa0: 6e63 696f 2e72 756e 286d 6169 6e2c 2064 ncio.run(main, d\n-0003fab0: 6562 7567 3d64 6562 7567 290a 0a20 2020 ebug=debug).. \n-0003fac0: 2069 6620 706f 6c79 6669 6c6c 3a0a 2020 if polyfill:. \n-0003fad0: 2020 2020 2020 6465 6c20 6173 796e 6369 del asynci\n-0003fae0: 6f2e 6372 6561 7465 5f74 6173 6b2c 2061 o.create_task, a\n-0003faf0: 7379 6e63 696f 2e67 6574 5f72 756e 6e69 syncio.get_runni\n-0003fb00: 6e67 5f6c 6f6f 702c 2061 7379 6e63 696f ng_loop, asyncio\n-0003fb10: 2e72 756e 0a27 2727 2c0a 2020 2763 6f63 .run.''',. 'coc\n-0003fb20: 6b70 6974 2f5f 7665 6e64 6f72 2f73 7973 kpit/_vendor/sys\n-0003fb30: 7465 6d64 5f63 7479 7065 732f 7061 7468 temd_ctypes/path\n-0003fb40: 7761 7463 682e 7079 273a 2062 7227 2727 watch.py': br'''\n-0003fb50: 2320 7379 7374 656d 645f 6374 7970 6573 # systemd_ctypes\n-0003fb60: 0a23 0a23 2043 6f70 7972 6967 6874 2028 .#.# Copyright (\n-0003fb70: 4329 2032 3032 3220 416c 6c69 736f 6e20 C) 2022 Allison \n-0003fb80: 4b61 726c 6974 736b 6179 6120 3c61 6c6c Karlitskaya <all\n-0003fb90: 6973 6f6e 2e6b 6172 6c69 7473 6b61 7961 ison.karlitskaya\n-0003fba0: 4072 6564 6861 742e 636f 6d3e 0a23 0a23 @redhat.com>.#.#\n-0003fbb0: 2054 6869 7320 7072 6f67 7261 6d20 6973 This program is\n-0003fbc0: 2066 7265 6520 736f 6674 7761 7265 3a20 free software: \n-0003fbd0: 796f 7520 6361 6e20 7265 6469 7374 7269 you can redistri\n-0003fbe0: 6275 7465 2069 7420 616e 642f 6f72 206d bute it and/or m\n-0003fbf0: 6f64 6966 790a 2320 6974 2075 6e64 6572 odify.# it under\n-0003fc00: 2074 6865 2074 6572 6d73 206f 6620 7468 the terms of th\n-0003fc10: 6520 474e 5520 4765 6e65 7261 6c20 5075 e GNU General Pu\n-0003fc20: 626c 6963 204c 6963 656e 7365 2061 7320 blic License as \n-0003fc30: 7075 626c 6973 6865 6420 6279 0a23 2074 published by.# t\n-0003fc40: 6865 2046 7265 6520 536f 6674 7761 7265 he Free Software\n-0003fc50: 2046 6f75 6e64 6174 696f 6e2c 2065 6974 Foundation, eit\n-0003fc60: 6865 7220 7665 7273 696f 6e20 3320 6f66 her version 3 of\n-0003fc70: 2074 6865 204c 6963 656e 7365 2c20 6f72 the License, or\n-0003fc80: 0a23 2028 6174 2079 6f75 7220 6f70 7469 .# (at your opti\n-0003fc90: 6f6e 2920 616e 7920 6c61 7465 7220 7665 on) any later ve\n-0003fca0: 7273 696f 6e2e 0a23 0a23 2054 6869 7320 rsion..#.# This \n-0003fcb0: 7072 6f67 7261 6d20 6973 2064 6973 7472 program is distr\n-0003fcc0: 6962 7574 6564 2069 6e20 7468 6520 686f ibuted in the ho\n-0003fcd0: 7065 2074 6861 7420 6974 2077 696c 6c20 pe that it will \n-0003fce0: 6265 2075 7365 6675 6c2c 0a23 2062 7574 be useful,.# but\n-0003fcf0: 2057 4954 484f 5554 2041 4e59 2057 4152 WITHOUT ANY WAR\n-0003fd00: 5241 4e54 593b 2077 6974 686f 7574 2065 RANTY; without e\n-0003fd10: 7665 6e20 7468 6520 696d 706c 6965 6420 ven the implied \n-0003fd20: 7761 7272 616e 7479 206f 660a 2320 4d45 warranty of.# ME\n-0003fd30: 5243 4841 4e54 4142 494c 4954 5920 6f72 RCHANTABILITY or\n-0003fd40: 2046 4954 4e45 5353 2046 4f52 2041 2050 FITNESS FOR A P\n-0003fd50: 4152 5449 4355 4c41 5220 5055 5250 4f53 ARTICULAR PURPOS\n-0003fd60: 452e 2020 5365 6520 7468 650a 2320 474e E. See the.# GN\n-0003fd70: 5520 4765 6e65 7261 6c20 5075 626c 6963 U General Public\n-0003fd80: 204c 6963 656e 7365 2066 6f72 206d 6f72 License for mor\n-0003fd90: 6520 6465 7461 696c 732e 0a23 0a23 2059 e details..#.# Y\n-0003fda0: 6f75 2073 686f 756c 6420 6861 7665 2072 ou should have r\n-0003fdb0: 6563 6569 7665 6420 6120 636f 7079 206f eceived a copy o\n-0003fdc0: 6620 7468 6520 474e 5520 4765 6e65 7261 f the GNU Genera\n-0003fdd0: 6c20 5075 626c 6963 204c 6963 656e 7365 l Public License\n-0003fde0: 0a23 2061 6c6f 6e67 2077 6974 6820 7468 .# along with th\n-0003fdf0: 6973 2070 726f 6772 616d 2e20 2049 6620 is program. If \n-0003fe00: 6e6f 742c 2073 6565 203c 6874 7470 3a2f not, see <http:/\n-0003fe10: 2f77 7777 2e67 6e75 2e6f 7267 2f6c 6963 /www.gnu.org/lic\n-0003fe20: 656e 7365 732f 3e2e 0a0a 696d 706f 7274 enses/>...import\n-0003fe30: 2065 7272 6e6f 0a69 6d70 6f72 7420 6c6f errno.import lo\n-0003fe40: 6767 696e 670a 696d 706f 7274 206f 730a gging.import os.\n-0003fe50: 696d 706f 7274 2073 7461 740a 6672 6f6d import stat.from\n-0003fe60: 2074 7970 696e 6720 696d 706f 7274 2041 typing import A\n-0003fe70: 6e79 2c20 4c69 7374 2c20 4f70 7469 6f6e ny, List, Option\n-0003fe80: 616c 0a0a 6672 6f6d 202e 6576 656e 7420 al..from .event \n-0003fe90: 696d 706f 7274 2045 7665 6e74 0a66 726f import Event.fro\n-0003fea0: 6d20 2e69 6e6f 7469 6679 2069 6d70 6f72 m .inotify impor\n-0003feb0: 7420 4576 656e 7420 6173 2049 4e0a 0a6c t Event as IN..l\n-0003fec0: 6f67 6765 7220 3d20 6c6f 6767 696e 672e ogger = logging.\n-0003fed0: 6765 744c 6f67 6765 7228 5f5f 6e61 6d65 getLogger(__name\n-0003fee0: 5f5f 290a 0a0a 2320 696e 6f74 6966 7920 __)...# inotify \n-0003fef0: 6861 7264 2066 6163 7473 3a0a 230a 2320 hard facts:.#.# \n-0003ff00: 4445 4c45 5445 5f53 454c 4620 646f 6573 DELETE_SELF does\n-0003ff10: 6e27 7420 6765 7420 6361 6c6c 6564 2075 n't get called u\n-0003ff20: 6e74 696c 2061 6c6c 2072 6566 6572 656e ntil all referen\n-0003ff30: 6365 7320 746f 2061 6e20 696e 6f64 6520 ces to an inode \n-0003ff40: 6172 6520 676f 6e65 0a23 2020 202d 2069 are gone.# - i\n-0003ff50: 6e63 6c75 6469 6e67 206f 7065 6e20 6664 ncluding open fd\n-0003ff60: 730a 2320 2020 2d20 696e 636c 7564 696e s.# - includin\n-0003ff70: 6720 6f6e 2064 6972 6563 746f 7269 6573 g on directories\n-0003ff80: 0a23 0a23 2041 5454 5249 4220 6765 7473 .#.# ATTRIB gets\n-0003ff90: 2063 616c 6c65 6420 7768 656e 2075 6e6c called when unl\n-0003ffa0: 696e 6b69 6e67 2066 696c 6573 2028 6265 inking files (be\n-0003ffb0: 6361 7573 6520 7468 6520 6c69 6e6b 2063 cause the link c\n-0003ffc0: 6f75 6e74 2063 6861 6e67 6573 2920 6275 ount changes) bu\n-0003ffd0: 740a 2320 6e6f 7420 6f6e 2064 6972 6563 t.# not on direc\n-0003ffe0: 746f 7269 6573 2e20 2057 6865 6e20 756e tories. When un\n-0003fff0: 6c69 6e6b 696e 6720 616e 206f 7065 6e20 linking an open \n-00040000: 6469 7265 6374 6f72 792c 206e 6f20 6576 directory, no ev\n-00040010: 656e 7473 2061 7420 616c 6c0a 2320 6861 ents at all.# ha\n-00040020: 7070 656e 206f 6e20 7468 6520 6469 7265 ppen on the dire\n-00040030: 6374 6f72 792e 2020 4154 5452 4942 2061 ctory. ATTRIB a\n-00040040: 6c73 6f20 636f 6c6c 6563 7473 2063 6869 lso collects chi\n-00040050: 6c64 2065 7665 6e74 732c 2077 6869 6368 ld events, which\n-00040060: 206d 6561 6e73 2077 650a 2320 6765 7420 means we.# get \n-00040070: 6120 6c6f 7420 6f66 2075 6e77 616e 7465 a lot of unwante\n-00040080: 6420 6e6f 6973 652e 0a23 0a23 2054 6865 d noise..#.# The\n-00040090: 7265 2773 206e 6f74 6869 6e67 206c 696b re's nothing lik\n-000400a0: 6520 554e 4c49 4e4b 5f53 454c 462c 2075 e UNLINK_SELF, u\n-000400b0: 6e66 6f72 7475 6e61 7465 6c79 2e0a 230a nfortunately..#.\n-000400c0: 2320 4576 656e 2069 6620 6974 2077 6173 # Even if it was\n-000400d0: 2070 6f73 7369 626c 6520 746f 2074 616b possible to tak\n-000400e0: 6520 7468 6973 2061 7070 726f 6163 682c e this approach,\n-000400f0: 2069 7420 6d69 6768 7420 6e6f 7420 776f it might not wo\n-00040100: 726b 3a20 6166 7465 720a 2320 796f 7527 rk: after.# you'\n-00040110: 7665 206f 7065 6e65 6420 7468 6520 6664 ve opened the fd\n-00040120: 2c20 6974 206d 6967 6874 2067 6574 2064 , it might get d\n-00040130: 656c 6574 6564 2062 6566 6f72 6520 796f eleted before yo\n-00040140: 7520 6361 6e20 6573 7461 626c 6973 6820 u can establish \n-00040150: 7468 6520 7761 7463 680a 2320 6f6e 2069 the watch.# on i\n-00040160: 742e 0a23 0a23 2041 6464 6974 696f 6e61 t..#.# Additiona\n-00040170: 6c6c 792c 2073 7973 7465 6d64 206d 616b lly, systemd mak\n-00040180: 6573 2069 7420 696d 706f 7373 6962 6c65 es it impossible\n-00040190: 2074 6f20 7265 6769 7374 6572 2074 686f to register tho\n-000401a0: 7365 2065 7665 6e74 7320 6f6e 0a23 2073 se events on.# s\n-000401b0: 796d 6c69 6e6b 7320 2862 6563 6175 7365 ymlinks (because\n-000401c0: 2069 7420 7265 6d6f 7665 7320 494e 5f44 it removes IN_D\n-000401d0: 4f4e 545f 464f 4c4c 4f57 2069 6e20 6f72 ONT_FOLLOW in or\n-000401e0: 6465 7220 746f 2077 6174 6368 2076 6961 der to watch via\n-000401f0: 0a23 202f 7072 6f63 2f73 656c 662f 6664 .# /proc/self/fd\n-00040200: 292e 0a23 0a23 2046 6f72 2061 6c6c 206f )..#.# For all o\n-00040210: 6620 7468 6573 6520 7265 6173 6f6e 732c f these reasons,\n-00040220: 2075 6e66 6f72 7475 6e61 7465 6c79 2c20 unfortunately, \n-00040230: 7468 6520 6265 7374 2077 6179 2073 6565 the best way see\n-00040240: 6d73 2074 6f20 6265 2074 6f20 7761 7463 ms to be to watc\n-00040250: 680a 2320 666f 7220 4352 4541 5445 7c44 h.# for CREATE|D\n-00040260: 454c 4554 457c 4d4f 5645 2065 7665 6e74 ELETE|MOVE event\n-00040270: 7320 6f6e 2065 6163 6820 696e 7465 726d s on each interm\n-00040280: 6564 6961 7465 2064 6972 6563 746f 7279 ediate directory\n-00040290: 2e0a 230a 2320 556e 666f 7274 756e 6174 ..#.# Unfortunat\n-000402a0: 656c 7920 7468 6572 6520 6973 206e 6f20 ely there is no \n-000402b0: 7761 7920 746f 2066 696c 7465 7220 746f way to filter to\n-000402c0: 206f 6e6c 7920 7468 6520 6e61 6d65 2077 only the name w\n-000402d0: 6527 7265 2069 6e74 6572 6573 7465 6420 e're interested \n-000402e0: 696e 2c0a 2320 736f 2077 6527 7265 2067 in,.# so we're g\n-000402f0: 6f6e 6e61 2067 6574 2061 206c 6f74 206f onna get a lot o\n-00040300: 6620 756e 6e65 6365 7373 6172 7920 7761 f unnecessary wa\n-00040310: 6b65 7570 732e 0a23 0a23 2041 6c73 6f3a keups..#.# Also:\n-00040320: 2064 7565 2074 6f20 7468 6520 6162 6f76 due to the abov\n-00040330: 652d 6d65 6e74 696f 6e65 6420 7261 6365 e-mentioned race\n-00040340: 2061 626f 7574 2077 6174 6368 696e 6720 about watching \n-00040350: 6166 7465 7220 6f70 656e 696e 6720 7468 after opening th\n-00040360: 6520 6664 2c0a 2320 6c65 7427 7320 6a75 e fd,.# let's ju\n-00040370: 7374 2061 6c77 6179 7320 7761 7463 6820 st always watch \n-00040380: 666f 7220 626f 7468 2063 7265 6174 6520 for both create \n-00040390: 616e 6420 6465 6c65 7465 2065 7665 6e74 and delete event\n-000403a0: 7320 2a62 6566 6f72 652a 2074 7279 696e s *before* tryin\n-000403b0: 6720 746f 0a23 206f 7065 6e20 7468 6520 g to.# open the \n-000403c0: 6664 2e20 2057 6520 636f 756c 6420 7472 fd. We could tr\n-000403d0: 7920 746f 2072 6564 7563 6520 7468 6520 y to reduce the \n-000403e0: 6d61 736b 2061 6674 6572 2074 6865 2066 mask after the f\n-000403f0: 6163 742c 2062 7574 206d 6568 2e2e 2e0a act, but meh....\n-00040400: 230a 2320 5765 2075 7365 2061 2057 6174 #.# We use a Wat\n-00040410: 6368 496e 7661 6c69 6461 746f 7220 7574 chInvalidator ut\n-00040420: 696c 6974 7920 636c 6173 7320 746f 2066 ility class to f\n-00040430: 696c 6c20 7468 6520 726f 6c65 206f 6620 ill the role of \n-00040440: 2254 656c 6c20 6d65 2077 6865 6e20 616e \"Tell me when an\n-00040450: 0a23 2065 7665 6e74 2068 6170 7065 6e65 .# event happene\n-00040460: 6420 6f6e 2074 6869 7320 2864 6972 6563 d on this (direc\n-00040470: 746f 7279 2920 6664 2077 6869 6368 2069 tory) fd which i\n-00040480: 6d70 6163 7465 6420 7468 6520 6e61 6d65 mpacted the name\n-00040490: 2066 696c 6522 2e20 2057 650a 2320 6275 file\". We.# bu\n-000404a0: 696c 6420 6120 7365 7269 6573 206f 6620 ild a series of \n-000404b0: 7468 6573 6520 7768 656e 2073 6574 7469 these when setti\n-000404c0: 6e67 2075 7020 6120 7761 7463 6820 696e ng up a watch in\n-000404d0: 206f 7264 6572 2074 6f20 6669 6e64 206f order to find o\n-000404e0: 7574 2069 6620 616e 790a 2320 7061 7274 ut if any.# part\n-000404f0: 206f 6620 7468 6520 7061 7468 206c 6561 of the path lea\n-00040500: 6469 6e67 2074 6f20 7468 6520 6d6f 6e69 ding to the moni\n-00040510: 746f 7265 6420 6669 6c65 2063 6861 6e67 tored file chang\n-00040520: 6564 2e0a 0a0a 636c 6173 7320 4861 6e64 ed....class Hand\n-00040530: 6c65 2869 6e74 293a 0a20 2020 2022 2222 le(int):. \"\"\"\n-00040540: 416e 2069 6e74 6567 6572 2073 7562 636c An integer subcl\n-00040550: 6173 7320 7468 6174 206d 616b 6573 2069 ass that makes i\n-00040560: 7420 6561 7369 6572 2074 6f20 776f 726b t easier to work\n-00040570: 2077 6974 6820 6669 6c65 2064 6573 6372 with file descr\n-00040580: 6970 746f 7273 2222 220a 0a20 2020 2064 iptors\"\"\".. d\n-00040590: 6566 205f 5f6e 6577 5f5f 2863 6c73 2c20 ef __new__(cls, \n-000405a0: 6664 3a20 696e 7420 3d20 2d31 2920 2d3e fd: int = -1) ->\n-000405b0: 2027 4861 6e64 6c65 273a 0a20 2020 2020 'Handle':. \n-000405c0: 2020 2072 6574 7572 6e20 7375 7065 7228 return super(\n-000405d0: 4861 6e64 6c65 2c20 636c 7329 2e5f 5f6e Handle, cls).__n\n-000405e0: 6577 5f5f 2863 6c73 2c20 6664 290a 0a20 ew__(cls, fd).. \n-000405f0: 2020 2023 2073 6570 6172 6174 6520 5f5f # separate __\n-00040600: 696e 6974 5f5f 2829 2074 6f20 7365 7420 init__() to set \n-00040610: 5f6e 6565 6473 5f63 6c6f 7365 206d 6f73 _needs_close mos\n-00040620: 746c 7920 746f 206b 6565 7020 7079 6c69 tly to keep pyli\n-00040630: 6e74 2071 7569 6574 0a20 2020 2064 6566 nt quiet. def\n-00040640: 205f 5f69 6e69 745f 5f28 7365 6c66 2c20 __init__(self, \n-00040650: 6664 3a20 696e 7420 3d20 2d31 293a 0a20 fd: int = -1):. \n-00040660: 2020 2020 2020 2073 7570 6572 2829 2e5f super()._\n-00040670: 5f69 6e69 745f 5f28 290a 2020 2020 2020 _init__(). \n-00040680: 2020 7365 6c66 2e5f 6e65 6564 735f 636c self._needs_cl\n-00040690: 6f73 6520 3d20 6664 2021 3d20 2d31 0a0a ose = fd != -1..\n-000406a0: 2020 2020 6465 6620 5f5f 626f 6f6c 5f5f def __bool__\n-000406b0: 2873 656c 6629 202d 3e20 626f 6f6c 3a0a (self) -> bool:.\n-000406c0: 2020 2020 2020 2020 7265 7475 726e 2073 return s\n-000406d0: 656c 6620 213d 202d 310a 0a20 2020 2064 elf != -1.. d\n-000406e0: 6566 2063 6c6f 7365 2873 656c 6629 202d ef close(self) -\n-000406f0: 3e20 4e6f 6e65 3a0a 2020 2020 2020 2020 > None:. \n-00040700: 6966 2073 656c 662e 5f6e 6565 6473 5f63 if self._needs_c\n-00040710: 6c6f 7365 3a0a 2020 2020 2020 2020 2020 lose:. \n-00040720: 2020 7365 6c66 2e5f 6e65 6564 735f 636c self._needs_cl\n-00040730: 6f73 6520 3d20 4661 6c73 650a 2020 2020 ose = False. \n-00040740: 2020 2020 2020 2020 6f73 2e63 6c6f 7365 os.close\n-00040750: 2873 656c 6629 0a0a 2020 2020 6465 6620 (self).. def \n-00040760: 5f5f 6571 5f5f 2873 656c 662c 2076 616c __eq__(self, val\n-00040770: 7565 3a20 6f62 6a65 6374 2920 2d3e 2062 ue: object) -> b\n-00040780: 6f6f 6c3a 0a20 2020 2020 2020 2069 6620 ool:. if \n-00040790: 696e 742e 5f5f 6571 5f5f 2873 656c 662c int.__eq__(self,\n-000407a0: 2076 616c 7565 293a 2020 2320 616c 736f value): # also\n-000407b0: 2068 616e 646c 6573 2062 6f74 6820 3d3d handles both ==\n-000407c0: 202d 310a 2020 2020 2020 2020 2020 2020 -1. \n-000407d0: 7265 7475 726e 2054 7275 650a 0a20 2020 return True.. \n-000407e0: 2020 2020 2069 6620 6e6f 7420 6973 696e if not isin\n-000407f0: 7374 616e 6365 2876 616c 7565 2c20 696e stance(value, in\n-00040800: 7429 3a20 2023 206f 7468 6572 206f 626a t): # other obj\n-00040810: 6563 7420 6973 206e 6f74 2061 6e20 696e ect is not an in\n-00040820: 740a 2020 2020 2020 2020 2020 2020 7265 t. re\n-00040830: 7475 726e 2046 616c 7365 0a0a 2020 2020 turn False.. \n-00040840: 2020 2020 6966 206e 6f74 2073 656c 6620 if not self \n-00040850: 6f72 206e 6f74 2076 616c 7565 3a20 2023 or not value: #\n-00040860: 2077 6865 6e20 6f6e 6c79 206f 6e65 203d when only one =\n-00040870: 3d20 2d31 0a20 2020 2020 2020 2020 2020 = -1. \n-00040880: 2072 6574 7572 6e20 4661 6c73 650a 0a20 return False.. \n-00040890: 2020 2020 2020 2072 6574 7572 6e20 6f73 return os\n-000408a0: 2e70 6174 682e 7361 6d65 6f70 656e 6669 .path.sameopenfi\n-000408b0: 6c65 2873 656c 662c 2076 616c 7565 290a le(self, value).\n-000408c0: 0a20 2020 2064 6566 205f 5f64 656c 5f5f . def __del__\n-000408d0: 2873 656c 6629 202d 3e20 4e6f 6e65 3a0a (self) -> None:.\n-000408e0: 2020 2020 2020 2020 6966 2073 656c 662e if self.\n-000408f0: 5f6e 6565 6473 5f63 6c6f 7365 3a0a 2020 _needs_close:. \n-00040900: 2020 2020 2020 2020 2020 7365 6c66 2e63 self.c\n-00040910: 6c6f 7365 2829 0a0a 2020 2020 6465 6620 lose().. def \n-00040920: 5f5f 656e 7465 725f 5f28 7365 6c66 2920 __enter__(self) \n-00040930: 2d3e 2027 4861 6e64 6c65 273a 0a20 2020 -> 'Handle':. \n-00040940: 2020 2020 2072 6574 7572 6e20 7365 6c66 return self\n-00040950: 0a0a 2020 2020 6465 6620 5f5f 6578 6974 .. def __exit\n-00040960: 5f5f 2873 656c 662c 205f 7479 7065 3a20 __(self, _type: \n-00040970: 7479 7065 2c20 5f76 616c 7565 3a20 6f62 type, _value: ob\n-00040980: 6a65 6374 2c20 5f74 7261 6365 6261 636b ject, _traceback\n-00040990: 3a20 6f62 6a65 6374 2920 2d3e 204e 6f6e : object) -> Non\n-000409a0: 653a 0a20 2020 2020 2020 2073 656c 662e e:. self.\n-000409b0: 636c 6f73 6528 290a 0a20 2020 2040 636c close().. @cl\n-000409c0: 6173 736d 6574 686f 640a 2020 2020 6465 assmethod. de\n-000409d0: 6620 6f70 656e 2863 6c73 2c20 2a61 7267 f open(cls, *arg\n-000409e0: 733a 2041 6e79 2c20 2a2a 6b77 6172 6773 s: Any, **kwargs\n-000409f0: 3a20 416e 7929 202d 3e20 2748 616e 646c : Any) -> 'Handl\n-00040a00: 6527 3a0a 2020 2020 2020 2020 7265 7475 e':. retu\n-00040a10: 726e 2063 6c73 286f 732e 6f70 656e 282a rn cls(os.open(*\n-00040a20: 6172 6773 2c20 2a2a 6b77 6172 6773 2929 args, **kwargs))\n-00040a30: 0a0a 2020 2020 6465 6620 7374 6561 6c28 .. def steal(\n-00040a40: 7365 6c66 2920 2d3e 2027 4861 6e64 6c65 self) -> 'Handle\n-00040a50: 273a 0a20 2020 2020 2020 2073 656c 662e ':. self.\n-00040a60: 5f6e 6565 6473 5f63 6c6f 7365 203d 2046 _needs_close = F\n-00040a70: 616c 7365 0a20 2020 2020 2020 2072 6574 alse. ret\n-00040a80: 7572 6e20 7365 6c66 2e5f 5f63 6c61 7373 urn self.__class\n-00040a90: 5f5f 2869 6e74 2873 656c 6629 290a 0a0a __(int(self))...\n-00040aa0: 636c 6173 7320 5761 7463 6849 6e76 616c class WatchInval\n-00040ab0: 6964 6174 6f72 3a0a 2020 2020 5f6e 616d idator:. _nam\n-00040ac0: 653a 2062 7974 6573 0a20 2020 205f 736f e: bytes. _so\n-00040ad0: 7572 6365 3a20 4f70 7469 6f6e 616c 5b45 urce: Optional[E\n-00040ae0: 7665 6e74 2e53 6f75 7263 655d 0a20 2020 vent.Source]. \n-00040af0: 205f 7761 7463 683a 204f 7074 696f 6e61 _watch: Optiona\n-00040b00: 6c5b 2750 6174 6857 6174 6368 275d 0a0a l['PathWatch']..\n-00040b10: 2020 2020 6465 6620 6576 656e 7428 7365 def event(se\n-00040b20: 6c66 2c20 6d61 736b 3a20 494e 2c20 5f63 lf, mask: IN, _c\n-00040b30: 6f6f 6b69 653a 2069 6e74 2c20 6e61 6d65 ookie: int, name\n-00040b40: 3a20 4f70 7469 6f6e 616c 5b62 7974 6573 : Optional[bytes\n-00040b50: 5d29 202d 3e20 4e6f 6e65 3a0a 2020 2020 ]) -> None:. \n-00040b60: 2020 2020 6c6f 6767 6572 2e64 6562 7567 logger.debug\n-00040b70: 2827 696e 7661 6c69 6461 746f 7220 6576 ('invalidator ev\n-00040b80: 656e 7420 2573 2025 7327 2c20 6d61 736b ent %s %s', mask\n-00040b90: 2c20 6e61 6d65 290a 2020 2020 2020 2020 , name). \n-00040ba0: 6966 2073 656c 662e 5f77 6174 6368 2069 if self._watch i\n-00040bb0: 7320 6e6f 7420 4e6f 6e65 3a0a 2020 2020 s not None:. \n-00040bc0: 2020 2020 2020 2020 2320 4966 2074 6869 # If thi\n-00040bd0: 7320 6e6f 6465 2069 7473 656c 6620 6469 s node itself di\n-00040be0: 7361 7070 6561 7265 642c 2074 6861 7427 sappeared, that'\n-00040bf0: 7320 6465 6669 6e69 7465 6c79 2061 6e0a s definitely an.\n-00040c00: 2020 2020 2020 2020 2020 2020 2320 696e # in\n-00040c10: 7661 6c69 6461 7469 6f6e 2e20 204f 7468 validation. Oth\n-00040c20: 6572 7769 7365 2c20 7468 6520 6e61 6d65 erwise, the name\n-00040c30: 206e 6565 6473 2074 6f20 6d61 7463 682e needs to match.\n-00040c40: 0a20 2020 2020 2020 2020 2020 2069 6620 . if \n-00040c50: 494e 2e49 474e 4f52 4544 2069 6e20 6d61 IN.IGNORED in ma\n-00040c60: 736b 206f 7220 7365 6c66 2e5f 6e61 6d65 sk or self._name\n-00040c70: 203d 3d20 6e61 6d65 3a0a 2020 2020 2020 == name:. \n-00040c80: 2020 2020 2020 2020 2020 6c6f 6767 6572 logger\n-00040c90: 2e64 6562 7567 2827 496e 7661 6c69 6461 .debug('Invalida\n-00040ca0: 7469 6e67 2127 290a 2020 2020 2020 2020 ting!'). \n-00040cb0: 2020 2020 2020 2020 7365 6c66 2e5f 7761 self._wa\n-00040cc0: 7463 682e 696e 7661 6c69 6461 7465 2829 tch.invalidate()\n-00040cd0: 0a0a 2020 2020 6465 6620 5f5f 696e 6974 .. def __init\n-00040ce0: 5f5f 2873 656c 662c 2077 6174 6368 3a20 __(self, watch: \n-00040cf0: 2750 6174 6857 6174 6368 272c 2065 7665 'PathWatch', eve\n-00040d00: 6e74 3a20 4576 656e 742c 2064 6972 6664 nt: Event, dirfd\n-00040d10: 3a20 696e 742c 206e 616d 653a 2073 7472 : int, name: str\n-00040d20: 293a 0a20 2020 2020 2020 2073 656c 662e ):. self.\n-00040d30: 5f77 6174 6368 203d 2077 6174 6368 0a20 _watch = watch. \n-00040d40: 2020 2020 2020 2073 656c 662e 5f6e 616d self._nam\n-00040d50: 6520 3d20 6e61 6d65 2e65 6e63 6f64 6528 e = name.encode(\n-00040d60: 2775 7466 2d38 2729 0a0a 2020 2020 2020 'utf-8').. \n-00040d70: 2020 2320 6573 7461 626c 6973 6869 6e67 # establishing\n-00040d80: 2069 6e76 616c 6964 6174 696f 6e20 7761 invalidation wa\n-00040d90: 7463 6865 7320 6973 2062 6573 742d 6566 tches is best-ef\n-00040da0: 666f 7274 2061 6e64 2063 616e 2066 6169 fort and can fai\n-00040db0: 6c20 666f 7220 610a 2020 2020 2020 2020 l for a. \n-00040dc0: 2320 6e75 6d62 6572 206f 6620 7265 6173 # number of reas\n-00040dd0: 6f6e 732c 2069 6e63 6c75 6469 6e67 2073 ons, including s\n-00040de0: 6561 7263 6820 282b 7829 2062 7574 206e earch (+x) but n\n-00040df0: 6f74 2072 6561 6420 282b 7229 2070 6572 ot read (+r) per\n-00040e00: 6d69 7373 696f 6e0a 2020 2020 2020 2020 mission. \n-00040e10: 2320 6f6e 2061 2070 6172 7469 6375 6c61 # on a particula\n-00040e20: 7220 7061 7468 2063 6f6d 706f 6e65 6e74 r path component\n-00040e30: 2c20 6f72 2065 7863 6565 6469 6e67 206c , or exceeding l\n-00040e40: 696d 6974 7320 6f6e 2077 6174 6368 6573 imits on watches\n-00040e50: 0a20 2020 2020 2020 2074 7279 3a0a 2020 . try:. \n-00040e60: 2020 2020 2020 2020 2020 6d61 736b 203d mask =\n-00040e70: 2049 4e2e 4352 4541 5445 207c 2049 4e2e IN.CREATE | IN.\n-00040e80: 4445 4c45 5445 207c 2049 4e2e 4d4f 5645 DELETE | IN.MOVE\n-00040e90: 207c 2049 4e2e 4445 4c45 5445 5f53 454c | IN.DELETE_SEL\n-00040ea0: 4620 7c20 494e 2e49 474e 4f52 4544 0a20 F | IN.IGNORED. \n-00040eb0: 2020 2020 2020 2020 2020 2073 656c 662e self.\n-00040ec0: 5f73 6f75 7263 6520 3d20 6576 656e 742e _source = event.\n-00040ed0: 6164 645f 696e 6f74 6966 795f 6664 2864 add_inotify_fd(d\n-00040ee0: 6972 6664 2c20 6d61 736b 2c20 7365 6c66 irfd, mask, self\n-00040ef0: 2e65 7665 6e74 290a 2020 2020 2020 2020 .event). \n-00040f00: 6578 6365 7074 204f 5345 7272 6f72 3a0a except OSError:.\n-00040f10: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n-00040f20: 2e5f 736f 7572 6365 203d 204e 6f6e 650a ._source = None.\n-00040f30: 0a20 2020 2064 6566 2063 6c6f 7365 2873 . def close(s\n-00040f40: 656c 6629 202d 3e20 4e6f 6e65 3a0a 2020 elf) -> None:. \n-00040f50: 2020 2020 2020 2320 5468 6973 2069 7320 # This is \n-00040f60: 6120 6c69 7474 6c65 2062 6974 2074 7269 a little bit tri\n-00040f70: 636b 793a 2073 7973 7465 6d64 2064 6f65 cky: systemd doe\n-00040f80: 736e 2774 2068 6176 6520 6120 7370 6563 sn't have a spec\n-00040f90: 6966 6963 2063 6c6f 7365 0a20 2020 2020 ific close. \n-00040fa0: 2020 2023 2041 5049 206f 7574 7369 6465 # API outside\n-00040fb0: 206f 6620 756e 7265 662c 2073 6f20 6c65 of unref, so le\n-00040fc0: 7427 7320 6d61 6b65 2069 7420 6173 2065 t's make it as e\n-00040fd0: 7870 6c69 6369 7420 6173 2070 6f73 7369 xplicit as possi\n-00040fe0: 626c 652e 0a20 2020 2020 2020 2073 656c ble.. sel\n-00040ff0: 662e 5f77 6174 6368 203d 204e 6f6e 650a f._watch = None.\n-00041000: 2020 2020 2020 2020 7365 6c66 2e5f 736f self._so\n-00041010: 7572 6365 203d 204e 6f6e 650a 0a0a 636c urce = None...cl\n-00041020: 6173 7320 5061 7468 5374 6163 6b28 4c69 ass PathStack(Li\n-00041030: 7374 5b73 7472 5d29 3a0a 2020 2020 6465 st[str]):. de\n-00041040: 6620 6164 645f 7061 7468 2873 656c 662c f add_path(self,\n-00041050: 2070 6174 686e 616d 653a 2073 7472 2920 pathname: str) \n-00041060: 2d3e 204e 6f6e 653a 0a20 2020 2020 2020 -> None:. \n-00041070: 2023 2054 4f20 444f 3a20 636f 6e73 6964 # TO DO: consid\n-00041080: 6572 2064 6f69 6e67 2073 6f6d 6574 6869 er doing somethi\n-00041090: 6e67 2072 6561 736f 6e61 626c 6520 7769 ng reasonable wi\n-000410a0: 7468 2074 7261 696c 696e 6720 736c 6173 th trailing slas\n-000410b0: 6865 730a 2020 2020 2020 2020 2320 7468 hes. # th\n-000410c0: 6973 2069 7320 6120 7374 6163 6b2c 2070 is is a stack, p\n-000410d0: 6f70 7065 6420 6672 6f6d 2074 6865 2065 opped from the e\n-000410e0: 6e64 3a20 7075 7368 2063 6f6d 706f 6e65 nd: push compone\n-000410f0: 6e74 7320 696e 2072 6576 6572 7365 0a20 nts in reverse. \n-00041100: 2020 2020 2020 2073 656c 662e 6578 7465 self.exte\n-00041110: 6e64 2869 7465 6d20 666f 7220 6974 656d nd(item for item\n-00041120: 2069 6e20 7265 7665 7273 6564 2870 6174 in reversed(pat\n-00041130: 686e 616d 652e 7370 6c69 7428 272f 2729 hname.split('/')\n-00041140: 2920 6966 2069 7465 6d29 0a20 2020 2020 ) if item). \n-00041150: 2020 2069 6620 7061 7468 6e61 6d65 2e73 if pathname.s\n-00041160: 7461 7274 7377 6974 6828 272f 2729 3a0a tartswith('/'):.\n-00041170: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n-00041180: 2e61 7070 656e 6428 272f 2729 0a0a 2020 .append('/').. \n-00041190: 2020 6465 6620 5f5f 696e 6974 5f5f 2873 def __init__(s\n-000411a0: 656c 662c 2070 6174 683a 2073 7472 293a elf, path: str):\n-000411b0: 0a20 2020 2020 2020 2073 7570 6572 2829 . super()\n-000411c0: 2e5f 5f69 6e69 745f 5f28 290a 2020 2020 .__init__(). \n-000411d0: 2020 2020 7365 6c66 2e61 6464 5f70 6174 self.add_pat\n-000411e0: 6828 7061 7468 290a 0a0a 636c 6173 7320 h(path)...class \n-000411f0: 4c69 7374 656e 6572 3a0a 2020 2020 6465 Listener:. de\n-00041200: 6620 646f 5f69 6e6f 7469 6679 5f65 7665 f do_inotify_eve\n-00041210: 6e74 2873 656c 662c 206d 6173 6b3a 2049 nt(self, mask: I\n-00041220: 4e2c 2063 6f6f 6b69 653a 2069 6e74 2c20 N, cookie: int, \n-00041230: 6e61 6d65 3a20 4f70 7469 6f6e 616c 5b62 name: Optional[b\n-00041240: 7974 6573 5d29 202d 3e20 4e6f 6e65 3a0a ytes]) -> None:.\n-00041250: 2020 2020 2020 2020 7261 6973 6520 4e6f raise No\n-00041260: 7449 6d70 6c65 6d65 6e74 6564 4572 726f tImplementedErro\n-00041270: 720a 0a20 2020 2064 6566 2064 6f5f 6964 r.. def do_id\n-00041280: 656e 7469 7479 5f63 6861 6e67 6564 2873 entity_changed(s\n-00041290: 656c 662c 2066 643a 204f 7074 696f 6e61 elf, fd: Optiona\n-000412a0: 6c5b 4861 6e64 6c65 5d2c 2065 7272 6e6f l[Handle], errno\n-000412b0: 3a20 4f70 7469 6f6e 616c 5b69 6e74 5d29 : Optional[int])\n-000412c0: 202d 3e20 4e6f 6e65 3a0a 2020 2020 2020 -> None:. \n-000412d0: 2020 7261 6973 6520 4e6f 7449 6d70 6c65 raise NotImple\n-000412e0: 6d65 6e74 6564 4572 726f 720a 0a0a 636c mentedError...cl\n-000412f0: 6173 7320 5061 7468 5761 7463 683a 0a20 ass PathWatch:. \n-00041300: 2020 205f 6576 656e 743a 2045 7665 6e74 _event: Event\n-00041310: 0a20 2020 205f 6c69 7374 656e 6572 3a20 . _listener: \n-00041320: 4c69 7374 656e 6572 0a20 2020 205f 7061 Listener. _pa\n-00041330: 7468 3a20 7374 720a 2020 2020 5f69 6e76 th: str. _inv\n-00041340: 616c 6964 6174 6f72 733a 204c 6973 745b alidators: List[\n-00041350: 5761 7463 6849 6e76 616c 6964 6174 6f72 WatchInvalidator\n-00041360: 5d0a 2020 2020 5f65 7272 6e6f 3a20 4f70 ]. _errno: Op\n-00041370: 7469 6f6e 616c 5b69 6e74 5d0a 2020 2020 tional[int]. \n-00041380: 5f73 6f75 7263 653a 204f 7074 696f 6e61 _source: Optiona\n-00041390: 6c5b 4576 656e 742e 536f 7572 6365 5d0a l[Event.Source].\n-000413a0: 2020 2020 5f74 6167 3a20 4f70 7469 6f6e _tag: Option\n-000413b0: 616c 5b4e 6f6e 655d 0a20 2020 205f 6664 al[None]. _fd\n-000413c0: 3a20 4861 6e64 6c65 0a0a 2020 2020 6465 : Handle.. de\n-000413d0: 6620 5f5f 696e 6974 5f5f 2873 656c 662c f __init__(self,\n-000413e0: 2070 6174 683a 2073 7472 2c20 6c69 7374 path: str, list\n-000413f0: 656e 6572 3a20 4c69 7374 656e 6572 2c20 ener: Listener, \n-00041400: 6576 656e 743a 204f 7074 696f 6e61 6c5b event: Optional[\n-00041410: 4576 656e 745d 203d 204e 6f6e 6529 3a0a Event] = None):.\n-00041420: 2020 2020 2020 2020 7365 6c66 2e5f 6576 self._ev\n-00041430: 656e 7420 3d20 6576 656e 7420 6f72 2045 ent = event or E\n-00041440: 7665 6e74 2e64 6566 6175 6c74 2829 0a20 vent.default(). \n-00041450: 2020 2020 2020 2073 656c 662e 5f70 6174 self._pat\n-00041460: 6820 3d20 7061 7468 0a20 2020 2020 2020 h = path. \n-00041470: 2073 656c 662e 5f6c 6973 7465 6e65 7220 self._listener \n-00041480: 3d20 6c69 7374 656e 6572 0a0a 2020 2020 = listener.. \n-00041490: 2020 2020 7365 6c66 2e5f 696e 7661 6c69 self._invali\n-000414a0: 6461 746f 7273 203d 205b 5d0a 2020 2020 dators = []. \n-000414b0: 2020 2020 7365 6c66 2e5f 6572 726e 6f20 self._errno \n-000414c0: 3d20 4e6f 6e65 0a20 2020 2020 2020 2073 = None. s\n-000414d0: 656c 662e 5f73 6f75 7263 6520 3d20 4e6f elf._source = No\n-000414e0: 6e65 0a20 2020 2020 2020 2073 656c 662e ne. self.\n-000414f0: 5f74 6167 203d 204e 6f6e 650a 2020 2020 _tag = None. \n-00041500: 2020 2020 7365 6c66 2e5f 6664 203d 2048 self._fd = H\n-00041510: 616e 646c 6528 290a 0a20 2020 2020 2020 andle().. \n-00041520: 2073 656c 662e 696e 7661 6c69 6461 7465 self.invalidate\n-00041530: 2829 0a0a 2020 2020 6465 6620 676f 745f ().. def got_\n-00041540: 6576 656e 7428 7365 6c66 2c20 6d61 736b event(self, mask\n-00041550: 3a20 494e 2c20 636f 6f6b 6965 3a20 696e : IN, cookie: in\n-00041560: 742c 206e 616d 653a 204f 7074 696f 6e61 t, name: Optiona\n-00041570: 6c5b 6279 7465 735d 2920 2d3e 204e 6f6e l[bytes]) -> Non\n-00041580: 653a 0a20 2020 2020 2020 206c 6f67 6765 e:. logge\n-00041590: 722e 6465 6275 6728 2774 6172 6765 7420 r.debug('target \n-000415a0: 6576 656e 7420 2573 3a20 2573 2025 7320 event %s: %s %s \n-000415b0: 2573 272c 2073 656c 662e 5f70 6174 682c %s', self._path,\n-000415c0: 206d 6173 6b2c 2063 6f6f 6b69 652c 206e mask, cookie, n\n-000415d0: 616d 6529 0a20 2020 2020 2020 2073 656c ame). sel\n-000415e0: 662e 5f6c 6973 7465 6e65 722e 646f 5f69 f._listener.do_i\n-000415f0: 6e6f 7469 6679 5f65 7665 6e74 286d 6173 notify_event(mas\n-00041600: 6b2c 2063 6f6f 6b69 652c 206e 616d 6529 k, cookie, name)\n-00041610: 0a0a 2020 2020 6465 6620 696e 7661 6c69 .. def invali\n-00041620: 6461 7465 2873 656c 6629 202d 3e20 4e6f date(self) -> No\n-00041630: 6e65 3a0a 2020 2020 2020 2020 666f 7220 ne:. for \n-00041640: 696e 7661 6c69 6461 746f 7220 696e 2073 invalidator in s\n-00041650: 656c 662e 5f69 6e76 616c 6964 6174 6f72 elf._invalidator\n-00041660: 733a 0a20 2020 2020 2020 2020 2020 2069 s:. i\n-00041670: 6e76 616c 6964 6174 6f72 2e63 6c6f 7365 nvalidator.close\n-00041680: 2829 0a20 2020 2020 2020 2073 656c 662e (). self.\n-00041690: 5f69 6e76 616c 6964 6174 6f72 7320 3d20 _invalidators = \n-000416a0: 5b5d 0a0a 2020 2020 2020 2020 7472 793a [].. try:\n-000416b0: 0a20 2020 2020 2020 2020 2020 2066 6420 . fd \n-000416c0: 3d20 7365 6c66 2e77 616c 6b28 290a 2020 = self.walk(). \n-000416d0: 2020 2020 2020 6578 6365 7074 204f 5345 except OSE\n-000416e0: 7272 6f72 2061 7320 6572 726f 723a 0a20 rror as error:. \n-000416f0: 2020 2020 2020 2020 2020 206c 6f67 6765 logge\n-00041700: 722e 6465 6275 6728 2777 616c 6b20 656e r.debug('walk en\n-00041710: 6465 6420 696e 2065 7272 6f72 2025 6427 ded in error %d'\n-00041720: 2c20 6572 726f 722e 6572 726e 6f29 0a0a , error.errno)..\n-00041730: 2020 2020 2020 2020 2020 2020 6966 2073 if s\n-00041740: 656c 662e 5f73 6f75 7263 6520 6f72 2073 elf._source or s\n-00041750: 656c 662e 5f66 6420 6f72 2073 656c 662e elf._fd or self.\n-00041760: 5f65 7272 6e6f 2021 3d20 6572 726f 722e _errno != error.\n-00041770: 6572 726e 6f3a 0a20 2020 2020 2020 2020 errno:. \n-00041780: 2020 2020 2020 206c 6f67 6765 722e 6465 logger.de\n-00041790: 6275 6728 2745 6e64 696e 6720 6578 6973 bug('Ending exis\n-000417a0: 7469 6e67 2077 6174 6368 6573 2e27 290a ting watches.').\n-000417b0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000417c0: 7365 6c66 2e5f 736f 7572 6365 203d 204e self._source = N\n-000417d0: 6f6e 650a 2020 2020 2020 2020 2020 2020 one. \n-000417e0: 2020 2020 7365 6c66 2e5f 6664 2e63 6c6f self._fd.clo\n-000417f0: 7365 2829 0a20 2020 2020 2020 2020 2020 se(). \n-00041800: 2020 2020 2073 656c 662e 5f66 6420 3d20 self._fd = \n-00041810: 4861 6e64 6c65 2829 0a20 2020 2020 2020 Handle(). \n-00041820: 2020 2020 2020 2020 2073 656c 662e 5f65 self._e\n-00041830: 7272 6e6f 203d 2065 7272 6f72 2e65 7272 rrno = error.err\n-00041840: 6e6f 0a0a 2020 2020 2020 2020 2020 2020 no.. \n-00041850: 2020 2020 6c6f 6767 6572 2e64 6562 7567 logger.debug\n-00041860: 2827 4e6f 7469 6679 696e 6720 6f66 206e ('Notifying of n\n-00041870: 6577 2065 7272 6f72 2073 7461 7465 2025 ew error state %\n-00041880: 6427 2c20 7365 6c66 2e5f 6572 726e 6f29 d', self._errno)\n-00041890: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-000418a0: 2073 656c 662e 5f6c 6973 7465 6e65 722e self._listener.\n-000418b0: 646f 5f69 6465 6e74 6974 795f 6368 616e do_identity_chan\n-000418c0: 6765 6428 4e6f 6e65 2c20 7365 6c66 2e5f ged(None, self._\n-000418d0: 6572 726e 6f29 0a0a 2020 2020 2020 2020 errno).. \n-000418e0: 2020 2020 7265 7475 726e 0a0a 2020 2020 return.. \n-000418f0: 2020 2020 7769 7468 2066 643a 0a20 2020 with fd:. \n-00041900: 2020 2020 2020 2020 206c 6f67 6765 722e logger.\n-00041910: 6465 6275 6728 2777 616c 6b20 7375 6363 debug('walk succ\n-00041920: 6573 7366 756c 2e20 2047 6f74 2066 6420 essful. Got fd \n-00041930: 2564 272c 2066 6429 0a20 2020 2020 2020 %d', fd). \n-00041940: 2020 2020 2069 6620 6664 203d 3d20 7365 if fd == se\n-00041950: 6c66 2e5f 6664 3a0a 2020 2020 2020 2020 lf._fd:. \n-00041960: 2020 2020 2020 2020 6c6f 6767 6572 2e64 logger.d\n-00041970: 6562 7567 2827 6664 2073 6565 6d73 2074 ebug('fd seems t\n-00041980: 6f20 7265 6665 7220 746f 2073 616d 6520 o refer to same \n-00041990: 6669 6c65 2e20 2044 6f69 6e67 206e 6f74 file. Doing not\n-000419a0: 6869 6e67 2e27 290a 2020 2020 2020 2020 hing.'). \n-000419b0: 2020 2020 2020 2020 7265 7475 726e 0a0a return..\n-000419c0: 2020 2020 2020 2020 2020 2020 6c6f 6767 logg\n-000419d0: 6572 2e64 6562 7567 2827 5468 6973 2066 er.debug('This f\n-000419e0: 696c 6520 6973 206e 6577 2066 6f72 2075 ile is new for u\n-000419f0: 732e 2020 5265 6d6f 7669 6e67 206f 6c64 s. Removing old\n-00041a00: 2077 6174 6368 2e27 290a 2020 2020 2020 watch.'). \n-00041a10: 2020 2020 2020 7365 6c66 2e5f 736f 7572 self._sour\n-00041a20: 6365 203d 204e 6f6e 650a 2020 2020 2020 ce = None. \n-00041a30: 2020 2020 2020 7365 6c66 2e5f 6664 2e63 self._fd.c\n-00041a40: 6c6f 7365 2829 0a20 2020 2020 2020 2020 lose(). \n-00041a50: 2020 2073 656c 662e 5f66 6420 3d20 6664 self._fd = fd\n-00041a60: 2e73 7465 616c 2829 0a0a 2020 2020 2020 .steal().. \n-00041a70: 2020 2020 2020 7472 793a 0a20 2020 2020 try:. \n-00041a80: 2020 2020 2020 2020 2020 206c 6f67 6765 logge\n-00041a90: 722e 6465 6275 6728 2745 7374 6162 6c69 r.debug('Establi\n-00041aa0: 7368 696e 6720 6120 6e65 7720 7761 7463 shing a new watc\n-00041ab0: 682e 2729 0a20 2020 2020 2020 2020 2020 h.'). \n-00041ac0: 2020 2020 2073 656c 662e 5f73 6f75 7263 self._sourc\n-00041ad0: 6520 3d20 7365 6c66 2e5f 6576 656e 742e e = self._event.\n-00041ae0: 6164 645f 696e 6f74 6966 795f 6664 2873 add_inotify_fd(s\n-00041af0: 656c 662e 5f66 642c 2049 4e2e 4348 414e elf._fd, IN.CHAN\n-00041b00: 4745 442c 2073 656c 662e 676f 745f 6576 GED, self.got_ev\n-00041b10: 656e 7429 0a20 2020 2020 2020 2020 2020 ent). \n-00041b20: 2020 2020 206c 6f67 6765 722e 6465 6275 logger.debu\n-00041b30: 6728 2757 6174 6368 696e 6720 7375 6363 g('Watching succ\n-00041b40: 6573 7366 756c 6c79 2e20 204e 6f74 6966 essfully. Notif\n-00041b50: 7969 6e67 206f 6620 6e65 7720 6964 656e ying of new iden\n-00041b60: 7469 7479 2e27 290a 2020 2020 2020 2020 tity.'). \n-00041b70: 2020 2020 2020 2020 7365 6c66 2e5f 6c69 self._li\n-00041b80: 7374 656e 6572 2e64 6f5f 6964 656e 7469 stener.do_identi\n-00041b90: 7479 5f63 6861 6e67 6564 2873 656c 662e ty_changed(self.\n-00041ba0: 5f66 642c 204e 6f6e 6529 0a20 2020 2020 _fd, None). \n-00041bb0: 2020 2020 2020 2065 7863 6570 7420 4f53 except OS\n-00041bc0: 4572 726f 7220 6173 2065 7272 6f72 3a0a Error as error:.\n-00041bd0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00041be0: 6c6f 6767 6572 2e64 6562 7567 2827 5761 logger.debug('Wa\n-00041bf0: 7463 6869 6e67 2066 6169 6c65 6420 2825 tching failed (%\n-00041c00: 6429 2e20 204e 6f74 6966 7969 6e67 206f d). Notifying o\n-00041c10: 6620 6e65 7720 6964 656e 7469 7479 2e27 f new identity.'\n-00041c20: 2c20 6572 726f 722e 6572 726e 6f29 0a20 , error.errno). \n-00041c30: 2020 2020 2020 2020 2020 2020 2020 2073 s\n-00041c40: 656c 662e 5f6c 6973 7465 6e65 722e 646f elf._listener.do\n-00041c50: 5f69 6465 6e74 6974 795f 6368 616e 6765 _identity_change\n-00041c60: 6428 7365 6c66 2e5f 6664 2c20 6572 726f d(self._fd, erro\n-00041c70: 722e 6572 726e 6f29 0a0a 2020 2020 6465 r.errno).. de\n-00041c80: 6620 7761 6c6b 2873 656c 6629 202d 3e20 f walk(self) -> \n-00041c90: 4861 6e64 6c65 3a0a 2020 2020 2020 2020 Handle:. \n-00041ca0: 7265 6d61 696e 696e 675f 7379 6d6c 696e remaining_symlin\n-00041cb0: 6b5f 6c6f 6f6b 7570 7320 3d20 3430 0a20 k_lookups = 40. \n-00041cc0: 2020 2020 2020 2072 656d 6169 6e69 6e67 remaining\n-00041cd0: 5f63 6f6d 706f 6e65 6e74 7320 3d20 5061 _components = Pa\n-00041ce0: 7468 5374 6163 6b28 7365 6c66 2e5f 7061 thStack(self._pa\n-00041cf0: 7468 290a 2020 2020 2020 2020 6469 7266 th). dirf\n-00041d00: 6420 3d20 4861 6e64 6c65 2829 0a0a 2020 d = Handle().. \n-00041d10: 2020 2020 2020 7472 793a 0a20 2020 2020 try:. \n-00041d20: 2020 2020 2020 206c 6f67 6765 722e 6465 logger.de\n-00041d30: 6275 6728 2753 7461 7274 696e 6720 7061 bug('Starting pa\n-00041d40: 7468 2077 616c 6b27 290a 0a20 2020 2020 th walk').. \n-00041d50: 2020 2020 2020 2077 6869 6c65 2072 656d while rem\n-00041d60: 6169 6e69 6e67 5f63 6f6d 706f 6e65 6e74 aining_component\n-00041d70: 733a 0a20 2020 2020 2020 2020 2020 2020 s:. \n-00041d80: 2020 206c 6f67 6765 722e 6465 6275 6728 logger.debug(\n-00041d90: 2772 3d25 7320 6466 643d 2573 272c 2072 'r=%s dfd=%s', r\n-00041da0: 656d 6169 6e69 6e67 5f63 6f6d 706f 6e65 emaining_compone\n-00041db0: 6e74 732c 2064 6972 6664 290a 0a20 2020 nts, dirfd).. \n-00041dc0: 2020 2020 2020 2020 2020 2020 206e 616d nam\n-00041dd0: 6520 3d20 7265 6d61 696e 696e 675f 636f e = remaining_co\n-00041de0: 6d70 6f6e 656e 7473 2e70 6f70 2829 0a0a mponents.pop()..\n-00041df0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00041e00: 6966 2064 6972 6664 2061 6e64 206e 616d if dirfd and nam\n-00041e10: 6520 213d 2027 2f27 3a0a 2020 2020 2020 e != '/':. \n-00041e20: 2020 2020 2020 2020 2020 2020 2020 7365 se\n-00041e30: 6c66 2e5f 696e 7661 6c69 6461 746f 7273 lf._invalidators\n-00041e40: 2e61 7070 656e 6428 5761 7463 6849 6e76 .append(WatchInv\n-00041e50: 616c 6964 6174 6f72 2873 656c 662c 2073 alidator(self, s\n-00041e60: 656c 662e 5f65 7665 6e74 2c20 6469 7266 elf._event, dirf\n-00041e70: 642c 206e 616d 6529 290a 0a20 2020 2020 d, name)).. \n-00041e80: 2020 2020 2020 2020 2020 2077 6974 6820 with \n-00041e90: 4861 6e64 6c65 2e6f 7065 6e28 6e61 6d65 Handle.open(name\n-00041ea0: 2c20 6f73 2e4f 5f50 4154 4820 7c20 6f73 , os.O_PATH | os\n-00041eb0: 2e4f 5f4e 4f46 4f4c 4c4f 5720 7c20 6f73 .O_NOFOLLOW | os\n-00041ec0: 2e4f 5f43 4c4f 4558 4543 2c20 6469 725f .O_CLOEXEC, dir_\n-00041ed0: 6664 3d64 6972 6664 2920 6173 2066 643a fd=dirfd) as fd:\n-00041ee0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-00041ef0: 2020 2020 206d 6f64 6520 3d20 6f73 2e66 mode = os.f\n-00041f00: 7374 6174 2866 6429 2e73 745f 6d6f 6465 stat(fd).st_mode\n-00041f10: 0a0a 2020 2020 2020 2020 2020 2020 2020 .. \n-00041f20: 2020 2020 2020 6966 2073 7461 742e 535f if stat.S_\n-00041f30: 4953 4c4e 4b28 6d6f 6465 293a 0a20 2020 ISLNK(mode):. \n-00041f40: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00041f50: 2020 2020 2069 6620 7265 6d61 696e 696e if remainin\n-00041f60: 675f 7379 6d6c 696e 6b5f 6c6f 6f6b 7570 g_symlink_lookup\n-00041f70: 7320 3d3d 2030 3a0a 2020 2020 2020 2020 s == 0:. \n-00041f80: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00041f90: 2020 2020 7261 6973 6520 4f53 4572 726f raise OSErro\n-00041fa0: 7228 6572 726e 6f2e 454c 4f4f 502c 206f r(errno.ELOOP, o\n-00041fb0: 732e 7374 7265 7272 6f72 2865 7272 6e6f s.strerror(errno\n-00041fc0: 2e45 4c4f 4f50 2929 0a20 2020 2020 2020 .ELOOP)). \n-00041fd0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00041fe0: 2072 656d 6169 6e69 6e67 5f73 796d 6c69 remaining_symli\n-00041ff0: 6e6b 5f6c 6f6f 6b75 7073 202d 3d20 310a nk_lookups -= 1.\n-00042000: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00042010: 2020 2020 2020 2020 6c69 6e6b 7061 7468 linkpath\n-00042020: 203d 206f 732e 7265 6164 6c69 6e6b 2827 = os.readlink('\n-00042030: 272c 2064 6972 5f66 643d 6664 290a 2020 ', dir_fd=fd). \n-00042040: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00042050: 2020 2020 2020 6c6f 6767 6572 2e64 6562 logger.deb\n-00042060: 7567 2827 2573 2069 7320 6120 7379 6d6c ug('%s is a syml\n-00042070: 696e 6b2e 2020 6164 6469 6e67 2025 7320 ink. adding %s \n-00042080: 746f 2063 6f6d 706f 6e65 6e74 7327 2c20 to components', \n-00042090: 6e61 6d65 2c20 6c69 6e6b 7061 7468 290a name, linkpath).\n-000420a0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000420b0: 2020 2020 2020 2020 7265 6d61 696e 696e remainin\n-000420c0: 675f 636f 6d70 6f6e 656e 7473 2e61 6464 g_components.add\n-000420d0: 5f70 6174 6828 6c69 6e6b 7061 7468 290a _path(linkpath).\n-000420e0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-000420f0: 2020 2020 2065 6c73 653a 0a20 2020 2020 else:. \n-00042100: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00042110: 2020 2064 6972 6664 2e63 6c6f 7365 2829 dirfd.close()\n-00042120: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-00042130: 2020 2020 2020 2020 2064 6972 6664 203d dirfd =\n-00042140: 2066 642e 7374 6561 6c28 290a 0a20 2020 fd.steal().. \n-00042150: 2020 2020 2020 2020 2072 6574 7572 6e20 return \n-00042160: 6469 7266 642e 7374 6561 6c28 290a 0a20 dirfd.steal().. \n-00042170: 2020 2020 2020 2066 696e 616c 6c79 3a0a finally:.\n-00042180: 2020 2020 2020 2020 2020 2020 6469 7266 dirf\n-00042190: 642e 636c 6f73 6528 290a 0a20 2020 2064 d.close().. d\n-000421a0: 6566 2063 6c6f 7365 2873 656c 6629 202d ef close(self) -\n-000421b0: 3e20 4e6f 6e65 3a0a 2020 2020 2020 2020 > None:. \n-000421c0: 666f 7220 696e 7661 6c69 6461 746f 7220 for invalidator \n-000421d0: 696e 2073 656c 662e 5f69 6e76 616c 6964 in self._invalid\n-000421e0: 6174 6f72 733a 0a20 2020 2020 2020 2020 ators:. \n-000421f0: 2020 2069 6e76 616c 6964 6174 6f72 2e63 invalidator.c\n-00042200: 6c6f 7365 2829 0a20 2020 2020 2020 2073 lose(). s\n-00042210: 656c 662e 5f69 6e76 616c 6964 6174 6f72 elf._invalidator\n-00042220: 7320 3d20 5b5d 0a20 2020 2020 2020 2073 s = []. s\n-00042230: 656c 662e 5f73 6f75 7263 6520 3d20 4e6f elf._source = No\n-00042240: 6e65 0a20 2020 2020 2020 2073 656c 662e ne. self.\n-00042250: 5f66 642e 636c 6f73 6528 290a 2727 272c _fd.close().''',\n-00042260: 0a20 2027 636f 636b 7069 742f 5f76 656e . 'cockpit/_ven\n-00042270: 646f 722f 7379 7374 656d 645f 6374 7970 dor/systemd_ctyp\n-00042280: 6573 2f69 6e6f 7469 6679 2e70 7927 3a20 es/inotify.py': \n-00042290: 6272 2727 2723 2073 7973 7465 6d64 5f63 br'''# systemd_c\n-000422a0: 7479 7065 730a 230a 2320 436f 7079 7269 types.#.# Copyri\n-000422b0: 6768 7420 2843 2920 3230 3232 2041 6c6c ght (C) 2022 All\n-000422c0: 6973 6f6e 204b 6172 6c69 7473 6b61 7961 ison Karlitskaya\n-000422d0: 203c 616c 6c69 736f 6e2e 6b61 726c 6974 <allison.karlit\n-000422e0: 736b 6179 6140 7265 6468 6174 2e63 6f6d skaya@redhat.com\n-000422f0: 3e0a 230a 2320 5468 6973 2070 726f 6772 >.#.# This progr\n-00042300: 616d 2069 7320 6672 6565 2073 6f66 7477 am is free softw\n-00042310: 6172 653a 2079 6f75 2063 616e 2072 6564 are: you can red\n-00042320: 6973 7472 6962 7574 6520 6974 2061 6e64 istribute it and\n-00042330: 2f6f 7220 6d6f 6469 6679 0a23 2069 7420 /or modify.# it \n-00042340: 756e 6465 7220 7468 6520 7465 726d 7320 under the terms \n-00042350: 6f66 2074 6865 2047 4e55 2047 656e 6572 of the GNU Gener\n-00042360: 616c 2050 7562 6c69 6320 4c69 6365 6e73 al Public Licens\n-00042370: 6520 6173 2070 7562 6c69 7368 6564 2062 e as published b\n-00042380: 790a 2320 7468 6520 4672 6565 2053 6f66 y.# the Free Sof\n-00042390: 7477 6172 6520 466f 756e 6461 7469 6f6e tware Foundation\n-000423a0: 2c20 6569 7468 6572 2076 6572 7369 6f6e , either version\n-000423b0: 2033 206f 6620 7468 6520 4c69 6365 6e73 3 of the Licens\n-000423c0: 652c 206f 720a 2320 2861 7420 796f 7572 e, or.# (at your\n-000423d0: 206f 7074 696f 6e29 2061 6e79 206c 6174 option) any lat\n-000423e0: 6572 2076 6572 7369 6f6e 2e0a 230a 2320 er version..#.# \n-000423f0: 5468 6973 2070 726f 6772 616d 2069 7320 This program is \n-00042400: 6469 7374 7269 6275 7465 6420 696e 2074 distributed in t\n-00042410: 6865 2068 6f70 6520 7468 6174 2069 7420 he hope that it \n-00042420: 7769 6c6c 2062 6520 7573 6566 756c 2c0a will be useful,.\n-00042430: 2320 6275 7420 5749 5448 4f55 5420 414e # but WITHOUT AN\n-00042440: 5920 5741 5252 414e 5459 3b20 7769 7468 Y WARRANTY; with\n-00042450: 6f75 7420 6576 656e 2074 6865 2069 6d70 out even the imp\n-00042460: 6c69 6564 2077 6172 7261 6e74 7920 6f66 lied warranty of\n-00042470: 0a23 204d 4552 4348 414e 5441 4249 4c49 .# MERCHANTABILI\n-00042480: 5459 206f 7220 4649 544e 4553 5320 464f TY or FITNESS FO\n-00042490: 5220 4120 5041 5254 4943 554c 4152 2050 R A PARTICULAR P\n-000424a0: 5552 504f 5345 2e20 2053 6565 2074 6865 URPOSE. See the\n-000424b0: 0a23 2047 4e55 2047 656e 6572 616c 2050 .# GNU General P\n-000424c0: 7562 6c69 6320 4c69 6365 6e73 6520 666f ublic License fo\n-000424d0: 7220 6d6f 7265 2064 6574 6169 6c73 2e0a r more details..\n-000424e0: 230a 2320 596f 7520 7368 6f75 6c64 2068 #.# You should h\n-000424f0: 6176 6520 7265 6365 6976 6564 2061 2063 ave received a c\n-00042500: 6f70 7920 6f66 2074 6865 2047 4e55 2047 opy of the GNU G\n-00042510: 656e 6572 616c 2050 7562 6c69 6320 4c69 eneral Public Li\n-00042520: 6365 6e73 650a 2320 616c 6f6e 6720 7769 cense.# along wi\n-00042530: 7468 2074 6869 7320 7072 6f67 7261 6d2e th this program.\n-00042540: 2020 4966 206e 6f74 2c20 7365 6520 3c68 If not, see <h\n-00042550: 7474 703a 2f2f 7777 772e 676e 752e 6f72 ttp://www.gnu.or\n-00042560: 672f 6c69 6365 6e73 6573 2f3e 2e0a 0a69 g/licenses/>...i\n-00042570: 6d70 6f72 7420 6374 7970 6573 0a66 726f mport ctypes.fro\n-00042580: 6d20 656e 756d 2069 6d70 6f72 7420 496e m enum import In\n-00042590: 7446 6c61 672c 2061 7574 6f0a 6672 6f6d tFlag, auto.from\n-000425a0: 2074 7970 696e 6720 696d 706f 7274 204f typing import O\n-000425b0: 7074 696f 6e61 6c0a 0a0a 636c 6173 7320 ptional...class \n-000425c0: 696e 6f74 6966 795f 6576 656e 7428 6374 inotify_event(ct\n-000425d0: 7970 6573 2e53 7472 7563 7475 7265 293a ypes.Structure):\n-000425e0: 0a20 2020 205f 6669 656c 6473 5f20 3d20 . _fields_ = \n-000425f0: 280a 2020 2020 2020 2020 2827 7764 272c (. ('wd',\n-00042600: 2063 7479 7065 732e 635f 696e 7433 3229 ctypes.c_int32)\n-00042610: 2c0a 2020 2020 2020 2020 2827 6d61 736b ,. ('mask\n-00042620: 272c 2063 7479 7065 732e 635f 7569 6e74 ', ctypes.c_uint\n-00042630: 3332 292c 0a20 2020 2020 2020 2028 2763 32),. ('c\n-00042640: 6f6f 6b69 6527 2c20 6374 7970 6573 2e63 ookie', ctypes.c\n-00042650: 5f75 696e 7433 3229 2c0a 2020 2020 2020 _uint32),. \n-00042660: 2020 2827 6c65 6e27 2c20 6374 7970 6573 ('len', ctypes\n-00042670: 2e63 5f75 696e 7433 3229 2c0a 2020 2020 .c_uint32),. \n-00042680: 290a 0a20 2020 2040 7072 6f70 6572 7479 ).. @property\n-00042690: 0a20 2020 2064 6566 206e 616d 6528 7365 . def name(se\n-000426a0: 6c66 2920 2d3e 204f 7074 696f 6e61 6c5b lf) -> Optional[\n-000426b0: 6279 7465 735d 3a0a 2020 2020 2020 2020 bytes]:. \n-000426c0: 6966 2073 656c 662e 6c65 6e20 3d3d 2030 if self.len == 0\n-000426d0: 3a0a 2020 2020 2020 2020 2020 2020 7265 :. re\n-000426e0: 7475 726e 204e 6f6e 650a 0a20 2020 2020 turn None.. \n-000426f0: 2020 2063 6c61 7373 2065 7665 6e74 5f77 class event_w\n-00042700: 6974 685f 6e61 6d65 2863 7479 7065 732e ith_name(ctypes.\n-00042710: 5374 7275 6374 7572 6529 3a0a 2020 2020 Structure):. \n-00042720: 2020 2020 2020 2020 5f66 6965 6c64 735f _fields_\n-00042730: 203d 2028 2a69 6e6f 7469 6679 5f65 7665 = (*inotify_eve\n-00042740: 6e74 2e5f 6669 656c 6473 5f2c 2028 276e nt._fields_, ('n\n-00042750: 616d 6527 2c20 6374 7970 6573 2e63 5f63 ame', ctypes.c_c\n-00042760: 6861 7220 2a20 7365 6c66 2e6c 656e 2929 har * self.len))\n-00042770: 0a0a 2020 2020 2020 2020 6e61 6d65 203d .. name =\n-00042780: 2063 7479 7065 732e 6361 7374 2863 7479 ctypes.cast(cty\n-00042790: 7065 732e 6164 6472 6573 736f 6628 7365 pes.addressof(se\n-000427a0: 6c66 292c 2063 7479 7065 732e 504f 494e lf), ctypes.POIN\n-000427b0: 5445 5228 6576 656e 745f 7769 7468 5f6e TER(event_with_n\n-000427c0: 616d 6529 292e 636f 6e74 656e 7473 2e6e ame)).contents.n\n-000427d0: 616d 650a 2020 2020 2020 2020 6173 7365 ame. asse\n-000427e0: 7274 2069 7369 6e73 7461 6e63 6528 6e61 rt isinstance(na\n-000427f0: 6d65 2c20 6279 7465 7329 0a20 2020 2020 me, bytes). \n-00042800: 2020 2072 6574 7572 6e20 6e61 6d65 0a0a return name..\n-00042810: 0a63 6c61 7373 2045 7665 6e74 2849 6e74 .class Event(Int\n-00042820: 466c 6167 293a 0a20 2020 2041 4343 4553 Flag):. ACCES\n-00042830: 5320 3d20 6175 746f 2829 0a20 2020 204d S = auto(). M\n-00042840: 4f44 4946 5920 3d20 6175 746f 2829 0a20 ODIFY = auto(). \n-00042850: 2020 2041 5454 5249 4220 3d20 6175 746f ATTRIB = auto\n-00042860: 2829 0a20 2020 2043 4c4f 5345 5f57 5249 (). CLOSE_WRI\n-00042870: 5445 203d 2061 7574 6f28 290a 2020 2020 TE = auto(). \n-00042880: 434c 4f53 455f 4e4f 5752 4954 4520 3d20 CLOSE_NOWRITE = \n-00042890: 6175 746f 2829 0a20 2020 204f 5045 4e20 auto(). OPEN \n-000428a0: 3d20 6175 746f 2829 0a20 2020 204d 4f56 = auto(). MOV\n-000428b0: 4544 5f46 524f 4d20 3d20 6175 746f 2829 ED_FROM = auto()\n-000428c0: 0a20 2020 204d 4f56 4544 5f54 4f20 3d20 . MOVED_TO = \n-000428d0: 6175 746f 2829 0a20 2020 2043 5245 4154 auto(). CREAT\n-000428e0: 4520 3d20 6175 746f 2829 0a20 2020 2044 E = auto(). D\n-000428f0: 454c 4554 4520 3d20 6175 746f 2829 0a20 ELETE = auto(). \n-00042900: 2020 2044 454c 4554 455f 5345 4c46 203d DELETE_SELF =\n-00042910: 2061 7574 6f28 290a 2020 2020 4d4f 5645 auto(). MOVE\n-00042920: 5f53 454c 4620 3d20 6175 746f 2829 0a0a _SELF = auto()..\n-00042930: 2020 2020 554e 4d4f 554e 5420 3d20 3120 UNMOUNT = 1 \n-00042940: 3c3c 2031 330a 2020 2020 515f 4f56 4552 << 13. Q_OVER\n-00042950: 464c 4f57 203d 2061 7574 6f28 290a 2020 FLOW = auto(). \n-00042960: 2020 4947 4e4f 5245 4420 3d20 6175 746f IGNORED = auto\n-00042970: 2829 0a0a 2020 2020 4f4e 4c59 4449 5220 ().. ONLYDIR \n-00042980: 3d20 3120 3c3c 2032 340a 2020 2020 444f = 1 << 24. DO\n-00042990: 4e54 5f46 4f4c 4c4f 5720 3d20 6175 746f NT_FOLLOW = auto\n-000429a0: 2829 0a20 2020 2045 5843 4c5f 554e 4c49 (). EXCL_UNLI\n-000429b0: 4e4b 203d 2061 7574 6f28 290a 0a20 2020 NK = auto().. \n-000429c0: 204d 4153 4b5f 4352 4541 5445 203d 2031 MASK_CREATE = 1\n-000429d0: 203c 3c20 3238 0a20 2020 204d 4153 4b5f << 28. MASK_\n-000429e0: 4144 4420 3d20 6175 746f 2829 0a20 2020 ADD = auto(). \n-000429f0: 2049 5344 4952 203d 2061 7574 6f28 290a ISDIR = auto().\n-00042a00: 2020 2020 4f4e 4553 484f 5420 3d20 6175 ONESHOT = au\n-00042a10: 746f 2829 0a0a 2020 2020 434c 4f53 4520 to().. CLOSE \n-00042a20: 3d20 434c 4f53 455f 5752 4954 4520 7c20 = CLOSE_WRITE | \n-00042a30: 434c 4f53 455f 4e4f 5752 4954 450a 2020 CLOSE_NOWRITE. \n-00042a40: 2020 4d4f 5645 203d 204d 4f56 4544 5f46 MOVE = MOVED_F\n-00042a50: 524f 4d20 7c20 4d4f 5645 445f 544f 0a20 ROM | MOVED_TO. \n-00042a60: 2020 2043 4841 4e47 4544 203d 2028 4d4f CHANGED = (MO\n-00042a70: 4449 4659 207c 2041 5454 5249 4220 7c20 DIFY | ATTRIB | \n-00042a80: 434c 4f53 455f 5752 4954 4520 7c20 4d4f CLOSE_WRITE | MO\n-00042a90: 5645 207c 0a20 2020 2020 2020 2020 2020 VE |. \n-00042aa0: 2020 2020 4352 4541 5445 207c 2044 454c CREATE | DEL\n-00042ab0: 4554 4520 7c20 4445 4c45 5445 5f53 454c ETE | DELETE_SEL\n-00042ac0: 4620 7c20 4d4f 5645 5f53 454c 4629 0a27 F | MOVE_SELF).'\n-00042ad0: 2727 2c0a 2020 2763 6f63 6b70 6974 2f5f '',. 'cockpit/_\n-00042ae0: 7665 6e64 6f72 2f73 7973 7465 6d64 5f63 vendor/systemd_c\n-00042af0: 7479 7065 732f 7479 7069 6e67 2e70 7927 types/typing.py'\n-00042b00: 3a20 6272 2727 2769 6d70 6f72 7420 7479 : br'''import ty\n-00042b10: 7069 6e67 0a66 726f 6d20 7479 7069 6e67 ping.from typing\n-00042b20: 2069 6d70 6f72 7420 5459 5045 5f43 4845 import TYPE_CHE\n-00042b30: 434b 494e 470a 0a23 2054 6865 2067 6f61 CKING..# The goa\n-00042b40: 6c20 6865 7265 2069 7320 746f 2063 6f6e l here is to con\n-00042b50: 7469 6e75 6520 746f 2077 6f72 6b20 6f6e tinue to work on\n-00042b60: 2050 7974 686f 6e20 332e 3620 7768 696c Python 3.6 whil\n-00042b70: 6520 7072 6574 656e 6469 6e67 2074 6f20 e pretending to \n-00042b80: 6861 7665 0a23 2061 6363 6573 7320 746f have.# access to\n-00042b90: 2073 6f6d 6520 6d6f 6465 726e 2074 7970 some modern typ\n-00042ba0: 696e 6720 6665 6174 7572 6573 2e20 2054 ing features. T\n-00042bb0: 6865 2073 6869 6d73 2070 726f 7669 6465 he shims provide\n-00042bc0: 6420 6865 7265 2061 7265 206f 6e6c 790a d here are only.\n-00042bd0: 2320 656e 6f75 6768 2066 6f72 2077 6861 # enough for wha\n-00042be0: 7420 7765 206e 6565 6420 666f 7220 7379 t we need for sy\n-00042bf0: 7374 656d 645f 6374 7970 6573 2074 6f20 stemd_ctypes to \n-00042c00: 776f 726b 2061 7420 7275 6e74 696d 652e work at runtime.\n-00042c10: 0a0a 0a69 6620 5459 5045 5f43 4845 434b ...if TYPE_CHECK\n-00042c20: 494e 473a 0a20 2020 2023 2053 6565 2068 ING:. # See h\n-00042c30: 7474 7073 3a2f 2f67 6974 6875 622e 636f ttps://github.co\n-00042c40: 6d2f 7079 7468 6f6e 2f6d 7970 792f 6973 m/python/mypy/is\n-00042c50: 7375 6573 2f31 3135 3320 666f 7220 7768 sues/1153 for wh\n-00042c60: 7920 7765 2064 6f20 7468 6973 2073 6570 y we do this sep\n-00042c70: 6172 6174 656c 790a 2020 2020 6672 6f6d arately. from\n-00042c80: 2074 7970 696e 6720 696d 706f 7274 2041 typing import A\n-00042c90: 6e6e 6f74 6174 6564 2c20 466f 7277 6172 nnotated, Forwar\n-00042ca0: 6452 6566 2c20 5479 7065 4775 6172 642c dRef, TypeGuard,\n-00042cb0: 2067 6574 5f61 7267 732c 2067 6574 5f6f get_args, get_o\n-00042cc0: 7269 6769 6e0a 0a65 6c73 653a 0a20 2020 rigin..else:. \n-00042cd0: 2023 2074 7970 696e 672e 6765 745f 6172 # typing.get_ar\n-00042ce0: 6773 2829 2061 6e64 202e 6765 745f 6f72 gs() and .get_or\n-00042cf0: 6967 696e 2829 2061 7070 6561 7265 6420 igin() appeared \n-00042d00: 696e 2050 7974 686f 6e20 332e 3820 6275 in Python 3.8 bu\n-00042d10: 7420 416e 6e6f 7461 7465 640a 2020 2020 t Annotated. \n-00042d20: 2320 6172 7269 7665 6420 696e 2033 2e39 # arrived in 3.9\n-00042d30: 2e20 2055 6e66 6f72 7475 6e61 7465 6c79 . Unfortunately\n-00042d40: 2c20 6974 2773 2064 6966 6669 6375 6c74 , it's difficult\n-00042d50: 2074 6f20 696d 706c 656d 656e 7420 6120 to implement a \n-00042d60: 6d6f 636b 6564 2075 700a 2020 2020 2320 mocked up. # \n-00042d70: 7665 7273 696f 6e20 6f66 2041 6e6e 6f74 version of Annot\n-00042d80: 6174 6564 2077 6869 6368 2077 6f72 6b73 ated which works\n-00042d90: 2077 6974 6820 7468 6520 7265 616c 2074 with the real t\n-00042da0: 7970 696e 672e 6765 745f 6172 6773 2829 yping.get_args()\n-00042db0: 2061 6e64 0a20 2020 2023 202e 6765 745f and. # .get_\n-00042dc0: 6f72 6967 696e 2829 2069 6e20 5079 7468 origin() in Pyth\n-00042dd0: 6f6e 2033 2e38 2c20 736f 2077 6520 7573 on 3.8, so we us\n-00042de0: 6520 6f75 7220 6f77 6e20 7665 7273 696f e our own versio\n-00042df0: 6e73 2074 6865 7265 2061 7320 7765 6c6c ns there as well\n-00042e00: 2e0a 2020 2020 7472 793a 0a20 2020 2020 .. try:. \n-00042e10: 2020 2066 726f 6d20 7479 7069 6e67 2069 from typing i\n-00042e20: 6d70 6f72 7420 416e 6e6f 7461 7465 642c mport Annotated,\n-00042e30: 2067 6574 5f61 7267 732c 2067 6574 5f6f get_args, get_o\n-00042e40: 7269 6769 6e0a 2020 2020 6578 6365 7074 rigin. except\n-00042e50: 2049 6d70 6f72 7445 7272 6f72 3a0a 2020 ImportError:. \n-00042e60: 2020 2020 2020 636c 6173 7320 416e 6e6f class Anno\n-00042e70: 7461 7465 644d 6574 6128 7479 7065 293a tatedMeta(type):\n-00042e80: 0a20 2020 2020 2020 2020 2020 2064 6566 . def\n-00042e90: 205f 5f67 6574 6974 656d 5f5f 2863 6c73 __getitem__(cls\n-00042ea0: 2c20 7061 7261 6d73 293a 0a20 2020 2020 , params):. \n-00042eb0: 2020 2020 2020 2020 2020 2063 6c61 7373 class\n-00042ec0: 2041 6e6e 6f74 6174 6564 5479 7065 3a0a AnnotatedType:.\n-00042ed0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00042ee0: 2020 2020 5f5f 6f72 6967 696e 5f5f 203d __origin__ =\n-00042ef0: 2041 6e6e 6f74 6174 6564 0a20 2020 2020 Annotated. \n-00042f00: 2020 2020 2020 2020 2020 2020 2020 205f _\n-00042f10: 5f61 7267 735f 5f20 3d20 7061 7261 6d73 _args__ = params\n-00042f20: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-00042f30: 2072 6574 7572 6e20 416e 6e6f 7461 7465 return Annotate\n-00042f40: 6454 7970 650a 0a20 2020 2020 2020 2063 dType.. c\n-00042f50: 6c61 7373 2041 6e6e 6f74 6174 6564 286d lass Annotated(m\n-00042f60: 6574 6163 6c61 7373 3d41 6e6e 6f74 6174 etaclass=Annotat\n-00042f70: 6564 4d65 7461 293a 0a20 2020 2020 2020 edMeta):. \n-00042f80: 2020 2020 2070 6173 730a 0a20 2020 2020 pass.. \n-00042f90: 2020 2064 6566 2067 6574 5f61 7267 7328 def get_args(\n-00042fa0: 616e 6e6f 7461 7469 6f6e 3a20 7479 7069 annotation: typi\n-00042fb0: 6e67 2e41 6e79 2920 2d3e 2074 7970 696e ng.Any) -> typin\n-00042fc0: 672e 5475 706c 655b 7479 7069 6e67 2e41 g.Tuple[typing.A\n-00042fd0: 6e79 5d3a 0a20 2020 2020 2020 2020 2020 ny]:. \n-00042fe0: 2072 6574 7572 6e20 6765 7461 7474 7228 return getattr(\n-00042ff0: 616e 6e6f 7461 7469 6f6e 2c20 275f 5f61 annotation, '__a\n-00043000: 7267 735f 5f27 2c20 2829 290a 0a20 2020 rgs__', ()).. \n-00043010: 2020 2020 2064 6566 2067 6574 5f6f 7269 def get_ori\n-00043020: 6769 6e28 616e 6e6f 7461 7469 6f6e 3a20 gin(annotation: \n-00043030: 7479 7069 6e67 2e41 6e79 2920 2d3e 2074 typing.Any) -> t\n-00043040: 7970 696e 672e 416e 793a 0a20 2020 2020 yping.Any:. \n-00043050: 2020 2020 2020 2072 6574 7572 6e20 6765 return ge\n-00043060: 7461 7474 7228 616e 6e6f 7461 7469 6f6e tattr(annotation\n-00043070: 2c20 275f 5f6f 7269 6769 6e5f 5f27 2c20 , '__origin__', \n-00043080: 4e6f 6e65 290a 0a20 2020 2074 7279 3a0a None).. try:.\n-00043090: 2020 2020 2020 2020 6672 6f6d 2074 7970 from typ\n-000430a0: 696e 6720 696d 706f 7274 2046 6f72 7761 ing import Forwa\n-000430b0: 7264 5265 660a 2020 2020 6578 6365 7074 rdRef. except\n-000430c0: 2049 6d70 6f72 7445 7272 6f72 3a0a 2020 ImportError:. \n-000430d0: 2020 2020 2020 6672 6f6d 2074 7970 696e from typin\n-000430e0: 6720 696d 706f 7274 205f 466f 7277 6172 g import _Forwar\n-000430f0: 6452 6566 2061 7320 466f 7277 6172 6452 dRef as ForwardR\n-00043100: 6566 0a0a 2020 2020 7472 793a 0a20 2020 ef.. try:. \n-00043110: 2020 2020 2066 726f 6d20 7479 7069 6e67 from typing\n-00043120: 2069 6d70 6f72 7420 5479 7065 4775 6172 import TypeGuar\n-00043130: 640a 2020 2020 6578 6365 7074 2049 6d70 d. except Imp\n-00043140: 6f72 7445 7272 6f72 3a0a 2020 2020 2020 ortError:. \n-00043150: 2020 5420 3d20 7479 7069 6e67 2e54 7970 T = typing.Typ\n-00043160: 6556 6172 2827 5427 290a 0a20 2020 2020 eVar('T').. \n-00043170: 2020 2063 6c61 7373 2054 7970 6547 7561 class TypeGua\n-00043180: 7264 2874 7970 696e 672e 4765 6e65 7269 rd(typing.Generi\n-00043190: 635b 545d 293a 0a20 2020 2020 2020 2020 c[T]):. \n-000431a0: 2020 2070 6173 730a 0a0a 5f5f 616c 6c5f pass...__all_\n-000431b0: 5f20 3d20 280a 2020 2020 2741 6e6e 6f74 _ = (. 'Annot\n-000431c0: 6174 6564 272c 0a20 2020 2027 466f 7277 ated',. 'Forw\n-000431d0: 6172 6452 6566 272c 0a20 2020 2027 5479 ardRef',. 'Ty\n-000431e0: 7065 4775 6172 6427 2c0a 2020 2020 2767 peGuard',. 'g\n-000431f0: 6574 5f61 7267 7327 2c0a 2020 2020 2767 et_args',. 'g\n-00043200: 6574 5f6f 7269 6769 6e27 2c0a 2020 2020 et_origin',. \n-00043210: 2754 5950 455f 4348 4543 4b49 4e47 272c 'TYPE_CHECKING',\n-00043220: 0a29 0a27 2727 2c0a 2020 2763 6f63 6b70 .).''',. 'cockp\n-00043230: 6974 2f5f 7665 6e64 6f72 2f73 7973 7465 it/_vendor/syste\n-00043240: 6d64 5f63 7479 7065 732f 6c69 6272 6172 md_ctypes/librar\n-00043250: 7977 7261 7070 6572 2e70 7927 3a20 6272 ywrapper.py': br\n-00043260: 2727 2723 2073 7973 7465 6d64 5f63 7479 '''# systemd_cty\n-00043270: 7065 730a 230a 2320 436f 7079 7269 6768 pes.#.# Copyrigh\n-00043280: 7420 2843 2920 3230 3232 2041 6c6c 6973 t (C) 2022 Allis\n-00043290: 6f6e 204b 6172 6c69 7473 6b61 7961 203c on Karlitskaya <\n-000432a0: 616c 6c69 736f 6e2e 6b61 726c 6974 736b allison.karlitsk\n-000432b0: 6179 6140 7265 6468 6174 2e63 6f6d 3e0a aya@redhat.com>.\n-000432c0: 230a 2320 5468 6973 2070 726f 6772 616d #.# This program\n-000432d0: 2069 7320 6672 6565 2073 6f66 7477 6172 is free softwar\n-000432e0: 653a 2079 6f75 2063 616e 2072 6564 6973 e: you can redis\n-000432f0: 7472 6962 7574 6520 6974 2061 6e64 2f6f tribute it and/o\n-00043300: 7220 6d6f 6469 6679 0a23 2069 7420 756e r modify.# it un\n-00043310: 6465 7220 7468 6520 7465 726d 7320 6f66 der the terms of\n-00043320: 2074 6865 2047 4e55 2047 656e 6572 616c the GNU General\n-00043330: 2050 7562 6c69 6320 4c69 6365 6e73 6520 Public License \n-00043340: 6173 2070 7562 6c69 7368 6564 2062 790a as published by.\n-00043350: 2320 7468 6520 4672 6565 2053 6f66 7477 # the Free Softw\n-00043360: 6172 6520 466f 756e 6461 7469 6f6e 2c20 are Foundation, \n-00043370: 6569 7468 6572 2076 6572 7369 6f6e 2033 either version 3\n-00043380: 206f 6620 7468 6520 4c69 6365 6e73 652c of the License,\n-00043390: 206f 720a 2320 2861 7420 796f 7572 206f or.# (at your o\n-000433a0: 7074 696f 6e29 2061 6e79 206c 6174 6572 ption) any later\n-000433b0: 2076 6572 7369 6f6e 2e0a 230a 2320 5468 version..#.# Th\n-000433c0: 6973 2070 726f 6772 616d 2069 7320 6469 is program is di\n-000433d0: 7374 7269 6275 7465 6420 696e 2074 6865 stributed in the\n-000433e0: 2068 6f70 6520 7468 6174 2069 7420 7769 hope that it wi\n-000433f0: 6c6c 2062 6520 7573 6566 756c 2c0a 2320 ll be useful,.# \n-00043400: 6275 7420 5749 5448 4f55 5420 414e 5920 but WITHOUT ANY \n-00043410: 5741 5252 414e 5459 3b20 7769 7468 6f75 WARRANTY; withou\n-00043420: 7420 6576 656e 2074 6865 2069 6d70 6c69 t even the impli\n-00043430: 6564 2077 6172 7261 6e74 7920 6f66 0a23 ed warranty of.#\n-00043440: 204d 4552 4348 414e 5441 4249 4c49 5459 MERCHANTABILITY\n-00043450: 206f 7220 4649 544e 4553 5320 464f 5220 or FITNESS FOR \n-00043460: 4120 5041 5254 4943 554c 4152 2050 5552 A PARTICULAR PUR\n-00043470: 504f 5345 2e20 2053 6565 2074 6865 0a23 POSE. See the.#\n-00043480: 2047 4e55 2047 656e 6572 616c 2050 7562 GNU General Pub\n-00043490: 6c69 6320 4c69 6365 6e73 6520 666f 7220 lic License for \n-000434a0: 6d6f 7265 2064 6574 6169 6c73 2e0a 230a more details..#.\n-000434b0: 2320 596f 7520 7368 6f75 6c64 2068 6176 # You should hav\n-000434c0: 6520 7265 6365 6976 6564 2061 2063 6f70 e received a cop\n-000434d0: 7920 6f66 2074 6865 2047 4e55 2047 656e y of the GNU Gen\n-000434e0: 6572 616c 2050 7562 6c69 6320 4c69 6365 eral Public Lice\n-000434f0: 6e73 650a 2320 616c 6f6e 6720 7769 7468 nse.# along with\n-00043500: 2074 6869 7320 7072 6f67 7261 6d2e 2020 this program. \n-00043510: 4966 206e 6f74 2c20 7365 6520 3c68 7474 If not, see <htt\n-00043520: 703a 2f2f 7777 772e 676e 752e 6f72 672f p://www.gnu.org/\n-00043530: 6c69 6365 6e73 6573 2f3e 2e0a 0a69 6d70 licenses/>...imp\n-00043540: 6f72 7420 6374 7970 6573 0a69 6d70 6f72 ort ctypes.impor\n-00043550: 7420 696e 7370 6563 740a 696d 706f 7274 t inspect.import\n-00043560: 206c 6f67 6769 6e67 0a69 6d70 6f72 7420 logging.import \n-00043570: 6f73 0a69 6d70 6f72 7420 7379 730a 696d os.import sys.im\n-00043580: 706f 7274 2074 7970 6573 0a66 726f 6d20 port types.from \n-00043590: 7479 7069 6e67 2069 6d70 6f72 7420 280a typing import (.\n-000435a0: 2020 2020 416e 792c 0a20 2020 2043 616c Any,. Cal\n-000435b0: 6c61 626c 652c 0a20 2020 2044 6963 742c lable,. Dict,\n-000435c0: 0a20 2020 2047 656e 6572 6963 2c0a 2020 . Generic,. \n-000435d0: 2020 4e65 7754 7970 652c 0a20 2020 204e NewType,. N\n-000435e0: 6f52 6574 7572 6e2c 0a20 2020 204f 7074 oReturn,. Opt\n-000435f0: 696f 6e61 6c2c 0a20 2020 2054 7570 6c65 ional,. Tuple\n-00043600: 2c0a 2020 2020 5479 7065 2c0a 2020 2020 ,. Type,. \n-00043610: 5479 7065 5661 722c 0a20 2020 2055 6e69 TypeVar,. Uni\n-00043620: 6f6e 2c0a 290a 0a66 726f 6d20 2e20 696d on,.)..from . im\n-00043630: 706f 7274 2074 7970 696e 670a 0a23 2046 port typing..# F\n-00043640: 6972 7374 2069 6e20 332e 3130 2c20 616e irst in 3.10, an\n-00043650: 6420 636f 6e64 6974 696f 6e61 6c20 696d d conditional im\n-00043660: 706f 7274 2067 6976 6573 2074 7970 6520 port gives type \n-00043670: 6572 726f 7273 0a4e 6f6e 6554 7970 6520 errors.NoneType \n-00043680: 3d20 7479 7065 284e 6f6e 6529 0a0a 6c6f = type(None)..lo\n-00043690: 6767 6572 203d 206c 6f67 6769 6e67 2e67 gger = logging.g\n-000436a0: 6574 4c6f 6767 6572 285f 5f6e 616d 655f etLogger(__name_\n-000436b0: 5f29 0a0a 6966 2074 7970 696e 672e 5459 _)..if typing.TY\n-000436c0: 5045 5f43 4845 434b 494e 473a 0a20 2020 PE_CHECKING:. \n-000436d0: 2043 5479 7065 203d 2054 7970 6556 6172 CType = TypeVar\n-000436e0: 2822 4354 7970 6522 2c20 626f 756e 643d (\"CType\", bound=\n-000436f0: 6374 7970 6573 2e5f 4344 6174 6129 0a20 ctypes._CData). \n-00043700: 2020 2043 616c 6c62 6163 6b20 3d20 6374 Callback = ct\n-00043710: 7970 6573 2e5f 4675 6e63 506f 696e 7465 ypes._FuncPointe\n-00043720: 720a 656c 7365 3a0a 2020 2020 4354 7970 r.else:. CTyp\n-00043730: 6520 3d20 5479 7065 5661 7228 2243 5479 e = TypeVar(\"CTy\n-00043740: 7065 2229 0a20 2020 2043 616c 6c62 6163 pe\"). Callbac\n-00043750: 6b20 3d20 6374 7970 6573 2e63 5f76 6f69 k = ctypes.c_voi\n-00043760: 645f 700a 0a0a 6966 2074 7970 696e 672e d_p...if typing.\n-00043770: 5459 5045 5f43 4845 434b 494e 473a 0a20 TYPE_CHECKING:. \n-00043780: 2020 2063 6c61 7373 2052 6566 6572 656e class Referen\n-00043790: 6365 2847 656e 6572 6963 5b43 5479 7065 ce(Generic[CType\n-000437a0: 5d2c 2063 7479 7065 732e 5f50 6f69 6e74 ], ctypes._Point\n-000437b0: 6572 5b43 5479 7065 5d29 3a0a 2020 2020 er[CType]):. \n-000437c0: 2020 2020 7061 7373 0a0a 2020 2020 6465 pass.. de\n-000437d0: 6620 6279 7265 6628 783a 2043 5479 7065 f byref(x: CType\n-000437e0: 2920 2d3e 2052 6566 6572 656e 6365 5b43 ) -> Reference[C\n-000437f0: 5479 7065 5d3a 0a20 2020 2020 2020 2072 Type]:. r\n-00043800: 6169 7365 204e 6f74 496d 706c 656d 656e aise NotImplemen\n-00043810: 7465 6445 7272 6f72 0a65 6c73 653a 0a20 tedError.else:. \n-00043820: 2020 2063 6c61 7373 2052 6566 6572 656e class Referen\n-00043830: 6365 2847 656e 6572 6963 5b43 5479 7065 ce(Generic[CType\n-00043840: 5d29 3a0a 2020 2020 2020 2020 7061 7373 ]):. pass\n-00043850: 0a0a 2020 2020 6279 7265 6620 3d20 6374 .. byref = ct\n-00043860: 7970 6573 2e62 7972 6566 0a0a 0a55 7365 ypes.byref...Use\n-00043870: 7244 6174 6120 3d20 4f70 7469 6f6e 616c rData = Optional\n-00043880: 5b63 7479 7065 732e 635f 766f 6964 5f70 [ctypes.c_void_p\n-00043890: 5d0a 0a0a 636c 6173 7320 6e65 6761 7469 ]...class negati\n-000438a0: 7665 5f65 7272 6e6f 2863 7479 7065 732e ve_errno(ctypes.\n-000438b0: 635f 696e 7429 3a0a 2020 2020 6465 6620 c_int):. def \n-000438c0: 6572 7263 6865 636b 2873 656c 662c 2066 errcheck(self, f\n-000438d0: 756e 633a 2043 616c 6c61 626c 655b 2e2e unc: Callable[..\n-000438e0: 2e2c 206f 626a 6563 745d 2c20 5f61 7267 ., object], _arg\n-000438f0: 733a 2054 7570 6c65 5b6f 626a 6563 742c s: Tuple[object,\n-00043900: 202e 2e2e 5d29 202d 3e20 696e 743a 0a20 ...]) -> int:. \n-00043910: 2020 2020 2020 2072 6573 756c 7420 3d20 result = \n-00043920: 7365 6c66 2e76 616c 7565 0a20 2020 2020 self.value. \n-00043930: 2020 2069 6620 7265 7375 6c74 203c 2030 if result < 0\n-00043940: 3a0a 2020 2020 2020 2020 2020 2020 7261 :. ra\n-00043950: 6973 6520 4f53 4572 726f 7228 2d72 6573 ise OSError(-res\n-00043960: 756c 742c 2066 227b 6675 6e63 2e5f 5f6e ult, f\"{func.__n\n-00043970: 616d 655f 5f7d 3a20 7b6f 732e 7374 7265 ame__}: {os.stre\n-00043980: 7272 6f72 282d 7265 7375 6c74 297d 2229 rror(-result)}\")\n-00043990: 0a20 2020 2020 2020 2072 6574 7572 6e20 . return \n-000439a0: 7265 7375 6c74 0a0a 0a63 6c61 7373 2075 result...class u\n-000439b0: 7466 3828 6374 7970 6573 2e63 5f63 6861 tf8(ctypes.c_cha\n-000439c0: 725f 7029 3a0a 2020 2020 6465 6620 6572 r_p):. def er\n-000439d0: 7263 6865 636b 2873 656c 662c 2066 756e rcheck(self, fun\n-000439e0: 633a 2043 616c 6c61 626c 655b 2e2e 2e2c c: Callable[...,\n-000439f0: 206f 626a 6563 745d 2c20 5f61 7267 733a object], _args:\n-00043a00: 2054 7570 6c65 5b6f 626a 6563 742c 202e Tuple[object, .\n-00043a10: 2e2e 5d29 202d 3e20 7374 723a 0a20 2020 ..]) -> str:. \n-00043a20: 2020 2020 2061 7373 6572 7420 7365 6c66 assert self\n-00043a30: 2e76 616c 7565 2069 7320 6e6f 7420 4e6f .value is not No\n-00043a40: 6e65 0a20 2020 2020 2020 2072 6574 7572 ne. retur\n-00043a50: 6e20 7365 6c66 2e76 616c 7565 2e64 6563 n self.value.dec\n-00043a60: 6f64 6528 290a 0a20 2020 2040 636c 6173 ode().. @clas\n-00043a70: 736d 6574 686f 640a 2020 2020 6465 6620 smethod. def \n-00043a80: 6672 6f6d 5f70 6172 616d 2863 6c73 2c20 from_param(cls, \n-00043a90: 7661 6c75 653a 2073 7472 2920 2d3e 2027 value: str) -> '\n-00043aa0: 7574 6638 273a 0a20 2020 2020 2020 2072 utf8':. r\n-00043ab0: 6574 7572 6e20 636c 7328 7661 6c75 652e eturn cls(value.\n-00043ac0: 656e 636f 6465 2829 290a 0a0a 636c 6173 encode())...clas\n-00043ad0: 7320 7574 6638 5f6f 725f 6e75 6c6c 2863 s utf8_or_null(c\n-00043ae0: 7479 7065 732e 635f 6368 6172 5f70 293a types.c_char_p):\n-00043af0: 0a20 2020 2064 6566 2065 7272 6368 6563 . def errchec\n-00043b00: 6b28 7365 6c66 2c0a 2020 2020 2020 2020 k(self,. \n-00043b10: 2020 2020 2020 2020 2066 756e 633a 2043 func: C\n-00043b20: 616c 6c61 626c 655b 2e2e 2e2c 206f 626a allable[..., obj\n-00043b30: 6563 745d 2c0a 2020 2020 2020 2020 2020 ect],. \n-00043b40: 2020 2020 2020 205f 6172 6773 3a20 5475 _args: Tu\n-00043b50: 706c 655b 6f62 6a65 6374 2c20 2e2e 2e5d ple[object, ...]\n-00043b60: 2920 2d3e 204f 7074 696f 6e61 6c5b 7374 ) -> Optional[st\n-00043b70: 725d 3a0a 2020 2020 2020 2020 7265 7475 r]:. retu\n-00043b80: 726e 2073 656c 662e 7661 6c75 652e 6465 rn self.value.de\n-00043b90: 636f 6465 2829 2069 6620 7365 6c66 2e76 code() if self.v\n-00043ba0: 616c 7565 2069 7320 6e6f 7420 4e6f 6e65 alue is not None\n-00043bb0: 2065 6c73 6520 4e6f 6e65 0a0a 2020 2020 else None.. \n-00043bc0: 4063 6c61 7373 6d65 7468 6f64 0a20 2020 @classmethod. \n-00043bd0: 2064 6566 2066 726f 6d5f 7061 7261 6d28 def from_param(\n-00043be0: 636c 732c 2076 616c 7565 3a20 4f70 7469 cls, value: Opti\n-00043bf0: 6f6e 616c 5b73 7472 5d29 202d 3e20 2775 onal[str]) -> 'u\n-00043c00: 7466 385f 6f72 5f6e 756c 6c27 3a0a 2020 tf8_or_null':. \n-00043c10: 2020 2020 2020 7265 7475 726e 2063 6c73 return cls\n-00043c20: 2876 616c 7565 2e65 6e63 6f64 6528 2920 (value.encode() \n-00043c30: 6966 2076 616c 7565 2069 7320 6e6f 7420 if value is not \n-00043c40: 4e6f 6e65 2065 6c73 6520 4e6f 6e65 290a None else None).\n-00043c50: 0a0a 636c 6173 7320 626f 6f6c 696e 7428 ..class boolint(\n-00043c60: 6374 7970 6573 2e63 5f69 6e74 293a 0a20 ctypes.c_int):. \n-00043c70: 2020 2064 6566 2065 7272 6368 6563 6b28 def errcheck(\n-00043c80: 7365 6c66 2c20 6675 6e63 3a20 4361 6c6c self, func: Call\n-00043c90: 6162 6c65 5b2e 2e2e 2c20 6f62 6a65 6374 able[..., object\n-00043ca0: 5d2c 205f 6172 6773 3a20 5475 706c 655b ], _args: Tuple[\n-00043cb0: 6f62 6a65 6374 2c20 2e2e 2e5d 2920 2d3e object, ...]) ->\n-00043cc0: 2062 6f6f 6c3a 0a20 2020 2020 2020 2072 bool:. r\n-00043cd0: 6574 7572 6e20 626f 6f6c 2873 656c 662e eturn bool(self.\n-00043ce0: 7661 6c75 6529 0a0a 0a57 6561 6b52 6566 value)...WeakRef\n-00043cf0: 6572 656e 6365 203d 204e 6577 5479 7065 erence = NewType\n-00043d00: 2822 5765 616b 5265 6665 7265 6e63 6522 (\"WeakReference\"\n-00043d10: 2c20 696e 7429 0a45 7272 6e6f 203d 2074 , int).Errno = t\n-00043d20: 7970 696e 672e 416e 6e6f 7461 7465 645b yping.Annotated[\n-00043d30: 4e6f 5265 7475 726e 2c20 2265 7272 6e6f NoReturn, \"errno\n-00043d40: 225d 0a0a 0a74 7970 655f 6d61 7020 3d20 \"]...type_map = \n-00043d50: 7b0a 2020 2020 556e 696f 6e5b 4e6f 6e65 {. Union[None\n-00043d60: 2c20 4572 726e 6f5d 3a20 6e65 6761 7469 , Errno]: negati\n-00043d70: 7665 5f65 7272 6e6f 2c20 2023 2074 6563 ve_errno, # tec\n-00043d80: 686e 6963 616c 6c79 2072 6574 7572 6e73 hnically returns\n-00043d90: 2069 6e74 0a20 2020 2055 6e69 6f6e 5b62 int. Union[b\n-00043da0: 6f6f 6c2c 2045 7272 6e6f 5d3a 206e 6567 ool, Errno]: neg\n-00043db0: 6174 6976 655f 6572 726e 6f2c 2020 2320 ative_errno, # \n-00043dc0: 7465 6368 6e69 6361 6c6c 7920 7265 7475 technically retu\n-00043dd0: 726e 7320 696e 740a 2020 2020 556e 696f rns int. Unio\n-00043de0: 6e5b 696e 742c 2045 7272 6e6f 5d3a 206e n[int, Errno]: n\n-00043df0: 6567 6174 6976 655f 6572 726e 6f2c 0a20 egative_errno,. \n-00043e00: 2020 2062 6f6f 6c3a 2062 6f6f 6c69 6e74 bool: boolint\n-00043e10: 2c0a 2020 2020 4f70 7469 6f6e 616c 5b73 ,. Optional[s\n-00043e20: 7472 5d3a 2075 7466 385f 6f72 5f6e 756c tr]: utf8_or_nul\n-00043e30: 6c2c 0a20 2020 2073 7472 3a20 7574 6638 l,. str: utf8\n-00043e40: 2c0a 2020 2020 696e 743a 2063 7479 7065 ,. int: ctype\n-00043e50: 732e 635f 696e 742c 0a20 2020 2057 6561 s.c_int,. Wea\n-00043e60: 6b52 6566 6572 656e 6365 3a20 6374 7970 kReference: ctyp\n-00043e70: 6573 2e63 5f76 6f69 645f 700a 7d0a 0a0a es.c_void_p.}...\n-00043e80: 6465 6620 6d61 705f 7479 7065 2861 6e6e def map_type(ann\n-00043e90: 6f74 6174 696f 6e3a 2041 6e79 2c20 676c otation: Any, gl\n-00043ea0: 6f62 616c 5f76 6172 733a 2044 6963 745b obal_vars: Dict[\n-00043eb0: 7374 722c 206f 626a 6563 745d 2920 2d3e str, object]) ->\n-00043ec0: 2041 6e79 3a0a 2020 2020 7472 793a 0a20 Any:. try:. \n-00043ed0: 2020 2020 2020 2072 6574 7572 6e20 7479 return ty\n-00043ee0: 7065 5f6d 6170 5b61 6e6e 6f74 6174 696f pe_map[annotatio\n-00043ef0: 6e5d 0a20 2020 2065 7863 6570 7420 4b65 n]. except Ke\n-00043f00: 7945 7272 6f72 3a0a 2020 2020 2020 2020 yError:. \n-00043f10: 7061 7373 2020 2320 2e2e 2e20 616e 6420 pass # ... and \n-00043f20: 7472 7920 6d6f 7265 2063 6173 6573 2062 try more cases b\n-00043f30: 656c 6f77 0a0a 2020 2020 6966 2069 7369 elow.. if isi\n-00043f40: 6e73 7461 6e63 6528 616e 6e6f 7461 7469 nstance(annotati\n-00043f50: 6f6e 2c20 7479 7069 6e67 2e46 6f72 7761 on, typing.Forwa\n-00043f60: 7264 5265 6629 3a0a 2020 2020 2020 2020 rdRef):. \n-00043f70: 616e 6e6f 7461 7469 6f6e 203d 2061 6e6e annotation = ann\n-00043f80: 6f74 6174 696f 6e2e 5f5f 666f 7277 6172 otation.__forwar\n-00043f90: 645f 6172 675f 5f0a 0a20 2020 2069 6620 d_arg__.. if \n-00043fa0: 6973 696e 7374 616e 6365 2861 6e6e 6f74 isinstance(annot\n-00043fb0: 6174 696f 6e2c 2073 7472 293a 0a20 2020 ation, str):. \n-00043fc0: 2020 2020 2061 6e6e 6f74 6174 696f 6e20 annotation \n-00043fd0: 3d20 676c 6f62 616c 5f76 6172 735b 616e = global_vars[an\n-00043fe0: 6e6f 7461 7469 6f6e 5d0a 0a20 2020 206f notation].. o\n-00043ff0: 7269 6769 6e20 3d20 7479 7069 6e67 2e67 rigin = typing.g\n-00044000: 6574 5f6f 7269 6769 6e28 616e 6e6f 7461 et_origin(annota\n-00044010: 7469 6f6e 290a 2020 2020 6172 6773 203d tion). args =\n-00044020: 2074 7970 696e 672e 6765 745f 6172 6773 typing.get_args\n-00044030: 2861 6e6e 6f74 6174 696f 6e29 0a0a 2020 (annotation).. \n-00044040: 2020 6966 206f 7269 6769 6e20 6973 2052 if origin is R\n-00044050: 6566 6572 656e 6365 3a0a 2020 2020 2020 eference:. \n-00044060: 2020 7265 7475 726e 2063 7479 7065 732e return ctypes.\n-00044070: 504f 494e 5445 5228 6d61 705f 7479 7065 POINTER(map_type\n-00044080: 2861 7267 735b 305d 2c20 676c 6f62 616c (args[0], global\n-00044090: 5f76 6172 7329 290a 0a20 2020 2065 6c69 _vars)).. eli\n-000440a0: 6620 6f72 6967 696e 2069 7320 556e 696f f origin is Unio\n-000440b0: 6e20 616e 6420 4e6f 6e65 5479 7065 2069 n and NoneType i\n-000440c0: 6e20 6172 6773 3a0a 2020 2020 2020 2020 n args:. \n-000440d0: 2320 7468 6520 4320 706f 696e 7465 7220 # the C pointer \n-000440e0: 7479 7065 7320 6172 6520 616c 7265 6164 types are alread\n-000440f0: 7920 6e75 6c6c 6162 6c65 0a20 2020 2020 y nullable. \n-00044100: 2020 206f 7468 6572 5f61 7267 2c20 3d20 other_arg, = \n-00044110: 7365 7428 6172 6773 2920 2d20 7b4e 6f6e set(args) - {Non\n-00044120: 6554 7970 657d 0a20 2020 2020 2020 2072 eType}. r\n-00044130: 6574 7572 6e20 6d61 705f 7479 7065 286f eturn map_type(o\n-00044140: 7468 6572 5f61 7267 2c20 676c 6f62 616c ther_arg, global\n-00044150: 5f76 6172 7329 0a0a 2020 2020 656c 6966 _vars).. elif\n-00044160: 206f 7269 6769 6e20 6973 2074 7970 696e origin is typin\n-00044170: 672e 416e 6e6f 7461 7465 643a 0a20 2020 g.Annotated:. \n-00044180: 2020 2020 2072 6574 7572 6e20 6172 6773 return args\n-00044190: 5b31 5d0a 0a20 2020 2065 6c73 653a 0a20 [1].. else:. \n-000441a0: 2020 2020 2020 2061 7373 6572 7420 6f72 assert or\n-000441b0: 6967 696e 2069 7320 4e6f 6e65 2c20 6f72 igin is None, or\n-000441c0: 6967 696e 0a20 2020 2020 2020 2072 6574 igin. ret\n-000441d0: 7572 6e20 616e 6e6f 7461 7469 6f6e 0a0a urn annotation..\n-000441e0: 0a63 6c61 7373 2052 6566 6572 656e 6365 .class Reference\n-000441f0: 5479 7065 2863 7479 7065 732e 635f 766f Type(ctypes.c_vo\n-00044200: 6964 5f70 293a 0a20 2020 2040 636c 6173 id_p):. @clas\n-00044210: 736d 6574 686f 640a 2020 2020 6465 6620 smethod. def \n-00044220: 5f69 6e73 7461 6c6c 5f63 6675 6e63 7328 _install_cfuncs(\n-00044230: 636c 732c 2063 646c 6c3a 2063 7479 7065 cls, cdll: ctype\n-00044240: 732e 4344 4c4c 2920 2d3e 204e 6f6e 653a s.CDLL) -> None:\n-00044250: 0a20 2020 2020 2020 206c 6f67 6765 722e . logger.\n-00044260: 6465 6275 6728 2749 6e73 7461 6c6c 696e debug('Installin\n-00044270: 6720 7374 7562 7320 666f 7220 2573 3a27 g stubs for %s:'\n-00044280: 2c20 636c 7329 0a20 2020 2020 2020 2073 , cls). s\n-00044290: 7475 6273 203d 2074 7570 6c65 2863 6c73 tubs = tuple(cls\n-000442a0: 2e5f 5f64 6963 745f 5f2e 6974 656d 7328 .__dict__.items(\n-000442b0: 2929 0a20 2020 2020 2020 2066 6f72 206e )). for n\n-000442c0: 616d 652c 2073 7475 6220 696e 2073 7475 ame, stub in stu\n-000442d0: 6273 3a0a 2020 2020 2020 2020 2020 2020 bs:. \n-000442e0: 6966 206e 616d 652e 7374 6172 7473 7769 if name.startswi\n-000442f0: 7468 2822 5f5f 2229 3a0a 2020 2020 2020 th(\"__\"):. \n-00044300: 2020 2020 2020 2020 2020 636f 6e74 696e contin\n-00044310: 7565 0a20 2020 2020 2020 2020 2020 2063 ue. c\n-00044320: 6c73 2e5f 7772 6170 2863 646c 6c2c 2073 ls._wrap(cdll, s\n-00044330: 7475 6229 0a0a 2020 2020 2020 2020 636c tub).. cl\n-00044340: 732e 5f77 7261 7028 6364 6c6c 2c20 636c s._wrap(cdll, cl\n-00044350: 732e 5f72 6566 290a 2020 2020 2020 2020 s._ref). \n-00044360: 636c 732e 5f77 7261 7028 6364 6c6c 2c20 cls._wrap(cdll, \n-00044370: 636c 732e 5f75 6e72 6566 290a 0a20 2020 cls._unref).. \n-00044380: 2040 636c 6173 736d 6574 686f 640a 2020 @classmethod. \n-00044390: 2020 6465 6620 5f77 7261 7028 636c 732c def _wrap(cls,\n-000443a0: 2063 646c 6c3a 2063 7479 7065 732e 4344 cdll: ctypes.CD\n-000443b0: 4c4c 2c20 7374 7562 3a20 6f62 6a65 6374 LL, stub: object\n-000443c0: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n-000443d0: 2020 2073 7475 625f 7479 7065 203d 2074 stub_type = t\n-000443e0: 7970 6528 7374 7562 290a 2020 2020 2020 ype(stub). \n-000443f0: 2020 6966 2069 7369 6e73 7461 6e63 6528 if isinstance(\n-00044400: 7374 7562 2c20 7374 6174 6963 6d65 7468 stub, staticmeth\n-00044410: 6f64 293a 0a20 2020 2020 2020 2020 2020 od):. \n-00044420: 2023 2049 6e20 6f6c 6465 7220 5079 7468 # In older Pyth\n-00044430: 6f6e 2076 6572 7369 6f6e 732c 2073 7461 on versions, sta\n-00044440: 7469 636d 6574 686f 6428 2920 6973 6e27 ticmethod() isn'\n-00044450: 7420 636f 6e73 6964 6572 6564 0a20 2020 t considered. \n-00044460: 2020 2020 2020 2020 2023 2063 616c 6c61 # calla\n-00044470: 626c 652c 2064 6f65 736e 2774 2068 6176 ble, doesn't hav\n-00044480: 6520 6120 6e61 6d65 2c20 616e 6420 6361 e a name, and ca\n-00044490: 6e27 7420 6265 2069 6e74 726f 7370 6563 n't be introspec\n-000444a0: 7465 6420 7769 7468 0a20 2020 2020 2020 ted with. \n-000444b0: 2020 2020 2023 2069 6e73 7065 6374 2e73 # inspect.s\n-000444c0: 6967 6e61 7475 7265 2829 2e20 556e 7772 ignature(). Unwr\n-000444d0: 6170 2069 742e 0a20 2020 2020 2020 2020 ap it.. \n-000444e0: 2020 2073 7475 6220 3d20 7374 7562 2e5f stub = stub._\n-000444f0: 5f66 756e 635f 5f0a 2020 2020 2020 2020 _func__. \n-00044500: 6173 7365 7274 2069 7369 6e73 7461 6e63 assert isinstanc\n-00044510: 6528 7374 7562 2c20 7479 7065 732e 4675 e(stub, types.Fu\n-00044520: 6e63 7469 6f6e 5479 7065 290a 2020 2020 nctionType). \n-00044530: 2020 2020 6e61 6d65 203d 2073 7475 622e name = stub.\n-00044540: 5f5f 6e61 6d65 5f5f 0a20 2020 2020 2020 __name__. \n-00044550: 2073 6967 6e61 7475 7265 203d 2069 6e73 signature = ins\n-00044560: 7065 6374 2e73 6967 6e61 7475 7265 2873 pect.signature(s\n-00044570: 7475 6229 0a20 2020 2020 2020 2073 7475 tub). stu\n-00044580: 625f 676c 6f62 616c 7320 3d20 7379 732e b_globals = sys.\n-00044590: 6d6f 6475 6c65 732e 6765 7428 636c 732e modules.get(cls.\n-000445a0: 5f5f 6d6f 6475 6c65 5f5f 292e 5f5f 6469 __module__).__di\n-000445b0: 6374 5f5f 0a0a 2020 2020 2020 2020 6675 ct__.. fu\n-000445c0: 6e63 203d 2063 646c 6c5b 6627 7b63 6c73 nc = cdll[f'{cls\n-000445d0: 2e5f 5f6e 616d 655f 5f7d 5f7b 6e61 6d65 .__name__}_{name\n-000445e0: 2e6c 7374 7269 7028 225f 2229 7d27 5d0a .lstrip(\"_\")}'].\n-000445f0: 2020 2020 2020 2020 6675 6e63 2e61 7267 func.arg\n-00044600: 7479 7065 7320 3d20 7475 706c 6528 0a20 types = tuple(. \n-00044610: 2020 2020 2020 2020 2020 206d 6170 5f74 map_t\n-00044620: 7970 6528 7061 7261 6d65 7465 722e 616e ype(parameter.an\n-00044630: 6e6f 7461 7469 6f6e 2c20 7374 7562 5f67 notation, stub_g\n-00044640: 6c6f 6261 6c73 290a 2020 2020 2020 2020 lobals). \n-00044650: 2020 2020 666f 7220 7061 7261 6d65 7465 for paramete\n-00044660: 7220 696e 2073 6967 6e61 7475 7265 2e70 r in signature.p\n-00044670: 6172 616d 6574 6572 732e 7661 6c75 6573 arameters.values\n-00044680: 2829 0a20 2020 2020 2020 2029 0a20 2020 (). ). \n-00044690: 2020 2020 2066 756e 632e 7265 7374 7970 func.restyp\n-000446a0: 6520 3d20 6d61 705f 7479 7065 2873 6967 e = map_type(sig\n-000446b0: 6e61 7475 7265 2e72 6574 7572 6e5f 616e nature.return_an\n-000446c0: 6e6f 7461 7469 6f6e 2c20 7374 7562 5f67 notation, stub_g\n-000446d0: 6c6f 6261 6c73 290a 2020 2020 2020 2020 lobals). \n-000446e0: 6572 7263 6865 636b 203d 2067 6574 6174 errcheck = getat\n-000446f0: 7472 2866 756e 632e 7265 7374 7970 652c tr(func.restype,\n-00044700: 2027 6572 7263 6865 636b 272c 204e 6f6e 'errcheck', Non\n-00044710: 6529 0a20 2020 2020 2020 2069 6620 6572 e). if er\n-00044720: 7263 6865 636b 2069 7320 6e6f 7420 4e6f rcheck is not No\n-00044730: 6e65 3a0a 2020 2020 2020 2020 2020 2020 ne:. \n-00044740: 6675 6e63 2e65 7272 6368 6563 6b20 3d20 func.errcheck = \n-00044750: 6572 7263 6865 636b 0a0a 2020 2020 2020 errcheck.. \n-00044760: 2020 6c6f 6767 6572 2e64 6562 7567 2827 logger.debug('\n-00044770: 2020 6372 6561 7465 2077 7261 7070 6572 create wrapper\n-00044780: 2025 732e 2573 2573 272c 2063 6c73 2e5f %s.%s%s', cls._\n-00044790: 5f6e 616d 655f 5f2c 206e 616d 652c 2073 _name__, name, s\n-000447a0: 6967 6e61 7475 7265 290a 2020 2020 2020 ignature). \n-000447b0: 2020 6c6f 6767 6572 2e64 6562 7567 2827 logger.debug('\n-000447c0: 2020 2020 6172 6773 2025 7320 7265 7320 args %s res \n-000447d0: 2573 272c 2066 756e 632e 6172 6774 7970 %s', func.argtyp\n-000447e0: 6573 2c20 6675 6e63 2e72 6573 7479 7065 es, func.restype\n-000447f0: 290a 0a20 2020 2020 2020 2023 2063 7479 ).. # cty\n-00044800: 7065 7320 6675 6e63 7469 6f6e 2070 6f69 pes function poi\n-00044810: 6e74 6572 206f 626a 6563 7473 2064 6f6e nter objects don\n-00044820: 2774 2069 6d70 6c65 6d65 6e74 2074 6865 't implement the\n-00044830: 2075 7375 616c 2066 756e 6374 696f 6e0a usual function.\n-00044840: 2020 2020 2020 2020 2320 6465 7363 7269 # descri\n-00044850: 7074 6f72 206c 6f67 6963 2c20 7768 6963 ptor logic, whic\n-00044860: 6820 6d65 616e 7320 7468 6579 2077 6f6e h means they won\n-00044870: 2774 2062 696e 6420 6173 206d 6574 686f 't bind as metho\n-00044880: 6473 2e20 2046 6f72 2073 7461 7469 630a ds. For static.\n-00044890: 2020 2020 2020 2020 2320 6d65 7468 6f64 # method\n-000448a0: 732c 2074 6861 7427 7320 676f 6f64 2c20 s, that's good, \n-000448b0: 6275 7420 666f 7220 696e 7374 616e 6365 but for instance\n-000448c0: 206d 6574 686f 6473 2c20 7765 2061 6464 methods, we add\n-000448d0: 2061 2077 7261 7070 6572 2061 730a 2020 a wrapper as. \n-000448e0: 2020 2020 2020 2320 7468 6520 6561 7369 # the easi\n-000448f0: 6573 7420 616e 6420 6d6f 7374 2070 6572 est and most per\n-00044900: 666f 726d 616e 7420 7761 7920 746f 2067 formant way to g\n-00044910: 6574 2074 6865 2062 696e 6469 6e67 2062 et the binding b\n-00044920: 6568 6176 696f 7572 2e0a 2020 2020 2020 ehaviour.. \n-00044930: 2020 6966 2073 7475 625f 7479 7065 2069 if stub_type i\n-00044940: 7320 6e6f 7420 7374 6174 6963 6d65 7468 s not staticmeth\n-00044950: 6f64 3a0a 2020 2020 2020 2020 2020 2020 od:. \n-00044960: 7365 7461 7474 7228 636c 732c 206e 616d setattr(cls, nam\n-00044970: 652c 206c 616d 6264 6120 2a61 7267 733a e, lambda *args:\n-00044980: 2066 756e 6328 2a61 7267 7329 290a 2020 func(*args)). \n-00044990: 2020 2020 2020 656c 7365 3a0a 2020 2020 else:. \n-000449a0: 2020 2020 2020 2020 7365 7461 7474 7228 setattr(\n-000449b0: 636c 732c 206e 616d 652c 2066 756e 6329 cls, name, func)\n-000449c0: 0a0a 2020 2020 6465 6620 5f75 6e72 6566 .. def _unref\n-000449d0: 2873 656c 663a 2027 5265 6665 7265 6e63 (self: 'Referenc\n-000449e0: 6554 7970 6527 2920 2d3e 204e 6f6e 653a eType') -> None:\n-000449f0: 0a20 2020 2020 2020 202e 2e2e 0a0a 2020 . ..... \n-00044a00: 2020 6465 6620 5f72 6566 2873 656c 663a def _ref(self:\n-00044a10: 2027 5265 6665 7265 6e63 6554 7970 6527 'ReferenceType'\n-00044a20: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n-00044a30: 2020 202e 2e2e 0a0a 2020 2020 5420 3d20 ..... T = \n-00044a40: 5479 7065 5661 7228 2254 222c 2062 6f75 TypeVar(\"T\", bou\n-00044a50: 6e64 3d27 5265 6665 7265 6e63 6554 7970 nd='ReferenceTyp\n-00044a60: 6527 290a 0a20 2020 2040 636c 6173 736d e').. @classm\n-00044a70: 6574 686f 640a 2020 2020 6465 6620 7265 ethod. def re\n-00044a80: 6628 636c 733a 2054 7970 655b 545d 2c20 f(cls: Type[T], \n-00044a90: 6f72 6967 696e 3a20 5765 616b 5265 6665 origin: WeakRefe\n-00044aa0: 7265 6e63 6529 202d 3e20 543a 0a20 2020 rence) -> T:. \n-00044ab0: 2020 2020 2073 656c 6620 3d20 636c 7328 self = cls(\n-00044ac0: 6f72 6967 696e 290a 2020 2020 2020 2020 origin). \n-00044ad0: 7365 6c66 2e5f 7265 6628 290a 2020 2020 self._ref(). \n-00044ae0: 2020 2020 7265 7475 726e 2073 656c 660a return self.\n-00044af0: 0a20 2020 2064 6566 205f 5f64 656c 5f5f . def __del__\n-00044b00: 2873 656c 6629 202d 3e20 4e6f 6e65 3a0a (self) -> None:.\n-00044b10: 2020 2020 2020 2020 6966 2073 656c 662e if self.\n-00044b20: 7661 6c75 6520 6973 206e 6f74 204e 6f6e value is not Non\n-00044b30: 653a 0a20 2020 2020 2020 2020 2020 2073 e:. s\n-00044b40: 656c 662e 5f75 6e72 6566 2829 0a27 2727 elf._unref().'''\n-00044b50: 2c0a 2020 2763 6f63 6b70 6974 2f5f 7665 ,. 'cockpit/_ve\n-00044b60: 6e64 6f72 2f73 7973 7465 6d64 5f63 7479 ndor/systemd_cty\n-00044b70: 7065 732f 5f5f 696e 6974 5f5f 2e70 7927 pes/__init__.py'\n-00044b80: 3a20 6272 2727 2723 2073 7973 7465 6d64 : br'''# systemd\n-00044b90: 5f63 7479 7065 730a 230a 2320 436f 7079 _ctypes.#.# Copy\n-00044ba0: 7269 6768 7420 2843 2920 3230 3232 2041 right (C) 2022 A\n-00044bb0: 6c6c 6973 6f6e 204b 6172 6c69 7473 6b61 llison Karlitska\n-00044bc0: 7961 203c 616c 6c69 736f 6e2e 6b61 726c ya <allison.karl\n-00044bd0: 6974 736b 6179 6140 7265 6468 6174 2e63 itskaya@redhat.c\n-00044be0: 6f6d 3e0a 230a 2320 5468 6973 2070 726f om>.#.# This pro\n-00044bf0: 6772 616d 2069 7320 6672 6565 2073 6f66 gram is free sof\n-00044c00: 7477 6172 653a 2079 6f75 2063 616e 2072 tware: you can r\n-00044c10: 6564 6973 7472 6962 7574 6520 6974 2061 edistribute it a\n-00044c20: 6e64 2f6f 7220 6d6f 6469 6679 0a23 2069 nd/or modify.# i\n-00044c30: 7420 756e 6465 7220 7468 6520 7465 726d t under the term\n-00044c40: 7320 6f66 2074 6865 2047 4e55 2047 656e s of the GNU Gen\n-00044c50: 6572 616c 2050 7562 6c69 6320 4c69 6365 eral Public Lice\n-00044c60: 6e73 6520 6173 2070 7562 6c69 7368 6564 nse as published\n-00044c70: 2062 790a 2320 7468 6520 4672 6565 2053 by.# the Free S\n-00044c80: 6f66 7477 6172 6520 466f 756e 6461 7469 oftware Foundati\n-00044c90: 6f6e 2c20 6569 7468 6572 2076 6572 7369 on, either versi\n-00044ca0: 6f6e 2033 206f 6620 7468 6520 4c69 6365 on 3 of the Lice\n-00044cb0: 6e73 652c 206f 720a 2320 2861 7420 796f nse, or.# (at yo\n-00044cc0: 7572 206f 7074 696f 6e29 2061 6e79 206c ur option) any l\n-00044cd0: 6174 6572 2076 6572 7369 6f6e 2e0a 230a ater version..#.\n-00044ce0: 2320 5468 6973 2070 726f 6772 616d 2069 # This program i\n-00044cf0: 7320 6469 7374 7269 6275 7465 6420 696e s distributed in\n-00044d00: 2074 6865 2068 6f70 6520 7468 6174 2069 the hope that i\n-00044d10: 7420 7769 6c6c 2062 6520 7573 6566 756c t will be useful\n-00044d20: 2c0a 2320 6275 7420 5749 5448 4f55 5420 ,.# but WITHOUT \n-00044d30: 414e 5920 5741 5252 414e 5459 3b20 7769 ANY WARRANTY; wi\n-00044d40: 7468 6f75 7420 6576 656e 2074 6865 2069 thout even the i\n-00044d50: 6d70 6c69 6564 2077 6172 7261 6e74 7920 mplied warranty \n-00044d60: 6f66 0a23 204d 4552 4348 414e 5441 4249 of.# MERCHANTABI\n-00044d70: 4c49 5459 206f 7220 4649 544e 4553 5320 LITY or FITNESS \n-00044d80: 464f 5220 4120 5041 5254 4943 554c 4152 FOR A PARTICULAR\n-00044d90: 2050 5552 504f 5345 2e20 2053 6565 2074 PURPOSE. See t\n-00044da0: 6865 0a23 2047 4e55 2047 656e 6572 616c he.# GNU General\n-00044db0: 2050 7562 6c69 6320 4c69 6365 6e73 6520 Public License \n-00044dc0: 666f 7220 6d6f 7265 2064 6574 6169 6c73 for more details\n-00044dd0: 2e0a 230a 2320 596f 7520 7368 6f75 6c64 ..#.# You should\n-00044de0: 2068 6176 6520 7265 6365 6976 6564 2061 have received a\n-00044df0: 2063 6f70 7920 6f66 2074 6865 2047 4e55 copy of the GNU\n-00044e00: 2047 656e 6572 616c 2050 7562 6c69 6320 General Public \n-00044e10: 4c69 6365 6e73 650a 2320 616c 6f6e 6720 License.# along \n-00044e20: 7769 7468 2074 6869 7320 7072 6f67 7261 with this progra\n-00044e30: 6d2e 2020 4966 206e 6f74 2c20 7365 6520 m. If not, see \n-00044e40: 3c68 7474 703a 2f2f 7777 772e 676e 752e <http://www.gnu.\n-00044e50: 6f72 672f 6c69 6365 6e73 6573 2f3e 2e0a org/licenses/>..\n-00044e60: 0a22 2222 7379 7374 656d 645f 6374 7970 .\"\"\"systemd_ctyp\n-00044e70: 6573 2222 220a 0a5f 5f76 6572 7369 6f6e es\"\"\"..__version\n-00044e80: 5f5f 203d 2022 3022 0a0a 6672 6f6d 202e __ = \"0\"..from .\n-00044e90: 6275 7320 696d 706f 7274 2042 7573 2c20 bus import Bus, \n-00044ea0: 4275 7345 7272 6f72 2c20 4275 734d 6573 BusError, BusMes\n-00044eb0: 7361 6765 0a66 726f 6d20 2e62 7573 7479 sage.from .busty\n-00044ec0: 7065 7320 696d 706f 7274 2042 7573 5479 pes import BusTy\n-00044ed0: 7065 2c20 4a53 4f4e 456e 636f 6465 722c pe, JSONEncoder,\n-00044ee0: 2056 6172 6961 6e74 0a66 726f 6d20 2e65 Variant.from .e\n-00044ef0: 7665 6e74 2069 6d70 6f72 7420 4576 656e vent import Even\n-00044f00: 742c 2045 7665 6e74 4c6f 6f70 506f 6c69 t, EventLoopPoli\n-00044f10: 6379 2c20 7275 6e5f 6173 796e 630a 6672 cy, run_async.fr\n-00044f20: 6f6d 202e 7061 7468 7761 7463 6820 696d om .pathwatch im\n-00044f30: 706f 7274 2048 616e 646c 652c 2050 6174 port Handle, Pat\n-00044f40: 6857 6174 6368 0a0a 5f5f 616c 6c5f 5f20 hWatch..__all__ \n-00044f50: 3d20 5b0a 2020 2020 2242 7573 222c 0a20 = [. \"Bus\",. \n-00044f60: 2020 2022 4275 7345 7272 6f72 222c 0a20 \"BusError\",. \n-00044f70: 2020 2022 4275 734d 6573 7361 6765 222c \"BusMessage\",\n-00044f80: 0a20 2020 2022 4275 7354 7970 6522 2c0a . \"BusType\",.\n-00044f90: 2020 2020 2245 7665 6e74 222c 0a20 2020 \"Event\",. \n-00044fa0: 2022 4576 656e 744c 6f6f 7050 6f6c 6963 \"EventLoopPolic\n-00044fb0: 7922 2c0a 2020 2020 2248 616e 646c 6522 y\",. \"Handle\"\n-00044fc0: 2c0a 2020 2020 224a 534f 4e45 6e63 6f64 ,. \"JSONEncod\n-00044fd0: 6572 222c 0a20 2020 2022 5061 7468 5761 er\",. \"PathWa\n-00044fe0: 7463 6822 2c0a 2020 2020 2256 6172 6961 tch\",. \"Varia\n-00044ff0: 6e74 222c 0a20 2020 2022 7275 6e5f 6173 nt\",. \"run_as\n-00045000: 796e 6322 2c0a 5d0a 2727 272c 0a20 2027 ync\",.].''',. '\n-00045010: 636f 636b 7069 742f 5f76 656e 646f 722f cockpit/_vendor/\n-00045020: 7379 7374 656d 645f 6374 7970 6573 2f70 systemd_ctypes/p\n-00045030: 792e 7479 7065 6427 3a20 6272 2727 2727 y.typed': br''''\n-00045040: 2727 2c0a 2020 2763 6f63 6b70 6974 2f5f '',. 'cockpit/_\n-00045050: 7665 6e64 6f72 2f73 7973 7465 6d64 5f63 vendor/systemd_c\n-00045060: 7479 7065 732f 6c69 6273 7973 7465 6d64 types/libsystemd\n-00045070: 2e70 7927 3a20 7227 2727 2320 7379 7374 .py': r'''# syst\n-00045080: 656d 645f 6374 7970 6573 0a23 0a23 2043 emd_ctypes.#.# C\n-00045090: 6f70 7972 6967 6874 2028 4329 2032 3032 opyright (C) 202\n-000450a0: 3220 416c 6c69 736f 6e20 4b61 726c 6974 2 Allison Karlit\n-000450b0: 736b 6179 6120 3c61 6c6c 6973 6f6e 2e6b skaya <allison.k\n-000450c0: 6172 6c69 7473 6b61 7961 4072 6564 6861 arlitskaya@redha\n-000450d0: 742e 636f 6d3e 0a23 0a23 2054 6869 7320 t.com>.#.# This \n-000450e0: 7072 6f67 7261 6d20 6973 2066 7265 6520 program is free \n-000450f0: 736f 6674 7761 7265 3a20 796f 7520 6361 software: you ca\n-00045100: 6e20 7265 6469 7374 7269 6275 7465 2069 n redistribute i\n-00045110: 7420 616e 642f 6f72 206d 6f64 6966 790a t and/or modify.\n-00045120: 2320 6974 2075 6e64 6572 2074 6865 2074 # it under the t\n-00045130: 6572 6d73 206f 6620 7468 6520 474e 5520 erms of the GNU \n-00045140: 4765 6e65 7261 6c20 5075 626c 6963 204c General Public L\n-00045150: 6963 656e 7365 2061 7320 7075 626c 6973 icense as publis\n-00045160: 6865 6420 6279 0a23 2074 6865 2046 7265 hed by.# the Fre\n-00045170: 6520 536f 6674 7761 7265 2046 6f75 6e64 e Software Found\n-00045180: 6174 696f 6e2c 2065 6974 6865 7220 7665 ation, either ve\n-00045190: 7273 696f 6e20 3320 6f66 2074 6865 204c rsion 3 of the L\n-000451a0: 6963 656e 7365 2c20 6f72 0a23 2028 6174 icense, or.# (at\n-000451b0: 2079 6f75 7220 6f70 7469 6f6e 2920 616e your option) an\n-000451c0: 7920 6c61 7465 7220 7665 7273 696f 6e2e y later version.\n-000451d0: 0a23 0a23 2054 6869 7320 7072 6f67 7261 .#.# This progra\n-000451e0: 6d20 6973 2064 6973 7472 6962 7574 6564 m is distributed\n-000451f0: 2069 6e20 7468 6520 686f 7065 2074 6861 in the hope tha\n-00045200: 7420 6974 2077 696c 6c20 6265 2075 7365 t it will be use\n-00045210: 6675 6c2c 0a23 2062 7574 2057 4954 484f ful,.# but WITHO\n-00045220: 5554 2041 4e59 2057 4152 5241 4e54 593b UT ANY WARRANTY;\n-00045230: 2077 6974 686f 7574 2065 7665 6e20 7468 without even th\n-00045240: 6520 696d 706c 6965 6420 7761 7272 616e e implied warran\n-00045250: 7479 206f 660a 2320 4d45 5243 4841 4e54 ty of.# MERCHANT\n-00045260: 4142 494c 4954 5920 6f72 2046 4954 4e45 ABILITY or FITNE\n-00045270: 5353 2046 4f52 2041 2050 4152 5449 4355 SS FOR A PARTICU\n-00045280: 4c41 5220 5055 5250 4f53 452e 2020 5365 LAR PURPOSE. Se\n-00045290: 6520 7468 650a 2320 474e 5520 4765 6e65 e the.# GNU Gene\n-000452a0: 7261 6c20 5075 626c 6963 204c 6963 656e ral Public Licen\n-000452b0: 7365 2066 6f72 206d 6f72 6520 6465 7461 se for more deta\n-000452c0: 696c 732e 0a23 0a23 2059 6f75 2073 686f ils..#.# You sho\n-000452d0: 756c 6420 6861 7665 2072 6563 6569 7665 uld have receive\n-000452e0: 6420 6120 636f 7079 206f 6620 7468 6520 d a copy of the \n-000452f0: 474e 5520 4765 6e65 7261 6c20 5075 626c GNU General Publ\n-00045300: 6963 204c 6963 656e 7365 0a23 2061 6c6f ic License.# alo\n-00045310: 6e67 2077 6974 6820 7468 6973 2070 726f ng with this pro\n-00045320: 6772 616d 2e20 2049 6620 6e6f 742c 2073 gram. If not, s\n-00045330: 6565 203c 6874 7470 3a2f 2f77 7777 2e67 ee <http://www.g\n-00045340: 6e75 2e6f 7267 2f6c 6963 656e 7365 732f nu.org/licenses/\n-00045350: 3e2e 0a0a 696d 706f 7274 2063 7479 7065 >...import ctype\n-00045360: 730a 696d 706f 7274 206f 730a 696d 706f s.import os.impo\n-00045370: 7274 2073 7973 0a66 726f 6d20 7479 7069 rt sys.from typi\n-00045380: 6e67 2069 6d70 6f72 7420 436c 6173 7356 ng import ClassV\n-00045390: 6172 2c20 4c69 7374 2c20 4f70 7469 6f6e ar, List, Option\n-000453a0: 616c 2c20 5475 706c 652c 2055 6e69 6f6e al, Tuple, Union\n-000453b0: 0a0a 6672 6f6d 202e 696e 6f74 6966 7920 ..from .inotify \n-000453c0: 696d 706f 7274 2069 6e6f 7469 6679 5f65 import inotify_e\n-000453d0: 7665 6e74 0a66 726f 6d20 2e6c 6962 7261 vent.from .libra\n-000453e0: 7279 7772 6170 7065 7220 696d 706f 7274 rywrapper import\n-000453f0: 2028 0a20 2020 2043 616c 6c62 6163 6b2c (. Callback,\n-00045400: 0a20 2020 2045 7272 6e6f 2c0a 2020 2020 . Errno,. \n-00045410: 5265 6665 7265 6e63 652c 0a20 2020 2052 Reference,. R\n-00045420: 6566 6572 656e 6365 5479 7065 2c0a 2020 eferenceType,. \n-00045430: 2020 5573 6572 4461 7461 2c0a 2020 2020 UserData,. \n-00045440: 5765 616b 5265 6665 7265 6e63 652c 0a20 WeakReference,. \n-00045450: 2020 2062 7972 6566 2c0a 290a 6672 6f6d byref,.).from\n-00045460: 202e 7479 7069 6e67 2069 6d70 6f72 7420 .typing import \n-00045470: 416e 6e6f 7461 7465 640a 0a0a 636c 6173 Annotated...clas\n-00045480: 7320 5472 616d 706f 6c69 6e65 2852 6566 s Trampoline(Ref\n-00045490: 6572 656e 6365 5479 7065 293a 0a20 2020 erenceType):. \n-000454a0: 2064 6566 6572 7265 643a 2027 436c 6173 deferred: 'Clas\n-000454b0: 7356 6172 5b6c 6973 745b 4361 6c6c 6261 sVar[list[Callba\n-000454c0: 636b 5d20 7c20 4e6f 6e65 5d27 203d 204e ck] | None]' = N\n-000454d0: 6f6e 650a 2020 2020 7472 616d 706f 6c69 one. trampoli\n-000454e0: 6e65 3a20 4361 6c6c 6261 636b 0a20 2020 ne: Callback. \n-000454f0: 2075 7365 7264 6174 613a 2055 7365 7244 userdata: UserD\n-00045500: 6174 6120 3d20 4e6f 6e65 0a0a 2020 2020 ata = None.. \n-00045510: 6465 6620 6361 6e63 656c 2873 656c 6629 def cancel(self)\n-00045520: 202d 3e20 4e6f 6e65 3a0a 2020 2020 2020 -> None:. \n-00045530: 2020 7365 6c66 2e5f 756e 7265 6628 290a self._unref().\n-00045540: 2020 2020 2020 2020 7365 6c66 2e76 616c self.val\n-00045550: 7565 203d 204e 6f6e 650a 0a20 2020 2064 ue = None.. d\n-00045560: 6566 205f 5f64 656c 5f5f 2873 656c 6629 ef __del__(self)\n-00045570: 202d 3e20 4e6f 6e65 3a0a 2020 2020 2020 -> None:. \n-00045580: 2020 2320 5468 6973 206d 6967 6874 2062 # This might b\n-00045590: 6520 7468 6520 6375 7272 656e 746c 792d e the currently-\n-000455a0: 6469 7370 6174 6368 696e 6720 6361 6c6c dispatching call\n-000455b0: 6261 636b 20e2 8094 206d 616b 6520 7375 back ... make su\n-000455c0: 7265 2077 6520 646f 6e27 740a 2020 2020 re we don't. \n-000455d0: 2020 2020 2320 6465 7374 726f 7920 7468 # destroy th\n-000455e0: 6520 7472 616d 706f 6c69 6e65 2062 6566 e trampoline bef\n-000455f0: 6f72 6520 7765 2072 6574 7572 6e2e 2020 ore we return. \n-00045600: 5765 2064 726f 7020 7468 6520 6465 6665 We drop the defe\n-00045610: 7272 6564 206c 6973 740a 2020 2020 2020 rred list. \n-00045620: 2020 2320 6672 6f6d 2074 6865 2065 7665 # from the eve\n-00045630: 6e74 206c 6f6f 7020 7768 656e 2077 6527 nt loop when we'\n-00045640: 7265 2073 7572 6520 7765 2772 6520 6e6f re sure we're no\n-00045650: 7420 646f 696e 6720 616e 7920 6469 7370 t doing any disp\n-00045660: 6174 6368 6573 2e0a 2020 2020 2020 2020 atches.. \n-00045670: 6966 2054 7261 6d70 6f6c 696e 652e 6465 if Trampoline.de\n-00045680: 6665 7272 6564 2069 7320 6e6f 7420 4e6f ferred is not No\n-00045690: 6e65 3a0a 2020 2020 2020 2020 2020 2020 ne:. \n-000456a0: 5472 616d 706f 6c69 6e65 2e64 6566 6572 Trampoline.defer\n-000456b0: 7265 642e 6170 7065 6e64 2873 656c 662e red.append(self.\n-000456c0: 7472 616d 706f 6c69 6e65 290a 2020 2020 trampoline). \n-000456d0: 2020 2020 6966 2073 656c 662e 7661 6c75 if self.valu\n-000456e0: 6520 6973 206e 6f74 204e 6f6e 653a 0a20 e is not None:. \n-000456f0: 2020 2020 2020 2020 2020 2073 656c 662e self.\n-00045700: 5f75 6e72 6566 2829 0a0a 0a63 6c61 7373 _unref()...class\n-00045710: 2073 645f 6275 735f 6572 726f 7228 6374 sd_bus_error(ct\n-00045720: 7970 6573 2e53 7472 7563 7475 7265 293a ypes.Structure):\n-00045730: 0a20 2020 2023 2054 6869 7320 6973 2041 . # This is A\n-00045740: 4249 2c20 736f 2077 6520 6172 6520 7361 BI, so we are sa\n-00045750: 6665 2074 6f20 6173 7375 6d65 2069 7420 fe to assume it \n-00045760: 646f 6573 6e27 7420 6368 616e 6765 2e0a doesn't change..\n-00045770: 2020 2020 2320 556e 666f 7274 756e 6174 # Unfortunat\n-00045780: 656c 792c 2077 6520 6c61 636b 2061 6e79 ely, we lack any\n-00045790: 7468 696e 6720 6c69 6b65 2073 645f 6275 thing like sd_bu\n-000457a0: 735f 6572 726f 725f 6e65 7728 292e 0a20 s_error_new().. \n-000457b0: 2020 205f 6669 656c 6473 5f20 3d20 280a _fields_ = (.\n-000457c0: 2020 2020 2020 2020 2822 6e61 6d65 222c (\"name\",\n-000457d0: 2063 7479 7065 732e 635f 6368 6172 5f70 ctypes.c_char_p\n-000457e0: 292c 0a20 2020 2020 2020 2028 226d 6573 ),. (\"mes\n-000457f0: 7361 6765 222c 2063 7479 7065 732e 635f sage\", ctypes.c_\n-00045800: 6368 6172 5f70 292c 0a20 2020 2020 2020 char_p),. \n-00045810: 2028 225f 6e65 6564 5f66 7265 6522 2c20 (\"_need_free\", \n-00045820: 6374 7970 6573 2e63 5f69 6e74 292c 0a20 ctypes.c_int),. \n-00045830: 2020 2029 0a0a 2020 2020 6465 6620 6765 ).. def ge\n-00045840: 7428 7365 6c66 2920 2d3e 2054 7570 6c65 t(self) -> Tuple\n-00045850: 5b73 7472 2c20 7374 725d 3a0a 2020 2020 [str, str]:. \n-00045860: 2020 2020 7265 7475 726e 2073 656c 662e return self.\n-00045870: 6e61 6d65 2e64 6563 6f64 6528 292c 2073 name.decode(), s\n-00045880: 656c 662e 6d65 7373 6167 652e 6465 636f elf.message.deco\n-00045890: 6465 2829 0a0a 2020 2020 6465 6620 7365 de().. def se\n-000458a0: 7428 7365 6c66 2c20 6e61 6d65 3a20 7374 t(self, name: st\n-000458b0: 722c 206d 6573 7361 6765 3a20 7374 7229 r, message: str)\n-000458c0: 202d 3e20 4e6f 6e65 3a0a 2020 2020 2020 -> None:. \n-000458d0: 2020 7265 7375 6c74 203d 206c 6962 7379 result = libsy\n-000458e0: 7374 656d 642e 7364 5f62 7573 5f65 7272 stemd.sd_bus_err\n-000458f0: 6f72 5f73 6574 2862 7972 6566 2873 656c or_set(byref(sel\n-00045900: 6629 2c20 6e61 6d65 2c20 6d65 7373 6167 f), name, messag\n-00045910: 6529 0a20 2020 2020 2020 2069 6620 7265 e). if re\n-00045920: 7375 6c74 203c 2030 3a0a 2020 2020 2020 sult < 0:. \n-00045930: 2020 2020 2020 7261 6973 6520 4f53 4572 raise OSEr\n-00045940: 726f 7228 2d72 6573 756c 742c 2066 2273 ror(-result, f\"s\n-00045950: 645f 6275 735f 6572 726f 725f 7365 743a d_bus_error_set:\n-00045960: 207b 6f73 2e73 7472 6572 726f 7228 2d72 {os.strerror(-r\n-00045970: 6573 756c 7429 7d22 290a 0a20 2020 2064 esult)}\").. d\n-00045980: 6566 205f 5f64 656c 5f5f 2873 656c 6629 ef __del__(self)\n-00045990: 202d 3e20 4e6f 6e65 3a0a 2020 2020 2020 -> None:. \n-000459a0: 2020 6966 2073 656c 662e 5f62 5f6e 6565 if self._b_nee\n-000459b0: 6473 6672 6565 5f3a 0a20 2020 2020 2020 dsfree_:. \n-000459c0: 2020 2020 206c 6962 7379 7374 656d 642e libsystemd.\n-000459d0: 7364 5f62 7573 5f65 7272 6f72 5f66 7265 sd_bus_error_fre\n-000459e0: 6528 6279 7265 6628 7365 6c66 2929 0a0a e(byref(self))..\n-000459f0: 0a63 6c61 7373 2073 645f 6964 3132 3828 .class sd_id128(\n-00045a00: 6374 7970 6573 2e53 7472 7563 7475 7265 ctypes.Structure\n-00045a10: 293a 0a20 2020 2023 2048 4143 4b3a 2050 ):. # HACK: P\n-00045a20: 6173 732d 6279 2d76 616c 7565 206f 6620 ass-by-value of \n-00045a30: 6172 7261 792d 636f 6e74 6169 6e69 6e67 array-containing\n-00045a40: 2d73 7472 7563 7473 2069 7320 6272 6f6b -structs is brok\n-00045a50: 656e 206f 6e20 5079 7468 6f6e 0a20 2020 en on Python. \n-00045a60: 2023 2033 2e36 2e20 5365 6520 6874 7470 # 3.6. See http\n-00045a70: 733a 2f2f 6275 6773 2e70 7974 686f 6e2e s://bugs.python.\n-00045a80: 6f72 672f 6973 7375 6532 3232 3733 0a20 org/issue22273. \n-00045a90: 2020 205f 6669 656c 6473 5f3a 204c 6973 _fields_: Lis\n-00045aa0: 745b 5475 706c 655b 7374 722c 2074 7970 t[Tuple[str, typ\n-00045ab0: 655d 5d20 3d20 280a 2020 2020 2020 2020 e]] = (. \n-00045ac0: 5b28 2262 7974 6573 222c 2063 7479 7065 [(\"bytes\", ctype\n-00045ad0: 732e 635f 7569 6e74 3820 2a20 3136 295d s.c_uint8 * 16)]\n-00045ae0: 0a20 2020 2020 2020 2069 6620 7379 732e . if sys.\n-00045af0: 7665 7273 696f 6e5f 696e 666f 203e 3d20 version_info >= \n-00045b00: 2833 2c20 372c 2030 290a 2020 2020 2020 (3, 7, 0). \n-00045b10: 2020 656c 7365 205b 2822 6f6e 6522 2c20 else [(\"one\", \n-00045b20: 6374 7970 6573 2e63 5f75 696e 7436 3429 ctypes.c_uint64)\n-00045b30: 2c20 2822 7477 6f22 2c20 6374 7970 6573 , (\"two\", ctypes\n-00045b40: 2e63 5f75 696e 7436 3429 5d0a 2020 2020 .c_uint64)]. \n-00045b50: 290a 0a0a 636c 6173 7320 7364 5f65 7665 )...class sd_eve\n-00045b60: 6e74 5f73 6f75 7263 6528 5472 616d 706f nt_source(Trampo\n-00045b70: 6c69 6e65 293a 0a20 2020 202e 2e2e 0a0a line):. .....\n-00045b80: 0a63 6c61 7373 2073 645f 6576 656e 7428 .class sd_event(\n-00045b90: 5265 6665 7265 6e63 6554 7970 6529 3a0a ReferenceType):.\n-00045ba0: 2020 2020 6465 6620 5f61 6464 5f69 6e6f def _add_ino\n-00045bb0: 7469 6679 280a 2020 2020 2020 2020 7365 tify(. se\n-00045bc0: 6c66 3a20 2773 645f 6576 656e 7427 2c0a lf: 'sd_event',.\n-00045bd0: 2020 2020 2020 2020 736f 7572 6365 3a20 source: \n-00045be0: 5265 6665 7265 6e63 655b 7364 5f65 7665 Reference[sd_eve\n-00045bf0: 6e74 5f73 6f75 7263 655d 2c0a 2020 2020 nt_source],. \n-00045c00: 2020 2020 7061 7468 3a20 7374 722c 0a20 path: str,. \n-00045c10: 2020 2020 2020 2065 7665 6e74 3a20 696e event: in\n-00045c20: 742c 0a20 2020 2020 2020 2063 616c 6c62 t,. callb\n-00045c30: 6163 6b3a 2043 616c 6c62 6163 6b2c 0a20 ack: Callback,. \n-00045c40: 2020 2020 2020 2075 7365 725f 6461 7461 user_data\n-00045c50: 3a20 5573 6572 4461 7461 2c0a 2020 2020 : UserData,. \n-00045c60: 2920 2d3e 2055 6e69 6f6e 5b4e 6f6e 652c ) -> Union[None,\n-00045c70: 2045 7272 6e6f 5d3a 0a20 2020 2020 2020 Errno]:. \n-00045c80: 202e 2e2e 0a0a 2020 2020 6465 6620 6469 ..... def di\n-00045c90: 7370 6174 6368 2873 656c 663a 2027 7364 spatch(self: 'sd\n-00045ca0: 5f65 7665 6e74 2729 202d 3e20 556e 696f _event') -> Unio\n-00045cb0: 6e5b 4e6f 6e65 2c20 4572 726e 6f5d 3a0a n[None, Errno]:.\n-00045cc0: 2020 2020 2020 2020 2e2e 2e0a 0a20 2020 ..... \n-00045cd0: 2064 6566 2067 6574 5f66 6428 7365 6c66 def get_fd(self\n-00045ce0: 3a20 2773 645f 6576 656e 7427 2920 2d3e : 'sd_event') ->\n-00045cf0: 2055 6e69 6f6e 5b69 6e74 2c20 4572 726e Union[int, Errn\n-00045d00: 6f5d 3a0a 2020 2020 2020 2020 7261 6973 o]:. rais\n-00045d10: 6520 4e6f 7449 6d70 6c65 6d65 6e74 6564 e NotImplemented\n-00045d20: 4572 726f 720a 0a20 2020 2064 6566 2067 Error.. def g\n-00045d30: 6574 5f73 7461 7465 2873 656c 663a 2027 et_state(self: '\n-00045d40: 7364 5f65 7665 6e74 2729 202d 3e20 556e sd_event') -> Un\n-00045d50: 696f 6e5b 696e 742c 2045 7272 6e6f 5d3a ion[int, Errno]:\n-00045d60: 0a20 2020 2020 2020 2072 6169 7365 204e . raise N\n-00045d70: 6f74 496d 706c 656d 656e 7465 6445 7272 otImplementedErr\n-00045d80: 6f72 0a0a 2020 2020 6465 6620 6c6f 6f70 or.. def loop\n-00045d90: 2873 656c 663a 2027 7364 5f65 7665 6e74 (self: 'sd_event\n-00045da0: 2729 202d 3e20 556e 696f 6e5b 4e6f 6e65 ') -> Union[None\n-00045db0: 2c20 4572 726e 6f5d 3a0a 2020 2020 2020 , Errno]:. \n-00045dc0: 2020 2e2e 2e0a 0a20 2020 2064 6566 2070 ..... def p\n-00045dd0: 7265 7061 7265 2873 656c 663a 2027 7364 repare(self: 'sd\n-00045de0: 5f65 7665 6e74 2729 202d 3e20 556e 696f _event') -> Unio\n-00045df0: 6e5b 4e6f 6e65 2c20 4572 726e 6f5d 3a0a n[None, Errno]:.\n-00045e00: 2020 2020 2020 2020 2e2e 2e0a 0a20 2020 ..... \n-00045e10: 2064 6566 2077 6169 7428 0a20 2020 2020 def wait(. \n-00045e20: 2020 2073 656c 663a 2027 7364 5f65 7665 self: 'sd_eve\n-00045e30: 6e74 272c 2074 696d 656f 7574 3a20 416e nt', timeout: An\n-00045e40: 6e6f 7461 7465 645b 696e 742c 2063 7479 notated[int, cty\n-00045e50: 7065 732e 635f 7569 6e74 3634 5d0a 2020 pes.c_uint64]. \n-00045e60: 2020 2920 2d3e 2055 6e69 6f6e 5b4e 6f6e ) -> Union[Non\n-00045e70: 652c 2045 7272 6e6f 5d3a 0a20 2020 2020 e, Errno]:. \n-00045e80: 2020 202e 2e2e 0a0a 2020 2020 4073 7461 ..... @sta\n-00045e90: 7469 636d 6574 686f 640a 2020 2020 6465 ticmethod. de\n-00045ea0: 6620 5f64 6566 6175 6c74 2872 6574 3a20 f _default(ret: \n-00045eb0: 5265 6665 7265 6e63 655b 2773 645f 6576 Reference['sd_ev\n-00045ec0: 656e 7427 5d29 202d 3e20 556e 696f 6e5b ent']) -> Union[\n-00045ed0: 4e6f 6e65 2c20 4572 726e 6f5d 3a0a 2020 None, Errno]:. \n-00045ee0: 2020 2020 2020 2e2e 2e0a 0a0a 636c 6173 ......clas\n-00045ef0: 7320 7364 5f62 7573 5f73 6c6f 7428 5472 s sd_bus_slot(Tr\n-00045f00: 616d 706f 6c69 6e65 293a 0a20 2020 202e ampoline):. .\n-00045f10: 2e2e 0a0a 0a63 6c61 7373 2073 645f 6275 .....class sd_bu\n-00045f20: 735f 6d65 7373 6167 6528 5265 6665 7265 s_message(Refere\n-00045f30: 6e63 6554 7970 6529 3a0a 2020 2020 6465 nceType):. de\n-00045f40: 6620 7265 7769 6e64 2873 656c 663a 2027 f rewind(self: '\n-00045f50: 7364 5f62 7573 5f6d 6573 7361 6765 272c sd_bus_message',\n-00045f60: 2063 6f6d 706c 6574 653a 2062 6f6f 6c29 complete: bool)\n-00045f70: 202d 3e20 556e 696f 6e5b 4e6f 6e65 2c20 -> Union[None, \n-00045f80: 4572 726e 6f5d 3a0a 2020 2020 2020 2020 Errno]:. \n-00045f90: 2e2e 2e0a 0a20 2020 2064 6566 205f 6765 ..... def _ge\n-00045fa0: 745f 6572 726f 7228 7365 6c66 3a20 2773 t_error(self: 's\n-00045fb0: 645f 6275 735f 6d65 7373 6167 6527 2920 d_bus_message') \n-00045fc0: 2d3e 2052 6566 6572 656e 6365 5b73 645f -> Reference[sd_\n-00045fd0: 6275 735f 6572 726f 725d 3a0a 2020 2020 bus_error]:. \n-00045fe0: 2020 2020 7261 6973 6520 4e6f 7449 6d70 raise NotImp\n-00045ff0: 6c65 6d65 6e74 6564 4572 726f 720a 0a20 lementedError.. \n-00046000: 2020 2064 6566 2068 6173 5f73 6967 6e61 def has_signa\n-00046010: 7475 7265 2873 656c 663a 2027 7364 5f62 ture(self: 'sd_b\n-00046020: 7573 5f6d 6573 7361 6765 272c 2073 6967 us_message', sig\n-00046030: 6e61 7475 7265 3a20 7374 7229 202d 3e20 nature: str) -> \n-00046040: 556e 696f 6e5b 626f 6f6c 2c20 4572 726e Union[bool, Errn\n-00046050: 6f5d 3a0a 2020 2020 2020 2020 7261 6973 o]:. rais\n-00046060: 6520 4e6f 7449 6d70 6c65 6d65 6e74 6564 e NotImplemented\n-00046070: 4572 726f 720a 0a20 2020 2064 6566 2069 Error.. def i\n-00046080: 735f 6d65 7468 6f64 5f65 7272 6f72 2873 s_method_error(s\n-00046090: 656c 663a 2027 7364 5f62 7573 5f6d 6573 elf: 'sd_bus_mes\n-000460a0: 7361 6765 272c 206e 616d 653a 2073 7472 sage', name: str\n-000460b0: 2920 2d3e 2055 6e69 6f6e 5b62 6f6f 6c2c ) -> Union[bool,\n-000460c0: 2045 7272 6e6f 5d3a 0a20 2020 2020 2020 Errno]:. \n-000460d0: 2072 6169 7365 204e 6f74 496d 706c 656d raise NotImplem\n-000460e0: 656e 7465 6445 7272 6f72 0a0a 2020 2020 entedError.. \n-000460f0: 6465 6620 5f6e 6577 5f6d 6574 686f 645f def _new_method_\n-00046100: 6572 726e 6f66 280a 2020 2020 2020 2020 errnof(. \n-00046110: 2020 2020 7365 6c66 3a20 2773 645f 6275 self: 'sd_bu\n-00046120: 735f 6d65 7373 6167 6527 2c0a 2020 2020 s_message',. \n-00046130: 2020 2020 2020 2020 6d65 7373 6167 653a message:\n-00046140: 2052 6566 6572 656e 6365 5b27 7364 5f62 Reference['sd_b\n-00046150: 7573 5f6d 6573 7361 6765 275d 2c0a 2020 us_message'],. \n-00046160: 2020 2020 2020 2020 2020 6572 726f 723a error:\n-00046170: 2069 6e74 2c0a 2020 2020 2020 2020 2020 int,. \n-00046180: 2020 666f 726d 6174 5f73 7472 3a20 7374 format_str: st\n-00046190: 722c 0a20 2020 2020 2020 2020 2020 2066 r,. f\n-000461a0: 6972 7374 5f61 7267 3a20 7374 720a 2020 irst_arg: str. \n-000461b0: 2020 2920 2d3e 2055 6e69 6f6e 5b4e 6f6e ) -> Union[Non\n-000461c0: 652c 2045 7272 6e6f 5d3a 0a20 2020 2020 e, Errno]:. \n-000461d0: 2020 202e 2e2e 0a0a 2020 2020 6465 6620 ..... def \n-000461e0: 5f6e 6577 5f6d 6574 686f 645f 6572 726f _new_method_erro\n-000461f0: 7266 280a 2020 2020 2020 2020 7365 6c66 rf(. self\n-00046200: 3a20 2773 645f 6275 735f 6d65 7373 6167 : 'sd_bus_messag\n-00046210: 6527 2c0a 2020 2020 2020 2020 6d3a 2052 e',. m: R\n-00046220: 6566 6572 656e 6365 5b27 7364 5f62 7573 eference['sd_bus\n-00046230: 5f6d 6573 7361 6765 275d 2c0a 2020 2020 _message'],. \n-00046240: 2020 2020 6e61 6d65 3a20 7374 722c 0a20 name: str,. \n-00046250: 2020 2020 2020 2066 6f72 6d61 745f 7374 format_st\n-00046260: 723a 2073 7472 2c0a 2020 2020 2020 2020 r: str,. \n-00046270: 6669 7273 745f 6172 673a 2073 7472 0a20 first_arg: str. \n-00046280: 2020 2029 202d 3e20 556e 696f 6e5b 4e6f ) -> Union[No\n-00046290: 6e65 2c20 4572 726e 6f5d 3a0a 2020 2020 ne, Errno]:. \n-000462a0: 2020 2020 2e2e 2e0a 0a20 2020 2064 6566 ..... def\n-000462b0: 205f 6e65 775f 6d65 7468 6f64 5f72 6574 _new_method_ret\n-000462c0: 7572 6e28 0a20 2020 2020 2020 2073 656c urn(. sel\n-000462d0: 663a 2027 7364 5f62 7573 5f6d 6573 7361 f: 'sd_bus_messa\n-000462e0: 6765 272c 206d 3a20 5265 6665 7265 6e63 ge', m: Referenc\n-000462f0: 655b 2773 645f 6275 735f 6d65 7373 6167 e['sd_bus_messag\n-00046300: 6527 5d0a 2020 2020 2920 2d3e 2055 6e69 e']. ) -> Uni\n-00046310: 6f6e 5b4e 6f6e 652c 2045 7272 6e6f 5d3a on[None, Errno]:\n-00046320: 0a20 2020 2020 2020 202e 2e2e 0a0a 2020 . ..... \n-00046330: 2020 6465 6620 7365 616c 280a 2020 2020 def seal(. \n-00046340: 2020 2020 7365 6c66 3a20 2773 645f 6275 self: 'sd_bu\n-00046350: 735f 6d65 7373 6167 6527 2c0a 2020 2020 s_message',. \n-00046360: 2020 2020 636f 6f6b 6965 3a20 416e 6e6f cookie: Anno\n-00046370: 7461 7465 645b 696e 742c 2063 7479 7065 tated[int, ctype\n-00046380: 732e 635f 7569 6e74 3634 5d2c 0a20 2020 s.c_uint64],. \n-00046390: 2020 2020 2074 696d 656f 7574 3a20 416e timeout: An\n-000463a0: 6e6f 7461 7465 645b 696e 742c 2063 7479 notated[int, cty\n-000463b0: 7065 732e 635f 7569 6e74 3634 5d2c 0a20 pes.c_uint64],. \n-000463c0: 2020 2029 202d 3e20 556e 696f 6e5b 4e6f ) -> Union[No\n-000463d0: 6e65 2c20 4572 726e 6f5d 3a0a 2020 2020 ne, Errno]:. \n-000463e0: 2020 2020 2e2e 2e0a 0a20 2020 2064 6566 ..... def\n-000463f0: 205f 6765 745f 6275 7328 7365 6c66 3a20 _get_bus(self: \n-00046400: 2773 645f 6275 735f 6d65 7373 6167 6527 'sd_bus_message'\n-00046410: 2920 2d3e 2057 6561 6b52 6566 6572 656e ) -> WeakReferen\n-00046420: 6365 3a0a 2020 2020 2020 2020 7261 6973 ce:. rais\n-00046430: 6520 4e6f 7449 6d70 6c65 6d65 6e74 6564 e NotImplemented\n-00046440: 4572 726f 720a 0a20 2020 2064 6566 2067 Error.. def g\n-00046450: 6574 5f64 6573 7469 6e61 7469 6f6e 2873 et_destination(s\n-00046460: 656c 663a 2027 7364 5f62 7573 5f6d 6573 elf: 'sd_bus_mes\n-00046470: 7361 6765 2729 202d 3e20 7374 723a 0a20 sage') -> str:. \n-00046480: 2020 2020 2020 2072 6169 7365 204e 6f74 raise Not\n-00046490: 496d 706c 656d 656e 7465 6445 7272 6f72 ImplementedError\n-000464a0: 0a0a 2020 2020 6465 6620 6765 745f 696e .. def get_in\n-000464b0: 7465 7266 6163 6528 7365 6c66 3a20 2773 terface(self: 's\n-000464c0: 645f 6275 735f 6d65 7373 6167 6527 2920 d_bus_message') \n-000464d0: 2d3e 2073 7472 3a0a 2020 2020 2020 2020 -> str:. \n-000464e0: 7261 6973 6520 4e6f 7449 6d70 6c65 6d65 raise NotImpleme\n-000464f0: 6e74 6564 4572 726f 720a 0a20 2020 2064 ntedError.. d\n-00046500: 6566 2067 6574 5f6d 656d 6265 7228 7365 ef get_member(se\n-00046510: 6c66 3a20 2773 645f 6275 735f 6d65 7373 lf: 'sd_bus_mess\n-00046520: 6167 6527 2920 2d3e 2073 7472 3a0a 2020 age') -> str:. \n-00046530: 2020 2020 2020 7261 6973 6520 4e6f 7449 raise NotI\n-00046540: 6d70 6c65 6d65 6e74 6564 4572 726f 720a mplementedError.\n-00046550: 0a20 2020 2064 6566 2067 6574 5f70 6174 . def get_pat\n-00046560: 6828 7365 6c66 3a20 2773 645f 6275 735f h(self: 'sd_bus_\n-00046570: 6d65 7373 6167 6527 2920 2d3e 2073 7472 message') -> str\n-00046580: 3a0a 2020 2020 2020 2020 7261 6973 6520 :. raise \n-00046590: 4e6f 7449 6d70 6c65 6d65 6e74 6564 4572 NotImplementedEr\n-000465a0: 726f 720a 0a20 2020 2064 6566 2067 6574 ror.. def get\n-000465b0: 5f73 656e 6465 7228 7365 6c66 3a20 2773 _sender(self: 's\n-000465c0: 645f 6275 735f 6d65 7373 6167 6527 2920 d_bus_message') \n-000465d0: 2d3e 204f 7074 696f 6e61 6c5b 7374 725d -> Optional[str]\n-000465e0: 3a0a 2020 2020 2020 2020 7261 6973 6520 :. raise \n-000465f0: 4e6f 7449 6d70 6c65 6d65 6e74 6564 4572 NotImplementedEr\n-00046600: 726f 720a 0a20 2020 2064 6566 2067 6574 ror.. def get\n-00046610: 5f73 6967 6e61 7475 7265 2873 656c 663a _signature(self:\n-00046620: 2027 7364 5f62 7573 5f6d 6573 7361 6765 'sd_bus_message\n-00046630: 272c 2063 6f6d 706c 6574 653a 2062 6f6f ', complete: boo\n-00046640: 6c29 202d 3e20 7374 723a 0a20 2020 2020 l) -> str:. \n-00046650: 2020 2072 6169 7365 204e 6f74 496d 706c raise NotImpl\n-00046660: 656d 656e 7465 6445 7272 6f72 0a0a 0a63 ementedError...c\n-00046670: 6c61 7373 2073 645f 6275 7328 5265 6665 lass sd_bus(Refe\n-00046680: 7265 6e63 6554 7970 6529 3a0a 2020 2020 renceType):. \n-00046690: 6465 6620 5f61 6464 5f6d 6174 6368 280a def _add_match(.\n-000466a0: 2020 2020 2020 2020 7365 6c66 3a20 2773 self: 's\n-000466b0: 645f 6275 7327 2c0a 2020 2020 2020 2020 d_bus',. \n-000466c0: 736c 6f74 3a20 5265 6665 7265 6e63 655b slot: Reference[\n-000466d0: 7364 5f62 7573 5f73 6c6f 745d 2c0a 2020 sd_bus_slot],. \n-000466e0: 2020 2020 2020 6d61 7463 683a 2073 7472 match: str\n-000466f0: 2c0a 2020 2020 2020 2020 6861 6e64 6c65 ,. handle\n-00046700: 723a 2043 616c 6c62 6163 6b2c 0a20 2020 r: Callback,. \n-00046710: 2020 2020 2075 7365 725f 6461 7461 3a20 user_data: \n-00046720: 5573 6572 4461 7461 2c0a 2020 2020 2920 UserData,. ) \n-00046730: 2d3e 2055 6e69 6f6e 5b4e 6f6e 652c 2045 -> Union[None, E\n-00046740: 7272 6e6f 5d3a 0a20 2020 2020 2020 202e rrno]:. .\n-00046750: 2e2e 0a0a 2020 2020 6465 6620 5f61 6464 .... def _add\n-00046760: 5f6d 6174 6368 5f61 7379 6e63 280a 2020 _match_async(. \n-00046770: 2020 2020 2020 7365 6c66 3a20 2773 645f self: 'sd_\n-00046780: 6275 7327 2c0a 2020 2020 2020 2020 736c bus',. sl\n-00046790: 6f74 3a20 5265 6665 7265 6e63 655b 7364 ot: Reference[sd\n-000467a0: 5f62 7573 5f73 6c6f 745d 2c0a 2020 2020 _bus_slot],. \n-000467b0: 2020 2020 6d61 7463 683a 2073 7472 2c0a match: str,.\n-000467c0: 2020 2020 2020 2020 6361 6c6c 6261 636b callback\n-000467d0: 3a20 4361 6c6c 6261 636b 2c0a 2020 2020 : Callback,. \n-000467e0: 2020 2020 696e 7374 616c 6c5f 6361 6c6c install_call\n-000467f0: 6261 636b 3a20 4361 6c6c 6261 636b 2c0a back: Callback,.\n-00046800: 2020 2020 2020 2020 7573 6572 5f64 6174 user_dat\n-00046810: 613a 2055 7365 7244 6174 612c 0a20 2020 a: UserData,. \n-00046820: 2029 202d 3e20 556e 696f 6e5b 4e6f 6e65 ) -> Union[None\n-00046830: 2c20 4572 726e 6f5d 3a0a 2020 2020 2020 , Errno]:. \n-00046840: 2020 2e2e 2e0a 0a20 2020 2064 6566 205f ..... def _\n-00046850: 6164 645f 6f62 6a65 6374 280a 2020 2020 add_object(. \n-00046860: 2020 2020 7365 6c66 3a20 2773 645f 6275 self: 'sd_bu\n-00046870: 7327 2c0a 2020 2020 2020 2020 736c 6f74 s',. slot\n-00046880: 3a20 5265 6665 7265 6e63 655b 7364 5f62 : Reference[sd_b\n-00046890: 7573 5f73 6c6f 745d 2c0a 2020 2020 2020 us_slot],. \n-000468a0: 2020 7061 7468 3a20 7374 722c 0a20 2020 path: str,. \n-000468b0: 2020 2020 2063 616c 6c62 6163 6b3a 2043 callback: C\n-000468c0: 616c 6c62 6163 6b2c 0a20 2020 2020 2020 allback,. \n-000468d0: 2075 7365 725f 6461 7461 3a20 5573 6572 user_data: User\n-000468e0: 4461 7461 2c0a 2020 2020 2920 2d3e 2055 Data,. ) -> U\n-000468f0: 6e69 6f6e 5b4e 6f6e 652c 2045 7272 6e6f nion[None, Errno\n-00046900: 5d3a 0a20 2020 2020 2020 202e 2e2e 0a0a ]:. .....\n-00046910: 2020 2020 6465 6620 6174 7461 6368 5f65 def attach_e\n-00046920: 7665 6e74 280a 2020 2020 2020 2020 7365 vent(. se\n-00046930: 6c66 3a20 2773 645f 6275 7327 2c20 6576 lf: 'sd_bus', ev\n-00046940: 656e 743a 204f 7074 696f 6e61 6c5b 7364 ent: Optional[sd\n-00046950: 5f65 7665 6e74 5d2c 2070 7269 6f72 6974 _event], priorit\n-00046960: 793a 2069 6e74 0a20 2020 2029 202d 3e20 y: int. ) -> \n-00046970: 556e 696f 6e5b 4e6f 6e65 2c20 4572 726e Union[None, Errn\n-00046980: 6f5d 3a0a 2020 2020 2020 2020 2e2e 2e0a o]:. ....\n-00046990: 0a20 2020 2064 6566 205f 6361 6c6c 280a . def _call(.\n-000469a0: 2020 2020 2020 2020 7365 6c66 3a20 2773 self: 's\n-000469b0: 645f 6275 7327 2c0a 2020 2020 2020 2020 d_bus',. \n-000469c0: 6d65 7373 6167 653a 2073 645f 6275 735f message: sd_bus_\n-000469d0: 6d65 7373 6167 652c 0a20 2020 2020 2020 message,. \n-000469e0: 2074 696d 656f 7574 3a20 416e 6e6f 7461 timeout: Annota\n-000469f0: 7465 645b 696e 742c 2063 7479 7065 732e ted[int, ctypes.\n-00046a00: 635f 7569 6e74 3634 5d2c 0a20 2020 2020 c_uint64],. \n-00046a10: 2020 2072 6574 5f65 7272 6f72 3a20 5265 ret_error: Re\n-00046a20: 6665 7265 6e63 655b 7364 5f62 7573 5f65 ference[sd_bus_e\n-00046a30: 7272 6f72 5d2c 0a20 2020 2020 2020 2072 rror],. r\n-00046a40: 6570 6c79 3a20 5265 6665 7265 6e63 655b eply: Reference[\n-00046a50: 7364 5f62 7573 5f6d 6573 7361 6765 5d2c sd_bus_message],\n-00046a60: 0a20 2020 2029 202d 3e20 556e 696f 6e5b . ) -> Union[\n-00046a70: 4e6f 6e65 2c20 4572 726e 6f5d 3a0a 2020 None, Errno]:. \n-00046a80: 2020 2020 2020 2e2e 2e0a 0a20 2020 2064 ..... d\n-00046a90: 6566 205f 6361 6c6c 5f61 7379 6e63 280a ef _call_async(.\n-00046aa0: 2020 2020 2020 2020 7365 6c66 3a20 2773 self: 's\n-00046ab0: 645f 6275 7327 2c0a 2020 2020 2020 2020 d_bus',. \n-00046ac0: 736c 6f74 3a20 5265 6665 7265 6e63 655b slot: Reference[\n-00046ad0: 7364 5f62 7573 5f73 6c6f 745d 2c0a 2020 sd_bus_slot],. \n-00046ae0: 2020 2020 2020 6d65 7373 6167 653a 2073 message: s\n-00046af0: 645f 6275 735f 6d65 7373 6167 652c 0a20 d_bus_message,. \n-00046b00: 2020 2020 2020 2063 616c 6c62 6163 6b3a callback:\n-00046b10: 2043 616c 6c62 6163 6b2c 0a20 2020 2020 Callback,. \n-00046b20: 2020 2075 7365 725f 6461 7461 3a20 5573 user_data: Us\n-00046b30: 6572 4461 7461 2c0a 2020 2020 2020 2020 erData,. \n-00046b40: 7469 6d65 6f75 745f 7573 6563 3a20 416e timeout_usec: An\n-00046b50: 6e6f 7461 7465 645b 696e 742c 2063 7479 notated[int, cty\n-00046b60: 7065 732e 635f 7569 6e74 3634 5d2c 0a20 pes.c_uint64],. \n-00046b70: 2020 2029 202d 3e20 556e 696f 6e5b 4e6f ) -> Union[No\n-00046b80: 6e65 2c20 4572 726e 6f5d 3a0a 2020 2020 ne, Errno]:. \n-00046b90: 2020 2020 2e2e 2e0a 0a20 2020 2064 6566 ..... def\n-00046ba0: 2066 6c75 7368 2873 656c 663a 2027 7364 flush(self: 'sd\n-00046bb0: 5f62 7573 2729 202d 3e20 556e 696f 6e5b _bus') -> Union[\n-00046bc0: 4e6f 6e65 2c20 4572 726e 6f5d 3a0a 2020 None, Errno]:. \n-00046bd0: 2020 2020 2020 2e2e 2e0a 0a20 2020 2064 ..... d\n-00046be0: 6566 2067 6574 5f66 6428 7365 6c66 3a20 ef get_fd(self: \n-00046bf0: 2773 645f 6275 7327 2920 2d3e 2055 6e69 'sd_bus') -> Uni\n-00046c00: 6f6e 5b69 6e74 2c20 4572 726e 6f5d 3a0a on[int, Errno]:.\n-00046c10: 2020 2020 2020 2020 7261 6973 6520 4e6f raise No\n-00046c20: 7449 6d70 6c65 6d65 6e74 6564 4572 726f tImplementedErro\n-00046c30: 720a 0a20 2020 2064 6566 205f 6d65 7373 r.. def _mess\n-00046c40: 6167 655f 6e65 775f 6d65 7468 6f64 5f63 age_new_method_c\n-00046c50: 616c 6c28 0a20 2020 2020 2020 2073 656c all(. sel\n-00046c60: 663a 2027 7364 5f62 7573 272c 0a20 2020 f: 'sd_bus',. \n-00046c70: 2020 2020 206d 6573 7361 6765 3a20 5265 message: Re\n-00046c80: 6665 7265 6e63 655b 7364 5f62 7573 5f6d ference[sd_bus_m\n-00046c90: 6573 7361 6765 5d2c 0a20 2020 2020 2020 essage],. \n-00046ca0: 2064 6573 7469 6e61 7469 6f6e 3a20 4f70 destination: Op\n-00046cb0: 7469 6f6e 616c 5b73 7472 5d2c 0a20 2020 tional[str],. \n-00046cc0: 2020 2020 2070 6174 683a 2073 7472 2c0a path: str,.\n-00046cd0: 2020 2020 2020 2020 696e 7465 7266 6163 interfac\n-00046ce0: 653a 2073 7472 2c0a 2020 2020 2020 2020 e: str,. \n-00046cf0: 6d65 6d62 6572 3a20 7374 722c 0a20 2020 member: str,. \n-00046d00: 2029 202d 3e20 556e 696f 6e5b 4e6f 6e65 ) -> Union[None\n-00046d10: 2c20 4572 726e 6f5d 3a0a 2020 2020 2020 , Errno]:. \n-00046d20: 2020 2e2e 2e0a 0a20 2020 2064 6566 205f ..... def _\n-00046d30: 6d65 7373 6167 655f 6e65 775f 7369 676e message_new_sign\n-00046d40: 616c 280a 2020 2020 2020 2020 7365 6c66 al(. self\n-00046d50: 3a20 2773 645f 6275 7327 2c0a 2020 2020 : 'sd_bus',. \n-00046d60: 2020 2020 6d65 7373 6167 653a 2052 6566 message: Ref\n-00046d70: 6572 656e 6365 5b73 645f 6275 735f 6d65 erence[sd_bus_me\n-00046d80: 7373 6167 655d 2c0a 2020 2020 2020 2020 ssage],. \n-00046d90: 7061 7468 3a20 7374 722c 0a20 2020 2020 path: str,. \n-00046da0: 2020 2069 6e74 6572 6661 6365 3a20 7374 interface: st\n-00046db0: 722c 0a20 2020 2020 2020 206d 656d 6265 r,. membe\n-00046dc0: 723a 2073 7472 2c0a 2020 2020 2920 2d3e r: str,. ) ->\n-00046dd0: 2055 6e69 6f6e 5b4e 6f6e 652c 2045 7272 Union[None, Err\n-00046de0: 6e6f 5d3a 0a20 2020 2020 2020 202e 2e2e no]:. ...\n-00046df0: 0a0a 2020 2020 6465 6620 7265 6c65 6173 .. def releas\n-00046e00: 655f 6e61 6d65 2873 656c 663a 2027 7364 e_name(self: 'sd\n-00046e10: 5f62 7573 272c 206e 616d 653a 2073 7472 _bus', name: str\n-00046e20: 2920 2d3e 2055 6e69 6f6e 5b4e 6f6e 652c ) -> Union[None,\n-00046e30: 2045 7272 6e6f 5d3a 0a20 2020 2020 2020 Errno]:. \n-00046e40: 202e 2e2e 0a0a 2020 2020 6465 6620 7265 ..... def re\n-00046e50: 7175 6573 745f 6e61 6d65 280a 2020 2020 quest_name(. \n-00046e60: 2020 2020 7365 6c66 3a20 2773 645f 6275 self: 'sd_bu\n-00046e70: 7327 2c20 6e61 6d65 3a20 7374 722c 2066 s', name: str, f\n-00046e80: 6c61 6773 3a20 416e 6e6f 7461 7465 645b lags: Annotated[\n-00046e90: 696e 742c 2063 7479 7065 732e 635f 7569 int, ctypes.c_ui\n-00046ea0: 6e74 3634 5d0a 2020 2020 2920 2d3e 2055 nt64]. ) -> U\n-00046eb0: 6e69 6f6e 5b4e 6f6e 652c 2045 7272 6e6f nion[None, Errno\n-00046ec0: 5d3a 0a20 2020 2020 2020 202e 2e2e 0a0a ]:. .....\n-00046ed0: 2020 2020 6465 6620 7365 745f 6164 6472 def set_addr\n-00046ee0: 6573 7328 7365 6c66 3a20 2773 645f 6275 ess(self: 'sd_bu\n-00046ef0: 7327 2c20 6164 6472 6573 733a 2073 7472 s', address: str\n-00046f00: 2920 2d3e 2055 6e69 6f6e 5b4e 6f6e 652c ) -> Union[None,\n-00046f10: 2045 7272 6e6f 5d3a 0a20 2020 2020 2020 Errno]:. \n-00046f20: 202e 2e2e 0a0a 2020 2020 6465 6620 7365 ..... def se\n-00046f30: 745f 6275 735f 636c 6965 6e74 2873 656c t_bus_client(sel\n-00046f40: 663a 2027 7364 5f62 7573 272c 2062 3a20 f: 'sd_bus', b: \n-00046f50: 626f 6f6c 2920 2d3e 2055 6e69 6f6e 5b4e bool) -> Union[N\n-00046f60: 6f6e 652c 2045 7272 6e6f 5d3a 0a20 2020 one, Errno]:. \n-00046f70: 2020 2020 202e 2e2e 0a0a 2020 2020 6465 ..... de\n-00046f80: 6620 7365 745f 6664 2873 656c 663a 2027 f set_fd(self: '\n-00046f90: 7364 5f62 7573 272c 2069 6e70 7574 5f66 sd_bus', input_f\n-00046fa0: 643a 2069 6e74 2c20 6f75 7470 7574 5f66 d: int, output_f\n-00046fb0: 643a 2069 6e74 2920 2d3e 2055 6e69 6f6e d: int) -> Union\n-00046fc0: 5b4e 6f6e 652c 2045 7272 6e6f 5d3a 0a20 [None, Errno]:. \n-00046fd0: 2020 2020 2020 202e 2e2e 0a0a 2020 2020 ..... \n-00046fe0: 6465 6620 7365 745f 7365 7276 6572 2873 def set_server(s\n-00046ff0: 656c 663a 2027 7364 5f62 7573 272c 2062 elf: 'sd_bus', b\n-00047000: 3a20 626f 6f6c 2c20 6275 735f 643a 2073 : bool, bus_d: s\n-00047010: 645f 6964 3132 3829 202d 3e20 556e 696f d_id128) -> Unio\n-00047020: 6e5b 4e6f 6e65 2c20 4572 726e 6f5d 3a0a n[None, Errno]:.\n-00047030: 2020 2020 2020 2020 2e2e 2e0a 0a20 2020 ..... \n-00047040: 2064 6566 2073 7461 7274 2873 656c 663a def start(self:\n-00047050: 2027 7364 5f62 7573 2729 202d 3e20 556e 'sd_bus') -> Un\n-00047060: 696f 6e5b 4e6f 6e65 2c20 4572 726e 6f5d ion[None, Errno]\n-00047070: 3a0a 2020 2020 2020 2020 2e2e 2e0a 0a20 :. ..... \n-00047080: 2020 2064 6566 2077 6169 7428 0a20 2020 def wait(. \n-00047090: 2020 2020 2073 656c 663a 2027 7364 5f62 self: 'sd_b\n-000470a0: 7573 272c 2074 696d 656f 7574 5f75 7365 us', timeout_use\n-000470b0: 633a 2041 6e6e 6f74 6174 6564 5b69 6e74 c: Annotated[int\n-000470c0: 2c20 6374 7970 6573 2e63 5f75 696e 7436 , ctypes.c_uint6\n-000470d0: 345d 0a20 2020 2029 202d 3e20 556e 696f 4]. ) -> Unio\n-000470e0: 6e5b 4e6f 6e65 2c20 4572 726e 6f5d 3a0a n[None, Errno]:.\n-000470f0: 2020 2020 2020 2020 2e2e 2e0a 0a20 2020 ..... \n-00047100: 2064 6566 2073 656e 6428 0a20 2020 2020 def send(. \n-00047110: 2020 2073 656c 663a 2027 7364 5f62 7573 self: 'sd_bus\n-00047120: 272c 206d 6573 7361 6765 3a20 7364 5f62 ', message: sd_b\n-00047130: 7573 5f6d 6573 7361 6765 2c20 636f 6f6b us_message, cook\n-00047140: 6965 3a20 4f70 7469 6f6e 616c 5b52 6566 ie: Optional[Ref\n-00047150: 6572 656e 6365 5b63 7479 7065 732e 635f erence[ctypes.c_\n-00047160: 7569 6e74 3634 5d5d 0a20 2020 2029 202d uint64]]. ) -\n-00047170: 3e20 556e 696f 6e5b 4e6f 6e65 2c20 4572 > Union[None, Er\n-00047180: 726e 6f5d 3a0a 2020 2020 2020 2020 2e2e rno]:. ..\n-00047190: 2e0a 0a20 2020 2040 7374 6174 6963 6d65 ... @staticme\n-000471a0: 7468 6f64 0a20 2020 2064 6566 205f 6465 thod. def _de\n-000471b0: 6661 756c 745f 7379 7374 656d 2872 6574 fault_system(ret\n-000471c0: 3a20 5265 6665 7265 6e63 655b 2773 645f : Reference['sd_\n-000471d0: 6275 7327 5d29 202d 3e20 556e 696f 6e5b bus']) -> Union[\n-000471e0: 4e6f 6e65 2c20 4572 726e 6f5d 3a0a 2020 None, Errno]:. \n-000471f0: 2020 2020 2020 2e2e 2e0a 0a20 2020 2040 ..... @\n-00047200: 7374 6174 6963 6d65 7468 6f64 0a20 2020 staticmethod. \n-00047210: 2064 6566 205f 6465 6661 756c 745f 7573 def _default_us\n-00047220: 6572 2872 6574 3a20 5265 6665 7265 6e63 er(ret: Referenc\n-00047230: 655b 2773 645f 6275 7327 5d29 202d 3e20 e['sd_bus']) -> \n-00047240: 556e 696f 6e5b 4e6f 6e65 2c20 4572 726e Union[None, Errn\n-00047250: 6f5d 3a0a 2020 2020 2020 2020 2e2e 2e0a o]:. ....\n-00047260: 0a20 2020 2040 7374 6174 6963 6d65 7468 . @staticmeth\n-00047270: 6f64 0a20 2020 2064 6566 205f 6e65 7728 od. def _new(\n-00047280: 7265 743a 2052 6566 6572 656e 6365 5b27 ret: Reference['\n-00047290: 7364 5f62 7573 275d 2920 2d3e 2055 6e69 sd_bus']) -> Uni\n-000472a0: 6f6e 5b4e 6f6e 652c 2045 7272 6e6f 5d3a on[None, Errno]:\n-000472b0: 0a20 2020 2020 2020 202e 2e2e 0a0a 0a73 . ......s\n-000472c0: 645f 6275 735f 6d65 7373 6167 655f 6861 d_bus_message_ha\n-000472d0: 6e64 6c65 725f 7420 3d20 6374 7970 6573 ndler_t = ctypes\n-000472e0: 2e43 4655 4e43 5459 5045 280a 2020 2020 .CFUNCTYPE(. \n-000472f0: 6374 7970 6573 2e63 5f69 6e74 2c20 6374 ctypes.c_int, ct\n-00047300: 7970 6573 2e63 5f76 6f69 645f 702c 2063 ypes.c_void_p, c\n-00047310: 7479 7065 732e 635f 766f 6964 5f70 2c20 types.c_void_p, \n-00047320: 6374 7970 6573 2e50 4f49 4e54 4552 2873 ctypes.POINTER(s\n-00047330: 645f 6275 735f 6572 726f 7229 290a 7364 d_bus_error)).sd\n-00047340: 5f65 7665 6e74 5f69 6e6f 7469 6679 5f68 _event_inotify_h\n-00047350: 616e 646c 6572 5f74 203d 2063 7479 7065 andler_t = ctype\n-00047360: 732e 4346 554e 4354 5950 4528 0a20 2020 s.CFUNCTYPE(. \n-00047370: 2063 7479 7065 732e 635f 696e 742c 2063 ctypes.c_int, c\n-00047380: 7479 7065 732e 635f 766f 6964 5f70 2c20 types.c_void_p, \n-00047390: 6374 7970 6573 2e50 4f49 4e54 4552 2869 ctypes.POINTER(i\n-000473a0: 6e6f 7469 6679 5f65 7665 6e74 292c 2063 notify_event), c\n-000473b0: 7479 7065 732e 635f 766f 6964 5f70 290a types.c_void_p).\n-000473c0: 0a0a 6c69 6273 7973 7465 6d64 203d 2063 ..libsystemd = c\n-000473d0: 7479 7065 732e 4344 4c4c 2822 6c69 6273 types.CDLL(\"libs\n-000473e0: 7973 7465 6d64 2e73 6f2e 3022 290a 666f ystemd.so.0\").fo\n-000473f0: 7220 636c 7320 696e 207b 0a20 2020 2073 r cls in {. s\n-00047400: 645f 6275 732c 0a20 2020 2073 645f 6275 d_bus,. sd_bu\n-00047410: 735f 6d65 7373 6167 652c 0a20 2020 2073 s_message,. s\n-00047420: 645f 6275 735f 736c 6f74 2c0a 2020 2020 d_bus_slot,. \n-00047430: 7364 5f65 7665 6e74 2c0a 2020 2020 7364 sd_event,. sd\n-00047440: 5f65 7665 6e74 5f73 6f75 7263 652c 0a7d _event_source,.}\n-00047450: 3a0a 2020 2020 636c 732e 5f69 6e73 7461 :. cls._insta\n-00047460: 6c6c 5f63 6675 6e63 7328 6c69 6273 7973 ll_cfuncs(libsys\n-00047470: 7465 6d64 290a 2727 272e 656e 636f 6465 temd).'''.encode\n-00047480: 2827 7574 662d 3827 292c 0a20 2027 636f ('utf-8'),. 'co\n-00047490: 636b 7069 742f 5f76 656e 646f 722f 7379 ckpit/_vendor/sy\n-000474a0: 7374 656d 645f 6374 7970 6573 2f62 7573 stemd_ctypes/bus\n-000474b0: 2e70 7927 3a20 6272 2727 2723 2073 7973 .py': br'''# sys\n-000474c0: 7465 6d64 5f63 7479 7065 730a 230a 2320 temd_ctypes.#.# \n-000474d0: 436f 7079 7269 6768 7420 2843 2920 3230 Copyright (C) 20\n-000474e0: 3232 2041 6c6c 6973 6f6e 204b 6172 6c69 22 Allison Karli\n-000474f0: 7473 6b61 7961 203c 616c 6c69 736f 6e2e tskaya <allison.\n-00047500: 6b61 726c 6974 736b 6179 6140 7265 6468 karlitskaya@redh\n-00047510: 6174 2e63 6f6d 3e0a 230a 2320 5468 6973 at.com>.#.# This\n-00047520: 2070 726f 6772 616d 2069 7320 6672 6565 program is free\n-00047530: 2073 6f66 7477 6172 653a 2079 6f75 2063 software: you c\n-00047540: 616e 2072 6564 6973 7472 6962 7574 6520 an redistribute \n-00047550: 6974 2061 6e64 2f6f 7220 6d6f 6469 6679 it and/or modify\n-00047560: 0a23 2069 7420 756e 6465 7220 7468 6520 .# it under the \n-00047570: 7465 726d 7320 6f66 2074 6865 2047 4e55 terms of the GNU\n-00047580: 2047 656e 6572 616c 2050 7562 6c69 6320 General Public \n-00047590: 4c69 6365 6e73 6520 6173 2070 7562 6c69 License as publi\n-000475a0: 7368 6564 2062 790a 2320 7468 6520 4672 shed by.# the Fr\n-000475b0: 6565 2053 6f66 7477 6172 6520 466f 756e ee Software Foun\n-000475c0: 6461 7469 6f6e 2c20 6569 7468 6572 2076 dation, either v\n-000475d0: 6572 7369 6f6e 2033 206f 6620 7468 6520 ersion 3 of the \n-000475e0: 4c69 6365 6e73 652c 206f 720a 2320 2861 License, or.# (a\n-000475f0: 7420 796f 7572 206f 7074 696f 6e29 2061 t your option) a\n-00047600: 6e79 206c 6174 6572 2076 6572 7369 6f6e ny later version\n-00047610: 2e0a 230a 2320 5468 6973 2070 726f 6772 ..#.# This progr\n-00047620: 616d 2069 7320 6469 7374 7269 6275 7465 am is distribute\n-00047630: 6420 696e 2074 6865 2068 6f70 6520 7468 d in the hope th\n-00047640: 6174 2069 7420 7769 6c6c 2062 6520 7573 at it will be us\n-00047650: 6566 756c 2c0a 2320 6275 7420 5749 5448 eful,.# but WITH\n-00047660: 4f55 5420 414e 5920 5741 5252 414e 5459 OUT ANY WARRANTY\n-00047670: 3b20 7769 7468 6f75 7420 6576 656e 2074 ; without even t\n-00047680: 6865 2069 6d70 6c69 6564 2077 6172 7261 he implied warra\n-00047690: 6e74 7920 6f66 0a23 204d 4552 4348 414e nty of.# MERCHAN\n-000476a0: 5441 4249 4c49 5459 206f 7220 4649 544e TABILITY or FITN\n-000476b0: 4553 5320 464f 5220 4120 5041 5254 4943 ESS FOR A PARTIC\n-000476c0: 554c 4152 2050 5552 504f 5345 2e20 2053 ULAR PURPOSE. S\n-000476d0: 6565 2074 6865 0a23 2047 4e55 2047 656e ee the.# GNU Gen\n-000476e0: 6572 616c 2050 7562 6c69 6320 4c69 6365 eral Public Lice\n-000476f0: 6e73 6520 666f 7220 6d6f 7265 2064 6574 nse for more det\n-00047700: 6169 6c73 2e0a 230a 2320 596f 7520 7368 ails..#.# You sh\n-00047710: 6f75 6c64 2068 6176 6520 7265 6365 6976 ould have receiv\n-00047720: 6564 2061 2063 6f70 7920 6f66 2074 6865 ed a copy of the\n-00047730: 2047 4e55 2047 656e 6572 616c 2050 7562 GNU General Pub\n-00047740: 6c69 6320 4c69 6365 6e73 650a 2320 616c lic License.# al\n-00047750: 6f6e 6720 7769 7468 2074 6869 7320 7072 ong with this pr\n-00047760: 6f67 7261 6d2e 2020 4966 206e 6f74 2c20 ogram. If not, \n-00047770: 7365 6520 3c68 7474 703a 2f2f 7777 772e see <http://www.\n-00047780: 676e 752e 6f72 672f 6c69 6365 6e73 6573 gnu.org/licenses\n-00047790: 2f3e 2e0a 0a69 6d70 6f72 7420 6173 796e />...import asyn\n-000477a0: 6369 6f0a 696d 706f 7274 2065 6e75 6d0a cio.import enum.\n-000477b0: 696d 706f 7274 206c 6f67 6769 6e67 0a69 import logging.i\n-000477c0: 6d70 6f72 7420 7479 7069 6e67 0a66 726f mport typing.fro\n-000477d0: 6d20 7479 7069 6e67 2069 6d70 6f72 7420 m typing import \n-000477e0: 416e 792c 2043 616c 6c61 626c 652c 2044 Any, Callable, D\n-000477f0: 6963 742c 204f 7074 696f 6e61 6c2c 2053 ict, Optional, S\n-00047800: 6571 7565 6e63 652c 2054 7570 6c65 2c20 equence, Tuple, \n-00047810: 556e 696f 6e0a 0a66 726f 6d20 2e20 696d Union..from . im\n-00047820: 706f 7274 2062 7573 7479 7065 732c 2069 port bustypes, i\n-00047830: 6e74 726f 7370 6563 7469 6f6e 2c20 6c69 ntrospection, li\n-00047840: 6273 7973 7465 6d64 0a66 726f 6d20 2e6c bsystemd.from .l\n-00047850: 6962 7261 7279 7772 6170 7065 7220 696d ibrarywrapper im\n-00047860: 706f 7274 2057 6561 6b52 6566 6572 656e port WeakReferen\n-00047870: 6365 2c20 6279 7265 660a 0a6c 6f67 6765 ce, byref..logge\n-00047880: 7220 3d20 6c6f 6767 696e 672e 6765 744c r = logging.getL\n-00047890: 6f67 6765 7228 5f5f 6e61 6d65 5f5f 290a ogger(__name__).\n-000478a0: 0a0a 636c 6173 7320 4275 7345 7272 6f72 ..class BusError\n-000478b0: 2845 7863 6570 7469 6f6e 293a 0a20 2020 (Exception):. \n-000478c0: 2022 2222 416e 2065 7863 6570 7469 6f6e \"\"\"An exception\n-000478d0: 2063 6f72 7265 7370 6f6e 6469 6e67 2074 corresponding t\n-000478e0: 6f20 6120 442d 4275 7320 6572 726f 7220 o a D-Bus error \n-000478f0: 6d65 7373 6167 650a 0a20 2020 2054 6869 message.. Thi\n-00047900: 7320 6578 6365 7074 696f 6e20 6973 2072 s exception is r\n-00047910: 6169 7365 6420 6279 2074 6865 206d 6574 aised by the met\n-00047920: 686f 6420 6361 6c6c 206d 6574 686f 6473 hod call methods\n-00047930: 2e20 2059 6f75 2063 616e 2061 6c73 6f20 . You can also \n-00047940: 7261 6973 6520 6974 0a20 2020 2066 726f raise it. fro\n-00047950: 6d20 796f 7572 206f 776e 206d 6574 686f m your own metho\n-00047960: 6420 6861 6e64 6c65 7273 2e20 2049 7420 d handlers. It \n-00047970: 6361 6e20 616c 736f 2062 6520 7061 7373 can also be pass\n-00047980: 6564 2064 6972 6563 746c 7920 746f 2066 ed directly to f\n-00047990: 756e 6374 696f 6e73 0a20 2020 2073 7563 unctions. suc\n-000479a0: 6820 6173 204d 6573 7361 6765 2e72 6570 h as Message.rep\n-000479b0: 6c79 5f6d 6574 686f 645f 6572 726f 7228 ly_method_error(\n-000479c0: 292e 0a0a 2020 2020 3a6e 616d 653a 2074 )... :name: t\n-000479d0: 6865 2027 636f 6465 2720 6f66 2074 6865 he 'code' of the\n-000479e0: 2065 7272 6f72 2c20 6c69 6b65 206f 7267 error, like org\n-000479f0: 2e66 7265 6564 6573 6b74 6f70 2e44 4275 .freedesktop.DBu\n-00047a00: 732e 4572 726f 722e 556e 6b6e 6f77 6e4d s.Error.UnknownM\n-00047a10: 6574 686f 640a 2020 2020 3a6d 6573 7361 ethod. :messa\n-00047a20: 6765 3a20 6120 6875 6d61 6e2d 7265 6164 ge: a human-read\n-00047a30: 6162 6c65 2064 6573 6372 6970 7469 6f6e able description\n-00047a40: 206f 6620 7468 6520 6572 726f 720a 2020 of the error. \n-00047a50: 2020 2222 220a 2020 2020 6465 6620 5f5f \"\"\". def __\n-00047a60: 696e 6974 5f5f 2873 656c 662c 206e 616d init__(self, nam\n-00047a70: 653a 2073 7472 2c20 6d65 7373 6167 653a e: str, message:\n-00047a80: 2073 7472 293a 0a20 2020 2020 2020 2073 str):. s\n-00047a90: 7570 6572 2829 2e5f 5f69 6e69 745f 5f28 uper().__init__(\n-00047aa0: 6627 7b6e 616d 657d 3a20 7b6d 6573 7361 f'{name}: {messa\n-00047ab0: 6765 7d27 290a 2020 2020 2020 2020 7365 ge}'). se\n-00047ac0: 6c66 2e6e 616d 6520 3d20 6e61 6d65 0a20 lf.name = name. \n-00047ad0: 2020 2020 2020 2073 656c 662e 6d65 7373 self.mess\n-00047ae0: 6167 6520 3d20 6d65 7373 6167 650a 0a0a age = message...\n-00047af0: 636c 6173 7320 4275 734d 6573 7361 6765 class BusMessage\n-00047b00: 286c 6962 7379 7374 656d 642e 7364 5f62 (libsystemd.sd_b\n-00047b10: 7573 5f6d 6573 7361 6765 293a 0a20 2020 us_message):. \n-00047b20: 2022 2222 4120 6d65 7373 6167 652c 2072 \"\"\"A message, r\n-00047b30: 6563 6569 7665 6420 6672 6f6d 206f 7220 eceived from or \n-00047b40: 746f 2062 6520 7365 6e74 206f 7665 7220 to be sent over \n-00047b50: 442d 4275 730a 0a20 2020 2054 6869 7320 D-Bus.. This \n-00047b60: 6973 2074 6865 206c 6f77 2d6c 6576 656c is the low-level\n-00047b70: 2069 6e74 6572 6661 6365 2074 6f20 7265 interface to re\n-00047b80: 6365 6976 696e 6720 616e 6420 7365 6e64 ceiving and send\n-00047b90: 696e 6720 696e 6469 7669 6475 616c 0a20 ing individual. \n-00047ba0: 2020 206d 6573 7361 6765 7320 6f76 6572 messages over\n-00047bb0: 2044 2d42 7573 2e20 2059 6f75 2077 6f6e D-Bus. You won\n-00047bc0: 2774 206e 6f72 6d61 6c6c 7920 6e65 6564 't normally need\n-00047bd0: 2074 6f20 7573 6520 6974 2e0a 0a20 2020 to use it... \n-00047be0: 2041 206d 6573 7361 6765 2069 7320 6173 A message is as\n-00047bf0: 736f 6369 6174 6564 2077 6974 6820 6120 sociated with a \n-00047c00: 7061 7274 6963 756c 6172 2062 7573 2e20 particular bus. \n-00047c10: 2059 6f75 2063 616e 2063 7265 6174 6520 You can create \n-00047c20: 6d65 7373 6167 6573 2066 6f72 0a20 2020 messages for. \n-00047c30: 2061 2062 7573 2077 6974 6820 4275 732e a bus with Bus.\n-00047c40: 6d65 7373 6167 655f 6e65 775f 6d65 7468 message_new_meth\n-00047c50: 6f64 5f63 616c 6c28 2920 6f72 2042 7573 od_call() or Bus\n-00047c60: 2e6d 6573 7361 6765 5f6e 6577 5f73 6967 .message_new_sig\n-00047c70: 6e61 6c28 292e 2020 596f 750a 2020 2020 nal(). You. \n-00047c80: 6361 6e20 6372 6561 7465 2072 6570 6c69 can create repli\n-00047c90: 6573 2074 6f20 6d65 7468 6f64 2063 616c es to method cal\n-00047ca0: 6c73 2077 6974 6820 4d65 7373 6167 652e ls with Message.\n-00047cb0: 6e65 775f 6d65 7468 6f64 5f72 6574 7572 new_method_retur\n-00047cc0: 6e28 2920 6f72 0a20 2020 204d 6573 7361 n() or. Messa\n-00047cd0: 6765 2e6e 6577 5f6d 6574 686f 645f 6572 ge.new_method_er\n-00047ce0: 726f 7228 292e 2020 596f 7520 6361 6e20 ror(). You can \n-00047cf0: 6170 7065 6e64 2061 7267 756d 656e 7473 append arguments\n-00047d00: 2077 6974 6820 4d65 7373 6167 652e 6170 with Message.ap\n-00047d10: 7065 6e64 2829 0a20 2020 2061 6e64 2073 pend(). and s\n-00047d20: 656e 6420 7468 6520 6d65 7373 6167 6520 end the message \n-00047d30: 7769 7468 204d 6573 7361 6765 2e73 656e with Message.sen\n-00047d40: 6428 292e 0a20 2020 2022 2222 0a20 2020 d().. \"\"\". \n-00047d50: 2064 6566 2067 6574 5f62 7573 2873 656c def get_bus(sel\n-00047d60: 6629 202d 3e20 2742 7573 273a 0a20 2020 f) -> 'Bus':. \n-00047d70: 2020 2020 2022 2222 4765 7420 7468 6520 \"\"\"Get the \n-00047d80: 6275 7320 7468 6174 2061 206d 6573 7361 bus that a messa\n-00047d90: 6765 2069 7320 6173 736f 6369 6174 6564 ge is associated\n-00047da0: 2077 6974 682e 0a0a 2020 2020 2020 2020 with... \n-00047db0: 5468 6973 2069 7320 7468 6520 6275 7320 This is the bus \n-00047dc0: 7468 6174 2061 206d 6573 7361 6765 2063 that a message c\n-00047dd0: 616d 6520 6672 6f6d 206f 7220 7769 6c6c ame from or will\n-00047de0: 2062 6520 7365 6e74 206f 6e2e 2020 4576 be sent on. Ev\n-00047df0: 6572 790a 2020 2020 2020 2020 6d65 7373 ery. mess\n-00047e00: 6167 6520 6861 7320 616e 2061 7373 6f63 age has an assoc\n-00047e10: 6961 7465 6420 6275 732c 2061 6e64 2069 iated bus, and i\n-00047e20: 7420 6361 6e6e 6f74 2062 6520 6368 616e t cannot be chan\n-00047e30: 6765 642e 0a0a 2020 2020 2020 2020 3a72 ged... :r\n-00047e40: 6574 7572 6e73 3a20 7468 6520 4275 730a eturns: the Bus.\n-00047e50: 2020 2020 2020 2020 2222 220a 2020 2020 \"\"\". \n-00047e60: 2020 2020 7265 7475 726e 2042 7573 2e72 return Bus.r\n-00047e70: 6566 2873 656c 662e 5f67 6574 5f62 7573 ef(self._get_bus\n-00047e80: 2829 290a 0a20 2020 2064 6566 2067 6574 ()).. def get\n-00047e90: 5f65 7272 6f72 2873 656c 6629 202d 3e20 _error(self) -> \n-00047ea0: 4f70 7469 6f6e 616c 5b42 7573 4572 726f Optional[BusErro\n-00047eb0: 725d 3a0a 2020 2020 2020 2020 2222 2247 r]:. \"\"\"G\n-00047ec0: 6574 2074 6865 2042 7573 4572 726f 7220 et the BusError \n-00047ed0: 6672 6f6d 2061 206d 6573 7361 6765 2e0a from a message..\n-00047ee0: 0a20 2020 2020 2020 203a 7265 7475 726e . :return\n-00047ef0: 733a 2061 2042 7573 4572 726f 7220 666f s: a BusError fo\n-00047f00: 7220 616e 2065 7272 6f72 206d 6573 7361 r an error messa\n-00047f10: 6765 2c20 6f72 204e 6f6e 6520 666f 7220 ge, or None for \n-00047f20: 6120 6e6f 6e2d 6572 726f 7220 6d65 7373 a non-error mess\n-00047f30: 6167 650a 2020 2020 2020 2020 2222 220a age. \"\"\".\n-00047f40: 2020 2020 2020 2020 6572 726f 7220 3d20 error = \n-00047f50: 7365 6c66 2e5f 6765 745f 6572 726f 7228 self._get_error(\n-00047f60: 290a 2020 2020 2020 2020 6966 2065 7272 ). if err\n-00047f70: 6f72 3a0a 2020 2020 2020 2020 2020 2020 or:. \n-00047f80: 7265 7475 726e 2042 7573 4572 726f 7228 return BusError(\n-00047f90: 2a65 7272 6f72 2e63 6f6e 7465 6e74 732e *error.contents.\n-00047fa0: 6765 7428 2929 0a20 2020 2020 2020 2065 get()). e\n-00047fb0: 6c73 653a 0a20 2020 2020 2020 2020 2020 lse:. \n-00047fc0: 2072 6574 7572 6e20 4e6f 6e65 0a0a 2020 return None.. \n-00047fd0: 2020 6465 6620 6e65 775f 6d65 7468 6f64 def new_method\n-00047fe0: 5f72 6574 7572 6e28 7365 6c66 2c20 7369 _return(self, si\n-00047ff0: 676e 6174 7572 653a 2073 7472 203d 2027 gnature: str = '\n-00048000: 272c 202a 6172 6773 3a20 416e 7929 202d ', *args: Any) -\n-00048010: 3e20 2742 7573 4d65 7373 6167 6527 3a0a > 'BusMessage':.\n-00048020: 2020 2020 2020 2020 2222 2243 7265 6174 \"\"\"Creat\n-00048030: 6520 6120 6e65 7720 2873 7563 6365 7373 e a new (success\n-00048040: 6675 6c29 2072 6574 7572 6e20 6d65 7373 ful) return mess\n-00048050: 6167 6520 6173 2061 2072 6570 6c79 2074 age as a reply t\n-00048060: 6f20 7468 6973 206d 6573 7361 6765 2e0a o this message..\n-00048070: 0a20 2020 2020 2020 2054 6869 7320 6f6e . This on\n-00048080: 6c79 206d 616b 6573 2073 656e 7365 2077 ly makes sense w\n-00048090: 6865 6e20 7065 7266 6f72 6d65 6420 6f6e hen performed on\n-000480a0: 2061 206d 6574 686f 6420 6361 6c6c 206d a method call m\n-000480b0: 6573 7361 6765 2e0a 0a20 2020 2020 2020 essage... \n-000480c0: 203a 7369 676e 6174 7572 653a 2054 6865 :signature: The\n-000480d0: 2073 6967 6e61 7475 7265 206f 6620 7468 signature of th\n-000480e0: 6520 7265 7375 6c74 2c20 6173 2061 2073 e result, as a s\n-000480f0: 7472 696e 672e 0a20 2020 2020 2020 203a tring.. :\n-00048100: 6172 6773 3a20 5468 6520 7661 6c75 6573 args: The values\n-00048110: 2074 6f20 7365 6e64 2c20 636f 6e66 6f72 to send, confor\n-00048120: 6d69 6e67 2074 6f20 7468 6520 7369 676e ming to the sign\n-00048130: 6174 7572 6520 7374 7269 6e67 2e0a 0a20 ature string... \n-00048140: 2020 2020 2020 203a 7265 7475 726e 733a :returns:\n-00048150: 2074 6865 2072 6570 6c79 206d 6573 7361 the reply messa\n-00048160: 6765 0a20 2020 2020 2020 2022 2222 0a20 ge. \"\"\". \n-00048170: 2020 2020 2020 2072 6570 6c79 203d 2042 reply = B\n-00048180: 7573 4d65 7373 6167 6528 290a 2020 2020 usMessage(). \n-00048190: 2020 2020 7365 6c66 2e5f 6e65 775f 6d65 self._new_me\n-000481a0: 7468 6f64 5f72 6574 7572 6e28 6279 7265 thod_return(byre\n-000481b0: 6628 7265 706c 7929 290a 2020 2020 2020 f(reply)). \n-000481c0: 2020 7265 706c 792e 6170 7065 6e64 2873 reply.append(s\n-000481d0: 6967 6e61 7475 7265 2c20 2a61 7267 7329 ignature, *args)\n-000481e0: 0a20 2020 2020 2020 2072 6574 7572 6e20 . return \n-000481f0: 7265 706c 790a 0a20 2020 2064 6566 206e reply.. def n\n-00048200: 6577 5f6d 6574 686f 645f 6572 726f 7228 ew_method_error(\n-00048210: 7365 6c66 2c20 6572 726f 723a 2055 6e69 self, error: Uni\n-00048220: 6f6e 5b42 7573 4572 726f 722c 204f 5345 on[BusError, OSE\n-00048230: 7272 6f72 5d29 202d 3e20 2742 7573 4d65 rror]) -> 'BusMe\n-00048240: 7373 6167 6527 3a0a 2020 2020 2020 2020 ssage':. \n-00048250: 2222 2243 7265 6174 6520 6120 6e65 7720 \"\"\"Create a new \n-00048260: 6572 726f 7220 6d65 7373 6167 6520 6173 error message as\n-00048270: 2061 2072 6570 6c79 2074 6f20 7468 6973 a reply to this\n-00048280: 206d 6573 7361 6765 2e0a 0a20 2020 2020 message... \n-00048290: 2020 2054 6869 7320 6f6e 6c79 206d 616b This only mak\n-000482a0: 6573 2073 656e 7365 2077 6865 6e20 7065 es sense when pe\n-000482b0: 7266 6f72 6d65 6420 6f6e 2061 206d 6574 rformed on a met\n-000482c0: 686f 6420 6361 6c6c 206d 6573 7361 6765 hod call message\n-000482d0: 2e0a 0a20 2020 2020 2020 203a 6572 726f ... :erro\n-000482e0: 723a 2042 7573 4572 726f 7220 6f72 204f r: BusError or O\n-000482f0: 5345 7272 6f72 206f 6620 7468 6520 6572 SError of the er\n-00048300: 726f 7220 746f 2073 656e 640a 0a20 2020 ror to send.. \n-00048310: 2020 2020 203a 7265 7475 726e 733a 2074 :returns: t\n-00048320: 6865 2072 6570 6c79 206d 6573 7361 6765 he reply message\n-00048330: 0a20 2020 2020 2020 2022 2222 0a20 2020 . \"\"\". \n-00048340: 2020 2020 2072 6570 6c79 203d 2042 7573 reply = Bus\n-00048350: 4d65 7373 6167 6528 290a 2020 2020 2020 Message(). \n-00048360: 2020 6966 2069 7369 6e73 7461 6e63 6528 if isinstance(\n-00048370: 6572 726f 722c 2042 7573 4572 726f 7229 error, BusError)\n-00048380: 3a0a 2020 2020 2020 2020 2020 2020 7365 :. se\n-00048390: 6c66 2e5f 6e65 775f 6d65 7468 6f64 5f65 lf._new_method_e\n-000483a0: 7272 6f72 6628 6279 7265 6628 7265 706c rrorf(byref(repl\n-000483b0: 7929 2c20 6572 726f 722e 6e61 6d65 2c20 y), error.name, \n-000483c0: 2225 7322 2c20 6572 726f 722e 6d65 7373 \"%s\", error.mess\n-000483d0: 6167 6529 0a20 2020 2020 2020 2065 6c73 age). els\n-000483e0: 653a 0a20 2020 2020 2020 2020 2020 2061 e:. a\n-000483f0: 7373 6572 7420 6973 696e 7374 616e 6365 ssert isinstance\n-00048400: 2865 7272 6f72 2c20 4f53 4572 726f 7229 (error, OSError)\n-00048410: 0a20 2020 2020 2020 2020 2020 2073 656c . sel\n-00048420: 662e 5f6e 6577 5f6d 6574 686f 645f 6572 f._new_method_er\n-00048430: 726e 6f66 2862 7972 6566 2872 6570 6c79 rnof(byref(reply\n-00048440: 292c 2065 7272 6f72 2e65 7272 6e6f 2c20 ), error.errno, \n-00048450: 2225 7322 2c20 7374 7228 6572 726f 7229 \"%s\", str(error)\n-00048460: 290a 2020 2020 2020 2020 7265 7475 726e ). return\n-00048470: 2072 6570 6c79 0a0a 2020 2020 6465 6620 reply.. def \n-00048480: 6170 7065 6e64 5f61 7267 2873 656c 662c append_arg(self,\n-00048490: 2074 7970 6573 7472 696e 673a 2073 7472 typestring: str\n-000484a0: 2c20 6172 673a 2041 6e79 2920 2d3e 204e , arg: Any) -> N\n-000484b0: 6f6e 653a 0a20 2020 2020 2020 2022 2222 one:. \"\"\"\n-000484c0: 4170 7065 6e64 2061 2073 696e 676c 6520 Append a single \n-000484d0: 6172 6775 6d65 6e74 2074 6f20 7468 6520 argument to the \n-000484e0: 6d65 7373 6167 652e 0a0a 2020 2020 2020 message... \n-000484f0: 2020 3a74 7970 6573 7472 696e 673a 2061 :typestring: a\n-00048500: 2073 696e 676c 6520 7479 7065 7374 7269 single typestri\n-00048510: 6e67 2c20 7375 6368 2061 7320 2773 272c ng, such as 's',\n-00048520: 206f 7220 2761 7b73 767d 270a 2020 2020 or 'a{sv}'. \n-00048530: 2020 2020 3a61 7267 3a20 7468 6520 6172 :arg: the ar\n-00048540: 6775 6d65 6e74 2074 6f20 6170 7065 6e64 gument to append\n-00048550: 2c20 6d61 7463 6869 6e67 2074 6865 2074 , matching the t\n-00048560: 7970 6573 7472 696e 670a 2020 2020 2020 ypestring. \n-00048570: 2020 2222 220a 2020 2020 2020 2020 7479 \"\"\". ty\n-00048580: 7065 5f2c 203d 2062 7573 7479 7065 732e pe_, = bustypes.\n-00048590: 6672 6f6d 5f73 6967 6e61 7475 7265 2874 from_signature(t\n-000485a0: 7970 6573 7472 696e 6729 0a20 2020 2020 ypestring). \n-000485b0: 2020 2074 7970 655f 2e77 7269 7465 7228 type_.writer(\n-000485c0: 7365 6c66 2c20 6172 6729 0a0a 2020 2020 self, arg).. \n-000485d0: 6465 6620 6170 7065 6e64 2873 656c 662c def append(self,\n-000485e0: 2073 6967 6e61 7475 7265 3a20 7374 722c signature: str,\n-000485f0: 202a 6172 6773 3a20 416e 7929 202d 3e20 *args: Any) -> \n-00048600: 4e6f 6e65 3a0a 2020 2020 2020 2020 2222 None:. \"\"\n-00048610: 2241 7070 656e 6420 7a65 726f 206f 7220 \"Append zero or \n-00048620: 6d6f 7265 2061 7267 756d 656e 7473 2074 more arguments t\n-00048630: 6f20 7468 6520 6d65 7373 6167 652e 0a0a o the message...\n-00048640: 2020 2020 2020 2020 3a73 6967 6e61 7475 :signatu\n-00048650: 7265 3a20 636f 6e63 6174 656e 6174 6564 re: concatenated\n-00048660: 2074 7970 6573 7472 696e 6773 2c20 7375 typestrings, su\n-00048670: 6368 2027 617b 7376 7d27 2028 6f6e 6520 ch 'a{sv}' (one \n-00048680: 6172 6729 2c20 6f72 2027 7373 2720 2874 arg), or 'ss' (t\n-00048690: 776f 2061 7267 7329 0a20 2020 2020 2020 wo args). \n-000486a0: 203a 6172 6773 3a20 6f6e 6520 6172 6775 :args: one argu\n-000486b0: 6d65 6e74 2066 6f72 2065 6163 6820 7479 ment for each ty\n-000486c0: 7065 2073 7472 696e 6720 696e 2074 6865 pe string in the\n-000486d0: 2073 6967 6e61 7475 7265 0a20 2020 2020 signature. \n-000486e0: 2020 2022 2222 0a20 2020 2020 2020 2074 \"\"\". t\n-000486f0: 7970 6573 203d 2062 7573 7479 7065 732e ypes = bustypes.\n-00048700: 6672 6f6d 5f73 6967 6e61 7475 7265 2873 from_signature(s\n-00048710: 6967 6e61 7475 7265 290a 2020 2020 2020 ignature). \n-00048720: 2020 6173 7365 7274 206c 656e 2874 7970 assert len(typ\n-00048730: 6573 2920 3d3d 206c 656e 2861 7267 7329 es) == len(args)\n-00048740: 2c20 6627 6361 6c6c 2061 7267 7320 7b61 , f'call args {a\n-00048750: 7267 737d 2068 6176 6520 6469 6666 6572 rgs} have differ\n-00048760: 656e 7420 6c65 6e67 7468 2074 6861 6e20 ent length than \n-00048770: 7369 676e 6174 7572 6520 7b73 6967 6e61 signature {signa\n-00048780: 7475 7265 7d27 0a20 2020 2020 2020 2066 ture}'. f\n-00048790: 6f72 2074 7970 655f 2c20 6172 6720 696e or type_, arg in\n-000487a0: 207a 6970 2874 7970 6573 2c20 6172 6773 zip(types, args\n-000487b0: 293a 0a20 2020 2020 2020 2020 2020 2074 ):. t\n-000487c0: 7970 655f 2e77 7269 7465 7228 7365 6c66 ype_.writer(self\n-000487d0: 2c20 6172 6729 0a0a 2020 2020 6465 6620 , arg).. def \n-000487e0: 6765 745f 626f 6479 2873 656c 6629 202d get_body(self) -\n-000487f0: 3e20 5475 706c 655b 6f62 6a65 6374 2c20 > Tuple[object, \n-00048800: 2e2e 2e5d 3a0a 2020 2020 2020 2020 2222 ...]:. \"\"\n-00048810: 2247 6574 7320 7468 6520 626f 6479 206f \"Gets the body o\n-00048820: 6620 6120 6d65 7373 6167 652e 0a0a 2020 f a message... \n-00048830: 2020 2020 2020 506f 7373 6962 6c65 2072 Possible r\n-00048840: 6574 7572 6e20 7661 6c75 6573 2061 7265 eturn values are\n-00048850: 2028 292c 2028 2773 696e 676c 6527 2c29 (), ('single',)\n-00048860: 2c20 6f72 2028 2778 272c 2027 7927 292e , or ('x', 'y').\n-00048870: 2020 4966 2079 6f75 0a20 2020 2020 2020 If you. \n-00048880: 2063 6865 636b 2074 6865 2073 6967 6e61 check the signa\n-00048890: 7475 7265 206f 6620 7468 6520 6d65 7373 ture of the mess\n-000488a0: 6167 6520 7573 696e 6720 4d65 7373 6167 age using Messag\n-000488b0: 652e 6861 735f 7369 676e 6174 7572 6528 e.has_signature(\n-000488c0: 2920 7468 656e 0a20 2020 2020 2020 2079 ) then. y\n-000488d0: 6f75 2063 616e 2075 7365 2074 7570 6c65 ou can use tuple\n-000488e0: 2075 6e70 6163 6b69 6e67 2e0a 0a20 2020 unpacking... \n-000488f0: 2020 2020 2020 2020 7369 6e67 6c65 2c20 single, \n-00048900: 3d20 6d65 7373 6167 652e 6765 745f 626f = message.get_bo\n-00048910: 6479 2829 0a0a 2020 2020 2020 2020 2020 dy().. \n-00048920: 2078 2c20 7920 3d20 6f74 6865 725f 6d65 x, y = other_me\n-00048930: 7373 6167 652e 6765 745f 626f 6479 2829 ssage.get_body()\n-00048940: 0a0a 2020 2020 2020 2020 3a72 6574 7572 .. :retur\n-00048950: 6e73 3a20 616e 206e 2d74 7570 6c65 2063 ns: an n-tuple c\n-00048960: 6f6e 7461 696e 696e 6720 6f6e 6520 7661 ontaining one va\n-00048970: 6c75 6520 7065 7220 6172 6775 6d65 6e74 lue per argument\n-00048980: 2069 6e20 7468 6520 6d65 7373 6167 650a in the message.\n-00048990: 2020 2020 2020 2020 2222 220a 2020 2020 \"\"\". \n-000489a0: 2020 2020 7365 6c66 2e72 6577 696e 6428 self.rewind(\n-000489b0: 5472 7565 290a 2020 2020 2020 2020 7479 True). ty\n-000489c0: 7065 7320 3d20 6275 7374 7970 6573 2e66 pes = bustypes.f\n-000489d0: 726f 6d5f 7369 676e 6174 7572 6528 7365 rom_signature(se\n-000489e0: 6c66 2e67 6574 5f73 6967 6e61 7475 7265 lf.get_signature\n-000489f0: 2854 7275 6529 290a 2020 2020 2020 2020 (True)). \n-00048a00: 7265 7475 726e 2074 7570 6c65 2874 7970 return tuple(typ\n-00048a10: 655f 2e72 6561 6465 7228 7365 6c66 2920 e_.reader(self) \n-00048a20: 666f 7220 7479 7065 5f20 696e 2074 7970 for type_ in typ\n-00048a30: 6573 290a 0a20 2020 2064 6566 2073 656e es).. def sen\n-00048a40: 6428 7365 6c66 2920 2d3e 2062 6f6f 6c3a d(self) -> bool:\n-00048a50: 2020 2320 4c69 7465 7261 6c5b 5472 7565 # Literal[True\n-00048a60: 5d0a 2020 2020 2020 2020 2222 2253 656e ]. \"\"\"Sen\n-00048a70: 6473 2061 206d 6573 7361 6765 206f 6e20 ds a message on \n-00048a80: 7468 6520 6275 7320 7468 6174 2069 7420 the bus that it \n-00048a90: 7761 7320 6372 6561 7465 6420 666f 722e was created for.\n-00048aa0: 0a0a 2020 2020 2020 2020 3a72 6574 7572 .. :retur\n-00048ab0: 6e73 3a20 5472 7565 0a20 2020 2020 2020 ns: True. \n-00048ac0: 2022 2222 0a20 2020 2020 2020 2073 656c \"\"\". sel\n-00048ad0: 662e 6765 745f 6275 7328 292e 7365 6e64 f.get_bus().send\n-00048ae0: 2873 656c 662c 204e 6f6e 6529 0a20 2020 (self, None). \n-00048af0: 2020 2020 2072 6574 7572 6e20 5472 7565 return True\n-00048b00: 0a0a 2020 2020 6465 6620 7265 706c 795f .. def reply_\n-00048b10: 6d65 7468 6f64 5f65 7272 6f72 2873 656c method_error(sel\n-00048b20: 662c 2065 7272 6f72 3a20 556e 696f 6e5b f, error: Union[\n-00048b30: 4275 7345 7272 6f72 2c20 4f53 4572 726f BusError, OSErro\n-00048b40: 725d 2920 2d3e 2062 6f6f 6c3a 2020 2320 r]) -> bool: # \n-00048b50: 4c69 7465 7261 6c5b 5472 7565 5d0a 2020 Literal[True]. \n-00048b60: 2020 2020 2020 2222 2253 656e 6473 2061 \"\"\"Sends a\n-00048b70: 6e20 6572 726f 7220 6173 2061 2072 6570 n error as a rep\n-00048b80: 6c79 2074 6f20 6120 6d65 7468 6f64 2063 ly to a method c\n-00048b90: 616c 6c20 6d65 7373 6167 652e 0a0a 2020 all message... \n-00048ba0: 2020 2020 2020 3a65 7272 6f72 3a20 4120 :error: A \n-00048bb0: 4275 7345 7272 6f72 206f 7220 4f53 4572 BusError or OSEr\n-00048bc0: 726f 720a 0a20 2020 2020 2020 203a 7265 ror.. :re\n-00048bd0: 7475 726e 733a 2054 7275 650a 2020 2020 turns: True. \n-00048be0: 2020 2020 2222 220a 2020 2020 2020 2020 \"\"\". \n-00048bf0: 7265 7475 726e 2073 656c 662e 6e65 775f return self.new_\n-00048c00: 6d65 7468 6f64 5f65 7272 6f72 2865 7272 method_error(err\n-00048c10: 6f72 292e 7365 6e64 2829 0a0a 2020 2020 or).send().. \n-00048c20: 6465 6620 7265 706c 795f 6d65 7468 6f64 def reply_method\n-00048c30: 5f72 6574 7572 6e28 7365 6c66 2c20 7369 _return(self, si\n-00048c40: 676e 6174 7572 653a 2073 7472 203d 2027 gnature: str = '\n-00048c50: 272c 202a 6172 6773 3a20 416e 7929 202d ', *args: Any) -\n-00048c60: 3e20 626f 6f6c 3a20 2023 204c 6974 6572 > bool: # Liter\n-00048c70: 616c 5b54 7275 655d 0a20 2020 2020 2020 al[True]. \n-00048c80: 2022 2222 5365 6e64 7320 6120 7265 7475 \"\"\"Sends a retu\n-00048c90: 726e 2076 616c 7565 2061 7320 6120 7265 rn value as a re\n-00048ca0: 706c 7920 746f 2061 206d 6574 686f 6420 ply to a method \n-00048cb0: 6361 6c6c 206d 6573 7361 6765 2e0a 0a20 call message... \n-00048cc0: 2020 2020 2020 203a 7369 676e 6174 7572 :signatur\n-00048cd0: 653a 2054 6865 2073 6967 6e61 7475 7265 e: The signature\n-00048ce0: 206f 6620 7468 6520 7265 7375 6c74 2c20 of the result, \n-00048cf0: 6173 2061 2073 7472 696e 672e 0a20 2020 as a string.. \n-00048d00: 2020 2020 203a 6172 6773 3a20 5468 6520 :args: The \n-00048d10: 7661 6c75 6573 2074 6f20 7365 6e64 2c20 values to send, \n-00048d20: 636f 6e66 6f72 6d69 6e67 2074 6f20 7468 conforming to th\n-00048d30: 6520 7369 676e 6174 7572 6520 7374 7269 e signature stri\n-00048d40: 6e67 2e0a 0a20 2020 2020 2020 203a 7265 ng... :re\n-00048d50: 7475 726e 733a 2054 7275 650a 2020 2020 turns: True. \n-00048d60: 2020 2020 2222 220a 2020 2020 2020 2020 \"\"\". \n-00048d70: 7265 7475 726e 2073 656c 662e 6e65 775f return self.new_\n-00048d80: 6d65 7468 6f64 5f72 6574 7572 6e28 7369 method_return(si\n-00048d90: 676e 6174 7572 652c 202a 6172 6773 292e gnature, *args).\n-00048da0: 7365 6e64 2829 0a0a 2020 2020 6465 6620 send().. def \n-00048db0: 5f63 6f72 6f75 7469 6e65 5f74 6173 6b5f _coroutine_task_\n-00048dc0: 636f 6d70 6c65 7465 2873 656c 662c 206f complete(self, o\n-00048dd0: 7574 5f74 7970 653a 2062 7573 7479 7065 ut_type: bustype\n-00048de0: 732e 4d65 7373 6167 6554 7970 652c 2074 s.MessageType, t\n-00048df0: 6173 6b3a 2061 7379 6e63 696f 2e54 6173 ask: asyncio.Tas\n-00048e00: 6b29 202d 3e20 4e6f 6e65 3a0a 2020 2020 k) -> None:. \n-00048e10: 2020 2020 7472 793a 0a20 2020 2020 2020 try:. \n-00048e20: 2020 2020 2073 656c 662e 7265 706c 795f self.reply_\n-00048e30: 6d65 7468 6f64 5f66 756e 6374 696f 6e5f method_function_\n-00048e40: 7265 7475 726e 5f76 616c 7565 286f 7574 return_value(out\n-00048e50: 5f74 7970 652c 2074 6173 6b2e 7265 7375 _type, task.resu\n-00048e60: 6c74 2829 290a 2020 2020 2020 2020 6578 lt()). ex\n-00048e70: 6365 7074 2028 4275 7345 7272 6f72 2c20 cept (BusError, \n-00048e80: 4f53 4572 726f 7229 2061 7320 6578 633a OSError) as exc:\n-00048e90: 0a20 2020 2020 2020 2020 2020 2073 656c . sel\n-00048ea0: 662e 7265 706c 795f 6d65 7468 6f64 5f65 f.reply_method_e\n-00048eb0: 7272 6f72 2865 7863 290a 0a20 2020 2064 rror(exc).. d\n-00048ec0: 6566 2072 6570 6c79 5f6d 6574 686f 645f ef reply_method_\n-00048ed0: 6675 6e63 7469 6f6e 5f72 6574 7572 6e5f function_return_\n-00048ee0: 7661 6c75 6528 7365 6c66 2c0a 2020 2020 value(self,. \n-00048ef0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00048f00: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00048f10: 2020 2020 2020 206f 7574 5f74 7970 653a out_type:\n-00048f20: 2062 7573 7479 7065 732e 4d65 7373 6167 bustypes.Messag\n-00048f30: 6554 7970 652c 0a20 2020 2020 2020 2020 eType,. \n-00048f40: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00048f50: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00048f60: 2020 7265 7475 726e 5f76 616c 7565 3a20 return_value: \n-00048f70: 416e 7929 202d 3e20 626f 6f6c 3a20 2023 Any) -> bool: #\n-00048f80: 204c 6974 6572 616c 5b54 7275 655d 3a0a Literal[True]:.\n-00048f90: 2020 2020 2020 2020 2222 2253 656e 6473 \"\"\"Sends\n-00048fa0: 2074 6865 2072 6573 756c 7420 6f66 2061 the result of a\n-00048fb0: 2066 756e 6374 696f 6e20 6361 6c6c 2061 function call a\n-00048fc0: 7320 6120 7265 706c 7920 746f 2061 206d s a reply to a m\n-00048fd0: 6574 686f 6420 6361 6c6c 206d 6573 7361 ethod call messa\n-00048fe0: 6765 2e0a 0a20 2020 2020 2020 2054 6869 ge... Thi\n-00048ff0: 7320 6361 6c6c 2064 6f65 7320 6120 6269 s call does a bi\n-00049000: 7420 6f66 206d 6167 6963 3a20 6974 2061 t of magic: it a\n-00049010: 6461 7074 7320 6672 6f6d 2074 6865 2075 dapts from the u\n-00049020: 7375 616c 2050 7974 686f 6e20 7265 7475 sual Python retu\n-00049030: 726e 0a20 2020 2020 2020 2076 616c 7565 rn. value\n-00049040: 2063 6f6e 7665 6e74 696f 6e73 2028 7768 conventions (wh\n-00049050: 6572 6520 7468 6520 7265 7475 726e 2076 ere the return v\n-00049060: 616c 7565 2069 7320 6060 4e6f 6e65 6060 alue is ``None``\n-00049070: 2c20 6120 7369 6e67 6c65 2076 616c 7565 , a single value\n-00049080: 2c0a 2020 2020 2020 2020 6f72 2061 2074 ,. or a t\n-00049090: 7570 6c65 2920 746f 2074 6865 206e 6f72 uple) to the nor\n-000490a0: 6d61 6c20 442d 4275 7320 7265 7475 726e mal D-Bus return\n-000490b0: 2076 616c 7565 2063 6f6e 7665 6e74 696f value conventio\n-000490c0: 6e73 2028 7768 6572 6520 7468 650a 2020 ns (where the. \n-000490d0: 2020 2020 2020 7265 7375 6c74 2069 7320 result is \n-000490e0: 616c 7761 7973 2061 2074 7570 6c65 292e always a tuple).\n-000490f0: 0a0a 2020 2020 2020 2020 4164 6469 7469 .. Additi\n-00049100: 6f6e 616c 6c79 2c20 6966 2074 6865 2076 onally, if the v\n-00049110: 616c 7565 2069 7320 666f 756e 6420 746f alue is found to\n-00049120: 2062 6520 6120 636f 726f 7574 696e 652c be a coroutine,\n-00049130: 2061 2074 6173 6b20 6973 0a20 2020 2020 a task is. \n-00049140: 2020 2063 7265 6174 6564 2074 6f20 7275 created to ru\n-00049150: 6e20 7468 6520 636f 726f 7574 696e 6520 n the coroutine \n-00049160: 746f 2063 6f6d 706c 6574 696f 6e20 616e to completion an\n-00049170: 6420 7265 7475 726e 2074 6865 2072 6573 d return the res\n-00049180: 756c 740a 2020 2020 2020 2020 2869 6e63 ult. (inc\n-00049190: 6c75 6469 6e67 2065 7863 6570 7469 6f6e luding exception\n-000491a0: 2068 616e 646c 696e 6729 2e0a 0a20 2020 handling)... \n-000491b0: 2020 2020 203a 6f75 745f 7479 7065 733a :out_types:\n-000491c0: 2054 6865 2074 7970 6573 206f 6620 7468 The types of th\n-000491d0: 6520 7265 7475 726e 2076 616c 7565 732c e return values,\n-000491e0: 2061 7320 616e 2069 7465 7261 626c 652e as an iterable.\n-000491f0: 0a20 2020 2020 2020 203a 7265 7475 726e . :return\n-00049200: 5f76 616c 7565 3a20 5468 6520 7265 7475 _value: The retu\n-00049210: 726e 2076 616c 7565 206f 6620 6120 5079 rn value of a Py\n-00049220: 7468 6f6e 2066 756e 6374 696f 6e20 6361 thon function ca\n-00049230: 6c6c 2e0a 0a20 2020 2020 2020 203a 7265 ll... :re\n-00049240: 7475 726e 733a 2054 7275 650a 2020 2020 turns: True. \n-00049250: 2020 2020 2222 220a 2020 2020 2020 2020 \"\"\". \n-00049260: 6966 2061 7379 6e63 696f 2e63 6f72 6f75 if asyncio.corou\n-00049270: 7469 6e65 732e 6973 636f 726f 7574 696e tines.iscoroutin\n-00049280: 6528 7265 7475 726e 5f76 616c 7565 293a e(return_value):\n-00049290: 0a20 2020 2020 2020 2020 2020 2074 6173 . tas\n-000492a0: 6b20 3d20 6173 796e 6369 6f2e 6372 6561 k = asyncio.crea\n-000492b0: 7465 5f74 6173 6b28 7265 7475 726e 5f76 te_task(return_v\n-000492c0: 616c 7565 290a 2020 2020 2020 2020 2020 alue). \n-000492d0: 2020 7461 736b 2e61 6464 5f64 6f6e 655f task.add_done_\n-000492e0: 6361 6c6c 6261 636b 286c 616d 6264 6120 callback(lambda \n-000492f0: 7461 736b 3a20 7365 6c66 2e5f 636f 726f task: self._coro\n-00049300: 7574 696e 655f 7461 736b 5f63 6f6d 706c utine_task_compl\n-00049310: 6574 6528 6f75 745f 7479 7065 2c20 7461 ete(out_type, ta\n-00049320: 736b 2929 0a20 2020 2020 2020 2020 2020 sk)). \n-00049330: 2072 6574 7572 6e20 5472 7565 0a0a 2020 return True.. \n-00049340: 2020 2020 2020 7265 706c 7920 3d20 7365 reply = se\n-00049350: 6c66 2e6e 6577 5f6d 6574 686f 645f 7265 lf.new_method_re\n-00049360: 7475 726e 2829 0a20 2020 2020 2020 2023 turn(). #\n-00049370: 2049 6e20 7468 6520 6765 6e65 7261 6c20 In the general \n-00049380: 6361 7365 2c20 6120 6675 6e63 7469 6f6e case, a function\n-00049390: 2072 6574 7572 6e73 2061 6e20 6e2d 7475 returns an n-tu\n-000493a0: 706c 652c 2062 7574 2e2e 2e0a 2020 2020 ple, but.... \n-000493b0: 2020 2020 6966 206c 656e 286f 7574 5f74 if len(out_t\n-000493c0: 7970 6529 203d 3d20 303a 0a20 2020 2020 ype) == 0:. \n-000493d0: 2020 2020 2020 2023 2046 756e 6374 696f # Functio\n-000493e0: 6e73 2077 6974 6820 6e6f 2072 6574 7572 ns with no retur\n-000493f0: 6e20 7661 6c75 6520 7265 7475 726e 204e n value return N\n-00049400: 6f6e 652e 0a20 2020 2020 2020 2020 2020 one.. \n-00049410: 2061 7373 6572 7420 7265 7475 726e 5f76 assert return_v\n-00049420: 616c 7565 2069 7320 4e6f 6e65 0a20 2020 alue is None. \n-00049430: 2020 2020 2065 6c69 6620 6c65 6e28 6f75 elif len(ou\n-00049440: 745f 7479 7065 2920 3d3d 2031 3a0a 2020 t_type) == 1:. \n-00049450: 2020 2020 2020 2020 2020 2320 4675 6e63 # Func\n-00049460: 7469 6f6e 7320 7769 7468 2061 2073 696e tions with a sin\n-00049470: 676c 6520 7265 7475 726e 2076 616c 7565 gle return value\n-00049480: 2072 6574 7572 6e20 7468 6174 2076 616c return that val\n-00049490: 7565 2e0a 2020 2020 2020 2020 2020 2020 ue.. \n-000494a0: 6f75 745f 7479 7065 2e77 7269 7465 2872 out_type.write(r\n-000494b0: 6570 6c79 2c20 7265 7475 726e 5f76 616c eply, return_val\n-000494c0: 7565 290a 2020 2020 2020 2020 656c 7365 ue). else\n-000494d0: 3a0a 2020 2020 2020 2020 2020 2020 2320 :. # \n-000494e0: 2867 656e 6572 616c 2063 6173 6529 206e (general case) n\n-000494f0: 2072 6574 7572 6e20 7661 6c75 6573 2061 return values a\n-00049500: 7265 2068 616e 646c 6564 2061 7320 616e re handled as an\n-00049510: 206e 2d74 7570 6c65 2e0a 2020 2020 2020 n-tuple.. \n-00049520: 2020 2020 2020 6173 7365 7274 206c 656e assert len\n-00049530: 286f 7574 5f74 7970 6529 203d 3d20 6c65 (out_type) == le\n-00049540: 6e28 7265 7475 726e 5f76 616c 7565 290a n(return_value).\n-00049550: 2020 2020 2020 2020 2020 2020 6f75 745f out_\n-00049560: 7479 7065 2e77 7269 7465 2872 6570 6c79 type.write(reply\n-00049570: 2c20 2a72 6574 7572 6e5f 7661 6c75 6529 , *return_value)\n-00049580: 0a20 2020 2020 2020 2072 6574 7572 6e20 . return \n-00049590: 7265 706c 792e 7365 6e64 2829 0a0a 0a63 reply.send()...c\n-000495a0: 6c61 7373 2053 6c6f 7428 6c69 6273 7973 lass Slot(libsys\n-000495b0: 7465 6d64 2e73 645f 6275 735f 736c 6f74 temd.sd_bus_slot\n-000495c0: 293a 0a20 2020 2064 6566 205f 5f69 6e69 ):. def __ini\n-000495d0: 745f 5f28 7365 6c66 2c20 6361 6c6c 6261 t__(self, callba\n-000495e0: 636b 3a20 4361 6c6c 6162 6c65 5b5b 4275 ck: Callable[[Bu\n-000495f0: 734d 6573 7361 6765 5d2c 2062 6f6f 6c5d sMessage], bool]\n-00049600: 293a 0a20 2020 2020 2020 2064 6566 2068 ):. def h\n-00049610: 616e 646c 6572 286d 6573 7361 6765 3a20 andler(message: \n-00049620: 5765 616b 5265 6665 7265 6e63 652c 205f WeakReference, _\n-00049630: 6461 7461 3a20 6f62 6a65 6374 2c20 5f65 data: object, _e\n-00049640: 7272 3a20 6f62 6a65 6374 2920 2d3e 2069 rr: object) -> i\n-00049650: 6e74 3a0a 2020 2020 2020 2020 2020 2020 nt:. \n-00049660: 7265 7475 726e 2031 2069 6620 6361 6c6c return 1 if call\n-00049670: 6261 636b 2842 7573 4d65 7373 6167 652e back(BusMessage.\n-00049680: 7265 6628 6d65 7373 6167 6529 2920 656c ref(message)) el\n-00049690: 7365 2030 0a20 2020 2020 2020 2073 656c se 0. sel\n-000496a0: 662e 7472 616d 706f 6c69 6e65 203d 206c f.trampoline = l\n-000496b0: 6962 7379 7374 656d 642e 7364 5f62 7573 ibsystemd.sd_bus\n-000496c0: 5f6d 6573 7361 6765 5f68 616e 646c 6572 _message_handler\n-000496d0: 5f74 2868 616e 646c 6572 290a 0a0a 6966 _t(handler)...if\n-000496e0: 2074 7970 696e 672e 5459 5045 5f43 4845 typing.TYPE_CHE\n-000496f0: 434b 494e 473a 0a20 2020 2046 7574 7572 CKING:. Futur\n-00049700: 654d 6573 7361 6765 203d 2061 7379 6e63 eMessage = async\n-00049710: 696f 2e46 7574 7572 655b 4275 734d 6573 io.Future[BusMes\n-00049720: 7361 6765 5d0a 656c 7365 3a0a 2020 2020 sage].else:. \n-00049730: 2320 5079 7468 6f6e 2033 2e36 2063 616e # Python 3.6 can\n-00049740: 2774 2073 7562 7363 7269 7074 2061 7379 't subscript asy\n-00049750: 6e63 696f 2e46 7574 7572 650a 2020 2020 ncio.Future. \n-00049760: 4675 7475 7265 4d65 7373 6167 6520 3d20 FutureMessage = \n-00049770: 6173 796e 6369 6f2e 4675 7475 7265 0a0a asyncio.Future..\n-00049780: 0a63 6c61 7373 2050 656e 6469 6e67 4361 .class PendingCa\n-00049790: 6c6c 2853 6c6f 7429 3a0a 2020 2020 6675 ll(Slot):. fu\n-000497a0: 7475 7265 3a20 4675 7475 7265 4d65 7373 ture: FutureMess\n-000497b0: 6167 650a 0a20 2020 2064 6566 205f 5f69 age.. def __i\n-000497c0: 6e69 745f 5f28 7365 6c66 2920 2d3e 204e nit__(self) -> N\n-000497d0: 6f6e 653a 0a20 2020 2020 2020 2066 7574 one:. fut\n-000497e0: 7572 6520 3d20 6173 796e 6369 6f2e 6765 ure = asyncio.ge\n-000497f0: 745f 7275 6e6e 696e 675f 6c6f 6f70 2829 t_running_loop()\n-00049800: 2e63 7265 6174 655f 6675 7475 7265 2829 .create_future()\n-00049810: 0a0a 2020 2020 2020 2020 6465 6620 646f .. def do\n-00049820: 6e65 286d 6573 7361 6765 3a20 4275 734d ne(message: BusM\n-00049830: 6573 7361 6765 2920 2d3e 2062 6f6f 6c3a essage) -> bool:\n-00049840: 0a20 2020 2020 2020 2020 2020 2065 7272 . err\n-00049850: 6f72 203d 206d 6573 7361 6765 2e67 6574 or = message.get\n-00049860: 5f65 7272 6f72 2829 0a20 2020 2020 2020 _error(). \n-00049870: 2020 2020 2069 6620 6675 7475 7265 2e63 if future.c\n-00049880: 616e 6365 6c6c 6564 2829 3a0a 2020 2020 ancelled():. \n-00049890: 2020 2020 2020 2020 2020 2020 7265 7475 retu\n-000498a0: 726e 2054 7275 650a 2020 2020 2020 2020 rn True. \n-000498b0: 2020 2020 6966 2065 7272 6f72 2069 7320 if error is \n-000498c0: 6e6f 7420 4e6f 6e65 3a0a 2020 2020 2020 not None:. \n-000498d0: 2020 2020 2020 2020 2020 6675 7475 7265 future\n-000498e0: 2e73 6574 5f65 7863 6570 7469 6f6e 2865 .set_exception(e\n-000498f0: 7272 6f72 290a 2020 2020 2020 2020 2020 rror). \n-00049900: 2020 656c 7365 3a0a 2020 2020 2020 2020 else:. \n-00049910: 2020 2020 2020 2020 6675 7475 7265 2e73 future.s\n-00049920: 6574 5f72 6573 756c 7428 6d65 7373 6167 et_result(messag\n-00049930: 6529 0a20 2020 2020 2020 2020 2020 2072 e). r\n-00049940: 6574 7572 6e20 5472 7565 0a0a 2020 2020 eturn True.. \n-00049950: 2020 2020 7375 7065 7228 292e 5f5f 696e super().__in\n-00049960: 6974 5f5f 2864 6f6e 6529 0a20 2020 2020 it__(done). \n-00049970: 2020 2073 656c 662e 6675 7475 7265 203d self.future =\n-00049980: 2066 7574 7572 650a 0a0a 636c 6173 7320 future...class \n-00049990: 4275 7328 6c69 6273 7973 7465 6d64 2e73 Bus(libsystemd.s\n-000499a0: 645f 6275 7329 3a0a 2020 2020 5f64 6566 d_bus):. _def\n-000499b0: 6175 6c74 5f73 7973 7465 6d5f 696e 7374 ault_system_inst\n-000499c0: 616e 6365 203d 204e 6f6e 650a 2020 2020 ance = None. \n-000499d0: 5f64 6566 6175 6c74 5f75 7365 725f 696e _default_user_in\n-000499e0: 7374 616e 6365 203d 204e 6f6e 650a 0a20 stance = None.. \n-000499f0: 2020 2063 6c61 7373 204e 616d 6546 6c61 class NameFla\n-00049a00: 6773 2865 6e75 6d2e 496e 7446 6c61 6729 gs(enum.IntFlag)\n-00049a10: 3a0a 2020 2020 2020 2020 4445 4641 554c :. DEFAUL\n-00049a20: 5420 3d20 300a 2020 2020 2020 2020 5245 T = 0. RE\n-00049a30: 504c 4143 455f 4558 4953 5449 4e47 203d PLACE_EXISTING =\n-00049a40: 2031 203c 3c20 300a 2020 2020 2020 2020 1 << 0. \n-00049a50: 414c 4c4f 575f 5245 504c 4143 454d 454e ALLOW_REPLACEMEN\n-00049a60: 5420 3d20 3120 3c3c 2031 0a20 2020 2020 T = 1 << 1. \n-00049a70: 2020 2051 5545 5545 203d 2031 203c 3c20 QUEUE = 1 << \n-00049a80: 320a 0a20 2020 2040 7374 6174 6963 6d65 2.. @staticme\n-00049a90: 7468 6f64 0a20 2020 2064 6566 206e 6577 thod. def new\n-00049aa0: 280a 2020 2020 2020 2020 2020 2020 6664 (. fd\n-00049ab0: 3a20 4f70 7469 6f6e 616c 5b69 6e74 5d20 : Optional[int] \n-00049ac0: 3d20 4e6f 6e65 2c0a 2020 2020 2020 2020 = None,. \n-00049ad0: 2020 2020 6164 6472 6573 733a 204f 7074 address: Opt\n-00049ae0: 696f 6e61 6c5b 7374 725d 203d 204e 6f6e ional[str] = Non\n-00049af0: 652c 0a20 2020 2020 2020 2020 2020 2062 e,. b\n-00049b00: 7573 5f63 6c69 656e 743a 2062 6f6f 6c20 us_client: bool \n-00049b10: 3d20 4661 6c73 652c 0a20 2020 2020 2020 = False,. \n-00049b20: 2020 2020 2073 6572 7665 723a 2062 6f6f server: boo\n-00049b30: 6c20 3d20 4661 6c73 652c 0a20 2020 2020 l = False,. \n-00049b40: 2020 2020 2020 2073 7461 7274 3a20 626f start: bo\n-00049b50: 6f6c 203d 2054 7275 652c 0a20 2020 2020 ol = True,. \n-00049b60: 2020 2020 2020 2061 7474 6163 685f 6576 attach_ev\n-00049b70: 656e 743a 2062 6f6f 6c20 3d20 5472 7565 ent: bool = True\n-00049b80: 0a20 2020 2029 202d 3e20 2742 7573 273a . ) -> 'Bus':\n-00049b90: 0a20 2020 2020 2020 2062 7573 203d 2042 . bus = B\n-00049ba0: 7573 2829 0a20 2020 2020 2020 2042 7573 us(). Bus\n-00049bb0: 2e5f 6e65 7728 6279 7265 6628 6275 7329 ._new(byref(bus)\n-00049bc0: 290a 2020 2020 2020 2020 6966 2061 6464 ). if add\n-00049bd0: 7265 7373 2069 7320 6e6f 7420 4e6f 6e65 ress is not None\n-00049be0: 3a0a 2020 2020 2020 2020 2020 2020 6275 :. bu\n-00049bf0: 732e 7365 745f 6164 6472 6573 7328 6164 s.set_address(ad\n-00049c00: 6472 6573 7329 0a20 2020 2020 2020 2069 dress). i\n-00049c10: 6620 6664 2069 7320 6e6f 7420 4e6f 6e65 f fd is not None\n-00049c20: 3a0a 2020 2020 2020 2020 2020 2020 6275 :. bu\n-00049c30: 732e 7365 745f 6664 2866 642c 2066 6429 s.set_fd(fd, fd)\n-00049c40: 0a20 2020 2020 2020 2069 6620 6275 735f . if bus_\n-00049c50: 636c 6965 6e74 3a0a 2020 2020 2020 2020 client:. \n-00049c60: 2020 2020 6275 732e 7365 745f 6275 735f bus.set_bus_\n-00049c70: 636c 6965 6e74 2854 7275 6529 0a20 2020 client(True). \n-00049c80: 2020 2020 2069 6620 7365 7276 6572 3a0a if server:.\n-00049c90: 2020 2020 2020 2020 2020 2020 6275 732e bus.\n-00049ca0: 7365 745f 7365 7276 6572 2854 7275 652c set_server(True,\n-00049cb0: 206c 6962 7379 7374 656d 642e 7364 5f69 libsystemd.sd_i\n-00049cc0: 6431 3238 2829 290a 2020 2020 2020 2020 d128()). \n-00049cd0: 6966 2061 6464 7265 7373 2069 7320 6e6f if address is no\n-00049ce0: 7420 4e6f 6e65 206f 7220 6664 2069 7320 t None or fd is \n-00049cf0: 6e6f 7420 4e6f 6e65 3a0a 2020 2020 2020 not None:. \n-00049d00: 2020 2020 2020 6966 2073 7461 7274 3a0a if start:.\n-00049d10: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00049d20: 6275 732e 7374 6172 7428 290a 2020 2020 bus.start(). \n-00049d30: 2020 2020 2020 2020 6966 2061 7474 6163 if attac\n-00049d40: 685f 6576 656e 743a 0a20 2020 2020 2020 h_event:. \n-00049d50: 2020 2020 2020 2020 2062 7573 2e61 7474 bus.att\n-00049d60: 6163 685f 6576 656e 7428 4e6f 6e65 2c20 ach_event(None, \n-00049d70: 3029 0a20 2020 2020 2020 2072 6574 7572 0). retur\n-00049d80: 6e20 6275 730a 0a20 2020 2040 7374 6174 n bus.. @stat\n-00049d90: 6963 6d65 7468 6f64 0a20 2020 2064 6566 icmethod. def\n-00049da0: 2064 6566 6175 6c74 5f73 7973 7465 6d28 default_system(\n-00049db0: 6174 7461 6368 5f65 7665 6e74 3a20 626f attach_event: bo\n-00049dc0: 6f6c 203d 2054 7275 6529 202d 3e20 2742 ol = True) -> 'B\n-00049dd0: 7573 273a 0a20 2020 2020 2020 2069 6620 us':. if \n-00049de0: 4275 732e 5f64 6566 6175 6c74 5f73 7973 Bus._default_sys\n-00049df0: 7465 6d5f 696e 7374 616e 6365 2069 7320 tem_instance is \n-00049e00: 4e6f 6e65 3a0a 2020 2020 2020 2020 2020 None:. \n-00049e10: 2020 4275 732e 5f64 6566 6175 6c74 5f73 Bus._default_s\n-00049e20: 7973 7465 6d5f 696e 7374 616e 6365 203d ystem_instance =\n-00049e30: 2042 7573 2829 0a20 2020 2020 2020 2020 Bus(). \n-00049e40: 2020 2042 7573 2e5f 6465 6661 756c 745f Bus._default_\n-00049e50: 7379 7374 656d 2862 7972 6566 2842 7573 system(byref(Bus\n-00049e60: 2e5f 6465 6661 756c 745f 7379 7374 656d ._default_system\n-00049e70: 5f69 6e73 7461 6e63 6529 290a 2020 2020 _instance)). \n-00049e80: 2020 2020 2020 2020 6966 2061 7474 6163 if attac\n-00049e90: 685f 6576 656e 743a 0a20 2020 2020 2020 h_event:. \n-00049ea0: 2020 2020 2020 2020 2042 7573 2e5f 6465 Bus._de\n-00049eb0: 6661 756c 745f 7379 7374 656d 5f69 6e73 fault_system_ins\n-00049ec0: 7461 6e63 652e 6174 7461 6368 5f65 7665 tance.attach_eve\n-00049ed0: 6e74 284e 6f6e 652c 2030 290a 2020 2020 nt(None, 0). \n-00049ee0: 2020 2020 7265 7475 726e 2042 7573 2e5f return Bus._\n-00049ef0: 6465 6661 756c 745f 7379 7374 656d 5f69 default_system_i\n-00049f00: 6e73 7461 6e63 650a 0a20 2020 2040 7374 nstance.. @st\n-00049f10: 6174 6963 6d65 7468 6f64 0a20 2020 2064 aticmethod. d\n-00049f20: 6566 2064 6566 6175 6c74 5f75 7365 7228 ef default_user(\n-00049f30: 6174 7461 6368 5f65 7665 6e74 3a20 626f attach_event: bo\n-00049f40: 6f6c 203d 2054 7275 6529 202d 3e20 2742 ol = True) -> 'B\n-00049f50: 7573 273a 0a20 2020 2020 2020 2069 6620 us':. if \n-00049f60: 4275 732e 5f64 6566 6175 6c74 5f75 7365 Bus._default_use\n-00049f70: 725f 696e 7374 616e 6365 2069 7320 4e6f r_instance is No\n-00049f80: 6e65 3a0a 2020 2020 2020 2020 2020 2020 ne:. \n-00049f90: 4275 732e 5f64 6566 6175 6c74 5f75 7365 Bus._default_use\n-00049fa0: 725f 696e 7374 616e 6365 203d 2042 7573 r_instance = Bus\n-00049fb0: 2829 0a20 2020 2020 2020 2020 2020 2042 (). B\n-00049fc0: 7573 2e5f 6465 6661 756c 745f 7573 6572 us._default_user\n-00049fd0: 2862 7972 6566 2842 7573 2e5f 6465 6661 (byref(Bus._defa\n-00049fe0: 756c 745f 7573 6572 5f69 6e73 7461 6e63 ult_user_instanc\n-00049ff0: 6529 290a 2020 2020 2020 2020 2020 2020 e)). \n-0004a000: 6966 2061 7474 6163 685f 6576 656e 743a if attach_event:\n-0004a010: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-0004a020: 2042 7573 2e5f 6465 6661 756c 745f 7573 Bus._default_us\n-0004a030: 6572 5f69 6e73 7461 6e63 652e 6174 7461 er_instance.atta\n-0004a040: 6368 5f65 7665 6e74 284e 6f6e 652c 2030 ch_event(None, 0\n-0004a050: 290a 2020 2020 2020 2020 7265 7475 726e ). return\n-0004a060: 2042 7573 2e5f 6465 6661 756c 745f 7573 Bus._default_us\n-0004a070: 6572 5f69 6e73 7461 6e63 650a 0a20 2020 er_instance.. \n-0004a080: 2064 6566 206d 6573 7361 6765 5f6e 6577 def message_new\n-0004a090: 5f6d 6574 686f 645f 6361 6c6c 280a 2020 _method_call(. \n-0004a0a0: 2020 2020 2020 2020 2020 7365 6c66 2c0a self,.\n-0004a0b0: 2020 2020 2020 2020 2020 2020 6465 7374 dest\n-0004a0c0: 696e 6174 696f 6e3a 204f 7074 696f 6e61 ination: Optiona\n-0004a0d0: 6c5b 7374 725d 2c0a 2020 2020 2020 2020 l[str],. \n-0004a0e0: 2020 2020 7061 7468 3a20 7374 722c 0a20 path: str,. \n-0004a0f0: 2020 2020 2020 2020 2020 2069 6e74 6572 inter\n-0004a100: 6661 6365 3a20 7374 722c 0a20 2020 2020 face: str,. \n-0004a110: 2020 2020 2020 206d 656d 6265 723a 2073 member: s\n-0004a120: 7472 2c0a 2020 2020 2020 2020 2020 2020 tr,. \n-0004a130: 7479 7065 733a 2073 7472 203d 2027 272c types: str = '',\n-0004a140: 0a20 2020 2020 2020 2020 2020 202a 6172 . *ar\n-0004a150: 6773 3a20 6f62 6a65 6374 0a20 2020 2029 gs: object. )\n-0004a160: 202d 3e20 4275 734d 6573 7361 6765 3a0a -> BusMessage:.\n-0004a170: 2020 2020 2020 2020 6d65 7373 6167 6520 message \n-0004a180: 3d20 4275 734d 6573 7361 6765 2829 0a20 = BusMessage(). \n-0004a190: 2020 2020 2020 2073 656c 662e 5f6d 6573 self._mes\n-0004a1a0: 7361 6765 5f6e 6577 5f6d 6574 686f 645f sage_new_method_\n-0004a1b0: 6361 6c6c 2862 7972 6566 286d 6573 7361 call(byref(messa\n-0004a1c0: 6765 292c 2064 6573 7469 6e61 7469 6f6e ge), destination\n-0004a1d0: 2c20 7061 7468 2c20 696e 7465 7266 6163 , path, interfac\n-0004a1e0: 652c 206d 656d 6265 7229 0a20 2020 2020 e, member). \n-0004a1f0: 2020 206d 6573 7361 6765 2e61 7070 656e message.appen\n-0004a200: 6428 7479 7065 732c 202a 6172 6773 290a d(types, *args).\n-0004a210: 2020 2020 2020 2020 7265 7475 726e 206d return m\n-0004a220: 6573 7361 6765 0a0a 2020 2020 6465 6620 essage.. def \n-0004a230: 6d65 7373 6167 655f 6e65 775f 7369 676e message_new_sign\n-0004a240: 616c 280a 2020 2020 2020 2020 7365 6c66 al(. self\n-0004a250: 2c20 7061 7468 3a20 7374 722c 2069 6e74 , path: str, int\n-0004a260: 6572 6661 6365 3a20 7374 722c 206d 656d erface: str, mem\n-0004a270: 6265 723a 2073 7472 2c20 7479 7065 733a ber: str, types:\n-0004a280: 2073 7472 203d 2027 272c 202a 6172 6773 str = '', *args\n-0004a290: 3a20 6f62 6a65 6374 0a20 2020 2029 202d : object. ) -\n-0004a2a0: 3e20 4275 734d 6573 7361 6765 3a0a 2020 > BusMessage:. \n-0004a2b0: 2020 2020 2020 6d65 7373 6167 6520 3d20 message = \n-0004a2c0: 4275 734d 6573 7361 6765 2829 0a20 2020 BusMessage(). \n-0004a2d0: 2020 2020 2073 656c 662e 5f6d 6573 7361 self._messa\n-0004a2e0: 6765 5f6e 6577 5f73 6967 6e61 6c28 6279 ge_new_signal(by\n-0004a2f0: 7265 6628 6d65 7373 6167 6529 2c20 7061 ref(message), pa\n-0004a300: 7468 2c20 696e 7465 7266 6163 652c 206d th, interface, m\n-0004a310: 656d 6265 7229 0a20 2020 2020 2020 206d ember). m\n-0004a320: 6573 7361 6765 2e61 7070 656e 6428 7479 essage.append(ty\n-0004a330: 7065 732c 202a 6172 6773 290a 2020 2020 pes, *args). \n-0004a340: 2020 2020 7265 7475 726e 206d 6573 7361 return messa\n-0004a350: 6765 0a0a 2020 2020 6465 6620 6361 6c6c ge.. def call\n-0004a360: 2873 656c 662c 206d 6573 7361 6765 3a20 (self, message: \n-0004a370: 4275 734d 6573 7361 6765 2c20 7469 6d65 BusMessage, time\n-0004a380: 6f75 743a 204f 7074 696f 6e61 6c5b 696e out: Optional[in\n-0004a390: 745d 203d 204e 6f6e 6529 202d 3e20 4275 t] = None) -> Bu\n-0004a3a0: 734d 6573 7361 6765 3a0a 2020 2020 2020 sMessage:. \n-0004a3b0: 2020 7265 706c 7920 3d20 4275 734d 6573 reply = BusMes\n-0004a3c0: 7361 6765 2829 0a20 2020 2020 2020 2065 sage(). e\n-0004a3d0: 7272 6f72 203d 206c 6962 7379 7374 656d rror = libsystem\n-0004a3e0: 642e 7364 5f62 7573 5f65 7272 6f72 2829 d.sd_bus_error()\n-0004a3f0: 0a20 2020 2020 2020 2074 7279 3a0a 2020 . try:. \n-0004a400: 2020 2020 2020 2020 2020 7365 6c66 2e5f self._\n-0004a410: 6361 6c6c 286d 6573 7361 6765 2c20 7469 call(message, ti\n-0004a420: 6d65 6f75 7420 6f72 2030 2c20 6279 7265 meout or 0, byre\n-0004a430: 6628 6572 726f 7229 2c20 6279 7265 6628 f(error), byref(\n-0004a440: 7265 706c 7929 290a 2020 2020 2020 2020 reply)). \n-0004a450: 2020 2020 7265 7475 726e 2072 6570 6c79 return reply\n-0004a460: 0a20 2020 2020 2020 2065 7863 6570 7420 . except \n-0004a470: 4f53 4572 726f 7220 6173 2065 7863 3a0a OSError as exc:.\n-0004a480: 2020 2020 2020 2020 2020 2020 7261 6973 rais\n-0004a490: 6520 4275 7345 7272 6f72 282a 6572 726f e BusError(*erro\n-0004a4a0: 722e 6765 7428 2929 2066 726f 6d20 6578 r.get()) from ex\n-0004a4b0: 630a 0a20 2020 2064 6566 2063 616c 6c5f c.. def call_\n-0004a4c0: 6d65 7468 6f64 280a 2020 2020 2020 2020 method(. \n-0004a4d0: 2020 2020 7365 6c66 2c0a 2020 2020 2020 self,. \n-0004a4e0: 2020 2020 2020 6465 7374 696e 6174 696f destinatio\n-0004a4f0: 6e3a 2073 7472 2c0a 2020 2020 2020 2020 n: str,. \n-0004a500: 2020 2020 7061 7468 3a20 7374 722c 0a20 path: str,. \n-0004a510: 2020 2020 2020 2020 2020 2069 6e74 6572 inter\n-0004a520: 6661 6365 3a20 7374 722c 0a20 2020 2020 face: str,. \n-0004a530: 2020 2020 2020 206d 656d 6265 723a 2073 member: s\n-0004a540: 7472 2c0a 2020 2020 2020 2020 2020 2020 tr,. \n-0004a550: 7479 7065 733a 2073 7472 203d 2027 272c types: str = '',\n-0004a560: 0a20 2020 2020 2020 2020 2020 202a 6172 . *ar\n-0004a570: 6773 3a20 6f62 6a65 6374 2c0a 2020 2020 gs: object,. \n-0004a580: 2020 2020 2020 2020 7469 6d65 6f75 743a timeout:\n-0004a590: 204f 7074 696f 6e61 6c5b 696e 745d 203d Optional[int] =\n-0004a5a0: 204e 6f6e 650a 2020 2020 2920 2d3e 2054 None. ) -> T\n-0004a5b0: 7570 6c65 5b6f 626a 6563 742c 202e 2e2e uple[object, ...\n-0004a5c0: 5d3a 0a20 2020 2020 2020 206c 6f67 6765 ]:. logge\n-0004a5d0: 722e 6465 6275 6728 2744 6f69 6e67 2073 r.debug('Doing s\n-0004a5e0: 796e 6320 6d65 7468 6f64 2063 616c 6c20 ync method call \n-0004a5f0: 2573 2025 7320 2573 2025 7320 2573 2025 %s %s %s %s %s %\n-0004a600: 7327 2c0a 2020 2020 2020 2020 2020 2020 s',. \n-0004a610: 2020 2020 2020 2020 2064 6573 7469 6e61 destina\n-0004a620: 7469 6f6e 2c20 7061 7468 2c20 696e 7465 tion, path, inte\n-0004a630: 7266 6163 652c 206d 656d 6265 722c 2074 rface, member, t\n-0004a640: 7970 6573 2c20 6172 6773 290a 2020 2020 ypes, args). \n-0004a650: 2020 2020 6d65 7373 6167 6520 3d20 7365 message = se\n-0004a660: 6c66 2e6d 6573 7361 6765 5f6e 6577 5f6d lf.message_new_m\n-0004a670: 6574 686f 645f 6361 6c6c 2864 6573 7469 ethod_call(desti\n-0004a680: 6e61 7469 6f6e 2c20 7061 7468 2c20 696e nation, path, in\n-0004a690: 7465 7266 6163 652c 206d 656d 6265 722c terface, member,\n-0004a6a0: 2074 7970 6573 2c20 2a61 7267 7329 0a20 types, *args). \n-0004a6b0: 2020 2020 2020 206d 6573 7361 6765 203d message =\n-0004a6c0: 2073 656c 662e 6361 6c6c 286d 6573 7361 self.call(messa\n-0004a6d0: 6765 2c20 7469 6d65 6f75 7429 0a20 2020 ge, timeout). \n-0004a6e0: 2020 2020 2072 6574 7572 6e20 6d65 7373 return mess\n-0004a6f0: 6167 652e 6765 745f 626f 6479 2829 0a0a age.get_body()..\n-0004a700: 2020 2020 6173 796e 6320 6465 6620 6361 async def ca\n-0004a710: 6c6c 5f61 7379 6e63 280a 2020 2020 2020 ll_async(. \n-0004a720: 2020 2020 2020 7365 6c66 2c0a 2020 2020 self,. \n-0004a730: 2020 2020 2020 2020 6d65 7373 6167 653a message:\n-0004a740: 2042 7573 4d65 7373 6167 652c 0a20 2020 BusMessage,. \n-0004a750: 2020 2020 2020 2020 2074 696d 656f 7574 timeout\n-0004a760: 3a20 4f70 7469 6f6e 616c 5b69 6e74 5d20 : Optional[int] \n-0004a770: 3d20 4e6f 6e65 0a20 2020 2029 202d 3e20 = None. ) -> \n-0004a780: 4275 734d 6573 7361 6765 3a0a 2020 2020 BusMessage:. \n-0004a790: 2020 2020 7065 6e64 696e 6720 3d20 5065 pending = Pe\n-0004a7a0: 6e64 696e 6743 616c 6c28 290a 2020 2020 ndingCall(). \n-0004a7b0: 2020 2020 7365 6c66 2e5f 6361 6c6c 5f61 self._call_a\n-0004a7c0: 7379 6e63 2862 7972 6566 2870 656e 6469 sync(byref(pendi\n-0004a7d0: 6e67 292c 206d 6573 7361 6765 2c20 7065 ng), message, pe\n-0004a7e0: 6e64 696e 672e 7472 616d 706f 6c69 6e65 nding.trampoline\n-0004a7f0: 2c20 7065 6e64 696e 672e 7573 6572 6461 , pending.userda\n-0004a800: 7461 2c20 7469 6d65 6f75 7420 6f72 2030 ta, timeout or 0\n-0004a810: 290a 2020 2020 2020 2020 7265 7475 726e ). return\n-0004a820: 2061 7761 6974 2070 656e 6469 6e67 2e66 await pending.f\n-0004a830: 7574 7572 650a 0a20 2020 2061 7379 6e63 uture.. async\n-0004a840: 2064 6566 2063 616c 6c5f 6d65 7468 6f64 def call_method\n-0004a850: 5f61 7379 6e63 280a 2020 2020 2020 2020 _async(. \n-0004a860: 7365 6c66 2c0a 2020 2020 2020 2020 6465 self,. de\n-0004a870: 7374 696e 6174 696f 6e3a 204f 7074 696f stination: Optio\n-0004a880: 6e61 6c5b 7374 725d 2c0a 2020 2020 2020 nal[str],. \n-0004a890: 2020 7061 7468 3a20 7374 722c 0a20 2020 path: str,. \n-0004a8a0: 2020 2020 2069 6e74 6572 6661 6365 3a20 interface: \n-0004a8b0: 7374 722c 0a20 2020 2020 2020 206d 656d str,. mem\n-0004a8c0: 6265 723a 2073 7472 2c0a 2020 2020 2020 ber: str,. \n-0004a8d0: 2020 7479 7065 733a 2073 7472 203d 2027 types: str = '\n-0004a8e0: 272c 0a20 2020 2020 2020 202a 6172 6773 ',. *args\n-0004a8f0: 3a20 6f62 6a65 6374 2c0a 2020 2020 2020 : object,. \n-0004a900: 2020 7469 6d65 6f75 743a 204f 7074 696f timeout: Optio\n-0004a910: 6e61 6c5b 696e 745d 203d 204e 6f6e 650a nal[int] = None.\n-0004a920: 2020 2020 2920 2d3e 2054 7570 6c65 5b6f ) -> Tuple[o\n-0004a930: 626a 6563 742c 202e 2e2e 5d3a 0a20 2020 bject, ...]:. \n-0004a940: 2020 2020 206c 6f67 6765 722e 6465 6275 logger.debu\n-0004a950: 6728 2744 6f69 6e67 2061 7379 6e63 206d g('Doing async m\n-0004a960: 6574 686f 6420 6361 6c6c 2025 7320 2573 ethod call %s %s\n-0004a970: 2025 7320 2573 2025 7320 2573 272c 0a20 %s %s %s %s',. \n-0004a980: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0004a990: 2020 2020 6465 7374 696e 6174 696f 6e2c destination,\n-0004a9a0: 2070 6174 682c 2069 6e74 6572 6661 6365 path, interface\n-0004a9b0: 2c20 6d65 6d62 6572 2c20 7479 7065 732c , member, types,\n-0004a9c0: 2061 7267 7329 0a20 2020 2020 2020 206d args). m\n-0004a9d0: 6573 7361 6765 203d 2073 656c 662e 6d65 essage = self.me\n-0004a9e0: 7373 6167 655f 6e65 775f 6d65 7468 6f64 ssage_new_method\n-0004a9f0: 5f63 616c 6c28 6465 7374 696e 6174 696f _call(destinatio\n-0004aa00: 6e2c 2070 6174 682c 2069 6e74 6572 6661 n, path, interfa\n-0004aa10: 6365 2c20 6d65 6d62 6572 2c20 7479 7065 ce, member, type\n-0004aa20: 732c 202a 6172 6773 290a 2020 2020 2020 s, *args). \n-0004aa30: 2020 6d65 7373 6167 6520 3d20 6177 6169 message = awai\n-0004aa40: 7420 7365 6c66 2e63 616c 6c5f 6173 796e t self.call_asyn\n-0004aa50: 6328 6d65 7373 6167 652c 2074 696d 656f c(message, timeo\n-0004aa60: 7574 290a 2020 2020 2020 2020 7265 7475 ut). retu\n-0004aa70: 726e 206d 6573 7361 6765 2e67 6574 5f62 rn message.get_b\n-0004aa80: 6f64 7928 290a 0a20 2020 2064 6566 2061 ody().. def a\n-0004aa90: 6464 5f6d 6174 6368 2873 656c 662c 2072 dd_match(self, r\n-0004aaa0: 756c 653a 2073 7472 2c20 6861 6e64 6c65 ule: str, handle\n-0004aab0: 723a 2043 616c 6c61 626c 655b 5b42 7573 r: Callable[[Bus\n-0004aac0: 4d65 7373 6167 655d 2c20 626f 6f6c 5d29 Message], bool])\n-0004aad0: 202d 3e20 536c 6f74 3a0a 2020 2020 2020 -> Slot:. \n-0004aae0: 2020 736c 6f74 203d 2053 6c6f 7428 6861 slot = Slot(ha\n-0004aaf0: 6e64 6c65 7229 0a20 2020 2020 2020 2073 ndler). s\n-0004ab00: 656c 662e 5f61 6464 5f6d 6174 6368 2862 elf._add_match(b\n-0004ab10: 7972 6566 2873 6c6f 7429 2c20 7275 6c65 yref(slot), rule\n-0004ab20: 2c20 736c 6f74 2e74 7261 6d70 6f6c 696e , slot.trampolin\n-0004ab30: 652c 2073 6c6f 742e 7573 6572 6461 7461 e, slot.userdata\n-0004ab40: 290a 2020 2020 2020 2020 7265 7475 726e ). return\n-0004ab50: 2073 6c6f 740a 0a20 2020 2064 6566 2061 slot.. def a\n-0004ab60: 6464 5f6f 626a 6563 7428 7365 6c66 2c20 dd_object(self, \n-0004ab70: 7061 7468 3a20 7374 722c 206f 626a 3a20 path: str, obj: \n-0004ab80: 2742 6173 654f 626a 6563 7427 2920 2d3e 'BaseObject') ->\n-0004ab90: 2053 6c6f 743a 0a20 2020 2020 2020 2073 Slot:. s\n-0004aba0: 6c6f 7420 3d20 536c 6f74 286f 626a 2e6d lot = Slot(obj.m\n-0004abb0: 6573 7361 6765 5f72 6563 6569 7665 6429 essage_received)\n-0004abc0: 0a20 2020 2020 2020 2073 656c 662e 5f61 . self._a\n-0004abd0: 6464 5f6f 626a 6563 7428 6279 7265 6628 dd_object(byref(\n-0004abe0: 736c 6f74 292c 2070 6174 682c 2073 6c6f slot), path, slo\n-0004abf0: 742e 7472 616d 706f 6c69 6e65 2c20 736c t.trampoline, sl\n-0004ac00: 6f74 2e75 7365 7264 6174 6129 0a20 2020 ot.userdata). \n-0004ac10: 2020 2020 206f 626a 2e72 6567 6973 7465 obj.registe\n-0004ac20: 7265 645f 6f6e 5f62 7573 2873 656c 662c red_on_bus(self,\n-0004ac30: 2070 6174 6829 0a20 2020 2020 2020 2072 path). r\n-0004ac40: 6574 7572 6e20 736c 6f74 0a0a 0a63 6c61 eturn slot...cla\n-0004ac50: 7373 2042 6173 654f 626a 6563 743a 0a20 ss BaseObject:. \n-0004ac60: 2020 2022 2222 4261 7365 206f 626a 6563 \"\"\"Base objec\n-0004ac70: 7420 7479 7065 2066 6f72 2065 7870 6f72 t type for expor\n-0004ac80: 7469 6e67 206f 626a 6563 7473 206f 6e20 ting objects on \n-0004ac90: 7468 6520 6275 730a 0a20 2020 2054 6869 the bus.. Thi\n-0004aca0: 7320 6973 2074 6865 206c 6f77 6573 742d s is the lowest-\n-0004acb0: 6c65 7665 6c20 636c 6173 7320 7468 6174 level class that\n-0004acc0: 2063 616e 2062 6520 7061 7373 6564 2074 can be passed t\n-0004acd0: 6f20 4275 732e 6164 645f 6f62 6a65 6374 o Bus.add_object\n-0004ace0: 2829 2e0a 0a20 2020 2049 6620 796f 7520 ()... If you \n-0004acf0: 7761 6e74 2074 6f20 6469 7265 6374 6c79 want to directly\n-0004ad00: 2073 7562 636c 6173 7320 7468 6973 2c20 subclass this, \n-0004ad10: 796f 7527 6c6c 206e 6565 6420 746f 2069 you'll need to i\n-0004ad20: 6d70 6c65 6d65 6e74 0a20 2020 2060 6d65 mplement. `me\n-0004ad30: 7373 6167 655f 7265 6365 6976 6564 2829 ssage_received()\n-0004ad40: 602e 0a0a 2020 2020 5375 6263 6c61 7373 `... Subclass\n-0004ad50: 696e 6720 6672 6f6d 2060 6275 732e 4f62 ing from `bus.Ob\n-0004ad60: 6a65 6374 6020 6973 2070 726f 6261 626c ject` is probabl\n-0004ad70: 7920 6120 6265 7474 6572 2063 686f 6963 y a better choic\n-0004ad80: 652e 0a20 2020 2022 2222 0a20 2020 205f e.. \"\"\". _\n-0004ad90: 6462 7573 5f62 7573 3a20 4f70 7469 6f6e dbus_bus: Option\n-0004ada0: 616c 5b42 7573 5d20 3d20 4e6f 6e65 0a20 al[Bus] = None. \n-0004adb0: 2020 205f 6462 7573 5f70 6174 683a 204f _dbus_path: O\n-0004adc0: 7074 696f 6e61 6c5b 7374 725d 203d 204e ptional[str] = N\n-0004add0: 6f6e 650a 0a20 2020 2064 6566 2072 6567 one.. def reg\n-0004ade0: 6973 7465 7265 645f 6f6e 5f62 7573 2873 istered_on_bus(s\n-0004adf0: 656c 662c 2062 7573 3a20 4275 732c 2070 elf, bus: Bus, p\n-0004ae00: 6174 683a 2073 7472 2920 2d3e 204e 6f6e ath: str) -> Non\n-0004ae10: 653a 0a20 2020 2020 2020 2022 2222 5265 e:. \"\"\"Re\n-0004ae20: 706f 7274 2074 6861 7420 616e 2069 6e73 port that an ins\n-0004ae30: 7461 6e63 6520 7761 7320 6578 706f 7274 tance was export\n-0004ae40: 6564 206f 6e20 6120 6769 7665 6e20 6275 ed on a given bu\n-0004ae50: 7320 616e 6420 7061 7468 2e0a 0a20 2020 s and path... \n-0004ae60: 2020 2020 2054 6869 7320 6973 2075 7365 This is use\n-0004ae70: 6420 736f 2074 6861 7420 7468 6520 696e d so that the in\n-0004ae80: 7374 616e 6365 206b 6e6f 7773 2077 6865 stance knows whe\n-0004ae90: 7265 2074 6f20 7365 6e64 2073 6967 6e61 re to send signa\n-0004aea0: 6c73 2e0a 2020 2020 2020 2020 4275 732e ls.. Bus.\n-0004aeb0: 6164 645f 6f62 6a65 6374 2829 2063 616c add_object() cal\n-0004aec0: 6c73 2074 6869 733a 2079 6f75 2070 726f ls this: you pro\n-0004aed0: 6261 626c 7920 7368 6f75 6c64 6e27 7420 bably shouldn't \n-0004aee0: 6361 6c6c 2074 6869 7320 6f6e 2079 6f75 call this on you\n-0004aef0: 720a 2020 2020 2020 2020 6f77 6e2e 0a20 r. own.. \n-0004af00: 2020 2020 2020 2022 2222 0a20 2020 2020 \"\"\". \n-0004af10: 2020 2073 656c 662e 5f64 6275 735f 6275 self._dbus_bu\n-0004af20: 7320 3d20 6275 730a 2020 2020 2020 2020 s = bus. \n-0004af30: 7365 6c66 2e5f 6462 7573 5f70 6174 6820 self._dbus_path \n-0004af40: 3d20 7061 7468 0a0a 2020 2020 2020 2020 = path.. \n-0004af50: 7365 6c66 2e72 6567 6973 7465 7265 6428 self.registered(\n-0004af60: 290a 0a20 2020 2064 6566 2072 6567 6973 ).. def regis\n-0004af70: 7465 7265 6428 7365 6c66 2920 2d3e 204e tered(self) -> N\n-0004af80: 6f6e 653a 0a20 2020 2020 2020 2022 2222 one:. \"\"\"\n-0004af90: 4361 6c6c 6564 2061 6674 6572 2061 6e20 Called after an \n-0004afa0: 6f62 6a65 6374 2068 6173 2062 6565 6e20 object has been \n-0004afb0: 7265 6769 7374 6572 6564 206f 6e20 7468 registered on th\n-0004afc0: 6520 6275 730a 0a20 2020 2020 2020 2054 e bus.. T\n-0004afd0: 6869 7320 6973 2074 6865 2063 6f72 7265 his is the corre\n-0004afe0: 6374 206d 6574 686f 6420 746f 2069 6d70 ct method to imp\n-0004aff0: 6c65 6d65 6e74 2074 6f20 646f 2073 6f6d lement to do som\n-0004b000: 6520 696e 6974 6961 6c20 776f 726b 2074 e initial work t\n-0004b010: 6861 740a 2020 2020 2020 2020 6e65 6564 hat. need\n-0004b020: 7320 746f 2062 6520 646f 6e65 2061 6674 s to be done aft\n-0004b030: 6572 2072 6567 6973 7472 6174 696f 6e2e er registration.\n-0004b040: 2020 5468 6520 6465 6661 756c 7420 696d The default im\n-0004b050: 706c 656d 656e 7461 7469 6f6e 2064 6f65 plementation doe\n-0004b060: 730a 2020 2020 2020 2020 6e6f 7468 696e s. nothin\n-0004b070: 672e 0a20 2020 2020 2020 2022 2222 0a20 g.. \"\"\". \n-0004b080: 2020 2020 2020 2070 6173 730a 0a20 2020 pass.. \n-0004b090: 2064 6566 2065 6d69 745f 7369 676e 616c def emit_signal\n-0004b0a0: 280a 2020 2020 2020 2020 2020 2020 7365 (. se\n-0004b0b0: 6c66 2c20 696e 7465 7266 6163 653a 2073 lf, interface: s\n-0004b0c0: 7472 2c20 6e61 6d65 3a20 7374 722c 2073 tr, name: str, s\n-0004b0d0: 6967 6e61 7475 7265 3a20 7374 722c 202a ignature: str, *\n-0004b0e0: 6172 6773 3a20 416e 790a 2020 2020 2920 args: Any. ) \n-0004b0f0: 2d3e 2062 6f6f 6c3a 0a20 2020 2020 2020 -> bool:. \n-0004b100: 2022 2222 456d 6974 2061 2044 2d42 7573 \"\"\"Emit a D-Bus\n-0004b110: 2073 6967 6e61 6c20 6f6e 2074 6869 7320 signal on this \n-0004b120: 6f62 6a65 6374 0a0a 2020 2020 2020 2020 object.. \n-0004b130: 5468 6520 6f62 6a65 6374 206d 7573 7420 The object must \n-0004b140: 6861 7665 2062 6565 6e20 6578 706f 7274 have been export\n-0004b150: 6564 206f 6e20 7468 6520 6275 7320 7769 ed on the bus wi\n-0004b160: 7468 2042 7573 2e61 6464 5f6f 626a 6563 th Bus.add_objec\n-0004b170: 7428 292e 0a0a 2020 2020 2020 2020 3a69 t()... :i\n-0004b180: 6e74 6572 6661 6365 3a20 7468 6520 696e nterface: the in\n-0004b190: 7465 7266 6163 6520 6f66 2074 6865 2073 terface of the s\n-0004b1a0: 6967 6e61 6c0a 2020 2020 2020 2020 3a6e ignal. :n\n-0004b1b0: 616d 653a 2074 6865 2027 6d65 6d62 6572 ame: the 'member\n-0004b1c0: 2720 6e61 6d65 206f 6620 7468 6520 7369 ' name of the si\n-0004b1d0: 676e 616c 2074 6f20 656d 6974 0a20 2020 gnal to emit. \n-0004b1e0: 2020 2020 203a 7369 676e 6174 7572 653a :signature:\n-0004b1f0: 2074 6865 2074 7970 6520 7369 676e 6174 the type signat\n-0004b200: 7572 652c 2061 7320 6120 7374 7269 6e67 ure, as a string\n-0004b210: 0a20 2020 2020 2020 203a 6172 6773 3a20 . :args: \n-0004b220: 7468 6520 6172 6775 6d65 6e74 732c 2061 the arguments, a\n-0004b230: 6363 6f72 6469 6e67 2074 6f20 7468 6520 ccording to the \n-0004b240: 7369 676e 6174 7572 650a 2020 2020 2020 signature. \n-0004b250: 2020 3a72 6574 7572 6e73 3a20 5472 7565 :returns: True\n-0004b260: 0a20 2020 2020 2020 2022 2222 0a20 2020 . \"\"\". \n-0004b270: 2020 2020 2061 7373 6572 7420 7365 6c66 assert self\n-0004b280: 2e5f 6462 7573 5f62 7573 2069 7320 6e6f ._dbus_bus is no\n-0004b290: 7420 4e6f 6e65 0a20 2020 2020 2020 2061 t None. a\n-0004b2a0: 7373 6572 7420 7365 6c66 2e5f 6462 7573 ssert self._dbus\n-0004b2b0: 5f70 6174 6820 6973 206e 6f74 204e 6f6e _path is not Non\n-0004b2c0: 650a 2020 2020 2020 2020 7265 7475 726e e. return\n-0004b2d0: 2073 656c 662e 5f64 6275 735f 6275 732e self._dbus_bus.\n-0004b2e0: 6d65 7373 6167 655f 6e65 775f 7369 676e message_new_sign\n-0004b2f0: 616c 2873 656c 662e 5f64 6275 735f 7061 al(self._dbus_pa\n-0004b300: 7468 2c20 696e 7465 7266 6163 652c 206e th, interface, n\n-0004b310: 616d 652c 2073 6967 6e61 7475 7265 2c20 ame, signature, \n-0004b320: 2a61 7267 7329 2e73 656e 6428 290a 0a20 *args).send().. \n-0004b330: 2020 2064 6566 206d 6573 7361 6765 5f72 def message_r\n-0004b340: 6563 6569 7665 6428 7365 6c66 2c20 6d65 eceived(self, me\n-0004b350: 7373 6167 653a 2042 7573 4d65 7373 6167 ssage: BusMessag\n-0004b360: 6529 202d 3e20 626f 6f6c 3a0a 2020 2020 e) -> bool:. \n-0004b370: 2020 2020 2222 2243 616c 6c65 6420 7768 \"\"\"Called wh\n-0004b380: 656e 2061 206d 6573 7361 6765 2069 7320 en a message is \n-0004b390: 7265 6365 6976 6564 2066 6f72 2074 6869 received for thi\n-0004b3a0: 7320 6f62 6a65 6374 0a0a 2020 2020 2020 s object.. \n-0004b3b0: 2020 5468 6973 2069 7320 7468 6520 6c6f This is the lo\n-0004b3c0: 7765 7374 206c 6576 656c 2069 6e74 6572 west level inter\n-0004b3d0: 6661 6365 2074 6f20 7468 6520 4261 7365 face to the Base\n-0004b3e0: 4f62 6a65 6374 2e20 2059 6f75 206e 6565 Object. You nee\n-0004b3f0: 6420 746f 0a20 2020 2020 2020 2068 616e d to. han\n-0004b400: 646c 6520 6d65 7468 6f64 2063 616c 6c73 dle method calls\n-0004b410: 2c20 7072 6f70 6572 7469 6573 2c20 616e , properties, an\n-0004b420: 6420 696e 7472 6f73 7065 6374 696f 6e2e d introspection.\n-0004b430: 0a0a 2020 2020 2020 2020 596f 7520 6172 .. You ar\n-0004b440: 6520 6578 7065 6374 6564 2074 6f20 6861 e expected to ha\n-0004b450: 6e64 6c65 2074 6865 206d 6573 7361 6765 ndle the message\n-0004b460: 2061 6e64 2072 6574 7572 6e20 5472 7565 and return True\n-0004b470: 2e20 204e 6f72 6d61 6c6c 7920 7468 6973 . Normally this\n-0004b480: 0a20 2020 2020 2020 206d 6561 6e73 2074 . means t\n-0004b490: 6861 7420 796f 7520 7365 6e64 2061 2072 hat you send a r\n-0004b4a0: 6570 6c79 2e20 2049 6620 796f 7520 646f eply. If you do\n-0004b4b0: 6e27 7420 7761 6e74 2074 6f20 6861 6e64 n't want to hand\n-0004b4c0: 6c65 2074 6865 206d 6573 7361 6765 2c0a le the message,.\n-0004b4d0: 2020 2020 2020 2020 7265 7475 726e 2046 return F\n-0004b4e0: 616c 7365 2061 6e64 206f 7468 6572 2068 alse and other h\n-0004b4f0: 616e 646c 6572 7320 7769 6c6c 2068 6176 andlers will hav\n-0004b500: 6520 6120 6368 616e 6365 2074 6f20 7275 e a chance to ru\n-0004b510: 6e2e 2020 4966 206e 6f0a 2020 2020 2020 n. If no. \n-0004b520: 2020 6861 6e64 6c65 7220 6861 6e64 6c65 handler handle\n-0004b530: 7320 7468 6520 6d65 7373 6167 652c 2073 s the message, s\n-0004b540: 7973 7465 6d64 2077 696c 6c20 6765 6e65 ystemd will gene\n-0004b550: 7261 7465 2061 2073 7569 7461 626c 6520 rate a suitable \n-0004b560: 6572 726f 720a 2020 2020 2020 2020 6d65 error. me\n-0004b570: 7373 6167 6520 616e 6420 7365 6e64 2074 ssage and send t\n-0004b580: 6861 742c 2069 6e73 7465 6164 2e0a 0a20 hat, instead... \n-0004b590: 2020 2020 2020 203a 6d65 7373 6167 653a :message:\n-0004b5a0: 2074 6865 206d 6573 7361 6765 2074 6861 the message tha\n-0004b5b0: 7420 7761 7320 7265 6365 6976 6564 0a20 t was received. \n-0004b5c0: 2020 2020 2020 203a 7265 7475 726e 733a :returns:\n-0004b5d0: 2054 7275 6520 6966 2074 6865 206d 6573 True if the mes\n-0004b5e0: 7361 6765 2077 6173 2068 616e 646c 6564 sage was handled\n-0004b5f0: 0a20 2020 2020 2020 2022 2222 0a20 2020 . \"\"\". \n-0004b600: 2020 2020 2072 6169 7365 204e 6f74 496d raise NotIm\n-0004b610: 706c 656d 656e 7465 6445 7272 6f72 0a0a plementedError..\n-0004b620: 0a63 6c61 7373 2049 6e74 6572 6661 6365 .class Interface\n-0004b630: 3a0a 2020 2020 2222 2254 6865 2068 6967 :. \"\"\"The hig\n-0004b640: 682d 6c65 7665 6c20 6261 7365 2063 6c61 h-level base cla\n-0004b650: 7373 2066 6f72 2064 6566 696e 696e 6720 ss for defining \n-0004b660: 442d 4275 7320 696e 7465 7266 6163 6573 D-Bus interfaces\n-0004b670: 0a0a 2020 2020 5468 6973 2063 6c61 7373 .. This class\n-0004b680: 2070 726f 7669 6465 7320 6869 6768 2d6c provides high-l\n-0004b690: 6576 656c 2041 5049 7320 666f 7220 6465 evel APIs for de\n-0004b6a0: 6669 6e69 6e67 206d 6574 686f 6473 2c20 fining methods, \n-0004b6b0: 7072 6f70 6572 7469 6573 2c20 616e 640a properties, and.\n-0004b6c0: 2020 2020 7369 676e 616c 732c 2061 7320 signals, as \n-0004b6d0: 7765 6c6c 2061 7320 696d 706c 656d 656e well as implemen\n-0004b6e0: 7469 6e67 2069 6e74 726f 7370 6563 7469 ting introspecti\n-0004b6f0: 6f6e 2e0a 0a20 2020 204f 6e20 6974 7320 on... On its \n-0004b700: 6f77 6e2c 2074 6869 7320 636c 6173 7320 own, this class \n-0004b710: 646f 6573 6e27 7420 7072 6f76 6964 6520 doesn't provide \n-0004b720: 6120 6d65 6368 616e 6973 6d20 666f 7220 a mechanism for \n-0004b730: 6578 706f 7274 696e 6720 616e 7974 6869 exporting anythi\n-0004b740: 6e67 0a20 2020 206f 6e20 7468 6520 6275 ng. on the bu\n-0004b750: 732e 2020 5468 6520 4f62 6a65 6374 2063 s. The Object c\n-0004b760: 6c61 7373 2064 6f65 7320 7468 6174 2c20 lass does that, \n-0004b770: 616e 6420 796f 7527 6c6c 2067 656e 6572 and you'll gener\n-0004b780: 616c 6c79 2077 616e 7420 746f 0a20 2020 ally want to. \n-0004b790: 2073 7562 636c 6173 7320 6672 6f6d 2069 subclass from i\n-0004b7a0: 742c 2061 7320 6974 2063 6f6e 7461 696e t, as it contain\n-0004b7b0: 7320 7365 7665 7261 6c20 6275 696c 742d s several built-\n-0004b7c0: 696e 2073 7461 6e64 6172 6420 696e 7465 in standard inte\n-0004b7d0: 7266 6163 6573 0a20 2020 2028 696e 7472 rfaces. (intr\n-0004b7e0: 6f73 7065 6374 696f 6e2c 2070 726f 7065 ospection, prope\n-0004b7f0: 7274 6965 732c 2065 7463 2e29 2e0a 0a20 rties, etc.)... \n-0004b800: 2020 2054 6865 206e 616d 6520 6f66 2079 The name of y\n-0004b810: 6f75 7220 636c 6173 7320 7769 6c6c 2062 our class will b\n-0004b820: 6520 696e 7465 7270 7265 7465 6420 6173 e interpreted as\n-0004b830: 2061 2044 2d42 7573 2069 6e74 6572 6661 a D-Bus interfa\n-0004b840: 6365 206e 616d 652e 0a20 2020 2055 6e64 ce name.. Und\n-0004b850: 6572 7363 6f72 6573 2061 7265 2063 6f6e erscores are con\n-0004b860: 7665 7274 6564 2074 6f20 646f 7473 2e20 verted to dots. \n-0004b870: 204e 6f20 6361 7365 2063 6f6e 7665 7273 No case convers\n-0004b880: 696f 6e20 6973 2070 6572 666f 726d 6564 ion is performed\n-0004b890: 2e20 2049 660a 2020 2020 7468 6520 696e . If. the in\n-0004b8a0: 7465 7266 6163 6520 6e61 6d65 2063 616e terface name can\n-0004b8b0: 2774 2062 6520 7265 7072 6573 656e 7465 't be represente\n-0004b8c0: 6420 7573 696e 6720 7468 6973 2073 6368 d using this sch\n-0004b8d0: 656d 652c 206f 7220 6966 2079 6f75 2764 eme, or if you'd\n-0004b8e0: 206c 696b 650a 2020 2020 746f 206e 616d like. to nam\n-0004b8f0: 6520 796f 7572 2063 6c61 7373 2064 6966 e your class dif\n-0004b900: 6665 7265 6e74 6c79 2c20 796f 7520 6361 ferently, you ca\n-0004b910: 6e20 7072 6f76 6964 6520 616e 2069 6e74 n provide an int\n-0004b920: 6572 6661 6365 3d20 6b77 6172 6720 746f erface= kwarg to\n-0004b930: 2074 6865 0a20 2020 2063 6c61 7373 2064 the. class d\n-0004b940: 6566 696e 6974 696f 6e2e 0a0a 2020 2020 efinition... \n-0004b950: 2020 2020 636c 6173 7320 636f 6d5f 6578 class com_ex\n-0004b960: 616d 706c 655f 496e 7465 7266 6163 6528 ample_Interface(\n-0004b970: 6275 732e 4f62 6a65 6374 293a 0a20 2020 bus.Object):. \n-0004b980: 2020 2020 2020 2020 2070 6173 730a 0a20 pass.. \n-0004b990: 2020 2020 2020 2063 6c61 7373 204d 7949 class MyI\n-0004b9a0: 6e74 6572 6661 6365 2862 7573 2e4f 626a nterface(bus.Obj\n-0004b9b0: 6563 742c 2069 6e74 6572 6661 6365 3d27 ect, interface='\n-0004b9c0: 6f72 672e 636f 636b 7069 745f 7072 6f6a org.cockpit_proj\n-0004b9d0: 6563 742e 496e 7465 7266 6163 6527 293a ect.Interface'):\n-0004b9e0: 0a20 2020 2020 2020 2020 2020 2070 6173 . pas\n-0004b9f0: 730a 0a20 2020 2054 6865 206d 6574 686f s.. The metho\n-0004ba00: 6473 2c20 7072 6f70 6572 7469 6573 2c20 ds, properties, \n-0004ba10: 616e 6420 7369 676e 616c 7320 7768 6963 and signals whic\n-0004ba20: 6820 6172 6520 7669 7369 626c 6520 6672 h are visible fr\n-0004ba30: 6f6d 2044 2d42 7573 2061 7265 0a20 2020 om D-Bus are. \n-0004ba40: 2064 6566 696e 6564 2075 7369 6e67 2068 defined using h\n-0004ba50: 656c 7065 7220 636c 6173 7365 7320 7769 elper classes wi\n-0004ba60: 7468 2074 6865 2063 6f72 7265 7370 6f6e th the correspon\n-0004ba70: 6469 6e67 206e 616d 6573 2028 4d65 7468 ding names (Meth\n-0004ba80: 6f64 2c0a 2020 2020 5072 6f70 6572 7479 od,. Property\n-0004ba90: 2c20 5369 676e 616c 292e 2020 596f 7520 , Signal). You \n-0004baa0: 7368 6f75 6c64 2075 7365 206e 6f72 6d61 should use norma\n-0004bab0: 6c20 5079 7468 6f6e 2073 6e61 6b65 5f63 l Python snake_c\n-0004bac0: 6173 6520 636f 6e76 656e 7469 6f6e 7320 ase conventions \n-0004bad0: 666f 720a 2020 2020 7468 6520 6d65 6d62 for. the memb\n-0004bae0: 6572 206e 616d 6573 3a20 7468 6579 2077 er names: they w\n-0004baf0: 696c 6c20 6175 746f 6d61 7469 6361 6c6c ill automaticall\n-0004bb00: 7920 6265 2063 6f6e 7665 7274 6564 2074 y be converted t\n-0004bb10: 6f20 4361 6d65 6c43 6173 6520 6279 0a20 o CamelCase by. \n-0004bb20: 2020 2073 706c 6974 7469 6e67 206f 6e20 splitting on \n-0004bb30: 756e 6465 7273 636f 7265 2061 6e64 2063 underscore and c\n-0004bb40: 6f6e 7665 7274 696e 6720 7468 6520 6669 onverting the fi\n-0004bb50: 7273 7420 6c65 7474 6572 206f 6620 6561 rst letter of ea\n-0004bb60: 6368 2072 6573 756c 7469 6e67 0a20 2020 ch resulting. \n-0004bb70: 2077 6f72 6420 746f 2075 7070 6572 6361 word to upperca\n-0004bb80: 7365 2e20 2046 6f72 2065 7861 6d70 6c65 se. For example\n-0004bb90: 2c20 606d 6574 686f 645f 6e61 6d65 6020 , `method_name` \n-0004bba0: 6265 636f 6d65 7320 604d 6574 686f 644e becomes `MethodN\n-0004bbb0: 616d 6560 2e0a 0a20 2020 2045 6163 6820 ame`... Each \n-0004bbc0: 4d65 7468 6f64 2c20 5072 6f70 6572 7479 Method, Property\n-0004bbd0: 2c20 6f72 2053 6967 6e61 6c20 636f 6e73 , or Signal cons\n-0004bbe0: 7472 7563 746f 7220 7461 6b65 7320 616e tructor takes an\n-0004bbf0: 206f 7074 696f 6e61 6c20 6e61 6d65 3d20 optional name= \n-0004bc00: 6b77 6172 6773 0a20 2020 2074 6f20 6f76 kwargs. to ov\n-0004bc10: 6572 7269 6465 2074 6865 2061 7574 6f6d erride the autom\n-0004bc20: 6174 6963 206e 616d 6520 636f 6e76 6572 atic name conver\n-0004bc30: 7369 6f6e 2063 6f6e 7665 6e74 696f 6e20 sion convention \n-0004bc40: 6162 6f76 652e 0a0a 2020 2020 416e 2065 above... An e\n-0004bc50: 7861 6d70 6c65 2063 6c61 7373 206d 6967 xample class mig\n-0004bc60: 6874 206c 6f6f 6b20 6c69 6b65 3a0a 0a20 ht look like:.. \n-0004bc70: 2020 2020 2020 2063 6c61 7373 2063 6f6d class com\n-0004bc80: 5f65 7861 6d70 6c65 5f4d 794f 626a 6563 _example_MyObjec\n-0004bc90: 7428 6275 732e 4f62 6a65 6374 293a 0a20 t(bus.Object):. \n-0004bca0: 2020 2020 2020 2020 2020 2063 7265 6174 creat\n-0004bcb0: 6564 203d 2062 7573 2e49 6e74 6572 6661 ed = bus.Interfa\n-0004bcc0: 6365 2e53 6967 6e61 6c28 2773 272c 2027 ce.Signal('s', '\n-0004bcd0: 6927 290a 2020 2020 2020 2020 2020 2020 i'). \n-0004bce0: 7265 6e61 6d65 7320 3d20 6275 732e 496e renames = bus.In\n-0004bcf0: 7465 7266 6163 652e 5072 6f70 6572 7479 terface.Property\n-0004bd00: 2827 7527 2c20 7661 6c75 653d 3029 0a20 ('u', value=0). \n-0004bd10: 2020 2020 2020 2020 2020 206e 616d 6520 name \n-0004bd20: 3d20 6275 732e 496e 7465 7266 6163 652e = bus.Interface.\n-0004bd30: 5072 6f70 6572 7479 2827 7327 2c20 2775 Property('s', 'u\n-0004bd40: 6e64 6566 696e 6564 2729 0a0a 2020 2020 ndefined').. \n-0004bd50: 2020 2020 2020 2020 4062 7573 2e49 6e74 @bus.Int\n-0004bd60: 6572 6661 6365 2e4d 6574 686f 6428 6f75 erface.Method(ou\n-0004bd70: 745f 7479 7065 733d 2829 2c20 696e 5f74 t_types=(), in_t\n-0004bd80: 7970 6573 3d27 7327 290a 2020 2020 2020 ypes='s'). \n-0004bd90: 2020 2020 2020 6465 6620 7265 6e61 6d65 def rename\n-0004bda0: 2873 656c 662c 206e 616d 6529 3a0a 2020 (self, name):. \n-0004bdb0: 2020 2020 2020 2020 2020 2020 2020 7365 se\n-0004bdc0: 6c66 2e72 656e 616d 6573 202b 3d20 310a lf.renames += 1.\n-0004bdd0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0004bde0: 7365 6c66 2e6e 616d 6520 3d20 6e61 6d65 self.name = name\n-0004bdf0: 0a0a 2020 2020 2020 2020 2020 2020 6465 .. de\n-0004be00: 6620 7265 6769 7374 6572 6564 2873 656c f registered(sel\n-0004be10: 6629 3a0a 2020 2020 2020 2020 2020 2020 f):. \n-0004be20: 2020 2020 7365 6c66 2e63 7265 6174 6564 self.created\n-0004be30: 2827 4865 6c6c 6f27 2c20 3432 290a 0a20 ('Hello', 42).. \n-0004be40: 2020 2053 6565 2074 6865 2064 6f63 756d See the docum\n-0004be50: 656e 7461 7469 6f6e 2066 6f72 2074 6865 entation for the\n-0004be60: 204d 6574 686f 642c 2050 726f 7065 7274 Method, Propert\n-0004be70: 792c 2061 6e64 2053 6967 6e61 6c20 636c y, and Signal cl\n-0004be80: 6173 7365 7320 666f 720a 2020 2020 6d6f asses for. mo\n-0004be90: 7265 2069 6e66 6f72 6d61 7469 6f6e 2061 re information a\n-0004bea0: 6e64 2065 7861 6d70 6c65 732e 0a20 2020 nd examples.. \n-0004beb0: 2022 2222 0a0a 2020 2020 2320 436c 6173 \"\"\".. # Clas\n-0004bec0: 7320 7661 7269 6162 6c65 730a 2020 2020 s variables. \n-0004bed0: 5f64 6275 735f 696e 7465 7266 6163 6573 _dbus_interfaces\n-0004bee0: 3a20 4469 6374 5b73 7472 2c20 4469 6374 : Dict[str, Dict\n-0004bef0: 5b73 7472 2c20 4469 6374 5b73 7472 2c20 [str, Dict[str, \n-0004bf00: 416e 795d 5d5d 0a20 2020 205f 6462 7573 Any]]]. _dbus\n-0004bf10: 5f6d 656d 6265 7273 3a20 4f70 7469 6f6e _members: Option\n-0004bf20: 616c 5b54 7570 6c65 5b73 7472 2c20 4469 al[Tuple[str, Di\n-0004bf30: 6374 5b73 7472 2c20 4469 6374 5b73 7472 ct[str, Dict[str\n-0004bf40: 2c20 416e 795d 5d5d 5d0a 0a20 2020 2023 , Any]]]].. #\n-0004bf50: 2049 6e73 7461 6e63 6520 7661 7269 6162 Instance variab\n-0004bf60: 6c65 733a 2073 746f 7265 6420 696e 2050 les: stored in P\n-0004bf70: 7974 686f 6e20 666f 726d 0a20 2020 205f ython form. _\n-0004bf80: 6462 7573 5f70 726f 7065 7274 795f 7661 dbus_property_va\n-0004bf90: 6c75 6573 3a20 4f70 7469 6f6e 616c 5b44 lues: Optional[D\n-0004bfa0: 6963 745b 7374 722c 2041 6e79 5d5d 203d ict[str, Any]] =\n-0004bfb0: 204e 6f6e 650a 0a20 2020 2040 636c 6173 None.. @clas\n-0004bfc0: 736d 6574 686f 640a 2020 2020 6465 6620 smethod. def \n-0004bfd0: 5f5f 696e 6974 5f73 7562 636c 6173 735f __init_subclass_\n-0004bfe0: 5f28 636c 732c 2069 6e74 6572 6661 6365 _(cls, interface\n-0004bff0: 3a20 4f70 7469 6f6e 616c 5b73 7472 5d20 : Optional[str] \n-0004c000: 3d20 4e6f 6e65 2920 2d3e 204e 6f6e 653a = None) -> None:\n-0004c010: 0a20 2020 2020 2020 2069 6620 696e 7465 . if inte\n-0004c020: 7266 6163 6520 6973 204e 6f6e 653a 0a20 rface is None:. \n-0004c030: 2020 2020 2020 2020 2020 2061 7373 6572 asser\n-0004c040: 7420 275f 5f27 206e 6f74 2069 6e20 636c t '__' not in cl\n-0004c050: 732e 5f5f 6e61 6d65 5f5f 2c20 2743 6c61 s.__name__, 'Cla\n-0004c060: 7373 206e 616d 6520 6361 6e6e 6f74 2063 ss name cannot c\n-0004c070: 6f6e 7461 696e 2073 6571 7565 6e74 6961 ontain sequentia\n-0004c080: 6c20 756e 6465 7273 636f 7265 7327 0a20 l underscores'. \n-0004c090: 2020 2020 2020 2020 2020 2069 6e74 6572 inter\n-0004c0a0: 6661 6365 203d 2063 6c73 2e5f 5f6e 616d face = cls.__nam\n-0004c0b0: 655f 5f2e 7265 706c 6163 6528 275f 272c e__.replace('_',\n-0004c0c0: 2027 2e27 290a 0a20 2020 2020 2020 2023 '.').. #\n-0004c0d0: 2054 6869 7320 6973 2074 6865 2069 6e66 This is the inf\n-0004c0e0: 6f72 6d61 7469 6f6e 2066 6f72 2074 6869 ormation for thi\n-0004c0f0: 7320 7375 6263 6c61 7373 2064 6972 6563 s subclass direc\n-0004c100: 746c 790a 2020 2020 2020 2020 6d65 6d62 tly. memb\n-0004c110: 6572 733a 2044 6963 745b 7374 722c 2044 ers: Dict[str, D\n-0004c120: 6963 745b 7374 722c 2049 6e74 6572 6661 ict[str, Interfa\n-0004c130: 6365 2e5f 4d65 6d62 6572 5d5d 203d 207b ce._Member]] = {\n-0004c140: 276d 6574 686f 6473 273a 207b 7d2c 2027 'methods': {}, '\n-0004c150: 7072 6f70 6572 7469 6573 273a 207b 7d2c properties': {},\n-0004c160: 2027 7369 676e 616c 7327 3a20 7b7d 7d0a 'signals': {}}.\n-0004c170: 2020 2020 2020 2020 666f 7220 6e61 6d65 for name\n-0004c180: 2c20 6d65 6d62 6572 2069 6e20 636c 732e , member in cls.\n-0004c190: 5f5f 6469 6374 5f5f 2e69 7465 6d73 2829 __dict__.items()\n-0004c1a0: 3a0a 2020 2020 2020 2020 2020 2020 6966 :. if\n-0004c1b0: 2069 7369 6e73 7461 6e63 6528 6d65 6d62 isinstance(memb\n-0004c1c0: 6572 2c20 496e 7465 7266 6163 652e 5f4d er, Interface._M\n-0004c1d0: 656d 6265 7229 3a0a 2020 2020 2020 2020 ember):. \n-0004c1e0: 2020 2020 2020 2020 6d65 6d62 6572 2e73 member.s\n-0004c1f0: 6574 7570 2869 6e74 6572 6661 6365 2c20 etup(interface, \n-0004c200: 6e61 6d65 2c20 6d65 6d62 6572 7329 0a0a name, members)..\n-0004c210: 2020 2020 2020 2020 2320 5765 206f 6e6c # We onl\n-0004c220: 7920 7374 6f72 6520 7468 6520 696e 666f y store the info\n-0004c230: 726d 6174 696f 6e20 6966 2073 6f6d 6574 rmation if somet\n-0004c240: 6869 6e67 2077 6173 2061 6374 7561 6c6c hing was actuall\n-0004c250: 7920 6465 6669 6e65 640a 2020 2020 2020 y defined. \n-0004c260: 2020 6966 2073 756d 286c 656e 2863 6174 if sum(len(cat\n-0004c270: 6567 6f72 7929 2066 6f72 2063 6174 6567 egory) for categ\n-0004c280: 6f72 7920 696e 206d 656d 6265 7273 2e76 ory in members.v\n-0004c290: 616c 7565 7328 2929 203e 2030 3a0a 2020 alues()) > 0:. \n-0004c2a0: 2020 2020 2020 2020 2020 636c 732e 5f64 cls._d\n-0004c2b0: 6275 735f 6d65 6d62 6572 7320 3d20 2869 bus_members = (i\n-0004c2c0: 6e74 6572 6661 6365 2c20 6d65 6d62 6572 nterface, member\n-0004c2d0: 7329 0a0a 2020 2020 2020 2020 2320 5468 s).. # Th\n-0004c2e0: 6973 2069 7320 7468 6520 696e 666f 726d is is the inform\n-0004c2f0: 6174 696f 6e20 666f 7220 7468 6973 2073 ation for this s\n-0004c300: 7562 636c 6173 732c 2077 6974 6820 616c ubclass, with al\n-0004c310: 6c20 6974 7320 616e 6365 7374 6f72 730a l its ancestors.\n-0004c320: 2020 2020 2020 2020 636c 732e 5f64 6275 cls._dbu\n-0004c330: 735f 696e 7465 7266 6163 6573 203d 2064 s_interfaces = d\n-0004c340: 6963 7428 616e 6365 7374 6f72 2e5f 5f64 ict(ancestor.__d\n-0004c350: 6963 745f 5f5b 275f 6462 7573 5f6d 656d ict__['_dbus_mem\n-0004c360: 6265 7273 275d 0a20 2020 2020 2020 2020 bers']. \n-0004c370: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0004c380: 2020 2020 2020 2020 2020 2066 6f72 2061 for a\n-0004c390: 6e63 6573 746f 7220 696e 2063 6c73 2e6d ncestor in cls.m\n-0004c3a0: 726f 2829 0a20 2020 2020 2020 2020 2020 ro(). \n-0004c3b0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0004c3c0: 2020 2020 2020 2020 2069 6620 275f 6462 if '_db\n-0004c3d0: 7573 5f6d 656d 6265 7273 2720 696e 2061 us_members' in a\n-0004c3e0: 6e63 6573 746f 722e 5f5f 6469 6374 5f5f ncestor.__dict__\n-0004c3f0: 290a 0a20 2020 2040 636c 6173 736d 6574 ).. @classmet\n-0004c400: 686f 640a 2020 2020 6465 6620 5f66 696e hod. def _fin\n-0004c410: 645f 696e 7465 7266 6163 6528 636c 732c d_interface(cls,\n-0004c420: 2069 6e74 6572 6661 6365 3a20 7374 7229 interface: str)\n-0004c430: 202d 3e20 4469 6374 5b73 7472 2c20 4469 -> Dict[str, Di\n-0004c440: 6374 5b73 7472 2c20 275f 4d65 6d62 6572 ct[str, '_Member\n-0004c450: 275d 5d3a 0a20 2020 2020 2020 2074 7279 ']]:. try\n-0004c460: 3a0a 2020 2020 2020 2020 2020 2020 7265 :. re\n-0004c470: 7475 726e 2063 6c73 2e5f 6462 7573 5f69 turn cls._dbus_i\n-0004c480: 6e74 6572 6661 6365 735b 696e 7465 7266 nterfaces[interf\n-0004c490: 6163 655d 0a20 2020 2020 2020 2065 7863 ace]. exc\n-0004c4a0: 6570 7420 4b65 7945 7272 6f72 2061 7320 ept KeyError as \n-0004c4b0: 6578 633a 0a20 2020 2020 2020 2020 2020 exc:. \n-0004c4c0: 2072 6169 7365 204f 626a 6563 742e 4d65 raise Object.Me\n-0004c4d0: 7468 6f64 2e55 6e68 616e 646c 6564 2066 thod.Unhandled f\n-0004c4e0: 726f 6d20 6578 630a 0a20 2020 2040 636c rom exc.. @cl\n-0004c4f0: 6173 736d 6574 686f 640a 2020 2020 6465 assmethod. de\n-0004c500: 6620 5f66 696e 645f 6361 7465 676f 7279 f _find_category\n-0004c510: 2863 6c73 2c20 696e 7465 7266 6163 653a (cls, interface:\n-0004c520: 2073 7472 2c20 6361 7465 676f 7279 3a20 str, category: \n-0004c530: 7374 7229 202d 3e20 4469 6374 5b73 7472 str) -> Dict[str\n-0004c540: 2c20 275f 4d65 6d62 6572 275d 3a0a 2020 , '_Member']:. \n-0004c550: 2020 2020 2020 7265 7475 726e 2063 6c73 return cls\n-0004c560: 2e5f 6669 6e64 5f69 6e74 6572 6661 6365 ._find_interface\n-0004c570: 2869 6e74 6572 6661 6365 295b 6361 7465 (interface)[cate\n-0004c580: 676f 7279 5d0a 0a20 2020 2040 636c 6173 gory].. @clas\n-0004c590: 736d 6574 686f 640a 2020 2020 6465 6620 smethod. def \n-0004c5a0: 5f66 696e 645f 6d65 6d62 6572 2863 6c73 _find_member(cls\n-0004c5b0: 2c20 696e 7465 7266 6163 653a 2073 7472 , interface: str\n-0004c5c0: 2c20 6361 7465 676f 7279 3a20 7374 722c , category: str,\n-0004c5d0: 206d 656d 6265 723a 2073 7472 2920 2d3e member: str) ->\n-0004c5e0: 2027 5f4d 656d 6265 7227 3a0a 2020 2020 '_Member':. \n-0004c5f0: 2020 2020 6d65 6d62 6572 7320 3d20 636c members = cl\n-0004c600: 732e 5f66 696e 645f 6361 7465 676f 7279 s._find_category\n-0004c610: 2869 6e74 6572 6661 6365 2c20 6361 7465 (interface, cate\n-0004c620: 676f 7279 290a 2020 2020 2020 2020 7472 gory). tr\n-0004c630: 793a 0a20 2020 2020 2020 2020 2020 2072 y:. r\n-0004c640: 6574 7572 6e20 6d65 6d62 6572 735b 6d65 eturn members[me\n-0004c650: 6d62 6572 5d0a 2020 2020 2020 2020 6578 mber]. ex\n-0004c660: 6365 7074 204b 6579 4572 726f 7220 6173 cept KeyError as\n-0004c670: 2065 7863 3a0a 2020 2020 2020 2020 2020 exc:. \n-0004c680: 2020 7261 6973 6520 4f62 6a65 6374 2e4d raise Object.M\n-0004c690: 6574 686f 642e 556e 6861 6e64 6c65 6420 ethod.Unhandled \n-0004c6a0: 6672 6f6d 2065 7863 0a0a 2020 2020 636c from exc.. cl\n-0004c6b0: 6173 7320 5f4d 656d 6265 723a 0a20 2020 ass _Member:. \n-0004c6c0: 2020 2020 205f 6361 7465 676f 7279 3a20 _category: \n-0004c6d0: 7374 7220 2023 2066 696c 6c65 6420 696e str # filled in\n-0004c6e0: 2066 726f 6d20 7375 6263 6c61 7373 6573 from subclasses\n-0004c6f0: 0a0a 2020 2020 2020 2020 5f70 7974 686f .. _pytho\n-0004c700: 6e5f 6e61 6d65 3a20 4f70 7469 6f6e 616c n_name: Optional\n-0004c710: 5b73 7472 5d20 3d20 4e6f 6e65 0a20 2020 [str] = None. \n-0004c720: 2020 2020 205f 6e61 6d65 3a20 4f70 7469 _name: Opti\n-0004c730: 6f6e 616c 5b73 7472 5d20 3d20 4e6f 6e65 onal[str] = None\n-0004c740: 0a20 2020 2020 2020 205f 696e 7465 7266 . _interf\n-0004c750: 6163 653a 204f 7074 696f 6e61 6c5b 7374 ace: Optional[st\n-0004c760: 725d 203d 204e 6f6e 650a 2020 2020 2020 r] = None. \n-0004c770: 2020 5f64 6573 6372 6970 7469 6f6e 3a20 _description: \n-0004c780: 4f70 7469 6f6e 616c 5b44 6963 745b 7374 Optional[Dict[st\n-0004c790: 722c 2041 6e79 5d5d 0a0a 2020 2020 2020 r, Any]].. \n-0004c7a0: 2020 6465 6620 5f5f 696e 6974 5f5f 2873 def __init__(s\n-0004c7b0: 656c 662c 206e 616d 653a 204f 7074 696f elf, name: Optio\n-0004c7c0: 6e61 6c5b 7374 725d 203d 204e 6f6e 6529 nal[str] = None)\n-0004c7d0: 202d 3e20 4e6f 6e65 3a0a 2020 2020 2020 -> None:. \n-0004c7e0: 2020 2020 2020 7365 6c66 2e5f 7079 7468 self._pyth\n-0004c7f0: 6f6e 5f6e 616d 6520 3d20 4e6f 6e65 0a20 on_name = None. \n-0004c800: 2020 2020 2020 2020 2020 2073 656c 662e self.\n-0004c810: 5f69 6e74 6572 6661 6365 203d 204e 6f6e _interface = Non\n-0004c820: 650a 2020 2020 2020 2020 2020 2020 7365 e. se\n-0004c830: 6c66 2e5f 6e61 6d65 203d 206e 616d 650a lf._name = name.\n-0004c840: 0a20 2020 2020 2020 2064 6566 2073 6574 . def set\n-0004c850: 7570 2873 656c 662c 2069 6e74 6572 6661 up(self, interfa\n-0004c860: 6365 3a20 7374 722c 206e 616d 653a 2073 ce: str, name: s\n-0004c870: 7472 2c20 6d65 6d62 6572 733a 2044 6963 tr, members: Dic\n-0004c880: 745b 7374 722c 2044 6963 745b 7374 722c t[str, Dict[str,\n-0004c890: 2027 496e 7465 7266 6163 652e 5f4d 656d 'Interface._Mem\n-0004c8a0: 6265 7227 5d5d 2920 2d3e 204e 6f6e 653a ber']]) -> None:\n-0004c8b0: 0a20 2020 2020 2020 2020 2020 2073 656c . sel\n-0004c8c0: 662e 5f70 7974 686f 6e5f 6e61 6d65 203d f._python_name =\n-0004c8d0: 206e 616d 6520 2023 2066 6f72 2065 7272 name # for err\n-0004c8e0: 6f72 206d 6573 7361 6765 730a 2020 2020 or messages. \n-0004c8f0: 2020 2020 2020 2020 6966 2073 656c 662e if self.\n-0004c900: 5f6e 616d 6520 6973 204e 6f6e 653a 0a20 _name is None:. \n-0004c910: 2020 2020 2020 2020 2020 2020 2020 2073 s\n-0004c920: 656c 662e 5f6e 616d 6520 3d20 2727 2e6a elf._name = ''.j\n-0004c930: 6f69 6e28 776f 7264 2e74 6974 6c65 2829 oin(word.title()\n-0004c940: 2066 6f72 2077 6f72 6420 696e 206e 616d for word in nam\n-0004c950: 652e 7370 6c69 7428 275f 2729 290a 2020 e.split('_')). \n-0004c960: 2020 2020 2020 2020 2020 7365 6c66 2e5f self._\n-0004c970: 696e 7465 7266 6163 6520 3d20 696e 7465 interface = inte\n-0004c980: 7266 6163 650a 2020 2020 2020 2020 2020 rface. \n-0004c990: 2020 7365 6c66 2e5f 6465 7363 7269 7074 self._descript\n-0004c9a0: 696f 6e20 3d20 7365 6c66 2e5f 6465 7363 ion = self._desc\n-0004c9b0: 7269 6265 2829 0a20 2020 2020 2020 2020 ribe(). \n-0004c9c0: 2020 206d 656d 6265 7273 5b73 656c 662e members[self.\n-0004c9d0: 5f63 6174 6567 6f72 795d 5b73 656c 662e _category][self.\n-0004c9e0: 5f6e 616d 655d 203d 2073 656c 660a 0a20 _name] = self.. \n-0004c9f0: 2020 2020 2020 2064 6566 205f 6465 7363 def _desc\n-0004ca00: 7269 6265 2873 656c 6629 202d 3e20 4469 ribe(self) -> Di\n-0004ca10: 6374 5b73 7472 2c20 416e 795d 3a0a 2020 ct[str, Any]:. \n-0004ca20: 2020 2020 2020 2020 2020 7261 6973 6520 raise \n-0004ca30: 4e6f 7449 6d70 6c65 6d65 6e74 6564 4572 NotImplementedEr\n-0004ca40: 726f 720a 0a20 2020 2020 2020 2064 6566 ror.. def\n-0004ca50: 205f 5f67 6574 6974 656d 5f5f 2873 656c __getitem__(sel\n-0004ca60: 662c 206b 6579 3a20 7374 7229 202d 3e20 f, key: str) -> \n-0004ca70: 416e 793a 0a20 2020 2020 2020 2020 2020 Any:. \n-0004ca80: 2023 2041 6374 7320 6173 2061 6e20 6164 # Acts as an ad\n-0004ca90: 6170 746f 7220 666f 7220 6469 6374 2061 aptor for dict a\n-0004caa0: 6363 6573 7365 7320 6672 6f6d 2069 6e74 ccesses from int\n-0004cab0: 726f 7370 6563 7469 6f6e 2e74 6f5f 786d rospection.to_xm\n-0004cac0: 6c28 290a 2020 2020 2020 2020 2020 2020 l(). \n-0004cad0: 6173 7365 7274 2073 656c 662e 5f64 6573 assert self._des\n-0004cae0: 6372 6970 7469 6f6e 2069 7320 6e6f 7420 cription is not \n-0004caf0: 4e6f 6e65 0a20 2020 2020 2020 2020 2020 None. \n-0004cb00: 2072 6574 7572 6e20 7365 6c66 2e5f 6465 return self._de\n-0004cb10: 7363 7269 7074 696f 6e5b 6b65 795d 0a0a scription[key]..\n-0004cb20: 2020 2020 636c 6173 7320 5072 6f70 6572 class Proper\n-0004cb30: 7479 285f 4d65 6d62 6572 293a 0a20 2020 ty(_Member):. \n-0004cb40: 2020 2020 2022 2222 4465 6669 6e65 7320 \"\"\"Defines \n-0004cb50: 6120 442d 4275 7320 7072 6f70 6572 7479 a D-Bus property\n-0004cb60: 206f 6e20 616e 2069 6e74 6572 6661 6365 on an interface\n-0004cb70: 0a0a 2020 2020 2020 2020 5468 6572 6520 .. There \n-0004cb80: 6172 6520 7477 6f20 6d61 696e 2077 6179 are two main way\n-0004cb90: 7320 746f 2064 6566 696e 6520 7072 6f70 s to define prop\n-0004cba0: 6572 7469 6573 3a20 7769 7468 2061 6e64 erties: with and\n-0004cbb0: 2077 6974 686f 7574 2067 6574 7465 7273 without getters\n-0004cbc0: 2e0a 2020 2020 2020 2020 4966 2079 6f75 .. If you\n-0004cbd0: 2064 6566 696e 6520 6120 7072 6f70 6572 define a proper\n-0004cbe0: 7479 2077 6974 686f 7574 2061 2067 6574 ty without a get\n-0004cbf0: 7465 722c 2074 6865 6e20 796f 7520 6d75 ter, then you mu\n-0004cc00: 7374 2070 726f 7669 6465 2061 0a20 2020 st provide a. \n-0004cc10: 2020 2020 2076 616c 7565 2028 7669 6120 value (via \n-0004cc20: 7468 6520 7661 6c75 653d 206b 7761 7267 the value= kwarg\n-0004cc30: 292e 2020 496e 2074 6869 7320 6361 7365 ). In this case\n-0004cc40: 2c20 7468 6520 7072 6f70 6572 7479 2076 , the property v\n-0004cc50: 616c 7565 2069 730a 2020 2020 2020 2020 alue is. \n-0004cc60: 6d61 696e 7461 696e 6564 2069 6e74 6572 maintained inter\n-0004cc70: 6e61 6c6c 7920 616e 6420 6361 6e20 6265 nally and can be\n-0004cc80: 2061 6363 6573 7365 6420 6672 6f6d 2050 accessed from P\n-0004cc90: 7974 686f 6e20 696e 2074 6865 2075 7375 ython in the usu\n-0004cca0: 616c 2077 6179 2e0a 2020 2020 2020 2020 al way.. \n-0004ccb0: 4368 616e 6765 2073 6967 6e61 6c73 2061 Change signals a\n-0004ccc0: 7265 2073 656e 7420 6175 746f 6d61 7469 re sent automati\n-0004ccd0: 6361 6c6c 792e 0a0a 2020 2020 2020 2020 cally... \n-0004cce0: 2020 2020 636c 6173 7320 4d79 4f62 6a65 class MyObje\n-0004ccf0: 6374 2862 7573 2e4f 626a 6563 7429 3a0a ct(bus.Object):.\n-0004cd00: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0004cd10: 636f 756e 7465 7220 3d20 6275 732e 496e counter = bus.In\n-0004cd20: 7465 7266 6163 652e 5072 6f70 6572 7479 terface.Property\n-0004cd30: 2827 6927 2c20 7661 6c75 653d 3029 0a0a ('i', value=0)..\n-0004cd40: 2020 2020 2020 2020 2020 2020 6120 3d20 a = \n-0004cd50: 4d79 4f62 6a65 6374 2829 0a20 2020 2020 MyObject(). \n-0004cd60: 2020 2020 2020 2061 2e63 6f75 6e74 6572 a.counter\n-0004cd70: 203d 2035 0a20 2020 2020 2020 2020 2020 = 5. \n-0004cd80: 2061 2e63 6f75 6e74 6572 202b 3d20 310a a.counter += 1.\n-0004cd90: 2020 2020 2020 2020 2020 2020 7072 696e prin\n-0004cda0: 7428 612e 636f 756e 7465 7229 0a0a 2020 t(a.counter).. \n-0004cdb0: 2020 2020 2020 5468 6520 6f74 6865 7220 The other \n-0004cdc0: 7761 7920 746f 2064 6566 696e 6520 7072 way to define pr\n-0004cdd0: 6f70 6572 7469 6573 2069 7320 7769 7468 operties is with\n-0004cde0: 2061 2067 6574 7465 7220 6675 6e63 7469 a getter functi\n-0004cdf0: 6f6e 2e20 2049 6e20 7468 6973 0a20 2020 on. In this. \n-0004ce00: 2020 2020 2063 6173 652c 2079 6f75 2063 case, you c\n-0004ce10: 616e 2072 6561 6420 6672 6f6d 2074 6865 an read from the\n-0004ce20: 2070 726f 7065 7274 7920 696e 2074 6865 property in the\n-0004ce30: 206e 6f72 6d61 6c20 7761 792c 2062 7574 normal way, but\n-0004ce40: 206e 6f74 2077 7269 7465 0a20 2020 2020 not write. \n-0004ce50: 2020 2074 6f20 6974 2e20 2059 6f75 2061 to it. You a\n-0004ce60: 7265 2072 6573 706f 6e73 6962 6c65 2066 re responsible f\n-0004ce70: 6f72 2065 6d69 7474 696e 6720 6368 616e or emitting chan\n-0004ce80: 6765 2073 6967 6e61 6c73 2066 6f72 2079 ge signals for y\n-0004ce90: 6f75 7273 656c 662e 0a20 2020 2020 2020 ourself.. \n-0004cea0: 2059 6f75 206d 7573 7420 6e6f 7420 7072 You must not pr\n-0004ceb0: 6f76 6964 6520 7468 6520 7661 6c75 653d ovide the value=\n-0004cec0: 206b 7761 7267 2e0a 0a20 2020 2020 2020 kwarg... \n-0004ced0: 2020 2020 2063 6c61 7373 204d 794f 626a class MyObj\n-0004cee0: 6563 7428 6275 732e 4f62 6a65 6374 293a ect(bus.Object):\n-0004cef0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-0004cf00: 205f 636f 756e 7465 7220 3d20 300a 0a20 _counter = 0.. \n-0004cf10: 2020 2020 2020 2020 2020 2020 2020 2063 c\n-0004cf20: 6f75 6e74 6572 203d 2062 7573 2e49 6e74 ounter = bus.Int\n-0004cf30: 6572 6661 6365 2e50 726f 7065 7274 7928 erface.Property(\n-0004cf40: 2769 2729 0a20 2020 2020 2020 2020 2020 'i'). \n-0004cf50: 2020 2020 2040 636f 756e 7465 722e 6765 @counter.ge\n-0004cf60: 7474 6572 0a20 2020 2020 2020 2020 2020 tter. \n-0004cf70: 2020 2020 2064 6566 2067 6574 5f63 6f75 def get_cou\n-0004cf80: 6e74 6572 2873 656c 6629 3a0a 2020 2020 nter(self):. \n-0004cf90: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0004cfa0: 7265 7475 726e 2073 656c 662e 5f63 6f75 return self._cou\n-0004cfb0: 6e74 6572 0a0a 2020 2020 2020 2020 2020 nter.. \n-0004cfc0: 2020 2020 2020 4063 6f75 6e74 6572 2e73 @counter.s\n-0004cfd0: 6574 7465 720a 2020 2020 2020 2020 2020 etter. \n-0004cfe0: 2020 2020 2020 6465 6620 7365 745f 636f def set_co\n-0004cff0: 756e 7465 7228 7365 6c66 2c20 7661 6c75 unter(self, valu\n-0004d000: 6529 3a0a 2020 2020 2020 2020 2020 2020 e):. \n-0004d010: 2020 2020 2020 2020 7365 6c66 2e5f 636f self._co\n-0004d020: 756e 7465 7220 3d20 7661 6c75 650a 2020 unter = value. \n-0004d030: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0004d040: 2020 7365 6c66 2e70 726f 7065 7274 795f self.property_\n-0004d050: 6368 616e 6765 6428 2743 6f75 6e74 6572 changed('Counter\n-0004d060: 2729 0a0a 2020 2020 2020 2020 496e 2065 ').. In e\n-0004d070: 6974 6865 7220 6361 7365 2c20 796f 7520 ither case, you \n-0004d080: 6361 6e20 7072 6f76 6964 6520 6120 7365 can provide a se\n-0004d090: 7474 6572 2066 756e 6374 696f 6e2e 2020 tter function. \n-0004d0a0: 5468 6973 2066 756e 6374 696f 6e20 6861 This function ha\n-0004d0b0: 730a 2020 2020 2020 2020 6e6f 2069 6d70 s. no imp\n-0004d0c0: 6163 7420 6f6e 2050 7974 686f 6e20 636f act on Python co\n-0004d0d0: 6465 2c20 6275 7420 6d61 6b65 7320 7468 de, but makes th\n-0004d0e0: 6520 7072 6f70 6572 7479 2077 7269 7461 e property writa\n-0004d0f0: 626c 6520 6672 6f6d 2074 6865 2076 6965 ble from the vie\n-0004d100: 770a 2020 2020 2020 2020 6f66 2044 2d42 w. of D-B\n-0004d110: 7573 2e20 2059 6f75 7220 7365 7474 6572 us. Your setter\n-0004d120: 2077 696c 6c20 6265 2063 616c 6c65 6420 will be called \n-0004d130: 7768 656e 2061 2050 726f 7065 7274 6965 when a Propertie\n-0004d140: 732e 5365 7428 2920 6361 6c6c 2069 730a s.Set() call is.\n-0004d150: 2020 2020 2020 2020 6d61 6465 2c20 616e made, an\n-0004d160: 6420 6e6f 206f 7468 6572 2061 6374 696f d no other actio\n-0004d170: 6e20 7769 6c6c 2062 6520 7065 7266 6f72 n will be perfor\n-0004d180: 6d65 642e 2020 4120 7472 6976 6961 6c20 med. A trivial \n-0004d190: 696d 706c 656d 656e 7461 7469 6f6e 0a20 implementation. \n-0004d1a0: 2020 2020 2020 206d 6967 6874 206c 6f6f might loo\n-0004d1b0: 6b20 6c69 6b65 3a0a 0a20 2020 2020 2020 k like:.. \n-0004d1c0: 2020 2020 2063 6c61 7373 204d 794f 626a class MyObj\n-0004d1d0: 6563 7428 6275 732e 4f62 6a65 6374 293a ect(bus.Object):\n-0004d1e0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-0004d1f0: 2063 6f75 6e74 6572 203d 2062 7573 2e49 counter = bus.I\n-0004d200: 6e74 6572 6661 6365 2e50 726f 7065 7274 nterface.Propert\n-0004d210: 7928 2769 272c 2076 616c 7565 3d30 290a y('i', value=0).\n-0004d220: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0004d230: 4063 6f75 6e74 6572 2e73 6574 7465 720a @counter.setter.\n-0004d240: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0004d250: 6465 6620 7365 745f 636f 756e 7465 7228 def set_counter(\n-0004d260: 7365 6c66 2c20 7661 6c75 6529 3a0a 2020 self, value):. \n-0004d270: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0004d280: 2020 2320 7765 2067 6f74 2061 2072 6571 # we got a req\n-0004d290: 7565 7374 2074 6f20 7365 7420 7468 6520 uest to set the \n-0004d2a0: 636f 756e 7465 7220 6672 6f6d 2044 2d42 counter from D-B\n-0004d2b0: 7573 0a20 2020 2020 2020 2020 2020 2020 us. \n-0004d2c0: 2020 2020 2020 2073 656c 662e 636f 756e self.coun\n-0004d2d0: 7465 7220 3d20 7661 6c75 650a 0a20 2020 ter = value.. \n-0004d2e0: 2020 2020 2049 6e20 616c 6c20 6361 7365 In all case\n-0004d2f0: 732c 2074 6865 2066 6972 7374 2028 616e s, the first (an\n-0004d300: 6420 6f6e 6c79 206d 616e 6461 746f 7279 d only mandatory\n-0004d310: 2920 6172 6775 6d65 6e74 2074 6f20 7468 ) argument to th\n-0004d320: 650a 2020 2020 2020 2020 636f 6e73 7472 e. constr\n-0004d330: 7563 746f 7220 6973 2074 6865 2044 2d42 uctor is the D-B\n-0004d340: 7573 2074 7970 6520 6f66 2074 6865 2070 us type of the p\n-0004d350: 726f 7065 7274 792e 0a0a 2020 2020 2020 roperty... \n-0004d360: 2020 596f 7572 2067 6574 7465 7220 616e Your getter an\n-0004d370: 6420 7365 7474 6572 2066 756e 6374 696f d setter functio\n-0004d380: 6e73 2063 616e 2062 6520 7072 6f76 6964 ns can be provid\n-0004d390: 6564 2062 7920 6b77 6172 6720 746f 2074 ed by kwarg to t\n-0004d3a0: 6865 0a20 2020 2020 2020 2063 6f6e 7374 he. const\n-0004d3b0: 7275 6374 6f72 2e20 2059 6f75 2063 616e ructor. You can\n-0004d3c0: 2061 6c73 6f20 6769 7665 2061 206e 616d also give a nam\n-0004d3d0: 653d 206b 7761 7267 2074 6f20 6f76 6572 e= kwarg to over\n-0004d3e0: 7269 6465 2074 6865 2064 6566 6175 6c74 ride the default\n-0004d3f0: 0a20 2020 2020 2020 206e 616d 6520 636f . name co\n-0004d400: 6e76 6572 7369 6f6e 2073 6368 656d 652e nversion scheme.\n-0004d410: 0a20 2020 2020 2020 2022 2222 0a20 2020 . \"\"\". \n-0004d420: 2020 2020 205f 6361 7465 676f 7279 203d _category =\n-0004d430: 2027 7072 6f70 6572 7469 6573 270a 0a20 'properties'.. \n-0004d440: 2020 2020 2020 205f 6765 7474 6572 3a20 _getter: \n-0004d450: 4f70 7469 6f6e 616c 5b43 616c 6c61 626c Optional[Callabl\n-0004d460: 655b 5b41 6e79 5d2c 2041 6e79 5d5d 0a20 e[[Any], Any]]. \n-0004d470: 2020 2020 2020 205f 7365 7474 6572 3a20 _setter: \n-0004d480: 4f70 7469 6f6e 616c 5b43 616c 6c61 626c Optional[Callabl\n-0004d490: 655b 5b41 6e79 2c20 416e 795d 2c20 4e6f e[[Any, Any], No\n-0004d4a0: 6e65 5d5d 0a20 2020 2020 2020 205f 7479 ne]]. _ty\n-0004d4b0: 7065 3a20 6275 7374 7970 6573 2e54 7970 pe: bustypes.Typ\n-0004d4c0: 650a 2020 2020 2020 2020 5f76 616c 7565 e. _value\n-0004d4d0: 3a20 416e 790a 0a20 2020 2020 2020 2064 : Any.. d\n-0004d4e0: 6566 205f 5f69 6e69 745f 5f28 7365 6c66 ef __init__(self\n-0004d4f0: 2c20 7479 7065 5f73 7472 696e 673a 2073 , type_string: s\n-0004d500: 7472 2c0a 2020 2020 2020 2020 2020 2020 tr,. \n-0004d510: 2020 2020 2020 2020 2076 616c 7565 3a20 value: \n-0004d520: 416e 7920 3d20 4e6f 6e65 2c0a 2020 2020 Any = None,. \n-0004d530: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0004d540: 206e 616d 653a 204f 7074 696f 6e61 6c5b name: Optional[\n-0004d550: 7374 725d 203d 204e 6f6e 652c 0a20 2020 str] = None,. \n-0004d560: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0004d570: 2020 6765 7474 6572 3a20 4f70 7469 6f6e getter: Option\n-0004d580: 616c 5b43 616c 6c61 626c 655b 5b41 6e79 al[Callable[[Any\n-0004d590: 5d2c 2041 6e79 5d5d 203d 204e 6f6e 652c ], Any]] = None,\n-0004d5a0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-0004d5b0: 2020 2020 2020 7365 7474 6572 3a20 4f70 setter: Op\n-0004d5c0: 7469 6f6e 616c 5b43 616c 6c61 626c 655b tional[Callable[\n-0004d5d0: 5b41 6e79 2c20 416e 795d 2c20 4e6f 6e65 [Any, Any], None\n-0004d5e0: 5d5d 203d 204e 6f6e 6529 3a0a 2020 2020 ]] = None):. \n-0004d5f0: 2020 2020 2020 2020 6173 7365 7274 2076 assert v\n-0004d600: 616c 7565 2069 7320 4e6f 6e65 206f 7220 alue is None or \n-0004d610: 6765 7474 6572 2069 7320 4e6f 6e65 2c20 getter is None, \n-0004d620: 2741 2070 726f 7065 7274 7920 6361 6e6e 'A property cann\n-0004d630: 6f74 2068 6176 6520 626f 7468 2061 2076 ot have both a v\n-0004d640: 616c 7565 2061 6e64 2061 2067 6574 7465 alue and a gette\n-0004d650: 7227 0a0a 2020 2020 2020 2020 2020 2020 r'.. \n-0004d660: 7375 7065 7228 292e 5f5f 696e 6974 5f5f super().__init__\n-0004d670: 286e 616d 653d 6e61 6d65 290a 2020 2020 (name=name). \n-0004d680: 2020 2020 2020 2020 7365 6c66 2e5f 6765 self._ge\n-0004d690: 7474 6572 203d 2067 6574 7465 720a 2020 tter = getter. \n-0004d6a0: 2020 2020 2020 2020 2020 7365 6c66 2e5f self._\n-0004d6b0: 7365 7474 6572 203d 2073 6574 7465 720a setter = setter.\n-0004d6c0: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n-0004d6d0: 2e5f 7479 7065 2c20 3d20 6275 7374 7970 ._type, = bustyp\n-0004d6e0: 6573 2e66 726f 6d5f 7369 676e 6174 7572 es.from_signatur\n-0004d6f0: 6528 7479 7065 5f73 7472 696e 6729 0a20 e(type_string). \n-0004d700: 2020 2020 2020 2020 2020 2073 656c 662e self.\n-0004d710: 5f76 616c 7565 203d 2076 616c 7565 0a0a _value = value..\n-0004d720: 2020 2020 2020 2020 6465 6620 5f64 6573 def _des\n-0004d730: 6372 6962 6528 7365 6c66 2920 2d3e 2044 cribe(self) -> D\n-0004d740: 6963 745b 7374 722c 2041 6e79 5d3a 0a20 ict[str, Any]:. \n-0004d750: 2020 2020 2020 2020 2020 2072 6574 7572 retur\n-0004d760: 6e20 7b27 7479 7065 273a 2073 656c 662e n {'type': self.\n-0004d770: 5f74 7970 652e 7479 7065 7374 7269 6e67 _type.typestring\n-0004d780: 2c20 2766 6c61 6773 273a 2027 7227 2069 , 'flags': 'r' i\n-0004d790: 6620 7365 6c66 2e5f 7365 7474 6572 2069 f self._setter i\n-0004d7a0: 7320 4e6f 6e65 2065 6c73 6520 2777 277d s None else 'w'}\n-0004d7b0: 0a0a 2020 2020 2020 2020 6465 6620 5f5f .. def __\n-0004d7c0: 6765 745f 5f28 7365 6c66 2c20 6f62 6a3a get__(self, obj:\n-0004d7d0: 2027 4f62 6a65 6374 272c 2063 6c73 3a20 'Object', cls: \n-0004d7e0: 4f70 7469 6f6e 616c 5b74 7970 655d 203d Optional[type] =\n-0004d7f0: 204e 6f6e 6529 202d 3e20 416e 793a 0a20 None) -> Any:. \n-0004d800: 2020 2020 2020 2020 2020 2061 7373 6572 asser\n-0004d810: 7420 7365 6c66 2e5f 6e61 6d65 2069 7320 t self._name is \n-0004d820: 6e6f 7420 4e6f 6e65 0a20 2020 2020 2020 not None. \n-0004d830: 2020 2020 2069 6620 6f62 6a20 6973 204e if obj is N\n-0004d840: 6f6e 653a 0a20 2020 2020 2020 2020 2020 one:. \n-0004d850: 2020 2020 2072 6574 7572 6e20 7365 6c66 return self\n-0004d860: 0a20 2020 2020 2020 2020 2020 2069 6620 . if \n-0004d870: 7365 6c66 2e5f 6765 7474 6572 2069 7320 self._getter is \n-0004d880: 6e6f 7420 4e6f 6e65 3a0a 2020 2020 2020 not None:. \n-0004d890: 2020 2020 2020 2020 2020 7265 7475 726e return\n-0004d8a0: 2073 656c 662e 5f67 6574 7465 722e 5f5f self._getter.__\n-0004d8b0: 6765 745f 5f28 6f62 6a2c 2063 6c73 2928 get__(obj, cls)(\n-0004d8c0: 290a 2020 2020 2020 2020 2020 2020 656c ). el\n-0004d8d0: 6966 2073 656c 662e 5f76 616c 7565 2069 if self._value i\n-0004d8e0: 7320 6e6f 7420 4e6f 6e65 3a0a 2020 2020 s not None:. \n-0004d8f0: 2020 2020 2020 2020 2020 2020 6966 206f if o\n-0004d900: 626a 2e5f 6462 7573 5f70 726f 7065 7274 bj._dbus_propert\n-0004d910: 795f 7661 6c75 6573 2069 7320 6e6f 7420 y_values is not \n-0004d920: 4e6f 6e65 3a0a 2020 2020 2020 2020 2020 None:. \n-0004d930: 2020 2020 2020 2020 2020 7265 7475 726e return\n-0004d940: 206f 626a 2e5f 6462 7573 5f70 726f 7065 obj._dbus_prope\n-0004d950: 7274 795f 7661 6c75 6573 2e67 6574 2873 rty_values.get(s\n-0004d960: 656c 662e 5f6e 616d 652c 2073 656c 662e elf._name, self.\n-0004d970: 5f76 616c 7565 290a 2020 2020 2020 2020 _value). \n-0004d980: 2020 2020 2020 2020 656c 7365 3a0a 2020 else:. \n-0004d990: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0004d9a0: 2020 7265 7475 726e 2073 656c 662e 5f76 return self._v\n-0004d9b0: 616c 7565 0a20 2020 2020 2020 2020 2020 alue. \n-0004d9c0: 2065 6c73 653a 0a20 2020 2020 2020 2020 else:. \n-0004d9d0: 2020 2020 2020 2072 6169 7365 2041 7474 raise Att\n-0004d9e0: 7269 6275 7465 4572 726f 7228 6622 277b ributeError(f\"'{\n-0004d9f0: 6f62 6a2e 5f5f 636c 6173 735f 5f2e 5f5f obj.__class__.__\n-0004da00: 6e61 6d65 5f5f 7d27 2070 726f 7065 7274 name__}' propert\n-0004da10: 7920 277b 7365 6c66 2e5f 7079 7468 6f6e y '{self._python\n-0004da20: 5f6e 616d 657d 2720 220a 2020 2020 2020 _name}' \". \n-0004da30: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0004da40: 2020 2020 2020 2020 2020 2020 2020 2066 f\n-0004da50: 2277 6173 206e 6f74 2070 726f 7065 726c \"was not properl\n-0004da60: 7920 696e 6974 6961 6c69 7365 643a 2075 y initialised: u\n-0004da70: 7365 2065 6974 6865 7220 7468 6520 2776 se either the 'v\n-0004da80: 616c 7565 3d27 206b 7761 7267 206f 7220 alue=' kwarg or \n-0004da90: 220a 2020 2020 2020 2020 2020 2020 2020 \". \n-0004daa0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0004dab0: 2020 2020 2020 2066 2274 6865 2040 277b f\"the @'{\n-0004dac0: 7365 6c66 2e5f 7079 7468 6f6e 5f6e 616d self._python_nam\n-0004dad0: 657d 2e67 6574 7465 7227 2064 6563 6f72 e}.getter' decor\n-0004dae0: 6174 6f72 2229 0a0a 2020 2020 2020 2020 ator\").. \n-0004daf0: 6465 6620 5f5f 7365 745f 5f28 7365 6c66 def __set__(self\n-0004db00: 2c20 6f62 6a3a 2027 4f62 6a65 6374 272c , obj: 'Object',\n-0004db10: 2076 616c 7565 3a20 416e 7929 202d 3e20 value: Any) -> \n-0004db20: 4e6f 6e65 3a0a 2020 2020 2020 2020 2020 None:. \n-0004db30: 2020 6173 7365 7274 2073 656c 662e 5f6e assert self._n\n-0004db40: 616d 6520 6973 206e 6f74 204e 6f6e 650a ame is not None.\n-0004db50: 2020 2020 2020 2020 2020 2020 6966 2073 if s\n-0004db60: 656c 662e 5f67 6574 7465 7220 6973 206e elf._getter is n\n-0004db70: 6f74 204e 6f6e 653a 0a20 2020 2020 2020 ot None:. \n-0004db80: 2020 2020 2020 2020 2072 6169 7365 2041 raise A\n-0004db90: 7474 7269 6275 7465 4572 726f 7228 6622 ttributeError(f\"\n-0004dba0: 4361 6e6e 6f74 2064 6972 6563 746c 7920 Cannot directly \n-0004dbb0: 6173 7369 676e 2027 7b6f 626a 2e5f 5f63 assign '{obj.__c\n-0004dbc0: 6c61 7373 5f5f 2e5f 5f6e 616d 655f 5f7d lass__.__name__}\n-0004dbd0: 2720 220a 2020 2020 2020 2020 2020 2020 ' \". \n-0004dbe0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0004dbf0: 2020 2020 2020 2020 2022 7072 6f70 6572 \"proper\n-0004dc00: 7479 2027 7b73 656c 662e 5f70 7974 686f ty '{self._pytho\n-0004dc10: 6e5f 6e61 6d65 7d27 2062 6563 6175 7365 n_name}' because\n-0004dc20: 2069 7420 6861 7320 6120 6765 7474 6572 it has a getter\n-0004dc30: 2229 0a20 2020 2020 2020 2020 2020 2069 \"). i\n-0004dc40: 6620 6f62 6a2e 5f64 6275 735f 7072 6f70 f obj._dbus_prop\n-0004dc50: 6572 7479 5f76 616c 7565 7320 6973 204e erty_values is N\n-0004dc60: 6f6e 653a 0a20 2020 2020 2020 2020 2020 one:. \n-0004dc70: 2020 2020 206f 626a 2e5f 6462 7573 5f70 obj._dbus_p\n-0004dc80: 726f 7065 7274 795f 7661 6c75 6573 203d roperty_values =\n-0004dc90: 207b 7d0a 2020 2020 2020 2020 2020 2020 {}. \n-0004dca0: 6f62 6a2e 5f64 6275 735f 7072 6f70 6572 obj._dbus_proper\n-0004dcb0: 7479 5f76 616c 7565 735b 7365 6c66 2e5f ty_values[self._\n-0004dcc0: 6e61 6d65 5d20 3d20 7661 6c75 650a 2020 name] = value. \n-0004dcd0: 2020 2020 2020 2020 2020 6966 206f 626a if obj\n-0004dce0: 2e5f 6462 7573 5f62 7573 2069 7320 6e6f ._dbus_bus is no\n-0004dcf0: 7420 4e6f 6e65 3a0a 2020 2020 2020 2020 t None:. \n-0004dd00: 2020 2020 2020 2020 6f62 6a2e 7072 6f70 obj.prop\n-0004dd10: 6572 7469 6573 5f63 6861 6e67 6564 2873 erties_changed(s\n-0004dd20: 656c 662e 5f69 6e74 6572 6661 6365 2c20 elf._interface, \n-0004dd30: 7b73 656c 662e 5f6e 616d 653a 2062 7573 {self._name: bus\n-0004dd40: 7479 7065 732e 5661 7269 616e 7428 7661 types.Variant(va\n-0004dd50: 6c75 652c 2073 656c 662e 5f74 7970 6529 lue, self._type)\n-0004dd60: 7d2c 205b 5d29 0a0a 2020 2020 2020 2020 }, []).. \n-0004dd70: 6465 6620 746f 5f64 6275 7328 7365 6c66 def to_dbus(self\n-0004dd80: 2c20 6f62 6a3a 2027 4f62 6a65 6374 2729 , obj: 'Object')\n-0004dd90: 202d 3e20 6275 7374 7970 6573 2e56 6172 -> bustypes.Var\n-0004dda0: 6961 6e74 3a0a 2020 2020 2020 2020 2020 iant:. \n-0004ddb0: 2020 7265 7475 726e 2062 7573 7479 7065 return bustype\n-0004ddc0: 732e 5661 7269 616e 7428 7365 6c66 2e5f s.Variant(self._\n-0004ddd0: 5f67 6574 5f5f 286f 626a 292c 2073 656c _get__(obj), sel\n-0004dde0: 662e 5f74 7970 6529 0a0a 2020 2020 2020 f._type).. \n-0004ddf0: 2020 6465 6620 6672 6f6d 5f64 6275 7328 def from_dbus(\n-0004de00: 7365 6c66 2c20 6f62 6a3a 2027 4f62 6a65 self, obj: 'Obje\n-0004de10: 6374 272c 2076 616c 7565 3a20 6275 7374 ct', value: bust\n-0004de20: 7970 6573 2e56 6172 6961 6e74 2920 2d3e ypes.Variant) ->\n-0004de30: 204e 6f6e 653a 0a20 2020 2020 2020 2020 None:. \n-0004de40: 2020 2069 6620 7365 6c66 2e5f 7365 7474 if self._sett\n-0004de50: 6572 2069 7320 4e6f 6e65 206f 7220 7365 er is None or se\n-0004de60: 6c66 2e5f 7479 7065 2021 3d20 7661 6c75 lf._type != valu\n-0004de70: 652e 7479 7065 3a0a 2020 2020 2020 2020 e.type:. \n-0004de80: 2020 2020 2020 2020 7261 6973 6520 4f62 raise Ob\n-0004de90: 6a65 6374 2e4d 6574 686f 642e 556e 6861 ject.Method.Unha\n-0004dea0: 6e64 6c65 640a 2020 2020 2020 2020 2020 ndled. \n-0004deb0: 2020 7365 6c66 2e5f 7365 7474 6572 2e5f self._setter._\n-0004dec0: 5f67 6574 5f5f 286f 626a 2928 7661 6c75 _get__(obj)(valu\n-0004ded0: 652e 7661 6c75 6529 0a0a 2020 2020 2020 e.value).. \n-0004dee0: 2020 6465 6620 6765 7474 6572 2873 656c def getter(sel\n-0004def0: 662c 2067 6574 7465 723a 2043 616c 6c61 f, getter: Calla\n-0004df00: 626c 655b 5b41 6e79 5d2c 2041 6e79 5d29 ble[[Any], Any])\n-0004df10: 202d 3e20 4361 6c6c 6162 6c65 5b5b 416e -> Callable[[An\n-0004df20: 795d 2c20 416e 795d 3a0a 2020 2020 2020 y], Any]:. \n-0004df30: 2020 2020 2020 6966 2073 656c 662e 5f76 if self._v\n-0004df40: 616c 7565 2069 7320 6e6f 7420 4e6f 6e65 alue is not None\n-0004df50: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n-0004df60: 2020 7261 6973 6520 5661 6c75 6545 7272 raise ValueErr\n-0004df70: 6f72 2827 4120 7072 6f70 6572 7479 2063 or('A property c\n-0004df80: 616e 6e6f 7420 6861 7665 2062 6f74 6820 annot have both \n-0004df90: 6120 7661 6c75 6520 616e 6420 6120 6765 a value and a ge\n-0004dfa0: 7474 6572 2729 0a20 2020 2020 2020 2020 tter'). \n-0004dfb0: 2020 2069 6620 7365 6c66 2e5f 6765 7474 if self._gett\n-0004dfc0: 6572 2069 7320 6e6f 7420 4e6f 6e65 3a0a er is not None:.\n-0004dfd0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0004dfe0: 7261 6973 6520 5661 6c75 6545 7272 6f72 raise ValueError\n-0004dff0: 2827 5468 6973 2070 726f 7065 7274 7920 ('This property \n-0004e000: 616c 7265 6164 7920 6861 7320 6120 6765 already has a ge\n-0004e010: 7474 6572 2729 0a20 2020 2020 2020 2020 tter'). \n-0004e020: 2020 2073 656c 662e 5f67 6574 7465 7220 self._getter \n-0004e030: 3d20 6765 7474 6572 0a20 2020 2020 2020 = getter. \n-0004e040: 2020 2020 2072 6574 7572 6e20 6765 7474 return gett\n-0004e050: 6572 0a0a 2020 2020 2020 2020 6465 6620 er.. def \n-0004e060: 7365 7474 6572 2873 656c 662c 2073 6574 setter(self, set\n-0004e070: 7465 723a 2043 616c 6c61 626c 655b 5b41 ter: Callable[[A\n-0004e080: 6e79 2c20 416e 795d 2c20 4e6f 6e65 5d29 ny, Any], None])\n-0004e090: 202d 3e20 4361 6c6c 6162 6c65 5b5b 416e -> Callable[[An\n-0004e0a0: 792c 2041 6e79 5d2c 204e 6f6e 655d 3a0a y, Any], None]:.\n+00038b70: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00038b80: 2020 2020 6e61 6d65 2c20 696e 762c 2073 name, inv, s\n+00038b90: 656c 662e 6e61 6d65 2c20 7061 7468 2c20 elf.name, path, \n+00038ba0: 7374 7228 6578 6329 290a 2020 2020 2020 str(exc)). \n+00038bb0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00038bc0: 2020 636f 6e74 696e 7565 0a20 2020 2020 continue. \n+00038bd0: 2020 2020 2020 2020 2020 2020 2020 2070 p\n+00038be0: 726f 7073 5b69 6e76 5d20 3d20 7265 706c rops[inv] = repl\n+00038bf0: 790a 2020 2020 2020 2020 2020 2020 2020 y. \n+00038c00: 2020 6e6f 7469 6679 203d 207b 7d0a 2020 notify = {}. \n+00038c10: 2020 2020 2020 2020 2020 2020 2020 6e6f no\n+00038c20: 7469 6679 5f75 7064 6174 6528 6e6f 7469 tify_update(noti\n+00038c30: 6679 2c20 7061 7468 2c20 6e61 6d65 2c20 fy, path, name, \n+00038c40: 7072 6f70 7329 0a20 2020 2020 2020 2020 props). \n+00038c50: 2020 2020 2020 2073 656c 662e 7365 6e64 self.send\n+00038c60: 5f6a 736f 6e28 6e6f 7469 6679 3d6e 6f74 _json(notify=not\n+00038c70: 6966 7929 0a0a 2020 2020 2020 2020 7468 ify).. th\n+00038c80: 6973 5f6d 6574 6120 3d20 6177 6169 7420 is_meta = await \n+00038c90: 7365 6c66 2e63 6163 6865 2e69 6e74 726f self.cache.intro\n+00038ca0: 7370 6563 745f 7061 7468 2873 656c 662e spect_path(self.\n+00038cb0: 6275 732c 2073 656c 662e 6e61 6d65 2c20 bus, self.name, \n+00038cc0: 7061 7468 290a 2020 2020 2020 2020 6966 path). if\n+00038cd0: 2069 6e74 6572 6661 6365 5f6e 616d 6520 interface_name \n+00038ce0: 6973 206e 6f74 204e 6f6e 653a 0a20 2020 is not None:. \n+00038cf0: 2020 2020 2020 2020 2069 6e74 6572 6661 interfa\n+00038d00: 6365 203d 2074 6869 735f 6d65 7461 2e67 ce = this_meta.g\n+00038d10: 6574 2869 6e74 6572 6661 6365 5f6e 616d et(interface_nam\n+00038d20: 6529 0a20 2020 2020 2020 2020 2020 2074 e). t\n+00038d30: 6869 735f 6d65 7461 203d 207b 696e 7465 his_meta = {inte\n+00038d40: 7266 6163 655f 6e61 6d65 3a20 696e 7465 rface_name: inte\n+00038d50: 7266 6163 657d 0a20 2020 2020 2020 206d rface}. m\n+00038d60: 6574 612e 7570 6461 7465 2874 6869 735f eta.update(this_\n+00038d70: 6d65 7461 290a 2020 2020 2020 2020 6966 meta). if\n+00038d80: 2072 6563 7572 7369 7665 5f70 726f 7073 recursive_props\n+00038d90: 3a0a 2020 2020 2020 2020 2020 2020 7365 :. se\n+00038da0: 6c66 2e61 6464 5f61 7379 6e63 5f73 6967 lf.add_async_sig\n+00038db0: 6e61 6c5f 6861 6e64 6c65 7228 6861 6e64 nal_handler(hand\n+00038dc0: 6c65 722c 0a20 2020 2020 2020 2020 2020 ler,. \n+00038dd0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00038de0: 2020 2020 2020 2020 2020 2020 2020 2069 i\n+00038df0: 6e74 6572 6661 6365 3d22 6f72 672e 6672 nterface=\"org.fr\n+00038e00: 6565 6465 736b 746f 702e 4442 7573 2e50 eedesktop.DBus.P\n+00038e10: 726f 7065 7274 6965 7322 2c0a 2020 2020 roperties\",. \n+00038e20: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00038e30: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00038e40: 2020 2020 2020 7061 7468 5f6e 616d 6573 path_names\n+00038e50: 7061 6365 3d70 6174 6829 0a20 2020 2020 pace=path). \n+00038e60: 2020 2065 6c73 653a 0a20 2020 2020 2020 else:. \n+00038e70: 2020 2020 2073 656c 662e 6164 645f 6173 self.add_as\n+00038e80: 796e 635f 7369 676e 616c 5f68 616e 646c ync_signal_handl\n+00038e90: 6572 2868 616e 646c 6572 2c0a 2020 2020 er(handler,. \n+00038ea0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00038eb0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00038ec0: 2020 2020 2020 696e 7465 7266 6163 653d interface=\n+00038ed0: 226f 7267 2e66 7265 6564 6573 6b74 6f70 \"org.freedesktop\n+00038ee0: 2e44 4275 732e 5072 6f70 6572 7469 6573 .DBus.Properties\n+00038ef0: 222c 0a20 2020 2020 2020 2020 2020 2020 \",. \n+00038f00: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00038f10: 2020 2020 2020 2020 2020 2020 2070 6174 pat\n+00038f20: 683d 7061 7468 290a 0a20 2020 2020 2020 h=path).. \n+00038f30: 2066 6f72 206e 616d 6520 696e 206d 6574 for name in met\n+00038f40: 613a 0a20 2020 2020 2020 2020 2020 2069 a:. i\n+00038f50: 6620 6e61 6d65 2e73 7461 7274 7377 6974 f name.startswit\n+00038f60: 6828 226f 7267 2e66 7265 6564 6573 6b74 h(\"org.freedeskt\n+00038f70: 6f70 2e44 4275 732e 2229 3a0a 2020 2020 op.DBus.\"):. \n+00038f80: 2020 2020 2020 2020 2020 2020 636f 6e74 cont\n+00038f90: 696e 7565 0a20 2020 2020 2020 2020 2020 inue. \n+00038fa0: 2074 7279 3a0a 2020 2020 2020 2020 2020 try:. \n+00038fb0: 2020 2020 2020 7072 6f70 732c 203d 2061 props, = a\n+00038fc0: 7761 6974 2073 656c 662e 6275 732e 6361 wait self.bus.ca\n+00038fd0: 6c6c 5f6d 6574 686f 645f 6173 796e 6328 ll_method_async(\n+00038fe0: 7365 6c66 2e6e 616d 652c 2070 6174 682c self.name, path,\n+00038ff0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+00039000: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00039010: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00039020: 2020 2020 2020 2020 2020 2027 6f72 672e 'org.\n+00039030: 6672 6565 6465 736b 746f 702e 4442 7573 freedesktop.DBus\n+00039040: 2e50 726f 7065 7274 6965 7327 2c0a 2020 .Properties',. \n+00039050: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00039060: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00039070: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00039080: 2020 2020 2020 2020 2747 6574 416c 6c27 'GetAll'\n+00039090: 2c20 2773 272c 206e 616d 6529 0a20 2020 , 's', name). \n+000390a0: 2020 2020 2020 2020 2020 2020 206e 6f74 not\n+000390b0: 6966 795f 7570 6461 7465 286e 6f74 6966 ify_update(notif\n+000390c0: 792c 2070 6174 682c 206e 616d 652c 2070 y, path, name, p\n+000390d0: 726f 7073 290a 2020 2020 2020 2020 2020 rops). \n+000390e0: 2020 6578 6365 7074 2042 7573 4572 726f except BusErro\n+000390f0: 723a 0a20 2020 2020 2020 2020 2020 2020 r:. \n+00039100: 2020 2070 6173 730a 0a20 2020 2061 7379 pass.. asy\n+00039110: 6e63 2064 6566 2064 6f5f 7761 7463 6828 nc def do_watch(\n+00039120: 7365 6c66 2c20 6d65 7373 6167 6529 3a0a self, message):.\n+00039130: 2020 2020 2020 2020 7761 7463 6820 3d20 watch = \n+00039140: 6d65 7373 6167 655b 2777 6174 6368 275d message['watch']\n+00039150: 0a20 2020 2020 2020 2070 6174 6820 3d20 . path = \n+00039160: 7761 7463 682e 6765 7428 2770 6174 6827 watch.get('path'\n+00039170: 290a 2020 2020 2020 2020 7061 7468 5f6e ). path_n\n+00039180: 616d 6573 7061 6365 203d 2077 6174 6368 amespace = watch\n+00039190: 2e67 6574 2827 7061 7468 5f6e 616d 6573 .get('path_names\n+000391a0: 7061 6365 2729 0a20 2020 2020 2020 2069 pace'). i\n+000391b0: 6e74 6572 6661 6365 5f6e 616d 6520 3d20 nterface_name = \n+000391c0: 7761 7463 682e 6765 7428 2769 6e74 6572 watch.get('inter\n+000391d0: 6661 6365 2729 0a20 2020 2020 2020 2063 face'). c\n+000391e0: 6f6f 6b69 6520 3d20 6d65 7373 6167 652e ookie = message.\n+000391f0: 6765 7428 2769 6427 290a 0a20 2020 2020 get('id').. \n+00039200: 2020 2070 6174 6820 3d20 7061 7468 206f path = path o\n+00039210: 7220 7061 7468 5f6e 616d 6573 7061 6365 r path_namespace\n+00039220: 0a20 2020 2020 2020 2072 6563 7572 7369 . recursi\n+00039230: 7665 203d 2070 6174 6820 3d3d 2070 6174 ve = path == pat\n+00039240: 685f 6e61 6d65 7370 6163 650a 0a20 2020 h_namespace.. \n+00039250: 2020 2020 2069 6620 7061 7468 2069 7320 if path is \n+00039260: 4e6f 6e65 206f 7220 636f 6f6b 6965 2069 None or cookie i\n+00039270: 7320 4e6f 6e65 3a0a 2020 2020 2020 2020 s None:. \n+00039280: 2020 2020 6c6f 6767 6572 2e64 6562 7567 logger.debug\n+00039290: 2827 6967 6e6f 7265 6420 696e 636f 6d70 ('ignored incomp\n+000392a0: 6c65 7465 2077 6174 6368 2072 6571 7565 lete watch reque\n+000392b0: 7374 2025 7327 2c20 6d65 7373 6167 6529 st %s', message)\n+000392c0: 0a20 2020 2020 2020 2020 2020 2073 656c . sel\n+000392d0: 662e 7365 6e64 5f6a 736f 6e28 6572 726f f.send_json(erro\n+000392e0: 723d 5b27 782e 792e 7a27 2c20 5b27 4e6f r=['x.y.z', ['No\n+000392f0: 7420 496d 706c 656d 656e 7465 6427 5d5d t Implemented']]\n+00039300: 2c20 6964 3d63 6f6f 6b69 6529 0a20 2020 , id=cookie). \n+00039310: 2020 2020 2020 2020 2073 656c 662e 7365 self.se\n+00039320: 6e64 5f6a 736f 6e28 7265 706c 793d 5b5d nd_json(reply=[]\n+00039330: 2c20 6964 3d63 6f6f 6b69 6529 0a20 2020 , id=cookie). \n+00039340: 2020 2020 2020 2020 2072 6574 7572 6e0a return.\n+00039350: 0a20 2020 2020 2020 2074 7279 3a0a 2020 . try:. \n+00039360: 2020 2020 2020 2020 2020 6173 796e 6320 async \n+00039370: 7769 7468 2073 656c 662e 7761 7463 685f with self.watch_\n+00039380: 7072 6f63 6573 7369 6e67 5f6c 6f63 6b3a processing_lock:\n+00039390: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+000393a0: 206d 6574 6120 3d20 7b7d 0a20 2020 2020 meta = {}. \n+000393b0: 2020 2020 2020 2020 2020 206e 6f74 6966 notif\n+000393c0: 7920 3d20 7b7d 0a20 2020 2020 2020 2020 y = {}. \n+000393d0: 2020 2020 2020 2061 7761 6974 2073 656c await sel\n+000393e0: 662e 7365 7475 705f 7061 7468 5f77 6174 f.setup_path_wat\n+000393f0: 6368 2870 6174 682c 2069 6e74 6572 6661 ch(path, interfa\n+00039400: 6365 5f6e 616d 652c 2072 6563 7572 7369 ce_name, recursi\n+00039410: 7665 2c20 6d65 7461 2c20 6e6f 7469 6679 ve, meta, notify\n+00039420: 290a 2020 2020 2020 2020 2020 2020 2020 ). \n+00039430: 2020 6966 2072 6563 7572 7369 7665 3a0a if recursive:.\n+00039440: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00039450: 2020 2020 6177 6169 7420 7365 6c66 2e73 await self.s\n+00039460: 6574 7570 5f6f 626a 6563 746d 616e 6167 etup_objectmanag\n+00039470: 6572 5f77 6174 6368 2870 6174 682c 2069 er_watch(path, i\n+00039480: 6e74 6572 6661 6365 5f6e 616d 652c 206d nterface_name, m\n+00039490: 6574 612c 206e 6f74 6966 7929 0a20 2020 eta, notify). \n+000394a0: 2020 2020 2020 2020 2020 2020 2073 656c sel\n+000394b0: 662e 7365 6e64 5f6a 736f 6e28 6d65 7461 f.send_json(meta\n+000394c0: 3d6d 6574 6129 0a20 2020 2020 2020 2020 =meta). \n+000394d0: 2020 2020 2020 2073 656c 662e 7365 6e64 self.send\n+000394e0: 5f6a 736f 6e28 6e6f 7469 6679 3d6e 6f74 _json(notify=not\n+000394f0: 6966 7929 0a20 2020 2020 2020 2020 2020 ify). \n+00039500: 2020 2020 2073 656c 662e 7365 6e64 5f6a self.send_j\n+00039510: 736f 6e28 7265 706c 793d 5b5d 2c20 6964 son(reply=[], id\n+00039520: 3d6d 6573 7361 6765 5b27 6964 275d 290a =message['id']).\n+00039530: 2020 2020 2020 2020 6578 6365 7074 2042 except B\n+00039540: 7573 4572 726f 7220 6173 2065 7272 6f72 usError as error\n+00039550: 3a0a 2020 2020 2020 2020 2020 2020 6c6f :. lo\n+00039560: 6767 6572 2e64 6562 7567 2822 646f 5f77 gger.debug(\"do_w\n+00039570: 6174 6368 2825 7329 2063 6175 6768 7420 atch(%s) caught \n+00039580: 442d 4275 7320 6572 726f 723a 2025 7322 D-Bus error: %s\"\n+00039590: 2c20 6d65 7373 6167 652c 2065 7272 6f72 , message, error\n+000395a0: 2e6d 6573 7361 6765 290a 2020 2020 2020 .message). \n+000395b0: 2020 2020 2020 7365 6c66 2e73 656e 645f self.send_\n+000395c0: 6a73 6f6e 2865 7272 6f72 3d5b 6572 726f json(error=[erro\n+000395d0: 722e 6e61 6d65 2c20 5b65 7272 6f72 2e6d r.name, [error.m\n+000395e0: 6573 7361 6765 5d5d 2c20 6964 3d63 6f6f essage]], id=coo\n+000395f0: 6b69 6529 0a0a 2020 2020 6173 796e 6320 kie).. async \n+00039600: 6465 6620 646f 5f6d 6574 6128 7365 6c66 def do_meta(self\n+00039610: 2c20 6d65 7373 6167 6529 3a0a 2020 2020 , message):. \n+00039620: 2020 2020 7365 6c66 2e63 6163 6865 2e69 self.cache.i\n+00039630: 6e6a 6563 7428 6d65 7373 6167 655b 276d nject(message['m\n+00039640: 6574 6127 5d29 0a0a 2020 2020 6465 6620 eta']).. def \n+00039650: 646f 5f64 6174 6128 7365 6c66 2c20 6461 do_data(self, da\n+00039660: 7461 293a 0a20 2020 2020 2020 206d 6573 ta):. mes\n+00039670: 7361 6765 203d 206a 736f 6e2e 6c6f 6164 sage = json.load\n+00039680: 7328 6461 7461 290a 2020 2020 2020 2020 s(data). \n+00039690: 6c6f 6767 6572 2e64 6562 7567 2827 7265 logger.debug('re\n+000396a0: 6365 6976 6520 6462 7573 2072 6571 7565 ceive dbus reque\n+000396b0: 7374 2025 7320 2573 272c 2073 656c 662e st %s %s', self.\n+000396c0: 6e61 6d65 2c20 6d65 7373 6167 6529 0a0a name, message)..\n+000396d0: 2020 2020 2020 2020 6966 2027 6361 6c6c if 'call\n+000396e0: 2720 696e 206d 6573 7361 6765 3a0a 2020 ' in message:. \n+000396f0: 2020 2020 2020 2020 2020 7365 6c66 2e63 self.c\n+00039700: 7265 6174 655f 7461 736b 2873 656c 662e reate_task(self.\n+00039710: 646f 5f63 616c 6c28 6d65 7373 6167 6529 do_call(message)\n+00039720: 290a 2020 2020 2020 2020 656c 6966 2027 ). elif '\n+00039730: 6164 642d 6d61 7463 6827 2069 6e20 6d65 add-match' in me\n+00039740: 7373 6167 653a 0a20 2020 2020 2020 2020 ssage:. \n+00039750: 2020 2073 656c 662e 6372 6561 7465 5f74 self.create_t\n+00039760: 6173 6b28 7365 6c66 2e64 6f5f 6164 645f ask(self.do_add_\n+00039770: 6d61 7463 6828 6d65 7373 6167 6529 290a match(message)).\n+00039780: 2020 2020 2020 2020 656c 6966 2027 7761 elif 'wa\n+00039790: 7463 6827 2069 6e20 6d65 7373 6167 653a tch' in message:\n+000397a0: 0a20 2020 2020 2020 2020 2020 2073 656c . sel\n+000397b0: 662e 6372 6561 7465 5f74 6173 6b28 7365 f.create_task(se\n+000397c0: 6c66 2e64 6f5f 7761 7463 6828 6d65 7373 lf.do_watch(mess\n+000397d0: 6167 6529 290a 2020 2020 2020 2020 656c age)). el\n+000397e0: 6966 2027 6d65 7461 2720 696e 206d 6573 if 'meta' in mes\n+000397f0: 7361 6765 3a0a 2020 2020 2020 2020 2020 sage:. \n+00039800: 2020 7365 6c66 2e63 7265 6174 655f 7461 self.create_ta\n+00039810: 736b 2873 656c 662e 646f 5f6d 6574 6128 sk(self.do_meta(\n+00039820: 6d65 7373 6167 6529 290a 2020 2020 2020 message)). \n+00039830: 2020 656c 7365 3a0a 2020 2020 2020 2020 else:. \n+00039840: 2020 2020 6c6f 6767 6572 2e64 6562 7567 logger.debug\n+00039850: 2827 6967 6e6f 7265 6420 6462 7573 2072 ('ignored dbus r\n+00039860: 6571 7565 7374 2025 7327 2c20 6d65 7373 equest %s', mess\n+00039870: 6167 6529 0a20 2020 2020 2020 2020 2020 age). \n+00039880: 2072 6574 7572 6e0a 0a20 2020 2064 6566 return.. def\n+00039890: 2064 6f5f 636c 6f73 6528 7365 6c66 293a do_close(self):\n+000398a0: 0a20 2020 2020 2020 2066 6f72 2073 6c6f . for slo\n+000398b0: 7420 696e 2073 656c 662e 6d61 7463 6865 t in self.matche\n+000398c0: 733a 0a20 2020 2020 2020 2020 2020 2073 s:. s\n+000398d0: 6c6f 742e 6361 6e63 656c 2829 0a20 2020 lot.cancel(). \n+000398e0: 2020 2020 2073 656c 662e 6d61 7463 6865 self.matche\n+000398f0: 7320 3d20 5b5d 0a20 2020 2020 2020 2073 s = []. s\n+00039900: 656c 662e 636c 6f73 6528 290a 2727 272e elf.close().'''.\n+00039910: 656e 636f 6465 2827 7574 662d 3827 292c encode('utf-8'),\n+00039920: 0a20 2027 636f 636b 7069 742f 6368 616e . 'cockpit/chan\n+00039930: 6e65 6c73 2f66 696c 6573 7973 7465 6d2e nels/filesystem.\n+00039940: 7079 273a 2072 2727 2723 2054 6869 7320 py': r'''# This \n+00039950: 6669 6c65 2069 7320 7061 7274 206f 6620 file is part of \n+00039960: 436f 636b 7069 742e 0a23 0a23 2043 6f70 Cockpit..#.# Cop\n+00039970: 7972 6967 6874 2028 4329 2032 3032 3220 yright (C) 2022 \n+00039980: 5265 6420 4861 742c 2049 6e63 2e0a 230a Red Hat, Inc..#.\n+00039990: 2320 5468 6973 2070 726f 6772 616d 2069 # This program i\n+000399a0: 7320 6672 6565 2073 6f66 7477 6172 653a s free software:\n+000399b0: 2079 6f75 2063 616e 2072 6564 6973 7472 you can redistr\n+000399c0: 6962 7574 6520 6974 2061 6e64 2f6f 7220 ibute it and/or \n+000399d0: 6d6f 6469 6679 0a23 2069 7420 756e 6465 modify.# it unde\n+000399e0: 7220 7468 6520 7465 726d 7320 6f66 2074 r the terms of t\n+000399f0: 6865 2047 4e55 2047 656e 6572 616c 2050 he GNU General P\n+00039a00: 7562 6c69 6320 4c69 6365 6e73 6520 6173 ublic License as\n+00039a10: 2070 7562 6c69 7368 6564 2062 790a 2320 published by.# \n+00039a20: 7468 6520 4672 6565 2053 6f66 7477 6172 the Free Softwar\n+00039a30: 6520 466f 756e 6461 7469 6f6e 2c20 6569 e Foundation, ei\n+00039a40: 7468 6572 2076 6572 7369 6f6e 2033 206f ther version 3 o\n+00039a50: 6620 7468 6520 4c69 6365 6e73 652c 206f f the License, o\n+00039a60: 720a 2320 2861 7420 796f 7572 206f 7074 r.# (at your opt\n+00039a70: 696f 6e29 2061 6e79 206c 6174 6572 2076 ion) any later v\n+00039a80: 6572 7369 6f6e 2e0a 230a 2320 5468 6973 ersion..#.# This\n+00039a90: 2070 726f 6772 616d 2069 7320 6469 7374 program is dist\n+00039aa0: 7269 6275 7465 6420 696e 2074 6865 2068 ributed in the h\n+00039ab0: 6f70 6520 7468 6174 2069 7420 7769 6c6c ope that it will\n+00039ac0: 2062 6520 7573 6566 756c 2c0a 2320 6275 be useful,.# bu\n+00039ad0: 7420 5749 5448 4f55 5420 414e 5920 5741 t WITHOUT ANY WA\n+00039ae0: 5252 414e 5459 3b20 7769 7468 6f75 7420 RRANTY; without \n+00039af0: 6576 656e 2074 6865 2069 6d70 6c69 6564 even the implied\n+00039b00: 2077 6172 7261 6e74 7920 6f66 0a23 204d warranty of.# M\n+00039b10: 4552 4348 414e 5441 4249 4c49 5459 206f ERCHANTABILITY o\n+00039b20: 7220 4649 544e 4553 5320 464f 5220 4120 r FITNESS FOR A \n+00039b30: 5041 5254 4943 554c 4152 2050 5552 504f PARTICULAR PURPO\n+00039b40: 5345 2e20 2053 6565 2074 6865 0a23 2047 SE. See the.# G\n+00039b50: 4e55 2047 656e 6572 616c 2050 7562 6c69 NU General Publi\n+00039b60: 6320 4c69 6365 6e73 6520 666f 7220 6d6f c License for mo\n+00039b70: 7265 2064 6574 6169 6c73 2e0a 230a 2320 re details..#.# \n+00039b80: 596f 7520 7368 6f75 6c64 2068 6176 6520 You should have \n+00039b90: 7265 6365 6976 6564 2061 2063 6f70 7920 received a copy \n+00039ba0: 6f66 2074 6865 2047 4e55 2047 656e 6572 of the GNU Gener\n+00039bb0: 616c 2050 7562 6c69 6320 4c69 6365 6e73 al Public Licens\n+00039bc0: 650a 2320 616c 6f6e 6720 7769 7468 2074 e.# along with t\n+00039bd0: 6869 7320 7072 6f67 7261 6d2e 2020 4966 his program. If\n+00039be0: 206e 6f74 2c20 7365 6520 3c68 7474 7073 not, see <https\n+00039bf0: 3a2f 2f77 7777 2e67 6e75 2e6f 7267 2f6c ://www.gnu.org/l\n+00039c00: 6963 656e 7365 732f 3e2e 0a0a 696d 706f icenses/>...impo\n+00039c10: 7274 2061 7379 6e63 696f 0a69 6d70 6f72 rt asyncio.impor\n+00039c20: 7420 636f 6e74 6578 746c 6962 0a69 6d70 t contextlib.imp\n+00039c30: 6f72 7420 656e 756d 0a69 6d70 6f72 7420 ort enum.import \n+00039c40: 6572 726e 6f0a 696d 706f 7274 2066 6e6d errno.import fnm\n+00039c50: 6174 6368 0a69 6d70 6f72 7420 6675 6e63 atch.import func\n+00039c60: 746f 6f6c 730a 696d 706f 7274 2067 7270 tools.import grp\n+00039c70: 0a69 6d70 6f72 7420 6c6f 6767 696e 670a .import logging.\n+00039c80: 696d 706f 7274 206f 730a 696d 706f 7274 import os.import\n+00039c90: 2070 7764 0a69 6d70 6f72 7420 7265 0a69 pwd.import re.i\n+00039ca0: 6d70 6f72 7420 7374 6174 0a69 6d70 6f72 mport stat.impor\n+00039cb0: 7420 7465 6d70 6669 6c65 0a66 726f 6d20 t tempfile.from \n+00039cc0: 7061 7468 6c69 6220 696d 706f 7274 2050 pathlib import P\n+00039cd0: 6174 680a 6672 6f6d 2074 7970 696e 6720 ath.from typing \n+00039ce0: 696d 706f 7274 2043 616c 6c61 626c 652c import Callable,\n+00039cf0: 2049 7465 7261 626c 650a 0a66 726f 6d20 Iterable..from \n+00039d00: 636f 636b 7069 742e 5f76 656e 646f 722e cockpit._vendor.\n+00039d10: 7379 7374 656d 645f 6374 7970 6573 2069 systemd_ctypes i\n+00039d20: 6d70 6f72 7420 4861 6e64 6c65 2c20 5061 mport Handle, Pa\n+00039d30: 7468 5761 7463 680a 6672 6f6d 2063 6f63 thWatch.from coc\n+00039d40: 6b70 6974 2e5f 7665 6e64 6f72 2e73 7973 kpit._vendor.sys\n+00039d50: 7465 6d64 5f63 7479 7065 732e 696e 6f74 temd_ctypes.inot\n+00039d60: 6966 7920 696d 706f 7274 2045 7665 6e74 ify import Event\n+00039d70: 2061 7320 496e 6f74 6966 7945 7665 6e74 as InotifyEvent\n+00039d80: 0a66 726f 6d20 636f 636b 7069 742e 5f76 .from cockpit._v\n+00039d90: 656e 646f 722e 7379 7374 656d 645f 6374 endor.systemd_ct\n+00039da0: 7970 6573 2e70 6174 6877 6174 6368 2069 ypes.pathwatch i\n+00039db0: 6d70 6f72 7420 4c69 7374 656e 6572 2061 mport Listener a\n+00039dc0: 7320 5061 7468 5761 7463 684c 6973 7465 s PathWatchListe\n+00039dd0: 6e65 720a 0a66 726f 6d20 2e2e 6368 616e ner..from ..chan\n+00039de0: 6e65 6c20 696d 706f 7274 2041 7379 6e63 nel import Async\n+00039df0: 4368 616e 6e65 6c2c 2043 6861 6e6e 656c Channel, Channel\n+00039e00: 2c20 4368 616e 6e65 6c45 7272 6f72 2c20 , ChannelError, \n+00039e10: 4765 6e65 7261 746f 7243 6861 6e6e 656c GeneratorChannel\n+00039e20: 0a66 726f 6d20 2e2e 6a73 6f6e 7574 696c .from ..jsonutil\n+00039e30: 2069 6d70 6f72 7420 280a 2020 2020 4a73 import (. Js\n+00039e40: 6f6e 4469 6374 2c0a 2020 2020 4a73 6f6e onDict,. Json\n+00039e50: 446f 6375 6d65 6e74 2c0a 2020 2020 4a73 Document,. Js\n+00039e60: 6f6e 4572 726f 722c 0a20 2020 204a 736f onError,. Jso\n+00039e70: 6e4f 626a 6563 742c 0a20 2020 2067 6574 nObject,. get\n+00039e80: 5f62 6f6f 6c2c 0a20 2020 2067 6574 5f65 _bool,. get_e\n+00039e90: 6e75 6d2c 0a20 2020 2067 6574 5f69 6e74 num,. get_int\n+00039ea0: 2c0a 2020 2020 6765 745f 7374 722c 0a20 ,. get_str,. \n+00039eb0: 2020 2067 6574 5f73 7472 762c 0a20 2020 get_strv,. \n+00039ec0: 206a 736f 6e5f 6d65 7267 655f 616e 645f json_merge_and_\n+00039ed0: 6669 6c74 6572 5f70 6174 6368 2c0a 290a filter_patch,.).\n+00039ee0: 0a6c 6f67 6765 7220 3d20 6c6f 6767 696e .logger = loggin\n+00039ef0: 672e 6765 744c 6f67 6765 7228 5f5f 6e61 g.getLogger(__na\n+00039f00: 6d65 5f5f 290a 0a0a 4066 756e 6374 6f6f me__)...@functoo\n+00039f10: 6c73 2e6c 7275 5f63 6163 6865 2829 0a64 ls.lru_cache().d\n+00039f20: 6566 206d 795f 756d 6173 6b28 2920 2d3e ef my_umask() ->\n+00039f30: 2069 6e74 3a0a 2020 2020 6d61 7463 6820 int:. match \n+00039f40: 3d20 7265 2e73 6561 7263 6828 7227 5e55 = re.search(r'^U\n+00039f50: 6d61 736b 3a5c 732a 3028 5b30 2d37 5d2a mask:\\s*0([0-7]*\n+00039f60: 2924 272c 2050 6174 6828 272f 7072 6f63 )$', Path('/proc\n+00039f70: 2f73 656c 662f 7374 6174 7573 2729 2e72 /self/status').r\n+00039f80: 6561 645f 7465 7874 2829 2c20 7265 2e4d ead_text(), re.M\n+00039f90: 290a 2020 2020 7265 7475 726e 2028 6d61 ). return (ma\n+00039fa0: 7463 6820 616e 6420 696e 7428 6d61 7463 tch and int(matc\n+00039fb0: 682e 6772 6f75 7028 3129 2c20 3829 2920 h.group(1), 8)) \n+00039fc0: 6f72 2030 6f30 3737 0a0a 0a64 6566 2074 or 0o077...def t\n+00039fd0: 6167 5f66 726f 6d5f 7374 6174 2862 7566 ag_from_stat(buf\n+00039fe0: 293a 0a20 2020 2072 6574 7572 6e20 6627 ):. return f'\n+00039ff0: 313a 7b62 7566 2e73 745f 696e 6f7d 2d7b 1:{buf.st_ino}-{\n+0003a000: 6275 662e 7374 5f6d 7469 6d65 7d2d 7b62 buf.st_mtime}-{b\n+0003a010: 7566 2e73 745f 6d6f 6465 3a6f 7d2d 7b62 uf.st_mode:o}-{b\n+0003a020: 7566 2e73 745f 7569 647d 2d7b 6275 662e uf.st_uid}-{buf.\n+0003a030: 7374 5f67 6964 7d27 0a0a 0a64 6566 2074 st_gid}'...def t\n+0003a040: 6167 5f66 726f 6d5f 7061 7468 2870 6174 ag_from_path(pat\n+0003a050: 6829 3a0a 2020 2020 7472 793a 0a20 2020 h):. try:. \n+0003a060: 2020 2020 2072 6574 7572 6e20 7461 675f return tag_\n+0003a070: 6672 6f6d 5f73 7461 7428 6f73 2e73 7461 from_stat(os.sta\n+0003a080: 7428 7061 7468 2929 0a20 2020 2065 7863 t(path)). exc\n+0003a090: 6570 7420 4669 6c65 4e6f 7446 6f75 6e64 ept FileNotFound\n+0003a0a0: 4572 726f 723a 0a20 2020 2020 2020 2072 Error:. r\n+0003a0b0: 6574 7572 6e20 272d 270a 2020 2020 6578 eturn '-'. ex\n+0003a0c0: 6365 7074 204f 5345 7272 6f72 3a0a 2020 cept OSError:. \n+0003a0d0: 2020 2020 2020 7265 7475 726e 204e 6f6e return Non\n+0003a0e0: 650a 0a0a 6465 6620 7461 675f 6672 6f6d e...def tag_from\n+0003a0f0: 5f66 6428 6664 293a 0a20 2020 2074 7279 _fd(fd):. try\n+0003a100: 3a0a 2020 2020 2020 2020 7265 7475 726e :. return\n+0003a110: 2074 6167 5f66 726f 6d5f 7374 6174 286f tag_from_stat(o\n+0003a120: 732e 6673 7461 7428 6664 2929 0a20 2020 s.fstat(fd)). \n+0003a130: 2065 7863 6570 7420 4f53 4572 726f 723a except OSError:\n+0003a140: 0a20 2020 2020 2020 2072 6574 7572 6e20 . return \n+0003a150: 4e6f 6e65 0a0a 0a63 6c61 7373 2046 734c None...class FsL\n+0003a160: 6973 7443 6861 6e6e 656c 2843 6861 6e6e istChannel(Chann\n+0003a170: 656c 293a 0a20 2020 2070 6179 6c6f 6164 el):. payload\n+0003a180: 203d 2027 6673 6c69 7374 3127 0a0a 2020 = 'fslist1'.. \n+0003a190: 2020 6465 6620 7365 6e64 5f65 6e74 7279 def send_entry\n+0003a1a0: 2873 656c 662c 2065 7665 6e74 2c20 656e (self, event, en\n+0003a1b0: 7472 7929 3a0a 2020 2020 2020 2020 6966 try):. if\n+0003a1c0: 2065 6e74 7279 2e69 735f 7379 6d6c 696e entry.is_symlin\n+0003a1d0: 6b28 293a 0a20 2020 2020 2020 2020 2020 k():. \n+0003a1e0: 206d 6f64 6520 3d20 276c 696e 6b27 0a20 mode = 'link'. \n+0003a1f0: 2020 2020 2020 2065 6c69 6620 656e 7472 elif entr\n+0003a200: 792e 6973 5f66 696c 6528 293a 0a20 2020 y.is_file():. \n+0003a210: 2020 2020 2020 2020 206d 6f64 6520 3d20 mode = \n+0003a220: 2766 696c 6527 0a20 2020 2020 2020 2065 'file'. e\n+0003a230: 6c69 6620 656e 7472 792e 6973 5f64 6972 lif entry.is_dir\n+0003a240: 2829 3a0a 2020 2020 2020 2020 2020 2020 ():. \n+0003a250: 6d6f 6465 203d 2027 6469 7265 6374 6f72 mode = 'director\n+0003a260: 7927 0a20 2020 2020 2020 2065 6c73 653a y'. else:\n+0003a270: 0a20 2020 2020 2020 2020 2020 206d 6f64 . mod\n+0003a280: 6520 3d20 2773 7065 6369 616c 270a 0a20 e = 'special'.. \n+0003a290: 2020 2020 2020 2073 656c 662e 7365 6e64 self.send\n+0003a2a0: 5f6a 736f 6e28 6576 656e 743d 6576 656e _json(event=even\n+0003a2b0: 742c 2070 6174 683d 656e 7472 792e 6e61 t, path=entry.na\n+0003a2c0: 6d65 2c20 7479 7065 3d6d 6f64 6529 0a0a me, type=mode)..\n+0003a2d0: 2020 2020 6465 6620 646f 5f6f 7065 6e28 def do_open(\n+0003a2e0: 7365 6c66 2c20 6f70 7469 6f6e 7329 3a0a self, options):.\n+0003a2f0: 2020 2020 2020 2020 7061 7468 203d 206f path = o\n+0003a300: 7074 696f 6e73 2e67 6574 2827 7061 7468 ptions.get('path\n+0003a310: 2729 0a20 2020 2020 2020 2077 6174 6368 '). watch\n+0003a320: 203d 206f 7074 696f 6e73 2e67 6574 2827 = options.get('\n+0003a330: 7761 7463 6827 2c20 5472 7565 290a 0a20 watch', True).. \n+0003a340: 2020 2020 2020 2069 6620 7761 7463 683a if watch:\n+0003a350: 0a20 2020 2020 2020 2020 2020 2072 6169 . rai\n+0003a360: 7365 2043 6861 6e6e 656c 4572 726f 7228 se ChannelError(\n+0003a370: 276e 6f74 2d73 7570 706f 7274 6564 272c 'not-supported',\n+0003a380: 206d 6573 7361 6765 3d27 7761 7463 6869 message='watchi\n+0003a390: 6e67 2069 7320 6e6f 7420 696d 706c 656d ng is not implem\n+0003a3a0: 656e 7465 642c 2075 7365 2066 7377 6174 ented, use fswat\n+0003a3b0: 6368 3127 290a 0a20 2020 2020 2020 2074 ch1').. t\n+0003a3c0: 7279 3a0a 2020 2020 2020 2020 2020 2020 ry:. \n+0003a3d0: 7363 616e 5f64 6972 203d 206f 732e 7363 scan_dir = os.sc\n+0003a3e0: 616e 6469 7228 7061 7468 290a 2020 2020 andir(path). \n+0003a3f0: 2020 2020 6578 6365 7074 2046 696c 654e except FileN\n+0003a400: 6f74 466f 756e 6445 7272 6f72 2061 7320 otFoundError as \n+0003a410: 6572 726f 723a 0a20 2020 2020 2020 2020 error:. \n+0003a420: 2020 2072 6169 7365 2043 6861 6e6e 656c raise Channel\n+0003a430: 4572 726f 7228 276e 6f74 2d66 6f75 6e64 Error('not-found\n+0003a440: 272c 206d 6573 7361 6765 3d73 7472 2865 ', message=str(e\n+0003a450: 7272 6f72 2929 2066 726f 6d20 6572 726f rror)) from erro\n+0003a460: 720a 2020 2020 2020 2020 6578 6365 7074 r. except\n+0003a470: 2050 6572 6d69 7373 696f 6e45 7272 6f72 PermissionError\n+0003a480: 2061 7320 6572 726f 723a 0a20 2020 2020 as error:. \n+0003a490: 2020 2020 2020 2072 6169 7365 2043 6861 raise Cha\n+0003a4a0: 6e6e 656c 4572 726f 7228 2761 6363 6573 nnelError('acces\n+0003a4b0: 732d 6465 6e69 6564 272c 206d 6573 7361 s-denied', messa\n+0003a4c0: 6765 3d73 7472 2865 7272 6f72 2929 2066 ge=str(error)) f\n+0003a4d0: 726f 6d20 6572 726f 720a 2020 2020 2020 rom error. \n+0003a4e0: 2020 6578 6365 7074 204f 5345 7272 6f72 except OSError\n+0003a4f0: 2061 7320 6572 726f 723a 0a20 2020 2020 as error:. \n+0003a500: 2020 2020 2020 2072 6169 7365 2043 6861 raise Cha\n+0003a510: 6e6e 656c 4572 726f 7228 2769 6e74 6572 nnelError('inter\n+0003a520: 6e61 6c2d 6572 726f 7227 2c20 6d65 7373 nal-error', mess\n+0003a530: 6167 653d 7374 7228 6572 726f 7229 2920 age=str(error)) \n+0003a540: 6672 6f6d 2065 7272 6f72 0a0a 2020 2020 from error.. \n+0003a550: 2020 2020 7365 6c66 2e72 6561 6479 2829 self.ready()\n+0003a560: 0a20 2020 2020 2020 2066 6f72 2065 6e74 . for ent\n+0003a570: 7279 2069 6e20 7363 616e 5f64 6972 3a0a ry in scan_dir:.\n+0003a580: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n+0003a590: 2e73 656e 645f 656e 7472 7928 2270 7265 .send_entry(\"pre\n+0003a5a0: 7365 6e74 222c 2065 6e74 7279 290a 0a20 sent\", entry).. \n+0003a5b0: 2020 2020 2020 2069 6620 6e6f 7420 7761 if not wa\n+0003a5c0: 7463 683a 0a20 2020 2020 2020 2020 2020 tch:. \n+0003a5d0: 2073 656c 662e 646f 6e65 2829 0a20 2020 self.done(). \n+0003a5e0: 2020 2020 2020 2020 2073 656c 662e 636c self.cl\n+0003a5f0: 6f73 6528 290a 0a0a 636c 6173 7320 4673 ose()...class Fs\n+0003a600: 5265 6164 4368 616e 6e65 6c28 4765 6e65 ReadChannel(Gene\n+0003a610: 7261 746f 7243 6861 6e6e 656c 293a 0a20 ratorChannel):. \n+0003a620: 2020 2070 6179 6c6f 6164 203d 2027 6673 payload = 'fs\n+0003a630: 7265 6164 3127 0a0a 2020 2020 6465 6620 read1'.. def \n+0003a640: 646f 5f79 6965 6c64 5f64 6174 6128 7365 do_yield_data(se\n+0003a650: 6c66 2c20 6f70 7469 6f6e 733a 204a 736f lf, options: Jso\n+0003a660: 6e4f 626a 6563 7429 202d 3e20 4765 6e65 nObject) -> Gene\n+0003a670: 7261 746f 7243 6861 6e6e 656c 2e44 6174 ratorChannel.Dat\n+0003a680: 6147 656e 6572 6174 6f72 3a0a 2020 2020 aGenerator:. \n+0003a690: 2020 2020 7061 7468 203d 2067 6574 5f73 path = get_s\n+0003a6a0: 7472 286f 7074 696f 6e73 2c20 2770 6174 tr(options, 'pat\n+0003a6b0: 6827 290a 2020 2020 2020 2020 6269 6e61 h'). bina\n+0003a6c0: 7279 203d 2067 6574 5f65 6e75 6d28 6f70 ry = get_enum(op\n+0003a6d0: 7469 6f6e 732c 2027 6269 6e61 7279 272c tions, 'binary',\n+0003a6e0: 205b 2772 6177 275d 2c20 4e6f 6e65 2920 ['raw'], None) \n+0003a6f0: 6973 206e 6f74 204e 6f6e 650a 2020 2020 is not None. \n+0003a700: 2020 2020 6d61 785f 7265 6164 5f73 697a max_read_siz\n+0003a710: 6520 3d20 6765 745f 696e 7428 6f70 7469 e = get_int(opti\n+0003a720: 6f6e 732c 2027 6d61 785f 7265 6164 5f73 ons, 'max_read_s\n+0003a730: 697a 6527 2c20 4e6f 6e65 290a 0a20 2020 ize', None).. \n+0003a740: 2020 2020 206c 6f67 6765 722e 6465 6275 logger.debu\n+0003a750: 6728 274f 7065 6e69 6e67 2066 696c 6520 g('Opening file \n+0003a760: 2225 7322 2066 6f72 2072 6561 6469 6e67 \"%s\" for reading\n+0003a770: 272c 2070 6174 6829 0a0a 2020 2020 2020 ', path).. \n+0003a780: 2020 7472 793a 0a20 2020 2020 2020 2020 try:. \n+0003a790: 2020 2077 6974 6820 6f70 656e 2870 6174 with open(pat\n+0003a7a0: 682c 2027 7262 2729 2061 7320 6669 6c65 h, 'rb') as file\n+0003a7b0: 703a 0a20 2020 2020 2020 2020 2020 2020 p:. \n+0003a7c0: 2020 2062 7566 203d 206f 732e 7374 6174 buf = os.stat\n+0003a7d0: 2866 696c 6570 2e66 696c 656e 6f28 2929 (filep.fileno())\n+0003a7e0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+0003a7f0: 2069 6620 6d61 785f 7265 6164 5f73 697a if max_read_siz\n+0003a800: 6520 6973 206e 6f74 204e 6f6e 6520 616e e is not None an\n+0003a810: 6420 6275 662e 7374 5f73 697a 6520 3e20 d buf.st_size > \n+0003a820: 6d61 785f 7265 6164 5f73 697a 653a 0a20 max_read_size:. \n+0003a830: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0003a840: 2020 2072 6169 7365 2043 6861 6e6e 656c raise Channel\n+0003a850: 4572 726f 7228 2774 6f6f 2d6c 6172 6765 Error('too-large\n+0003a860: 2729 0a0a 2020 2020 2020 2020 2020 2020 ').. \n+0003a870: 2020 2020 6966 2062 696e 6172 7920 616e if binary an\n+0003a880: 6420 7374 6174 2e53 5f49 5352 4547 2862 d stat.S_ISREG(b\n+0003a890: 7566 2e73 745f 6d6f 6465 293a 0a20 2020 uf.st_mode):. \n+0003a8a0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0003a8b0: 2073 656c 662e 7265 6164 7928 7369 7a65 self.ready(size\n+0003a8c0: 5f68 696e 743d 6275 662e 7374 5f73 697a _hint=buf.st_siz\n+0003a8d0: 6529 0a20 2020 2020 2020 2020 2020 2020 e). \n+0003a8e0: 2020 2065 6c73 653a 0a20 2020 2020 2020 else:. \n+0003a8f0: 2020 2020 2020 2020 2020 2020 2073 656c sel\n+0003a900: 662e 7265 6164 7928 290a 0a20 2020 2020 f.ready().. \n+0003a910: 2020 2020 2020 2020 2020 2077 6869 6c65 while\n+0003a920: 2054 7275 653a 0a20 2020 2020 2020 2020 True:. \n+0003a930: 2020 2020 2020 2020 2020 2064 6174 6120 data \n+0003a940: 3d20 6669 6c65 702e 7265 6164 3128 4368 = filep.read1(Ch\n+0003a950: 616e 6e65 6c2e 424c 4f43 4b5f 5349 5a45 annel.BLOCK_SIZE\n+0003a960: 290a 2020 2020 2020 2020 2020 2020 2020 ). \n+0003a970: 2020 2020 2020 6966 2064 6174 6120 3d3d if data ==\n+0003a980: 2062 2727 3a0a 2020 2020 2020 2020 2020 b'':. \n+0003a990: 2020 2020 2020 2020 2020 2020 2020 6272 br\n+0003a9a0: 6561 6b0a 2020 2020 2020 2020 2020 2020 eak. \n+0003a9b0: 2020 2020 2020 2020 6c6f 6767 6572 2e64 logger.d\n+0003a9c0: 6562 7567 2827 2020 2e2e 2e73 656e 6469 ebug(' ...sendi\n+0003a9d0: 6e67 2025 6420 6279 7465 7327 2c20 6c65 ng %d bytes', le\n+0003a9e0: 6e28 6461 7461 2929 0a20 2020 2020 2020 n(data)). \n+0003a9f0: 2020 2020 2020 2020 2020 2020 2069 6620 if \n+0003aa00: 6e6f 7420 6269 6e61 7279 3a0a 2020 2020 not binary:. \n+0003aa10: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0003aa20: 2020 2020 6461 7461 203d 2064 6174 612e data = data.\n+0003aa30: 7265 706c 6163 6528 6227 5c30 272c 2062 replace(b'\\0', b\n+0003aa40: 2727 292e 6465 636f 6465 2827 7574 662d '').decode('utf-\n+0003aa50: 3827 2c20 6572 726f 7273 3d27 6967 6e6f 8', errors='igno\n+0003aa60: 7265 2729 2e65 6e63 6f64 6528 2775 7466 re').encode('utf\n+0003aa70: 2d38 2729 0a20 2020 2020 2020 2020 2020 -8'). \n+0003aa80: 2020 2020 2020 2020 2079 6965 6c64 2064 yield d\n+0003aa90: 6174 610a 0a20 2020 2020 2020 2020 2020 ata.. \n+0003aaa0: 2072 6574 7572 6e20 7b27 7461 6727 3a20 return {'tag': \n+0003aab0: 7461 675f 6672 6f6d 5f73 7461 7428 6275 tag_from_stat(bu\n+0003aac0: 6629 7d0a 0a20 2020 2020 2020 2065 7863 f)}.. exc\n+0003aad0: 6570 7420 4669 6c65 4e6f 7446 6f75 6e64 ept FileNotFound\n+0003aae0: 4572 726f 723a 0a20 2020 2020 2020 2020 Error:. \n+0003aaf0: 2020 2072 6574 7572 6e20 7b27 7461 6727 return {'tag'\n+0003ab00: 3a20 272d 277d 0a20 2020 2020 2020 2065 : '-'}. e\n+0003ab10: 7863 6570 7420 5065 726d 6973 7369 6f6e xcept Permission\n+0003ab20: 4572 726f 7220 6173 2065 7863 3a0a 2020 Error as exc:. \n+0003ab30: 2020 2020 2020 2020 2020 7261 6973 6520 raise \n+0003ab40: 4368 616e 6e65 6c45 7272 6f72 2827 6163 ChannelError('ac\n+0003ab50: 6365 7373 2d64 656e 6965 6427 2920 6672 cess-denied') fr\n+0003ab60: 6f6d 2065 7863 0a20 2020 2020 2020 2065 om exc. e\n+0003ab70: 7863 6570 7420 4f53 4572 726f 7220 6173 xcept OSError as\n+0003ab80: 2065 7863 3a0a 2020 2020 2020 2020 2020 exc:. \n+0003ab90: 2020 7261 6973 6520 4368 616e 6e65 6c45 raise ChannelE\n+0003aba0: 7272 6f72 2827 696e 7465 726e 616c 2d65 rror('internal-e\n+0003abb0: 7272 6f72 272c 206d 6573 7361 6765 3d73 rror', message=s\n+0003abc0: 7472 2865 7863 2929 2066 726f 6d20 6578 tr(exc)) from ex\n+0003abd0: 630a 0a0a 636c 6173 7320 4673 5265 706c c...class FsRepl\n+0003abe0: 6163 6543 6861 6e6e 656c 2841 7379 6e63 aceChannel(Async\n+0003abf0: 4368 616e 6e65 6c29 3a0a 2020 2020 7061 Channel):. pa\n+0003ac00: 796c 6f61 6420 3d20 2766 7372 6570 6c61 yload = 'fsrepla\n+0003ac10: 6365 3127 0a0a 2020 2020 6173 796e 6320 ce1'.. async \n+0003ac20: 6465 6620 7275 6e28 7365 6c66 2c20 6f70 def run(self, op\n+0003ac30: 7469 6f6e 733a 204a 736f 6e4f 626a 6563 tions: JsonObjec\n+0003ac40: 7429 202d 3e20 4a73 6f6e 4f62 6a65 6374 t) -> JsonObject\n+0003ac50: 3a0a 2020 2020 2020 2020 7061 7468 203d :. path =\n+0003ac60: 2067 6574 5f73 7472 286f 7074 696f 6e73 get_str(options\n+0003ac70: 2c20 2770 6174 6827 290a 2020 2020 2020 , 'path'). \n+0003ac80: 2020 7461 6720 3d20 6765 745f 7374 7228 tag = get_str(\n+0003ac90: 6f70 7469 6f6e 732c 2027 7461 6727 2c20 options, 'tag', \n+0003aca0: 4e6f 6e65 290a 2020 2020 2020 2020 6469 None). di\n+0003acb0: 726e 616d 652c 2062 6173 656e 616d 6520 rname, basename \n+0003acc0: 3d20 6f73 2e70 6174 682e 7370 6c69 7428 = os.path.split(\n+0003acd0: 6765 745f 7374 7228 6f70 7469 6f6e 732c get_str(options,\n+0003ace0: 2027 7061 7468 2729 290a 0a20 2020 2020 'path')).. \n+0003acf0: 2020 2073 656c 662e 7265 6164 7928 290a self.ready().\n+0003ad00: 0a20 2020 2020 2020 2074 7279 3a0a 2020 . try:. \n+0003ad10: 2020 2020 2020 2020 2020 6465 6c65 7465 delete\n+0003ad20: 5f6f 6e5f 6578 6974 203d 204e 6f6e 650a _on_exit = None.\n+0003ad30: 2020 2020 2020 2020 2020 2020 6461 7461 data\n+0003ad40: 203d 2061 7761 6974 2073 656c 662e 7265 = await self.re\n+0003ad50: 6164 2829 0a20 2020 2020 2020 2020 2020 ad(). \n+0003ad60: 2069 6620 6461 7461 2069 7320 4e6f 6e65 if data is None\n+0003ad70: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n+0003ad80: 2020 2320 6966 2077 6520 6765 7420 454f # if we get EO\n+0003ad90: 4620 7269 6768 7420 6177 6179 2c20 7468 F right away, th\n+0003ada0: 6174 2773 2061 2072 6571 7565 7374 2074 at's a request t\n+0003adb0: 6f20 6465 6c65 7465 0a20 2020 2020 2020 o delete. \n+0003adc0: 2020 2020 2020 2020 2069 6620 7461 6720 if tag \n+0003add0: 6973 206e 6f74 204e 6f6e 6520 616e 6420 is not None and \n+0003ade0: 7461 6720 213d 2074 6167 5f66 726f 6d5f tag != tag_from_\n+0003adf0: 7061 7468 2870 6174 6829 3a0a 2020 2020 path(path):. \n+0003ae00: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0003ae10: 7261 6973 6520 4368 616e 6e65 6c45 7272 raise ChannelErr\n+0003ae20: 6f72 2827 6368 616e 6765 2d63 6f6e 666c or('change-confl\n+0003ae30: 6963 7427 290a 2020 2020 2020 2020 2020 ict'). \n+0003ae40: 2020 2020 2020 7769 7468 2063 6f6e 7465 with conte\n+0003ae50: 7874 6c69 622e 7375 7070 7265 7373 2846 xtlib.suppress(F\n+0003ae60: 696c 654e 6f74 466f 756e 6445 7272 6f72 ileNotFoundError\n+0003ae70: 293a 2020 2320 6465 6c65 7465 2069 7320 ): # delete is \n+0003ae80: 6964 656d 706f 7465 6e74 0a20 2020 2020 idempotent. \n+0003ae90: 2020 2020 2020 2020 2020 2020 2020 206f o\n+0003aea0: 732e 756e 6c69 6e6b 2870 6174 6829 0a20 s.unlink(path). \n+0003aeb0: 2020 2020 2020 2020 2020 2065 6c73 653a else:\n+0003aec0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+0003aed0: 2023 206f 7468 6572 7769 7365 2c20 7370 # otherwise, sp\n+0003aee0: 6f6f 6c20 6461 7461 2069 6e74 6f20 6120 ool data into a \n+0003aef0: 7465 6d70 6f72 6172 7920 6669 6c65 2075 temporary file u\n+0003af00: 6e74 696c 2045 4f46 2074 6865 6e20 7265 ntil EOF then re\n+0003af10: 6e61 6d65 2069 6e74 6f20 706c 6163 652e name into place.\n+0003af20: 2e2e 0a20 2020 2020 2020 2020 2020 2020 ... \n+0003af30: 2020 2077 6974 6820 7465 6d70 6669 6c65 with tempfile\n+0003af40: 2e4e 616d 6564 5465 6d70 6f72 6172 7946 .NamedTemporaryF\n+0003af50: 696c 6528 6469 723d 6469 726e 616d 652c ile(dir=dirname,\n+0003af60: 2070 7265 6669 783d 6627 2e7b 6261 7365 prefix=f'.{base\n+0003af70: 6e61 6d65 7d2d 272c 2064 656c 6574 653d name}-', delete=\n+0003af80: 4661 6c73 6529 2061 7320 746d 703a 0a20 False) as tmp:. \n+0003af90: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0003afa0: 2020 2064 656c 6574 655f 6f6e 5f65 7869 delete_on_exi\n+0003afb0: 7420 3d20 746d 702e 6e61 6d65 0a20 2020 t = tmp.name. \n+0003afc0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0003afd0: 206c 6f6f 7020 3d20 6173 796e 6369 6f2e loop = asyncio.\n+0003afe0: 6765 745f 7275 6e6e 696e 675f 6c6f 6f70 get_running_loop\n+0003aff0: 2829 0a20 2020 2020 2020 2020 2020 2020 (). \n+0003b000: 2020 2020 2020 2077 6869 6c65 2064 6174 while dat\n+0003b010: 6120 6973 206e 6f74 204e 6f6e 653a 0a20 a is not None:. \n+0003b020: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0003b030: 2020 2020 2020 2061 7761 6974 206c 6f6f await loo\n+0003b040: 702e 7275 6e5f 696e 5f65 7865 6375 746f p.run_in_executo\n+0003b050: 7228 4e6f 6e65 2c20 746d 702e 7772 6974 r(None, tmp.writ\n+0003b060: 652c 2064 6174 6129 0a20 2020 2020 2020 e, data). \n+0003b070: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0003b080: 2064 6174 6120 3d20 6177 6169 7420 7365 data = await se\n+0003b090: 6c66 2e72 6561 6428 290a 0a20 2020 2020 lf.read().. \n+0003b0a0: 2020 2020 2020 2020 2020 2020 2020 2061 a\n+0003b0b0: 7761 6974 206c 6f6f 702e 7275 6e5f 696e wait loop.run_in\n+0003b0c0: 5f65 7865 6375 746f 7228 4e6f 6e65 2c20 _executor(None, \n+0003b0d0: 6f73 2e66 6461 7461 7379 6e63 2c20 746d os.fdatasync, tm\n+0003b0e0: 702e 6669 6c65 6e6f 2829 290a 0a20 2020 p.fileno()).. \n+0003b0f0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0003b100: 2069 6620 7461 6720 6973 204e 6f6e 653a if tag is None:\n+0003b110: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+0003b120: 2020 2020 2020 2020 2023 206e 6f20 7072 # no pr\n+0003b130: 6563 6f6e 6469 7469 6f6e 7320 6162 6f75 econditions abou\n+0003b140: 7420 7768 6174 2063 7572 7265 6e74 6c79 t what currently\n+0003b150: 2065 7869 7374 7320 6f72 206e 6f74 0a20 exists or not. \n+0003b160: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0003b170: 2020 2020 2020 2023 2063 616c 6375 6c61 # calcula\n+0003b180: 7465 2074 6865 2066 696c 6520 6d6f 6465 te the file mode\n+0003b190: 2066 726f 6d20 7468 6520 756d 6173 6b0a from the umask.\n+0003b1a0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0003b1b0: 2020 2020 2020 2020 6f73 2e66 6368 6d6f os.fchmo\n+0003b1c0: 6428 746d 702e 6669 6c65 6e6f 2829 2c20 d(tmp.fileno(), \n+0003b1d0: 306f 3636 3620 2620 7e6d 795f 756d 6173 0o666 & ~my_umas\n+0003b1e0: 6b28 2929 0a20 2020 2020 2020 2020 2020 k()). \n+0003b1f0: 2020 2020 2020 2020 2020 2020 206f 732e os.\n+0003b200: 7265 6e61 6d65 2874 6d70 2e6e 616d 652c rename(tmp.name,\n+0003b210: 2070 6174 6829 0a20 2020 2020 2020 2020 path). \n+0003b220: 2020 2020 2020 2020 2020 2020 2020 2064 d\n+0003b230: 656c 6574 655f 6f6e 5f65 7869 7420 3d20 elete_on_exit = \n+0003b240: 4e6f 6e65 0a0a 2020 2020 2020 2020 2020 None.. \n+0003b250: 2020 2020 2020 2020 2020 656c 6966 2074 elif t\n+0003b260: 6167 203d 3d20 272d 273a 0a20 2020 2020 ag == '-':. \n+0003b270: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0003b280: 2020 2023 2074 6865 2066 696c 6520 6d75 # the file mu\n+0003b290: 7374 206e 6f74 2065 7869 7374 2e20 2066 st not exist. f\n+0003b2a0: 696c 6520 6d6f 6465 2066 726f 6d20 756d ile mode from um\n+0003b2b0: 6173 6b2e 0a20 2020 2020 2020 2020 2020 ask.. \n+0003b2c0: 2020 2020 2020 2020 2020 2020 206f 732e os.\n+0003b2d0: 6663 686d 6f64 2874 6d70 2e66 696c 656e fchmod(tmp.filen\n+0003b2e0: 6f28 292c 2030 6f36 3636 2026 207e 6d79 o(), 0o666 & ~my\n+0003b2f0: 5f75 6d61 736b 2829 290a 2020 2020 2020 _umask()). \n+0003b300: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0003b310: 2020 6f73 2e6c 696e 6b28 746d 702e 6e61 os.link(tmp.na\n+0003b320: 6d65 2c20 7061 7468 2920 2023 2077 696c me, path) # wil\n+0003b330: 6c20 6661 696c 2069 6620 6669 6c65 2065 l fail if file e\n+0003b340: 7869 7374 730a 0a20 2020 2020 2020 2020 xists.. \n+0003b350: 2020 2020 2020 2020 2020 2065 6c73 653a else:\n+0003b360: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+0003b370: 2020 2020 2020 2020 2023 2074 6865 2066 # the f\n+0003b380: 696c 6520 6d75 7374 2065 7869 7374 2077 ile must exist w\n+0003b390: 6974 6820 7468 6520 6769 7665 6e20 7461 ith the given ta\n+0003b3a0: 670a 2020 2020 2020 2020 2020 2020 2020 g. \n+0003b3b0: 2020 2020 2020 2020 2020 6275 6620 3d20 buf = \n+0003b3c0: 6f73 2e73 7461 7428 7061 7468 290a 2020 os.stat(path). \n+0003b3d0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0003b3e0: 2020 2020 2020 6966 2074 6167 2021 3d20 if tag != \n+0003b3f0: 7461 675f 6672 6f6d 5f73 7461 7428 6275 tag_from_stat(bu\n+0003b400: 6629 3a0a 2020 2020 2020 2020 2020 2020 f):. \n+0003b410: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0003b420: 7261 6973 6520 4368 616e 6e65 6c45 7272 raise ChannelErr\n+0003b430: 6f72 2827 6368 616e 6765 2d63 6f6e 666c or('change-confl\n+0003b440: 6963 7427 290a 2020 2020 2020 2020 2020 ict'). \n+0003b450: 2020 2020 2020 2020 2020 2020 2020 2320 # \n+0003b460: 6368 6f77 6e2f 6368 6d6f 6420 6672 6f6d chown/chmod from\n+0003b470: 2074 6865 2065 7869 7374 696e 6720 6669 the existing fi\n+0003b480: 6c65 2070 6572 6d69 7373 696f 6e73 0a20 le permissions. \n+0003b490: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0003b4a0: 2020 2020 2020 206f 732e 6663 686d 6f64 os.fchmod\n+0003b4b0: 2874 6d70 2e66 696c 656e 6f28 292c 2073 (tmp.fileno(), s\n+0003b4c0: 7461 742e 535f 494d 4f44 4528 6275 662e tat.S_IMODE(buf.\n+0003b4d0: 7374 5f6d 6f64 6529 290a 2020 2020 2020 st_mode)). \n+0003b4e0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0003b4f0: 2020 6f73 2e66 6368 6f77 6e28 746d 702e os.fchown(tmp.\n+0003b500: 6669 6c65 6e6f 2829 2c20 6275 662e 7374 fileno(), buf.st\n+0003b510: 5f75 6964 2c20 6275 662e 7374 5f67 6964 _uid, buf.st_gid\n+0003b520: 290a 2020 2020 2020 2020 2020 2020 2020 ). \n+0003b530: 2020 2020 2020 2020 2020 6f73 2e72 656e os.ren\n+0003b540: 616d 6528 746d 702e 6e61 6d65 2c20 7061 ame(tmp.name, pa\n+0003b550: 7468 290a 2020 2020 2020 2020 2020 2020 th). \n+0003b560: 2020 2020 2020 2020 2020 2020 6465 6c65 dele\n+0003b570: 7465 5f6f 6e5f 6578 6974 203d 204e 6f6e te_on_exit = Non\n+0003b580: 650a 0a20 2020 2020 2020 2065 7863 6570 e.. excep\n+0003b590: 7420 4669 6c65 4e6f 7446 6f75 6e64 4572 t FileNotFoundEr\n+0003b5a0: 726f 7220 6173 2065 7863 3a0a 2020 2020 ror as exc:. \n+0003b5b0: 2020 2020 2020 2020 7261 6973 6520 4368 raise Ch\n+0003b5c0: 616e 6e65 6c45 7272 6f72 2827 6e6f 742d annelError('not-\n+0003b5d0: 666f 756e 6427 2920 6672 6f6d 2065 7863 found') from exc\n+0003b5e0: 0a20 2020 2020 2020 2065 7863 6570 7420 . except \n+0003b5f0: 4669 6c65 4578 6973 7473 4572 726f 7220 FileExistsError \n+0003b600: 6173 2065 7863 3a0a 2020 2020 2020 2020 as exc:. \n+0003b610: 2020 2020 2320 7468 6174 2773 2066 726f # that's fro\n+0003b620: 6d20 6c69 6e6b 2829 206e 6f74 6963 696e m link() noticin\n+0003b630: 6720 7468 6174 2074 6865 2074 6172 6765 g that the targe\n+0003b640: 7420 6669 6c65 2061 6c72 6561 6479 2065 t file already e\n+0003b650: 7869 7374 730a 2020 2020 2020 2020 2020 xists. \n+0003b660: 2020 7261 6973 6520 4368 616e 6e65 6c45 raise ChannelE\n+0003b670: 7272 6f72 2827 6368 616e 6765 2d63 6f6e rror('change-con\n+0003b680: 666c 6963 7427 2920 6672 6f6d 2065 7863 flict') from exc\n+0003b690: 0a20 2020 2020 2020 2065 7863 6570 7420 . except \n+0003b6a0: 5065 726d 6973 7369 6f6e 4572 726f 7220 PermissionError \n+0003b6b0: 6173 2065 7863 3a0a 2020 2020 2020 2020 as exc:. \n+0003b6c0: 2020 2020 7261 6973 6520 4368 616e 6e65 raise Channe\n+0003b6d0: 6c45 7272 6f72 2827 6163 6365 7373 2d64 lError('access-d\n+0003b6e0: 656e 6965 6427 2920 6672 6f6d 2065 7863 enied') from exc\n+0003b6f0: 0a20 2020 2020 2020 2065 7863 6570 7420 . except \n+0003b700: 4973 4144 6972 6563 746f 7279 4572 726f IsADirectoryErro\n+0003b710: 7220 6173 2065 7863 3a0a 2020 2020 2020 r as exc:. \n+0003b720: 2020 2020 2020 2320 6e6f 7420 6964 6561 # not idea\n+0003b730: 6c2c 2062 7574 2074 6865 2063 6c6f 7365 l, but the close\n+0003b740: 7374 2063 6f64 6520 7765 2068 6176 650a st code we have.\n+0003b750: 2020 2020 2020 2020 2020 2020 7261 6973 rais\n+0003b760: 6520 4368 616e 6e65 6c45 7272 6f72 2827 e ChannelError('\n+0003b770: 6163 6365 7373 2d64 656e 6965 6427 2c20 access-denied', \n+0003b780: 6d65 7373 6167 653d 7374 7228 6578 6329 message=str(exc)\n+0003b790: 2920 6672 6f6d 2065 7863 0a20 2020 2020 ) from exc. \n+0003b7a0: 2020 2065 7863 6570 7420 4f53 4572 726f except OSErro\n+0003b7b0: 7220 6173 2065 7863 3a0a 2020 2020 2020 r as exc:. \n+0003b7c0: 2020 2020 2020 7261 6973 6520 4368 616e raise Chan\n+0003b7d0: 6e65 6c45 7272 6f72 2827 696e 7465 726e nelError('intern\n+0003b7e0: 616c 2d65 7272 6f72 272c 206d 6573 7361 al-error', messa\n+0003b7f0: 6765 3d73 7472 2865 7863 2929 2066 726f ge=str(exc)) fro\n+0003b800: 6d20 6578 630a 2020 2020 2020 2020 6669 m exc. fi\n+0003b810: 6e61 6c6c 793a 0a20 2020 2020 2020 2020 nally:. \n+0003b820: 2020 2069 6620 6465 6c65 7465 5f6f 6e5f if delete_on_\n+0003b830: 6578 6974 2069 7320 6e6f 7420 4e6f 6e65 exit is not None\n+0003b840: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n+0003b850: 2020 6f73 2e75 6e6c 696e 6b28 6465 6c65 os.unlink(dele\n+0003b860: 7465 5f6f 6e5f 6578 6974 290a 0a20 2020 te_on_exit).. \n+0003b870: 2020 2020 2073 656c 662e 646f 6e65 2829 self.done()\n+0003b880: 0a0a 2020 2020 2020 2020 7265 7475 726e .. return\n+0003b890: 207b 2774 6167 273a 2074 6167 5f66 726f {'tag': tag_fro\n+0003b8a0: 6d5f 7061 7468 2870 6174 6829 7d0a 0a0a m_path(path)}...\n+0003b8b0: 636c 6173 7320 4673 5761 7463 6843 6861 class FsWatchCha\n+0003b8c0: 6e6e 656c 2843 6861 6e6e 656c 293a 0a20 nnel(Channel):. \n+0003b8d0: 2020 2070 6179 6c6f 6164 203d 2027 6673 payload = 'fs\n+0003b8e0: 7761 7463 6831 270a 2020 2020 5f74 6167 watch1'. _tag\n+0003b8f0: 203d 204e 6f6e 650a 2020 2020 5f70 6174 = None. _pat\n+0003b900: 6820 3d20 4e6f 6e65 0a20 2020 205f 7761 h = None. _wa\n+0003b910: 7463 6820 3d20 4e6f 6e65 0a0a 2020 2020 tch = None.. \n+0003b920: 2320 5468 6520 4320 6272 6964 6765 2064 # The C bridge d\n+0003b930: 6f65 736e 2774 2073 656e 6420 7468 6520 oesn't send the \n+0003b940: 696e 6974 6961 6c20 6576 656e 742c 2061 initial event, a\n+0003b950: 6e64 2074 6865 204a 5320 6361 6c6c 7320 nd the JS calls \n+0003b960: 7265 6164 2829 0a20 2020 2023 2069 6e73 read(). # ins\n+0003b970: 7465 6164 2074 6f20 6669 6775 7265 206f tead to figure o\n+0003b980: 7574 2074 6865 2069 6e69 7469 616c 2073 ut the initial s\n+0003b990: 7461 7465 206f 6620 7468 6520 6669 6c65 tate of the file\n+0003b9a0: 2e20 2049 6620 7765 2073 656e 6420 7468 . If we send th\n+0003b9b0: 650a 2020 2020 2320 696e 6974 6961 6c20 e. # initial \n+0003b9c0: 7374 6174 6520 7468 656e 2077 6520 6361 state then we ca\n+0003b9d0: 7573 6520 7468 6520 6576 656e 7420 746f use the event to\n+0003b9e0: 2067 6574 2064 656c 6976 6572 6564 2074 get delivered t\n+0003b9f0: 7769 6365 2e0a 2020 2020 2320 4964 6561 wice.. # Idea\n+0003ba00: 6c6c 7920 7765 276c 6c20 736f 7274 2074 lly we'll sort t\n+0003ba10: 6861 7420 6f75 7420 6174 2073 6f6d 6520 hat out at some \n+0003ba20: 706f 696e 742c 2062 7574 2066 6f72 206e point, but for n\n+0003ba30: 6f77 2c20 7375 7070 7265 7373 2069 742e ow, suppress it.\n+0003ba40: 0a20 2020 205f 6163 7469 7665 203d 2046 . _active = F\n+0003ba50: 616c 7365 0a0a 2020 2020 4073 7461 7469 alse.. @stati\n+0003ba60: 636d 6574 686f 640a 2020 2020 6465 6620 cmethod. def \n+0003ba70: 6d61 736b 5f74 6f5f 6576 656e 745f 616e mask_to_event_an\n+0003ba80: 645f 7479 7065 286d 6173 6b29 3a0a 2020 d_type(mask):. \n+0003ba90: 2020 2020 2020 6966 2028 496e 6f74 6966 if (Inotif\n+0003baa0: 7945 7665 6e74 2e43 5245 4154 4520 6f72 yEvent.CREATE or\n+0003bab0: 2049 6e6f 7469 6679 4576 656e 742e 4d4f InotifyEvent.MO\n+0003bac0: 5645 445f 544f 2920 696e 206d 6173 6b3a VED_TO) in mask:\n+0003bad0: 0a20 2020 2020 2020 2020 2020 2072 6574 . ret\n+0003bae0: 7572 6e20 2763 7265 6174 6564 272c 2027 urn 'created', '\n+0003baf0: 6469 7265 6374 6f72 7927 2069 6620 496e directory' if In\n+0003bb00: 6f74 6966 7945 7665 6e74 2e49 5344 4952 otifyEvent.ISDIR\n+0003bb10: 2069 6e20 6d61 736b 2065 6c73 6520 2766 in mask else 'f\n+0003bb20: 696c 6527 0a20 2020 2020 2020 2065 6c69 ile'. eli\n+0003bb30: 6620 496e 6f74 6966 7945 7665 6e74 2e4d f InotifyEvent.M\n+0003bb40: 4f56 4544 5f46 524f 4d20 696e 206d 6173 OVED_FROM in mas\n+0003bb50: 6b20 6f72 2049 6e6f 7469 6679 4576 656e k or InotifyEven\n+0003bb60: 742e 4445 4c45 5445 2069 6e20 6d61 736b t.DELETE in mask\n+0003bb70: 206f 7220 496e 6f74 6966 7945 7665 6e74 or InotifyEvent\n+0003bb80: 2e44 454c 4554 455f 5345 4c46 2069 6e20 .DELETE_SELF in \n+0003bb90: 6d61 736b 3a0a 2020 2020 2020 2020 2020 mask:. \n+0003bba0: 2020 7265 7475 726e 2027 6465 6c65 7465 return 'delete\n+0003bbb0: 6427 2c20 4e6f 6e65 0a20 2020 2020 2020 d', None. \n+0003bbc0: 2065 6c69 6620 496e 6f74 6966 7945 7665 elif InotifyEve\n+0003bbd0: 6e74 2e41 5454 5249 4220 696e 206d 6173 nt.ATTRIB in mas\n+0003bbe0: 6b3a 0a20 2020 2020 2020 2020 2020 2072 k:. r\n+0003bbf0: 6574 7572 6e20 2761 7474 7269 6275 7465 eturn 'attribute\n+0003bc00: 2d63 6861 6e67 6564 272c 204e 6f6e 650a -changed', None.\n+0003bc10: 2020 2020 2020 2020 656c 6966 2049 6e6f elif Ino\n+0003bc20: 7469 6679 4576 656e 742e 434c 4f53 455f tifyEvent.CLOSE_\n+0003bc30: 5752 4954 4520 696e 206d 6173 6b3a 0a20 WRITE in mask:. \n+0003bc40: 2020 2020 2020 2020 2020 2072 6574 7572 retur\n+0003bc50: 6e20 2764 6f6e 652d 6869 6e74 272c 204e n 'done-hint', N\n+0003bc60: 6f6e 650a 2020 2020 2020 2020 656c 7365 one. else\n+0003bc70: 3a0a 2020 2020 2020 2020 2020 2020 7265 :. re\n+0003bc80: 7475 726e 2027 6368 616e 6765 6427 2c20 turn 'changed', \n+0003bc90: 4e6f 6e65 0a0a 2020 2020 6465 6620 646f None.. def do\n+0003bca0: 5f69 6e6f 7469 6679 5f65 7665 6e74 2873 _inotify_event(s\n+0003bcb0: 656c 662c 206d 6173 6b2c 205f 636f 6f6b elf, mask, _cook\n+0003bcc0: 6965 2c20 6e61 6d65 293a 0a20 2020 2020 ie, name):. \n+0003bcd0: 2020 206c 6f67 6765 722e 6465 6275 6728 logger.debug(\n+0003bce0: 2264 6f5f 696e 6f74 6966 795f 6576 656e \"do_inotify_even\n+0003bcf0: 7428 2573 293a 206d 6173 6b20 2558 206e t(%s): mask %X n\n+0003bd00: 616d 6520 2573 222c 2073 656c 662e 5f70 ame %s\", self._p\n+0003bd10: 6174 682c 206d 6173 6b2c 206e 616d 6529 ath, mask, name)\n+0003bd20: 0a20 2020 2020 2020 2065 7665 6e74 2c20 . event, \n+0003bd30: 7479 7065 5f20 3d20 7365 6c66 2e6d 6173 type_ = self.mas\n+0003bd40: 6b5f 746f 5f65 7665 6e74 5f61 6e64 5f74 k_to_event_and_t\n+0003bd50: 7970 6528 6d61 736b 290a 2020 2020 2020 ype(mask). \n+0003bd60: 2020 6966 206e 616d 653a 0a20 2020 2020 if name:. \n+0003bd70: 2020 2020 2020 2023 2066 696c 6520 696e # file in\n+0003bd80: 7369 6465 2077 6174 6368 6564 2064 6972 side watched dir\n+0003bd90: 6563 746f 7279 2063 6861 6e67 6564 0a20 ectory changed. \n+0003bda0: 2020 2020 2020 2020 2020 2070 6174 6820 path \n+0003bdb0: 3d20 6f73 2e70 6174 682e 6a6f 696e 2873 = os.path.join(s\n+0003bdc0: 656c 662e 5f70 6174 682c 206e 616d 652e elf._path, name.\n+0003bdd0: 6465 636f 6465 2829 290a 2020 2020 2020 decode()). \n+0003bde0: 2020 2020 2020 7461 6720 3d20 7461 675f tag = tag_\n+0003bdf0: 6672 6f6d 5f70 6174 6828 7061 7468 290a from_path(path).\n+0003be00: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n+0003be10: 2e73 656e 645f 6a73 6f6e 2865 7665 6e74 .send_json(event\n+0003be20: 3d65 7665 6e74 2c20 7061 7468 3d70 6174 =event, path=pat\n+0003be30: 682c 2074 6167 3d74 6167 2c20 7479 7065 h, tag=tag, type\n+0003be40: 3d74 7970 655f 290a 2020 2020 2020 2020 =type_). \n+0003be50: 656c 7365 3a0a 2020 2020 2020 2020 2020 else:. \n+0003be60: 2020 2320 7468 6520 7761 7463 6865 6420 # the watched \n+0003be70: 7061 7468 2069 7473 656c 6620 6368 616e path itself chan\n+0003be80: 6765 643b 2066 696c 7465 7220 6f75 7420 ged; filter out \n+0003be90: 6475 706c 6963 6174 6520 6576 656e 7473 duplicate events\n+0003bea0: 0a20 2020 2020 2020 2020 2020 2074 6167 . tag\n+0003beb0: 203d 2074 6167 5f66 726f 6d5f 7061 7468 = tag_from_path\n+0003bec0: 2873 656c 662e 5f70 6174 6829 0a20 2020 (self._path). \n+0003bed0: 2020 2020 2020 2020 2069 6620 7461 6720 if tag \n+0003bee0: 3d3d 2073 656c 662e 5f74 6167 3a0a 2020 == self._tag:. \n+0003bef0: 2020 2020 2020 2020 2020 2020 2020 7265 re\n+0003bf00: 7475 726e 0a20 2020 2020 2020 2020 2020 turn. \n+0003bf10: 2073 656c 662e 5f74 6167 203d 2074 6167 self._tag = tag\n+0003bf20: 0a20 2020 2020 2020 2020 2020 2073 656c . sel\n+0003bf30: 662e 7365 6e64 5f6a 736f 6e28 6576 656e f.send_json(even\n+0003bf40: 743d 6576 656e 742c 2070 6174 683d 7365 t=event, path=se\n+0003bf50: 6c66 2e5f 7061 7468 2c20 7461 673d 7365 lf._path, tag=se\n+0003bf60: 6c66 2e5f 7461 672c 2074 7970 653d 7479 lf._tag, type=ty\n+0003bf70: 7065 5f29 0a0a 2020 2020 6465 6620 646f pe_).. def do\n+0003bf80: 5f69 6465 6e74 6974 795f 6368 616e 6765 _identity_change\n+0003bf90: 6428 7365 6c66 2c20 6664 2c20 6572 7229 d(self, fd, err)\n+0003bfa0: 3a0a 2020 2020 2020 2020 6c6f 6767 6572 :. logger\n+0003bfb0: 2e64 6562 7567 2822 646f 5f69 6465 6e74 .debug(\"do_ident\n+0003bfc0: 6974 795f 6368 616e 6765 6428 2573 293a ity_changed(%s):\n+0003bfd0: 2066 6420 2573 2c20 6572 7220 2573 222c fd %s, err %s\",\n+0003bfe0: 2073 656c 662e 5f70 6174 682c 2073 7472 self._path, str\n+0003bff0: 2866 6429 2c20 6572 7229 0a20 2020 2020 (fd), err). \n+0003c000: 2020 2073 656c 662e 5f74 6167 203d 2074 self._tag = t\n+0003c010: 6167 5f66 726f 6d5f 6664 2866 6429 2069 ag_from_fd(fd) i\n+0003c020: 6620 6664 2065 6c73 6520 272d 270a 2020 f fd else '-'. \n+0003c030: 2020 2020 2020 6966 2073 656c 662e 5f61 if self._a\n+0003c040: 6374 6976 653a 0a20 2020 2020 2020 2020 ctive:. \n+0003c050: 2020 2073 656c 662e 7365 6e64 5f6a 736f self.send_jso\n+0003c060: 6e28 6576 656e 743d 2763 7265 6174 6564 n(event='created\n+0003c070: 2720 6966 2066 6420 656c 7365 2027 6465 ' if fd else 'de\n+0003c080: 6c65 7465 6427 2c20 7061 7468 3d73 656c leted', path=sel\n+0003c090: 662e 5f70 6174 682c 2074 6167 3d73 656c f._path, tag=sel\n+0003c0a0: 662e 5f74 6167 290a 0a20 2020 2064 6566 f._tag).. def\n+0003c0b0: 2064 6f5f 6f70 656e 2873 656c 662c 206f do_open(self, o\n+0003c0c0: 7074 696f 6e73 293a 0a20 2020 2020 2020 ptions):. \n+0003c0d0: 2073 656c 662e 5f70 6174 6820 3d20 6f70 self._path = op\n+0003c0e0: 7469 6f6e 735b 2770 6174 6827 5d0a 2020 tions['path']. \n+0003c0f0: 2020 2020 2020 7365 6c66 2e5f 7461 6720 self._tag \n+0003c100: 3d20 4e6f 6e65 0a0a 2020 2020 2020 2020 = None.. \n+0003c110: 7365 6c66 2e5f 6163 7469 7665 203d 2046 self._active = F\n+0003c120: 616c 7365 0a20 2020 2020 2020 2073 656c alse. sel\n+0003c130: 662e 5f77 6174 6368 203d 2050 6174 6857 f._watch = PathW\n+0003c140: 6174 6368 2873 656c 662e 5f70 6174 682c atch(self._path,\n+0003c150: 2073 656c 6629 0a20 2020 2020 2020 2073 self). s\n+0003c160: 656c 662e 5f61 6374 6976 6520 3d20 5472 elf._active = Tr\n+0003c170: 7565 0a0a 2020 2020 2020 2020 7365 6c66 ue.. self\n+0003c180: 2e72 6561 6479 2829 0a0a 2020 2020 6465 .ready().. de\n+0003c190: 6620 646f 5f63 6c6f 7365 2873 656c 6629 f do_close(self)\n+0003c1a0: 3a0a 2020 2020 2020 2020 7365 6c66 2e5f :. self._\n+0003c1b0: 7761 7463 682e 636c 6f73 6528 290a 2020 watch.close(). \n+0003c1c0: 2020 2020 2020 7365 6c66 2e5f 7761 7463 self._watc\n+0003c1d0: 6820 3d20 4e6f 6e65 0a20 2020 2020 2020 h = None. \n+0003c1e0: 2073 656c 662e 636c 6f73 6528 290a 0a0a self.close()...\n+0003c1f0: 636c 6173 7320 466f 6c6c 6f77 2865 6e75 class Follow(enu\n+0003c200: 6d2e 456e 756d 293a 0a20 2020 204e 4f20 m.Enum):. NO \n+0003c210: 3d20 4661 6c73 650a 2020 2020 5945 5320 = False. YES \n+0003c220: 3d20 5472 7565 0a0a 0a63 6c61 7373 2046 = True...class F\n+0003c230: 7349 6e66 6f43 6861 6e6e 656c 2843 6861 sInfoChannel(Cha\n+0003c240: 6e6e 656c 2c20 5061 7468 5761 7463 684c nnel, PathWatchL\n+0003c250: 6973 7465 6e65 7229 3a0a 2020 2020 7061 istener):. pa\n+0003c260: 796c 6f61 6420 3d20 2766 7369 6e66 6f27 yload = 'fsinfo'\n+0003c270: 0a0a 2020 2020 2320 4f70 7469 6f6e 7320 .. # Options \n+0003c280: 2861 6c6c 2067 6574 2073 6574 2069 6e20 (all get set in \n+0003c290: 6064 6f5f 6f70 656e 2829 6029 0a20 2020 `do_open()`). \n+0003c2a0: 2070 6174 683a 2073 7472 0a20 2020 2061 path: str. a\n+0003c2b0: 7474 7273 3a20 2773 6574 5b73 7472 5d27 ttrs: 'set[str]'\n+0003c2c0: 0a20 2020 2066 6e6d 6174 6368 3a20 7374 . fnmatch: st\n+0003c2d0: 720a 2020 2020 7461 7267 6574 733a 2062 r. targets: b\n+0003c2e0: 6f6f 6c0a 2020 2020 666f 6c6c 6f77 3a20 ool. follow: \n+0003c2f0: 626f 6f6c 0a20 2020 2077 6174 6368 3a20 bool. watch: \n+0003c300: 626f 6f6c 0a0a 2020 2020 2320 5374 6174 bool.. # Stat\n+0003c310: 650a 2020 2020 6375 7272 656e 745f 7661 e. current_va\n+0003c320: 6c75 653a 204a 736f 6e44 6963 740a 2020 lue: JsonDict. \n+0003c330: 2020 6566 6665 6374 6976 655f 666e 6d61 effective_fnma\n+0003c340: 7463 683a 2073 7472 203d 2027 270a 2020 tch: str = ''. \n+0003c350: 2020 6664 3a20 2748 616e 646c 6520 7c20 fd: 'Handle | \n+0003c360: 4e6f 6e65 2720 3d20 4e6f 6e65 0a20 2020 None' = None. \n+0003c370: 2070 656e 6469 6e67 3a20 2773 6574 5b73 pending: 'set[s\n+0003c380: 7472 5d20 7c20 4e6f 6e65 2720 3d20 4e6f tr] | None' = No\n+0003c390: 6e65 0a20 2020 2070 6174 685f 7761 7463 ne. path_watc\n+0003c3a0: 683a 2027 5061 7468 5761 7463 6820 7c20 h: 'PathWatch | \n+0003c3b0: 4e6f 6e65 2720 3d20 4e6f 6e65 0a20 2020 None' = None. \n+0003c3c0: 2067 6574 6174 7472 733a 2027 4361 6c6c getattrs: 'Call\n+0003c3d0: 6162 6c65 5b5b 696e 742c 2073 7472 2c20 able[[int, str, \n+0003c3e0: 466f 6c6c 6f77 5d2c 204a 736f 6e44 6f63 Follow], JsonDoc\n+0003c3f0: 756d 656e 745d 270a 0a20 2020 2040 7374 ument]'.. @st\n+0003c400: 6174 6963 6d65 7468 6f64 0a20 2020 2064 aticmethod. d\n+0003c410: 6566 206d 616b 655f 6765 7461 7474 7273 ef make_getattrs\n+0003c420: 2861 7474 7273 3a20 4974 6572 6162 6c65 (attrs: Iterable\n+0003c430: 5b73 7472 5d29 202d 3e20 2743 616c 6c61 [str]) -> 'Calla\n+0003c440: 626c 655b 5b69 6e74 2c20 7374 722c 2046 ble[[int, str, F\n+0003c450: 6f6c 6c6f 775d 2c20 4a73 6f6e 446f 6375 ollow], JsonDocu\n+0003c460: 6d65 6e74 207c 204e 6f6e 655d 273a 0a20 ment | None]':. \n+0003c470: 2020 2020 2020 2023 2043 6163 6865 6420 # Cached \n+0003c480: 666f 7220 7468 6520 6475 7261 7469 6f6e for the duration\n+0003c490: 206f 6620 7468 6520 636c 6f73 7572 6520 of the closure \n+0003c4a0: 7765 2772 6520 6372 6561 7469 6e67 0a20 we're creating. \n+0003c4b0: 2020 2020 2020 2040 6675 6e63 746f 6f6c @functool\n+0003c4c0: 732e 6c72 755f 6361 6368 6528 290a 2020 s.lru_cache(). \n+0003c4d0: 2020 2020 2020 6465 6620 6765 745f 7573 def get_us\n+0003c4e0: 6572 2875 6964 3a20 696e 7429 202d 3e20 er(uid: int) -> \n+0003c4f0: 2773 7472 207c 2069 6e74 273a 0a20 2020 'str | int':. \n+0003c500: 2020 2020 2020 2020 2074 7279 3a0a 2020 try:. \n+0003c510: 2020 2020 2020 2020 2020 2020 2020 7265 re\n+0003c520: 7475 726e 2070 7764 2e67 6574 7077 7569 turn pwd.getpwui\n+0003c530: 6428 7569 6429 2e70 775f 6e61 6d65 0a20 d(uid).pw_name. \n+0003c540: 2020 2020 2020 2020 2020 2065 7863 6570 excep\n+0003c550: 7420 4b65 7945 7272 6f72 3a0a 2020 2020 t KeyError:. \n+0003c560: 2020 2020 2020 2020 2020 2020 7265 7475 retu\n+0003c570: 726e 2075 6964 0a0a 2020 2020 2020 2020 rn uid.. \n+0003c580: 4066 756e 6374 6f6f 6c73 2e6c 7275 5f63 @functools.lru_c\n+0003c590: 6163 6865 2829 0a20 2020 2020 2020 2064 ache(). d\n+0003c5a0: 6566 2067 6574 5f67 726f 7570 2867 6964 ef get_group(gid\n+0003c5b0: 3a20 696e 7429 202d 3e20 2773 7472 207c : int) -> 'str |\n+0003c5c0: 2069 6e74 273a 0a20 2020 2020 2020 2020 int':. \n+0003c5d0: 2020 2074 7279 3a0a 2020 2020 2020 2020 try:. \n+0003c5e0: 2020 2020 2020 2020 7265 7475 726e 2067 return g\n+0003c5f0: 7270 2e67 6574 6772 6769 6428 6769 6429 rp.getgrgid(gid)\n+0003c600: 2e67 725f 6e61 6d65 0a20 2020 2020 2020 .gr_name. \n+0003c610: 2020 2020 2065 7863 6570 7420 4b65 7945 except KeyE\n+0003c620: 7272 6f72 3a0a 2020 2020 2020 2020 2020 rror:. \n+0003c630: 2020 2020 2020 7265 7475 726e 2067 6964 return gid\n+0003c640: 0a0a 2020 2020 2020 2020 7374 6174 5f74 .. stat_t\n+0003c650: 7970 6573 203d 207b 7374 6174 2e53 5f49 ypes = {stat.S_I\n+0003c660: 4652 4547 3a20 2772 6567 272c 2073 7461 FREG: 'reg', sta\n+0003c670: 742e 535f 4946 4449 523a 2027 6469 7227 t.S_IFDIR: 'dir'\n+0003c680: 2c20 7374 6174 2e53 5f49 464c 4e4b 3a20 , stat.S_IFLNK: \n+0003c690: 276c 6e6b 272c 2073 7461 742e 535f 4946 'lnk', stat.S_IF\n+0003c6a0: 4348 523a 2027 6368 7227 2c0a 2020 2020 CHR: 'chr',. \n+0003c6b0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0003c6c0: 2020 7374 6174 2e53 5f49 4642 4c4b 3a20 stat.S_IFBLK: \n+0003c6d0: 2762 6c6b 272c 2073 7461 742e 535f 4946 'blk', stat.S_IF\n+0003c6e0: 4946 4f3a 2027 6669 666f 272c 2073 7461 IFO: 'fifo', sta\n+0003c6f0: 742e 535f 4946 534f 434b 3a20 2773 6f63 t.S_IFSOCK: 'soc\n+0003c700: 6b27 7d0a 2020 2020 2020 2020 6176 6169 k'}. avai\n+0003c710: 6c61 626c 655f 7374 6174 5f67 6574 7465 lable_stat_gette\n+0003c720: 7273 203d 207b 0a20 2020 2020 2020 2020 rs = {. \n+0003c730: 2020 2027 7479 7065 273a 206c 616d 6264 'type': lambd\n+0003c740: 6120 6275 663a 2073 7461 745f 7479 7065 a buf: stat_type\n+0003c750: 732e 6765 7428 7374 6174 2e53 5f49 464d s.get(stat.S_IFM\n+0003c760: 5428 6275 662e 7374 5f6d 6f64 6529 292c T(buf.st_mode)),\n+0003c770: 0a20 2020 2020 2020 2020 2020 2027 7461 . 'ta\n+0003c780: 6727 3a20 7461 675f 6672 6f6d 5f73 7461 g': tag_from_sta\n+0003c790: 742c 0a20 2020 2020 2020 2020 2020 2027 t,. '\n+0003c7a0: 6d6f 6465 273a 206c 616d 6264 6120 6275 mode': lambda bu\n+0003c7b0: 663a 2073 7461 742e 535f 494d 4f44 4528 f: stat.S_IMODE(\n+0003c7c0: 6275 662e 7374 5f6d 6f64 6529 2c0a 2020 buf.st_mode),. \n+0003c7d0: 2020 2020 2020 2020 2020 2773 697a 6527 'size'\n+0003c7e0: 3a20 6c61 6d62 6461 2062 7566 3a20 6275 : lambda buf: bu\n+0003c7f0: 662e 7374 5f73 697a 652c 0a20 2020 2020 f.st_size,. \n+0003c800: 2020 2020 2020 2027 7569 6427 3a20 6c61 'uid': la\n+0003c810: 6d62 6461 2062 7566 3a20 6275 662e 7374 mbda buf: buf.st\n+0003c820: 5f75 6964 2c0a 2020 2020 2020 2020 2020 _uid,. \n+0003c830: 2020 2767 6964 273a 206c 616d 6264 6120 'gid': lambda \n+0003c840: 6275 663a 2062 7566 2e73 745f 6769 642c buf: buf.st_gid,\n+0003c850: 0a20 2020 2020 2020 2020 2020 2027 6d74 . 'mt\n+0003c860: 696d 6527 3a20 6c61 6d62 6461 2062 7566 ime': lambda buf\n+0003c870: 3a20 6275 662e 7374 5f6d 7469 6d65 2c0a : buf.st_mtime,.\n+0003c880: 2020 2020 2020 2020 2020 2020 2775 7365 'use\n+0003c890: 7227 3a20 6c61 6d62 6461 2062 7566 3a20 r': lambda buf: \n+0003c8a0: 6765 745f 7573 6572 2862 7566 2e73 745f get_user(buf.st_\n+0003c8b0: 7569 6429 2c0a 2020 2020 2020 2020 2020 uid),. \n+0003c8c0: 2020 2767 726f 7570 273a 206c 616d 6264 'group': lambd\n+0003c8d0: 6120 6275 663a 2067 6574 5f67 726f 7570 a buf: get_group\n+0003c8e0: 2862 7566 2e73 745f 6769 6429 2c0a 2020 (buf.st_gid),. \n+0003c8f0: 2020 2020 2020 7d0a 2020 2020 2020 2020 }. \n+0003c900: 7374 6174 5f67 6574 7465 7273 203d 2074 stat_getters = t\n+0003c910: 7570 6c65 2828 6b65 792c 2061 7661 696c uple((key, avail\n+0003c920: 6162 6c65 5f73 7461 745f 6765 7474 6572 able_stat_getter\n+0003c930: 732e 6765 7428 6b65 792c 206c 616d 6264 s.get(key, lambd\n+0003c940: 6120 5f3a 204e 6f6e 6529 2920 666f 7220 a _: None)) for \n+0003c950: 6b65 7920 696e 2061 7474 7273 290a 0a20 key in attrs).. \n+0003c960: 2020 2020 2020 2064 6566 2067 6574 5f61 def get_a\n+0003c970: 7474 7273 2866 643a 2069 6e74 2c20 6e61 ttrs(fd: int, na\n+0003c980: 6d65 3a20 7374 722c 2066 6f6c 6c6f 773a me: str, follow:\n+0003c990: 2046 6f6c 6c6f 7729 202d 3e20 274a 736f Follow) -> 'Jso\n+0003c9a0: 6e44 6963 7420 7c20 4e6f 6e65 273a 0a20 nDict | None':. \n+0003c9b0: 2020 2020 2020 2020 2020 2074 7279 3a0a try:.\n+0003c9c0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0003c9d0: 6275 6620 3d20 6f73 2e73 7461 7428 6e61 buf = os.stat(na\n+0003c9e0: 6d65 2c20 666f 6c6c 6f77 5f73 796d 6c69 me, follow_symli\n+0003c9f0: 6e6b 733d 666f 6c6c 6f77 2e76 616c 7565 nks=follow.value\n+0003ca00: 2c20 6469 725f 6664 3d66 6429 2069 6620 , dir_fd=fd) if \n+0003ca10: 6e61 6d65 2065 6c73 6520 6f73 2e66 7374 name else os.fst\n+0003ca20: 6174 2866 6429 0a20 2020 2020 2020 2020 at(fd). \n+0003ca30: 2020 2065 7863 6570 7420 4669 6c65 4e6f except FileNo\n+0003ca40: 7446 6f75 6e64 4572 726f 723a 0a20 2020 tFoundError:. \n+0003ca50: 2020 2020 2020 2020 2020 2020 2072 6574 ret\n+0003ca60: 7572 6e20 4e6f 6e65 0a20 2020 2020 2020 urn None. \n+0003ca70: 2020 2020 2065 7863 6570 7420 4f53 4572 except OSEr\n+0003ca80: 726f 723a 0a20 2020 2020 2020 2020 2020 ror:. \n+0003ca90: 2020 2020 2072 6574 7572 6e20 7b6e 616d return {nam\n+0003caa0: 653a 204e 6f6e 6520 666f 7220 6e61 6d65 e: None for name\n+0003cab0: 2c20 6675 6e63 2069 6e20 7374 6174 5f67 , func in stat_g\n+0003cac0: 6574 7465 7273 7d0a 0a20 2020 2020 2020 etters}.. \n+0003cad0: 2020 2020 2072 6573 756c 7420 3d20 7b6b result = {k\n+0003cae0: 6579 3a20 6675 6e63 2862 7566 2920 666f ey: func(buf) fo\n+0003caf0: 7220 6b65 792c 2066 756e 6320 696e 2073 r key, func in s\n+0003cb00: 7461 745f 6765 7474 6572 737d 0a0a 2020 tat_getters}.. \n+0003cb10: 2020 2020 2020 2020 2020 6966 2027 7461 if 'ta\n+0003cb20: 7267 6574 2720 696e 2072 6573 756c 7420 rget' in result \n+0003cb30: 616e 6420 7374 6174 2e53 5f49 464d 5428 and stat.S_IFMT(\n+0003cb40: 6275 662e 7374 5f6d 6f64 6529 203d 3d20 buf.st_mode) == \n+0003cb50: 7374 6174 2e53 5f49 464c 4e4b 3a0a 2020 stat.S_IFLNK:. \n+0003cb60: 2020 2020 2020 2020 2020 2020 2020 7769 wi\n+0003cb70: 7468 2063 6f6e 7465 7874 6c69 622e 7375 th contextlib.su\n+0003cb80: 7070 7265 7373 284f 5345 7272 6f72 293a ppress(OSError):\n+0003cb90: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+0003cba0: 2020 2020 2072 6573 756c 745b 2774 6172 result['tar\n+0003cbb0: 6765 7427 5d20 3d20 6f73 2e72 6561 646c get'] = os.readl\n+0003cbc0: 696e 6b28 6e61 6d65 2c20 6469 725f 6664 ink(name, dir_fd\n+0003cbd0: 3d66 6429 0a0a 2020 2020 2020 2020 2020 =fd).. \n+0003cbe0: 2020 7265 7475 726e 2072 6573 756c 740a return result.\n+0003cbf0: 0a20 2020 2020 2020 2072 6574 7572 6e20 . return \n+0003cc00: 6765 745f 6174 7472 730a 0a20 2020 2064 get_attrs.. d\n+0003cc10: 6566 2073 656e 645f 7570 6461 7465 2873 ef send_update(s\n+0003cc20: 656c 662c 2075 7064 6174 6573 3a20 4a73 elf, updates: Js\n+0003cc30: 6f6e 4469 6374 2c20 2a2c 2072 6573 6574 onDict, *, reset\n+0003cc40: 3a20 626f 6f6c 203d 2046 616c 7365 2920 : bool = False) \n+0003cc50: 2d3e 204e 6f6e 653a 0a20 2020 2020 2020 -> None:. \n+0003cc60: 2069 6620 7265 7365 743a 0a20 2020 2020 if reset:. \n+0003cc70: 2020 2020 2020 2069 6620 7365 7428 7365 if set(se\n+0003cc80: 6c66 2e63 7572 7265 6e74 5f76 616c 7565 lf.current_value\n+0003cc90: 2920 2620 7365 7428 7570 6461 7465 7329 ) & set(updates)\n+0003cca0: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n+0003ccb0: 2020 2320 6966 2077 6520 6861 7665 2061 # if we have a\n+0003ccc0: 6e20 6f76 6572 6c61 702c 2077 6520 6e65 n overlap, we ne\n+0003ccd0: 6564 2074 6f20 646f 2061 2070 726f 7065 ed to do a prope\n+0003cce0: 7220 7265 7365 740a 2020 2020 2020 2020 r reset. \n+0003ccf0: 2020 2020 2020 2020 7365 6c66 2e73 656e self.sen\n+0003cd00: 645f 6a73 6f6e 2864 6963 742e 6672 6f6d d_json(dict.from\n+0003cd10: 6b65 7973 2873 656c 662e 6375 7272 656e keys(self.curren\n+0003cd20: 745f 7661 6c75 6529 2c20 7061 7274 6961 t_value), partia\n+0003cd30: 6c3d 5472 7565 290a 2020 2020 2020 2020 l=True). \n+0003cd40: 2020 2020 2020 2020 7365 6c66 2e63 7572 self.cur\n+0003cd50: 7265 6e74 5f76 616c 7565 203d 207b 2770 rent_value = {'p\n+0003cd60: 6172 7469 616c 273a 2054 7275 657d 0a20 artial': True}. \n+0003cd70: 2020 2020 2020 2020 2020 2020 2020 2075 u\n+0003cd80: 7064 6174 6573 2e75 7064 6174 6528 7061 pdates.update(pa\n+0003cd90: 7274 6961 6c3d 4e6f 6e65 290a 2020 2020 rtial=None). \n+0003cda0: 2020 2020 2020 2020 656c 7365 3a0a 2020 else:. \n+0003cdb0: 2020 2020 2020 2020 2020 2020 2020 2320 # \n+0003cdc0: 6f74 6865 7277 6973 6520 7468 6572 6527 otherwise there'\n+0003cdd0: 7320 6e6f 206f 7665 726c 6170 3a20 7765 s no overlap: we\n+0003cde0: 2063 616e 206a 7573 7420 7265 6d6f 7665 can just remove\n+0003cdf0: 2074 6865 206f 6c64 206b 6579 730a 2020 the old keys. \n+0003ce00: 2020 2020 2020 2020 2020 2020 2020 7570 up\n+0003ce10: 6461 7465 732e 7570 6461 7465 2864 6963 dates.update(dic\n+0003ce20: 742e 6672 6f6d 6b65 7973 2873 656c 662e t.fromkeys(self.\n+0003ce30: 6375 7272 656e 745f 7661 6c75 6529 290a current_value)).\n+0003ce40: 0a20 2020 2020 2020 206a 736f 6e5f 6d65 . json_me\n+0003ce50: 7267 655f 616e 645f 6669 6c74 6572 5f70 rge_and_filter_p\n+0003ce60: 6174 6368 2873 656c 662e 6375 7272 656e atch(self.curren\n+0003ce70: 745f 7661 6c75 652c 2075 7064 6174 6573 t_value, updates\n+0003ce80: 290a 2020 2020 2020 2020 6966 2075 7064 ). if upd\n+0003ce90: 6174 6573 3a0a 2020 2020 2020 2020 2020 ates:. \n+0003cea0: 2020 7365 6c66 2e73 656e 645f 6a73 6f6e self.send_json\n+0003ceb0: 2875 7064 6174 6573 290a 0a20 2020 2064 (updates).. d\n+0003cec0: 6566 2070 726f 6365 7373 5f75 7064 6174 ef process_updat\n+0003ced0: 6528 7365 6c66 2c20 7570 6461 7465 733a e(self, updates:\n+0003cee0: 2027 7365 745b 7374 725d 272c 202a 2c20 'set[str]', *, \n+0003cef0: 7265 7365 743a 2062 6f6f 6c20 3d20 4661 reset: bool = Fa\n+0003cf00: 6c73 6529 202d 3e20 4e6f 6e65 3a0a 2020 lse) -> None:. \n+0003cf10: 2020 2020 2020 6173 7365 7274 2073 656c assert sel\n+0003cf20: 662e 6664 2069 7320 6e6f 7420 4e6f 6e65 f.fd is not None\n+0003cf30: 0a0a 2020 2020 2020 2020 656e 7472 6965 .. entrie\n+0003cf40: 733a 204a 736f 6e44 6963 7420 3d20 7b6e s: JsonDict = {n\n+0003cf50: 616d 653a 2073 656c 662e 6765 7461 7474 ame: self.getatt\n+0003cf60: 7273 2873 656c 662e 6664 2c20 6e61 6d65 rs(self.fd, name\n+0003cf70: 2c20 466f 6c6c 6f77 2e4e 4f29 2066 6f72 , Follow.NO) for\n+0003cf80: 206e 616d 6520 696e 2075 7064 6174 6573 name in updates\n+0003cf90: 7d0a 0a20 2020 2020 2020 2069 6e66 6f20 }.. info \n+0003cfa0: 3d20 656e 7472 6965 732e 706f 7028 2727 = entries.pop(''\n+0003cfb0: 2c20 7b7d 290a 2020 2020 2020 2020 6173 , {}). as\n+0003cfc0: 7365 7274 2069 7369 6e73 7461 6e63 6528 sert isinstance(\n+0003cfd0: 696e 666f 2c20 6469 6374 2920 2023 2066 info, dict) # f\n+0003cfe0: 7374 6174 2829 2077 696c 6c20 6e65 7665 stat() will neve\n+0003cff0: 7220 6661 696c 2077 6974 6820 4669 6c65 r fail with File\n+0003d000: 4e6f 7446 6f75 6e64 4572 726f 720a 0a20 NotFoundError.. \n+0003d010: 2020 2020 2020 2069 6620 7365 6c66 2e65 if self.e\n+0003d020: 6666 6563 7469 7665 5f66 6e6d 6174 6368 ffective_fnmatch\n+0003d030: 3a0a 2020 2020 2020 2020 2020 2020 696e :. in\n+0003d040: 666f 5b27 656e 7472 6965 7327 5d20 3d20 fo['entries'] = \n+0003d050: 656e 7472 6965 730a 0a20 2020 2020 2020 entries.. \n+0003d060: 2069 6620 7365 6c66 2e74 6172 6765 7473 if self.targets\n+0003d070: 3a0a 2020 2020 2020 2020 2020 2020 696e :. in\n+0003d080: 666f 5b27 7461 7267 6574 7327 5d20 3d20 fo['targets'] = \n+0003d090: 7461 7267 6574 7320 3d20 7b7d 0a20 2020 targets = {}. \n+0003d0a0: 2020 2020 2020 2020 2066 6f72 206e 616d for nam\n+0003d0b0: 6520 696e 207b 652e 6765 7428 2774 6172 e in {e.get('tar\n+0003d0c0: 6765 7427 2920 666f 7220 6520 696e 2065 get') for e in e\n+0003d0d0: 6e74 7269 6573 2e76 616c 7565 7328 2920 ntries.values() \n+0003d0e0: 6966 2069 7369 6e73 7461 6e63 6528 652c if isinstance(e,\n+0003d0f0: 2064 6963 7429 7d3a 0a20 2020 2020 2020 dict)}:. \n+0003d100: 2020 2020 2020 2020 2069 6620 6973 696e if isin\n+0003d110: 7374 616e 6365 286e 616d 652c 2073 7472 stance(name, str\n+0003d120: 2920 616e 6420 2827 2f27 2069 6e20 6e61 ) and ('/' in na\n+0003d130: 6d65 206f 7220 6e6f 7420 7365 6c66 2e69 me or not self.i\n+0003d140: 6e74 6572 6573 7469 6e67 286e 616d 6529 nteresting(name)\n+0003d150: 293a 0a20 2020 2020 2020 2020 2020 2020 ):. \n+0003d160: 2020 2020 2020 2023 2069 6620 7468 6973 # if this\n+0003d170: 2074 6172 6765 7420 6973 2061 2073 7472 target is a str\n+0003d180: 696e 6720 7468 6174 2077 6520 776f 756c ing that we woul\n+0003d190: 646e 2774 206f 7468 6572 7769 7365 0a20 dn't otherwise. \n+0003d1a0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0003d1b0: 2020 2023 2072 6570 6f72 742c 2074 6865 # report, the\n+0003d1c0: 6e20 7265 706f 7274 2069 7420 7669 6120 n report it via \n+0003d1d0: 6f75 7220 2274 6172 6765 7473 2220 6174 our \"targets\" at\n+0003d1e0: 7472 6962 7574 652e 0a20 2020 2020 2020 tribute.. \n+0003d1f0: 2020 2020 2020 2020 2020 2020 2074 6172 tar\n+0003d200: 6765 7473 5b6e 616d 655d 203d 2073 656c gets[name] = sel\n+0003d210: 662e 6765 7461 7474 7273 2873 656c 662e f.getattrs(self.\n+0003d220: 6664 2c20 6e61 6d65 2c20 466f 6c6c 6f77 fd, name, Follow\n+0003d230: 2e59 4553 290a 0a20 2020 2020 2020 2073 .YES).. s\n+0003d240: 656c 662e 7365 6e64 5f75 7064 6174 6528 elf.send_update(\n+0003d250: 7b27 696e 666f 273a 2069 6e66 6f7d 2c20 {'info': info}, \n+0003d260: 7265 7365 743d 7265 7365 7429 0a0a 2020 reset=reset).. \n+0003d270: 2020 6465 6620 7072 6f63 6573 735f 7065 def process_pe\n+0003d280: 6e64 696e 675f 7570 6461 7465 7328 7365 nding_updates(se\n+0003d290: 6c66 2920 2d3e 204e 6f6e 653a 0a20 2020 lf) -> None:. \n+0003d2a0: 2020 2020 2061 7373 6572 7420 7365 6c66 assert self\n+0003d2b0: 2e70 656e 6469 6e67 2069 7320 6e6f 7420 .pending is not \n+0003d2c0: 4e6f 6e65 0a20 2020 2020 2020 2069 6620 None. if \n+0003d2d0: 7365 6c66 2e70 656e 6469 6e67 3a0a 2020 self.pending:. \n+0003d2e0: 2020 2020 2020 2020 2020 7365 6c66 2e70 self.p\n+0003d2f0: 726f 6365 7373 5f75 7064 6174 6528 7365 rocess_update(se\n+0003d300: 6c66 2e70 656e 6469 6e67 290a 2020 2020 lf.pending). \n+0003d310: 2020 2020 7365 6c66 2e70 656e 6469 6e67 self.pending\n+0003d320: 203d 204e 6f6e 650a 0a20 2020 2064 6566 = None.. def\n+0003d330: 2069 6e74 6572 6573 7469 6e67 2873 656c interesting(sel\n+0003d340: 662c 206e 616d 653a 2073 7472 2920 2d3e f, name: str) ->\n+0003d350: 2062 6f6f 6c3a 0a20 2020 2020 2020 2069 bool:. i\n+0003d360: 6620 6e61 6d65 203d 3d20 2727 3a0a 2020 f name == '':. \n+0003d370: 2020 2020 2020 2020 2020 7265 7475 726e return\n+0003d380: 2054 7275 650a 2020 2020 2020 2020 656c True. el\n+0003d390: 7365 3a0a 2020 2020 2020 2020 2020 2020 se:. \n+0003d3a0: 2320 6f6e 6c79 2072 6570 6f72 7420 7570 # only report up\n+0003d3b0: 6461 7465 7320 6f6e 2065 6e74 7279 2066 dates on entry f\n+0003d3c0: 696c 656e 616d 6573 2069 6620 7765 206d ilenames if we m\n+0003d3d0: 6174 6368 2074 6865 6d0a 2020 2020 2020 atch them. \n+0003d3e0: 2020 2020 2020 7265 7475 726e 2066 6e6d return fnm\n+0003d3f0: 6174 6368 2e66 6e6d 6174 6368 286e 616d atch.fnmatch(nam\n+0003d400: 652c 2073 656c 662e 6566 6665 6374 6976 e, self.effectiv\n+0003d410: 655f 666e 6d61 7463 6829 0a0a 2020 2020 e_fnmatch).. \n+0003d420: 6465 6620 7363 6865 6475 6c65 5f75 7064 def schedule_upd\n+0003d430: 6174 6528 7365 6c66 2c20 6e61 6d65 3a20 ate(self, name: \n+0003d440: 7374 7229 202d 3e20 4e6f 6e65 3a0a 2020 str) -> None:. \n+0003d450: 2020 2020 2020 6966 206e 6f74 2073 656c if not sel\n+0003d460: 662e 696e 7465 7265 7374 696e 6728 6e61 f.interesting(na\n+0003d470: 6d65 293a 0a20 2020 2020 2020 2020 2020 me):. \n+0003d480: 2072 6574 7572 6e0a 0a20 2020 2020 2020 return.. \n+0003d490: 2069 6620 7365 6c66 2e70 656e 6469 6e67 if self.pending\n+0003d4a0: 2069 7320 4e6f 6e65 3a0a 2020 2020 2020 is None:. \n+0003d4b0: 2020 2020 2020 6173 796e 6369 6f2e 6765 asyncio.ge\n+0003d4c0: 745f 7275 6e6e 696e 675f 6c6f 6f70 2829 t_running_loop()\n+0003d4d0: 2e63 616c 6c5f 6c61 7465 7228 302e 312c .call_later(0.1,\n+0003d4e0: 2073 656c 662e 7072 6f63 6573 735f 7065 self.process_pe\n+0003d4f0: 6e64 696e 675f 7570 6461 7465 7329 0a20 nding_updates). \n+0003d500: 2020 2020 2020 2020 2020 2073 656c 662e self.\n+0003d510: 7065 6e64 696e 6720 3d20 7365 7428 290a pending = set().\n+0003d520: 0a20 2020 2020 2020 2073 656c 662e 7065 . self.pe\n+0003d530: 6e64 696e 672e 6164 6428 6e61 6d65 290a nding.add(name).\n+0003d540: 0a20 2020 2064 6566 2072 6570 6f72 745f . def report_\n+0003d550: 6572 726f 7228 7365 6c66 2c20 6572 723a error(self, err:\n+0003d560: 2069 6e74 2920 2d3e 204e 6f6e 653a 0a20 int) -> None:. \n+0003d570: 2020 2020 2020 2069 6620 6572 7220 3d3d if err ==\n+0003d580: 2065 7272 6e6f 2e45 4e4f 454e 543a 0a20 errno.ENOENT:. \n+0003d590: 2020 2020 2020 2020 2020 2070 726f 626c probl\n+0003d5a0: 656d 203d 2027 6e6f 742d 666f 756e 6427 em = 'not-found'\n+0003d5b0: 0a20 2020 2020 2020 2065 6c69 6620 6572 . elif er\n+0003d5c0: 7220 696e 2028 6572 726e 6f2e 4550 4552 r in (errno.EPER\n+0003d5d0: 4d2c 2065 7272 6e6f 2e45 4143 4345 5329 M, errno.EACCES)\n+0003d5e0: 3a0a 2020 2020 2020 2020 2020 2020 7072 :. pr\n+0003d5f0: 6f62 6c65 6d20 3d20 2761 6363 6573 732d oblem = 'access-\n+0003d600: 6465 6e69 6564 270a 2020 2020 2020 2020 denied'. \n+0003d610: 656c 6966 2065 7272 203d 3d20 6572 726e elif err == errn\n+0003d620: 6f2e 454e 4f54 4449 523a 0a20 2020 2020 o.ENOTDIR:. \n+0003d630: 2020 2020 2020 2070 726f 626c 656d 203d problem =\n+0003d640: 2027 6e6f 742d 6469 7265 6374 6f72 7927 'not-directory'\n+0003d650: 0a20 2020 2020 2020 2065 6c73 653a 0a20 . else:. \n+0003d660: 2020 2020 2020 2020 2020 2070 726f 626c probl\n+0003d670: 656d 203d 2027 696e 7465 726e 616c 2d65 em = 'internal-e\n+0003d680: 7272 6f72 270a 0a20 2020 2020 2020 2073 rror'.. s\n+0003d690: 656c 662e 7365 6e64 5f75 7064 6174 6528 elf.send_update(\n+0003d6a0: 7b27 6572 726f 7227 3a20 7b0a 2020 2020 {'error': {. \n+0003d6b0: 2020 2020 2020 2020 2770 726f 626c 656d 'problem\n+0003d6c0: 273a 2070 726f 626c 656d 2c20 276d 6573 ': problem, 'mes\n+0003d6d0: 7361 6765 273a 206f 732e 7374 7265 7272 sage': os.strerr\n+0003d6e0: 6f72 2865 7272 292c 2027 6572 726e 6f27 or(err), 'errno'\n+0003d6f0: 3a20 6572 726e 6f2e 6572 726f 7263 6f64 : errno.errorcod\n+0003d700: 655b 6572 725d 0a20 2020 2020 2020 207d e[err]. }\n+0003d710: 7d2c 2072 6573 6574 3d54 7275 6529 0a0a }, reset=True)..\n+0003d720: 2020 2020 6465 6620 666c 6167 5f6f 6e6c def flag_onl\n+0003d730: 7964 6972 5f65 7272 6f72 2873 656c 662c ydir_error(self,\n+0003d740: 2066 643a 2048 616e 646c 6529 202d 3e20 fd: Handle) -> \n+0003d750: 626f 6f6c 3a0a 2020 2020 2020 2020 2320 bool:. # \n+0003d760: 4966 206f 7572 2072 6571 7565 7374 6564 If our requested\n+0003d770: 2070 6174 6820 656e 6465 6420 7769 7468 path ended with\n+0003d780: 2027 2f27 2074 6865 6e20 6d61 6b65 2073 '/' then make s\n+0003d790: 7572 6520 7765 2067 6f74 2061 0a20 2020 ure we got a. \n+0003d7a0: 2020 2020 2023 2064 6972 6563 746f 7279 # directory\n+0003d7b0: 2c20 6f72 2065 6c73 6520 6974 2773 2061 , or else it's a\n+0003d7c0: 6e20 6572 726f 722e 2020 6f70 656e 2829 n error. open()\n+0003d7d0: 2077 696c 6c20 6861 7665 2061 6c72 6561 will have alrea\n+0003d7e0: 6479 2066 6c61 6767 6564 0a20 2020 2020 dy flagged. \n+0003d7f0: 2020 2023 2074 6861 7420 666f 7220 7573 # that for us\n+0003d800: 2c20 6275 7420 7379 7374 656d 645f 6374 , but systemd_ct\n+0003d810: 7970 6573 2064 6f65 736e 2774 2064 6f20 ypes doesn't do \n+0003d820: 7468 6174 2028 7965 7429 2e0a 2020 2020 that (yet).. \n+0003d830: 2020 2020 6966 206e 6f74 2073 656c 662e if not self.\n+0003d840: 7761 7463 6820 6f72 206e 6f74 2073 656c watch or not sel\n+0003d850: 662e 7061 7468 2e65 6e64 7377 6974 6828 f.path.endswith(\n+0003d860: 272f 2729 3a0a 2020 2020 2020 2020 2020 '/'):. \n+0003d870: 2020 7265 7475 726e 2046 616c 7365 0a0a return False..\n+0003d880: 2020 2020 2020 2020 6275 6620 3d20 6f73 buf = os\n+0003d890: 2e66 7374 6174 2866 6429 2020 2320 7468 .fstat(fd) # th\n+0003d8a0: 6973 2073 686f 756c 6420 6e65 7665 7220 is should never \n+0003d8b0: 6661 696c 0a20 2020 2020 2020 2069 6620 fail. if \n+0003d8c0: 7374 6174 2e53 5f49 464d 5428 6275 662e stat.S_IFMT(buf.\n+0003d8d0: 7374 5f6d 6f64 6529 2021 3d20 7374 6174 st_mode) != stat\n+0003d8e0: 2e53 5f49 4644 4952 3a0a 2020 2020 2020 .S_IFDIR:. \n+0003d8f0: 2020 2020 2020 7365 6c66 2e72 6570 6f72 self.repor\n+0003d900: 745f 6572 726f 7228 6572 726e 6f2e 454e t_error(errno.EN\n+0003d910: 4f54 4449 5229 0a20 2020 2020 2020 2020 OTDIR). \n+0003d920: 2020 2072 6574 7572 6e20 5472 7565 0a0a return True..\n+0003d930: 2020 2020 2020 2020 7265 7475 726e 2046 return F\n+0003d940: 616c 7365 0a0a 2020 2020 6465 6620 7265 alse.. def re\n+0003d950: 706f 7274 5f69 6e69 7469 616c 5f73 7461 port_initial_sta\n+0003d960: 7465 2873 656c 662c 2066 643a 2048 616e te(self, fd: Han\n+0003d970: 646c 6529 202d 3e20 4e6f 6e65 3a0a 2020 dle) -> None:. \n+0003d980: 2020 2020 2020 6966 2073 656c 662e 666c if self.fl\n+0003d990: 6167 5f6f 6e6c 7964 6972 5f65 7272 6f72 ag_onlydir_error\n+0003d9a0: 2866 6429 3a0a 2020 2020 2020 2020 2020 (fd):. \n+0003d9b0: 2020 7265 7475 726e 0a0a 2020 2020 2020 return.. \n+0003d9c0: 2020 7365 6c66 2e66 6420 3d20 6664 0a0a self.fd = fd..\n+0003d9d0: 2020 2020 2020 2020 656e 7472 6965 7320 entries \n+0003d9e0: 3d20 7b27 277d 0a20 2020 2020 2020 2069 = {''}. i\n+0003d9f0: 6620 7365 6c66 2e66 6e6d 6174 6368 3a0a f self.fnmatch:.\n+0003da00: 2020 2020 2020 2020 2020 2020 7472 793a try:\n+0003da10: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+0003da20: 2065 6e74 7269 6573 2e75 7064 6174 6528 entries.update(\n+0003da30: 6f73 2e6c 6973 7464 6972 2866 272f 7072 os.listdir(f'/pr\n+0003da40: 6f63 2f73 656c 662f 6664 2f7b 7365 6c66 oc/self/fd/{self\n+0003da50: 2e66 647d 2729 290a 2020 2020 2020 2020 .fd}')). \n+0003da60: 2020 2020 2020 2020 7365 6c66 2e65 6666 self.eff\n+0003da70: 6563 7469 7665 5f66 6e6d 6174 6368 203d ective_fnmatch =\n+0003da80: 2073 656c 662e 666e 6d61 7463 680a 2020 self.fnmatch. \n+0003da90: 2020 2020 2020 2020 2020 6578 6365 7074 except\n+0003daa0: 204f 5345 7272 6f72 3a0a 2020 2020 2020 OSError:. \n+0003dab0: 2020 2020 2020 2020 2020 2320 4966 2077 # If w\n+0003dac0: 6520 6661 696c 6564 2074 6f20 6765 7420 e failed to get \n+0003dad0: 616e 2069 6e69 7469 616c 206c 6973 742c an initial list,\n+0003dae0: 2074 6865 6e20 7265 706f 7274 206e 6f74 then report not\n+0003daf0: 6869 6e67 2066 726f 6d20 6e6f 7720 6f6e hing from now on\n+0003db00: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+0003db10: 2073 656c 662e 6566 6665 6374 6976 655f self.effective_\n+0003db20: 666e 6d61 7463 6820 3d20 2727 0a0a 2020 fnmatch = ''.. \n+0003db30: 2020 2020 2020 7365 6c66 2e70 726f 6365 self.proce\n+0003db40: 7373 5f75 7064 6174 6528 7b65 2066 6f72 ss_update({e for\n+0003db50: 2065 2069 6e20 656e 7472 6965 7320 6966 e in entries if\n+0003db60: 2073 656c 662e 696e 7465 7265 7374 696e self.interestin\n+0003db70: 6728 6529 7d2c 2072 6573 6574 3d54 7275 g(e)}, reset=Tru\n+0003db80: 6529 0a0a 2020 2020 6465 6620 646f 5f69 e).. def do_i\n+0003db90: 6e6f 7469 6679 5f65 7665 6e74 2873 656c notify_event(sel\n+0003dba0: 662c 206d 6173 6b3a 2049 6e6f 7469 6679 f, mask: Inotify\n+0003dbb0: 4576 656e 742c 2063 6f6f 6b69 653a 2069 Event, cookie: i\n+0003dbc0: 6e74 2c20 7261 776e 616d 653a 2027 6279 nt, rawname: 'by\n+0003dbd0: 7465 7320 7c20 4e6f 6e65 2729 202d 3e20 tes | None') -> \n+0003dbe0: 4e6f 6e65 3a0a 2020 2020 2020 2020 6c6f None:. lo\n+0003dbf0: 6767 6572 2e64 6562 7567 2827 646f 5f69 gger.debug('do_i\n+0003dc00: 6e6f 7469 6679 5f65 7665 6e74 2825 722c notify_event(%r,\n+0003dc10: 2025 722c 2025 7229 272c 206d 6173 6b2c %r, %r)', mask,\n+0003dc20: 2063 6f6f 6b69 652c 2072 6177 6e61 6d65 cookie, rawname\n+0003dc30: 290a 2020 2020 2020 2020 6e61 6d65 203d ). name =\n+0003dc40: 2028 7261 776e 616d 6520 6f72 2062 2727 (rawname or b''\n+0003dc50: 292e 6465 636f 6465 2865 7272 6f72 733d ).decode(errors=\n+0003dc60: 2773 7572 726f 6761 7465 6573 6361 7065 'surrogateescape\n+0003dc70: 2729 0a0a 2020 2020 2020 2020 7365 6c66 ').. self\n+0003dc80: 2e73 6368 6564 756c 655f 7570 6461 7465 .schedule_update\n+0003dc90: 286e 616d 6529 0a0a 2020 2020 2020 2020 (name).. \n+0003dca0: 6966 206e 616d 6520 616e 6420 6d61 736b if name and mask\n+0003dcb0: 207c 2028 496e 6f74 6966 7945 7665 6e74 | (InotifyEvent\n+0003dcc0: 2e43 5245 4154 4520 7c20 496e 6f74 6966 .CREATE | Inotif\n+0003dcd0: 7945 7665 6e74 2e44 454c 4554 4520 7c0a yEvent.DELETE |.\n+0003dce0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0003dcf0: 2020 2020 2020 2020 2020 2020 496e 6f74 Inot\n+0003dd00: 6966 7945 7665 6e74 2e4d 4f56 4544 5f54 ifyEvent.MOVED_T\n+0003dd10: 4f20 7c20 496e 6f74 6966 7945 7665 6e74 O | InotifyEvent\n+0003dd20: 2e4d 4f56 4544 5f46 524f 4d29 3a0a 2020 .MOVED_FROM):. \n+0003dd30: 2020 2020 2020 2020 2020 2320 5468 6573 # Thes\n+0003dd40: 6520 6576 656e 7473 2063 6861 6e67 6520 e events change \n+0003dd50: 7468 6520 6d74 696d 6520 6f66 2074 6865 the mtime of the\n+0003dd60: 2064 6972 6563 746f 7279 0a20 2020 2020 directory. \n+0003dd70: 2020 2020 2020 2073 656c 662e 7363 6865 self.sche\n+0003dd80: 6475 6c65 5f75 7064 6174 6528 2727 290a dule_update('').\n+0003dd90: 0a20 2020 2064 6566 2064 6f5f 6964 656e . def do_iden\n+0003dda0: 7469 7479 5f63 6861 6e67 6564 2873 656c tity_changed(sel\n+0003ddb0: 662c 2066 643a 2027 4861 6e64 6c65 207c f, fd: 'Handle |\n+0003ddc0: 204e 6f6e 6527 2c20 6572 723a 2027 696e None', err: 'in\n+0003ddd0: 7420 7c20 4e6f 6e65 2729 202d 3e20 4e6f t | None') -> No\n+0003dde0: 6e65 3a0a 2020 2020 2020 2020 6c6f 6767 ne:. logg\n+0003ddf0: 6572 2e64 6562 7567 2827 646f 5f69 6465 er.debug('do_ide\n+0003de00: 6e74 6974 795f 6368 616e 6765 6428 2572 ntity_changed(%r\n+0003de10: 2c20 2572 2927 2c20 6664 2c20 6572 7229 , %r)', fd, err)\n+0003de20: 0a20 2020 2020 2020 2023 2049 6620 7468 . # If th\n+0003de30: 6572 6520 7765 7265 2070 7265 7669 6f75 ere were previou\n+0003de40: 736c 7920 7065 6e64 696e 6720 6368 616e sly pending chan\n+0003de50: 6765 732c 2074 6865 7920 6172 6520 6e6f ges, they are no\n+0003de60: 7720 6972 7265 6c65 7661 6e74 2e0a 2020 w irrelevant.. \n+0003de70: 2020 2020 2020 6966 2073 656c 662e 7065 if self.pe\n+0003de80: 6e64 696e 6720 6973 206e 6f74 204e 6f6e nding is not Non\n+0003de90: 653a 0a20 2020 2020 2020 2020 2020 2023 e:. #\n+0003dea0: 204e 6f74 653a 2064 6f6e 2774 2073 6574 Note: don't set\n+0003deb0: 2074 6f20 4e6f 6e65 2c20 7369 6e63 6520 to None, since \n+0003dec0: 7468 6520 6861 6e64 6c65 7220 6973 2073 the handler is s\n+0003ded0: 7469 6c6c 2070 656e 6469 6e67 0a20 2020 till pending. \n+0003dee0: 2020 2020 2020 2020 2073 656c 662e 7065 self.pe\n+0003def0: 6e64 696e 672e 636c 6561 7228 290a 0a20 nding.clear().. \n+0003df00: 2020 2020 2020 2069 6620 6572 7220 6973 if err is\n+0003df10: 204e 6f6e 653a 0a20 2020 2020 2020 2020 None:. \n+0003df20: 2020 2061 7373 6572 7420 6664 2069 7320 assert fd is \n+0003df30: 6e6f 7420 4e6f 6e65 0a20 2020 2020 2020 not None. \n+0003df40: 2020 2020 2073 656c 662e 7265 706f 7274 self.report\n+0003df50: 5f69 6e69 7469 616c 5f73 7461 7465 2866 _initial_state(f\n+0003df60: 6429 0a20 2020 2020 2020 2065 6c73 653a d). else:\n+0003df70: 0a20 2020 2020 2020 2020 2020 2073 656c . sel\n+0003df80: 662e 7265 706f 7274 5f65 7272 6f72 2865 f.report_error(e\n+0003df90: 7272 290a 0a20 2020 2064 6566 2064 6f5f rr).. def do_\n+0003dfa0: 636c 6f73 6528 7365 6c66 2920 2d3e 204e close(self) -> N\n+0003dfb0: 6f6e 653a 0a20 2020 2020 2020 2023 206e one:. # n\n+0003dfc0: 6f6e 2d77 6174 6368 2063 6861 6e6e 656c on-watch channel\n+0003dfd0: 7320 636c 6f73 6520 696d 6d65 6469 6174 s close immediat\n+0003dfe0: 656c 7920 e280 9420 6966 2077 6520 6765 ely ... if we ge\n+0003dff0: 7420 7468 6973 2c20 7765 2772 6520 7761 t this, we're wa\n+0003e000: 7463 6869 6e67 0a20 2020 2020 2020 2061 tching. a\n+0003e010: 7373 6572 7420 7365 6c66 2e70 6174 685f ssert self.path_\n+0003e020: 7761 7463 6820 6973 206e 6f74 204e 6f6e watch is not Non\n+0003e030: 650a 2020 2020 2020 2020 7365 6c66 2e70 e. self.p\n+0003e040: 6174 685f 7761 7463 682e 636c 6f73 6528 ath_watch.close(\n+0003e050: 290a 2020 2020 2020 2020 7365 6c66 2e63 ). self.c\n+0003e060: 6c6f 7365 2829 0a0a 2020 2020 6465 6620 lose().. def \n+0003e070: 646f 5f6f 7065 6e28 7365 6c66 2c20 6f70 do_open(self, op\n+0003e080: 7469 6f6e 733a 204a 736f 6e4f 626a 6563 tions: JsonObjec\n+0003e090: 7429 202d 3e20 4e6f 6e65 3a0a 2020 2020 t) -> None:. \n+0003e0a0: 2020 2020 7365 6c66 2e70 6174 6820 3d20 self.path = \n+0003e0b0: 6765 745f 7374 7228 6f70 7469 6f6e 732c get_str(options,\n+0003e0c0: 2027 7061 7468 2729 0a20 2020 2020 2020 'path'). \n+0003e0d0: 2069 6620 6e6f 7420 6f73 2e70 6174 682e if not os.path.\n+0003e0e0: 6973 6162 7328 7365 6c66 2e70 6174 6829 isabs(self.path)\n+0003e0f0: 3a0a 2020 2020 2020 2020 2020 2020 7261 :. ra\n+0003e100: 6973 6520 4a73 6f6e 4572 726f 7228 6f70 ise JsonError(op\n+0003e110: 7469 6f6e 732c 2027 2270 6174 6822 206d tions, '\"path\" m\n+0003e120: 7573 7420 6265 2061 6e20 6162 736f 6c75 ust be an absolu\n+0003e130: 7465 2070 6174 6827 290a 0a20 2020 2020 te path').. \n+0003e140: 2020 2061 7474 7273 203d 2073 6574 2867 attrs = set(g\n+0003e150: 6574 5f73 7472 7628 6f70 7469 6f6e 732c et_strv(options,\n+0003e160: 2027 6174 7472 7327 2929 0a20 2020 2020 'attrs')). \n+0003e170: 2020 2073 656c 662e 6765 7461 7474 7273 self.getattrs\n+0003e180: 203d 2073 656c 662e 6d61 6b65 5f67 6574 = self.make_get\n+0003e190: 6174 7472 7328 6174 7472 7320 2d20 7b27 attrs(attrs - {'\n+0003e1a0: 7461 7267 6574 7327 2c20 2765 6e74 7269 targets', 'entri\n+0003e1b0: 6573 277d 290a 2020 2020 2020 2020 7365 es'}). se\n+0003e1c0: 6c66 2e66 6e6d 6174 6368 203d 2067 6574 lf.fnmatch = get\n+0003e1d0: 5f73 7472 286f 7074 696f 6e73 2c20 2766 _str(options, 'f\n+0003e1e0: 6e6d 6174 6368 272c 2027 2a27 2069 6620 nmatch', '*' if \n+0003e1f0: 2765 6e74 7269 6573 2720 696e 2061 7474 'entries' in att\n+0003e200: 7273 2065 6c73 6520 2727 290a 2020 2020 rs else ''). \n+0003e210: 2020 2020 7365 6c66 2e74 6172 6765 7473 self.targets\n+0003e220: 203d 2027 7461 7267 6574 7327 2069 6e20 = 'targets' in \n+0003e230: 6174 7472 730a 2020 2020 2020 2020 7365 attrs. se\n+0003e240: 6c66 2e66 6f6c 6c6f 7720 3d20 6765 745f lf.follow = get_\n+0003e250: 626f 6f6c 286f 7074 696f 6e73 2c20 2766 bool(options, 'f\n+0003e260: 6f6c 6c6f 7727 2c20 6465 6661 756c 743d ollow', default=\n+0003e270: 5472 7565 290a 2020 2020 2020 2020 7365 True). se\n+0003e280: 6c66 2e77 6174 6368 203d 2067 6574 5f62 lf.watch = get_b\n+0003e290: 6f6f 6c28 6f70 7469 6f6e 732c 2027 7761 ool(options, 'wa\n+0003e2a0: 7463 6827 2c20 6465 6661 756c 743d 4661 tch', default=Fa\n+0003e2b0: 6c73 6529 0a20 2020 2020 2020 2069 6620 lse). if \n+0003e2c0: 7365 6c66 2e77 6174 6368 2061 6e64 206e self.watch and n\n+0003e2d0: 6f74 2073 656c 662e 666f 6c6c 6f77 3a0a ot self.follow:.\n+0003e2e0: 2020 2020 2020 2020 2020 2020 7261 6973 rais\n+0003e2f0: 6520 4a73 6f6e 4572 726f 7228 6f70 7469 e JsonError(opti\n+0003e300: 6f6e 732c 2027 2277 6174 6368 3a20 7472 ons, '\"watch: tr\n+0003e310: 7565 2220 616e 6420 2266 6f6c 6c6f 773a ue\" and \"follow:\n+0003e320: 2066 616c 7365 2220 6172 6520 2863 7572 false\" are (cur\n+0003e330: 7265 6e74 6c79 2920 696e 636f 6d70 6174 rently) incompat\n+0003e340: 6962 6c65 2729 0a20 2020 2020 2020 2069 ible'). i\n+0003e350: 6620 7365 6c66 2e74 6172 6765 7473 2061 f self.targets a\n+0003e360: 6e64 206e 6f74 2073 656c 662e 666f 6c6c nd not self.foll\n+0003e370: 6f77 3a0a 2020 2020 2020 2020 2020 2020 ow:. \n+0003e380: 7261 6973 6520 4a73 6f6e 4572 726f 7228 raise JsonError(\n+0003e390: 6f70 7469 6f6e 732c 2027 6074 6172 6765 options, '`targe\n+0003e3a0: 7473 3a20 2273 7461 7422 6020 616e 6420 ts: \"stat\"` and \n+0003e3b0: 6066 6f6c 6c6f 773a 2066 616c 7365 6020 `follow: false` \n+0003e3c0: 6172 6520 2863 7572 7265 6e74 6c79 2920 are (currently) \n+0003e3d0: 696e 636f 6d70 6174 6962 6c65 2729 0a0a incompatible')..\n+0003e3e0: 2020 2020 2020 2020 7365 6c66 2e63 7572 self.cur\n+0003e3f0: 7265 6e74 5f76 616c 7565 203d 207b 7d0a rent_value = {}.\n+0003e400: 2020 2020 2020 2020 7365 6c66 2e72 6561 self.rea\n+0003e410: 6479 2829 0a0a 2020 2020 2020 2020 6966 dy().. if\n+0003e420: 206e 6f74 2073 656c 662e 7761 7463 683a not self.watch:\n+0003e430: 0a20 2020 2020 2020 2020 2020 2074 7279 . try\n+0003e440: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n+0003e450: 2020 6664 203d 2048 616e 646c 652e 6f70 fd = Handle.op\n+0003e460: 656e 2873 656c 662e 7061 7468 2c20 6f73 en(self.path, os\n+0003e470: 2e4f 5f50 4154 4820 6966 2073 656c 662e .O_PATH if self.\n+0003e480: 666f 6c6c 6f77 2065 6c73 6520 6f73 2e4f follow else os.O\n+0003e490: 5f50 4154 4820 7c20 6f73 2e4f 5f4e 4f46 _PATH | os.O_NOF\n+0003e4a0: 4f4c 4c4f 5729 0a20 2020 2020 2020 2020 OLLOW). \n+0003e4b0: 2020 2065 7863 6570 7420 4f53 4572 726f except OSErro\n+0003e4c0: 7220 6173 2065 7863 3a0a 2020 2020 2020 r as exc:. \n+0003e4d0: 2020 2020 2020 2020 2020 7365 6c66 2e72 self.r\n+0003e4e0: 6570 6f72 745f 6572 726f 7228 6578 632e eport_error(exc.\n+0003e4f0: 6572 726e 6f29 0a20 2020 2020 2020 2020 errno). \n+0003e500: 2020 2065 6c73 653a 0a20 2020 2020 2020 else:. \n+0003e510: 2020 2020 2020 2020 2073 656c 662e 7265 self.re\n+0003e520: 706f 7274 5f69 6e69 7469 616c 5f73 7461 port_initial_sta\n+0003e530: 7465 2866 6429 0a20 2020 2020 2020 2020 te(fd). \n+0003e540: 2020 2020 2020 2066 642e 636c 6f73 6528 fd.close(\n+0003e550: 290a 0a20 2020 2020 2020 2020 2020 2073 ).. s\n+0003e560: 656c 662e 646f 6e65 2829 0a20 2020 2020 elf.done(). \n+0003e570: 2020 2020 2020 2073 656c 662e 636c 6f73 self.clos\n+0003e580: 6528 290a 0a20 2020 2020 2020 2065 6c73 e().. els\n+0003e590: 653a 0a20 2020 2020 2020 2020 2020 2023 e:. #\n+0003e5a0: 2050 6174 6857 6174 6368 2077 696c 6c20 PathWatch will \n+0003e5b0: 6361 6c6c 2064 6f5f 6964 656e 7469 7479 call do_identity\n+0003e5c0: 5f63 6861 6e67 6564 2829 2c20 7768 6963 _changed(), whic\n+0003e5d0: 6820 646f 6573 2074 6865 2073 616d 6520 h does the same \n+0003e5e0: 6173 0a20 2020 2020 2020 2020 2020 2023 as. #\n+0003e5f0: 2061 626f 7665 3a20 6361 6c6c 7320 6569 above: calls ei\n+0003e600: 7468 6572 2072 6570 6f72 745f 696e 6974 ther report_init\n+0003e610: 6961 6c5f 7374 6174 6528 2920 6f72 2072 ial_state() or r\n+0003e620: 6570 6f72 745f 6572 726f 7228 292c 0a20 eport_error(),. \n+0003e630: 2020 2020 2020 2020 2020 2023 2064 6570 # dep\n+0003e640: 656e 6469 6e67 206f 6e20 6966 2069 7420 ending on if it \n+0003e650: 7761 7320 7072 6f76 6964 6564 2077 6974 was provided wit\n+0003e660: 6820 616e 2066 6420 6f72 2061 6e20 6572 h an fd or an er\n+0003e670: 726f 7220 636f 6465 2e0a 2020 2020 2020 ror code.. \n+0003e680: 2020 2020 2020 7365 6c66 2e70 6174 685f self.path_\n+0003e690: 7761 7463 6820 3d20 5061 7468 5761 7463 watch = PathWatc\n+0003e6a0: 6828 7365 6c66 2e70 6174 682c 2073 656c h(self.path, sel\n+0003e6b0: 6629 0a27 2727 2e65 6e63 6f64 6528 2775 f).'''.encode('u\n+0003e6c0: 7466 2d38 2729 2c0a 2020 2763 6f63 6b70 tf-8'),. 'cockp\n+0003e6d0: 6974 2f5f 7665 6e64 6f72 2f5f 5f69 6e69 it/_vendor/__ini\n+0003e6e0: 745f 5f2e 7079 273a 2062 7227 2727 2727 t__.py': br'''''\n+0003e6f0: 272c 0a20 2027 636f 636b 7069 742f 5f76 ',. 'cockpit/_v\n+0003e700: 656e 646f 722f 6265 692f 5f5f 696e 6974 endor/bei/__init\n+0003e710: 5f5f 2e70 7927 3a20 6272 2727 2727 2727 __.py': br''''''\n+0003e720: 2c0a 2020 2763 6f63 6b70 6974 2f5f 7665 ,. 'cockpit/_ve\n+0003e730: 6e64 6f72 2f62 6569 2f62 6f6f 746c 6f61 ndor/bei/bootloa\n+0003e740: 6465 722e 7079 273a 2062 7227 2727 2320 der.py': br'''# \n+0003e750: 6265 6962 6f6f 7420 2d20 5265 6d6f 7465 beiboot - Remote\n+0003e760: 2062 6f6f 746c 6f61 6465 7220 666f 7220 bootloader for \n+0003e770: 5079 7468 6f6e 0a23 0a23 2043 6f70 7972 Python.#.# Copyr\n+0003e780: 6967 6874 2028 4329 2032 3032 3320 416c ight (C) 2023 Al\n+0003e790: 6c69 736f 6e20 4b61 726c 6974 736b 6179 lison Karlitskay\n+0003e7a0: 6120 3c61 6c6c 6973 6f6e 2e6b 6172 6c69 a <allison.karli\n+0003e7b0: 7473 6b61 7961 4072 6564 6861 742e 636f tskaya@redhat.co\n+0003e7c0: 6d3e 0a23 0a23 2054 6869 7320 7072 6f67 m>.#.# This prog\n+0003e7d0: 7261 6d20 6973 2066 7265 6520 736f 6674 ram is free soft\n+0003e7e0: 7761 7265 3a20 796f 7520 6361 6e20 7265 ware: you can re\n+0003e7f0: 6469 7374 7269 6275 7465 2069 7420 616e distribute it an\n+0003e800: 642f 6f72 206d 6f64 6966 790a 2320 6974 d/or modify.# it\n+0003e810: 2075 6e64 6572 2074 6865 2074 6572 6d73 under the terms\n+0003e820: 206f 6620 7468 6520 474e 5520 4765 6e65 of the GNU Gene\n+0003e830: 7261 6c20 5075 626c 6963 204c 6963 656e ral Public Licen\n+0003e840: 7365 2061 7320 7075 626c 6973 6865 6420 se as published \n+0003e850: 6279 0a23 2074 6865 2046 7265 6520 536f by.# the Free So\n+0003e860: 6674 7761 7265 2046 6f75 6e64 6174 696f ftware Foundatio\n+0003e870: 6e2c 2065 6974 6865 7220 7665 7273 696f n, either versio\n+0003e880: 6e20 3320 6f66 2074 6865 204c 6963 656e n 3 of the Licen\n+0003e890: 7365 2c20 6f72 0a23 2028 6174 2079 6f75 se, or.# (at you\n+0003e8a0: 7220 6f70 7469 6f6e 2920 616e 7920 6c61 r option) any la\n+0003e8b0: 7465 7220 7665 7273 696f 6e2e 0a23 0a23 ter version..#.#\n+0003e8c0: 2054 6869 7320 7072 6f67 7261 6d20 6973 This program is\n+0003e8d0: 2064 6973 7472 6962 7574 6564 2069 6e20 distributed in \n+0003e8e0: 7468 6520 686f 7065 2074 6861 7420 6974 the hope that it\n+0003e8f0: 2077 696c 6c20 6265 2075 7365 6675 6c2c will be useful,\n+0003e900: 0a23 2062 7574 2057 4954 484f 5554 2041 .# but WITHOUT A\n+0003e910: 4e59 2057 4152 5241 4e54 593b 2077 6974 NY WARRANTY; wit\n+0003e920: 686f 7574 2065 7665 6e20 7468 6520 696d hout even the im\n+0003e930: 706c 6965 6420 7761 7272 616e 7479 206f plied warranty o\n+0003e940: 660a 2320 4d45 5243 4841 4e54 4142 494c f.# MERCHANTABIL\n+0003e950: 4954 5920 6f72 2046 4954 4e45 5353 2046 ITY or FITNESS F\n+0003e960: 4f52 2041 2050 4152 5449 4355 4c41 5220 OR A PARTICULAR \n+0003e970: 5055 5250 4f53 452e 2020 5365 6520 7468 PURPOSE. See th\n+0003e980: 650a 2320 474e 5520 4765 6e65 7261 6c20 e.# GNU General \n+0003e990: 5075 626c 6963 204c 6963 656e 7365 2066 Public License f\n+0003e9a0: 6f72 206d 6f72 6520 6465 7461 696c 732e or more details.\n+0003e9b0: 0a23 0a23 2059 6f75 2073 686f 756c 6420 .#.# You should \n+0003e9c0: 6861 7665 2072 6563 6569 7665 6420 6120 have received a \n+0003e9d0: 636f 7079 206f 6620 7468 6520 474e 5520 copy of the GNU \n+0003e9e0: 4765 6e65 7261 6c20 5075 626c 6963 204c General Public L\n+0003e9f0: 6963 656e 7365 0a23 2061 6c6f 6e67 2077 icense.# along w\n+0003ea00: 6974 6820 7468 6973 2070 726f 6772 616d ith this program\n+0003ea10: 2e20 2049 6620 6e6f 742c 2073 6565 203c . If not, see <\n+0003ea20: 6874 7470 3a2f 2f77 7777 2e67 6e75 2e6f http://www.gnu.o\n+0003ea30: 7267 2f6c 6963 656e 7365 732f 3e2e 0a0a rg/licenses/>...\n+0003ea40: 696d 706f 7274 2074 6578 7477 7261 700a import textwrap.\n+0003ea50: 6672 6f6d 2074 7970 696e 6720 696d 706f from typing impo\n+0003ea60: 7274 2044 6963 742c 2049 7465 7261 626c rt Dict, Iterabl\n+0003ea70: 652c 204c 6973 742c 204f 7074 696f 6e61 e, List, Optiona\n+0003ea80: 6c2c 2053 6571 7565 6e63 652c 2053 6574 l, Sequence, Set\n+0003ea90: 2c20 5475 706c 650a 0a47 4144 4745 5453 , Tuple..GADGETS\n+0003eaa0: 203d 207b 0a20 2020 2022 5f66 7261 6d65 = {. \"_frame\n+0003eab0: 223a 2072 2222 220a 2020 2020 2020 2020 \": r\"\"\". \n+0003eac0: 696d 706f 7274 2073 7973 0a20 2020 2020 import sys. \n+0003ead0: 2020 2069 6d70 6f72 7420 7472 6163 6562 import traceb\n+0003eae0: 6163 6b0a 2020 2020 2020 2020 7472 793a ack. try:\n+0003eaf0: 0a20 2020 2020 2020 2020 2020 202e 2e2e . ...\n+0003eb00: 0a20 2020 2020 2020 2065 7863 6570 7420 . except \n+0003eb10: 5379 7374 656d 4578 6974 3a0a 2020 2020 SystemExit:. \n+0003eb20: 2020 2020 2020 2020 7261 6973 650a 2020 raise. \n+0003eb30: 2020 2020 2020 6578 6365 7074 2042 6173 except Bas\n+0003eb40: 6545 7863 6570 7469 6f6e 3a0a 2020 2020 eException:. \n+0003eb50: 2020 2020 2020 2020 636f 6d6d 616e 6428 command(\n+0003eb60: 2762 6569 626f 6f74 2e65 7863 272c 2074 'beiboot.exc', t\n+0003eb70: 7261 6365 6261 636b 2e66 6f72 6d61 745f raceback.format_\n+0003eb80: 6578 6328 2929 0a20 2020 2020 2020 2020 exc()). \n+0003eb90: 2020 2073 7973 2e65 7869 7428 3337 290a sys.exit(37).\n+0003eba0: 2020 2020 2222 222c 0a20 2020 2022 7472 \"\"\",. \"tr\n+0003ebb0: 795f 6578 6563 223a 2072 2222 220a 2020 y_exec\": r\"\"\". \n+0003ebc0: 2020 2020 2020 696d 706f 7274 2063 6f6e import con\n+0003ebd0: 7465 7874 6c69 620a 2020 2020 2020 2020 textlib. \n+0003ebe0: 696d 706f 7274 206f 730a 2020 2020 2020 import os. \n+0003ebf0: 2020 6465 6620 7472 795f 6578 6563 2861 def try_exec(a\n+0003ec00: 7267 7629 3a0a 2020 2020 2020 2020 2020 rgv):. \n+0003ec10: 2020 7769 7468 2063 6f6e 7465 7874 6c69 with contextli\n+0003ec20: 622e 7375 7070 7265 7373 284f 5345 7272 b.suppress(OSErr\n+0003ec30: 6f72 293a 0a20 2020 2020 2020 2020 2020 or):. \n+0003ec40: 2020 2020 206f 732e 6578 6563 7670 2861 os.execvp(a\n+0003ec50: 7267 765b 305d 2c20 6172 6776 290a 2020 rgv[0], argv). \n+0003ec60: 2020 2222 222c 0a20 2020 2022 626f 6f74 \"\"\",. \"boot\n+0003ec70: 5f78 7a22 3a20 7222 2222 0a20 2020 2020 _xz\": r\"\"\". \n+0003ec80: 2020 2069 6d70 6f72 7420 6c7a 6d61 0a20 import lzma. \n+0003ec90: 2020 2020 2020 2069 6d70 6f72 7420 7379 import sy\n+0003eca0: 730a 2020 2020 2020 2020 6465 6620 626f s. def bo\n+0003ecb0: 6f74 5f78 7a28 6669 6c65 6e61 6d65 2c20 ot_xz(filename, \n+0003ecc0: 7369 7a65 2c20 6172 6773 3d5b 5d2c 2073 size, args=[], s\n+0003ecd0: 656e 645f 656e 643d 4661 6c73 6529 3a0a end_end=False):.\n+0003ece0: 2020 2020 2020 2020 2020 2020 636f 6d6d comm\n+0003ecf0: 616e 6428 2762 6569 626f 6f74 2e70 726f and('beiboot.pro\n+0003ed00: 7669 6465 272c 2073 697a 6529 0a20 2020 vide', size). \n+0003ed10: 2020 2020 2020 2020 2073 7263 5f78 7a20 src_xz \n+0003ed20: 3d20 7379 732e 7374 6469 6e2e 6275 6666 = sys.stdin.buff\n+0003ed30: 6572 2e72 6561 6428 7369 7a65 290a 2020 er.read(size). \n+0003ed40: 2020 2020 2020 2020 2020 7372 6320 3d20 src = \n+0003ed50: 6c7a 6d61 2e64 6563 6f6d 7072 6573 7328 lzma.decompress(\n+0003ed60: 7372 635f 787a 290a 2020 2020 2020 2020 src_xz). \n+0003ed70: 2020 2020 7379 732e 6172 6776 203d 205b sys.argv = [\n+0003ed80: 6669 6c65 6e61 6d65 2c20 2a61 7267 735d filename, *args]\n+0003ed90: 0a20 2020 2020 2020 2020 2020 2069 6620 . if \n+0003eda0: 7365 6e64 5f65 6e64 3a0a 2020 2020 2020 send_end:. \n+0003edb0: 2020 2020 2020 2020 2020 656e 6428 290a end().\n+0003edc0: 2020 2020 2020 2020 2020 2020 6578 6563 exec\n+0003edd0: 2873 7263 2c20 7b0a 2020 2020 2020 2020 (src, {. \n+0003ede0: 2020 2020 2020 2020 275f 5f6e 616d 655f '__name_\n+0003edf0: 5f27 3a20 275f 5f6d 6169 6e5f 5f27 2c0a _': '__main__',.\n+0003ee00: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0003ee10: 275f 5f73 656c 665f 736f 7572 6365 5f5f '__self_source__\n+0003ee20: 273a 2073 7263 5f78 7a2c 0a20 2020 2020 ': src_xz,. \n+0003ee30: 2020 2020 2020 2020 2020 2027 5f5f 6669 '__fi\n+0003ee40: 6c65 5f5f 273a 2066 696c 656e 616d 657d le__': filename}\n+0003ee50: 290a 2020 2020 2020 2020 2020 2020 7379 ). sy\n+0003ee60: 732e 6578 6974 2829 0a20 2020 2022 2222 s.exit(). \"\"\"\n+0003ee70: 2c0a 7d0a 0a0a 6465 6620 7370 6c69 745f ,.}...def split_\n+0003ee80: 636f 6465 2863 6f64 653a 2073 7472 2c20 code(code: str, \n+0003ee90: 696d 706f 7274 733a 2053 6574 5b73 7472 imports: Set[str\n+0003eea0: 5d29 202d 3e20 4974 6572 6162 6c65 5b54 ]) -> Iterable[T\n+0003eeb0: 7570 6c65 5b73 7472 2c20 7374 725d 5d3a uple[str, str]]:\n+0003eec0: 0a20 2020 2066 6f72 206c 696e 6520 696e . for line in\n+0003eed0: 2074 6578 7477 7261 702e 6465 6465 6e74 textwrap.dedent\n+0003eee0: 2863 6f64 6529 2e73 706c 6974 6c69 6e65 (code).splitline\n+0003eef0: 7328 293a 0a20 2020 2020 2020 2074 6578 s():. tex\n+0003ef00: 7420 3d20 6c69 6e65 2e6c 7374 7269 7028 t = line.lstrip(\n+0003ef10: 2220 2229 0a20 2020 2020 2020 2069 6620 \" \"). if \n+0003ef20: 7465 7874 2e73 7461 7274 7377 6974 6828 text.startswith(\n+0003ef30: 2269 6d70 6f72 7420 2229 3a0a 2020 2020 \"import \"):. \n+0003ef40: 2020 2020 2020 2020 696d 706f 7274 732e imports.\n+0003ef50: 6164 6428 7465 7874 290a 2020 2020 2020 add(text). \n+0003ef60: 2020 656c 6966 2074 6578 743a 0a20 2020 elif text:. \n+0003ef70: 2020 2020 2020 2020 2073 7061 6365 7320 spaces \n+0003ef80: 3d20 6c65 6e28 6c69 6e65 2920 2d20 6c65 = len(line) - le\n+0003ef90: 6e28 7465 7874 290a 2020 2020 2020 2020 n(text). \n+0003efa0: 2020 2020 6173 7365 7274 2028 7370 6163 assert (spac\n+0003efb0: 6573 2025 2034 2920 3d3d 2030 0a20 2020 es % 4) == 0. \n+0003efc0: 2020 2020 2020 2020 2079 6965 6c64 2022 yield \"\n+0003efd0: 5c74 2220 2a20 2873 7061 6365 7320 2f2f \\t\" * (spaces //\n+0003efe0: 2034 292c 2074 6578 740a 0a0a 6465 6620 4), text...def \n+0003eff0: 7969 656c 645f 626f 6479 2875 7365 725f yield_body(user_\n+0003f000: 6761 6467 6574 733a 2044 6963 745b 7374 gadgets: Dict[st\n+0003f010: 722c 2073 7472 5d2c 0a20 2020 2020 2020 r, str],. \n+0003f020: 2020 2020 2020 2020 7374 6570 733a 2053 steps: S\n+0003f030: 6571 7565 6e63 655b 5475 706c 655b 7374 equence[Tuple[st\n+0003f040: 722c 2053 6571 7565 6e63 655b 6f62 6a65 r, Sequence[obje\n+0003f050: 6374 5d5d 5d2c 0a20 2020 2020 2020 2020 ct]]],. \n+0003f060: 2020 2020 2020 696d 706f 7274 733a 2053 imports: S\n+0003f070: 6574 5b73 7472 5d29 202d 3e20 4974 6572 et[str]) -> Iter\n+0003f080: 6162 6c65 5b54 7570 6c65 5b73 7472 2c20 able[Tuple[str, \n+0003f090: 7374 725d 5d3a 0a20 2020 2023 2041 6c6c str]]:. # All\n+0003f0a0: 6f77 2074 6865 2063 616c 6c65 7220 746f ow the caller to\n+0003f0b0: 206f 7665 7272 6964 6520 6f75 7220 6761 override our ga\n+0003f0c0: 6467 6574 732c 2062 7574 206b 6565 7020 dgets, but keep \n+0003f0d0: 7468 6520 6f72 6967 696e 616c 0a20 2020 the original. \n+0003f0e0: 2023 2076 6172 6961 626c 6520 666f 7220 # variable for \n+0003f0f0: 7573 6520 696e 2074 6865 206e 6578 7420 use in the next \n+0003f100: 7374 6570 2e0a 2020 2020 6761 6467 6574 step.. gadget\n+0003f110: 7320 3d20 6469 6374 2847 4144 4745 5453 s = dict(GADGETS\n+0003f120: 2c20 2a2a 7573 6572 5f67 6164 6765 7473 , **user_gadgets\n+0003f130: 290a 0a20 2020 2023 2046 6972 7374 2065 ).. # First e\n+0003f140: 6d69 7420 7468 6520 6761 6467 6574 732e mit the gadgets.\n+0003f150: 2020 456d 6974 2061 6c6c 2067 6164 6765 Emit all gadge\n+0003f160: 7473 2070 726f 7669 6465 6420 6279 2074 ts provided by t\n+0003f170: 6865 2063 616c 6c65 722c 0a20 2020 2023 he caller,. #\n+0003f180: 2070 6c75 7320 616e 7920 7265 6665 7272 plus any referr\n+0003f190: 6564 2074 6f20 6279 2074 6865 2063 616c ed to by the cal\n+0003f1a0: 6c65 7227 7320 6c69 7374 206f 6620 7374 ler's list of st\n+0003f1b0: 6570 732e 0a20 2020 2070 726f 7669 6465 eps.. provide\n+0003f1c0: 645f 6761 6467 6574 7320 3d20 7365 7428 d_gadgets = set(\n+0003f1d0: 7573 6572 5f67 6164 6765 7473 290a 2020 user_gadgets). \n+0003f1e0: 2020 7374 6570 5f67 6164 6765 7473 203d step_gadgets =\n+0003f1f0: 207b 6e61 6d65 2066 6f72 206e 616d 652c {name for name,\n+0003f200: 205f 6172 6773 2069 6e20 7374 6570 737d _args in steps}\n+0003f210: 0a20 2020 2066 6f72 206e 616d 6520 696e . for name in\n+0003f220: 2070 726f 7669 6465 645f 6761 6467 6574 provided_gadget\n+0003f230: 7320 7c20 7374 6570 5f67 6164 6765 7473 s | step_gadgets\n+0003f240: 3a0a 2020 2020 2020 2020 7969 656c 6420 :. yield \n+0003f250: 6672 6f6d 2073 706c 6974 5f63 6f64 6528 from split_code(\n+0003f260: 6761 6467 6574 735b 6e61 6d65 5d2c 2069 gadgets[name], i\n+0003f270: 6d70 6f72 7473 290a 0a20 2020 2023 2059 mports).. # Y\n+0003f280: 6965 6c64 2066 756e 6374 696f 6e73 206d ield functions m\n+0003f290: 656e 7469 6f6e 6564 2069 6e20 7374 6570 entioned in step\n+0003f2a0: 7320 6672 6f6d 2074 6865 2063 616c 6c65 s from the calle\n+0003f2b0: 720a 2020 2020 666f 7220 6e61 6d65 2c20 r. for name, \n+0003f2c0: 6172 6773 2069 6e20 7374 6570 733a 0a20 args in steps:. \n+0003f2d0: 2020 2020 2020 2079 6965 6c64 2027 272c yield '',\n+0003f2e0: 206e 616d 6520 2b20 7265 7072 2874 7570 name + repr(tup\n+0003f2f0: 6c65 2861 7267 7329 290a 0a0a 6465 6620 le(args))...def \n+0003f300: 6d61 6b65 5f62 6f6f 746c 6f61 6465 7228 make_bootloader(\n+0003f310: 7374 6570 733a 2053 6571 7565 6e63 655b steps: Sequence[\n+0003f320: 5475 706c 655b 7374 722c 2053 6571 7565 Tuple[str, Seque\n+0003f330: 6e63 655b 6f62 6a65 6374 5d5d 5d2c 0a20 nce[object]]],. \n+0003f340: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0003f350: 2020 2067 6164 6765 7473 3a20 4f70 7469 gadgets: Opti\n+0003f360: 6f6e 616c 5b44 6963 745b 7374 722c 2073 onal[Dict[str, s\n+0003f370: 7472 5d5d 203d 204e 6f6e 6529 202d 3e20 tr]] = None) -> \n+0003f380: 7374 723a 0a20 2020 2069 6d70 6f72 7473 str:. imports\n+0003f390: 3a20 5365 745b 7374 725d 203d 2073 6574 : Set[str] = set\n+0003f3a0: 2829 0a20 2020 206c 696e 6573 3a20 4c69 (). lines: Li\n+0003f3b0: 7374 5b73 7472 5d20 3d20 5b5d 0a0a 2020 st[str] = [].. \n+0003f3c0: 2020 666f 7220 6672 616d 655f 7370 6163 for frame_spac\n+0003f3d0: 6573 2c20 6672 616d 655f 7465 7874 2069 es, frame_text i\n+0003f3e0: 6e20 7370 6c69 745f 636f 6465 2847 4144 n split_code(GAD\n+0003f3f0: 4745 5453 5b22 5f66 7261 6d65 225d 2c20 GETS[\"_frame\"], \n+0003f400: 696d 706f 7274 7329 3a0a 2020 2020 2020 imports):. \n+0003f410: 2020 6966 2066 7261 6d65 5f74 6578 7420 if frame_text \n+0003f420: 3d3d 2022 2e2e 2e22 3a0a 2020 2020 2020 == \"...\":. \n+0003f430: 2020 2020 2020 666f 7220 7370 6163 6573 for spaces\n+0003f440: 2c20 7465 7874 2069 6e20 7969 656c 645f , text in yield_\n+0003f450: 626f 6479 2867 6164 6765 7473 206f 7220 body(gadgets or \n+0003f460: 7b7d 2c20 7374 6570 732c 2069 6d70 6f72 {}, steps, impor\n+0003f470: 7473 293a 0a20 2020 2020 2020 2020 2020 ts):. \n+0003f480: 2020 2020 206c 696e 6573 2e61 7070 656e lines.appen\n+0003f490: 6428 6672 616d 655f 7370 6163 6573 202b d(frame_spaces +\n+0003f4a0: 2073 7061 6365 7320 2b20 7465 7874 290a spaces + text).\n+0003f4b0: 2020 2020 2020 2020 656c 7365 3a0a 2020 else:. \n+0003f4c0: 2020 2020 2020 2020 2020 6c69 6e65 732e lines.\n+0003f4d0: 6170 7065 6e64 2866 7261 6d65 5f73 7061 append(frame_spa\n+0003f4e0: 6365 7320 2b20 6672 616d 655f 7465 7874 ces + frame_text\n+0003f4f0: 290a 0a20 2020 2072 6574 7572 6e20 2222 ).. return \"\"\n+0003f500: 2e6a 6f69 6e28 6622 7b6c 696e 657d 5c6e .join(f\"{line}\\n\n+0003f510: 2220 666f 7220 6c69 6e65 2069 6e20 5b2a \" for line in [*\n+0003f520: 696d 706f 7274 732c 202a 6c69 6e65 735d imports, *lines]\n+0003f530: 2920 2b20 225c 6e22 0a27 2727 2c0a 2020 ) + \"\\n\".''',. \n+0003f540: 2763 6f63 6b70 6974 2f5f 7665 6e64 6f72 'cockpit/_vendor\n+0003f550: 2f62 6569 2f62 6569 626f 6f74 2e70 7927 /bei/beiboot.py'\n+0003f560: 3a20 6272 2222 2223 2062 6569 626f 6f74 : br\"\"\"# beiboot\n+0003f570: 202d 2052 656d 6f74 6520 626f 6f74 6c6f - Remote bootlo\n+0003f580: 6164 6572 2066 6f72 2050 7974 686f 6e0a ader for Python.\n+0003f590: 230a 2320 436f 7079 7269 6768 7420 2843 #.# Copyright (C\n+0003f5a0: 2920 3230 3232 2041 6c6c 6973 6f6e 204b ) 2022 Allison K\n+0003f5b0: 6172 6c69 7473 6b61 7961 203c 616c 6c69 arlitskaya <alli\n+0003f5c0: 736f 6e2e 6b61 726c 6974 736b 6179 6140 son.karlitskaya@\n+0003f5d0: 7265 6468 6174 2e63 6f6d 3e0a 230a 2320 redhat.com>.#.# \n+0003f5e0: 5468 6973 2070 726f 6772 616d 2069 7320 This program is \n+0003f5f0: 6672 6565 2073 6f66 7477 6172 653a 2079 free software: y\n+0003f600: 6f75 2063 616e 2072 6564 6973 7472 6962 ou can redistrib\n+0003f610: 7574 6520 6974 2061 6e64 2f6f 7220 6d6f ute it and/or mo\n+0003f620: 6469 6679 0a23 2069 7420 756e 6465 7220 dify.# it under \n+0003f630: 7468 6520 7465 726d 7320 6f66 2074 6865 the terms of the\n+0003f640: 2047 4e55 2047 656e 6572 616c 2050 7562 GNU General Pub\n+0003f650: 6c69 6320 4c69 6365 6e73 6520 6173 2070 lic License as p\n+0003f660: 7562 6c69 7368 6564 2062 790a 2320 7468 ublished by.# th\n+0003f670: 6520 4672 6565 2053 6f66 7477 6172 6520 e Free Software \n+0003f680: 466f 756e 6461 7469 6f6e 2c20 6569 7468 Foundation, eith\n+0003f690: 6572 2076 6572 7369 6f6e 2033 206f 6620 er version 3 of \n+0003f6a0: 7468 6520 4c69 6365 6e73 652c 206f 720a the License, or.\n+0003f6b0: 2320 2861 7420 796f 7572 206f 7074 696f # (at your optio\n+0003f6c0: 6e29 2061 6e79 206c 6174 6572 2076 6572 n) any later ver\n+0003f6d0: 7369 6f6e 2e0a 230a 2320 5468 6973 2070 sion..#.# This p\n+0003f6e0: 726f 6772 616d 2069 7320 6469 7374 7269 rogram is distri\n+0003f6f0: 6275 7465 6420 696e 2074 6865 2068 6f70 buted in the hop\n+0003f700: 6520 7468 6174 2069 7420 7769 6c6c 2062 e that it will b\n+0003f710: 6520 7573 6566 756c 2c0a 2320 6275 7420 e useful,.# but \n+0003f720: 5749 5448 4f55 5420 414e 5920 5741 5252 WITHOUT ANY WARR\n+0003f730: 414e 5459 3b20 7769 7468 6f75 7420 6576 ANTY; without ev\n+0003f740: 656e 2074 6865 2069 6d70 6c69 6564 2077 en the implied w\n+0003f750: 6172 7261 6e74 7920 6f66 0a23 204d 4552 arranty of.# MER\n+0003f760: 4348 414e 5441 4249 4c49 5459 206f 7220 CHANTABILITY or \n+0003f770: 4649 544e 4553 5320 464f 5220 4120 5041 FITNESS FOR A PA\n+0003f780: 5254 4943 554c 4152 2050 5552 504f 5345 RTICULAR PURPOSE\n+0003f790: 2e20 2053 6565 2074 6865 0a23 2047 4e55 . See the.# GNU\n+0003f7a0: 2047 656e 6572 616c 2050 7562 6c69 6320 General Public \n+0003f7b0: 4c69 6365 6e73 6520 666f 7220 6d6f 7265 License for more\n+0003f7c0: 2064 6574 6169 6c73 2e0a 230a 2320 596f details..#.# Yo\n+0003f7d0: 7520 7368 6f75 6c64 2068 6176 6520 7265 u should have re\n+0003f7e0: 6365 6976 6564 2061 2063 6f70 7920 6f66 ceived a copy of\n+0003f7f0: 2074 6865 2047 4e55 2047 656e 6572 616c the GNU General\n+0003f800: 2050 7562 6c69 6320 4c69 6365 6e73 650a Public License.\n+0003f810: 2320 616c 6f6e 6720 7769 7468 2074 6869 # along with thi\n+0003f820: 7320 7072 6f67 7261 6d2e 2020 4966 206e s program. If n\n+0003f830: 6f74 2c20 7365 6520 3c68 7474 703a 2f2f ot, see <http://\n+0003f840: 7777 772e 676e 752e 6f72 672f 6c69 6365 www.gnu.org/lice\n+0003f850: 6e73 6573 2f3e 2e0a 0a69 6d70 6f72 7420 nses/>...import \n+0003f860: 6172 6770 6172 7365 0a69 6d70 6f72 7420 argparse.import \n+0003f870: 6173 796e 6369 6f0a 696d 706f 7274 206f asyncio.import o\n+0003f880: 730a 696d 706f 7274 2073 686c 6578 0a69 s.import shlex.i\n+0003f890: 6d70 6f72 7420 7375 6270 726f 6365 7373 mport subprocess\n+0003f8a0: 0a69 6d70 6f72 7420 7379 730a 696d 706f .import sys.impo\n+0003f8b0: 7274 2074 6872 6561 6469 6e67 0a66 726f rt threading.fro\n+0003f8c0: 6d20 7479 7069 6e67 2069 6d70 6f72 7420 m typing import \n+0003f8d0: 494f 2c20 4c69 7374 2c20 5365 7175 656e IO, List, Sequen\n+0003f8e0: 6365 2c20 5475 706c 650a 0a66 726f 6d20 ce, Tuple..from \n+0003f8f0: 2e62 6f6f 746c 6f61 6465 7220 696d 706f .bootloader impo\n+0003f900: 7274 206d 616b 655f 626f 6f74 6c6f 6164 rt make_bootload\n+0003f910: 6572 0a0a 0a64 6566 2067 6574 5f70 7974 er...def get_pyt\n+0003f920: 686f 6e5f 636f 6d6d 616e 6428 6c6f 6361 hon_command(loca\n+0003f930: 6c3a 2062 6f6f 6c20 3d20 4661 6c73 652c l: bool = False,\n+0003f940: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+0003f950: 2020 2020 2020 2020 7474 793a 2062 6f6f tty: boo\n+0003f960: 6c20 3d20 4661 6c73 652c 0a20 2020 2020 l = False,. \n+0003f970: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0003f980: 2020 7368 3a20 626f 6f6c 203d 2046 616c sh: bool = Fal\n+0003f990: 7365 2920 2d3e 2053 6571 7565 6e63 655b se) -> Sequence[\n+0003f9a0: 7374 725d 3a0a 2020 2020 696e 7465 7270 str]:. interp\n+0003f9b0: 7265 7465 7220 3d20 7379 732e 6578 6563 reter = sys.exec\n+0003f9c0: 7574 6162 6c65 2069 6620 6c6f 6361 6c20 utable if local \n+0003f9d0: 656c 7365 2027 7079 7468 6f6e 3327 0a20 else 'python3'. \n+0003f9e0: 2020 2063 6f6d 6d61 6e64 3a20 5365 7175 command: Sequ\n+0003f9f0: 656e 6365 5b73 7472 5d0a 0a20 2020 2069 ence[str].. i\n+0003fa00: 6620 7474 793a 0a20 2020 2020 2020 2063 f tty:. c\n+0003fa10: 6f6d 6d61 6e64 203d 2028 696e 7465 7270 ommand = (interp\n+0003fa20: 7265 7465 722c 2027 2d69 7127 290a 2020 reter, '-iq'). \n+0003fa30: 2020 656c 7365 3a0a 2020 2020 2020 2020 else:. \n+0003fa40: 636f 6d6d 616e 6420 3d20 280a 2020 2020 command = (. \n+0003fa50: 2020 2020 2020 2020 696e 7465 7270 7265 interpre\n+0003fa60: 7465 722c 2027 2d69 6327 2c0a 2020 2020 ter, '-ic',. \n+0003fa70: 2020 2020 2020 2020 2320 6874 7470 733a # https:\n+0003fa80: 2f2f 6769 7468 7562 2e63 6f6d 2f70 7974 //github.com/pyt\n+0003fa90: 686f 6e2f 6370 7974 686f 6e2f 6973 7375 hon/cpython/issu\n+0003faa0: 6573 2f39 3331 3339 0a20 2020 2020 2020 es/93139. \n+0003fab0: 2020 2020 2027 2727 2220 2d20 6265 6962 '''\" - beib\n+0003fac0: 6f6f 7420 2d20 223b 2069 6d70 6f72 7420 oot - \"; import \n+0003fad0: 7379 733b 2073 7973 2e70 7331 203d 2027 sys; sys.ps1 = '\n+0003fae0: 273b 2073 7973 2e70 7332 203d 2027 273b '; sys.ps2 = '';\n+0003faf0: 2727 270a 2020 2020 2020 2020 290a 0a20 '''. ).. \n+0003fb00: 2020 2069 6620 7368 3a0a 2020 2020 2020 if sh:. \n+0003fb10: 2020 636f 6d6d 616e 6420 3d20 2827 2027 command = (' '\n+0003fb20: 2e6a 6f69 6e28 7368 6c65 782e 7175 6f74 .join(shlex.quot\n+0003fb30: 6528 6172 6729 2066 6f72 2061 7267 2069 e(arg) for arg i\n+0003fb40: 6e20 636f 6d6d 616e 6429 2c29 0a0a 2020 n command),).. \n+0003fb50: 2020 7265 7475 726e 2063 6f6d 6d61 6e64 return command\n+0003fb60: 0a0a 0a64 6566 2067 6574 5f73 7368 5f63 ...def get_ssh_c\n+0003fb70: 6f6d 6d61 6e64 282a 6172 6773 3a20 7374 ommand(*args: st\n+0003fb80: 722c 2074 7479 3a20 626f 6f6c 203d 2046 r, tty: bool = F\n+0003fb90: 616c 7365 2920 2d3e 2053 6571 7565 6e63 alse) -> Sequenc\n+0003fba0: 655b 7374 725d 3a0a 2020 2020 7265 7475 e[str]:. retu\n+0003fbb0: 726e 2028 2773 7368 272c 0a20 2020 2020 rn ('ssh',. \n+0003fbc0: 2020 2020 2020 202a 285b 272d 7427 5d20 *(['-t'] \n+0003fbd0: 6966 2074 7479 2065 6c73 6520 2829 292c if tty else ()),\n+0003fbe0: 0a20 2020 2020 2020 2020 2020 202a 6172 . *ar\n+0003fbf0: 6773 2c0a 2020 2020 2020 2020 2020 2020 gs,. \n+0003fc00: 2a67 6574 5f70 7974 686f 6e5f 636f 6d6d *get_python_comm\n+0003fc10: 616e 6428 7474 793d 7474 792c 2073 683d and(tty=tty, sh=\n+0003fc20: 5472 7565 2929 0a0a 0a64 6566 2067 6574 True))...def get\n+0003fc30: 5f63 6f6e 7461 696e 6572 5f63 6f6d 6d61 _container_comma\n+0003fc40: 6e64 282a 6172 6773 3a20 7374 722c 2074 nd(*args: str, t\n+0003fc50: 7479 3a20 626f 6f6c 203d 2046 616c 7365 ty: bool = False\n+0003fc60: 2920 2d3e 2053 6571 7565 6e63 655b 7374 ) -> Sequence[st\n+0003fc70: 725d 3a0a 2020 2020 7265 7475 726e 2028 r]:. return (\n+0003fc80: 2770 6f64 6d61 6e27 2c20 2765 7865 6327 'podman', 'exec'\n+0003fc90: 2c20 272d 2d69 6e74 6572 6163 7469 7665 , '--interactive\n+0003fca0: 272c 0a20 2020 2020 2020 2020 2020 202a ',. *\n+0003fcb0: 285b 272d 2d74 7479 275d 2069 6620 7474 (['--tty'] if tt\n+0003fcc0: 7920 656c 7365 2028 2929 2c0a 2020 2020 y else ()),. \n+0003fcd0: 2020 2020 2020 2020 2a61 7267 732c 0a20 *args,. \n+0003fce0: 2020 2020 2020 2020 2020 202a 6765 745f *get_\n+0003fcf0: 7079 7468 6f6e 5f63 6f6d 6d61 6e64 2874 python_command(t\n+0003fd00: 7479 3d74 7479 2929 0a0a 0a64 6566 2067 ty=tty))...def g\n+0003fd10: 6574 5f63 6f6d 6d61 6e64 282a 6172 6773 et_command(*args\n+0003fd20: 3a20 7374 722c 2074 7479 3a20 626f 6f6c : str, tty: bool\n+0003fd30: 203d 2046 616c 7365 2c20 7368 3a20 626f = False, sh: bo\n+0003fd40: 6f6c 203d 2046 616c 7365 2920 2d3e 2053 ol = False) -> S\n+0003fd50: 6571 7565 6e63 655b 7374 725d 3a0a 2020 equence[str]:. \n+0003fd60: 2020 7265 7475 726e 2028 2a61 7267 732c return (*args,\n+0003fd70: 202a 6765 745f 7079 7468 6f6e 5f63 6f6d *get_python_com\n+0003fd80: 6d61 6e64 286c 6f63 616c 3d54 7275 652c mand(local=True,\n+0003fd90: 2074 7479 3d74 7479 2c20 7368 3d73 6829 tty=tty, sh=sh)\n+0003fda0: 290a 0a0a 6465 6620 7370 6c69 6365 5f69 )...def splice_i\n+0003fdb0: 6e5f 7468 7265 6164 2873 7263 3a20 696e n_thread(src: in\n+0003fdc0: 742c 2064 7374 3a20 494f 5b62 7974 6573 t, dst: IO[bytes\n+0003fdd0: 5d29 202d 3e20 4e6f 6e65 3a0a 2020 2020 ]) -> None:. \n+0003fde0: 6465 6620 5f74 6872 6561 6428 2920 2d3e def _thread() ->\n+0003fdf0: 204e 6f6e 653a 0a20 2020 2020 2020 2023 None:. #\n+0003fe00: 206f 732e 7370 6c69 6365 2829 206f 6e6c os.splice() onl\n+0003fe10: 7920 696e 2050 7974 686f 6e20 332e 3130 y in Python 3.10\n+0003fe20: 0a20 2020 2020 2020 2077 6974 6820 6473 . with ds\n+0003fe30: 743a 0a20 2020 2020 2020 2020 2020 2062 t:. b\n+0003fe40: 6c6f 636b 5f73 697a 6520 3d20 3120 3c3c lock_size = 1 <<\n+0003fe50: 2032 300a 2020 2020 2020 2020 2020 2020 20. \n+0003fe60: 7768 696c 6520 5472 7565 3a0a 2020 2020 while True:. \n+0003fe70: 2020 2020 2020 2020 2020 2020 6461 7461 data\n+0003fe80: 203d 206f 732e 7265 6164 2873 7263 2c20 = os.read(src, \n+0003fe90: 626c 6f63 6b5f 7369 7a65 290a 2020 2020 block_size). \n+0003fea0: 2020 2020 2020 2020 2020 2020 6966 206e if n\n+0003feb0: 6f74 2064 6174 613a 0a20 2020 2020 2020 ot data:. \n+0003fec0: 2020 2020 2020 2020 2020 2020 2062 7265 bre\n+0003fed0: 616b 0a20 2020 2020 2020 2020 2020 2020 ak. \n+0003fee0: 2020 2064 7374 2e77 7269 7465 2864 6174 dst.write(dat\n+0003fef0: 6129 0a20 2020 2020 2020 2020 2020 2020 a). \n+0003ff00: 2020 2064 7374 2e66 6c75 7368 2829 0a0a dst.flush()..\n+0003ff10: 2020 2020 7468 7265 6164 696e 672e 5468 threading.Th\n+0003ff20: 7265 6164 2874 6172 6765 743d 5f74 6872 read(target=_thr\n+0003ff30: 6561 642c 2064 6165 6d6f 6e3d 5472 7565 ead, daemon=True\n+0003ff40: 292e 7374 6172 7428 290a 0a0a 6465 6620 ).start()...def \n+0003ff50: 7365 6e64 5f61 6e64 5f73 706c 6963 6528 send_and_splice(\n+0003ff60: 636f 6d6d 616e 643a 2053 6571 7565 6e63 command: Sequenc\n+0003ff70: 655b 7374 725d 2c20 7363 7269 7074 3a20 e[str], script: \n+0003ff80: 6279 7465 7329 202d 3e20 4e6f 6e65 3a0a bytes) -> None:.\n+0003ff90: 2020 2020 7769 7468 2073 7562 7072 6f63 with subproc\n+0003ffa0: 6573 732e 506f 7065 6e28 636f 6d6d 616e ess.Popen(comman\n+0003ffb0: 642c 2073 7464 696e 3d73 7562 7072 6f63 d, stdin=subproc\n+0003ffc0: 6573 732e 5049 5045 2920 6173 2070 726f ess.PIPE) as pro\n+0003ffd0: 633a 0a20 2020 2020 2020 2061 7373 6572 c:. asser\n+0003ffe0: 7420 7072 6f63 2e73 7464 696e 2069 7320 t proc.stdin is \n+0003fff0: 6e6f 7420 4e6f 6e65 0a20 2020 2020 2020 not None. \n+00040000: 2070 726f 632e 7374 6469 6e2e 7772 6974 proc.stdin.writ\n+00040010: 6528 7363 7269 7074 290a 0a20 2020 2020 e(script).. \n+00040020: 2020 2073 706c 6963 655f 696e 5f74 6872 splice_in_thr\n+00040030: 6561 6428 302c 2070 726f 632e 7374 6469 ead(0, proc.stdi\n+00040040: 6e29 0a20 2020 2020 2020 2073 7973 2e65 n). sys.e\n+00040050: 7869 7428 7072 6f63 2e77 6169 7428 2929 xit(proc.wait())\n+00040060: 0a0a 0a64 6566 2073 656e 645f 787a 5f61 ...def send_xz_a\n+00040070: 6e64 5f73 706c 6963 6528 636f 6d6d 616e nd_splice(comman\n+00040080: 643a 2053 6571 7565 6e63 655b 7374 725d d: Sequence[str]\n+00040090: 2c20 7363 7269 7074 3a20 6279 7465 7329 , script: bytes)\n+000400a0: 202d 3e20 4e6f 6e65 3a0a 2020 2020 696d -> None:. im\n+000400b0: 706f 7274 2066 6572 6e79 0a0a 2020 2020 port ferny.. \n+000400c0: 636c 6173 7320 5265 7370 6f6e 6465 7228 class Responder(\n+000400d0: 6665 726e 792e 496e 7465 7261 6374 696f ferny.Interactio\n+000400e0: 6e52 6573 706f 6e64 6572 293a 0a20 2020 nResponder):. \n+000400f0: 2020 2020 2061 7379 6e63 2064 6566 2064 async def d\n+00040100: 6f5f 6375 7374 6f6d 5f63 6f6d 6d61 6e64 o_custom_command\n+00040110: 2873 656c 662c 0a20 2020 2020 2020 2020 (self,. \n+00040120: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00040130: 2020 2020 2020 2020 2020 2063 6f6d 6d61 comma\n+00040140: 6e64 3a20 7374 722c 0a20 2020 2020 2020 nd: str,. \n+00040150: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00040160: 2020 2020 2020 2020 2020 2020 2061 7267 arg\n+00040170: 733a 2054 7570 6c65 2c0a 2020 2020 2020 s: Tuple,. \n+00040180: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00040190: 2020 2020 2020 2020 2020 2020 2020 6664 fd\n+000401a0: 733a 204c 6973 745b 696e 745d 2c0a 2020 s: List[int],. \n+000401b0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000401c0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000401d0: 2020 7374 6465 7272 3a20 7374 7229 202d stderr: str) -\n+000401e0: 3e20 4e6f 6e65 3a0a 2020 2020 2020 2020 > None:. \n+000401f0: 2020 2020 6173 7365 7274 2070 726f 632e assert proc.\n+00040200: 7374 6469 6e20 6973 206e 6f74 204e 6f6e stdin is not Non\n+00040210: 650a 2020 2020 2020 2020 2020 2020 6966 e. if\n+00040220: 2063 6f6d 6d61 6e64 203d 3d20 2762 6569 command == 'bei\n+00040230: 626f 6f74 2e70 726f 7669 6465 273a 0a20 boot.provide':. \n+00040240: 2020 2020 2020 2020 2020 2020 2020 2070 p\n+00040250: 726f 632e 7374 6469 6e2e 7772 6974 6528 roc.stdin.write(\n+00040260: 7363 7269 7074 290a 2020 2020 2020 2020 script). \n+00040270: 2020 2020 2020 2020 7072 6f63 2e73 7464 proc.std\n+00040280: 696e 2e66 6c75 7368 2829 0a0a 2020 2020 in.flush().. \n+00040290: 6167 656e 7420 3d20 6665 726e 792e 496e agent = ferny.In\n+000402a0: 7465 7261 6374 696f 6e41 6765 6e74 2852 teractionAgent(R\n+000402b0: 6573 706f 6e64 6572 2829 290a 2020 2020 esponder()). \n+000402c0: 7769 7468 2073 7562 7072 6f63 6573 732e with subprocess.\n+000402d0: 506f 7065 6e28 636f 6d6d 616e 642c 2073 Popen(command, s\n+000402e0: 7464 696e 3d73 7562 7072 6f63 6573 732e tdin=subprocess.\n+000402f0: 5049 5045 2c20 7374 6465 7272 3d61 6765 PIPE, stderr=age\n+00040300: 6e74 2920 6173 2070 726f 633a 0a20 2020 nt) as proc:. \n+00040310: 2020 2020 2061 7373 6572 7420 7072 6f63 assert proc\n+00040320: 2e73 7464 696e 2069 7320 6e6f 7420 4e6f .stdin is not No\n+00040330: 6e65 0a20 2020 2020 2020 2070 726f 632e ne. proc.\n+00040340: 7374 6469 6e2e 7772 6974 6528 6d61 6b65 stdin.write(make\n+00040350: 5f62 6f6f 746c 6f61 6465 7228 5b0a 2020 _bootloader([. \n+00040360: 2020 2020 2020 2020 2020 2827 626f 6f74 ('boot\n+00040370: 5f78 7a27 2c20 2827 7363 7269 7074 2e70 _xz', ('script.p\n+00040380: 792e 787a 272c 206c 656e 2873 6372 6970 y.xz', len(scrip\n+00040390: 7429 2c20 5b5d 2c20 5472 7565 2929 2c0a t), [], True)),.\n+000403a0: 2020 2020 2020 2020 5d2c 2067 6164 6765 ], gadge\n+000403b0: 7473 3d66 6572 6e79 2e42 4549 424f 4f54 ts=ferny.BEIBOOT\n+000403c0: 5f47 4144 4745 5453 292e 656e 636f 6465 _GADGETS).encode\n+000403d0: 2829 290a 2020 2020 2020 2020 7072 6f63 ()). proc\n+000403e0: 2e73 7464 696e 2e66 6c75 7368 2829 0a0a .stdin.flush()..\n+000403f0: 2020 2020 2020 2020 6173 796e 6369 6f2e asyncio.\n+00040400: 7275 6e28 6167 656e 742e 636f 6d6d 756e run(agent.commun\n+00040410: 6963 6174 6528 2929 0a20 2020 2020 2020 icate()). \n+00040420: 2073 706c 6963 655f 696e 5f74 6872 6561 splice_in_threa\n+00040430: 6428 302c 2070 726f 632e 7374 6469 6e29 d(0, proc.stdin)\n+00040440: 0a20 2020 2020 2020 2073 7973 2e65 7869 . sys.exi\n+00040450: 7428 7072 6f63 2e77 6169 7428 2929 0a0a t(proc.wait())..\n+00040460: 0a64 6566 206d 6169 6e28 2920 2d3e 204e .def main() -> N\n+00040470: 6f6e 653a 0a20 2020 2070 6172 7365 7220 one:. parser \n+00040480: 3d20 6172 6770 6172 7365 2e41 7267 756d = argparse.Argum\n+00040490: 656e 7450 6172 7365 7228 290a 2020 2020 entParser(). \n+000404a0: 7061 7273 6572 2e61 6464 5f61 7267 756d parser.add_argum\n+000404b0: 656e 7428 272d 2d73 6827 2c20 6163 7469 ent('--sh', acti\n+000404c0: 6f6e 3d27 7374 6f72 655f 7472 7565 272c on='store_true',\n+000404d0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+000404e0: 2020 2020 2020 2020 2068 656c 703d 2750 help='P\n+000404f0: 6173 7320 5079 7468 6f6e 2069 6e74 6572 ass Python inter\n+00040500: 7072 6574 6572 2063 6f6d 6d61 6e64 2061 preter command a\n+00040510: 7320 7368 656c 6c2d 7363 7269 7074 2729 s shell-script')\n+00040520: 0a20 2020 2070 6172 7365 722e 6164 645f . parser.add_\n+00040530: 6172 6775 6d65 6e74 2827 2d2d 787a 272c argument('--xz',\n+00040540: 2068 656c 703d 2274 6865 2078 7a20 746f help=\"the xz to\n+00040550: 2072 756e 2072 656d 6f74 656c 7922 290a run remotely\").\n+00040560: 2020 2020 7061 7273 6572 2e61 6464 5f61 parser.add_a\n+00040570: 7267 756d 656e 7428 272d 2d73 6372 6970 rgument('--scrip\n+00040580: 7427 2c0a 2020 2020 2020 2020 2020 2020 t',. \n+00040590: 2020 2020 2020 2020 2020 2020 6865 6c70 help\n+000405a0: 3d22 7468 6520 7363 7269 7074 2074 6f20 =\"the script to \n+000405b0: 7275 6e20 7265 6d6f 7465 6c79 2028 6d75 run remotely (mu\n+000405c0: 7374 2062 6520 7265 706c 2d66 7269 656e st be repl-frien\n+000405d0: 646c 7929 2229 0a20 2020 2070 6172 7365 dly)\"). parse\n+000405e0: 722e 6164 645f 6172 6775 6d65 6e74 2827 r.add_argument('\n+000405f0: 636f 6d6d 616e 6427 2c20 6e61 7267 733d command', nargs=\n+00040600: 272a 2729 0a0a 2020 2020 6172 6773 203d '*').. args =\n+00040610: 2070 6172 7365 722e 7061 7273 655f 6172 parser.parse_ar\n+00040620: 6773 2829 0a20 2020 2074 7479 203d 206e gs(). tty = n\n+00040630: 6f74 2061 7267 732e 7363 7269 7074 2061 ot args.script a\n+00040640: 6e64 206f 732e 6973 6174 7479 2830 290a nd os.isatty(0).\n+00040650: 0a20 2020 2069 6620 6172 6773 2e63 6f6d . if args.com\n+00040660: 6d61 6e64 203d 3d20 5b5d 3a0a 2020 2020 mand == []:. \n+00040670: 2020 2020 636f 6d6d 616e 6420 3d20 6765 command = ge\n+00040680: 745f 7079 7468 6f6e 5f63 6f6d 6d61 6e64 t_python_command\n+00040690: 2874 7479 3d74 7479 290a 2020 2020 656c (tty=tty). el\n+000406a0: 6966 2061 7267 732e 636f 6d6d 616e 645b if args.command[\n+000406b0: 305d 203d 3d20 2773 7368 273a 0a20 2020 0] == 'ssh':. \n+000406c0: 2020 2020 2063 6f6d 6d61 6e64 203d 2067 command = g\n+000406d0: 6574 5f73 7368 5f63 6f6d 6d61 6e64 282a et_ssh_command(*\n+000406e0: 6172 6773 2e63 6f6d 6d61 6e64 5b31 3a5d args.command[1:]\n+000406f0: 2c20 7474 793d 7474 7929 0a20 2020 2065 , tty=tty). e\n+00040700: 6c69 6620 6172 6773 2e63 6f6d 6d61 6e64 lif args.command\n+00040710: 5b30 5d20 3d3d 2027 636f 6e74 6169 6e65 [0] == 'containe\n+00040720: 7227 3a0a 2020 2020 2020 2020 636f 6d6d r':. comm\n+00040730: 616e 6420 3d20 6765 745f 636f 6e74 6169 and = get_contai\n+00040740: 6e65 725f 636f 6d6d 616e 6428 2a61 7267 ner_command(*arg\n+00040750: 732e 636f 6d6d 616e 645b 313a 5d2c 2074 s.command[1:], t\n+00040760: 7479 3d74 7479 290a 2020 2020 656c 7365 ty=tty). else\n+00040770: 3a0a 2020 2020 2020 2020 636f 6d6d 616e :. comman\n+00040780: 6420 3d20 6765 745f 636f 6d6d 616e 6428 d = get_command(\n+00040790: 2a61 7267 732e 636f 6d6d 616e 642c 2074 *args.command, t\n+000407a0: 7479 3d74 7479 2c20 7368 3d61 7267 732e ty=tty, sh=args.\n+000407b0: 7368 290a 0a20 2020 2069 6620 6172 6773 sh).. if args\n+000407c0: 2e73 6372 6970 743a 0a20 2020 2020 2020 .script:. \n+000407d0: 2077 6974 6820 6f70 656e 2861 7267 732e with open(args.\n+000407e0: 7363 7269 7074 2c20 2772 6227 2920 6173 script, 'rb') as\n+000407f0: 2066 696c 653a 0a20 2020 2020 2020 2020 file:. \n+00040800: 2020 2073 6372 6970 7420 3d20 6669 6c65 script = file\n+00040810: 2e72 6561 6428 290a 0a20 2020 2020 2020 .read().. \n+00040820: 2073 656e 645f 616e 645f 7370 6c69 6365 send_and_splice\n+00040830: 2863 6f6d 6d61 6e64 2c20 7363 7269 7074 (command, script\n+00040840: 290a 0a20 2020 2065 6c69 6620 6172 6773 ).. elif args\n+00040850: 2e78 7a3a 0a20 2020 2020 2020 2077 6974 .xz:. wit\n+00040860: 6820 6f70 656e 2861 7267 732e 787a 2c20 h open(args.xz, \n+00040870: 2772 6227 2920 6173 2066 696c 653a 0a20 'rb') as file:. \n+00040880: 2020 2020 2020 2020 2020 2073 6372 6970 scrip\n+00040890: 7420 3d20 6669 6c65 2e72 6561 6428 290a t = file.read().\n+000408a0: 0a20 2020 2020 2020 2073 656e 645f 787a . send_xz\n+000408b0: 5f61 6e64 5f73 706c 6963 6528 636f 6d6d _and_splice(comm\n+000408c0: 616e 642c 2073 6372 6970 7429 0a0a 2020 and, script).. \n+000408d0: 2020 656c 7365 3a0a 2020 2020 2020 2020 else:. \n+000408e0: 2320 4966 2077 6527 7265 2073 7472 6561 # If we're strea\n+000408f0: 6d69 6e67 2066 726f 6d20 7374 6469 6e20 ming from stdin \n+00040900: 7468 656e 2074 6869 7320 6973 2061 206c then this is a l\n+00040910: 6f74 2065 6173 6965 722e 2e2e 0a20 2020 ot easier.... \n+00040920: 2020 2020 206f 732e 6578 6563 6c70 2863 os.execlp(c\n+00040930: 6f6d 6d61 6e64 5b30 5d2c 202a 636f 6d6d ommand[0], *comm\n+00040940: 616e 6429 0a0a 2020 2020 2320 4f74 6865 and).. # Othe\n+00040950: 7277 6973 652c 2022 6675 6c6c 2073 7472 rwise, \"full str\n+00040960: 656e 6774 6822 0a0a 6966 205f 5f6e 616d ength\"..if __nam\n+00040970: 655f 5f20 3d3d 2027 5f5f 6d61 696e 5f5f e__ == '__main__\n+00040980: 273a 0a20 2020 206d 6169 6e28 290a 2222 ':. main().\"\"\n+00040990: 222c 0a20 2027 636f 636b 7069 742f 5f76 \",. 'cockpit/_v\n+000409a0: 656e 646f 722f 6265 692f 7370 6177 6e2e endor/bei/spawn.\n+000409b0: 7079 273a 2062 7227 2727 2222 2248 656c py': br'''\"\"\"Hel\n+000409c0: 7065 7220 746f 2063 7265 6174 6520 6120 per to create a \n+000409d0: 6265 6970 6163 6b20 746f 2073 7061 776e beipack to spawn\n+000409e0: 2061 2063 6f6d 6d61 6e64 2077 6974 6820 a command with \n+000409f0: 6669 6c65 7320 696e 2061 2074 6d70 6469 files in a tmpdi\n+00040a00: 7222 2222 0a0a 696d 706f 7274 2061 7267 r\"\"\"..import arg\n+00040a10: 7061 7273 650a 696d 706f 7274 206f 730a parse.import os.\n+00040a20: 696d 706f 7274 2073 7973 0a0a 6672 6f6d import sys..from\n+00040a30: 202e 2069 6d70 6f72 7420 7061 636b 2c20 . import pack, \n+00040a40: 746d 7066 730a 0a0a 6465 6620 6d61 696e tmpfs...def main\n+00040a50: 2829 202d 3e20 4e6f 6e65 3a0a 2020 2020 () -> None:. \n+00040a60: 7061 7273 6572 203d 2061 7267 7061 7273 parser = argpars\n+00040a70: 652e 4172 6775 6d65 6e74 5061 7273 6572 e.ArgumentParser\n+00040a80: 2829 0a20 2020 2070 6172 7365 722e 6164 (). parser.ad\n+00040a90: 645f 6172 6775 6d65 6e74 2827 2d2d 6669 d_argument('--fi\n+00040aa0: 6c65 272c 2027 2d66 272c 2061 6374 696f le', '-f', actio\n+00040ab0: 6e3d 2761 7070 656e 6427 290a 2020 2020 n='append'). \n+00040ac0: 7061 7273 6572 2e61 6464 5f61 7267 756d parser.add_argum\n+00040ad0: 656e 7428 2763 6f6d 6d61 6e64 272c 206e ent('command', n\n+00040ae0: 6172 6773 3d27 2b27 2c20 6865 6c70 3d27 args='+', help='\n+00040af0: 5468 6520 636f 6d6d 616e 6420 746f 2065 The command to e\n+00040b00: 7865 6375 7465 2729 0a20 2020 2061 7267 xecute'). arg\n+00040b10: 7320 3d20 7061 7273 6572 2e70 6172 7365 s = parser.parse\n+00040b20: 5f61 7267 7328 290a 0a20 2020 2063 6f6e _args().. con\n+00040b30: 7465 6e74 7320 3d20 7b0a 2020 2020 2020 tents = {. \n+00040b40: 2020 275f 6265 6974 6d70 6673 2e70 7927 '_beitmpfs.py'\n+00040b50: 3a20 746d 7066 732e 5f5f 7370 6563 5f5f : tmpfs.__spec__\n+00040b60: 2e6c 6f61 6465 722e 6765 745f 6461 7461 .loader.get_data\n+00040b70: 2874 6d70 6673 2e5f 5f73 7065 635f 5f2e (tmpfs.__spec__.\n+00040b80: 6f72 6967 696e 290a 2020 2020 7d0a 0a20 origin). }.. \n+00040b90: 2020 2069 6620 6172 6773 2e66 696c 6520 if args.file \n+00040ba0: 6973 206e 6f74 204e 6f6e 653a 0a20 2020 is not None:. \n+00040bb0: 2020 2020 2066 696c 6573 203d 2061 7267 files = arg\n+00040bc0: 732e 6669 6c65 0a20 2020 2065 6c73 653a s.file. else:\n+00040bd0: 0a20 2020 2020 2020 2066 696c 6520 3d20 . file = \n+00040be0: 6172 6773 2e63 6f6d 6d61 6e64 5b2d 315d args.command[-1]\n+00040bf0: 0a20 2020 2020 2020 2066 696c 6573 203d . files =\n+00040c00: 205b 6669 6c65 5d0a 2020 2020 2020 2020 [file]. \n+00040c10: 6172 6773 2e63 6f6d 6d61 6e64 5b2d 315d args.command[-1]\n+00040c20: 203d 2027 2e2f 2720 2b20 6f73 2e70 6174 = './' + os.pat\n+00040c30: 682e 6261 7365 6e61 6d65 2866 696c 6529 h.basename(file)\n+00040c40: 0a0a 2020 2020 666f 7220 6669 6c65 6e61 .. for filena\n+00040c50: 6d65 2069 6e20 6669 6c65 733a 0a20 2020 me in files:. \n+00040c60: 2020 2020 2077 6974 6820 6f70 656e 2866 with open(f\n+00040c70: 696c 656e 616d 652c 2027 7262 2729 2061 ilename, 'rb') a\n+00040c80: 7320 6669 6c65 3a0a 2020 2020 2020 2020 s file:. \n+00040c90: 2020 2020 6261 7365 6e61 6d65 203d 206f basename = o\n+00040ca0: 732e 7061 7468 2e62 6173 656e 616d 6528 s.path.basename(\n+00040cb0: 6669 6c65 6e61 6d65 290a 2020 2020 2020 filename). \n+00040cc0: 2020 2020 2020 636f 6e74 656e 7473 5b66 contents[f\n+00040cd0: 2774 6d70 6673 2f7b 6261 7365 6e61 6d65 'tmpfs/{basename\n+00040ce0: 7d27 5d20 3d20 6669 6c65 2e72 6561 6428 }'] = file.read(\n+00040cf0: 290a 0a20 2020 2073 6372 6970 7420 3d20 ).. script = \n+00040d00: 7061 636b 2e70 6163 6b28 636f 6e74 656e pack.pack(conten\n+00040d10: 7473 2c20 275f 6265 6974 6d70 6673 3a6d ts, '_beitmpfs:m\n+00040d20: 6169 6e27 2c20 272a 2720 2b20 7265 7072 ain', '*' + repr\n+00040d30: 2861 7267 732e 636f 6d6d 616e 6429 290a (args.command)).\n+00040d40: 2020 2020 7379 732e 7374 646f 7574 2e77 sys.stdout.w\n+00040d50: 7269 7465 2873 6372 6970 7429 0a0a 0a69 rite(script)...i\n+00040d60: 6620 5f5f 6e61 6d65 5f5f 203d 3d20 275f f __name__ == '_\n+00040d70: 5f6d 6169 6e5f 5f27 3a0a 2020 2020 6d61 _main__':. ma\n+00040d80: 696e 2829 0a27 2727 2c0a 2020 2763 6f63 in().''',. 'coc\n+00040d90: 6b70 6974 2f5f 7665 6e64 6f72 2f62 6569 kpit/_vendor/bei\n+00040da0: 2f74 6d70 6673 2e70 7927 3a20 6272 2727 /tmpfs.py': br''\n+00040db0: 2769 6d70 6f72 7420 6f73 0a69 6d70 6f72 'import os.impor\n+00040dc0: 7420 7375 6270 726f 6365 7373 0a69 6d70 t subprocess.imp\n+00040dd0: 6f72 7420 7379 730a 696d 706f 7274 2074 ort sys.import t\n+00040de0: 656d 7066 696c 650a 0a0a 6465 6620 6d61 empfile...def ma\n+00040df0: 696e 282a 636f 6d6d 616e 643a 2073 7472 in(*command: str\n+00040e00: 2920 2d3e 204e 6f6e 653a 0a20 2020 2077 ) -> None:. w\n+00040e10: 6974 6820 7465 6d70 6669 6c65 2e54 656d ith tempfile.Tem\n+00040e20: 706f 7261 7279 4469 7265 6374 6f72 7928 poraryDirectory(\n+00040e30: 2920 6173 2074 6d70 6469 723a 0a20 2020 ) as tmpdir:. \n+00040e40: 2020 2020 206f 732e 6368 6469 7228 746d os.chdir(tm\n+00040e50: 7064 6972 290a 0a20 2020 2020 2020 2066 pdir).. f\n+00040e60: 6f72 206b 6579 2c20 7661 6c75 6520 696e or key, value in\n+00040e70: 205f 5f6c 6f61 6465 725f 5f2e 6765 745f __loader__.get_\n+00040e80: 636f 6e74 656e 7473 2829 2e69 7465 6d73 contents().items\n+00040e90: 2829 3a0a 2020 2020 2020 2020 2020 2020 ():. \n+00040ea0: 6966 206b 6579 2e73 7461 7274 7377 6974 if key.startswit\n+00040eb0: 6828 2774 6d70 6673 2f27 293a 0a20 2020 h('tmpfs/'):. \n+00040ec0: 2020 2020 2020 2020 2020 2020 2073 7562 sub\n+00040ed0: 6469 7220 3d20 6f73 2e70 6174 682e 6469 dir = os.path.di\n+00040ee0: 726e 616d 6528 6b65 7929 0a20 2020 2020 rname(key). \n+00040ef0: 2020 2020 2020 2020 2020 206f 732e 6d61 os.ma\n+00040f00: 6b65 6469 7273 2873 7562 6469 722c 2065 kedirs(subdir, e\n+00040f10: 7869 7374 5f6f 6b3d 5472 7565 290a 2020 xist_ok=True). \n+00040f20: 2020 2020 2020 2020 2020 2020 2020 7769 wi\n+00040f30: 7468 206f 7065 6e28 6b65 792c 2027 7762 th open(key, 'wb\n+00040f40: 2729 2061 7320 6670 3a0a 2020 2020 2020 ') as fp:. \n+00040f50: 2020 2020 2020 2020 2020 2020 2020 6670 fp\n+00040f60: 2e77 7269 7465 2876 616c 7565 290a 0a20 .write(value).. \n+00040f70: 2020 2020 2020 206f 732e 6368 6469 7228 os.chdir(\n+00040f80: 2774 6d70 6673 2729 0a0a 2020 2020 2020 'tmpfs').. \n+00040f90: 2020 7265 7375 6c74 203d 2073 7562 7072 result = subpr\n+00040fa0: 6f63 6573 732e 7275 6e28 636f 6d6d 616e ocess.run(comman\n+00040fb0: 642c 2063 6865 636b 3d46 616c 7365 290a d, check=False).\n+00040fc0: 2020 2020 2020 2020 7379 732e 6578 6974 sys.exit\n+00040fd0: 2872 6573 756c 742e 7265 7475 726e 636f (result.returnco\n+00040fe0: 6465 290a 2727 272c 0a20 2027 636f 636b de).''',. 'cock\n+00040ff0: 7069 742f 5f76 656e 646f 722f 6265 692f pit/_vendor/bei/\n+00041000: 6265 6970 6163 6b2e 7079 273a 2062 7227 beipack.py': br'\n+00041010: 2727 2320 6265 6970 6163 6b20 2d20 5265 ''# beipack - Re\n+00041020: 6d6f 7465 2062 6f6f 746c 6f61 6465 7220 mote bootloader \n+00041030: 666f 7220 5079 7468 6f6e 0a23 0a23 2043 for Python.#.# C\n+00041040: 6f70 7972 6967 6874 2028 4329 2032 3032 opyright (C) 202\n+00041050: 3220 416c 6c69 736f 6e20 4b61 726c 6974 2 Allison Karlit\n+00041060: 736b 6179 6120 3c61 6c6c 6973 6f6e 2e6b skaya <allison.k\n+00041070: 6172 6c69 7473 6b61 7961 4072 6564 6861 arlitskaya@redha\n+00041080: 742e 636f 6d3e 0a23 0a23 2054 6869 7320 t.com>.#.# This \n+00041090: 7072 6f67 7261 6d20 6973 2066 7265 6520 program is free \n+000410a0: 736f 6674 7761 7265 3a20 796f 7520 6361 software: you ca\n+000410b0: 6e20 7265 6469 7374 7269 6275 7465 2069 n redistribute i\n+000410c0: 7420 616e 642f 6f72 206d 6f64 6966 790a t and/or modify.\n+000410d0: 2320 6974 2075 6e64 6572 2074 6865 2074 # it under the t\n+000410e0: 6572 6d73 206f 6620 7468 6520 474e 5520 erms of the GNU \n+000410f0: 4765 6e65 7261 6c20 5075 626c 6963 204c General Public L\n+00041100: 6963 656e 7365 2061 7320 7075 626c 6973 icense as publis\n+00041110: 6865 6420 6279 0a23 2074 6865 2046 7265 hed by.# the Fre\n+00041120: 6520 536f 6674 7761 7265 2046 6f75 6e64 e Software Found\n+00041130: 6174 696f 6e2c 2065 6974 6865 7220 7665 ation, either ve\n+00041140: 7273 696f 6e20 3320 6f66 2074 6865 204c rsion 3 of the L\n+00041150: 6963 656e 7365 2c20 6f72 0a23 2028 6174 icense, or.# (at\n+00041160: 2079 6f75 7220 6f70 7469 6f6e 2920 616e your option) an\n+00041170: 7920 6c61 7465 7220 7665 7273 696f 6e2e y later version.\n+00041180: 0a23 0a23 2054 6869 7320 7072 6f67 7261 .#.# This progra\n+00041190: 6d20 6973 2064 6973 7472 6962 7574 6564 m is distributed\n+000411a0: 2069 6e20 7468 6520 686f 7065 2074 6861 in the hope tha\n+000411b0: 7420 6974 2077 696c 6c20 6265 2075 7365 t it will be use\n+000411c0: 6675 6c2c 0a23 2062 7574 2057 4954 484f ful,.# but WITHO\n+000411d0: 5554 2041 4e59 2057 4152 5241 4e54 593b UT ANY WARRANTY;\n+000411e0: 2077 6974 686f 7574 2065 7665 6e20 7468 without even th\n+000411f0: 6520 696d 706c 6965 6420 7761 7272 616e e implied warran\n+00041200: 7479 206f 660a 2320 4d45 5243 4841 4e54 ty of.# MERCHANT\n+00041210: 4142 494c 4954 5920 6f72 2046 4954 4e45 ABILITY or FITNE\n+00041220: 5353 2046 4f52 2041 2050 4152 5449 4355 SS FOR A PARTICU\n+00041230: 4c41 5220 5055 5250 4f53 452e 2020 5365 LAR PURPOSE. Se\n+00041240: 6520 7468 650a 2320 474e 5520 4765 6e65 e the.# GNU Gene\n+00041250: 7261 6c20 5075 626c 6963 204c 6963 656e ral Public Licen\n+00041260: 7365 2066 6f72 206d 6f72 6520 6465 7461 se for more deta\n+00041270: 696c 732e 0a23 0a23 2059 6f75 2073 686f ils..#.# You sho\n+00041280: 756c 6420 6861 7665 2072 6563 6569 7665 uld have receive\n+00041290: 6420 6120 636f 7079 206f 6620 7468 6520 d a copy of the \n+000412a0: 474e 5520 4765 6e65 7261 6c20 5075 626c GNU General Publ\n+000412b0: 6963 204c 6963 656e 7365 0a23 2061 6c6f ic License.# alo\n+000412c0: 6e67 2077 6974 6820 7468 6973 2070 726f ng with this pro\n+000412d0: 6772 616d 2e20 2049 6620 6e6f 742c 2073 gram. If not, s\n+000412e0: 6565 203c 6874 7470 3a2f 2f77 7777 2e67 ee <http://www.g\n+000412f0: 6e75 2e6f 7267 2f6c 6963 656e 7365 732f nu.org/licenses/\n+00041300: 3e2e 0a0a 696d 706f 7274 2061 7267 7061 >...import argpa\n+00041310: 7273 650a 696d 706f 7274 2062 696e 6173 rse.import binas\n+00041320: 6369 690a 696d 706f 7274 206c 7a6d 610a cii.import lzma.\n+00041330: 696d 706f 7274 206f 730a 696d 706f 7274 import os.import\n+00041340: 2073 7973 0a69 6d70 6f72 7420 7465 6d70 sys.import temp\n+00041350: 6669 6c65 0a69 6d70 6f72 7420 7a69 7066 file.import zipf\n+00041360: 696c 650a 6672 6f6d 2074 7970 696e 6720 ile.from typing \n+00041370: 696d 706f 7274 2044 6963 742c 2049 7465 import Dict, Ite\n+00041380: 7261 626c 652c 204c 6973 742c 204f 7074 rable, List, Opt\n+00041390: 696f 6e61 6c2c 2053 6574 2c20 5475 706c ional, Set, Tupl\n+000413a0: 650a 0a66 726f 6d20 2e64 6174 6120 696d e..from .data im\n+000413b0: 706f 7274 2072 6561 645f 6461 7461 5f66 port read_data_f\n+000413c0: 696c 650a 0a0a 6465 6620 6573 6361 7065 ile...def escape\n+000413d0: 5f73 7472 696e 6728 6461 7461 3a20 7374 _string(data: st\n+000413e0: 7229 202d 3e20 7374 723a 0a20 2020 2023 r) -> str:. #\n+000413f0: 2041 766f 6964 206d 656e 7469 6f6e 696e Avoid mentionin\n+00041400: 6720 2720 2720 2720 6c69 7465 7261 6c6c g ' ' ' literall\n+00041410: 792c 2074 6f20 6d61 6b65 206f 7572 206f y, to make our o\n+00041420: 776e 2070 6163 6b69 6e67 2061 2062 6974 wn packing a bit\n+00041430: 2070 7265 7474 6965 720a 2020 2020 7472 prettier. tr\n+00041440: 6970 6c65 7175 6f74 6520 3d20 2227 2220 iplequote = \"'\" \n+00041450: 2a20 330a 2020 2020 6966 2074 7269 706c * 3. if tripl\n+00041460: 6571 756f 7465 206e 6f74 2069 6e20 6461 equote not in da\n+00041470: 7461 3a0a 2020 2020 2020 2020 7265 7475 ta:. retu\n+00041480: 726e 2022 7222 202b 2074 7269 706c 6571 rn \"r\" + tripleq\n+00041490: 756f 7465 202b 2064 6174 6120 2b20 7472 uote + data + tr\n+000414a0: 6970 6c65 7175 6f74 650a 2020 2020 6966 iplequote. if\n+000414b0: 2027 2222 2227 206e 6f74 2069 6e20 6461 '\"\"\"' not in da\n+000414c0: 7461 3a0a 2020 2020 2020 2020 7265 7475 ta:. retu\n+000414d0: 726e 2027 7222 2222 2720 2b20 6461 7461 rn 'r\"\"\"' + data\n+000414e0: 202b 2027 2222 2227 0a20 2020 2072 6574 + '\"\"\"'. ret\n+000414f0: 7572 6e20 7265 7072 2864 6174 6129 0a0a urn repr(data)..\n+00041500: 0a64 6566 2061 7363 6969 5f62 7974 6573 .def ascii_bytes\n+00041510: 5f72 6570 7228 6461 7461 3a20 6279 7465 _repr(data: byte\n+00041520: 7329 202d 3e20 7374 723a 0a20 2020 2072 s) -> str:. r\n+00041530: 6574 7572 6e20 2762 2720 2b20 6573 6361 eturn 'b' + esca\n+00041540: 7065 5f73 7472 696e 6728 6461 7461 2e64 pe_string(data.d\n+00041550: 6563 6f64 6528 2761 7363 6969 2729 290a ecode('ascii')).\n+00041560: 0a0a 6465 6620 7574 6638 5f62 7974 6573 ..def utf8_bytes\n+00041570: 5f72 6570 7228 6461 7461 3a20 6279 7465 _repr(data: byte\n+00041580: 7329 202d 3e20 7374 723a 0a20 2020 2072 s) -> str:. r\n+00041590: 6574 7572 6e20 6573 6361 7065 5f73 7472 eturn escape_str\n+000415a0: 696e 6728 6461 7461 2e64 6563 6f64 6528 ing(data.decode(\n+000415b0: 2775 7466 2d38 2729 2920 2b20 222e 656e 'utf-8')) + \".en\n+000415c0: 636f 6465 2827 7574 662d 3827 2922 0a0a code('utf-8')\"..\n+000415d0: 0a64 6566 2062 6173 6536 345f 6279 7465 .def base64_byte\n+000415e0: 735f 7265 7072 2864 6174 613a 2062 7974 s_repr(data: byt\n+000415f0: 6573 2c20 696d 706f 7274 733a 2053 6574 es, imports: Set\n+00041600: 5b73 7472 5d29 202d 3e20 7374 723a 0a20 [str]) -> str:. \n+00041610: 2020 2023 2062 6173 6538 3520 6973 2073 # base85 is s\n+00041620: 6d61 6c6c 6572 2c20 6275 7420 6261 7365 maller, but base\n+00041630: 3634 2069 7320 696e 2043 2c20 616e 6420 64 is in C, and \n+00041640: 7e32 3078 2066 6173 7465 722e 0a20 2020 ~20x faster.. \n+00041650: 2023 2077 6865 6e20 636f 6d70 7265 7373 # when compress\n+00041660: 696e 6720 7769 7468 2060 787a 202d 6560 ing with `xz -e`\n+00041670: 2074 6865 2073 697a 6520 6469 6666 6572 the size differ\n+00041680: 656e 6365 2069 7320 6d61 7267 696e 616c ence is marginal\n+00041690: 2e0a 2020 2020 696d 706f 7274 732e 6164 .. imports.ad\n+000416a0: 6428 2766 726f 6d20 6269 6e61 7363 6969 d('from binascii\n+000416b0: 2069 6d70 6f72 7420 6132 625f 6261 7365 import a2b_base\n+000416c0: 3634 2729 0a20 2020 2065 6e63 6f64 6564 64'). encoded\n+000416d0: 203d 2062 696e 6173 6369 692e 6232 615f = binascii.b2a_\n+000416e0: 6261 7365 3634 2864 6174 6129 2e64 6563 base64(data).dec\n+000416f0: 6f64 6528 2761 7363 6969 2729 2e73 7472 ode('ascii').str\n+00041700: 6970 2829 0a20 2020 2072 6574 7572 6e20 ip(). return \n+00041710: 6627 6132 625f 6261 7365 3634 2822 7b65 f'a2b_base64(\"{e\n+00041720: 6e63 6f64 6564 7d22 2927 0a0a 0a64 6566 ncoded}\")'...def\n+00041730: 2062 7974 6573 5f72 6570 7228 6461 7461 bytes_repr(data\n+00041740: 3a20 6279 7465 732c 2069 6d70 6f72 7473 : bytes, imports\n+00041750: 3a20 5365 745b 7374 725d 2920 2d3e 2073 : Set[str]) -> s\n+00041760: 7472 3a0a 2020 2020 2320 5374 7261 7465 tr:. # Strate\n+00041770: 6779 3a0a 2020 2020 2320 2020 6966 2074 gy:. # if t\n+00041780: 6865 2066 696c 6520 6973 2061 7363 6969 he file is ascii\n+00041790: 2c20 656e 636f 6465 2069 7420 6469 7265 , encode it dire\n+000417a0: 6374 6c79 2061 7320 6279 7465 730a 2020 ctly as bytes. \n+000417b0: 2020 2320 2020 6f74 6865 7277 6973 652c # otherwise,\n+000417c0: 2069 6620 6974 2773 2055 5446 2d38 2c20 if it's UTF-8, \n+000417d0: 7573 6520 6120 756e 6963 6f64 6520 7374 use a unicode st\n+000417e0: 7269 6e67 2061 6e64 2065 6e63 6f64 650a ring and encode.\n+000417f0: 2020 2020 2320 2020 6f74 6865 7277 6973 # otherwis\n+00041800: 652c 2062 6173 6536 340a 0a20 2020 2074 e, base64.. t\n+00041810: 7279 3a0a 2020 2020 2020 2020 7265 7475 ry:. retu\n+00041820: 726e 2061 7363 6969 5f62 7974 6573 5f72 rn ascii_bytes_r\n+00041830: 6570 7228 6461 7461 290a 2020 2020 6578 epr(data). ex\n+00041840: 6365 7074 2055 6e69 636f 6465 4465 636f cept UnicodeDeco\n+00041850: 6465 4572 726f 723a 0a20 2020 2020 2020 deError:. \n+00041860: 2023 2069 7427 7320 6e6f 7420 6173 6369 # it's not asci\n+00041870: 690a 2020 2020 2020 2020 7061 7373 0a0a i. pass..\n+00041880: 2020 2020 2320 7574 662d 380a 2020 2020 # utf-8. \n+00041890: 7472 793a 0a20 2020 2020 2020 2072 6574 try:. ret\n+000418a0: 7572 6e20 7574 6638 5f62 7974 6573 5f72 urn utf8_bytes_r\n+000418b0: 6570 7228 6461 7461 290a 2020 2020 6578 epr(data). ex\n+000418c0: 6365 7074 2055 6e69 636f 6465 4465 636f cept UnicodeDeco\n+000418d0: 6465 4572 726f 723a 0a20 2020 2020 2020 deError:. \n+000418e0: 2023 2069 7427 7320 6e6f 7420 7574 662d # it's not utf-\n+000418f0: 380a 2020 2020 2020 2020 7061 7373 0a0a 8. pass..\n+00041900: 2020 2020 7265 7475 726e 2062 6173 6536 return base6\n+00041910: 345f 6279 7465 735f 7265 7072 2864 6174 4_bytes_repr(dat\n+00041920: 612c 2069 6d70 6f72 7473 290a 0a0a 6465 a, imports)...de\n+00041930: 6620 6469 6374 5f72 6570 7228 636f 6e74 f dict_repr(cont\n+00041940: 656e 7473 3a20 4469 6374 5b73 7472 2c20 ents: Dict[str, \n+00041950: 6279 7465 735d 2c20 696d 706f 7274 733a bytes], imports:\n+00041960: 2053 6574 5b73 7472 5d29 202d 3e20 7374 Set[str]) -> st\n+00041970: 723a 0a20 2020 2072 6574 7572 6e20 2827 r:. return ('\n+00041980: 7b5c 6e27 202b 0a20 2020 2020 2020 2020 {\\n' +. \n+00041990: 2020 2027 272e 6a6f 696e 2866 2720 207b ''.join(f' {\n+000419a0: 7265 7072 286b 297d 3a20 7b62 7974 6573 repr(k)}: {bytes\n+000419b0: 5f72 6570 7228 762c 2069 6d70 6f72 7473 _repr(v, imports\n+000419c0: 297d 2c5c 6e27 0a20 2020 2020 2020 2020 )},\\n'. \n+000419d0: 2020 2020 2020 2020 2020 2066 6f72 206b for k\n+000419e0: 2c20 7620 696e 2063 6f6e 7465 6e74 732e , v in contents.\n+000419f0: 6974 656d 7328 2929 202b 0a20 2020 2020 items()) +. \n+00041a00: 2020 2020 2020 2027 7d27 290a 0a0a 6465 '}')...de\n+00041a10: 6620 7061 636b 2863 6f6e 7465 6e74 733a f pack(contents:\n+00041a20: 2044 6963 745b 7374 722c 2062 7974 6573 Dict[str, bytes\n+00041a30: 5d2c 0a20 2020 2020 2020 2020 656e 7472 ],. entr\n+00041a40: 7970 6f69 6e74 3a20 4f70 7469 6f6e 616c ypoint: Optional\n+00041a50: 5b73 7472 5d20 3d20 4e6f 6e65 2c0a 2020 [str] = None,. \n+00041a60: 2020 2020 2020 2061 7267 733a 2073 7472 args: str\n+00041a70: 203d 2027 2729 202d 3e20 7374 723a 0a20 = '') -> str:. \n+00041a80: 2020 2022 2222 4372 6561 7465 7320 6120 \"\"\"Creates a \n+00041a90: 6265 6970 6163 6b20 7769 7468 2074 6865 beipack with the\n+00041aa0: 2067 6976 656e 2060 636f 6e74 656e 7473 given `contents\n+00041ab0: 602e 0a0a 2020 2020 4966 2060 656e 7472 `... If `entr\n+00041ac0: 7970 6f69 6e74 6020 6973 2067 6976 656e ypoint` is given\n+00041ad0: 2c20 6974 2073 686f 756c 6420 6265 2061 , it should be a\n+00041ae0: 6e20 656e 7472 7920 706f 696e 7420 7768 n entry point wh\n+00041af0: 6963 6820 6973 2072 756e 2061 7320 7468 ich is run as th\n+00041b00: 650a 2020 2020 226d 6169 6e22 2066 756e e. \"main\" fun\n+00041b10: 6374 696f 6e2e 2020 4974 2069 7320 6769 ction. It is gi\n+00041b20: 7665 6e20 696e 2074 6865 2060 7061 636b ven in the `pack\n+00041b30: 6167 652e 6d6f 6475 6c65 3a66 756e 6320 age.module:func \n+00041b40: 666f 726d 6174 6020 7375 6368 2074 6861 format` such tha\n+00041b50: 740a 2020 2020 7468 6520 666f 6c6c 6f77 t. the follow\n+00041b60: 696e 6720 636f 6465 2069 7320 656d 6974 ing code is emit\n+00041b70: 7465 643a 0a0a 2020 2020 2020 2020 6672 ted:.. fr\n+00041b80: 6f6d 2070 6163 6b61 6765 2e6d 6f64 756c om package.modul\n+00041b90: 6520 696d 706f 7274 2066 756e 6320 6173 e import func as\n+00041ba0: 206d 6169 6e0a 2020 2020 2020 2020 6d61 main. ma\n+00041bb0: 696e 2829 0a0a 2020 2020 4164 6469 7469 in().. Additi\n+00041bc0: 6f6e 616c 6c79 2c20 6966 2060 6172 6773 onally, if `args\n+00041bd0: 6020 6973 2067 6976 656e 2c20 6974 2069 ` is given, it i\n+00041be0: 7320 7772 6974 7465 6e20 7665 7262 6174 s written verbat\n+00041bf0: 696d 2062 6574 7765 656e 2074 6865 2070 im between the p\n+00041c00: 6172 656e 730a 2020 2020 6f66 2074 6865 arens. of the\n+00041c10: 2063 616c 6c20 746f 206d 6169 6e20 2869 call to main (i\n+00041c20: 653a 2069 7420 7368 6f75 6c64 2061 6c72 e: it should alr\n+00041c30: 6561 6479 2062 6520 696e 2050 7974 686f eady be in Pytho\n+00041c40: 6e20 7379 6e74 6178 292e 0a20 2020 2022 n syntax).. \"\n+00041c50: 2222 0a0a 2020 2020 6c6f 6164 6572 203d \"\".. loader =\n+00041c60: 2072 6561 645f 6461 7461 5f66 696c 6528 read_data_file(\n+00041c70: 2762 6569 7061 636b 5f6c 6f61 6465 722e 'beipack_loader.\n+00041c80: 7079 2729 0a20 2020 206c 696e 6573 203d py'). lines =\n+00041c90: 205b 6c69 6e65 2066 6f72 206c 696e 6520 [line for line \n+00041ca0: 696e 206c 6f61 6465 722e 7370 6c69 746c in loader.splitl\n+00041cb0: 696e 6573 2829 2069 6620 6c69 6e65 5d0a ines() if line].\n+00041cc0: 2020 2020 6c69 6e65 732e 6170 7065 6e64 lines.append\n+00041cd0: 2827 2729 0a0a 2020 2020 696d 706f 7274 ('').. import\n+00041ce0: 7320 3d20 7b27 696d 706f 7274 2073 7973 s = {'import sys\n+00041cf0: 277d 0a20 2020 2063 6f6e 7465 6e74 735f '}. contents_\n+00041d00: 7478 7420 3d20 6469 6374 5f72 6570 7228 txt = dict_repr(\n+00041d10: 636f 6e74 656e 7473 2c20 696d 706f 7274 contents, import\n+00041d20: 7329 0a20 2020 206c 696e 6573 2e65 7874 s). lines.ext\n+00041d30: 656e 6428 696d 706f 7274 7329 0a20 2020 end(imports). \n+00041d40: 206c 696e 6573 2e61 7070 656e 6428 6627 lines.append(f'\n+00041d50: 7379 732e 6d65 7461 5f70 6174 682e 696e sys.meta_path.in\n+00041d60: 7365 7274 2830 2c20 4265 6970 6163 6b4c sert(0, BeipackL\n+00041d70: 6f61 6465 7228 7b63 6f6e 7465 6e74 735f oader({contents_\n+00041d80: 7478 747d 2929 2729 0a0a 2020 2020 6966 txt}))').. if\n+00041d90: 2065 6e74 7279 706f 696e 743a 0a20 2020 entrypoint:. \n+00041da0: 2020 2020 2070 6163 6b61 6765 2c20 6d61 package, ma\n+00041db0: 696e 203d 2065 6e74 7279 706f 696e 742e in = entrypoint.\n+00041dc0: 7370 6c69 7428 273a 2729 0a20 2020 2020 split(':'). \n+00041dd0: 2020 206c 696e 6573 2e61 7070 656e 6428 lines.append(\n+00041de0: 6627 6672 6f6d 207b 7061 636b 6167 657d f'from {package}\n+00041df0: 2069 6d70 6f72 7420 7b6d 6169 6e7d 2061 import {main} a\n+00041e00: 7320 6d61 696e 2729 0a20 2020 2020 2020 s main'). \n+00041e10: 206c 696e 6573 2e61 7070 656e 6428 6627 lines.append(f'\n+00041e20: 6d61 696e 287b 6172 6773 7d29 2729 0a0a main({args})')..\n+00041e30: 2020 2020 7265 7475 726e 2027 272e 6a6f return ''.jo\n+00041e40: 696e 2866 277b 6c69 6e65 7d5c 6e27 2066 in(f'{line}\\n' f\n+00041e50: 6f72 206c 696e 6520 696e 206c 696e 6573 or line in lines\n+00041e60: 290a 0a0a 6465 6620 636f 6c6c 6563 745f )...def collect_\n+00041e70: 636f 6e74 656e 7473 2866 696c 656e 616d contents(filenam\n+00041e80: 6573 3a20 4c69 7374 5b73 7472 5d2c 0a20 es: List[str],. \n+00041e90: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00041ea0: 2020 2020 7265 6c61 7469 7665 5f74 6f3a relative_to:\n+00041eb0: 204f 7074 696f 6e61 6c5b 7374 725d 203d Optional[str] =\n+00041ec0: 204e 6f6e 6529 202d 3e20 4469 6374 5b73 None) -> Dict[s\n+00041ed0: 7472 2c20 6279 7465 735d 3a0a 2020 2020 tr, bytes]:. \n+00041ee0: 636f 6e74 656e 7473 3a20 4469 6374 5b73 contents: Dict[s\n+00041ef0: 7472 2c20 6279 7465 735d 203d 207b 7d0a tr, bytes] = {}.\n+00041f00: 0a20 2020 2066 6f72 2066 696c 656e 616d . for filenam\n+00041f10: 6520 696e 2066 696c 656e 616d 6573 3a0a e in filenames:.\n+00041f20: 2020 2020 2020 2020 7769 7468 206f 7065 with ope\n+00041f30: 6e28 6669 6c65 6e61 6d65 2c20 2772 6227 n(filename, 'rb'\n+00041f40: 2920 6173 2066 696c 653a 0a20 2020 2020 ) as file:. \n+00041f50: 2020 2020 2020 2063 6f6e 7465 6e74 735b contents[\n+00041f60: 6f73 2e70 6174 682e 7265 6c70 6174 6828 os.path.relpath(\n+00041f70: 6669 6c65 6e61 6d65 2c20 7374 6172 743d filename, start=\n+00041f80: 7265 6c61 7469 7665 5f74 6f29 5d20 3d20 relative_to)] = \n+00041f90: 6669 6c65 2e72 6561 6428 290a 0a20 2020 file.read().. \n+00041fa0: 2072 6574 7572 6e20 636f 6e74 656e 7473 return contents\n+00041fb0: 0a0a 0a64 6566 2063 6f6c 6c65 6374 5f6d ...def collect_m\n+00041fc0: 6f64 756c 6528 6e61 6d65 3a20 7374 722c odule(name: str,\n+00041fd0: 202a 2c20 7265 6375 7273 6976 653a 2062 *, recursive: b\n+00041fe0: 6f6f 6c29 202d 3e20 4469 6374 5b73 7472 ool) -> Dict[str\n+00041ff0: 2c20 6279 7465 735d 3a0a 2020 2020 696d , bytes]:. im\n+00042000: 706f 7274 2069 6d70 6f72 746c 6962 2e72 port importlib.r\n+00042010: 6573 6f75 7263 6573 0a20 2020 2066 726f esources. fro\n+00042020: 6d20 696d 706f 7274 6c69 622e 7265 736f m importlib.reso\n+00042030: 7572 6365 732e 6162 6320 696d 706f 7274 urces.abc import\n+00042040: 2054 7261 7665 7273 6162 6c65 0a0a 2020 Traversable.. \n+00042050: 2020 6465 6620 7761 6c6b 2870 6174 683a def walk(path:\n+00042060: 2073 7472 2c20 656e 7472 793a 2054 7261 str, entry: Tra\n+00042070: 7665 7273 6162 6c65 2920 2d3e 2049 7465 versable) -> Ite\n+00042080: 7261 626c 655b 5475 706c 655b 7374 722c rable[Tuple[str,\n+00042090: 2062 7974 6573 5d5d 3a0a 2020 2020 2020 bytes]]:. \n+000420a0: 2020 666f 7220 6974 656d 2069 6e20 656e for item in en\n+000420b0: 7472 792e 6974 6572 6469 7228 293a 0a20 try.iterdir():. \n+000420c0: 2020 2020 2020 2020 2020 2069 7465 6d6e itemn\n+000420d0: 616d 6520 3d20 6627 7b70 6174 687d 2f7b ame = f'{path}/{\n+000420e0: 6974 656d 2e6e 616d 657d 270a 2020 2020 item.name}'. \n+000420f0: 2020 2020 2020 2020 6966 2069 7465 6d2e if item.\n+00042100: 6973 5f66 696c 6528 293a 0a20 2020 2020 is_file():. \n+00042110: 2020 2020 2020 2020 2020 2079 6965 6c64 yield\n+00042120: 2069 7465 6d6e 616d 652c 2069 7465 6d2e itemname, item.\n+00042130: 7265 6164 5f62 7974 6573 2829 0a20 2020 read_bytes(). \n+00042140: 2020 2020 2020 2020 2065 6c69 6620 7265 elif re\n+00042150: 6375 7273 6976 6520 616e 6420 6974 656d cursive and item\n+00042160: 2e6e 616d 6520 213d 2027 5f5f 7079 6361 .name != '__pyca\n+00042170: 6368 655f 5f27 3a0a 2020 2020 2020 2020 che__':. \n+00042180: 2020 2020 2020 2020 7969 656c 6420 6672 yield fr\n+00042190: 6f6d 2077 616c 6b28 6974 656d 6e61 6d65 om walk(itemname\n+000421a0: 2c20 6974 656d 290a 0a20 2020 2072 6574 , item).. ret\n+000421b0: 7572 6e20 6469 6374 2877 616c 6b28 6e61 urn dict(walk(na\n+000421c0: 6d65 2e72 6570 6c61 6365 2827 2e27 2c20 me.replace('.', \n+000421d0: 272f 2729 2c20 696d 706f 7274 6c69 622e '/'), importlib.\n+000421e0: 7265 736f 7572 6365 732e 6669 6c65 7328 resources.files(\n+000421f0: 6e61 6d65 2929 290a 0a0a 6465 6620 636f name)))...def co\n+00042200: 6c6c 6563 745f 7a69 7028 6669 6c65 6e61 llect_zip(filena\n+00042210: 6d65 3a20 7374 7229 202d 3e20 4469 6374 me: str) -> Dict\n+00042220: 5b73 7472 2c20 6279 7465 735d 3a0a 2020 [str, bytes]:. \n+00042230: 2020 636f 6e74 656e 7473 203d 207b 7d0a contents = {}.\n+00042240: 0a20 2020 2077 6974 6820 7a69 7066 696c . with zipfil\n+00042250: 652e 5a69 7046 696c 6528 6669 6c65 6e61 e.ZipFile(filena\n+00042260: 6d65 2920 6173 2066 696c 653a 0a20 2020 me) as file:. \n+00042270: 2020 2020 2066 6f72 2065 6e74 7279 2069 for entry i\n+00042280: 6e20 6669 6c65 2e66 696c 656c 6973 743a n file.filelist:\n+00042290: 0a20 2020 2020 2020 2020 2020 2069 6620 . if \n+000422a0: 272e 6469 7374 2d69 6e66 6f2f 2720 696e '.dist-info/' in\n+000422b0: 2065 6e74 7279 2e66 696c 656e 616d 653a entry.filename:\n+000422c0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+000422d0: 2063 6f6e 7469 6e75 650a 2020 2020 2020 continue. \n+000422e0: 2020 2020 2020 636f 6e74 656e 7473 5b65 contents[e\n+000422f0: 6e74 7279 2e66 696c 656e 616d 655d 203d ntry.filename] =\n+00042300: 2066 696c 652e 7265 6164 2865 6e74 7279 file.read(entry\n+00042310: 290a 0a20 2020 2072 6574 7572 6e20 636f ).. return co\n+00042320: 6e74 656e 7473 0a0a 0a64 6566 2063 6f6c ntents...def col\n+00042330: 6c65 6374 5f70 6570 3531 3728 7061 7468 lect_pep517(path\n+00042340: 3a20 7374 7229 202d 3e20 4469 6374 5b73 : str) -> Dict[s\n+00042350: 7472 2c20 6279 7465 735d 3a0a 2020 2020 tr, bytes]:. \n+00042360: 7769 7468 2074 656d 7066 696c 652e 5465 with tempfile.Te\n+00042370: 6d70 6f72 6172 7944 6972 6563 746f 7279 mporaryDirectory\n+00042380: 2829 2061 7320 746d 7064 6972 3a0a 2020 () as tmpdir:. \n+00042390: 2020 2020 2020 696d 706f 7274 2062 7569 import bui\n+000423a0: 6c64 0a20 2020 2020 2020 2062 7569 6c64 ld. build\n+000423b0: 6572 203d 2062 7569 6c64 2e50 726f 6a65 er = build.Proje\n+000423c0: 6374 4275 696c 6465 7228 7061 7468 290a ctBuilder(path).\n+000423d0: 2020 2020 2020 2020 7768 6565 6c20 3d20 wheel = \n+000423e0: 6275 696c 6465 722e 6275 696c 6428 2777 builder.build('w\n+000423f0: 6865 656c 272c 2074 6d70 6469 7229 0a20 heel', tmpdir). \n+00042400: 2020 2020 2020 2072 6574 7572 6e20 636f return co\n+00042410: 6c6c 6563 745f 7a69 7028 7768 6565 6c29 llect_zip(wheel)\n+00042420: 0a0a 0a64 6566 206d 6169 6e28 2920 2d3e ...def main() ->\n+00042430: 204e 6f6e 653a 0a20 2020 2070 6172 7365 None:. parse\n+00042440: 7220 3d20 6172 6770 6172 7365 2e41 7267 r = argparse.Arg\n+00042450: 756d 656e 7450 6172 7365 7228 290a 2020 umentParser(). \n+00042460: 2020 7061 7273 6572 2e61 6464 5f61 7267 parser.add_arg\n+00042470: 756d 656e 7428 272d 2d70 7974 686f 6e27 ument('--python'\n+00042480: 2c20 272d 7027 2c0a 2020 2020 2020 2020 , '-p',. \n+00042490: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000424a0: 6865 6c70 3d22 6164 6420 6120 2321 7079 help=\"add a #!py\n+000424b0: 7468 6f6e 3320 696e 7465 7270 7265 7465 thon3 interprete\n+000424c0: 7220 6c69 6e65 2075 7369 6e67 2074 6865 r line using the\n+000424d0: 2067 6976 656e 2070 6174 6822 290a 2020 given path\"). \n+000424e0: 2020 7061 7273 6572 2e61 6464 5f61 7267 parser.add_arg\n+000424f0: 756d 656e 7428 272d 2d78 7a27 2c20 272d ument('--xz', '-\n+00042500: 4a27 2c20 6163 7469 6f6e 3d27 7374 6f72 J', action='stor\n+00042510: 655f 7472 7565 272c 0a20 2020 2020 2020 e_true',. \n+00042520: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00042530: 2068 656c 703d 2263 6f6d 7072 6573 7320 help=\"compress \n+00042540: 7468 6520 6f75 7470 7574 2077 6974 6820 the output with \n+00042550: 6078 7a60 2229 0a20 2020 2070 6172 7365 `xz`\"). parse\n+00042560: 722e 6164 645f 6172 6775 6d65 6e74 2827 r.add_argument('\n+00042570: 2d2d 746f 7064 6972 272c 0a20 2020 2020 --topdir',. \n+00042580: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00042590: 2020 2068 656c 703d 2274 6f70 6c65 7665 help=\"topleve\n+000425a0: 6c20 6469 7265 6374 6f72 7920 2870 6174 l directory (pat\n+000425b0: 6873 2061 7265 2073 746f 7265 6420 7265 hs are stored re\n+000425c0: 6c61 7469 7665 2074 6f20 7468 6973 2922 lative to this)\"\n+000425d0: 290a 2020 2020 7061 7273 6572 2e61 6464 ). parser.add\n+000425e0: 5f61 7267 756d 656e 7428 272d 2d6f 7574 _argument('--out\n+000425f0: 7075 7427 2c20 272d 6f27 2c0a 2020 2020 put', '-o',. \n+00042600: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00042610: 2020 2020 6865 6c70 3d22 7772 6974 6520 help=\"write \n+00042620: 6f75 7470 7574 2074 6f20 6120 6669 6c65 output to a file\n+00042630: 2028 6465 6661 756c 743a 2073 7464 6f75 (default: stdou\n+00042640: 7429 2229 0a20 2020 2070 6172 7365 722e t)\"). parser.\n+00042650: 6164 645f 6172 6775 6d65 6e74 2827 2d2d add_argument('--\n+00042660: 6d61 696e 272c 2027 2d6d 272c 206d 6574 main', '-m', met\n+00042670: 6176 6172 3d27 4d4f 4455 4c45 3a46 554e avar='MODULE:FUN\n+00042680: 4327 2c0a 2020 2020 2020 2020 2020 2020 C',. \n+00042690: 2020 2020 2020 2020 2020 2020 6865 6c70 help\n+000426a0: 3d22 7573 6520 4655 4e43 2066 726f 6d20 =\"use FUNC from \n+000426b0: 4d4f 4455 4c45 2061 7320 7468 6520 6d61 MODULE as the ma\n+000426c0: 696e 2066 756e 6374 696f 6e22 290a 2020 in function\"). \n+000426d0: 2020 7061 7273 6572 2e61 6464 5f61 7267 parser.add_arg\n+000426e0: 756d 656e 7428 272d 2d6d 6169 6e2d 6172 ument('--main-ar\n+000426f0: 6773 272c 206d 6574 6176 6172 3d27 4152 gs', metavar='AR\n+00042700: 4753 272c 0a20 2020 2020 2020 2020 2020 GS',. \n+00042710: 2020 2020 2020 2020 2020 2020 2068 656c hel\n+00042720: 703d 2261 7267 756d 656e 7473 2074 6f20 p=\"arguments to \n+00042730: 6d61 696e 2829 2069 6e20 5079 7468 6f6e main() in Python\n+00042740: 2073 796e 7461 7822 2c20 6465 6661 756c syntax\", defaul\n+00042750: 743d 2727 290a 2020 2020 7061 7273 6572 t=''). parser\n+00042760: 2e61 6464 5f61 7267 756d 656e 7428 272d .add_argument('-\n+00042770: 2d6d 6f64 756c 6527 2c20 6163 7469 6f6e -module', action\n+00042780: 3d27 6170 7065 6e64 272c 2064 6566 6175 ='append', defau\n+00042790: 6c74 3d5b 5d2c 0a20 2020 2020 2020 2020 lt=[],. \n+000427a0: 2020 2020 2020 2020 2020 2020 2020 2068 h\n+000427b0: 656c 703d 2263 6f6c 6c65 6374 2069 6e73 elp=\"collect ins\n+000427c0: 7461 6c6c 6564 206d 6f64 756c 6573 2028 talled modules (\n+000427d0: 7265 6375 7273 6976 656c 7929 2229 0a20 recursively)\"). \n+000427e0: 2020 2070 6172 7365 722e 6164 645f 6172 parser.add_ar\n+000427f0: 6775 6d65 6e74 2827 2d2d 7a69 7027 2c20 gument('--zip', \n+00042800: 272d 7a27 2c20 6163 7469 6f6e 3d27 6170 '-z', action='ap\n+00042810: 7065 6e64 272c 2064 6566 6175 6c74 3d5b pend', default=[\n+00042820: 5d2c 0a20 2020 2020 2020 2020 2020 2020 ],. \n+00042830: 2020 2020 2020 2020 2020 2068 656c 703d help=\n+00042840: 2269 6e63 6c75 6465 2066 696c 6573 2066 \"include files f\n+00042850: 726f 6d20 6120 7a69 7066 696c 6520 286f rom a zipfile (o\n+00042860: 7220 7768 6565 6c29 2229 0a20 2020 2070 r wheel)\"). p\n+00042870: 6172 7365 722e 6164 645f 6172 6775 6d65 arser.add_argume\n+00042880: 6e74 2827 2d2d 6275 696c 6427 2c20 6d65 nt('--build', me\n+00042890: 7461 7661 723d 2744 4952 272c 2061 6374 tavar='DIR', act\n+000428a0: 696f 6e3d 2761 7070 656e 6427 2c20 6465 ion='append', de\n+000428b0: 6661 756c 743d 5b5d 2c0a 2020 2020 2020 fault=[],. \n+000428c0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000428d0: 2020 6865 6c70 3d22 5045 502d 3531 3720 help=\"PEP-517 \n+000428e0: 6672 6f6d 2061 2067 6976 656e 2073 6f75 from a given sou\n+000428f0: 7263 6520 6469 7265 6374 6f72 7922 290a rce directory\").\n+00042900: 2020 2020 7061 7273 6572 2e61 6464 5f61 parser.add_a\n+00042910: 7267 756d 656e 7428 2766 696c 6573 272c rgument('files',\n+00042920: 206e 6172 6773 3d27 2a27 2c0a 2020 2020 nargs='*',. \n+00042930: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00042940: 2020 2020 6865 6c70 3d22 6669 6c65 7320 help=\"files \n+00042950: 746f 2069 6e63 6c75 6465 2069 6e20 7468 to include in th\n+00042960: 6520 6265 6970 6163 6b22 290a 2020 2020 e beipack\"). \n+00042970: 6172 6773 203d 2070 6172 7365 722e 7061 args = parser.pa\n+00042980: 7273 655f 6172 6773 2829 0a0a 2020 2020 rse_args().. \n+00042990: 636f 6e74 656e 7473 203d 2063 6f6c 6c65 contents = colle\n+000429a0: 6374 5f63 6f6e 7465 6e74 7328 6172 6773 ct_contents(args\n+000429b0: 2e66 696c 6573 2c20 7265 6c61 7469 7665 .files, relative\n+000429c0: 5f74 6f3d 6172 6773 2e74 6f70 6469 7229 _to=args.topdir)\n+000429d0: 0a0a 2020 2020 666f 7220 6669 6c65 2069 .. for file i\n+000429e0: 6e20 6172 6773 2e7a 6970 3a0a 2020 2020 n args.zip:. \n+000429f0: 2020 2020 636f 6e74 656e 7473 2e75 7064 contents.upd\n+00042a00: 6174 6528 636f 6c6c 6563 745f 7a69 7028 ate(collect_zip(\n+00042a10: 6669 6c65 2929 0a0a 2020 2020 666f 7220 file)).. for \n+00042a20: 6e61 6d65 2069 6e20 6172 6773 2e6d 6f64 name in args.mod\n+00042a30: 756c 653a 0a20 2020 2020 2020 2063 6f6e ule:. con\n+00042a40: 7465 6e74 732e 7570 6461 7465 2863 6f6c tents.update(col\n+00042a50: 6c65 6374 5f6d 6f64 756c 6528 6e61 6d65 lect_module(name\n+00042a60: 2c20 7265 6375 7273 6976 653d 5472 7565 , recursive=True\n+00042a70: 2929 0a0a 2020 2020 666f 7220 7061 7468 )).. for path\n+00042a80: 2069 6e20 6172 6773 2e62 7569 6c64 3a0a in args.build:.\n+00042a90: 2020 2020 2020 2020 636f 6e74 656e 7473 contents\n+00042aa0: 2e75 7064 6174 6528 636f 6c6c 6563 745f .update(collect_\n+00042ab0: 7065 7035 3137 2870 6174 6829 290a 0a20 pep517(path)).. \n+00042ac0: 2020 2072 6573 756c 7420 3d20 7061 636b result = pack\n+00042ad0: 2863 6f6e 7465 6e74 732c 2061 7267 732e (contents, args.\n+00042ae0: 6d61 696e 2c20 6172 6773 2e6d 6169 6e5f main, args.main_\n+00042af0: 6172 6773 292e 656e 636f 6465 2827 7574 args).encode('ut\n+00042b00: 662d 3827 290a 0a20 2020 2069 6620 6172 f-8').. if ar\n+00042b10: 6773 2e70 7974 686f 6e3a 0a20 2020 2020 gs.python:. \n+00042b20: 2020 2072 6573 756c 7420 3d20 6227 2321 result = b'#!\n+00042b30: 2720 2b20 6172 6773 2e70 7974 686f 6e2e ' + args.python.\n+00042b40: 656e 636f 6465 2827 6173 6369 6927 2920 encode('ascii') \n+00042b50: 2b20 6227 5c6e 2720 2b20 7265 7375 6c74 + b'\\n' + result\n+00042b60: 0a0a 2020 2020 6966 2061 7267 732e 787a .. if args.xz\n+00042b70: 3a0a 2020 2020 2020 2020 7265 7375 6c74 :. result\n+00042b80: 203d 206c 7a6d 612e 636f 6d70 7265 7373 = lzma.compress\n+00042b90: 2872 6573 756c 742c 2070 7265 7365 743d (result, preset=\n+00042ba0: 6c7a 6d61 2e50 5245 5345 545f 4558 5452 lzma.PRESET_EXTR\n+00042bb0: 454d 4529 0a0a 2020 2020 6966 2061 7267 EME).. if arg\n+00042bc0: 732e 6f75 7470 7574 3a0a 2020 2020 2020 s.output:. \n+00042bd0: 2020 7769 7468 206f 7065 6e28 6172 6773 with open(args\n+00042be0: 2e6f 7574 7075 742c 2027 7762 2729 2061 .output, 'wb') a\n+00042bf0: 7320 6669 6c65 3a0a 2020 2020 2020 2020 s file:. \n+00042c00: 2020 2020 6669 6c65 2e77 7269 7465 2872 file.write(r\n+00042c10: 6573 756c 7429 0a20 2020 2065 6c73 653a esult). else:\n+00042c20: 0a20 2020 2020 2020 2069 6620 6172 6773 . if args\n+00042c30: 2e78 7a20 616e 6420 6f73 2e69 7361 7474 .xz and os.isatt\n+00042c40: 7928 3129 3a0a 2020 2020 2020 2020 2020 y(1):. \n+00042c50: 2020 7379 732e 6578 6974 2827 7265 6675 sys.exit('refu\n+00042c60: 7369 6e67 2074 6f20 7772 6974 6520 636f sing to write co\n+00042c70: 6d70 7265 7373 6564 206f 7574 7075 7420 mpressed output \n+00042c80: 746f 2061 2074 6572 6d69 6e61 6c27 290a to a terminal').\n+00042c90: 2020 2020 2020 2020 7379 732e 7374 646f sys.stdo\n+00042ca0: 7574 2e62 7566 6665 722e 7772 6974 6528 ut.buffer.write(\n+00042cb0: 7265 7375 6c74 290a 0a0a 6966 205f 5f6e result)...if __n\n+00042cc0: 616d 655f 5f20 3d3d 2027 5f5f 6d61 696e ame__ == '__main\n+00042cd0: 5f5f 273a 0a20 2020 206d 6169 6e28 290a __':. main().\n+00042ce0: 2727 272c 0a20 2027 636f 636b 7069 742f ''',. 'cockpit/\n+00042cf0: 5f76 656e 646f 722f 6265 692f 6461 7461 _vendor/bei/data\n+00042d00: 2f5f 5f69 6e69 745f 5f2e 7079 273a 2062 /__init__.py': b\n+00042d10: 7227 2727 696d 706f 7274 2073 7973 0a0a r'''import sys..\n+00042d20: 6966 2073 7973 2e76 6572 7369 6f6e 5f69 if sys.version_i\n+00042d30: 6e66 6f20 3e3d 2028 332c 2039 293a 0a20 nfo >= (3, 9):. \n+00042d40: 2020 2069 6d70 6f72 7420 696d 706f 7274 import import\n+00042d50: 6c69 622e 6162 630a 2020 2020 696d 706f lib.abc. impo\n+00042d60: 7274 2069 6d70 6f72 746c 6962 2e72 6573 rt importlib.res\n+00042d70: 6f75 7263 6573 0a0a 2020 2020 6465 6620 ources.. def \n+00042d80: 7265 6164 5f64 6174 615f 6669 6c65 2866 read_data_file(f\n+00042d90: 696c 656e 616d 653a 2073 7472 2920 2d3e ilename: str) ->\n+00042da0: 2073 7472 3a0a 2020 2020 2020 2020 7265 str:. re\n+00042db0: 7475 726e 2028 696d 706f 7274 6c69 622e turn (importlib.\n+00042dc0: 7265 736f 7572 6365 732e 6669 6c65 7328 resources.files(\n+00042dd0: 5f5f 6e61 6d65 5f5f 2920 2f20 6669 6c65 __name__) / file\n+00042de0: 6e61 6d65 292e 7265 6164 5f74 6578 7428 name).read_text(\n+00042df0: 290a 656c 7365 3a0a 2020 2020 6465 6620 ).else:. def \n+00042e00: 7265 6164 5f64 6174 615f 6669 6c65 2866 read_data_file(f\n+00042e10: 696c 656e 616d 653a 2073 7472 2920 2d3e ilename: str) ->\n+00042e20: 2073 7472 3a0a 2020 2020 2020 2020 6c6f str:. lo\n+00042e30: 6164 6572 203d 205f 5f6c 6f61 6465 725f ader = __loader_\n+00042e40: 5f20 2023 2074 7970 653a 2069 676e 6f72 _ # type: ignor\n+00042e50: 655b 6e61 6d65 2d64 6566 696e 6564 5d0a e[name-defined].\n+00042e60: 2020 2020 2020 2020 6461 7461 203d 206c data = l\n+00042e70: 6f61 6465 722e 6765 745f 6461 7461 285f oader.get_data(_\n+00042e80: 5f66 696c 655f 5f2e 7265 706c 6163 6528 _file__.replace(\n+00042e90: 275f 5f69 6e69 745f 5f2e 7079 272c 2066 '__init__.py', f\n+00042ea0: 696c 656e 616d 6529 290a 2020 2020 2020 ilename)). \n+00042eb0: 2020 7265 7475 726e 2064 6174 612e 6465 return data.de\n+00042ec0: 636f 6465 2827 7574 662d 3827 290a 2727 code('utf-8').''\n+00042ed0: 272c 0a20 2027 636f 636b 7069 742f 5f76 ',. 'cockpit/_v\n+00042ee0: 656e 646f 722f 6265 692f 6461 7461 2f62 endor/bei/data/b\n+00042ef0: 6569 7061 636b 5f6c 6f61 6465 722e 7079 eipack_loader.py\n+00042f00: 273a 2062 7227 2727 2320 6265 6970 6163 ': br'''# beipac\n+00042f10: 6b20 6874 7470 733a 2f2f 6769 7468 7562 k https://github\n+00042f20: 2e63 6f6d 2f61 6c6c 6973 6f6e 6b61 726c .com/allisonkarl\n+00042f30: 6974 736b 6179 612f 6265 6970 6163 6b0a itskaya/beipack.\n+00042f40: 0a69 6d70 6f72 7420 696d 706f 7274 6c69 .import importli\n+00042f50: 622e 6162 630a 696d 706f 7274 2069 6d70 b.abc.import imp\n+00042f60: 6f72 746c 6962 2e75 7469 6c0a 696d 706f ortlib.util.impo\n+00042f70: 7274 2069 6f0a 696d 706f 7274 2073 7973 rt io.import sys\n+00042f80: 0a66 726f 6d20 7479 7065 7320 696d 706f .from types impo\n+00042f90: 7274 204d 6f64 756c 6554 7970 650a 6672 rt ModuleType.fr\n+00042fa0: 6f6d 2074 7970 696e 6720 696d 706f 7274 om typing import\n+00042fb0: 2042 696e 6172 7949 4f2c 2044 6963 742c BinaryIO, Dict,\n+00042fc0: 2049 7465 7261 746f 722c 204f 7074 696f Iterator, Optio\n+00042fd0: 6e61 6c2c 2053 6571 7565 6e63 650a 0a0a nal, Sequence...\n+00042fe0: 636c 6173 7320 4265 6970 6163 6b4c 6f61 class BeipackLoa\n+00042ff0: 6465 7228 696d 706f 7274 6c69 622e 6162 der(importlib.ab\n+00043000: 632e 536f 7572 6365 4c6f 6164 6572 2c20 c.SourceLoader, \n+00043010: 696d 706f 7274 6c69 622e 6162 632e 4d65 importlib.abc.Me\n+00043020: 7461 5061 7468 4669 6e64 6572 293a 0a20 taPathFinder):. \n+00043030: 2020 2069 6620 7379 732e 7665 7273 696f if sys.versio\n+00043040: 6e5f 696e 666f 203e 3d20 2833 2c20 3131 n_info >= (3, 11\n+00043050: 293a 0a20 2020 2020 2020 2066 726f 6d20 ):. from \n+00043060: 696d 706f 7274 6c69 622e 7265 736f 7572 importlib.resour\n+00043070: 6365 732e 6162 6320 696d 706f 7274 2052 ces.abc import R\n+00043080: 6573 6f75 7263 6552 6561 6465 7220 6173 esourceReader as\n+00043090: 2041 6273 7472 6163 7452 6573 6f75 7263 AbstractResourc\n+000430a0: 6552 6561 6465 720a 2020 2020 656c 7365 eReader. else\n+000430b0: 3a0a 2020 2020 2020 2020 4162 7374 7261 :. Abstra\n+000430c0: 6374 5265 736f 7572 6365 5265 6164 6572 ctResourceReader\n+000430d0: 203d 206f 626a 6563 740a 0a20 2020 2063 = object.. c\n+000430e0: 6c61 7373 2052 6573 6f75 7263 6552 6561 lass ResourceRea\n+000430f0: 6465 7228 4162 7374 7261 6374 5265 736f der(AbstractReso\n+00043100: 7572 6365 5265 6164 6572 293a 0a20 2020 urceReader):. \n+00043110: 2020 2020 2064 6566 205f 5f69 6e69 745f def __init_\n+00043120: 5f28 7365 6c66 2c20 636f 6e74 656e 7473 _(self, contents\n+00043130: 3a20 4469 6374 5b73 7472 2c20 6279 7465 : Dict[str, byte\n+00043140: 735d 2c20 6669 6c65 6e61 6d65 3a20 7374 s], filename: st\n+00043150: 7229 202d 3e20 4e6f 6e65 3a0a 2020 2020 r) -> None:. \n+00043160: 2020 2020 2020 2020 7365 6c66 2e5f 636f self._co\n+00043170: 6e74 656e 7473 203d 2063 6f6e 7465 6e74 ntents = content\n+00043180: 730a 2020 2020 2020 2020 2020 2020 7365 s. se\n+00043190: 6c66 2e5f 6469 7220 3d20 6627 7b66 696c lf._dir = f'{fil\n+000431a0: 656e 616d 657d 2f27 0a0a 2020 2020 2020 ename}/'.. \n+000431b0: 2020 6465 6620 6973 5f72 6573 6f75 7263 def is_resourc\n+000431c0: 6528 7365 6c66 2c20 7265 736f 7572 6365 e(self, resource\n+000431d0: 3a20 7374 7229 202d 3e20 626f 6f6c 3a0a : str) -> bool:.\n+000431e0: 2020 2020 2020 2020 2020 2020 7265 7475 retu\n+000431f0: 726e 2066 277b 7365 6c66 2e5f 6469 727d rn f'{self._dir}\n+00043200: 7b72 6573 6f75 7263 657d 2720 696e 2073 {resource}' in s\n+00043210: 656c 662e 5f63 6f6e 7465 6e74 730a 0a20 elf._contents.. \n+00043220: 2020 2020 2020 2064 6566 206f 7065 6e5f def open_\n+00043230: 7265 736f 7572 6365 2873 656c 662c 2072 resource(self, r\n+00043240: 6573 6f75 7263 653a 2073 7472 2920 2d3e esource: str) ->\n+00043250: 2042 696e 6172 7949 4f3a 0a20 2020 2020 BinaryIO:. \n+00043260: 2020 2020 2020 2072 6574 7572 6e20 696f return io\n+00043270: 2e42 7974 6573 494f 2873 656c 662e 5f63 .BytesIO(self._c\n+00043280: 6f6e 7465 6e74 735b 6627 7b73 656c 662e ontents[f'{self.\n+00043290: 5f64 6972 7d7b 7265 736f 7572 6365 7d27 _dir}{resource}'\n+000432a0: 5d29 0a0a 2020 2020 2020 2020 6465 6620 ]).. def \n+000432b0: 7265 736f 7572 6365 5f70 6174 6828 7365 resource_path(se\n+000432c0: 6c66 2c20 7265 736f 7572 6365 3a20 7374 lf, resource: st\n+000432d0: 7229 202d 3e20 7374 723a 0a20 2020 2020 r) -> str:. \n+000432e0: 2020 2020 2020 2072 6169 7365 2046 696c raise Fil\n+000432f0: 654e 6f74 466f 756e 6445 7272 6f72 0a0a eNotFoundError..\n+00043300: 2020 2020 2020 2020 6465 6620 636f 6e74 def cont\n+00043310: 656e 7473 2873 656c 6629 202d 3e20 4974 ents(self) -> It\n+00043320: 6572 6174 6f72 5b73 7472 5d3a 0a20 2020 erator[str]:. \n+00043330: 2020 2020 2020 2020 2064 6972 5f6c 656e dir_len\n+00043340: 6774 6820 3d20 6c65 6e28 7365 6c66 2e5f gth = len(self._\n+00043350: 6469 7229 0a20 2020 2020 2020 2020 2020 dir). \n+00043360: 2072 6573 756c 7420 3d20 7365 7428 290a result = set().\n+00043370: 0a20 2020 2020 2020 2020 2020 2066 6f72 . for\n+00043380: 2066 696c 656e 616d 6520 696e 2073 656c filename in sel\n+00043390: 662e 5f63 6f6e 7465 6e74 733a 0a20 2020 f._contents:. \n+000433a0: 2020 2020 2020 2020 2020 2020 2069 6620 if \n+000433b0: 6669 6c65 6e61 6d65 2e73 7461 7274 7377 filename.startsw\n+000433c0: 6974 6828 7365 6c66 2e5f 6469 7229 3a0a ith(self._dir):.\n+000433d0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000433e0: 2020 2020 7472 793a 0a20 2020 2020 2020 try:. \n+000433f0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00043400: 206e 6578 745f 736c 6173 6820 3d20 6669 next_slash = fi\n+00043410: 6c65 6e61 6d65 2e69 6e64 6578 2827 2f27 lename.index('/'\n+00043420: 2c20 6469 725f 6c65 6e67 7468 290a 2020 , dir_length). \n+00043430: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00043440: 2020 6578 6365 7074 2056 616c 7565 4572 except ValueEr\n+00043450: 726f 723a 0a20 2020 2020 2020 2020 2020 ror:. \n+00043460: 2020 2020 2020 2020 2020 2020 206e 6578 nex\n+00043470: 745f 736c 6173 6820 3d20 4e6f 6e65 0a20 t_slash = None. \n+00043480: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00043490: 2020 2072 6573 756c 742e 6164 6428 6669 result.add(fi\n+000434a0: 6c65 6e61 6d65 5b64 6972 5f6c 656e 6774 lename[dir_lengt\n+000434b0: 683a 6e65 7874 5f73 6c61 7368 5d29 0a0a h:next_slash])..\n+000434c0: 2020 2020 2020 2020 2020 2020 7265 7475 retu\n+000434d0: 726e 2069 7465 7228 7265 7375 6c74 290a rn iter(result).\n+000434e0: 0a20 2020 2063 6f6e 7465 6e74 733a 2044 . contents: D\n+000434f0: 6963 745b 7374 722c 2062 7974 6573 5d0a ict[str, bytes].\n+00043500: 2020 2020 6d6f 6475 6c65 733a 2044 6963 modules: Dic\n+00043510: 745b 7374 722c 2073 7472 5d0a 0a20 2020 t[str, str].. \n+00043520: 2064 6566 205f 5f69 6e69 745f 5f28 7365 def __init__(se\n+00043530: 6c66 2c20 636f 6e74 656e 7473 3a20 4469 lf, contents: Di\n+00043540: 6374 5b73 7472 2c20 6279 7465 735d 2920 ct[str, bytes]) \n+00043550: 2d3e 204e 6f6e 653a 0a20 2020 2020 2020 -> None:. \n+00043560: 2074 7279 3a0a 2020 2020 2020 2020 2020 try:. \n+00043570: 2020 636f 6e74 656e 7473 5b5f 5f66 696c contents[__fil\n+00043580: 655f 5f5d 203d 205f 5f73 656c 665f 736f e__] = __self_so\n+00043590: 7572 6365 5f5f 2020 2320 7479 7065 3a20 urce__ # type: \n+000435a0: 6967 6e6f 7265 5b6e 616d 652d 6465 6669 ignore[name-defi\n+000435b0: 6e65 645d 0a20 2020 2020 2020 2065 7863 ned]. exc\n+000435c0: 6570 7420 4e61 6d65 4572 726f 723a 0a20 ept NameError:. \n+000435d0: 2020 2020 2020 2020 2020 2070 6173 730a pass.\n+000435e0: 0a20 2020 2020 2020 2073 656c 662e 636f . self.co\n+000435f0: 6e74 656e 7473 203d 2063 6f6e 7465 6e74 ntents = content\n+00043600: 730a 2020 2020 2020 2020 7365 6c66 2e6d s. self.m\n+00043610: 6f64 756c 6573 203d 207b 0a20 2020 2020 odules = {. \n+00043620: 2020 2020 2020 2073 656c 662e 6765 745f self.get_\n+00043630: 6675 6c6c 6e61 6d65 2866 696c 656e 616d fullname(filenam\n+00043640: 6529 3a20 6669 6c65 6e61 6d65 0a20 2020 e): filename. \n+00043650: 2020 2020 2020 2020 2066 6f72 2066 696c for fil\n+00043660: 656e 616d 6520 696e 2063 6f6e 7465 6e74 ename in content\n+00043670: 730a 2020 2020 2020 2020 2020 2020 6966 s. if\n+00043680: 2066 696c 656e 616d 652e 656e 6473 7769 filename.endswi\n+00043690: 7468 2822 2e70 7922 290a 2020 2020 2020 th(\".py\"). \n+000436a0: 2020 7d0a 0a20 2020 2064 6566 2067 6574 }.. def get\n+000436b0: 5f66 756c 6c6e 616d 6528 7365 6c66 2c20 _fullname(self, \n+000436c0: 6669 6c65 6e61 6d65 3a20 7374 7229 202d filename: str) -\n+000436d0: 3e20 7374 723a 0a20 2020 2020 2020 2061 > str:. a\n+000436e0: 7373 6572 7420 6669 6c65 6e61 6d65 2e65 ssert filename.e\n+000436f0: 6e64 7377 6974 6828 222e 7079 2229 0a20 ndswith(\".py\"). \n+00043700: 2020 2020 2020 2066 696c 656e 616d 6520 filename \n+00043710: 3d20 6669 6c65 6e61 6d65 5b3a 2d33 5d0a = filename[:-3].\n+00043720: 2020 2020 2020 2020 6966 2066 696c 656e if filen\n+00043730: 616d 652e 656e 6473 7769 7468 2822 2f5f ame.endswith(\"/_\n+00043740: 5f69 6e69 745f 5f22 293a 0a20 2020 2020 _init__\"):. \n+00043750: 2020 2020 2020 2066 696c 656e 616d 6520 filename \n+00043760: 3d20 6669 6c65 6e61 6d65 5b3a 2d39 5d0a = filename[:-9].\n+00043770: 2020 2020 2020 2020 7265 7475 726e 2066 return f\n+00043780: 696c 656e 616d 652e 7265 706c 6163 6528 ilename.replace(\n+00043790: 222f 222c 2022 2e22 290a 0a20 2020 2064 \"/\", \".\").. d\n+000437a0: 6566 2067 6574 5f72 6573 6f75 7263 655f ef get_resource_\n+000437b0: 7265 6164 6572 2873 656c 662c 2066 756c reader(self, ful\n+000437c0: 6c6e 616d 653a 2073 7472 2920 2d3e 2052 lname: str) -> R\n+000437d0: 6573 6f75 7263 6552 6561 6465 723a 0a20 esourceReader:. \n+000437e0: 2020 2020 2020 2072 6574 7572 6e20 4265 return Be\n+000437f0: 6970 6163 6b4c 6f61 6465 722e 5265 736f ipackLoader.Reso\n+00043800: 7572 6365 5265 6164 6572 2873 656c 662e urceReader(self.\n+00043810: 636f 6e74 656e 7473 2c20 6675 6c6c 6e61 contents, fullna\n+00043820: 6d65 2e72 6570 6c61 6365 2827 2e27 2c20 me.replace('.', \n+00043830: 272f 2729 290a 0a20 2020 2064 6566 2067 '/')).. def g\n+00043840: 6574 5f64 6174 6128 7365 6c66 2c20 7061 et_data(self, pa\n+00043850: 7468 3a20 7374 7229 202d 3e20 6279 7465 th: str) -> byte\n+00043860: 733a 0a20 2020 2020 2020 2072 6574 7572 s:. retur\n+00043870: 6e20 7365 6c66 2e63 6f6e 7465 6e74 735b n self.contents[\n+00043880: 7061 7468 5d0a 0a20 2020 2064 6566 2067 path].. def g\n+00043890: 6574 5f66 696c 656e 616d 6528 7365 6c66 et_filename(self\n+000438a0: 2c20 6675 6c6c 6e61 6d65 3a20 7374 7229 , fullname: str)\n+000438b0: 202d 3e20 7374 723a 0a20 2020 2020 2020 -> str:. \n+000438c0: 2072 6574 7572 6e20 7365 6c66 2e6d 6f64 return self.mod\n+000438d0: 756c 6573 5b66 756c 6c6e 616d 655d 0a0a ules[fullname]..\n+000438e0: 2020 2020 6465 6620 6669 6e64 5f73 7065 def find_spe\n+000438f0: 6328 0a20 2020 2020 2020 2073 656c 662c c(. self,\n+00043900: 0a20 2020 2020 2020 2066 756c 6c6e 616d . fullnam\n+00043910: 653a 2073 7472 2c0a 2020 2020 2020 2020 e: str,. \n+00043920: 7061 7468 3a20 4f70 7469 6f6e 616c 5b53 path: Optional[S\n+00043930: 6571 7565 6e63 655b 7374 725d 5d2c 0a20 equence[str]],. \n+00043940: 2020 2020 2020 2074 6172 6765 743a 204f target: O\n+00043950: 7074 696f 6e61 6c5b 4d6f 6475 6c65 5479 ptional[ModuleTy\n+00043960: 7065 5d20 3d20 4e6f 6e65 0a20 2020 2020 pe] = None. \n+00043970: 2029 202d 3e20 4f70 7469 6f6e 616c 5b69 ) -> Optional[i\n+00043980: 6d70 6f72 746c 6962 2e6d 6163 6869 6e65 mportlib.machine\n+00043990: 7279 2e4d 6f64 756c 6553 7065 635d 3a0a ry.ModuleSpec]:.\n+000439a0: 2020 2020 2020 2020 6966 2066 756c 6c6e if fulln\n+000439b0: 616d 6520 6e6f 7420 696e 2073 656c 662e ame not in self.\n+000439c0: 6d6f 6475 6c65 733a 0a20 2020 2020 2020 modules:. \n+000439d0: 2020 2020 2072 6574 7572 6e20 4e6f 6e65 return None\n+000439e0: 0a20 2020 2020 2020 2072 6574 7572 6e20 . return \n+000439f0: 696d 706f 7274 6c69 622e 7574 696c 2e73 importlib.util.s\n+00043a00: 7065 635f 6672 6f6d 5f6c 6f61 6465 7228 pec_from_loader(\n+00043a10: 6675 6c6c 6e61 6d65 2c20 7365 6c66 290a fullname, self).\n+00043a20: 2727 272c 0a20 2027 636f 636b 7069 742f ''',. 'cockpit/\n+00043a30: 5f76 656e 646f 722f 7379 7374 656d 645f _vendor/systemd_\n+00043a40: 6374 7970 6573 2f5f 5f69 6e69 745f 5f2e ctypes/__init__.\n+00043a50: 7079 273a 2062 7227 2727 2320 7379 7374 py': br'''# syst\n+00043a60: 656d 645f 6374 7970 6573 0a23 0a23 2043 emd_ctypes.#.# C\n+00043a70: 6f70 7972 6967 6874 2028 4329 2032 3032 opyright (C) 202\n+00043a80: 3220 416c 6c69 736f 6e20 4b61 726c 6974 2 Allison Karlit\n+00043a90: 736b 6179 6120 3c61 6c6c 6973 6f6e 2e6b skaya <allison.k\n+00043aa0: 6172 6c69 7473 6b61 7961 4072 6564 6861 arlitskaya@redha\n+00043ab0: 742e 636f 6d3e 0a23 0a23 2054 6869 7320 t.com>.#.# This \n+00043ac0: 7072 6f67 7261 6d20 6973 2066 7265 6520 program is free \n+00043ad0: 736f 6674 7761 7265 3a20 796f 7520 6361 software: you ca\n+00043ae0: 6e20 7265 6469 7374 7269 6275 7465 2069 n redistribute i\n+00043af0: 7420 616e 642f 6f72 206d 6f64 6966 790a t and/or modify.\n+00043b00: 2320 6974 2075 6e64 6572 2074 6865 2074 # it under the t\n+00043b10: 6572 6d73 206f 6620 7468 6520 474e 5520 erms of the GNU \n+00043b20: 4765 6e65 7261 6c20 5075 626c 6963 204c General Public L\n+00043b30: 6963 656e 7365 2061 7320 7075 626c 6973 icense as publis\n+00043b40: 6865 6420 6279 0a23 2074 6865 2046 7265 hed by.# the Fre\n+00043b50: 6520 536f 6674 7761 7265 2046 6f75 6e64 e Software Found\n+00043b60: 6174 696f 6e2c 2065 6974 6865 7220 7665 ation, either ve\n+00043b70: 7273 696f 6e20 3320 6f66 2074 6865 204c rsion 3 of the L\n+00043b80: 6963 656e 7365 2c20 6f72 0a23 2028 6174 icense, or.# (at\n+00043b90: 2079 6f75 7220 6f70 7469 6f6e 2920 616e your option) an\n+00043ba0: 7920 6c61 7465 7220 7665 7273 696f 6e2e y later version.\n+00043bb0: 0a23 0a23 2054 6869 7320 7072 6f67 7261 .#.# This progra\n+00043bc0: 6d20 6973 2064 6973 7472 6962 7574 6564 m is distributed\n+00043bd0: 2069 6e20 7468 6520 686f 7065 2074 6861 in the hope tha\n+00043be0: 7420 6974 2077 696c 6c20 6265 2075 7365 t it will be use\n+00043bf0: 6675 6c2c 0a23 2062 7574 2057 4954 484f ful,.# but WITHO\n+00043c00: 5554 2041 4e59 2057 4152 5241 4e54 593b UT ANY WARRANTY;\n+00043c10: 2077 6974 686f 7574 2065 7665 6e20 7468 without even th\n+00043c20: 6520 696d 706c 6965 6420 7761 7272 616e e implied warran\n+00043c30: 7479 206f 660a 2320 4d45 5243 4841 4e54 ty of.# MERCHANT\n+00043c40: 4142 494c 4954 5920 6f72 2046 4954 4e45 ABILITY or FITNE\n+00043c50: 5353 2046 4f52 2041 2050 4152 5449 4355 SS FOR A PARTICU\n+00043c60: 4c41 5220 5055 5250 4f53 452e 2020 5365 LAR PURPOSE. Se\n+00043c70: 6520 7468 650a 2320 474e 5520 4765 6e65 e the.# GNU Gene\n+00043c80: 7261 6c20 5075 626c 6963 204c 6963 656e ral Public Licen\n+00043c90: 7365 2066 6f72 206d 6f72 6520 6465 7461 se for more deta\n+00043ca0: 696c 732e 0a23 0a23 2059 6f75 2073 686f ils..#.# You sho\n+00043cb0: 756c 6420 6861 7665 2072 6563 6569 7665 uld have receive\n+00043cc0: 6420 6120 636f 7079 206f 6620 7468 6520 d a copy of the \n+00043cd0: 474e 5520 4765 6e65 7261 6c20 5075 626c GNU General Publ\n+00043ce0: 6963 204c 6963 656e 7365 0a23 2061 6c6f ic License.# alo\n+00043cf0: 6e67 2077 6974 6820 7468 6973 2070 726f ng with this pro\n+00043d00: 6772 616d 2e20 2049 6620 6e6f 742c 2073 gram. If not, s\n+00043d10: 6565 203c 6874 7470 3a2f 2f77 7777 2e67 ee <http://www.g\n+00043d20: 6e75 2e6f 7267 2f6c 6963 656e 7365 732f nu.org/licenses/\n+00043d30: 3e2e 0a0a 2222 2273 7973 7465 6d64 5f63 >...\"\"\"systemd_c\n+00043d40: 7479 7065 7322 2222 0a0a 5f5f 7665 7273 types\"\"\"..__vers\n+00043d50: 696f 6e5f 5f20 3d20 2230 220a 0a66 726f ion__ = \"0\"..fro\n+00043d60: 6d20 2e62 7573 2069 6d70 6f72 7420 4275 m .bus import Bu\n+00043d70: 732c 2042 7573 4572 726f 722c 2042 7573 s, BusError, Bus\n+00043d80: 4d65 7373 6167 650a 6672 6f6d 202e 6275 Message.from .bu\n+00043d90: 7374 7970 6573 2069 6d70 6f72 7420 4275 stypes import Bu\n+00043da0: 7354 7970 652c 204a 534f 4e45 6e63 6f64 sType, JSONEncod\n+00043db0: 6572 2c20 5661 7269 616e 740a 6672 6f6d er, Variant.from\n+00043dc0: 202e 6576 656e 7420 696d 706f 7274 2045 .event import E\n+00043dd0: 7665 6e74 2c20 4576 656e 744c 6f6f 7050 vent, EventLoopP\n+00043de0: 6f6c 6963 792c 2072 756e 5f61 7379 6e63 olicy, run_async\n+00043df0: 0a66 726f 6d20 2e70 6174 6877 6174 6368 .from .pathwatch\n+00043e00: 2069 6d70 6f72 7420 4861 6e64 6c65 2c20 import Handle, \n+00043e10: 5061 7468 5761 7463 680a 0a5f 5f61 6c6c PathWatch..__all\n+00043e20: 5f5f 203d 205b 0a20 2020 2022 4275 7322 __ = [. \"Bus\"\n+00043e30: 2c0a 2020 2020 2242 7573 4572 726f 7222 ,. \"BusError\"\n+00043e40: 2c0a 2020 2020 2242 7573 4d65 7373 6167 ,. \"BusMessag\n+00043e50: 6522 2c0a 2020 2020 2242 7573 5479 7065 e\",. \"BusType\n+00043e60: 222c 0a20 2020 2022 4576 656e 7422 2c0a \",. \"Event\",.\n+00043e70: 2020 2020 2245 7665 6e74 4c6f 6f70 506f \"EventLoopPo\n+00043e80: 6c69 6379 222c 0a20 2020 2022 4861 6e64 licy\",. \"Hand\n+00043e90: 6c65 222c 0a20 2020 2022 4a53 4f4e 456e le\",. \"JSONEn\n+00043ea0: 636f 6465 7222 2c0a 2020 2020 2250 6174 coder\",. \"Pat\n+00043eb0: 6857 6174 6368 222c 0a20 2020 2022 5661 hWatch\",. \"Va\n+00043ec0: 7269 616e 7422 2c0a 2020 2020 2272 756e riant\",. \"run\n+00043ed0: 5f61 7379 6e63 222c 0a5d 0a27 2727 2c0a _async\",.].''',.\n+00043ee0: 2020 2763 6f63 6b70 6974 2f5f 7665 6e64 'cockpit/_vend\n+00043ef0: 6f72 2f73 7973 7465 6d64 5f63 7479 7065 or/systemd_ctype\n+00043f00: 732f 6c69 6273 7973 7465 6d64 2e70 7927 s/libsystemd.py'\n+00043f10: 3a20 7227 2727 2320 7379 7374 656d 645f : r'''# systemd_\n+00043f20: 6374 7970 6573 0a23 0a23 2043 6f70 7972 ctypes.#.# Copyr\n+00043f30: 6967 6874 2028 4329 2032 3032 3220 416c ight (C) 2022 Al\n+00043f40: 6c69 736f 6e20 4b61 726c 6974 736b 6179 lison Karlitskay\n+00043f50: 6120 3c61 6c6c 6973 6f6e 2e6b 6172 6c69 a <allison.karli\n+00043f60: 7473 6b61 7961 4072 6564 6861 742e 636f tskaya@redhat.co\n+00043f70: 6d3e 0a23 0a23 2054 6869 7320 7072 6f67 m>.#.# This prog\n+00043f80: 7261 6d20 6973 2066 7265 6520 736f 6674 ram is free soft\n+00043f90: 7761 7265 3a20 796f 7520 6361 6e20 7265 ware: you can re\n+00043fa0: 6469 7374 7269 6275 7465 2069 7420 616e distribute it an\n+00043fb0: 642f 6f72 206d 6f64 6966 790a 2320 6974 d/or modify.# it\n+00043fc0: 2075 6e64 6572 2074 6865 2074 6572 6d73 under the terms\n+00043fd0: 206f 6620 7468 6520 474e 5520 4765 6e65 of the GNU Gene\n+00043fe0: 7261 6c20 5075 626c 6963 204c 6963 656e ral Public Licen\n+00043ff0: 7365 2061 7320 7075 626c 6973 6865 6420 se as published \n+00044000: 6279 0a23 2074 6865 2046 7265 6520 536f by.# the Free So\n+00044010: 6674 7761 7265 2046 6f75 6e64 6174 696f ftware Foundatio\n+00044020: 6e2c 2065 6974 6865 7220 7665 7273 696f n, either versio\n+00044030: 6e20 3320 6f66 2074 6865 204c 6963 656e n 3 of the Licen\n+00044040: 7365 2c20 6f72 0a23 2028 6174 2079 6f75 se, or.# (at you\n+00044050: 7220 6f70 7469 6f6e 2920 616e 7920 6c61 r option) any la\n+00044060: 7465 7220 7665 7273 696f 6e2e 0a23 0a23 ter version..#.#\n+00044070: 2054 6869 7320 7072 6f67 7261 6d20 6973 This program is\n+00044080: 2064 6973 7472 6962 7574 6564 2069 6e20 distributed in \n+00044090: 7468 6520 686f 7065 2074 6861 7420 6974 the hope that it\n+000440a0: 2077 696c 6c20 6265 2075 7365 6675 6c2c will be useful,\n+000440b0: 0a23 2062 7574 2057 4954 484f 5554 2041 .# but WITHOUT A\n+000440c0: 4e59 2057 4152 5241 4e54 593b 2077 6974 NY WARRANTY; wit\n+000440d0: 686f 7574 2065 7665 6e20 7468 6520 696d hout even the im\n+000440e0: 706c 6965 6420 7761 7272 616e 7479 206f plied warranty o\n+000440f0: 660a 2320 4d45 5243 4841 4e54 4142 494c f.# MERCHANTABIL\n+00044100: 4954 5920 6f72 2046 4954 4e45 5353 2046 ITY or FITNESS F\n+00044110: 4f52 2041 2050 4152 5449 4355 4c41 5220 OR A PARTICULAR \n+00044120: 5055 5250 4f53 452e 2020 5365 6520 7468 PURPOSE. See th\n+00044130: 650a 2320 474e 5520 4765 6e65 7261 6c20 e.# GNU General \n+00044140: 5075 626c 6963 204c 6963 656e 7365 2066 Public License f\n+00044150: 6f72 206d 6f72 6520 6465 7461 696c 732e or more details.\n+00044160: 0a23 0a23 2059 6f75 2073 686f 756c 6420 .#.# You should \n+00044170: 6861 7665 2072 6563 6569 7665 6420 6120 have received a \n+00044180: 636f 7079 206f 6620 7468 6520 474e 5520 copy of the GNU \n+00044190: 4765 6e65 7261 6c20 5075 626c 6963 204c General Public L\n+000441a0: 6963 656e 7365 0a23 2061 6c6f 6e67 2077 icense.# along w\n+000441b0: 6974 6820 7468 6973 2070 726f 6772 616d ith this program\n+000441c0: 2e20 2049 6620 6e6f 742c 2073 6565 203c . If not, see <\n+000441d0: 6874 7470 3a2f 2f77 7777 2e67 6e75 2e6f http://www.gnu.o\n+000441e0: 7267 2f6c 6963 656e 7365 732f 3e2e 0a0a rg/licenses/>...\n+000441f0: 696d 706f 7274 2063 7479 7065 730a 696d import ctypes.im\n+00044200: 706f 7274 206f 730a 696d 706f 7274 2073 port os.import s\n+00044210: 7973 0a66 726f 6d20 7479 7069 6e67 2069 ys.from typing i\n+00044220: 6d70 6f72 7420 436c 6173 7356 6172 2c20 mport ClassVar, \n+00044230: 4c69 7374 2c20 4f70 7469 6f6e 616c 2c20 List, Optional, \n+00044240: 5475 706c 652c 2055 6e69 6f6e 0a0a 6672 Tuple, Union..fr\n+00044250: 6f6d 202e 696e 6f74 6966 7920 696d 706f om .inotify impo\n+00044260: 7274 2069 6e6f 7469 6679 5f65 7665 6e74 rt inotify_event\n+00044270: 0a66 726f 6d20 2e6c 6962 7261 7279 7772 .from .librarywr\n+00044280: 6170 7065 7220 696d 706f 7274 2028 0a20 apper import (. \n+00044290: 2020 2043 616c 6c62 6163 6b2c 0a20 2020 Callback,. \n+000442a0: 2045 7272 6e6f 2c0a 2020 2020 5265 6665 Errno,. Refe\n+000442b0: 7265 6e63 652c 0a20 2020 2052 6566 6572 rence,. Refer\n+000442c0: 656e 6365 5479 7065 2c0a 2020 2020 5573 enceType,. Us\n+000442d0: 6572 4461 7461 2c0a 2020 2020 5765 616b erData,. Weak\n+000442e0: 5265 6665 7265 6e63 652c 0a20 2020 2062 Reference,. b\n+000442f0: 7972 6566 2c0a 290a 6672 6f6d 202e 7479 yref,.).from .ty\n+00044300: 7069 6e67 2069 6d70 6f72 7420 416e 6e6f ping import Anno\n+00044310: 7461 7465 640a 0a0a 636c 6173 7320 5472 tated...class Tr\n+00044320: 616d 706f 6c69 6e65 2852 6566 6572 656e ampoline(Referen\n+00044330: 6365 5479 7065 293a 0a20 2020 2064 6566 ceType):. def\n+00044340: 6572 7265 643a 2027 436c 6173 7356 6172 erred: 'ClassVar\n+00044350: 5b6c 6973 745b 4361 6c6c 6261 636b 5d20 [list[Callback] \n+00044360: 7c20 4e6f 6e65 5d27 203d 204e 6f6e 650a | None]' = None.\n+00044370: 2020 2020 7472 616d 706f 6c69 6e65 3a20 trampoline: \n+00044380: 4361 6c6c 6261 636b 0a20 2020 2075 7365 Callback. use\n+00044390: 7264 6174 613a 2055 7365 7244 6174 6120 rdata: UserData \n+000443a0: 3d20 4e6f 6e65 0a0a 2020 2020 6465 6620 = None.. def \n+000443b0: 6361 6e63 656c 2873 656c 6629 202d 3e20 cancel(self) -> \n+000443c0: 4e6f 6e65 3a0a 2020 2020 2020 2020 7365 None:. se\n+000443d0: 6c66 2e5f 756e 7265 6628 290a 2020 2020 lf._unref(). \n+000443e0: 2020 2020 7365 6c66 2e76 616c 7565 203d self.value =\n+000443f0: 204e 6f6e 650a 0a20 2020 2064 6566 205f None.. def _\n+00044400: 5f64 656c 5f5f 2873 656c 6629 202d 3e20 _del__(self) -> \n+00044410: 4e6f 6e65 3a0a 2020 2020 2020 2020 2320 None:. # \n+00044420: 5468 6973 206d 6967 6874 2062 6520 7468 This might be th\n+00044430: 6520 6375 7272 656e 746c 792d 6469 7370 e currently-disp\n+00044440: 6174 6368 696e 6720 6361 6c6c 6261 636b atching callback\n+00044450: 20e2 8094 206d 616b 6520 7375 7265 2077 ... make sure w\n+00044460: 6520 646f 6e27 740a 2020 2020 2020 2020 e don't. \n+00044470: 2320 6465 7374 726f 7920 7468 6520 7472 # destroy the tr\n+00044480: 616d 706f 6c69 6e65 2062 6566 6f72 6520 ampoline before \n+00044490: 7765 2072 6574 7572 6e2e 2020 5765 2064 we return. We d\n+000444a0: 726f 7020 7468 6520 6465 6665 7272 6564 rop the deferred\n+000444b0: 206c 6973 740a 2020 2020 2020 2020 2320 list. # \n+000444c0: 6672 6f6d 2074 6865 2065 7665 6e74 206c from the event l\n+000444d0: 6f6f 7020 7768 656e 2077 6527 7265 2073 oop when we're s\n+000444e0: 7572 6520 7765 2772 6520 6e6f 7420 646f ure we're not do\n+000444f0: 696e 6720 616e 7920 6469 7370 6174 6368 ing any dispatch\n+00044500: 6573 2e0a 2020 2020 2020 2020 6966 2054 es.. if T\n+00044510: 7261 6d70 6f6c 696e 652e 6465 6665 7272 rampoline.deferr\n+00044520: 6564 2069 7320 6e6f 7420 4e6f 6e65 3a0a ed is not None:.\n+00044530: 2020 2020 2020 2020 2020 2020 5472 616d Tram\n+00044540: 706f 6c69 6e65 2e64 6566 6572 7265 642e poline.deferred.\n+00044550: 6170 7065 6e64 2873 656c 662e 7472 616d append(self.tram\n+00044560: 706f 6c69 6e65 290a 2020 2020 2020 2020 poline). \n+00044570: 6966 2073 656c 662e 7661 6c75 6520 6973 if self.value is\n+00044580: 206e 6f74 204e 6f6e 653a 0a20 2020 2020 not None:. \n+00044590: 2020 2020 2020 2073 656c 662e 5f75 6e72 self._unr\n+000445a0: 6566 2829 0a0a 0a63 6c61 7373 2073 645f ef()...class sd_\n+000445b0: 6275 735f 6572 726f 7228 6374 7970 6573 bus_error(ctypes\n+000445c0: 2e53 7472 7563 7475 7265 293a 0a20 2020 .Structure):. \n+000445d0: 2023 2054 6869 7320 6973 2041 4249 2c20 # This is ABI, \n+000445e0: 736f 2077 6520 6172 6520 7361 6665 2074 so we are safe t\n+000445f0: 6f20 6173 7375 6d65 2069 7420 646f 6573 o assume it does\n+00044600: 6e27 7420 6368 616e 6765 2e0a 2020 2020 n't change.. \n+00044610: 2320 556e 666f 7274 756e 6174 656c 792c # Unfortunately,\n+00044620: 2077 6520 6c61 636b 2061 6e79 7468 696e we lack anythin\n+00044630: 6720 6c69 6b65 2073 645f 6275 735f 6572 g like sd_bus_er\n+00044640: 726f 725f 6e65 7728 292e 0a20 2020 205f ror_new().. _\n+00044650: 6669 656c 6473 5f20 3d20 280a 2020 2020 fields_ = (. \n+00044660: 2020 2020 2822 6e61 6d65 222c 2063 7479 (\"name\", cty\n+00044670: 7065 732e 635f 6368 6172 5f70 292c 0a20 pes.c_char_p),. \n+00044680: 2020 2020 2020 2028 226d 6573 7361 6765 (\"message\n+00044690: 222c 2063 7479 7065 732e 635f 6368 6172 \", ctypes.c_char\n+000446a0: 5f70 292c 0a20 2020 2020 2020 2028 225f _p),. (\"_\n+000446b0: 6e65 6564 5f66 7265 6522 2c20 6374 7970 need_free\", ctyp\n+000446c0: 6573 2e63 5f69 6e74 292c 0a20 2020 2029 es.c_int),. )\n+000446d0: 0a0a 2020 2020 6465 6620 6765 7428 7365 .. def get(se\n+000446e0: 6c66 2920 2d3e 2054 7570 6c65 5b73 7472 lf) -> Tuple[str\n+000446f0: 2c20 7374 725d 3a0a 2020 2020 2020 2020 , str]:. \n+00044700: 7265 7475 726e 2073 656c 662e 6e61 6d65 return self.name\n+00044710: 2e64 6563 6f64 6528 292c 2073 656c 662e .decode(), self.\n+00044720: 6d65 7373 6167 652e 6465 636f 6465 2829 message.decode()\n+00044730: 0a0a 2020 2020 6465 6620 7365 7428 7365 .. def set(se\n+00044740: 6c66 2c20 6e61 6d65 3a20 7374 722c 206d lf, name: str, m\n+00044750: 6573 7361 6765 3a20 7374 7229 202d 3e20 essage: str) -> \n+00044760: 4e6f 6e65 3a0a 2020 2020 2020 2020 7265 None:. re\n+00044770: 7375 6c74 203d 206c 6962 7379 7374 656d sult = libsystem\n+00044780: 642e 7364 5f62 7573 5f65 7272 6f72 5f73 d.sd_bus_error_s\n+00044790: 6574 2862 7972 6566 2873 656c 6629 2c20 et(byref(self), \n+000447a0: 6e61 6d65 2c20 6d65 7373 6167 6529 0a20 name, message). \n+000447b0: 2020 2020 2020 2069 6620 7265 7375 6c74 if result\n+000447c0: 203c 2030 3a0a 2020 2020 2020 2020 2020 < 0:. \n+000447d0: 2020 7261 6973 6520 4f53 4572 726f 7228 raise OSError(\n+000447e0: 2d72 6573 756c 742c 2066 2273 645f 6275 -result, f\"sd_bu\n+000447f0: 735f 6572 726f 725f 7365 743a 207b 6f73 s_error_set: {os\n+00044800: 2e73 7472 6572 726f 7228 2d72 6573 756c .strerror(-resul\n+00044810: 7429 7d22 290a 0a20 2020 2064 6566 205f t)}\").. def _\n+00044820: 5f64 656c 5f5f 2873 656c 6629 202d 3e20 _del__(self) -> \n+00044830: 4e6f 6e65 3a0a 2020 2020 2020 2020 6966 None:. if\n+00044840: 2073 656c 662e 5f62 5f6e 6565 6473 6672 self._b_needsfr\n+00044850: 6565 5f3a 0a20 2020 2020 2020 2020 2020 ee_:. \n+00044860: 206c 6962 7379 7374 656d 642e 7364 5f62 libsystemd.sd_b\n+00044870: 7573 5f65 7272 6f72 5f66 7265 6528 6279 us_error_free(by\n+00044880: 7265 6628 7365 6c66 2929 0a0a 0a63 6c61 ref(self))...cla\n+00044890: 7373 2073 645f 6964 3132 3828 6374 7970 ss sd_id128(ctyp\n+000448a0: 6573 2e53 7472 7563 7475 7265 293a 0a20 es.Structure):. \n+000448b0: 2020 2023 2048 4143 4b3a 2050 6173 732d # HACK: Pass-\n+000448c0: 6279 2d76 616c 7565 206f 6620 6172 7261 by-value of arra\n+000448d0: 792d 636f 6e74 6169 6e69 6e67 2d73 7472 y-containing-str\n+000448e0: 7563 7473 2069 7320 6272 6f6b 656e 206f ucts is broken o\n+000448f0: 6e20 5079 7468 6f6e 0a20 2020 2023 2033 n Python. # 3\n+00044900: 2e36 2e20 5365 6520 6874 7470 733a 2f2f .6. See https://\n+00044910: 6275 6773 2e70 7974 686f 6e2e 6f72 672f bugs.python.org/\n+00044920: 6973 7375 6532 3232 3733 0a20 2020 205f issue22273. _\n+00044930: 6669 656c 6473 5f3a 204c 6973 745b 5475 fields_: List[Tu\n+00044940: 706c 655b 7374 722c 2074 7970 655d 5d20 ple[str, type]] \n+00044950: 3d20 280a 2020 2020 2020 2020 5b28 2262 = (. [(\"b\n+00044960: 7974 6573 222c 2063 7479 7065 732e 635f ytes\", ctypes.c_\n+00044970: 7569 6e74 3820 2a20 3136 295d 0a20 2020 uint8 * 16)]. \n+00044980: 2020 2020 2069 6620 7379 732e 7665 7273 if sys.vers\n+00044990: 696f 6e5f 696e 666f 203e 3d20 2833 2c20 ion_info >= (3, \n+000449a0: 372c 2030 290a 2020 2020 2020 2020 656c 7, 0). el\n+000449b0: 7365 205b 2822 6f6e 6522 2c20 6374 7970 se [(\"one\", ctyp\n+000449c0: 6573 2e63 5f75 696e 7436 3429 2c20 2822 es.c_uint64), (\"\n+000449d0: 7477 6f22 2c20 6374 7970 6573 2e63 5f75 two\", ctypes.c_u\n+000449e0: 696e 7436 3429 5d0a 2020 2020 290a 0a0a int64)]. )...\n+000449f0: 636c 6173 7320 7364 5f65 7665 6e74 5f73 class sd_event_s\n+00044a00: 6f75 7263 6528 5472 616d 706f 6c69 6e65 ource(Trampoline\n+00044a10: 293a 0a20 2020 202e 2e2e 0a0a 0a63 6c61 ):. ......cla\n+00044a20: 7373 2073 645f 6576 656e 7428 5265 6665 ss sd_event(Refe\n+00044a30: 7265 6e63 6554 7970 6529 3a0a 2020 2020 renceType):. \n+00044a40: 6465 6620 5f61 6464 5f69 6e6f 7469 6679 def _add_inotify\n+00044a50: 280a 2020 2020 2020 2020 7365 6c66 3a20 (. self: \n+00044a60: 2773 645f 6576 656e 7427 2c0a 2020 2020 'sd_event',. \n+00044a70: 2020 2020 736f 7572 6365 3a20 5265 6665 source: Refe\n+00044a80: 7265 6e63 655b 7364 5f65 7665 6e74 5f73 rence[sd_event_s\n+00044a90: 6f75 7263 655d 2c0a 2020 2020 2020 2020 ource],. \n+00044aa0: 7061 7468 3a20 7374 722c 0a20 2020 2020 path: str,. \n+00044ab0: 2020 2065 7665 6e74 3a20 696e 742c 0a20 event: int,. \n+00044ac0: 2020 2020 2020 2063 616c 6c62 6163 6b3a callback:\n+00044ad0: 2043 616c 6c62 6163 6b2c 0a20 2020 2020 Callback,. \n+00044ae0: 2020 2075 7365 725f 6461 7461 3a20 5573 user_data: Us\n+00044af0: 6572 4461 7461 2c0a 2020 2020 2920 2d3e erData,. ) ->\n+00044b00: 2055 6e69 6f6e 5b4e 6f6e 652c 2045 7272 Union[None, Err\n+00044b10: 6e6f 5d3a 0a20 2020 2020 2020 202e 2e2e no]:. ...\n+00044b20: 0a0a 2020 2020 6465 6620 6469 7370 6174 .. def dispat\n+00044b30: 6368 2873 656c 663a 2027 7364 5f65 7665 ch(self: 'sd_eve\n+00044b40: 6e74 2729 202d 3e20 556e 696f 6e5b 4e6f nt') -> Union[No\n+00044b50: 6e65 2c20 4572 726e 6f5d 3a0a 2020 2020 ne, Errno]:. \n+00044b60: 2020 2020 2e2e 2e0a 0a20 2020 2064 6566 ..... def\n+00044b70: 2067 6574 5f66 6428 7365 6c66 3a20 2773 get_fd(self: 's\n+00044b80: 645f 6576 656e 7427 2920 2d3e 2055 6e69 d_event') -> Uni\n+00044b90: 6f6e 5b69 6e74 2c20 4572 726e 6f5d 3a0a on[int, Errno]:.\n+00044ba0: 2020 2020 2020 2020 7261 6973 6520 4e6f raise No\n+00044bb0: 7449 6d70 6c65 6d65 6e74 6564 4572 726f tImplementedErro\n+00044bc0: 720a 0a20 2020 2064 6566 2067 6574 5f73 r.. def get_s\n+00044bd0: 7461 7465 2873 656c 663a 2027 7364 5f65 tate(self: 'sd_e\n+00044be0: 7665 6e74 2729 202d 3e20 556e 696f 6e5b vent') -> Union[\n+00044bf0: 696e 742c 2045 7272 6e6f 5d3a 0a20 2020 int, Errno]:. \n+00044c00: 2020 2020 2072 6169 7365 204e 6f74 496d raise NotIm\n+00044c10: 706c 656d 656e 7465 6445 7272 6f72 0a0a plementedError..\n+00044c20: 2020 2020 6465 6620 6c6f 6f70 2873 656c def loop(sel\n+00044c30: 663a 2027 7364 5f65 7665 6e74 2729 202d f: 'sd_event') -\n+00044c40: 3e20 556e 696f 6e5b 4e6f 6e65 2c20 4572 > Union[None, Er\n+00044c50: 726e 6f5d 3a0a 2020 2020 2020 2020 2e2e rno]:. ..\n+00044c60: 2e0a 0a20 2020 2064 6566 2070 7265 7061 ... def prepa\n+00044c70: 7265 2873 656c 663a 2027 7364 5f65 7665 re(self: 'sd_eve\n+00044c80: 6e74 2729 202d 3e20 556e 696f 6e5b 4e6f nt') -> Union[No\n+00044c90: 6e65 2c20 4572 726e 6f5d 3a0a 2020 2020 ne, Errno]:. \n+00044ca0: 2020 2020 2e2e 2e0a 0a20 2020 2064 6566 ..... def\n+00044cb0: 2077 6169 7428 0a20 2020 2020 2020 2073 wait(. s\n+00044cc0: 656c 663a 2027 7364 5f65 7665 6e74 272c elf: 'sd_event',\n+00044cd0: 2074 696d 656f 7574 3a20 416e 6e6f 7461 timeout: Annota\n+00044ce0: 7465 645b 696e 742c 2063 7479 7065 732e ted[int, ctypes.\n+00044cf0: 635f 7569 6e74 3634 5d0a 2020 2020 2920 c_uint64]. ) \n+00044d00: 2d3e 2055 6e69 6f6e 5b4e 6f6e 652c 2045 -> Union[None, E\n+00044d10: 7272 6e6f 5d3a 0a20 2020 2020 2020 202e rrno]:. .\n+00044d20: 2e2e 0a0a 2020 2020 4073 7461 7469 636d .... @staticm\n+00044d30: 6574 686f 640a 2020 2020 6465 6620 5f64 ethod. def _d\n+00044d40: 6566 6175 6c74 2872 6574 3a20 5265 6665 efault(ret: Refe\n+00044d50: 7265 6e63 655b 2773 645f 6576 656e 7427 rence['sd_event'\n+00044d60: 5d29 202d 3e20 556e 696f 6e5b 4e6f 6e65 ]) -> Union[None\n+00044d70: 2c20 4572 726e 6f5d 3a0a 2020 2020 2020 , Errno]:. \n+00044d80: 2020 2e2e 2e0a 0a0a 636c 6173 7320 7364 ......class sd\n+00044d90: 5f62 7573 5f73 6c6f 7428 5472 616d 706f _bus_slot(Trampo\n+00044da0: 6c69 6e65 293a 0a20 2020 202e 2e2e 0a0a line):. .....\n+00044db0: 0a63 6c61 7373 2073 645f 6275 735f 6d65 .class sd_bus_me\n+00044dc0: 7373 6167 6528 5265 6665 7265 6e63 6554 ssage(ReferenceT\n+00044dd0: 7970 6529 3a0a 2020 2020 6465 6620 7265 ype):. def re\n+00044de0: 7769 6e64 2873 656c 663a 2027 7364 5f62 wind(self: 'sd_b\n+00044df0: 7573 5f6d 6573 7361 6765 272c 2063 6f6d us_message', com\n+00044e00: 706c 6574 653a 2062 6f6f 6c29 202d 3e20 plete: bool) -> \n+00044e10: 556e 696f 6e5b 4e6f 6e65 2c20 4572 726e Union[None, Errn\n+00044e20: 6f5d 3a0a 2020 2020 2020 2020 2e2e 2e0a o]:. ....\n+00044e30: 0a20 2020 2064 6566 205f 6765 745f 6572 . def _get_er\n+00044e40: 726f 7228 7365 6c66 3a20 2773 645f 6275 ror(self: 'sd_bu\n+00044e50: 735f 6d65 7373 6167 6527 2920 2d3e 2052 s_message') -> R\n+00044e60: 6566 6572 656e 6365 5b73 645f 6275 735f eference[sd_bus_\n+00044e70: 6572 726f 725d 3a0a 2020 2020 2020 2020 error]:. \n+00044e80: 7261 6973 6520 4e6f 7449 6d70 6c65 6d65 raise NotImpleme\n+00044e90: 6e74 6564 4572 726f 720a 0a20 2020 2064 ntedError.. d\n+00044ea0: 6566 2068 6173 5f73 6967 6e61 7475 7265 ef has_signature\n+00044eb0: 2873 656c 663a 2027 7364 5f62 7573 5f6d (self: 'sd_bus_m\n+00044ec0: 6573 7361 6765 272c 2073 6967 6e61 7475 essage', signatu\n+00044ed0: 7265 3a20 7374 7229 202d 3e20 556e 696f re: str) -> Unio\n+00044ee0: 6e5b 626f 6f6c 2c20 4572 726e 6f5d 3a0a n[bool, Errno]:.\n+00044ef0: 2020 2020 2020 2020 7261 6973 6520 4e6f raise No\n+00044f00: 7449 6d70 6c65 6d65 6e74 6564 4572 726f tImplementedErro\n+00044f10: 720a 0a20 2020 2064 6566 2069 735f 6d65 r.. def is_me\n+00044f20: 7468 6f64 5f65 7272 6f72 2873 656c 663a thod_error(self:\n+00044f30: 2027 7364 5f62 7573 5f6d 6573 7361 6765 'sd_bus_message\n+00044f40: 272c 206e 616d 653a 2073 7472 2920 2d3e ', name: str) ->\n+00044f50: 2055 6e69 6f6e 5b62 6f6f 6c2c 2045 7272 Union[bool, Err\n+00044f60: 6e6f 5d3a 0a20 2020 2020 2020 2072 6169 no]:. rai\n+00044f70: 7365 204e 6f74 496d 706c 656d 656e 7465 se NotImplemente\n+00044f80: 6445 7272 6f72 0a0a 2020 2020 6465 6620 dError.. def \n+00044f90: 5f6e 6577 5f6d 6574 686f 645f 6572 726e _new_method_errn\n+00044fa0: 6f66 280a 2020 2020 2020 2020 2020 2020 of(. \n+00044fb0: 7365 6c66 3a20 2773 645f 6275 735f 6d65 self: 'sd_bus_me\n+00044fc0: 7373 6167 6527 2c0a 2020 2020 2020 2020 ssage',. \n+00044fd0: 2020 2020 6d65 7373 6167 653a 2052 6566 message: Ref\n+00044fe0: 6572 656e 6365 5b27 7364 5f62 7573 5f6d erence['sd_bus_m\n+00044ff0: 6573 7361 6765 275d 2c0a 2020 2020 2020 essage'],. \n+00045000: 2020 2020 2020 6572 726f 723a 2069 6e74 error: int\n+00045010: 2c0a 2020 2020 2020 2020 2020 2020 666f ,. fo\n+00045020: 726d 6174 5f73 7472 3a20 7374 722c 0a20 rmat_str: str,. \n+00045030: 2020 2020 2020 2020 2020 2066 6972 7374 first\n+00045040: 5f61 7267 3a20 7374 720a 2020 2020 2920 _arg: str. ) \n+00045050: 2d3e 2055 6e69 6f6e 5b4e 6f6e 652c 2045 -> Union[None, E\n+00045060: 7272 6e6f 5d3a 0a20 2020 2020 2020 202e rrno]:. .\n+00045070: 2e2e 0a0a 2020 2020 6465 6620 5f6e 6577 .... def _new\n+00045080: 5f6d 6574 686f 645f 6572 726f 7266 280a _method_errorf(.\n+00045090: 2020 2020 2020 2020 7365 6c66 3a20 2773 self: 's\n+000450a0: 645f 6275 735f 6d65 7373 6167 6527 2c0a d_bus_message',.\n+000450b0: 2020 2020 2020 2020 6d3a 2052 6566 6572 m: Refer\n+000450c0: 656e 6365 5b27 7364 5f62 7573 5f6d 6573 ence['sd_bus_mes\n+000450d0: 7361 6765 275d 2c0a 2020 2020 2020 2020 sage'],. \n+000450e0: 6e61 6d65 3a20 7374 722c 0a20 2020 2020 name: str,. \n+000450f0: 2020 2066 6f72 6d61 745f 7374 723a 2073 format_str: s\n+00045100: 7472 2c0a 2020 2020 2020 2020 6669 7273 tr,. firs\n+00045110: 745f 6172 673a 2073 7472 0a20 2020 2029 t_arg: str. )\n+00045120: 202d 3e20 556e 696f 6e5b 4e6f 6e65 2c20 -> Union[None, \n+00045130: 4572 726e 6f5d 3a0a 2020 2020 2020 2020 Errno]:. \n+00045140: 2e2e 2e0a 0a20 2020 2064 6566 205f 6e65 ..... def _ne\n+00045150: 775f 6d65 7468 6f64 5f72 6574 7572 6e28 w_method_return(\n+00045160: 0a20 2020 2020 2020 2073 656c 663a 2027 . self: '\n+00045170: 7364 5f62 7573 5f6d 6573 7361 6765 272c sd_bus_message',\n+00045180: 206d 3a20 5265 6665 7265 6e63 655b 2773 m: Reference['s\n+00045190: 645f 6275 735f 6d65 7373 6167 6527 5d0a d_bus_message'].\n+000451a0: 2020 2020 2920 2d3e 2055 6e69 6f6e 5b4e ) -> Union[N\n+000451b0: 6f6e 652c 2045 7272 6e6f 5d3a 0a20 2020 one, Errno]:. \n+000451c0: 2020 2020 202e 2e2e 0a0a 2020 2020 6465 ..... de\n+000451d0: 6620 7365 616c 280a 2020 2020 2020 2020 f seal(. \n+000451e0: 7365 6c66 3a20 2773 645f 6275 735f 6d65 self: 'sd_bus_me\n+000451f0: 7373 6167 6527 2c0a 2020 2020 2020 2020 ssage',. \n+00045200: 636f 6f6b 6965 3a20 416e 6e6f 7461 7465 cookie: Annotate\n+00045210: 645b 696e 742c 2063 7479 7065 732e 635f d[int, ctypes.c_\n+00045220: 7569 6e74 3634 5d2c 0a20 2020 2020 2020 uint64],. \n+00045230: 2074 696d 656f 7574 3a20 416e 6e6f 7461 timeout: Annota\n+00045240: 7465 645b 696e 742c 2063 7479 7065 732e ted[int, ctypes.\n+00045250: 635f 7569 6e74 3634 5d2c 0a20 2020 2029 c_uint64],. )\n+00045260: 202d 3e20 556e 696f 6e5b 4e6f 6e65 2c20 -> Union[None, \n+00045270: 4572 726e 6f5d 3a0a 2020 2020 2020 2020 Errno]:. \n+00045280: 2e2e 2e0a 0a20 2020 2064 6566 205f 6765 ..... def _ge\n+00045290: 745f 6275 7328 7365 6c66 3a20 2773 645f t_bus(self: 'sd_\n+000452a0: 6275 735f 6d65 7373 6167 6527 2920 2d3e bus_message') ->\n+000452b0: 2057 6561 6b52 6566 6572 656e 6365 3a0a WeakReference:.\n+000452c0: 2020 2020 2020 2020 7261 6973 6520 4e6f raise No\n+000452d0: 7449 6d70 6c65 6d65 6e74 6564 4572 726f tImplementedErro\n+000452e0: 720a 0a20 2020 2064 6566 2067 6574 5f64 r.. def get_d\n+000452f0: 6573 7469 6e61 7469 6f6e 2873 656c 663a estination(self:\n+00045300: 2027 7364 5f62 7573 5f6d 6573 7361 6765 'sd_bus_message\n+00045310: 2729 202d 3e20 7374 723a 0a20 2020 2020 ') -> str:. \n+00045320: 2020 2072 6169 7365 204e 6f74 496d 706c raise NotImpl\n+00045330: 656d 656e 7465 6445 7272 6f72 0a0a 2020 ementedError.. \n+00045340: 2020 6465 6620 6765 745f 696e 7465 7266 def get_interf\n+00045350: 6163 6528 7365 6c66 3a20 2773 645f 6275 ace(self: 'sd_bu\n+00045360: 735f 6d65 7373 6167 6527 2920 2d3e 2073 s_message') -> s\n+00045370: 7472 3a0a 2020 2020 2020 2020 7261 6973 tr:. rais\n+00045380: 6520 4e6f 7449 6d70 6c65 6d65 6e74 6564 e NotImplemented\n+00045390: 4572 726f 720a 0a20 2020 2064 6566 2067 Error.. def g\n+000453a0: 6574 5f6d 656d 6265 7228 7365 6c66 3a20 et_member(self: \n+000453b0: 2773 645f 6275 735f 6d65 7373 6167 6527 'sd_bus_message'\n+000453c0: 2920 2d3e 2073 7472 3a0a 2020 2020 2020 ) -> str:. \n+000453d0: 2020 7261 6973 6520 4e6f 7449 6d70 6c65 raise NotImple\n+000453e0: 6d65 6e74 6564 4572 726f 720a 0a20 2020 mentedError.. \n+000453f0: 2064 6566 2067 6574 5f70 6174 6828 7365 def get_path(se\n+00045400: 6c66 3a20 2773 645f 6275 735f 6d65 7373 lf: 'sd_bus_mess\n+00045410: 6167 6527 2920 2d3e 2073 7472 3a0a 2020 age') -> str:. \n+00045420: 2020 2020 2020 7261 6973 6520 4e6f 7449 raise NotI\n+00045430: 6d70 6c65 6d65 6e74 6564 4572 726f 720a mplementedError.\n+00045440: 0a20 2020 2064 6566 2067 6574 5f73 656e . def get_sen\n+00045450: 6465 7228 7365 6c66 3a20 2773 645f 6275 der(self: 'sd_bu\n+00045460: 735f 6d65 7373 6167 6527 2920 2d3e 204f s_message') -> O\n+00045470: 7074 696f 6e61 6c5b 7374 725d 3a0a 2020 ptional[str]:. \n+00045480: 2020 2020 2020 7261 6973 6520 4e6f 7449 raise NotI\n+00045490: 6d70 6c65 6d65 6e74 6564 4572 726f 720a mplementedError.\n+000454a0: 0a20 2020 2064 6566 2067 6574 5f73 6967 . def get_sig\n+000454b0: 6e61 7475 7265 2873 656c 663a 2027 7364 nature(self: 'sd\n+000454c0: 5f62 7573 5f6d 6573 7361 6765 272c 2063 _bus_message', c\n+000454d0: 6f6d 706c 6574 653a 2062 6f6f 6c29 202d omplete: bool) -\n+000454e0: 3e20 7374 723a 0a20 2020 2020 2020 2072 > str:. r\n+000454f0: 6169 7365 204e 6f74 496d 706c 656d 656e aise NotImplemen\n+00045500: 7465 6445 7272 6f72 0a0a 0a63 6c61 7373 tedError...class\n+00045510: 2073 645f 6275 7328 5265 6665 7265 6e63 sd_bus(Referenc\n+00045520: 6554 7970 6529 3a0a 2020 2020 6465 6620 eType):. def \n+00045530: 5f61 6464 5f6d 6174 6368 280a 2020 2020 _add_match(. \n+00045540: 2020 2020 7365 6c66 3a20 2773 645f 6275 self: 'sd_bu\n+00045550: 7327 2c0a 2020 2020 2020 2020 736c 6f74 s',. slot\n+00045560: 3a20 5265 6665 7265 6e63 655b 7364 5f62 : Reference[sd_b\n+00045570: 7573 5f73 6c6f 745d 2c0a 2020 2020 2020 us_slot],. \n+00045580: 2020 6d61 7463 683a 2073 7472 2c0a 2020 match: str,. \n+00045590: 2020 2020 2020 6861 6e64 6c65 723a 2043 handler: C\n+000455a0: 616c 6c62 6163 6b2c 0a20 2020 2020 2020 allback,. \n+000455b0: 2075 7365 725f 6461 7461 3a20 5573 6572 user_data: User\n+000455c0: 4461 7461 2c0a 2020 2020 2920 2d3e 2055 Data,. ) -> U\n+000455d0: 6e69 6f6e 5b4e 6f6e 652c 2045 7272 6e6f nion[None, Errno\n+000455e0: 5d3a 0a20 2020 2020 2020 202e 2e2e 0a0a ]:. .....\n+000455f0: 2020 2020 6465 6620 5f61 6464 5f6d 6174 def _add_mat\n+00045600: 6368 5f61 7379 6e63 280a 2020 2020 2020 ch_async(. \n+00045610: 2020 7365 6c66 3a20 2773 645f 6275 7327 self: 'sd_bus'\n+00045620: 2c0a 2020 2020 2020 2020 736c 6f74 3a20 ,. slot: \n+00045630: 5265 6665 7265 6e63 655b 7364 5f62 7573 Reference[sd_bus\n+00045640: 5f73 6c6f 745d 2c0a 2020 2020 2020 2020 _slot],. \n+00045650: 6d61 7463 683a 2073 7472 2c0a 2020 2020 match: str,. \n+00045660: 2020 2020 6361 6c6c 6261 636b 3a20 4361 callback: Ca\n+00045670: 6c6c 6261 636b 2c0a 2020 2020 2020 2020 llback,. \n+00045680: 696e 7374 616c 6c5f 6361 6c6c 6261 636b install_callback\n+00045690: 3a20 4361 6c6c 6261 636b 2c0a 2020 2020 : Callback,. \n+000456a0: 2020 2020 7573 6572 5f64 6174 613a 2055 user_data: U\n+000456b0: 7365 7244 6174 612c 0a20 2020 2029 202d serData,. ) -\n+000456c0: 3e20 556e 696f 6e5b 4e6f 6e65 2c20 4572 > Union[None, Er\n+000456d0: 726e 6f5d 3a0a 2020 2020 2020 2020 2e2e rno]:. ..\n+000456e0: 2e0a 0a20 2020 2064 6566 205f 6164 645f ... def _add_\n+000456f0: 6f62 6a65 6374 280a 2020 2020 2020 2020 object(. \n+00045700: 7365 6c66 3a20 2773 645f 6275 7327 2c0a self: 'sd_bus',.\n+00045710: 2020 2020 2020 2020 736c 6f74 3a20 5265 slot: Re\n+00045720: 6665 7265 6e63 655b 7364 5f62 7573 5f73 ference[sd_bus_s\n+00045730: 6c6f 745d 2c0a 2020 2020 2020 2020 7061 lot],. pa\n+00045740: 7468 3a20 7374 722c 0a20 2020 2020 2020 th: str,. \n+00045750: 2063 616c 6c62 6163 6b3a 2043 616c 6c62 callback: Callb\n+00045760: 6163 6b2c 0a20 2020 2020 2020 2075 7365 ack,. use\n+00045770: 725f 6461 7461 3a20 5573 6572 4461 7461 r_data: UserData\n+00045780: 2c0a 2020 2020 2920 2d3e 2055 6e69 6f6e ,. ) -> Union\n+00045790: 5b4e 6f6e 652c 2045 7272 6e6f 5d3a 0a20 [None, Errno]:. \n+000457a0: 2020 2020 2020 202e 2e2e 0a0a 2020 2020 ..... \n+000457b0: 6465 6620 6174 7461 6368 5f65 7665 6e74 def attach_event\n+000457c0: 280a 2020 2020 2020 2020 7365 6c66 3a20 (. self: \n+000457d0: 2773 645f 6275 7327 2c20 6576 656e 743a 'sd_bus', event:\n+000457e0: 204f 7074 696f 6e61 6c5b 7364 5f65 7665 Optional[sd_eve\n+000457f0: 6e74 5d2c 2070 7269 6f72 6974 793a 2069 nt], priority: i\n+00045800: 6e74 0a20 2020 2029 202d 3e20 556e 696f nt. ) -> Unio\n+00045810: 6e5b 4e6f 6e65 2c20 4572 726e 6f5d 3a0a n[None, Errno]:.\n+00045820: 2020 2020 2020 2020 2e2e 2e0a 0a20 2020 ..... \n+00045830: 2064 6566 205f 6361 6c6c 280a 2020 2020 def _call(. \n+00045840: 2020 2020 7365 6c66 3a20 2773 645f 6275 self: 'sd_bu\n+00045850: 7327 2c0a 2020 2020 2020 2020 6d65 7373 s',. mess\n+00045860: 6167 653a 2073 645f 6275 735f 6d65 7373 age: sd_bus_mess\n+00045870: 6167 652c 0a20 2020 2020 2020 2074 696d age,. tim\n+00045880: 656f 7574 3a20 416e 6e6f 7461 7465 645b eout: Annotated[\n+00045890: 696e 742c 2063 7479 7065 732e 635f 7569 int, ctypes.c_ui\n+000458a0: 6e74 3634 5d2c 0a20 2020 2020 2020 2072 nt64],. r\n+000458b0: 6574 5f65 7272 6f72 3a20 5265 6665 7265 et_error: Refere\n+000458c0: 6e63 655b 7364 5f62 7573 5f65 7272 6f72 nce[sd_bus_error\n+000458d0: 5d2c 0a20 2020 2020 2020 2072 6570 6c79 ],. reply\n+000458e0: 3a20 5265 6665 7265 6e63 655b 7364 5f62 : Reference[sd_b\n+000458f0: 7573 5f6d 6573 7361 6765 5d2c 0a20 2020 us_message],. \n+00045900: 2029 202d 3e20 556e 696f 6e5b 4e6f 6e65 ) -> Union[None\n+00045910: 2c20 4572 726e 6f5d 3a0a 2020 2020 2020 , Errno]:. \n+00045920: 2020 2e2e 2e0a 0a20 2020 2064 6566 205f ..... def _\n+00045930: 6361 6c6c 5f61 7379 6e63 280a 2020 2020 call_async(. \n+00045940: 2020 2020 7365 6c66 3a20 2773 645f 6275 self: 'sd_bu\n+00045950: 7327 2c0a 2020 2020 2020 2020 736c 6f74 s',. slot\n+00045960: 3a20 5265 6665 7265 6e63 655b 7364 5f62 : Reference[sd_b\n+00045970: 7573 5f73 6c6f 745d 2c0a 2020 2020 2020 us_slot],. \n+00045980: 2020 6d65 7373 6167 653a 2073 645f 6275 message: sd_bu\n+00045990: 735f 6d65 7373 6167 652c 0a20 2020 2020 s_message,. \n+000459a0: 2020 2063 616c 6c62 6163 6b3a 2043 616c callback: Cal\n+000459b0: 6c62 6163 6b2c 0a20 2020 2020 2020 2075 lback,. u\n+000459c0: 7365 725f 6461 7461 3a20 5573 6572 4461 ser_data: UserDa\n+000459d0: 7461 2c0a 2020 2020 2020 2020 7469 6d65 ta,. time\n+000459e0: 6f75 745f 7573 6563 3a20 416e 6e6f 7461 out_usec: Annota\n+000459f0: 7465 645b 696e 742c 2063 7479 7065 732e ted[int, ctypes.\n+00045a00: 635f 7569 6e74 3634 5d2c 0a20 2020 2029 c_uint64],. )\n+00045a10: 202d 3e20 556e 696f 6e5b 4e6f 6e65 2c20 -> Union[None, \n+00045a20: 4572 726e 6f5d 3a0a 2020 2020 2020 2020 Errno]:. \n+00045a30: 2e2e 2e0a 0a20 2020 2064 6566 2066 6c75 ..... def flu\n+00045a40: 7368 2873 656c 663a 2027 7364 5f62 7573 sh(self: 'sd_bus\n+00045a50: 2729 202d 3e20 556e 696f 6e5b 4e6f 6e65 ') -> Union[None\n+00045a60: 2c20 4572 726e 6f5d 3a0a 2020 2020 2020 , Errno]:. \n+00045a70: 2020 2e2e 2e0a 0a20 2020 2064 6566 2067 ..... def g\n+00045a80: 6574 5f66 6428 7365 6c66 3a20 2773 645f et_fd(self: 'sd_\n+00045a90: 6275 7327 2920 2d3e 2055 6e69 6f6e 5b69 bus') -> Union[i\n+00045aa0: 6e74 2c20 4572 726e 6f5d 3a0a 2020 2020 nt, Errno]:. \n+00045ab0: 2020 2020 7261 6973 6520 4e6f 7449 6d70 raise NotImp\n+00045ac0: 6c65 6d65 6e74 6564 4572 726f 720a 0a20 lementedError.. \n+00045ad0: 2020 2064 6566 205f 6d65 7373 6167 655f def _message_\n+00045ae0: 6e65 775f 6d65 7468 6f64 5f63 616c 6c28 new_method_call(\n+00045af0: 0a20 2020 2020 2020 2073 656c 663a 2027 . self: '\n+00045b00: 7364 5f62 7573 272c 0a20 2020 2020 2020 sd_bus',. \n+00045b10: 206d 6573 7361 6765 3a20 5265 6665 7265 message: Refere\n+00045b20: 6e63 655b 7364 5f62 7573 5f6d 6573 7361 nce[sd_bus_messa\n+00045b30: 6765 5d2c 0a20 2020 2020 2020 2064 6573 ge],. des\n+00045b40: 7469 6e61 7469 6f6e 3a20 4f70 7469 6f6e tination: Option\n+00045b50: 616c 5b73 7472 5d2c 0a20 2020 2020 2020 al[str],. \n+00045b60: 2070 6174 683a 2073 7472 2c0a 2020 2020 path: str,. \n+00045b70: 2020 2020 696e 7465 7266 6163 653a 2073 interface: s\n+00045b80: 7472 2c0a 2020 2020 2020 2020 6d65 6d62 tr,. memb\n+00045b90: 6572 3a20 7374 722c 0a20 2020 2029 202d er: str,. ) -\n+00045ba0: 3e20 556e 696f 6e5b 4e6f 6e65 2c20 4572 > Union[None, Er\n+00045bb0: 726e 6f5d 3a0a 2020 2020 2020 2020 2e2e rno]:. ..\n+00045bc0: 2e0a 0a20 2020 2064 6566 205f 6d65 7373 ... def _mess\n+00045bd0: 6167 655f 6e65 775f 7369 676e 616c 280a age_new_signal(.\n+00045be0: 2020 2020 2020 2020 7365 6c66 3a20 2773 self: 's\n+00045bf0: 645f 6275 7327 2c0a 2020 2020 2020 2020 d_bus',. \n+00045c00: 6d65 7373 6167 653a 2052 6566 6572 656e message: Referen\n+00045c10: 6365 5b73 645f 6275 735f 6d65 7373 6167 ce[sd_bus_messag\n+00045c20: 655d 2c0a 2020 2020 2020 2020 7061 7468 e],. path\n+00045c30: 3a20 7374 722c 0a20 2020 2020 2020 2069 : str,. i\n+00045c40: 6e74 6572 6661 6365 3a20 7374 722c 0a20 nterface: str,. \n+00045c50: 2020 2020 2020 206d 656d 6265 723a 2073 member: s\n+00045c60: 7472 2c0a 2020 2020 2920 2d3e 2055 6e69 tr,. ) -> Uni\n+00045c70: 6f6e 5b4e 6f6e 652c 2045 7272 6e6f 5d3a on[None, Errno]:\n+00045c80: 0a20 2020 2020 2020 202e 2e2e 0a0a 2020 . ..... \n+00045c90: 2020 6465 6620 7265 6c65 6173 655f 6e61 def release_na\n+00045ca0: 6d65 2873 656c 663a 2027 7364 5f62 7573 me(self: 'sd_bus\n+00045cb0: 272c 206e 616d 653a 2073 7472 2920 2d3e ', name: str) ->\n+00045cc0: 2055 6e69 6f6e 5b4e 6f6e 652c 2045 7272 Union[None, Err\n+00045cd0: 6e6f 5d3a 0a20 2020 2020 2020 202e 2e2e no]:. ...\n+00045ce0: 0a0a 2020 2020 6465 6620 7265 7175 6573 .. def reques\n+00045cf0: 745f 6e61 6d65 280a 2020 2020 2020 2020 t_name(. \n+00045d00: 7365 6c66 3a20 2773 645f 6275 7327 2c20 self: 'sd_bus', \n+00045d10: 6e61 6d65 3a20 7374 722c 2066 6c61 6773 name: str, flags\n+00045d20: 3a20 416e 6e6f 7461 7465 645b 696e 742c : Annotated[int,\n+00045d30: 2063 7479 7065 732e 635f 7569 6e74 3634 ctypes.c_uint64\n+00045d40: 5d0a 2020 2020 2920 2d3e 2055 6e69 6f6e ]. ) -> Union\n+00045d50: 5b4e 6f6e 652c 2045 7272 6e6f 5d3a 0a20 [None, Errno]:. \n+00045d60: 2020 2020 2020 202e 2e2e 0a0a 2020 2020 ..... \n+00045d70: 6465 6620 7365 745f 6164 6472 6573 7328 def set_address(\n+00045d80: 7365 6c66 3a20 2773 645f 6275 7327 2c20 self: 'sd_bus', \n+00045d90: 6164 6472 6573 733a 2073 7472 2920 2d3e address: str) ->\n+00045da0: 2055 6e69 6f6e 5b4e 6f6e 652c 2045 7272 Union[None, Err\n+00045db0: 6e6f 5d3a 0a20 2020 2020 2020 202e 2e2e no]:. ...\n+00045dc0: 0a0a 2020 2020 6465 6620 7365 745f 6275 .. def set_bu\n+00045dd0: 735f 636c 6965 6e74 2873 656c 663a 2027 s_client(self: '\n+00045de0: 7364 5f62 7573 272c 2062 3a20 626f 6f6c sd_bus', b: bool\n+00045df0: 2920 2d3e 2055 6e69 6f6e 5b4e 6f6e 652c ) -> Union[None,\n+00045e00: 2045 7272 6e6f 5d3a 0a20 2020 2020 2020 Errno]:. \n+00045e10: 202e 2e2e 0a0a 2020 2020 6465 6620 7365 ..... def se\n+00045e20: 745f 6664 2873 656c 663a 2027 7364 5f62 t_fd(self: 'sd_b\n+00045e30: 7573 272c 2069 6e70 7574 5f66 643a 2069 us', input_fd: i\n+00045e40: 6e74 2c20 6f75 7470 7574 5f66 643a 2069 nt, output_fd: i\n+00045e50: 6e74 2920 2d3e 2055 6e69 6f6e 5b4e 6f6e nt) -> Union[Non\n+00045e60: 652c 2045 7272 6e6f 5d3a 0a20 2020 2020 e, Errno]:. \n+00045e70: 2020 202e 2e2e 0a0a 2020 2020 6465 6620 ..... def \n+00045e80: 7365 745f 7365 7276 6572 2873 656c 663a set_server(self:\n+00045e90: 2027 7364 5f62 7573 272c 2062 3a20 626f 'sd_bus', b: bo\n+00045ea0: 6f6c 2c20 6275 735f 643a 2073 645f 6964 ol, bus_d: sd_id\n+00045eb0: 3132 3829 202d 3e20 556e 696f 6e5b 4e6f 128) -> Union[No\n+00045ec0: 6e65 2c20 4572 726e 6f5d 3a0a 2020 2020 ne, Errno]:. \n+00045ed0: 2020 2020 2e2e 2e0a 0a20 2020 2064 6566 ..... def\n+00045ee0: 2073 7461 7274 2873 656c 663a 2027 7364 start(self: 'sd\n+00045ef0: 5f62 7573 2729 202d 3e20 556e 696f 6e5b _bus') -> Union[\n+00045f00: 4e6f 6e65 2c20 4572 726e 6f5d 3a0a 2020 None, Errno]:. \n+00045f10: 2020 2020 2020 2e2e 2e0a 0a20 2020 2064 ..... d\n+00045f20: 6566 2077 6169 7428 0a20 2020 2020 2020 ef wait(. \n+00045f30: 2073 656c 663a 2027 7364 5f62 7573 272c self: 'sd_bus',\n+00045f40: 2074 696d 656f 7574 5f75 7365 633a 2041 timeout_usec: A\n+00045f50: 6e6e 6f74 6174 6564 5b69 6e74 2c20 6374 nnotated[int, ct\n+00045f60: 7970 6573 2e63 5f75 696e 7436 345d 0a20 ypes.c_uint64]. \n+00045f70: 2020 2029 202d 3e20 556e 696f 6e5b 4e6f ) -> Union[No\n+00045f80: 6e65 2c20 4572 726e 6f5d 3a0a 2020 2020 ne, Errno]:. \n+00045f90: 2020 2020 2e2e 2e0a 0a20 2020 2064 6566 ..... def\n+00045fa0: 2073 656e 6428 0a20 2020 2020 2020 2073 send(. s\n+00045fb0: 656c 663a 2027 7364 5f62 7573 272c 206d elf: 'sd_bus', m\n+00045fc0: 6573 7361 6765 3a20 7364 5f62 7573 5f6d essage: sd_bus_m\n+00045fd0: 6573 7361 6765 2c20 636f 6f6b 6965 3a20 essage, cookie: \n+00045fe0: 4f70 7469 6f6e 616c 5b52 6566 6572 656e Optional[Referen\n+00045ff0: 6365 5b63 7479 7065 732e 635f 7569 6e74 ce[ctypes.c_uint\n+00046000: 3634 5d5d 0a20 2020 2029 202d 3e20 556e 64]]. ) -> Un\n+00046010: 696f 6e5b 4e6f 6e65 2c20 4572 726e 6f5d ion[None, Errno]\n+00046020: 3a0a 2020 2020 2020 2020 2e2e 2e0a 0a20 :. ..... \n+00046030: 2020 2040 7374 6174 6963 6d65 7468 6f64 @staticmethod\n+00046040: 0a20 2020 2064 6566 205f 6465 6661 756c . def _defaul\n+00046050: 745f 7379 7374 656d 2872 6574 3a20 5265 t_system(ret: Re\n+00046060: 6665 7265 6e63 655b 2773 645f 6275 7327 ference['sd_bus'\n+00046070: 5d29 202d 3e20 556e 696f 6e5b 4e6f 6e65 ]) -> Union[None\n+00046080: 2c20 4572 726e 6f5d 3a0a 2020 2020 2020 , Errno]:. \n+00046090: 2020 2e2e 2e0a 0a20 2020 2040 7374 6174 ..... @stat\n+000460a0: 6963 6d65 7468 6f64 0a20 2020 2064 6566 icmethod. def\n+000460b0: 205f 6465 6661 756c 745f 7573 6572 2872 _default_user(r\n+000460c0: 6574 3a20 5265 6665 7265 6e63 655b 2773 et: Reference['s\n+000460d0: 645f 6275 7327 5d29 202d 3e20 556e 696f d_bus']) -> Unio\n+000460e0: 6e5b 4e6f 6e65 2c20 4572 726e 6f5d 3a0a n[None, Errno]:.\n+000460f0: 2020 2020 2020 2020 2e2e 2e0a 0a20 2020 ..... \n+00046100: 2040 7374 6174 6963 6d65 7468 6f64 0a20 @staticmethod. \n+00046110: 2020 2064 6566 205f 6e65 7728 7265 743a def _new(ret:\n+00046120: 2052 6566 6572 656e 6365 5b27 7364 5f62 Reference['sd_b\n+00046130: 7573 275d 2920 2d3e 2055 6e69 6f6e 5b4e us']) -> Union[N\n+00046140: 6f6e 652c 2045 7272 6e6f 5d3a 0a20 2020 one, Errno]:. \n+00046150: 2020 2020 202e 2e2e 0a0a 0a73 645f 6275 ......sd_bu\n+00046160: 735f 6d65 7373 6167 655f 6861 6e64 6c65 s_message_handle\n+00046170: 725f 7420 3d20 6374 7970 6573 2e43 4655 r_t = ctypes.CFU\n+00046180: 4e43 5459 5045 280a 2020 2020 6374 7970 NCTYPE(. ctyp\n+00046190: 6573 2e63 5f69 6e74 2c20 6374 7970 6573 es.c_int, ctypes\n+000461a0: 2e63 5f76 6f69 645f 702c 2063 7479 7065 .c_void_p, ctype\n+000461b0: 732e 635f 766f 6964 5f70 2c20 6374 7970 s.c_void_p, ctyp\n+000461c0: 6573 2e50 4f49 4e54 4552 2873 645f 6275 es.POINTER(sd_bu\n+000461d0: 735f 6572 726f 7229 290a 7364 5f65 7665 s_error)).sd_eve\n+000461e0: 6e74 5f69 6e6f 7469 6679 5f68 616e 646c nt_inotify_handl\n+000461f0: 6572 5f74 203d 2063 7479 7065 732e 4346 er_t = ctypes.CF\n+00046200: 554e 4354 5950 4528 0a20 2020 2063 7479 UNCTYPE(. cty\n+00046210: 7065 732e 635f 696e 742c 2063 7479 7065 pes.c_int, ctype\n+00046220: 732e 635f 766f 6964 5f70 2c20 6374 7970 s.c_void_p, ctyp\n+00046230: 6573 2e50 4f49 4e54 4552 2869 6e6f 7469 es.POINTER(inoti\n+00046240: 6679 5f65 7665 6e74 292c 2063 7479 7065 fy_event), ctype\n+00046250: 732e 635f 766f 6964 5f70 290a 0a0a 6c69 s.c_void_p)...li\n+00046260: 6273 7973 7465 6d64 203d 2063 7479 7065 bsystemd = ctype\n+00046270: 732e 4344 4c4c 2822 6c69 6273 7973 7465 s.CDLL(\"libsyste\n+00046280: 6d64 2e73 6f2e 3022 290a 666f 7220 636c md.so.0\").for cl\n+00046290: 7320 696e 207b 0a20 2020 2073 645f 6275 s in {. sd_bu\n+000462a0: 732c 0a20 2020 2073 645f 6275 735f 6d65 s,. sd_bus_me\n+000462b0: 7373 6167 652c 0a20 2020 2073 645f 6275 ssage,. sd_bu\n+000462c0: 735f 736c 6f74 2c0a 2020 2020 7364 5f65 s_slot,. sd_e\n+000462d0: 7665 6e74 2c0a 2020 2020 7364 5f65 7665 vent,. sd_eve\n+000462e0: 6e74 5f73 6f75 7263 652c 0a7d 3a0a 2020 nt_source,.}:. \n+000462f0: 2020 636c 732e 5f69 6e73 7461 6c6c 5f63 cls._install_c\n+00046300: 6675 6e63 7328 6c69 6273 7973 7465 6d64 funcs(libsystemd\n+00046310: 290a 2727 272e 656e 636f 6465 2827 7574 ).'''.encode('ut\n+00046320: 662d 3827 292c 0a20 2027 636f 636b 7069 f-8'),. 'cockpi\n+00046330: 742f 5f76 656e 646f 722f 7379 7374 656d t/_vendor/system\n+00046340: 645f 6374 7970 6573 2f65 7665 6e74 2e70 d_ctypes/event.p\n+00046350: 7927 3a20 6272 2727 2723 2073 7973 7465 y': br'''# syste\n+00046360: 6d64 5f63 7479 7065 730a 230a 2320 436f md_ctypes.#.# Co\n+00046370: 7079 7269 6768 7420 2843 2920 3230 3232 pyright (C) 2022\n+00046380: 2041 6c6c 6973 6f6e 204b 6172 6c69 7473 Allison Karlits\n+00046390: 6b61 7961 203c 616c 6c69 736f 6e2e 6b61 kaya <allison.ka\n+000463a0: 726c 6974 736b 6179 6140 7265 6468 6174 rlitskaya@redhat\n+000463b0: 2e63 6f6d 3e0a 230a 2320 5468 6973 2070 .com>.#.# This p\n+000463c0: 726f 6772 616d 2069 7320 6672 6565 2073 rogram is free s\n+000463d0: 6f66 7477 6172 653a 2079 6f75 2063 616e oftware: you can\n+000463e0: 2072 6564 6973 7472 6962 7574 6520 6974 redistribute it\n+000463f0: 2061 6e64 2f6f 7220 6d6f 6469 6679 0a23 and/or modify.#\n+00046400: 2069 7420 756e 6465 7220 7468 6520 7465 it under the te\n+00046410: 726d 7320 6f66 2074 6865 2047 4e55 2047 rms of the GNU G\n+00046420: 656e 6572 616c 2050 7562 6c69 6320 4c69 eneral Public Li\n+00046430: 6365 6e73 6520 6173 2070 7562 6c69 7368 cense as publish\n+00046440: 6564 2062 790a 2320 7468 6520 4672 6565 ed by.# the Free\n+00046450: 2053 6f66 7477 6172 6520 466f 756e 6461 Software Founda\n+00046460: 7469 6f6e 2c20 6569 7468 6572 2076 6572 tion, either ver\n+00046470: 7369 6f6e 2033 206f 6620 7468 6520 4c69 sion 3 of the Li\n+00046480: 6365 6e73 652c 206f 720a 2320 2861 7420 cense, or.# (at \n+00046490: 796f 7572 206f 7074 696f 6e29 2061 6e79 your option) any\n+000464a0: 206c 6174 6572 2076 6572 7369 6f6e 2e0a later version..\n+000464b0: 230a 2320 5468 6973 2070 726f 6772 616d #.# This program\n+000464c0: 2069 7320 6469 7374 7269 6275 7465 6420 is distributed \n+000464d0: 696e 2074 6865 2068 6f70 6520 7468 6174 in the hope that\n+000464e0: 2069 7420 7769 6c6c 2062 6520 7573 6566 it will be usef\n+000464f0: 756c 2c0a 2320 6275 7420 5749 5448 4f55 ul,.# but WITHOU\n+00046500: 5420 414e 5920 5741 5252 414e 5459 3b20 T ANY WARRANTY; \n+00046510: 7769 7468 6f75 7420 6576 656e 2074 6865 without even the\n+00046520: 2069 6d70 6c69 6564 2077 6172 7261 6e74 implied warrant\n+00046530: 7920 6f66 0a23 204d 4552 4348 414e 5441 y of.# MERCHANTA\n+00046540: 4249 4c49 5459 206f 7220 4649 544e 4553 BILITY or FITNES\n+00046550: 5320 464f 5220 4120 5041 5254 4943 554c S FOR A PARTICUL\n+00046560: 4152 2050 5552 504f 5345 2e20 2053 6565 AR PURPOSE. See\n+00046570: 2074 6865 0a23 2047 4e55 2047 656e 6572 the.# GNU Gener\n+00046580: 616c 2050 7562 6c69 6320 4c69 6365 6e73 al Public Licens\n+00046590: 6520 666f 7220 6d6f 7265 2064 6574 6169 e for more detai\n+000465a0: 6c73 2e0a 230a 2320 596f 7520 7368 6f75 ls..#.# You shou\n+000465b0: 6c64 2068 6176 6520 7265 6365 6976 6564 ld have received\n+000465c0: 2061 2063 6f70 7920 6f66 2074 6865 2047 a copy of the G\n+000465d0: 4e55 2047 656e 6572 616c 2050 7562 6c69 NU General Publi\n+000465e0: 6320 4c69 6365 6e73 650a 2320 616c 6f6e c License.# alon\n+000465f0: 6720 7769 7468 2074 6869 7320 7072 6f67 g with this prog\n+00046600: 7261 6d2e 2020 4966 206e 6f74 2c20 7365 ram. If not, se\n+00046610: 6520 3c68 7474 703a 2f2f 7777 772e 676e e <http://www.gn\n+00046620: 752e 6f72 672f 6c69 6365 6e73 6573 2f3e u.org/licenses/>\n+00046630: 2e0a 0a69 6d70 6f72 7420 6173 796e 6369 ...import asynci\n+00046640: 6f0a 696d 706f 7274 2073 656c 6563 746f o.import selecto\n+00046650: 7273 0a69 6d70 6f72 7420 7379 730a 6672 rs.import sys.fr\n+00046660: 6f6d 2074 7970 696e 6720 696d 706f 7274 om typing import\n+00046670: 2043 616c 6c61 626c 652c 2043 6c61 7373 Callable, Class\n+00046680: 5661 722c 2043 6f72 6f75 7469 6e65 2c20 Var, Coroutine, \n+00046690: 4c69 7374 2c20 4f70 7469 6f6e 616c 2c20 List, Optional, \n+000466a0: 5475 706c 650a 0a66 726f 6d20 2e20 696d Tuple..from . im\n+000466b0: 706f 7274 2069 6e6f 7469 6679 2c20 6c69 port inotify, li\n+000466c0: 6273 7973 7465 6d64 0a66 726f 6d20 2e6c bsystemd.from .l\n+000466d0: 6962 7261 7279 7772 6170 7065 7220 696d ibrarywrapper im\n+000466e0: 706f 7274 2052 6566 6572 656e 6365 2c20 port Reference, \n+000466f0: 5573 6572 4461 7461 2c20 6279 7265 660a UserData, byref.\n+00046700: 0a0a 636c 6173 7320 4576 656e 7428 6c69 ..class Event(li\n+00046710: 6273 7973 7465 6d64 2e73 645f 6576 656e bsystemd.sd_even\n+00046720: 7429 3a0a 2020 2020 636c 6173 7320 536f t):. class So\n+00046730: 7572 6365 286c 6962 7379 7374 656d 642e urce(libsystemd.\n+00046740: 7364 5f65 7665 6e74 5f73 6f75 7263 6529 sd_event_source)\n+00046750: 3a0a 2020 2020 2020 2020 6465 6620 6361 :. def ca\n+00046760: 6e63 656c 2873 656c 6629 202d 3e20 4e6f ncel(self) -> No\n+00046770: 6e65 3a0a 2020 2020 2020 2020 2020 2020 ne:. \n+00046780: 7365 6c66 2e5f 756e 7265 6628 290a 2020 self._unref(). \n+00046790: 2020 2020 2020 2020 2020 7365 6c66 2e76 self.v\n+000467a0: 616c 7565 203d 204e 6f6e 650a 0a20 2020 alue = None.. \n+000467b0: 205f 6465 6661 756c 745f 696e 7374 616e _default_instan\n+000467c0: 6365 3a20 436c 6173 7356 6172 5b4f 7074 ce: ClassVar[Opt\n+000467d0: 696f 6e61 6c5b 2745 7665 6e74 275d 5d20 ional['Event']] \n+000467e0: 3d20 4e6f 6e65 0a0a 2020 2020 4073 7461 = None.. @sta\n+000467f0: 7469 636d 6574 686f 640a 2020 2020 6465 ticmethod. de\n+00046800: 6620 6465 6661 756c 7428 2920 2d3e 2027 f default() -> '\n+00046810: 4576 656e 7427 3a0a 2020 2020 2020 2020 Event':. \n+00046820: 6966 2045 7665 6e74 2e5f 6465 6661 756c if Event._defaul\n+00046830: 745f 696e 7374 616e 6365 2069 7320 4e6f t_instance is No\n+00046840: 6e65 3a0a 2020 2020 2020 2020 2020 2020 ne:. \n+00046850: 4576 656e 742e 5f64 6566 6175 6c74 5f69 Event._default_i\n+00046860: 6e73 7461 6e63 6520 3d20 4576 656e 7428 nstance = Event(\n+00046870: 290a 2020 2020 2020 2020 2020 2020 4576 ). Ev\n+00046880: 656e 742e 5f64 6566 6175 6c74 2862 7972 ent._default(byr\n+00046890: 6566 2845 7665 6e74 2e5f 6465 6661 756c ef(Event._defaul\n+000468a0: 745f 696e 7374 616e 6365 2929 0a20 2020 t_instance)). \n+000468b0: 2020 2020 2072 6574 7572 6e20 4576 656e return Even\n+000468c0: 742e 5f64 6566 6175 6c74 5f69 6e73 7461 t._default_insta\n+000468d0: 6e63 650a 0a20 2020 2049 6e6f 7469 6679 nce.. Inotify\n+000468e0: 4861 6e64 6c65 7220 3d20 4361 6c6c 6162 Handler = Callab\n+000468f0: 6c65 5b5b 696e 6f74 6966 792e 4576 656e le[[inotify.Even\n+00046900: 742c 2069 6e74 2c20 4f70 7469 6f6e 616c t, int, Optional\n+00046910: 5b62 7974 6573 5d5d 2c20 4e6f 6e65 5d0a [bytes]], None].\n+00046920: 0a20 2020 2063 6c61 7373 2049 6e6f 7469 . class Inoti\n+00046930: 6679 536f 7572 6365 2853 6f75 7263 6529 fySource(Source)\n+00046940: 3a0a 2020 2020 2020 2020 6465 6620 5f5f :. def __\n+00046950: 696e 6974 5f5f 2873 656c 662c 2068 616e init__(self, han\n+00046960: 646c 6572 3a20 2745 7665 6e74 2e49 6e6f dler: 'Event.Ino\n+00046970: 7469 6679 4861 6e64 6c65 7227 2920 2d3e tifyHandler') ->\n+00046980: 204e 6f6e 653a 0a20 2020 2020 2020 2020 None:. \n+00046990: 2020 2064 6566 2063 616c 6c62 6163 6b28 def callback(\n+000469a0: 736f 7572 6365 3a20 6c69 6273 7973 7465 source: libsyste\n+000469b0: 6d64 2e73 645f 6576 656e 745f 736f 7572 md.sd_event_sour\n+000469c0: 6365 2c0a 2020 2020 2020 2020 2020 2020 ce,. \n+000469d0: 2020 2020 2020 2020 2020 2020 205f 6576 _ev\n+000469e0: 656e 743a 2052 6566 6572 656e 6365 5b69 ent: Reference[i\n+000469f0: 6e6f 7469 6679 2e69 6e6f 7469 6679 5f65 notify.inotify_e\n+00046a00: 7665 6e74 5d2c 0a20 2020 2020 2020 2020 vent],. \n+00046a10: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00046a20: 7573 6572 6461 7461 3a20 5573 6572 4461 userdata: UserDa\n+00046a30: 7461 2920 2d3e 2069 6e74 3a0a 2020 2020 ta) -> int:. \n+00046a40: 2020 2020 2020 2020 2020 2020 6576 656e even\n+00046a50: 7420 3d20 5f65 7665 6e74 2e63 6f6e 7465 t = _event.conte\n+00046a60: 6e74 730a 2020 2020 2020 2020 2020 2020 nts. \n+00046a70: 2020 2020 6861 6e64 6c65 7228 696e 6f74 handler(inot\n+00046a80: 6966 792e 4576 656e 7428 6576 656e 742e ify.Event(event.\n+00046a90: 6d61 736b 292c 2065 7665 6e74 2e63 6f6f mask), event.coo\n+00046aa0: 6b69 652c 2065 7665 6e74 2e6e 616d 6529 kie, event.name)\n+00046ab0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+00046ac0: 2072 6574 7572 6e20 300a 2020 2020 2020 return 0. \n+00046ad0: 2020 2020 2020 7365 6c66 2e74 7261 6d70 self.tramp\n+00046ae0: 6f6c 696e 6520 3d20 6c69 6273 7973 7465 oline = libsyste\n+00046af0: 6d64 2e73 645f 6576 656e 745f 696e 6f74 md.sd_event_inot\n+00046b00: 6966 795f 6861 6e64 6c65 725f 7428 6361 ify_handler_t(ca\n+00046b10: 6c6c 6261 636b 290a 0a20 2020 2064 6566 llback).. def\n+00046b20: 2061 6464 5f69 6e6f 7469 6679 2873 656c add_inotify(sel\n+00046b30: 662c 2070 6174 683a 2073 7472 2c20 6d61 f, path: str, ma\n+00046b40: 736b 3a20 696e 6f74 6966 792e 4576 656e sk: inotify.Even\n+00046b50: 742c 2068 616e 646c 6572 3a20 496e 6f74 t, handler: Inot\n+00046b60: 6966 7948 616e 646c 6572 2920 2d3e 2049 ifyHandler) -> I\n+00046b70: 6e6f 7469 6679 536f 7572 6365 3a0a 2020 notifySource:. \n+00046b80: 2020 2020 2020 736f 7572 6365 203d 2045 source = E\n+00046b90: 7665 6e74 2e49 6e6f 7469 6679 536f 7572 vent.InotifySour\n+00046ba0: 6365 2868 616e 646c 6572 290a 2020 2020 ce(handler). \n+00046bb0: 2020 2020 7365 6c66 2e5f 6164 645f 696e self._add_in\n+00046bc0: 6f74 6966 7928 6279 7265 6628 736f 7572 otify(byref(sour\n+00046bd0: 6365 292c 2070 6174 682c 206d 6173 6b2c ce), path, mask,\n+00046be0: 2073 6f75 7263 652e 7472 616d 706f 6c69 source.trampoli\n+00046bf0: 6e65 2c20 736f 7572 6365 2e75 7365 7264 ne, source.userd\n+00046c00: 6174 6129 0a20 2020 2020 2020 2072 6574 ata). ret\n+00046c10: 7572 6e20 736f 7572 6365 0a0a 2020 2020 urn source.. \n+00046c20: 6465 6620 6164 645f 696e 6f74 6966 795f def add_inotify_\n+00046c30: 6664 2873 656c 662c 2066 643a 2069 6e74 fd(self, fd: int\n+00046c40: 2c20 6d61 736b 3a20 696e 6f74 6966 792e , mask: inotify.\n+00046c50: 4576 656e 742c 2068 616e 646c 6572 3a20 Event, handler: \n+00046c60: 496e 6f74 6966 7948 616e 646c 6572 2920 InotifyHandler) \n+00046c70: 2d3e 2049 6e6f 7469 6679 536f 7572 6365 -> InotifySource\n+00046c80: 3a0a 2020 2020 2020 2020 2320 4841 434b :. # HACK\n+00046c90: 3a20 7364 5f65 7665 6e74 5f61 6464 5f69 : sd_event_add_i\n+00046ca0: 6e6f 7469 6679 5f66 6428 2920 676f 7420 notify_fd() got \n+00046cb0: 6164 6465 6420 696e 2032 3530 2c20 7768 added in 250, wh\n+00046cc0: 6963 6820 6973 2074 6f6f 206e 6577 2e20 ich is too new. \n+00046cd0: 2046 616b 6520 6974 2e0a 2020 2020 2020 Fake it.. \n+00046ce0: 2020 7265 7475 726e 2073 656c 662e 6164 return self.ad\n+00046cf0: 645f 696e 6f74 6966 7928 6627 2f70 726f d_inotify(f'/pro\n+00046d00: 632f 7365 6c66 2f66 642f 7b66 647d 272c c/self/fd/{fd}',\n+00046d10: 206d 6173 6b2c 2068 616e 646c 6572 290a mask, handler).\n+00046d20: 0a0a 2320 5468 6973 2069 7320 616c 6c20 ..# This is all \n+00046d30: 6120 6269 7420 6d6f 7265 2061 776b 7761 a bit more awkwa\n+00046d40: 7264 2074 6861 6e20 6974 2073 686f 756c rd than it shoul\n+00046d50: 6420 6861 7665 2074 6f20 6265 3a20 7379 d have to be: sy\n+00046d60: 7374 656d 6427 7320 6576 656e 740a 2320 stemd's event.# \n+00046d70: 6c6f 6f70 2063 6861 696e 696e 6720 6d6f loop chaining mo\n+00046d80: 6465 6c20 6973 2064 6573 6967 6e65 6420 del is designed \n+00046d90: 666f 7220 676c 6962 2773 2070 7265 7061 for glib's prepa\n+00046da0: 7265 2f63 6865 636b 2f64 6973 7061 7463 re/check/dispatc\n+00046db0: 6820 7061 7261 6469 676d 3b0a 2320 6661 h paradigm;.# fa\n+00046dc0: 696c 696e 6720 746f 2063 616c 6c20 7072 iling to call pr\n+00046dd0: 6570 6172 6528 2920 6361 6e20 6c65 6164 epare() can lead\n+00046de0: 2074 6f20 6465 6164 6c6f 636b 732c 2066 to deadlocks, f\n+00046df0: 6f72 2065 7861 6d70 6c65 2e0a 230a 2320 or example..#.# \n+00046e00: 4861 636b 2061 2073 656c 6563 746f 7220 Hack a selector \n+00046e10: 7375 6263 6c61 7373 2077 6869 6368 2063 subclass which c\n+00046e20: 616c 6c73 2070 7265 7061 7265 2829 2062 alls prepare() b\n+00046e30: 6566 6f72 6520 736c 6565 7069 6e67 2061 efore sleeping a\n+00046e40: 6e64 2074 6869 7320 666f 7220 7573 2e0a nd this for us..\n+00046e50: 636c 6173 7320 5365 6c65 6374 6f72 2873 class Selector(s\n+00046e60: 656c 6563 746f 7273 2e44 6566 6175 6c74 electors.Default\n+00046e70: 5365 6c65 6374 6f72 293a 0a20 2020 2064 Selector):. d\n+00046e80: 6566 205f 5f69 6e69 745f 5f28 7365 6c66 ef __init__(self\n+00046e90: 2c20 6576 656e 743a 204f 7074 696f 6e61 , event: Optiona\n+00046ea0: 6c5b 4576 656e 745d 203d 204e 6f6e 6529 l[Event] = None)\n+00046eb0: 202d 3e20 4e6f 6e65 3a0a 2020 2020 2020 -> None:. \n+00046ec0: 2020 7375 7065 7228 292e 5f5f 696e 6974 super().__init\n+00046ed0: 5f5f 2829 0a20 2020 2020 2020 2073 656c __(). sel\n+00046ee0: 662e 7364 5f65 7665 6e74 203d 2065 7665 f.sd_event = eve\n+00046ef0: 6e74 206f 7220 4576 656e 742e 6465 6661 nt or Event.defa\n+00046f00: 756c 7428 290a 2020 2020 2020 2020 7365 ult(). se\n+00046f10: 6c66 2e6b 6579 203d 2073 656c 662e 7265 lf.key = self.re\n+00046f20: 6769 7374 6572 2873 656c 662e 7364 5f65 gister(self.sd_e\n+00046f30: 7665 6e74 2e67 6574 5f66 6428 292c 2073 vent.get_fd(), s\n+00046f40: 656c 6563 746f 7273 2e45 5645 4e54 5f52 electors.EVENT_R\n+00046f50: 4541 4429 0a0a 2020 2020 6465 6620 7365 EAD).. def se\n+00046f60: 6c65 6374 280a 2020 2020 2020 2020 2020 lect(. \n+00046f70: 2020 7365 6c66 2c20 7469 6d65 6f75 743a self, timeout:\n+00046f80: 204f 7074 696f 6e61 6c5b 666c 6f61 745d Optional[float]\n+00046f90: 203d 204e 6f6e 650a 2020 2020 2920 2d3e = None. ) ->\n+00046fa0: 204c 6973 745b 5475 706c 655b 7365 6c65 List[Tuple[sele\n+00046fb0: 6374 6f72 732e 5365 6c65 6374 6f72 4b65 ctors.SelectorKe\n+00046fc0: 792c 2069 6e74 5d5d 3a0a 2020 2020 2020 y, int]]:. \n+00046fd0: 2020 2320 4974 2773 2063 6f6d 6d6f 6e20 # It's common \n+00046fe0: 746f 2064 726f 7020 7468 6520 6c61 7374 to drop the last\n+00046ff0: 2072 6566 6572 656e 6365 2074 6f20 6120 reference to a \n+00047000: 536f 7572 6365 206f 7220 536c 6f74 206f Source or Slot o\n+00047010: 626a 6563 7420 6f6e 0a20 2020 2020 2020 bject on. \n+00047020: 2023 2061 2064 6973 7061 7463 6820 6f66 # a dispatch of\n+00047030: 2074 6861 7420 7361 6d65 2073 6f75 7263 that same sourc\n+00047040: 652f 736c 6f74 2066 726f 6d20 7468 6520 e/slot from the \n+00047050: 6d61 696e 206c 6f6f 702e 2020 4966 2077 main loop. If w\n+00047060: 6520 6861 7070 656e 0a20 2020 2020 2020 e happen. \n+00047070: 2023 2074 6f20 6761 7262 6167 6520 636f # to garbage co\n+00047080: 6c6c 6563 7420 6265 666f 7265 2072 6574 llect before ret\n+00047090: 7572 6e69 6e67 2c20 7468 6520 7472 616d urning, the tram\n+000470a0: 706f 6c69 6e65 2063 6f75 6c64 2062 650a poline could be.\n+000470b0: 2020 2020 2020 2020 2320 6465 7374 726f # destro\n+000470c0: 7965 6420 6265 666f 7265 2077 6527 7265 yed before we're\n+000470d0: 2064 6f6e 6520 7573 696e 6720 6974 2e20 done using it. \n+000470e0: 2050 726f 7669 6465 2061 206d 6563 6861 Provide a mecha\n+000470f0: 6e69 736d 2074 6f20 6465 6665 720a 2020 nism to defer. \n+00047100: 2020 2020 2020 2320 7468 6520 6465 7374 # the dest\n+00047110: 7275 6374 696f 6e20 6f66 2074 7261 6d70 ruction of tramp\n+00047120: 6f6c 696e 6573 2066 6f72 2061 7320 6c6f olines for as lo\n+00047130: 6e67 2061 7320 7765 206d 6967 6874 2062 ng as we might b\n+00047140: 650a 2020 2020 2020 2020 2320 6469 7370 e. # disp\n+00047150: 6174 6368 696e 672e 2020 5468 6973 2067 atching. This g\n+00047160: 6574 7320 636c 6561 7265 6420 6167 6169 ets cleared agai\n+00047170: 6e20 6174 2074 6865 2062 6f74 746f 6d2c n at the bottom,\n+00047180: 2062 6566 6f72 6520 7265 7475 726e 2e0a before return..\n+00047190: 2020 2020 2020 2020 6c69 6273 7973 7465 libsyste\n+000471a0: 6d64 2e54 7261 6d70 6f6c 696e 652e 6465 md.Trampoline.de\n+000471b0: 6665 7272 6564 203d 205b 5d0a 0a20 2020 ferred = [].. \n+000471c0: 2020 2020 2077 6869 6c65 2073 656c 662e while self.\n+000471d0: 7364 5f65 7665 6e74 2e70 7265 7061 7265 sd_event.prepare\n+000471e0: 2829 3a0a 2020 2020 2020 2020 2020 2020 ():. \n+000471f0: 7365 6c66 2e73 645f 6576 656e 742e 6469 self.sd_event.di\n+00047200: 7370 6174 6368 2829 0a20 2020 2020 2020 spatch(). \n+00047210: 2072 6561 6479 203d 2073 7570 6572 2829 ready = super()\n+00047220: 2e73 656c 6563 7428 7469 6d65 6f75 7429 .select(timeout)\n+00047230: 0a20 2020 2020 2020 2023 2077 6f72 6b61 . # worka\n+00047240: 726f 756e 6420 6874 7470 733a 2f2f 6769 round https://gi\n+00047250: 7468 7562 2e63 6f6d 2f73 7973 7465 6d64 thub.com/systemd\n+00047260: 2f73 7973 7465 6d64 2f69 7373 7565 732f /systemd/issues/\n+00047270: 3233 3832 360a 2020 2020 2020 2020 2320 23826. # \n+00047280: 6b65 6570 2063 616c 6c69 6e67 2077 6169 keep calling wai\n+00047290: 7428 2920 756e 7469 6c20 7468 6572 6527 t() until there'\n+000472a0: 7320 6e6f 7468 696e 6720 6c65 6674 0a20 s nothing left. \n+000472b0: 2020 2020 2020 2077 6869 6c65 2073 656c while sel\n+000472c0: 662e 7364 5f65 7665 6e74 2e77 6169 7428 f.sd_event.wait(\n+000472d0: 3029 3a0a 2020 2020 2020 2020 2020 2020 0):. \n+000472e0: 7365 6c66 2e73 645f 6576 656e 742e 6469 self.sd_event.di\n+000472f0: 7370 6174 6368 2829 0a20 2020 2020 2020 spatch(). \n+00047300: 2020 2020 2077 6869 6c65 2073 656c 662e while self.\n+00047310: 7364 5f65 7665 6e74 2e70 7265 7061 7265 sd_event.prepare\n+00047320: 2829 3a0a 2020 2020 2020 2020 2020 2020 ():. \n+00047330: 2020 2020 7365 6c66 2e73 645f 6576 656e self.sd_even\n+00047340: 742e 6469 7370 6174 6368 2829 0a0a 2020 t.dispatch().. \n+00047350: 2020 2020 2020 2320 5765 2063 616e 2062 # We can b\n+00047360: 6520 7375 7265 2077 6527 7265 206e 6f74 e sure we're not\n+00047370: 2064 6973 7061 7463 6869 6e67 2063 616c dispatching cal\n+00047380: 6c62 6163 6b73 2061 6e79 6d6f 7265 0a20 lbacks anymore. \n+00047390: 2020 2020 2020 206c 6962 7379 7374 656d libsystem\n+000473a0: 642e 5472 616d 706f 6c69 6e65 2e64 6566 d.Trampoline.def\n+000473b0: 6572 7265 6420 3d20 4e6f 6e65 0a0a 2020 erred = None.. \n+000473c0: 2020 2020 2020 2320 5468 6973 2063 6f75 # This cou\n+000473d0: 6c64 2072 6574 7572 6e20 7a65 726f 2065 ld return zero e\n+000473e0: 7665 6e74 7320 7769 7468 2069 6e66 696e vents with infin\n+000473f0: 6974 6520 7469 6d65 6f75 742c 2062 7574 ite timeout, but\n+00047400: 206e 6f62 6f64 7920 7365 656d 7320 746f nobody seems to\n+00047410: 206d 696e 642e 0a20 2020 2020 2020 2072 mind.. r\n+00047420: 6574 7572 6e20 5b28 6b65 792c 2065 7665 eturn [(key, eve\n+00047430: 6e74 7329 2066 6f72 2028 6b65 792c 2065 nts) for (key, e\n+00047440: 7665 6e74 7329 2069 6e20 7265 6164 7920 vents) in ready \n+00047450: 6966 206b 6579 2021 3d20 7365 6c66 2e6b if key != self.k\n+00047460: 6579 5d0a 0a0a 636c 6173 7320 4576 656e ey]...class Even\n+00047470: 744c 6f6f 7050 6f6c 6963 7928 6173 796e tLoopPolicy(asyn\n+00047480: 6369 6f2e 4465 6661 756c 7445 7665 6e74 cio.DefaultEvent\n+00047490: 4c6f 6f70 506f 6c69 6379 293a 0a20 2020 LoopPolicy):. \n+000474a0: 2064 6566 206e 6577 5f65 7665 6e74 5f6c def new_event_l\n+000474b0: 6f6f 7028 7365 6c66 2920 2d3e 2061 7379 oop(self) -> asy\n+000474c0: 6e63 696f 2e41 6273 7472 6163 7445 7665 ncio.AbstractEve\n+000474d0: 6e74 4c6f 6f70 3a0a 2020 2020 2020 2020 ntLoop:. \n+000474e0: 7265 7475 726e 2061 7379 6e63 696f 2e53 return asyncio.S\n+000474f0: 656c 6563 746f 7245 7665 6e74 4c6f 6f70 electorEventLoop\n+00047500: 2853 656c 6563 746f 7228 2929 0a0a 0a64 (Selector())...d\n+00047510: 6566 2072 756e 5f61 7379 6e63 286d 6169 ef run_async(mai\n+00047520: 6e3a 2043 6f72 6f75 7469 6e65 5b4e 6f6e n: Coroutine[Non\n+00047530: 652c 204e 6f6e 652c 204e 6f6e 655d 2c20 e, None, None], \n+00047540: 6465 6275 673a 204f 7074 696f 6e61 6c5b debug: Optional[\n+00047550: 626f 6f6c 5d20 3d20 4e6f 6e65 2920 2d3e bool] = None) ->\n+00047560: 204e 6f6e 653a 0a20 2020 2061 7379 6e63 None:. async\n+00047570: 696f 2e73 6574 5f65 7665 6e74 5f6c 6f6f io.set_event_loo\n+00047580: 705f 706f 6c69 6379 2845 7665 6e74 4c6f p_policy(EventLo\n+00047590: 6f70 506f 6c69 6379 2829 290a 0a20 2020 opPolicy()).. \n+000475a0: 2070 6f6c 7966 696c 6c20 3d20 7379 732e polyfill = sys.\n+000475b0: 7665 7273 696f 6e5f 696e 666f 203c 2028 version_info < (\n+000475c0: 332c 2037 2c20 3029 2061 6e64 206e 6f74 3, 7, 0) and not\n+000475d0: 2068 6173 6174 7472 2861 7379 6e63 696f hasattr(asyncio\n+000475e0: 2c20 2772 756e 2729 0a20 2020 2069 6620 , 'run'). if \n+000475f0: 706f 6c79 6669 6c6c 3a0a 2020 2020 2020 polyfill:. \n+00047600: 2020 2320 506f 6c79 6669 6c6c 7320 666f # Polyfills fo\n+00047610: 7220 5079 7468 6f6e 2033 2e36 3a0a 2020 r Python 3.6:. \n+00047620: 2020 2020 2020 6c6f 6f70 203d 2061 7379 loop = asy\n+00047630: 6e63 696f 2e67 6574 5f65 7665 6e74 5f6c ncio.get_event_l\n+00047640: 6f6f 7028 290a 0a20 2020 2020 2020 2061 oop().. a\n+00047650: 7373 6572 7420 6e6f 7420 6861 7361 7474 ssert not hasatt\n+00047660: 7228 6173 796e 6369 6f2c 2027 6765 745f r(asyncio, 'get_\n+00047670: 7275 6e6e 696e 675f 6c6f 6f70 2729 0a20 running_loop'). \n+00047680: 2020 2020 2020 2061 7379 6e63 696f 2e67 asyncio.g\n+00047690: 6574 5f72 756e 6e69 6e67 5f6c 6f6f 7020 et_running_loop \n+000476a0: 3d20 6c61 6d62 6461 3a20 6c6f 6f70 0a0a = lambda: loop..\n+000476b0: 2020 2020 2020 2020 6173 7365 7274 206e assert n\n+000476c0: 6f74 2068 6173 6174 7472 2861 7379 6e63 ot hasattr(async\n+000476d0: 696f 2c20 2763 7265 6174 655f 7461 736b io, 'create_task\n+000476e0: 2729 0a20 2020 2020 2020 2061 7379 6e63 '). async\n+000476f0: 696f 2e63 7265 6174 655f 7461 736b 203d io.create_task =\n+00047700: 206c 6f6f 702e 6372 6561 7465 5f74 6173 loop.create_tas\n+00047710: 6b0a 0a20 2020 2020 2020 2061 7373 6572 k.. asser\n+00047720: 7420 6e6f 7420 6861 7361 7474 7228 6173 t not hasattr(as\n+00047730: 796e 6369 6f2c 2027 7275 6e27 290a 0a20 yncio, 'run').. \n+00047740: 2020 2020 2020 2064 6566 2072 756e 280a def run(.\n+00047750: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00047760: 6d61 696e 3a20 436f 726f 7574 696e 655b main: Coroutine[\n+00047770: 4e6f 6e65 2c20 4e6f 6e65 2c20 4e6f 6e65 None, None, None\n+00047780: 5d2c 2064 6562 7567 3a20 4f70 7469 6f6e ], debug: Option\n+00047790: 616c 5b62 6f6f 6c5d 203d 204e 6f6e 650a al[bool] = None.\n+000477a0: 2020 2020 2020 2020 2920 2d3e 204e 6f6e ) -> Non\n+000477b0: 653a 0a20 2020 2020 2020 2020 2020 2069 e:. i\n+000477c0: 6620 6465 6275 6720 6973 206e 6f74 204e f debug is not N\n+000477d0: 6f6e 653a 0a20 2020 2020 2020 2020 2020 one:. \n+000477e0: 2020 2020 206c 6f6f 702e 7365 745f 6465 loop.set_de\n+000477f0: 6275 6728 6465 6275 6729 0a20 2020 2020 bug(debug). \n+00047800: 2020 2020 2020 206c 6f6f 702e 7275 6e5f loop.run_\n+00047810: 756e 7469 6c5f 636f 6d70 6c65 7465 286d until_complete(m\n+00047820: 6169 6e29 0a0a 2020 2020 2020 2020 6173 ain).. as\n+00047830: 796e 6369 6f2e 7275 6e20 3d20 7275 6e20 yncio.run = run \n+00047840: 2023 2074 7970 653a 2069 676e 6f72 655b # type: ignore[\n+00047850: 6173 7369 676e 6d65 6e74 5d0a 0a20 2020 assignment].. \n+00047860: 2020 2020 2061 7379 6e63 696f 2e5f 7379 asyncio._sy\n+00047870: 7374 656d 645f 6374 7970 6573 5f70 6f6c stemd_ctypes_pol\n+00047880: 7966 696c 6c73 203d 2054 7275 6520 2023 yfills = True #\n+00047890: 2074 7970 653a 2069 676e 6f72 655b 6174 type: ignore[at\n+000478a0: 7472 2d64 6566 696e 6564 5d0a 0a20 2020 tr-defined].. \n+000478b0: 2061 7379 6e63 696f 2e72 756e 286d 6169 asyncio.run(mai\n+000478c0: 6e2c 2064 6562 7567 3d64 6562 7567 290a n, debug=debug).\n+000478d0: 0a20 2020 2069 6620 706f 6c79 6669 6c6c . if polyfill\n+000478e0: 3a0a 2020 2020 2020 2020 6465 6c20 6173 :. del as\n+000478f0: 796e 6369 6f2e 6372 6561 7465 5f74 6173 yncio.create_tas\n+00047900: 6b2c 2061 7379 6e63 696f 2e67 6574 5f72 k, asyncio.get_r\n+00047910: 756e 6e69 6e67 5f6c 6f6f 702c 2061 7379 unning_loop, asy\n+00047920: 6e63 696f 2e72 756e 0a27 2727 2c0a 2020 ncio.run.''',. \n+00047930: 2763 6f63 6b70 6974 2f5f 7665 6e64 6f72 'cockpit/_vendor\n+00047940: 2f73 7973 7465 6d64 5f63 7479 7065 732f /systemd_ctypes/\n+00047950: 7079 2e74 7970 6564 273a 2062 7227 2727 py.typed': br'''\n+00047960: 2727 272c 0a20 2027 636f 636b 7069 742f ''',. 'cockpit/\n+00047970: 5f76 656e 646f 722f 7379 7374 656d 645f _vendor/systemd_\n+00047980: 6374 7970 6573 2f70 6174 6877 6174 6368 ctypes/pathwatch\n+00047990: 2e70 7927 3a20 6272 2727 2723 2073 7973 .py': br'''# sys\n+000479a0: 7465 6d64 5f63 7479 7065 730a 230a 2320 temd_ctypes.#.# \n+000479b0: 436f 7079 7269 6768 7420 2843 2920 3230 Copyright (C) 20\n+000479c0: 3232 2041 6c6c 6973 6f6e 204b 6172 6c69 22 Allison Karli\n+000479d0: 7473 6b61 7961 203c 616c 6c69 736f 6e2e tskaya <allison.\n+000479e0: 6b61 726c 6974 736b 6179 6140 7265 6468 karlitskaya@redh\n+000479f0: 6174 2e63 6f6d 3e0a 230a 2320 5468 6973 at.com>.#.# This\n+00047a00: 2070 726f 6772 616d 2069 7320 6672 6565 program is free\n+00047a10: 2073 6f66 7477 6172 653a 2079 6f75 2063 software: you c\n+00047a20: 616e 2072 6564 6973 7472 6962 7574 6520 an redistribute \n+00047a30: 6974 2061 6e64 2f6f 7220 6d6f 6469 6679 it and/or modify\n+00047a40: 0a23 2069 7420 756e 6465 7220 7468 6520 .# it under the \n+00047a50: 7465 726d 7320 6f66 2074 6865 2047 4e55 terms of the GNU\n+00047a60: 2047 656e 6572 616c 2050 7562 6c69 6320 General Public \n+00047a70: 4c69 6365 6e73 6520 6173 2070 7562 6c69 License as publi\n+00047a80: 7368 6564 2062 790a 2320 7468 6520 4672 shed by.# the Fr\n+00047a90: 6565 2053 6f66 7477 6172 6520 466f 756e ee Software Foun\n+00047aa0: 6461 7469 6f6e 2c20 6569 7468 6572 2076 dation, either v\n+00047ab0: 6572 7369 6f6e 2033 206f 6620 7468 6520 ersion 3 of the \n+00047ac0: 4c69 6365 6e73 652c 206f 720a 2320 2861 License, or.# (a\n+00047ad0: 7420 796f 7572 206f 7074 696f 6e29 2061 t your option) a\n+00047ae0: 6e79 206c 6174 6572 2076 6572 7369 6f6e ny later version\n+00047af0: 2e0a 230a 2320 5468 6973 2070 726f 6772 ..#.# This progr\n+00047b00: 616d 2069 7320 6469 7374 7269 6275 7465 am is distribute\n+00047b10: 6420 696e 2074 6865 2068 6f70 6520 7468 d in the hope th\n+00047b20: 6174 2069 7420 7769 6c6c 2062 6520 7573 at it will be us\n+00047b30: 6566 756c 2c0a 2320 6275 7420 5749 5448 eful,.# but WITH\n+00047b40: 4f55 5420 414e 5920 5741 5252 414e 5459 OUT ANY WARRANTY\n+00047b50: 3b20 7769 7468 6f75 7420 6576 656e 2074 ; without even t\n+00047b60: 6865 2069 6d70 6c69 6564 2077 6172 7261 he implied warra\n+00047b70: 6e74 7920 6f66 0a23 204d 4552 4348 414e nty of.# MERCHAN\n+00047b80: 5441 4249 4c49 5459 206f 7220 4649 544e TABILITY or FITN\n+00047b90: 4553 5320 464f 5220 4120 5041 5254 4943 ESS FOR A PARTIC\n+00047ba0: 554c 4152 2050 5552 504f 5345 2e20 2053 ULAR PURPOSE. S\n+00047bb0: 6565 2074 6865 0a23 2047 4e55 2047 656e ee the.# GNU Gen\n+00047bc0: 6572 616c 2050 7562 6c69 6320 4c69 6365 eral Public Lice\n+00047bd0: 6e73 6520 666f 7220 6d6f 7265 2064 6574 nse for more det\n+00047be0: 6169 6c73 2e0a 230a 2320 596f 7520 7368 ails..#.# You sh\n+00047bf0: 6f75 6c64 2068 6176 6520 7265 6365 6976 ould have receiv\n+00047c00: 6564 2061 2063 6f70 7920 6f66 2074 6865 ed a copy of the\n+00047c10: 2047 4e55 2047 656e 6572 616c 2050 7562 GNU General Pub\n+00047c20: 6c69 6320 4c69 6365 6e73 650a 2320 616c lic License.# al\n+00047c30: 6f6e 6720 7769 7468 2074 6869 7320 7072 ong with this pr\n+00047c40: 6f67 7261 6d2e 2020 4966 206e 6f74 2c20 ogram. If not, \n+00047c50: 7365 6520 3c68 7474 703a 2f2f 7777 772e see <http://www.\n+00047c60: 676e 752e 6f72 672f 6c69 6365 6e73 6573 gnu.org/licenses\n+00047c70: 2f3e 2e0a 0a69 6d70 6f72 7420 6572 726e />...import errn\n+00047c80: 6f0a 696d 706f 7274 206c 6f67 6769 6e67 o.import logging\n+00047c90: 0a69 6d70 6f72 7420 6f73 0a69 6d70 6f72 .import os.impor\n+00047ca0: 7420 7374 6174 0a66 726f 6d20 7479 7069 t stat.from typi\n+00047cb0: 6e67 2069 6d70 6f72 7420 416e 792c 204c ng import Any, L\n+00047cc0: 6973 742c 204f 7074 696f 6e61 6c0a 0a66 ist, Optional..f\n+00047cd0: 726f 6d20 2e65 7665 6e74 2069 6d70 6f72 rom .event impor\n+00047ce0: 7420 4576 656e 740a 6672 6f6d 202e 696e t Event.from .in\n+00047cf0: 6f74 6966 7920 696d 706f 7274 2045 7665 otify import Eve\n+00047d00: 6e74 2061 7320 494e 0a0a 6c6f 6767 6572 nt as IN..logger\n+00047d10: 203d 206c 6f67 6769 6e67 2e67 6574 4c6f = logging.getLo\n+00047d20: 6767 6572 285f 5f6e 616d 655f 5f29 0a0a gger(__name__)..\n+00047d30: 0a23 2069 6e6f 7469 6679 2068 6172 6420 .# inotify hard \n+00047d40: 6661 6374 733a 0a23 0a23 2044 454c 4554 facts:.#.# DELET\n+00047d50: 455f 5345 4c46 2064 6f65 736e 2774 2067 E_SELF doesn't g\n+00047d60: 6574 2063 616c 6c65 6420 756e 7469 6c20 et called until \n+00047d70: 616c 6c20 7265 6665 7265 6e63 6573 2074 all references t\n+00047d80: 6f20 616e 2069 6e6f 6465 2061 7265 2067 o an inode are g\n+00047d90: 6f6e 650a 2320 2020 2d20 696e 636c 7564 one.# - includ\n+00047da0: 696e 6720 6f70 656e 2066 6473 0a23 2020 ing open fds.# \n+00047db0: 202d 2069 6e63 6c75 6469 6e67 206f 6e20 - including on \n+00047dc0: 6469 7265 6374 6f72 6965 730a 230a 2320 directories.#.# \n+00047dd0: 4154 5452 4942 2067 6574 7320 6361 6c6c ATTRIB gets call\n+00047de0: 6564 2077 6865 6e20 756e 6c69 6e6b 696e ed when unlinkin\n+00047df0: 6720 6669 6c65 7320 2862 6563 6175 7365 g files (because\n+00047e00: 2074 6865 206c 696e 6b20 636f 756e 7420 the link count \n+00047e10: 6368 616e 6765 7329 2062 7574 0a23 206e changes) but.# n\n+00047e20: 6f74 206f 6e20 6469 7265 6374 6f72 6965 ot on directorie\n+00047e30: 732e 2020 5768 656e 2075 6e6c 696e 6b69 s. When unlinki\n+00047e40: 6e67 2061 6e20 6f70 656e 2064 6972 6563 ng an open direc\n+00047e50: 746f 7279 2c20 6e6f 2065 7665 6e74 7320 tory, no events \n+00047e60: 6174 2061 6c6c 0a23 2068 6170 7065 6e20 at all.# happen \n+00047e70: 6f6e 2074 6865 2064 6972 6563 746f 7279 on the directory\n+00047e80: 2e20 2041 5454 5249 4220 616c 736f 2063 . ATTRIB also c\n+00047e90: 6f6c 6c65 6374 7320 6368 696c 6420 6576 ollects child ev\n+00047ea0: 656e 7473 2c20 7768 6963 6820 6d65 616e ents, which mean\n+00047eb0: 7320 7765 0a23 2067 6574 2061 206c 6f74 s we.# get a lot\n+00047ec0: 206f 6620 756e 7761 6e74 6564 206e 6f69 of unwanted noi\n+00047ed0: 7365 2e0a 230a 2320 5468 6572 6527 7320 se..#.# There's \n+00047ee0: 6e6f 7468 696e 6720 6c69 6b65 2055 4e4c nothing like UNL\n+00047ef0: 494e 4b5f 5345 4c46 2c20 756e 666f 7274 INK_SELF, unfort\n+00047f00: 756e 6174 656c 792e 0a23 0a23 2045 7665 unately..#.# Eve\n+00047f10: 6e20 6966 2069 7420 7761 7320 706f 7373 n if it was poss\n+00047f20: 6962 6c65 2074 6f20 7461 6b65 2074 6869 ible to take thi\n+00047f30: 7320 6170 7072 6f61 6368 2c20 6974 206d s approach, it m\n+00047f40: 6967 6874 206e 6f74 2077 6f72 6b3a 2061 ight not work: a\n+00047f50: 6674 6572 0a23 2079 6f75 2776 6520 6f70 fter.# you've op\n+00047f60: 656e 6564 2074 6865 2066 642c 2069 7420 ened the fd, it \n+00047f70: 6d69 6768 7420 6765 7420 6465 6c65 7465 might get delete\n+00047f80: 6420 6265 666f 7265 2079 6f75 2063 616e d before you can\n+00047f90: 2065 7374 6162 6c69 7368 2074 6865 2077 establish the w\n+00047fa0: 6174 6368 0a23 206f 6e20 6974 2e0a 230a atch.# on it..#.\n+00047fb0: 2320 4164 6469 7469 6f6e 616c 6c79 2c20 # Additionally, \n+00047fc0: 7379 7374 656d 6420 6d61 6b65 7320 6974 systemd makes it\n+00047fd0: 2069 6d70 6f73 7369 626c 6520 746f 2072 impossible to r\n+00047fe0: 6567 6973 7465 7220 7468 6f73 6520 6576 egister those ev\n+00047ff0: 656e 7473 206f 6e0a 2320 7379 6d6c 696e ents on.# symlin\n+00048000: 6b73 2028 6265 6361 7573 6520 6974 2072 ks (because it r\n+00048010: 656d 6f76 6573 2049 4e5f 444f 4e54 5f46 emoves IN_DONT_F\n+00048020: 4f4c 4c4f 5720 696e 206f 7264 6572 2074 OLLOW in order t\n+00048030: 6f20 7761 7463 6820 7669 610a 2320 2f70 o watch via.# /p\n+00048040: 726f 632f 7365 6c66 2f66 6429 2e0a 230a roc/self/fd)..#.\n+00048050: 2320 466f 7220 616c 6c20 6f66 2074 6865 # For all of the\n+00048060: 7365 2072 6561 736f 6e73 2c20 756e 666f se reasons, unfo\n+00048070: 7274 756e 6174 656c 792c 2074 6865 2062 rtunately, the b\n+00048080: 6573 7420 7761 7920 7365 656d 7320 746f est way seems to\n+00048090: 2062 6520 746f 2077 6174 6368 0a23 2066 be to watch.# f\n+000480a0: 6f72 2043 5245 4154 457c 4445 4c45 5445 or CREATE|DELETE\n+000480b0: 7c4d 4f56 4520 6576 656e 7473 206f 6e20 |MOVE events on \n+000480c0: 6561 6368 2069 6e74 6572 6d65 6469 6174 each intermediat\n+000480d0: 6520 6469 7265 6374 6f72 792e 0a23 0a23 e directory..#.#\n+000480e0: 2055 6e66 6f72 7475 6e61 7465 6c79 2074 Unfortunately t\n+000480f0: 6865 7265 2069 7320 6e6f 2077 6179 2074 here is no way t\n+00048100: 6f20 6669 6c74 6572 2074 6f20 6f6e 6c79 o filter to only\n+00048110: 2074 6865 206e 616d 6520 7765 2772 6520 the name we're \n+00048120: 696e 7465 7265 7374 6564 2069 6e2c 0a23 interested in,.#\n+00048130: 2073 6f20 7765 2772 6520 676f 6e6e 6120 so we're gonna \n+00048140: 6765 7420 6120 6c6f 7420 6f66 2075 6e6e get a lot of unn\n+00048150: 6563 6573 7361 7279 2077 616b 6575 7073 ecessary wakeups\n+00048160: 2e0a 230a 2320 416c 736f 3a20 6475 6520 ..#.# Also: due \n+00048170: 746f 2074 6865 2061 626f 7665 2d6d 656e to the above-men\n+00048180: 7469 6f6e 6564 2072 6163 6520 6162 6f75 tioned race abou\n+00048190: 7420 7761 7463 6869 6e67 2061 6674 6572 t watching after\n+000481a0: 206f 7065 6e69 6e67 2074 6865 2066 642c opening the fd,\n+000481b0: 0a23 206c 6574 2773 206a 7573 7420 616c .# let's just al\n+000481c0: 7761 7973 2077 6174 6368 2066 6f72 2062 ways watch for b\n+000481d0: 6f74 6820 6372 6561 7465 2061 6e64 2064 oth create and d\n+000481e0: 656c 6574 6520 6576 656e 7473 202a 6265 elete events *be\n+000481f0: 666f 7265 2a20 7472 7969 6e67 2074 6f0a fore* trying to.\n+00048200: 2320 6f70 656e 2074 6865 2066 642e 2020 # open the fd. \n+00048210: 5765 2063 6f75 6c64 2074 7279 2074 6f20 We could try to \n+00048220: 7265 6475 6365 2074 6865 206d 6173 6b20 reduce the mask \n+00048230: 6166 7465 7220 7468 6520 6661 6374 2c20 after the fact, \n+00048240: 6275 7420 6d65 682e 2e2e 0a23 0a23 2057 but meh....#.# W\n+00048250: 6520 7573 6520 6120 5761 7463 6849 6e76 e use a WatchInv\n+00048260: 616c 6964 6174 6f72 2075 7469 6c69 7479 alidator utility\n+00048270: 2063 6c61 7373 2074 6f20 6669 6c6c 2074 class to fill t\n+00048280: 6865 2072 6f6c 6520 6f66 2022 5465 6c6c he role of \"Tell\n+00048290: 206d 6520 7768 656e 2061 6e0a 2320 6576 me when an.# ev\n+000482a0: 656e 7420 6861 7070 656e 6564 206f 6e20 ent happened on \n+000482b0: 7468 6973 2028 6469 7265 6374 6f72 7929 this (directory)\n+000482c0: 2066 6420 7768 6963 6820 696d 7061 6374 fd which impact\n+000482d0: 6564 2074 6865 206e 616d 6520 6669 6c65 ed the name file\n+000482e0: 222e 2020 5765 0a23 2062 7569 6c64 2061 \". We.# build a\n+000482f0: 2073 6572 6965 7320 6f66 2074 6865 7365 series of these\n+00048300: 2077 6865 6e20 7365 7474 696e 6720 7570 when setting up\n+00048310: 2061 2077 6174 6368 2069 6e20 6f72 6465 a watch in orde\n+00048320: 7220 746f 2066 696e 6420 6f75 7420 6966 r to find out if\n+00048330: 2061 6e79 0a23 2070 6172 7420 6f66 2074 any.# part of t\n+00048340: 6865 2070 6174 6820 6c65 6164 696e 6720 he path leading \n+00048350: 746f 2074 6865 206d 6f6e 6974 6f72 6564 to the monitored\n+00048360: 2066 696c 6520 6368 616e 6765 642e 0a0a file changed...\n+00048370: 0a63 6c61 7373 2048 616e 646c 6528 696e .class Handle(in\n+00048380: 7429 3a0a 2020 2020 2222 2241 6e20 696e t):. \"\"\"An in\n+00048390: 7465 6765 7220 7375 6263 6c61 7373 2074 teger subclass t\n+000483a0: 6861 7420 6d61 6b65 7320 6974 2065 6173 hat makes it eas\n+000483b0: 6965 7220 746f 2077 6f72 6b20 7769 7468 ier to work with\n+000483c0: 2066 696c 6520 6465 7363 7269 7074 6f72 file descriptor\n+000483d0: 7322 2222 0a0a 2020 2020 6465 6620 5f5f s\"\"\".. def __\n+000483e0: 6e65 775f 5f28 636c 732c 2066 643a 2069 new__(cls, fd: i\n+000483f0: 6e74 203d 202d 3129 202d 3e20 2748 616e nt = -1) -> 'Han\n+00048400: 646c 6527 3a0a 2020 2020 2020 2020 7265 dle':. re\n+00048410: 7475 726e 2073 7570 6572 2848 616e 646c turn super(Handl\n+00048420: 652c 2063 6c73 292e 5f5f 6e65 775f 5f28 e, cls).__new__(\n+00048430: 636c 732c 2066 6429 0a0a 2020 2020 2320 cls, fd).. # \n+00048440: 7365 7061 7261 7465 205f 5f69 6e69 745f separate __init_\n+00048450: 5f28 2920 746f 2073 6574 205f 6e65 6564 _() to set _need\n+00048460: 735f 636c 6f73 6520 6d6f 7374 6c79 2074 s_close mostly t\n+00048470: 6f20 6b65 6570 2070 796c 696e 7420 7175 o keep pylint qu\n+00048480: 6965 740a 2020 2020 6465 6620 5f5f 696e iet. def __in\n+00048490: 6974 5f5f 2873 656c 662c 2066 643a 2069 it__(self, fd: i\n+000484a0: 6e74 203d 202d 3129 3a0a 2020 2020 2020 nt = -1):. \n+000484b0: 2020 7375 7065 7228 292e 5f5f 696e 6974 super().__init\n+000484c0: 5f5f 2829 0a20 2020 2020 2020 2073 656c __(). sel\n+000484d0: 662e 5f6e 6565 6473 5f63 6c6f 7365 203d f._needs_close =\n+000484e0: 2066 6420 213d 202d 310a 0a20 2020 2064 fd != -1.. d\n+000484f0: 6566 205f 5f62 6f6f 6c5f 5f28 7365 6c66 ef __bool__(self\n+00048500: 2920 2d3e 2062 6f6f 6c3a 0a20 2020 2020 ) -> bool:. \n+00048510: 2020 2072 6574 7572 6e20 7365 6c66 2021 return self !\n+00048520: 3d20 2d31 0a0a 2020 2020 6465 6620 636c = -1.. def cl\n+00048530: 6f73 6528 7365 6c66 2920 2d3e 204e 6f6e ose(self) -> Non\n+00048540: 653a 0a20 2020 2020 2020 2069 6620 7365 e:. if se\n+00048550: 6c66 2e5f 6e65 6564 735f 636c 6f73 653a lf._needs_close:\n+00048560: 0a20 2020 2020 2020 2020 2020 2073 656c . sel\n+00048570: 662e 5f6e 6565 6473 5f63 6c6f 7365 203d f._needs_close =\n+00048580: 2046 616c 7365 0a20 2020 2020 2020 2020 False. \n+00048590: 2020 206f 732e 636c 6f73 6528 7365 6c66 os.close(self\n+000485a0: 290a 0a20 2020 2064 6566 205f 5f65 715f ).. def __eq_\n+000485b0: 5f28 7365 6c66 2c20 7661 6c75 653a 206f _(self, value: o\n+000485c0: 626a 6563 7429 202d 3e20 626f 6f6c 3a0a bject) -> bool:.\n+000485d0: 2020 2020 2020 2020 6966 2069 6e74 2e5f if int._\n+000485e0: 5f65 715f 5f28 7365 6c66 2c20 7661 6c75 _eq__(self, valu\n+000485f0: 6529 3a20 2023 2061 6c73 6f20 6861 6e64 e): # also hand\n+00048600: 6c65 7320 626f 7468 203d 3d20 2d31 0a20 les both == -1. \n+00048610: 2020 2020 2020 2020 2020 2072 6574 7572 retur\n+00048620: 6e20 5472 7565 0a0a 2020 2020 2020 2020 n True.. \n+00048630: 6966 206e 6f74 2069 7369 6e73 7461 6e63 if not isinstanc\n+00048640: 6528 7661 6c75 652c 2069 6e74 293a 2020 e(value, int): \n+00048650: 2320 6f74 6865 7220 6f62 6a65 6374 2069 # other object i\n+00048660: 7320 6e6f 7420 616e 2069 6e74 0a20 2020 s not an int. \n+00048670: 2020 2020 2020 2020 2072 6574 7572 6e20 return \n+00048680: 4661 6c73 650a 0a20 2020 2020 2020 2069 False.. i\n+00048690: 6620 6e6f 7420 7365 6c66 206f 7220 6e6f f not self or no\n+000486a0: 7420 7661 6c75 653a 2020 2320 7768 656e t value: # when\n+000486b0: 206f 6e6c 7920 6f6e 6520 3d3d 202d 310a only one == -1.\n+000486c0: 2020 2020 2020 2020 2020 2020 7265 7475 retu\n+000486d0: 726e 2046 616c 7365 0a0a 2020 2020 2020 rn False.. \n+000486e0: 2020 7265 7475 726e 206f 732e 7061 7468 return os.path\n+000486f0: 2e73 616d 656f 7065 6e66 696c 6528 7365 .sameopenfile(se\n+00048700: 6c66 2c20 7661 6c75 6529 0a0a 2020 2020 lf, value).. \n+00048710: 6465 6620 5f5f 6465 6c5f 5f28 7365 6c66 def __del__(self\n+00048720: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n+00048730: 2020 2069 6620 7365 6c66 2e5f 6e65 6564 if self._need\n+00048740: 735f 636c 6f73 653a 0a20 2020 2020 2020 s_close:. \n+00048750: 2020 2020 2073 656c 662e 636c 6f73 6528 self.close(\n+00048760: 290a 0a20 2020 2064 6566 205f 5f65 6e74 ).. def __ent\n+00048770: 6572 5f5f 2873 656c 6629 202d 3e20 2748 er__(self) -> 'H\n+00048780: 616e 646c 6527 3a0a 2020 2020 2020 2020 andle':. \n+00048790: 7265 7475 726e 2073 656c 660a 0a20 2020 return self.. \n+000487a0: 2064 6566 205f 5f65 7869 745f 5f28 7365 def __exit__(se\n+000487b0: 6c66 2c20 5f74 7970 653a 2074 7970 652c lf, _type: type,\n+000487c0: 205f 7661 6c75 653a 206f 626a 6563 742c _value: object,\n+000487d0: 205f 7472 6163 6562 6163 6b3a 206f 626a _traceback: obj\n+000487e0: 6563 7429 202d 3e20 4e6f 6e65 3a0a 2020 ect) -> None:. \n+000487f0: 2020 2020 2020 7365 6c66 2e63 6c6f 7365 self.close\n+00048800: 2829 0a0a 2020 2020 4063 6c61 7373 6d65 ().. @classme\n+00048810: 7468 6f64 0a20 2020 2064 6566 206f 7065 thod. def ope\n+00048820: 6e28 636c 732c 202a 6172 6773 3a20 416e n(cls, *args: An\n+00048830: 792c 202a 2a6b 7761 7267 733a 2041 6e79 y, **kwargs: Any\n+00048840: 2920 2d3e 2027 4861 6e64 6c65 273a 0a20 ) -> 'Handle':. \n+00048850: 2020 2020 2020 2072 6574 7572 6e20 636c return cl\n+00048860: 7328 6f73 2e6f 7065 6e28 2a61 7267 732c s(os.open(*args,\n+00048870: 202a 2a6b 7761 7267 7329 290a 0a20 2020 **kwargs)).. \n+00048880: 2064 6566 2073 7465 616c 2873 656c 6629 def steal(self)\n+00048890: 202d 3e20 2748 616e 646c 6527 3a0a 2020 -> 'Handle':. \n+000488a0: 2020 2020 2020 7365 6c66 2e5f 6e65 6564 self._need\n+000488b0: 735f 636c 6f73 6520 3d20 4661 6c73 650a s_close = False.\n+000488c0: 2020 2020 2020 2020 7265 7475 726e 2073 return s\n+000488d0: 656c 662e 5f5f 636c 6173 735f 5f28 696e elf.__class__(in\n+000488e0: 7428 7365 6c66 2929 0a0a 0a63 6c61 7373 t(self))...class\n+000488f0: 2057 6174 6368 496e 7661 6c69 6461 746f WatchInvalidato\n+00048900: 723a 0a20 2020 205f 6e61 6d65 3a20 6279 r:. _name: by\n+00048910: 7465 730a 2020 2020 5f73 6f75 7263 653a tes. _source:\n+00048920: 204f 7074 696f 6e61 6c5b 4576 656e 742e Optional[Event.\n+00048930: 536f 7572 6365 5d0a 2020 2020 5f77 6174 Source]. _wat\n+00048940: 6368 3a20 4f70 7469 6f6e 616c 5b27 5061 ch: Optional['Pa\n+00048950: 7468 5761 7463 6827 5d0a 0a20 2020 2064 thWatch'].. d\n+00048960: 6566 2065 7665 6e74 2873 656c 662c 206d ef event(self, m\n+00048970: 6173 6b3a 2049 4e2c 205f 636f 6f6b 6965 ask: IN, _cookie\n+00048980: 3a20 696e 742c 206e 616d 653a 204f 7074 : int, name: Opt\n+00048990: 696f 6e61 6c5b 6279 7465 735d 2920 2d3e ional[bytes]) ->\n+000489a0: 204e 6f6e 653a 0a20 2020 2020 2020 206c None:. l\n+000489b0: 6f67 6765 722e 6465 6275 6728 2769 6e76 ogger.debug('inv\n+000489c0: 616c 6964 6174 6f72 2065 7665 6e74 2025 alidator event %\n+000489d0: 7320 2573 272c 206d 6173 6b2c 206e 616d s %s', mask, nam\n+000489e0: 6529 0a20 2020 2020 2020 2069 6620 7365 e). if se\n+000489f0: 6c66 2e5f 7761 7463 6820 6973 206e 6f74 lf._watch is not\n+00048a00: 204e 6f6e 653a 0a20 2020 2020 2020 2020 None:. \n+00048a10: 2020 2023 2049 6620 7468 6973 206e 6f64 # If this nod\n+00048a20: 6520 6974 7365 6c66 2064 6973 6170 7065 e itself disappe\n+00048a30: 6172 6564 2c20 7468 6174 2773 2064 6566 ared, that's def\n+00048a40: 696e 6974 656c 7920 616e 0a20 2020 2020 initely an. \n+00048a50: 2020 2020 2020 2023 2069 6e76 616c 6964 # invalid\n+00048a60: 6174 696f 6e2e 2020 4f74 6865 7277 6973 ation. Otherwis\n+00048a70: 652c 2074 6865 206e 616d 6520 6e65 6564 e, the name need\n+00048a80: 7320 746f 206d 6174 6368 2e0a 2020 2020 s to match.. \n+00048a90: 2020 2020 2020 2020 6966 2049 4e2e 4947 if IN.IG\n+00048aa0: 4e4f 5245 4420 696e 206d 6173 6b20 6f72 NORED in mask or\n+00048ab0: 2073 656c 662e 5f6e 616d 6520 3d3d 206e self._name == n\n+00048ac0: 616d 653a 0a20 2020 2020 2020 2020 2020 ame:. \n+00048ad0: 2020 2020 206c 6f67 6765 722e 6465 6275 logger.debu\n+00048ae0: 6728 2749 6e76 616c 6964 6174 696e 6721 g('Invalidating!\n+00048af0: 2729 0a20 2020 2020 2020 2020 2020 2020 '). \n+00048b00: 2020 2073 656c 662e 5f77 6174 6368 2e69 self._watch.i\n+00048b10: 6e76 616c 6964 6174 6528 290a 0a20 2020 nvalidate().. \n+00048b20: 2064 6566 205f 5f69 6e69 745f 5f28 7365 def __init__(se\n+00048b30: 6c66 2c20 7761 7463 683a 2027 5061 7468 lf, watch: 'Path\n+00048b40: 5761 7463 6827 2c20 6576 656e 743a 2045 Watch', event: E\n+00048b50: 7665 6e74 2c20 6469 7266 643a 2069 6e74 vent, dirfd: int\n+00048b60: 2c20 6e61 6d65 3a20 7374 7229 3a0a 2020 , name: str):. \n+00048b70: 2020 2020 2020 7365 6c66 2e5f 7761 7463 self._watc\n+00048b80: 6820 3d20 7761 7463 680a 2020 2020 2020 h = watch. \n+00048b90: 2020 7365 6c66 2e5f 6e61 6d65 203d 206e self._name = n\n+00048ba0: 616d 652e 656e 636f 6465 2827 7574 662d ame.encode('utf-\n+00048bb0: 3827 290a 0a20 2020 2020 2020 2023 2065 8').. # e\n+00048bc0: 7374 6162 6c69 7368 696e 6720 696e 7661 stablishing inva\n+00048bd0: 6c69 6461 7469 6f6e 2077 6174 6368 6573 lidation watches\n+00048be0: 2069 7320 6265 7374 2d65 6666 6f72 7420 is best-effort \n+00048bf0: 616e 6420 6361 6e20 6661 696c 2066 6f72 and can fail for\n+00048c00: 2061 0a20 2020 2020 2020 2023 206e 756d a. # num\n+00048c10: 6265 7220 6f66 2072 6561 736f 6e73 2c20 ber of reasons, \n+00048c20: 696e 636c 7564 696e 6720 7365 6172 6368 including search\n+00048c30: 2028 2b78 2920 6275 7420 6e6f 7420 7265 (+x) but not re\n+00048c40: 6164 2028 2b72 2920 7065 726d 6973 7369 ad (+r) permissi\n+00048c50: 6f6e 0a20 2020 2020 2020 2023 206f 6e20 on. # on \n+00048c60: 6120 7061 7274 6963 756c 6172 2070 6174 a particular pat\n+00048c70: 6820 636f 6d70 6f6e 656e 742c 206f 7220 h component, or \n+00048c80: 6578 6365 6564 696e 6720 6c69 6d69 7473 exceeding limits\n+00048c90: 206f 6e20 7761 7463 6865 730a 2020 2020 on watches. \n+00048ca0: 2020 2020 7472 793a 0a20 2020 2020 2020 try:. \n+00048cb0: 2020 2020 206d 6173 6b20 3d20 494e 2e43 mask = IN.C\n+00048cc0: 5245 4154 4520 7c20 494e 2e44 454c 4554 REATE | IN.DELET\n+00048cd0: 4520 7c20 494e 2e4d 4f56 4520 7c20 494e E | IN.MOVE | IN\n+00048ce0: 2e44 454c 4554 455f 5345 4c46 207c 2049 .DELETE_SELF | I\n+00048cf0: 4e2e 4947 4e4f 5245 440a 2020 2020 2020 N.IGNORED. \n+00048d00: 2020 2020 2020 7365 6c66 2e5f 736f 7572 self._sour\n+00048d10: 6365 203d 2065 7665 6e74 2e61 6464 5f69 ce = event.add_i\n+00048d20: 6e6f 7469 6679 5f66 6428 6469 7266 642c notify_fd(dirfd,\n+00048d30: 206d 6173 6b2c 2073 656c 662e 6576 656e mask, self.even\n+00048d40: 7429 0a20 2020 2020 2020 2065 7863 6570 t). excep\n+00048d50: 7420 4f53 4572 726f 723a 0a20 2020 2020 t OSError:. \n+00048d60: 2020 2020 2020 2073 656c 662e 5f73 6f75 self._sou\n+00048d70: 7263 6520 3d20 4e6f 6e65 0a0a 2020 2020 rce = None.. \n+00048d80: 6465 6620 636c 6f73 6528 7365 6c66 2920 def close(self) \n+00048d90: 2d3e 204e 6f6e 653a 0a20 2020 2020 2020 -> None:. \n+00048da0: 2023 2054 6869 7320 6973 2061 206c 6974 # This is a lit\n+00048db0: 746c 6520 6269 7420 7472 6963 6b79 3a20 tle bit tricky: \n+00048dc0: 7379 7374 656d 6420 646f 6573 6e27 7420 systemd doesn't \n+00048dd0: 6861 7665 2061 2073 7065 6369 6669 6320 have a specific \n+00048de0: 636c 6f73 650a 2020 2020 2020 2020 2320 close. # \n+00048df0: 4150 4920 6f75 7473 6964 6520 6f66 2075 API outside of u\n+00048e00: 6e72 6566 2c20 736f 206c 6574 2773 206d nref, so let's m\n+00048e10: 616b 6520 6974 2061 7320 6578 706c 6963 ake it as explic\n+00048e20: 6974 2061 7320 706f 7373 6962 6c65 2e0a it as possible..\n+00048e30: 2020 2020 2020 2020 7365 6c66 2e5f 7761 self._wa\n+00048e40: 7463 6820 3d20 4e6f 6e65 0a20 2020 2020 tch = None. \n+00048e50: 2020 2073 656c 662e 5f73 6f75 7263 6520 self._source \n+00048e60: 3d20 4e6f 6e65 0a0a 0a63 6c61 7373 2050 = None...class P\n+00048e70: 6174 6853 7461 636b 284c 6973 745b 7374 athStack(List[st\n+00048e80: 725d 293a 0a20 2020 2064 6566 2061 6464 r]):. def add\n+00048e90: 5f70 6174 6828 7365 6c66 2c20 7061 7468 _path(self, path\n+00048ea0: 6e61 6d65 3a20 7374 7229 202d 3e20 4e6f name: str) -> No\n+00048eb0: 6e65 3a0a 2020 2020 2020 2020 2320 544f ne:. # TO\n+00048ec0: 2044 4f3a 2063 6f6e 7369 6465 7220 646f DO: consider do\n+00048ed0: 696e 6720 736f 6d65 7468 696e 6720 7265 ing something re\n+00048ee0: 6173 6f6e 6162 6c65 2077 6974 6820 7472 asonable with tr\n+00048ef0: 6169 6c69 6e67 2073 6c61 7368 6573 0a20 ailing slashes. \n+00048f00: 2020 2020 2020 2023 2074 6869 7320 6973 # this is\n+00048f10: 2061 2073 7461 636b 2c20 706f 7070 6564 a stack, popped\n+00048f20: 2066 726f 6d20 7468 6520 656e 643a 2070 from the end: p\n+00048f30: 7573 6820 636f 6d70 6f6e 656e 7473 2069 ush components i\n+00048f40: 6e20 7265 7665 7273 650a 2020 2020 2020 n reverse. \n+00048f50: 2020 7365 6c66 2e65 7874 656e 6428 6974 self.extend(it\n+00048f60: 656d 2066 6f72 2069 7465 6d20 696e 2072 em for item in r\n+00048f70: 6576 6572 7365 6428 7061 7468 6e61 6d65 eversed(pathname\n+00048f80: 2e73 706c 6974 2827 2f27 2929 2069 6620 .split('/')) if \n+00048f90: 6974 656d 290a 2020 2020 2020 2020 6966 item). if\n+00048fa0: 2070 6174 686e 616d 652e 7374 6172 7473 pathname.starts\n+00048fb0: 7769 7468 2827 2f27 293a 0a20 2020 2020 with('/'):. \n+00048fc0: 2020 2020 2020 2073 656c 662e 6170 7065 self.appe\n+00048fd0: 6e64 2827 2f27 290a 0a20 2020 2064 6566 nd('/').. def\n+00048fe0: 205f 5f69 6e69 745f 5f28 7365 6c66 2c20 __init__(self, \n+00048ff0: 7061 7468 3a20 7374 7229 3a0a 2020 2020 path: str):. \n+00049000: 2020 2020 7375 7065 7228 292e 5f5f 696e super().__in\n+00049010: 6974 5f5f 2829 0a20 2020 2020 2020 2073 it__(). s\n+00049020: 656c 662e 6164 645f 7061 7468 2870 6174 elf.add_path(pat\n+00049030: 6829 0a0a 0a63 6c61 7373 204c 6973 7465 h)...class Liste\n+00049040: 6e65 723a 0a20 2020 2064 6566 2064 6f5f ner:. def do_\n+00049050: 696e 6f74 6966 795f 6576 656e 7428 7365 inotify_event(se\n+00049060: 6c66 2c20 6d61 736b 3a20 494e 2c20 636f lf, mask: IN, co\n+00049070: 6f6b 6965 3a20 696e 742c 206e 616d 653a okie: int, name:\n+00049080: 204f 7074 696f 6e61 6c5b 6279 7465 735d Optional[bytes]\n+00049090: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n+000490a0: 2020 2072 6169 7365 204e 6f74 496d 706c raise NotImpl\n+000490b0: 656d 656e 7465 6445 7272 6f72 0a0a 2020 ementedError.. \n+000490c0: 2020 6465 6620 646f 5f69 6465 6e74 6974 def do_identit\n+000490d0: 795f 6368 616e 6765 6428 7365 6c66 2c20 y_changed(self, \n+000490e0: 6664 3a20 4f70 7469 6f6e 616c 5b48 616e fd: Optional[Han\n+000490f0: 646c 655d 2c20 6572 726e 6f3a 204f 7074 dle], errno: Opt\n+00049100: 696f 6e61 6c5b 696e 745d 2920 2d3e 204e ional[int]) -> N\n+00049110: 6f6e 653a 0a20 2020 2020 2020 2072 6169 one:. rai\n+00049120: 7365 204e 6f74 496d 706c 656d 656e 7465 se NotImplemente\n+00049130: 6445 7272 6f72 0a0a 0a63 6c61 7373 2050 dError...class P\n+00049140: 6174 6857 6174 6368 3a0a 2020 2020 5f65 athWatch:. _e\n+00049150: 7665 6e74 3a20 4576 656e 740a 2020 2020 vent: Event. \n+00049160: 5f6c 6973 7465 6e65 723a 204c 6973 7465 _listener: Liste\n+00049170: 6e65 720a 2020 2020 5f70 6174 683a 2073 ner. _path: s\n+00049180: 7472 0a20 2020 205f 696e 7661 6c69 6461 tr. _invalida\n+00049190: 746f 7273 3a20 4c69 7374 5b57 6174 6368 tors: List[Watch\n+000491a0: 496e 7661 6c69 6461 746f 725d 0a20 2020 Invalidator]. \n+000491b0: 205f 6572 726e 6f3a 204f 7074 696f 6e61 _errno: Optiona\n+000491c0: 6c5b 696e 745d 0a20 2020 205f 736f 7572 l[int]. _sour\n+000491d0: 6365 3a20 4f70 7469 6f6e 616c 5b45 7665 ce: Optional[Eve\n+000491e0: 6e74 2e53 6f75 7263 655d 0a20 2020 205f nt.Source]. _\n+000491f0: 7461 673a 204f 7074 696f 6e61 6c5b 4e6f tag: Optional[No\n+00049200: 6e65 5d0a 2020 2020 5f66 643a 2048 616e ne]. _fd: Han\n+00049210: 646c 650a 0a20 2020 2064 6566 205f 5f69 dle.. def __i\n+00049220: 6e69 745f 5f28 7365 6c66 2c20 7061 7468 nit__(self, path\n+00049230: 3a20 7374 722c 206c 6973 7465 6e65 723a : str, listener:\n+00049240: 204c 6973 7465 6e65 722c 2065 7665 6e74 Listener, event\n+00049250: 3a20 4f70 7469 6f6e 616c 5b45 7665 6e74 : Optional[Event\n+00049260: 5d20 3d20 4e6f 6e65 293a 0a20 2020 2020 ] = None):. \n+00049270: 2020 2073 656c 662e 5f65 7665 6e74 203d self._event =\n+00049280: 2065 7665 6e74 206f 7220 4576 656e 742e event or Event.\n+00049290: 6465 6661 756c 7428 290a 2020 2020 2020 default(). \n+000492a0: 2020 7365 6c66 2e5f 7061 7468 203d 2070 self._path = p\n+000492b0: 6174 680a 2020 2020 2020 2020 7365 6c66 ath. self\n+000492c0: 2e5f 6c69 7374 656e 6572 203d 206c 6973 ._listener = lis\n+000492d0: 7465 6e65 720a 0a20 2020 2020 2020 2073 tener.. s\n+000492e0: 656c 662e 5f69 6e76 616c 6964 6174 6f72 elf._invalidator\n+000492f0: 7320 3d20 5b5d 0a20 2020 2020 2020 2073 s = []. s\n+00049300: 656c 662e 5f65 7272 6e6f 203d 204e 6f6e elf._errno = Non\n+00049310: 650a 2020 2020 2020 2020 7365 6c66 2e5f e. self._\n+00049320: 736f 7572 6365 203d 204e 6f6e 650a 2020 source = None. \n+00049330: 2020 2020 2020 7365 6c66 2e5f 7461 6720 self._tag \n+00049340: 3d20 4e6f 6e65 0a20 2020 2020 2020 2073 = None. s\n+00049350: 656c 662e 5f66 6420 3d20 4861 6e64 6c65 elf._fd = Handle\n+00049360: 2829 0a0a 2020 2020 2020 2020 7365 6c66 ().. self\n+00049370: 2e69 6e76 616c 6964 6174 6528 290a 0a20 .invalidate().. \n+00049380: 2020 2064 6566 2067 6f74 5f65 7665 6e74 def got_event\n+00049390: 2873 656c 662c 206d 6173 6b3a 2049 4e2c (self, mask: IN,\n+000493a0: 2063 6f6f 6b69 653a 2069 6e74 2c20 6e61 cookie: int, na\n+000493b0: 6d65 3a20 4f70 7469 6f6e 616c 5b62 7974 me: Optional[byt\n+000493c0: 6573 5d29 202d 3e20 4e6f 6e65 3a0a 2020 es]) -> None:. \n+000493d0: 2020 2020 2020 6c6f 6767 6572 2e64 6562 logger.deb\n+000493e0: 7567 2827 7461 7267 6574 2065 7665 6e74 ug('target event\n+000493f0: 2025 733a 2025 7320 2573 2025 7327 2c20 %s: %s %s %s', \n+00049400: 7365 6c66 2e5f 7061 7468 2c20 6d61 736b self._path, mask\n+00049410: 2c20 636f 6f6b 6965 2c20 6e61 6d65 290a , cookie, name).\n+00049420: 2020 2020 2020 2020 7365 6c66 2e5f 6c69 self._li\n+00049430: 7374 656e 6572 2e64 6f5f 696e 6f74 6966 stener.do_inotif\n+00049440: 795f 6576 656e 7428 6d61 736b 2c20 636f y_event(mask, co\n+00049450: 6f6b 6965 2c20 6e61 6d65 290a 0a20 2020 okie, name).. \n+00049460: 2064 6566 2069 6e76 616c 6964 6174 6528 def invalidate(\n+00049470: 7365 6c66 2920 2d3e 204e 6f6e 653a 0a20 self) -> None:. \n+00049480: 2020 2020 2020 2066 6f72 2069 6e76 616c for inval\n+00049490: 6964 6174 6f72 2069 6e20 7365 6c66 2e5f idator in self._\n+000494a0: 696e 7661 6c69 6461 746f 7273 3a0a 2020 invalidators:. \n+000494b0: 2020 2020 2020 2020 2020 696e 7661 6c69 invali\n+000494c0: 6461 746f 722e 636c 6f73 6528 290a 2020 dator.close(). \n+000494d0: 2020 2020 2020 7365 6c66 2e5f 696e 7661 self._inva\n+000494e0: 6c69 6461 746f 7273 203d 205b 5d0a 0a20 lidators = [].. \n+000494f0: 2020 2020 2020 2074 7279 3a0a 2020 2020 try:. \n+00049500: 2020 2020 2020 2020 6664 203d 2073 656c fd = sel\n+00049510: 662e 7761 6c6b 2829 0a20 2020 2020 2020 f.walk(). \n+00049520: 2065 7863 6570 7420 4f53 4572 726f 7220 except OSError \n+00049530: 6173 2065 7272 6f72 3a0a 2020 2020 2020 as error:. \n+00049540: 2020 2020 2020 6c6f 6767 6572 2e64 6562 logger.deb\n+00049550: 7567 2827 7761 6c6b 2065 6e64 6564 2069 ug('walk ended i\n+00049560: 6e20 6572 726f 7220 2564 272c 2065 7272 n error %d', err\n+00049570: 6f72 2e65 7272 6e6f 290a 0a20 2020 2020 or.errno).. \n+00049580: 2020 2020 2020 2069 6620 7365 6c66 2e5f if self._\n+00049590: 736f 7572 6365 206f 7220 7365 6c66 2e5f source or self._\n+000495a0: 6664 206f 7220 7365 6c66 2e5f 6572 726e fd or self._errn\n+000495b0: 6f20 213d 2065 7272 6f72 2e65 7272 6e6f o != error.errno\n+000495c0: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n+000495d0: 2020 6c6f 6767 6572 2e64 6562 7567 2827 logger.debug('\n+000495e0: 456e 6469 6e67 2065 7869 7374 696e 6720 Ending existing \n+000495f0: 7761 7463 6865 732e 2729 0a20 2020 2020 watches.'). \n+00049600: 2020 2020 2020 2020 2020 2073 656c 662e self.\n+00049610: 5f73 6f75 7263 6520 3d20 4e6f 6e65 0a20 _source = None. \n+00049620: 2020 2020 2020 2020 2020 2020 2020 2073 s\n+00049630: 656c 662e 5f66 642e 636c 6f73 6528 290a elf._fd.close().\n+00049640: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00049650: 7365 6c66 2e5f 6664 203d 2048 616e 646c self._fd = Handl\n+00049660: 6528 290a 2020 2020 2020 2020 2020 2020 e(). \n+00049670: 2020 2020 7365 6c66 2e5f 6572 726e 6f20 self._errno \n+00049680: 3d20 6572 726f 722e 6572 726e 6f0a 0a20 = error.errno.. \n+00049690: 2020 2020 2020 2020 2020 2020 2020 206c l\n+000496a0: 6f67 6765 722e 6465 6275 6728 274e 6f74 ogger.debug('Not\n+000496b0: 6966 7969 6e67 206f 6620 6e65 7720 6572 ifying of new er\n+000496c0: 726f 7220 7374 6174 6520 2564 272c 2073 ror state %d', s\n+000496d0: 656c 662e 5f65 7272 6e6f 290a 2020 2020 elf._errno). \n+000496e0: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n+000496f0: 2e5f 6c69 7374 656e 6572 2e64 6f5f 6964 ._listener.do_id\n+00049700: 656e 7469 7479 5f63 6861 6e67 6564 284e entity_changed(N\n+00049710: 6f6e 652c 2073 656c 662e 5f65 7272 6e6f one, self._errno\n+00049720: 290a 0a20 2020 2020 2020 2020 2020 2072 ).. r\n+00049730: 6574 7572 6e0a 0a20 2020 2020 2020 2077 eturn.. w\n+00049740: 6974 6820 6664 3a0a 2020 2020 2020 2020 ith fd:. \n+00049750: 2020 2020 6c6f 6767 6572 2e64 6562 7567 logger.debug\n+00049760: 2827 7761 6c6b 2073 7563 6365 7373 6675 ('walk successfu\n+00049770: 6c2e 2020 476f 7420 6664 2025 6427 2c20 l. Got fd %d', \n+00049780: 6664 290a 2020 2020 2020 2020 2020 2020 fd). \n+00049790: 6966 2066 6420 3d3d 2073 656c 662e 5f66 if fd == self._f\n+000497a0: 643a 0a20 2020 2020 2020 2020 2020 2020 d:. \n+000497b0: 2020 206c 6f67 6765 722e 6465 6275 6728 logger.debug(\n+000497c0: 2766 6420 7365 656d 7320 746f 2072 6566 'fd seems to ref\n+000497d0: 6572 2074 6f20 7361 6d65 2066 696c 652e er to same file.\n+000497e0: 2020 446f 696e 6720 6e6f 7468 696e 672e Doing nothing.\n+000497f0: 2729 0a20 2020 2020 2020 2020 2020 2020 '). \n+00049800: 2020 2072 6574 7572 6e0a 0a20 2020 2020 return.. \n+00049810: 2020 2020 2020 206c 6f67 6765 722e 6465 logger.de\n+00049820: 6275 6728 2754 6869 7320 6669 6c65 2069 bug('This file i\n+00049830: 7320 6e65 7720 666f 7220 7573 2e20 2052 s new for us. R\n+00049840: 656d 6f76 696e 6720 6f6c 6420 7761 7463 emoving old watc\n+00049850: 682e 2729 0a20 2020 2020 2020 2020 2020 h.'). \n+00049860: 2073 656c 662e 5f73 6f75 7263 6520 3d20 self._source = \n+00049870: 4e6f 6e65 0a20 2020 2020 2020 2020 2020 None. \n+00049880: 2073 656c 662e 5f66 642e 636c 6f73 6528 self._fd.close(\n+00049890: 290a 2020 2020 2020 2020 2020 2020 7365 ). se\n+000498a0: 6c66 2e5f 6664 203d 2066 642e 7374 6561 lf._fd = fd.stea\n+000498b0: 6c28 290a 0a20 2020 2020 2020 2020 2020 l().. \n+000498c0: 2074 7279 3a0a 2020 2020 2020 2020 2020 try:. \n+000498d0: 2020 2020 2020 6c6f 6767 6572 2e64 6562 logger.deb\n+000498e0: 7567 2827 4573 7461 626c 6973 6869 6e67 ug('Establishing\n+000498f0: 2061 206e 6577 2077 6174 6368 2e27 290a a new watch.').\n+00049900: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00049910: 7365 6c66 2e5f 736f 7572 6365 203d 2073 self._source = s\n+00049920: 656c 662e 5f65 7665 6e74 2e61 6464 5f69 elf._event.add_i\n+00049930: 6e6f 7469 6679 5f66 6428 7365 6c66 2e5f notify_fd(self._\n+00049940: 6664 2c20 494e 2e43 4841 4e47 4544 2c20 fd, IN.CHANGED, \n+00049950: 7365 6c66 2e67 6f74 5f65 7665 6e74 290a self.got_event).\n+00049960: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00049970: 6c6f 6767 6572 2e64 6562 7567 2827 5761 logger.debug('Wa\n+00049980: 7463 6869 6e67 2073 7563 6365 7373 6675 tching successfu\n+00049990: 6c6c 792e 2020 4e6f 7469 6679 696e 6720 lly. Notifying \n+000499a0: 6f66 206e 6577 2069 6465 6e74 6974 792e of new identity.\n+000499b0: 2729 0a20 2020 2020 2020 2020 2020 2020 '). \n+000499c0: 2020 2073 656c 662e 5f6c 6973 7465 6e65 self._listene\n+000499d0: 722e 646f 5f69 6465 6e74 6974 795f 6368 r.do_identity_ch\n+000499e0: 616e 6765 6428 7365 6c66 2e5f 6664 2c20 anged(self._fd, \n+000499f0: 4e6f 6e65 290a 2020 2020 2020 2020 2020 None). \n+00049a00: 2020 6578 6365 7074 204f 5345 7272 6f72 except OSError\n+00049a10: 2061 7320 6572 726f 723a 0a20 2020 2020 as error:. \n+00049a20: 2020 2020 2020 2020 2020 206c 6f67 6765 logge\n+00049a30: 722e 6465 6275 6728 2757 6174 6368 696e r.debug('Watchin\n+00049a40: 6720 6661 696c 6564 2028 2564 292e 2020 g failed (%d). \n+00049a50: 4e6f 7469 6679 696e 6720 6f66 206e 6577 Notifying of new\n+00049a60: 2069 6465 6e74 6974 792e 272c 2065 7272 identity.', err\n+00049a70: 6f72 2e65 7272 6e6f 290a 2020 2020 2020 or.errno). \n+00049a80: 2020 2020 2020 2020 2020 7365 6c66 2e5f self._\n+00049a90: 6c69 7374 656e 6572 2e64 6f5f 6964 656e listener.do_iden\n+00049aa0: 7469 7479 5f63 6861 6e67 6564 2873 656c tity_changed(sel\n+00049ab0: 662e 5f66 642c 2065 7272 6f72 2e65 7272 f._fd, error.err\n+00049ac0: 6e6f 290a 0a20 2020 2064 6566 2077 616c no).. def wal\n+00049ad0: 6b28 7365 6c66 2920 2d3e 2048 616e 646c k(self) -> Handl\n+00049ae0: 653a 0a20 2020 2020 2020 2072 656d 6169 e:. remai\n+00049af0: 6e69 6e67 5f73 796d 6c69 6e6b 5f6c 6f6f ning_symlink_loo\n+00049b00: 6b75 7073 203d 2034 300a 2020 2020 2020 kups = 40. \n+00049b10: 2020 7265 6d61 696e 696e 675f 636f 6d70 remaining_comp\n+00049b20: 6f6e 656e 7473 203d 2050 6174 6853 7461 onents = PathSta\n+00049b30: 636b 2873 656c 662e 5f70 6174 6829 0a20 ck(self._path). \n+00049b40: 2020 2020 2020 2064 6972 6664 203d 2048 dirfd = H\n+00049b50: 616e 646c 6528 290a 0a20 2020 2020 2020 andle().. \n+00049b60: 2074 7279 3a0a 2020 2020 2020 2020 2020 try:. \n+00049b70: 2020 6c6f 6767 6572 2e64 6562 7567 2827 logger.debug('\n+00049b80: 5374 6172 7469 6e67 2070 6174 6820 7761 Starting path wa\n+00049b90: 6c6b 2729 0a0a 2020 2020 2020 2020 2020 lk').. \n+00049ba0: 2020 7768 696c 6520 7265 6d61 696e 696e while remainin\n+00049bb0: 675f 636f 6d70 6f6e 656e 7473 3a0a 2020 g_components:. \n+00049bc0: 2020 2020 2020 2020 2020 2020 2020 6c6f lo\n+00049bd0: 6767 6572 2e64 6562 7567 2827 723d 2573 gger.debug('r=%s\n+00049be0: 2064 6664 3d25 7327 2c20 7265 6d61 696e dfd=%s', remain\n+00049bf0: 696e 675f 636f 6d70 6f6e 656e 7473 2c20 ing_components, \n+00049c00: 6469 7266 6429 0a0a 2020 2020 2020 2020 dirfd).. \n+00049c10: 2020 2020 2020 2020 6e61 6d65 203d 2072 name = r\n+00049c20: 656d 6169 6e69 6e67 5f63 6f6d 706f 6e65 emaining_compone\n+00049c30: 6e74 732e 706f 7028 290a 0a20 2020 2020 nts.pop().. \n+00049c40: 2020 2020 2020 2020 2020 2069 6620 6469 if di\n+00049c50: 7266 6420 616e 6420 6e61 6d65 2021 3d20 rfd and name != \n+00049c60: 272f 273a 0a20 2020 2020 2020 2020 2020 '/':. \n+00049c70: 2020 2020 2020 2020 2073 656c 662e 5f69 self._i\n+00049c80: 6e76 616c 6964 6174 6f72 732e 6170 7065 nvalidators.appe\n+00049c90: 6e64 2857 6174 6368 496e 7661 6c69 6461 nd(WatchInvalida\n+00049ca0: 746f 7228 7365 6c66 2c20 7365 6c66 2e5f tor(self, self._\n+00049cb0: 6576 656e 742c 2064 6972 6664 2c20 6e61 event, dirfd, na\n+00049cc0: 6d65 2929 0a0a 2020 2020 2020 2020 2020 me)).. \n+00049cd0: 2020 2020 2020 7769 7468 2048 616e 646c with Handl\n+00049ce0: 652e 6f70 656e 286e 616d 652c 206f 732e e.open(name, os.\n+00049cf0: 4f5f 5041 5448 207c 206f 732e 4f5f 4e4f O_PATH | os.O_NO\n+00049d00: 464f 4c4c 4f57 207c 206f 732e 4f5f 434c FOLLOW | os.O_CL\n+00049d10: 4f45 5845 432c 2064 6972 5f66 643d 6469 OEXEC, dir_fd=di\n+00049d20: 7266 6429 2061 7320 6664 3a0a 2020 2020 rfd) as fd:. \n+00049d30: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00049d40: 6d6f 6465 203d 206f 732e 6673 7461 7428 mode = os.fstat(\n+00049d50: 6664 292e 7374 5f6d 6f64 650a 0a20 2020 fd).st_mode.. \n+00049d60: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00049d70: 2069 6620 7374 6174 2e53 5f49 534c 4e4b if stat.S_ISLNK\n+00049d80: 286d 6f64 6529 3a0a 2020 2020 2020 2020 (mode):. \n+00049d90: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00049da0: 6966 2072 656d 6169 6e69 6e67 5f73 796d if remaining_sym\n+00049db0: 6c69 6e6b 5f6c 6f6f 6b75 7073 203d 3d20 link_lookups == \n+00049dc0: 303a 0a20 2020 2020 2020 2020 2020 2020 0:. \n+00049dd0: 2020 2020 2020 2020 2020 2020 2020 2072 r\n+00049de0: 6169 7365 204f 5345 7272 6f72 2865 7272 aise OSError(err\n+00049df0: 6e6f 2e45 4c4f 4f50 2c20 6f73 2e73 7472 no.ELOOP, os.str\n+00049e00: 6572 726f 7228 6572 726e 6f2e 454c 4f4f error(errno.ELOO\n+00049e10: 5029 290a 2020 2020 2020 2020 2020 2020 P)). \n+00049e20: 2020 2020 2020 2020 2020 2020 7265 6d61 rema\n+00049e30: 696e 696e 675f 7379 6d6c 696e 6b5f 6c6f ining_symlink_lo\n+00049e40: 6f6b 7570 7320 2d3d 2031 0a20 2020 2020 okups -= 1. \n+00049e50: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00049e60: 2020 206c 696e 6b70 6174 6820 3d20 6f73 linkpath = os\n+00049e70: 2e72 6561 646c 696e 6b28 2727 2c20 6469 .readlink('', di\n+00049e80: 725f 6664 3d66 6429 0a20 2020 2020 2020 r_fd=fd). \n+00049e90: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00049ea0: 206c 6f67 6765 722e 6465 6275 6728 2725 logger.debug('%\n+00049eb0: 7320 6973 2061 2073 796d 6c69 6e6b 2e20 s is a symlink. \n+00049ec0: 2061 6464 696e 6720 2573 2074 6f20 636f adding %s to co\n+00049ed0: 6d70 6f6e 656e 7473 272c 206e 616d 652c mponents', name,\n+00049ee0: 206c 696e 6b70 6174 6829 0a20 2020 2020 linkpath). \n+00049ef0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00049f00: 2020 2072 656d 6169 6e69 6e67 5f63 6f6d remaining_com\n+00049f10: 706f 6e65 6e74 732e 6164 645f 7061 7468 ponents.add_path\n+00049f20: 286c 696e 6b70 6174 6829 0a0a 2020 2020 (linkpath).. \n+00049f30: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00049f40: 656c 7365 3a0a 2020 2020 2020 2020 2020 else:. \n+00049f50: 2020 2020 2020 2020 2020 2020 2020 6469 di\n+00049f60: 7266 642e 636c 6f73 6528 290a 2020 2020 rfd.close(). \n+00049f70: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00049f80: 2020 2020 6469 7266 6420 3d20 6664 2e73 dirfd = fd.s\n+00049f90: 7465 616c 2829 0a0a 2020 2020 2020 2020 teal().. \n+00049fa0: 2020 2020 7265 7475 726e 2064 6972 6664 return dirfd\n+00049fb0: 2e73 7465 616c 2829 0a0a 2020 2020 2020 .steal().. \n+00049fc0: 2020 6669 6e61 6c6c 793a 0a20 2020 2020 finally:. \n+00049fd0: 2020 2020 2020 2064 6972 6664 2e63 6c6f dirfd.clo\n+00049fe0: 7365 2829 0a0a 2020 2020 6465 6620 636c se().. def cl\n+00049ff0: 6f73 6528 7365 6c66 2920 2d3e 204e 6f6e ose(self) -> Non\n+0004a000: 653a 0a20 2020 2020 2020 2066 6f72 2069 e:. for i\n+0004a010: 6e76 616c 6964 6174 6f72 2069 6e20 7365 nvalidator in se\n+0004a020: 6c66 2e5f 696e 7661 6c69 6461 746f 7273 lf._invalidators\n+0004a030: 3a0a 2020 2020 2020 2020 2020 2020 696e :. in\n+0004a040: 7661 6c69 6461 746f 722e 636c 6f73 6528 validator.close(\n+0004a050: 290a 2020 2020 2020 2020 7365 6c66 2e5f ). self._\n+0004a060: 696e 7661 6c69 6461 746f 7273 203d 205b invalidators = [\n+0004a070: 5d0a 2020 2020 2020 2020 7365 6c66 2e5f ]. self._\n+0004a080: 736f 7572 6365 203d 204e 6f6e 650a 2020 source = None. \n+0004a090: 2020 2020 2020 7365 6c66 2e5f 6664 2e63 self._fd.c\n+0004a0a0: 6c6f 7365 2829 0a27 2727 2c0a 2020 2763 lose().''',. 'c\n+0004a0b0: 6f63 6b70 6974 2f5f 7665 6e64 6f72 2f73 ockpit/_vendor/s\n+0004a0c0: 7973 7465 6d64 5f63 7479 7065 732f 7479 ystemd_ctypes/ty\n+0004a0d0: 7069 6e67 2e70 7927 3a20 6272 2727 2769 ping.py': br'''i\n+0004a0e0: 6d70 6f72 7420 7479 7069 6e67 0a66 726f mport typing.fro\n+0004a0f0: 6d20 7479 7069 6e67 2069 6d70 6f72 7420 m typing import \n+0004a100: 5459 5045 5f43 4845 434b 494e 470a 0a23 TYPE_CHECKING..#\n+0004a110: 2054 6865 2067 6f61 6c20 6865 7265 2069 The goal here i\n+0004a120: 7320 746f 2063 6f6e 7469 6e75 6520 746f s to continue to\n+0004a130: 2077 6f72 6b20 6f6e 2050 7974 686f 6e20 work on Python \n+0004a140: 332e 3620 7768 696c 6520 7072 6574 656e 3.6 while preten\n+0004a150: 6469 6e67 2074 6f20 6861 7665 0a23 2061 ding to have.# a\n+0004a160: 6363 6573 7320 746f 2073 6f6d 6520 6d6f ccess to some mo\n+0004a170: 6465 726e 2074 7970 696e 6720 6665 6174 dern typing feat\n+0004a180: 7572 6573 2e20 2054 6865 2073 6869 6d73 ures. The shims\n+0004a190: 2070 726f 7669 6465 6420 6865 7265 2061 provided here a\n+0004a1a0: 7265 206f 6e6c 790a 2320 656e 6f75 6768 re only.# enough\n+0004a1b0: 2066 6f72 2077 6861 7420 7765 206e 6565 for what we nee\n+0004a1c0: 6420 666f 7220 7379 7374 656d 645f 6374 d for systemd_ct\n+0004a1d0: 7970 6573 2074 6f20 776f 726b 2061 7420 ypes to work at \n+0004a1e0: 7275 6e74 696d 652e 0a0a 0a69 6620 5459 runtime....if TY\n+0004a1f0: 5045 5f43 4845 434b 494e 473a 0a20 2020 PE_CHECKING:. \n+0004a200: 2023 2053 6565 2068 7474 7073 3a2f 2f67 # See https://g\n+0004a210: 6974 6875 622e 636f 6d2f 7079 7468 6f6e ithub.com/python\n+0004a220: 2f6d 7970 792f 6973 7375 6573 2f31 3135 /mypy/issues/115\n+0004a230: 3320 666f 7220 7768 7920 7765 2064 6f20 3 for why we do \n+0004a240: 7468 6973 2073 6570 6172 6174 656c 790a this separately.\n+0004a250: 2020 2020 6672 6f6d 2074 7970 696e 6720 from typing \n+0004a260: 696d 706f 7274 2041 6e6e 6f74 6174 6564 import Annotated\n+0004a270: 2c20 466f 7277 6172 6452 6566 2c20 5479 , ForwardRef, Ty\n+0004a280: 7065 4775 6172 642c 2067 6574 5f61 7267 peGuard, get_arg\n+0004a290: 732c 2067 6574 5f6f 7269 6769 6e0a 0a65 s, get_origin..e\n+0004a2a0: 6c73 653a 0a20 2020 2023 2074 7970 696e lse:. # typin\n+0004a2b0: 672e 6765 745f 6172 6773 2829 2061 6e64 g.get_args() and\n+0004a2c0: 202e 6765 745f 6f72 6967 696e 2829 2061 .get_origin() a\n+0004a2d0: 7070 6561 7265 6420 696e 2050 7974 686f ppeared in Pytho\n+0004a2e0: 6e20 332e 3820 6275 7420 416e 6e6f 7461 n 3.8 but Annota\n+0004a2f0: 7465 640a 2020 2020 2320 6172 7269 7665 ted. # arrive\n+0004a300: 6420 696e 2033 2e39 2e20 2055 6e66 6f72 d in 3.9. Unfor\n+0004a310: 7475 6e61 7465 6c79 2c20 6974 2773 2064 tunately, it's d\n+0004a320: 6966 6669 6375 6c74 2074 6f20 696d 706c ifficult to impl\n+0004a330: 656d 656e 7420 6120 6d6f 636b 6564 2075 ement a mocked u\n+0004a340: 700a 2020 2020 2320 7665 7273 696f 6e20 p. # version \n+0004a350: 6f66 2041 6e6e 6f74 6174 6564 2077 6869 of Annotated whi\n+0004a360: 6368 2077 6f72 6b73 2077 6974 6820 7468 ch works with th\n+0004a370: 6520 7265 616c 2074 7970 696e 672e 6765 e real typing.ge\n+0004a380: 745f 6172 6773 2829 2061 6e64 0a20 2020 t_args() and. \n+0004a390: 2023 202e 6765 745f 6f72 6967 696e 2829 # .get_origin()\n+0004a3a0: 2069 6e20 5079 7468 6f6e 2033 2e38 2c20 in Python 3.8, \n+0004a3b0: 736f 2077 6520 7573 6520 6f75 7220 6f77 so we use our ow\n+0004a3c0: 6e20 7665 7273 696f 6e73 2074 6865 7265 n versions there\n+0004a3d0: 2061 7320 7765 6c6c 2e0a 2020 2020 7472 as well.. tr\n+0004a3e0: 793a 0a20 2020 2020 2020 2066 726f 6d20 y:. from \n+0004a3f0: 7479 7069 6e67 2069 6d70 6f72 7420 416e typing import An\n+0004a400: 6e6f 7461 7465 642c 2067 6574 5f61 7267 notated, get_arg\n+0004a410: 732c 2067 6574 5f6f 7269 6769 6e0a 2020 s, get_origin. \n+0004a420: 2020 6578 6365 7074 2049 6d70 6f72 7445 except ImportE\n+0004a430: 7272 6f72 3a0a 2020 2020 2020 2020 636c rror:. cl\n+0004a440: 6173 7320 416e 6e6f 7461 7465 644d 6574 ass AnnotatedMet\n+0004a450: 6128 7479 7065 293a 0a20 2020 2020 2020 a(type):. \n+0004a460: 2020 2020 2064 6566 205f 5f67 6574 6974 def __getit\n+0004a470: 656d 5f5f 2863 6c73 2c20 7061 7261 6d73 em__(cls, params\n+0004a480: 293a 0a20 2020 2020 2020 2020 2020 2020 ):. \n+0004a490: 2020 2063 6c61 7373 2041 6e6e 6f74 6174 class Annotat\n+0004a4a0: 6564 5479 7065 3a0a 2020 2020 2020 2020 edType:. \n+0004a4b0: 2020 2020 2020 2020 2020 2020 5f5f 6f72 __or\n+0004a4c0: 6967 696e 5f5f 203d 2041 6e6e 6f74 6174 igin__ = Annotat\n+0004a4d0: 6564 0a20 2020 2020 2020 2020 2020 2020 ed. \n+0004a4e0: 2020 2020 2020 205f 5f61 7267 735f 5f20 __args__ \n+0004a4f0: 3d20 7061 7261 6d73 0a20 2020 2020 2020 = params. \n+0004a500: 2020 2020 2020 2020 2072 6574 7572 6e20 return \n+0004a510: 416e 6e6f 7461 7465 6454 7970 650a 0a20 AnnotatedType.. \n+0004a520: 2020 2020 2020 2063 6c61 7373 2041 6e6e class Ann\n+0004a530: 6f74 6174 6564 286d 6574 6163 6c61 7373 otated(metaclass\n+0004a540: 3d41 6e6e 6f74 6174 6564 4d65 7461 293a =AnnotatedMeta):\n+0004a550: 0a20 2020 2020 2020 2020 2020 2070 6173 . pas\n+0004a560: 730a 0a20 2020 2020 2020 2064 6566 2067 s.. def g\n+0004a570: 6574 5f61 7267 7328 616e 6e6f 7461 7469 et_args(annotati\n+0004a580: 6f6e 3a20 7479 7069 6e67 2e41 6e79 2920 on: typing.Any) \n+0004a590: 2d3e 2074 7970 696e 672e 5475 706c 655b -> typing.Tuple[\n+0004a5a0: 7479 7069 6e67 2e41 6e79 5d3a 0a20 2020 typing.Any]:. \n+0004a5b0: 2020 2020 2020 2020 2072 6574 7572 6e20 return \n+0004a5c0: 6765 7461 7474 7228 616e 6e6f 7461 7469 getattr(annotati\n+0004a5d0: 6f6e 2c20 275f 5f61 7267 735f 5f27 2c20 on, '__args__', \n+0004a5e0: 2829 290a 0a20 2020 2020 2020 2064 6566 ()).. def\n+0004a5f0: 2067 6574 5f6f 7269 6769 6e28 616e 6e6f get_origin(anno\n+0004a600: 7461 7469 6f6e 3a20 7479 7069 6e67 2e41 tation: typing.A\n+0004a610: 6e79 2920 2d3e 2074 7970 696e 672e 416e ny) -> typing.An\n+0004a620: 793a 0a20 2020 2020 2020 2020 2020 2072 y:. r\n+0004a630: 6574 7572 6e20 6765 7461 7474 7228 616e eturn getattr(an\n+0004a640: 6e6f 7461 7469 6f6e 2c20 275f 5f6f 7269 notation, '__ori\n+0004a650: 6769 6e5f 5f27 2c20 4e6f 6e65 290a 0a20 gin__', None).. \n+0004a660: 2020 2074 7279 3a0a 2020 2020 2020 2020 try:. \n+0004a670: 6672 6f6d 2074 7970 696e 6720 696d 706f from typing impo\n+0004a680: 7274 2046 6f72 7761 7264 5265 660a 2020 rt ForwardRef. \n+0004a690: 2020 6578 6365 7074 2049 6d70 6f72 7445 except ImportE\n+0004a6a0: 7272 6f72 3a0a 2020 2020 2020 2020 6672 rror:. fr\n+0004a6b0: 6f6d 2074 7970 696e 6720 696d 706f 7274 om typing import\n+0004a6c0: 205f 466f 7277 6172 6452 6566 2061 7320 _ForwardRef as \n+0004a6d0: 466f 7277 6172 6452 6566 0a0a 2020 2020 ForwardRef.. \n+0004a6e0: 7472 793a 0a20 2020 2020 2020 2066 726f try:. fro\n+0004a6f0: 6d20 7479 7069 6e67 2069 6d70 6f72 7420 m typing import \n+0004a700: 5479 7065 4775 6172 640a 2020 2020 6578 TypeGuard. ex\n+0004a710: 6365 7074 2049 6d70 6f72 7445 7272 6f72 cept ImportError\n+0004a720: 3a0a 2020 2020 2020 2020 5420 3d20 7479 :. T = ty\n+0004a730: 7069 6e67 2e54 7970 6556 6172 2827 5427 ping.TypeVar('T'\n+0004a740: 290a 0a20 2020 2020 2020 2063 6c61 7373 ).. class\n+0004a750: 2054 7970 6547 7561 7264 2874 7970 696e TypeGuard(typin\n+0004a760: 672e 4765 6e65 7269 635b 545d 293a 0a20 g.Generic[T]):. \n+0004a770: 2020 2020 2020 2020 2020 2070 6173 730a pass.\n+0004a780: 0a0a 5f5f 616c 6c5f 5f20 3d20 280a 2020 ..__all__ = (. \n+0004a790: 2020 2741 6e6e 6f74 6174 6564 272c 0a20 'Annotated',. \n+0004a7a0: 2020 2027 466f 7277 6172 6452 6566 272c 'ForwardRef',\n+0004a7b0: 0a20 2020 2027 5479 7065 4775 6172 6427 . 'TypeGuard'\n+0004a7c0: 2c0a 2020 2020 2767 6574 5f61 7267 7327 ,. 'get_args'\n+0004a7d0: 2c0a 2020 2020 2767 6574 5f6f 7269 6769 ,. 'get_origi\n+0004a7e0: 6e27 2c0a 2020 2020 2754 5950 455f 4348 n',. 'TYPE_CH\n+0004a7f0: 4543 4b49 4e47 272c 0a29 0a27 2727 2c0a ECKING',.).''',.\n+0004a800: 2020 2763 6f63 6b70 6974 2f5f 7665 6e64 'cockpit/_vend\n+0004a810: 6f72 2f73 7973 7465 6d64 5f63 7479 7065 or/systemd_ctype\n+0004a820: 732f 696e 6f74 6966 792e 7079 273a 2062 s/inotify.py': b\n+0004a830: 7227 2727 2320 7379 7374 656d 645f 6374 r'''# systemd_ct\n+0004a840: 7970 6573 0a23 0a23 2043 6f70 7972 6967 ypes.#.# Copyrig\n+0004a850: 6874 2028 4329 2032 3032 3220 416c 6c69 ht (C) 2022 Alli\n+0004a860: 736f 6e20 4b61 726c 6974 736b 6179 6120 son Karlitskaya \n+0004a870: 3c61 6c6c 6973 6f6e 2e6b 6172 6c69 7473 <allison.karlits\n+0004a880: 6b61 7961 4072 6564 6861 742e 636f 6d3e kaya@redhat.com>\n+0004a890: 0a23 0a23 2054 6869 7320 7072 6f67 7261 .#.# This progra\n+0004a8a0: 6d20 6973 2066 7265 6520 736f 6674 7761 m is free softwa\n+0004a8b0: 7265 3a20 796f 7520 6361 6e20 7265 6469 re: you can redi\n+0004a8c0: 7374 7269 6275 7465 2069 7420 616e 642f stribute it and/\n+0004a8d0: 6f72 206d 6f64 6966 790a 2320 6974 2075 or modify.# it u\n+0004a8e0: 6e64 6572 2074 6865 2074 6572 6d73 206f nder the terms o\n+0004a8f0: 6620 7468 6520 474e 5520 4765 6e65 7261 f the GNU Genera\n+0004a900: 6c20 5075 626c 6963 204c 6963 656e 7365 l Public License\n+0004a910: 2061 7320 7075 626c 6973 6865 6420 6279 as published by\n+0004a920: 0a23 2074 6865 2046 7265 6520 536f 6674 .# the Free Soft\n+0004a930: 7761 7265 2046 6f75 6e64 6174 696f 6e2c ware Foundation,\n+0004a940: 2065 6974 6865 7220 7665 7273 696f 6e20 either version \n+0004a950: 3320 6f66 2074 6865 204c 6963 656e 7365 3 of the License\n+0004a960: 2c20 6f72 0a23 2028 6174 2079 6f75 7220 , or.# (at your \n+0004a970: 6f70 7469 6f6e 2920 616e 7920 6c61 7465 option) any late\n+0004a980: 7220 7665 7273 696f 6e2e 0a23 0a23 2054 r version..#.# T\n+0004a990: 6869 7320 7072 6f67 7261 6d20 6973 2064 his program is d\n+0004a9a0: 6973 7472 6962 7574 6564 2069 6e20 7468 istributed in th\n+0004a9b0: 6520 686f 7065 2074 6861 7420 6974 2077 e hope that it w\n+0004a9c0: 696c 6c20 6265 2075 7365 6675 6c2c 0a23 ill be useful,.#\n+0004a9d0: 2062 7574 2057 4954 484f 5554 2041 4e59 but WITHOUT ANY\n+0004a9e0: 2057 4152 5241 4e54 593b 2077 6974 686f WARRANTY; witho\n+0004a9f0: 7574 2065 7665 6e20 7468 6520 696d 706c ut even the impl\n+0004aa00: 6965 6420 7761 7272 616e 7479 206f 660a ied warranty of.\n+0004aa10: 2320 4d45 5243 4841 4e54 4142 494c 4954 # MERCHANTABILIT\n+0004aa20: 5920 6f72 2046 4954 4e45 5353 2046 4f52 Y or FITNESS FOR\n+0004aa30: 2041 2050 4152 5449 4355 4c41 5220 5055 A PARTICULAR PU\n+0004aa40: 5250 4f53 452e 2020 5365 6520 7468 650a RPOSE. See the.\n+0004aa50: 2320 474e 5520 4765 6e65 7261 6c20 5075 # GNU General Pu\n+0004aa60: 626c 6963 204c 6963 656e 7365 2066 6f72 blic License for\n+0004aa70: 206d 6f72 6520 6465 7461 696c 732e 0a23 more details..#\n+0004aa80: 0a23 2059 6f75 2073 686f 756c 6420 6861 .# You should ha\n+0004aa90: 7665 2072 6563 6569 7665 6420 6120 636f ve received a co\n+0004aaa0: 7079 206f 6620 7468 6520 474e 5520 4765 py of the GNU Ge\n+0004aab0: 6e65 7261 6c20 5075 626c 6963 204c 6963 neral Public Lic\n+0004aac0: 656e 7365 0a23 2061 6c6f 6e67 2077 6974 ense.# along wit\n+0004aad0: 6820 7468 6973 2070 726f 6772 616d 2e20 h this program. \n+0004aae0: 2049 6620 6e6f 742c 2073 6565 203c 6874 If not, see <ht\n+0004aaf0: 7470 3a2f 2f77 7777 2e67 6e75 2e6f 7267 tp://www.gnu.org\n+0004ab00: 2f6c 6963 656e 7365 732f 3e2e 0a0a 696d /licenses/>...im\n+0004ab10: 706f 7274 2063 7479 7065 730a 6672 6f6d port ctypes.from\n+0004ab20: 2065 6e75 6d20 696d 706f 7274 2049 6e74 enum import Int\n+0004ab30: 466c 6167 2c20 6175 746f 0a66 726f 6d20 Flag, auto.from \n+0004ab40: 7479 7069 6e67 2069 6d70 6f72 7420 4f70 typing import Op\n+0004ab50: 7469 6f6e 616c 0a0a 0a63 6c61 7373 2069 tional...class i\n+0004ab60: 6e6f 7469 6679 5f65 7665 6e74 2863 7479 notify_event(cty\n+0004ab70: 7065 732e 5374 7275 6374 7572 6529 3a0a pes.Structure):.\n+0004ab80: 2020 2020 5f66 6965 6c64 735f 203d 2028 _fields_ = (\n+0004ab90: 0a20 2020 2020 2020 2028 2777 6427 2c20 . ('wd', \n+0004aba0: 6374 7970 6573 2e63 5f69 6e74 3332 292c ctypes.c_int32),\n+0004abb0: 0a20 2020 2020 2020 2028 276d 6173 6b27 . ('mask'\n+0004abc0: 2c20 6374 7970 6573 2e63 5f75 696e 7433 , ctypes.c_uint3\n+0004abd0: 3229 2c0a 2020 2020 2020 2020 2827 636f 2),. ('co\n+0004abe0: 6f6b 6965 272c 2063 7479 7065 732e 635f okie', ctypes.c_\n+0004abf0: 7569 6e74 3332 292c 0a20 2020 2020 2020 uint32),. \n+0004ac00: 2028 276c 656e 272c 2063 7479 7065 732e ('len', ctypes.\n+0004ac10: 635f 7569 6e74 3332 292c 0a20 2020 2029 c_uint32),. )\n+0004ac20: 0a0a 2020 2020 4070 726f 7065 7274 790a .. @property.\n+0004ac30: 2020 2020 6465 6620 6e61 6d65 2873 656c def name(sel\n+0004ac40: 6629 202d 3e20 4f70 7469 6f6e 616c 5b62 f) -> Optional[b\n+0004ac50: 7974 6573 5d3a 0a20 2020 2020 2020 2069 ytes]:. i\n+0004ac60: 6620 7365 6c66 2e6c 656e 203d 3d20 303a f self.len == 0:\n+0004ac70: 0a20 2020 2020 2020 2020 2020 2072 6574 . ret\n+0004ac80: 7572 6e20 4e6f 6e65 0a0a 2020 2020 2020 urn None.. \n+0004ac90: 2020 636c 6173 7320 6576 656e 745f 7769 class event_wi\n+0004aca0: 7468 5f6e 616d 6528 6374 7970 6573 2e53 th_name(ctypes.S\n+0004acb0: 7472 7563 7475 7265 293a 0a20 2020 2020 tructure):. \n+0004acc0: 2020 2020 2020 205f 6669 656c 6473 5f20 _fields_ \n+0004acd0: 3d20 282a 696e 6f74 6966 795f 6576 656e = (*inotify_even\n+0004ace0: 742e 5f66 6965 6c64 735f 2c20 2827 6e61 t._fields_, ('na\n+0004acf0: 6d65 272c 2063 7479 7065 732e 635f 6368 me', ctypes.c_ch\n+0004ad00: 6172 202a 2073 656c 662e 6c65 6e29 290a ar * self.len)).\n+0004ad10: 0a20 2020 2020 2020 206e 616d 6520 3d20 . name = \n+0004ad20: 6374 7970 6573 2e63 6173 7428 6374 7970 ctypes.cast(ctyp\n+0004ad30: 6573 2e61 6464 7265 7373 6f66 2873 656c es.addressof(sel\n+0004ad40: 6629 2c20 6374 7970 6573 2e50 4f49 4e54 f), ctypes.POINT\n+0004ad50: 4552 2865 7665 6e74 5f77 6974 685f 6e61 ER(event_with_na\n+0004ad60: 6d65 2929 2e63 6f6e 7465 6e74 732e 6e61 me)).contents.na\n+0004ad70: 6d65 0a20 2020 2020 2020 2061 7373 6572 me. asser\n+0004ad80: 7420 6973 696e 7374 616e 6365 286e 616d t isinstance(nam\n+0004ad90: 652c 2062 7974 6573 290a 2020 2020 2020 e, bytes). \n+0004ada0: 2020 7265 7475 726e 206e 616d 650a 0a0a return name...\n+0004adb0: 636c 6173 7320 4576 656e 7428 496e 7446 class Event(IntF\n+0004adc0: 6c61 6729 3a0a 2020 2020 4143 4345 5353 lag):. ACCESS\n+0004add0: 203d 2061 7574 6f28 290a 2020 2020 4d4f = auto(). MO\n+0004ade0: 4449 4659 203d 2061 7574 6f28 290a 2020 DIFY = auto(). \n+0004adf0: 2020 4154 5452 4942 203d 2061 7574 6f28 ATTRIB = auto(\n+0004ae00: 290a 2020 2020 434c 4f53 455f 5752 4954 ). CLOSE_WRIT\n+0004ae10: 4520 3d20 6175 746f 2829 0a20 2020 2043 E = auto(). C\n+0004ae20: 4c4f 5345 5f4e 4f57 5249 5445 203d 2061 LOSE_NOWRITE = a\n+0004ae30: 7574 6f28 290a 2020 2020 4f50 454e 203d uto(). OPEN =\n+0004ae40: 2061 7574 6f28 290a 2020 2020 4d4f 5645 auto(). MOVE\n+0004ae50: 445f 4652 4f4d 203d 2061 7574 6f28 290a D_FROM = auto().\n+0004ae60: 2020 2020 4d4f 5645 445f 544f 203d 2061 MOVED_TO = a\n+0004ae70: 7574 6f28 290a 2020 2020 4352 4541 5445 uto(). CREATE\n+0004ae80: 203d 2061 7574 6f28 290a 2020 2020 4445 = auto(). DE\n+0004ae90: 4c45 5445 203d 2061 7574 6f28 290a 2020 LETE = auto(). \n+0004aea0: 2020 4445 4c45 5445 5f53 454c 4620 3d20 DELETE_SELF = \n+0004aeb0: 6175 746f 2829 0a20 2020 204d 4f56 455f auto(). MOVE_\n+0004aec0: 5345 4c46 203d 2061 7574 6f28 290a 0a20 SELF = auto().. \n+0004aed0: 2020 2055 4e4d 4f55 4e54 203d 2031 203c UNMOUNT = 1 <\n+0004aee0: 3c20 3133 0a20 2020 2051 5f4f 5645 5246 < 13. Q_OVERF\n+0004aef0: 4c4f 5720 3d20 6175 746f 2829 0a20 2020 LOW = auto(). \n+0004af00: 2049 474e 4f52 4544 203d 2061 7574 6f28 IGNORED = auto(\n+0004af10: 290a 0a20 2020 204f 4e4c 5944 4952 203d ).. ONLYDIR =\n+0004af20: 2031 203c 3c20 3234 0a20 2020 2044 4f4e 1 << 24. DON\n+0004af30: 545f 464f 4c4c 4f57 203d 2061 7574 6f28 T_FOLLOW = auto(\n+0004af40: 290a 2020 2020 4558 434c 5f55 4e4c 494e ). EXCL_UNLIN\n+0004af50: 4b20 3d20 6175 746f 2829 0a0a 2020 2020 K = auto().. \n+0004af60: 4d41 534b 5f43 5245 4154 4520 3d20 3120 MASK_CREATE = 1 \n+0004af70: 3c3c 2032 380a 2020 2020 4d41 534b 5f41 << 28. MASK_A\n+0004af80: 4444 203d 2061 7574 6f28 290a 2020 2020 DD = auto(). \n+0004af90: 4953 4449 5220 3d20 6175 746f 2829 0a20 ISDIR = auto(). \n+0004afa0: 2020 204f 4e45 5348 4f54 203d 2061 7574 ONESHOT = aut\n+0004afb0: 6f28 290a 0a20 2020 2043 4c4f 5345 203d o().. CLOSE =\n+0004afc0: 2043 4c4f 5345 5f57 5249 5445 207c 2043 CLOSE_WRITE | C\n+0004afd0: 4c4f 5345 5f4e 4f57 5249 5445 0a20 2020 LOSE_NOWRITE. \n+0004afe0: 204d 4f56 4520 3d20 4d4f 5645 445f 4652 MOVE = MOVED_FR\n+0004aff0: 4f4d 207c 204d 4f56 4544 5f54 4f0a 2020 OM | MOVED_TO. \n+0004b000: 2020 4348 414e 4745 4420 3d20 284d 4f44 CHANGED = (MOD\n+0004b010: 4946 5920 7c20 4154 5452 4942 207c 2043 IFY | ATTRIB | C\n+0004b020: 4c4f 5345 5f57 5249 5445 207c 204d 4f56 LOSE_WRITE | MOV\n+0004b030: 4520 7c0a 2020 2020 2020 2020 2020 2020 E |. \n+0004b040: 2020 2043 5245 4154 4520 7c20 4445 4c45 CREATE | DELE\n+0004b050: 5445 207c 2044 454c 4554 455f 5345 4c46 TE | DELETE_SELF\n+0004b060: 207c 204d 4f56 455f 5345 4c46 290a 2727 | MOVE_SELF).''\n+0004b070: 272c 0a20 2027 636f 636b 7069 742f 5f76 ',. 'cockpit/_v\n+0004b080: 656e 646f 722f 7379 7374 656d 645f 6374 endor/systemd_ct\n+0004b090: 7970 6573 2f62 7573 2e70 7927 3a20 6272 ypes/bus.py': br\n+0004b0a0: 2727 2723 2073 7973 7465 6d64 5f63 7479 '''# systemd_cty\n+0004b0b0: 7065 730a 230a 2320 436f 7079 7269 6768 pes.#.# Copyrigh\n+0004b0c0: 7420 2843 2920 3230 3232 2041 6c6c 6973 t (C) 2022 Allis\n+0004b0d0: 6f6e 204b 6172 6c69 7473 6b61 7961 203c on Karlitskaya <\n+0004b0e0: 616c 6c69 736f 6e2e 6b61 726c 6974 736b allison.karlitsk\n+0004b0f0: 6179 6140 7265 6468 6174 2e63 6f6d 3e0a aya@redhat.com>.\n+0004b100: 230a 2320 5468 6973 2070 726f 6772 616d #.# This program\n+0004b110: 2069 7320 6672 6565 2073 6f66 7477 6172 is free softwar\n+0004b120: 653a 2079 6f75 2063 616e 2072 6564 6973 e: you can redis\n+0004b130: 7472 6962 7574 6520 6974 2061 6e64 2f6f tribute it and/o\n+0004b140: 7220 6d6f 6469 6679 0a23 2069 7420 756e r modify.# it un\n+0004b150: 6465 7220 7468 6520 7465 726d 7320 6f66 der the terms of\n+0004b160: 2074 6865 2047 4e55 2047 656e 6572 616c the GNU General\n+0004b170: 2050 7562 6c69 6320 4c69 6365 6e73 6520 Public License \n+0004b180: 6173 2070 7562 6c69 7368 6564 2062 790a as published by.\n+0004b190: 2320 7468 6520 4672 6565 2053 6f66 7477 # the Free Softw\n+0004b1a0: 6172 6520 466f 756e 6461 7469 6f6e 2c20 are Foundation, \n+0004b1b0: 6569 7468 6572 2076 6572 7369 6f6e 2033 either version 3\n+0004b1c0: 206f 6620 7468 6520 4c69 6365 6e73 652c of the License,\n+0004b1d0: 206f 720a 2320 2861 7420 796f 7572 206f or.# (at your o\n+0004b1e0: 7074 696f 6e29 2061 6e79 206c 6174 6572 ption) any later\n+0004b1f0: 2076 6572 7369 6f6e 2e0a 230a 2320 5468 version..#.# Th\n+0004b200: 6973 2070 726f 6772 616d 2069 7320 6469 is program is di\n+0004b210: 7374 7269 6275 7465 6420 696e 2074 6865 stributed in the\n+0004b220: 2068 6f70 6520 7468 6174 2069 7420 7769 hope that it wi\n+0004b230: 6c6c 2062 6520 7573 6566 756c 2c0a 2320 ll be useful,.# \n+0004b240: 6275 7420 5749 5448 4f55 5420 414e 5920 but WITHOUT ANY \n+0004b250: 5741 5252 414e 5459 3b20 7769 7468 6f75 WARRANTY; withou\n+0004b260: 7420 6576 656e 2074 6865 2069 6d70 6c69 t even the impli\n+0004b270: 6564 2077 6172 7261 6e74 7920 6f66 0a23 ed warranty of.#\n+0004b280: 204d 4552 4348 414e 5441 4249 4c49 5459 MERCHANTABILITY\n+0004b290: 206f 7220 4649 544e 4553 5320 464f 5220 or FITNESS FOR \n+0004b2a0: 4120 5041 5254 4943 554c 4152 2050 5552 A PARTICULAR PUR\n+0004b2b0: 504f 5345 2e20 2053 6565 2074 6865 0a23 POSE. See the.#\n+0004b2c0: 2047 4e55 2047 656e 6572 616c 2050 7562 GNU General Pub\n+0004b2d0: 6c69 6320 4c69 6365 6e73 6520 666f 7220 lic License for \n+0004b2e0: 6d6f 7265 2064 6574 6169 6c73 2e0a 230a more details..#.\n+0004b2f0: 2320 596f 7520 7368 6f75 6c64 2068 6176 # You should hav\n+0004b300: 6520 7265 6365 6976 6564 2061 2063 6f70 e received a cop\n+0004b310: 7920 6f66 2074 6865 2047 4e55 2047 656e y of the GNU Gen\n+0004b320: 6572 616c 2050 7562 6c69 6320 4c69 6365 eral Public Lice\n+0004b330: 6e73 650a 2320 616c 6f6e 6720 7769 7468 nse.# along with\n+0004b340: 2074 6869 7320 7072 6f67 7261 6d2e 2020 this program. \n+0004b350: 4966 206e 6f74 2c20 7365 6520 3c68 7474 If not, see <htt\n+0004b360: 703a 2f2f 7777 772e 676e 752e 6f72 672f p://www.gnu.org/\n+0004b370: 6c69 6365 6e73 6573 2f3e 2e0a 0a69 6d70 licenses/>...imp\n+0004b380: 6f72 7420 6173 796e 6369 6f0a 696d 706f ort asyncio.impo\n+0004b390: 7274 2065 6e75 6d0a 696d 706f 7274 206c rt enum.import l\n+0004b3a0: 6f67 6769 6e67 0a69 6d70 6f72 7420 7479 ogging.import ty\n+0004b3b0: 7069 6e67 0a66 726f 6d20 7479 7069 6e67 ping.from typing\n+0004b3c0: 2069 6d70 6f72 7420 416e 792c 2043 616c import Any, Cal\n+0004b3d0: 6c61 626c 652c 2044 6963 742c 204f 7074 lable, Dict, Opt\n+0004b3e0: 696f 6e61 6c2c 2053 6571 7565 6e63 652c ional, Sequence,\n+0004b3f0: 2054 7570 6c65 2c20 556e 696f 6e0a 0a66 Tuple, Union..f\n+0004b400: 726f 6d20 2e20 696d 706f 7274 2062 7573 rom . import bus\n+0004b410: 7479 7065 732c 2069 6e74 726f 7370 6563 types, introspec\n+0004b420: 7469 6f6e 2c20 6c69 6273 7973 7465 6d64 tion, libsystemd\n+0004b430: 0a66 726f 6d20 2e6c 6962 7261 7279 7772 .from .librarywr\n+0004b440: 6170 7065 7220 696d 706f 7274 2057 6561 apper import Wea\n+0004b450: 6b52 6566 6572 656e 6365 2c20 6279 7265 kReference, byre\n+0004b460: 660a 0a6c 6f67 6765 7220 3d20 6c6f 6767 f..logger = logg\n+0004b470: 696e 672e 6765 744c 6f67 6765 7228 5f5f ing.getLogger(__\n+0004b480: 6e61 6d65 5f5f 290a 0a0a 636c 6173 7320 name__)...class \n+0004b490: 4275 7345 7272 6f72 2845 7863 6570 7469 BusError(Excepti\n+0004b4a0: 6f6e 293a 0a20 2020 2022 2222 416e 2065 on):. \"\"\"An e\n+0004b4b0: 7863 6570 7469 6f6e 2063 6f72 7265 7370 xception corresp\n+0004b4c0: 6f6e 6469 6e67 2074 6f20 6120 442d 4275 onding to a D-Bu\n+0004b4d0: 7320 6572 726f 7220 6d65 7373 6167 650a s error message.\n+0004b4e0: 0a20 2020 2054 6869 7320 6578 6365 7074 . This except\n+0004b4f0: 696f 6e20 6973 2072 6169 7365 6420 6279 ion is raised by\n+0004b500: 2074 6865 206d 6574 686f 6420 6361 6c6c the method call\n+0004b510: 206d 6574 686f 6473 2e20 2059 6f75 2063 methods. You c\n+0004b520: 616e 2061 6c73 6f20 7261 6973 6520 6974 an also raise it\n+0004b530: 0a20 2020 2066 726f 6d20 796f 7572 206f . from your o\n+0004b540: 776e 206d 6574 686f 6420 6861 6e64 6c65 wn method handle\n+0004b550: 7273 2e20 2049 7420 6361 6e20 616c 736f rs. It can also\n+0004b560: 2062 6520 7061 7373 6564 2064 6972 6563 be passed direc\n+0004b570: 746c 7920 746f 2066 756e 6374 696f 6e73 tly to functions\n+0004b580: 0a20 2020 2073 7563 6820 6173 204d 6573 . such as Mes\n+0004b590: 7361 6765 2e72 6570 6c79 5f6d 6574 686f sage.reply_metho\n+0004b5a0: 645f 6572 726f 7228 292e 0a0a 2020 2020 d_error()... \n+0004b5b0: 3a6e 616d 653a 2074 6865 2027 636f 6465 :name: the 'code\n+0004b5c0: 2720 6f66 2074 6865 2065 7272 6f72 2c20 ' of the error, \n+0004b5d0: 6c69 6b65 206f 7267 2e66 7265 6564 6573 like org.freedes\n+0004b5e0: 6b74 6f70 2e44 4275 732e 4572 726f 722e ktop.DBus.Error.\n+0004b5f0: 556e 6b6e 6f77 6e4d 6574 686f 640a 2020 UnknownMethod. \n+0004b600: 2020 3a6d 6573 7361 6765 3a20 6120 6875 :message: a hu\n+0004b610: 6d61 6e2d 7265 6164 6162 6c65 2064 6573 man-readable des\n+0004b620: 6372 6970 7469 6f6e 206f 6620 7468 6520 cription of the \n+0004b630: 6572 726f 720a 2020 2020 2222 220a 2020 error. \"\"\". \n+0004b640: 2020 6465 6620 5f5f 696e 6974 5f5f 2873 def __init__(s\n+0004b650: 656c 662c 206e 616d 653a 2073 7472 2c20 elf, name: str, \n+0004b660: 6d65 7373 6167 653a 2073 7472 293a 0a20 message: str):. \n+0004b670: 2020 2020 2020 2073 7570 6572 2829 2e5f super()._\n+0004b680: 5f69 6e69 745f 5f28 6627 7b6e 616d 657d _init__(f'{name}\n+0004b690: 3a20 7b6d 6573 7361 6765 7d27 290a 2020 : {message}'). \n+0004b6a0: 2020 2020 2020 7365 6c66 2e6e 616d 6520 self.name \n+0004b6b0: 3d20 6e61 6d65 0a20 2020 2020 2020 2073 = name. s\n+0004b6c0: 656c 662e 6d65 7373 6167 6520 3d20 6d65 elf.message = me\n+0004b6d0: 7373 6167 650a 0a0a 636c 6173 7320 4275 ssage...class Bu\n+0004b6e0: 734d 6573 7361 6765 286c 6962 7379 7374 sMessage(libsyst\n+0004b6f0: 656d 642e 7364 5f62 7573 5f6d 6573 7361 emd.sd_bus_messa\n+0004b700: 6765 293a 0a20 2020 2022 2222 4120 6d65 ge):. \"\"\"A me\n+0004b710: 7373 6167 652c 2072 6563 6569 7665 6420 ssage, received \n+0004b720: 6672 6f6d 206f 7220 746f 2062 6520 7365 from or to be se\n+0004b730: 6e74 206f 7665 7220 442d 4275 730a 0a20 nt over D-Bus.. \n+0004b740: 2020 2054 6869 7320 6973 2074 6865 206c This is the l\n+0004b750: 6f77 2d6c 6576 656c 2069 6e74 6572 6661 ow-level interfa\n+0004b760: 6365 2074 6f20 7265 6365 6976 696e 6720 ce to receiving \n+0004b770: 616e 6420 7365 6e64 696e 6720 696e 6469 and sending indi\n+0004b780: 7669 6475 616c 0a20 2020 206d 6573 7361 vidual. messa\n+0004b790: 6765 7320 6f76 6572 2044 2d42 7573 2e20 ges over D-Bus. \n+0004b7a0: 2059 6f75 2077 6f6e 2774 206e 6f72 6d61 You won't norma\n+0004b7b0: 6c6c 7920 6e65 6564 2074 6f20 7573 6520 lly need to use \n+0004b7c0: 6974 2e0a 0a20 2020 2041 206d 6573 7361 it... A messa\n+0004b7d0: 6765 2069 7320 6173 736f 6369 6174 6564 ge is associated\n+0004b7e0: 2077 6974 6820 6120 7061 7274 6963 756c with a particul\n+0004b7f0: 6172 2062 7573 2e20 2059 6f75 2063 616e ar bus. You can\n+0004b800: 2063 7265 6174 6520 6d65 7373 6167 6573 create messages\n+0004b810: 2066 6f72 0a20 2020 2061 2062 7573 2077 for. a bus w\n+0004b820: 6974 6820 4275 732e 6d65 7373 6167 655f ith Bus.message_\n+0004b830: 6e65 775f 6d65 7468 6f64 5f63 616c 6c28 new_method_call(\n+0004b840: 2920 6f72 2042 7573 2e6d 6573 7361 6765 ) or Bus.message\n+0004b850: 5f6e 6577 5f73 6967 6e61 6c28 292e 2020 _new_signal(). \n+0004b860: 596f 750a 2020 2020 6361 6e20 6372 6561 You. can crea\n+0004b870: 7465 2072 6570 6c69 6573 2074 6f20 6d65 te replies to me\n+0004b880: 7468 6f64 2063 616c 6c73 2077 6974 6820 thod calls with \n+0004b890: 4d65 7373 6167 652e 6e65 775f 6d65 7468 Message.new_meth\n+0004b8a0: 6f64 5f72 6574 7572 6e28 2920 6f72 0a20 od_return() or. \n+0004b8b0: 2020 204d 6573 7361 6765 2e6e 6577 5f6d Message.new_m\n+0004b8c0: 6574 686f 645f 6572 726f 7228 292e 2020 ethod_error(). \n+0004b8d0: 596f 7520 6361 6e20 6170 7065 6e64 2061 You can append a\n+0004b8e0: 7267 756d 656e 7473 2077 6974 6820 4d65 rguments with Me\n+0004b8f0: 7373 6167 652e 6170 7065 6e64 2829 0a20 ssage.append(). \n+0004b900: 2020 2061 6e64 2073 656e 6420 7468 6520 and send the \n+0004b910: 6d65 7373 6167 6520 7769 7468 204d 6573 message with Mes\n+0004b920: 7361 6765 2e73 656e 6428 292e 0a20 2020 sage.send().. \n+0004b930: 2022 2222 0a20 2020 2064 6566 2067 6574 \"\"\". def get\n+0004b940: 5f62 7573 2873 656c 6629 202d 3e20 2742 _bus(self) -> 'B\n+0004b950: 7573 273a 0a20 2020 2020 2020 2022 2222 us':. \"\"\"\n+0004b960: 4765 7420 7468 6520 6275 7320 7468 6174 Get the bus that\n+0004b970: 2061 206d 6573 7361 6765 2069 7320 6173 a message is as\n+0004b980: 736f 6369 6174 6564 2077 6974 682e 0a0a sociated with...\n+0004b990: 2020 2020 2020 2020 5468 6973 2069 7320 This is \n+0004b9a0: 7468 6520 6275 7320 7468 6174 2061 206d the bus that a m\n+0004b9b0: 6573 7361 6765 2063 616d 6520 6672 6f6d essage came from\n+0004b9c0: 206f 7220 7769 6c6c 2062 6520 7365 6e74 or will be sent\n+0004b9d0: 206f 6e2e 2020 4576 6572 790a 2020 2020 on. Every. \n+0004b9e0: 2020 2020 6d65 7373 6167 6520 6861 7320 message has \n+0004b9f0: 616e 2061 7373 6f63 6961 7465 6420 6275 an associated bu\n+0004ba00: 732c 2061 6e64 2069 7420 6361 6e6e 6f74 s, and it cannot\n+0004ba10: 2062 6520 6368 616e 6765 642e 0a0a 2020 be changed... \n+0004ba20: 2020 2020 2020 3a72 6574 7572 6e73 3a20 :returns: \n+0004ba30: 7468 6520 4275 730a 2020 2020 2020 2020 the Bus. \n+0004ba40: 2222 220a 2020 2020 2020 2020 7265 7475 \"\"\". retu\n+0004ba50: 726e 2042 7573 2e72 6566 2873 656c 662e rn Bus.ref(self.\n+0004ba60: 5f67 6574 5f62 7573 2829 290a 0a20 2020 _get_bus()).. \n+0004ba70: 2064 6566 2067 6574 5f65 7272 6f72 2873 def get_error(s\n+0004ba80: 656c 6629 202d 3e20 4f70 7469 6f6e 616c elf) -> Optional\n+0004ba90: 5b42 7573 4572 726f 725d 3a0a 2020 2020 [BusError]:. \n+0004baa0: 2020 2020 2222 2247 6574 2074 6865 2042 \"\"\"Get the B\n+0004bab0: 7573 4572 726f 7220 6672 6f6d 2061 206d usError from a m\n+0004bac0: 6573 7361 6765 2e0a 0a20 2020 2020 2020 essage... \n+0004bad0: 203a 7265 7475 726e 733a 2061 2042 7573 :returns: a Bus\n+0004bae0: 4572 726f 7220 666f 7220 616e 2065 7272 Error for an err\n+0004baf0: 6f72 206d 6573 7361 6765 2c20 6f72 204e or message, or N\n+0004bb00: 6f6e 6520 666f 7220 6120 6e6f 6e2d 6572 one for a non-er\n+0004bb10: 726f 7220 6d65 7373 6167 650a 2020 2020 ror message. \n+0004bb20: 2020 2020 2222 220a 2020 2020 2020 2020 \"\"\". \n+0004bb30: 6572 726f 7220 3d20 7365 6c66 2e5f 6765 error = self._ge\n+0004bb40: 745f 6572 726f 7228 290a 2020 2020 2020 t_error(). \n+0004bb50: 2020 6966 2065 7272 6f72 3a0a 2020 2020 if error:. \n+0004bb60: 2020 2020 2020 2020 7265 7475 726e 2042 return B\n+0004bb70: 7573 4572 726f 7228 2a65 7272 6f72 2e63 usError(*error.c\n+0004bb80: 6f6e 7465 6e74 732e 6765 7428 2929 0a20 ontents.get()). \n+0004bb90: 2020 2020 2020 2065 6c73 653a 0a20 2020 else:. \n+0004bba0: 2020 2020 2020 2020 2072 6574 7572 6e20 return \n+0004bbb0: 4e6f 6e65 0a0a 2020 2020 6465 6620 6e65 None.. def ne\n+0004bbc0: 775f 6d65 7468 6f64 5f72 6574 7572 6e28 w_method_return(\n+0004bbd0: 7365 6c66 2c20 7369 676e 6174 7572 653a self, signature:\n+0004bbe0: 2073 7472 203d 2027 272c 202a 6172 6773 str = '', *args\n+0004bbf0: 3a20 416e 7929 202d 3e20 2742 7573 4d65 : Any) -> 'BusMe\n+0004bc00: 7373 6167 6527 3a0a 2020 2020 2020 2020 ssage':. \n+0004bc10: 2222 2243 7265 6174 6520 6120 6e65 7720 \"\"\"Create a new \n+0004bc20: 2873 7563 6365 7373 6675 6c29 2072 6574 (successful) ret\n+0004bc30: 7572 6e20 6d65 7373 6167 6520 6173 2061 urn message as a\n+0004bc40: 2072 6570 6c79 2074 6f20 7468 6973 206d reply to this m\n+0004bc50: 6573 7361 6765 2e0a 0a20 2020 2020 2020 essage... \n+0004bc60: 2054 6869 7320 6f6e 6c79 206d 616b 6573 This only makes\n+0004bc70: 2073 656e 7365 2077 6865 6e20 7065 7266 sense when perf\n+0004bc80: 6f72 6d65 6420 6f6e 2061 206d 6574 686f ormed on a metho\n+0004bc90: 6420 6361 6c6c 206d 6573 7361 6765 2e0a d call message..\n+0004bca0: 0a20 2020 2020 2020 203a 7369 676e 6174 . :signat\n+0004bcb0: 7572 653a 2054 6865 2073 6967 6e61 7475 ure: The signatu\n+0004bcc0: 7265 206f 6620 7468 6520 7265 7375 6c74 re of the result\n+0004bcd0: 2c20 6173 2061 2073 7472 696e 672e 0a20 , as a string.. \n+0004bce0: 2020 2020 2020 203a 6172 6773 3a20 5468 :args: Th\n+0004bcf0: 6520 7661 6c75 6573 2074 6f20 7365 6e64 e values to send\n+0004bd00: 2c20 636f 6e66 6f72 6d69 6e67 2074 6f20 , conforming to \n+0004bd10: 7468 6520 7369 676e 6174 7572 6520 7374 the signature st\n+0004bd20: 7269 6e67 2e0a 0a20 2020 2020 2020 203a ring... :\n+0004bd30: 7265 7475 726e 733a 2074 6865 2072 6570 returns: the rep\n+0004bd40: 6c79 206d 6573 7361 6765 0a20 2020 2020 ly message. \n+0004bd50: 2020 2022 2222 0a20 2020 2020 2020 2072 \"\"\". r\n+0004bd60: 6570 6c79 203d 2042 7573 4d65 7373 6167 eply = BusMessag\n+0004bd70: 6528 290a 2020 2020 2020 2020 7365 6c66 e(). self\n+0004bd80: 2e5f 6e65 775f 6d65 7468 6f64 5f72 6574 ._new_method_ret\n+0004bd90: 7572 6e28 6279 7265 6628 7265 706c 7929 urn(byref(reply)\n+0004bda0: 290a 2020 2020 2020 2020 7265 706c 792e ). reply.\n+0004bdb0: 6170 7065 6e64 2873 6967 6e61 7475 7265 append(signature\n+0004bdc0: 2c20 2a61 7267 7329 0a20 2020 2020 2020 , *args). \n+0004bdd0: 2072 6574 7572 6e20 7265 706c 790a 0a20 return reply.. \n+0004bde0: 2020 2064 6566 206e 6577 5f6d 6574 686f def new_metho\n+0004bdf0: 645f 6572 726f 7228 7365 6c66 2c20 6572 d_error(self, er\n+0004be00: 726f 723a 2055 6e69 6f6e 5b42 7573 4572 ror: Union[BusEr\n+0004be10: 726f 722c 204f 5345 7272 6f72 5d29 202d ror, OSError]) -\n+0004be20: 3e20 2742 7573 4d65 7373 6167 6527 3a0a > 'BusMessage':.\n+0004be30: 2020 2020 2020 2020 2222 2243 7265 6174 \"\"\"Creat\n+0004be40: 6520 6120 6e65 7720 6572 726f 7220 6d65 e a new error me\n+0004be50: 7373 6167 6520 6173 2061 2072 6570 6c79 ssage as a reply\n+0004be60: 2074 6f20 7468 6973 206d 6573 7361 6765 to this message\n+0004be70: 2e0a 0a20 2020 2020 2020 2054 6869 7320 ... This \n+0004be80: 6f6e 6c79 206d 616b 6573 2073 656e 7365 only makes sense\n+0004be90: 2077 6865 6e20 7065 7266 6f72 6d65 6420 when performed \n+0004bea0: 6f6e 2061 206d 6574 686f 6420 6361 6c6c on a method call\n+0004beb0: 206d 6573 7361 6765 2e0a 0a20 2020 2020 message... \n+0004bec0: 2020 203a 6572 726f 723a 2042 7573 4572 :error: BusEr\n+0004bed0: 726f 7220 6f72 204f 5345 7272 6f72 206f ror or OSError o\n+0004bee0: 6620 7468 6520 6572 726f 7220 746f 2073 f the error to s\n+0004bef0: 656e 640a 0a20 2020 2020 2020 203a 7265 end.. :re\n+0004bf00: 7475 726e 733a 2074 6865 2072 6570 6c79 turns: the reply\n+0004bf10: 206d 6573 7361 6765 0a20 2020 2020 2020 message. \n+0004bf20: 2022 2222 0a20 2020 2020 2020 2072 6570 \"\"\". rep\n+0004bf30: 6c79 203d 2042 7573 4d65 7373 6167 6528 ly = BusMessage(\n+0004bf40: 290a 2020 2020 2020 2020 6966 2069 7369 ). if isi\n+0004bf50: 6e73 7461 6e63 6528 6572 726f 722c 2042 nstance(error, B\n+0004bf60: 7573 4572 726f 7229 3a0a 2020 2020 2020 usError):. \n+0004bf70: 2020 2020 2020 7365 6c66 2e5f 6e65 775f self._new_\n+0004bf80: 6d65 7468 6f64 5f65 7272 6f72 6628 6279 method_errorf(by\n+0004bf90: 7265 6628 7265 706c 7929 2c20 6572 726f ref(reply), erro\n+0004bfa0: 722e 6e61 6d65 2c20 2225 7322 2c20 6572 r.name, \"%s\", er\n+0004bfb0: 726f 722e 6d65 7373 6167 6529 0a20 2020 ror.message). \n+0004bfc0: 2020 2020 2065 6c73 653a 0a20 2020 2020 else:. \n+0004bfd0: 2020 2020 2020 2061 7373 6572 7420 6973 assert is\n+0004bfe0: 696e 7374 616e 6365 2865 7272 6f72 2c20 instance(error, \n+0004bff0: 4f53 4572 726f 7229 0a20 2020 2020 2020 OSError). \n+0004c000: 2020 2020 2073 656c 662e 5f6e 6577 5f6d self._new_m\n+0004c010: 6574 686f 645f 6572 726e 6f66 2862 7972 ethod_errnof(byr\n+0004c020: 6566 2872 6570 6c79 292c 2065 7272 6f72 ef(reply), error\n+0004c030: 2e65 7272 6e6f 2c20 2225 7322 2c20 7374 .errno, \"%s\", st\n+0004c040: 7228 6572 726f 7229 290a 2020 2020 2020 r(error)). \n+0004c050: 2020 7265 7475 726e 2072 6570 6c79 0a0a return reply..\n+0004c060: 2020 2020 6465 6620 6170 7065 6e64 5f61 def append_a\n+0004c070: 7267 2873 656c 662c 2074 7970 6573 7472 rg(self, typestr\n+0004c080: 696e 673a 2073 7472 2c20 6172 673a 2041 ing: str, arg: A\n+0004c090: 6e79 2920 2d3e 204e 6f6e 653a 0a20 2020 ny) -> None:. \n+0004c0a0: 2020 2020 2022 2222 4170 7065 6e64 2061 \"\"\"Append a\n+0004c0b0: 2073 696e 676c 6520 6172 6775 6d65 6e74 single argument\n+0004c0c0: 2074 6f20 7468 6520 6d65 7373 6167 652e to the message.\n+0004c0d0: 0a0a 2020 2020 2020 2020 3a74 7970 6573 .. :types\n+0004c0e0: 7472 696e 673a 2061 2073 696e 676c 6520 tring: a single \n+0004c0f0: 7479 7065 7374 7269 6e67 2c20 7375 6368 typestring, such\n+0004c100: 2061 7320 2773 272c 206f 7220 2761 7b73 as 's', or 'a{s\n+0004c110: 767d 270a 2020 2020 2020 2020 3a61 7267 v}'. :arg\n+0004c120: 3a20 7468 6520 6172 6775 6d65 6e74 2074 : the argument t\n+0004c130: 6f20 6170 7065 6e64 2c20 6d61 7463 6869 o append, matchi\n+0004c140: 6e67 2074 6865 2074 7970 6573 7472 696e ng the typestrin\n+0004c150: 670a 2020 2020 2020 2020 2222 220a 2020 g. \"\"\". \n+0004c160: 2020 2020 2020 7479 7065 5f2c 203d 2062 type_, = b\n+0004c170: 7573 7479 7065 732e 6672 6f6d 5f73 6967 ustypes.from_sig\n+0004c180: 6e61 7475 7265 2874 7970 6573 7472 696e nature(typestrin\n+0004c190: 6729 0a20 2020 2020 2020 2074 7970 655f g). type_\n+0004c1a0: 2e77 7269 7465 7228 7365 6c66 2c20 6172 .writer(self, ar\n+0004c1b0: 6729 0a0a 2020 2020 6465 6620 6170 7065 g).. def appe\n+0004c1c0: 6e64 2873 656c 662c 2073 6967 6e61 7475 nd(self, signatu\n+0004c1d0: 7265 3a20 7374 722c 202a 6172 6773 3a20 re: str, *args: \n+0004c1e0: 416e 7929 202d 3e20 4e6f 6e65 3a0a 2020 Any) -> None:. \n+0004c1f0: 2020 2020 2020 2222 2241 7070 656e 6420 \"\"\"Append \n+0004c200: 7a65 726f 206f 7220 6d6f 7265 2061 7267 zero or more arg\n+0004c210: 756d 656e 7473 2074 6f20 7468 6520 6d65 uments to the me\n+0004c220: 7373 6167 652e 0a0a 2020 2020 2020 2020 ssage... \n+0004c230: 3a73 6967 6e61 7475 7265 3a20 636f 6e63 :signature: conc\n+0004c240: 6174 656e 6174 6564 2074 7970 6573 7472 atenated typestr\n+0004c250: 696e 6773 2c20 7375 6368 2027 617b 7376 ings, such 'a{sv\n+0004c260: 7d27 2028 6f6e 6520 6172 6729 2c20 6f72 }' (one arg), or\n+0004c270: 2027 7373 2720 2874 776f 2061 7267 7329 'ss' (two args)\n+0004c280: 0a20 2020 2020 2020 203a 6172 6773 3a20 . :args: \n+0004c290: 6f6e 6520 6172 6775 6d65 6e74 2066 6f72 one argument for\n+0004c2a0: 2065 6163 6820 7479 7065 2073 7472 696e each type strin\n+0004c2b0: 6720 696e 2074 6865 2073 6967 6e61 7475 g in the signatu\n+0004c2c0: 7265 0a20 2020 2020 2020 2022 2222 0a20 re. \"\"\". \n+0004c2d0: 2020 2020 2020 2074 7970 6573 203d 2062 types = b\n+0004c2e0: 7573 7479 7065 732e 6672 6f6d 5f73 6967 ustypes.from_sig\n+0004c2f0: 6e61 7475 7265 2873 6967 6e61 7475 7265 nature(signature\n+0004c300: 290a 2020 2020 2020 2020 6173 7365 7274 ). assert\n+0004c310: 206c 656e 2874 7970 6573 2920 3d3d 206c len(types) == l\n+0004c320: 656e 2861 7267 7329 2c20 6627 6361 6c6c en(args), f'call\n+0004c330: 2061 7267 7320 7b61 7267 737d 2068 6176 args {args} hav\n+0004c340: 6520 6469 6666 6572 656e 7420 6c65 6e67 e different leng\n+0004c350: 7468 2074 6861 6e20 7369 676e 6174 7572 th than signatur\n+0004c360: 6520 7b73 6967 6e61 7475 7265 7d27 0a20 e {signature}'. \n+0004c370: 2020 2020 2020 2066 6f72 2074 7970 655f for type_\n+0004c380: 2c20 6172 6720 696e 207a 6970 2874 7970 , arg in zip(typ\n+0004c390: 6573 2c20 6172 6773 293a 0a20 2020 2020 es, args):. \n+0004c3a0: 2020 2020 2020 2074 7970 655f 2e77 7269 type_.wri\n+0004c3b0: 7465 7228 7365 6c66 2c20 6172 6729 0a0a ter(self, arg)..\n+0004c3c0: 2020 2020 6465 6620 6765 745f 626f 6479 def get_body\n+0004c3d0: 2873 656c 6629 202d 3e20 5475 706c 655b (self) -> Tuple[\n+0004c3e0: 6f62 6a65 6374 2c20 2e2e 2e5d 3a0a 2020 object, ...]:. \n+0004c3f0: 2020 2020 2020 2222 2247 6574 7320 7468 \"\"\"Gets th\n+0004c400: 6520 626f 6479 206f 6620 6120 6d65 7373 e body of a mess\n+0004c410: 6167 652e 0a0a 2020 2020 2020 2020 506f age... Po\n+0004c420: 7373 6962 6c65 2072 6574 7572 6e20 7661 ssible return va\n+0004c430: 6c75 6573 2061 7265 2028 292c 2028 2773 lues are (), ('s\n+0004c440: 696e 676c 6527 2c29 2c20 6f72 2028 2778 ingle',), or ('x\n+0004c450: 272c 2027 7927 292e 2020 4966 2079 6f75 ', 'y'). If you\n+0004c460: 0a20 2020 2020 2020 2063 6865 636b 2074 . check t\n+0004c470: 6865 2073 6967 6e61 7475 7265 206f 6620 he signature of \n+0004c480: 7468 6520 6d65 7373 6167 6520 7573 696e the message usin\n+0004c490: 6720 4d65 7373 6167 652e 6861 735f 7369 g Message.has_si\n+0004c4a0: 676e 6174 7572 6528 2920 7468 656e 0a20 gnature() then. \n+0004c4b0: 2020 2020 2020 2079 6f75 2063 616e 2075 you can u\n+0004c4c0: 7365 2074 7570 6c65 2075 6e70 6163 6b69 se tuple unpacki\n+0004c4d0: 6e67 2e0a 0a20 2020 2020 2020 2020 2020 ng... \n+0004c4e0: 7369 6e67 6c65 2c20 3d20 6d65 7373 6167 single, = messag\n+0004c4f0: 652e 6765 745f 626f 6479 2829 0a0a 2020 e.get_body().. \n+0004c500: 2020 2020 2020 2020 2078 2c20 7920 3d20 x, y = \n+0004c510: 6f74 6865 725f 6d65 7373 6167 652e 6765 other_message.ge\n+0004c520: 745f 626f 6479 2829 0a0a 2020 2020 2020 t_body().. \n+0004c530: 2020 3a72 6574 7572 6e73 3a20 616e 206e :returns: an n\n+0004c540: 2d74 7570 6c65 2063 6f6e 7461 696e 696e -tuple containin\n+0004c550: 6720 6f6e 6520 7661 6c75 6520 7065 7220 g one value per \n+0004c560: 6172 6775 6d65 6e74 2069 6e20 7468 6520 argument in the \n+0004c570: 6d65 7373 6167 650a 2020 2020 2020 2020 message. \n+0004c580: 2222 220a 2020 2020 2020 2020 7365 6c66 \"\"\". self\n+0004c590: 2e72 6577 696e 6428 5472 7565 290a 2020 .rewind(True). \n+0004c5a0: 2020 2020 2020 7479 7065 7320 3d20 6275 types = bu\n+0004c5b0: 7374 7970 6573 2e66 726f 6d5f 7369 676e stypes.from_sign\n+0004c5c0: 6174 7572 6528 7365 6c66 2e67 6574 5f73 ature(self.get_s\n+0004c5d0: 6967 6e61 7475 7265 2854 7275 6529 290a ignature(True)).\n+0004c5e0: 2020 2020 2020 2020 7265 7475 726e 2074 return t\n+0004c5f0: 7570 6c65 2874 7970 655f 2e72 6561 6465 uple(type_.reade\n+0004c600: 7228 7365 6c66 2920 666f 7220 7479 7065 r(self) for type\n+0004c610: 5f20 696e 2074 7970 6573 290a 0a20 2020 _ in types).. \n+0004c620: 2064 6566 2073 656e 6428 7365 6c66 2920 def send(self) \n+0004c630: 2d3e 2062 6f6f 6c3a 2020 2320 4c69 7465 -> bool: # Lite\n+0004c640: 7261 6c5b 5472 7565 5d0a 2020 2020 2020 ral[True]. \n+0004c650: 2020 2222 2253 656e 6473 2061 206d 6573 \"\"\"Sends a mes\n+0004c660: 7361 6765 206f 6e20 7468 6520 6275 7320 sage on the bus \n+0004c670: 7468 6174 2069 7420 7761 7320 6372 6561 that it was crea\n+0004c680: 7465 6420 666f 722e 0a0a 2020 2020 2020 ted for... \n+0004c690: 2020 3a72 6574 7572 6e73 3a20 5472 7565 :returns: True\n+0004c6a0: 0a20 2020 2020 2020 2022 2222 0a20 2020 . \"\"\". \n+0004c6b0: 2020 2020 2073 656c 662e 6765 745f 6275 self.get_bu\n+0004c6c0: 7328 292e 7365 6e64 2873 656c 662c 204e s().send(self, N\n+0004c6d0: 6f6e 6529 0a20 2020 2020 2020 2072 6574 one). ret\n+0004c6e0: 7572 6e20 5472 7565 0a0a 2020 2020 6465 urn True.. de\n+0004c6f0: 6620 7265 706c 795f 6d65 7468 6f64 5f65 f reply_method_e\n+0004c700: 7272 6f72 2873 656c 662c 2065 7272 6f72 rror(self, error\n+0004c710: 3a20 556e 696f 6e5b 4275 7345 7272 6f72 : Union[BusError\n+0004c720: 2c20 4f53 4572 726f 725d 2920 2d3e 2062 , OSError]) -> b\n+0004c730: 6f6f 6c3a 2020 2320 4c69 7465 7261 6c5b ool: # Literal[\n+0004c740: 5472 7565 5d0a 2020 2020 2020 2020 2222 True]. \"\"\n+0004c750: 2253 656e 6473 2061 6e20 6572 726f 7220 \"Sends an error \n+0004c760: 6173 2061 2072 6570 6c79 2074 6f20 6120 as a reply to a \n+0004c770: 6d65 7468 6f64 2063 616c 6c20 6d65 7373 method call mess\n+0004c780: 6167 652e 0a0a 2020 2020 2020 2020 3a65 age... :e\n+0004c790: 7272 6f72 3a20 4120 4275 7345 7272 6f72 rror: A BusError\n+0004c7a0: 206f 7220 4f53 4572 726f 720a 0a20 2020 or OSError.. \n+0004c7b0: 2020 2020 203a 7265 7475 726e 733a 2054 :returns: T\n+0004c7c0: 7275 650a 2020 2020 2020 2020 2222 220a rue. \"\"\".\n+0004c7d0: 2020 2020 2020 2020 7265 7475 726e 2073 return s\n+0004c7e0: 656c 662e 6e65 775f 6d65 7468 6f64 5f65 elf.new_method_e\n+0004c7f0: 7272 6f72 2865 7272 6f72 292e 7365 6e64 rror(error).send\n+0004c800: 2829 0a0a 2020 2020 6465 6620 7265 706c ().. def repl\n+0004c810: 795f 6d65 7468 6f64 5f72 6574 7572 6e28 y_method_return(\n+0004c820: 7365 6c66 2c20 7369 676e 6174 7572 653a self, signature:\n+0004c830: 2073 7472 203d 2027 272c 202a 6172 6773 str = '', *args\n+0004c840: 3a20 416e 7929 202d 3e20 626f 6f6c 3a20 : Any) -> bool: \n+0004c850: 2023 204c 6974 6572 616c 5b54 7275 655d # Literal[True]\n+0004c860: 0a20 2020 2020 2020 2022 2222 5365 6e64 . \"\"\"Send\n+0004c870: 7320 6120 7265 7475 726e 2076 616c 7565 s a return value\n+0004c880: 2061 7320 6120 7265 706c 7920 746f 2061 as a reply to a\n+0004c890: 206d 6574 686f 6420 6361 6c6c 206d 6573 method call mes\n+0004c8a0: 7361 6765 2e0a 0a20 2020 2020 2020 203a sage... :\n+0004c8b0: 7369 676e 6174 7572 653a 2054 6865 2073 signature: The s\n+0004c8c0: 6967 6e61 7475 7265 206f 6620 7468 6520 ignature of the \n+0004c8d0: 7265 7375 6c74 2c20 6173 2061 2073 7472 result, as a str\n+0004c8e0: 696e 672e 0a20 2020 2020 2020 203a 6172 ing.. :ar\n+0004c8f0: 6773 3a20 5468 6520 7661 6c75 6573 2074 gs: The values t\n+0004c900: 6f20 7365 6e64 2c20 636f 6e66 6f72 6d69 o send, conformi\n+0004c910: 6e67 2074 6f20 7468 6520 7369 676e 6174 ng to the signat\n+0004c920: 7572 6520 7374 7269 6e67 2e0a 0a20 2020 ure string... \n+0004c930: 2020 2020 203a 7265 7475 726e 733a 2054 :returns: T\n+0004c940: 7275 650a 2020 2020 2020 2020 2222 220a rue. \"\"\".\n+0004c950: 2020 2020 2020 2020 7265 7475 726e 2073 return s\n+0004c960: 656c 662e 6e65 775f 6d65 7468 6f64 5f72 elf.new_method_r\n+0004c970: 6574 7572 6e28 7369 676e 6174 7572 652c eturn(signature,\n+0004c980: 202a 6172 6773 292e 7365 6e64 2829 0a0a *args).send()..\n+0004c990: 2020 2020 6465 6620 5f63 6f72 6f75 7469 def _corouti\n+0004c9a0: 6e65 5f74 6173 6b5f 636f 6d70 6c65 7465 ne_task_complete\n+0004c9b0: 2873 656c 662c 206f 7574 5f74 7970 653a (self, out_type:\n+0004c9c0: 2062 7573 7479 7065 732e 4d65 7373 6167 bustypes.Messag\n+0004c9d0: 6554 7970 652c 2074 6173 6b3a 2061 7379 eType, task: asy\n+0004c9e0: 6e63 696f 2e54 6173 6b29 202d 3e20 4e6f ncio.Task) -> No\n+0004c9f0: 6e65 3a0a 2020 2020 2020 2020 7472 793a ne:. try:\n+0004ca00: 0a20 2020 2020 2020 2020 2020 2073 656c . sel\n+0004ca10: 662e 7265 706c 795f 6d65 7468 6f64 5f66 f.reply_method_f\n+0004ca20: 756e 6374 696f 6e5f 7265 7475 726e 5f76 unction_return_v\n+0004ca30: 616c 7565 286f 7574 5f74 7970 652c 2074 alue(out_type, t\n+0004ca40: 6173 6b2e 7265 7375 6c74 2829 290a 2020 ask.result()). \n+0004ca50: 2020 2020 2020 6578 6365 7074 2028 4275 except (Bu\n+0004ca60: 7345 7272 6f72 2c20 4f53 4572 726f 7229 sError, OSError)\n+0004ca70: 2061 7320 6578 633a 0a20 2020 2020 2020 as exc:. \n+0004ca80: 2020 2020 2073 656c 662e 7265 706c 795f self.reply_\n+0004ca90: 6d65 7468 6f64 5f65 7272 6f72 2865 7863 method_error(exc\n+0004caa0: 290a 0a20 2020 2064 6566 2072 6570 6c79 ).. def reply\n+0004cab0: 5f6d 6574 686f 645f 6675 6e63 7469 6f6e _method_function\n+0004cac0: 5f72 6574 7572 6e5f 7661 6c75 6528 7365 _return_value(se\n+0004cad0: 6c66 2c0a 2020 2020 2020 2020 2020 2020 lf,. \n+0004cae0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0004caf0: 2020 2020 2020 2020 2020 2020 2020 206f o\n+0004cb00: 7574 5f74 7970 653a 2062 7573 7479 7065 ut_type: bustype\n+0004cb10: 732e 4d65 7373 6167 6554 7970 652c 0a20 s.MessageType,. \n+0004cb20: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0004cb30: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0004cb40: 2020 2020 2020 2020 2020 7265 7475 726e return\n+0004cb50: 5f76 616c 7565 3a20 416e 7929 202d 3e20 _value: Any) -> \n+0004cb60: 626f 6f6c 3a20 2023 204c 6974 6572 616c bool: # Literal\n+0004cb70: 5b54 7275 655d 3a0a 2020 2020 2020 2020 [True]:. \n+0004cb80: 2222 2253 656e 6473 2074 6865 2072 6573 \"\"\"Sends the res\n+0004cb90: 756c 7420 6f66 2061 2066 756e 6374 696f ult of a functio\n+0004cba0: 6e20 6361 6c6c 2061 7320 6120 7265 706c n call as a repl\n+0004cbb0: 7920 746f 2061 206d 6574 686f 6420 6361 y to a method ca\n+0004cbc0: 6c6c 206d 6573 7361 6765 2e0a 0a20 2020 ll message... \n+0004cbd0: 2020 2020 2054 6869 7320 6361 6c6c 2064 This call d\n+0004cbe0: 6f65 7320 6120 6269 7420 6f66 206d 6167 oes a bit of mag\n+0004cbf0: 6963 3a20 6974 2061 6461 7074 7320 6672 ic: it adapts fr\n+0004cc00: 6f6d 2074 6865 2075 7375 616c 2050 7974 om the usual Pyt\n+0004cc10: 686f 6e20 7265 7475 726e 0a20 2020 2020 hon return. \n+0004cc20: 2020 2076 616c 7565 2063 6f6e 7665 6e74 value convent\n+0004cc30: 696f 6e73 2028 7768 6572 6520 7468 6520 ions (where the \n+0004cc40: 7265 7475 726e 2076 616c 7565 2069 7320 return value is \n+0004cc50: 6060 4e6f 6e65 6060 2c20 6120 7369 6e67 ``None``, a sing\n+0004cc60: 6c65 2076 616c 7565 2c0a 2020 2020 2020 le value,. \n+0004cc70: 2020 6f72 2061 2074 7570 6c65 2920 746f or a tuple) to\n+0004cc80: 2074 6865 206e 6f72 6d61 6c20 442d 4275 the normal D-Bu\n+0004cc90: 7320 7265 7475 726e 2076 616c 7565 2063 s return value c\n+0004cca0: 6f6e 7665 6e74 696f 6e73 2028 7768 6572 onventions (wher\n+0004ccb0: 6520 7468 650a 2020 2020 2020 2020 7265 e the. re\n+0004ccc0: 7375 6c74 2069 7320 616c 7761 7973 2061 sult is always a\n+0004ccd0: 2074 7570 6c65 292e 0a0a 2020 2020 2020 tuple)... \n+0004cce0: 2020 4164 6469 7469 6f6e 616c 6c79 2c20 Additionally, \n+0004ccf0: 6966 2074 6865 2076 616c 7565 2069 7320 if the value is \n+0004cd00: 666f 756e 6420 746f 2062 6520 6120 636f found to be a co\n+0004cd10: 726f 7574 696e 652c 2061 2074 6173 6b20 routine, a task \n+0004cd20: 6973 0a20 2020 2020 2020 2063 7265 6174 is. creat\n+0004cd30: 6564 2074 6f20 7275 6e20 7468 6520 636f ed to run the co\n+0004cd40: 726f 7574 696e 6520 746f 2063 6f6d 706c routine to compl\n+0004cd50: 6574 696f 6e20 616e 6420 7265 7475 726e etion and return\n+0004cd60: 2074 6865 2072 6573 756c 740a 2020 2020 the result. \n+0004cd70: 2020 2020 2869 6e63 6c75 6469 6e67 2065 (including e\n+0004cd80: 7863 6570 7469 6f6e 2068 616e 646c 696e xception handlin\n+0004cd90: 6729 2e0a 0a20 2020 2020 2020 203a 6f75 g)... :ou\n+0004cda0: 745f 7479 7065 733a 2054 6865 2074 7970 t_types: The typ\n+0004cdb0: 6573 206f 6620 7468 6520 7265 7475 726e es of the return\n+0004cdc0: 2076 616c 7565 732c 2061 7320 616e 2069 values, as an i\n+0004cdd0: 7465 7261 626c 652e 0a20 2020 2020 2020 terable.. \n+0004cde0: 203a 7265 7475 726e 5f76 616c 7565 3a20 :return_value: \n+0004cdf0: 5468 6520 7265 7475 726e 2076 616c 7565 The return value\n+0004ce00: 206f 6620 6120 5079 7468 6f6e 2066 756e of a Python fun\n+0004ce10: 6374 696f 6e20 6361 6c6c 2e0a 0a20 2020 ction call... \n+0004ce20: 2020 2020 203a 7265 7475 726e 733a 2054 :returns: T\n+0004ce30: 7275 650a 2020 2020 2020 2020 2222 220a rue. \"\"\".\n+0004ce40: 2020 2020 2020 2020 6966 2061 7379 6e63 if async\n+0004ce50: 696f 2e63 6f72 6f75 7469 6e65 732e 6973 io.coroutines.is\n+0004ce60: 636f 726f 7574 696e 6528 7265 7475 726e coroutine(return\n+0004ce70: 5f76 616c 7565 293a 0a20 2020 2020 2020 _value):. \n+0004ce80: 2020 2020 2074 6173 6b20 3d20 6173 796e task = asyn\n+0004ce90: 6369 6f2e 6372 6561 7465 5f74 6173 6b28 cio.create_task(\n+0004cea0: 7265 7475 726e 5f76 616c 7565 290a 2020 return_value). \n+0004ceb0: 2020 2020 2020 2020 2020 7461 736b 2e61 task.a\n+0004cec0: 6464 5f64 6f6e 655f 6361 6c6c 6261 636b dd_done_callback\n+0004ced0: 286c 616d 6264 6120 7461 736b 3a20 7365 (lambda task: se\n+0004cee0: 6c66 2e5f 636f 726f 7574 696e 655f 7461 lf._coroutine_ta\n+0004cef0: 736b 5f63 6f6d 706c 6574 6528 6f75 745f sk_complete(out_\n+0004cf00: 7479 7065 2c20 7461 736b 2929 0a20 2020 type, task)). \n+0004cf10: 2020 2020 2020 2020 2072 6574 7572 6e20 return \n+0004cf20: 5472 7565 0a0a 2020 2020 2020 2020 7265 True.. re\n+0004cf30: 706c 7920 3d20 7365 6c66 2e6e 6577 5f6d ply = self.new_m\n+0004cf40: 6574 686f 645f 7265 7475 726e 2829 0a20 ethod_return(). \n+0004cf50: 2020 2020 2020 2023 2049 6e20 7468 6520 # In the \n+0004cf60: 6765 6e65 7261 6c20 6361 7365 2c20 6120 general case, a \n+0004cf70: 6675 6e63 7469 6f6e 2072 6574 7572 6e73 function returns\n+0004cf80: 2061 6e20 6e2d 7475 706c 652c 2062 7574 an n-tuple, but\n+0004cf90: 2e2e 2e0a 2020 2020 2020 2020 6966 206c .... if l\n+0004cfa0: 656e 286f 7574 5f74 7970 6529 203d 3d20 en(out_type) == \n+0004cfb0: 303a 0a20 2020 2020 2020 2020 2020 2023 0:. #\n+0004cfc0: 2046 756e 6374 696f 6e73 2077 6974 6820 Functions with \n+0004cfd0: 6e6f 2072 6574 7572 6e20 7661 6c75 6520 no return value \n+0004cfe0: 7265 7475 726e 204e 6f6e 652e 0a20 2020 return None.. \n+0004cff0: 2020 2020 2020 2020 2061 7373 6572 7420 assert \n+0004d000: 7265 7475 726e 5f76 616c 7565 2069 7320 return_value is \n+0004d010: 4e6f 6e65 0a20 2020 2020 2020 2065 6c69 None. eli\n+0004d020: 6620 6c65 6e28 6f75 745f 7479 7065 2920 f len(out_type) \n+0004d030: 3d3d 2031 3a0a 2020 2020 2020 2020 2020 == 1:. \n+0004d040: 2020 2320 4675 6e63 7469 6f6e 7320 7769 # Functions wi\n+0004d050: 7468 2061 2073 696e 676c 6520 7265 7475 th a single retu\n+0004d060: 726e 2076 616c 7565 2072 6574 7572 6e20 rn value return \n+0004d070: 7468 6174 2076 616c 7565 2e0a 2020 2020 that value.. \n+0004d080: 2020 2020 2020 2020 6f75 745f 7479 7065 out_type\n+0004d090: 2e77 7269 7465 2872 6570 6c79 2c20 7265 .write(reply, re\n+0004d0a0: 7475 726e 5f76 616c 7565 290a 2020 2020 turn_value). \n+0004d0b0: 2020 2020 656c 7365 3a0a 2020 2020 2020 else:. \n+0004d0c0: 2020 2020 2020 2320 2867 656e 6572 616c # (general\n+0004d0d0: 2063 6173 6529 206e 2072 6574 7572 6e20 case) n return \n+0004d0e0: 7661 6c75 6573 2061 7265 2068 616e 646c values are handl\n+0004d0f0: 6564 2061 7320 616e 206e 2d74 7570 6c65 ed as an n-tuple\n+0004d100: 2e0a 2020 2020 2020 2020 2020 2020 6173 .. as\n+0004d110: 7365 7274 206c 656e 286f 7574 5f74 7970 sert len(out_typ\n+0004d120: 6529 203d 3d20 6c65 6e28 7265 7475 726e e) == len(return\n+0004d130: 5f76 616c 7565 290a 2020 2020 2020 2020 _value). \n+0004d140: 2020 2020 6f75 745f 7479 7065 2e77 7269 out_type.wri\n+0004d150: 7465 2872 6570 6c79 2c20 2a72 6574 7572 te(reply, *retur\n+0004d160: 6e5f 7661 6c75 6529 0a20 2020 2020 2020 n_value). \n+0004d170: 2072 6574 7572 6e20 7265 706c 792e 7365 return reply.se\n+0004d180: 6e64 2829 0a0a 0a63 6c61 7373 2053 6c6f nd()...class Slo\n+0004d190: 7428 6c69 6273 7973 7465 6d64 2e73 645f t(libsystemd.sd_\n+0004d1a0: 6275 735f 736c 6f74 293a 0a20 2020 2064 bus_slot):. d\n+0004d1b0: 6566 205f 5f69 6e69 745f 5f28 7365 6c66 ef __init__(self\n+0004d1c0: 2c20 6361 6c6c 6261 636b 3a20 4361 6c6c , callback: Call\n+0004d1d0: 6162 6c65 5b5b 4275 734d 6573 7361 6765 able[[BusMessage\n+0004d1e0: 5d2c 2062 6f6f 6c5d 293a 0a20 2020 2020 ], bool]):. \n+0004d1f0: 2020 2064 6566 2068 616e 646c 6572 286d def handler(m\n+0004d200: 6573 7361 6765 3a20 5765 616b 5265 6665 essage: WeakRefe\n+0004d210: 7265 6e63 652c 205f 6461 7461 3a20 6f62 rence, _data: ob\n+0004d220: 6a65 6374 2c20 5f65 7272 3a20 6f62 6a65 ject, _err: obje\n+0004d230: 6374 2920 2d3e 2069 6e74 3a0a 2020 2020 ct) -> int:. \n+0004d240: 2020 2020 2020 2020 7265 7475 726e 2031 return 1\n+0004d250: 2069 6620 6361 6c6c 6261 636b 2842 7573 if callback(Bus\n+0004d260: 4d65 7373 6167 652e 7265 6628 6d65 7373 Message.ref(mess\n+0004d270: 6167 6529 2920 656c 7365 2030 0a20 2020 age)) else 0. \n+0004d280: 2020 2020 2073 656c 662e 7472 616d 706f self.trampo\n+0004d290: 6c69 6e65 203d 206c 6962 7379 7374 656d line = libsystem\n+0004d2a0: 642e 7364 5f62 7573 5f6d 6573 7361 6765 d.sd_bus_message\n+0004d2b0: 5f68 616e 646c 6572 5f74 2868 616e 646c _handler_t(handl\n+0004d2c0: 6572 290a 0a0a 6966 2074 7970 696e 672e er)...if typing.\n+0004d2d0: 5459 5045 5f43 4845 434b 494e 473a 0a20 TYPE_CHECKING:. \n+0004d2e0: 2020 2046 7574 7572 654d 6573 7361 6765 FutureMessage\n+0004d2f0: 203d 2061 7379 6e63 696f 2e46 7574 7572 = asyncio.Futur\n+0004d300: 655b 4275 734d 6573 7361 6765 5d0a 656c e[BusMessage].el\n+0004d310: 7365 3a0a 2020 2020 2320 5079 7468 6f6e se:. # Python\n+0004d320: 2033 2e36 2063 616e 2774 2073 7562 7363 3.6 can't subsc\n+0004d330: 7269 7074 2061 7379 6e63 696f 2e46 7574 ript asyncio.Fut\n+0004d340: 7572 650a 2020 2020 4675 7475 7265 4d65 ure. FutureMe\n+0004d350: 7373 6167 6520 3d20 6173 796e 6369 6f2e ssage = asyncio.\n+0004d360: 4675 7475 7265 0a0a 0a63 6c61 7373 2050 Future...class P\n+0004d370: 656e 6469 6e67 4361 6c6c 2853 6c6f 7429 endingCall(Slot)\n+0004d380: 3a0a 2020 2020 6675 7475 7265 3a20 4675 :. future: Fu\n+0004d390: 7475 7265 4d65 7373 6167 650a 0a20 2020 tureMessage.. \n+0004d3a0: 2064 6566 205f 5f69 6e69 745f 5f28 7365 def __init__(se\n+0004d3b0: 6c66 2920 2d3e 204e 6f6e 653a 0a20 2020 lf) -> None:. \n+0004d3c0: 2020 2020 2066 7574 7572 6520 3d20 6173 future = as\n+0004d3d0: 796e 6369 6f2e 6765 745f 7275 6e6e 696e yncio.get_runnin\n+0004d3e0: 675f 6c6f 6f70 2829 2e63 7265 6174 655f g_loop().create_\n+0004d3f0: 6675 7475 7265 2829 0a0a 2020 2020 2020 future().. \n+0004d400: 2020 6465 6620 646f 6e65 286d 6573 7361 def done(messa\n+0004d410: 6765 3a20 4275 734d 6573 7361 6765 2920 ge: BusMessage) \n+0004d420: 2d3e 2062 6f6f 6c3a 0a20 2020 2020 2020 -> bool:. \n+0004d430: 2020 2020 2065 7272 6f72 203d 206d 6573 error = mes\n+0004d440: 7361 6765 2e67 6574 5f65 7272 6f72 2829 sage.get_error()\n+0004d450: 0a20 2020 2020 2020 2020 2020 2069 6620 . if \n+0004d460: 6675 7475 7265 2e63 616e 6365 6c6c 6564 future.cancelled\n+0004d470: 2829 3a0a 2020 2020 2020 2020 2020 2020 ():. \n+0004d480: 2020 2020 7265 7475 726e 2054 7275 650a return True.\n+0004d490: 2020 2020 2020 2020 2020 2020 6966 2065 if e\n+0004d4a0: 7272 6f72 2069 7320 6e6f 7420 4e6f 6e65 rror is not None\n+0004d4b0: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n+0004d4c0: 2020 6675 7475 7265 2e73 6574 5f65 7863 future.set_exc\n+0004d4d0: 6570 7469 6f6e 2865 7272 6f72 290a 2020 eption(error). \n+0004d4e0: 2020 2020 2020 2020 2020 656c 7365 3a0a else:.\n+0004d4f0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0004d500: 6675 7475 7265 2e73 6574 5f72 6573 756c future.set_resul\n+0004d510: 7428 6d65 7373 6167 6529 0a20 2020 2020 t(message). \n+0004d520: 2020 2020 2020 2072 6574 7572 6e20 5472 return Tr\n+0004d530: 7565 0a0a 2020 2020 2020 2020 7375 7065 ue.. supe\n+0004d540: 7228 292e 5f5f 696e 6974 5f5f 2864 6f6e r().__init__(don\n+0004d550: 6529 0a20 2020 2020 2020 2073 656c 662e e). self.\n+0004d560: 6675 7475 7265 203d 2066 7574 7572 650a future = future.\n+0004d570: 0a0a 636c 6173 7320 4275 7328 6c69 6273 ..class Bus(libs\n+0004d580: 7973 7465 6d64 2e73 645f 6275 7329 3a0a ystemd.sd_bus):.\n+0004d590: 2020 2020 5f64 6566 6175 6c74 5f73 7973 _default_sys\n+0004d5a0: 7465 6d5f 696e 7374 616e 6365 203d 204e tem_instance = N\n+0004d5b0: 6f6e 650a 2020 2020 5f64 6566 6175 6c74 one. _default\n+0004d5c0: 5f75 7365 725f 696e 7374 616e 6365 203d _user_instance =\n+0004d5d0: 204e 6f6e 650a 0a20 2020 2063 6c61 7373 None.. class\n+0004d5e0: 204e 616d 6546 6c61 6773 2865 6e75 6d2e NameFlags(enum.\n+0004d5f0: 496e 7446 6c61 6729 3a0a 2020 2020 2020 IntFlag):. \n+0004d600: 2020 4445 4641 554c 5420 3d20 300a 2020 DEFAULT = 0. \n+0004d610: 2020 2020 2020 5245 504c 4143 455f 4558 REPLACE_EX\n+0004d620: 4953 5449 4e47 203d 2031 203c 3c20 300a ISTING = 1 << 0.\n+0004d630: 2020 2020 2020 2020 414c 4c4f 575f 5245 ALLOW_RE\n+0004d640: 504c 4143 454d 454e 5420 3d20 3120 3c3c PLACEMENT = 1 <<\n+0004d650: 2031 0a20 2020 2020 2020 2051 5545 5545 1. QUEUE\n+0004d660: 203d 2031 203c 3c20 320a 0a20 2020 2040 = 1 << 2.. @\n+0004d670: 7374 6174 6963 6d65 7468 6f64 0a20 2020 staticmethod. \n+0004d680: 2064 6566 206e 6577 280a 2020 2020 2020 def new(. \n+0004d690: 2020 2020 2020 6664 3a20 4f70 7469 6f6e fd: Option\n+0004d6a0: 616c 5b69 6e74 5d20 3d20 4e6f 6e65 2c0a al[int] = None,.\n+0004d6b0: 2020 2020 2020 2020 2020 2020 6164 6472 addr\n+0004d6c0: 6573 733a 204f 7074 696f 6e61 6c5b 7374 ess: Optional[st\n+0004d6d0: 725d 203d 204e 6f6e 652c 0a20 2020 2020 r] = None,. \n+0004d6e0: 2020 2020 2020 2062 7573 5f63 6c69 656e bus_clien\n+0004d6f0: 743a 2062 6f6f 6c20 3d20 4661 6c73 652c t: bool = False,\n+0004d700: 0a20 2020 2020 2020 2020 2020 2073 6572 . ser\n+0004d710: 7665 723a 2062 6f6f 6c20 3d20 4661 6c73 ver: bool = Fals\n+0004d720: 652c 0a20 2020 2020 2020 2020 2020 2073 e,. s\n+0004d730: 7461 7274 3a20 626f 6f6c 203d 2054 7275 tart: bool = Tru\n+0004d740: 652c 0a20 2020 2020 2020 2020 2020 2061 e,. a\n+0004d750: 7474 6163 685f 6576 656e 743a 2062 6f6f ttach_event: boo\n+0004d760: 6c20 3d20 5472 7565 0a20 2020 2029 202d l = True. ) -\n+0004d770: 3e20 2742 7573 273a 0a20 2020 2020 2020 > 'Bus':. \n+0004d780: 2062 7573 203d 2042 7573 2829 0a20 2020 bus = Bus(). \n+0004d790: 2020 2020 2042 7573 2e5f 6e65 7728 6279 Bus._new(by\n+0004d7a0: 7265 6628 6275 7329 290a 2020 2020 2020 ref(bus)). \n+0004d7b0: 2020 6966 2061 6464 7265 7373 2069 7320 if address is \n+0004d7c0: 6e6f 7420 4e6f 6e65 3a0a 2020 2020 2020 not None:. \n+0004d7d0: 2020 2020 2020 6275 732e 7365 745f 6164 bus.set_ad\n+0004d7e0: 6472 6573 7328 6164 6472 6573 7329 0a20 dress(address). \n+0004d7f0: 2020 2020 2020 2069 6620 6664 2069 7320 if fd is \n+0004d800: 6e6f 7420 4e6f 6e65 3a0a 2020 2020 2020 not None:. \n+0004d810: 2020 2020 2020 6275 732e 7365 745f 6664 bus.set_fd\n+0004d820: 2866 642c 2066 6429 0a20 2020 2020 2020 (fd, fd). \n+0004d830: 2069 6620 6275 735f 636c 6965 6e74 3a0a if bus_client:.\n+0004d840: 2020 2020 2020 2020 2020 2020 6275 732e bus.\n+0004d850: 7365 745f 6275 735f 636c 6965 6e74 2854 set_bus_client(T\n+0004d860: 7275 6529 0a20 2020 2020 2020 2069 6620 rue). if \n+0004d870: 7365 7276 6572 3a0a 2020 2020 2020 2020 server:. \n+0004d880: 2020 2020 6275 732e 7365 745f 7365 7276 bus.set_serv\n+0004d890: 6572 2854 7275 652c 206c 6962 7379 7374 er(True, libsyst\n+0004d8a0: 656d 642e 7364 5f69 6431 3238 2829 290a emd.sd_id128()).\n+0004d8b0: 2020 2020 2020 2020 6966 2061 6464 7265 if addre\n+0004d8c0: 7373 2069 7320 6e6f 7420 4e6f 6e65 206f ss is not None o\n+0004d8d0: 7220 6664 2069 7320 6e6f 7420 4e6f 6e65 r fd is not None\n+0004d8e0: 3a0a 2020 2020 2020 2020 2020 2020 6966 :. if\n+0004d8f0: 2073 7461 7274 3a0a 2020 2020 2020 2020 start:. \n+0004d900: 2020 2020 2020 2020 6275 732e 7374 6172 bus.star\n+0004d910: 7428 290a 2020 2020 2020 2020 2020 2020 t(). \n+0004d920: 6966 2061 7474 6163 685f 6576 656e 743a if attach_event:\n+0004d930: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+0004d940: 2062 7573 2e61 7474 6163 685f 6576 656e bus.attach_even\n+0004d950: 7428 4e6f 6e65 2c20 3029 0a20 2020 2020 t(None, 0). \n+0004d960: 2020 2072 6574 7572 6e20 6275 730a 0a20 return bus.. \n+0004d970: 2020 2040 7374 6174 6963 6d65 7468 6f64 @staticmethod\n+0004d980: 0a20 2020 2064 6566 2064 6566 6175 6c74 . def default\n+0004d990: 5f73 7973 7465 6d28 6174 7461 6368 5f65 _system(attach_e\n+0004d9a0: 7665 6e74 3a20 626f 6f6c 203d 2054 7275 vent: bool = Tru\n+0004d9b0: 6529 202d 3e20 2742 7573 273a 0a20 2020 e) -> 'Bus':. \n+0004d9c0: 2020 2020 2069 6620 4275 732e 5f64 6566 if Bus._def\n+0004d9d0: 6175 6c74 5f73 7973 7465 6d5f 696e 7374 ault_system_inst\n+0004d9e0: 616e 6365 2069 7320 4e6f 6e65 3a0a 2020 ance is None:. \n+0004d9f0: 2020 2020 2020 2020 2020 4275 732e 5f64 Bus._d\n+0004da00: 6566 6175 6c74 5f73 7973 7465 6d5f 696e efault_system_in\n+0004da10: 7374 616e 6365 203d 2042 7573 2829 0a20 stance = Bus(). \n+0004da20: 2020 2020 2020 2020 2020 2042 7573 2e5f Bus._\n+0004da30: 6465 6661 756c 745f 7379 7374 656d 2862 default_system(b\n+0004da40: 7972 6566 2842 7573 2e5f 6465 6661 756c yref(Bus._defaul\n+0004da50: 745f 7379 7374 656d 5f69 6e73 7461 6e63 t_system_instanc\n+0004da60: 6529 290a 2020 2020 2020 2020 2020 2020 e)). \n+0004da70: 6966 2061 7474 6163 685f 6576 656e 743a if attach_event:\n+0004da80: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+0004da90: 2042 7573 2e5f 6465 6661 756c 745f 7379 Bus._default_sy\n+0004daa0: 7374 656d 5f69 6e73 7461 6e63 652e 6174 stem_instance.at\n+0004dab0: 7461 6368 5f65 7665 6e74 284e 6f6e 652c tach_event(None,\n+0004dac0: 2030 290a 2020 2020 2020 2020 7265 7475 0). retu\n+0004dad0: 726e 2042 7573 2e5f 6465 6661 756c 745f rn Bus._default_\n+0004dae0: 7379 7374 656d 5f69 6e73 7461 6e63 650a system_instance.\n+0004daf0: 0a20 2020 2040 7374 6174 6963 6d65 7468 . @staticmeth\n+0004db00: 6f64 0a20 2020 2064 6566 2064 6566 6175 od. def defau\n+0004db10: 6c74 5f75 7365 7228 6174 7461 6368 5f65 lt_user(attach_e\n+0004db20: 7665 6e74 3a20 626f 6f6c 203d 2054 7275 vent: bool = Tru\n+0004db30: 6529 202d 3e20 2742 7573 273a 0a20 2020 e) -> 'Bus':. \n+0004db40: 2020 2020 2069 6620 4275 732e 5f64 6566 if Bus._def\n+0004db50: 6175 6c74 5f75 7365 725f 696e 7374 616e ault_user_instan\n+0004db60: 6365 2069 7320 4e6f 6e65 3a0a 2020 2020 ce is None:. \n+0004db70: 2020 2020 2020 2020 4275 732e 5f64 6566 Bus._def\n+0004db80: 6175 6c74 5f75 7365 725f 696e 7374 616e ault_user_instan\n+0004db90: 6365 203d 2042 7573 2829 0a20 2020 2020 ce = Bus(). \n+0004dba0: 2020 2020 2020 2042 7573 2e5f 6465 6661 Bus._defa\n+0004dbb0: 756c 745f 7573 6572 2862 7972 6566 2842 ult_user(byref(B\n+0004dbc0: 7573 2e5f 6465 6661 756c 745f 7573 6572 us._default_user\n+0004dbd0: 5f69 6e73 7461 6e63 6529 290a 2020 2020 _instance)). \n+0004dbe0: 2020 2020 2020 2020 6966 2061 7474 6163 if attac\n+0004dbf0: 685f 6576 656e 743a 0a20 2020 2020 2020 h_event:. \n+0004dc00: 2020 2020 2020 2020 2042 7573 2e5f 6465 Bus._de\n+0004dc10: 6661 756c 745f 7573 6572 5f69 6e73 7461 fault_user_insta\n+0004dc20: 6e63 652e 6174 7461 6368 5f65 7665 6e74 nce.attach_event\n+0004dc30: 284e 6f6e 652c 2030 290a 2020 2020 2020 (None, 0). \n+0004dc40: 2020 7265 7475 726e 2042 7573 2e5f 6465 return Bus._de\n+0004dc50: 6661 756c 745f 7573 6572 5f69 6e73 7461 fault_user_insta\n+0004dc60: 6e63 650a 0a20 2020 2064 6566 206d 6573 nce.. def mes\n+0004dc70: 7361 6765 5f6e 6577 5f6d 6574 686f 645f sage_new_method_\n+0004dc80: 6361 6c6c 280a 2020 2020 2020 2020 2020 call(. \n+0004dc90: 2020 7365 6c66 2c0a 2020 2020 2020 2020 self,. \n+0004dca0: 2020 2020 6465 7374 696e 6174 696f 6e3a destination:\n+0004dcb0: 204f 7074 696f 6e61 6c5b 7374 725d 2c0a Optional[str],.\n+0004dcc0: 2020 2020 2020 2020 2020 2020 7061 7468 path\n+0004dcd0: 3a20 7374 722c 0a20 2020 2020 2020 2020 : str,. \n+0004dce0: 2020 2069 6e74 6572 6661 6365 3a20 7374 interface: st\n+0004dcf0: 722c 0a20 2020 2020 2020 2020 2020 206d r,. m\n+0004dd00: 656d 6265 723a 2073 7472 2c0a 2020 2020 ember: str,. \n+0004dd10: 2020 2020 2020 2020 7479 7065 733a 2073 types: s\n+0004dd20: 7472 203d 2027 272c 0a20 2020 2020 2020 tr = '',. \n+0004dd30: 2020 2020 202a 6172 6773 3a20 6f62 6a65 *args: obje\n+0004dd40: 6374 0a20 2020 2029 202d 3e20 4275 734d ct. ) -> BusM\n+0004dd50: 6573 7361 6765 3a0a 2020 2020 2020 2020 essage:. \n+0004dd60: 6d65 7373 6167 6520 3d20 4275 734d 6573 message = BusMes\n+0004dd70: 7361 6765 2829 0a20 2020 2020 2020 2073 sage(). s\n+0004dd80: 656c 662e 5f6d 6573 7361 6765 5f6e 6577 elf._message_new\n+0004dd90: 5f6d 6574 686f 645f 6361 6c6c 2862 7972 _method_call(byr\n+0004dda0: 6566 286d 6573 7361 6765 292c 2064 6573 ef(message), des\n+0004ddb0: 7469 6e61 7469 6f6e 2c20 7061 7468 2c20 tination, path, \n+0004ddc0: 696e 7465 7266 6163 652c 206d 656d 6265 interface, membe\n+0004ddd0: 7229 0a20 2020 2020 2020 206d 6573 7361 r). messa\n+0004dde0: 6765 2e61 7070 656e 6428 7479 7065 732c ge.append(types,\n+0004ddf0: 202a 6172 6773 290a 2020 2020 2020 2020 *args). \n+0004de00: 7265 7475 726e 206d 6573 7361 6765 0a0a return message..\n+0004de10: 2020 2020 6465 6620 6d65 7373 6167 655f def message_\n+0004de20: 6e65 775f 7369 676e 616c 280a 2020 2020 new_signal(. \n+0004de30: 2020 2020 7365 6c66 2c20 7061 7468 3a20 self, path: \n+0004de40: 7374 722c 2069 6e74 6572 6661 6365 3a20 str, interface: \n+0004de50: 7374 722c 206d 656d 6265 723a 2073 7472 str, member: str\n+0004de60: 2c20 7479 7065 733a 2073 7472 203d 2027 , types: str = '\n+0004de70: 272c 202a 6172 6773 3a20 6f62 6a65 6374 ', *args: object\n+0004de80: 0a20 2020 2029 202d 3e20 4275 734d 6573 . ) -> BusMes\n+0004de90: 7361 6765 3a0a 2020 2020 2020 2020 6d65 sage:. me\n+0004dea0: 7373 6167 6520 3d20 4275 734d 6573 7361 ssage = BusMessa\n+0004deb0: 6765 2829 0a20 2020 2020 2020 2073 656c ge(). sel\n+0004dec0: 662e 5f6d 6573 7361 6765 5f6e 6577 5f73 f._message_new_s\n+0004ded0: 6967 6e61 6c28 6279 7265 6628 6d65 7373 ignal(byref(mess\n+0004dee0: 6167 6529 2c20 7061 7468 2c20 696e 7465 age), path, inte\n+0004def0: 7266 6163 652c 206d 656d 6265 7229 0a20 rface, member). \n+0004df00: 2020 2020 2020 206d 6573 7361 6765 2e61 message.a\n+0004df10: 7070 656e 6428 7479 7065 732c 202a 6172 ppend(types, *ar\n+0004df20: 6773 290a 2020 2020 2020 2020 7265 7475 gs). retu\n+0004df30: 726e 206d 6573 7361 6765 0a0a 2020 2020 rn message.. \n+0004df40: 6465 6620 6361 6c6c 2873 656c 662c 206d def call(self, m\n+0004df50: 6573 7361 6765 3a20 4275 734d 6573 7361 essage: BusMessa\n+0004df60: 6765 2c20 7469 6d65 6f75 743a 204f 7074 ge, timeout: Opt\n+0004df70: 696f 6e61 6c5b 696e 745d 203d 204e 6f6e ional[int] = Non\n+0004df80: 6529 202d 3e20 4275 734d 6573 7361 6765 e) -> BusMessage\n+0004df90: 3a0a 2020 2020 2020 2020 7265 706c 7920 :. reply \n+0004dfa0: 3d20 4275 734d 6573 7361 6765 2829 0a20 = BusMessage(). \n+0004dfb0: 2020 2020 2020 2065 7272 6f72 203d 206c error = l\n+0004dfc0: 6962 7379 7374 656d 642e 7364 5f62 7573 ibsystemd.sd_bus\n+0004dfd0: 5f65 7272 6f72 2829 0a20 2020 2020 2020 _error(). \n+0004dfe0: 2074 7279 3a0a 2020 2020 2020 2020 2020 try:. \n+0004dff0: 2020 7365 6c66 2e5f 6361 6c6c 286d 6573 self._call(mes\n+0004e000: 7361 6765 2c20 7469 6d65 6f75 7420 6f72 sage, timeout or\n+0004e010: 2030 2c20 6279 7265 6628 6572 726f 7229 0, byref(error)\n+0004e020: 2c20 6279 7265 6628 7265 706c 7929 290a , byref(reply)).\n+0004e030: 2020 2020 2020 2020 2020 2020 7265 7475 retu\n+0004e040: 726e 2072 6570 6c79 0a20 2020 2020 2020 rn reply. \n+0004e050: 2065 7863 6570 7420 4f53 4572 726f 7220 except OSError \n+0004e060: 6173 2065 7863 3a0a 2020 2020 2020 2020 as exc:. \n+0004e070: 2020 2020 7261 6973 6520 4275 7345 7272 raise BusErr\n+0004e080: 6f72 282a 6572 726f 722e 6765 7428 2929 or(*error.get())\n+0004e090: 2066 726f 6d20 6578 630a 0a20 2020 2064 from exc.. d\n+0004e0a0: 6566 2063 616c 6c5f 6d65 7468 6f64 280a ef call_method(.\n 0004e0b0: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n-0004e0c0: 2e5f 7365 7474 6572 203d 2073 6574 7465 ._setter = sette\n-0004e0d0: 720a 2020 2020 2020 2020 2020 2020 7265 r. re\n-0004e0e0: 7475 726e 2073 6574 7465 720a 0a20 2020 turn setter.. \n-0004e0f0: 2063 6c61 7373 2053 6967 6e61 6c28 5f4d class Signal(_M\n-0004e100: 656d 6265 7229 3a0a 2020 2020 2020 2020 ember):. \n-0004e110: 2222 2244 6566 696e 6573 2061 2044 2d42 \"\"\"Defines a D-B\n-0004e120: 7573 2073 6967 6e61 6c20 6f6e 2061 6e20 us signal on an \n-0004e130: 696e 7465 7266 6163 650a 0a20 2020 2020 interface.. \n-0004e140: 2020 2054 6869 7320 6973 2061 2063 616c This is a cal\n-0004e150: 6c61 626c 6520 7768 6963 6820 7769 6c6c lable which will\n-0004e160: 2072 6573 756c 7420 696e 2074 6865 2073 result in the s\n-0004e170: 6967 6e61 6c20 6265 696e 6720 656d 6974 ignal being emit\n-0004e180: 7465 642e 0a0a 2020 2020 2020 2020 5468 ted... Th\n-0004e190: 6520 636f 6e73 7472 7563 746f 7220 7461 e constructor ta\n-0004e1a0: 6b65 7320 7468 6520 7479 7065 7320 6f66 kes the types of\n-0004e1b0: 2074 6865 2061 7267 756d 656e 7473 2c20 the arguments, \n-0004e1c0: 6561 6368 206f 6e65 2061 7320 610a 2020 each one as a. \n-0004e1d0: 2020 2020 2020 7365 7061 7261 7465 2070 separate p\n-0004e1e0: 6172 616d 6574 6572 2e20 2046 6f72 2065 arameter. For e\n-0004e1f0: 7861 6d70 6c65 3a0a 0a20 2020 2020 2020 xample:.. \n-0004e200: 2020 2020 2070 726f 7065 7274 6965 735f properties_\n-0004e210: 6368 616e 6765 6420 3d20 496e 7465 7266 changed = Interf\n-0004e220: 6163 652e 5369 676e 616c 2827 7327 2c20 ace.Signal('s', \n-0004e230: 2761 7b73 767d 272c 2027 6173 2729 0a0a 'a{sv}', 'as')..\n-0004e240: 2020 2020 2020 2020 596f 7520 6361 6e20 You can \n-0004e250: 6769 7665 2061 206e 616d 653d 206b 7761 give a name= kwa\n-0004e260: 7267 2074 6f20 6f76 6572 7269 6465 2074 rg to override t\n-0004e270: 6865 2064 6566 6175 6c74 206e 616d 6520 he default name \n-0004e280: 636f 6e76 6572 7369 6f6e 0a20 2020 2020 conversion. \n-0004e290: 2020 2073 6368 656d 652e 0a20 2020 2020 scheme.. \n-0004e2a0: 2020 2022 2222 0a20 2020 2020 2020 205f \"\"\". _\n-0004e2b0: 6361 7465 676f 7279 203d 2027 7369 676e category = 'sign\n-0004e2c0: 616c 7327 0a20 2020 2020 2020 205f 7479 als'. _ty\n-0004e2d0: 7065 3a20 6275 7374 7970 6573 2e4d 6573 pe: bustypes.Mes\n-0004e2e0: 7361 6765 5479 7065 0a0a 2020 2020 2020 sageType.. \n-0004e2f0: 2020 6465 6620 5f5f 696e 6974 5f5f 2873 def __init__(s\n-0004e300: 656c 662c 202a 6f75 745f 7479 7065 733a elf, *out_types:\n-0004e310: 2073 7472 2c20 6e61 6d65 3a20 4f70 7469 str, name: Opti\n-0004e320: 6f6e 616c 5b73 7472 5d20 3d20 4e6f 6e65 onal[str] = None\n-0004e330: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n-0004e340: 2020 2020 2020 2073 7570 6572 2829 2e5f super()._\n-0004e350: 5f69 6e69 745f 5f28 6e61 6d65 3d6e 616d _init__(name=nam\n-0004e360: 6529 0a20 2020 2020 2020 2020 2020 2073 e). s\n-0004e370: 656c 662e 5f74 7970 6520 3d20 6275 7374 elf._type = bust\n-0004e380: 7970 6573 2e4d 6573 7361 6765 5479 7065 ypes.MessageType\n-0004e390: 286f 7574 5f74 7970 6573 290a 0a20 2020 (out_types).. \n-0004e3a0: 2020 2020 2064 6566 205f 6465 7363 7269 def _descri\n-0004e3b0: 6265 2873 656c 6629 202d 3e20 4469 6374 be(self) -> Dict\n-0004e3c0: 5b73 7472 2c20 416e 795d 3a0a 2020 2020 [str, Any]:. \n-0004e3d0: 2020 2020 2020 2020 7265 7475 726e 207b return {\n-0004e3e0: 2769 6e27 3a20 7365 6c66 2e5f 7479 7065 'in': self._type\n-0004e3f0: 2e74 7970 6573 7472 696e 6773 7d0a 0a20 .typestrings}.. \n-0004e400: 2020 2020 2020 2064 6566 205f 5f67 6574 def __get\n-0004e410: 5f5f 2873 656c 662c 206f 626a 3a20 274f __(self, obj: 'O\n-0004e420: 626a 6563 7427 2c20 636c 733a 204f 7074 bject', cls: Opt\n-0004e430: 696f 6e61 6c5b 7479 7065 5d20 3d20 4e6f ional[type] = No\n-0004e440: 6e65 2920 2d3e 2043 616c 6c61 626c 655b ne) -> Callable[\n-0004e450: 2e2e 2e2c 204e 6f6e 655d 3a0a 2020 2020 ..., None]:. \n-0004e460: 2020 2020 2020 2020 6465 6620 656d 6974 def emit\n-0004e470: 7465 7228 6f62 6a3a 204f 626a 6563 742c ter(obj: Object,\n-0004e480: 202a 6172 6773 3a20 416e 7929 202d 3e20 *args: Any) -> \n-0004e490: 4e6f 6e65 3a0a 2020 2020 2020 2020 2020 None:. \n-0004e4a0: 2020 2020 2020 6173 7365 7274 2073 656c assert sel\n-0004e4b0: 662e 5f69 6e74 6572 6661 6365 2069 7320 f._interface is \n-0004e4c0: 6e6f 7420 4e6f 6e65 0a20 2020 2020 2020 not None. \n-0004e4d0: 2020 2020 2020 2020 2061 7373 6572 7420 assert \n-0004e4e0: 7365 6c66 2e5f 6e61 6d65 2069 7320 6e6f self._name is no\n-0004e4f0: 7420 4e6f 6e65 0a20 2020 2020 2020 2020 t None. \n-0004e500: 2020 2020 2020 2061 7373 6572 7420 6f62 assert ob\n-0004e510: 6a2e 5f64 6275 735f 6275 7320 6973 206e j._dbus_bus is n\n-0004e520: 6f74 204e 6f6e 650a 2020 2020 2020 2020 ot None. \n-0004e530: 2020 2020 2020 2020 6173 7365 7274 206f assert o\n-0004e540: 626a 2e5f 6462 7573 5f70 6174 6820 6973 bj._dbus_path is\n-0004e550: 206e 6f74 204e 6f6e 650a 2020 2020 2020 not None. \n-0004e560: 2020 2020 2020 2020 2020 6d65 7373 6167 messag\n-0004e570: 6520 3d20 6f62 6a2e 5f64 6275 735f 6275 e = obj._dbus_bu\n-0004e580: 732e 6d65 7373 6167 655f 6e65 775f 7369 s.message_new_si\n-0004e590: 676e 616c 286f 626a 2e5f 6462 7573 5f70 gnal(obj._dbus_p\n-0004e5a0: 6174 682c 2073 656c 662e 5f69 6e74 6572 ath, self._inter\n-0004e5b0: 6661 6365 2c20 7365 6c66 2e5f 6e61 6d65 face, self._name\n-0004e5c0: 290a 2020 2020 2020 2020 2020 2020 2020 ). \n-0004e5d0: 2020 7365 6c66 2e5f 7479 7065 2e77 7269 self._type.wri\n-0004e5e0: 7465 286d 6573 7361 6765 2c20 2a61 7267 te(message, *arg\n-0004e5f0: 7329 0a20 2020 2020 2020 2020 2020 2020 s). \n-0004e600: 2020 206d 6573 7361 6765 2e73 656e 6428 message.send(\n-0004e610: 290a 2020 2020 2020 2020 2020 2020 7265 ). re\n-0004e620: 7475 726e 2065 6d69 7474 6572 2e5f 5f67 turn emitter.__g\n-0004e630: 6574 5f5f 286f 626a 2c20 636c 7329 0a0a et__(obj, cls)..\n-0004e640: 2020 2020 636c 6173 7320 4d65 7468 6f64 class Method\n-0004e650: 285f 4d65 6d62 6572 293a 0a20 2020 2020 (_Member):. \n-0004e660: 2020 2022 2222 4465 6669 6e65 7320 6120 \"\"\"Defines a \n-0004e670: 442d 4275 7320 6d65 7468 6f64 206f 6e20 D-Bus method on \n-0004e680: 616e 2069 6e74 6572 6661 6365 0a0a 2020 an interface.. \n-0004e690: 2020 2020 2020 5468 6973 2069 7320 6120 This is a \n-0004e6a0: 6675 6e63 7469 6f6e 2064 6563 6f72 6174 function decorat\n-0004e6b0: 6f72 2077 6869 6368 206d 6172 6b73 2061 or which marks a\n-0004e6c0: 2067 6976 656e 206d 6574 686f 6420 666f given method fo\n-0004e6d0: 7220 6578 706f 7274 2e0a 0a20 2020 2020 r export... \n-0004e6e0: 2020 2054 6865 2063 6f6e 7374 7275 6374 The construct\n-0004e6f0: 6f72 2074 616b 6573 2074 776f 2061 7267 or takes two arg\n-0004e700: 756d 656e 7473 3a20 7468 6520 7479 7065 uments: the type\n-0004e710: 206f 6620 7468 6520 6f75 7470 7574 2061 of the output a\n-0004e720: 7267 756d 656e 7473 2c0a 2020 2020 2020 rguments,. \n-0004e730: 2020 616e 6420 7468 6520 7479 7065 206f and the type o\n-0004e740: 6620 7468 6520 696e 7075 7420 6172 6775 f the input argu\n-0004e750: 6d65 6e74 732e 2020 426f 7468 2073 686f ments. Both sho\n-0004e760: 756c 6420 6265 2067 6976 656e 2061 7320 uld be given as \n-0004e770: 610a 2020 2020 2020 2020 7365 7175 656e a. sequen\n-0004e780: 6365 2e0a 0a20 2020 2020 2020 2020 2020 ce... \n-0004e790: 2040 496e 7465 7266 6163 652e 4d65 7468 @Interface.Meth\n-0004e7a0: 6f64 285b 2761 7b73 767d 275d 2c20 5b27 od(['a{sv}'], ['\n-0004e7b0: 7327 5d29 0a20 2020 2020 2020 2020 2020 s']). \n-0004e7c0: 2064 6566 2067 6574 5f61 6c6c 2873 656c def get_all(sel\n-0004e7d0: 662c 2069 6e74 6572 6661 6365 293a 0a20 f, interface):. \n-0004e7e0: 2020 2020 2020 2020 2020 2020 2020 202e .\n-0004e7f0: 2e2e 0a0a 2020 2020 2020 2020 596f 7520 .... You \n-0004e800: 6361 6e20 6769 7665 2061 206e 616d 653d can give a name=\n-0004e810: 206b 7761 7267 2074 6f20 6f76 6572 7269 kwarg to overri\n-0004e820: 6465 2074 6865 2064 6566 6175 6c74 206e de the default n\n-0004e830: 616d 6520 636f 6e76 6572 7369 6f6e 0a20 ame conversion. \n-0004e840: 2020 2020 2020 2073 6368 656d 652e 0a20 scheme.. \n-0004e850: 2020 2020 2020 2022 2222 0a20 2020 2020 \"\"\". \n-0004e860: 2020 205f 6361 7465 676f 7279 203d 2027 _category = '\n-0004e870: 6d65 7468 6f64 7327 0a0a 2020 2020 2020 methods'.. \n-0004e880: 2020 636c 6173 7320 556e 6861 6e64 6c65 class Unhandle\n-0004e890: 6428 4578 6365 7074 696f 6e29 3a0a 2020 d(Exception):. \n-0004e8a0: 2020 2020 2020 2020 2020 2222 2252 6169 \"\"\"Rai\n-0004e8b0: 7365 6420 6279 2061 206d 6574 686f 6420 sed by a method \n-0004e8c0: 746f 2069 6e64 6963 6174 6520 7468 6174 to indicate that\n-0004e8d0: 2074 6865 206d 6573 7361 6765 2074 7269 the message tri\n-0004e8e0: 6767 6572 696e 6720 7468 6174 0a20 2020 ggering that. \n-0004e8f0: 2020 2020 2020 2020 206d 6574 686f 6420 method \n-0004e900: 6361 6c6c 2072 656d 6169 6e73 2075 6e68 call remains unh\n-0004e910: 616e 646c 6564 2e22 2222 0a20 2020 2020 andled.\"\"\". \n-0004e920: 2020 2020 2020 2070 6173 730a 0a20 2020 pass.. \n-0004e930: 2020 2020 2064 6566 205f 5f69 6e69 745f def __init_\n-0004e940: 5f28 7365 6c66 2c20 6f75 745f 7479 7065 _(self, out_type\n-0004e950: 733a 2053 6571 7565 6e63 655b 7374 725d s: Sequence[str]\n-0004e960: 203d 2028 292c 2069 6e5f 7479 7065 733a = (), in_types:\n-0004e970: 2053 6571 7565 6e63 655b 7374 725d 203d Sequence[str] =\n-0004e980: 2028 292c 206e 616d 653a 204f 7074 696f (), name: Optio\n-0004e990: 6e61 6c5b 7374 725d 203d 204e 6f6e 6529 nal[str] = None)\n-0004e9a0: 3a0a 2020 2020 2020 2020 2020 2020 7375 :. su\n-0004e9b0: 7065 7228 292e 5f5f 696e 6974 5f5f 286e per().__init__(n\n-0004e9c0: 616d 653d 6e61 6d65 290a 2020 2020 2020 ame=name). \n-0004e9d0: 2020 2020 2020 7365 6c66 2e5f 6f75 745f self._out_\n-0004e9e0: 7479 7065 203d 2062 7573 7479 7065 732e type = bustypes.\n-0004e9f0: 4d65 7373 6167 6554 7970 6528 6f75 745f MessageType(out_\n-0004ea00: 7479 7065 7329 0a20 2020 2020 2020 2020 types). \n-0004ea10: 2020 2073 656c 662e 5f69 6e5f 7479 7065 self._in_type\n-0004ea20: 203d 2062 7573 7479 7065 732e 4d65 7373 = bustypes.Mess\n-0004ea30: 6167 6554 7970 6528 696e 5f74 7970 6573 ageType(in_types\n-0004ea40: 290a 2020 2020 2020 2020 2020 2020 7365 ). se\n-0004ea50: 6c66 2e5f 6675 6e63 203d 204e 6f6e 650a lf._func = None.\n-0004ea60: 0a20 2020 2020 2020 2064 6566 205f 5f67 . def __g\n-0004ea70: 6574 5f5f 2873 656c 662c 206f 626a 2c20 et__(self, obj, \n-0004ea80: 636c 733d 4e6f 6e65 293a 0a20 2020 2020 cls=None):. \n-0004ea90: 2020 2020 2020 2072 6574 7572 6e20 7365 return se\n-0004eaa0: 6c66 2e5f 6675 6e63 2e5f 5f67 6574 5f5f lf._func.__get__\n-0004eab0: 286f 626a 2c20 636c 7329 0a0a 2020 2020 (obj, cls).. \n-0004eac0: 2020 2020 6465 6620 5f5f 6361 6c6c 5f5f def __call__\n-0004ead0: 2873 656c 662c 202a 6172 6773 2c20 2a2a (self, *args, **\n-0004eae0: 6b77 6172 6773 293a 0a20 2020 2020 2020 kwargs):. \n-0004eaf0: 2020 2020 2023 2064 6563 6f72 6174 6f72 # decorator\n-0004eb00: 0a20 2020 2020 2020 2020 2020 2073 656c . sel\n-0004eb10: 662e 5f66 756e 632c 203d 2061 7267 730a f._func, = args.\n-0004eb20: 2020 2020 2020 2020 2020 2020 7265 7475 retu\n-0004eb30: 726e 2073 656c 660a 0a20 2020 2020 2020 rn self.. \n-0004eb40: 2064 6566 205f 6465 7363 7269 6265 2873 def _describe(s\n-0004eb50: 656c 6629 202d 3e20 4469 6374 5b73 7472 elf) -> Dict[str\n-0004eb60: 2c20 416e 795d 3a0a 2020 2020 2020 2020 , Any]:. \n-0004eb70: 2020 2020 7265 7475 726e 207b 2769 6e27 return {'in'\n-0004eb80: 3a20 5b69 7465 6d2e 7479 7065 7374 7269 : [item.typestri\n-0004eb90: 6e67 2066 6f72 2069 7465 6d20 696e 2073 ng for item in s\n-0004eba0: 656c 662e 5f69 6e5f 7479 7065 2e69 7465 elf._in_type.ite\n-0004ebb0: 6d5f 7479 7065 735d 2c0a 2020 2020 2020 m_types],. \n-0004ebc0: 2020 2020 2020 2020 2020 2020 2020 276f 'o\n-0004ebd0: 7574 273a 205b 6974 656d 2e74 7970 6573 ut': [item.types\n-0004ebe0: 7472 696e 6720 666f 7220 6974 656d 2069 tring for item i\n-0004ebf0: 6e20 7365 6c66 2e5f 6f75 745f 7479 7065 n self._out_type\n-0004ec00: 2e69 7465 6d5f 7479 7065 735d 7d0a 0a20 .item_types]}.. \n-0004ec10: 2020 2020 2020 2064 6566 205f 696e 766f def _invo\n-0004ec20: 6b65 2873 656c 662c 206f 626a 2c20 6d65 ke(self, obj, me\n-0004ec30: 7373 6167 6529 3a0a 2020 2020 2020 2020 ssage):. \n-0004ec40: 2020 2020 6172 6773 203d 2073 656c 662e args = self.\n-0004ec50: 5f69 6e5f 7479 7065 2e72 6561 6428 6d65 _in_type.read(me\n-0004ec60: 7373 6167 6529 0a20 2020 2020 2020 2020 ssage). \n-0004ec70: 2020 2069 6620 6172 6773 2069 7320 4e6f if args is No\n-0004ec80: 6e65 3a0a 2020 2020 2020 2020 2020 2020 ne:. \n-0004ec90: 2020 2020 7265 7475 726e 2046 616c 7365 return False\n-0004eca0: 0a20 2020 2020 2020 2020 2020 2074 7279 . try\n-0004ecb0: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n-0004ecc0: 2020 7265 7375 6c74 203d 2073 656c 662e result = self.\n-0004ecd0: 5f66 756e 632e 5f5f 6765 745f 5f28 6f62 _func.__get__(ob\n-0004ece0: 6a29 282a 6172 6773 290a 2020 2020 2020 j)(*args). \n-0004ecf0: 2020 2020 2020 6578 6365 7074 2028 4275 except (Bu\n-0004ed00: 7345 7272 6f72 2c20 4f53 4572 726f 7229 sError, OSError)\n-0004ed10: 2061 7320 6572 726f 723a 0a20 2020 2020 as error:. \n-0004ed20: 2020 2020 2020 2020 2020 2072 6574 7572 retur\n-0004ed30: 6e20 6d65 7373 6167 652e 7265 706c 795f n message.reply_\n-0004ed40: 6d65 7468 6f64 5f65 7272 6f72 2865 7272 method_error(err\n-0004ed50: 6f72 290a 0a20 2020 2020 2020 2020 2020 or).. \n-0004ed60: 2072 6574 7572 6e20 6d65 7373 6167 652e return message.\n-0004ed70: 7265 706c 795f 6d65 7468 6f64 5f66 756e reply_method_fun\n-0004ed80: 6374 696f 6e5f 7265 7475 726e 5f76 616c ction_return_val\n-0004ed90: 7565 2873 656c 662e 5f6f 7574 5f74 7970 ue(self._out_typ\n-0004eda0: 652c 2072 6573 756c 7429 0a0a 0a63 6c61 e, result)...cla\n-0004edb0: 7373 206f 7267 5f66 7265 6564 6573 6b74 ss org_freedeskt\n-0004edc0: 6f70 5f44 4275 735f 5065 6572 2849 6e74 op_DBus_Peer(Int\n-0004edd0: 6572 6661 6365 293a 0a20 2020 2040 496e erface):. @In\n-0004ede0: 7465 7266 6163 652e 4d65 7468 6f64 2829 terface.Method()\n-0004edf0: 0a20 2020 2040 7374 6174 6963 6d65 7468 . @staticmeth\n-0004ee00: 6f64 0a20 2020 2064 6566 2070 696e 6728 od. def ping(\n-0004ee10: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n-0004ee20: 2020 2070 6173 730a 0a20 2020 2040 496e pass.. @In\n-0004ee30: 7465 7266 6163 652e 4d65 7468 6f64 2827 terface.Method('\n-0004ee40: 7327 290a 2020 2020 4073 7461 7469 636d s'). @staticm\n-0004ee50: 6574 686f 640a 2020 2020 6465 6620 6765 ethod. def ge\n-0004ee60: 745f 6d61 6368 696e 655f 6964 2829 202d t_machine_id() -\n-0004ee70: 3e20 7374 723a 0a20 2020 2020 2020 2077 > str:. w\n-0004ee80: 6974 6820 6f70 656e 2827 2f65 7463 2f6d ith open('/etc/m\n-0004ee90: 6163 6869 6e65 2d69 6427 2c20 656e 636f achine-id', enco\n-0004eea0: 6469 6e67 3d27 6173 6369 6927 2920 6173 ding='ascii') as\n-0004eeb0: 2066 696c 653a 0a20 2020 2020 2020 2020 file:. \n-0004eec0: 2020 2072 6574 7572 6e20 6669 6c65 2e72 return file.r\n-0004eed0: 6561 6428 292e 7374 7269 7028 290a 0a0a ead().strip()...\n-0004eee0: 636c 6173 7320 6f72 675f 6672 6565 6465 class org_freede\n-0004eef0: 736b 746f 705f 4442 7573 5f49 6e74 726f sktop_DBus_Intro\n-0004ef00: 7370 6563 7461 626c 6528 496e 7465 7266 spectable(Interf\n-0004ef10: 6163 6529 3a0a 2020 2020 4049 6e74 6572 ace):. @Inter\n-0004ef20: 6661 6365 2e4d 6574 686f 6428 2773 2729 face.Method('s')\n-0004ef30: 0a20 2020 2040 636c 6173 736d 6574 686f . @classmetho\n-0004ef40: 640a 2020 2020 6465 6620 696e 7472 6f73 d. def intros\n-0004ef50: 7065 6374 2863 6c73 2920 2d3e 2073 7472 pect(cls) -> str\n-0004ef60: 3a0a 2020 2020 2020 2020 7265 7475 726e :. return\n-0004ef70: 2069 6e74 726f 7370 6563 7469 6f6e 2e74 introspection.t\n-0004ef80: 6f5f 786d 6c28 636c 732e 5f64 6275 735f o_xml(cls._dbus_\n-0004ef90: 696e 7465 7266 6163 6573 290a 0a0a 636c interfaces)...cl\n-0004efa0: 6173 7320 6f72 675f 6672 6565 6465 736b ass org_freedesk\n-0004efb0: 746f 705f 4442 7573 5f50 726f 7065 7274 top_DBus_Propert\n-0004efc0: 6965 7328 496e 7465 7266 6163 6529 3a0a ies(Interface):.\n-0004efd0: 2020 2020 7072 6f70 6572 7469 6573 5f63 properties_c\n-0004efe0: 6861 6e67 6564 203d 2049 6e74 6572 6661 hanged = Interfa\n-0004eff0: 6365 2e53 6967 6e61 6c28 2773 272c 2027 ce.Signal('s', '\n-0004f000: 617b 7376 7d27 2c20 2761 7327 290a 0a20 a{sv}', 'as').. \n-0004f010: 2020 2040 496e 7465 7266 6163 652e 4d65 @Interface.Me\n-0004f020: 7468 6f64 2827 7627 2c20 2773 7327 290a thod('v', 'ss').\n-0004f030: 2020 2020 6465 6620 6765 7428 7365 6c66 def get(self\n-0004f040: 2c20 696e 7465 7266 6163 652c 206e 616d , interface, nam\n-0004f050: 6529 3a0a 2020 2020 2020 2020 7265 7475 e):. retu\n-0004f060: 726e 2073 656c 662e 5f66 696e 645f 6d65 rn self._find_me\n-0004f070: 6d62 6572 2869 6e74 6572 6661 6365 2c20 mber(interface, \n-0004f080: 2770 726f 7065 7274 6965 7327 2c20 6e61 'properties', na\n-0004f090: 6d65 292e 746f 5f64 6275 7328 7365 6c66 me).to_dbus(self\n-0004f0a0: 290a 0a20 2020 2040 496e 7465 7266 6163 ).. @Interfac\n-0004f0b0: 652e 4d65 7468 6f64 285b 2761 7b73 767d e.Method(['a{sv}\n-0004f0c0: 275d 2c20 2773 2729 0a20 2020 2064 6566 '], 's'). def\n-0004f0d0: 2067 6574 5f61 6c6c 2873 656c 662c 2069 get_all(self, i\n-0004f0e0: 6e74 6572 6661 6365 293a 0a20 2020 2020 nterface):. \n-0004f0f0: 2020 2070 726f 7065 7274 6965 7320 3d20 properties = \n-0004f100: 7365 6c66 2e5f 6669 6e64 5f63 6174 6567 self._find_categ\n-0004f110: 6f72 7928 696e 7465 7266 6163 652c 2027 ory(interface, '\n-0004f120: 7072 6f70 6572 7469 6573 2729 0a20 2020 properties'). \n-0004f130: 2020 2020 2072 6574 7572 6e20 7b6e 616d return {nam\n-0004f140: 653a 2070 726f 702e 746f 5f64 6275 7328 e: prop.to_dbus(\n-0004f150: 7365 6c66 2920 666f 7220 6e61 6d65 2c20 self) for name, \n-0004f160: 7072 6f70 2069 6e20 7072 6f70 6572 7469 prop in properti\n-0004f170: 6573 2e69 7465 6d73 2829 7d0a 0a20 2020 es.items()}.. \n-0004f180: 2040 496e 7465 7266 6163 652e 4d65 7468 @Interface.Meth\n-0004f190: 6f64 2827 272c 2027 7373 7627 290a 2020 od('', 'ssv'). \n-0004f1a0: 2020 6465 6620 7365 7428 7365 6c66 2c20 def set(self, \n-0004f1b0: 696e 7465 7266 6163 652c 206e 616d 652c interface, name,\n-0004f1c0: 2076 616c 7565 293a 0a20 2020 2020 2020 value):. \n-0004f1d0: 2073 656c 662e 5f66 696e 645f 6d65 6d62 self._find_memb\n-0004f1e0: 6572 2869 6e74 6572 6661 6365 2c20 2770 er(interface, 'p\n-0004f1f0: 726f 7065 7274 6965 7327 2c20 6e61 6d65 roperties', name\n-0004f200: 292e 6672 6f6d 5f64 6275 7328 7365 6c66 ).from_dbus(self\n-0004f210: 2c20 7661 6c75 6529 0a0a 0a63 6c61 7373 , value)...class\n-0004f220: 204f 626a 6563 7428 6f72 675f 6672 6565 Object(org_free\n-0004f230: 6465 736b 746f 705f 4442 7573 5f49 6e74 desktop_DBus_Int\n-0004f240: 726f 7370 6563 7461 626c 652c 0a20 2020 rospectable,. \n-0004f250: 2020 2020 2020 2020 2020 6f72 675f 6672 org_fr\n-0004f260: 6565 6465 736b 746f 705f 4442 7573 5f50 eedesktop_DBus_P\n-0004f270: 6565 722c 0a20 2020 2020 2020 2020 2020 eer,. \n-0004f280: 2020 6f72 675f 6672 6565 6465 736b 746f org_freedeskto\n-0004f290: 705f 4442 7573 5f50 726f 7065 7274 6965 p_DBus_Propertie\n-0004f2a0: 732c 0a20 2020 2020 2020 2020 2020 2020 s,. \n-0004f2b0: 4261 7365 4f62 6a65 6374 2c0a 2020 2020 BaseObject,. \n-0004f2c0: 2020 2020 2020 2020 2049 6e74 6572 6661 Interfa\n-0004f2d0: 6365 293a 0a20 2020 2022 2222 4869 6768 ce):. \"\"\"High\n-0004f2e0: 2d6c 6576 656c 2062 6173 6520 636c 6173 -level base clas\n-0004f2f0: 7320 666f 7220 6578 706f 7274 696e 6720 s for exporting \n-0004f300: 6f62 6a65 6374 7320 6f6e 2044 2d42 7573 objects on D-Bus\n-0004f310: 0a0a 2020 2020 5468 6973 2069 7320 7573 .. This is us\n-0004f320: 7561 6c6c 7920 7768 6572 6520 796f 7520 ually where you \n-0004f330: 7368 6f75 6c64 2073 7461 7274 2e0a 0a20 should start... \n-0004f340: 2020 2054 6869 7320 7072 6f76 6964 6573 This provides\n-0004f350: 2061 2062 6173 6520 666f 7220 6578 706f a base for expo\n-0004f360: 7274 696e 6720 6f62 6a65 6374 7320 6f6e rting objects on\n-0004f370: 2074 6865 2062 7573 2c20 696d 706c 656d the bus, implem\n-0004f380: 656e 7473 2074 6865 0a20 2020 2073 7461 ents the. sta\n-0004f390: 6e64 6172 6420 442d 4275 7320 696e 7465 ndard D-Bus inte\n-0004f3a0: 7266 6163 6573 2c20 616e 6420 616c 6c6f rfaces, and allo\n-0004f3b0: 7773 2079 6f75 2074 6f20 6164 6420 796f ws you to add yo\n-0004f3c0: 7572 206f 776e 2069 6e74 6572 6661 6365 ur own interface\n-0004f3d0: 7320 746f 2074 6865 0a20 2020 206d 6978 s to the. mix\n-0004f3e0: 2e20 2053 6565 2074 6865 2064 6f63 756d . See the docum\n-0004f3f0: 656e 7461 7469 6f6e 2066 6f72 2049 6e74 entation for Int\n-0004f400: 6572 6661 6365 2074 6f20 6669 6e64 206f erface to find o\n-0004f410: 7574 2068 6f77 2074 6f20 6465 6669 6e65 ut how to define\n-0004f420: 2061 6e64 0a20 2020 2069 6d70 6c65 6d65 and. impleme\n-0004f430: 6e74 2079 6f75 7220 442d 4275 7320 696e nt your D-Bus in\n-0004f440: 7465 7266 6163 652e 0a20 2020 2022 2222 terface.. \"\"\"\n-0004f450: 0a20 2020 2064 6566 206d 6573 7361 6765 . def message\n-0004f460: 5f72 6563 6569 7665 6428 7365 6c66 2c20 _received(self, \n-0004f470: 6d65 7373 6167 653a 2042 7573 4d65 7373 message: BusMess\n-0004f480: 6167 6529 202d 3e20 626f 6f6c 3a0a 2020 age) -> bool:. \n-0004f490: 2020 2020 2020 696e 7465 7266 6163 6520 interface \n-0004f4a0: 3d20 6d65 7373 6167 652e 6765 745f 696e = message.get_in\n-0004f4b0: 7465 7266 6163 6528 290a 2020 2020 2020 terface(). \n-0004f4c0: 2020 6e61 6d65 203d 206d 6573 7361 6765 name = message\n-0004f4d0: 2e67 6574 5f6d 656d 6265 7228 290a 0a20 .get_member().. \n-0004f4e0: 2020 2020 2020 2074 7279 3a0a 2020 2020 try:. \n-0004f4f0: 2020 2020 2020 2020 6d65 7468 6f64 203d method =\n-0004f500: 2073 656c 662e 5f66 696e 645f 6d65 6d62 self._find_memb\n-0004f510: 6572 2869 6e74 6572 6661 6365 2c20 276d er(interface, 'm\n-0004f520: 6574 686f 6473 272c 206e 616d 6529 0a20 ethods', name). \n-0004f530: 2020 2020 2020 2020 2020 2061 7373 6572 asser\n-0004f540: 7420 6973 696e 7374 616e 6365 286d 6574 t isinstance(met\n-0004f550: 686f 642c 2049 6e74 6572 6661 6365 2e4d hod, Interface.M\n-0004f560: 6574 686f 6429 0a20 2020 2020 2020 2020 ethod). \n-0004f570: 2020 2072 6574 7572 6e20 6d65 7468 6f64 return method\n-0004f580: 2e5f 696e 766f 6b65 2873 656c 662c 206d ._invoke(self, m\n-0004f590: 6573 7361 6765 290a 2020 2020 2020 2020 essage). \n-0004f5a0: 6578 6365 7074 204f 626a 6563 742e 4d65 except Object.Me\n-0004f5b0: 7468 6f64 2e55 6e68 616e 646c 6564 3a0a thod.Unhandled:.\n-0004f5c0: 2020 2020 2020 2020 2020 2020 7265 7475 retu\n-0004f5d0: 726e 2046 616c 7365 0a27 2727 2c0a 2020 rn False.''',. \n-0004f5e0: 2763 6f63 6b70 6974 2f5f 7665 6e64 6f72 'cockpit/_vendor\n-0004f5f0: 2f73 7973 7465 6d64 5f63 7479 7065 732f /systemd_ctypes/\n-0004f600: 6275 7374 7970 6573 2e70 7927 3a20 6272 bustypes.py': br\n-0004f610: 2727 2723 2073 7973 7465 6d64 5f63 7479 '''# systemd_cty\n-0004f620: 7065 730a 230a 2320 436f 7079 7269 6768 pes.#.# Copyrigh\n-0004f630: 7420 2843 2920 3230 3233 2041 6c6c 6973 t (C) 2023 Allis\n-0004f640: 6f6e 204b 6172 6c69 7473 6b61 7961 203c on Karlitskaya <\n-0004f650: 616c 6c69 736f 6e2e 6b61 726c 6974 736b allison.karlitsk\n-0004f660: 6179 6140 7265 6468 6174 2e63 6f6d 3e0a aya@redhat.com>.\n-0004f670: 230a 2320 5468 6973 2070 726f 6772 616d #.# This program\n-0004f680: 2069 7320 6672 6565 2073 6f66 7477 6172 is free softwar\n-0004f690: 653a 2079 6f75 2063 616e 2072 6564 6973 e: you can redis\n-0004f6a0: 7472 6962 7574 6520 6974 2061 6e64 2f6f tribute it and/o\n-0004f6b0: 7220 6d6f 6469 6679 0a23 2069 7420 756e r modify.# it un\n-0004f6c0: 6465 7220 7468 6520 7465 726d 7320 6f66 der the terms of\n-0004f6d0: 2074 6865 2047 4e55 2047 656e 6572 616c the GNU General\n-0004f6e0: 2050 7562 6c69 6320 4c69 6365 6e73 6520 Public License \n-0004f6f0: 6173 2070 7562 6c69 7368 6564 2062 790a as published by.\n-0004f700: 2320 7468 6520 4672 6565 2053 6f66 7477 # the Free Softw\n-0004f710: 6172 6520 466f 756e 6461 7469 6f6e 2c20 are Foundation, \n-0004f720: 6569 7468 6572 2076 6572 7369 6f6e 2033 either version 3\n-0004f730: 206f 6620 7468 6520 4c69 6365 6e73 652c of the License,\n-0004f740: 206f 720a 2320 2861 7420 796f 7572 206f or.# (at your o\n-0004f750: 7074 696f 6e29 2061 6e79 206c 6174 6572 ption) any later\n-0004f760: 2076 6572 7369 6f6e 2e0a 230a 2320 5468 version..#.# Th\n-0004f770: 6973 2070 726f 6772 616d 2069 7320 6469 is program is di\n-0004f780: 7374 7269 6275 7465 6420 696e 2074 6865 stributed in the\n-0004f790: 2068 6f70 6520 7468 6174 2069 7420 7769 hope that it wi\n-0004f7a0: 6c6c 2062 6520 7573 6566 756c 2c0a 2320 ll be useful,.# \n-0004f7b0: 6275 7420 5749 5448 4f55 5420 414e 5920 but WITHOUT ANY \n-0004f7c0: 5741 5252 414e 5459 3b20 7769 7468 6f75 WARRANTY; withou\n-0004f7d0: 7420 6576 656e 2074 6865 2069 6d70 6c69 t even the impli\n-0004f7e0: 6564 2077 6172 7261 6e74 7920 6f66 0a23 ed warranty of.#\n-0004f7f0: 204d 4552 4348 414e 5441 4249 4c49 5459 MERCHANTABILITY\n-0004f800: 206f 7220 4649 544e 4553 5320 464f 5220 or FITNESS FOR \n-0004f810: 4120 5041 5254 4943 554c 4152 2050 5552 A PARTICULAR PUR\n-0004f820: 504f 5345 2e20 2053 6565 2074 6865 0a23 POSE. See the.#\n-0004f830: 2047 4e55 2047 656e 6572 616c 2050 7562 GNU General Pub\n-0004f840: 6c69 6320 4c69 6365 6e73 6520 666f 7220 lic License for \n-0004f850: 6d6f 7265 2064 6574 6169 6c73 2e0a 230a more details..#.\n-0004f860: 2320 596f 7520 7368 6f75 6c64 2068 6176 # You should hav\n-0004f870: 6520 7265 6365 6976 6564 2061 2063 6f70 e received a cop\n-0004f880: 7920 6f66 2074 6865 2047 4e55 2047 656e y of the GNU Gen\n-0004f890: 6572 616c 2050 7562 6c69 6320 4c69 6365 eral Public Lice\n-0004f8a0: 6e73 650a 2320 616c 6f6e 6720 7769 7468 nse.# along with\n-0004f8b0: 2074 6869 7320 7072 6f67 7261 6d2e 2020 this program. \n-0004f8c0: 4966 206e 6f74 2c20 7365 6520 3c68 7474 If not, see <htt\n-0004f8d0: 703a 2f2f 7777 772e 676e 752e 6f72 672f p://www.gnu.org/\n-0004f8e0: 6c69 6365 6e73 6573 2f3e 2e0a 0a0a 2320 licenses/>....# \n-0004f8f0: 5468 6973 2066 696c 6520 6973 2072 6573 This file is res\n-0004f900: 706f 6e73 6962 6c65 2066 6f72 2063 7265 ponsible for cre\n-0004f910: 6174 696e 6720 6675 6e63 7469 6f6e 7320 ating functions \n-0004f920: 746f 2028 6465 2973 6572 6961 6c69 7a65 to (de)serialize\n-0004f930: 2050 7974 686f 6e0a 2320 6f62 6a65 6374 Python.# object\n-0004f940: 7320 696e 746f 2061 6e64 206f 7574 206f s into and out o\n-0004f950: 6620 4275 734d 6573 7361 6765 206f 626a f BusMessage obj\n-0004f960: 6563 7473 2e0a 230a 2320 4561 6368 2054 ects..#.# Each T\n-0004f970: 7970 6520 636f 7272 6573 706f 6e64 7320 ype corresponds \n-0004f980: 746f 2061 2028 706f 7373 6962 6c79 2063 to a (possibly c\n-0004f990: 6f6d 706c 6578 2920 442d 4275 7320 7479 omplex) D-Bus ty\n-0004f9a0: 7065 2e20 2049 7420 6861 7320 6120 2e72 pe. It has a .r\n-0004f9b0: 6561 6465 720a 2320 616e 6420 6120 2e77 eader.# and a .w\n-0004f9c0: 7269 7465 7220 7072 6f70 6572 7479 2e20 riter property. \n-0004f9d0: 2054 6865 2072 6561 6465 7273 2074 616b The readers tak\n-0004f9e0: 6520 6120 6d65 7373 6167 6520 616e 6420 e a message and \n-0004f9f0: 6465 7365 7269 616c 697a 6520 6120 7369 deserialize a si\n-0004fa00: 6e67 6c65 0a23 2076 616c 7565 2066 726f ngle.# value fro\n-0004fa10: 6d20 6974 2c20 7265 7475 726e 696e 6720 m it, returning \n-0004fa20: 7468 6520 7661 6c75 653a 0a23 0a23 2020 the value:.#.# \n-0004fa30: 2064 6566 2072 6561 6465 7228 6d65 7373 def reader(mess\n-0004fa40: 6167 653a 2042 7573 4d65 7373 6167 6529 age: BusMessage)\n-0004fa50: 202d 3e20 6f62 6a65 6374 3a0a 230a 2320 -> object:.#.# \n-0004fa60: 5468 6520 7772 6974 6572 7320 7461 6b65 The writers take\n-0004fa70: 2061 206d 6573 7361 6765 2061 6e64 2061 a message and a\n-0004fa80: 2076 616c 7565 2c20 616e 6420 6170 7065 value, and appe\n-0004fa90: 6e64 2074 6865 2076 616c 7565 2074 6f20 nd the value to \n-0004faa0: 7468 6520 6d65 7373 6167 652e 0a23 0a23 the message..#.#\n-0004fab0: 2020 2064 6566 2077 7269 7465 7228 6d65 def writer(me\n-0004fac0: 7373 6167 653a 2042 7573 4d65 7373 6167 ssage: BusMessag\n-0004fad0: 652c 2076 616c 7565 3a20 6f62 6a65 6374 e, value: object\n-0004fae0: 2920 2d3e 204e 6f6e 653a 0a23 0a23 2054 ) -> None:.#.# T\n-0004faf0: 6865 206e 6563 6573 7361 7279 2069 6e66 he necessary inf\n-0004fb00: 6f72 6d61 7469 6f6e 2066 6f72 2074 6865 ormation for the\n-0004fb10: 2073 7065 6369 6669 6320 7479 7065 206f specific type o\n-0004fb20: 6620 6f62 6a65 6374 2074 6f20 6265 2068 f object to be h\n-0004fb30: 616e 646c 6564 2069 730a 2320 7061 7274 andled is.# part\n-0004fb40: 206f 6620 7468 6520 6675 6e63 7469 6f6e of the function\n-0004fb50: 2e20 204e 6f20 6164 6469 7469 6f6e 616c . No additional\n-0004fb60: 2069 6e66 6f72 6d61 7469 6f6e 206e 6565 information nee\n-0004fb70: 6473 2074 6f20 6265 2070 726f 7669 6465 ds to be provide\n-0004fb80: 642e 0a0a 696d 706f 7274 2062 696e 6173 d...import binas\n-0004fb90: 6369 690a 696d 706f 7274 2063 7479 7065 cii.import ctype\n-0004fba0: 730a 696d 706f 7274 2066 756e 6374 6f6f s.import functoo\n-0004fbb0: 6c73 0a69 6d70 6f72 7420 696e 7370 6563 ls.import inspec\n-0004fbc0: 740a 696d 706f 7274 206a 736f 6e0a 696d t.import json.im\n-0004fbd0: 706f 7274 2072 650a 6672 6f6d 2065 6e75 port re.from enu\n-0004fbe0: 6d20 696d 706f 7274 2045 6e75 6d0a 6672 m import Enum.fr\n-0004fbf0: 6f6d 2074 7970 696e 6720 696d 706f 7274 om typing import\n-0004fc00: 2041 6e79 2c20 4361 6c6c 6162 6c65 2c20 Any, Callable, \n-0004fc10: 436c 6173 7356 6172 2c20 4469 6374 2c20 ClassVar, Dict, \n-0004fc20: 4974 6572 6162 6c65 2c20 4c69 7374 2c20 Iterable, List, \n-0004fc30: 4f70 7469 6f6e 616c 2c20 5365 7175 656e Optional, Sequen\n-0004fc40: 6365 2c20 5475 706c 652c 2054 7970 6556 ce, Tuple, TypeV\n-0004fc50: 6172 2c20 556e 696f 6e0a 0a66 726f 6d20 ar, Union..from \n-0004fc60: 2e20 696d 706f 7274 206c 6962 7379 7374 . import libsyst\n-0004fc70: 656d 642c 2074 7970 696e 670a 6672 6f6d emd, typing.from\n-0004fc80: 202e 7479 7069 6e67 2069 6d70 6f72 7420 .typing import \n-0004fc90: 416e 6e6f 7461 7465 642c 2054 7970 6547 Annotated, TypeG\n-0004fca0: 7561 7264 0a0a 5f6f 626a 6563 745f 7061 uard.._object_pa\n-0004fcb0: 7468 5f72 6520 3d20 7265 2e63 6f6d 7069 th_re = re.compi\n-0004fcc0: 6c65 2872 272f 7c28 2f5b 412d 5a61 2d7a le(r'/|(/[A-Za-z\n-0004fcd0: 302d 395f 5d2b 292b 2729 0a0a 0a64 6566 0-9_]+)+')...def\n-0004fce0: 2069 735f 6f62 6a65 6374 5f70 6174 6828 is_object_path(\n-0004fcf0: 6361 6e64 6964 6174 653a 2073 7472 2920 candidate: str) \n-0004fd00: 2d3e 2054 7970 6547 7561 7264 5b27 4275 -> TypeGuard['Bu\n-0004fd10: 7354 7970 652e 6f62 6a65 6374 7061 7468 sType.objectpath\n-0004fd20: 275d 3a0a 2020 2020 7265 7475 726e 205f ']:. return _\n-0004fd30: 6f62 6a65 6374 5f70 6174 685f 7265 2e66 object_path_re.f\n-0004fd40: 756c 6c6d 6174 6368 2863 616e 6469 6461 ullmatch(candida\n-0004fd50: 7465 2920 6973 206e 6f74 204e 6f6e 650a te) is not None.\n-0004fd60: 0a0a 6465 6620 6973 5f73 6967 6e61 7475 ..def is_signatu\n-0004fd70: 7265 2863 616e 6469 6461 7465 3a20 7374 re(candidate: st\n-0004fd80: 7229 202d 3e20 5479 7065 4775 6172 645b r) -> TypeGuard[\n-0004fd90: 2742 7573 5479 7065 2e73 6967 6e61 7475 'BusType.signatu\n-0004fda0: 7265 275d 3a0a 2020 2020 6f66 6673 6574 re']:. offset\n-0004fdb0: 203d 2030 0a0a 2020 2020 6465 6620 6d61 = 0.. def ma\n-0004fdc0: 7962 655f 706f 7028 6163 6365 7074 6162 ybe_pop(acceptab\n-0004fdd0: 6c65 3a20 7374 7229 202d 3e20 4f70 7469 le: str) -> Opti\n-0004fde0: 6f6e 616c 5b73 7472 5d3a 0a20 2020 2020 onal[str]:. \n-0004fdf0: 2020 206e 6f6e 6c6f 6361 6c20 6f66 6673 nonlocal offs\n-0004fe00: 6574 0a20 2020 2020 2020 2063 6861 7220 et. char \n-0004fe10: 3d20 6361 6e64 6964 6174 655b 6f66 6673 = candidate[offs\n-0004fe20: 6574 5d0a 2020 2020 2020 2020 6966 2063 et]. if c\n-0004fe30: 6861 7220 696e 2061 6363 6570 7461 626c har in acceptabl\n-0004fe40: 653a 0a20 2020 2020 2020 2020 2020 206f e:. o\n-0004fe50: 6666 7365 7420 2b3d 2031 0a20 2020 2020 ffset += 1. \n-0004fe60: 2020 2020 2020 2072 6574 7572 6e20 6368 return ch\n-0004fe70: 6172 0a20 2020 2020 2020 2065 6c73 653a ar. else:\n-0004fe80: 0a20 2020 2020 2020 2020 2020 2072 6574 . ret\n-0004fe90: 7572 6e20 4e6f 6e65 0a0a 2020 2020 6465 urn None.. de\n-0004fea0: 6620 706f 7028 6163 6365 7074 6162 6c65 f pop(acceptable\n-0004feb0: 3a20 7374 7229 202d 3e20 7374 723a 0a20 : str) -> str:. \n-0004fec0: 2020 2020 2020 2063 6861 7220 3d20 6d61 char = ma\n-0004fed0: 7962 655f 706f 7028 6163 6365 7074 6162 ybe_pop(acceptab\n-0004fee0: 6c65 290a 2020 2020 2020 2020 6173 7365 le). asse\n-0004fef0: 7274 2063 6861 7220 6973 206e 6f74 204e rt char is not N\n-0004ff00: 6f6e 650a 2020 2020 2020 2020 7265 7475 one. retu\n-0004ff10: 726e 2063 6861 720a 0a20 2020 2064 6566 rn char.. def\n-0004ff20: 2066 696e 645f 6e65 7874 2829 202d 3e20 find_next() -> \n-0004ff30: 4e6f 6e65 3a0a 2020 2020 2020 2020 6669 None:. fi\n-0004ff40: 7273 7420 3d20 706f 7028 2779 626e 7169 rst = pop('ybnqi\n-0004ff50: 7578 7473 6f67 6476 6128 2729 2020 2020 uxtsogdva(') \n-0004ff60: 2320 7661 6c69 6420 6669 7273 7420 6368 # valid first ch\n-0004ff70: 6172 6163 7465 7273 0a20 2020 2020 2020 aracters. \n-0004ff80: 2069 6620 6669 7273 7420 3d3d 2027 6127 if first == 'a'\n-0004ff90: 3a0a 2020 2020 2020 2020 2020 2020 6966 :. if\n-0004ffa0: 206d 6179 6265 5f70 6f70 2827 7b27 293a maybe_pop('{'):\n-0004ffb0: 2020 2020 2020 2020 2020 2020 2020 2320 # \n-0004ffc0: 6469 6374 0a20 2020 2020 2020 2020 2020 dict. \n-0004ffd0: 2020 2020 2070 6f70 2827 7962 6e71 6975 pop('ybnqiu\n-0004ffe0: 7874 736f 6764 2729 2020 2020 2020 2020 xtsogd') \n-0004fff0: 2020 2023 206b 6579 0a20 2020 2020 2020 # key. \n-00050000: 2020 2020 2020 2020 2066 696e 645f 6e65 find_ne\n-00050010: 7874 2829 2020 2020 2020 2020 2020 2020 xt() \n-00050020: 2020 2020 2020 2023 2076 616c 7565 0a20 # value. \n-00050030: 2020 2020 2020 2020 2020 2020 2020 2070 p\n-00050040: 6f70 2827 7d27 290a 2020 2020 2020 2020 op('}'). \n-00050050: 2020 2020 656c 7365 3a20 2020 2020 2020 else: \n-00050060: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00050070: 2020 2020 2320 6172 7261 790a 2020 2020 # array. \n-00050080: 2020 2020 2020 2020 2020 2020 6669 6e64 find\n-00050090: 5f6e 6578 7428 2920 2020 2020 2020 2020 _next() \n-000500a0: 2020 2020 2020 2020 2020 2320 6974 656d # item\n-000500b0: 0a20 2020 2020 2020 2065 6c69 6620 6669 . elif fi\n-000500c0: 7273 7420 3d3d 2027 2827 3a20 2020 2020 rst == '(': \n-000500d0: 2020 2020 2020 2020 2020 2020 2023 2073 # s\n-000500e0: 7472 7563 7475 7265 0a20 2020 2020 2020 tructure. \n-000500f0: 2020 2020 2066 696e 645f 6e65 7874 2829 find_next()\n-00050100: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00050110: 2020 2020 2020 2023 2061 7420 6c65 6173 # at leas\n-00050120: 7420 6f6e 6520 6974 656d 0a20 2020 2020 t one item. \n-00050130: 2020 2020 2020 2077 6869 6c65 206e 6f74 while not\n-00050140: 206d 6179 6265 5f70 6f70 2827 2927 293a maybe_pop(')'):\n-00050150: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-00050160: 2066 696e 645f 6e65 7874 2829 2020 2020 find_next() \n-00050170: 2020 2020 2020 2020 2020 2020 2020 2023 #\n-00050180: 2061 6e64 2070 6f73 7369 626c 7920 6d6f and possibly mo\n-00050190: 7265 0a0a 2020 2020 7472 793a 0a20 2020 re.. try:. \n-000501a0: 2020 2020 2077 6869 6c65 206f 6666 7365 while offse\n-000501b0: 7420 3c20 6c65 6e28 6361 6e64 6964 6174 t < len(candidat\n-000501c0: 6529 3a0a 2020 2020 2020 2020 2020 2020 e):. \n-000501d0: 6669 6e64 5f6e 6578 7428 290a 2020 2020 find_next(). \n-000501e0: 2020 2020 7265 7475 726e 2054 7275 650a return True.\n-000501f0: 2020 2020 6578 6365 7074 2028 4173 7365 except (Asse\n-00050200: 7274 696f 6e45 7272 6f72 2c20 496e 6465 rtionError, Inde\n-00050210: 7845 7272 6f72 293a 0a20 2020 2020 2020 xError):. \n-00050220: 2072 6574 7572 6e20 4661 6c73 650a 0a0a return False...\n-00050230: 6465 6620 7969 656c 645f 6261 7365 5f68 def yield_base_h\n-00050240: 656c 7065 7273 2829 202d 3e20 4974 6572 elpers() -> Iter\n-00050250: 6162 6c65 5b54 7570 6c65 5b73 7472 2c20 able[Tuple[str, \n-00050260: 6f62 6a65 6374 5d5d 3a0a 2020 2020 666f object]]:. fo\n-00050270: 7220 6d65 7468 6f64 2069 6e20 5b27 656e r method in ['en\n-00050280: 7465 725f 636f 6e74 6169 6e65 7227 2c20 ter_container', \n-00050290: 2765 7869 745f 636f 6e74 6169 6e65 7227 'exit_container'\n-000502a0: 2c20 276f 7065 6e5f 636f 6e74 6169 6e65 , 'open_containe\n-000502b0: 7227 2c20 2763 6c6f 7365 5f63 6f6e 7461 r', 'close_conta\n-000502c0: 696e 6572 272c 0a20 2020 2020 2020 2020 iner',. \n-000502d0: 2020 2020 2020 2020 2020 2761 7070 656e 'appen\n-000502e0: 645f 6261 7369 6327 2c20 2772 6561 645f d_basic', 'read_\n-000502f0: 6261 7369 6327 2c20 2761 7070 656e 645f basic', 'append_\n-00050300: 6172 7261 7927 2c20 2772 6561 645f 6172 array', 'read_ar\n-00050310: 7261 7927 5d3a 0a20 2020 2020 2020 2079 ray']:. y\n-00050320: 6965 6c64 206d 6574 686f 642c 206c 6962 ield method, lib\n-00050330: 7379 7374 656d 642e 6c69 6273 7973 7465 systemd.libsyste\n-00050340: 6d64 5b66 2773 645f 6275 735f 6d65 7373 md[f'sd_bus_mess\n-00050350: 6167 655f 7b6d 6574 686f 647d 275d 0a0a age_{method}']..\n-00050360: 2020 2020 666f 7220 6e61 6d65 2069 6e20 for name in \n-00050370: 5b27 7369 7a65 5f74 272c 2027 6368 6172 ['size_t', 'char\n-00050380: 5f70 275d 3a0a 2020 2020 2020 2020 696e _p']:. in\n-00050390: 7374 616e 6365 203d 2067 6574 6174 7472 stance = getattr\n-000503a0: 2863 7479 7065 732c 2066 2763 5f7b 6e61 (ctypes, f'c_{na\n-000503b0: 6d65 7d27 2928 290a 2020 2020 2020 2020 me}')(). \n-000503c0: 7969 656c 6420 6627 7b6e 616d 657d 272c yield f'{name}',\n-000503d0: 2069 6e73 7461 6e63 650a 2020 2020 2020 instance. \n-000503e0: 2020 7969 656c 6420 6627 7b6e 616d 657d yield f'{name}\n-000503f0: 5f72 6566 272c 2063 7479 7065 732e 6279 _ref', ctypes.by\n-00050400: 7265 6628 696e 7374 616e 6365 290a 2020 ref(instance). \n-00050410: 2020 2020 2020 7969 656c 6420 6627 7b6e yield f'{n\n-00050420: 616d 657d 5f73 6574 7465 7227 2c20 696e ame}_setter', in\n-00050430: 7374 616e 6365 2e5f 5f63 6c61 7373 5f5f stance.__class__\n-00050440: 2e76 616c 7565 2e5f 5f73 6574 5f5f 0a0a .value.__set__..\n-00050450: 2020 2020 666f 7220 6368 6172 2069 6e20 for char in \n-00050460: 2761 6572 7679 273a 0a20 2020 2020 2020 'aervy':. \n-00050470: 2079 6965 6c64 2063 6861 722c 2063 7479 yield char, cty\n-00050480: 7065 732e 635f 6368 6172 286f 7264 2863 pes.c_char(ord(c\n-00050490: 6861 7229 290a 0a20 2020 2023 2068 7474 har)).. # htt\n-000504a0: 7073 3a2f 2f64 6f63 732e 7079 7468 6f6e ps://docs.python\n-000504b0: 2e6f 7267 2f33 2f63 2d61 7069 2f75 6e69 .org/3/c-api/uni\n-000504c0: 636f 6465 2e68 746d 6c23 632e 5079 556e code.html#c.PyUn\n-000504d0: 6963 6f64 655f 4672 6f6d 5374 7269 6e67 icode_FromString\n-000504e0: 0a20 2020 2074 6f5f 6279 7465 7320 3d20 . to_bytes = \n-000504f0: 6374 7970 6573 2e70 7974 686f 6e61 7069 ctypes.pythonapi\n-00050500: 2e50 7942 7974 6573 5f46 726f 6d53 7472 .PyBytes_FromStr\n-00050510: 696e 6741 6e64 5369 7a65 0a20 2020 2074 ingAndSize. t\n-00050520: 6f5f 6279 7465 732e 7265 7374 7970 6520 o_bytes.restype \n-00050530: 3d20 6374 7970 6573 2e70 795f 6f62 6a65 = ctypes.py_obje\n-00050540: 6374 0a20 2020 2079 6965 6c64 2027 746f ct. yield 'to\n-00050550: 5f62 7974 6573 272c 2074 6f5f 6279 7465 _bytes', to_byte\n-00050560: 730a 0a0a 5f62 6173 655f 6865 6c70 6572 s..._base_helper\n-00050570: 7320 3d20 6469 6374 2879 6965 6c64 5f62 s = dict(yield_b\n-00050580: 6173 655f 6865 6c70 6572 7328 2929 0a0a ase_helpers())..\n-00050590: 5420 3d20 5479 7065 5661 7228 2754 2729 T = TypeVar('T')\n-000505a0: 0a0a 0a64 6566 2063 616c 6c5f 7769 7468 ...def call_with\n-000505b0: 5f6b 7761 7267 7328 6675 6e63 3a20 4361 _kwargs(func: Ca\n-000505c0: 6c6c 6162 6c65 5b2e 2e2e 2c20 545d 2c20 llable[..., T], \n-000505d0: 6b77 6172 6773 3a20 4469 6374 5b73 7472 kwargs: Dict[str\n-000505e0: 2c20 416e 795d 2920 2d3e 2054 3a0a 2020 , Any]) -> T:. \n-000505f0: 2020 7061 7261 6d65 7465 7273 203d 2073 parameters = s\n-00050600: 6574 2869 6e73 7065 6374 2e73 6967 6e61 et(inspect.signa\n-00050610: 7475 7265 2866 756e 6329 2e70 6172 616d ture(func).param\n-00050620: 6574 6572 7329 0a20 2020 2072 6574 7572 eters). retur\n-00050630: 6e20 6675 6e63 282a 2a7b 6b65 793a 2076 n func(**{key: v\n-00050640: 616c 7565 2066 6f72 206b 6579 2c20 7661 alue for key, va\n-00050650: 6c75 6520 696e 206b 7761 7267 732e 6974 lue in kwargs.it\n-00050660: 656d 7328 2920 6966 206b 6579 2069 6e20 ems() if key in \n-00050670: 7061 7261 6d65 7465 7273 7d29 0a0a 0a63 parameters})...c\n-00050680: 6c61 7373 2054 7970 653a 0a20 2020 205f lass Type:. _\n-00050690: 6361 6368 653a 2043 6c61 7373 5661 725b cache: ClassVar[\n-000506a0: 4469 6374 5b54 7570 6c65 5b74 7970 652c Dict[Tuple[type,\n-000506b0: 2054 7570 6c65 5b6f 626a 6563 742c 202e Tuple[object, .\n-000506c0: 2e2e 5d5d 2c20 2754 7970 6527 5d5d 203d ..]], 'Type']] =\n-000506d0: 207b 7d0a 0a20 2020 205f 5f73 6c6f 7473 {}.. __slots\n-000506e0: 5f5f 203d 2027 7479 7065 7374 7269 6e67 __ = 'typestring\n-000506f0: 272c 2027 6279 7465 735f 7479 7065 7374 ', 'bytes_typest\n-00050700: 7269 6e67 272c 2027 7772 6974 6572 272c ring', 'writer',\n-00050710: 2027 7265 6164 6572 270a 2020 2020 7479 'reader'. ty\n-00050720: 7065 7374 7269 6e67 3a20 7374 720a 2020 pestring: str. \n-00050730: 2020 6279 7465 735f 7479 7065 7374 7269 bytes_typestri\n-00050740: 6e67 3a20 6279 7465 730a 2020 2020 7265 ng: bytes. re\n-00050750: 6164 6572 3a20 4361 6c6c 6162 6c65 5b5b ader: Callable[[\n-00050760: 6c69 6273 7973 7465 6d64 2e73 645f 6275 libsystemd.sd_bu\n-00050770: 735f 6d65 7373 6167 655d 2c20 6f62 6a65 s_message], obje\n-00050780: 6374 5d0a 2020 2020 7772 6974 6572 3a20 ct]. writer: \n-00050790: 4361 6c6c 6162 6c65 5b5b 6c69 6273 7973 Callable[[libsys\n-000507a0: 7465 6d64 2e73 645f 6275 735f 6d65 7373 temd.sd_bus_mess\n-000507b0: 6167 652c 206f 626a 6563 745d 2c20 4e6f age, object], No\n-000507c0: 6e65 5d0a 0a20 2020 2064 6566 205f 5f6e ne].. def __n\n-000507d0: 6577 5f5f 2863 6c73 2c20 2a61 7267 733a ew__(cls, *args:\n-000507e0: 2041 6e79 2920 2d3e 2027 5479 7065 273a Any) -> 'Type':\n-000507f0: 0a20 2020 2020 2020 2069 6e73 7461 6e63 . instanc\n-00050800: 6520 3d20 5479 7065 2e5f 6361 6368 652e e = Type._cache.\n-00050810: 6765 7428 2863 6c73 2c20 6172 6773 2929 get((cls, args))\n-00050820: 0a20 2020 2020 2020 2069 6620 696e 7374 . if inst\n-00050830: 616e 6365 2069 7320 4e6f 6e65 3a0a 2020 ance is None:. \n-00050840: 2020 2020 2020 2020 2020 696e 7374 616e instan\n-00050850: 6365 203d 206f 626a 6563 742e 5f5f 6e65 ce = object.__ne\n-00050860: 775f 5f28 636c 7329 0a20 2020 2020 2020 w__(cls). \n-00050870: 2020 2020 2054 7970 652e 5f63 6163 6865 Type._cache\n-00050880: 5b28 636c 732c 2061 7267 7329 5d20 3d20 [(cls, args)] = \n-00050890: 696e 7374 616e 6365 0a20 2020 2020 2020 instance. \n-000508a0: 2072 6574 7572 6e20 696e 7374 616e 6365 return instance\n-000508b0: 0a0a 2020 2020 6465 6620 5f5f 696e 6974 .. def __init\n-000508c0: 5f5f 2873 656c 662c 2074 7970 6573 7472 __(self, typestr\n-000508d0: 696e 673a 2073 7472 2c20 2a2a 6b77 6172 ing: str, **kwar\n-000508e0: 6773 3a20 416e 7929 3a0a 2020 2020 2020 gs: Any):. \n-000508f0: 2020 7365 6c66 2e74 7970 6573 7472 696e self.typestrin\n-00050900: 6720 3d20 7479 7065 7374 7269 6e67 0a20 g = typestring. \n-00050910: 2020 2020 2020 2073 656c 662e 6279 7465 self.byte\n-00050920: 735f 7479 7065 7374 7269 6e67 203d 2074 s_typestring = t\n-00050930: 7970 6573 7472 696e 672e 656e 636f 6465 ypestring.encode\n-00050940: 2827 6173 6369 6927 290a 0a20 2020 2020 ('ascii').. \n-00050950: 2020 206b 7761 7267 7320 3d20 6469 6374 kwargs = dict\n-00050960: 285f 6261 7365 5f68 656c 7065 7273 2c20 (_base_helpers, \n-00050970: 2a2a 6b77 6172 6773 290a 2020 2020 2020 **kwargs). \n-00050980: 2020 7365 6c66 2e77 7269 7465 7220 3d20 self.writer = \n-00050990: 6361 6c6c 5f77 6974 685f 6b77 6172 6773 call_with_kwargs\n-000509a0: 2873 656c 662e 6765 745f 7772 6974 6572 (self.get_writer\n-000509b0: 2c20 6b77 6172 6773 290a 2020 2020 2020 , kwargs). \n-000509c0: 2020 7365 6c66 2e72 6561 6465 7220 3d20 self.reader = \n-000509d0: 6361 6c6c 5f77 6974 685f 6b77 6172 6773 call_with_kwargs\n-000509e0: 2873 656c 662e 6765 745f 7265 6164 6572 (self.get_reader\n-000509f0: 2c20 6b77 6172 6773 290a 0a20 2020 2064 , kwargs).. d\n-00050a00: 6566 205f 5f72 6570 725f 5f28 7365 6c66 ef __repr__(self\n-00050a10: 2920 2d3e 2073 7472 3a0a 2020 2020 2020 ) -> str:. \n-00050a20: 2020 7265 7475 726e 2066 227b 7365 6c66 return f\"{self\n-00050a30: 2e5f 5f63 6c61 7373 5f5f 2e5f 5f6e 616d .__class__.__nam\n-00050a40: 655f 5f7d 2827 7b73 656c 662e 7479 7065 e__}('{self.type\n-00050a50: 7374 7269 6e67 7d27 2922 0a0a 2020 2020 string}')\".. \n-00050a60: 6465 6620 6765 745f 7772 6974 6572 2873 def get_writer(s\n-00050a70: 656c 662c 202a 2a6b 7761 7267 733a 206f elf, **kwargs: o\n-00050a80: 626a 6563 7429 202d 3e20 4361 6c6c 6162 bject) -> Callab\n-00050a90: 6c65 5b5b 6f62 6a65 6374 2c20 6f62 6a65 le[[object, obje\n-00050aa0: 6374 5d2c 204e 6f6e 655d 3a0a 2020 2020 ct], None]:. \n-00050ab0: 2020 2020 7261 6973 6520 4e6f 7449 6d70 raise NotImp\n-00050ac0: 6c65 6d65 6e74 6564 4572 726f 720a 0a20 lementedError.. \n-00050ad0: 2020 2064 6566 2067 6574 5f72 6561 6465 def get_reade\n-00050ae0: 7228 7365 6c66 2c20 2a2a 6b77 6172 6773 r(self, **kwargs\n-00050af0: 3a20 6f62 6a65 6374 2920 2d3e 2043 616c : object) -> Cal\n-00050b00: 6c61 626c 655b 5b6f 626a 6563 745d 2c20 lable[[object], \n-00050b10: 6f62 6a65 6374 5d3a 0a20 2020 2020 2020 object]:. \n-00050b20: 2072 6169 7365 204e 6f74 496d 706c 656d raise NotImplem\n-00050b30: 656e 7465 6445 7272 6f72 0a0a 0a63 6c61 entedError...cla\n-00050b40: 7373 2042 6173 6963 5479 7065 2854 7970 ss BasicType(Typ\n-00050b50: 6529 3a0a 2020 2020 5f5f 736c 6f74 735f e):. __slots_\n-00050b60: 5f20 3d20 2829 0a0a 2020 2020 6465 6620 _ = ().. def \n-00050b70: 5f5f 696e 6974 5f5f 2873 656c 662c 2074 __init__(self, t\n-00050b80: 7970 6573 7472 696e 673a 2073 7472 2c20 ypestring: str, \n-00050b90: 6374 7970 652c 2067 6574 5f77 7261 7070 ctype, get_wrapp\n-00050ba0: 6572 3d4e 6f6e 652c 202a 2a6b 7761 7267 er=None, **kwarg\n-00050bb0: 7329 3a0a 2020 2020 2020 2020 7661 7269 s):. vari\n-00050bc0: 6162 6c65 203d 2063 7479 7065 2829 2020 able = ctype() \n-00050bd0: 2320 4e42 3a20 6e6f 7420 7468 7265 6164 # NB: not thread\n-00050be0: 2d73 6166 650a 2020 2020 2020 2020 7375 -safe. su\n-00050bf0: 7065 7228 292e 5f5f 696e 6974 5f5f 2874 per().__init__(t\n-00050c00: 7970 6573 7472 696e 672c 2063 7479 7065 ypestring, ctype\n-00050c10: 3d63 7479 7065 2c20 7479 7065 5f63 6f6e =ctype, type_con\n-00050c20: 7374 616e 743d 6374 7970 6573 2e63 5f63 stant=ctypes.c_c\n-00050c30: 6861 7228 6f72 6428 7479 7065 7374 7269 har(ord(typestri\n-00050c40: 6e67 2929 2c0a 2020 2020 2020 2020 2020 ng)),. \n-00050c50: 2020 2020 2020 2020 2020 2020 2020 2067 g\n-00050c60: 6574 7465 723d 6765 745f 7772 6170 7065 etter=get_wrappe\n-00050c70: 7220 6f72 2063 7479 7065 2e76 616c 7565 r or ctype.value\n-00050c80: 2e5f 5f67 6574 5f5f 2c20 7365 7474 6572 .__get__, setter\n-00050c90: 3d63 7479 7065 2e76 616c 7565 2e5f 5f73 =ctype.value.__s\n-00050ca0: 6574 5f5f 2c0a 2020 2020 2020 2020 2020 et__,. \n-00050cb0: 2020 2020 2020 2020 2020 2020 2020 2076 v\n-00050cc0: 6172 6961 626c 653d 7661 7269 6162 6c65 ariable=variable\n-00050cd0: 2c20 7265 6665 7265 6e63 653d 6374 7970 , reference=ctyp\n-00050ce0: 6573 2e62 7972 6566 2876 6172 6961 626c es.byref(variabl\n-00050cf0: 6529 2c20 2a2a 6b77 6172 6773 290a 0a20 e), **kwargs).. \n-00050d00: 2020 2064 6566 2067 6574 5f72 6561 6465 def get_reade\n-00050d10: 7228 7365 6c66 2c20 7265 6164 5f62 6173 r(self, read_bas\n-00050d20: 6963 2c20 7479 7065 5f63 6f6e 7374 616e ic, type_constan\n-00050d30: 742c 2076 6172 6961 626c 652c 2072 6566 t, variable, ref\n-00050d40: 6572 656e 6365 2c20 6765 7474 6572 293a erence, getter):\n-00050d50: 0a20 2020 2020 2020 2064 6566 2062 6173 . def bas\n-00050d60: 6963 5f72 6561 6465 7228 6d65 7373 6167 ic_reader(messag\n-00050d70: 653a 206c 6962 7379 7374 656d 642e 7364 e: libsystemd.sd\n-00050d80: 5f62 7573 5f6d 6573 7361 6765 2920 2d3e _bus_message) ->\n-00050d90: 206f 626a 6563 743a 0a20 2020 2020 2020 object:. \n-00050da0: 2020 2020 2069 6620 7265 6164 5f62 6173 if read_bas\n-00050db0: 6963 286d 6573 7361 6765 2c20 7479 7065 ic(message, type\n-00050dc0: 5f63 6f6e 7374 616e 742c 2072 6566 6572 _constant, refer\n-00050dd0: 656e 6365 2920 3c3d 2030 3a0a 2020 2020 ence) <= 0:. \n-00050de0: 2020 2020 2020 2020 2020 2020 7261 6973 rais\n-00050df0: 6520 5374 6f70 4974 6572 6174 696f 6e0a e StopIteration.\n-00050e00: 2020 2020 2020 2020 2020 2020 7265 7475 retu\n-00050e10: 726e 2067 6574 7465 7228 7661 7269 6162 rn getter(variab\n-00050e20: 6c65 290a 2020 2020 2020 2020 7265 7475 le). retu\n-00050e30: 726e 2062 6173 6963 5f72 6561 6465 720a rn basic_reader.\n-00050e40: 0a0a 636c 6173 7320 4669 7865 6454 7970 ..class FixedTyp\n-00050e50: 6528 4261 7369 6354 7970 6529 3a0a 2020 e(BasicType):. \n-00050e60: 2020 5f5f 736c 6f74 735f 5f20 3d20 2829 __slots__ = ()\n-00050e70: 0a0a 2020 2020 6465 6620 6765 745f 7772 .. def get_wr\n-00050e80: 6974 6572 2873 656c 662c 2061 7070 656e iter(self, appen\n-00050e90: 645f 6261 7369 632c 2074 7970 655f 636f d_basic, type_co\n-00050ea0: 6e73 7461 6e74 2c20 7661 7269 6162 6c65 nstant, variable\n-00050eb0: 2c20 7265 6665 7265 6e63 652c 2073 6574 , reference, set\n-00050ec0: 7465 722c 2067 6574 7465 7229 3a0a 2020 ter, getter):. \n-00050ed0: 2020 2020 2020 6465 6620 6669 7865 645f def fixed_\n-00050ee0: 7772 6974 6572 286d 6573 7361 6765 3a20 writer(message: \n-00050ef0: 6c69 6273 7973 7465 6d64 2e73 645f 6275 libsystemd.sd_bu\n-00050f00: 735f 6d65 7373 6167 652c 2076 616c 7565 s_message, value\n-00050f10: 3a20 6f62 6a65 6374 2920 2d3e 204e 6f6e : object) -> Non\n-00050f20: 653a 0a20 2020 2020 2020 2020 2020 2073 e:. s\n-00050f30: 6574 7465 7228 7661 7269 6162 6c65 2c20 etter(variable, \n-00050f40: 7661 6c75 6529 0a20 2020 2020 2020 2020 value). \n-00050f50: 2020 2069 6620 6765 7474 6572 2876 6172 if getter(var\n-00050f60: 6961 626c 6529 2021 3d20 7661 6c75 653a iable) != value:\n-00050f70: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-00050f80: 2072 6169 7365 2054 7970 6545 7272 6f72 raise TypeError\n-00050f90: 2866 2243 616e 6e6f 7420 7265 7072 6573 (f\"Cannot repres\n-00050fa0: 656e 7420 7661 6c75 6520 7b76 616c 7565 ent value {value\n-00050fb0: 7d20 7769 7468 2074 7970 6520 277b 7365 } with type '{se\n-00050fc0: 6c66 2e74 7970 6573 7472 696e 677d 2722 lf.typestring}'\"\n-00050fd0: 290a 2020 2020 2020 2020 2020 2020 6170 ). ap\n-00050fe0: 7065 6e64 5f62 6173 6963 286d 6573 7361 pend_basic(messa\n-00050ff0: 6765 2c20 7479 7065 5f63 6f6e 7374 616e ge, type_constan\n-00051000: 742c 2072 6566 6572 656e 6365 290a 2020 t, reference). \n-00051010: 2020 2020 2020 7265 7475 726e 2066 6978 return fix\n-00051020: 6564 5f77 7269 7465 720a 0a0a 636c 6173 ed_writer...clas\n-00051030: 7320 5374 7269 6e67 4c69 6b65 5479 7065 s StringLikeType\n-00051040: 2842 6173 6963 5479 7065 293a 0a20 2020 (BasicType):. \n-00051050: 205f 5f73 6c6f 7473 5f5f 203d 2028 290a __slots__ = ().\n-00051060: 0a20 2020 2040 7374 6174 6963 6d65 7468 . @staticmeth\n-00051070: 6f64 0a20 2020 2064 6566 2067 6574 5f67 od. def get_g\n-00051080: 7561 7264 6564 5f63 6f6e 7665 7273 696f uarded_conversio\n-00051090: 6e28 7479 7065 7374 7269 6e67 3a20 7374 n(typestring: st\n-000510a0: 722c 2067 7561 7264 3a20 4361 6c6c 6162 r, guard: Callab\n-000510b0: 6c65 5b5b 7374 725d 2c20 626f 6f6c 5d29 le[[str], bool])\n-000510c0: 202d 3e20 4361 6c6c 6162 6c65 5b5b 6f62 -> Callable[[ob\n-000510d0: 6a65 6374 5d2c 2062 7974 6573 5d3a 0a20 ject], bytes]:. \n-000510e0: 2020 2020 2020 2064 6566 2063 6f6e 7665 def conve\n-000510f0: 7274 2863 616e 6469 6461 7465 3a20 6f62 rt(candidate: ob\n-00051100: 6a65 6374 2920 2d3e 2062 7974 6573 3a0a ject) -> bytes:.\n-00051110: 2020 2020 2020 2020 2020 2020 6966 206e if n\n-00051120: 6f74 2069 7369 6e73 7461 6e63 6528 6361 ot isinstance(ca\n-00051130: 6e64 6964 6174 652c 2073 7472 293a 0a20 ndidate, str):. \n-00051140: 2020 2020 2020 2020 2020 2020 2020 2072 r\n-00051150: 6169 7365 2054 7970 6545 7272 6f72 2866 aise TypeError(f\n-00051160: 2227 7b74 7970 6573 7472 696e 677d 2720 \"'{typestring}' \n-00051170: 656e 636f 6465 7320 2773 7472 272c 206e encodes 'str', n\n-00051180: 6f74 2027 7b63 616e 6469 6461 7465 2e5f ot '{candidate._\n-00051190: 5f63 6c61 7373 5f5f 2e5f 5f6e 616d 655f _class__.__name_\n-000511a0: 5f7d 2722 290a 2020 2020 2020 2020 2020 _}'\"). \n-000511b0: 2020 6966 206e 6f74 2067 7561 7264 2863 if not guard(c\n-000511c0: 616e 6469 6461 7465 293a 0a20 2020 2020 andidate):. \n-000511d0: 2020 2020 2020 2020 2020 2072 6169 7365 raise\n-000511e0: 2056 616c 7565 4572 726f 7228 6622 496e ValueError(f\"In\n-000511f0: 7661 6c69 6420 7661 6c75 6520 7072 6f76 valid value prov\n-00051200: 6964 6564 2066 6f72 2074 7970 6520 277b ided for type '{\n-00051210: 7479 7065 7374 7269 6e67 7d27 2229 0a20 typestring}'\"). \n-00051220: 2020 2020 2020 2020 2020 2072 6574 7572 retur\n-00051230: 6e20 7374 722e 656e 636f 6465 2863 616e n str.encode(can\n-00051240: 6469 6461 7465 290a 2020 2020 2020 2020 didate). \n-00051250: 7265 7475 726e 2063 6f6e 7665 7274 0a0a return convert..\n-00051260: 2020 2020 6465 6620 5f5f 696e 6974 5f5f def __init__\n-00051270: 2873 656c 662c 2074 7970 6573 7472 696e (self, typestrin\n-00051280: 673a 2073 7472 2c20 6775 6172 643a 204f g: str, guard: O\n-00051290: 7074 696f 6e61 6c5b 4361 6c6c 6162 6c65 ptional[Callable\n-000512a0: 5b5b 7374 725d 2c20 626f 6f6c 5d5d 203d [[str], bool]] =\n-000512b0: 204e 6f6e 6529 3a0a 2020 2020 2020 2020 None):. \n-000512c0: 2320 6874 7470 733a 2f2f 646f 6373 2e70 # https://docs.p\n-000512d0: 7974 686f 6e2e 6f72 672f 332f 632d 6170 ython.org/3/c-ap\n-000512e0: 692f 756e 6963 6f64 652e 6874 6d6c 2363 i/unicode.html#c\n-000512f0: 2e50 7955 6e69 636f 6465 5f46 726f 6d53 .PyUnicode_FromS\n-00051300: 7472 696e 670a 2020 2020 2020 2020 746f tring. to\n-00051310: 5f75 6e69 636f 6465 203d 2063 7479 7065 _unicode = ctype\n-00051320: 732e 7079 7468 6f6e 6170 692e 5079 556e s.pythonapi.PyUn\n-00051330: 6963 6f64 655f 4672 6f6d 5374 7269 6e67 icode_FromString\n-00051340: 0a20 2020 2020 2020 2074 6f5f 756e 6963 . to_unic\n-00051350: 6f64 652e 7265 7374 7970 6520 3d20 6374 ode.restype = ct\n-00051360: 7970 6573 2e70 795f 6f62 6a65 6374 0a0a ypes.py_object..\n-00051370: 2020 2020 2020 2020 6966 2067 7561 7264 if guard\n-00051380: 2069 7320 6e6f 7420 4e6f 6e65 3a0a 2020 is not None:. \n-00051390: 2020 2020 2020 2020 2020 636f 6e76 6572 conver\n-000513a0: 7420 3d20 5374 7269 6e67 4c69 6b65 5479 t = StringLikeTy\n-000513b0: 7065 2e67 6574 5f67 7561 7264 6564 5f63 pe.get_guarded_c\n-000513c0: 6f6e 7665 7273 696f 6e28 7479 7065 7374 onversion(typest\n-000513d0: 7269 6e67 2c20 6775 6172 6429 0a20 2020 ring, guard). \n-000513e0: 2020 2020 2065 6c73 653a 0a20 2020 2020 else:. \n-000513f0: 2020 2020 2020 2063 6f6e 7665 7274 203d convert =\n-00051400: 2073 7472 2e65 6e63 6f64 6520 2023 2074 str.encode # t\n-00051410: 7970 653a 2069 676e 6f72 655b 6173 7369 ype: ignore[assi\n-00051420: 676e 6d65 6e74 5d20 2320 6361 6e20 7468 gnment] # can th\n-00051430: 726f 7720 5479 7065 4572 726f 7220 6f6e row TypeError on\n-00051440: 2063 616c 6c0a 0a20 2020 2020 2020 2073 call.. s\n-00051450: 7570 6572 2829 2e5f 5f69 6e69 745f 5f28 uper().__init__(\n-00051460: 7479 7065 7374 7269 6e67 2c20 6374 7970 typestring, ctyp\n-00051470: 6573 2e63 5f63 6861 725f 702c 2074 6f5f es.c_char_p, to_\n-00051480: 756e 6963 6f64 652c 2063 6f6e 7665 7274 unicode, convert\n-00051490: 3d63 6f6e 7665 7274 290a 0a20 2020 2064 =convert).. d\n-000514a0: 6566 2067 6574 5f77 7269 7465 7228 7365 ef get_writer(se\n-000514b0: 6c66 2c20 6170 7065 6e64 5f62 6173 6963 lf, append_basic\n-000514c0: 2c20 7479 7065 5f63 6f6e 7374 616e 742c , type_constant,\n-000514d0: 2063 6f6e 7665 7274 293a 0a20 2020 2020 convert):. \n-000514e0: 2020 2064 6566 2073 7472 696e 675f 7772 def string_wr\n-000514f0: 6974 6572 286d 6573 7361 6765 3a20 6c69 iter(message: li\n-00051500: 6273 7973 7465 6d64 2e73 645f 6275 735f bsystemd.sd_bus_\n-00051510: 6d65 7373 6167 652c 2076 616c 7565 3a20 message, value: \n-00051520: 6f62 6a65 6374 2920 2d3e 204e 6f6e 653a object) -> None:\n-00051530: 0a20 2020 2020 2020 2020 2020 2061 7070 . app\n-00051540: 656e 645f 6261 7369 6328 6d65 7373 6167 end_basic(messag\n-00051550: 652c 2074 7970 655f 636f 6e73 7461 6e74 e, type_constant\n-00051560: 2c20 636f 6e76 6572 7428 7661 6c75 6529 , convert(value)\n-00051570: 290a 2020 2020 2020 2020 7265 7475 726e ). return\n-00051580: 2073 7472 696e 675f 7772 6974 6572 0a0a string_writer..\n-00051590: 0a63 6c61 7373 2042 7974 6573 7472 696e .class Bytestrin\n-000515a0: 6754 7970 6528 5479 7065 293a 0a20 2020 gType(Type):. \n-000515b0: 205f 5f73 6c6f 7473 5f5f 203d 2028 290a __slots__ = ().\n-000515c0: 0a20 2020 2064 6566 2067 6574 5f77 7269 . def get_wri\n-000515d0: 7465 7228 7365 6c66 2c20 6170 7065 6e64 ter(self, append\n-000515e0: 5f61 7272 6179 2c20 792c 2073 697a 655f _array, y, size_\n-000515f0: 745f 7365 7474 6572 2c20 7369 7a65 5f74 t_setter, size_t\n-00051600: 293a 0a20 2020 2020 2020 2064 6566 2062 ):. def b\n-00051610: 7974 6573 5f77 7269 7465 7228 6d65 7373 ytes_writer(mess\n-00051620: 6167 653a 206c 6962 7379 7374 656d 642e age: libsystemd.\n-00051630: 7364 5f62 7573 5f6d 6573 7361 6765 2c20 sd_bus_message, \n-00051640: 7661 6c75 653a 206f 626a 6563 7429 202d value: object) -\n-00051650: 3e20 4e6f 6e65 3a0a 2020 2020 2020 2020 > None:. \n-00051660: 2020 2020 6966 206e 6f74 2069 7369 6e73 if not isins\n-00051670: 7461 6e63 6528 7661 6c75 652c 2062 7974 tance(value, byt\n-00051680: 6573 293a 0a20 2020 2020 2020 2020 2020 es):. \n-00051690: 2020 2020 2069 6620 6973 696e 7374 616e if isinstan\n-000516a0: 6365 2876 616c 7565 2c20 7374 7229 3a0a ce(value, str):.\n-000516b0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000516c0: 2020 2020 7472 793a 0a20 2020 2020 2020 try:. \n-000516d0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000516e0: 2076 616c 7565 203d 2062 696e 6173 6369 value = binasci\n-000516f0: 692e 6132 625f 6261 7365 3634 2876 616c i.a2b_base64(val\n-00051700: 7565 2e65 6e63 6f64 6528 2761 7363 6969 ue.encode('ascii\n-00051710: 2729 2920 2023 206f 7220 6465 636f 6465 ')) # or decode\n-00051720: 2062 6173 6536 340a 2020 2020 2020 2020 base64. \n-00051730: 2020 2020 2020 2020 2020 2020 6578 6365 exce\n-00051740: 7074 2062 696e 6173 6369 692e 4572 726f pt binascii.Erro\n-00051750: 7220 6173 2065 7863 3a0a 2020 2020 2020 r as exc:. \n-00051760: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00051770: 2020 7261 6973 6520 5661 6c75 6545 7272 raise ValueErr\n-00051780: 6f72 2822 2761 7927 2063 616e 6e6f 7420 or(\"'ay' cannot \n-00051790: 656e 636f 6465 2069 6e76 616c 6964 2062 encode invalid b\n-000517a0: 6173 6536 3420 7374 7269 6e67 2229 2066 ase64 string\") f\n-000517b0: 726f 6d20 6578 630a 2020 2020 2020 2020 rom exc. \n-000517c0: 2020 2020 2020 2020 656c 6966 2069 7369 elif isi\n-000517d0: 6e73 7461 6e63 6528 7661 6c75 652c 2028 nstance(value, (\n-000517e0: 6d65 6d6f 7279 7669 6577 2c20 6279 7465 memoryview, byte\n-000517f0: 6172 7261 7929 293a 0a20 2020 2020 2020 array)):. \n-00051800: 2020 2020 2020 2020 2020 2020 2076 616c val\n-00051810: 7565 203d 2062 7974 6573 2876 616c 7565 ue = bytes(value\n-00051820: 290a 2020 2020 2020 2020 2020 2020 2020 ). \n-00051830: 2020 656c 7365 3a0a 2020 2020 2020 2020 else:. \n-00051840: 2020 2020 2020 2020 2020 2020 7261 6973 rais\n-00051850: 6520 5479 7065 4572 726f 7228 2227 6179 e TypeError(\"'ay\n-00051860: 2720 6361 6e20 6f6e 6c79 2065 6e63 6f64 ' can only encod\n-00051870: 6520 6279 7465 732d 6c69 6b65 206f 7220 e bytes-like or \n-00051880: 6261 7365 3634 2073 7472 696e 6720 6f62 base64 string ob\n-00051890: 6a65 6374 732c 2022 0a20 2020 2020 2020 jects, \". \n-000518a0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000518b0: 2020 2020 2020 2020 2020 2020 2066 226e f\"n\n-000518c0: 6f74 2027 7b76 616c 7565 2e5f 5f63 6c61 ot '{value.__cla\n-000518d0: 7373 5f5f 2e5f 5f6e 616d 655f 5f7d 272e ss__.__name__}'.\n-000518e0: 2229 0a20 2020 2020 2020 2020 2020 2073 \"). s\n-000518f0: 697a 655f 745f 7365 7474 6572 2873 697a ize_t_setter(siz\n-00051900: 655f 742c 206c 656e 2876 616c 7565 2929 e_t, len(value))\n-00051910: 0a20 2020 2020 2020 2020 2020 2061 7070 . app\n-00051920: 656e 645f 6172 7261 7928 6d65 7373 6167 end_array(messag\n-00051930: 652c 2079 2c20 7661 6c75 652c 2073 697a e, y, value, siz\n-00051940: 655f 7429 0a20 2020 2020 2020 2072 6574 e_t). ret\n-00051950: 7572 6e20 6279 7465 735f 7772 6974 6572 urn bytes_writer\n-00051960: 0a0a 2020 2020 6465 6620 6765 745f 7265 .. def get_re\n-00051970: 6164 6572 2873 656c 662c 2072 6561 645f ader(self, read_\n-00051980: 6172 7261 792c 2079 2c20 746f 5f62 7974 array, y, to_byt\n-00051990: 6573 2c20 6368 6172 5f70 2c20 6368 6172 es, char_p, char\n-000519a0: 5f70 5f72 6566 2c20 7369 7a65 5f74 2c20 _p_ref, size_t, \n-000519b0: 7369 7a65 5f74 5f72 6566 293a 0a20 2020 size_t_ref):. \n-000519c0: 2020 2020 2064 6566 2062 7974 6573 5f72 def bytes_r\n-000519d0: 6561 6465 7228 6d65 7373 6167 6529 3a0a eader(message):.\n-000519e0: 2020 2020 2020 2020 2020 2020 6966 2072 if r\n-000519f0: 6561 645f 6172 7261 7928 6d65 7373 6167 ead_array(messag\n-00051a00: 652c 2079 2c20 6368 6172 5f70 5f72 6566 e, y, char_p_ref\n-00051a10: 2c20 7369 7a65 5f74 5f72 6566 2920 3c3d , size_t_ref) <=\n-00051a20: 2030 3a0a 2020 2020 2020 2020 2020 2020 0:. \n-00051a30: 2020 2020 7261 6973 6520 5374 6f70 4974 raise StopIt\n-00051a40: 6572 6174 696f 6e0a 2020 2020 2020 2020 eration. \n-00051a50: 2020 2020 7265 7475 726e 2074 6f5f 6279 return to_by\n-00051a60: 7465 7328 6368 6172 5f70 2c20 7369 7a65 tes(char_p, size\n-00051a70: 5f74 290a 2020 2020 2020 2020 7265 7475 _t). retu\n-00051a80: 726e 2062 7974 6573 5f72 6561 6465 720a rn bytes_reader.\n-00051a90: 0a0a 636c 6173 7320 436f 6e74 6169 6e65 ..class Containe\n-00051aa0: 7254 7970 6528 5479 7065 293a 0a20 2020 rType(Type):. \n-00051ab0: 205f 7479 7065 7374 7269 6e67 5f74 656d _typestring_tem\n-00051ac0: 706c 6174 653a 2043 6c61 7373 5661 725b plate: ClassVar[\n-00051ad0: 7374 725d 0a20 2020 205f 5f73 6c6f 7473 str]. __slots\n-00051ae0: 5f5f 203d 2027 6974 656d 5f74 7970 6573 __ = 'item_types\n-00051af0: 270a 2020 2020 6974 656d 5f74 7970 6573 '. item_types\n-00051b00: 3a20 5365 7175 656e 6365 5b54 7970 655d : Sequence[Type]\n-00051b10: 0a0a 2020 2020 6465 6620 5f5f 696e 6974 .. def __init\n-00051b20: 5f5f 2873 656c 662c 202a 6974 656d 5f74 __(self, *item_t\n-00051b30: 7970 6573 3a20 5479 7065 2c20 2a2a 6b77 ypes: Type, **kw\n-00051b40: 6172 6773 3a20 416e 7929 3a0a 2020 2020 args: Any):. \n-00051b50: 2020 2020 6173 7365 7274 206c 656e 2869 assert len(i\n-00051b60: 7465 6d5f 7479 7065 7329 203e 2030 0a20 tem_types) > 0. \n-00051b70: 2020 2020 2020 2069 7465 6d5f 7479 7065 item_type\n-00051b80: 7374 7269 6e67 7320 3d20 2727 2e6a 6f69 strings = ''.joi\n-00051b90: 6e28 6974 656d 2e74 7970 6573 7472 696e n(item.typestrin\n-00051ba0: 6720 666f 7220 6974 656d 2069 6e20 6974 g for item in it\n-00051bb0: 656d 5f74 7970 6573 290a 2020 2020 2020 em_types). \n-00051bc0: 2020 7365 6c66 2e69 7465 6d5f 7479 7065 self.item_type\n-00051bd0: 7320 3d20 6974 656d 5f74 7970 6573 0a20 s = item_types. \n-00051be0: 2020 2020 2020 2073 7570 6572 2829 2e5f super()._\n-00051bf0: 5f69 6e69 745f 5f28 7365 6c66 2e5f 7479 _init__(self._ty\n-00051c00: 7065 7374 7269 6e67 5f74 656d 706c 6174 pestring_templat\n-00051c10: 652e 7265 706c 6163 6528 275f 272c 2069 e.replace('_', i\n-00051c20: 7465 6d5f 7479 7065 7374 7269 6e67 7329 tem_typestrings)\n-00051c30: 2c0a 2020 2020 2020 2020 2020 2020 2020 ,. \n-00051c40: 2020 2020 2020 2020 2020 2074 7970 655f type_\n-00051c50: 636f 6e74 656e 7473 3d63 7479 7065 732e contents=ctypes.\n-00051c60: 635f 6368 6172 5f70 2869 7465 6d5f 7479 c_char_p(item_ty\n-00051c70: 7065 7374 7269 6e67 732e 656e 636f 6465 pestrings.encode\n-00051c80: 2827 6173 6369 6927 2929 2c0a 2020 2020 ('ascii')),. \n-00051c90: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00051ca0: 2020 2020 202a 2a6b 7761 7267 7329 0a0a **kwargs)..\n-00051cb0: 0a63 6c61 7373 2041 7272 6179 5479 7065 .class ArrayType\n-00051cc0: 2843 6f6e 7461 696e 6572 5479 7065 293a (ContainerType):\n-00051cd0: 0a20 2020 205f 7479 7065 7374 7269 6e67 . _typestring\n-00051ce0: 5f74 656d 706c 6174 6520 3d20 2761 5f27 _template = 'a_'\n-00051cf0: 0a20 2020 205f 5f73 6c6f 7473 5f5f 203d . __slots__ =\n-00051d00: 2028 290a 0a20 2020 2064 6566 205f 5f69 ().. def __i\n-00051d10: 6e69 745f 5f28 7365 6c66 2c20 6974 656d nit__(self, item\n-00051d20: 5f74 7970 653a 2054 7970 6529 3a0a 2020 _type: Type):. \n-00051d30: 2020 2020 2020 7375 7065 7228 292e 5f5f super().__\n-00051d40: 696e 6974 5f5f 2869 7465 6d5f 7479 7065 init__(item_type\n-00051d50: 2c0a 2020 2020 2020 2020 2020 2020 2020 ,. \n-00051d60: 2020 2020 2020 2020 2020 2069 7465 6d5f item_\n-00051d70: 7772 6974 6572 3d69 7465 6d5f 7479 7065 writer=item_type\n-00051d80: 2e77 7269 7465 722c 0a20 2020 2020 2020 .writer,. \n-00051d90: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00051da0: 2020 6974 656d 5f72 6561 6465 723d 6974 item_reader=it\n-00051db0: 656d 5f74 7970 652e 7265 6164 6572 2c0a em_type.reader,.\n-00051dc0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00051dd0: 2020 2020 2020 2020 206c 6973 745f 6170 list_ap\n-00051de0: 7065 6e64 3d6c 6973 742e 6170 7065 6e64 pend=list.append\n-00051df0: 290a 0a20 2020 2064 6566 2067 6574 5f72 ).. def get_r\n-00051e00: 6561 6465 7228 7365 6c66 2c20 656e 7465 eader(self, ente\n-00051e10: 725f 636f 6e74 6169 6e65 722c 2065 7869 r_container, exi\n-00051e20: 745f 636f 6e74 6169 6e65 722c 206c 6973 t_container, lis\n-00051e30: 745f 6170 7065 6e64 2c20 6974 656d 5f72 t_append, item_r\n-00051e40: 6561 6465 7229 3a0a 2020 2020 2020 2020 eader):. \n-00051e50: 6465 6620 6172 7261 795f 7265 6164 6572 def array_reader\n-00051e60: 286d 6573 7361 6765 3a20 6c69 6273 7973 (message: libsys\n-00051e70: 7465 6d64 2e73 645f 6275 735f 6d65 7373 temd.sd_bus_mess\n-00051e80: 6167 6529 202d 3e20 6f62 6a65 6374 3a0a age) -> object:.\n-00051e90: 2020 2020 2020 2020 2020 2020 6966 2065 if e\n-00051ea0: 6e74 6572 5f63 6f6e 7461 696e 6572 286d nter_container(m\n-00051eb0: 6573 7361 6765 2c20 302c 204e 6f6e 6529 essage, 0, None)\n-00051ec0: 203c 3d20 303a 0a20 2020 2020 2020 2020 <= 0:. \n-00051ed0: 2020 2020 2020 2072 6169 7365 2053 746f raise Sto\n-00051ee0: 7049 7465 7261 7469 6f6e 0a20 2020 2020 pIteration. \n-00051ef0: 2020 2020 2020 2072 6573 756c 743a 204c result: L\n-00051f00: 6973 745b 6f62 6a65 6374 5d20 3d20 5b5d ist[object] = []\n-00051f10: 0a20 2020 2020 2020 2020 2020 2074 7279 . try\n-00051f20: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n-00051f30: 2020 7768 696c 6520 5472 7565 3a0a 2020 while True:. \n-00051f40: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00051f50: 2020 6c69 7374 5f61 7070 656e 6428 7265 list_append(re\n-00051f60: 7375 6c74 2c20 6974 656d 5f72 6561 6465 sult, item_reade\n-00051f70: 7228 6d65 7373 6167 6529 290a 2020 2020 r(message)). \n-00051f80: 2020 2020 2020 2020 6578 6365 7074 2053 except S\n-00051f90: 746f 7049 7465 7261 7469 6f6e 3a0a 2020 topIteration:. \n-00051fa0: 2020 2020 2020 2020 2020 2020 2020 7265 re\n-00051fb0: 7475 726e 2072 6573 756c 740a 2020 2020 turn result. \n-00051fc0: 2020 2020 2020 2020 6669 6e61 6c6c 793a finally:\n-00051fd0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-00051fe0: 2065 7869 745f 636f 6e74 6169 6e65 7228 exit_container(\n-00051ff0: 6d65 7373 6167 6529 0a20 2020 2020 2020 message). \n-00052000: 2072 6574 7572 6e20 6172 7261 795f 7265 return array_re\n-00052010: 6164 6572 0a0a 2020 2020 6465 6620 6765 ader.. def ge\n-00052020: 745f 7772 6974 6572 2873 656c 662c 2061 t_writer(self, a\n-00052030: 2c20 7479 7065 5f63 6f6e 7465 6e74 732c , type_contents,\n-00052040: 206f 7065 6e5f 636f 6e74 6169 6e65 722c open_container,\n-00052050: 2063 6c6f 7365 5f63 6f6e 7461 696e 6572 close_container\n-00052060: 2c20 6974 656d 5f77 7269 7465 7229 3a0a , item_writer):.\n-00052070: 2020 2020 2020 2020 6465 6620 6172 7261 def arra\n-00052080: 795f 7772 6974 6572 286d 6573 7361 6765 y_writer(message\n-00052090: 3a20 6c69 6273 7973 7465 6d64 2e73 645f : libsystemd.sd_\n-000520a0: 6275 735f 6d65 7373 6167 652c 2076 616c bus_message, val\n-000520b0: 7565 3a20 6f62 6a65 6374 2920 2d3e 204e ue: object) -> N\n-000520c0: 6f6e 653a 0a20 2020 2020 2020 2020 2020 one:. \n-000520d0: 206f 7065 6e5f 636f 6e74 6169 6e65 7228 open_container(\n-000520e0: 6d65 7373 6167 652c 2061 2c20 7479 7065 message, a, type\n-000520f0: 5f63 6f6e 7465 6e74 7329 0a20 2020 2020 _contents). \n-00052100: 2020 2020 2020 2066 6f72 2069 7465 6d20 for item \n-00052110: 696e 2076 616c 7565 3a20 2023 2074 7970 in value: # typ\n-00052120: 653a 2069 676e 6f72 655b 6174 7472 2d64 e: ignore[attr-d\n-00052130: 6566 696e 6564 5d20 2320 6361 6e20 7468 efined] # can th\n-00052140: 726f 7720 5479 7065 4572 726f 720a 2020 row TypeError. \n-00052150: 2020 2020 2020 2020 2020 2020 2020 6974 it\n-00052160: 656d 5f77 7269 7465 7228 6d65 7373 6167 em_writer(messag\n-00052170: 652c 2069 7465 6d29 0a20 2020 2020 2020 e, item). \n-00052180: 2020 2020 2063 6c6f 7365 5f63 6f6e 7461 close_conta\n-00052190: 696e 6572 286d 6573 7361 6765 290a 2020 iner(message). \n-000521a0: 2020 2020 2020 7265 7475 726e 2061 7272 return arr\n-000521b0: 6179 5f77 7269 7465 720a 0a0a 636c 6173 ay_writer...clas\n-000521c0: 7320 5374 7275 6374 5479 7065 2843 6f6e s StructType(Con\n-000521d0: 7461 696e 6572 5479 7065 293a 0a20 2020 tainerType):. \n-000521e0: 205f 7479 7065 7374 7269 6e67 5f74 656d _typestring_tem\n-000521f0: 706c 6174 6520 3d20 2728 5f29 270a 2020 plate = '(_)'. \n-00052200: 2020 5f5f 736c 6f74 735f 5f20 3d20 2829 __slots__ = ()\n-00052210: 0a0a 2020 2020 6465 6620 6765 745f 7265 .. def get_re\n-00052220: 6164 6572 2873 656c 662c 2065 6e74 6572 ader(self, enter\n-00052230: 5f63 6f6e 7461 696e 6572 2c20 6578 6974 _container, exit\n-00052240: 5f63 6f6e 7461 696e 6572 293a 0a20 2020 _container):. \n-00052250: 2020 2020 2069 7465 6d5f 7265 6164 6572 item_reader\n-00052260: 7320 3d20 7475 706c 6528 6974 656d 5f74 s = tuple(item_t\n-00052270: 7970 652e 7265 6164 6572 2066 6f72 2069 ype.reader for i\n-00052280: 7465 6d5f 7479 7065 2069 6e20 7365 6c66 tem_type in self\n-00052290: 2e69 7465 6d5f 7479 7065 7329 0a0a 2020 .item_types).. \n-000522a0: 2020 2020 2020 6465 6620 6172 7261 795f def array_\n-000522b0: 7265 6164 6572 286d 6573 7361 6765 3a20 reader(message: \n-000522c0: 6c69 6273 7973 7465 6d64 2e73 645f 6275 libsystemd.sd_bu\n-000522d0: 735f 6d65 7373 6167 6529 202d 3e20 6f62 s_message) -> ob\n-000522e0: 6a65 6374 3a0a 2020 2020 2020 2020 2020 ject:. \n-000522f0: 2020 6966 2065 6e74 6572 5f63 6f6e 7461 if enter_conta\n-00052300: 696e 6572 286d 6573 7361 6765 2c20 302c iner(message, 0,\n-00052310: 204e 6f6e 6529 203c 3d20 303a 0a20 2020 None) <= 0:. \n-00052320: 2020 2020 2020 2020 2020 2020 2072 6169 rai\n-00052330: 7365 2053 746f 7049 7465 7261 7469 6f6e se StopIteration\n-00052340: 0a20 2020 2020 2020 2020 2020 2072 6573 . res\n-00052350: 756c 7420 3d20 7475 706c 6528 6974 656d ult = tuple(item\n-00052360: 5f72 6561 6465 7228 6d65 7373 6167 6529 _reader(message)\n-00052370: 2066 6f72 2069 7465 6d5f 7265 6164 6572 for item_reader\n-00052380: 2069 6e20 6974 656d 5f72 6561 6465 7273 in item_readers\n-00052390: 290a 2020 2020 2020 2020 2020 2020 6578 ). ex\n-000523a0: 6974 5f63 6f6e 7461 696e 6572 286d 6573 it_container(mes\n-000523b0: 7361 6765 290a 2020 2020 2020 2020 2020 sage). \n-000523c0: 2020 7265 7475 726e 2072 6573 756c 740a return result.\n-000523d0: 2020 2020 2020 2020 7265 7475 726e 2061 return a\n-000523e0: 7272 6179 5f72 6561 6465 720a 0a20 2020 rray_reader.. \n-000523f0: 2064 6566 2067 6574 5f77 7269 7465 7228 def get_writer(\n-00052400: 7365 6c66 2c20 722c 2074 7970 655f 636f self, r, type_co\n-00052410: 6e74 656e 7473 2c20 6f70 656e 5f63 6f6e ntents, open_con\n-00052420: 7461 696e 6572 2c20 636c 6f73 655f 636f tainer, close_co\n-00052430: 6e74 6169 6e65 7229 3a0a 2020 2020 2020 ntainer):. \n-00052440: 2020 6974 656d 5f77 7269 7465 7273 203d item_writers =\n-00052450: 2074 7570 6c65 2869 7465 6d5f 7479 7065 tuple(item_type\n-00052460: 2e77 7269 7465 7220 666f 7220 6974 656d .writer for item\n-00052470: 5f74 7970 6520 696e 2073 656c 662e 6974 _type in self.it\n-00052480: 656d 5f74 7970 6573 290a 0a20 2020 2020 em_types).. \n-00052490: 2020 2064 6566 2073 7472 7563 745f 7772 def struct_wr\n-000524a0: 6974 6572 286d 6573 7361 6765 3a20 6c69 iter(message: li\n-000524b0: 6273 7973 7465 6d64 2e73 645f 6275 735f bsystemd.sd_bus_\n-000524c0: 6d65 7373 6167 652c 2076 616c 7565 3a20 message, value: \n-000524d0: 6f62 6a65 6374 2920 2d3e 204e 6f6e 653a object) -> None:\n-000524e0: 0a20 2020 2020 2020 2020 2020 206e 5f69 . n_i\n-000524f0: 7465 6d73 203d 206c 656e 2876 616c 7565 tems = len(value\n-00052500: 2920 2023 2074 7970 653a 2069 676e 6f72 ) # type: ignor\n-00052510: 655b 6172 672d 7479 7065 5d20 2320 6361 e[arg-type] # ca\n-00052520: 6e20 7468 726f 7720 5479 7065 4572 726f n throw TypeErro\n-00052530: 720a 2020 2020 2020 2020 2020 2020 6966 r. if\n-00052540: 206e 5f69 7465 6d73 2021 3d20 6c65 6e28 n_items != len(\n-00052550: 6974 656d 5f77 7269 7465 7273 293a 0a20 item_writers):. \n-00052560: 2020 2020 2020 2020 2020 2020 2020 2072 r\n-00052570: 6169 7365 2054 7970 6545 7272 6f72 2866 aise TypeError(f\n-00052580: 2257 726f 6e67 206e 756d 6265 7273 206f \"Wrong numbers o\n-00052590: 6620 6974 656d 7320 287b 6e5f 6974 656d f items ({n_item\n-000525a0: 737d 2920 666f 7220 7374 7275 6374 7572 s}) for structur\n-000525b0: 6520 7479 7065 2027 7b73 656c 662e 7479 e type '{self.ty\n-000525c0: 7065 7374 7269 6e67 7d27 2229 0a20 2020 pestring}'\"). \n-000525d0: 2020 2020 2020 2020 206f 7065 6e5f 636f open_co\n-000525e0: 6e74 6169 6e65 7228 6d65 7373 6167 652c ntainer(message,\n-000525f0: 2072 2c20 7479 7065 5f63 6f6e 7465 6e74 r, type_content\n-00052600: 7329 0a20 2020 2020 2020 2020 2020 2066 s). f\n-00052610: 6f72 2069 7465 6d5f 7772 6974 6572 2c20 or item_writer, \n-00052620: 6974 656d 2069 6e20 7a69 7028 6974 656d item in zip(item\n-00052630: 5f77 7269 7465 7273 2c20 7661 6c75 6529 _writers, value)\n-00052640: 3a20 2023 2074 7970 653a 2069 676e 6f72 : # type: ignor\n-00052650: 655b 6361 6c6c 2d6f 7665 726c 6f61 645d e[call-overload]\n-00052660: 2023 2063 616e 2074 6872 6f77 2054 7970 # can throw Typ\n-00052670: 6545 7272 6f72 0a20 2020 2020 2020 2020 eError. \n-00052680: 2020 2020 2020 2069 7465 6d5f 7772 6974 item_writ\n-00052690: 6572 286d 6573 7361 6765 2c20 6974 656d er(message, item\n-000526a0: 290a 2020 2020 2020 2020 2020 2020 636c ). cl\n-000526b0: 6f73 655f 636f 6e74 6169 6e65 7228 6d65 ose_container(me\n-000526c0: 7373 6167 6529 0a20 2020 2020 2020 2072 ssage). r\n-000526d0: 6574 7572 6e20 7374 7275 6374 5f77 7269 eturn struct_wri\n-000526e0: 7465 720a 0a0a 636c 6173 7320 4469 6374 ter...class Dict\n-000526f0: 696f 6e61 7279 5479 7065 2843 6f6e 7461 ionaryType(Conta\n-00052700: 696e 6572 5479 7065 293a 0a20 2020 205f inerType):. _\n-00052710: 7479 7065 7374 7269 6e67 5f74 656d 706c typestring_templ\n-00052720: 6174 6520 3d20 2761 7b5f 7d27 0a20 2020 ate = 'a{_}'. \n-00052730: 205f 5f73 6c6f 7473 5f5f 203d 2028 290a __slots__ = ().\n-00052740: 0a20 2020 2064 6566 205f 5f69 6e69 745f . def __init_\n-00052750: 5f28 7365 6c66 2c20 6b65 795f 7479 7065 _(self, key_type\n-00052760: 3a20 5479 7065 2c20 7661 6c75 655f 7479 : Type, value_ty\n-00052770: 7065 3a20 5479 7065 293a 0a20 2020 2020 pe: Type):. \n-00052780: 2020 2061 7373 6572 7420 6973 696e 7374 assert isinst\n-00052790: 616e 6365 286b 6579 5f74 7970 652c 2042 ance(key_type, B\n-000527a0: 6173 6963 5479 7065 290a 2020 2020 2020 asicType). \n-000527b0: 2020 6974 656d 5f74 7970 6520 3d20 277b item_type = '{\n-000527c0: 2720 2b20 6b65 795f 7479 7065 2e74 7970 ' + key_type.typ\n-000527d0: 6573 7472 696e 6720 2b20 7661 6c75 655f estring + value_\n-000527e0: 7479 7065 2e74 7970 6573 7472 696e 6720 type.typestring \n-000527f0: 2b20 277d 270a 2020 2020 2020 2020 7375 + '}'. su\n-00052800: 7065 7228 292e 5f5f 696e 6974 5f5f 286b per().__init__(k\n-00052810: 6579 5f74 7970 652c 2076 616c 7565 5f74 ey_type, value_t\n-00052820: 7970 652c 0a20 2020 2020 2020 2020 2020 ype,. \n-00052830: 2020 2020 2020 2020 2020 2020 2020 6b65 ke\n-00052840: 795f 7265 6164 6572 3d6b 6579 5f74 7970 y_reader=key_typ\n-00052850: 652e 7265 6164 6572 2c20 6b65 795f 7772 e.reader, key_wr\n-00052860: 6974 6572 3d6b 6579 5f74 7970 652e 7772 iter=key_type.wr\n-00052870: 6974 6572 2c0a 2020 2020 2020 2020 2020 iter,. \n-00052880: 2020 2020 2020 2020 2020 2020 2020 2076 v\n-00052890: 616c 7565 5f72 6561 6465 723d 7661 6c75 alue_reader=valu\n-000528a0: 655f 7479 7065 2e72 6561 6465 722c 2076 e_type.reader, v\n-000528b0: 616c 7565 5f77 7269 7465 723d 7661 6c75 alue_writer=valu\n-000528c0: 655f 7479 7065 2e77 7269 7465 722c 0a20 e_type.writer,. \n-000528d0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000528e0: 2020 2020 2020 2020 6974 656d 5f74 7970 item_typ\n-000528f0: 653d 6374 7970 6573 2e63 5f63 6861 725f e=ctypes.c_char_\n-00052900: 7028 6974 656d 5f74 7970 652e 656e 636f p(item_type.enco\n-00052910: 6465 2827 6173 6369 6927 2929 290a 0a20 de('ascii'))).. \n-00052920: 2020 2064 6566 2067 6574 5f72 6561 6465 def get_reade\n-00052930: 7228 7365 6c66 2c20 656e 7465 725f 636f r(self, enter_co\n-00052940: 6e74 6169 6e65 722c 2065 7869 745f 636f ntainer, exit_co\n-00052950: 6e74 6169 6e65 722c 206b 6579 5f72 6561 ntainer, key_rea\n-00052960: 6465 722c 2076 616c 7565 5f72 6561 6465 der, value_reade\n-00052970: 7229 3a0a 2020 2020 2020 2020 6465 6620 r):. def \n-00052980: 6469 6374 5f72 6561 6465 7228 6d65 7373 dict_reader(mess\n-00052990: 6167 653a 206c 6962 7379 7374 656d 642e age: libsystemd.\n-000529a0: 7364 5f62 7573 5f6d 6573 7361 6765 2920 sd_bus_message) \n-000529b0: 2d3e 206f 626a 6563 743a 0a20 2020 2020 -> object:. \n-000529c0: 2020 2020 2020 2069 6620 656e 7465 725f if enter_\n-000529d0: 636f 6e74 6169 6e65 7228 6d65 7373 6167 container(messag\n-000529e0: 652c 2030 2c20 4e6f 6e65 2920 3c3d 2030 e, 0, None) <= 0\n-000529f0: 3a20 2020 2023 2061 7272 6179 0a20 2020 : # array. \n-00052a00: 2020 2020 2020 2020 2020 2020 2072 6169 rai\n-00052a10: 7365 2053 746f 7049 7465 7261 7469 6f6e se StopIteration\n-00052a20: 0a20 2020 2020 2020 2020 2020 2072 6573 . res\n-00052a30: 756c 7420 3d20 7b7d 0a20 2020 2020 2020 ult = {}. \n-00052a40: 2020 2020 2077 6869 6c65 2065 6e74 6572 while enter\n-00052a50: 5f63 6f6e 7461 696e 6572 286d 6573 7361 _container(messa\n-00052a60: 6765 2c20 302c 204e 6f6e 6529 203e 2030 ge, 0, None) > 0\n-00052a70: 3a20 2023 2065 6e74 7279 0a20 2020 2020 : # entry. \n-00052a80: 2020 2020 2020 2020 2020 206b 6579 203d key =\n-00052a90: 206b 6579 5f72 6561 6465 7228 6d65 7373 key_reader(mess\n-00052aa0: 6167 6529 0a20 2020 2020 2020 2020 2020 age). \n-00052ab0: 2020 2020 2076 616c 7565 203d 2076 616c value = val\n-00052ac0: 7565 5f72 6561 6465 7228 6d65 7373 6167 ue_reader(messag\n-00052ad0: 6529 0a20 2020 2020 2020 2020 2020 2020 e). \n-00052ae0: 2020 2072 6573 756c 745b 6b65 795d 203d result[key] =\n-00052af0: 2076 616c 7565 0a20 2020 2020 2020 2020 value. \n-00052b00: 2020 2020 2020 2065 7869 745f 636f 6e74 exit_cont\n-00052b10: 6169 6e65 7228 6d65 7373 6167 6529 0a20 ainer(message). \n-00052b20: 2020 2020 2020 2020 2020 2065 7869 745f exit_\n-00052b30: 636f 6e74 6169 6e65 7228 6d65 7373 6167 container(messag\n-00052b40: 6529 0a20 2020 2020 2020 2020 2020 2072 e). r\n-00052b50: 6574 7572 6e20 7265 7375 6c74 0a20 2020 eturn result. \n-00052b60: 2020 2020 2072 6574 7572 6e20 6469 6374 return dict\n-00052b70: 5f72 6561 6465 720a 0a20 2020 2064 6566 _reader.. def\n-00052b80: 2067 6574 5f77 7269 7465 7228 7365 6c66 get_writer(self\n-00052b90: 2c20 612c 2069 7465 6d5f 7479 7065 2c20 , a, item_type, \n-00052ba0: 652c 2074 7970 655f 636f 6e74 656e 7473 e, type_contents\n-00052bb0: 2c20 6f70 656e 5f63 6f6e 7461 696e 6572 , open_container\n-00052bc0: 2c20 636c 6f73 655f 636f 6e74 6169 6e65 , close_containe\n-00052bd0: 722c 206b 6579 5f77 7269 7465 722c 2076 r, key_writer, v\n-00052be0: 616c 7565 5f77 7269 7465 7229 3a0a 2020 alue_writer):. \n-00052bf0: 2020 2020 2020 6465 6620 6469 6374 5f77 def dict_w\n-00052c00: 7269 7465 7228 6d65 7373 6167 653a 206c riter(message: l\n-00052c10: 6962 7379 7374 656d 642e 7364 5f62 7573 ibsystemd.sd_bus\n-00052c20: 5f6d 6573 7361 6765 2c20 7661 6c75 653a _message, value:\n-00052c30: 206f 626a 6563 7429 202d 3e20 4e6f 6e65 object) -> None\n-00052c40: 3a0a 2020 2020 2020 2020 2020 2020 6f70 :. op\n-00052c50: 656e 5f63 6f6e 7461 696e 6572 286d 6573 en_container(mes\n-00052c60: 7361 6765 2c20 612c 2069 7465 6d5f 7479 sage, a, item_ty\n-00052c70: 7065 2920 2020 2020 2020 2020 2020 2020 pe) \n-00052c80: 2020 2020 2020 2023 2061 7272 6179 0a20 # array. \n-00052c90: 2020 2020 2020 2020 2020 2066 6f72 206b for k\n-00052ca0: 6579 2c20 7661 6c20 696e 2076 616c 7565 ey, val in value\n-00052cb0: 2e69 7465 6d73 2829 3a20 2023 2074 7970 .items(): # typ\n-00052cc0: 653a 2069 676e 6f72 655b 6174 7472 2d64 e: ignore[attr-d\n-00052cd0: 6566 696e 6564 5d20 2320 6361 6e20 7261 efined] # can ra\n-00052ce0: 6973 6520 4174 7472 6962 7574 6545 7272 ise AttributeErr\n-00052cf0: 6f72 0a20 2020 2020 2020 2020 2020 2020 or. \n-00052d00: 2020 206f 7065 6e5f 636f 6e74 6169 6e65 open_containe\n-00052d10: 7228 6d65 7373 6167 652c 2065 2c20 7479 r(message, e, ty\n-00052d20: 7065 5f63 6f6e 7465 6e74 7329 2020 2020 pe_contents) \n-00052d30: 2020 2020 2020 2020 2020 2320 656e 7472 # entr\n-00052d40: 790a 2020 2020 2020 2020 2020 2020 2020 y. \n-00052d50: 2020 6b65 795f 7772 6974 6572 286d 6573 key_writer(mes\n-00052d60: 7361 6765 2c20 6b65 7929 2020 2020 2020 sage, key) \n-00052d70: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00052d80: 2020 2020 2020 2020 2020 2023 206b 6579 # key\n-00052d90: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-00052da0: 2076 616c 7565 5f77 7269 7465 7228 6d65 value_writer(me\n-00052db0: 7373 6167 652c 2076 616c 2920 2020 2020 ssage, val) \n-00052dc0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00052dd0: 2020 2020 2020 2020 2020 2320 7661 6c75 # valu\n-00052de0: 650a 2020 2020 2020 2020 2020 2020 2020 e. \n-00052df0: 2020 636c 6f73 655f 636f 6e74 6169 6e65 close_containe\n-00052e00: 7228 6d65 7373 6167 6529 2020 2020 2020 r(message) \n-00052e10: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00052e20: 2020 2020 2020 2020 2023 2065 6e64 2065 # end e\n-00052e30: 6e74 7279 0a20 2020 2020 2020 2020 2020 ntry. \n-00052e40: 2063 6c6f 7365 5f63 6f6e 7461 696e 6572 close_container\n-00052e50: 286d 6573 7361 6765 2920 2020 2020 2020 (message) \n-00052e60: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00052e70: 2020 2020 2020 2020 2020 2320 656e 6420 # end \n-00052e80: 6172 7261 790a 2020 2020 2020 2020 7265 array. re\n-00052e90: 7475 726e 2064 6963 745f 7772 6974 6572 turn dict_writer\n-00052ea0: 0a0a 0a63 6c61 7373 2056 6172 6961 6e74 ...class Variant\n-00052eb0: 5479 7065 2854 7970 6529 3a0a 2020 2020 Type(Type):. \n-00052ec0: 5f5f 736c 6f74 735f 5f20 3d20 2829 0a0a __slots__ = ()..\n-00052ed0: 2020 2020 6465 6620 6765 745f 7265 6164 def get_read\n-00052ee0: 6572 2873 656c 662c 2065 6e74 6572 5f63 er(self, enter_c\n-00052ef0: 6f6e 7461 696e 6572 2c20 6578 6974 5f63 ontainer, exit_c\n-00052f00: 6f6e 7461 696e 6572 293a 0a20 2020 2020 ontainer):. \n-00052f10: 2020 2064 6566 2076 6172 6961 6e74 5f72 def variant_r\n-00052f20: 6561 6465 7228 6d65 7373 6167 653a 206c eader(message: l\n-00052f30: 6962 7379 7374 656d 642e 7364 5f62 7573 ibsystemd.sd_bus\n-00052f40: 5f6d 6573 7361 6765 2920 2d3e 206f 626a _message) -> obj\n-00052f50: 6563 743a 0a20 2020 2020 2020 2020 2020 ect:. \n-00052f60: 2069 6620 656e 7465 725f 636f 6e74 6169 if enter_contai\n-00052f70: 6e65 7228 6d65 7373 6167 652c 2030 2c20 ner(message, 0, \n-00052f80: 4e6f 6e65 2920 3c3d 2030 3a0a 2020 2020 None) <= 0:. \n-00052f90: 2020 2020 2020 2020 2020 2020 7261 6973 rais\n-00052fa0: 6520 5374 6f70 4974 6572 6174 696f 6e0a e StopIteration.\n-00052fb0: 2020 2020 2020 2020 2020 2020 7479 7065 type\n-00052fc0: 7374 7269 6e67 203d 206d 6573 7361 6765 string = message\n-00052fd0: 2e67 6574 5f73 6967 6e61 7475 7265 2846 .get_signature(F\n-00052fe0: 616c 7365 290a 2020 2020 2020 2020 2020 alse). \n-00052ff0: 2020 7479 7065 5f2c 203d 2066 726f 6d5f type_, = from_\n-00053000: 7369 676e 6174 7572 6528 7479 7065 7374 signature(typest\n-00053010: 7269 6e67 290a 2020 2020 2020 2020 2020 ring). \n-00053020: 2020 7661 6c75 6520 3d20 7479 7065 5f2e value = type_.\n-00053030: 7265 6164 6572 286d 6573 7361 6765 290a reader(message).\n-00053040: 2020 2020 2020 2020 2020 2020 6578 6974 exit\n-00053050: 5f63 6f6e 7461 696e 6572 286d 6573 7361 _container(messa\n-00053060: 6765 290a 2020 2020 2020 2020 2020 2020 ge). \n-00053070: 7265 7475 726e 2056 6172 6961 6e74 2876 return Variant(v\n-00053080: 616c 7565 2c20 7479 7065 5f29 0a20 2020 alue, type_). \n-00053090: 2020 2020 2072 6574 7572 6e20 7661 7269 return vari\n-000530a0: 616e 745f 7265 6164 6572 0a0a 2020 2020 ant_reader.. \n-000530b0: 6465 6620 6765 745f 7772 6974 6572 2873 def get_writer(s\n-000530c0: 656c 662c 206f 7065 6e5f 636f 6e74 6169 elf, open_contai\n-000530d0: 6e65 722c 2063 6c6f 7365 5f63 6f6e 7461 ner, close_conta\n-000530e0: 696e 6572 2c20 7629 3a0a 2020 2020 2020 iner, v):. \n-000530f0: 2020 6465 6620 7661 7269 616e 745f 7772 def variant_wr\n-00053100: 6974 6572 286d 6573 7361 6765 3a20 6c69 iter(message: li\n-00053110: 6273 7973 7465 6d64 2e73 645f 6275 735f bsystemd.sd_bus_\n-00053120: 6d65 7373 6167 652c 2076 616c 7565 3a20 message, value: \n-00053130: 6f62 6a65 6374 2920 2d3e 204e 6f6e 653a object) -> None:\n-00053140: 0a20 2020 2020 2020 2020 2020 2069 6620 . if \n-00053150: 6973 696e 7374 616e 6365 2876 616c 7565 isinstance(value\n-00053160: 2c20 5661 7269 616e 7429 3a0a 2020 2020 , Variant):. \n-00053170: 2020 2020 2020 2020 2020 2020 7479 7065 type\n-00053180: 5f20 3d20 7661 6c75 652e 7479 7065 0a20 _ = value.type. \n-00053190: 2020 2020 2020 2020 2020 2020 2020 2063 c\n-000531a0: 6f6e 7465 6e74 7320 3d20 7661 6c75 652e ontents = value.\n-000531b0: 7661 6c75 650a 2020 2020 2020 2020 2020 value. \n-000531c0: 2020 656c 7365 3a0a 2020 2020 2020 2020 else:. \n-000531d0: 2020 2020 2020 2020 7472 793a 0a20 2020 try:. \n-000531e0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000531f0: 2074 7970 655f 2c20 3d20 6672 6f6d 5f73 type_, = from_s\n-00053200: 6967 6e61 7475 7265 2876 616c 7565 5b27 ignature(value['\n-00053210: 7427 5d29 2020 2320 7479 7065 3a20 6967 t']) # type: ig\n-00053220: 6e6f 7265 5b69 6e64 6578 5d20 2320 6361 nore[index] # ca\n-00053230: 6e20 7468 726f 7720 5479 7065 4572 726f n throw TypeErro\n-00053240: 720a 2020 2020 2020 2020 2020 2020 2020 r. \n-00053250: 2020 2020 2020 636f 6e74 656e 7473 203d contents =\n-00053260: 2076 616c 7565 5b27 7627 5d20 2023 2074 value['v'] # t\n-00053270: 7970 653a 2069 676e 6f72 655b 696e 6465 ype: ignore[inde\n-00053280: 785d 2023 2063 616e 2074 6872 6f77 2054 x] # can throw T\n-00053290: 7970 6545 7272 6f72 0a20 2020 2020 2020 ypeError. \n-000532a0: 2020 2020 2020 2020 2065 7863 6570 7420 except \n-000532b0: 4b65 7945 7272 6f72 2061 7320 6578 633a KeyError as exc:\n-000532c0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-000532d0: 2020 2020 2072 6169 7365 2054 7970 6545 raise TypeE\n-000532e0: 7272 6f72 2822 2776 2720 6361 6e20 656e rror(\"'v' can en\n-000532f0: 636f 6465 2056 6172 6961 6e74 206f 626a code Variant obj\n-00053300: 6563 7473 2c20 6f72 206d 6170 7069 6e67 ects, or mapping\n-00053310: 7320 7769 7468 2027 7427 2061 6e64 2027 s with 't' and '\n-00053320: 7627 206b 6579 7322 2920 6672 6f6d 2065 v' keys\") from e\n-00053330: 7863 0a0a 2020 2020 2020 2020 2020 2020 xc.. \n-00053340: 6f70 656e 5f63 6f6e 7461 696e 6572 286d open_container(m\n-00053350: 6573 7361 6765 2c20 762c 2074 7970 655f essage, v, type_\n-00053360: 2e62 7974 6573 5f74 7970 6573 7472 696e .bytes_typestrin\n-00053370: 6729 0a20 2020 2020 2020 2020 2020 2074 g). t\n-00053380: 7970 655f 2e77 7269 7465 7228 6d65 7373 ype_.writer(mess\n-00053390: 6167 652c 2063 6f6e 7465 6e74 7329 0a20 age, contents). \n-000533a0: 2020 2020 2020 2020 2020 2063 6c6f 7365 close\n-000533b0: 5f63 6f6e 7461 696e 6572 286d 6573 7361 _container(messa\n-000533c0: 6765 290a 2020 2020 2020 2020 7265 7475 ge). retu\n-000533d0: 726e 2076 6172 6961 6e74 5f77 7269 7465 rn variant_write\n-000533e0: 720a 0a0a 636c 6173 7320 5661 7269 616e r...class Varian\n-000533f0: 743a 0a20 2020 205f 5f73 6c6f 7473 5f5f t:. __slots__\n-00053400: 203d 2027 7479 7065 272c 2027 7661 6c75 = 'type', 'valu\n-00053410: 6527 0a20 2020 2074 7970 653a 2054 7970 e'. type: Typ\n-00053420: 650a 2020 2020 7661 6c75 653a 206f 626a e. value: obj\n-00053430: 6563 740a 0a20 2020 2064 6566 205f 5f69 ect.. def __i\n-00053440: 6e69 745f 5f28 7365 6c66 2c20 7661 6c75 nit__(self, valu\n-00053450: 653a 206f 626a 6563 742c 2068 696e 743a e: object, hint:\n-00053460: 206f 626a 6563 7420 3d20 4e6f 6e65 293a object = None):\n-00053470: 0a20 2020 2020 2020 2069 6620 6973 696e . if isin\n-00053480: 7374 616e 6365 2868 696e 742c 2054 7970 stance(hint, Typ\n-00053490: 6529 3a0a 2020 2020 2020 2020 2020 2020 e):. \n-000534a0: 7365 6c66 2e74 7970 6520 3d20 6869 6e74 self.type = hint\n-000534b0: 0a20 2020 2020 2020 2065 6c69 6620 6973 . elif is\n-000534c0: 696e 7374 616e 6365 2868 696e 742c 2073 instance(hint, s\n-000534d0: 7472 293a 0a20 2020 2020 2020 2020 2020 tr):. \n-000534e0: 2073 656c 662e 7479 7065 2c20 3d20 6672 self.type, = fr\n-000534f0: 6f6d 5f73 6967 6e61 7475 7265 2868 696e om_signature(hin\n-00053500: 7429 0a20 2020 2020 2020 2065 6c73 653a t). else:\n-00053510: 0a20 2020 2020 2020 2020 2020 2073 656c . sel\n-00053520: 662e 7479 7065 203d 2066 726f 6d5f 616e f.type = from_an\n-00053530: 6e6f 7461 7469 6f6e 2868 696e 7420 6f72 notation(hint or\n-00053540: 2076 616c 7565 2e5f 5f63 6c61 7373 5f5f value.__class__\n-00053550: 290a 2020 2020 2020 2020 7365 6c66 2e76 ). self.v\n-00053560: 616c 7565 203d 2076 616c 7565 0a0a 2020 alue = value.. \n-00053570: 2020 6465 6620 5f5f 7265 7072 5f5f 2873 def __repr__(s\n-00053580: 656c 6629 202d 3e20 7374 723a 0a20 2020 elf) -> str:. \n-00053590: 2020 2020 2072 6574 7572 6e20 6622 7379 return f\"sy\n-000535a0: 7374 656d 645f 6374 7970 6573 2e56 6172 stemd_ctypes.Var\n-000535b0: 6961 6e74 287b 7365 6c66 2e76 616c 7565 iant({self.value\n-000535c0: 7d2c 2027 7b73 656c 662e 7479 7065 2e74 }, '{self.type.t\n-000535d0: 7970 6573 7472 696e 677d 2729 220a 0a20 ypestring}')\".. \n-000535e0: 2020 2064 6566 205f 5f65 715f 5f28 7365 def __eq__(se\n-000535f0: 6c66 2c20 6f74 6865 723a 206f 626a 6563 lf, other: objec\n-00053600: 7429 202d 3e20 626f 6f6c 3a0a 2020 2020 t) -> bool:. \n-00053610: 2020 2020 6966 2069 7369 6e73 7461 6e63 if isinstanc\n-00053620: 6528 6f74 6865 722c 2056 6172 6961 6e74 e(other, Variant\n-00053630: 293a 0a20 2020 2020 2020 2020 2020 2072 ):. r\n-00053640: 6574 7572 6e20 7365 6c66 2e74 7970 6520 eturn self.type \n-00053650: 3d3d 206f 7468 6572 2e74 7970 6520 616e == other.type an\n-00053660: 6420 7365 6c66 2e76 616c 7565 203d 3d20 d self.value == \n-00053670: 6f74 6865 722e 7661 6c75 650a 2020 2020 other.value. \n-00053680: 2020 2020 656c 6966 2069 7369 6e73 7461 elif isinsta\n-00053690: 6e63 6528 6f74 6865 722c 2064 6963 7429 nce(other, dict)\n-000536a0: 3a0a 2020 2020 2020 2020 2020 2020 7265 :. re\n-000536b0: 7475 726e 2028 7365 6c66 2e74 7970 652c turn (self.type,\n-000536c0: 2920 3d3d 2066 726f 6d5f 7369 676e 6174 ) == from_signat\n-000536d0: 7572 6528 6f74 6865 725b 2774 275d 2920 ure(other['t']) \n-000536e0: 616e 6420 7365 6c66 2e76 616c 7565 203d and self.value =\n-000536f0: 3d20 6f74 6865 725b 2776 275d 0a20 2020 = other['v']. \n-00053700: 2020 2020 2065 6c73 653a 0a20 2020 2020 else:. \n-00053710: 2020 2020 2020 2072 6574 7572 6e20 4661 return Fa\n-00053720: 6c73 650a 0a20 2020 2064 6566 205f 5f68 lse.. def __h\n-00053730: 6173 685f 5f28 7365 6c66 2920 2d3e 2069 ash__(self) -> i\n-00053740: 6e74 3a0a 2020 2020 2020 2020 7265 7475 nt:. retu\n-00053750: 726e 2068 6173 6828 7365 6c66 2e74 7970 rn hash(self.typ\n-00053760: 6529 205e 2068 6173 6828 7365 6c66 2e76 e) ^ hash(self.v\n-00053770: 616c 7565 290a 0a0a 636c 6173 7320 4275 alue)...class Bu\n-00053780: 7354 7970 6528 456e 756d 293a 0a20 2020 sType(Enum):. \n-00053790: 2062 6f6f 6c65 616e 203d 2041 6e6e 6f74 boolean = Annot\n-000537a0: 6174 6564 5b62 6f6f 6c2c 2046 6978 6564 ated[bool, Fixed\n-000537b0: 5479 7065 2827 6227 2c20 6374 7970 6573 Type('b', ctypes\n-000537c0: 2e63 5f69 6e74 2c20 6374 7970 6573 2e63 .c_int, ctypes.c\n-000537d0: 5f69 6e74 2e5f 5f62 6f6f 6c5f 5f29 5d0a _int.__bool__)].\n-000537e0: 2020 2020 6279 7465 203d 2041 6e6e 6f74 byte = Annot\n-000537f0: 6174 6564 5b69 6e74 2c20 4669 7865 6454 ated[int, FixedT\n-00053800: 7970 6528 2779 272c 2063 7479 7065 732e ype('y', ctypes.\n-00053810: 635f 7569 6e74 3829 5d0a 2020 2020 696e c_uint8)]. in\n-00053820: 7431 3620 3d20 416e 6e6f 7461 7465 645b t16 = Annotated[\n-00053830: 696e 742c 2046 6978 6564 5479 7065 2827 int, FixedType('\n-00053840: 6e27 2c20 6374 7970 6573 2e63 5f69 6e74 n', ctypes.c_int\n-00053850: 3136 295d 0a20 2020 2075 696e 7431 3620 16)]. uint16 \n-00053860: 3d20 416e 6e6f 7461 7465 645b 696e 742c = Annotated[int,\n-00053870: 2046 6978 6564 5479 7065 2827 7127 2c20 FixedType('q', \n-00053880: 6374 7970 6573 2e63 5f75 696e 7431 3629 ctypes.c_uint16)\n-00053890: 5d0a 2020 2020 696e 7433 3220 3d20 416e ]. int32 = An\n-000538a0: 6e6f 7461 7465 645b 696e 742c 2046 6978 notated[int, Fix\n-000538b0: 6564 5479 7065 2827 6927 2c20 6374 7970 edType('i', ctyp\n-000538c0: 6573 2e63 5f69 6e74 3332 295d 0a20 2020 es.c_int32)]. \n-000538d0: 2075 696e 7433 3220 3d20 416e 6e6f 7461 uint32 = Annota\n-000538e0: 7465 645b 696e 742c 2046 6978 6564 5479 ted[int, FixedTy\n-000538f0: 7065 2827 7527 2c20 6374 7970 6573 2e63 pe('u', ctypes.c\n-00053900: 5f75 696e 7433 3229 5d0a 2020 2020 696e _uint32)]. in\n-00053910: 7436 3420 3d20 416e 6e6f 7461 7465 645b t64 = Annotated[\n-00053920: 696e 742c 2046 6978 6564 5479 7065 2827 int, FixedType('\n-00053930: 7827 2c20 6374 7970 6573 2e63 5f69 6e74 x', ctypes.c_int\n-00053940: 3634 295d 0a20 2020 2075 696e 7436 3420 64)]. uint64 \n-00053950: 3d20 416e 6e6f 7461 7465 645b 696e 742c = Annotated[int,\n-00053960: 2046 6978 6564 5479 7065 2827 7427 2c20 FixedType('t', \n-00053970: 6374 7970 6573 2e63 5f75 696e 7436 3429 ctypes.c_uint64)\n-00053980: 5d0a 2020 2020 646f 7562 6c65 203d 2041 ]. double = A\n-00053990: 6e6e 6f74 6174 6564 5b66 6c6f 6174 2c20 nnotated[float, \n-000539a0: 4669 7865 6454 7970 6528 2764 272c 2063 FixedType('d', c\n-000539b0: 7479 7065 732e 635f 646f 7562 6c65 295d types.c_double)]\n-000539c0: 0a20 2020 2073 7472 696e 6720 3d20 416e . string = An\n-000539d0: 6e6f 7461 7465 645b 7374 722c 2053 7472 notated[str, Str\n-000539e0: 696e 674c 696b 6554 7970 6528 2773 2729 ingLikeType('s')\n-000539f0: 5d0a 2020 2020 6f62 6a65 6374 7061 7468 ]. objectpath\n-00053a00: 203d 2041 6e6e 6f74 6174 6564 5b73 7472 = Annotated[str\n-00053a10: 2c20 5374 7269 6e67 4c69 6b65 5479 7065 , StringLikeType\n-00053a20: 2827 6f27 2c20 6973 5f6f 626a 6563 745f ('o', is_object_\n-00053a30: 7061 7468 295d 0a20 2020 2073 6967 6e61 path)]. signa\n-00053a40: 7475 7265 203d 2041 6e6e 6f74 6174 6564 ture = Annotated\n-00053a50: 5b73 7472 2c20 5374 7269 6e67 4c69 6b65 [str, StringLike\n-00053a60: 5479 7065 2827 6727 2c20 6973 5f73 6967 Type('g', is_sig\n-00053a70: 6e61 7475 7265 295d 0a20 2020 2062 7974 nature)]. byt\n-00053a80: 6573 7472 696e 6720 3d20 416e 6e6f 7461 estring = Annota\n-00053a90: 7465 645b 6279 7465 732c 2042 7974 6573 ted[bytes, Bytes\n-00053aa0: 7472 696e 6754 7970 6528 2761 7927 295d tringType('ay')]\n-00053ab0: 0a20 2020 2076 6172 6961 6e74 203d 2041 . variant = A\n-00053ac0: 6e6e 6f74 6174 6564 5b64 6963 742c 2056 nnotated[dict, V\n-00053ad0: 6172 6961 6e74 5479 7065 2827 7627 295d ariantType('v')]\n-00053ae0: 0a0a 0a23 206d 7970 7920 6765 7473 2063 ...# mypy gets c\n-00053af0: 6f6e 6675 7365 6420 6279 2065 6e75 6d73 onfused by enums\n-00053b00: 2c20 736f 206a 7573 7420 7573 6520 416e , so just use An\n-00053b10: 790a 5f62 6173 655f 6571 7569 7661 6c65 y._base_equivale\n-00053b20: 6e63 655f 6d61 703a 2044 6963 745b 7479 nce_map: Dict[ty\n-00053b30: 7065 2c20 416e 795d 203d 207b 0a20 2020 pe, Any] = {. \n-00053b40: 2062 6f6f 6c3a 2042 7573 5479 7065 2e62 bool: BusType.b\n-00053b50: 6f6f 6c65 616e 2c0a 2020 2020 6279 7465 oolean,. byte\n-00053b60: 733a 2042 7573 5479 7065 2e62 7974 6573 s: BusType.bytes\n-00053b70: 7472 696e 672c 0a20 2020 2069 6e74 3a20 tring,. int: \n-00053b80: 4275 7354 7970 652e 696e 7433 322c 0a20 BusType.int32,. \n-00053b90: 2020 2073 7472 3a20 4275 7354 7970 652e str: BusType.\n-00053ba0: 7374 7269 6e67 2c0a 2020 2020 5661 7269 string,. Vari\n-00053bb0: 616e 743a 2042 7573 5479 7065 2e76 6172 ant: BusType.var\n-00053bc0: 6961 6e74 2c0a 7d0a 0a5f 6661 6374 6f72 iant,.}.._factor\n-00053bd0: 795f 6d61 703a 2044 6963 745b 6f62 6a65 y_map: Dict[obje\n-00053be0: 6374 2c20 4361 6c6c 6162 6c65 5b2e 2e2e ct, Callable[...\n-00053bf0: 2c20 5479 7065 5d5d 203d 207b 0a20 2020 , Type]] = {. \n-00053c00: 2064 6963 743a 2044 6963 7469 6f6e 6172 dict: Dictionar\n-00053c10: 7954 7970 652c 2044 6963 743a 2044 6963 yType, Dict: Dic\n-00053c20: 7469 6f6e 6172 7954 7970 652c 0a20 2020 tionaryType,. \n-00053c30: 206c 6973 743a 2041 7272 6179 5479 7065 list: ArrayType\n-00053c40: 2c20 4c69 7374 3a20 4172 7261 7954 7970 , List: ArrayTyp\n-00053c50: 652c 0a20 2020 2074 7570 6c65 3a20 5374 e,. tuple: St\n-00053c60: 7275 6374 5479 7065 2c20 5475 706c 653a ructType, Tuple:\n-00053c70: 2053 7472 7563 7454 7970 652c 0a7d 0a0a StructType,.}..\n-00053c80: 0a40 6675 6e63 746f 6f6c 732e 6c72 755f .@functools.lru_\n-00053c90: 6361 6368 6528 290a 6465 6620 6672 6f6d cache().def from\n-00053ca0: 5f61 6e6e 6f74 6174 696f 6e28 616e 6e6f _annotation(anno\n-00053cb0: 7461 7469 6f6e 3a20 556e 696f 6e5b 7374 tation: Union[st\n-00053cc0: 722c 2074 7970 652c 2042 7573 5479 7065 r, type, BusType\n-00053cd0: 5d29 202d 3e20 5479 7065 3a0a 2020 2020 ]) -> Type:. \n-00053ce0: 2320 5369 6d70 6c65 2050 7974 686f 6e20 # Simple Python \n-00053cf0: 7479 7065 730a 2020 2020 6966 2069 7369 types. if isi\n-00053d00: 6e73 7461 6e63 6528 616e 6e6f 7461 7469 nstance(annotati\n-00053d10: 6f6e 2c20 7374 7229 3a0a 2020 2020 2020 on, str):. \n-00053d20: 2020 7479 7065 7320 3d20 6672 6f6d 5f73 types = from_s\n-00053d30: 6967 6e61 7475 7265 2861 6e6e 6f74 6174 ignature(annotat\n-00053d40: 696f 6e29 0a20 2020 2020 2020 2069 6620 ion). if \n-00053d50: 6c65 6e28 7479 7065 7329 2021 3d20 313a len(types) != 1:\n-00053d60: 0a20 2020 2020 2020 2020 2020 2072 6169 . rai\n-00053d70: 7365 2054 7970 6545 7272 6f72 2866 2253 se TypeError(f\"S\n-00053d80: 6967 6e61 7475 7265 2027 7b61 6e6e 6f74 ignature '{annot\n-00053d90: 6174 696f 6e7d 2720 696e 7661 6c69 6420 ation}' invalid \n-00053da0: 6173 2061 2074 7970 6520 7374 7269 6e67 as a type string\n-00053db0: 2022 0a20 2020 2020 2020 2020 2020 2020 \". \n-00053dc0: 2020 2020 2020 2020 2020 2020 2020 2066 f\n-00053dd0: 2262 6563 6175 7365 2069 7420 6465 7363 \"because it desc\n-00053de0: 7269 6265 7320 7b6c 656e 2874 7970 6573 ribes {len(types\n-00053df0: 297d 2074 7970 6573 2c20 6e6f 7420 6f6e )} types, not on\n-00053e00: 652e 2229 0a20 2020 2020 2020 2072 6574 e.\"). ret\n-00053e10: 7572 6e20 7479 7065 735b 305d 0a0a 2020 urn types[0].. \n-00053e20: 2020 6966 2069 7369 6e73 7461 6e63 6528 if isinstance(\n-00053e30: 616e 6e6f 7461 7469 6f6e 2c20 7479 7065 annotation, type\n-00053e40: 293a 0a20 2020 2020 2020 2061 6e6e 6f74 ):. annot\n-00053e50: 6174 696f 6e20 3d20 5f62 6173 655f 6571 ation = _base_eq\n-00053e60: 7569 7661 6c65 6e63 655f 6d61 702e 6765 uivalence_map.ge\n-00053e70: 7428 616e 6e6f 7461 7469 6f6e 2c20 616e t(annotation, an\n-00053e80: 6e6f 7461 7469 6f6e 290a 0a20 2020 2023 notation).. #\n-00053e90: 204f 7572 206f 776e 2042 7573 5479 7065 Our own BusType\n-00053ea0: 2074 7970 6573 0a20 2020 2069 6620 6973 types. if is\n-00053eb0: 696e 7374 616e 6365 2861 6e6e 6f74 6174 instance(annotat\n-00053ec0: 696f 6e2c 2042 7573 5479 7065 293a 0a20 ion, BusType):. \n-00053ed0: 2020 2020 2020 2062 7573 5f74 7970 6520 bus_type \n-00053ee0: 3d20 7479 7069 6e67 2e67 6574 5f61 7267 = typing.get_arg\n-00053ef0: 7328 616e 6e6f 7461 7469 6f6e 2e76 616c s(annotation.val\n-00053f00: 7565 295b 315d 0a20 2020 2020 2020 2061 ue)[1]. a\n-00053f10: 7373 6572 7420 6973 696e 7374 616e 6365 ssert isinstance\n-00053f20: 2862 7573 5f74 7970 652c 2054 7970 6529 (bus_type, Type)\n-00053f30: 0a20 2020 2020 2020 2072 6574 7572 6e20 . return \n-00053f40: 6275 735f 7479 7065 0a0a 2020 2020 2320 bus_type.. # \n-00053f50: 436f 6e74 6169 6e65 7220 7479 7065 730a Container types.\n-00053f60: 2020 2020 7472 793a 0a20 2020 2020 2020 try:. \n-00053f70: 2066 6163 746f 7279 203d 205f 6661 6374 factory = _fact\n-00053f80: 6f72 795f 6d61 705b 7479 7069 6e67 2e67 ory_map[typing.g\n-00053f90: 6574 5f6f 7269 6769 6e28 616e 6e6f 7461 et_origin(annota\n-00053fa0: 7469 6f6e 295d 0a20 2020 2020 2020 2061 tion)]. a\n-00053fb0: 7267 7320 3d20 5b66 726f 6d5f 616e 6e6f rgs = [from_anno\n-00053fc0: 7461 7469 6f6e 2861 7267 2920 666f 7220 tation(arg) for \n-00053fd0: 6172 6720 696e 2074 7970 696e 672e 6765 arg in typing.ge\n-00053fe0: 745f 6172 6773 2861 6e6e 6f74 6174 696f t_args(annotatio\n-00053ff0: 6e29 5d0a 2020 2020 2020 2020 7265 7475 n)]. retu\n-00054000: 726e 2066 6163 746f 7279 282a 6172 6773 rn factory(*args\n-00054010: 290a 2020 2020 6578 6365 7074 2028 4173 ). except (As\n-00054020: 7365 7274 696f 6e45 7272 6f72 2c20 4174 sertionError, At\n-00054030: 7472 6962 7574 6545 7272 6f72 2c20 4b65 tributeError, Ke\n-00054040: 7945 7272 6f72 2c20 5479 7065 4572 726f yError, TypeErro\n-00054050: 7229 3a0a 2020 2020 2020 2020 7261 6973 r):. rais\n-00054060: 6520 5479 7065 4572 726f 7228 6622 4361 e TypeError(f\"Ca\n-00054070: 6e6e 6f74 2069 6e74 6572 7072 6574 207b nnot interpret {\n-00054080: 616e 6e6f 7461 7469 6f6e 7d20 6173 2061 annotation} as a\n-00054090: 2064 6275 7320 7479 7065 2229 2066 726f dbus type\") fro\n-000540a0: 6d20 4e6f 6e65 0a0a 0a5f 6261 7365 5f74 m None..._base_t\n-000540b0: 7970 6573 7472 696e 675f 6d61 703a 2044 ypestring_map: D\n-000540c0: 6963 745b 7374 722c 2054 7970 655d 203d ict[str, Type] =\n-000540d0: 207b 0a20 2020 2062 7573 7479 7065 2e74 {. bustype.t\n-000540e0: 7970 6573 7472 696e 673a 2062 7573 7479 ypestring: busty\n-000540f0: 7065 2066 6f72 2062 7573 7479 7065 2069 pe for bustype i\n-00054100: 6e20 2866 726f 6d5f 616e 6e6f 7461 7469 n (from_annotati\n-00054110: 6f6e 2865 6e74 7279 2920 666f 7220 656e on(entry) for en\n-00054120: 7472 7920 696e 2042 7573 5479 7065 290a try in BusType).\n-00054130: 7d0a 0a0a 4066 756e 6374 6f6f 6c73 2e6c }...@functools.l\n-00054140: 7275 5f63 6163 6865 2829 0a64 6566 2066 ru_cache().def f\n-00054150: 726f 6d5f 7369 676e 6174 7572 6528 7369 rom_signature(si\n-00054160: 676e 6174 7572 653a 2073 7472 2920 2d3e gnature: str) ->\n-00054170: 2054 7570 6c65 5b54 7970 652c 202e 2e2e Tuple[Type, ...\n-00054180: 5d3a 0a20 2020 2073 7461 636b 203d 206c ]:. stack = l\n-00054190: 6973 7428 7265 7665 7273 6564 2873 6967 ist(reversed(sig\n-000541a0: 6e61 7475 7265 2929 0a0a 2020 2020 6465 nature)).. de\n-000541b0: 6620 6765 745f 6f6e 6528 2920 2d3e 2054 f get_one() -> T\n-000541c0: 7970 653a 0a20 2020 2020 2020 2066 6972 ype:. fir\n-000541d0: 7374 203d 2073 7461 636b 2e70 6f70 2829 st = stack.pop()\n-000541e0: 0a20 2020 2020 2020 2069 6620 6669 7273 . if firs\n-000541f0: 7420 3d3d 2027 6127 3a0a 2020 2020 2020 t == 'a':. \n-00054200: 2020 2020 2020 6966 2073 7461 636b 5b2d if stack[-\n-00054210: 315d 203d 3d20 2779 273a 0a20 2020 2020 1] == 'y':. \n-00054220: 2020 2020 2020 2020 2020 2066 6972 7374 first\n-00054230: 202b 3d20 7374 6163 6b2e 706f 7028 290a += stack.pop().\n-00054240: 2020 2020 2020 2020 2020 2020 656c 6966 elif\n-00054250: 2073 7461 636b 5b2d 315d 203d 3d20 277b stack[-1] == '{\n-00054260: 273a 0a20 2020 2020 2020 2020 2020 2020 ':. \n-00054270: 2020 2073 7461 636b 2e70 6f70 2829 0a20 stack.pop(). \n-00054280: 2020 2020 2020 2020 2020 2020 2020 2072 r\n-00054290: 6574 7572 6e20 4469 6374 696f 6e61 7279 eturn Dictionary\n-000542a0: 5479 7065 282a 6765 745f 7365 7665 7261 Type(*get_severa\n-000542b0: 6c28 277d 2729 290a 2020 2020 2020 2020 l('}')). \n-000542c0: 2020 2020 656c 7365 3a0a 2020 2020 2020 else:. \n-000542d0: 2020 2020 2020 2020 2020 7265 7475 726e return\n-000542e0: 2041 7272 6179 5479 7065 2867 6574 5f6f ArrayType(get_o\n-000542f0: 6e65 2829 290a 2020 2020 2020 2020 656c ne()). el\n-00054300: 6966 2066 6972 7374 203d 3d20 2728 273a if first == '(':\n-00054310: 0a20 2020 2020 2020 2020 2020 2072 6574 . ret\n-00054320: 7572 6e20 5374 7275 6374 5479 7065 282a urn StructType(*\n-00054330: 6765 745f 7365 7665 7261 6c28 2729 2729 get_several(')')\n-00054340: 290a 0a20 2020 2020 2020 2072 6574 7572 ).. retur\n-00054350: 6e20 5f62 6173 655f 7479 7065 7374 7269 n _base_typestri\n-00054360: 6e67 5f6d 6170 5b66 6972 7374 5d0a 0a20 ng_map[first].. \n-00054370: 2020 2064 6566 2067 6574 5f73 6576 6572 def get_sever\n-00054380: 616c 2865 6e64 3a20 7374 7229 202d 3e20 al(end: str) -> \n-00054390: 4974 6572 6162 6c65 5b54 7970 655d 3a0a Iterable[Type]:.\n-000543a0: 2020 2020 2020 2020 7969 656c 6420 6765 yield ge\n-000543b0: 745f 6f6e 6528 290a 2020 2020 2020 2020 t_one(). \n-000543c0: 7768 696c 6520 7374 6163 6b5b 2d31 5d20 while stack[-1] \n-000543d0: 213d 2065 6e64 3a0a 2020 2020 2020 2020 != end:. \n-000543e0: 2020 2020 7969 656c 6420 6765 745f 6f6e yield get_on\n-000543f0: 6528 290a 2020 2020 2020 2020 7374 6163 e(). stac\n-00054400: 6b2e 706f 7028 290a 0a20 2020 2064 6566 k.pop().. def\n-00054410: 2067 6574 5f61 6c6c 2829 202d 3e20 4974 get_all() -> It\n-00054420: 6572 6162 6c65 5b54 7970 655d 3a0a 2020 erable[Type]:. \n-00054430: 2020 2020 2020 7768 696c 6520 7374 6163 while stac\n-00054440: 6b3a 0a20 2020 2020 2020 2020 2020 2079 k:. y\n-00054450: 6965 6c64 2067 6574 5f6f 6e65 2829 0a0a ield get_one()..\n-00054460: 2020 2020 7472 793a 0a20 2020 2020 2020 try:. \n-00054470: 2072 6574 7572 6e20 7475 706c 6528 6765 return tuple(ge\n-00054480: 745f 616c 6c28 2929 0a20 2020 2065 7863 t_all()). exc\n-00054490: 6570 7420 2841 7373 6572 7469 6f6e 4572 ept (AssertionEr\n-000544a0: 726f 722c 2049 6e64 6578 4572 726f 722c ror, IndexError,\n-000544b0: 204b 6579 4572 726f 7229 2061 7320 6578 KeyError) as ex\n-000544c0: 633a 0a20 2020 2020 2020 2072 6169 7365 c:. raise\n-000544d0: 2054 7970 6545 7272 6f72 2866 2249 6e76 TypeError(f\"Inv\n-000544e0: 616c 6964 2074 7970 6520 7369 676e 6174 alid type signat\n-000544f0: 7572 6520 277b 7369 676e 6174 7572 657d ure '{signature}\n-00054500: 2722 2920 6672 6f6d 2065 7863 0a0a 0a63 '\") from exc...c\n-00054510: 6c61 7373 204d 6573 7361 6765 5479 7065 lass MessageType\n-00054520: 3a0a 2020 2020 6974 656d 5f74 7970 6573 :. item_types\n-00054530: 3a20 5365 7175 656e 6365 5b54 7970 655d : Sequence[Type]\n-00054540: 0a20 2020 2074 7970 6573 7472 696e 6773 . typestrings\n-00054550: 3a20 4c69 7374 5b73 7472 5d0a 2020 2020 : List[str]. \n-00054560: 7369 676e 6174 7572 653a 2073 7472 0a0a signature: str..\n-00054570: 2020 2020 6465 6620 5f5f 696e 6974 5f5f def __init__\n-00054580: 2873 656c 662c 2069 7465 6d5f 7479 7065 (self, item_type\n-00054590: 733a 2053 6571 7565 6e63 655b 556e 696f s: Sequence[Unio\n-000545a0: 6e5b 7374 722c 2074 7970 652c 2042 7573 n[str, type, Bus\n-000545b0: 5479 7065 5d5d 293a 0a20 2020 2020 2020 Type]]):. \n-000545c0: 2073 656c 662e 6974 656d 5f74 7970 6573 self.item_types\n-000545d0: 203d 205b 6672 6f6d 5f61 6e6e 6f74 6174 = [from_annotat\n-000545e0: 696f 6e28 6974 656d 5f74 7970 6529 2066 ion(item_type) f\n-000545f0: 6f72 2069 7465 6d5f 7479 7065 2069 6e20 or item_type in \n-00054600: 6974 656d 5f74 7970 6573 5d0a 2020 2020 item_types]. \n-00054610: 2020 2020 7365 6c66 2e74 7970 6573 7472 self.typestr\n-00054620: 696e 6773 203d 205b 6974 656d 5f74 7970 ings = [item_typ\n-00054630: 652e 7479 7065 7374 7269 6e67 2066 6f72 e.typestring for\n-00054640: 2069 7465 6d5f 7479 7065 2069 6e20 7365 item_type in se\n-00054650: 6c66 2e69 7465 6d5f 7479 7065 735d 0a20 lf.item_types]. \n-00054660: 2020 2020 2020 2073 656c 662e 7369 676e self.sign\n-00054670: 6174 7572 6520 3d20 2727 2e6a 6f69 6e28 ature = ''.join(\n-00054680: 7365 6c66 2e74 7970 6573 7472 696e 6773 self.typestrings\n-00054690: 290a 0a20 2020 2064 6566 2077 7269 7465 ).. def write\n-000546a0: 2873 656c 662c 206d 6573 7361 6765 3a20 (self, message: \n-000546b0: 6c69 6273 7973 7465 6d64 2e73 645f 6275 libsystemd.sd_bu\n-000546c0: 735f 6d65 7373 6167 652c 202a 6974 656d s_message, *item\n-000546d0: 733a 206f 626a 6563 7429 202d 3e20 4e6f s: object) -> No\n-000546e0: 6e65 3a0a 2020 2020 2020 2020 6173 7365 ne:. asse\n-000546f0: 7274 206c 656e 2869 7465 6d73 2920 3d3d rt len(items) ==\n-00054700: 206c 656e 2873 656c 662e 6974 656d 5f74 len(self.item_t\n-00054710: 7970 6573 290a 2020 2020 2020 2020 666f ypes). fo\n-00054720: 7220 6974 656d 5f74 7970 652c 2069 7465 r item_type, ite\n-00054730: 6d20 696e 207a 6970 2873 656c 662e 6974 m in zip(self.it\n-00054740: 656d 5f74 7970 6573 2c20 6974 656d 7329 em_types, items)\n-00054750: 3a0a 2020 2020 2020 2020 2020 2020 6974 :. it\n-00054760: 656d 5f74 7970 652e 7772 6974 6572 286d em_type.writer(m\n-00054770: 6573 7361 6765 2c20 6974 656d 290a 0a20 essage, item).. \n-00054780: 2020 2064 6566 2072 6561 6428 7365 6c66 def read(self\n-00054790: 2c20 6d65 7373 6167 653a 206c 6962 7379 , message: libsy\n-000547a0: 7374 656d 642e 7364 5f62 7573 5f6d 6573 stemd.sd_bus_mes\n-000547b0: 7361 6765 2920 2d3e 204f 7074 696f 6e61 sage) -> Optiona\n-000547c0: 6c5b 5475 706c 655b 6f62 6a65 6374 2c20 l[Tuple[object, \n-000547d0: 2e2e 2e5d 5d3a 0a20 2020 2020 2020 2069 ...]]:. i\n-000547e0: 6620 6e6f 7420 6d65 7373 6167 652e 6861 f not message.ha\n-000547f0: 735f 7369 676e 6174 7572 6528 7365 6c66 s_signature(self\n-00054800: 2e73 6967 6e61 7475 7265 293a 0a20 2020 .signature):. \n-00054810: 2020 2020 2020 2020 2072 6574 7572 6e20 return \n-00054820: 4e6f 6e65 0a20 2020 2020 2020 2072 6574 None. ret\n-00054830: 7572 6e20 7475 706c 6528 6974 656d 5f74 urn tuple(item_t\n-00054840: 7970 652e 7265 6164 6572 286d 6573 7361 ype.reader(messa\n-00054850: 6765 2920 666f 7220 6974 656d 5f74 7970 ge) for item_typ\n-00054860: 6520 696e 2073 656c 662e 6974 656d 5f74 e in self.item_t\n-00054870: 7970 6573 290a 0a20 2020 2064 6566 205f ypes).. def _\n-00054880: 5f6c 656e 5f5f 2873 656c 6629 202d 3e20 _len__(self) -> \n-00054890: 696e 743a 0a20 2020 2020 2020 2072 6574 int:. ret\n-000548a0: 7572 6e20 6c65 6e28 7365 6c66 2e69 7465 urn len(self.ite\n-000548b0: 6d5f 7479 7065 7329 0a0a 0a63 6c61 7373 m_types)...class\n-000548c0: 204a 534f 4e45 6e63 6f64 6572 286a 736f JSONEncoder(jso\n-000548d0: 6e2e 4a53 4f4e 456e 636f 6465 7229 3a0a n.JSONEncoder):.\n-000548e0: 2020 2020 6465 6620 6465 6661 756c 7428 def default(\n-000548f0: 7365 6c66 2c20 6f62 6a3a 206f 626a 6563 self, obj: objec\n-00054900: 7429 202d 3e20 6f62 6a65 6374 3a0a 2020 t) -> object:. \n-00054910: 2020 2020 2020 6966 2069 7369 6e73 7461 if isinsta\n-00054920: 6e63 6528 6f62 6a2c 2056 6172 6961 6e74 nce(obj, Variant\n-00054930: 293a 0a20 2020 2020 2020 2020 2020 2072 ):. r\n-00054940: 6574 7572 6e20 7b22 7422 3a20 6f62 6a2e eturn {\"t\": obj.\n-00054950: 7479 7065 2e74 7970 6573 7472 696e 672c type.typestring,\n-00054960: 2022 7622 3a20 6f62 6a2e 7661 6c75 657d \"v\": obj.value}\n-00054970: 0a20 2020 2020 2020 2065 6c69 6620 6973 . elif is\n-00054980: 696e 7374 616e 6365 286f 626a 2c20 6279 instance(obj, by\n-00054990: 7465 7329 3a0a 2020 2020 2020 2020 2020 tes):. \n-000549a0: 2020 7265 7475 726e 2062 696e 6173 6369 return binasci\n-000549b0: 692e 6232 615f 6261 7365 3634 286f 626a i.b2a_base64(obj\n-000549c0: 2c20 6e65 776c 696e 653d 4661 6c73 6529 , newline=False)\n-000549d0: 2e64 6563 6f64 6528 2761 7363 6969 2729 .decode('ascii')\n-000549e0: 0a20 2020 2020 2020 2072 6574 7572 6e20 . return \n-000549f0: 7375 7065 7228 292e 6465 6661 756c 7428 super().default(\n-00054a00: 6f62 6a29 0a27 2727 2c0a 2020 2763 6f63 obj).''',. 'coc\n-00054a10: 6b70 6974 2f5f 7665 6e64 6f72 2f66 6572 kpit/_vendor/fer\n-00054a20: 6e79 2f73 7368 5f61 736b 7061 7373 2e70 ny/ssh_askpass.p\n-00054a30: 7927 3a20 6272 2727 2769 6d70 6f72 7420 y': br'''import \n-00054a40: 6c6f 6767 696e 670a 696d 706f 7274 2072 logging.import r\n-00054a50: 650a 6672 6f6d 2074 7970 696e 6720 696d e.from typing im\n-00054a60: 706f 7274 2043 6c61 7373 5661 722c 204d port ClassVar, M\n-00054a70: 6174 6368 2c20 5365 7175 656e 6365 0a0a atch, Sequence..\n-00054a80: 6672 6f6d 202e 696e 7465 7261 6374 696f from .interactio\n-00054a90: 6e5f 6167 656e 7420 696d 706f 7274 2041 n_agent import A\n-00054aa0: 736b 7061 7373 4861 6e64 6c65 720a 0a6c skpassHandler..l\n-00054ab0: 6f67 6765 7220 3d20 6c6f 6767 696e 672e ogger = logging.\n-00054ac0: 6765 744c 6f67 6765 7228 5f5f 6e61 6d65 getLogger(__name\n-00054ad0: 5f5f 290a 0a0a 636c 6173 7320 4173 6b70 __)...class Askp\n-00054ae0: 6173 7350 726f 6d70 743a 0a20 2020 2022 assPrompt:. \"\n-00054af0: 2222 416e 2061 736b 7061 7373 2070 726f \"\"An askpass pro\n-00054b00: 6d70 7420 7265 7375 6c74 696e 6720 6672 mpt resulting fr\n-00054b10: 6f6d 2061 2063 616c 6c20 746f 2066 6572 om a call to fer\n-00054b20: 6e79 2d61 736b 7061 7373 2e0a 0a20 2020 ny-askpass... \n-00054b30: 2020 2073 7464 6572 723a 2074 6865 2063 stderr: the c\n-00054b40: 6f6e 7465 6e74 7320 6f66 2073 7464 6572 ontents of stder\n-00054b50: 7220 6672 6f6d 2062 6566 6f72 6520 6665 r from before fe\n-00054b60: 726e 792d 6173 6b70 6173 7320 7761 7320 rny-askpass was \n-00054b70: 6361 6c6c 6564 2e0a 2020 2020 2020 2020 called.. \n-00054b80: 2020 2020 2020 4c69 6b65 6c79 2072 656c Likely rel\n-00054b90: 6174 6564 2074 6f20 7072 6576 696f 7573 ated to previous\n-00054ba0: 2066 6169 6c65 6420 6f70 6572 6174 696f failed operatio\n-00054bb0: 6e73 2e0a 2020 2020 2020 6d65 7373 6167 ns.. messag\n-00054bc0: 6573 3a20 616c 6c20 6275 7420 7468 6520 es: all but the \n-00054bd0: 6c61 7374 206c 696e 6520 6f66 2074 6865 last line of the\n-00054be0: 2070 726f 6d70 7420 6173 2068 616e 6465 prompt as hande\n-00054bf0: 6420 746f 2066 6572 6e79 2d61 736b 7061 d to ferny-askpa\n-00054c00: 7373 2e0a 2020 2020 2020 2020 2020 2020 ss.. \n-00054c10: 2020 2020 5573 7561 6c6c 7920 636f 6e74 Usually cont\n-00054c20: 6169 6e73 2063 6f6e 7465 7874 2061 626f ains context abo\n-00054c30: 7574 2074 6865 2071 7565 7374 696f 6e2e ut the question.\n-00054c40: 0a20 2020 2020 2070 726f 6d70 743a 2074 . prompt: t\n-00054c50: 6865 206c 6173 7420 6c69 6e65 2068 616e he last line han\n-00054c60: 6465 6420 746f 2066 6572 6e79 2d61 736b ded to ferny-ask\n-00054c70: 7061 7373 2e20 2054 6865 2070 726f 6d70 pass. The promp\n-00054c80: 7420 6974 7365 6c66 2e0a 2020 2020 2222 t itself.. \"\"\n-00054c90: 220a 2020 2020 7374 6465 7272 3a20 7374 \". stderr: st\n-00054ca0: 720a 2020 2020 6d65 7373 6167 6573 3a20 r. messages: \n-00054cb0: 7374 720a 2020 2020 7072 6f6d 7074 3a20 str. prompt: \n-00054cc0: 7374 720a 0a20 2020 2064 6566 205f 5f69 str.. def __i\n-00054cd0: 6e69 745f 5f28 7365 6c66 2c20 7072 6f6d nit__(self, prom\n-00054ce0: 7074 3a20 7374 722c 206d 6573 7361 6765 pt: str, message\n-00054cf0: 733a 2073 7472 2c20 7374 6465 7272 3a20 s: str, stderr: \n-00054d00: 7374 7229 202d 3e20 4e6f 6e65 3a0a 2020 str) -> None:. \n-00054d10: 2020 2020 2020 7365 6c66 2e73 7464 6572 self.stder\n-00054d20: 7220 3d20 7374 6465 7272 0a20 2020 2020 r = stderr. \n-00054d30: 2020 2073 656c 662e 6d65 7373 6167 6573 self.messages\n-00054d40: 203d 206d 6573 7361 6765 730a 2020 2020 = messages. \n-00054d50: 2020 2020 7365 6c66 2e70 726f 6d70 7420 self.prompt \n-00054d60: 3d20 7072 6f6d 7074 0a0a 2020 2020 6465 = prompt.. de\n-00054d70: 6620 7265 706c 7928 7365 6c66 2c20 7265 f reply(self, re\n-00054d80: 7370 6f6e 7365 3a20 7374 7229 202d 3e20 sponse: str) -> \n-00054d90: 4e6f 6e65 3a0a 2020 2020 2020 2020 7061 None:. pa\n-00054da0: 7373 0a0a 2020 2020 6465 6620 636c 6f73 ss.. def clos\n-00054db0: 6528 7365 6c66 2920 2d3e 204e 6f6e 653a e(self) -> None:\n-00054dc0: 0a20 2020 2020 2020 2070 6173 730a 0a20 . pass.. \n-00054dd0: 2020 2061 7379 6e63 2064 6566 2068 616e async def han\n-00054de0: 646c 655f 7669 6128 7365 6c66 2c20 7265 dle_via(self, re\n-00054df0: 7370 6f6e 6465 723a 2027 5373 6841 736b sponder: 'SshAsk\n-00054e00: 7061 7373 5265 7370 6f6e 6465 7227 2920 passResponder') \n-00054e10: 2d3e 204e 6f6e 653a 0a20 2020 2020 2020 -> None:. \n-00054e20: 2074 7279 3a0a 2020 2020 2020 2020 2020 try:. \n-00054e30: 2020 7265 7370 6f6e 7365 203d 2061 7761 response = awa\n-00054e40: 6974 2073 656c 662e 6469 7370 6174 6368 it self.dispatch\n-00054e50: 2872 6573 706f 6e64 6572 290a 2020 2020 (responder). \n-00054e60: 2020 2020 2020 2020 6966 2072 6573 706f if respo\n-00054e70: 6e73 6520 6973 206e 6f74 204e 6f6e 653a nse is not None:\n-00054e80: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-00054e90: 2073 656c 662e 7265 706c 7928 7265 7370 self.reply(resp\n-00054ea0: 6f6e 7365 290a 2020 2020 2020 2020 6669 onse). fi\n-00054eb0: 6e61 6c6c 793a 0a20 2020 2020 2020 2020 nally:. \n-00054ec0: 2020 2073 656c 662e 636c 6f73 6528 290a self.close().\n-00054ed0: 0a20 2020 2061 7379 6e63 2064 6566 2064 . async def d\n-00054ee0: 6973 7061 7463 6828 7365 6c66 2c20 7265 ispatch(self, re\n-00054ef0: 7370 6f6e 6465 723a 2027 5373 6841 736b sponder: 'SshAsk\n-00054f00: 7061 7373 5265 7370 6f6e 6465 7227 2920 passResponder') \n-00054f10: 2d3e 2027 7374 7220 7c20 4e6f 6e65 273a -> 'str | None':\n-00054f20: 0a20 2020 2020 2020 2072 6574 7572 6e20 . return \n-00054f30: 6177 6169 7420 7265 7370 6f6e 6465 722e await responder.\n-00054f40: 646f 5f70 726f 6d70 7428 7365 6c66 290a do_prompt(self).\n-00054f50: 0a0a 636c 6173 7320 5353 4841 736b 7061 ..class SSHAskpa\n-00054f60: 7373 5072 6f6d 7074 2841 736b 7061 7373 ssPrompt(Askpass\n-00054f70: 5072 6f6d 7074 293a 0a20 2020 2023 2054 Prompt):. # T\n-00054f80: 6865 2076 616c 6964 2061 6e73 7765 7273 he valid answers\n-00054f90: 2074 6f20 7072 6f6d 7074 7320 6f66 2074 to prompts of t\n-00054fa0: 6869 7320 7479 7065 2e20 2049 6620 7468 his type. If th\n-00054fb0: 6973 2069 7320 4e6f 6e65 2074 6865 6e20 is is None then \n-00054fc0: 616e 790a 2020 2020 2320 616e 7377 6572 any. # answer\n-00054fd0: 2069 7320 7065 726d 6974 7465 642e 2020 is permitted. \n-00054fe0: 4966 2069 7427 7320 6120 7365 7175 656e If it's a sequen\n-00054ff0: 6365 2074 6865 6e20 6f6e 6c79 2061 6e73 ce then only ans\n-00055000: 7765 7273 2066 726f 6d20 7468 650a 2020 wers from the. \n-00055010: 2020 2320 7365 7175 656e 6365 2061 7265 # sequence are\n-00055020: 2070 6572 6d69 7474 6564 2e20 2049 6620 permitted. If \n-00055030: 6974 2773 2061 6e20 656d 7074 7920 7365 it's an empty se\n-00055040: 7175 656e 6365 2c20 7468 656e 206e 6f20 quence, then no \n-00055050: 616e 7377 6572 2069 730a 2020 2020 2320 answer is. # \n-00055060: 7065 726d 6974 7465 6420 2869 653a 2074 permitted (ie: t\n-00055070: 6865 2061 736b 7061 7373 2063 616c 6c62 he askpass callb\n-00055080: 6163 6b20 7368 6f75 6c64 206e 6576 6572 ack should never\n-00055090: 2072 6574 7572 6e29 2e0a 2020 2020 616e return).. an\n-000550a0: 7377 6572 733a 2027 436c 6173 7356 6172 swers: 'ClassVar\n-000550b0: 5b53 6571 7565 6e63 655b 7374 725d 207c [Sequence[str] |\n-000550c0: 204e 6f6e 655d 2720 3d20 4e6f 6e65 0a0a None]' = None..\n-000550d0: 2020 2020 2320 5061 7474 6572 6e73 2074 # Patterns t\n-000550e0: 6f20 6361 7074 7572 652e 2020 605f 7061 o capture. `_pa\n-000550f0: 7474 6572 6e60 202a 6d75 7374 2a20 6d61 ttern` *must* ma\n-00055100: 7463 682e 0a20 2020 205f 7061 7474 6572 tch.. _patter\n-00055110: 6e3a 2043 6c61 7373 5661 725b 7374 725d n: ClassVar[str]\n-00055120: 0a20 2020 2023 2060 5f65 7874 7261 5f70 . # `_extra_p\n-00055130: 6174 7465 726e 7360 2063 616e 2066 696c atterns` can fil\n-00055140: 6c20 696e 2065 7874 7261 2063 6c61 7373 l in extra class\n-00055150: 2061 7474 7269 6275 7465 7320 6966 2074 attributes if t\n-00055160: 6865 7920 6d61 7463 682e 0a20 2020 205f hey match.. _\n-00055170: 6578 7472 615f 7061 7474 6572 6e73 3a20 extra_patterns: \n-00055180: 436c 6173 7356 6172 5b53 6571 7565 6e63 ClassVar[Sequenc\n-00055190: 655b 7374 725d 5d20 3d20 2829 0a0a 2020 e[str]] = ().. \n-000551a0: 2020 6465 6620 5f5f 696e 6974 5f5f 2873 def __init__(s\n-000551b0: 656c 662c 2070 726f 6d70 743a 2073 7472 elf, prompt: str\n-000551c0: 2c20 6d65 7373 6167 6573 3a20 7374 722c , messages: str,\n-000551d0: 2073 7464 6572 723a 2073 7472 2c20 6d61 stderr: str, ma\n-000551e0: 7463 683a 204d 6174 6368 2920 2d3e 204e tch: Match) -> N\n-000551f0: 6f6e 653a 0a20 2020 2020 2020 2073 7570 one:. sup\n-00055200: 6572 2829 2e5f 5f69 6e69 745f 5f28 7072 er().__init__(pr\n-00055210: 6f6d 7074 2c20 6d65 7373 6167 6573 2c20 ompt, messages, \n-00055220: 7374 6465 7272 290a 2020 2020 2020 2020 stderr). \n-00055230: 7365 6c66 2e5f 5f64 6963 745f 5f2e 7570 self.__dict__.up\n-00055240: 6461 7465 286d 6174 6368 2e67 726f 7570 date(match.group\n-00055250: 6469 6374 2829 290a 0a20 2020 2020 2020 dict()).. \n-00055260: 2066 6f72 2070 6174 7465 726e 2069 6e20 for pattern in \n-00055270: 7365 6c66 2e5f 6578 7472 615f 7061 7474 self._extra_patt\n-00055280: 6572 6e73 3a0a 2020 2020 2020 2020 2020 erns:. \n-00055290: 2020 6578 7472 615f 6d61 7463 6820 3d20 extra_match = \n-000552a0: 7265 2e73 6561 7263 6828 7769 7468 5f68 re.search(with_h\n-000552b0: 656c 7065 7273 2870 6174 7465 726e 292c elpers(pattern),\n-000552c0: 206d 6573 7361 6765 732c 2072 652e 4d29 messages, re.M)\n-000552d0: 0a20 2020 2020 2020 2020 2020 2069 6620 . if \n-000552e0: 6578 7472 615f 6d61 7463 6820 6973 206e extra_match is n\n-000552f0: 6f74 204e 6f6e 653a 0a20 2020 2020 2020 ot None:. \n-00055300: 2020 2020 2020 2020 2073 656c 662e 5f5f self.__\n-00055310: 6469 6374 5f5f 2e75 7064 6174 6528 6578 dict__.update(ex\n-00055320: 7472 615f 6d61 7463 682e 6772 6f75 7064 tra_match.groupd\n-00055330: 6963 7428 2929 0a0a 0a23 2053 7065 6369 ict())...# Speci\n-00055340: 6669 6320 7072 6f6d 7074 730a 4845 4c50 fic prompts.HELP\n-00055350: 4552 5320 3d20 7b0a 2020 2020 2225 7b61 ERS = {. \"%{a\n-00055360: 6c67 6f72 6974 686d 7d22 3a20 7222 283f lgorithm}\": r\"(?\n-00055370: 503c 616c 676f 7269 7468 6d3e 5c62 5b2d P<algorithm>\\b[-\n-00055380: 5c77 5d2b 5c62 2922 2c0a 2020 2020 2225 \\w]+\\b)\",. \"%\n-00055390: 7b66 696c 656e 616d 657d 223a 2072 2228 {filename}\": r\"(\n-000553a0: 3f50 3c66 696c 656e 616d 653e 2e2b 2922 ?P<filename>.+)\"\n-000553b0: 2c0a 2020 2020 2225 7b66 696e 6765 7270 ,. \"%{fingerp\n-000553c0: 7269 6e74 7d22 3a20 7222 283f 503c 6669 rint}\": r\"(?P<fi\n-000553d0: 6e67 6572 7072 696e 743e 5348 4132 3536 ngerprint>SHA256\n-000553e0: 3a5b 302d 3941 2d5a 612d 7a2b 2f5d 7b34 :[0-9A-Za-z+/]{4\n-000553f0: 337d 2922 2c0a 2020 2020 2225 7b68 6f73 3})\",. \"%{hos\n-00055400: 746e 616d 657d 223a 2072 2228 3f50 3c68 tname}\": r\"(?P<h\n-00055410: 6f73 746e 616d 653e 5b5e 2040 275d 2b29 ostname>[^ @']+)\n-00055420: 222c 0a20 2020 2022 257b 706b 6373 3131 \",. \"%{pkcs11\n-00055430: 5f69 647d 223a 2072 2228 3f50 3c70 6b63 _id}\": r\"(?P<pkc\n-00055440: 7331 315f 6964 3e2e 2b29 222c 0a20 2020 s11_id>.+)\",. \n-00055450: 2022 257b 7573 6572 6e61 6d65 7d22 3a20 \"%{username}\": \n-00055460: 7222 283f 503c 7573 6572 6e61 6d65 3e5b r\"(?P<username>[\n-00055470: 5e20 4027 5d2b 2922 2c0a 7d0a 0a0a 636c ^ @']+)\",.}...cl\n-00055480: 6173 7320 5373 6850 6173 7377 6f72 6450 ass SshPasswordP\n-00055490: 726f 6d70 7428 5353 4841 736b 7061 7373 rompt(SSHAskpass\n-000554a0: 5072 6f6d 7074 293a 0a20 2020 205f 7061 Prompt):. _pa\n-000554b0: 7474 6572 6e20 3d20 7222 257b 7573 6572 ttern = r\"%{user\n-000554c0: 6e61 6d65 7d40 257b 686f 7374 6e61 6d65 name}@%{hostname\n-000554d0: 7d27 7320 7061 7373 776f 7264 3a20 220a }'s password: \".\n-000554e0: 2020 2020 7573 6572 6e61 6d65 3a20 2773 username: 's\n-000554f0: 7472 207c 204e 6f6e 6527 203d 204e 6f6e tr | None' = Non\n-00055500: 650a 2020 2020 686f 7374 6e61 6d65 3a20 e. hostname: \n-00055510: 2773 7472 207c 204e 6f6e 6527 203d 204e 'str | None' = N\n-00055520: 6f6e 650a 0a20 2020 2061 7379 6e63 2064 one.. async d\n-00055530: 6566 2064 6973 7061 7463 6828 7365 6c66 ef dispatch(self\n-00055540: 2c20 7265 7370 6f6e 6465 723a 2027 5373 , responder: 'Ss\n-00055550: 6841 736b 7061 7373 5265 7370 6f6e 6465 hAskpassResponde\n-00055560: 7227 2920 2d3e 2027 7374 7220 7c20 4e6f r') -> 'str | No\n-00055570: 6e65 273a 0a20 2020 2020 2020 2072 6574 ne':. ret\n-00055580: 7572 6e20 6177 6169 7420 7265 7370 6f6e urn await respon\n-00055590: 6465 722e 646f 5f70 6173 7377 6f72 645f der.do_password_\n-000555a0: 7072 6f6d 7074 2873 656c 6629 0a0a 0a63 prompt(self)...c\n-000555b0: 6c61 7373 2053 7368 5061 7373 7068 7261 lass SshPassphra\n-000555c0: 7365 5072 6f6d 7074 2853 5348 4173 6b70 sePrompt(SSHAskp\n-000555d0: 6173 7350 726f 6d70 7429 3a0a 2020 2020 assPrompt):. \n-000555e0: 5f70 6174 7465 726e 203d 2072 2245 6e74 _pattern = r\"Ent\n-000555f0: 6572 2070 6173 7370 6872 6173 6520 666f er passphrase fo\n-00055600: 7220 6b65 7920 2725 7b66 696c 656e 616d r key '%{filenam\n-00055610: 657d 273a 2022 0a20 2020 2066 696c 656e e}': \". filen\n-00055620: 616d 653a 2073 7472 0a0a 2020 2020 6173 ame: str.. as\n-00055630: 796e 6320 6465 6620 6469 7370 6174 6368 ync def dispatch\n-00055640: 2873 656c 662c 2072 6573 706f 6e64 6572 (self, responder\n-00055650: 3a20 2753 7368 4173 6b70 6173 7352 6573 : 'SshAskpassRes\n-00055660: 706f 6e64 6572 2729 202d 3e20 2773 7472 ponder') -> 'str\n-00055670: 207c 204e 6f6e 6527 3a0a 2020 2020 2020 | None':. \n-00055680: 2020 7265 7475 726e 2061 7761 6974 2072 return await r\n-00055690: 6573 706f 6e64 6572 2e64 6f5f 7061 7373 esponder.do_pass\n-000556a0: 7068 7261 7365 5f70 726f 6d70 7428 7365 phrase_prompt(se\n-000556b0: 6c66 290a 0a0a 636c 6173 7320 5373 6846 lf)...class SshF\n-000556c0: 4944 4f50 494e 5072 6f6d 7074 2853 5348 IDOPINPrompt(SSH\n-000556d0: 4173 6b70 6173 7350 726f 6d70 7429 3a0a AskpassPrompt):.\n-000556e0: 2020 2020 5f70 6174 7465 726e 203d 2072 _pattern = r\n-000556f0: 2245 6e74 6572 2050 494e 2066 6f72 2025 \"Enter PIN for %\n-00055700: 7b61 6c67 6f72 6974 686d 7d20 6b65 7920 {algorithm} key \n-00055710: 257b 6669 6c65 6e61 6d65 7d3a 2022 0a20 %{filename}: \". \n-00055720: 2020 2061 6c67 6f72 6974 686d 3a20 7374 algorithm: st\n-00055730: 720a 2020 2020 6669 6c65 6e61 6d65 3a20 r. filename: \n-00055740: 7374 720a 0a20 2020 2061 7379 6e63 2064 str.. async d\n-00055750: 6566 2064 6973 7061 7463 6828 7365 6c66 ef dispatch(self\n-00055760: 2c20 7265 7370 6f6e 6465 723a 2027 5373 , responder: 'Ss\n-00055770: 6841 736b 7061 7373 5265 7370 6f6e 6465 hAskpassResponde\n-00055780: 7227 2920 2d3e 2027 7374 7220 207c 204e r') -> 'str | N\n-00055790: 6f6e 6527 3a0a 2020 2020 2020 2020 7265 one':. re\n-000557a0: 7475 726e 2061 7761 6974 2072 6573 706f turn await respo\n-000557b0: 6e64 6572 2e64 6f5f 6669 646f 5f70 696e nder.do_fido_pin\n-000557c0: 5f70 726f 6d70 7428 7365 6c66 290a 0a0a _prompt(self)...\n-000557d0: 636c 6173 7320 5373 6846 4944 4f55 7365 class SshFIDOUse\n-000557e0: 7250 7265 7365 6e63 6550 726f 6d70 7428 rPresencePrompt(\n-000557f0: 5353 4841 736b 7061 7373 5072 6f6d 7074 SSHAskpassPrompt\n-00055800: 293a 0a20 2020 205f 7061 7474 6572 6e20 ):. _pattern \n-00055810: 3d20 7222 436f 6e66 6972 6d20 7573 6572 = r\"Confirm user\n-00055820: 2070 7265 7365 6e63 6520 666f 7220 6b65 presence for ke\n-00055830: 7920 257b 616c 676f 7269 7468 6d7d 2025 y %{algorithm} %\n-00055840: 7b66 696e 6765 7270 7269 6e74 7d22 0a20 {fingerprint}\". \n-00055850: 2020 2061 6e73 7765 7273 203d 2028 290a answers = ().\n-00055860: 2020 2020 616c 676f 7269 7468 6d3a 2073 algorithm: s\n-00055870: 7472 0a20 2020 2066 696e 6765 7270 7269 tr. fingerpri\n-00055880: 6e74 3a20 7374 720a 0a20 2020 2061 7379 nt: str.. asy\n-00055890: 6e63 2064 6566 2064 6973 7061 7463 6828 nc def dispatch(\n-000558a0: 7365 6c66 2c20 7265 7370 6f6e 6465 723a self, responder:\n-000558b0: 2027 5373 6841 736b 7061 7373 5265 7370 'SshAskpassResp\n-000558c0: 6f6e 6465 7227 2920 2d3e 2027 7374 7220 onder') -> 'str \n-000558d0: 7c20 4e6f 6e65 273a 0a20 2020 2020 2020 | None':. \n-000558e0: 2072 6574 7572 6e20 6177 6169 7420 7265 return await re\n-000558f0: 7370 6f6e 6465 722e 646f 5f66 6964 6f5f sponder.do_fido_\n-00055900: 7573 6572 5f70 7265 7365 6e63 655f 7072 user_presence_pr\n-00055910: 6f6d 7074 2873 656c 6629 0a0a 0a63 6c61 ompt(self)...cla\n-00055920: 7373 2053 7368 504b 4353 3131 5049 4e50 ss SshPKCS11PINP\n-00055930: 726f 6d70 7428 5353 4841 736b 7061 7373 rompt(SSHAskpass\n-00055940: 5072 6f6d 7074 293a 0a20 2020 205f 7061 Prompt):. _pa\n-00055950: 7474 6572 6e20 3d20 7222 456e 7465 7220 ttern = r\"Enter \n-00055960: 5049 4e20 666f 7220 2725 7b70 6b63 7331 PIN for '%{pkcs1\n-00055970: 315f 6964 7d27 3a20 220a 2020 2020 706b 1_id}': \". pk\n-00055980: 6373 3131 5f69 643a 2073 7472 0a0a 2020 cs11_id: str.. \n-00055990: 2020 6173 796e 6320 6465 6620 6469 7370 async def disp\n-000559a0: 6174 6368 2873 656c 662c 2072 6573 706f atch(self, respo\n-000559b0: 6e64 6572 3a20 2753 7368 4173 6b70 6173 nder: 'SshAskpas\n-000559c0: 7352 6573 706f 6e64 6572 2729 202d 3e20 sResponder') -> \n-000559d0: 2773 7472 207c 204e 6f6e 6527 3a0a 2020 'str | None':. \n-000559e0: 2020 2020 2020 7265 7475 726e 2061 7761 return awa\n-000559f0: 6974 2072 6573 706f 6e64 6572 2e64 6f5f it responder.do_\n-00055a00: 706b 6373 3131 5f70 696e 5f70 726f 6d70 pkcs11_pin_promp\n-00055a10: 7428 7365 6c66 290a 0a0a 636c 6173 7320 t(self)...class \n-00055a20: 5373 6848 6f73 744b 6579 5072 6f6d 7074 SshHostKeyPrompt\n-00055a30: 2853 5348 4173 6b70 6173 7350 726f 6d70 (SSHAskpassPromp\n-00055a40: 7429 3a0a 2020 2020 5f70 6174 7465 726e t):. _pattern\n-00055a50: 203d 2072 2241 7265 2079 6f75 2073 7572 = r\"Are you sur\n-00055a60: 6520 796f 7520 7761 6e74 2074 6f20 636f e you want to co\n-00055a70: 6e74 696e 7565 2063 6f6e 6e65 6374 696e ntinue connectin\n-00055a80: 6720 5c28 7965 732f 6e6f 282f 5c5b 6669 g \\(yes/no(/\\[fi\n-00055a90: 6e67 6572 7072 696e 745c 5d29 3f5c 295c ngerprint\\])?\\)\\\n-00055aa0: 3f20 220a 2020 2020 5f65 7874 7261 5f70 ? \". _extra_p\n-00055ab0: 6174 7465 726e 7320 3d20 5b0a 2020 2020 atterns = [. \n-00055ac0: 2020 2020 7222 257b 6669 6e67 6572 7072 r\"%{fingerpr\n-00055ad0: 696e 747d 5b2e 5d24 222c 0a20 2020 2020 int}[.]$\",. \n-00055ae0: 2020 2072 225e 257b 616c 676f 7269 7468 r\"^%{algorith\n-00055af0: 6d7d 206b 6579 2066 696e 6765 7270 7269 m} key fingerpri\n-00055b00: 6e74 2069 7322 2c0a 2020 2020 2020 2020 nt is\",. \n-00055b10: 7222 5e54 6865 2066 696e 6765 7270 7269 r\"^The fingerpri\n-00055b20: 6e74 2066 6f72 2074 6865 2025 7b61 6c67 nt for the %{alg\n-00055b30: 6f72 6974 686d 7d20 6b65 7920 7365 6e74 orithm} key sent\n-00055b40: 2062 7920 7468 6520 7265 6d6f 7465 2068 by the remote h\n-00055b50: 6f73 7420 6973 2422 0a20 2020 205d 0a20 ost is$\". ]. \n-00055b60: 2020 2061 6e73 7765 7273 203d 2028 2779 answers = ('y\n-00055b70: 6573 272c 2027 6e6f 2729 0a20 2020 2061 es', 'no'). a\n-00055b80: 6c67 6f72 6974 686d 3a20 7374 720a 2020 lgorithm: str. \n-00055b90: 2020 6669 6e67 6572 7072 696e 743a 2073 fingerprint: s\n-00055ba0: 7472 0a0a 2020 2020 6173 796e 6320 6465 tr.. async de\n-00055bb0: 6620 6469 7370 6174 6368 2873 656c 662c f dispatch(self,\n-00055bc0: 2072 6573 706f 6e64 6572 3a20 2753 7368 responder: 'Ssh\n-00055bd0: 4173 6b70 6173 7352 6573 706f 6e64 6572 AskpassResponder\n-00055be0: 2729 202d 3e20 2773 7472 207c 204e 6f6e ') -> 'str | Non\n-00055bf0: 6527 3a0a 2020 2020 2020 2020 7265 7475 e':. retu\n-00055c00: 726e 2061 7761 6974 2072 6573 706f 6e64 rn await respond\n-00055c10: 6572 2e64 6f5f 686f 7374 5f6b 6579 5f70 er.do_host_key_p\n-00055c20: 726f 6d70 7428 7365 6c66 290a 0a0a 6465 rompt(self)...de\n-00055c30: 6620 7769 7468 5f68 656c 7065 7273 2870 f with_helpers(p\n-00055c40: 6174 7465 726e 3a20 7374 7229 202d 3e20 attern: str) -> \n-00055c50: 7374 723a 0a20 2020 2066 6f72 206e 616d str:. for nam\n-00055c60: 652c 2068 656c 7065 7220 696e 2048 454c e, helper in HEL\n-00055c70: 5045 5253 2e69 7465 6d73 2829 3a0a 2020 PERS.items():. \n-00055c80: 2020 2020 2020 7061 7474 6572 6e20 3d20 pattern = \n-00055c90: 7061 7474 6572 6e2e 7265 706c 6163 6528 pattern.replace(\n-00055ca0: 6e61 6d65 2c20 6865 6c70 6572 290a 0a20 name, helper).. \n-00055cb0: 2020 2061 7373 6572 7420 2725 7b27 206e assert '%{' n\n-00055cc0: 6f74 2069 6e20 7061 7474 6572 6e0a 2020 ot in pattern. \n-00055cd0: 2020 7265 7475 726e 2070 6174 7465 726e return pattern\n-00055ce0: 0a0a 0a64 6566 2063 6174 6567 6f72 697a ...def categoriz\n-00055cf0: 655f 7373 685f 7072 6f6d 7074 2873 7472 e_ssh_prompt(str\n-00055d00: 696e 673a 2073 7472 2c20 7374 6465 7272 ing: str, stderr\n-00055d10: 3a20 7374 7229 202d 3e20 4173 6b70 6173 : str) -> Askpas\n-00055d20: 7350 726f 6d70 743a 0a20 2020 2063 6c61 sPrompt:. cla\n-00055d30: 7373 6573 203d 205b 0a20 2020 2020 2020 sses = [. \n-00055d40: 2053 7368 4649 444f 5049 4e50 726f 6d70 SshFIDOPINPromp\n-00055d50: 742c 0a20 2020 2020 2020 2053 7368 4649 t,. SshFI\n-00055d60: 444f 5573 6572 5072 6573 656e 6365 5072 DOUserPresencePr\n-00055d70: 6f6d 7074 2c0a 2020 2020 2020 2020 5373 ompt,. Ss\n-00055d80: 6848 6f73 744b 6579 5072 6f6d 7074 2c0a hHostKeyPrompt,.\n-00055d90: 2020 2020 2020 2020 5373 6850 4b43 5331 SshPKCS1\n-00055da0: 3150 494e 5072 6f6d 7074 2c0a 2020 2020 1PINPrompt,. \n-00055db0: 2020 2020 5373 6850 6173 7370 6872 6173 SshPassphras\n-00055dc0: 6550 726f 6d70 742c 0a20 2020 2020 2020 ePrompt,. \n-00055dd0: 2053 7368 5061 7373 776f 7264 5072 6f6d SshPasswordProm\n-00055de0: 7074 2c0a 2020 2020 5d0a 0a20 2020 2023 pt,. ].. #\n-00055df0: 2054 6865 206c 6173 7420 6c69 6e65 2069 The last line i\n-00055e00: 7320 7468 6520 6c69 6e65 2061 6674 6572 s the line after\n-00055e10: 2074 6865 206c 6173 7420 6e65 776c 696e the last newlin\n-00055e20: 6520 6368 6172 6163 7465 722c 2065 7863 e character, exc\n-00055e30: 6c75 6469 6e67 2074 6865 0a20 2020 2023 luding the. #\n-00055e40: 206f 7074 696f 6e61 6c20 6669 6e61 6c20 optional final \n-00055e50: 6e65 776c 696e 6520 6368 6172 6163 7465 newline characte\n-00055e60: 722e 2020 6567 3a20 2278 5c6e 795c 6e4c r. eg: \"x\\ny\\nL\n-00055e70: 4153 545c 6e22 206f 7220 2278 5c6e 795c AST\\n\" or \"x\\ny\\\n-00055e80: 6e4c 4153 5422 0a20 2020 2073 6563 6f6e nLAST\". secon\n-00055e90: 645f 6c61 7374 5f6e 6577 6c69 6e65 203d d_last_newline =\n-00055ea0: 2073 7472 696e 672e 7266 696e 6428 275c string.rfind('\\\n-00055eb0: 6e27 2c20 302c 202d 3129 0a20 2020 2069 n', 0, -1). i\n-00055ec0: 6620 7365 636f 6e64 5f6c 6173 745f 6e65 f second_last_ne\n-00055ed0: 776c 696e 6520 3e3d 2030 3a0a 2020 2020 wline >= 0:. \n-00055ee0: 2020 2020 6c61 7374 5f6c 696e 6520 3d20 last_line = \n-00055ef0: 7374 7269 6e67 5b73 6563 6f6e 645f 6c61 string[second_la\n-00055f00: 7374 5f6e 6577 6c69 6e65 202b 2031 3a5d st_newline + 1:]\n-00055f10: 0a20 2020 2020 2020 2065 7874 7261 7320 . extras \n-00055f20: 3d20 7374 7269 6e67 5b3a 7365 636f 6e64 = string[:second\n-00055f30: 5f6c 6173 745f 6e65 776c 696e 6520 2b20 _last_newline + \n-00055f40: 315d 0a20 2020 2065 6c73 653a 0a20 2020 1]. else:. \n-00055f50: 2020 2020 206c 6173 745f 6c69 6e65 203d last_line =\n-00055f60: 2073 7472 696e 670a 2020 2020 2020 2020 string. \n-00055f70: 6578 7472 6173 203d 2027 270a 0a20 2020 extras = ''.. \n-00055f80: 2066 6f72 2063 6c73 2069 6e20 636c 6173 for cls in clas\n-00055f90: 7365 733a 0a20 2020 2020 2020 2070 6174 ses:. pat\n-00055fa0: 7465 726e 203d 2077 6974 685f 6865 6c70 tern = with_help\n-00055fb0: 6572 7328 636c 732e 5f70 6174 7465 726e ers(cls._pattern\n-00055fc0: 290a 2020 2020 2020 2020 6d61 7463 6820 ). match \n-00055fd0: 3d20 7265 2e66 756c 6c6d 6174 6368 2870 = re.fullmatch(p\n-00055fe0: 6174 7465 726e 2c20 6c61 7374 5f6c 696e attern, last_lin\n-00055ff0: 6529 0a20 2020 2020 2020 2069 6620 6d61 e). if ma\n-00056000: 7463 6820 6973 206e 6f74 204e 6f6e 653a tch is not None:\n-00056010: 0a20 2020 2020 2020 2020 2020 2072 6574 . ret\n-00056020: 7572 6e20 636c 7328 6c61 7374 5f6c 696e urn cls(last_lin\n-00056030: 652c 2065 7874 7261 732c 2073 7464 6572 e, extras, stder\n-00056040: 722c 206d 6174 6368 290a 0a20 2020 2072 r, match).. r\n-00056050: 6574 7572 6e20 4173 6b70 6173 7350 726f eturn AskpassPro\n-00056060: 6d70 7428 6c61 7374 5f6c 696e 652c 2065 mpt(last_line, e\n-00056070: 7874 7261 732c 2073 7464 6572 7229 0a0a xtras, stderr)..\n-00056080: 0a63 6c61 7373 2053 7368 4173 6b70 6173 .class SshAskpas\n-00056090: 7352 6573 706f 6e64 6572 2841 736b 7061 sResponder(Askpa\n-000560a0: 7373 4861 6e64 6c65 7229 3a0a 2020 2020 ssHandler):. \n-000560b0: 6173 796e 6320 6465 6620 646f 5f61 736b async def do_ask\n-000560c0: 7061 7373 2873 656c 662c 2073 7464 6572 pass(self, stder\n-000560d0: 723a 2073 7472 2c20 7072 6f6d 7074 3a20 r: str, prompt: \n-000560e0: 7374 722c 2068 696e 743a 2073 7472 2920 str, hint: str) \n-000560f0: 2d3e 2027 7374 7220 7c20 4e6f 6e65 273a -> 'str | None':\n-00056100: 0a20 2020 2020 2020 2072 6574 7572 6e20 . return \n-00056110: 6177 6169 7420 6361 7465 676f 7269 7a65 await categorize\n-00056120: 5f73 7368 5f70 726f 6d70 7428 7072 6f6d _ssh_prompt(prom\n-00056130: 7074 2c20 7374 6465 7272 292e 6469 7370 pt, stderr).disp\n-00056140: 6174 6368 2873 656c 6629 0a0a 2020 2020 atch(self).. \n-00056150: 6173 796e 6320 6465 6620 646f 5f70 726f async def do_pro\n-00056160: 6d70 7428 7365 6c66 2c20 7072 6f6d 7074 mpt(self, prompt\n-00056170: 3a20 4173 6b70 6173 7350 726f 6d70 7429 : AskpassPrompt)\n-00056180: 202d 3e20 2773 7472 207c 204e 6f6e 6527 -> 'str | None'\n-00056190: 3a0a 2020 2020 2020 2020 2320 4465 6661 :. # Defa\n-000561a0: 756c 7420 6661 6c6c 6261 636b 2066 6f72 ult fallback for\n-000561b0: 2075 6e72 6563 6f67 6e69 7365 6420 6d65 unrecognised me\n-000561c0: 7373 6167 6520 7479 7065 733a 2075 6e69 ssage types: uni\n-000561d0: 6d70 6c65 6d65 6e74 6564 0a20 2020 2020 mplemented. \n-000561e0: 2020 2072 6574 7572 6e20 4e6f 6e65 0a0a return None..\n-000561f0: 2020 2020 6173 796e 6320 6465 6620 646f async def do\n-00056200: 5f66 6964 6f5f 7069 6e5f 7072 6f6d 7074 _fido_pin_prompt\n-00056210: 2873 656c 662c 2070 726f 6d70 743a 2053 (self, prompt: S\n-00056220: 7368 4649 444f 5049 4e50 726f 6d70 7429 shFIDOPINPrompt)\n-00056230: 202d 3e20 2773 7472 207c 204e 6f6e 6527 -> 'str | None'\n-00056240: 3a0a 2020 2020 2020 2020 7265 7475 726e :. return\n-00056250: 2061 7761 6974 2073 656c 662e 646f 5f70 await self.do_p\n-00056260: 726f 6d70 7428 7072 6f6d 7074 290a 0a20 rompt(prompt).. \n-00056270: 2020 2061 7379 6e63 2064 6566 2064 6f5f async def do_\n-00056280: 6669 646f 5f75 7365 725f 7072 6573 656e fido_user_presen\n-00056290: 6365 5f70 726f 6d70 7428 7365 6c66 2c20 ce_prompt(self, \n-000562a0: 7072 6f6d 7074 3a20 5373 6846 4944 4f55 prompt: SshFIDOU\n-000562b0: 7365 7250 7265 7365 6e63 6550 726f 6d70 serPresencePromp\n-000562c0: 7429 202d 3e20 2773 7472 207c 204e 6f6e t) -> 'str | Non\n-000562d0: 6527 3a0a 2020 2020 2020 2020 7265 7475 e':. retu\n-000562e0: 726e 2061 7761 6974 2073 656c 662e 646f rn await self.do\n-000562f0: 5f70 726f 6d70 7428 7072 6f6d 7074 290a _prompt(prompt).\n-00056300: 0a20 2020 2061 7379 6e63 2064 6566 2064 . async def d\n-00056310: 6f5f 686f 7374 5f6b 6579 5f70 726f 6d70 o_host_key_promp\n-00056320: 7428 7365 6c66 2c20 7072 6f6d 7074 3a20 t(self, prompt: \n-00056330: 5373 6848 6f73 744b 6579 5072 6f6d 7074 SshHostKeyPrompt\n-00056340: 2920 2d3e 2027 7374 7220 7c20 4e6f 6e65 ) -> 'str | None\n-00056350: 273a 0a20 2020 2020 2020 2072 6574 7572 ':. retur\n-00056360: 6e20 6177 6169 7420 7365 6c66 2e64 6f5f n await self.do_\n-00056370: 7072 6f6d 7074 2870 726f 6d70 7429 0a0a prompt(prompt)..\n-00056380: 2020 2020 6173 796e 6320 6465 6620 646f async def do\n-00056390: 5f70 6b63 7331 315f 7069 6e5f 7072 6f6d _pkcs11_pin_prom\n-000563a0: 7074 2873 656c 662c 2070 726f 6d70 743a pt(self, prompt:\n-000563b0: 2053 7368 504b 4353 3131 5049 4e50 726f SshPKCS11PINPro\n-000563c0: 6d70 7429 202d 3e20 2773 7472 207c 204e mpt) -> 'str | N\n-000563d0: 6f6e 6527 3a0a 2020 2020 2020 2020 7265 one':. re\n-000563e0: 7475 726e 2061 7761 6974 2073 656c 662e turn await self.\n-000563f0: 646f 5f70 726f 6d70 7428 7072 6f6d 7074 do_prompt(prompt\n-00056400: 290a 0a20 2020 2061 7379 6e63 2064 6566 ).. async def\n-00056410: 2064 6f5f 7061 7373 7068 7261 7365 5f70 do_passphrase_p\n-00056420: 726f 6d70 7428 7365 6c66 2c20 7072 6f6d rompt(self, prom\n-00056430: 7074 3a20 5373 6850 6173 7370 6872 6173 pt: SshPassphras\n-00056440: 6550 726f 6d70 7429 202d 3e20 2773 7472 ePrompt) -> 'str\n-00056450: 207c 204e 6f6e 6527 3a0a 2020 2020 2020 | None':. \n-00056460: 2020 7265 7475 726e 2061 7761 6974 2073 return await s\n-00056470: 656c 662e 646f 5f70 726f 6d70 7428 7072 elf.do_prompt(pr\n-00056480: 6f6d 7074 290a 0a20 2020 2061 7379 6e63 ompt).. async\n-00056490: 2064 6566 2064 6f5f 7061 7373 776f 7264 def do_password\n-000564a0: 5f70 726f 6d70 7428 7365 6c66 2c20 7072 _prompt(self, pr\n-000564b0: 6f6d 7074 3a20 5373 6850 6173 7377 6f72 ompt: SshPasswor\n-000564c0: 6450 726f 6d70 7429 202d 3e20 2773 7472 dPrompt) -> 'str\n-000564d0: 207c 204e 6f6e 6527 3a0a 2020 2020 2020 | None':. \n-000564e0: 2020 7265 7475 726e 2061 7761 6974 2073 return await s\n-000564f0: 656c 662e 646f 5f70 726f 6d70 7428 7072 elf.do_prompt(pr\n-00056500: 6f6d 7074 290a 2727 272c 0a20 2027 636f ompt).''',. 'co\n-00056510: 636b 7069 742f 5f76 656e 646f 722f 6665 ckpit/_vendor/fe\n-00056520: 726e 792f 7365 7373 696f 6e2e 7079 273a rny/session.py':\n-00056530: 2072 2727 2723 2066 6572 6e79 202d 2061 r'''# ferny - a\n-00056540: 7379 6e63 696f 2053 5348 2063 6c69 656e syncio SSH clien\n-00056550: 7420 6c69 6272 6172 792c 2075 7369 6e67 t library, using\n-00056560: 2073 7368 2831 290a 230a 2320 436f 7079 ssh(1).#.# Copy\n-00056570: 7269 6768 7420 2843 2920 3230 3232 2041 right (C) 2022 A\n-00056580: 6c6c 6973 6f6e 204b 6172 6c69 7473 6b61 llison Karlitska\n-00056590: 7961 203c 616c 6c69 736f 6e2e 6b61 726c ya <allison.karl\n-000565a0: 6974 736b 6179 6140 7265 6468 6174 2e63 itskaya@redhat.c\n-000565b0: 6f6d 3e0a 230a 2320 5468 6973 2070 726f om>.#.# This pro\n-000565c0: 6772 616d 2069 7320 6672 6565 2073 6f66 gram is free sof\n-000565d0: 7477 6172 653a 2079 6f75 2063 616e 2072 tware: you can r\n-000565e0: 6564 6973 7472 6962 7574 6520 6974 2061 edistribute it a\n-000565f0: 6e64 2f6f 7220 6d6f 6469 6679 0a23 2069 nd/or modify.# i\n-00056600: 7420 756e 6465 7220 7468 6520 7465 726d t under the term\n-00056610: 7320 6f66 2074 6865 2047 4e55 2047 656e s of the GNU Gen\n-00056620: 6572 616c 2050 7562 6c69 6320 4c69 6365 eral Public Lice\n-00056630: 6e73 6520 6173 2070 7562 6c69 7368 6564 nse as published\n-00056640: 2062 790a 2320 7468 6520 4672 6565 2053 by.# the Free S\n-00056650: 6f66 7477 6172 6520 466f 756e 6461 7469 oftware Foundati\n-00056660: 6f6e 2c20 6569 7468 6572 2076 6572 7369 on, either versi\n-00056670: 6f6e 2033 206f 6620 7468 6520 4c69 6365 on 3 of the Lice\n-00056680: 6e73 652c 206f 720a 2320 2861 7420 796f nse, or.# (at yo\n-00056690: 7572 206f 7074 696f 6e29 2061 6e79 206c ur option) any l\n-000566a0: 6174 6572 2076 6572 7369 6f6e 2e0a 230a ater version..#.\n-000566b0: 2320 5468 6973 2070 726f 6772 616d 2069 # This program i\n-000566c0: 7320 6469 7374 7269 6275 7465 6420 696e s distributed in\n-000566d0: 2074 6865 2068 6f70 6520 7468 6174 2069 the hope that i\n-000566e0: 7420 7769 6c6c 2062 6520 7573 6566 756c t will be useful\n-000566f0: 2c0a 2320 6275 7420 5749 5448 4f55 5420 ,.# but WITHOUT \n-00056700: 414e 5920 5741 5252 414e 5459 3b20 7769 ANY WARRANTY; wi\n-00056710: 7468 6f75 7420 6576 656e 2074 6865 2069 thout even the i\n-00056720: 6d70 6c69 6564 2077 6172 7261 6e74 7920 mplied warranty \n-00056730: 6f66 0a23 204d 4552 4348 414e 5441 4249 of.# MERCHANTABI\n-00056740: 4c49 5459 206f 7220 4649 544e 4553 5320 LITY or FITNESS \n-00056750: 464f 5220 4120 5041 5254 4943 554c 4152 FOR A PARTICULAR\n-00056760: 2050 5552 504f 5345 2e20 2053 6565 2074 PURPOSE. See t\n-00056770: 6865 0a23 2047 4e55 2047 656e 6572 616c he.# GNU General\n-00056780: 2050 7562 6c69 6320 4c69 6365 6e73 6520 Public License \n-00056790: 666f 7220 6d6f 7265 2064 6574 6169 6c73 for more details\n-000567a0: 2e0a 230a 2320 596f 7520 7368 6f75 6c64 ..#.# You should\n-000567b0: 2068 6176 6520 7265 6365 6976 6564 2061 have received a\n-000567c0: 2063 6f70 7920 6f66 2074 6865 2047 4e55 copy of the GNU\n-000567d0: 2047 656e 6572 616c 2050 7562 6c69 6320 General Public \n-000567e0: 4c69 6365 6e73 650a 2320 616c 6f6e 6720 License.# along \n-000567f0: 7769 7468 2074 6869 7320 7072 6f67 7261 with this progra\n-00056800: 6d2e 2020 4966 206e 6f74 2c20 7365 6520 m. If not, see \n-00056810: 3c68 7474 703a 2f2f 7777 772e 676e 752e <http://www.gnu.\n-00056820: 6f72 672f 6c69 6365 6e73 6573 2f3e 2e0a org/licenses/>..\n-00056830: 0a69 6d70 6f72 7420 6173 796e 6369 6f0a .import asyncio.\n-00056840: 696d 706f 7274 2063 7479 7065 730a 696d import ctypes.im\n-00056850: 706f 7274 2066 756e 6374 6f6f 6c73 0a69 port functools.i\n-00056860: 6d70 6f72 7420 6c6f 6767 696e 670a 696d mport logging.im\n-00056870: 706f 7274 206f 730a 696d 706f 7274 2073 port os.import s\n-00056880: 686c 6578 0a69 6d70 6f72 7420 7369 676e hlex.import sign\n-00056890: 616c 0a69 6d70 6f72 7420 7375 6270 726f al.import subpro\n-000568a0: 6365 7373 0a69 6d70 6f72 7420 7465 6d70 cess.import temp\n-000568b0: 6669 6c65 0a66 726f 6d20 7479 7069 6e67 file.from typing\n-000568c0: 2069 6d70 6f72 7420 4d61 7070 696e 672c import Mapping,\n-000568d0: 2053 6571 7565 6e63 650a 0a66 726f 6d20 Sequence..from \n-000568e0: 2e20 696d 706f 7274 2073 7368 5f65 7272 . import ssh_err\n-000568f0: 6f72 730a 6672 6f6d 202e 696e 7465 7261 ors.from .intera\n-00056900: 6374 696f 6e5f 6167 656e 7420 696d 706f ction_agent impo\n-00056910: 7274 2049 6e74 6572 6163 7469 6f6e 4167 rt InteractionAg\n-00056920: 656e 742c 2049 6e74 6572 6163 7469 6f6e ent, Interaction\n-00056930: 4572 726f 722c 2049 6e74 6572 6163 7469 Error, Interacti\n-00056940: 6f6e 4861 6e64 6c65 722c 2077 7269 7465 onHandler, write\n-00056950: 5f61 736b 7061 7373 5f74 6f5f 746d 7064 _askpass_to_tmpd\n-00056960: 6972 0a0a 7072 6374 6c20 3d20 6374 7970 ir..prctl = ctyp\n-00056970: 6573 2e63 646c 6c2e 4c6f 6164 4c69 6272 es.cdll.LoadLibr\n-00056980: 6172 7928 276c 6962 632e 736f 2e36 2729 ary('libc.so.6')\n-00056990: 2e70 7263 746c 0a6c 6f67 6765 7220 3d20 .prctl.logger = \n-000569a0: 6c6f 6767 696e 672e 6765 744c 6f67 6765 logging.getLogge\n-000569b0: 7228 5f5f 6e61 6d65 5f5f 290a 5052 5f53 r(__name__).PR_S\n-000569c0: 4554 5f50 4445 4154 4853 4947 203d 2031 ET_PDEATHSIG = 1\n-000569d0: 0a0a 0a40 6675 6e63 746f 6f6c 732e 6c72 ...@functools.lr\n-000569e0: 755f 6361 6368 6528 290a 6465 6620 6861 u_cache().def ha\n-000569f0: 735f 6665 6174 7572 6528 6665 6174 7572 s_feature(featur\n-00056a00: 653a 2073 7472 2c20 7465 7374 7374 723a e: str, teststr:\n-00056a10: 2073 7472 203d 2027 7827 2920 2d3e 2062 str = 'x') -> b\n-00056a20: 6f6f 6c3a 0a20 2020 2074 7279 3a0a 2020 ool:. try:. \n-00056a30: 2020 2020 2020 7375 6270 726f 6365 7373 subprocess\n-00056a40: 2e63 6865 636b 5f6f 7574 7075 7428 5b27 .check_output(['\n-00056a50: 7373 6827 2c20 6627 2d6f 7b66 6561 7475 ssh', f'-o{featu\n-00056a60: 7265 7d20 7b74 6573 7473 7472 7d27 2c20 re} {teststr}', \n-00056a70: 272d 4727 2c20 276e 6f6e 6578 6973 7469 '-G', 'nonexisti\n-00056a80: 6e67 275d 2c20 7374 6465 7272 3d73 7562 ng'], stderr=sub\n-00056a90: 7072 6f63 6573 732e 4445 564e 554c 4c29 process.DEVNULL)\n-00056aa0: 0a20 2020 2020 2020 2072 6574 7572 6e20 . return \n-00056ab0: 5472 7565 0a20 2020 2065 7863 6570 7420 True. except \n-00056ac0: 7375 6270 726f 6365 7373 2e43 616c 6c65 subprocess.Calle\n-00056ad0: 6450 726f 6365 7373 4572 726f 723a 0a20 dProcessError:. \n-00056ae0: 2020 2020 2020 2072 6574 7572 6e20 4661 return Fa\n-00056af0: 6c73 650a 0a0a 636c 6173 7320 5375 6270 lse...class Subp\n-00056b00: 726f 6365 7373 436f 6e74 6578 743a 0a20 rocessContext:. \n-00056b10: 2020 2064 6566 2077 7261 705f 7375 6270 def wrap_subp\n-00056b20: 726f 6365 7373 5f61 7267 7328 7365 6c66 rocess_args(self\n-00056b30: 2c20 6172 6773 3a20 5365 7175 656e 6365 , args: Sequence\n-00056b40: 5b73 7472 5d29 202d 3e20 5365 7175 656e [str]) -> Sequen\n-00056b50: 6365 5b73 7472 5d3a 0a20 2020 2020 2020 ce[str]:. \n-00056b60: 2022 2222 5265 7475 726e 2074 6865 2061 \"\"\"Return the a\n-00056b70: 7267 7320 7265 7175 6972 6564 2074 6f20 rgs required to \n-00056b80: 6c61 756e 6368 2061 2070 726f 6365 7373 launch a process\n-00056b90: 2069 6e20 7468 6520 6769 7665 6e20 636f in the given co\n-00056ba0: 6e74 6578 742e 0a0a 2020 2020 2020 2020 ntext... \n-00056bb0: 466f 7220 6578 616d 706c 652c 2074 6869 For example, thi\n-00056bc0: 7320 6d69 6768 7420 7265 7475 726e 2061 s might return a\n-00056bd0: 2076 6563 746f 7220 7769 7468 0a20 2020 vector with. \n-00056be0: 2020 2020 2020 2020 205b 2273 7564 6f22 [\"sudo\"\n-00056bf0: 5d0a 2020 2020 2020 2020 6f72 0a20 2020 ]. or. \n-00056c00: 2020 2020 2020 2020 205b 2266 6c61 7470 [\"flatp\n-00056c10: 616b 2d73 7061 776e 222c 2022 2d2d 686f ak-spawn\", \"--ho\n-00056c20: 7374 225d 0a20 2020 2020 2020 2070 7265 st\"]. pre\n-00056c30: 7065 6e64 6564 2e0a 0a20 2020 2020 2020 pended... \n-00056c40: 2049 7420 6973 2061 6c73 6f20 706f 7373 It is also poss\n-00056c50: 6962 6c65 2074 6861 7420 6d6f 7265 2073 ible that more s\n-00056c60: 7562 7374 616e 7469 616c 2063 6861 6e67 ubstantial chang\n-00056c70: 6573 206d 6179 2062 6520 7065 7266 6f72 es may be perfor\n-00056c80: 6d65 642e 0a0a 2020 2020 2020 2020 5468 med... Th\n-00056c90: 6973 2066 756e 6374 696f 6e20 6973 206e is function is n\n-00056ca0: 6f74 2070 6572 6d69 7474 6564 2074 6f20 ot permitted to \n-00056cb0: 6d6f 6469 6679 2069 7473 2061 7267 756d modify its argum\n-00056cc0: 656e 742c 2061 6c74 686f 7567 6820 6974 ent, although it\n-00056cd0: 206d 6179 0a20 2020 2020 2020 2028 6f70 may. (op\n-00056ce0: 7469 6f6e 616c 6c79 2920 7265 7475 726e tionally) return\n-00056cf0: 2069 7420 756e 6d6f 6469 6669 6564 2c20 it unmodified, \n-00056d00: 6966 206e 6f20 6368 616e 6765 7320 6172 if no changes ar\n-00056d10: 6520 7265 7175 6972 6564 2e0a 2020 2020 e required.. \n-00056d20: 2020 2020 2222 220a 2020 2020 2020 2020 \"\"\". \n-00056d30: 7265 7475 726e 2061 7267 730a 0a20 2020 return args.. \n-00056d40: 2064 6566 2077 7261 705f 7375 6270 726f def wrap_subpro\n-00056d50: 6365 7373 5f65 6e76 2873 656c 662c 2065 cess_env(self, e\n-00056d60: 6e76 3a20 4d61 7070 696e 675b 7374 722c nv: Mapping[str,\n-00056d70: 2073 7472 5d29 202d 3e20 4d61 7070 696e str]) -> Mappin\n-00056d80: 675b 7374 722c 2073 7472 5d3a 0a20 2020 g[str, str]:. \n-00056d90: 2020 2020 2022 2222 5265 7475 726e 2074 \"\"\"Return t\n-00056da0: 6865 2065 6e76 7020 7265 7175 6972 6564 he envp required\n-00056db0: 2074 6f20 6c61 756e 6368 2061 2070 726f to launch a pro\n-00056dc0: 6365 7373 2069 6e20 7468 6520 6769 7665 cess in the give\n-00056dd0: 6e20 636f 6e74 6578 742e 0a0a 2020 2020 n context... \n-00056de0: 2020 2020 466f 7220 6578 616d 706c 652c For example,\n-00056df0: 2074 6869 7320 6d69 6768 7420 7365 7420 this might set \n-00056e00: 7468 6520 2253 5544 4f5f 4153 4b50 4153 the \"SUDO_ASKPAS\n-00056e10: 5322 2065 6e76 6972 6f6e 6d65 6e74 2076 S\" environment v\n-00056e20: 6172 6961 626c 652c 2069 660a 2020 2020 ariable, if. \n-00056e30: 2020 2020 6e65 6564 6564 2e0a 0a20 2020 needed... \n-00056e40: 2020 2020 2041 7320 7769 7468 2077 7261 As with wra\n-00056e50: 705f 7375 6270 726f 6365 7373 5f61 7267 p_subprocess_arg\n-00056e60: 7328 292c 2074 6869 7320 6675 6e63 7469 s(), this functi\n-00056e70: 6f6e 2069 7320 6e6f 7420 7065 726d 6974 on is not permit\n-00056e80: 7465 6420 746f 0a20 2020 2020 2020 206d ted to. m\n-00056e90: 6f64 6966 7920 6974 7320 6172 6775 6d65 odify its argume\n-00056ea0: 6e74 2c20 616c 7468 6f75 6768 2069 7420 nt, although it \n-00056eb0: 6d61 7920 286f 7074 696f 6e61 6c6c 7929 may (optionally)\n-00056ec0: 2072 6574 7572 6e20 6974 2075 6e6d 6f64 return it unmod\n-00056ed0: 6966 6965 640a 2020 2020 2020 2020 6966 ified. if\n-00056ee0: 206e 6f20 6368 616e 6765 7320 6172 6520 no changes are \n-00056ef0: 7265 7175 6972 6564 2e0a 2020 2020 2020 required.. \n-00056f00: 2020 2222 220a 2020 2020 2020 2020 7265 \"\"\". re\n-00056f10: 7475 726e 2065 6e76 0a0a 0a63 6c61 7373 turn env...class\n-00056f20: 2053 6573 7369 6f6e 2853 7562 7072 6f63 Session(Subproc\n-00056f30: 6573 7343 6f6e 7465 7874 2c20 496e 7465 essContext, Inte\n-00056f40: 7261 6374 696f 6e48 616e 646c 6572 293a ractionHandler):\n-00056f50: 0a20 2020 2023 2053 6574 2061 6674 6572 . # Set after\n-00056f60: 202e 636f 6e6e 6563 7428 2920 6361 6c6c .connect() call\n-00056f70: 6564 2c20 6576 656e 2069 6620 6661 696c ed, even if fail\n-00056f80: 6564 0a20 2020 205f 636f 6e74 726f 6c64 ed. _controld\n-00056f90: 6972 3a20 2774 656d 7066 696c 652e 5465 ir: 'tempfile.Te\n-00056fa0: 6d70 6f72 6172 7944 6972 6563 746f 7279 mporaryDirectory\n-00056fb0: 207c 204e 6f6e 6527 203d 204e 6f6e 650a | None' = None.\n-00056fc0: 2020 2020 5f63 6f6e 7472 6f6c 736f 636b _controlsock\n-00056fd0: 3a20 2773 7472 207c 204e 6f6e 6527 203d : 'str | None' =\n-00056fe0: 204e 6f6e 650a 0a20 2020 2023 2053 6574 None.. # Set\n-00056ff0: 2069 6620 636f 6e6e 6563 7465 642c 2065 if connected, e\n-00057000: 6c73 6520 4e6f 6e65 0a20 2020 205f 7072 lse None. _pr\n-00057010: 6f63 6573 733a 2027 6173 796e 6369 6f2e ocess: 'asyncio.\n-00057020: 7375 6270 726f 6365 7373 2e50 726f 6365 subprocess.Proce\n-00057030: 7373 207c 204e 6f6e 6527 203d 204e 6f6e ss | None' = Non\n-00057040: 650a 0a20 2020 2061 7379 6e63 2064 6566 e.. async def\n-00057050: 2063 6f6e 6e65 6374 2873 656c 662c 0a20 connect(self,. \n-00057060: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00057070: 2020 2020 2064 6573 7469 6e61 7469 6f6e destination\n-00057080: 3a20 7374 722c 0a20 2020 2020 2020 2020 : str,. \n-00057090: 2020 2020 2020 2020 2020 2020 2068 616e han\n-000570a0: 646c 655f 686f 7374 5f6b 6579 3a20 626f dle_host_key: bo\n-000570b0: 6f6c 203d 2046 616c 7365 2c0a 2020 2020 ol = False,. \n-000570c0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000570d0: 2020 636f 6e66 6967 6669 6c65 3a20 2773 configfile: 's\n-000570e0: 7472 207c 204e 6f6e 6527 203d 204e 6f6e tr | None' = Non\n-000570f0: 652c 0a20 2020 2020 2020 2020 2020 2020 e,. \n-00057100: 2020 2020 2020 2020 2069 6465 6e74 6974 identit\n-00057110: 795f 6669 6c65 3a20 2773 7472 207c 204e y_file: 'str | N\n-00057120: 6f6e 6527 203d 204e 6f6e 652c 0a20 2020 one' = None,. \n-00057130: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00057140: 2020 206c 6f67 696e 5f6e 616d 653a 2027 login_name: '\n-00057150: 7374 7220 7c20 4e6f 6e65 2720 3d20 4e6f str | None' = No\n-00057160: 6e65 2c0a 2020 2020 2020 2020 2020 2020 ne,. \n-00057170: 2020 2020 2020 2020 2020 6f70 7469 6f6e option\n-00057180: 733a 2027 4d61 7070 696e 675b 7374 722c s: 'Mapping[str,\n-00057190: 2073 7472 5d20 7c20 4e6f 6e65 2720 3d20 str] | None' = \n-000571a0: 4e6f 6e65 2c0a 2020 2020 2020 2020 2020 None,. \n-000571b0: 2020 2020 2020 2020 2020 2020 706b 6373 pkcs\n-000571c0: 3131 3a20 2773 7472 207c 204e 6f6e 6527 11: 'str | None'\n-000571d0: 203d 204e 6f6e 652c 0a20 2020 2020 2020 = None,. \n-000571e0: 2020 2020 2020 2020 2020 2020 2020 2070 p\n-000571f0: 6f72 743a 2027 696e 7420 7c20 4e6f 6e65 ort: 'int | None\n-00057200: 2720 3d20 4e6f 6e65 2c0a 2020 2020 2020 ' = None,. \n-00057210: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00057220: 696e 7465 7261 6374 696f 6e5f 7265 7370 interaction_resp\n-00057230: 6f6e 6465 723a 2027 496e 7465 7261 6374 onder: 'Interact\n-00057240: 696f 6e48 616e 646c 6572 207c 204e 6f6e ionHandler | Non\n-00057250: 6527 203d 204e 6f6e 6529 202d 3e20 4e6f e' = None) -> No\n-00057260: 6e65 3a0a 2020 2020 2020 2020 7275 6e64 ne:. rund\n-00057270: 6972 203d 206f 732e 7061 7468 2e6a 6f69 ir = os.path.joi\n-00057280: 6e28 6f73 2e65 6e76 6972 6f6e 2e67 6574 n(os.environ.get\n-00057290: 2827 5844 475f 5255 4e54 494d 455f 4449 ('XDG_RUNTIME_DI\n-000572a0: 5227 2c20 272f 7275 6e27 292c 2027 6665 R', '/run'), 'fe\n-000572b0: 726e 7927 290a 2020 2020 2020 2020 6f73 rny'). os\n-000572c0: 2e6d 616b 6564 6972 7328 7275 6e64 6972 .makedirs(rundir\n-000572d0: 2c20 6578 6973 745f 6f6b 3d54 7275 6529 , exist_ok=True)\n-000572e0: 0a20 2020 2020 2020 2073 656c 662e 5f63 . self._c\n-000572f0: 6f6e 7472 6f6c 6469 7220 3d20 7465 6d70 ontroldir = temp\n-00057300: 6669 6c65 2e54 656d 706f 7261 7279 4469 file.TemporaryDi\n-00057310: 7265 6374 6f72 7928 6469 723d 7275 6e64 rectory(dir=rund\n-00057320: 6972 290a 2020 2020 2020 2020 7365 6c66 ir). self\n-00057330: 2e5f 636f 6e74 726f 6c73 6f63 6b20 3d20 ._controlsock = \n-00057340: 6627 7b73 656c 662e 5f63 6f6e 7472 6f6c f'{self._control\n-00057350: 6469 722e 6e61 6d65 7d2f 736f 636b 6574 dir.name}/socket\n-00057360: 270a 0a20 2020 2020 2020 2023 2049 6e20 '.. # In \n-00057370: 6765 6e65 7261 6c2c 2077 6520 6361 6e27 general, we can'\n-00057380: 7420 6775 6172 616e 7465 6520 616e 2061 t guarantee an a\n-00057390: 6363 6573 7369 626c 6520 616e 6420 6578 ccessible and ex\n-000573a0: 6563 7574 6162 6c65 2076 6572 7369 6f6e ecutable version\n-000573b0: 0a20 2020 2020 2020 2023 206f 6620 7468 . # of th\n-000573c0: 6973 2066 696c 652c 2062 7574 2073 696e is file, but sin\n-000573d0: 6365 2069 7427 7320 736d 616c 6c20 616e ce it's small an\n-000573e0: 6420 7765 2772 6520 6d61 6b69 6e67 2061 d we're making a\n-000573f0: 2074 656d 706f 7261 7279 0a20 2020 2020 temporary. \n-00057400: 2020 2023 2064 6972 6563 746f 7279 2061 # directory a\n-00057410: 6e79 7761 792c 206c 6574 2773 206a 7573 nyway, let's jus\n-00057420: 7420 636f 7079 2069 7420 696e 746f 2070 t copy it into p\n-00057430: 6c61 6365 2061 6e64 2075 7365 2069 7420 lace and use it \n-00057440: 6672 6f6d 0a20 2020 2020 2020 2023 2074 from. # t\n-00057450: 6865 7265 2e0a 2020 2020 2020 2020 6173 here.. as\n-00057460: 6b70 6173 735f 7061 7468 203d 2077 7269 kpass_path = wri\n-00057470: 7465 5f61 736b 7061 7373 5f74 6f5f 746d te_askpass_to_tm\n-00057480: 7064 6972 2873 656c 662e 5f63 6f6e 7472 pdir(self._contr\n-00057490: 6f6c 6469 722e 6e61 6d65 290a 0a20 2020 oldir.name).. \n-000574a0: 2020 2020 2065 6e76 203d 2064 6963 7428 env = dict(\n-000574b0: 6f73 2e65 6e76 6972 6f6e 290a 2020 2020 os.environ). \n-000574c0: 2020 2020 656e 765b 2753 5348 5f41 534b env['SSH_ASK\n-000574d0: 5041 5353 275d 203d 2061 736b 7061 7373 PASS'] = askpass\n-000574e0: 5f70 6174 680a 2020 2020 2020 2020 656e _path. en\n-000574f0: 765b 2753 5348 5f41 534b 5041 5353 5f52 v['SSH_ASKPASS_R\n-00057500: 4551 5549 5245 275d 203d 2027 666f 7263 EQUIRE'] = 'forc\n-00057510: 6527 0a20 2020 2020 2020 2023 206f 6c64 e'. # old\n-00057520: 2053 5348 2064 6f65 736e 2774 2075 6e64 SSH doesn't und\n-00057530: 6572 7374 616e 6420 5353 485f 4153 4b50 erstand SSH_ASKP\n-00057540: 4153 535f 5245 5155 4952 4520 616e 6420 ASS_REQUIRE and \n-00057550: 6775 6573 7365 7320 6261 7365 6420 6f6e guesses based on\n-00057560: 2044 4953 504c 4159 2069 6e73 7465 6164 DISPLAY instead\n-00057570: 0a20 2020 2020 2020 2065 6e76 5b27 4449 . env['DI\n-00057580: 5350 4c41 5927 5d20 3d20 272d 270a 0a20 SPLAY'] = '-'.. \n-00057590: 2020 2020 2020 2061 7267 7320 3d20 5b0a args = [.\n-000575a0: 2020 2020 2020 2020 2020 2020 272d 4d27 '-M'\n-000575b0: 2c0a 2020 2020 2020 2020 2020 2020 272d ,. '-\n-000575c0: 4e27 2c0a 2020 2020 2020 2020 2020 2020 N',. \n-000575d0: 272d 5327 2c20 7365 6c66 2e5f 636f 6e74 '-S', self._cont\n-000575e0: 726f 6c73 6f63 6b2c 0a20 2020 2020 2020 rolsock,. \n-000575f0: 2020 2020 2027 2d6f 272c 2027 5065 726d '-o', 'Perm\n-00057600: 6974 4c6f 6361 6c43 6f6d 6d61 6e64 3d79 itLocalCommand=y\n-00057610: 6573 272c 0a20 2020 2020 2020 2020 2020 es',. \n-00057620: 2027 2d6f 272c 2066 274c 6f63 616c 436f '-o', f'LocalCo\n-00057630: 6d6d 616e 643d 7b61 736b 7061 7373 5f70 mmand={askpass_p\n-00057640: 6174 687d 272c 0a20 2020 2020 2020 205d ath}',. ]\n-00057650: 0a0a 2020 2020 2020 2020 6966 2063 6f6e .. if con\n-00057660: 6669 6766 696c 6520 6973 206e 6f74 204e figfile is not N\n-00057670: 6f6e 653a 0a20 2020 2020 2020 2020 2020 one:. \n-00057680: 2061 7267 732e 6170 7065 6e64 2866 272d args.append(f'-\n-00057690: 467b 636f 6e66 6967 6669 6c65 7d27 290a F{configfile}').\n-000576a0: 0a20 2020 2020 2020 2069 6620 6964 656e . if iden\n-000576b0: 7469 7479 5f66 696c 6520 6973 206e 6f74 tity_file is not\n-000576c0: 204e 6f6e 653a 0a20 2020 2020 2020 2020 None:. \n-000576d0: 2020 2061 7267 732e 6170 7065 6e64 2866 args.append(f\n-000576e0: 272d 697b 6964 656e 7469 7479 5f66 696c '-i{identity_fil\n-000576f0: 657d 2729 0a0a 2020 2020 2020 2020 6966 e}').. if\n-00057700: 206f 7074 696f 6e73 2069 7320 6e6f 7420 options is not \n-00057710: 4e6f 6e65 3a0a 2020 2020 2020 2020 2020 None:. \n-00057720: 2020 666f 7220 6b65 7920 696e 206f 7074 for key in opt\n-00057730: 696f 6e73 3a20 2023 204e 6f74 653a 204d ions: # Note: M\n-00057740: 6170 7069 6e67 206d 6179 206e 6f74 2068 apping may not h\n-00057750: 6176 6520 2e69 7465 6d73 2829 0a20 2020 ave .items(). \n-00057760: 2020 2020 2020 2020 2020 2020 2061 7267 arg\n-00057770: 732e 6170 7065 6e64 2866 272d 6f7b 6b65 s.append(f'-o{ke\n-00057780: 797d 207b 6f70 7469 6f6e 735b 6b65 795d y} {options[key]\n-00057790: 7d27 290a 0a20 2020 2020 2020 2069 6620 }').. if \n-000577a0: 706b 6373 3131 2069 7320 6e6f 7420 4e6f pkcs11 is not No\n-000577b0: 6e65 3a0a 2020 2020 2020 2020 2020 2020 ne:. \n-000577c0: 6172 6773 2e61 7070 656e 6428 6627 2d49 args.append(f'-I\n-000577d0: 7b70 6b63 7331 317d 2729 0a0a 2020 2020 {pkcs11}').. \n-000577e0: 2020 2020 6966 2070 6f72 7420 6973 206e if port is n\n-000577f0: 6f74 204e 6f6e 653a 0a20 2020 2020 2020 ot None:. \n-00057800: 2020 2020 2061 7267 732e 6170 7065 6e64 args.append\n-00057810: 2866 272d 707b 706f 7274 7d27 290a 0a20 (f'-p{port}').. \n-00057820: 2020 2020 2020 2069 6620 6c6f 6769 6e5f if login_\n-00057830: 6e61 6d65 2069 7320 6e6f 7420 4e6f 6e65 name is not None\n-00057840: 3a0a 2020 2020 2020 2020 2020 2020 6172 :. ar\n-00057850: 6773 2e61 7070 656e 6428 6627 2d6c 7b6c gs.append(f'-l{l\n-00057860: 6f67 696e 5f6e 616d 657d 2729 0a0a 2020 ogin_name}').. \n-00057870: 2020 2020 2020 6966 2068 616e 646c 655f if handle_\n-00057880: 686f 7374 5f6b 6579 2061 6e64 2068 6173 host_key and has\n-00057890: 5f66 6561 7475 7265 2827 4b6e 6f77 6e48 _feature('KnownH\n-000578a0: 6f73 7473 436f 6d6d 616e 6427 293a 0a20 ostsCommand'):. \n-000578b0: 2020 2020 2020 2020 2020 2061 7267 732e args.\n-000578c0: 6578 7465 6e64 285b 0a20 2020 2020 2020 extend([. \n-000578d0: 2020 2020 2020 2020 2027 2d6f 272c 2066 '-o', f\n-000578e0: 274b 6e6f 776e 486f 7374 7343 6f6d 6d61 'KnownHostsComma\n-000578f0: 6e64 3d7b 6173 6b70 6173 735f 7061 7468 nd={askpass_path\n-00057900: 7d20 2549 2025 4820 2574 2025 4b20 2566 } %I %H %t %K %f\n-00057910: 272c 0a20 2020 2020 2020 2020 2020 2020 ',. \n-00057920: 2020 2027 2d6f 272c 2027 5374 7269 6374 '-o', 'Strict\n-00057930: 486f 7374 4b65 7943 6865 636b 696e 673d HostKeyChecking=\n-00057940: 7965 7327 2c0a 2020 2020 2020 2020 2020 yes',. \n-00057950: 2020 5d29 0a0a 2020 2020 2020 2020 6167 ]).. ag\n-00057960: 656e 7420 3d20 496e 7465 7261 6374 696f ent = Interactio\n-00057970: 6e41 6765 6e74 285b 696e 7465 7261 6374 nAgent([interact\n-00057980: 696f 6e5f 7265 7370 6f6e 6465 725d 2069 ion_responder] i\n-00057990: 6620 696e 7465 7261 6374 696f 6e5f 7265 f interaction_re\n-000579a0: 7370 6f6e 6465 7220 6973 206e 6f74 204e sponder is not N\n-000579b0: 6f6e 6520 656c 7365 205b 5d29 0a0a 2020 one else []).. \n-000579c0: 2020 2020 2020 2320 5353 485f 4153 4b50 # SSH_ASKP\n-000579d0: 4153 535f 5245 5155 4952 4520 6973 206e ASS_REQUIRE is n\n-000579e0: 6f74 2067 656e 6572 616c 6c79 2061 7661 ot generally ava\n-000579f0: 696c 6162 6c65 2c20 736f 2075 7365 2073 ilable, so use s\n-00057a00: 6574 7369 640a 2020 2020 2020 2020 7072 etsid. pr\n-00057a10: 6f63 6573 7320 3d20 6177 6169 7420 6173 ocess = await as\n-00057a20: 796e 6369 6f2e 6372 6561 7465 5f73 7562 yncio.create_sub\n-00057a30: 7072 6f63 6573 735f 6578 6563 280a 2020 process_exec(. \n-00057a40: 2020 2020 2020 2020 2020 2a28 272f 7573 *('/us\n-00057a50: 722f 6269 6e2f 7373 6827 2c20 2a61 7267 r/bin/ssh', *arg\n-00057a60: 732c 2064 6573 7469 6e61 7469 6f6e 292c s, destination),\n-00057a70: 2065 6e76 3d65 6e76 2c0a 2020 2020 2020 env=env,. \n-00057a80: 2020 2020 2020 7374 6172 745f 6e65 775f start_new_\n-00057a90: 7365 7373 696f 6e3d 5472 7565 2c20 7374 session=True, st\n-00057aa0: 6469 6e3d 6173 796e 6369 6f2e 7375 6270 din=asyncio.subp\n-00057ab0: 726f 6365 7373 2e44 4556 4e55 4c4c 2c0a rocess.DEVNULL,.\n-00057ac0: 2020 2020 2020 2020 2020 2020 7374 646f stdo\n-00057ad0: 7574 3d61 7379 6e63 696f 2e73 7562 7072 ut=asyncio.subpr\n-00057ae0: 6f63 6573 732e 4445 564e 554c 4c2c 2073 ocess.DEVNULL, s\n-00057af0: 7464 6572 723d 6167 656e 742c 2020 2320 tderr=agent, # \n-00057b00: 7479 7065 3a20 6967 6e6f 7265 0a20 2020 type: ignore. \n-00057b10: 2020 2020 2020 2020 2070 7265 6578 6563 preexec\n-00057b20: 5f66 6e3d 6c61 6d62 6461 3a20 7072 6374 _fn=lambda: prct\n-00057b30: 6c28 5052 5f53 4554 5f50 4445 4154 4853 l(PR_SET_PDEATHS\n-00057b40: 4947 2c20 7369 676e 616c 2e53 4947 4b49 IG, signal.SIGKI\n-00057b50: 4c4c 2929 0a0a 2020 2020 2020 2020 2320 LL)).. # \n-00057b60: 5468 6973 2069 7320 7472 6963 6b79 3a20 This is tricky: \n-00057b70: 7765 206e 6565 6420 746f 2063 6c65 616e we need to clean\n-00057b80: 2075 7020 7468 6520 7375 6270 726f 6365 up the subproce\n-00057b90: 7373 2c20 6275 7420 6f6e 6c79 2069 6e20 ss, but only in \n-00057ba0: 6361 7365 0a20 2020 2020 2020 2023 2069 case. # i\n-00057bb0: 6620 6661 696c 7572 652e 2020 4f74 6865 f failure. Othe\n-00057bc0: 7277 6973 652c 2077 6520 6b65 6570 2069 rwise, we keep i\n-00057bd0: 7420 6172 6f75 6e64 2e0a 2020 2020 2020 t around.. \n-00057be0: 2020 7472 793a 0a20 2020 2020 2020 2020 try:. \n-00057bf0: 2020 2061 7761 6974 2061 6765 6e74 2e63 await agent.c\n-00057c00: 6f6d 6d75 6e69 6361 7465 2829 0a20 2020 ommunicate(). \n-00057c10: 2020 2020 2020 2020 2061 7373 6572 7420 assert \n-00057c20: 6f73 2e70 6174 682e 6578 6973 7473 2873 os.path.exists(s\n-00057c30: 656c 662e 5f63 6f6e 7472 6f6c 736f 636b elf._controlsock\n-00057c40: 290a 2020 2020 2020 2020 2020 2020 7365 ). se\n-00057c50: 6c66 2e5f 7072 6f63 6573 7320 3d20 7072 lf._process = pr\n-00057c60: 6f63 6573 730a 2020 2020 2020 2020 6578 ocess. ex\n-00057c70: 6365 7074 2049 6e74 6572 6163 7469 6f6e cept Interaction\n-00057c80: 4572 726f 7220 6173 2065 7863 3a0a 2020 Error as exc:. \n-00057c90: 2020 2020 2020 2020 2020 6177 6169 7420 await \n-00057ca0: 7072 6f63 6573 732e 7761 6974 2829 0a20 process.wait(). \n-00057cb0: 2020 2020 2020 2020 2020 2072 6169 7365 raise\n-00057cc0: 2073 7368 5f65 7272 6f72 732e 6765 745f ssh_errors.get_\n-00057cd0: 6578 6365 7074 696f 6e5f 666f 725f 7373 exception_for_ss\n-00057ce0: 685f 7374 6465 7272 2873 7472 2865 7863 h_stderr(str(exc\n-00057cf0: 2929 2066 726f 6d20 4e6f 6e65 0a20 2020 )) from None. \n-00057d00: 2020 2020 2065 7863 6570 7420 4261 7365 except Base\n-00057d10: 4578 6365 7074 696f 6e3a 0a20 2020 2020 Exception:. \n-00057d20: 2020 2020 2020 2023 2049 6620 7765 2067 # If we g\n-00057d30: 6574 2068 6572 6520 6265 6361 7573 6520 et here because \n-00057d40: 7468 6520 496e 7465 7261 6374 696f 6e48 the InteractionH\n-00057d50: 616e 646c 6572 2072 6169 7365 6420 616e andler raised an\n-00057d60: 0a20 2020 2020 2020 2020 2020 2023 2065 . # e\n-00057d70: 7863 6570 7469 6f6e 2074 6865 6e20 5353 xception then SS\n-00057d80: 4820 6d69 6768 7420 7374 696c 6c20 6265 H might still be\n-00057d90: 2072 756e 6e69 6e67 2c20 616e 6420 6d61 running, and ma\n-00057da0: 7920 6576 656e 2061 7474 656d 7074 0a20 y even attempt. \n-00057db0: 2020 2020 2020 2020 2020 2023 2066 7572 # fur\n-00057dc0: 7468 6572 2069 6e74 6572 6163 7469 6f6e ther interaction\n-00057dd0: 7320 2869 653a 2032 6e64 2061 7474 656d s (ie: 2nd attem\n-00057de0: 7074 2066 6f72 2070 6173 7377 6f72 6429 pt for password)\n-00057df0: 2e20 2057 6520 616c 7265 6164 790a 2020 . We already. \n-00057e00: 2020 2020 2020 2020 2020 2320 6861 7665 # have\n-00057e10: 206f 7572 2065 7863 6570 7469 6f6e 2061 our exception a\n-00057e20: 6e64 2064 6f6e 2774 206e 6565 6420 616e nd don't need an\n-00057e30: 7920 6d6f 7265 2069 6e66 6f2e 2020 4b69 y more info. Ki\n-00057e40: 6c6c 2069 742e 0a20 2020 2020 2020 2020 ll it.. \n-00057e50: 2020 2074 7279 3a0a 2020 2020 2020 2020 try:. \n-00057e60: 2020 2020 2020 2020 7072 6f63 6573 732e process.\n-00057e70: 6b69 6c6c 2829 0a20 2020 2020 2020 2020 kill(). \n-00057e80: 2020 2065 7863 6570 7420 5072 6f63 6573 except Proces\n-00057e90: 734c 6f6f 6b75 7045 7272 6f72 3a0a 2020 sLookupError:. \n-00057ea0: 2020 2020 2020 2020 2020 2020 2020 7061 pa\n-00057eb0: 7373 2020 2320 616c 7265 6164 7920 6578 ss # already ex\n-00057ec0: 6974 6564 3f20 2067 6f6f 642e 0a20 2020 ited? good.. \n-00057ed0: 2020 2020 2020 2020 2061 7761 6974 2070 await p\n-00057ee0: 726f 6365 7373 2e77 6169 7428 290a 2020 rocess.wait(). \n-00057ef0: 2020 2020 2020 2020 2020 7261 6973 650a raise.\n-00057f00: 0a20 2020 2064 6566 2069 735f 636f 6e6e . def is_conn\n-00057f10: 6563 7465 6428 7365 6c66 2920 2d3e 2062 ected(self) -> b\n-00057f20: 6f6f 6c3a 0a20 2020 2020 2020 2072 6574 ool:. ret\n-00057f30: 7572 6e20 7365 6c66 2e5f 7072 6f63 6573 urn self._proces\n-00057f40: 7320 6973 206e 6f74 204e 6f6e 650a 0a20 s is not None.. \n-00057f50: 2020 2061 7379 6e63 2064 6566 2077 6169 async def wai\n-00057f60: 7428 7365 6c66 2920 2d3e 204e 6f6e 653a t(self) -> None:\n-00057f70: 0a20 2020 2020 2020 2061 7373 6572 7420 . assert \n-00057f80: 7365 6c66 2e5f 7072 6f63 6573 7320 6973 self._process is\n-00057f90: 206e 6f74 204e 6f6e 650a 2020 2020 2020 not None. \n-00057fa0: 2020 6177 6169 7420 7365 6c66 2e5f 7072 await self._pr\n-00057fb0: 6f63 6573 732e 7761 6974 2829 0a0a 2020 ocess.wait().. \n-00057fc0: 2020 6465 6620 6578 6974 2873 656c 6629 def exit(self)\n-00057fd0: 202d 3e20 4e6f 6e65 3a0a 2020 2020 2020 -> None:. \n-00057fe0: 2020 6173 7365 7274 2073 656c 662e 5f70 assert self._p\n-00057ff0: 726f 6365 7373 2069 7320 6e6f 7420 4e6f rocess is not No\n-00058000: 6e65 0a20 2020 2020 2020 2073 656c 662e ne. self.\n-00058010: 5f70 726f 6365 7373 2e74 6572 6d69 6e61 _process.termina\n-00058020: 7465 2829 0a0a 2020 2020 6173 796e 6320 te().. async \n-00058030: 6465 6620 6469 7363 6f6e 6e65 6374 2873 def disconnect(s\n-00058040: 656c 6629 202d 3e20 4e6f 6e65 3a0a 2020 elf) -> None:. \n-00058050: 2020 2020 2020 7365 6c66 2e65 7869 7428 self.exit(\n-00058060: 290a 2020 2020 2020 2020 6177 6169 7420 ). await \n-00058070: 7365 6c66 2e77 6169 7428 290a 0a20 2020 self.wait().. \n-00058080: 2023 204c 6175 6e63 6869 6e67 206f 6620 # Launching of \n-00058090: 7072 6f63 6573 7365 730a 2020 2020 6465 processes. de\n-000580a0: 6620 7772 6170 5f73 7562 7072 6f63 6573 f wrap_subproces\n-000580b0: 735f 6172 6773 2873 656c 662c 2061 7267 s_args(self, arg\n-000580c0: 733a 2053 6571 7565 6e63 655b 7374 725d s: Sequence[str]\n-000580d0: 2920 2d3e 2053 6571 7565 6e63 655b 7374 ) -> Sequence[st\n-000580e0: 725d 3a0a 2020 2020 2020 2020 6173 7365 r]:. asse\n-000580f0: 7274 2073 656c 662e 5f63 6f6e 7472 6f6c rt self._control\n-00058100: 736f 636b 2069 7320 6e6f 7420 4e6f 6e65 sock is not None\n-00058110: 0a20 2020 2020 2020 2023 2031 2e20 5765 . # 1. We\n-00058120: 2073 7065 6369 6679 2074 6865 2068 6f73 specify the hos\n-00058130: 746e 616d 6520 6173 2074 6865 2065 6d70 tname as the emp\n-00058140: 7479 2073 7472 696e 673a 2069 7420 7769 ty string: it wi\n-00058150: 6c6c 2062 6520 6967 6e6f 7265 640a 2020 ll be ignored. \n-00058160: 2020 2020 2020 2320 2020 2077 6865 6e20 # when \n-00058170: 7373 6820 6973 2074 7279 696e 6720 746f ssh is trying to\n-00058180: 2075 7365 2074 6865 2063 6f6e 7472 6f6c use the control\n-00058190: 2073 6f63 6b65 742c 2062 7574 2069 6e20 socket, but in \n-000581a0: 6361 7365 2074 6865 0a20 2020 2020 2020 case the. \n-000581b0: 2023 2020 2020 736f 636b 6574 2068 6173 # socket has\n-000581c0: 2073 746f 7070 6564 2077 6f72 6b69 6e67 stopped working\n-000581d0: 2c20 7373 6820 7769 6c6c 2074 7279 2074 , ssh will try t\n-000581e0: 6f20 6661 6c6c 2062 6163 6b20 746f 2064 o fall back to d\n-000581f0: 6972 6563 746c 790a 2020 2020 2020 2020 irectly. \n-00058200: 2320 2020 2063 6f6e 6e65 6374 696e 672c # connecting,\n-00058210: 2069 6e20 7768 6963 6820 6361 7365 2061 in which case a\n-00058220: 6e20 656d 7074 7920 686f 7374 6e61 6d65 n empty hostname\n-00058230: 2077 696c 6c20 7072 6576 656e 7420 7468 will prevent th\n-00058240: 6174 2e0a 2020 2020 2020 2020 2320 322e at.. # 2.\n-00058250: 2057 6520 6e65 6564 2074 6f20 7175 6f74 We need to quot\n-00058260: 6520 7468 6520 6172 6775 6d65 6e74 7320 e the arguments \n-00058270: e280 9420 7373 6820 7769 6c6c 2070 6173 ... ssh will pas\n-00058280: 7465 2074 6865 6d20 746f 6765 7468 6572 te them together\n-00058290: 0a20 2020 2020 2020 2023 2020 2020 7573 . # us\n-000582a0: 696e 6720 6f6e 6c79 2073 7061 6365 732c ing only spaces,\n-000582b0: 2065 7865 6375 7469 6e67 2074 6865 2072 executing the r\n-000582c0: 6573 756c 7420 7573 696e 6720 7468 6520 esult using the \n-000582d0: 7573 6572 2773 2073 6865 6c6c 2e0a 2020 user's shell.. \n-000582e0: 2020 2020 2020 7265 7475 726e 2028 2773 return ('s\n-000582f0: 7368 272c 2027 2d53 272c 2073 656c 662e sh', '-S', self.\n-00058300: 5f63 6f6e 7472 6f6c 736f 636b 2c20 2727 _controlsock, ''\n-00058310: 2c20 2a6d 6170 2873 686c 6578 2e71 756f , *map(shlex.quo\n-00058320: 7465 2c20 6172 6773 2929 0a27 2727 2e65 te, args)).'''.e\n-00058330: 6e63 6f64 6528 2775 7466 2d38 2729 2c0a ncode('utf-8'),.\n-00058340: 2020 2763 6f63 6b70 6974 2f5f 7665 6e64 'cockpit/_vend\n-00058350: 6f72 2f66 6572 6e79 2f74 7261 6e73 706f or/ferny/transpo\n-00058360: 7274 2e70 7927 3a20 6272 2727 2723 2066 rt.py': br'''# f\n-00058370: 6572 6e79 202d 2061 7379 6e63 696f 2053 erny - asyncio S\n-00058380: 5348 2063 6c69 656e 7420 6c69 6272 6172 SH client librar\n-00058390: 792c 2075 7369 6e67 2073 7368 2831 290a y, using ssh(1).\n-000583a0: 230a 2320 436f 7079 7269 6768 7420 2843 #.# Copyright (C\n-000583b0: 2920 3230 3233 2041 6c6c 6973 6f6e 204b ) 2023 Allison K\n-000583c0: 6172 6c69 7473 6b61 7961 203c 616c 6c69 arlitskaya <alli\n-000583d0: 736f 6e2e 6b61 726c 6974 736b 6179 6140 son.karlitskaya@\n-000583e0: 7265 6468 6174 2e63 6f6d 3e0a 230a 2320 redhat.com>.#.# \n-000583f0: 5468 6973 2070 726f 6772 616d 2069 7320 This program is \n-00058400: 6672 6565 2073 6f66 7477 6172 653a 2079 free software: y\n-00058410: 6f75 2063 616e 2072 6564 6973 7472 6962 ou can redistrib\n-00058420: 7574 6520 6974 2061 6e64 2f6f 7220 6d6f ute it and/or mo\n-00058430: 6469 6679 0a23 2069 7420 756e 6465 7220 dify.# it under \n-00058440: 7468 6520 7465 726d 7320 6f66 2074 6865 the terms of the\n-00058450: 2047 4e55 2047 656e 6572 616c 2050 7562 GNU General Pub\n-00058460: 6c69 6320 4c69 6365 6e73 6520 6173 2070 lic License as p\n-00058470: 7562 6c69 7368 6564 2062 790a 2320 7468 ublished by.# th\n-00058480: 6520 4672 6565 2053 6f66 7477 6172 6520 e Free Software \n-00058490: 466f 756e 6461 7469 6f6e 2c20 6569 7468 Foundation, eith\n-000584a0: 6572 2076 6572 7369 6f6e 2033 206f 6620 er version 3 of \n-000584b0: 7468 6520 4c69 6365 6e73 652c 206f 720a the License, or.\n-000584c0: 2320 2861 7420 796f 7572 206f 7074 696f # (at your optio\n-000584d0: 6e29 2061 6e79 206c 6174 6572 2076 6572 n) any later ver\n-000584e0: 7369 6f6e 2e0a 230a 2320 5468 6973 2070 sion..#.# This p\n-000584f0: 726f 6772 616d 2069 7320 6469 7374 7269 rogram is distri\n-00058500: 6275 7465 6420 696e 2074 6865 2068 6f70 buted in the hop\n-00058510: 6520 7468 6174 2069 7420 7769 6c6c 2062 e that it will b\n-00058520: 6520 7573 6566 756c 2c0a 2320 6275 7420 e useful,.# but \n-00058530: 5749 5448 4f55 5420 414e 5920 5741 5252 WITHOUT ANY WARR\n-00058540: 414e 5459 3b20 7769 7468 6f75 7420 6576 ANTY; without ev\n-00058550: 656e 2074 6865 2069 6d70 6c69 6564 2077 en the implied w\n-00058560: 6172 7261 6e74 7920 6f66 0a23 204d 4552 arranty of.# MER\n-00058570: 4348 414e 5441 4249 4c49 5459 206f 7220 CHANTABILITY or \n-00058580: 4649 544e 4553 5320 464f 5220 4120 5041 FITNESS FOR A PA\n-00058590: 5254 4943 554c 4152 2050 5552 504f 5345 RTICULAR PURPOSE\n-000585a0: 2e20 2053 6565 2074 6865 0a23 2047 4e55 . See the.# GNU\n-000585b0: 2047 656e 6572 616c 2050 7562 6c69 6320 General Public \n-000585c0: 4c69 6365 6e73 6520 666f 7220 6d6f 7265 License for more\n-000585d0: 2064 6574 6169 6c73 2e0a 230a 2320 596f details..#.# Yo\n-000585e0: 7520 7368 6f75 6c64 2068 6176 6520 7265 u should have re\n-000585f0: 6365 6976 6564 2061 2063 6f70 7920 6f66 ceived a copy of\n-00058600: 2074 6865 2047 4e55 2047 656e 6572 616c the GNU General\n-00058610: 2050 7562 6c69 6320 4c69 6365 6e73 650a Public License.\n-00058620: 2320 616c 6f6e 6720 7769 7468 2074 6869 # along with thi\n-00058630: 7320 7072 6f67 7261 6d2e 2020 4966 206e s program. If n\n-00058640: 6f74 2c20 7365 6520 3c68 7474 703a 2f2f ot, see <http://\n-00058650: 7777 772e 676e 752e 6f72 672f 6c69 6365 www.gnu.org/lice\n-00058660: 6e73 6573 2f3e 2e0a 0a69 6d70 6f72 7420 nses/>...import \n-00058670: 6173 796e 6369 6f0a 696d 706f 7274 2063 asyncio.import c\n-00058680: 6f6e 7465 7874 6c69 620a 696d 706f 7274 ontextlib.import\n-00058690: 206c 6f67 6769 6e67 0a69 6d70 6f72 7420 logging.import \n-000586a0: 7479 7069 6e67 0a66 726f 6d20 7479 7069 typing.from typi\n-000586b0: 6e67 2069 6d70 6f72 7420 416e 792c 2043 ng import Any, C\n-000586c0: 616c 6c61 626c 652c 2049 7465 7261 626c allable, Iterabl\n-000586d0: 652c 2053 6571 7565 6e63 652c 2054 7970 e, Sequence, Typ\n-000586e0: 6556 6172 0a0a 6672 6f6d 202e 696e 7465 eVar..from .inte\n-000586f0: 7261 6374 696f 6e5f 6167 656e 7420 696d raction_agent im\n-00058700: 706f 7274 2049 6e74 6572 6163 7469 6f6e port Interaction\n-00058710: 4167 656e 742c 2049 6e74 6572 6163 7469 Agent, Interacti\n-00058720: 6f6e 4861 6e64 6c65 722c 2067 6574 5f72 onHandler, get_r\n-00058730: 756e 6e69 6e67 5f6c 6f6f 700a 6672 6f6d unning_loop.from\n-00058740: 202e 7373 685f 6572 726f 7273 2069 6d70 .ssh_errors imp\n-00058750: 6f72 7420 6765 745f 6578 6365 7074 696f ort get_exceptio\n-00058760: 6e5f 666f 725f 7373 685f 7374 6465 7272 n_for_ssh_stderr\n-00058770: 0a0a 6c6f 6767 6572 203d 206c 6f67 6769 ..logger = loggi\n-00058780: 6e67 2e67 6574 4c6f 6767 6572 285f 5f6e ng.getLogger(__n\n-00058790: 616d 655f 5f29 0a0a 5020 3d20 5479 7065 ame__)..P = Type\n-000587a0: 5661 7228 2750 272c 2062 6f75 6e64 3d61 Var('P', bound=a\n-000587b0: 7379 6e63 696f 2e50 726f 746f 636f 6c29 syncio.Protocol)\n-000587c0: 0a0a 0a63 6c61 7373 2053 7562 7072 6f63 ...class Subproc\n-000587d0: 6573 7345 7272 6f72 2845 7863 6570 7469 essError(Excepti\n-000587e0: 6f6e 293a 0a20 2020 2072 6574 7572 6e63 on):. returnc\n-000587f0: 6f64 653a 2069 6e74 0a20 2020 2073 7464 ode: int. std\n-00058800: 6572 723a 2073 7472 0a0a 2020 2020 6465 err: str.. de\n-00058810: 6620 5f5f 696e 6974 5f5f 2873 656c 662c f __init__(self,\n-00058820: 2072 6574 7572 6e63 6f64 653a 2069 6e74 returncode: int\n-00058830: 2c20 7374 6465 7272 3a20 7374 7229 202d , stderr: str) -\n-00058840: 3e20 4e6f 6e65 3a0a 2020 2020 2020 2020 > None:. \n-00058850: 7375 7065 7228 292e 5f5f 696e 6974 5f5f super().__init__\n-00058860: 2872 6574 7572 6e63 6f64 652c 2073 7464 (returncode, std\n-00058870: 6572 7229 0a20 2020 2020 2020 2073 656c err). sel\n-00058880: 662e 7265 7475 726e 636f 6465 203d 2072 f.returncode = r\n-00058890: 6574 7572 6e63 6f64 650a 2020 2020 2020 eturncode. \n-000588a0: 2020 7365 6c66 2e73 7464 6572 7220 3d20 self.stderr = \n-000588b0: 7374 6465 7272 0a0a 0a63 6c61 7373 2046 stderr...class F\n-000588c0: 6572 6e79 5472 616e 7370 6f72 7428 6173 ernyTransport(as\n-000588d0: 796e 6369 6f2e 5472 616e 7370 6f72 742c yncio.Transport,\n-000588e0: 2061 7379 6e63 696f 2e53 7562 7072 6f63 asyncio.Subproc\n-000588f0: 6573 7350 726f 746f 636f 6c29 3a0a 2020 essProtocol):. \n-00058900: 2020 5f61 6765 6e74 3a20 496e 7465 7261 _agent: Intera\n-00058910: 6374 696f 6e41 6765 6e74 0a20 2020 205f ctionAgent. _\n-00058920: 6578 6563 5f74 6173 6b3a 2027 6173 796e exec_task: 'asyn\n-00058930: 6369 6f2e 5461 736b 5b74 7570 6c65 5b61 cio.Task[tuple[a\n-00058940: 7379 6e63 696f 2e53 7562 7072 6f63 6573 syncio.Subproces\n-00058950: 7354 7261 6e73 706f 7274 2c20 4665 726e sTransport, Fern\n-00058960: 7954 7261 6e73 706f 7274 5d5d 270a 2020 yTransport]]'. \n-00058970: 2020 5f69 735f 7373 683a 2062 6f6f 6c0a _is_ssh: bool.\n-00058980: 2020 2020 5f70 726f 746f 636f 6c3a 2061 _protocol: a\n-00058990: 7379 6e63 696f 2e50 726f 746f 636f 6c0a syncio.Protocol.\n-000589a0: 2020 2020 5f70 726f 746f 636f 6c5f 6469 _protocol_di\n-000589b0: 7363 6f6e 6e65 6374 6564 3a20 626f 6f6c sconnected: bool\n-000589c0: 203d 2046 616c 7365 0a0a 2020 2020 2320 = False.. # \n-000589d0: 5468 6573 6520 6765 7420 696e 6974 6961 These get initia\n-000589e0: 6c69 7a65 6420 696e 2063 6f6e 6e65 6374 lized in connect\n-000589f0: 696f 6e5f 6d61 6465 2829 2061 6e64 206f ion_made() and o\n-00058a00: 6e63 6520 7365 742c 206e 6576 6572 2067 nce set, never g\n-00058a10: 6574 2075 6e73 6574 2e0a 2020 2020 5f73 et unset.. _s\n-00058a20: 7562 7072 6f63 6573 735f 7472 616e 7370 ubprocess_transp\n-00058a30: 6f72 743a 2027 6173 796e 6369 6f2e 5375 ort: 'asyncio.Su\n-00058a40: 6270 726f 6365 7373 5472 616e 7370 6f72 bprocessTranspor\n-00058a50: 7420 7c20 4e6f 6e65 2720 3d20 4e6f 6e65 t | None' = None\n-00058a60: 0a20 2020 205f 7374 6469 6e5f 7472 616e . _stdin_tran\n-00058a70: 7370 6f72 743a 2027 6173 796e 6369 6f2e sport: 'asyncio.\n-00058a80: 5772 6974 6554 7261 6e73 706f 7274 207c WriteTransport |\n-00058a90: 204e 6f6e 6527 203d 204e 6f6e 650a 2020 None' = None. \n-00058aa0: 2020 5f73 7464 6f75 745f 7472 616e 7370 _stdout_transp\n-00058ab0: 6f72 743a 2027 6173 796e 6369 6f2e 5265 ort: 'asyncio.Re\n-00058ac0: 6164 5472 616e 7370 6f72 7420 7c20 4e6f adTransport | No\n-00058ad0: 6e65 2720 3d20 4e6f 6e65 0a0a 2020 2020 ne' = None.. \n-00058ae0: 2320 5765 2072 6563 6f72 6420 6576 656e # We record even\n-00058af0: 7473 2074 6861 7420 6d69 6768 7420 6275 ts that might bu\n-00058b00: 696c 6420 746f 7761 7264 7320 6120 636f ild towards a co\n-00058b10: 6e6e 6563 7469 6f6e 2074 6572 6d69 6e61 nnection termina\n-00058b20: 7469 6f6e 2068 6572 650a 2020 2020 2320 tion here. # \n-00058b30: 616e 6420 636f 6e73 6964 6572 2074 6865 and consider the\n-00058b40: 6d20 6672 6f6d 205f 636f 6e73 6964 6572 m from _consider\n-00058b50: 5f64 6973 636f 6e6e 6563 7428 2920 696e _disconnect() in\n-00058b60: 206f 7264 6572 2074 6f20 7472 7920 746f order to try to\n-00058b70: 2067 6574 2074 6865 0a20 2020 2023 2062 get the. # b\n-00058b80: 6573 7420 706f 7373 6962 6c65 2045 7863 est possible Exc\n-00058b90: 6570 7469 6f6e 2066 6f72 2074 6865 2070 eption for the p\n-00058ba0: 726f 746f 636f 6c2c 2072 6174 6865 7220 rotocol, rather \n-00058bb0: 7468 616e 206a 7573 7420 7461 6b69 6e67 than just taking\n-00058bc0: 2074 6865 0a20 2020 2023 2066 6972 7374 the. # first\n-00058bd0: 206f 6e65 2028 7768 6963 6820 6973 206c one (which is l\n-00058be0: 696b 656c 7920 746f 2062 6520 736f 6d65 ikely to be some\n-00058bf0: 7768 6174 2072 616e 646f 6d29 2e0a 2020 what random).. \n-00058c00: 2020 5f65 7863 6570 7469 6f6e 3a20 2745 _exception: 'E\n-00058c10: 7863 6570 7469 6f6e 207c 204e 6f6e 6527 xception | None'\n-00058c20: 203d 204e 6f6e 650a 2020 2020 5f73 7464 = None. _std\n-00058c30: 6572 725f 6f75 7470 7574 3a20 2773 7472 err_output: 'str\n-00058c40: 207c 204e 6f6e 6527 203d 204e 6f6e 650a | None' = None.\n-00058c50: 2020 2020 5f72 6574 7572 6e63 6f64 653a _returncode:\n-00058c60: 2027 696e 7420 7c20 4e6f 6e65 2720 3d20 'int | None' = \n-00058c70: 4e6f 6e65 0a20 2020 205f 7472 616e 7370 None. _transp\n-00058c80: 6f72 745f 6469 7363 6f6e 6e65 6374 6564 ort_disconnected\n-00058c90: 3a20 626f 6f6c 203d 2046 616c 7365 0a20 : bool = False. \n-00058ca0: 2020 205f 636c 6f73 6564 3a20 626f 6f6c _closed: bool\n-00058cb0: 203d 2046 616c 7365 0a0a 2020 2020 4063 = False.. @c\n-00058cc0: 6c61 7373 6d65 7468 6f64 0a20 2020 2064 lassmethod. d\n-00058cd0: 6566 2073 7061 776e 280a 2020 2020 2020 ef spawn(. \n-00058ce0: 2020 636c 733a 2027 7479 7065 5b74 7970 cls: 'type[typ\n-00058cf0: 696e 672e 5365 6c66 5d27 2c0a 2020 2020 ing.Self]',. \n-00058d00: 2020 2020 7072 6f74 6f63 6f6c 5f66 6163 protocol_fac\n-00058d10: 746f 7279 3a20 4361 6c6c 6162 6c65 5b5b tory: Callable[[\n-00058d20: 5d2c 2050 5d2c 0a20 2020 2020 2020 2061 ], P],. a\n-00058d30: 7267 733a 2053 6571 7565 6e63 655b 7374 rgs: Sequence[st\n-00058d40: 725d 2c0a 2020 2020 2020 2020 6c6f 6f70 r],. loop\n-00058d50: 3a20 2761 7379 6e63 696f 2e41 6273 7472 : 'asyncio.Abstr\n-00058d60: 6163 7445 7665 6e74 4c6f 6f70 207c 204e actEventLoop | N\n-00058d70: 6f6e 6527 203d 204e 6f6e 652c 0a20 2020 one' = None,. \n-00058d80: 2020 2020 2069 6e74 6572 6163 7469 6f6e interaction\n-00058d90: 5f68 616e 646c 6572 733a 2053 6571 7565 _handlers: Seque\n-00058da0: 6e63 655b 496e 7465 7261 6374 696f 6e48 nce[InteractionH\n-00058db0: 616e 646c 6572 5d20 3d20 2829 2c0a 2020 andler] = (),. \n-00058dc0: 2020 2020 2020 6973 5f73 7368 3a20 626f is_ssh: bo\n-00058dd0: 6f6c 203d 2054 7275 652c 0a20 2020 2020 ol = True,. \n-00058de0: 2020 202a 2a6b 7761 7267 733a 2041 6e79 **kwargs: Any\n-00058df0: 0a20 2020 2029 202d 3e20 2774 7570 6c65 . ) -> 'tuple\n-00058e00: 5b74 7970 696e 672e 5365 6c66 2c20 505d [typing.Self, P]\n-00058e10: 273a 0a20 2020 2020 2020 2022 2222 436f ':. \"\"\"Co\n-00058e20: 6e6e 6563 7473 2061 2046 6572 6e79 5472 nnects a FernyTr\n-00058e30: 616e 7370 6f72 7420 746f 2061 2070 726f ansport to a pro\n-00058e40: 746f 636f 6c2c 2075 7369 6e67 2074 6865 tocol, using the\n-00058e50: 2067 6976 656e 2063 6f6d 6d61 6e64 2e0a given command..\n-00058e60: 0a20 2020 2020 2020 2054 6869 7320 7370 . This sp\n-00058e70: 6177 6e73 2061 6e20 6578 7465 726e 616c awns an external\n-00058e80: 2063 6f6d 6d61 6e64 2061 6e64 2063 6f6e command and con\n-00058e90: 6e65 6374 7320 7468 6520 7374 6469 6e20 nects the stdin \n-00058ea0: 616e 6420 7374 646f 7574 206f 660a 2020 and stdout of. \n-00058eb0: 2020 2020 2020 7468 6520 636f 6d6d 616e the comman\n-00058ec0: 6420 746f 2074 6865 2070 726f 746f 636f d to the protoco\n-00058ed0: 6c20 7265 7475 726e 6564 2062 7920 7468 l returned by th\n-00058ee0: 6520 6661 6374 6f72 792e 0a0a 2020 2020 e factory... \n-00058ef0: 2020 2020 416e 2069 6e73 7461 6e63 6520 An instance \n-00058f00: 6f66 2066 6572 6e79 2e49 6e74 6572 6163 of ferny.Interac\n-00058f10: 7469 6f6e 4167 656e 7420 6973 2063 7265 tionAgent is cre\n-00058f20: 6174 6564 2061 6e64 2061 7474 6163 6865 ated and attache\n-00058f30: 6420 746f 2074 6865 0a20 2020 2020 2020 d to the. \n-00058f40: 2073 7464 6572 7220 6f66 2074 6865 2073 stderr of the s\n-00058f50: 7061 776e 6564 2070 726f 6365 7373 2c20 pawned process, \n-00058f60: 7573 696e 6720 7468 6520 7072 6f76 6964 using the provid\n-00058f70: 6564 2068 616e 646c 6572 732e 2020 4974 ed handlers. It\n-00058f80: 2069 7320 7468 650a 2020 2020 2020 2020 is the. \n-00058f90: 7265 7370 6f6e 7369 6269 6c69 7479 206f responsibility o\n-00058fa0: 6620 7468 6520 6361 6c6c 6572 2074 6f20 f the caller to \n-00058fb0: 656e 7375 7265 2074 6861 743a 0a20 2020 ensure that:. \n-00058fc0: 2020 2020 2020 202d 2061 2060 6665 726e - a `fern\n-00058fd0: 792d 6173 6b70 6173 7360 2063 6c69 656e y-askpass` clien\n-00058fe0: 7420 7072 6f67 7261 6d20 6973 2069 6e73 t program is ins\n-00058ff0: 7461 6c6c 6564 2073 6f6d 6577 6865 7265 talled somewhere\n-00059000: 3b20 616e 640a 2020 2020 2020 2020 2020 ; and. \n-00059010: 2d20 616e 7920 7265 6c65 7661 6e74 2063 - any relevant c\n-00059020: 6f6d 6d61 6e64 2d6c 696e 6520 6172 6775 ommand-line argu\n-00059030: 6d65 6e74 7320 6f72 2065 6e76 6972 6f6e ments or environ\n-00059040: 6d65 6e74 2076 6172 6961 626c 6573 2061 ment variables a\n-00059050: 7265 0a20 2020 2020 2020 2020 2020 2070 re. p\n-00059060: 6173 7365 6420 636f 7272 6563 746c 7920 assed correctly \n-00059070: 746f 2074 6865 2070 726f 6772 616d 2074 to the program t\n-00059080: 6f20 6265 2073 7061 776e 6564 0a0a 2020 o be spawned.. \n-00059090: 2020 2020 2020 5468 6973 2066 756e 6374 This funct\n-000590a0: 696f 6e20 7265 7475 726e 7320 696d 6d65 ion returns imme\n-000590b0: 6469 6174 656c 7920 616e 6420 6e65 7665 diately and neve\n-000590c0: 7220 7261 6973 6573 2065 7863 6570 7469 r raises excepti\n-000590d0: 6f6e 732c 2061 7373 756d 696e 670a 2020 ons, assuming. \n-000590e0: 2020 2020 2020 616c 6c20 7072 6563 6f6e all precon\n-000590f0: 6469 7469 6f6e 7320 6172 6520 6d65 742e ditions are met.\n-00059100: 0a0a 2020 2020 2020 2020 4966 2073 7061 .. If spa\n-00059110: 776e 696e 6720 7468 6520 7072 6f63 6573 wning the proces\n-00059120: 7320 6661 696c 7320 7468 656e 2063 6f6e s fails then con\n-00059130: 6e65 6374 696f 6e5f 6c6f 7374 2829 2077 nection_lost() w\n-00059140: 696c 6c20 6265 0a20 2020 2020 2020 2063 ill be. c\n-00059150: 616c 6c65 6420 7769 7468 2074 6865 2072 alled with the r\n-00059160: 656c 6576 616e 7420 4f53 4572 726f 722c elevant OSError,\n-00059170: 2065 7665 6e20 6265 666f 7265 2063 6f6e even before con\n-00059180: 6e65 6374 696f 6e5f 6d61 6465 2829 2069 nection_made() i\n-00059190: 730a 2020 2020 2020 2020 6361 6c6c 6564 s. called\n-000591a0: 2e20 2054 6869 7320 6973 2073 6f6d 6577 . This is somew\n-000591b0: 6861 7420 6e6f 6e2d 7374 616e 6461 7264 hat non-standard\n-000591c0: 2062 6568 6176 696f 7572 2c20 6275 7420 behaviour, but \n-000591d0: 6973 2074 6865 2065 6173 6965 7374 0a20 is the easiest. \n-000591e0: 2020 2020 2020 2077 6179 2074 6f20 7265 way to re\n-000591f0: 706f 7274 2074 6865 7365 2065 7272 6f72 port these error\n-00059200: 7320 7769 7468 6f75 7420 6d61 6b69 6e67 s without making\n-00059210: 2074 6869 7320 6675 6e63 7469 6f6e 2061 this function a\n-00059220: 7379 6e63 2e0a 0a20 2020 2020 2020 204f sync... O\n-00059230: 6e63 6520 7468 6520 7072 6f63 6573 7320 nce the process \n-00059240: 6973 2073 7563 6365 7373 6675 6c6c 7920 is successfully \n-00059250: 6578 6563 7574 6564 2c20 636f 6e6e 6563 executed, connec\n-00059260: 7469 6f6e 5f6d 6164 6528 2920 7769 6c6c tion_made() will\n-00059270: 2062 650a 2020 2020 2020 2020 6361 6c6c be. call\n-00059280: 6564 2061 6e64 2074 6865 2074 7261 6e73 ed and the trans\n-00059290: 706f 7274 2063 616e 2062 6520 7573 6564 port can be used\n-000592a0: 2061 7320 6e6f 726d 616c 2e20 2063 6f6e as normal. con\n-000592b0: 6e65 6374 696f 6e5f 6c6f 7374 2829 2077 nection_lost() w\n-000592c0: 696c 6c0a 2020 2020 2020 2020 6265 2063 ill. be c\n-000592d0: 616c 6c65 6420 6966 2074 6865 2070 726f alled if the pro\n-000592e0: 6365 7373 2065 7869 7473 206f 7220 616e cess exits or an\n-000592f0: 6f74 6865 7220 6572 726f 7220 6f63 6375 other error occu\n-00059300: 7273 2e0a 0a20 2020 2020 2020 2054 6865 rs... The\n-00059310: 2072 6574 7572 6e20 7661 6c75 6520 6f66 return value of\n-00059320: 2074 6869 7320 6675 6e63 7469 6f6e 2069 this function i\n-00059330: 7320 7468 6520 7472 616e 7370 6f72 742c s the transport,\n-00059340: 2062 7574 2069 7420 6578 6973 7473 2069 but it exists i\n-00059350: 6e20 610a 2020 2020 2020 2020 7365 6d69 n a. semi\n-00059360: 2d69 6e69 7469 616c 697a 6564 2073 7461 -initialized sta\n-00059370: 7465 2e20 2059 6f75 2063 616e 2063 616c te. You can cal\n-00059380: 6c20 2e63 6c6f 7365 2829 206f 6e20 6974 l .close() on it\n-00059390: 2c20 6275 7420 6e6f 7468 696e 6720 656c , but nothing el\n-000593a0: 7365 2e0a 2020 2020 2020 2020 4f6e 6365 se.. Once\n-000593b0: 202e 636f 6e6e 6563 7469 6f6e 5f6d 6164 .connection_mad\n-000593c0: 6528 2920 6973 2063 616c 6c65 642c 2079 e() is called, y\n-000593d0: 6f75 2063 616e 2063 616c 6c20 616c 6c20 ou can call all \n-000593e0: 7468 6520 6f74 6865 720a 2020 2020 2020 the other. \n-000593f0: 2020 6675 6e63 7469 6f6e 732e 0a0a 2020 functions... \n-00059400: 2020 2020 2020 4166 7465 7220 796f 7520 After you \n-00059410: 6361 6c6c 2074 6869 7320 6675 6e63 7469 call this functi\n-00059420: 6f6e 2c20 602e 636f 6e6e 6563 7469 6f6e on, `.connection\n-00059430: 5f6c 6f73 7428 2960 2077 696c 6c20 6265 _lost()` will be\n-00059440: 2063 616c 6c65 6420 6f6e 0a20 2020 2020 called on. \n-00059450: 2020 2079 6f75 7220 5072 6f74 6f63 6f6c your Protocol\n-00059460: 2c20 6578 6163 746c 7920 6f6e 6365 2c20 , exactly once, \n-00059470: 6e6f 206d 6174 7465 7220 7768 6174 2e20 no matter what. \n-00059480: 2055 6e74 696c 2074 6861 7420 6861 7070 Until that happ\n-00059490: 656e 732c 2079 6f75 0a20 2020 2020 2020 ens, you. \n-000594a0: 2061 7265 2072 6573 706f 6e73 6962 6c65 are responsible\n-000594b0: 2066 6f72 2068 6f6c 6469 6e67 2061 2072 for holding a r\n-000594c0: 6566 6572 656e 6365 2074 6f20 7468 6520 eference to the \n-000594d0: 7265 7475 726e 6564 2074 7261 6e73 706f returned transpo\n-000594e0: 7274 2e0a 0a20 2020 2020 2020 203a 7061 rt... :pa\n-000594f0: 7261 6d20 6172 6773 3a20 7468 6520 6675 ram args: the fu\n-00059500: 6c6c 2061 7267 7620 6f66 2074 6865 2063 ll argv of the c\n-00059510: 6f6d 6d61 6e64 2074 6f20 7370 6177 6e0a ommand to spawn.\n-00059520: 2020 2020 2020 2020 3a70 6172 616d 206c :param l\n-00059530: 6f6f 703a 2074 6865 2065 7665 6e74 206c oop: the event l\n-00059540: 6f6f 7020 746f 2075 7365 2e20 2049 6620 oop to use. If \n-00059550: 6e6f 6e65 2069 7320 7072 6f76 6964 6564 none is provided\n-00059560: 2c20 7765 2075 7365 2074 6865 0a20 2020 , we use the. \n-00059570: 2020 2020 2020 2020 206f 6e65 2077 6869 one whi\n-00059580: 6368 2069 7320 2872 6561 643a 206d 7573 ch is (read: mus\n-00059590: 7420 6265 2920 6375 7272 656e 746c 7920 t be) currently \n-000595a0: 7275 6e6e 696e 672e 0a20 2020 2020 2020 running.. \n-000595b0: 203a 7061 7261 6d20 696e 7465 7261 6374 :param interact\n-000595c0: 696f 6e5f 6861 6e64 6c65 7273 3a20 7468 ion_handlers: th\n-000595d0: 6520 6861 6e64 6c65 7273 2070 6173 7365 e handlers passe\n-000595e0: 6420 746f 2074 6865 0a20 2020 2020 2020 d to the. \n-000595f0: 2020 2020 2049 6e74 6572 6163 7469 6f6e Interaction\n-00059600: 4167 656e 740a 2020 2020 2020 2020 3a70 Agent. :p\n-00059610: 6172 616d 2069 735f 7373 683a 2077 6865 aram is_ssh: whe\n-00059620: 7468 6572 2077 6520 7368 6f75 6c64 2061 ther we should a\n-00059630: 7474 656d 7074 2074 6f20 696e 7465 7270 ttempt to interp\n-00059640: 7265 7420 7374 6465 7272 2061 7320 7373 ret stderr as ss\n-00059650: 680a 2020 2020 2020 2020 2020 2020 6572 h. er\n-00059660: 726f 7220 6d65 7373 6167 6573 0a20 2020 ror messages. \n-00059670: 2020 2020 203a 7061 7261 6d20 6b77 6172 :param kwar\n-00059680: 6773 3a20 616e 7974 6869 6e67 2065 6c73 gs: anything els\n-00059690: 6520 6973 2070 6173 7365 6420 7468 726f e is passed thro\n-000596a0: 7567 6820 746f 2060 7375 6270 726f 6365 ugh to `subproce\n-000596b0: 7373 5f65 7865 6328 2960 0a20 2020 2020 ss_exec()`. \n-000596c0: 2020 203a 7265 7475 726e 733a 2074 6865 :returns: the\n-000596d0: 2075 7375 616c 2060 2854 7261 6e73 706f usual `(Transpo\n-000596e0: 7274 2c20 5072 6f74 6f63 6f6c 2960 2070 rt, Protocol)` p\n-000596f0: 6169 720a 2020 2020 2020 2020 2222 220a air. \"\"\".\n-00059700: 2020 2020 2020 2020 6c6f 6767 6572 2e64 logger.d\n-00059710: 6562 7567 2827 7370 6177 6e28 2572 2c20 ebug('spawn(%r, \n-00059720: 2572 2c20 2572 2927 2c20 636c 732c 2070 %r, %r)', cls, p\n-00059730: 726f 746f 636f 6c5f 6661 6374 6f72 792c rotocol_factory,\n-00059740: 2061 7267 7329 0a0a 2020 2020 2020 2020 args).. \n-00059750: 7072 6f74 6f63 6f6c 203d 2070 726f 746f protocol = proto\n-00059760: 636f 6c5f 6661 6374 6f72 7928 290a 2020 col_factory(). \n-00059770: 2020 2020 2020 7365 6c66 203d 2063 6c73 self = cls\n-00059780: 2870 726f 746f 636f 6c29 0a20 2020 2020 (protocol). \n-00059790: 2020 2073 656c 662e 5f69 735f 7373 6820 self._is_ssh \n-000597a0: 3d20 6973 5f73 7368 0a0a 2020 2020 2020 = is_ssh.. \n-000597b0: 2020 6966 206c 6f6f 7020 6973 204e 6f6e if loop is Non\n-000597c0: 653a 0a20 2020 2020 2020 2020 2020 206c e:. l\n-000597d0: 6f6f 7020 3d20 6765 745f 7275 6e6e 696e oop = get_runnin\n-000597e0: 675f 6c6f 6f70 2829 0a0a 2020 2020 2020 g_loop().. \n-000597f0: 2020 7365 6c66 2e5f 6167 656e 7420 3d20 self._agent = \n-00059800: 496e 7465 7261 6374 696f 6e41 6765 6e74 InteractionAgent\n-00059810: 2869 6e74 6572 6163 7469 6f6e 5f68 616e (interaction_han\n-00059820: 646c 6572 732c 206c 6f6f 702c 2073 656c dlers, loop, sel\n-00059830: 662e 5f69 6e74 6572 6163 7469 6f6e 5f63 f._interaction_c\n-00059840: 6f6d 706c 6574 6564 290a 2020 2020 2020 ompleted). \n-00059850: 2020 6b77 6172 6773 2e73 6574 6465 6661 kwargs.setdefa\n-00059860: 756c 7428 2773 7464 6572 7227 2c20 7365 ult('stderr', se\n-00059870: 6c66 2e5f 6167 656e 742e 6669 6c65 6e6f lf._agent.fileno\n-00059880: 2829 290a 0a20 2020 2020 2020 2023 2041 ()).. # A\n-00059890: 7320 6f66 2050 7974 686f 6e20 332e 3132 s of Python 3.12\n-000598a0: 2074 6869 7320 6973 6e27 7420 7265 616c this isn't real\n-000598b0: 6c79 2061 7379 6e63 6872 6f6e 6f75 7320 ly asynchronous \n-000598c0: 2873 696e 6365 2069 7420 7573 6573 2074 (since it uses t\n-000598d0: 6865 0a20 2020 2020 2020 2023 2073 7562 he. # sub\n-000598e0: 7072 6f63 6573 7320 6d6f 6475 6c65 2c20 process module, \n-000598f0: 7768 6963 6820 626c 6f63 6b73 2077 6869 which blocks whi\n-00059900: 6c65 2077 6169 7469 6e67 2066 6f72 2074 le waiting for t\n-00059910: 6865 2065 7865 6328 2920 746f 0a20 2020 he exec() to. \n-00059920: 2020 2020 2023 2063 6f6d 706c 6574 6520 # complete \n-00059930: 696e 2074 6865 2063 6869 6c64 292c 2062 in the child), b\n-00059940: 7574 2077 6520 6861 7665 2074 6f20 6465 ut we have to de\n-00059950: 616c 2077 6974 6820 7468 6520 636f 6d70 al with the comp\n-00059960: 6c69 6361 7469 6f6e 206f 660a 2020 2020 lication of. \n-00059970: 2020 2020 2320 7468 6520 6173 796e 6320 # the async \n-00059980: 696e 7465 7266 6163 6520 616e 7977 6179 interface anyway\n-00059990: 2e20 2053 696e 6365 2077 652c 206f 7572 . Since we, our\n-000599a0: 7365 6c76 6573 2c20 7761 6e74 2074 6f20 selves, want to \n-000599b0: 6578 706f 7274 2061 0a20 2020 2020 2020 export a. \n-000599c0: 2023 206e 6f6e 2d61 7379 6e63 2069 6e74 # non-async int\n-000599d0: 6572 6661 6365 2c20 7468 6174 206d 6561 erface, that mea\n-000599e0: 6e73 2074 6861 7420 7765 206e 6565 6420 ns that we need \n-000599f0: 6120 7461 736b 2068 6572 6520 616e 6420 a task here and \n-00059a00: 610a 2020 2020 2020 2020 2320 626f 7474 a. # bott\n-00059a10: 6f6d 2d68 616c 6620 6861 6e64 6c65 7220 om-half handler \n-00059a20: 6265 6c6f 772e 0a20 2020 2020 2020 2073 below.. s\n-00059a30: 656c 662e 5f65 7865 635f 7461 736b 203d elf._exec_task =\n-00059a40: 206c 6f6f 702e 6372 6561 7465 5f74 6173 loop.create_tas\n-00059a50: 6b28 6c6f 6f70 2e73 7562 7072 6f63 6573 k(loop.subproces\n-00059a60: 735f 6578 6563 286c 616d 6264 613a 2073 s_exec(lambda: s\n-00059a70: 656c 662c 202a 6172 6773 2c20 2a2a 6b77 elf, *args, **kw\n-00059a80: 6172 6773 2929 0a0a 2020 2020 2020 2020 args)).. \n-00059a90: 6465 6620 6578 6563 5f63 6f6d 706c 6574 def exec_complet\n-00059aa0: 6564 2874 6173 6b3a 2061 7379 6e63 696f ed(task: asyncio\n-00059ab0: 2e54 6173 6b29 202d 3e20 4e6f 6e65 3a0a .Task) -> None:.\n-00059ac0: 2020 2020 2020 2020 2020 2020 6c6f 6767 logg\n-00059ad0: 6572 2e64 6562 7567 2827 6578 6563 5f63 er.debug('exec_c\n-00059ae0: 6f6d 706c 6574 6564 2825 722c 2025 7229 ompleted(%r, %r)\n-00059af0: 272c 2073 656c 662c 2074 6173 6b29 0a20 ', self, task). \n-00059b00: 2020 2020 2020 2020 2020 2061 7373 6572 asser\n-00059b10: 7420 7461 736b 2069 7320 7365 6c66 2e5f t task is self._\n-00059b20: 6578 6563 5f74 6173 6b0a 2020 2020 2020 exec_task. \n-00059b30: 2020 2020 2020 7472 793a 0a20 2020 2020 try:. \n-00059b40: 2020 2020 2020 2020 2020 2074 7261 6e73 trans\n-00059b50: 706f 7274 2c20 6d65 203d 2074 6173 6b2e port, me = task.\n-00059b60: 7265 7375 6c74 2829 0a20 2020 2020 2020 result(). \n-00059b70: 2020 2020 2020 2020 2061 7373 6572 7420 assert \n-00059b80: 6d65 2069 7320 7365 6c66 0a20 2020 2020 me is self. \n-00059b90: 2020 2020 2020 2020 2020 206c 6f67 6765 logge\n-00059ba0: 722e 6465 6275 6728 2720 2073 7563 6365 r.debug(' succe\n-00059bb0: 7373 2e27 290a 2020 2020 2020 2020 2020 ss.'). \n-00059bc0: 2020 6578 6365 7074 2061 7379 6e63 696f except asyncio\n-00059bd0: 2e43 616e 6365 6c6c 6564 4572 726f 723a .CancelledError:\n-00059be0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-00059bf0: 2072 6574 7572 6e20 2023 2069 6e20 7468 return # in th\n-00059c00: 6174 2063 6173 652c 2064 6f20 6e6f 7468 at case, do noth\n-00059c10: 696e 670a 2020 2020 2020 2020 2020 2020 ing. \n-00059c20: 6578 6365 7074 204f 5345 7272 6f72 2061 except OSError a\n-00059c30: 7320 6578 633a 0a20 2020 2020 2020 2020 s exc:. \n-00059c40: 2020 2020 2020 206c 6f67 6765 722e 6465 logger.de\n-00059c50: 6275 6728 2720 204f 5345 7272 6f72 2025 bug(' OSError %\n-00059c60: 7227 2c20 6578 6329 0a20 2020 2020 2020 r', exc). \n-00059c70: 2020 2020 2020 2020 2073 656c 662e 636c self.cl\n-00059c80: 6f73 6528 6578 6329 0a20 2020 2020 2020 ose(exc). \n-00059c90: 2020 2020 2020 2020 2072 6574 7572 6e0a return.\n-00059ca0: 0a20 2020 2020 2020 2020 2020 2023 204f . # O\n-00059cb0: 7572 206f 776e 202e 636f 6e6e 6563 7469 ur own .connecti\n-00059cc0: 6f6e 5f6d 6164 6528 2920 6861 6e64 6c65 on_made() handle\n-00059cd0: 7220 7368 6f75 6c64 2068 6176 6520 676f r should have go\n-00059ce0: 7474 656e 2063 616c 6c65 6420 6279 0a20 tten called by. \n-00059cf0: 2020 2020 2020 2020 2020 2023 206e 6f77 # now\n-00059d00: 2e20 204d 616b 6520 7375 7265 2065 7665 . Make sure eve\n-00059d10: 7279 7468 696e 6720 676f 7420 6669 6c6c rything got fill\n-00059d20: 6564 2069 6e20 7072 6f70 6572 6c79 2e0a ed in properly..\n-00059d30: 2020 2020 2020 2020 2020 2020 6173 7365 asse\n-00059d40: 7274 2073 656c 662e 5f73 7562 7072 6f63 rt self._subproc\n-00059d50: 6573 735f 7472 616e 7370 6f72 7420 6973 ess_transport is\n-00059d60: 2074 7261 6e73 706f 7274 0a20 2020 2020 transport. \n-00059d70: 2020 2020 2020 2061 7373 6572 7420 7365 assert se\n-00059d80: 6c66 2e5f 7374 6469 6e5f 7472 616e 7370 lf._stdin_transp\n-00059d90: 6f72 7420 6973 206e 6f74 204e 6f6e 650a ort is not None.\n-00059da0: 2020 2020 2020 2020 2020 2020 6173 7365 asse\n-00059db0: 7274 2073 656c 662e 5f73 7464 6f75 745f rt self._stdout_\n-00059dc0: 7472 616e 7370 6f72 7420 6973 206e 6f74 transport is not\n-00059dd0: 204e 6f6e 650a 0a20 2020 2020 2020 2020 None.. \n-00059de0: 2020 2023 2041 736b 2074 6865 2049 6e74 # Ask the Int\n-00059df0: 6572 6163 7469 6f6e 4167 656e 7420 746f eractionAgent to\n-00059e00: 2073 7461 7274 2070 726f 6365 7373 696e start processin\n-00059e10: 6720 7374 6465 7272 2e0a 2020 2020 2020 g stderr.. \n-00059e20: 2020 2020 2020 7365 6c66 2e5f 6167 656e self._agen\n-00059e30: 742e 7374 6172 7428 290a 0a20 2020 2020 t.start().. \n-00059e40: 2020 2073 656c 662e 5f65 7865 635f 7461 self._exec_ta\n-00059e50: 736b 2e61 6464 5f64 6f6e 655f 6361 6c6c sk.add_done_call\n-00059e60: 6261 636b 2865 7865 635f 636f 6d70 6c65 back(exec_comple\n-00059e70: 7465 6429 0a0a 2020 2020 2020 2020 7265 ted).. re\n-00059e80: 7475 726e 2073 656c 662c 2070 726f 746f turn self, proto\n-00059e90: 636f 6c0a 0a20 2020 2064 6566 205f 5f69 col.. def __i\n-00059ea0: 6e69 745f 5f28 7365 6c66 2c20 7072 6f74 nit__(self, prot\n-00059eb0: 6f63 6f6c 3a20 6173 796e 6369 6f2e 5072 ocol: asyncio.Pr\n-00059ec0: 6f74 6f63 6f6c 2920 2d3e 204e 6f6e 653a otocol) -> None:\n-00059ed0: 0a20 2020 2020 2020 2073 656c 662e 5f70 . self._p\n-00059ee0: 726f 746f 636f 6c20 3d20 7072 6f74 6f63 rotocol = protoc\n-00059ef0: 6f6c 0a0a 2020 2020 6465 6620 5f63 6f6e ol.. def _con\n-00059f00: 7369 6465 725f 6469 7363 6f6e 6e65 6374 sider_disconnect\n-00059f10: 2873 656c 6629 202d 3e20 4e6f 6e65 3a0a (self) -> None:.\n-00059f20: 2020 2020 2020 2020 6c6f 6767 6572 2e64 logger.d\n-00059f30: 6562 7567 2827 5f63 6f6e 7369 6465 725f ebug('_consider_\n-00059f40: 6469 7363 6f6e 6e65 6374 2825 7229 272c disconnect(%r)',\n-00059f50: 2073 656c 6629 0a20 2020 2020 2020 2023 self). #\n-00059f60: 2057 6520 6361 6e6e 6f74 2064 6973 636f We cannot disco\n-00059f70: 6e6e 6563 7420 6173 206c 6f6e 6720 6173 nnect as long as\n-00059f80: 2061 6e79 206f 6620 7468 6573 6520 7468 any of these th\n-00059f90: 7265 6520 7468 696e 6773 2061 7265 2068 ree things are h\n-00059fa0: 6170 7065 6e69 6e67 0a20 2020 2020 2020 appening. \n-00059fb0: 2069 6620 6e6f 7420 7365 6c66 2e5f 6578 if not self._ex\n-00059fc0: 6563 5f74 6173 6b2e 646f 6e65 2829 3a0a ec_task.done():.\n-00059fd0: 2020 2020 2020 2020 2020 2020 6c6f 6767 logg\n-00059fe0: 6572 2e64 6562 7567 2827 2020 6578 6563 er.debug(' exec\n-00059ff0: 5f74 6173 6b20 7374 696c 6c20 7275 6e6e _task still runn\n-0005a000: 696e 6720 2572 272c 2073 656c 662e 5f65 ing %r', self._e\n-0005a010: 7865 635f 7461 736b 290a 2020 2020 2020 xec_task). \n-0005a020: 2020 2020 2020 7265 7475 726e 0a0a 2020 return.. \n-0005a030: 2020 2020 2020 6966 2073 656c 662e 5f73 if self._s\n-0005a040: 7562 7072 6f63 6573 735f 7472 616e 7370 ubprocess_transp\n-0005a050: 6f72 7420 6973 206e 6f74 204e 6f6e 6520 ort is not None \n-0005a060: 616e 6420 6e6f 7420 7365 6c66 2e5f 7472 and not self._tr\n-0005a070: 616e 7370 6f72 745f 6469 7363 6f6e 6e65 ansport_disconne\n-0005a080: 6374 6564 3a0a 2020 2020 2020 2020 2020 cted:. \n-0005a090: 2020 6c6f 6767 6572 2e64 6562 7567 2827 logger.debug('\n-0005a0a0: 2020 7472 616e 7370 6f72 7420 7374 696c transport stil\n-0005a0b0: 6c20 636f 6e6e 6563 7465 6420 2572 272c l connected %r',\n-0005a0c0: 2073 656c 662e 5f73 7562 7072 6f63 6573 self._subproces\n-0005a0d0: 735f 7472 616e 7370 6f72 7429 0a20 2020 s_transport). \n-0005a0e0: 2020 2020 2020 2020 2072 6574 7572 6e0a return.\n-0005a0f0: 0a20 2020 2020 2020 2069 6620 7365 6c66 . if self\n-0005a100: 2e5f 7374 6465 7272 5f6f 7574 7075 7420 ._stderr_output \n-0005a110: 6973 204e 6f6e 653a 0a20 2020 2020 2020 is None:. \n-0005a120: 2020 2020 206c 6f67 6765 722e 6465 6275 logger.debu\n-0005a130: 6728 2720 2061 6765 6e74 2073 7469 6c6c g(' agent still\n-0005a140: 2072 756e 6e69 6e67 2729 0a20 2020 2020 running'). \n-0005a150: 2020 2020 2020 2072 6574 7572 6e0a 0a20 return.. \n-0005a160: 2020 2020 2020 2023 2041 6c6c 2063 6f6e # All con\n-0005a170: 6469 7469 6f6e 7320 666f 7220 6469 7363 ditions for disc\n-0005a180: 6f6e 6e65 6374 696f 6e20 6172 6520 7361 onnection are sa\n-0005a190: 7469 7366 6965 642e 0a20 2020 2020 2020 tisfied.. \n-0005a1a0: 2069 6620 7365 6c66 2e5f 7072 6f74 6f63 if self._protoc\n-0005a1b0: 6f6c 5f64 6973 636f 6e6e 6563 7465 643a ol_disconnected:\n-0005a1c0: 0a20 2020 2020 2020 2020 2020 206c 6f67 . log\n-0005a1d0: 6765 722e 6465 6275 6728 2720 2061 6c72 ger.debug(' alr\n-0005a1e0: 6561 6479 2064 6973 636f 6e6e 6563 7465 eady disconnecte\n-0005a1f0: 6427 290a 2020 2020 2020 2020 2020 2020 d'). \n-0005a200: 7265 7475 726e 0a20 2020 2020 2020 2073 return. s\n-0005a210: 656c 662e 5f70 726f 746f 636f 6c5f 6469 elf._protocol_di\n-0005a220: 7363 6f6e 6e65 6374 6564 203d 2054 7275 sconnected = Tru\n-0005a230: 650a 0a20 2020 2020 2020 2023 204e 6f77 e.. # Now\n-0005a240: 2077 6520 6a75 7374 206e 6565 6420 746f we just need to\n-0005a250: 2064 6574 6572 6d69 6e65 2077 6861 7420 determine what \n-0005a260: 7765 2072 6570 6f72 7420 746f 2074 6865 we report to the\n-0005a270: 2070 726f 746f 636f 6c2e 2e2e 0a20 2020 protocol.... \n-0005a280: 2020 2020 2069 6620 7365 6c66 2e5f 6578 if self._ex\n-0005a290: 6365 7074 696f 6e20 6973 206e 6f74 204e ception is not N\n-0005a2a0: 6f6e 653a 0a20 2020 2020 2020 2020 2020 one:. \n-0005a2b0: 2023 2049 6620 7765 2067 6f74 2061 6e20 # If we got an \n-0005a2c0: 6578 6365 7074 696f 6e20 7265 706f 7274 exception report\n-0005a2d0: 6564 2c20 7468 6174 2773 206f 7572 2072 ed, that's our r\n-0005a2e0: 6561 736f 6e20 666f 7220 636c 6f73 696e eason for closin\n-0005a2f0: 672e 0a20 2020 2020 2020 2020 2020 206c g.. l\n-0005a300: 6f67 6765 722e 6465 6275 6728 2720 2064 ogger.debug(' d\n-0005a310: 6973 636f 6e6e 6563 7420 7769 7468 2065 isconnect with e\n-0005a320: 7863 6570 7469 6f6e 2025 7227 2c20 7365 xception %r', se\n-0005a330: 6c66 2e5f 6578 6365 7074 696f 6e29 0a20 lf._exception). \n-0005a340: 2020 2020 2020 2020 2020 2073 656c 662e self.\n-0005a350: 5f70 726f 746f 636f 6c2e 636f 6e6e 6563 _protocol.connec\n-0005a360: 7469 6f6e 5f6c 6f73 7428 7365 6c66 2e5f tion_lost(self._\n-0005a370: 6578 6365 7074 696f 6e29 0a20 2020 2020 exception). \n-0005a380: 2020 2065 6c69 6620 7365 6c66 2e5f 7265 elif self._re\n-0005a390: 7475 726e 636f 6465 203d 3d20 3020 6f72 turncode == 0 or\n-0005a3a0: 2073 656c 662e 5f63 6c6f 7365 643a 0a20 self._closed:. \n-0005a3b0: 2020 2020 2020 2020 2020 2023 2049 6620 # If \n-0005a3c0: 7765 2063 616c 6c65 6420 636c 6f73 6528 we called close(\n-0005a3d0: 2920 6f72 2068 6176 6520 6120 7a65 726f ) or have a zero\n-0005a3e0: 2072 6574 7572 6e20 7374 6174 7573 2c20 return status, \n-0005a3f0: 7468 6174 2773 2061 2063 6c65 616e 0a20 that's a clean. \n-0005a400: 2020 2020 2020 2020 2020 2023 2065 7869 # exi\n-0005a410: 742c 2072 6567 6172 646c 6573 7320 6f66 t, regardless of\n-0005a420: 206e 6f69 7365 2074 6861 7420 6d69 6768 noise that migh\n-0005a430: 7420 6861 7665 206c 616e 6465 6420 696e t have landed in\n-0005a440: 2073 7464 6572 722e 0a20 2020 2020 2020 stderr.. \n-0005a450: 2020 2020 206c 6f67 6765 722e 6465 6275 logger.debu\n-0005a460: 6728 2720 2063 6c65 616e 2064 6973 636f g(' clean disco\n-0005a470: 6e6e 6563 7427 290a 2020 2020 2020 2020 nnect'). \n-0005a480: 2020 2020 7365 6c66 2e5f 7072 6f74 6f63 self._protoc\n-0005a490: 6f6c 2e63 6f6e 6e65 6374 696f 6e5f 6c6f ol.connection_lo\n-0005a4a0: 7374 284e 6f6e 6529 0a20 2020 2020 2020 st(None). \n-0005a4b0: 2065 6c69 6620 7365 6c66 2e5f 6973 5f73 elif self._is_s\n-0005a4c0: 7368 2061 6e64 2073 656c 662e 5f72 6574 sh and self._ret\n-0005a4d0: 7572 6e63 6f64 6520 3d3d 2032 3535 3a0a urncode == 255:.\n-0005a4e0: 2020 2020 2020 2020 2020 2020 2320 5468 # Th\n-0005a4f0: 6973 2069 7320 616e 2065 7272 6f72 2063 is is an error c\n-0005a500: 6f64 6520 6475 6520 746f 2061 6e20 5353 ode due to an SS\n-0005a510: 4820 6661 696c 7572 652e 2020 5472 7920 H failure. Try \n-0005a520: 746f 2069 6e74 6572 7072 6574 2069 742e to interpret it.\n-0005a530: 0a20 2020 2020 2020 2020 2020 206c 6f67 . log\n-0005a540: 6765 722e 6465 6275 6728 2720 2064 6973 ger.debug(' dis\n-0005a550: 636f 6e6e 6563 7420 7769 7468 2073 7368 connect with ssh\n-0005a560: 2065 7272 6f72 2025 7227 2c20 7365 6c66 error %r', self\n-0005a570: 2e5f 7374 6465 7272 5f6f 7574 7075 7429 ._stderr_output)\n-0005a580: 0a20 2020 2020 2020 2020 2020 2073 656c . sel\n-0005a590: 662e 5f70 726f 746f 636f 6c2e 636f 6e6e f._protocol.conn\n-0005a5a0: 6563 7469 6f6e 5f6c 6f73 7428 6765 745f ection_lost(get_\n-0005a5b0: 6578 6365 7074 696f 6e5f 666f 725f 7373 exception_for_ss\n-0005a5c0: 685f 7374 6465 7272 2873 656c 662e 5f73 h_stderr(self._s\n-0005a5d0: 7464 6572 725f 6f75 7470 7574 2929 0a20 tderr_output)). \n-0005a5e0: 2020 2020 2020 2065 6c73 653a 0a20 2020 else:. \n-0005a5f0: 2020 2020 2020 2020 2023 204f 7468 6572 # Other\n-0005a600: 7769 7365 2c20 7265 706f 7274 2074 6865 wise, report the\n-0005a610: 2073 7464 6572 7220 7465 7874 2061 6e64 stderr text and\n-0005a620: 2072 6574 7572 6e20 636f 6465 2e0a 2020 return code.. \n-0005a630: 2020 2020 2020 2020 2020 6c6f 6767 6572 logger\n-0005a640: 2e64 6562 7567 2827 2020 6469 7363 6f6e .debug(' discon\n-0005a650: 6e65 6374 2077 6974 6820 6578 6974 2063 nect with exit c\n-0005a660: 6f64 6520 2572 2c20 7374 6465 7272 2025 ode %r, stderr %\n-0005a670: 7227 2c20 7365 6c66 2e5f 7265 7475 726e r', self._return\n-0005a680: 636f 6465 2c20 7365 6c66 2e5f 7374 6465 code, self._stde\n-0005a690: 7272 5f6f 7574 7075 7429 0a20 2020 2020 rr_output). \n-0005a6a0: 2020 2020 2020 2023 2057 6520 7375 7265 # We sure\n-0005a6b0: 6c79 2068 6176 6520 5f72 6574 7572 6e63 ly have _returnc\n-0005a6c0: 6f64 6520 7365 7420 6865 7265 2c20 7369 ode set here, si\n-0005a6d0: 6e63 6520 6f74 6865 7277 6973 653a 0a20 nce otherwise:. \n-0005a6e0: 2020 2020 2020 2020 2020 2023 2020 2d20 # - \n-0005a6f0: 6578 6563 5f74 6173 6b20 6661 696c 6564 exec_task failed\n-0005a700: 2077 6974 6820 616e 2065 7863 6570 7469 with an excepti\n-0005a710: 6f6e 2028 7768 6963 6820 7765 2068 616e on (which we han\n-0005a720: 646c 6520 6162 6f76 6529 3b20 6f72 0a20 dle above); or. \n-0005a730: 2020 2020 2020 2020 2020 2023 2020 2d20 # - \n-0005a740: 7765 2772 6520 7374 696c 6c20 636f 6e6e we're still conn\n-0005a750: 6563 7465 642e 2e2e 0a20 2020 2020 2020 ected.... \n-0005a760: 2020 2020 2061 7373 6572 7420 7365 6c66 assert self\n-0005a770: 2e5f 7265 7475 726e 636f 6465 2069 7320 ._returncode is \n-0005a780: 6e6f 7420 4e6f 6e65 0a20 2020 2020 2020 not None. \n-0005a790: 2020 2020 2073 656c 662e 5f70 726f 746f self._proto\n-0005a7a0: 636f 6c2e 636f 6e6e 6563 7469 6f6e 5f6c col.connection_l\n-0005a7b0: 6f73 7428 5375 6270 726f 6365 7373 4572 ost(SubprocessEr\n-0005a7c0: 726f 7228 7365 6c66 2e5f 7265 7475 726e ror(self._return\n-0005a7d0: 636f 6465 2c20 7365 6c66 2e5f 7374 6465 code, self._stde\n-0005a7e0: 7272 5f6f 7574 7075 7429 290a 0a20 2020 rr_output)).. \n-0005a7f0: 2064 6566 205f 696e 7465 7261 6374 696f def _interactio\n-0005a800: 6e5f 636f 6d70 6c65 7465 6428 7365 6c66 n_completed(self\n-0005a810: 2c20 6675 7475 7265 3a20 2761 7379 6e63 , future: 'async\n-0005a820: 696f 2e46 7574 7572 655b 7374 725d 2729 io.Future[str]')\n-0005a830: 202d 3e20 4e6f 6e65 3a0a 2020 2020 2020 -> None:. \n-0005a840: 2020 6c6f 6767 6572 2e64 6562 7567 2827 logger.debug('\n-0005a850: 5f69 6e74 6572 6163 7469 6f6e 5f63 6f6d _interaction_com\n-0005a860: 706c 6574 6564 2825 722c 2025 7229 272c pleted(%r, %r)',\n-0005a870: 2073 656c 662c 2066 7574 7572 6529 0a20 self, future). \n-0005a880: 2020 2020 2020 2074 7279 3a0a 2020 2020 try:. \n-0005a890: 2020 2020 2020 2020 7365 6c66 2e5f 7374 self._st\n-0005a8a0: 6465 7272 5f6f 7574 7075 7420 3d20 6675 derr_output = fu\n-0005a8b0: 7475 7265 2e72 6573 756c 7428 290a 2020 ture.result(). \n-0005a8c0: 2020 2020 2020 2020 2020 6c6f 6767 6572 logger\n-0005a8d0: 2e64 6562 7567 2827 2020 7374 6465 7272 .debug(' stderr\n-0005a8e0: 3a20 2572 272c 2073 656c 662e 5f73 7464 : %r', self._std\n-0005a8f0: 6572 725f 6f75 7470 7574 290a 2020 2020 err_output). \n-0005a900: 2020 2020 6578 6365 7074 2045 7863 6570 except Excep\n-0005a910: 7469 6f6e 2061 7320 6578 633a 0a20 2020 tion as exc:. \n-0005a920: 2020 2020 2020 2020 206c 6f67 6765 722e logger.\n-0005a930: 6465 6275 6728 2720 2065 7863 6570 7469 debug(' excepti\n-0005a940: 6f6e 3a20 2572 272c 2065 7863 290a 2020 on: %r', exc). \n-0005a950: 2020 2020 2020 2020 2020 7365 6c66 2e5f self._\n-0005a960: 7374 6465 7272 5f6f 7574 7075 7420 3d20 stderr_output = \n-0005a970: 2727 2020 2320 7765 206e 6565 6420 746f '' # we need to\n-0005a980: 2073 6574 2074 6869 7320 696e 206f 7264 set this in ord\n-0005a990: 6572 2074 6f20 636f 6d70 6c65 7465 0a20 er to complete. \n-0005a9a0: 2020 2020 2020 2020 2020 2073 656c 662e self.\n-0005a9b0: 636c 6f73 6528 6578 6329 0a0a 2020 2020 close(exc).. \n-0005a9c0: 2020 2020 7365 6c66 2e5f 636f 6e73 6964 self._consid\n-0005a9d0: 6572 5f64 6973 636f 6e6e 6563 7428 290a er_disconnect().\n-0005a9e0: 0a20 2020 2023 2042 6173 6550 726f 746f . # BaseProto\n-0005a9f0: 636f 6c20 696d 706c 656d 656e 7461 7469 col implementati\n-0005aa00: 6f6e 0a20 2020 2064 6566 2063 6f6e 6e65 on. def conne\n-0005aa10: 6374 696f 6e5f 6d61 6465 2873 656c 662c ction_made(self,\n-0005aa20: 2074 7261 6e73 706f 7274 3a20 6173 796e transport: asyn\n-0005aa30: 6369 6f2e 4261 7365 5472 616e 7370 6f72 cio.BaseTranspor\n-0005aa40: 7429 202d 3e20 4e6f 6e65 3a0a 2020 2020 t) -> None:. \n-0005aa50: 2020 2020 6c6f 6767 6572 2e64 6562 7567 logger.debug\n-0005aa60: 2827 636f 6e6e 6563 7469 6f6e 5f6d 6164 ('connection_mad\n-0005aa70: 6528 2572 2c20 2572 2927 2c20 7365 6c66 e(%r, %r)', self\n-0005aa80: 2c20 7472 616e 7370 6f72 7429 0a20 2020 , transport). \n-0005aa90: 2020 2020 2061 7373 6572 7420 6973 696e assert isin\n-0005aaa0: 7374 616e 6365 2874 7261 6e73 706f 7274 stance(transport\n-0005aab0: 2c20 6173 796e 6369 6f2e 5375 6270 726f , asyncio.Subpro\n-0005aac0: 6365 7373 5472 616e 7370 6f72 7429 0a20 cessTransport). \n-0005aad0: 2020 2020 2020 2073 656c 662e 5f73 7562 self._sub\n-0005aae0: 7072 6f63 6573 735f 7472 616e 7370 6f72 process_transpor\n-0005aaf0: 7420 3d20 7472 616e 7370 6f72 740a 0a20 t = transport.. \n-0005ab00: 2020 2020 2020 2073 7464 696e 5f74 7261 stdin_tra\n-0005ab10: 6e73 706f 7274 203d 2074 7261 6e73 706f nsport = transpo\n-0005ab20: 7274 2e67 6574 5f70 6970 655f 7472 616e rt.get_pipe_tran\n-0005ab30: 7370 6f72 7428 3029 0a20 2020 2020 2020 sport(0). \n-0005ab40: 2061 7373 6572 7420 6973 696e 7374 616e assert isinstan\n-0005ab50: 6365 2873 7464 696e 5f74 7261 6e73 706f ce(stdin_transpo\n-0005ab60: 7274 2c20 6173 796e 6369 6f2e 5772 6974 rt, asyncio.Writ\n-0005ab70: 6554 7261 6e73 706f 7274 290a 2020 2020 eTransport). \n-0005ab80: 2020 2020 7365 6c66 2e5f 7374 6469 6e5f self._stdin_\n-0005ab90: 7472 616e 7370 6f72 7420 3d20 7374 6469 transport = stdi\n-0005aba0: 6e5f 7472 616e 7370 6f72 740a 0a20 2020 n_transport.. \n-0005abb0: 2020 2020 2073 7464 6f75 745f 7472 616e stdout_tran\n-0005abc0: 7370 6f72 7420 3d20 7472 616e 7370 6f72 sport = transpor\n-0005abd0: 742e 6765 745f 7069 7065 5f74 7261 6e73 t.get_pipe_trans\n-0005abe0: 706f 7274 2831 290a 2020 2020 2020 2020 port(1). \n-0005abf0: 6173 7365 7274 2069 7369 6e73 7461 6e63 assert isinstanc\n-0005ac00: 6528 7374 646f 7574 5f74 7261 6e73 706f e(stdout_transpo\n-0005ac10: 7274 2c20 6173 796e 6369 6f2e 5265 6164 rt, asyncio.Read\n-0005ac20: 5472 616e 7370 6f72 7429 0a20 2020 2020 Transport). \n-0005ac30: 2020 2073 656c 662e 5f73 7464 6f75 745f self._stdout_\n-0005ac40: 7472 616e 7370 6f72 7420 3d20 7374 646f transport = stdo\n-0005ac50: 7574 5f74 7261 6e73 706f 7274 0a0a 2020 ut_transport.. \n-0005ac60: 2020 2020 2020 7374 6465 7272 5f74 7261 stderr_tra\n-0005ac70: 6e73 706f 7274 203d 2074 7261 6e73 706f nsport = transpo\n-0005ac80: 7274 2e67 6574 5f70 6970 655f 7472 616e rt.get_pipe_tran\n-0005ac90: 7370 6f72 7428 3229 0a20 2020 2020 2020 sport(2). \n-0005aca0: 2061 7373 6572 7420 7374 6465 7272 5f74 assert stderr_t\n-0005acb0: 7261 6e73 706f 7274 2069 7320 4e6f 6e65 ransport is None\n-0005acc0: 0a0a 2020 2020 2020 2020 6c6f 6767 6572 .. logger\n-0005acd0: 2e64 6562 7567 2827 6361 6c6c 696e 6720 .debug('calling \n-0005ace0: 636f 6e6e 6563 7469 6f6e 5f6d 6164 6528 connection_made(\n-0005acf0: 2572 2c20 2572 2927 2c20 7365 6c66 2c20 %r, %r)', self, \n-0005ad00: 7365 6c66 2e5f 7072 6f74 6f63 6f6c 290a self._protocol).\n-0005ad10: 2020 2020 2020 2020 7365 6c66 2e5f 7072 self._pr\n-0005ad20: 6f74 6f63 6f6c 2e63 6f6e 6e65 6374 696f otocol.connectio\n-0005ad30: 6e5f 6d61 6465 2873 656c 6629 0a0a 2020 n_made(self).. \n-0005ad40: 2020 6465 6620 636f 6e6e 6563 7469 6f6e def connection\n-0005ad50: 5f6c 6f73 7428 7365 6c66 2c20 6578 633a _lost(self, exc:\n-0005ad60: 2027 4578 6365 7074 696f 6e20 7c20 4e6f 'Exception | No\n-0005ad70: 6e65 2729 202d 3e20 4e6f 6e65 3a0a 2020 ne') -> None:. \n-0005ad80: 2020 2020 2020 6c6f 6767 6572 2e64 6562 logger.deb\n-0005ad90: 7567 2827 636f 6e6e 6563 7469 6f6e 5f6c ug('connection_l\n-0005ada0: 6f73 7428 2572 2c20 2572 2927 2c20 7365 ost(%r, %r)', se\n-0005adb0: 6c66 2c20 6578 6329 0a20 2020 2020 2020 lf, exc). \n-0005adc0: 2069 6620 7365 6c66 2e5f 6578 6365 7074 if self._except\n-0005add0: 696f 6e20 6973 204e 6f6e 653a 0a20 2020 ion is None:. \n-0005ade0: 2020 2020 2020 2020 2073 656c 662e 5f65 self._e\n-0005adf0: 7863 6570 7469 6f6e 203d 2065 7863 0a20 xception = exc. \n-0005ae00: 2020 2020 2020 2073 656c 662e 5f74 7261 self._tra\n-0005ae10: 6e73 706f 7274 5f64 6973 636f 6e6e 6563 nsport_disconnec\n-0005ae20: 7465 6420 3d20 5472 7565 0a20 2020 2020 ted = True. \n-0005ae30: 2020 2073 656c 662e 5f63 6f6e 7369 6465 self._conside\n-0005ae40: 725f 6469 7363 6f6e 6e65 6374 2829 0a0a r_disconnect()..\n-0005ae50: 2020 2020 2320 5375 6270 726f 6365 7373 # Subprocess\n-0005ae60: 5072 6f74 6f63 6f6c 2069 6d70 6c65 6d65 Protocol impleme\n-0005ae70: 6e74 6174 696f 6e0a 2020 2020 6465 6620 ntation. def \n-0005ae80: 7069 7065 5f64 6174 615f 7265 6365 6976 pipe_data_receiv\n-0005ae90: 6564 2873 656c 662c 2066 643a 2069 6e74 ed(self, fd: int\n-0005aea0: 2c20 6461 7461 3a20 6279 7465 7329 202d , data: bytes) -\n-0005aeb0: 3e20 4e6f 6e65 3a0a 2020 2020 2020 2020 > None:. \n-0005aec0: 6c6f 6767 6572 2e64 6562 7567 2827 7069 logger.debug('pi\n-0005aed0: 7065 5f64 6174 615f 7265 6365 6976 6564 pe_data_received\n-0005aee0: 2825 722c 2025 722c 2025 7229 272c 2073 (%r, %r, %r)', s\n-0005aef0: 656c 662c 2066 642c 206c 656e 2864 6174 elf, fd, len(dat\n-0005af00: 6129 290a 2020 2020 2020 2020 6173 7365 a)). asse\n-0005af10: 7274 2066 6420 3d3d 2031 2020 2320 7374 rt fd == 1 # st\n-0005af20: 6465 7272 2069 7320 6861 6e64 6c65 6420 derr is handled \n-0005af30: 7365 7061 7261 7465 6c79 0a20 2020 2020 separately. \n-0005af40: 2020 2073 656c 662e 5f70 726f 746f 636f self._protoco\n-0005af50: 6c2e 6461 7461 5f72 6563 6569 7665 6428 l.data_received(\n-0005af60: 6461 7461 290a 0a20 2020 2064 6566 2070 data).. def p\n-0005af70: 6970 655f 636f 6e6e 6563 7469 6f6e 5f6c ipe_connection_l\n-0005af80: 6f73 7428 7365 6c66 2c20 6664 3a20 696e ost(self, fd: in\n-0005af90: 742c 2065 7863 3a20 2745 7863 6570 7469 t, exc: 'Excepti\n-0005afa0: 6f6e 207c 204e 6f6e 6527 2920 2d3e 204e on | None') -> N\n-0005afb0: 6f6e 653a 0a20 2020 2020 2020 206c 6f67 one:. log\n-0005afc0: 6765 722e 6465 6275 6728 2770 6970 655f ger.debug('pipe_\n-0005afd0: 636f 6e6e 6563 7469 6f6e 5f6c 6f73 7428 connection_lost(\n-0005afe0: 2572 2c20 2572 2c20 2572 2927 2c20 7365 %r, %r, %r)', se\n-0005aff0: 6c66 2c20 6664 2c20 6578 6329 0a20 2020 lf, fd, exc). \n-0005b000: 2020 2020 2061 7373 6572 7420 6664 2069 assert fd i\n-0005b010: 6e20 2830 2c20 3129 2020 2320 7374 6465 n (0, 1) # stde\n-0005b020: 7272 2069 7320 6861 6e64 6c65 6420 7365 rr is handled se\n-0005b030: 7061 7261 7465 6c79 0a0a 2020 2020 2020 parately.. \n-0005b040: 2020 2320 5765 2074 7265 6174 2074 6869 # We treat thi\n-0005b050: 7320 6173 2061 2063 6c65 616e 2063 6c6f s as a clean clo\n-0005b060: 7365 0a20 2020 2020 2020 2069 6620 6973 se. if is\n-0005b070: 696e 7374 616e 6365 2865 7863 2c20 4272 instance(exc, Br\n-0005b080: 6f6b 656e 5069 7065 4572 726f 7229 3a0a okenPipeError):.\n-0005b090: 2020 2020 2020 2020 2020 2020 6578 6320 exc \n-0005b0a0: 3d20 4e6f 6e65 0a0a 2020 2020 2020 2020 = None.. \n-0005b0b0: 2320 5265 636f 7264 2073 6572 696f 7573 # Record serious\n-0005b0c0: 2065 7272 6f72 7320 746f 2070 726f 7061 errors to propa\n-0005b0d0: 6761 7465 2074 6865 6d20 746f 2074 6865 gate them to the\n-0005b0e0: 2070 726f 746f 636f 6c0a 2020 2020 2020 protocol. \n-0005b0f0: 2020 2320 4966 2074 6869 7320 6973 2061 # If this is a\n-0005b100: 2063 6c65 616e 2065 7869 7420 6f6e 2073 clean exit on s\n-0005b110: 7464 6f75 742c 2072 6570 6f72 7420 616e tdout, report an\n-0005b120: 2045 4f46 0a20 2020 2020 2020 2069 6620 EOF. if \n-0005b130: 6578 6320 6973 206e 6f74 204e 6f6e 653a exc is not None:\n-0005b140: 0a20 2020 2020 2020 2020 2020 2073 656c . sel\n-0005b150: 662e 636c 6f73 6528 6578 6329 0a20 2020 f.close(exc). \n-0005b160: 2020 2020 2065 6c69 6620 6664 203d 3d20 elif fd == \n-0005b170: 3120 616e 6420 6e6f 7420 7365 6c66 2e5f 1 and not self._\n-0005b180: 636c 6f73 6564 3a0a 2020 2020 2020 2020 closed:. \n-0005b190: 2020 2020 6966 206e 6f74 2073 656c 662e if not self.\n-0005b1a0: 5f70 726f 746f 636f 6c2e 656f 665f 7265 _protocol.eof_re\n-0005b1b0: 6365 6976 6564 2829 3a0a 2020 2020 2020 ceived():. \n-0005b1c0: 2020 2020 2020 2020 2020 7365 6c66 2e63 self.c\n-0005b1d0: 6c6f 7365 2829 0a0a 2020 2020 6465 6620 lose().. def \n-0005b1e0: 7072 6f63 6573 735f 6578 6974 6564 2873 process_exited(s\n-0005b1f0: 656c 6629 202d 3e20 4e6f 6e65 3a0a 2020 elf) -> None:. \n-0005b200: 2020 2020 2020 6c6f 6767 6572 2e64 6562 logger.deb\n-0005b210: 7567 2827 7072 6f63 6573 735f 6578 6974 ug('process_exit\n-0005b220: 6564 2825 7229 272c 2073 656c 6629 0a20 ed(%r)', self). \n-0005b230: 2020 2020 2020 2061 7373 6572 7420 7365 assert se\n-0005b240: 6c66 2e5f 7375 6270 726f 6365 7373 5f74 lf._subprocess_t\n-0005b250: 7261 6e73 706f 7274 2069 7320 6e6f 7420 ransport is not \n-0005b260: 4e6f 6e65 0a20 2020 2020 2020 2073 656c None. sel\n-0005b270: 662e 5f72 6574 7572 6e63 6f64 6520 3d20 f._returncode = \n-0005b280: 7365 6c66 2e5f 7375 6270 726f 6365 7373 self._subprocess\n-0005b290: 5f74 7261 6e73 706f 7274 2e67 6574 5f72 _transport.get_r\n-0005b2a0: 6574 7572 6e63 6f64 6528 290a 2020 2020 eturncode(). \n-0005b2b0: 2020 2020 6c6f 6767 6572 2e64 6562 7567 logger.debug\n-0005b2c0: 2827 2020 2e5f 7265 7475 726e 636f 6465 (' ._returncode\n-0005b2d0: 203d 2025 7227 2c20 7365 6c66 2e5f 7265 = %r', self._re\n-0005b2e0: 7475 726e 636f 6465 290a 2020 2020 2020 turncode). \n-0005b2f0: 2020 7365 6c66 2e5f 6167 656e 742e 666f self._agent.fo\n-0005b300: 7263 655f 636f 6d70 6c65 7469 6f6e 2829 rce_completion()\n-0005b310: 0a0a 2020 2020 6465 6620 7061 7573 655f .. def pause_\n-0005b320: 7772 6974 696e 6728 7365 6c66 2920 2d3e writing(self) ->\n-0005b330: 204e 6f6e 653a 0a20 2020 2020 2020 206c None:. l\n-0005b340: 6f67 6765 722e 6465 6275 6728 2770 6175 ogger.debug('pau\n-0005b350: 7365 5f77 7269 7469 6e67 2825 7229 272c se_writing(%r)',\n-0005b360: 2073 656c 6629 0a20 2020 2020 2020 2073 self). s\n-0005b370: 656c 662e 5f70 726f 746f 636f 6c2e 7061 elf._protocol.pa\n-0005b380: 7573 655f 7772 6974 696e 6728 290a 0a20 use_writing().. \n-0005b390: 2020 2064 6566 2072 6573 756d 655f 7772 def resume_wr\n-0005b3a0: 6974 696e 6728 7365 6c66 2920 2d3e 204e iting(self) -> N\n-0005b3b0: 6f6e 653a 0a20 2020 2020 2020 206c 6f67 one:. log\n-0005b3c0: 6765 722e 6465 6275 6728 2772 6573 756d ger.debug('resum\n-0005b3d0: 655f 7772 6974 696e 6728 2572 2927 2c20 e_writing(%r)', \n-0005b3e0: 7365 6c66 290a 2020 2020 2020 2020 7365 self). se\n-0005b3f0: 6c66 2e5f 7072 6f74 6f63 6f6c 2e72 6573 lf._protocol.res\n-0005b400: 756d 655f 7772 6974 696e 6728 290a 0a20 ume_writing().. \n-0005b410: 2020 2023 2054 7261 6e73 706f 7274 2069 # Transport i\n-0005b420: 6d70 6c65 6d65 6e74 6174 696f 6e2e 2020 mplementation. \n-0005b430: 4d6f 7374 206f 6620 7468 6973 2069 7320 Most of this is \n-0005b440: 7374 7261 6967 6874 2064 656c 6567 6174 straight delegat\n-0005b450: 696f 6e2e 0a20 2020 2064 6566 2063 6c6f ion.. def clo\n-0005b460: 7365 2873 656c 662c 2065 7863 3a20 2745 se(self, exc: 'E\n-0005b470: 7863 6570 7469 6f6e 207c 204e 6f6e 6527 xception | None'\n-0005b480: 203d 204e 6f6e 6529 202d 3e20 4e6f 6e65 = None) -> None\n-0005b490: 3a0a 2020 2020 2020 2020 6c6f 6767 6572 :. logger\n-0005b4a0: 2e64 6562 7567 2827 636c 6f73 6528 2572 .debug('close(%r\n-0005b4b0: 2c20 2572 2927 2c20 7365 6c66 2c20 6578 , %r)', self, ex\n-0005b4c0: 6329 0a20 2020 2020 2020 2073 656c 662e c). self.\n-0005b4d0: 5f63 6c6f 7365 6420 3d20 5472 7565 0a20 _closed = True. \n-0005b4e0: 2020 2020 2020 2069 6620 7365 6c66 2e5f if self._\n-0005b4f0: 6578 6365 7074 696f 6e20 6973 204e 6f6e exception is Non\n-0005b500: 653a 0a20 2020 2020 2020 2020 2020 206c e:. l\n-0005b510: 6f67 6765 722e 6465 6275 6728 2720 2073 ogger.debug(' s\n-0005b520: 6574 7469 6e67 2065 7863 6570 7469 6f6e etting exception\n-0005b530: 2025 7227 2c20 6578 6329 0a20 2020 2020 %r', exc). \n-0005b540: 2020 2020 2020 2073 656c 662e 5f65 7863 self._exc\n-0005b550: 6570 7469 6f6e 203d 2065 7863 0a20 2020 eption = exc. \n-0005b560: 2020 2020 2069 6620 6e6f 7420 7365 6c66 if not self\n-0005b570: 2e5f 6578 6563 5f74 6173 6b2e 646f 6e65 ._exec_task.done\n-0005b580: 2829 3a0a 2020 2020 2020 2020 2020 2020 ():. \n-0005b590: 6c6f 6767 6572 2e64 6562 7567 2827 2020 logger.debug(' \n-0005b5a0: 6361 6e63 656c 6c69 6e67 205f 6578 6563 cancelling _exec\n-0005b5b0: 5f74 6173 6b27 290a 2020 2020 2020 2020 _task'). \n-0005b5c0: 2020 2020 7365 6c66 2e5f 6578 6563 5f74 self._exec_t\n-0005b5d0: 6173 6b2e 6361 6e63 656c 2829 0a20 2020 ask.cancel(). \n-0005b5e0: 2020 2020 2069 6620 7365 6c66 2e5f 7375 if self._su\n-0005b5f0: 6270 726f 6365 7373 5f74 7261 6e73 706f bprocess_transpo\n-0005b600: 7274 2069 7320 6e6f 7420 4e6f 6e65 3a0a rt is not None:.\n-0005b610: 2020 2020 2020 2020 2020 2020 6c6f 6767 logg\n-0005b620: 6572 2e64 6562 7567 2827 2020 636c 6f73 er.debug(' clos\n-0005b630: 696e 6720 5f73 7562 7072 6f63 6573 735f ing _subprocess_\n-0005b640: 7472 616e 7370 6f72 7427 290a 2020 2020 transport'). \n-0005b650: 2020 2020 2020 2020 2320 6874 7470 733a # https:\n-0005b660: 2f2f 6769 7468 7562 2e63 6f6d 2f70 7974 //github.com/pyt\n-0005b670: 686f 6e2f 6370 7974 686f 6e2f 6973 7375 hon/cpython/issu\n-0005b680: 6573 2f31 3132 3830 300a 2020 2020 2020 es/112800. \n-0005b690: 2020 2020 2020 7769 7468 2063 6f6e 7465 with conte\n-0005b6a0: 7874 6c69 622e 7375 7070 7265 7373 2850 xtlib.suppress(P\n-0005b6b0: 6572 6d69 7373 696f 6e45 7272 6f72 293a ermissionError):\n-0005b6c0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-0005b6d0: 2073 656c 662e 5f73 7562 7072 6f63 6573 self._subproces\n-0005b6e0: 735f 7472 616e 7370 6f72 742e 636c 6f73 s_transport.clos\n-0005b6f0: 6528 290a 2020 2020 2020 2020 7365 6c66 e(). self\n-0005b700: 2e5f 6167 656e 742e 666f 7263 655f 636f ._agent.force_co\n-0005b710: 6d70 6c65 7469 6f6e 2829 0a0a 2020 2020 mpletion().. \n-0005b720: 6465 6620 6973 5f63 6c6f 7369 6e67 2873 def is_closing(s\n-0005b730: 656c 6629 202d 3e20 626f 6f6c 3a0a 2020 elf) -> bool:. \n-0005b740: 2020 2020 2020 6173 7365 7274 2073 656c assert sel\n-0005b750: 662e 5f73 7562 7072 6f63 6573 735f 7472 f._subprocess_tr\n-0005b760: 616e 7370 6f72 7420 6973 206e 6f74 204e ansport is not N\n-0005b770: 6f6e 650a 2020 2020 2020 2020 7265 7475 one. retu\n-0005b780: 726e 2073 656c 662e 5f73 7562 7072 6f63 rn self._subproc\n-0005b790: 6573 735f 7472 616e 7370 6f72 742e 6973 ess_transport.is\n-0005b7a0: 5f63 6c6f 7369 6e67 2829 0a0a 2020 2020 _closing().. \n-0005b7b0: 6465 6620 6765 745f 6578 7472 615f 696e def get_extra_in\n-0005b7c0: 666f 2873 656c 662c 206e 616d 653a 2073 fo(self, name: s\n-0005b7d0: 7472 2c20 6465 6661 756c 743a 206f 626a tr, default: obj\n-0005b7e0: 6563 7420 3d20 4e6f 6e65 2920 2d3e 206f ect = None) -> o\n-0005b7f0: 626a 6563 743a 0a20 2020 2020 2020 2061 bject:. a\n-0005b800: 7373 6572 7420 7365 6c66 2e5f 7375 6270 ssert self._subp\n-0005b810: 726f 6365 7373 5f74 7261 6e73 706f 7274 rocess_transport\n-0005b820: 2069 7320 6e6f 7420 4e6f 6e65 0a20 2020 is not None. \n-0005b830: 2020 2020 2072 6574 7572 6e20 7365 6c66 return self\n-0005b840: 2e5f 7375 6270 726f 6365 7373 5f74 7261 ._subprocess_tra\n-0005b850: 6e73 706f 7274 2e67 6574 5f65 7874 7261 nsport.get_extra\n-0005b860: 5f69 6e66 6f28 6e61 6d65 2c20 6465 6661 _info(name, defa\n-0005b870: 756c 7429 0a0a 2020 2020 6465 6620 7365 ult).. def se\n-0005b880: 745f 7072 6f74 6f63 6f6c 2873 656c 662c t_protocol(self,\n-0005b890: 2070 726f 746f 636f 6c3a 2061 7379 6e63 protocol: async\n-0005b8a0: 696f 2e42 6173 6550 726f 746f 636f 6c29 io.BaseProtocol)\n-0005b8b0: 202d 3e20 4e6f 6e65 3a0a 2020 2020 2020 -> None:. \n-0005b8c0: 2020 6173 7365 7274 2069 7369 6e73 7461 assert isinsta\n-0005b8d0: 6e63 6528 7072 6f74 6f63 6f6c 2c20 6173 nce(protocol, as\n-0005b8e0: 796e 6369 6f2e 5072 6f74 6f63 6f6c 290a yncio.Protocol).\n-0005b8f0: 2020 2020 2020 2020 7365 6c66 2e5f 7072 self._pr\n-0005b900: 6f74 6f63 6f6c 203d 2070 726f 746f 636f otocol = protoco\n-0005b910: 6c0a 0a20 2020 2064 6566 2067 6574 5f70 l.. def get_p\n-0005b920: 726f 746f 636f 6c28 7365 6c66 2920 2d3e rotocol(self) ->\n-0005b930: 2061 7379 6e63 696f 2e50 726f 746f 636f asyncio.Protoco\n-0005b940: 6c3a 0a20 2020 2020 2020 2072 6574 7572 l:. retur\n-0005b950: 6e20 7365 6c66 2e5f 7072 6f74 6f63 6f6c n self._protocol\n-0005b960: 0a0a 2020 2020 6465 6620 6973 5f72 6561 .. def is_rea\n-0005b970: 6469 6e67 2873 656c 6629 202d 3e20 626f ding(self) -> bo\n-0005b980: 6f6c 3a0a 2020 2020 2020 2020 6173 7365 ol:. asse\n-0005b990: 7274 2073 656c 662e 5f73 7464 6f75 745f rt self._stdout_\n-0005b9a0: 7472 616e 7370 6f72 7420 6973 206e 6f74 transport is not\n-0005b9b0: 204e 6f6e 650a 2020 2020 2020 2020 7472 None. tr\n-0005b9c0: 793a 0a20 2020 2020 2020 2020 2020 2072 y:. r\n-0005b9d0: 6574 7572 6e20 7365 6c66 2e5f 7374 646f eturn self._stdo\n-0005b9e0: 7574 5f74 7261 6e73 706f 7274 2e69 735f ut_transport.is_\n-0005b9f0: 7265 6164 696e 6728 290a 2020 2020 2020 reading(). \n-0005ba00: 2020 6578 6365 7074 204e 6f74 496d 706c except NotImpl\n-0005ba10: 656d 656e 7465 6445 7272 6f72 3a0a 2020 ementedError:. \n-0005ba20: 2020 2020 2020 2020 2020 2320 5468 6973 # This\n-0005ba30: 2069 7320 2869 6e63 6f72 7265 6374 6c79 is (incorrectly\n-0005ba40: 2920 756e 696d 706c 656d 656e 7465 6420 ) unimplemented \n-0005ba50: 6265 666f 7265 2050 7974 686f 6e20 332e before Python 3.\n-0005ba60: 3131 0a20 2020 2020 2020 2020 2020 2072 11. r\n-0005ba70: 6574 7572 6e20 6e6f 7420 7365 6c66 2e5f eturn not self._\n-0005ba80: 7374 646f 7574 5f74 7261 6e73 706f 7274 stdout_transport\n-0005ba90: 2e5f 7061 7573 6564 2020 2320 7479 7065 ._paused # type\n-0005baa0: 3a69 676e 6f72 655b 6174 7472 2d64 6566 :ignore[attr-def\n-0005bab0: 696e 6564 5d0a 2020 2020 2020 2020 6578 ined]. ex\n-0005bac0: 6365 7074 2041 7474 7269 6275 7465 4572 cept AttributeEr\n-0005bad0: 726f 723a 0a20 2020 2020 2020 2020 2020 ror:. \n-0005bae0: 2023 202e 2e2e 616e 6420 696e 2050 7974 # ...and in Pyt\n-0005baf0: 686f 6e20 332e 3620 6974 2773 2065 7665 hon 3.6 it's eve\n-0005bb00: 6e20 776f 7273 650a 2020 2020 2020 2020 n worse. \n-0005bb10: 2020 2020 7472 793a 0a20 2020 2020 2020 try:. \n-0005bb20: 2020 2020 2020 2020 2073 656c 6563 746f selecto\n-0005bb30: 7220 3d20 7365 6c66 2e5f 7374 646f 7574 r = self._stdout\n-0005bb40: 5f74 7261 6e73 706f 7274 2e5f 6c6f 6f70 _transport._loop\n-0005bb50: 2e5f 7365 6c65 6374 6f72 2020 2320 7479 ._selector # ty\n-0005bb60: 7065 3a69 676e 6f72 655b 6174 7472 2d64 pe:ignore[attr-d\n-0005bb70: 6566 696e 6564 5d0a 2020 2020 2020 2020 efined]. \n-0005bb80: 2020 2020 2020 2020 7365 6c65 6374 6f72 selector\n-0005bb90: 2e67 6574 5f6b 6579 2873 656c 662e 5f73 .get_key(self._s\n-0005bba0: 7464 6f75 745f 7472 616e 7370 6f72 742e tdout_transport.\n-0005bbb0: 5f66 696c 656e 6f29 2020 2320 7479 7065 _fileno) # type\n-0005bbc0: 3a69 676e 6f72 655b 6174 7472 2d64 6566 :ignore[attr-def\n-0005bbd0: 696e 6564 5d0a 2020 2020 2020 2020 2020 ined]. \n-0005bbe0: 2020 2020 2020 7265 7475 726e 2054 7275 return Tru\n-0005bbf0: 650a 2020 2020 2020 2020 2020 2020 6578 e. ex\n-0005bc00: 6365 7074 204b 6579 4572 726f 723a 0a20 cept KeyError:. \n-0005bc10: 2020 2020 2020 2020 2020 2020 2020 2072 r\n-0005bc20: 6574 7572 6e20 4661 6c73 650a 0a20 2020 eturn False.. \n-0005bc30: 2064 6566 2070 6175 7365 5f72 6561 6469 def pause_readi\n-0005bc40: 6e67 2873 656c 6629 202d 3e20 4e6f 6e65 ng(self) -> None\n-0005bc50: 3a0a 2020 2020 2020 2020 6173 7365 7274 :. assert\n-0005bc60: 2073 656c 662e 5f73 7464 6f75 745f 7472 self._stdout_tr\n-0005bc70: 616e 7370 6f72 7420 6973 206e 6f74 204e ansport is not N\n-0005bc80: 6f6e 650a 2020 2020 2020 2020 7365 6c66 one. self\n-0005bc90: 2e5f 7374 646f 7574 5f74 7261 6e73 706f ._stdout_transpo\n-0005bca0: 7274 2e70 6175 7365 5f72 6561 6469 6e67 rt.pause_reading\n-0005bcb0: 2829 0a0a 2020 2020 6465 6620 7265 7375 ().. def resu\n-0005bcc0: 6d65 5f72 6561 6469 6e67 2873 656c 6629 me_reading(self)\n-0005bcd0: 202d 3e20 4e6f 6e65 3a0a 2020 2020 2020 -> None:. \n-0005bce0: 2020 6173 7365 7274 2073 656c 662e 5f73 assert self._s\n-0005bcf0: 7464 6f75 745f 7472 616e 7370 6f72 7420 tdout_transport \n-0005bd00: 6973 206e 6f74 204e 6f6e 650a 2020 2020 is not None. \n-0005bd10: 2020 2020 7365 6c66 2e5f 7374 646f 7574 self._stdout\n-0005bd20: 5f74 7261 6e73 706f 7274 2e72 6573 756d _transport.resum\n-0005bd30: 655f 7265 6164 696e 6728 290a 0a20 2020 e_reading().. \n-0005bd40: 2064 6566 2061 626f 7274 2873 656c 6629 def abort(self)\n-0005bd50: 202d 3e20 4e6f 6e65 3a0a 2020 2020 2020 -> None:. \n-0005bd60: 2020 6173 7365 7274 2073 656c 662e 5f73 assert self._s\n-0005bd70: 7464 696e 5f74 7261 6e73 706f 7274 2069 tdin_transport i\n-0005bd80: 7320 6e6f 7420 4e6f 6e65 0a20 2020 2020 s not None. \n-0005bd90: 2020 2061 7373 6572 7420 7365 6c66 2e5f assert self._\n-0005bda0: 7375 6270 726f 6365 7373 5f74 7261 6e73 subprocess_trans\n-0005bdb0: 706f 7274 2069 7320 6e6f 7420 4e6f 6e65 port is not None\n-0005bdc0: 0a20 2020 2020 2020 2073 656c 662e 5f73 . self._s\n-0005bdd0: 7464 696e 5f74 7261 6e73 706f 7274 2e61 tdin_transport.a\n-0005bde0: 626f 7274 2829 0a20 2020 2020 2020 2073 bort(). s\n-0005bdf0: 656c 662e 5f73 7562 7072 6f63 6573 735f elf._subprocess_\n-0005be00: 7472 616e 7370 6f72 742e 6b69 6c6c 2829 transport.kill()\n-0005be10: 0a0a 2020 2020 6465 6620 6361 6e5f 7772 .. def can_wr\n-0005be20: 6974 655f 656f 6628 7365 6c66 2920 2d3e ite_eof(self) ->\n-0005be30: 2062 6f6f 6c3a 0a20 2020 2020 2020 2061 bool:. a\n-0005be40: 7373 6572 7420 7365 6c66 2e5f 7374 6469 ssert self._stdi\n-0005be50: 6e5f 7472 616e 7370 6f72 7420 6973 206e n_transport is n\n-0005be60: 6f74 204e 6f6e 650a 2020 2020 2020 2020 ot None. \n-0005be70: 7265 7475 726e 2073 656c 662e 5f73 7464 return self._std\n-0005be80: 696e 5f74 7261 6e73 706f 7274 2e63 616e in_transport.can\n-0005be90: 5f77 7269 7465 5f65 6f66 2829 2020 2320 _write_eof() # \n-0005bea0: 7769 6c6c 2061 6c77 6179 7320 6265 2054 will always be T\n-0005beb0: 7275 650a 0a20 2020 2064 6566 2067 6574 rue.. def get\n-0005bec0: 5f77 7269 7465 5f62 7566 6665 725f 7369 _write_buffer_si\n-0005bed0: 7a65 2873 656c 6629 202d 3e20 696e 743a ze(self) -> int:\n-0005bee0: 0a20 2020 2020 2020 2061 7373 6572 7420 . assert \n-0005bef0: 7365 6c66 2e5f 7374 6469 6e5f 7472 616e self._stdin_tran\n-0005bf00: 7370 6f72 7420 6973 206e 6f74 204e 6f6e sport is not Non\n-0005bf10: 650a 2020 2020 2020 2020 7265 7475 726e e. return\n-0005bf20: 2073 656c 662e 5f73 7464 696e 5f74 7261 self._stdin_tra\n-0005bf30: 6e73 706f 7274 2e67 6574 5f77 7269 7465 nsport.get_write\n-0005bf40: 5f62 7566 6665 725f 7369 7a65 2829 0a0a _buffer_size()..\n-0005bf50: 2020 2020 6465 6620 6765 745f 7772 6974 def get_writ\n-0005bf60: 655f 6275 6666 6572 5f6c 696d 6974 7328 e_buffer_limits(\n-0005bf70: 7365 6c66 2920 2d3e 2027 7475 706c 655b self) -> 'tuple[\n-0005bf80: 696e 742c 2069 6e74 5d27 3a0a 2020 2020 int, int]':. \n-0005bf90: 2020 2020 6173 7365 7274 2073 656c 662e assert self.\n-0005bfa0: 5f73 7464 696e 5f74 7261 6e73 706f 7274 _stdin_transport\n-0005bfb0: 2069 7320 6e6f 7420 4e6f 6e65 0a20 2020 is not None. \n-0005bfc0: 2020 2020 2072 6574 7572 6e20 7365 6c66 return self\n-0005bfd0: 2e5f 7374 6469 6e5f 7472 616e 7370 6f72 ._stdin_transpor\n-0005bfe0: 742e 6765 745f 7772 6974 655f 6275 6666 t.get_write_buff\n-0005bff0: 6572 5f6c 696d 6974 7328 290a 0a20 2020 er_limits().. \n-0005c000: 2064 6566 2073 6574 5f77 7269 7465 5f62 def set_write_b\n-0005c010: 7566 6665 725f 6c69 6d69 7473 2873 656c uffer_limits(sel\n-0005c020: 662c 2068 6967 683a 2027 696e 7420 7c20 f, high: 'int | \n-0005c030: 4e6f 6e65 2720 3d20 4e6f 6e65 2c20 6c6f None' = None, lo\n-0005c040: 773a 2027 696e 7420 7c20 4e6f 6e65 2720 w: 'int | None' \n-0005c050: 3d20 4e6f 6e65 2920 2d3e 204e 6f6e 653a = None) -> None:\n-0005c060: 0a20 2020 2020 2020 2061 7373 6572 7420 . assert \n-0005c070: 7365 6c66 2e5f 7374 6469 6e5f 7472 616e self._stdin_tran\n-0005c080: 7370 6f72 7420 6973 206e 6f74 204e 6f6e sport is not Non\n-0005c090: 650a 2020 2020 2020 2020 7265 7475 726e e. return\n-0005c0a0: 2073 656c 662e 5f73 7464 696e 5f74 7261 self._stdin_tra\n-0005c0b0: 6e73 706f 7274 2e73 6574 5f77 7269 7465 nsport.set_write\n-0005c0c0: 5f62 7566 6665 725f 6c69 6d69 7473 2868 _buffer_limits(h\n-0005c0d0: 6967 682c 206c 6f77 290a 0a20 2020 2064 igh, low).. d\n-0005c0e0: 6566 2077 7269 7465 2873 656c 662c 2064 ef write(self, d\n-0005c0f0: 6174 613a 2062 7974 6573 2920 2d3e 204e ata: bytes) -> N\n-0005c100: 6f6e 653a 0a20 2020 2020 2020 2061 7373 one:. ass\n-0005c110: 6572 7420 7365 6c66 2e5f 7374 6469 6e5f ert self._stdin_\n-0005c120: 7472 616e 7370 6f72 7420 6973 206e 6f74 transport is not\n-0005c130: 204e 6f6e 650a 2020 2020 2020 2020 7265 None. re\n-0005c140: 7475 726e 2073 656c 662e 5f73 7464 696e turn self._stdin\n-0005c150: 5f74 7261 6e73 706f 7274 2e77 7269 7465 _transport.write\n-0005c160: 2864 6174 6129 0a0a 2020 2020 6465 6620 (data).. def \n-0005c170: 7772 6974 656c 696e 6573 2873 656c 662c writelines(self,\n-0005c180: 206c 6973 745f 6f66 5f64 6174 613a 2049 list_of_data: I\n-0005c190: 7465 7261 626c 655b 6279 7465 735d 2920 terable[bytes]) \n-0005c1a0: 2d3e 204e 6f6e 653a 0a20 2020 2020 2020 -> None:. \n-0005c1b0: 2061 7373 6572 7420 7365 6c66 2e5f 7374 assert self._st\n-0005c1c0: 6469 6e5f 7472 616e 7370 6f72 7420 6973 din_transport is\n-0005c1d0: 206e 6f74 204e 6f6e 650a 2020 2020 2020 not None. \n-0005c1e0: 2020 7265 7475 726e 2073 656c 662e 5f73 return self._s\n-0005c1f0: 7464 696e 5f74 7261 6e73 706f 7274 2e77 tdin_transport.w\n-0005c200: 7269 7465 6c69 6e65 7328 6c69 7374 5f6f ritelines(list_o\n-0005c210: 665f 6461 7461 290a 0a20 2020 2064 6566 f_data).. def\n-0005c220: 2077 7269 7465 5f65 6f66 2873 656c 6629 write_eof(self)\n-0005c230: 202d 3e20 4e6f 6e65 3a0a 2020 2020 2020 -> None:. \n-0005c240: 2020 6173 7365 7274 2073 656c 662e 5f73 assert self._s\n-0005c250: 7464 696e 5f74 7261 6e73 706f 7274 2069 tdin_transport i\n-0005c260: 7320 6e6f 7420 4e6f 6e65 0a20 2020 2020 s not None. \n-0005c270: 2020 2072 6574 7572 6e20 7365 6c66 2e5f return self._\n-0005c280: 7374 6469 6e5f 7472 616e 7370 6f72 742e stdin_transport.\n-0005c290: 7772 6974 655f 656f 6628 290a 0a20 2020 write_eof().. \n-0005c2a0: 2023 2057 6520 646f 6e27 7420 7265 616c # We don't real\n-0005c2b0: 6c79 2069 6d70 6c65 6d65 6e74 2053 7562 ly implement Sub\n-0005c2c0: 7072 6f63 6573 7354 7261 6e73 706f 7274 processTransport\n-0005c2d0: 2c20 6275 7420 7072 6f76 6964 6520 7468 , but provide th\n-0005c2e0: 6573 6520 6173 0a20 2020 2023 2022 6578 ese as. # \"ex\n-0005c2f0: 7472 6173 2220 746f 206f 7572 2075 7365 tras\" to our use\n-0005c300: 722e 0a20 2020 2064 6566 2067 6574 5f70 r.. def get_p\n-0005c310: 6964 2873 656c 6629 202d 3e20 696e 743a id(self) -> int:\n-0005c320: 0a20 2020 2020 2020 2061 7373 6572 7420 . assert \n-0005c330: 7365 6c66 2e5f 7375 6270 726f 6365 7373 self._subprocess\n-0005c340: 5f74 7261 6e73 706f 7274 2069 7320 6e6f _transport is no\n-0005c350: 7420 4e6f 6e65 0a20 2020 2020 2020 2072 t None. r\n-0005c360: 6574 7572 6e20 7365 6c66 2e5f 7375 6270 eturn self._subp\n-0005c370: 726f 6365 7373 5f74 7261 6e73 706f 7274 rocess_transport\n-0005c380: 2e67 6574 5f70 6964 2829 0a0a 2020 2020 .get_pid().. \n-0005c390: 6465 6620 6765 745f 7265 7475 726e 636f def get_returnco\n-0005c3a0: 6465 2873 656c 6629 202d 3e20 2769 6e74 de(self) -> 'int\n-0005c3b0: 207c 204e 6f6e 6527 3a0a 2020 2020 2020 | None':. \n-0005c3c0: 2020 7265 7475 726e 2073 656c 662e 5f72 return self._r\n-0005c3d0: 6574 7572 6e63 6f64 650a 0a20 2020 2064 eturncode.. d\n-0005c3e0: 6566 206b 696c 6c28 7365 6c66 2920 2d3e ef kill(self) ->\n-0005c3f0: 204e 6f6e 653a 0a20 2020 2020 2020 2061 None:. a\n-0005c400: 7373 6572 7420 7365 6c66 2e5f 7375 6270 ssert self._subp\n-0005c410: 726f 6365 7373 5f74 7261 6e73 706f 7274 rocess_transport\n-0005c420: 2069 7320 6e6f 7420 4e6f 6e65 0a20 2020 is not None. \n-0005c430: 2020 2020 2073 656c 662e 5f73 7562 7072 self._subpr\n-0005c440: 6f63 6573 735f 7472 616e 7370 6f72 742e ocess_transport.\n-0005c450: 6b69 6c6c 2829 0a0a 2020 2020 6465 6620 kill().. def \n-0005c460: 7365 6e64 5f73 6967 6e61 6c28 7365 6c66 send_signal(self\n-0005c470: 2c20 6e75 6d62 6572 3a20 696e 7429 202d , number: int) -\n-0005c480: 3e20 4e6f 6e65 3a0a 2020 2020 2020 2020 > None:. \n-0005c490: 6173 7365 7274 2073 656c 662e 5f73 7562 assert self._sub\n-0005c4a0: 7072 6f63 6573 735f 7472 616e 7370 6f72 process_transpor\n-0005c4b0: 7420 6973 206e 6f74 204e 6f6e 650a 2020 t is not None. \n-0005c4c0: 2020 2020 2020 7365 6c66 2e5f 7375 6270 self._subp\n-0005c4d0: 726f 6365 7373 5f74 7261 6e73 706f 7274 rocess_transport\n-0005c4e0: 2e73 656e 645f 7369 676e 616c 286e 756d .send_signal(num\n-0005c4f0: 6265 7229 0a0a 2020 2020 6465 6620 7465 ber).. def te\n-0005c500: 726d 696e 6174 6528 7365 6c66 2920 2d3e rminate(self) ->\n-0005c510: 204e 6f6e 653a 0a20 2020 2020 2020 2061 None:. a\n-0005c520: 7373 6572 7420 7365 6c66 2e5f 7375 6270 ssert self._subp\n-0005c530: 726f 6365 7373 5f74 7261 6e73 706f 7274 rocess_transport\n-0005c540: 2069 7320 6e6f 7420 4e6f 6e65 0a20 2020 is not None. \n-0005c550: 2020 2020 2073 656c 662e 5f73 7562 7072 self._subpr\n-0005c560: 6f63 6573 735f 7472 616e 7370 6f72 742e ocess_transport.\n-0005c570: 7465 726d 696e 6174 6528 290a 2727 272c terminate().''',\n-0005c580: 0a20 2027 636f 636b 7069 742f 5f76 656e . 'cockpit/_ven\n-0005c590: 646f 722f 6665 726e 792f 6173 6b70 6173 dor/ferny/askpas\n-0005c5a0: 732e 7079 273a 2062 7227 2727 6672 6f6d s.py': br'''from\n-0005c5b0: 202e 696e 7465 7261 6374 696f 6e5f 636c .interaction_cl\n-0005c5c0: 6965 6e74 2069 6d70 6f72 7420 6d61 696e ient import main\n-0005c5d0: 0a0a 6966 205f 5f6e 616d 655f 5f20 3d3d ..if __name__ ==\n-0005c5e0: 2027 5f5f 6d61 696e 5f5f 273a 0a20 2020 '__main__':. \n-0005c5f0: 206d 6169 6e28 290a 2727 272c 0a20 2027 main().''',. '\n-0005c600: 636f 636b 7069 742f 5f76 656e 646f 722f cockpit/_vendor/\n-0005c610: 6665 726e 792f 696e 7465 7261 6374 696f ferny/interactio\n-0005c620: 6e5f 636c 6965 6e74 2e70 7927 3a20 6272 n_client.py': br\n-0005c630: 2727 2723 212f 7573 722f 6269 6e2f 7079 '''#!/usr/bin/py\n-0005c640: 7468 6f6e 330a 0a69 6d70 6f72 7420 6172 thon3..import ar\n-0005c650: 7261 790a 696d 706f 7274 2069 6f0a 696d ray.import io.im\n-0005c660: 706f 7274 206f 730a 696d 706f 7274 2073 port os.import s\n-0005c670: 6f63 6b65 740a 696d 706f 7274 2073 7973 ocket.import sys\n-0005c680: 0a66 726f 6d20 7479 7069 6e67 2069 6d70 .from typing imp\n-0005c690: 6f72 7420 5365 7175 656e 6365 0a0a 0a64 ort Sequence...d\n-0005c6a0: 6566 2063 6f6d 6d61 6e64 2873 7464 6572 ef command(stder\n-0005c6b0: 725f 6664 3a20 696e 742c 2063 6f6d 6d61 r_fd: int, comma\n-0005c6c0: 6e64 3a20 7374 722c 202a 6172 6773 3a20 nd: str, *args: \n-0005c6d0: 6f62 6a65 6374 2c20 6664 733a 2053 6571 object, fds: Seq\n-0005c6e0: 7565 6e63 655b 696e 745d 203d 2028 2929 uence[int] = ())\n-0005c6f0: 202d 3e20 4e6f 6e65 3a0a 2020 2020 636d -> None:. cm\n-0005c700: 645f 7265 6164 2c20 636d 645f 7772 6974 d_read, cmd_writ\n-0005c710: 6520 3d20 5b69 6f2e 6f70 656e 282a 656e e = [io.open(*en\n-0005c720: 6429 2066 6f72 2065 6e64 2069 6e20 7a69 d) for end in zi\n-0005c730: 7028 6f73 2e70 6970 6528 292c 2027 7277 p(os.pipe(), 'rw\n-0005c740: 2729 5d0a 0a20 2020 2077 6974 6820 636d ')].. with cm\n-0005c750: 645f 7772 6974 653a 0a20 2020 2020 2020 d_write:. \n-0005c760: 2077 6974 6820 636d 645f 7265 6164 3a0a with cmd_read:.\n-0005c770: 2020 2020 2020 2020 2020 2020 7769 7468 with\n-0005c780: 2073 6f63 6b65 742e 6672 6f6d 6664 2873 socket.fromfd(s\n-0005c790: 7464 6572 725f 6664 2c20 736f 636b 6574 tderr_fd, socket\n-0005c7a0: 2e41 465f 554e 4958 2c20 736f 636b 6574 .AF_UNIX, socket\n-0005c7b0: 2e53 4f43 4b5f 5354 5245 414d 2920 6173 .SOCK_STREAM) as\n-0005c7c0: 2073 6f63 6b3a 0a20 2020 2020 2020 2020 sock:. \n-0005c7d0: 2020 2020 2020 2066 645f 6172 7261 7920 fd_array \n-0005c7e0: 3d20 6172 7261 792e 6172 7261 7928 2769 = array.array('i\n-0005c7f0: 272c 2028 636d 645f 7265 6164 2e66 696c ', (cmd_read.fil\n-0005c800: 656e 6f28 292c 202a 6664 7329 290a 2020 eno(), *fds)). \n-0005c810: 2020 2020 2020 2020 2020 2020 2020 736f so\n-0005c820: 636b 2e73 656e 646d 7367 285b 6227 5c30 ck.sendmsg([b'\\0\n-0005c830: 275d 2c20 5b28 736f 636b 6574 2e53 4f4c '], [(socket.SOL\n-0005c840: 5f53 4f43 4b45 542c 2073 6f63 6b65 742e _SOCKET, socket.\n-0005c850: 5343 4d5f 5249 4748 5453 2c20 6664 5f61 SCM_RIGHTS, fd_a\n-0005c860: 7272 6179 295d 290a 0a20 2020 2020 2020 rray)]).. \n-0005c870: 2063 6d64 5f77 7269 7465 2e77 7269 7465 cmd_write.write\n-0005c880: 2872 6570 7228 2863 6f6d 6d61 6e64 2c20 (repr((command, \n-0005c890: 6172 6773 2929 290a 0a0a 6465 6620 6173 args)))...def as\n-0005c8a0: 6b70 6173 7328 7374 6465 7272 5f66 643a kpass(stderr_fd:\n-0005c8b0: 2069 6e74 2c20 7374 646f 7574 5f66 643a int, stdout_fd:\n-0005c8c0: 2069 6e74 2c20 6172 6773 3a20 276c 6973 int, args: 'lis\n-0005c8d0: 745b 7374 725d 272c 2065 6e76 3a20 2764 t[str]', env: 'd\n-0005c8e0: 6963 745b 7374 722c 2073 7472 5d27 2920 ict[str, str]') \n-0005c8f0: 2d3e 2069 6e74 3a0a 2020 2020 6f75 7273 -> int:. ours\n-0005c900: 2c20 7468 6569 7273 203d 2073 6f63 6b65 , theirs = socke\n-0005c910: 742e 736f 636b 6574 7061 6972 2829 0a0a t.socketpair()..\n-0005c920: 2020 2020 7769 7468 2074 6865 6972 733a with theirs:\n-0005c930: 0a20 2020 2020 2020 2063 6f6d 6d61 6e64 . command\n-0005c940: 2873 7464 6572 725f 6664 2c20 2766 6572 (stderr_fd, 'fer\n-0005c950: 6e79 2e61 736b 7061 7373 272c 2061 7267 ny.askpass', arg\n-0005c960: 732c 2065 6e76 2c20 6664 733d 2874 6865 s, env, fds=(the\n-0005c970: 6972 732e 6669 6c65 6e6f 2829 2c20 7374 irs.fileno(), st\n-0005c980: 646f 7574 5f66 6429 290a 0a20 2020 2077 dout_fd)).. w\n-0005c990: 6974 6820 6f75 7273 3a0a 2020 2020 2020 ith ours:. \n-0005c9a0: 2020 7265 7475 726e 2069 6e74 286f 7572 return int(our\n-0005c9b0: 732e 7265 6376 2831 3629 206f 7220 6227 s.recv(16) or b'\n-0005c9c0: 3127 290a 0a0a 6465 6620 6d61 696e 2829 1')...def main()\n-0005c9d0: 202d 3e20 4e6f 6e65 3a0a 2020 2020 6966 -> None:. if\n-0005c9e0: 206c 656e 2873 7973 2e61 7267 7629 203d len(sys.argv) =\n-0005c9f0: 3d20 313a 0a20 2020 2020 2020 2063 6f6d = 1:. com\n-0005ca00: 6d61 6e64 2832 2c20 2766 6572 6e79 2e65 mand(2, 'ferny.e\n-0005ca10: 6e64 272c 205b 5d29 0a20 2020 2065 6c73 nd', []). els\n-0005ca20: 653a 0a20 2020 2020 2020 2073 7973 2e65 e:. sys.e\n-0005ca30: 7869 7428 6173 6b70 6173 7328 322c 2031 xit(askpass(2, 1\n-0005ca40: 2c20 7379 732e 6172 6776 2c20 6469 6374 , sys.argv, dict\n-0005ca50: 286f 732e 656e 7669 726f 6e29 2929 0a0a (os.environ)))..\n-0005ca60: 0a69 6620 5f5f 6e61 6d65 5f5f 203d 3d20 .if __name__ == \n-0005ca70: 275f 5f6d 6169 6e5f 5f27 3a0a 2020 2020 '__main__':. \n-0005ca80: 6d61 696e 2829 0a27 2727 2c0a 2020 2763 main().''',. 'c\n-0005ca90: 6f63 6b70 6974 2f5f 7665 6e64 6f72 2f66 ockpit/_vendor/f\n-0005caa0: 6572 6e79 2f5f 5f69 6e69 745f 5f2e 7079 erny/__init__.py\n-0005cab0: 273a 2062 7227 2727 6672 6f6d 202e 696e ': br'''from .in\n-0005cac0: 7465 7261 6374 696f 6e5f 6167 656e 7420 teraction_agent \n-0005cad0: 696d 706f 7274 2028 0a20 2020 2042 4549 import (. BEI\n-0005cae0: 424f 4f54 5f47 4144 4745 5453 2c0a 2020 BOOT_GADGETS,. \n-0005caf0: 2020 434f 4d4d 414e 445f 5445 4d50 4c41 COMMAND_TEMPLA\n-0005cb00: 5445 2c0a 2020 2020 4173 6b70 6173 7348 TE,. AskpassH\n-0005cb10: 616e 646c 6572 2c0a 2020 2020 496e 7465 andler,. Inte\n-0005cb20: 7261 6374 696f 6e41 6765 6e74 2c0a 2020 ractionAgent,. \n-0005cb30: 2020 496e 7465 7261 6374 696f 6e45 7272 InteractionErr\n-0005cb40: 6f72 2c0a 2020 2020 496e 7465 7261 6374 or,. Interact\n-0005cb50: 696f 6e48 616e 646c 6572 2c0a 2020 2020 ionHandler,. \n-0005cb60: 7465 6d70 6f72 6172 795f 6173 6b70 6173 temporary_askpas\n-0005cb70: 732c 0a20 2020 2077 7269 7465 5f61 736b s,. write_ask\n-0005cb80: 7061 7373 5f74 6f5f 746d 7064 6972 2c0a pass_to_tmpdir,.\n-0005cb90: 290a 6672 6f6d 202e 7365 7373 696f 6e20 ).from .session \n-0005cba0: 696d 706f 7274 2053 6573 7369 6f6e 0a66 import Session.f\n-0005cbb0: 726f 6d20 2e73 7368 5f61 736b 7061 7373 rom .ssh_askpass\n-0005cbc0: 2069 6d70 6f72 7420 280a 2020 2020 4173 import (. As\n-0005cbd0: 6b70 6173 7350 726f 6d70 742c 0a20 2020 kpassPrompt,. \n-0005cbe0: 2053 7368 4173 6b70 6173 7352 6573 706f SshAskpassRespo\n-0005cbf0: 6e64 6572 2c0a 2020 2020 5373 6846 4944 nder,. SshFID\n-0005cc00: 4f50 494e 5072 6f6d 7074 2c0a 2020 2020 OPINPrompt,. \n-0005cc10: 5373 6846 4944 4f55 7365 7250 7265 7365 SshFIDOUserPrese\n-0005cc20: 6e63 6550 726f 6d70 742c 0a20 2020 2053 ncePrompt,. S\n-0005cc30: 7368 486f 7374 4b65 7950 726f 6d70 742c shHostKeyPrompt,\n-0005cc40: 0a20 2020 2053 7368 5061 7373 7068 7261 . SshPassphra\n-0005cc50: 7365 5072 6f6d 7074 2c0a 2020 2020 5373 sePrompt,. Ss\n-0005cc60: 6850 6173 7377 6f72 6450 726f 6d70 742c hPasswordPrompt,\n-0005cc70: 0a20 2020 2053 7368 504b 4353 3131 5049 . SshPKCS11PI\n-0005cc80: 4e50 726f 6d70 742c 0a29 0a66 726f 6d20 NPrompt,.).from \n-0005cc90: 2e73 7368 5f65 7272 6f72 7320 696d 706f .ssh_errors impo\n-0005cca0: 7274 2028 0a20 2020 2053 7368 4175 7468 rt (. SshAuth\n-0005ccb0: 656e 7469 6361 7469 6f6e 4572 726f 722c enticationError,\n-0005ccc0: 0a20 2020 2053 7368 4368 616e 6765 6448 . SshChangedH\n-0005ccd0: 6f73 744b 6579 4572 726f 722c 0a20 2020 ostKeyError,. \n-0005cce0: 2053 7368 4572 726f 722c 0a20 2020 2053 SshError,. S\n-0005ccf0: 7368 486f 7374 4b65 7945 7272 6f72 2c0a shHostKeyError,.\n-0005cd00: 2020 2020 5373 6855 6e6b 6e6f 776e 486f SshUnknownHo\n-0005cd10: 7374 4b65 7945 7272 6f72 2c0a 290a 6672 stKeyError,.).fr\n-0005cd20: 6f6d 202e 7472 616e 7370 6f72 7420 696d om .transport im\n-0005cd30: 706f 7274 2046 6572 6e79 5472 616e 7370 port FernyTransp\n-0005cd40: 6f72 742c 2053 7562 7072 6f63 6573 7345 ort, SubprocessE\n-0005cd50: 7272 6f72 0a0a 5f5f 616c 6c5f 5f20 3d20 rror..__all__ = \n-0005cd60: 5b0a 2020 2020 2741 736b 7061 7373 4861 [. 'AskpassHa\n-0005cd70: 6e64 6c65 7227 2c0a 2020 2020 2741 736b ndler',. 'Ask\n-0005cd80: 7061 7373 5072 6f6d 7074 272c 0a20 2020 passPrompt',. \n-0005cd90: 2027 4175 7468 656e 7469 6361 7469 6f6e 'Authentication\n-0005cda0: 4572 726f 7227 2c0a 2020 2020 2742 4549 Error',. 'BEI\n-0005cdb0: 424f 4f54 5f47 4144 4745 5453 272c 0a20 BOOT_GADGETS',. \n-0005cdc0: 2020 2027 434f 4d4d 414e 445f 5445 4d50 'COMMAND_TEMP\n-0005cdd0: 4c41 5445 272c 0a20 2020 2027 4368 616e LATE',. 'Chan\n-0005cde0: 6765 6448 6f73 744b 6579 4572 726f 7227 gedHostKeyError'\n-0005cdf0: 2c0a 2020 2020 2746 6572 6e79 5472 616e ,. 'FernyTran\n-0005ce00: 7370 6f72 7427 2c0a 2020 2020 2748 6f73 sport',. 'Hos\n-0005ce10: 744b 6579 4572 726f 7227 2c0a 2020 2020 tKeyError',. \n-0005ce20: 2749 6e74 6572 6163 7469 6f6e 4167 656e 'InteractionAgen\n-0005ce30: 7427 2c0a 2020 2020 2749 6e74 6572 6163 t',. 'Interac\n-0005ce40: 7469 6f6e 4572 726f 7227 2c0a 2020 2020 tionError',. \n-0005ce50: 2749 6e74 6572 6163 7469 6f6e 4861 6e64 'InteractionHand\n-0005ce60: 6c65 7227 2c0a 2020 2020 2753 6573 7369 ler',. 'Sessi\n-0005ce70: 6f6e 272c 0a20 2020 2027 5373 6841 736b on',. 'SshAsk\n-0005ce80: 7061 7373 5265 7370 6f6e 6465 7227 2c0a passResponder',.\n-0005ce90: 2020 2020 2753 7368 4175 7468 656e 7469 'SshAuthenti\n-0005cea0: 6361 7469 6f6e 4572 726f 7227 2c0a 2020 cationError',. \n-0005ceb0: 2020 2753 7368 4368 616e 6765 6448 6f73 'SshChangedHos\n-0005cec0: 744b 6579 4572 726f 7227 2c0a 2020 2020 tKeyError',. \n-0005ced0: 2753 7368 4572 726f 7227 2c0a 2020 2020 'SshError',. \n-0005cee0: 2753 7368 4649 444f 5049 4e50 726f 6d70 'SshFIDOPINPromp\n-0005cef0: 7427 2c0a 2020 2020 2753 7368 4649 444f t',. 'SshFIDO\n-0005cf00: 5573 6572 5072 6573 656e 6365 5072 6f6d UserPresenceProm\n-0005cf10: 7074 272c 0a20 2020 2027 5373 6848 6f73 pt',. 'SshHos\n-0005cf20: 744b 6579 4572 726f 7227 2c0a 2020 2020 tKeyError',. \n-0005cf30: 2753 7368 486f 7374 4b65 7950 726f 6d70 'SshHostKeyPromp\n-0005cf40: 7427 2c0a 2020 2020 2753 7368 504b 4353 t',. 'SshPKCS\n-0005cf50: 3131 5049 4e50 726f 6d70 7427 2c0a 2020 11PINPrompt',. \n-0005cf60: 2020 2753 7368 5061 7373 7068 7261 7365 'SshPassphrase\n-0005cf70: 5072 6f6d 7074 272c 0a20 2020 2027 5373 Prompt',. 'Ss\n-0005cf80: 6850 6173 7377 6f72 6450 726f 6d70 7427 hPasswordPrompt'\n-0005cf90: 2c0a 2020 2020 2753 7368 556e 6b6e 6f77 ,. 'SshUnknow\n-0005cfa0: 6e48 6f73 744b 6579 4572 726f 7227 2c0a nHostKeyError',.\n-0005cfb0: 2020 2020 2753 7562 7072 6f63 6573 7345 'SubprocessE\n-0005cfc0: 7272 6f72 272c 0a20 2020 2027 7465 6d70 rror',. 'temp\n-0005cfd0: 6f72 6172 795f 6173 6b70 6173 7327 2c0a orary_askpass',.\n-0005cfe0: 2020 2020 2777 7269 7465 5f61 736b 7061 'write_askpa\n-0005cff0: 7373 5f74 6f5f 746d 7064 6972 272c 0a5d ss_to_tmpdir',.]\n-0005d000: 0a0a 5f5f 7665 7273 696f 6e5f 5f20 3d20 ..__version__ = \n-0005d010: 2730 270a 2727 272c 0a20 2027 636f 636b '0'.''',. 'cock\n-0005d020: 7069 742f 5f76 656e 646f 722f 6665 726e pit/_vendor/fern\n-0005d030: 792f 7373 685f 6572 726f 7273 2e70 7927 y/ssh_errors.py'\n-0005d040: 3a20 6272 2727 2723 2066 6572 6e79 202d : br'''# ferny -\n-0005d050: 2061 7379 6e63 696f 2053 5348 2063 6c69 asyncio SSH cli\n-0005d060: 656e 7420 6c69 6272 6172 792c 2075 7369 ent library, usi\n-0005d070: 6e67 2073 7368 2831 290a 230a 2320 436f ng ssh(1).#.# Co\n-0005d080: 7079 7269 6768 7420 2843 2920 3230 3233 pyright (C) 2023\n-0005d090: 2041 6c6c 6973 6f6e 204b 6172 6c69 7473 Allison Karlits\n-0005d0a0: 6b61 7961 203c 616c 6c69 736f 6e2e 6b61 kaya <allison.ka\n-0005d0b0: 726c 6974 736b 6179 6140 7265 6468 6174 rlitskaya@redhat\n-0005d0c0: 2e63 6f6d 3e0a 230a 2320 5468 6973 2070 .com>.#.# This p\n-0005d0d0: 726f 6772 616d 2069 7320 6672 6565 2073 rogram is free s\n-0005d0e0: 6f66 7477 6172 653a 2079 6f75 2063 616e oftware: you can\n-0005d0f0: 2072 6564 6973 7472 6962 7574 6520 6974 redistribute it\n-0005d100: 2061 6e64 2f6f 7220 6d6f 6469 6679 0a23 and/or modify.#\n-0005d110: 2069 7420 756e 6465 7220 7468 6520 7465 it under the te\n-0005d120: 726d 7320 6f66 2074 6865 2047 4e55 2047 rms of the GNU G\n-0005d130: 656e 6572 616c 2050 7562 6c69 6320 4c69 eneral Public Li\n-0005d140: 6365 6e73 6520 6173 2070 7562 6c69 7368 cense as publish\n-0005d150: 6564 2062 790a 2320 7468 6520 4672 6565 ed by.# the Free\n-0005d160: 2053 6f66 7477 6172 6520 466f 756e 6461 Software Founda\n-0005d170: 7469 6f6e 2c20 6569 7468 6572 2076 6572 tion, either ver\n-0005d180: 7369 6f6e 2033 206f 6620 7468 6520 4c69 sion 3 of the Li\n-0005d190: 6365 6e73 652c 206f 720a 2320 2861 7420 cense, or.# (at \n-0005d1a0: 796f 7572 206f 7074 696f 6e29 2061 6e79 your option) any\n-0005d1b0: 206c 6174 6572 2076 6572 7369 6f6e 2e0a later version..\n-0005d1c0: 230a 2320 5468 6973 2070 726f 6772 616d #.# This program\n-0005d1d0: 2069 7320 6469 7374 7269 6275 7465 6420 is distributed \n-0005d1e0: 696e 2074 6865 2068 6f70 6520 7468 6174 in the hope that\n-0005d1f0: 2069 7420 7769 6c6c 2062 6520 7573 6566 it will be usef\n-0005d200: 756c 2c0a 2320 6275 7420 5749 5448 4f55 ul,.# but WITHOU\n-0005d210: 5420 414e 5920 5741 5252 414e 5459 3b20 T ANY WARRANTY; \n-0005d220: 7769 7468 6f75 7420 6576 656e 2074 6865 without even the\n-0005d230: 2069 6d70 6c69 6564 2077 6172 7261 6e74 implied warrant\n-0005d240: 7920 6f66 0a23 204d 4552 4348 414e 5441 y of.# MERCHANTA\n-0005d250: 4249 4c49 5459 206f 7220 4649 544e 4553 BILITY or FITNES\n-0005d260: 5320 464f 5220 4120 5041 5254 4943 554c S FOR A PARTICUL\n-0005d270: 4152 2050 5552 504f 5345 2e20 2053 6565 AR PURPOSE. See\n-0005d280: 2074 6865 0a23 2047 4e55 2047 656e 6572 the.# GNU Gener\n-0005d290: 616c 2050 7562 6c69 6320 4c69 6365 6e73 al Public Licens\n-0005d2a0: 6520 666f 7220 6d6f 7265 2064 6574 6169 e for more detai\n-0005d2b0: 6c73 2e0a 230a 2320 596f 7520 7368 6f75 ls..#.# You shou\n-0005d2c0: 6c64 2068 6176 6520 7265 6365 6976 6564 ld have received\n-0005d2d0: 2061 2063 6f70 7920 6f66 2074 6865 2047 a copy of the G\n-0005d2e0: 4e55 2047 656e 6572 616c 2050 7562 6c69 NU General Publi\n-0005d2f0: 6320 4c69 6365 6e73 650a 2320 616c 6f6e c License.# alon\n-0005d300: 6720 7769 7468 2074 6869 7320 7072 6f67 g with this prog\n-0005d310: 7261 6d2e 2020 4966 206e 6f74 2c20 7365 ram. If not, se\n-0005d320: 6520 3c68 7474 703a 2f2f 7777 772e 676e e <http://www.gn\n-0005d330: 752e 6f72 672f 6c69 6365 6e73 6573 2f3e u.org/licenses/>\n-0005d340: 2e0a 0a69 6d70 6f72 7420 6374 7970 6573 ...import ctypes\n-0005d350: 0a69 6d70 6f72 7420 6572 726e 6f0a 696d .import errno.im\n-0005d360: 706f 7274 206f 730a 696d 706f 7274 2072 port os.import r\n-0005d370: 650a 696d 706f 7274 2073 6f63 6b65 740a e.import socket.\n-0005d380: 6672 6f6d 2074 7970 696e 6720 696d 706f from typing impo\n-0005d390: 7274 2043 6c61 7373 5661 722c 2049 7465 rt ClassVar, Ite\n-0005d3a0: 7261 626c 652c 204d 6174 6368 2c20 5061 rable, Match, Pa\n-0005d3b0: 7474 6572 6e0a 0a0a 636c 6173 7320 5373 ttern...class Ss\n-0005d3c0: 6845 7272 6f72 2845 7863 6570 7469 6f6e hError(Exception\n-0005d3d0: 293a 0a20 2020 2050 4154 5445 524e 3a20 ):. PATTERN: \n-0005d3e0: 436c 6173 7356 6172 5b50 6174 7465 726e ClassVar[Pattern\n-0005d3f0: 5d0a 0a20 2020 2064 6566 205f 5f69 6e69 ].. def __ini\n-0005d400: 745f 5f28 7365 6c66 2c20 6d61 7463 683a t__(self, match:\n-0005d410: 2027 4d61 7463 6820 7c20 4e6f 6e65 272c 'Match | None',\n-0005d420: 2073 7464 6572 723a 2073 7472 2920 2d3e stderr: str) ->\n-0005d430: 204e 6f6e 653a 0a20 2020 2020 2020 2073 None:. s\n-0005d440: 7570 6572 2829 2e5f 5f69 6e69 745f 5f28 uper().__init__(\n-0005d450: 6d61 7463 682e 6772 6f75 7028 3029 2069 match.group(0) i\n-0005d460: 6620 6d61 7463 6820 6973 206e 6f74 204e f match is not N\n-0005d470: 6f6e 6520 656c 7365 2073 7464 6572 7229 one else stderr)\n-0005d480: 0a20 2020 2020 2020 2073 656c 662e 7374 . self.st\n-0005d490: 6465 7272 203d 2073 7464 6572 720a 0a0a derr = stderr...\n-0005d4a0: 636c 6173 7320 5373 6841 7574 6865 6e74 class SshAuthent\n-0005d4b0: 6963 6174 696f 6e45 7272 6f72 2853 7368 icationError(Ssh\n-0005d4c0: 4572 726f 7229 3a0a 2020 2020 5041 5454 Error):. PATT\n-0005d4d0: 4552 4e20 3d20 7265 2e63 6f6d 7069 6c65 ERN = re.compile\n-0005d4e0: 2872 275e 285b 5e3a 5d2b 293a 2050 6572 (r'^([^:]+): Per\n-0005d4f0: 6d69 7373 696f 6e20 6465 6e69 6564 205c mission denied \\\n-0005d500: 2828 5b5e 2829 5d2b 295c 295c 2e24 272c (([^()]+)\\)\\.$',\n-0005d510: 2072 652e 4d29 0a0a 2020 2020 6465 6620 re.M).. def \n-0005d520: 5f5f 696e 6974 5f5f 2873 656c 662c 206d __init__(self, m\n-0005d530: 6174 6368 3a20 4d61 7463 682c 2073 7464 atch: Match, std\n-0005d540: 6572 723a 2073 7472 2920 2d3e 204e 6f6e err: str) -> Non\n-0005d550: 653a 0a20 2020 2020 2020 2073 7570 6572 e:. super\n-0005d560: 2829 2e5f 5f69 6e69 745f 5f28 6d61 7463 ().__init__(matc\n-0005d570: 682c 2073 7464 6572 7229 0a20 2020 2020 h, stderr). \n-0005d580: 2020 2073 656c 662e 6465 7374 696e 6174 self.destinat\n-0005d590: 696f 6e20 3d20 6d61 7463 682e 6772 6f75 ion = match.grou\n-0005d5a0: 7028 3129 0a20 2020 2020 2020 2073 656c p(1). sel\n-0005d5b0: 662e 6d65 7468 6f64 7320 3d20 6d61 7463 f.methods = matc\n-0005d5c0: 682e 6772 6f75 7028 3229 2e73 706c 6974 h.group(2).split\n-0005d5d0: 2827 2c27 290a 2020 2020 2020 2020 7365 (','). se\n-0005d5e0: 6c66 2e6d 6573 7361 6765 203d 206d 6174 lf.message = mat\n-0005d5f0: 6368 2e67 726f 7570 2830 290a 0a0a 2320 ch.group(0)...# \n-0005d600: 6765 6e65 7269 6320 686f 7374 206b 6579 generic host key\n-0005d610: 2065 7272 6f72 2066 6f72 204f 5365 7320 error for OSes \n-0005d620: 7769 7468 6f75 7420 4b6e 6f77 6e48 6f73 without KnownHos\n-0005d630: 7473 436f 6d6d 616e 6420 7375 7070 6f72 tsCommand suppor\n-0005d640: 740a 636c 6173 7320 5373 6848 6f73 744b t.class SshHostK\n-0005d650: 6579 4572 726f 7228 5373 6845 7272 6f72 eyError(SshError\n-0005d660: 293a 0a20 2020 2050 4154 5445 524e 203d ):. PATTERN =\n-0005d670: 2072 652e 636f 6d70 696c 6528 7227 5e48 re.compile(r'^H\n-0005d680: 6f73 7420 6b65 7920 7665 7269 6669 6361 ost key verifica\n-0005d690: 7469 6f6e 2066 6169 6c65 642e 2427 2c20 tion failed.$', \n-0005d6a0: 7265 2e4d 290a 0a0a 2320 7370 6563 6966 re.M)...# specif\n-0005d6b0: 6963 2065 7272 6f72 7320 666f 7220 4f53 ic errors for OS\n-0005d6c0: 6573 2077 6974 6820 4b6e 6f77 6e48 6f73 es with KnownHos\n-0005d6d0: 7473 436f 6d6d 616e 640a 636c 6173 7320 tsCommand.class \n-0005d6e0: 5373 6855 6e6b 6e6f 776e 486f 7374 4b65 SshUnknownHostKe\n-0005d6f0: 7945 7272 6f72 2853 7368 486f 7374 4b65 yError(SshHostKe\n-0005d700: 7945 7272 6f72 293a 0a20 2020 2050 4154 yError):. PAT\n-0005d710: 5445 524e 203d 2072 652e 636f 6d70 696c TERN = re.compil\n-0005d720: 6528 7227 5e4e 6f20 2e2a 2068 6f73 7420 e(r'^No .* host \n-0005d730: 6b65 7920 6973 206b 6e6f 776e 2e2a 486f key is known.*Ho\n-0005d740: 7374 206b 6579 2076 6572 6966 6963 6174 st key verificat\n-0005d750: 696f 6e20 6661 696c 6564 2e24 272c 2072 ion failed.$', r\n-0005d760: 652e 5320 7c20 7265 2e4d 290a 0a0a 636c e.S | re.M)...cl\n-0005d770: 6173 7320 5373 6843 6861 6e67 6564 486f ass SshChangedHo\n-0005d780: 7374 4b65 7945 7272 6f72 2853 7368 486f stKeyError(SshHo\n-0005d790: 7374 4b65 7945 7272 6f72 293a 0a20 2020 stKeyError):. \n-0005d7a0: 2050 4154 5445 524e 203d 2072 652e 636f PATTERN = re.co\n-0005d7b0: 6d70 696c 6528 7227 7761 726e 696e 672e mpile(r'warning.\n-0005d7c0: 2a72 656d 6f74 6520 686f 7374 2069 6465 *remote host ide\n-0005d7d0: 6e74 6966 6963 6174 696f 6e20 6861 7320 ntification has \n-0005d7e0: 6368 616e 6765 6427 2c20 7265 2e49 290a changed', re.I).\n-0005d7f0: 0a0a 2320 4675 6e63 7469 6f6e 616c 6974 ..# Functionalit\n-0005d800: 7920 666f 7220 6d61 7070 696e 6720 6765 y for mapping ge\n-0005d810: 7461 6464 7269 6e66 6f28 292d 6661 6d69 taddrinfo()-fami\n-0005d820: 6c79 2065 7272 6f72 206d 6573 7361 6765 ly error message\n-0005d830: 7320 746f 2074 6865 6972 0a23 2065 7175 s to their.# equ\n-0005d840: 6976 616c 656e 7420 5079 7468 6f6e 2065 ivalent Python e\n-0005d850: 7863 6570 7469 6f6e 732e 0a64 6566 206d xceptions..def m\n-0005d860: 616b 655f 6761 6965 7272 6f72 5f6d 6170 ake_gaierror_map\n-0005d870: 2829 202d 3e20 2749 7465 7261 626c 655b () -> 'Iterable[\n-0005d880: 7475 706c 655b 7374 722c 2069 6e74 5d5d tuple[str, int]]\n-0005d890: 273a 0a20 2020 206c 6962 6320 3d20 6374 ':. libc = ct\n-0005d8a0: 7970 6573 2e43 444c 4c28 4e6f 6e65 290a ypes.CDLL(None).\n-0005d8b0: 2020 2020 6c69 6263 2e67 6169 5f73 7472 libc.gai_str\n-0005d8c0: 6572 726f 722e 7265 7374 7970 6520 3d20 error.restype = \n-0005d8d0: 6374 7970 6573 2e63 5f63 6861 725f 700a ctypes.c_char_p.\n-0005d8e0: 0a20 2020 2066 6f72 206b 6579 2069 6e20 . for key in \n-0005d8f0: 6469 7228 736f 636b 6574 293a 0a20 2020 dir(socket):. \n-0005d900: 2020 2020 2069 6620 6b65 792e 7374 6172 if key.star\n-0005d910: 7473 7769 7468 2827 4541 495f 2729 3a0a tswith('EAI_'):.\n-0005d920: 2020 2020 2020 2020 2020 2020 6572 726e errn\n-0005d930: 756d 203d 2067 6574 6174 7472 2873 6f63 um = getattr(soc\n-0005d940: 6b65 742c 206b 6579 290a 2020 2020 2020 ket, key). \n-0005d950: 2020 2020 2020 7969 656c 6420 6c69 6263 yield libc\n-0005d960: 2e67 6169 5f73 7472 6572 726f 7228 6572 .gai_strerror(er\n-0005d970: 726e 756d 292e 6465 636f 6465 2827 7574 rnum).decode('ut\n-0005d980: 662d 3827 292c 2065 7272 6e75 6d0a 0a0a f-8'), errnum...\n-0005d990: 6761 6965 7272 6f72 5f6d 6170 203d 2064 gaierror_map = d\n-0005d9a0: 6963 7428 6d61 6b65 5f67 6169 6572 726f ict(make_gaierro\n-0005d9b0: 725f 6d61 7028 2929 0a0a 0a23 2046 756e r_map())...# Fun\n-0005d9c0: 6374 696f 6e61 6c69 7479 2066 6f72 2070 ctionality for p\n-0005d9d0: 6173 7369 6e67 2073 7472 6572 726f 7228 assing strerror(\n-0005d9e0: 2920 6572 726f 7220 6d65 7373 6167 6573 ) error messages\n-0005d9f0: 2074 6f20 7468 6569 7220 6571 7569 7661 to their equiva\n-0005da00: 6c65 6e74 0a23 2050 7974 686f 6e20 6578 lent.# Python ex\n-0005da10: 6365 7074 696f 6e73 2e0a 2320 5468 6572 ceptions..# Ther\n-0005da20: 6520 646f 6573 6e27 7420 7365 656d 2074 e doesn't seem t\n-0005da30: 6f20 6265 2061 6e20 6f66 6669 6369 616c o be an official\n-0005da40: 2041 5049 2066 6f72 2074 7572 6e69 6e67 API for turning\n-0005da50: 2061 6e20 6572 726e 6f20 696e 746f 2074 an errno into t\n-0005da60: 6865 0a23 2063 6f72 7265 6374 2073 7562 he.# correct sub\n-0005da70: 7479 7065 206f 6620 4f53 4572 726f 722c type of OSError,\n-0005da80: 2061 6e64 2074 6865 206c 6973 7420 7468 and the list th\n-0005da90: 6174 2063 7079 7468 6f6e 2075 7365 7320 at cpython uses \n-0005daa0: 6973 2068 6964 6465 6e20 6661 6972 6c79 is hidden fairly\n-0005dab0: 0a23 2064 6565 706c 7920 696e 7369 6465 .# deeply inside\n-0005dac0: 206f 6620 7468 6520 696d 706c 656d 656e of the implemen\n-0005dad0: 7461 7469 6f6e 2e20 2054 6869 7320 6973 tation. This is\n-0005dae0: 2062 6173 6963 616c 6c79 2063 6f70 6965 basically copie\n-0005daf0: 6420 6672 6f6d 2074 6865 0a23 2041 4444 d from the.# ADD\n-0005db00: 5f45 5252 4e4f 2829 206c 696e 6573 2069 _ERRNO() lines i\n-0005db10: 6e20 5f50 7945 7863 5f49 6e69 7453 7461 n _PyExc_InitSta\n-0005db20: 7465 2069 6e20 6370 7974 686f 6e2f 4f62 te in cpython/Ob\n-0005db30: 6a65 6374 732f 6578 6365 7074 696f 6e73 jects/exceptions\n-0005db40: 2e63 0a6f 7365 7272 6f72 5f73 7562 636c .c.oserror_subcl\n-0005db50: 6173 735f 6d61 7020 3d20 6469 6374 2828 ass_map = dict((\n-0005db60: 6572 726e 756d 2c20 636c 7329 2066 6f72 errnum, cls) for\n-0005db70: 2063 6c73 2c20 6572 726e 756d 2069 6e20 cls, errnum in \n-0005db80: 5b0a 2020 2020 2842 6c6f 636b 696e 6749 [. (BlockingI\n-0005db90: 4f45 7272 6f72 2c20 6572 726e 6f2e 4541 OError, errno.EA\n-0005dba0: 4741 494e 292c 0a20 2020 2028 426c 6f63 GAIN),. (Bloc\n-0005dbb0: 6b69 6e67 494f 4572 726f 722c 2065 7272 kingIOError, err\n-0005dbc0: 6e6f 2e45 414c 5245 4144 5929 2c0a 2020 no.EALREADY),. \n-0005dbd0: 2020 2842 6c6f 636b 696e 6749 4f45 7272 (BlockingIOErr\n-0005dbe0: 6f72 2c20 6572 726e 6f2e 4549 4e50 524f or, errno.EINPRO\n-0005dbf0: 4752 4553 5329 2c0a 2020 2020 2842 6c6f GRESS),. (Blo\n-0005dc00: 636b 696e 6749 4f45 7272 6f72 2c20 6572 ckingIOError, er\n-0005dc10: 726e 6f2e 4557 4f55 4c44 424c 4f43 4b29 rno.EWOULDBLOCK)\n-0005dc20: 2c0a 2020 2020 2842 726f 6b65 6e50 6970 ,. (BrokenPip\n-0005dc30: 6545 7272 6f72 2c20 6572 726e 6f2e 4550 eError, errno.EP\n-0005dc40: 4950 4529 2c0a 2020 2020 2842 726f 6b65 IPE),. (Broke\n-0005dc50: 6e50 6970 6545 7272 6f72 2c20 6572 726e nPipeError, errn\n-0005dc60: 6f2e 4553 4855 5444 4f57 4e29 2c0a 2020 o.ESHUTDOWN),. \n-0005dc70: 2020 2843 6869 6c64 5072 6f63 6573 7345 (ChildProcessE\n-0005dc80: 7272 6f72 2c20 6572 726e 6f2e 4543 4849 rror, errno.ECHI\n-0005dc90: 4c44 292c 0a20 2020 2028 436f 6e6e 6563 LD),. (Connec\n-0005dca0: 7469 6f6e 4162 6f72 7465 6445 7272 6f72 tionAbortedError\n-0005dcb0: 2c20 6572 726e 6f2e 4543 4f4e 4e41 424f , errno.ECONNABO\n-0005dcc0: 5254 4544 292c 0a20 2020 2028 436f 6e6e RTED),. (Conn\n-0005dcd0: 6563 7469 6f6e 5265 6675 7365 6445 7272 ectionRefusedErr\n-0005dce0: 6f72 2c20 6572 726e 6f2e 4543 4f4e 4e52 or, errno.ECONNR\n-0005dcf0: 4546 5553 4544 292c 0a20 2020 2028 436f EFUSED),. (Co\n-0005dd00: 6e6e 6563 7469 6f6e 5265 7365 7445 7272 nnectionResetErr\n-0005dd10: 6f72 2c20 6572 726e 6f2e 4543 4f4e 4e52 or, errno.ECONNR\n-0005dd20: 4553 4554 292c 0a20 2020 2028 4669 6c65 ESET),. (File\n-0005dd30: 4578 6973 7473 4572 726f 722c 2065 7272 ExistsError, err\n-0005dd40: 6e6f 2e45 4558 4953 5429 2c0a 2020 2020 no.EEXIST),. \n-0005dd50: 2846 696c 654e 6f74 466f 756e 6445 7272 (FileNotFoundErr\n-0005dd60: 6f72 2c20 6572 726e 6f2e 454e 4f45 4e54 or, errno.ENOENT\n-0005dd70: 292c 0a20 2020 2028 4973 4144 6972 6563 ),. (IsADirec\n-0005dd80: 746f 7279 4572 726f 722c 2065 7272 6e6f toryError, errno\n-0005dd90: 2e45 4953 4449 5229 2c0a 2020 2020 284e .EISDIR),. (N\n-0005dda0: 6f74 4144 6972 6563 746f 7279 4572 726f otADirectoryErro\n-0005ddb0: 722c 2065 7272 6e6f 2e45 4e4f 5444 4952 r, errno.ENOTDIR\n-0005ddc0: 292c 0a20 2020 2028 496e 7465 7272 7570 ),. (Interrup\n-0005ddd0: 7465 6445 7272 6f72 2c20 6572 726e 6f2e tedError, errno.\n-0005dde0: 4549 4e54 5229 2c0a 2020 2020 2850 6572 EINTR),. (Per\n-0005ddf0: 6d69 7373 696f 6e45 7272 6f72 2c20 6572 missionError, er\n-0005de00: 726e 6f2e 4541 4343 4553 292c 0a20 2020 rno.EACCES),. \n-0005de10: 2028 5065 726d 6973 7369 6f6e 4572 726f (PermissionErro\n-0005de20: 722c 2065 7272 6e6f 2e45 5045 524d 292c r, errno.EPERM),\n-0005de30: 0a20 2020 2028 5072 6f63 6573 734c 6f6f . (ProcessLoo\n-0005de40: 6b75 7045 7272 6f72 2c20 6572 726e 6f2e kupError, errno.\n-0005de50: 4553 5243 4829 2c0a 2020 2020 2854 696d ESRCH),. (Tim\n-0005de60: 656f 7574 4572 726f 722c 2065 7272 6e6f eoutError, errno\n-0005de70: 2e45 5449 4d45 444f 5554 292c 0a5d 290a .ETIMEDOUT),.]).\n-0005de80: 0a0a 6465 6620 6765 745f 6578 6365 7074 ..def get_except\n-0005de90: 696f 6e5f 666f 725f 7373 685f 7374 6465 ion_for_ssh_stde\n-0005dea0: 7272 2873 7464 6572 723a 2073 7472 2920 rr(stderr: str) \n-0005deb0: 2d3e 2045 7863 6570 7469 6f6e 3a0a 2020 -> Exception:. \n-0005dec0: 2020 7374 6465 7272 203d 2073 7464 6572 stderr = stder\n-0005ded0: 722e 7265 706c 6163 6528 275c 725c 6e27 r.replace('\\r\\n'\n-0005dee0: 2c20 275c 6e27 2920 2023 2066 6978 206c , '\\n') # fix l\n-0005def0: 696e 6520 7365 7061 7261 746f 7273 0a0a ine separators..\n-0005df00: 2020 2020 2320 6368 6563 6b20 666f 7220 # check for \n-0005df10: 7468 6520 7370 6563 6966 6963 2065 7272 the specific err\n-0005df20: 6f72 206d 6573 7361 6765 7320 6669 7273 or messages firs\n-0005df30: 742c 2074 6865 6e20 666f 7220 6765 6e65 t, then for gene\n-0005df40: 7269 6320 5373 6848 6f73 744b 6579 4572 ric SshHostKeyEr\n-0005df50: 726f 720a 2020 2020 666f 7220 7373 685f ror. for ssh_\n-0005df60: 636c 7320 696e 205b 5373 6841 7574 6865 cls in [SshAuthe\n-0005df70: 6e74 6963 6174 696f 6e45 7272 6f72 2c20 nticationError, \n-0005df80: 5373 6843 6861 6e67 6564 486f 7374 4b65 SshChangedHostKe\n-0005df90: 7945 7272 6f72 2c20 5373 6855 6e6b 6e6f yError, SshUnkno\n-0005dfa0: 776e 486f 7374 4b65 7945 7272 6f72 2c20 wnHostKeyError, \n-0005dfb0: 5373 6848 6f73 744b 6579 4572 726f 725d SshHostKeyError]\n-0005dfc0: 3a0a 2020 2020 2020 2020 6d61 7463 6820 :. match \n-0005dfd0: 3d20 7373 685f 636c 732e 5041 5454 4552 = ssh_cls.PATTER\n-0005dfe0: 4e2e 7365 6172 6368 2873 7464 6572 7229 N.search(stderr)\n-0005dff0: 0a20 2020 2020 2020 2069 6620 6d61 7463 . if matc\n-0005e000: 6820 6973 206e 6f74 204e 6f6e 653a 0a20 h is not None:. \n-0005e010: 2020 2020 2020 2020 2020 2072 6574 7572 retur\n-0005e020: 6e20 7373 685f 636c 7328 6d61 7463 682c n ssh_cls(match,\n-0005e030: 2073 7464 6572 7229 0a0a 2020 2020 6265 stderr).. be\n-0005e040: 666f 7265 2c20 636f 6c6f 6e2c 2061 6674 fore, colon, aft\n-0005e050: 6572 203d 2073 7464 6572 722e 7270 6172 er = stderr.rpar\n-0005e060: 7469 7469 6f6e 2827 3a27 290a 2020 2020 tition(':'). \n-0005e070: 6966 2063 6f6c 6f6e 2061 6e64 2061 6674 if colon and aft\n-0005e080: 6572 3a0a 2020 2020 2020 2020 706f 7465 er:. pote\n-0005e090: 6e74 6961 6c5f 7374 7265 7272 6f72 203d ntial_strerror =\n-0005e0a0: 2061 6674 6572 2e73 7472 6970 2829 0a0a after.strip()..\n-0005e0b0: 2020 2020 2020 2020 2320 444e 5320 6c6f # DNS lo\n-0005e0c0: 6f6b 7570 2065 7272 6f72 730a 2020 2020 okup errors. \n-0005e0d0: 2020 2020 6966 2070 6f74 656e 7469 616c if potential\n-0005e0e0: 5f73 7472 6572 726f 7220 696e 2067 6169 _strerror in gai\n-0005e0f0: 6572 726f 725f 6d61 703a 0a20 2020 2020 error_map:. \n-0005e100: 2020 2020 2020 2065 7272 6e75 6d20 3d20 errnum = \n-0005e110: 6761 6965 7272 6f72 5f6d 6170 5b70 6f74 gaierror_map[pot\n-0005e120: 656e 7469 616c 5f73 7472 6572 726f 725d ential_strerror]\n-0005e130: 0a20 2020 2020 2020 2020 2020 2072 6574 . ret\n-0005e140: 7572 6e20 736f 636b 6574 2e67 6169 6572 urn socket.gaier\n-0005e150: 726f 7228 6572 726e 756d 2c20 7374 6465 ror(errnum, stde\n-0005e160: 7272 290a 0a20 2020 2020 2020 2023 204e rr).. # N\n-0005e170: 6574 776f 726b 2063 6f6e 6e65 6374 2065 etwork connect e\n-0005e180: 7272 6f72 730a 2020 2020 2020 2020 666f rrors. fo\n-0005e190: 7220 6572 726e 756d 2069 6e20 6572 726e r errnum in errn\n-0005e1a0: 6f2e 6572 726f 7263 6f64 653a 0a20 2020 o.errorcode:. \n-0005e1b0: 2020 2020 2020 2020 2069 6620 6f73 2e73 if os.s\n-0005e1c0: 7472 6572 726f 7228 6572 726e 756d 2920 trerror(errnum) \n-0005e1d0: 3d3d 2070 6f74 656e 7469 616c 5f73 7472 == potential_str\n-0005e1e0: 6572 726f 723a 0a20 2020 2020 2020 2020 error:. \n-0005e1f0: 2020 2020 2020 206f 735f 636c 7320 3d20 os_cls = \n-0005e200: 6f73 6572 726f 725f 7375 6263 6c61 7373 oserror_subclass\n-0005e210: 5f6d 6170 2e67 6574 2865 7272 6e75 6d2c _map.get(errnum,\n-0005e220: 204f 5345 7272 6f72 290a 2020 2020 2020 OSError). \n-0005e230: 2020 2020 2020 2020 2020 7265 7475 726e return\n-0005e240: 206f 735f 636c 7328 6572 726e 756d 2c20 os_cls(errnum, \n-0005e250: 7374 6465 7272 290a 0a20 2020 2023 204e stderr).. # N\n-0005e260: 6f20 6d61 7463 683f 2020 4765 6e65 7269 o match? Generi\n-0005e270: 632e 0a20 2020 2072 6574 7572 6e20 5373 c.. return Ss\n-0005e280: 6845 7272 6f72 284e 6f6e 652c 2073 7464 hError(None, std\n-0005e290: 6572 7229 0a27 2727 2c0a 2020 2763 6f63 err).''',. 'coc\n-0005e2a0: 6b70 6974 2f5f 7665 6e64 6f72 2f66 6572 kpit/_vendor/fer\n-0005e2b0: 6e79 2f69 6e74 6572 6163 7469 6f6e 5f61 ny/interaction_a\n-0005e2c0: 6765 6e74 2e70 7927 3a20 7227 2727 2320 gent.py': r'''# \n-0005e2d0: 6665 726e 7920 2d20 6173 796e 6369 6f20 ferny - asyncio \n-0005e2e0: 5353 4820 636c 6965 6e74 206c 6962 7261 SSH client libra\n-0005e2f0: 7279 2c20 7573 696e 6720 7373 6828 3129 ry, using ssh(1)\n-0005e300: 0a23 0a23 2043 6f70 7972 6967 6874 2028 .#.# Copyright (\n-0005e310: 4329 2032 3032 3320 416c 6c69 736f 6e20 C) 2023 Allison \n-0005e320: 4b61 726c 6974 736b 6179 6120 3c61 6c6c Karlitskaya <all\n-0005e330: 6973 6f6e 2e6b 6172 6c69 7473 6b61 7961 ison.karlitskaya\n-0005e340: 4072 6564 6861 742e 636f 6d3e 0a23 0a23 @redhat.com>.#.#\n-0005e350: 2054 6869 7320 7072 6f67 7261 6d20 6973 This program is\n-0005e360: 2066 7265 6520 736f 6674 7761 7265 3a20 free software: \n-0005e370: 796f 7520 6361 6e20 7265 6469 7374 7269 you can redistri\n-0005e380: 6275 7465 2069 7420 616e 642f 6f72 206d bute it and/or m\n-0005e390: 6f64 6966 790a 2320 6974 2075 6e64 6572 odify.# it under\n-0005e3a0: 2074 6865 2074 6572 6d73 206f 6620 7468 the terms of th\n-0005e3b0: 6520 474e 5520 4765 6e65 7261 6c20 5075 e GNU General Pu\n-0005e3c0: 626c 6963 204c 6963 656e 7365 2061 7320 blic License as \n-0005e3d0: 7075 626c 6973 6865 6420 6279 0a23 2074 published by.# t\n-0005e3e0: 6865 2046 7265 6520 536f 6674 7761 7265 he Free Software\n-0005e3f0: 2046 6f75 6e64 6174 696f 6e2c 2065 6974 Foundation, eit\n-0005e400: 6865 7220 7665 7273 696f 6e20 3320 6f66 her version 3 of\n-0005e410: 2074 6865 204c 6963 656e 7365 2c20 6f72 the License, or\n-0005e420: 0a23 2028 6174 2079 6f75 7220 6f70 7469 .# (at your opti\n-0005e430: 6f6e 2920 616e 7920 6c61 7465 7220 7665 on) any later ve\n-0005e440: 7273 696f 6e2e 0a23 0a23 2054 6869 7320 rsion..#.# This \n-0005e450: 7072 6f67 7261 6d20 6973 2064 6973 7472 program is distr\n-0005e460: 6962 7574 6564 2069 6e20 7468 6520 686f ibuted in the ho\n-0005e470: 7065 2074 6861 7420 6974 2077 696c 6c20 pe that it will \n-0005e480: 6265 2075 7365 6675 6c2c 0a23 2062 7574 be useful,.# but\n-0005e490: 2057 4954 484f 5554 2041 4e59 2057 4152 WITHOUT ANY WAR\n-0005e4a0: 5241 4e54 593b 2077 6974 686f 7574 2065 RANTY; without e\n-0005e4b0: 7665 6e20 7468 6520 696d 706c 6965 6420 ven the implied \n-0005e4c0: 7761 7272 616e 7479 206f 660a 2320 4d45 warranty of.# ME\n-0005e4d0: 5243 4841 4e54 4142 494c 4954 5920 6f72 RCHANTABILITY or\n-0005e4e0: 2046 4954 4e45 5353 2046 4f52 2041 2050 FITNESS FOR A P\n-0005e4f0: 4152 5449 4355 4c41 5220 5055 5250 4f53 ARTICULAR PURPOS\n-0005e500: 452e 2020 5365 6520 7468 650a 2320 474e E. See the.# GN\n-0005e510: 5520 4765 6e65 7261 6c20 5075 626c 6963 U General Public\n-0005e520: 204c 6963 656e 7365 2066 6f72 206d 6f72 License for mor\n-0005e530: 6520 6465 7461 696c 732e 0a23 0a23 2059 e details..#.# Y\n-0005e540: 6f75 2073 686f 756c 6420 6861 7665 2072 ou should have r\n-0005e550: 6563 6569 7665 6420 6120 636f 7079 206f eceived a copy o\n-0005e560: 6620 7468 6520 474e 5520 4765 6e65 7261 f the GNU Genera\n-0005e570: 6c20 5075 626c 6963 204c 6963 656e 7365 l Public License\n-0005e580: 0a23 2061 6c6f 6e67 2077 6974 6820 7468 .# along with th\n-0005e590: 6973 2070 726f 6772 616d 2e20 2049 6620 is program. If \n-0005e5a0: 6e6f 742c 2073 6565 203c 6874 7470 3a2f not, see <http:/\n-0005e5b0: 2f77 7777 2e67 6e75 2e6f 7267 2f6c 6963 /www.gnu.org/lic\n-0005e5c0: 656e 7365 732f 3e2e 0a0a 696d 706f 7274 enses/>...import\n-0005e5d0: 2061 7272 6179 0a69 6d70 6f72 7420 6173 array.import as\n-0005e5e0: 740a 696d 706f 7274 2061 7379 6e63 696f t.import asyncio\n-0005e5f0: 0a69 6d70 6f72 7420 636f 6e74 6578 746c .import contextl\n-0005e600: 6962 0a69 6d70 6f72 7420 6c6f 6767 696e ib.import loggin\n-0005e610: 670a 696d 706f 7274 206f 730a 696d 706f g.import os.impo\n-0005e620: 7274 2072 650a 696d 706f 7274 2073 6f63 rt re.import soc\n-0005e630: 6b65 740a 696d 706f 7274 2074 656d 7066 ket.import tempf\n-0005e640: 696c 650a 6672 6f6d 2074 7970 696e 6720 ile.from typing \n-0005e650: 696d 706f 7274 2041 6e79 2c20 4361 6c6c import Any, Call\n-0005e660: 6162 6c65 2c20 436c 6173 7356 6172 2c20 able, ClassVar, \n-0005e670: 4765 6e65 7261 746f 722c 2053 6571 7565 Generator, Seque\n-0005e680: 6e63 650a 0a66 726f 6d20 2e20 696d 706f nce..from . impo\n-0005e690: 7274 2069 6e74 6572 6163 7469 6f6e 5f63 rt interaction_c\n-0005e6a0: 6c69 656e 740a 0a6c 6f67 6765 7220 3d20 lient..logger = \n-0005e6b0: 6c6f 6767 696e 672e 6765 744c 6f67 6765 logging.getLogge\n-0005e6c0: 7228 5f5f 6e61 6d65 5f5f 290a 0a0a 434f r(__name__)...CO\n-0005e6d0: 4d4d 414e 445f 5245 203d 2072 652e 636f MMAND_RE = re.co\n-0005e6e0: 6d70 696c 6528 6227 5c30 6665 726e 795c mpile(b'\\0ferny\\\n-0005e6f0: 3028 5b5e 5c6e 5d2a 295c 305c 305c 6e27 0([^\\n]*)\\0\\0\\n'\n-0005e700: 290a 434f 4d4d 414e 445f 5445 4d50 4c41 ).COMMAND_TEMPLA\n-0005e710: 5445 203d 2027 5c30 6665 726e 795c 307b TE = '\\0ferny\\0{\n-0005e720: 2863 6f6d 6d61 6e64 2c20 6172 6773 2921 (command, args)!\n-0005e730: 727d 5c30 5c30 5c6e 270a 0a42 4549 424f r}\\0\\0\\n'..BEIBO\n-0005e740: 4f54 5f47 4144 4745 5453 203d 207b 0a20 OT_GADGETS = {. \n-0005e750: 2020 2022 636f 6d6d 616e 6422 3a20 6672 \"command\": fr\n-0005e760: 2222 220a 2020 2020 2020 2020 696d 706f \"\"\". impo\n-0005e770: 7274 2073 7973 0a20 2020 2020 2020 2064 rt sys. d\n-0005e780: 6566 2063 6f6d 6d61 6e64 2863 6f6d 6d61 ef command(comma\n-0005e790: 6e64 2c20 2a61 7267 7329 3a0a 2020 2020 nd, *args):. \n-0005e7a0: 2020 2020 2020 2020 7379 732e 7374 6465 sys.stde\n-0005e7b0: 7272 2e77 7269 7465 2866 7b43 4f4d 4d41 rr.write(f{COMMA\n-0005e7c0: 4e44 5f54 454d 504c 4154 4521 727d 290a ND_TEMPLATE!r}).\n-0005e7d0: 2020 2020 2020 2020 2020 2020 7379 732e sys.\n-0005e7e0: 7374 6465 7272 2e66 6c75 7368 2829 0a20 stderr.flush(). \n-0005e7f0: 2020 2022 2222 2c0a 2020 2020 2265 6e64 \"\"\",. \"end\n-0005e800: 223a 2072 2222 220a 2020 2020 2020 2020 \": r\"\"\". \n-0005e810: 6465 6620 656e 6428 293a 0a20 2020 2020 def end():. \n-0005e820: 2020 2020 2020 2063 6f6d 6d61 6e64 2827 command('\n-0005e830: 6665 726e 792e 656e 6427 290a 2020 2020 ferny.end'). \n-0005e840: 2222 222c 0a7d 0a0a 0a63 6c61 7373 2049 \"\"\",.}...class I\n-0005e850: 6e74 6572 6163 7469 6f6e 4572 726f 7228 nteractionError(\n-0005e860: 4578 6365 7074 696f 6e29 3a0a 2020 2020 Exception):. \n-0005e870: 7061 7373 0a0a 0a74 7279 3a0a 2020 2020 pass...try:. \n-0005e880: 7265 6376 5f66 6473 203d 2073 6f63 6b65 recv_fds = socke\n-0005e890: 742e 7265 6376 5f66 6473 0a65 7863 6570 t.recv_fds.excep\n-0005e8a0: 7420 4174 7472 6962 7574 6545 7272 6f72 t AttributeError\n-0005e8b0: 3a0a 2020 2020 2320 5079 7468 6f6e 203c :. # Python <\n-0005e8c0: 2033 2e39 0a0a 2020 2020 6465 6620 7265 3.9.. def re\n-0005e8d0: 6376 5f66 6473 280a 2020 2020 2020 2020 cv_fds(. \n-0005e8e0: 736f 636b 3a20 736f 636b 6574 2e73 6f63 sock: socket.soc\n-0005e8f0: 6b65 742c 2062 7566 7369 7a65 3a20 696e ket, bufsize: in\n-0005e900: 742c 206d 6178 6664 733a 2069 6e74 2c20 t, maxfds: int, \n-0005e910: 666c 6167 733a 2069 6e74 203d 2030 0a20 flags: int = 0. \n-0005e920: 2020 2029 202d 3e20 2774 7570 6c65 5b62 ) -> 'tuple[b\n-0005e930: 7974 6573 2c20 6c69 7374 5b69 6e74 5d2c ytes, list[int],\n-0005e940: 2069 6e74 2c20 4e6f 6e65 5d27 3a0a 2020 int, None]':. \n-0005e950: 2020 2020 2020 6664 7320 3d20 6172 7261 fds = arra\n-0005e960: 792e 6172 7261 7928 2269 2229 0a20 2020 y.array(\"i\"). \n-0005e970: 2020 2020 206d 7367 2c20 616e 6364 6174 msg, ancdat\n-0005e980: 612c 2066 6c61 6773 2c20 6164 6472 203d a, flags, addr =\n-0005e990: 2073 6f63 6b2e 7265 6376 6d73 6728 6275 sock.recvmsg(bu\n-0005e9a0: 6673 697a 652c 2073 6f63 6b65 742e 434d fsize, socket.CM\n-0005e9b0: 5347 5f4c 454e 286d 6178 6664 7320 2a20 SG_LEN(maxfds * \n-0005e9c0: 6664 732e 6974 656d 7369 7a65 2929 0a20 fds.itemsize)). \n-0005e9d0: 2020 2020 2020 2066 6f72 2063 6d73 675f for cmsg_\n-0005e9e0: 6c65 7665 6c2c 2063 6d73 675f 7479 7065 level, cmsg_type\n-0005e9f0: 2c20 636d 7367 5f64 6174 6120 696e 2061 , cmsg_data in a\n-0005ea00: 6e63 6461 7461 3a0a 2020 2020 2020 2020 ncdata:. \n-0005ea10: 2020 2020 6966 2028 636d 7367 5f6c 6576 if (cmsg_lev\n-0005ea20: 656c 203d 3d20 736f 636b 6574 2e53 4f4c el == socket.SOL\n-0005ea30: 5f53 4f43 4b45 5420 616e 6420 636d 7367 _SOCKET and cmsg\n-0005ea40: 5f74 7970 6520 3d3d 2073 6f63 6b65 742e _type == socket.\n-0005ea50: 5343 4d5f 5249 4748 5453 293a 0a20 2020 SCM_RIGHTS):. \n-0005ea60: 2020 2020 2020 2020 2020 2020 2066 6473 fds\n-0005ea70: 2e66 726f 6d62 7974 6573 2863 6d73 675f .frombytes(cmsg_\n-0005ea80: 6461 7461 5b3a 6c65 6e28 636d 7367 5f64 data[:len(cmsg_d\n-0005ea90: 6174 6129 202d 2028 6c65 6e28 636d 7367 ata) - (len(cmsg\n-0005eaa0: 5f64 6174 6129 2025 2066 6473 2e69 7465 _data) % fds.ite\n-0005eab0: 6d73 697a 6529 5d29 0a20 2020 2020 2020 msize)]). \n-0005eac0: 2072 6574 7572 6e20 6d73 672c 206c 6973 return msg, lis\n-0005ead0: 7428 6664 7329 2c20 666c 6167 732c 2061 t(fds), flags, a\n-0005eae0: 6464 720a 0a0a 6465 6620 6765 745f 7275 ddr...def get_ru\n-0005eaf0: 6e6e 696e 675f 6c6f 6f70 2829 202d 3e20 nning_loop() -> \n-0005eb00: 6173 796e 6369 6f2e 4162 7374 7261 6374 asyncio.Abstract\n-0005eb10: 4576 656e 744c 6f6f 703a 0a20 2020 2074 EventLoop:. t\n-0005eb20: 7279 3a0a 2020 2020 2020 2020 7265 7475 ry:. retu\n-0005eb30: 726e 2061 7379 6e63 696f 2e67 6574 5f72 rn asyncio.get_r\n-0005eb40: 756e 6e69 6e67 5f6c 6f6f 7028 290a 2020 unning_loop(). \n-0005eb50: 2020 6578 6365 7074 2041 7474 7269 6275 except Attribu\n-0005eb60: 7465 4572 726f 723a 0a20 2020 2020 2020 teError:. \n-0005eb70: 2023 2050 7974 686f 6e20 332e 360a 2020 # Python 3.6. \n-0005eb80: 2020 2020 2020 7265 7475 726e 2061 7379 return asy\n-0005eb90: 6e63 696f 2e67 6574 5f65 7665 6e74 5f6c ncio.get_event_l\n-0005eba0: 6f6f 7028 290a 0a0a 636c 6173 7320 496e oop()...class In\n-0005ebb0: 7465 7261 6374 696f 6e48 616e 646c 6572 teractionHandler\n-0005ebc0: 3a0a 2020 2020 636f 6d6d 616e 6473 3a20 :. commands: \n-0005ebd0: 436c 6173 7356 6172 5b53 6571 7565 6e63 ClassVar[Sequenc\n-0005ebe0: 655b 7374 725d 5d0a 0a20 2020 2061 7379 e[str]].. asy\n-0005ebf0: 6e63 2064 6566 2072 756e 5f63 6f6d 6d61 nc def run_comma\n-0005ec00: 6e64 2873 656c 662c 2063 6f6d 6d61 6e64 nd(self, command\n-0005ec10: 3a20 7374 722c 2061 7267 733a 2027 7475 : str, args: 'tu\n-0005ec20: 706c 655b 6f62 6a65 6374 2c20 2e2e 2e5d ple[object, ...]\n-0005ec30: 272c 2066 6473 3a20 276c 6973 745b 696e ', fds: 'list[in\n-0005ec40: 745d 272c 2073 7464 6572 723a 2073 7472 t]', stderr: str\n-0005ec50: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n-0005ec60: 2020 2072 6169 7365 204e 6f74 496d 706c raise NotImpl\n-0005ec70: 656d 656e 7465 6445 7272 6f72 0a0a 0a63 ementedError...c\n-0005ec80: 6c61 7373 2041 736b 7061 7373 4861 6e64 lass AskpassHand\n-0005ec90: 6c65 7228 496e 7465 7261 6374 696f 6e48 ler(InteractionH\n-0005eca0: 616e 646c 6572 293a 0a20 2020 2063 6f6d andler):. com\n-0005ecb0: 6d61 6e64 733a 2043 6c61 7373 5661 725b mands: ClassVar[\n-0005ecc0: 5365 7175 656e 6365 5b73 7472 5d5d 203d Sequence[str]] =\n-0005ecd0: 2028 2766 6572 6e79 2e61 736b 7061 7373 ('ferny.askpass\n-0005ece0: 272c 290a 0a20 2020 2061 7379 6e63 2064 ',).. async d\n-0005ecf0: 6566 2064 6f5f 6173 6b70 6173 7328 7365 ef do_askpass(se\n-0005ed00: 6c66 2c20 6d65 7373 6167 6573 3a20 7374 lf, messages: st\n-0005ed10: 722c 2070 726f 6d70 743a 2073 7472 2c20 r, prompt: str, \n-0005ed20: 6869 6e74 3a20 7374 7229 202d 3e20 2773 hint: str) -> 's\n-0005ed30: 7472 207c 204e 6f6e 6527 3a0a 2020 2020 tr | None':. \n-0005ed40: 2020 2020 2222 2250 726f 6d70 7420 7468 \"\"\"Prompt th\n-0005ed50: 6520 7573 6572 2066 6f72 2061 6e20 6175 e user for an au\n-0005ed60: 7468 656e 7469 6361 7469 6f6e 206f 7220 thentication or \n-0005ed70: 636f 6e66 6972 6d61 7469 6f6e 2069 6e74 confirmation int\n-0005ed80: 6572 6163 7469 6f6e 2e0a 0a20 2020 2020 eraction... \n-0005ed90: 2020 2027 6d65 7373 6167 6573 2720 6973 'messages' is\n-0005eda0: 2064 6174 6120 7468 6174 2077 6173 2073 data that was s\n-0005edb0: 656e 7420 746f 2073 7464 6572 7220 6265 ent to stderr be\n-0005edc0: 666f 7265 2074 6865 2069 6e74 6572 6163 fore the interac\n-0005edd0: 7469 6f6e 2077 6173 2072 6571 7565 7374 tion was request\n-0005ede0: 6564 2e0a 2020 2020 2020 2020 2770 726f ed.. 'pro\n-0005edf0: 6d70 7427 2069 7320 7468 6520 696e 7465 mpt' is the inte\n-0005ee00: 7261 6374 696f 6e20 7072 6f6d 7074 2e0a raction prompt..\n-0005ee10: 0a20 2020 2020 2020 2054 6865 2065 7870 . The exp\n-0005ee20: 6563 7465 6420 7265 7370 6f6e 7365 2074 ected response t\n-0005ee30: 7970 6520 6465 7065 6e64 7320 6f6e 2068 ype depends on h\n-0005ee40: 696e 743a 0a0a 2020 2020 2020 2020 2020 int:.. \n-0005ee50: 2020 2d20 2263 6f6e 6669 726d 223a 2061 - \"confirm\": a\n-0005ee60: 736b 2066 6f72 2070 6572 6d69 7373 696f sk for permissio\n-0005ee70: 6e2c 2072 6574 7572 6e69 6e67 2022 7965 n, returning \"ye\n-0005ee80: 7322 2069 6620 6163 6365 7074 6564 0a20 s\" if accepted. \n-0005ee90: 2020 2020 2020 2020 2020 2020 2020 202d -\n-0005eea0: 2065 7861 6d70 6c65 3a20 6175 7468 6f72 example: author\n-0005eeb0: 697a 696e 6720 6167 656e 7420 6f70 6572 izing agent oper\n-0005eec0: 6174 696f 6e0a 0a20 2020 2020 2020 2020 ation.. \n-0005eed0: 2020 202d 2022 6e6f 6e65 223a 2073 686f - \"none\": sho\n-0005eee0: 7720 6120 7265 7175 6573 7420 7769 7468 w a request with\n-0005eef0: 6f75 7420 6e65 6564 2066 6f72 2061 2072 out need for a r\n-0005ef00: 6573 706f 6e73 650a 2020 2020 2020 2020 esponse. \n-0005ef10: 2020 2020 2020 2020 2d20 6578 616d 706c - exampl\n-0005ef20: 653a 2070 6c65 6173 6520 746f 7563 6820 e: please touch \n-0005ef30: 796f 7572 2061 7574 6865 6e74 6963 6174 your authenticat\n-0005ef40: 696f 6e20 746f 6b65 6e0a 0a20 2020 2020 ion token.. \n-0005ef50: 2020 2020 2020 202d 206f 7468 6572 7769 - otherwi\n-0005ef60: 7365 3a20 7265 7475 726e 2061 2070 6173 se: return a pas\n-0005ef70: 7377 6f72 6420 6f72 206f 7468 6572 2066 sword or other f\n-0005ef80: 6f72 6d20 6f66 2074 6578 7420 746f 6b65 orm of text toke\n-0005ef90: 6e0a 2020 2020 2020 2020 2020 2020 2020 n. \n-0005efa0: 2020 2d20 6578 616d 706c 6573 3a20 656e - examples: en\n-0005efb0: 7465 7220 7061 7373 776f 7264 2c20 756e ter password, un\n-0005efc0: 6c6f 636b 2070 7269 7661 7465 206b 6579 lock private key\n-0005efd0: 0a0a 2020 2020 2020 2020 496e 2061 6e79 .. In any\n-0005efe0: 2063 6173 652c 2074 6865 2066 756e 6374 case, the funct\n-0005eff0: 696f 6e20 7368 6f75 6c64 2070 726f 7065 ion should prope\n-0005f000: 726c 7920 6861 6e64 6c65 2063 616e 6365 rly handle cance\n-0005f010: 6c6c 6174 696f 6e2e 2020 466f 7220 7468 llation. For th\n-0005f020: 650a 2020 2020 2020 2020 226e 6f6e 6522 e. \"none\"\n-0005f030: 2063 6173 652c 2074 6869 7320 7769 6c6c case, this will\n-0005f040: 2062 6520 7468 6520 6e6f 726d 616c 2077 be the normal w\n-0005f050: 6179 2074 6f20 6469 736d 6973 7320 7468 ay to dismiss th\n-0005f060: 6520 6469 616c 6f67 2e0a 2020 2020 2020 e dialog.. \n-0005f070: 2020 2222 220a 2020 2020 2020 2020 7265 \"\"\". re\n-0005f080: 7475 726e 204e 6f6e 650a 0a20 2020 2061 turn None.. a\n-0005f090: 7379 6e63 2064 6566 2064 6f5f 686f 7374 sync def do_host\n-0005f0a0: 6b65 7928 7365 6c66 2c20 7265 6173 6f6e key(self, reason\n-0005f0b0: 3a20 7374 722c 2068 6f73 743a 2073 7472 : str, host: str\n-0005f0c0: 2c20 616c 676f 7269 7468 6d3a 2073 7472 , algorithm: str\n-0005f0d0: 2c20 6b65 793a 2073 7472 2c20 6669 6e67 , key: str, fing\n-0005f0e0: 6572 7072 696e 743a 2073 7472 2920 2d3e erprint: str) ->\n-0005f0f0: 2062 6f6f 6c3a 0a20 2020 2020 2020 2022 bool:. \"\n-0005f100: 2222 5072 6f6d 7074 2074 6865 2075 7365 \"\"Prompt the use\n-0005f110: 7220 666f 7220 6120 6465 6369 7369 6f6e r for a decision\n-0005f120: 2072 6567 6172 6469 6e67 2061 6363 6570 regarding accep\n-0005f130: 7461 6e63 6520 6f66 2061 2068 6f73 7420 tance of a host \n-0005f140: 6b65 792e 0a0a 2020 2020 2020 2020 5468 key... Th\n-0005f150: 6520 2272 6561 736f 6e22 2077 696c 6c20 e \"reason\" will \n-0005f160: 6265 2065 6974 6865 7220 2248 4f53 544e be either \"HOSTN\n-0005f170: 414d 4522 206f 7220 2241 4444 5245 5353 AME\" or \"ADDRESS\n-0005f180: 2220 2869 6620 6043 6865 636b 486f 7374 \" (if `CheckHost\n-0005f190: 4950 6020 6973 2065 6e61 626c 6564 292e IP` is enabled).\n-0005f1a0: 0a0a 2020 2020 2020 2020 5468 6520 686f .. The ho\n-0005f1b0: 7374 2c20 616c 676f 7269 7468 6d2c 2061 st, algorithm, a\n-0005f1c0: 6e64 206b 6579 2070 6172 616d 6574 6572 nd key parameter\n-0005f1d0: 7320 6172 6520 7468 6520 7661 6c75 6573 s are the values\n-0005f1e0: 2069 6e20 7468 6520 666f 726d 2074 6861 in the form tha\n-0005f1f0: 740a 2020 2020 2020 2020 7468 6579 2077 t. they w\n-0005f200: 6f75 6c64 2061 7070 6561 7220 6f6e 6520 ould appear one \n-0005f210: 6120 7369 6e67 6c65 206c 696e 6520 696e a single line in\n-0005f220: 2074 6865 206b 6e6f 776e 2068 6f73 7473 the known hosts\n-0005f230: 2066 696c 652e 2020 5468 650a 2020 2020 file. The. \n-0005f240: 2020 2020 6669 6e67 6572 7072 696e 7420 fingerprint \n-0005f250: 6973 2074 6865 206b 6579 2066 696e 6765 is the key finge\n-0005f260: 7270 7269 6e74 2069 6e20 7468 6520 666f rprint in the fo\n-0005f270: 726d 6174 2074 6861 7420 7373 6820 776f rmat that ssh wo\n-0005f280: 756c 640a 2020 2020 2020 2020 6e6f 726d uld. norm\n-0005f290: 616c 6c79 2070 7265 7365 6e74 2069 7420 ally present it \n-0005f2a0: 746f 2074 6865 2075 7365 722e 0a0a 2020 to the user... \n-0005f2b0: 2020 2020 2020 496e 2063 6173 6520 7468 In case th\n-0005f2c0: 6520 686f 7374 206b 6579 2073 686f 756c e host key shoul\n-0005f2d0: 6420 6265 2061 6363 6570 7465 642c 2074 d be accepted, t\n-0005f2e0: 6869 7320 6675 6e63 7469 6f6e 206e 6565 his function nee\n-0005f2f0: 6473 2074 6f20 7265 7475 726e 0a20 2020 ds to return. \n-0005f300: 2020 2020 2054 7275 652e 2020 5265 7475 True. Retu\n-0005f310: 726e 696e 6720 4661 6c73 6520 6d65 616e rning False mean\n-0005f320: 7320 7468 6174 2073 7368 2069 6d70 6c65 s that ssh imple\n-0005f330: 6d65 6e74 7320 6974 7320 6465 6661 756c ments its defaul\n-0005f340: 7420 6c6f 6769 632e 2020 546f 0a20 2020 t logic. To. \n-0005f350: 2020 2020 2069 6e74 6572 7275 7074 2074 interrupt t\n-0005f360: 6865 2063 6f6e 6e65 6374 696f 6e2c 2072 he connection, r\n-0005f370: 6169 7365 2061 6e20 6578 6365 7074 696f aise an exceptio\n-0005f380: 6e2e 0a20 2020 2020 2020 2022 2222 0a20 n.. \"\"\". \n-0005f390: 2020 2020 2020 2072 6574 7572 6e20 4661 return Fa\n-0005f3a0: 6c73 650a 0a20 2020 2061 7379 6e63 2064 lse.. async d\n-0005f3b0: 6566 2064 6f5f 6375 7374 6f6d 5f63 6f6d ef do_custom_com\n-0005f3c0: 6d61 6e64 280a 2020 2020 2020 2020 7365 mand(. se\n-0005f3d0: 6c66 2c20 636f 6d6d 616e 643a 2073 7472 lf, command: str\n-0005f3e0: 2c20 6172 6773 3a20 2774 7570 6c65 5b6f , args: 'tuple[o\n-0005f3f0: 626a 6563 742c 202e 2e2e 5d27 2c20 6664 bject, ...]', fd\n-0005f400: 733a 2027 6c69 7374 5b69 6e74 5d27 2c20 s: 'list[int]', \n-0005f410: 7374 6465 7272 3a20 7374 720a 2020 2020 stderr: str. \n-0005f420: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n-0005f430: 2020 2022 2222 4861 6e64 6c65 2061 2063 \"\"\"Handle a c\n-0005f440: 7573 746f 6d20 636f 6d6d 616e 642e 0a0a ustom command...\n-0005f450: 2020 2020 2020 2020 5468 6520 636f 6d6d The comm\n-0005f460: 616e 6420 6e61 6d65 2c20 6974 7320 6172 and name, its ar\n-0005f470: 6775 6d65 6e74 732c 2074 6865 2070 6173 guments, the pas\n-0005f480: 7365 6420 6664 732c 2061 6e64 2074 6865 sed fds, and the\n-0005f490: 2073 7464 6572 7220 6c65 6164 696e 670a stderr leading.\n-0005f4a0: 2020 2020 2020 2020 7570 2074 6f20 7468 up to th\n-0005f4b0: 6520 636f 6d6d 616e 6420 696e 766f 6361 e command invoca\n-0005f4c0: 7469 6f6e 2061 7265 2061 6c6c 2070 726f tion are all pro\n-0005f4d0: 7669 6465 642e 0a0a 2020 2020 2020 2020 vided... \n-0005f4e0: 5365 6520 646f 632f 696e 7465 7261 6374 See doc/interact\n-0005f4f0: 696f 6e2d 7072 6f74 6f63 6f6c 2e6d 640a ion-protocol.md.\n-0005f500: 2020 2020 2020 2020 2222 220a 0a20 2020 \"\"\".. \n-0005f510: 2061 7379 6e63 2064 6566 205f 6173 6b70 async def _askp\n-0005f520: 6173 735f 636f 6d6d 616e 6428 7365 6c66 ass_command(self\n-0005f530: 2c20 6172 6773 3a20 2774 7570 6c65 5b6f , args: 'tuple[o\n-0005f540: 626a 6563 742c 202e 2e2e 5d27 2c20 6664 bject, ...]', fd\n-0005f550: 733a 2027 6c69 7374 5b69 6e74 5d27 2c20 s: 'list[int]', \n-0005f560: 7374 6465 7272 3a20 7374 7229 202d 3e20 stderr: str) -> \n-0005f570: 4e6f 6e65 3a0a 2020 2020 2020 2020 6c6f None:. lo\n-0005f580: 6767 6572 2e64 6562 7567 2827 5f61 736b gger.debug('_ask\n-0005f590: 7061 7373 5f63 6f6d 6d61 6e64 2825 732c pass_command(%s,\n-0005f5a0: 2025 732c 2025 7329 272c 2061 7267 732c %s, %s)', args,\n-0005f5b0: 2066 6473 2c20 7374 6465 7272 290a 2020 fds, stderr). \n-0005f5c0: 2020 2020 2020 7472 793a 0a20 2020 2020 try:. \n-0005f5d0: 2020 2020 2020 2061 7267 762c 2065 6e76 argv, env\n-0005f5e0: 203d 2061 7267 730a 2020 2020 2020 2020 = args. \n-0005f5f0: 2020 2020 6173 7365 7274 2069 7369 6e73 assert isins\n-0005f600: 7461 6e63 6528 6172 6776 2c20 6c69 7374 tance(argv, list\n-0005f610: 290a 2020 2020 2020 2020 2020 2020 6173 ). as\n-0005f620: 7365 7274 2061 6c6c 2869 7369 6e73 7461 sert all(isinsta\n-0005f630: 6e63 6528 6172 672c 2073 7472 2920 666f nce(arg, str) fo\n-0005f640: 7220 6172 6720 696e 2061 7267 7629 0a20 r arg in argv). \n-0005f650: 2020 2020 2020 2020 2020 2061 7373 6572 asser\n-0005f660: 7420 6973 696e 7374 616e 6365 2865 6e76 t isinstance(env\n-0005f670: 2c20 6469 6374 290a 2020 2020 2020 2020 , dict). \n-0005f680: 2020 2020 6173 7365 7274 2061 6c6c 2869 assert all(i\n-0005f690: 7369 6e73 7461 6e63 6528 6b65 792c 2073 sinstance(key, s\n-0005f6a0: 7472 2920 616e 6420 6973 696e 7374 616e tr) and isinstan\n-0005f6b0: 6365 2876 616c 2c20 7374 7229 2066 6f72 ce(val, str) for\n-0005f6c0: 206b 6579 2c20 7661 6c20 696e 2065 6e76 key, val in env\n-0005f6d0: 2e69 7465 6d73 2829 290a 2020 2020 2020 .items()). \n-0005f6e0: 2020 2020 2020 6173 7365 7274 206c 656e assert len\n-0005f6f0: 2866 6473 2920 3d3d 2032 0a20 2020 2020 (fds) == 2. \n-0005f700: 2020 2065 7863 6570 7420 2856 616c 7565 except (Value\n-0005f710: 4572 726f 722c 2054 7970 6545 7272 6f72 Error, TypeError\n-0005f720: 2c20 4173 7365 7274 696f 6e45 7272 6f72 , AssertionError\n-0005f730: 2920 6173 2065 7863 3a0a 2020 2020 2020 ) as exc:. \n-0005f740: 2020 2020 2020 6c6f 6767 6572 2e65 7272 logger.err\n-0005f750: 6f72 2827 496e 7661 6c69 6420 6172 6775 or('Invalid argu\n-0005f760: 6d65 6e74 7320 746f 2061 736b 7061 7373 ments to askpass\n-0005f770: 2069 6e74 6572 6163 7469 6f6e 3a20 2573 interaction: %s\n-0005f780: 2c20 2573 3a20 2573 272c 2061 7267 732c , %s: %s', args,\n-0005f790: 2066 6473 2c20 6578 6329 0a20 2020 2020 fds, exc). \n-0005f7a0: 2020 2020 2020 2072 6574 7572 6e0a 0a20 return.. \n-0005f7b0: 2020 2020 2020 2077 6974 6820 6f70 656e with open\n-0005f7c0: 2866 6473 2e70 6f70 2830 292c 2027 7727 (fds.pop(0), 'w'\n-0005f7d0: 2920 6173 2073 7461 7475 732c 206f 7065 ) as status, ope\n-0005f7e0: 6e28 6664 732e 706f 7028 3029 2c20 2777 n(fds.pop(0), 'w\n-0005f7f0: 2729 2061 7320 7374 646f 7574 3a0a 2020 ') as stdout:. \n-0005f800: 2020 2020 2020 2020 2020 7472 793a 0a20 try:. \n-0005f810: 2020 2020 2020 2020 2020 2020 2020 206c l\n-0005f820: 6f6f 7020 3d20 6765 745f 7275 6e6e 696e oop = get_runnin\n-0005f830: 675f 6c6f 6f70 2829 0a20 2020 2020 2020 g_loop(). \n-0005f840: 2020 2020 2020 2020 2074 7279 3a0a 2020 try:. \n-0005f850: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0005f860: 2020 7461 736b 203d 2061 7379 6e63 696f task = asyncio\n-0005f870: 2e63 7572 7265 6e74 5f74 6173 6b28 290a .current_task().\n-0005f880: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0005f890: 6578 6365 7074 2041 7474 7269 6275 7465 except Attribute\n-0005f8a0: 4572 726f 723a 0a20 2020 2020 2020 2020 Error:. \n-0005f8b0: 2020 2020 2020 2020 2020 2074 6173 6b20 task \n-0005f8c0: 3d20 6173 796e 6369 6f2e 5461 736b 2e63 = asyncio.Task.c\n-0005f8d0: 7572 7265 6e74 5f74 6173 6b28 2920 2023 urrent_task() #\n-0005f8e0: 2074 7970 653a 6967 6e6f 7265 5b61 7474 type:ignore[att\n-0005f8f0: 722d 6465 6669 6e65 645d 2023 2028 5079 r-defined] # (Py\n-0005f900: 7468 6f6e 2033 2e36 290a 2020 2020 2020 thon 3.6). \n-0005f910: 2020 2020 2020 2020 2020 6173 7365 7274 assert\n-0005f920: 2074 6173 6b20 6973 206e 6f74 204e 6f6e task is not Non\n-0005f930: 650a 2020 2020 2020 2020 2020 2020 2020 e. \n-0005f940: 2020 6c6f 6f70 2e61 6464 5f72 6561 6465 loop.add_reade\n-0005f950: 7228 7374 6174 7573 2c20 7461 736b 2e63 r(status, task.c\n-0005f960: 616e 6365 6c29 0a0a 2020 2020 2020 2020 ancel).. \n-0005f970: 2020 2020 2020 2020 6966 206c 656e 2861 if len(a\n-0005f980: 7267 7629 203d 3d20 323a 0a20 2020 2020 rgv) == 2:. \n-0005f990: 2020 2020 2020 2020 2020 2020 2020 2023 #\n-0005f9a0: 206e 6f72 6d61 6c20 6173 6b70 6173 730a normal askpass.\n-0005f9b0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0005f9c0: 2020 2020 7072 6f6d 7074 203d 2061 7267 prompt = arg\n-0005f9d0: 765b 315d 0a20 2020 2020 2020 2020 2020 v[1]. \n-0005f9e0: 2020 2020 2020 2020 2068 696e 7420 3d20 hint = \n-0005f9f0: 656e 762e 6765 7428 2753 5348 5f41 534b env.get('SSH_ASK\n-0005fa00: 5041 5353 5f50 524f 4d50 5427 2c20 2727 PASS_PROMPT', ''\n-0005fa10: 290a 2020 2020 2020 2020 2020 2020 2020 ). \n-0005fa20: 2020 2020 2020 6c6f 6767 6572 2e64 6562 logger.deb\n-0005fa30: 7567 2827 646f 5f61 736b 7061 7373 2825 ug('do_askpass(%\n-0005fa40: 722c 2025 722c 2025 7229 272c 2073 7464 r, %r, %r)', std\n-0005fa50: 6572 722c 2070 726f 6d70 742c 2068 696e err, prompt, hin\n-0005fa60: 7429 0a20 2020 2020 2020 2020 2020 2020 t). \n-0005fa70: 2020 2020 2020 2061 6e73 7765 7220 3d20 answer = \n-0005fa80: 6177 6169 7420 7365 6c66 2e64 6f5f 6173 await self.do_as\n-0005fa90: 6b70 6173 7328 7374 6465 7272 2c20 7072 kpass(stderr, pr\n-0005faa0: 6f6d 7074 2c20 6869 6e74 290a 2020 2020 ompt, hint). \n-0005fab0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0005fac0: 6c6f 6767 6572 2e64 6562 7567 2827 646f logger.debug('do\n-0005fad0: 5f61 736b 7061 7373 2061 6e73 7765 7220 _askpass answer \n-0005fae0: 2572 272c 2061 6e73 7765 7229 0a20 2020 %r', answer). \n-0005faf0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0005fb00: 2069 6620 616e 7377 6572 2069 7320 6e6f if answer is no\n-0005fb10: 7420 4e6f 6e65 3a0a 2020 2020 2020 2020 t None:. \n-0005fb20: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0005fb30: 7072 696e 7428 616e 7377 6572 2c20 6669 print(answer, fi\n-0005fb40: 6c65 3d73 7464 6f75 7429 0a20 2020 2020 le=stdout). \n-0005fb50: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0005fb60: 2020 2070 7269 6e74 2830 2c20 6669 6c65 print(0, file\n-0005fb70: 3d73 7461 7475 7329 0a0a 2020 2020 2020 =status).. \n-0005fb80: 2020 2020 2020 2020 2020 656c 6966 206c elif l\n-0005fb90: 656e 2861 7267 7629 203d 3d20 363a 0a20 en(argv) == 6:. \n-0005fba0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0005fbb0: 2020 2023 204b 6e6f 776e 486f 7374 7343 # KnownHostsC\n-0005fbc0: 6f6d 6d61 6e64 0a20 2020 2020 2020 2020 ommand. \n-0005fbd0: 2020 2020 2020 2020 2020 2061 7267 7630 argv0\n-0005fbe0: 2c20 7265 6173 6f6e 2c20 686f 7374 2c20 , reason, host, \n-0005fbf0: 616c 676f 7269 7468 6d2c 206b 6579 2c20 algorithm, key, \n-0005fc00: 6669 6e67 6572 7072 696e 7420 3d20 6172 fingerprint = ar\n-0005fc10: 6776 0a20 2020 2020 2020 2020 2020 2020 gv. \n-0005fc20: 2020 2020 2020 2069 6620 7265 6173 6f6e if reason\n-0005fc30: 2069 6e20 5b27 4144 4452 4553 5327 2c20 in ['ADDRESS', \n-0005fc40: 2748 4f53 544e 414d 4527 5d3a 0a20 2020 'HOSTNAME']:. \n-0005fc50: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0005fc60: 2020 2020 206c 6f67 6765 722e 6465 6275 logger.debu\n-0005fc70: 6728 2764 6f5f 686f 7374 6b65 7928 2572 g('do_hostkey(%r\n-0005fc80: 2c20 2572 2c20 2572 2c20 2572 2c20 2572 , %r, %r, %r, %r\n-0005fc90: 2927 2c20 7265 6173 6f6e 2c20 686f 7374 )', reason, host\n-0005fca0: 2c20 616c 676f 7269 7468 6d2c 206b 6579 , algorithm, key\n-0005fcb0: 2c20 6669 6e67 6572 7072 696e 7429 0a20 , fingerprint). \n-0005fcc0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0005fcd0: 2020 2020 2020 2069 6620 6177 6169 7420 if await \n-0005fce0: 7365 6c66 2e64 6f5f 686f 7374 6b65 7928 self.do_hostkey(\n-0005fcf0: 7265 6173 6f6e 2c20 686f 7374 2c20 616c reason, host, al\n-0005fd00: 676f 7269 7468 6d2c 206b 6579 2c20 6669 gorithm, key, fi\n-0005fd10: 6e67 6572 7072 696e 7429 3a0a 2020 2020 ngerprint):. \n-0005fd20: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0005fd30: 2020 2020 2020 2020 7072 696e 7428 686f print(ho\n-0005fd40: 7374 2c20 616c 676f 7269 7468 6d2c 206b st, algorithm, k\n-0005fd50: 6579 2c20 6669 6c65 3d73 7464 6f75 7429 ey, file=stdout)\n-0005fd60: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-0005fd70: 2020 2020 2065 6c73 653a 0a20 2020 2020 else:. \n-0005fd80: 2020 2020 2020 2020 2020 2020 2020 2020 \n-0005fd90: 2020 206c 6f67 6765 722e 6465 6275 6728 logger.debug(\n-0005fda0: 2769 676e 6f72 696e 6720 4b6e 6f77 6e48 'ignoring KnownH\n-0005fdb0: 6f73 7473 436f 6d6d 616e 6420 7265 6173 ostsCommand reas\n-0005fdc0: 6f6e 2025 7227 2c20 7265 6173 6f6e 290a on %r', reason).\n-0005fdd0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-0005fde0: 2020 2020 2070 7269 6e74 2830 2c20 6669 print(0, fi\n-0005fdf0: 6c65 3d73 7461 7475 7329 0a0a 2020 2020 le=status).. \n-0005fe00: 2020 2020 2020 2020 2020 2020 656c 7365 else\n-0005fe10: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n-0005fe20: 2020 2020 2020 6c6f 6767 6572 2e65 7272 logger.err\n-0005fe30: 6f72 2827 496e 636f 7272 6563 7420 6e75 or('Incorrect nu\n-0005fe40: 6d62 6572 206f 6620 636f 6d6d 616e 642d mber of command-\n-0005fe50: 6c69 6e65 2061 7267 756d 656e 7473 2074 line arguments t\n-0005fe60: 6f20 6665 726e 792d 6173 6b70 6173 733a o ferny-askpass:\n-0005fe70: 2025 7327 2c20 6172 6776 290a 2020 2020 %s', argv). \n-0005fe80: 2020 2020 2020 2020 6669 6e61 6c6c 793a finally:\n-0005fe90: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-0005fea0: 206c 6f6f 702e 7265 6d6f 7665 5f72 6561 loop.remove_rea\n-0005feb0: 6465 7228 7374 6174 7573 290a 0a20 2020 der(status).. \n-0005fec0: 2061 7379 6e63 2064 6566 2072 756e 5f63 async def run_c\n-0005fed0: 6f6d 6d61 6e64 2873 656c 662c 2063 6f6d ommand(self, com\n-0005fee0: 6d61 6e64 3a20 7374 722c 2061 7267 733a mand: str, args:\n-0005fef0: 2027 7475 706c 655b 6f62 6a65 6374 2c20 'tuple[object, \n-0005ff00: 2e2e 2e5d 272c 2066 6473 3a20 276c 6973 ...]', fds: 'lis\n-0005ff10: 745b 696e 745d 272c 2073 7464 6572 723a t[int]', stderr:\n-0005ff20: 2073 7472 2920 2d3e 204e 6f6e 653a 0a20 str) -> None:. \n-0005ff30: 2020 2020 2020 206c 6f67 6765 722e 6465 logger.de\n-0005ff40: 6275 6728 2772 756e 5f63 6f6d 6d61 6e64 bug('run_command\n-0005ff50: 2825 732c 2025 732c 2025 732c 2025 7329 (%s, %s, %s, %s)\n-0005ff60: 272c 2063 6f6d 6d61 6e64 2c20 6172 6773 ', command, args\n-0005ff70: 2c20 6664 732c 2073 7464 6572 7229 0a20 , fds, stderr). \n-0005ff80: 2020 2020 2020 2069 6620 636f 6d6d 616e if comman\n-0005ff90: 6420 3d3d 2027 6665 726e 792e 6173 6b70 d == 'ferny.askp\n-0005ffa0: 6173 7327 3a0a 2020 2020 2020 2020 2020 ass':. \n-0005ffb0: 2020 6177 6169 7420 7365 6c66 2e5f 6173 await self._as\n-0005ffc0: 6b70 6173 735f 636f 6d6d 616e 6428 6172 kpass_command(ar\n-0005ffd0: 6773 2c20 6664 732c 2073 7464 6572 7229 gs, fds, stderr)\n-0005ffe0: 0a20 2020 2020 2020 2065 6c73 653a 0a20 . else:. \n-0005fff0: 2020 2020 2020 2020 2020 2061 7761 6974 await\n-00060000: 2073 656c 662e 646f 5f63 7573 746f 6d5f self.do_custom_\n-00060010: 636f 6d6d 616e 6428 636f 6d6d 616e 642c command(command,\n-00060020: 2061 7267 732c 2066 6473 2c20 7374 6465 args, fds, stde\n-00060030: 7272 290a 0a0a 636c 6173 7320 496e 7465 rr)...class Inte\n-00060040: 7261 6374 696f 6e41 6765 6e74 3a0a 2020 ractionAgent:. \n-00060050: 2020 5f68 616e 646c 6572 733a 2027 6469 _handlers: 'di\n-00060060: 6374 5b73 7472 2c20 496e 7465 7261 6374 ct[str, Interact\n-00060070: 696f 6e48 616e 646c 6572 5d27 0a0a 2020 ionHandler]'.. \n-00060080: 2020 5f6c 6f6f 703a 2061 7379 6e63 696f _loop: asyncio\n-00060090: 2e41 6273 7472 6163 7445 7665 6e74 4c6f .AbstractEventLo\n-000600a0: 6f70 0a0a 2020 2020 5f74 6173 6b73 3a20 op.. _tasks: \n-000600b0: 2773 6574 5b61 7379 6e63 696f 2e54 6173 'set[asyncio.Tas\n-000600c0: 6b5d 270a 0a20 2020 205f 6275 6666 6572 k]'.. _buffer\n-000600d0: 3a20 6279 7465 6172 7261 790a 2020 2020 : bytearray. \n-000600e0: 5f6f 7572 733a 2073 6f63 6b65 742e 736f _ours: socket.so\n-000600f0: 636b 6574 0a20 2020 205f 7468 6569 7273 cket. _theirs\n-00060100: 3a20 736f 636b 6574 2e73 6f63 6b65 740a : socket.socket.\n-00060110: 0a20 2020 205f 636f 6d70 6c65 7469 6f6e . _completion\n-00060120: 5f66 7574 7572 653a 2027 6173 796e 6369 _future: 'asynci\n-00060130: 6f2e 4675 7475 7265 5b73 7472 5d27 0a20 o.Future[str]'. \n-00060140: 2020 205f 7065 6e64 696e 675f 7265 7375 _pending_resu\n-00060150: 6c74 3a20 274e 6f6e 6520 7c20 7374 7220 lt: 'None | str \n-00060160: 7c20 4578 6365 7074 696f 6e27 203d 204e | Exception' = N\n-00060170: 6f6e 650a 2020 2020 5f65 6e64 3a20 626f one. _end: bo\n-00060180: 6f6c 203d 2046 616c 7365 0a0a 2020 2020 ol = False.. \n-00060190: 6465 6620 5f63 6f6e 7369 6465 725f 636f def _consider_co\n-000601a0: 6d70 6c65 7469 6f6e 2873 656c 6629 202d mpletion(self) -\n-000601b0: 3e20 4e6f 6e65 3a0a 2020 2020 2020 2020 > None:. \n-000601c0: 6c6f 6767 6572 2e64 6562 7567 2827 5f63 logger.debug('_c\n-000601d0: 6f6e 7369 6465 725f 636f 6d70 6c65 7469 onsider_completi\n-000601e0: 6f6e 2825 7229 272c 2073 656c 6629 0a0a on(%r)', self)..\n-000601f0: 2020 2020 2020 2020 6966 2073 656c 662e if self.\n-00060200: 5f70 656e 6469 6e67 5f72 6573 756c 7420 _pending_result \n-00060210: 6973 204e 6f6e 6520 6f72 2073 656c 662e is None or self.\n-00060220: 5f74 6173 6b73 3a0a 2020 2020 2020 2020 _tasks:. \n-00060230: 2020 2020 6c6f 6767 6572 2e64 6562 7567 logger.debug\n-00060240: 2827 2020 6275 7420 6e6f 7420 7265 6164 (' but not read\n-00060250: 7920 7965 7427 290a 0a20 2020 2020 2020 y yet').. \n-00060260: 2065 6c69 6620 7365 6c66 2e5f 636f 6d70 elif self._comp\n-00060270: 6c65 7469 6f6e 5f66 7574 7572 652e 646f letion_future.do\n-00060280: 6e65 2829 3a0a 2020 2020 2020 2020 2020 ne():. \n-00060290: 2020 6c6f 6767 6572 2e64 6562 7567 2827 logger.debug('\n-000602a0: 2020 6275 7420 616c 7265 6164 7920 636f but already co\n-000602b0: 6d70 6c65 7465 2729 0a0a 2020 2020 2020 mplete').. \n-000602c0: 2020 656c 6966 2069 7369 6e73 7461 6e63 elif isinstanc\n-000602d0: 6528 7365 6c66 2e5f 7065 6e64 696e 675f e(self._pending_\n-000602e0: 7265 7375 6c74 2c20 7374 7229 3a0a 2020 result, str):. \n-000602f0: 2020 2020 2020 2020 2020 6c6f 6767 6572 logger\n-00060300: 2e64 6562 7567 2827 2020 7375 626d 6974 .debug(' submit\n-00060310: 7469 6e67 2073 7464 6572 7220 2825 7229 ting stderr (%r)\n-00060320: 2074 6f20 636f 6d70 6c65 7469 6f6e 5f66 to completion_f\n-00060330: 7574 7572 6527 2c20 7365 6c66 2e5f 7065 uture', self._pe\n-00060340: 6e64 696e 675f 7265 7375 6c74 290a 2020 nding_result). \n-00060350: 2020 2020 2020 2020 2020 7365 6c66 2e5f self._\n-00060360: 636f 6d70 6c65 7469 6f6e 5f66 7574 7572 completion_futur\n-00060370: 652e 7365 745f 7265 7375 6c74 2873 656c e.set_result(sel\n-00060380: 662e 5f70 656e 6469 6e67 5f72 6573 756c f._pending_resul\n-00060390: 7429 0a0a 2020 2020 2020 2020 656c 7365 t).. else\n-000603a0: 3a0a 2020 2020 2020 2020 2020 2020 6c6f :. lo\n-000603b0: 6767 6572 2e64 6562 7567 2827 2020 7375 gger.debug(' su\n-000603c0: 626d 6974 7469 6e67 2065 7863 6570 7469 bmitting excepti\n-000603d0: 6f6e 2028 2572 2920 746f 2063 6f6d 706c on (%r) to compl\n-000603e0: 6574 696f 6e5f 6675 7475 7265 2729 0a20 etion_future'). \n-000603f0: 2020 2020 2020 2020 2020 2073 656c 662e self.\n-00060400: 5f63 6f6d 706c 6574 696f 6e5f 6675 7475 _completion_futu\n-00060410: 7265 2e73 6574 5f65 7863 6570 7469 6f6e re.set_exception\n-00060420: 2873 656c 662e 5f70 656e 6469 6e67 5f72 (self._pending_r\n-00060430: 6573 756c 7429 0a0a 2020 2020 6465 6620 esult).. def \n-00060440: 5f72 6573 756c 7428 7365 6c66 2c20 7265 _result(self, re\n-00060450: 7375 6c74 3a20 2773 7472 207c 2045 7863 sult: 'str | Exc\n-00060460: 6570 7469 6f6e 2729 202d 3e20 4e6f 6e65 eption') -> None\n-00060470: 3a0a 2020 2020 2020 2020 6c6f 6767 6572 :. logger\n-00060480: 2e64 6562 7567 2827 5f72 6573 756c 7428 .debug('_result(\n-00060490: 2572 2c20 2572 2927 2c20 7365 6c66 2c20 %r, %r)', self, \n-000604a0: 7265 7375 6c74 290a 0a20 2020 2020 2020 result).. \n-000604b0: 2069 6620 7365 6c66 2e5f 7065 6e64 696e if self._pendin\n-000604c0: 675f 7265 7375 6c74 2069 7320 4e6f 6e65 g_result is None\n-000604d0: 3a0a 2020 2020 2020 2020 2020 2020 7365 :. se\n-000604e0: 6c66 2e5f 7065 6e64 696e 675f 7265 7375 lf._pending_resu\n-000604f0: 6c74 203d 2072 6573 756c 740a 0a20 2020 lt = result.. \n-00060500: 2020 2020 2069 6620 7365 6c66 2e5f 6f75 if self._ou\n-00060510: 7273 2e66 696c 656e 6f28 2920 213d 202d rs.fileno() != -\n-00060520: 313a 0a20 2020 2020 2020 2020 2020 206c 1:. l\n-00060530: 6f67 6765 722e 6465 6275 6728 2720 2072 ogger.debug(' r\n-00060540: 656d 6f76 655f 7265 6164 6572 2825 7229 emove_reader(%r)\n-00060550: 272c 2073 656c 662e 5f6f 7572 7329 0a20 ', self._ours). \n-00060560: 2020 2020 2020 2020 2020 2073 656c 662e self.\n-00060570: 5f6c 6f6f 702e 7265 6d6f 7665 5f72 6561 _loop.remove_rea\n-00060580: 6465 7228 7365 6c66 2e5f 6f75 7273 2e66 der(self._ours.f\n-00060590: 696c 656e 6f28 2929 0a0a 2020 2020 2020 ileno()).. \n-000605a0: 2020 666f 7220 7461 736b 2069 6e20 7365 for task in se\n-000605b0: 6c66 2e5f 7461 736b 733a 0a20 2020 2020 lf._tasks:. \n-000605c0: 2020 2020 2020 206c 6f67 6765 722e 6465 logger.de\n-000605d0: 6275 6728 2720 2020 2063 616e 6365 6c28 bug(' cancel(\n-000605e0: 2572 2927 2c20 7461 736b 290a 2020 2020 %r)', task). \n-000605f0: 2020 2020 2020 2020 7461 736b 2e63 616e task.can\n-00060600: 6365 6c28 290a 0a20 2020 2020 2020 206c cel().. l\n-00060610: 6f67 6765 722e 6465 6275 6728 2720 2063 ogger.debug(' c\n-00060620: 6c6f 7369 6e67 2073 6f63 6b65 7473 2729 losing sockets')\n-00060630: 0a20 2020 2020 2020 2073 656c 662e 5f74 . self._t\n-00060640: 6865 6972 732e 636c 6f73 6528 2920 2023 heirs.close() #\n-00060650: 2069 6465 6d70 6f74 656e 740a 2020 2020 idempotent. \n-00060660: 2020 2020 7365 6c66 2e5f 6f75 7273 2e63 self._ours.c\n-00060670: 6c6f 7365 2829 0a0a 2020 2020 2020 2020 lose().. \n-00060680: 7365 6c66 2e5f 636f 6e73 6964 6572 5f63 self._consider_c\n-00060690: 6f6d 706c 6574 696f 6e28 290a 0a20 2020 ompletion().. \n-000606a0: 2064 6566 205f 696e 766f 6b65 5f63 6f6d def _invoke_com\n-000606b0: 6d61 6e64 2873 656c 662c 2073 7464 6572 mand(self, stder\n-000606c0: 723a 2062 7974 6573 2c20 636f 6d6d 616e r: bytes, comman\n-000606d0: 645f 626c 6f62 3a20 6279 7465 732c 2066 d_blob: bytes, f\n-000606e0: 6473 3a20 276c 6973 745b 696e 745d 2729 ds: 'list[int]')\n-000606f0: 202d 3e20 4e6f 6e65 3a0a 2020 2020 2020 -> None:. \n-00060700: 2020 6c6f 6767 6572 2e64 6562 7567 2827 logger.debug('\n-00060710: 5f69 6e76 6f6b 655f 636f 6d6d 616e 6428 _invoke_command(\n-00060720: 2572 2c20 2572 2c20 2572 2927 2c20 7374 %r, %r, %r)', st\n-00060730: 6465 7272 2c20 636f 6d6d 616e 645f 626c derr, command_bl\n-00060740: 6f62 2c20 6664 7329 0a20 2020 2020 2020 ob, fds). \n-00060750: 2074 7279 3a0a 2020 2020 2020 2020 2020 try:. \n-00060760: 2020 636f 6d6d 616e 642c 2061 7267 7320 command, args \n-00060770: 3d20 6173 742e 6c69 7465 7261 6c5f 6576 = ast.literal_ev\n-00060780: 616c 2863 6f6d 6d61 6e64 5f62 6c6f 622e al(command_blob.\n-00060790: 6465 636f 6465 2829 290a 2020 2020 2020 decode()). \n-000607a0: 2020 2020 2020 6966 206e 6f74 2069 7369 if not isi\n-000607b0: 6e73 7461 6e63 6528 636f 6d6d 616e 642c nstance(command,\n-000607c0: 2073 7472 2920 6f72 206e 6f74 2069 7369 str) or not isi\n-000607d0: 6e73 7461 6e63 6528 6172 6773 2c20 7475 nstance(args, tu\n-000607e0: 706c 6529 3a0a 2020 2020 2020 2020 2020 ple):. \n-000607f0: 2020 2020 2020 7261 6973 6520 5479 7065 raise Type\n-00060800: 4572 726f 7228 2749 6e76 616c 6964 2061 Error('Invalid a\n-00060810: 7267 756d 656e 7420 7479 7065 7327 290a rgument types').\n-00060820: 2020 2020 2020 2020 6578 6365 7074 2028 except (\n-00060830: 556e 6963 6f64 6544 6563 6f64 6545 7272 UnicodeDecodeErr\n-00060840: 6f72 2c20 5379 6e74 6178 4572 726f 722c or, SyntaxError,\n-00060850: 2056 616c 7565 4572 726f 722c 2054 7970 ValueError, Typ\n-00060860: 6545 7272 6f72 2920 6173 2065 7863 3a0a eError) as exc:.\n-00060870: 2020 2020 2020 2020 2020 2020 6c6f 6767 logg\n-00060880: 6572 2e65 7272 6f72 2827 5265 6365 6976 er.error('Receiv\n-00060890: 6564 2069 6e76 616c 6964 2066 6572 6e79 ed invalid ferny\n-000608a0: 2063 6f6d 6d61 6e64 3a20 2573 3a20 2573 command: %s: %s\n-000608b0: 272c 2063 6f6d 6d61 6e64 5f62 6c6f 622c ', command_blob,\n-000608c0: 2065 7863 290a 2020 2020 2020 2020 2020 exc). \n-000608d0: 2020 7265 7475 726e 0a0a 2020 2020 2020 return.. \n-000608e0: 2020 6966 2063 6f6d 6d61 6e64 203d 3d20 if command == \n-000608f0: 2766 6572 6e79 2e65 6e64 273a 0a20 2020 'ferny.end':. \n-00060900: 2020 2020 2020 2020 2073 656c 662e 5f65 self._e\n-00060910: 6e64 203d 2054 7275 650a 2020 2020 2020 nd = True. \n-00060920: 2020 2020 2020 7365 6c66 2e5f 7265 7375 self._resu\n-00060930: 6c74 2873 656c 662e 5f62 7566 6665 722e lt(self._buffer.\n-00060940: 6465 636f 6465 2865 7272 6f72 733d 2772 decode(errors='r\n-00060950: 6570 6c61 6365 2729 290a 2020 2020 2020 eplace')). \n-00060960: 2020 2020 2020 7265 7475 726e 0a0a 2020 return.. \n-00060970: 2020 2020 2020 7472 793a 0a20 2020 2020 try:. \n-00060980: 2020 2020 2020 2068 616e 646c 6572 203d handler =\n-00060990: 2073 656c 662e 5f68 616e 646c 6572 735b self._handlers[\n-000609a0: 636f 6d6d 616e 645d 0a20 2020 2020 2020 command]. \n-000609b0: 2065 7863 6570 7420 4b65 7945 7272 6f72 except KeyError\n-000609c0: 3a0a 2020 2020 2020 2020 2020 2020 6c6f :. lo\n-000609d0: 6767 6572 2e65 7272 6f72 2827 5265 6365 gger.error('Rece\n-000609e0: 6976 6564 2075 6e68 616e 646c 6564 2066 ived unhandled f\n-000609f0: 6572 6e79 2063 6f6d 6d61 6e64 3a20 2573 erny command: %s\n-00060a00: 272c 2063 6f6d 6d61 6e64 290a 2020 2020 ', command). \n-00060a10: 2020 2020 2020 2020 7265 7475 726e 0a0a return..\n-00060a20: 2020 2020 2020 2020 2320 5468 6520 7461 # The ta\n-00060a30: 736b 2069 7320 7265 7370 6f6e 7369 626c sk is responsibl\n-00060a40: 6520 666f 7220 7468 6520 6c69 7374 206f e for the list o\n-00060a50: 6620 6664 7320 616e 6420 7265 6d6f 7669 f fds and removi\n-00060a60: 6e67 2069 7473 656c 660a 2020 2020 2020 ng itself. \n-00060a70: 2020 2320 6672 6f6d 2074 6865 2073 6574 # from the set\n-00060a80: 2e0a 2020 2020 2020 2020 7461 736b 5f66 .. task_f\n-00060a90: 6473 203d 206c 6973 7428 6664 7329 0a20 ds = list(fds). \n-00060aa0: 2020 2020 2020 2074 6173 6b20 3d20 7365 task = se\n-00060ab0: 6c66 2e5f 6c6f 6f70 2e63 7265 6174 655f lf._loop.create_\n-00060ac0: 7461 736b 2868 616e 646c 6572 2e72 756e task(handler.run\n-00060ad0: 5f63 6f6d 6d61 6e64 2863 6f6d 6d61 6e64 _command(command\n-00060ae0: 2c20 6172 6773 2c20 7461 736b 5f66 6473 , args, task_fds\n-00060af0: 2c20 7374 6465 7272 2e64 6563 6f64 6528 , stderr.decode(\n-00060b00: 2929 290a 0a20 2020 2020 2020 2064 6566 ))).. def\n-00060b10: 2062 6f74 746f 6d5f 6861 6c66 2863 6f6d bottom_half(com\n-00060b20: 706c 6574 6564 5f74 6173 6b3a 2061 7379 pleted_task: asy\n-00060b30: 6e63 696f 2e54 6173 6b29 202d 3e20 4e6f ncio.Task) -> No\n-00060b40: 6e65 3a0a 2020 2020 2020 2020 2020 2020 ne:. \n-00060b50: 6173 7365 7274 2063 6f6d 706c 6574 6564 assert completed\n-00060b60: 5f74 6173 6b20 6973 2074 6173 6b0a 2020 _task is task. \n-00060b70: 2020 2020 2020 2020 2020 7768 696c 6520 while \n-00060b80: 7461 736b 5f66 6473 3a0a 2020 2020 2020 task_fds:. \n-00060b90: 2020 2020 2020 2020 2020 6f73 2e63 6c6f os.clo\n-00060ba0: 7365 2874 6173 6b5f 6664 732e 706f 7028 se(task_fds.pop(\n-00060bb0: 2929 0a20 2020 2020 2020 2020 2020 2073 )). s\n-00060bc0: 656c 662e 5f74 6173 6b73 2e72 656d 6f76 elf._tasks.remov\n-00060bd0: 6528 7461 736b 290a 0a20 2020 2020 2020 e(task).. \n-00060be0: 2020 2020 2074 7279 3a0a 2020 2020 2020 try:. \n-00060bf0: 2020 2020 2020 2020 2020 7461 736b 2e72 task.r\n-00060c00: 6573 756c 7428 290a 2020 2020 2020 2020 esult(). \n-00060c10: 2020 2020 2020 2020 6c6f 6767 6572 2e64 logger.d\n-00060c20: 6562 7567 2827 2572 2063 6f6d 706c 6574 ebug('%r complet\n-00060c30: 6564 2063 6c65 616e 6c79 272c 2068 616e ed cleanly', han\n-00060c40: 646c 6572 290a 2020 2020 2020 2020 2020 dler). \n-00060c50: 2020 6578 6365 7074 2061 7379 6e63 696f except asyncio\n-00060c60: 2e43 616e 6365 6c6c 6564 4572 726f 723a .CancelledError:\n-00060c70: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-00060c80: 2023 2074 6869 7320 6973 206e 6f74 2061 # this is not a\n-00060c90: 6e20 6572 726f 7220 e280 9420 6974 206a n error ... it j\n-00060ca0: 7573 7420 6d65 616e 7320 6665 726e 792d ust means ferny-\n-00060cb0: 6173 6b70 6173 7320 6578 6974 6564 2076 askpass exited v\n-00060cc0: 6961 2073 6967 6e61 6c0a 2020 2020 2020 ia signal. \n-00060cd0: 2020 2020 2020 2020 2020 6c6f 6767 6572 logger\n-00060ce0: 2e64 6562 7567 2827 2572 2077 6173 2063 .debug('%r was c\n-00060cf0: 616e 6365 6c6c 6564 272c 2068 616e 646c ancelled', handl\n-00060d00: 6572 290a 2020 2020 2020 2020 2020 2020 er). \n-00060d10: 6578 6365 7074 2045 7863 6570 7469 6f6e except Exception\n-00060d20: 2061 7320 6578 633a 0a20 2020 2020 2020 as exc:. \n-00060d30: 2020 2020 2020 2020 206c 6f67 6765 722e logger.\n-00060d40: 6465 6275 6728 2725 7220 7261 6973 6564 debug('%r raised\n-00060d50: 2025 7227 2c20 6861 6e64 6c65 722c 2065 %r', handler, e\n-00060d60: 7863 290a 2020 2020 2020 2020 2020 2020 xc). \n-00060d70: 2020 2020 7365 6c66 2e5f 7265 7375 6c74 self._result\n-00060d80: 2865 7863 290a 0a20 2020 2020 2020 2020 (exc).. \n-00060d90: 2020 2073 656c 662e 5f63 6f6e 7369 6465 self._conside\n-00060da0: 725f 636f 6d70 6c65 7469 6f6e 2829 0a0a r_completion()..\n-00060db0: 2020 2020 2020 2020 7461 736b 2e61 6464 task.add\n-00060dc0: 5f64 6f6e 655f 6361 6c6c 6261 636b 2862 _done_callback(b\n-00060dd0: 6f74 746f 6d5f 6861 6c66 290a 2020 2020 ottom_half). \n-00060de0: 2020 2020 7365 6c66 2e5f 7461 736b 732e self._tasks.\n-00060df0: 6164 6428 7461 736b 290a 2020 2020 2020 add(task). \n-00060e00: 2020 6664 735b 3a5d 203d 205b 5d0a 0a20 fds[:] = [].. \n-00060e10: 2020 2064 6566 205f 676f 745f 6461 7461 def _got_data\n-00060e20: 2873 656c 662c 2064 6174 613a 2062 7974 (self, data: byt\n-00060e30: 6573 2c20 6664 733a 2027 6c69 7374 5b69 es, fds: 'list[i\n-00060e40: 6e74 5d27 2920 2d3e 204e 6f6e 653a 0a20 nt]') -> None:. \n-00060e50: 2020 2020 2020 206c 6f67 6765 722e 6465 logger.de\n-00060e60: 6275 6728 275f 676f 745f 6461 7461 2825 bug('_got_data(%\n-00060e70: 722c 2025 7229 272c 2064 6174 612c 2066 r, %r)', data, f\n-00060e80: 6473 290a 0a20 2020 2020 2020 2069 6620 ds).. if \n-00060e90: 6461 7461 203d 3d20 6227 273a 0a20 2020 data == b'':. \n-00060ea0: 2020 2020 2020 2020 2073 656c 662e 5f72 self._r\n-00060eb0: 6573 756c 7428 7365 6c66 2e5f 6275 6666 esult(self._buff\n-00060ec0: 6572 2e64 6563 6f64 6528 6572 726f 7273 er.decode(errors\n-00060ed0: 3d27 7265 706c 6163 6527 2929 0a20 2020 ='replace')). \n-00060ee0: 2020 2020 2020 2020 2072 6574 7572 6e0a return.\n-00060ef0: 0a20 2020 2020 2020 2073 656c 662e 5f62 . self._b\n-00060f00: 7566 6665 722e 6578 7465 6e64 2864 6174 uffer.extend(dat\n-00060f10: 6129 0a0a 2020 2020 2020 2020 2320 5265 a).. # Re\n-00060f20: 6164 207a 6572 6f20 6f72 206d 6f72 6520 ad zero or more \n-00060f30: 2272 656d 6f74 6522 206d 6573 7361 6765 \"remote\" message\n-00060f40: 730a 2020 2020 2020 2020 6368 756e 6b73 s. chunks\n-00060f50: 203d 2043 4f4d 4d41 4e44 5f52 452e 7370 = COMMAND_RE.sp\n-00060f60: 6c69 7428 7365 6c66 2e5f 6275 6666 6572 lit(self._buffer\n-00060f70: 290a 2020 2020 2020 2020 7365 6c66 2e5f ). self._\n-00060f80: 6275 6666 6572 203d 2062 7974 6561 7272 buffer = bytearr\n-00060f90: 6179 2863 6875 6e6b 732e 706f 7028 2929 ay(chunks.pop())\n-00060fa0: 0a20 2020 2020 2020 2077 6869 6c65 206c . while l\n-00060fb0: 656e 2863 6875 6e6b 7329 203e 2031 3a0a en(chunks) > 1:.\n-00060fc0: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n-00060fd0: 2e5f 696e 766f 6b65 5f63 6f6d 6d61 6e64 ._invoke_command\n-00060fe0: 2863 6875 6e6b 735b 305d 2c20 6368 756e (chunks[0], chun\n-00060ff0: 6b73 5b31 5d2c 205b 5d29 0a20 2020 2020 ks[1], []). \n-00061000: 2020 2020 2020 2063 6875 6e6b 7320 3d20 chunks = \n-00061010: 6368 756e 6b73 5b32 3a5d 0a0a 2020 2020 chunks[2:].. \n-00061020: 2020 2020 2320 4d61 7962 6520 7265 6164 # Maybe read\n-00061030: 206f 6e65 2022 6c6f 6361 6c22 206d 6573 one \"local\" mes\n-00061040: 7361 6765 0a20 2020 2020 2020 2069 6620 sage. if \n-00061050: 6664 733a 0a20 2020 2020 2020 2020 2020 fds:. \n-00061060: 2061 7373 6572 7420 7365 6c66 2e5f 6275 assert self._bu\n-00061070: 6666 6572 2e65 6e64 7377 6974 6828 6227 ffer.endswith(b'\n-00061080: 5c30 2729 2c20 7365 6c66 2e5f 6275 6666 \\0'), self._buff\n-00061090: 6572 0a20 2020 2020 2020 2020 2020 2073 er. s\n-000610a0: 7464 6572 7220 3d20 7365 6c66 2e5f 6275 tderr = self._bu\n-000610b0: 6666 6572 5b3a 2d31 5d0a 2020 2020 2020 ffer[:-1]. \n-000610c0: 2020 2020 2020 7365 6c66 2e5f 6275 6666 self._buff\n-000610d0: 6572 203d 2062 7974 6561 7272 6179 2862 er = bytearray(b\n-000610e0: 2727 290a 2020 2020 2020 2020 2020 2020 ''). \n-000610f0: 7769 7468 206f 7065 6e28 6664 732e 706f with open(fds.po\n-00061100: 7028 3029 2c20 2772 6227 2920 6173 2063 p(0), 'rb') as c\n-00061110: 6f6d 6d61 6e64 5f63 6861 6e6e 656c 3a0a ommand_channel:.\n-00061120: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00061130: 636f 6d6d 616e 6420 3d20 636f 6d6d 616e command = comman\n-00061140: 645f 6368 616e 6e65 6c2e 7265 6164 2829 d_channel.read()\n-00061150: 0a20 2020 2020 2020 2020 2020 2073 656c . sel\n-00061160: 662e 5f69 6e76 6f6b 655f 636f 6d6d 616e f._invoke_comman\n-00061170: 6428 7374 6465 7272 2c20 636f 6d6d 616e d(stderr, comman\n-00061180: 642c 2066 6473 290a 0a20 2020 2064 6566 d, fds).. def\n-00061190: 205f 7265 6164 5f72 6561 6479 2873 656c _read_ready(sel\n-000611a0: 6629 202d 3e20 4e6f 6e65 3a0a 2020 2020 f) -> None:. \n-000611b0: 2020 2020 7472 793a 0a20 2020 2020 2020 try:. \n-000611c0: 2020 2020 2064 6174 612c 2066 6473 2c20 data, fds, \n-000611d0: 5f66 6c61 6773 2c20 5f61 6464 7220 3d20 _flags, _addr = \n-000611e0: 7265 6376 5f66 6473 2873 656c 662e 5f6f recv_fds(self._o\n-000611f0: 7572 732c 2034 3039 362c 2031 302c 2066 urs, 4096, 10, f\n-00061200: 6c61 6773 3d73 6f63 6b65 742e 4d53 475f lags=socket.MSG_\n-00061210: 444f 4e54 5741 4954 290a 2020 2020 2020 DONTWAIT). \n-00061220: 2020 6578 6365 7074 2042 6c6f 636b 696e except Blockin\n-00061230: 6749 4f45 7272 6f72 3a0a 2020 2020 2020 gIOError:. \n-00061240: 2020 2020 2020 7265 7475 726e 0a20 2020 return. \n-00061250: 2020 2020 2065 7863 6570 7420 4f53 4572 except OSEr\n-00061260: 726f 7220 6173 2065 7863 3a0a 2020 2020 ror as exc:. \n-00061270: 2020 2020 2020 2020 7365 6c66 2e5f 7265 self._re\n-00061280: 7375 6c74 2865 7863 290a 2020 2020 2020 sult(exc). \n-00061290: 2020 656c 7365 3a0a 2020 2020 2020 2020 else:. \n-000612a0: 2020 2020 7365 6c66 2e5f 676f 745f 6461 self._got_da\n-000612b0: 7461 2864 6174 612c 2066 6473 290a 2020 ta(data, fds). \n-000612c0: 2020 2020 2020 6669 6e61 6c6c 793a 0a20 finally:. \n-000612d0: 2020 2020 2020 2020 2020 2077 6869 6c65 while\n-000612e0: 2066 6473 3a0a 2020 2020 2020 2020 2020 fds:. \n-000612f0: 2020 2020 2020 6f73 2e63 6c6f 7365 2866 os.close(f\n-00061300: 6473 2e70 6f70 2829 290a 0a20 2020 2064 ds.pop()).. d\n-00061310: 6566 205f 5f69 6e69 745f 5f28 0a20 2020 ef __init__(. \n-00061320: 2020 2020 2073 656c 662c 0a20 2020 2020 self,. \n-00061330: 2020 2068 616e 646c 6572 733a 2053 6571 handlers: Seq\n-00061340: 7565 6e63 655b 496e 7465 7261 6374 696f uence[Interactio\n-00061350: 6e48 616e 646c 6572 5d2c 0a20 2020 2020 nHandler],. \n-00061360: 2020 206c 6f6f 703a 2027 6173 796e 6369 loop: 'asynci\n-00061370: 6f2e 4162 7374 7261 6374 4576 656e 744c o.AbstractEventL\n-00061380: 6f6f 7020 7c20 4e6f 6e65 2720 3d20 4e6f oop | None' = No\n-00061390: 6e65 2c0a 2020 2020 2020 2020 646f 6e65 ne,. done\n-000613a0: 5f63 616c 6c62 6163 6b3a 2027 4361 6c6c _callback: 'Call\n-000613b0: 6162 6c65 5b5b 6173 796e 6369 6f2e 4675 able[[asyncio.Fu\n-000613c0: 7475 7265 5b73 7472 5d5d 2c20 4e6f 6e65 ture[str]], None\n-000613d0: 5d20 7c20 4e6f 6e65 2720 3d20 4e6f 6e65 ] | None' = None\n-000613e0: 2c0a 2020 2020 2920 2d3e 204e 6f6e 653a ,. ) -> None:\n-000613f0: 0a20 2020 2020 2020 2073 656c 662e 5f6c . self._l\n-00061400: 6f6f 7020 3d20 6c6f 6f70 206f 7220 6765 oop = loop or ge\n-00061410: 745f 7275 6e6e 696e 675f 6c6f 6f70 2829 t_running_loop()\n-00061420: 0a20 2020 2020 2020 2073 656c 662e 5f63 . self._c\n-00061430: 6f6d 706c 6574 696f 6e5f 6675 7475 7265 ompletion_future\n-00061440: 203d 2073 656c 662e 5f6c 6f6f 702e 6372 = self._loop.cr\n-00061450: 6561 7465 5f66 7574 7572 6528 290a 2020 eate_future(). \n-00061460: 2020 2020 2020 7365 6c66 2e5f 7461 736b self._task\n-00061470: 7320 3d20 7365 7428 290a 2020 2020 2020 s = set(). \n-00061480: 2020 7365 6c66 2e5f 6861 6e64 6c65 7273 self._handlers\n-00061490: 203d 207b 7d0a 0a20 2020 2020 2020 2066 = {}.. f\n-000614a0: 6f72 2068 616e 646c 6572 2069 6e20 6861 or handler in ha\n-000614b0: 6e64 6c65 7273 3a0a 2020 2020 2020 2020 ndlers:. \n-000614c0: 2020 2020 666f 7220 636f 6d6d 616e 6420 for command \n-000614d0: 696e 2068 616e 646c 6572 2e63 6f6d 6d61 in handler.comma\n-000614e0: 6e64 733a 0a20 2020 2020 2020 2020 2020 nds:. \n-000614f0: 2020 2020 2073 656c 662e 5f68 616e 646c self._handl\n-00061500: 6572 735b 636f 6d6d 616e 645d 203d 2068 ers[command] = h\n-00061510: 616e 646c 6572 0a0a 2020 2020 2020 2020 andler.. \n-00061520: 6966 2064 6f6e 655f 6361 6c6c 6261 636b if done_callback\n-00061530: 2069 7320 6e6f 7420 4e6f 6e65 3a0a 2020 is not None:. \n-00061540: 2020 2020 2020 2020 2020 7365 6c66 2e5f self._\n-00061550: 636f 6d70 6c65 7469 6f6e 5f66 7574 7572 completion_futur\n-00061560: 652e 6164 645f 646f 6e65 5f63 616c 6c62 e.add_done_callb\n-00061570: 6163 6b28 646f 6e65 5f63 616c 6c62 6163 ack(done_callbac\n-00061580: 6b29 0a0a 2020 2020 2020 2020 7365 6c66 k).. self\n-00061590: 2e5f 7468 6569 7273 2c20 7365 6c66 2e5f ._theirs, self._\n-000615a0: 6f75 7273 203d 2073 6f63 6b65 742e 736f ours = socket.so\n-000615b0: 636b 6574 7061 6972 2873 6f63 6b65 742e cketpair(socket.\n-000615c0: 4146 5f55 4e49 582c 2073 6f63 6b65 742e AF_UNIX, socket.\n-000615d0: 534f 434b 5f53 5452 4541 4d29 0a20 2020 SOCK_STREAM). \n-000615e0: 2020 2020 2073 656c 662e 5f62 7566 6665 self._buffe\n-000615f0: 7220 3d20 6279 7465 6172 7261 7928 290a r = bytearray().\n-00061600: 0a20 2020 2064 6566 2066 696c 656e 6f28 . def fileno(\n-00061610: 7365 6c66 2920 2d3e 2069 6e74 3a0a 2020 self) -> int:. \n-00061620: 2020 2020 2020 7265 7475 726e 2073 656c return sel\n-00061630: 662e 5f74 6865 6972 732e 6669 6c65 6e6f f._theirs.fileno\n-00061640: 2829 0a0a 2020 2020 6465 6620 7374 6172 ().. def star\n-00061650: 7428 7365 6c66 2920 2d3e 204e 6f6e 653a t(self) -> None:\n-00061660: 0a20 2020 2020 2020 206c 6f67 6765 722e . logger.\n-00061670: 6465 6275 6728 2773 7461 7274 2825 7229 debug('start(%r)\n-00061680: 272c 2073 656c 6629 0a20 2020 2020 2020 ', self). \n-00061690: 2069 6620 7365 6c66 2e5f 6f75 7273 2e66 if self._ours.f\n-000616a0: 696c 656e 6f28 2920 213d 202d 313a 0a20 ileno() != -1:. \n-000616b0: 2020 2020 2020 2020 2020 206c 6f67 6765 logge\n-000616c0: 722e 6465 6275 6728 2720 2061 6464 5f72 r.debug(' add_r\n-000616d0: 6561 6465 7228 2572 2927 2c20 7365 6c66 eader(%r)', self\n-000616e0: 2e5f 6f75 7273 290a 2020 2020 2020 2020 ._ours). \n-000616f0: 2020 2020 7365 6c66 2e5f 6c6f 6f70 2e61 self._loop.a\n-00061700: 6464 5f72 6561 6465 7228 7365 6c66 2e5f dd_reader(self._\n-00061710: 6f75 7273 2e66 696c 656e 6f28 292c 2073 ours.fileno(), s\n-00061720: 656c 662e 5f72 6561 645f 7265 6164 7929 elf._read_ready)\n-00061730: 0a20 2020 2020 2020 2065 6c73 653a 0a20 . else:. \n-00061740: 2020 2020 2020 2020 2020 206c 6f67 6765 logge\n-00061750: 722e 6465 6275 6728 2720 202e 2e2e 6275 r.debug(' ...bu\n-00061760: 7420 6167 656e 7420 6973 2061 6c72 6561 t agent is alrea\n-00061770: 6479 2066 696e 6973 6865 642e 2729 0a0a dy finished.')..\n-00061780: 2020 2020 2020 2020 6c6f 6767 6572 2e64 logger.d\n-00061790: 6562 7567 2827 2020 636c 6f73 6528 2572 ebug(' close(%r\n-000617a0: 2927 2c20 7365 6c66 2e5f 7468 6569 7273 )', self._theirs\n-000617b0: 290a 2020 2020 2020 2020 7365 6c66 2e5f ). self._\n-000617c0: 7468 6569 7273 2e63 6c6f 7365 2829 0a0a theirs.close()..\n-000617d0: 2020 2020 6465 6620 666f 7263 655f 636f def force_co\n-000617e0: 6d70 6c65 7469 6f6e 2873 656c 6629 202d mpletion(self) -\n-000617f0: 3e20 4e6f 6e65 3a0a 2020 2020 2020 2020 > None:. \n-00061800: 6c6f 6767 6572 2e64 6562 7567 2827 666f logger.debug('fo\n-00061810: 7263 655f 636f 6d70 6c65 7469 6f6e 2825 rce_completion(%\n-00061820: 7229 272c 2073 656c 6629 0a0a 2020 2020 r)', self).. \n-00061830: 2020 2020 2320 7265 6164 2061 6e79 2072 # read any r\n-00061840: 6573 6964 7561 6c20 6461 7461 206f 6e20 esidual data on \n-00061850: 7374 6465 7272 2c20 6275 7420 646f 6e27 stderr, but don'\n-00061860: 7420 7072 6f63 6573 7320 636f 6d6d 616e t process comman\n-00061870: 6473 2c20 616e 640a 2020 2020 2020 2020 ds, and. \n-00061880: 2320 646f 6e27 7420 626c 6f63 6b0a 2020 # don't block. \n-00061890: 2020 2020 2020 7472 793a 0a20 2020 2020 try:. \n-000618a0: 2020 2020 2020 2069 6620 7365 6c66 2e5f if self._\n-000618b0: 6f75 7273 2e66 696c 656e 6f28 2920 213d ours.fileno() !=\n-000618c0: 202d 313a 0a20 2020 2020 2020 2020 2020 -1:. \n-000618d0: 2020 2020 206c 6f67 6765 722e 6465 6275 logger.debu\n-000618e0: 6728 2720 2064 7261 696e 696e 6720 7065 g(' draining pe\n-000618f0: 6e64 696e 6720 7374 6465 7272 2064 6174 nding stderr dat\n-00061900: 6120 286e 6f6e 2d62 6c6f 636b 696e 6729 a (non-blocking)\n-00061910: 2729 0a20 2020 2020 2020 2020 2020 2020 '). \n-00061920: 2020 2077 6974 6820 636f 6e74 6578 746c with contextl\n-00061930: 6962 2e73 7570 7072 6573 7328 426c 6f63 ib.suppress(Bloc\n-00061940: 6b69 6e67 494f 4572 726f 7229 3a0a 2020 kingIOError):. \n-00061950: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00061960: 2020 7768 696c 6520 5472 7565 3a0a 2020 while True:. \n-00061970: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00061980: 2020 2020 2020 6461 7461 203d 2073 656c data = sel\n-00061990: 662e 5f6f 7572 732e 7265 6376 2834 3039 f._ours.recv(409\n-000619a0: 362c 2073 6f63 6b65 742e 4d53 475f 444f 6, socket.MSG_DO\n-000619b0: 4e54 5741 4954 290a 2020 2020 2020 2020 NTWAIT). \n-000619c0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000619d0: 6c6f 6767 6572 2e64 6562 7567 2827 2020 logger.debug(' \n-000619e0: 2020 676f 7420 2564 2062 7974 6573 272c got %d bytes',\n-000619f0: 206c 656e 2864 6174 6129 290a 2020 2020 len(data)). \n-00061a00: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00061a10: 2020 2020 6966 206e 6f74 2064 6174 613a if not data:\n-00061a20: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-00061a30: 2020 2020 2020 2020 2020 2020 2062 7265 bre\n-00061a40: 616b 0a20 2020 2020 2020 2020 2020 2020 ak. \n-00061a50: 2020 2020 2020 2020 2020 2073 656c 662e self.\n-00061a60: 5f62 7566 6665 722e 6578 7465 6e64 2864 _buffer.extend(d\n-00061a70: 6174 6129 0a20 2020 2020 2020 2065 7863 ata). exc\n-00061a80: 6570 7420 4f53 4572 726f 7220 6173 2065 ept OSError as e\n-00061a90: 7863 3a0a 2020 2020 2020 2020 2020 2020 xc:. \n-00061aa0: 7365 6c66 2e5f 7265 7375 6c74 2865 7863 self._result(exc\n-00061ab0: 290a 2020 2020 2020 2020 656c 7365 3a0a ). else:.\n-00061ac0: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n-00061ad0: 2e5f 7265 7375 6c74 2873 656c 662e 5f62 ._result(self._b\n-00061ae0: 7566 6665 722e 6465 636f 6465 2865 7272 uffer.decode(err\n-00061af0: 6f72 733d 2772 6570 6c61 6365 2729 290a ors='replace')).\n-00061b00: 0a20 2020 2061 7379 6e63 2064 6566 2063 . async def c\n-00061b10: 6f6d 6d75 6e69 6361 7465 2873 656c 6629 ommunicate(self)\n-00061b20: 202d 3e20 4e6f 6e65 3a0a 2020 2020 2020 -> None:. \n-00061b30: 2020 6c6f 6767 6572 2e64 6562 7567 2827 logger.debug('\n-00061b40: 5f63 6f6d 6d75 6e69 6361 7465 2825 7229 _communicate(%r)\n-00061b50: 272c 2073 656c 6629 0a20 2020 2020 2020 ', self). \n-00061b60: 2074 7279 3a0a 2020 2020 2020 2020 2020 try:. \n-00061b70: 2020 7365 6c66 2e73 7461 7274 2829 0a20 self.start(). \n-00061b80: 2020 2020 2020 2020 2020 2023 2057 6520 # We \n-00061b90: 6173 7375 6d65 2074 6861 7420 7765 2061 assume that we a\n-00061ba0: 7265 2074 6865 206f 6e6c 7920 6f6e 6573 re the only ones\n-00061bb0: 2074 6f20 7772 6974 6520 746f 0a20 2020 to write to. \n-00061bc0: 2020 2020 2020 2020 2023 2073 656c 662e # self.\n-00061bd0: 5f63 6f6d 706c 6574 696f 6e5f 6675 7475 _completion_futu\n-00061be0: 7265 2e20 2049 6620 7765 2064 6972 6563 re. If we direc\n-00061bf0: 746c 7920 6177 6169 7420 6974 2c20 7468 tly await it, th\n-00061c00: 6f75 6768 2c20 6974 2063 616e 0a20 2020 ough, it can. \n-00061c10: 2020 2020 2020 2020 2023 2061 6c73 6f20 # also \n-00061c20: 6861 7665 2061 2061 7379 6e63 696f 2e43 have a asyncio.C\n-00061c30: 616e 6365 6c6c 6564 4572 726f 7220 706f ancelledError po\n-00061c40: 7374 6564 2074 6f20 6974 2066 726f 6d20 sted to it from \n-00061c50: 6f75 7473 6964 652e 0a20 2020 2020 2020 outside.. \n-00061c60: 2020 2020 2023 2053 6869 656c 6420 6974 # Shield it\n-00061c70: 2074 6f20 7072 6576 656e 7420 7468 6174 to prevent that\n-00061c80: 2066 726f 6d20 6861 7070 656e 696e 672e from happening.\n-00061c90: 0a20 2020 2020 2020 2020 2020 2073 7464 . std\n-00061ca0: 6572 7220 3d20 6177 6169 7420 6173 796e err = await asyn\n-00061cb0: 6369 6f2e 7368 6965 6c64 2873 656c 662e cio.shield(self.\n-00061cc0: 5f63 6f6d 706c 6574 696f 6e5f 6675 7475 _completion_futu\n-00061cd0: 7265 290a 2020 2020 2020 2020 2020 2020 re). \n-00061ce0: 6c6f 6767 6572 2e64 6562 7567 2827 5f63 logger.debug('_c\n-00061cf0: 6f6d 6d75 6e69 6361 7465 2825 7229 2073 ommunicate(%r) s\n-00061d00: 7464 6572 7220 7265 7375 6c74 2069 7320 tderr result is \n-00061d10: 2572 272c 2073 656c 662c 2073 7464 6572 %r', self, stder\n-00061d20: 7229 0a20 2020 2020 2020 2066 696e 616c r). final\n-00061d30: 6c79 3a0a 2020 2020 2020 2020 2020 2020 ly:. \n-00061d40: 6c6f 6767 6572 2e64 6562 7567 2827 5f63 logger.debug('_c\n-00061d50: 6f6d 6d75 6e69 6361 7465 2066 696e 6973 ommunicate finis\n-00061d60: 6865 642e 2020 456e 7375 7269 6e67 2063 hed. Ensuring c\n-00061d70: 6f6d 706c 6574 696f 6e2e 2729 0a20 2020 ompletion.'). \n-00061d80: 2020 2020 2020 2020 2073 656c 662e 666f self.fo\n-00061d90: 7263 655f 636f 6d70 6c65 7469 6f6e 2829 rce_completion()\n-00061da0: 0a20 2020 2020 2020 2069 6620 6e6f 7420 . if not \n-00061db0: 7365 6c66 2e5f 656e 643a 0a20 2020 2020 self._end:. \n-00061dc0: 2020 2020 2020 206c 6f67 6765 722e 6465 logger.de\n-00061dd0: 6275 6728 275f 636f 6d6d 756e 6963 6174 bug('_communicat\n-00061de0: 6520 6e65 7665 7220 7361 7720 6665 726e e never saw fern\n-00061df0: 792e 656e 642e 2020 7261 6973 696e 6720 y.end. raising \n-00061e00: 496e 7465 7261 6374 696f 6e45 7272 6f72 InteractionError\n-00061e10: 2e27 290a 2020 2020 2020 2020 2020 2020 .'). \n-00061e20: 7261 6973 6520 496e 7465 7261 6374 696f raise Interactio\n-00061e30: 6e45 7272 6f72 2873 7464 6572 722e 7374 nError(stderr.st\n-00061e40: 7269 7028 2929 0a0a 0a64 6566 2077 7269 rip())...def wri\n-00061e50: 7465 5f61 736b 7061 7373 5f74 6f5f 746d te_askpass_to_tm\n-00061e60: 7064 6972 2874 6d70 6469 723a 2073 7472 pdir(tmpdir: str\n-00061e70: 2920 2d3e 2073 7472 3a0a 2020 2020 6173 ) -> str:. as\n-00061e80: 6b70 6173 735f 7061 7468 203d 206f 732e kpass_path = os.\n-00061e90: 7061 7468 2e6a 6f69 6e28 746d 7064 6972 path.join(tmpdir\n-00061ea0: 2c20 2766 6572 6e79 2d61 736b 7061 7373 , 'ferny-askpass\n-00061eb0: 2729 0a20 2020 2066 6420 3d20 6f73 2e6f '). fd = os.o\n-00061ec0: 7065 6e28 6173 6b70 6173 735f 7061 7468 pen(askpass_path\n-00061ed0: 2c20 6f73 2e4f 5f43 5245 4154 207c 206f , os.O_CREAT | o\n-00061ee0: 732e 4f5f 5752 4f4e 4c59 207c 206f 732e s.O_WRONLY | os.\n-00061ef0: 4f5f 434c 4f45 5845 4320 7c20 6f73 2e4f O_CLOEXEC | os.O\n-00061f00: 5f45 5843 4c20 7c20 6f73 2e4f 5f4e 4f46 _EXCL | os.O_NOF\n-00061f10: 4f4c 4c4f 572c 2030 6f37 3737 290a 2020 OLLOW, 0o777). \n-00061f20: 2020 7472 793a 0a20 2020 2020 2020 206f try:. o\n-00061f30: 732e 7772 6974 6528 6664 2c20 5f5f 6c6f s.write(fd, __lo\n-00061f40: 6164 6572 5f5f 2e67 6574 5f64 6174 6128 ader__.get_data(\n-00061f50: 696e 7465 7261 6374 696f 6e5f 636c 6965 interaction_clie\n-00061f60: 6e74 2e5f 5f66 696c 655f 5f29 2920 2023 nt.__file__)) #\n-00061f70: 2074 7970 653a 2069 676e 6f72 650a 2020 type: ignore. \n-00061f80: 2020 6669 6e61 6c6c 793a 0a20 2020 2020 finally:. \n-00061f90: 2020 206f 732e 636c 6f73 6528 6664 290a os.close(fd).\n-00061fa0: 2020 2020 7265 7475 726e 2061 736b 7061 return askpa\n-00061fb0: 7373 5f70 6174 680a 0a0a 4063 6f6e 7465 ss_path...@conte\n-00061fc0: 7874 6c69 622e 636f 6e74 6578 746d 616e xtlib.contextman\n-00061fd0: 6167 6572 0a64 6566 2074 656d 706f 7261 ager.def tempora\n-00061fe0: 7279 5f61 736b 7061 7373 282a 2a6b 7761 ry_askpass(**kwa\n-00061ff0: 7267 733a 2041 6e79 2920 2d3e 2047 656e rgs: Any) -> Gen\n-00062000: 6572 6174 6f72 5b73 7472 2c20 4e6f 6e65 erator[str, None\n-00062010: 2c20 4e6f 6e65 5d3a 0a20 2020 2077 6974 , None]:. wit\n-00062020: 6820 7465 6d70 6669 6c65 2e54 656d 706f h tempfile.Tempo\n-00062030: 7261 7279 4469 7265 6374 6f72 7928 2a2a raryDirectory(**\n-00062040: 6b77 6172 6773 2920 6173 2064 6972 6563 kwargs) as direc\n-00062050: 746f 7279 3a0a 2020 2020 2020 2020 7969 tory:. yi\n-00062060: 656c 6420 7772 6974 655f 6173 6b70 6173 eld write_askpas\n-00062070: 735f 746f 5f74 6d70 6469 7228 6469 7265 s_to_tmpdir(dire\n-00062080: 6374 6f72 7929 0a27 2727 2e65 6e63 6f64 ctory).'''.encod\n-00062090: 6528 2775 7466 2d38 2729 2c0a 2020 2763 e('utf-8'),. 'c\n-000620a0: 6f63 6b70 6974 2f5f 7665 6e64 6f72 2f66 ockpit/_vendor/f\n-000620b0: 6572 6e79 2f70 792e 7479 7065 6427 3a20 erny/py.typed': \n-000620c0: 6272 2727 2727 2727 2c0a 2020 2763 6f63 br'''''',. 'coc\n-000620d0: 6b70 6974 2f5f 7665 6e64 6f72 2f62 6569 kpit/_vendor/bei\n-000620e0: 2f62 6569 626f 6f74 2e70 7927 3a20 6272 /beiboot.py': br\n-000620f0: 2222 2223 2062 6569 626f 6f74 202d 2052 \"\"\"# beiboot - R\n-00062100: 656d 6f74 6520 626f 6f74 6c6f 6164 6572 emote bootloader\n-00062110: 2066 6f72 2050 7974 686f 6e0a 230a 2320 for Python.#.# \n-00062120: 436f 7079 7269 6768 7420 2843 2920 3230 Copyright (C) 20\n-00062130: 3232 2041 6c6c 6973 6f6e 204b 6172 6c69 22 Allison Karli\n-00062140: 7473 6b61 7961 203c 616c 6c69 736f 6e2e tskaya <allison.\n-00062150: 6b61 726c 6974 736b 6179 6140 7265 6468 karlitskaya@redh\n-00062160: 6174 2e63 6f6d 3e0a 230a 2320 5468 6973 at.com>.#.# This\n-00062170: 2070 726f 6772 616d 2069 7320 6672 6565 program is free\n-00062180: 2073 6f66 7477 6172 653a 2079 6f75 2063 software: you c\n-00062190: 616e 2072 6564 6973 7472 6962 7574 6520 an redistribute \n-000621a0: 6974 2061 6e64 2f6f 7220 6d6f 6469 6679 it and/or modify\n-000621b0: 0a23 2069 7420 756e 6465 7220 7468 6520 .# it under the \n-000621c0: 7465 726d 7320 6f66 2074 6865 2047 4e55 terms of the GNU\n-000621d0: 2047 656e 6572 616c 2050 7562 6c69 6320 General Public \n-000621e0: 4c69 6365 6e73 6520 6173 2070 7562 6c69 License as publi\n-000621f0: 7368 6564 2062 790a 2320 7468 6520 4672 shed by.# the Fr\n-00062200: 6565 2053 6f66 7477 6172 6520 466f 756e ee Software Foun\n-00062210: 6461 7469 6f6e 2c20 6569 7468 6572 2076 dation, either v\n-00062220: 6572 7369 6f6e 2033 206f 6620 7468 6520 ersion 3 of the \n-00062230: 4c69 6365 6e73 652c 206f 720a 2320 2861 License, or.# (a\n-00062240: 7420 796f 7572 206f 7074 696f 6e29 2061 t your option) a\n-00062250: 6e79 206c 6174 6572 2076 6572 7369 6f6e ny later version\n-00062260: 2e0a 230a 2320 5468 6973 2070 726f 6772 ..#.# This progr\n-00062270: 616d 2069 7320 6469 7374 7269 6275 7465 am is distribute\n-00062280: 6420 696e 2074 6865 2068 6f70 6520 7468 d in the hope th\n-00062290: 6174 2069 7420 7769 6c6c 2062 6520 7573 at it will be us\n-000622a0: 6566 756c 2c0a 2320 6275 7420 5749 5448 eful,.# but WITH\n-000622b0: 4f55 5420 414e 5920 5741 5252 414e 5459 OUT ANY WARRANTY\n-000622c0: 3b20 7769 7468 6f75 7420 6576 656e 2074 ; without even t\n-000622d0: 6865 2069 6d70 6c69 6564 2077 6172 7261 he implied warra\n-000622e0: 6e74 7920 6f66 0a23 204d 4552 4348 414e nty of.# MERCHAN\n-000622f0: 5441 4249 4c49 5459 206f 7220 4649 544e TABILITY or FITN\n-00062300: 4553 5320 464f 5220 4120 5041 5254 4943 ESS FOR A PARTIC\n-00062310: 554c 4152 2050 5552 504f 5345 2e20 2053 ULAR PURPOSE. S\n-00062320: 6565 2074 6865 0a23 2047 4e55 2047 656e ee the.# GNU Gen\n-00062330: 6572 616c 2050 7562 6c69 6320 4c69 6365 eral Public Lice\n-00062340: 6e73 6520 666f 7220 6d6f 7265 2064 6574 nse for more det\n-00062350: 6169 6c73 2e0a 230a 2320 596f 7520 7368 ails..#.# You sh\n-00062360: 6f75 6c64 2068 6176 6520 7265 6365 6976 ould have receiv\n-00062370: 6564 2061 2063 6f70 7920 6f66 2074 6865 ed a copy of the\n-00062380: 2047 4e55 2047 656e 6572 616c 2050 7562 GNU General Pub\n-00062390: 6c69 6320 4c69 6365 6e73 650a 2320 616c lic License.# al\n-000623a0: 6f6e 6720 7769 7468 2074 6869 7320 7072 ong with this pr\n-000623b0: 6f67 7261 6d2e 2020 4966 206e 6f74 2c20 ogram. If not, \n-000623c0: 7365 6520 3c68 7474 703a 2f2f 7777 772e see <http://www.\n-000623d0: 676e 752e 6f72 672f 6c69 6365 6e73 6573 gnu.org/licenses\n-000623e0: 2f3e 2e0a 0a69 6d70 6f72 7420 6172 6770 />...import argp\n-000623f0: 6172 7365 0a69 6d70 6f72 7420 6173 796e arse.import asyn\n-00062400: 6369 6f0a 696d 706f 7274 206f 730a 696d cio.import os.im\n-00062410: 706f 7274 2073 686c 6578 0a69 6d70 6f72 port shlex.impor\n-00062420: 7420 7375 6270 726f 6365 7373 0a69 6d70 t subprocess.imp\n-00062430: 6f72 7420 7379 730a 696d 706f 7274 2074 ort sys.import t\n-00062440: 6872 6561 6469 6e67 0a66 726f 6d20 7479 hreading.from ty\n-00062450: 7069 6e67 2069 6d70 6f72 7420 494f 2c20 ping import IO, \n-00062460: 4c69 7374 2c20 5365 7175 656e 6365 2c20 List, Sequence, \n-00062470: 5475 706c 650a 0a66 726f 6d20 2e62 6f6f Tuple..from .boo\n-00062480: 746c 6f61 6465 7220 696d 706f 7274 206d tloader import m\n-00062490: 616b 655f 626f 6f74 6c6f 6164 6572 0a0a ake_bootloader..\n-000624a0: 0a64 6566 2067 6574 5f70 7974 686f 6e5f .def get_python_\n-000624b0: 636f 6d6d 616e 6428 6c6f 6361 6c3a 2062 command(local: b\n-000624c0: 6f6f 6c20 3d20 4661 6c73 652c 0a20 2020 ool = False,. \n-000624d0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000624e0: 2020 2020 7474 793a 2062 6f6f 6c20 3d20 tty: bool = \n-000624f0: 4661 6c73 652c 0a20 2020 2020 2020 2020 False,. \n-00062500: 2020 2020 2020 2020 2020 2020 2020 7368 sh\n-00062510: 3a20 626f 6f6c 203d 2046 616c 7365 2920 : bool = False) \n-00062520: 2d3e 2053 6571 7565 6e63 655b 7374 725d -> Sequence[str]\n-00062530: 3a0a 2020 2020 696e 7465 7270 7265 7465 :. interprete\n-00062540: 7220 3d20 7379 732e 6578 6563 7574 6162 r = sys.executab\n-00062550: 6c65 2069 6620 6c6f 6361 6c20 656c 7365 le if local else\n-00062560: 2027 7079 7468 6f6e 3327 0a20 2020 2063 'python3'. c\n-00062570: 6f6d 6d61 6e64 3a20 5365 7175 656e 6365 ommand: Sequence\n-00062580: 5b73 7472 5d0a 0a20 2020 2069 6620 7474 [str].. if tt\n-00062590: 793a 0a20 2020 2020 2020 2063 6f6d 6d61 y:. comma\n-000625a0: 6e64 203d 2028 696e 7465 7270 7265 7465 nd = (interprete\n-000625b0: 722c 2027 2d69 7127 290a 2020 2020 656c r, '-iq'). el\n-000625c0: 7365 3a0a 2020 2020 2020 2020 636f 6d6d se:. comm\n-000625d0: 616e 6420 3d20 280a 2020 2020 2020 2020 and = (. \n-000625e0: 2020 2020 696e 7465 7270 7265 7465 722c interpreter,\n-000625f0: 2027 2d69 6327 2c0a 2020 2020 2020 2020 '-ic',. \n-00062600: 2020 2020 2320 6874 7470 733a 2f2f 6769 # https://gi\n-00062610: 7468 7562 2e63 6f6d 2f70 7974 686f 6e2f thub.com/python/\n-00062620: 6370 7974 686f 6e2f 6973 7375 6573 2f39 cpython/issues/9\n-00062630: 3331 3339 0a20 2020 2020 2020 2020 2020 3139. \n-00062640: 2027 2727 2220 2d20 6265 6962 6f6f 7420 '''\" - beiboot \n-00062650: 2d20 223b 2069 6d70 6f72 7420 7379 733b - \"; import sys;\n-00062660: 2073 7973 2e70 7331 203d 2027 273b 2073 sys.ps1 = ''; s\n-00062670: 7973 2e70 7332 203d 2027 273b 2727 270a ys.ps2 = '';'''.\n-00062680: 2020 2020 2020 2020 290a 0a20 2020 2069 ).. i\n-00062690: 6620 7368 3a0a 2020 2020 2020 2020 636f f sh:. co\n-000626a0: 6d6d 616e 6420 3d20 2827 2027 2e6a 6f69 mmand = (' '.joi\n-000626b0: 6e28 7368 6c65 782e 7175 6f74 6528 6172 n(shlex.quote(ar\n-000626c0: 6729 2066 6f72 2061 7267 2069 6e20 636f g) for arg in co\n-000626d0: 6d6d 616e 6429 2c29 0a0a 2020 2020 7265 mmand),).. re\n-000626e0: 7475 726e 2063 6f6d 6d61 6e64 0a0a 0a64 turn command...d\n-000626f0: 6566 2067 6574 5f73 7368 5f63 6f6d 6d61 ef get_ssh_comma\n-00062700: 6e64 282a 6172 6773 3a20 7374 722c 2074 nd(*args: str, t\n-00062710: 7479 3a20 626f 6f6c 203d 2046 616c 7365 ty: bool = False\n-00062720: 2920 2d3e 2053 6571 7565 6e63 655b 7374 ) -> Sequence[st\n-00062730: 725d 3a0a 2020 2020 7265 7475 726e 2028 r]:. return (\n-00062740: 2773 7368 272c 0a20 2020 2020 2020 2020 'ssh',. \n-00062750: 2020 202a 285b 272d 7427 5d20 6966 2074 *(['-t'] if t\n-00062760: 7479 2065 6c73 6520 2829 292c 0a20 2020 ty else ()),. \n-00062770: 2020 2020 2020 2020 202a 6172 6773 2c0a *args,.\n-00062780: 2020 2020 2020 2020 2020 2020 2a67 6574 *get\n-00062790: 5f70 7974 686f 6e5f 636f 6d6d 616e 6428 _python_command(\n-000627a0: 7474 793d 7474 792c 2073 683d 5472 7565 tty=tty, sh=True\n-000627b0: 2929 0a0a 0a64 6566 2067 6574 5f63 6f6e ))...def get_con\n-000627c0: 7461 696e 6572 5f63 6f6d 6d61 6e64 282a tainer_command(*\n-000627d0: 6172 6773 3a20 7374 722c 2074 7479 3a20 args: str, tty: \n-000627e0: 626f 6f6c 203d 2046 616c 7365 2920 2d3e bool = False) ->\n-000627f0: 2053 6571 7565 6e63 655b 7374 725d 3a0a Sequence[str]:.\n-00062800: 2020 2020 7265 7475 726e 2028 2770 6f64 return ('pod\n-00062810: 6d61 6e27 2c20 2765 7865 6327 2c20 272d man', 'exec', '-\n-00062820: 2d69 6e74 6572 6163 7469 7665 272c 0a20 -interactive',. \n-00062830: 2020 2020 2020 2020 2020 202a 285b 272d *(['-\n-00062840: 2d74 7479 275d 2069 6620 7474 7920 656c -tty'] if tty el\n-00062850: 7365 2028 2929 2c0a 2020 2020 2020 2020 se ()),. \n-00062860: 2020 2020 2a61 7267 732c 0a20 2020 2020 *args,. \n-00062870: 2020 2020 2020 202a 6765 745f 7079 7468 *get_pyth\n-00062880: 6f6e 5f63 6f6d 6d61 6e64 2874 7479 3d74 on_command(tty=t\n-00062890: 7479 2929 0a0a 0a64 6566 2067 6574 5f63 ty))...def get_c\n-000628a0: 6f6d 6d61 6e64 282a 6172 6773 3a20 7374 ommand(*args: st\n-000628b0: 722c 2074 7479 3a20 626f 6f6c 203d 2046 r, tty: bool = F\n-000628c0: 616c 7365 2c20 7368 3a20 626f 6f6c 203d alse, sh: bool =\n-000628d0: 2046 616c 7365 2920 2d3e 2053 6571 7565 False) -> Seque\n-000628e0: 6e63 655b 7374 725d 3a0a 2020 2020 7265 nce[str]:. re\n-000628f0: 7475 726e 2028 2a61 7267 732c 202a 6765 turn (*args, *ge\n-00062900: 745f 7079 7468 6f6e 5f63 6f6d 6d61 6e64 t_python_command\n-00062910: 286c 6f63 616c 3d54 7275 652c 2074 7479 (local=True, tty\n-00062920: 3d74 7479 2c20 7368 3d73 6829 290a 0a0a =tty, sh=sh))...\n-00062930: 6465 6620 7370 6c69 6365 5f69 6e5f 7468 def splice_in_th\n-00062940: 7265 6164 2873 7263 3a20 696e 742c 2064 read(src: int, d\n-00062950: 7374 3a20 494f 5b62 7974 6573 5d29 202d st: IO[bytes]) -\n-00062960: 3e20 4e6f 6e65 3a0a 2020 2020 6465 6620 > None:. def \n-00062970: 5f74 6872 6561 6428 2920 2d3e 204e 6f6e _thread() -> Non\n-00062980: 653a 0a20 2020 2020 2020 2023 206f 732e e:. # os.\n-00062990: 7370 6c69 6365 2829 206f 6e6c 7920 696e splice() only in\n-000629a0: 2050 7974 686f 6e20 332e 3130 0a20 2020 Python 3.10. \n-000629b0: 2020 2020 2077 6974 6820 6473 743a 0a20 with dst:. \n-000629c0: 2020 2020 2020 2020 2020 2062 6c6f 636b block\n-000629d0: 5f73 697a 6520 3d20 3120 3c3c 2032 300a _size = 1 << 20.\n-000629e0: 2020 2020 2020 2020 2020 2020 7768 696c whil\n-000629f0: 6520 5472 7565 3a0a 2020 2020 2020 2020 e True:. \n-00062a00: 2020 2020 2020 2020 6461 7461 203d 206f data = o\n-00062a10: 732e 7265 6164 2873 7263 2c20 626c 6f63 s.read(src, bloc\n-00062a20: 6b5f 7369 7a65 290a 2020 2020 2020 2020 k_size). \n-00062a30: 2020 2020 2020 2020 6966 206e 6f74 2064 if not d\n-00062a40: 6174 613a 0a20 2020 2020 2020 2020 2020 ata:. \n-00062a50: 2020 2020 2020 2020 2062 7265 616b 0a20 break. \n-00062a60: 2020 2020 2020 2020 2020 2020 2020 2064 d\n-00062a70: 7374 2e77 7269 7465 2864 6174 6129 0a20 st.write(data). \n-00062a80: 2020 2020 2020 2020 2020 2020 2020 2064 d\n-00062a90: 7374 2e66 6c75 7368 2829 0a0a 2020 2020 st.flush().. \n-00062aa0: 7468 7265 6164 696e 672e 5468 7265 6164 threading.Thread\n-00062ab0: 2874 6172 6765 743d 5f74 6872 6561 642c (target=_thread,\n-00062ac0: 2064 6165 6d6f 6e3d 5472 7565 292e 7374 daemon=True).st\n-00062ad0: 6172 7428 290a 0a0a 6465 6620 7365 6e64 art()...def send\n-00062ae0: 5f61 6e64 5f73 706c 6963 6528 636f 6d6d _and_splice(comm\n-00062af0: 616e 643a 2053 6571 7565 6e63 655b 7374 and: Sequence[st\n-00062b00: 725d 2c20 7363 7269 7074 3a20 6279 7465 r], script: byte\n-00062b10: 7329 202d 3e20 4e6f 6e65 3a0a 2020 2020 s) -> None:. \n-00062b20: 7769 7468 2073 7562 7072 6f63 6573 732e with subprocess.\n-00062b30: 506f 7065 6e28 636f 6d6d 616e 642c 2073 Popen(command, s\n-00062b40: 7464 696e 3d73 7562 7072 6f63 6573 732e tdin=subprocess.\n-00062b50: 5049 5045 2920 6173 2070 726f 633a 0a20 PIPE) as proc:. \n-00062b60: 2020 2020 2020 2061 7373 6572 7420 7072 assert pr\n-00062b70: 6f63 2e73 7464 696e 2069 7320 6e6f 7420 oc.stdin is not \n-00062b80: 4e6f 6e65 0a20 2020 2020 2020 2070 726f None. pro\n-00062b90: 632e 7374 6469 6e2e 7772 6974 6528 7363 c.stdin.write(sc\n-00062ba0: 7269 7074 290a 0a20 2020 2020 2020 2073 ript).. s\n-00062bb0: 706c 6963 655f 696e 5f74 6872 6561 6428 plice_in_thread(\n-00062bc0: 302c 2070 726f 632e 7374 6469 6e29 0a20 0, proc.stdin). \n-00062bd0: 2020 2020 2020 2073 7973 2e65 7869 7428 sys.exit(\n-00062be0: 7072 6f63 2e77 6169 7428 2929 0a0a 0a64 proc.wait())...d\n-00062bf0: 6566 2073 656e 645f 787a 5f61 6e64 5f73 ef send_xz_and_s\n-00062c00: 706c 6963 6528 636f 6d6d 616e 643a 2053 plice(command: S\n-00062c10: 6571 7565 6e63 655b 7374 725d 2c20 7363 equence[str], sc\n-00062c20: 7269 7074 3a20 6279 7465 7329 202d 3e20 ript: bytes) -> \n-00062c30: 4e6f 6e65 3a0a 2020 2020 696d 706f 7274 None:. import\n-00062c40: 2066 6572 6e79 0a0a 2020 2020 636c 6173 ferny.. clas\n-00062c50: 7320 5265 7370 6f6e 6465 7228 6665 726e s Responder(fern\n-00062c60: 792e 496e 7465 7261 6374 696f 6e52 6573 y.InteractionRes\n-00062c70: 706f 6e64 6572 293a 0a20 2020 2020 2020 ponder):. \n-00062c80: 2061 7379 6e63 2064 6566 2064 6f5f 6375 async def do_cu\n-00062c90: 7374 6f6d 5f63 6f6d 6d61 6e64 2873 656c stom_command(sel\n-00062ca0: 662c 0a20 2020 2020 2020 2020 2020 2020 f,. \n-00062cb0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00062cc0: 2020 2020 2020 2063 6f6d 6d61 6e64 3a20 command: \n-00062cd0: 7374 722c 0a20 2020 2020 2020 2020 2020 str,. \n-00062ce0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00062cf0: 2020 2020 2020 2020 2061 7267 733a 2054 args: T\n-00062d00: 7570 6c65 2c0a 2020 2020 2020 2020 2020 uple,. \n-00062d10: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00062d20: 2020 2020 2020 2020 2020 6664 733a 204c fds: L\n-00062d30: 6973 745b 696e 745d 2c0a 2020 2020 2020 ist[int],. \n-00062d40: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00062d50: 2020 2020 2020 2020 2020 2020 2020 7374 st\n-00062d60: 6465 7272 3a20 7374 7229 202d 3e20 4e6f derr: str) -> No\n-00062d70: 6e65 3a0a 2020 2020 2020 2020 2020 2020 ne:. \n-00062d80: 6173 7365 7274 2070 726f 632e 7374 6469 assert proc.stdi\n-00062d90: 6e20 6973 206e 6f74 204e 6f6e 650a 2020 n is not None. \n-00062da0: 2020 2020 2020 2020 2020 6966 2063 6f6d if com\n-00062db0: 6d61 6e64 203d 3d20 2762 6569 626f 6f74 mand == 'beiboot\n-00062dc0: 2e70 726f 7669 6465 273a 0a20 2020 2020 .provide':. \n-00062dd0: 2020 2020 2020 2020 2020 2070 726f 632e proc.\n-00062de0: 7374 6469 6e2e 7772 6974 6528 7363 7269 stdin.write(scri\n-00062df0: 7074 290a 2020 2020 2020 2020 2020 2020 pt). \n-00062e00: 2020 2020 7072 6f63 2e73 7464 696e 2e66 proc.stdin.f\n-00062e10: 6c75 7368 2829 0a0a 2020 2020 6167 656e lush().. agen\n-00062e20: 7420 3d20 6665 726e 792e 496e 7465 7261 t = ferny.Intera\n-00062e30: 6374 696f 6e41 6765 6e74 2852 6573 706f ctionAgent(Respo\n-00062e40: 6e64 6572 2829 290a 2020 2020 7769 7468 nder()). with\n-00062e50: 2073 7562 7072 6f63 6573 732e 506f 7065 subprocess.Pope\n-00062e60: 6e28 636f 6d6d 616e 642c 2073 7464 696e n(command, stdin\n-00062e70: 3d73 7562 7072 6f63 6573 732e 5049 5045 =subprocess.PIPE\n-00062e80: 2c20 7374 6465 7272 3d61 6765 6e74 2920 , stderr=agent) \n-00062e90: 6173 2070 726f 633a 0a20 2020 2020 2020 as proc:. \n-00062ea0: 2061 7373 6572 7420 7072 6f63 2e73 7464 assert proc.std\n-00062eb0: 696e 2069 7320 6e6f 7420 4e6f 6e65 0a20 in is not None. \n-00062ec0: 2020 2020 2020 2070 726f 632e 7374 6469 proc.stdi\n-00062ed0: 6e2e 7772 6974 6528 6d61 6b65 5f62 6f6f n.write(make_boo\n-00062ee0: 746c 6f61 6465 7228 5b0a 2020 2020 2020 tloader([. \n-00062ef0: 2020 2020 2020 2827 626f 6f74 5f78 7a27 ('boot_xz'\n-00062f00: 2c20 2827 7363 7269 7074 2e70 792e 787a , ('script.py.xz\n-00062f10: 272c 206c 656e 2873 6372 6970 7429 2c20 ', len(script), \n-00062f20: 5b5d 2c20 5472 7565 2929 2c0a 2020 2020 [], True)),. \n-00062f30: 2020 2020 5d2c 2067 6164 6765 7473 3d66 ], gadgets=f\n-00062f40: 6572 6e79 2e42 4549 424f 4f54 5f47 4144 erny.BEIBOOT_GAD\n-00062f50: 4745 5453 292e 656e 636f 6465 2829 290a GETS).encode()).\n-00062f60: 2020 2020 2020 2020 7072 6f63 2e73 7464 proc.std\n-00062f70: 696e 2e66 6c75 7368 2829 0a0a 2020 2020 in.flush().. \n-00062f80: 2020 2020 6173 796e 6369 6f2e 7275 6e28 asyncio.run(\n-00062f90: 6167 656e 742e 636f 6d6d 756e 6963 6174 agent.communicat\n-00062fa0: 6528 2929 0a20 2020 2020 2020 2073 706c e()). spl\n-00062fb0: 6963 655f 696e 5f74 6872 6561 6428 302c ice_in_thread(0,\n-00062fc0: 2070 726f 632e 7374 6469 6e29 0a20 2020 proc.stdin). \n-00062fd0: 2020 2020 2073 7973 2e65 7869 7428 7072 sys.exit(pr\n-00062fe0: 6f63 2e77 6169 7428 2929 0a0a 0a64 6566 oc.wait())...def\n-00062ff0: 206d 6169 6e28 2920 2d3e 204e 6f6e 653a main() -> None:\n-00063000: 0a20 2020 2070 6172 7365 7220 3d20 6172 . parser = ar\n-00063010: 6770 6172 7365 2e41 7267 756d 656e 7450 gparse.ArgumentP\n-00063020: 6172 7365 7228 290a 2020 2020 7061 7273 arser(). pars\n-00063030: 6572 2e61 6464 5f61 7267 756d 656e 7428 er.add_argument(\n-00063040: 272d 2d73 6827 2c20 6163 7469 6f6e 3d27 '--sh', action='\n-00063050: 7374 6f72 655f 7472 7565 272c 0a20 2020 store_true',. \n-00063060: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00063070: 2020 2020 2068 656c 703d 2750 6173 7320 help='Pass \n-00063080: 5079 7468 6f6e 2069 6e74 6572 7072 6574 Python interpret\n-00063090: 6572 2063 6f6d 6d61 6e64 2061 7320 7368 er command as sh\n-000630a0: 656c 6c2d 7363 7269 7074 2729 0a20 2020 ell-script'). \n-000630b0: 2070 6172 7365 722e 6164 645f 6172 6775 parser.add_argu\n-000630c0: 6d65 6e74 2827 2d2d 787a 272c 2068 656c ment('--xz', hel\n-000630d0: 703d 2274 6865 2078 7a20 746f 2072 756e p=\"the xz to run\n-000630e0: 2072 656d 6f74 656c 7922 290a 2020 2020 remotely\"). \n-000630f0: 7061 7273 6572 2e61 6464 5f61 7267 756d parser.add_argum\n-00063100: 656e 7428 272d 2d73 6372 6970 7427 2c0a ent('--script',.\n-00063110: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00063120: 2020 2020 2020 2020 6865 6c70 3d22 7468 help=\"th\n-00063130: 6520 7363 7269 7074 2074 6f20 7275 6e20 e script to run \n-00063140: 7265 6d6f 7465 6c79 2028 6d75 7374 2062 remotely (must b\n-00063150: 6520 7265 706c 2d66 7269 656e 646c 7929 e repl-friendly)\n-00063160: 2229 0a20 2020 2070 6172 7365 722e 6164 \"). parser.ad\n-00063170: 645f 6172 6775 6d65 6e74 2827 636f 6d6d d_argument('comm\n-00063180: 616e 6427 2c20 6e61 7267 733d 272a 2729 and', nargs='*')\n-00063190: 0a0a 2020 2020 6172 6773 203d 2070 6172 .. args = par\n-000631a0: 7365 722e 7061 7273 655f 6172 6773 2829 ser.parse_args()\n-000631b0: 0a20 2020 2074 7479 203d 206e 6f74 2061 . tty = not a\n-000631c0: 7267 732e 7363 7269 7074 2061 6e64 206f rgs.script and o\n-000631d0: 732e 6973 6174 7479 2830 290a 0a20 2020 s.isatty(0).. \n-000631e0: 2069 6620 6172 6773 2e63 6f6d 6d61 6e64 if args.command\n-000631f0: 203d 3d20 5b5d 3a0a 2020 2020 2020 2020 == []:. \n-00063200: 636f 6d6d 616e 6420 3d20 6765 745f 7079 command = get_py\n-00063210: 7468 6f6e 5f63 6f6d 6d61 6e64 2874 7479 thon_command(tty\n-00063220: 3d74 7479 290a 2020 2020 656c 6966 2061 =tty). elif a\n-00063230: 7267 732e 636f 6d6d 616e 645b 305d 203d rgs.command[0] =\n-00063240: 3d20 2773 7368 273a 0a20 2020 2020 2020 = 'ssh':. \n-00063250: 2063 6f6d 6d61 6e64 203d 2067 6574 5f73 command = get_s\n-00063260: 7368 5f63 6f6d 6d61 6e64 282a 6172 6773 sh_command(*args\n-00063270: 2e63 6f6d 6d61 6e64 5b31 3a5d 2c20 7474 .command[1:], tt\n-00063280: 793d 7474 7929 0a20 2020 2065 6c69 6620 y=tty). elif \n-00063290: 6172 6773 2e63 6f6d 6d61 6e64 5b30 5d20 args.command[0] \n-000632a0: 3d3d 2027 636f 6e74 6169 6e65 7227 3a0a == 'container':.\n-000632b0: 2020 2020 2020 2020 636f 6d6d 616e 6420 command \n-000632c0: 3d20 6765 745f 636f 6e74 6169 6e65 725f = get_container_\n-000632d0: 636f 6d6d 616e 6428 2a61 7267 732e 636f command(*args.co\n-000632e0: 6d6d 616e 645b 313a 5d2c 2074 7479 3d74 mmand[1:], tty=t\n-000632f0: 7479 290a 2020 2020 656c 7365 3a0a 2020 ty). else:. \n-00063300: 2020 2020 2020 636f 6d6d 616e 6420 3d20 command = \n-00063310: 6765 745f 636f 6d6d 616e 6428 2a61 7267 get_command(*arg\n-00063320: 732e 636f 6d6d 616e 642c 2074 7479 3d74 s.command, tty=t\n-00063330: 7479 2c20 7368 3d61 7267 732e 7368 290a ty, sh=args.sh).\n-00063340: 0a20 2020 2069 6620 6172 6773 2e73 6372 . if args.scr\n-00063350: 6970 743a 0a20 2020 2020 2020 2077 6974 ipt:. wit\n-00063360: 6820 6f70 656e 2861 7267 732e 7363 7269 h open(args.scri\n-00063370: 7074 2c20 2772 6227 2920 6173 2066 696c pt, 'rb') as fil\n-00063380: 653a 0a20 2020 2020 2020 2020 2020 2073 e:. s\n-00063390: 6372 6970 7420 3d20 6669 6c65 2e72 6561 cript = file.rea\n-000633a0: 6428 290a 0a20 2020 2020 2020 2073 656e d().. sen\n-000633b0: 645f 616e 645f 7370 6c69 6365 2863 6f6d d_and_splice(com\n-000633c0: 6d61 6e64 2c20 7363 7269 7074 290a 0a20 mand, script).. \n-000633d0: 2020 2065 6c69 6620 6172 6773 2e78 7a3a elif args.xz:\n-000633e0: 0a20 2020 2020 2020 2077 6974 6820 6f70 . with op\n-000633f0: 656e 2861 7267 732e 787a 2c20 2772 6227 en(args.xz, 'rb'\n-00063400: 2920 6173 2066 696c 653a 0a20 2020 2020 ) as file:. \n-00063410: 2020 2020 2020 2073 6372 6970 7420 3d20 script = \n-00063420: 6669 6c65 2e72 6561 6428 290a 0a20 2020 file.read().. \n-00063430: 2020 2020 2073 656e 645f 787a 5f61 6e64 send_xz_and\n-00063440: 5f73 706c 6963 6528 636f 6d6d 616e 642c _splice(command,\n-00063450: 2073 6372 6970 7429 0a0a 2020 2020 656c script).. el\n-00063460: 7365 3a0a 2020 2020 2020 2020 2320 4966 se:. # If\n-00063470: 2077 6527 7265 2073 7472 6561 6d69 6e67 we're streaming\n-00063480: 2066 726f 6d20 7374 6469 6e20 7468 656e from stdin then\n-00063490: 2074 6869 7320 6973 2061 206c 6f74 2065 this is a lot e\n-000634a0: 6173 6965 722e 2e2e 0a20 2020 2020 2020 asier.... \n-000634b0: 206f 732e 6578 6563 6c70 2863 6f6d 6d61 os.execlp(comma\n-000634c0: 6e64 5b30 5d2c 202a 636f 6d6d 616e 6429 nd[0], *command)\n-000634d0: 0a0a 2020 2020 2320 4f74 6865 7277 6973 .. # Otherwis\n-000634e0: 652c 2022 6675 6c6c 2073 7472 656e 6774 e, \"full strengt\n-000634f0: 6822 0a0a 6966 205f 5f6e 616d 655f 5f20 h\"..if __name__ \n-00063500: 3d3d 2027 5f5f 6d61 696e 5f5f 273a 0a20 == '__main__':. \n-00063510: 2020 206d 6169 6e28 290a 2222 222c 0a20 main().\"\"\",. \n-00063520: 2027 636f 636b 7069 742f 5f76 656e 646f 'cockpit/_vendo\n-00063530: 722f 6265 692f 626f 6f74 6c6f 6164 6572 r/bei/bootloader\n-00063540: 2e70 7927 3a20 6272 2727 2723 2062 6569 .py': br'''# bei\n-00063550: 626f 6f74 202d 2052 656d 6f74 6520 626f boot - Remote bo\n-00063560: 6f74 6c6f 6164 6572 2066 6f72 2050 7974 otloader for Pyt\n-00063570: 686f 6e0a 230a 2320 436f 7079 7269 6768 hon.#.# Copyrigh\n-00063580: 7420 2843 2920 3230 3233 2041 6c6c 6973 t (C) 2023 Allis\n-00063590: 6f6e 204b 6172 6c69 7473 6b61 7961 203c on Karlitskaya <\n-000635a0: 616c 6c69 736f 6e2e 6b61 726c 6974 736b allison.karlitsk\n-000635b0: 6179 6140 7265 6468 6174 2e63 6f6d 3e0a aya@redhat.com>.\n-000635c0: 230a 2320 5468 6973 2070 726f 6772 616d #.# This program\n-000635d0: 2069 7320 6672 6565 2073 6f66 7477 6172 is free softwar\n-000635e0: 653a 2079 6f75 2063 616e 2072 6564 6973 e: you can redis\n-000635f0: 7472 6962 7574 6520 6974 2061 6e64 2f6f tribute it and/o\n-00063600: 7220 6d6f 6469 6679 0a23 2069 7420 756e r modify.# it un\n-00063610: 6465 7220 7468 6520 7465 726d 7320 6f66 der the terms of\n-00063620: 2074 6865 2047 4e55 2047 656e 6572 616c the GNU General\n-00063630: 2050 7562 6c69 6320 4c69 6365 6e73 6520 Public License \n-00063640: 6173 2070 7562 6c69 7368 6564 2062 790a as published by.\n-00063650: 2320 7468 6520 4672 6565 2053 6f66 7477 # the Free Softw\n-00063660: 6172 6520 466f 756e 6461 7469 6f6e 2c20 are Foundation, \n-00063670: 6569 7468 6572 2076 6572 7369 6f6e 2033 either version 3\n-00063680: 206f 6620 7468 6520 4c69 6365 6e73 652c of the License,\n-00063690: 206f 720a 2320 2861 7420 796f 7572 206f or.# (at your o\n-000636a0: 7074 696f 6e29 2061 6e79 206c 6174 6572 ption) any later\n-000636b0: 2076 6572 7369 6f6e 2e0a 230a 2320 5468 version..#.# Th\n-000636c0: 6973 2070 726f 6772 616d 2069 7320 6469 is program is di\n-000636d0: 7374 7269 6275 7465 6420 696e 2074 6865 stributed in the\n-000636e0: 2068 6f70 6520 7468 6174 2069 7420 7769 hope that it wi\n-000636f0: 6c6c 2062 6520 7573 6566 756c 2c0a 2320 ll be useful,.# \n-00063700: 6275 7420 5749 5448 4f55 5420 414e 5920 but WITHOUT ANY \n-00063710: 5741 5252 414e 5459 3b20 7769 7468 6f75 WARRANTY; withou\n-00063720: 7420 6576 656e 2074 6865 2069 6d70 6c69 t even the impli\n-00063730: 6564 2077 6172 7261 6e74 7920 6f66 0a23 ed warranty of.#\n-00063740: 204d 4552 4348 414e 5441 4249 4c49 5459 MERCHANTABILITY\n-00063750: 206f 7220 4649 544e 4553 5320 464f 5220 or FITNESS FOR \n-00063760: 4120 5041 5254 4943 554c 4152 2050 5552 A PARTICULAR PUR\n-00063770: 504f 5345 2e20 2053 6565 2074 6865 0a23 POSE. See the.#\n-00063780: 2047 4e55 2047 656e 6572 616c 2050 7562 GNU General Pub\n-00063790: 6c69 6320 4c69 6365 6e73 6520 666f 7220 lic License for \n-000637a0: 6d6f 7265 2064 6574 6169 6c73 2e0a 230a more details..#.\n-000637b0: 2320 596f 7520 7368 6f75 6c64 2068 6176 # You should hav\n-000637c0: 6520 7265 6365 6976 6564 2061 2063 6f70 e received a cop\n-000637d0: 7920 6f66 2074 6865 2047 4e55 2047 656e y of the GNU Gen\n-000637e0: 6572 616c 2050 7562 6c69 6320 4c69 6365 eral Public Lice\n-000637f0: 6e73 650a 2320 616c 6f6e 6720 7769 7468 nse.# along with\n-00063800: 2074 6869 7320 7072 6f67 7261 6d2e 2020 this program. \n-00063810: 4966 206e 6f74 2c20 7365 6520 3c68 7474 If not, see <htt\n-00063820: 703a 2f2f 7777 772e 676e 752e 6f72 672f p://www.gnu.org/\n-00063830: 6c69 6365 6e73 6573 2f3e 2e0a 0a69 6d70 licenses/>...imp\n-00063840: 6f72 7420 7465 7874 7772 6170 0a66 726f ort textwrap.fro\n-00063850: 6d20 7479 7069 6e67 2069 6d70 6f72 7420 m typing import \n-00063860: 4469 6374 2c20 4974 6572 6162 6c65 2c20 Dict, Iterable, \n-00063870: 4c69 7374 2c20 4f70 7469 6f6e 616c 2c20 List, Optional, \n-00063880: 5365 7175 656e 6365 2c20 5365 742c 2054 Sequence, Set, T\n-00063890: 7570 6c65 0a0a 4741 4447 4554 5320 3d20 uple..GADGETS = \n-000638a0: 7b0a 2020 2020 225f 6672 616d 6522 3a20 {. \"_frame\": \n-000638b0: 7222 2222 0a20 2020 2020 2020 2069 6d70 r\"\"\". imp\n-000638c0: 6f72 7420 7379 730a 2020 2020 2020 2020 ort sys. \n-000638d0: 696d 706f 7274 2074 7261 6365 6261 636b import traceback\n-000638e0: 0a20 2020 2020 2020 2074 7279 3a0a 2020 . try:. \n-000638f0: 2020 2020 2020 2020 2020 2e2e 2e0a 2020 .... \n-00063900: 2020 2020 2020 6578 6365 7074 2053 7973 except Sys\n-00063910: 7465 6d45 7869 743a 0a20 2020 2020 2020 temExit:. \n-00063920: 2020 2020 2072 6169 7365 0a20 2020 2020 raise. \n-00063930: 2020 2065 7863 6570 7420 4261 7365 4578 except BaseEx\n-00063940: 6365 7074 696f 6e3a 0a20 2020 2020 2020 ception:. \n-00063950: 2020 2020 2063 6f6d 6d61 6e64 2827 6265 command('be\n-00063960: 6962 6f6f 742e 6578 6327 2c20 7472 6163 iboot.exc', trac\n-00063970: 6562 6163 6b2e 666f 726d 6174 5f65 7863 eback.format_exc\n-00063980: 2829 290a 2020 2020 2020 2020 2020 2020 ()). \n-00063990: 7379 732e 6578 6974 2833 3729 0a20 2020 sys.exit(37). \n-000639a0: 2022 2222 2c0a 2020 2020 2274 7279 5f65 \"\"\",. \"try_e\n-000639b0: 7865 6322 3a20 7222 2222 0a20 2020 2020 xec\": r\"\"\". \n-000639c0: 2020 2069 6d70 6f72 7420 636f 6e74 6578 import contex\n-000639d0: 746c 6962 0a20 2020 2020 2020 2069 6d70 tlib. imp\n-000639e0: 6f72 7420 6f73 0a20 2020 2020 2020 2064 ort os. d\n-000639f0: 6566 2074 7279 5f65 7865 6328 6172 6776 ef try_exec(argv\n-00063a00: 293a 0a20 2020 2020 2020 2020 2020 2077 ):. w\n-00063a10: 6974 6820 636f 6e74 6578 746c 6962 2e73 ith contextlib.s\n-00063a20: 7570 7072 6573 7328 4f53 4572 726f 7229 uppress(OSError)\n-00063a30: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n-00063a40: 2020 6f73 2e65 7865 6376 7028 6172 6776 os.execvp(argv\n-00063a50: 5b30 5d2c 2061 7267 7629 0a20 2020 2022 [0], argv). \"\n-00063a60: 2222 2c0a 2020 2020 2262 6f6f 745f 787a \"\",. \"boot_xz\n-00063a70: 223a 2072 2222 220a 2020 2020 2020 2020 \": r\"\"\". \n-00063a80: 696d 706f 7274 206c 7a6d 610a 2020 2020 import lzma. \n-00063a90: 2020 2020 696d 706f 7274 2073 7973 0a20 import sys. \n-00063aa0: 2020 2020 2020 2064 6566 2062 6f6f 745f def boot_\n-00063ab0: 787a 2866 696c 656e 616d 652c 2073 697a xz(filename, siz\n-00063ac0: 652c 2061 7267 733d 5b5d 2c20 7365 6e64 e, args=[], send\n-00063ad0: 5f65 6e64 3d46 616c 7365 293a 0a20 2020 _end=False):. \n-00063ae0: 2020 2020 2020 2020 2063 6f6d 6d61 6e64 command\n-00063af0: 2827 6265 6962 6f6f 742e 7072 6f76 6964 ('beiboot.provid\n-00063b00: 6527 2c20 7369 7a65 290a 2020 2020 2020 e', size). \n-00063b10: 2020 2020 2020 7372 635f 787a 203d 2073 src_xz = s\n-00063b20: 7973 2e73 7464 696e 2e62 7566 6665 722e ys.stdin.buffer.\n-00063b30: 7265 6164 2873 697a 6529 0a20 2020 2020 read(size). \n-00063b40: 2020 2020 2020 2073 7263 203d 206c 7a6d src = lzm\n-00063b50: 612e 6465 636f 6d70 7265 7373 2873 7263 a.decompress(src\n-00063b60: 5f78 7a29 0a20 2020 2020 2020 2020 2020 _xz). \n-00063b70: 2073 7973 2e61 7267 7620 3d20 5b66 696c sys.argv = [fil\n-00063b80: 656e 616d 652c 202a 6172 6773 5d0a 2020 ename, *args]. \n-00063b90: 2020 2020 2020 2020 2020 6966 2073 656e if sen\n-00063ba0: 645f 656e 643a 0a20 2020 2020 2020 2020 d_end:. \n-00063bb0: 2020 2020 2020 2065 6e64 2829 0a20 2020 end(). \n-00063bc0: 2020 2020 2020 2020 2065 7865 6328 7372 exec(sr\n-00063bd0: 632c 207b 0a20 2020 2020 2020 2020 2020 c, {. \n-00063be0: 2020 2020 2027 5f5f 6e61 6d65 5f5f 273a '__name__':\n-00063bf0: 2027 5f5f 6d61 696e 5f5f 272c 0a20 2020 '__main__',. \n-00063c00: 2020 2020 2020 2020 2020 2020 2027 5f5f '__\n-00063c10: 7365 6c66 5f73 6f75 7263 655f 5f27 3a20 self_source__': \n-00063c20: 7372 635f 787a 2c0a 2020 2020 2020 2020 src_xz,. \n-00063c30: 2020 2020 2020 2020 275f 5f66 696c 655f '__file_\n-00063c40: 5f27 3a20 6669 6c65 6e61 6d65 7d29 0a20 _': filename}). \n-00063c50: 2020 2020 2020 2020 2020 2073 7973 2e65 sys.e\n-00063c60: 7869 7428 290a 2020 2020 2222 222c 0a7d xit(). \"\"\",.}\n-00063c70: 0a0a 0a64 6566 2073 706c 6974 5f63 6f64 ...def split_cod\n-00063c80: 6528 636f 6465 3a20 7374 722c 2069 6d70 e(code: str, imp\n-00063c90: 6f72 7473 3a20 5365 745b 7374 725d 2920 orts: Set[str]) \n-00063ca0: 2d3e 2049 7465 7261 626c 655b 5475 706c -> Iterable[Tupl\n-00063cb0: 655b 7374 722c 2073 7472 5d5d 3a0a 2020 e[str, str]]:. \n-00063cc0: 2020 666f 7220 6c69 6e65 2069 6e20 7465 for line in te\n-00063cd0: 7874 7772 6170 2e64 6564 656e 7428 636f xtwrap.dedent(co\n-00063ce0: 6465 292e 7370 6c69 746c 696e 6573 2829 de).splitlines()\n-00063cf0: 3a0a 2020 2020 2020 2020 7465 7874 203d :. text =\n-00063d00: 206c 696e 652e 6c73 7472 6970 2822 2022 line.lstrip(\" \"\n-00063d10: 290a 2020 2020 2020 2020 6966 2074 6578 ). if tex\n-00063d20: 742e 7374 6172 7473 7769 7468 2822 696d t.startswith(\"im\n-00063d30: 706f 7274 2022 293a 0a20 2020 2020 2020 port \"):. \n-00063d40: 2020 2020 2069 6d70 6f72 7473 2e61 6464 imports.add\n-00063d50: 2874 6578 7429 0a20 2020 2020 2020 2065 (text). e\n-00063d60: 6c69 6620 7465 7874 3a0a 2020 2020 2020 lif text:. \n-00063d70: 2020 2020 2020 7370 6163 6573 203d 206c spaces = l\n-00063d80: 656e 286c 696e 6529 202d 206c 656e 2874 en(line) - len(t\n-00063d90: 6578 7429 0a20 2020 2020 2020 2020 2020 ext). \n-00063da0: 2061 7373 6572 7420 2873 7061 6365 7320 assert (spaces \n-00063db0: 2520 3429 203d 3d20 300a 2020 2020 2020 % 4) == 0. \n-00063dc0: 2020 2020 2020 7969 656c 6420 225c 7422 yield \"\\t\"\n-00063dd0: 202a 2028 7370 6163 6573 202f 2f20 3429 * (spaces // 4)\n-00063de0: 2c20 7465 7874 0a0a 0a64 6566 2079 6965 , text...def yie\n-00063df0: 6c64 5f62 6f64 7928 7573 6572 5f67 6164 ld_body(user_gad\n-00063e00: 6765 7473 3a20 4469 6374 5b73 7472 2c20 gets: Dict[str, \n-00063e10: 7374 725d 2c0a 2020 2020 2020 2020 2020 str],. \n-00063e20: 2020 2020 2073 7465 7073 3a20 5365 7175 steps: Sequ\n-00063e30: 656e 6365 5b54 7570 6c65 5b73 7472 2c20 ence[Tuple[str, \n-00063e40: 5365 7175 656e 6365 5b6f 626a 6563 745d Sequence[object]\n-00063e50: 5d5d 2c0a 2020 2020 2020 2020 2020 2020 ]],. \n-00063e60: 2020 2069 6d70 6f72 7473 3a20 5365 745b imports: Set[\n-00063e70: 7374 725d 2920 2d3e 2049 7465 7261 626c str]) -> Iterabl\n-00063e80: 655b 5475 706c 655b 7374 722c 2073 7472 e[Tuple[str, str\n-00063e90: 5d5d 3a0a 2020 2020 2320 416c 6c6f 7720 ]]:. # Allow \n-00063ea0: 7468 6520 6361 6c6c 6572 2074 6f20 6f76 the caller to ov\n-00063eb0: 6572 7269 6465 206f 7572 2067 6164 6765 erride our gadge\n-00063ec0: 7473 2c20 6275 7420 6b65 6570 2074 6865 ts, but keep the\n-00063ed0: 206f 7269 6769 6e61 6c0a 2020 2020 2320 original. # \n-00063ee0: 7661 7269 6162 6c65 2066 6f72 2075 7365 variable for use\n-00063ef0: 2069 6e20 7468 6520 6e65 7874 2073 7465 in the next ste\n-00063f00: 702e 0a20 2020 2067 6164 6765 7473 203d p.. gadgets =\n-00063f10: 2064 6963 7428 4741 4447 4554 532c 202a dict(GADGETS, *\n-00063f20: 2a75 7365 725f 6761 6467 6574 7329 0a0a *user_gadgets)..\n-00063f30: 2020 2020 2320 4669 7273 7420 656d 6974 # First emit\n-00063f40: 2074 6865 2067 6164 6765 7473 2e20 2045 the gadgets. E\n-00063f50: 6d69 7420 616c 6c20 6761 6467 6574 7320 mit all gadgets \n-00063f60: 7072 6f76 6964 6564 2062 7920 7468 6520 provided by the \n-00063f70: 6361 6c6c 6572 2c0a 2020 2020 2320 706c caller,. # pl\n-00063f80: 7573 2061 6e79 2072 6566 6572 7265 6420 us any referred \n-00063f90: 746f 2062 7920 7468 6520 6361 6c6c 6572 to by the caller\n-00063fa0: 2773 206c 6973 7420 6f66 2073 7465 7073 's list of steps\n-00063fb0: 2e0a 2020 2020 7072 6f76 6964 6564 5f67 .. provided_g\n-00063fc0: 6164 6765 7473 203d 2073 6574 2875 7365 adgets = set(use\n-00063fd0: 725f 6761 6467 6574 7329 0a20 2020 2073 r_gadgets). s\n-00063fe0: 7465 705f 6761 6467 6574 7320 3d20 7b6e tep_gadgets = {n\n-00063ff0: 616d 6520 666f 7220 6e61 6d65 2c20 5f61 ame for name, _a\n-00064000: 7267 7320 696e 2073 7465 7073 7d0a 2020 rgs in steps}. \n-00064010: 2020 666f 7220 6e61 6d65 2069 6e20 7072 for name in pr\n-00064020: 6f76 6964 6564 5f67 6164 6765 7473 207c ovided_gadgets |\n-00064030: 2073 7465 705f 6761 6467 6574 733a 0a20 step_gadgets:. \n-00064040: 2020 2020 2020 2079 6965 6c64 2066 726f yield fro\n-00064050: 6d20 7370 6c69 745f 636f 6465 2867 6164 m split_code(gad\n-00064060: 6765 7473 5b6e 616d 655d 2c20 696d 706f gets[name], impo\n-00064070: 7274 7329 0a0a 2020 2020 2320 5969 656c rts).. # Yiel\n-00064080: 6420 6675 6e63 7469 6f6e 7320 6d65 6e74 d functions ment\n-00064090: 696f 6e65 6420 696e 2073 7465 7073 2066 ioned in steps f\n-000640a0: 726f 6d20 7468 6520 6361 6c6c 6572 0a20 rom the caller. \n-000640b0: 2020 2066 6f72 206e 616d 652c 2061 7267 for name, arg\n-000640c0: 7320 696e 2073 7465 7073 3a0a 2020 2020 s in steps:. \n-000640d0: 2020 2020 7969 656c 6420 2727 2c20 6e61 yield '', na\n-000640e0: 6d65 202b 2072 6570 7228 7475 706c 6528 me + repr(tuple(\n-000640f0: 6172 6773 2929 0a0a 0a64 6566 206d 616b args))...def mak\n-00064100: 655f 626f 6f74 6c6f 6164 6572 2873 7465 e_bootloader(ste\n-00064110: 7073 3a20 5365 7175 656e 6365 5b54 7570 ps: Sequence[Tup\n-00064120: 6c65 5b73 7472 2c20 5365 7175 656e 6365 le[str, Sequence\n-00064130: 5b6f 626a 6563 745d 5d5d 2c0a 2020 2020 [object]]],. \n-00064140: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00064150: 6761 6467 6574 733a 204f 7074 696f 6e61 gadgets: Optiona\n-00064160: 6c5b 4469 6374 5b73 7472 2c20 7374 725d l[Dict[str, str]\n-00064170: 5d20 3d20 4e6f 6e65 2920 2d3e 2073 7472 ] = None) -> str\n-00064180: 3a0a 2020 2020 696d 706f 7274 733a 2053 :. imports: S\n-00064190: 6574 5b73 7472 5d20 3d20 7365 7428 290a et[str] = set().\n-000641a0: 2020 2020 6c69 6e65 733a 204c 6973 745b lines: List[\n-000641b0: 7374 725d 203d 205b 5d0a 0a20 2020 2066 str] = [].. f\n-000641c0: 6f72 2066 7261 6d65 5f73 7061 6365 732c or frame_spaces,\n-000641d0: 2066 7261 6d65 5f74 6578 7420 696e 2073 frame_text in s\n-000641e0: 706c 6974 5f63 6f64 6528 4741 4447 4554 plit_code(GADGET\n-000641f0: 535b 225f 6672 616d 6522 5d2c 2069 6d70 S[\"_frame\"], imp\n-00064200: 6f72 7473 293a 0a20 2020 2020 2020 2069 orts):. i\n-00064210: 6620 6672 616d 655f 7465 7874 203d 3d20 f frame_text == \n-00064220: 222e 2e2e 223a 0a20 2020 2020 2020 2020 \"...\":. \n-00064230: 2020 2066 6f72 2073 7061 6365 732c 2074 for spaces, t\n-00064240: 6578 7420 696e 2079 6965 6c64 5f62 6f64 ext in yield_bod\n-00064250: 7928 6761 6467 6574 7320 6f72 207b 7d2c y(gadgets or {},\n-00064260: 2073 7465 7073 2c20 696d 706f 7274 7329 steps, imports)\n-00064270: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n-00064280: 2020 6c69 6e65 732e 6170 7065 6e64 2866 lines.append(f\n-00064290: 7261 6d65 5f73 7061 6365 7320 2b20 7370 rame_spaces + sp\n-000642a0: 6163 6573 202b 2074 6578 7429 0a20 2020 aces + text). \n-000642b0: 2020 2020 2065 6c73 653a 0a20 2020 2020 else:. \n-000642c0: 2020 2020 2020 206c 696e 6573 2e61 7070 lines.app\n-000642d0: 656e 6428 6672 616d 655f 7370 6163 6573 end(frame_spaces\n-000642e0: 202b 2066 7261 6d65 5f74 6578 7429 0a0a + frame_text)..\n-000642f0: 2020 2020 7265 7475 726e 2022 222e 6a6f return \"\".jo\n-00064300: 696e 2866 227b 6c69 6e65 7d5c 6e22 2066 in(f\"{line}\\n\" f\n-00064310: 6f72 206c 696e 6520 696e 205b 2a69 6d70 or line in [*imp\n-00064320: 6f72 7473 2c20 2a6c 696e 6573 5d29 202b orts, *lines]) +\n-00064330: 2022 5c6e 220a 2727 272c 0a20 2027 636f \"\\n\".''',. 'co\n-00064340: 636b 7069 742f 5f76 656e 646f 722f 6265 ckpit/_vendor/be\n-00064350: 692f 746d 7066 732e 7079 273a 2062 7227 i/tmpfs.py': br'\n-00064360: 2727 696d 706f 7274 206f 730a 696d 706f ''import os.impo\n-00064370: 7274 2073 7562 7072 6f63 6573 730a 696d rt subprocess.im\n-00064380: 706f 7274 2073 7973 0a69 6d70 6f72 7420 port sys.import \n-00064390: 7465 6d70 6669 6c65 0a0a 0a64 6566 206d tempfile...def m\n-000643a0: 6169 6e28 2a63 6f6d 6d61 6e64 3a20 7374 ain(*command: st\n-000643b0: 7229 202d 3e20 4e6f 6e65 3a0a 2020 2020 r) -> None:. \n-000643c0: 7769 7468 2074 656d 7066 696c 652e 5465 with tempfile.Te\n-000643d0: 6d70 6f72 6172 7944 6972 6563 746f 7279 mporaryDirectory\n-000643e0: 2829 2061 7320 746d 7064 6972 3a0a 2020 () as tmpdir:. \n-000643f0: 2020 2020 2020 6f73 2e63 6864 6972 2874 os.chdir(t\n-00064400: 6d70 6469 7229 0a0a 2020 2020 2020 2020 mpdir).. \n-00064410: 666f 7220 6b65 792c 2076 616c 7565 2069 for key, value i\n-00064420: 6e20 5f5f 6c6f 6164 6572 5f5f 2e67 6574 n __loader__.get\n-00064430: 5f63 6f6e 7465 6e74 7328 292e 6974 656d _contents().item\n-00064440: 7328 293a 0a20 2020 2020 2020 2020 2020 s():. \n-00064450: 2069 6620 6b65 792e 7374 6172 7473 7769 if key.startswi\n-00064460: 7468 2827 746d 7066 732f 2729 3a0a 2020 th('tmpfs/'):. \n-00064470: 2020 2020 2020 2020 2020 2020 2020 7375 su\n-00064480: 6264 6972 203d 206f 732e 7061 7468 2e64 bdir = os.path.d\n-00064490: 6972 6e61 6d65 286b 6579 290a 2020 2020 irname(key). \n-000644a0: 2020 2020 2020 2020 2020 2020 6f73 2e6d os.m\n-000644b0: 616b 6564 6972 7328 7375 6264 6972 2c20 akedirs(subdir, \n-000644c0: 6578 6973 745f 6f6b 3d54 7275 6529 0a20 exist_ok=True). \n-000644d0: 2020 2020 2020 2020 2020 2020 2020 2077 w\n-000644e0: 6974 6820 6f70 656e 286b 6579 2c20 2777 ith open(key, 'w\n-000644f0: 6227 2920 6173 2066 703a 0a20 2020 2020 b') as fp:. \n-00064500: 2020 2020 2020 2020 2020 2020 2020 2066 f\n-00064510: 702e 7772 6974 6528 7661 6c75 6529 0a0a p.write(value)..\n-00064520: 2020 2020 2020 2020 6f73 2e63 6864 6972 os.chdir\n-00064530: 2827 746d 7066 7327 290a 0a20 2020 2020 ('tmpfs').. \n-00064540: 2020 2072 6573 756c 7420 3d20 7375 6270 result = subp\n-00064550: 726f 6365 7373 2e72 756e 2863 6f6d 6d61 rocess.run(comma\n-00064560: 6e64 2c20 6368 6563 6b3d 4661 6c73 6529 nd, check=False)\n-00064570: 0a20 2020 2020 2020 2073 7973 2e65 7869 . sys.exi\n-00064580: 7428 7265 7375 6c74 2e72 6574 7572 6e63 t(result.returnc\n-00064590: 6f64 6529 0a27 2727 2c0a 2020 2763 6f63 ode).''',. 'coc\n-000645a0: 6b70 6974 2f5f 7665 6e64 6f72 2f62 6569 kpit/_vendor/bei\n-000645b0: 2f5f 5f69 6e69 745f 5f2e 7079 273a 2062 /__init__.py': b\n-000645c0: 7227 2727 2727 272c 0a20 2027 636f 636b r'''''',. 'cock\n-000645d0: 7069 742f 5f76 656e 646f 722f 6265 692f pit/_vendor/bei/\n-000645e0: 7370 6177 6e2e 7079 273a 2062 7227 2727 spawn.py': br'''\n-000645f0: 2222 2248 656c 7065 7220 746f 2063 7265 \"\"\"Helper to cre\n-00064600: 6174 6520 6120 6265 6970 6163 6b20 746f ate a beipack to\n-00064610: 2073 7061 776e 2061 2063 6f6d 6d61 6e64 spawn a command\n-00064620: 2077 6974 6820 6669 6c65 7320 696e 2061 with files in a\n-00064630: 2074 6d70 6469 7222 2222 0a0a 696d 706f tmpdir\"\"\"..impo\n-00064640: 7274 2061 7267 7061 7273 650a 696d 706f rt argparse.impo\n-00064650: 7274 206f 730a 696d 706f 7274 2073 7973 rt os.import sys\n-00064660: 0a0a 6672 6f6d 202e 2069 6d70 6f72 7420 ..from . import \n-00064670: 7061 636b 2c20 746d 7066 730a 0a0a 6465 pack, tmpfs...de\n-00064680: 6620 6d61 696e 2829 202d 3e20 4e6f 6e65 f main() -> None\n-00064690: 3a0a 2020 2020 7061 7273 6572 203d 2061 :. parser = a\n-000646a0: 7267 7061 7273 652e 4172 6775 6d65 6e74 rgparse.Argument\n-000646b0: 5061 7273 6572 2829 0a20 2020 2070 6172 Parser(). par\n-000646c0: 7365 722e 6164 645f 6172 6775 6d65 6e74 ser.add_argument\n-000646d0: 2827 2d2d 6669 6c65 272c 2027 2d66 272c ('--file', '-f',\n-000646e0: 2061 6374 696f 6e3d 2761 7070 656e 6427 action='append'\n-000646f0: 290a 2020 2020 7061 7273 6572 2e61 6464 ). parser.add\n-00064700: 5f61 7267 756d 656e 7428 2763 6f6d 6d61 _argument('comma\n-00064710: 6e64 272c 206e 6172 6773 3d27 2b27 2c20 nd', nargs='+', \n-00064720: 6865 6c70 3d27 5468 6520 636f 6d6d 616e help='The comman\n-00064730: 6420 746f 2065 7865 6375 7465 2729 0a20 d to execute'). \n-00064740: 2020 2061 7267 7320 3d20 7061 7273 6572 args = parser\n-00064750: 2e70 6172 7365 5f61 7267 7328 290a 0a20 .parse_args().. \n-00064760: 2020 2063 6f6e 7465 6e74 7320 3d20 7b0a contents = {.\n-00064770: 2020 2020 2020 2020 275f 6265 6974 6d70 '_beitmp\n-00064780: 6673 2e70 7927 3a20 746d 7066 732e 5f5f fs.py': tmpfs.__\n-00064790: 7370 6563 5f5f 2e6c 6f61 6465 722e 6765 spec__.loader.ge\n-000647a0: 745f 6461 7461 2874 6d70 6673 2e5f 5f73 t_data(tmpfs.__s\n-000647b0: 7065 635f 5f2e 6f72 6967 696e 290a 2020 pec__.origin). \n-000647c0: 2020 7d0a 0a20 2020 2069 6620 6172 6773 }.. if args\n-000647d0: 2e66 696c 6520 6973 206e 6f74 204e 6f6e .file is not Non\n-000647e0: 653a 0a20 2020 2020 2020 2066 696c 6573 e:. files\n-000647f0: 203d 2061 7267 732e 6669 6c65 0a20 2020 = args.file. \n-00064800: 2065 6c73 653a 0a20 2020 2020 2020 2066 else:. f\n-00064810: 696c 6520 3d20 6172 6773 2e63 6f6d 6d61 ile = args.comma\n-00064820: 6e64 5b2d 315d 0a20 2020 2020 2020 2066 nd[-1]. f\n-00064830: 696c 6573 203d 205b 6669 6c65 5d0a 2020 iles = [file]. \n-00064840: 2020 2020 2020 6172 6773 2e63 6f6d 6d61 args.comma\n-00064850: 6e64 5b2d 315d 203d 2027 2e2f 2720 2b20 nd[-1] = './' + \n-00064860: 6f73 2e70 6174 682e 6261 7365 6e61 6d65 os.path.basename\n-00064870: 2866 696c 6529 0a0a 2020 2020 666f 7220 (file).. for \n-00064880: 6669 6c65 6e61 6d65 2069 6e20 6669 6c65 filename in file\n-00064890: 733a 0a20 2020 2020 2020 2077 6974 6820 s:. with \n-000648a0: 6f70 656e 2866 696c 656e 616d 652c 2027 open(filename, '\n-000648b0: 7262 2729 2061 7320 6669 6c65 3a0a 2020 rb') as file:. \n-000648c0: 2020 2020 2020 2020 2020 6261 7365 6e61 basena\n-000648d0: 6d65 203d 206f 732e 7061 7468 2e62 6173 me = os.path.bas\n-000648e0: 656e 616d 6528 6669 6c65 6e61 6d65 290a ename(filename).\n-000648f0: 2020 2020 2020 2020 2020 2020 636f 6e74 cont\n-00064900: 656e 7473 5b66 2774 6d70 6673 2f7b 6261 ents[f'tmpfs/{ba\n-00064910: 7365 6e61 6d65 7d27 5d20 3d20 6669 6c65 sename}'] = file\n-00064920: 2e72 6561 6428 290a 0a20 2020 2073 6372 .read().. scr\n-00064930: 6970 7420 3d20 7061 636b 2e70 6163 6b28 ipt = pack.pack(\n-00064940: 636f 6e74 656e 7473 2c20 275f 6265 6974 contents, '_beit\n-00064950: 6d70 6673 3a6d 6169 6e27 2c20 272a 2720 mpfs:main', '*' \n-00064960: 2b20 7265 7072 2861 7267 732e 636f 6d6d + repr(args.comm\n-00064970: 616e 6429 290a 2020 2020 7379 732e 7374 and)). sys.st\n-00064980: 646f 7574 2e77 7269 7465 2873 6372 6970 dout.write(scrip\n-00064990: 7429 0a0a 0a69 6620 5f5f 6e61 6d65 5f5f t)...if __name__\n-000649a0: 203d 3d20 275f 5f6d 6169 6e5f 5f27 3a0a == '__main__':.\n-000649b0: 2020 2020 6d61 696e 2829 0a27 2727 2c0a main().''',.\n-000649c0: 2020 2763 6f63 6b70 6974 2f5f 7665 6e64 'cockpit/_vend\n-000649d0: 6f72 2f62 6569 2f62 6569 7061 636b 2e70 or/bei/beipack.p\n-000649e0: 7927 3a20 6272 2727 2723 2062 6569 7061 y': br'''# beipa\n-000649f0: 636b 202d 2052 656d 6f74 6520 626f 6f74 ck - Remote boot\n-00064a00: 6c6f 6164 6572 2066 6f72 2050 7974 686f loader for Pytho\n-00064a10: 6e0a 230a 2320 436f 7079 7269 6768 7420 n.#.# Copyright \n-00064a20: 2843 2920 3230 3232 2041 6c6c 6973 6f6e (C) 2022 Allison\n-00064a30: 204b 6172 6c69 7473 6b61 7961 203c 616c Karlitskaya <al\n-00064a40: 6c69 736f 6e2e 6b61 726c 6974 736b 6179 lison.karlitskay\n-00064a50: 6140 7265 6468 6174 2e63 6f6d 3e0a 230a a@redhat.com>.#.\n-00064a60: 2320 5468 6973 2070 726f 6772 616d 2069 # This program i\n-00064a70: 7320 6672 6565 2073 6f66 7477 6172 653a s free software:\n-00064a80: 2079 6f75 2063 616e 2072 6564 6973 7472 you can redistr\n-00064a90: 6962 7574 6520 6974 2061 6e64 2f6f 7220 ibute it and/or \n-00064aa0: 6d6f 6469 6679 0a23 2069 7420 756e 6465 modify.# it unde\n-00064ab0: 7220 7468 6520 7465 726d 7320 6f66 2074 r the terms of t\n-00064ac0: 6865 2047 4e55 2047 656e 6572 616c 2050 he GNU General P\n-00064ad0: 7562 6c69 6320 4c69 6365 6e73 6520 6173 ublic License as\n-00064ae0: 2070 7562 6c69 7368 6564 2062 790a 2320 published by.# \n-00064af0: 7468 6520 4672 6565 2053 6f66 7477 6172 the Free Softwar\n-00064b00: 6520 466f 756e 6461 7469 6f6e 2c20 6569 e Foundation, ei\n-00064b10: 7468 6572 2076 6572 7369 6f6e 2033 206f ther version 3 o\n-00064b20: 6620 7468 6520 4c69 6365 6e73 652c 206f f the License, o\n-00064b30: 720a 2320 2861 7420 796f 7572 206f 7074 r.# (at your opt\n-00064b40: 696f 6e29 2061 6e79 206c 6174 6572 2076 ion) any later v\n-00064b50: 6572 7369 6f6e 2e0a 230a 2320 5468 6973 ersion..#.# This\n-00064b60: 2070 726f 6772 616d 2069 7320 6469 7374 program is dist\n-00064b70: 7269 6275 7465 6420 696e 2074 6865 2068 ributed in the h\n-00064b80: 6f70 6520 7468 6174 2069 7420 7769 6c6c ope that it will\n-00064b90: 2062 6520 7573 6566 756c 2c0a 2320 6275 be useful,.# bu\n-00064ba0: 7420 5749 5448 4f55 5420 414e 5920 5741 t WITHOUT ANY WA\n-00064bb0: 5252 414e 5459 3b20 7769 7468 6f75 7420 RRANTY; without \n-00064bc0: 6576 656e 2074 6865 2069 6d70 6c69 6564 even the implied\n-00064bd0: 2077 6172 7261 6e74 7920 6f66 0a23 204d warranty of.# M\n-00064be0: 4552 4348 414e 5441 4249 4c49 5459 206f ERCHANTABILITY o\n-00064bf0: 7220 4649 544e 4553 5320 464f 5220 4120 r FITNESS FOR A \n-00064c00: 5041 5254 4943 554c 4152 2050 5552 504f PARTICULAR PURPO\n-00064c10: 5345 2e20 2053 6565 2074 6865 0a23 2047 SE. See the.# G\n-00064c20: 4e55 2047 656e 6572 616c 2050 7562 6c69 NU General Publi\n-00064c30: 6320 4c69 6365 6e73 6520 666f 7220 6d6f c License for mo\n-00064c40: 7265 2064 6574 6169 6c73 2e0a 230a 2320 re details..#.# \n-00064c50: 596f 7520 7368 6f75 6c64 2068 6176 6520 You should have \n-00064c60: 7265 6365 6976 6564 2061 2063 6f70 7920 received a copy \n-00064c70: 6f66 2074 6865 2047 4e55 2047 656e 6572 of the GNU Gener\n-00064c80: 616c 2050 7562 6c69 6320 4c69 6365 6e73 al Public Licens\n-00064c90: 650a 2320 616c 6f6e 6720 7769 7468 2074 e.# along with t\n-00064ca0: 6869 7320 7072 6f67 7261 6d2e 2020 4966 his program. If\n-00064cb0: 206e 6f74 2c20 7365 6520 3c68 7474 703a not, see <http:\n-00064cc0: 2f2f 7777 772e 676e 752e 6f72 672f 6c69 //www.gnu.org/li\n-00064cd0: 6365 6e73 6573 2f3e 2e0a 0a69 6d70 6f72 censes/>...impor\n-00064ce0: 7420 6172 6770 6172 7365 0a69 6d70 6f72 t argparse.impor\n-00064cf0: 7420 6269 6e61 7363 6969 0a69 6d70 6f72 t binascii.impor\n-00064d00: 7420 6c7a 6d61 0a69 6d70 6f72 7420 6f73 t lzma.import os\n-00064d10: 0a69 6d70 6f72 7420 7379 730a 696d 706f .import sys.impo\n-00064d20: 7274 2074 656d 7066 696c 650a 696d 706f rt tempfile.impo\n-00064d30: 7274 207a 6970 6669 6c65 0a66 726f 6d20 rt zipfile.from \n-00064d40: 7479 7069 6e67 2069 6d70 6f72 7420 4469 typing import Di\n-00064d50: 6374 2c20 4974 6572 6162 6c65 2c20 4c69 ct, Iterable, Li\n-00064d60: 7374 2c20 4f70 7469 6f6e 616c 2c20 5365 st, Optional, Se\n-00064d70: 742c 2054 7570 6c65 0a0a 6672 6f6d 202e t, Tuple..from .\n-00064d80: 6461 7461 2069 6d70 6f72 7420 7265 6164 data import read\n-00064d90: 5f64 6174 615f 6669 6c65 0a0a 0a64 6566 _data_file...def\n-00064da0: 2065 7363 6170 655f 7374 7269 6e67 2864 escape_string(d\n-00064db0: 6174 613a 2073 7472 2920 2d3e 2073 7472 ata: str) -> str\n-00064dc0: 3a0a 2020 2020 2320 4176 6f69 6420 6d65 :. # Avoid me\n-00064dd0: 6e74 696f 6e69 6e67 2027 2027 2027 206c ntioning ' ' ' l\n-00064de0: 6974 6572 616c 6c79 2c20 746f 206d 616b iterally, to mak\n-00064df0: 6520 6f75 7220 6f77 6e20 7061 636b 696e e our own packin\n-00064e00: 6720 6120 6269 7420 7072 6574 7469 6572 g a bit prettier\n-00064e10: 0a20 2020 2074 7269 706c 6571 756f 7465 . triplequote\n-00064e20: 203d 2022 2722 202a 2033 0a20 2020 2069 = \"'\" * 3. i\n-00064e30: 6620 7472 6970 6c65 7175 6f74 6520 6e6f f triplequote no\n-00064e40: 7420 696e 2064 6174 613a 0a20 2020 2020 t in data:. \n-00064e50: 2020 2072 6574 7572 6e20 2272 2220 2b20 return \"r\" + \n-00064e60: 7472 6970 6c65 7175 6f74 6520 2b20 6461 triplequote + da\n-00064e70: 7461 202b 2074 7269 706c 6571 756f 7465 ta + triplequote\n-00064e80: 0a20 2020 2069 6620 2722 2222 2720 6e6f . if '\"\"\"' no\n-00064e90: 7420 696e 2064 6174 613a 0a20 2020 2020 t in data:. \n-00064ea0: 2020 2072 6574 7572 6e20 2772 2222 2227 return 'r\"\"\"'\n-00064eb0: 202b 2064 6174 6120 2b20 2722 2222 270a + data + '\"\"\"'.\n-00064ec0: 2020 2020 7265 7475 726e 2072 6570 7228 return repr(\n-00064ed0: 6461 7461 290a 0a0a 6465 6620 6173 6369 data)...def asci\n-00064ee0: 695f 6279 7465 735f 7265 7072 2864 6174 i_bytes_repr(dat\n-00064ef0: 613a 2062 7974 6573 2920 2d3e 2073 7472 a: bytes) -> str\n-00064f00: 3a0a 2020 2020 7265 7475 726e 2027 6227 :. return 'b'\n-00064f10: 202b 2065 7363 6170 655f 7374 7269 6e67 + escape_string\n-00064f20: 2864 6174 612e 6465 636f 6465 2827 6173 (data.decode('as\n-00064f30: 6369 6927 2929 0a0a 0a64 6566 2075 7466 cii'))...def utf\n-00064f40: 385f 6279 7465 735f 7265 7072 2864 6174 8_bytes_repr(dat\n-00064f50: 613a 2062 7974 6573 2920 2d3e 2073 7472 a: bytes) -> str\n-00064f60: 3a0a 2020 2020 7265 7475 726e 2065 7363 :. return esc\n-00064f70: 6170 655f 7374 7269 6e67 2864 6174 612e ape_string(data.\n-00064f80: 6465 636f 6465 2827 7574 662d 3827 2929 decode('utf-8'))\n-00064f90: 202b 2022 2e65 6e63 6f64 6528 2775 7466 + \".encode('utf\n-00064fa0: 2d38 2729 220a 0a0a 6465 6620 6261 7365 -8')\"...def base\n-00064fb0: 3634 5f62 7974 6573 5f72 6570 7228 6461 64_bytes_repr(da\n-00064fc0: 7461 3a20 6279 7465 732c 2069 6d70 6f72 ta: bytes, impor\n-00064fd0: 7473 3a20 5365 745b 7374 725d 2920 2d3e ts: Set[str]) ->\n-00064fe0: 2073 7472 3a0a 2020 2020 2320 6261 7365 str:. # base\n-00064ff0: 3835 2069 7320 736d 616c 6c65 722c 2062 85 is smaller, b\n-00065000: 7574 2062 6173 6536 3420 6973 2069 6e20 ut base64 is in \n-00065010: 432c 2061 6e64 207e 3230 7820 6661 7374 C, and ~20x fast\n-00065020: 6572 2e0a 2020 2020 2320 7768 656e 2063 er.. # when c\n-00065030: 6f6d 7072 6573 7369 6e67 2077 6974 6820 ompressing with \n-00065040: 6078 7a20 2d65 6020 7468 6520 7369 7a65 `xz -e` the size\n-00065050: 2064 6966 6665 7265 6e63 6520 6973 206d difference is m\n-00065060: 6172 6769 6e61 6c2e 0a20 2020 2069 6d70 arginal.. imp\n-00065070: 6f72 7473 2e61 6464 2827 6672 6f6d 2062 orts.add('from b\n-00065080: 696e 6173 6369 6920 696d 706f 7274 2061 inascii import a\n-00065090: 3262 5f62 6173 6536 3427 290a 2020 2020 2b_base64'). \n-000650a0: 656e 636f 6465 6420 3d20 6269 6e61 7363 encoded = binasc\n-000650b0: 6969 2e62 3261 5f62 6173 6536 3428 6461 ii.b2a_base64(da\n-000650c0: 7461 292e 6465 636f 6465 2827 6173 6369 ta).decode('asci\n-000650d0: 6927 292e 7374 7269 7028 290a 2020 2020 i').strip(). \n-000650e0: 7265 7475 726e 2066 2761 3262 5f62 6173 return f'a2b_bas\n-000650f0: 6536 3428 227b 656e 636f 6465 647d 2229 e64(\"{encoded}\")\n-00065100: 270a 0a0a 6465 6620 6279 7465 735f 7265 '...def bytes_re\n-00065110: 7072 2864 6174 613a 2062 7974 6573 2c20 pr(data: bytes, \n-00065120: 696d 706f 7274 733a 2053 6574 5b73 7472 imports: Set[str\n-00065130: 5d29 202d 3e20 7374 723a 0a20 2020 2023 ]) -> str:. #\n-00065140: 2053 7472 6174 6567 793a 0a20 2020 2023 Strategy:. #\n-00065150: 2020 2069 6620 7468 6520 6669 6c65 2069 if the file i\n-00065160: 7320 6173 6369 692c 2065 6e63 6f64 6520 s ascii, encode \n-00065170: 6974 2064 6972 6563 746c 7920 6173 2062 it directly as b\n-00065180: 7974 6573 0a20 2020 2023 2020 206f 7468 ytes. # oth\n-00065190: 6572 7769 7365 2c20 6966 2069 7427 7320 erwise, if it's \n-000651a0: 5554 462d 382c 2075 7365 2061 2075 6e69 UTF-8, use a uni\n-000651b0: 636f 6465 2073 7472 696e 6720 616e 6420 code string and \n-000651c0: 656e 636f 6465 0a20 2020 2023 2020 206f encode. # o\n-000651d0: 7468 6572 7769 7365 2c20 6261 7365 3634 therwise, base64\n-000651e0: 0a0a 2020 2020 7472 793a 0a20 2020 2020 .. try:. \n-000651f0: 2020 2072 6574 7572 6e20 6173 6369 695f return ascii_\n-00065200: 6279 7465 735f 7265 7072 2864 6174 6129 bytes_repr(data)\n-00065210: 0a20 2020 2065 7863 6570 7420 556e 6963 . except Unic\n-00065220: 6f64 6544 6563 6f64 6545 7272 6f72 3a0a odeDecodeError:.\n-00065230: 2020 2020 2020 2020 2320 6974 2773 206e # it's n\n-00065240: 6f74 2061 7363 6969 0a20 2020 2020 2020 ot ascii. \n-00065250: 2070 6173 730a 0a20 2020 2023 2075 7466 pass.. # utf\n-00065260: 2d38 0a20 2020 2074 7279 3a0a 2020 2020 -8. try:. \n-00065270: 2020 2020 7265 7475 726e 2075 7466 385f return utf8_\n-00065280: 6279 7465 735f 7265 7072 2864 6174 6129 bytes_repr(data)\n-00065290: 0a20 2020 2065 7863 6570 7420 556e 6963 . except Unic\n-000652a0: 6f64 6544 6563 6f64 6545 7272 6f72 3a0a odeDecodeError:.\n-000652b0: 2020 2020 2020 2020 2320 6974 2773 206e # it's n\n-000652c0: 6f74 2075 7466 2d38 0a20 2020 2020 2020 ot utf-8. \n-000652d0: 2070 6173 730a 0a20 2020 2072 6574 7572 pass.. retur\n-000652e0: 6e20 6261 7365 3634 5f62 7974 6573 5f72 n base64_bytes_r\n-000652f0: 6570 7228 6461 7461 2c20 696d 706f 7274 epr(data, import\n-00065300: 7329 0a0a 0a64 6566 2064 6963 745f 7265 s)...def dict_re\n-00065310: 7072 2863 6f6e 7465 6e74 733a 2044 6963 pr(contents: Dic\n-00065320: 745b 7374 722c 2062 7974 6573 5d2c 2069 t[str, bytes], i\n-00065330: 6d70 6f72 7473 3a20 5365 745b 7374 725d mports: Set[str]\n-00065340: 2920 2d3e 2073 7472 3a0a 2020 2020 7265 ) -> str:. re\n-00065350: 7475 726e 2028 277b 5c6e 2720 2b0a 2020 turn ('{\\n' +. \n-00065360: 2020 2020 2020 2020 2020 2727 2e6a 6f69 ''.joi\n-00065370: 6e28 6627 2020 7b72 6570 7228 6b29 7d3a n(f' {repr(k)}:\n-00065380: 207b 6279 7465 735f 7265 7072 2876 2c20 {bytes_repr(v, \n-00065390: 696d 706f 7274 7329 7d2c 5c6e 270a 2020 imports)},\\n'. \n-000653a0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000653b0: 2020 666f 7220 6b2c 2076 2069 6e20 636f for k, v in co\n-000653c0: 6e74 656e 7473 2e69 7465 6d73 2829 2920 ntents.items()) \n-000653d0: 2b0a 2020 2020 2020 2020 2020 2020 277d +. '}\n-000653e0: 2729 0a0a 0a64 6566 2070 6163 6b28 636f ')...def pack(co\n-000653f0: 6e74 656e 7473 3a20 4469 6374 5b73 7472 ntents: Dict[str\n-00065400: 2c20 6279 7465 735d 2c0a 2020 2020 2020 , bytes],. \n-00065410: 2020 2065 6e74 7279 706f 696e 743a 204f entrypoint: O\n-00065420: 7074 696f 6e61 6c5b 7374 725d 203d 204e ptional[str] = N\n-00065430: 6f6e 652c 0a20 2020 2020 2020 2020 6172 one,. ar\n-00065440: 6773 3a20 7374 7220 3d20 2727 2920 2d3e gs: str = '') ->\n-00065450: 2073 7472 3a0a 2020 2020 2222 2243 7265 str:. \"\"\"Cre\n-00065460: 6174 6573 2061 2062 6569 7061 636b 2077 ates a beipack w\n-00065470: 6974 6820 7468 6520 6769 7665 6e20 6063 ith the given `c\n-00065480: 6f6e 7465 6e74 7360 2e0a 0a20 2020 2049 ontents`... I\n-00065490: 6620 6065 6e74 7279 706f 696e 7460 2069 f `entrypoint` i\n-000654a0: 7320 6769 7665 6e2c 2069 7420 7368 6f75 s given, it shou\n-000654b0: 6c64 2062 6520 616e 2065 6e74 7279 2070 ld be an entry p\n-000654c0: 6f69 6e74 2077 6869 6368 2069 7320 7275 oint which is ru\n-000654d0: 6e20 6173 2074 6865 0a20 2020 2022 6d61 n as the. \"ma\n-000654e0: 696e 2220 6675 6e63 7469 6f6e 2e20 2049 in\" function. I\n-000654f0: 7420 6973 2067 6976 656e 2069 6e20 7468 t is given in th\n-00065500: 6520 6070 6163 6b61 6765 2e6d 6f64 756c e `package.modul\n-00065510: 653a 6675 6e63 2066 6f72 6d61 7460 2073 e:func format` s\n-00065520: 7563 6820 7468 6174 0a20 2020 2074 6865 uch that. the\n-00065530: 2066 6f6c 6c6f 7769 6e67 2063 6f64 6520 following code \n-00065540: 6973 2065 6d69 7474 6564 3a0a 0a20 2020 is emitted:.. \n-00065550: 2020 2020 2066 726f 6d20 7061 636b 6167 from packag\n-00065560: 652e 6d6f 6475 6c65 2069 6d70 6f72 7420 e.module import \n-00065570: 6675 6e63 2061 7320 6d61 696e 0a20 2020 func as main. \n-00065580: 2020 2020 206d 6169 6e28 290a 0a20 2020 main().. \n-00065590: 2041 6464 6974 696f 6e61 6c6c 792c 2069 Additionally, i\n-000655a0: 6620 6061 7267 7360 2069 7320 6769 7665 f `args` is give\n-000655b0: 6e2c 2069 7420 6973 2077 7269 7474 656e n, it is written\n-000655c0: 2076 6572 6261 7469 6d20 6265 7477 6565 verbatim betwee\n-000655d0: 6e20 7468 6520 7061 7265 6e73 0a20 2020 n the parens. \n-000655e0: 206f 6620 7468 6520 6361 6c6c 2074 6f20 of the call to \n-000655f0: 6d61 696e 2028 6965 3a20 6974 2073 686f main (ie: it sho\n-00065600: 756c 6420 616c 7265 6164 7920 6265 2069 uld already be i\n-00065610: 6e20 5079 7468 6f6e 2073 796e 7461 7829 n Python syntax)\n-00065620: 2e0a 2020 2020 2222 220a 0a20 2020 206c .. \"\"\".. l\n-00065630: 6f61 6465 7220 3d20 7265 6164 5f64 6174 oader = read_dat\n-00065640: 615f 6669 6c65 2827 6265 6970 6163 6b5f a_file('beipack_\n-00065650: 6c6f 6164 6572 2e70 7927 290a 2020 2020 loader.py'). \n-00065660: 6c69 6e65 7320 3d20 5b6c 696e 6520 666f lines = [line fo\n-00065670: 7220 6c69 6e65 2069 6e20 6c6f 6164 6572 r line in loader\n-00065680: 2e73 706c 6974 6c69 6e65 7328 2920 6966 .splitlines() if\n-00065690: 206c 696e 655d 0a20 2020 206c 696e 6573 line]. lines\n-000656a0: 2e61 7070 656e 6428 2727 290a 0a20 2020 .append('').. \n-000656b0: 2069 6d70 6f72 7473 203d 207b 2769 6d70 imports = {'imp\n-000656c0: 6f72 7420 7379 7327 7d0a 2020 2020 636f ort sys'}. co\n-000656d0: 6e74 656e 7473 5f74 7874 203d 2064 6963 ntents_txt = dic\n-000656e0: 745f 7265 7072 2863 6f6e 7465 6e74 732c t_repr(contents,\n-000656f0: 2069 6d70 6f72 7473 290a 2020 2020 6c69 imports). li\n-00065700: 6e65 732e 6578 7465 6e64 2869 6d70 6f72 nes.extend(impor\n-00065710: 7473 290a 2020 2020 6c69 6e65 732e 6170 ts). lines.ap\n-00065720: 7065 6e64 2866 2773 7973 2e6d 6574 615f pend(f'sys.meta_\n-00065730: 7061 7468 2e69 6e73 6572 7428 302c 2042 path.insert(0, B\n-00065740: 6569 7061 636b 4c6f 6164 6572 287b 636f eipackLoader({co\n-00065750: 6e74 656e 7473 5f74 7874 7d29 2927 290a ntents_txt}))').\n-00065760: 0a20 2020 2069 6620 656e 7472 7970 6f69 . if entrypoi\n-00065770: 6e74 3a0a 2020 2020 2020 2020 7061 636b nt:. pack\n-00065780: 6167 652c 206d 6169 6e20 3d20 656e 7472 age, main = entr\n-00065790: 7970 6f69 6e74 2e73 706c 6974 2827 3a27 ypoint.split(':'\n-000657a0: 290a 2020 2020 2020 2020 6c69 6e65 732e ). lines.\n-000657b0: 6170 7065 6e64 2866 2766 726f 6d20 7b70 append(f'from {p\n-000657c0: 6163 6b61 6765 7d20 696d 706f 7274 207b ackage} import {\n-000657d0: 6d61 696e 7d20 6173 206d 6169 6e27 290a main} as main').\n-000657e0: 2020 2020 2020 2020 6c69 6e65 732e 6170 lines.ap\n-000657f0: 7065 6e64 2866 276d 6169 6e28 7b61 7267 pend(f'main({arg\n-00065800: 737d 2927 290a 0a20 2020 2072 6574 7572 s})').. retur\n-00065810: 6e20 2727 2e6a 6f69 6e28 6627 7b6c 696e n ''.join(f'{lin\n-00065820: 657d 5c6e 2720 666f 7220 6c69 6e65 2069 e}\\n' for line i\n-00065830: 6e20 6c69 6e65 7329 0a0a 0a64 6566 2063 n lines)...def c\n-00065840: 6f6c 6c65 6374 5f63 6f6e 7465 6e74 7328 ollect_contents(\n-00065850: 6669 6c65 6e61 6d65 733a 204c 6973 745b filenames: List[\n-00065860: 7374 725d 2c0a 2020 2020 2020 2020 2020 str],. \n-00065870: 2020 2020 2020 2020 2020 2072 656c 6174 relat\n-00065880: 6976 655f 746f 3a20 4f70 7469 6f6e 616c ive_to: Optional\n-00065890: 5b73 7472 5d20 3d20 4e6f 6e65 2920 2d3e [str] = None) ->\n-000658a0: 2044 6963 745b 7374 722c 2062 7974 6573 Dict[str, bytes\n-000658b0: 5d3a 0a20 2020 2063 6f6e 7465 6e74 733a ]:. contents:\n-000658c0: 2044 6963 745b 7374 722c 2062 7974 6573 Dict[str, bytes\n-000658d0: 5d20 3d20 7b7d 0a0a 2020 2020 666f 7220 ] = {}.. for \n-000658e0: 6669 6c65 6e61 6d65 2069 6e20 6669 6c65 filename in file\n-000658f0: 6e61 6d65 733a 0a20 2020 2020 2020 2077 names:. w\n-00065900: 6974 6820 6f70 656e 2866 696c 656e 616d ith open(filenam\n-00065910: 652c 2027 7262 2729 2061 7320 6669 6c65 e, 'rb') as file\n-00065920: 3a0a 2020 2020 2020 2020 2020 2020 636f :. co\n-00065930: 6e74 656e 7473 5b6f 732e 7061 7468 2e72 ntents[os.path.r\n-00065940: 656c 7061 7468 2866 696c 656e 616d 652c elpath(filename,\n-00065950: 2073 7461 7274 3d72 656c 6174 6976 655f start=relative_\n-00065960: 746f 295d 203d 2066 696c 652e 7265 6164 to)] = file.read\n-00065970: 2829 0a0a 2020 2020 7265 7475 726e 2063 ().. return c\n-00065980: 6f6e 7465 6e74 730a 0a0a 6465 6620 636f ontents...def co\n-00065990: 6c6c 6563 745f 6d6f 6475 6c65 286e 616d llect_module(nam\n-000659a0: 653a 2073 7472 2c20 2a2c 2072 6563 7572 e: str, *, recur\n-000659b0: 7369 7665 3a20 626f 6f6c 2920 2d3e 2044 sive: bool) -> D\n-000659c0: 6963 745b 7374 722c 2062 7974 6573 5d3a ict[str, bytes]:\n-000659d0: 0a20 2020 2069 6d70 6f72 7420 696d 706f . import impo\n-000659e0: 7274 6c69 622e 7265 736f 7572 6365 730a rtlib.resources.\n-000659f0: 2020 2020 6672 6f6d 2069 6d70 6f72 746c from importl\n-00065a00: 6962 2e72 6573 6f75 7263 6573 2e61 6263 ib.resources.abc\n-00065a10: 2069 6d70 6f72 7420 5472 6176 6572 7361 import Traversa\n-00065a20: 626c 650a 0a20 2020 2064 6566 2077 616c ble.. def wal\n-00065a30: 6b28 7061 7468 3a20 7374 722c 2065 6e74 k(path: str, ent\n-00065a40: 7279 3a20 5472 6176 6572 7361 626c 6529 ry: Traversable)\n-00065a50: 202d 3e20 4974 6572 6162 6c65 5b54 7570 -> Iterable[Tup\n-00065a60: 6c65 5b73 7472 2c20 6279 7465 735d 5d3a le[str, bytes]]:\n-00065a70: 0a20 2020 2020 2020 2066 6f72 2069 7465 . for ite\n-00065a80: 6d20 696e 2065 6e74 7279 2e69 7465 7264 m in entry.iterd\n-00065a90: 6972 2829 3a0a 2020 2020 2020 2020 2020 ir():. \n-00065aa0: 2020 6974 656d 6e61 6d65 203d 2066 277b itemname = f'{\n-00065ab0: 7061 7468 7d2f 7b69 7465 6d2e 6e61 6d65 path}/{item.name\n-00065ac0: 7d27 0a20 2020 2020 2020 2020 2020 2069 }'. i\n-00065ad0: 6620 6974 656d 2e69 735f 6669 6c65 2829 f item.is_file()\n-00065ae0: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n-00065af0: 2020 7969 656c 6420 6974 656d 6e61 6d65 yield itemname\n-00065b00: 2c20 6974 656d 2e72 6561 645f 6279 7465 , item.read_byte\n-00065b10: 7328 290a 2020 2020 2020 2020 2020 2020 s(). \n-00065b20: 656c 6966 2072 6563 7572 7369 7665 2061 elif recursive a\n-00065b30: 6e64 2069 7465 6d2e 6e61 6d65 2021 3d20 nd item.name != \n-00065b40: 275f 5f70 7963 6163 6865 5f5f 273a 0a20 '__pycache__':. \n-00065b50: 2020 2020 2020 2020 2020 2020 2020 2079 y\n-00065b60: 6965 6c64 2066 726f 6d20 7761 6c6b 2869 ield from walk(i\n-00065b70: 7465 6d6e 616d 652c 2069 7465 6d29 0a0a temname, item)..\n-00065b80: 2020 2020 7265 7475 726e 2064 6963 7428 return dict(\n-00065b90: 7761 6c6b 286e 616d 652e 7265 706c 6163 walk(name.replac\n-00065ba0: 6528 272e 272c 2027 2f27 292c 2069 6d70 e('.', '/'), imp\n-00065bb0: 6f72 746c 6962 2e72 6573 6f75 7263 6573 ortlib.resources\n-00065bc0: 2e66 696c 6573 286e 616d 6529 2929 0a0a .files(name)))..\n-00065bd0: 0a64 6566 2063 6f6c 6c65 6374 5f7a 6970 .def collect_zip\n-00065be0: 2866 696c 656e 616d 653a 2073 7472 2920 (filename: str) \n-00065bf0: 2d3e 2044 6963 745b 7374 722c 2062 7974 -> Dict[str, byt\n-00065c00: 6573 5d3a 0a20 2020 2063 6f6e 7465 6e74 es]:. content\n-00065c10: 7320 3d20 7b7d 0a0a 2020 2020 7769 7468 s = {}.. with\n-00065c20: 207a 6970 6669 6c65 2e5a 6970 4669 6c65 zipfile.ZipFile\n-00065c30: 2866 696c 656e 616d 6529 2061 7320 6669 (filename) as fi\n-00065c40: 6c65 3a0a 2020 2020 2020 2020 666f 7220 le:. for \n-00065c50: 656e 7472 7920 696e 2066 696c 652e 6669 entry in file.fi\n-00065c60: 6c65 6c69 7374 3a0a 2020 2020 2020 2020 lelist:. \n-00065c70: 2020 2020 6966 2027 2e64 6973 742d 696e if '.dist-in\n-00065c80: 666f 2f27 2069 6e20 656e 7472 792e 6669 fo/' in entry.fi\n-00065c90: 6c65 6e61 6d65 3a0a 2020 2020 2020 2020 lename:. \n-00065ca0: 2020 2020 2020 2020 636f 6e74 696e 7565 continue\n-00065cb0: 0a20 2020 2020 2020 2020 2020 2063 6f6e . con\n-00065cc0: 7465 6e74 735b 656e 7472 792e 6669 6c65 tents[entry.file\n-00065cd0: 6e61 6d65 5d20 3d20 6669 6c65 2e72 6561 name] = file.rea\n-00065ce0: 6428 656e 7472 7929 0a0a 2020 2020 7265 d(entry).. re\n-00065cf0: 7475 726e 2063 6f6e 7465 6e74 730a 0a0a turn contents...\n-00065d00: 6465 6620 636f 6c6c 6563 745f 7065 7035 def collect_pep5\n-00065d10: 3137 2870 6174 683a 2073 7472 2920 2d3e 17(path: str) ->\n-00065d20: 2044 6963 745b 7374 722c 2062 7974 6573 Dict[str, bytes\n-00065d30: 5d3a 0a20 2020 2077 6974 6820 7465 6d70 ]:. with temp\n-00065d40: 6669 6c65 2e54 656d 706f 7261 7279 4469 file.TemporaryDi\n-00065d50: 7265 6374 6f72 7928 2920 6173 2074 6d70 rectory() as tmp\n-00065d60: 6469 723a 0a20 2020 2020 2020 2069 6d70 dir:. imp\n-00065d70: 6f72 7420 6275 696c 640a 2020 2020 2020 ort build. \n-00065d80: 2020 6275 696c 6465 7220 3d20 6275 696c builder = buil\n-00065d90: 642e 5072 6f6a 6563 7442 7569 6c64 6572 d.ProjectBuilder\n-00065da0: 2870 6174 6829 0a20 2020 2020 2020 2077 (path). w\n-00065db0: 6865 656c 203d 2062 7569 6c64 6572 2e62 heel = builder.b\n-00065dc0: 7569 6c64 2827 7768 6565 6c27 2c20 746d uild('wheel', tm\n-00065dd0: 7064 6972 290a 2020 2020 2020 2020 7265 pdir). re\n-00065de0: 7475 726e 2063 6f6c 6c65 6374 5f7a 6970 turn collect_zip\n-00065df0: 2877 6865 656c 290a 0a0a 6465 6620 6d61 (wheel)...def ma\n-00065e00: 696e 2829 202d 3e20 4e6f 6e65 3a0a 2020 in() -> None:. \n-00065e10: 2020 7061 7273 6572 203d 2061 7267 7061 parser = argpa\n-00065e20: 7273 652e 4172 6775 6d65 6e74 5061 7273 rse.ArgumentPars\n-00065e30: 6572 2829 0a20 2020 2070 6172 7365 722e er(). parser.\n-00065e40: 6164 645f 6172 6775 6d65 6e74 2827 2d2d add_argument('--\n-00065e50: 7079 7468 6f6e 272c 2027 2d70 272c 0a20 python', '-p',. \n-00065e60: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00065e70: 2020 2020 2020 2068 656c 703d 2261 6464 help=\"add\n-00065e80: 2061 2023 2170 7974 686f 6e33 2069 6e74 a #!python3 int\n-00065e90: 6572 7072 6574 6572 206c 696e 6520 7573 erpreter line us\n-00065ea0: 696e 6720 7468 6520 6769 7665 6e20 7061 ing the given pa\n-00065eb0: 7468 2229 0a20 2020 2070 6172 7365 722e th\"). parser.\n-00065ec0: 6164 645f 6172 6775 6d65 6e74 2827 2d2d add_argument('--\n-00065ed0: 787a 272c 2027 2d4a 272c 2061 6374 696f xz', '-J', actio\n-00065ee0: 6e3d 2773 746f 7265 5f74 7275 6527 2c0a n='store_true',.\n-00065ef0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00065f00: 2020 2020 2020 2020 6865 6c70 3d22 636f help=\"co\n-00065f10: 6d70 7265 7373 2074 6865 206f 7574 7075 mpress the outpu\n-00065f20: 7420 7769 7468 2060 787a 6022 290a 2020 t with `xz`\"). \n-00065f30: 2020 7061 7273 6572 2e61 6464 5f61 7267 parser.add_arg\n-00065f40: 756d 656e 7428 272d 2d74 6f70 6469 7227 ument('--topdir'\n-00065f50: 2c0a 2020 2020 2020 2020 2020 2020 2020 ,. \n-00065f60: 2020 2020 2020 2020 2020 6865 6c70 3d22 help=\"\n-00065f70: 746f 706c 6576 656c 2064 6972 6563 746f toplevel directo\n-00065f80: 7279 2028 7061 7468 7320 6172 6520 7374 ry (paths are st\n-00065f90: 6f72 6564 2072 656c 6174 6976 6520 746f ored relative to\n-00065fa0: 2074 6869 7329 2229 0a20 2020 2070 6172 this)\"). par\n-00065fb0: 7365 722e 6164 645f 6172 6775 6d65 6e74 ser.add_argument\n-00065fc0: 2827 2d2d 6f75 7470 7574 272c 2027 2d6f ('--output', '-o\n-00065fd0: 272c 0a20 2020 2020 2020 2020 2020 2020 ',. \n-00065fe0: 2020 2020 2020 2020 2020 2068 656c 703d help=\n-00065ff0: 2277 7269 7465 206f 7574 7075 7420 746f \"write output to\n-00066000: 2061 2066 696c 6520 2864 6566 6175 6c74 a file (default\n-00066010: 3a20 7374 646f 7574 2922 290a 2020 2020 : stdout)\"). \n-00066020: 7061 7273 6572 2e61 6464 5f61 7267 756d parser.add_argum\n-00066030: 656e 7428 272d 2d6d 6169 6e27 2c20 272d ent('--main', '-\n-00066040: 6d27 2c20 6d65 7461 7661 723d 274d 4f44 m', metavar='MOD\n-00066050: 554c 453a 4655 4e43 272c 0a20 2020 2020 ULE:FUNC',. \n-00066060: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00066070: 2020 2068 656c 703d 2275 7365 2046 554e help=\"use FUN\n-00066080: 4320 6672 6f6d 204d 4f44 554c 4520 6173 C from MODULE as\n-00066090: 2074 6865 206d 6169 6e20 6675 6e63 7469 the main functi\n-000660a0: 6f6e 2229 0a20 2020 2070 6172 7365 722e on\"). parser.\n-000660b0: 6164 645f 6172 6775 6d65 6e74 2827 2d2d add_argument('--\n-000660c0: 6d61 696e 2d61 7267 7327 2c20 6d65 7461 main-args', meta\n-000660d0: 7661 723d 2741 5247 5327 2c0a 2020 2020 var='ARGS',. \n-000660e0: 2020 2020 2020 2020 2020 2020 2020 2020 \n-000660f0: 2020 2020 6865 6c70 3d22 6172 6775 6d65 help=\"argume\n-00066100: 6e74 7320 746f 206d 6169 6e28 2920 696e nts to main() in\n-00066110: 2050 7974 686f 6e20 7379 6e74 6178 222c Python syntax\",\n-00066120: 2064 6566 6175 6c74 3d27 2729 0a20 2020 default=''). \n-00066130: 2070 6172 7365 722e 6164 645f 6172 6775 parser.add_argu\n-00066140: 6d65 6e74 2827 2d2d 6d6f 6475 6c65 272c ment('--module',\n-00066150: 2061 6374 696f 6e3d 2761 7070 656e 6427 action='append'\n-00066160: 2c20 6465 6661 756c 743d 5b5d 2c0a 2020 , default=[],. \n-00066170: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00066180: 2020 2020 2020 6865 6c70 3d22 636f 6c6c help=\"coll\n-00066190: 6563 7420 696e 7374 616c 6c65 6420 6d6f ect installed mo\n-000661a0: 6475 6c65 7320 2872 6563 7572 7369 7665 dules (recursive\n-000661b0: 6c79 2922 290a 2020 2020 7061 7273 6572 ly)\"). parser\n-000661c0: 2e61 6464 5f61 7267 756d 656e 7428 272d .add_argument('-\n-000661d0: 2d7a 6970 272c 2027 2d7a 272c 2061 6374 -zip', '-z', act\n-000661e0: 696f 6e3d 2761 7070 656e 6427 2c20 6465 ion='append', de\n-000661f0: 6661 756c 743d 5b5d 2c0a 2020 2020 2020 fault=[],. \n-00066200: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00066210: 2020 6865 6c70 3d22 696e 636c 7564 6520 help=\"include \n-00066220: 6669 6c65 7320 6672 6f6d 2061 207a 6970 files from a zip\n-00066230: 6669 6c65 2028 6f72 2077 6865 656c 2922 file (or wheel)\"\n-00066240: 290a 2020 2020 7061 7273 6572 2e61 6464 ). parser.add\n-00066250: 5f61 7267 756d 656e 7428 272d 2d62 7569 _argument('--bui\n-00066260: 6c64 272c 206d 6574 6176 6172 3d27 4449 ld', metavar='DI\n-00066270: 5227 2c20 6163 7469 6f6e 3d27 6170 7065 R', action='appe\n-00066280: 6e64 272c 2064 6566 6175 6c74 3d5b 5d2c nd', default=[],\n-00066290: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n-000662a0: 2020 2020 2020 2020 2068 656c 703d 2250 help=\"P\n-000662b0: 4550 2d35 3137 2066 726f 6d20 6120 6769 EP-517 from a gi\n-000662c0: 7665 6e20 736f 7572 6365 2064 6972 6563 ven source direc\n-000662d0: 746f 7279 2229 0a20 2020 2070 6172 7365 tory\"). parse\n-000662e0: 722e 6164 645f 6172 6775 6d65 6e74 2827 r.add_argument('\n-000662f0: 6669 6c65 7327 2c20 6e61 7267 733d 272a files', nargs='*\n-00066300: 272c 0a20 2020 2020 2020 2020 2020 2020 ',. \n-00066310: 2020 2020 2020 2020 2020 2068 656c 703d help=\n-00066320: 2266 696c 6573 2074 6f20 696e 636c 7564 \"files to includ\n-00066330: 6520 696e 2074 6865 2062 6569 7061 636b e in the beipack\n-00066340: 2229 0a20 2020 2061 7267 7320 3d20 7061 \"). args = pa\n-00066350: 7273 6572 2e70 6172 7365 5f61 7267 7328 rser.parse_args(\n-00066360: 290a 0a20 2020 2063 6f6e 7465 6e74 7320 ).. contents \n-00066370: 3d20 636f 6c6c 6563 745f 636f 6e74 656e = collect_conten\n-00066380: 7473 2861 7267 732e 6669 6c65 732c 2072 ts(args.files, r\n-00066390: 656c 6174 6976 655f 746f 3d61 7267 732e elative_to=args.\n-000663a0: 746f 7064 6972 290a 0a20 2020 2066 6f72 topdir).. for\n-000663b0: 2066 696c 6520 696e 2061 7267 732e 7a69 file in args.zi\n-000663c0: 703a 0a20 2020 2020 2020 2063 6f6e 7465 p:. conte\n-000663d0: 6e74 732e 7570 6461 7465 2863 6f6c 6c65 nts.update(colle\n-000663e0: 6374 5f7a 6970 2866 696c 6529 290a 0a20 ct_zip(file)).. \n-000663f0: 2020 2066 6f72 206e 616d 6520 696e 2061 for name in a\n-00066400: 7267 732e 6d6f 6475 6c65 3a0a 2020 2020 rgs.module:. \n-00066410: 2020 2020 636f 6e74 656e 7473 2e75 7064 contents.upd\n-00066420: 6174 6528 636f 6c6c 6563 745f 6d6f 6475 ate(collect_modu\n-00066430: 6c65 286e 616d 652c 2072 6563 7572 7369 le(name, recursi\n-00066440: 7665 3d54 7275 6529 290a 0a20 2020 2066 ve=True)).. f\n-00066450: 6f72 2070 6174 6820 696e 2061 7267 732e or path in args.\n-00066460: 6275 696c 643a 0a20 2020 2020 2020 2063 build:. c\n-00066470: 6f6e 7465 6e74 732e 7570 6461 7465 2863 ontents.update(c\n-00066480: 6f6c 6c65 6374 5f70 6570 3531 3728 7061 ollect_pep517(pa\n-00066490: 7468 2929 0a0a 2020 2020 7265 7375 6c74 th)).. result\n-000664a0: 203d 2070 6163 6b28 636f 6e74 656e 7473 = pack(contents\n-000664b0: 2c20 6172 6773 2e6d 6169 6e2c 2061 7267 , args.main, arg\n-000664c0: 732e 6d61 696e 5f61 7267 7329 2e65 6e63 s.main_args).enc\n-000664d0: 6f64 6528 2775 7466 2d38 2729 0a0a 2020 ode('utf-8').. \n-000664e0: 2020 6966 2061 7267 732e 7079 7468 6f6e if args.python\n-000664f0: 3a0a 2020 2020 2020 2020 7265 7375 6c74 :. result\n-00066500: 203d 2062 2723 2127 202b 2061 7267 732e = b'#!' + args.\n-00066510: 7079 7468 6f6e 2e65 6e63 6f64 6528 2761 python.encode('a\n-00066520: 7363 6969 2729 202b 2062 275c 6e27 202b scii') + b'\\n' +\n-00066530: 2072 6573 756c 740a 0a20 2020 2069 6620 result.. if \n-00066540: 6172 6773 2e78 7a3a 0a20 2020 2020 2020 args.xz:. \n-00066550: 2072 6573 756c 7420 3d20 6c7a 6d61 2e63 result = lzma.c\n-00066560: 6f6d 7072 6573 7328 7265 7375 6c74 2c20 ompress(result, \n-00066570: 7072 6573 6574 3d6c 7a6d 612e 5052 4553 preset=lzma.PRES\n-00066580: 4554 5f45 5854 5245 4d45 290a 0a20 2020 ET_EXTREME).. \n-00066590: 2069 6620 6172 6773 2e6f 7574 7075 743a if args.output:\n-000665a0: 0a20 2020 2020 2020 2077 6974 6820 6f70 . with op\n-000665b0: 656e 2861 7267 732e 6f75 7470 7574 2c20 en(args.output, \n-000665c0: 2777 6227 2920 6173 2066 696c 653a 0a20 'wb') as file:. \n-000665d0: 2020 2020 2020 2020 2020 2066 696c 652e file.\n-000665e0: 7772 6974 6528 7265 7375 6c74 290a 2020 write(result). \n-000665f0: 2020 656c 7365 3a0a 2020 2020 2020 2020 else:. \n-00066600: 6966 2061 7267 732e 787a 2061 6e64 206f if args.xz and o\n-00066610: 732e 6973 6174 7479 2831 293a 0a20 2020 s.isatty(1):. \n-00066620: 2020 2020 2020 2020 2073 7973 2e65 7869 sys.exi\n-00066630: 7428 2772 6566 7573 696e 6720 746f 2077 t('refusing to w\n-00066640: 7269 7465 2063 6f6d 7072 6573 7365 6420 rite compressed \n-00066650: 6f75 7470 7574 2074 6f20 6120 7465 726d output to a term\n-00066660: 696e 616c 2729 0a20 2020 2020 2020 2073 inal'). s\n-00066670: 7973 2e73 7464 6f75 742e 6275 6666 6572 ys.stdout.buffer\n-00066680: 2e77 7269 7465 2872 6573 756c 7429 0a0a .write(result)..\n-00066690: 0a69 6620 5f5f 6e61 6d65 5f5f 203d 3d20 .if __name__ == \n-000666a0: 275f 5f6d 6169 6e5f 5f27 3a0a 2020 2020 '__main__':. \n-000666b0: 6d61 696e 2829 0a27 2727 2c0a 2020 2763 main().''',. 'c\n-000666c0: 6f63 6b70 6974 2f5f 7665 6e64 6f72 2f62 ockpit/_vendor/b\n-000666d0: 6569 2f64 6174 612f 6265 6970 6163 6b5f ei/data/beipack_\n-000666e0: 6c6f 6164 6572 2e70 7927 3a20 6272 2727 loader.py': br''\n-000666f0: 2723 2062 6569 7061 636b 2068 7474 7073 '# beipack https\n-00066700: 3a2f 2f67 6974 6875 622e 636f 6d2f 616c ://github.com/al\n-00066710: 6c69 736f 6e6b 6172 6c69 7473 6b61 7961 lisonkarlitskaya\n-00066720: 2f62 6569 7061 636b 0a0a 696d 706f 7274 /beipack..import\n-00066730: 2069 6d70 6f72 746c 6962 2e61 6263 0a69 importlib.abc.i\n-00066740: 6d70 6f72 7420 696d 706f 7274 6c69 622e mport importlib.\n-00066750: 7574 696c 0a69 6d70 6f72 7420 696f 0a69 util.import io.i\n-00066760: 6d70 6f72 7420 7379 730a 6672 6f6d 2074 mport sys.from t\n-00066770: 7970 6573 2069 6d70 6f72 7420 4d6f 6475 ypes import Modu\n-00066780: 6c65 5479 7065 0a66 726f 6d20 7479 7069 leType.from typi\n-00066790: 6e67 2069 6d70 6f72 7420 4269 6e61 7279 ng import Binary\n-000667a0: 494f 2c20 4469 6374 2c20 4974 6572 6174 IO, Dict, Iterat\n-000667b0: 6f72 2c20 4f70 7469 6f6e 616c 2c20 5365 or, Optional, Se\n-000667c0: 7175 656e 6365 0a0a 0a63 6c61 7373 2042 quence...class B\n-000667d0: 6569 7061 636b 4c6f 6164 6572 2869 6d70 eipackLoader(imp\n-000667e0: 6f72 746c 6962 2e61 6263 2e53 6f75 7263 ortlib.abc.Sourc\n-000667f0: 654c 6f61 6465 722c 2069 6d70 6f72 746c eLoader, importl\n-00066800: 6962 2e61 6263 2e4d 6574 6150 6174 6846 ib.abc.MetaPathF\n-00066810: 696e 6465 7229 3a0a 2020 2020 6966 2073 inder):. if s\n-00066820: 7973 2e76 6572 7369 6f6e 5f69 6e66 6f20 ys.version_info \n-00066830: 3e3d 2028 332c 2031 3129 3a0a 2020 2020 >= (3, 11):. \n-00066840: 2020 2020 6672 6f6d 2069 6d70 6f72 746c from importl\n-00066850: 6962 2e72 6573 6f75 7263 6573 2e61 6263 ib.resources.abc\n-00066860: 2069 6d70 6f72 7420 5265 736f 7572 6365 import Resource\n-00066870: 5265 6164 6572 2061 7320 4162 7374 7261 Reader as Abstra\n-00066880: 6374 5265 736f 7572 6365 5265 6164 6572 ctResourceReader\n-00066890: 0a20 2020 2065 6c73 653a 0a20 2020 2020 . else:. \n-000668a0: 2020 2041 6273 7472 6163 7452 6573 6f75 AbstractResou\n-000668b0: 7263 6552 6561 6465 7220 3d20 6f62 6a65 rceReader = obje\n-000668c0: 6374 0a0a 2020 2020 636c 6173 7320 5265 ct.. class Re\n-000668d0: 736f 7572 6365 5265 6164 6572 2841 6273 sourceReader(Abs\n-000668e0: 7472 6163 7452 6573 6f75 7263 6552 6561 tractResourceRea\n-000668f0: 6465 7229 3a0a 2020 2020 2020 2020 6465 der):. de\n-00066900: 6620 5f5f 696e 6974 5f5f 2873 656c 662c f __init__(self,\n-00066910: 2063 6f6e 7465 6e74 733a 2044 6963 745b contents: Dict[\n-00066920: 7374 722c 2062 7974 6573 5d2c 2066 696c str, bytes], fil\n-00066930: 656e 616d 653a 2073 7472 2920 2d3e 204e ename: str) -> N\n-00066940: 6f6e 653a 0a20 2020 2020 2020 2020 2020 one:. \n-00066950: 2073 656c 662e 5f63 6f6e 7465 6e74 7320 self._contents \n-00066960: 3d20 636f 6e74 656e 7473 0a20 2020 2020 = contents. \n-00066970: 2020 2020 2020 2073 656c 662e 5f64 6972 self._dir\n-00066980: 203d 2066 277b 6669 6c65 6e61 6d65 7d2f = f'{filename}/\n-00066990: 270a 0a20 2020 2020 2020 2064 6566 2069 '.. def i\n-000669a0: 735f 7265 736f 7572 6365 2873 656c 662c s_resource(self,\n-000669b0: 2072 6573 6f75 7263 653a 2073 7472 2920 resource: str) \n-000669c0: 2d3e 2062 6f6f 6c3a 0a20 2020 2020 2020 -> bool:. \n-000669d0: 2020 2020 2072 6574 7572 6e20 6627 7b73 return f'{s\n-000669e0: 656c 662e 5f64 6972 7d7b 7265 736f 7572 elf._dir}{resour\n-000669f0: 6365 7d27 2069 6e20 7365 6c66 2e5f 636f ce}' in self._co\n-00066a00: 6e74 656e 7473 0a0a 2020 2020 2020 2020 ntents.. \n-00066a10: 6465 6620 6f70 656e 5f72 6573 6f75 7263 def open_resourc\n-00066a20: 6528 7365 6c66 2c20 7265 736f 7572 6365 e(self, resource\n-00066a30: 3a20 7374 7229 202d 3e20 4269 6e61 7279 : str) -> Binary\n-00066a40: 494f 3a0a 2020 2020 2020 2020 2020 2020 IO:. \n-00066a50: 7265 7475 726e 2069 6f2e 4279 7465 7349 return io.BytesI\n-00066a60: 4f28 7365 6c66 2e5f 636f 6e74 656e 7473 O(self._contents\n-00066a70: 5b66 277b 7365 6c66 2e5f 6469 727d 7b72 [f'{self._dir}{r\n-00066a80: 6573 6f75 7263 657d 275d 290a 0a20 2020 esource}']).. \n-00066a90: 2020 2020 2064 6566 2072 6573 6f75 7263 def resourc\n-00066aa0: 655f 7061 7468 2873 656c 662c 2072 6573 e_path(self, res\n-00066ab0: 6f75 7263 653a 2073 7472 2920 2d3e 2073 ource: str) -> s\n-00066ac0: 7472 3a0a 2020 2020 2020 2020 2020 2020 tr:. \n-00066ad0: 7261 6973 6520 4669 6c65 4e6f 7446 6f75 raise FileNotFou\n-00066ae0: 6e64 4572 726f 720a 0a20 2020 2020 2020 ndError.. \n-00066af0: 2064 6566 2063 6f6e 7465 6e74 7328 7365 def contents(se\n-00066b00: 6c66 2920 2d3e 2049 7465 7261 746f 725b lf) -> Iterator[\n-00066b10: 7374 725d 3a0a 2020 2020 2020 2020 2020 str]:. \n-00066b20: 2020 6469 725f 6c65 6e67 7468 203d 206c dir_length = l\n-00066b30: 656e 2873 656c 662e 5f64 6972 290a 2020 en(self._dir). \n-00066b40: 2020 2020 2020 2020 2020 7265 7375 6c74 result\n-00066b50: 203d 2073 6574 2829 0a0a 2020 2020 2020 = set().. \n-00066b60: 2020 2020 2020 666f 7220 6669 6c65 6e61 for filena\n-00066b70: 6d65 2069 6e20 7365 6c66 2e5f 636f 6e74 me in self._cont\n-00066b80: 656e 7473 3a0a 2020 2020 2020 2020 2020 ents:. \n-00066b90: 2020 2020 2020 6966 2066 696c 656e 616d if filenam\n-00066ba0: 652e 7374 6172 7473 7769 7468 2873 656c e.startswith(sel\n-00066bb0: 662e 5f64 6972 293a 0a20 2020 2020 2020 f._dir):. \n-00066bc0: 2020 2020 2020 2020 2020 2020 2074 7279 try\n-00066bd0: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n-00066be0: 2020 2020 2020 2020 2020 6e65 7874 5f73 next_s\n-00066bf0: 6c61 7368 203d 2066 696c 656e 616d 652e lash = filename.\n-00066c00: 696e 6465 7828 272f 272c 2064 6972 5f6c index('/', dir_l\n-00066c10: 656e 6774 6829 0a20 2020 2020 2020 2020 ength). \n-00066c20: 2020 2020 2020 2020 2020 2065 7863 6570 excep\n-00066c30: 7420 5661 6c75 6545 7272 6f72 3a0a 2020 t ValueError:. \n-00066c40: 2020 2020 2020 2020 2020 2020 2020 2020 \n-00066c50: 2020 2020 2020 6e65 7874 5f73 6c61 7368 next_slash\n-00066c60: 203d 204e 6f6e 650a 2020 2020 2020 2020 = None. \n-00066c70: 2020 2020 2020 2020 2020 2020 7265 7375 resu\n-00066c80: 6c74 2e61 6464 2866 696c 656e 616d 655b lt.add(filename[\n-00066c90: 6469 725f 6c65 6e67 7468 3a6e 6578 745f dir_length:next_\n-00066ca0: 736c 6173 685d 290a 0a20 2020 2020 2020 slash]).. \n-00066cb0: 2020 2020 2072 6574 7572 6e20 6974 6572 return iter\n-00066cc0: 2872 6573 756c 7429 0a0a 2020 2020 636f (result).. co\n-00066cd0: 6e74 656e 7473 3a20 4469 6374 5b73 7472 ntents: Dict[str\n-00066ce0: 2c20 6279 7465 735d 0a20 2020 206d 6f64 , bytes]. mod\n-00066cf0: 756c 6573 3a20 4469 6374 5b73 7472 2c20 ules: Dict[str, \n-00066d00: 7374 725d 0a0a 2020 2020 6465 6620 5f5f str].. def __\n-00066d10: 696e 6974 5f5f 2873 656c 662c 2063 6f6e init__(self, con\n-00066d20: 7465 6e74 733a 2044 6963 745b 7374 722c tents: Dict[str,\n-00066d30: 2062 7974 6573 5d29 202d 3e20 4e6f 6e65 bytes]) -> None\n-00066d40: 3a0a 2020 2020 2020 2020 7472 793a 0a20 :. try:. \n-00066d50: 2020 2020 2020 2020 2020 2063 6f6e 7465 conte\n-00066d60: 6e74 735b 5f5f 6669 6c65 5f5f 5d20 3d20 nts[__file__] = \n-00066d70: 5f5f 7365 6c66 5f73 6f75 7263 655f 5f20 __self_source__ \n-00066d80: 2023 2074 7970 653a 2069 676e 6f72 655b # type: ignore[\n-00066d90: 6e61 6d65 2d64 6566 696e 6564 5d0a 2020 name-defined]. \n-00066da0: 2020 2020 2020 6578 6365 7074 204e 616d except Nam\n-00066db0: 6545 7272 6f72 3a0a 2020 2020 2020 2020 eError:. \n-00066dc0: 2020 2020 7061 7373 0a0a 2020 2020 2020 pass.. \n-00066dd0: 2020 7365 6c66 2e63 6f6e 7465 6e74 7320 self.contents \n-00066de0: 3d20 636f 6e74 656e 7473 0a20 2020 2020 = contents. \n-00066df0: 2020 2073 656c 662e 6d6f 6475 6c65 7320 self.modules \n-00066e00: 3d20 7b0a 2020 2020 2020 2020 2020 2020 = {. \n-00066e10: 7365 6c66 2e67 6574 5f66 756c 6c6e 616d self.get_fullnam\n-00066e20: 6528 6669 6c65 6e61 6d65 293a 2066 696c e(filename): fil\n-00066e30: 656e 616d 650a 2020 2020 2020 2020 2020 ename. \n-00066e40: 2020 666f 7220 6669 6c65 6e61 6d65 2069 for filename i\n-00066e50: 6e20 636f 6e74 656e 7473 0a20 2020 2020 n contents. \n-00066e60: 2020 2020 2020 2069 6620 6669 6c65 6e61 if filena\n-00066e70: 6d65 2e65 6e64 7377 6974 6828 222e 7079 me.endswith(\".py\n-00066e80: 2229 0a20 2020 2020 2020 207d 0a0a 2020 \"). }.. \n-00066e90: 2020 6465 6620 6765 745f 6675 6c6c 6e61 def get_fullna\n-00066ea0: 6d65 2873 656c 662c 2066 696c 656e 616d me(self, filenam\n-00066eb0: 653a 2073 7472 2920 2d3e 2073 7472 3a0a e: str) -> str:.\n-00066ec0: 2020 2020 2020 2020 6173 7365 7274 2066 assert f\n-00066ed0: 696c 656e 616d 652e 656e 6473 7769 7468 ilename.endswith\n-00066ee0: 2822 2e70 7922 290a 2020 2020 2020 2020 (\".py\"). \n-00066ef0: 6669 6c65 6e61 6d65 203d 2066 696c 656e filename = filen\n-00066f00: 616d 655b 3a2d 335d 0a20 2020 2020 2020 ame[:-3]. \n-00066f10: 2069 6620 6669 6c65 6e61 6d65 2e65 6e64 if filename.end\n-00066f20: 7377 6974 6828 222f 5f5f 696e 6974 5f5f swith(\"/__init__\n-00066f30: 2229 3a0a 2020 2020 2020 2020 2020 2020 \"):. \n-00066f40: 6669 6c65 6e61 6d65 203d 2066 696c 656e filename = filen\n-00066f50: 616d 655b 3a2d 395d 0a20 2020 2020 2020 ame[:-9]. \n-00066f60: 2072 6574 7572 6e20 6669 6c65 6e61 6d65 return filename\n-00066f70: 2e72 6570 6c61 6365 2822 2f22 2c20 222e .replace(\"/\", \".\n-00066f80: 2229 0a0a 2020 2020 6465 6620 6765 745f \").. def get_\n-00066f90: 7265 736f 7572 6365 5f72 6561 6465 7228 resource_reader(\n-00066fa0: 7365 6c66 2c20 6675 6c6c 6e61 6d65 3a20 self, fullname: \n-00066fb0: 7374 7229 202d 3e20 5265 736f 7572 6365 str) -> Resource\n-00066fc0: 5265 6164 6572 3a0a 2020 2020 2020 2020 Reader:. \n-00066fd0: 7265 7475 726e 2042 6569 7061 636b 4c6f return BeipackLo\n-00066fe0: 6164 6572 2e52 6573 6f75 7263 6552 6561 ader.ResourceRea\n-00066ff0: 6465 7228 7365 6c66 2e63 6f6e 7465 6e74 der(self.content\n-00067000: 732c 2066 756c 6c6e 616d 652e 7265 706c s, fullname.repl\n-00067010: 6163 6528 272e 272c 2027 2f27 2929 0a0a ace('.', '/'))..\n-00067020: 2020 2020 6465 6620 6765 745f 6461 7461 def get_data\n-00067030: 2873 656c 662c 2070 6174 683a 2073 7472 (self, path: str\n-00067040: 2920 2d3e 2062 7974 6573 3a0a 2020 2020 ) -> bytes:. \n-00067050: 2020 2020 7265 7475 726e 2073 656c 662e return self.\n-00067060: 636f 6e74 656e 7473 5b70 6174 685d 0a0a contents[path]..\n-00067070: 2020 2020 6465 6620 6765 745f 6669 6c65 def get_file\n-00067080: 6e61 6d65 2873 656c 662c 2066 756c 6c6e name(self, fulln\n-00067090: 616d 653a 2073 7472 2920 2d3e 2073 7472 ame: str) -> str\n-000670a0: 3a0a 2020 2020 2020 2020 7265 7475 726e :. return\n-000670b0: 2073 656c 662e 6d6f 6475 6c65 735b 6675 self.modules[fu\n-000670c0: 6c6c 6e61 6d65 5d0a 0a20 2020 2064 6566 llname].. def\n-000670d0: 2066 696e 645f 7370 6563 280a 2020 2020 find_spec(. \n-000670e0: 2020 2020 7365 6c66 2c0a 2020 2020 2020 self,. \n-000670f0: 2020 6675 6c6c 6e61 6d65 3a20 7374 722c fullname: str,\n-00067100: 0a20 2020 2020 2020 2070 6174 683a 204f . path: O\n-00067110: 7074 696f 6e61 6c5b 5365 7175 656e 6365 ptional[Sequence\n-00067120: 5b73 7472 5d5d 2c0a 2020 2020 2020 2020 [str]],. \n-00067130: 7461 7267 6574 3a20 4f70 7469 6f6e 616c target: Optional\n-00067140: 5b4d 6f64 756c 6554 7970 655d 203d 204e [ModuleType] = N\n-00067150: 6f6e 650a 2020 2020 2020 2920 2d3e 204f one. ) -> O\n-00067160: 7074 696f 6e61 6c5b 696d 706f 7274 6c69 ptional[importli\n-00067170: 622e 6d61 6368 696e 6572 792e 4d6f 6475 b.machinery.Modu\n-00067180: 6c65 5370 6563 5d3a 0a20 2020 2020 2020 leSpec]:. \n-00067190: 2069 6620 6675 6c6c 6e61 6d65 206e 6f74 if fullname not\n-000671a0: 2069 6e20 7365 6c66 2e6d 6f64 756c 6573 in self.modules\n-000671b0: 3a0a 2020 2020 2020 2020 2020 2020 7265 :. re\n-000671c0: 7475 726e 204e 6f6e 650a 2020 2020 2020 turn None. \n-000671d0: 2020 7265 7475 726e 2069 6d70 6f72 746c return importl\n-000671e0: 6962 2e75 7469 6c2e 7370 6563 5f66 726f ib.util.spec_fro\n-000671f0: 6d5f 6c6f 6164 6572 2866 756c 6c6e 616d m_loader(fullnam\n-00067200: 652c 2073 656c 6629 0a27 2727 2c0a 2020 e, self).''',. \n-00067210: 2763 6f63 6b70 6974 2f5f 7665 6e64 6f72 'cockpit/_vendor\n-00067220: 2f62 6569 2f64 6174 612f 5f5f 696e 6974 /bei/data/__init\n-00067230: 5f5f 2e70 7927 3a20 6272 2727 2769 6d70 __.py': br'''imp\n-00067240: 6f72 7420 7379 730a 0a69 6620 7379 732e ort sys..if sys.\n-00067250: 7665 7273 696f 6e5f 696e 666f 203e 3d20 version_info >= \n-00067260: 2833 2c20 3929 3a0a 2020 2020 696d 706f (3, 9):. impo\n-00067270: 7274 2069 6d70 6f72 746c 6962 2e61 6263 rt importlib.abc\n-00067280: 0a20 2020 2069 6d70 6f72 7420 696d 706f . import impo\n-00067290: 7274 6c69 622e 7265 736f 7572 6365 730a rtlib.resources.\n-000672a0: 0a20 2020 2064 6566 2072 6561 645f 6461 . def read_da\n-000672b0: 7461 5f66 696c 6528 6669 6c65 6e61 6d65 ta_file(filename\n-000672c0: 3a20 7374 7229 202d 3e20 7374 723a 0a20 : str) -> str:. \n-000672d0: 2020 2020 2020 2072 6574 7572 6e20 2869 return (i\n-000672e0: 6d70 6f72 746c 6962 2e72 6573 6f75 7263 mportlib.resourc\n-000672f0: 6573 2e66 696c 6573 285f 5f6e 616d 655f es.files(__name_\n-00067300: 5f29 202f 2066 696c 656e 616d 6529 2e72 _) / filename).r\n-00067310: 6561 645f 7465 7874 2829 0a65 6c73 653a ead_text().else:\n-00067320: 0a20 2020 2064 6566 2072 6561 645f 6461 . def read_da\n-00067330: 7461 5f66 696c 6528 6669 6c65 6e61 6d65 ta_file(filename\n-00067340: 3a20 7374 7229 202d 3e20 7374 723a 0a20 : str) -> str:. \n-00067350: 2020 2020 2020 206c 6f61 6465 7220 3d20 loader = \n-00067360: 5f5f 6c6f 6164 6572 5f5f 2020 2320 7479 __loader__ # ty\n-00067370: 7065 3a20 6967 6e6f 7265 5b6e 616d 652d pe: ignore[name-\n-00067380: 6465 6669 6e65 645d 0a20 2020 2020 2020 defined]. \n-00067390: 2064 6174 6120 3d20 6c6f 6164 6572 2e67 data = loader.g\n-000673a0: 6574 5f64 6174 6128 5f5f 6669 6c65 5f5f et_data(__file__\n-000673b0: 2e72 6570 6c61 6365 2827 5f5f 696e 6974 .replace('__init\n-000673c0: 5f5f 2e70 7927 2c20 6669 6c65 6e61 6d65 __.py', filename\n-000673d0: 2929 0a20 2020 2020 2020 2072 6574 7572 )). retur\n-000673e0: 6e20 6461 7461 2e64 6563 6f64 6528 2775 n data.decode('u\n-000673f0: 7466 2d38 2729 0a27 2727 2c0a 2020 2763 tf-8').''',. 'c\n-00067400: 6f63 6b70 6974 2f64 6174 612f 5f5f 696e ockpit/data/__in\n-00067410: 6974 5f5f 2e70 7927 3a20 6272 2727 2769 it__.py': br'''i\n-00067420: 6d70 6f72 7420 7379 730a 0a69 6620 7379 mport sys..if sy\n-00067430: 732e 7665 7273 696f 6e5f 696e 666f 203e s.version_info >\n-00067440: 3d20 2833 2c20 3131 293a 0a20 2020 2069 = (3, 11):. i\n-00067450: 6d70 6f72 7420 696d 706f 7274 6c69 622e mport importlib.\n-00067460: 7265 736f 7572 6365 730a 0a20 2020 2064 resources.. d\n-00067470: 6566 2072 6561 645f 636f 636b 7069 745f ef read_cockpit_\n-00067480: 6461 7461 5f66 696c 6528 6669 6c65 6e61 data_file(filena\n-00067490: 6d65 3a20 7374 7229 202d 3e20 6279 7465 me: str) -> byte\n-000674a0: 733a 0a20 2020 2020 2020 2072 6574 7572 s:. retur\n-000674b0: 6e20 2869 6d70 6f72 746c 6962 2e72 6573 n (importlib.res\n-000674c0: 6f75 7263 6573 2e66 696c 6573 2827 636f ources.files('co\n-000674d0: 636b 7069 742e 6461 7461 2729 202f 2066 ckpit.data') / f\n-000674e0: 696c 656e 616d 6529 2e72 6561 645f 6279 ilename).read_by\n-000674f0: 7465 7328 290a 0a65 6c73 653a 0a20 2020 tes()..else:. \n-00067500: 2069 6d70 6f72 7420 696d 706f 7274 6c69 import importli\n-00067510: 622e 6162 630a 0a20 2020 2064 6566 2072 b.abc.. def r\n-00067520: 6561 645f 636f 636b 7069 745f 6461 7461 ead_cockpit_data\n-00067530: 5f66 696c 6528 6669 6c65 6e61 6d65 3a20 _file(filename: \n-00067540: 7374 7229 202d 3e20 6279 7465 733a 0a20 str) -> bytes:. \n-00067550: 2020 2020 2020 2023 2068 7474 7073 3a2f # https:/\n-00067560: 2f67 6974 6875 622e 636f 6d2f 7079 7468 /github.com/pyth\n-00067570: 6f6e 2f6d 7970 792f 6973 7375 6573 2f34 on/mypy/issues/4\n-00067580: 3138 320a 2020 2020 2020 2020 6c6f 6164 182. load\n-00067590: 6572 203d 205f 5f6c 6f61 6465 725f 5f20 er = __loader__ \n-000675a0: 2023 2074 7970 653a 2069 676e 6f72 655b # type: ignore[\n-000675b0: 6e61 6d65 2d64 6566 696e 6564 5d0a 2020 name-defined]. \n-000675c0: 2020 2020 2020 6173 7365 7274 2069 7369 assert isi\n-000675d0: 6e73 7461 6e63 6528 6c6f 6164 6572 2c20 nstance(loader, \n-000675e0: 696d 706f 7274 6c69 622e 6162 632e 5265 importlib.abc.Re\n-000675f0: 736f 7572 6365 4c6f 6164 6572 290a 0a20 sourceLoader).. \n-00067600: 2020 2020 2020 2070 6174 6820 3d20 5f5f path = __\n-00067610: 6669 6c65 5f5f 2e72 6570 6c61 6365 2827 file__.replace('\n-00067620: 5f5f 696e 6974 5f5f 2e70 7927 2c20 6669 __init__.py', fi\n-00067630: 6c65 6e61 6d65 290a 2020 2020 2020 2020 lename). \n-00067640: 7265 7475 726e 206c 6f61 6465 722e 6765 return loader.ge\n-00067650: 745f 6461 7461 2870 6174 6829 0a27 2727 t_data(path).'''\n-00067660: 2c0a 2020 2763 6f63 6b70 6974 2f64 6174 ,. 'cockpit/dat\n-00067670: 612f 6661 696c 2e68 746d 6c27 3a20 6272 a/fail.html': br\n-00067680: 2727 273c 2144 4f43 5459 5045 2068 746d '''<!DOCTYPE htm\n-00067690: 6c3e 0a3c 6874 6d6c 3e0a 3c68 6561 643e l>.<html>.<head>\n-000676a0: 0a20 2020 203c 7469 746c 653e 4040 6d65 . <title>@@me\n-000676b0: 7373 6167 6540 403c 2f74 6974 6c65 3e0a ssage@@.\n-000676c0: 2020 2020 3c6d 6574 6120 6874 7470 2d65 . . \n-00067a70: 0a3c 2f68 6561 643e 0a3c 626f 6479 3e0a ...\n-00067a80: 2020 2020 3c64 6976 2063 6c61 7373 3d22
\n-00067aa0: 0a20 2020 2020 2020 203c 696d 6720 7372 . . <\n-000682e0: 6831 3e40 406d 6573 7361 6765 4040 3c2f h1>@@message@@.
.<\n-00068300: 2f62 6f64 793e 0a3c 2f68 746d 6c3e 0a27 /body>..'\n+0004e0c0: 2c0a 2020 2020 2020 2020 2020 2020 6465 ,. de\n+0004e0d0: 7374 696e 6174 696f 6e3a 2073 7472 2c0a stination: str,.\n+0004e0e0: 2020 2020 2020 2020 2020 2020 7061 7468 path\n+0004e0f0: 3a20 7374 722c 0a20 2020 2020 2020 2020 : str,. \n+0004e100: 2020 2069 6e74 6572 6661 6365 3a20 7374 interface: st\n+0004e110: 722c 0a20 2020 2020 2020 2020 2020 206d r,. m\n+0004e120: 656d 6265 723a 2073 7472 2c0a 2020 2020 ember: str,. \n+0004e130: 2020 2020 2020 2020 7479 7065 733a 2073 types: s\n+0004e140: 7472 203d 2027 272c 0a20 2020 2020 2020 tr = '',. \n+0004e150: 2020 2020 202a 6172 6773 3a20 6f62 6a65 *args: obje\n+0004e160: 6374 2c0a 2020 2020 2020 2020 2020 2020 ct,. \n+0004e170: 7469 6d65 6f75 743a 204f 7074 696f 6e61 timeout: Optiona\n+0004e180: 6c5b 696e 745d 203d 204e 6f6e 650a 2020 l[int] = None. \n+0004e190: 2020 2920 2d3e 2054 7570 6c65 5b6f 626a ) -> Tuple[obj\n+0004e1a0: 6563 742c 202e 2e2e 5d3a 0a20 2020 2020 ect, ...]:. \n+0004e1b0: 2020 206c 6f67 6765 722e 6465 6275 6728 logger.debug(\n+0004e1c0: 2744 6f69 6e67 2073 796e 6320 6d65 7468 'Doing sync meth\n+0004e1d0: 6f64 2063 616c 6c20 2573 2025 7320 2573 od call %s %s %s\n+0004e1e0: 2025 7320 2573 2025 7327 2c0a 2020 2020 %s %s %s',. \n+0004e1f0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0004e200: 2064 6573 7469 6e61 7469 6f6e 2c20 7061 destination, pa\n+0004e210: 7468 2c20 696e 7465 7266 6163 652c 206d th, interface, m\n+0004e220: 656d 6265 722c 2074 7970 6573 2c20 6172 ember, types, ar\n+0004e230: 6773 290a 2020 2020 2020 2020 6d65 7373 gs). mess\n+0004e240: 6167 6520 3d20 7365 6c66 2e6d 6573 7361 age = self.messa\n+0004e250: 6765 5f6e 6577 5f6d 6574 686f 645f 6361 ge_new_method_ca\n+0004e260: 6c6c 2864 6573 7469 6e61 7469 6f6e 2c20 ll(destination, \n+0004e270: 7061 7468 2c20 696e 7465 7266 6163 652c path, interface,\n+0004e280: 206d 656d 6265 722c 2074 7970 6573 2c20 member, types, \n+0004e290: 2a61 7267 7329 0a20 2020 2020 2020 206d *args). m\n+0004e2a0: 6573 7361 6765 203d 2073 656c 662e 6361 essage = self.ca\n+0004e2b0: 6c6c 286d 6573 7361 6765 2c20 7469 6d65 ll(message, time\n+0004e2c0: 6f75 7429 0a20 2020 2020 2020 2072 6574 out). ret\n+0004e2d0: 7572 6e20 6d65 7373 6167 652e 6765 745f urn message.get_\n+0004e2e0: 626f 6479 2829 0a0a 2020 2020 6173 796e body().. asyn\n+0004e2f0: 6320 6465 6620 6361 6c6c 5f61 7379 6e63 c def call_async\n+0004e300: 280a 2020 2020 2020 2020 2020 2020 7365 (. se\n+0004e310: 6c66 2c0a 2020 2020 2020 2020 2020 2020 lf,. \n+0004e320: 6d65 7373 6167 653a 2042 7573 4d65 7373 message: BusMess\n+0004e330: 6167 652c 0a20 2020 2020 2020 2020 2020 age,. \n+0004e340: 2074 696d 656f 7574 3a20 4f70 7469 6f6e timeout: Option\n+0004e350: 616c 5b69 6e74 5d20 3d20 4e6f 6e65 0a20 al[int] = None. \n+0004e360: 2020 2029 202d 3e20 4275 734d 6573 7361 ) -> BusMessa\n+0004e370: 6765 3a0a 2020 2020 2020 2020 7065 6e64 ge:. pend\n+0004e380: 696e 6720 3d20 5065 6e64 696e 6743 616c ing = PendingCal\n+0004e390: 6c28 290a 2020 2020 2020 2020 7365 6c66 l(). self\n+0004e3a0: 2e5f 6361 6c6c 5f61 7379 6e63 2862 7972 ._call_async(byr\n+0004e3b0: 6566 2870 656e 6469 6e67 292c 206d 6573 ef(pending), mes\n+0004e3c0: 7361 6765 2c20 7065 6e64 696e 672e 7472 sage, pending.tr\n+0004e3d0: 616d 706f 6c69 6e65 2c20 7065 6e64 696e ampoline, pendin\n+0004e3e0: 672e 7573 6572 6461 7461 2c20 7469 6d65 g.userdata, time\n+0004e3f0: 6f75 7420 6f72 2030 290a 2020 2020 2020 out or 0). \n+0004e400: 2020 7265 7475 726e 2061 7761 6974 2070 return await p\n+0004e410: 656e 6469 6e67 2e66 7574 7572 650a 0a20 ending.future.. \n+0004e420: 2020 2061 7379 6e63 2064 6566 2063 616c async def cal\n+0004e430: 6c5f 6d65 7468 6f64 5f61 7379 6e63 280a l_method_async(.\n+0004e440: 2020 2020 2020 2020 7365 6c66 2c0a 2020 self,. \n+0004e450: 2020 2020 2020 6465 7374 696e 6174 696f destinatio\n+0004e460: 6e3a 204f 7074 696f 6e61 6c5b 7374 725d n: Optional[str]\n+0004e470: 2c0a 2020 2020 2020 2020 7061 7468 3a20 ,. path: \n+0004e480: 7374 722c 0a20 2020 2020 2020 2069 6e74 str,. int\n+0004e490: 6572 6661 6365 3a20 7374 722c 0a20 2020 erface: str,. \n+0004e4a0: 2020 2020 206d 656d 6265 723a 2073 7472 member: str\n+0004e4b0: 2c0a 2020 2020 2020 2020 7479 7065 733a ,. types:\n+0004e4c0: 2073 7472 203d 2027 272c 0a20 2020 2020 str = '',. \n+0004e4d0: 2020 202a 6172 6773 3a20 6f62 6a65 6374 *args: object\n+0004e4e0: 2c0a 2020 2020 2020 2020 7469 6d65 6f75 ,. timeou\n+0004e4f0: 743a 204f 7074 696f 6e61 6c5b 696e 745d t: Optional[int]\n+0004e500: 203d 204e 6f6e 650a 2020 2020 2920 2d3e = None. ) ->\n+0004e510: 2054 7570 6c65 5b6f 626a 6563 742c 202e Tuple[object, .\n+0004e520: 2e2e 5d3a 0a20 2020 2020 2020 206c 6f67 ..]:. log\n+0004e530: 6765 722e 6465 6275 6728 2744 6f69 6e67 ger.debug('Doing\n+0004e540: 2061 7379 6e63 206d 6574 686f 6420 6361 async method ca\n+0004e550: 6c6c 2025 7320 2573 2025 7320 2573 2025 ll %s %s %s %s %\n+0004e560: 7320 2573 272c 0a20 2020 2020 2020 2020 s %s',. \n+0004e570: 2020 2020 2020 2020 2020 2020 6465 7374 dest\n+0004e580: 696e 6174 696f 6e2c 2070 6174 682c 2069 ination, path, i\n+0004e590: 6e74 6572 6661 6365 2c20 6d65 6d62 6572 nterface, member\n+0004e5a0: 2c20 7479 7065 732c 2061 7267 7329 0a20 , types, args). \n+0004e5b0: 2020 2020 2020 206d 6573 7361 6765 203d message =\n+0004e5c0: 2073 656c 662e 6d65 7373 6167 655f 6e65 self.message_ne\n+0004e5d0: 775f 6d65 7468 6f64 5f63 616c 6c28 6465 w_method_call(de\n+0004e5e0: 7374 696e 6174 696f 6e2c 2070 6174 682c stination, path,\n+0004e5f0: 2069 6e74 6572 6661 6365 2c20 6d65 6d62 interface, memb\n+0004e600: 6572 2c20 7479 7065 732c 202a 6172 6773 er, types, *args\n+0004e610: 290a 2020 2020 2020 2020 6d65 7373 6167 ). messag\n+0004e620: 6520 3d20 6177 6169 7420 7365 6c66 2e63 e = await self.c\n+0004e630: 616c 6c5f 6173 796e 6328 6d65 7373 6167 all_async(messag\n+0004e640: 652c 2074 696d 656f 7574 290a 2020 2020 e, timeout). \n+0004e650: 2020 2020 7265 7475 726e 206d 6573 7361 return messa\n+0004e660: 6765 2e67 6574 5f62 6f64 7928 290a 0a20 ge.get_body().. \n+0004e670: 2020 2064 6566 2061 6464 5f6d 6174 6368 def add_match\n+0004e680: 2873 656c 662c 2072 756c 653a 2073 7472 (self, rule: str\n+0004e690: 2c20 6861 6e64 6c65 723a 2043 616c 6c61 , handler: Calla\n+0004e6a0: 626c 655b 5b42 7573 4d65 7373 6167 655d ble[[BusMessage]\n+0004e6b0: 2c20 626f 6f6c 5d29 202d 3e20 536c 6f74 , bool]) -> Slot\n+0004e6c0: 3a0a 2020 2020 2020 2020 736c 6f74 203d :. slot =\n+0004e6d0: 2053 6c6f 7428 6861 6e64 6c65 7229 0a20 Slot(handler). \n+0004e6e0: 2020 2020 2020 2073 656c 662e 5f61 6464 self._add\n+0004e6f0: 5f6d 6174 6368 2862 7972 6566 2873 6c6f _match(byref(slo\n+0004e700: 7429 2c20 7275 6c65 2c20 736c 6f74 2e74 t), rule, slot.t\n+0004e710: 7261 6d70 6f6c 696e 652c 2073 6c6f 742e rampoline, slot.\n+0004e720: 7573 6572 6461 7461 290a 2020 2020 2020 userdata). \n+0004e730: 2020 7265 7475 726e 2073 6c6f 740a 0a20 return slot.. \n+0004e740: 2020 2064 6566 2061 6464 5f6f 626a 6563 def add_objec\n+0004e750: 7428 7365 6c66 2c20 7061 7468 3a20 7374 t(self, path: st\n+0004e760: 722c 206f 626a 3a20 2742 6173 654f 626a r, obj: 'BaseObj\n+0004e770: 6563 7427 2920 2d3e 2053 6c6f 743a 0a20 ect') -> Slot:. \n+0004e780: 2020 2020 2020 2073 6c6f 7420 3d20 536c slot = Sl\n+0004e790: 6f74 286f 626a 2e6d 6573 7361 6765 5f72 ot(obj.message_r\n+0004e7a0: 6563 6569 7665 6429 0a20 2020 2020 2020 eceived). \n+0004e7b0: 2073 656c 662e 5f61 6464 5f6f 626a 6563 self._add_objec\n+0004e7c0: 7428 6279 7265 6628 736c 6f74 292c 2070 t(byref(slot), p\n+0004e7d0: 6174 682c 2073 6c6f 742e 7472 616d 706f ath, slot.trampo\n+0004e7e0: 6c69 6e65 2c20 736c 6f74 2e75 7365 7264 line, slot.userd\n+0004e7f0: 6174 6129 0a20 2020 2020 2020 206f 626a ata). obj\n+0004e800: 2e72 6567 6973 7465 7265 645f 6f6e 5f62 .registered_on_b\n+0004e810: 7573 2873 656c 662c 2070 6174 6829 0a20 us(self, path). \n+0004e820: 2020 2020 2020 2072 6574 7572 6e20 736c return sl\n+0004e830: 6f74 0a0a 0a63 6c61 7373 2042 6173 654f ot...class BaseO\n+0004e840: 626a 6563 743a 0a20 2020 2022 2222 4261 bject:. \"\"\"Ba\n+0004e850: 7365 206f 626a 6563 7420 7479 7065 2066 se object type f\n+0004e860: 6f72 2065 7870 6f72 7469 6e67 206f 626a or exporting obj\n+0004e870: 6563 7473 206f 6e20 7468 6520 6275 730a ects on the bus.\n+0004e880: 0a20 2020 2054 6869 7320 6973 2074 6865 . This is the\n+0004e890: 206c 6f77 6573 742d 6c65 7665 6c20 636c lowest-level cl\n+0004e8a0: 6173 7320 7468 6174 2063 616e 2062 6520 ass that can be \n+0004e8b0: 7061 7373 6564 2074 6f20 4275 732e 6164 passed to Bus.ad\n+0004e8c0: 645f 6f62 6a65 6374 2829 2e0a 0a20 2020 d_object()... \n+0004e8d0: 2049 6620 796f 7520 7761 6e74 2074 6f20 If you want to \n+0004e8e0: 6469 7265 6374 6c79 2073 7562 636c 6173 directly subclas\n+0004e8f0: 7320 7468 6973 2c20 796f 7527 6c6c 206e s this, you'll n\n+0004e900: 6565 6420 746f 2069 6d70 6c65 6d65 6e74 eed to implement\n+0004e910: 0a20 2020 2060 6d65 7373 6167 655f 7265 . `message_re\n+0004e920: 6365 6976 6564 2829 602e 0a0a 2020 2020 ceived()`... \n+0004e930: 5375 6263 6c61 7373 696e 6720 6672 6f6d Subclassing from\n+0004e940: 2060 6275 732e 4f62 6a65 6374 6020 6973 `bus.Object` is\n+0004e950: 2070 726f 6261 626c 7920 6120 6265 7474 probably a bett\n+0004e960: 6572 2063 686f 6963 652e 0a20 2020 2022 er choice.. \"\n+0004e970: 2222 0a20 2020 205f 6462 7573 5f62 7573 \"\". _dbus_bus\n+0004e980: 3a20 4f70 7469 6f6e 616c 5b42 7573 5d20 : Optional[Bus] \n+0004e990: 3d20 4e6f 6e65 0a20 2020 205f 6462 7573 = None. _dbus\n+0004e9a0: 5f70 6174 683a 204f 7074 696f 6e61 6c5b _path: Optional[\n+0004e9b0: 7374 725d 203d 204e 6f6e 650a 0a20 2020 str] = None.. \n+0004e9c0: 2064 6566 2072 6567 6973 7465 7265 645f def registered_\n+0004e9d0: 6f6e 5f62 7573 2873 656c 662c 2062 7573 on_bus(self, bus\n+0004e9e0: 3a20 4275 732c 2070 6174 683a 2073 7472 : Bus, path: str\n+0004e9f0: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n+0004ea00: 2020 2022 2222 5265 706f 7274 2074 6861 \"\"\"Report tha\n+0004ea10: 7420 616e 2069 6e73 7461 6e63 6520 7761 t an instance wa\n+0004ea20: 7320 6578 706f 7274 6564 206f 6e20 6120 s exported on a \n+0004ea30: 6769 7665 6e20 6275 7320 616e 6420 7061 given bus and pa\n+0004ea40: 7468 2e0a 0a20 2020 2020 2020 2054 6869 th... Thi\n+0004ea50: 7320 6973 2075 7365 6420 736f 2074 6861 s is used so tha\n+0004ea60: 7420 7468 6520 696e 7374 616e 6365 206b t the instance k\n+0004ea70: 6e6f 7773 2077 6865 7265 2074 6f20 7365 nows where to se\n+0004ea80: 6e64 2073 6967 6e61 6c73 2e0a 2020 2020 nd signals.. \n+0004ea90: 2020 2020 4275 732e 6164 645f 6f62 6a65 Bus.add_obje\n+0004eaa0: 6374 2829 2063 616c 6c73 2074 6869 733a ct() calls this:\n+0004eab0: 2079 6f75 2070 726f 6261 626c 7920 7368 you probably sh\n+0004eac0: 6f75 6c64 6e27 7420 6361 6c6c 2074 6869 ouldn't call thi\n+0004ead0: 7320 6f6e 2079 6f75 720a 2020 2020 2020 s on your. \n+0004eae0: 2020 6f77 6e2e 0a20 2020 2020 2020 2022 own.. \"\n+0004eaf0: 2222 0a20 2020 2020 2020 2073 656c 662e \"\". self.\n+0004eb00: 5f64 6275 735f 6275 7320 3d20 6275 730a _dbus_bus = bus.\n+0004eb10: 2020 2020 2020 2020 7365 6c66 2e5f 6462 self._db\n+0004eb20: 7573 5f70 6174 6820 3d20 7061 7468 0a0a us_path = path..\n+0004eb30: 2020 2020 2020 2020 7365 6c66 2e72 6567 self.reg\n+0004eb40: 6973 7465 7265 6428 290a 0a20 2020 2064 istered().. d\n+0004eb50: 6566 2072 6567 6973 7465 7265 6428 7365 ef registered(se\n+0004eb60: 6c66 2920 2d3e 204e 6f6e 653a 0a20 2020 lf) -> None:. \n+0004eb70: 2020 2020 2022 2222 4361 6c6c 6564 2061 \"\"\"Called a\n+0004eb80: 6674 6572 2061 6e20 6f62 6a65 6374 2068 fter an object h\n+0004eb90: 6173 2062 6565 6e20 7265 6769 7374 6572 as been register\n+0004eba0: 6564 206f 6e20 7468 6520 6275 730a 0a20 ed on the bus.. \n+0004ebb0: 2020 2020 2020 2054 6869 7320 6973 2074 This is t\n+0004ebc0: 6865 2063 6f72 7265 6374 206d 6574 686f he correct metho\n+0004ebd0: 6420 746f 2069 6d70 6c65 6d65 6e74 2074 d to implement t\n+0004ebe0: 6f20 646f 2073 6f6d 6520 696e 6974 6961 o do some initia\n+0004ebf0: 6c20 776f 726b 2074 6861 740a 2020 2020 l work that. \n+0004ec00: 2020 2020 6e65 6564 7320 746f 2062 6520 needs to be \n+0004ec10: 646f 6e65 2061 6674 6572 2072 6567 6973 done after regis\n+0004ec20: 7472 6174 696f 6e2e 2020 5468 6520 6465 tration. The de\n+0004ec30: 6661 756c 7420 696d 706c 656d 656e 7461 fault implementa\n+0004ec40: 7469 6f6e 2064 6f65 730a 2020 2020 2020 tion does. \n+0004ec50: 2020 6e6f 7468 696e 672e 0a20 2020 2020 nothing.. \n+0004ec60: 2020 2022 2222 0a20 2020 2020 2020 2070 \"\"\". p\n+0004ec70: 6173 730a 0a20 2020 2064 6566 2065 6d69 ass.. def emi\n+0004ec80: 745f 7369 676e 616c 280a 2020 2020 2020 t_signal(. \n+0004ec90: 2020 2020 2020 7365 6c66 2c20 696e 7465 self, inte\n+0004eca0: 7266 6163 653a 2073 7472 2c20 6e61 6d65 rface: str, name\n+0004ecb0: 3a20 7374 722c 2073 6967 6e61 7475 7265 : str, signature\n+0004ecc0: 3a20 7374 722c 202a 6172 6773 3a20 416e : str, *args: An\n+0004ecd0: 790a 2020 2020 2920 2d3e 2062 6f6f 6c3a y. ) -> bool:\n+0004ece0: 0a20 2020 2020 2020 2022 2222 456d 6974 . \"\"\"Emit\n+0004ecf0: 2061 2044 2d42 7573 2073 6967 6e61 6c20 a D-Bus signal \n+0004ed00: 6f6e 2074 6869 7320 6f62 6a65 6374 0a0a on this object..\n+0004ed10: 2020 2020 2020 2020 5468 6520 6f62 6a65 The obje\n+0004ed20: 6374 206d 7573 7420 6861 7665 2062 6565 ct must have bee\n+0004ed30: 6e20 6578 706f 7274 6564 206f 6e20 7468 n exported on th\n+0004ed40: 6520 6275 7320 7769 7468 2042 7573 2e61 e bus with Bus.a\n+0004ed50: 6464 5f6f 626a 6563 7428 292e 0a0a 2020 dd_object()... \n+0004ed60: 2020 2020 2020 3a69 6e74 6572 6661 6365 :interface\n+0004ed70: 3a20 7468 6520 696e 7465 7266 6163 6520 : the interface \n+0004ed80: 6f66 2074 6865 2073 6967 6e61 6c0a 2020 of the signal. \n+0004ed90: 2020 2020 2020 3a6e 616d 653a 2074 6865 :name: the\n+0004eda0: 2027 6d65 6d62 6572 2720 6e61 6d65 206f 'member' name o\n+0004edb0: 6620 7468 6520 7369 676e 616c 2074 6f20 f the signal to \n+0004edc0: 656d 6974 0a20 2020 2020 2020 203a 7369 emit. :si\n+0004edd0: 676e 6174 7572 653a 2074 6865 2074 7970 gnature: the typ\n+0004ede0: 6520 7369 676e 6174 7572 652c 2061 7320 e signature, as \n+0004edf0: 6120 7374 7269 6e67 0a20 2020 2020 2020 a string. \n+0004ee00: 203a 6172 6773 3a20 7468 6520 6172 6775 :args: the argu\n+0004ee10: 6d65 6e74 732c 2061 6363 6f72 6469 6e67 ments, according\n+0004ee20: 2074 6f20 7468 6520 7369 676e 6174 7572 to the signatur\n+0004ee30: 650a 2020 2020 2020 2020 3a72 6574 7572 e. :retur\n+0004ee40: 6e73 3a20 5472 7565 0a20 2020 2020 2020 ns: True. \n+0004ee50: 2022 2222 0a20 2020 2020 2020 2061 7373 \"\"\". ass\n+0004ee60: 6572 7420 7365 6c66 2e5f 6462 7573 5f62 ert self._dbus_b\n+0004ee70: 7573 2069 7320 6e6f 7420 4e6f 6e65 0a20 us is not None. \n+0004ee80: 2020 2020 2020 2061 7373 6572 7420 7365 assert se\n+0004ee90: 6c66 2e5f 6462 7573 5f70 6174 6820 6973 lf._dbus_path is\n+0004eea0: 206e 6f74 204e 6f6e 650a 2020 2020 2020 not None. \n+0004eeb0: 2020 7265 7475 726e 2073 656c 662e 5f64 return self._d\n+0004eec0: 6275 735f 6275 732e 6d65 7373 6167 655f bus_bus.message_\n+0004eed0: 6e65 775f 7369 676e 616c 2873 656c 662e new_signal(self.\n+0004eee0: 5f64 6275 735f 7061 7468 2c20 696e 7465 _dbus_path, inte\n+0004eef0: 7266 6163 652c 206e 616d 652c 2073 6967 rface, name, sig\n+0004ef00: 6e61 7475 7265 2c20 2a61 7267 7329 2e73 nature, *args).s\n+0004ef10: 656e 6428 290a 0a20 2020 2064 6566 206d end().. def m\n+0004ef20: 6573 7361 6765 5f72 6563 6569 7665 6428 essage_received(\n+0004ef30: 7365 6c66 2c20 6d65 7373 6167 653a 2042 self, message: B\n+0004ef40: 7573 4d65 7373 6167 6529 202d 3e20 626f usMessage) -> bo\n+0004ef50: 6f6c 3a0a 2020 2020 2020 2020 2222 2243 ol:. \"\"\"C\n+0004ef60: 616c 6c65 6420 7768 656e 2061 206d 6573 alled when a mes\n+0004ef70: 7361 6765 2069 7320 7265 6365 6976 6564 sage is received\n+0004ef80: 2066 6f72 2074 6869 7320 6f62 6a65 6374 for this object\n+0004ef90: 0a0a 2020 2020 2020 2020 5468 6973 2069 .. This i\n+0004efa0: 7320 7468 6520 6c6f 7765 7374 206c 6576 s the lowest lev\n+0004efb0: 656c 2069 6e74 6572 6661 6365 2074 6f20 el interface to \n+0004efc0: 7468 6520 4261 7365 4f62 6a65 6374 2e20 the BaseObject. \n+0004efd0: 2059 6f75 206e 6565 6420 746f 0a20 2020 You need to. \n+0004efe0: 2020 2020 2068 616e 646c 6520 6d65 7468 handle meth\n+0004eff0: 6f64 2063 616c 6c73 2c20 7072 6f70 6572 od calls, proper\n+0004f000: 7469 6573 2c20 616e 6420 696e 7472 6f73 ties, and intros\n+0004f010: 7065 6374 696f 6e2e 0a0a 2020 2020 2020 pection... \n+0004f020: 2020 596f 7520 6172 6520 6578 7065 6374 You are expect\n+0004f030: 6564 2074 6f20 6861 6e64 6c65 2074 6865 ed to handle the\n+0004f040: 206d 6573 7361 6765 2061 6e64 2072 6574 message and ret\n+0004f050: 7572 6e20 5472 7565 2e20 204e 6f72 6d61 urn True. Norma\n+0004f060: 6c6c 7920 7468 6973 0a20 2020 2020 2020 lly this. \n+0004f070: 206d 6561 6e73 2074 6861 7420 796f 7520 means that you \n+0004f080: 7365 6e64 2061 2072 6570 6c79 2e20 2049 send a reply. I\n+0004f090: 6620 796f 7520 646f 6e27 7420 7761 6e74 f you don't want\n+0004f0a0: 2074 6f20 6861 6e64 6c65 2074 6865 206d to handle the m\n+0004f0b0: 6573 7361 6765 2c0a 2020 2020 2020 2020 essage,. \n+0004f0c0: 7265 7475 726e 2046 616c 7365 2061 6e64 return False and\n+0004f0d0: 206f 7468 6572 2068 616e 646c 6572 7320 other handlers \n+0004f0e0: 7769 6c6c 2068 6176 6520 6120 6368 616e will have a chan\n+0004f0f0: 6365 2074 6f20 7275 6e2e 2020 4966 206e ce to run. If n\n+0004f100: 6f0a 2020 2020 2020 2020 6861 6e64 6c65 o. handle\n+0004f110: 7220 6861 6e64 6c65 7320 7468 6520 6d65 r handles the me\n+0004f120: 7373 6167 652c 2073 7973 7465 6d64 2077 ssage, systemd w\n+0004f130: 696c 6c20 6765 6e65 7261 7465 2061 2073 ill generate a s\n+0004f140: 7569 7461 626c 6520 6572 726f 720a 2020 uitable error. \n+0004f150: 2020 2020 2020 6d65 7373 6167 6520 616e message an\n+0004f160: 6420 7365 6e64 2074 6861 742c 2069 6e73 d send that, ins\n+0004f170: 7465 6164 2e0a 0a20 2020 2020 2020 203a tead... :\n+0004f180: 6d65 7373 6167 653a 2074 6865 206d 6573 message: the mes\n+0004f190: 7361 6765 2074 6861 7420 7761 7320 7265 sage that was re\n+0004f1a0: 6365 6976 6564 0a20 2020 2020 2020 203a ceived. :\n+0004f1b0: 7265 7475 726e 733a 2054 7275 6520 6966 returns: True if\n+0004f1c0: 2074 6865 206d 6573 7361 6765 2077 6173 the message was\n+0004f1d0: 2068 616e 646c 6564 0a20 2020 2020 2020 handled. \n+0004f1e0: 2022 2222 0a20 2020 2020 2020 2072 6169 \"\"\". rai\n+0004f1f0: 7365 204e 6f74 496d 706c 656d 656e 7465 se NotImplemente\n+0004f200: 6445 7272 6f72 0a0a 0a63 6c61 7373 2049 dError...class I\n+0004f210: 6e74 6572 6661 6365 3a0a 2020 2020 2222 nterface:. \"\"\n+0004f220: 2254 6865 2068 6967 682d 6c65 7665 6c20 \"The high-level \n+0004f230: 6261 7365 2063 6c61 7373 2066 6f72 2064 base class for d\n+0004f240: 6566 696e 696e 6720 442d 4275 7320 696e efining D-Bus in\n+0004f250: 7465 7266 6163 6573 0a0a 2020 2020 5468 terfaces.. Th\n+0004f260: 6973 2063 6c61 7373 2070 726f 7669 6465 is class provide\n+0004f270: 7320 6869 6768 2d6c 6576 656c 2041 5049 s high-level API\n+0004f280: 7320 666f 7220 6465 6669 6e69 6e67 206d s for defining m\n+0004f290: 6574 686f 6473 2c20 7072 6f70 6572 7469 ethods, properti\n+0004f2a0: 6573 2c20 616e 640a 2020 2020 7369 676e es, and. sign\n+0004f2b0: 616c 732c 2061 7320 7765 6c6c 2061 7320 als, as well as \n+0004f2c0: 696d 706c 656d 656e 7469 6e67 2069 6e74 implementing int\n+0004f2d0: 726f 7370 6563 7469 6f6e 2e0a 0a20 2020 rospection... \n+0004f2e0: 204f 6e20 6974 7320 6f77 6e2c 2074 6869 On its own, thi\n+0004f2f0: 7320 636c 6173 7320 646f 6573 6e27 7420 s class doesn't \n+0004f300: 7072 6f76 6964 6520 6120 6d65 6368 616e provide a mechan\n+0004f310: 6973 6d20 666f 7220 6578 706f 7274 696e ism for exportin\n+0004f320: 6720 616e 7974 6869 6e67 0a20 2020 206f g anything. o\n+0004f330: 6e20 7468 6520 6275 732e 2020 5468 6520 n the bus. The \n+0004f340: 4f62 6a65 6374 2063 6c61 7373 2064 6f65 Object class doe\n+0004f350: 7320 7468 6174 2c20 616e 6420 796f 7527 s that, and you'\n+0004f360: 6c6c 2067 656e 6572 616c 6c79 2077 616e ll generally wan\n+0004f370: 7420 746f 0a20 2020 2073 7562 636c 6173 t to. subclas\n+0004f380: 7320 6672 6f6d 2069 742c 2061 7320 6974 s from it, as it\n+0004f390: 2063 6f6e 7461 696e 7320 7365 7665 7261 contains severa\n+0004f3a0: 6c20 6275 696c 742d 696e 2073 7461 6e64 l built-in stand\n+0004f3b0: 6172 6420 696e 7465 7266 6163 6573 0a20 ard interfaces. \n+0004f3c0: 2020 2028 696e 7472 6f73 7065 6374 696f (introspectio\n+0004f3d0: 6e2c 2070 726f 7065 7274 6965 732c 2065 n, properties, e\n+0004f3e0: 7463 2e29 2e0a 0a20 2020 2054 6865 206e tc.)... The n\n+0004f3f0: 616d 6520 6f66 2079 6f75 7220 636c 6173 ame of your clas\n+0004f400: 7320 7769 6c6c 2062 6520 696e 7465 7270 s will be interp\n+0004f410: 7265 7465 6420 6173 2061 2044 2d42 7573 reted as a D-Bus\n+0004f420: 2069 6e74 6572 6661 6365 206e 616d 652e interface name.\n+0004f430: 0a20 2020 2055 6e64 6572 7363 6f72 6573 . Underscores\n+0004f440: 2061 7265 2063 6f6e 7665 7274 6564 2074 are converted t\n+0004f450: 6f20 646f 7473 2e20 204e 6f20 6361 7365 o dots. No case\n+0004f460: 2063 6f6e 7665 7273 696f 6e20 6973 2070 conversion is p\n+0004f470: 6572 666f 726d 6564 2e20 2049 660a 2020 erformed. If. \n+0004f480: 2020 7468 6520 696e 7465 7266 6163 6520 the interface \n+0004f490: 6e61 6d65 2063 616e 2774 2062 6520 7265 name can't be re\n+0004f4a0: 7072 6573 656e 7465 6420 7573 696e 6720 presented using \n+0004f4b0: 7468 6973 2073 6368 656d 652c 206f 7220 this scheme, or \n+0004f4c0: 6966 2079 6f75 2764 206c 696b 650a 2020 if you'd like. \n+0004f4d0: 2020 746f 206e 616d 6520 796f 7572 2063 to name your c\n+0004f4e0: 6c61 7373 2064 6966 6665 7265 6e74 6c79 lass differently\n+0004f4f0: 2c20 796f 7520 6361 6e20 7072 6f76 6964 , you can provid\n+0004f500: 6520 616e 2069 6e74 6572 6661 6365 3d20 e an interface= \n+0004f510: 6b77 6172 6720 746f 2074 6865 0a20 2020 kwarg to the. \n+0004f520: 2063 6c61 7373 2064 6566 696e 6974 696f class definitio\n+0004f530: 6e2e 0a0a 2020 2020 2020 2020 636c 6173 n... clas\n+0004f540: 7320 636f 6d5f 6578 616d 706c 655f 496e s com_example_In\n+0004f550: 7465 7266 6163 6528 6275 732e 4f62 6a65 terface(bus.Obje\n+0004f560: 6374 293a 0a20 2020 2020 2020 2020 2020 ct):. \n+0004f570: 2070 6173 730a 0a20 2020 2020 2020 2063 pass.. c\n+0004f580: 6c61 7373 204d 7949 6e74 6572 6661 6365 lass MyInterface\n+0004f590: 2862 7573 2e4f 626a 6563 742c 2069 6e74 (bus.Object, int\n+0004f5a0: 6572 6661 6365 3d27 6f72 672e 636f 636b erface='org.cock\n+0004f5b0: 7069 745f 7072 6f6a 6563 742e 496e 7465 pit_project.Inte\n+0004f5c0: 7266 6163 6527 293a 0a20 2020 2020 2020 rface'):. \n+0004f5d0: 2020 2020 2070 6173 730a 0a20 2020 2054 pass.. T\n+0004f5e0: 6865 206d 6574 686f 6473 2c20 7072 6f70 he methods, prop\n+0004f5f0: 6572 7469 6573 2c20 616e 6420 7369 676e erties, and sign\n+0004f600: 616c 7320 7768 6963 6820 6172 6520 7669 als which are vi\n+0004f610: 7369 626c 6520 6672 6f6d 2044 2d42 7573 sible from D-Bus\n+0004f620: 2061 7265 0a20 2020 2064 6566 696e 6564 are. defined\n+0004f630: 2075 7369 6e67 2068 656c 7065 7220 636c using helper cl\n+0004f640: 6173 7365 7320 7769 7468 2074 6865 2063 asses with the c\n+0004f650: 6f72 7265 7370 6f6e 6469 6e67 206e 616d orresponding nam\n+0004f660: 6573 2028 4d65 7468 6f64 2c0a 2020 2020 es (Method,. \n+0004f670: 5072 6f70 6572 7479 2c20 5369 676e 616c Property, Signal\n+0004f680: 292e 2020 596f 7520 7368 6f75 6c64 2075 ). You should u\n+0004f690: 7365 206e 6f72 6d61 6c20 5079 7468 6f6e se normal Python\n+0004f6a0: 2073 6e61 6b65 5f63 6173 6520 636f 6e76 snake_case conv\n+0004f6b0: 656e 7469 6f6e 7320 666f 720a 2020 2020 entions for. \n+0004f6c0: 7468 6520 6d65 6d62 6572 206e 616d 6573 the member names\n+0004f6d0: 3a20 7468 6579 2077 696c 6c20 6175 746f : they will auto\n+0004f6e0: 6d61 7469 6361 6c6c 7920 6265 2063 6f6e matically be con\n+0004f6f0: 7665 7274 6564 2074 6f20 4361 6d65 6c43 verted to CamelC\n+0004f700: 6173 6520 6279 0a20 2020 2073 706c 6974 ase by. split\n+0004f710: 7469 6e67 206f 6e20 756e 6465 7273 636f ting on undersco\n+0004f720: 7265 2061 6e64 2063 6f6e 7665 7274 696e re and convertin\n+0004f730: 6720 7468 6520 6669 7273 7420 6c65 7474 g the first lett\n+0004f740: 6572 206f 6620 6561 6368 2072 6573 756c er of each resul\n+0004f750: 7469 6e67 0a20 2020 2077 6f72 6420 746f ting. word to\n+0004f760: 2075 7070 6572 6361 7365 2e20 2046 6f72 uppercase. For\n+0004f770: 2065 7861 6d70 6c65 2c20 606d 6574 686f example, `metho\n+0004f780: 645f 6e61 6d65 6020 6265 636f 6d65 7320 d_name` becomes \n+0004f790: 604d 6574 686f 644e 616d 6560 2e0a 0a20 `MethodName`... \n+0004f7a0: 2020 2045 6163 6820 4d65 7468 6f64 2c20 Each Method, \n+0004f7b0: 5072 6f70 6572 7479 2c20 6f72 2053 6967 Property, or Sig\n+0004f7c0: 6e61 6c20 636f 6e73 7472 7563 746f 7220 nal constructor \n+0004f7d0: 7461 6b65 7320 616e 206f 7074 696f 6e61 takes an optiona\n+0004f7e0: 6c20 6e61 6d65 3d20 6b77 6172 6773 0a20 l name= kwargs. \n+0004f7f0: 2020 2074 6f20 6f76 6572 7269 6465 2074 to override t\n+0004f800: 6865 2061 7574 6f6d 6174 6963 206e 616d he automatic nam\n+0004f810: 6520 636f 6e76 6572 7369 6f6e 2063 6f6e e conversion con\n+0004f820: 7665 6e74 696f 6e20 6162 6f76 652e 0a0a vention above...\n+0004f830: 2020 2020 416e 2065 7861 6d70 6c65 2063 An example c\n+0004f840: 6c61 7373 206d 6967 6874 206c 6f6f 6b20 lass might look \n+0004f850: 6c69 6b65 3a0a 0a20 2020 2020 2020 2063 like:.. c\n+0004f860: 6c61 7373 2063 6f6d 5f65 7861 6d70 6c65 lass com_example\n+0004f870: 5f4d 794f 626a 6563 7428 6275 732e 4f62 _MyObject(bus.Ob\n+0004f880: 6a65 6374 293a 0a20 2020 2020 2020 2020 ject):. \n+0004f890: 2020 2063 7265 6174 6564 203d 2062 7573 created = bus\n+0004f8a0: 2e49 6e74 6572 6661 6365 2e53 6967 6e61 .Interface.Signa\n+0004f8b0: 6c28 2773 272c 2027 6927 290a 2020 2020 l('s', 'i'). \n+0004f8c0: 2020 2020 2020 2020 7265 6e61 6d65 7320 renames \n+0004f8d0: 3d20 6275 732e 496e 7465 7266 6163 652e = bus.Interface.\n+0004f8e0: 5072 6f70 6572 7479 2827 7527 2c20 7661 Property('u', va\n+0004f8f0: 6c75 653d 3029 0a20 2020 2020 2020 2020 lue=0). \n+0004f900: 2020 206e 616d 6520 3d20 6275 732e 496e name = bus.In\n+0004f910: 7465 7266 6163 652e 5072 6f70 6572 7479 terface.Property\n+0004f920: 2827 7327 2c20 2775 6e64 6566 696e 6564 ('s', 'undefined\n+0004f930: 2729 0a0a 2020 2020 2020 2020 2020 2020 ').. \n+0004f940: 4062 7573 2e49 6e74 6572 6661 6365 2e4d @bus.Interface.M\n+0004f950: 6574 686f 6428 6f75 745f 7479 7065 733d ethod(out_types=\n+0004f960: 2829 2c20 696e 5f74 7970 6573 3d27 7327 (), in_types='s'\n+0004f970: 290a 2020 2020 2020 2020 2020 2020 6465 ). de\n+0004f980: 6620 7265 6e61 6d65 2873 656c 662c 206e f rename(self, n\n+0004f990: 616d 6529 3a0a 2020 2020 2020 2020 2020 ame):. \n+0004f9a0: 2020 2020 2020 7365 6c66 2e72 656e 616d self.renam\n+0004f9b0: 6573 202b 3d20 310a 2020 2020 2020 2020 es += 1. \n+0004f9c0: 2020 2020 2020 2020 7365 6c66 2e6e 616d self.nam\n+0004f9d0: 6520 3d20 6e61 6d65 0a0a 2020 2020 2020 e = name.. \n+0004f9e0: 2020 2020 2020 6465 6620 7265 6769 7374 def regist\n+0004f9f0: 6572 6564 2873 656c 6629 3a0a 2020 2020 ered(self):. \n+0004fa00: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n+0004fa10: 2e63 7265 6174 6564 2827 4865 6c6c 6f27 .created('Hello'\n+0004fa20: 2c20 3432 290a 0a20 2020 2053 6565 2074 , 42).. See t\n+0004fa30: 6865 2064 6f63 756d 656e 7461 7469 6f6e he documentation\n+0004fa40: 2066 6f72 2074 6865 204d 6574 686f 642c for the Method,\n+0004fa50: 2050 726f 7065 7274 792c 2061 6e64 2053 Property, and S\n+0004fa60: 6967 6e61 6c20 636c 6173 7365 7320 666f ignal classes fo\n+0004fa70: 720a 2020 2020 6d6f 7265 2069 6e66 6f72 r. more infor\n+0004fa80: 6d61 7469 6f6e 2061 6e64 2065 7861 6d70 mation and examp\n+0004fa90: 6c65 732e 0a20 2020 2022 2222 0a0a 2020 les.. \"\"\".. \n+0004faa0: 2020 2320 436c 6173 7320 7661 7269 6162 # Class variab\n+0004fab0: 6c65 730a 2020 2020 5f64 6275 735f 696e les. _dbus_in\n+0004fac0: 7465 7266 6163 6573 3a20 4469 6374 5b73 terfaces: Dict[s\n+0004fad0: 7472 2c20 4469 6374 5b73 7472 2c20 4469 tr, Dict[str, Di\n+0004fae0: 6374 5b73 7472 2c20 416e 795d 5d5d 0a20 ct[str, Any]]]. \n+0004faf0: 2020 205f 6462 7573 5f6d 656d 6265 7273 _dbus_members\n+0004fb00: 3a20 4f70 7469 6f6e 616c 5b54 7570 6c65 : Optional[Tuple\n+0004fb10: 5b73 7472 2c20 4469 6374 5b73 7472 2c20 [str, Dict[str, \n+0004fb20: 4469 6374 5b73 7472 2c20 416e 795d 5d5d Dict[str, Any]]]\n+0004fb30: 5d0a 0a20 2020 2023 2049 6e73 7461 6e63 ].. # Instanc\n+0004fb40: 6520 7661 7269 6162 6c65 733a 2073 746f e variables: sto\n+0004fb50: 7265 6420 696e 2050 7974 686f 6e20 666f red in Python fo\n+0004fb60: 726d 0a20 2020 205f 6462 7573 5f70 726f rm. _dbus_pro\n+0004fb70: 7065 7274 795f 7661 6c75 6573 3a20 4f70 perty_values: Op\n+0004fb80: 7469 6f6e 616c 5b44 6963 745b 7374 722c tional[Dict[str,\n+0004fb90: 2041 6e79 5d5d 203d 204e 6f6e 650a 0a20 Any]] = None.. \n+0004fba0: 2020 2040 636c 6173 736d 6574 686f 640a @classmethod.\n+0004fbb0: 2020 2020 6465 6620 5f5f 696e 6974 5f73 def __init_s\n+0004fbc0: 7562 636c 6173 735f 5f28 636c 732c 2069 ubclass__(cls, i\n+0004fbd0: 6e74 6572 6661 6365 3a20 4f70 7469 6f6e nterface: Option\n+0004fbe0: 616c 5b73 7472 5d20 3d20 4e6f 6e65 2920 al[str] = None) \n+0004fbf0: 2d3e 204e 6f6e 653a 0a20 2020 2020 2020 -> None:. \n+0004fc00: 2069 6620 696e 7465 7266 6163 6520 6973 if interface is\n+0004fc10: 204e 6f6e 653a 0a20 2020 2020 2020 2020 None:. \n+0004fc20: 2020 2061 7373 6572 7420 275f 5f27 206e assert '__' n\n+0004fc30: 6f74 2069 6e20 636c 732e 5f5f 6e61 6d65 ot in cls.__name\n+0004fc40: 5f5f 2c20 2743 6c61 7373 206e 616d 6520 __, 'Class name \n+0004fc50: 6361 6e6e 6f74 2063 6f6e 7461 696e 2073 cannot contain s\n+0004fc60: 6571 7565 6e74 6961 6c20 756e 6465 7273 equential unders\n+0004fc70: 636f 7265 7327 0a20 2020 2020 2020 2020 cores'. \n+0004fc80: 2020 2069 6e74 6572 6661 6365 203d 2063 interface = c\n+0004fc90: 6c73 2e5f 5f6e 616d 655f 5f2e 7265 706c ls.__name__.repl\n+0004fca0: 6163 6528 275f 272c 2027 2e27 290a 0a20 ace('_', '.').. \n+0004fcb0: 2020 2020 2020 2023 2054 6869 7320 6973 # This is\n+0004fcc0: 2074 6865 2069 6e66 6f72 6d61 7469 6f6e the information\n+0004fcd0: 2066 6f72 2074 6869 7320 7375 6263 6c61 for this subcla\n+0004fce0: 7373 2064 6972 6563 746c 790a 2020 2020 ss directly. \n+0004fcf0: 2020 2020 6d65 6d62 6572 733a 2044 6963 members: Dic\n+0004fd00: 745b 7374 722c 2044 6963 745b 7374 722c t[str, Dict[str,\n+0004fd10: 2049 6e74 6572 6661 6365 2e5f 4d65 6d62 Interface._Memb\n+0004fd20: 6572 5d5d 203d 207b 276d 6574 686f 6473 er]] = {'methods\n+0004fd30: 273a 207b 7d2c 2027 7072 6f70 6572 7469 ': {}, 'properti\n+0004fd40: 6573 273a 207b 7d2c 2027 7369 676e 616c es': {}, 'signal\n+0004fd50: 7327 3a20 7b7d 7d0a 2020 2020 2020 2020 s': {}}. \n+0004fd60: 666f 7220 6e61 6d65 2c20 6d65 6d62 6572 for name, member\n+0004fd70: 2069 6e20 636c 732e 5f5f 6469 6374 5f5f in cls.__dict__\n+0004fd80: 2e69 7465 6d73 2829 3a0a 2020 2020 2020 .items():. \n+0004fd90: 2020 2020 2020 6966 2069 7369 6e73 7461 if isinsta\n+0004fda0: 6e63 6528 6d65 6d62 6572 2c20 496e 7465 nce(member, Inte\n+0004fdb0: 7266 6163 652e 5f4d 656d 6265 7229 3a0a rface._Member):.\n+0004fdc0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0004fdd0: 6d65 6d62 6572 2e73 6574 7570 2869 6e74 member.setup(int\n+0004fde0: 6572 6661 6365 2c20 6e61 6d65 2c20 6d65 erface, name, me\n+0004fdf0: 6d62 6572 7329 0a0a 2020 2020 2020 2020 mbers).. \n+0004fe00: 2320 5765 206f 6e6c 7920 7374 6f72 6520 # We only store \n+0004fe10: 7468 6520 696e 666f 726d 6174 696f 6e20 the information \n+0004fe20: 6966 2073 6f6d 6574 6869 6e67 2077 6173 if something was\n+0004fe30: 2061 6374 7561 6c6c 7920 6465 6669 6e65 actually define\n+0004fe40: 640a 2020 2020 2020 2020 6966 2073 756d d. if sum\n+0004fe50: 286c 656e 2863 6174 6567 6f72 7929 2066 (len(category) f\n+0004fe60: 6f72 2063 6174 6567 6f72 7920 696e 206d or category in m\n+0004fe70: 656d 6265 7273 2e76 616c 7565 7328 2929 embers.values())\n+0004fe80: 203e 2030 3a0a 2020 2020 2020 2020 2020 > 0:. \n+0004fe90: 2020 636c 732e 5f64 6275 735f 6d65 6d62 cls._dbus_memb\n+0004fea0: 6572 7320 3d20 2869 6e74 6572 6661 6365 ers = (interface\n+0004feb0: 2c20 6d65 6d62 6572 7329 0a0a 2020 2020 , members).. \n+0004fec0: 2020 2020 2320 5468 6973 2069 7320 7468 # This is th\n+0004fed0: 6520 696e 666f 726d 6174 696f 6e20 666f e information fo\n+0004fee0: 7220 7468 6973 2073 7562 636c 6173 732c r this subclass,\n+0004fef0: 2077 6974 6820 616c 6c20 6974 7320 616e with all its an\n+0004ff00: 6365 7374 6f72 730a 2020 2020 2020 2020 cestors. \n+0004ff10: 636c 732e 5f64 6275 735f 696e 7465 7266 cls._dbus_interf\n+0004ff20: 6163 6573 203d 2064 6963 7428 616e 6365 aces = dict(ance\n+0004ff30: 7374 6f72 2e5f 5f64 6963 745f 5f5b 275f stor.__dict__['_\n+0004ff40: 6462 7573 5f6d 656d 6265 7273 275d 0a20 dbus_members']. \n+0004ff50: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0004ff60: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0004ff70: 2020 2066 6f72 2061 6e63 6573 746f 7220 for ancestor \n+0004ff80: 696e 2063 6c73 2e6d 726f 2829 0a20 2020 in cls.mro(). \n+0004ff90: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0004ffa0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0004ffb0: 2069 6620 275f 6462 7573 5f6d 656d 6265 if '_dbus_membe\n+0004ffc0: 7273 2720 696e 2061 6e63 6573 746f 722e rs' in ancestor.\n+0004ffd0: 5f5f 6469 6374 5f5f 290a 0a20 2020 2040 __dict__).. @\n+0004ffe0: 636c 6173 736d 6574 686f 640a 2020 2020 classmethod. \n+0004fff0: 6465 6620 5f66 696e 645f 696e 7465 7266 def _find_interf\n+00050000: 6163 6528 636c 732c 2069 6e74 6572 6661 ace(cls, interfa\n+00050010: 6365 3a20 7374 7229 202d 3e20 4469 6374 ce: str) -> Dict\n+00050020: 5b73 7472 2c20 4469 6374 5b73 7472 2c20 [str, Dict[str, \n+00050030: 275f 4d65 6d62 6572 275d 5d3a 0a20 2020 '_Member']]:. \n+00050040: 2020 2020 2074 7279 3a0a 2020 2020 2020 try:. \n+00050050: 2020 2020 2020 7265 7475 726e 2063 6c73 return cls\n+00050060: 2e5f 6462 7573 5f69 6e74 6572 6661 6365 ._dbus_interface\n+00050070: 735b 696e 7465 7266 6163 655d 0a20 2020 s[interface]. \n+00050080: 2020 2020 2065 7863 6570 7420 4b65 7945 except KeyE\n+00050090: 7272 6f72 2061 7320 6578 633a 0a20 2020 rror as exc:. \n+000500a0: 2020 2020 2020 2020 2072 6169 7365 204f raise O\n+000500b0: 626a 6563 742e 4d65 7468 6f64 2e55 6e68 bject.Method.Unh\n+000500c0: 616e 646c 6564 2066 726f 6d20 6578 630a andled from exc.\n+000500d0: 0a20 2020 2040 636c 6173 736d 6574 686f . @classmetho\n+000500e0: 640a 2020 2020 6465 6620 5f66 696e 645f d. def _find_\n+000500f0: 6361 7465 676f 7279 2863 6c73 2c20 696e category(cls, in\n+00050100: 7465 7266 6163 653a 2073 7472 2c20 6361 terface: str, ca\n+00050110: 7465 676f 7279 3a20 7374 7229 202d 3e20 tegory: str) -> \n+00050120: 4469 6374 5b73 7472 2c20 275f 4d65 6d62 Dict[str, '_Memb\n+00050130: 6572 275d 3a0a 2020 2020 2020 2020 7265 er']:. re\n+00050140: 7475 726e 2063 6c73 2e5f 6669 6e64 5f69 turn cls._find_i\n+00050150: 6e74 6572 6661 6365 2869 6e74 6572 6661 nterface(interfa\n+00050160: 6365 295b 6361 7465 676f 7279 5d0a 0a20 ce)[category].. \n+00050170: 2020 2040 636c 6173 736d 6574 686f 640a @classmethod.\n+00050180: 2020 2020 6465 6620 5f66 696e 645f 6d65 def _find_me\n+00050190: 6d62 6572 2863 6c73 2c20 696e 7465 7266 mber(cls, interf\n+000501a0: 6163 653a 2073 7472 2c20 6361 7465 676f ace: str, catego\n+000501b0: 7279 3a20 7374 722c 206d 656d 6265 723a ry: str, member:\n+000501c0: 2073 7472 2920 2d3e 2027 5f4d 656d 6265 str) -> '_Membe\n+000501d0: 7227 3a0a 2020 2020 2020 2020 6d65 6d62 r':. memb\n+000501e0: 6572 7320 3d20 636c 732e 5f66 696e 645f ers = cls._find_\n+000501f0: 6361 7465 676f 7279 2869 6e74 6572 6661 category(interfa\n+00050200: 6365 2c20 6361 7465 676f 7279 290a 2020 ce, category). \n+00050210: 2020 2020 2020 7472 793a 0a20 2020 2020 try:. \n+00050220: 2020 2020 2020 2072 6574 7572 6e20 6d65 return me\n+00050230: 6d62 6572 735b 6d65 6d62 6572 5d0a 2020 mbers[member]. \n+00050240: 2020 2020 2020 6578 6365 7074 204b 6579 except Key\n+00050250: 4572 726f 7220 6173 2065 7863 3a0a 2020 Error as exc:. \n+00050260: 2020 2020 2020 2020 2020 7261 6973 6520 raise \n+00050270: 4f62 6a65 6374 2e4d 6574 686f 642e 556e Object.Method.Un\n+00050280: 6861 6e64 6c65 6420 6672 6f6d 2065 7863 handled from exc\n+00050290: 0a0a 2020 2020 636c 6173 7320 5f4d 656d .. class _Mem\n+000502a0: 6265 723a 0a20 2020 2020 2020 205f 6361 ber:. _ca\n+000502b0: 7465 676f 7279 3a20 7374 7220 2023 2066 tegory: str # f\n+000502c0: 696c 6c65 6420 696e 2066 726f 6d20 7375 illed in from su\n+000502d0: 6263 6c61 7373 6573 0a0a 2020 2020 2020 bclasses.. \n+000502e0: 2020 5f70 7974 686f 6e5f 6e61 6d65 3a20 _python_name: \n+000502f0: 4f70 7469 6f6e 616c 5b73 7472 5d20 3d20 Optional[str] = \n+00050300: 4e6f 6e65 0a20 2020 2020 2020 205f 6e61 None. _na\n+00050310: 6d65 3a20 4f70 7469 6f6e 616c 5b73 7472 me: Optional[str\n+00050320: 5d20 3d20 4e6f 6e65 0a20 2020 2020 2020 ] = None. \n+00050330: 205f 696e 7465 7266 6163 653a 204f 7074 _interface: Opt\n+00050340: 696f 6e61 6c5b 7374 725d 203d 204e 6f6e ional[str] = Non\n+00050350: 650a 2020 2020 2020 2020 5f64 6573 6372 e. _descr\n+00050360: 6970 7469 6f6e 3a20 4f70 7469 6f6e 616c iption: Optional\n+00050370: 5b44 6963 745b 7374 722c 2041 6e79 5d5d [Dict[str, Any]]\n+00050380: 0a0a 2020 2020 2020 2020 6465 6620 5f5f .. def __\n+00050390: 696e 6974 5f5f 2873 656c 662c 206e 616d init__(self, nam\n+000503a0: 653a 204f 7074 696f 6e61 6c5b 7374 725d e: Optional[str]\n+000503b0: 203d 204e 6f6e 6529 202d 3e20 4e6f 6e65 = None) -> None\n+000503c0: 3a0a 2020 2020 2020 2020 2020 2020 7365 :. se\n+000503d0: 6c66 2e5f 7079 7468 6f6e 5f6e 616d 6520 lf._python_name \n+000503e0: 3d20 4e6f 6e65 0a20 2020 2020 2020 2020 = None. \n+000503f0: 2020 2073 656c 662e 5f69 6e74 6572 6661 self._interfa\n+00050400: 6365 203d 204e 6f6e 650a 2020 2020 2020 ce = None. \n+00050410: 2020 2020 2020 7365 6c66 2e5f 6e61 6d65 self._name\n+00050420: 203d 206e 616d 650a 0a20 2020 2020 2020 = name.. \n+00050430: 2064 6566 2073 6574 7570 2873 656c 662c def setup(self,\n+00050440: 2069 6e74 6572 6661 6365 3a20 7374 722c interface: str,\n+00050450: 206e 616d 653a 2073 7472 2c20 6d65 6d62 name: str, memb\n+00050460: 6572 733a 2044 6963 745b 7374 722c 2044 ers: Dict[str, D\n+00050470: 6963 745b 7374 722c 2027 496e 7465 7266 ict[str, 'Interf\n+00050480: 6163 652e 5f4d 656d 6265 7227 5d5d 2920 ace._Member']]) \n+00050490: 2d3e 204e 6f6e 653a 0a20 2020 2020 2020 -> None:. \n+000504a0: 2020 2020 2073 656c 662e 5f70 7974 686f self._pytho\n+000504b0: 6e5f 6e61 6d65 203d 206e 616d 6520 2023 n_name = name #\n+000504c0: 2066 6f72 2065 7272 6f72 206d 6573 7361 for error messa\n+000504d0: 6765 730a 2020 2020 2020 2020 2020 2020 ges. \n+000504e0: 6966 2073 656c 662e 5f6e 616d 6520 6973 if self._name is\n+000504f0: 204e 6f6e 653a 0a20 2020 2020 2020 2020 None:. \n+00050500: 2020 2020 2020 2073 656c 662e 5f6e 616d self._nam\n+00050510: 6520 3d20 2727 2e6a 6f69 6e28 776f 7264 e = ''.join(word\n+00050520: 2e74 6974 6c65 2829 2066 6f72 2077 6f72 .title() for wor\n+00050530: 6420 696e 206e 616d 652e 7370 6c69 7428 d in name.split(\n+00050540: 275f 2729 290a 2020 2020 2020 2020 2020 '_')). \n+00050550: 2020 7365 6c66 2e5f 696e 7465 7266 6163 self._interfac\n+00050560: 6520 3d20 696e 7465 7266 6163 650a 2020 e = interface. \n+00050570: 2020 2020 2020 2020 2020 7365 6c66 2e5f self._\n+00050580: 6465 7363 7269 7074 696f 6e20 3d20 7365 description = se\n+00050590: 6c66 2e5f 6465 7363 7269 6265 2829 0a20 lf._describe(). \n+000505a0: 2020 2020 2020 2020 2020 206d 656d 6265 membe\n+000505b0: 7273 5b73 656c 662e 5f63 6174 6567 6f72 rs[self._categor\n+000505c0: 795d 5b73 656c 662e 5f6e 616d 655d 203d y][self._name] =\n+000505d0: 2073 656c 660a 0a20 2020 2020 2020 2064 self.. d\n+000505e0: 6566 205f 6465 7363 7269 6265 2873 656c ef _describe(sel\n+000505f0: 6629 202d 3e20 4469 6374 5b73 7472 2c20 f) -> Dict[str, \n+00050600: 416e 795d 3a0a 2020 2020 2020 2020 2020 Any]:. \n+00050610: 2020 7261 6973 6520 4e6f 7449 6d70 6c65 raise NotImple\n+00050620: 6d65 6e74 6564 4572 726f 720a 0a20 2020 mentedError.. \n+00050630: 2020 2020 2064 6566 205f 5f67 6574 6974 def __getit\n+00050640: 656d 5f5f 2873 656c 662c 206b 6579 3a20 em__(self, key: \n+00050650: 7374 7229 202d 3e20 416e 793a 0a20 2020 str) -> Any:. \n+00050660: 2020 2020 2020 2020 2023 2041 6374 7320 # Acts \n+00050670: 6173 2061 6e20 6164 6170 746f 7220 666f as an adaptor fo\n+00050680: 7220 6469 6374 2061 6363 6573 7365 7320 r dict accesses \n+00050690: 6672 6f6d 2069 6e74 726f 7370 6563 7469 from introspecti\n+000506a0: 6f6e 2e74 6f5f 786d 6c28 290a 2020 2020 on.to_xml(). \n+000506b0: 2020 2020 2020 2020 6173 7365 7274 2073 assert s\n+000506c0: 656c 662e 5f64 6573 6372 6970 7469 6f6e elf._description\n+000506d0: 2069 7320 6e6f 7420 4e6f 6e65 0a20 2020 is not None. \n+000506e0: 2020 2020 2020 2020 2072 6574 7572 6e20 return \n+000506f0: 7365 6c66 2e5f 6465 7363 7269 7074 696f self._descriptio\n+00050700: 6e5b 6b65 795d 0a0a 2020 2020 636c 6173 n[key].. clas\n+00050710: 7320 5072 6f70 6572 7479 285f 4d65 6d62 s Property(_Memb\n+00050720: 6572 293a 0a20 2020 2020 2020 2022 2222 er):. \"\"\"\n+00050730: 4465 6669 6e65 7320 6120 442d 4275 7320 Defines a D-Bus \n+00050740: 7072 6f70 6572 7479 206f 6e20 616e 2069 property on an i\n+00050750: 6e74 6572 6661 6365 0a0a 2020 2020 2020 nterface.. \n+00050760: 2020 5468 6572 6520 6172 6520 7477 6f20 There are two \n+00050770: 6d61 696e 2077 6179 7320 746f 2064 6566 main ways to def\n+00050780: 696e 6520 7072 6f70 6572 7469 6573 3a20 ine properties: \n+00050790: 7769 7468 2061 6e64 2077 6974 686f 7574 with and without\n+000507a0: 2067 6574 7465 7273 2e0a 2020 2020 2020 getters.. \n+000507b0: 2020 4966 2079 6f75 2064 6566 696e 6520 If you define \n+000507c0: 6120 7072 6f70 6572 7479 2077 6974 686f a property witho\n+000507d0: 7574 2061 2067 6574 7465 722c 2074 6865 ut a getter, the\n+000507e0: 6e20 796f 7520 6d75 7374 2070 726f 7669 n you must provi\n+000507f0: 6465 2061 0a20 2020 2020 2020 2076 616c de a. val\n+00050800: 7565 2028 7669 6120 7468 6520 7661 6c75 ue (via the valu\n+00050810: 653d 206b 7761 7267 292e 2020 496e 2074 e= kwarg). In t\n+00050820: 6869 7320 6361 7365 2c20 7468 6520 7072 his case, the pr\n+00050830: 6f70 6572 7479 2076 616c 7565 2069 730a operty value is.\n+00050840: 2020 2020 2020 2020 6d61 696e 7461 696e maintain\n+00050850: 6564 2069 6e74 6572 6e61 6c6c 7920 616e ed internally an\n+00050860: 6420 6361 6e20 6265 2061 6363 6573 7365 d can be accesse\n+00050870: 6420 6672 6f6d 2050 7974 686f 6e20 696e d from Python in\n+00050880: 2074 6865 2075 7375 616c 2077 6179 2e0a the usual way..\n+00050890: 2020 2020 2020 2020 4368 616e 6765 2073 Change s\n+000508a0: 6967 6e61 6c73 2061 7265 2073 656e 7420 ignals are sent \n+000508b0: 6175 746f 6d61 7469 6361 6c6c 792e 0a0a automatically...\n+000508c0: 2020 2020 2020 2020 2020 2020 636c 6173 clas\n+000508d0: 7320 4d79 4f62 6a65 6374 2862 7573 2e4f s MyObject(bus.O\n+000508e0: 626a 6563 7429 3a0a 2020 2020 2020 2020 bject):. \n+000508f0: 2020 2020 2020 2020 636f 756e 7465 7220 counter \n+00050900: 3d20 6275 732e 496e 7465 7266 6163 652e = bus.Interface.\n+00050910: 5072 6f70 6572 7479 2827 6927 2c20 7661 Property('i', va\n+00050920: 6c75 653d 3029 0a0a 2020 2020 2020 2020 lue=0).. \n+00050930: 2020 2020 6120 3d20 4d79 4f62 6a65 6374 a = MyObject\n+00050940: 2829 0a20 2020 2020 2020 2020 2020 2061 (). a\n+00050950: 2e63 6f75 6e74 6572 203d 2035 0a20 2020 .counter = 5. \n+00050960: 2020 2020 2020 2020 2061 2e63 6f75 6e74 a.count\n+00050970: 6572 202b 3d20 310a 2020 2020 2020 2020 er += 1. \n+00050980: 2020 2020 7072 696e 7428 612e 636f 756e print(a.coun\n+00050990: 7465 7229 0a0a 2020 2020 2020 2020 5468 ter).. Th\n+000509a0: 6520 6f74 6865 7220 7761 7920 746f 2064 e other way to d\n+000509b0: 6566 696e 6520 7072 6f70 6572 7469 6573 efine properties\n+000509c0: 2069 7320 7769 7468 2061 2067 6574 7465 is with a gette\n+000509d0: 7220 6675 6e63 7469 6f6e 2e20 2049 6e20 r function. In \n+000509e0: 7468 6973 0a20 2020 2020 2020 2063 6173 this. cas\n+000509f0: 652c 2079 6f75 2063 616e 2072 6561 6420 e, you can read \n+00050a00: 6672 6f6d 2074 6865 2070 726f 7065 7274 from the propert\n+00050a10: 7920 696e 2074 6865 206e 6f72 6d61 6c20 y in the normal \n+00050a20: 7761 792c 2062 7574 206e 6f74 2077 7269 way, but not wri\n+00050a30: 7465 0a20 2020 2020 2020 2074 6f20 6974 te. to it\n+00050a40: 2e20 2059 6f75 2061 7265 2072 6573 706f . You are respo\n+00050a50: 6e73 6962 6c65 2066 6f72 2065 6d69 7474 nsible for emitt\n+00050a60: 696e 6720 6368 616e 6765 2073 6967 6e61 ing change signa\n+00050a70: 6c73 2066 6f72 2079 6f75 7273 656c 662e ls for yourself.\n+00050a80: 0a20 2020 2020 2020 2059 6f75 206d 7573 . You mus\n+00050a90: 7420 6e6f 7420 7072 6f76 6964 6520 7468 t not provide th\n+00050aa0: 6520 7661 6c75 653d 206b 7761 7267 2e0a e value= kwarg..\n+00050ab0: 0a20 2020 2020 2020 2020 2020 2063 6c61 . cla\n+00050ac0: 7373 204d 794f 626a 6563 7428 6275 732e ss MyObject(bus.\n+00050ad0: 4f62 6a65 6374 293a 0a20 2020 2020 2020 Object):. \n+00050ae0: 2020 2020 2020 2020 205f 636f 756e 7465 _counte\n+00050af0: 7220 3d20 300a 0a20 2020 2020 2020 2020 r = 0.. \n+00050b00: 2020 2020 2020 2063 6f75 6e74 6572 203d counter =\n+00050b10: 2062 7573 2e49 6e74 6572 6661 6365 2e50 bus.Interface.P\n+00050b20: 726f 7065 7274 7928 2769 2729 0a20 2020 roperty('i'). \n+00050b30: 2020 2020 2020 2020 2020 2020 2040 636f @co\n+00050b40: 756e 7465 722e 6765 7474 6572 0a20 2020 unter.getter. \n+00050b50: 2020 2020 2020 2020 2020 2020 2064 6566 def\n+00050b60: 2067 6574 5f63 6f75 6e74 6572 2873 656c get_counter(sel\n+00050b70: 6629 3a0a 2020 2020 2020 2020 2020 2020 f):. \n+00050b80: 2020 2020 2020 2020 7265 7475 726e 2073 return s\n+00050b90: 656c 662e 5f63 6f75 6e74 6572 0a0a 2020 elf._counter.. \n+00050ba0: 2020 2020 2020 2020 2020 2020 2020 4063 @c\n+00050bb0: 6f75 6e74 6572 2e73 6574 7465 720a 2020 ounter.setter. \n+00050bc0: 2020 2020 2020 2020 2020 2020 2020 6465 de\n+00050bd0: 6620 7365 745f 636f 756e 7465 7228 7365 f set_counter(se\n+00050be0: 6c66 2c20 7661 6c75 6529 3a0a 2020 2020 lf, value):. \n+00050bf0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00050c00: 7365 6c66 2e5f 636f 756e 7465 7220 3d20 self._counter = \n+00050c10: 7661 6c75 650a 2020 2020 2020 2020 2020 value. \n+00050c20: 2020 2020 2020 2020 2020 7365 6c66 2e70 self.p\n+00050c30: 726f 7065 7274 795f 6368 616e 6765 6428 roperty_changed(\n+00050c40: 2743 6f75 6e74 6572 2729 0a0a 2020 2020 'Counter').. \n+00050c50: 2020 2020 496e 2065 6974 6865 7220 6361 In either ca\n+00050c60: 7365 2c20 796f 7520 6361 6e20 7072 6f76 se, you can prov\n+00050c70: 6964 6520 6120 7365 7474 6572 2066 756e ide a setter fun\n+00050c80: 6374 696f 6e2e 2020 5468 6973 2066 756e ction. This fun\n+00050c90: 6374 696f 6e20 6861 730a 2020 2020 2020 ction has. \n+00050ca0: 2020 6e6f 2069 6d70 6163 7420 6f6e 2050 no impact on P\n+00050cb0: 7974 686f 6e20 636f 6465 2c20 6275 7420 ython code, but \n+00050cc0: 6d61 6b65 7320 7468 6520 7072 6f70 6572 makes the proper\n+00050cd0: 7479 2077 7269 7461 626c 6520 6672 6f6d ty writable from\n+00050ce0: 2074 6865 2076 6965 770a 2020 2020 2020 the view. \n+00050cf0: 2020 6f66 2044 2d42 7573 2e20 2059 6f75 of D-Bus. You\n+00050d00: 7220 7365 7474 6572 2077 696c 6c20 6265 r setter will be\n+00050d10: 2063 616c 6c65 6420 7768 656e 2061 2050 called when a P\n+00050d20: 726f 7065 7274 6965 732e 5365 7428 2920 roperties.Set() \n+00050d30: 6361 6c6c 2069 730a 2020 2020 2020 2020 call is. \n+00050d40: 6d61 6465 2c20 616e 6420 6e6f 206f 7468 made, and no oth\n+00050d50: 6572 2061 6374 696f 6e20 7769 6c6c 2062 er action will b\n+00050d60: 6520 7065 7266 6f72 6d65 642e 2020 4120 e performed. A \n+00050d70: 7472 6976 6961 6c20 696d 706c 656d 656e trivial implemen\n+00050d80: 7461 7469 6f6e 0a20 2020 2020 2020 206d tation. m\n+00050d90: 6967 6874 206c 6f6f 6b20 6c69 6b65 3a0a ight look like:.\n+00050da0: 0a20 2020 2020 2020 2020 2020 2063 6c61 . cla\n+00050db0: 7373 204d 794f 626a 6563 7428 6275 732e ss MyObject(bus.\n+00050dc0: 4f62 6a65 6374 293a 0a20 2020 2020 2020 Object):. \n+00050dd0: 2020 2020 2020 2020 2063 6f75 6e74 6572 counter\n+00050de0: 203d 2062 7573 2e49 6e74 6572 6661 6365 = bus.Interface\n+00050df0: 2e50 726f 7065 7274 7928 2769 272c 2076 .Property('i', v\n+00050e00: 616c 7565 3d30 290a 2020 2020 2020 2020 alue=0). \n+00050e10: 2020 2020 2020 2020 4063 6f75 6e74 6572 @counter\n+00050e20: 2e73 6574 7465 720a 2020 2020 2020 2020 .setter. \n+00050e30: 2020 2020 2020 2020 6465 6620 7365 745f def set_\n+00050e40: 636f 756e 7465 7228 7365 6c66 2c20 7661 counter(self, va\n+00050e50: 6c75 6529 3a0a 2020 2020 2020 2020 2020 lue):. \n+00050e60: 2020 2020 2020 2020 2020 2320 7765 2067 # we g\n+00050e70: 6f74 2061 2072 6571 7565 7374 2074 6f20 ot a request to \n+00050e80: 7365 7420 7468 6520 636f 756e 7465 7220 set the counter \n+00050e90: 6672 6f6d 2044 2d42 7573 0a20 2020 2020 from D-Bus. \n+00050ea0: 2020 2020 2020 2020 2020 2020 2020 2073 s\n+00050eb0: 656c 662e 636f 756e 7465 7220 3d20 7661 elf.counter = va\n+00050ec0: 6c75 650a 0a20 2020 2020 2020 2049 6e20 lue.. In \n+00050ed0: 616c 6c20 6361 7365 732c 2074 6865 2066 all cases, the f\n+00050ee0: 6972 7374 2028 616e 6420 6f6e 6c79 206d irst (and only m\n+00050ef0: 616e 6461 746f 7279 2920 6172 6775 6d65 andatory) argume\n+00050f00: 6e74 2074 6f20 7468 650a 2020 2020 2020 nt to the. \n+00050f10: 2020 636f 6e73 7472 7563 746f 7220 6973 constructor is\n+00050f20: 2074 6865 2044 2d42 7573 2074 7970 6520 the D-Bus type \n+00050f30: 6f66 2074 6865 2070 726f 7065 7274 792e of the property.\n+00050f40: 0a0a 2020 2020 2020 2020 596f 7572 2067 .. Your g\n+00050f50: 6574 7465 7220 616e 6420 7365 7474 6572 etter and setter\n+00050f60: 2066 756e 6374 696f 6e73 2063 616e 2062 functions can b\n+00050f70: 6520 7072 6f76 6964 6564 2062 7920 6b77 e provided by kw\n+00050f80: 6172 6720 746f 2074 6865 0a20 2020 2020 arg to the. \n+00050f90: 2020 2063 6f6e 7374 7275 6374 6f72 2e20 constructor. \n+00050fa0: 2059 6f75 2063 616e 2061 6c73 6f20 6769 You can also gi\n+00050fb0: 7665 2061 206e 616d 653d 206b 7761 7267 ve a name= kwarg\n+00050fc0: 2074 6f20 6f76 6572 7269 6465 2074 6865 to override the\n+00050fd0: 2064 6566 6175 6c74 0a20 2020 2020 2020 default. \n+00050fe0: 206e 616d 6520 636f 6e76 6572 7369 6f6e name conversion\n+00050ff0: 2073 6368 656d 652e 0a20 2020 2020 2020 scheme.. \n+00051000: 2022 2222 0a20 2020 2020 2020 205f 6361 \"\"\". _ca\n+00051010: 7465 676f 7279 203d 2027 7072 6f70 6572 tegory = 'proper\n+00051020: 7469 6573 270a 0a20 2020 2020 2020 205f ties'.. _\n+00051030: 6765 7474 6572 3a20 4f70 7469 6f6e 616c getter: Optional\n+00051040: 5b43 616c 6c61 626c 655b 5b41 6e79 5d2c [Callable[[Any],\n+00051050: 2041 6e79 5d5d 0a20 2020 2020 2020 205f Any]]. _\n+00051060: 7365 7474 6572 3a20 4f70 7469 6f6e 616c setter: Optional\n+00051070: 5b43 616c 6c61 626c 655b 5b41 6e79 2c20 [Callable[[Any, \n+00051080: 416e 795d 2c20 4e6f 6e65 5d5d 0a20 2020 Any], None]]. \n+00051090: 2020 2020 205f 7479 7065 3a20 6275 7374 _type: bust\n+000510a0: 7970 6573 2e54 7970 650a 2020 2020 2020 ypes.Type. \n+000510b0: 2020 5f76 616c 7565 3a20 416e 790a 0a20 _value: Any.. \n+000510c0: 2020 2020 2020 2064 6566 205f 5f69 6e69 def __ini\n+000510d0: 745f 5f28 7365 6c66 2c20 7479 7065 5f73 t__(self, type_s\n+000510e0: 7472 696e 673a 2073 7472 2c0a 2020 2020 tring: str,. \n+000510f0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00051100: 2076 616c 7565 3a20 416e 7920 3d20 4e6f value: Any = No\n+00051110: 6e65 2c0a 2020 2020 2020 2020 2020 2020 ne,. \n+00051120: 2020 2020 2020 2020 206e 616d 653a 204f name: O\n+00051130: 7074 696f 6e61 6c5b 7374 725d 203d 204e ptional[str] = N\n+00051140: 6f6e 652c 0a20 2020 2020 2020 2020 2020 one,. \n+00051150: 2020 2020 2020 2020 2020 6765 7474 6572 getter\n+00051160: 3a20 4f70 7469 6f6e 616c 5b43 616c 6c61 : Optional[Calla\n+00051170: 626c 655b 5b41 6e79 5d2c 2041 6e79 5d5d ble[[Any], Any]]\n+00051180: 203d 204e 6f6e 652c 0a20 2020 2020 2020 = None,. \n+00051190: 2020 2020 2020 2020 2020 2020 2020 7365 se\n+000511a0: 7474 6572 3a20 4f70 7469 6f6e 616c 5b43 tter: Optional[C\n+000511b0: 616c 6c61 626c 655b 5b41 6e79 2c20 416e allable[[Any, An\n+000511c0: 795d 2c20 4e6f 6e65 5d5d 203d 204e 6f6e y], None]] = Non\n+000511d0: 6529 3a0a 2020 2020 2020 2020 2020 2020 e):. \n+000511e0: 6173 7365 7274 2076 616c 7565 2069 7320 assert value is \n+000511f0: 4e6f 6e65 206f 7220 6765 7474 6572 2069 None or getter i\n+00051200: 7320 4e6f 6e65 2c20 2741 2070 726f 7065 s None, 'A prope\n+00051210: 7274 7920 6361 6e6e 6f74 2068 6176 6520 rty cannot have \n+00051220: 626f 7468 2061 2076 616c 7565 2061 6e64 both a value and\n+00051230: 2061 2067 6574 7465 7227 0a0a 2020 2020 a getter'.. \n+00051240: 2020 2020 2020 2020 7375 7065 7228 292e super().\n+00051250: 5f5f 696e 6974 5f5f 286e 616d 653d 6e61 __init__(name=na\n+00051260: 6d65 290a 2020 2020 2020 2020 2020 2020 me). \n+00051270: 7365 6c66 2e5f 6765 7474 6572 203d 2067 self._getter = g\n+00051280: 6574 7465 720a 2020 2020 2020 2020 2020 etter. \n+00051290: 2020 7365 6c66 2e5f 7365 7474 6572 203d self._setter =\n+000512a0: 2073 6574 7465 720a 2020 2020 2020 2020 setter. \n+000512b0: 2020 2020 7365 6c66 2e5f 7479 7065 2c20 self._type, \n+000512c0: 3d20 6275 7374 7970 6573 2e66 726f 6d5f = bustypes.from_\n+000512d0: 7369 676e 6174 7572 6528 7479 7065 5f73 signature(type_s\n+000512e0: 7472 696e 6729 0a20 2020 2020 2020 2020 tring). \n+000512f0: 2020 2073 656c 662e 5f76 616c 7565 203d self._value =\n+00051300: 2076 616c 7565 0a0a 2020 2020 2020 2020 value.. \n+00051310: 6465 6620 5f64 6573 6372 6962 6528 7365 def _describe(se\n+00051320: 6c66 2920 2d3e 2044 6963 745b 7374 722c lf) -> Dict[str,\n+00051330: 2041 6e79 5d3a 0a20 2020 2020 2020 2020 Any]:. \n+00051340: 2020 2072 6574 7572 6e20 7b27 7479 7065 return {'type\n+00051350: 273a 2073 656c 662e 5f74 7970 652e 7479 ': self._type.ty\n+00051360: 7065 7374 7269 6e67 2c20 2766 6c61 6773 pestring, 'flags\n+00051370: 273a 2027 7227 2069 6620 7365 6c66 2e5f ': 'r' if self._\n+00051380: 7365 7474 6572 2069 7320 4e6f 6e65 2065 setter is None e\n+00051390: 6c73 6520 2777 277d 0a0a 2020 2020 2020 lse 'w'}.. \n+000513a0: 2020 6465 6620 5f5f 6765 745f 5f28 7365 def __get__(se\n+000513b0: 6c66 2c20 6f62 6a3a 2027 4f62 6a65 6374 lf, obj: 'Object\n+000513c0: 272c 2063 6c73 3a20 4f70 7469 6f6e 616c ', cls: Optional\n+000513d0: 5b74 7970 655d 203d 204e 6f6e 6529 202d [type] = None) -\n+000513e0: 3e20 416e 793a 0a20 2020 2020 2020 2020 > Any:. \n+000513f0: 2020 2061 7373 6572 7420 7365 6c66 2e5f assert self._\n+00051400: 6e61 6d65 2069 7320 6e6f 7420 4e6f 6e65 name is not None\n+00051410: 0a20 2020 2020 2020 2020 2020 2069 6620 . if \n+00051420: 6f62 6a20 6973 204e 6f6e 653a 0a20 2020 obj is None:. \n+00051430: 2020 2020 2020 2020 2020 2020 2072 6574 ret\n+00051440: 7572 6e20 7365 6c66 0a20 2020 2020 2020 urn self. \n+00051450: 2020 2020 2069 6620 7365 6c66 2e5f 6765 if self._ge\n+00051460: 7474 6572 2069 7320 6e6f 7420 4e6f 6e65 tter is not None\n+00051470: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n+00051480: 2020 7265 7475 726e 2073 656c 662e 5f67 return self._g\n+00051490: 6574 7465 722e 5f5f 6765 745f 5f28 6f62 etter.__get__(ob\n+000514a0: 6a2c 2063 6c73 2928 290a 2020 2020 2020 j, cls)(). \n+000514b0: 2020 2020 2020 656c 6966 2073 656c 662e elif self.\n+000514c0: 5f76 616c 7565 2069 7320 6e6f 7420 4e6f _value is not No\n+000514d0: 6e65 3a0a 2020 2020 2020 2020 2020 2020 ne:. \n+000514e0: 2020 2020 6966 206f 626a 2e5f 6462 7573 if obj._dbus\n+000514f0: 5f70 726f 7065 7274 795f 7661 6c75 6573 _property_values\n+00051500: 2069 7320 6e6f 7420 4e6f 6e65 3a0a 2020 is not None:. \n+00051510: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00051520: 2020 7265 7475 726e 206f 626a 2e5f 6462 return obj._db\n+00051530: 7573 5f70 726f 7065 7274 795f 7661 6c75 us_property_valu\n+00051540: 6573 2e67 6574 2873 656c 662e 5f6e 616d es.get(self._nam\n+00051550: 652c 2073 656c 662e 5f76 616c 7565 290a e, self._value).\n+00051560: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00051570: 656c 7365 3a0a 2020 2020 2020 2020 2020 else:. \n+00051580: 2020 2020 2020 2020 2020 7265 7475 726e return\n+00051590: 2073 656c 662e 5f76 616c 7565 0a20 2020 self._value. \n+000515a0: 2020 2020 2020 2020 2065 6c73 653a 0a20 else:. \n+000515b0: 2020 2020 2020 2020 2020 2020 2020 2072 r\n+000515c0: 6169 7365 2041 7474 7269 6275 7465 4572 aise AttributeEr\n+000515d0: 726f 7228 6622 277b 6f62 6a2e 5f5f 636c ror(f\"'{obj.__cl\n+000515e0: 6173 735f 5f2e 5f5f 6e61 6d65 5f5f 7d27 ass__.__name__}'\n+000515f0: 2070 726f 7065 7274 7920 277b 7365 6c66 property '{self\n+00051600: 2e5f 7079 7468 6f6e 5f6e 616d 657d 2720 ._python_name}' \n+00051610: 220a 2020 2020 2020 2020 2020 2020 2020 \". \n+00051620: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00051630: 2020 2020 2020 2066 2277 6173 206e 6f74 f\"was not\n+00051640: 2070 726f 7065 726c 7920 696e 6974 6961 properly initia\n+00051650: 6c69 7365 643a 2075 7365 2065 6974 6865 lised: use eithe\n+00051660: 7220 7468 6520 2776 616c 7565 3d27 206b r the 'value=' k\n+00051670: 7761 7267 206f 7220 220a 2020 2020 2020 warg or \". \n+00051680: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00051690: 2020 2020 2020 2020 2020 2020 2020 2066 f\n+000516a0: 2274 6865 2040 277b 7365 6c66 2e5f 7079 \"the @'{self._py\n+000516b0: 7468 6f6e 5f6e 616d 657d 2e67 6574 7465 thon_name}.gette\n+000516c0: 7227 2064 6563 6f72 6174 6f72 2229 0a0a r' decorator\")..\n+000516d0: 2020 2020 2020 2020 6465 6620 5f5f 7365 def __se\n+000516e0: 745f 5f28 7365 6c66 2c20 6f62 6a3a 2027 t__(self, obj: '\n+000516f0: 4f62 6a65 6374 272c 2076 616c 7565 3a20 Object', value: \n+00051700: 416e 7929 202d 3e20 4e6f 6e65 3a0a 2020 Any) -> None:. \n+00051710: 2020 2020 2020 2020 2020 6173 7365 7274 assert\n+00051720: 2073 656c 662e 5f6e 616d 6520 6973 206e self._name is n\n+00051730: 6f74 204e 6f6e 650a 2020 2020 2020 2020 ot None. \n+00051740: 2020 2020 6966 2073 656c 662e 5f67 6574 if self._get\n+00051750: 7465 7220 6973 206e 6f74 204e 6f6e 653a ter is not None:\n+00051760: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+00051770: 2072 6169 7365 2041 7474 7269 6275 7465 raise Attribute\n+00051780: 4572 726f 7228 6622 4361 6e6e 6f74 2064 Error(f\"Cannot d\n+00051790: 6972 6563 746c 7920 6173 7369 676e 2027 irectly assign '\n+000517a0: 7b6f 626a 2e5f 5f63 6c61 7373 5f5f 2e5f {obj.__class__._\n+000517b0: 5f6e 616d 655f 5f7d 2720 220a 2020 2020 _name__}' \". \n+000517c0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000517d0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000517e0: 2022 7072 6f70 6572 7479 2027 7b73 656c \"property '{sel\n+000517f0: 662e 5f70 7974 686f 6e5f 6e61 6d65 7d27 f._python_name}'\n+00051800: 2062 6563 6175 7365 2069 7420 6861 7320 because it has \n+00051810: 6120 6765 7474 6572 2229 0a20 2020 2020 a getter\"). \n+00051820: 2020 2020 2020 2069 6620 6f62 6a2e 5f64 if obj._d\n+00051830: 6275 735f 7072 6f70 6572 7479 5f76 616c bus_property_val\n+00051840: 7565 7320 6973 204e 6f6e 653a 0a20 2020 ues is None:. \n+00051850: 2020 2020 2020 2020 2020 2020 206f 626a obj\n+00051860: 2e5f 6462 7573 5f70 726f 7065 7274 795f ._dbus_property_\n+00051870: 7661 6c75 6573 203d 207b 7d0a 2020 2020 values = {}. \n+00051880: 2020 2020 2020 2020 6f62 6a2e 5f64 6275 obj._dbu\n+00051890: 735f 7072 6f70 6572 7479 5f76 616c 7565 s_property_value\n+000518a0: 735b 7365 6c66 2e5f 6e61 6d65 5d20 3d20 s[self._name] = \n+000518b0: 7661 6c75 650a 2020 2020 2020 2020 2020 value. \n+000518c0: 2020 6966 206f 626a 2e5f 6462 7573 5f62 if obj._dbus_b\n+000518d0: 7573 2069 7320 6e6f 7420 4e6f 6e65 3a0a us is not None:.\n+000518e0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000518f0: 6f62 6a2e 7072 6f70 6572 7469 6573 5f63 obj.properties_c\n+00051900: 6861 6e67 6564 2873 656c 662e 5f69 6e74 hanged(self._int\n+00051910: 6572 6661 6365 2c20 7b73 656c 662e 5f6e erface, {self._n\n+00051920: 616d 653a 2062 7573 7479 7065 732e 5661 ame: bustypes.Va\n+00051930: 7269 616e 7428 7661 6c75 652c 2073 656c riant(value, sel\n+00051940: 662e 5f74 7970 6529 7d2c 205b 5d29 0a0a f._type)}, [])..\n+00051950: 2020 2020 2020 2020 6465 6620 746f 5f64 def to_d\n+00051960: 6275 7328 7365 6c66 2c20 6f62 6a3a 2027 bus(self, obj: '\n+00051970: 4f62 6a65 6374 2729 202d 3e20 6275 7374 Object') -> bust\n+00051980: 7970 6573 2e56 6172 6961 6e74 3a0a 2020 ypes.Variant:. \n+00051990: 2020 2020 2020 2020 2020 7265 7475 726e return\n+000519a0: 2062 7573 7479 7065 732e 5661 7269 616e bustypes.Varian\n+000519b0: 7428 7365 6c66 2e5f 5f67 6574 5f5f 286f t(self.__get__(o\n+000519c0: 626a 292c 2073 656c 662e 5f74 7970 6529 bj), self._type)\n+000519d0: 0a0a 2020 2020 2020 2020 6465 6620 6672 .. def fr\n+000519e0: 6f6d 5f64 6275 7328 7365 6c66 2c20 6f62 om_dbus(self, ob\n+000519f0: 6a3a 2027 4f62 6a65 6374 272c 2076 616c j: 'Object', val\n+00051a00: 7565 3a20 6275 7374 7970 6573 2e56 6172 ue: bustypes.Var\n+00051a10: 6961 6e74 2920 2d3e 204e 6f6e 653a 0a20 iant) -> None:. \n+00051a20: 2020 2020 2020 2020 2020 2069 6620 7365 if se\n+00051a30: 6c66 2e5f 7365 7474 6572 2069 7320 4e6f lf._setter is No\n+00051a40: 6e65 206f 7220 7365 6c66 2e5f 7479 7065 ne or self._type\n+00051a50: 2021 3d20 7661 6c75 652e 7479 7065 3a0a != value.type:.\n+00051a60: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00051a70: 7261 6973 6520 4f62 6a65 6374 2e4d 6574 raise Object.Met\n+00051a80: 686f 642e 556e 6861 6e64 6c65 640a 2020 hod.Unhandled. \n+00051a90: 2020 2020 2020 2020 2020 7365 6c66 2e5f self._\n+00051aa0: 7365 7474 6572 2e5f 5f67 6574 5f5f 286f setter.__get__(o\n+00051ab0: 626a 2928 7661 6c75 652e 7661 6c75 6529 bj)(value.value)\n+00051ac0: 0a0a 2020 2020 2020 2020 6465 6620 6765 .. def ge\n+00051ad0: 7474 6572 2873 656c 662c 2067 6574 7465 tter(self, gette\n+00051ae0: 723a 2043 616c 6c61 626c 655b 5b41 6e79 r: Callable[[Any\n+00051af0: 5d2c 2041 6e79 5d29 202d 3e20 4361 6c6c ], Any]) -> Call\n+00051b00: 6162 6c65 5b5b 416e 795d 2c20 416e 795d able[[Any], Any]\n+00051b10: 3a0a 2020 2020 2020 2020 2020 2020 6966 :. if\n+00051b20: 2073 656c 662e 5f76 616c 7565 2069 7320 self._value is \n+00051b30: 6e6f 7420 4e6f 6e65 3a0a 2020 2020 2020 not None:. \n+00051b40: 2020 2020 2020 2020 2020 7261 6973 6520 raise \n+00051b50: 5661 6c75 6545 7272 6f72 2827 4120 7072 ValueError('A pr\n+00051b60: 6f70 6572 7479 2063 616e 6e6f 7420 6861 operty cannot ha\n+00051b70: 7665 2062 6f74 6820 6120 7661 6c75 6520 ve both a value \n+00051b80: 616e 6420 6120 6765 7474 6572 2729 0a20 and a getter'). \n+00051b90: 2020 2020 2020 2020 2020 2069 6620 7365 if se\n+00051ba0: 6c66 2e5f 6765 7474 6572 2069 7320 6e6f lf._getter is no\n+00051bb0: 7420 4e6f 6e65 3a0a 2020 2020 2020 2020 t None:. \n+00051bc0: 2020 2020 2020 2020 7261 6973 6520 5661 raise Va\n+00051bd0: 6c75 6545 7272 6f72 2827 5468 6973 2070 lueError('This p\n+00051be0: 726f 7065 7274 7920 616c 7265 6164 7920 roperty already \n+00051bf0: 6861 7320 6120 6765 7474 6572 2729 0a20 has a getter'). \n+00051c00: 2020 2020 2020 2020 2020 2073 656c 662e self.\n+00051c10: 5f67 6574 7465 7220 3d20 6765 7474 6572 _getter = getter\n+00051c20: 0a20 2020 2020 2020 2020 2020 2072 6574 . ret\n+00051c30: 7572 6e20 6765 7474 6572 0a0a 2020 2020 urn getter.. \n+00051c40: 2020 2020 6465 6620 7365 7474 6572 2873 def setter(s\n+00051c50: 656c 662c 2073 6574 7465 723a 2043 616c elf, setter: Cal\n+00051c60: 6c61 626c 655b 5b41 6e79 2c20 416e 795d lable[[Any, Any]\n+00051c70: 2c20 4e6f 6e65 5d29 202d 3e20 4361 6c6c , None]) -> Call\n+00051c80: 6162 6c65 5b5b 416e 792c 2041 6e79 5d2c able[[Any, Any],\n+00051c90: 204e 6f6e 655d 3a0a 2020 2020 2020 2020 None]:. \n+00051ca0: 2020 2020 7365 6c66 2e5f 7365 7474 6572 self._setter\n+00051cb0: 203d 2073 6574 7465 720a 2020 2020 2020 = setter. \n+00051cc0: 2020 2020 2020 7265 7475 726e 2073 6574 return set\n+00051cd0: 7465 720a 0a20 2020 2063 6c61 7373 2053 ter.. class S\n+00051ce0: 6967 6e61 6c28 5f4d 656d 6265 7229 3a0a ignal(_Member):.\n+00051cf0: 2020 2020 2020 2020 2222 2244 6566 696e \"\"\"Defin\n+00051d00: 6573 2061 2044 2d42 7573 2073 6967 6e61 es a D-Bus signa\n+00051d10: 6c20 6f6e 2061 6e20 696e 7465 7266 6163 l on an interfac\n+00051d20: 650a 0a20 2020 2020 2020 2054 6869 7320 e.. This \n+00051d30: 6973 2061 2063 616c 6c61 626c 6520 7768 is a callable wh\n+00051d40: 6963 6820 7769 6c6c 2072 6573 756c 7420 ich will result \n+00051d50: 696e 2074 6865 2073 6967 6e61 6c20 6265 in the signal be\n+00051d60: 696e 6720 656d 6974 7465 642e 0a0a 2020 ing emitted... \n+00051d70: 2020 2020 2020 5468 6520 636f 6e73 7472 The constr\n+00051d80: 7563 746f 7220 7461 6b65 7320 7468 6520 uctor takes the \n+00051d90: 7479 7065 7320 6f66 2074 6865 2061 7267 types of the arg\n+00051da0: 756d 656e 7473 2c20 6561 6368 206f 6e65 uments, each one\n+00051db0: 2061 7320 610a 2020 2020 2020 2020 7365 as a. se\n+00051dc0: 7061 7261 7465 2070 6172 616d 6574 6572 parate parameter\n+00051dd0: 2e20 2046 6f72 2065 7861 6d70 6c65 3a0a . For example:.\n+00051de0: 0a20 2020 2020 2020 2020 2020 2070 726f . pro\n+00051df0: 7065 7274 6965 735f 6368 616e 6765 6420 perties_changed \n+00051e00: 3d20 496e 7465 7266 6163 652e 5369 676e = Interface.Sign\n+00051e10: 616c 2827 7327 2c20 2761 7b73 767d 272c al('s', 'a{sv}',\n+00051e20: 2027 6173 2729 0a0a 2020 2020 2020 2020 'as').. \n+00051e30: 596f 7520 6361 6e20 6769 7665 2061 206e You can give a n\n+00051e40: 616d 653d 206b 7761 7267 2074 6f20 6f76 ame= kwarg to ov\n+00051e50: 6572 7269 6465 2074 6865 2064 6566 6175 erride the defau\n+00051e60: 6c74 206e 616d 6520 636f 6e76 6572 7369 lt name conversi\n+00051e70: 6f6e 0a20 2020 2020 2020 2073 6368 656d on. schem\n+00051e80: 652e 0a20 2020 2020 2020 2022 2222 0a20 e.. \"\"\". \n+00051e90: 2020 2020 2020 205f 6361 7465 676f 7279 _category\n+00051ea0: 203d 2027 7369 676e 616c 7327 0a20 2020 = 'signals'. \n+00051eb0: 2020 2020 205f 7479 7065 3a20 6275 7374 _type: bust\n+00051ec0: 7970 6573 2e4d 6573 7361 6765 5479 7065 ypes.MessageType\n+00051ed0: 0a0a 2020 2020 2020 2020 6465 6620 5f5f .. def __\n+00051ee0: 696e 6974 5f5f 2873 656c 662c 202a 6f75 init__(self, *ou\n+00051ef0: 745f 7479 7065 733a 2073 7472 2c20 6e61 t_types: str, na\n+00051f00: 6d65 3a20 4f70 7469 6f6e 616c 5b73 7472 me: Optional[str\n+00051f10: 5d20 3d20 4e6f 6e65 2920 2d3e 204e 6f6e ] = None) -> Non\n+00051f20: 653a 0a20 2020 2020 2020 2020 2020 2073 e:. s\n+00051f30: 7570 6572 2829 2e5f 5f69 6e69 745f 5f28 uper().__init__(\n+00051f40: 6e61 6d65 3d6e 616d 6529 0a20 2020 2020 name=name). \n+00051f50: 2020 2020 2020 2073 656c 662e 5f74 7970 self._typ\n+00051f60: 6520 3d20 6275 7374 7970 6573 2e4d 6573 e = bustypes.Mes\n+00051f70: 7361 6765 5479 7065 286f 7574 5f74 7970 sageType(out_typ\n+00051f80: 6573 290a 0a20 2020 2020 2020 2064 6566 es).. def\n+00051f90: 205f 6465 7363 7269 6265 2873 656c 6629 _describe(self)\n+00051fa0: 202d 3e20 4469 6374 5b73 7472 2c20 416e -> Dict[str, An\n+00051fb0: 795d 3a0a 2020 2020 2020 2020 2020 2020 y]:. \n+00051fc0: 7265 7475 726e 207b 2769 6e27 3a20 7365 return {'in': se\n+00051fd0: 6c66 2e5f 7479 7065 2e74 7970 6573 7472 lf._type.typestr\n+00051fe0: 696e 6773 7d0a 0a20 2020 2020 2020 2064 ings}.. d\n+00051ff0: 6566 205f 5f67 6574 5f5f 2873 656c 662c ef __get__(self,\n+00052000: 206f 626a 3a20 274f 626a 6563 7427 2c20 obj: 'Object', \n+00052010: 636c 733a 204f 7074 696f 6e61 6c5b 7479 cls: Optional[ty\n+00052020: 7065 5d20 3d20 4e6f 6e65 2920 2d3e 2043 pe] = None) -> C\n+00052030: 616c 6c61 626c 655b 2e2e 2e2c 204e 6f6e allable[..., Non\n+00052040: 655d 3a0a 2020 2020 2020 2020 2020 2020 e]:. \n+00052050: 6465 6620 656d 6974 7465 7228 6f62 6a3a def emitter(obj:\n+00052060: 204f 626a 6563 742c 202a 6172 6773 3a20 Object, *args: \n+00052070: 416e 7929 202d 3e20 4e6f 6e65 3a0a 2020 Any) -> None:. \n+00052080: 2020 2020 2020 2020 2020 2020 2020 6173 as\n+00052090: 7365 7274 2073 656c 662e 5f69 6e74 6572 sert self._inter\n+000520a0: 6661 6365 2069 7320 6e6f 7420 4e6f 6e65 face is not None\n+000520b0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+000520c0: 2061 7373 6572 7420 7365 6c66 2e5f 6e61 assert self._na\n+000520d0: 6d65 2069 7320 6e6f 7420 4e6f 6e65 0a20 me is not None. \n+000520e0: 2020 2020 2020 2020 2020 2020 2020 2061 a\n+000520f0: 7373 6572 7420 6f62 6a2e 5f64 6275 735f ssert obj._dbus_\n+00052100: 6275 7320 6973 206e 6f74 204e 6f6e 650a bus is not None.\n+00052110: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00052120: 6173 7365 7274 206f 626a 2e5f 6462 7573 assert obj._dbus\n+00052130: 5f70 6174 6820 6973 206e 6f74 204e 6f6e _path is not Non\n+00052140: 650a 2020 2020 2020 2020 2020 2020 2020 e. \n+00052150: 2020 6d65 7373 6167 6520 3d20 6f62 6a2e message = obj.\n+00052160: 5f64 6275 735f 6275 732e 6d65 7373 6167 _dbus_bus.messag\n+00052170: 655f 6e65 775f 7369 676e 616c 286f 626a e_new_signal(obj\n+00052180: 2e5f 6462 7573 5f70 6174 682c 2073 656c ._dbus_path, sel\n+00052190: 662e 5f69 6e74 6572 6661 6365 2c20 7365 f._interface, se\n+000521a0: 6c66 2e5f 6e61 6d65 290a 2020 2020 2020 lf._name). \n+000521b0: 2020 2020 2020 2020 2020 7365 6c66 2e5f self._\n+000521c0: 7479 7065 2e77 7269 7465 286d 6573 7361 type.write(messa\n+000521d0: 6765 2c20 2a61 7267 7329 0a20 2020 2020 ge, *args). \n+000521e0: 2020 2020 2020 2020 2020 206d 6573 7361 messa\n+000521f0: 6765 2e73 656e 6428 290a 2020 2020 2020 ge.send(). \n+00052200: 2020 2020 2020 7265 7475 726e 2065 6d69 return emi\n+00052210: 7474 6572 2e5f 5f67 6574 5f5f 286f 626a tter.__get__(obj\n+00052220: 2c20 636c 7329 0a0a 2020 2020 636c 6173 , cls).. clas\n+00052230: 7320 4d65 7468 6f64 285f 4d65 6d62 6572 s Method(_Member\n+00052240: 293a 0a20 2020 2020 2020 2022 2222 4465 ):. \"\"\"De\n+00052250: 6669 6e65 7320 6120 442d 4275 7320 6d65 fines a D-Bus me\n+00052260: 7468 6f64 206f 6e20 616e 2069 6e74 6572 thod on an inter\n+00052270: 6661 6365 0a0a 2020 2020 2020 2020 5468 face.. Th\n+00052280: 6973 2069 7320 6120 6675 6e63 7469 6f6e is is a function\n+00052290: 2064 6563 6f72 6174 6f72 2077 6869 6368 decorator which\n+000522a0: 206d 6172 6b73 2061 2067 6976 656e 206d marks a given m\n+000522b0: 6574 686f 6420 666f 7220 6578 706f 7274 ethod for export\n+000522c0: 2e0a 0a20 2020 2020 2020 2054 6865 2063 ... The c\n+000522d0: 6f6e 7374 7275 6374 6f72 2074 616b 6573 onstructor takes\n+000522e0: 2074 776f 2061 7267 756d 656e 7473 3a20 two arguments: \n+000522f0: 7468 6520 7479 7065 206f 6620 7468 6520 the type of the \n+00052300: 6f75 7470 7574 2061 7267 756d 656e 7473 output arguments\n+00052310: 2c0a 2020 2020 2020 2020 616e 6420 7468 ,. and th\n+00052320: 6520 7479 7065 206f 6620 7468 6520 696e e type of the in\n+00052330: 7075 7420 6172 6775 6d65 6e74 732e 2020 put arguments. \n+00052340: 426f 7468 2073 686f 756c 6420 6265 2067 Both should be g\n+00052350: 6976 656e 2061 7320 610a 2020 2020 2020 iven as a. \n+00052360: 2020 7365 7175 656e 6365 2e0a 0a20 2020 sequence... \n+00052370: 2020 2020 2020 2020 2040 496e 7465 7266 @Interf\n+00052380: 6163 652e 4d65 7468 6f64 285b 2761 7b73 ace.Method(['a{s\n+00052390: 767d 275d 2c20 5b27 7327 5d29 0a20 2020 v}'], ['s']). \n+000523a0: 2020 2020 2020 2020 2064 6566 2067 6574 def get\n+000523b0: 5f61 6c6c 2873 656c 662c 2069 6e74 6572 _all(self, inter\n+000523c0: 6661 6365 293a 0a20 2020 2020 2020 2020 face):. \n+000523d0: 2020 2020 2020 202e 2e2e 0a0a 2020 2020 ..... \n+000523e0: 2020 2020 596f 7520 6361 6e20 6769 7665 You can give\n+000523f0: 2061 206e 616d 653d 206b 7761 7267 2074 a name= kwarg t\n+00052400: 6f20 6f76 6572 7269 6465 2074 6865 2064 o override the d\n+00052410: 6566 6175 6c74 206e 616d 6520 636f 6e76 efault name conv\n+00052420: 6572 7369 6f6e 0a20 2020 2020 2020 2073 ersion. s\n+00052430: 6368 656d 652e 0a20 2020 2020 2020 2022 cheme.. \"\n+00052440: 2222 0a20 2020 2020 2020 205f 6361 7465 \"\". _cate\n+00052450: 676f 7279 203d 2027 6d65 7468 6f64 7327 gory = 'methods'\n+00052460: 0a0a 2020 2020 2020 2020 636c 6173 7320 .. class \n+00052470: 556e 6861 6e64 6c65 6428 4578 6365 7074 Unhandled(Except\n+00052480: 696f 6e29 3a0a 2020 2020 2020 2020 2020 ion):. \n+00052490: 2020 2222 2252 6169 7365 6420 6279 2061 \"\"\"Raised by a\n+000524a0: 206d 6574 686f 6420 746f 2069 6e64 6963 method to indic\n+000524b0: 6174 6520 7468 6174 2074 6865 206d 6573 ate that the mes\n+000524c0: 7361 6765 2074 7269 6767 6572 696e 6720 sage triggering \n+000524d0: 7468 6174 0a20 2020 2020 2020 2020 2020 that. \n+000524e0: 206d 6574 686f 6420 6361 6c6c 2072 656d method call rem\n+000524f0: 6169 6e73 2075 6e68 616e 646c 6564 2e22 ains unhandled.\"\n+00052500: 2222 0a20 2020 2020 2020 2020 2020 2070 \"\". p\n+00052510: 6173 730a 0a20 2020 2020 2020 2064 6566 ass.. def\n+00052520: 205f 5f69 6e69 745f 5f28 7365 6c66 2c20 __init__(self, \n+00052530: 6f75 745f 7479 7065 733a 2053 6571 7565 out_types: Seque\n+00052540: 6e63 655b 7374 725d 203d 2028 292c 2069 nce[str] = (), i\n+00052550: 6e5f 7479 7065 733a 2053 6571 7565 6e63 n_types: Sequenc\n+00052560: 655b 7374 725d 203d 2028 292c 206e 616d e[str] = (), nam\n+00052570: 653a 204f 7074 696f 6e61 6c5b 7374 725d e: Optional[str]\n+00052580: 203d 204e 6f6e 6529 3a0a 2020 2020 2020 = None):. \n+00052590: 2020 2020 2020 7375 7065 7228 292e 5f5f super().__\n+000525a0: 696e 6974 5f5f 286e 616d 653d 6e61 6d65 init__(name=name\n+000525b0: 290a 2020 2020 2020 2020 2020 2020 7365 ). se\n+000525c0: 6c66 2e5f 6f75 745f 7479 7065 203d 2062 lf._out_type = b\n+000525d0: 7573 7479 7065 732e 4d65 7373 6167 6554 ustypes.MessageT\n+000525e0: 7970 6528 6f75 745f 7479 7065 7329 0a20 ype(out_types). \n+000525f0: 2020 2020 2020 2020 2020 2073 656c 662e self.\n+00052600: 5f69 6e5f 7479 7065 203d 2062 7573 7479 _in_type = busty\n+00052610: 7065 732e 4d65 7373 6167 6554 7970 6528 pes.MessageType(\n+00052620: 696e 5f74 7970 6573 290a 2020 2020 2020 in_types). \n+00052630: 2020 2020 2020 7365 6c66 2e5f 6675 6e63 self._func\n+00052640: 203d 204e 6f6e 650a 0a20 2020 2020 2020 = None.. \n+00052650: 2064 6566 205f 5f67 6574 5f5f 2873 656c def __get__(sel\n+00052660: 662c 206f 626a 2c20 636c 733d 4e6f 6e65 f, obj, cls=None\n+00052670: 293a 0a20 2020 2020 2020 2020 2020 2072 ):. r\n+00052680: 6574 7572 6e20 7365 6c66 2e5f 6675 6e63 eturn self._func\n+00052690: 2e5f 5f67 6574 5f5f 286f 626a 2c20 636c .__get__(obj, cl\n+000526a0: 7329 0a0a 2020 2020 2020 2020 6465 6620 s).. def \n+000526b0: 5f5f 6361 6c6c 5f5f 2873 656c 662c 202a __call__(self, *\n+000526c0: 6172 6773 2c20 2a2a 6b77 6172 6773 293a args, **kwargs):\n+000526d0: 0a20 2020 2020 2020 2020 2020 2023 2064 . # d\n+000526e0: 6563 6f72 6174 6f72 0a20 2020 2020 2020 ecorator. \n+000526f0: 2020 2020 2073 656c 662e 5f66 756e 632c self._func,\n+00052700: 203d 2061 7267 730a 2020 2020 2020 2020 = args. \n+00052710: 2020 2020 7265 7475 726e 2073 656c 660a return self.\n+00052720: 0a20 2020 2020 2020 2064 6566 205f 6465 . def _de\n+00052730: 7363 7269 6265 2873 656c 6629 202d 3e20 scribe(self) -> \n+00052740: 4469 6374 5b73 7472 2c20 416e 795d 3a0a Dict[str, Any]:.\n+00052750: 2020 2020 2020 2020 2020 2020 7265 7475 retu\n+00052760: 726e 207b 2769 6e27 3a20 5b69 7465 6d2e rn {'in': [item.\n+00052770: 7479 7065 7374 7269 6e67 2066 6f72 2069 typestring for i\n+00052780: 7465 6d20 696e 2073 656c 662e 5f69 6e5f tem in self._in_\n+00052790: 7479 7065 2e69 7465 6d5f 7479 7065 735d type.item_types]\n+000527a0: 2c0a 2020 2020 2020 2020 2020 2020 2020 ,. \n+000527b0: 2020 2020 2020 276f 7574 273a 205b 6974 'out': [it\n+000527c0: 656d 2e74 7970 6573 7472 696e 6720 666f em.typestring fo\n+000527d0: 7220 6974 656d 2069 6e20 7365 6c66 2e5f r item in self._\n+000527e0: 6f75 745f 7479 7065 2e69 7465 6d5f 7479 out_type.item_ty\n+000527f0: 7065 735d 7d0a 0a20 2020 2020 2020 2064 pes]}.. d\n+00052800: 6566 205f 696e 766f 6b65 2873 656c 662c ef _invoke(self,\n+00052810: 206f 626a 2c20 6d65 7373 6167 6529 3a0a obj, message):.\n+00052820: 2020 2020 2020 2020 2020 2020 6172 6773 args\n+00052830: 203d 2073 656c 662e 5f69 6e5f 7479 7065 = self._in_type\n+00052840: 2e72 6561 6428 6d65 7373 6167 6529 0a20 .read(message). \n+00052850: 2020 2020 2020 2020 2020 2069 6620 6172 if ar\n+00052860: 6773 2069 7320 4e6f 6e65 3a0a 2020 2020 gs is None:. \n+00052870: 2020 2020 2020 2020 2020 2020 7265 7475 retu\n+00052880: 726e 2046 616c 7365 0a20 2020 2020 2020 rn False. \n+00052890: 2020 2020 2074 7279 3a0a 2020 2020 2020 try:. \n+000528a0: 2020 2020 2020 2020 2020 7265 7375 6c74 result\n+000528b0: 203d 2073 656c 662e 5f66 756e 632e 5f5f = self._func.__\n+000528c0: 6765 745f 5f28 6f62 6a29 282a 6172 6773 get__(obj)(*args\n+000528d0: 290a 2020 2020 2020 2020 2020 2020 6578 ). ex\n+000528e0: 6365 7074 2028 4275 7345 7272 6f72 2c20 cept (BusError, \n+000528f0: 4f53 4572 726f 7229 2061 7320 6572 726f OSError) as erro\n+00052900: 723a 0a20 2020 2020 2020 2020 2020 2020 r:. \n+00052910: 2020 2072 6574 7572 6e20 6d65 7373 6167 return messag\n+00052920: 652e 7265 706c 795f 6d65 7468 6f64 5f65 e.reply_method_e\n+00052930: 7272 6f72 2865 7272 6f72 290a 0a20 2020 rror(error).. \n+00052940: 2020 2020 2020 2020 2072 6574 7572 6e20 return \n+00052950: 6d65 7373 6167 652e 7265 706c 795f 6d65 message.reply_me\n+00052960: 7468 6f64 5f66 756e 6374 696f 6e5f 7265 thod_function_re\n+00052970: 7475 726e 5f76 616c 7565 2873 656c 662e turn_value(self.\n+00052980: 5f6f 7574 5f74 7970 652c 2072 6573 756c _out_type, resul\n+00052990: 7429 0a0a 0a63 6c61 7373 206f 7267 5f66 t)...class org_f\n+000529a0: 7265 6564 6573 6b74 6f70 5f44 4275 735f reedesktop_DBus_\n+000529b0: 5065 6572 2849 6e74 6572 6661 6365 293a Peer(Interface):\n+000529c0: 0a20 2020 2040 496e 7465 7266 6163 652e . @Interface.\n+000529d0: 4d65 7468 6f64 2829 0a20 2020 2040 7374 Method(). @st\n+000529e0: 6174 6963 6d65 7468 6f64 0a20 2020 2064 aticmethod. d\n+000529f0: 6566 2070 696e 6728 2920 2d3e 204e 6f6e ef ping() -> Non\n+00052a00: 653a 0a20 2020 2020 2020 2070 6173 730a e:. pass.\n+00052a10: 0a20 2020 2040 496e 7465 7266 6163 652e . @Interface.\n+00052a20: 4d65 7468 6f64 2827 7327 290a 2020 2020 Method('s'). \n+00052a30: 4073 7461 7469 636d 6574 686f 640a 2020 @staticmethod. \n+00052a40: 2020 6465 6620 6765 745f 6d61 6368 696e def get_machin\n+00052a50: 655f 6964 2829 202d 3e20 7374 723a 0a20 e_id() -> str:. \n+00052a60: 2020 2020 2020 2077 6974 6820 6f70 656e with open\n+00052a70: 2827 2f65 7463 2f6d 6163 6869 6e65 2d69 ('/etc/machine-i\n+00052a80: 6427 2c20 656e 636f 6469 6e67 3d27 6173 d', encoding='as\n+00052a90: 6369 6927 2920 6173 2066 696c 653a 0a20 cii') as file:. \n+00052aa0: 2020 2020 2020 2020 2020 2072 6574 7572 retur\n+00052ab0: 6e20 6669 6c65 2e72 6561 6428 292e 7374 n file.read().st\n+00052ac0: 7269 7028 290a 0a0a 636c 6173 7320 6f72 rip()...class or\n+00052ad0: 675f 6672 6565 6465 736b 746f 705f 4442 g_freedesktop_DB\n+00052ae0: 7573 5f49 6e74 726f 7370 6563 7461 626c us_Introspectabl\n+00052af0: 6528 496e 7465 7266 6163 6529 3a0a 2020 e(Interface):. \n+00052b00: 2020 4049 6e74 6572 6661 6365 2e4d 6574 @Interface.Met\n+00052b10: 686f 6428 2773 2729 0a20 2020 2040 636c hod('s'). @cl\n+00052b20: 6173 736d 6574 686f 640a 2020 2020 6465 assmethod. de\n+00052b30: 6620 696e 7472 6f73 7065 6374 2863 6c73 f introspect(cls\n+00052b40: 2920 2d3e 2073 7472 3a0a 2020 2020 2020 ) -> str:. \n+00052b50: 2020 7265 7475 726e 2069 6e74 726f 7370 return introsp\n+00052b60: 6563 7469 6f6e 2e74 6f5f 786d 6c28 636c ection.to_xml(cl\n+00052b70: 732e 5f64 6275 735f 696e 7465 7266 6163 s._dbus_interfac\n+00052b80: 6573 290a 0a0a 636c 6173 7320 6f72 675f es)...class org_\n+00052b90: 6672 6565 6465 736b 746f 705f 4442 7573 freedesktop_DBus\n+00052ba0: 5f50 726f 7065 7274 6965 7328 496e 7465 _Properties(Inte\n+00052bb0: 7266 6163 6529 3a0a 2020 2020 7072 6f70 rface):. prop\n+00052bc0: 6572 7469 6573 5f63 6861 6e67 6564 203d erties_changed =\n+00052bd0: 2049 6e74 6572 6661 6365 2e53 6967 6e61 Interface.Signa\n+00052be0: 6c28 2773 272c 2027 617b 7376 7d27 2c20 l('s', 'a{sv}', \n+00052bf0: 2761 7327 290a 0a20 2020 2040 496e 7465 'as').. @Inte\n+00052c00: 7266 6163 652e 4d65 7468 6f64 2827 7627 rface.Method('v'\n+00052c10: 2c20 2773 7327 290a 2020 2020 6465 6620 , 'ss'). def \n+00052c20: 6765 7428 7365 6c66 2c20 696e 7465 7266 get(self, interf\n+00052c30: 6163 652c 206e 616d 6529 3a0a 2020 2020 ace, name):. \n+00052c40: 2020 2020 7265 7475 726e 2073 656c 662e return self.\n+00052c50: 5f66 696e 645f 6d65 6d62 6572 2869 6e74 _find_member(int\n+00052c60: 6572 6661 6365 2c20 2770 726f 7065 7274 erface, 'propert\n+00052c70: 6965 7327 2c20 6e61 6d65 292e 746f 5f64 ies', name).to_d\n+00052c80: 6275 7328 7365 6c66 290a 0a20 2020 2040 bus(self).. @\n+00052c90: 496e 7465 7266 6163 652e 4d65 7468 6f64 Interface.Method\n+00052ca0: 285b 2761 7b73 767d 275d 2c20 2773 2729 (['a{sv}'], 's')\n+00052cb0: 0a20 2020 2064 6566 2067 6574 5f61 6c6c . def get_all\n+00052cc0: 2873 656c 662c 2069 6e74 6572 6661 6365 (self, interface\n+00052cd0: 293a 0a20 2020 2020 2020 2070 726f 7065 ):. prope\n+00052ce0: 7274 6965 7320 3d20 7365 6c66 2e5f 6669 rties = self._fi\n+00052cf0: 6e64 5f63 6174 6567 6f72 7928 696e 7465 nd_category(inte\n+00052d00: 7266 6163 652c 2027 7072 6f70 6572 7469 rface, 'properti\n+00052d10: 6573 2729 0a20 2020 2020 2020 2072 6574 es'). ret\n+00052d20: 7572 6e20 7b6e 616d 653a 2070 726f 702e urn {name: prop.\n+00052d30: 746f 5f64 6275 7328 7365 6c66 2920 666f to_dbus(self) fo\n+00052d40: 7220 6e61 6d65 2c20 7072 6f70 2069 6e20 r name, prop in \n+00052d50: 7072 6f70 6572 7469 6573 2e69 7465 6d73 properties.items\n+00052d60: 2829 7d0a 0a20 2020 2040 496e 7465 7266 ()}.. @Interf\n+00052d70: 6163 652e 4d65 7468 6f64 2827 272c 2027 ace.Method('', '\n+00052d80: 7373 7627 290a 2020 2020 6465 6620 7365 ssv'). def se\n+00052d90: 7428 7365 6c66 2c20 696e 7465 7266 6163 t(self, interfac\n+00052da0: 652c 206e 616d 652c 2076 616c 7565 293a e, name, value):\n+00052db0: 0a20 2020 2020 2020 2073 656c 662e 5f66 . self._f\n+00052dc0: 696e 645f 6d65 6d62 6572 2869 6e74 6572 ind_member(inter\n+00052dd0: 6661 6365 2c20 2770 726f 7065 7274 6965 face, 'propertie\n+00052de0: 7327 2c20 6e61 6d65 292e 6672 6f6d 5f64 s', name).from_d\n+00052df0: 6275 7328 7365 6c66 2c20 7661 6c75 6529 bus(self, value)\n+00052e00: 0a0a 0a63 6c61 7373 204f 626a 6563 7428 ...class Object(\n+00052e10: 6f72 675f 6672 6565 6465 736b 746f 705f org_freedesktop_\n+00052e20: 4442 7573 5f49 6e74 726f 7370 6563 7461 DBus_Introspecta\n+00052e30: 626c 652c 0a20 2020 2020 2020 2020 2020 ble,. \n+00052e40: 2020 6f72 675f 6672 6565 6465 736b 746f org_freedeskto\n+00052e50: 705f 4442 7573 5f50 6565 722c 0a20 2020 p_DBus_Peer,. \n+00052e60: 2020 2020 2020 2020 2020 6f72 675f 6672 org_fr\n+00052e70: 6565 6465 736b 746f 705f 4442 7573 5f50 eedesktop_DBus_P\n+00052e80: 726f 7065 7274 6965 732c 0a20 2020 2020 roperties,. \n+00052e90: 2020 2020 2020 2020 4261 7365 4f62 6a65 BaseObje\n+00052ea0: 6374 2c0a 2020 2020 2020 2020 2020 2020 ct,. \n+00052eb0: 2049 6e74 6572 6661 6365 293a 0a20 2020 Interface):. \n+00052ec0: 2022 2222 4869 6768 2d6c 6576 656c 2062 \"\"\"High-level b\n+00052ed0: 6173 6520 636c 6173 7320 666f 7220 6578 ase class for ex\n+00052ee0: 706f 7274 696e 6720 6f62 6a65 6374 7320 porting objects \n+00052ef0: 6f6e 2044 2d42 7573 0a0a 2020 2020 5468 on D-Bus.. Th\n+00052f00: 6973 2069 7320 7573 7561 6c6c 7920 7768 is is usually wh\n+00052f10: 6572 6520 796f 7520 7368 6f75 6c64 2073 ere you should s\n+00052f20: 7461 7274 2e0a 0a20 2020 2054 6869 7320 tart... This \n+00052f30: 7072 6f76 6964 6573 2061 2062 6173 6520 provides a base \n+00052f40: 666f 7220 6578 706f 7274 696e 6720 6f62 for exporting ob\n+00052f50: 6a65 6374 7320 6f6e 2074 6865 2062 7573 jects on the bus\n+00052f60: 2c20 696d 706c 656d 656e 7473 2074 6865 , implements the\n+00052f70: 0a20 2020 2073 7461 6e64 6172 6420 442d . standard D-\n+00052f80: 4275 7320 696e 7465 7266 6163 6573 2c20 Bus interfaces, \n+00052f90: 616e 6420 616c 6c6f 7773 2079 6f75 2074 and allows you t\n+00052fa0: 6f20 6164 6420 796f 7572 206f 776e 2069 o add your own i\n+00052fb0: 6e74 6572 6661 6365 7320 746f 2074 6865 nterfaces to the\n+00052fc0: 0a20 2020 206d 6978 2e20 2053 6565 2074 . mix. See t\n+00052fd0: 6865 2064 6f63 756d 656e 7461 7469 6f6e he documentation\n+00052fe0: 2066 6f72 2049 6e74 6572 6661 6365 2074 for Interface t\n+00052ff0: 6f20 6669 6e64 206f 7574 2068 6f77 2074 o find out how t\n+00053000: 6f20 6465 6669 6e65 2061 6e64 0a20 2020 o define and. \n+00053010: 2069 6d70 6c65 6d65 6e74 2079 6f75 7220 implement your \n+00053020: 442d 4275 7320 696e 7465 7266 6163 652e D-Bus interface.\n+00053030: 0a20 2020 2022 2222 0a20 2020 2064 6566 . \"\"\". def\n+00053040: 206d 6573 7361 6765 5f72 6563 6569 7665 message_receive\n+00053050: 6428 7365 6c66 2c20 6d65 7373 6167 653a d(self, message:\n+00053060: 2042 7573 4d65 7373 6167 6529 202d 3e20 BusMessage) -> \n+00053070: 626f 6f6c 3a0a 2020 2020 2020 2020 696e bool:. in\n+00053080: 7465 7266 6163 6520 3d20 6d65 7373 6167 terface = messag\n+00053090: 652e 6765 745f 696e 7465 7266 6163 6528 e.get_interface(\n+000530a0: 290a 2020 2020 2020 2020 6e61 6d65 203d ). name =\n+000530b0: 206d 6573 7361 6765 2e67 6574 5f6d 656d message.get_mem\n+000530c0: 6265 7228 290a 0a20 2020 2020 2020 2074 ber().. t\n+000530d0: 7279 3a0a 2020 2020 2020 2020 2020 2020 ry:. \n+000530e0: 6d65 7468 6f64 203d 2073 656c 662e 5f66 method = self._f\n+000530f0: 696e 645f 6d65 6d62 6572 2869 6e74 6572 ind_member(inter\n+00053100: 6661 6365 2c20 276d 6574 686f 6473 272c face, 'methods',\n+00053110: 206e 616d 6529 0a20 2020 2020 2020 2020 name). \n+00053120: 2020 2061 7373 6572 7420 6973 696e 7374 assert isinst\n+00053130: 616e 6365 286d 6574 686f 642c 2049 6e74 ance(method, Int\n+00053140: 6572 6661 6365 2e4d 6574 686f 6429 0a20 erface.Method). \n+00053150: 2020 2020 2020 2020 2020 2072 6574 7572 retur\n+00053160: 6e20 6d65 7468 6f64 2e5f 696e 766f 6b65 n method._invoke\n+00053170: 2873 656c 662c 206d 6573 7361 6765 290a (self, message).\n+00053180: 2020 2020 2020 2020 6578 6365 7074 204f except O\n+00053190: 626a 6563 742e 4d65 7468 6f64 2e55 6e68 bject.Method.Unh\n+000531a0: 616e 646c 6564 3a0a 2020 2020 2020 2020 andled:. \n+000531b0: 2020 2020 7265 7475 726e 2046 616c 7365 return False\n+000531c0: 0a27 2727 2c0a 2020 2763 6f63 6b70 6974 .''',. 'cockpit\n+000531d0: 2f5f 7665 6e64 6f72 2f73 7973 7465 6d64 /_vendor/systemd\n+000531e0: 5f63 7479 7065 732f 696e 7472 6f73 7065 _ctypes/introspe\n+000531f0: 6374 696f 6e2e 7079 273a 2062 7227 2727 ction.py': br'''\n+00053200: 2320 7379 7374 656d 645f 6374 7970 6573 # systemd_ctypes\n+00053210: 0a23 0a23 2043 6f70 7972 6967 6874 2028 .#.# Copyright (\n+00053220: 4329 2032 3032 3220 416c 6c69 736f 6e20 C) 2022 Allison \n+00053230: 4b61 726c 6974 736b 6179 6120 3c61 6c6c Karlitskaya .#.#\n+00053260: 2054 6869 7320 7072 6f67 7261 6d20 6973 This program is\n+00053270: 2066 7265 6520 736f 6674 7761 7265 3a20 free software: \n+00053280: 796f 7520 6361 6e20 7265 6469 7374 7269 you can redistri\n+00053290: 6275 7465 2069 7420 616e 642f 6f72 206d bute it and/or m\n+000532a0: 6f64 6966 790a 2320 6974 2075 6e64 6572 odify.# it under\n+000532b0: 2074 6865 2074 6572 6d73 206f 6620 7468 the terms of th\n+000532c0: 6520 474e 5520 4765 6e65 7261 6c20 5075 e GNU General Pu\n+000532d0: 626c 6963 204c 6963 656e 7365 2061 7320 blic License as \n+000532e0: 7075 626c 6973 6865 6420 6279 0a23 2074 published by.# t\n+000532f0: 6865 2046 7265 6520 536f 6674 7761 7265 he Free Software\n+00053300: 2046 6f75 6e64 6174 696f 6e2c 2065 6974 Foundation, eit\n+00053310: 6865 7220 7665 7273 696f 6e20 3320 6f66 her version 3 of\n+00053320: 2074 6865 204c 6963 656e 7365 2c20 6f72 the License, or\n+00053330: 0a23 2028 6174 2079 6f75 7220 6f70 7469 .# (at your opti\n+00053340: 6f6e 2920 616e 7920 6c61 7465 7220 7665 on) any later ve\n+00053350: 7273 696f 6e2e 0a23 0a23 2054 6869 7320 rsion..#.# This \n+00053360: 7072 6f67 7261 6d20 6973 2064 6973 7472 program is distr\n+00053370: 6962 7574 6564 2069 6e20 7468 6520 686f ibuted in the ho\n+00053380: 7065 2074 6861 7420 6974 2077 696c 6c20 pe that it will \n+00053390: 6265 2075 7365 6675 6c2c 0a23 2062 7574 be useful,.# but\n+000533a0: 2057 4954 484f 5554 2041 4e59 2057 4152 WITHOUT ANY WAR\n+000533b0: 5241 4e54 593b 2077 6974 686f 7574 2065 RANTY; without e\n+000533c0: 7665 6e20 7468 6520 696d 706c 6965 6420 ven the implied \n+000533d0: 7761 7272 616e 7479 206f 660a 2320 4d45 warranty of.# ME\n+000533e0: 5243 4841 4e54 4142 494c 4954 5920 6f72 RCHANTABILITY or\n+000533f0: 2046 4954 4e45 5353 2046 4f52 2041 2050 FITNESS FOR A P\n+00053400: 4152 5449 4355 4c41 5220 5055 5250 4f53 ARTICULAR PURPOS\n+00053410: 452e 2020 5365 6520 7468 650a 2320 474e E. See the.# GN\n+00053420: 5520 4765 6e65 7261 6c20 5075 626c 6963 U General Public\n+00053430: 204c 6963 656e 7365 2066 6f72 206d 6f72 License for mor\n+00053440: 6520 6465 7461 696c 732e 0a23 0a23 2059 e details..#.# Y\n+00053450: 6f75 2073 686f 756c 6420 6861 7665 2072 ou should have r\n+00053460: 6563 6569 7665 6420 6120 636f 7079 206f eceived a copy o\n+00053470: 6620 7468 6520 474e 5520 4765 6e65 7261 f the GNU Genera\n+00053480: 6c20 5075 626c 6963 204c 6963 656e 7365 l Public License\n+00053490: 0a23 2061 6c6f 6e67 2077 6974 6820 7468 .# along with th\n+000534a0: 6973 2070 726f 6772 616d 2e20 2049 6620 is program. If \n+000534b0: 6e6f 742c 2073 6565 203c 6874 7470 3a2f not, see ...import\n+000534e0: 2078 6d6c 2e65 7472 6565 2e45 6c65 6d65 xml.etree.Eleme\n+000534f0: 6e74 5472 6565 2061 7320 4554 0a0a 0a64 ntTree as ET...d\n+00053500: 6566 2070 6172 7365 5f6d 6574 686f 6428 ef parse_method(\n+00053510: 6d65 7468 6f64 293a 0a20 2020 2072 6574 method):. ret\n+00053520: 7572 6e20 7b0a 2020 2020 2020 2020 2269 urn {. \"i\n+00053530: 6e22 3a20 5b74 6167 2e61 7474 7269 625b n\": [tag.attrib[\n+00053540: 2774 7970 6527 5d20 666f 7220 7461 6720 'type'] for tag \n+00053550: 696e 206d 6574 686f 642e 6669 6e64 616c in method.findal\n+00053560: 6c28 2261 7267 2229 2069 6620 7461 672e l(\"arg\") if tag.\n+00053570: 6765 7428 2764 6972 6563 7469 6f6e 272c get('direction',\n+00053580: 2027 696e 2729 203d 3d20 2769 6e27 5d2c 'in') == 'in'],\n+00053590: 0a20 2020 2020 2020 2022 6f75 7422 3a20 . \"out\": \n+000535a0: 5b74 6167 2e61 7474 7269 625b 2774 7970 [tag.attrib['typ\n+000535b0: 6527 5d20 666f 7220 7461 6720 696e 206d e'] for tag in m\n+000535c0: 6574 686f 642e 6669 6e64 616c 6c28 2261 ethod.findall(\"a\n+000535d0: 7267 5b40 6469 7265 6374 696f 6e3d 276f rg[@direction='o\n+000535e0: 7574 275d 2229 5d0a 2020 2020 7d0a 0a0a ut']\")]. }...\n+000535f0: 6465 6620 7061 7273 655f 7072 6f70 6572 def parse_proper\n+00053600: 7479 2870 726f 7029 3a0a 2020 2020 7265 ty(prop):. re\n+00053610: 7475 726e 207b 0a20 2020 2020 2020 2022 turn {. \"\n+00053620: 666c 6167 7322 3a20 2777 2720 6966 2070 flags\": 'w' if p\n+00053630: 726f 702e 6174 7472 6962 2e67 6574 2827 rop.attrib.get('\n+00053640: 6163 6365 7373 2729 203d 3d20 2777 7269 access') == 'wri\n+00053650: 7465 2720 656c 7365 2027 7227 2c0a 2020 te' else 'r',. \n+00053660: 2020 2020 2020 2274 7970 6522 3a20 7072 \"type\": pr\n+00053670: 6f70 2e61 7474 7269 625b 2774 7970 6527 op.attrib['type'\n+00053680: 5d0a 2020 2020 7d0a 0a0a 6465 6620 7061 ]. }...def pa\n+00053690: 7273 655f 7369 676e 616c 2873 6967 6e61 rse_signal(signa\n+000536a0: 6c29 3a0a 2020 2020 7265 7475 726e 207b l):. return {\n+000536b0: 2269 6e22 3a20 5b74 6167 2e61 7474 7269 \"in\": [tag.attri\n+000536c0: 625b 2774 7970 6527 5d20 666f 7220 7461 b['type'] for ta\n+000536d0: 6720 696e 2073 6967 6e61 6c2e 6669 6e64 g in signal.find\n+000536e0: 616c 6c28 2261 7267 2229 5d7d 0a0a 0a64 all(\"arg\")]}...d\n+000536f0: 6566 2070 6172 7365 5f69 6e74 6572 6661 ef parse_interfa\n+00053700: 6365 2869 6e74 6572 6661 6365 293a 0a20 ce(interface):. \n+00053710: 2020 2072 6574 7572 6e20 7b0a 2020 2020 return {. \n+00053720: 2020 2020 226d 6574 686f 6473 223a 207b \"methods\": {\n+00053730: 7461 672e 6174 7472 6962 5b27 6e61 6d65 tag.attrib['name\n+00053740: 275d 3a20 7061 7273 655f 6d65 7468 6f64 ']: parse_method\n+00053750: 2874 6167 2920 666f 7220 7461 6720 696e (tag) for tag in\n+00053760: 2069 6e74 6572 6661 6365 2e66 696e 6461 interface.finda\n+00053770: 6c6c 2827 6d65 7468 6f64 2729 7d2c 0a20 ll('method')},. \n+00053780: 2020 2020 2020 2022 7072 6f70 6572 7469 \"properti\n+00053790: 6573 223a 207b 7461 672e 6174 7472 6962 es\": {tag.attrib\n+000537a0: 5b27 6e61 6d65 275d 3a20 7061 7273 655f ['name']: parse_\n+000537b0: 7072 6f70 6572 7479 2874 6167 2920 666f property(tag) fo\n+000537c0: 7220 7461 6720 696e 2069 6e74 6572 6661 r tag in interfa\n+000537d0: 6365 2e66 696e 6461 6c6c 2827 7072 6f70 ce.findall('prop\n+000537e0: 6572 7479 2729 7d2c 0a20 2020 2020 2020 erty')},. \n+000537f0: 2022 7369 676e 616c 7322 3a20 7b74 6167 \"signals\": {tag\n+00053800: 2e61 7474 7269 625b 276e 616d 6527 5d3a .attrib['name']:\n+00053810: 2070 6172 7365 5f73 6967 6e61 6c28 7461 parse_signal(ta\n+00053820: 6729 2066 6f72 2074 6167 2069 6e20 696e g) for tag in in\n+00053830: 7465 7266 6163 652e 6669 6e64 616c 6c28 terface.findall(\n+00053840: 2773 6967 6e61 6c27 297d 0a20 2020 207d 'signal')}. }\n+00053850: 0a0a 0a64 6566 2070 6172 7365 5f78 6d6c ...def parse_xml\n+00053860: 2878 6d6c 293a 0a20 2020 2065 7420 3d20 (xml):. et = \n+00053870: 4554 2e66 726f 6d73 7472 696e 6728 786d ET.fromstring(xm\n+00053880: 6c29 0a20 2020 2072 6574 7572 6e20 7b74 l). return {t\n+00053890: 6167 2e61 7474 7269 625b 276e 616d 6527 ag.attrib['name'\n+000538a0: 5d3a 2070 6172 7365 5f69 6e74 6572 6661 ]: parse_interfa\n+000538b0: 6365 2874 6167 2920 666f 7220 7461 6720 ce(tag) for tag \n+000538c0: 696e 2065 742e 6669 6e64 616c 6c28 2769 in et.findall('i\n+000538d0: 6e74 6572 6661 6365 2729 7d0a 0a0a 2320 nterface')}...# \n+000538e0: 5072 6574 656e 6420 6c69 6b65 2074 6869 Pretend like thi\n+000538f0: 7320 6973 2061 206c 6974 746c 6520 6269 s is a little bi\n+00053900: 7420 6675 6e63 7469 6f6e 616c 0a64 6566 t functional.def\n+00053910: 2065 6c65 6d65 6e74 2874 6167 2c20 6368 element(tag, ch\n+00053920: 696c 6472 656e 3d28 292c 202a 2a6b 7761 ildren=(), **kwa\n+00053930: 7267 7329 3a0a 2020 2020 7461 6720 3d20 rgs):. tag = \n+00053940: 4554 2e45 6c65 6d65 6e74 2874 6167 2c20 ET.Element(tag, \n+00053950: 6b77 6172 6773 290a 2020 2020 7461 672e kwargs). tag.\n+00053960: 6578 7465 6e64 2863 6869 6c64 7265 6e29 extend(children)\n+00053970: 0a20 2020 2072 6574 7572 6e20 7461 670a . return tag.\n+00053980: 0a0a 6465 6620 6d65 7468 6f64 5f74 6f5f ..def method_to_\n+00053990: 786d 6c28 6e61 6d65 2c20 6d65 7468 6f64 xml(name, method\n+000539a0: 5f69 6e66 6f29 3a0a 2020 2020 7265 7475 _info):. retu\n+000539b0: 726e 2065 6c65 6d65 6e74 2827 6d65 7468 rn element('meth\n+000539c0: 6f64 272c 206e 616d 653d 6e61 6d65 2c0a od', name=name,.\n+000539d0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000539e0: 2020 2063 6869 6c64 7265 6e3d 5b0a 2020 children=[. \n+000539f0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00053a00: 2020 2020 2065 6c65 6d65 6e74 2827 6172 element('ar\n+00053a10: 6727 2c20 7479 7065 3d61 7267 5f74 7970 g', type=arg_typ\n+00053a20: 652c 2064 6972 6563 7469 6f6e 3d64 6972 e, direction=dir\n+00053a30: 6563 7469 6f6e 290a 2020 2020 2020 2020 ection). \n+00053a40: 2020 2020 2020 2020 2020 2020 2020 2066 f\n+00053a50: 6f72 2064 6972 6563 7469 6f6e 2069 6e20 or direction in \n+00053a60: 5b27 696e 272c 2027 6f75 7427 5d0a 2020 ['in', 'out']. \n+00053a70: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00053a80: 2020 2020 2066 6f72 2061 7267 5f74 7970 for arg_typ\n+00053a90: 6520 696e 206d 6574 686f 645f 696e 666f e in method_info\n+00053aa0: 5b64 6972 6563 7469 6f6e 5d0a 2020 2020 [direction]. \n+00053ab0: 2020 2020 2020 2020 2020 2020 2020 205d ]\n+00053ac0: 290a 0a0a 6465 6620 7072 6f70 6572 7479 )...def property\n+00053ad0: 5f74 6f5f 786d 6c28 6e61 6d65 2c20 7072 _to_xml(name, pr\n+00053ae0: 6f70 6572 7479 5f69 6e66 6f29 3a0a 2020 operty_info):. \n+00053af0: 2020 7265 7475 726e 2065 6c65 6d65 6e74 return element\n+00053b00: 2827 7072 6f70 6572 7479 272c 206e 616d ('property', nam\n+00053b10: 653d 6e61 6d65 2c0a 2020 2020 2020 2020 e=name,. \n+00053b20: 2020 2020 2020 2020 2020 2061 6363 6573 acces\n+00053b30: 733d 2777 7269 7465 2720 6966 2070 726f s='write' if pro\n+00053b40: 7065 7274 795f 696e 666f 5b27 666c 6167 perty_info['flag\n+00053b50: 7327 5d20 3d3d 2027 7727 2065 6c73 6520 s'] == 'w' else \n+00053b60: 2772 6561 6427 2c0a 2020 2020 2020 2020 'read',. \n+00053b70: 2020 2020 2020 2020 2020 2074 7970 653d type=\n+00053b80: 7072 6f70 6572 7479 5f69 6e66 6f5b 2774 property_info['t\n+00053b90: 7970 6527 5d29 0a0a 0a64 6566 2073 6967 ype'])...def sig\n+00053ba0: 6e61 6c5f 746f 5f78 6d6c 286e 616d 652c nal_to_xml(name,\n+00053bb0: 2073 6967 6e61 6c5f 696e 666f 293a 0a20 signal_info):. \n+00053bc0: 2020 2072 6574 7572 6e20 656c 656d 656e return elemen\n+00053bd0: 7428 2773 6967 6e61 6c27 2c20 6e61 6d65 t('signal', name\n+00053be0: 3d6e 616d 652c 0a20 2020 2020 2020 2020 =name,. \n+00053bf0: 2020 2020 2020 2020 2020 6368 696c 6472 childr\n+00053c00: 656e 3d5b 0a20 2020 2020 2020 2020 2020 en=[. \n+00053c10: 2020 2020 2020 2020 2020 2020 656c 656d elem\n+00053c20: 656e 7428 2761 7267 272c 2074 7970 653d ent('arg', type=\n+00053c30: 6172 675f 7479 7065 2920 666f 7220 6172 arg_type) for ar\n+00053c40: 675f 7479 7065 2069 6e20 7369 676e 616c g_type in signal\n+00053c50: 5f69 6e66 6f5b 2769 6e27 5d0a 2020 2020 _info['in']. \n+00053c60: 2020 2020 2020 2020 2020 2020 2020 205d ]\n+00053c70: 290a 0a0a 6465 6620 696e 7465 7266 6163 )...def interfac\n+00053c80: 655f 746f 5f78 6d6c 286e 616d 652c 2069 e_to_xml(name, i\n+00053c90: 6e74 6572 6661 6365 5f69 6e66 6f29 3a0a nterface_info):.\n+00053ca0: 2020 2020 7265 7475 726e 2065 6c65 6d65 return eleme\n+00053cb0: 6e74 2827 696e 7465 7266 6163 6527 2c20 nt('interface', \n+00053cc0: 6e61 6d65 3d6e 616d 652c 0a20 2020 2020 name=name,. \n+00053cd0: 2020 2020 2020 2020 2020 2020 2020 6368 ch\n+00053ce0: 696c 6472 656e 3d5b 0a20 2020 2020 2020 ildren=[. \n+00053cf0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00053d00: 2a28 6d65 7468 6f64 5f74 6f5f 786d 6c28 *(method_to_xml(\n+00053d10: 6e61 6d65 2c20 696e 666f 2920 666f 7220 name, info) for \n+00053d20: 6e61 6d65 2c20 696e 666f 2069 6e20 696e name, info in in\n+00053d30: 7465 7266 6163 655f 696e 666f 5b27 6d65 terface_info['me\n+00053d40: 7468 6f64 7327 5d2e 6974 656d 7328 2929 thods'].items())\n+00053d50: 2c0a 2020 2020 2020 2020 2020 2020 2020 ,. \n+00053d60: 2020 2020 2020 2020 202a 2870 726f 7065 *(prope\n+00053d70: 7274 795f 746f 5f78 6d6c 286e 616d 652c rty_to_xml(name,\n+00053d80: 2069 6e66 6f29 2066 6f72 206e 616d 652c info) for name,\n+00053d90: 2069 6e66 6f20 696e 2069 6e74 6572 6661 info in interfa\n+00053da0: 6365 5f69 6e66 6f5b 2770 726f 7065 7274 ce_info['propert\n+00053db0: 6965 7327 5d2e 6974 656d 7328 2929 2c0a ies'].items()),.\n+00053dc0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00053dd0: 2020 2020 2020 202a 2873 6967 6e61 6c5f *(signal_\n+00053de0: 746f 5f78 6d6c 286e 616d 652c 2069 6e66 to_xml(name, inf\n+00053df0: 6f29 2066 6f72 206e 616d 652c 2069 6e66 o) for name, inf\n+00053e00: 6f20 696e 2069 6e74 6572 6661 6365 5f69 o in interface_i\n+00053e10: 6e66 6f5b 2773 6967 6e61 6c73 275d 2e69 nfo['signals'].i\n+00053e20: 7465 6d73 2829 292c 0a20 2020 2020 2020 tems()),. \n+00053e30: 2020 2020 2020 2020 2020 2020 5d29 0a0a ])..\n+00053e40: 0a64 6566 2074 6f5f 786d 6c28 696e 7465 .def to_xml(inte\n+00053e50: 7266 6163 6573 293a 0a20 2020 206e 6f64 rfaces):. nod\n+00053e60: 6520 3d20 656c 656d 656e 7428 276e 6f64 e = element('nod\n+00053e70: 6527 2c20 6368 696c 6472 656e 3d28 696e e', children=(in\n+00053e80: 7465 7266 6163 655f 746f 5f78 6d6c 286e terface_to_xml(n\n+00053e90: 616d 652c 206d 656d 6265 7273 2920 666f ame, members) fo\n+00053ea0: 7220 6e61 6d65 2c20 6d65 6d62 6572 7320 r name, members \n+00053eb0: 696e 2069 6e74 6572 6661 6365 732e 6974 in interfaces.it\n+00053ec0: 656d 7328 2929 290a 2020 2020 7265 7475 ems())). retu\n+00053ed0: 726e 2045 542e 746f 7374 7269 6e67 286e rn ET.tostring(n\n+00053ee0: 6f64 652c 2065 6e63 6f64 696e 673d 2775 ode, encoding='u\n+00053ef0: 6e69 636f 6465 2729 0a27 2727 2c0a 2020 nicode').''',. \n+00053f00: 2763 6f63 6b70 6974 2f5f 7665 6e64 6f72 'cockpit/_vendor\n+00053f10: 2f73 7973 7465 6d64 5f63 7479 7065 732f /systemd_ctypes/\n+00053f20: 6c69 6272 6172 7977 7261 7070 6572 2e70 librarywrapper.p\n+00053f30: 7927 3a20 6272 2727 2723 2073 7973 7465 y': br'''# syste\n+00053f40: 6d64 5f63 7479 7065 730a 230a 2320 436f md_ctypes.#.# Co\n+00053f50: 7079 7269 6768 7420 2843 2920 3230 3232 pyright (C) 2022\n+00053f60: 2041 6c6c 6973 6f6e 204b 6172 6c69 7473 Allison Karlits\n+00053f70: 6b61 7961 203c 616c 6c69 736f 6e2e 6b61 kaya .#.# This p\n+00053fa0: 726f 6772 616d 2069 7320 6672 6565 2073 rogram is free s\n+00053fb0: 6f66 7477 6172 653a 2079 6f75 2063 616e oftware: you can\n+00053fc0: 2072 6564 6973 7472 6962 7574 6520 6974 redistribute it\n+00053fd0: 2061 6e64 2f6f 7220 6d6f 6469 6679 0a23 and/or modify.#\n+00053fe0: 2069 7420 756e 6465 7220 7468 6520 7465 it under the te\n+00053ff0: 726d 7320 6f66 2074 6865 2047 4e55 2047 rms of the GNU G\n+00054000: 656e 6572 616c 2050 7562 6c69 6320 4c69 eneral Public Li\n+00054010: 6365 6e73 6520 6173 2070 7562 6c69 7368 cense as publish\n+00054020: 6564 2062 790a 2320 7468 6520 4672 6565 ed by.# the Free\n+00054030: 2053 6f66 7477 6172 6520 466f 756e 6461 Software Founda\n+00054040: 7469 6f6e 2c20 6569 7468 6572 2076 6572 tion, either ver\n+00054050: 7369 6f6e 2033 206f 6620 7468 6520 4c69 sion 3 of the Li\n+00054060: 6365 6e73 652c 206f 720a 2320 2861 7420 cense, or.# (at \n+00054070: 796f 7572 206f 7074 696f 6e29 2061 6e79 your option) any\n+00054080: 206c 6174 6572 2076 6572 7369 6f6e 2e0a later version..\n+00054090: 230a 2320 5468 6973 2070 726f 6772 616d #.# This program\n+000540a0: 2069 7320 6469 7374 7269 6275 7465 6420 is distributed \n+000540b0: 696e 2074 6865 2068 6f70 6520 7468 6174 in the hope that\n+000540c0: 2069 7420 7769 6c6c 2062 6520 7573 6566 it will be usef\n+000540d0: 756c 2c0a 2320 6275 7420 5749 5448 4f55 ul,.# but WITHOU\n+000540e0: 5420 414e 5920 5741 5252 414e 5459 3b20 T ANY WARRANTY; \n+000540f0: 7769 7468 6f75 7420 6576 656e 2074 6865 without even the\n+00054100: 2069 6d70 6c69 6564 2077 6172 7261 6e74 implied warrant\n+00054110: 7920 6f66 0a23 204d 4552 4348 414e 5441 y of.# MERCHANTA\n+00054120: 4249 4c49 5459 206f 7220 4649 544e 4553 BILITY or FITNES\n+00054130: 5320 464f 5220 4120 5041 5254 4943 554c S FOR A PARTICUL\n+00054140: 4152 2050 5552 504f 5345 2e20 2053 6565 AR PURPOSE. See\n+00054150: 2074 6865 0a23 2047 4e55 2047 656e 6572 the.# GNU Gener\n+00054160: 616c 2050 7562 6c69 6320 4c69 6365 6e73 al Public Licens\n+00054170: 6520 666f 7220 6d6f 7265 2064 6574 6169 e for more detai\n+00054180: 6c73 2e0a 230a 2320 596f 7520 7368 6f75 ls..#.# You shou\n+00054190: 6c64 2068 6176 6520 7265 6365 6976 6564 ld have received\n+000541a0: 2061 2063 6f70 7920 6f66 2074 6865 2047 a copy of the G\n+000541b0: 4e55 2047 656e 6572 616c 2050 7562 6c69 NU General Publi\n+000541c0: 6320 4c69 6365 6e73 650a 2320 616c 6f6e c License.# alon\n+000541d0: 6720 7769 7468 2074 6869 7320 7072 6f67 g with this prog\n+000541e0: 7261 6d2e 2020 4966 206e 6f74 2c20 7365 ram. If not, se\n+000541f0: 6520 3c68 7474 703a 2f2f 7777 772e 676e e \n+00054210: 2e0a 0a69 6d70 6f72 7420 6374 7970 6573 ...import ctypes\n+00054220: 0a69 6d70 6f72 7420 696e 7370 6563 740a .import inspect.\n+00054230: 696d 706f 7274 206c 6f67 6769 6e67 0a69 import logging.i\n+00054240: 6d70 6f72 7420 6f73 0a69 6d70 6f72 7420 mport os.import \n+00054250: 7379 730a 696d 706f 7274 2074 7970 6573 sys.import types\n+00054260: 0a66 726f 6d20 7479 7069 6e67 2069 6d70 .from typing imp\n+00054270: 6f72 7420 280a 2020 2020 416e 792c 0a20 ort (. Any,. \n+00054280: 2020 2043 616c 6c61 626c 652c 0a20 2020 Callable,. \n+00054290: 2044 6963 742c 0a20 2020 2047 656e 6572 Dict,. Gener\n+000542a0: 6963 2c0a 2020 2020 4e65 7754 7970 652c ic,. NewType,\n+000542b0: 0a20 2020 204e 6f52 6574 7572 6e2c 0a20 . NoReturn,. \n+000542c0: 2020 204f 7074 696f 6e61 6c2c 0a20 2020 Optional,. \n+000542d0: 2054 7570 6c65 2c0a 2020 2020 5479 7065 Tuple,. Type\n+000542e0: 2c0a 2020 2020 5479 7065 5661 722c 0a20 ,. TypeVar,. \n+000542f0: 2020 2055 6e69 6f6e 2c0a 290a 0a66 726f Union,.)..fro\n+00054300: 6d20 2e20 696d 706f 7274 2074 7970 696e m . import typin\n+00054310: 670a 0a23 2046 6972 7374 2069 6e20 332e g..# First in 3.\n+00054320: 3130 2c20 616e 6420 636f 6e64 6974 696f 10, and conditio\n+00054330: 6e61 6c20 696d 706f 7274 2067 6976 6573 nal import gives\n+00054340: 2074 7970 6520 6572 726f 7273 0a4e 6f6e type errors.Non\n+00054350: 6554 7970 6520 3d20 7479 7065 284e 6f6e eType = type(Non\n+00054360: 6529 0a0a 6c6f 6767 6572 203d 206c 6f67 e)..logger = log\n+00054370: 6769 6e67 2e67 6574 4c6f 6767 6572 285f ging.getLogger(_\n+00054380: 5f6e 616d 655f 5f29 0a0a 6966 2074 7970 _name__)..if typ\n+00054390: 696e 672e 5459 5045 5f43 4845 434b 494e ing.TYPE_CHECKIN\n+000543a0: 473a 0a20 2020 2043 5479 7065 203d 2054 G:. CType = T\n+000543b0: 7970 6556 6172 2822 4354 7970 6522 2c20 ypeVar(\"CType\", \n+000543c0: 626f 756e 643d 6374 7970 6573 2e5f 4344 bound=ctypes._CD\n+000543d0: 6174 6129 0a20 2020 2043 616c 6c62 6163 ata). Callbac\n+000543e0: 6b20 3d20 6374 7970 6573 2e5f 4675 6e63 k = ctypes._Func\n+000543f0: 506f 696e 7465 720a 656c 7365 3a0a 2020 Pointer.else:. \n+00054400: 2020 4354 7970 6520 3d20 5479 7065 5661 CType = TypeVa\n+00054410: 7228 2243 5479 7065 2229 0a20 2020 2043 r(\"CType\"). C\n+00054420: 616c 6c62 6163 6b20 3d20 6374 7970 6573 allback = ctypes\n+00054430: 2e63 5f76 6f69 645f 700a 0a0a 6966 2074 .c_void_p...if t\n+00054440: 7970 696e 672e 5459 5045 5f43 4845 434b yping.TYPE_CHECK\n+00054450: 494e 473a 0a20 2020 2063 6c61 7373 2052 ING:. class R\n+00054460: 6566 6572 656e 6365 2847 656e 6572 6963 eference(Generic\n+00054470: 5b43 5479 7065 5d2c 2063 7479 7065 732e [CType], ctypes.\n+00054480: 5f50 6f69 6e74 6572 5b43 5479 7065 5d29 _Pointer[CType])\n+00054490: 3a0a 2020 2020 2020 2020 7061 7373 0a0a :. pass..\n+000544a0: 2020 2020 6465 6620 6279 7265 6628 783a def byref(x:\n+000544b0: 2043 5479 7065 2920 2d3e 2052 6566 6572 CType) -> Refer\n+000544c0: 656e 6365 5b43 5479 7065 5d3a 0a20 2020 ence[CType]:. \n+000544d0: 2020 2020 2072 6169 7365 204e 6f74 496d raise NotIm\n+000544e0: 706c 656d 656e 7465 6445 7272 6f72 0a65 plementedError.e\n+000544f0: 6c73 653a 0a20 2020 2063 6c61 7373 2052 lse:. class R\n+00054500: 6566 6572 656e 6365 2847 656e 6572 6963 eference(Generic\n+00054510: 5b43 5479 7065 5d29 3a0a 2020 2020 2020 [CType]):. \n+00054520: 2020 7061 7373 0a0a 2020 2020 6279 7265 pass.. byre\n+00054530: 6620 3d20 6374 7970 6573 2e62 7972 6566 f = ctypes.byref\n+00054540: 0a0a 0a55 7365 7244 6174 6120 3d20 4f70 ...UserData = Op\n+00054550: 7469 6f6e 616c 5b63 7479 7065 732e 635f tional[ctypes.c_\n+00054560: 766f 6964 5f70 5d0a 0a0a 636c 6173 7320 void_p]...class \n+00054570: 6e65 6761 7469 7665 5f65 7272 6e6f 2863 negative_errno(c\n+00054580: 7479 7065 732e 635f 696e 7429 3a0a 2020 types.c_int):. \n+00054590: 2020 6465 6620 6572 7263 6865 636b 2873 def errcheck(s\n+000545a0: 656c 662c 2066 756e 633a 2043 616c 6c61 elf, func: Calla\n+000545b0: 626c 655b 2e2e 2e2c 206f 626a 6563 745d ble[..., object]\n+000545c0: 2c20 5f61 7267 733a 2054 7570 6c65 5b6f , _args: Tuple[o\n+000545d0: 626a 6563 742c 202e 2e2e 5d29 202d 3e20 bject, ...]) -> \n+000545e0: 696e 743a 0a20 2020 2020 2020 2072 6573 int:. res\n+000545f0: 756c 7420 3d20 7365 6c66 2e76 616c 7565 ult = self.value\n+00054600: 0a20 2020 2020 2020 2069 6620 7265 7375 . if resu\n+00054610: 6c74 203c 2030 3a0a 2020 2020 2020 2020 lt < 0:. \n+00054620: 2020 2020 7261 6973 6520 4f53 4572 726f raise OSErro\n+00054630: 7228 2d72 6573 756c 742c 2066 227b 6675 r(-result, f\"{fu\n+00054640: 6e63 2e5f 5f6e 616d 655f 5f7d 3a20 7b6f nc.__name__}: {o\n+00054650: 732e 7374 7265 7272 6f72 282d 7265 7375 s.strerror(-resu\n+00054660: 6c74 297d 2229 0a20 2020 2020 2020 2072 lt)}\"). r\n+00054670: 6574 7572 6e20 7265 7375 6c74 0a0a 0a63 eturn result...c\n+00054680: 6c61 7373 2075 7466 3828 6374 7970 6573 lass utf8(ctypes\n+00054690: 2e63 5f63 6861 725f 7029 3a0a 2020 2020 .c_char_p):. \n+000546a0: 6465 6620 6572 7263 6865 636b 2873 656c def errcheck(sel\n+000546b0: 662c 2066 756e 633a 2043 616c 6c61 626c f, func: Callabl\n+000546c0: 655b 2e2e 2e2c 206f 626a 6563 745d 2c20 e[..., object], \n+000546d0: 5f61 7267 733a 2054 7570 6c65 5b6f 626a _args: Tuple[obj\n+000546e0: 6563 742c 202e 2e2e 5d29 202d 3e20 7374 ect, ...]) -> st\n+000546f0: 723a 0a20 2020 2020 2020 2061 7373 6572 r:. asser\n+00054700: 7420 7365 6c66 2e76 616c 7565 2069 7320 t self.value is \n+00054710: 6e6f 7420 4e6f 6e65 0a20 2020 2020 2020 not None. \n+00054720: 2072 6574 7572 6e20 7365 6c66 2e76 616c return self.val\n+00054730: 7565 2e64 6563 6f64 6528 290a 0a20 2020 ue.decode().. \n+00054740: 2040 636c 6173 736d 6574 686f 640a 2020 @classmethod. \n+00054750: 2020 6465 6620 6672 6f6d 5f70 6172 616d def from_param\n+00054760: 2863 6c73 2c20 7661 6c75 653a 2073 7472 (cls, value: str\n+00054770: 2920 2d3e 2027 7574 6638 273a 0a20 2020 ) -> 'utf8':. \n+00054780: 2020 2020 2072 6574 7572 6e20 636c 7328 return cls(\n+00054790: 7661 6c75 652e 656e 636f 6465 2829 290a value.encode()).\n+000547a0: 0a0a 636c 6173 7320 7574 6638 5f6f 725f ..class utf8_or_\n+000547b0: 6e75 6c6c 2863 7479 7065 732e 635f 6368 null(ctypes.c_ch\n+000547c0: 6172 5f70 293a 0a20 2020 2064 6566 2065 ar_p):. def e\n+000547d0: 7272 6368 6563 6b28 7365 6c66 2c0a 2020 rrcheck(self,. \n+000547e0: 2020 2020 2020 2020 2020 2020 2020 2066 f\n+000547f0: 756e 633a 2043 616c 6c61 626c 655b 2e2e unc: Callable[..\n+00054800: 2e2c 206f 626a 6563 745d 2c0a 2020 2020 ., object],. \n+00054810: 2020 2020 2020 2020 2020 2020 205f 6172 _ar\n+00054820: 6773 3a20 5475 706c 655b 6f62 6a65 6374 gs: Tuple[object\n+00054830: 2c20 2e2e 2e5d 2920 2d3e 204f 7074 696f , ...]) -> Optio\n+00054840: 6e61 6c5b 7374 725d 3a0a 2020 2020 2020 nal[str]:. \n+00054850: 2020 7265 7475 726e 2073 656c 662e 7661 return self.va\n+00054860: 6c75 652e 6465 636f 6465 2829 2069 6620 lue.decode() if \n+00054870: 7365 6c66 2e76 616c 7565 2069 7320 6e6f self.value is no\n+00054880: 7420 4e6f 6e65 2065 6c73 6520 4e6f 6e65 t None else None\n+00054890: 0a0a 2020 2020 4063 6c61 7373 6d65 7468 .. @classmeth\n+000548a0: 6f64 0a20 2020 2064 6566 2066 726f 6d5f od. def from_\n+000548b0: 7061 7261 6d28 636c 732c 2076 616c 7565 param(cls, value\n+000548c0: 3a20 4f70 7469 6f6e 616c 5b73 7472 5d29 : Optional[str])\n+000548d0: 202d 3e20 2775 7466 385f 6f72 5f6e 756c -> 'utf8_or_nul\n+000548e0: 6c27 3a0a 2020 2020 2020 2020 7265 7475 l':. retu\n+000548f0: 726e 2063 6c73 2876 616c 7565 2e65 6e63 rn cls(value.enc\n+00054900: 6f64 6528 2920 6966 2076 616c 7565 2069 ode() if value i\n+00054910: 7320 6e6f 7420 4e6f 6e65 2065 6c73 6520 s not None else \n+00054920: 4e6f 6e65 290a 0a0a 636c 6173 7320 626f None)...class bo\n+00054930: 6f6c 696e 7428 6374 7970 6573 2e63 5f69 olint(ctypes.c_i\n+00054940: 6e74 293a 0a20 2020 2064 6566 2065 7272 nt):. def err\n+00054950: 6368 6563 6b28 7365 6c66 2c20 6675 6e63 check(self, func\n+00054960: 3a20 4361 6c6c 6162 6c65 5b2e 2e2e 2c20 : Callable[..., \n+00054970: 6f62 6a65 6374 5d2c 205f 6172 6773 3a20 object], _args: \n+00054980: 5475 706c 655b 6f62 6a65 6374 2c20 2e2e Tuple[object, ..\n+00054990: 2e5d 2920 2d3e 2062 6f6f 6c3a 0a20 2020 .]) -> bool:. \n+000549a0: 2020 2020 2072 6574 7572 6e20 626f 6f6c return bool\n+000549b0: 2873 656c 662e 7661 6c75 6529 0a0a 0a57 (self.value)...W\n+000549c0: 6561 6b52 6566 6572 656e 6365 203d 204e eakReference = N\n+000549d0: 6577 5479 7065 2822 5765 616b 5265 6665 ewType(\"WeakRefe\n+000549e0: 7265 6e63 6522 2c20 696e 7429 0a45 7272 rence\", int).Err\n+000549f0: 6e6f 203d 2074 7970 696e 672e 416e 6e6f no = typing.Anno\n+00054a00: 7461 7465 645b 4e6f 5265 7475 726e 2c20 tated[NoReturn, \n+00054a10: 2265 7272 6e6f 225d 0a0a 0a74 7970 655f \"errno\"]...type_\n+00054a20: 6d61 7020 3d20 7b0a 2020 2020 556e 696f map = {. Unio\n+00054a30: 6e5b 4e6f 6e65 2c20 4572 726e 6f5d 3a20 n[None, Errno]: \n+00054a40: 6e65 6761 7469 7665 5f65 7272 6e6f 2c20 negative_errno, \n+00054a50: 2023 2074 6563 686e 6963 616c 6c79 2072 # technically r\n+00054a60: 6574 7572 6e73 2069 6e74 0a20 2020 2055 eturns int. U\n+00054a70: 6e69 6f6e 5b62 6f6f 6c2c 2045 7272 6e6f nion[bool, Errno\n+00054a80: 5d3a 206e 6567 6174 6976 655f 6572 726e ]: negative_errn\n+00054a90: 6f2c 2020 2320 7465 6368 6e69 6361 6c6c o, # technicall\n+00054aa0: 7920 7265 7475 726e 7320 696e 740a 2020 y returns int. \n+00054ab0: 2020 556e 696f 6e5b 696e 742c 2045 7272 Union[int, Err\n+00054ac0: 6e6f 5d3a 206e 6567 6174 6976 655f 6572 no]: negative_er\n+00054ad0: 726e 6f2c 0a20 2020 2062 6f6f 6c3a 2062 rno,. bool: b\n+00054ae0: 6f6f 6c69 6e74 2c0a 2020 2020 4f70 7469 oolint,. Opti\n+00054af0: 6f6e 616c 5b73 7472 5d3a 2075 7466 385f onal[str]: utf8_\n+00054b00: 6f72 5f6e 756c 6c2c 0a20 2020 2073 7472 or_null,. str\n+00054b10: 3a20 7574 6638 2c0a 2020 2020 696e 743a : utf8,. int:\n+00054b20: 2063 7479 7065 732e 635f 696e 742c 0a20 ctypes.c_int,. \n+00054b30: 2020 2057 6561 6b52 6566 6572 656e 6365 WeakReference\n+00054b40: 3a20 6374 7970 6573 2e63 5f76 6f69 645f : ctypes.c_void_\n+00054b50: 700a 7d0a 0a0a 6465 6620 6d61 705f 7479 p.}...def map_ty\n+00054b60: 7065 2861 6e6e 6f74 6174 696f 6e3a 2041 pe(annotation: A\n+00054b70: 6e79 2c20 676c 6f62 616c 5f76 6172 733a ny, global_vars:\n+00054b80: 2044 6963 745b 7374 722c 206f 626a 6563 Dict[str, objec\n+00054b90: 745d 2920 2d3e 2041 6e79 3a0a 2020 2020 t]) -> Any:. \n+00054ba0: 7472 793a 0a20 2020 2020 2020 2072 6574 try:. ret\n+00054bb0: 7572 6e20 7479 7065 5f6d 6170 5b61 6e6e urn type_map[ann\n+00054bc0: 6f74 6174 696f 6e5d 0a20 2020 2065 7863 otation]. exc\n+00054bd0: 6570 7420 4b65 7945 7272 6f72 3a0a 2020 ept KeyError:. \n+00054be0: 2020 2020 2020 7061 7373 2020 2320 2e2e pass # ..\n+00054bf0: 2e20 616e 6420 7472 7920 6d6f 7265 2063 . and try more c\n+00054c00: 6173 6573 2062 656c 6f77 0a0a 2020 2020 ases below.. \n+00054c10: 6966 2069 7369 6e73 7461 6e63 6528 616e if isinstance(an\n+00054c20: 6e6f 7461 7469 6f6e 2c20 7479 7069 6e67 notation, typing\n+00054c30: 2e46 6f72 7761 7264 5265 6629 3a0a 2020 .ForwardRef):. \n+00054c40: 2020 2020 2020 616e 6e6f 7461 7469 6f6e annotation\n+00054c50: 203d 2061 6e6e 6f74 6174 696f 6e2e 5f5f = annotation.__\n+00054c60: 666f 7277 6172 645f 6172 675f 5f0a 0a20 forward_arg__.. \n+00054c70: 2020 2069 6620 6973 696e 7374 616e 6365 if isinstance\n+00054c80: 2861 6e6e 6f74 6174 696f 6e2c 2073 7472 (annotation, str\n+00054c90: 293a 0a20 2020 2020 2020 2061 6e6e 6f74 ):. annot\n+00054ca0: 6174 696f 6e20 3d20 676c 6f62 616c 5f76 ation = global_v\n+00054cb0: 6172 735b 616e 6e6f 7461 7469 6f6e 5d0a ars[annotation].\n+00054cc0: 0a20 2020 206f 7269 6769 6e20 3d20 7479 . origin = ty\n+00054cd0: 7069 6e67 2e67 6574 5f6f 7269 6769 6e28 ping.get_origin(\n+00054ce0: 616e 6e6f 7461 7469 6f6e 290a 2020 2020 annotation). \n+00054cf0: 6172 6773 203d 2074 7970 696e 672e 6765 args = typing.ge\n+00054d00: 745f 6172 6773 2861 6e6e 6f74 6174 696f t_args(annotatio\n+00054d10: 6e29 0a0a 2020 2020 6966 206f 7269 6769 n).. if origi\n+00054d20: 6e20 6973 2052 6566 6572 656e 6365 3a0a n is Reference:.\n+00054d30: 2020 2020 2020 2020 7265 7475 726e 2063 return c\n+00054d40: 7479 7065 732e 504f 494e 5445 5228 6d61 types.POINTER(ma\n+00054d50: 705f 7479 7065 2861 7267 735b 305d 2c20 p_type(args[0], \n+00054d60: 676c 6f62 616c 5f76 6172 7329 290a 0a20 global_vars)).. \n+00054d70: 2020 2065 6c69 6620 6f72 6967 696e 2069 elif origin i\n+00054d80: 7320 556e 696f 6e20 616e 6420 4e6f 6e65 s Union and None\n+00054d90: 5479 7065 2069 6e20 6172 6773 3a0a 2020 Type in args:. \n+00054da0: 2020 2020 2020 2320 7468 6520 4320 706f # the C po\n+00054db0: 696e 7465 7220 7479 7065 7320 6172 6520 inter types are \n+00054dc0: 616c 7265 6164 7920 6e75 6c6c 6162 6c65 already nullable\n+00054dd0: 0a20 2020 2020 2020 206f 7468 6572 5f61 . other_a\n+00054de0: 7267 2c20 3d20 7365 7428 6172 6773 2920 rg, = set(args) \n+00054df0: 2d20 7b4e 6f6e 6554 7970 657d 0a20 2020 - {NoneType}. \n+00054e00: 2020 2020 2072 6574 7572 6e20 6d61 705f return map_\n+00054e10: 7479 7065 286f 7468 6572 5f61 7267 2c20 type(other_arg, \n+00054e20: 676c 6f62 616c 5f76 6172 7329 0a0a 2020 global_vars).. \n+00054e30: 2020 656c 6966 206f 7269 6769 6e20 6973 elif origin is\n+00054e40: 2074 7970 696e 672e 416e 6e6f 7461 7465 typing.Annotate\n+00054e50: 643a 0a20 2020 2020 2020 2072 6574 7572 d:. retur\n+00054e60: 6e20 6172 6773 5b31 5d0a 0a20 2020 2065 n args[1].. e\n+00054e70: 6c73 653a 0a20 2020 2020 2020 2061 7373 lse:. ass\n+00054e80: 6572 7420 6f72 6967 696e 2069 7320 4e6f ert origin is No\n+00054e90: 6e65 2c20 6f72 6967 696e 0a20 2020 2020 ne, origin. \n+00054ea0: 2020 2072 6574 7572 6e20 616e 6e6f 7461 return annota\n+00054eb0: 7469 6f6e 0a0a 0a63 6c61 7373 2052 6566 tion...class Ref\n+00054ec0: 6572 656e 6365 5479 7065 2863 7479 7065 erenceType(ctype\n+00054ed0: 732e 635f 766f 6964 5f70 293a 0a20 2020 s.c_void_p):. \n+00054ee0: 2040 636c 6173 736d 6574 686f 640a 2020 @classmethod. \n+00054ef0: 2020 6465 6620 5f69 6e73 7461 6c6c 5f63 def _install_c\n+00054f00: 6675 6e63 7328 636c 732c 2063 646c 6c3a funcs(cls, cdll:\n+00054f10: 2063 7479 7065 732e 4344 4c4c 2920 2d3e ctypes.CDLL) ->\n+00054f20: 204e 6f6e 653a 0a20 2020 2020 2020 206c None:. l\n+00054f30: 6f67 6765 722e 6465 6275 6728 2749 6e73 ogger.debug('Ins\n+00054f40: 7461 6c6c 696e 6720 7374 7562 7320 666f talling stubs fo\n+00054f50: 7220 2573 3a27 2c20 636c 7329 0a20 2020 r %s:', cls). \n+00054f60: 2020 2020 2073 7475 6273 203d 2074 7570 stubs = tup\n+00054f70: 6c65 2863 6c73 2e5f 5f64 6963 745f 5f2e le(cls.__dict__.\n+00054f80: 6974 656d 7328 2929 0a20 2020 2020 2020 items()). \n+00054f90: 2066 6f72 206e 616d 652c 2073 7475 6220 for name, stub \n+00054fa0: 696e 2073 7475 6273 3a0a 2020 2020 2020 in stubs:. \n+00054fb0: 2020 2020 2020 6966 206e 616d 652e 7374 if name.st\n+00054fc0: 6172 7473 7769 7468 2822 5f5f 2229 3a0a artswith(\"__\"):.\n+00054fd0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00054fe0: 636f 6e74 696e 7565 0a20 2020 2020 2020 continue. \n+00054ff0: 2020 2020 2063 6c73 2e5f 7772 6170 2863 cls._wrap(c\n+00055000: 646c 6c2c 2073 7475 6229 0a0a 2020 2020 dll, stub).. \n+00055010: 2020 2020 636c 732e 5f77 7261 7028 6364 cls._wrap(cd\n+00055020: 6c6c 2c20 636c 732e 5f72 6566 290a 2020 ll, cls._ref). \n+00055030: 2020 2020 2020 636c 732e 5f77 7261 7028 cls._wrap(\n+00055040: 6364 6c6c 2c20 636c 732e 5f75 6e72 6566 cdll, cls._unref\n+00055050: 290a 0a20 2020 2040 636c 6173 736d 6574 ).. @classmet\n+00055060: 686f 640a 2020 2020 6465 6620 5f77 7261 hod. def _wra\n+00055070: 7028 636c 732c 2063 646c 6c3a 2063 7479 p(cls, cdll: cty\n+00055080: 7065 732e 4344 4c4c 2c20 7374 7562 3a20 pes.CDLL, stub: \n+00055090: 6f62 6a65 6374 2920 2d3e 204e 6f6e 653a object) -> None:\n+000550a0: 0a20 2020 2020 2020 2073 7475 625f 7479 . stub_ty\n+000550b0: 7065 203d 2074 7970 6528 7374 7562 290a pe = type(stub).\n+000550c0: 2020 2020 2020 2020 6966 2069 7369 6e73 if isins\n+000550d0: 7461 6e63 6528 7374 7562 2c20 7374 6174 tance(stub, stat\n+000550e0: 6963 6d65 7468 6f64 293a 0a20 2020 2020 icmethod):. \n+000550f0: 2020 2020 2020 2023 2049 6e20 6f6c 6465 # In olde\n+00055100: 7220 5079 7468 6f6e 2076 6572 7369 6f6e r Python version\n+00055110: 732c 2073 7461 7469 636d 6574 686f 6428 s, staticmethod(\n+00055120: 2920 6973 6e27 7420 636f 6e73 6964 6572 ) isn't consider\n+00055130: 6564 0a20 2020 2020 2020 2020 2020 2023 ed. #\n+00055140: 2063 616c 6c61 626c 652c 2064 6f65 736e callable, doesn\n+00055150: 2774 2068 6176 6520 6120 6e61 6d65 2c20 't have a name, \n+00055160: 616e 6420 6361 6e27 7420 6265 2069 6e74 and can't be int\n+00055170: 726f 7370 6563 7465 6420 7769 7468 0a20 rospected with. \n+00055180: 2020 2020 2020 2020 2020 2023 2069 6e73 # ins\n+00055190: 7065 6374 2e73 6967 6e61 7475 7265 2829 pect.signature()\n+000551a0: 2e20 556e 7772 6170 2069 742e 0a20 2020 . Unwrap it.. \n+000551b0: 2020 2020 2020 2020 2073 7475 6220 3d20 stub = \n+000551c0: 7374 7562 2e5f 5f66 756e 635f 5f0a 2020 stub.__func__. \n+000551d0: 2020 2020 2020 6173 7365 7274 2069 7369 assert isi\n+000551e0: 6e73 7461 6e63 6528 7374 7562 2c20 7479 nstance(stub, ty\n+000551f0: 7065 732e 4675 6e63 7469 6f6e 5479 7065 pes.FunctionType\n+00055200: 290a 2020 2020 2020 2020 6e61 6d65 203d ). name =\n+00055210: 2073 7475 622e 5f5f 6e61 6d65 5f5f 0a20 stub.__name__. \n+00055220: 2020 2020 2020 2073 6967 6e61 7475 7265 signature\n+00055230: 203d 2069 6e73 7065 6374 2e73 6967 6e61 = inspect.signa\n+00055240: 7475 7265 2873 7475 6229 0a20 2020 2020 ture(stub). \n+00055250: 2020 2073 7475 625f 676c 6f62 616c 7320 stub_globals \n+00055260: 3d20 7379 732e 6d6f 6475 6c65 732e 6765 = sys.modules.ge\n+00055270: 7428 636c 732e 5f5f 6d6f 6475 6c65 5f5f t(cls.__module__\n+00055280: 292e 5f5f 6469 6374 5f5f 0a0a 2020 2020 ).__dict__.. \n+00055290: 2020 2020 6675 6e63 203d 2063 646c 6c5b func = cdll[\n+000552a0: 6627 7b63 6c73 2e5f 5f6e 616d 655f 5f7d f'{cls.__name__}\n+000552b0: 5f7b 6e61 6d65 2e6c 7374 7269 7028 225f _{name.lstrip(\"_\n+000552c0: 2229 7d27 5d0a 2020 2020 2020 2020 6675 \")}']. fu\n+000552d0: 6e63 2e61 7267 7479 7065 7320 3d20 7475 nc.argtypes = tu\n+000552e0: 706c 6528 0a20 2020 2020 2020 2020 2020 ple(. \n+000552f0: 206d 6170 5f74 7970 6528 7061 7261 6d65 map_type(parame\n+00055300: 7465 722e 616e 6e6f 7461 7469 6f6e 2c20 ter.annotation, \n+00055310: 7374 7562 5f67 6c6f 6261 6c73 290a 2020 stub_globals). \n+00055320: 2020 2020 2020 2020 2020 666f 7220 7061 for pa\n+00055330: 7261 6d65 7465 7220 696e 2073 6967 6e61 rameter in signa\n+00055340: 7475 7265 2e70 6172 616d 6574 6572 732e ture.parameters.\n+00055350: 7661 6c75 6573 2829 0a20 2020 2020 2020 values(). \n+00055360: 2029 0a20 2020 2020 2020 2066 756e 632e ). func.\n+00055370: 7265 7374 7970 6520 3d20 6d61 705f 7479 restype = map_ty\n+00055380: 7065 2873 6967 6e61 7475 7265 2e72 6574 pe(signature.ret\n+00055390: 7572 6e5f 616e 6e6f 7461 7469 6f6e 2c20 urn_annotation, \n+000553a0: 7374 7562 5f67 6c6f 6261 6c73 290a 2020 stub_globals). \n+000553b0: 2020 2020 2020 6572 7263 6865 636b 203d errcheck =\n+000553c0: 2067 6574 6174 7472 2866 756e 632e 7265 getattr(func.re\n+000553d0: 7374 7970 652c 2027 6572 7263 6865 636b stype, 'errcheck\n+000553e0: 272c 204e 6f6e 6529 0a20 2020 2020 2020 ', None). \n+000553f0: 2069 6620 6572 7263 6865 636b 2069 7320 if errcheck is \n+00055400: 6e6f 7420 4e6f 6e65 3a0a 2020 2020 2020 not None:. \n+00055410: 2020 2020 2020 6675 6e63 2e65 7272 6368 func.errch\n+00055420: 6563 6b20 3d20 6572 7263 6865 636b 0a0a eck = errcheck..\n+00055430: 2020 2020 2020 2020 6c6f 6767 6572 2e64 logger.d\n+00055440: 6562 7567 2827 2020 6372 6561 7465 2077 ebug(' create w\n+00055450: 7261 7070 6572 2025 732e 2573 2573 272c rapper %s.%s%s',\n+00055460: 2063 6c73 2e5f 5f6e 616d 655f 5f2c 206e cls.__name__, n\n+00055470: 616d 652c 2073 6967 6e61 7475 7265 290a ame, signature).\n+00055480: 2020 2020 2020 2020 6c6f 6767 6572 2e64 logger.d\n+00055490: 6562 7567 2827 2020 2020 6172 6773 2025 ebug(' args %\n+000554a0: 7320 7265 7320 2573 272c 2066 756e 632e s res %s', func.\n+000554b0: 6172 6774 7970 6573 2c20 6675 6e63 2e72 argtypes, func.r\n+000554c0: 6573 7479 7065 290a 0a20 2020 2020 2020 estype).. \n+000554d0: 2023 2063 7479 7065 7320 6675 6e63 7469 # ctypes functi\n+000554e0: 6f6e 2070 6f69 6e74 6572 206f 626a 6563 on pointer objec\n+000554f0: 7473 2064 6f6e 2774 2069 6d70 6c65 6d65 ts don't impleme\n+00055500: 6e74 2074 6865 2075 7375 616c 2066 756e nt the usual fun\n+00055510: 6374 696f 6e0a 2020 2020 2020 2020 2320 ction. # \n+00055520: 6465 7363 7269 7074 6f72 206c 6f67 6963 descriptor logic\n+00055530: 2c20 7768 6963 6820 6d65 616e 7320 7468 , which means th\n+00055540: 6579 2077 6f6e 2774 2062 696e 6420 6173 ey won't bind as\n+00055550: 206d 6574 686f 6473 2e20 2046 6f72 2073 methods. For s\n+00055560: 7461 7469 630a 2020 2020 2020 2020 2320 tatic. # \n+00055570: 6d65 7468 6f64 732c 2074 6861 7427 7320 methods, that's \n+00055580: 676f 6f64 2c20 6275 7420 666f 7220 696e good, but for in\n+00055590: 7374 616e 6365 206d 6574 686f 6473 2c20 stance methods, \n+000555a0: 7765 2061 6464 2061 2077 7261 7070 6572 we add a wrapper\n+000555b0: 2061 730a 2020 2020 2020 2020 2320 7468 as. # th\n+000555c0: 6520 6561 7369 6573 7420 616e 6420 6d6f e easiest and mo\n+000555d0: 7374 2070 6572 666f 726d 616e 7420 7761 st performant wa\n+000555e0: 7920 746f 2067 6574 2074 6865 2062 696e y to get the bin\n+000555f0: 6469 6e67 2062 6568 6176 696f 7572 2e0a ding behaviour..\n+00055600: 2020 2020 2020 2020 6966 2073 7475 625f if stub_\n+00055610: 7479 7065 2069 7320 6e6f 7420 7374 6174 type is not stat\n+00055620: 6963 6d65 7468 6f64 3a0a 2020 2020 2020 icmethod:. \n+00055630: 2020 2020 2020 7365 7461 7474 7228 636c setattr(cl\n+00055640: 732c 206e 616d 652c 206c 616d 6264 6120 s, name, lambda \n+00055650: 2a61 7267 733a 2066 756e 6328 2a61 7267 *args: func(*arg\n+00055660: 7329 290a 2020 2020 2020 2020 656c 7365 s)). else\n+00055670: 3a0a 2020 2020 2020 2020 2020 2020 7365 :. se\n+00055680: 7461 7474 7228 636c 732c 206e 616d 652c tattr(cls, name,\n+00055690: 2066 756e 6329 0a0a 2020 2020 6465 6620 func).. def \n+000556a0: 5f75 6e72 6566 2873 656c 663a 2027 5265 _unref(self: 'Re\n+000556b0: 6665 7265 6e63 6554 7970 6527 2920 2d3e ferenceType') ->\n+000556c0: 204e 6f6e 653a 0a20 2020 2020 2020 202e None:. .\n+000556d0: 2e2e 0a0a 2020 2020 6465 6620 5f72 6566 .... def _ref\n+000556e0: 2873 656c 663a 2027 5265 6665 7265 6e63 (self: 'Referenc\n+000556f0: 6554 7970 6527 2920 2d3e 204e 6f6e 653a eType') -> None:\n+00055700: 0a20 2020 2020 2020 202e 2e2e 0a0a 2020 . ..... \n+00055710: 2020 5420 3d20 5479 7065 5661 7228 2254 T = TypeVar(\"T\n+00055720: 222c 2062 6f75 6e64 3d27 5265 6665 7265 \", bound='Refere\n+00055730: 6e63 6554 7970 6527 290a 0a20 2020 2040 nceType').. @\n+00055740: 636c 6173 736d 6574 686f 640a 2020 2020 classmethod. \n+00055750: 6465 6620 7265 6628 636c 733a 2054 7970 def ref(cls: Typ\n+00055760: 655b 545d 2c20 6f72 6967 696e 3a20 5765 e[T], origin: We\n+00055770: 616b 5265 6665 7265 6e63 6529 202d 3e20 akReference) -> \n+00055780: 543a 0a20 2020 2020 2020 2073 656c 6620 T:. self \n+00055790: 3d20 636c 7328 6f72 6967 696e 290a 2020 = cls(origin). \n+000557a0: 2020 2020 2020 7365 6c66 2e5f 7265 6628 self._ref(\n+000557b0: 290a 2020 2020 2020 2020 7265 7475 726e ). return\n+000557c0: 2073 656c 660a 0a20 2020 2064 6566 205f self.. def _\n+000557d0: 5f64 656c 5f5f 2873 656c 6629 202d 3e20 _del__(self) -> \n+000557e0: 4e6f 6e65 3a0a 2020 2020 2020 2020 6966 None:. if\n+000557f0: 2073 656c 662e 7661 6c75 6520 6973 206e self.value is n\n+00055800: 6f74 204e 6f6e 653a 0a20 2020 2020 2020 ot None:. \n+00055810: 2020 2020 2073 656c 662e 5f75 6e72 6566 self._unref\n+00055820: 2829 0a27 2727 2c0a 2020 2763 6f63 6b70 ().''',. 'cockp\n+00055830: 6974 2f5f 7665 6e64 6f72 2f73 7973 7465 it/_vendor/syste\n+00055840: 6d64 5f63 7479 7065 732f 6275 7374 7970 md_ctypes/bustyp\n+00055850: 6573 2e70 7927 3a20 6272 2727 2723 2073 es.py': br'''# s\n+00055860: 7973 7465 6d64 5f63 7479 7065 730a 230a ystemd_ctypes.#.\n+00055870: 2320 436f 7079 7269 6768 7420 2843 2920 # Copyright (C) \n+00055880: 3230 3233 2041 6c6c 6973 6f6e 204b 6172 2023 Allison Kar\n+00055890: 6c69 7473 6b61 7961 203c 616c 6c69 736f litskaya .#.# Th\n+000558c0: 6973 2070 726f 6772 616d 2069 7320 6672 is program is fr\n+000558d0: 6565 2073 6f66 7477 6172 653a 2079 6f75 ee software: you\n+000558e0: 2063 616e 2072 6564 6973 7472 6962 7574 can redistribut\n+000558f0: 6520 6974 2061 6e64 2f6f 7220 6d6f 6469 e it and/or modi\n+00055900: 6679 0a23 2069 7420 756e 6465 7220 7468 fy.# it under th\n+00055910: 6520 7465 726d 7320 6f66 2074 6865 2047 e terms of the G\n+00055920: 4e55 2047 656e 6572 616c 2050 7562 6c69 NU General Publi\n+00055930: 6320 4c69 6365 6e73 6520 6173 2070 7562 c License as pub\n+00055940: 6c69 7368 6564 2062 790a 2320 7468 6520 lished by.# the \n+00055950: 4672 6565 2053 6f66 7477 6172 6520 466f Free Software Fo\n+00055960: 756e 6461 7469 6f6e 2c20 6569 7468 6572 undation, either\n+00055970: 2076 6572 7369 6f6e 2033 206f 6620 7468 version 3 of th\n+00055980: 6520 4c69 6365 6e73 652c 206f 720a 2320 e License, or.# \n+00055990: 2861 7420 796f 7572 206f 7074 696f 6e29 (at your option)\n+000559a0: 2061 6e79 206c 6174 6572 2076 6572 7369 any later versi\n+000559b0: 6f6e 2e0a 230a 2320 5468 6973 2070 726f on..#.# This pro\n+000559c0: 6772 616d 2069 7320 6469 7374 7269 6275 gram is distribu\n+000559d0: 7465 6420 696e 2074 6865 2068 6f70 6520 ted in the hope \n+000559e0: 7468 6174 2069 7420 7769 6c6c 2062 6520 that it will be \n+000559f0: 7573 6566 756c 2c0a 2320 6275 7420 5749 useful,.# but WI\n+00055a00: 5448 4f55 5420 414e 5920 5741 5252 414e THOUT ANY WARRAN\n+00055a10: 5459 3b20 7769 7468 6f75 7420 6576 656e TY; without even\n+00055a20: 2074 6865 2069 6d70 6c69 6564 2077 6172 the implied war\n+00055a30: 7261 6e74 7920 6f66 0a23 204d 4552 4348 ranty of.# MERCH\n+00055a40: 414e 5441 4249 4c49 5459 206f 7220 4649 ANTABILITY or FI\n+00055a50: 544e 4553 5320 464f 5220 4120 5041 5254 TNESS FOR A PART\n+00055a60: 4943 554c 4152 2050 5552 504f 5345 2e20 ICULAR PURPOSE. \n+00055a70: 2053 6565 2074 6865 0a23 2047 4e55 2047 See the.# GNU G\n+00055a80: 656e 6572 616c 2050 7562 6c69 6320 4c69 eneral Public Li\n+00055a90: 6365 6e73 6520 666f 7220 6d6f 7265 2064 cense for more d\n+00055aa0: 6574 6169 6c73 2e0a 230a 2320 596f 7520 etails..#.# You \n+00055ab0: 7368 6f75 6c64 2068 6176 6520 7265 6365 should have rece\n+00055ac0: 6976 6564 2061 2063 6f70 7920 6f66 2074 ived a copy of t\n+00055ad0: 6865 2047 4e55 2047 656e 6572 616c 2050 he GNU General P\n+00055ae0: 7562 6c69 6320 4c69 6365 6e73 650a 2320 ublic License.# \n+00055af0: 616c 6f6e 6720 7769 7468 2074 6869 7320 along with this \n+00055b00: 7072 6f67 7261 6d2e 2020 4966 206e 6f74 program. If not\n+00055b10: 2c20 7365 6520 3c68 7474 703a 2f2f 7777 , see ....# This f\n+00055b40: 696c 6520 6973 2072 6573 706f 6e73 6962 ile is responsib\n+00055b50: 6c65 2066 6f72 2063 7265 6174 696e 6720 le for creating \n+00055b60: 6675 6e63 7469 6f6e 7320 746f 2028 6465 functions to (de\n+00055b70: 2973 6572 6961 6c69 7a65 2050 7974 686f )serialize Pytho\n+00055b80: 6e0a 2320 6f62 6a65 6374 7320 696e 746f n.# objects into\n+00055b90: 2061 6e64 206f 7574 206f 6620 4275 734d and out of BusM\n+00055ba0: 6573 7361 6765 206f 626a 6563 7473 2e0a essage objects..\n+00055bb0: 230a 2320 4561 6368 2054 7970 6520 636f #.# Each Type co\n+00055bc0: 7272 6573 706f 6e64 7320 746f 2061 2028 rresponds to a (\n+00055bd0: 706f 7373 6962 6c79 2063 6f6d 706c 6578 possibly complex\n+00055be0: 2920 442d 4275 7320 7479 7065 2e20 2049 ) D-Bus type. I\n+00055bf0: 7420 6861 7320 6120 2e72 6561 6465 720a t has a .reader.\n+00055c00: 2320 616e 6420 6120 2e77 7269 7465 7220 # and a .writer \n+00055c10: 7072 6f70 6572 7479 2e20 2054 6865 2072 property. The r\n+00055c20: 6561 6465 7273 2074 616b 6520 6120 6d65 eaders take a me\n+00055c30: 7373 6167 6520 616e 6420 6465 7365 7269 ssage and deseri\n+00055c40: 616c 697a 6520 6120 7369 6e67 6c65 0a23 alize a single.#\n+00055c50: 2076 616c 7565 2066 726f 6d20 6974 2c20 value from it, \n+00055c60: 7265 7475 726e 696e 6720 7468 6520 7661 returning the va\n+00055c70: 6c75 653a 0a23 0a23 2020 2064 6566 2072 lue:.#.# def r\n+00055c80: 6561 6465 7228 6d65 7373 6167 653a 2042 eader(message: B\n+00055c90: 7573 4d65 7373 6167 6529 202d 3e20 6f62 usMessage) -> ob\n+00055ca0: 6a65 6374 3a0a 230a 2320 5468 6520 7772 ject:.#.# The wr\n+00055cb0: 6974 6572 7320 7461 6b65 2061 206d 6573 iters take a mes\n+00055cc0: 7361 6765 2061 6e64 2061 2076 616c 7565 sage and a value\n+00055cd0: 2c20 616e 6420 6170 7065 6e64 2074 6865 , and append the\n+00055ce0: 2076 616c 7565 2074 6f20 7468 6520 6d65 value to the me\n+00055cf0: 7373 6167 652e 0a23 0a23 2020 2064 6566 ssage..#.# def\n+00055d00: 2077 7269 7465 7228 6d65 7373 6167 653a writer(message:\n+00055d10: 2042 7573 4d65 7373 6167 652c 2076 616c BusMessage, val\n+00055d20: 7565 3a20 6f62 6a65 6374 2920 2d3e 204e ue: object) -> N\n+00055d30: 6f6e 653a 0a23 0a23 2054 6865 206e 6563 one:.#.# The nec\n+00055d40: 6573 7361 7279 2069 6e66 6f72 6d61 7469 essary informati\n+00055d50: 6f6e 2066 6f72 2074 6865 2073 7065 6369 on for the speci\n+00055d60: 6669 6320 7479 7065 206f 6620 6f62 6a65 fic type of obje\n+00055d70: 6374 2074 6f20 6265 2068 616e 646c 6564 ct to be handled\n+00055d80: 2069 730a 2320 7061 7274 206f 6620 7468 is.# part of th\n+00055d90: 6520 6675 6e63 7469 6f6e 2e20 204e 6f20 e function. No \n+00055da0: 6164 6469 7469 6f6e 616c 2069 6e66 6f72 additional infor\n+00055db0: 6d61 7469 6f6e 206e 6565 6473 2074 6f20 mation needs to \n+00055dc0: 6265 2070 726f 7669 6465 642e 0a0a 696d be provided...im\n+00055dd0: 706f 7274 2062 696e 6173 6369 690a 696d port binascii.im\n+00055de0: 706f 7274 2063 7479 7065 730a 696d 706f port ctypes.impo\n+00055df0: 7274 2066 756e 6374 6f6f 6c73 0a69 6d70 rt functools.imp\n+00055e00: 6f72 7420 696e 7370 6563 740a 696d 706f ort inspect.impo\n+00055e10: 7274 206a 736f 6e0a 696d 706f 7274 2072 rt json.import r\n+00055e20: 650a 6672 6f6d 2065 6e75 6d20 696d 706f e.from enum impo\n+00055e30: 7274 2045 6e75 6d0a 6672 6f6d 2074 7970 rt Enum.from typ\n+00055e40: 696e 6720 696d 706f 7274 2041 6e79 2c20 ing import Any, \n+00055e50: 4361 6c6c 6162 6c65 2c20 436c 6173 7356 Callable, ClassV\n+00055e60: 6172 2c20 4469 6374 2c20 4974 6572 6162 ar, Dict, Iterab\n+00055e70: 6c65 2c20 4c69 7374 2c20 4f70 7469 6f6e le, List, Option\n+00055e80: 616c 2c20 5365 7175 656e 6365 2c20 5475 al, Sequence, Tu\n+00055e90: 706c 652c 2054 7970 6556 6172 2c20 556e ple, TypeVar, Un\n+00055ea0: 696f 6e0a 0a66 726f 6d20 2e20 696d 706f ion..from . impo\n+00055eb0: 7274 206c 6962 7379 7374 656d 642c 2074 rt libsystemd, t\n+00055ec0: 7970 696e 670a 6672 6f6d 202e 7479 7069 yping.from .typi\n+00055ed0: 6e67 2069 6d70 6f72 7420 416e 6e6f 7461 ng import Annota\n+00055ee0: 7465 642c 2054 7970 6547 7561 7264 0a0a ted, TypeGuard..\n+00055ef0: 5f6f 626a 6563 745f 7061 7468 5f72 6520 _object_path_re \n+00055f00: 3d20 7265 2e63 6f6d 7069 6c65 2872 272f = re.compile(r'/\n+00055f10: 7c28 2f5b 412d 5a61 2d7a 302d 395f 5d2b |(/[A-Za-z0-9_]+\n+00055f20: 292b 2729 0a0a 0a64 6566 2069 735f 6f62 )+')...def is_ob\n+00055f30: 6a65 6374 5f70 6174 6828 6361 6e64 6964 ject_path(candid\n+00055f40: 6174 653a 2073 7472 2920 2d3e 2054 7970 ate: str) -> Typ\n+00055f50: 6547 7561 7264 5b27 4275 7354 7970 652e eGuard['BusType.\n+00055f60: 6f62 6a65 6374 7061 7468 275d 3a0a 2020 objectpath']:. \n+00055f70: 2020 7265 7475 726e 205f 6f62 6a65 6374 return _object\n+00055f80: 5f70 6174 685f 7265 2e66 756c 6c6d 6174 _path_re.fullmat\n+00055f90: 6368 2863 616e 6469 6461 7465 2920 6973 ch(candidate) is\n+00055fa0: 206e 6f74 204e 6f6e 650a 0a0a 6465 6620 not None...def \n+00055fb0: 6973 5f73 6967 6e61 7475 7265 2863 616e is_signature(can\n+00055fc0: 6469 6461 7465 3a20 7374 7229 202d 3e20 didate: str) -> \n+00055fd0: 5479 7065 4775 6172 645b 2742 7573 5479 TypeGuard['BusTy\n+00055fe0: 7065 2e73 6967 6e61 7475 7265 275d 3a0a pe.signature']:.\n+00055ff0: 2020 2020 6f66 6673 6574 203d 2030 0a0a offset = 0..\n+00056000: 2020 2020 6465 6620 6d61 7962 655f 706f def maybe_po\n+00056010: 7028 6163 6365 7074 6162 6c65 3a20 7374 p(acceptable: st\n+00056020: 7229 202d 3e20 4f70 7469 6f6e 616c 5b73 r) -> Optional[s\n+00056030: 7472 5d3a 0a20 2020 2020 2020 206e 6f6e tr]:. non\n+00056040: 6c6f 6361 6c20 6f66 6673 6574 0a20 2020 local offset. \n+00056050: 2020 2020 2063 6861 7220 3d20 6361 6e64 char = cand\n+00056060: 6964 6174 655b 6f66 6673 6574 5d0a 2020 idate[offset]. \n+00056070: 2020 2020 2020 6966 2063 6861 7220 696e if char in\n+00056080: 2061 6363 6570 7461 626c 653a 0a20 2020 acceptable:. \n+00056090: 2020 2020 2020 2020 206f 6666 7365 7420 offset \n+000560a0: 2b3d 2031 0a20 2020 2020 2020 2020 2020 += 1. \n+000560b0: 2072 6574 7572 6e20 6368 6172 0a20 2020 return char. \n+000560c0: 2020 2020 2065 6c73 653a 0a20 2020 2020 else:. \n+000560d0: 2020 2020 2020 2072 6574 7572 6e20 4e6f return No\n+000560e0: 6e65 0a0a 2020 2020 6465 6620 706f 7028 ne.. def pop(\n+000560f0: 6163 6365 7074 6162 6c65 3a20 7374 7229 acceptable: str)\n+00056100: 202d 3e20 7374 723a 0a20 2020 2020 2020 -> str:. \n+00056110: 2063 6861 7220 3d20 6d61 7962 655f 706f char = maybe_po\n+00056120: 7028 6163 6365 7074 6162 6c65 290a 2020 p(acceptable). \n+00056130: 2020 2020 2020 6173 7365 7274 2063 6861 assert cha\n+00056140: 7220 6973 206e 6f74 204e 6f6e 650a 2020 r is not None. \n+00056150: 2020 2020 2020 7265 7475 726e 2063 6861 return cha\n+00056160: 720a 0a20 2020 2064 6566 2066 696e 645f r.. def find_\n+00056170: 6e65 7874 2829 202d 3e20 4e6f 6e65 3a0a next() -> None:.\n+00056180: 2020 2020 2020 2020 6669 7273 7420 3d20 first = \n+00056190: 706f 7028 2779 626e 7169 7578 7473 6f67 pop('ybnqiuxtsog\n+000561a0: 6476 6128 2729 2020 2020 2320 7661 6c69 dva(') # vali\n+000561b0: 6420 6669 7273 7420 6368 6172 6163 7465 d first characte\n+000561c0: 7273 0a20 2020 2020 2020 2069 6620 6669 rs. if fi\n+000561d0: 7273 7420 3d3d 2027 6127 3a0a 2020 2020 rst == 'a':. \n+000561e0: 2020 2020 2020 2020 6966 206d 6179 6265 if maybe\n+000561f0: 5f70 6f70 2827 7b27 293a 2020 2020 2020 _pop('{'): \n+00056200: 2020 2020 2020 2020 2320 6469 6374 0a20 # dict. \n+00056210: 2020 2020 2020 2020 2020 2020 2020 2070 p\n+00056220: 6f70 2827 7962 6e71 6975 7874 736f 6764 op('ybnqiuxtsogd\n+00056230: 2729 2020 2020 2020 2020 2020 2023 206b ') # k\n+00056240: 6579 0a20 2020 2020 2020 2020 2020 2020 ey. \n+00056250: 2020 2066 696e 645f 6e65 7874 2829 2020 find_next() \n+00056260: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00056270: 2023 2076 616c 7565 0a20 2020 2020 2020 # value. \n+00056280: 2020 2020 2020 2020 2070 6f70 2827 7d27 pop('}'\n+00056290: 290a 2020 2020 2020 2020 2020 2020 656c ). el\n+000562a0: 7365 3a20 2020 2020 2020 2020 2020 2020 se: \n+000562b0: 2020 2020 2020 2020 2020 2020 2020 2320 # \n+000562c0: 6172 7261 790a 2020 2020 2020 2020 2020 array. \n+000562d0: 2020 2020 2020 6669 6e64 5f6e 6578 7428 find_next(\n+000562e0: 2920 2020 2020 2020 2020 2020 2020 2020 ) \n+000562f0: 2020 2020 2320 6974 656d 0a20 2020 2020 # item. \n+00056300: 2020 2065 6c69 6620 6669 7273 7420 3d3d elif first ==\n+00056310: 2027 2827 3a20 2020 2020 2020 2020 2020 '(': \n+00056320: 2020 2020 2020 2023 2073 7472 7563 7475 # structu\n+00056330: 7265 0a20 2020 2020 2020 2020 2020 2066 re. f\n+00056340: 696e 645f 6e65 7874 2829 2020 2020 2020 ind_next() \n+00056350: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00056360: 2023 2061 7420 6c65 6173 7420 6f6e 6520 # at least one \n+00056370: 6974 656d 0a20 2020 2020 2020 2020 2020 item. \n+00056380: 2077 6869 6c65 206e 6f74 206d 6179 6265 while not maybe\n+00056390: 5f70 6f70 2827 2927 293a 0a20 2020 2020 _pop(')'):. \n+000563a0: 2020 2020 2020 2020 2020 2066 696e 645f find_\n+000563b0: 6e65 7874 2829 2020 2020 2020 2020 2020 next() \n+000563c0: 2020 2020 2020 2020 2023 2061 6e64 2070 # and p\n+000563d0: 6f73 7369 626c 7920 6d6f 7265 0a0a 2020 ossibly more.. \n+000563e0: 2020 7472 793a 0a20 2020 2020 2020 2077 try:. w\n+000563f0: 6869 6c65 206f 6666 7365 7420 3c20 6c65 hile offset < le\n+00056400: 6e28 6361 6e64 6964 6174 6529 3a0a 2020 n(candidate):. \n+00056410: 2020 2020 2020 2020 2020 6669 6e64 5f6e find_n\n+00056420: 6578 7428 290a 2020 2020 2020 2020 7265 ext(). re\n+00056430: 7475 726e 2054 7275 650a 2020 2020 6578 turn True. ex\n+00056440: 6365 7074 2028 4173 7365 7274 696f 6e45 cept (AssertionE\n+00056450: 7272 6f72 2c20 496e 6465 7845 7272 6f72 rror, IndexError\n+00056460: 293a 0a20 2020 2020 2020 2072 6574 7572 ):. retur\n+00056470: 6e20 4661 6c73 650a 0a0a 6465 6620 7969 n False...def yi\n+00056480: 656c 645f 6261 7365 5f68 656c 7065 7273 eld_base_helpers\n+00056490: 2829 202d 3e20 4974 6572 6162 6c65 5b54 () -> Iterable[T\n+000564a0: 7570 6c65 5b73 7472 2c20 6f62 6a65 6374 uple[str, object\n+000564b0: 5d5d 3a0a 2020 2020 666f 7220 6d65 7468 ]]:. for meth\n+000564c0: 6f64 2069 6e20 5b27 656e 7465 725f 636f od in ['enter_co\n+000564d0: 6e74 6169 6e65 7227 2c20 2765 7869 745f ntainer', 'exit_\n+000564e0: 636f 6e74 6169 6e65 7227 2c20 276f 7065 container', 'ope\n+000564f0: 6e5f 636f 6e74 6169 6e65 7227 2c20 2763 n_container', 'c\n+00056500: 6c6f 7365 5f63 6f6e 7461 696e 6572 272c lose_container',\n+00056510: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+00056520: 2020 2020 2761 7070 656e 645f 6261 7369 'append_basi\n+00056530: 6327 2c20 2772 6561 645f 6261 7369 6327 c', 'read_basic'\n+00056540: 2c20 2761 7070 656e 645f 6172 7261 7927 , 'append_array'\n+00056550: 2c20 2772 6561 645f 6172 7261 7927 5d3a , 'read_array']:\n+00056560: 0a20 2020 2020 2020 2079 6965 6c64 206d . yield m\n+00056570: 6574 686f 642c 206c 6962 7379 7374 656d ethod, libsystem\n+00056580: 642e 6c69 6273 7973 7465 6d64 5b66 2773 d.libsystemd[f's\n+00056590: 645f 6275 735f 6d65 7373 6167 655f 7b6d d_bus_message_{m\n+000565a0: 6574 686f 647d 275d 0a0a 2020 2020 666f ethod}'].. fo\n+000565b0: 7220 6e61 6d65 2069 6e20 5b27 7369 7a65 r name in ['size\n+000565c0: 5f74 272c 2027 6368 6172 5f70 275d 3a0a _t', 'char_p']:.\n+000565d0: 2020 2020 2020 2020 696e 7374 616e 6365 instance\n+000565e0: 203d 2067 6574 6174 7472 2863 7479 7065 = getattr(ctype\n+000565f0: 732c 2066 2763 5f7b 6e61 6d65 7d27 2928 s, f'c_{name}')(\n+00056600: 290a 2020 2020 2020 2020 7969 656c 6420 ). yield \n+00056610: 6627 7b6e 616d 657d 272c 2069 6e73 7461 f'{name}', insta\n+00056620: 6e63 650a 2020 2020 2020 2020 7969 656c nce. yiel\n+00056630: 6420 6627 7b6e 616d 657d 5f72 6566 272c d f'{name}_ref',\n+00056640: 2063 7479 7065 732e 6279 7265 6628 696e ctypes.byref(in\n+00056650: 7374 616e 6365 290a 2020 2020 2020 2020 stance). \n+00056660: 7969 656c 6420 6627 7b6e 616d 657d 5f73 yield f'{name}_s\n+00056670: 6574 7465 7227 2c20 696e 7374 616e 6365 etter', instance\n+00056680: 2e5f 5f63 6c61 7373 5f5f 2e76 616c 7565 .__class__.value\n+00056690: 2e5f 5f73 6574 5f5f 0a0a 2020 2020 666f .__set__.. fo\n+000566a0: 7220 6368 6172 2069 6e20 2761 6572 7679 r char in 'aervy\n+000566b0: 273a 0a20 2020 2020 2020 2079 6965 6c64 ':. yield\n+000566c0: 2063 6861 722c 2063 7479 7065 732e 635f char, ctypes.c_\n+000566d0: 6368 6172 286f 7264 2863 6861 7229 290a char(ord(char)).\n+000566e0: 0a20 2020 2023 2068 7474 7073 3a2f 2f64 . # https://d\n+000566f0: 6f63 732e 7079 7468 6f6e 2e6f 7267 2f33 ocs.python.org/3\n+00056700: 2f63 2d61 7069 2f75 6e69 636f 6465 2e68 /c-api/unicode.h\n+00056710: 746d 6c23 632e 5079 556e 6963 6f64 655f tml#c.PyUnicode_\n+00056720: 4672 6f6d 5374 7269 6e67 0a20 2020 2074 FromString. t\n+00056730: 6f5f 6279 7465 7320 3d20 6374 7970 6573 o_bytes = ctypes\n+00056740: 2e70 7974 686f 6e61 7069 2e50 7942 7974 .pythonapi.PyByt\n+00056750: 6573 5f46 726f 6d53 7472 696e 6741 6e64 es_FromStringAnd\n+00056760: 5369 7a65 0a20 2020 2074 6f5f 6279 7465 Size. to_byte\n+00056770: 732e 7265 7374 7970 6520 3d20 6374 7970 s.restype = ctyp\n+00056780: 6573 2e70 795f 6f62 6a65 6374 0a20 2020 es.py_object. \n+00056790: 2079 6965 6c64 2027 746f 5f62 7974 6573 yield 'to_bytes\n+000567a0: 272c 2074 6f5f 6279 7465 730a 0a0a 5f62 ', to_bytes..._b\n+000567b0: 6173 655f 6865 6c70 6572 7320 3d20 6469 ase_helpers = di\n+000567c0: 6374 2879 6965 6c64 5f62 6173 655f 6865 ct(yield_base_he\n+000567d0: 6c70 6572 7328 2929 0a0a 5420 3d20 5479 lpers())..T = Ty\n+000567e0: 7065 5661 7228 2754 2729 0a0a 0a64 6566 peVar('T')...def\n+000567f0: 2063 616c 6c5f 7769 7468 5f6b 7761 7267 call_with_kwarg\n+00056800: 7328 6675 6e63 3a20 4361 6c6c 6162 6c65 s(func: Callable\n+00056810: 5b2e 2e2e 2c20 545d 2c20 6b77 6172 6773 [..., T], kwargs\n+00056820: 3a20 4469 6374 5b73 7472 2c20 416e 795d : Dict[str, Any]\n+00056830: 2920 2d3e 2054 3a0a 2020 2020 7061 7261 ) -> T:. para\n+00056840: 6d65 7465 7273 203d 2073 6574 2869 6e73 meters = set(ins\n+00056850: 7065 6374 2e73 6967 6e61 7475 7265 2866 pect.signature(f\n+00056860: 756e 6329 2e70 6172 616d 6574 6572 7329 unc).parameters)\n+00056870: 0a20 2020 2072 6574 7572 6e20 6675 6e63 . return func\n+00056880: 282a 2a7b 6b65 793a 2076 616c 7565 2066 (**{key: value f\n+00056890: 6f72 206b 6579 2c20 7661 6c75 6520 696e or key, value in\n+000568a0: 206b 7761 7267 732e 6974 656d 7328 2920 kwargs.items() \n+000568b0: 6966 206b 6579 2069 6e20 7061 7261 6d65 if key in parame\n+000568c0: 7465 7273 7d29 0a0a 0a63 6c61 7373 2054 ters})...class T\n+000568d0: 7970 653a 0a20 2020 205f 6361 6368 653a ype:. _cache:\n+000568e0: 2043 6c61 7373 5661 725b 4469 6374 5b54 ClassVar[Dict[T\n+000568f0: 7570 6c65 5b74 7970 652c 2054 7570 6c65 uple[type, Tuple\n+00056900: 5b6f 626a 6563 742c 202e 2e2e 5d5d 2c20 [object, ...]], \n+00056910: 2754 7970 6527 5d5d 203d 207b 7d0a 0a20 'Type']] = {}.. \n+00056920: 2020 205f 5f73 6c6f 7473 5f5f 203d 2027 __slots__ = '\n+00056930: 7479 7065 7374 7269 6e67 272c 2027 6279 typestring', 'by\n+00056940: 7465 735f 7479 7065 7374 7269 6e67 272c tes_typestring',\n+00056950: 2027 7772 6974 6572 272c 2027 7265 6164 'writer', 'read\n+00056960: 6572 270a 2020 2020 7479 7065 7374 7269 er'. typestri\n+00056970: 6e67 3a20 7374 720a 2020 2020 6279 7465 ng: str. byte\n+00056980: 735f 7479 7065 7374 7269 6e67 3a20 6279 s_typestring: by\n+00056990: 7465 730a 2020 2020 7265 6164 6572 3a20 tes. reader: \n+000569a0: 4361 6c6c 6162 6c65 5b5b 6c69 6273 7973 Callable[[libsys\n+000569b0: 7465 6d64 2e73 645f 6275 735f 6d65 7373 temd.sd_bus_mess\n+000569c0: 6167 655d 2c20 6f62 6a65 6374 5d0a 2020 age], object]. \n+000569d0: 2020 7772 6974 6572 3a20 4361 6c6c 6162 writer: Callab\n+000569e0: 6c65 5b5b 6c69 6273 7973 7465 6d64 2e73 le[[libsystemd.s\n+000569f0: 645f 6275 735f 6d65 7373 6167 652c 206f d_bus_message, o\n+00056a00: 626a 6563 745d 2c20 4e6f 6e65 5d0a 0a20 bject], None].. \n+00056a10: 2020 2064 6566 205f 5f6e 6577 5f5f 2863 def __new__(c\n+00056a20: 6c73 2c20 2a61 7267 733a 2041 6e79 2920 ls, *args: Any) \n+00056a30: 2d3e 2027 5479 7065 273a 0a20 2020 2020 -> 'Type':. \n+00056a40: 2020 2069 6e73 7461 6e63 6520 3d20 5479 instance = Ty\n+00056a50: 7065 2e5f 6361 6368 652e 6765 7428 2863 pe._cache.get((c\n+00056a60: 6c73 2c20 6172 6773 2929 0a20 2020 2020 ls, args)). \n+00056a70: 2020 2069 6620 696e 7374 616e 6365 2069 if instance i\n+00056a80: 7320 4e6f 6e65 3a0a 2020 2020 2020 2020 s None:. \n+00056a90: 2020 2020 696e 7374 616e 6365 203d 206f instance = o\n+00056aa0: 626a 6563 742e 5f5f 6e65 775f 5f28 636c bject.__new__(cl\n+00056ab0: 7329 0a20 2020 2020 2020 2020 2020 2054 s). T\n+00056ac0: 7970 652e 5f63 6163 6865 5b28 636c 732c ype._cache[(cls,\n+00056ad0: 2061 7267 7329 5d20 3d20 696e 7374 616e args)] = instan\n+00056ae0: 6365 0a20 2020 2020 2020 2072 6574 7572 ce. retur\n+00056af0: 6e20 696e 7374 616e 6365 0a0a 2020 2020 n instance.. \n+00056b00: 6465 6620 5f5f 696e 6974 5f5f 2873 656c def __init__(sel\n+00056b10: 662c 2074 7970 6573 7472 696e 673a 2073 f, typestring: s\n+00056b20: 7472 2c20 2a2a 6b77 6172 6773 3a20 416e tr, **kwargs: An\n+00056b30: 7929 3a0a 2020 2020 2020 2020 7365 6c66 y):. self\n+00056b40: 2e74 7970 6573 7472 696e 6720 3d20 7479 .typestring = ty\n+00056b50: 7065 7374 7269 6e67 0a20 2020 2020 2020 pestring. \n+00056b60: 2073 656c 662e 6279 7465 735f 7479 7065 self.bytes_type\n+00056b70: 7374 7269 6e67 203d 2074 7970 6573 7472 string = typestr\n+00056b80: 696e 672e 656e 636f 6465 2827 6173 6369 ing.encode('asci\n+00056b90: 6927 290a 0a20 2020 2020 2020 206b 7761 i').. kwa\n+00056ba0: 7267 7320 3d20 6469 6374 285f 6261 7365 rgs = dict(_base\n+00056bb0: 5f68 656c 7065 7273 2c20 2a2a 6b77 6172 _helpers, **kwar\n+00056bc0: 6773 290a 2020 2020 2020 2020 7365 6c66 gs). self\n+00056bd0: 2e77 7269 7465 7220 3d20 6361 6c6c 5f77 .writer = call_w\n+00056be0: 6974 685f 6b77 6172 6773 2873 656c 662e ith_kwargs(self.\n+00056bf0: 6765 745f 7772 6974 6572 2c20 6b77 6172 get_writer, kwar\n+00056c00: 6773 290a 2020 2020 2020 2020 7365 6c66 gs). self\n+00056c10: 2e72 6561 6465 7220 3d20 6361 6c6c 5f77 .reader = call_w\n+00056c20: 6974 685f 6b77 6172 6773 2873 656c 662e ith_kwargs(self.\n+00056c30: 6765 745f 7265 6164 6572 2c20 6b77 6172 get_reader, kwar\n+00056c40: 6773 290a 0a20 2020 2064 6566 205f 5f72 gs).. def __r\n+00056c50: 6570 725f 5f28 7365 6c66 2920 2d3e 2073 epr__(self) -> s\n+00056c60: 7472 3a0a 2020 2020 2020 2020 7265 7475 tr:. retu\n+00056c70: 726e 2066 227b 7365 6c66 2e5f 5f63 6c61 rn f\"{self.__cla\n+00056c80: 7373 5f5f 2e5f 5f6e 616d 655f 5f7d 2827 ss__.__name__}('\n+00056c90: 7b73 656c 662e 7479 7065 7374 7269 6e67 {self.typestring\n+00056ca0: 7d27 2922 0a0a 2020 2020 6465 6620 6765 }')\".. def ge\n+00056cb0: 745f 7772 6974 6572 2873 656c 662c 202a t_writer(self, *\n+00056cc0: 2a6b 7761 7267 733a 206f 626a 6563 7429 *kwargs: object)\n+00056cd0: 202d 3e20 4361 6c6c 6162 6c65 5b5b 6f62 -> Callable[[ob\n+00056ce0: 6a65 6374 2c20 6f62 6a65 6374 5d2c 204e ject, object], N\n+00056cf0: 6f6e 655d 3a0a 2020 2020 2020 2020 7261 one]:. ra\n+00056d00: 6973 6520 4e6f 7449 6d70 6c65 6d65 6e74 ise NotImplement\n+00056d10: 6564 4572 726f 720a 0a20 2020 2064 6566 edError.. def\n+00056d20: 2067 6574 5f72 6561 6465 7228 7365 6c66 get_reader(self\n+00056d30: 2c20 2a2a 6b77 6172 6773 3a20 6f62 6a65 , **kwargs: obje\n+00056d40: 6374 2920 2d3e 2043 616c 6c61 626c 655b ct) -> Callable[\n+00056d50: 5b6f 626a 6563 745d 2c20 6f62 6a65 6374 [object], object\n+00056d60: 5d3a 0a20 2020 2020 2020 2072 6169 7365 ]:. raise\n+00056d70: 204e 6f74 496d 706c 656d 656e 7465 6445 NotImplementedE\n+00056d80: 7272 6f72 0a0a 0a63 6c61 7373 2042 6173 rror...class Bas\n+00056d90: 6963 5479 7065 2854 7970 6529 3a0a 2020 icType(Type):. \n+00056da0: 2020 5f5f 736c 6f74 735f 5f20 3d20 2829 __slots__ = ()\n+00056db0: 0a0a 2020 2020 6465 6620 5f5f 696e 6974 .. def __init\n+00056dc0: 5f5f 2873 656c 662c 2074 7970 6573 7472 __(self, typestr\n+00056dd0: 696e 673a 2073 7472 2c20 6374 7970 652c ing: str, ctype,\n+00056de0: 2067 6574 5f77 7261 7070 6572 3d4e 6f6e get_wrapper=Non\n+00056df0: 652c 202a 2a6b 7761 7267 7329 3a0a 2020 e, **kwargs):. \n+00056e00: 2020 2020 2020 7661 7269 6162 6c65 203d variable =\n+00056e10: 2063 7479 7065 2829 2020 2320 4e42 3a20 ctype() # NB: \n+00056e20: 6e6f 7420 7468 7265 6164 2d73 6166 650a not thread-safe.\n+00056e30: 2020 2020 2020 2020 7375 7065 7228 292e super().\n+00056e40: 5f5f 696e 6974 5f5f 2874 7970 6573 7472 __init__(typestr\n+00056e50: 696e 672c 2063 7479 7065 3d63 7479 7065 ing, ctype=ctype\n+00056e60: 2c20 7479 7065 5f63 6f6e 7374 616e 743d , type_constant=\n+00056e70: 6374 7970 6573 2e63 5f63 6861 7228 6f72 ctypes.c_char(or\n+00056e80: 6428 7479 7065 7374 7269 6e67 2929 2c0a d(typestring)),.\n+00056e90: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00056ea0: 2020 2020 2020 2020 2067 6574 7465 723d getter=\n+00056eb0: 6765 745f 7772 6170 7065 7220 6f72 2063 get_wrapper or c\n+00056ec0: 7479 7065 2e76 616c 7565 2e5f 5f67 6574 type.value.__get\n+00056ed0: 5f5f 2c20 7365 7474 6572 3d63 7479 7065 __, setter=ctype\n+00056ee0: 2e76 616c 7565 2e5f 5f73 6574 5f5f 2c0a .value.__set__,.\n+00056ef0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00056f00: 2020 2020 2020 2020 2076 6172 6961 626c variabl\n+00056f10: 653d 7661 7269 6162 6c65 2c20 7265 6665 e=variable, refe\n+00056f20: 7265 6e63 653d 6374 7970 6573 2e62 7972 rence=ctypes.byr\n+00056f30: 6566 2876 6172 6961 626c 6529 2c20 2a2a ef(variable), **\n+00056f40: 6b77 6172 6773 290a 0a20 2020 2064 6566 kwargs).. def\n+00056f50: 2067 6574 5f72 6561 6465 7228 7365 6c66 get_reader(self\n+00056f60: 2c20 7265 6164 5f62 6173 6963 2c20 7479 , read_basic, ty\n+00056f70: 7065 5f63 6f6e 7374 616e 742c 2076 6172 pe_constant, var\n+00056f80: 6961 626c 652c 2072 6566 6572 656e 6365 iable, reference\n+00056f90: 2c20 6765 7474 6572 293a 0a20 2020 2020 , getter):. \n+00056fa0: 2020 2064 6566 2062 6173 6963 5f72 6561 def basic_rea\n+00056fb0: 6465 7228 6d65 7373 6167 653a 206c 6962 der(message: lib\n+00056fc0: 7379 7374 656d 642e 7364 5f62 7573 5f6d systemd.sd_bus_m\n+00056fd0: 6573 7361 6765 2920 2d3e 206f 626a 6563 essage) -> objec\n+00056fe0: 743a 0a20 2020 2020 2020 2020 2020 2069 t:. i\n+00056ff0: 6620 7265 6164 5f62 6173 6963 286d 6573 f read_basic(mes\n+00057000: 7361 6765 2c20 7479 7065 5f63 6f6e 7374 sage, type_const\n+00057010: 616e 742c 2072 6566 6572 656e 6365 2920 ant, reference) \n+00057020: 3c3d 2030 3a0a 2020 2020 2020 2020 2020 <= 0:. \n+00057030: 2020 2020 2020 7261 6973 6520 5374 6f70 raise Stop\n+00057040: 4974 6572 6174 696f 6e0a 2020 2020 2020 Iteration. \n+00057050: 2020 2020 2020 7265 7475 726e 2067 6574 return get\n+00057060: 7465 7228 7661 7269 6162 6c65 290a 2020 ter(variable). \n+00057070: 2020 2020 2020 7265 7475 726e 2062 6173 return bas\n+00057080: 6963 5f72 6561 6465 720a 0a0a 636c 6173 ic_reader...clas\n+00057090: 7320 4669 7865 6454 7970 6528 4261 7369 s FixedType(Basi\n+000570a0: 6354 7970 6529 3a0a 2020 2020 5f5f 736c cType):. __sl\n+000570b0: 6f74 735f 5f20 3d20 2829 0a0a 2020 2020 ots__ = ().. \n+000570c0: 6465 6620 6765 745f 7772 6974 6572 2873 def get_writer(s\n+000570d0: 656c 662c 2061 7070 656e 645f 6261 7369 elf, append_basi\n+000570e0: 632c 2074 7970 655f 636f 6e73 7461 6e74 c, type_constant\n+000570f0: 2c20 7661 7269 6162 6c65 2c20 7265 6665 , variable, refe\n+00057100: 7265 6e63 652c 2073 6574 7465 722c 2067 rence, setter, g\n+00057110: 6574 7465 7229 3a0a 2020 2020 2020 2020 etter):. \n+00057120: 6465 6620 6669 7865 645f 7772 6974 6572 def fixed_writer\n+00057130: 286d 6573 7361 6765 3a20 6c69 6273 7973 (message: libsys\n+00057140: 7465 6d64 2e73 645f 6275 735f 6d65 7373 temd.sd_bus_mess\n+00057150: 6167 652c 2076 616c 7565 3a20 6f62 6a65 age, value: obje\n+00057160: 6374 2920 2d3e 204e 6f6e 653a 0a20 2020 ct) -> None:. \n+00057170: 2020 2020 2020 2020 2073 6574 7465 7228 setter(\n+00057180: 7661 7269 6162 6c65 2c20 7661 6c75 6529 variable, value)\n+00057190: 0a20 2020 2020 2020 2020 2020 2069 6620 . if \n+000571a0: 6765 7474 6572 2876 6172 6961 626c 6529 getter(variable)\n+000571b0: 2021 3d20 7661 6c75 653a 0a20 2020 2020 != value:. \n+000571c0: 2020 2020 2020 2020 2020 2072 6169 7365 raise\n+000571d0: 2054 7970 6545 7272 6f72 2866 2243 616e TypeError(f\"Can\n+000571e0: 6e6f 7420 7265 7072 6573 656e 7420 7661 not represent va\n+000571f0: 6c75 6520 7b76 616c 7565 7d20 7769 7468 lue {value} with\n+00057200: 2074 7970 6520 277b 7365 6c66 2e74 7970 type '{self.typ\n+00057210: 6573 7472 696e 677d 2722 290a 2020 2020 estring}'\"). \n+00057220: 2020 2020 2020 2020 6170 7065 6e64 5f62 append_b\n+00057230: 6173 6963 286d 6573 7361 6765 2c20 7479 asic(message, ty\n+00057240: 7065 5f63 6f6e 7374 616e 742c 2072 6566 pe_constant, ref\n+00057250: 6572 656e 6365 290a 2020 2020 2020 2020 erence). \n+00057260: 7265 7475 726e 2066 6978 6564 5f77 7269 return fixed_wri\n+00057270: 7465 720a 0a0a 636c 6173 7320 5374 7269 ter...class Stri\n+00057280: 6e67 4c69 6b65 5479 7065 2842 6173 6963 ngLikeType(Basic\n+00057290: 5479 7065 293a 0a20 2020 205f 5f73 6c6f Type):. __slo\n+000572a0: 7473 5f5f 203d 2028 290a 0a20 2020 2040 ts__ = ().. @\n+000572b0: 7374 6174 6963 6d65 7468 6f64 0a20 2020 staticmethod. \n+000572c0: 2064 6566 2067 6574 5f67 7561 7264 6564 def get_guarded\n+000572d0: 5f63 6f6e 7665 7273 696f 6e28 7479 7065 _conversion(type\n+000572e0: 7374 7269 6e67 3a20 7374 722c 2067 7561 string: str, gua\n+000572f0: 7264 3a20 4361 6c6c 6162 6c65 5b5b 7374 rd: Callable[[st\n+00057300: 725d 2c20 626f 6f6c 5d29 202d 3e20 4361 r], bool]) -> Ca\n+00057310: 6c6c 6162 6c65 5b5b 6f62 6a65 6374 5d2c llable[[object],\n+00057320: 2062 7974 6573 5d3a 0a20 2020 2020 2020 bytes]:. \n+00057330: 2064 6566 2063 6f6e 7665 7274 2863 616e def convert(can\n+00057340: 6469 6461 7465 3a20 6f62 6a65 6374 2920 didate: object) \n+00057350: 2d3e 2062 7974 6573 3a0a 2020 2020 2020 -> bytes:. \n+00057360: 2020 2020 2020 6966 206e 6f74 2069 7369 if not isi\n+00057370: 6e73 7461 6e63 6528 6361 6e64 6964 6174 nstance(candidat\n+00057380: 652c 2073 7472 293a 0a20 2020 2020 2020 e, str):. \n+00057390: 2020 2020 2020 2020 2072 6169 7365 2054 raise T\n+000573a0: 7970 6545 7272 6f72 2866 2227 7b74 7970 ypeError(f\"'{typ\n+000573b0: 6573 7472 696e 677d 2720 656e 636f 6465 estring}' encode\n+000573c0: 7320 2773 7472 272c 206e 6f74 2027 7b63 s 'str', not '{c\n+000573d0: 616e 6469 6461 7465 2e5f 5f63 6c61 7373 andidate.__class\n+000573e0: 5f5f 2e5f 5f6e 616d 655f 5f7d 2722 290a __.__name__}'\").\n+000573f0: 2020 2020 2020 2020 2020 2020 6966 206e if n\n+00057400: 6f74 2067 7561 7264 2863 616e 6469 6461 ot guard(candida\n+00057410: 7465 293a 0a20 2020 2020 2020 2020 2020 te):. \n+00057420: 2020 2020 2072 6169 7365 2056 616c 7565 raise Value\n+00057430: 4572 726f 7228 6622 496e 7661 6c69 6420 Error(f\"Invalid \n+00057440: 7661 6c75 6520 7072 6f76 6964 6564 2066 value provided f\n+00057450: 6f72 2074 7970 6520 277b 7479 7065 7374 or type '{typest\n+00057460: 7269 6e67 7d27 2229 0a20 2020 2020 2020 ring}'\"). \n+00057470: 2020 2020 2072 6574 7572 6e20 7374 722e return str.\n+00057480: 656e 636f 6465 2863 616e 6469 6461 7465 encode(candidate\n+00057490: 290a 2020 2020 2020 2020 7265 7475 726e ). return\n+000574a0: 2063 6f6e 7665 7274 0a0a 2020 2020 6465 convert.. de\n+000574b0: 6620 5f5f 696e 6974 5f5f 2873 656c 662c f __init__(self,\n+000574c0: 2074 7970 6573 7472 696e 673a 2073 7472 typestring: str\n+000574d0: 2c20 6775 6172 643a 204f 7074 696f 6e61 , guard: Optiona\n+000574e0: 6c5b 4361 6c6c 6162 6c65 5b5b 7374 725d l[Callable[[str]\n+000574f0: 2c20 626f 6f6c 5d5d 203d 204e 6f6e 6529 , bool]] = None)\n+00057500: 3a0a 2020 2020 2020 2020 2320 6874 7470 :. # http\n+00057510: 733a 2f2f 646f 6373 2e70 7974 686f 6e2e s://docs.python.\n+00057520: 6f72 672f 332f 632d 6170 692f 756e 6963 org/3/c-api/unic\n+00057530: 6f64 652e 6874 6d6c 2363 2e50 7955 6e69 ode.html#c.PyUni\n+00057540: 636f 6465 5f46 726f 6d53 7472 696e 670a code_FromString.\n+00057550: 2020 2020 2020 2020 746f 5f75 6e69 636f to_unico\n+00057560: 6465 203d 2063 7479 7065 732e 7079 7468 de = ctypes.pyth\n+00057570: 6f6e 6170 692e 5079 556e 6963 6f64 655f onapi.PyUnicode_\n+00057580: 4672 6f6d 5374 7269 6e67 0a20 2020 2020 FromString. \n+00057590: 2020 2074 6f5f 756e 6963 6f64 652e 7265 to_unicode.re\n+000575a0: 7374 7970 6520 3d20 6374 7970 6573 2e70 stype = ctypes.p\n+000575b0: 795f 6f62 6a65 6374 0a0a 2020 2020 2020 y_object.. \n+000575c0: 2020 6966 2067 7561 7264 2069 7320 6e6f if guard is no\n+000575d0: 7420 4e6f 6e65 3a0a 2020 2020 2020 2020 t None:. \n+000575e0: 2020 2020 636f 6e76 6572 7420 3d20 5374 convert = St\n+000575f0: 7269 6e67 4c69 6b65 5479 7065 2e67 6574 ringLikeType.get\n+00057600: 5f67 7561 7264 6564 5f63 6f6e 7665 7273 _guarded_convers\n+00057610: 696f 6e28 7479 7065 7374 7269 6e67 2c20 ion(typestring, \n+00057620: 6775 6172 6429 0a20 2020 2020 2020 2065 guard). e\n+00057630: 6c73 653a 0a20 2020 2020 2020 2020 2020 lse:. \n+00057640: 2063 6f6e 7665 7274 203d 2073 7472 2e65 convert = str.e\n+00057650: 6e63 6f64 6520 2023 2074 7970 653a 2069 ncode # type: i\n+00057660: 676e 6f72 655b 6173 7369 676e 6d65 6e74 gnore[assignment\n+00057670: 5d20 2320 6361 6e20 7468 726f 7720 5479 ] # can throw Ty\n+00057680: 7065 4572 726f 7220 6f6e 2063 616c 6c0a peError on call.\n+00057690: 0a20 2020 2020 2020 2073 7570 6572 2829 . super()\n+000576a0: 2e5f 5f69 6e69 745f 5f28 7479 7065 7374 .__init__(typest\n+000576b0: 7269 6e67 2c20 6374 7970 6573 2e63 5f63 ring, ctypes.c_c\n+000576c0: 6861 725f 702c 2074 6f5f 756e 6963 6f64 har_p, to_unicod\n+000576d0: 652c 2063 6f6e 7665 7274 3d63 6f6e 7665 e, convert=conve\n+000576e0: 7274 290a 0a20 2020 2064 6566 2067 6574 rt).. def get\n+000576f0: 5f77 7269 7465 7228 7365 6c66 2c20 6170 _writer(self, ap\n+00057700: 7065 6e64 5f62 6173 6963 2c20 7479 7065 pend_basic, type\n+00057710: 5f63 6f6e 7374 616e 742c 2063 6f6e 7665 _constant, conve\n+00057720: 7274 293a 0a20 2020 2020 2020 2064 6566 rt):. def\n+00057730: 2073 7472 696e 675f 7772 6974 6572 286d string_writer(m\n+00057740: 6573 7361 6765 3a20 6c69 6273 7973 7465 essage: libsyste\n+00057750: 6d64 2e73 645f 6275 735f 6d65 7373 6167 md.sd_bus_messag\n+00057760: 652c 2076 616c 7565 3a20 6f62 6a65 6374 e, value: object\n+00057770: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n+00057780: 2020 2020 2020 2061 7070 656e 645f 6261 append_ba\n+00057790: 7369 6328 6d65 7373 6167 652c 2074 7970 sic(message, typ\n+000577a0: 655f 636f 6e73 7461 6e74 2c20 636f 6e76 e_constant, conv\n+000577b0: 6572 7428 7661 6c75 6529 290a 2020 2020 ert(value)). \n+000577c0: 2020 2020 7265 7475 726e 2073 7472 696e return strin\n+000577d0: 675f 7772 6974 6572 0a0a 0a63 6c61 7373 g_writer...class\n+000577e0: 2042 7974 6573 7472 696e 6754 7970 6528 BytestringType(\n+000577f0: 5479 7065 293a 0a20 2020 205f 5f73 6c6f Type):. __slo\n+00057800: 7473 5f5f 203d 2028 290a 0a20 2020 2064 ts__ = ().. d\n+00057810: 6566 2067 6574 5f77 7269 7465 7228 7365 ef get_writer(se\n+00057820: 6c66 2c20 6170 7065 6e64 5f61 7272 6179 lf, append_array\n+00057830: 2c20 792c 2073 697a 655f 745f 7365 7474 , y, size_t_sett\n+00057840: 6572 2c20 7369 7a65 5f74 293a 0a20 2020 er, size_t):. \n+00057850: 2020 2020 2064 6566 2062 7974 6573 5f77 def bytes_w\n+00057860: 7269 7465 7228 6d65 7373 6167 653a 206c riter(message: l\n+00057870: 6962 7379 7374 656d 642e 7364 5f62 7573 ibsystemd.sd_bus\n+00057880: 5f6d 6573 7361 6765 2c20 7661 6c75 653a _message, value:\n+00057890: 206f 626a 6563 7429 202d 3e20 4e6f 6e65 object) -> None\n+000578a0: 3a0a 2020 2020 2020 2020 2020 2020 6966 :. if\n+000578b0: 206e 6f74 2069 7369 6e73 7461 6e63 6528 not isinstance(\n+000578c0: 7661 6c75 652c 2062 7974 6573 293a 0a20 value, bytes):. \n+000578d0: 2020 2020 2020 2020 2020 2020 2020 2069 i\n+000578e0: 6620 6973 696e 7374 616e 6365 2876 616c f isinstance(val\n+000578f0: 7565 2c20 7374 7229 3a0a 2020 2020 2020 ue, str):. \n+00057900: 2020 2020 2020 2020 2020 2020 2020 7472 tr\n+00057910: 793a 0a20 2020 2020 2020 2020 2020 2020 y:. \n+00057920: 2020 2020 2020 2020 2020 2076 616c 7565 value\n+00057930: 203d 2062 696e 6173 6369 692e 6132 625f = binascii.a2b_\n+00057940: 6261 7365 3634 2876 616c 7565 2e65 6e63 base64(value.enc\n+00057950: 6f64 6528 2761 7363 6969 2729 2920 2023 ode('ascii')) #\n+00057960: 206f 7220 6465 636f 6465 2062 6173 6536 or decode base6\n+00057970: 340a 2020 2020 2020 2020 2020 2020 2020 4. \n+00057980: 2020 2020 2020 6578 6365 7074 2062 696e except bin\n+00057990: 6173 6369 692e 4572 726f 7220 6173 2065 ascii.Error as e\n+000579a0: 7863 3a0a 2020 2020 2020 2020 2020 2020 xc:. \n+000579b0: 2020 2020 2020 2020 2020 2020 7261 6973 rais\n+000579c0: 6520 5661 6c75 6545 7272 6f72 2822 2761 e ValueError(\"'a\n+000579d0: 7927 2063 616e 6e6f 7420 656e 636f 6465 y' cannot encode\n+000579e0: 2069 6e76 616c 6964 2062 6173 6536 3420 invalid base64 \n+000579f0: 7374 7269 6e67 2229 2066 726f 6d20 6578 string\") from ex\n+00057a00: 630a 2020 2020 2020 2020 2020 2020 2020 c. \n+00057a10: 2020 656c 6966 2069 7369 6e73 7461 6e63 elif isinstanc\n+00057a20: 6528 7661 6c75 652c 2028 6d65 6d6f 7279 e(value, (memory\n+00057a30: 7669 6577 2c20 6279 7465 6172 7261 7929 view, bytearray)\n+00057a40: 293a 0a20 2020 2020 2020 2020 2020 2020 ):. \n+00057a50: 2020 2020 2020 2076 616c 7565 203d 2062 value = b\n+00057a60: 7974 6573 2876 616c 7565 290a 2020 2020 ytes(value). \n+00057a70: 2020 2020 2020 2020 2020 2020 656c 7365 else\n+00057a80: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n+00057a90: 2020 2020 2020 7261 6973 6520 5479 7065 raise Type\n+00057aa0: 4572 726f 7228 2227 6179 2720 6361 6e20 Error(\"'ay' can \n+00057ab0: 6f6e 6c79 2065 6e63 6f64 6520 6279 7465 only encode byte\n+00057ac0: 732d 6c69 6b65 206f 7220 6261 7365 3634 s-like or base64\n+00057ad0: 2073 7472 696e 6720 6f62 6a65 6374 732c string objects,\n+00057ae0: 2022 0a20 2020 2020 2020 2020 2020 2020 \". \n+00057af0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00057b00: 2020 2020 2020 2066 226e 6f74 2027 7b76 f\"not '{v\n+00057b10: 616c 7565 2e5f 5f63 6c61 7373 5f5f 2e5f alue.__class__._\n+00057b20: 5f6e 616d 655f 5f7d 272e 2229 0a20 2020 _name__}'.\"). \n+00057b30: 2020 2020 2020 2020 2073 697a 655f 745f size_t_\n+00057b40: 7365 7474 6572 2873 697a 655f 742c 206c setter(size_t, l\n+00057b50: 656e 2876 616c 7565 2929 0a20 2020 2020 en(value)). \n+00057b60: 2020 2020 2020 2061 7070 656e 645f 6172 append_ar\n+00057b70: 7261 7928 6d65 7373 6167 652c 2079 2c20 ray(message, y, \n+00057b80: 7661 6c75 652c 2073 697a 655f 7429 0a20 value, size_t). \n+00057b90: 2020 2020 2020 2072 6574 7572 6e20 6279 return by\n+00057ba0: 7465 735f 7772 6974 6572 0a0a 2020 2020 tes_writer.. \n+00057bb0: 6465 6620 6765 745f 7265 6164 6572 2873 def get_reader(s\n+00057bc0: 656c 662c 2072 6561 645f 6172 7261 792c elf, read_array,\n+00057bd0: 2079 2c20 746f 5f62 7974 6573 2c20 6368 y, to_bytes, ch\n+00057be0: 6172 5f70 2c20 6368 6172 5f70 5f72 6566 ar_p, char_p_ref\n+00057bf0: 2c20 7369 7a65 5f74 2c20 7369 7a65 5f74 , size_t, size_t\n+00057c00: 5f72 6566 293a 0a20 2020 2020 2020 2064 _ref):. d\n+00057c10: 6566 2062 7974 6573 5f72 6561 6465 7228 ef bytes_reader(\n+00057c20: 6d65 7373 6167 6529 3a0a 2020 2020 2020 message):. \n+00057c30: 2020 2020 2020 6966 2072 6561 645f 6172 if read_ar\n+00057c40: 7261 7928 6d65 7373 6167 652c 2079 2c20 ray(message, y, \n+00057c50: 6368 6172 5f70 5f72 6566 2c20 7369 7a65 char_p_ref, size\n+00057c60: 5f74 5f72 6566 2920 3c3d 2030 3a0a 2020 _t_ref) <= 0:. \n+00057c70: 2020 2020 2020 2020 2020 2020 2020 7261 ra\n+00057c80: 6973 6520 5374 6f70 4974 6572 6174 696f ise StopIteratio\n+00057c90: 6e0a 2020 2020 2020 2020 2020 2020 7265 n. re\n+00057ca0: 7475 726e 2074 6f5f 6279 7465 7328 6368 turn to_bytes(ch\n+00057cb0: 6172 5f70 2c20 7369 7a65 5f74 290a 2020 ar_p, size_t). \n+00057cc0: 2020 2020 2020 7265 7475 726e 2062 7974 return byt\n+00057cd0: 6573 5f72 6561 6465 720a 0a0a 636c 6173 es_reader...clas\n+00057ce0: 7320 436f 6e74 6169 6e65 7254 7970 6528 s ContainerType(\n+00057cf0: 5479 7065 293a 0a20 2020 205f 7479 7065 Type):. _type\n+00057d00: 7374 7269 6e67 5f74 656d 706c 6174 653a string_template:\n+00057d10: 2043 6c61 7373 5661 725b 7374 725d 0a20 ClassVar[str]. \n+00057d20: 2020 205f 5f73 6c6f 7473 5f5f 203d 2027 __slots__ = '\n+00057d30: 6974 656d 5f74 7970 6573 270a 2020 2020 item_types'. \n+00057d40: 6974 656d 5f74 7970 6573 3a20 5365 7175 item_types: Sequ\n+00057d50: 656e 6365 5b54 7970 655d 0a0a 2020 2020 ence[Type].. \n+00057d60: 6465 6620 5f5f 696e 6974 5f5f 2873 656c def __init__(sel\n+00057d70: 662c 202a 6974 656d 5f74 7970 6573 3a20 f, *item_types: \n+00057d80: 5479 7065 2c20 2a2a 6b77 6172 6773 3a20 Type, **kwargs: \n+00057d90: 416e 7929 3a0a 2020 2020 2020 2020 6173 Any):. as\n+00057da0: 7365 7274 206c 656e 2869 7465 6d5f 7479 sert len(item_ty\n+00057db0: 7065 7329 203e 2030 0a20 2020 2020 2020 pes) > 0. \n+00057dc0: 2069 7465 6d5f 7479 7065 7374 7269 6e67 item_typestring\n+00057dd0: 7320 3d20 2727 2e6a 6f69 6e28 6974 656d s = ''.join(item\n+00057de0: 2e74 7970 6573 7472 696e 6720 666f 7220 .typestring for \n+00057df0: 6974 656d 2069 6e20 6974 656d 5f74 7970 item in item_typ\n+00057e00: 6573 290a 2020 2020 2020 2020 7365 6c66 es). self\n+00057e10: 2e69 7465 6d5f 7479 7065 7320 3d20 6974 .item_types = it\n+00057e20: 656d 5f74 7970 6573 0a20 2020 2020 2020 em_types. \n+00057e30: 2073 7570 6572 2829 2e5f 5f69 6e69 745f super().__init_\n+00057e40: 5f28 7365 6c66 2e5f 7479 7065 7374 7269 _(self._typestri\n+00057e50: 6e67 5f74 656d 706c 6174 652e 7265 706c ng_template.repl\n+00057e60: 6163 6528 275f 272c 2069 7465 6d5f 7479 ace('_', item_ty\n+00057e70: 7065 7374 7269 6e67 7329 2c0a 2020 2020 pestrings),. \n+00057e80: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00057e90: 2020 2020 2074 7970 655f 636f 6e74 656e type_conten\n+00057ea0: 7473 3d63 7479 7065 732e 635f 6368 6172 ts=ctypes.c_char\n+00057eb0: 5f70 2869 7465 6d5f 7479 7065 7374 7269 _p(item_typestri\n+00057ec0: 6e67 732e 656e 636f 6465 2827 6173 6369 ngs.encode('asci\n+00057ed0: 6927 2929 2c0a 2020 2020 2020 2020 2020 i')),. \n+00057ee0: 2020 2020 2020 2020 2020 2020 2020 202a *\n+00057ef0: 2a6b 7761 7267 7329 0a0a 0a63 6c61 7373 *kwargs)...class\n+00057f00: 2041 7272 6179 5479 7065 2843 6f6e 7461 ArrayType(Conta\n+00057f10: 696e 6572 5479 7065 293a 0a20 2020 205f inerType):. _\n+00057f20: 7479 7065 7374 7269 6e67 5f74 656d 706c typestring_templ\n+00057f30: 6174 6520 3d20 2761 5f27 0a20 2020 205f ate = 'a_'. _\n+00057f40: 5f73 6c6f 7473 5f5f 203d 2028 290a 0a20 _slots__ = ().. \n+00057f50: 2020 2064 6566 205f 5f69 6e69 745f 5f28 def __init__(\n+00057f60: 7365 6c66 2c20 6974 656d 5f74 7970 653a self, item_type:\n+00057f70: 2054 7970 6529 3a0a 2020 2020 2020 2020 Type):. \n+00057f80: 7375 7065 7228 292e 5f5f 696e 6974 5f5f super().__init__\n+00057f90: 2869 7465 6d5f 7479 7065 2c0a 2020 2020 (item_type,. \n+00057fa0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00057fb0: 2020 2020 2069 7465 6d5f 7772 6974 6572 item_writer\n+00057fc0: 3d69 7465 6d5f 7479 7065 2e77 7269 7465 =item_type.write\n+00057fd0: 722c 0a20 2020 2020 2020 2020 2020 2020 r,. \n+00057fe0: 2020 2020 2020 2020 2020 2020 6974 656d item\n+00057ff0: 5f72 6561 6465 723d 6974 656d 5f74 7970 _reader=item_typ\n+00058000: 652e 7265 6164 6572 2c0a 2020 2020 2020 e.reader,. \n+00058010: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00058020: 2020 206c 6973 745f 6170 7065 6e64 3d6c list_append=l\n+00058030: 6973 742e 6170 7065 6e64 290a 0a20 2020 ist.append).. \n+00058040: 2064 6566 2067 6574 5f72 6561 6465 7228 def get_reader(\n+00058050: 7365 6c66 2c20 656e 7465 725f 636f 6e74 self, enter_cont\n+00058060: 6169 6e65 722c 2065 7869 745f 636f 6e74 ainer, exit_cont\n+00058070: 6169 6e65 722c 206c 6973 745f 6170 7065 ainer, list_appe\n+00058080: 6e64 2c20 6974 656d 5f72 6561 6465 7229 nd, item_reader)\n+00058090: 3a0a 2020 2020 2020 2020 6465 6620 6172 :. def ar\n+000580a0: 7261 795f 7265 6164 6572 286d 6573 7361 ray_reader(messa\n+000580b0: 6765 3a20 6c69 6273 7973 7465 6d64 2e73 ge: libsystemd.s\n+000580c0: 645f 6275 735f 6d65 7373 6167 6529 202d d_bus_message) -\n+000580d0: 3e20 6f62 6a65 6374 3a0a 2020 2020 2020 > object:. \n+000580e0: 2020 2020 2020 6966 2065 6e74 6572 5f63 if enter_c\n+000580f0: 6f6e 7461 696e 6572 286d 6573 7361 6765 ontainer(message\n+00058100: 2c20 302c 204e 6f6e 6529 203c 3d20 303a , 0, None) <= 0:\n+00058110: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+00058120: 2072 6169 7365 2053 746f 7049 7465 7261 raise StopItera\n+00058130: 7469 6f6e 0a20 2020 2020 2020 2020 2020 tion. \n+00058140: 2072 6573 756c 743a 204c 6973 745b 6f62 result: List[ob\n+00058150: 6a65 6374 5d20 3d20 5b5d 0a20 2020 2020 ject] = []. \n+00058160: 2020 2020 2020 2074 7279 3a0a 2020 2020 try:. \n+00058170: 2020 2020 2020 2020 2020 2020 7768 696c whil\n+00058180: 6520 5472 7565 3a0a 2020 2020 2020 2020 e True:. \n+00058190: 2020 2020 2020 2020 2020 2020 6c69 7374 list\n+000581a0: 5f61 7070 656e 6428 7265 7375 6c74 2c20 _append(result, \n+000581b0: 6974 656d 5f72 6561 6465 7228 6d65 7373 item_reader(mess\n+000581c0: 6167 6529 290a 2020 2020 2020 2020 2020 age)). \n+000581d0: 2020 6578 6365 7074 2053 746f 7049 7465 except StopIte\n+000581e0: 7261 7469 6f6e 3a0a 2020 2020 2020 2020 ration:. \n+000581f0: 2020 2020 2020 2020 7265 7475 726e 2072 return r\n+00058200: 6573 756c 740a 2020 2020 2020 2020 2020 esult. \n+00058210: 2020 6669 6e61 6c6c 793a 0a20 2020 2020 finally:. \n+00058220: 2020 2020 2020 2020 2020 2065 7869 745f exit_\n+00058230: 636f 6e74 6169 6e65 7228 6d65 7373 6167 container(messag\n+00058240: 6529 0a20 2020 2020 2020 2072 6574 7572 e). retur\n+00058250: 6e20 6172 7261 795f 7265 6164 6572 0a0a n array_reader..\n+00058260: 2020 2020 6465 6620 6765 745f 7772 6974 def get_writ\n+00058270: 6572 2873 656c 662c 2061 2c20 7479 7065 er(self, a, type\n+00058280: 5f63 6f6e 7465 6e74 732c 206f 7065 6e5f _contents, open_\n+00058290: 636f 6e74 6169 6e65 722c 2063 6c6f 7365 container, close\n+000582a0: 5f63 6f6e 7461 696e 6572 2c20 6974 656d _container, item\n+000582b0: 5f77 7269 7465 7229 3a0a 2020 2020 2020 _writer):. \n+000582c0: 2020 6465 6620 6172 7261 795f 7772 6974 def array_writ\n+000582d0: 6572 286d 6573 7361 6765 3a20 6c69 6273 er(message: libs\n+000582e0: 7973 7465 6d64 2e73 645f 6275 735f 6d65 ystemd.sd_bus_me\n+000582f0: 7373 6167 652c 2076 616c 7565 3a20 6f62 ssage, value: ob\n+00058300: 6a65 6374 2920 2d3e 204e 6f6e 653a 0a20 ject) -> None:. \n+00058310: 2020 2020 2020 2020 2020 206f 7065 6e5f open_\n+00058320: 636f 6e74 6169 6e65 7228 6d65 7373 6167 container(messag\n+00058330: 652c 2061 2c20 7479 7065 5f63 6f6e 7465 e, a, type_conte\n+00058340: 6e74 7329 0a20 2020 2020 2020 2020 2020 nts). \n+00058350: 2066 6f72 2069 7465 6d20 696e 2076 616c for item in val\n+00058360: 7565 3a20 2023 2074 7970 653a 2069 676e ue: # type: ign\n+00058370: 6f72 655b 6174 7472 2d64 6566 696e 6564 ore[attr-defined\n+00058380: 5d20 2320 6361 6e20 7468 726f 7720 5479 ] # can throw Ty\n+00058390: 7065 4572 726f 720a 2020 2020 2020 2020 peError. \n+000583a0: 2020 2020 2020 2020 6974 656d 5f77 7269 item_wri\n+000583b0: 7465 7228 6d65 7373 6167 652c 2069 7465 ter(message, ite\n+000583c0: 6d29 0a20 2020 2020 2020 2020 2020 2063 m). c\n+000583d0: 6c6f 7365 5f63 6f6e 7461 696e 6572 286d lose_container(m\n+000583e0: 6573 7361 6765 290a 2020 2020 2020 2020 essage). \n+000583f0: 7265 7475 726e 2061 7272 6179 5f77 7269 return array_wri\n+00058400: 7465 720a 0a0a 636c 6173 7320 5374 7275 ter...class Stru\n+00058410: 6374 5479 7065 2843 6f6e 7461 696e 6572 ctType(Container\n+00058420: 5479 7065 293a 0a20 2020 205f 7479 7065 Type):. _type\n+00058430: 7374 7269 6e67 5f74 656d 706c 6174 6520 string_template \n+00058440: 3d20 2728 5f29 270a 2020 2020 5f5f 736c = '(_)'. __sl\n+00058450: 6f74 735f 5f20 3d20 2829 0a0a 2020 2020 ots__ = ().. \n+00058460: 6465 6620 6765 745f 7265 6164 6572 2873 def get_reader(s\n+00058470: 656c 662c 2065 6e74 6572 5f63 6f6e 7461 elf, enter_conta\n+00058480: 696e 6572 2c20 6578 6974 5f63 6f6e 7461 iner, exit_conta\n+00058490: 696e 6572 293a 0a20 2020 2020 2020 2069 iner):. i\n+000584a0: 7465 6d5f 7265 6164 6572 7320 3d20 7475 tem_readers = tu\n+000584b0: 706c 6528 6974 656d 5f74 7970 652e 7265 ple(item_type.re\n+000584c0: 6164 6572 2066 6f72 2069 7465 6d5f 7479 ader for item_ty\n+000584d0: 7065 2069 6e20 7365 6c66 2e69 7465 6d5f pe in self.item_\n+000584e0: 7479 7065 7329 0a0a 2020 2020 2020 2020 types).. \n+000584f0: 6465 6620 6172 7261 795f 7265 6164 6572 def array_reader\n+00058500: 286d 6573 7361 6765 3a20 6c69 6273 7973 (message: libsys\n+00058510: 7465 6d64 2e73 645f 6275 735f 6d65 7373 temd.sd_bus_mess\n+00058520: 6167 6529 202d 3e20 6f62 6a65 6374 3a0a age) -> object:.\n+00058530: 2020 2020 2020 2020 2020 2020 6966 2065 if e\n+00058540: 6e74 6572 5f63 6f6e 7461 696e 6572 286d nter_container(m\n+00058550: 6573 7361 6765 2c20 302c 204e 6f6e 6529 essage, 0, None)\n+00058560: 203c 3d20 303a 0a20 2020 2020 2020 2020 <= 0:. \n+00058570: 2020 2020 2020 2072 6169 7365 2053 746f raise Sto\n+00058580: 7049 7465 7261 7469 6f6e 0a20 2020 2020 pIteration. \n+00058590: 2020 2020 2020 2072 6573 756c 7420 3d20 result = \n+000585a0: 7475 706c 6528 6974 656d 5f72 6561 6465 tuple(item_reade\n+000585b0: 7228 6d65 7373 6167 6529 2066 6f72 2069 r(message) for i\n+000585c0: 7465 6d5f 7265 6164 6572 2069 6e20 6974 tem_reader in it\n+000585d0: 656d 5f72 6561 6465 7273 290a 2020 2020 em_readers). \n+000585e0: 2020 2020 2020 2020 6578 6974 5f63 6f6e exit_con\n+000585f0: 7461 696e 6572 286d 6573 7361 6765 290a tainer(message).\n+00058600: 2020 2020 2020 2020 2020 2020 7265 7475 retu\n+00058610: 726e 2072 6573 756c 740a 2020 2020 2020 rn result. \n+00058620: 2020 7265 7475 726e 2061 7272 6179 5f72 return array_r\n+00058630: 6561 6465 720a 0a20 2020 2064 6566 2067 eader.. def g\n+00058640: 6574 5f77 7269 7465 7228 7365 6c66 2c20 et_writer(self, \n+00058650: 722c 2074 7970 655f 636f 6e74 656e 7473 r, type_contents\n+00058660: 2c20 6f70 656e 5f63 6f6e 7461 696e 6572 , open_container\n+00058670: 2c20 636c 6f73 655f 636f 6e74 6169 6e65 , close_containe\n+00058680: 7229 3a0a 2020 2020 2020 2020 6974 656d r):. item\n+00058690: 5f77 7269 7465 7273 203d 2074 7570 6c65 _writers = tuple\n+000586a0: 2869 7465 6d5f 7479 7065 2e77 7269 7465 (item_type.write\n+000586b0: 7220 666f 7220 6974 656d 5f74 7970 6520 r for item_type \n+000586c0: 696e 2073 656c 662e 6974 656d 5f74 7970 in self.item_typ\n+000586d0: 6573 290a 0a20 2020 2020 2020 2064 6566 es).. def\n+000586e0: 2073 7472 7563 745f 7772 6974 6572 286d struct_writer(m\n+000586f0: 6573 7361 6765 3a20 6c69 6273 7973 7465 essage: libsyste\n+00058700: 6d64 2e73 645f 6275 735f 6d65 7373 6167 md.sd_bus_messag\n+00058710: 652c 2076 616c 7565 3a20 6f62 6a65 6374 e, value: object\n+00058720: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n+00058730: 2020 2020 2020 206e 5f69 7465 6d73 203d n_items =\n+00058740: 206c 656e 2876 616c 7565 2920 2023 2074 len(value) # t\n+00058750: 7970 653a 2069 676e 6f72 655b 6172 672d ype: ignore[arg-\n+00058760: 7479 7065 5d20 2320 6361 6e20 7468 726f type] # can thro\n+00058770: 7720 5479 7065 4572 726f 720a 2020 2020 w TypeError. \n+00058780: 2020 2020 2020 2020 6966 206e 5f69 7465 if n_ite\n+00058790: 6d73 2021 3d20 6c65 6e28 6974 656d 5f77 ms != len(item_w\n+000587a0: 7269 7465 7273 293a 0a20 2020 2020 2020 riters):. \n+000587b0: 2020 2020 2020 2020 2072 6169 7365 2054 raise T\n+000587c0: 7970 6545 7272 6f72 2866 2257 726f 6e67 ypeError(f\"Wrong\n+000587d0: 206e 756d 6265 7273 206f 6620 6974 656d numbers of item\n+000587e0: 7320 287b 6e5f 6974 656d 737d 2920 666f s ({n_items}) fo\n+000587f0: 7220 7374 7275 6374 7572 6520 7479 7065 r structure type\n+00058800: 2027 7b73 656c 662e 7479 7065 7374 7269 '{self.typestri\n+00058810: 6e67 7d27 2229 0a20 2020 2020 2020 2020 ng}'\"). \n+00058820: 2020 206f 7065 6e5f 636f 6e74 6169 6e65 open_containe\n+00058830: 7228 6d65 7373 6167 652c 2072 2c20 7479 r(message, r, ty\n+00058840: 7065 5f63 6f6e 7465 6e74 7329 0a20 2020 pe_contents). \n+00058850: 2020 2020 2020 2020 2066 6f72 2069 7465 for ite\n+00058860: 6d5f 7772 6974 6572 2c20 6974 656d 2069 m_writer, item i\n+00058870: 6e20 7a69 7028 6974 656d 5f77 7269 7465 n zip(item_write\n+00058880: 7273 2c20 7661 6c75 6529 3a20 2023 2074 rs, value): # t\n+00058890: 7970 653a 2069 676e 6f72 655b 6361 6c6c ype: ignore[call\n+000588a0: 2d6f 7665 726c 6f61 645d 2023 2063 616e -overload] # can\n+000588b0: 2074 6872 6f77 2054 7970 6545 7272 6f72 throw TypeError\n+000588c0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+000588d0: 2069 7465 6d5f 7772 6974 6572 286d 6573 item_writer(mes\n+000588e0: 7361 6765 2c20 6974 656d 290a 2020 2020 sage, item). \n+000588f0: 2020 2020 2020 2020 636c 6f73 655f 636f close_co\n+00058900: 6e74 6169 6e65 7228 6d65 7373 6167 6529 ntainer(message)\n+00058910: 0a20 2020 2020 2020 2072 6574 7572 6e20 . return \n+00058920: 7374 7275 6374 5f77 7269 7465 720a 0a0a struct_writer...\n+00058930: 636c 6173 7320 4469 6374 696f 6e61 7279 class Dictionary\n+00058940: 5479 7065 2843 6f6e 7461 696e 6572 5479 Type(ContainerTy\n+00058950: 7065 293a 0a20 2020 205f 7479 7065 7374 pe):. _typest\n+00058960: 7269 6e67 5f74 656d 706c 6174 6520 3d20 ring_template = \n+00058970: 2761 7b5f 7d27 0a20 2020 205f 5f73 6c6f 'a{_}'. __slo\n+00058980: 7473 5f5f 203d 2028 290a 0a20 2020 2064 ts__ = ().. d\n+00058990: 6566 205f 5f69 6e69 745f 5f28 7365 6c66 ef __init__(self\n+000589a0: 2c20 6b65 795f 7479 7065 3a20 5479 7065 , key_type: Type\n+000589b0: 2c20 7661 6c75 655f 7479 7065 3a20 5479 , value_type: Ty\n+000589c0: 7065 293a 0a20 2020 2020 2020 2061 7373 pe):. ass\n+000589d0: 6572 7420 6973 696e 7374 616e 6365 286b ert isinstance(k\n+000589e0: 6579 5f74 7970 652c 2042 6173 6963 5479 ey_type, BasicTy\n+000589f0: 7065 290a 2020 2020 2020 2020 6974 656d pe). item\n+00058a00: 5f74 7970 6520 3d20 277b 2720 2b20 6b65 _type = '{' + ke\n+00058a10: 795f 7479 7065 2e74 7970 6573 7472 696e y_type.typestrin\n+00058a20: 6720 2b20 7661 6c75 655f 7479 7065 2e74 g + value_type.t\n+00058a30: 7970 6573 7472 696e 6720 2b20 277d 270a ypestring + '}'.\n+00058a40: 2020 2020 2020 2020 7375 7065 7228 292e super().\n+00058a50: 5f5f 696e 6974 5f5f 286b 6579 5f74 7970 __init__(key_typ\n+00058a60: 652c 2076 616c 7565 5f74 7970 652c 0a20 e, value_type,. \n+00058a70: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00058a80: 2020 2020 2020 2020 6b65 795f 7265 6164 key_read\n+00058a90: 6572 3d6b 6579 5f74 7970 652e 7265 6164 er=key_type.read\n+00058aa0: 6572 2c20 6b65 795f 7772 6974 6572 3d6b er, key_writer=k\n+00058ab0: 6579 5f74 7970 652e 7772 6974 6572 2c0a ey_type.writer,.\n+00058ac0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00058ad0: 2020 2020 2020 2020 2076 616c 7565 5f72 value_r\n+00058ae0: 6561 6465 723d 7661 6c75 655f 7479 7065 eader=value_type\n+00058af0: 2e72 6561 6465 722c 2076 616c 7565 5f77 .reader, value_w\n+00058b00: 7269 7465 723d 7661 6c75 655f 7479 7065 riter=value_type\n+00058b10: 2e77 7269 7465 722c 0a20 2020 2020 2020 .writer,. \n+00058b20: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00058b30: 2020 6974 656d 5f74 7970 653d 6374 7970 item_type=ctyp\n+00058b40: 6573 2e63 5f63 6861 725f 7028 6974 656d es.c_char_p(item\n+00058b50: 5f74 7970 652e 656e 636f 6465 2827 6173 _type.encode('as\n+00058b60: 6369 6927 2929 290a 0a20 2020 2064 6566 cii'))).. def\n+00058b70: 2067 6574 5f72 6561 6465 7228 7365 6c66 get_reader(self\n+00058b80: 2c20 656e 7465 725f 636f 6e74 6169 6e65 , enter_containe\n+00058b90: 722c 2065 7869 745f 636f 6e74 6169 6e65 r, exit_containe\n+00058ba0: 722c 206b 6579 5f72 6561 6465 722c 2076 r, key_reader, v\n+00058bb0: 616c 7565 5f72 6561 6465 7229 3a0a 2020 alue_reader):. \n+00058bc0: 2020 2020 2020 6465 6620 6469 6374 5f72 def dict_r\n+00058bd0: 6561 6465 7228 6d65 7373 6167 653a 206c eader(message: l\n+00058be0: 6962 7379 7374 656d 642e 7364 5f62 7573 ibsystemd.sd_bus\n+00058bf0: 5f6d 6573 7361 6765 2920 2d3e 206f 626a _message) -> obj\n+00058c00: 6563 743a 0a20 2020 2020 2020 2020 2020 ect:. \n+00058c10: 2069 6620 656e 7465 725f 636f 6e74 6169 if enter_contai\n+00058c20: 6e65 7228 6d65 7373 6167 652c 2030 2c20 ner(message, 0, \n+00058c30: 4e6f 6e65 2920 3c3d 2030 3a20 2020 2023 None) <= 0: #\n+00058c40: 2061 7272 6179 0a20 2020 2020 2020 2020 array. \n+00058c50: 2020 2020 2020 2072 6169 7365 2053 746f raise Sto\n+00058c60: 7049 7465 7261 7469 6f6e 0a20 2020 2020 pIteration. \n+00058c70: 2020 2020 2020 2072 6573 756c 7420 3d20 result = \n+00058c80: 7b7d 0a20 2020 2020 2020 2020 2020 2077 {}. w\n+00058c90: 6869 6c65 2065 6e74 6572 5f63 6f6e 7461 hile enter_conta\n+00058ca0: 696e 6572 286d 6573 7361 6765 2c20 302c iner(message, 0,\n+00058cb0: 204e 6f6e 6529 203e 2030 3a20 2023 2065 None) > 0: # e\n+00058cc0: 6e74 7279 0a20 2020 2020 2020 2020 2020 ntry. \n+00058cd0: 2020 2020 206b 6579 203d 206b 6579 5f72 key = key_r\n+00058ce0: 6561 6465 7228 6d65 7373 6167 6529 0a20 eader(message). \n+00058cf0: 2020 2020 2020 2020 2020 2020 2020 2076 v\n+00058d00: 616c 7565 203d 2076 616c 7565 5f72 6561 alue = value_rea\n+00058d10: 6465 7228 6d65 7373 6167 6529 0a20 2020 der(message). \n+00058d20: 2020 2020 2020 2020 2020 2020 2072 6573 res\n+00058d30: 756c 745b 6b65 795d 203d 2076 616c 7565 ult[key] = value\n+00058d40: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+00058d50: 2065 7869 745f 636f 6e74 6169 6e65 7228 exit_container(\n+00058d60: 6d65 7373 6167 6529 0a20 2020 2020 2020 message). \n+00058d70: 2020 2020 2065 7869 745f 636f 6e74 6169 exit_contai\n+00058d80: 6e65 7228 6d65 7373 6167 6529 0a20 2020 ner(message). \n+00058d90: 2020 2020 2020 2020 2072 6574 7572 6e20 return \n+00058da0: 7265 7375 6c74 0a20 2020 2020 2020 2072 result. r\n+00058db0: 6574 7572 6e20 6469 6374 5f72 6561 6465 eturn dict_reade\n+00058dc0: 720a 0a20 2020 2064 6566 2067 6574 5f77 r.. def get_w\n+00058dd0: 7269 7465 7228 7365 6c66 2c20 612c 2069 riter(self, a, i\n+00058de0: 7465 6d5f 7479 7065 2c20 652c 2074 7970 tem_type, e, typ\n+00058df0: 655f 636f 6e74 656e 7473 2c20 6f70 656e e_contents, open\n+00058e00: 5f63 6f6e 7461 696e 6572 2c20 636c 6f73 _container, clos\n+00058e10: 655f 636f 6e74 6169 6e65 722c 206b 6579 e_container, key\n+00058e20: 5f77 7269 7465 722c 2076 616c 7565 5f77 _writer, value_w\n+00058e30: 7269 7465 7229 3a0a 2020 2020 2020 2020 riter):. \n+00058e40: 6465 6620 6469 6374 5f77 7269 7465 7228 def dict_writer(\n+00058e50: 6d65 7373 6167 653a 206c 6962 7379 7374 message: libsyst\n+00058e60: 656d 642e 7364 5f62 7573 5f6d 6573 7361 emd.sd_bus_messa\n+00058e70: 6765 2c20 7661 6c75 653a 206f 626a 6563 ge, value: objec\n+00058e80: 7429 202d 3e20 4e6f 6e65 3a0a 2020 2020 t) -> None:. \n+00058e90: 2020 2020 2020 2020 6f70 656e 5f63 6f6e open_con\n+00058ea0: 7461 696e 6572 286d 6573 7361 6765 2c20 tainer(message, \n+00058eb0: 612c 2069 7465 6d5f 7479 7065 2920 2020 a, item_type) \n+00058ec0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00058ed0: 2023 2061 7272 6179 0a20 2020 2020 2020 # array. \n+00058ee0: 2020 2020 2066 6f72 206b 6579 2c20 7661 for key, va\n+00058ef0: 6c20 696e 2076 616c 7565 2e69 7465 6d73 l in value.items\n+00058f00: 2829 3a20 2023 2074 7970 653a 2069 676e (): # type: ign\n+00058f10: 6f72 655b 6174 7472 2d64 6566 696e 6564 ore[attr-defined\n+00058f20: 5d20 2320 6361 6e20 7261 6973 6520 4174 ] # can raise At\n+00058f30: 7472 6962 7574 6545 7272 6f72 0a20 2020 tributeError. \n+00058f40: 2020 2020 2020 2020 2020 2020 206f 7065 ope\n+00058f50: 6e5f 636f 6e74 6169 6e65 7228 6d65 7373 n_container(mess\n+00058f60: 6167 652c 2065 2c20 7479 7065 5f63 6f6e age, e, type_con\n+00058f70: 7465 6e74 7329 2020 2020 2020 2020 2020 tents) \n+00058f80: 2020 2020 2320 656e 7472 790a 2020 2020 # entry. \n+00058f90: 2020 2020 2020 2020 2020 2020 6b65 795f key_\n+00058fa0: 7772 6974 6572 286d 6573 7361 6765 2c20 writer(message, \n+00058fb0: 6b65 7929 2020 2020 2020 2020 2020 2020 key) \n+00058fc0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00058fd0: 2020 2020 2023 206b 6579 0a20 2020 2020 # key. \n+00058fe0: 2020 2020 2020 2020 2020 2076 616c 7565 value\n+00058ff0: 5f77 7269 7465 7228 6d65 7373 6167 652c _writer(message,\n+00059000: 2076 616c 2920 2020 2020 2020 2020 2020 val) \n+00059010: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00059020: 2020 2020 2320 7661 6c75 650a 2020 2020 # value. \n+00059030: 2020 2020 2020 2020 2020 2020 636c 6f73 clos\n+00059040: 655f 636f 6e74 6169 6e65 7228 6d65 7373 e_container(mess\n+00059050: 6167 6529 2020 2020 2020 2020 2020 2020 age) \n+00059060: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00059070: 2020 2023 2065 6e64 2065 6e74 7279 0a20 # end entry. \n+00059080: 2020 2020 2020 2020 2020 2063 6c6f 7365 close\n+00059090: 5f63 6f6e 7461 696e 6572 286d 6573 7361 _container(messa\n+000590a0: 6765 2920 2020 2020 2020 2020 2020 2020 ge) \n+000590b0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000590c0: 2020 2020 2320 656e 6420 6172 7261 790a # end array.\n+000590d0: 2020 2020 2020 2020 7265 7475 726e 2064 return d\n+000590e0: 6963 745f 7772 6974 6572 0a0a 0a63 6c61 ict_writer...cla\n+000590f0: 7373 2056 6172 6961 6e74 5479 7065 2854 ss VariantType(T\n+00059100: 7970 6529 3a0a 2020 2020 5f5f 736c 6f74 ype):. __slot\n+00059110: 735f 5f20 3d20 2829 0a0a 2020 2020 6465 s__ = ().. de\n+00059120: 6620 6765 745f 7265 6164 6572 2873 656c f get_reader(sel\n+00059130: 662c 2065 6e74 6572 5f63 6f6e 7461 696e f, enter_contain\n+00059140: 6572 2c20 6578 6974 5f63 6f6e 7461 696e er, exit_contain\n+00059150: 6572 293a 0a20 2020 2020 2020 2064 6566 er):. def\n+00059160: 2076 6172 6961 6e74 5f72 6561 6465 7228 variant_reader(\n+00059170: 6d65 7373 6167 653a 206c 6962 7379 7374 message: libsyst\n+00059180: 656d 642e 7364 5f62 7573 5f6d 6573 7361 emd.sd_bus_messa\n+00059190: 6765 2920 2d3e 206f 626a 6563 743a 0a20 ge) -> object:. \n+000591a0: 2020 2020 2020 2020 2020 2069 6620 656e if en\n+000591b0: 7465 725f 636f 6e74 6169 6e65 7228 6d65 ter_container(me\n+000591c0: 7373 6167 652c 2030 2c20 4e6f 6e65 2920 ssage, 0, None) \n+000591d0: 3c3d 2030 3a0a 2020 2020 2020 2020 2020 <= 0:. \n+000591e0: 2020 2020 2020 7261 6973 6520 5374 6f70 raise Stop\n+000591f0: 4974 6572 6174 696f 6e0a 2020 2020 2020 Iteration. \n+00059200: 2020 2020 2020 7479 7065 7374 7269 6e67 typestring\n+00059210: 203d 206d 6573 7361 6765 2e67 6574 5f73 = message.get_s\n+00059220: 6967 6e61 7475 7265 2846 616c 7365 290a ignature(False).\n+00059230: 2020 2020 2020 2020 2020 2020 7479 7065 type\n+00059240: 5f2c 203d 2066 726f 6d5f 7369 676e 6174 _, = from_signat\n+00059250: 7572 6528 7479 7065 7374 7269 6e67 290a ure(typestring).\n+00059260: 2020 2020 2020 2020 2020 2020 7661 6c75 valu\n+00059270: 6520 3d20 7479 7065 5f2e 7265 6164 6572 e = type_.reader\n+00059280: 286d 6573 7361 6765 290a 2020 2020 2020 (message). \n+00059290: 2020 2020 2020 6578 6974 5f63 6f6e 7461 exit_conta\n+000592a0: 696e 6572 286d 6573 7361 6765 290a 2020 iner(message). \n+000592b0: 2020 2020 2020 2020 2020 7265 7475 726e return\n+000592c0: 2056 6172 6961 6e74 2876 616c 7565 2c20 Variant(value, \n+000592d0: 7479 7065 5f29 0a20 2020 2020 2020 2072 type_). r\n+000592e0: 6574 7572 6e20 7661 7269 616e 745f 7265 eturn variant_re\n+000592f0: 6164 6572 0a0a 2020 2020 6465 6620 6765 ader.. def ge\n+00059300: 745f 7772 6974 6572 2873 656c 662c 206f t_writer(self, o\n+00059310: 7065 6e5f 636f 6e74 6169 6e65 722c 2063 pen_container, c\n+00059320: 6c6f 7365 5f63 6f6e 7461 696e 6572 2c20 lose_container, \n+00059330: 7629 3a0a 2020 2020 2020 2020 6465 6620 v):. def \n+00059340: 7661 7269 616e 745f 7772 6974 6572 286d variant_writer(m\n+00059350: 6573 7361 6765 3a20 6c69 6273 7973 7465 essage: libsyste\n+00059360: 6d64 2e73 645f 6275 735f 6d65 7373 6167 md.sd_bus_messag\n+00059370: 652c 2076 616c 7565 3a20 6f62 6a65 6374 e, value: object\n+00059380: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n+00059390: 2020 2020 2020 2069 6620 6973 696e 7374 if isinst\n+000593a0: 616e 6365 2876 616c 7565 2c20 5661 7269 ance(value, Vari\n+000593b0: 616e 7429 3a0a 2020 2020 2020 2020 2020 ant):. \n+000593c0: 2020 2020 2020 7479 7065 5f20 3d20 7661 type_ = va\n+000593d0: 6c75 652e 7479 7065 0a20 2020 2020 2020 lue.type. \n+000593e0: 2020 2020 2020 2020 2063 6f6e 7465 6e74 content\n+000593f0: 7320 3d20 7661 6c75 652e 7661 6c75 650a s = value.value.\n+00059400: 2020 2020 2020 2020 2020 2020 656c 7365 else\n+00059410: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n+00059420: 2020 7472 793a 0a20 2020 2020 2020 2020 try:. \n+00059430: 2020 2020 2020 2020 2020 2074 7970 655f type_\n+00059440: 2c20 3d20 6672 6f6d 5f73 6967 6e61 7475 , = from_signatu\n+00059450: 7265 2876 616c 7565 5b27 7427 5d29 2020 re(value['t']) \n+00059460: 2320 7479 7065 3a20 6967 6e6f 7265 5b69 # type: ignore[i\n+00059470: 6e64 6578 5d20 2320 6361 6e20 7468 726f ndex] # can thro\n+00059480: 7720 5479 7065 4572 726f 720a 2020 2020 w TypeError. \n+00059490: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000594a0: 636f 6e74 656e 7473 203d 2076 616c 7565 contents = value\n+000594b0: 5b27 7627 5d20 2023 2074 7970 653a 2069 ['v'] # type: i\n+000594c0: 676e 6f72 655b 696e 6465 785d 2023 2063 gnore[index] # c\n+000594d0: 616e 2074 6872 6f77 2054 7970 6545 7272 an throw TypeErr\n+000594e0: 6f72 0a20 2020 2020 2020 2020 2020 2020 or. \n+000594f0: 2020 2065 7863 6570 7420 4b65 7945 7272 except KeyErr\n+00059500: 6f72 2061 7320 6578 633a 0a20 2020 2020 or as exc:. \n+00059510: 2020 2020 2020 2020 2020 2020 2020 2072 r\n+00059520: 6169 7365 2054 7970 6545 7272 6f72 2822 aise TypeError(\"\n+00059530: 2776 2720 6361 6e20 656e 636f 6465 2056 'v' can encode V\n+00059540: 6172 6961 6e74 206f 626a 6563 7473 2c20 ariant objects, \n+00059550: 6f72 206d 6170 7069 6e67 7320 7769 7468 or mappings with\n+00059560: 2027 7427 2061 6e64 2027 7627 206b 6579 't' and 'v' key\n+00059570: 7322 2920 6672 6f6d 2065 7863 0a0a 2020 s\") from exc.. \n+00059580: 2020 2020 2020 2020 2020 6f70 656e 5f63 open_c\n+00059590: 6f6e 7461 696e 6572 286d 6573 7361 6765 ontainer(message\n+000595a0: 2c20 762c 2074 7970 655f 2e62 7974 6573 , v, type_.bytes\n+000595b0: 5f74 7970 6573 7472 696e 6729 0a20 2020 _typestring). \n+000595c0: 2020 2020 2020 2020 2074 7970 655f 2e77 type_.w\n+000595d0: 7269 7465 7228 6d65 7373 6167 652c 2063 riter(message, c\n+000595e0: 6f6e 7465 6e74 7329 0a20 2020 2020 2020 ontents). \n+000595f0: 2020 2020 2063 6c6f 7365 5f63 6f6e 7461 close_conta\n+00059600: 696e 6572 286d 6573 7361 6765 290a 2020 iner(message). \n+00059610: 2020 2020 2020 7265 7475 726e 2076 6172 return var\n+00059620: 6961 6e74 5f77 7269 7465 720a 0a0a 636c iant_writer...cl\n+00059630: 6173 7320 5661 7269 616e 743a 0a20 2020 ass Variant:. \n+00059640: 205f 5f73 6c6f 7473 5f5f 203d 2027 7479 __slots__ = 'ty\n+00059650: 7065 272c 2027 7661 6c75 6527 0a20 2020 pe', 'value'. \n+00059660: 2074 7970 653a 2054 7970 650a 2020 2020 type: Type. \n+00059670: 7661 6c75 653a 206f 626a 6563 740a 0a20 value: object.. \n+00059680: 2020 2064 6566 205f 5f69 6e69 745f 5f28 def __init__(\n+00059690: 7365 6c66 2c20 7661 6c75 653a 206f 626a self, value: obj\n+000596a0: 6563 742c 2068 696e 743a 206f 626a 6563 ect, hint: objec\n+000596b0: 7420 3d20 4e6f 6e65 293a 0a20 2020 2020 t = None):. \n+000596c0: 2020 2069 6620 6973 696e 7374 616e 6365 if isinstance\n+000596d0: 2868 696e 742c 2054 7970 6529 3a0a 2020 (hint, Type):. \n+000596e0: 2020 2020 2020 2020 2020 7365 6c66 2e74 self.t\n+000596f0: 7970 6520 3d20 6869 6e74 0a20 2020 2020 ype = hint. \n+00059700: 2020 2065 6c69 6620 6973 696e 7374 616e elif isinstan\n+00059710: 6365 2868 696e 742c 2073 7472 293a 0a20 ce(hint, str):. \n+00059720: 2020 2020 2020 2020 2020 2073 656c 662e self.\n+00059730: 7479 7065 2c20 3d20 6672 6f6d 5f73 6967 type, = from_sig\n+00059740: 6e61 7475 7265 2868 696e 7429 0a20 2020 nature(hint). \n+00059750: 2020 2020 2065 6c73 653a 0a20 2020 2020 else:. \n+00059760: 2020 2020 2020 2073 656c 662e 7479 7065 self.type\n+00059770: 203d 2066 726f 6d5f 616e 6e6f 7461 7469 = from_annotati\n+00059780: 6f6e 2868 696e 7420 6f72 2076 616c 7565 on(hint or value\n+00059790: 2e5f 5f63 6c61 7373 5f5f 290a 2020 2020 .__class__). \n+000597a0: 2020 2020 7365 6c66 2e76 616c 7565 203d self.value =\n+000597b0: 2076 616c 7565 0a0a 2020 2020 6465 6620 value.. def \n+000597c0: 5f5f 7265 7072 5f5f 2873 656c 6629 202d __repr__(self) -\n+000597d0: 3e20 7374 723a 0a20 2020 2020 2020 2072 > str:. r\n+000597e0: 6574 7572 6e20 6622 7379 7374 656d 645f eturn f\"systemd_\n+000597f0: 6374 7970 6573 2e56 6172 6961 6e74 287b ctypes.Variant({\n+00059800: 7365 6c66 2e76 616c 7565 7d2c 2027 7b73 self.value}, '{s\n+00059810: 656c 662e 7479 7065 2e74 7970 6573 7472 elf.type.typestr\n+00059820: 696e 677d 2729 220a 0a20 2020 2064 6566 ing}')\".. def\n+00059830: 205f 5f65 715f 5f28 7365 6c66 2c20 6f74 __eq__(self, ot\n+00059840: 6865 723a 206f 626a 6563 7429 202d 3e20 her: object) -> \n+00059850: 626f 6f6c 3a0a 2020 2020 2020 2020 6966 bool:. if\n+00059860: 2069 7369 6e73 7461 6e63 6528 6f74 6865 isinstance(othe\n+00059870: 722c 2056 6172 6961 6e74 293a 0a20 2020 r, Variant):. \n+00059880: 2020 2020 2020 2020 2072 6574 7572 6e20 return \n+00059890: 7365 6c66 2e74 7970 6520 3d3d 206f 7468 self.type == oth\n+000598a0: 6572 2e74 7970 6520 616e 6420 7365 6c66 er.type and self\n+000598b0: 2e76 616c 7565 203d 3d20 6f74 6865 722e .value == other.\n+000598c0: 7661 6c75 650a 2020 2020 2020 2020 656c value. el\n+000598d0: 6966 2069 7369 6e73 7461 6e63 6528 6f74 if isinstance(ot\n+000598e0: 6865 722c 2064 6963 7429 3a0a 2020 2020 her, dict):. \n+000598f0: 2020 2020 2020 2020 7265 7475 726e 2028 return (\n+00059900: 7365 6c66 2e74 7970 652c 2920 3d3d 2066 self.type,) == f\n+00059910: 726f 6d5f 7369 676e 6174 7572 6528 6f74 rom_signature(ot\n+00059920: 6865 725b 2774 275d 2920 616e 6420 7365 her['t']) and se\n+00059930: 6c66 2e76 616c 7565 203d 3d20 6f74 6865 lf.value == othe\n+00059940: 725b 2776 275d 0a20 2020 2020 2020 2065 r['v']. e\n+00059950: 6c73 653a 0a20 2020 2020 2020 2020 2020 lse:. \n+00059960: 2072 6574 7572 6e20 4661 6c73 650a 0a20 return False.. \n+00059970: 2020 2064 6566 205f 5f68 6173 685f 5f28 def __hash__(\n+00059980: 7365 6c66 2920 2d3e 2069 6e74 3a0a 2020 self) -> int:. \n+00059990: 2020 2020 2020 7265 7475 726e 2068 6173 return has\n+000599a0: 6828 7365 6c66 2e74 7970 6529 205e 2068 h(self.type) ^ h\n+000599b0: 6173 6828 7365 6c66 2e76 616c 7565 290a ash(self.value).\n+000599c0: 0a0a 636c 6173 7320 4275 7354 7970 6528 ..class BusType(\n+000599d0: 456e 756d 293a 0a20 2020 2062 6f6f 6c65 Enum):. boole\n+000599e0: 616e 203d 2041 6e6e 6f74 6174 6564 5b62 an = Annotated[b\n+000599f0: 6f6f 6c2c 2046 6978 6564 5479 7065 2827 ool, FixedType('\n+00059a00: 6227 2c20 6374 7970 6573 2e63 5f69 6e74 b', ctypes.c_int\n+00059a10: 2c20 6374 7970 6573 2e63 5f69 6e74 2e5f , ctypes.c_int._\n+00059a20: 5f62 6f6f 6c5f 5f29 5d0a 2020 2020 6279 _bool__)]. by\n+00059a30: 7465 203d 2041 6e6e 6f74 6174 6564 5b69 te = Annotated[i\n+00059a40: 6e74 2c20 4669 7865 6454 7970 6528 2779 nt, FixedType('y\n+00059a50: 272c 2063 7479 7065 732e 635f 7569 6e74 ', ctypes.c_uint\n+00059a60: 3829 5d0a 2020 2020 696e 7431 3620 3d20 8)]. int16 = \n+00059a70: 416e 6e6f 7461 7465 645b 696e 742c 2046 Annotated[int, F\n+00059a80: 6978 6564 5479 7065 2827 6e27 2c20 6374 ixedType('n', ct\n+00059a90: 7970 6573 2e63 5f69 6e74 3136 295d 0a20 ypes.c_int16)]. \n+00059aa0: 2020 2075 696e 7431 3620 3d20 416e 6e6f uint16 = Anno\n+00059ab0: 7461 7465 645b 696e 742c 2046 6978 6564 tated[int, Fixed\n+00059ac0: 5479 7065 2827 7127 2c20 6374 7970 6573 Type('q', ctypes\n+00059ad0: 2e63 5f75 696e 7431 3629 5d0a 2020 2020 .c_uint16)]. \n+00059ae0: 696e 7433 3220 3d20 416e 6e6f 7461 7465 int32 = Annotate\n+00059af0: 645b 696e 742c 2046 6978 6564 5479 7065 d[int, FixedType\n+00059b00: 2827 6927 2c20 6374 7970 6573 2e63 5f69 ('i', ctypes.c_i\n+00059b10: 6e74 3332 295d 0a20 2020 2075 696e 7433 nt32)]. uint3\n+00059b20: 3220 3d20 416e 6e6f 7461 7465 645b 696e 2 = Annotated[in\n+00059b30: 742c 2046 6978 6564 5479 7065 2827 7527 t, FixedType('u'\n+00059b40: 2c20 6374 7970 6573 2e63 5f75 696e 7433 , ctypes.c_uint3\n+00059b50: 3229 5d0a 2020 2020 696e 7436 3420 3d20 2)]. int64 = \n+00059b60: 416e 6e6f 7461 7465 645b 696e 742c 2046 Annotated[int, F\n+00059b70: 6978 6564 5479 7065 2827 7827 2c20 6374 ixedType('x', ct\n+00059b80: 7970 6573 2e63 5f69 6e74 3634 295d 0a20 ypes.c_int64)]. \n+00059b90: 2020 2075 696e 7436 3420 3d20 416e 6e6f uint64 = Anno\n+00059ba0: 7461 7465 645b 696e 742c 2046 6978 6564 tated[int, Fixed\n+00059bb0: 5479 7065 2827 7427 2c20 6374 7970 6573 Type('t', ctypes\n+00059bc0: 2e63 5f75 696e 7436 3429 5d0a 2020 2020 .c_uint64)]. \n+00059bd0: 646f 7562 6c65 203d 2041 6e6e 6f74 6174 double = Annotat\n+00059be0: 6564 5b66 6c6f 6174 2c20 4669 7865 6454 ed[float, FixedT\n+00059bf0: 7970 6528 2764 272c 2063 7479 7065 732e ype('d', ctypes.\n+00059c00: 635f 646f 7562 6c65 295d 0a20 2020 2073 c_double)]. s\n+00059c10: 7472 696e 6720 3d20 416e 6e6f 7461 7465 tring = Annotate\n+00059c20: 645b 7374 722c 2053 7472 696e 674c 696b d[str, StringLik\n+00059c30: 6554 7970 6528 2773 2729 5d0a 2020 2020 eType('s')]. \n+00059c40: 6f62 6a65 6374 7061 7468 203d 2041 6e6e objectpath = Ann\n+00059c50: 6f74 6174 6564 5b73 7472 2c20 5374 7269 otated[str, Stri\n+00059c60: 6e67 4c69 6b65 5479 7065 2827 6f27 2c20 ngLikeType('o', \n+00059c70: 6973 5f6f 626a 6563 745f 7061 7468 295d is_object_path)]\n+00059c80: 0a20 2020 2073 6967 6e61 7475 7265 203d . signature =\n+00059c90: 2041 6e6e 6f74 6174 6564 5b73 7472 2c20 Annotated[str, \n+00059ca0: 5374 7269 6e67 4c69 6b65 5479 7065 2827 StringLikeType('\n+00059cb0: 6727 2c20 6973 5f73 6967 6e61 7475 7265 g', is_signature\n+00059cc0: 295d 0a20 2020 2062 7974 6573 7472 696e )]. bytestrin\n+00059cd0: 6720 3d20 416e 6e6f 7461 7465 645b 6279 g = Annotated[by\n+00059ce0: 7465 732c 2042 7974 6573 7472 696e 6754 tes, BytestringT\n+00059cf0: 7970 6528 2761 7927 295d 0a20 2020 2076 ype('ay')]. v\n+00059d00: 6172 6961 6e74 203d 2041 6e6e 6f74 6174 ariant = Annotat\n+00059d10: 6564 5b64 6963 742c 2056 6172 6961 6e74 ed[dict, Variant\n+00059d20: 5479 7065 2827 7627 295d 0a0a 0a23 206d Type('v')]...# m\n+00059d30: 7970 7920 6765 7473 2063 6f6e 6675 7365 ypy gets confuse\n+00059d40: 6420 6279 2065 6e75 6d73 2c20 736f 206a d by enums, so j\n+00059d50: 7573 7420 7573 6520 416e 790a 5f62 6173 ust use Any._bas\n+00059d60: 655f 6571 7569 7661 6c65 6e63 655f 6d61 e_equivalence_ma\n+00059d70: 703a 2044 6963 745b 7479 7065 2c20 416e p: Dict[type, An\n+00059d80: 795d 203d 207b 0a20 2020 2062 6f6f 6c3a y] = {. bool:\n+00059d90: 2042 7573 5479 7065 2e62 6f6f 6c65 616e BusType.boolean\n+00059da0: 2c0a 2020 2020 6279 7465 733a 2042 7573 ,. bytes: Bus\n+00059db0: 5479 7065 2e62 7974 6573 7472 696e 672c Type.bytestring,\n+00059dc0: 0a20 2020 2069 6e74 3a20 4275 7354 7970 . int: BusTyp\n+00059dd0: 652e 696e 7433 322c 0a20 2020 2073 7472 e.int32,. str\n+00059de0: 3a20 4275 7354 7970 652e 7374 7269 6e67 : BusType.string\n+00059df0: 2c0a 2020 2020 5661 7269 616e 743a 2042 ,. Variant: B\n+00059e00: 7573 5479 7065 2e76 6172 6961 6e74 2c0a usType.variant,.\n+00059e10: 7d0a 0a5f 6661 6374 6f72 795f 6d61 703a }.._factory_map:\n+00059e20: 2044 6963 745b 6f62 6a65 6374 2c20 4361 Dict[object, Ca\n+00059e30: 6c6c 6162 6c65 5b2e 2e2e 2c20 5479 7065 llable[..., Type\n+00059e40: 5d5d 203d 207b 0a20 2020 2064 6963 743a ]] = {. dict:\n+00059e50: 2044 6963 7469 6f6e 6172 7954 7970 652c DictionaryType,\n+00059e60: 2044 6963 743a 2044 6963 7469 6f6e 6172 Dict: Dictionar\n+00059e70: 7954 7970 652c 0a20 2020 206c 6973 743a yType,. list:\n+00059e80: 2041 7272 6179 5479 7065 2c20 4c69 7374 ArrayType, List\n+00059e90: 3a20 4172 7261 7954 7970 652c 0a20 2020 : ArrayType,. \n+00059ea0: 2074 7570 6c65 3a20 5374 7275 6374 5479 tuple: StructTy\n+00059eb0: 7065 2c20 5475 706c 653a 2053 7472 7563 pe, Tuple: Struc\n+00059ec0: 7454 7970 652c 0a7d 0a0a 0a40 6675 6e63 tType,.}...@func\n+00059ed0: 746f 6f6c 732e 6c72 755f 6361 6368 6528 tools.lru_cache(\n+00059ee0: 290a 6465 6620 6672 6f6d 5f61 6e6e 6f74 ).def from_annot\n+00059ef0: 6174 696f 6e28 616e 6e6f 7461 7469 6f6e ation(annotation\n+00059f00: 3a20 556e 696f 6e5b 7374 722c 2074 7970 : Union[str, typ\n+00059f10: 652c 2042 7573 5479 7065 5d29 202d 3e20 e, BusType]) -> \n+00059f20: 5479 7065 3a0a 2020 2020 2320 5369 6d70 Type:. # Simp\n+00059f30: 6c65 2050 7974 686f 6e20 7479 7065 730a le Python types.\n+00059f40: 2020 2020 6966 2069 7369 6e73 7461 6e63 if isinstanc\n+00059f50: 6528 616e 6e6f 7461 7469 6f6e 2c20 7374 e(annotation, st\n+00059f60: 7229 3a0a 2020 2020 2020 2020 7479 7065 r):. type\n+00059f70: 7320 3d20 6672 6f6d 5f73 6967 6e61 7475 s = from_signatu\n+00059f80: 7265 2861 6e6e 6f74 6174 696f 6e29 0a20 re(annotation). \n+00059f90: 2020 2020 2020 2069 6620 6c65 6e28 7479 if len(ty\n+00059fa0: 7065 7329 2021 3d20 313a 0a20 2020 2020 pes) != 1:. \n+00059fb0: 2020 2020 2020 2072 6169 7365 2054 7970 raise Typ\n+00059fc0: 6545 7272 6f72 2866 2253 6967 6e61 7475 eError(f\"Signatu\n+00059fd0: 7265 2027 7b61 6e6e 6f74 6174 696f 6e7d re '{annotation}\n+00059fe0: 2720 696e 7661 6c69 6420 6173 2061 2074 ' invalid as a t\n+00059ff0: 7970 6520 7374 7269 6e67 2022 0a20 2020 ype string \". \n+0005a000: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0005a010: 2020 2020 2020 2020 2066 2262 6563 6175 f\"becau\n+0005a020: 7365 2069 7420 6465 7363 7269 6265 7320 se it describes \n+0005a030: 7b6c 656e 2874 7970 6573 297d 2074 7970 {len(types)} typ\n+0005a040: 6573 2c20 6e6f 7420 6f6e 652e 2229 0a20 es, not one.\"). \n+0005a050: 2020 2020 2020 2072 6574 7572 6e20 7479 return ty\n+0005a060: 7065 735b 305d 0a0a 2020 2020 6966 2069 pes[0].. if i\n+0005a070: 7369 6e73 7461 6e63 6528 616e 6e6f 7461 sinstance(annota\n+0005a080: 7469 6f6e 2c20 7479 7065 293a 0a20 2020 tion, type):. \n+0005a090: 2020 2020 2061 6e6e 6f74 6174 696f 6e20 annotation \n+0005a0a0: 3d20 5f62 6173 655f 6571 7569 7661 6c65 = _base_equivale\n+0005a0b0: 6e63 655f 6d61 702e 6765 7428 616e 6e6f nce_map.get(anno\n+0005a0c0: 7461 7469 6f6e 2c20 616e 6e6f 7461 7469 tation, annotati\n+0005a0d0: 6f6e 290a 0a20 2020 2023 204f 7572 206f on).. # Our o\n+0005a0e0: 776e 2042 7573 5479 7065 2074 7970 6573 wn BusType types\n+0005a0f0: 0a20 2020 2069 6620 6973 696e 7374 616e . if isinstan\n+0005a100: 6365 2861 6e6e 6f74 6174 696f 6e2c 2042 ce(annotation, B\n+0005a110: 7573 5479 7065 293a 0a20 2020 2020 2020 usType):. \n+0005a120: 2062 7573 5f74 7970 6520 3d20 7479 7069 bus_type = typi\n+0005a130: 6e67 2e67 6574 5f61 7267 7328 616e 6e6f ng.get_args(anno\n+0005a140: 7461 7469 6f6e 2e76 616c 7565 295b 315d tation.value)[1]\n+0005a150: 0a20 2020 2020 2020 2061 7373 6572 7420 . assert \n+0005a160: 6973 696e 7374 616e 6365 2862 7573 5f74 isinstance(bus_t\n+0005a170: 7970 652c 2054 7970 6529 0a20 2020 2020 ype, Type). \n+0005a180: 2020 2072 6574 7572 6e20 6275 735f 7479 return bus_ty\n+0005a190: 7065 0a0a 2020 2020 2320 436f 6e74 6169 pe.. # Contai\n+0005a1a0: 6e65 7220 7479 7065 730a 2020 2020 7472 ner types. tr\n+0005a1b0: 793a 0a20 2020 2020 2020 2066 6163 746f y:. facto\n+0005a1c0: 7279 203d 205f 6661 6374 6f72 795f 6d61 ry = _factory_ma\n+0005a1d0: 705b 7479 7069 6e67 2e67 6574 5f6f 7269 p[typing.get_ori\n+0005a1e0: 6769 6e28 616e 6e6f 7461 7469 6f6e 295d gin(annotation)]\n+0005a1f0: 0a20 2020 2020 2020 2061 7267 7320 3d20 . args = \n+0005a200: 5b66 726f 6d5f 616e 6e6f 7461 7469 6f6e [from_annotation\n+0005a210: 2861 7267 2920 666f 7220 6172 6720 696e (arg) for arg in\n+0005a220: 2074 7970 696e 672e 6765 745f 6172 6773 typing.get_args\n+0005a230: 2861 6e6e 6f74 6174 696f 6e29 5d0a 2020 (annotation)]. \n+0005a240: 2020 2020 2020 7265 7475 726e 2066 6163 return fac\n+0005a250: 746f 7279 282a 6172 6773 290a 2020 2020 tory(*args). \n+0005a260: 6578 6365 7074 2028 4173 7365 7274 696f except (Assertio\n+0005a270: 6e45 7272 6f72 2c20 4174 7472 6962 7574 nError, Attribut\n+0005a280: 6545 7272 6f72 2c20 4b65 7945 7272 6f72 eError, KeyError\n+0005a290: 2c20 5479 7065 4572 726f 7229 3a0a 2020 , TypeError):. \n+0005a2a0: 2020 2020 2020 7261 6973 6520 5479 7065 raise Type\n+0005a2b0: 4572 726f 7228 6622 4361 6e6e 6f74 2069 Error(f\"Cannot i\n+0005a2c0: 6e74 6572 7072 6574 207b 616e 6e6f 7461 nterpret {annota\n+0005a2d0: 7469 6f6e 7d20 6173 2061 2064 6275 7320 tion} as a dbus \n+0005a2e0: 7479 7065 2229 2066 726f 6d20 4e6f 6e65 type\") from None\n+0005a2f0: 0a0a 0a5f 6261 7365 5f74 7970 6573 7472 ..._base_typestr\n+0005a300: 696e 675f 6d61 703a 2044 6963 745b 7374 ing_map: Dict[st\n+0005a310: 722c 2054 7970 655d 203d 207b 0a20 2020 r, Type] = {. \n+0005a320: 2062 7573 7479 7065 2e74 7970 6573 7472 bustype.typestr\n+0005a330: 696e 673a 2062 7573 7479 7065 2066 6f72 ing: bustype for\n+0005a340: 2062 7573 7479 7065 2069 6e20 2866 726f bustype in (fro\n+0005a350: 6d5f 616e 6e6f 7461 7469 6f6e 2865 6e74 m_annotation(ent\n+0005a360: 7279 2920 666f 7220 656e 7472 7920 696e ry) for entry in\n+0005a370: 2042 7573 5479 7065 290a 7d0a 0a0a 4066 BusType).}...@f\n+0005a380: 756e 6374 6f6f 6c73 2e6c 7275 5f63 6163 unctools.lru_cac\n+0005a390: 6865 2829 0a64 6566 2066 726f 6d5f 7369 he().def from_si\n+0005a3a0: 676e 6174 7572 6528 7369 676e 6174 7572 gnature(signatur\n+0005a3b0: 653a 2073 7472 2920 2d3e 2054 7570 6c65 e: str) -> Tuple\n+0005a3c0: 5b54 7970 652c 202e 2e2e 5d3a 0a20 2020 [Type, ...]:. \n+0005a3d0: 2073 7461 636b 203d 206c 6973 7428 7265 stack = list(re\n+0005a3e0: 7665 7273 6564 2873 6967 6e61 7475 7265 versed(signature\n+0005a3f0: 2929 0a0a 2020 2020 6465 6620 6765 745f )).. def get_\n+0005a400: 6f6e 6528 2920 2d3e 2054 7970 653a 0a20 one() -> Type:. \n+0005a410: 2020 2020 2020 2066 6972 7374 203d 2073 first = s\n+0005a420: 7461 636b 2e70 6f70 2829 0a20 2020 2020 tack.pop(). \n+0005a430: 2020 2069 6620 6669 7273 7420 3d3d 2027 if first == '\n+0005a440: 6127 3a0a 2020 2020 2020 2020 2020 2020 a':. \n+0005a450: 6966 2073 7461 636b 5b2d 315d 203d 3d20 if stack[-1] == \n+0005a460: 2779 273a 0a20 2020 2020 2020 2020 2020 'y':. \n+0005a470: 2020 2020 2066 6972 7374 202b 3d20 7374 first += st\n+0005a480: 6163 6b2e 706f 7028 290a 2020 2020 2020 ack.pop(). \n+0005a490: 2020 2020 2020 656c 6966 2073 7461 636b elif stack\n+0005a4a0: 5b2d 315d 203d 3d20 277b 273a 0a20 2020 [-1] == '{':. \n+0005a4b0: 2020 2020 2020 2020 2020 2020 2073 7461 sta\n+0005a4c0: 636b 2e70 6f70 2829 0a20 2020 2020 2020 ck.pop(). \n+0005a4d0: 2020 2020 2020 2020 2072 6574 7572 6e20 return \n+0005a4e0: 4469 6374 696f 6e61 7279 5479 7065 282a DictionaryType(*\n+0005a4f0: 6765 745f 7365 7665 7261 6c28 277d 2729 get_several('}')\n+0005a500: 290a 2020 2020 2020 2020 2020 2020 656c ). el\n+0005a510: 7365 3a0a 2020 2020 2020 2020 2020 2020 se:. \n+0005a520: 2020 2020 7265 7475 726e 2041 7272 6179 return Array\n+0005a530: 5479 7065 2867 6574 5f6f 6e65 2829 290a Type(get_one()).\n+0005a540: 2020 2020 2020 2020 656c 6966 2066 6972 elif fir\n+0005a550: 7374 203d 3d20 2728 273a 0a20 2020 2020 st == '(':. \n+0005a560: 2020 2020 2020 2072 6574 7572 6e20 5374 return St\n+0005a570: 7275 6374 5479 7065 282a 6765 745f 7365 ructType(*get_se\n+0005a580: 7665 7261 6c28 2729 2729 290a 0a20 2020 veral(')')).. \n+0005a590: 2020 2020 2072 6574 7572 6e20 5f62 6173 return _bas\n+0005a5a0: 655f 7479 7065 7374 7269 6e67 5f6d 6170 e_typestring_map\n+0005a5b0: 5b66 6972 7374 5d0a 0a20 2020 2064 6566 [first].. def\n+0005a5c0: 2067 6574 5f73 6576 6572 616c 2865 6e64 get_several(end\n+0005a5d0: 3a20 7374 7229 202d 3e20 4974 6572 6162 : str) -> Iterab\n+0005a5e0: 6c65 5b54 7970 655d 3a0a 2020 2020 2020 le[Type]:. \n+0005a5f0: 2020 7969 656c 6420 6765 745f 6f6e 6528 yield get_one(\n+0005a600: 290a 2020 2020 2020 2020 7768 696c 6520 ). while \n+0005a610: 7374 6163 6b5b 2d31 5d20 213d 2065 6e64 stack[-1] != end\n+0005a620: 3a0a 2020 2020 2020 2020 2020 2020 7969 :. yi\n+0005a630: 656c 6420 6765 745f 6f6e 6528 290a 2020 eld get_one(). \n+0005a640: 2020 2020 2020 7374 6163 6b2e 706f 7028 stack.pop(\n+0005a650: 290a 0a20 2020 2064 6566 2067 6574 5f61 ).. def get_a\n+0005a660: 6c6c 2829 202d 3e20 4974 6572 6162 6c65 ll() -> Iterable\n+0005a670: 5b54 7970 655d 3a0a 2020 2020 2020 2020 [Type]:. \n+0005a680: 7768 696c 6520 7374 6163 6b3a 0a20 2020 while stack:. \n+0005a690: 2020 2020 2020 2020 2079 6965 6c64 2067 yield g\n+0005a6a0: 6574 5f6f 6e65 2829 0a0a 2020 2020 7472 et_one().. tr\n+0005a6b0: 793a 0a20 2020 2020 2020 2072 6574 7572 y:. retur\n+0005a6c0: 6e20 7475 706c 6528 6765 745f 616c 6c28 n tuple(get_all(\n+0005a6d0: 2929 0a20 2020 2065 7863 6570 7420 2841 )). except (A\n+0005a6e0: 7373 6572 7469 6f6e 4572 726f 722c 2049 ssertionError, I\n+0005a6f0: 6e64 6578 4572 726f 722c 204b 6579 4572 ndexError, KeyEr\n+0005a700: 726f 7229 2061 7320 6578 633a 0a20 2020 ror) as exc:. \n+0005a710: 2020 2020 2072 6169 7365 2054 7970 6545 raise TypeE\n+0005a720: 7272 6f72 2866 2249 6e76 616c 6964 2074 rror(f\"Invalid t\n+0005a730: 7970 6520 7369 676e 6174 7572 6520 277b ype signature '{\n+0005a740: 7369 676e 6174 7572 657d 2722 2920 6672 signature}'\") fr\n+0005a750: 6f6d 2065 7863 0a0a 0a63 6c61 7373 204d om exc...class M\n+0005a760: 6573 7361 6765 5479 7065 3a0a 2020 2020 essageType:. \n+0005a770: 6974 656d 5f74 7970 6573 3a20 5365 7175 item_types: Sequ\n+0005a780: 656e 6365 5b54 7970 655d 0a20 2020 2074 ence[Type]. t\n+0005a790: 7970 6573 7472 696e 6773 3a20 4c69 7374 ypestrings: List\n+0005a7a0: 5b73 7472 5d0a 2020 2020 7369 676e 6174 [str]. signat\n+0005a7b0: 7572 653a 2073 7472 0a0a 2020 2020 6465 ure: str.. de\n+0005a7c0: 6620 5f5f 696e 6974 5f5f 2873 656c 662c f __init__(self,\n+0005a7d0: 2069 7465 6d5f 7479 7065 733a 2053 6571 item_types: Seq\n+0005a7e0: 7565 6e63 655b 556e 696f 6e5b 7374 722c uence[Union[str,\n+0005a7f0: 2074 7970 652c 2042 7573 5479 7065 5d5d type, BusType]]\n+0005a800: 293a 0a20 2020 2020 2020 2073 656c 662e ):. self.\n+0005a810: 6974 656d 5f74 7970 6573 203d 205b 6672 item_types = [fr\n+0005a820: 6f6d 5f61 6e6e 6f74 6174 696f 6e28 6974 om_annotation(it\n+0005a830: 656d 5f74 7970 6529 2066 6f72 2069 7465 em_type) for ite\n+0005a840: 6d5f 7479 7065 2069 6e20 6974 656d 5f74 m_type in item_t\n+0005a850: 7970 6573 5d0a 2020 2020 2020 2020 7365 ypes]. se\n+0005a860: 6c66 2e74 7970 6573 7472 696e 6773 203d lf.typestrings =\n+0005a870: 205b 6974 656d 5f74 7970 652e 7479 7065 [item_type.type\n+0005a880: 7374 7269 6e67 2066 6f72 2069 7465 6d5f string for item_\n+0005a890: 7479 7065 2069 6e20 7365 6c66 2e69 7465 type in self.ite\n+0005a8a0: 6d5f 7479 7065 735d 0a20 2020 2020 2020 m_types]. \n+0005a8b0: 2073 656c 662e 7369 676e 6174 7572 6520 self.signature \n+0005a8c0: 3d20 2727 2e6a 6f69 6e28 7365 6c66 2e74 = ''.join(self.t\n+0005a8d0: 7970 6573 7472 696e 6773 290a 0a20 2020 ypestrings).. \n+0005a8e0: 2064 6566 2077 7269 7465 2873 656c 662c def write(self,\n+0005a8f0: 206d 6573 7361 6765 3a20 6c69 6273 7973 message: libsys\n+0005a900: 7465 6d64 2e73 645f 6275 735f 6d65 7373 temd.sd_bus_mess\n+0005a910: 6167 652c 202a 6974 656d 733a 206f 626a age, *items: obj\n+0005a920: 6563 7429 202d 3e20 4e6f 6e65 3a0a 2020 ect) -> None:. \n+0005a930: 2020 2020 2020 6173 7365 7274 206c 656e assert len\n+0005a940: 2869 7465 6d73 2920 3d3d 206c 656e 2873 (items) == len(s\n+0005a950: 656c 662e 6974 656d 5f74 7970 6573 290a elf.item_types).\n+0005a960: 2020 2020 2020 2020 666f 7220 6974 656d for item\n+0005a970: 5f74 7970 652c 2069 7465 6d20 696e 207a _type, item in z\n+0005a980: 6970 2873 656c 662e 6974 656d 5f74 7970 ip(self.item_typ\n+0005a990: 6573 2c20 6974 656d 7329 3a0a 2020 2020 es, items):. \n+0005a9a0: 2020 2020 2020 2020 6974 656d 5f74 7970 item_typ\n+0005a9b0: 652e 7772 6974 6572 286d 6573 7361 6765 e.writer(message\n+0005a9c0: 2c20 6974 656d 290a 0a20 2020 2064 6566 , item).. def\n+0005a9d0: 2072 6561 6428 7365 6c66 2c20 6d65 7373 read(self, mess\n+0005a9e0: 6167 653a 206c 6962 7379 7374 656d 642e age: libsystemd.\n+0005a9f0: 7364 5f62 7573 5f6d 6573 7361 6765 2920 sd_bus_message) \n+0005aa00: 2d3e 204f 7074 696f 6e61 6c5b 5475 706c -> Optional[Tupl\n+0005aa10: 655b 6f62 6a65 6374 2c20 2e2e 2e5d 5d3a e[object, ...]]:\n+0005aa20: 0a20 2020 2020 2020 2069 6620 6e6f 7420 . if not \n+0005aa30: 6d65 7373 6167 652e 6861 735f 7369 676e message.has_sign\n+0005aa40: 6174 7572 6528 7365 6c66 2e73 6967 6e61 ature(self.signa\n+0005aa50: 7475 7265 293a 0a20 2020 2020 2020 2020 ture):. \n+0005aa60: 2020 2072 6574 7572 6e20 4e6f 6e65 0a20 return None. \n+0005aa70: 2020 2020 2020 2072 6574 7572 6e20 7475 return tu\n+0005aa80: 706c 6528 6974 656d 5f74 7970 652e 7265 ple(item_type.re\n+0005aa90: 6164 6572 286d 6573 7361 6765 2920 666f ader(message) fo\n+0005aaa0: 7220 6974 656d 5f74 7970 6520 696e 2073 r item_type in s\n+0005aab0: 656c 662e 6974 656d 5f74 7970 6573 290a elf.item_types).\n+0005aac0: 0a20 2020 2064 6566 205f 5f6c 656e 5f5f . def __len__\n+0005aad0: 2873 656c 6629 202d 3e20 696e 743a 0a20 (self) -> int:. \n+0005aae0: 2020 2020 2020 2072 6574 7572 6e20 6c65 return le\n+0005aaf0: 6e28 7365 6c66 2e69 7465 6d5f 7479 7065 n(self.item_type\n+0005ab00: 7329 0a0a 0a63 6c61 7373 204a 534f 4e45 s)...class JSONE\n+0005ab10: 6e63 6f64 6572 286a 736f 6e2e 4a53 4f4e ncoder(json.JSON\n+0005ab20: 456e 636f 6465 7229 3a0a 2020 2020 6465 Encoder):. de\n+0005ab30: 6620 6465 6661 756c 7428 7365 6c66 2c20 f default(self, \n+0005ab40: 6f62 6a3a 206f 626a 6563 7429 202d 3e20 obj: object) -> \n+0005ab50: 6f62 6a65 6374 3a0a 2020 2020 2020 2020 object:. \n+0005ab60: 6966 2069 7369 6e73 7461 6e63 6528 6f62 if isinstance(ob\n+0005ab70: 6a2c 2056 6172 6961 6e74 293a 0a20 2020 j, Variant):. \n+0005ab80: 2020 2020 2020 2020 2072 6574 7572 6e20 return \n+0005ab90: 7b22 7422 3a20 6f62 6a2e 7479 7065 2e74 {\"t\": obj.type.t\n+0005aba0: 7970 6573 7472 696e 672c 2022 7622 3a20 ypestring, \"v\": \n+0005abb0: 6f62 6a2e 7661 6c75 657d 0a20 2020 2020 obj.value}. \n+0005abc0: 2020 2065 6c69 6620 6973 696e 7374 616e elif isinstan\n+0005abd0: 6365 286f 626a 2c20 6279 7465 7329 3a0a ce(obj, bytes):.\n+0005abe0: 2020 2020 2020 2020 2020 2020 7265 7475 retu\n+0005abf0: 726e 2062 696e 6173 6369 692e 6232 615f rn binascii.b2a_\n+0005ac00: 6261 7365 3634 286f 626a 2c20 6e65 776c base64(obj, newl\n+0005ac10: 696e 653d 4661 6c73 6529 2e64 6563 6f64 ine=False).decod\n+0005ac20: 6528 2761 7363 6969 2729 0a20 2020 2020 e('ascii'). \n+0005ac30: 2020 2072 6574 7572 6e20 7375 7065 7228 return super(\n+0005ac40: 292e 6465 6661 756c 7428 6f62 6a29 0a27 ).default(obj).'\n+0005ac50: 2727 2c0a 2020 2763 6f63 6b70 6974 2f5f '',. 'cockpit/_\n+0005ac60: 7665 6e64 6f72 2f66 6572 6e79 2f5f 5f69 vendor/ferny/__i\n+0005ac70: 6e69 745f 5f2e 7079 273a 2062 7227 2727 nit__.py': br'''\n+0005ac80: 6672 6f6d 202e 696e 7465 7261 6374 696f from .interactio\n+0005ac90: 6e5f 6167 656e 7420 696d 706f 7274 2028 n_agent import (\n+0005aca0: 0a20 2020 2042 4549 424f 4f54 5f47 4144 . BEIBOOT_GAD\n+0005acb0: 4745 5453 2c0a 2020 2020 434f 4d4d 414e GETS,. COMMAN\n+0005acc0: 445f 5445 4d50 4c41 5445 2c0a 2020 2020 D_TEMPLATE,. \n+0005acd0: 4173 6b70 6173 7348 616e 646c 6572 2c0a AskpassHandler,.\n+0005ace0: 2020 2020 496e 7465 7261 6374 696f 6e41 InteractionA\n+0005acf0: 6765 6e74 2c0a 2020 2020 496e 7465 7261 gent,. Intera\n+0005ad00: 6374 696f 6e45 7272 6f72 2c0a 2020 2020 ctionError,. \n+0005ad10: 496e 7465 7261 6374 696f 6e48 616e 646c InteractionHandl\n+0005ad20: 6572 2c0a 2020 2020 7465 6d70 6f72 6172 er,. temporar\n+0005ad30: 795f 6173 6b70 6173 732c 0a20 2020 2077 y_askpass,. w\n+0005ad40: 7269 7465 5f61 736b 7061 7373 5f74 6f5f rite_askpass_to_\n+0005ad50: 746d 7064 6972 2c0a 290a 6672 6f6d 202e tmpdir,.).from .\n+0005ad60: 7365 7373 696f 6e20 696d 706f 7274 2053 session import S\n+0005ad70: 6573 7369 6f6e 0a66 726f 6d20 2e73 7368 ession.from .ssh\n+0005ad80: 5f61 736b 7061 7373 2069 6d70 6f72 7420 _askpass import \n+0005ad90: 280a 2020 2020 4173 6b70 6173 7350 726f (. AskpassPro\n+0005ada0: 6d70 742c 0a20 2020 2053 7368 4173 6b70 mpt,. SshAskp\n+0005adb0: 6173 7352 6573 706f 6e64 6572 2c0a 2020 assResponder,. \n+0005adc0: 2020 5373 6846 4944 4f50 494e 5072 6f6d SshFIDOPINProm\n+0005add0: 7074 2c0a 2020 2020 5373 6846 4944 4f55 pt,. SshFIDOU\n+0005ade0: 7365 7250 7265 7365 6e63 6550 726f 6d70 serPresencePromp\n+0005adf0: 742c 0a20 2020 2053 7368 486f 7374 4b65 t,. SshHostKe\n+0005ae00: 7950 726f 6d70 742c 0a20 2020 2053 7368 yPrompt,. Ssh\n+0005ae10: 5061 7373 7068 7261 7365 5072 6f6d 7074 PassphrasePrompt\n+0005ae20: 2c0a 2020 2020 5373 6850 6173 7377 6f72 ,. SshPasswor\n+0005ae30: 6450 726f 6d70 742c 0a20 2020 2053 7368 dPrompt,. Ssh\n+0005ae40: 504b 4353 3131 5049 4e50 726f 6d70 742c PKCS11PINPrompt,\n+0005ae50: 0a29 0a66 726f 6d20 2e73 7368 5f65 7272 .).from .ssh_err\n+0005ae60: 6f72 7320 696d 706f 7274 2028 0a20 2020 ors import (. \n+0005ae70: 2053 7368 4175 7468 656e 7469 6361 7469 SshAuthenticati\n+0005ae80: 6f6e 4572 726f 722c 0a20 2020 2053 7368 onError,. Ssh\n+0005ae90: 4368 616e 6765 6448 6f73 744b 6579 4572 ChangedHostKeyEr\n+0005aea0: 726f 722c 0a20 2020 2053 7368 4572 726f ror,. SshErro\n+0005aeb0: 722c 0a20 2020 2053 7368 486f 7374 4b65 r,. SshHostKe\n+0005aec0: 7945 7272 6f72 2c0a 2020 2020 5373 6855 yError,. SshU\n+0005aed0: 6e6b 6e6f 776e 486f 7374 4b65 7945 7272 nknownHostKeyErr\n+0005aee0: 6f72 2c0a 290a 6672 6f6d 202e 7472 616e or,.).from .tran\n+0005aef0: 7370 6f72 7420 696d 706f 7274 2046 6572 sport import Fer\n+0005af00: 6e79 5472 616e 7370 6f72 742c 2053 7562 nyTransport, Sub\n+0005af10: 7072 6f63 6573 7345 7272 6f72 0a0a 5f5f processError..__\n+0005af20: 616c 6c5f 5f20 3d20 5b0a 2020 2020 2741 all__ = [. 'A\n+0005af30: 736b 7061 7373 4861 6e64 6c65 7227 2c0a skpassHandler',.\n+0005af40: 2020 2020 2741 736b 7061 7373 5072 6f6d 'AskpassProm\n+0005af50: 7074 272c 0a20 2020 2027 4175 7468 656e pt',. 'Authen\n+0005af60: 7469 6361 7469 6f6e 4572 726f 7227 2c0a ticationError',.\n+0005af70: 2020 2020 2742 4549 424f 4f54 5f47 4144 'BEIBOOT_GAD\n+0005af80: 4745 5453 272c 0a20 2020 2027 434f 4d4d GETS',. 'COMM\n+0005af90: 414e 445f 5445 4d50 4c41 5445 272c 0a20 AND_TEMPLATE',. \n+0005afa0: 2020 2027 4368 616e 6765 6448 6f73 744b 'ChangedHostK\n+0005afb0: 6579 4572 726f 7227 2c0a 2020 2020 2746 eyError',. 'F\n+0005afc0: 6572 6e79 5472 616e 7370 6f72 7427 2c0a ernyTransport',.\n+0005afd0: 2020 2020 2748 6f73 744b 6579 4572 726f 'HostKeyErro\n+0005afe0: 7227 2c0a 2020 2020 2749 6e74 6572 6163 r',. 'Interac\n+0005aff0: 7469 6f6e 4167 656e 7427 2c0a 2020 2020 tionAgent',. \n+0005b000: 2749 6e74 6572 6163 7469 6f6e 4572 726f 'InteractionErro\n+0005b010: 7227 2c0a 2020 2020 2749 6e74 6572 6163 r',. 'Interac\n+0005b020: 7469 6f6e 4861 6e64 6c65 7227 2c0a 2020 tionHandler',. \n+0005b030: 2020 2753 6573 7369 6f6e 272c 0a20 2020 'Session',. \n+0005b040: 2027 5373 6841 736b 7061 7373 5265 7370 'SshAskpassResp\n+0005b050: 6f6e 6465 7227 2c0a 2020 2020 2753 7368 onder',. 'Ssh\n+0005b060: 4175 7468 656e 7469 6361 7469 6f6e 4572 AuthenticationEr\n+0005b070: 726f 7227 2c0a 2020 2020 2753 7368 4368 ror',. 'SshCh\n+0005b080: 616e 6765 6448 6f73 744b 6579 4572 726f angedHostKeyErro\n+0005b090: 7227 2c0a 2020 2020 2753 7368 4572 726f r',. 'SshErro\n+0005b0a0: 7227 2c0a 2020 2020 2753 7368 4649 444f r',. 'SshFIDO\n+0005b0b0: 5049 4e50 726f 6d70 7427 2c0a 2020 2020 PINPrompt',. \n+0005b0c0: 2753 7368 4649 444f 5573 6572 5072 6573 'SshFIDOUserPres\n+0005b0d0: 656e 6365 5072 6f6d 7074 272c 0a20 2020 encePrompt',. \n+0005b0e0: 2027 5373 6848 6f73 744b 6579 4572 726f 'SshHostKeyErro\n+0005b0f0: 7227 2c0a 2020 2020 2753 7368 486f 7374 r',. 'SshHost\n+0005b100: 4b65 7950 726f 6d70 7427 2c0a 2020 2020 KeyPrompt',. \n+0005b110: 2753 7368 504b 4353 3131 5049 4e50 726f 'SshPKCS11PINPro\n+0005b120: 6d70 7427 2c0a 2020 2020 2753 7368 5061 mpt',. 'SshPa\n+0005b130: 7373 7068 7261 7365 5072 6f6d 7074 272c ssphrasePrompt',\n+0005b140: 0a20 2020 2027 5373 6850 6173 7377 6f72 . 'SshPasswor\n+0005b150: 6450 726f 6d70 7427 2c0a 2020 2020 2753 dPrompt',. 'S\n+0005b160: 7368 556e 6b6e 6f77 6e48 6f73 744b 6579 shUnknownHostKey\n+0005b170: 4572 726f 7227 2c0a 2020 2020 2753 7562 Error',. 'Sub\n+0005b180: 7072 6f63 6573 7345 7272 6f72 272c 0a20 processError',. \n+0005b190: 2020 2027 7465 6d70 6f72 6172 795f 6173 'temporary_as\n+0005b1a0: 6b70 6173 7327 2c0a 2020 2020 2777 7269 kpass',. 'wri\n+0005b1b0: 7465 5f61 736b 7061 7373 5f74 6f5f 746d te_askpass_to_tm\n+0005b1c0: 7064 6972 272c 0a5d 0a0a 5f5f 7665 7273 pdir',.]..__vers\n+0005b1d0: 696f 6e5f 5f20 3d20 2730 270a 2727 272c ion__ = '0'.''',\n+0005b1e0: 0a20 2027 636f 636b 7069 742f 5f76 656e . 'cockpit/_ven\n+0005b1f0: 646f 722f 6665 726e 792f 696e 7465 7261 dor/ferny/intera\n+0005b200: 6374 696f 6e5f 6167 656e 742e 7079 273a ction_agent.py':\n+0005b210: 2072 2727 2723 2066 6572 6e79 202d 2061 r'''# ferny - a\n+0005b220: 7379 6e63 696f 2053 5348 2063 6c69 656e syncio SSH clien\n+0005b230: 7420 6c69 6272 6172 792c 2075 7369 6e67 t library, using\n+0005b240: 2073 7368 2831 290a 230a 2320 436f 7079 ssh(1).#.# Copy\n+0005b250: 7269 6768 7420 2843 2920 3230 3233 2041 right (C) 2023 A\n+0005b260: 6c6c 6973 6f6e 204b 6172 6c69 7473 6b61 llison Karlitska\n+0005b270: 7961 203c 616c 6c69 736f 6e2e 6b61 726c ya .#.# This pro\n+0005b2a0: 6772 616d 2069 7320 6672 6565 2073 6f66 gram is free sof\n+0005b2b0: 7477 6172 653a 2079 6f75 2063 616e 2072 tware: you can r\n+0005b2c0: 6564 6973 7472 6962 7574 6520 6974 2061 edistribute it a\n+0005b2d0: 6e64 2f6f 7220 6d6f 6469 6679 0a23 2069 nd/or modify.# i\n+0005b2e0: 7420 756e 6465 7220 7468 6520 7465 726d t under the term\n+0005b2f0: 7320 6f66 2074 6865 2047 4e55 2047 656e s of the GNU Gen\n+0005b300: 6572 616c 2050 7562 6c69 6320 4c69 6365 eral Public Lice\n+0005b310: 6e73 6520 6173 2070 7562 6c69 7368 6564 nse as published\n+0005b320: 2062 790a 2320 7468 6520 4672 6565 2053 by.# the Free S\n+0005b330: 6f66 7477 6172 6520 466f 756e 6461 7469 oftware Foundati\n+0005b340: 6f6e 2c20 6569 7468 6572 2076 6572 7369 on, either versi\n+0005b350: 6f6e 2033 206f 6620 7468 6520 4c69 6365 on 3 of the Lice\n+0005b360: 6e73 652c 206f 720a 2320 2861 7420 796f nse, or.# (at yo\n+0005b370: 7572 206f 7074 696f 6e29 2061 6e79 206c ur option) any l\n+0005b380: 6174 6572 2076 6572 7369 6f6e 2e0a 230a ater version..#.\n+0005b390: 2320 5468 6973 2070 726f 6772 616d 2069 # This program i\n+0005b3a0: 7320 6469 7374 7269 6275 7465 6420 696e s distributed in\n+0005b3b0: 2074 6865 2068 6f70 6520 7468 6174 2069 the hope that i\n+0005b3c0: 7420 7769 6c6c 2062 6520 7573 6566 756c t will be useful\n+0005b3d0: 2c0a 2320 6275 7420 5749 5448 4f55 5420 ,.# but WITHOUT \n+0005b3e0: 414e 5920 5741 5252 414e 5459 3b20 7769 ANY WARRANTY; wi\n+0005b3f0: 7468 6f75 7420 6576 656e 2074 6865 2069 thout even the i\n+0005b400: 6d70 6c69 6564 2077 6172 7261 6e74 7920 mplied warranty \n+0005b410: 6f66 0a23 204d 4552 4348 414e 5441 4249 of.# MERCHANTABI\n+0005b420: 4c49 5459 206f 7220 4649 544e 4553 5320 LITY or FITNESS \n+0005b430: 464f 5220 4120 5041 5254 4943 554c 4152 FOR A PARTICULAR\n+0005b440: 2050 5552 504f 5345 2e20 2053 6565 2074 PURPOSE. See t\n+0005b450: 6865 0a23 2047 4e55 2047 656e 6572 616c he.# GNU General\n+0005b460: 2050 7562 6c69 6320 4c69 6365 6e73 6520 Public License \n+0005b470: 666f 7220 6d6f 7265 2064 6574 6169 6c73 for more details\n+0005b480: 2e0a 230a 2320 596f 7520 7368 6f75 6c64 ..#.# You should\n+0005b490: 2068 6176 6520 7265 6365 6976 6564 2061 have received a\n+0005b4a0: 2063 6f70 7920 6f66 2074 6865 2047 4e55 copy of the GNU\n+0005b4b0: 2047 656e 6572 616c 2050 7562 6c69 6320 General Public \n+0005b4c0: 4c69 6365 6e73 650a 2320 616c 6f6e 6720 License.# along \n+0005b4d0: 7769 7468 2074 6869 7320 7072 6f67 7261 with this progra\n+0005b4e0: 6d2e 2020 4966 206e 6f74 2c20 7365 6520 m. If not, see \n+0005b4f0: 3c68 7474 703a 2f2f 7777 772e 676e 752e ..\n+0005b510: 0a69 6d70 6f72 7420 6172 7261 790a 696d .import array.im\n+0005b520: 706f 7274 2061 7374 0a69 6d70 6f72 7420 port ast.import \n+0005b530: 6173 796e 6369 6f0a 696d 706f 7274 2063 asyncio.import c\n+0005b540: 6f6e 7465 7874 6c69 620a 696d 706f 7274 ontextlib.import\n+0005b550: 206c 6f67 6769 6e67 0a69 6d70 6f72 7420 logging.import \n+0005b560: 6f73 0a69 6d70 6f72 7420 7265 0a69 6d70 os.import re.imp\n+0005b570: 6f72 7420 736f 636b 6574 0a69 6d70 6f72 ort socket.impor\n+0005b580: 7420 7465 6d70 6669 6c65 0a66 726f 6d20 t tempfile.from \n+0005b590: 7479 7069 6e67 2069 6d70 6f72 7420 416e typing import An\n+0005b5a0: 792c 2043 616c 6c61 626c 652c 2043 6c61 y, Callable, Cla\n+0005b5b0: 7373 5661 722c 2047 656e 6572 6174 6f72 ssVar, Generator\n+0005b5c0: 2c20 5365 7175 656e 6365 0a0a 6672 6f6d , Sequence..from\n+0005b5d0: 202e 2069 6d70 6f72 7420 696e 7465 7261 . import intera\n+0005b5e0: 6374 696f 6e5f 636c 6965 6e74 0a0a 6c6f ction_client..lo\n+0005b5f0: 6767 6572 203d 206c 6f67 6769 6e67 2e67 gger = logging.g\n+0005b600: 6574 4c6f 6767 6572 285f 5f6e 616d 655f etLogger(__name_\n+0005b610: 5f29 0a0a 0a43 4f4d 4d41 4e44 5f52 4520 _)...COMMAND_RE \n+0005b620: 3d20 7265 2e63 6f6d 7069 6c65 2862 275c = re.compile(b'\\\n+0005b630: 3066 6572 6e79 5c30 285b 5e5c 6e5d 2a29 0ferny\\0([^\\n]*)\n+0005b640: 5c30 5c30 5c6e 2729 0a43 4f4d 4d41 4e44 \\0\\0\\n').COMMAND\n+0005b650: 5f54 454d 504c 4154 4520 3d20 275c 3066 _TEMPLATE = '\\0f\n+0005b660: 6572 6e79 5c30 7b28 636f 6d6d 616e 642c erny\\0{(command,\n+0005b670: 2061 7267 7329 2172 7d5c 305c 305c 6e27 args)!r}\\0\\0\\n'\n+0005b680: 0a0a 4245 4942 4f4f 545f 4741 4447 4554 ..BEIBOOT_GADGET\n+0005b690: 5320 3d20 7b0a 2020 2020 2263 6f6d 6d61 S = {. \"comma\n+0005b6a0: 6e64 223a 2066 7222 2222 0a20 2020 2020 nd\": fr\"\"\". \n+0005b6b0: 2020 2069 6d70 6f72 7420 7379 730a 2020 import sys. \n+0005b6c0: 2020 2020 2020 6465 6620 636f 6d6d 616e def comman\n+0005b6d0: 6428 636f 6d6d 616e 642c 202a 6172 6773 d(command, *args\n+0005b6e0: 293a 0a20 2020 2020 2020 2020 2020 2073 ):. s\n+0005b6f0: 7973 2e73 7464 6572 722e 7772 6974 6528 ys.stderr.write(\n+0005b700: 667b 434f 4d4d 414e 445f 5445 4d50 4c41 f{COMMAND_TEMPLA\n+0005b710: 5445 2172 7d29 0a20 2020 2020 2020 2020 TE!r}). \n+0005b720: 2020 2073 7973 2e73 7464 6572 722e 666c sys.stderr.fl\n+0005b730: 7573 6828 290a 2020 2020 2222 222c 0a20 ush(). \"\"\",. \n+0005b740: 2020 2022 656e 6422 3a20 7222 2222 0a20 \"end\": r\"\"\". \n+0005b750: 2020 2020 2020 2064 6566 2065 6e64 2829 def end()\n+0005b760: 3a0a 2020 2020 2020 2020 2020 2020 636f :. co\n+0005b770: 6d6d 616e 6428 2766 6572 6e79 2e65 6e64 mmand('ferny.end\n+0005b780: 2729 0a20 2020 2022 2222 2c0a 7d0a 0a0a '). \"\"\",.}...\n+0005b790: 636c 6173 7320 496e 7465 7261 6374 696f class Interactio\n+0005b7a0: 6e45 7272 6f72 2845 7863 6570 7469 6f6e nError(Exception\n+0005b7b0: 293a 0a20 2020 2070 6173 730a 0a0a 7472 ):. pass...tr\n+0005b7c0: 793a 0a20 2020 2072 6563 765f 6664 7320 y:. recv_fds \n+0005b7d0: 3d20 736f 636b 6574 2e72 6563 765f 6664 = socket.recv_fd\n+0005b7e0: 730a 6578 6365 7074 2041 7474 7269 6275 s.except Attribu\n+0005b7f0: 7465 4572 726f 723a 0a20 2020 2023 2050 teError:. # P\n+0005b800: 7974 686f 6e20 3c20 332e 390a 0a20 2020 ython < 3.9.. \n+0005b810: 2064 6566 2072 6563 765f 6664 7328 0a20 def recv_fds(. \n+0005b820: 2020 2020 2020 2073 6f63 6b3a 2073 6f63 sock: soc\n+0005b830: 6b65 742e 736f 636b 6574 2c20 6275 6673 ket.socket, bufs\n+0005b840: 697a 653a 2069 6e74 2c20 6d61 7866 6473 ize: int, maxfds\n+0005b850: 3a20 696e 742c 2066 6c61 6773 3a20 696e : int, flags: in\n+0005b860: 7420 3d20 300a 2020 2020 2920 2d3e 2027 t = 0. ) -> '\n+0005b870: 7475 706c 655b 6279 7465 732c 206c 6973 tuple[bytes, lis\n+0005b880: 745b 696e 745d 2c20 696e 742c 204e 6f6e t[int], int, Non\n+0005b890: 655d 273a 0a20 2020 2020 2020 2066 6473 e]':. fds\n+0005b8a0: 203d 2061 7272 6179 2e61 7272 6179 2822 = array.array(\"\n+0005b8b0: 6922 290a 2020 2020 2020 2020 6d73 672c i\"). msg,\n+0005b8c0: 2061 6e63 6461 7461 2c20 666c 6167 732c ancdata, flags,\n+0005b8d0: 2061 6464 7220 3d20 736f 636b 2e72 6563 addr = sock.rec\n+0005b8e0: 766d 7367 2862 7566 7369 7a65 2c20 736f vmsg(bufsize, so\n+0005b8f0: 636b 6574 2e43 4d53 475f 4c45 4e28 6d61 cket.CMSG_LEN(ma\n+0005b900: 7866 6473 202a 2066 6473 2e69 7465 6d73 xfds * fds.items\n+0005b910: 697a 6529 290a 2020 2020 2020 2020 666f ize)). fo\n+0005b920: 7220 636d 7367 5f6c 6576 656c 2c20 636d r cmsg_level, cm\n+0005b930: 7367 5f74 7970 652c 2063 6d73 675f 6461 sg_type, cmsg_da\n+0005b940: 7461 2069 6e20 616e 6364 6174 613a 0a20 ta in ancdata:. \n+0005b950: 2020 2020 2020 2020 2020 2069 6620 2863 if (c\n+0005b960: 6d73 675f 6c65 7665 6c20 3d3d 2073 6f63 msg_level == soc\n+0005b970: 6b65 742e 534f 4c5f 534f 434b 4554 2061 ket.SOL_SOCKET a\n+0005b980: 6e64 2063 6d73 675f 7479 7065 203d 3d20 nd cmsg_type == \n+0005b990: 736f 636b 6574 2e53 434d 5f52 4947 4854 socket.SCM_RIGHT\n+0005b9a0: 5329 3a0a 2020 2020 2020 2020 2020 2020 S):. \n+0005b9b0: 2020 2020 6664 732e 6672 6f6d 6279 7465 fds.frombyte\n+0005b9c0: 7328 636d 7367 5f64 6174 615b 3a6c 656e s(cmsg_data[:len\n+0005b9d0: 2863 6d73 675f 6461 7461 2920 2d20 286c (cmsg_data) - (l\n+0005b9e0: 656e 2863 6d73 675f 6461 7461 2920 2520 en(cmsg_data) % \n+0005b9f0: 6664 732e 6974 656d 7369 7a65 295d 290a fds.itemsize)]).\n+0005ba00: 2020 2020 2020 2020 7265 7475 726e 206d return m\n+0005ba10: 7367 2c20 6c69 7374 2866 6473 292c 2066 sg, list(fds), f\n+0005ba20: 6c61 6773 2c20 6164 6472 0a0a 0a64 6566 lags, addr...def\n+0005ba30: 2067 6574 5f72 756e 6e69 6e67 5f6c 6f6f get_running_loo\n+0005ba40: 7028 2920 2d3e 2061 7379 6e63 696f 2e41 p() -> asyncio.A\n+0005ba50: 6273 7472 6163 7445 7665 6e74 4c6f 6f70 bstractEventLoop\n+0005ba60: 3a0a 2020 2020 7472 793a 0a20 2020 2020 :. try:. \n+0005ba70: 2020 2072 6574 7572 6e20 6173 796e 6369 return asynci\n+0005ba80: 6f2e 6765 745f 7275 6e6e 696e 675f 6c6f o.get_running_lo\n+0005ba90: 6f70 2829 0a20 2020 2065 7863 6570 7420 op(). except \n+0005baa0: 4174 7472 6962 7574 6545 7272 6f72 3a0a AttributeError:.\n+0005bab0: 2020 2020 2020 2020 2320 5079 7468 6f6e # Python\n+0005bac0: 2033 2e36 0a20 2020 2020 2020 2072 6574 3.6. ret\n+0005bad0: 7572 6e20 6173 796e 6369 6f2e 6765 745f urn asyncio.get_\n+0005bae0: 6576 656e 745f 6c6f 6f70 2829 0a0a 0a63 event_loop()...c\n+0005baf0: 6c61 7373 2049 6e74 6572 6163 7469 6f6e lass Interaction\n+0005bb00: 4861 6e64 6c65 723a 0a20 2020 2063 6f6d Handler:. com\n+0005bb10: 6d61 6e64 733a 2043 6c61 7373 5661 725b mands: ClassVar[\n+0005bb20: 5365 7175 656e 6365 5b73 7472 5d5d 0a0a Sequence[str]]..\n+0005bb30: 2020 2020 6173 796e 6320 6465 6620 7275 async def ru\n+0005bb40: 6e5f 636f 6d6d 616e 6428 7365 6c66 2c20 n_command(self, \n+0005bb50: 636f 6d6d 616e 643a 2073 7472 2c20 6172 command: str, ar\n+0005bb60: 6773 3a20 2774 7570 6c65 5b6f 626a 6563 gs: 'tuple[objec\n+0005bb70: 742c 202e 2e2e 5d27 2c20 6664 733a 2027 t, ...]', fds: '\n+0005bb80: 6c69 7374 5b69 6e74 5d27 2c20 7374 6465 list[int]', stde\n+0005bb90: 7272 3a20 7374 7229 202d 3e20 4e6f 6e65 rr: str) -> None\n+0005bba0: 3a0a 2020 2020 2020 2020 7261 6973 6520 :. raise \n+0005bbb0: 4e6f 7449 6d70 6c65 6d65 6e74 6564 4572 NotImplementedEr\n+0005bbc0: 726f 720a 0a0a 636c 6173 7320 4173 6b70 ror...class Askp\n+0005bbd0: 6173 7348 616e 646c 6572 2849 6e74 6572 assHandler(Inter\n+0005bbe0: 6163 7469 6f6e 4861 6e64 6c65 7229 3a0a actionHandler):.\n+0005bbf0: 2020 2020 636f 6d6d 616e 6473 3a20 436c commands: Cl\n+0005bc00: 6173 7356 6172 5b53 6571 7565 6e63 655b assVar[Sequence[\n+0005bc10: 7374 725d 5d20 3d20 2827 6665 726e 792e str]] = ('ferny.\n+0005bc20: 6173 6b70 6173 7327 2c29 0a0a 2020 2020 askpass',).. \n+0005bc30: 6173 796e 6320 6465 6620 646f 5f61 736b async def do_ask\n+0005bc40: 7061 7373 2873 656c 662c 206d 6573 7361 pass(self, messa\n+0005bc50: 6765 733a 2073 7472 2c20 7072 6f6d 7074 ges: str, prompt\n+0005bc60: 3a20 7374 722c 2068 696e 743a 2073 7472 : str, hint: str\n+0005bc70: 2920 2d3e 2027 7374 7220 7c20 4e6f 6e65 ) -> 'str | None\n+0005bc80: 273a 0a20 2020 2020 2020 2022 2222 5072 ':. \"\"\"Pr\n+0005bc90: 6f6d 7074 2074 6865 2075 7365 7220 666f ompt the user fo\n+0005bca0: 7220 616e 2061 7574 6865 6e74 6963 6174 r an authenticat\n+0005bcb0: 696f 6e20 6f72 2063 6f6e 6669 726d 6174 ion or confirmat\n+0005bcc0: 696f 6e20 696e 7465 7261 6374 696f 6e2e ion interaction.\n+0005bcd0: 0a0a 2020 2020 2020 2020 276d 6573 7361 .. 'messa\n+0005bce0: 6765 7327 2069 7320 6461 7461 2074 6861 ges' is data tha\n+0005bcf0: 7420 7761 7320 7365 6e74 2074 6f20 7374 t was sent to st\n+0005bd00: 6465 7272 2062 6566 6f72 6520 7468 6520 derr before the \n+0005bd10: 696e 7465 7261 6374 696f 6e20 7761 7320 interaction was \n+0005bd20: 7265 7175 6573 7465 642e 0a20 2020 2020 requested.. \n+0005bd30: 2020 2027 7072 6f6d 7074 2720 6973 2074 'prompt' is t\n+0005bd40: 6865 2069 6e74 6572 6163 7469 6f6e 2070 he interaction p\n+0005bd50: 726f 6d70 742e 0a0a 2020 2020 2020 2020 rompt... \n+0005bd60: 5468 6520 6578 7065 6374 6564 2072 6573 The expected res\n+0005bd70: 706f 6e73 6520 7479 7065 2064 6570 656e ponse type depen\n+0005bd80: 6473 206f 6e20 6869 6e74 3a0a 0a20 2020 ds on hint:.. \n+0005bd90: 2020 2020 2020 2020 202d 2022 636f 6e66 - \"conf\n+0005bda0: 6972 6d22 3a20 6173 6b20 666f 7220 7065 irm\": ask for pe\n+0005bdb0: 726d 6973 7369 6f6e 2c20 7265 7475 726e rmission, return\n+0005bdc0: 696e 6720 2279 6573 2220 6966 2061 6363 ing \"yes\" if acc\n+0005bdd0: 6570 7465 640a 2020 2020 2020 2020 2020 epted. \n+0005bde0: 2020 2020 2020 2d20 6578 616d 706c 653a - example:\n+0005bdf0: 2061 7574 686f 7269 7a69 6e67 2061 6765 authorizing age\n+0005be00: 6e74 206f 7065 7261 7469 6f6e 0a0a 2020 nt operation.. \n+0005be10: 2020 2020 2020 2020 2020 2d20 226e 6f6e - \"non\n+0005be20: 6522 3a20 7368 6f77 2061 2072 6571 7565 e\": show a reque\n+0005be30: 7374 2077 6974 686f 7574 206e 6565 6420 st without need \n+0005be40: 666f 7220 6120 7265 7370 6f6e 7365 0a20 for a response. \n+0005be50: 2020 2020 2020 2020 2020 2020 2020 202d -\n+0005be60: 2065 7861 6d70 6c65 3a20 706c 6561 7365 example: please\n+0005be70: 2074 6f75 6368 2079 6f75 7220 6175 7468 touch your auth\n+0005be80: 656e 7469 6361 7469 6f6e 2074 6f6b 656e entication token\n+0005be90: 0a0a 2020 2020 2020 2020 2020 2020 2d20 .. - \n+0005bea0: 6f74 6865 7277 6973 653a 2072 6574 7572 otherwise: retur\n+0005beb0: 6e20 6120 7061 7373 776f 7264 206f 7220 n a password or \n+0005bec0: 6f74 6865 7220 666f 726d 206f 6620 7465 other form of te\n+0005bed0: 7874 2074 6f6b 656e 0a20 2020 2020 2020 xt token. \n+0005bee0: 2020 2020 2020 2020 202d 2065 7861 6d70 - examp\n+0005bef0: 6c65 733a 2065 6e74 6572 2070 6173 7377 les: enter passw\n+0005bf00: 6f72 642c 2075 6e6c 6f63 6b20 7072 6976 ord, unlock priv\n+0005bf10: 6174 6520 6b65 790a 0a20 2020 2020 2020 ate key.. \n+0005bf20: 2049 6e20 616e 7920 6361 7365 2c20 7468 In any case, th\n+0005bf30: 6520 6675 6e63 7469 6f6e 2073 686f 756c e function shoul\n+0005bf40: 6420 7072 6f70 6572 6c79 2068 616e 646c d properly handl\n+0005bf50: 6520 6361 6e63 656c 6c61 7469 6f6e 2e20 e cancellation. \n+0005bf60: 2046 6f72 2074 6865 0a20 2020 2020 2020 For the. \n+0005bf70: 2022 6e6f 6e65 2220 6361 7365 2c20 7468 \"none\" case, th\n+0005bf80: 6973 2077 696c 6c20 6265 2074 6865 206e is will be the n\n+0005bf90: 6f72 6d61 6c20 7761 7920 746f 2064 6973 ormal way to dis\n+0005bfa0: 6d69 7373 2074 6865 2064 6961 6c6f 672e miss the dialog.\n+0005bfb0: 0a20 2020 2020 2020 2022 2222 0a20 2020 . \"\"\". \n+0005bfc0: 2020 2020 2072 6574 7572 6e20 4e6f 6e65 return None\n+0005bfd0: 0a0a 2020 2020 6173 796e 6320 6465 6620 .. async def \n+0005bfe0: 646f 5f68 6f73 746b 6579 2873 656c 662c do_hostkey(self,\n+0005bff0: 2072 6561 736f 6e3a 2073 7472 2c20 686f reason: str, ho\n+0005c000: 7374 3a20 7374 722c 2061 6c67 6f72 6974 st: str, algorit\n+0005c010: 686d 3a20 7374 722c 206b 6579 3a20 7374 hm: str, key: st\n+0005c020: 722c 2066 696e 6765 7270 7269 6e74 3a20 r, fingerprint: \n+0005c030: 7374 7229 202d 3e20 626f 6f6c 3a0a 2020 str) -> bool:. \n+0005c040: 2020 2020 2020 2222 2250 726f 6d70 7420 \"\"\"Prompt \n+0005c050: 7468 6520 7573 6572 2066 6f72 2061 2064 the user for a d\n+0005c060: 6563 6973 696f 6e20 7265 6761 7264 696e ecision regardin\n+0005c070: 6720 6163 6365 7074 616e 6365 206f 6620 g acceptance of \n+0005c080: 6120 686f 7374 206b 6579 2e0a 0a20 2020 a host key... \n+0005c090: 2020 2020 2054 6865 2022 7265 6173 6f6e The \"reason\n+0005c0a0: 2220 7769 6c6c 2062 6520 6569 7468 6572 \" will be either\n+0005c0b0: 2022 484f 5354 4e41 4d45 2220 6f72 2022 \"HOSTNAME\" or \"\n+0005c0c0: 4144 4452 4553 5322 2028 6966 2060 4368 ADDRESS\" (if `Ch\n+0005c0d0: 6563 6b48 6f73 7449 5060 2069 7320 656e eckHostIP` is en\n+0005c0e0: 6162 6c65 6429 2e0a 0a20 2020 2020 2020 abled)... \n+0005c0f0: 2054 6865 2068 6f73 742c 2061 6c67 6f72 The host, algor\n+0005c100: 6974 686d 2c20 616e 6420 6b65 7920 7061 ithm, and key pa\n+0005c110: 7261 6d65 7465 7273 2061 7265 2074 6865 rameters are the\n+0005c120: 2076 616c 7565 7320 696e 2074 6865 2066 values in the f\n+0005c130: 6f72 6d20 7468 6174 0a20 2020 2020 2020 orm that. \n+0005c140: 2074 6865 7920 776f 756c 6420 6170 7065 they would appe\n+0005c150: 6172 206f 6e65 2061 2073 696e 676c 6520 ar one a single \n+0005c160: 6c69 6e65 2069 6e20 7468 6520 6b6e 6f77 line in the know\n+0005c170: 6e20 686f 7374 7320 6669 6c65 2e20 2054 n hosts file. T\n+0005c180: 6865 0a20 2020 2020 2020 2066 696e 6765 he. finge\n+0005c190: 7270 7269 6e74 2069 7320 7468 6520 6b65 rprint is the ke\n+0005c1a0: 7920 6669 6e67 6572 7072 696e 7420 696e y fingerprint in\n+0005c1b0: 2074 6865 2066 6f72 6d61 7420 7468 6174 the format that\n+0005c1c0: 2073 7368 2077 6f75 6c64 0a20 2020 2020 ssh would. \n+0005c1d0: 2020 206e 6f72 6d61 6c6c 7920 7072 6573 normally pres\n+0005c1e0: 656e 7420 6974 2074 6f20 7468 6520 7573 ent it to the us\n+0005c1f0: 6572 2e0a 0a20 2020 2020 2020 2049 6e20 er... In \n+0005c200: 6361 7365 2074 6865 2068 6f73 7420 6b65 case the host ke\n+0005c210: 7920 7368 6f75 6c64 2062 6520 6163 6365 y should be acce\n+0005c220: 7074 6564 2c20 7468 6973 2066 756e 6374 pted, this funct\n+0005c230: 696f 6e20 6e65 6564 7320 746f 2072 6574 ion needs to ret\n+0005c240: 7572 6e0a 2020 2020 2020 2020 5472 7565 urn. True\n+0005c250: 2e20 2052 6574 7572 6e69 6e67 2046 616c . Returning Fal\n+0005c260: 7365 206d 6561 6e73 2074 6861 7420 7373 se means that ss\n+0005c270: 6820 696d 706c 656d 656e 7473 2069 7473 h implements its\n+0005c280: 2064 6566 6175 6c74 206c 6f67 6963 2e20 default logic. \n+0005c290: 2054 6f0a 2020 2020 2020 2020 696e 7465 To. inte\n+0005c2a0: 7272 7570 7420 7468 6520 636f 6e6e 6563 rrupt the connec\n+0005c2b0: 7469 6f6e 2c20 7261 6973 6520 616e 2065 tion, raise an e\n+0005c2c0: 7863 6570 7469 6f6e 2e0a 2020 2020 2020 xception.. \n+0005c2d0: 2020 2222 220a 2020 2020 2020 2020 7265 \"\"\". re\n+0005c2e0: 7475 726e 2046 616c 7365 0a0a 2020 2020 turn False.. \n+0005c2f0: 6173 796e 6320 6465 6620 646f 5f63 7573 async def do_cus\n+0005c300: 746f 6d5f 636f 6d6d 616e 6428 0a20 2020 tom_command(. \n+0005c310: 2020 2020 2073 656c 662c 2063 6f6d 6d61 self, comma\n+0005c320: 6e64 3a20 7374 722c 2061 7267 733a 2027 nd: str, args: '\n+0005c330: 7475 706c 655b 6f62 6a65 6374 2c20 2e2e tuple[object, ..\n+0005c340: 2e5d 272c 2066 6473 3a20 276c 6973 745b .]', fds: 'list[\n+0005c350: 696e 745d 272c 2073 7464 6572 723a 2073 int]', stderr: s\n+0005c360: 7472 0a20 2020 2029 202d 3e20 4e6f 6e65 tr. ) -> None\n+0005c370: 3a0a 2020 2020 2020 2020 2222 2248 616e :. \"\"\"Han\n+0005c380: 646c 6520 6120 6375 7374 6f6d 2063 6f6d dle a custom com\n+0005c390: 6d61 6e64 2e0a 0a20 2020 2020 2020 2054 mand... T\n+0005c3a0: 6865 2063 6f6d 6d61 6e64 206e 616d 652c he command name,\n+0005c3b0: 2069 7473 2061 7267 756d 656e 7473 2c20 its arguments, \n+0005c3c0: 7468 6520 7061 7373 6564 2066 6473 2c20 the passed fds, \n+0005c3d0: 616e 6420 7468 6520 7374 6465 7272 206c and the stderr l\n+0005c3e0: 6561 6469 6e67 0a20 2020 2020 2020 2075 eading. u\n+0005c3f0: 7020 746f 2074 6865 2063 6f6d 6d61 6e64 p to the command\n+0005c400: 2069 6e76 6f63 6174 696f 6e20 6172 6520 invocation are \n+0005c410: 616c 6c20 7072 6f76 6964 6564 2e0a 0a20 all provided... \n+0005c420: 2020 2020 2020 2053 6565 2064 6f63 2f69 See doc/i\n+0005c430: 6e74 6572 6163 7469 6f6e 2d70 726f 746f nteraction-proto\n+0005c440: 636f 6c2e 6d64 0a20 2020 2020 2020 2022 col.md. \"\n+0005c450: 2222 0a0a 2020 2020 6173 796e 6320 6465 \"\".. async de\n+0005c460: 6620 5f61 736b 7061 7373 5f63 6f6d 6d61 f _askpass_comma\n+0005c470: 6e64 2873 656c 662c 2061 7267 733a 2027 nd(self, args: '\n+0005c480: 7475 706c 655b 6f62 6a65 6374 2c20 2e2e tuple[object, ..\n+0005c490: 2e5d 272c 2066 6473 3a20 276c 6973 745b .]', fds: 'list[\n+0005c4a0: 696e 745d 272c 2073 7464 6572 723a 2073 int]', stderr: s\n+0005c4b0: 7472 2920 2d3e 204e 6f6e 653a 0a20 2020 tr) -> None:. \n+0005c4c0: 2020 2020 206c 6f67 6765 722e 6465 6275 logger.debu\n+0005c4d0: 6728 275f 6173 6b70 6173 735f 636f 6d6d g('_askpass_comm\n+0005c4e0: 616e 6428 2573 2c20 2573 2c20 2573 2927 and(%s, %s, %s)'\n+0005c4f0: 2c20 6172 6773 2c20 6664 732c 2073 7464 , args, fds, std\n+0005c500: 6572 7229 0a20 2020 2020 2020 2074 7279 err). try\n+0005c510: 3a0a 2020 2020 2020 2020 2020 2020 6172 :. ar\n+0005c520: 6776 2c20 656e 7620 3d20 6172 6773 0a20 gv, env = args. \n+0005c530: 2020 2020 2020 2020 2020 2061 7373 6572 asser\n+0005c540: 7420 6973 696e 7374 616e 6365 2861 7267 t isinstance(arg\n+0005c550: 762c 206c 6973 7429 0a20 2020 2020 2020 v, list). \n+0005c560: 2020 2020 2061 7373 6572 7420 616c 6c28 assert all(\n+0005c570: 6973 696e 7374 616e 6365 2861 7267 2c20 isinstance(arg, \n+0005c580: 7374 7229 2066 6f72 2061 7267 2069 6e20 str) for arg in \n+0005c590: 6172 6776 290a 2020 2020 2020 2020 2020 argv). \n+0005c5a0: 2020 6173 7365 7274 2069 7369 6e73 7461 assert isinsta\n+0005c5b0: 6e63 6528 656e 762c 2064 6963 7429 0a20 nce(env, dict). \n+0005c5c0: 2020 2020 2020 2020 2020 2061 7373 6572 asser\n+0005c5d0: 7420 616c 6c28 6973 696e 7374 616e 6365 t all(isinstance\n+0005c5e0: 286b 6579 2c20 7374 7229 2061 6e64 2069 (key, str) and i\n+0005c5f0: 7369 6e73 7461 6e63 6528 7661 6c2c 2073 sinstance(val, s\n+0005c600: 7472 2920 666f 7220 6b65 792c 2076 616c tr) for key, val\n+0005c610: 2069 6e20 656e 762e 6974 656d 7328 2929 in env.items())\n+0005c620: 0a20 2020 2020 2020 2020 2020 2061 7373 . ass\n+0005c630: 6572 7420 6c65 6e28 6664 7329 203d 3d20 ert len(fds) == \n+0005c640: 320a 2020 2020 2020 2020 6578 6365 7074 2. except\n+0005c650: 2028 5661 6c75 6545 7272 6f72 2c20 5479 (ValueError, Ty\n+0005c660: 7065 4572 726f 722c 2041 7373 6572 7469 peError, Asserti\n+0005c670: 6f6e 4572 726f 7229 2061 7320 6578 633a onError) as exc:\n+0005c680: 0a20 2020 2020 2020 2020 2020 206c 6f67 . log\n+0005c690: 6765 722e 6572 726f 7228 2749 6e76 616c ger.error('Inval\n+0005c6a0: 6964 2061 7267 756d 656e 7473 2074 6f20 id arguments to \n+0005c6b0: 6173 6b70 6173 7320 696e 7465 7261 6374 askpass interact\n+0005c6c0: 696f 6e3a 2025 732c 2025 733a 2025 7327 ion: %s, %s: %s'\n+0005c6d0: 2c20 6172 6773 2c20 6664 732c 2065 7863 , args, fds, exc\n+0005c6e0: 290a 2020 2020 2020 2020 2020 2020 7265 ). re\n+0005c6f0: 7475 726e 0a0a 2020 2020 2020 2020 7769 turn.. wi\n+0005c700: 7468 206f 7065 6e28 6664 732e 706f 7028 th open(fds.pop(\n+0005c710: 3029 2c20 2777 2729 2061 7320 7374 6174 0), 'w') as stat\n+0005c720: 7573 2c20 6f70 656e 2866 6473 2e70 6f70 us, open(fds.pop\n+0005c730: 2830 292c 2027 7727 2920 6173 2073 7464 (0), 'w') as std\n+0005c740: 6f75 743a 0a20 2020 2020 2020 2020 2020 out:. \n+0005c750: 2074 7279 3a0a 2020 2020 2020 2020 2020 try:. \n+0005c760: 2020 2020 2020 6c6f 6f70 203d 2067 6574 loop = get\n+0005c770: 5f72 756e 6e69 6e67 5f6c 6f6f 7028 290a _running_loop().\n+0005c780: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0005c790: 7472 793a 0a20 2020 2020 2020 2020 2020 try:. \n+0005c7a0: 2020 2020 2020 2020 2074 6173 6b20 3d20 task = \n+0005c7b0: 6173 796e 6369 6f2e 6375 7272 656e 745f asyncio.current_\n+0005c7c0: 7461 736b 2829 0a20 2020 2020 2020 2020 task(). \n+0005c7d0: 2020 2020 2020 2065 7863 6570 7420 4174 except At\n+0005c7e0: 7472 6962 7574 6545 7272 6f72 3a0a 2020 tributeError:. \n+0005c7f0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0005c800: 2020 7461 736b 203d 2061 7379 6e63 696f task = asyncio\n+0005c810: 2e54 6173 6b2e 6375 7272 656e 745f 7461 .Task.current_ta\n+0005c820: 736b 2829 2020 2320 7479 7065 3a69 676e sk() # type:ign\n+0005c830: 6f72 655b 6174 7472 2d64 6566 696e 6564 ore[attr-defined\n+0005c840: 5d20 2320 2850 7974 686f 6e20 332e 3629 ] # (Python 3.6)\n+0005c850: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+0005c860: 2061 7373 6572 7420 7461 736b 2069 7320 assert task is \n+0005c870: 6e6f 7420 4e6f 6e65 0a20 2020 2020 2020 not None. \n+0005c880: 2020 2020 2020 2020 206c 6f6f 702e 6164 loop.ad\n+0005c890: 645f 7265 6164 6572 2873 7461 7475 732c d_reader(status,\n+0005c8a0: 2074 6173 6b2e 6361 6e63 656c 290a 0a20 task.cancel).. \n+0005c8b0: 2020 2020 2020 2020 2020 2020 2020 2069 i\n+0005c8c0: 6620 6c65 6e28 6172 6776 2920 3d3d 2032 f len(argv) == 2\n+0005c8d0: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n+0005c8e0: 2020 2020 2020 2320 6e6f 726d 616c 2061 # normal a\n+0005c8f0: 736b 7061 7373 0a20 2020 2020 2020 2020 skpass. \n+0005c900: 2020 2020 2020 2020 2020 2070 726f 6d70 promp\n+0005c910: 7420 3d20 6172 6776 5b31 5d0a 2020 2020 t = argv[1]. \n+0005c920: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0005c930: 6869 6e74 203d 2065 6e76 2e67 6574 2827 hint = env.get('\n+0005c940: 5353 485f 4153 4b50 4153 535f 5052 4f4d SSH_ASKPASS_PROM\n+0005c950: 5054 272c 2027 2729 0a20 2020 2020 2020 PT', ''). \n+0005c960: 2020 2020 2020 2020 2020 2020 206c 6f67 log\n+0005c970: 6765 722e 6465 6275 6728 2764 6f5f 6173 ger.debug('do_as\n+0005c980: 6b70 6173 7328 2572 2c20 2572 2c20 2572 kpass(%r, %r, %r\n+0005c990: 2927 2c20 7374 6465 7272 2c20 7072 6f6d )', stderr, prom\n+0005c9a0: 7074 2c20 6869 6e74 290a 2020 2020 2020 pt, hint). \n+0005c9b0: 2020 2020 2020 2020 2020 2020 2020 616e an\n+0005c9c0: 7377 6572 203d 2061 7761 6974 2073 656c swer = await sel\n+0005c9d0: 662e 646f 5f61 736b 7061 7373 2873 7464 f.do_askpass(std\n+0005c9e0: 6572 722c 2070 726f 6d70 742c 2068 696e err, prompt, hin\n+0005c9f0: 7429 0a20 2020 2020 2020 2020 2020 2020 t). \n+0005ca00: 2020 2020 2020 206c 6f67 6765 722e 6465 logger.de\n+0005ca10: 6275 6728 2764 6f5f 6173 6b70 6173 7320 bug('do_askpass \n+0005ca20: 616e 7377 6572 2025 7227 2c20 616e 7377 answer %r', answ\n+0005ca30: 6572 290a 2020 2020 2020 2020 2020 2020 er). \n+0005ca40: 2020 2020 2020 2020 6966 2061 6e73 7765 if answe\n+0005ca50: 7220 6973 206e 6f74 204e 6f6e 653a 0a20 r is not None:. \n+0005ca60: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0005ca70: 2020 2020 2020 2070 7269 6e74 2861 6e73 print(ans\n+0005ca80: 7765 722c 2066 696c 653d 7374 646f 7574 wer, file=stdout\n+0005ca90: 290a 2020 2020 2020 2020 2020 2020 2020 ). \n+0005caa0: 2020 2020 2020 2020 2020 7072 696e 7428 print(\n+0005cab0: 302c 2066 696c 653d 7374 6174 7573 290a 0, file=status).\n+0005cac0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+0005cad0: 2065 6c69 6620 6c65 6e28 6172 6776 2920 elif len(argv) \n+0005cae0: 3d3d 2036 3a0a 2020 2020 2020 2020 2020 == 6:. \n+0005caf0: 2020 2020 2020 2020 2020 2320 4b6e 6f77 # Know\n+0005cb00: 6e48 6f73 7473 436f 6d6d 616e 640a 2020 nHostsCommand. \n+0005cb10: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0005cb20: 2020 6172 6776 302c 2072 6561 736f 6e2c argv0, reason,\n+0005cb30: 2068 6f73 742c 2061 6c67 6f72 6974 686d host, algorithm\n+0005cb40: 2c20 6b65 792c 2066 696e 6765 7270 7269 , key, fingerpri\n+0005cb50: 6e74 203d 2061 7267 760a 2020 2020 2020 nt = argv. \n+0005cb60: 2020 2020 2020 2020 2020 2020 2020 6966 if\n+0005cb70: 2072 6561 736f 6e20 696e 205b 2741 4444 reason in ['ADD\n+0005cb80: 5245 5353 272c 2027 484f 5354 4e41 4d45 RESS', 'HOSTNAME\n+0005cb90: 275d 3a0a 2020 2020 2020 2020 2020 2020 ']:. \n+0005cba0: 2020 2020 2020 2020 2020 2020 6c6f 6767 logg\n+0005cbb0: 6572 2e64 6562 7567 2827 646f 5f68 6f73 er.debug('do_hos\n+0005cbc0: 746b 6579 2825 722c 2025 722c 2025 722c tkey(%r, %r, %r,\n+0005cbd0: 2025 722c 2025 7229 272c 2072 6561 736f %r, %r)', reaso\n+0005cbe0: 6e2c 2068 6f73 742c 2061 6c67 6f72 6974 n, host, algorit\n+0005cbf0: 686d 2c20 6b65 792c 2066 696e 6765 7270 hm, key, fingerp\n+0005cc00: 7269 6e74 290a 2020 2020 2020 2020 2020 rint). \n+0005cc10: 2020 2020 2020 2020 2020 2020 2020 6966 if\n+0005cc20: 2061 7761 6974 2073 656c 662e 646f 5f68 await self.do_h\n+0005cc30: 6f73 746b 6579 2872 6561 736f 6e2c 2068 ostkey(reason, h\n+0005cc40: 6f73 742c 2061 6c67 6f72 6974 686d 2c20 ost, algorithm, \n+0005cc50: 6b65 792c 2066 696e 6765 7270 7269 6e74 key, fingerprint\n+0005cc60: 293a 0a20 2020 2020 2020 2020 2020 2020 ):. \n+0005cc70: 2020 2020 2020 2020 2020 2020 2020 2070 p\n+0005cc80: 7269 6e74 2868 6f73 742c 2061 6c67 6f72 rint(host, algor\n+0005cc90: 6974 686d 2c20 6b65 792c 2066 696c 653d ithm, key, file=\n+0005cca0: 7374 646f 7574 290a 2020 2020 2020 2020 stdout). \n+0005ccb0: 2020 2020 2020 2020 2020 2020 656c 7365 else\n+0005ccc0: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n+0005ccd0: 2020 2020 2020 2020 2020 6c6f 6767 6572 logger\n+0005cce0: 2e64 6562 7567 2827 6967 6e6f 7269 6e67 .debug('ignoring\n+0005ccf0: 204b 6e6f 776e 486f 7374 7343 6f6d 6d61 KnownHostsComma\n+0005cd00: 6e64 2072 6561 736f 6e20 2572 272c 2072 nd reason %r', r\n+0005cd10: 6561 736f 6e29 0a0a 2020 2020 2020 2020 eason).. \n+0005cd20: 2020 2020 2020 2020 2020 2020 7072 696e prin\n+0005cd30: 7428 302c 2066 696c 653d 7374 6174 7573 t(0, file=status\n+0005cd40: 290a 0a20 2020 2020 2020 2020 2020 2020 ).. \n+0005cd50: 2020 2065 6c73 653a 0a20 2020 2020 2020 else:. \n+0005cd60: 2020 2020 2020 2020 2020 2020 206c 6f67 log\n+0005cd70: 6765 722e 6572 726f 7228 2749 6e63 6f72 ger.error('Incor\n+0005cd80: 7265 6374 206e 756d 6265 7220 6f66 2063 rect number of c\n+0005cd90: 6f6d 6d61 6e64 2d6c 696e 6520 6172 6775 ommand-line argu\n+0005cda0: 6d65 6e74 7320 746f 2066 6572 6e79 2d61 ments to ferny-a\n+0005cdb0: 736b 7061 7373 3a20 2573 272c 2061 7267 skpass: %s', arg\n+0005cdc0: 7629 0a20 2020 2020 2020 2020 2020 2066 v). f\n+0005cdd0: 696e 616c 6c79 3a0a 2020 2020 2020 2020 inally:. \n+0005cde0: 2020 2020 2020 2020 6c6f 6f70 2e72 656d loop.rem\n+0005cdf0: 6f76 655f 7265 6164 6572 2873 7461 7475 ove_reader(statu\n+0005ce00: 7329 0a0a 2020 2020 6173 796e 6320 6465 s).. async de\n+0005ce10: 6620 7275 6e5f 636f 6d6d 616e 6428 7365 f run_command(se\n+0005ce20: 6c66 2c20 636f 6d6d 616e 643a 2073 7472 lf, command: str\n+0005ce30: 2c20 6172 6773 3a20 2774 7570 6c65 5b6f , args: 'tuple[o\n+0005ce40: 626a 6563 742c 202e 2e2e 5d27 2c20 6664 bject, ...]', fd\n+0005ce50: 733a 2027 6c69 7374 5b69 6e74 5d27 2c20 s: 'list[int]', \n+0005ce60: 7374 6465 7272 3a20 7374 7229 202d 3e20 stderr: str) -> \n+0005ce70: 4e6f 6e65 3a0a 2020 2020 2020 2020 6c6f None:. lo\n+0005ce80: 6767 6572 2e64 6562 7567 2827 7275 6e5f gger.debug('run_\n+0005ce90: 636f 6d6d 616e 6428 2573 2c20 2573 2c20 command(%s, %s, \n+0005cea0: 2573 2c20 2573 2927 2c20 636f 6d6d 616e %s, %s)', comman\n+0005ceb0: 642c 2061 7267 732c 2066 6473 2c20 7374 d, args, fds, st\n+0005cec0: 6465 7272 290a 2020 2020 2020 2020 6966 derr). if\n+0005ced0: 2063 6f6d 6d61 6e64 203d 3d20 2766 6572 command == 'fer\n+0005cee0: 6e79 2e61 736b 7061 7373 273a 0a20 2020 ny.askpass':. \n+0005cef0: 2020 2020 2020 2020 2061 7761 6974 2073 await s\n+0005cf00: 656c 662e 5f61 736b 7061 7373 5f63 6f6d elf._askpass_com\n+0005cf10: 6d61 6e64 2861 7267 732c 2066 6473 2c20 mand(args, fds, \n+0005cf20: 7374 6465 7272 290a 2020 2020 2020 2020 stderr). \n+0005cf30: 656c 7365 3a0a 2020 2020 2020 2020 2020 else:. \n+0005cf40: 2020 6177 6169 7420 7365 6c66 2e64 6f5f await self.do_\n+0005cf50: 6375 7374 6f6d 5f63 6f6d 6d61 6e64 2863 custom_command(c\n+0005cf60: 6f6d 6d61 6e64 2c20 6172 6773 2c20 6664 ommand, args, fd\n+0005cf70: 732c 2073 7464 6572 7229 0a0a 0a63 6c61 s, stderr)...cla\n+0005cf80: 7373 2049 6e74 6572 6163 7469 6f6e 4167 ss InteractionAg\n+0005cf90: 656e 743a 0a20 2020 205f 6861 6e64 6c65 ent:. _handle\n+0005cfa0: 7273 3a20 2764 6963 745b 7374 722c 2049 rs: 'dict[str, I\n+0005cfb0: 6e74 6572 6163 7469 6f6e 4861 6e64 6c65 nteractionHandle\n+0005cfc0: 725d 270a 0a20 2020 205f 6c6f 6f70 3a20 r]'.. _loop: \n+0005cfd0: 6173 796e 6369 6f2e 4162 7374 7261 6374 asyncio.Abstract\n+0005cfe0: 4576 656e 744c 6f6f 700a 0a20 2020 205f EventLoop.. _\n+0005cff0: 7461 736b 733a 2027 7365 745b 6173 796e tasks: 'set[asyn\n+0005d000: 6369 6f2e 5461 736b 5d27 0a0a 2020 2020 cio.Task]'.. \n+0005d010: 5f62 7566 6665 723a 2062 7974 6561 7272 _buffer: bytearr\n+0005d020: 6179 0a20 2020 205f 6f75 7273 3a20 736f ay. _ours: so\n+0005d030: 636b 6574 2e73 6f63 6b65 740a 2020 2020 cket.socket. \n+0005d040: 5f74 6865 6972 733a 2073 6f63 6b65 742e _theirs: socket.\n+0005d050: 736f 636b 6574 0a0a 2020 2020 5f63 6f6d socket.. _com\n+0005d060: 706c 6574 696f 6e5f 6675 7475 7265 3a20 pletion_future: \n+0005d070: 2761 7379 6e63 696f 2e46 7574 7572 655b 'asyncio.Future[\n+0005d080: 7374 725d 270a 2020 2020 5f70 656e 6469 str]'. _pendi\n+0005d090: 6e67 5f72 6573 756c 743a 2027 4e6f 6e65 ng_result: 'None\n+0005d0a0: 207c 2073 7472 207c 2045 7863 6570 7469 | str | Excepti\n+0005d0b0: 6f6e 2720 3d20 4e6f 6e65 0a20 2020 205f on' = None. _\n+0005d0c0: 656e 643a 2062 6f6f 6c20 3d20 4661 6c73 end: bool = Fals\n+0005d0d0: 650a 0a20 2020 2064 6566 205f 636f 6e73 e.. def _cons\n+0005d0e0: 6964 6572 5f63 6f6d 706c 6574 696f 6e28 ider_completion(\n+0005d0f0: 7365 6c66 2920 2d3e 204e 6f6e 653a 0a20 self) -> None:. \n+0005d100: 2020 2020 2020 206c 6f67 6765 722e 6465 logger.de\n+0005d110: 6275 6728 275f 636f 6e73 6964 6572 5f63 bug('_consider_c\n+0005d120: 6f6d 706c 6574 696f 6e28 2572 2927 2c20 ompletion(%r)', \n+0005d130: 7365 6c66 290a 0a20 2020 2020 2020 2069 self).. i\n+0005d140: 6620 7365 6c66 2e5f 7065 6e64 696e 675f f self._pending_\n+0005d150: 7265 7375 6c74 2069 7320 4e6f 6e65 206f result is None o\n+0005d160: 7220 7365 6c66 2e5f 7461 736b 733a 0a20 r self._tasks:. \n+0005d170: 2020 2020 2020 2020 2020 206c 6f67 6765 logge\n+0005d180: 722e 6465 6275 6728 2720 2062 7574 206e r.debug(' but n\n+0005d190: 6f74 2072 6561 6479 2079 6574 2729 0a0a ot ready yet')..\n+0005d1a0: 2020 2020 2020 2020 656c 6966 2073 656c elif sel\n+0005d1b0: 662e 5f63 6f6d 706c 6574 696f 6e5f 6675 f._completion_fu\n+0005d1c0: 7475 7265 2e64 6f6e 6528 293a 0a20 2020 ture.done():. \n+0005d1d0: 2020 2020 2020 2020 206c 6f67 6765 722e logger.\n+0005d1e0: 6465 6275 6728 2720 2062 7574 2061 6c72 debug(' but alr\n+0005d1f0: 6561 6479 2063 6f6d 706c 6574 6527 290a eady complete').\n+0005d200: 0a20 2020 2020 2020 2065 6c69 6620 6973 . elif is\n+0005d210: 696e 7374 616e 6365 2873 656c 662e 5f70 instance(self._p\n+0005d220: 656e 6469 6e67 5f72 6573 756c 742c 2073 ending_result, s\n+0005d230: 7472 293a 0a20 2020 2020 2020 2020 2020 tr):. \n+0005d240: 206c 6f67 6765 722e 6465 6275 6728 2720 logger.debug(' \n+0005d250: 2073 7562 6d69 7474 696e 6720 7374 6465 submitting stde\n+0005d260: 7272 2028 2572 2920 746f 2063 6f6d 706c rr (%r) to compl\n+0005d270: 6574 696f 6e5f 6675 7475 7265 272c 2073 etion_future', s\n+0005d280: 656c 662e 5f70 656e 6469 6e67 5f72 6573 elf._pending_res\n+0005d290: 756c 7429 0a20 2020 2020 2020 2020 2020 ult). \n+0005d2a0: 2073 656c 662e 5f63 6f6d 706c 6574 696f self._completio\n+0005d2b0: 6e5f 6675 7475 7265 2e73 6574 5f72 6573 n_future.set_res\n+0005d2c0: 756c 7428 7365 6c66 2e5f 7065 6e64 696e ult(self._pendin\n+0005d2d0: 675f 7265 7375 6c74 290a 0a20 2020 2020 g_result).. \n+0005d2e0: 2020 2065 6c73 653a 0a20 2020 2020 2020 else:. \n+0005d2f0: 2020 2020 206c 6f67 6765 722e 6465 6275 logger.debu\n+0005d300: 6728 2720 2073 7562 6d69 7474 696e 6720 g(' submitting \n+0005d310: 6578 6365 7074 696f 6e20 2825 7229 2074 exception (%r) t\n+0005d320: 6f20 636f 6d70 6c65 7469 6f6e 5f66 7574 o completion_fut\n+0005d330: 7572 6527 290a 2020 2020 2020 2020 2020 ure'). \n+0005d340: 2020 7365 6c66 2e5f 636f 6d70 6c65 7469 self._completi\n+0005d350: 6f6e 5f66 7574 7572 652e 7365 745f 6578 on_future.set_ex\n+0005d360: 6365 7074 696f 6e28 7365 6c66 2e5f 7065 ception(self._pe\n+0005d370: 6e64 696e 675f 7265 7375 6c74 290a 0a20 nding_result).. \n+0005d380: 2020 2064 6566 205f 7265 7375 6c74 2873 def _result(s\n+0005d390: 656c 662c 2072 6573 756c 743a 2027 7374 elf, result: 'st\n+0005d3a0: 7220 7c20 4578 6365 7074 696f 6e27 2920 r | Exception') \n+0005d3b0: 2d3e 204e 6f6e 653a 0a20 2020 2020 2020 -> None:. \n+0005d3c0: 206c 6f67 6765 722e 6465 6275 6728 275f logger.debug('_\n+0005d3d0: 7265 7375 6c74 2825 722c 2025 7229 272c result(%r, %r)',\n+0005d3e0: 2073 656c 662c 2072 6573 756c 7429 0a0a self, result)..\n+0005d3f0: 2020 2020 2020 2020 6966 2073 656c 662e if self.\n+0005d400: 5f70 656e 6469 6e67 5f72 6573 756c 7420 _pending_result \n+0005d410: 6973 204e 6f6e 653a 0a20 2020 2020 2020 is None:. \n+0005d420: 2020 2020 2073 656c 662e 5f70 656e 6469 self._pendi\n+0005d430: 6e67 5f72 6573 756c 7420 3d20 7265 7375 ng_result = resu\n+0005d440: 6c74 0a0a 2020 2020 2020 2020 6966 2073 lt.. if s\n+0005d450: 656c 662e 5f6f 7572 732e 6669 6c65 6e6f elf._ours.fileno\n+0005d460: 2829 2021 3d20 2d31 3a0a 2020 2020 2020 () != -1:. \n+0005d470: 2020 2020 2020 6c6f 6767 6572 2e64 6562 logger.deb\n+0005d480: 7567 2827 2020 7265 6d6f 7665 5f72 6561 ug(' remove_rea\n+0005d490: 6465 7228 2572 2927 2c20 7365 6c66 2e5f der(%r)', self._\n+0005d4a0: 6f75 7273 290a 2020 2020 2020 2020 2020 ours). \n+0005d4b0: 2020 7365 6c66 2e5f 6c6f 6f70 2e72 656d self._loop.rem\n+0005d4c0: 6f76 655f 7265 6164 6572 2873 656c 662e ove_reader(self.\n+0005d4d0: 5f6f 7572 732e 6669 6c65 6e6f 2829 290a _ours.fileno()).\n+0005d4e0: 0a20 2020 2020 2020 2066 6f72 2074 6173 . for tas\n+0005d4f0: 6b20 696e 2073 656c 662e 5f74 6173 6b73 k in self._tasks\n+0005d500: 3a0a 2020 2020 2020 2020 2020 2020 6c6f :. lo\n+0005d510: 6767 6572 2e64 6562 7567 2827 2020 2020 gger.debug(' \n+0005d520: 6361 6e63 656c 2825 7229 272c 2074 6173 cancel(%r)', tas\n+0005d530: 6b29 0a20 2020 2020 2020 2020 2020 2074 k). t\n+0005d540: 6173 6b2e 6361 6e63 656c 2829 0a0a 2020 ask.cancel().. \n+0005d550: 2020 2020 2020 6c6f 6767 6572 2e64 6562 logger.deb\n+0005d560: 7567 2827 2020 636c 6f73 696e 6720 736f ug(' closing so\n+0005d570: 636b 6574 7327 290a 2020 2020 2020 2020 ckets'). \n+0005d580: 7365 6c66 2e5f 7468 6569 7273 2e63 6c6f self._theirs.clo\n+0005d590: 7365 2829 2020 2320 6964 656d 706f 7465 se() # idempote\n+0005d5a0: 6e74 0a20 2020 2020 2020 2073 656c 662e nt. self.\n+0005d5b0: 5f6f 7572 732e 636c 6f73 6528 290a 0a20 _ours.close().. \n+0005d5c0: 2020 2020 2020 2073 656c 662e 5f63 6f6e self._con\n+0005d5d0: 7369 6465 725f 636f 6d70 6c65 7469 6f6e sider_completion\n+0005d5e0: 2829 0a0a 2020 2020 6465 6620 5f69 6e76 ().. def _inv\n+0005d5f0: 6f6b 655f 636f 6d6d 616e 6428 7365 6c66 oke_command(self\n+0005d600: 2c20 7374 6465 7272 3a20 6279 7465 732c , stderr: bytes,\n+0005d610: 2063 6f6d 6d61 6e64 5f62 6c6f 623a 2062 command_blob: b\n+0005d620: 7974 6573 2c20 6664 733a 2027 6c69 7374 ytes, fds: 'list\n+0005d630: 5b69 6e74 5d27 2920 2d3e 204e 6f6e 653a [int]') -> None:\n+0005d640: 0a20 2020 2020 2020 206c 6f67 6765 722e . logger.\n+0005d650: 6465 6275 6728 275f 696e 766f 6b65 5f63 debug('_invoke_c\n+0005d660: 6f6d 6d61 6e64 2825 722c 2025 722c 2025 ommand(%r, %r, %\n+0005d670: 7229 272c 2073 7464 6572 722c 2063 6f6d r)', stderr, com\n+0005d680: 6d61 6e64 5f62 6c6f 622c 2066 6473 290a mand_blob, fds).\n+0005d690: 2020 2020 2020 2020 7472 793a 0a20 2020 try:. \n+0005d6a0: 2020 2020 2020 2020 2063 6f6d 6d61 6e64 command\n+0005d6b0: 2c20 6172 6773 203d 2061 7374 2e6c 6974 , args = ast.lit\n+0005d6c0: 6572 616c 5f65 7661 6c28 636f 6d6d 616e eral_eval(comman\n+0005d6d0: 645f 626c 6f62 2e64 6563 6f64 6528 2929 d_blob.decode())\n+0005d6e0: 0a20 2020 2020 2020 2020 2020 2069 6620 . if \n+0005d6f0: 6e6f 7420 6973 696e 7374 616e 6365 2863 not isinstance(c\n+0005d700: 6f6d 6d61 6e64 2c20 7374 7229 206f 7220 ommand, str) or \n+0005d710: 6e6f 7420 6973 696e 7374 616e 6365 2861 not isinstance(a\n+0005d720: 7267 732c 2074 7570 6c65 293a 0a20 2020 rgs, tuple):. \n+0005d730: 2020 2020 2020 2020 2020 2020 2072 6169 rai\n+0005d740: 7365 2054 7970 6545 7272 6f72 2827 496e se TypeError('In\n+0005d750: 7661 6c69 6420 6172 6775 6d65 6e74 2074 valid argument t\n+0005d760: 7970 6573 2729 0a20 2020 2020 2020 2065 ypes'). e\n+0005d770: 7863 6570 7420 2855 6e69 636f 6465 4465 xcept (UnicodeDe\n+0005d780: 636f 6465 4572 726f 722c 2053 796e 7461 codeError, Synta\n+0005d790: 7845 7272 6f72 2c20 5661 6c75 6545 7272 xError, ValueErr\n+0005d7a0: 6f72 2c20 5479 7065 4572 726f 7229 2061 or, TypeError) a\n+0005d7b0: 7320 6578 633a 0a20 2020 2020 2020 2020 s exc:. \n+0005d7c0: 2020 206c 6f67 6765 722e 6572 726f 7228 logger.error(\n+0005d7d0: 2752 6563 6569 7665 6420 696e 7661 6c69 'Received invali\n+0005d7e0: 6420 6665 726e 7920 636f 6d6d 616e 643a d ferny command:\n+0005d7f0: 2025 733a 2025 7327 2c20 636f 6d6d 616e %s: %s', comman\n+0005d800: 645f 626c 6f62 2c20 6578 6329 0a20 2020 d_blob, exc). \n+0005d810: 2020 2020 2020 2020 2072 6574 7572 6e0a return.\n+0005d820: 0a20 2020 2020 2020 2069 6620 636f 6d6d . if comm\n+0005d830: 616e 6420 3d3d 2027 6665 726e 792e 656e and == 'ferny.en\n+0005d840: 6427 3a0a 2020 2020 2020 2020 2020 2020 d':. \n+0005d850: 7365 6c66 2e5f 656e 6420 3d20 5472 7565 self._end = True\n+0005d860: 0a20 2020 2020 2020 2020 2020 2073 656c . sel\n+0005d870: 662e 5f72 6573 756c 7428 7365 6c66 2e5f f._result(self._\n+0005d880: 6275 6666 6572 2e64 6563 6f64 6528 6572 buffer.decode(er\n+0005d890: 726f 7273 3d27 7265 706c 6163 6527 2929 rors='replace'))\n+0005d8a0: 0a20 2020 2020 2020 2020 2020 2072 6574 . ret\n+0005d8b0: 7572 6e0a 0a20 2020 2020 2020 2074 7279 urn.. try\n+0005d8c0: 3a0a 2020 2020 2020 2020 2020 2020 6861 :. ha\n+0005d8d0: 6e64 6c65 7220 3d20 7365 6c66 2e5f 6861 ndler = self._ha\n+0005d8e0: 6e64 6c65 7273 5b63 6f6d 6d61 6e64 5d0a ndlers[command].\n+0005d8f0: 2020 2020 2020 2020 6578 6365 7074 204b except K\n+0005d900: 6579 4572 726f 723a 0a20 2020 2020 2020 eyError:. \n+0005d910: 2020 2020 206c 6f67 6765 722e 6572 726f logger.erro\n+0005d920: 7228 2752 6563 6569 7665 6420 756e 6861 r('Received unha\n+0005d930: 6e64 6c65 6420 6665 726e 7920 636f 6d6d ndled ferny comm\n+0005d940: 616e 643a 2025 7327 2c20 636f 6d6d 616e and: %s', comman\n+0005d950: 6429 0a20 2020 2020 2020 2020 2020 2072 d). r\n+0005d960: 6574 7572 6e0a 0a20 2020 2020 2020 2023 eturn.. #\n+0005d970: 2054 6865 2074 6173 6b20 6973 2072 6573 The task is res\n+0005d980: 706f 6e73 6962 6c65 2066 6f72 2074 6865 ponsible for the\n+0005d990: 206c 6973 7420 6f66 2066 6473 2061 6e64 list of fds and\n+0005d9a0: 2072 656d 6f76 696e 6720 6974 7365 6c66 removing itself\n+0005d9b0: 0a20 2020 2020 2020 2023 2066 726f 6d20 . # from \n+0005d9c0: 7468 6520 7365 742e 0a20 2020 2020 2020 the set.. \n+0005d9d0: 2074 6173 6b5f 6664 7320 3d20 6c69 7374 task_fds = list\n+0005d9e0: 2866 6473 290a 2020 2020 2020 2020 7461 (fds). ta\n+0005d9f0: 736b 203d 2073 656c 662e 5f6c 6f6f 702e sk = self._loop.\n+0005da00: 6372 6561 7465 5f74 6173 6b28 6861 6e64 create_task(hand\n+0005da10: 6c65 722e 7275 6e5f 636f 6d6d 616e 6428 ler.run_command(\n+0005da20: 636f 6d6d 616e 642c 2061 7267 732c 2074 command, args, t\n+0005da30: 6173 6b5f 6664 732c 2073 7464 6572 722e ask_fds, stderr.\n+0005da40: 6465 636f 6465 2829 2929 0a0a 2020 2020 decode())).. \n+0005da50: 2020 2020 6465 6620 626f 7474 6f6d 5f68 def bottom_h\n+0005da60: 616c 6628 636f 6d70 6c65 7465 645f 7461 alf(completed_ta\n+0005da70: 736b 3a20 6173 796e 6369 6f2e 5461 736b sk: asyncio.Task\n+0005da80: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n+0005da90: 2020 2020 2020 2061 7373 6572 7420 636f assert co\n+0005daa0: 6d70 6c65 7465 645f 7461 736b 2069 7320 mpleted_task is \n+0005dab0: 7461 736b 0a20 2020 2020 2020 2020 2020 task. \n+0005dac0: 2077 6869 6c65 2074 6173 6b5f 6664 733a while task_fds:\n+0005dad0: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+0005dae0: 206f 732e 636c 6f73 6528 7461 736b 5f66 os.close(task_f\n+0005daf0: 6473 2e70 6f70 2829 290a 2020 2020 2020 ds.pop()). \n+0005db00: 2020 2020 2020 7365 6c66 2e5f 7461 736b self._task\n+0005db10: 732e 7265 6d6f 7665 2874 6173 6b29 0a0a s.remove(task)..\n+0005db20: 2020 2020 2020 2020 2020 2020 7472 793a try:\n+0005db30: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+0005db40: 2074 6173 6b2e 7265 7375 6c74 2829 0a20 task.result(). \n+0005db50: 2020 2020 2020 2020 2020 2020 2020 206c l\n+0005db60: 6f67 6765 722e 6465 6275 6728 2725 7220 ogger.debug('%r \n+0005db70: 636f 6d70 6c65 7465 6420 636c 6561 6e6c completed cleanl\n+0005db80: 7927 2c20 6861 6e64 6c65 7229 0a20 2020 y', handler). \n+0005db90: 2020 2020 2020 2020 2065 7863 6570 7420 except \n+0005dba0: 6173 796e 6369 6f2e 4361 6e63 656c 6c65 asyncio.Cancelle\n+0005dbb0: 6445 7272 6f72 3a0a 2020 2020 2020 2020 dError:. \n+0005dbc0: 2020 2020 2020 2020 2320 7468 6973 2069 # this i\n+0005dbd0: 7320 6e6f 7420 616e 2065 7272 6f72 20e2 s not an error .\n+0005dbe0: 8094 2069 7420 6a75 7374 206d 6561 6e73 .. it just means\n+0005dbf0: 2066 6572 6e79 2d61 736b 7061 7373 2065 ferny-askpass e\n+0005dc00: 7869 7465 6420 7669 6120 7369 676e 616c xited via signal\n+0005dc10: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+0005dc20: 206c 6f67 6765 722e 6465 6275 6728 2725 logger.debug('%\n+0005dc30: 7220 7761 7320 6361 6e63 656c 6c65 6427 r was cancelled'\n+0005dc40: 2c20 6861 6e64 6c65 7229 0a20 2020 2020 , handler). \n+0005dc50: 2020 2020 2020 2065 7863 6570 7420 4578 except Ex\n+0005dc60: 6365 7074 696f 6e20 6173 2065 7863 3a0a ception as exc:.\n+0005dc70: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0005dc80: 6c6f 6767 6572 2e64 6562 7567 2827 2572 logger.debug('%r\n+0005dc90: 2072 6169 7365 6420 2572 272c 2068 616e raised %r', han\n+0005dca0: 646c 6572 2c20 6578 6329 0a20 2020 2020 dler, exc). \n+0005dcb0: 2020 2020 2020 2020 2020 2073 656c 662e self.\n+0005dcc0: 5f72 6573 756c 7428 6578 6329 0a0a 2020 _result(exc).. \n+0005dcd0: 2020 2020 2020 2020 2020 7365 6c66 2e5f self._\n+0005dce0: 636f 6e73 6964 6572 5f63 6f6d 706c 6574 consider_complet\n+0005dcf0: 696f 6e28 290a 0a20 2020 2020 2020 2074 ion().. t\n+0005dd00: 6173 6b2e 6164 645f 646f 6e65 5f63 616c ask.add_done_cal\n+0005dd10: 6c62 6163 6b28 626f 7474 6f6d 5f68 616c lback(bottom_hal\n+0005dd20: 6629 0a20 2020 2020 2020 2073 656c 662e f). self.\n+0005dd30: 5f74 6173 6b73 2e61 6464 2874 6173 6b29 _tasks.add(task)\n+0005dd40: 0a20 2020 2020 2020 2066 6473 5b3a 5d20 . fds[:] \n+0005dd50: 3d20 5b5d 0a0a 2020 2020 6465 6620 5f67 = [].. def _g\n+0005dd60: 6f74 5f64 6174 6128 7365 6c66 2c20 6461 ot_data(self, da\n+0005dd70: 7461 3a20 6279 7465 732c 2066 6473 3a20 ta: bytes, fds: \n+0005dd80: 276c 6973 745b 696e 745d 2729 202d 3e20 'list[int]') -> \n+0005dd90: 4e6f 6e65 3a0a 2020 2020 2020 2020 6c6f None:. lo\n+0005dda0: 6767 6572 2e64 6562 7567 2827 5f67 6f74 gger.debug('_got\n+0005ddb0: 5f64 6174 6128 2572 2c20 2572 2927 2c20 _data(%r, %r)', \n+0005ddc0: 6461 7461 2c20 6664 7329 0a0a 2020 2020 data, fds).. \n+0005ddd0: 2020 2020 6966 2064 6174 6120 3d3d 2062 if data == b\n+0005dde0: 2727 3a0a 2020 2020 2020 2020 2020 2020 '':. \n+0005ddf0: 7365 6c66 2e5f 7265 7375 6c74 2873 656c self._result(sel\n+0005de00: 662e 5f62 7566 6665 722e 6465 636f 6465 f._buffer.decode\n+0005de10: 2865 7272 6f72 733d 2772 6570 6c61 6365 (errors='replace\n+0005de20: 2729 290a 2020 2020 2020 2020 2020 2020 ')). \n+0005de30: 7265 7475 726e 0a0a 2020 2020 2020 2020 return.. \n+0005de40: 7365 6c66 2e5f 6275 6666 6572 2e65 7874 self._buffer.ext\n+0005de50: 656e 6428 6461 7461 290a 0a20 2020 2020 end(data).. \n+0005de60: 2020 2023 2052 6561 6420 7a65 726f 206f # Read zero o\n+0005de70: 7220 6d6f 7265 2022 7265 6d6f 7465 2220 r more \"remote\" \n+0005de80: 6d65 7373 6167 6573 0a20 2020 2020 2020 messages. \n+0005de90: 2063 6875 6e6b 7320 3d20 434f 4d4d 414e chunks = COMMAN\n+0005dea0: 445f 5245 2e73 706c 6974 2873 656c 662e D_RE.split(self.\n+0005deb0: 5f62 7566 6665 7229 0a20 2020 2020 2020 _buffer). \n+0005dec0: 2073 656c 662e 5f62 7566 6665 7220 3d20 self._buffer = \n+0005ded0: 6279 7465 6172 7261 7928 6368 756e 6b73 bytearray(chunks\n+0005dee0: 2e70 6f70 2829 290a 2020 2020 2020 2020 .pop()). \n+0005def0: 7768 696c 6520 6c65 6e28 6368 756e 6b73 while len(chunks\n+0005df00: 2920 3e20 313a 0a20 2020 2020 2020 2020 ) > 1:. \n+0005df10: 2020 2073 656c 662e 5f69 6e76 6f6b 655f self._invoke_\n+0005df20: 636f 6d6d 616e 6428 6368 756e 6b73 5b30 command(chunks[0\n+0005df30: 5d2c 2063 6875 6e6b 735b 315d 2c20 5b5d ], chunks[1], []\n+0005df40: 290a 2020 2020 2020 2020 2020 2020 6368 ). ch\n+0005df50: 756e 6b73 203d 2063 6875 6e6b 735b 323a unks = chunks[2:\n+0005df60: 5d0a 0a20 2020 2020 2020 2023 204d 6179 ].. # May\n+0005df70: 6265 2072 6561 6420 6f6e 6520 226c 6f63 be read one \"loc\n+0005df80: 616c 2220 6d65 7373 6167 650a 2020 2020 al\" message. \n+0005df90: 2020 2020 6966 2066 6473 3a0a 2020 2020 if fds:. \n+0005dfa0: 2020 2020 2020 2020 6173 7365 7274 2073 assert s\n+0005dfb0: 656c 662e 5f62 7566 6665 722e 656e 6473 elf._buffer.ends\n+0005dfc0: 7769 7468 2862 275c 3027 292c 2073 656c with(b'\\0'), sel\n+0005dfd0: 662e 5f62 7566 6665 720a 2020 2020 2020 f._buffer. \n+0005dfe0: 2020 2020 2020 7374 6465 7272 203d 2073 stderr = s\n+0005dff0: 656c 662e 5f62 7566 6665 725b 3a2d 315d elf._buffer[:-1]\n+0005e000: 0a20 2020 2020 2020 2020 2020 2073 656c . sel\n+0005e010: 662e 5f62 7566 6665 7220 3d20 6279 7465 f._buffer = byte\n+0005e020: 6172 7261 7928 6227 2729 0a20 2020 2020 array(b''). \n+0005e030: 2020 2020 2020 2077 6974 6820 6f70 656e with open\n+0005e040: 2866 6473 2e70 6f70 2830 292c 2027 7262 (fds.pop(0), 'rb\n+0005e050: 2729 2061 7320 636f 6d6d 616e 645f 6368 ') as command_ch\n+0005e060: 616e 6e65 6c3a 0a20 2020 2020 2020 2020 annel:. \n+0005e070: 2020 2020 2020 2063 6f6d 6d61 6e64 203d command =\n+0005e080: 2063 6f6d 6d61 6e64 5f63 6861 6e6e 656c command_channel\n+0005e090: 2e72 6561 6428 290a 2020 2020 2020 2020 .read(). \n+0005e0a0: 2020 2020 7365 6c66 2e5f 696e 766f 6b65 self._invoke\n+0005e0b0: 5f63 6f6d 6d61 6e64 2873 7464 6572 722c _command(stderr,\n+0005e0c0: 2063 6f6d 6d61 6e64 2c20 6664 7329 0a0a command, fds)..\n+0005e0d0: 2020 2020 6465 6620 5f72 6561 645f 7265 def _read_re\n+0005e0e0: 6164 7928 7365 6c66 2920 2d3e 204e 6f6e ady(self) -> Non\n+0005e0f0: 653a 0a20 2020 2020 2020 2074 7279 3a0a e:. try:.\n+0005e100: 2020 2020 2020 2020 2020 2020 6461 7461 data\n+0005e110: 2c20 6664 732c 205f 666c 6167 732c 205f , fds, _flags, _\n+0005e120: 6164 6472 203d 2072 6563 765f 6664 7328 addr = recv_fds(\n+0005e130: 7365 6c66 2e5f 6f75 7273 2c20 3430 3936 self._ours, 4096\n+0005e140: 2c20 3130 2c20 666c 6167 733d 736f 636b , 10, flags=sock\n+0005e150: 6574 2e4d 5347 5f44 4f4e 5457 4149 5429 et.MSG_DONTWAIT)\n+0005e160: 0a20 2020 2020 2020 2065 7863 6570 7420 . except \n+0005e170: 426c 6f63 6b69 6e67 494f 4572 726f 723a BlockingIOError:\n+0005e180: 0a20 2020 2020 2020 2020 2020 2072 6574 . ret\n+0005e190: 7572 6e0a 2020 2020 2020 2020 6578 6365 urn. exce\n+0005e1a0: 7074 204f 5345 7272 6f72 2061 7320 6578 pt OSError as ex\n+0005e1b0: 633a 0a20 2020 2020 2020 2020 2020 2073 c:. s\n+0005e1c0: 656c 662e 5f72 6573 756c 7428 6578 6329 elf._result(exc)\n+0005e1d0: 0a20 2020 2020 2020 2065 6c73 653a 0a20 . else:. \n+0005e1e0: 2020 2020 2020 2020 2020 2073 656c 662e self.\n+0005e1f0: 5f67 6f74 5f64 6174 6128 6461 7461 2c20 _got_data(data, \n+0005e200: 6664 7329 0a20 2020 2020 2020 2066 696e fds). fin\n+0005e210: 616c 6c79 3a0a 2020 2020 2020 2020 2020 ally:. \n+0005e220: 2020 7768 696c 6520 6664 733a 0a20 2020 while fds:. \n+0005e230: 2020 2020 2020 2020 2020 2020 206f 732e os.\n+0005e240: 636c 6f73 6528 6664 732e 706f 7028 2929 close(fds.pop())\n+0005e250: 0a0a 2020 2020 6465 6620 5f5f 696e 6974 .. def __init\n+0005e260: 5f5f 280a 2020 2020 2020 2020 7365 6c66 __(. self\n+0005e270: 2c0a 2020 2020 2020 2020 6861 6e64 6c65 ,. handle\n+0005e280: 7273 3a20 5365 7175 656e 6365 5b49 6e74 rs: Sequence[Int\n+0005e290: 6572 6163 7469 6f6e 4861 6e64 6c65 725d eractionHandler]\n+0005e2a0: 2c0a 2020 2020 2020 2020 6c6f 6f70 3a20 ,. loop: \n+0005e2b0: 2761 7379 6e63 696f 2e41 6273 7472 6163 'asyncio.Abstrac\n+0005e2c0: 7445 7665 6e74 4c6f 6f70 207c 204e 6f6e tEventLoop | Non\n+0005e2d0: 6527 203d 204e 6f6e 652c 0a20 2020 2020 e' = None,. \n+0005e2e0: 2020 2064 6f6e 655f 6361 6c6c 6261 636b done_callback\n+0005e2f0: 3a20 2743 616c 6c61 626c 655b 5b61 7379 : 'Callable[[asy\n+0005e300: 6e63 696f 2e46 7574 7572 655b 7374 725d ncio.Future[str]\n+0005e310: 5d2c 204e 6f6e 655d 207c 204e 6f6e 6527 ], None] | None'\n+0005e320: 203d 204e 6f6e 652c 0a20 2020 2029 202d = None,. ) -\n+0005e330: 3e20 4e6f 6e65 3a0a 2020 2020 2020 2020 > None:. \n+0005e340: 7365 6c66 2e5f 6c6f 6f70 203d 206c 6f6f self._loop = loo\n+0005e350: 7020 6f72 2067 6574 5f72 756e 6e69 6e67 p or get_running\n+0005e360: 5f6c 6f6f 7028 290a 2020 2020 2020 2020 _loop(). \n+0005e370: 7365 6c66 2e5f 636f 6d70 6c65 7469 6f6e self._completion\n+0005e380: 5f66 7574 7572 6520 3d20 7365 6c66 2e5f _future = self._\n+0005e390: 6c6f 6f70 2e63 7265 6174 655f 6675 7475 loop.create_futu\n+0005e3a0: 7265 2829 0a20 2020 2020 2020 2073 656c re(). sel\n+0005e3b0: 662e 5f74 6173 6b73 203d 2073 6574 2829 f._tasks = set()\n+0005e3c0: 0a20 2020 2020 2020 2073 656c 662e 5f68 . self._h\n+0005e3d0: 616e 646c 6572 7320 3d20 7b7d 0a0a 2020 andlers = {}.. \n+0005e3e0: 2020 2020 2020 666f 7220 6861 6e64 6c65 for handle\n+0005e3f0: 7220 696e 2068 616e 646c 6572 733a 0a20 r in handlers:. \n+0005e400: 2020 2020 2020 2020 2020 2066 6f72 2063 for c\n+0005e410: 6f6d 6d61 6e64 2069 6e20 6861 6e64 6c65 ommand in handle\n+0005e420: 722e 636f 6d6d 616e 6473 3a0a 2020 2020 r.commands:. \n+0005e430: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n+0005e440: 2e5f 6861 6e64 6c65 7273 5b63 6f6d 6d61 ._handlers[comma\n+0005e450: 6e64 5d20 3d20 6861 6e64 6c65 720a 0a20 nd] = handler.. \n+0005e460: 2020 2020 2020 2069 6620 646f 6e65 5f63 if done_c\n+0005e470: 616c 6c62 6163 6b20 6973 206e 6f74 204e allback is not N\n+0005e480: 6f6e 653a 0a20 2020 2020 2020 2020 2020 one:. \n+0005e490: 2073 656c 662e 5f63 6f6d 706c 6574 696f self._completio\n+0005e4a0: 6e5f 6675 7475 7265 2e61 6464 5f64 6f6e n_future.add_don\n+0005e4b0: 655f 6361 6c6c 6261 636b 2864 6f6e 655f e_callback(done_\n+0005e4c0: 6361 6c6c 6261 636b 290a 0a20 2020 2020 callback).. \n+0005e4d0: 2020 2073 656c 662e 5f74 6865 6972 732c self._theirs,\n+0005e4e0: 2073 656c 662e 5f6f 7572 7320 3d20 736f self._ours = so\n+0005e4f0: 636b 6574 2e73 6f63 6b65 7470 6169 7228 cket.socketpair(\n+0005e500: 736f 636b 6574 2e41 465f 554e 4958 2c20 socket.AF_UNIX, \n+0005e510: 736f 636b 6574 2e53 4f43 4b5f 5354 5245 socket.SOCK_STRE\n+0005e520: 414d 290a 2020 2020 2020 2020 7365 6c66 AM). self\n+0005e530: 2e5f 6275 6666 6572 203d 2062 7974 6561 ._buffer = bytea\n+0005e540: 7272 6179 2829 0a0a 2020 2020 6465 6620 rray().. def \n+0005e550: 6669 6c65 6e6f 2873 656c 6629 202d 3e20 fileno(self) -> \n+0005e560: 696e 743a 0a20 2020 2020 2020 2072 6574 int:. ret\n+0005e570: 7572 6e20 7365 6c66 2e5f 7468 6569 7273 urn self._theirs\n+0005e580: 2e66 696c 656e 6f28 290a 0a20 2020 2064 .fileno().. d\n+0005e590: 6566 2073 7461 7274 2873 656c 6629 202d ef start(self) -\n+0005e5a0: 3e20 4e6f 6e65 3a0a 2020 2020 2020 2020 > None:. \n+0005e5b0: 6c6f 6767 6572 2e64 6562 7567 2827 7374 logger.debug('st\n+0005e5c0: 6172 7428 2572 2927 2c20 7365 6c66 290a art(%r)', self).\n+0005e5d0: 2020 2020 2020 2020 6966 2073 656c 662e if self.\n+0005e5e0: 5f6f 7572 732e 6669 6c65 6e6f 2829 2021 _ours.fileno() !\n+0005e5f0: 3d20 2d31 3a0a 2020 2020 2020 2020 2020 = -1:. \n+0005e600: 2020 6c6f 6767 6572 2e64 6562 7567 2827 logger.debug('\n+0005e610: 2020 6164 645f 7265 6164 6572 2825 7229 add_reader(%r)\n+0005e620: 272c 2073 656c 662e 5f6f 7572 7329 0a20 ', self._ours). \n+0005e630: 2020 2020 2020 2020 2020 2073 656c 662e self.\n+0005e640: 5f6c 6f6f 702e 6164 645f 7265 6164 6572 _loop.add_reader\n+0005e650: 2873 656c 662e 5f6f 7572 732e 6669 6c65 (self._ours.file\n+0005e660: 6e6f 2829 2c20 7365 6c66 2e5f 7265 6164 no(), self._read\n+0005e670: 5f72 6561 6479 290a 2020 2020 2020 2020 _ready). \n+0005e680: 656c 7365 3a0a 2020 2020 2020 2020 2020 else:. \n+0005e690: 2020 6c6f 6767 6572 2e64 6562 7567 2827 logger.debug('\n+0005e6a0: 2020 2e2e 2e62 7574 2061 6765 6e74 2069 ...but agent i\n+0005e6b0: 7320 616c 7265 6164 7920 6669 6e69 7368 s already finish\n+0005e6c0: 6564 2e27 290a 0a20 2020 2020 2020 206c ed.').. l\n+0005e6d0: 6f67 6765 722e 6465 6275 6728 2720 2063 ogger.debug(' c\n+0005e6e0: 6c6f 7365 2825 7229 272c 2073 656c 662e lose(%r)', self.\n+0005e6f0: 5f74 6865 6972 7329 0a20 2020 2020 2020 _theirs). \n+0005e700: 2073 656c 662e 5f74 6865 6972 732e 636c self._theirs.cl\n+0005e710: 6f73 6528 290a 0a20 2020 2064 6566 2066 ose().. def f\n+0005e720: 6f72 6365 5f63 6f6d 706c 6574 696f 6e28 orce_completion(\n+0005e730: 7365 6c66 2920 2d3e 204e 6f6e 653a 0a20 self) -> None:. \n+0005e740: 2020 2020 2020 206c 6f67 6765 722e 6465 logger.de\n+0005e750: 6275 6728 2766 6f72 6365 5f63 6f6d 706c bug('force_compl\n+0005e760: 6574 696f 6e28 2572 2927 2c20 7365 6c66 etion(%r)', self\n+0005e770: 290a 0a20 2020 2020 2020 2023 2072 6561 ).. # rea\n+0005e780: 6420 616e 7920 7265 7369 6475 616c 2064 d any residual d\n+0005e790: 6174 6120 6f6e 2073 7464 6572 722c 2062 ata on stderr, b\n+0005e7a0: 7574 2064 6f6e 2774 2070 726f 6365 7373 ut don't process\n+0005e7b0: 2063 6f6d 6d61 6e64 732c 2061 6e64 0a20 commands, and. \n+0005e7c0: 2020 2020 2020 2023 2064 6f6e 2774 2062 # don't b\n+0005e7d0: 6c6f 636b 0a20 2020 2020 2020 2074 7279 lock. try\n+0005e7e0: 3a0a 2020 2020 2020 2020 2020 2020 6966 :. if\n+0005e7f0: 2073 656c 662e 5f6f 7572 732e 6669 6c65 self._ours.file\n+0005e800: 6e6f 2829 2021 3d20 2d31 3a0a 2020 2020 no() != -1:. \n+0005e810: 2020 2020 2020 2020 2020 2020 6c6f 6767 logg\n+0005e820: 6572 2e64 6562 7567 2827 2020 6472 6169 er.debug(' drai\n+0005e830: 6e69 6e67 2070 656e 6469 6e67 2073 7464 ning pending std\n+0005e840: 6572 7220 6461 7461 2028 6e6f 6e2d 626c err data (non-bl\n+0005e850: 6f63 6b69 6e67 2927 290a 2020 2020 2020 ocking)'). \n+0005e860: 2020 2020 2020 2020 2020 7769 7468 2063 with c\n+0005e870: 6f6e 7465 7874 6c69 622e 7375 7070 7265 ontextlib.suppre\n+0005e880: 7373 2842 6c6f 636b 696e 6749 4f45 7272 ss(BlockingIOErr\n+0005e890: 6f72 293a 0a20 2020 2020 2020 2020 2020 or):. \n+0005e8a0: 2020 2020 2020 2020 2077 6869 6c65 2054 while T\n+0005e8b0: 7275 653a 0a20 2020 2020 2020 2020 2020 rue:. \n+0005e8c0: 2020 2020 2020 2020 2020 2020 2064 6174 dat\n+0005e8d0: 6120 3d20 7365 6c66 2e5f 6f75 7273 2e72 a = self._ours.r\n+0005e8e0: 6563 7628 3430 3936 2c20 736f 636b 6574 ecv(4096, socket\n+0005e8f0: 2e4d 5347 5f44 4f4e 5457 4149 5429 0a20 .MSG_DONTWAIT). \n+0005e900: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0005e910: 2020 2020 2020 206c 6f67 6765 722e 6465 logger.de\n+0005e920: 6275 6728 2720 2020 2067 6f74 2025 6420 bug(' got %d \n+0005e930: 6279 7465 7327 2c20 6c65 6e28 6461 7461 bytes', len(data\n+0005e940: 2929 0a20 2020 2020 2020 2020 2020 2020 )). \n+0005e950: 2020 2020 2020 2020 2020 2069 6620 6e6f if no\n+0005e960: 7420 6461 7461 3a0a 2020 2020 2020 2020 t data:. \n+0005e970: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0005e980: 2020 2020 6272 6561 6b0a 2020 2020 2020 break. \n+0005e990: 2020 2020 2020 2020 2020 2020 2020 2020 \n+0005e9a0: 2020 7365 6c66 2e5f 6275 6666 6572 2e65 self._buffer.e\n+0005e9b0: 7874 656e 6428 6461 7461 290a 2020 2020 xtend(data). \n+0005e9c0: 2020 2020 6578 6365 7074 204f 5345 7272 except OSErr\n+0005e9d0: 6f72 2061 7320 6578 633a 0a20 2020 2020 or as exc:. \n+0005e9e0: 2020 2020 2020 2073 656c 662e 5f72 6573 self._res\n+0005e9f0: 756c 7428 6578 6329 0a20 2020 2020 2020 ult(exc). \n+0005ea00: 2065 6c73 653a 0a20 2020 2020 2020 2020 else:. \n+0005ea10: 2020 2073 656c 662e 5f72 6573 756c 7428 self._result(\n+0005ea20: 7365 6c66 2e5f 6275 6666 6572 2e64 6563 self._buffer.dec\n+0005ea30: 6f64 6528 6572 726f 7273 3d27 7265 706c ode(errors='repl\n+0005ea40: 6163 6527 2929 0a0a 2020 2020 6173 796e ace')).. asyn\n+0005ea50: 6320 6465 6620 636f 6d6d 756e 6963 6174 c def communicat\n+0005ea60: 6528 7365 6c66 2920 2d3e 204e 6f6e 653a e(self) -> None:\n+0005ea70: 0a20 2020 2020 2020 206c 6f67 6765 722e . logger.\n+0005ea80: 6465 6275 6728 275f 636f 6d6d 756e 6963 debug('_communic\n+0005ea90: 6174 6528 2572 2927 2c20 7365 6c66 290a ate(%r)', self).\n+0005eaa0: 2020 2020 2020 2020 7472 793a 0a20 2020 try:. \n+0005eab0: 2020 2020 2020 2020 2073 656c 662e 7374 self.st\n+0005eac0: 6172 7428 290a 2020 2020 2020 2020 2020 art(). \n+0005ead0: 2020 2320 5765 2061 7373 756d 6520 7468 # We assume th\n+0005eae0: 6174 2077 6520 6172 6520 7468 6520 6f6e at we are the on\n+0005eaf0: 6c79 206f 6e65 7320 746f 2077 7269 7465 ly ones to write\n+0005eb00: 2074 6f0a 2020 2020 2020 2020 2020 2020 to. \n+0005eb10: 2320 7365 6c66 2e5f 636f 6d70 6c65 7469 # self._completi\n+0005eb20: 6f6e 5f66 7574 7572 652e 2020 4966 2077 on_future. If w\n+0005eb30: 6520 6469 7265 6374 6c79 2061 7761 6974 e directly await\n+0005eb40: 2069 742c 2074 686f 7567 682c 2069 7420 it, though, it \n+0005eb50: 6361 6e0a 2020 2020 2020 2020 2020 2020 can. \n+0005eb60: 2320 616c 736f 2068 6176 6520 6120 6173 # also have a as\n+0005eb70: 796e 6369 6f2e 4361 6e63 656c 6c65 6445 yncio.CancelledE\n+0005eb80: 7272 6f72 2070 6f73 7465 6420 746f 2069 rror posted to i\n+0005eb90: 7420 6672 6f6d 206f 7574 7369 6465 2e0a t from outside..\n+0005eba0: 2020 2020 2020 2020 2020 2020 2320 5368 # Sh\n+0005ebb0: 6965 6c64 2069 7420 746f 2070 7265 7665 ield it to preve\n+0005ebc0: 6e74 2074 6861 7420 6672 6f6d 2068 6170 nt that from hap\n+0005ebd0: 7065 6e69 6e67 2e0a 2020 2020 2020 2020 pening.. \n+0005ebe0: 2020 2020 7374 6465 7272 203d 2061 7761 stderr = awa\n+0005ebf0: 6974 2061 7379 6e63 696f 2e73 6869 656c it asyncio.shiel\n+0005ec00: 6428 7365 6c66 2e5f 636f 6d70 6c65 7469 d(self._completi\n+0005ec10: 6f6e 5f66 7574 7572 6529 0a20 2020 2020 on_future). \n+0005ec20: 2020 2020 2020 206c 6f67 6765 722e 6465 logger.de\n+0005ec30: 6275 6728 275f 636f 6d6d 756e 6963 6174 bug('_communicat\n+0005ec40: 6528 2572 2920 7374 6465 7272 2072 6573 e(%r) stderr res\n+0005ec50: 756c 7420 6973 2025 7227 2c20 7365 6c66 ult is %r', self\n+0005ec60: 2c20 7374 6465 7272 290a 2020 2020 2020 , stderr). \n+0005ec70: 2020 6669 6e61 6c6c 793a 0a20 2020 2020 finally:. \n+0005ec80: 2020 2020 2020 206c 6f67 6765 722e 6465 logger.de\n+0005ec90: 6275 6728 275f 636f 6d6d 756e 6963 6174 bug('_communicat\n+0005eca0: 6520 6669 6e69 7368 6564 2e20 2045 6e73 e finished. Ens\n+0005ecb0: 7572 696e 6720 636f 6d70 6c65 7469 6f6e uring completion\n+0005ecc0: 2e27 290a 2020 2020 2020 2020 2020 2020 .'). \n+0005ecd0: 7365 6c66 2e66 6f72 6365 5f63 6f6d 706c self.force_compl\n+0005ece0: 6574 696f 6e28 290a 2020 2020 2020 2020 etion(). \n+0005ecf0: 6966 206e 6f74 2073 656c 662e 5f65 6e64 if not self._end\n+0005ed00: 3a0a 2020 2020 2020 2020 2020 2020 6c6f :. lo\n+0005ed10: 6767 6572 2e64 6562 7567 2827 5f63 6f6d gger.debug('_com\n+0005ed20: 6d75 6e69 6361 7465 206e 6576 6572 2073 municate never s\n+0005ed30: 6177 2066 6572 6e79 2e65 6e64 2e20 2072 aw ferny.end. r\n+0005ed40: 6169 7369 6e67 2049 6e74 6572 6163 7469 aising Interacti\n+0005ed50: 6f6e 4572 726f 722e 2729 0a20 2020 2020 onError.'). \n+0005ed60: 2020 2020 2020 2072 6169 7365 2049 6e74 raise Int\n+0005ed70: 6572 6163 7469 6f6e 4572 726f 7228 7374 eractionError(st\n+0005ed80: 6465 7272 2e73 7472 6970 2829 290a 0a0a derr.strip())...\n+0005ed90: 6465 6620 7772 6974 655f 6173 6b70 6173 def write_askpas\n+0005eda0: 735f 746f 5f74 6d70 6469 7228 746d 7064 s_to_tmpdir(tmpd\n+0005edb0: 6972 3a20 7374 7229 202d 3e20 7374 723a ir: str) -> str:\n+0005edc0: 0a20 2020 2061 736b 7061 7373 5f70 6174 . askpass_pat\n+0005edd0: 6820 3d20 6f73 2e70 6174 682e 6a6f 696e h = os.path.join\n+0005ede0: 2874 6d70 6469 722c 2027 6665 726e 792d (tmpdir, 'ferny-\n+0005edf0: 6173 6b70 6173 7327 290a 2020 2020 6664 askpass'). fd\n+0005ee00: 203d 206f 732e 6f70 656e 2861 736b 7061 = os.open(askpa\n+0005ee10: 7373 5f70 6174 682c 206f 732e 4f5f 4352 ss_path, os.O_CR\n+0005ee20: 4541 5420 7c20 6f73 2e4f 5f57 524f 4e4c EAT | os.O_WRONL\n+0005ee30: 5920 7c20 6f73 2e4f 5f43 4c4f 4558 4543 Y | os.O_CLOEXEC\n+0005ee40: 207c 206f 732e 4f5f 4558 434c 207c 206f | os.O_EXCL | o\n+0005ee50: 732e 4f5f 4e4f 464f 4c4c 4f57 2c20 306f s.O_NOFOLLOW, 0o\n+0005ee60: 3737 3729 0a20 2020 2074 7279 3a0a 2020 777). try:. \n+0005ee70: 2020 2020 2020 6f73 2e77 7269 7465 2866 os.write(f\n+0005ee80: 642c 205f 5f6c 6f61 6465 725f 5f2e 6765 d, __loader__.ge\n+0005ee90: 745f 6461 7461 2869 6e74 6572 6163 7469 t_data(interacti\n+0005eea0: 6f6e 5f63 6c69 656e 742e 5f5f 6669 6c65 on_client.__file\n+0005eeb0: 5f5f 2929 2020 2320 7479 7065 3a20 6967 __)) # type: ig\n+0005eec0: 6e6f 7265 0a20 2020 2066 696e 616c 6c79 nore. finally\n+0005eed0: 3a0a 2020 2020 2020 2020 6f73 2e63 6c6f :. os.clo\n+0005eee0: 7365 2866 6429 0a20 2020 2072 6574 7572 se(fd). retur\n+0005eef0: 6e20 6173 6b70 6173 735f 7061 7468 0a0a n askpass_path..\n+0005ef00: 0a40 636f 6e74 6578 746c 6962 2e63 6f6e .@contextlib.con\n+0005ef10: 7465 7874 6d61 6e61 6765 720a 6465 6620 textmanager.def \n+0005ef20: 7465 6d70 6f72 6172 795f 6173 6b70 6173 temporary_askpas\n+0005ef30: 7328 2a2a 6b77 6172 6773 3a20 416e 7929 s(**kwargs: Any)\n+0005ef40: 202d 3e20 4765 6e65 7261 746f 725b 7374 -> Generator[st\n+0005ef50: 722c 204e 6f6e 652c 204e 6f6e 655d 3a0a r, None, None]:.\n+0005ef60: 2020 2020 7769 7468 2074 656d 7066 696c with tempfil\n+0005ef70: 652e 5465 6d70 6f72 6172 7944 6972 6563 e.TemporaryDirec\n+0005ef80: 746f 7279 282a 2a6b 7761 7267 7329 2061 tory(**kwargs) a\n+0005ef90: 7320 6469 7265 6374 6f72 793a 0a20 2020 s directory:. \n+0005efa0: 2020 2020 2079 6965 6c64 2077 7269 7465 yield write\n+0005efb0: 5f61 736b 7061 7373 5f74 6f5f 746d 7064 _askpass_to_tmpd\n+0005efc0: 6972 2864 6972 6563 746f 7279 290a 2727 ir(directory).''\n+0005efd0: 272e 656e 636f 6465 2827 7574 662d 3827 '.encode('utf-8'\n+0005efe0: 292c 0a20 2027 636f 636b 7069 742f 5f76 ),. 'cockpit/_v\n+0005eff0: 656e 646f 722f 6665 726e 792f 7472 616e endor/ferny/tran\n+0005f000: 7370 6f72 742e 7079 273a 2062 7227 2727 sport.py': br'''\n+0005f010: 2320 6665 726e 7920 2d20 6173 796e 6369 # ferny - asynci\n+0005f020: 6f20 5353 4820 636c 6965 6e74 206c 6962 o SSH client lib\n+0005f030: 7261 7279 2c20 7573 696e 6720 7373 6828 rary, using ssh(\n+0005f040: 3129 0a23 0a23 2043 6f70 7972 6967 6874 1).#.# Copyright\n+0005f050: 2028 4329 2032 3032 3320 416c 6c69 736f (C) 2023 Alliso\n+0005f060: 6e20 4b61 726c 6974 736b 6179 6120 3c61 n Karlitskaya .#\n+0005f090: 0a23 2054 6869 7320 7072 6f67 7261 6d20 .# This program \n+0005f0a0: 6973 2066 7265 6520 736f 6674 7761 7265 is free software\n+0005f0b0: 3a20 796f 7520 6361 6e20 7265 6469 7374 : you can redist\n+0005f0c0: 7269 6275 7465 2069 7420 616e 642f 6f72 ribute it and/or\n+0005f0d0: 206d 6f64 6966 790a 2320 6974 2075 6e64 modify.# it und\n+0005f0e0: 6572 2074 6865 2074 6572 6d73 206f 6620 er the terms of \n+0005f0f0: 7468 6520 474e 5520 4765 6e65 7261 6c20 the GNU General \n+0005f100: 5075 626c 6963 204c 6963 656e 7365 2061 Public License a\n+0005f110: 7320 7075 626c 6973 6865 6420 6279 0a23 s published by.#\n+0005f120: 2074 6865 2046 7265 6520 536f 6674 7761 the Free Softwa\n+0005f130: 7265 2046 6f75 6e64 6174 696f 6e2c 2065 re Foundation, e\n+0005f140: 6974 6865 7220 7665 7273 696f 6e20 3320 ither version 3 \n+0005f150: 6f66 2074 6865 204c 6963 656e 7365 2c20 of the License, \n+0005f160: 6f72 0a23 2028 6174 2079 6f75 7220 6f70 or.# (at your op\n+0005f170: 7469 6f6e 2920 616e 7920 6c61 7465 7220 tion) any later \n+0005f180: 7665 7273 696f 6e2e 0a23 0a23 2054 6869 version..#.# Thi\n+0005f190: 7320 7072 6f67 7261 6d20 6973 2064 6973 s program is dis\n+0005f1a0: 7472 6962 7574 6564 2069 6e20 7468 6520 tributed in the \n+0005f1b0: 686f 7065 2074 6861 7420 6974 2077 696c hope that it wil\n+0005f1c0: 6c20 6265 2075 7365 6675 6c2c 0a23 2062 l be useful,.# b\n+0005f1d0: 7574 2057 4954 484f 5554 2041 4e59 2057 ut WITHOUT ANY W\n+0005f1e0: 4152 5241 4e54 593b 2077 6974 686f 7574 ARRANTY; without\n+0005f1f0: 2065 7665 6e20 7468 6520 696d 706c 6965 even the implie\n+0005f200: 6420 7761 7272 616e 7479 206f 660a 2320 d warranty of.# \n+0005f210: 4d45 5243 4841 4e54 4142 494c 4954 5920 MERCHANTABILITY \n+0005f220: 6f72 2046 4954 4e45 5353 2046 4f52 2041 or FITNESS FOR A\n+0005f230: 2050 4152 5449 4355 4c41 5220 5055 5250 PARTICULAR PURP\n+0005f240: 4f53 452e 2020 5365 6520 7468 650a 2320 OSE. See the.# \n+0005f250: 474e 5520 4765 6e65 7261 6c20 5075 626c GNU General Publ\n+0005f260: 6963 204c 6963 656e 7365 2066 6f72 206d ic License for m\n+0005f270: 6f72 6520 6465 7461 696c 732e 0a23 0a23 ore details..#.#\n+0005f280: 2059 6f75 2073 686f 756c 6420 6861 7665 You should have\n+0005f290: 2072 6563 6569 7665 6420 6120 636f 7079 received a copy\n+0005f2a0: 206f 6620 7468 6520 474e 5520 4765 6e65 of the GNU Gene\n+0005f2b0: 7261 6c20 5075 626c 6963 204c 6963 656e ral Public Licen\n+0005f2c0: 7365 0a23 2061 6c6f 6e67 2077 6974 6820 se.# along with \n+0005f2d0: 7468 6973 2070 726f 6772 616d 2e20 2049 this program. I\n+0005f2e0: 6620 6e6f 742c 2073 6565 203c 6874 7470 f not, see ...impo\n+0005f310: 7274 2061 7379 6e63 696f 0a69 6d70 6f72 rt asyncio.impor\n+0005f320: 7420 636f 6e74 6578 746c 6962 0a69 6d70 t contextlib.imp\n+0005f330: 6f72 7420 6c6f 6767 696e 670a 696d 706f ort logging.impo\n+0005f340: 7274 2074 7970 696e 670a 6672 6f6d 2074 rt typing.from t\n+0005f350: 7970 696e 6720 696d 706f 7274 2041 6e79 yping import Any\n+0005f360: 2c20 4361 6c6c 6162 6c65 2c20 4974 6572 , Callable, Iter\n+0005f370: 6162 6c65 2c20 5365 7175 656e 6365 2c20 able, Sequence, \n+0005f380: 5479 7065 5661 720a 0a66 726f 6d20 2e69 TypeVar..from .i\n+0005f390: 6e74 6572 6163 7469 6f6e 5f61 6765 6e74 nteraction_agent\n+0005f3a0: 2069 6d70 6f72 7420 496e 7465 7261 6374 import Interact\n+0005f3b0: 696f 6e41 6765 6e74 2c20 496e 7465 7261 ionAgent, Intera\n+0005f3c0: 6374 696f 6e48 616e 646c 6572 2c20 6765 ctionHandler, ge\n+0005f3d0: 745f 7275 6e6e 696e 675f 6c6f 6f70 0a66 t_running_loop.f\n+0005f3e0: 726f 6d20 2e73 7368 5f65 7272 6f72 7320 rom .ssh_errors \n+0005f3f0: 696d 706f 7274 2067 6574 5f65 7863 6570 import get_excep\n+0005f400: 7469 6f6e 5f66 6f72 5f73 7368 5f73 7464 tion_for_ssh_std\n+0005f410: 6572 720a 0a6c 6f67 6765 7220 3d20 6c6f err..logger = lo\n+0005f420: 6767 696e 672e 6765 744c 6f67 6765 7228 gging.getLogger(\n+0005f430: 5f5f 6e61 6d65 5f5f 290a 0a50 203d 2054 __name__)..P = T\n+0005f440: 7970 6556 6172 2827 5027 2c20 626f 756e ypeVar('P', boun\n+0005f450: 643d 6173 796e 6369 6f2e 5072 6f74 6f63 d=asyncio.Protoc\n+0005f460: 6f6c 290a 0a0a 636c 6173 7320 5375 6270 ol)...class Subp\n+0005f470: 726f 6365 7373 4572 726f 7228 4578 6365 rocessError(Exce\n+0005f480: 7074 696f 6e29 3a0a 2020 2020 7265 7475 ption):. retu\n+0005f490: 726e 636f 6465 3a20 696e 740a 2020 2020 rncode: int. \n+0005f4a0: 7374 6465 7272 3a20 7374 720a 0a20 2020 stderr: str.. \n+0005f4b0: 2064 6566 205f 5f69 6e69 745f 5f28 7365 def __init__(se\n+0005f4c0: 6c66 2c20 7265 7475 726e 636f 6465 3a20 lf, returncode: \n+0005f4d0: 696e 742c 2073 7464 6572 723a 2073 7472 int, stderr: str\n+0005f4e0: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n+0005f4f0: 2020 2073 7570 6572 2829 2e5f 5f69 6e69 super().__ini\n+0005f500: 745f 5f28 7265 7475 726e 636f 6465 2c20 t__(returncode, \n+0005f510: 7374 6465 7272 290a 2020 2020 2020 2020 stderr). \n+0005f520: 7365 6c66 2e72 6574 7572 6e63 6f64 6520 self.returncode \n+0005f530: 3d20 7265 7475 726e 636f 6465 0a20 2020 = returncode. \n+0005f540: 2020 2020 2073 656c 662e 7374 6465 7272 self.stderr\n+0005f550: 203d 2073 7464 6572 720a 0a0a 636c 6173 = stderr...clas\n+0005f560: 7320 4665 726e 7954 7261 6e73 706f 7274 s FernyTransport\n+0005f570: 2861 7379 6e63 696f 2e54 7261 6e73 706f (asyncio.Transpo\n+0005f580: 7274 2c20 6173 796e 6369 6f2e 5375 6270 rt, asyncio.Subp\n+0005f590: 726f 6365 7373 5072 6f74 6f63 6f6c 293a rocessProtocol):\n+0005f5a0: 0a20 2020 205f 6167 656e 743a 2049 6e74 . _agent: Int\n+0005f5b0: 6572 6163 7469 6f6e 4167 656e 740a 2020 eractionAgent. \n+0005f5c0: 2020 5f65 7865 635f 7461 736b 3a20 2761 _exec_task: 'a\n+0005f5d0: 7379 6e63 696f 2e54 6173 6b5b 7475 706c syncio.Task[tupl\n+0005f5e0: 655b 6173 796e 6369 6f2e 5375 6270 726f e[asyncio.Subpro\n+0005f5f0: 6365 7373 5472 616e 7370 6f72 742c 2046 cessTransport, F\n+0005f600: 6572 6e79 5472 616e 7370 6f72 745d 5d27 ernyTransport]]'\n+0005f610: 0a20 2020 205f 6973 5f73 7368 3a20 626f . _is_ssh: bo\n+0005f620: 6f6c 0a20 2020 205f 7072 6f74 6f63 6f6c ol. _protocol\n+0005f630: 3a20 6173 796e 6369 6f2e 5072 6f74 6f63 : asyncio.Protoc\n+0005f640: 6f6c 0a20 2020 205f 7072 6f74 6f63 6f6c ol. _protocol\n+0005f650: 5f64 6973 636f 6e6e 6563 7465 643a 2062 _disconnected: b\n+0005f660: 6f6f 6c20 3d20 4661 6c73 650a 0a20 2020 ool = False.. \n+0005f670: 2023 2054 6865 7365 2067 6574 2069 6e69 # These get ini\n+0005f680: 7469 616c 697a 6564 2069 6e20 636f 6e6e tialized in conn\n+0005f690: 6563 7469 6f6e 5f6d 6164 6528 2920 616e ection_made() an\n+0005f6a0: 6420 6f6e 6365 2073 6574 2c20 6e65 7665 d once set, neve\n+0005f6b0: 7220 6765 7420 756e 7365 742e 0a20 2020 r get unset.. \n+0005f6c0: 205f 7375 6270 726f 6365 7373 5f74 7261 _subprocess_tra\n+0005f6d0: 6e73 706f 7274 3a20 2761 7379 6e63 696f nsport: 'asyncio\n+0005f6e0: 2e53 7562 7072 6f63 6573 7354 7261 6e73 .SubprocessTrans\n+0005f6f0: 706f 7274 207c 204e 6f6e 6527 203d 204e port | None' = N\n+0005f700: 6f6e 650a 2020 2020 5f73 7464 696e 5f74 one. _stdin_t\n+0005f710: 7261 6e73 706f 7274 3a20 2761 7379 6e63 ransport: 'async\n+0005f720: 696f 2e57 7269 7465 5472 616e 7370 6f72 io.WriteTranspor\n+0005f730: 7420 7c20 4e6f 6e65 2720 3d20 4e6f 6e65 t | None' = None\n+0005f740: 0a20 2020 205f 7374 646f 7574 5f74 7261 . _stdout_tra\n+0005f750: 6e73 706f 7274 3a20 2761 7379 6e63 696f nsport: 'asyncio\n+0005f760: 2e52 6561 6454 7261 6e73 706f 7274 207c .ReadTransport |\n+0005f770: 204e 6f6e 6527 203d 204e 6f6e 650a 0a20 None' = None.. \n+0005f780: 2020 2023 2057 6520 7265 636f 7264 2065 # We record e\n+0005f790: 7665 6e74 7320 7468 6174 206d 6967 6874 vents that might\n+0005f7a0: 2062 7569 6c64 2074 6f77 6172 6473 2061 build towards a\n+0005f7b0: 2063 6f6e 6e65 6374 696f 6e20 7465 726d connection term\n+0005f7c0: 696e 6174 696f 6e20 6865 7265 0a20 2020 ination here. \n+0005f7d0: 2023 2061 6e64 2063 6f6e 7369 6465 7220 # and consider \n+0005f7e0: 7468 656d 2066 726f 6d20 5f63 6f6e 7369 them from _consi\n+0005f7f0: 6465 725f 6469 7363 6f6e 6e65 6374 2829 der_disconnect()\n+0005f800: 2069 6e20 6f72 6465 7220 746f 2074 7279 in order to try\n+0005f810: 2074 6f20 6765 7420 7468 650a 2020 2020 to get the. \n+0005f820: 2320 6265 7374 2070 6f73 7369 626c 6520 # best possible \n+0005f830: 4578 6365 7074 696f 6e20 666f 7220 7468 Exception for th\n+0005f840: 6520 7072 6f74 6f63 6f6c 2c20 7261 7468 e protocol, rath\n+0005f850: 6572 2074 6861 6e20 6a75 7374 2074 616b er than just tak\n+0005f860: 696e 6720 7468 650a 2020 2020 2320 6669 ing the. # fi\n+0005f870: 7273 7420 6f6e 6520 2877 6869 6368 2069 rst one (which i\n+0005f880: 7320 6c69 6b65 6c79 2074 6f20 6265 2073 s likely to be s\n+0005f890: 6f6d 6577 6861 7420 7261 6e64 6f6d 292e omewhat random).\n+0005f8a0: 0a20 2020 205f 6578 6365 7074 696f 6e3a . _exception:\n+0005f8b0: 2027 4578 6365 7074 696f 6e20 7c20 4e6f 'Exception | No\n+0005f8c0: 6e65 2720 3d20 4e6f 6e65 0a20 2020 205f ne' = None. _\n+0005f8d0: 7374 6465 7272 5f6f 7574 7075 743a 2027 stderr_output: '\n+0005f8e0: 7374 7220 7c20 4e6f 6e65 2720 3d20 4e6f str | None' = No\n+0005f8f0: 6e65 0a20 2020 205f 7265 7475 726e 636f ne. _returnco\n+0005f900: 6465 3a20 2769 6e74 207c 204e 6f6e 6527 de: 'int | None'\n+0005f910: 203d 204e 6f6e 650a 2020 2020 5f74 7261 = None. _tra\n+0005f920: 6e73 706f 7274 5f64 6973 636f 6e6e 6563 nsport_disconnec\n+0005f930: 7465 643a 2062 6f6f 6c20 3d20 4661 6c73 ted: bool = Fals\n+0005f940: 650a 2020 2020 5f63 6c6f 7365 643a 2062 e. _closed: b\n+0005f950: 6f6f 6c20 3d20 4661 6c73 650a 0a20 2020 ool = False.. \n+0005f960: 2040 636c 6173 736d 6574 686f 640a 2020 @classmethod. \n+0005f970: 2020 6465 6620 7370 6177 6e28 0a20 2020 def spawn(. \n+0005f980: 2020 2020 2063 6c73 3a20 2774 7970 655b cls: 'type[\n+0005f990: 7479 7069 6e67 2e53 656c 665d 272c 0a20 typing.Self]',. \n+0005f9a0: 2020 2020 2020 2070 726f 746f 636f 6c5f protocol_\n+0005f9b0: 6661 6374 6f72 793a 2043 616c 6c61 626c factory: Callabl\n+0005f9c0: 655b 5b5d 2c20 505d 2c0a 2020 2020 2020 e[[], P],. \n+0005f9d0: 2020 6172 6773 3a20 5365 7175 656e 6365 args: Sequence\n+0005f9e0: 5b73 7472 5d2c 0a20 2020 2020 2020 206c [str],. l\n+0005f9f0: 6f6f 703a 2027 6173 796e 6369 6f2e 4162 oop: 'asyncio.Ab\n+0005fa00: 7374 7261 6374 4576 656e 744c 6f6f 7020 stractEventLoop \n+0005fa10: 7c20 4e6f 6e65 2720 3d20 4e6f 6e65 2c0a | None' = None,.\n+0005fa20: 2020 2020 2020 2020 696e 7465 7261 6374 interact\n+0005fa30: 696f 6e5f 6861 6e64 6c65 7273 3a20 5365 ion_handlers: Se\n+0005fa40: 7175 656e 6365 5b49 6e74 6572 6163 7469 quence[Interacti\n+0005fa50: 6f6e 4861 6e64 6c65 725d 203d 2028 292c onHandler] = (),\n+0005fa60: 0a20 2020 2020 2020 2069 735f 7373 683a . is_ssh:\n+0005fa70: 2062 6f6f 6c20 3d20 5472 7565 2c0a 2020 bool = True,. \n+0005fa80: 2020 2020 2020 2a2a 6b77 6172 6773 3a20 **kwargs: \n+0005fa90: 416e 790a 2020 2020 2920 2d3e 2027 7475 Any. ) -> 'tu\n+0005faa0: 706c 655b 7479 7069 6e67 2e53 656c 662c ple[typing.Self,\n+0005fab0: 2050 5d27 3a0a 2020 2020 2020 2020 2222 P]':. \"\"\n+0005fac0: 2243 6f6e 6e65 6374 7320 6120 4665 726e \"Connects a Fern\n+0005fad0: 7954 7261 6e73 706f 7274 2074 6f20 6120 yTransport to a \n+0005fae0: 7072 6f74 6f63 6f6c 2c20 7573 696e 6720 protocol, using \n+0005faf0: 7468 6520 6769 7665 6e20 636f 6d6d 616e the given comman\n+0005fb00: 642e 0a0a 2020 2020 2020 2020 5468 6973 d... This\n+0005fb10: 2073 7061 776e 7320 616e 2065 7874 6572 spawns an exter\n+0005fb20: 6e61 6c20 636f 6d6d 616e 6420 616e 6420 nal command and \n+0005fb30: 636f 6e6e 6563 7473 2074 6865 2073 7464 connects the std\n+0005fb40: 696e 2061 6e64 2073 7464 6f75 7420 6f66 in and stdout of\n+0005fb50: 0a20 2020 2020 2020 2074 6865 2063 6f6d . the com\n+0005fb60: 6d61 6e64 2074 6f20 7468 6520 7072 6f74 mand to the prot\n+0005fb70: 6f63 6f6c 2072 6574 7572 6e65 6420 6279 ocol returned by\n+0005fb80: 2074 6865 2066 6163 746f 7279 2e0a 0a20 the factory... \n+0005fb90: 2020 2020 2020 2041 6e20 696e 7374 616e An instan\n+0005fba0: 6365 206f 6620 6665 726e 792e 496e 7465 ce of ferny.Inte\n+0005fbb0: 7261 6374 696f 6e41 6765 6e74 2069 7320 ractionAgent is \n+0005fbc0: 6372 6561 7465 6420 616e 6420 6174 7461 created and atta\n+0005fbd0: 6368 6564 2074 6f20 7468 650a 2020 2020 ched to the. \n+0005fbe0: 2020 2020 7374 6465 7272 206f 6620 7468 stderr of th\n+0005fbf0: 6520 7370 6177 6e65 6420 7072 6f63 6573 e spawned proces\n+0005fc00: 732c 2075 7369 6e67 2074 6865 2070 726f s, using the pro\n+0005fc10: 7669 6465 6420 6861 6e64 6c65 7273 2e20 vided handlers. \n+0005fc20: 2049 7420 6973 2074 6865 0a20 2020 2020 It is the. \n+0005fc30: 2020 2072 6573 706f 6e73 6962 696c 6974 responsibilit\n+0005fc40: 7920 6f66 2074 6865 2063 616c 6c65 7220 y of the caller \n+0005fc50: 746f 2065 6e73 7572 6520 7468 6174 3a0a to ensure that:.\n+0005fc60: 2020 2020 2020 2020 2020 2d20 6120 6066 - a `f\n+0005fc70: 6572 6e79 2d61 736b 7061 7373 6020 636c erny-askpass` cl\n+0005fc80: 6965 6e74 2070 726f 6772 616d 2069 7320 ient program is \n+0005fc90: 696e 7374 616c 6c65 6420 736f 6d65 7768 installed somewh\n+0005fca0: 6572 653b 2061 6e64 0a20 2020 2020 2020 ere; and. \n+0005fcb0: 2020 202d 2061 6e79 2072 656c 6576 616e - any relevan\n+0005fcc0: 7420 636f 6d6d 616e 642d 6c69 6e65 2061 t command-line a\n+0005fcd0: 7267 756d 656e 7473 206f 7220 656e 7669 rguments or envi\n+0005fce0: 726f 6e6d 656e 7420 7661 7269 6162 6c65 ronment variable\n+0005fcf0: 7320 6172 650a 2020 2020 2020 2020 2020 s are. \n+0005fd00: 2020 7061 7373 6564 2063 6f72 7265 6374 passed correct\n+0005fd10: 6c79 2074 6f20 7468 6520 7072 6f67 7261 ly to the progra\n+0005fd20: 6d20 746f 2062 6520 7370 6177 6e65 640a m to be spawned.\n+0005fd30: 0a20 2020 2020 2020 2054 6869 7320 6675 . This fu\n+0005fd40: 6e63 7469 6f6e 2072 6574 7572 6e73 2069 nction returns i\n+0005fd50: 6d6d 6564 6961 7465 6c79 2061 6e64 206e mmediately and n\n+0005fd60: 6576 6572 2072 6169 7365 7320 6578 6365 ever raises exce\n+0005fd70: 7074 696f 6e73 2c20 6173 7375 6d69 6e67 ptions, assuming\n+0005fd80: 0a20 2020 2020 2020 2061 6c6c 2070 7265 . all pre\n+0005fd90: 636f 6e64 6974 696f 6e73 2061 7265 206d conditions are m\n+0005fda0: 6574 2e0a 0a20 2020 2020 2020 2049 6620 et... If \n+0005fdb0: 7370 6177 6e69 6e67 2074 6865 2070 726f spawning the pro\n+0005fdc0: 6365 7373 2066 6169 6c73 2074 6865 6e20 cess fails then \n+0005fdd0: 636f 6e6e 6563 7469 6f6e 5f6c 6f73 7428 connection_lost(\n+0005fde0: 2920 7769 6c6c 2062 650a 2020 2020 2020 ) will be. \n+0005fdf0: 2020 6361 6c6c 6564 2077 6974 6820 7468 called with th\n+0005fe00: 6520 7265 6c65 7661 6e74 204f 5345 7272 e relevant OSErr\n+0005fe10: 6f72 2c20 6576 656e 2062 6566 6f72 6520 or, even before \n+0005fe20: 636f 6e6e 6563 7469 6f6e 5f6d 6164 6528 connection_made(\n+0005fe30: 2920 6973 0a20 2020 2020 2020 2063 616c ) is. cal\n+0005fe40: 6c65 642e 2020 5468 6973 2069 7320 736f led. This is so\n+0005fe50: 6d65 7768 6174 206e 6f6e 2d73 7461 6e64 mewhat non-stand\n+0005fe60: 6172 6420 6265 6861 7669 6f75 722c 2062 ard behaviour, b\n+0005fe70: 7574 2069 7320 7468 6520 6561 7369 6573 ut is the easies\n+0005fe80: 740a 2020 2020 2020 2020 7761 7920 746f t. way to\n+0005fe90: 2072 6570 6f72 7420 7468 6573 6520 6572 report these er\n+0005fea0: 726f 7273 2077 6974 686f 7574 206d 616b rors without mak\n+0005feb0: 696e 6720 7468 6973 2066 756e 6374 696f ing this functio\n+0005fec0: 6e20 6173 796e 632e 0a0a 2020 2020 2020 n async... \n+0005fed0: 2020 4f6e 6365 2074 6865 2070 726f 6365 Once the proce\n+0005fee0: 7373 2069 7320 7375 6363 6573 7366 756c ss is successful\n+0005fef0: 6c79 2065 7865 6375 7465 642c 2063 6f6e ly executed, con\n+0005ff00: 6e65 6374 696f 6e5f 6d61 6465 2829 2077 nection_made() w\n+0005ff10: 696c 6c20 6265 0a20 2020 2020 2020 2063 ill be. c\n+0005ff20: 616c 6c65 6420 616e 6420 7468 6520 7472 alled and the tr\n+0005ff30: 616e 7370 6f72 7420 6361 6e20 6265 2075 ansport can be u\n+0005ff40: 7365 6420 6173 206e 6f72 6d61 6c2e 2020 sed as normal. \n+0005ff50: 636f 6e6e 6563 7469 6f6e 5f6c 6f73 7428 connection_lost(\n+0005ff60: 2920 7769 6c6c 0a20 2020 2020 2020 2062 ) will. b\n+0005ff70: 6520 6361 6c6c 6564 2069 6620 7468 6520 e called if the \n+0005ff80: 7072 6f63 6573 7320 6578 6974 7320 6f72 process exits or\n+0005ff90: 2061 6e6f 7468 6572 2065 7272 6f72 206f another error o\n+0005ffa0: 6363 7572 732e 0a0a 2020 2020 2020 2020 ccurs... \n+0005ffb0: 5468 6520 7265 7475 726e 2076 616c 7565 The return value\n+0005ffc0: 206f 6620 7468 6973 2066 756e 6374 696f of this functio\n+0005ffd0: 6e20 6973 2074 6865 2074 7261 6e73 706f n is the transpo\n+0005ffe0: 7274 2c20 6275 7420 6974 2065 7869 7374 rt, but it exist\n+0005fff0: 7320 696e 2061 0a20 2020 2020 2020 2073 s in a. s\n+00060000: 656d 692d 696e 6974 6961 6c69 7a65 6420 emi-initialized \n+00060010: 7374 6174 652e 2020 596f 7520 6361 6e20 state. You can \n+00060020: 6361 6c6c 202e 636c 6f73 6528 2920 6f6e call .close() on\n+00060030: 2069 742c 2062 7574 206e 6f74 6869 6e67 it, but nothing\n+00060040: 2065 6c73 652e 0a20 2020 2020 2020 204f else.. O\n+00060050: 6e63 6520 2e63 6f6e 6e65 6374 696f 6e5f nce .connection_\n+00060060: 6d61 6465 2829 2069 7320 6361 6c6c 6564 made() is called\n+00060070: 2c20 796f 7520 6361 6e20 6361 6c6c 2061 , you can call a\n+00060080: 6c6c 2074 6865 206f 7468 6572 0a20 2020 ll the other. \n+00060090: 2020 2020 2066 756e 6374 696f 6e73 2e0a functions..\n+000600a0: 0a20 2020 2020 2020 2041 6674 6572 2079 . After y\n+000600b0: 6f75 2063 616c 6c20 7468 6973 2066 756e ou call this fun\n+000600c0: 6374 696f 6e2c 2060 2e63 6f6e 6e65 6374 ction, `.connect\n+000600d0: 696f 6e5f 6c6f 7374 2829 6020 7769 6c6c ion_lost()` will\n+000600e0: 2062 6520 6361 6c6c 6564 206f 6e0a 2020 be called on. \n+000600f0: 2020 2020 2020 796f 7572 2050 726f 746f your Proto\n+00060100: 636f 6c2c 2065 7861 6374 6c79 206f 6e63 col, exactly onc\n+00060110: 652c 206e 6f20 6d61 7474 6572 2077 6861 e, no matter wha\n+00060120: 742e 2020 556e 7469 6c20 7468 6174 2068 t. Until that h\n+00060130: 6170 7065 6e73 2c20 796f 750a 2020 2020 appens, you. \n+00060140: 2020 2020 6172 6520 7265 7370 6f6e 7369 are responsi\n+00060150: 626c 6520 666f 7220 686f 6c64 696e 6720 ble for holding \n+00060160: 6120 7265 6665 7265 6e63 6520 746f 2074 a reference to t\n+00060170: 6865 2072 6574 7572 6e65 6420 7472 616e he returned tran\n+00060180: 7370 6f72 742e 0a0a 2020 2020 2020 2020 sport... \n+00060190: 3a70 6172 616d 2061 7267 733a 2074 6865 :param args: the\n+000601a0: 2066 756c 6c20 6172 6776 206f 6620 7468 full argv of th\n+000601b0: 6520 636f 6d6d 616e 6420 746f 2073 7061 e command to spa\n+000601c0: 776e 0a20 2020 2020 2020 203a 7061 7261 wn. :para\n+000601d0: 6d20 6c6f 6f70 3a20 7468 6520 6576 656e m loop: the even\n+000601e0: 7420 6c6f 6f70 2074 6f20 7573 652e 2020 t loop to use. \n+000601f0: 4966 206e 6f6e 6520 6973 2070 726f 7669 If none is provi\n+00060200: 6465 642c 2077 6520 7573 6520 7468 650a ded, we use the.\n+00060210: 2020 2020 2020 2020 2020 2020 6f6e 6520 one \n+00060220: 7768 6963 6820 6973 2028 7265 6164 3a20 which is (read: \n+00060230: 6d75 7374 2062 6529 2063 7572 7265 6e74 must be) current\n+00060240: 6c79 2072 756e 6e69 6e67 2e0a 2020 2020 ly running.. \n+00060250: 2020 2020 3a70 6172 616d 2069 6e74 6572 :param inter\n+00060260: 6163 7469 6f6e 5f68 616e 646c 6572 733a action_handlers:\n+00060270: 2074 6865 2068 616e 646c 6572 7320 7061 the handlers pa\n+00060280: 7373 6564 2074 6f20 7468 650a 2020 2020 ssed to the. \n+00060290: 2020 2020 2020 2020 496e 7465 7261 6374 Interact\n+000602a0: 696f 6e41 6765 6e74 0a20 2020 2020 2020 ionAgent. \n+000602b0: 203a 7061 7261 6d20 6973 5f73 7368 3a20 :param is_ssh: \n+000602c0: 7768 6574 6865 7220 7765 2073 686f 756c whether we shoul\n+000602d0: 6420 6174 7465 6d70 7420 746f 2069 6e74 d attempt to int\n+000602e0: 6572 7072 6574 2073 7464 6572 7220 6173 erpret stderr as\n+000602f0: 2073 7368 0a20 2020 2020 2020 2020 2020 ssh. \n+00060300: 2065 7272 6f72 206d 6573 7361 6765 730a error messages.\n+00060310: 2020 2020 2020 2020 3a70 6172 616d 206b :param k\n+00060320: 7761 7267 733a 2061 6e79 7468 696e 6720 wargs: anything \n+00060330: 656c 7365 2069 7320 7061 7373 6564 2074 else is passed t\n+00060340: 6872 6f75 6768 2074 6f20 6073 7562 7072 hrough to `subpr\n+00060350: 6f63 6573 735f 6578 6563 2829 600a 2020 ocess_exec()`. \n+00060360: 2020 2020 2020 3a72 6574 7572 6e73 3a20 :returns: \n+00060370: 7468 6520 7573 7561 6c20 6028 5472 616e the usual `(Tran\n+00060380: 7370 6f72 742c 2050 726f 746f 636f 6c29 sport, Protocol)\n+00060390: 6020 7061 6972 0a20 2020 2020 2020 2022 ` pair. \"\n+000603a0: 2222 0a20 2020 2020 2020 206c 6f67 6765 \"\". logge\n+000603b0: 722e 6465 6275 6728 2773 7061 776e 2825 r.debug('spawn(%\n+000603c0: 722c 2025 722c 2025 7229 272c 2063 6c73 r, %r, %r)', cls\n+000603d0: 2c20 7072 6f74 6f63 6f6c 5f66 6163 746f , protocol_facto\n+000603e0: 7279 2c20 6172 6773 290a 0a20 2020 2020 ry, args).. \n+000603f0: 2020 2070 726f 746f 636f 6c20 3d20 7072 protocol = pr\n+00060400: 6f74 6f63 6f6c 5f66 6163 746f 7279 2829 otocol_factory()\n+00060410: 0a20 2020 2020 2020 2073 656c 6620 3d20 . self = \n+00060420: 636c 7328 7072 6f74 6f63 6f6c 290a 2020 cls(protocol). \n+00060430: 2020 2020 2020 7365 6c66 2e5f 6973 5f73 self._is_s\n+00060440: 7368 203d 2069 735f 7373 680a 0a20 2020 sh = is_ssh.. \n+00060450: 2020 2020 2069 6620 6c6f 6f70 2069 7320 if loop is \n+00060460: 4e6f 6e65 3a0a 2020 2020 2020 2020 2020 None:. \n+00060470: 2020 6c6f 6f70 203d 2067 6574 5f72 756e loop = get_run\n+00060480: 6e69 6e67 5f6c 6f6f 7028 290a 0a20 2020 ning_loop().. \n+00060490: 2020 2020 2073 656c 662e 5f61 6765 6e74 self._agent\n+000604a0: 203d 2049 6e74 6572 6163 7469 6f6e 4167 = InteractionAg\n+000604b0: 656e 7428 696e 7465 7261 6374 696f 6e5f ent(interaction_\n+000604c0: 6861 6e64 6c65 7273 2c20 6c6f 6f70 2c20 handlers, loop, \n+000604d0: 7365 6c66 2e5f 696e 7465 7261 6374 696f self._interactio\n+000604e0: 6e5f 636f 6d70 6c65 7465 6429 0a20 2020 n_completed). \n+000604f0: 2020 2020 206b 7761 7267 732e 7365 7464 kwargs.setd\n+00060500: 6566 6175 6c74 2827 7374 6465 7272 272c efault('stderr',\n+00060510: 2073 656c 662e 5f61 6765 6e74 2e66 696c self._agent.fil\n+00060520: 656e 6f28 2929 0a0a 2020 2020 2020 2020 eno()).. \n+00060530: 2320 4173 206f 6620 5079 7468 6f6e 2033 # As of Python 3\n+00060540: 2e31 3220 7468 6973 2069 736e 2774 2072 .12 this isn't r\n+00060550: 6561 6c6c 7920 6173 796e 6368 726f 6e6f eally asynchrono\n+00060560: 7573 2028 7369 6e63 6520 6974 2075 7365 us (since it use\n+00060570: 7320 7468 650a 2020 2020 2020 2020 2320 s the. # \n+00060580: 7375 6270 726f 6365 7373 206d 6f64 756c subprocess modul\n+00060590: 652c 2077 6869 6368 2062 6c6f 636b 7320 e, which blocks \n+000605a0: 7768 696c 6520 7761 6974 696e 6720 666f while waiting fo\n+000605b0: 7220 7468 6520 6578 6563 2829 2074 6f0a r the exec() to.\n+000605c0: 2020 2020 2020 2020 2320 636f 6d70 6c65 # comple\n+000605d0: 7465 2069 6e20 7468 6520 6368 696c 6429 te in the child)\n+000605e0: 2c20 6275 7420 7765 2068 6176 6520 746f , but we have to\n+000605f0: 2064 6561 6c20 7769 7468 2074 6865 2063 deal with the c\n+00060600: 6f6d 706c 6963 6174 696f 6e20 6f66 0a20 omplication of. \n+00060610: 2020 2020 2020 2023 2074 6865 2061 7379 # the asy\n+00060620: 6e63 2069 6e74 6572 6661 6365 2061 6e79 nc interface any\n+00060630: 7761 792e 2020 5369 6e63 6520 7765 2c20 way. Since we, \n+00060640: 6f75 7273 656c 7665 732c 2077 616e 7420 ourselves, want \n+00060650: 746f 2065 7870 6f72 7420 610a 2020 2020 to export a. \n+00060660: 2020 2020 2320 6e6f 6e2d 6173 796e 6320 # non-async \n+00060670: 696e 7465 7266 6163 652c 2074 6861 7420 interface, that \n+00060680: 6d65 616e 7320 7468 6174 2077 6520 6e65 means that we ne\n+00060690: 6564 2061 2074 6173 6b20 6865 7265 2061 ed a task here a\n+000606a0: 6e64 2061 0a20 2020 2020 2020 2023 2062 nd a. # b\n+000606b0: 6f74 746f 6d2d 6861 6c66 2068 616e 646c ottom-half handl\n+000606c0: 6572 2062 656c 6f77 2e0a 2020 2020 2020 er below.. \n+000606d0: 2020 7365 6c66 2e5f 6578 6563 5f74 6173 self._exec_tas\n+000606e0: 6b20 3d20 6c6f 6f70 2e63 7265 6174 655f k = loop.create_\n+000606f0: 7461 736b 286c 6f6f 702e 7375 6270 726f task(loop.subpro\n+00060700: 6365 7373 5f65 7865 6328 6c61 6d62 6461 cess_exec(lambda\n+00060710: 3a20 7365 6c66 2c20 2a61 7267 732c 202a : self, *args, *\n+00060720: 2a6b 7761 7267 7329 290a 0a20 2020 2020 *kwargs)).. \n+00060730: 2020 2064 6566 2065 7865 635f 636f 6d70 def exec_comp\n+00060740: 6c65 7465 6428 7461 736b 3a20 6173 796e leted(task: asyn\n+00060750: 6369 6f2e 5461 736b 2920 2d3e 204e 6f6e cio.Task) -> Non\n+00060760: 653a 0a20 2020 2020 2020 2020 2020 206c e:. l\n+00060770: 6f67 6765 722e 6465 6275 6728 2765 7865 ogger.debug('exe\n+00060780: 635f 636f 6d70 6c65 7465 6428 2572 2c20 c_completed(%r, \n+00060790: 2572 2927 2c20 7365 6c66 2c20 7461 736b %r)', self, task\n+000607a0: 290a 2020 2020 2020 2020 2020 2020 6173 ). as\n+000607b0: 7365 7274 2074 6173 6b20 6973 2073 656c sert task is sel\n+000607c0: 662e 5f65 7865 635f 7461 736b 0a20 2020 f._exec_task. \n+000607d0: 2020 2020 2020 2020 2074 7279 3a0a 2020 try:. \n+000607e0: 2020 2020 2020 2020 2020 2020 2020 7472 tr\n+000607f0: 616e 7370 6f72 742c 206d 6520 3d20 7461 ansport, me = ta\n+00060800: 736b 2e72 6573 756c 7428 290a 2020 2020 sk.result(). \n+00060810: 2020 2020 2020 2020 2020 2020 6173 7365 asse\n+00060820: 7274 206d 6520 6973 2073 656c 660a 2020 rt me is self. \n+00060830: 2020 2020 2020 2020 2020 2020 2020 6c6f lo\n+00060840: 6767 6572 2e64 6562 7567 2827 2020 7375 gger.debug(' su\n+00060850: 6363 6573 732e 2729 0a20 2020 2020 2020 ccess.'). \n+00060860: 2020 2020 2065 7863 6570 7420 6173 796e except asyn\n+00060870: 6369 6f2e 4361 6e63 656c 6c65 6445 7272 cio.CancelledErr\n+00060880: 6f72 3a0a 2020 2020 2020 2020 2020 2020 or:. \n+00060890: 2020 2020 7265 7475 726e 2020 2320 696e return # in\n+000608a0: 2074 6861 7420 6361 7365 2c20 646f 206e that case, do n\n+000608b0: 6f74 6869 6e67 0a20 2020 2020 2020 2020 othing. \n+000608c0: 2020 2065 7863 6570 7420 4f53 4572 726f except OSErro\n+000608d0: 7220 6173 2065 7863 3a0a 2020 2020 2020 r as exc:. \n+000608e0: 2020 2020 2020 2020 2020 6c6f 6767 6572 logger\n+000608f0: 2e64 6562 7567 2827 2020 4f53 4572 726f .debug(' OSErro\n+00060900: 7220 2572 272c 2065 7863 290a 2020 2020 r %r', exc). \n+00060910: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n+00060920: 2e63 6c6f 7365 2865 7863 290a 2020 2020 .close(exc). \n+00060930: 2020 2020 2020 2020 2020 2020 7265 7475 retu\n+00060940: 726e 0a0a 2020 2020 2020 2020 2020 2020 rn.. \n+00060950: 2320 4f75 7220 6f77 6e20 2e63 6f6e 6e65 # Our own .conne\n+00060960: 6374 696f 6e5f 6d61 6465 2829 2068 616e ction_made() han\n+00060970: 646c 6572 2073 686f 756c 6420 6861 7665 dler should have\n+00060980: 2067 6f74 7465 6e20 6361 6c6c 6564 2062 gotten called b\n+00060990: 790a 2020 2020 2020 2020 2020 2020 2320 y. # \n+000609a0: 6e6f 772e 2020 4d61 6b65 2073 7572 6520 now. Make sure \n+000609b0: 6576 6572 7974 6869 6e67 2067 6f74 2066 everything got f\n+000609c0: 696c 6c65 6420 696e 2070 726f 7065 726c illed in properl\n+000609d0: 792e 0a20 2020 2020 2020 2020 2020 2061 y.. a\n+000609e0: 7373 6572 7420 7365 6c66 2e5f 7375 6270 ssert self._subp\n+000609f0: 726f 6365 7373 5f74 7261 6e73 706f 7274 rocess_transport\n+00060a00: 2069 7320 7472 616e 7370 6f72 740a 2020 is transport. \n+00060a10: 2020 2020 2020 2020 2020 6173 7365 7274 assert\n+00060a20: 2073 656c 662e 5f73 7464 696e 5f74 7261 self._stdin_tra\n+00060a30: 6e73 706f 7274 2069 7320 6e6f 7420 4e6f nsport is not No\n+00060a40: 6e65 0a20 2020 2020 2020 2020 2020 2061 ne. a\n+00060a50: 7373 6572 7420 7365 6c66 2e5f 7374 646f ssert self._stdo\n+00060a60: 7574 5f74 7261 6e73 706f 7274 2069 7320 ut_transport is \n+00060a70: 6e6f 7420 4e6f 6e65 0a0a 2020 2020 2020 not None.. \n+00060a80: 2020 2020 2020 2320 4173 6b20 7468 6520 # Ask the \n+00060a90: 496e 7465 7261 6374 696f 6e41 6765 6e74 InteractionAgent\n+00060aa0: 2074 6f20 7374 6172 7420 7072 6f63 6573 to start proces\n+00060ab0: 7369 6e67 2073 7464 6572 722e 0a20 2020 sing stderr.. \n+00060ac0: 2020 2020 2020 2020 2073 656c 662e 5f61 self._a\n+00060ad0: 6765 6e74 2e73 7461 7274 2829 0a0a 2020 gent.start().. \n+00060ae0: 2020 2020 2020 7365 6c66 2e5f 6578 6563 self._exec\n+00060af0: 5f74 6173 6b2e 6164 645f 646f 6e65 5f63 _task.add_done_c\n+00060b00: 616c 6c62 6163 6b28 6578 6563 5f63 6f6d allback(exec_com\n+00060b10: 706c 6574 6564 290a 0a20 2020 2020 2020 pleted).. \n+00060b20: 2072 6574 7572 6e20 7365 6c66 2c20 7072 return self, pr\n+00060b30: 6f74 6f63 6f6c 0a0a 2020 2020 6465 6620 otocol.. def \n+00060b40: 5f5f 696e 6974 5f5f 2873 656c 662c 2070 __init__(self, p\n+00060b50: 726f 746f 636f 6c3a 2061 7379 6e63 696f rotocol: asyncio\n+00060b60: 2e50 726f 746f 636f 6c29 202d 3e20 4e6f .Protocol) -> No\n+00060b70: 6e65 3a0a 2020 2020 2020 2020 7365 6c66 ne:. self\n+00060b80: 2e5f 7072 6f74 6f63 6f6c 203d 2070 726f ._protocol = pro\n+00060b90: 746f 636f 6c0a 0a20 2020 2064 6566 205f tocol.. def _\n+00060ba0: 636f 6e73 6964 6572 5f64 6973 636f 6e6e consider_disconn\n+00060bb0: 6563 7428 7365 6c66 2920 2d3e 204e 6f6e ect(self) -> Non\n+00060bc0: 653a 0a20 2020 2020 2020 206c 6f67 6765 e:. logge\n+00060bd0: 722e 6465 6275 6728 275f 636f 6e73 6964 r.debug('_consid\n+00060be0: 6572 5f64 6973 636f 6e6e 6563 7428 2572 er_disconnect(%r\n+00060bf0: 2927 2c20 7365 6c66 290a 2020 2020 2020 )', self). \n+00060c00: 2020 2320 5765 2063 616e 6e6f 7420 6469 # We cannot di\n+00060c10: 7363 6f6e 6e65 6374 2061 7320 6c6f 6e67 sconnect as long\n+00060c20: 2061 7320 616e 7920 6f66 2074 6865 7365 as any of these\n+00060c30: 2074 6872 6565 2074 6869 6e67 7320 6172 three things ar\n+00060c40: 6520 6861 7070 656e 696e 670a 2020 2020 e happening. \n+00060c50: 2020 2020 6966 206e 6f74 2073 656c 662e if not self.\n+00060c60: 5f65 7865 635f 7461 736b 2e64 6f6e 6528 _exec_task.done(\n+00060c70: 293a 0a20 2020 2020 2020 2020 2020 206c ):. l\n+00060c80: 6f67 6765 722e 6465 6275 6728 2720 2065 ogger.debug(' e\n+00060c90: 7865 635f 7461 736b 2073 7469 6c6c 2072 xec_task still r\n+00060ca0: 756e 6e69 6e67 2025 7227 2c20 7365 6c66 unning %r', self\n+00060cb0: 2e5f 6578 6563 5f74 6173 6b29 0a20 2020 ._exec_task). \n+00060cc0: 2020 2020 2020 2020 2072 6574 7572 6e0a return.\n+00060cd0: 0a20 2020 2020 2020 2069 6620 7365 6c66 . if self\n+00060ce0: 2e5f 7375 6270 726f 6365 7373 5f74 7261 ._subprocess_tra\n+00060cf0: 6e73 706f 7274 2069 7320 6e6f 7420 4e6f nsport is not No\n+00060d00: 6e65 2061 6e64 206e 6f74 2073 656c 662e ne and not self.\n+00060d10: 5f74 7261 6e73 706f 7274 5f64 6973 636f _transport_disco\n+00060d20: 6e6e 6563 7465 643a 0a20 2020 2020 2020 nnected:. \n+00060d30: 2020 2020 206c 6f67 6765 722e 6465 6275 logger.debu\n+00060d40: 6728 2720 2074 7261 6e73 706f 7274 2073 g(' transport s\n+00060d50: 7469 6c6c 2063 6f6e 6e65 6374 6564 2025 till connected %\n+00060d60: 7227 2c20 7365 6c66 2e5f 7375 6270 726f r', self._subpro\n+00060d70: 6365 7373 5f74 7261 6e73 706f 7274 290a cess_transport).\n+00060d80: 2020 2020 2020 2020 2020 2020 7265 7475 retu\n+00060d90: 726e 0a0a 2020 2020 2020 2020 6966 2073 rn.. if s\n+00060da0: 656c 662e 5f73 7464 6572 725f 6f75 7470 elf._stderr_outp\n+00060db0: 7574 2069 7320 4e6f 6e65 3a0a 2020 2020 ut is None:. \n+00060dc0: 2020 2020 2020 2020 6c6f 6767 6572 2e64 logger.d\n+00060dd0: 6562 7567 2827 2020 6167 656e 7420 7374 ebug(' agent st\n+00060de0: 696c 6c20 7275 6e6e 696e 6727 290a 2020 ill running'). \n+00060df0: 2020 2020 2020 2020 2020 7265 7475 726e return\n+00060e00: 0a0a 2020 2020 2020 2020 2320 416c 6c20 .. # All \n+00060e10: 636f 6e64 6974 696f 6e73 2066 6f72 2064 conditions for d\n+00060e20: 6973 636f 6e6e 6563 7469 6f6e 2061 7265 isconnection are\n+00060e30: 2073 6174 6973 6669 6564 2e0a 2020 2020 satisfied.. \n+00060e40: 2020 2020 6966 2073 656c 662e 5f70 726f if self._pro\n+00060e50: 746f 636f 6c5f 6469 7363 6f6e 6e65 6374 tocol_disconnect\n+00060e60: 6564 3a0a 2020 2020 2020 2020 2020 2020 ed:. \n+00060e70: 6c6f 6767 6572 2e64 6562 7567 2827 2020 logger.debug(' \n+00060e80: 616c 7265 6164 7920 6469 7363 6f6e 6e65 already disconne\n+00060e90: 6374 6564 2729 0a20 2020 2020 2020 2020 cted'). \n+00060ea0: 2020 2072 6574 7572 6e0a 2020 2020 2020 return. \n+00060eb0: 2020 7365 6c66 2e5f 7072 6f74 6f63 6f6c self._protocol\n+00060ec0: 5f64 6973 636f 6e6e 6563 7465 6420 3d20 _disconnected = \n+00060ed0: 5472 7565 0a0a 2020 2020 2020 2020 2320 True.. # \n+00060ee0: 4e6f 7720 7765 206a 7573 7420 6e65 6564 Now we just need\n+00060ef0: 2074 6f20 6465 7465 726d 696e 6520 7768 to determine wh\n+00060f00: 6174 2077 6520 7265 706f 7274 2074 6f20 at we report to \n+00060f10: 7468 6520 7072 6f74 6f63 6f6c 2e2e 2e0a the protocol....\n+00060f20: 2020 2020 2020 2020 6966 2073 656c 662e if self.\n+00060f30: 5f65 7863 6570 7469 6f6e 2069 7320 6e6f _exception is no\n+00060f40: 7420 4e6f 6e65 3a0a 2020 2020 2020 2020 t None:. \n+00060f50: 2020 2020 2320 4966 2077 6520 676f 7420 # If we got \n+00060f60: 616e 2065 7863 6570 7469 6f6e 2072 6570 an exception rep\n+00060f70: 6f72 7465 642c 2074 6861 7427 7320 6f75 orted, that's ou\n+00060f80: 7220 7265 6173 6f6e 2066 6f72 2063 6c6f r reason for clo\n+00060f90: 7369 6e67 2e0a 2020 2020 2020 2020 2020 sing.. \n+00060fa0: 2020 6c6f 6767 6572 2e64 6562 7567 2827 logger.debug('\n+00060fb0: 2020 6469 7363 6f6e 6e65 6374 2077 6974 disconnect wit\n+00060fc0: 6820 6578 6365 7074 696f 6e20 2572 272c h exception %r',\n+00060fd0: 2073 656c 662e 5f65 7863 6570 7469 6f6e self._exception\n+00060fe0: 290a 2020 2020 2020 2020 2020 2020 7365 ). se\n+00060ff0: 6c66 2e5f 7072 6f74 6f63 6f6c 2e63 6f6e lf._protocol.con\n+00061000: 6e65 6374 696f 6e5f 6c6f 7374 2873 656c nection_lost(sel\n+00061010: 662e 5f65 7863 6570 7469 6f6e 290a 2020 f._exception). \n+00061020: 2020 2020 2020 656c 6966 2073 656c 662e elif self.\n+00061030: 5f72 6574 7572 6e63 6f64 6520 3d3d 2030 _returncode == 0\n+00061040: 206f 7220 7365 6c66 2e5f 636c 6f73 6564 or self._closed\n+00061050: 3a0a 2020 2020 2020 2020 2020 2020 2320 :. # \n+00061060: 4966 2077 6520 6361 6c6c 6564 2063 6c6f If we called clo\n+00061070: 7365 2829 206f 7220 6861 7665 2061 207a se() or have a z\n+00061080: 6572 6f20 7265 7475 726e 2073 7461 7475 ero return statu\n+00061090: 732c 2074 6861 7427 7320 6120 636c 6561 s, that's a clea\n+000610a0: 6e0a 2020 2020 2020 2020 2020 2020 2320 n. # \n+000610b0: 6578 6974 2c20 7265 6761 7264 6c65 7373 exit, regardless\n+000610c0: 206f 6620 6e6f 6973 6520 7468 6174 206d of noise that m\n+000610d0: 6967 6874 2068 6176 6520 6c61 6e64 6564 ight have landed\n+000610e0: 2069 6e20 7374 6465 7272 2e0a 2020 2020 in stderr.. \n+000610f0: 2020 2020 2020 2020 6c6f 6767 6572 2e64 logger.d\n+00061100: 6562 7567 2827 2020 636c 6561 6e20 6469 ebug(' clean di\n+00061110: 7363 6f6e 6e65 6374 2729 0a20 2020 2020 sconnect'). \n+00061120: 2020 2020 2020 2073 656c 662e 5f70 726f self._pro\n+00061130: 746f 636f 6c2e 636f 6e6e 6563 7469 6f6e tocol.connection\n+00061140: 5f6c 6f73 7428 4e6f 6e65 290a 2020 2020 _lost(None). \n+00061150: 2020 2020 656c 6966 2073 656c 662e 5f69 elif self._i\n+00061160: 735f 7373 6820 616e 6420 7365 6c66 2e5f s_ssh and self._\n+00061170: 7265 7475 726e 636f 6465 203d 3d20 3235 returncode == 25\n+00061180: 353a 0a20 2020 2020 2020 2020 2020 2023 5:. #\n+00061190: 2054 6869 7320 6973 2061 6e20 6572 726f This is an erro\n+000611a0: 7220 636f 6465 2064 7565 2074 6f20 616e r code due to an\n+000611b0: 2053 5348 2066 6169 6c75 7265 2e20 2054 SSH failure. T\n+000611c0: 7279 2074 6f20 696e 7465 7270 7265 7420 ry to interpret \n+000611d0: 6974 2e0a 2020 2020 2020 2020 2020 2020 it.. \n+000611e0: 6c6f 6767 6572 2e64 6562 7567 2827 2020 logger.debug(' \n+000611f0: 6469 7363 6f6e 6e65 6374 2077 6974 6820 disconnect with \n+00061200: 7373 6820 6572 726f 7220 2572 272c 2073 ssh error %r', s\n+00061210: 656c 662e 5f73 7464 6572 725f 6f75 7470 elf._stderr_outp\n+00061220: 7574 290a 2020 2020 2020 2020 2020 2020 ut). \n+00061230: 7365 6c66 2e5f 7072 6f74 6f63 6f6c 2e63 self._protocol.c\n+00061240: 6f6e 6e65 6374 696f 6e5f 6c6f 7374 2867 onnection_lost(g\n+00061250: 6574 5f65 7863 6570 7469 6f6e 5f66 6f72 et_exception_for\n+00061260: 5f73 7368 5f73 7464 6572 7228 7365 6c66 _ssh_stderr(self\n+00061270: 2e5f 7374 6465 7272 5f6f 7574 7075 7429 ._stderr_output)\n+00061280: 290a 2020 2020 2020 2020 656c 7365 3a0a ). else:.\n+00061290: 2020 2020 2020 2020 2020 2020 2320 4f74 # Ot\n+000612a0: 6865 7277 6973 652c 2072 6570 6f72 7420 herwise, report \n+000612b0: 7468 6520 7374 6465 7272 2074 6578 7420 the stderr text \n+000612c0: 616e 6420 7265 7475 726e 2063 6f64 652e and return code.\n+000612d0: 0a20 2020 2020 2020 2020 2020 206c 6f67 . log\n+000612e0: 6765 722e 6465 6275 6728 2720 2064 6973 ger.debug(' dis\n+000612f0: 636f 6e6e 6563 7420 7769 7468 2065 7869 connect with exi\n+00061300: 7420 636f 6465 2025 722c 2073 7464 6572 t code %r, stder\n+00061310: 7220 2572 272c 2073 656c 662e 5f72 6574 r %r', self._ret\n+00061320: 7572 6e63 6f64 652c 2073 656c 662e 5f73 urncode, self._s\n+00061330: 7464 6572 725f 6f75 7470 7574 290a 2020 tderr_output). \n+00061340: 2020 2020 2020 2020 2020 2320 5765 2073 # We s\n+00061350: 7572 656c 7920 6861 7665 205f 7265 7475 urely have _retu\n+00061360: 726e 636f 6465 2073 6574 2068 6572 652c rncode set here,\n+00061370: 2073 696e 6365 206f 7468 6572 7769 7365 since otherwise\n+00061380: 3a0a 2020 2020 2020 2020 2020 2020 2320 :. # \n+00061390: 202d 2065 7865 635f 7461 736b 2066 6169 - exec_task fai\n+000613a0: 6c65 6420 7769 7468 2061 6e20 6578 6365 led with an exce\n+000613b0: 7074 696f 6e20 2877 6869 6368 2077 6520 ption (which we \n+000613c0: 6861 6e64 6c65 2061 626f 7665 293b 206f handle above); o\n+000613d0: 720a 2020 2020 2020 2020 2020 2020 2320 r. # \n+000613e0: 202d 2077 6527 7265 2073 7469 6c6c 2063 - we're still c\n+000613f0: 6f6e 6e65 6374 6564 2e2e 2e0a 2020 2020 onnected.... \n+00061400: 2020 2020 2020 2020 6173 7365 7274 2073 assert s\n+00061410: 656c 662e 5f72 6574 7572 6e63 6f64 6520 elf._returncode \n+00061420: 6973 206e 6f74 204e 6f6e 650a 2020 2020 is not None. \n+00061430: 2020 2020 2020 2020 7365 6c66 2e5f 7072 self._pr\n+00061440: 6f74 6f63 6f6c 2e63 6f6e 6e65 6374 696f otocol.connectio\n+00061450: 6e5f 6c6f 7374 2853 7562 7072 6f63 6573 n_lost(Subproces\n+00061460: 7345 7272 6f72 2873 656c 662e 5f72 6574 sError(self._ret\n+00061470: 7572 6e63 6f64 652c 2073 656c 662e 5f73 urncode, self._s\n+00061480: 7464 6572 725f 6f75 7470 7574 2929 0a0a tderr_output))..\n+00061490: 2020 2020 6465 6620 5f69 6e74 6572 6163 def _interac\n+000614a0: 7469 6f6e 5f63 6f6d 706c 6574 6564 2873 tion_completed(s\n+000614b0: 656c 662c 2066 7574 7572 653a 2027 6173 elf, future: 'as\n+000614c0: 796e 6369 6f2e 4675 7475 7265 5b73 7472 yncio.Future[str\n+000614d0: 5d27 2920 2d3e 204e 6f6e 653a 0a20 2020 ]') -> None:. \n+000614e0: 2020 2020 206c 6f67 6765 722e 6465 6275 logger.debu\n+000614f0: 6728 275f 696e 7465 7261 6374 696f 6e5f g('_interaction_\n+00061500: 636f 6d70 6c65 7465 6428 2572 2c20 2572 completed(%r, %r\n+00061510: 2927 2c20 7365 6c66 2c20 6675 7475 7265 )', self, future\n+00061520: 290a 2020 2020 2020 2020 7472 793a 0a20 ). try:. \n+00061530: 2020 2020 2020 2020 2020 2073 656c 662e self.\n+00061540: 5f73 7464 6572 725f 6f75 7470 7574 203d _stderr_output =\n+00061550: 2066 7574 7572 652e 7265 7375 6c74 2829 future.result()\n+00061560: 0a20 2020 2020 2020 2020 2020 206c 6f67 . log\n+00061570: 6765 722e 6465 6275 6728 2720 2073 7464 ger.debug(' std\n+00061580: 6572 723a 2025 7227 2c20 7365 6c66 2e5f err: %r', self._\n+00061590: 7374 6465 7272 5f6f 7574 7075 7429 0a20 stderr_output). \n+000615a0: 2020 2020 2020 2065 7863 6570 7420 4578 except Ex\n+000615b0: 6365 7074 696f 6e20 6173 2065 7863 3a0a ception as exc:.\n+000615c0: 2020 2020 2020 2020 2020 2020 6c6f 6767 logg\n+000615d0: 6572 2e64 6562 7567 2827 2020 6578 6365 er.debug(' exce\n+000615e0: 7074 696f 6e3a 2025 7227 2c20 6578 6329 ption: %r', exc)\n+000615f0: 0a20 2020 2020 2020 2020 2020 2073 656c . sel\n+00061600: 662e 5f73 7464 6572 725f 6f75 7470 7574 f._stderr_output\n+00061610: 203d 2027 2720 2023 2077 6520 6e65 6564 = '' # we need\n+00061620: 2074 6f20 7365 7420 7468 6973 2069 6e20 to set this in \n+00061630: 6f72 6465 7220 746f 2063 6f6d 706c 6574 order to complet\n+00061640: 650a 2020 2020 2020 2020 2020 2020 7365 e. se\n+00061650: 6c66 2e63 6c6f 7365 2865 7863 290a 0a20 lf.close(exc).. \n+00061660: 2020 2020 2020 2073 656c 662e 5f63 6f6e self._con\n+00061670: 7369 6465 725f 6469 7363 6f6e 6e65 6374 sider_disconnect\n+00061680: 2829 0a0a 2020 2020 2320 4261 7365 5072 ().. # BasePr\n+00061690: 6f74 6f63 6f6c 2069 6d70 6c65 6d65 6e74 otocol implement\n+000616a0: 6174 696f 6e0a 2020 2020 6465 6620 636f ation. def co\n+000616b0: 6e6e 6563 7469 6f6e 5f6d 6164 6528 7365 nnection_made(se\n+000616c0: 6c66 2c20 7472 616e 7370 6f72 743a 2061 lf, transport: a\n+000616d0: 7379 6e63 696f 2e42 6173 6554 7261 6e73 syncio.BaseTrans\n+000616e0: 706f 7274 2920 2d3e 204e 6f6e 653a 0a20 port) -> None:. \n+000616f0: 2020 2020 2020 206c 6f67 6765 722e 6465 logger.de\n+00061700: 6275 6728 2763 6f6e 6e65 6374 696f 6e5f bug('connection_\n+00061710: 6d61 6465 2825 722c 2025 7229 272c 2073 made(%r, %r)', s\n+00061720: 656c 662c 2074 7261 6e73 706f 7274 290a elf, transport).\n+00061730: 2020 2020 2020 2020 6173 7365 7274 2069 assert i\n+00061740: 7369 6e73 7461 6e63 6528 7472 616e 7370 sinstance(transp\n+00061750: 6f72 742c 2061 7379 6e63 696f 2e53 7562 ort, asyncio.Sub\n+00061760: 7072 6f63 6573 7354 7261 6e73 706f 7274 processTransport\n+00061770: 290a 2020 2020 2020 2020 7365 6c66 2e5f ). self._\n+00061780: 7375 6270 726f 6365 7373 5f74 7261 6e73 subprocess_trans\n+00061790: 706f 7274 203d 2074 7261 6e73 706f 7274 port = transport\n+000617a0: 0a0a 2020 2020 2020 2020 7374 6469 6e5f .. stdin_\n+000617b0: 7472 616e 7370 6f72 7420 3d20 7472 616e transport = tran\n+000617c0: 7370 6f72 742e 6765 745f 7069 7065 5f74 sport.get_pipe_t\n+000617d0: 7261 6e73 706f 7274 2830 290a 2020 2020 ransport(0). \n+000617e0: 2020 2020 6173 7365 7274 2069 7369 6e73 assert isins\n+000617f0: 7461 6e63 6528 7374 6469 6e5f 7472 616e tance(stdin_tran\n+00061800: 7370 6f72 742c 2061 7379 6e63 696f 2e57 sport, asyncio.W\n+00061810: 7269 7465 5472 616e 7370 6f72 7429 0a20 riteTransport). \n+00061820: 2020 2020 2020 2073 656c 662e 5f73 7464 self._std\n+00061830: 696e 5f74 7261 6e73 706f 7274 203d 2073 in_transport = s\n+00061840: 7464 696e 5f74 7261 6e73 706f 7274 0a0a tdin_transport..\n+00061850: 2020 2020 2020 2020 7374 646f 7574 5f74 stdout_t\n+00061860: 7261 6e73 706f 7274 203d 2074 7261 6e73 ransport = trans\n+00061870: 706f 7274 2e67 6574 5f70 6970 655f 7472 port.get_pipe_tr\n+00061880: 616e 7370 6f72 7428 3129 0a20 2020 2020 ansport(1). \n+00061890: 2020 2061 7373 6572 7420 6973 696e 7374 assert isinst\n+000618a0: 616e 6365 2873 7464 6f75 745f 7472 616e ance(stdout_tran\n+000618b0: 7370 6f72 742c 2061 7379 6e63 696f 2e52 sport, asyncio.R\n+000618c0: 6561 6454 7261 6e73 706f 7274 290a 2020 eadTransport). \n+000618d0: 2020 2020 2020 7365 6c66 2e5f 7374 646f self._stdo\n+000618e0: 7574 5f74 7261 6e73 706f 7274 203d 2073 ut_transport = s\n+000618f0: 7464 6f75 745f 7472 616e 7370 6f72 740a tdout_transport.\n+00061900: 0a20 2020 2020 2020 2073 7464 6572 725f . stderr_\n+00061910: 7472 616e 7370 6f72 7420 3d20 7472 616e transport = tran\n+00061920: 7370 6f72 742e 6765 745f 7069 7065 5f74 sport.get_pipe_t\n+00061930: 7261 6e73 706f 7274 2832 290a 2020 2020 ransport(2). \n+00061940: 2020 2020 6173 7365 7274 2073 7464 6572 assert stder\n+00061950: 725f 7472 616e 7370 6f72 7420 6973 204e r_transport is N\n+00061960: 6f6e 650a 0a20 2020 2020 2020 206c 6f67 one.. log\n+00061970: 6765 722e 6465 6275 6728 2763 616c 6c69 ger.debug('calli\n+00061980: 6e67 2063 6f6e 6e65 6374 696f 6e5f 6d61 ng connection_ma\n+00061990: 6465 2825 722c 2025 7229 272c 2073 656c de(%r, %r)', sel\n+000619a0: 662c 2073 656c 662e 5f70 726f 746f 636f f, self._protoco\n+000619b0: 6c29 0a20 2020 2020 2020 2073 656c 662e l). self.\n+000619c0: 5f70 726f 746f 636f 6c2e 636f 6e6e 6563 _protocol.connec\n+000619d0: 7469 6f6e 5f6d 6164 6528 7365 6c66 290a tion_made(self).\n+000619e0: 0a20 2020 2064 6566 2063 6f6e 6e65 6374 . def connect\n+000619f0: 696f 6e5f 6c6f 7374 2873 656c 662c 2065 ion_lost(self, e\n+00061a00: 7863 3a20 2745 7863 6570 7469 6f6e 207c xc: 'Exception |\n+00061a10: 204e 6f6e 6527 2920 2d3e 204e 6f6e 653a None') -> None:\n+00061a20: 0a20 2020 2020 2020 206c 6f67 6765 722e . logger.\n+00061a30: 6465 6275 6728 2763 6f6e 6e65 6374 696f debug('connectio\n+00061a40: 6e5f 6c6f 7374 2825 722c 2025 7229 272c n_lost(%r, %r)',\n+00061a50: 2073 656c 662c 2065 7863 290a 2020 2020 self, exc). \n+00061a60: 2020 2020 6966 2073 656c 662e 5f65 7863 if self._exc\n+00061a70: 6570 7469 6f6e 2069 7320 4e6f 6e65 3a0a eption is None:.\n+00061a80: 2020 2020 2020 2020 2020 2020 7365 6c66 self\n+00061a90: 2e5f 6578 6365 7074 696f 6e20 3d20 6578 ._exception = ex\n+00061aa0: 630a 2020 2020 2020 2020 7365 6c66 2e5f c. self._\n+00061ab0: 7472 616e 7370 6f72 745f 6469 7363 6f6e transport_discon\n+00061ac0: 6e65 6374 6564 203d 2054 7275 650a 2020 nected = True. \n+00061ad0: 2020 2020 2020 7365 6c66 2e5f 636f 6e73 self._cons\n+00061ae0: 6964 6572 5f64 6973 636f 6e6e 6563 7428 ider_disconnect(\n+00061af0: 290a 0a20 2020 2023 2053 7562 7072 6f63 ).. # Subproc\n+00061b00: 6573 7350 726f 746f 636f 6c20 696d 706c essProtocol impl\n+00061b10: 656d 656e 7461 7469 6f6e 0a20 2020 2064 ementation. d\n+00061b20: 6566 2070 6970 655f 6461 7461 5f72 6563 ef pipe_data_rec\n+00061b30: 6569 7665 6428 7365 6c66 2c20 6664 3a20 eived(self, fd: \n+00061b40: 696e 742c 2064 6174 613a 2062 7974 6573 int, data: bytes\n+00061b50: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n+00061b60: 2020 206c 6f67 6765 722e 6465 6275 6728 logger.debug(\n+00061b70: 2770 6970 655f 6461 7461 5f72 6563 6569 'pipe_data_recei\n+00061b80: 7665 6428 2572 2c20 2572 2c20 2572 2927 ved(%r, %r, %r)'\n+00061b90: 2c20 7365 6c66 2c20 6664 2c20 6c65 6e28 , self, fd, len(\n+00061ba0: 6461 7461 2929 0a20 2020 2020 2020 2061 data)). a\n+00061bb0: 7373 6572 7420 6664 203d 3d20 3120 2023 ssert fd == 1 #\n+00061bc0: 2073 7464 6572 7220 6973 2068 616e 646c stderr is handl\n+00061bd0: 6564 2073 6570 6172 6174 656c 790a 2020 ed separately. \n+00061be0: 2020 2020 2020 7365 6c66 2e5f 7072 6f74 self._prot\n+00061bf0: 6f63 6f6c 2e64 6174 615f 7265 6365 6976 ocol.data_receiv\n+00061c00: 6564 2864 6174 6129 0a0a 2020 2020 6465 ed(data).. de\n+00061c10: 6620 7069 7065 5f63 6f6e 6e65 6374 696f f pipe_connectio\n+00061c20: 6e5f 6c6f 7374 2873 656c 662c 2066 643a n_lost(self, fd:\n+00061c30: 2069 6e74 2c20 6578 633a 2027 4578 6365 int, exc: 'Exce\n+00061c40: 7074 696f 6e20 7c20 4e6f 6e65 2729 202d ption | None') -\n+00061c50: 3e20 4e6f 6e65 3a0a 2020 2020 2020 2020 > None:. \n+00061c60: 6c6f 6767 6572 2e64 6562 7567 2827 7069 logger.debug('pi\n+00061c70: 7065 5f63 6f6e 6e65 6374 696f 6e5f 6c6f pe_connection_lo\n+00061c80: 7374 2825 722c 2025 722c 2025 7229 272c st(%r, %r, %r)',\n+00061c90: 2073 656c 662c 2066 642c 2065 7863 290a self, fd, exc).\n+00061ca0: 2020 2020 2020 2020 6173 7365 7274 2066 assert f\n+00061cb0: 6420 696e 2028 302c 2031 2920 2023 2073 d in (0, 1) # s\n+00061cc0: 7464 6572 7220 6973 2068 616e 646c 6564 tderr is handled\n+00061cd0: 2073 6570 6172 6174 656c 790a 0a20 2020 separately.. \n+00061ce0: 2020 2020 2023 2057 6520 7472 6561 7420 # We treat \n+00061cf0: 7468 6973 2061 7320 6120 636c 6561 6e20 this as a clean \n+00061d00: 636c 6f73 650a 2020 2020 2020 2020 6966 close. if\n+00061d10: 2069 7369 6e73 7461 6e63 6528 6578 632c isinstance(exc,\n+00061d20: 2042 726f 6b65 6e50 6970 6545 7272 6f72 BrokenPipeError\n+00061d30: 293a 0a20 2020 2020 2020 2020 2020 2065 ):. e\n+00061d40: 7863 203d 204e 6f6e 650a 0a20 2020 2020 xc = None.. \n+00061d50: 2020 2023 2052 6563 6f72 6420 7365 7269 # Record seri\n+00061d60: 6f75 7320 6572 726f 7273 2074 6f20 7072 ous errors to pr\n+00061d70: 6f70 6167 6174 6520 7468 656d 2074 6f20 opagate them to \n+00061d80: 7468 6520 7072 6f74 6f63 6f6c 0a20 2020 the protocol. \n+00061d90: 2020 2020 2023 2049 6620 7468 6973 2069 # If this i\n+00061da0: 7320 6120 636c 6561 6e20 6578 6974 206f s a clean exit o\n+00061db0: 6e20 7374 646f 7574 2c20 7265 706f 7274 n stdout, report\n+00061dc0: 2061 6e20 454f 460a 2020 2020 2020 2020 an EOF. \n+00061dd0: 6966 2065 7863 2069 7320 6e6f 7420 4e6f if exc is not No\n+00061de0: 6e65 3a0a 2020 2020 2020 2020 2020 2020 ne:. \n+00061df0: 7365 6c66 2e63 6c6f 7365 2865 7863 290a self.close(exc).\n+00061e00: 2020 2020 2020 2020 656c 6966 2066 6420 elif fd \n+00061e10: 3d3d 2031 2061 6e64 206e 6f74 2073 656c == 1 and not sel\n+00061e20: 662e 5f63 6c6f 7365 643a 0a20 2020 2020 f._closed:. \n+00061e30: 2020 2020 2020 2069 6620 6e6f 7420 7365 if not se\n+00061e40: 6c66 2e5f 7072 6f74 6f63 6f6c 2e65 6f66 lf._protocol.eof\n+00061e50: 5f72 6563 6569 7665 6428 293a 0a20 2020 _received():. \n+00061e60: 2020 2020 2020 2020 2020 2020 2073 656c sel\n+00061e70: 662e 636c 6f73 6528 290a 0a20 2020 2064 f.close().. d\n+00061e80: 6566 2070 726f 6365 7373 5f65 7869 7465 ef process_exite\n+00061e90: 6428 7365 6c66 2920 2d3e 204e 6f6e 653a d(self) -> None:\n+00061ea0: 0a20 2020 2020 2020 206c 6f67 6765 722e . logger.\n+00061eb0: 6465 6275 6728 2770 726f 6365 7373 5f65 debug('process_e\n+00061ec0: 7869 7465 6428 2572 2927 2c20 7365 6c66 xited(%r)', self\n+00061ed0: 290a 2020 2020 2020 2020 6173 7365 7274 ). assert\n+00061ee0: 2073 656c 662e 5f73 7562 7072 6f63 6573 self._subproces\n+00061ef0: 735f 7472 616e 7370 6f72 7420 6973 206e s_transport is n\n+00061f00: 6f74 204e 6f6e 650a 2020 2020 2020 2020 ot None. \n+00061f10: 7365 6c66 2e5f 7265 7475 726e 636f 6465 self._returncode\n+00061f20: 203d 2073 656c 662e 5f73 7562 7072 6f63 = self._subproc\n+00061f30: 6573 735f 7472 616e 7370 6f72 742e 6765 ess_transport.ge\n+00061f40: 745f 7265 7475 726e 636f 6465 2829 0a20 t_returncode(). \n+00061f50: 2020 2020 2020 206c 6f67 6765 722e 6465 logger.de\n+00061f60: 6275 6728 2720 202e 5f72 6574 7572 6e63 bug(' ._returnc\n+00061f70: 6f64 6520 3d20 2572 272c 2073 656c 662e ode = %r', self.\n+00061f80: 5f72 6574 7572 6e63 6f64 6529 0a20 2020 _returncode). \n+00061f90: 2020 2020 2073 656c 662e 5f61 6765 6e74 self._agent\n+00061fa0: 2e66 6f72 6365 5f63 6f6d 706c 6574 696f .force_completio\n+00061fb0: 6e28 290a 0a20 2020 2064 6566 2070 6175 n().. def pau\n+00061fc0: 7365 5f77 7269 7469 6e67 2873 656c 6629 se_writing(self)\n+00061fd0: 202d 3e20 4e6f 6e65 3a0a 2020 2020 2020 -> None:. \n+00061fe0: 2020 6c6f 6767 6572 2e64 6562 7567 2827 logger.debug('\n+00061ff0: 7061 7573 655f 7772 6974 696e 6728 2572 pause_writing(%r\n+00062000: 2927 2c20 7365 6c66 290a 2020 2020 2020 )', self). \n+00062010: 2020 7365 6c66 2e5f 7072 6f74 6f63 6f6c self._protocol\n+00062020: 2e70 6175 7365 5f77 7269 7469 6e67 2829 .pause_writing()\n+00062030: 0a0a 2020 2020 6465 6620 7265 7375 6d65 .. def resume\n+00062040: 5f77 7269 7469 6e67 2873 656c 6629 202d _writing(self) -\n+00062050: 3e20 4e6f 6e65 3a0a 2020 2020 2020 2020 > None:. \n+00062060: 6c6f 6767 6572 2e64 6562 7567 2827 7265 logger.debug('re\n+00062070: 7375 6d65 5f77 7269 7469 6e67 2825 7229 sume_writing(%r)\n+00062080: 272c 2073 656c 6629 0a20 2020 2020 2020 ', self). \n+00062090: 2073 656c 662e 5f70 726f 746f 636f 6c2e self._protocol.\n+000620a0: 7265 7375 6d65 5f77 7269 7469 6e67 2829 resume_writing()\n+000620b0: 0a0a 2020 2020 2320 5472 616e 7370 6f72 .. # Transpor\n+000620c0: 7420 696d 706c 656d 656e 7461 7469 6f6e t implementation\n+000620d0: 2e20 204d 6f73 7420 6f66 2074 6869 7320 . Most of this \n+000620e0: 6973 2073 7472 6169 6768 7420 6465 6c65 is straight dele\n+000620f0: 6761 7469 6f6e 2e0a 2020 2020 6465 6620 gation.. def \n+00062100: 636c 6f73 6528 7365 6c66 2c20 6578 633a close(self, exc:\n+00062110: 2027 4578 6365 7074 696f 6e20 7c20 4e6f 'Exception | No\n+00062120: 6e65 2720 3d20 4e6f 6e65 2920 2d3e 204e ne' = None) -> N\n+00062130: 6f6e 653a 0a20 2020 2020 2020 206c 6f67 one:. log\n+00062140: 6765 722e 6465 6275 6728 2763 6c6f 7365 ger.debug('close\n+00062150: 2825 722c 2025 7229 272c 2073 656c 662c (%r, %r)', self,\n+00062160: 2065 7863 290a 2020 2020 2020 2020 7365 exc). se\n+00062170: 6c66 2e5f 636c 6f73 6564 203d 2054 7275 lf._closed = Tru\n+00062180: 650a 2020 2020 2020 2020 6966 2073 656c e. if sel\n+00062190: 662e 5f65 7863 6570 7469 6f6e 2069 7320 f._exception is \n+000621a0: 4e6f 6e65 3a0a 2020 2020 2020 2020 2020 None:. \n+000621b0: 2020 6c6f 6767 6572 2e64 6562 7567 2827 logger.debug('\n+000621c0: 2020 7365 7474 696e 6720 6578 6365 7074 setting except\n+000621d0: 696f 6e20 2572 272c 2065 7863 290a 2020 ion %r', exc). \n+000621e0: 2020 2020 2020 2020 2020 7365 6c66 2e5f self._\n+000621f0: 6578 6365 7074 696f 6e20 3d20 6578 630a exception = exc.\n+00062200: 2020 2020 2020 2020 6966 206e 6f74 2073 if not s\n+00062210: 656c 662e 5f65 7865 635f 7461 736b 2e64 elf._exec_task.d\n+00062220: 6f6e 6528 293a 0a20 2020 2020 2020 2020 one():. \n+00062230: 2020 206c 6f67 6765 722e 6465 6275 6728 logger.debug(\n+00062240: 2720 2063 616e 6365 6c6c 696e 6720 5f65 ' cancelling _e\n+00062250: 7865 635f 7461 736b 2729 0a20 2020 2020 xec_task'). \n+00062260: 2020 2020 2020 2073 656c 662e 5f65 7865 self._exe\n+00062270: 635f 7461 736b 2e63 616e 6365 6c28 290a c_task.cancel().\n+00062280: 2020 2020 2020 2020 6966 2073 656c 662e if self.\n+00062290: 5f73 7562 7072 6f63 6573 735f 7472 616e _subprocess_tran\n+000622a0: 7370 6f72 7420 6973 206e 6f74 204e 6f6e sport is not Non\n+000622b0: 653a 0a20 2020 2020 2020 2020 2020 206c e:. l\n+000622c0: 6f67 6765 722e 6465 6275 6728 2720 2063 ogger.debug(' c\n+000622d0: 6c6f 7369 6e67 205f 7375 6270 726f 6365 losing _subproce\n+000622e0: 7373 5f74 7261 6e73 706f 7274 2729 0a20 ss_transport'). \n+000622f0: 2020 2020 2020 2020 2020 2023 2068 7474 # htt\n+00062300: 7073 3a2f 2f67 6974 6875 622e 636f 6d2f ps://github.com/\n+00062310: 7079 7468 6f6e 2f63 7079 7468 6f6e 2f69 python/cpython/i\n+00062320: 7373 7565 732f 3131 3238 3030 0a20 2020 ssues/112800. \n+00062330: 2020 2020 2020 2020 2077 6974 6820 636f with co\n+00062340: 6e74 6578 746c 6962 2e73 7570 7072 6573 ntextlib.suppres\n+00062350: 7328 5065 726d 6973 7369 6f6e 4572 726f s(PermissionErro\n+00062360: 7229 3a0a 2020 2020 2020 2020 2020 2020 r):. \n+00062370: 2020 2020 7365 6c66 2e5f 7375 6270 726f self._subpro\n+00062380: 6365 7373 5f74 7261 6e73 706f 7274 2e63 cess_transport.c\n+00062390: 6c6f 7365 2829 0a20 2020 2020 2020 2073 lose(). s\n+000623a0: 656c 662e 5f61 6765 6e74 2e66 6f72 6365 elf._agent.force\n+000623b0: 5f63 6f6d 706c 6574 696f 6e28 290a 0a20 _completion().. \n+000623c0: 2020 2064 6566 2069 735f 636c 6f73 696e def is_closin\n+000623d0: 6728 7365 6c66 2920 2d3e 2062 6f6f 6c3a g(self) -> bool:\n+000623e0: 0a20 2020 2020 2020 2061 7373 6572 7420 . assert \n+000623f0: 7365 6c66 2e5f 7375 6270 726f 6365 7373 self._subprocess\n+00062400: 5f74 7261 6e73 706f 7274 2069 7320 6e6f _transport is no\n+00062410: 7420 4e6f 6e65 0a20 2020 2020 2020 2072 t None. r\n+00062420: 6574 7572 6e20 7365 6c66 2e5f 7375 6270 eturn self._subp\n+00062430: 726f 6365 7373 5f74 7261 6e73 706f 7274 rocess_transport\n+00062440: 2e69 735f 636c 6f73 696e 6728 290a 0a20 .is_closing().. \n+00062450: 2020 2064 6566 2067 6574 5f65 7874 7261 def get_extra\n+00062460: 5f69 6e66 6f28 7365 6c66 2c20 6e61 6d65 _info(self, name\n+00062470: 3a20 7374 722c 2064 6566 6175 6c74 3a20 : str, default: \n+00062480: 6f62 6a65 6374 203d 204e 6f6e 6529 202d object = None) -\n+00062490: 3e20 6f62 6a65 6374 3a0a 2020 2020 2020 > object:. \n+000624a0: 2020 6173 7365 7274 2073 656c 662e 5f73 assert self._s\n+000624b0: 7562 7072 6f63 6573 735f 7472 616e 7370 ubprocess_transp\n+000624c0: 6f72 7420 6973 206e 6f74 204e 6f6e 650a ort is not None.\n+000624d0: 2020 2020 2020 2020 7265 7475 726e 2073 return s\n+000624e0: 656c 662e 5f73 7562 7072 6f63 6573 735f elf._subprocess_\n+000624f0: 7472 616e 7370 6f72 742e 6765 745f 6578 transport.get_ex\n+00062500: 7472 615f 696e 666f 286e 616d 652c 2064 tra_info(name, d\n+00062510: 6566 6175 6c74 290a 0a20 2020 2064 6566 efault).. def\n+00062520: 2073 6574 5f70 726f 746f 636f 6c28 7365 set_protocol(se\n+00062530: 6c66 2c20 7072 6f74 6f63 6f6c 3a20 6173 lf, protocol: as\n+00062540: 796e 6369 6f2e 4261 7365 5072 6f74 6f63 yncio.BaseProtoc\n+00062550: 6f6c 2920 2d3e 204e 6f6e 653a 0a20 2020 ol) -> None:. \n+00062560: 2020 2020 2061 7373 6572 7420 6973 696e assert isin\n+00062570: 7374 616e 6365 2870 726f 746f 636f 6c2c stance(protocol,\n+00062580: 2061 7379 6e63 696f 2e50 726f 746f 636f asyncio.Protoco\n+00062590: 6c29 0a20 2020 2020 2020 2073 656c 662e l). self.\n+000625a0: 5f70 726f 746f 636f 6c20 3d20 7072 6f74 _protocol = prot\n+000625b0: 6f63 6f6c 0a0a 2020 2020 6465 6620 6765 ocol.. def ge\n+000625c0: 745f 7072 6f74 6f63 6f6c 2873 656c 6629 t_protocol(self)\n+000625d0: 202d 3e20 6173 796e 6369 6f2e 5072 6f74 -> asyncio.Prot\n+000625e0: 6f63 6f6c 3a0a 2020 2020 2020 2020 7265 ocol:. re\n+000625f0: 7475 726e 2073 656c 662e 5f70 726f 746f turn self._proto\n+00062600: 636f 6c0a 0a20 2020 2064 6566 2069 735f col.. def is_\n+00062610: 7265 6164 696e 6728 7365 6c66 2920 2d3e reading(self) ->\n+00062620: 2062 6f6f 6c3a 0a20 2020 2020 2020 2061 bool:. a\n+00062630: 7373 6572 7420 7365 6c66 2e5f 7374 646f ssert self._stdo\n+00062640: 7574 5f74 7261 6e73 706f 7274 2069 7320 ut_transport is \n+00062650: 6e6f 7420 4e6f 6e65 0a20 2020 2020 2020 not None. \n+00062660: 2074 7279 3a0a 2020 2020 2020 2020 2020 try:. \n+00062670: 2020 7265 7475 726e 2073 656c 662e 5f73 return self._s\n+00062680: 7464 6f75 745f 7472 616e 7370 6f72 742e tdout_transport.\n+00062690: 6973 5f72 6561 6469 6e67 2829 0a20 2020 is_reading(). \n+000626a0: 2020 2020 2065 7863 6570 7420 4e6f 7449 except NotI\n+000626b0: 6d70 6c65 6d65 6e74 6564 4572 726f 723a mplementedError:\n+000626c0: 0a20 2020 2020 2020 2020 2020 2023 2054 . # T\n+000626d0: 6869 7320 6973 2028 696e 636f 7272 6563 his is (incorrec\n+000626e0: 746c 7929 2075 6e69 6d70 6c65 6d65 6e74 tly) unimplement\n+000626f0: 6564 2062 6566 6f72 6520 5079 7468 6f6e ed before Python\n+00062700: 2033 2e31 310a 2020 2020 2020 2020 2020 3.11. \n+00062710: 2020 7265 7475 726e 206e 6f74 2073 656c return not sel\n+00062720: 662e 5f73 7464 6f75 745f 7472 616e 7370 f._stdout_transp\n+00062730: 6f72 742e 5f70 6175 7365 6420 2023 2074 ort._paused # t\n+00062740: 7970 653a 6967 6e6f 7265 5b61 7474 722d ype:ignore[attr-\n+00062750: 6465 6669 6e65 645d 0a20 2020 2020 2020 defined]. \n+00062760: 2065 7863 6570 7420 4174 7472 6962 7574 except Attribut\n+00062770: 6545 7272 6f72 3a0a 2020 2020 2020 2020 eError:. \n+00062780: 2020 2020 2320 2e2e 2e61 6e64 2069 6e20 # ...and in \n+00062790: 5079 7468 6f6e 2033 2e36 2069 7427 7320 Python 3.6 it's \n+000627a0: 6576 656e 2077 6f72 7365 0a20 2020 2020 even worse. \n+000627b0: 2020 2020 2020 2074 7279 3a0a 2020 2020 try:. \n+000627c0: 2020 2020 2020 2020 2020 2020 7365 6c65 sele\n+000627d0: 6374 6f72 203d 2073 656c 662e 5f73 7464 ctor = self._std\n+000627e0: 6f75 745f 7472 616e 7370 6f72 742e 5f6c out_transport._l\n+000627f0: 6f6f 702e 5f73 656c 6563 746f 7220 2023 oop._selector #\n+00062800: 2074 7970 653a 6967 6e6f 7265 5b61 7474 type:ignore[att\n+00062810: 722d 6465 6669 6e65 645d 0a20 2020 2020 r-defined]. \n+00062820: 2020 2020 2020 2020 2020 2073 656c 6563 selec\n+00062830: 746f 722e 6765 745f 6b65 7928 7365 6c66 tor.get_key(self\n+00062840: 2e5f 7374 646f 7574 5f74 7261 6e73 706f ._stdout_transpo\n+00062850: 7274 2e5f 6669 6c65 6e6f 2920 2023 2074 rt._fileno) # t\n+00062860: 7970 653a 6967 6e6f 7265 5b61 7474 722d ype:ignore[attr-\n+00062870: 6465 6669 6e65 645d 0a20 2020 2020 2020 defined]. \n+00062880: 2020 2020 2020 2020 2072 6574 7572 6e20 return \n+00062890: 5472 7565 0a20 2020 2020 2020 2020 2020 True. \n+000628a0: 2065 7863 6570 7420 4b65 7945 7272 6f72 except KeyError\n+000628b0: 3a0a 2020 2020 2020 2020 2020 2020 2020 :. \n+000628c0: 2020 7265 7475 726e 2046 616c 7365 0a0a return False..\n+000628d0: 2020 2020 6465 6620 7061 7573 655f 7265 def pause_re\n+000628e0: 6164 696e 6728 7365 6c66 2920 2d3e 204e ading(self) -> N\n+000628f0: 6f6e 653a 0a20 2020 2020 2020 2061 7373 one:. ass\n+00062900: 6572 7420 7365 6c66 2e5f 7374 646f 7574 ert self._stdout\n+00062910: 5f74 7261 6e73 706f 7274 2069 7320 6e6f _transport is no\n+00062920: 7420 4e6f 6e65 0a20 2020 2020 2020 2073 t None. s\n+00062930: 656c 662e 5f73 7464 6f75 745f 7472 616e elf._stdout_tran\n+00062940: 7370 6f72 742e 7061 7573 655f 7265 6164 sport.pause_read\n+00062950: 696e 6728 290a 0a20 2020 2064 6566 2072 ing().. def r\n+00062960: 6573 756d 655f 7265 6164 696e 6728 7365 esume_reading(se\n+00062970: 6c66 2920 2d3e 204e 6f6e 653a 0a20 2020 lf) -> None:. \n+00062980: 2020 2020 2061 7373 6572 7420 7365 6c66 assert self\n+00062990: 2e5f 7374 646f 7574 5f74 7261 6e73 706f ._stdout_transpo\n+000629a0: 7274 2069 7320 6e6f 7420 4e6f 6e65 0a20 rt is not None. \n+000629b0: 2020 2020 2020 2073 656c 662e 5f73 7464 self._std\n+000629c0: 6f75 745f 7472 616e 7370 6f72 742e 7265 out_transport.re\n+000629d0: 7375 6d65 5f72 6561 6469 6e67 2829 0a0a sume_reading()..\n+000629e0: 2020 2020 6465 6620 6162 6f72 7428 7365 def abort(se\n+000629f0: 6c66 2920 2d3e 204e 6f6e 653a 0a20 2020 lf) -> None:. \n+00062a00: 2020 2020 2061 7373 6572 7420 7365 6c66 assert self\n+00062a10: 2e5f 7374 6469 6e5f 7472 616e 7370 6f72 ._stdin_transpor\n+00062a20: 7420 6973 206e 6f74 204e 6f6e 650a 2020 t is not None. \n+00062a30: 2020 2020 2020 6173 7365 7274 2073 656c assert sel\n+00062a40: 662e 5f73 7562 7072 6f63 6573 735f 7472 f._subprocess_tr\n+00062a50: 616e 7370 6f72 7420 6973 206e 6f74 204e ansport is not N\n+00062a60: 6f6e 650a 2020 2020 2020 2020 7365 6c66 one. self\n+00062a70: 2e5f 7374 6469 6e5f 7472 616e 7370 6f72 ._stdin_transpor\n+00062a80: 742e 6162 6f72 7428 290a 2020 2020 2020 t.abort(). \n+00062a90: 2020 7365 6c66 2e5f 7375 6270 726f 6365 self._subproce\n+00062aa0: 7373 5f74 7261 6e73 706f 7274 2e6b 696c ss_transport.kil\n+00062ab0: 6c28 290a 0a20 2020 2064 6566 2063 616e l().. def can\n+00062ac0: 5f77 7269 7465 5f65 6f66 2873 656c 6629 _write_eof(self)\n+00062ad0: 202d 3e20 626f 6f6c 3a0a 2020 2020 2020 -> bool:. \n+00062ae0: 2020 6173 7365 7274 2073 656c 662e 5f73 assert self._s\n+00062af0: 7464 696e 5f74 7261 6e73 706f 7274 2069 tdin_transport i\n+00062b00: 7320 6e6f 7420 4e6f 6e65 0a20 2020 2020 s not None. \n+00062b10: 2020 2072 6574 7572 6e20 7365 6c66 2e5f return self._\n+00062b20: 7374 6469 6e5f 7472 616e 7370 6f72 742e stdin_transport.\n+00062b30: 6361 6e5f 7772 6974 655f 656f 6628 2920 can_write_eof() \n+00062b40: 2023 2077 696c 6c20 616c 7761 7973 2062 # will always b\n+00062b50: 6520 5472 7565 0a0a 2020 2020 6465 6620 e True.. def \n+00062b60: 6765 745f 7772 6974 655f 6275 6666 6572 get_write_buffer\n+00062b70: 5f73 697a 6528 7365 6c66 2920 2d3e 2069 _size(self) -> i\n+00062b80: 6e74 3a0a 2020 2020 2020 2020 6173 7365 nt:. asse\n+00062b90: 7274 2073 656c 662e 5f73 7464 696e 5f74 rt self._stdin_t\n+00062ba0: 7261 6e73 706f 7274 2069 7320 6e6f 7420 ransport is not \n+00062bb0: 4e6f 6e65 0a20 2020 2020 2020 2072 6574 None. ret\n+00062bc0: 7572 6e20 7365 6c66 2e5f 7374 6469 6e5f urn self._stdin_\n+00062bd0: 7472 616e 7370 6f72 742e 6765 745f 7772 transport.get_wr\n+00062be0: 6974 655f 6275 6666 6572 5f73 697a 6528 ite_buffer_size(\n+00062bf0: 290a 0a20 2020 2064 6566 2067 6574 5f77 ).. def get_w\n+00062c00: 7269 7465 5f62 7566 6665 725f 6c69 6d69 rite_buffer_limi\n+00062c10: 7473 2873 656c 6629 202d 3e20 2774 7570 ts(self) -> 'tup\n+00062c20: 6c65 5b69 6e74 2c20 696e 745d 273a 0a20 le[int, int]':. \n+00062c30: 2020 2020 2020 2061 7373 6572 7420 7365 assert se\n+00062c40: 6c66 2e5f 7374 6469 6e5f 7472 616e 7370 lf._stdin_transp\n+00062c50: 6f72 7420 6973 206e 6f74 204e 6f6e 650a ort is not None.\n+00062c60: 2020 2020 2020 2020 7265 7475 726e 2073 return s\n+00062c70: 656c 662e 5f73 7464 696e 5f74 7261 6e73 elf._stdin_trans\n+00062c80: 706f 7274 2e67 6574 5f77 7269 7465 5f62 port.get_write_b\n+00062c90: 7566 6665 725f 6c69 6d69 7473 2829 0a0a uffer_limits()..\n+00062ca0: 2020 2020 6465 6620 7365 745f 7772 6974 def set_writ\n+00062cb0: 655f 6275 6666 6572 5f6c 696d 6974 7328 e_buffer_limits(\n+00062cc0: 7365 6c66 2c20 6869 6768 3a20 2769 6e74 self, high: 'int\n+00062cd0: 207c 204e 6f6e 6527 203d 204e 6f6e 652c | None' = None,\n+00062ce0: 206c 6f77 3a20 2769 6e74 207c 204e 6f6e low: 'int | Non\n+00062cf0: 6527 203d 204e 6f6e 6529 202d 3e20 4e6f e' = None) -> No\n+00062d00: 6e65 3a0a 2020 2020 2020 2020 6173 7365 ne:. asse\n+00062d10: 7274 2073 656c 662e 5f73 7464 696e 5f74 rt self._stdin_t\n+00062d20: 7261 6e73 706f 7274 2069 7320 6e6f 7420 ransport is not \n+00062d30: 4e6f 6e65 0a20 2020 2020 2020 2072 6574 None. ret\n+00062d40: 7572 6e20 7365 6c66 2e5f 7374 6469 6e5f urn self._stdin_\n+00062d50: 7472 616e 7370 6f72 742e 7365 745f 7772 transport.set_wr\n+00062d60: 6974 655f 6275 6666 6572 5f6c 696d 6974 ite_buffer_limit\n+00062d70: 7328 6869 6768 2c20 6c6f 7729 0a0a 2020 s(high, low).. \n+00062d80: 2020 6465 6620 7772 6974 6528 7365 6c66 def write(self\n+00062d90: 2c20 6461 7461 3a20 6279 7465 7329 202d , data: bytes) -\n+00062da0: 3e20 4e6f 6e65 3a0a 2020 2020 2020 2020 > None:. \n+00062db0: 6173 7365 7274 2073 656c 662e 5f73 7464 assert self._std\n+00062dc0: 696e 5f74 7261 6e73 706f 7274 2069 7320 in_transport is \n+00062dd0: 6e6f 7420 4e6f 6e65 0a20 2020 2020 2020 not None. \n+00062de0: 2072 6574 7572 6e20 7365 6c66 2e5f 7374 return self._st\n+00062df0: 6469 6e5f 7472 616e 7370 6f72 742e 7772 din_transport.wr\n+00062e00: 6974 6528 6461 7461 290a 0a20 2020 2064 ite(data).. d\n+00062e10: 6566 2077 7269 7465 6c69 6e65 7328 7365 ef writelines(se\n+00062e20: 6c66 2c20 6c69 7374 5f6f 665f 6461 7461 lf, list_of_data\n+00062e30: 3a20 4974 6572 6162 6c65 5b62 7974 6573 : Iterable[bytes\n+00062e40: 5d29 202d 3e20 4e6f 6e65 3a0a 2020 2020 ]) -> None:. \n+00062e50: 2020 2020 6173 7365 7274 2073 656c 662e assert self.\n+00062e60: 5f73 7464 696e 5f74 7261 6e73 706f 7274 _stdin_transport\n+00062e70: 2069 7320 6e6f 7420 4e6f 6e65 0a20 2020 is not None. \n+00062e80: 2020 2020 2072 6574 7572 6e20 7365 6c66 return self\n+00062e90: 2e5f 7374 6469 6e5f 7472 616e 7370 6f72 ._stdin_transpor\n+00062ea0: 742e 7772 6974 656c 696e 6573 286c 6973 t.writelines(lis\n+00062eb0: 745f 6f66 5f64 6174 6129 0a0a 2020 2020 t_of_data).. \n+00062ec0: 6465 6620 7772 6974 655f 656f 6628 7365 def write_eof(se\n+00062ed0: 6c66 2920 2d3e 204e 6f6e 653a 0a20 2020 lf) -> None:. \n+00062ee0: 2020 2020 2061 7373 6572 7420 7365 6c66 assert self\n+00062ef0: 2e5f 7374 6469 6e5f 7472 616e 7370 6f72 ._stdin_transpor\n+00062f00: 7420 6973 206e 6f74 204e 6f6e 650a 2020 t is not None. \n+00062f10: 2020 2020 2020 7265 7475 726e 2073 656c return sel\n+00062f20: 662e 5f73 7464 696e 5f74 7261 6e73 706f f._stdin_transpo\n+00062f30: 7274 2e77 7269 7465 5f65 6f66 2829 0a0a rt.write_eof()..\n+00062f40: 2020 2020 2320 5765 2064 6f6e 2774 2072 # We don't r\n+00062f50: 6561 6c6c 7920 696d 706c 656d 656e 7420 eally implement \n+00062f60: 5375 6270 726f 6365 7373 5472 616e 7370 SubprocessTransp\n+00062f70: 6f72 742c 2062 7574 2070 726f 7669 6465 ort, but provide\n+00062f80: 2074 6865 7365 2061 730a 2020 2020 2320 these as. # \n+00062f90: 2265 7874 7261 7322 2074 6f20 6f75 7220 \"extras\" to our \n+00062fa0: 7573 6572 2e0a 2020 2020 6465 6620 6765 user.. def ge\n+00062fb0: 745f 7069 6428 7365 6c66 2920 2d3e 2069 t_pid(self) -> i\n+00062fc0: 6e74 3a0a 2020 2020 2020 2020 6173 7365 nt:. asse\n+00062fd0: 7274 2073 656c 662e 5f73 7562 7072 6f63 rt self._subproc\n+00062fe0: 6573 735f 7472 616e 7370 6f72 7420 6973 ess_transport is\n+00062ff0: 206e 6f74 204e 6f6e 650a 2020 2020 2020 not None. \n+00063000: 2020 7265 7475 726e 2073 656c 662e 5f73 return self._s\n+00063010: 7562 7072 6f63 6573 735f 7472 616e 7370 ubprocess_transp\n+00063020: 6f72 742e 6765 745f 7069 6428 290a 0a20 ort.get_pid().. \n+00063030: 2020 2064 6566 2067 6574 5f72 6574 7572 def get_retur\n+00063040: 6e63 6f64 6528 7365 6c66 2920 2d3e 2027 ncode(self) -> '\n+00063050: 696e 7420 7c20 4e6f 6e65 273a 0a20 2020 int | None':. \n+00063060: 2020 2020 2072 6574 7572 6e20 7365 6c66 return self\n+00063070: 2e5f 7265 7475 726e 636f 6465 0a0a 2020 ._returncode.. \n+00063080: 2020 6465 6620 6b69 6c6c 2873 656c 6629 def kill(self)\n+00063090: 202d 3e20 4e6f 6e65 3a0a 2020 2020 2020 -> None:. \n+000630a0: 2020 6173 7365 7274 2073 656c 662e 5f73 assert self._s\n+000630b0: 7562 7072 6f63 6573 735f 7472 616e 7370 ubprocess_transp\n+000630c0: 6f72 7420 6973 206e 6f74 204e 6f6e 650a ort is not None.\n+000630d0: 2020 2020 2020 2020 7365 6c66 2e5f 7375 self._su\n+000630e0: 6270 726f 6365 7373 5f74 7261 6e73 706f bprocess_transpo\n+000630f0: 7274 2e6b 696c 6c28 290a 0a20 2020 2064 rt.kill().. d\n+00063100: 6566 2073 656e 645f 7369 676e 616c 2873 ef send_signal(s\n+00063110: 656c 662c 206e 756d 6265 723a 2069 6e74 elf, number: int\n+00063120: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n+00063130: 2020 2061 7373 6572 7420 7365 6c66 2e5f assert self._\n+00063140: 7375 6270 726f 6365 7373 5f74 7261 6e73 subprocess_trans\n+00063150: 706f 7274 2069 7320 6e6f 7420 4e6f 6e65 port is not None\n+00063160: 0a20 2020 2020 2020 2073 656c 662e 5f73 . self._s\n+00063170: 7562 7072 6f63 6573 735f 7472 616e 7370 ubprocess_transp\n+00063180: 6f72 742e 7365 6e64 5f73 6967 6e61 6c28 ort.send_signal(\n+00063190: 6e75 6d62 6572 290a 0a20 2020 2064 6566 number).. def\n+000631a0: 2074 6572 6d69 6e61 7465 2873 656c 6629 terminate(self)\n+000631b0: 202d 3e20 4e6f 6e65 3a0a 2020 2020 2020 -> None:. \n+000631c0: 2020 6173 7365 7274 2073 656c 662e 5f73 assert self._s\n+000631d0: 7562 7072 6f63 6573 735f 7472 616e 7370 ubprocess_transp\n+000631e0: 6f72 7420 6973 206e 6f74 204e 6f6e 650a ort is not None.\n+000631f0: 2020 2020 2020 2020 7365 6c66 2e5f 7375 self._su\n+00063200: 6270 726f 6365 7373 5f74 7261 6e73 706f bprocess_transpo\n+00063210: 7274 2e74 6572 6d69 6e61 7465 2829 0a27 rt.terminate().'\n+00063220: 2727 2c0a 2020 2763 6f63 6b70 6974 2f5f '',. 'cockpit/_\n+00063230: 7665 6e64 6f72 2f66 6572 6e79 2f70 792e vendor/ferny/py.\n+00063240: 7479 7065 6427 3a20 6272 2727 2727 2727 typed': br''''''\n+00063250: 2c0a 2020 2763 6f63 6b70 6974 2f5f 7665 ,. 'cockpit/_ve\n+00063260: 6e64 6f72 2f66 6572 6e79 2f69 6e74 6572 ndor/ferny/inter\n+00063270: 6163 7469 6f6e 5f63 6c69 656e 742e 7079 action_client.py\n+00063280: 273a 2062 7227 2727 2321 2f75 7372 2f62 ': br'''#!/usr/b\n+00063290: 696e 2f70 7974 686f 6e33 0a0a 696d 706f in/python3..impo\n+000632a0: 7274 2061 7272 6179 0a69 6d70 6f72 7420 rt array.import \n+000632b0: 696f 0a69 6d70 6f72 7420 6f73 0a69 6d70 io.import os.imp\n+000632c0: 6f72 7420 736f 636b 6574 0a69 6d70 6f72 ort socket.impor\n+000632d0: 7420 7379 730a 6672 6f6d 2074 7970 696e t sys.from typin\n+000632e0: 6720 696d 706f 7274 2053 6571 7565 6e63 g import Sequenc\n+000632f0: 650a 0a0a 6465 6620 636f 6d6d 616e 6428 e...def command(\n+00063300: 7374 6465 7272 5f66 643a 2069 6e74 2c20 stderr_fd: int, \n+00063310: 636f 6d6d 616e 643a 2073 7472 2c20 2a61 command: str, *a\n+00063320: 7267 733a 206f 626a 6563 742c 2066 6473 rgs: object, fds\n+00063330: 3a20 5365 7175 656e 6365 5b69 6e74 5d20 : Sequence[int] \n+00063340: 3d20 2829 2920 2d3e 204e 6f6e 653a 0a20 = ()) -> None:. \n+00063350: 2020 2063 6d64 5f72 6561 642c 2063 6d64 cmd_read, cmd\n+00063360: 5f77 7269 7465 203d 205b 696f 2e6f 7065 _write = [io.ope\n+00063370: 6e28 2a65 6e64 2920 666f 7220 656e 6420 n(*end) for end \n+00063380: 696e 207a 6970 286f 732e 7069 7065 2829 in zip(os.pipe()\n+00063390: 2c20 2772 7727 295d 0a0a 2020 2020 7769 , 'rw')].. wi\n+000633a0: 7468 2063 6d64 5f77 7269 7465 3a0a 2020 th cmd_write:. \n+000633b0: 2020 2020 2020 7769 7468 2063 6d64 5f72 with cmd_r\n+000633c0: 6561 643a 0a20 2020 2020 2020 2020 2020 ead:. \n+000633d0: 2077 6974 6820 736f 636b 6574 2e66 726f with socket.fro\n+000633e0: 6d66 6428 7374 6465 7272 5f66 642c 2073 mfd(stderr_fd, s\n+000633f0: 6f63 6b65 742e 4146 5f55 4e49 582c 2073 ocket.AF_UNIX, s\n+00063400: 6f63 6b65 742e 534f 434b 5f53 5452 4541 ocket.SOCK_STREA\n+00063410: 4d29 2061 7320 736f 636b 3a0a 2020 2020 M) as sock:. \n+00063420: 2020 2020 2020 2020 2020 2020 6664 5f61 fd_a\n+00063430: 7272 6179 203d 2061 7272 6179 2e61 7272 rray = array.arr\n+00063440: 6179 2827 6927 2c20 2863 6d64 5f72 6561 ay('i', (cmd_rea\n+00063450: 642e 6669 6c65 6e6f 2829 2c20 2a66 6473 d.fileno(), *fds\n+00063460: 2929 0a20 2020 2020 2020 2020 2020 2020 )). \n+00063470: 2020 2073 6f63 6b2e 7365 6e64 6d73 6728 sock.sendmsg(\n+00063480: 5b62 275c 3027 5d2c 205b 2873 6f63 6b65 [b'\\0'], [(socke\n+00063490: 742e 534f 4c5f 534f 434b 4554 2c20 736f t.SOL_SOCKET, so\n+000634a0: 636b 6574 2e53 434d 5f52 4947 4854 532c cket.SCM_RIGHTS,\n+000634b0: 2066 645f 6172 7261 7929 5d29 0a0a 2020 fd_array)]).. \n+000634c0: 2020 2020 2020 636d 645f 7772 6974 652e cmd_write.\n+000634d0: 7772 6974 6528 7265 7072 2828 636f 6d6d write(repr((comm\n+000634e0: 616e 642c 2061 7267 7329 2929 0a0a 0a64 and, args)))...d\n+000634f0: 6566 2061 736b 7061 7373 2873 7464 6572 ef askpass(stder\n+00063500: 725f 6664 3a20 696e 742c 2073 7464 6f75 r_fd: int, stdou\n+00063510: 745f 6664 3a20 696e 742c 2061 7267 733a t_fd: int, args:\n+00063520: 2027 6c69 7374 5b73 7472 5d27 2c20 656e 'list[str]', en\n+00063530: 763a 2027 6469 6374 5b73 7472 2c20 7374 v: 'dict[str, st\n+00063540: 725d 2729 202d 3e20 696e 743a 0a20 2020 r]') -> int:. \n+00063550: 206f 7572 732c 2074 6865 6972 7320 3d20 ours, theirs = \n+00063560: 736f 636b 6574 2e73 6f63 6b65 7470 6169 socket.socketpai\n+00063570: 7228 290a 0a20 2020 2077 6974 6820 7468 r().. with th\n+00063580: 6569 7273 3a0a 2020 2020 2020 2020 636f eirs:. co\n+00063590: 6d6d 616e 6428 7374 6465 7272 5f66 642c mmand(stderr_fd,\n+000635a0: 2027 6665 726e 792e 6173 6b70 6173 7327 'ferny.askpass'\n+000635b0: 2c20 6172 6773 2c20 656e 762c 2066 6473 , args, env, fds\n+000635c0: 3d28 7468 6569 7273 2e66 696c 656e 6f28 =(theirs.fileno(\n+000635d0: 292c 2073 7464 6f75 745f 6664 2929 0a0a ), stdout_fd))..\n+000635e0: 2020 2020 7769 7468 206f 7572 733a 0a20 with ours:. \n+000635f0: 2020 2020 2020 2072 6574 7572 6e20 696e return in\n+00063600: 7428 6f75 7273 2e72 6563 7628 3136 2920 t(ours.recv(16) \n+00063610: 6f72 2062 2731 2729 0a0a 0a64 6566 206d or b'1')...def m\n+00063620: 6169 6e28 2920 2d3e 204e 6f6e 653a 0a20 ain() -> None:. \n+00063630: 2020 2069 6620 6c65 6e28 7379 732e 6172 if len(sys.ar\n+00063640: 6776 2920 3d3d 2031 3a0a 2020 2020 2020 gv) == 1:. \n+00063650: 2020 636f 6d6d 616e 6428 322c 2027 6665 command(2, 'fe\n+00063660: 726e 792e 656e 6427 2c20 5b5d 290a 2020 rny.end', []). \n+00063670: 2020 656c 7365 3a0a 2020 2020 2020 2020 else:. \n+00063680: 7379 732e 6578 6974 2861 736b 7061 7373 sys.exit(askpass\n+00063690: 2832 2c20 312c 2073 7973 2e61 7267 762c (2, 1, sys.argv,\n+000636a0: 2064 6963 7428 6f73 2e65 6e76 6972 6f6e dict(os.environ\n+000636b0: 2929 290a 0a0a 6966 205f 5f6e 616d 655f )))...if __name_\n+000636c0: 5f20 3d3d 2027 5f5f 6d61 696e 5f5f 273a _ == '__main__':\n+000636d0: 0a20 2020 206d 6169 6e28 290a 2727 272c . main().''',\n+000636e0: 0a20 2027 636f 636b 7069 742f 5f76 656e . 'cockpit/_ven\n+000636f0: 646f 722f 6665 726e 792f 7373 685f 6572 dor/ferny/ssh_er\n+00063700: 726f 7273 2e70 7927 3a20 6272 2727 2723 rors.py': br'''#\n+00063710: 2066 6572 6e79 202d 2061 7379 6e63 696f ferny - asyncio\n+00063720: 2053 5348 2063 6c69 656e 7420 6c69 6272 SSH client libr\n+00063730: 6172 792c 2075 7369 6e67 2073 7368 2831 ary, using ssh(1\n+00063740: 290a 230a 2320 436f 7079 7269 6768 7420 ).#.# Copyright \n+00063750: 2843 2920 3230 3233 2041 6c6c 6973 6f6e (C) 2023 Allison\n+00063760: 204b 6172 6c69 7473 6b61 7961 203c 616c Karlitskaya .#.\n+00063790: 2320 5468 6973 2070 726f 6772 616d 2069 # This program i\n+000637a0: 7320 6672 6565 2073 6f66 7477 6172 653a s free software:\n+000637b0: 2079 6f75 2063 616e 2072 6564 6973 7472 you can redistr\n+000637c0: 6962 7574 6520 6974 2061 6e64 2f6f 7220 ibute it and/or \n+000637d0: 6d6f 6469 6679 0a23 2069 7420 756e 6465 modify.# it unde\n+000637e0: 7220 7468 6520 7465 726d 7320 6f66 2074 r the terms of t\n+000637f0: 6865 2047 4e55 2047 656e 6572 616c 2050 he GNU General P\n+00063800: 7562 6c69 6320 4c69 6365 6e73 6520 6173 ublic License as\n+00063810: 2070 7562 6c69 7368 6564 2062 790a 2320 published by.# \n+00063820: 7468 6520 4672 6565 2053 6f66 7477 6172 the Free Softwar\n+00063830: 6520 466f 756e 6461 7469 6f6e 2c20 6569 e Foundation, ei\n+00063840: 7468 6572 2076 6572 7369 6f6e 2033 206f ther version 3 o\n+00063850: 6620 7468 6520 4c69 6365 6e73 652c 206f f the License, o\n+00063860: 720a 2320 2861 7420 796f 7572 206f 7074 r.# (at your opt\n+00063870: 696f 6e29 2061 6e79 206c 6174 6572 2076 ion) any later v\n+00063880: 6572 7369 6f6e 2e0a 230a 2320 5468 6973 ersion..#.# This\n+00063890: 2070 726f 6772 616d 2069 7320 6469 7374 program is dist\n+000638a0: 7269 6275 7465 6420 696e 2074 6865 2068 ributed in the h\n+000638b0: 6f70 6520 7468 6174 2069 7420 7769 6c6c ope that it will\n+000638c0: 2062 6520 7573 6566 756c 2c0a 2320 6275 be useful,.# bu\n+000638d0: 7420 5749 5448 4f55 5420 414e 5920 5741 t WITHOUT ANY WA\n+000638e0: 5252 414e 5459 3b20 7769 7468 6f75 7420 RRANTY; without \n+000638f0: 6576 656e 2074 6865 2069 6d70 6c69 6564 even the implied\n+00063900: 2077 6172 7261 6e74 7920 6f66 0a23 204d warranty of.# M\n+00063910: 4552 4348 414e 5441 4249 4c49 5459 206f ERCHANTABILITY o\n+00063920: 7220 4649 544e 4553 5320 464f 5220 4120 r FITNESS FOR A \n+00063930: 5041 5254 4943 554c 4152 2050 5552 504f PARTICULAR PURPO\n+00063940: 5345 2e20 2053 6565 2074 6865 0a23 2047 SE. See the.# G\n+00063950: 4e55 2047 656e 6572 616c 2050 7562 6c69 NU General Publi\n+00063960: 6320 4c69 6365 6e73 6520 666f 7220 6d6f c License for mo\n+00063970: 7265 2064 6574 6169 6c73 2e0a 230a 2320 re details..#.# \n+00063980: 596f 7520 7368 6f75 6c64 2068 6176 6520 You should have \n+00063990: 7265 6365 6976 6564 2061 2063 6f70 7920 received a copy \n+000639a0: 6f66 2074 6865 2047 4e55 2047 656e 6572 of the GNU Gener\n+000639b0: 616c 2050 7562 6c69 6320 4c69 6365 6e73 al Public Licens\n+000639c0: 650a 2320 616c 6f6e 6720 7769 7468 2074 e.# along with t\n+000639d0: 6869 7320 7072 6f67 7261 6d2e 2020 4966 his program. If\n+000639e0: 206e 6f74 2c20 7365 6520 3c68 7474 703a not, see ...impor\n+00063a10: 7420 6374 7970 6573 0a69 6d70 6f72 7420 t ctypes.import \n+00063a20: 6572 726e 6f0a 696d 706f 7274 206f 730a errno.import os.\n+00063a30: 696d 706f 7274 2072 650a 696d 706f 7274 import re.import\n+00063a40: 2073 6f63 6b65 740a 6672 6f6d 2074 7970 socket.from typ\n+00063a50: 696e 6720 696d 706f 7274 2043 6c61 7373 ing import Class\n+00063a60: 5661 722c 2049 7465 7261 626c 652c 204d Var, Iterable, M\n+00063a70: 6174 6368 2c20 5061 7474 6572 6e0a 0a0a atch, Pattern...\n+00063a80: 636c 6173 7320 5373 6845 7272 6f72 2845 class SshError(E\n+00063a90: 7863 6570 7469 6f6e 293a 0a20 2020 2050 xception):. P\n+00063aa0: 4154 5445 524e 3a20 436c 6173 7356 6172 ATTERN: ClassVar\n+00063ab0: 5b50 6174 7465 726e 5d0a 0a20 2020 2064 [Pattern].. d\n+00063ac0: 6566 205f 5f69 6e69 745f 5f28 7365 6c66 ef __init__(self\n+00063ad0: 2c20 6d61 7463 683a 2027 4d61 7463 6820 , match: 'Match \n+00063ae0: 7c20 4e6f 6e65 272c 2073 7464 6572 723a | None', stderr:\n+00063af0: 2073 7472 2920 2d3e 204e 6f6e 653a 0a20 str) -> None:. \n+00063b00: 2020 2020 2020 2073 7570 6572 2829 2e5f super()._\n+00063b10: 5f69 6e69 745f 5f28 6d61 7463 682e 6772 _init__(match.gr\n+00063b20: 6f75 7028 3029 2069 6620 6d61 7463 6820 oup(0) if match \n+00063b30: 6973 206e 6f74 204e 6f6e 6520 656c 7365 is not None else\n+00063b40: 2073 7464 6572 7229 0a20 2020 2020 2020 stderr). \n+00063b50: 2073 656c 662e 7374 6465 7272 203d 2073 self.stderr = s\n+00063b60: 7464 6572 720a 0a0a 636c 6173 7320 5373 tderr...class Ss\n+00063b70: 6841 7574 6865 6e74 6963 6174 696f 6e45 hAuthenticationE\n+00063b80: 7272 6f72 2853 7368 4572 726f 7229 3a0a rror(SshError):.\n+00063b90: 2020 2020 5041 5454 4552 4e20 3d20 7265 PATTERN = re\n+00063ba0: 2e63 6f6d 7069 6c65 2872 275e 285b 5e3a .compile(r'^([^:\n+00063bb0: 5d2b 293a 2050 6572 6d69 7373 696f 6e20 ]+): Permission \n+00063bc0: 6465 6e69 6564 205c 2828 5b5e 2829 5d2b denied \\(([^()]+\n+00063bd0: 295c 295c 2e24 272c 2072 652e 4d29 0a0a )\\)\\.$', re.M)..\n+00063be0: 2020 2020 6465 6620 5f5f 696e 6974 5f5f def __init__\n+00063bf0: 2873 656c 662c 206d 6174 6368 3a20 4d61 (self, match: Ma\n+00063c00: 7463 682c 2073 7464 6572 723a 2073 7472 tch, stderr: str\n+00063c10: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n+00063c20: 2020 2073 7570 6572 2829 2e5f 5f69 6e69 super().__ini\n+00063c30: 745f 5f28 6d61 7463 682c 2073 7464 6572 t__(match, stder\n+00063c40: 7229 0a20 2020 2020 2020 2073 656c 662e r). self.\n+00063c50: 6465 7374 696e 6174 696f 6e20 3d20 6d61 destination = ma\n+00063c60: 7463 682e 6772 6f75 7028 3129 0a20 2020 tch.group(1). \n+00063c70: 2020 2020 2073 656c 662e 6d65 7468 6f64 self.method\n+00063c80: 7320 3d20 6d61 7463 682e 6772 6f75 7028 s = match.group(\n+00063c90: 3229 2e73 706c 6974 2827 2c27 290a 2020 2).split(','). \n+00063ca0: 2020 2020 2020 7365 6c66 2e6d 6573 7361 self.messa\n+00063cb0: 6765 203d 206d 6174 6368 2e67 726f 7570 ge = match.group\n+00063cc0: 2830 290a 0a0a 2320 6765 6e65 7269 6320 (0)...# generic \n+00063cd0: 686f 7374 206b 6579 2065 7272 6f72 2066 host key error f\n+00063ce0: 6f72 204f 5365 7320 7769 7468 6f75 7420 or OSes without \n+00063cf0: 4b6e 6f77 6e48 6f73 7473 436f 6d6d 616e KnownHostsComman\n+00063d00: 6420 7375 7070 6f72 740a 636c 6173 7320 d support.class \n+00063d10: 5373 6848 6f73 744b 6579 4572 726f 7228 SshHostKeyError(\n+00063d20: 5373 6845 7272 6f72 293a 0a20 2020 2050 SshError):. P\n+00063d30: 4154 5445 524e 203d 2072 652e 636f 6d70 ATTERN = re.comp\n+00063d40: 696c 6528 7227 5e48 6f73 7420 6b65 7920 ile(r'^Host key \n+00063d50: 7665 7269 6669 6361 7469 6f6e 2066 6169 verification fai\n+00063d60: 6c65 642e 2427 2c20 7265 2e4d 290a 0a0a led.$', re.M)...\n+00063d70: 2320 7370 6563 6966 6963 2065 7272 6f72 # specific error\n+00063d80: 7320 666f 7220 4f53 6573 2077 6974 6820 s for OSes with \n+00063d90: 4b6e 6f77 6e48 6f73 7473 436f 6d6d 616e KnownHostsComman\n+00063da0: 640a 636c 6173 7320 5373 6855 6e6b 6e6f d.class SshUnkno\n+00063db0: 776e 486f 7374 4b65 7945 7272 6f72 2853 wnHostKeyError(S\n+00063dc0: 7368 486f 7374 4b65 7945 7272 6f72 293a shHostKeyError):\n+00063dd0: 0a20 2020 2050 4154 5445 524e 203d 2072 . PATTERN = r\n+00063de0: 652e 636f 6d70 696c 6528 7227 5e4e 6f20 e.compile(r'^No \n+00063df0: 2e2a 2068 6f73 7420 6b65 7920 6973 206b .* host key is k\n+00063e00: 6e6f 776e 2e2a 486f 7374 206b 6579 2076 nown.*Host key v\n+00063e10: 6572 6966 6963 6174 696f 6e20 6661 696c erification fail\n+00063e20: 6564 2e24 272c 2072 652e 5320 7c20 7265 ed.$', re.S | re\n+00063e30: 2e4d 290a 0a0a 636c 6173 7320 5373 6843 .M)...class SshC\n+00063e40: 6861 6e67 6564 486f 7374 4b65 7945 7272 hangedHostKeyErr\n+00063e50: 6f72 2853 7368 486f 7374 4b65 7945 7272 or(SshHostKeyErr\n+00063e60: 6f72 293a 0a20 2020 2050 4154 5445 524e or):. PATTERN\n+00063e70: 203d 2072 652e 636f 6d70 696c 6528 7227 = re.compile(r'\n+00063e80: 7761 726e 696e 672e 2a72 656d 6f74 6520 warning.*remote \n+00063e90: 686f 7374 2069 6465 6e74 6966 6963 6174 host identificat\n+00063ea0: 696f 6e20 6861 7320 6368 616e 6765 6427 ion has changed'\n+00063eb0: 2c20 7265 2e49 290a 0a0a 2320 4675 6e63 , re.I)...# Func\n+00063ec0: 7469 6f6e 616c 6974 7920 666f 7220 6d61 tionality for ma\n+00063ed0: 7070 696e 6720 6765 7461 6464 7269 6e66 pping getaddrinf\n+00063ee0: 6f28 292d 6661 6d69 6c79 2065 7272 6f72 o()-family error\n+00063ef0: 206d 6573 7361 6765 7320 746f 2074 6865 messages to the\n+00063f00: 6972 0a23 2065 7175 6976 616c 656e 7420 ir.# equivalent \n+00063f10: 5079 7468 6f6e 2065 7863 6570 7469 6f6e Python exception\n+00063f20: 732e 0a64 6566 206d 616b 655f 6761 6965 s..def make_gaie\n+00063f30: 7272 6f72 5f6d 6170 2829 202d 3e20 2749 rror_map() -> 'I\n+00063f40: 7465 7261 626c 655b 7475 706c 655b 7374 terable[tuple[st\n+00063f50: 722c 2069 6e74 5d5d 273a 0a20 2020 206c r, int]]':. l\n+00063f60: 6962 6320 3d20 6374 7970 6573 2e43 444c ibc = ctypes.CDL\n+00063f70: 4c28 4e6f 6e65 290a 2020 2020 6c69 6263 L(None). libc\n+00063f80: 2e67 6169 5f73 7472 6572 726f 722e 7265 .gai_strerror.re\n+00063f90: 7374 7970 6520 3d20 6374 7970 6573 2e63 stype = ctypes.c\n+00063fa0: 5f63 6861 725f 700a 0a20 2020 2066 6f72 _char_p.. for\n+00063fb0: 206b 6579 2069 6e20 6469 7228 736f 636b key in dir(sock\n+00063fc0: 6574 293a 0a20 2020 2020 2020 2069 6620 et):. if \n+00063fd0: 6b65 792e 7374 6172 7473 7769 7468 2827 key.startswith('\n+00063fe0: 4541 495f 2729 3a0a 2020 2020 2020 2020 EAI_'):. \n+00063ff0: 2020 2020 6572 726e 756d 203d 2067 6574 errnum = get\n+00064000: 6174 7472 2873 6f63 6b65 742c 206b 6579 attr(socket, key\n+00064010: 290a 2020 2020 2020 2020 2020 2020 7969 ). yi\n+00064020: 656c 6420 6c69 6263 2e67 6169 5f73 7472 eld libc.gai_str\n+00064030: 6572 726f 7228 6572 726e 756d 292e 6465 error(errnum).de\n+00064040: 636f 6465 2827 7574 662d 3827 292c 2065 code('utf-8'), e\n+00064050: 7272 6e75 6d0a 0a0a 6761 6965 7272 6f72 rrnum...gaierror\n+00064060: 5f6d 6170 203d 2064 6963 7428 6d61 6b65 _map = dict(make\n+00064070: 5f67 6169 6572 726f 725f 6d61 7028 2929 _gaierror_map())\n+00064080: 0a0a 0a23 2046 756e 6374 696f 6e61 6c69 ...# Functionali\n+00064090: 7479 2066 6f72 2070 6173 7369 6e67 2073 ty for passing s\n+000640a0: 7472 6572 726f 7228 2920 6572 726f 7220 trerror() error \n+000640b0: 6d65 7373 6167 6573 2074 6f20 7468 6569 messages to thei\n+000640c0: 7220 6571 7569 7661 6c65 6e74 0a23 2050 r equivalent.# P\n+000640d0: 7974 686f 6e20 6578 6365 7074 696f 6e73 ython exceptions\n+000640e0: 2e0a 2320 5468 6572 6520 646f 6573 6e27 ..# There doesn'\n+000640f0: 7420 7365 656d 2074 6f20 6265 2061 6e20 t seem to be an \n+00064100: 6f66 6669 6369 616c 2041 5049 2066 6f72 official API for\n+00064110: 2074 7572 6e69 6e67 2061 6e20 6572 726e turning an errn\n+00064120: 6f20 696e 746f 2074 6865 0a23 2063 6f72 o into the.# cor\n+00064130: 7265 6374 2073 7562 7479 7065 206f 6620 rect subtype of \n+00064140: 4f53 4572 726f 722c 2061 6e64 2074 6865 OSError, and the\n+00064150: 206c 6973 7420 7468 6174 2063 7079 7468 list that cpyth\n+00064160: 6f6e 2075 7365 7320 6973 2068 6964 6465 on uses is hidde\n+00064170: 6e20 6661 6972 6c79 0a23 2064 6565 706c n fairly.# deepl\n+00064180: 7920 696e 7369 6465 206f 6620 7468 6520 y inside of the \n+00064190: 696d 706c 656d 656e 7461 7469 6f6e 2e20 implementation. \n+000641a0: 2054 6869 7320 6973 2062 6173 6963 616c This is basical\n+000641b0: 6c79 2063 6f70 6965 6420 6672 6f6d 2074 ly copied from t\n+000641c0: 6865 0a23 2041 4444 5f45 5252 4e4f 2829 he.# ADD_ERRNO()\n+000641d0: 206c 696e 6573 2069 6e20 5f50 7945 7863 lines in _PyExc\n+000641e0: 5f49 6e69 7453 7461 7465 2069 6e20 6370 _InitState in cp\n+000641f0: 7974 686f 6e2f 4f62 6a65 6374 732f 6578 ython/Objects/ex\n+00064200: 6365 7074 696f 6e73 2e63 0a6f 7365 7272 ceptions.c.oserr\n+00064210: 6f72 5f73 7562 636c 6173 735f 6d61 7020 or_subclass_map \n+00064220: 3d20 6469 6374 2828 6572 726e 756d 2c20 = dict((errnum, \n+00064230: 636c 7329 2066 6f72 2063 6c73 2c20 6572 cls) for cls, er\n+00064240: 726e 756d 2069 6e20 5b0a 2020 2020 2842 rnum in [. (B\n+00064250: 6c6f 636b 696e 6749 4f45 7272 6f72 2c20 lockingIOError, \n+00064260: 6572 726e 6f2e 4541 4741 494e 292c 0a20 errno.EAGAIN),. \n+00064270: 2020 2028 426c 6f63 6b69 6e67 494f 4572 (BlockingIOEr\n+00064280: 726f 722c 2065 7272 6e6f 2e45 414c 5245 ror, errno.EALRE\n+00064290: 4144 5929 2c0a 2020 2020 2842 6c6f 636b ADY),. (Block\n+000642a0: 696e 6749 4f45 7272 6f72 2c20 6572 726e ingIOError, errn\n+000642b0: 6f2e 4549 4e50 524f 4752 4553 5329 2c0a o.EINPROGRESS),.\n+000642c0: 2020 2020 2842 6c6f 636b 696e 6749 4f45 (BlockingIOE\n+000642d0: 7272 6f72 2c20 6572 726e 6f2e 4557 4f55 rror, errno.EWOU\n+000642e0: 4c44 424c 4f43 4b29 2c0a 2020 2020 2842 LDBLOCK),. (B\n+000642f0: 726f 6b65 6e50 6970 6545 7272 6f72 2c20 rokenPipeError, \n+00064300: 6572 726e 6f2e 4550 4950 4529 2c0a 2020 errno.EPIPE),. \n+00064310: 2020 2842 726f 6b65 6e50 6970 6545 7272 (BrokenPipeErr\n+00064320: 6f72 2c20 6572 726e 6f2e 4553 4855 5444 or, errno.ESHUTD\n+00064330: 4f57 4e29 2c0a 2020 2020 2843 6869 6c64 OWN),. (Child\n+00064340: 5072 6f63 6573 7345 7272 6f72 2c20 6572 ProcessError, er\n+00064350: 726e 6f2e 4543 4849 4c44 292c 0a20 2020 rno.ECHILD),. \n+00064360: 2028 436f 6e6e 6563 7469 6f6e 4162 6f72 (ConnectionAbor\n+00064370: 7465 6445 7272 6f72 2c20 6572 726e 6f2e tedError, errno.\n+00064380: 4543 4f4e 4e41 424f 5254 4544 292c 0a20 ECONNABORTED),. \n+00064390: 2020 2028 436f 6e6e 6563 7469 6f6e 5265 (ConnectionRe\n+000643a0: 6675 7365 6445 7272 6f72 2c20 6572 726e fusedError, errn\n+000643b0: 6f2e 4543 4f4e 4e52 4546 5553 4544 292c o.ECONNREFUSED),\n+000643c0: 0a20 2020 2028 436f 6e6e 6563 7469 6f6e . (Connection\n+000643d0: 5265 7365 7445 7272 6f72 2c20 6572 726e ResetError, errn\n+000643e0: 6f2e 4543 4f4e 4e52 4553 4554 292c 0a20 o.ECONNRESET),. \n+000643f0: 2020 2028 4669 6c65 4578 6973 7473 4572 (FileExistsEr\n+00064400: 726f 722c 2065 7272 6e6f 2e45 4558 4953 ror, errno.EEXIS\n+00064410: 5429 2c0a 2020 2020 2846 696c 654e 6f74 T),. (FileNot\n+00064420: 466f 756e 6445 7272 6f72 2c20 6572 726e FoundError, errn\n+00064430: 6f2e 454e 4f45 4e54 292c 0a20 2020 2028 o.ENOENT),. (\n+00064440: 4973 4144 6972 6563 746f 7279 4572 726f IsADirectoryErro\n+00064450: 722c 2065 7272 6e6f 2e45 4953 4449 5229 r, errno.EISDIR)\n+00064460: 2c0a 2020 2020 284e 6f74 4144 6972 6563 ,. (NotADirec\n+00064470: 746f 7279 4572 726f 722c 2065 7272 6e6f toryError, errno\n+00064480: 2e45 4e4f 5444 4952 292c 0a20 2020 2028 .ENOTDIR),. (\n+00064490: 496e 7465 7272 7570 7465 6445 7272 6f72 InterruptedError\n+000644a0: 2c20 6572 726e 6f2e 4549 4e54 5229 2c0a , errno.EINTR),.\n+000644b0: 2020 2020 2850 6572 6d69 7373 696f 6e45 (PermissionE\n+000644c0: 7272 6f72 2c20 6572 726e 6f2e 4541 4343 rror, errno.EACC\n+000644d0: 4553 292c 0a20 2020 2028 5065 726d 6973 ES),. (Permis\n+000644e0: 7369 6f6e 4572 726f 722c 2065 7272 6e6f sionError, errno\n+000644f0: 2e45 5045 524d 292c 0a20 2020 2028 5072 .EPERM),. (Pr\n+00064500: 6f63 6573 734c 6f6f 6b75 7045 7272 6f72 ocessLookupError\n+00064510: 2c20 6572 726e 6f2e 4553 5243 4829 2c0a , errno.ESRCH),.\n+00064520: 2020 2020 2854 696d 656f 7574 4572 726f (TimeoutErro\n+00064530: 722c 2065 7272 6e6f 2e45 5449 4d45 444f r, errno.ETIMEDO\n+00064540: 5554 292c 0a5d 290a 0a0a 6465 6620 6765 UT),.])...def ge\n+00064550: 745f 6578 6365 7074 696f 6e5f 666f 725f t_exception_for_\n+00064560: 7373 685f 7374 6465 7272 2873 7464 6572 ssh_stderr(stder\n+00064570: 723a 2073 7472 2920 2d3e 2045 7863 6570 r: str) -> Excep\n+00064580: 7469 6f6e 3a0a 2020 2020 7374 6465 7272 tion:. stderr\n+00064590: 203d 2073 7464 6572 722e 7265 706c 6163 = stderr.replac\n+000645a0: 6528 275c 725c 6e27 2c20 275c 6e27 2920 e('\\r\\n', '\\n') \n+000645b0: 2023 2066 6978 206c 696e 6520 7365 7061 # fix line sepa\n+000645c0: 7261 746f 7273 0a0a 2020 2020 2320 6368 rators.. # ch\n+000645d0: 6563 6b20 666f 7220 7468 6520 7370 6563 eck for the spec\n+000645e0: 6966 6963 2065 7272 6f72 206d 6573 7361 ific error messa\n+000645f0: 6765 7320 6669 7273 742c 2074 6865 6e20 ges first, then \n+00064600: 666f 7220 6765 6e65 7269 6320 5373 6848 for generic SshH\n+00064610: 6f73 744b 6579 4572 726f 720a 2020 2020 ostKeyError. \n+00064620: 666f 7220 7373 685f 636c 7320 696e 205b for ssh_cls in [\n+00064630: 5373 6841 7574 6865 6e74 6963 6174 696f SshAuthenticatio\n+00064640: 6e45 7272 6f72 2c20 5373 6843 6861 6e67 nError, SshChang\n+00064650: 6564 486f 7374 4b65 7945 7272 6f72 2c20 edHostKeyError, \n+00064660: 5373 6855 6e6b 6e6f 776e 486f 7374 4b65 SshUnknownHostKe\n+00064670: 7945 7272 6f72 2c20 5373 6848 6f73 744b yError, SshHostK\n+00064680: 6579 4572 726f 725d 3a0a 2020 2020 2020 eyError]:. \n+00064690: 2020 6d61 7463 6820 3d20 7373 685f 636c match = ssh_cl\n+000646a0: 732e 5041 5454 4552 4e2e 7365 6172 6368 s.PATTERN.search\n+000646b0: 2873 7464 6572 7229 0a20 2020 2020 2020 (stderr). \n+000646c0: 2069 6620 6d61 7463 6820 6973 206e 6f74 if match is not\n+000646d0: 204e 6f6e 653a 0a20 2020 2020 2020 2020 None:. \n+000646e0: 2020 2072 6574 7572 6e20 7373 685f 636c return ssh_cl\n+000646f0: 7328 6d61 7463 682c 2073 7464 6572 7229 s(match, stderr)\n+00064700: 0a0a 2020 2020 6265 666f 7265 2c20 636f .. before, co\n+00064710: 6c6f 6e2c 2061 6674 6572 203d 2073 7464 lon, after = std\n+00064720: 6572 722e 7270 6172 7469 7469 6f6e 2827 err.rpartition('\n+00064730: 3a27 290a 2020 2020 6966 2063 6f6c 6f6e :'). if colon\n+00064740: 2061 6e64 2061 6674 6572 3a0a 2020 2020 and after:. \n+00064750: 2020 2020 706f 7465 6e74 6961 6c5f 7374 potential_st\n+00064760: 7265 7272 6f72 203d 2061 6674 6572 2e73 rerror = after.s\n+00064770: 7472 6970 2829 0a0a 2020 2020 2020 2020 trip().. \n+00064780: 2320 444e 5320 6c6f 6f6b 7570 2065 7272 # DNS lookup err\n+00064790: 6f72 730a 2020 2020 2020 2020 6966 2070 ors. if p\n+000647a0: 6f74 656e 7469 616c 5f73 7472 6572 726f otential_strerro\n+000647b0: 7220 696e 2067 6169 6572 726f 725f 6d61 r in gaierror_ma\n+000647c0: 703a 0a20 2020 2020 2020 2020 2020 2065 p:. e\n+000647d0: 7272 6e75 6d20 3d20 6761 6965 7272 6f72 rrnum = gaierror\n+000647e0: 5f6d 6170 5b70 6f74 656e 7469 616c 5f73 _map[potential_s\n+000647f0: 7472 6572 726f 725d 0a20 2020 2020 2020 trerror]. \n+00064800: 2020 2020 2072 6574 7572 6e20 736f 636b return sock\n+00064810: 6574 2e67 6169 6572 726f 7228 6572 726e et.gaierror(errn\n+00064820: 756d 2c20 7374 6465 7272 290a 0a20 2020 um, stderr).. \n+00064830: 2020 2020 2023 204e 6574 776f 726b 2063 # Network c\n+00064840: 6f6e 6e65 6374 2065 7272 6f72 730a 2020 onnect errors. \n+00064850: 2020 2020 2020 666f 7220 6572 726e 756d for errnum\n+00064860: 2069 6e20 6572 726e 6f2e 6572 726f 7263 in errno.errorc\n+00064870: 6f64 653a 0a20 2020 2020 2020 2020 2020 ode:. \n+00064880: 2069 6620 6f73 2e73 7472 6572 726f 7228 if os.strerror(\n+00064890: 6572 726e 756d 2920 3d3d 2070 6f74 656e errnum) == poten\n+000648a0: 7469 616c 5f73 7472 6572 726f 723a 0a20 tial_strerror:. \n+000648b0: 2020 2020 2020 2020 2020 2020 2020 206f o\n+000648c0: 735f 636c 7320 3d20 6f73 6572 726f 725f s_cls = oserror_\n+000648d0: 7375 6263 6c61 7373 5f6d 6170 2e67 6574 subclass_map.get\n+000648e0: 2865 7272 6e75 6d2c 204f 5345 7272 6f72 (errnum, OSError\n+000648f0: 290a 2020 2020 2020 2020 2020 2020 2020 ). \n+00064900: 2020 7265 7475 726e 206f 735f 636c 7328 return os_cls(\n+00064910: 6572 726e 756d 2c20 7374 6465 7272 290a errnum, stderr).\n+00064920: 0a20 2020 2023 204e 6f20 6d61 7463 683f . # No match?\n+00064930: 2020 4765 6e65 7269 632e 0a20 2020 2072 Generic.. r\n+00064940: 6574 7572 6e20 5373 6845 7272 6f72 284e eturn SshError(N\n+00064950: 6f6e 652c 2073 7464 6572 7229 0a27 2727 one, stderr).'''\n+00064960: 2c0a 2020 2763 6f63 6b70 6974 2f5f 7665 ,. 'cockpit/_ve\n+00064970: 6e64 6f72 2f66 6572 6e79 2f73 6573 7369 ndor/ferny/sessi\n+00064980: 6f6e 2e70 7927 3a20 7227 2727 2320 6665 on.py': r'''# fe\n+00064990: 726e 7920 2d20 6173 796e 6369 6f20 5353 rny - asyncio SS\n+000649a0: 4820 636c 6965 6e74 206c 6962 7261 7279 H client library\n+000649b0: 2c20 7573 696e 6720 7373 6828 3129 0a23 , using ssh(1).#\n+000649c0: 0a23 2043 6f70 7972 6967 6874 2028 4329 .# Copyright (C)\n+000649d0: 2032 3032 3220 416c 6c69 736f 6e20 4b61 2022 Allison Ka\n+000649e0: 726c 6974 736b 6179 6120 3c61 6c6c 6973 rlitskaya .#.# T\n+00064a10: 6869 7320 7072 6f67 7261 6d20 6973 2066 his program is f\n+00064a20: 7265 6520 736f 6674 7761 7265 3a20 796f ree software: yo\n+00064a30: 7520 6361 6e20 7265 6469 7374 7269 6275 u can redistribu\n+00064a40: 7465 2069 7420 616e 642f 6f72 206d 6f64 te it and/or mod\n+00064a50: 6966 790a 2320 6974 2075 6e64 6572 2074 ify.# it under t\n+00064a60: 6865 2074 6572 6d73 206f 6620 7468 6520 he terms of the \n+00064a70: 474e 5520 4765 6e65 7261 6c20 5075 626c GNU General Publ\n+00064a80: 6963 204c 6963 656e 7365 2061 7320 7075 ic License as pu\n+00064a90: 626c 6973 6865 6420 6279 0a23 2074 6865 blished by.# the\n+00064aa0: 2046 7265 6520 536f 6674 7761 7265 2046 Free Software F\n+00064ab0: 6f75 6e64 6174 696f 6e2c 2065 6974 6865 oundation, eithe\n+00064ac0: 7220 7665 7273 696f 6e20 3320 6f66 2074 r version 3 of t\n+00064ad0: 6865 204c 6963 656e 7365 2c20 6f72 0a23 he License, or.#\n+00064ae0: 2028 6174 2079 6f75 7220 6f70 7469 6f6e (at your option\n+00064af0: 2920 616e 7920 6c61 7465 7220 7665 7273 ) any later vers\n+00064b00: 696f 6e2e 0a23 0a23 2054 6869 7320 7072 ion..#.# This pr\n+00064b10: 6f67 7261 6d20 6973 2064 6973 7472 6962 ogram is distrib\n+00064b20: 7574 6564 2069 6e20 7468 6520 686f 7065 uted in the hope\n+00064b30: 2074 6861 7420 6974 2077 696c 6c20 6265 that it will be\n+00064b40: 2075 7365 6675 6c2c 0a23 2062 7574 2057 useful,.# but W\n+00064b50: 4954 484f 5554 2041 4e59 2057 4152 5241 ITHOUT ANY WARRA\n+00064b60: 4e54 593b 2077 6974 686f 7574 2065 7665 NTY; without eve\n+00064b70: 6e20 7468 6520 696d 706c 6965 6420 7761 n the implied wa\n+00064b80: 7272 616e 7479 206f 660a 2320 4d45 5243 rranty of.# MERC\n+00064b90: 4841 4e54 4142 494c 4954 5920 6f72 2046 HANTABILITY or F\n+00064ba0: 4954 4e45 5353 2046 4f52 2041 2050 4152 ITNESS FOR A PAR\n+00064bb0: 5449 4355 4c41 5220 5055 5250 4f53 452e TICULAR PURPOSE.\n+00064bc0: 2020 5365 6520 7468 650a 2320 474e 5520 See the.# GNU \n+00064bd0: 4765 6e65 7261 6c20 5075 626c 6963 204c General Public L\n+00064be0: 6963 656e 7365 2066 6f72 206d 6f72 6520 icense for more \n+00064bf0: 6465 7461 696c 732e 0a23 0a23 2059 6f75 details..#.# You\n+00064c00: 2073 686f 756c 6420 6861 7665 2072 6563 should have rec\n+00064c10: 6569 7665 6420 6120 636f 7079 206f 6620 eived a copy of \n+00064c20: 7468 6520 474e 5520 4765 6e65 7261 6c20 the GNU General \n+00064c30: 5075 626c 6963 204c 6963 656e 7365 0a23 Public License.#\n+00064c40: 2061 6c6f 6e67 2077 6974 6820 7468 6973 along with this\n+00064c50: 2070 726f 6772 616d 2e20 2049 6620 6e6f program. If no\n+00064c60: 742c 2073 6565 203c 6874 7470 3a2f 2f77 t, see ...import a\n+00064c90: 7379 6e63 696f 0a69 6d70 6f72 7420 6374 syncio.import ct\n+00064ca0: 7970 6573 0a69 6d70 6f72 7420 6675 6e63 ypes.import func\n+00064cb0: 746f 6f6c 730a 696d 706f 7274 206c 6f67 tools.import log\n+00064cc0: 6769 6e67 0a69 6d70 6f72 7420 6f73 0a69 ging.import os.i\n+00064cd0: 6d70 6f72 7420 7368 6c65 780a 696d 706f mport shlex.impo\n+00064ce0: 7274 2073 6967 6e61 6c0a 696d 706f 7274 rt signal.import\n+00064cf0: 2073 7562 7072 6f63 6573 730a 696d 706f subprocess.impo\n+00064d00: 7274 2074 656d 7066 696c 650a 6672 6f6d rt tempfile.from\n+00064d10: 2074 7970 696e 6720 696d 706f 7274 204d typing import M\n+00064d20: 6170 7069 6e67 2c20 5365 7175 656e 6365 apping, Sequence\n+00064d30: 0a0a 6672 6f6d 202e 2069 6d70 6f72 7420 ..from . import \n+00064d40: 7373 685f 6572 726f 7273 0a66 726f 6d20 ssh_errors.from \n+00064d50: 2e69 6e74 6572 6163 7469 6f6e 5f61 6765 .interaction_age\n+00064d60: 6e74 2069 6d70 6f72 7420 496e 7465 7261 nt import Intera\n+00064d70: 6374 696f 6e41 6765 6e74 2c20 496e 7465 ctionAgent, Inte\n+00064d80: 7261 6374 696f 6e45 7272 6f72 2c20 496e ractionError, In\n+00064d90: 7465 7261 6374 696f 6e48 616e 646c 6572 teractionHandler\n+00064da0: 2c20 7772 6974 655f 6173 6b70 6173 735f , write_askpass_\n+00064db0: 746f 5f74 6d70 6469 720a 0a70 7263 746c to_tmpdir..prctl\n+00064dc0: 203d 2063 7479 7065 732e 6364 6c6c 2e4c = ctypes.cdll.L\n+00064dd0: 6f61 644c 6962 7261 7279 2827 6c69 6263 oadLibrary('libc\n+00064de0: 2e73 6f2e 3627 292e 7072 6374 6c0a 6c6f .so.6').prctl.lo\n+00064df0: 6767 6572 203d 206c 6f67 6769 6e67 2e67 gger = logging.g\n+00064e00: 6574 4c6f 6767 6572 285f 5f6e 616d 655f etLogger(__name_\n+00064e10: 5f29 0a50 525f 5345 545f 5044 4541 5448 _).PR_SET_PDEATH\n+00064e20: 5349 4720 3d20 310a 0a0a 4066 756e 6374 SIG = 1...@funct\n+00064e30: 6f6f 6c73 2e6c 7275 5f63 6163 6865 2829 ools.lru_cache()\n+00064e40: 0a64 6566 2068 6173 5f66 6561 7475 7265 .def has_feature\n+00064e50: 2866 6561 7475 7265 3a20 7374 722c 2074 (feature: str, t\n+00064e60: 6573 7473 7472 3a20 7374 7220 3d20 2778 eststr: str = 'x\n+00064e70: 2729 202d 3e20 626f 6f6c 3a0a 2020 2020 ') -> bool:. \n+00064e80: 7472 793a 0a20 2020 2020 2020 2073 7562 try:. sub\n+00064e90: 7072 6f63 6573 732e 6368 6563 6b5f 6f75 process.check_ou\n+00064ea0: 7470 7574 285b 2773 7368 272c 2066 272d tput(['ssh', f'-\n+00064eb0: 6f7b 6665 6174 7572 657d 207b 7465 7374 o{feature} {test\n+00064ec0: 7374 727d 272c 2027 2d47 272c 2027 6e6f str}', '-G', 'no\n+00064ed0: 6e65 7869 7374 696e 6727 5d2c 2073 7464 nexisting'], std\n+00064ee0: 6572 723d 7375 6270 726f 6365 7373 2e44 err=subprocess.D\n+00064ef0: 4556 4e55 4c4c 290a 2020 2020 2020 2020 EVNULL). \n+00064f00: 7265 7475 726e 2054 7275 650a 2020 2020 return True. \n+00064f10: 6578 6365 7074 2073 7562 7072 6f63 6573 except subproces\n+00064f20: 732e 4361 6c6c 6564 5072 6f63 6573 7345 s.CalledProcessE\n+00064f30: 7272 6f72 3a0a 2020 2020 2020 2020 7265 rror:. re\n+00064f40: 7475 726e 2046 616c 7365 0a0a 0a63 6c61 turn False...cla\n+00064f50: 7373 2053 7562 7072 6f63 6573 7343 6f6e ss SubprocessCon\n+00064f60: 7465 7874 3a0a 2020 2020 6465 6620 7772 text:. def wr\n+00064f70: 6170 5f73 7562 7072 6f63 6573 735f 6172 ap_subprocess_ar\n+00064f80: 6773 2873 656c 662c 2061 7267 733a 2053 gs(self, args: S\n+00064f90: 6571 7565 6e63 655b 7374 725d 2920 2d3e equence[str]) ->\n+00064fa0: 2053 6571 7565 6e63 655b 7374 725d 3a0a Sequence[str]:.\n+00064fb0: 2020 2020 2020 2020 2222 2252 6574 7572 \"\"\"Retur\n+00064fc0: 6e20 7468 6520 6172 6773 2072 6571 7569 n the args requi\n+00064fd0: 7265 6420 746f 206c 6175 6e63 6820 6120 red to launch a \n+00064fe0: 7072 6f63 6573 7320 696e 2074 6865 2067 process in the g\n+00064ff0: 6976 656e 2063 6f6e 7465 7874 2e0a 0a20 iven context... \n+00065000: 2020 2020 2020 2046 6f72 2065 7861 6d70 For examp\n+00065010: 6c65 2c20 7468 6973 206d 6967 6874 2072 le, this might r\n+00065020: 6574 7572 6e20 6120 7665 6374 6f72 2077 eturn a vector w\n+00065030: 6974 680a 2020 2020 2020 2020 2020 2020 ith. \n+00065040: 5b22 7375 646f 225d 0a20 2020 2020 2020 [\"sudo\"]. \n+00065050: 206f 720a 2020 2020 2020 2020 2020 2020 or. \n+00065060: 5b22 666c 6174 7061 6b2d 7370 6177 6e22 [\"flatpak-spawn\"\n+00065070: 2c20 222d 2d68 6f73 7422 5d0a 2020 2020 , \"--host\"]. \n+00065080: 2020 2020 7072 6570 656e 6465 642e 0a0a prepended...\n+00065090: 2020 2020 2020 2020 4974 2069 7320 616c It is al\n+000650a0: 736f 2070 6f73 7369 626c 6520 7468 6174 so possible that\n+000650b0: 206d 6f72 6520 7375 6273 7461 6e74 6961 more substantia\n+000650c0: 6c20 6368 616e 6765 7320 6d61 7920 6265 l changes may be\n+000650d0: 2070 6572 666f 726d 6564 2e0a 0a20 2020 performed... \n+000650e0: 2020 2020 2054 6869 7320 6675 6e63 7469 This functi\n+000650f0: 6f6e 2069 7320 6e6f 7420 7065 726d 6974 on is not permit\n+00065100: 7465 6420 746f 206d 6f64 6966 7920 6974 ted to modify it\n+00065110: 7320 6172 6775 6d65 6e74 2c20 616c 7468 s argument, alth\n+00065120: 6f75 6768 2069 7420 6d61 790a 2020 2020 ough it may. \n+00065130: 2020 2020 286f 7074 696f 6e61 6c6c 7929 (optionally)\n+00065140: 2072 6574 7572 6e20 6974 2075 6e6d 6f64 return it unmod\n+00065150: 6966 6965 642c 2069 6620 6e6f 2063 6861 ified, if no cha\n+00065160: 6e67 6573 2061 7265 2072 6571 7569 7265 nges are require\n+00065170: 642e 0a20 2020 2020 2020 2022 2222 0a20 d.. \"\"\". \n+00065180: 2020 2020 2020 2072 6574 7572 6e20 6172 return ar\n+00065190: 6773 0a0a 2020 2020 6465 6620 7772 6170 gs.. def wrap\n+000651a0: 5f73 7562 7072 6f63 6573 735f 656e 7628 _subprocess_env(\n+000651b0: 7365 6c66 2c20 656e 763a 204d 6170 7069 self, env: Mappi\n+000651c0: 6e67 5b73 7472 2c20 7374 725d 2920 2d3e ng[str, str]) ->\n+000651d0: 204d 6170 7069 6e67 5b73 7472 2c20 7374 Mapping[str, st\n+000651e0: 725d 3a0a 2020 2020 2020 2020 2222 2252 r]:. \"\"\"R\n+000651f0: 6574 7572 6e20 7468 6520 656e 7670 2072 eturn the envp r\n+00065200: 6571 7569 7265 6420 746f 206c 6175 6e63 equired to launc\n+00065210: 6820 6120 7072 6f63 6573 7320 696e 2074 h a process in t\n+00065220: 6865 2067 6976 656e 2063 6f6e 7465 7874 he given context\n+00065230: 2e0a 0a20 2020 2020 2020 2046 6f72 2065 ... For e\n+00065240: 7861 6d70 6c65 2c20 7468 6973 206d 6967 xample, this mig\n+00065250: 6874 2073 6574 2074 6865 2022 5355 444f ht set the \"SUDO\n+00065260: 5f41 534b 5041 5353 2220 656e 7669 726f _ASKPASS\" enviro\n+00065270: 6e6d 656e 7420 7661 7269 6162 6c65 2c20 nment variable, \n+00065280: 6966 0a20 2020 2020 2020 206e 6565 6465 if. neede\n+00065290: 642e 0a0a 2020 2020 2020 2020 4173 2077 d... As w\n+000652a0: 6974 6820 7772 6170 5f73 7562 7072 6f63 ith wrap_subproc\n+000652b0: 6573 735f 6172 6773 2829 2c20 7468 6973 ess_args(), this\n+000652c0: 2066 756e 6374 696f 6e20 6973 206e 6f74 function is not\n+000652d0: 2070 6572 6d69 7474 6564 2074 6f0a 2020 permitted to. \n+000652e0: 2020 2020 2020 6d6f 6469 6679 2069 7473 modify its\n+000652f0: 2061 7267 756d 656e 742c 2061 6c74 686f argument, altho\n+00065300: 7567 6820 6974 206d 6179 2028 6f70 7469 ugh it may (opti\n+00065310: 6f6e 616c 6c79 2920 7265 7475 726e 2069 onally) return i\n+00065320: 7420 756e 6d6f 6469 6669 6564 0a20 2020 t unmodified. \n+00065330: 2020 2020 2069 6620 6e6f 2063 6861 6e67 if no chang\n+00065340: 6573 2061 7265 2072 6571 7569 7265 642e es are required.\n+00065350: 0a20 2020 2020 2020 2022 2222 0a20 2020 . \"\"\". \n+00065360: 2020 2020 2072 6574 7572 6e20 656e 760a return env.\n+00065370: 0a0a 636c 6173 7320 5365 7373 696f 6e28 ..class Session(\n+00065380: 5375 6270 726f 6365 7373 436f 6e74 6578 SubprocessContex\n+00065390: 742c 2049 6e74 6572 6163 7469 6f6e 4861 t, InteractionHa\n+000653a0: 6e64 6c65 7229 3a0a 2020 2020 2320 5365 ndler):. # Se\n+000653b0: 7420 6166 7465 7220 2e63 6f6e 6e65 6374 t after .connect\n+000653c0: 2829 2063 616c 6c65 642c 2065 7665 6e20 () called, even \n+000653d0: 6966 2066 6169 6c65 640a 2020 2020 5f63 if failed. _c\n+000653e0: 6f6e 7472 6f6c 6469 723a 2027 7465 6d70 ontroldir: 'temp\n+000653f0: 6669 6c65 2e54 656d 706f 7261 7279 4469 file.TemporaryDi\n+00065400: 7265 6374 6f72 7920 7c20 4e6f 6e65 2720 rectory | None' \n+00065410: 3d20 4e6f 6e65 0a20 2020 205f 636f 6e74 = None. _cont\n+00065420: 726f 6c73 6f63 6b3a 2027 7374 7220 7c20 rolsock: 'str | \n+00065430: 4e6f 6e65 2720 3d20 4e6f 6e65 0a0a 2020 None' = None.. \n+00065440: 2020 2320 5365 7420 6966 2063 6f6e 6e65 # Set if conne\n+00065450: 6374 6564 2c20 656c 7365 204e 6f6e 650a cted, else None.\n+00065460: 2020 2020 5f70 726f 6365 7373 3a20 2761 _process: 'a\n+00065470: 7379 6e63 696f 2e73 7562 7072 6f63 6573 syncio.subproces\n+00065480: 732e 5072 6f63 6573 7320 7c20 4e6f 6e65 s.Process | None\n+00065490: 2720 3d20 4e6f 6e65 0a0a 2020 2020 6173 ' = None.. as\n+000654a0: 796e 6320 6465 6620 636f 6e6e 6563 7428 ync def connect(\n+000654b0: 7365 6c66 2c0a 2020 2020 2020 2020 2020 self,. \n+000654c0: 2020 2020 2020 2020 2020 2020 6465 7374 dest\n+000654d0: 696e 6174 696f 6e3a 2073 7472 2c0a 2020 ination: str,. \n+000654e0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000654f0: 2020 2020 6861 6e64 6c65 5f68 6f73 745f handle_host_\n+00065500: 6b65 793a 2062 6f6f 6c20 3d20 4661 6c73 key: bool = Fals\n+00065510: 652c 0a20 2020 2020 2020 2020 2020 2020 e,. \n+00065520: 2020 2020 2020 2020 2063 6f6e 6669 6766 configf\n+00065530: 696c 653a 2027 7374 7220 7c20 4e6f 6e65 ile: 'str | None\n+00065540: 2720 3d20 4e6f 6e65 2c0a 2020 2020 2020 ' = None,. \n+00065550: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00065560: 6964 656e 7469 7479 5f66 696c 653a 2027 identity_file: '\n+00065570: 7374 7220 7c20 4e6f 6e65 2720 3d20 4e6f str | None' = No\n+00065580: 6e65 2c0a 2020 2020 2020 2020 2020 2020 ne,. \n+00065590: 2020 2020 2020 2020 2020 6c6f 6769 6e5f login_\n+000655a0: 6e61 6d65 3a20 2773 7472 207c 204e 6f6e name: 'str | Non\n+000655b0: 6527 203d 204e 6f6e 652c 0a20 2020 2020 e' = None,. \n+000655c0: 2020 2020 2020 2020 2020 2020 2020 2020 \n+000655d0: 206f 7074 696f 6e73 3a20 274d 6170 7069 options: 'Mappi\n+000655e0: 6e67 5b73 7472 2c20 7374 725d 207c 204e ng[str, str] | N\n+000655f0: 6f6e 6527 203d 204e 6f6e 652c 0a20 2020 one' = None,. \n+00065600: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00065610: 2020 2070 6b63 7331 313a 2027 7374 7220 pkcs11: 'str \n+00065620: 7c20 4e6f 6e65 2720 3d20 4e6f 6e65 2c0a | None' = None,.\n+00065630: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00065640: 2020 2020 2020 706f 7274 3a20 2769 6e74 port: 'int\n+00065650: 207c 204e 6f6e 6527 203d 204e 6f6e 652c | None' = None,\n+00065660: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+00065670: 2020 2020 2020 2069 6e74 6572 6163 7469 interacti\n+00065680: 6f6e 5f72 6573 706f 6e64 6572 3a20 2749 on_responder: 'I\n+00065690: 6e74 6572 6163 7469 6f6e 4861 6e64 6c65 nteractionHandle\n+000656a0: 7220 7c20 4e6f 6e65 2720 3d20 4e6f 6e65 r | None' = None\n+000656b0: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n+000656c0: 2020 2072 756e 6469 7220 3d20 6f73 2e70 rundir = os.p\n+000656d0: 6174 682e 6a6f 696e 286f 732e 656e 7669 ath.join(os.envi\n+000656e0: 726f 6e2e 6765 7428 2758 4447 5f52 554e ron.get('XDG_RUN\n+000656f0: 5449 4d45 5f44 4952 272c 2027 2f72 756e TIME_DIR', '/run\n+00065700: 2729 2c20 2766 6572 6e79 2729 0a20 2020 '), 'ferny'). \n+00065710: 2020 2020 206f 732e 6d61 6b65 6469 7273 os.makedirs\n+00065720: 2872 756e 6469 722c 2065 7869 7374 5f6f (rundir, exist_o\n+00065730: 6b3d 5472 7565 290a 2020 2020 2020 2020 k=True). \n+00065740: 7365 6c66 2e5f 636f 6e74 726f 6c64 6972 self._controldir\n+00065750: 203d 2074 656d 7066 696c 652e 5465 6d70 = tempfile.Temp\n+00065760: 6f72 6172 7944 6972 6563 746f 7279 2864 oraryDirectory(d\n+00065770: 6972 3d72 756e 6469 7229 0a20 2020 2020 ir=rundir). \n+00065780: 2020 2073 656c 662e 5f63 6f6e 7472 6f6c self._control\n+00065790: 736f 636b 203d 2066 277b 7365 6c66 2e5f sock = f'{self._\n+000657a0: 636f 6e74 726f 6c64 6972 2e6e 616d 657d controldir.name}\n+000657b0: 2f73 6f63 6b65 7427 0a0a 2020 2020 2020 /socket'.. \n+000657c0: 2020 2320 496e 2067 656e 6572 616c 2c20 # In general, \n+000657d0: 7765 2063 616e 2774 2067 7561 7261 6e74 we can't guarant\n+000657e0: 6565 2061 6e20 6163 6365 7373 6962 6c65 ee an accessible\n+000657f0: 2061 6e64 2065 7865 6375 7461 626c 6520 and executable \n+00065800: 7665 7273 696f 6e0a 2020 2020 2020 2020 version. \n+00065810: 2320 6f66 2074 6869 7320 6669 6c65 2c20 # of this file, \n+00065820: 6275 7420 7369 6e63 6520 6974 2773 2073 but since it's s\n+00065830: 6d61 6c6c 2061 6e64 2077 6527 7265 206d mall and we're m\n+00065840: 616b 696e 6720 6120 7465 6d70 6f72 6172 aking a temporar\n+00065850: 790a 2020 2020 2020 2020 2320 6469 7265 y. # dire\n+00065860: 6374 6f72 7920 616e 7977 6179 2c20 6c65 ctory anyway, le\n+00065870: 7427 7320 6a75 7374 2063 6f70 7920 6974 t's just copy it\n+00065880: 2069 6e74 6f20 706c 6163 6520 616e 6420 into place and \n+00065890: 7573 6520 6974 2066 726f 6d0a 2020 2020 use it from. \n+000658a0: 2020 2020 2320 7468 6572 652e 0a20 2020 # there.. \n+000658b0: 2020 2020 2061 736b 7061 7373 5f70 6174 askpass_pat\n+000658c0: 6820 3d20 7772 6974 655f 6173 6b70 6173 h = write_askpas\n+000658d0: 735f 746f 5f74 6d70 6469 7228 7365 6c66 s_to_tmpdir(self\n+000658e0: 2e5f 636f 6e74 726f 6c64 6972 2e6e 616d ._controldir.nam\n+000658f0: 6529 0a0a 2020 2020 2020 2020 656e 7620 e).. env \n+00065900: 3d20 6469 6374 286f 732e 656e 7669 726f = dict(os.enviro\n+00065910: 6e29 0a20 2020 2020 2020 2065 6e76 5b27 n). env['\n+00065920: 5353 485f 4153 4b50 4153 5327 5d20 3d20 SSH_ASKPASS'] = \n+00065930: 6173 6b70 6173 735f 7061 7468 0a20 2020 askpass_path. \n+00065940: 2020 2020 2065 6e76 5b27 5353 485f 4153 env['SSH_AS\n+00065950: 4b50 4153 535f 5245 5155 4952 4527 5d20 KPASS_REQUIRE'] \n+00065960: 3d20 2766 6f72 6365 270a 2020 2020 2020 = 'force'. \n+00065970: 2020 2320 6f6c 6420 5353 4820 646f 6573 # old SSH does\n+00065980: 6e27 7420 756e 6465 7273 7461 6e64 2053 n't understand S\n+00065990: 5348 5f41 534b 5041 5353 5f52 4551 5549 SH_ASKPASS_REQUI\n+000659a0: 5245 2061 6e64 2067 7565 7373 6573 2062 RE and guesses b\n+000659b0: 6173 6564 206f 6e20 4449 5350 4c41 5920 ased on DISPLAY \n+000659c0: 696e 7374 6561 640a 2020 2020 2020 2020 instead. \n+000659d0: 656e 765b 2744 4953 504c 4159 275d 203d env['DISPLAY'] =\n+000659e0: 2027 2d27 0a0a 2020 2020 2020 2020 6172 '-'.. ar\n+000659f0: 6773 203d 205b 0a20 2020 2020 2020 2020 gs = [. \n+00065a00: 2020 2027 2d4d 272c 0a20 2020 2020 2020 '-M',. \n+00065a10: 2020 2020 2027 2d4e 272c 0a20 2020 2020 '-N',. \n+00065a20: 2020 2020 2020 2027 2d53 272c 2073 656c '-S', sel\n+00065a30: 662e 5f63 6f6e 7472 6f6c 736f 636b 2c0a f._controlsock,.\n+00065a40: 2020 2020 2020 2020 2020 2020 272d 6f27 '-o'\n+00065a50: 2c20 2750 6572 6d69 744c 6f63 616c 436f , 'PermitLocalCo\n+00065a60: 6d6d 616e 643d 7965 7327 2c0a 2020 2020 mmand=yes',. \n+00065a70: 2020 2020 2020 2020 272d 6f27 2c20 6627 '-o', f'\n+00065a80: 4c6f 6361 6c43 6f6d 6d61 6e64 3d7b 6173 LocalCommand={as\n+00065a90: 6b70 6173 735f 7061 7468 7d27 2c0a 2020 kpass_path}',. \n+00065aa0: 2020 2020 2020 5d0a 0a20 2020 2020 2020 ].. \n+00065ab0: 2069 6620 636f 6e66 6967 6669 6c65 2069 if configfile i\n+00065ac0: 7320 6e6f 7420 4e6f 6e65 3a0a 2020 2020 s not None:. \n+00065ad0: 2020 2020 2020 2020 6172 6773 2e61 7070 args.app\n+00065ae0: 656e 6428 6627 2d46 7b63 6f6e 6669 6766 end(f'-F{configf\n+00065af0: 696c 657d 2729 0a0a 2020 2020 2020 2020 ile}').. \n+00065b00: 6966 2069 6465 6e74 6974 795f 6669 6c65 if identity_file\n+00065b10: 2069 7320 6e6f 7420 4e6f 6e65 3a0a 2020 is not None:. \n+00065b20: 2020 2020 2020 2020 2020 6172 6773 2e61 args.a\n+00065b30: 7070 656e 6428 6627 2d69 7b69 6465 6e74 ppend(f'-i{ident\n+00065b40: 6974 795f 6669 6c65 7d27 290a 0a20 2020 ity_file}').. \n+00065b50: 2020 2020 2069 6620 6f70 7469 6f6e 7320 if options \n+00065b60: 6973 206e 6f74 204e 6f6e 653a 0a20 2020 is not None:. \n+00065b70: 2020 2020 2020 2020 2066 6f72 206b 6579 for key\n+00065b80: 2069 6e20 6f70 7469 6f6e 733a 2020 2320 in options: # \n+00065b90: 4e6f 7465 3a20 4d61 7070 696e 6720 6d61 Note: Mapping ma\n+00065ba0: 7920 6e6f 7420 6861 7665 202e 6974 656d y not have .item\n+00065bb0: 7328 290a 2020 2020 2020 2020 2020 2020 s(). \n+00065bc0: 2020 2020 6172 6773 2e61 7070 656e 6428 args.append(\n+00065bd0: 6627 2d6f 7b6b 6579 7d20 7b6f 7074 696f f'-o{key} {optio\n+00065be0: 6e73 5b6b 6579 5d7d 2729 0a0a 2020 2020 ns[key]}').. \n+00065bf0: 2020 2020 6966 2070 6b63 7331 3120 6973 if pkcs11 is\n+00065c00: 206e 6f74 204e 6f6e 653a 0a20 2020 2020 not None:. \n+00065c10: 2020 2020 2020 2061 7267 732e 6170 7065 args.appe\n+00065c20: 6e64 2866 272d 497b 706b 6373 3131 7d27 nd(f'-I{pkcs11}'\n+00065c30: 290a 0a20 2020 2020 2020 2069 6620 706f ).. if po\n+00065c40: 7274 2069 7320 6e6f 7420 4e6f 6e65 3a0a rt is not None:.\n+00065c50: 2020 2020 2020 2020 2020 2020 6172 6773 args\n+00065c60: 2e61 7070 656e 6428 6627 2d70 7b70 6f72 .append(f'-p{por\n+00065c70: 747d 2729 0a0a 2020 2020 2020 2020 6966 t}').. if\n+00065c80: 206c 6f67 696e 5f6e 616d 6520 6973 206e login_name is n\n+00065c90: 6f74 204e 6f6e 653a 0a20 2020 2020 2020 ot None:. \n+00065ca0: 2020 2020 2061 7267 732e 6170 7065 6e64 args.append\n+00065cb0: 2866 272d 6c7b 6c6f 6769 6e5f 6e61 6d65 (f'-l{login_name\n+00065cc0: 7d27 290a 0a20 2020 2020 2020 2069 6620 }').. if \n+00065cd0: 6861 6e64 6c65 5f68 6f73 745f 6b65 7920 handle_host_key \n+00065ce0: 616e 6420 6861 735f 6665 6174 7572 6528 and has_feature(\n+00065cf0: 274b 6e6f 776e 486f 7374 7343 6f6d 6d61 'KnownHostsComma\n+00065d00: 6e64 2729 3a0a 2020 2020 2020 2020 2020 nd'):. \n+00065d10: 2020 6172 6773 2e65 7874 656e 6428 5b0a args.extend([.\n+00065d20: 2020 2020 2020 2020 2020 2020 2020 2020 \n+00065d30: 272d 6f27 2c20 6627 4b6e 6f77 6e48 6f73 '-o', f'KnownHos\n+00065d40: 7473 436f 6d6d 616e 643d 7b61 736b 7061 tsCommand={askpa\n+00065d50: 7373 5f70 6174 687d 2025 4920 2548 2025 ss_path} %I %H %\n+00065d60: 7420 254b 2025 6627 2c0a 2020 2020 2020 t %K %f',. \n+00065d70: 2020 2020 2020 2020 2020 272d 6f27 2c20 '-o', \n+00065d80: 2753 7472 6963 7448 6f73 744b 6579 4368 'StrictHostKeyCh\n+00065d90: 6563 6b69 6e67 3d79 6573 272c 0a20 2020 ecking=yes',. \n+00065da0: 2020 2020 2020 2020 205d 290a 0a20 2020 ]).. \n+00065db0: 2020 2020 2061 6765 6e74 203d 2049 6e74 agent = Int\n+00065dc0: 6572 6163 7469 6f6e 4167 656e 7428 5b69 eractionAgent([i\n+00065dd0: 6e74 6572 6163 7469 6f6e 5f72 6573 706f nteraction_respo\n+00065de0: 6e64 6572 5d20 6966 2069 6e74 6572 6163 nder] if interac\n+00065df0: 7469 6f6e 5f72 6573 706f 6e64 6572 2069 tion_responder i\n+00065e00: 7320 6e6f 7420 4e6f 6e65 2065 6c73 6520 s not None else \n+00065e10: 5b5d 290a 0a20 2020 2020 2020 2023 2053 []).. # S\n+00065e20: 5348 5f41 534b 5041 5353 5f52 4551 5549 SH_ASKPASS_REQUI\n+00065e30: 5245 2069 7320 6e6f 7420 6765 6e65 7261 RE is not genera\n+00065e40: 6c6c 7920 6176 6169 6c61 626c 652c 2073 lly available, s\n+00065e50: 6f20 7573 6520 7365 7473 6964 0a20 2020 o use setsid. \n+00065e60: 2020 2020 2070 726f 6365 7373 203d 2061 process = a\n+00065e70: 7761 6974 2061 7379 6e63 696f 2e63 7265 wait asyncio.cre\n+00065e80: 6174 655f 7375 6270 726f 6365 7373 5f65 ate_subprocess_e\n+00065e90: 7865 6328 0a20 2020 2020 2020 2020 2020 xec(. \n+00065ea0: 202a 2827 2f75 7372 2f62 696e 2f73 7368 *('/usr/bin/ssh\n+00065eb0: 272c 202a 6172 6773 2c20 6465 7374 696e ', *args, destin\n+00065ec0: 6174 696f 6e29 2c20 656e 763d 656e 762c ation), env=env,\n+00065ed0: 0a20 2020 2020 2020 2020 2020 2073 7461 . sta\n+00065ee0: 7274 5f6e 6577 5f73 6573 7369 6f6e 3d54 rt_new_session=T\n+00065ef0: 7275 652c 2073 7464 696e 3d61 7379 6e63 rue, stdin=async\n+00065f00: 696f 2e73 7562 7072 6f63 6573 732e 4445 io.subprocess.DE\n+00065f10: 564e 554c 4c2c 0a20 2020 2020 2020 2020 VNULL,. \n+00065f20: 2020 2073 7464 6f75 743d 6173 796e 6369 stdout=asynci\n+00065f30: 6f2e 7375 6270 726f 6365 7373 2e44 4556 o.subprocess.DEV\n+00065f40: 4e55 4c4c 2c20 7374 6465 7272 3d61 6765 NULL, stderr=age\n+00065f50: 6e74 2c20 2023 2074 7970 653a 2069 676e nt, # type: ign\n+00065f60: 6f72 650a 2020 2020 2020 2020 2020 2020 ore. \n+00065f70: 7072 6565 7865 635f 666e 3d6c 616d 6264 preexec_fn=lambd\n+00065f80: 613a 2070 7263 746c 2850 525f 5345 545f a: prctl(PR_SET_\n+00065f90: 5044 4541 5448 5349 472c 2073 6967 6e61 PDEATHSIG, signa\n+00065fa0: 6c2e 5349 474b 494c 4c29 290a 0a20 2020 l.SIGKILL)).. \n+00065fb0: 2020 2020 2023 2054 6869 7320 6973 2074 # This is t\n+00065fc0: 7269 636b 793a 2077 6520 6e65 6564 2074 ricky: we need t\n+00065fd0: 6f20 636c 6561 6e20 7570 2074 6865 2073 o clean up the s\n+00065fe0: 7562 7072 6f63 6573 732c 2062 7574 206f ubprocess, but o\n+00065ff0: 6e6c 7920 696e 2063 6173 650a 2020 2020 nly in case. \n+00066000: 2020 2020 2320 6966 2066 6169 6c75 7265 # if failure\n+00066010: 2e20 204f 7468 6572 7769 7365 2c20 7765 . Otherwise, we\n+00066020: 206b 6565 7020 6974 2061 726f 756e 642e keep it around.\n+00066030: 0a20 2020 2020 2020 2074 7279 3a0a 2020 . try:. \n+00066040: 2020 2020 2020 2020 2020 6177 6169 7420 await \n+00066050: 6167 656e 742e 636f 6d6d 756e 6963 6174 agent.communicat\n+00066060: 6528 290a 2020 2020 2020 2020 2020 2020 e(). \n+00066070: 6173 7365 7274 206f 732e 7061 7468 2e65 assert os.path.e\n+00066080: 7869 7374 7328 7365 6c66 2e5f 636f 6e74 xists(self._cont\n+00066090: 726f 6c73 6f63 6b29 0a20 2020 2020 2020 rolsock). \n+000660a0: 2020 2020 2073 656c 662e 5f70 726f 6365 self._proce\n+000660b0: 7373 203d 2070 726f 6365 7373 0a20 2020 ss = process. \n+000660c0: 2020 2020 2065 7863 6570 7420 496e 7465 except Inte\n+000660d0: 7261 6374 696f 6e45 7272 6f72 2061 7320 ractionError as \n+000660e0: 6578 633a 0a20 2020 2020 2020 2020 2020 exc:. \n+000660f0: 2061 7761 6974 2070 726f 6365 7373 2e77 await process.w\n+00066100: 6169 7428 290a 2020 2020 2020 2020 2020 ait(). \n+00066110: 2020 7261 6973 6520 7373 685f 6572 726f raise ssh_erro\n+00066120: 7273 2e67 6574 5f65 7863 6570 7469 6f6e rs.get_exception\n+00066130: 5f66 6f72 5f73 7368 5f73 7464 6572 7228 _for_ssh_stderr(\n+00066140: 7374 7228 6578 6329 2920 6672 6f6d 204e str(exc)) from N\n+00066150: 6f6e 650a 2020 2020 2020 2020 6578 6365 one. exce\n+00066160: 7074 2042 6173 6545 7863 6570 7469 6f6e pt BaseException\n+00066170: 3a0a 2020 2020 2020 2020 2020 2020 2320 :. # \n+00066180: 4966 2077 6520 6765 7420 6865 7265 2062 If we get here b\n+00066190: 6563 6175 7365 2074 6865 2049 6e74 6572 ecause the Inter\n+000661a0: 6163 7469 6f6e 4861 6e64 6c65 7220 7261 actionHandler ra\n+000661b0: 6973 6564 2061 6e0a 2020 2020 2020 2020 ised an. \n+000661c0: 2020 2020 2320 6578 6365 7074 696f 6e20 # exception \n+000661d0: 7468 656e 2053 5348 206d 6967 6874 2073 then SSH might s\n+000661e0: 7469 6c6c 2062 6520 7275 6e6e 696e 672c till be running,\n+000661f0: 2061 6e64 206d 6179 2065 7665 6e20 6174 and may even at\n+00066200: 7465 6d70 740a 2020 2020 2020 2020 2020 tempt. \n+00066210: 2020 2320 6675 7274 6865 7220 696e 7465 # further inte\n+00066220: 7261 6374 696f 6e73 2028 6965 3a20 326e ractions (ie: 2n\n+00066230: 6420 6174 7465 6d70 7420 666f 7220 7061 d attempt for pa\n+00066240: 7373 776f 7264 292e 2020 5765 2061 6c72 ssword). We alr\n+00066250: 6561 6479 0a20 2020 2020 2020 2020 2020 eady. \n+00066260: 2023 2068 6176 6520 6f75 7220 6578 6365 # have our exce\n+00066270: 7074 696f 6e20 616e 6420 646f 6e27 7420 ption and don't \n+00066280: 6e65 6564 2061 6e79 206d 6f72 6520 696e need any more in\n+00066290: 666f 2e20 204b 696c 6c20 6974 2e0a 2020 fo. Kill it.. \n+000662a0: 2020 2020 2020 2020 2020 7472 793a 0a20 try:. \n+000662b0: 2020 2020 2020 2020 2020 2020 2020 2070 p\n+000662c0: 726f 6365 7373 2e6b 696c 6c28 290a 2020 rocess.kill(). \n+000662d0: 2020 2020 2020 2020 2020 6578 6365 7074 except\n+000662e0: 2050 726f 6365 7373 4c6f 6f6b 7570 4572 ProcessLookupEr\n+000662f0: 726f 723a 0a20 2020 2020 2020 2020 2020 ror:. \n+00066300: 2020 2020 2070 6173 7320 2023 2061 6c72 pass # alr\n+00066310: 6561 6479 2065 7869 7465 643f 2020 676f eady exited? go\n+00066320: 6f64 2e0a 2020 2020 2020 2020 2020 2020 od.. \n+00066330: 6177 6169 7420 7072 6f63 6573 732e 7761 await process.wa\n+00066340: 6974 2829 0a20 2020 2020 2020 2020 2020 it(). \n+00066350: 2072 6169 7365 0a0a 2020 2020 6465 6620 raise.. def \n+00066360: 6973 5f63 6f6e 6e65 6374 6564 2873 656c is_connected(sel\n+00066370: 6629 202d 3e20 626f 6f6c 3a0a 2020 2020 f) -> bool:. \n+00066380: 2020 2020 7265 7475 726e 2073 656c 662e return self.\n+00066390: 5f70 726f 6365 7373 2069 7320 6e6f 7420 _process is not \n+000663a0: 4e6f 6e65 0a0a 2020 2020 6173 796e 6320 None.. async \n+000663b0: 6465 6620 7761 6974 2873 656c 6629 202d def wait(self) -\n+000663c0: 3e20 4e6f 6e65 3a0a 2020 2020 2020 2020 > None:. \n+000663d0: 6173 7365 7274 2073 656c 662e 5f70 726f assert self._pro\n+000663e0: 6365 7373 2069 7320 6e6f 7420 4e6f 6e65 cess is not None\n+000663f0: 0a20 2020 2020 2020 2061 7761 6974 2073 . await s\n+00066400: 656c 662e 5f70 726f 6365 7373 2e77 6169 elf._process.wai\n+00066410: 7428 290a 0a20 2020 2064 6566 2065 7869 t().. def exi\n+00066420: 7428 7365 6c66 2920 2d3e 204e 6f6e 653a t(self) -> None:\n+00066430: 0a20 2020 2020 2020 2061 7373 6572 7420 . assert \n+00066440: 7365 6c66 2e5f 7072 6f63 6573 7320 6973 self._process is\n+00066450: 206e 6f74 204e 6f6e 650a 2020 2020 2020 not None. \n+00066460: 2020 7365 6c66 2e5f 7072 6f63 6573 732e self._process.\n+00066470: 7465 726d 696e 6174 6528 290a 0a20 2020 terminate().. \n+00066480: 2061 7379 6e63 2064 6566 2064 6973 636f async def disco\n+00066490: 6e6e 6563 7428 7365 6c66 2920 2d3e 204e nnect(self) -> N\n+000664a0: 6f6e 653a 0a20 2020 2020 2020 2073 656c one:. sel\n+000664b0: 662e 6578 6974 2829 0a20 2020 2020 2020 f.exit(). \n+000664c0: 2061 7761 6974 2073 656c 662e 7761 6974 await self.wait\n+000664d0: 2829 0a0a 2020 2020 2320 4c61 756e 6368 ().. # Launch\n+000664e0: 696e 6720 6f66 2070 726f 6365 7373 6573 ing of processes\n+000664f0: 0a20 2020 2064 6566 2077 7261 705f 7375 . def wrap_su\n+00066500: 6270 726f 6365 7373 5f61 7267 7328 7365 bprocess_args(se\n+00066510: 6c66 2c20 6172 6773 3a20 5365 7175 656e lf, args: Sequen\n+00066520: 6365 5b73 7472 5d29 202d 3e20 5365 7175 ce[str]) -> Sequ\n+00066530: 656e 6365 5b73 7472 5d3a 0a20 2020 2020 ence[str]:. \n+00066540: 2020 2061 7373 6572 7420 7365 6c66 2e5f assert self._\n+00066550: 636f 6e74 726f 6c73 6f63 6b20 6973 206e controlsock is n\n+00066560: 6f74 204e 6f6e 650a 2020 2020 2020 2020 ot None. \n+00066570: 2320 312e 2057 6520 7370 6563 6966 7920 # 1. We specify \n+00066580: 7468 6520 686f 7374 6e61 6d65 2061 7320 the hostname as \n+00066590: 7468 6520 656d 7074 7920 7374 7269 6e67 the empty string\n+000665a0: 3a20 6974 2077 696c 6c20 6265 2069 676e : it will be ign\n+000665b0: 6f72 6564 0a20 2020 2020 2020 2023 2020 ored. # \n+000665c0: 2020 7768 656e 2073 7368 2069 7320 7472 when ssh is tr\n+000665d0: 7969 6e67 2074 6f20 7573 6520 7468 6520 ying to use the \n+000665e0: 636f 6e74 726f 6c20 736f 636b 6574 2c20 control socket, \n+000665f0: 6275 7420 696e 2063 6173 6520 7468 650a but in case the.\n+00066600: 2020 2020 2020 2020 2320 2020 2073 6f63 # soc\n+00066610: 6b65 7420 6861 7320 7374 6f70 7065 6420 ket has stopped \n+00066620: 776f 726b 696e 672c 2073 7368 2077 696c working, ssh wil\n+00066630: 6c20 7472 7920 746f 2066 616c 6c20 6261 l try to fall ba\n+00066640: 636b 2074 6f20 6469 7265 6374 6c79 0a20 ck to directly. \n+00066650: 2020 2020 2020 2023 2020 2020 636f 6e6e # conn\n+00066660: 6563 7469 6e67 2c20 696e 2077 6869 6368 ecting, in which\n+00066670: 2063 6173 6520 616e 2065 6d70 7479 2068 case an empty h\n+00066680: 6f73 746e 616d 6520 7769 6c6c 2070 7265 ostname will pre\n+00066690: 7665 6e74 2074 6861 742e 0a20 2020 2020 vent that.. \n+000666a0: 2020 2023 2032 2e20 5765 206e 6565 6420 # 2. We need \n+000666b0: 746f 2071 756f 7465 2074 6865 2061 7267 to quote the arg\n+000666c0: 756d 656e 7473 20e2 8094 2073 7368 2077 uments ... ssh w\n+000666d0: 696c 6c20 7061 7374 6520 7468 656d 2074 ill paste them t\n+000666e0: 6f67 6574 6865 720a 2020 2020 2020 2020 ogether. \n+000666f0: 2320 2020 2075 7369 6e67 206f 6e6c 7920 # using only \n+00066700: 7370 6163 6573 2c20 6578 6563 7574 696e spaces, executin\n+00066710: 6720 7468 6520 7265 7375 6c74 2075 7369 g the result usi\n+00066720: 6e67 2074 6865 2075 7365 7227 7320 7368 ng the user's sh\n+00066730: 656c 6c2e 0a20 2020 2020 2020 2072 6574 ell.. ret\n+00066740: 7572 6e20 2827 7373 6827 2c20 272d 5327 urn ('ssh', '-S'\n+00066750: 2c20 7365 6c66 2e5f 636f 6e74 726f 6c73 , self._controls\n+00066760: 6f63 6b2c 2027 272c 202a 6d61 7028 7368 ock, '', *map(sh\n+00066770: 6c65 782e 7175 6f74 652c 2061 7267 7329 lex.quote, args)\n+00066780: 290a 2727 272e 656e 636f 6465 2827 7574 ).'''.encode('ut\n+00066790: 662d 3827 292c 0a20 2027 636f 636b 7069 f-8'),. 'cockpi\n+000667a0: 742f 5f76 656e 646f 722f 6665 726e 792f t/_vendor/ferny/\n+000667b0: 7373 685f 6173 6b70 6173 732e 7079 273a ssh_askpass.py':\n+000667c0: 2062 7227 2727 696d 706f 7274 206c 6f67 br'''import log\n+000667d0: 6769 6e67 0a69 6d70 6f72 7420 7265 0a66 ging.import re.f\n+000667e0: 726f 6d20 7479 7069 6e67 2069 6d70 6f72 rom typing impor\n+000667f0: 7420 436c 6173 7356 6172 2c20 4d61 7463 t ClassVar, Matc\n+00066800: 682c 2053 6571 7565 6e63 650a 0a66 726f h, Sequence..fro\n+00066810: 6d20 2e69 6e74 6572 6163 7469 6f6e 5f61 m .interaction_a\n+00066820: 6765 6e74 2069 6d70 6f72 7420 4173 6b70 gent import Askp\n+00066830: 6173 7348 616e 646c 6572 0a0a 6c6f 6767 assHandler..logg\n+00066840: 6572 203d 206c 6f67 6769 6e67 2e67 6574 er = logging.get\n+00066850: 4c6f 6767 6572 285f 5f6e 616d 655f 5f29 Logger(__name__)\n+00066860: 0a0a 0a63 6c61 7373 2041 736b 7061 7373 ...class Askpass\n+00066870: 5072 6f6d 7074 3a0a 2020 2020 2222 2241 Prompt:. \"\"\"A\n+00066880: 6e20 6173 6b70 6173 7320 7072 6f6d 7074 n askpass prompt\n+00066890: 2072 6573 756c 7469 6e67 2066 726f 6d20 resulting from \n+000668a0: 6120 6361 6c6c 2074 6f20 6665 726e 792d a call to ferny-\n+000668b0: 6173 6b70 6173 732e 0a0a 2020 2020 2020 askpass... \n+000668c0: 7374 6465 7272 3a20 7468 6520 636f 6e74 stderr: the cont\n+000668d0: 656e 7473 206f 6620 7374 6465 7272 2066 ents of stderr f\n+000668e0: 726f 6d20 6265 666f 7265 2066 6572 6e79 rom before ferny\n+000668f0: 2d61 736b 7061 7373 2077 6173 2063 616c -askpass was cal\n+00066900: 6c65 642e 0a20 2020 2020 2020 2020 2020 led.. \n+00066910: 2020 204c 696b 656c 7920 7265 6c61 7465 Likely relate\n+00066920: 6420 746f 2070 7265 7669 6f75 7320 6661 d to previous fa\n+00066930: 696c 6564 206f 7065 7261 7469 6f6e 732e iled operations.\n+00066940: 0a20 2020 2020 206d 6573 7361 6765 733a . messages:\n+00066950: 2061 6c6c 2062 7574 2074 6865 206c 6173 all but the las\n+00066960: 7420 6c69 6e65 206f 6620 7468 6520 7072 t line of the pr\n+00066970: 6f6d 7074 2061 7320 6861 6e64 6564 2074 ompt as handed t\n+00066980: 6f20 6665 726e 792d 6173 6b70 6173 732e o ferny-askpass.\n+00066990: 0a20 2020 2020 2020 2020 2020 2020 2020 . \n+000669a0: 2055 7375 616c 6c79 2063 6f6e 7461 696e Usually contain\n+000669b0: 7320 636f 6e74 6578 7420 6162 6f75 7420 s context about \n+000669c0: 7468 6520 7175 6573 7469 6f6e 2e0a 2020 the question.. \n+000669d0: 2020 2020 7072 6f6d 7074 3a20 7468 6520 prompt: the \n+000669e0: 6c61 7374 206c 696e 6520 6861 6e64 6564 last line handed\n+000669f0: 2074 6f20 6665 726e 792d 6173 6b70 6173 to ferny-askpas\n+00066a00: 732e 2020 5468 6520 7072 6f6d 7074 2069 s. The prompt i\n+00066a10: 7473 656c 662e 0a20 2020 2022 2222 0a20 tself.. \"\"\". \n+00066a20: 2020 2073 7464 6572 723a 2073 7472 0a20 stderr: str. \n+00066a30: 2020 206d 6573 7361 6765 733a 2073 7472 messages: str\n+00066a40: 0a20 2020 2070 726f 6d70 743a 2073 7472 . prompt: str\n+00066a50: 0a0a 2020 2020 6465 6620 5f5f 696e 6974 .. def __init\n+00066a60: 5f5f 2873 656c 662c 2070 726f 6d70 743a __(self, prompt:\n+00066a70: 2073 7472 2c20 6d65 7373 6167 6573 3a20 str, messages: \n+00066a80: 7374 722c 2073 7464 6572 723a 2073 7472 str, stderr: str\n+00066a90: 2920 2d3e 204e 6f6e 653a 0a20 2020 2020 ) -> None:. \n+00066aa0: 2020 2073 656c 662e 7374 6465 7272 203d self.stderr =\n+00066ab0: 2073 7464 6572 720a 2020 2020 2020 2020 stderr. \n+00066ac0: 7365 6c66 2e6d 6573 7361 6765 7320 3d20 self.messages = \n+00066ad0: 6d65 7373 6167 6573 0a20 2020 2020 2020 messages. \n+00066ae0: 2073 656c 662e 7072 6f6d 7074 203d 2070 self.prompt = p\n+00066af0: 726f 6d70 740a 0a20 2020 2064 6566 2072 rompt.. def r\n+00066b00: 6570 6c79 2873 656c 662c 2072 6573 706f eply(self, respo\n+00066b10: 6e73 653a 2073 7472 2920 2d3e 204e 6f6e nse: str) -> Non\n+00066b20: 653a 0a20 2020 2020 2020 2070 6173 730a e:. pass.\n+00066b30: 0a20 2020 2064 6566 2063 6c6f 7365 2873 . def close(s\n+00066b40: 656c 6629 202d 3e20 4e6f 6e65 3a0a 2020 elf) -> None:. \n+00066b50: 2020 2020 2020 7061 7373 0a0a 2020 2020 pass.. \n+00066b60: 6173 796e 6320 6465 6620 6861 6e64 6c65 async def handle\n+00066b70: 5f76 6961 2873 656c 662c 2072 6573 706f _via(self, respo\n+00066b80: 6e64 6572 3a20 2753 7368 4173 6b70 6173 nder: 'SshAskpas\n+00066b90: 7352 6573 706f 6e64 6572 2729 202d 3e20 sResponder') -> \n+00066ba0: 4e6f 6e65 3a0a 2020 2020 2020 2020 7472 None:. tr\n+00066bb0: 793a 0a20 2020 2020 2020 2020 2020 2072 y:. r\n+00066bc0: 6573 706f 6e73 6520 3d20 6177 6169 7420 esponse = await \n+00066bd0: 7365 6c66 2e64 6973 7061 7463 6828 7265 self.dispatch(re\n+00066be0: 7370 6f6e 6465 7229 0a20 2020 2020 2020 sponder). \n+00066bf0: 2020 2020 2069 6620 7265 7370 6f6e 7365 if response\n+00066c00: 2069 7320 6e6f 7420 4e6f 6e65 3a0a 2020 is not None:. \n+00066c10: 2020 2020 2020 2020 2020 2020 2020 7365 se\n+00066c20: 6c66 2e72 6570 6c79 2872 6573 706f 6e73 lf.reply(respons\n+00066c30: 6529 0a20 2020 2020 2020 2066 696e 616c e). final\n+00066c40: 6c79 3a0a 2020 2020 2020 2020 2020 2020 ly:. \n+00066c50: 7365 6c66 2e63 6c6f 7365 2829 0a0a 2020 self.close().. \n+00066c60: 2020 6173 796e 6320 6465 6620 6469 7370 async def disp\n+00066c70: 6174 6368 2873 656c 662c 2072 6573 706f atch(self, respo\n+00066c80: 6e64 6572 3a20 2753 7368 4173 6b70 6173 nder: 'SshAskpas\n+00066c90: 7352 6573 706f 6e64 6572 2729 202d 3e20 sResponder') -> \n+00066ca0: 2773 7472 207c 204e 6f6e 6527 3a0a 2020 'str | None':. \n+00066cb0: 2020 2020 2020 7265 7475 726e 2061 7761 return awa\n+00066cc0: 6974 2072 6573 706f 6e64 6572 2e64 6f5f it responder.do_\n+00066cd0: 7072 6f6d 7074 2873 656c 6629 0a0a 0a63 prompt(self)...c\n+00066ce0: 6c61 7373 2053 5348 4173 6b70 6173 7350 lass SSHAskpassP\n+00066cf0: 726f 6d70 7428 4173 6b70 6173 7350 726f rompt(AskpassPro\n+00066d00: 6d70 7429 3a0a 2020 2020 2320 5468 6520 mpt):. # The \n+00066d10: 7661 6c69 6420 616e 7377 6572 7320 746f valid answers to\n+00066d20: 2070 726f 6d70 7473 206f 6620 7468 6973 prompts of this\n+00066d30: 2074 7970 652e 2020 4966 2074 6869 7320 type. If this \n+00066d40: 6973 204e 6f6e 6520 7468 656e 2061 6e79 is None then any\n+00066d50: 0a20 2020 2023 2061 6e73 7765 7220 6973 . # answer is\n+00066d60: 2070 6572 6d69 7474 6564 2e20 2049 6620 permitted. If \n+00066d70: 6974 2773 2061 2073 6571 7565 6e63 6520 it's a sequence \n+00066d80: 7468 656e 206f 6e6c 7920 616e 7377 6572 then only answer\n+00066d90: 7320 6672 6f6d 2074 6865 0a20 2020 2023 s from the. #\n+00066da0: 2073 6571 7565 6e63 6520 6172 6520 7065 sequence are pe\n+00066db0: 726d 6974 7465 642e 2020 4966 2069 7427 rmitted. If it'\n+00066dc0: 7320 616e 2065 6d70 7479 2073 6571 7565 s an empty seque\n+00066dd0: 6e63 652c 2074 6865 6e20 6e6f 2061 6e73 nce, then no ans\n+00066de0: 7765 7220 6973 0a20 2020 2023 2070 6572 wer is. # per\n+00066df0: 6d69 7474 6564 2028 6965 3a20 7468 6520 mitted (ie: the \n+00066e00: 6173 6b70 6173 7320 6361 6c6c 6261 636b askpass callback\n+00066e10: 2073 686f 756c 6420 6e65 7665 7220 7265 should never re\n+00066e20: 7475 726e 292e 0a20 2020 2061 6e73 7765 turn).. answe\n+00066e30: 7273 3a20 2743 6c61 7373 5661 725b 5365 rs: 'ClassVar[Se\n+00066e40: 7175 656e 6365 5b73 7472 5d20 7c20 4e6f quence[str] | No\n+00066e50: 6e65 5d27 203d 204e 6f6e 650a 0a20 2020 ne]' = None.. \n+00066e60: 2023 2050 6174 7465 726e 7320 746f 2063 # Patterns to c\n+00066e70: 6170 7475 7265 2e20 2060 5f70 6174 7465 apture. `_patte\n+00066e80: 726e 6020 2a6d 7573 742a 206d 6174 6368 rn` *must* match\n+00066e90: 2e0a 2020 2020 5f70 6174 7465 726e 3a20 .. _pattern: \n+00066ea0: 436c 6173 7356 6172 5b73 7472 5d0a 2020 ClassVar[str]. \n+00066eb0: 2020 2320 605f 6578 7472 615f 7061 7474 # `_extra_patt\n+00066ec0: 6572 6e73 6020 6361 6e20 6669 6c6c 2069 erns` can fill i\n+00066ed0: 6e20 6578 7472 6120 636c 6173 7320 6174 n extra class at\n+00066ee0: 7472 6962 7574 6573 2069 6620 7468 6579 tributes if they\n+00066ef0: 206d 6174 6368 2e0a 2020 2020 5f65 7874 match.. _ext\n+00066f00: 7261 5f70 6174 7465 726e 733a 2043 6c61 ra_patterns: Cla\n+00066f10: 7373 5661 725b 5365 7175 656e 6365 5b73 ssVar[Sequence[s\n+00066f20: 7472 5d5d 203d 2028 290a 0a20 2020 2064 tr]] = ().. d\n+00066f30: 6566 205f 5f69 6e69 745f 5f28 7365 6c66 ef __init__(self\n+00066f40: 2c20 7072 6f6d 7074 3a20 7374 722c 206d , prompt: str, m\n+00066f50: 6573 7361 6765 733a 2073 7472 2c20 7374 essages: str, st\n+00066f60: 6465 7272 3a20 7374 722c 206d 6174 6368 derr: str, match\n+00066f70: 3a20 4d61 7463 6829 202d 3e20 4e6f 6e65 : Match) -> None\n+00066f80: 3a0a 2020 2020 2020 2020 7375 7065 7228 :. super(\n+00066f90: 292e 5f5f 696e 6974 5f5f 2870 726f 6d70 ).__init__(promp\n+00066fa0: 742c 206d 6573 7361 6765 732c 2073 7464 t, messages, std\n+00066fb0: 6572 7229 0a20 2020 2020 2020 2073 656c err). sel\n+00066fc0: 662e 5f5f 6469 6374 5f5f 2e75 7064 6174 f.__dict__.updat\n+00066fd0: 6528 6d61 7463 682e 6772 6f75 7064 6963 e(match.groupdic\n+00066fe0: 7428 2929 0a0a 2020 2020 2020 2020 666f t()).. fo\n+00066ff0: 7220 7061 7474 6572 6e20 696e 2073 656c r pattern in sel\n+00067000: 662e 5f65 7874 7261 5f70 6174 7465 726e f._extra_pattern\n+00067010: 733a 0a20 2020 2020 2020 2020 2020 2065 s:. e\n+00067020: 7874 7261 5f6d 6174 6368 203d 2072 652e xtra_match = re.\n+00067030: 7365 6172 6368 2877 6974 685f 6865 6c70 search(with_help\n+00067040: 6572 7328 7061 7474 6572 6e29 2c20 6d65 ers(pattern), me\n+00067050: 7373 6167 6573 2c20 7265 2e4d 290a 2020 ssages, re.M). \n+00067060: 2020 2020 2020 2020 2020 6966 2065 7874 if ext\n+00067070: 7261 5f6d 6174 6368 2069 7320 6e6f 7420 ra_match is not \n+00067080: 4e6f 6e65 3a0a 2020 2020 2020 2020 2020 None:. \n+00067090: 2020 2020 2020 7365 6c66 2e5f 5f64 6963 self.__dic\n+000670a0: 745f 5f2e 7570 6461 7465 2865 7874 7261 t__.update(extra\n+000670b0: 5f6d 6174 6368 2e67 726f 7570 6469 6374 _match.groupdict\n+000670c0: 2829 290a 0a0a 2320 5370 6563 6966 6963 ())...# Specific\n+000670d0: 2070 726f 6d70 7473 0a48 454c 5045 5253 prompts.HELPERS\n+000670e0: 203d 207b 0a20 2020 2022 257b 616c 676f = {. \"%{algo\n+000670f0: 7269 7468 6d7d 223a 2072 2228 3f50 3c61 rithm}\": r\"(?P\\b[-\\w]\n+00067110: 2b5c 6229 222c 0a20 2020 2022 257b 6669 +\\b)\",. \"%{fi\n+00067120: 6c65 6e61 6d65 7d22 3a20 7222 283f 503c lename}\": r\"(?P<\n+00067130: 6669 6c65 6e61 6d65 3e2e 2b29 222c 0a20 filename>.+)\",. \n+00067140: 2020 2022 257b 6669 6e67 6572 7072 696e \"%{fingerprin\n+00067150: 747d 223a 2072 2228 3f50 3c66 696e 6765 t}\": r\"(?PSHA256:[0\n+00067170: 2d39 412d 5a61 2d7a 2b2f 5d7b 3433 7d29 -9A-Za-z+/]{43})\n+00067180: 222c 0a20 2020 2022 257b 686f 7374 6e61 \",. \"%{hostna\n+00067190: 6d65 7d22 3a20 7222 283f 503c 686f 7374 me}\": r\"(?P[^ @']+)\",.\n+000671b0: 2020 2020 2225 7b70 6b63 7331 315f 6964 \"%{pkcs11_id\n+000671c0: 7d22 3a20 7222 283f 503c 706b 6373 3131 }\": r\"(?P.+)\",. \"%\n+000671e0: 7b75 7365 726e 616d 657d 223a 2072 2228 {username}\": r\"(\n+000671f0: 3f50 3c75 7365 726e 616d 653e 5b5e 2040 ?P[^ @\n+00067200: 275d 2b29 222c 0a7d 0a0a 0a63 6c61 7373 ']+)\",.}...class\n+00067210: 2053 7368 5061 7373 776f 7264 5072 6f6d SshPasswordProm\n+00067220: 7074 2853 5348 4173 6b70 6173 7350 726f pt(SSHAskpassPro\n+00067230: 6d70 7429 3a0a 2020 2020 5f70 6174 7465 mpt):. _patte\n+00067240: 726e 203d 2072 2225 7b75 7365 726e 616d rn = r\"%{usernam\n+00067250: 657d 4025 7b68 6f73 746e 616d 657d 2773 e}@%{hostname}'s\n+00067260: 2070 6173 7377 6f72 643a 2022 0a20 2020 password: \". \n+00067270: 2075 7365 726e 616d 653a 2027 7374 7220 username: 'str \n+00067280: 7c20 4e6f 6e65 2720 3d20 4e6f 6e65 0a20 | None' = None. \n+00067290: 2020 2068 6f73 746e 616d 653a 2027 7374 hostname: 'st\n+000672a0: 7220 7c20 4e6f 6e65 2720 3d20 4e6f 6e65 r | None' = None\n+000672b0: 0a0a 2020 2020 6173 796e 6320 6465 6620 .. async def \n+000672c0: 6469 7370 6174 6368 2873 656c 662c 2072 dispatch(self, r\n+000672d0: 6573 706f 6e64 6572 3a20 2753 7368 4173 esponder: 'SshAs\n+000672e0: 6b70 6173 7352 6573 706f 6e64 6572 2729 kpassResponder')\n+000672f0: 202d 3e20 2773 7472 207c 204e 6f6e 6527 -> 'str | None'\n+00067300: 3a0a 2020 2020 2020 2020 7265 7475 726e :. return\n+00067310: 2061 7761 6974 2072 6573 706f 6e64 6572 await responder\n+00067320: 2e64 6f5f 7061 7373 776f 7264 5f70 726f .do_password_pro\n+00067330: 6d70 7428 7365 6c66 290a 0a0a 636c 6173 mpt(self)...clas\n+00067340: 7320 5373 6850 6173 7370 6872 6173 6550 s SshPassphraseP\n+00067350: 726f 6d70 7428 5353 4841 736b 7061 7373 rompt(SSHAskpass\n+00067360: 5072 6f6d 7074 293a 0a20 2020 205f 7061 Prompt):. _pa\n+00067370: 7474 6572 6e20 3d20 7222 456e 7465 7220 ttern = r\"Enter \n+00067380: 7061 7373 7068 7261 7365 2066 6f72 206b passphrase for k\n+00067390: 6579 2027 257b 6669 6c65 6e61 6d65 7d27 ey '%{filename}'\n+000673a0: 3a20 220a 2020 2020 6669 6c65 6e61 6d65 : \". filename\n+000673b0: 3a20 7374 720a 0a20 2020 2061 7379 6e63 : str.. async\n+000673c0: 2064 6566 2064 6973 7061 7463 6828 7365 def dispatch(se\n+000673d0: 6c66 2c20 7265 7370 6f6e 6465 723a 2027 lf, responder: '\n+000673e0: 5373 6841 736b 7061 7373 5265 7370 6f6e SshAskpassRespon\n+000673f0: 6465 7227 2920 2d3e 2027 7374 7220 7c20 der') -> 'str | \n+00067400: 4e6f 6e65 273a 0a20 2020 2020 2020 2072 None':. r\n+00067410: 6574 7572 6e20 6177 6169 7420 7265 7370 eturn await resp\n+00067420: 6f6e 6465 722e 646f 5f70 6173 7370 6872 onder.do_passphr\n+00067430: 6173 655f 7072 6f6d 7074 2873 656c 6629 ase_prompt(self)\n+00067440: 0a0a 0a63 6c61 7373 2053 7368 4649 444f ...class SshFIDO\n+00067450: 5049 4e50 726f 6d70 7428 5353 4841 736b PINPrompt(SSHAsk\n+00067460: 7061 7373 5072 6f6d 7074 293a 0a20 2020 passPrompt):. \n+00067470: 205f 7061 7474 6572 6e20 3d20 7222 456e _pattern = r\"En\n+00067480: 7465 7220 5049 4e20 666f 7220 257b 616c ter PIN for %{al\n+00067490: 676f 7269 7468 6d7d 206b 6579 2025 7b66 gorithm} key %{f\n+000674a0: 696c 656e 616d 657d 3a20 220a 2020 2020 ilename}: \". \n+000674b0: 616c 676f 7269 7468 6d3a 2073 7472 0a20 algorithm: str. \n+000674c0: 2020 2066 696c 656e 616d 653a 2073 7472 filename: str\n+000674d0: 0a0a 2020 2020 6173 796e 6320 6465 6620 .. async def \n+000674e0: 6469 7370 6174 6368 2873 656c 662c 2072 dispatch(self, r\n+000674f0: 6573 706f 6e64 6572 3a20 2753 7368 4173 esponder: 'SshAs\n+00067500: 6b70 6173 7352 6573 706f 6e64 6572 2729 kpassResponder')\n+00067510: 202d 3e20 2773 7472 2020 7c20 4e6f 6e65 -> 'str | None\n+00067520: 273a 0a20 2020 2020 2020 2072 6574 7572 ':. retur\n+00067530: 6e20 6177 6169 7420 7265 7370 6f6e 6465 n await responde\n+00067540: 722e 646f 5f66 6964 6f5f 7069 6e5f 7072 r.do_fido_pin_pr\n+00067550: 6f6d 7074 2873 656c 6629 0a0a 0a63 6c61 ompt(self)...cla\n+00067560: 7373 2053 7368 4649 444f 5573 6572 5072 ss SshFIDOUserPr\n+00067570: 6573 656e 6365 5072 6f6d 7074 2853 5348 esencePrompt(SSH\n+00067580: 4173 6b70 6173 7350 726f 6d70 7429 3a0a AskpassPrompt):.\n+00067590: 2020 2020 5f70 6174 7465 726e 203d 2072 _pattern = r\n+000675a0: 2243 6f6e 6669 726d 2075 7365 7220 7072 \"Confirm user pr\n+000675b0: 6573 656e 6365 2066 6f72 206b 6579 2025 esence for key %\n+000675c0: 7b61 6c67 6f72 6974 686d 7d20 257b 6669 {algorithm} %{fi\n+000675d0: 6e67 6572 7072 696e 747d 220a 2020 2020 ngerprint}\". \n+000675e0: 616e 7377 6572 7320 3d20 2829 0a20 2020 answers = (). \n+000675f0: 2061 6c67 6f72 6974 686d 3a20 7374 720a algorithm: str.\n+00067600: 2020 2020 6669 6e67 6572 7072 696e 743a fingerprint:\n+00067610: 2073 7472 0a0a 2020 2020 6173 796e 6320 str.. async \n+00067620: 6465 6620 6469 7370 6174 6368 2873 656c def dispatch(sel\n+00067630: 662c 2072 6573 706f 6e64 6572 3a20 2753 f, responder: 'S\n+00067640: 7368 4173 6b70 6173 7352 6573 706f 6e64 shAskpassRespond\n+00067650: 6572 2729 202d 3e20 2773 7472 207c 204e er') -> 'str | N\n+00067660: 6f6e 6527 3a0a 2020 2020 2020 2020 7265 one':. re\n+00067670: 7475 726e 2061 7761 6974 2072 6573 706f turn await respo\n+00067680: 6e64 6572 2e64 6f5f 6669 646f 5f75 7365 nder.do_fido_use\n+00067690: 725f 7072 6573 656e 6365 5f70 726f 6d70 r_presence_promp\n+000676a0: 7428 7365 6c66 290a 0a0a 636c 6173 7320 t(self)...class \n+000676b0: 5373 6850 4b43 5331 3150 494e 5072 6f6d SshPKCS11PINProm\n+000676c0: 7074 2853 5348 4173 6b70 6173 7350 726f pt(SSHAskpassPro\n+000676d0: 6d70 7429 3a0a 2020 2020 5f70 6174 7465 mpt):. _patte\n+000676e0: 726e 203d 2072 2245 6e74 6572 2050 494e rn = r\"Enter PIN\n+000676f0: 2066 6f72 2027 257b 706b 6373 3131 5f69 for '%{pkcs11_i\n+00067700: 647d 273a 2022 0a20 2020 2070 6b63 7331 d}': \". pkcs1\n+00067710: 315f 6964 3a20 7374 720a 0a20 2020 2061 1_id: str.. a\n+00067720: 7379 6e63 2064 6566 2064 6973 7061 7463 sync def dispatc\n+00067730: 6828 7365 6c66 2c20 7265 7370 6f6e 6465 h(self, responde\n+00067740: 723a 2027 5373 6841 736b 7061 7373 5265 r: 'SshAskpassRe\n+00067750: 7370 6f6e 6465 7227 2920 2d3e 2027 7374 sponder') -> 'st\n+00067760: 7220 7c20 4e6f 6e65 273a 0a20 2020 2020 r | None':. \n+00067770: 2020 2072 6574 7572 6e20 6177 6169 7420 return await \n+00067780: 7265 7370 6f6e 6465 722e 646f 5f70 6b63 responder.do_pkc\n+00067790: 7331 315f 7069 6e5f 7072 6f6d 7074 2873 s11_pin_prompt(s\n+000677a0: 656c 6629 0a0a 0a63 6c61 7373 2053 7368 elf)...class Ssh\n+000677b0: 486f 7374 4b65 7950 726f 6d70 7428 5353 HostKeyPrompt(SS\n+000677c0: 4841 736b 7061 7373 5072 6f6d 7074 293a HAskpassPrompt):\n+000677d0: 0a20 2020 205f 7061 7474 6572 6e20 3d20 . _pattern = \n+000677e0: 7222 4172 6520 796f 7520 7375 7265 2079 r\"Are you sure y\n+000677f0: 6f75 2077 616e 7420 746f 2063 6f6e 7469 ou want to conti\n+00067800: 6e75 6520 636f 6e6e 6563 7469 6e67 205c nue connecting \\\n+00067810: 2879 6573 2f6e 6f28 2f5c 5b66 696e 6765 (yes/no(/\\[finge\n+00067820: 7270 7269 6e74 5c5d 293f 5c29 5c3f 2022 rprint\\])?\\)\\? \"\n+00067830: 0a20 2020 205f 6578 7472 615f 7061 7474 . _extra_patt\n+00067840: 6572 6e73 203d 205b 0a20 2020 2020 2020 erns = [. \n+00067850: 2072 2225 7b66 696e 6765 7270 7269 6e74 r\"%{fingerprint\n+00067860: 7d5b 2e5d 2422 2c0a 2020 2020 2020 2020 }[.]$\",. \n+00067870: 7222 5e25 7b61 6c67 6f72 6974 686d 7d20 r\"^%{algorithm} \n+00067880: 6b65 7920 6669 6e67 6572 7072 696e 7420 key fingerprint \n+00067890: 6973 222c 0a20 2020 2020 2020 2072 225e is\",. r\"^\n+000678a0: 5468 6520 6669 6e67 6572 7072 696e 7420 The fingerprint \n+000678b0: 666f 7220 7468 6520 257b 616c 676f 7269 for the %{algori\n+000678c0: 7468 6d7d 206b 6579 2073 656e 7420 6279 thm} key sent by\n+000678d0: 2074 6865 2072 656d 6f74 6520 686f 7374 the remote host\n+000678e0: 2069 7324 220a 2020 2020 5d0a 2020 2020 is$\". ]. \n+000678f0: 616e 7377 6572 7320 3d20 2827 7965 7327 answers = ('yes'\n+00067900: 2c20 276e 6f27 290a 2020 2020 616c 676f , 'no'). algo\n+00067910: 7269 7468 6d3a 2073 7472 0a20 2020 2066 rithm: str. f\n+00067920: 696e 6765 7270 7269 6e74 3a20 7374 720a ingerprint: str.\n+00067930: 0a20 2020 2061 7379 6e63 2064 6566 2064 . async def d\n+00067940: 6973 7061 7463 6828 7365 6c66 2c20 7265 ispatch(self, re\n+00067950: 7370 6f6e 6465 723a 2027 5373 6841 736b sponder: 'SshAsk\n+00067960: 7061 7373 5265 7370 6f6e 6465 7227 2920 passResponder') \n+00067970: 2d3e 2027 7374 7220 7c20 4e6f 6e65 273a -> 'str | None':\n+00067980: 0a20 2020 2020 2020 2072 6574 7572 6e20 . return \n+00067990: 6177 6169 7420 7265 7370 6f6e 6465 722e await responder.\n+000679a0: 646f 5f68 6f73 745f 6b65 795f 7072 6f6d do_host_key_prom\n+000679b0: 7074 2873 656c 6629 0a0a 0a64 6566 2077 pt(self)...def w\n+000679c0: 6974 685f 6865 6c70 6572 7328 7061 7474 ith_helpers(patt\n+000679d0: 6572 6e3a 2073 7472 2920 2d3e 2073 7472 ern: str) -> str\n+000679e0: 3a0a 2020 2020 666f 7220 6e61 6d65 2c20 :. for name, \n+000679f0: 6865 6c70 6572 2069 6e20 4845 4c50 4552 helper in HELPER\n+00067a00: 532e 6974 656d 7328 293a 0a20 2020 2020 S.items():. \n+00067a10: 2020 2070 6174 7465 726e 203d 2070 6174 pattern = pat\n+00067a20: 7465 726e 2e72 6570 6c61 6365 286e 616d tern.replace(nam\n+00067a30: 652c 2068 656c 7065 7229 0a0a 2020 2020 e, helper).. \n+00067a40: 6173 7365 7274 2027 257b 2720 6e6f 7420 assert '%{' not \n+00067a50: 696e 2070 6174 7465 726e 0a20 2020 2072 in pattern. r\n+00067a60: 6574 7572 6e20 7061 7474 6572 6e0a 0a0a eturn pattern...\n+00067a70: 6465 6620 6361 7465 676f 7269 7a65 5f73 def categorize_s\n+00067a80: 7368 5f70 726f 6d70 7428 7374 7269 6e67 sh_prompt(string\n+00067a90: 3a20 7374 722c 2073 7464 6572 723a 2073 : str, stderr: s\n+00067aa0: 7472 2920 2d3e 2041 736b 7061 7373 5072 tr) -> AskpassPr\n+00067ab0: 6f6d 7074 3a0a 2020 2020 636c 6173 7365 ompt:. classe\n+00067ac0: 7320 3d20 5b0a 2020 2020 2020 2020 5373 s = [. Ss\n+00067ad0: 6846 4944 4f50 494e 5072 6f6d 7074 2c0a hFIDOPINPrompt,.\n+00067ae0: 2020 2020 2020 2020 5373 6846 4944 4f55 SshFIDOU\n+00067af0: 7365 7250 7265 7365 6e63 6550 726f 6d70 serPresencePromp\n+00067b00: 742c 0a20 2020 2020 2020 2053 7368 486f t,. SshHo\n+00067b10: 7374 4b65 7950 726f 6d70 742c 0a20 2020 stKeyPrompt,. \n+00067b20: 2020 2020 2053 7368 504b 4353 3131 5049 SshPKCS11PI\n+00067b30: 4e50 726f 6d70 742c 0a20 2020 2020 2020 NPrompt,. \n+00067b40: 2053 7368 5061 7373 7068 7261 7365 5072 SshPassphrasePr\n+00067b50: 6f6d 7074 2c0a 2020 2020 2020 2020 5373 ompt,. Ss\n+00067b60: 6850 6173 7377 6f72 6450 726f 6d70 742c hPasswordPrompt,\n+00067b70: 0a20 2020 205d 0a0a 2020 2020 2320 5468 . ].. # Th\n+00067b80: 6520 6c61 7374 206c 696e 6520 6973 2074 e last line is t\n+00067b90: 6865 206c 696e 6520 6166 7465 7220 7468 he line after th\n+00067ba0: 6520 6c61 7374 206e 6577 6c69 6e65 2063 e last newline c\n+00067bb0: 6861 7261 6374 6572 2c20 6578 636c 7564 haracter, exclud\n+00067bc0: 696e 6720 7468 650a 2020 2020 2320 6f70 ing the. # op\n+00067bd0: 7469 6f6e 616c 2066 696e 616c 206e 6577 tional final new\n+00067be0: 6c69 6e65 2063 6861 7261 6374 6572 2e20 line character. \n+00067bf0: 2065 673a 2022 785c 6e79 5c6e 4c41 5354 eg: \"x\\ny\\nLAST\n+00067c00: 5c6e 2220 6f72 2022 785c 6e79 5c6e 4c41 \\n\" or \"x\\ny\\nLA\n+00067c10: 5354 220a 2020 2020 7365 636f 6e64 5f6c ST\". second_l\n+00067c20: 6173 745f 6e65 776c 696e 6520 3d20 7374 ast_newline = st\n+00067c30: 7269 6e67 2e72 6669 6e64 2827 5c6e 272c ring.rfind('\\n',\n+00067c40: 2030 2c20 2d31 290a 2020 2020 6966 2073 0, -1). if s\n+00067c50: 6563 6f6e 645f 6c61 7374 5f6e 6577 6c69 econd_last_newli\n+00067c60: 6e65 203e 3d20 303a 0a20 2020 2020 2020 ne >= 0:. \n+00067c70: 206c 6173 745f 6c69 6e65 203d 2073 7472 last_line = str\n+00067c80: 696e 675b 7365 636f 6e64 5f6c 6173 745f ing[second_last_\n+00067c90: 6e65 776c 696e 6520 2b20 313a 5d0a 2020 newline + 1:]. \n+00067ca0: 2020 2020 2020 6578 7472 6173 203d 2073 extras = s\n+00067cb0: 7472 696e 675b 3a73 6563 6f6e 645f 6c61 tring[:second_la\n+00067cc0: 7374 5f6e 6577 6c69 6e65 202b 2031 5d0a st_newline + 1].\n+00067cd0: 2020 2020 656c 7365 3a0a 2020 2020 2020 else:. \n+00067ce0: 2020 6c61 7374 5f6c 696e 6520 3d20 7374 last_line = st\n+00067cf0: 7269 6e67 0a20 2020 2020 2020 2065 7874 ring. ext\n+00067d00: 7261 7320 3d20 2727 0a0a 2020 2020 666f ras = ''.. fo\n+00067d10: 7220 636c 7320 696e 2063 6c61 7373 6573 r cls in classes\n+00067d20: 3a0a 2020 2020 2020 2020 7061 7474 6572 :. patter\n+00067d30: 6e20 3d20 7769 7468 5f68 656c 7065 7273 n = with_helpers\n+00067d40: 2863 6c73 2e5f 7061 7474 6572 6e29 0a20 (cls._pattern). \n+00067d50: 2020 2020 2020 206d 6174 6368 203d 2072 match = r\n+00067d60: 652e 6675 6c6c 6d61 7463 6828 7061 7474 e.fullmatch(patt\n+00067d70: 6572 6e2c 206c 6173 745f 6c69 6e65 290a ern, last_line).\n+00067d80: 2020 2020 2020 2020 6966 206d 6174 6368 if match\n+00067d90: 2069 7320 6e6f 7420 4e6f 6e65 3a0a 2020 is not None:. \n+00067da0: 2020 2020 2020 2020 2020 7265 7475 726e return\n+00067db0: 2063 6c73 286c 6173 745f 6c69 6e65 2c20 cls(last_line, \n+00067dc0: 6578 7472 6173 2c20 7374 6465 7272 2c20 extras, stderr, \n+00067dd0: 6d61 7463 6829 0a0a 2020 2020 7265 7475 match).. retu\n+00067de0: 726e 2041 736b 7061 7373 5072 6f6d 7074 rn AskpassPrompt\n+00067df0: 286c 6173 745f 6c69 6e65 2c20 6578 7472 (last_line, extr\n+00067e00: 6173 2c20 7374 6465 7272 290a 0a0a 636c as, stderr)...cl\n+00067e10: 6173 7320 5373 6841 736b 7061 7373 5265 ass SshAskpassRe\n+00067e20: 7370 6f6e 6465 7228 4173 6b70 6173 7348 sponder(AskpassH\n+00067e30: 616e 646c 6572 293a 0a20 2020 2061 7379 andler):. asy\n+00067e40: 6e63 2064 6566 2064 6f5f 6173 6b70 6173 nc def do_askpas\n+00067e50: 7328 7365 6c66 2c20 7374 6465 7272 3a20 s(self, stderr: \n+00067e60: 7374 722c 2070 726f 6d70 743a 2073 7472 str, prompt: str\n+00067e70: 2c20 6869 6e74 3a20 7374 7229 202d 3e20 , hint: str) -> \n+00067e80: 2773 7472 207c 204e 6f6e 6527 3a0a 2020 'str | None':. \n+00067e90: 2020 2020 2020 7265 7475 726e 2061 7761 return awa\n+00067ea0: 6974 2063 6174 6567 6f72 697a 655f 7373 it categorize_ss\n+00067eb0: 685f 7072 6f6d 7074 2870 726f 6d70 742c h_prompt(prompt,\n+00067ec0: 2073 7464 6572 7229 2e64 6973 7061 7463 stderr).dispatc\n+00067ed0: 6828 7365 6c66 290a 0a20 2020 2061 7379 h(self).. asy\n+00067ee0: 6e63 2064 6566 2064 6f5f 7072 6f6d 7074 nc def do_prompt\n+00067ef0: 2873 656c 662c 2070 726f 6d70 743a 2041 (self, prompt: A\n+00067f00: 736b 7061 7373 5072 6f6d 7074 2920 2d3e skpassPrompt) ->\n+00067f10: 2027 7374 7220 7c20 4e6f 6e65 273a 0a20 'str | None':. \n+00067f20: 2020 2020 2020 2023 2044 6566 6175 6c74 # Default\n+00067f30: 2066 616c 6c62 6163 6b20 666f 7220 756e fallback for un\n+00067f40: 7265 636f 676e 6973 6564 206d 6573 7361 recognised messa\n+00067f50: 6765 2074 7970 6573 3a20 756e 696d 706c ge types: unimpl\n+00067f60: 656d 656e 7465 640a 2020 2020 2020 2020 emented. \n+00067f70: 7265 7475 726e 204e 6f6e 650a 0a20 2020 return None.. \n+00067f80: 2061 7379 6e63 2064 6566 2064 6f5f 6669 async def do_fi\n+00067f90: 646f 5f70 696e 5f70 726f 6d70 7428 7365 do_pin_prompt(se\n+00067fa0: 6c66 2c20 7072 6f6d 7074 3a20 5373 6846 lf, prompt: SshF\n+00067fb0: 4944 4f50 494e 5072 6f6d 7074 2920 2d3e IDOPINPrompt) ->\n+00067fc0: 2027 7374 7220 7c20 4e6f 6e65 273a 0a20 'str | None':. \n+00067fd0: 2020 2020 2020 2072 6574 7572 6e20 6177 return aw\n+00067fe0: 6169 7420 7365 6c66 2e64 6f5f 7072 6f6d ait self.do_prom\n+00067ff0: 7074 2870 726f 6d70 7429 0a0a 2020 2020 pt(prompt).. \n+00068000: 6173 796e 6320 6465 6620 646f 5f66 6964 async def do_fid\n+00068010: 6f5f 7573 6572 5f70 7265 7365 6e63 655f o_user_presence_\n+00068020: 7072 6f6d 7074 2873 656c 662c 2070 726f prompt(self, pro\n+00068030: 6d70 743a 2053 7368 4649 444f 5573 6572 mpt: SshFIDOUser\n+00068040: 5072 6573 656e 6365 5072 6f6d 7074 2920 PresencePrompt) \n+00068050: 2d3e 2027 7374 7220 7c20 4e6f 6e65 273a -> 'str | None':\n+00068060: 0a20 2020 2020 2020 2072 6574 7572 6e20 . return \n+00068070: 6177 6169 7420 7365 6c66 2e64 6f5f 7072 await self.do_pr\n+00068080: 6f6d 7074 2870 726f 6d70 7429 0a0a 2020 ompt(prompt).. \n+00068090: 2020 6173 796e 6320 6465 6620 646f 5f68 async def do_h\n+000680a0: 6f73 745f 6b65 795f 7072 6f6d 7074 2873 ost_key_prompt(s\n+000680b0: 656c 662c 2070 726f 6d70 743a 2053 7368 elf, prompt: Ssh\n+000680c0: 486f 7374 4b65 7950 726f 6d70 7429 202d HostKeyPrompt) -\n+000680d0: 3e20 2773 7472 207c 204e 6f6e 6527 3a0a > 'str | None':.\n+000680e0: 2020 2020 2020 2020 7265 7475 726e 2061 return a\n+000680f0: 7761 6974 2073 656c 662e 646f 5f70 726f wait self.do_pro\n+00068100: 6d70 7428 7072 6f6d 7074 290a 0a20 2020 mpt(prompt).. \n+00068110: 2061 7379 6e63 2064 6566 2064 6f5f 706b async def do_pk\n+00068120: 6373 3131 5f70 696e 5f70 726f 6d70 7428 cs11_pin_prompt(\n+00068130: 7365 6c66 2c20 7072 6f6d 7074 3a20 5373 self, prompt: Ss\n+00068140: 6850 4b43 5331 3150 494e 5072 6f6d 7074 hPKCS11PINPrompt\n+00068150: 2920 2d3e 2027 7374 7220 7c20 4e6f 6e65 ) -> 'str | None\n+00068160: 273a 0a20 2020 2020 2020 2072 6574 7572 ':. retur\n+00068170: 6e20 6177 6169 7420 7365 6c66 2e64 6f5f n await self.do_\n+00068180: 7072 6f6d 7074 2870 726f 6d70 7429 0a0a prompt(prompt)..\n+00068190: 2020 2020 6173 796e 6320 6465 6620 646f async def do\n+000681a0: 5f70 6173 7370 6872 6173 655f 7072 6f6d _passphrase_prom\n+000681b0: 7074 2873 656c 662c 2070 726f 6d70 743a pt(self, prompt:\n+000681c0: 2053 7368 5061 7373 7068 7261 7365 5072 SshPassphrasePr\n+000681d0: 6f6d 7074 2920 2d3e 2027 7374 7220 7c20 ompt) -> 'str | \n+000681e0: 4e6f 6e65 273a 0a20 2020 2020 2020 2072 None':. r\n+000681f0: 6574 7572 6e20 6177 6169 7420 7365 6c66 eturn await self\n+00068200: 2e64 6f5f 7072 6f6d 7074 2870 726f 6d70 .do_prompt(promp\n+00068210: 7429 0a0a 2020 2020 6173 796e 6320 6465 t).. async de\n+00068220: 6620 646f 5f70 6173 7377 6f72 645f 7072 f do_password_pr\n+00068230: 6f6d 7074 2873 656c 662c 2070 726f 6d70 ompt(self, promp\n+00068240: 743a 2053 7368 5061 7373 776f 7264 5072 t: SshPasswordPr\n+00068250: 6f6d 7074 2920 2d3e 2027 7374 7220 7c20 ompt) -> 'str | \n+00068260: 4e6f 6e65 273a 0a20 2020 2020 2020 2072 None':. r\n+00068270: 6574 7572 6e20 6177 6169 7420 7365 6c66 eturn await self\n+00068280: 2e64 6f5f 7072 6f6d 7074 2870 726f 6d70 .do_prompt(promp\n+00068290: 7429 0a27 2727 2c0a 2020 2763 6f63 6b70 t).''',. 'cockp\n+000682a0: 6974 2f5f 7665 6e64 6f72 2f66 6572 6e79 it/_vendor/ferny\n+000682b0: 2f61 736b 7061 7373 2e70 7927 3a20 6272 /askpass.py': br\n+000682c0: 2727 2766 726f 6d20 2e69 6e74 6572 6163 '''from .interac\n+000682d0: 7469 6f6e 5f63 6c69 656e 7420 696d 706f tion_client impo\n+000682e0: 7274 206d 6169 6e0a 0a69 6620 5f5f 6e61 rt main..if __na\n+000682f0: 6d65 5f5f 203d 3d20 275f 5f6d 6169 6e5f me__ == '__main_\n+00068300: 5f27 3a0a 2020 2020 6d61 696e 2829 0a27 _':. main().'\n 00068310: 2727 2c0a 7d29 290a 6672 6f6d 2063 6f63 '',.})).from coc\n 00068320: 6b70 6974 2e62 7269 6467 6520 696d 706f kpit.bridge impo\n 00068330: 7274 206d 6169 6e20 6173 206d 6169 6e0a rt main as main.\n 00068340: 6d61 696e 2862 6569 7061 636b 3d54 7275 main(beipack=Tru\n 00068350: 6529 0a e).\n"}, {"source1": "xz --list", "source2": "xz --list", "unified_diff": "@@ -1,13 +1,13 @@\n Streams: 1\n Blocks: 1\n- Compressed size: 84.8 KiB (86800 B)\n+ Compressed size: 85.0 KiB (87000 B)\n Uncompressed size: 416.8 KiB (426835 B)\n- Ratio: 0.203\n+ Ratio: 0.204\n Check: CRC64\n Stream Padding: 0 B\n Streams:\n Stream Blocks CompOffset UncompOffset CompSize UncompSize Ratio Check Padding\n- 1 1 0 0 86800 426835 0.203 CRC64 0\n+ 1 1 0 0 87000 426835 0.204 CRC64 0\n Blocks:\n Stream Block CompOffset UncompOffset TotalSize UncompSize Ratio Check\n- 1 1 12 0 86764 426835 0.203 CRC64\n+ 1 1 12 0 86964 426835 0.204 CRC64\n"}]}, {"source1": "./usr/lib/python3/dist-packages/cockpit-316.dist-info/direct_url.json", "source2": "./usr/lib/python3/dist-packages/cockpit-316.dist-info/direct_url.json", "unified_diff": null, "details": [{"source1": "Pretty-printed", "source2": "Pretty-printed", "comments": ["Similarity: 0.90625%", "Differences: {\"'archive_info'\": \"{'hash': \"", " \"'sha256=308378125cc7da6e6c2e6f02104347ca2407f76e6d13108f9606379f0395c5c3', \"", " \"'hashes': {'sha256': \"", " \"'308378125cc7da6e6c2e6f02104347ca2407f76e6d13108f9606379f0395c5c3'}}\"}"], "unified_diff": "@@ -1,9 +1,9 @@\n {\n \"archive_info\": {\n- \"hash\": \"sha256=0fd2cd237ac294704d26b51ce667c52386d3a892d89f4005298d6ca91a8356d9\",\n+ \"hash\": \"sha256=308378125cc7da6e6c2e6f02104347ca2407f76e6d13108f9606379f0395c5c3\",\n \"hashes\": {\n- \"sha256\": \"0fd2cd237ac294704d26b51ce667c52386d3a892d89f4005298d6ca91a8356d9\"\n+ \"sha256\": \"308378125cc7da6e6c2e6f02104347ca2407f76e6d13108f9606379f0395c5c3\"\n }\n },\n \"url\": \"file:///build/reproducible-path/cockpit-316/tmp/wheel/cockpit-316-py3-none-any.whl\"\n }\n"}]}]}, {"source1": "xz --list", "source2": "xz --list", "unified_diff": "@@ -1,13 +1,13 @@\n Streams: 1\n Blocks: 1\n- Compressed size: 347.4 KiB (355704 B)\n+ Compressed size: 347.5 KiB (355888 B)\n Uncompressed size: 870.0 KiB (890880 B)\n Ratio: 0.399\n Check: CRC64\n Stream Padding: 0 B\n Streams:\n Stream Blocks CompOffset UncompOffset CompSize UncompSize Ratio Check Padding\n- 1 1 0 0 355704 890880 0.399 CRC64 0\n+ 1 1 0 0 355888 890880 0.399 CRC64 0\n Blocks:\n Stream Block CompOffset UncompOffset TotalSize UncompSize Ratio Check\n- 1 1 12 0 355668 890880 0.399 CRC64\n+ 1 1 12 0 355852 890880 0.399 CRC64\n"}]}]}]}