| 151 | |
| 152 | |
| 153 | def zip_directory(zipfile_name, source_root): |
| 154 | source_root = os.path.abspath(source_root) |
| 155 | with open(zipfile_name, 'wb') as f: |
| 156 | zip_file = zipfile.ZipFile(f, 'w', zipfile.ZIP_DEFLATED, True) |
| 157 | with contextlib.closing(zip_file) as zf: |
| 158 | for root, dirs, files in os.walk(source_root): |
| 159 | for filename in files: |
| 160 | full_path = os.path.join(root, filename) |
| 161 | relative_path = os.path.relpath(full_path, source_root) |
| 162 | zf.write(full_path, relative_path) |
| 163 | |
| 164 | |
| 165 | def validate_directory(source_root): |