-
-
Save banterability/333365 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fabric.api import * | |
[...] | |
def gzip_assets(): | |
""" | |
GZips every file in the assets directory and places the new file | |
in the gzip directory with the same filename. | |
""" | |
local('python gzip_assets.py') | |
def deploy_to_s3(): | |
""" | |
Deploy the latest built tables to S3. | |
""" | |
env.gzip_path = 'gzip/tables/' | |
local(('s3cmd -P --add-header=Content-encoding:gzip --guess-mime-type sync %(gzip_path)s s3://%(s3_bucket)s/%(project_name)s/') % env) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env python | |
import os | |
import gzip | |
import shutil | |
class FakeTime: | |
def time(self): | |
return 1261130520.0 | |
# Hack to override gzip's time implementation | |
# See: http://stackoverflow.com/questions/264224/setting-the-gzip-timestamp-from-python | |
gzip.time = FakeTime() | |
shutil.rmtree('gzip', ignore_errors=True) | |
shutil.copytree('out', 'gzip') | |
for path, dirs, files in os.walk('gzip'): | |
for filename in files: | |
if filename[-3:] in ['gif', 'png', 'jpg']: | |
continue | |
file_path = os.path.join(path, filename) | |
f_in = open(file_path, 'rb') | |
contents = f_in.readlines() | |
f_in.close() | |
f_out = gzip.open(file_path, 'wb') | |
f_out.writelines(contents) | |
f_out.close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment