本文整理汇总了Python中pyasm.command.Trigger.call_all_triggers方法的典型用法代码示例。如果您正苦于以下问题:Python Trigger.call_all_triggers方法的具体用法?Python Trigger.call_all_triggers怎么用?Python Trigger.call_all_triggers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.command.Trigger
的用法示例。
在下文中一共展示了Trigger.call_all_triggers方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _test_notification
# 需要导入模块: from pyasm.command import Trigger [as 别名]
# 或者: from pyasm.command.Trigger import call_all_triggers [as 别名]
def _test_notification(self):
sobject = SearchType.create("sthpw/notification")
sobject.set_value('subject', 'TACTIC Unittest 001: a new item has been added.')
sobject.set_value("event",'insert|unittest/country')
sobject.commit()
sobject = SearchType.create("sthpw/notification")
sobject.set_value('subject', 'TACTIC Unittest 002: an item has been updated.')
sobject.set_value("event",'update|unittest/country')
sobject.commit()
sobject = SearchType.create("sthpw/notification")
sobject.set_value('subject', 'TACTIC Unittest 003: New notes added.')
sobject.set_value("event",'insert|sthpw/note')
sobject.commit()
sobject = SearchType.create("sthpw/notification")
sobject.set_value('subject', 'TACTIC Unittest 004: New task assigned.')
sobject.set_value("event",'change|sthpw/task|status')
sobject.commit()
sobject = SearchType.create("sthpw/notification")
sobject.set_value('subject', 'TACTIC Unittest 005: task status has been changed.')
sobject.set_value("event",'change|sthpw/task|assigned')
sobject.commit()
sobject = SearchType.create("sthpw/notification")
sobject.set_value('subject', 'TACTIC Unittest 006: Files are checked in.')
sobject.set_value("event",'checkin|unittest/country')
sobject.commit()
# Item added
self.clear_notification()
sobject1 = SearchType.create("unittest/country")
sobject1.set_value('code', 'test_update_trigger')
sobject1.commit()
# Updated item
sobject1.set_value('code','success')
sobject1.commit()
# Note added
Note.create(self.person, "test note2", context='default2')
# Task assigned
sobject = Task.create(self.person,'hi','hellotest',assigned="test assigned")
# Task status changed
tasks = Task.get_by_sobject(self.person)
tasks[0].set_value('process','success')
tasks[0].commit()
# Files are checked in
file_path = "./notification_test_check.txt"
for i in range(0,4):
file = open(file_path, 'w')
file.write("whatever")
file.close()
checkin = FileCheckin(sobject1, file_path, "main", context='test', checkin_type='auto')
checkin.execute()
Trigger.call_all_triggers()
if os.path.exists(file_path):
os.remove(file_path)
示例2: execute
# 需要导入模块: from pyasm.command import Trigger [as 别名]
# 或者: from pyasm.command.Trigger import call_all_triggers [as 别名]
#.........这里部分代码省略.........
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:
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
# Write data into TACTIC_log file under /tmp/drop
f = open(log_path, 'a')
f.write(pre_log)
f.close()
#server.abort()
transaction.rollback()
raise
else:
transaction.commit()
#server.finish()
if server_return_value:
# Create the TACTIC_log file to record every check-in.
# Search for all required data
checkin_time=server_return_value.get('timestamp')
version_nu=server_return_value.get('version')
version_num=str(version_nu)
try:
value = parser.parse(checkin_time)
value = value.strftime("%Y/%m/%d %H:%M")
except:
value = checkin_time
pre_log=file_name+(50-len(file_name))*' '+value+(33-len(value))*' '+version_num+(15-len(version_num))*' ' +'ok\n'
# Write data into TACTIC_log file under /tmp/drop
f = open(log_path, 'a')
f.write(pre_log)
f.close()
# Invoke Trigger:called_triggers
from pyasm.command import Trigger
Trigger.call_all_triggers()
# Delete the source file after check-in step.
print "File handled."
if os.path.exists(file_path):
if os.path.isdir(file_path):
os.rmdirs(file_path)
else:
os.unlink(file_path)
print "Source file [%s] deleted: " %file_name