Skip to content

Commit

Permalink
Encode string to utf-8 and covert to bytes before sending to pipe
Browse files Browse the repository at this point in the history
Due to changes in Python3 string handling, strings must be encoded prior to being sent to the pipe, as it may introduce a type error such as:
`TypeError: a bytes-like object is required, not 'str'`
  • Loading branch information
emkll committed Sep 13, 2018
1 parent 40d73f3 commit 9b6ec99
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion sd-decrypt/decrypt-sd-submission
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def send_progress(msg):
"sd-process.Feedback"],
close_fds=True,
stdin=subprocess.PIPE)
p.communicate(msg)
p.communicate(bytes(msg.encode('utf-8')))


input = sys.argv[1]
Expand Down
4 changes: 2 additions & 2 deletions sd-journalist/sd-process-download
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ wait_for_sigfile(sigfile)
if os.path.isfile(fn) is False:
c = subprocess.Popen(["/usr/local/bin/sd-process-feedback"],
stdin=subprocess.PIPE)
c.communicate('DOWNLOAD_FILE_MISSING\n')
c.communicate(bytes("DOWNLOAD_FILE_MISSING\n".encode('utf-8')))
sys.exit()

fh = tempfile.NamedTemporaryFile(suffix=".sd-xfer", delete=False)
Expand All @@ -81,7 +81,7 @@ fh.close()
# from the same machine? This can only happen on sd-journalist.
c = subprocess.Popen(["/usr/local/bin/sd-process-feedback"],
stdin=subprocess.PIPE)
c.communicate(input="DOWNLOAD_BUNDLE_CREATED\n")
c.communicate(bytes("DOWNLOAD_BUNDLE_CREATED\n".encode('utf-8')))

# ship this to the next phase
subprocess.call(["qvm-open-in-vm", "sd-decrypt", fh.name])
Expand Down
2 changes: 1 addition & 1 deletion sd-journalist/sd-process-feedback
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import posix
import sys
import os

arg = sys.stdin.readline()
arg = sys.stdin.readline().encode('utf-8')

try:
fifo = os.open('/home/user/sdfifo', posix.O_WRONLY | posix.O_NONBLOCK)
Expand Down
2 changes: 1 addition & 1 deletion sd-svs/accept-sd-xfer-extracted
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def send_progress(msg):
"sd-process.Feedback"],
close_fds=True,
stdin=subprocess.PIPE)
p.communicate(msg)
p.communicate(bytes(msg.encode('utf-8')))


send_progress("DECRYPTED_BUNDLE_ON_SVS")
Expand Down

0 comments on commit 9b6ec99

Please sign in to comment.