#!/usr/bin/env python # -*- coding: utf-8 -*- import os import sys import unittest from application import app from application import config if __name__ == '__main__': app.init('./conf/unittest.ini') topLevelDir = os.path.abspath(os.path.dirname(__file__) + '/../') startDir = topLevelDir if len(sys.argv) >= 2: startDir = topLevelDir + '/' + sys.argv[1] if os.path.isfile(startDir): testDir = os.path.dirname(startDir) fileName = os.path.basename(startDir) discover = unittest.defaultTestLoader.discover( testDir, pattern=fileName, top_level_dir=topLevelDir) else: if len(sys.argv) >= 3: pattern = sys.argv[2] else: pattern = 'test*.py' discover = unittest.defaultTestLoader.discover( startDir, pattern=pattern, top_level_dir=topLevelDir)
help='指定的唯一任务名,必选,对应的增量更新进程需要指定同样的值。') parser.add_argument( '-a', '--action', type=str, action='store', default='update', help= '指定的动作,默认是update。目前只支持update、reset和clean: update, 全量更新;reset, 重置任务状态,通常在全量更新失败执行reset;clean, 清理脏数据,脏数据通常是因为全量更新失败造成的。' ) return parser if __name__ == '__main__': prjRoot = os.path.abspath(os.path.dirname(__file__)) app.init(prjRoot + '/conf/app.ini') argParser = validate_parser() args = argParser.parse_args() if os.path.isabs(args.config): handlerConfigPath = args.config else: handlerConfigPath = prjRoot + '/conf/handlers/' + args.config action = args.action name = args.name print('action is %s ' % action) print('handler config path is %s' % handlerConfigPath) print('task name is %s' % name)