當前位置: 首頁>>代碼示例>>Python>>正文


Python Project.export_completed方法代碼示例

本文整理匯總了Python中project.model.Project.export_completed方法的典型用法代碼示例。如果您正苦於以下問題:Python Project.export_completed方法的具體用法?Python Project.export_completed怎麽用?Python Project.export_completed使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在project.model.Project的用法示例。


在下文中一共展示了Project.export_completed方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: export_worker

# 需要導入模塊: from project.model import Project [as 別名]
# 或者: from project.model.Project import export_completed [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']}
開發者ID:sweemeng,項目名稱:scrapedump,代碼行數:41,代碼來源:export_worker.py


注:本文中的project.model.Project.export_completed方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。