def driver(date, time, duration, rounds, teams, byes): #rounds = 4 #day = "2015-10-1" #time_of_day = 19 #duration = 2 date = date + ":" + time #time = datetime.timedelta(hours=time) duration = datetime.timedelta(hours=duration) date = datetime.datetime.strptime(date, "%Y-%m-%d:%H:%M") sg = schedule_generator.ScheduleGenerator(rounds, date, duration) times = sg.generate_start_times() print(times) rrg = round_robin_generator.RRMatchupGenerator(teams, rounds, byes) matchups = rrg.generate_matchups() print(matchups) with open("static/test.csv", 'wt') as file: writer = csv.writer(file) writer.writerow(('Team A', 'Team B', 'Time', 'Date')) for i in range(len(times)): time = times[i] date = time.strftime("%Y-%m-%d") time = time.strftime("%H:%M") round_matchups = matchups[i] for matchup in round_matchups: writer.writerow((matchup[0], matchup[1], time, date))
def test_generate_schedule(good_schedule): gen = schedule_generator.ScheduleGenerator('kod', 'c', good_schedule.get_schedule()) gen.run() assert gen.schedule[ 0] == "2019 12 01 00 00 3240 5 uafscan --stid kod --xcf 1 --fast --df 10400 --nf 10400 -c 3" assert gen.schedule[ 2] == "2019 12 03 12 00 4320 5 uafscan --stid kod --di --xcf 1 --fast --df 10400 --nf 10400 -c 3" assert gen.schedule[ 9] == "# >>> Schedule Note <<< The following entry is operating in the mode Special:THEMISSCAN" assert gen.schedule[ 10] == "2019 12 19 06 00 720 5 uafscan --stid kod --xcf 1 --fast --df 10400 --nf 10400 -c 3"
def test_generate_header(good_schedule): gen = schedule_generator.ScheduleGenerator('kod', 'c', good_schedule.get_schedule()) gen.generate_header() assert gen.header == 'path /home/radar/rst/usr/bin\n' \ 'default uafscan --stid kod --xcf 1 --fast --df 10400 --nf 10400 -c 3\n' \ 'stationid kod\n' \ 'sitelib ros\n' \ 'channel c\n' \ 'priority 1\n' \ 'duration a\n\n'
def create_schedule_for_wave(wave, date, rounds, duration, location, sublocations): rrg = round_robin_generator.RRMatchupGenerator(wave, rounds) matchups = rrg.generate_matchups() sg = schedule_generator.ScheduleGenerator(rounds, date, duration) times = sg.generate_start_times() with open("static/test.csv", 'a') as file: writer = csv.writer(file) for i in range(len(times)): time = times[i] date = time.strftime("%Y-%m-%d") time = time.strftime("%H:%M") round_matchups = matchups[i] j = 0 for matchup in round_matchups: writer.writerow((matchup[0], matchup[1], time, date, location, sublocations[j])) j += 1
if correct_schedule != 'y': quit() site_list = [] if not args.sitelist: site_list = [f"{args.site}.{args.channel}"] else: site_list = args.sitelist for site in site_list: frame_print(f"Generating Schedule for {site}") generator = schedule_generator.ScheduleGenerator( site.split('.')[0], site.split('.')[1], schedule.get_schedule()) generator.run() generator.print_schedule() correct_schedule = 'n' if not args.auto: correct_schedule = input( "Is the generated schedule correct? Enter 'y' if it is, 'n' if not: " ) else: correct_schedule = 'y' if args.append: write_mode = 'a' else: