import time


def _cyclic_location_selection(locations, period):
    """Return one of `locations` (: separated list)
    basing on the current time and query interval `period`
    """

    locations = locations.split(':')
    max_len = max(len(x) for x in locations)
    locations = [x.rjust(max_len) for x in locations]

    try:
        period = int(period)
    except ValueError:
        period = 1

    index = int(time.time()/period) % len(locations)
    return locations[index]