本文整理汇总了Python中assets.sync函数的典型用法代码示例。如果您正苦于以下问题:Python sync函数的具体用法?Python sync怎么用?Python sync使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sync函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: deploy
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
}
)
开发者ID:danilito19,项目名称:dailygraphics,代码行数:35,代码来源:__init__.py
示例2: update
def update():
"""
Update all application data not in repository (copy, assets, etc).
"""
text.update()
assets.sync()
data.update()
开发者ID:stlpublicradio,项目名称:suspendedfutures.org,代码行数:7,代码来源:__init__.py
示例3: render
def render():
"""
Render HTML templates and compile assets.
"""
from flask import g
#update_copy()
assets.sync()
update_data()
less()
jst()
app_config_js()
copy_js()
compiled_includes = []
for rule in app.app.url_map.iter_rules():
rule_string = rule.rule
name = rule.endpoint
if name == 'static' or name.startswith('_'):
print 'Skipping %s' % name
continue
if rule_string.endswith('/'):
filename = 'www' + rule_string + 'index.html'
elif rule_string.endswith('.html'):
filename = 'www' + rule_string
else:
print 'Skipping %s' % name
continue
dirname = os.path.dirname(filename)
if not (os.path.exists(dirname)):
os.makedirs(dirname)
print 'Rendering %s' % (filename)
with app.app.test_request_context(path=rule_string):
g.compile_includes = True
g.compiled_includes = compiled_includes
bits = name.split('.')
# Determine which module the view resides in
if len(bits) > 1:
module, name = bits
else:
module = 'app'
view = globals()[module].__dict__[name]
content = view()
compiled_includes = g.compiled_includes
with open(filename, 'w') as f:
f.write(content.encode('utf-8'))
开发者ID:nprapps,项目名称:musicgame,代码行数:59,代码来源:__init__.py
示例4: render
def render():
"""
Render HTML templates and compile assets.
"""
from flask import g
update_copy()
assets.sync()
update_data()
less()
jst()
app_config_js()
copy_js()
compiled_includes = []
for rule in app.app.url_map.iter_rules():
rule_string = rule.rule
name = rule.endpoint
if name == "static" or name.startswith("_"):
print "Skipping %s" % name
continue
if rule_string.endswith("/"):
filename = "www" + rule_string + "index.html"
elif rule_string.endswith(".html"):
filename = "www" + rule_string
else:
print "Skipping %s" % name
continue
dirname = os.path.dirname(filename)
if not (os.path.exists(dirname)):
os.makedirs(dirname)
print "Rendering %s" % (filename)
with app.app.test_request_context(path=rule_string):
g.compile_includes = True
g.compiled_includes = compiled_includes
bits = name.split(".")
# Determine which module the view resides in
if len(bits) > 1:
module, name = bits
else:
module = "app"
view = globals()[module].__dict__[name]
content = view()
compiled_includes = g.compiled_includes
with open(filename, "w") as f:
f.write(content.encode("utf-8"))
开发者ID:BeckyBowers,项目名称:guest-tracker,代码行数:59,代码来源:__init__.py
示例5: update
def update():
"""
Update all application data not in repository (copy, assets, etc).
"""
utils.install_font(force=False)
text.update()
assets.sync()
data.update()
开发者ID:nprapps,项目名称:leadpipes,代码行数:8,代码来源:__init__.py
示例6: update
def update():
"""
Update all application data not in repository (copy, assets, etc).
"""
require('slug', provided_by=[post])
text.update()
assets.sync()
开发者ID:BenHeubl,项目名称:lookatthis,代码行数:8,代码来源:__init__.py
示例7: local_bootstrap_data
def local_bootstrap_data():
"""
Sets up the app from scratch.
"""
assets.sync()
local_init_db()
init_tables()
os.system('rm -f www/live-data/audio/*.oga www/live-data/audio/*.mp3')
load_quizzes()
开发者ID:nprapps,项目名称:musicgame,代码行数:9,代码来源:__init__.py
示例8: deploy
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)
开发者ID:azizjiwani,项目名称:dailygraphics,代码行数:57,代码来源:__init__.py
示例9: update
def update():
"""
Update all application data not in repository (copy, assets, etc).
"""
utils.install_font(force=False)
text.update_copytext()
text.update_calendar()
text.update_newsletter()
text.update_all_docs()
assets.sync()
开发者ID:katlonsdorf,项目名称:elections16,代码行数:10,代码来源:__init__.py
示例10: bootstrap
def bootstrap():
"""
Bootstrap this project. Should only need to be run once.
"""
# Reimport app_config in case this is part of the app_template bootstrap
import app_config
local('npm install less universal-jst -g --prefix node_modules')
assets.sync()
#update_copy()
update_data()
开发者ID:nprapps,项目名称:musicgame,代码行数:12,代码来源:__init__.py
示例11: bootstrap
def bootstrap():
"""
Bootstrap this project. Should only need to be run once.
"""
# Reimport app_config in case this is part of the app_template bootstrap
import app_config
local(NPM_INSTALL_COMMAND)
assets.sync()
update_copy()
update_data()
开发者ID:nprapps,项目名称:visits,代码行数:12,代码来源:__init__.py
示例12: deploy
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)
开发者ID:BenHeubl,项目名称:dailygraphics,代码行数:43,代码来源:__init__.py
示例13: deploy_single
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)
开发者ID:stlpublicradio,项目名称:dailygraphics,代码行数:55,代码来源:__init__.py
示例14: deploy_single
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)
开发者ID:TheLens,项目名称:dailygraphics,代码行数:61,代码来源:__init__.py
示例15: deploy_single
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='david the daily graphics bot',
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)
开发者ID:lexieheinle,项目名称:dailygraphics,代码行数:98,代码来源:__init__.py
注:本文中的assets.sync函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论