TypeError: __init__() got an unexpected keyword argument 'text'
ggiesen opened this issue · 2 comments
ggiesen commented
When running bw_add_sshkeys,py, I get the following error:
$ bw_add_sshkeys.py
INFO:root:Getting Bitwarden session
Traceback (most recent call last):
File "/home/ggiesen/bin/bw_add_sshkeys.py", line 254, in <module>
main()
File "/home/ggiesen/bin/bw_add_sshkeys.py", line 238, in main
session = get_session()
File "/home/ggiesen/bin/bw_add_sshkeys.py", line 82, in get_session
check=True,
File "/usr/lib64/python3.6/subprocess.py", line 423, in run
with Popen(*popenargs, **kwargs) as process:
TypeError: __init__() got an unexpected keyword argument 'text'
$ bw --version
1.19.1
$ cat /etc/redhat-release
Rocky Linux release 8.4 (Green Obsidian)
$ python3 -V
Python 3.6.8
$ rpm -qa | grep openssh-clients
openssh-clients-8.0p1-6.el8_4.2.x86_64
ggiesen commented
Looks like changing text=True
to universal_newlines=True
resolves the issue, as text
is just an alias for universal_newlines
introduced in Python 3.7:
https://docs.python.org/3.7/library/subprocess.html
diff -urN bw_add_sshkeys.py.orig bw_add_sshkeys.py
--- bw_add_sshkeys.py.orig 2021-11-20 14:28:03.955436300 -0500
+++ bw_add_sshkeys.py 2021-11-21 09:33:11.871930700 -0500
@@ -36,7 +36,7 @@
proc_version = subprocess.run(
['bw', '--version'],
stdout=subprocess.PIPE,
- text=True,
+ universal_newlines=True,
check=True,
)
return proc_version.stdout
@@ -78,7 +78,7 @@
proc_session = subprocess.run(
['bw', '--raw', operation],
stdout=subprocess.PIPE,
- text=True,
+ universal_newlines=True,
check=True,
)
return proc_session.stdout
@@ -93,7 +93,7 @@
proc_folders = subprocess.run(
['bw', 'list', 'folders', '--search', foldername, '--session', session],
stdout=subprocess.PIPE,
- text=True,
+ universal_newlines=True,
check=True,
)
@@ -120,7 +120,7 @@
proc_items = subprocess.run(
[ 'bw', 'list', 'items', '--folderid', folder_id, '--session', session],
stdout=subprocess.PIPE,
- text=True,
+ universal_newlines=True,
check=True,
)
return json.loads(proc_items.stdout)
@@ -176,7 +176,7 @@
'--session', session
],
stdout=subprocess.PIPE,
- text=True,
+ universal_newlines=True,
check=True,
)
ssh_key = proc_attachment.stdout
@@ -189,7 +189,7 @@
input=ssh_key,
# Works even if ssh-askpass is not installed
env=dict(os.environ, SSH_ASKPASS_REQUIRE="never"),
- text=True,
+ universal_newlines=True,
check=True,
)
joaojacome commented
Solved on #19
Thank you for your contribution :)