本文整理汇总了Python中tactic.command.PythonCmd.execute方法的典型用法代码示例。如果您正苦于以下问题:Python PythonCmd.execute方法的具体用法?Python PythonCmd.execute怎么用?Python PythonCmd.execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tactic.command.PythonCmd
的用法示例。
在下文中一共展示了PythonCmd.execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_callback
# 需要导入模块: from tactic.command import PythonCmd [as 别名]
# 或者: from tactic.command.PythonCmd import execute [as 别名]
def run_callback(my, pipeline, process, status):
# get the node triggers
# TODO: make this more efficient
search = Search("config/process")
search.add_filter("pipeline_code", pipeline.get_code())
search.add_filter("process", process)
process_sobj = search.get_sobject()
#print "callback process: ", process, pipeline.get_code()
if not process_sobj:
raise TacticException('Process item [%s] has not been created. Please save your pipeline in the Project Workflow Editor to refresh the processes.'%process)
triggers = {}
if process_sobj:
triggers = process_sobj.get_json_value("workflow")
if not triggers:
triggers = {}
ret_val = None
action = triggers.get("on_%s" % status)
js_action = triggers.get("cbjs_%s" % status)
action_path = triggers.get("on_%s_path" % status)
kwargs, input = my.build_trigger_input()
if action or action_path:
from tactic.command import PythonCmd
if action:
cmd = PythonCmd(code=action, input=input, **kwargs)
else:
cmd = PythonCmd(script_path=script_path, input=input, **kwargs)
ret_val = cmd.execute()
elif js_action:
from tactic.command import JsCmd
if action:
cmd = JsCmd(code=action, input=input, **kwargs)
else:
cmd = JsCmd(script_path=script_path, input=input, **kwargs)
ret_val = cmd.execute()
else:
# or call a trigger
event = "process|%s" % status
# how to get the value here?
process_code = process_sobj.get_code()
triggers = Trigger.call(my, event, kwargs, process=process_code)
if triggers:
ret_val = triggers[0].get_ret_val()
return ret_val
示例2: get_display
# 需要导入模块: from tactic.command import PythonCmd [as 别名]
# 或者: from tactic.command.PythonCmd import execute [as 别名]
def get_display(self):
script_path = self.get_option("script_path")
script_code = self.get_option("script_code")
from tactic.command import PythonCmd
if script_path:
cmd = PythonCmd(script_path=script_path, values=self.values, search=search, show_title=self.show_title)
elif script_code:
cmd = PythonCmd(script_code=script_code, values=self.values, search=search, show_title=self.show_title)
cmd.execute()
示例3: alter_search
# 需要导入模块: from tactic.command import PythonCmd [as 别名]
# 或者: from tactic.command.PythonCmd import execute [as 别名]
def alter_search(my, search):
script_path = my.get_option("alter_search_script_path")
script_code = my.get_option("alter_search_script_code")
from tactic.command import PythonCmd
if script_path:
cmd = PythonCmd(script_path=script_path, values=my.values, search=search, show_title=my.show_title)
elif script_code:
cmd = PythonCmd(script_code=script_code, values=my.values, search=search, show_title=my.show_title)
cmd.execute()
示例4: verify
# 需要导入模块: from tactic.command import PythonCmd [as 别名]
# 或者: from tactic.command.PythonCmd import execute [as 别名]
def verify(self, login_name, password):
if login_name.find("\\") != -1:
domain, base_login_name = login_name.split("\\")
else:
base_login_name = login_name
domain = None
# confirm that there is a domain present if required
require_domain = Config.get_value("active_directory", "require_domain")
domain_component = Config.get_value("active_directory","domain_component")
script_path = Config.get_value("active_directory","allow_script")
if script_path:
flag = False
try:
from tactic.command import PythonCmd
from pyasm.command import Command
kwargs = {'login' : login_name}
cmd = PythonCmd(script_path=script_path, **kwargs)
#flag = Command.execute_cmd(cmd)
flag = cmd.execute()
except Exception, e:
print e
raise
if flag != True:
return False
示例5: delete_files
# 需要导入模块: from tactic.command import PythonCmd [as 别名]
# 或者: from tactic.command.PythonCmd import execute [as 别名]
def delete_files(my, nodes):
# clean out all of the files
for node in nodes:
name = my.xml.get_node_name(node)
if name == "include":
path = my.xml.get_attribute(node, "path")
if not path:
print("WARNING: No path found for search type in manifest")
continue
path = "%s/%s" % (my.plugin_dir, path)
if path.endswith(".py"):
from tactic.command import PythonCmd
cmd = PythonCmd(file_path=path)
manifest = cmd.execute()
if manifest:
xml = Xml()
xml.read_string(manifest)
include_nodes = xml.get_nodes("manifest/*")
my.delete_files(include_nodes)
elif name == "python":
# don't delete python node file
pass
else:
path = my.get_path_from_node(node)
if path and os.path.exists(path):
print "Deleting: ", path
os.unlink(path)
示例6: handle_include
# 需要导入模块: from tactic.command import PythonCmd [as 别名]
# 或者: from tactic.command.PythonCmd import execute [as 别名]
def handle_include(my, node):
path = my.xml.get_attribute(node, "path")
if not path:
raise TacticException("No path found for include in manifest")
path = "%s/%s" % (my.plugin_dir, path)
if path.endswith(".py"):
from tactic.command import PythonCmd
cmd = PythonCmd(file_path=path)
manifest = cmd.execute()
if not manifest:
print "No manifest discovered in [%s]" %path
return
xml = Xml()
xml.read_string(manifest)
nodes = xml.get_nodes("manifest/*")
sobjects = []
for i, node in enumerate(nodes):
name = my.xml.get_node_name(node)
if name == 'sobject':
dumped_sobjects = my.handle_sobject(node)
if not dumped_sobjects:
dumped_sobjects = []
sobjects.extend(dumped_sobjects)
elif name == 'search_type':
my.handle_search_type(node)
elif name == 'include':
my.handle_include(node)
示例7: handle_action
# 需要导入模块: from tactic.command import PythonCmd [as 别名]
# 或者: from tactic.command.PythonCmd import execute [as 别名]
def handle_action(my):
my.log_message(my.sobject, my.process, "in_progress")
process_obj = my.pipeline.get_process(my.process)
# get the node's triggers
search = Search("config/process")
search.add_filter("process", my.process)
search.add_filter("pipeline_code", my.pipeline.get_code())
process_sobj = search.get_sobject()
#process_sobj = my.pipeline.get_process_sobject(my.process)
triggers = {}
if process_sobj:
triggers = process_sobj.get_json_value("workflow")
if not triggers:
triggers = {}
action = triggers.get("on_action")
cbjs_action = triggers.get("cbjs_action")
action_path = triggers.get("on_action_path")
kwargs, input = my.build_trigger_input()
if action or action_path:
from tactic.command import PythonCmd
if action:
cmd = PythonCmd(code=action, input=input, **kwargs)
else:
cmd = PythonCmd(script_path=action_path, input=input, **kwargs)
ret_val = cmd.execute()
elif cbjs_action:
from tactic.command import JsCmd
if cbjs_action:
cmd = JsCmd(code=cbjs_action, input=input, **kwargs)
else:
cmd = JsCmd(script_path=script_path, input=input, **kwargs)
ret_val = cmd.execute()
else:
# or call an action trigger
Trigger.call(my, "process|action", input, process=process_sobj.get_code())
Trigger.call(my, "process|complete", my.input)
示例8: get_result
# 需要导入模块: from tactic.command import PythonCmd [as 别名]
# 或者: from tactic.command.PythonCmd import execute [as 别名]
def get_result(my, sobject):
result = None
sobject_dict = sobject.get_sobject_dict()
filter_data = my.filter_data.get_data()
try:
cmd = PythonCmd(code=my.code, sobject=sobject_dict, filter_data=filter_data)
result = cmd.execute()
except Exception, e:
return str(e)
示例9: handle_python
# 需要导入模块: from tactic.command import PythonCmd [as 别名]
# 或者: from tactic.command.PythonCmd import execute [as 别名]
def handle_python(my, node):
'''during uninstall, handle the python undo_path'''
path = my.xml.get_attribute(node, "undo_path")
# if no path, then nothing to undo
if not path:
print "No undo_path defined for this python node"
return
if not path.endswith('.py'):
raise TacticException("Path should have the .py extension for python in manifest")
path = "%s/%s" % (my.plugin_dir, path)
if not os.path.exists(path):
raise TacticException("Undo Path [%s] does not exist python in manifest" %path)
if path.endswith(".py"):
from tactic.command import PythonCmd
cmd = PythonCmd(file_path=path)
cmd.execute()
示例10: get_text_value
# 需要导入模块: from tactic.command import PythonCmd [as 别名]
# 或者: from tactic.command.PythonCmd import execute [as 别名]
def get_text_value(my):
sobject = my.get_current_sobject()
sobject_dict = sobject.get_sobject_dict()
try:
cmd = PythonCmd(code=my.code, sobject=sobject_dict)
result = cmd.execute()
except Exception, e:
return str(e)
示例11: get_display
# 需要导入模块: from tactic.command import PythonCmd [as 别名]
# 或者: from tactic.command.PythonCmd import execute [as 别名]
def get_display(my):
script_path = my.kwargs.get("script_path")
if not script_path:
return {}
python_cmd = PythonCmd(**my.kwargs)
ret_val = python_cmd.execute()
return ret_val
示例12: preprocess
# 需要导入模块: from tactic.command import PythonCmd [as 别名]
# 或者: from tactic.command.PythonCmd import execute [as 别名]
def preprocess(my):
code = my.kwargs.get('data')
if not code:
my.data = {}
return
# preprocess using mako
#include_mako = my.kwargs.get("include_mako")
#if not include_mako:
# include_mako = my.view_attrs.get("include_mako")
from tactic.command import PythonCmd
python_cmd = PythonCmd(code=code)
my.data = python_cmd.execute()
示例13: handle_include
# 需要导入模块: from tactic.command import PythonCmd [as 别名]
# 或者: from tactic.command.PythonCmd import execute [as 别名]
def handle_include(my, node):
path = my.xml.get_attribute(node, "path")
if not path:
raise TacticException("No path found for search type in manifest")
path = "%s/%s" % (my.plugin_dir, path)
if path.endswith(".py"):
from tactic.command import PythonCmd
cmd = PythonCmd(file_path=path)
manifest = cmd.execute()
xml = Xml()
xml.read_string(manifest)
nodes = xml.get_nodes("manifest/*")
nodes.reverse()
my.handle_nodes(nodes)
示例14: get_text_value
# 需要导入模块: from tactic.command import PythonCmd [as 别名]
# 或者: from tactic.command.PythonCmd import execute [as 别名]
def get_text_value(self):
sobject = self.get_current_sobject()
sobject_dict = sobject.get_sobject_dict()
try:
cmd = PythonCmd(code=self.code, sobject=sobject_dict)
result = cmd.execute()
except Exception as e:
return str(e)
if result == "":
return result
sobject.set_value(self.get_name(), result, temp=True)
display_format = self.get_option("display_format")
if display_format:
expr = "@FORMAT(@GET(.%s), '%s')" % (self.get_name(), display_format)
result = Search.eval(expr, sobject, single=True)
return result
示例15: PythonCmd
# 需要导入模块: from tactic.command import PythonCmd [as 别名]
# 或者: from tactic.command.PythonCmd import execute [as 别名]
# TODO: not sure if we need to make the distinction between
# a between a process script and a validation script. They
# basically do the same thing???
my.process_script = my.kwargs.get("process_script")
if my.process_script:
from tactic.command import PythonCmd
input = {
"path": path,
"sobject": my.sobject,
"parent": my.parent,
"snapshot": snapshot
}
process_cmd = PythonCmd(script_path=my.process_script, input=input)
result = process_cmd.execute()
if not result:
return
#print "keywords: ", keywords
#
# action
#