Merge lp:~gocept/landscape-client/py3-startup into lp:~landscape/landscape-client/trunk

Proposed by Steffen Allner
Status: Merged
Approved by: Free Ekanayaka
Approved revision: 1004
Merged at revision: 1000
Proposed branch: lp:~gocept/landscape-client/py3-startup
Merge into: lp:~landscape/landscape-client/trunk
Prerequisite: lp:~gocept/landscape-client/py3-packages
Diff against target: 52 lines (+13/-2)
2 files modified
landscape/lib/bpickle.py (+11/-0)
landscape/watchdog.py (+2/-2)
To merge this branch: bzr merge lp:~gocept/landscape-client/py3-startup
Reviewer Review Type Date Requested Status
Daniel Havlik (community) Approve
Alberto Donato (community) Approve
Free Ekanayaka (community) Approve
🤖 Landscape Builder test results Approve
Review via email: mp+321961@code.launchpad.net

Commit message

This MP allows to startup the client as there has been an issue with writing bytes to the stdout/stderr with the watchdog.

Additionally, I included a hacky workaround to convert all keys in dictionaries to unicode, when they are retrieved from a bpickled stream of data, and to write them back as bytes when bpickle.dumps().

If this is accepted that should be included in the bpickle git repository.

Description of the change

This MP allows to startup the client as there has been an issue with writing bytes to the stdout/stderr with the watchdog.

Additionally, I included a hacky workaround to convert all keys in dictionaries to unicode, when they are retrieved from a bpickled stream of data, and to write them back as bytes when bpickle.dumps().

If this is accepted that should be included in the bpickle git repository.

This MP was requested by Free Ekanayaka.

To post a comment you must log in.
Revision history for this message
🤖 Landscape Builder (landscape-builder) :
review: Abstain (executing tests)
Revision history for this message
🤖 Landscape Builder (landscape-builder) wrote :

Command: make ci-check
Result: Success
Revno: 1004
Branch: lp:~gocept/landscape-client/py3-startup
Jenkins: https://ci.lscape.net/job/latch-test-xenial/3836/

review: Approve (test results)
Revision history for this message
Free Ekanayaka (free.ekanayaka) wrote :

+1 we will clean up the details in follow-up branches

review: Approve
Revision history for this message
Alberto Donato (ack) wrote :

+1

review: Approve
Revision history for this message
Daniel Havlik (nilo) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'landscape/lib/bpickle.py'
2--- landscape/lib/bpickle.py 2017-03-17 09:26:45 +0000
3+++ landscape/lib/bpickle.py 2017-04-05 08:13:15 +0000
4@@ -32,6 +32,7 @@
5 wire compatible and behave the same way (bugs notwithstanding).
6 """
7
8+import logging
9
10 dumps_table = {}
11 loads_table = {}
12@@ -93,6 +94,11 @@
13 append = res.append
14 for key in keys:
15 val = obj[key]
16+ if (bytes is not str) and isinstance(key, str):
17+ try:
18+ key.encode("ascii")
19+ except UnicodeError as e:
20+ logging.warning(e)
21 append(_dt[type(key)](key))
22 append(_dt[type(val)](val))
23 return b"d%s;" % b"".join(res)
24@@ -154,6 +160,11 @@
25 while bytestring[pos:pos+1] != b";":
26 key, pos = _lt[bytestring[pos:pos+1]](bytestring, pos)
27 val, pos = _lt[bytestring[pos:pos+1]](bytestring, pos)
28+ if (bytes is not str) and isinstance(key, bytes):
29+ try:
30+ key.decode("ascii")
31+ except UnicodeError as e:
32+ logging.warning(e)
33 res[key] = val
34 return res, pos+1
35
36
37=== modified file 'landscape/watchdog.py'
38--- landscape/watchdog.py 2017-04-04 08:50:05 +0000
39+++ landscape/watchdog.py 2017-04-05 08:13:15 +0000
40@@ -295,10 +295,10 @@
41
42 def outReceived(self, data):
43 # it's *probably* going to always be line buffered, by accident
44- sys.stdout.write(data)
45+ sys.stdout.buffer.write(data)
46
47 def errReceived(self, data):
48- sys.stderr.write(data)
49+ sys.stderr.buffer.write(data)
50
51 def processEnded(self, reason):
52 """The process has ended; restart it."""

Subscribers

People subscribed via source and target branches

to all changes: