本文整理汇总了Python中tactic.command.PythonCmd类的典型用法代码示例。如果您正苦于以下问题:Python PythonCmd类的具体用法?Python PythonCmd怎么用?Python PythonCmd使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PythonCmd类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: verify
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
开发者ID:mincau,项目名称:TACTIC,代码行数:27,代码来源:ad_authenticate.py
示例2: delete_files
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)
开发者ID:talha81,项目名称:TACTIC-DEV,代码行数:32,代码来源:plugin.py
示例3: handle_include
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)
开发者ID:talha81,项目名称:TACTIC-DEV,代码行数:32,代码来源:plugin.py
示例4: get_result
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)
开发者ID:0-T-0,项目名称:TACTIC,代码行数:9,代码来源:python_element_wdg.py
示例5: get_text_value
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)
开发者ID:0-T-0,项目名称:TACTIC,代码行数:10,代码来源:python_element_wdg.py
示例6: get_display
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
开发者ID:0-T-0,项目名称:TACTIC,代码行数:11,代码来源:python_rest_handler.py
示例7: alter_search
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()
开发者ID:southpawtech,项目名称:TACTIC-DEV,代码行数:11,代码来源:custom_layout_wdg.py
示例8: get_display
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()
开发者ID:mincau,项目名称:TACTIC,代码行数:11,代码来源:checkin_trigger.py
示例9: preprocess
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()
开发者ID:southpawtech,项目名称:TACTIC-DEV,代码行数:14,代码来源:custom_layout_wdg.py
示例10: handle_include
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)
开发者ID:blezek,项目名称:TACTIC,代码行数:18,代码来源:plugin.py
示例11: handle_python
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()
开发者ID:talha81,项目名称:TACTIC-DEV,代码行数:19,代码来源:plugin.py
示例12: get_text_value
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
开发者ID:mincau,项目名称:TACTIC,代码行数:20,代码来源:python_element_wdg.py
示例13: run_callback
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
开发者ID:jayvdb,项目名称:TACTIC,代码行数:56,代码来源:workflow.py
示例14: handle_action
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)
开发者ID:jayvdb,项目名称:TACTIC,代码行数:46,代码来源:workflow.py
示例15: execute
def execute(my):
file_path = my.kwargs.get("path")
project_code = my.kwargs.get("project_code")
base_dir = my.kwargs.get("base_dir")
search_type = my.kwargs.get("search_type")
process = my.kwargs.get("process")
watch_script_path = my.kwargs.get("script_path")
if not process:
process = "publish"
basename = os.path.basename(file_path)
context = my.kwargs.get("context")
if not context:
context = '%s/%s' % (process, basename)
# find the relative_dir and relative_path
relative_path = file_path.replace("%s/" % base_dir, "")
relative_dir = os.path.dirname(relative_path)
file_name = os.path.basename(file_path)
log_path = '%s/TACTIC_log.txt' %(base_dir)
my.create_checkin_log()
# Define asset type of the file
asset_type = my.get_asset_type(file_path)
description = "drop folder check-in of %s" %file_name
from client.tactic_client_lib import TacticServerStub
server = TacticServerStub.get(protocol='local')
server.set_project(project_code)
transaction = Transaction.get(create=True)
server.start(title='Check-in of media', description='Check-in of media')
server_return_value = {}
try:
filters = [
[ 'name', '=', file_name ],
#[ 'relative_dir', '=', relative_dir ]
]
sobj = server.query(search_type, filters=filters, single=True)
if not sobj:
# create sobject if it does not yet exist
sobj = SearchType.create(search_type)
if SearchType.column_exists(search_type, "name"):
sobj.set_value("name", basename)
if SearchType.column_exists(search_type, "media_type"):
sobj.set_value("media_type", asset_type)
if SearchType.column_exists(search_type, "relative_dir"):
sobj.set_value("relative_dir", relative_dir)
if SearchType.column_exists(search_type, "keywords"):
relative_path = relative_path
keywords = Common.get_keywords_from_path(relative_path)
keywords = " ".join( keywords )
sobj.set_value("keywords", keywords)
sobj.commit()
search_key = sobj.get_search_key()
else:
search_key = sobj.get("__search_key__")
#task = server.create_task(sobj.get('__search_key__'),process='publish')
#server.update(task, {'status': 'New'})
server_return_value = server.simple_checkin(search_key, context, file_path, description=description, mode='move')
if watch_script_path:
cmd = PythonCmd(script_path=watch_script_path,search_type=search_type,drop_path=file_path,search_key=search_key)
cmd.execute()
except Exception, e:
print "Error occurred", e
error_message=str(e)
import traceback
tb = sys.exc_info()[2]
stacktrace = traceback.format_tb(tb)
stacktrace_str = "".join(stacktrace)
print "-"*50
print stacktrace_str
version_num='Error:'
system_time=strftime("%Y/%m/%d %H:%M", gmtime())
pre_log=file_name+(50-len(file_name))*' '+system_time+(33-len(system_time))*' '+version_num+(15-len(version_num))*' ' +error_message+'\n'\
+ stacktrace_str + '\n' + watch_script_path
#.........这里部分代码省略.........
开发者ID:0-T-0,项目名称:TACTIC,代码行数:101,代码来源:watch_drop_folder.py
示例16: PythonCmd
return
# 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
#
开发者ID:0-T-0,项目名称:TACTIC,代码行数:31,代码来源:ingestion_cmd.py
示例17: Xml
if manifest:
xml = Xml()
xml.read_string(manifest)
nodes = xml.get_nodes("manifest/*")
my.import_manifest(nodes)
elif node_name == 'python':
path = my.xml.get_attribute(node, "path")
path = "%s/%s" % (my.plugin_dir, path)
# just run the python script
from tactic.command import PythonCmd
cmd = PythonCmd(file_path=path)
cmd.execute()
''' TODO: do we store the transaction here???
try:
from pyasm.search import Transaction
transaction = Transaction.get()
transaction_str = transaction.xml.to_string()
my.plugin.set_value("transaction", transaction_str)
my.plugin.commit()
开发者ID:talha81,项目名称:TACTIC-DEV,代码行数:30,代码来源:plugin.py
示例18: process_path
def process_path(my, path, pattern, checkin_type):
is_matched = my.process_pattern(path, pattern)
if not is_matched:
return
status = my.kwargs.get("mode")
action_type = my.kwargs.get("action_type")
if action_type == 'ignore':
print "ignoring: ", path
(mode, ino, dev, nlink, uid, gid, size, atime, mtime, ctime) = os.stat(path)
my.data[path] = {
'size': size,
'ctime': ctime,
'status': status
}
return
search_key = my.kwargs.get("search_key")
search_type = my.kwargs.get("search_type")
# create an sobject to store data
if search_key:
my.sobject = Search.get_by_search_key(search_key)
my.parent = my.sobject.get_parent()
elif search_type:
code = my.sobject_tags.get("code")
id = my.sobject_tags.get("id")
if code:
my.sobject = Search.get_by_code(search_type, code)
elif id:
my.sobject = Search.get_by_id(search_type, code)
else:
my.sobject = None
if not my.sobject:
# create a new sobject
my.sobject = SearchType.create(search_type)
my.parent = None
# create a snapshot to store snapshot data
snapshot = SearchType.create("sthpw/snapshot")
# extras
keywords = []
search_type_sobj = SearchType.get(search_type)
# create the new sobject
for name, value in my.sobject_tags.items():
if search_type_sobj.column_exists(name):
my.sobject.set_value(name, value)
keywords.append(value)
extra_names = my.kwargs.get("extra_name")
extra_values = my.kwargs.get("extra_value")
for name, value in zip(extra_names, extra_values):
if not name:
continue
if search_type_sobj.column_exists(name):
my.sobject.set_value(name, value)
keywords.append(value)
extra_keywords = my.kwargs.get("keywords")
if extra_keywords:
extra_keywords = extra_keywords.split(",")
for k in extra_keywords:
keywords.append(k)
#has_keyword = True
#if has_keyword:
if search_type_sobj.column_exists('keywords'):
keywords = " ".join(keywords)
my.sobject.set_value("keywords", keywords)
my.validation_script = my.kwargs.get("validation_script")
if my.validation_script:
from tactic.command import PythonCmd
input = {
"path": path,
"sobject": my.sobject,
"parent": my.parent,
"snapshot": snapshot
}
validation_cmd = PythonCmd(script_path=my.validation_script, input=input, IngestException=IngestException)
try:
result = validation_cmd.execute()
except IngestException, e:
print e.message
#.........这里部分代码省略.........
开发者ID:0-T-0,项目名称:TACTIC,代码行数:101,代码来源:ingestion_cmd.py
示例19: get_from_db_naming
def get_from_db_naming(my, search_type):
project_code = Project.get_project_code()
if project_code in ["admin", "sthpw"]:
return ""
file_type = my.get_file_type()
filename = my.file_object.get_full_file_name()
naming = Naming.get(my.sobject, my.snapshot, file_path=filename)
if not naming:
return None
if naming and my.checkin_type:
checkin_type = naming.get_value('checkin_type')
if checkin_type and my.checkin_type != checkin_type:
print "mismatched checkin_type!"
naming = None
return None
naming_util = NamingUtil()
# Provide a mechanism for a custom class
naming_class = naming.get_value("class_name", no_exception=True)
if naming_class:
kwargs = {
'sobject': my.sobject,
'snapshot': my.snapshot,
'file_object': my.file_object,
'ext': my.get_ext(),
'mode': 'file'
}
naming = Common.create_from_class_path(naming_class, kwargs)
filename = naming.get_file()
if filename:
return filename
# provide a mechanism for a custom client side script
script_path = naming.get_value("script_path", no_exception=True)
if script_path:
project_code = my.sobject.get_project_code()
input = {
'sobject': my.sobject,
'snapshot': my.snapshot,
'file_object': my.file_object,
'ext': my.get_ext(),
'mode': 'file',
'project': project_code
}
from tactic.command import PythonCmd
cmd = PythonCmd(script_path=script_path, input=input)
results = cmd.execute()
if results:
return results
naming_value = naming.get_value("file_naming")
if not naming_value:
is_versionless = naming.get_value("latest_versionless") or naming.get_value("current_versionless")
if not is_versionless:
return ""
# FIXME:
# if this is a versionless naming, then empty uses a default
# This is put here because the check-in type is determined by the
# naming here. Normally, this is passed through with "naming_expr"
# but in snapshot.py, it is not yet known that this is an "auto"
# checkin_type because it is defined in the naming and not the
# process
server = Config.get_value("install", "server")
if server:
naming_value= "{basefile}_{snapshot.process}_%s.{ext}" % server
else:
naming_value = "{basefile}_{snapshot.process}.{ext}"
# check for manual_version
manual_version = naming.get_value('manual_version')
if manual_version == True:
# if the file version is not the same as the snapshot version
# then check to see if the snapshot already exists
filename = my.file_object.get_full_file_name()
version = my.get_version_from_file_name(filename)
context = my.snapshot.get_context()
if version > 0 and version != my.snapshot.get_value("version"):
existing_snap = Snapshot.get_snapshot(\
my.snapshot.get_value("search_type"),\
my.snapshot.get_value("search_id"), context=context, \
version=version, show_retired=True)
if existing_snap:
raise TacticException('You have chosen manual version in Naming for this SObject. A snapshot with context "%s" and version "%s" already exists.' % (context, version) )
my.snapshot.set_value("version", version)
#.........这里部分代码省略.........
开发者ID:0-T-0,项目名称:TACTIC,代码行数:101,代码来源:file_naming.py
示例20: execute
def execute(self):
file_path = self.kwargs.get("path")
site = self.kwargs.get("site")
project_code = self.kwargs.get("project_code")
base_dir = self.kwargs.get("base_dir")
search_type = self.kwargs.get("search_type")
process = self.kwargs.get("process")
watch_script_path = self.kwargs.get("script_path")
if not process:
process = "publish"
basename = os.path.basename(file_path)
context = self.kwargs.get("context")
if not context:
context = '%s/%s' % (process, basename)
# find the relative_dir and relative_path
relative_path = file_path.replace("%s/" % base_dir, "")
relative_dir = os.path.dirname(relative_path)
file_name = os.path.basename(file_path)
log_path = '%s/TACTIC_log.txt' %(base_dir)
self.create_checkin_log()
# Define asset type of the file
asset_type = self.get_asset_type(file_path)
description = "drop folder check-in of %s" %file_name
from client.tactic_client_lib import TacticServerStub
server = TacticServerStub.get(protocol='local')
server.set_project(project_code)
transaction = Transaction.get(create=True)
server.start(title='Check-in of media', description='Check-in of media')
server_return_value = {}
try:
filters = [
[ 'name', '=', file_name ],
#[ 'relative_dir', '=', relative_dir ]
]
sobj = server.query(search_type, filters=filters, single=True)
if not sobj:
# create sobject if it does not yet exist
sobj = SearchType.create(search_type)
if SearchType.column_exists(search_type, "name"):
sobj.set_value("name", basename)
if SearchType.column_exists(search_type, "media_type"):
sobj.set_value("media_type", asset_type)
if SearchType.column_exists(search_type, "relative_dir"):
sobj.set_value("relative_dir", relative_dir)
if SearchType.column_exists(search_type, "keywords"):
relative_path = relative_path
keywords = Common.extract_keywords_from_path(relative_path)
keywords = " ".join( keywords )
sobj.set_value("keywords", keywords)
sobj.commit()
search_key = sobj.get_search_key()
else:
search_key = sobj.get("__search_key__")
#task = server.create_task(sobj.get('__search_key__'),process='publish')
#server.update(task, {'status': 'New'})
"""
#TEST: simulate different check-in duration
from random import randint
sec = randint(1, 5)
print "checking in for ", sec, "sec"
server.eval("@SOBJECT(sthpw/login)")
import shutil
dir_name,base_name = os.path.split(file_path)
dest_dir = 'C:/ProgramData/Southpaw/watch_temp'
if not os.path.exists(dest_dir):
os.makedirs(dest_dir)
shutil.move(file_path, '%s/%s'%(dest_dir, base_name))
time.sleep(sec)
# move back the file in a few seconds
shutil.move('%s/%s'%(dest_dir, base_name), file_path)
"""
server_return_value = server.simple_checkin(search_key, context, file_path, description=description, mode='move')
if watch_script_path:
cmd = PythonCmd(script_path=watch_script_path,search_type=search_type,drop_path=file_path,search_key=search_key)
cmd.execute()
except Exception as e:
#.........这里部分代码省略.........
开发者ID:mincau,项目名称:TACTIC,代码行数:101,代码来源:watch_drop_folder.py
注:本文中的tactic.command.PythonCmd类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论