Merge lp:~fginther/codetree/fix-charm-symlinks into lp:codetree

Proposed by Francis Ginther
Status: Merged
Merged at revision: 64
Proposed branch: lp:~fginther/codetree/fix-charm-symlinks
Merge into: lp:codetree
Diff against target: 61 lines (+5/-6)
3 files modified
codetree/handlers/charm.py (+2/-3)
debian/control (+1/-1)
tests/test_charm_handler.py (+2/-2)
To merge this branch: bzr merge lp:~fginther/codetree/fix-charm-symlinks
Reviewer Review Type Date Requested Status
Tim Kuhlman (community) Approve
Review via email: mp+296278@code.launchpad.net

Commit message

Use a subproccess call to unzip instead of the zipfile module to avoid corrupting symlinks.

Description of the change

Use a subproccess call to unzip instead of the zipfile module to avoid corrupting symlinks.

Testing:
Created a config file consisting of:

postgresql cs:trusty/postgresql

and verified that when executed, the symlinks under the postgresql/hooks directory exist. Prior to this change they are extracted as regular files containing the symlink target as the content of the file.

To post a comment you must log in.
65. By Francis Ginther

Fix test_download_invalid_zip to match use of unzip.

Revision history for this message
Tim Kuhlman (timkuhlman) wrote :

Thanks! I am adding "stderr=subprocess.STDOUT" so the test output remains clean.

Revision history for this message
Tim Kuhlman (timkuhlman) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'codetree/handlers/charm.py'
2--- codetree/handlers/charm.py 2016-06-01 16:12:47 +0000
3+++ codetree/handlers/charm.py 2016-06-02 11:23:14 +0000
4@@ -2,11 +2,11 @@
5 import logging
6 import os
7 import shutil
8+import subprocess
9 import sys
10 import tempfile
11 from urlparse import urlparse
12 import urllib2
13-import zipfile
14
15 from basic import SourceHandler
16 from exceptions import InvalidOption
17@@ -65,8 +65,7 @@
18 tmp_dir = tempfile.mkdtemp()
19 try:
20 zipped_path = self.cs_download(tmp_dir)
21- with zipfile.ZipFile(zipped_path, 'r') as zipped:
22- zipped.extractall(dest)
23+ subprocess.check_output(['unzip', zipped_path, '-d', dest])
24 except Exception:
25 raise
26 finally:
27
28=== modified file 'debian/control'
29--- debian/control 2016-02-09 17:42:19 +0000
30+++ debian/control 2016-06-02 11:23:14 +0000
31@@ -7,5 +7,5 @@
32
33 Package: python-codetree
34 Architecture: all
35-Depends: ${misc:Depends}, ${python:Depends}, python-bzrlib, python-concurrent.futures, git, rsync
36+Depends: ${misc:Depends}, ${python:Depends}, python-bzrlib, python-concurrent.futures, git, rsync, unzip
37 Description: A code tree builder
38
39=== modified file 'tests/test_charm_handler.py'
40--- tests/test_charm_handler.py 2016-05-12 15:52:25 +0000
41+++ tests/test_charm_handler.py 2016-06-02 11:23:14 +0000
42@@ -2,11 +2,11 @@
43 import os
44 from pkg_resources import resource_filename
45 import shutil
46+import subprocess
47 import tempfile
48 from unittest import TestCase
49 from urlparse import urlparse
50 import urllib2
51-import zipfile
52
53 from codetree.handlers import CharmStoreHandler
54 from codetree.handlers.utils import handler_types
55@@ -112,5 +112,5 @@
56 test_sha = '0291dbcaaa51039c59ae631f106d95791fb8c74815fee44f3f31fea7f9f30d001e24d038e90ed632d1d71a6f4082ad5c'
57 _urlopen.return_value = MockedReq(file_data='not a valid zip', sha=test_sha)
58
59- with self.assertRaises(zipfile.BadZipfile):
60+ with self.assertRaises(subprocess.CalledProcessError):
61 self.cs.get(dest, {})

Subscribers

People subscribed via source and target branches