Writing bytes to NamedTemporaryFile

This commit is contained in:
PCoder 2017-09-13 02:31:19 +05:30
parent 261615e701
commit 3770489a49

View file

@ -97,7 +97,7 @@ class UserHostingKeyForm(forms.ModelForm):
openssh_pubkey_str = self.data.get('public_key') openssh_pubkey_str = self.data.get('public_key')
with tempfile.NamedTemporaryFile(delete=True) as tmp_public_key_file: with tempfile.NamedTemporaryFile(delete=True) as tmp_public_key_file:
tmp_public_key_file.writelines(openssh_pubkey_str) tmp_public_key_file.write(openssh_pubkey_str.encode('utf-8'))
tmp_public_key_file.flush() tmp_public_key_file.flush()
try: try:
out = subprocess.check_output( out = subprocess.check_output(