def deploy(remote='origin', reload=False): """ Deploy the latest app to S3 and, if configured, to our servers. """ require('settings', provided_by=[production, staging]) if app_config.DEPLOY_TO_SERVERS: require('branch', provided_by=[stable, master, branch]) if (app_config.DEPLOYMENT_TARGET == 'production' and env.branch != 'stable'): utils.confirm( colored("You are trying to deploy the '%s' branch to production.\nYou should really only deploy a stable branch.\nDo you know what you're doing?" % env.branch, "red") ) servers.checkout_latest(remote) if app_config.DEPLOY_CRONTAB: servers.install_crontab() if app_config.DEPLOY_SERVICES: servers.deploy_confs() update() render.render_all() flat.deploy_folder( app_config.S3_BUCKET, 'www', app_config.PROJECT_SLUG, headers={ 'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE }, ignore=[] )
def deploy_cards(): """ Deploy content cards. """ require('settings', provided_by=[production, staging]) local('rm -rf .cards_html') COPY = copytext.Copy(app_config.COPY_PATH) if env.settings == 'production': state = COPY['meta']['prod_state']['value'] elif env.settings == 'staging': state = COPY['meta']['stage_state']['value'] else: state = COPY['meta']['dev_state']['value'] script = COPY[state] for row in script: render.render_card_route(row['function'], row['params']) render.render_current_state() render.render_index() flat.deploy_folder( app_config.S3_BUCKET, '.cards_html', '', headers={ 'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE } )
def update_price(): # pull today now = datetime.now() today = ("%s-%02d-%02d" % (now.year, now.month, now.day)) quotes = ystockquote.get_historical_prices('SPY', '2015-01-15', today) #pull data #writing json with open('www/live-data/price.json', 'w') as file: json.dump(quotes, file) #get current price current_price = ystockquote.get_price('SPY') current_date = now.strftime('%Y-%m-%d') current_time = now.strftime('%H:%M:%S') current_value = str(current_date) + "," + str(current_time) + "," + str( current_price) header = "date,time,price" with open('www/live-data/current.csv', 'wb') as f: fwriter = csv.writer(f, delimiter=" ") fwriter.writerow([header]) fwriter.writerow([current_value]) if app_config.DEPLOYMENT_TARGET: flat.deploy_folder('www/live-data', 'live-data', max_age=app_config.DEFAULT_MAX_AGE)
def deploy(remote='origin', reload=False): """ Deploy the latest app to S3 and, if configured, to our servers. """ require('settings', provided_by=[production, staging]) update() render.render_all() # Clear files that should never be deployed local('rm -rf www/live-data') flat.deploy_folder( app_config.S3_BUCKET, 'www', app_config.PROJECT_SLUG, headers={'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE}, ignore=['www/assets/*', 'www/live-data/*']) flat.deploy_folder( app_config.S3_BUCKET, 'www/assets', '%s/assets' % app_config.PROJECT_SLUG, headers={'Cache-Control': 'max-age=%i' % app_config.ASSETS_MAX_AGE}) if reload: reset_browsers() if not check_timestamp(): reset_browsers()
def deploy(quick=None, remote='origin', reload=False): """ Deploy the latest app to S3 and, if configured, to our servers. """ require('settings', provided_by=[random_prod, production, staging]) if app_config.DEPLOYMENT_TARGET == 'production' or app_config.DEPLOYMENT_TARGET == 'random_prod': utils.confirm( colored( "You are trying to deploy to production this project %s.\nDo you know what you're doing?" % app_config.PROJECT_SLUG, "red")) if app_config.DEPLOY_TO_SERVERS: require('branch', provided_by=[stable, master, branch]) if (app_config.DEPLOYMENT_TARGET == 'production' and env.branch != 'stable'): utils.confirm( colored( "You are trying to deploy the '%s' branch to production.\nYou should really only deploy a stable branch.\nDo you know what you're doing?" % env.branch, "red")) servers.checkout_latest(remote) servers.fabcast('text.update') servers.fabcast('data.update') servers.fabcast('assets.sync') if app_config.DEPLOY_CRONTAB: servers.install_crontab() if app_config.DEPLOY_SERVICES: servers.deploy_confs() if quick != 'quick': update() render.render_all() # Clear files that should never be deployed local('rm -rf www/live-data') flat.deploy_folder( app_config.S3_BUCKET, 'www', app_config.PROJECT_SLUG, headers={'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE}, ignore=['www/assets/*', 'www/live-data/*']) flat.deploy_folder( app_config.S3_BUCKET, 'www/assets', '%s/assets' % app_config.PROJECT_SLUG, headers={'Cache-Control': 'max-age=%i' % app_config.ASSETS_MAX_AGE}) if reload: reset_browsers() if not check_timestamp(): reset_browsers()
def deploy(slug): """ Deploy the latest app to S3 and, if configured, to our servers. """ require('settings', provided_by=[production, staging]) if not slug: print 'You must specify a project slug, like this: "deploy:slug"' return update_copy(slug) assets.sync(slug) render(slug) graphic_root = '%s/%s' % (app_config.GRAPHICS_PATH, slug) s3_root = '%s/graphics/%s' % (app_config.PROJECT_SLUG, slug) graphic_assets = '%s/assets' % graphic_root s3_assets = '%s/assets' % s3_root flat.deploy_folder( graphic_root, s3_root, headers={ 'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE }, ignore=['%s/*' % graphic_assets] ) flat.deploy_folder( graphic_assets, s3_assets, headers={ 'Cache-Control': 'max-age=%i' % app_config.ASSETS_MAX_AGE } )
def deploy_single(path): """ Deploy a single project to S3 and, if configured, to our servers. """ require('settings', provided_by=[production, staging]) slug, abspath = utils.parse_path(path) graphic_root = '%s/%s' % (abspath, slug) s3_root = '%s/graphics/%s' % (app_config.PROJECT_SLUG, slug) graphic_assets = '%s/assets' % graphic_root s3_assets = '%s/assets' % s3_root graphic_node_modules = '%s/node_modules' % graphic_root graphic_config = load_graphic_config(graphic_root) use_assets = getattr(graphic_config, 'USE_ASSETS', True) default_max_age = getattr(graphic_config, 'DEFAULT_MAX_AGE', None) or app_config.DEFAULT_MAX_AGE assets_max_age = getattr(graphic_config, 'ASSETS_MAX_AGE', None) or app_config.ASSETS_MAX_AGE update_copy(path) if use_assets: error = assets.sync(path) if error: return render.render(path) flat.deploy_folder( graphic_root, s3_root, headers={'Cache-Control': 'max-age=%i' % default_max_age}, ignore=[ '%s/*' % graphic_assets, '%s/*' % graphic_node_modules, # Ignore files unused on static S3 server '*.xls', '*.xlsx', '*.pyc', '*.py', '*.less', '*.bak', '%s/base_template.html' % graphic_root, '%s/child_template.html' % graphic_root, '%s/README.md' % graphic_root ]) if use_assets: flat.deploy_folder( graphic_assets, s3_assets, headers={'Cache-Control': 'max-age=%i' % assets_max_age}, ignore=['%s/private/*' % graphic_assets]) # Need to explicitly point to index.html for the AWS staging link file_suffix = '' if env.settings == 'staging': file_suffix = 'index.html' print '' print '%s URL: %s/graphics/%s/%s' % ( env.settings.capitalize(), app_config.S3_BASE_URL, slug, file_suffix)
def deploy_embeds(): render.render_embeds() flat.deploy_folder( app_config.S3_BUCKET, 'www/embeds', '%s%s/embeds' % (app_config.FACTCHECKS_DIRECTORY_PREFIX, app_config.CURRENT_FACTCHECK), headers={'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE})
def deploy(quick=None, remote='origin', reload=False): """ Deploy the latest app to S3 and, if configured, to our servers. """ require('settings', provided_by=[production, staging]) if app_config.DEPLOY_TO_SERVERS: require('branch', provided_by=[stable, master, branch]) if (app_config.DEPLOYMENT_TARGET == 'production' and env.branch != 'stable'): utils.confirm( colored("You are trying to deploy the '%s' branch to production.\nYou should really only deploy a stable branch.\nDo you know what you're doing?" % env.branch, "red") ) servers.checkout_latest(remote) servers.fabcast('text.update') servers.fabcast('assets.sync') servers.fabcast('data.update') if app_config.DEPLOY_CRONTAB: servers.install_crontab() if app_config.DEPLOY_SERVICES: servers.deploy_confs() if quick != 'quick': update() render.render_all() # Clear files that should never be deployed local('rm -rf www/live-data') flat.deploy_folder( app_config.S3_BUCKET, 'www', app_config.PROJECT_SLUG, headers={ 'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE }, ignore=['www/assets/*', 'www/live-data/*'] ) flat.deploy_folder( app_config.S3_BUCKET, 'www/assets', '%s/assets' % app_config.PROJECT_SLUG, headers={ 'Cache-Control': 'max-age=%i' % app_config.ASSETS_MAX_AGE } ) if reload: reset_browsers() if not check_timestamp(): reset_browsers()
def deploy(remote='origin', reload=False): """ Deploy the latest app to S3 and, if configured, to our servers. """ require('settings', provided_by=[production, staging]) if app_config.DEPLOY_TO_SERVERS: require('branch', provided_by=[stable, master, branch]) if (app_config.DEPLOYMENT_TARGET == 'production' and env.branch != 'stable'): utils.confirm( colored( "You are trying to deploy the '%s' branch to production.\nYou should really only deploy a stable branch.\nDo you know what you're doing?" % env.branch, "red")) servers.checkout_latest(remote) # servers.fabcast('text.update') # servers.fabcast('assets.sync') # servers.fabcast('data.update') if app_config.DEPLOY_CRONTAB: servers.install_crontab() if app_config.DEPLOY_SERVICES: servers.deploy_confs() update() render.render_all() # Clear files that should never be deployed local('rm -rf www/live-data') flat.deploy_folder( app_config.S3_BUCKET, 'www', '%s%s' % (app_config.DEBATE_DIRECTORY_PREFIX, app_config.CURRENT_DEBATE), headers={'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE}, ignore=['www/assets/*', 'www/live-data/*']) flat.deploy_folder( app_config.S3_BUCKET, 'www/assets', '%s%s/assets' % (app_config.DEBATE_DIRECTORY_PREFIX, app_config.CURRENT_DEBATE), headers={'Cache-Control': 'max-age=%i' % app_config.ASSETS_MAX_AGE}) # DEPLOY STATIC FACTCHECK FROM LOCAL ENVIRONMENT if app_config.DEPLOY_STATIC_FACTCHECK: execute('deploy_factcheck') if reload: reset_browsers() if not check_timestamp(): reset_browsers()
def deploy_single(path): """ Deploy a single project to S3 and, if configured, to our servers. """ require('settings', provided_by=[production, staging]) slug, abspath = utils.parse_path(path) graphic_root = '%s/%s' % (abspath, slug) s3_root = '%s/graphics/%s' % (app_config.PROJECT_SLUG, slug) graphic_assets = '%s/assets' % graphic_root s3_assets = '%s/assets' % s3_root graphic_node_modules = '%s/node_modules' % graphic_root graphic_config = load_graphic_config(graphic_root) use_assets = getattr(graphic_config, 'USE_ASSETS', True) default_max_age = getattr(graphic_config, 'DEFAULT_MAX_AGE', None) or app_config.DEFAULT_MAX_AGE assets_max_age = getattr(graphic_config, 'ASSETS_MAX_AGE', None) or app_config.ASSETS_MAX_AGE update_copy(path) if use_assets: error = assets.sync(path) if error: return render.render(path) flat.deploy_folder( graphic_root, s3_root, headers={ 'Cache-Control': 'max-age=%i' % default_max_age }, ignore=['%s/*' % graphic_assets, '%s/*' % graphic_node_modules, # Ignore files unused on static S3 server '*.xls', '*.xlsx', '*.pyc', '*.py', '*.less', '*.bak', '%s/base_template.html' % graphic_root, '%s/child_template.html' % graphic_root, '%s/README.md' % graphic_root] ) if use_assets: flat.deploy_folder( graphic_assets, s3_assets, headers={ 'Cache-Control': 'max-age=%i' % assets_max_age }, ignore=['%s/private/*' % graphic_assets] ) # Need to explicitly point to index.html for the AWS staging link file_suffix = '' if env.settings == 'staging': file_suffix = 'index.html' print '' print '%s URL: %s/graphics/%s/%s' % (env.settings.capitalize(), app_config.S3_BASE_URL, slug, file_suffix)
def deploy_factcheck(): render.render_factcheck() flat.deploy_folder( app_config.S3_BUCKET, '.factcheck', '%s%s' % (app_config.DEBATE_DIRECTORY_PREFIX, app_config.CURRENT_DEBATE), headers={'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE}) if app_config.DEPLOYMENT_TARGET == 'production': execute('deploy_transcript_backup')
def deploy_transcript_backup(): """ deploy to our backup S3 bucket election-backup.apps.npr.org """ now = datetime.now().strftime('%Y-%m-%d-%H:%M:%S') flat.deploy_folder( app_config.ARCHIVE_S3_BUCKET, '.copydoc', 'debates/%s-%s' % (now, app_config.CURRENT_DEBATE), headers={'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE})
def backup(): """ Back up the database """ import data today = time.strftime('%Y-%m-%d') dst_directory = 'backup/{0}'.format(today) dump_directory = '/tmp/graeae-backup/{0}'.format(today) data.dump_db(dump_directory) flat.deploy_folder(app_config.BACKUP_S3_BUCKET, dump_directory, dst_directory) local('rm -Rf /tmp/graeae-backup')
def deploy_test(): require('settings', provided_by=[production, staging]) render.render_all() # Clear files that should never be deployed local('rm -rf www/live-data') flat.deploy_folder( 'www', app_config.PROJECT_SLUG, headers={'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE}, ignore=['www/assets/*'])
def deploy_liveblog_backup(): """ deploy to our backup S3 bucket election-backup.apps.npr.org """ now = datetime.now().strftime('%Y-%m-%d-%H:%M:%S') flat.deploy_folder( app_config.ARCHIVE_S3_BUCKET, '.liveblog', 'liveblogs/%s/%s-%s' % (app_config.CURRENT_LIVEBLOG, now, app_config.PROJECT_SLUG), headers={'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE})
def deploy_results_data(): """ Deploy results cards. """ local('rm -rf .cards_html/data') render.render_results_json() flat.deploy_folder( app_config.S3_BUCKET, '.cards_html/data', 'data', headers={ 'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE } )
def deploy(remote="origin"): """ Deploy the latest app to S3 and, if configured, to our servers. """ require("settings", provided_by=[production, staging]) if app_config.DEPLOY_TO_SERVERS: require("branch", provided_by=[stable, master, branch]) if app_config.DEPLOYMENT_TARGET == "production" and env.branch != "stable": utils.confirm( colored( "You are trying to deploy the '%s' branch to production.\nYou should really only deploy a stable branch.\nDo you know what you're doing?" % env.branch, "red", ) ) servers.checkout_latest(remote) servers.fabcast("text.update") servers.fabcast("assets.sync") servers.fabcast("data.update") if app_config.DEPLOY_CRONTAB: servers.install_crontab() if app_config.DEPLOY_SERVICES: servers.deploy_confs() update() render.render_all() # Clear files that should never be deployed local("rm -rf www/live-data") flat.deploy_folder( "www", app_config.PROJECT_SLUG, headers={"Cache-Control": "max-age=%i" % app_config.DEFAULT_MAX_AGE}, ignore=["www/assets/*", "www/live-data/*"], ) flat.deploy_folder( "www/assets", "%s/assets" % app_config.PROJECT_SLUG, headers={"Cache-Control": "max-age=%i" % app_config.ASSETS_MAX_AGE}, )
def deploy_delegates_data(): """ Deploy results cards. """ require('settings', provided_by=[production, staging]) local('rm -rf .cards_html/data') render.render_delegates_json() flat.deploy_folder( app_config.S3_BUCKET, '.cards_html/data', 'data', headers={ 'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE } )
def deploy(analyse=True, remote='origin'): """ Deploy the latest app to S3 and, if configured, to our servers. """ require('settings', provided_by=[production, staging]) if app_config.DEPLOY_TO_SERVERS: require('branch', provided_by=[stable, master, branch]) if (app_config.DEPLOYMENT_TARGET == 'production' and env.branch != 'stable'): utils.confirm( colored( "You are trying to deploy the '%s' branch to production.\nYou should really only deploy a stable branch.\nDo you know what you're doing?" % env.branch, "red")) servers.checkout_latest(remote) servers.fabcast('text.update') servers.fabcast('assets.sync') if app_config.DEPLOY_CRONTAB: servers.install_crontab() if app_config.DEPLOY_SERVICES: servers.deploy_confs() if analyse == True: execute('analysis.analyse') execute('render.render_all') flat.deploy_folder(app_config.S3_BUCKET['bucket_name'], 'www', app_config.PROJECT_SLUG, headers={ 'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE }, ignore=['www/assets/*']) flat.deploy_folder(app_config.S3_BUCKET['bucket_name'], 'www/assets', '%s/assets' % app_config.PROJECT_SLUG, headers={ 'Cache-Control': 'max-age=%i' % app_config.ASSETS_MAX_AGE })
def _deploy_to_s3(path='.gzip'): """ Deploy the gzipped stuff to S3. """ # Clear files that should never be deployed flat.deploy_folder( app_config.S3_BUCKET, 'www', app_config.PROJECT_SLUG, headers={'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE}, ignore=['www/assets/*', 'www/live-data/*']) flat.deploy_folder( app_config.S3_BUCKET, 'www/assets', '%s/assets' % app_config.PROJECT_SLUG, headers={'Cache-Control': 'max-age=%i' % app_config.ASSETS_MAX_AGE})
def deploy_liveblog(): """ Renders and deploys the liveblog and preview html """ require('settings', provided_by=[production, staging]) render.render_liveblog() flat.deploy_folder( app_config.S3_BUCKET, '.liveblog', '%s%s' % (app_config.LIVEBLOG_DIRECTORY_PREFIX, app_config.CURRENT_LIVEBLOG), headers={'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE}) # TODO turn backup on inauguration day if app_config.DEPLOYMENT_TARGET == 'production': execute('deploy_liveblog_backup')
def deploy(remote='origin'): """ Deploy the latest app to S3 and, if configured, to our servers. """ require('settings', provided_by=[production, staging]) if env.get('deploy_to_servers', False): require('branch', provided_by=[stable, master, branch]) if (env.settings == 'production' and env.branch != 'stable'): _confirm("You are trying to deploy the '%(branch)s' branch to production.\nYou should really only deploy a stable branch.\nDo you know what you're doing?" % env) render_pages() _gzip_www() print app_config.S3_BUCKET flat.deploy_folder( app_config.S3_BUCKET, 'www', app_config.PROJECT_SLUG, headers={ 'Cache-Control': 'max-age=20' }, ignore=['www/assets/*', 'www/live-data/*'] ) flat.deploy_folder( app_config.S3_BUCKET, 'www/assets', '%s/assets' % app_config.PROJECT_SLUG, headers={ 'Cache-Control': 'max-age=86400' } ) if env['deploy_to_servers']: checkout_latest(remote) if env['deploy_crontab']: install_crontab() if env['deploy_services']: deploy_confs()
def deploy(remote='origin'): """ Deploy the latest app to S3 and, if configured, to our servers. """ require('settings', provided_by=[production, staging]) if app_config.DEPLOY_TO_SERVERS: require('branch', provided_by=[stable, master, branch]) if (app_config.DEPLOYMENT_TARGET == 'production' and env.branch != 'stable'): utils.confirm( colored("You are trying to deploy the '%s' branch to production.\nYou should really only deploy a stable branch.\nDo you know what you're doing?" % env.branch, "red") ) servers.checkout_latest(remote) servers.fabcast('text.update') servers.fabcast('assets.sync') servers.fabcast('data.update') if app_config.DEPLOY_CRONTAB: servers.install_crontab() if app_config.DEPLOY_SERVICES: servers.deploy_confs() update() render.render_all() # Clear files that should never be deployed local('rm -rf www/live-data') flat.deploy_folder( 'www', app_config.PROJECT_SLUG, max_age=app_config.DEFAULT_MAX_AGE, ignore=['www/assets/*', 'www/live-data/*'] ) flat.deploy_folder( 'www/assets', '%s/assets' % app_config.PROJECT_SLUG, max_age=app_config.ASSETS_MAX_AGE )
def deploy(path, slug=None): """ manual deploy parts of a project that needs fixing """ require('settings', provided_by=[production, staging]) if not slug: slug = path utils.confirm( colored( "You are trying to override parts of %s project in %s.\n" "Do you know what you're doing?" % (slug, env.settings), "red")) flat.deploy_folder( app_config.S3_BUCKET, path, slug, headers={'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE})
def deploy(): """ Deploy the latest app to S3 and, if configured, to our servers. """ require('settings', provided_by=['production', 'staging']) require('static_path', provided_by=['tumblr']) execute('update') render() flat.deploy_folder('%s/www' % env.static_path, '%s/%s' % (app_config.PROJECT_SLUG, env.static_path), max_age=app_config.DEFAULT_MAX_AGE, ignore=['%s/www/assets/*' % env.static_path]) flat.deploy_folder('%s/www/assets' % env.static_path, '%s/%s/assets' % (app_config.PROJECT_SLUG, env.static_path), max_age=app_config.ASSETS_MAX_AGE)
def deploy(slug=''): """ Deploy the latest app to S3 and, if configured, to our servers. """ require('settings', provided_by=[staging, production]) require('slug', provided_by=[post]) update() render.render_all() flat.deploy_folder('%s/www' % env.static_path, '%s/%s' % (env.post_root, env.post_config.DEPLOY_SLUG), max_age=app_config.DEFAULT_MAX_AGE, ignore=['%s/www/assets/*' % env.static_path]) flat.deploy_folder('%s/www/assets' % env.static_path, '%s/%s/assets' % (env.post_root, env.post_config.DEPLOY_SLUG), max_age=app_config.ASSETS_MAX_AGE, warn_threshold=app_config.WARN_THRESHOLD)
def deploy(remote='origin', reload=False): """ Deploy the latest app to S3 and, if configured, to our servers. """ require('settings', provided_by=[production, staging, electron]) render.render_all() if env.settings == 'electron': if not os.path.exists('electron'): os.makedirs('electron') local('npm run-script pack') if env.settings == 'fileserver': local('rsync -vr www/ %s@%s:%s/%s' % ( app_config.FILE_SERVER_USER, app_config.FILE_SERVER, app_config.FILE_SERVER_PATH, app_config.PROJECT_SLUG )) if env.settings == 'production' or env.settings == 'staging': flat.deploy_folder( app_config.S3_BUCKET, 'www', app_config.PROJECT_SLUG, headers={ 'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE }, ignore=['www/img/*', 'www/live-data/*'] ) flat.deploy_folder( app_config.S3_BUCKET, 'www/img', '%s/img' % app_config.PROJECT_SLUG, headers={ 'Cache-Control': 'max-age=%i' % app_config.ASSETS_MAX_AGE } )
def reset_browsers(): """ Deploy a timestamp so the client will reset their page. For bugfixes """ require('settings', provided_by=[production, staging]) if not os.path.exists('www/live-data'): os.makedirs('www/live-data') payload = {} now = datetime.now().strftime('%s') payload['timestamp'] = now with open('www/live-data/timestamp.json', 'w') as f: json.dump(payload, f) flat.deploy_folder( app_config.S3_BUCKET, 'www/live-data', '%s/live-data' % app_config.PROJECT_SLUG, headers={'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE})
def deploy(remote="origin", reload=False): """ Deploy the latest app to S3 and, if configured, to our servers. """ require("settings", provided_by=[production, staging, electron]) render.render_all() if env.settings == "electron": if not os.path.exists("electron"): os.makedirs("electron") local("npm run-script pack") if env.settings == "fileserver": local( "rsync -vr www/ %s@%s:%s/%s" % ( app_config.FILE_SERVER_USER, app_config.FILE_SERVER, app_config.FILE_SERVER_PATH, app_config.PROJECT_SLUG, ) ) if env.settings == "production" or env.settings == "staging": flat.deploy_folder( app_config.S3_BUCKET, "www", app_config.PROJECT_SLUG, headers={"Cache-Control": "max-age=%i" % app_config.DEFAULT_MAX_AGE}, ignore=["www/img/*", "www/live-data/*"], ) flat.deploy_folder( app_config.S3_BUCKET, "www/img", "%s/img" % app_config.PROJECT_SLUG, headers={"Cache-Control": "max-age=%i" % app_config.ASSETS_MAX_AGE}, )
def deploy(): """ Deploy the latest app to S3 and, if configured, to our servers. """ require('settings', provided_by=['production', 'staging']) require('static_path', provided_by=['tumblr']) execute('update') render() flat.deploy_folder( '%s/www' % env.static_path, '%s/%s' % (app_config.PROJECT_SLUG, env.static_path), max_age=app_config.DEFAULT_MAX_AGE, ignore=['%s/www/assets/*' % env.static_path] ) flat.deploy_folder( '%s/www/assets' % env.static_path, '%s/%s/assets' % (app_config.PROJECT_SLUG, env.static_path), max_age=app_config.ASSETS_MAX_AGE )
def deploy(remote='origin'): """ Deploy the latest app to S3 and, if configured, to our servers. """ require('settings', provided_by=[production, staging]) if env.get('deploy_to_servers', False): require('branch', provided_by=[stable, master, branch]) if (env.settings == 'production' and env.branch != 'stable'): _confirm( "You are trying to deploy the '%(branch)s' branch to production.\nYou should really only deploy a stable branch.\nDo you know what you're doing?" % env) render_pages() _gzip_www() print app_config.S3_BUCKET flat.deploy_folder(app_config.S3_BUCKET, 'www', app_config.PROJECT_SLUG, headers={'Cache-Control': 'max-age=20'}, ignore=['www/assets/*', 'www/live-data/*']) flat.deploy_folder(app_config.S3_BUCKET, 'www/assets', '%s/assets' % app_config.PROJECT_SLUG, headers={'Cache-Control': 'max-age=86400'}) if env['deploy_to_servers']: checkout_latest(remote) if env['deploy_crontab']: install_crontab() if env['deploy_services']: deploy_confs()
def deploy(slug=''): """ Deploy the latest app to S3 and, if configured, to our servers. """ require('settings', provided_by=[staging, production]) require('slug', provided_by=[post]) update() render.render_all() flat.deploy_folder( '%s/www' % env.static_path, '%s/%s' % (env.post_root, env.post_config.DEPLOY_SLUG), max_age=app_config.DEFAULT_MAX_AGE, ignore=['%s/www/assets/*' % env.static_path] ) flat.deploy_folder( '%s/www/assets' % env.static_path, '%s/%s/assets' % (env.post_root, env.post_config.DEPLOY_SLUG), max_age=app_config.ASSETS_MAX_AGE, warn_threshold=app_config.WARN_THRESHOLD )
def _deploy_to_s3(path='.gzip'): """ Deploy the gzipped stuff to S3. """ # Clear files that should never be deployed flat.deploy_folder( app_config.S3_BUCKET, 'www', app_config.PROJECT_SLUG, headers={ 'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE }, ignore=['www/assets/*', 'www/live-data/*'] ) flat.deploy_folder( app_config.S3_BUCKET, 'www/assets', '%s/assets' % app_config.PROJECT_SLUG, headers={ 'Cache-Control': 'max-age=%i' % app_config.ASSETS_MAX_AGE } )
def deploy(slug): """ Deploy the latest app to S3 and, if configured, to our servers. """ require('settings', provided_by=[production, staging]) if not slug: print 'You must specify a project slug, like this: "deploy:slug"' return graphic_root = '%s/%s' % (app_config.GRAPHICS_PATH, slug) s3_root = '%s/graphics/%s' % (app_config.PROJECT_SLUG, slug) graphic_assets = '%s/assets' % graphic_root s3_assets = '%s/assets' % s3_root graphic_config = load_graphic_config(graphic_root) use_assets = getattr(graphic_config, 'USE_ASSETS', True) default_max_age = getattr(graphic_config, 'DEFAULT_MAX_AGE', None) or app_config.DEFAULT_MAX_AGE assets_max_age = getattr(graphic_config, 'ASSETS_MAX_AGE', None) or app_config.ASSETS_MAX_AGE update_copy(slug) if use_assets: assets.sync(slug) render.render(slug) flat.deploy_folder( graphic_root, s3_root, headers={ 'Cache-Control': 'max-age=%i' % default_max_age }, ignore=['%s/*' % graphic_assets] ) # Deploy parent assets flat.deploy_folder( 'www', app_config.PROJECT_SLUG, headers={ 'Cache-Control': 'max-age=%i' % default_max_age } ) if use_assets: flat.deploy_folder( graphic_assets, s3_assets, headers={ 'Cache-Control': 'max-age=%i' % assets_max_age } ) print '' print '%s URL: %s/graphics/%s/' % (env.settings.capitalize(), app_config.S3_BASE_URL, slug)
def deploy_client(reload=False): """ Deploy the latest app to S3. """ require('settings', provided_by=[production, staging]) update() render.render_all() render.render_current_state(folder='www') # Clear files that should never be deployed local('rm -rf www/live-data') flat.deploy_folder( app_config.S3_BUCKET, 'www', '', headers={ 'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE }, ignore=['www/assets/*', 'www/live-data/*'] ) flat.deploy_folder( app_config.S3_BUCKET, 'www/assets', 'assets', headers={ 'Cache-Control': 'max-age=%i' % app_config.ASSETS_MAX_AGE } ) if reload: reset_browsers() if not check_timestamp(): reset_browsers()
def deploy(remote='origin', reload=False): """ Deploy the latest app to S3 and, if configured, to our servers. """ require('settings', provided_by=[production, staging]) update() render.render_all() # Clear files that should never be deployed local('rm -rf www/live-data') flat.deploy_folder( app_config.S3_BUCKET, 'www', app_config.PROJECT_SLUG, headers={ 'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE }, ignore=['www/assets/*', 'www/live-data/*'] ) flat.deploy_folder( app_config.S3_BUCKET, 'www/assets', '%s/assets' % app_config.PROJECT_SLUG, headers={ 'Cache-Control': 'max-age=%i' % app_config.ASSETS_MAX_AGE } ) if reload: reset_browsers() if not check_timestamp(): reset_browsers()
def reset_browsers(): """ Deploy a timestamp so the client will reset their page. For bugfixes """ require('settings', provided_by=[production, staging]) if not os.path.exists('www/live-data'): os.makedirs('www/live-data') payload = {} now = datetime.now().strftime('%s') payload['timestamp'] = now with open('www/live-data/timestamp.json', 'w') as f: json.dump(payload, f) flat.deploy_folder( app_config.S3_BUCKET, 'www/live-data', '%s/live-data' % app_config.PROJECT_SLUG, headers={ 'Cache-Control': 'max-age=%i' % app_config.DEFAULT_MAX_AGE } )
def deploy_single(slug): """ Deploy a single project to S3 and, if configured, to our servers. """ require('settings', provided_by=[production, staging]) graphic_root = '%s/%s' % (app_config.GRAPHICS_PATH, slug) s3_root = '%s/graphics/%s' % (app_config.PROJECT_SLUG, slug) graphic_assets = '%s/assets' % graphic_root s3_assets = '%s/assets' % s3_root graphic_config = load_graphic_config(graphic_root) use_assets = getattr(graphic_config, 'USE_ASSETS', True) default_max_age = getattr(graphic_config, 'DEFAULT_MAX_AGE', None) or app_config.DEFAULT_MAX_AGE assets_max_age = getattr(graphic_config, 'ASSETS_MAX_AGE', None) or app_config.ASSETS_MAX_AGE update_copy(slug) if use_assets: assets.sync(slug) render.render(slug) flat.deploy_folder( graphic_root, s3_root, headers={ 'Cache-Control': 'max-age=%i' % default_max_age }, ignore=['%s/*' % graphic_assets] ) # Deploy parent assets flat.deploy_folder( 'www', app_config.PROJECT_SLUG, headers={ 'Cache-Control': 'max-age=%i' % default_max_age } ) if use_assets: flat.deploy_folder( graphic_assets, s3_assets, headers={ 'Cache-Control': 'max-age=%i' % assets_max_age } ) print '' print '%s URL: %s/graphics/%s/' % (env.settings.capitalize(), app_config.S3_BASE_URL, slug)
def deploy(remote='origin'): """ Deploy the latest app to S3 and, if configured, to our servers. """ require('settings', provided_by=[production, staging]) if app_config.DEPLOY_TO_SERVERS: require('branch', provided_by=[stable, master, branch]) if (app_config.DEPLOYMENT_TARGET == 'production' and env.branch != 'stable'): utils.confirm( colored("You are trying to deploy the '%s' branch to production.\nYou should really only deploy a stable branch.\nDo you know what you're doing?" % env.branch, "red") ) servers.checkout_latest(remote) servers.fabcast('text.update') servers.fabcast('assets.sync') servers.fabcast('data.update') if app_config.DEPLOY_CRONTAB: servers.install_crontab() if app_config.DEPLOY_SERVICES: servers.deploy_confs() update() render.render_all() # Clear files that should never be deployed local('rm -rf www/live-data') flat.deploy_folder( 'www', app_config.PROJECT_SLUG, max_age=app_config.DEFAULT_MAX_AGE, ignore=['www/assets/*'] ) flat.deploy_folder( '.briefings_html', app_config.PROJECT_SLUG, max_age=app_config.DEFAULT_MAX_AGE, ) flat.deploy_folder( 'www/assets', '%s/assets' % app_config.PROJECT_SLUG, max_age=app_config.ASSETS_MAX_AGE )
def deploy(slug): """ Deploy the latest app to S3 and, if configured, to our servers. """ require("settings", provided_by=[production, staging]) if not slug: print 'You must specify a project slug, like this: "deploy:slug"' return graphic_root = "%s/%s" % (app_config.GRAPHICS_PATH, slug) s3_root = "%s/graphics/%s" % (app_config.PROJECT_SLUG, slug) graphic_assets = "%s/assets" % graphic_root s3_assets = "%s/assets" % s3_root graphic_config = _graphic_config(slug) use_assets = getattr(graphic_config, "USE_ASSETS", True) default_max_age = getattr(graphic_config, "DEFAULT_MAX_AGE", None) or app_config.DEFAULT_MAX_AGE assets_max_age = getattr(graphic_config, "ASSETS_MAX_AGE", None) or app_config.ASSETS_MAX_AGE update_copy(slug) if use_assets: assets.sync(slug) render.render(slug) flat.deploy_folder( graphic_root, s3_root, headers={"Cache-Control": "max-age=%i" % default_max_age}, ignore=["%s/*" % graphic_assets], ) # Deploy parent assets flat.deploy_folder("www", app_config.PROJECT_SLUG, headers={"Cache-Control": "max-age=%i" % default_max_age}) if use_assets: flat.deploy_folder(graphic_assets, s3_assets, headers={"Cache-Control": "max-age=%i" % assets_max_age}) print "" print "%s URL: %s/graphics/%s/" % (env.settings.capitalize(), app_config.S3_BASE_URL, slug)
def deploy_single(path): """ Deploy a single project to S3 and, if configured, to our servers. """ require('settings', provided_by=[production, staging]) SLACK_TOKEN = os.environ.get('SLACK_TOKEN') if SLACK_TOKEN == None: print "Can't find the Slack Token. Source your bash." return slack_client = SlackClient(SLACK_TOKEN) slug, abspath = utils.parse_path(path) graphic_root = '%s/%s' % (abspath, slug) s3_root = '%s/%s' % (app_config.PROJECT_SLUG, slug) graphic_assets = '%s/assets' % graphic_root s3_assets = '%s/assets' % s3_root graphic_node_modules = '%s/node_modules' % graphic_root graphic_config = load_graphic_config(graphic_root) use_assets = getattr(graphic_config, 'USE_ASSETS', True) default_max_age = getattr(graphic_config, 'DEFAULT_MAX_AGE', None) or app_config.DEFAULT_MAX_AGE assets_max_age = getattr(graphic_config, 'ASSETS_MAX_AGE', None) or app_config.ASSETS_MAX_AGE update_copy(path) if use_assets: error = assets.sync(path) if error: return render.render(path) flat.deploy_folder( graphic_root, s3_root, headers={ 'Cache-Control': 'max-age=%i' % default_max_age }, ignore=['%s/*' % graphic_assets, '%s/*' % graphic_node_modules, # Ignore files unused on static S3 server '*.xls', '*.xlsx', '*.pyc', '*.py', '*.less', '*.bak', '%s/base_template.html' % graphic_root, '%s/child_template.html' % graphic_root] ) if use_assets: flat.deploy_folder( graphic_assets, s3_assets, headers={ 'Cache-Control': 'max-age=%i' % assets_max_age }, ignore=['%s/private/*' % graphic_assets] ) def get_start_message(slug): result = slack_client.api_call( "search.messages", query= '{0} in:charts'.format(slug), ) if result['messages']['matches'][0].get('attachments') != None: print 'found attachments' if result['messages']['matches'][0]['attachments'][0]['title'] == slug: print 'found it' return result['messages']['matches'][0]['ts'] if result['messages']['matches'][0].get('previous') != None: print 'found previous' if 'attachments' in result['messages']['matches'][0]['previous']: if result['messages']['matches'][0]['previous']['attachments'][0]['title'] == slug: print 'found in previous mention' return result['messages']['matches'][0]['previous']['ts'] if result['messages']['matches'][0].get('previous_2') != None: print 'its in previous_2' if 'attachments' in result['messages']['matches'][0]['previous_2']: print 'attachemnts in prevous_2 ' if result['messages']['matches'][0]['previous_2']['attachments'][0]['title'] == slug: print 'found in previous_2 mention' return result['messages']['matches'][0]['previous_2']['ts'] else: print('Not found') print(result['messages']['matches'][0]) def send_thread_message(message, ts): slack_client.api_call( "chat.postMessage", channel='#charts', text=message, username='******', icon_emoji=':bowtie:', thread_ts=ts, ) if env.settings == 'production': message = 'Updated final link' else: message = 'Updated review link' """message_search_results = get_start_message(slug) if message_search_results != None: send_thread_message(message, message_search_results) print 'message sent'""" print '' print '%s URL: %s/%s/index.html' % (env.settings.capitalize(), app_config.S3_BASE_URL, slug)
def deploy_single(slug): """ Deploy a single project to S3 and, if configured, to our servers. """ require('settings', provided_by=[production, staging]) graphic_root = '%s/%s' % (app_config.GRAPHICS_PATH, slug) s3_root = '%s/graphics/%s' % (app_config.PROJECT_SLUG, slug) graphic_assets = '%s/assets' % graphic_root s3_assets = '%s/assets' % s3_root # New to The Lens. Check if fallback image has been created if not os.path.isfile('%s/fallback.png' % graphic_root): print 'Render a fallback image before deploying. ' + \ 'Run "fab render.save_fallback_image:slug".' return graphic_config = load_graphic_config(graphic_root) use_assets = getattr(graphic_config, 'USE_ASSETS', True) default_max_age = getattr( graphic_config, 'DEFAULT_MAX_AGE', None) or app_config.DEFAULT_MAX_AGE assets_max_age = getattr( graphic_config, 'ASSETS_MAX_AGE', None) or app_config.ASSETS_MAX_AGE update_copy(slug) if use_assets: assets.sync(slug) render.render(slug) flat.deploy_folder( graphic_root, s3_root, headers={ 'Cache-Control': 'max-age=%i' % default_max_age }, ignore=['%s/*' % graphic_assets] ) # Deploy parent assets flat.deploy_folder( 'www', app_config.PROJECT_SLUG, headers={ 'Cache-Control': 'max-age=%i' % default_max_age } ) if use_assets: flat.deploy_folder( graphic_assets, s3_assets, headers={ 'Cache-Control': 'max-age=%i' % assets_max_age } ) print '\n%s URL: %s/graphics/%s/' % ( env.settings.capitalize(), app_config.S3_BASE_URL, slug)