Merge lp:~fo0bar/turku/turku-agent-encoding into lp:turku/turku-agent

Proposed by Ryan Finnie
Status: Merged
Approved by: Haw Loeung
Approved revision: 52
Merged at revision: 53
Proposed branch: lp:~fo0bar/turku/turku-agent-encoding
Merge into: lp:turku/turku-agent
Diff against target: 28 lines (+4/-4)
1 file modified
turku_agent/ping.py (+4/-4)
To merge this branch: bzr merge lp:~fo0bar/turku/turku-agent-encoding
Reviewer Review Type Date Requested Status
Stuart Bishop (community) Approve
Review via email: mp+381075@code.launchpad.net

Commit message

Move encoding from writes to opens

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
Stuart Bishop (stub) wrote :

Code changes look good. Looks like turku-agent has already switched to Python3, so no worries with Python2 compatibility.

review: Approve
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 53

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'turku_agent/ping.py'
2--- turku_agent/ping.py 2019-04-22 01:39:55 +0000
3+++ turku_agent/ping.py 2020-03-23 22:52:07 +0000
4@@ -40,9 +40,9 @@
5
6 def call_ssh(config, storage, ssh_req):
7 # Write the server host public key
8- t = tempfile.NamedTemporaryFile()
9+ t = tempfile.NamedTemporaryFile(mode='w+', encoding='UTF-8')
10 for key in storage['ssh_ping_host_keys']:
11- t.write(('%s %s\n' % (storage['ssh_ping_host'], key)).encode('UTF-8'))
12+ t.write('%s %s\n' % (storage['ssh_ping_host'], key))
13 t.flush()
14
15 # Call ssh
16@@ -60,10 +60,10 @@
17 storage['ssh_ping_host'],
18 'turku-ping-remote',
19 ]
20- p = subprocess.Popen(ssh_command, stdin=subprocess.PIPE)
21+ p = subprocess.Popen(ssh_command, stdin=subprocess.PIPE, encoding='UTF-8')
22
23 # Write the ssh request
24- p.stdin.write((json.dumps(ssh_req) + '\n.\n').encode('UTF-8'))
25+ p.stdin.write(json.dumps(ssh_req) + '\n.\n')
26 p.stdin.flush()
27
28 # Wait for the server to close the SSH connection

Subscribers

People subscribed via source and target branches

to all changes: