本文整理汇总了Python中project.model.Project.get_exported_file方法的典型用法代码示例。如果您正苦于以下问题:Python Project.get_exported_file方法的具体用法?Python Project.get_exported_file怎么用?Python Project.get_exported_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类project.model.Project
的用法示例。
在下文中一共展示了Project.get_exported_file方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: download_export
# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import get_exported_file [as 别名]
def download_export(project_id,entry_id,export_type):
project = Project()
project.get(project_id)
metadata = project.get_exported_file(entry_id,export_type)
file_ = project.get_datafile(str(metadata['file_id']))
response = make_response(file_.read())
response.headers['Content-Description'] = 'Uploaded File'
response.headers['Content-Type'] = 'application/%s' % file_.content_type
response.headers['Content-Length'] = file_.length
response.headers['Content-Disposition'] = 'attachment; filename=%s' % file_.filename
return response
示例2: export_worker
# 需要导入模块: from project.model import Project [as 别名]
# 或者: from project.model.Project import get_exported_file [as 别名]
def export_worker(msg):
project = Project()
project.get(msg['project_id'])
completed = project.export_completed(msg['entry_id'],msg['format'])
file_id = ''
if completed:
print 'task completed, making sure file need to regenerated'
metadata = project.get_exported_file(msg['entry_id'],msg['format'])
if metadata['file_id']:
f = project.get_datafile(metadata['file_id'])
uploaded_date = f.upload_date
last_updated = project.get_entry_updated()
print uploaded_date
print last_updated
if last_updated > uploaded_date:
print 'file need regen'
task = export_single.delay(msg['project_id'],msg['entry_id'],msg['format'])
print task
project.set_exporter_task(msg['entry_id'],msg['format'],task.id)
completed = project.export_completed(msg['entry_id'],msg['format'])
else:
task = export_single.delay(msg['project_id'],msg['entry_id'],msg['format'])
project.set_exporter_task(msg['entry_id'],msg['format'],task.id)
completed = project.export_completed(msg['entry_id'],msg['format'])
while not completed:
completed = project.export_completed(msg['entry_id'],msg['format'])
yield {'completed':False,'file_id':file_id,'format':msg['format'],
'project_id':msg['project_id'],'entry_id':msg['entry_id']}
time.sleep(1)
project.get(msg['project_id'])
metadata = project.get_exported_file(msg['entry_id'],msg['format'])
print metadata['file_id']
f = project.get_datafile(metadata['file_id'])
file_id = metadata['file_id']
yield {'completed':True,'file_id':file_id,'format':msg['format'],
'project_id':msg['project_id'],'entry_id':msg['entry_id']}