本文整理汇总了Python中oozie.models2.Coordinator.set_workspace方法的典型用法代码示例。如果您正苦于以下问题:Python Coordinator.set_workspace方法的具体用法?Python Coordinator.set_workspace怎么用?Python Coordinator.set_workspace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oozie.models2.Coordinator
的用法示例。
在下文中一共展示了Coordinator.set_workspace方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: edit_coordinator
# 需要导入模块: from oozie.models2 import Coordinator [as 别名]
# 或者: from oozie.models2.Coordinator import set_workspace [as 别名]
def edit_coordinator(request):
coordinator_id = request.GET.get('coordinator', request.GET.get('uuid'))
doc = None
workflow_uuid = None
if coordinator_id:
cid = {}
if coordinator_id.isdigit():
cid['id'] = coordinator_id
else:
cid['uuid'] = coordinator_id
doc = Document2.objects.get(**cid)
coordinator = Coordinator(document=doc)
else:
coordinator = Coordinator()
coordinator.set_workspace(request.user)
if request.GET.get('workflow'):
workflow_uuid = request.GET.get('workflow')
if workflow_uuid:
coordinator.data['properties']['workflow'] = workflow_uuid
api = get_oozie(request.user)
credentials = Credentials()
try:
credentials.fetch(api)
except Exception, e:
LOG.error(smart_str(e))
示例2: edit_coordinator
# 需要导入模块: from oozie.models2 import Coordinator [as 别名]
# 或者: from oozie.models2.Coordinator import set_workspace [as 别名]
def edit_coordinator(request):
coordinator_id = request.GET.get('coordinator', request.GET.get('uuid'))
doc = None
workflow_uuid = None
if coordinator_id:
cid = {}
if coordinator_id.isdigit():
cid['id'] = coordinator_id
else:
cid['uuid'] = coordinator_id
doc = Document2.objects.get(**cid)
coordinator = Coordinator(document=doc)
else:
coordinator = Coordinator()
coordinator.set_workspace(request.user)
# Automatically create the workflow of a scheduled document
# To move to save coordinator
document_uuid = request.GET.get('document')
if document_uuid:
# Has already a workflow managing the query for this user?
workflows = Document2.objects.filter(type='oozie-workflow2', owner=request.user, is_managed=True, dependencies__uuid__in=[document_uuid])
if workflows.exists():
workflow_doc = workflows.get()
else:
document = Document2.objects.get_by_uuid(user=request.user, uuid=document_uuid)
workflow_doc = WorkflowBuilder().create_workflow(document=document, user=request.user, managed=True)
if doc:
doc.dependencies.add(workflow_doc)
workflow_uuid = workflow_doc.uuid
coordinator.data['name'] = _('Schedule of %s') % workflow_doc.name
elif request.GET.get('workflow'):
workflow_uuid = request.GET.get('workflow')
if workflow_uuid:
coordinator.data['properties']['workflow'] = workflow_uuid
api = get_oozie(request.user)
credentials = Credentials()
try:
credentials.fetch(api)
except Exception, e:
LOG.error(smart_str(e))