print "No args. Use default!" logLevel = 'DEBUG' testenv = 'test' if UsualTools.isWindowsSystem(): print u"windows不能运行任务取消!" elif UsualTools.isMacOS(): print u"macOS不能运行任务取消!" ################################################################################################## #初始化数据库配置conf sc = ServiceConf(testenv) db = DBTool(sc.dbhost, sc.dbport, sc.dbusername, sc.dbpassword, sc.dbname) conf_path = "" if UsualTools.isLinuxSystem(): #正式环境 conf_path = "/home" elif UsualTools.isWindowsSystem(): #王吉亮测试环境 conf_path = "D:/devcodes/DubboInterfaceTestFramework/DubboInterfaceTestFramework" elif UsualTools.isMacOS(): #liyaochao测试环境 conf_path = "/home" commonRetCode, commnonConfig = getConfFromDB(db, "commonconf", confPath=conf_path + "/taskCancelcommonconf.conf") commonDict = commnonConfig.conf_dict db.release() if commonRetCode['errorCode'] != '10000': print u"没有得到commonconf配置文件!" sys.exit(0)
import sys reload(sys) sys.setdefaultencoding('utf8') sys.path.append("..") from Lib.UsualTools import UsualTools import os, subprocess from Lib.DBTool import DBTool import logging import time from Config.Config import Config if __name__ == "__main__": if UsualTools.isLinuxSystem(): logging.basicConfig( level='INFO', format= '%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s', datefmt='%a, %d %b %Y %H:%M:%S', filename='/home/InterfaceFrameworkOnline/logs/runtask.log', filemode='w') # 循环遍历t_task表,顺序执行任务,执行时把state变成2,执行后变成3. conf = Config("../ConfFile/platform.conf").conf_dict while True: db = DBTool(conf['db']['host'], int(conf['db']['port']), conf['db']['username'], conf['db']['password'], conf['db']['dbname']) results = db.execute_sql( "select * from tb_taskpython where state=1 or state=2 order by create_time asc"