def vars_map(self, key, value, init_day, format=None): init_date = DateUtil.parse_date(init_day, None) if key == 'today': if value is None: return DateUtil.get_now_fmt(format, init_date) else: return value elif key == 'yesterday': if value is None: return DateUtil.get_yesterday_fmt(format, init_date) else: return value elif key == 'intervalday': if value is None: raise Exception("interval day is none") return DateUtil.get_interval_day_fmt(int(value), format, init_date) elif key == 'lastMonth': if value is None: return DateUtil.get_last_month(init_date) else: return value elif key == 'currentMonth': if value is None: return DateUtil.get_current_month(init_date) else: return value elif key == 'yesterdayMonth': if value is None: return DateUtil.get_yesterday_month(init_date) else: return value else: return value
reload(sys) sys.setdefaultencoding('utf-8') run_yaml = RunYaml() optParser = run_yaml.option_parser() options, args = optParser.parse_args(sys.argv[1:]) if options.path is None: print("require yaml file") optParser.print_help() sys.exit(-1) start = options.start end = options.end if start is None: start = DateUtil.parse_date(DateUtil.get_now_fmt()) else: start = DateUtil.parse_date(start) if end is None: end = DateUtil.parse_date(DateUtil.get_now_fmt()) else: end = DateUtil.parse_date(end) run_code = [] for p_day in DateUtil.get_list_day(start, end): print "运行时设置的日期:", p_day code = run_yaml.run_command(options.path, p_day) run_code.append(str(code)) if code != 0: sys.exit(1) code_str = ",".join(run_code)