Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/supervisorctl/files/sendProcessStdin.py

raw
1 #!/usr/bin/env python
2 # Copyright (c) Ansible Project
3 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
4 # SPDX-License-Identifier: GPL-3.0-or-later
5
6
7 from __future__ import annotations
8
9 import sys
10 from urllib.parse import quote
11 from xmlrpc.client import ServerProxy
12
13 proc = sys.argv[1]
14 value = sys.argv[2]
15 username = sys.argv[3]
16 password = sys.argv[4]
17
18 if username:
19 url = f"http://{quote(username, safe='')}:{quote(password, safe='')}@127.0.0.1:9001/RPC2"
20 else:
21 url = "http://127.0.0.1:9001/RPC2"
22
23 server = ServerProxy(url, verbose=True)
24 server.supervisor.sendProcessStdin(proc, f"import sys; print({value}); sys.stdout.flush();\n")