def setup_s3_subdir(self): self.s3_subdirectory = utils.s3_subdirectory() if self.options['skip_commit_check']: return git_commit = get_current_commit_hash(skip_sanity_checks=True) if git_commit != self.s3_subdirectory: raise CommandError("The commit in commit.py doesn't match " "the output of git rev-parse HEAD. " "Run python deploy/create_commit_file.py to " "update commit.py")
def handle(self, *args, **options): from django.conf import settings # set AWS_BUCKET_NAME from options self.AWS_BUCKET_NAME = options.get('aws_bucket_name') if not hasattr(settings, 'STATIC_ROOT'): raise CommandError('STATIC_ROOT must be set in your settings.') else: if not settings.STATIC_ROOT: raise CommandError('STATIC_ROOT must be set in your settings.') try: self.DIRECTORY = get_cache_dir() # Check for AWS keys in settings if not hasattr(settings, 'AWS_ACCESS_KEY_ID') or \ not hasattr(settings, 'AWS_SECRET_ACCESS_KEY'): raise CommandError( 'Missing AWS keys from settings file. Please' + 'supply both AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.') else: self.AWS_ACCESS_KEY_ID = settings.AWS_ACCESS_KEY_ID self.AWS_SECRET_ACCESS_KEY = settings.AWS_SECRET_ACCESS_KEY if not self.AWS_BUCKET_NAME: if not hasattr(settings, 'AWS_BUCKET_NAME'): raise CommandError( 'Missing bucket name from settings file. Please' + ' add the AWS_BUCKET_NAME to your settings file.') else: if not settings.AWS_BUCKET_NAME: raise CommandError('AWS_BUCKET_NAME cannot be empty.') self.AWS_BUCKET_NAME = settings.AWS_BUCKET_NAME self.verbosity = int(options.get('verbosity')) self.prefix = options.get('prefix') if bool(self.prefix) is False: self.prefix = os.path.join(settings.COMPRESS_OUTPUT_DIRNAME, get_current_commit_hash()) self.do_gzip = options.get('gzip') self.do_expires = options.get('expires') self.do_force = options.get('force') # Now call the syncing method to walk the STATIC_ROOT directory and # upload all files found. self.sync_s3() print print "%d files uploaded." % (self.upload_count) print "%d files skipped." % (self.skip_count) except Exception, e: import traceback print("Error uploading: {0}".format(traceback.format_exc())) sys.exit(10)
def handle(self, *args, **options): from django.conf import settings if not hasattr(settings, 'MEDIA_ROOT'): raise CommandError('MEDIA_ROOT must be set in your settings.') else: if not settings.MEDIA_ROOT: raise CommandError('MEDIA_ROOT must be set in your settings.') self.DIRECTORY = get_cache_dir() # Check for AWS keys in settings if not hasattr(settings, 'AWS_ACCESS_KEY_ID') or \ not hasattr(settings, 'AWS_SECRET_ACCESS_KEY'): raise CommandError('Missing AWS keys from settings file. Please' + 'supply both AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.') else: self.AWS_ACCESS_KEY_ID = settings.AWS_ACCESS_KEY_ID self.AWS_SECRET_ACCESS_KEY = settings.AWS_SECRET_ACCESS_KEY if not hasattr(settings, 'AWS_BUCKET_NAME'): raise CommandError('Missing bucket name from settings file. Please' + ' add the AWS_BUCKET_NAME to your settings file.') else: if not settings.AWS_BUCKET_NAME: raise CommandError('AWS_BUCKET_NAME cannot be empty.') self.AWS_BUCKET_NAME = settings.AWS_BUCKET_NAME self.verbosity = int(options.get('verbosity')) self.prefix = options.get('prefix') if bool(self.prefix) is False: self.prefix = os.path.join(settings.COMPRESS_OUTPUT_DIRNAME, get_current_commit_hash()) self.do_gzip = options.get('gzip') self.do_expires = options.get('expires') self.do_force = options.get('force') # Now call the syncing method to walk the MEDIA_ROOT directory and # upload all files found. self.sync_s3() print print "%d files uploaded." % (self.upload_count) print "%d files skipped." % (self.skip_count)
from django.conf import settings from django.core.management.base import BaseCommand from django.contrib import admin from django.contrib.sites.models import Site from django.template.loader import render_to_string import optparse from deploy.git_helpers import get_current_commit_hash from apps import widget from apps.unisubs_compressor.contrib.rjsmin import jsmin # on vagrant .git is a symlink and this needts to be ran before media compilation ;( LAST_COMMIT_GUID = get_current_commit_hash( ) or settings.LAST_COMMIT_GUID.split('/')[-1] def _make_version_debug_string(): """ See Command._append_verion_for_debug We have this as an external function because we need this on compilation and testing deployment """ return '/*unisubs.static_version="%s"*/' % LAST_COMMIT_GUID logging.basicConfig(level=logging.INFO, format='%(asctime)s %(levelname)s %(message)s')
# http://www.gnu.org/licenses/agpl-3.0.html. import sys, os, shutil, subprocess, logging, time from django.conf import settings from django.core.management.base import BaseCommand from django.contrib.sites.models import Site from django.template.loader import render_to_string import optparse from deploy.git_helpers import get_current_commit_hash from apps import widget LAST_COMMIT_GUID = get_current_commit_hash() def _make_version_debug_string(): """ See Command._append_verion_for_debug We have this as an external function because we need this on compilation and testing deployment """ return '/*mirosubs.static_version="%s"*/' % LAST_COMMIT_GUID logging.basicConfig(level=logging.INFO, format='%(asctime)s %(levelname)s %(message)s') MEDIA_ROOT = settings.MEDIA_ROOT
import sys, os, shutil, subprocess, logging, time import re from django.conf import settings from django.core.management.base import BaseCommand from django.contrib.sites.models import Site from django.template.loader import render_to_string import optparse from deploy.git_helpers import get_current_commit_hash from apps import widget LAST_COMMIT_GUID = get_current_commit_hash() def _make_version_debug_string(): """ See Command._append_verion_for_debug We have this as an external function because we need this on compilation and testing deployment """ return '/*unisubs.static_version="%s"*/' % LAST_COMMIT_GUID logging.basicConfig(level=logging.INFO, format='%(asctime)s %(levelname)s %(message)s')
from django.core.management.base import BaseCommand, CommandError from django.conf import settings from deploy.git_helpers import get_current_commit_hash import staticmedia import widget LEGACYJS_DIR = os.path.join(settings.STATIC_ROOT, 'legacy-js') JS_LIB = os.path.join(settings.PROJECT_ROOT, "media") CLOSURE_LIB = os.path.join(JS_LIB, "js", "closure-library") FLOWPLAYER_JS = os.path.join(settings.PROJECT_ROOT, "media/flowplayer/flowplayer-3.2.13.min.js") COMPILER_PATH = os.path.join(settings.PROJECT_ROOT, "closure", "compiler.jar") LAST_COMMIT_GUID = get_current_commit_hash() or settings.LAST_COMMIT_GUID # Old settings that we need to do the builds, but we don't want to keep in # settings.py # paths provided relative to media/js JS_CORE = \ ['js/unisubs.js', 'js/rpc.js', 'js/clippy.js', 'js/flash.js', 'js/spinner.js', 'js/sliderbase.js', 'js/closingwindow.js', 'js/loadingdom.js', 'js/tracker.js',
def get_cache_base_url(): commit_hash = get_current_commit_hash() return "%s/%s/%s" % (settings.MEDIA_URL, settings.COMPRESS_OUTPUT_DIRNAME, commit_hash)
def get_cache_dir(): commit_hash = get_current_commit_hash() return os.path.join(settings.MEDIA_ROOT, settings.COMPRESS_OUTPUT_DIRNAME, commit_hash)