Merge lp:~abentley/juju-release-tools/make-parent-dir into lp:juju-release-tools

Proposed by Aaron Bentley
Status: Merged
Merged at revision: 265
Proposed branch: lp:~abentley/juju-release-tools/make-parent-dir
Merge into: lp:juju-release-tools
Diff against target: 23 lines (+6/-0)
1 file modified
download_agents.py (+6/-0)
To merge this branch: bzr merge lp:~abentley/juju-release-tools/make-parent-dir
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+286411@code.launchpad.net

Commit message

Create parent directories as needed.

Description of the change

Update download_agents to create the parent directories of agents.

This is needed now that agents have version prefixes like agent/1.25.1

To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :

Thank you.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'download_agents.py'
2--- download_agents.py 2015-11-06 21:00:26 +0000
3+++ download_agents.py 2016-02-17 21:41:53 +0000
4@@ -2,6 +2,7 @@
5 from __future__ import print_function
6
7 from argparse import ArgumentParser
8+import errno
9 import json
10 import os
11 from urllib.request import urlopen
12@@ -22,6 +23,11 @@
13 else:
14 print('Downloading: {}'.format(path), end='')
15 sys.stdout.flush()
16+ try:
17+ os.makedirs(os.path.dirname(download['path']))
18+ except OSError as e:
19+ if e.errno != errno.EEXIST:
20+ raise
21 with open(download['path'], 'wb') as target:
22 with urlopen(download['url']) as source:
23 while True:

Subscribers

People subscribed via source and target branches