Merge lp:~dmitriis/landscape-client-charm/landscape-client-charm into lp:landscape-client-charm

Proposed by Dmitrii Shcherbakov
Status: Merged
Merged at revision: 67
Proposed branch: lp:~dmitriis/landscape-client-charm/landscape-client-charm
Merge into: lp:landscape-client-charm
Diff against target: 10 lines (+1/-1)
1 file modified
hooks/hooks.py (+1/-1)
To merge this branch: bzr merge lp:~dmitriis/landscape-client-charm/landscape-client-charm
Reviewer Review Type Date Requested Status
Simon Poirier (community) Approve
🤖 Landscape Builder test results Approve
Review via email: mp+358402@code.launchpad.net

Commit message

Handle py2 and py3 by opening a file in wb mode

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 :
review: Needs Fixing (test results)
Revision history for this message
Dave Jones (waveform) wrote :

Possibly a silly question but why not just change the open() call to write a binary file instead?

Revision history for this message
Dmitrii Shcherbakov (dmitriis) wrote :

Well, that's another way to do it.

I could make that change instead.

Revision history for this message
Simon Poirier (simpoir) wrote :

I'm with Dave, opening as "wb" would be safer than blindly decoding as utf8, and also closer to the py2 behaviour.

Revision history for this message
Dmitrii Shcherbakov (dmitriis) wrote :

Updated the branch accordingly.

Revision history for this message
🤖 Landscape Builder (landscape-builder) :
review: Abstain (executing tests)
Revision history for this message
🤖 Landscape Builder (landscape-builder) wrote :
review: Approve (test results)
Revision history for this message
Simon Poirier (simpoir) wrote :

+1
I verified charm on both trusty, xenial and bionic and this fix seems to work fine.

review: Approve
Revision history for this message
🤖 Landscape Builder (landscape-builder) wrote :

The attempt to merge lp:~dmitriis/landscape-client-charm/landscape-client-charm into lp:landscape-client-charm failed. Below is the output from the failed tests.

./dev/ubuntu-deps
Reading package lists...
Building dependency tree...
Reading state information...
python-flake8 is already the newest version.
python-yaml is already the newest version.
landscape-common is already the newest version.
landscape-common set to manually installed.
The following packages were automatically installed and are no longer required:
  gconf-service gconf-service-backend gconf2 gconf2-common landscape-base
  landscape-client-base libavahi-glib1 libbonobo2-0 libbonobo2-common
  libcanberra0 libgconf-2-4 libgconf2-4 libgnome-keyring-common
  libgnome-keyring0 libgnome2-0 libgnome2-bin libgnome2-common libgnomevfs2-0
  libgnomevfs2-common libidl-common libidl0 liborbit-2-0 liborbit2 libspeechd2
  libtdb1 libvorbisfile3 linux-headers-3.13.0-107
  linux-headers-3.13.0-107-generic linux-image-3.13.0-107-generic
  python3-characteristic python3-configobj python3-landscape-lib
  python3-openssl python3-passlib python3-pyasn1 python3-pyasn1-modules
  python3-service-identity python3-twisted python3-zope.interface
  sound-theme-freedesktop
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 83 not upgraded.
make test lint
make[1]: Entering directory `/var/tmp/tarmac/landscape-client-charm/trunk'
cd hooks && trial test_hooks.py
test_hooks
  py ... [ERROR]

===============================================================================
[ERROR]
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/twisted/trial/runner.py", line 605, in loadByNames
    things.append(self.findByName(name))
  File "/usr/lib/python2.7/dist-packages/twisted/trial/runner.py", line 408, in findByName
    return filenameToModule(name)
  File "/usr/lib/python2.7/dist-packages/twisted/trial/runner.py", line 93, in filenameToModule
    ret = reflect.namedAny(reflect.filenameToModuleName(fn))
  File "/usr/lib/python2.7/dist-packages/twisted/python/reflect.py", line 303, in namedAny
    topLevelPackage = _importAndCheckStack(trialname)
  File "/usr/lib/python2.7/dist-packages/twisted/python/reflect.py", line 250, in _importAndCheckStack
    reraise(excValue, excTraceback)
  File "/var/tmp/tarmac/landscape-client-charm/trunk/hooks/test_hooks.py", line 10, in <module>
    from landscape.deployment import Configuration
exceptions.ImportError: No module named deployment

test_hooks.py
-------------------------------------------------------------------------------
Ran 1 tests in 0.025s

FAILED (errors=1)
make[1]: Leaving directory `/var/tmp/tarmac/landscape-client-charm/trunk'

make[1]: *** [test] Error 1
make: *** [ci-test] Error 2

Revision history for this message
🤖 Landscape Builder (landscape-builder) wrote :

No approved revision specified.

Revision history for this message
Dmitrii Shcherbakov (dmitriis) wrote :

Thanks!

Is there still automation to push it to the charm store? As of now the old version is still the latest one in CS.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'hooks/hooks.py'
--- hooks/hooks.py 2018-02-24 05:26:59 +0000
+++ hooks/hooks.py 2018-11-07 15:09:06 +0000
@@ -214,7 +214,7 @@
214 @param certificate Text of the certificate, base64 encoded.214 @param certificate Text of the certificate, base64 encoded.
215 @param filename Full path to file to write215 @param filename Full path to file to write
216 """216 """
217 with open(filename, "w") as file:217 with open(filename, "wb") as file:
218 file.write(base64.b64decode(certificate))218 file.write(base64.b64decode(certificate))
219219
220220

Subscribers

People subscribed via source and target branches

to all changes: