AttributeError: __exit__ when downloading charm from the store

Bug #1884297 reported by Guillermo Gonzalez
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mojo: Continuous Delivery for Juju
Invalid
Undecided
Unassigned
codetree
Fix Committed
High
Unassigned

Bug Description

While calling mojo collect, which calls codetree, we are getting the error: AttributeError: __exit__.
This happens on python3.4 from Trusty, which could be causing this error.

After adding custom logging to mojo got this traceback:

Traceback (most recent call last):
  File "/home/user1/mojo/dist/usr/local/lib/python3.4/dist-packages/mojo/cli.py", line 684, in run_with_args
    args.func(args)
  File "/home/user1/mojo/dist/usr/local/lib/python3.4/dist-packages/mojo/utils.py", line 384, in wrapped
    return method(*args, **kwargs)
  File "/home/user1/mojo/dist/usr/local/lib/python3.4/dist-packages/mojo/cli.py", line 352, in run_from_manifest
    manifest.run(project, workspace, args.stage, args.interactive)
  File "/home/user1/mojo/dist/usr/local/lib/python3.4/dist-packages/mojo/manifest.py", line 124, in run
    phase_name.run(project, workspace, stage, auto_repo=auto_repo)
  File "/home/user1/mojo/dist/usr/local/lib/python3.4/dist-packages/mojo/phase.py", line 252, in run
    collect_success = collect_config.build()
  File "/usr/lib/python3/dist-packages/codetree/config.py", line 277, in build
    results.append(f.result())
  File "/usr/lib/python3.4/concurrent/futures/_base.py", line 402, in result
    return self.__get_result()
  File "/usr/lib/python3.4/concurrent/futures/_base.py", line 354, in __get_result
    raise self._exception
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3/dist-packages/codetree/config.py", line 118, in run_with_dependency
    return self.run()
  File "/usr/lib/python3/dist-packages/codetree/config.py", line 86, in run
    result = self.source.get(self.location, self.source_options)
  File "/usr/lib/python3/dist-packages/codetree/handlers/charm.py", line 89, in get
    if downloader.get(dest):
  File "/usr/lib/python3/dist-packages/codetree/handlers/charm.py", line 143, in get
    zipped_path = self.cs_download(tmp_dir)
  File "/usr/lib/python3/dist-packages/codetree/handlers/charm.py", line 163, in cs_download
    with open(zip_path, 'wb') as charm_file, requests.get(url) as req:
AttributeError: __exit__

Related branches

Revision history for this message
Tom Haddon (mthaddon) wrote :

This is a simple reproduction using just codetree: https://pastebin.ubuntu.com/p/qGkRVBdkZz/

Works fine locally, but fails when called via ssh from a remote machine.

Changed in mojo:
status: New → Invalid
Changed in codetree:
status: New → Confirmed
importance: Undecided → High
Revision history for this message
Tom Haddon (mthaddon) wrote :

The reason this fails via ssh but not locally on the machines we were testing with here is that we use a different codepath if we can find the "charm" command vs. not finding it, and the one that we trigger when we can't find the "charm" command uses this:

with open(zip_path, 'wb') as charm_file, requests.get(url) as req:

In python3.4 (which the machine this is failing on is running) requests.get isn't a context manager.

Tom Haddon (mthaddon)
Changed in codetree:
status: Confirmed → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.