本文整理匯總了Python中tester.Tester.commit方法的典型用法代碼示例。如果您正苦於以下問題:Python Tester.commit方法的具體用法?Python Tester.commit怎麽用?Python Tester.commit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tester.Tester
的用法示例。
在下文中一共展示了Tester.commit方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: email_receiver
# 需要導入模塊: from tester import Tester [as 別名]
# 或者: from tester.Tester import commit [as 別名]
def email_receiver(cmd,msg):
T = Tester()
T.newtest(testname=cmd)
# Save the received email mesasge in the database
messageid = T.insert_email_message(tester.EMAIL_TAG_USER_SENT,str(msg))
args = {"messageid":messageid,"cmd":cmd}
# Depending on the command, institute the next step...
if cmd=="bouncer":
T.insert_task(tester.TASK_COMPOSE_SIMPLE_RESPONSE, args)
T.commit()
elif cmd=="register":
T.insert_task(tester.TASK_REGISTER_FROM_EMAIL, args)
T.commit()
else:
# Log invalid command
logging.info("Invalid command: {} Message {}".format(cmd,messageid))
示例2: periodic
# 需要導入模塊: from tester import Tester [as 別名]
# 或者: from tester.Tester import commit [as 別名]
def periodic():
from tester import Tester
import argparse
parser = argparse.ArgumentParser(description="database maintenance")
parser.add_argument("--debug", action="store_true")
parser.add_argument("--list", help="List all of the tasks", action="store_true")
args = parser.parse_args()
W = Tester() # get a database connection
c = W.conn.cursor()
if args.list:
c.execute("select workqueueid,testid,created,completed from workqueue")
for line in c:
print(line)
exit(0)
# Run the queue until there is nothing left to run
while True:
c.execute("select workqueueid,testid,task,args from workqueue where isnull(completed)")
count = 0
for (workqueueid, testid, task, task_args_str) in c.fetchall():
count += 1
T = Tester(testid=testid)
task_args = json.loads(task_args_str)
if args.debug or debug:
print("task_args=", task_args)
task_args["state"] = "WORKING"
logging.info("testid={} task={} task_args={}".format(testid, task, task_args))
if eval(task + "(T,task_args)"):
c.execute("update workqueue set completed=now() where workqueueid=%s", (workqueueid,))
W.commit()
if count == 0:
break
示例3: len
# 需要導入模塊: from tester import Tester [as 別名]
# 或者: from tester.Tester import commit [as 別名]
if len(args.name)!=1:
print("Error: One name must be provided")
exit(1)
name = args.name[0]
print("DBDNS DEMO")
T = Tester()
T.newtest(testname="dig")
print("dig -t {} {}".format(args.t,name))
print("TestID: {}".format(T.testid))
response = dbdns.query(T,name,args.t)
for part in range(len(response.answer)):
print("ANSWER PART {}:".format(part))
for i in range(len(response.answer[part])):
print("RR {}: {} {}".format(i,response.answer[part][i],type(response.answer[part][i])))
T.commit()
print("\n\n\nReplay:")
response = dbdns.query(T,name,args.t,replay=True)
for part in range(len(response.answer)):
print("ANSWER PART {}:".format(part))
for i in range(len(b.answer[part])):
print("RR {}: {} {}".format(i,
response.answer[part][i],
type(response.answer[part][i])))
if args.mxdemo:
print("MX hosts for dnspython.org:")
print("")
print("Traditional dnspython MX resolution:")
a = dns.resolver.query("dnspython.org","MX")