本文整理汇总了Python中pyasm.biz.Task.get_by_sobject方法的典型用法代码示例。如果您正苦于以下问题:Python Task.get_by_sobject方法的具体用法?Python Task.get_by_sobject怎么用?Python Task.get_by_sobject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.biz.Task
的用法示例。
在下文中一共展示了Task.get_by_sobject方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_all_tasks
# 需要导入模块: from pyasm.biz import Task [as 别名]
# 或者: from pyasm.biz.Task import get_by_sobject [as 别名]
def set_all_tasks(my, sobject, process, status):
tasks = Task.get_by_sobject(sobject, process=process)
title = status.replace("-", " ")
title = title.replace("_", " ")
title = Common.get_display_title(title)
for task in tasks:
task.set_value("status", title)
task.commit()
示例2: _test_approval
# 需要导入模块: from pyasm.biz import Task [as 别名]
# 或者: from pyasm.biz.Task import get_by_sobject [as 别名]
def _test_approval(my):
# create a dummy sobject
sobject = SearchType.create("unittest/person")
pipeline_xml = '''
<pipeline>
<process type="action" name="a"/>
<process type="approval" name="b"/>
<process type="action" name="c"/>
<connect from="a" to="b"/>
<connect from="b" to="c"/>
</pipeline>
'''
pipeline, processes = my.get_pipeline(pipeline_xml)
sobject.set_value("pipeline_code", pipeline.get_code())
sobject.commit()
# ensure there are not tasks
tasks = Task.get_by_sobject(sobject, process="b")
my.assertEquals(0, len(tasks))
# Run the pipeline
process = "a"
output = {
"pipeline": pipeline,
"sobject": sobject,
"process": process
}
Trigger.call(my, "process|pending", output)
# ensure there are not tasks
tasks = Task.get_by_sobject(sobject, process="b")
my.assertEquals(1, len(tasks))
task = tasks[0]
my.assertEquals("b", task.get("process"))
# approve the task
task.set_value("status", "approved")
task.commit()
my.assertEquals( "complete", sobject.get_value("b"))
my.assertEquals( "complete", sobject.get_value("c"))
示例3: handle_sobject
# 需要导入模块: from pyasm.biz import Task [as 别名]
# 或者: from pyasm.biz.Task import get_by_sobject [as 别名]
def handle_sobject(self, sobject, command):
# the sobject here is a task
if not self.check(sobject):
return
# the parent is the asset or shot
parent = sobject.get_parent()
print "Check finished"
tasks = Task.get_by_sobject(parent, 'compositing')
# about to commit
task_ids = []
for task in tasks:
if task.get_value('status') != 'Pending':
task.set_value('status','Pending')
task.commit()
task_ids.append(task.get_id())
print "Changed task status to [Pending] for task id %s'" %str(task_ids)
示例4: handle_sobject
# 需要导入模块: from pyasm.biz import Task [as 别名]
# 或者: from pyasm.biz.Task import get_by_sobject [as 别名]
def handle_sobject(my, sobject, command):
# the sobject here is a task
if not my.check(sobject):
return
# the parent is the asset or shot
parent = sobject.get_parent()
print "Check finished"
tasks = Task.get_by_sobject(parent, "compositing")
# about to commit
task_ids = []
for task in tasks:
if task.get_value("status") != "Pending":
task.set_value("status", "Pending")
task.commit()
task_ids.append(task.get_id())
print "Changed task status to [Pending] for task id %s'" % str(task_ids)
示例5: get_to
# 需要导入模块: from pyasm.biz import Task [as 别名]
# 或者: from pyasm.biz.Task import get_by_sobject [as 别名]
def get_to(my):
recipients = super(TaskStatusEmailHandler, my).get_to()
sobj = my.sobject
# it could be the parent of task:
if not isinstance(sobj, Task):
tasks = Task.get_by_sobject(sobj)
else:
tasks = [sobj]
for task in tasks:
assigned = my._get_login(task.get_assigned())
if assigned:
recipients.add(assigned)
supe = my._get_login(task.get_supervisor())
if supe:
recipients.add(supe)
return recipients
示例6: get_display
# 需要导入模块: from pyasm.biz import Task [as 别名]
# 或者: from pyasm.biz.Task import get_by_sobject [as 别名]
def get_display(my):
web = WebContainer.get_web()
task = my.get_current_sobject()
id = task.get_id()
if task.is_insert():
return HtmlElement.i("Dependency on insert not supported yet.")
# get the sobject
sobject = task.get_parent()
if not sobject:
return "No parent"
tmp_tasks = Task.get_by_sobject(sobject)
tasks = []
for tmp_task in tmp_tasks:
# skip the task self
if tmp_task.get_id() == id:
continue
# prevent direct circular dependencies
if tmp_task.get_value("depend_id") == id:
continue
tasks.append(tmp_task)
ids = [x.get_id() for x in tasks]
labels = []
for task in tasks:
process = task.get_value("process")
description = task.get_value("description")
if len(description) > 30:
description = description[0:30]+"..."
label = "%s - %s" % (process, description)
labels.append(label)
my.set_option("empty", "true")
my.set_option("labels", labels)
my.set_option("values", ids)
return super(TaskParentInputWdg,my).get_display()
示例7: delete
# 需要导入模块: from pyasm.biz import Task [as 别名]
# 或者: from pyasm.biz.Task import get_by_sobject [as 别名]
def delete(my, log=True):
'''This is for undo'''
# TODO: the should probably be clearer!!!!
if log == False:
super(Asset,my).delete(log)
return
# An asset can only be deleted if only icon snapshots exist
snapshots = Snapshot.get_by_sobject(my)
only_icons = True
for snapshot in snapshots:
context = snapshot.get_value("context")
if context != my.get_icon_context():
only_icons = False
if not only_icons:
raise TacticException("Cannot delete because snapshots exist")
# only delete if not tasks have been assigned
tasks = Task.get_by_sobject(my)
has_assigned = False
for task in tasks:
assigned = task.get_value("assigned")
if assigned != "" and assigned != "None":
has_assigned = True
if has_assigned:
raise TacticException("Cannot delete because tasks have been assigned")
# delete tasks and icons
for snapshot in snapshots:
snapshot.delete()
for task in tasks:
task.delete()
my.description = "Deleted '%s', search_type '%s'" % (my.get_code(), my.get_search_type)
super(Asset,my).delete(log)
示例8: get_display
# 需要导入模块: from pyasm.biz import Task [as 别名]
# 或者: from pyasm.biz.Task import get_by_sobject [as 别名]
def get_display(my):
args = WebContainer.get_web().get_form_args()
# get the args in the URL
search_type = args['search_type']
search_id = args['search_id']
sobject = Search.get_by_search_key("%s|%s" % (search_type,search_id) )
widget = DivWdg()
widget.add_style("width: 95%")
widget.add_style("margin-left: 20px")
table = TableWdg("sthpw/task", "layout_right")
from pyasm.biz import Task
tasks = Task.get_by_sobject(sobject)
table.set_sobjects(tasks)
table.set_show_property(False)
widget.add(table)
return widget
示例9: handle_pending
# 需要导入模块: from pyasm.biz import Task [as 别名]
# 或者: from pyasm.biz.Task import get_by_sobject [as 别名]
def handle_pending(my):
my.log_message(my.sobject, my.process, "pending")
search = Search("config/process")
search.add_filter("process", my.process)
search.add_filter("pipeline_code", my.pipeline.get_code())
process_sobj = search.get_sobject()
workflow = process_sobj.get_json_value("workflow")
if workflow:
assigned = workflow.get("assigned")
else:
assigned = None
# check to see if the tasks exist and if they don't then create one
tasks = Task.get_by_sobject(my.sobject, process=my.process)
if not tasks:
tasks = Task.add_initial_tasks(my.sobject, processes=[my.process], assigned=assigned)
else:
my.set_all_tasks(my.sobject, my.process, "pending")
Trigger.call(my, "process|action", my.input)
示例10: get_pipeline_wdg
# 需要导入模块: from pyasm.biz import Task [as 别名]
# 或者: from pyasm.biz.Task import get_by_sobject [as 别名]
def get_pipeline_wdg(my, pipeline_code):
div = DivWdg()
title = DivWdg()
title.add_gradient("background", "background3", 0)
title.add_style("height: 20px")
title.add_style("font-weight: bold")
title.add_style("padding: 4px")
title.add_border()
title.add("Pipeline")
div.add(title)
kwargs = {
'width': 800,
'height': 300,
'pipeline': pipeline_code,
'scale': 0.7,
}
pipeline = TaskDetailPipelineWdg(**kwargs)
div.add(pipeline)
load_div = DivWdg()
div.add(load_div)
# This is only for tasks!!!!
enabled_tasks = set()
from pyasm.biz import Task
process = ''
if my.parent:
tasks = Task.get_by_sobject(my.parent)
if my.sobject.has_value("process"):
process = my.sobject.get_value("process")
else:
tasks = Task.get_by_sobject(my.sobject)
for task in tasks:
enabled_tasks.add(task.get_value("process"))
enabled_tasks = list(enabled_tasks)
load_div.add_behavior( {
'type': 'load',
'process': process,
'enabled_tasks': enabled_tasks,
'pipeline': pipeline_code,
'cbjs_action': '''
var top = bvr.src_el.getParent(".spt_pipeline_wrapper");
spt.pipeline.init_cbk(top);
var nodes = spt.pipeline.get_nodes_by_group(bvr.pipeline);
for (var i = 0; i < nodes.length; i++) {
var has_task = false;
var node = nodes[i];
var node_name = spt.pipeline.get_node_name(node);
for (var j = 0; j < bvr.enabled_tasks.length; j++) {
if (node_name == bvr.enabled_tasks[j]) {
has_task = true;
break;
}
}
if (!has_task && node) {
spt.pipeline.disable_node(node);
}
}
spt.pipeline.unselect_all_nodes();
var node = spt.pipeline.get_node_by_name(bvr.process);
//process and node name could be different
if (node) {
node.setStyle("font-weight", "bold");
spt.pipeline.select_node(node);
//spt.pipeline.center_node(node);
}
spt.pipeline.fit_to_canvas(bvr.pipeline);
'''
} )
#div.add_style("padding: 10px")
div.add_border()
return div
示例11: execute
# 需要导入模块: from pyasm.biz import Task [as 别名]
# 或者: from pyasm.biz.Task import get_by_sobject [as 别名]
def execute(my):
trigger_sobj = my.get_trigger_sobj()
data = trigger_sobj.get_value("data")
data = jsonloads(data)
print "trigger data: ", data, type(data)
data_list = data
if isinstance(data, dict):
data_list = [data]
src_task = my.get_caller()
for data in data_list:
# get the src task caller
dst_task = None
# it could be the FileCheckin Command
if not isinstance(src_task, SObject):
input = my.get_input()
snapshot = input.get('snapshot')
if not snapshot:
continue
if isinstance(snapshot, dict):
snapshot = SearchKey.get_by_search_key(snapshot.get('__search_key__'))
src_process = data.get('src_process')
src_task = Search.eval("@SOBJECT(parent.sthpw/task['process','%s'])"%src_process,\
sobjects=snapshot, single=True)
if not src_task:
continue
# make sure the caller process is the same as the source process
if src_task.get_value("process") != data.get("src_process"):
continue
#conditionx = "@GET(.status) != 'Approved'"
#result = Search.eval(conditionx, src_task)
#print "result: ", result
# make sure that the appropriate status was set
src_status = data.get("src_status")
if src_status and src_task.get_value("status") != src_status:
continue
dst_process = data.get("dst_process")
dst_status = data.get("dst_status")
sobject = src_task.get_parent()
tasks = Task.get_by_sobject(sobject)
updated_tasks = []
use_parent = data.get("use_parent")
if use_parent in [True,'true']:
parent = sobject.get_parent()
parent_tasks = Task.get_by_sobject(parent, dst_process)
condition = data.get("condition")
if not condition:
condition = "all"
if condition == "all":
condition_met = True
for task in tasks:
if src_task.get_value("status") != src_status:
condition_met = False
elif condition == "any":
condition_met = False
for task in tasks:
if task.get_value("status") == src_status:
condition_met = True
break
if condition_met:
for task in parent_tasks:
if task.get_value("process") == dst_process:
updated_tasks.append(task)
else:
for task in tasks:
if task.get_value("process") == dst_process:
updated_tasks.append(task)
for task in updated_tasks:
if task.get_value("process") == dst_process:
task.set_value("status", dst_status)
task.commit()
"""
示例12: execute
# 需要导入模块: from pyasm.biz import Task [as 别名]
# 或者: from pyasm.biz.Task import get_by_sobject [as 别名]
def execute(my):
# set all task to pending
pipeline = my.input.get("pipeline")
process = my.input.get("process")
sobject = my.input.get("sobject")
process_obj = pipeline.get_process(process)
node_type = process_obj.get_type()
#print "pending: ", process, node_type
my.run_callback(pipeline, process, "pending")
if node_type not in ["node", "manual"]:
my.set_all_tasks(sobject, process, "pending")
if node_type in ["action", "condition"]:
Trigger.call(my, "process|action", output=my.input)
elif node_type in ["approval"]:
# check to see if the tasks exist and if they don't then create one
tasks = Task.get_by_sobject(sobject, process=process)
if not tasks:
tasks = Task.add_initial_tasks(sobject, processes=[process])
else:
my.set_all_tasks(sobject, process, "pending")
elif node_type in ["hierarchy"]:
search = Search("config/process")
search.add_filter("pipeline_code", pipeline.get_code())
search.add_filter("process", process)
process_sobj = search.get_sobject()
process_code = process_sobj.get_code()
search = Search("sthpw/pipeline")
search.add_filter("parent_process", process_code)
subpipeline = search.get_sobject()
if not subpipeline:
return
child_processes = subpipeline.get_processes()
#child_pipeline = process_obj.get_child_pipeline()
#child_processes = child_pipeline.get_processes()
if child_processes:
first_process = child_processes[0]
first_name = first_process.get_name()
input = {
'pipeline': subpipeline,
'sobject': sobject,
'process': first_process.get_name(),
}
event = "process|pending"
Trigger.call(my, event, input)
示例13: execute
# 需要导入模块: from pyasm.biz import Task [as 别名]
# 或者: from pyasm.biz.Task import get_by_sobject [as 别名]
def execute(self):
trigger_sobj = self.get_trigger_sobj()
data = trigger_sobj.get_value("data")
data = jsonloads(data)
data_list = data
if isinstance(data, dict):
data_list = [data]
src_task = self.get_caller()
for data in data_list:
# get the src task caller
dst_task = None
# it could be the FileCheckin Command
if not isinstance(src_task, SObject):
input = self.get_input()
snapshot = input.get('snapshot')
if not snapshot:
continue
if isinstance(snapshot, dict):
snapshot = SearchKey.get_by_search_key(snapshot.get('__search_key__'))
src_process = data.get('src_process')
src_task = Search.eval("@SOBJECT(parent.sthpw/task['process','%s'])"%src_process,\
sobjects=snapshot, single=True)
if not src_task:
continue
# make sure the caller process is the same as the source process
if src_task.get_value("process") != data.get("src_process"):
continue
#conditionx = "@GET(.status) != 'Approved'"
#result = Search.eval(conditionx, src_task)
#print "result: ", result
# make sure that the appropriate status was set
src_status = data.get("src_status")
if src_status and src_task.get_value("status") != src_status:
continue
# Execute script if necessary
script_path = trigger_sobj.get_value("script_path")
if script_path:
cmd = PythonTrigger(script_path=script_path)
cmd.set_input(self.input)
cmd.set_output(self.input)
cmd.execute()
continue
# Execute trigger if necessary
class_path = data.get("class_path")
if class_path:
trigger = Common.create_from_class_path(class_path)
trigger.set_input(self.input)
trigger.set_output(self.input)
trigger.execute()
continue
# If no script was execute,then assume other task
# statuses should be updated.
dst_process = data.get("dst_process")
dst_status = data.get("dst_status")
sobject = src_task.get_parent()
tasks = Task.get_by_sobject(sobject)
updated_tasks = []
use_parent = data.get("use_parent")
if use_parent in [True,'true']:
parent = sobject.get_parent()
parent_tasks = Task.get_by_sobject(parent, dst_process)
condition = data.get("condition")
if not condition:
condition = "all"
if condition == "all":
condition_met = True
for task in tasks:
if src_task.get_value("status") != src_status:
condition_met = False
elif condition == "any":
condition_met = False
for task in tasks:
if task.get_value("status") == src_status:
condition_met = True
break
if condition_met:
for task in parent_tasks:
if task.get_value("process") == dst_process:
#.........这里部分代码省略.........